@domino-sdk/relay 1.11.1 → 1.14.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.
Files changed (50) hide show
  1. package/README.md +1 -0
  2. package/build.mjs +15 -0
  3. package/dist/accounts-5ciAkCMP.d.ts +147 -0
  4. package/dist/{activity-CNiPDPK6.d.ts → activity-D_R3J-gU.d.ts} +115 -115
  5. package/dist/attempt-captures-DZldPZJc.d.ts +285 -0
  6. package/dist/authoring.d.ts +49 -47
  7. package/dist/authoring.js +6 -4
  8. package/dist/{automatic-outcomes-kPIDv6X_.d.ts → automatic-outcomes-6lJGnSDe.d.ts} +1 -1
  9. package/dist/browser.d.ts +8 -7
  10. package/dist/browser.js +7 -6
  11. package/dist/capability-error-oTd3eYFH.d.ts +151 -0
  12. package/dist/chunk-2UAVZCMH.js +314 -0
  13. package/dist/chunk-5TS3OAWS.js +470 -0
  14. package/dist/{chunk-PUDL4JBY.js → chunk-6DD7DVNQ.js} +2 -2
  15. package/dist/{chunk-AGFUDCNM.js → chunk-C3CB4WIQ.js} +1 -1
  16. package/dist/{chunk-T657WO56.js → chunk-LLMJ2SUT.js} +6 -2
  17. package/dist/chunk-NIYCAW2I.js +79 -0
  18. package/dist/chunk-UJACD6K2.js +987 -0
  19. package/dist/{chunk-XK5E4HAS.js → chunk-VBHFJH3P.js} +80 -28
  20. package/dist/chunk-W335CWYJ.js +53 -0
  21. package/dist/{chunk-X7ECZ3AK.js → chunk-XMBM2XD5.js} +1 -1
  22. package/dist/{chunk-2K2QBPAD.js → chunk-ZLYBUM7K.js} +6 -4
  23. package/dist/{client-fUSERMAC.d.ts → client-BTd_CyX3.d.ts} +26 -6
  24. package/dist/{groups-BK8ts2yK.d.ts → groups-4Jb3uYFO.d.ts} +1 -1
  25. package/dist/{images-aw6W7vFZ.d.ts → images-D5kpqHxv.d.ts} +1 -1
  26. package/dist/index.d.ts +9 -8
  27. package/dist/index.js +8 -6
  28. package/dist/{capability-error-ty3SqD_b.d.ts → integrations-Cr9EhGI_.d.ts} +1 -149
  29. package/dist/internal.d.ts +32 -5
  30. package/dist/internal.js +8 -3
  31. package/dist/{offers-C2FANzrG.d.ts → offers-BFI5t-e-.d.ts} +2 -2
  32. package/dist/{pages-Chb6OZSB.d.ts → pages-nIoMT9J3.d.ts} +1 -1
  33. package/dist/{participant-activity-DkL3nY5a.d.ts → participant-activity-DYdUUhw2.d.ts} +1 -0
  34. package/dist/portal-proxy.js +1 -1
  35. package/dist/react/index.d.ts +246 -177
  36. package/dist/react/index.js +954 -383
  37. package/dist/{referral-reward-kinds-M3f0PdiR.d.ts → referral-reward-kinds-DnvQXL8L.d.ts} +100 -3
  38. package/dist/{schema-DEM8y8Fm.d.ts → schema-K-Pg5lPz.d.ts} +1 -1
  39. package/dist/schema.d.ts +316 -314
  40. package/dist/schema.js +16 -14
  41. package/dist/server/index.d.ts +2546 -377
  42. package/dist/server/index.js +594 -841
  43. package/dist/{sign-in-options-iWOp9puZ.d.ts → sign-in-options-DBjMzgnu.d.ts} +2 -2
  44. package/dist/submission-input-CPIsJt-_.d.ts +146 -0
  45. package/dist/testing.d.ts +641 -0
  46. package/dist/testing.js +1282 -0
  47. package/package.json +6 -2
  48. package/dist/chunk-OCXGG75K.js +0 -171
  49. package/dist/chunk-ZFABFKIY.js +0 -1295
  50. package/dist/submission-input-BbBJTVlT.d.ts +0 -290
