@getuserfeedback/protocol 1.4.0 → 1.5.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.
@@ -1,7 +1,44 @@
1
1
  import * as z from "zod/mini";
2
+ export declare const runtimeDisplayEligibilitySchema: z.ZodMiniObject<{
3
+ requiredCapabilities: z.ZodMiniDefault<z.ZodMiniArray<z.ZodMiniString<string>>>;
4
+ requiredPage: z.ZodMiniOptional<z.ZodMiniObject<{
5
+ path: z.ZodMiniString<string>;
6
+ }, z.core.$strip>>;
7
+ }, z.core.$strip>;
8
+ export declare const runtimeDisplayBroadcastOpportunitySchema: z.ZodMiniObject<{
9
+ opportunityId: z.ZodMiniString<string>;
10
+ flowId: z.ZodMiniString<string>;
11
+ flowVersionId: z.ZodMiniString<string>;
12
+ source: z.ZodMiniObject<{
13
+ kind: z.ZodMiniLiteral<"runtime_broadcast">;
14
+ automationId: z.ZodMiniOptional<z.ZodMiniString<string>>;
15
+ automationVersionId: z.ZodMiniOptional<z.ZodMiniString<string>>;
16
+ }, z.core.$strip>;
17
+ runtimeEligibility: z.ZodMiniObject<{
18
+ requiredCapabilities: z.ZodMiniDefault<z.ZodMiniArray<z.ZodMiniString<string>>>;
19
+ requiredPage: z.ZodMiniOptional<z.ZodMiniObject<{
20
+ path: z.ZodMiniString<string>;
21
+ }, z.core.$strip>>;
22
+ }, z.core.$strip>;
23
+ }, z.core.$strip>;
2
24
  export declare const runtimeDisplayBroadcastsSchema: z.ZodMiniObject<{
3
25
  version: z.ZodMiniString<string>;
4
- opportunities: z.ZodMiniArray<z.ZodMiniNever>;
26
+ opportunities: z.ZodMiniArray<z.ZodMiniObject<{
27
+ opportunityId: z.ZodMiniString<string>;
28
+ flowId: z.ZodMiniString<string>;
29
+ flowVersionId: z.ZodMiniString<string>;
30
+ source: z.ZodMiniObject<{
31
+ kind: z.ZodMiniLiteral<"runtime_broadcast">;
32
+ automationId: z.ZodMiniOptional<z.ZodMiniString<string>>;
33
+ automationVersionId: z.ZodMiniOptional<z.ZodMiniString<string>>;
34
+ }, z.core.$strip>;
35
+ runtimeEligibility: z.ZodMiniObject<{
36
+ requiredCapabilities: z.ZodMiniDefault<z.ZodMiniArray<z.ZodMiniString<string>>>;
37
+ requiredPage: z.ZodMiniOptional<z.ZodMiniObject<{
38
+ path: z.ZodMiniString<string>;
39
+ }, z.core.$strip>>;
40
+ }, z.core.$strip>;
41
+ }, z.core.$strip>>;
5
42
  }, z.core.$strip>;
