@domino-sdk/relay 1.0.0-next.2 → 1.0.0-next.34

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 (61) hide show
  1. package/README.md +13 -1
  2. package/build.mjs +18 -1
  3. package/dist/activity-B8k9Sa_a.d.ts +9112 -0
  4. package/dist/authoring.d.ts +1355 -182
  5. package/dist/authoring.js +658 -225
  6. package/dist/automatic-outcomes-B1xrETxm.d.ts +758 -0
  7. package/dist/avatar.d.ts +29 -0
  8. package/dist/avatar.js +21 -0
  9. package/dist/browser-J7tUpXxy.d.ts +4154 -0
  10. package/dist/browser.d.ts +11 -4580
  11. package/dist/browser.js +8 -6
  12. package/dist/capability-error-DNMwKmlL.d.ts +458 -0
  13. package/dist/chunk-36HTX2BM.js +1223 -0
  14. package/dist/chunk-6QJ3LADK.js +112 -0
  15. package/dist/chunk-BGGKNIRP.js +171 -0
  16. package/dist/chunk-EYH5RDIE.js +496 -0
  17. package/dist/chunk-GQKYAQM6.js +84 -0
  18. package/dist/chunk-GUP7YRR4.js +42 -0
  19. package/dist/chunk-GZ6FJAXN.js +1659 -0
  20. package/dist/chunk-JON5SESL.js +2986 -0
  21. package/dist/chunk-MC6V6VMG.js +49 -0
  22. package/dist/chunk-NPGENI7K.js +37 -0
  23. package/dist/chunk-V7UKZLHA.js +35 -0
  24. package/dist/chunk-VFHHLN6A.js +284 -0
  25. package/dist/chunk-WJSSJ7AF.js +151 -0
  26. package/dist/{chunk-VH4OQ5VX.js → chunk-XFMSUPNS.js} +26 -5
  27. package/dist/{chunk-FDWRBMB3.js → chunk-ZVIRG24J.js} +150 -33
  28. package/dist/client-XiuFnug_.d.ts +4262 -0
  29. package/dist/groups-Ck-OxzjD.d.ts +2449 -0
  30. package/dist/identity-integration-GxAHdKR2.d.ts +58 -0
  31. package/dist/images-Dv-P5VBw.d.ts +234 -0
  32. package/dist/index.d.ts +15 -13115
  33. package/dist/index.js +30 -689
  34. package/dist/internal.d.ts +159 -0
  35. package/dist/internal.js +79 -0
  36. package/dist/offers-Cy-e4o5x.d.ts +431 -0
  37. package/dist/outcomes-kVB-Juzs.d.ts +4902 -0
  38. package/dist/pages-BBYD21IE.d.ts +359 -0
  39. package/dist/participant-rewards-3duLb8YJ.d.ts +668 -0
  40. package/dist/portal-proxy.js +26 -9
  41. package/dist/profiles-D2aFcOxu.d.ts +297 -0
  42. package/dist/react/index.d.ts +3378 -3318
  43. package/dist/react/index.js +1635 -783
  44. package/dist/request-error-DWduJCGV.d.ts +62 -0
  45. package/dist/schema-DfJzH2ci.d.ts +5644 -0
  46. package/dist/schema.d.ts +15 -3388
  47. package/dist/schema.js +790 -3
  48. package/dist/server/index.d.ts +81498 -0
  49. package/dist/server/index.js +2520 -0
  50. package/dist/streaks-CWyq8Px5.d.ts +71 -0
  51. package/dist/submission-input-BZkm6ohU.d.ts +290 -0
  52. package/dist/units-CwgsPB_r.d.ts +9 -0
  53. package/dist/vite.d.ts +1 -1
  54. package/dist/vite.js +1 -0
  55. package/dist/wallet-YssWxGg8.d.ts +228 -0
  56. package/package.json +24 -5
  57. package/dist/chunk-4KNTMNXA.js +0 -1847
  58. package/dist/chunk-B76BAJ25.js +0 -624
  59. package/dist/chunk-NKGJEYZM.js +0 -1833
  60. package/dist/chunk-ONDBQSMU.js +0 -373
  61. package/dist/submission-input-JDwq3EVK.d.ts +0 -4986