@@ -0,0 +1,987 @@
1
+ import {
2
+ authoringIdentityShape,
3
+ calendarPeriodSchema,
4
+ contentMetricSchema,
5
+ contentMetricsSchema,
6
+ identifier,
7
+ pageCursorSchema,
8
+ pointsRewardSchema,
9
+ refuseWindowTimeZone,
10
+ resourceHandle,
11
+ responseShape,
12
+ rewardKey,
13
+ tierRewardSchema
14
+ } from "./chunk-46C33ASD.js";
15
+
16
+ // src/point-ledgers.ts
17
+ import { z } from "zod";
18
+ var pointLedgerPropertiesSchema = z.object({
19
+ name: z.string().trim().min(1).max(120),
20
+ description: z.string().trim().max(1e3).default("")
21
+ }).strict();
22
+ var createPointLedgerSchema = pointLedgerPropertiesSchema.extend({ actionId: identifier, key: identifier.optional() }).strict();
23
+ var pointLedgerSchema = pointLedgerPropertiesSchema.extend({
24
+ id: identifier
25
+ });
26
+ var managedPointLedgerSchema = pointLedgerSchema.extend({
27
+ archivedAt: z.number().int().nonnegative().nullable()
28
+ });
29
+ var pointLedgerDeclarationSchema = pointLedgerPropertiesSchema.extend({ key: identifier }).strict();
30
+ var pointLedgerArtifactSchema = z.union([
31
+ pointLedgerDeclarationSchema,
32
+ z.object({ code: z.string().min(1).max(2e6) }).strict()
33
+ ]);
34
+ var pointLedgerReferenceSchema = z.object({
35
+ id: identifier,
36
+ key: identifier.nullable(),
37
+ name: z.string()
38
+ });
39
+ var points = z.number().int().safe();
40
+ var pointBalanceSchema = z.object({
41
+ ledger: pointLedgerReferenceSchema,
42
+ balance: points,
43
+ available: points
44
+ });
45
+ var pointBalancesSchema = z.object({
46
+ items: z.array(pointBalanceSchema)
47
+ });
48
+ var PointEntryKind = {
49
+ /** Points a quest completion, an engagement settlement or an operator awarded. */
50
+ Award: "award",
51
+ /** Points the member spent. */
52
+ Spend: "spend",
53
+ /** A correction in either direction, by an operator or a referral payout. */
54
+ Adjust: "adjust",
55
+ /** Undoes part or all of an award or a positive adjustment (`reverses`). */
56
+ Reverse: "reverse"
57
+ };
58
+ var pointEntryKindSchema = z.string().min(1).max(64);
59
+ var pointEntrySchema = z.object({
60
+ id: identifier,
61
+ amount: points,
62
+ kind: pointEntryKindSchema,
63
+ /** When the entry took effect, in epoch milliseconds. A reversal keeps its source's. */
64
+ at: points.nonnegative(),
65
+ quest: identifier.nullable(),
66
+ reverses: identifier.nullable()
67
+ });
68
+ var pointHistoryQuerySchema = z.strictObject({
69
+ ledger: identifier,
70
+ cursor: pageCursorSchema.optional()
71
+ });
72
+ var pointHistoryPageSchema = z.object({
73
+ items: z.array(pointEntrySchema),
74
+ nextCursor: pageCursorSchema.nullable()
75
+ });
76
+
77
+ // src/engagement.ts
78
+ import { z as z2 } from "zod";
79
+ var amount = z2.number().int().safe().nonnegative();
80
+ var engagementBudgetSchema = z2.strictObject({
81
+ scope: z2.enum(["member", "project"]),
82
+ period: calendarPeriodSchema,
83
+ limit: amount
84
+ });
85
+ var engagementDefinitionSchema = z2.strictObject({
86
+ key: identifier,
87
+ qualifiedBy: identifier,
88
+ balance: identifier,
89
+ metrics: z2.array(contentMetricSchema).min(1).max(10).refine(
90
+ (metrics) => new Set(metrics).size === metrics.length,
91
+ "Metrics must be unique"
92
+ ),
93
+ baseline: z2.literal("historical"),
94
+ maxAgeMs: z2.number().int().positive().max(864e5).default(36e5),
95
+ budgets: z2.array(engagementBudgetSchema).max(8).default([]).refine(
96
+ (budgets) => new Set(budgets.map((b) => b.scope + ":" + b.period)).size === budgets.length,
97
+ "Give each scope and period one budget"
98
+ )
99
+ });
100
+ var engagementScoreInputSchema = z2.strictObject({
101
+ metrics: contentMetricsSchema,
102
+ baseline: contentMetricsSchema
103
+ });
104
+ var engagementScoreSchema = z2.strictObject({
105
+ target: amount,
106
+ baseline: amount
107
+ });
108
+ var engagementPublishSchema = z2.strictObject({
109
+ actionId: identifier,
110
+ code: z2.string().min(1).max(1e6)
111
+ });
112
+ var engagementRuleSchema = z2.strictObject({
113
+ version: identifier,
114
+ definition: engagementDefinitionSchema,
115
+ publishedAt: amount
116
+ });
117
+ var engagementPageQuerySchema = z2.strictObject({
118
+ rule: identifier,
119
+ content: z2.string().min(1).max(256),
120
+ member: identifier.optional(),
121
+ cursor: pageCursorSchema.optional()
122
+ });
123
+ var engagementSettlementSchema = z2.strictObject({
124
+ id: identifier,
125
+ day: z2.string(),
126
+ observation: identifier,
127
+ qualification: identifier,
128
+ earned: amount,
129
+ growth: amount,
130
+ paid: amount,
131
+ excluded: amount,
132
+ entry: identifier.nullable(),
133
+ createdAt: amount
134
+ });
135
+ var engagementPageSchema = z2.strictObject({
136
+ rule: engagementRuleSchema,
137
+ account: z2.strictObject({
138
+ member: identifier,
139
+ earned: amount,
140
+ accounted: amount,
141
+ paid: amount,
142
+ excluded: amount,
143
+ pending: amount,
144
+ counters: contentMetricsSchema,
145
+ baseline: contentMetricsSchema,
146
+ observation: identifier.nullable(),
147
+ nextSettlementAt: amount.nullable(),
148
+ reason: z2.string().nullable()
149
+ }).nullable(),
150
+ items: z2.array(engagementSettlementSchema),
151
+ nextCursor: pageCursorSchema.nullable()
152
+ });
153
+ var engagementChangePreviewInputSchema = z2.strictObject({
154
+ code: z2.string().min(1).max(1e6)
155
+ });
156
+ var engagementChangeSchema = engagementPublishSchema.extend({
157
+ expectedVersion: identifier,
158
+ previewHash: identifier
159
+ });
160
+ var total = z2.string().regex(/^(0|[1-9][0-9]*)$/);
161
+ var engagementChangePreviewSchema = z2.strictObject({
162
+ rule: identifier,
163
+ fromVersion: identifier,
164
+ toVersion: identifier,
165
+ previewHash: identifier,
166
+ definition: engagementDefinitionSchema,
167
+ boundary: z2.literal("available-eligible-observation"),
168
+ settlement: z2.literal("deferred"),
169
+ summary: z2.strictObject({
170
+ knownAdmissions: amount,
171
+ accounts: amount,
172
+ uninitialized: amount,
173
+ pendingTransitions: amount,
174
+ earned: total,
175
+ paid: total,
176
+ excluded: total,
177
+ pending: total
178
+ })
179
+ });
180
+ var engagementVersionSchema = engagementRuleSchema.extend({
181
+ previousVersion: identifier.nullable()
182
+ });
183
+ var engagementRuleVersionPageSchema = z2.object({
184
+ items: z2.array(
185
+ z2.object({
186
+ version: identifier,
187
+ definition: z2.object({
188
+ ...engagementDefinitionSchema.shape,
189
+ budgets: z2.array(z2.object(engagementBudgetSchema.shape)).max(8).default([])
190
+ }),
191
+ publishedAt: amount,
192
+ previousVersion: identifier.nullable()
193
+ })
194
+ ),
195
+ nextCursor: pageCursorSchema.nullable()
196
+ });
197
+ var engagementVersionPageSchema = z2.strictObject({
198
+ items: z2.array(engagementVersionSchema),
199
+ next: amount.nullable()
200
+ });
201
+ var engagementVersionQuerySchema = z2.strictObject({
202
+ rule: identifier,
203
+ before: z2.coerce.number().int().positive().safe().optional()
204
+ });
205
+ var engagementBoundaryPageSchema = z2.strictObject({
206
+ current: engagementRuleSchema.nullable(),
207
+ requested: engagementRuleSchema,
208
+ items: z2.array(
209
+ z2.strictObject({
210
+ from: identifier,
211
+ to: identifier,
212
+ baseline: contentMetricsSchema,
213
+ observedAt: amount,
214
+ settlement: engagementSettlementSchema
215
+ })
216
+ ),
217
+ nextCursor: pageCursorSchema.nullable()
218
+ });
219
+ var engagementArtifactSchema = engagementPublishSchema.omit({
220
+ actionId: true
221
+ });
222
+ var deploymentEntry = engagementArtifactSchema.extend({
223
+ rule: engagementRuleSchema
224
+ });
225
+ var engagementDeploymentEntrySchema = z2.discriminatedUnion("kind", [
226
+ deploymentEntry.extend({ kind: z2.literal("create") }),
227
+ deploymentEntry.extend({ kind: z2.literal("unchanged") }),
228
+ deploymentEntry.extend({
229
+ kind: z2.literal("change"),
230
+ change: engagementChangePreviewSchema
231
+ })
232
+ ]);
233
+
234
+ // src/profiles.ts
235
+ import { z as z3 } from "zod";
236
+ var count = z3.number().int().nonnegative().safe();
237
+ var profileVisibilitySchema = z3.enum([
238
+ "private",
239
+ "participants",
240
+ "public"
241
+ ]);
242
+ var avatarProviderSchema = z3.enum(["x", "discord", "google"]);
243
+ var profileDefaultProviderSchema = z3.enum(["x", "discord"]);
244
+ var profileDefaultsSchema = z3.array(profileDefaultProviderSchema).max(profileDefaultProviderSchema.options.length).refine(
245
+ (providers) => new Set(providers).size === providers.length,
246
+ "List each provider once"
247
+ );
248
+ var avatarSeedSchema = z3.string().min(1).max(100);
249
+ var profileAvatarSchema = z3.discriminatedUnion("source", [
250
+ z3.object({
251
+ source: z3.literal("upload"),
252
+ url: z3.string().url(),
253
+ seed: avatarSeedSchema
254
+ }),
255
+ z3.object({
256
+ source: z3.literal("account"),
257
+ provider: avatarProviderSchema,
258
+ url: z3.string().url(),
259
+ seed: avatarSeedSchema
260
+ }),
261
+ z3.object({ source: z3.literal("generated"), seed: avatarSeedSchema })
262
+ ]);
263
+ var profileSummarySchema = z3.object({
264
+ id: identifier,
265
+ name: z3.string(),
266
+ avatar: profileAvatarSchema
267
+ });
268
+ var invisible = /[\p{Cc}؜᠎​-‏‪-‮⁠-⁤⁦-⁩]/u;
269
+ var displayNameSchema = z3.string().max(200).transform((value) => value.normalize("NFC").replace(/\s+/g, " ").trim()).pipe(
270
+ z3.string().min(1, "Enter a name").max(40, "Use at most 40 characters").refine((value) => !invisible.test(value), "Use visible characters only")
271
+ );
272
+ var profileUpdateSchema = z3.object({
273
+ displayName: displayNameSchema.nullable().optional(),
274
+ avatar: z3.discriminatedUnion("source", [
275
+ z3.object({
276
+ source: z3.literal("account"),
277
+ provider: avatarProviderSchema
278
+ }).strict(),
279
+ z3.object({ source: z3.literal("generated") }).strict()
280
+ ]).nullable().optional(),
281
+ hidden: z3.boolean().optional()
282
+ }).strict().refine(
283
+ (value) => Object.values(value).some((field) => field !== void 0),
284
+ "Change at least one field"
285
+ );
286
+ var ownProfileSchema = profileSummarySchema.extend({
287
+ /** The name the member chose, or null for the default. */
288
+ displayName: z3.string().nullable(),
289
+ /** The avatar the member chose: `default` follows the project's defaults. */
290
+ avatarChoice: z3.enum(["default", "upload", "account", "generated"]),
291
+ /** The account of an `account` choice. */
292
+ avatarProvider: avatarProviderSchema.nullable(),
293
+ hidden: z3.boolean(),
294
+ /** An operator locked the name and avatar; the member can still hide the profile. */
295
+ locked: z3.boolean(),
296
+ /** Who can see profiles in this project, so the app can explain it. */
297
+ visibility: profileVisibilitySchema,
298
+ /** The member's connected accounts a picture or name can come from. */
299
+ options: z3.array(
300
+ z3.object({
301
+ provider: avatarProviderSchema,
302
+ name: z3.string().nullable(),
303
+ imageUrl: z3.string().url().nullable()
304
+ })
305
+ )
306
+ });
307
+ var cursor = z3.string().min(1).max(512);
308
+ var profileCompletionQuerySchema = z3.object({
309
+ limit: z3.coerce.number().int().min(1).max(100).default(20),
310
+ cursor: cursor.optional()
311
+ }).strict();
312
+ var profileCompletionSchema = z3.object({
313
+ quest: identifier,
314
+ key: identifier.optional(),
315
+ title: z3.string(),
316
+ completions: count.positive(),
317
+ /** Null for completions recorded before completion times were. */
318
+ lastCompletedAt: count.nullable()
319
+ });
320
+ var profileCompletionPageSchema = z3.object({
321
+ items: z3.array(profileCompletionSchema),
322
+ nextCursor: cursor.nullable()
323
+ });
324
+ var profileReferralSchema = z3.object({
325
+ program: identifier,
326
+ key: identifier.optional(),
327
+ title: z3.string(),
328
+ /** Members this member invited. Invitations are shared by every program. */
329
+ invited: count,
330
+ /** Invited members who qualified in this program. */
331
+ qualified: count,
332
+ milestones: z3.array(
333
+ z3.object({ id: identifier, count, reached: z3.boolean() })
334
+ )
335
+ });
336
+ var profileSettingsSchema = z3.object({
337
+ visibility: profileVisibilitySchema,
338
+ defaults: profileDefaultsSchema,
339
+ revision: count,
340
+ actor: z3.string().nullable(),
341
+ updatedAt: count.nullable()
342
+ });
343
+ var profileSettingsInputSchema = profileSettingsSchema.omit({ revision: true, actor: true, updatedAt: true }).extend({
344
+ actionId: identifier,
345
+ /** The revision the change was made against; a newer one is a 409. */
346
+ expectedRevision: count,
347
+ reason: z3.string().trim().min(1).max(500)
348
+ }).strict();
349
+ var profileModerationSchema = z3.object({
350
+ actionId: identifier,
351
+ resetName: z3.boolean().default(false),
352
+ removeAvatar: z3.boolean().default(false),
353
+ /** True locks the name and avatar, false unlocks them. */
354
+ lock: z3.boolean().optional(),
355
+ reason: z3.string().trim().min(1).max(1e3)
356
+ }).strict().refine(
357
+ (value) => value.resetName || value.removeAvatar || value.lock !== void 0,
358
+ "Choose an action"
359
+ );
360
+ var managedProfileSchema = ownProfileSchema.omit({ options: true }).extend({
361
+ member: identifier,
362
+ lockedAt: count.nullable(),
363
+ lockedBy: z3.string().nullable(),
364
+ lockedReason: z3.string().nullable(),
365
+ updatedAt: count
366
+ });
367
+ var AVATAR_UPLOAD_LIMIT = 5 * 1024 * 1024;
368
+ var avatarUploadTypes = ["image/jpeg", "image/png", "image/webp"];
369
+
370
+ // src/leaderboards.ts
371
+ import { z as z4 } from "zod";
372
+ var integer = z4.number().int().safe();
373
+ var timestamp = integer.nonnegative().max(864e13);
374
+ var leaderboardWindowSchema = z4.discriminatedUnion("kind", [
375
+ z4.object({ kind: z4.literal("all-time") }).strict(),
376
+ z4.object({ kind: z4.literal("fixed"), start: timestamp, end: timestamp }).strict().refine((w) => w.end > w.start, "Window end must follow its start"),
377
+ z4.object({ kind: z4.literal("rolling"), days: integer.min(1).max(3660) }).strict(),
378
+ // Not strict: boards published while a calendar window named its own `timeZone` keep reading,
379
+ // and the field drops on parse. The authoring schema refuses it.
380
+ z4.object({
381
+ kind: z4.literal("calendar"),
382
+ /** The current day, week (ISO, starting on Monday) or month of the project calendar. */
383
+ period: calendarPeriodSchema.exclude(["lifetime"])
384
+ })
385
+ ]);
386
+ var periodScore = {
387
+ window: leaderboardWindowSchema.default({ kind: "all-time" }),
388
+ quests: z4.array(identifier).min(1).max(100).optional()
389
+ };
390
+ var scoreSchema = z4.discriminatedUnion("kind", [
391
+ z4.object({ kind: z4.literal("balance") }).strict(),
392
+ z4.object({ kind: z4.literal("earned"), ...periodScore }).strict(),
393
+ z4.object({
394
+ kind: z4.literal("net"),
395
+ window: leaderboardWindowSchema.default({ kind: "all-time" })
396
+ }).strict()
397
+ ]).default({ kind: "balance" });
398
+ var leaderboardPrizeRewardSchema = z4.union([
399
+ pointsRewardSchema,
400
+ tierRewardSchema
401
+ ]);
402
+ var leaderboardPrizeSchema = z4.object({
403
+ ranks: z4.tuple([integer.positive(), integer.positive()]).refine(([first, last]) => last >= first, {
404
+ message: "Prize rank range must end at or after it starts"
405
+ }),
406
+ rewards: z4.array(leaderboardPrizeRewardSchema).min(1).max(20)
407
+ }).strict();
408
+ var leaderboardSettlementPolicySchema = z4.object({
409
+ at: z4.literal("window-end"),
410
+ ties: z4.enum(["shared", "earliest"]),
411
+ prizes: z4.array(leaderboardPrizeSchema).min(1).max(50)
412
+ }).strict().superRefine((policy, context) => {
413
+ for (const [index, prize] of policy.prizes.entries()) {
414
+ const keys = prize.rewards.map(rewardKey);
415
+ if (new Set(keys).size !== keys.length) {
416
+ context.addIssue({
417
+ code: "custom",
418
+ message: "A prize may grant each point ledger or tiered reward only once",
419
+ path: ["prizes", index, "rewards"]
420
+ });
421
+ }
422
+ }
423
+ for (let index = 1; index < policy.prizes.length; index++) {
424
+ const previous = policy.prizes[index - 1];
425
+ const current = policy.prizes[index];
426
+ if (current.ranks[0] <= previous.ranks[1]) {
427
+ context.addIssue({
428
+ code: "custom",
429
+ message: "Prize rank ranges must be ordered and must not overlap",
430
+ path: ["prizes", index, "ranks"]
431
+ });
432
+ }
433
+ }
434
+ });
435
+ var leaderboardDefinitionObject = z4.object({
436
+ id: identifier,
437
+ key: identifier.optional(),
438
+ title: z4.string().trim().min(1).max(120),
439
+ balance: identifier,
440
+ score: scoreSchema,
441
+ access: z4.enum(["participants", "public"]).default("participants"),
442
+ group: identifier.optional(),
443
+ settle: leaderboardSettlementPolicySchema.optional()
444
+ }).strict();
445
+ var validateSettlementWindow = (definition, context) => {
446
+ if (definition.settle && (definition.score.kind === "balance" || !["fixed", "calendar"].includes(definition.score.window.kind))) {
447
+ context.addIssue({
448
+ code: "custom",
449
+ message: "Leaderboard prizes require an earned or net score with a fixed or calendar window",
450
+ path: ["settle"]
451
+ });
452
+ }
453
+ };
454
+ var leaderboardDefinitionSchema = leaderboardDefinitionObject.superRefine(validateSettlementWindow);
455
+ var leaderboardDefinitionResponseSchema = responseShape(
456
+ leaderboardDefinitionSchema
457
+ );
458
+ var leaderboardAuthoringSchema = leaderboardDefinitionObject.omit({ id: true }).extend({
459
+ ...authoringIdentityShape,
460
+ score: z4.preprocess(refuseWindowTimeZone, scoreSchema),
461
+ group: identifier.optional()
462
+ }).strict().superRefine(validateSettlementWindow);
463
+ var leaderboardArtifactSchema = z4.union([
464
+ leaderboardAuthoringSchema,
465
+ z4.object({ code: z4.string().min(1).max(2e6) }).strict()
466
+ ]);
467
+ var publishedLeaderboardSchema = z4.object({
468
+ archivedAt: z4.number().int().nonnegative().nullable().optional(),
469
+ version: identifier,
470
+ definition: leaderboardDefinitionResponseSchema,
471
+ publishedAt: timestamp,
472
+ actor: z4.string().nullable()
473
+ });
474
+ var leaderboardQuerySchema = z4.object({
475
+ limit: z4.coerce.number().int().min(1).max(100).default(25),
476
+ cursor: z4.string().max(4096).optional()
477
+ }).strict();
478
+ var leaderboardRowSchema = z4.object({
479
+ /** The row's stable key: a pseudonym per board and member. */
480
+ participant: identifier,
481
+ member: identifier.optional(),
482
+ /** The profile's name where the viewer can see it, otherwise the pseudonym's. */
483
+ name: z4.string(),
484
+ score: integer,
485
+ rank: integer.positive(),
486
+ /** The member's profile, where visible to this viewer and not hidden by the member. */
487
+ profile: profileSummarySchema.nullable()
488
+ });
489
+ var leaderboardPageSchema = z4.object({
490
+ leaderboard: identifier,
491
+ title: z4.string(),
492
+ version: identifier,
493
+ calculation: z4.enum(["balance", "earned", "net"]),
494
+ period: z4.object({ start: timestamp.nullable(), end: timestamp.nullable() }),
495
+ calculatedAt: timestamp,
496
+ lastEntryAt: timestamp.nullable(),
497
+ total: integer.nonnegative(),
498
+ items: z4.array(leaderboardRowSchema),
499
+ me: leaderboardRowSchema.nullable(),
500
+ nearby: z4.array(leaderboardRowSchema),
501
+ nextCursor: z4.string().nullable()
502
+ });
503
+ var leaderboardPlacementSchema = z4.object({
504
+ leaderboard: identifier,
505
+ key: identifier.optional(),
506
+ title: z4.string(),
507
+ profile: identifier,
508
+ rank: integer.positive().nullable(),
509
+ score: integer.nullable(),
510
+ /** Ranked participants on the board. */
511
+ total: integer.nonnegative()
512
+ });
513
+ var leaderboardPreviewSchema = z4.object({
514
+ published: publishedLeaderboardSchema,
515
+ before: leaderboardPageSchema.nullable(),
516
+ after: leaderboardPageSchema
517
+ });
518
+ var mutationBase = {
519
+ actionId: identifier,
520
+ member: identifier,
521
+ balance: identifier,
522
+ reason: z4.string().trim().min(1).max(1e3)
523
+ };
524
+ var datedMutation = { ...mutationBase, effectiveAt: timestamp.optional() };
525
+ var pointsMutationSchema = z4.discriminatedUnion("kind", [
526
+ z4.object({
527
+ ...datedMutation,
528
+ kind: z4.literal("award"),
529
+ referralEligible: z4.boolean().optional(),
530
+ amount: integer.positive()
531
+ }).strict(),
532
+ z4.object({
533
+ ...datedMutation,
534
+ kind: z4.literal("spend"),
535
+ amount: integer.positive()
536
+ }).strict(),
537
+ z4.object({
538
+ ...datedMutation,
539
+ kind: z4.literal("adjust"),
540
+ amount: integer.refine((n) => n !== 0)
541
+ }).strict(),
542
+ z4.object({
543
+ ...datedMutation,
544
+ kind: z4.literal("set"),
545
+ total: integer.nonnegative(),
546
+ expectedTotal: integer.nonnegative(),
547
+ classification: z4.enum(["earned", "spend"])
548
+ }).strict(),
549
+ z4.object({
550
+ ...mutationBase,
551
+ kind: z4.literal("reverse"),
552
+ entry: identifier,
553
+ amount: integer.positive()
554
+ }).strict()
555
+ ]);
556
+ var pointsEntrySchema = z4.object({
557
+ id: identifier,
558
+ completion: z4.string().nullable(),
559
+ member: identifier,
560
+ balance: identifier,
561
+ amount: integer,
562
+ kind: z4.enum(["award", "spend", "adjust", "reverse"]),
563
+ effectiveAt: timestamp,
564
+ receivedAt: timestamp,
565
+ quest: identifier.nullable(),
566
+ original: identifier.nullable(),
567
+ reason: z4.string(),
568
+ actor: z4.string().nullable()
569
+ });
570
+ var managedPointHistoryPageSchema = z4.object({
571
+ items: z4.array(pointsEntrySchema),
572
+ nextCursor: pageCursorSchema.nullable(),
573
+ /** @deprecated Use `nextCursor`, passed back as `cursor`. Removed in 2.0.0. */
574
+ next: z4.number().nullable()
575
+ });
576
+ var pointsResultSchema = z4.object({
577
+ entry: pointsEntrySchema,
578
+ total: integer.nonnegative()
579
+ });
580
+ var pointsAccountSchema = z4.object({
581
+ member: identifier,
582
+ balance: identifier,
583
+ total: integer.nonnegative(),
584
+ held: integer.nonnegative()
585
+ });
586
+ var leaderboardExclusionSchema = z4.object({
587
+ actionId: identifier,
588
+ member: identifier,
589
+ excluded: z4.boolean(),
590
+ reason: z4.string().trim().min(1).max(1e3)
591
+ }).strict();
592
+ var leaderboardGroupSchema = z4.object({
593
+ actionId: identifier,
594
+ member: identifier,
595
+ included: z4.boolean(),
596
+ reason: z4.string().trim().min(1).max(1e3)
597
+ }).strict();
598
+ var leaderboardSettlementStatusSchema = z4.enum(["pending", "approved"]);
599
+ var leaderboardSettlementSummarySchema = z4.object({
600
+ id: identifier,
601
+ leaderboard: identifier,
602
+ version: identifier,
603
+ title: z4.string(),
604
+ period: z4.object({ start: timestamp, end: timestamp }),
605
+ ties: z4.enum(["shared", "earliest"]),
606
+ status: leaderboardSettlementStatusSchema,
607
+ total: integer.nonnegative(),
608
+ winners: integer.nonnegative(),
609
+ createdAt: timestamp,
610
+ approvedAt: timestamp.nullable(),
611
+ approvedBy: z4.string().nullable(),
612
+ approvalReason: z4.string().nullable()
613
+ });
614
+ var leaderboardSettlementRowSchema = z4.object({
615
+ member: identifier,
616
+ score: integer,
617
+ rank: integer.positive(),
618
+ position: integer.positive(),
619
+ scoredAt: timestamp,
620
+ prizes: z4.array(integer.nonnegative()),
621
+ completion: identifier.nullable(),
622
+ revokedAt: timestamp.nullable()
623
+ });
624
+ var leaderboardSettlementSchema = leaderboardSettlementSummarySchema.extend({
625
+ prizes: z4.array(leaderboardPrizeSchema),
626
+ excluded: z4.array(identifier),
627
+ rows: z4.array(leaderboardSettlementRowSchema)
628
+ });
629
+ var leaderboardSettlementApprovalSchema = z4.object({
630
+ actionId: identifier,
631
+ reason: z4.string().trim().min(1).max(500)
632
+ }).strict();
633
+
634
+ // src/referrals.ts
635
+ import { z as z5 } from "zod";
636
+ var rewardSchema = z5.union([pointsRewardSchema, tierRewardSchema]);
637
+ var amount2 = z5.number().int().safe().nonnegative();
638
+ var reason = z5.string().trim().min(1).max(1e3);
639
+ var referralDefinitionSchema = z5.object({
640
+ id: identifier,
641
+ key: identifier.optional(),
642
+ title: z5.string().trim().min(1).max(120),
643
+ enabled: z5.boolean().default(true),
644
+ qualification: z5.discriminatedUnion("kind", [
645
+ z5.object({ kind: z5.literal("signup") }).strict(),
646
+ z5.object({ kind: z5.literal("quest"), quest: identifier }).strict(),
647
+ z5.object({ kind: z5.literal("external") }).strict()
648
+ ]),
649
+ inviterGroup: identifier.optional(),
650
+ rewards: z5.object({
651
+ inviter: z5.array(rewardSchema).max(10).default([]),
652
+ invitee: z5.array(rewardSchema).max(10).default([])
653
+ }).strict().default({ inviter: [], invitee: [] }),
654
+ milestones: z5.array(
655
+ z5.object({
656
+ id: identifier,
657
+ count: amount2.min(1),
658
+ rewards: z5.array(rewardSchema).min(1).max(10)
659
+ }).strict()
660
+ ).max(30).default([]),
661
+ bonuses: z5.array(
662
+ z5.object({
663
+ id: identifier,
664
+ balance: identifier,
665
+ basisPoints: amount2.min(1).max(1e4),
666
+ quests: z5.array(identifier).min(1).max(100).optional(),
667
+ external: z5.boolean().default(false),
668
+ durationDays: amount2.min(1).max(36500).optional(),
669
+ maxPoints: amount2.min(1).optional()
670
+ }).strict()
671
+ ).max(20).default([])
672
+ }).strict().superRefine((value, ctx) => {
673
+ for (const entries of [value.milestones, value.bonuses]) {
674
+ if (new Set(entries.map((e) => e.id)).size !== entries.length) {
675
+ ctx.addIssue({ code: "custom", message: "Rule IDs must be unique" });
676
+ }
677
+ }
678
+ });
679
+ var referralAuthoringSchema = z5.object(referralDefinitionSchema.shape).omit({ id: true }).extend({
680
+ ...authoringIdentityShape,
681
+ inviterGroup: identifier.optional()
682
+ }).strict().superRefine((value, ctx) => {
683
+ for (const entries of [value.milestones, value.bonuses]) {
684
+ if (new Set(entries.map((entry) => entry.id)).size !== entries.length) {
685
+ ctx.addIssue({ code: "custom", message: "Rule keys must be unique" });
686
+ }
687
+ }
688
+ });
689
+ var referralArtifactSchema = z5.union([
690
+ referralAuthoringSchema,
691
+ z5.object({ code: z5.string().min(1).max(2e6) }).strict()
692
+ ]);
693
+ var publishedReferralSchema = z5.object({
694
+ archivedAt: z5.number().int().nonnegative().nullable().optional(),
695
+ version: identifier,
696
+ definition: referralDefinitionSchema,
697
+ publishedAt: amount2,
698
+ actor: z5.string().nullable()
699
+ });
700
+ var referralAcceptSchema = z5.object({ actionId: identifier, code: identifier }).strict();
701
+ var referralSuspensionSchema = z5.object({ actionId: identifier, suspended: z5.boolean(), reason }).strict();
702
+ var referralQualificationSchema = z5.object({ actionId: identifier, qualified: z5.boolean(), reason }).strict();
703
+ var referralRewardResolutionSchema = z5.object({ actionId: identifier, reason }).strict();
704
+ var referralControlSchema = z5.discriminatedUnion("kind", [
705
+ z5.object({
706
+ kind: z5.literal("suspend"),
707
+ actionId: identifier,
708
+ member: identifier,
709
+ suspended: z5.boolean(),
710
+ reason
711
+ }).strict(),
712
+ z5.object({
713
+ kind: z5.literal("qualify"),
714
+ actionId: identifier,
715
+ member: identifier,
716
+ program: identifier,
717
+ qualified: z5.boolean(),
718
+ reason
719
+ }).strict(),
720
+ z5.object({
721
+ kind: z5.literal("resolve-reward"),
722
+ actionId: identifier,
723
+ entitlement: identifier,
724
+ reason
725
+ }).strict()
726
+ ]);
727
+ var referralRelationshipSchema = z5.object({
728
+ member: identifier,
729
+ inviter: identifier,
730
+ acceptedAt: amount2,
731
+ suspended: z5.boolean()
732
+ });
733
+ var referralAccountSchema = z5.object({
734
+ id: identifier,
735
+ program: identifier,
736
+ kind: z5.enum(["bonus", "fixed", "milestone"]),
737
+ balance: identifier,
738
+ earned: amount2,
739
+ settled: amount2,
740
+ outstanding: amount2
741
+ });
742
+ var referralSummarySchema = z5.object({
743
+ code: identifier,
744
+ attributed: amount2,
745
+ programs: z5.array(
746
+ z5.object({
747
+ definition: referralDefinitionSchema,
748
+ qualified: amount2,
749
+ milestones: z5.array(
750
+ z5.object({ id: identifier, count: amount2, reached: z5.boolean() })
751
+ )
752
+ })
753
+ ),
754
+ accounts: z5.array(referralAccountSchema)
755
+ });
756
+ var referralHistorySchema = z5.object({
757
+ items: z5.array(
758
+ z5.object({
759
+ id: amount2,
760
+ program: identifier,
761
+ balance: identifier,
762
+ amount: z5.number().int().safe(),
763
+ at: amount2,
764
+ reason: z5.string()
765
+ })
766
+ ),
767
+ nextCursor: pageCursorSchema.nullable()
768
+ });
769
+ var referralManagementSchema = z5.object({
770
+ relationships: z5.array(referralRelationshipSchema),
771
+ qualifications: z5.array(
772
+ z5.object({
773
+ member: identifier,
774
+ program: identifier,
775
+ qualified: z5.boolean(),
776
+ qualifiedAt: amount2
777
+ })
778
+ ),
779
+ accounts: z5.array(
780
+ referralAccountSchema.extend({ member: identifier, invitee: z5.string() })
781
+ ),
782
+ reviews: z5.array(
783
+ z5.object({
784
+ entitlement: identifier,
785
+ member: identifier,
786
+ program: identifier,
787
+ reason: z5.string()
788
+ })
789
+ ),
790
+ nextCursor: pageCursorSchema.nullable().default(null),
791
+ /** @deprecated Use `nextCursor`, passed back as `cursor`. Removed in 2.0.0. */
792
+ next: amount2.nullable()
793
+ });
794
+
795
+ // src/offers.ts
796
+ import { z as z6 } from "zod";
797
+ var quantity = z6.number().int().safe().nonnegative();
798
+ var offerPriceSchema = pointsRewardSchema.extend({
799
+ amount: z6.number().int().positive().max(1e4)
800
+ });
801
+ var offerLimitSchema = z6.object({ perMember: z6.number().int().positive().max(1e4) }).strict();
802
+ var offerDefinitionSchema = z6.object({
803
+ id: identifier,
804
+ key: identifier.optional(),
805
+ title: z6.string().trim().min(1).max(120),
806
+ price: offerPriceSchema,
807
+ reward: tierRewardSchema,
808
+ stock: quantity.max(1e6),
809
+ limit: offerLimitSchema.default({ perMember: 1 }),
810
+ enabled: z6.boolean().default(true)
811
+ }).strict();
812
+ var offerAuthoringSchema = offerDefinitionSchema.omit({ id: true, title: true, enabled: true }).extend({
813
+ ...authoringIdentityShape,
814
+ title: z6.string().trim().min(1).max(120).optional()
815
+ }).strict().transform((offer) => ({
816
+ ...offer,
817
+ title: offer.title ?? offer.reward.reward.title,
818
+ enabled: true
819
+ }));
820
+ var offerArtifactSchema = z6.union([
821
+ offerAuthoringSchema,
822
+ z6.object({ code: z6.string().min(1).max(2e6) }).strict()
823
+ ]);
824
+ var offerAvailabilitySchema = responseShape(
825
+ z6.discriminatedUnion("kind", [
826
+ z6.object({ kind: z6.literal("available"), remaining: quantity }).strict(),
827
+ z6.object({ kind: z6.literal("out-of-stock") }).strict(),
828
+ z6.object({ kind: z6.literal("limit-reached") }).strict(),
829
+ z6.object({ kind: z6.literal("paused") }).strict()
830
+ ])
831
+ );
832
+ var offerSchema = responseShape(
833
+ offerDefinitionSchema.extend({
834
+ revision: z6.number().int().positive(),
835
+ available: quantity,
836
+ redeemed: quantity,
837
+ availability: offerAvailabilitySchema
838
+ })
839
+ );
840
+ var redeemOfferSchema = z6.object({ actionId: identifier }).strict();
841
+ var redemptionBase = {
842
+ id: identifier,
843
+ offer: identifier,
844
+ member: identifier,
845
+ /**
846
+ * @deprecated Use `id` to refer to a redemption. A redemption is fulfilled in the request that
847
+ * makes it, so nothing is reserved beforehand; the ID refers to no other record. Removed in
848
+ * 2.0.0.
849
+ */
850
+ reservation: identifier,
851
+ price: offerPriceSchema,
852
+ reward: tierRewardSchema,
853
+ entitlement: identifier,
854
+ revision: z6.number().int().positive(),
855
+ redeemedAt: z6.number().int().safe().nonnegative()
856
+ };
857
+ var redemptionSchema = responseShape(
858
+ z6.discriminatedUnion("status", [
859
+ z6.object({ ...redemptionBase, status: z6.literal("fulfilled") }).strict(),
860
+ z6.object({
861
+ ...redemptionBase,
862
+ status: z6.literal("canceled"),
863
+ canceledAt: z6.number().int().safe().nonnegative(),
864
+ reason: z6.string().min(1).max(500)
865
+ }).strict()
866
+ ])
867
+ );
868
+ var offerControlSchema = z6.object({
869
+ actionId: identifier,
870
+ revision: z6.number().int().positive(),
871
+ enabled: z6.boolean(),
872
+ reason: z6.string().trim().min(1).max(500)
873
+ }).strict();
874
+ var redemptionCancellationSchema = z6.object({
875
+ actionId: identifier,
876
+ revision: z6.number().int().positive(),
877
+ reason: z6.string().trim().min(1).max(500)
878
+ }).strict();
879
+ function defineOffer(input) {
880
+ return resourceHandle("offer", offerAuthoringSchema.parse(input));
881
+ }
882
+
883
+ export {
884
+ pointLedgerPropertiesSchema,
885
+ createPointLedgerSchema,
886
+ pointLedgerSchema,
887
+ managedPointLedgerSchema,
888
+ pointLedgerDeclarationSchema,
889
+ pointLedgerArtifactSchema,
890
+ pointLedgerReferenceSchema,
891
+ pointBalanceSchema,
892
+ pointBalancesSchema,
893
+ PointEntryKind,
894
+ pointEntrySchema,
895
+ pointHistoryQuerySchema,
896
+ pointHistoryPageSchema,
897
+ engagementBudgetSchema,
898
+ engagementDefinitionSchema,
899
+ engagementScoreInputSchema,
900
+ engagementScoreSchema,
901
+ engagementPublishSchema,
902
+ engagementRuleSchema,
903
+ engagementPageQuerySchema,
904
+ engagementSettlementSchema,
905
+ engagementPageSchema,
906
+ engagementChangePreviewInputSchema,
907
+ engagementChangeSchema,
908
+ engagementChangePreviewSchema,
909
+ engagementRuleVersionPageSchema,
910
+ engagementVersionPageSchema,
911
+ engagementVersionQuerySchema,
912
+ engagementBoundaryPageSchema,
913
+ engagementArtifactSchema,
914
+ engagementDeploymentEntrySchema,
915
+ profileVisibilitySchema,
916
+ avatarProviderSchema,
917
+ profileDefaultProviderSchema,
918
+ profileDefaultsSchema,
919
+ avatarSeedSchema,
920
+ profileAvatarSchema,
921
+ profileSummarySchema,
922
+ displayNameSchema,
923
+ profileUpdateSchema,
924
+ ownProfileSchema,
925
+ profileCompletionQuerySchema,
926
+ profileCompletionSchema,
927
+ profileCompletionPageSchema,
928
+ profileReferralSchema,
929
+ profileSettingsSchema,
930
+ profileSettingsInputSchema,
931
+ profileModerationSchema,
932
+ managedProfileSchema,
933
+ AVATAR_UPLOAD_LIMIT,
934
+ avatarUploadTypes,
935
+ leaderboardWindowSchema,
936
+ leaderboardPrizeRewardSchema,
937
+ leaderboardPrizeSchema,
938
+ leaderboardSettlementPolicySchema,
939
+ leaderboardDefinitionSchema,
940
+ leaderboardDefinitionResponseSchema,
941
+ leaderboardAuthoringSchema,
942
+ leaderboardArtifactSchema,
943
+ publishedLeaderboardSchema,
944
+ leaderboardQuerySchema,
945
+ leaderboardRowSchema,
946
+ leaderboardPageSchema,
947
+ leaderboardPlacementSchema,
948
+ leaderboardPreviewSchema,
949
+ pointsMutationSchema,
950
+ pointsEntrySchema,
951
+ managedPointHistoryPageSchema,
952
+ pointsResultSchema,
953
+ pointsAccountSchema,
954
+ leaderboardExclusionSchema,
955
+ leaderboardGroupSchema,
956
+ leaderboardSettlementStatusSchema,
957
+ leaderboardSettlementSummarySchema,
958
+ leaderboardSettlementRowSchema,
959
+ leaderboardSettlementSchema,
960
+ leaderboardSettlementApprovalSchema,
961
+ referralDefinitionSchema,
962
+ referralAuthoringSchema,
963
+ referralArtifactSchema,
964
+ publishedReferralSchema,
965
+ referralAcceptSchema,
966
+ referralSuspensionSchema,
967
+ referralQualificationSchema,
968
+ referralRewardResolutionSchema,
969
+ referralControlSchema,
970
+ referralRelationshipSchema,
971
+ referralAccountSchema,
972
+ referralSummarySchema,
973
+ referralHistorySchema,
974
+ referralManagementSchema,
975
+ offerPriceSchema,
976
+ offerLimitSchema,
977
+ offerDefinitionSchema,
978
+ offerAuthoringSchema,
979
+ offerArtifactSchema,
980
+ offerAvailabilitySchema,
981
+ offerSchema,
982
+ redeemOfferSchema,
983
+ redemptionSchema,
984
+ offerControlSchema,
985
+ redemptionCancellationSchema,
986
+ defineOffer
987
+ };