@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.
Files changed (80) hide show
  1. package/CHANGELOG.md +156 -8
  2. package/README.md +3 -2
  3. package/dist/{schema-CZ6Rj0ZF.d.ts → accounts-CCqCKCVx.d.ts} +3127 -1764
  4. package/dist/action-9Xl0StBg.d.ts +33 -0
  5. package/dist/{integrations-B3y36OaB.d.ts → analytics-BwAKLi7O.d.ts} +347 -57
  6. package/dist/{attempt-captures-DYnJVkfg.d.ts → attempt-captures-Cm-5G0PC.d.ts} +1 -1
  7. package/dist/authoring.d.ts +130 -42
  8. package/dist/authoring.js +112 -37
  9. package/dist/{automatic-outcomes-If88LR9f.d.ts → automatic-outcomes-pAsOyIVp.d.ts} +5 -1
  10. package/dist/avatar.d.ts +1 -1
  11. package/dist/browser.d.ts +15 -11
  12. package/dist/browser.js +15 -11
  13. package/dist/{announcements-CHx3-HBw.d.ts → capability-error-DFMwSuSf.d.ts} +161 -4
  14. package/dist/{pages-K7-KjSXw.d.ts → catalog--ZIlskAo.d.ts} +39 -561
  15. package/dist/{chunk-DYXDZFKA.js → chunk-3KLC4AMA.js} +37 -11
  16. package/dist/{chunk-XBV2CK2H.js → chunk-3PYYGFSB.js} +14 -2
  17. package/dist/{chunk-RHBS5FJL.js → chunk-5TEYFX6X.js} +2 -2
  18. package/dist/chunk-6WCIWXUV.js +31 -0
  19. package/dist/chunk-CICDIBOF.js +373 -0
  20. package/dist/{chunk-MHPKEVEW.js → chunk-CZFXGGEK.js} +5 -0
  21. package/dist/chunk-D26YNACF.js +320 -0
  22. package/dist/{chunk-5I54XBK2.js → chunk-E6IKQHTX.js} +2 -2
  23. package/dist/chunk-FWLQ5XCS.js +21 -0
  24. package/dist/{chunk-SKGTNTLF.js → chunk-GKIFABGN.js} +150 -61
  25. package/dist/chunk-GTDW453U.js +522 -0
  26. package/dist/{chunk-VURRFVNP.js → chunk-HTZHBTIL.js} +69 -27
  27. package/dist/chunk-K2KS3JLY.js +188 -0
  28. package/dist/{chunk-ZDJLPN4L.js → chunk-MK425RXJ.js} +3143 -3209
  29. package/dist/{chunk-L77O64I4.js → chunk-QYPMPWVX.js} +1 -1
  30. package/dist/chunk-UAKYDVT3.js +565 -0
  31. package/dist/{chunk-DHXDBAJF.js → chunk-UPQPUJOU.js} +36 -123
  32. package/dist/{chunk-24I4R732.js → chunk-UW5232GG.js} +34 -19
  33. package/dist/chunk-WSBYWVTZ.js +717 -0
  34. package/dist/{chunk-PPB7HALD.js → chunk-XJFYAXET.js} +9 -8
  35. package/dist/{chunk-7A4J67ZL.js → chunk-XNKSSE32.js} +1 -1
  36. package/dist/{chunk-QEAS4ZGS.js → chunk-Y322OTCH.js} +1 -1
  37. package/dist/{client-C51w7fMb.d.ts → client-B-hbHX30.d.ts} +109 -40
  38. package/dist/{deployments-kWoHFaqj.d.ts → deployments-M4OHn7G3.d.ts} +407 -18
  39. package/dist/identity-integration-3mX6b5iH.d.ts +1241 -0
  40. package/dist/index.d.ts +13 -11
  41. package/dist/index.js +14 -11
  42. package/dist/internal.d.ts +14 -12
  43. package/dist/internal.js +26 -14
  44. package/dist/{offers-BoV4ryUc.d.ts → offers-DhAtss4_.d.ts} +21 -4
  45. package/dist/pages-B8q8Y_dQ.d.ts +715 -0
  46. package/dist/{participant-activity-DHL8QYks.d.ts → participant-activity-D-Drp24G.d.ts} +16 -3
  47. package/dist/portal-proxy.d.ts +59 -2
  48. package/dist/portal-proxy.js +109 -23
  49. package/dist/react/index.d.ts +206 -26
  50. package/dist/react/index.js +153 -25
  51. package/dist/{action-DBzILFx9.d.ts → request-error-D_dUPLwo.d.ts} +1 -31
  52. package/dist/runtime/authoring.js +1 -1
  53. package/dist/runtime/chunks/Y4OAVXFR.js +1 -0
  54. package/dist/runtime/manifest.json +3 -3
  55. package/dist/runtime/schema.js +1 -1
  56. package/dist/schema.d.ts +154 -30
  57. package/dist/schema.js +126 -75
  58. package/dist/server/index.d.ts +14 -12
  59. package/dist/server/index.js +2137 -1633
  60. package/dist/sign-in-providers-BkjcDsFF.d.ts +39 -0
  61. package/dist/submission-input-DHGKhXfp.d.ts +342 -0
  62. package/dist/{telegram-browser-BUceZIGZ.d.ts → telegram-browser-BCE7zdOb.d.ts} +46 -6
  63. package/dist/telegram.d.ts +64 -0
  64. package/dist/telegram.js +23 -0
  65. package/dist/testing.d.ts +112 -15
  66. package/dist/testing.js +321 -16
  67. package/dist/tracker-data-Hb1uQnk5.d.ts +1855 -0
  68. package/dist/{transport-BrX9pIGN.d.ts → transport-DkhX2Cbs.d.ts} +5764 -2217
  69. package/dist/{wallet-CIqFoxdm.d.ts → wallet-DTO7SXj7.d.ts} +20 -7
  70. package/package.json +5 -1
  71. package/dist/accounts-DoabriBX.d.ts +0 -306
  72. package/dist/capability-error-DufwG3G0.d.ts +0 -159
  73. package/dist/chunk-3Y3L2F54.js +0 -982
  74. package/dist/chunk-EN3M5Z4J.js +0 -13
  75. package/dist/chunk-QNUHWK7R.js +0 -602
  76. package/dist/chunk-SE4PFJPT.js +0 -247
  77. package/dist/groups-CqcA2Ycs.d.ts +0 -2827
  78. package/dist/runtime/chunks/5QVFB4TU.js +0 -1
  79. package/dist/submission-input-C54Q8yAD.d.ts +0 -146
  80. package/dist/x-D1PGi8Sq.d.ts +0 -331
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  parseDefinition
3
- } from "./chunk-3Y3L2F54.js";
3
+ } from "./chunk-GTDW453U.js";
4
4
  import {
5
5
  identifier,
6
6
  resourceHandle,
7
7
  responseShape
8
- } from "./chunk-ZDJLPN4L.js";
8
+ } from "./chunk-MK425RXJ.js";
9
9
 
