@getuserfeedback/protocol 0.5.0 → 0.5.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 +8 -72
- package/dist/app-event.d.ts.map +1 -1
- package/dist/app-event.js +2 -9
- package/dist/identity-type.d.ts +8 -0
- package/dist/identity-type.d.ts.map +1 -0
- package/dist/identity-type.js +59 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/runtime-endpoints.d.ts +3 -0
- package/dist/runtime-endpoints.d.ts.map +1 -1
- package/dist/runtime-endpoints.js +49 -0
- package/package.json +1 -1
package/dist/app-event.d.ts
CHANGED
|
@@ -1,23 +1,7 @@
|
|
|
1
1
|
import * as z from "zod";
|
|
2
|
-
export
|
|
3
|
-
anonymousId: "anonymousId";
|
|
4
|
-
userId: "userId";
|
|
5
|
-
"traits.email": "traits.email";
|
|
6
|
-
"traits.phone": "traits.phone";
|
|
7
|
-
"context.device.id": "context.device.id";
|
|
8
|
-
"context.device.advertisingId": "context.device.advertisingId";
|
|
9
|
-
"context.device.token": "context.device.token";
|
|
10
|
-
}>;
|
|
2
|
+
export { appEventIdentityTypeSchema } from "./identity-type.js";
|
|
11
3
|
export declare const appEventIdentitySchema: z.ZodObject<{
|
|
12
|
-
type: z.
|
|
13
|
-
anonymousId: "anonymousId";
|
|
14
|
-
userId: "userId";
|
|
15
|
-
"traits.email": "traits.email";
|
|
16
|
-
"traits.phone": "traits.phone";
|
|
17
|
-
"context.device.id": "context.device.id";
|
|
18
|
-
"context.device.advertisingId": "context.device.advertisingId";
|
|
19
|
-
"context.device.token": "context.device.token";
|
|
20
|
-
}>;
|
|
4
|
+
type: z.ZodPipe<z.ZodString, z.ZodTransform<"anonymousId" | "userId" | "traits.email" | "traits.phone" | "context.device.id" | "context.device.advertisingId" | "context.device.token", string>>;
|
|
21
5
|
value: z.ZodString;
|
|
22
6
|
}, z.core.$strip>;
|
|
23
7
|
export declare const appEventContextSchema: z.ZodObject<{
|
|
@@ -32,15 +16,7 @@ export declare const appEventContextSchema: z.ZodObject<{
|
|
|
32
16
|
export declare const appEventBaseSchema: z.ZodObject<{
|
|
33
17
|
traits: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
34
18
|
identities: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
35
|
-
type: z.
|
|
36
|
-
anonymousId: "anonymousId";
|
|
37
|
-
userId: "userId";
|
|
38
|
-
"traits.email": "traits.email";
|
|
39
|
-
"traits.phone": "traits.phone";
|
|
40
|
-
"context.device.id": "context.device.id";
|
|
41
|
-
"context.device.advertisingId": "context.device.advertisingId";
|
|
42
|
-
"context.device.token": "context.device.token";
|
|
43
|
-
}>;
|
|
19
|
+
type: z.ZodPipe<z.ZodString, z.ZodTransform<"anonymousId" | "userId" | "traits.email" | "traits.phone" | "context.device.id" | "context.device.advertisingId" | "context.device.token", string>>;
|
|
44
20
|
value: z.ZodString;
|
|
45
21
|
}, z.core.$strip>>>;
|
|
46
22
|
context: z.ZodOptional<z.ZodObject<{
|
|
@@ -58,15 +34,7 @@ export declare const appEventBaseSchema: z.ZodObject<{
|
|
|
58
34
|
export declare const appEventSurveyViewedSchema: z.ZodObject<{
|
|
59
35
|
traits: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
60
36
|
identities: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
61
|
-
type: z.
|
|
62
|
-
anonymousId: "anonymousId";
|
|
63
|
-
userId: "userId";
|
|
64
|
-
"traits.email": "traits.email";
|
|
65
|
-
"traits.phone": "traits.phone";
|
|
66
|
-
"context.device.id": "context.device.id";
|
|
67
|
-
"context.device.advertisingId": "context.device.advertisingId";
|
|
68
|
-
"context.device.token": "context.device.token";
|
|
69
|
-
}>;
|
|
37
|
+
type: z.ZodPipe<z.ZodString, z.ZodTransform<"anonymousId" | "userId" | "traits.email" | "traits.phone" | "context.device.id" | "context.device.advertisingId" | "context.device.token", string>>;
|
|
70
38
|
value: z.ZodString;
|
|
71
39
|
}, z.core.$strip>>>;
|
|
72
40
|
context: z.ZodOptional<z.ZodObject<{
|
|
@@ -88,15 +56,7 @@ export declare const appEventSurveyViewedSchema: z.ZodObject<{
|
|
|
88
56
|
export declare const appEventFlowDismissedSchema: z.ZodObject<{
|
|
89
57
|
traits: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
90
58
|
identities: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
91
|
-
type: z.
|
|
92
|
-
anonymousId: "anonymousId";
|
|
93
|
-
userId: "userId";
|
|
94
|
-
"traits.email": "traits.email";
|
|
95
|
-
"traits.phone": "traits.phone";
|
|
96
|
-
"context.device.id": "context.device.id";
|
|
97
|
-
"context.device.advertisingId": "context.device.advertisingId";
|
|
98
|
-
"context.device.token": "context.device.token";
|
|
99
|
-
}>;
|
|
59
|
+
type: z.ZodPipe<z.ZodString, z.ZodTransform<"anonymousId" | "userId" | "traits.email" | "traits.phone" | "context.device.id" | "context.device.advertisingId" | "context.device.token", string>>;
|
|
100
60
|
value: z.ZodString;
|
|
101
61
|
}, z.core.$strip>>>;
|
|
102
62
|
context: z.ZodOptional<z.ZodObject<{
|
|
@@ -118,15 +78,7 @@ export declare const appEventFlowDismissedSchema: z.ZodObject<{
|
|
|
118
78
|
export declare const appEventTrackSchema: z.ZodObject<{
|
|
119
79
|
traits: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
120
80
|
identities: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
121
|
-
type: z.
|
|
122
|
-
anonymousId: "anonymousId";
|
|
123
|
-
userId: "userId";
|
|
124
|
-
"traits.email": "traits.email";
|
|
125
|
-
"traits.phone": "traits.phone";
|
|
126
|
-
"context.device.id": "context.device.id";
|
|
127
|
-
"context.device.advertisingId": "context.device.advertisingId";
|
|
128
|
-
"context.device.token": "context.device.token";
|
|
129
|
-
}>;
|
|
81
|
+
type: z.ZodPipe<z.ZodString, z.ZodTransform<"anonymousId" | "userId" | "traits.email" | "traits.phone" | "context.device.id" | "context.device.advertisingId" | "context.device.token", string>>;
|
|
130
82
|
value: z.ZodString;
|
|
131
83
|
}, z.core.$strip>>>;
|
|
132
84
|
context: z.ZodOptional<z.ZodObject<{
|
|
@@ -151,15 +103,7 @@ export declare const appEventTrackSchema: z.ZodObject<{
|
|
|
151
103
|
export declare const appEventPayloadSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
152
104
|
traits: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
153
105
|
identities: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
154
|
-
type: z.
|
|
155
|
-
anonymousId: "anonymousId";
|
|
156
|
-
userId: "userId";
|
|
157
|
-
"traits.email": "traits.email";
|
|
158
|
-
"traits.phone": "traits.phone";
|
|
159
|
-
"context.device.id": "context.device.id";
|
|
160
|
-
"context.device.advertisingId": "context.device.advertisingId";
|
|
161
|
-
"context.device.token": "context.device.token";
|
|
162
|
-
}>;
|
|
106
|
+
type: z.ZodPipe<z.ZodString, z.ZodTransform<"anonymousId" | "userId" | "traits.email" | "traits.phone" | "context.device.id" | "context.device.advertisingId" | "context.device.token", string>>;
|
|
163
107
|
value: z.ZodString;
|
|
164
108
|
}, z.core.$strip>>>;
|
|
165
109
|
context: z.ZodOptional<z.ZodObject<{
|
|
@@ -180,15 +124,7 @@ export declare const appEventPayloadSchema: z.ZodDiscriminatedUnion<[z.ZodObject
|
|
|
180
124
|
}, z.core.$strip>, z.ZodObject<{
|
|
181
125
|
traits: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
182
126
|
identities: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
183
|
-
type: z.
|
|
184
|
-
anonymousId: "anonymousId";
|
|
185
|
-
userId: "userId";
|
|
186
|
-
"traits.email": "traits.email";
|
|
187
|
-
"traits.phone": "traits.phone";
|
|
188
|
-
"context.device.id": "context.device.id";
|
|
189
|
-
"context.device.advertisingId": "context.device.advertisingId";
|
|
190
|
-
"context.device.token": "context.device.token";
|
|
191
|
-
}>;
|
|
127
|
+
type: z.ZodPipe<z.ZodString, z.ZodTransform<"anonymousId" | "userId" | "traits.email" | "traits.phone" | "context.device.id" | "context.device.advertisingId" | "context.device.token", string>>;
|
|
192
128
|
value: z.ZodString;
|
|
193
129
|
}, z.core.$strip>>>;
|
|
194
130
|
context: z.ZodOptional<z.ZodObject<{
|
package/dist/app-event.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-event.d.ts","sourceRoot":"","sources":["../src/app-event.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"app-event.d.ts","sourceRoot":"","sources":["../src/app-event.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAGzB,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAEhE,eAAO,MAAM,sBAAsB;;;iBAGjC,CAAC;AAQH,eAAO,MAAM,qBAAqB;;;;;;;;iBAIhC,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;iBAM7B,CAAC;AAMH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;iBAGrC,CAAC;AAEH,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;iBAGtC,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;iBAG9B,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BAGhC,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,mBAAmB,CAAC,CAAC;AACtE,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
|
package/dist/app-event.js
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
import * as z from "zod";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
"userId",
|
|
5
|
-
"traits.email",
|
|
6
|
-
"traits.phone",
|
|
7
|
-
"context.device.id",
|
|
8
|
-
"context.device.advertisingId",
|
|
9
|
-
"context.device.token",
|
|
10
|
-
]);
|
|
2
|
+
import { appEventIdentityTypeSchema } from "./identity-type.js";
|
|
3
|
+
export { appEventIdentityTypeSchema } from "./identity-type.js";
|
|
11
4
|
export const appEventIdentitySchema = z.object({
|
|
12
5
|
type: appEventIdentityTypeSchema,
|
|
13
6
|
value: z.string().trim().min(1),
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
export declare const IDENTITY_TYPE_VALUES: readonly ["anonymousId", "userId", "traits.email", "traits.phone", "context.device.id", "context.device.advertisingId", "context.device.token"];
|
|
3
|
+
export type IdentityTypeValue = (typeof IDENTITY_TYPE_VALUES)[number];
|
|
4
|
+
export declare const isIdentityTypeValue: (value: string) => value is IdentityTypeValue;
|
|
5
|
+
export declare const getIdentityTypeSuggestion: (value: string) => IdentityTypeValue | null;
|
|
6
|
+
export declare const buildIdentityTypeGuidanceMessage: (value: string) => string;
|
|
7
|
+
export declare const appEventIdentityTypeSchema: z.ZodPipe<z.ZodString, z.ZodTransform<"anonymousId" | "userId" | "traits.email" | "traits.phone" | "context.device.id" | "context.device.advertisingId" | "context.device.token", string>>;
|
|
8
|
+
//# sourceMappingURL=identity-type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity-type.d.ts","sourceRoot":"","sources":["../src/identity-type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAEzB,eAAO,MAAM,oBAAoB,iJAQvB,CAAC;AAEX,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;AAsBtE,eAAO,MAAM,mBAAmB,GAC/B,OAAO,MAAM,KACX,KAAK,IAAI,iBACkD,CAAC;AAK/D,eAAO,MAAM,yBAAyB,GACrC,OAAO,MAAM,KACX,iBAAiB,GAAG,IACuD,CAAC;AAE/E,eAAO,MAAM,gCAAgC,GAAI,OAAO,MAAM,KAAG,MAehE,CAAC;AAEF,eAAO,MAAM,0BAA0B,4LAqBpC,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
export const IDENTITY_TYPE_VALUES = [
|
|
3
|
+
"anonymousId",
|
|
4
|
+
"userId",
|
|
5
|
+
"traits.email",
|
|
6
|
+
"traits.phone",
|
|
7
|
+
"context.device.id",
|
|
8
|
+
"context.device.advertisingId",
|
|
9
|
+
"context.device.token",
|
|
10
|
+
];
|
|
11
|
+
const IDENTITY_TYPE_ALIAS_SUGGESTIONS = {
|
|
12
|
+
advertising_id: "context.device.advertisingId",
|
|
13
|
+
anonymous_id: "anonymousId",
|
|
14
|
+
device_id: "context.device.id",
|
|
15
|
+
device_token: "context.device.token",
|
|
16
|
+
email: "traits.email",
|
|
17
|
+
phone: "traits.phone",
|
|
18
|
+
phone_number: "traits.phone",
|
|
19
|
+
user_id: "userId",
|
|
20
|
+
};
|
|
21
|
+
const COMMON_IDENTITY_TYPE_MAPPINGS = [
|
|
22
|
+
["email", "traits.email"],
|
|
23
|
+
["phone", "traits.phone"],
|
|
24
|
+
["user_id", "userId"],
|
|
25
|
+
];
|
|
26
|
+
const normalizeIdentityTypeAliasKey = (value) => value.trim().toLowerCase().replace(/-/g, "_");
|
|
27
|
+
export const isIdentityTypeValue = (value) => IDENTITY_TYPE_VALUES.some((candidate) => candidate === value);
|
|
28
|
+
const parseIdentityTypeValue = (value) => isIdentityTypeValue(value) ? value : null;
|
|
29
|
+
export const getIdentityTypeSuggestion = (value) => IDENTITY_TYPE_ALIAS_SUGGESTIONS[normalizeIdentityTypeAliasKey(value)] ?? null;
|
|
30
|
+
export const buildIdentityTypeGuidanceMessage = (value) => {
|
|
31
|
+
const normalizedValue = value.trim();
|
|
32
|
+
const displayValue = normalizedValue.length > 0 ? `"${normalizedValue}"` : "that value";
|
|
33
|
+
const suggestion = getIdentityTypeSuggestion(value);
|
|
34
|
+
if (suggestion) {
|
|
35
|
+
return `Unsupported identity type ${displayValue}. Use "${suggestion}" instead.`;
|
|
36
|
+
}
|
|
37
|
+
const mappingExamples = COMMON_IDENTITY_TYPE_MAPPINGS.map(([from, to]) => `${from} -> ${to}`).join(", ");
|
|
38
|
+
return `Unsupported identity type ${displayValue}. Use one of: ${IDENTITY_TYPE_VALUES.join(", ")}. Common mappings: ${mappingExamples}.`;
|
|
39
|
+
};
|
|
40
|
+
export const appEventIdentityTypeSchema = z
|
|
41
|
+
.string()
|
|
42
|
+
.trim()
|
|
43
|
+
.min(1, "Identity type is required.")
|
|
44
|
+
.superRefine((value, ctx) => {
|
|
45
|
+
if (!isIdentityTypeValue(value)) {
|
|
46
|
+
ctx.addIssue({
|
|
47
|
+
code: "custom",
|
|
48
|
+
fatal: true,
|
|
49
|
+
message: buildIdentityTypeGuidanceMessage(value),
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
.transform((value) => {
|
|
54
|
+
const parsed = parseIdentityTypeValue(value);
|
|
55
|
+
if (parsed === null) {
|
|
56
|
+
throw new Error(`Identity type should have been validated before transform: ${value}`);
|
|
57
|
+
}
|
|
58
|
+
return parsed;
|
|
59
|
+
});
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export { type AppEventPayload, type AppEventTrackInput, appEventBaseSchema, appEventContextSchema, appEventFlowDismissedSchema, appEventIdentitySchema, appEventIdentityTypeSchema, appEventPayloadSchema, appEventSurveyViewedSchema, appEventTrackSchema, } from "./app-event.js";
|
|
2
2
|
export { type ClientMeta, clientMetaSchema, } from "./client-meta.js";
|
|
3
3
|
export { DEFAULT_AUTO_DETECT_COLOR_SCHEME_ATTRS } from "./defaults.js";
|
|
4
|
+
export { buildIdentityTypeGuidanceMessage, getIdentityTypeSuggestion, IDENTITY_TYPE_VALUES, type IdentityTypeValue, isIdentityTypeValue, } from "./identity-type.js";
|
|
5
|
+
export { type RuntimeEndpoints, resolveApiBaseUrl, resolveCoreUrl, resolveTrpcBaseUrl, runtimeEndpointsSchema, } from "./runtime-endpoints.js";
|
|
4
6
|
export { getScopeMeta, isScope, listScopes, SCOPE_IDS, type Scope, scopeIdSchema, } from "./scopes.js";
|
|
5
7
|
export { type FlowVersionResolution, flowVersionResolutionSchema, type ThemeVersionResolution, themeVersionResolutionSchema, } from "./version-resolution.js";
|
|
6
8
|
export { type PublicCommandPayload, parseConfigureOptions, parseInitOptions, parsePublicCommand, publicCommandPayloadSchema, } from "./widget-commands.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,kBAAkB,EAClB,qBAAqB,EACrB,2BAA2B,EAC3B,sBAAsB,EACtB,0BAA0B,EAC1B,qBAAqB,EACrB,0BAA0B,EAC1B,mBAAmB,GACnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACN,KAAK,UAAU,EACf,gBAAgB,GAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,sCAAsC,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EACN,YAAY,EACZ,OAAO,EACP,UAAU,EACV,SAAS,EACT,KAAK,KAAK,EACV,aAAa,GACb,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,KAAK,qBAAqB,EAC1B,2BAA2B,EAC3B,KAAK,sBAAsB,EAC3B,4BAA4B,GAC5B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACN,KAAK,oBAAoB,EACzB,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,0BAA0B,GAC1B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACN,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,4BAA4B,EAC5B,sBAAsB,EACtB,wBAAwB,EACxB,KAAK,WAAW,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,KAAK,gBAAgB,EACrB,wBAAwB,GACxB,MAAM,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,kBAAkB,EAClB,qBAAqB,EACrB,2BAA2B,EAC3B,sBAAsB,EACtB,0BAA0B,EAC1B,qBAAqB,EACrB,0BAA0B,EAC1B,mBAAmB,GACnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACN,KAAK,UAAU,EACf,gBAAgB,GAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,sCAAsC,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EACN,gCAAgC,EAChC,yBAAyB,EACzB,oBAAoB,EACpB,KAAK,iBAAiB,EACtB,mBAAmB,GACnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACN,KAAK,gBAAgB,EACrB,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,sBAAsB,GACtB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,YAAY,EACZ,OAAO,EACP,UAAU,EACV,SAAS,EACT,KAAK,KAAK,EACV,aAAa,GACb,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,KAAK,qBAAqB,EAC1B,2BAA2B,EAC3B,KAAK,sBAAsB,EAC3B,4BAA4B,GAC5B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACN,KAAK,oBAAoB,EACzB,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,0BAA0B,GAC1B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACN,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,4BAA4B,EAC5B,sBAAsB,EACtB,wBAAwB,EACxB,KAAK,WAAW,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,KAAK,gBAAgB,EACrB,wBAAwB,GACxB,MAAM,oBAAoB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export { appEventBaseSchema, appEventContextSchema, appEventFlowDismissedSchema, appEventIdentitySchema, appEventIdentityTypeSchema, appEventPayloadSchema, appEventSurveyViewedSchema, appEventTrackSchema, } from "./app-event.js";
|
|
2
2
|
export { clientMetaSchema, } from "./client-meta.js";
|
|
3
3
|
export { DEFAULT_AUTO_DETECT_COLOR_SCHEME_ATTRS } from "./defaults.js";
|
|
4
|
+
export { buildIdentityTypeGuidanceMessage, getIdentityTypeSuggestion, IDENTITY_TYPE_VALUES, isIdentityTypeValue, } from "./identity-type.js";
|
|
5
|
+
export { resolveApiBaseUrl, resolveCoreUrl, resolveTrpcBaseUrl, runtimeEndpointsSchema, } from "./runtime-endpoints.js";
|
|
4
6
|
export { getScopeMeta, isScope, listScopes, SCOPE_IDS, scopeIdSchema, } from "./scopes.js";
|
|
5
7
|
export { flowVersionResolutionSchema, themeVersionResolutionSchema, } from "./version-resolution.js";
|
|
6
8
|
export { parseConfigureOptions, parseInitOptions, parsePublicCommand, publicCommandPayloadSchema, } from "./widget-commands.js";
|
|
@@ -4,4 +4,7 @@ export declare const runtimeEndpointsSchema: z.ZodObject<{
|
|
|
4
4
|
coreUrl: z.ZodOptional<z.ZodString>;
|
|
5
5
|
}, z.core.$strict>;
|
|
6
6
|
export type RuntimeEndpoints = z.output<typeof runtimeEndpointsSchema>;
|
|
7
|
+
export declare const resolveCoreUrl: (runtimeEndpoints: RuntimeEndpoints | undefined) => URL | null;
|
|
8
|
+
export declare const resolveApiBaseUrl: (runtimeEndpoints: RuntimeEndpoints | undefined) => URL | null;
|
|
9
|
+
export declare const resolveTrpcBaseUrl: (runtimeEndpoints: RuntimeEndpoints | undefined) => URL | null;
|
|
7
10
|
//# sourceMappingURL=runtime-endpoints.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-endpoints.d.ts","sourceRoot":"","sources":["../src/runtime-endpoints.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAIzB,eAAO,MAAM,sBAAsB;;;kBAKzB,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,sBAAsB,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"runtime-endpoints.d.ts","sourceRoot":"","sources":["../src/runtime-endpoints.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAIzB,eAAO,MAAM,sBAAsB;;;kBAKzB,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAqBvE,eAAO,MAAM,cAAc,GAC1B,kBAAkB,gBAAgB,GAAG,SAAS,KAC5C,GAAG,GAAG,IAER,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAC7B,kBAAkB,gBAAgB,GAAG,SAAS,KAC5C,GAAG,GAAG,IAaR,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAC9B,kBAAkB,gBAAgB,GAAG,SAAS,KAC5C,GAAG,GAAG,IAaR,CAAC"}
|
|
@@ -6,3 +6,52 @@ export const runtimeEndpointsSchema = z
|
|
|
6
6
|
coreUrl: z.optional(absoluteUrlSchema),
|
|
7
7
|
})
|
|
8
8
|
.strict();
|
|
9
|
+
const parseAbsoluteUrl = (value) => {
|
|
10
|
+
if (!value) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
try {
|
|
14
|
+
return new URL(value);
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const normalizeOrigin = (value) => {
|
|
21
|
+
const parsed = parseAbsoluteUrl(value);
|
|
22
|
+
if (!parsed) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
return parsed.origin;
|
|
26
|
+
};
|
|
27
|
+
export const resolveCoreUrl = (runtimeEndpoints) => {
|
|
28
|
+
return parseAbsoluteUrl(runtimeEndpoints?.coreUrl);
|
|
29
|
+
};
|
|
30
|
+
export const resolveApiBaseUrl = (runtimeEndpoints) => {
|
|
31
|
+
const apiUrl = runtimeEndpoints?.apiUrl;
|
|
32
|
+
const parsed = parseAbsoluteUrl(apiUrl);
|
|
33
|
+
if (!parsed) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
if (!parsed.pathname || parsed.pathname === "/") {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
if (!parsed.pathname.endsWith("/")) {
|
|
40
|
+
parsed.pathname = `${parsed.pathname}/`;
|
|
41
|
+
}
|
|
42
|
+
return parsed;
|
|
43
|
+
};
|
|
44
|
+
export const resolveTrpcBaseUrl = (runtimeEndpoints) => {
|
|
45
|
+
const apiBaseUrl = resolveApiBaseUrl(runtimeEndpoints);
|
|
46
|
+
if (!apiBaseUrl) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
const normalizedApiPath = apiBaseUrl.pathname.endsWith("/")
|
|
50
|
+
? apiBaseUrl.pathname.slice(0, -1)
|
|
51
|
+
: apiBaseUrl.pathname;
|
|
52
|
+
if (!normalizedApiPath.endsWith("/v1")) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
const trpcPath = normalizedApiPath.slice(0, -"/v1".length) || "/";
|
|
56
|
+
return new URL(trpcPath, `${normalizeOrigin(apiBaseUrl.toString()) ?? ""}/`);
|
|
57
|
+
};
|