@getuserfeedback/protocol 0.5.11 → 0.6.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.
- package/dist/app-event.d.ts +274 -274
- package/dist/app-event.d.ts.map +1 -1
- package/dist/app-event.js +16 -16
- package/dist/client-meta.d.ts +13 -13
- package/dist/client-meta.d.ts.map +1 -1
- package/dist/client-meta.js +6 -6
- package/dist/flow-assignments.d.ts +183 -183
- package/dist/flow-assignments.d.ts.map +1 -1
- package/dist/flow-assignments.js +16 -16
- package/dist/host/sdk-types.d.ts +8 -4
- package/dist/host/sdk-types.d.ts.map +1 -1
- package/dist/identity-type.d.ts +2 -2
- package/dist/identity-type.d.ts.map +1 -1
- package/dist/identity-type.js +13 -15
- package/dist/index.d.ts +86 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- package/dist/public-grant-scope.d.ts +12 -0
- package/dist/public-grant-scope.d.ts.map +1 -0
- package/dist/public-grant-scope.js +13 -0
- package/dist/runtime-endpoints.d.ts +4 -4
- package/dist/runtime-endpoints.d.ts.map +1 -1
- package/dist/runtime-endpoints.js +4 -6
- package/dist/scopes.d.ts +4 -4
- package/dist/scopes.d.ts.map +1 -1
- package/dist/scopes.js +1 -1
- package/dist/trpc-envelope.d.ts +4 -4
- package/dist/trpc-envelope.d.ts.map +1 -1
- package/dist/trpc-envelope.js +1 -1
- package/dist/version-resolution.d.ts +5 -5
- package/dist/version-resolution.d.ts.map +1 -1
- package/dist/version-resolution.js +2 -2
- package/dist/widget-commands.d.ts +112 -108
- package/dist/widget-commands.d.ts.map +1 -1
- package/dist/widget-commands.js +30 -56
- package/dist/widget-config.d.ts +315 -96
- package/dist/widget-config.d.ts.map +1 -1
- package/dist/widget-config.js +65 -35
- package/package.json +1 -1
package/dist/widget-config.js
CHANGED
|
@@ -1,61 +1,51 @@
|
|
|
1
|
-
import * as z from "zod";
|
|
1
|
+
import * as z from "zod/mini";
|
|
2
2
|
import { appEventCapabilitySchema, appEventFlagSchema } from "./app-event.js";
|
|
3
3
|
import { clientMetaSchema } from "./client-meta.js";
|
|
4
4
|
import { DEFAULT_AUTO_DETECT_COLOR_SCHEME_ATTRS } from "./defaults.js";
|
|
5
5
|
import { runtimeEndpointsSchema } from "./runtime-endpoints.js";
|
|
6
|
+
import { scopeIdSchema } from "./scopes.js";
|
|
6
7
|
const colorSchemeValueSchema = z.enum(["light", "dark", "system"]);
|
|
7
8
|
const autoDetectColorSchemeArraySchema = z
|
|
8
|
-
.array(z.string().trim().
|
|
9
|
-
.
|
|
10
|
-
const publicGrantScopeIds = [
|
|
11
|
-
"analytics.storage",
|
|
12
|
-
"analytics.measurement",
|
|
13
|
-
"personalization.storage",
|
|
14
|
-
"ads.storage",
|
|
15
|
-
"ads.user_data",
|
|
16
|
-
"ads.personalization",
|
|
17
|
-
];
|
|
18
|
-
export const publicGrantScopeIdSchema = z.enum(publicGrantScopeIds);
|
|
19
|
-
export function isPublicGrantScope(value) {
|
|
20
|
-
return publicGrantScopeIdSchema.safeParse(value).success;
|
|
21
|
-
}
|
|
9
|
+
.array(z.string().check(z.trim(), z.minLength(1)))
|
|
10
|
+
.check(z.minLength(1));
|
|
22
11
|
export const colorSchemeConfigInputSchema = z.union([
|
|
23
|
-
z
|
|
24
|
-
.object({
|
|
12
|
+
z.strictObject({
|
|
25
13
|
autoDetectColorScheme: autoDetectColorSchemeArraySchema,
|
|
26
|
-
})
|
|
27
|
-
.strict(),
|
|
14
|
+
}),
|
|
28
15
|
colorSchemeValueSchema,
|
|
29
16
|
]);
|
|
17
|
+
export const telemetryConfigInputSchema = z.object({
|
|
18
|
+
enabled: z.optional(z.boolean()),
|
|
19
|
+
});
|
|
30
20
|
export const consentConfigInputSchema = z.union([
|
|
31
21
|
z.enum(["granted", "denied", "pending", "revoked"]),
|
|
32
|
-
z.array(
|
|
22
|
+
z.array(scopeIdSchema),
|
|
33
23
|
]);
|
|
34
24
|
export const debugInputSchema = z.union([
|
|
35
25
|
z.boolean(),
|
|
36
26
|
z.string(),
|
|
37
27
|
z.array(z.string()),
|
|
38
28
|
]);
|
|
29
|
+
export const authJwtConfigInputSchema = z.object({
|
|
30
|
+
token: z.string().check(z.trim(), z.minLength(1)),
|
|
31
|
+
});
|
|
39
32
|
export const authConfigInputSchema = z.object({
|
|
40
|
-
jwt: z.optional(z.union([
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
33
|
+
jwt: z.optional(z.union([authJwtConfigInputSchema, z.null()])),
|
|
34
|
+
});
|
|
35
|
+
export const identityConfigInputSchema = z.object({
|
|
36
|
+
anonymousId: z.optional(z.string().check(z.trim(), z.minLength(1))),
|
|
37
|
+
userId: z.optional(z.string().check(z.trim(), z.minLength(1))),
|
|
38
|
+
traits: z.optional(z.record(z.string(), z.unknown())),
|
|
46
39
|
});
|
|
47
40
|
export const flagsConfigInputSchema = z.array(appEventFlagSchema);
|
|
48
41
|
export const hostCapabilitiesConfigInputSchema = z.array(appEventCapabilitySchema);
|
|
49
|
-
export const configureOptionsSchema = z
|
|
50
|
-
.object({
|
|
42
|
+
export const configureOptionsSchema = z.strictObject({
|
|
51
43
|
colorScheme: z.optional(colorSchemeConfigInputSchema),
|
|
52
44
|
consent: z.optional(consentConfigInputSchema),
|
|
53
45
|
auth: z.optional(authConfigInputSchema),
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
.object({
|
|
58
|
-
apiKey: z.string().trim().min(1),
|
|
46
|
+
});
|
|
47
|
+
export const initOptionsSchema = z.strictObject({
|
|
48
|
+
apiKey: z.string().check(z.trim(), z.minLength(1)),
|
|
59
49
|
colorScheme: z.optional(colorSchemeConfigInputSchema),
|
|
60
50
|
disableTelemetry: z.optional(z.boolean()),
|
|
61
51
|
enableDebug: z.optional(debugInputSchema),
|
|
@@ -65,8 +55,48 @@ export const initOptionsSchema = z
|
|
|
65
55
|
flags: z.optional(flagsConfigInputSchema),
|
|
66
56
|
hostCapabilities: z.optional(hostCapabilitiesConfigInputSchema),
|
|
67
57
|
runtimeEndpoints: z.optional(runtimeEndpointsSchema),
|
|
68
|
-
})
|
|
69
|
-
.strict();
|
|
58
|
+
});
|
|
70
59
|
export const DEFAULT_COLOR_SCHEME_CONFIG = {
|
|
71
60
|
autoDetectColorScheme: [...DEFAULT_AUTO_DETECT_COLOR_SCHEME_ATTRS],
|
|
72
61
|
};
|
|
62
|
+
/**
|
|
63
|
+
* Schema for the subset of instance config that can be updated via merge (any source).
|
|
64
|
+
* Telemetry, enableDebug, clientMeta, SDK protocol capabilities, customer
|
|
65
|
+
* flags, and customer host capabilities are set at registration only.
|
|
66
|
+
*/
|
|
67
|
+
export const instanceUpdateableConfigSchema = z.strictObject({
|
|
68
|
+
colorScheme: z.optional(colorSchemeConfigInputSchema),
|
|
69
|
+
consent: z.optional(consentConfigInputSchema),
|
|
70
|
+
auth: z.optional(authConfigInputSchema),
|
|
71
|
+
identity: z.optional(identityConfigInputSchema),
|
|
72
|
+
});
|
|
73
|
+
/** Keys that may be merged into instance config (updatable subset). */
|
|
74
|
+
export const INSTANCE_CONFIG_UPDATE_KEYS = [
|
|
75
|
+
"colorScheme",
|
|
76
|
+
"consent",
|
|
77
|
+
"auth",
|
|
78
|
+
"identity",
|
|
79
|
+
];
|
|
80
|
+
/**
|
|
81
|
+
* Schema for resolved instance config state. Used when producing or validating
|
|
82
|
+
* stored config (e.g. after register or merge). Defaults are applied here so
|
|
83
|
+
* state always has a full shape; parse partial input with this schema to get
|
|
84
|
+
* resolved state. For update shape use InstanceUpdateableConfig. Configure
|
|
85
|
+
* command opts are in widget-commands (widgetConfigUpdateSchema).
|
|
86
|
+
*/
|
|
87
|
+
export const coreInstanceConfigSchema = z.strictObject({
|
|
88
|
+
colorScheme: z._default(z.optional(colorSchemeConfigInputSchema), {
|
|
89
|
+
autoDetectColorScheme: [...DEFAULT_AUTO_DETECT_COLOR_SCHEME_ATTRS],
|
|
90
|
+
}),
|
|
91
|
+
disableTelemetry: z._default(z.optional(z.boolean()), false),
|
|
92
|
+
enableDebug: z._default(z.optional(debugInputSchema), false),
|
|
93
|
+
consent: z.optional(consentConfigInputSchema),
|
|
94
|
+
auth: z.optional(authConfigInputSchema),
|
|
95
|
+
identity: z.optional(identityConfigInputSchema),
|
|
96
|
+
apiKey: z.string().check(z.trim(), z.minLength(1)),
|
|
97
|
+
clientMeta: z.optional(clientMetaSchema),
|
|
98
|
+
capabilities: z.optional(z.array(z.string())),
|
|
99
|
+
flags: z.optional(flagsConfigInputSchema),
|
|
100
|
+
hostCapabilities: z.optional(hostCapabilitiesConfigInputSchema),
|
|
101
|
+
runtimeEndpoints: z.optional(runtimeEndpointsSchema),
|
|
102
|
+
});
|