@domino-sdk/relay 1.7.0 → 1.10.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 (45) hide show
  1. package/dist/action-9Xl0StBg.d.ts +33 -0
  2. package/dist/{activity-Br6vyYze.d.ts → activity-C0O3g7VJ.d.ts} +9 -9
  3. package/dist/authoring.d.ts +12 -12
  4. package/dist/authoring.js +3 -3
  5. package/dist/{automatic-outcomes-C1Q9LrDb.d.ts → automatic-outcomes-kPIDv6X_.d.ts} +1 -1
  6. package/dist/avatar.d.ts +2 -2
  7. package/dist/browser.d.ts +9 -8
  8. package/dist/browser.js +8 -6
  9. package/dist/{capability-error-Bv996M-h.d.ts → capability-error-ty3SqD_b.d.ts} +1 -1
  10. package/dist/{chunk-KGJSKGKI.js → chunk-23JUD56J.js} +1119 -910
  11. package/dist/{chunk-ZOUEEK5L.js → chunk-7BRHUUVB.js} +83 -26
  12. package/dist/{chunk-C25TDFHN.js → chunk-BKLGWPPD.js} +48 -37
  13. package/dist/{chunk-6ON4RMEN.js → chunk-BUXNTVER.js} +1 -1
  14. package/dist/{chunk-BFZHJA2B.js → chunk-GEPSEVQO.js} +2 -2
  15. package/dist/chunk-GFAFH7XR.js +98 -0
  16. package/dist/{chunk-6RBF3UDA.js → chunk-GPS546KR.js} +232 -7
  17. package/dist/{chunk-5ECM6AWV.js → chunk-MMWTHVXW.js} +3 -3
  18. package/dist/chunk-N2HXMTVA.js +13 -0
  19. package/dist/{chunk-23QJ7WH4.js → chunk-QL77V77D.js} +1 -1
  20. package/dist/{chunk-GMPPLZKH.js → chunk-UIR6NSYZ.js} +243 -228
  21. package/dist/{chunk-JW4G3SY5.js → chunk-WRBPLXVP.js} +60 -47
  22. package/dist/{client-pfml_XAa.d.ts → client-Yq11HA_f.d.ts} +64 -43
  23. package/dist/{groups-BpWEqaPn.d.ts → groups-BK8ts2yK.d.ts} +94 -6
  24. package/dist/{images-BaKYd0fl.d.ts → images-aw6W7vFZ.d.ts} +2 -2
  25. package/dist/index.d.ts +10 -9
  26. package/dist/index.js +10 -5
  27. package/dist/internal.d.ts +3 -3
  28. package/dist/internal.js +5 -5
  29. package/dist/{offers-CYtal8jO.d.ts → offers-C2FANzrG.d.ts} +3 -3
  30. package/dist/{pages-CixTNnF4.d.ts → pages-D00JDZB-.d.ts} +70 -39
  31. package/dist/portal-proxy.js +8 -2
  32. package/dist/react/index.d.ts +203 -19
  33. package/dist/react/index.js +256 -113
  34. package/dist/{referral-reward-kinds-ClxAuCGx.d.ts → referral-reward-kinds-M3f0PdiR.d.ts} +2 -2
  35. package/dist/{schema-CQydLqw4.d.ts → schema-DEM8y8Fm.d.ts} +16 -16
  36. package/dist/schema.d.ts +11239 -13
  37. package/dist/schema.js +38 -6
  38. package/dist/server/index.d.ts +43693 -52
  39. package/dist/server/index.js +465 -53
  40. package/dist/{sign-in-options-CtXUFV7E.d.ts → sign-in-options-Coim0G1u.d.ts} +3 -3
  41. package/dist/{submission-input-CLefHTrj.d.ts → submission-input-BbBJTVlT.d.ts} +3 -3
  42. package/dist/util.d-w9f9t3ua.d.ts +5 -0
  43. package/dist/{wallet-YssWxGg8.d.ts → wallet-CDyo-U4n.d.ts} +1 -1
  44. package/package.json +1 -1
  45. package/dist/{profiles-D2aFcOxu.d.ts → profiles-BHMVj0kM.d.ts} +5 -5
@@ -12,41 +12,164 @@ import {
12
12
  pointsRewardSchema,
13
13
  refuseWindowTimeZone,
14
14
  resourceHandle,
15
+ responseShape,
15
16
  rewardKey,
16
17
  tierRewardSchema
17
- } from "./chunk-KGJSKGKI.js";
18
+ } from "./chunk-23JUD56J.js";
18
19
 
19
- // src/point-ledgers.ts
20
+ // src/errors.ts
20
21
  import { z } from "zod";
