@domino-sdk/relay 1.61.0 → 1.62.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/CHANGELOG.md +156 -8
- package/README.md +3 -2
- package/dist/{schema-CZ6Rj0ZF.d.ts → accounts-CCqCKCVx.d.ts} +3127 -1764
- package/dist/action-9Xl0StBg.d.ts +33 -0
- package/dist/{integrations-B3y36OaB.d.ts → analytics-BwAKLi7O.d.ts} +347 -57
- package/dist/{attempt-captures-DYnJVkfg.d.ts → attempt-captures-Cm-5G0PC.d.ts} +1 -1
- package/dist/authoring.d.ts +130 -42
- package/dist/authoring.js +112 -37
- package/dist/{automatic-outcomes-If88LR9f.d.ts → automatic-outcomes-pAsOyIVp.d.ts} +5 -1
- package/dist/avatar.d.ts +1 -1
- package/dist/browser.d.ts +15 -11
- package/dist/browser.js +15 -11
- package/dist/{announcements-CHx3-HBw.d.ts → capability-error-DFMwSuSf.d.ts} +161 -4
- package/dist/{pages-K7-KjSXw.d.ts → catalog--ZIlskAo.d.ts} +39 -561
- package/dist/{chunk-DYXDZFKA.js → chunk-3KLC4AMA.js} +37 -11
- package/dist/{chunk-XBV2CK2H.js → chunk-3PYYGFSB.js} +14 -2
- package/dist/{chunk-RHBS5FJL.js → chunk-5TEYFX6X.js} +2 -2
- package/dist/chunk-6WCIWXUV.js +31 -0
- package/dist/chunk-CICDIBOF.js +373 -0
- package/dist/{chunk-MHPKEVEW.js → chunk-CZFXGGEK.js} +5 -0
- package/dist/chunk-D26YNACF.js +320 -0
- package/dist/{chunk-5I54XBK2.js → chunk-E6IKQHTX.js} +2 -2
- package/dist/chunk-FWLQ5XCS.js +21 -0
- package/dist/{chunk-SKGTNTLF.js → chunk-GKIFABGN.js} +150 -61
- package/dist/chunk-GTDW453U.js +522 -0
- package/dist/{chunk-VURRFVNP.js → chunk-HTZHBTIL.js} +69 -27
- package/dist/chunk-K2KS3JLY.js +188 -0
- package/dist/{chunk-ZDJLPN4L.js → chunk-MK425RXJ.js} +3143 -3209
- package/dist/{chunk-L77O64I4.js → chunk-QYPMPWVX.js} +1 -1
- package/dist/chunk-UAKYDVT3.js +565 -0
- package/dist/{chunk-DHXDBAJF.js → chunk-UPQPUJOU.js} +36 -123
- package/dist/{chunk-24I4R732.js → chunk-UW5232GG.js} +34 -19
- package/dist/chunk-WSBYWVTZ.js +717 -0
- package/dist/{chunk-PPB7HALD.js → chunk-XJFYAXET.js} +9 -8
- package/dist/{chunk-7A4J67ZL.js → chunk-XNKSSE32.js} +1 -1
- package/dist/{chunk-QEAS4ZGS.js → chunk-Y322OTCH.js} +1 -1
- package/dist/{client-C51w7fMb.d.ts → client-B-hbHX30.d.ts} +109 -40
- package/dist/{deployments-kWoHFaqj.d.ts → deployments-M4OHn7G3.d.ts} +407 -18
- package/dist/identity-integration-3mX6b5iH.d.ts +1241 -0
- package/dist/index.d.ts +13 -11
- package/dist/index.js +14 -11
- package/dist/internal.d.ts +14 -12
- package/dist/internal.js +26 -14
- package/dist/{offers-BoV4ryUc.d.ts → offers-DhAtss4_.d.ts} +21 -4
- package/dist/pages-B8q8Y_dQ.d.ts +715 -0
- package/dist/{participant-activity-DHL8QYks.d.ts → participant-activity-D-Drp24G.d.ts} +16 -3
- package/dist/portal-proxy.d.ts +59 -2
- package/dist/portal-proxy.js +109 -23
- package/dist/react/index.d.ts +206 -26
- package/dist/react/index.js +153 -25
- package/dist/{action-DBzILFx9.d.ts → request-error-D_dUPLwo.d.ts} +1 -31
- package/dist/runtime/authoring.js +1 -1
- package/dist/runtime/chunks/Y4OAVXFR.js +1 -0
- package/dist/runtime/manifest.json +3 -3
- package/dist/runtime/schema.js +1 -1
- package/dist/schema.d.ts +154 -30
- package/dist/schema.js +126 -75
- package/dist/server/index.d.ts +14 -12
- package/dist/server/index.js +2137 -1633
- package/dist/sign-in-providers-BkjcDsFF.d.ts +39 -0
- package/dist/submission-input-DHGKhXfp.d.ts +342 -0
- package/dist/{telegram-browser-BUceZIGZ.d.ts → telegram-browser-BCE7zdOb.d.ts} +46 -6
- package/dist/telegram.d.ts +64 -0
- package/dist/telegram.js +23 -0
- package/dist/testing.d.ts +112 -15
- package/dist/testing.js +321 -16
- package/dist/tracker-data-Hb1uQnk5.d.ts +1855 -0
- package/dist/{transport-BrX9pIGN.d.ts → transport-DkhX2Cbs.d.ts} +5764 -2217
- package/dist/{wallet-CIqFoxdm.d.ts → wallet-DTO7SXj7.d.ts} +20 -7
- package/package.json +5 -1
- package/dist/accounts-DoabriBX.d.ts +0 -306
- package/dist/capability-error-DufwG3G0.d.ts +0 -159
- package/dist/chunk-3Y3L2F54.js +0 -982
- package/dist/chunk-EN3M5Z4J.js +0 -13
- package/dist/chunk-QNUHWK7R.js +0 -602
- package/dist/chunk-SE4PFJPT.js +0 -247
- package/dist/groups-CqcA2Ycs.d.ts +0 -2827
- package/dist/runtime/chunks/5QVFB4TU.js +0 -1
- package/dist/submission-input-C54Q8yAD.d.ts +0 -146
- package/dist/x-D1PGi8Sq.d.ts +0 -331
|
@@ -0,0 +1,522 @@
|
|
|
1
|
+
import {
|
|
2
|
+
authoringIdentityShape,
|
|
3
|
+
calendarPeriodSchema,
|
|
4
|
+
contentMetricSchema,
|
|
5
|
+
contentMetricsSchema,
|
|
6
|
+
identifier,
|
|
7
|
+
maxPointsAmount,
|
|
8
|
+
missingPrerequisiteSchema,
|
|
9
|
+
pageCursorSchema,
|
|
10
|
+
pointsRewardSchema,
|
|
11
|
+
prerequisiteSchema,
|
|
12
|
+
resourceHandle,
|
|
13
|
+
responseShape,
|
|
14
|
+
tierRewardSchema
|
|
15
|
+
} from "./chunk-MK425RXJ.js";
|
|
16
|
+
|
|
17
|
+
// src/engagement.ts
|
|
18
|
+
import * as z from "zod";
|
|
19
|
+
var amount = z.number().int().safe().nonnegative();
|
|
20
|
+
var engagementBudgetSchema = z.strictObject({
|
|
21
|
+
scope: z.enum(["member", "project"]),
|
|
22
|
+
period: calendarPeriodSchema,
|
|
23
|
+
limit: amount
|
|
24
|
+
});
|
|
25
|
+
var engagementDefinitionSchema = z.strictObject({
|
|
26
|
+
key: identifier,
|
|
27
|
+
qualifiedBy: identifier,
|
|
28
|
+
balance: identifier,
|
|
29
|
+
metrics: z.array(contentMetricSchema).min(1).max(10).refine(
|
|
30
|
+
(metrics) => new Set(metrics).size === metrics.length,
|
|
31
|
+
"Metrics must be unique"
|
|
32
|
+
),
|
|
33
|
+
baseline: z.literal("historical"),
|
|
34
|
+
maxAgeMs: z.number().int().positive().max(864e5).default(36e5),
|
|
35
|
+
budgets: z.array(engagementBudgetSchema).max(8).default([]).refine(
|
|
36
|
+
(budgets) => new Set(budgets.map((b) => b.scope + ":" + b.period)).size === budgets.length,
|
|
37
|
+
"Give each scope and period one budget"
|
|
38
|
+
)
|
|
39
|
+
});
|
|
40
|
+
var engagementScoreInputSchema = z.strictObject({
|
|
41
|
+
metrics: contentMetricsSchema,
|
|
42
|
+
baseline: contentMetricsSchema
|
|
43
|
+
});
|
|
44
|
+
var engagementScoreSchema = z.strictObject({
|
|
45
|
+
target: amount,
|
|
46
|
+
baseline: amount
|
|
47
|
+
});
|
|
48
|
+
var engagementPublishSchema = z.strictObject({
|
|
49
|
+
actionId: identifier,
|
|
50
|
+
code: z.string().min(1).max(1e6)
|
|
51
|
+
});
|
|
52
|
+
var engagementRuleSchema = z.strictObject({
|
|
53
|
+
version: identifier,
|
|
54
|
+
definition: engagementDefinitionSchema,
|
|
55
|
+
publishedAt: amount
|
|
56
|
+
});
|
|
57
|
+
var engagementPageQuerySchema = z.strictObject({
|
|
58
|
+
rule: identifier,
|
|
59
|
+
content: z.string().min(1).max(256),
|
|
60
|
+
member: identifier.optional(),
|
|
61
|
+
cursor: pageCursorSchema.optional()
|
|
62
|
+
});
|
|
63
|
+
var engagementSettlementSchema = z.strictObject({
|
|
64
|
+
id: identifier,
|
|
65
|
+
day: z.string(),
|
|
66
|
+
observation: identifier,
|
|
67
|
+
qualification: identifier,
|
|
68
|
+
earned: amount,
|
|
69
|
+
growth: amount,
|
|
70
|
+
paid: amount,
|
|
71
|
+
excluded: amount,
|
|
72
|
+
entry: identifier.nullable(),
|
|
73
|
+
createdAt: amount
|
|
74
|
+
});
|
|
75
|
+
var engagementPageSchema = z.strictObject({
|
|
76
|
+
rule: engagementRuleSchema,
|
|
77
|
+
account: z.strictObject({
|
|
78
|
+
member: identifier,
|
|
79
|
+
earned: amount,
|
|
80
|
+
accounted: amount,
|
|
81
|
+
paid: amount,
|
|
82
|
+
excluded: amount,
|
|
83
|
+
pending: amount,
|
|
84
|
+
counters: contentMetricsSchema,
|
|
85
|
+
baseline: contentMetricsSchema,
|
|
86
|
+
observation: identifier.nullable(),
|
|
87
|
+
nextSettlementAt: amount.nullable(),
|
|
88
|
+
reason: z.string().nullable()
|
|
89
|
+
}).nullable(),
|
|
90
|
+
items: z.array(engagementSettlementSchema),
|
|
91
|
+
nextCursor: pageCursorSchema.nullable()
|
|
92
|
+
});
|
|
93
|
+
var engagementChangePreviewInputSchema = z.strictObject({
|
|
94
|
+
code: z.string().min(1).max(1e6)
|
|
95
|
+
});
|
|
96
|
+
var engagementChangeSchema = engagementPublishSchema.extend({
|
|
97
|
+
expectedVersion: identifier,
|
|
98
|
+
previewHash: identifier
|
|
99
|
+
});
|
|
100
|
+
var total = z.string().regex(/^(0|[1-9][0-9]*)$/);
|
|
101
|
+
var engagementChangePreviewSchema = z.strictObject({
|
|
102
|
+
rule: identifier,
|
|
103
|
+
fromVersion: identifier,
|
|
104
|
+
toVersion: identifier,
|
|
105
|
+
previewHash: identifier,
|
|
106
|
+
definition: engagementDefinitionSchema,
|
|
107
|
+
boundary: z.literal("available-eligible-observation"),
|
|
108
|
+
settlement: z.literal("deferred"),
|
|
109
|
+
summary: z.strictObject({
|
|
110
|
+
knownAdmissions: amount,
|
|
111
|
+
accounts: amount,
|
|
112
|
+
uninitialized: amount,
|
|
113
|
+
pendingTransitions: amount,
|
|
114
|
+
earned: total,
|
|
115
|
+
paid: total,
|
|
116
|
+
excluded: total,
|
|
117
|
+
pending: total
|
|
118
|
+
})
|
|
119
|
+
});
|
|
120
|
+
var engagementVersionSchema = engagementRuleSchema.extend({
|
|
121
|
+
previousVersion: identifier.nullable()
|
|
122
|
+
});
|
|
123
|
+
var engagementRuleVersionPageSchema = z.object({
|
|
124
|
+
items: z.array(
|
|
125
|
+
z.object({
|
|
126
|
+
version: identifier,
|
|
127
|
+
definition: z.object({
|
|
128
|
+
...engagementDefinitionSchema.shape,
|
|
129
|
+
budgets: z.array(z.object(engagementBudgetSchema.shape)).max(8).default([])
|
|
130
|
+
}),
|
|
131
|
+
publishedAt: amount,
|
|
132
|
+
previousVersion: identifier.nullable()
|
|
133
|
+
})
|
|
134
|
+
),
|
|
135
|
+
nextCursor: pageCursorSchema.nullable()
|
|
136
|
+
});
|
|
137
|
+
var engagementVersionPageSchema = z.strictObject({
|
|
138
|
+
items: z.array(engagementVersionSchema),
|
|
139
|
+
next: amount.nullable()
|
|
140
|
+
});
|
|
141
|
+
var engagementVersionQuerySchema = z.strictObject({
|
|
142
|
+
rule: identifier,
|
|
143
|
+
before: z.coerce.number().int().positive().safe().optional()
|
|
144
|
+
});
|
|
145
|
+
var engagementBoundaryPageSchema = z.strictObject({
|
|
146
|
+
current: engagementRuleSchema.nullable(),
|
|
147
|
+
requested: engagementRuleSchema,
|
|
148
|
+
items: z.array(
|
|
149
|
+
z.strictObject({
|
|
150
|
+
from: identifier,
|
|
151
|
+
to: identifier,
|
|
152
|
+
baseline: contentMetricsSchema,
|
|
153
|
+
observedAt: amount,
|
|
154
|
+
settlement: engagementSettlementSchema
|
|
155
|
+
})
|
|
156
|
+
),
|
|
157
|
+
nextCursor: pageCursorSchema.nullable()
|
|
158
|
+
});
|
|
159
|
+
var engagementArtifactSchema = engagementPublishSchema.omit({
|
|
160
|
+
actionId: true
|
|
161
|
+
});
|
|
162
|
+
var deploymentEntry = engagementArtifactSchema.extend({
|
|
163
|
+
rule: engagementRuleSchema
|
|
164
|
+
});
|
|
165
|
+
var engagementDeploymentEntrySchema = z.discriminatedUnion("kind", [
|
|
166
|
+
deploymentEntry.extend({ kind: z.literal("create") }),
|
|
167
|
+
deploymentEntry.extend({ kind: z.literal("unchanged") }),
|
|
168
|
+
deploymentEntry.extend({
|
|
169
|
+
kind: z.literal("change"),
|
|
170
|
+
change: engagementChangePreviewSchema
|
|
171
|
+
})
|
|
172
|
+
]);
|
|
173
|
+
|
|
174
|
+
// src/referrals.ts
|
|
175
|
+
import * as z2 from "zod";
|
|
176
|
+
var rewardSchema = z2.union([pointsRewardSchema, tierRewardSchema]);
|
|
177
|
+
var amount2 = z2.number().int().safe().nonnegative();
|
|
178
|
+
var reason = z2.string().trim().min(1).max(1e3);
|
|
179
|
+
var referralDefinitionSchema = z2.object({
|
|
180
|
+
id: identifier,
|
|
181
|
+
key: identifier.optional(),
|
|
182
|
+
title: z2.string().trim().min(1).max(120),
|
|
183
|
+
enabled: z2.boolean().default(true),
|
|
184
|
+
qualification: z2.discriminatedUnion("kind", [
|
|
185
|
+
z2.object({ kind: z2.literal("signup") }).strict(),
|
|
186
|
+
z2.object({ kind: z2.literal("quest"), quest: identifier }).strict(),
|
|
187
|
+
z2.object({ kind: z2.literal("external") }).strict()
|
|
188
|
+
]),
|
|
189
|
+
inviterGroup: identifier.optional(),
|
|
190
|
+
rewards: z2.object({
|
|
191
|
+
inviter: z2.array(rewardSchema).max(10).default([]),
|
|
192
|
+
invitee: z2.array(rewardSchema).max(10).default([])
|
|
193
|
+
}).strict().default({ inviter: [], invitee: [] }),
|
|
194
|
+
milestones: z2.array(
|
|
195
|
+
z2.object({
|
|
196
|
+
id: identifier,
|
|
197
|
+
count: amount2.min(1),
|
|
198
|
+
rewards: z2.array(rewardSchema).min(1).max(10)
|
|
199
|
+
}).strict()
|
|
200
|
+
).max(30).default([]),
|
|
201
|
+
bonuses: z2.array(
|
|
202
|
+
z2.object({
|
|
203
|
+
id: identifier,
|
|
204
|
+
balance: identifier,
|
|
205
|
+
basisPoints: amount2.min(1).max(1e4),
|
|
206
|
+
quests: z2.array(identifier).min(1).max(100).optional(),
|
|
207
|
+
external: z2.boolean().default(false),
|
|
208
|
+
durationDays: amount2.min(1).max(36500).optional(),
|
|
209
|
+
maxPoints: amount2.min(1).optional()
|
|
210
|
+
}).strict()
|
|
211
|
+
).max(20).default([])
|
|
212
|
+
}).strict().superRefine((value, ctx) => {
|
|
213
|
+
for (const entries of [value.milestones, value.bonuses]) {
|
|
214
|
+
if (new Set(entries.map((e) => e.id)).size !== entries.length) {
|
|
215
|
+
ctx.addIssue({ code: "custom", message: "Rule IDs must be unique" });
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
var referralAuthoringSchema = z2.object(referralDefinitionSchema.shape).omit({ id: true }).extend({
|
|
220
|
+
...authoringIdentityShape,
|
|
221
|
+
inviterGroup: identifier.optional()
|
|
222
|
+
}).strict().superRefine((value, ctx) => {
|
|
223
|
+
for (const entries of [value.milestones, value.bonuses]) {
|
|
224
|
+
if (new Set(entries.map((entry) => entry.id)).size !== entries.length) {
|
|
225
|
+
ctx.addIssue({ code: "custom", message: "Rule keys must be unique" });
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
var referralArtifactSchema = z2.union([
|
|
230
|
+
referralAuthoringSchema,
|
|
231
|
+
z2.object({ code: z2.string().min(1).max(2e6) }).strict()
|
|
232
|
+
]);
|
|
233
|
+
var publishedReferralSchema = z2.object({
|
|
234
|
+
archivedAt: z2.number().int().nonnegative().nullable().optional(),
|
|
235
|
+
version: identifier,
|
|
236
|
+
definition: referralDefinitionSchema,
|
|
237
|
+
publishedAt: amount2,
|
|
238
|
+
actor: z2.string().nullable()
|
|
239
|
+
});
|
|
240
|
+
var referralAcceptSchema = z2.object({ actionId: identifier, code: identifier }).strict();
|
|
241
|
+
var referralSuspensionSchema = z2.object({ actionId: identifier, suspended: z2.boolean(), reason }).strict();
|
|
242
|
+
var referralQualificationSchema = z2.object({ actionId: identifier, qualified: z2.boolean(), reason }).strict();
|
|
243
|
+
var referralRewardResolutionSchema = z2.object({ actionId: identifier, reason }).strict();
|
|
244
|
+
var referralControlSchema = z2.discriminatedUnion("kind", [
|
|
245
|
+
z2.object({
|
|
246
|
+
kind: z2.literal("suspend"),
|
|
247
|
+
actionId: identifier,
|
|
248
|
+
member: identifier,
|
|
249
|
+
suspended: z2.boolean(),
|
|
250
|
+
reason
|
|
251
|
+
}).strict(),
|
|
252
|
+
z2.object({
|
|
253
|
+
kind: z2.literal("qualify"),
|
|
254
|
+
actionId: identifier,
|
|
255
|
+
member: identifier,
|
|
256
|
+
program: identifier,
|
|
257
|
+
qualified: z2.boolean(),
|
|
258
|
+
reason
|
|
259
|
+
}).strict(),
|
|
260
|
+
z2.object({
|
|
261
|
+
kind: z2.literal("resolve-reward"),
|
|
262
|
+
actionId: identifier,
|
|
263
|
+
entitlement: identifier,
|
|
264
|
+
reason
|
|
265
|
+
}).strict()
|
|
266
|
+
]);
|
|
267
|
+
var referralRelationshipSchema = z2.object({
|
|
268
|
+
member: identifier,
|
|
269
|
+
inviter: identifier,
|
|
270
|
+
acceptedAt: amount2,
|
|
271
|
+
suspended: z2.boolean(),
|
|
272
|
+
/** The member import that recorded this referral, or null when the friend accepted an invitation. */
|
|
273
|
+
import: identifier.nullable().optional()
|
|
274
|
+
});
|
|
275
|
+
var referralAccountSchema = z2.object({
|
|
276
|
+
id: identifier,
|
|
277
|
+
program: identifier,
|
|
278
|
+
kind: z2.enum(["bonus", "fixed", "milestone"]),
|
|
279
|
+
balance: identifier,
|
|
280
|
+
earned: amount2,
|
|
281
|
+
settled: amount2,
|
|
282
|
+
outstanding: amount2
|
|
283
|
+
});
|
|
284
|
+
var referralSummarySchema = z2.object({
|
|
285
|
+
code: identifier,
|
|
286
|
+
attributed: amount2,
|
|
287
|
+
programs: z2.array(
|
|
288
|
+
z2.object({
|
|
289
|
+
definition: referralDefinitionSchema,
|
|
290
|
+
qualified: amount2,
|
|
291
|
+
milestones: z2.array(
|
|
292
|
+
z2.object({ id: identifier, count: amount2, reached: z2.boolean() })
|
|
293
|
+
)
|
|
294
|
+
})
|
|
295
|
+
),
|
|
296
|
+
accounts: z2.array(referralAccountSchema)
|
|
297
|
+
});
|
|
298
|
+
var referralHistorySchema = z2.object({
|
|
299
|
+
items: z2.array(
|
|
300
|
+
z2.object({
|
|
301
|
+
id: amount2,
|
|
302
|
+
program: identifier,
|
|
303
|
+
balance: identifier,
|
|
304
|
+
amount: z2.number().int().safe(),
|
|
305
|
+
at: amount2,
|
|
306
|
+
reason: z2.string()
|
|
307
|
+
})
|
|
308
|
+
),
|
|
309
|
+
nextCursor: pageCursorSchema.nullable()
|
|
310
|
+
});
|
|
311
|
+
var referralManagementSchema = z2.object({
|
|
312
|
+
relationships: z2.array(referralRelationshipSchema),
|
|
313
|
+
qualifications: z2.array(
|
|
314
|
+
z2.object({
|
|
315
|
+
member: identifier,
|
|
316
|
+
program: identifier,
|
|
317
|
+
qualified: z2.boolean(),
|
|
318
|
+
qualifiedAt: amount2,
|
|
319
|
+
/** The member import that recorded this qualification, which paid no reward, or null. */
|
|
320
|
+
import: identifier.nullable().optional()
|
|
321
|
+
})
|
|
322
|
+
),
|
|
323
|
+
accounts: z2.array(
|
|
324
|
+
referralAccountSchema.extend({ member: identifier, invitee: z2.string() })
|
|
325
|
+
),
|
|
326
|
+
reviews: z2.array(
|
|
327
|
+
z2.object({
|
|
328
|
+
entitlement: identifier,
|
|
329
|
+
member: identifier,
|
|
330
|
+
program: identifier,
|
|
331
|
+
reason: z2.string()
|
|
332
|
+
})
|
|
333
|
+
),
|
|
334
|
+
nextCursor: pageCursorSchema.nullable().default(null),
|
|
335
|
+
/** @deprecated Use `nextCursor`, passed back as `cursor`. Removed in 2.0.0. */
|
|
336
|
+
next: amount2.nullable()
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
// src/definition-error.ts
|
|
340
|
+
function issueText(issues) {
|
|
341
|
+
return issues.map(
|
|
342
|
+
(issue) => issue.path.length ? issue.path.map(String).join(".") + ": " + issue.message : issue.message
|
|
343
|
+
).join("; ");
|
|
344
|
+
}
|
|
345
|
+
function parseDefinition(kind, schema, input) {
|
|
346
|
+
const parsed = schema.safeParse(input);
|
|
347
|
+
if (parsed.success) {
|
|
348
|
+
return parsed.data;
|
|
349
|
+
}
|
|
350
|
+
const key = typeof input === "object" && input !== null && "key" in input && typeof input.key === "string" ? ` "${input.key}"` : "";
|
|
351
|
+
parsed.error.message = `${kind}${key} is invalid: ${issueText(parsed.error.issues)}`;
|
|
352
|
+
throw parsed.error;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
// src/offers.ts
|
|
356
|
+
import * as z3 from "zod";
|
|
357
|
+
var quantity = z3.number().int().safe().nonnegative();
|
|
358
|
+
var offerPriceSchema = pointsRewardSchema.extend({
|
|
359
|
+
amount: z3.number().int().positive().max(maxPointsAmount)
|
|
360
|
+
});
|
|
361
|
+
var offerLimitSchema = z3.object({ perMember: z3.number().int().positive().max(1e4) }).strict();
|
|
362
|
+
var offerDefinitionSchema = z3.object({
|
|
363
|
+
id: identifier,
|
|
364
|
+
key: identifier.optional(),
|
|
365
|
+
title: z3.string().trim().min(1).max(120),
|
|
366
|
+
price: offerPriceSchema,
|
|
367
|
+
reward: tierRewardSchema,
|
|
368
|
+
stock: quantity.max(1e6),
|
|
369
|
+
limit: offerLimitSchema.default({ perMember: 1 }),
|
|
370
|
+
/**
|
|
371
|
+
* What a member must meet to redeem, the same prerequisites quests take: `completed`,
|
|
372
|
+
* `balanceAtLeast` and `inGroup`. Checked when the member redeems; absent, anyone can.
|
|
373
|
+
*/
|
|
374
|
+
requires: z3.array(prerequisiteSchema).max(30).optional(),
|
|
375
|
+
enabled: z3.boolean().default(true)
|
|
376
|
+
}).strict();
|
|
377
|
+
var offerAuthoringSchema = offerDefinitionSchema.omit({ id: true, title: true, enabled: true }).extend({
|
|
378
|
+
...authoringIdentityShape,
|
|
379
|
+
title: z3.string().trim().min(1).max(120).optional(),
|
|
380
|
+
// `defineOffer` returns `enabled: true`, and a deployment describes the module's default
|
|
381
|
+
// export and parses it again, so the output has to read back. Pause an offer in Console.
|
|
382
|
+
enabled: z3.literal(true).optional()
|
|
383
|
+
}).strict().transform(({ enabled: _, ...offer }) => ({
|
|
384
|
+
...offer,
|
|
385
|
+
title: offer.title ?? offer.reward.reward.title,
|
|
386
|
+
enabled: true
|
|
387
|
+
}));
|
|
388
|
+
var offerArtifactSchema = z3.union([
|
|
389
|
+
offerAuthoringSchema,
|
|
390
|
+
z3.object({ code: z3.string().min(1).max(2e6) }).strict()
|
|
391
|
+
]);
|
|
392
|
+
var offerAvailabilitySchema = responseShape(
|
|
393
|
+
z3.discriminatedUnion("kind", [
|
|
394
|
+
z3.object({ kind: z3.literal("available"), remaining: quantity }).strict(),
|
|
395
|
+
z3.object({ kind: z3.literal("out-of-stock") }).strict(),
|
|
396
|
+
z3.object({ kind: z3.literal("limit-reached") }).strict(),
|
|
397
|
+
z3.object({ kind: z3.literal("paused") }).strict()
|
|
398
|
+
])
|
|
399
|
+
);
|
|
400
|
+
var offerSchema = responseShape(
|
|
401
|
+
offerDefinitionSchema.extend({
|
|
402
|
+
revision: z3.number().int().positive(),
|
|
403
|
+
available: quantity,
|
|
404
|
+
redeemed: quantity,
|
|
405
|
+
availability: offerAvailabilitySchema,
|
|
406
|
+
/**
|
|
407
|
+
* When an operator archived the offer, or `null`. Only management reads carry it and list an
|
|
408
|
+
* archived offer; it refuses new redemptions with `offer-paused` until it is restored.
|
|
409
|
+
*/
|
|
410
|
+
archivedAt: z3.number().int().nonnegative().nullable().optional(),
|
|
411
|
+
/**
|
|
412
|
+
* The prerequisites the signed-in member has not met yet, so an app can show the offer locked
|
|
413
|
+
* and why. Empty when nothing is missing or the read has no member; redeeming while it is not
|
|
414
|
+
* empty fails with `prerequisites-incomplete`.
|
|
415
|
+
*/
|
|
416
|
+
missing: z3.array(missingPrerequisiteSchema).default([])
|
|
417
|
+
})
|
|
418
|
+
);
|
|
419
|
+
var redeemOfferSchema = z3.object({ actionId: identifier }).strict();
|
|
420
|
+
var redemptionBase = {
|
|
421
|
+
id: identifier,
|
|
422
|
+
offer: identifier,
|
|
423
|
+
member: identifier,
|
|
424
|
+
/**
|
|
425
|
+
* @deprecated Use `id` to refer to a redemption. A redemption is fulfilled in the request that
|
|
426
|
+
* makes it, so nothing is reserved beforehand; the ID refers to no other record. Removed in
|
|
427
|
+
* 2.0.0.
|
|
428
|
+
*/
|
|
429
|
+
reservation: identifier,
|
|
430
|
+
price: offerPriceSchema,
|
|
431
|
+
reward: tierRewardSchema,
|
|
432
|
+
entitlement: identifier,
|
|
433
|
+
revision: z3.number().int().positive(),
|
|
434
|
+
redeemedAt: z3.number().int().safe().nonnegative()
|
|
435
|
+
};
|
|
436
|
+
var redemptionSchema = responseShape(
|
|
437
|
+
z3.discriminatedUnion("status", [
|
|
438
|
+
z3.object({ ...redemptionBase, status: z3.literal("fulfilled") }).strict(),
|
|
439
|
+
z3.object({
|
|
440
|
+
...redemptionBase,
|
|
441
|
+
status: z3.literal("canceled"),
|
|
442
|
+
canceledAt: z3.number().int().safe().nonnegative(),
|
|
443
|
+
reason: z3.string().min(1).max(500)
|
|
444
|
+
}).strict()
|
|
445
|
+
])
|
|
446
|
+
);
|
|
447
|
+
var redemptionQuerySchema = z3.strictObject({
|
|
448
|
+
member: identifier.optional(),
|
|
449
|
+
cursor: pageCursorSchema.optional(),
|
|
450
|
+
limit: z3.coerce.number().int().min(1).max(100).optional()
|
|
451
|
+
});
|
|
452
|
+
var redemptionPageSchema = z3.object({
|
|
453
|
+
items: z3.array(redemptionSchema),
|
|
454
|
+
nextCursor: pageCursorSchema.nullable()
|
|
455
|
+
});
|
|
456
|
+
var offerControlSchema = z3.object({
|
|
457
|
+
actionId: identifier,
|
|
458
|
+
revision: z3.number().int().positive(),
|
|
459
|
+
enabled: z3.boolean(),
|
|
460
|
+
reason: z3.string().trim().min(1).max(500)
|
|
461
|
+
}).strict();
|
|
462
|
+
var redemptionCancellationSchema = z3.object({
|
|
463
|
+
actionId: identifier,
|
|
464
|
+
revision: z3.number().int().positive(),
|
|
465
|
+
reason: z3.string().trim().min(1).max(500)
|
|
466
|
+
}).strict();
|
|
467
|
+
function defineOffer(input) {
|
|
468
|
+
return resourceHandle(
|
|
469
|
+
"offer",
|
|
470
|
+
parseDefinition("Offer", offerAuthoringSchema, input)
|
|
471
|
+
);
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
export {
|
|
475
|
+
engagementBudgetSchema,
|
|
476
|
+
engagementDefinitionSchema,
|
|
477
|
+
engagementScoreInputSchema,
|
|
478
|
+
engagementScoreSchema,
|
|
479
|
+
engagementPublishSchema,
|
|
480
|
+
engagementRuleSchema,
|
|
481
|
+
engagementPageQuerySchema,
|
|
482
|
+
engagementSettlementSchema,
|
|
483
|
+
engagementPageSchema,
|
|
484
|
+
engagementChangePreviewInputSchema,
|
|
485
|
+
engagementChangeSchema,
|
|
486
|
+
engagementChangePreviewSchema,
|
|
487
|
+
engagementRuleVersionPageSchema,
|
|
488
|
+
engagementVersionPageSchema,
|
|
489
|
+
engagementVersionQuerySchema,
|
|
490
|
+
engagementBoundaryPageSchema,
|
|
491
|
+
engagementArtifactSchema,
|
|
492
|
+
engagementDeploymentEntrySchema,
|
|
493
|
+
referralDefinitionSchema,
|
|
494
|
+
referralAuthoringSchema,
|
|
495
|
+
referralArtifactSchema,
|
|
496
|
+
publishedReferralSchema,
|
|
497
|
+
referralAcceptSchema,
|
|
498
|
+
referralSuspensionSchema,
|
|
499
|
+
referralQualificationSchema,
|
|
500
|
+
referralRewardResolutionSchema,
|
|
501
|
+
referralControlSchema,
|
|
502
|
+
referralRelationshipSchema,
|
|
503
|
+
referralAccountSchema,
|
|
504
|
+
referralSummarySchema,
|
|
505
|
+
referralHistorySchema,
|
|
506
|
+
referralManagementSchema,
|
|
507
|
+
parseDefinition,
|
|
508
|
+
offerPriceSchema,
|
|
509
|
+
offerLimitSchema,
|
|
510
|
+
offerDefinitionSchema,
|
|
511
|
+
offerAuthoringSchema,
|
|
512
|
+
offerArtifactSchema,
|
|
513
|
+
offerAvailabilitySchema,
|
|
514
|
+
offerSchema,
|
|
515
|
+
redeemOfferSchema,
|
|
516
|
+
redemptionSchema,
|
|
517
|
+
redemptionQuerySchema,
|
|
518
|
+
redemptionPageSchema,
|
|
519
|
+
offerControlSchema,
|
|
520
|
+
redemptionCancellationSchema,
|
|
521
|
+
defineOffer
|
|
522
|
+
};
|