vident-sdk 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/README.md +216 -0
  2. package/dist/client.d.ts +100 -0
  3. package/dist/client.d.ts.map +1 -0
  4. package/dist/client.js +249 -0
  5. package/dist/client.js.map +1 -0
  6. package/dist/context.d.ts +15 -0
  7. package/dist/context.d.ts.map +1 -0
  8. package/dist/context.js +41 -0
  9. package/dist/context.js.map +1 -0
  10. package/dist/errors.d.ts +18 -0
  11. package/dist/errors.d.ts.map +1 -0
  12. package/dist/errors.js +35 -0
  13. package/dist/errors.js.map +1 -0
  14. package/dist/http.d.ts +4 -0
  15. package/dist/http.d.ts.map +1 -0
  16. package/dist/http.js +60 -0
  17. package/dist/http.js.map +1 -0
  18. package/dist/index.d.ts +19 -0
  19. package/dist/index.d.ts.map +1 -0
  20. package/dist/index.js +21 -0
  21. package/dist/index.js.map +1 -0
  22. package/dist/instrument/aws-sdk.d.ts +9 -0
  23. package/dist/instrument/aws-sdk.d.ts.map +1 -0
  24. package/dist/instrument/aws-sdk.js +57 -0
  25. package/dist/instrument/aws-sdk.js.map +1 -0
  26. package/dist/instrument/fetch.d.ts +15 -0
  27. package/dist/instrument/fetch.d.ts.map +1 -0
  28. package/dist/instrument/fetch.js +124 -0
  29. package/dist/instrument/fetch.js.map +1 -0
  30. package/dist/instrument/handler.d.ts +40 -0
  31. package/dist/instrument/handler.d.ts.map +1 -0
  32. package/dist/instrument/handler.js +90 -0
  33. package/dist/instrument/handler.js.map +1 -0
  34. package/dist/instrument/hono.d.ts +4 -0
  35. package/dist/instrument/hono.d.ts.map +1 -0
  36. package/dist/instrument/hono.js +130 -0
  37. package/dist/instrument/hono.js.map +1 -0
  38. package/dist/instrument/index.d.ts +7 -0
  39. package/dist/instrument/index.d.ts.map +1 -0
  40. package/dist/instrument/index.js +6 -0
  41. package/dist/instrument/index.js.map +1 -0
  42. package/dist/instrument/prisma.d.ts +25 -0
  43. package/dist/instrument/prisma.d.ts.map +1 -0
  44. package/dist/instrument/prisma.js +73 -0
  45. package/dist/instrument/prisma.js.map +1 -0
  46. package/dist/instrument/types.d.ts +7 -0
  47. package/dist/instrument/types.d.ts.map +1 -0
  48. package/dist/instrument/types.js +2 -0
  49. package/dist/instrument/types.js.map +1 -0
  50. package/dist/resources/api-keys.d.ts +10 -0
  51. package/dist/resources/api-keys.d.ts.map +1 -0
  52. package/dist/resources/api-keys.js +17 -0
  53. package/dist/resources/api-keys.js.map +1 -0
  54. package/dist/resources/channels.d.ts +16 -0
  55. package/dist/resources/channels.d.ts.map +1 -0
  56. package/dist/resources/channels.js +38 -0
  57. package/dist/resources/channels.js.map +1 -0
  58. package/dist/resources/checks.d.ts +15 -0
  59. package/dist/resources/checks.d.ts.map +1 -0
  60. package/dist/resources/checks.js +44 -0
  61. package/dist/resources/checks.js.map +1 -0
  62. package/dist/resources/events.d.ts +25 -0
  63. package/dist/resources/events.d.ts.map +1 -0
  64. package/dist/resources/events.js +122 -0
  65. package/dist/resources/events.js.map +1 -0
  66. package/dist/resources/metrics.d.ts +24 -0
  67. package/dist/resources/metrics.d.ts.map +1 -0
  68. package/dist/resources/metrics.js +121 -0
  69. package/dist/resources/metrics.js.map +1 -0
  70. package/dist/resources/organizations.d.ts +12 -0
  71. package/dist/resources/organizations.d.ts.map +1 -0
  72. package/dist/resources/organizations.js +23 -0
  73. package/dist/resources/organizations.js.map +1 -0
  74. package/dist/resources/projects.d.ts +12 -0
  75. package/dist/resources/projects.d.ts.map +1 -0
  76. package/dist/resources/projects.js +35 -0
  77. package/dist/resources/projects.js.map +1 -0
  78. package/dist/resources/tracing.d.ts +26 -0
  79. package/dist/resources/tracing.d.ts.map +1 -0
  80. package/dist/resources/tracing.js +320 -0
  81. package/dist/resources/tracing.js.map +1 -0
  82. package/dist/sampler.d.ts +61 -0
  83. package/dist/sampler.d.ts.map +1 -0
  84. package/dist/sampler.js +73 -0
  85. package/dist/sampler.js.map +1 -0
  86. package/dist/trace-context.d.ts +31 -0
  87. package/dist/trace-context.d.ts.map +1 -0
  88. package/dist/trace-context.js +60 -0
  89. package/dist/trace-context.js.map +1 -0
  90. package/dist/types.d.ts +256 -0
  91. package/dist/types.d.ts.map +1 -0
  92. package/dist/types.js +33 -0
  93. package/dist/types.js.map +1 -0
  94. package/package.json +52 -0
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Sampler abstraction for trace sampling decisions.
3
+ * Follows OpenTelemetry Sampler specification patterns.
4
+ *
5
+ * @see https://opentelemetry.io/docs/specs/otel/trace/sdk/#sampler
6
+ */
7
+ export type SamplingDecision = "RECORD_AND_SAMPLE" | "DROP";
8
+ export type ParentContext = {
9
+ traceId: string;
10
+ spanId: string;
11
+ /** Whether parent came from a remote service (traceparent header) */
12
+ isRemote: boolean;
13
+ /** Parent's sampling decision (from traceparent flags or local span) */
14
+ sampled: boolean;
15
+ };
16
+ export type SamplingContext = {
17
+ traceId: string;
18
+ name: string;
19
+ parentContext?: ParentContext;
20
+ };
21
+ export type Sampler = {
22
+ shouldSample(context: SamplingContext): SamplingDecision;
23
+ readonly description: string;
24
+ };
25
+ /**
26
+ * Always samples - use for development or when you want 100% traces.
27
+ */
28
+ export declare function alwaysOnSampler(): Sampler;
29
+ /**
30
+ * Never samples - use to disable tracing entirely.
31
+ */
32
+ export declare function alwaysOffSampler(): Sampler;
33
+ /**
34
+ * Samples based on a probability ratio (0.0 to 1.0).
35
+ * Uses Math.random() for simplicity - not deterministic across services.
36
+ */
37
+ export declare function traceIdRatioSampler(ratio: number): Sampler;
38
+ export type ParentBasedSamplerOptions = {
39
+ /** Sampler for new traces (no parent) */
40
+ root: Sampler;
41
+ /** Sampler when remote parent was sampled (default: AlwaysOn) */
42
+ remoteParentSampled?: Sampler;
43
+ /** Sampler when remote parent was not sampled (default: AlwaysOff) */
44
+ remoteParentNotSampled?: Sampler;
45
+ /** Sampler when local parent was sampled (default: AlwaysOn) */
46
+ localParentSampled?: Sampler;
47
+ /** Sampler when local parent was not sampled (default: AlwaysOff) */
48
+ localParentNotSampled?: Sampler;
49
+ };
50
+ /**
51
+ * Makes sampling decisions based on parent span's decision.
52
+ * This is the recommended default sampler for distributed tracing.
53
+ *
54
+ * - Remote parent sampled (traceparent with sampled=1): sample
55
+ * - Remote parent not sampled: don't sample
56
+ * - Local parent sampled: sample
57
+ * - Local parent not sampled: don't sample
58
+ * - No parent: delegate to root sampler
59
+ */
60
+ export declare function parentBasedSampler(options: ParentBasedSamplerOptions): Sampler;
61
+ //# sourceMappingURL=sampler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sampler.d.ts","sourceRoot":"","sources":["../src/sampler.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,MAAM,gBAAgB,GAAG,mBAAmB,GAAG,MAAM,CAAA;AAE3D,MAAM,MAAM,aAAa,GAAG;IAC3B,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;IACd,qEAAqE;IACrE,QAAQ,EAAE,OAAO,CAAA;IACjB,wEAAwE;IACxE,OAAO,EAAE,OAAO,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC7B,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,aAAa,CAAC,EAAE,aAAa,CAAA;CAC7B,CAAA;AAED,MAAM,MAAM,OAAO,GAAG;IACrB,YAAY,CAAC,OAAO,EAAE,eAAe,GAAG,gBAAgB,CAAA;IACxD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;CAC5B,CAAA;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,OAAO,CAKzC;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,OAAO,CAK1C;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAW1D;AAED,MAAM,MAAM,yBAAyB,GAAG;IACvC,yCAAyC;IACzC,IAAI,EAAE,OAAO,CAAA;IACb,iEAAiE;IACjE,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,sEAAsE;IACtE,sBAAsB,CAAC,EAAE,OAAO,CAAA;IAChC,gEAAgE;IAChE,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,qEAAqE;IACrE,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAC/B,CAAA;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CACjC,OAAO,EAAE,yBAAyB,GAChC,OAAO,CAgCT"}
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Sampler abstraction for trace sampling decisions.
3
+ * Follows OpenTelemetry Sampler specification patterns.
4
+ *
5
+ * @see https://opentelemetry.io/docs/specs/otel/trace/sdk/#sampler
6
+ */
7
+ /**
8
+ * Always samples - use for development or when you want 100% traces.
9
+ */
10
+ export function alwaysOnSampler() {
11
+ return {
12
+ shouldSample: () => "RECORD_AND_SAMPLE",
13
+ description: "AlwaysOnSampler",
14
+ };
15
+ }
16
+ /**
17
+ * Never samples - use to disable tracing entirely.
18
+ */
19
+ export function alwaysOffSampler() {
20
+ return {
21
+ shouldSample: () => "DROP",
22
+ description: "AlwaysOffSampler",
23
+ };
24
+ }
25
+ /**
26
+ * Samples based on a probability ratio (0.0 to 1.0).
27
+ * Uses Math.random() for simplicity - not deterministic across services.
28
+ */
29
+ export function traceIdRatioSampler(ratio) {
30
+ const normalizedRatio = Math.max(0, Math.min(1, ratio));
31
+ if (normalizedRatio === 0)
32
+ return alwaysOffSampler();
33
+ if (normalizedRatio === 1)
34
+ return alwaysOnSampler();
35
+ return {
36
+ shouldSample: () => Math.random() < normalizedRatio ? "RECORD_AND_SAMPLE" : "DROP",
37
+ description: `TraceIdRatioSampler{${normalizedRatio}}`,
38
+ };
39
+ }
40
+ /**
41
+ * Makes sampling decisions based on parent span's decision.
42
+ * This is the recommended default sampler for distributed tracing.
43
+ *
44
+ * - Remote parent sampled (traceparent with sampled=1): sample
45
+ * - Remote parent not sampled: don't sample
46
+ * - Local parent sampled: sample
47
+ * - Local parent not sampled: don't sample
48
+ * - No parent: delegate to root sampler
49
+ */
50
+ export function parentBasedSampler(options) {
51
+ const { root, remoteParentSampled = alwaysOnSampler(), remoteParentNotSampled = alwaysOffSampler(), localParentSampled = alwaysOnSampler(), localParentNotSampled = alwaysOffSampler(), } = options;
52
+ return {
53
+ shouldSample: (context) => {
54
+ const { parentContext } = context;
55
+ // No parent - new trace, use root sampler
56
+ if (!parentContext) {
57
+ return root.shouldSample(context);
58
+ }
59
+ // Remote parent (from traceparent header)
60
+ if (parentContext.isRemote) {
61
+ return parentContext.sampled
62
+ ? remoteParentSampled.shouldSample(context)
63
+ : remoteParentNotSampled.shouldSample(context);
64
+ }
65
+ // Local parent (same process)
66
+ return parentContext.sampled
67
+ ? localParentSampled.shouldSample(context)
68
+ : localParentNotSampled.shouldSample(context);
69
+ },
70
+ description: `ParentBasedSampler{root=${root.description}}`,
71
+ };
72
+ }
73
+ //# sourceMappingURL=sampler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sampler.js","sourceRoot":"","sources":["../src/sampler.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAwBH;;GAEG;AACH,MAAM,UAAU,eAAe;IAC9B,OAAO;QACN,YAAY,EAAE,GAAG,EAAE,CAAC,mBAAmB;QACvC,WAAW,EAAE,iBAAiB;KAC9B,CAAA;AACF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB;IAC/B,OAAO;QACN,YAAY,EAAE,GAAG,EAAE,CAAC,MAAM;QAC1B,WAAW,EAAE,kBAAkB;KAC/B,CAAA;AACF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAa;IAChD,MAAM,eAAe,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAA;IAEvD,IAAI,eAAe,KAAK,CAAC;QAAE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
@@ -0,0 +1,31 @@
1
+ /**
2
+ * W3C Trace Context utilities for distributed tracing.
3
+ * Implements the W3C Trace Context specification:
4
+ * https://www.w3.org/TR/trace-context/
5
+ *
6
+ * traceparent format: version-traceId-spanId-flags
7
+ * Example: 00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01
8
+ */
9
+ export type TraceparentData = {
10
+ traceId: string;
11
+ spanId: string;
12
+ sampled: boolean;
13
+ };
14
+ /**
15
+ * Generate a random 32-character hex trace ID (16 bytes).
16
+ */
17
+ export declare function generateTraceId(): string;
18
+ /**
19
+ * Generate a random 16-character hex span ID (8 bytes).
20
+ */
21
+ export declare function generateSpanId(): string;
22
+ /**
23
+ * Parse a W3C traceparent header into its components.
24
+ * Returns null if the header is invalid.
25
+ */
26
+ export declare function parseTraceparent(header: string): TraceparentData | null;
27
+ /**
28
+ * Create a W3C traceparent header value.
29
+ */
30
+ export declare function createTraceparent(traceId: string, spanId: string, sampled: boolean): string;
31
+ //# sourceMappingURL=trace-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trace-context.d.ts","sourceRoot":"","sources":["../src/trace-context.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,MAAM,MAAM,eAAe,GAAG;IAC7B,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,OAAO,CAAA;CAChB,CAAA;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAMxC;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAMvC;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI,CAkBvE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAChC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,GACd,MAAM,CAGR"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * W3C Trace Context utilities for distributed tracing.
3
+ * Implements the W3C Trace Context specification:
4
+ * https://www.w3.org/TR/trace-context/
5
+ *
6
+ * traceparent format: version-traceId-spanId-flags
7
+ * Example: 00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01
8
+ */
9
+ const TRACEPARENT_REGEX = /^00-([a-f0-9]{32})-([a-f0-9]{16})-([a-f0-9]{2})$/;
10
+ /**
11
+ * Generate a random 32-character hex trace ID (16 bytes).
12
+ */
13
+ export function generateTraceId() {
14
+ const bytes = new Uint8Array(16);
15
+ crypto.getRandomValues(bytes);
16
+ return Array.from(bytes)
17
+ .map((b) => b.toString(16).padStart(2, "0"))
18
+ .join("");
19
+ }
20
+ /**
21
+ * Generate a random 16-character hex span ID (8 bytes).
22
+ */
23
+ export function generateSpanId() {
24
+ const bytes = new Uint8Array(8);
25
+ crypto.getRandomValues(bytes);
26
+ return Array.from(bytes)
27
+ .map((b) => b.toString(16).padStart(2, "0"))
28
+ .join("");
29
+ }
30
+ /**
31
+ * Parse a W3C traceparent header into its components.
32
+ * Returns null if the header is invalid.
33
+ */
34
+ export function parseTraceparent(header) {
35
+ const match = header.match(TRACEPARENT_REGEX);
36
+ if (!match)
37
+ return null;
38
+ const [, traceId, spanId, flags] = match;
39
+ if (!traceId || !spanId || !flags)
40
+ return null;
41
+ // Validate trace ID is not all zeros
42
+ if (traceId === "00000000000000000000000000000000")
43
+ return null;
44
+ // Validate span ID is not all zeros
45
+ if (spanId === "0000000000000000")
46
+ return null;
47
+ return {
48
+ traceId,
49
+ spanId,
50
+ sampled: (Number.parseInt(flags, 16) & 0x01) === 1,
51
+ };
52
+ }
53
+ /**
54
+ * Create a W3C traceparent header value.
55
+ */
56
+ export function createTraceparent(traceId, spanId, sampled) {
57
+ const flags = sampled ? "01" : "00";
58
+ return `00-${traceId}-${spanId}-${flags}`;
59
+ }
60
+ //# sourceMappingURL=trace-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trace-context.js","sourceRoot":"","sources":["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,OAAO,IAAI,CAAA;IAE/D,oCAAoC;IACpC,IAAI,MAAM,KAAK,kBAAkB;QAAE,OAAO,IAAI,CAAA;IAE9C,OAAO;QACN,OAAO;QACP,MAAM;QACN,OAAO,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC;KAClD,CAAA;AACF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAChC,OAAe,EACf,MAAc,EACd,OAAgB;IAEhB,MAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAA;IACnC,OAAO,MAAM,OAAO,IAAI,MAAM,IAAI,KAAK,EAAE,CAAA;AAC1C,CAAC"}
@@ -0,0 +1,256 @@
1
+ import type { Instrumentation } from "./instrument/types.js";
2
+ import type { Sampler } from "./sampler.js";
3
+ export type VidentConfig = {
4
+ apiKey?: string;
5
+ baseUrl?: string;
6
+ timeout?: number;
7
+ retries?: number;
8
+ serviceName?: string;
9
+ instrumentations?: Instrumentation[];
10
+ /**
11
+ * Sampler for tracing. Default: parentBasedSampler with 100% root sampling.
12
+ * @example
13
+ * // 10% sampling for new traces, respect parent decisions
14
+ * sampler: parentBasedSampler({ root: traceIdRatioSampler(0.1) })
15
+ */
16
+ sampler?: Sampler;
17
+ /**
18
+ * Explicitly enable/disable the SDK. When false, all methods are no-ops.
19
+ * Useful for test environments: `enabled: process.env.NODE_ENV !== 'test'`
20
+ * Default: true if apiKey is provided, false otherwise.
21
+ */
22
+ enabled?: boolean;
23
+ };
24
+ export type { Instrumentation };
25
+ export type Project = {
26
+ id: string;
27
+ name: string;
28
+ slug: string;
29
+ orgId: string;
30
+ timezone: string;
31
+ createdAt: string;
32
+ updatedAt: string;
33
+ };
34
+ export type CreateProjectInput = {
35
+ name: string;
36
+ slug: string;
37
+ orgId: string;
38
+ timezone?: string;
39
+ };
40
+ export type UpdateProjectInput = {
41
+ name?: string;
42
+ timezone?: string;
43
+ };
44
+ export type CheckStatus = "NEW" | "UP" | "LATE" | "DOWN" | "PAUSED";
45
+ export type ScheduleType = "PERIOD" | "CRON";
46
+ export type Check = {
47
+ id: string;
48
+ projectId: string;
49
+ name: string;
50
+ slug: string | null;
51
+ scheduleType: ScheduleType;
52
+ scheduleValue: string;
53
+ graceSeconds: number;
54
+ timezone: string | null;
55
+ status: CheckStatus;
56
+ lastPingAt: string | null;
57
+ nextExpectedAt: string | null;
58
+ alertOnRecovery: boolean;
59
+ reminderIntervalHours: number | null;
60
+ channelIds: string[];
61
+ createdAt: string;
62
+ updatedAt: string;
63
+ };
64
+ export type CreateCheckInput = {
65
+ name: string;
66
+ slug?: string;
67
+ scheduleType: ScheduleType;
68
+ scheduleValue: string;
69
+ graceSeconds?: number;
70
+ timezone?: string;
71
+ alertOnRecovery?: boolean;
72
+ reminderIntervalHours?: number;
73
+ };
74
+ export type UpdateCheckInput = Partial<CreateCheckInput> & {
75
+ channelIds?: string[];
76
+ };
77
+ export type ChannelType = "EMAIL" | "SLACK_WEBHOOK" | "SLACK_APP" | "DISCORD" | "PAGERDUTY" | "OPSGENIE" | "WEBHOOK";
78
+ export type EmailChannelConfig = {
79
+ email: string;
80
+ };
81
+ export type SlackWebhookChannelConfig = {
82
+ webhookUrl: string;
83
+ };
84
+ export type SlackAppChannelConfig = {
85
+ accessToken: string;
86
+ channelId: string;
87
+ webhookUrl?: string;
88
+ };
89
+ export type DiscordChannelConfig = {
90
+ webhookUrl: string;
91
+ };
92
+ export type PagerDutyChannelConfig = {
93
+ routingKey: string;
94
+ };
95
+ export type OpsgenieChannelConfig = {
96
+ apiKey: string;
97
+ region?: "us" | "eu";
98
+ };
99
+ export type WebhookChannelConfig = {
100
+ url: string;
101
+ secret?: string;
102
+ };
103
+ export type ChannelConfig = EmailChannelConfig | SlackWebhookChannelConfig | SlackAppChannelConfig | DiscordChannelConfig | PagerDutyChannelConfig | OpsgenieChannelConfig | WebhookChannelConfig;
104
+ export type Channel = {
105
+ id: string;
106
+ projectId: string;
107
+ type: ChannelType;
108
+ name: string;
109
+ config: ChannelConfig;
110
+ createdAt: string;
111
+ updatedAt: string;
112
+ };
113
+ export type CreateChannelInput = {
114
+ type: "EMAIL";
115
+ name: string;
116
+ config: EmailChannelConfig;
117
+ } | {
118
+ type: "SLACK_WEBHOOK";
119
+ name: string;
120
+ config: SlackWebhookChannelConfig;
121
+ } | {
122
+ type: "SLACK_APP";
123
+ name: string;
124
+ config: SlackAppChannelConfig;
125
+ } | {
126
+ type: "DISCORD";
127
+ name: string;
128
+ config: DiscordChannelConfig;
129
+ } | {
130
+ type: "PAGERDUTY";
131
+ name: string;
132
+ config: PagerDutyChannelConfig;
133
+ } | {
134
+ type: "OPSGENIE";
135
+ name: string;
136
+ config: OpsgenieChannelConfig;
137
+ } | {
138
+ type: "WEBHOOK";
139
+ name: string;
140
+ config: WebhookChannelConfig;
141
+ };
142
+ export type UpdateChannelInput = {
143
+ name?: string;
144
+ config?: ChannelConfig;
145
+ };
146
+ export type Organization = {
147
+ id: string;
148
+ name: string;
149
+ slug: string;
150
+ plan: string;
151
+ trialEndsAt: string | null;
152
+ createdAt: string;
153
+ updatedAt: string;
154
+ };
155
+ export type CreateOrganizationInput = {
156
+ name: string;
157
+ slug: string;
158
+ };
159
+ export type UpdateOrganizationInput = {
160
+ name?: string;
161
+ };
162
+ export type ApiKey = {
163
+ id: string;
164
+ projectId: string;
165
+ name: string;
166
+ prefix: string;
167
+ createdAt: string;
168
+ lastUsedAt: string | null;
169
+ };
170
+ export type ApiKeyCreated = ApiKey & {
171
+ key: string;
172
+ };
173
+ export type CreateApiKeyInput = {
174
+ name: string;
175
+ };
176
+ export type UptimeDay = {
177
+ date: string;
178
+ upPercent: number;
179
+ upMinutes: number;
180
+ downMinutes: number;
181
+ totalPings: number;
182
+ };
183
+ export type CheckStats = {
184
+ checkId: string;
185
+ days: UptimeDay[];
186
+ };
187
+ export type PingOptions = {
188
+ type?: "success" | "start" | "fail";
189
+ body?: string;
190
+ };
191
+ export type WrapOptions = {
192
+ /** Send START ping before execution to track duration. Default: false */
193
+ trackDuration?: boolean;
194
+ };
195
+ export type SpanKind = "server" | "client" | "internal" | "producer" | "consumer";
196
+ export type SpanOptions = {
197
+ kind?: SpanKind;
198
+ attributes?: Record<string, string | number | boolean>;
199
+ /** Parent span context for distributed tracing */
200
+ parent?: SpanContext;
201
+ /** Mark this span as an intentional root span (no parent expected) */
202
+ root?: boolean;
203
+ };
204
+ export type TraceOptions = {
205
+ kind?: SpanKind;
206
+ attributes?: Record<string, string | number | boolean>;
207
+ /** Parent span context for distributed tracing */
208
+ parent?: SpanContext;
209
+ /** Mark this trace as an intentional root (no parent expected) */
210
+ root?: boolean;
211
+ };
212
+ export type SpanContext = {
213
+ traceId: string;
214
+ spanId: string;
215
+ /** Whether this context came from a remote service */
216
+ isRemote?: boolean;
217
+ /** Whether this span was sampled */
218
+ sampled?: boolean;
219
+ };
220
+ export type SpanInterface = {
221
+ spanId: string;
222
+ traceId: string;
223
+ name: string;
224
+ end: (options?: {
225
+ error?: Error;
226
+ }) => void;
227
+ setAttributes: (attrs: Record<string, string | number | boolean>) => void;
228
+ updateName: (name: string) => void;
229
+ context: () => SpanContext;
230
+ };
231
+ export type PaginationParams = {
232
+ page?: number;
233
+ limit?: number;
234
+ };
235
+ export type PaginatedResponse<T> = {
236
+ data: T[];
237
+ total: number;
238
+ page: number;
239
+ limit: number;
240
+ totalPages: number;
241
+ };
242
+ /**
243
+ * Creates an async generator that iterates through all pages of a paginated endpoint.
244
+ * @example
245
+ * for await (const project of paginate(params => client.projects.list(params))) {
246
+ * console.log(project.name)
247
+ * }
248
+ */
249
+ export declare function paginate<T>(fetcher: (params: PaginationParams) => Promise<PaginatedResponse<T>>, params?: Omit<PaginationParams, "page">): AsyncGenerator<T, void, unknown>;
250
+ /**
251
+ * Fetches all items from a paginated endpoint into an array.
252
+ * @example
253
+ * const allProjects = await fetchAll(params => client.projects.list(params))
254
+ */
255
+ export declare function fetchAll<T>(fetcher: (params: PaginationParams) => Promise<PaginatedResponse<T>>, params?: Omit<PaginationParams, "page">): Promise<T[]>;
256
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAC5D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAG3C,MAAM,MAAM,YAAY,GAAG;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,gBAAgB,CAAC,EAAE,eAAe,EAAE,CAAA;IACpC;;;;;OAKG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;CACjB,CAAA;AAGD,YAAY,EAAE,eAAe,EAAE,CAAA;AAG/B,MAAM,MAAM,OAAO,GAAG;IACrB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG;IAChC,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG;IAChC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAA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M,CAAA;IACb,UAAU,EAAE,MAAM,CAAA;CAClB,CAAA;AAED;;;;;;GAMG;AACH,wBAAuB,QAAQ,CAAC,CAAC,EAChC,OAAO,EAAE,CAAC,MAAM,EAAE,gBAAgB,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,EACpE,MAAM,CAAC,EAAE,IAAI,CAAC,gBAAgB,EAAE,MAAM,CAAC,GACrC,cAAc,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,CAYlC;AAED;;;;GAIG;AACH,wBAAsB,QAAQ,CAAC,CAAC,EAC/B,OAAO,EAAE,CAAC,MAAM,EAAE,gBAAgB,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,EACpE,MAAM,CAAC,EAAE,IAAI,CAAC,gBAAgB,EAAE,MAAM,CAAC,GACrC,OAAO,CAAC,CAAC,EAAE,CAAC,CAMd"}
package/dist/types.js ADDED
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Creates an async generator that iterates through all pages of a paginated endpoint.
3
+ * @example
4
+ * for await (const project of paginate(params => client.projects.list(params))) {
5
+ * console.log(project.name)
6
+ * }
7
+ */
8
+ export async function* paginate(fetcher, params) {
9
+ let page = 1;
10
+ const limit = params?.limit ?? 20;
11
+ while (true) {
12
+ const response = await fetcher({ page, limit });
13
+ for (const item of response.data) {
14
+ yield item;
15
+ }
16
+ if (page >= response.totalPages)
17
+ break;
18
+ page++;
19
+ }
20
+ }
21
+ /**
22
+ * Fetches all items from a paginated endpoint into an array.
23
+ * @example
24
+ * const allProjects = await fetchAll(params => client.projects.list(params))
25
+ */
26
+ export async function fetchAll(fetcher, params) {
27
+ const items = [];
28
+ for await (const item of paginate(fetcher, params)) {
29
+ items.push(item);
30
+ }
31
+ return items;
32
+ }
33
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAiSA;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,SAAS,CAAC,CAAC,QAAQ,CAC9B,OAAoE,EACpE,MAAuC;IAEvC,IAAI,IAAI,GAAG,CAAC,CAAA;IACZ,MAAM,KAAK,GAAG,MAAM,EAAE,KAAK,IAAI,EAAE,CAAA;IAEjC,OAAO,IAAI,EAAE,CAAC;QACb,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAA;QAC/C,KAAK,MAAM,IAAI,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC;YAClC,MAAM,IAAI,CAAA;QACX,CAAC;QACD,IAAI,IAAI,IAAI,QAAQ,CAAC,UAAU;YAAE,MAAK;QACtC,IAAI,EAAE,CAAA;IACP,CAAC;AACF,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC7B,OAAoE,EACpE,MAAuC;IAEvC,MAAM,KAAK,GAAQ,EAAE,CAAA;IACrB,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,CAAC;QACpD,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACjB,CAAC;IACD,OAAO,KAAK,CAAA;AACb,CAAC"}
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "vident-sdk",
3
+ "version": "0.11.0",
4
+ "description": "TypeScript SDK for Vident - monitoring, tracing, and error tracking",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "publishConfig": {
9
+ "access": "public"
10
+ },
11
+ "exports": {
12
+ ".": {
13
+ "import": "./dist/index.js",
14
+ "types": "./dist/index.d.ts"
15
+ },
16
+ "./instrument": {
17
+ "import": "./dist/instrument/index.js",
18
+ "types": "./dist/instrument/index.d.ts"
19
+ }
20
+ },
21
+ "files": ["dist"],
22
+ "scripts": {
23
+ "build": "tsc",
24
+ "dev": "tsc --watch",
25
+ "clean": "rm -rf dist",
26
+ "generate-types": "openapi-typescript http://localhost:3000/openapi.json -o src/types.generated.ts"
27
+ },
28
+ "keywords": ["vident", "monitoring", "tracing", "observability", "apm"],
29
+ "license": "MIT",
30
+ "peerDependencies": {
31
+ "@aws-sdk/smithy-client": ">=3.0.0",
32
+ "@prisma/client": ">=5.0.0",
33
+ "hono": ">=4.0.0"
34
+ },
35
+ "peerDependenciesMeta": {
36
+ "@aws-sdk/smithy-client": {
37
+ "optional": true
38
+ },
39
+ "@prisma/client": {
40
+ "optional": true
41
+ },
42
+ "hono": {
43
+ "optional": true
44
+ }
45
+ },
46
+ "devDependencies": {
47
+ "@types/node": "^22.0.0",
48
+ "hono": "^4.0.0",
49
+ "openapi-typescript": "^7.4.4",
50
+ "typescript": "^5.7.2"
51
+ }
52
+ }