-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Type catch-all params * Add tx schema and inferred type * Use Tx type in Mermaid * Use tx schema and type in txs * Use tx schema and type in tx detail
- Loading branch information
Showing
5 changed files
with
83 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,36 @@ | ||
export type Tx = { | ||
_id: string; | ||
_source: { | ||
traceID: string; | ||
spanID: string; | ||
operationName: string; | ||
references: Array<{ refType: string; traceID: string; spanID: string }>; | ||
tags: Array<{ key: string; type: string; value: string }>; | ||
}; | ||
}; | ||
import { z } from "zod"; | ||
|
||
export const TxSchema = z | ||
.object({ | ||
_id: z.string(), | ||
_source: z.object({ | ||
traceID: z.string(), | ||
spanID: z.string(), | ||
operationName: z.string(), | ||
references: z.array( | ||
z.object({ | ||
refType: z.string(), | ||
traceID: z.string(), | ||
spanID: z.string(), | ||
}), | ||
), | ||
tags: z.array( | ||
z.object({ key: z.string(), type: z.string(), value: z.string() }), | ||
), | ||
}), | ||
}) | ||
.transform((v) => ({ | ||
//NOTE - Using _id for React keyprop for now since I found different spans with same spanId | ||
_id: v._id, | ||
traceId: v._source.traceID, | ||
spanId: v._source.spanID, | ||
operationName: v._source.operationName, | ||
parentSpanId: | ||
v._source.references.find( | ||
(ref) => | ||
ref.traceID === v._source.traceID && ref.refType === "CHILD_OF", | ||
)?.spanID ?? null, | ||
tags: new Map(v._source.tags.map(({ key, value }) => [key, value])), | ||
})); | ||
|
||
export type Tx = Readonly<z.infer<typeof TxSchema>>; |