@getuserfeedback/protocol 0.7.2 → 0.8.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 +147 -20
- package/dist/app-event.d.ts.map +1 -1
- package/dist/app-event.js +10 -0
- package/dist/flow-assignments.d.ts +7 -4
- package/dist/flow-assignments.d.ts.map +1 -1
- package/dist/flow-assignments.js +15 -5
- package/dist/host/external-id-argument-guards.d.ts +10 -0
- package/dist/host/external-id-argument-guards.d.ts.map +1 -0
- package/dist/host/external-id-argument-guards.js +27 -0
- package/dist/host/index.d.ts +1 -0
- package/dist/host/index.d.ts.map +1 -1
- package/dist/host/index.js +1 -0
- package/dist/host/sdk-types.d.ts +24 -4
- package/dist/host/sdk-types.d.ts.map +1 -1
- package/dist/identity-type.d.ts +2 -3
- package/dist/identity-type.d.ts.map +1 -1
- package/dist/identity-type.js +2 -4
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/widget-commands.d.ts +23 -1
- package/dist/widget-commands.d.ts.map +1 -1
- package/dist/widget-commands.js +6 -1
- package/dist/widget-config.d.ts +18 -0
- package/dist/widget-config.d.ts.map +1 -1
- package/dist/widget-config.js +2 -1
- package/package.json +1 -1
- package/src/app-event.ts +24 -0
- package/src/flow-assignments.test.ts +19 -0
- package/src/flow-assignments.ts +31 -5
- package/src/host/external-id-argument-guards.ts +57 -0
- package/src/host/index.ts +1 -0
- package/src/host/sdk-types.ts +27 -5
- package/src/identity-type.ts +3 -9
- package/src/index.ts +4 -1
- package/src/protocol-root.test.ts +109 -3
- package/src/widget-commands.ts +11 -1
- package/src/widget-config.ts +8 -1
package/dist/host/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export * from "./command-dispatch.js";
|
|
|
5
5
|
export * from "./command-envelope.js";
|
|
6
6
|
export * from "./command-settlement.js";
|
|
7
7
|
export * from "./constants.js";
|
|
8
|
+
export * from "./external-id-argument-guards.js";
|
|
8
9
|
export * from "./host-event-contract.js";
|
|
9
10
|
export * from "./lazy-handle-client.js";
|
|
10
11
|
export { createCommandRequestId } from "./request-id.js";
|
package/dist/host/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/host/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/host/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kCAAkC,CAAC;AACjD,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/host/index.js
CHANGED
|
@@ -5,6 +5,7 @@ export * from "./command-dispatch.js";
|
|
|
5
5
|
export * from "./command-envelope.js";
|
|
6
6
|
export * from "./command-settlement.js";
|
|
7
7
|
export * from "./constants.js";
|
|
8
|
+
export * from "./external-id-argument-guards.js";
|
|
8
9
|
export * from "./host-event-contract.js";
|
|
9
10
|
export * from "./lazy-handle-client.js";
|
|
10
11
|
export { createCommandRequestId } from "./request-id.js";
|
package/dist/host/sdk-types.d.ts
CHANGED
|
@@ -7,17 +7,28 @@ import type { Scope } from "../scopes.js";
|
|
|
7
7
|
/**
|
|
8
8
|
* Identifier types supported by event tracking and identity resolution.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
* `
|
|
10
|
+
* Business-specific identifiers are sent as Segment-compatible
|
|
11
|
+
* `context.externalIds` entries on app events or identify options.
|
|
12
12
|
*
|
|
13
13
|
* @see https://getuserfeedback.com/docs/guides/identity-resolution
|
|
14
14
|
*/
|
|
15
|
-
export type AppEventIdentityType = "anonymousId" | "userId" | "traits.email" | "traits.phone" | "context.device.id" | "context.device.advertisingId" | "context.device.token"
|
|
16
|
-
/** A single identifier, such as a user ID, anonymous ID, email, or
|
|
15
|
+
export type AppEventIdentityType = "anonymousId" | "userId" | "traits.email" | "traits.phone" | "context.device.id" | "context.device.advertisingId" | "context.device.token";
|
|
16
|
+
/** A single standard identifier, such as a user ID, anonymous ID, email, or device ID. */
|
|
17
17
|
export type AppEventIdentity = {
|
|
18
18
|
type: AppEventIdentityType;
|
|
19
19
|
value: string;
|
|
20
20
|
};
|
|
21
|
+
/**
|
|
22
|
+
* Segment-compatible external identifier.
|
|
23
|
+
*
|
|
24
|
+
* Only `collection: "users"` participates in person identity resolution today.
|
|
25
|
+
*/
|
|
26
|
+
export type AppEventExternalId = {
|
|
27
|
+
id: string;
|
|
28
|
+
type: string;
|
|
29
|
+
collection: "users";
|
|
30
|
+
encoding: "none";
|
|
31
|
+
};
|
|
21
32
|
/** Page, feature flag, and capability context attached to an event. */
|
|
22
33
|
export type AppEventContext = {
|
|
23
34
|
page?: {
|
|
@@ -27,6 +38,7 @@ export type AppEventContext = {
|
|
|
27
38
|
};
|
|
28
39
|
locale?: string;
|
|
29
40
|
userAgent?: string;
|
|
41
|
+
externalIds?: AppEventExternalId[] | undefined;
|
|
30
42
|
flags?: AppEventFlag[] | undefined;
|
|
31
43
|
capabilities?: AppEventCapability[] | undefined;
|
|
32
44
|
};
|
|
@@ -291,15 +303,23 @@ export type PrerenderCommandPayload = {
|
|
|
291
303
|
export type IdentifyTraitsOnlyCommandPayload = {
|
|
292
304
|
kind: "identify";
|
|
293
305
|
traits: Record<string, unknown>;
|
|
306
|
+
options?: IdentifyOptions | undefined;
|
|
294
307
|
};
|
|
295
308
|
/** Identify with userId and optional traits (`client.identify(userId, traits?)`). */
|
|
296
309
|
export type IdentifyUserCommandPayload = {
|
|
297
310
|
kind: "identify";
|
|
298
311
|
userId: string;
|
|
299
312
|
traits?: Record<string, unknown> | undefined;
|
|
313
|
+
options?: IdentifyOptions | undefined;
|
|
300
314
|
};
|
|
301
315
|
/** Identify command payload: either traits-only or userId+traits shape. */
|
|
302
316
|
export type IdentifyCommandPayload = IdentifyTraitsOnlyCommandPayload | IdentifyUserCommandPayload;
|
|
317
|
+
export type IdentifyOptions = {
|
|
318
|
+
externalIds?: AppEventExternalId[] | undefined;
|
|
319
|
+
};
|
|
320
|
+
export type TrackOptions = {
|
|
321
|
+
externalIds?: AppEventExternalId[] | undefined;
|
|
322
|
+
};
|
|
303
323
|
/**
|
|
304
324
|
* Command payload for `client.track()`.
|
|
305
325
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk-types.d.ts","sourceRoot":"","sources":["../../src/host/sdk-types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAI1C;;;;;;;GAOG;AACH,MAAM,MAAM,oBAAoB,GAC7B,aAAa,GACb,QAAQ,GACR,cAAc,GACd,cAAc,GACd,mBAAmB,GACnB,8BAA8B,GAC9B,sBAAsB,
|
|
1
|
+
{"version":3,"file":"sdk-types.d.ts","sourceRoot":"","sources":["../../src/host/sdk-types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAI1C;;;;;;;GAOG;AACH,MAAM,MAAM,oB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AE,GAAG,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;IACpC,OAAO,EAAE,oBAAoB,CAAC;CAC9B,CAAC;AAIF,gFAAgF;AAChF,MAAM,MAAM,qBAAqB,GAAG,oBAAoB,CAAC;AAEzD;;;;;;;;GAQG;AACH,MAAM,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,+GAA+G;IAC/G,KAAK,EAAE,OAAO,CAAC;IACf,UAAU,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,qBAAqB,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAClE,OAAO,EAAE;QACR,IAAI,EAAE;YACL,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;YACjC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;YACrC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;YACnC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;SACnC,CAAC;QACF,aAAa,EAAE,MAAM,CAAC;QACtB,UAAU,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;KACpC,CAAC;IACF,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;CACjD,CAAC"}
|
package/dist/identity-type.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import * as z from "zod/mini";
|
|
2
2
|
export declare const IDENTITY_TYPE_VALUES: readonly ["anonymousId", "userId", "traits.email", "traits.phone", "context.device.id", "context.device.advertisingId", "context.device.token"];
|
|
3
3
|
export type StandardIdentityTypeValue = (typeof IDENTITY_TYPE_VALUES)[number];
|
|
4
|
-
export type
|
|
5
|
-
export type IdentityTypeValue = StandardIdentityTypeValue | CustomIdentityTypeValue;
|
|
4
|
+
export type IdentityTypeValue = StandardIdentityTypeValue;
|
|
6
5
|
export declare const isIdentityTypeValue: (value: string) => value is IdentityTypeValue;
|
|
7
6
|
export declare const getIdentityTypeSuggestion: (value: string) => IdentityTypeValue | null;
|
|
8
7
|
export declare const buildIdentityTypeGuidanceMessage: (value: string) => string;
|
|
9
|
-
export declare const appEventIdentityTypeSchema: z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<
|
|
8
|
+
export declare const appEventIdentityTypeSchema: z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<"anonymousId" | "userId" | "traits.email" | "traits.phone" | "context.device.id" | "context.device.advertisingId" | "context.device.token", string>>;
|
|
10
9
|
//# sourceMappingURL=identity-type.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity-type.d.ts","sourceRoot":"","sources":["../src/identity-type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAE9B,eAAO,MAAM,oBAAoB,iJAQvB,CAAC;AAEX,MAAM,MAAM,yBAAyB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;AAC9E,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"identity-type.d.ts","sourceRoot":"","sources":["../src/identity-type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAE9B,eAAO,MAAM,oBAAoB,iJAQvB,CAAC;AAEX,MAAM,MAAM,yBAAyB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;AAC9E,MAAM,MAAM,iBAAiB,GAAG,yBAAyB,CAAC;AAyB1D,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;AAkBF,eAAO,MAAM,0BAA0B,gNAWtC,CAAC"}
|
package/dist/identity-type.js
CHANGED
|
@@ -8,7 +8,6 @@ export const IDENTITY_TYPE_VALUES = [
|
|
|
8
8
|
"context.device.advertisingId",
|
|
9
9
|
"context.device.token",
|
|
10
10
|
];
|
|
11
|
-
const CUSTOM_IDENTITY_TYPE_PATTERN = /^custom\.[a-zA-Z0-9][a-zA-Z0-9_.-]*$/;
|
|
12
11
|
const IDENTITY_TYPE_ALIAS_SUGGESTIONS = {
|
|
13
12
|
advertising_id: "context.device.advertisingId",
|
|
14
13
|
anonymous_id: "anonymousId",
|
|
@@ -25,8 +24,7 @@ const COMMON_IDENTITY_TYPE_MAPPINGS = [
|
|
|
25
24
|
["user_id", "userId"],
|
|
26
25
|
];
|
|
27
26
|
const normalizeIdentityTypeAliasKey = (value) => value.trim().toLowerCase().replace(/-/g, "_");
|
|
28
|
-
export const isIdentityTypeValue = (value) => IDENTITY_TYPE_VALUES.some((candidate) => candidate === value)
|
|
29
|
-
CUSTOM_IDENTITY_TYPE_PATTERN.test(value);
|
|
27
|
+
export const isIdentityTypeValue = (value) => IDENTITY_TYPE_VALUES.some((candidate) => candidate === value);
|
|
30
28
|
const parseIdentityTypeValue = (value) => isIdentityTypeValue(value) ? value : null;
|
|
31
29
|
export const getIdentityTypeSuggestion = (value) => IDENTITY_TYPE_ALIAS_SUGGESTIONS[normalizeIdentityTypeAliasKey(value)] ?? null;
|
|
32
30
|
export const buildIdentityTypeGuidanceMessage = (value) => {
|
|
@@ -37,7 +35,7 @@ export const buildIdentityTypeGuidanceMessage = (value) => {
|
|
|
37
35
|
return `Unsupported identity type ${displayValue}. Use "${suggestion}" instead.`;
|
|
38
36
|
}
|
|
39
37
|
const mappingExamples = COMMON_IDENTITY_TYPE_MAPPINGS.map(([from, to]) => `${from} -> ${to}`).join(", ");
|
|
40
|
-
return `Unsupported identity type ${displayValue}. Use one of: ${IDENTITY_TYPE_VALUES.join(", ")}
|
|
38
|
+
return `Unsupported identity type ${displayValue}. Use one of: ${IDENTITY_TYPE_VALUES.join(", ")}. For external IDs, send Segment-compatible context.externalIds entries instead. Common mappings: ${mappingExamples}.`;
|
|
41
39
|
};
|
|
42
40
|
const identityTypeInputSchema = z.string().check(z.trim(), z.minLength(1, { error: "Identity type is required." }), z.check((ctx) => {
|
|
43
41
|
if (isIdentityTypeValue(ctx.value)) {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export { type AppEventCapability, type AppEventFlag, type AppEventJsonValue, type AppEventPayload, type AppEventTrackInput, appEventBaseSchema, appEventCapabilitySchema, appEventContextSchema, appEventCustomerTrackSchema, appEventFlagProviderSchema, appEventFlagSchema, appEventFlowDismissedSchema, appEventIdentitySchema, appEventIdentityTypeSchema, appEventPayloadSchema, appEventSurveyViewedSchema, appEventSystemBaseSchema, appEventSystemTrackSchema, appEventTrackSchema, reservedSystemAppEventNames, } from "./app-event.js";
|
|
1
|
+
export { type AppEventCapability, type AppEventExternalId, type AppEventFlag, type AppEventJsonValue, type AppEventPayload, type AppEventTrackInput, appEventBaseSchema, appEventCapabilitySchema, appEventContextSchema, appEventCustomerTrackSchema, appEventExternalIdSchema, appEventFlagProviderSchema, appEventFlagSchema, appEventFlowDismissedSchema, appEventIdentitySchema, appEventIdentityTypeSchema, appEventPayloadSchema, appEventSurveyViewedSchema, appEventSystemBaseSchema, appEventSystemTrackSchema, appEventTrackSchema, reservedSystemAppEventNames, } 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
4
|
export type { ErrorEvent, ProtocolErrorCode } from "./errors.js";
|
|
5
5
|
export { ErrorCategory, ErrorCategorySchema, ErrorEventSchema, ProtocolError, } from "./errors.js";
|
|
6
|
-
export { type ClaimPendingFlowAssignmentsRequest, type ClaimPendingFlowAssignmentsResponse, claimPendingFlowAssignmentsRequestSchema, claimPendingFlowAssignmentsResponseSchema, type FlowAssignmentRecipientRequest, type FlowAssignmentRecord, type FlowAssignmentStatus, type FlowAssignmentTargetingContext, flowAssignmentRecipientRequestSchema, flowAssignmentRecordSchema, flowAssignmentStatusSchema, flowAssignmentTargetingContextSchema, type ListPendingFlowAssignmentsResponse, listPendingFlowAssignmentsResponseSchema, nullableUpdateFlowAssignmentLifecycleResponseSchema, type ReleaseFlowAssignmentClaimRequest, type ReleaseFlowAssignmentClaimResponse, releaseFlowAssignmentClaimRequestSchema, releaseFlowAssignmentClaimResponseSchema, type UpdateFlowAssignmentLifecycleRequest, type UpdateFlowAssignmentLifecycleResponse, updateFlowAssignmentLifecycleRequestSchema, updateFlowAssignmentLifecycleResponseSchema, } from "./flow-assignments.js";
|
|
7
|
-
export { buildIdentityTypeGuidanceMessage,
|
|
6
|
+
export { type ClaimPendingFlowAssignmentsRequest, type ClaimPendingFlowAssignmentsResponse, claimPendingFlowAssignmentsRequestSchema, claimPendingFlowAssignmentsResponseSchema, type FlowAssignmentExternalIdIdentityTypeValue, type FlowAssignmentIdentityTypeValue, type FlowAssignmentRecipientRequest, type FlowAssignmentRecord, type FlowAssignmentStatus, type FlowAssignmentTargetingContext, flowAssignmentRecipientRequestSchema, flowAssignmentRecordSchema, flowAssignmentStatusSchema, flowAssignmentTargetingContextSchema, type ListPendingFlowAssignmentsResponse, listPendingFlowAssignmentsResponseSchema, nullableUpdateFlowAssignmentLifecycleResponseSchema, type ReleaseFlowAssignmentClaimRequest, type ReleaseFlowAssignmentClaimResponse, releaseFlowAssignmentClaimRequestSchema, releaseFlowAssignmentClaimResponseSchema, type UpdateFlowAssignmentLifecycleRequest, type UpdateFlowAssignmentLifecycleResponse, updateFlowAssignmentLifecycleRequestSchema, updateFlowAssignmentLifecycleResponseSchema, } from "./flow-assignments.js";
|
|
7
|
+
export { buildIdentityTypeGuidanceMessage, getIdentityTypeSuggestion, IDENTITY_TYPE_VALUES, type IdentityTypeValue, isIdentityTypeValue, type StandardIdentityTypeValue, } from "./identity-type.js";
|
|
8
8
|
export { isPublicGrantScope, type PublicGrantScope, publicGrantScopeIdSchema, } from "./public-grant-scope.js";
|
|
9
9
|
export { type RuntimeEndpoints, resolveApiBaseUrl, resolveCoreUrl, resolveTrpcBaseUrl, runtimeEndpointsSchema, } from "./runtime-endpoints.js";
|
|
10
10
|
export { getScopeMeta, isScope, listScopes, SCOPE_IDS, type Scope, scopeIdSchema, } from "./scopes.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,kBAAkB,EACvB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,kBAAkB,EAClB,wBAAwB,EACxB,qBAAqB,EACrB,2BAA2B,EAC3B,0BAA0B,EAC1B,kBAAkB,EAClB,2BAA2B,EAC3B,sBAAsB,EACtB,0BAA0B,EAC1B,qBAAqB,EACrB,0BAA0B,EAC1B,wBAAwB,EACxB,yBAAyB,EACzB,mBAAmB,EACnB,2BAA2B,GAC3B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACN,KAAK,UAAU,EACf,gBAAgB,GAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,sCAAsC,EAAE,MAAM,eAAe,CAAC;AACvE,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EACN,aAAa,EACb,mBAAmB,EACnB,gBAAgB,EAChB,aAAa,GACb,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,KAAK,kCAAkC,EACvC,KAAK,mCAAmC,EACxC,wCAAwC,EACxC,yCAAyC,EACzC,KAAK,8BAA8B,EACnC,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,8BAA8B,EACnC,oCAAoC,EACpC,0BAA0B,EAC1B,0BAA0B,EAC1B,oCAAoC,EACpC,KAAK,kCAAkC,EACvC,wCAAwC,EACxC,mDAAmD,EACnD,KAAK,iCAAiC,EACtC,KAAK,kCAAkC,EACvC,uCAAuC,EACvC,wCAAwC,EACxC,KAAK,oCAAoC,EACzC,KAAK,qCAAqC,EAC1C,0CAA0C,EAC1C,2CAA2C,GAC3C,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACN,gCAAgC,EAChC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,kBAAkB,EAClB,wBAAwB,EACxB,qBAAqB,EACrB,2BAA2B,EAC3B,wBAAwB,EACxB,0BAA0B,EAC1B,kBAAkB,EAClB,2BAA2B,EAC3B,sBAAsB,EACtB,0BAA0B,EAC1B,qBAAqB,EACrB,0BAA0B,EAC1B,wBAAwB,EACxB,yBAAyB,EACzB,mBAAmB,EACnB,2BAA2B,GAC3B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACN,KAAK,UAAU,EACf,gBAAgB,GAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,sCAAsC,EAAE,MAAM,eAAe,CAAC;AACvE,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EACN,aAAa,EACb,mBAAmB,EACnB,gBAAgB,EAChB,aAAa,GACb,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,KAAK,kCAAkC,EACvC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K,eAAe,EACpB,KAAK,kBAAkB,EACvB,qBAAqB,EACrB,wBAAwB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC5B,4BAA4B,EAC5B,sBAAsB,EACtB,wBAAwB,EACxB,wBAAwB,EACxB,KAAK,gBAAgB,EACrB,gBAAgB,EAChB,KAAK,gBAAgB,EACrB,sBAAsB,EACtB,KAAK,2BAA2B,EAChC,iCAAiC,EACjC,KAAK,mBAAmB,EACxB,2BAA2B,EAC3B,KAAK,WAAW,EAChB,KAAK,wBAAwB,EAC7B,yBAAyB,EACzB,iBAAiB,EACjB,8BAA8B,EAC9B,KAAK,oBAAoB,EACzB,0BAA0B,GAC1B,MAAM,oBAAoB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { appEventBaseSchema, appEventCapabilitySchema, appEventContextSchema, appEventCustomerTrackSchema, appEventFlagProviderSchema, appEventFlagSchema, appEventFlowDismissedSchema, appEventIdentitySchema, appEventIdentityTypeSchema, appEventPayloadSchema, appEventSurveyViewedSchema, appEventSystemBaseSchema, appEventSystemTrackSchema, appEventTrackSchema, reservedSystemAppEventNames, } from "./app-event.js";
|
|
1
|
+
export { appEventBaseSchema, appEventCapabilitySchema, appEventContextSchema, appEventCustomerTrackSchema, appEventExternalIdSchema, appEventFlagProviderSchema, appEventFlagSchema, appEventFlowDismissedSchema, appEventIdentitySchema, appEventIdentityTypeSchema, appEventPayloadSchema, appEventSurveyViewedSchema, appEventSystemBaseSchema, appEventSystemTrackSchema, appEventTrackSchema, reservedSystemAppEventNames, } 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
4
|
export { ErrorCategory, ErrorCategorySchema, ErrorEventSchema, ProtocolError, } from "./errors.js";
|
|
@@ -257,7 +257,7 @@ export declare const publicCommandPayloadSchema: z.ZodMiniUnion<readonly [z.ZodM
|
|
|
257
257
|
}, z.core.$strict>, z.ZodMiniObject<{
|
|
258
258
|
traits: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnknown>>;
|
|
259
259
|
identities: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
|
|
260
|
-
type: z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<
|
|
260
|
+
type: z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<"anonymousId" | "userId" | "traits.email" | "traits.phone" | "context.device.id" | "context.device.advertisingId" | "context.device.token", string>>;
|
|
261
261
|
value: z.ZodMiniString<string>;
|
|
262
262
|
}, z.core.$strip>>>;
|
|
263
263
|
context: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
@@ -268,6 +268,12 @@ export declare const publicCommandPayloadSchema: z.ZodMiniUnion<readonly [z.ZodM
|
|
|
268
268
|
}, z.core.$strip>>;
|
|
269
269
|
locale: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
270
270
|
userAgent: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
271
|
+
externalIds: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
|
|
272
|
+
id: z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<string, string>>;
|
|
273
|
+
type: z.ZodMiniString<string>;
|
|
274
|
+
collection: z.ZodMiniLiteral<"users">;
|
|
275
|
+
encoding: z.ZodMiniLiteral<"none">;
|
|
276
|
+
}, z.core.$strip>>>;
|
|
271
277
|
flags: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
|
|
272
278
|
key: z.ZodMiniString<string>;
|
|
273
279
|
target: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
@@ -355,10 +361,26 @@ export declare const publicCommandPayloadSchema: z.ZodMiniUnion<readonly [z.ZodM
|
|
|
355
361
|
}, z.core.$strip>], "kind">, z.ZodMiniUnion<readonly [z.ZodMiniObject<{
|
|
356
362
|
kind: z.ZodMiniLiteral<"identify">;
|
|
357
363
|
traits: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnknown>;
|
|
364
|
+
options: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
365
|
+
externalIds: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
|
|
366
|
+
id: z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<string, string>>;
|
|
367
|
+
type: z.ZodMiniString<string>;
|
|
368
|
+
collection: z.ZodMiniLiteral<"users">;
|
|
369
|
+
encoding: z.ZodMiniLiteral<"none">;
|
|
370
|
+
}, z.core.$strip>>>;
|
|
371
|
+
}, z.core.$strict>>;
|
|
358
372
|
}, z.core.$strict>, z.ZodMiniObject<{
|
|
359
373
|
kind: z.ZodMiniLiteral<"identify">;
|
|
360
374
|
userId: z.ZodMiniString<string>;
|
|
361
375
|
traits: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnknown>>;
|
|
376
|
+
options: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
377
|
+
externalIds: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
|
|
378
|
+
id: z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<string, string>>;
|
|
379
|
+
type: z.ZodMiniString<string>;
|
|
380
|
+
collection: z.ZodMiniLiteral<"users">;
|
|
381
|
+
encoding: z.ZodMiniLiteral<"none">;
|
|
382
|
+
}, z.core.$strip>>>;
|
|
383
|
+
}, z.core.$strict>>;
|
|
362
384
|
}, z.core.$strict>]>]>;
|
|
363
385
|
export type PublicCommandPayload = z.output<typeof publicCommandPayloadSchema>;
|
|
364
386
|
export type ContainerPolicy = z.output<typeof containerPolicySchema>;
|
|
@@ -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;AAK9B,OAAO,EACN,KAAK,gBAAgB,EAErB,KAAK,WAAW,EAEhB,MAAM,oBAAoB,CAAC;AAoB5B,eAAO,MAAM,6BAA6B;;;;;;;;;;;;EAAmC,CAAC;AAgD9E,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,5 +1,5 @@
|
|
|
1
1
|
import * as z from "zod/mini";
|
|
2
|
-
import { appEventCustomerTrackSchema } from "./app-event.js";
|
|
2
|
+
import { appEventCustomerTrackSchema, appEventExternalIdSchema, } from "./app-event.js";
|
|
3
3
|
import { configureOptionsSchema, initOptionsSchema, } from "./widget-config.js";
|
|
4
4
|
const flowHandleIdSchema = z.string().check(z.trim(), z.minLength(1));
|
|
5
5
|
const flowIdSchema = z.string().check(z.trim(), z.minLength(1));
|
|
@@ -36,15 +36,20 @@ const htmlElementOrNullSchema = z.custom((value) => value === null || isHTMLElem
|
|
|
36
36
|
message: "Container must be null or an HTMLElement with nodeType=1",
|
|
37
37
|
});
|
|
38
38
|
const identifyTraitsSchema = z.record(z.string(), z.unknown());
|
|
39
|
+
const identifyOptionsSchema = z.strictObject({
|
|
40
|
+
externalIds: z.optional(z.array(appEventExternalIdSchema).check(z.maxLength(20))),
|
|
41
|
+
});
|
|
39
42
|
const identifyPayloadSchema = z.union([
|
|
40
43
|
z.strictObject({
|
|
41
44
|
kind: z.literal("identify"),
|
|
42
45
|
traits: identifyTraitsSchema,
|
|
46
|
+
options: z.optional(identifyOptionsSchema),
|
|
43
47
|
}),
|
|
44
48
|
z.strictObject({
|
|
45
49
|
kind: z.literal("identify"),
|
|
46
50
|
userId: z.string().check(z.trim(), z.minLength(1)),
|
|
47
51
|
traits: z.optional(identifyTraitsSchema),
|
|
52
|
+
options: z.optional(identifyOptionsSchema),
|
|
48
53
|
}),
|
|
49
54
|
]);
|
|
50
55
|
// TODO(migration): After telemetry confirms no remaining `open.containerRequirement` in host command queues, remove the optional field and transform so unknown keys fail under `.strict()` again.
|
package/dist/widget-config.d.ts
CHANGED
|
@@ -43,6 +43,12 @@ export declare const identityConfigInputSchema: z.ZodMiniObject<{
|
|
|
43
43
|
anonymousId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
44
44
|
userId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
45
45
|
traits: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnknown>>;
|
|
46
|
+
externalIds: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
|
|
47
|
+
id: z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<string, string>>;
|
|
48
|
+
type: z.ZodMiniString<string>;
|
|
49
|
+
collection: z.ZodMiniLiteral<"users">;
|
|
50
|
+
encoding: z.ZodMiniLiteral<"none">;
|
|
51
|
+
}, z.core.$strip>>>;
|
|
46
52
|
}, z.core.$strip>;
|
|
47
53
|
export type IdentityConfigInput = z.output<typeof identityConfigInputSchema>;
|
|
48
54
|
export declare const flagsConfigInputSchema: z.ZodMiniArray<z.ZodMiniObject<{
|
|
@@ -338,6 +344,12 @@ export declare const instanceUpdateableConfigSchema: z.ZodMiniObject<{
|
|
|
338
344
|
anonymousId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
339
345
|
userId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
340
346
|
traits: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnknown>>;
|
|
347
|
+
externalIds: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
|
|
348
|
+
id: z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<string, string>>;
|
|
349
|
+
type: z.ZodMiniString<string>;
|
|
350
|
+
collection: z.ZodMiniLiteral<"users">;
|
|
351
|
+
encoding: z.ZodMiniLiteral<"none">;
|
|
352
|
+
}, z.core.$strip>>>;
|
|
341
353
|
}, z.core.$strip>>;
|
|
342
354
|
}, z.core.$strict>;
|
|
343
355
|
export type InstanceUpdateableConfig = z.output<typeof instanceUpdateableConfigSchema>;
|
|
@@ -384,6 +396,12 @@ export declare const coreInstanceConfigSchema: z.ZodMiniObject<{
|
|
|
384
396
|
anonymousId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
385
397
|
userId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
386
398
|
traits: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnknown>>;
|
|
399
|
+
externalIds: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
|
|
400
|
+
id: z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<string, string>>;
|
|
401
|
+
type: z.ZodMiniString<string>;
|
|
402
|
+
collection: z.ZodMiniLiteral<"users">;
|
|
403
|
+
encoding: z.ZodMiniLiteral<"none">;
|
|
404
|
+
}, z.core.$strip>>>;
|
|
387
405
|
}, z.core.$strip>>;
|
|
388
406
|
apiKey: z.ZodMiniString<string>;
|
|
389
407
|
clientMeta: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"widget-config.d.ts","sourceRoot":"","sources":["../src/widget-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"widget-config.d.ts","sourceRoot":"","sources":["../src/widget-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAiB9B,eAAO,MAAM,4BAA4B;;;;;;IAKvC,CAAC;AAEH,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAC5C,OAAO,4BAA4B,CACnC,CAAC;AAEF,eAAO,MAAM,0BAA0B;;iBAErC,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE/E,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;KAGnC,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE3E,eAAO,MAAM,gBAAgB,wHAI3B,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,C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,eAAO,MAAM,2BAA2B,EAAE,sBAEzC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAKzC,CAAC;AAEH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAC9C,OAAO,8BAA8B,CACrC,CAAC;AAEF,uEAAuE;AACvE,eAAO,MAAM,2BAA2B,EAAE,CAAC,MAAM,wBAAwB,CAAC,EAKzE,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAenC,CAAC;AAEH,0EAA0E;AAC1E,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE/E,yDAAyD;AACzD,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,wBAAwB,CAAC,CAAC"}
|
package/dist/widget-config.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as z from "zod/mini";
|
|
2
|
-
import { appEventCapabilitySchema, appEventFlagSchema } from "./app-event.js";
|
|
2
|
+
import { appEventCapabilitySchema, appEventExternalIdSchema, 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";
|
|
@@ -36,6 +36,7 @@ export const identityConfigInputSchema = z.object({
|
|
|
36
36
|
anonymousId: z.optional(z.string().check(z.trim(), z.minLength(1))),
|
|
37
37
|
userId: z.optional(z.string().check(z.trim(), z.minLength(1))),
|
|
38
38
|
traits: z.optional(z.record(z.string(), z.unknown())),
|
|
39
|
+
externalIds: z.optional(z.array(appEventExternalIdSchema).check(z.maxLength(20))),
|
|
39
40
|
});
|
|
40
41
|
export const flagsConfigInputSchema = z.array(appEventFlagSchema);
|
|
41
42
|
export const hostCapabilitiesConfigInputSchema = z.array(appEventCapabilitySchema);
|
package/package.json
CHANGED
package/src/app-event.ts
CHANGED
|
@@ -86,10 +86,34 @@ const appEventPageSchema = z.object({
|
|
|
86
86
|
search: z.optional(z.string()),
|
|
87
87
|
});
|
|
88
88
|
|
|
89
|
+
const externalIdTypeSchema = z.string().check(
|
|
90
|
+
z.trim(),
|
|
91
|
+
z.minLength(1),
|
|
92
|
+
z.regex(/^[a-z0-9][a-z0-9_.-]*$/, {
|
|
93
|
+
message:
|
|
94
|
+
"External ID type must start with a lowercase letter or number and may contain lowercase letters, numbers, underscores, dots, or hyphens.",
|
|
95
|
+
}),
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
export const appEventExternalIdSchema = z.object({
|
|
99
|
+
id: z.pipe(
|
|
100
|
+
z.string().check(z.trim(), z.minLength(1)),
|
|
101
|
+
z.transform((value) => value.trim()),
|
|
102
|
+
),
|
|
103
|
+
type: externalIdTypeSchema,
|
|
104
|
+
collection: z.literal("users"),
|
|
105
|
+
encoding: z.literal("none"),
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
export type AppEventExternalId = z.output<typeof appEventExternalIdSchema>;
|
|
109
|
+
|
|
89
110
|
export const appEventContextSchema = z.object({
|
|
90
111
|
page: z.optional(appEventPageSchema),
|
|
91
112
|
locale: z.optional(z.string()),
|
|
92
113
|
userAgent: z.optional(z.string()),
|
|
114
|
+
externalIds: z.optional(
|
|
115
|
+
z.array(appEventExternalIdSchema).check(z.maxLength(20)),
|
|
116
|
+
),
|
|
93
117
|
flags: z.optional(z.array(appEventFlagSchema)),
|
|
94
118
|
capabilities: z.optional(z.array(appEventCapabilitySchema)),
|
|
95
119
|
});
|
|
@@ -39,6 +39,25 @@ describe("flow assignment request contracts", () => {
|
|
|
39
39
|
expect(result.context?.capabilities?.[0]?.key).toBe("billing.portal");
|
|
40
40
|
});
|
|
41
41
|
|
|
42
|
+
it("accepts external ID identities for recipient continuity", () => {
|
|
43
|
+
const result = claimPendingFlowAssignmentsRequestSchema.parse({
|
|
44
|
+
holdOwnerKey: "inst_1",
|
|
45
|
+
identities: [
|
|
46
|
+
{
|
|
47
|
+
type: "externalId.shopify_customer_id",
|
|
48
|
+
value: "gid://shopify/Customer/123",
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
expect(result.identities).toEqual([
|
|
54
|
+
{
|
|
55
|
+
type: "externalId.shopify_customer_id",
|
|
56
|
+
value: "gid://shopify/Customer/123",
|
|
57
|
+
},
|
|
58
|
+
]);
|
|
59
|
+
});
|
|
60
|
+
|
|
42
61
|
it("accepts runtime targeting context for lifecycle updates", () => {
|
|
43
62
|
const result = updateFlowAssignmentLifecycleRequestSchema.parse({
|
|
44
63
|
identities: [{ type: "userId", value: "user_1" }],
|
package/src/flow-assignments.ts
CHANGED
|
@@ -3,8 +3,34 @@ import * as z from "zod/mini";
|
|
|
3
3
|
import {
|
|
4
4
|
appEventCapabilitySchema,
|
|
5
5
|
appEventFlagSchema,
|
|
6
|
-
|
|
6
|
+
appEventIdentityTypeSchema,
|
|
7
7
|
} from "./app-event.js";
|
|
8
|
+
import type { IdentityTypeValue } from "./identity-type.js";
|
|
9
|
+
|
|
10
|
+
export type FlowAssignmentExternalIdIdentityTypeValue = `externalId.${string}`;
|
|
11
|
+
export type FlowAssignmentIdentityTypeValue =
|
|
12
|
+
| IdentityTypeValue
|
|
13
|
+
| FlowAssignmentExternalIdIdentityTypeValue;
|
|
14
|
+
|
|
15
|
+
const flowAssignmentExternalIdIdentityTypeSchema = z.string().check(
|
|
16
|
+
z.trim(),
|
|
17
|
+
z.minLength(1),
|
|
18
|
+
z.regex(/^externalId\.[a-z0-9][a-z0-9_.-]*$/, {
|
|
19
|
+
message:
|
|
20
|
+
"External ID identity type must use externalId.<type> with a lowercase Segment external ID type.",
|
|
21
|
+
}),
|
|
22
|
+
) as z.ZodMiniType<
|
|
23
|
+
FlowAssignmentExternalIdIdentityTypeValue,
|
|
24
|
+
FlowAssignmentExternalIdIdentityTypeValue
|
|
25
|
+
>;
|
|
26
|
+
|
|
27
|
+
const flowAssignmentIdentitySchema = z.object({
|
|
28
|
+
type: z.union([
|
|
29
|
+
appEventIdentityTypeSchema,
|
|
30
|
+
flowAssignmentExternalIdIdentityTypeSchema,
|
|
31
|
+
]),
|
|
32
|
+
value: z.string().check(z.trim(), z.minLength(1)),
|
|
33
|
+
});
|
|
8
34
|
|
|
9
35
|
export const flowAssignmentStatusSchema = z.enum([
|
|
10
36
|
"pending",
|
|
@@ -24,7 +50,7 @@ export const flowAssignmentTargetingContextSchema = z.object({
|
|
|
24
50
|
});
|
|
25
51
|
|
|
26
52
|
export const flowAssignmentRecipientRequestSchema = z.object({
|
|
27
|
-
identities: z._default(z.array(
|
|
53
|
+
identities: z._default(z.array(flowAssignmentIdentitySchema), []),
|
|
28
54
|
context: z.optional(flowAssignmentTargetingContextSchema),
|
|
29
55
|
at: z.optional(z.number()),
|
|
30
56
|
});
|
|
@@ -56,7 +82,7 @@ export const listPendingFlowAssignmentsResponseSchema = z.object({
|
|
|
56
82
|
});
|
|
57
83
|
|
|
58
84
|
export const claimPendingFlowAssignmentsRequestSchema = z.object({
|
|
59
|
-
identities: z._default(z.array(
|
|
85
|
+
identities: z._default(z.array(flowAssignmentIdentitySchema), []),
|
|
60
86
|
context: z.optional(flowAssignmentTargetingContextSchema),
|
|
61
87
|
holdOwnerKey: z.string().check(z.trim(), z.minLength(1)),
|
|
62
88
|
at: z.optional(z.number()),
|
|
@@ -69,7 +95,7 @@ export const claimPendingFlowAssignmentsResponseSchema = z.object({
|
|
|
69
95
|
});
|
|
70
96
|
|
|
71
97
|
export const updateFlowAssignmentLifecycleRequestSchema = z.object({
|
|
72
|
-
identities: z._default(z.array(
|
|
98
|
+
identities: z._default(z.array(flowAssignmentIdentitySchema), []),
|
|
73
99
|
context: z.optional(flowAssignmentTargetingContextSchema),
|
|
74
100
|
flowAssignmentId: z.string().check(z.trim(), z.minLength(1)),
|
|
75
101
|
flowVersionId: z.optional(z.string().check(z.trim(), z.minLength(1))),
|
|
@@ -78,7 +104,7 @@ export const updateFlowAssignmentLifecycleRequestSchema = z.object({
|
|
|
78
104
|
});
|
|
79
105
|
|
|
80
106
|
export const releaseFlowAssignmentClaimRequestSchema = z.object({
|
|
81
|
-
identities: z._default(z.array(
|
|
107
|
+
identities: z._default(z.array(flowAssignmentIdentitySchema), []),
|
|
82
108
|
holdGroupToken: z.string().check(z.trim(), z.minLength(1)),
|
|
83
109
|
holdOwnerKey: z.optional(z.string().check(z.trim(), z.minLength(1))),
|
|
84
110
|
at: z.optional(z.number()),
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
type ExternalIdArgumentCommandName = "identify" | "track";
|
|
2
|
+
type ExternalIdArgumentValueName = "traits" | "properties";
|
|
3
|
+
|
|
4
|
+
const isAmbiguousExternalIdsArgument = (value: unknown): boolean => {
|
|
5
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const entries = Object.entries(value);
|
|
10
|
+
const externalIds = entries[0]?.[1];
|
|
11
|
+
return (
|
|
12
|
+
entries.length === 1 &&
|
|
13
|
+
entries[0]?.[0] === "externalIds" &&
|
|
14
|
+
Array.isArray(externalIds) &&
|
|
15
|
+
externalIds.length > 0 &&
|
|
16
|
+
externalIds.every(isSegmentExternalIdLike)
|
|
17
|
+
);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const isSegmentExternalIdLike = (
|
|
21
|
+
value: unknown,
|
|
22
|
+
): value is {
|
|
23
|
+
id: string;
|
|
24
|
+
type: string;
|
|
25
|
+
collection: "users";
|
|
26
|
+
encoding: "none";
|
|
27
|
+
} => {
|
|
28
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
return (
|
|
32
|
+
typeof Reflect.get(value, "id") === "string" &&
|
|
33
|
+
typeof Reflect.get(value, "type") === "string" &&
|
|
34
|
+
Reflect.get(value, "collection") === "users" &&
|
|
35
|
+
Reflect.get(value, "encoding") === "none"
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const assertNoAmbiguousExternalIdsArgument = ({
|
|
40
|
+
argument,
|
|
41
|
+
options,
|
|
42
|
+
commandName,
|
|
43
|
+
valueArgumentName,
|
|
44
|
+
}: {
|
|
45
|
+
argument: unknown;
|
|
46
|
+
options: unknown;
|
|
47
|
+
commandName: ExternalIdArgumentCommandName;
|
|
48
|
+
valueArgumentName: ExternalIdArgumentValueName;
|
|
49
|
+
}): void => {
|
|
50
|
+
if (options !== undefined || !isAmbiguousExternalIdsArgument(argument)) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
throw new Error(
|
|
55
|
+
`${commandName} received externalIds in the ${valueArgumentName} argument. Pass undefined for ${valueArgumentName} and provide externalIds as options instead.`,
|
|
56
|
+
);
|
|
57
|
+
};
|
package/src/host/index.ts
CHANGED
|
@@ -6,6 +6,7 @@ export * from "./command-dispatch.js";
|
|
|
6
6
|
export * from "./command-envelope.js";
|
|
7
7
|
export * from "./command-settlement.js";
|
|
8
8
|
export * from "./constants.js";
|
|
9
|
+
export * from "./external-id-argument-guards.js";
|
|
9
10
|
export * from "./host-event-contract.js";
|
|
10
11
|
export * from "./lazy-handle-client.js";
|
|
11
12
|
export { createCommandRequestId } from "./request-id.js";
|