@getuserfeedback/protocol 0.6.0 → 0.7.2
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.
- package/dist/app-event.d.ts +659 -17
- package/dist/app-event.d.ts.map +1 -1
- package/dist/app-event.js +71 -8
- package/dist/errors.d.ts +73 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +43 -0
- package/dist/flow-assignments.d.ts +83 -4
- package/dist/flow-assignments.d.ts.map +1 -1
- package/dist/flow-assignments.js +1 -0
- package/dist/host/constants.d.ts +2 -2
- package/dist/host/constants.d.ts.map +1 -1
- package/dist/host/constants.js +3 -1
- package/dist/host/sdk-types.d.ts +73 -28
- package/dist/host/sdk-types.d.ts.map +1 -1
- package/dist/host/sdk.d.ts.map +1 -1
- package/dist/identity-type.d.ts +4 -2
- package/dist/identity-type.d.ts.map +1 -1
- package/dist/identity-type.js +4 -2
- package/dist/index.d.ts +4 -86
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -6
- package/dist/widget-commands.d.ts +102 -3
- package/dist/widget-commands.d.ts.map +1 -1
- package/dist/widget-commands.js +5 -0
- package/dist/widget-config.d.ts +5 -5
- package/package.json +22 -2
- package/src/app-event.ts +211 -0
- package/src/client-meta.ts +25 -0
- package/src/defaults.ts +4 -0
- package/src/errors.ts +58 -0
- package/src/flow-assignments.test.ts +63 -0
- package/src/flow-assignments.ts +125 -0
- package/src/host/command-dispatch.ts +59 -0
- package/src/host/command-envelope.ts +41 -0
- package/src/host/command-settlement.ts +121 -0
- package/src/host/constants.ts +103 -0
- package/src/host/host-event-contract.ts +277 -0
- package/src/host/index.ts +13 -0
- package/src/host/lazy-handle-client.ts +207 -0
- package/src/host/request-id.ts +3 -0
- package/src/host/sdk-types.ts +506 -0
- package/src/host/sdk.ts +43 -0
- package/src/host/unique-id.ts +17 -0
- package/src/identity-type.ts +102 -0
- package/src/index.ts +136 -0
- package/src/protocol-root.test.ts +476 -0
- package/src/public-grant-scope.ts +25 -0
- package/src/runtime-endpoints.ts +69 -0
- package/src/scopes.ts +79 -0
- package/src/trpc-envelope.ts +9 -0
- package/src/version-resolution.ts +18 -0
- package/src/widget-commands.ts +152 -0
- package/src/widget-config.ts +157 -0
|
@@ -11,6 +11,7 @@ export declare const publicWidgetCommandKindSchema: z.ZodMiniEnum<{
|
|
|
11
11
|
init: "init";
|
|
12
12
|
close: "close";
|
|
13
13
|
reset: "reset";
|
|
14
|
+
track: "track";
|
|
14
15
|
}>;
|
|
15
16
|
export declare const containerPolicySchema: z.ZodMiniDiscriminatedUnion<[z.ZodMiniObject<{
|
|
16
17
|
kind: z.ZodMiniLiteral<"floating">;
|
|
@@ -76,9 +77,9 @@ export declare const publicCommandPayloadSchema: z.ZodMiniUnion<readonly [z.ZodM
|
|
|
76
77
|
colorScheme: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniObject<{
|
|
77
78
|
autoDetectColorScheme: z.ZodMiniArray<z.ZodMiniString<string>>;
|
|
78
79
|
}, z.core.$strict>, z.ZodMiniEnum<{
|
|
80
|
+
system: "system";
|
|
79
81
|
light: "light";
|
|
80
82
|
dark: "dark";
|
|
81
|
-
system: "system";
|
|
82
83
|
}>]>>;
|
|
83
84
|
consent: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniEnum<{
|
|
84
85
|
pending: "pending";
|
|
@@ -108,9 +109,9 @@ export declare const publicCommandPayloadSchema: z.ZodMiniUnion<readonly [z.ZodM
|
|
|
108
109
|
colorScheme: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniObject<{
|
|
109
110
|
autoDetectColorScheme: z.ZodMiniArray<z.ZodMiniString<string>>;
|
|
110
111
|
}, z.core.$strict>, z.ZodMiniEnum<{
|
|
112
|
+
system: "system";
|
|
111
113
|
light: "light";
|
|
112
114
|
dark: "dark";
|
|
113
|
-
system: "system";
|
|
114
115
|
}>]>>;
|
|
115
116
|
disableTelemetry: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
116
117
|
enableDebug: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
@@ -253,7 +254,105 @@ export declare const publicCommandPayloadSchema: z.ZodMiniUnion<readonly [z.ZodM
|
|
|
253
254
|
flowHandleId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
254
255
|
}, z.core.$strict>, z.ZodMiniObject<{
|
|
255
256
|
kind: z.ZodMiniLiteral<"reset">;
|
|
256
|
-
}, z.core.$strict
|
|
257
|
+
}, z.core.$strict>, z.ZodMiniObject<{
|
|
258
|
+
traits: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnknown>>;
|
|
259
|
+
identities: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
|
|
260
|
+
type: z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<import("./identity-type.js").IdentityTypeValue, string>>;
|
|
261
|
+
value: z.ZodMiniString<string>;
|
|
262
|
+
}, z.core.$strip>>>;
|
|
263
|
+
context: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
264
|
+
page: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
265
|
+
path: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
266
|
+
referrer: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
267
|
+
search: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
268
|
+
}, z.core.$strip>>;
|
|
269
|
+
locale: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
270
|
+
userAgent: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
271
|
+
flags: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
|
|
272
|
+
key: z.ZodMiniString<string>;
|
|
273
|
+
target: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
274
|
+
value: z.ZodMiniType<string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | {
|
|
275
|
+
[key: string]: string | number | boolean | /*elided*/ any | /*elided*/ any | null;
|
|
276
|
+
} | null)[] | {
|
|
277
|
+
[key: string]: string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any | null)[] | /*elided*/ any | null;
|
|
278
|
+
} | null)[] | {
|
|
279
|
+
[key: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null;
|
|
280
|
+
} | null)[] | {
|
|
281
|
+
[key: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null;
|
|
282
|
+
} | null)[] | {
|
|
283
|
+
[key: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null;
|
|
284
|
+
} | null)[] | {
|
|
285
|
+
[key: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null;
|
|
286
|
+
} | null)[] | {
|
|
287
|
+
[key: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null;
|
|
288
|
+
} | null)[] | {
|
|
289
|
+
[key: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null;
|
|
290
|
+
} | null)[] | {
|
|
291
|
+
[key: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null;
|
|
292
|
+
} | null)[] | {
|
|
293
|
+
[key: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null;
|
|
294
|
+
} | null)[] | {
|
|
295
|
+
[key: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null;
|
|
296
|
+
} | null)[] | {
|
|
297
|
+
[key: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null;
|
|
298
|
+
} | null, unknown, z.core.$ZodTypeInternals<string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | {
|
|
299
|
+
[key: string]: string | number | boolean | /*elided*/ any | /*elided*/ any | null;
|
|
300
|
+
} | null)[] | {
|
|
301
|
+
[key: string]: string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any | null)[] | /*elided*/ any | null;
|
|
302
|
+
} | null)[] | {
|
|
303
|
+
[key: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null;
|
|
304
|
+
} | null)[] | {
|
|
305
|
+
[key: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null;
|
|
306
|
+
} | null)[] | {
|
|
307
|
+
[key: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null;
|
|
308
|
+
} | null)[] | {
|
|
309
|
+
[key: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null;
|
|
310
|
+
} | null)[] | {
|
|
311
|
+
[key: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null;
|
|
312
|
+
} | null)[] | {
|
|
313
|
+
[key: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null;
|
|
314
|
+
} | null)[] | {
|
|
315
|
+
[key: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null;
|
|
316
|
+
} | null)[] | {
|
|
317
|
+
[key: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null;
|
|
318
|
+
} | null)[] | {
|
|
319
|
+
[key: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null;
|
|
320
|
+
} | null)[] | {
|
|
321
|
+
[key: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null;
|
|
322
|
+
} | null, unknown>>;
|
|
323
|
+
variant: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
324
|
+
origin: z.ZodMiniOptional<z.ZodMiniEnum<{
|
|
325
|
+
runtime_config: "runtime_config";
|
|
326
|
+
trigger_context: "trigger_context";
|
|
327
|
+
provider_sync: "provider_sync";
|
|
328
|
+
api: "api";
|
|
329
|
+
}>>;
|
|
330
|
+
provider: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
331
|
+
name: z.ZodMiniString<string>;
|
|
332
|
+
project: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
333
|
+
environment: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
334
|
+
}, z.core.$strip>>;
|
|
335
|
+
status: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
336
|
+
reason: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
337
|
+
evaluatedAt: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
338
|
+
}, z.core.$strip>>>;
|
|
339
|
+
capabilities: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
|
|
340
|
+
key: z.ZodMiniString<string>;
|
|
341
|
+
source: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
342
|
+
provider: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
343
|
+
name: z.ZodMiniString<string>;
|
|
344
|
+
project: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
345
|
+
environment: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
346
|
+
}, z.core.$strip>>;
|
|
347
|
+
}, z.core.$strip>>>;
|
|
348
|
+
}, z.core.$strip>>;
|
|
349
|
+
messageId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
350
|
+
timestamp: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
351
|
+
origin: z.ZodMiniLiteral<"customer">;
|
|
352
|
+
event: z.ZodMiniString<string>;
|
|
353
|
+
properties: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniType<import("./app-event.js").AppEventJsonValue, unknown, z.core.$ZodTypeInternals<import("./app-event.js").AppEventJsonValue, unknown>>>>;
|
|
354
|
+
kind: z.ZodMiniLiteral<"track">;
|
|
355
|
+
}, z.core.$strip>], "kind">, z.ZodMiniUnion<readonly [z.ZodMiniObject<{
|
|
257
356
|
kind: z.ZodMiniLiteral<"identify">;
|
|
258
357
|
traits: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnknown>;
|
|
259
358
|
}, z.core.$strict>, z.ZodMiniObject<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"widget-commands.d.ts","sourceRoot":"","sources":["../src/widget-commands.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"widget-commands.d.ts","sourceRoot":"","sources":["../src/widget-commands.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAE9B,OAAO,EACN,KAAK,gBAAgB,EAErB,KAAK,WAAW,EAEhB,MAAM,oBAAoB,CAAC;AAoB5B,eAAO,MAAM,6BAA6B;;;;;;;;;;;;EAAmC,CAAC;AAyC9E,eAAO,MAAM,qBAAqB;;;;;;;;;4BAShC,CAAC;AAeH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBA2CrC,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE/E,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAErE,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,WAAW,CAE5D;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,gBAAgB,CAEtE;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,oBAAoB,CAEvE"}
|
package/dist/widget-commands.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as z from "zod/mini";
|
|
2
|
+
import { appEventCustomerTrackSchema } from "./app-event.js";
|
|
2
3
|
import { configureOptionsSchema, initOptionsSchema, } from "./widget-config.js";
|
|
3
4
|
const flowHandleIdSchema = z.string().check(z.trim(), z.minLength(1));
|
|
4
5
|
const flowIdSchema = z.string().check(z.trim(), z.minLength(1));
|
|
@@ -14,6 +15,7 @@ const publicWidgetCommandKinds = [
|
|
|
14
15
|
"init",
|
|
15
16
|
"close",
|
|
16
17
|
"reset",
|
|
18
|
+
"track",
|
|
17
19
|
];
|
|
18
20
|
export const publicWidgetCommandKindSchema = z.enum(publicWidgetCommandKinds);
|
|
19
21
|
const isHTMLElementLike = (value) => {
|
|
@@ -105,6 +107,9 @@ export const publicCommandPayloadSchema = z.union([
|
|
|
105
107
|
z.strictObject({
|
|
106
108
|
kind: z.literal("reset"),
|
|
107
109
|
}),
|
|
110
|
+
z.extend(appEventCustomerTrackSchema, {
|
|
111
|
+
kind: z.literal("track"),
|
|
112
|
+
}),
|
|
108
113
|
]),
|
|
109
114
|
identifyPayloadSchema,
|
|
110
115
|
]);
|
package/dist/widget-config.d.ts
CHANGED
|
@@ -2,9 +2,9 @@ import * as z from "zod/mini";
|
|
|
2
2
|
export declare const colorSchemeConfigInputSchema: z.ZodMiniUnion<readonly [z.ZodMiniObject<{
|
|
3
3
|
autoDetectColorScheme: z.ZodMiniArray<z.ZodMiniString<string>>;
|
|
4
4
|
}, z.core.$strict>, z.ZodMiniEnum<{
|
|
5
|
+
system: "system";
|
|
5
6
|
light: "light";
|
|
6
7
|
dark: "dark";
|
|
7
|
-
system: "system";
|
|
8
8
|
}>]>;
|
|
9
9
|
export type ColorSchemeConfigInput = z.output<typeof colorSchemeConfigInputSchema>;
|
|
10
10
|
export declare const telemetryConfigInputSchema: z.ZodMiniObject<{
|
|
@@ -128,9 +128,9 @@ export declare const configureOptionsSchema: z.ZodMiniObject<{
|
|
|
128
128
|
colorScheme: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniObject<{
|
|
129
129
|
autoDetectColorScheme: z.ZodMiniArray<z.ZodMiniString<string>>;
|
|
130
130
|
}, z.core.$strict>, z.ZodMiniEnum<{
|
|
131
|
+
system: "system";
|
|
131
132
|
light: "light";
|
|
132
133
|
dark: "dark";
|
|
133
|
-
system: "system";
|
|
134
134
|
}>]>>;
|
|
135
135
|
consent: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniEnum<{
|
|
136
136
|
pending: "pending";
|
|
@@ -159,9 +159,9 @@ export declare const initOptionsSchema: z.ZodMiniObject<{
|
|
|
159
159
|
colorScheme: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniObject<{
|
|
160
160
|
autoDetectColorScheme: z.ZodMiniArray<z.ZodMiniString<string>>;
|
|
161
161
|
}, z.core.$strict>, z.ZodMiniEnum<{
|
|
162
|
+
system: "system";
|
|
162
163
|
light: "light";
|
|
163
164
|
dark: "dark";
|
|
164
|
-
system: "system";
|
|
165
165
|
}>]>>;
|
|
166
166
|
disableTelemetry: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
167
167
|
enableDebug: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
@@ -310,9 +310,9 @@ export declare const instanceUpdateableConfigSchema: z.ZodMiniObject<{
|
|
|
310
310
|
colorScheme: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniObject<{
|
|
311
311
|
autoDetectColorScheme: z.ZodMiniArray<z.ZodMiniString<string>>;
|
|
312
312
|
}, z.core.$strict>, z.ZodMiniEnum<{
|
|
313
|
+
system: "system";
|
|
313
314
|
light: "light";
|
|
314
315
|
dark: "dark";
|
|
315
|
-
system: "system";
|
|
316
316
|
}>]>>;
|
|
317
317
|
consent: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniEnum<{
|
|
318
318
|
pending: "pending";
|
|
@@ -354,9 +354,9 @@ export declare const coreInstanceConfigSchema: z.ZodMiniObject<{
|
|
|
354
354
|
colorScheme: z.ZodMiniDefault<z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniObject<{
|
|
355
355
|
autoDetectColorScheme: z.ZodMiniArray<z.ZodMiniString<string>>;
|
|
356
356
|
}, z.core.$strict>, z.ZodMiniEnum<{
|
|
357
|
+
system: "system";
|
|
357
358
|
light: "light";
|
|
358
359
|
dark: "dark";
|
|
359
|
-
system: "system";
|
|
360
360
|
}>]>>>;
|
|
361
361
|
disableTelemetry: z.ZodMiniDefault<z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>>;
|
|
362
362
|
enableDebug: z.ZodMiniDefault<z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getuserfeedback/protocol",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"description": "getuserfeedback widget protocol — host surface and (later) wire protocol",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"getuserfeedback",
|
|
@@ -8,82 +8,101 @@
|
|
|
8
8
|
"protocol"
|
|
9
9
|
],
|
|
10
10
|
"license": "MIT",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/getuserfeedback/getuserfeedback.git"
|
|
14
|
+
},
|
|
11
15
|
"publishConfig": {
|
|
12
16
|
"access": "public"
|
|
13
17
|
},
|
|
14
18
|
"type": "module",
|
|
15
19
|
"sideEffects": false,
|
|
16
20
|
"files": [
|
|
17
|
-
"dist"
|
|
21
|
+
"dist",
|
|
22
|
+
"src"
|
|
18
23
|
],
|
|
19
24
|
"exports": {
|
|
20
25
|
".": {
|
|
21
26
|
"types": "./dist/index.d.ts",
|
|
27
|
+
"bun": "./src/index.ts",
|
|
22
28
|
"import": "./dist/index.js",
|
|
23
29
|
"default": "./dist/index.js"
|
|
24
30
|
},
|
|
25
31
|
"./host": {
|
|
26
32
|
"types": "./dist/host/index.d.ts",
|
|
33
|
+
"bun": "./src/host/index.ts",
|
|
27
34
|
"import": "./dist/host/index.js",
|
|
28
35
|
"default": "./dist/host/index.js"
|
|
29
36
|
},
|
|
30
37
|
"./host/sdk-types": {
|
|
31
38
|
"types": "./dist/host/sdk-types.d.ts",
|
|
39
|
+
"bun": "./src/host/sdk-types.ts",
|
|
32
40
|
"import": "./dist/host/sdk-types.js",
|
|
33
41
|
"default": "./dist/host/sdk-types.js"
|
|
34
42
|
},
|
|
35
43
|
"./host/host-event-contract": {
|
|
36
44
|
"types": "./dist/host/host-event-contract.d.ts",
|
|
45
|
+
"bun": "./src/host/host-event-contract.ts",
|
|
37
46
|
"import": "./dist/host/host-event-contract.js",
|
|
38
47
|
"default": "./dist/host/host-event-contract.js"
|
|
39
48
|
},
|
|
40
49
|
"./host/constants": {
|
|
41
50
|
"types": "./dist/host/constants.d.ts",
|
|
51
|
+
"bun": "./src/host/constants.ts",
|
|
42
52
|
"import": "./dist/host/constants.js",
|
|
43
53
|
"default": "./dist/host/constants.js"
|
|
44
54
|
},
|
|
45
55
|
"./host/command-dispatch": {
|
|
46
56
|
"types": "./dist/host/command-dispatch.d.ts",
|
|
57
|
+
"bun": "./src/host/command-dispatch.ts",
|
|
47
58
|
"import": "./dist/host/command-dispatch.js",
|
|
48
59
|
"default": "./dist/host/command-dispatch.js"
|
|
49
60
|
},
|
|
50
61
|
"./host/command-settlement": {
|
|
51
62
|
"types": "./dist/host/command-settlement.d.ts",
|
|
63
|
+
"bun": "./src/host/command-settlement.ts",
|
|
52
64
|
"import": "./dist/host/command-settlement.js",
|
|
53
65
|
"default": "./dist/host/command-settlement.js"
|
|
54
66
|
},
|
|
55
67
|
"./host/sdk": {
|
|
56
68
|
"types": "./dist/host/sdk.d.ts",
|
|
69
|
+
"bun": "./src/host/sdk.ts",
|
|
57
70
|
"import": "./dist/host/sdk.js",
|
|
58
71
|
"default": "./dist/host/sdk.js"
|
|
59
72
|
},
|
|
60
73
|
"./host/request-id": {
|
|
61
74
|
"types": "./dist/host/request-id.d.ts",
|
|
75
|
+
"bun": "./src/host/request-id.ts",
|
|
62
76
|
"import": "./dist/host/request-id.js",
|
|
63
77
|
"default": "./dist/host/request-id.js"
|
|
64
78
|
},
|
|
65
79
|
"./host/unique-id": {
|
|
66
80
|
"types": "./dist/host/unique-id.d.ts",
|
|
81
|
+
"bun": "./src/host/unique-id.ts",
|
|
67
82
|
"import": "./dist/host/unique-id.js",
|
|
68
83
|
"default": "./dist/host/unique-id.js"
|
|
69
84
|
},
|
|
70
85
|
"./host/lazy-handle-client": {
|
|
71
86
|
"types": "./dist/host/lazy-handle-client.d.ts",
|
|
87
|
+
"bun": "./src/host/lazy-handle-client.ts",
|
|
72
88
|
"import": "./dist/host/lazy-handle-client.js",
|
|
73
89
|
"default": "./dist/host/lazy-handle-client.js"
|
|
74
90
|
},
|
|
75
91
|
"./version-resolution": {
|
|
76
92
|
"types": "./dist/version-resolution.d.ts",
|
|
93
|
+
"bun": "./src/version-resolution.ts",
|
|
77
94
|
"import": "./dist/version-resolution.js",
|
|
78
95
|
"default": "./dist/version-resolution.js"
|
|
79
96
|
},
|
|
80
97
|
"./flow-assignments": {
|
|
81
98
|
"types": "./dist/flow-assignments.d.ts",
|
|
99
|
+
"bun": "./src/flow-assignments.ts",
|
|
82
100
|
"import": "./dist/flow-assignments.js",
|
|
83
101
|
"default": "./dist/flow-assignments.js"
|
|
84
102
|
},
|
|
85
103
|
"./trpc-envelope": {
|
|
86
104
|
"types": "./dist/trpc-envelope.d.ts",
|
|
105
|
+
"bun": "./src/trpc-envelope.ts",
|
|
87
106
|
"import": "./dist/trpc-envelope.js",
|
|
88
107
|
"default": "./dist/trpc-envelope.js"
|
|
89
108
|
}
|
|
@@ -91,6 +110,7 @@
|
|
|
91
110
|
"scripts": {
|
|
92
111
|
"lint": "ultracite check .",
|
|
93
112
|
"build": "bun ../../scripts/clean-build-output.ts dist tsconfig.tsbuildinfo && tsc -b tsconfig.json",
|
|
113
|
+
"types": "bun ../../scripts/clean-build-output.ts dist tsconfig.tsbuildinfo && tsc -b tsconfig.json --emitDeclarationOnly",
|
|
94
114
|
"typecheck": "tsc -b tsconfig.json",
|
|
95
115
|
"test": "bun test --dots",
|
|
96
116
|
"pack:verify": "node ../../scripts/pack-and-verify.cjs",
|
package/src/app-event.ts
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import * as z from "zod/mini";
|
|
2
|
+
import { appEventIdentityTypeSchema } from "./identity-type.js";
|
|
3
|
+
|
|
4
|
+
export { appEventIdentityTypeSchema } from "./identity-type.js";
|
|
5
|
+
|
|
6
|
+
export const appEventIdentitySchema = z.object({
|
|
7
|
+
type: appEventIdentityTypeSchema,
|
|
8
|
+
value: z.string().check(z.trim(), z.minLength(1)),
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
type AppEventFlagValue =
|
|
12
|
+
| string
|
|
13
|
+
| number
|
|
14
|
+
| boolean
|
|
15
|
+
| null
|
|
16
|
+
| AppEventFlagValue[]
|
|
17
|
+
| { [key: string]: AppEventFlagValue };
|
|
18
|
+
|
|
19
|
+
export type AppEventJsonValue =
|
|
20
|
+
| string
|
|
21
|
+
| number
|
|
22
|
+
| boolean
|
|
23
|
+
| null
|
|
24
|
+
| AppEventJsonValue[]
|
|
25
|
+
| { [key: string]: AppEventJsonValue };
|
|
26
|
+
|
|
27
|
+
const appEventFlagValueSchema: z.ZodMiniType<AppEventFlagValue> = z.lazy(() =>
|
|
28
|
+
z.union([
|
|
29
|
+
z.string(),
|
|
30
|
+
z.number(),
|
|
31
|
+
z.boolean(),
|
|
32
|
+
z.null(),
|
|
33
|
+
z.array(appEventFlagValueSchema),
|
|
34
|
+
z.record(z.string(), appEventFlagValueSchema),
|
|
35
|
+
]),
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
const appEventJsonNumberSchema = z.number().check(
|
|
39
|
+
z.refine(Number.isFinite, {
|
|
40
|
+
message: "Expected a finite JSON number.",
|
|
41
|
+
}),
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
const appEventJsonValueSchema: z.ZodMiniType<AppEventJsonValue> = z.lazy(() =>
|
|
45
|
+
z.union([
|
|
46
|
+
z.string(),
|
|
47
|
+
appEventJsonNumberSchema,
|
|
48
|
+
z.boolean(),
|
|
49
|
+
z.null(),
|
|
50
|
+
z.array(appEventJsonValueSchema),
|
|
51
|
+
z.record(z.string(), appEventJsonValueSchema),
|
|
52
|
+
]),
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
const appEventJsonObjectSchema = z.record(z.string(), appEventJsonValueSchema);
|
|
56
|
+
|
|
57
|
+
export const appEventFlagProviderSchema = z.object({
|
|
58
|
+
name: z.string().check(z.trim(), z.minLength(1)),
|
|
59
|
+
project: z.optional(z.string().check(z.trim(), z.minLength(1))),
|
|
60
|
+
environment: z.optional(z.string().check(z.trim(), z.minLength(1))),
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
export const appEventFlagSchema = z.object({
|
|
64
|
+
key: z.string().check(z.trim(), z.minLength(1)),
|
|
65
|
+
target: z.optional(z.string().check(z.trim(), z.minLength(1))),
|
|
66
|
+
value: appEventFlagValueSchema,
|
|
67
|
+
variant: z.optional(z.string().check(z.trim(), z.minLength(1))),
|
|
68
|
+
origin: z.optional(
|
|
69
|
+
z.enum(["runtime_config", "trigger_context", "provider_sync", "api"]),
|
|
70
|
+
),
|
|
71
|
+
provider: z.optional(appEventFlagProviderSchema),
|
|
72
|
+
status: z.optional(z.string().check(z.trim(), z.minLength(1))),
|
|
73
|
+
reason: z.optional(z.string().check(z.trim(), z.minLength(1))),
|
|
74
|
+
evaluatedAt: z.optional(z.string().check(z.trim(), z.minLength(1))),
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
export const appEventCapabilitySchema = z.object({
|
|
78
|
+
key: z.string().check(z.trim(), z.minLength(1)),
|
|
79
|
+
source: z.optional(z.string().check(z.trim(), z.minLength(1))),
|
|
80
|
+
provider: z.optional(appEventFlagProviderSchema),
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const appEventPageSchema = z.object({
|
|
84
|
+
path: z.optional(z.string()),
|
|
85
|
+
referrer: z.optional(z.string()),
|
|
86
|
+
search: z.optional(z.string()),
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
export const appEventContextSchema = z.object({
|
|
90
|
+
page: z.optional(appEventPageSchema),
|
|
91
|
+
locale: z.optional(z.string()),
|
|
92
|
+
userAgent: z.optional(z.string()),
|
|
93
|
+
flags: z.optional(z.array(appEventFlagSchema)),
|
|
94
|
+
capabilities: z.optional(z.array(appEventCapabilitySchema)),
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
export const appEventBaseSchema = z.object({
|
|
98
|
+
traits: z.optional(z.record(z.string(), z.unknown())),
|
|
99
|
+
identities: z.optional(z.array(appEventIdentitySchema)),
|
|
100
|
+
context: z.optional(appEventContextSchema),
|
|
101
|
+
messageId: z.optional(z.string()),
|
|
102
|
+
timestamp: z.optional(z.number()),
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
const appEventSurveyReferenceSchema = z.object({
|
|
106
|
+
surveyId: z.string(),
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
export const reservedSystemAppEventNames = [
|
|
110
|
+
"Response Submitted",
|
|
111
|
+
"Flow Viewed",
|
|
112
|
+
"Flow Dismissed",
|
|
113
|
+
"Identified",
|
|
114
|
+
] as const;
|
|
115
|
+
const reservedSystemAppEventNameLowercaseSet = new Set<string>(
|
|
116
|
+
reservedSystemAppEventNames.map((event) => event.toLowerCase()),
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
const appEventSystemTrackNameSchema = z.enum(["Flow Viewed", "Flow Dismissed"]);
|
|
120
|
+
|
|
121
|
+
const appEventCustomerNameSchema = z.string().check(
|
|
122
|
+
z.trim(),
|
|
123
|
+
z.minLength(1),
|
|
124
|
+
z.maxLength(255),
|
|
125
|
+
z.check<string>((ctx) => {
|
|
126
|
+
if (!reservedSystemAppEventNameLowercaseSet.has(ctx.value.toLowerCase())) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
ctx.issues.push({
|
|
130
|
+
code: "custom",
|
|
131
|
+
input: ctx.value,
|
|
132
|
+
message:
|
|
133
|
+
"Customer app event names cannot use reserved system event names.",
|
|
134
|
+
continue: false,
|
|
135
|
+
});
|
|
136
|
+
}),
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
export const appEventSystemBaseSchema = z.extend(appEventBaseSchema, {
|
|
140
|
+
origin: z.literal("system"),
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
const normalizeSystemAppEventOrigin = <T extends { origin?: "system" }>(
|
|
144
|
+
input: T,
|
|
145
|
+
): Omit<T, "origin"> & { origin: "system" } => {
|
|
146
|
+
const { origin: _origin, ...rest } = input;
|
|
147
|
+
return {
|
|
148
|
+
...rest,
|
|
149
|
+
origin: "system" as const,
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
export const appEventSurveyViewedSchema = z.pipe(
|
|
154
|
+
z.extend(appEventBaseSchema, {
|
|
155
|
+
origin: z.optional(z.literal("system")),
|
|
156
|
+
event: z.literal("Flow Viewed"),
|
|
157
|
+
references: appEventSurveyReferenceSchema,
|
|
158
|
+
}),
|
|
159
|
+
z.transform(normalizeSystemAppEventOrigin),
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
export const appEventFlowDismissedSchema = z.pipe(
|
|
163
|
+
z.extend(appEventBaseSchema, {
|
|
164
|
+
origin: z.optional(z.literal("system")),
|
|
165
|
+
event: z.literal("Flow Dismissed"),
|
|
166
|
+
references: appEventSurveyReferenceSchema,
|
|
167
|
+
}),
|
|
168
|
+
z.transform(normalizeSystemAppEventOrigin),
|
|
169
|
+
);
|
|
170
|
+
|
|
171
|
+
export const appEventSystemTrackSchema = z.extend(appEventSystemBaseSchema, {
|
|
172
|
+
event: appEventSystemTrackNameSchema,
|
|
173
|
+
references: appEventSurveyReferenceSchema,
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
const appEventLegacySystemTrackSchema = z.pipe(
|
|
177
|
+
z.extend(appEventBaseSchema, {
|
|
178
|
+
origin: z.optional(z.literal("system")),
|
|
179
|
+
event: appEventSystemTrackNameSchema,
|
|
180
|
+
references: appEventSurveyReferenceSchema,
|
|
181
|
+
}),
|
|
182
|
+
z.transform(normalizeSystemAppEventOrigin),
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
export const appEventCustomerTrackSchema = z.extend(appEventBaseSchema, {
|
|
186
|
+
origin: z.literal("customer"),
|
|
187
|
+
event: appEventCustomerNameSchema,
|
|
188
|
+
// TODO(migration): Normalize Date values in event properties to ISO strings.
|
|
189
|
+
// [from=manual-date-property-serialization] [to=protocol-date-property-normalization] [scope=slice] [priority=medium] [impact=medium] [risk=low]
|
|
190
|
+
properties: z.optional(appEventJsonObjectSchema),
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
export const appEventTrackSchema = z.union([
|
|
194
|
+
appEventLegacySystemTrackSchema,
|
|
195
|
+
appEventCustomerTrackSchema,
|
|
196
|
+
]);
|
|
197
|
+
|
|
198
|
+
const appEventDiscriminatedPayloadSchema = z.discriminatedUnion("origin", [
|
|
199
|
+
appEventSystemTrackSchema,
|
|
200
|
+
appEventCustomerTrackSchema,
|
|
201
|
+
]);
|
|
202
|
+
|
|
203
|
+
export const appEventPayloadSchema = z.union([
|
|
204
|
+
appEventLegacySystemTrackSchema,
|
|
205
|
+
appEventDiscriminatedPayloadSchema,
|
|
206
|
+
]);
|
|
207
|
+
|
|
208
|
+
export type AppEventTrackInput = z.output<typeof appEventTrackSchema>;
|
|
209
|
+
export type AppEventPayload = z.output<typeof appEventPayloadSchema>;
|
|
210
|
+
export type AppEventFlag = z.output<typeof appEventFlagSchema>;
|
|
211
|
+
export type AppEventCapability = z.output<typeof appEventCapabilitySchema>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as z from "zod/mini";
|
|
2
|
+
|
|
3
|
+
export const clientMetaSchema = z.object({
|
|
4
|
+
loader: z.enum(["sdk", "gtm", "segment", "rudderstack", "tealium", "custom"]),
|
|
5
|
+
clientName: z.optional(z.string().check(z.trim(), z.minLength(1))),
|
|
6
|
+
clientVersion: z.optional(z.string().check(z.trim(), z.minLength(1))),
|
|
7
|
+
integrator: z.optional(
|
|
8
|
+
z.object({
|
|
9
|
+
name: z.optional(z.string().check(z.trim(), z.minLength(1))),
|
|
10
|
+
version: z.optional(z.string().check(z.trim(), z.minLength(1))),
|
|
11
|
+
}),
|
|
12
|
+
),
|
|
13
|
+
transport: z.optional(
|
|
14
|
+
z.enum(["script-tag", "esm", "loader", "tag-manager", "snippet"]),
|
|
15
|
+
),
|
|
16
|
+
runtime: z.optional(
|
|
17
|
+
z.object({
|
|
18
|
+
framework: z.optional(z.enum(["next", "vite", "webpack", "plain"])),
|
|
19
|
+
runtime: z.optional(z.enum(["browser", "edge"])),
|
|
20
|
+
}),
|
|
21
|
+
),
|
|
22
|
+
notes: z.optional(z.string().check(z.trim(), z.minLength(1))),
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export type ClientMeta = z.output<typeof clientMetaSchema>;
|
package/src/defaults.ts
ADDED
package/src/errors.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import * as z from "zod/mini";
|
|
2
|
+
|
|
3
|
+
import { clientMetaSchema } from "./client-meta.js";
|
|
4
|
+
|
|
5
|
+
// ---------------------------------------------------------------------------
|
|
6
|
+
// Error-telemetry definitions shared across widget / host.
|
|
7
|
+
// ---------------------------------------------------------------------------
|
|
8
|
+
|
|
9
|
+
export const ErrorCategory = {
|
|
10
|
+
INTERNAL: "INTERNAL",
|
|
11
|
+
INVALID_USAGE: "INVALID_USAGE",
|
|
12
|
+
HOST: "HOST",
|
|
13
|
+
} as const;
|
|
14
|
+
|
|
15
|
+
export type ErrorCategory = (typeof ErrorCategory)[keyof typeof ErrorCategory];
|
|
16
|
+
|
|
17
|
+
export const ErrorCategorySchema = z.enum([
|
|
18
|
+
ErrorCategory.INTERNAL,
|
|
19
|
+
ErrorCategory.INVALID_USAGE,
|
|
20
|
+
ErrorCategory.HOST,
|
|
21
|
+
]);
|
|
22
|
+
|
|
23
|
+
export const ErrorEventSchema = z.object({
|
|
24
|
+
id: z.string(),
|
|
25
|
+
name: z.string(),
|
|
26
|
+
message: z.string(),
|
|
27
|
+
stack: z.optional(z.string()),
|
|
28
|
+
category: ErrorCategorySchema,
|
|
29
|
+
timestamp: z.number(),
|
|
30
|
+
probability: z.optional(z.number()),
|
|
31
|
+
context: z.object({
|
|
32
|
+
widgetVersion: z.string(),
|
|
33
|
+
clientMeta: z.optional(clientMetaSchema),
|
|
34
|
+
/** When true, telemetry was captured with debug mode on (affects how to interpret context). */
|
|
35
|
+
debug: z.optional(z.boolean()),
|
|
36
|
+
}),
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
export type ErrorEvent = z.output<typeof ErrorEventSchema>;
|
|
40
|
+
|
|
41
|
+
export type ProtocolErrorCode = "PARSE" | "VERSION" | "UNKNOWN_TYPE";
|
|
42
|
+
|
|
43
|
+
const MAX_DETAIL_LENGTH = 80;
|
|
44
|
+
|
|
45
|
+
export class ProtocolError extends Error {
|
|
46
|
+
code: ProtocolErrorCode;
|
|
47
|
+
details: string;
|
|
48
|
+
|
|
49
|
+
constructor(code: ProtocolErrorCode, details: string) {
|
|
50
|
+
const short =
|
|
51
|
+
details.length > MAX_DETAIL_LENGTH
|
|
52
|
+
? details.slice(0, MAX_DETAIL_LENGTH)
|
|
53
|
+
: details;
|
|
54
|
+
super(short);
|
|
55
|
+
this.code = code;
|
|
56
|
+
this.details = short;
|
|
57
|
+
}
|
|
58
|
+
}
|