6
43
  export declare const flowDisplaySyncRequestSchema: z.ZodMiniObject<{
7
44
  identities: z.ZodMiniDefault<z.ZodMiniArray<z.ZodMiniObject<{
@@ -131,10 +168,27 @@ export declare const flowDisplaySyncResponseSchema: z.ZodMiniObject<{
131
168
  }, z.core.$strip>;
132
169
  broadcasts: z.ZodMiniObject<{
133
170
  version: z.ZodMiniString<string>;
134
- opportunities: z.ZodMiniArray<z.ZodMiniNever>;
171
+ opportunities: z.ZodMiniArray<z.ZodMiniObject<{
172
+ opportunityId: z.ZodMiniString<string>;
173
+ flowId: z.ZodMiniString<string>;
174
+ flowVersionId: z.ZodMiniString<string>;
175
+ source: z.ZodMiniObject<{
176
+ kind: z.ZodMiniLiteral<"runtime_broadcast">;
177
+ automationId: z.ZodMiniOptional<z.ZodMiniString<string>>;
178
+ automationVersionId: z.ZodMiniOptional<z.ZodMiniString<string>>;
179
+ }, z.core.$strip>;
180
+ runtimeEligibility: z.ZodMiniObject<{
181
+ requiredCapabilities: z.ZodMiniDefault<z.ZodMiniArray<z.ZodMiniString<string>>>;
182
+ requiredPage: z.ZodMiniOptional<z.ZodMiniObject<{
183
+ path: z.ZodMiniString<string>;
184
+ }, z.core.$strip>>;
185
+ }, z.core.$strip>;
186
+ }, z.core.$strip>>;
135
187
  }, z.core.$strip>;
136
188
  }, z.core.$strip>;
137
189
  export type RuntimeDisplayBroadcasts = z.output<typeof runtimeDisplayBroadcastsSchema>;
190
+ export type RuntimeDisplayBroadcastOpportunity = z.output<typeof runtimeDisplayBroadcastOpportunitySchema>;
191
+ export type RuntimeDisplayEligibility = z.output<typeof runtimeDisplayEligibilitySchema>;
138
192
  export type FlowDisplaySyncRequest = z.output<typeof flowDisplaySyncRequestSchema>;
139
193
  export type FlowDisplaySyncResponse = z.output<typeof flowDisplaySyncResponseSchema>;
140
194
  //# sourceMappingURL=flow-display.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"flow-display.d.ts","sourceRoot":"","sources":["../src/flow-display.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAQ9B,eAAO,MAAM,8BAA8B;;;iBAGzC,CAAC;AAEH,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBASvC,CAAC;AAEH,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAMxC,CAAC;AAEH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAC9C,OAAO,8BAA8B,CACrC,CAAC;AACF,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAC5C,OAAO,4BAA4B,CACnC,CAAC;AACF,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAC7C,OAAO,6BAA6B,CACpC,CAAC"}
1
+ {"version":3,"file":"flow-display.d.ts","sourceRoot":"","sources":["../src/flow-display.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAQ9B,eAAO,MAAM,+BAA+B;;;;;iBAU1C,CAAC;AAEH,eAAO,MAAM,wCAAwC;;;;;;;;;;;;;;;iBAUnD,CAAC;AAEH,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;iBAGzC,CAAC;AAEH,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBASvC,CAAC;AAEH,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAMxC,CAAC;AAEH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAC9C,OAAO,8BAA8B,CACrC,CAAC;AACF,MAAM,MAAM,kCAAkC,GAAG,CAAC,CAAC,MAAM,CACxD,OAAO,wCAAwC,CAC/C,CAAC;AACF,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,MAAM,CAC/C,OAAO,+BAA+B,CACtC,CAAC;AACF,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAC5C,OAAO,4BAA4B,CACnC,CAAC;AACF,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAC7C,OAAO,6BAA6B,CACpC,CAAC"}
@@ -1,8 +1,25 @@
1
1
  import * as z from "zod/mini";
2
2
  import { flowAssignmentIdentitySchema, flowAssignmentRecordSchema, flowAssignmentTargetingContextSchema, } from "./flow-assignments.js";
3
+ export const runtimeDisplayEligibilitySchema = z.object({
4
+ requiredCapabilities: z._default(z.array(z.string().check(z.trim(), z.minLength(1))), []),
5
+ requiredPage: z.optional(z.object({
6
+ path: z.string().check(z.trim(), z.minLength(1)),
7
+ })),
8
+ });
9
+ export const runtimeDisplayBroadcastOpportunitySchema = z.object({
10
+ opportunityId: z.string().check(z.trim(), z.minLength(1)),
11
+ flowId: z.string().check(z.trim(), z.minLength(1)),
12
+ flowVersionId: z.string().check(z.trim(), z.minLength(1)),
13
+ source: z.object({
14
+ kind: z.literal("runtime_broadcast"),
15
+ automationId: z.optional(z.string().check(z.trim(), z.minLength(1))),
16
+ automationVersionId: z.optional(z.string().check(z.trim(), z.minLength(1))),
17
+ }),
18
+ runtimeEligibility: runtimeDisplayEligibilitySchema,
19
+ });
3
20
  export const runtimeDisplayBroadcastsSchema = z.object({
4
21
  version: z.string().check(z.trim(), z.minLength(1)),
5
- opportunities: z.array(z.never()),
22
+ opportunities: z.array(runtimeDisplayBroadcastOpportunitySchema),
6
23
  });
7
24
  export const flowDisplaySyncRequestSchema = z.object({
8
25
  identities: z._default(z.array(flowAssignmentIdentitySchema), []),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getuserfeedback/protocol",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "getuserfeedback widget protocol — host surface and (later) wire protocol",
5
5
  "keywords": [
6
6
  "getuserfeedback",
@@ -53,4 +53,47 @@ describe("flow display sync contracts", () => {
53
53
  expect(result.assignments.claimed[0]?.flowAssignmentId).toBe("fa_1");
54
54
  expect(result.broadcasts.opportunities).toEqual([]);
55
55
  });
56
+
57
+ it("accepts runtime broadcast opportunities", () => {
58
+ const result = flowDisplaySyncResponseSchema.parse({
59
+ fetchedAt: "2026-06-18T00:00:00.000Z",
60
+ assignments: {
61
+ claimed: [],
62
+ },
63
+ broadcasts: {
64
+ version: "broadcasts_1",
65
+ opportunities: [
66
+ {
67
+ opportunityId: "rtb_daver_1",
68
+ flowId: "sur_1",
69
+ flowVersionId: "flv_1",
70
+ source: {
71
+ kind: "runtime_broadcast",
72
+ automationId: "dauto_1",
73
+ automationVersionId: "daver_1",
74
+ },
75
+ runtimeEligibility: {
76
+ requiredCapabilities: ["checkout.drawer"],
77
+ requiredPage: { path: "/checkout/*" },
78
+ },
79
+ },
80
+ ],
81
+ },
82
+ });
83
+
84
+ expect(result.broadcasts.opportunities[0]).toEqual({
85
+ opportunityId: "rtb_daver_1",
86
+ flowId: "sur_1",
87
+ flowVersionId: "flv_1",
88
+ source: {
89
+ kind: "runtime_broadcast",
90
+ automationId: "dauto_1",
91
+ automationVersionId: "daver_1",
92
+ },
93
+ runtimeEligibility: {
94
+ requiredCapabilities: ["checkout.drawer"],
95
+ requiredPage: { path: "/checkout/*" },
96
+ },
97
+ });
98
+ });
56
99
  });
@@ -6,9 +6,33 @@ import {
6
6
  flowAssignmentTargetingContextSchema,
7
7
  } from "./flow-assignments.js";
8
8
 
9
+ export const runtimeDisplayEligibilitySchema = z.object({
10
+ requiredCapabilities: z._default(
11
+ z.array(z.string().check(z.trim(), z.minLength(1))),
12
+ [],
13
+ ),
14
+ requiredPage: z.optional(
15
+ z.object({
16
+ path: z.string().check(z.trim(), z.minLength(1)),
17
+ }),
18
+ ),
19
+ });
20
+
21
+ export const runtimeDisplayBroadcastOpportunitySchema = z.object({
22
+ opportunityId: z.string().check(z.trim(), z.minLength(1)),
23
+ flowId: z.string().check(z.trim(), z.minLength(1)),
24
+ flowVersionId: z.string().check(z.trim(), z.minLength(1)),
25
+ source: z.object({
26
+ kind: z.literal("runtime_broadcast"),
27
+ automationId: z.optional(z.string().check(z.trim(), z.minLength(1))),
28
+ automationVersionId: z.optional(z.string().check(z.trim(), z.minLength(1))),
29
+ }),
30
+ runtimeEligibility: runtimeDisplayEligibilitySchema,
31
+ });
32
+
9
33
  export const runtimeDisplayBroadcastsSchema = z.object({
10
34
  version: z.string().check(z.trim(), z.minLength(1)),
11
- opportunities: z.array(z.never()),
35
+ opportunities: z.array(runtimeDisplayBroadcastOpportunitySchema),
12
36
  });
13
37
 
14
38
  export const flowDisplaySyncRequestSchema = z.object({
@@ -33,6 +57,12 @@ export const flowDisplaySyncResponseSchema = z.object({
33
57
  export type RuntimeDisplayBroadcasts = z.output<
34
58
  typeof runtimeDisplayBroadcastsSchema
35
59
  >;
60
+ export type RuntimeDisplayBroadcastOpportunity = z.output<
61
+ typeof runtimeDisplayBroadcastOpportunitySchema
62
+ >;
63
+ export type RuntimeDisplayEligibility = z.output<
64
+ typeof runtimeDisplayEligibilitySchema
65
+ >;
36
66
  export type FlowDisplaySyncRequest = z.output<
37
67
  typeof flowDisplaySyncRequestSchema
38
68
  >;