@@ -0,0 +1,496 @@
1
+ import {
2
+ pointLedgerReferenceSchema
3
+ } from "./chunk-36HTX2BM.js";
4
+ import {
5
+ authoringIdentityShape,
6
+ entitlementSchema,
7
+ identifier,
8
+ memberProgressSchema,
9
+ pageCursorSchema,
10
+ pickupAvailabilitySchema,
11
+ pickupSelectionSchema,
12
+ prerequisiteSchema,
13
+ publishedReleaseSchema,
14
+ reviewModeSchema,
15
+ settingsValuesSchema,
16
+ storedQuestDescriptionSchema,
17
+ storedReviewModeSchema,
18
+ tieredRewardReferenceSchema
19
+ } from "./chunk-JON5SESL.js";
20
+
21
+ // src/participant-activity.ts
22
+ import { z } from "zod";
23
+ var base = { id: z.string(), at: z.number() };
24
+ var attempt = {
25
+ ...base,
26
+ quest: z.string(),
27
+ attempt: z.string(),
28
+ completion: z.string().nullable()
29
+ };
30
+ var kinds = [
31
+ "attempt.accepted",
32
+ "attempt.rejected",
33
+ "attempt.review",
34
+ "points.awarded",
35
+ "entitlement.granted",
36
+ "entitlement.collected",
37
+ "delivery.updated",
38
+ "referral.qualified"
39
+ ];
40
+ var knownRelayEventSchema = z.discriminatedUnion("kind", [
41
+ z.object({ ...attempt, kind: z.literal("attempt.accepted") }),
42
+ z.object({ ...attempt, kind: z.literal("attempt.rejected") }),
43
+ z.object({ ...attempt, kind: z.literal("attempt.review") }),
44
+ z.object({
45
+ ...base,
46
+ kind: z.literal("points.awarded"),
47
+ entry: z.string(),
48
+ ledger: z.string(),
49
+ amount: z.number(),
50
+ quest: z.string().nullable(),
51
+ completion: z.string().nullable()
52
+ }),
53
+ z.object({
54
+ ...base,
55
+ kind: z.literal("entitlement.granted"),
56
+ entitlement: z.string(),
57
+ tier: z.string(),
58
+ status: z.string()
59
+ }),
60
+ z.object({
61
+ ...base,
62
+ kind: z.literal("entitlement.collected"),
63
+ entitlement: z.string()
64
+ }),
65
+ z.object({
66
+ ...base,
67
+ kind: z.literal("delivery.updated"),
68
+ delivery: z.string(),
69
+ quest: z.string(),
70
+ completion: z.string(),
71
+ status: z.string()
72
+ }),
73
+ z.object({
74
+ ...base,
75
+ kind: z.literal("referral.qualified"),
76
+ program: z.string()
77
+ })
78
+ ]);
79
+ var relayEventSchema = z.union([
80
+ knownRelayEventSchema,
81
+ z.object({
82
+ ...base,
83
+ kind: z.string().refine((kind) => !kinds.includes(kind))
84
+ }).catchall(z.json()).transform(({ kind, ...event }) => ({
85
+ ...event,
86
+ kind: "unknown",
87
+ reportedKind: kind
88
+ }))
89
+ ]);
90
+ var participantActivityQuerySchema = z.object({
91
+ cursor: pageCursorSchema.optional(),
92
+ limit: z.number().int().min(1).max(100).default(50)
93
+ }).strict();
94
+ var participantActivitySchema = z.object({
95
+ member: z.string(),
96
+ items: z.array(relayEventSchema),
97
+ nextCursor: pageCursorSchema
98
+ });
99
+
100
+ // src/catalog.ts
101
+ import { z as z2 } from "zod";
102
+ var interactionSchema = z2.enum([
103
+ "photo",
104
+ "text",
105
+ "url",
106
+ "quiz",
107
+ "claim",
108
+ "staff",
109
+ "automatic"
110
+ ]);
111
+ function questInteraction(trigger) {
112
+ return trigger.kind === "automatic" ? "automatic" : trigger.actor === "staff" ? "staff" : trigger.input === "none" ? "claim" : trigger.input;
113
+ }
114
+ var questTypeVersionSchema = z2.object({
115
+ archivedAt: z2.number().int().nonnegative().nullable().optional(),
116
+ key: identifier.optional(),
117
+ id: identifier,
118
+ version: identifier,
119
+ code: z2.string(),
120
+ definition: storedQuestDescriptionSchema,
121
+ provider: storedReviewModeSchema,
122
+ createdAt: z2.number()
123
+ });
124
+ var collectionSlotSchema = z2.object({
125
+ archivedAt: z2.number().int().nonnegative().nullable().optional(),
126
+ id: identifier,
127
+ key: identifier.optional(),
128
+ title: z2.string().trim().min(1).max(120)
129
+ }).strict();
130
+ var collectionSlotDeclarationSchema = collectionSlotSchema.omit({ id: true, archivedAt: true }).extend(authoringIdentityShape).strict();
131
+ var questCollectionSchema = collectionSlotSchema.extend({
132
+ quests: z2.array(identifier).max(100).refine(
133
+ (v) => new Set(v).size === v.length,
134
+ "A collection can contain a quest only once"
135
+ )
136
+ });
137
+ var questInstanceSchema = z2.object({
138
+ id: identifier,
139
+ title: z2.string().trim().min(1).max(120),
140
+ typeVersion: identifier,
141
+ settings: settingsValuesSchema,
142
+ requires: z2.array(prerequisiteSchema).max(30),
143
+ status: z2.enum(["active", "paused", "archived"])
144
+ }).strict();
145
+ var questDraftChangesSchema = z2.object({
146
+ quests: z2.array(
147
+ questInstanceSchema.extend({ expectedRelease: identifier.nullable() })
148
+ ).max(50),
149
+ collections: z2.array(questCollectionSchema.omit({ archivedAt: true })).max(50)
150
+ }).strict();
151
+ var draftBase = z2.object({
152
+ id: identifier,
153
+ revision: z2.number().int().positive(),
154
+ baseRevision: z2.number().int().nonnegative(),
155
+ changes: questDraftChangesSchema
156
+ });
157
+ var questDraftSchema = z2.discriminatedUnion("status", [
158
+ draftBase.extend({ status: z2.literal("draft") }),
159
+ draftBase.extend({
160
+ status: z2.literal("published"),
161
+ releaseIds: z2.array(identifier)
162
+ })
163
+ ]);
164
+ var questCatalogSchema = z2.object({
165
+ revision: z2.number().int().nonnegative(),
166
+ types: z2.array(questTypeVersionSchema),
167
+ collections: z2.array(questCollectionSchema),
168
+ quests: z2.array(questInstanceSchema),
169
+ drafts: z2.array(questDraftSchema),
170
+ releases: z2.array(publishedReleaseSchema).default([]),
171
+ supportedInteractions: z2.array(interactionSchema)
172
+ });
173
+ var catalogDeploymentSchema = z2.object({
174
+ expectedRevision: z2.number().int().nonnegative(),
175
+ types: z2.array(
176
+ z2.object({
177
+ code: z2.string().min(1).max(1e6),
178
+ provider: reviewModeSchema
179
+ })
180
+ ).max(50).default([]),
181
+ collections: z2.array(collectionSlotDeclarationSchema).max(50).default([]),
182
+ supportedInteractions: z2.array(interactionSchema).min(1).optional()
183
+ }).strict();
184
+ var catalogDeploymentPreviewSchema = z2.object({
185
+ revision: z2.number().int().nonnegative(),
186
+ types: z2.array(questTypeVersionSchema),
187
+ collections: z2.array(collectionSlotSchema),
188
+ supportedInteractions: z2.array(interactionSchema)
189
+ });
190
+ var saveQuestDraftSchema = z2.object({
191
+ id: identifier.optional(),
192
+ actionId: identifier,
193
+ expectedRevision: z2.number().int().nonnegative(),
194
+ baseRevision: z2.number().int().nonnegative(),
195
+ changes: questDraftChangesSchema
196
+ }).strict();
197
+ var publishQuestDraftSchema = z2.object({ id: identifier, expectedRevision: z2.number().int().positive() }).strict();
198
+ var questRewardViewSchema = z2.discriminatedUnion("kind", [
199
+ z2.object({
200
+ kind: z2.literal("points"),
201
+ label: z2.string(),
202
+ amount: z2.number().int().nonnegative(),
203
+ ledger: pointLedgerReferenceSchema
204
+ }),
205
+ z2.object({
206
+ kind: z2.literal("tier"),
207
+ label: z2.string(),
208
+ reward: tieredRewardReferenceSchema.extend({ title: z2.string() }),
209
+ tier: identifier
210
+ }),
211
+ z2.object({ kind: z2.literal("integration"), label: z2.string() })
212
+ ]);
213
+ var questViewSchema = memberProgressSchema.shape.quests.element.extend(
214
+ {
215
+ release: identifier,
216
+ interaction: interactionSchema,
217
+ lifecycle: z2.enum(["active", "paused", "archived"]),
218
+ rewards: z2.array(questRewardViewSchema)
219
+ }
220
+ );
221
+ var collectionViewSchema = z2.object({
222
+ key: identifier.optional(),
223
+ id: identifier,
224
+ title: z2.string(),
225
+ quests: z2.array(questViewSchema)
226
+ });
227
+ var questExperienceSchema = z2.object({
228
+ entitlements: z2.array(entitlementSchema).default([]),
229
+ member: identifier,
230
+ quests: z2.array(questViewSchema),
231
+ collections: z2.array(collectionViewSchema)
232
+ });
233
+ var questPublicationPreviewSchema = z2.object({
234
+ draft: questDraftSchema,
235
+ releases: z2.array(publishedReleaseSchema),
236
+ affectedCollections: z2.array(questCollectionSchema)
237
+ });
238
+ var allocateQuestSchema = z2.object({ actionId: identifier }).strict();
239
+ var allocatedQuestSchema = z2.object({ id: identifier });
240
+
241
+ // src/collection.ts
242
+ import { z as z3 } from "zod";
243
+ var collectionCodeSchema = z3.string().regex(/^relay:collect:[a-f0-9]{64}$/);
244
+ var collectionPassSchema = z3.object({
245
+ code: collectionCodeSchema,
246
+ expiresAt: z3.number(),
247
+ entitlement: identifier
248
+ });
249
+ var collectionResolveSchema = z3.object({ code: collectionCodeSchema }).strict();
250
+ var collectionBeginSchema = collectionResolveSchema.extend({
251
+ actionId: identifier,
252
+ revision: z3.number().int().positive(),
253
+ selection: pickupSelectionSchema.optional()
254
+ });
255
+ var collectionPreviewSchema = z3.object({
256
+ entitlement: entitlementSchema,
257
+ inventory: pickupAvailabilitySchema,
258
+ expiresAt: z3.number()
259
+ });
260
+
261
+ // src/outcomes.ts
262
+ import { z as z4 } from "zod";
263
+ var timestamp = z4.number().int().safe().nonnegative();
264
+ var questEnrollmentInputSchema = z4.strictObject({
265
+ actionId: identifier,
266
+ /** Quest key or ID. */
267
+ quest: identifier
268
+ });
269
+ var memberEnrollmentInputSchema = questEnrollmentInputSchema.extend({
270
+ member: identifier
271
+ });
272
+ var questEnrollmentSchema = z4.object({
273
+ /** Stable quest ID. */
274
+ quest: identifier,
275
+ member: identifier,
276
+ enrolledAt: timestamp
277
+ });
278
+ var questClaimInputSchema = z4.strictObject({
279
+ actionId: identifier,
280
+ /** Quest key or ID. */
281
+ quest: identifier,
282
+ /** The outcome's tracker, as `QuestOutcome.tracker` names it. */
283
+ tracker: identifier,
284
+ record: z4.string().min(1).max(256),
285
+ observedAt: timestamp
286
+ });
287
+ var QuestOutcomeState = {
288
+ Admitted: "admitted",
289
+ Skipped: "skipped"
290
+ };
291
+ var questOutcomeSchema = z4.object({
292
+ /** Prerequisite transition identity; absent on older tracker responses. */
293
+ automatic: identifier.optional(),
294
+ /** Stable quest ID. */
295
+ quest: identifier,
296
+ /** Stable tracker ID of the record decided. */
297
+ tracker: identifier.nullable(),
298
+ /** The record's ID in its tracker. */
299
+ record: z4.string().nullable(),
300
+ /** Which observation of the record was decided. */
301
+ observedAt: timestamp.nullable(),
302
+ state: z4.enum(["admitted", "skipped"]),
303
+ /**
304
+ * Why it was skipped, one of `trackerSkipCodes` or a code a newer Relay sends; null when
305
+ * admitted. Show an unknown code by its `reason`.
306
+ */
307
+ code: z4.string().nullable(),
308
+ /** Why it was skipped, for people; null when admitted. */
309
+ reason: z4.string().nullable(),
310
+ /** The admitted attempt. */
311
+ attempt: identifier.nullable(),
312
+ /** The member can claim it with `relay.quests.claim()`. */
313
+ claimable: z4.boolean(),
314
+ createdAt: timestamp,
315
+ updatedAt: timestamp
316
+ });
317
+ var questOutcomeQuerySchema = z4.strictObject({
318
+ /** Quest key or ID. */
319
+ quest: identifier.optional(),
320
+ state: z4.enum(["admitted", "skipped"]).optional(),
321
+ /** Only skips with this code, such as `historical`. */
322
+ code: z4.string().min(1).max(100).optional(),
323
+ cursor: pageCursorSchema.optional()
324
+ });
325
+ var questOutcomePageSchema = z4.object({
326
+ items: z4.array(questOutcomeSchema),
327
+ nextCursor: pageCursorSchema.nullable()
328
+ });
329
+
330
+ // src/participant-rewards.ts
331
+ import { z as z5 } from "zod";
332
+ var participantEntitlementsSchema = z5.object({
333
+ items: z5.array(entitlementSchema)
334
+ });
335
+ var base2 = {
336
+ id: z5.string(),
337
+ status: z5.string(),
338
+ at: z5.number().nullable(),
339
+ quest: z5.string().nullable(),
340
+ completion: z5.string().nullable()
341
+ };
342
+ var known = z5.discriminatedUnion("kind", [
343
+ z5.object({
344
+ ...base2,
345
+ kind: z5.literal("points"),
346
+ ledger: pointLedgerReferenceSchema,
347
+ amount: z5.number(),
348
+ reversed: z5.number()
349
+ }).catchall(z5.json()),
350
+ z5.object({
351
+ ...base2,
352
+ kind: z5.literal("tier"),
353
+ entitlement: entitlementSchema
354
+ }).catchall(z5.json().transform((value) => value)),
355
+ z5.object({
356
+ ...base2,
357
+ kind: z5.literal("integration"),
358
+ provider: z5.string(),
359
+ action: z5.string(),
360
+ roleId: z5.string().optional(),
361
+ deliveredAt: z5.number().nullable(),
362
+ revokedAt: z5.number().nullable(),
363
+ reconciliation: z5.object({ status: z5.string(), ownership: z5.string(), at: z5.number() }).catchall(z5.json()).nullable()
364
+ }).catchall(z5.json().optional())
365
+ ]);
366
+ var participantDeliverySchema = z5.union([
367
+ known,
368
+ z5.object({
369
+ ...base2,
370
+ kind: z5.string().refine((kind) => !["points", "tier", "integration"].includes(kind))
371
+ }).catchall(z5.json()).transform(({ kind, ...item }) => ({
372
+ ...item,
373
+ kind: "unknown",
374
+ reportedKind: kind
375
+ }))
376
+ ]);
377
+ var participantDeliveriesSchema = z5.object({
378
+ items: z5.array(participantDeliverySchema)
379
+ });
380
+
381
+ // src/reward-deliveries.ts
382
+ import { z as z6 } from "zod";
383
+ var RewardDeliveryAction = {
384
+ /** Delivers a quest's Discord role reward. */
385
+ GrantRole: "grant-role"
386
+ };
387
+ var rewardDeliveryActionSchema = z6.string().min(1).max(64);
388
+ var roleReconciliationSchema = z6.object({
389
+ status: z6.enum(["pending", "granted", "removed", "preserved", "failed"]),
390
+ ownership: z6.enum(["unclaimed", "relay", "external"]),
391
+ at: z6.number(),
392
+ reason: z6.string().nullable()
393
+ });
394
+ var knownRewardDeliverySchema = z6.object({
395
+ id: z6.string(),
396
+ quest: z6.string(),
397
+ completion: z6.string(),
398
+ member: z6.string(),
399
+ provider: z6.literal("discord"),
400
+ /** `RewardDeliveryAction`, such as `grant-role`. */
401
+ action: rewardDeliveryActionSchema,
402
+ roleId: z6.string(),
403
+ /**
404
+ * `failed` is terminal: Discord rejected the grant permanently (unknown role,
405
+ * member left the server, missing permissions) or retries ran out after about
406
+ * a day. An operator can retry it once the cause is fixed, unless revokedAt is set.
407
+ * Revoke stops pending grants; a late success records deliveredAt but leaves status failed.
408
+ */
409
+ status: z6.enum(["pending", "delivered", "failed"]),
410
+ /** Provider attempts in the current round; an operator retry starts a new round at zero. */
411
+ attempts: z6.number().int(),
412
+ /** While pending with a `lastError`, when the next attempt is scheduled. */
413
+ nextAt: z6.number(),
414
+ lastError: z6.string().nullable(),
415
+ createdAt: z6.number(),
416
+ deliveredAt: z6.number().nullable(),
417
+ /** First dispatch attempt, retained across retries. Legacy rows use creation time when dispatch timing is unknown. */
418
+ dispatchedAt: z6.number().nullable().optional(),
419
+ /** Completion revocation stops retries, including deliveries that had already failed. */
420
+ revokedAt: z6.number().nullable().optional(),
421
+ /** Current reconciliation of the pinned Discord membership; original delivery and revoke history stay intact. */
422
+ reconciliation: roleReconciliationSchema.nullable().optional()
423
+ });
424
+ var futureRewardDeliverySchema = knownRewardDeliverySchema.extend({
425
+ provider: z6.string(),
426
+ status: z6.string(),
427
+ roleId: z6.string().optional(),
428
+ reconciliation: z6.object({
429
+ status: z6.string(),
430
+ ownership: z6.string(),
431
+ at: z6.number(),
432
+ reason: z6.string().nullable()
433
+ }).catchall(z6.json()).nullable().optional()
434
+ }).catchall(z6.json().optional()).refine(
435
+ (delivery) => delivery.provider !== "discord" || !["pending", "delivered", "failed"].includes(delivery.status) || delivery.reconciliation && (!["pending", "granted", "removed", "preserved", "failed"].includes(
436
+ delivery.reconciliation.status
437
+ ) || !["unclaimed", "relay", "external"].includes(
438
+ delivery.reconciliation.ownership
439
+ ))
440
+ );
441
+ var rewardDeliverySchema = z6.union([
442
+ knownRewardDeliverySchema.catchall(z6.json().optional()),
443
+ futureRewardDeliverySchema
444
+ ]);
445
+ var rewardDeliveriesSchema = z6.object({
446
+ deliveries: z6.array(rewardDeliverySchema)
447
+ });
448
+
449
+ export {
450
+ knownRelayEventSchema,
451
+ relayEventSchema,
452
+ participantActivityQuerySchema,
453
+ participantActivitySchema,
454
+ interactionSchema,
455
+ questInteraction,
456
+ questTypeVersionSchema,
457
+ collectionSlotSchema,
458
+ collectionSlotDeclarationSchema,
459
+ questCollectionSchema,
460
+ questInstanceSchema,
461
+ questDraftChangesSchema,
462
+ questDraftSchema,
463
+ questCatalogSchema,
464
+ catalogDeploymentSchema,
465
+ catalogDeploymentPreviewSchema,
466
+ saveQuestDraftSchema,
467
+ publishQuestDraftSchema,
468
+ questRewardViewSchema,
469
+ questViewSchema,
470
+ collectionViewSchema,
471
+ questExperienceSchema,
472
+ questPublicationPreviewSchema,
473
+ allocateQuestSchema,
474
+ allocatedQuestSchema,
475
+ collectionCodeSchema,
476
+ collectionPassSchema,
477
+ collectionResolveSchema,
478
+ collectionBeginSchema,
479
+ collectionPreviewSchema,
480
+ questEnrollmentInputSchema,
481
+ memberEnrollmentInputSchema,
482
+ questEnrollmentSchema,
483
+ questClaimInputSchema,
484
+ QuestOutcomeState,
485
+ questOutcomeSchema,
486
+ questOutcomeQuerySchema,
487
+ questOutcomePageSchema,
488
+ participantEntitlementsSchema,
489
+ participantDeliverySchema,
490
+ participantDeliveriesSchema,
491
+ RewardDeliveryAction,
492
+ roleReconciliationSchema,
493
+ knownRewardDeliverySchema,
494
+ rewardDeliverySchema,
495
+ rewardDeliveriesSchema
496
+ };
@@ -0,0 +1,84 @@
1
+ import {
2
+ discordMessageDataSchema,
3
+ discordMessageTextDataSchema,
4
+ discordReactionDataSchema,
5
+ isKnownTrackerSource,
6
+ trackerDataSchema,
7
+ xAccountRoles
8
+ } from "./chunk-JON5SESL.js";
9
+
10
+ // src/quest-shape.ts
11
+ function validateQuestShape(description, options = {}) {
12
+ const { trigger, completion, requires, performance } = description;
13
+ const tracker = trigger.kind === "automatic" ? trigger.tracker : void 0;
14
+ const content = tracker?.content === true;
15
+ if (performance && !content) {
16
+ throw new Error("Performance requires a content quest");
17
+ }
18
+ if (content) {
19
+ if (completion.kind !== "keyed") {
20
+ throw new Error("Content quests complete once per content item");
21
+ }
22
+ if (tracker.beneficiary !== "author" || tracker.on !== "new-record") {
23
+ throw new Error(
24
+ "A content quest pays each content item's author and fires on its first observation"
25
+ );
26
+ }
27
+ }
28
+ if (trigger.kind === "automatic" && !tracker) {
29
+ if (!options.template && requires.length === 0) {
30
+ throw new Error("Automatic quests need at least one prerequisite");
31
+ }
32
+ if (completion.kind !== "once") {
33
+ throw new Error("Prerequisite-only automatic quests complete once");
34
+ }
35
+ }
36
+ }
37
+
38
+ // src/tracker-sources.ts
39
+ var discordMessageRoles = ["author"];
40
+ var discordReactionRoles = ["author", "messageAuthor"];
41
+ function sourceRoles(source) {
42
+ if (!isKnownTrackerSource(source)) {
43
+ return [];
44
+ }
45
+ switch (source.kind) {
46
+ case "x-search":
47
+ return xAccountRoles;
48
+ case "discord-messages":
49
+ return discordMessageRoles;
50
+ case "discord-reactions":
51
+ return discordReactionRoles;
52
+ case "custom":
53
+ return ["author", ...source.accounts ?? []];
54
+ }
55
+ }
56
+ var discordSchemas = /* @__PURE__ */ new Map();
57
+ function discordDataSchema(source) {
58
+ const key = source.kind === "discord-messages" && source.text ? "messages-text" : source.kind;
59
+ let schema = discordSchemas.get(key);
60
+ if (!schema) {
61
+ schema = trackerDataSchema(
62
+ key === "messages-text" ? discordMessageTextDataSchema : key === "discord-messages" ? discordMessageDataSchema : discordReactionDataSchema
63
+ );
64
+ discordSchemas.set(key, schema);
65
+ }
66
+ return schema;
67
+ }
68
+ function sourceDataSchema(source) {
69
+ switch (source.kind) {
70
+ case "x-search":
71
+ return void 0;
72
+ case "discord-messages":
73
+ case "discord-reactions":
74
+ return discordDataSchema(source);
75
+ case "custom":
76
+ return source.data;
77
+ }
78
+ }
79
+
80
+ export {
81
+ validateQuestShape,
82
+ sourceRoles,
83
+ sourceDataSchema
84
+ };
@@ -0,0 +1,42 @@
1
+ // src/participant-routes.ts
2
+ function isActivityParticipantRoute(path, method) {
3
+ return path === "/v1/me/activity" && method === "GET";
4
+ }
5
+ function isRewardsParticipantRoute(path, method) {
6
+ return method === "GET" && ["/v1/me/entitlements", "/v1/me/deliveries"].includes(path);
7
+ }
8
+ function isContentParticipantRoute(path, method) {
9
+ return method === "GET" && (path === "/v1/content/qualifications" || path === "/v1/content/performance" || path === "/v1/engagement/history" || path === "/v1/engagement/boundaries");
10
+ }
11
+ function isQuestOutcomeParticipantRoute(path, method) {
12
+ return method === "GET" && path === "/v1/quests/outcomes" || method === "POST" && (path === "/v1/quests/enrollments" || path === "/v1/campaigns/enrollments" || path === "/v1/campaigns/enrollments/withdraw" || path === "/v1/quests/claims");
13
+ }
14
+ function isPointsParticipantRoute(path, method) {
15
+ return method === "GET" && /^\/v1\/me\/points(?:\/[\w-]+\/history)?$/.test(path);
16
+ }
17
+ function isOfferParticipantRoute(path, method) {
18
+ return path === "/v1/offers" && method === "GET" || /^\/v1\/offers\/[\w-]+\/redeem$/.test(path) && method === "POST";
19
+ }
20
+ function isProfileParticipantRoute(path, method) {
21
+ return method === "GET" && (path === "/v1/me/profile" || /^\/v1\/profiles\/[\w-]+(?:\/completions|\/referrals\/[\w-]+)?$/.test(
22
+ path
23
+ ) || /^\/v1\/leaderboards\/[\w-]+\/profiles\/[\w-]+$/.test(path)) || method === "POST" && (path === "/v1/me/profile" || path === "/v1/me/profile/avatar");
24
+ }
25
+ function isWalletParticipantRoute(path) {
26
+ return /^\/v1\/me\/wallets(?:\/challenge|\/verify|\/unlink)?$/.test(path);
27
+ }
28
+ function isWalletSignInRoute(path) {
29
+ return /^\/v1\/auth\/wallet\/(?:start|verify)$/.test(path);
30
+ }
31
+
32
+ export {
33
+ isActivityParticipantRoute,
34
+ isRewardsParticipantRoute,
35
+ isContentParticipantRoute,
36
+ isQuestOutcomeParticipantRoute,
37
+ isPointsParticipantRoute,
38
+ isOfferParticipantRoute,
39
+ isProfileParticipantRoute,
40
+ isWalletParticipantRoute,
41
+ isWalletSignInRoute
42
+ };