@use-tusk/drift-node-sdk 0.1.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.
@@ -0,0 +1,103 @@
1
+ //#region src/core/types.d.ts
2
+
3
+ type OneOf<T extends object> = { [K in keyof T]: Required<Pick<T, K>> & Partial<Record<Exclude<keyof T, K>, null>> }[keyof T];
4
+ //#endregion
5
+ //#region src/core/utils/logger.d.ts
6
+ type LogLevel = "silent" | "error" | "warn" | "info" | "debug";
7
+ //#endregion
8
+ //#region src/instrumentation/libraries/http/HttpTransformEngine.d.ts
9
+ interface TransformConfigs {
10
+ http: HttpTransform[];
11
+ }
12
+ interface HttpTransform {
13
+ matcher: HttpTransformMatcher;
14
+ action: HttpTransformAction;
15
+ }
16
+ /** A matcher config. An element is matched iff *all* conditions specified
17
+ * here are true. Only one target field is allowed, but any of the common
18
+ * fields may be provided.
19
+ * */
20
+ type HttpTransformMatcher = {
21
+ /** Request direction, relative to this service. */
22
+ direction: "inbound" | "outbound";
23
+ /** HTTP method: array of methods like ["GET", "POST"]. Empty array matches all methods. */
24
+ method?: ("GET" | "POST" | "DELETE" | "PUT")[];
25
+ /** URL path pattern: "/api/user/*" */
26
+ pathPattern?: string;
27
+ /** Host pattern. e.g. "api.example.com" */
28
+ host?: string;
29
+ } & OneOf<HttpTransformTarget>;
30
+ type HttpTransformTarget = {
31
+ /** JSONPath expression: "$.user.password" */
32
+ jsonPath: string;
33
+ /** Query parameter name: "ssn" */
34
+ queryParam: string;
35
+ /** Header name: "Authorization" */
36
+ headerName: string;
37
+ /** Transform the entire URL path */
38
+ urlPath: string;
39
+ /** Transform the entire request/response body */
40
+ fullBody: string;
41
+ };
42
+ type HttpTransformAction = {
43
+ type: "redact";
44
+ /** Prefix for hash (default: "REDACTED_") */
45
+ hashPrefix?: string;
46
+ } | {
47
+ type: "mask";
48
+ /** Character to use for masking (default: "*") */
49
+ maskChar?: string;
50
+ } | {
51
+ type: "replace";
52
+ /** Static replacement value (required) */
53
+ replaceWith: string;
54
+ } | {
55
+ type: "drop";
56
+ };
57
+ //#endregion
58
+ //#region src/core/TuskDrift.d.ts
59
+ interface InitParams {
60
+ apiKey?: string;
61
+ env: string;
62
+ logLevel?: LogLevel;
63
+ transforms?: TransformConfigs;
64
+ }
65
+ interface TuskDriftPublicAPI {
66
+ /**
67
+ * Initialize the TuskDrift SDK instance
68
+ *
69
+ * This is the main initialization function for TuskDrift that must be called before importing/requiring any other modules.
70
+ *
71
+ * @param initParams - The initialization parameters object containing:
72
+ * - apiKey: string - Your TuskDrift API key (required)
73
+ * - env: string - The environment name (e.g., 'development', 'staging', 'production') (required)
74
+ * - logLevel?: LogLevel - Optional logging level ('silent' | 'error' | 'warn' | 'info' | 'debug'), defaults to 'info'
75
+ *
76
+ * @returns void - Initializes the SDK
77
+ *
78
+ * @example
79
+ * ```typescript
80
+ * import { TuskDrift } from 'tusk-drift-sdk';
81
+ *
82
+ * TuskDrift.initialize({
83
+ * apiKey: 'your-api-key',
84
+ * env: 'production',
85
+ * logLevel: 'debug'
86
+ * });
87
+ *
88
+ * ```
89
+ */
90
+ initialize(initParams: InitParams): void;
91
+ /**
92
+ * Mark the application as ready for recording/replay
93
+ *
94
+ * This should be called after the application has completed initialization and is ready to serve requests.
95
+ *
96
+ * @returns void
97
+ */
98
+ markAppAsReady(): void;
99
+ }
100
+ declare const TuskDrift: TuskDriftPublicAPI;
101
+ //#endregion
102
+ export { TuskDrift };
103
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1,106 @@
1
+ import { SpanKind } from "@opentelemetry/api";
2
+ import { PackageType, StatusCode } from "@use-tusk/drift-schemas/core/span";
3
+
4
+ //#region src/core/types.d.ts
5
+
6
+ type OneOf<T extends object> = { [K in keyof T]: Required<Pick<T, K>> & Partial<Record<Exclude<keyof T, K>, null>> }[keyof T];
7
+ //#endregion
8
+ //#region src/core/utils/logger.d.ts
9
+ type LogLevel = "silent" | "error" | "warn" | "info" | "debug";
10
+ //#endregion
11
+ //#region src/instrumentation/libraries/http/HttpTransformEngine.d.ts
12
+ interface TransformConfigs {
13
+ http: HttpTransform[];
14
+ }
15
+ interface HttpTransform {
16
+ matcher: HttpTransformMatcher;
17
+ action: HttpTransformAction;
18
+ }
19
+ /** A matcher config. An element is matched iff *all* conditions specified
20
+ * here are true. Only one target field is allowed, but any of the common
21
+ * fields may be provided.
22
+ * */
23
+ type HttpTransformMatcher = {
24
+ /** Request direction, relative to this service. */
25
+ direction: "inbound" | "outbound";
26
+ /** HTTP method: array of methods like ["GET", "POST"]. Empty array matches all methods. */
27
+ method?: ("GET" | "POST" | "DELETE" | "PUT")[];
28
+ /** URL path pattern: "/api/user/*" */
29
+ pathPattern?: string;
30
+ /** Host pattern. e.g. "api.example.com" */
31
+ host?: string;
32
+ } & OneOf<HttpTransformTarget>;
33
+ type HttpTransformTarget = {
34
+ /** JSONPath expression: "$.user.password" */
35
+ jsonPath: string;
36
+ /** Query parameter name: "ssn" */
37
+ queryParam: string;
38
+ /** Header name: "Authorization" */
39
+ headerName: string;
40
+ /** Transform the entire URL path */
41
+ urlPath: string;
42
+ /** Transform the entire request/response body */
43
+ fullBody: string;
44
+ };
45
+ type HttpTransformAction = {
46
+ type: "redact";
47
+ /** Prefix for hash (default: "REDACTED_") */
48
+ hashPrefix?: string;
49
+ } | {
50
+ type: "mask";
51
+ /** Character to use for masking (default: "*") */
52
+ maskChar?: string;
53
+ } | {
54
+ type: "replace";
55
+ /** Static replacement value (required) */
56
+ replaceWith: string;
57
+ } | {
58
+ type: "drop";
59
+ };
60
+ //#endregion
61
+ //#region src/core/TuskDrift.d.ts
62
+ interface InitParams {
63
+ apiKey?: string;
64
+ env: string;
65
+ logLevel?: LogLevel;
66
+ transforms?: TransformConfigs;
67
+ }
68
+ interface TuskDriftPublicAPI {
69
+ /**
70
+ * Initialize the TuskDrift SDK instance
71
+ *
72
+ * This is the main initialization function for TuskDrift that must be called before importing/requiring any other modules.
73
+ *
74
+ * @param initParams - The initialization parameters object containing:
75
+ * - apiKey: string - Your TuskDrift API key (required)
76
+ * - env: string - The environment name (e.g., 'development', 'staging', 'production') (required)
77
+ * - logLevel?: LogLevel - Optional logging level ('silent' | 'error' | 'warn' | 'info' | 'debug'), defaults to 'info'
78
+ *
79
+ * @returns void - Initializes the SDK
80
+ *
81
+ * @example
82
+ * ```typescript
83
+ * import { TuskDrift } from 'tusk-drift-sdk';
84
+ *
85
+ * TuskDrift.initialize({
86
+ * apiKey: 'your-api-key',
87
+ * env: 'production',
88
+ * logLevel: 'debug'
89
+ * });
90
+ *
91
+ * ```
92
+ */
93
+ initialize(initParams: InitParams): void;
94
+ /**
95
+ * Mark the application as ready for recording/replay
96
+ *
97
+ * This should be called after the application has completed initialization and is ready to serve requests.
98
+ *
99
+ * @returns void
100
+ */
101
+ markAppAsReady(): void;
102
+ }
103
+ declare const TuskDrift: TuskDriftPublicAPI;
104
+ //#endregion
105
+ export { TuskDrift };
106
+ //# sourceMappingURL=index.d.ts.map