10
10
  // src/youtube.ts
11
11
  import * as z from "zod";
@@ -63,20 +63,25 @@ var analyticsRanges = ["7d", "30d", "90d", "all"];
63
63
  var amount = once(() => z3.number().int().safe());
64
64
  var amounts = once(() => z3.array(amount()));
65
65
  var instant = once(() => z3.iso.datetime({ offset: true }));
66
+ var instantMs = once(() => amount().optional());
66
67
  var bucket = once(
67
68
  () => z3.object({
68
69
  /** The period's label in its time zone, such as `2026-10-08@Europe/Budapest` or `2026-W41@UTC`. */
69
70
  key: z3.string(),
70
71
  start: instant(),
71
- end: instant()
72
+ startMs: instantMs(),
73
+ end: instant(),
74
+ endMs: instantMs()
72
75
  })
73
76
  );
74
77
  var range = once(
75
78
  () => z3.object({
76
79
  key: z3.enum(analyticsRanges),
77
80
  from: instant(),
81
+ fromMs: instantMs(),
78
82
  /** Now, by the database's clock, when the read ran. */
79
83
  to: instant(),
84
+ toMs: instantMs(),
80
85
  bucket: z3.enum(["day", "week"]),
81
86
  /** The project calendar's time zone now. Buckets before a time zone change follow the old one. */
82
87
  timeZone: z3.string(),
@@ -84,7 +89,12 @@ var range = once(
84
89
  })
85
90
  );
86
91
  var previousRange = once(
87
- () => z3.object({ from: instant(), to: instant() }).optional()
92
+ () => z3.object({
93
+ from: instant(),
94
+ fromMs: instantMs(),
95
+ to: instant(),
96
+ toMs: instantMs()
97
+ }).optional()
88
98
  );
89
99
  var analyticsQuerySchema = z3.strictObject(
90
100
  lazyShape({
@@ -119,29 +129,40 @@ var quest = once(
119
129
  rejectionRate: z3.number().min(0).max(1).nullable(),
120
130
  /**
121
131
  * The 5 most common rejections, most frequent first. Rejections with a code (an evaluator's
122
- * reject code or one Relay writes, such as `budget-exhausted`) group by it, and `reason` is the
123
- * latest rejection's reason; rejections without one group by their exact reason.
132
+ * reject code or one Relay writes, such as `budget-exhausted`) group by it and by who wrote it,
133
+ * so Relay's `key-used` and an evaluator's own `key-used` are separate rows; `reason` is the
134
+ * latest rejection's reason. Rejections without one group by their exact reason.
124
135
  */
125
136
  topReasons: z3.array(
126
137
  z3.object({
127
138
  reason: z3.string(),
128
139
  code: z3.string().nullable(),
140
+ /**
141
+ * Who wrote `code`: `relay` or `evaluator`, null for a rejection without one. Relay always
142
+ * sends it; servers before it was added did not.
143
+ */
144
+ codeSource: z3.string().nullish(),
129
145
  count: amount()
130
146
  })
131
147
  ),
132
- /** Rejections by who made them: the evaluator, staff, an exhausted budget, an expired deferral. */
148
+ /**
149
+ * Rejections by who made them: the evaluator, staff, an exhausted budget, an expired deferral,
150
+ * or Relay because another member's completion holds the attempt's shared key (`keyUsed`, which
151
+ * Relay always sends; servers before it was added counted those as `evaluator`).
152
+ */
133
153
  rejectionsBySource: z3.object({
134
154
  evaluator: amount(),
135
155
  staff: amount(),
136
156
  budget: amount(),
137
- expired: amount()
157
+ expired: amount(),
158
+ keyUsed: amount().optional()
138
159
  }),
139
160
  /** Attempts and completions per bucket. */
140
161
  series: z3.object({ attempts: amounts(), completions: amounts() })
141
162
  })
142
163
  );
143
- var analyticsReadSchema = z3.object(
144
- lazyShape({
164
+ var analyticsReadSchema = /* @__PURE__ */ z3.object(
165
+ /* @__PURE__ */ lazyShape({
145
166
  range,
146
167
  previous: previousRange,
147
168
  members: () => z3.object({
@@ -210,6 +231,8 @@ var analyticsReadSchema = z3.object(
210
231
  testEnvironment: () => z3.object({
211
232
  /** When a test member was last reset, deleting their history, or null. */
212
233
  lastResetAt: instant().nullable(),
234
+ /** `lastResetAt` in epoch milliseconds. Servers before it was added did not send it. */
235
+ lastResetAtMs: amount().nullish(),
213
236
  /** Test members whose clock is advanced, so their activity can be dated in the future. */
214
237
  shiftedClockMembers: amount()
215
238
  }).optional()
@@ -458,7 +481,10 @@ var analyticsMetricResultSchema = z3.object(
458
481
  */
459
482
  rows: z3.array(
460
483
  z3.object({
461
- /** The resource's key (its ID when it has none), the source, the outcome, or the reason's code or text. */
484
+ /**
485
+ * The resource's key (its ID when it has none), the source, the outcome, or the reason's
486
+ * code or text; Relay's `key-used` is `relay:key-used`, apart from an evaluator's `key-used`.
487
+ */
462
488
  key: z3.string(),
463
489
  title: z3.string(),
464
490
  archived: z3.boolean(),
@@ -1,6 +1,16 @@
1
1
  import {
2
2
  isRequestError
3
- } from "./chunk-ZDJLPN4L.js";
3
+ } from "./chunk-K2KS3JLY.js";
4
+
5
+ // package.json
6
+ var name = "@domino-sdk/relay";
7
+ var version = "1.62.0";
8
+
9
+ // src/client-identity.ts
10
+ function clientIdentity() {
11
+ const runtime = typeof document === "undefined" ? "server" : "browser";
12
+ return `${name}/${version} (${runtime})`;
13
+ }
4
14
 
5
15
  // src/request-lifetime.ts
6
16
  var PARTICIPANT_TIMEOUT = 15e3;
@@ -46,7 +56,8 @@ function backoff(retry) {
46
56
  function retryDelay(failure, context) {
47
57
  const transient = failure.kind === "network" && (failure.status === void 0 || failure.status < 400) || (failure.kind === "http" || failure.kind === "network") && transientStatuses.has(failure.status ?? 0) && // Domino's rate limits run for minutes or hours: a 429 waits only when told how long.
48
58
  (failure.status !== 429 || failure.retryAfter !== void 0);
49
- if (!transient || !context.replaySafe || context.attempt >= MAX_ATTEMPTS) {
59
+ const repeatable = context.replaySafe || failure.status === 503 && failure.retryAfter !== void 0;
60
+ if (!transient || !repeatable || context.attempt >= MAX_ATTEMPTS) {
50
61
  return void 0;
51
62
  }
52
63
  const wait = failure.retryAfter ?? backoff(context.attempt);
@@ -103,6 +114,7 @@ function markUncertain(error) {
103
114
  }
104
115
 
105
116
  export {
117
+ clientIdentity,
106
118
  PARTICIPANT_TIMEOUT,
107
119
  MANAGEMENT_TIMEOUT,
108
120
  validTimeout,
@@ -5,7 +5,7 @@ import {
5
5
  isKnownTrackerSource,
6
6
  trackerDataSchema,
7
7
  xAccountRoles
8
- } from "./chunk-ZDJLPN4L.js";
8
+ } from "./chunk-MK425RXJ.js";
9
9
 
10
10
  // src/quest-shape.ts
11
11
  function validateQuestShape(description, options = {}) {
@@ -29,7 +29,7 @@ function validateQuestShape(description, options = {}) {
29
29
  );
30
30
  }
31
31
  if (content) {
32
- if (completion.kind !== "keyed") {
32
+ if (completion.kind !== "keyed" || completion.across) {
33
33
  throw new Error("Content quests complete once per content item");
34
34
  }
35
35
  if (tracker.beneficiary !== "author" || tracker.on !== "new-record") {
@@ -0,0 +1,31 @@
1
+ import {
2
+ RelayErrorCode,
3
+ clientError
4
+ } from "./chunk-K2KS3JLY.js";
5
+
6
+ // src/plugin-client.ts
7
+ var transportKey = /* @__PURE__ */ Symbol.for("@domino-sdk/relay:plugin-transport");
8
+ function setPluginTransport(client, transport) {
9
+ Object.defineProperty(client, transportKey, { value: transport });
10
+ }
11
+ function withPluginNamespace(client, name, build) {
12
+ if (!Object.hasOwn(client, name)) {
13
+ const transport = client[transportKey];
14
+ if (!transport) {
15
+ throw clientError(
16
+ "Pass a client that createRelayClient or createBrowserRelayClient made",
17
+ RelayErrorCode.InvalidInput
18
+ );
19
+ }
20
+ Object.defineProperty(client, name, {
21
+ value: build(transport),
22
+ enumerable: true
23
+ });
24
+ }
25
+ return client;
26
+ }
27
+
28
+ export {
29
+ setPluginTransport,
30
+ withPluginNamespace
31
+ };
@@ -0,0 +1,373 @@
1
+ import {
2
+ pointLedgerReferenceSchema
3
+ } from "./chunk-WSBYWVTZ.js";
4
+ import {
5
+ authProviderSchema,
6
+ entitlementSchema,
7
+ identifier,
8
+ pageCursorSchema,
9
+ pickupAvailabilitySchema,
10
+ pickupSelectionSchema,
11
+ signInProviderOptionSchema,
12
+ telegramSignInMethodsSchema,
13
+ walletSignInNetworksSchema
14
+ } from "./chunk-MK425RXJ.js";
15
+
16
+ // src/sign-in-providers.ts
17
+ import * as z from "zod";
18
+ var authProvidersSchema = z.object({
19
+ providers: z.array(
20
+ z.object({
21
+ provider: authProviderSchema,
22
+ configured: z.boolean()
23
+ })
24
+ ),
25
+ email: z.boolean(),
26
+ /** The wallet sign-in this project enabled. */
27
+ wallets: walletSignInNetworksSchema,
28
+ demo: z.boolean(),
29
+ /**
30
+ * Telegram's sign-in, which is not one of `providers` in SDK 1.x. Absent from Relay versions
31
+ * without Telegram. `login` is deprecated in favour of `signInProviders`; `miniApp` is not.
32
+ */
33
+ telegram: telegramSignInMethodsSchema.optional(),
34
+ /**
35
+ * Every sign-in provider the platform has, Telegram included, and whether Domino configured it:
36
+ * the open sibling of `providers`, which SDK 1.x keeps to `AuthProvider`. A newer Relay may list
37
+ * providers this SDK does not know. Absent from older Relay versions.
38
+ */
39
+ signInProviders: z.array(signInProviderOptionSchema).optional()
40
+ });
41
+
42
+ // src/creator-accounts.ts
43
+ import * as z2 from "zod";
44
+ var knownCreatorAccountProviders = ["youtube", "tiktok"];
45
+ var creatorAccountProviderSchema = z2.custom(
46
+ (value) => typeof value === "string" && /^[a-z][a-z0-9-]{0,39}$/.test(value)
47
+ );
48
+ var creatorAccountSchema = z2.object({
49
+ provider: creatorAccountProviderSchema,
50
+ configured: z2.boolean(),
51
+ status: z2.enum(["disconnected", "connected", "reconnect"]),
52
+ subject: z2.string().nullable(),
53
+ revision: z2.number().int().nonnegative(),
54
+ profile: z2.object({
55
+ name: z2.string().optional(),
56
+ username: z2.string().optional(),
57
+ imageUrl: z2.string().optional()
58
+ }).nullable()
59
+ });
60
+ var creatorAccountsSchema = z2.object({
61
+ accounts: z2.array(creatorAccountSchema)
62
+ });
63
+
64
+ // src/consent.ts
65
+ import * as z3 from "zod";
66
+ var consentWordingMaxLength = 2e3;
67
+ var knownConsentChannels = ["email"];
68
+ var openValue = z3.string().min(1).max(64);
69
+ var memberConsentSchema = z3.object({
70
+ member: identifier,
71
+ channel: openValue,
72
+ state: openValue,
73
+ at: z3.number().int().safe().nonnegative(),
74
+ wording: z3.string().nullable(),
75
+ source: openValue
76
+ });
77
+ var memberConsentListSchema = z3.array(memberConsentSchema);
78
+ var consentInputSchema = z3.object({
79
+ actionId: identifier,
80
+ channel: z3.custom(
81
+ (value) => typeof value === "string" && value.length <= 64
82
+ ),
83
+ granted: z3.boolean(),
84
+ wording: z3.string().optional()
85
+ }).strict();
86
+ var memberConsentInputSchema = z3.object({
87
+ actionId: identifier,
88
+ member: identifier,
89
+ channel: z3.string().max(64),
90
+ granted: z3.boolean(),
91
+ wording: z3.string().optional()
92
+ }).strict();
93
+ var memberConsentHistorySchema = z3.object({
94
+ items: z3.array(memberConsentSchema),
95
+ nextCursor: z3.string().nullable()
96
+ });
97
+ var memberConsentHistoryQuerySchema = z3.object({
98
+ cursor: z3.string().max(2e3).optional(),
99
+ limit: z3.coerce.number().int().min(1).max(100).optional()
100
+ }).strict();
101
+
102
+ // src/collection.ts
103
+ import * as z4 from "zod";
104
+ var collectionCodeSchema = z4.string().regex(/^relay:collect:[a-f0-9]{64}$/);
105
+ var collectionPassSchema = z4.object({
106
+ code: collectionCodeSchema,
107
+ expiresAt: z4.number(),
108
+ entitlement: identifier
109
+ });
110
+ var collectionResolveSchema = z4.object({ code: collectionCodeSchema }).strict();
111
+ var collectionBeginSchema = collectionResolveSchema.extend({
112
+ actionId: identifier,
113
+ revision: z4.number().int().positive(),
114
+ selection: pickupSelectionSchema.optional()
115
+ });
116
+ var collectionPreviewSchema = z4.object({
117
+ entitlement: entitlementSchema,
118
+ inventory: pickupAvailabilitySchema,
119
+ expiresAt: z4.number()
120
+ });
121
+
122
+ // src/outcomes.ts
123
+ import * as z5 from "zod";
124
+ var timestamp = z5.number().int().safe().nonnegative();
125
+ var questEnrollmentInputSchema = z5.strictObject({
126
+ actionId: identifier,
127
+ /** Quest key or ID. */
128
+ quest: identifier
129
+ });
130
+ var memberEnrollmentInputSchema = questEnrollmentInputSchema.extend({
131
+ member: identifier
132
+ });
133
+ var questEnrollmentSchema = z5.object({
134
+ /** Stable quest ID. */
135
+ quest: identifier,
136
+ member: identifier,
137
+ enrolledAt: timestamp
138
+ });
139
+ var questClaimInputSchema = z5.strictObject({
140
+ actionId: identifier,
141
+ /** Quest key or ID. */
142
+ quest: identifier,
143
+ /** The outcome's tracker, as `QuestOutcome.tracker` names it. */
144
+ tracker: identifier,
145
+ record: z5.string().min(1).max(256),
146
+ observedAt: timestamp
147
+ });
148
+ var QuestOutcomeState = {
149
+ Admitted: "admitted",
150
+ Skipped: "skipped"
151
+ };
152
+ var questOutcomeSchema = z5.object({
153
+ /** Prerequisite transition identity; absent on older tracker responses. */
154
+ automatic: identifier.optional(),
155
+ /** Stable quest ID. */
156
+ quest: identifier,
157
+ /** Stable tracker ID of the record decided. */
158
+ tracker: identifier.nullable(),
159
+ /** The record's ID in its tracker. */
160
+ record: z5.string().nullable(),
161
+ /** Which observation of the record was decided. */
162
+ observedAt: timestamp.nullable(),
163
+ state: z5.enum(["admitted", "skipped"]),
164
+ /**
165
+ * Why it was skipped, one of `trackerSkipCodes` or a code a newer Relay sends; null when
166
+ * admitted. Show an unknown code by its `reason`.
167
+ */
168
+ code: z5.string().nullable(),
169
+ /** Why it was skipped, for people; null when admitted. */
170
+ reason: z5.string().nullable(),
171
+ /** Which window refused admission when `code` is `outside-window`. */
172
+ window: z5.enum(["tracker", "quest"]).optional(),
173
+ /** The admitted attempt. */
174
+ attempt: identifier.nullable(),
175
+ /** The member can claim it with `relay.quests.claim()`. */
176
+ claimable: z5.boolean(),
177
+ createdAt: timestamp,
178
+ updatedAt: timestamp
179
+ });
180
+ var questOutcomeQuerySchema = z5.strictObject({
181
+ /** Quest key or ID. */
182
+ quest: identifier.optional(),
183
+ state: z5.enum(["admitted", "skipped"]).optional(),
184
+ /** Only skips with this code, such as `historical`. */
185
+ code: z5.string().min(1).max(100).optional(),
186
+ cursor: pageCursorSchema.optional()
187
+ });
188
+ var questOutcomePageSchema = z5.object({
189
+ items: z5.array(questOutcomeSchema),
190
+ nextCursor: pageCursorSchema.nullable()
191
+ });
192
+
193
+ // src/participant-rewards.ts
194
+ import * as z6 from "zod";
195
+ var participantEntitlementsSchema = z6.object({
196
+ items: z6.array(entitlementSchema)
197
+ });
198
+ var base = {
199
+ id: z6.string(),
200
+ status: z6.string(),
201
+ at: z6.number().nullable(),
202
+ quest: z6.string().nullable(),
203
+ completion: z6.string().nullable()
204
+ };
205
+ var known = z6.discriminatedUnion("kind", [
206
+ z6.object({
207
+ ...base,
208
+ kind: z6.literal("points"),
209
+ ledger: pointLedgerReferenceSchema,
210
+ amount: z6.number(),
211
+ reversed: z6.number()
212
+ }).catchall(z6.json()),
213
+ z6.object({
214
+ ...base,
215
+ kind: z6.literal("tier"),
216
+ entitlement: entitlementSchema
217
+ }).catchall(z6.json().transform((value) => value)),
218
+ z6.object({
219
+ ...base,
220
+ kind: z6.literal("integration"),
221
+ provider: z6.string(),
222
+ action: z6.string(),
223
+ roleId: z6.string().optional(),
224
+ deliveredAt: z6.number().nullable(),
225
+ revokedAt: z6.number().nullable(),
226
+ reconciliation: z6.object({ status: z6.string(), ownership: z6.string(), at: z6.number() }).catchall(z6.json()).nullable()
227
+ }).catchall(z6.json().optional())
228
+ ]);
229
+ var participantDeliverySchema = z6.union([
230
+ known,
231
+ z6.object({
232
+ ...base,
233
+ kind: z6.string().refine((kind) => !["points", "tier", "integration"].includes(kind))
234
+ }).catchall(z6.json()).transform(({ kind, ...item }) => ({
235
+ ...item,
236
+ kind: "unknown",
237
+ reportedKind: kind
238
+ }))
239
+ ]);
240
+ var participantDeliveriesSchema = z6.object({
241
+ items: z6.array(participantDeliverySchema)
242
+ });
243
+
244
+ // src/reward-deliveries.ts
245
+ import * as z7 from "zod";
246
+ var RewardDeliveryAction = {
247
+ /** Delivers a quest's Discord role reward. */
248
+ GrantRole: "grant-role",
249
+ /**
250
+ * Posts a quest's announcement in a Telegram chat or Discord channel. Its `provider` is
251
+ * `telegram` or `discord`, and its `roleId` is empty.
252
+ */
253
+ PostMessage: "post-message"
254
+ };
255
+ var rewardDeliveryActionSchema = z7.string().min(1).max(64);
256
+ var roleReconciliationSchema = z7.object({
257
+ status: z7.enum(["pending", "granted", "removed", "preserved", "failed"]),
258
+ ownership: z7.enum(["unclaimed", "relay", "external"]),
259
+ at: z7.number(),
260
+ reason: z7.string().nullable()
261
+ });
262
+ var knownRewardDeliverySchema = z7.object({
263
+ id: z7.string(),
264
+ quest: z7.string(),
265
+ completion: z7.string(),
266
+ member: z7.string(),
267
+ provider: z7.literal("discord"),
268
+ /** `RewardDeliveryAction`, such as `grant-role`. */
269
+ action: rewardDeliveryActionSchema,
270
+ roleId: z7.string(),
271
+ /**
272
+ * `failed` is terminal: Discord rejected the grant permanently (unknown role,
273
+ * member left the server, missing permissions) or retries ran out after about
274
+ * a day. An operator can retry it once the cause is fixed, unless revokedAt is set.
275
+ * Revoke stops pending grants; a late success records deliveredAt but leaves status failed.
276
+ */
277
+ status: z7.enum(["pending", "delivered", "failed"]),
278
+ /** Provider attempts in the current round; an operator retry starts a new round at zero. */
279
+ attempts: z7.number().int(),
280
+ /** While pending with a `lastError`, when the next attempt is scheduled. */
281
+ nextAt: z7.number(),
282
+ lastError: z7.string().nullable(),
283
+ createdAt: z7.number(),
284
+ deliveredAt: z7.number().nullable(),
285
+ /** First dispatch attempt, retained across retries. Legacy rows use creation time when dispatch timing is unknown. */
286
+ dispatchedAt: z7.number().nullable().optional(),
287
+ /** Completion revocation stops retries, including deliveries that had already failed. */
288
+ revokedAt: z7.number().nullable().optional(),
289
+ /** Current reconciliation of the pinned Discord membership; original delivery and revoke history stay intact. */
290
+ reconciliation: roleReconciliationSchema.nullable().optional()
291
+ });
292
+ var futureRewardDeliverySchema = knownRewardDeliverySchema.extend({
293
+ provider: z7.string(),
294
+ status: z7.string(),
295
+ roleId: z7.string().optional(),
296
+ reconciliation: z7.object({
297
+ status: z7.string(),
298
+ ownership: z7.string(),
299
+ at: z7.number(),
300
+ reason: z7.string().nullable()
301
+ }).catchall(z7.json()).nullable().optional()
302
+ }).catchall(z7.json().optional()).refine(
303
+ (delivery) => delivery.provider !== "discord" || !["pending", "delivered", "failed"].includes(delivery.status) || delivery.reconciliation && (!["pending", "granted", "removed", "preserved", "failed"].includes(
304
+ delivery.reconciliation.status
305
+ ) || !["unclaimed", "relay", "external"].includes(
306
+ delivery.reconciliation.ownership
307
+ ))
308
+ );
309
+ var rewardDeliverySchema = z7.union([
310
+ knownRewardDeliverySchema.catchall(z7.json().optional()),
311
+ futureRewardDeliverySchema
312
+ ]);
313
+ var rewardDeliveriesSchema = z7.object({
314
+ deliveries: z7.array(rewardDeliverySchema),
315
+ nextCursor: pageCursorSchema.nullable().default(null)
316
+ });
317
+ var rewardDeliveryQuerySchema = z7.strictObject({
318
+ cursor: pageCursorSchema.optional(),
319
+ limit: z7.coerce.number().int().min(1).max(500).optional()
320
+ });
321
+ var discordRoleRewardSchema = z7.object({
322
+ roleId: z7.string(),
323
+ quests: z7.array(z7.string()),
324
+ /** Delivery records of this role by `RewardDelivery.status`. */
325
+ deliveries: z7.object({
326
+ pending: z7.number().int(),
327
+ delivered: z7.number().int(),
328
+ failed: z7.number().int()
329
+ })
330
+ });
331
+ var discordRoleRewardsSchema = z7.object({
332
+ roles: z7.array(discordRoleRewardSchema)
333
+ });
334
+
335
+ export {
336
+ authProvidersSchema,
337
+ knownCreatorAccountProviders,
338
+ creatorAccountProviderSchema,
339
+ creatorAccountSchema,
340
+ creatorAccountsSchema,
341
+ consentWordingMaxLength,
342
+ knownConsentChannels,
343
+ memberConsentSchema,
344
+ memberConsentListSchema,
345
+ consentInputSchema,
346
+ memberConsentInputSchema,
347
+ memberConsentHistorySchema,
348
+ memberConsentHistoryQuerySchema,
349
+ collectionCodeSchema,
350
+ collectionPassSchema,
351
+ collectionResolveSchema,
352
+ collectionBeginSchema,
353
+ collectionPreviewSchema,
354
+ questEnrollmentInputSchema,
355
+ memberEnrollmentInputSchema,
356
+ questEnrollmentSchema,
357
+ questClaimInputSchema,
358
+ QuestOutcomeState,
359
+ questOutcomeSchema,
360
+ questOutcomeQuerySchema,
361
+ questOutcomePageSchema,
362
+ participantEntitlementsSchema,
363
+ participantDeliverySchema,
364
+ participantDeliveriesSchema,
365
+ RewardDeliveryAction,
366
+ roleReconciliationSchema,
367
+ knownRewardDeliverySchema,
368
+ rewardDeliverySchema,
369
+ rewardDeliveriesSchema,
370
+ rewardDeliveryQuerySchema,
371
+ discordRoleRewardSchema,
372
+ discordRoleRewardsSchema
373
+ };
@@ -20,6 +20,7 @@ var participantRoutes = [
20
20
  { method: "POST", path: "/v1/auth/logout" },
21
21
  { method: "GET", path: "/v1/auth/accounts" },
22
22
  { method: "GET", path: "/v1/auth/accounts/telegram" },
23
+ { method: "GET", path: "/v1/auth/sign-in-accounts" },
23
24
  { method: "GET", path: "/v1/auth/creator-accounts" },
24
25
  { method: "POST", path: "/v1/auth/accounts/disconnect" },
25
26
  { method: "POST", path: "/v1/auth/telegram/mini-app" },
@@ -52,6 +53,9 @@ var participantRoutes = [
52
53
  { method: "GET", path: "/v1/me/profile" },
53
54
  { method: "POST", path: "/v1/me/profile" },
54
55
  { method: "POST", path: "/v1/me/profile/avatar" },
56
+ // The member's marketing consent per channel.
57
+ { method: "GET", path: "/v1/me/consent" },
58
+ { method: "POST", path: "/v1/me/consent" },
55
59
  { method: "GET", path: `/v1/profiles/:profile${id}` },
56
60
  { method: "GET", path: `/v1/profiles/:profile${id}/completions` },
57
61
  {
@@ -85,6 +89,7 @@ var participantRoutes = [
85
89
  { method: "GET", path: `/v1/leaderboards/:board${id}` },
86
90
  { method: "GET", path: "/v1/point-ledgers" },
87
91
  { method: "GET", path: "/v1/badges" },
92
+ { method: "GET", path: "/v1/badges/catalog" },
88
93
  { method: "GET", path: "/v1/me/badges" },
89
94
  { method: "GET", path: "/v1/profiles/:profile{[\\w-]+}/badges" },
90
95
  { method: "GET", path: "/v1/tiered-rewards" }