21
- var pointLedgerPropertiesSchema = z.object({
22
- name: z.string().trim().min(1).max(120),
23
- description: z.string().trim().max(1e3).default("")
22
+ var RelayErrorCode = {
23
+ /** The call needs a signed-in member. */
24
+ NotSignedIn: "not-signed-in",
25
+ /** The session changed since the app read it (the `session` option). Reload before retrying. */
26
+ StaleSession: "stale-session",
27
+ /** The input failed validation before it was sent. */
28
+ InvalidInput: "invalid-input",
29
+ /** Relay's answer was not JSON or not the expected shape (kind `invalid-response`). */
30
+ InvalidResponse: "invalid-response",
31
+ /** The transport failed, before a response or while reading its body (kind `network`). */
32
+ Network: "network",
33
+ /** The client's deadline elapsed (kind `timeout`). */
34
+ Timeout: "timeout",
35
+ /** The caller cancelled the request (kind `aborted`). */
36
+ Aborted: "aborted",
37
+ /** A quest or collection the call named is not in the member's experience. */
38
+ NotFound: "not-found",
39
+ /** The quest has no failed attempt the member can retry. */
40
+ RetryUnavailable: "retry-unavailable",
41
+ /**
42
+ * Durable submission storage is missing, blocked or unreadable. Nothing was lost: call the
43
+ * handle's `status()` or `resume()` again once storage is available.
44
+ */
45
+ SubmissionStorage: "submission-storage",
46
+ /** Browser storage is full, so submission progress was not saved. Free space, then resume. */
47
+ SubmissionStorageQuota: "submission-storage-quota",
48
+ /** The saved submission is in a state that does not allow this action. */
49
+ SubmissionConflict: "submission-conflict",
50
+ /** The quest changed since the member saw it; review it before submitting again. */
51
+ QuestUpdated: "quest-updated",
52
+ /** Wait for the deferred attempt before submitting another action. */
53
+ AttemptPending: "attempt-pending",
54
+ /** The quiz changed since the member answered it. */
55
+ StaleQuiz: "stale-quiz",
56
+ /** Relay refused the submitted evidence. */
57
+ InvalidSubmission: "invalid-submission",
58
+ /** A page cursor Relay cannot read; start again from the first page. */
59
+ InvalidCursor: "invalid-cursor",
60
+ /** No point ledger in the project has the key or ID the call named. */
61
+ PointLedgerNotFound: "point-ledger-not-found",
62
+ /** The member has not joined this project, so it holds no points here. */
63
+ NotJoined: "not-joined",
64
+ /** The quest or campaign is not open at this time. */
65
+ OutsideWindow: "outside-window",
66
+ /** The signed-in member must enroll in the campaign first. */
67
+ EnrollmentRequired: "enrollment-required",
68
+ /** The quest's current reward budget has no remaining capacity. */
69
+ BudgetExhausted: "budget-exhausted",
70
+ /** No published offer has the key or ID the call named. */
71
+ OfferNotFound: "offer-not-found",
72
+ /** The operator paused this offer. */
73
+ OfferPaused: "offer-paused",
74
+ /** This member has already used the offer's allowed number of redemptions. */
75
+ OfferLimitReached: "offer-limit-reached",
76
+ /** No declared units remain. */
77
+ OfferOutOfStock: "offer-out-of-stock",
78
+ /** The participant's available point balance is below the offer price. */
79
+ InsufficientPoints: "insufficient-points",
80
+ /** A wallet signer failed or the member refused to sign; `cause` is the wallet's own error. */
81
+ WalletSigner: "wallet-signer",
82
+ /** The member has not met the quest's prerequisites; `missing` lists them. */
83
+ PrerequisitesIncomplete: "prerequisites-incomplete",
84
+ /** The quest is archived or retired: it takes no new participation. */
85
+ QuestClosed: "quest-closed",
86
+ /** An operator paused the quest. */
87
+ QuestPaused: "quest-paused",
88
+ /** An operator locked the member's profile; hiding it is still allowed. */
89
+ ProfileLocked: "profile-locked",
90
+ /** No member in the project has the invitation code the member accepted. */
91
+ InvitationNotFound: "invitation-not-found",
92
+ /** The email sign-in code is wrong; the member can type it again. */
93
+ InvalidCode: "invalid-code",
94
+ /** The email sign-in code expired, was used or had too many attempts; request another. */
95
+ CodeExpired: "code-expired",
96
+ /** The wallet sign-in challenge expired, was used or changed; start sign-in again. */
97
+ ChallengeExpired: "challenge-expired",
98
+ /** Too many requests; `retryAfter` says how long to wait when Relay knows. */
99
+ RateLimited: "rate-limited"
100
+ };
101
+ var relayErrorBrand = /* @__PURE__ */ Symbol.for("@domino-sdk/relay.RelayError");
102
+ function isRelayError(value) {
103
+ return isRequestError(value) && value[relayErrorBrand] === true;
104
+ }
105
+ var RelayError = class extends RequestError {
106
+ name = "RelayError";
107
+ [relayErrorBrand] = true;
108
+ /** Which window refused admission when `code` is `outside-window`. */
109
+ window;
110
+ /** Prerequisites the member does not currently meet, when Relay refused for that reason. */
111
+ missing;
112
+ constructor(message, details) {
113
+ super(message, details);
114
+ this.window = details.window;
115
+ this.missing = details.missing ?? [];
116
+ }
117
+ };
118
+ function asRelayError(cause, fallback = "Request failed") {
119
+ if (isRelayError(cause)) {
120
+ return cause;
121
+ }
122
+ return new RelayError(
123
+ cause instanceof Error && cause.message ? cause.message : fallback,
124
+ { kind: "client", cause }
125
+ );
126
+ }
127
+ function clientError(message, code, details = {}) {
128
+ return new RelayError(message, { ...details, kind: "client", code });
129
+ }
130
+ function parseInput(schema, value) {
131
+ const parsed = schema.safeParse(value);
132
+ if (!parsed.success) {
133
+ throw clientError(
134
+ z.prettifyError(parsed.error),
135
+ RelayErrorCode.InvalidInput,
136
+ { cause: parsed.error }
137
+ );
138
+ }
139
+ return parsed.data;
140
+ }
141
+
142
+ // src/point-ledgers.ts
143
+ import { z as z2 } from "zod";
144
+ var pointLedgerPropertiesSchema = z2.object({
145
+ name: z2.string().trim().min(1).max(120),
146
+ description: z2.string().trim().max(1e3).default("")
24
147
  }).strict();
25
148
  var createPointLedgerSchema = pointLedgerPropertiesSchema.extend({ actionId: identifier, key: identifier.optional() }).strict();
26
149
  var pointLedgerSchema = pointLedgerPropertiesSchema.extend({
27
150
  id: identifier
28
151
  });
29
152
  var managedPointLedgerSchema = pointLedgerSchema.extend({
30
- archivedAt: z.number().int().nonnegative().nullable()
153
+ archivedAt: z2.number().int().nonnegative().nullable()
31
154
  });
32
155
  var pointLedgerDeclarationSchema = pointLedgerPropertiesSchema.extend({ key: identifier }).strict();
33
- var pointLedgerArtifactSchema = z.union([
156
+ var pointLedgerArtifactSchema = z2.union([
34
157
  pointLedgerDeclarationSchema,
35
- z.object({ code: z.string().min(1).max(2e6) }).strict()
158
+ z2.object({ code: z2.string().min(1).max(2e6) }).strict()
36
159
  ]);
37
- var pointLedgerReferenceSchema = z.object({
160
+ var pointLedgerReferenceSchema = z2.object({
38
161
  id: identifier,
39
162
  key: identifier.nullable(),
40
- name: z.string()
163
+ name: z2.string()
41
164
  });
42
- var points = z.number().int().safe();
43
- var pointBalanceSchema = z.object({
165
+ var points = z2.number().int().safe();
166
+ var pointBalanceSchema = z2.object({
44
167
  ledger: pointLedgerReferenceSchema,
45
168
  balance: points,
46
169
  available: points
47
170
  });
48
- var pointBalancesSchema = z.object({
49
- items: z.array(pointBalanceSchema)
171
+ var pointBalancesSchema = z2.object({
172
+ items: z2.array(pointBalanceSchema)
50
173
  });
51
174
  var PointEntryKind = {
52
175
  /** Points a quest completion, an engagement settlement or an operator awarded. */
@@ -58,8 +181,8 @@ var PointEntryKind = {
58
181
  /** Undoes part or all of an award or a positive adjustment (`reverses`). */
59
182
  Reverse: "reverse"
60
183
  };
61
- var pointEntryKindSchema = z.string().min(1).max(64);
62
- var pointEntrySchema = z.object({
184
+ var pointEntryKindSchema = z2.string().min(1).max(64);
185
+ var pointEntrySchema = z2.object({
63
186
  id: identifier,
64
187
  amount: points,
65
188
  kind: pointEntryKindSchema,
@@ -68,64 +191,64 @@ var pointEntrySchema = z.object({
68
191
  quest: identifier.nullable(),
69
192
  reverses: identifier.nullable()
70
193
  });
71
- var pointHistoryQuerySchema = z.strictObject({
194
+ var pointHistoryQuerySchema = z2.strictObject({
72
195
  ledger: identifier,
73
196
  cursor: pageCursorSchema.optional()
74
197
  });
75
- var pointHistoryPageSchema = z.object({
76
- items: z.array(pointEntrySchema),
198
+ var pointHistoryPageSchema = z2.object({
199
+ items: z2.array(pointEntrySchema),
77
200
  nextCursor: pageCursorSchema.nullable()
78
201
  });
79
202
 
80
203
  // src/engagement.ts
81
- import { z as z2 } from "zod";
82
- var amount = z2.number().int().safe().nonnegative();
83
- var engagementBudgetSchema = z2.strictObject({
84
- scope: z2.enum(["member", "project"]),
204
+ import { z as z3 } from "zod";
205
+ var amount = z3.number().int().safe().nonnegative();
206
+ var engagementBudgetSchema = z3.strictObject({
207
+ scope: z3.enum(["member", "project"]),
85
208
  period: calendarPeriodSchema,
86
209
  limit: amount
87
210
  });
88
- var engagementDefinitionSchema = z2.strictObject({
211
+ var engagementDefinitionSchema = z3.strictObject({
89
212
  key: identifier,
90
213
  qualifiedBy: identifier,
91
214
  balance: identifier,
92
- metrics: z2.array(contentMetricSchema).min(1).max(10).refine(
215
+ metrics: z3.array(contentMetricSchema).min(1).max(10).refine(
93
216
  (metrics) => new Set(metrics).size === metrics.length,
94
217
  "Metrics must be unique"
95
218
  ),
96
- baseline: z2.literal("historical"),
97
- maxAgeMs: z2.number().int().positive().max(864e5).default(36e5),
98
- budgets: z2.array(engagementBudgetSchema).max(8).default([]).refine(
219
+ baseline: z3.literal("historical"),
220
+ maxAgeMs: z3.number().int().positive().max(864e5).default(36e5),
221
+ budgets: z3.array(engagementBudgetSchema).max(8).default([]).refine(
99
222
  (budgets) => new Set(budgets.map((b) => b.scope + ":" + b.period)).size === budgets.length,
100
223
  "Give each scope and period one budget"
101
224
  )
102
225
  });
103
- var engagementScoreInputSchema = z2.strictObject({
226
+ var engagementScoreInputSchema = z3.strictObject({
104
227
  metrics: contentMetricsSchema,
105
228
  baseline: contentMetricsSchema
106
229
  });
107
- var engagementScoreSchema = z2.strictObject({
230
+ var engagementScoreSchema = z3.strictObject({
108
231
  target: amount,
109
232
  baseline: amount
110
233
  });
111
- var engagementPublishSchema = z2.strictObject({
234
+ var engagementPublishSchema = z3.strictObject({
112
235
  actionId: identifier,
113
- code: z2.string().min(1).max(1e6)
236
+ code: z3.string().min(1).max(1e6)
114
237
  });
115
- var engagementRuleSchema = z2.strictObject({
238
+ var engagementRuleSchema = z3.strictObject({
116
239
  version: identifier,
117
240
  definition: engagementDefinitionSchema,
118
241
  publishedAt: amount
119
242
  });
120
- var engagementPageQuerySchema = z2.strictObject({
243
+ var engagementPageQuerySchema = z3.strictObject({
121
244
  rule: identifier,
122
- content: z2.string().min(1).max(256),
245
+ content: z3.string().min(1).max(256),
123
246
  member: identifier.optional(),
124
247
  cursor: pageCursorSchema.optional()
125
248
  });
126
- var engagementSettlementSchema = z2.strictObject({
249
+ var engagementSettlementSchema = z3.strictObject({
127
250
  id: identifier,
128
- day: z2.string(),
251
+ day: z3.string(),
129
252
  observation: identifier,
130
253
  qualification: identifier,
131
254
  earned: amount,
@@ -135,9 +258,9 @@ var engagementSettlementSchema = z2.strictObject({
135
258
  entry: identifier.nullable(),
136
259
  createdAt: amount
137
260
  });
138
- var engagementPageSchema = z2.strictObject({
261
+ var engagementPageSchema = z3.strictObject({
139
262
  rule: engagementRuleSchema,
140
- account: z2.strictObject({
263
+ account: z3.strictObject({
141
264
  member: identifier,
142
265
  earned: amount,
143
266
  accounted: amount,
@@ -148,28 +271,28 @@ var engagementPageSchema = z2.strictObject({
148
271
  baseline: contentMetricsSchema,
149
272
  observation: identifier.nullable(),
150
273
  nextSettlementAt: amount.nullable(),
151
- reason: z2.string().nullable()
274
+ reason: z3.string().nullable()
152
275
  }).nullable(),
153
- items: z2.array(engagementSettlementSchema),
276
+ items: z3.array(engagementSettlementSchema),
154
277
  nextCursor: pageCursorSchema.nullable()
155
278
  });
156
- var engagementChangePreviewInputSchema = z2.strictObject({
157
- code: z2.string().min(1).max(1e6)
279
+ var engagementChangePreviewInputSchema = z3.strictObject({
280
+ code: z3.string().min(1).max(1e6)
158
281
  });
159
282
  var engagementChangeSchema = engagementPublishSchema.extend({
160
283
  expectedVersion: identifier,
161
284
  previewHash: identifier
162
285
  });
163
- var total = z2.string().regex(/^(0|[1-9][0-9]*)$/);
164
- var engagementChangePreviewSchema = z2.strictObject({
286
+ var total = z3.string().regex(/^(0|[1-9][0-9]*)$/);
287
+ var engagementChangePreviewSchema = z3.strictObject({
165
288
  rule: identifier,
166
289
  fromVersion: identifier,
167
290
  toVersion: identifier,
168
291
  previewHash: identifier,
169
292
  definition: engagementDefinitionSchema,
170
- boundary: z2.literal("available-eligible-observation"),
171
- settlement: z2.literal("deferred"),
172
- summary: z2.strictObject({
293
+ boundary: z3.literal("available-eligible-observation"),
294
+ settlement: z3.literal("deferred"),
295
+ summary: z3.strictObject({
173
296
  knownAdmissions: amount,
174
297
  accounts: amount,
175
298
  uninitialized: amount,
@@ -183,13 +306,13 @@ var engagementChangePreviewSchema = z2.strictObject({
183
306
  var engagementVersionSchema = engagementRuleSchema.extend({
184
307
  previousVersion: identifier.nullable()
185
308
  });
186
- var engagementRuleVersionPageSchema = z2.object({
187
- items: z2.array(
188
- z2.object({
309
+ var engagementRuleVersionPageSchema = z3.object({
310
+ items: z3.array(
311
+ z3.object({
189
312
  version: identifier,
190
- definition: z2.object({
313
+ definition: z3.object({
191
314
  ...engagementDefinitionSchema.shape,
192
- budgets: z2.array(z2.object(engagementBudgetSchema.shape)).max(8).default([])
315
+ budgets: z3.array(z3.object(engagementBudgetSchema.shape)).max(8).default([])
193
316
  }),
194
317
  publishedAt: amount,
195
318
  previousVersion: identifier.nullable()
@@ -197,19 +320,19 @@ var engagementRuleVersionPageSchema = z2.object({
197
320
  ),
198
321
  nextCursor: pageCursorSchema.nullable()
199
322
  });
200
- var engagementVersionPageSchema = z2.strictObject({
201
- items: z2.array(engagementVersionSchema),
323
+ var engagementVersionPageSchema = z3.strictObject({
324
+ items: z3.array(engagementVersionSchema),
202
325
  next: amount.nullable()
203
326
  });
204
- var engagementVersionQuerySchema = z2.strictObject({
327
+ var engagementVersionQuerySchema = z3.strictObject({
205
328
  rule: identifier,
206
- before: z2.coerce.number().int().positive().safe().optional()
329
+ before: z3.coerce.number().int().positive().safe().optional()
207
330
  });
208
- var engagementBoundaryPageSchema = z2.strictObject({
331
+ var engagementBoundaryPageSchema = z3.strictObject({
209
332
  current: engagementRuleSchema.nullable(),
210
333
  requested: engagementRuleSchema,
211
- items: z2.array(
212
- z2.strictObject({
334
+ items: z3.array(
335
+ z3.strictObject({
213
336
  from: identifier,
214
337
  to: identifier,
215
338
  baseline: contentMetricsSchema,
@@ -225,137 +348,15 @@ var engagementArtifactSchema = engagementPublishSchema.omit({
225
348
  var deploymentEntry = engagementArtifactSchema.extend({
226
349
  rule: engagementRuleSchema
227
350
  });
228
- var engagementDeploymentEntrySchema = z2.discriminatedUnion("kind", [
229
- deploymentEntry.extend({ kind: z2.literal("create") }),
230
- deploymentEntry.extend({ kind: z2.literal("unchanged") }),
351
+ var engagementDeploymentEntrySchema = z3.discriminatedUnion("kind", [
352
+ deploymentEntry.extend({ kind: z3.literal("create") }),
353
+ deploymentEntry.extend({ kind: z3.literal("unchanged") }),
231
354
  deploymentEntry.extend({
232
- kind: z2.literal("change"),
355
+ kind: z3.literal("change"),
233
356
  change: engagementChangePreviewSchema
234
357
  })
235
358
  ]);
236
359
 
237
- // src/errors.ts
238
- import { z as z3 } from "zod";
239
- var RelayErrorCode = {
240
- /** The call needs a signed-in member. */
241
- NotSignedIn: "not-signed-in",
242
- /** The session changed since the app read it (the `session` option). Reload before retrying. */
243
- StaleSession: "stale-session",
244
- /** The input failed validation before it was sent. */
245
- InvalidInput: "invalid-input",
246
- /** Relay's answer was not JSON or not the expected shape (kind `invalid-response`). */
247
- InvalidResponse: "invalid-response",
248
- /** The transport failed, before a response or while reading its body (kind `network`). */
249
- Network: "network",
250
- /** The client's deadline elapsed (kind `timeout`). */
251
- Timeout: "timeout",
252
- /** The caller cancelled the request (kind `aborted`). */
253
- Aborted: "aborted",
254
- /** A quest or collection the call named is not in the member's experience. */
255
- NotFound: "not-found",
256
- /** The quest has no failed attempt the member can retry. */
257
- RetryUnavailable: "retry-unavailable",
258
- /**
259
- * Durable submission storage is missing, blocked or unreadable. Nothing was lost: call the
260
- * handle's `status()` or `resume()` again once storage is available.
261
- */
262
- SubmissionStorage: "submission-storage",
263
- /** Browser storage is full, so submission progress was not saved. Free space, then resume. */
264
- SubmissionStorageQuota: "submission-storage-quota",
265
- /** The saved submission is in a state that does not allow this action. */
266
- SubmissionConflict: "submission-conflict",
267
- /** The quest changed since the member saw it; review it before submitting again. */
268
- QuestUpdated: "quest-updated",
269
- /** Wait for the deferred attempt before submitting another action. */
270
- AttemptPending: "attempt-pending",
271
- /** The quiz changed since the member answered it. */
272
- StaleQuiz: "stale-quiz",
273
- /** Relay refused the submitted evidence. */
274
- InvalidSubmission: "invalid-submission",
275
- /** A page cursor Relay cannot read; start again from the first page. */
276
- InvalidCursor: "invalid-cursor",
277
- /** No point ledger in the project has the key or ID the call named. */
278
- PointLedgerNotFound: "point-ledger-not-found",
279
- /** The member has not joined this project, so it holds no points here. */
280
- NotJoined: "not-joined",
281
- /** The quest or campaign is not open at this time. */
282
- OutsideWindow: "outside-window",
283
- /** The signed-in member must enroll in the campaign first. */
284
- EnrollmentRequired: "enrollment-required",
285
- /** The quest's current reward budget has no remaining capacity. */
286
- BudgetExhausted: "budget-exhausted",
287
- /** No published offer has the key or ID the call named. */
288
- OfferNotFound: "offer-not-found",
289
- /** The operator paused this offer. */
290
- OfferPaused: "offer-paused",
291
- /** This member has already used the offer's allowed number of redemptions. */
292
- OfferLimitReached: "offer-limit-reached",
293
- /** No declared units remain. */
294
- OfferOutOfStock: "offer-out-of-stock",
295
- /** The participant's available point balance is below the offer price. */
296
- InsufficientPoints: "insufficient-points",
297
- /** A wallet signer failed or the member refused to sign; `cause` is the wallet's own error. */
298
- WalletSigner: "wallet-signer",
299
- /** The member has not met the quest's prerequisites; `missing` lists them. */
300
- PrerequisitesIncomplete: "prerequisites-incomplete",
301
- /** The quest is archived or retired: it takes no new participation. */
302
- QuestClosed: "quest-closed",
303
- /** An operator paused the quest. */
304
- QuestPaused: "quest-paused",
305
- /** An operator locked the member's profile; hiding it is still allowed. */
306
- ProfileLocked: "profile-locked",
307
- /** No member in the project has the invitation code the member accepted. */
308
- InvitationNotFound: "invitation-not-found",
309
- /** The email sign-in code is wrong; the member can type it again. */
310
- InvalidCode: "invalid-code",
311
- /** The email sign-in code expired, was used or had too many attempts; request another. */
312
- CodeExpired: "code-expired",
313
- /** The wallet sign-in challenge expired, was used or changed; start sign-in again. */
314
- ChallengeExpired: "challenge-expired",
315
- /** Too many requests; `retryAfter` says how long to wait when Relay knows. */
316
- RateLimited: "rate-limited"
317
- };
318
- var relayErrorBrand = /* @__PURE__ */ Symbol.for("@domino-sdk/relay.RelayError");
319
- function isRelayError(value) {
320
- return isRequestError(value) && value[relayErrorBrand] === true;
321
- }
322
- var RelayError = class extends RequestError {
323
- name = "RelayError";
324
- [relayErrorBrand] = true;
325
- /** Which window refused admission when `code` is `outside-window`. */
326
- window;
327
- /** Prerequisites the member does not currently meet, when Relay refused for that reason. */
328
- missing;
329
- constructor(message, details) {
330
- super(message, details);
331
- this.window = details.window;
332
- this.missing = details.missing ?? [];
333
- }
334
- };
335
- function asRelayError(cause, fallback = "Request failed") {
336
- if (isRelayError(cause)) {
337
- return cause;
338
- }
339
- return new RelayError(
340
- cause instanceof Error && cause.message ? cause.message : fallback,
341
- { kind: "client", cause }
342
- );
343
- }
344
- function clientError(message, code, details = {}) {
345
- return new RelayError(message, { ...details, kind: "client", code });
346
- }
347
- function parseInput(schema, value) {
348
- const parsed = schema.safeParse(value);
349
- if (!parsed.success) {
350
- throw clientError(
351
- z3.prettifyError(parsed.error),
352
- RelayErrorCode.InvalidInput,
353
- { cause: parsed.error }
354
- );
355
- }
356
- return parsed.data;
357
- }
358
-
359
360
  // src/profiles.ts
360
361
  import { z as z4 } from "zod";
361
362
  var count = z4.number().int().nonnegative().safe();
@@ -577,6 +578,9 @@ var validateSettlementWindow = (definition, context) => {
577
578
  }
578
579
  };
579
580
  var leaderboardDefinitionSchema = leaderboardDefinitionObject.superRefine(validateSettlementWindow);
581
+ var leaderboardDefinitionResponseSchema = responseShape(
582
+ leaderboardDefinitionSchema
583
+ );
580
584
  var leaderboardAuthoringSchema = leaderboardDefinitionObject.omit({ id: true }).extend({
581
585
  ...authoringIdentityShape,
582
586
  score: z5.preprocess(refuseWindowTimeZone, scoreSchema),
@@ -589,7 +593,7 @@ var leaderboardArtifactSchema = z5.union([
589
593
  var publishedLeaderboardSchema = z5.object({
590
594
  archivedAt: z5.number().int().nonnegative().nullable().optional(),
591
595
  version: identifier,
592
- definition: leaderboardDefinitionSchema,
596
+ definition: leaderboardDefinitionResponseSchema,
593
597
  publishedAt: timestamp,
594
598
  actor: z5.string().nullable()
595
599
  });
@@ -943,18 +947,22 @@ var offerArtifactSchema = z7.union([
943
947
  offerAuthoringSchema,
944
948
  z7.object({ code: z7.string().min(1).max(2e6) }).strict()
945
949
  ]);
946
- var offerAvailabilitySchema = z7.discriminatedUnion("kind", [
947
- z7.object({ kind: z7.literal("available"), remaining: quantity }).strict(),
948
- z7.object({ kind: z7.literal("out-of-stock") }).strict(),
949
- z7.object({ kind: z7.literal("limit-reached") }).strict(),
950
- z7.object({ kind: z7.literal("paused") }).strict()
951
- ]);
952
- var offerSchema = offerDefinitionSchema.extend({
953
- revision: z7.number().int().positive(),
954
- available: quantity,
955
- redeemed: quantity,
956
- availability: offerAvailabilitySchema
957
- });
950
+ var offerAvailabilitySchema = responseShape(
951
+ z7.discriminatedUnion("kind", [
952
+ z7.object({ kind: z7.literal("available"), remaining: quantity }).strict(),
953
+ z7.object({ kind: z7.literal("out-of-stock") }).strict(),
954
+ z7.object({ kind: z7.literal("limit-reached") }).strict(),
955
+ z7.object({ kind: z7.literal("paused") }).strict()
956
+ ])
957
+ );
958
+ var offerSchema = responseShape(
959
+ offerDefinitionSchema.extend({
960
+ revision: z7.number().int().positive(),
961
+ available: quantity,
962
+ redeemed: quantity,
963
+ availability: offerAvailabilitySchema
964
+ })
965
+ );
958
966
  var redeemOfferSchema = z7.object({ actionId: identifier }).strict();
959
967
  var redemptionBase = {
960
968
  id: identifier,
@@ -972,15 +980,17 @@ var redemptionBase = {
972
980
  revision: z7.number().int().positive(),
973
981
  redeemedAt: z7.number().int().safe().nonnegative()
974
982
  };
975
- var redemptionSchema = z7.discriminatedUnion("status", [
976
- z7.object({ ...redemptionBase, status: z7.literal("fulfilled") }).strict(),
977
- z7.object({
978
- ...redemptionBase,
979
- status: z7.literal("canceled"),
980
- canceledAt: z7.number().int().safe().nonnegative(),
981
- reason: z7.string().min(1).max(500)
982
- }).strict()
983
- ]);
983
+ var redemptionSchema = responseShape(
984
+ z7.discriminatedUnion("status", [
985
+ z7.object({ ...redemptionBase, status: z7.literal("fulfilled") }).strict(),
986
+ z7.object({
987
+ ...redemptionBase,
988
+ status: z7.literal("canceled"),
989
+ canceledAt: z7.number().int().safe().nonnegative(),
990
+ reason: z7.string().min(1).max(500)
991
+ }).strict()
992
+ ])
993
+ );
984
994
  var offerControlSchema = z7.object({
985
995
  actionId: identifier,
986
996
  revision: z7.number().int().positive(),
@@ -1130,22 +1140,32 @@ var evmChainIdSchema = z8.custom(
1130
1140
  'Use an EVM chain ID such as "eip155:8453"'
1131
1141
  );
1132
1142
  var units = z8.string().regex(/^(0|[1-9][0-9]*)$/);
1133
- var walletBalanceSchema = z8.object({
1134
- /** Canonical CAIP-2 ID for Solana, EVM or a supported Cosmos SDK chain. */
1135
- chain: z8.string(),
1136
- /** The canonical mint, EIP-55 contract or Cosmos bank denom; null for a native coin. */
1137
- token: z8.string().nullable(),
1138
- /** Null when token metadata does not report decimals. */
1139
- decimals: z8.number().int().min(0).max(255).nullable(),
1140
- /** The sum over `wallets`. */
1141
- total: units,
1142
- wallets: z8.array(z8.object({ address: z8.string(), amount: units }).strict()),
1143
- /** Solana: lowest slot. EVM: approximate latest block. Cosmos: the fixed queried block. */
1144
- at: z8.object({ kind: z8.enum(["slot", "block"]), number: units }).strict(),
1145
- observedAt: z8.number().int().nonnegative()
1146
- }).strict();
1143
+ var walletBalanceSchema = responseShape(
1144
+ z8.object({
1145
+ /** Canonical CAIP-2 ID for Solana, EVM or a supported Cosmos SDK chain. */
1146
+ chain: z8.string(),
1147
+ /** The canonical mint, EIP-55 contract or Cosmos bank denom; null for a native coin. */
1148
+ token: z8.string().nullable(),
1149
+ /** Null when token metadata does not report decimals. */
1150
+ decimals: z8.number().int().min(0).max(255).nullable(),
1151
+ /** The sum over `wallets`. */
1152
+ total: units,
1153
+ wallets: z8.array(
1154
+ z8.object({ address: z8.string(), amount: units }).strict()
1155
+ ),
1156
+ /** Solana: lowest slot. EVM: approximate latest block. Cosmos: the fixed queried block. */
1157
+ at: z8.object({ kind: z8.enum(["slot", "block"]), number: units }).strict(),
1158
+ observedAt: z8.number().int().nonnegative()
1159
+ }).strict()
1160
+ );
1147
1161
 
1148
1162
  export {
1163
+ RelayErrorCode,
1164
+ isRelayError,
1165
+ RelayError,
1166
+ asRelayError,
1167
+ clientError,
1168
+ parseInput,
1149
1169
  pointLedgerPropertiesSchema,
1150
1170
  createPointLedgerSchema,
1151
1171
  pointLedgerSchema,
@@ -1177,12 +1197,6 @@ export {
1177
1197
  engagementBoundaryPageSchema,
1178
1198
  engagementArtifactSchema,
1179
1199
  engagementDeploymentEntrySchema,
1180
- RelayErrorCode,
1181
- isRelayError,
1182
- RelayError,
1183
- asRelayError,
1184
- clientError,
1185
- parseInput,
1186
1200
  profileVisibilitySchema,
1187
1201
  avatarProviderSchema,
1188
1202
  profileDefaultProviderSchema,
@@ -1208,6 +1222,7 @@ export {
1208
1222
  leaderboardPrizeSchema,
1209
1223
  leaderboardSettlementPolicySchema,
1210
1224
  leaderboardDefinitionSchema,
1225
+ leaderboardDefinitionResponseSchema,
1211
1226
  leaderboardAuthoringSchema,
1212
1227
  leaderboardArtifactSchema,
1213
1228
  publishedLeaderboardSchema,