@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
@@ -1,1295 +0,0 @@
1
- import {
2
- RequestError,
3
- isRequestError
4
- } from "./chunk-NPGENI7K.js";
5
- import {
6
- authoringIdentityShape,
7
- calendarPeriodSchema,
8
- contentMetricSchema,
9
- contentMetricsSchema,
10
- identifier,
11
- pageCursorSchema,
12
- pointsRewardSchema,
13
- refuseWindowTimeZone,
14
- resourceHandle,
15
- responseShape,
16
- rewardKey,
17
- tierRewardSchema
18
- } from "./chunk-46C33ASD.js";
19
-
20
- // src/errors.ts
21
- import { z } from "zod";
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("")
147
- }).strict();
148
- var createPointLedgerSchema = pointLedgerPropertiesSchema.extend({ actionId: identifier, key: identifier.optional() }).strict();
149
- var pointLedgerSchema = pointLedgerPropertiesSchema.extend({
150
- id: identifier
151
- });
152
- var managedPointLedgerSchema = pointLedgerSchema.extend({
153
- archivedAt: z2.number().int().nonnegative().nullable()
154
- });
155
- var pointLedgerDeclarationSchema = pointLedgerPropertiesSchema.extend({ key: identifier }).strict();
156
- var pointLedgerArtifactSchema = z2.union([
157
- pointLedgerDeclarationSchema,
158
- z2.object({ code: z2.string().min(1).max(2e6) }).strict()
159
- ]);
160
- var pointLedgerReferenceSchema = z2.object({
161
- id: identifier,
162
- key: identifier.nullable(),
163
- name: z2.string()
164
- });
165
- var points = z2.number().int().safe();
166
- var pointBalanceSchema = z2.object({
167
- ledger: pointLedgerReferenceSchema,
168
- balance: points,
169
- available: points
170
- });
171
- var pointBalancesSchema = z2.object({
172
- items: z2.array(pointBalanceSchema)
173
- });
174
- var PointEntryKind = {
175
- /** Points a quest completion, an engagement settlement or an operator awarded. */
176
- Award: "award",
177
- /** Points the member spent. */
178
- Spend: "spend",
179
- /** A correction in either direction, by an operator or a referral payout. */
180
- Adjust: "adjust",
181
- /** Undoes part or all of an award or a positive adjustment (`reverses`). */
182
- Reverse: "reverse"
183
- };
184
- var pointEntryKindSchema = z2.string().min(1).max(64);
185
- var pointEntrySchema = z2.object({
186
- id: identifier,
187
- amount: points,
188
- kind: pointEntryKindSchema,
189
- /** When the entry took effect, in epoch milliseconds. A reversal keeps its source's. */
190
- at: points.nonnegative(),
191
- quest: identifier.nullable(),
192
- reverses: identifier.nullable()
193
- });
194
- var pointHistoryQuerySchema = z2.strictObject({
195
- ledger: identifier,
196
- cursor: pageCursorSchema.optional()
197
- });
198
- var pointHistoryPageSchema = z2.object({
199
- items: z2.array(pointEntrySchema),
200
- nextCursor: pageCursorSchema.nullable()
201
- });
202
-
203
- // src/engagement.ts
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"]),
208
- period: calendarPeriodSchema,
209
- limit: amount
210
- });
211
- var engagementDefinitionSchema = z3.strictObject({
212
- key: identifier,
213
- qualifiedBy: identifier,
214
- balance: identifier,
215
- metrics: z3.array(contentMetricSchema).min(1).max(10).refine(
216
- (metrics) => new Set(metrics).size === metrics.length,
217
- "Metrics must be unique"
218
- ),
219
- baseline: z3.literal("historical"),
220
- maxAgeMs: z3.number().int().positive().max(864e5).default(36e5),
221
- budgets: z3.array(engagementBudgetSchema).max(8).default([]).refine(
222
- (budgets) => new Set(budgets.map((b) => b.scope + ":" + b.period)).size === budgets.length,
223
- "Give each scope and period one budget"
224
- )
225
- });
226
- var engagementScoreInputSchema = z3.strictObject({
227
- metrics: contentMetricsSchema,
228
- baseline: contentMetricsSchema
229
- });
230
- var engagementScoreSchema = z3.strictObject({
231
- target: amount,
232
- baseline: amount
233
- });
234
- var engagementPublishSchema = z3.strictObject({
235
- actionId: identifier,
236
- code: z3.string().min(1).max(1e6)
237
- });
238
- var engagementRuleSchema = z3.strictObject({
239
- version: identifier,
240
- definition: engagementDefinitionSchema,
241
- publishedAt: amount
242
- });
243
- var engagementPageQuerySchema = z3.strictObject({
244
- rule: identifier,
245
- content: z3.string().min(1).max(256),
246
- member: identifier.optional(),
247
- cursor: pageCursorSchema.optional()
248
- });
249
- var engagementSettlementSchema = z3.strictObject({
250
- id: identifier,
251
- day: z3.string(),
252
- observation: identifier,
253
- qualification: identifier,
254
- earned: amount,
255
- growth: amount,
256
- paid: amount,
257
- excluded: amount,
258
- entry: identifier.nullable(),
259
- createdAt: amount
260
- });
261
- var engagementPageSchema = z3.strictObject({
262
- rule: engagementRuleSchema,
263
- account: z3.strictObject({
264
- member: identifier,
265
- earned: amount,
266
- accounted: amount,
267
- paid: amount,
268
- excluded: amount,
269
- pending: amount,
270
- counters: contentMetricsSchema,
271
- baseline: contentMetricsSchema,
272
- observation: identifier.nullable(),
273
- nextSettlementAt: amount.nullable(),
274
- reason: z3.string().nullable()
275
- }).nullable(),
276
- items: z3.array(engagementSettlementSchema),
277
- nextCursor: pageCursorSchema.nullable()
278
- });
279
- var engagementChangePreviewInputSchema = z3.strictObject({
280
- code: z3.string().min(1).max(1e6)
281
- });
282
- var engagementChangeSchema = engagementPublishSchema.extend({
283
- expectedVersion: identifier,
284
- previewHash: identifier
285
- });
286
- var total = z3.string().regex(/^(0|[1-9][0-9]*)$/);
287
- var engagementChangePreviewSchema = z3.strictObject({
288
- rule: identifier,
289
- fromVersion: identifier,
290
- toVersion: identifier,
291
- previewHash: identifier,
292
- definition: engagementDefinitionSchema,
293
- boundary: z3.literal("available-eligible-observation"),
294
- settlement: z3.literal("deferred"),
295
- summary: z3.strictObject({
296
- knownAdmissions: amount,
297
- accounts: amount,
298
- uninitialized: amount,
299
- pendingTransitions: amount,
300
- earned: total,
301
- paid: total,
302
- excluded: total,
303
- pending: total
304
- })
305
- });
306
- var engagementVersionSchema = engagementRuleSchema.extend({
307
- previousVersion: identifier.nullable()
308
- });
309
- var engagementRuleVersionPageSchema = z3.object({
310
- items: z3.array(
311
- z3.object({
312
- version: identifier,
313
- definition: z3.object({
314
- ...engagementDefinitionSchema.shape,
315
- budgets: z3.array(z3.object(engagementBudgetSchema.shape)).max(8).default([])
316
- }),
317
- publishedAt: amount,
318
- previousVersion: identifier.nullable()
319
- })
320
- ),
321
- nextCursor: pageCursorSchema.nullable()
322
- });
323
- var engagementVersionPageSchema = z3.strictObject({
324
- items: z3.array(engagementVersionSchema),
325
- next: amount.nullable()
326
- });
327
- var engagementVersionQuerySchema = z3.strictObject({
328
- rule: identifier,
329
- before: z3.coerce.number().int().positive().safe().optional()
330
- });
331
- var engagementBoundaryPageSchema = z3.strictObject({
332
- current: engagementRuleSchema.nullable(),
333
- requested: engagementRuleSchema,
334
- items: z3.array(
335
- z3.strictObject({
336
- from: identifier,
337
- to: identifier,
338
- baseline: contentMetricsSchema,
339
- observedAt: amount,
340
- settlement: engagementSettlementSchema
341
- })
342
- ),
343
- nextCursor: pageCursorSchema.nullable()
344
- });
345
- var engagementArtifactSchema = engagementPublishSchema.omit({
346
- actionId: true
347
- });
348
- var deploymentEntry = engagementArtifactSchema.extend({
349
- rule: engagementRuleSchema
350
- });
351
- var engagementDeploymentEntrySchema = z3.discriminatedUnion("kind", [
352
- deploymentEntry.extend({ kind: z3.literal("create") }),
353
- deploymentEntry.extend({ kind: z3.literal("unchanged") }),
354
- deploymentEntry.extend({
355
- kind: z3.literal("change"),
356
- change: engagementChangePreviewSchema
357
- })
358
- ]);
359
-
360
- // src/profiles.ts
361
- import { z as z4 } from "zod";
362
- var count = z4.number().int().nonnegative().safe();
363
- var profileVisibilitySchema = z4.enum([
364
- "private",
365
- "participants",
366
- "public"
367
- ]);
368
- var avatarProviderSchema = z4.enum(["x", "discord", "google"]);
369
- var profileDefaultProviderSchema = z4.enum(["x", "discord"]);
370
- var profileDefaultsSchema = z4.array(profileDefaultProviderSchema).max(profileDefaultProviderSchema.options.length).refine(
371
- (providers) => new Set(providers).size === providers.length,
372
- "List each provider once"
373
- );
374
- var avatarSeedSchema = z4.string().min(1).max(100);
375
- var profileAvatarSchema = z4.discriminatedUnion("source", [
376
- z4.object({
377
- source: z4.literal("upload"),
378
- url: z4.string().url(),
379
- seed: avatarSeedSchema
380
- }),
381
- z4.object({
382
- source: z4.literal("account"),
383
- provider: avatarProviderSchema,
384
- url: z4.string().url(),
385
- seed: avatarSeedSchema
386
- }),
387
- z4.object({ source: z4.literal("generated"), seed: avatarSeedSchema })
388
- ]);
389
- var profileSummarySchema = z4.object({
390
- id: identifier,
391
- name: z4.string(),
392
- avatar: profileAvatarSchema
393
- });
394
- var invisible = /[\p{Cc}؜᠎​-‏‪-‮⁠-⁤⁦-⁩]/u;
395
- var displayNameSchema = z4.string().max(200).transform((value) => value.normalize("NFC").replace(/\s+/g, " ").trim()).pipe(
396
- z4.string().min(1, "Enter a name").max(40, "Use at most 40 characters").refine((value) => !invisible.test(value), "Use visible characters only")
397
- );
398
- var profileUpdateSchema = z4.object({
399
- displayName: displayNameSchema.nullable().optional(),
400
- avatar: z4.discriminatedUnion("source", [
401
- z4.object({
402
- source: z4.literal("account"),
403
- provider: avatarProviderSchema
404
- }).strict(),
405
- z4.object({ source: z4.literal("generated") }).strict()
406
- ]).nullable().optional(),
407
- hidden: z4.boolean().optional()
408
- }).strict().refine(
409
- (value) => Object.values(value).some((field) => field !== void 0),
410
- "Change at least one field"
411
- );
412
- var ownProfileSchema = profileSummarySchema.extend({
413
- /** The name the member chose, or null for the default. */
414
- displayName: z4.string().nullable(),
415
- /** The avatar the member chose: `default` follows the project's defaults. */
416
- avatarChoice: z4.enum(["default", "upload", "account", "generated"]),
417
- /** The account of an `account` choice. */
418
- avatarProvider: avatarProviderSchema.nullable(),
419
- hidden: z4.boolean(),
420
- /** An operator locked the name and avatar; the member can still hide the profile. */
421
- locked: z4.boolean(),
422
- /** Who can see profiles in this project, so the app can explain it. */
423
- visibility: profileVisibilitySchema,
424
- /** The member's connected accounts a picture or name can come from. */
425
- options: z4.array(
426
- z4.object({
427
- provider: avatarProviderSchema,
428
- name: z4.string().nullable(),
429
- imageUrl: z4.string().url().nullable()
430
- })
431
- )
432
- });
433
- var cursor = z4.string().min(1).max(512);
434
- var profileCompletionQuerySchema = z4.object({
435
- limit: z4.coerce.number().int().min(1).max(100).default(20),
436
- cursor: cursor.optional()
437
- }).strict();
438
- var profileCompletionSchema = z4.object({
439
- quest: identifier,
440
- key: identifier.optional(),
441
- title: z4.string(),
442
- completions: count.positive(),
443
- /** Null for completions recorded before completion times were. */
444
- lastCompletedAt: count.nullable()
445
- });
446
- var profileCompletionPageSchema = z4.object({
447
- items: z4.array(profileCompletionSchema),
448
- nextCursor: cursor.nullable()
449
- });
450
- var profileReferralSchema = z4.object({
451
- program: identifier,
452
- key: identifier.optional(),
453
- title: z4.string(),
454
- /** Members this member invited. Invitations are shared by every program. */
455
- invited: count,
456
- /** Invited members who qualified in this program. */
457
- qualified: count,
458
- milestones: z4.array(
459
- z4.object({ id: identifier, count, reached: z4.boolean() })
460
- )
461
- });
462
- var profileSettingsSchema = z4.object({
463
- visibility: profileVisibilitySchema,
464
- defaults: profileDefaultsSchema,
465
- revision: count,
466
- actor: z4.string().nullable(),
467
- updatedAt: count.nullable()
468
- });
469
- var profileSettingsInputSchema = profileSettingsSchema.omit({ revision: true, actor: true, updatedAt: true }).extend({
470
- actionId: identifier,
471
- /** The revision the change was made against; a newer one is a 409. */
472
- expectedRevision: count,
473
- reason: z4.string().trim().min(1).max(500)
474
- }).strict();
475
- var profileModerationSchema = z4.object({
476
- actionId: identifier,
477
- resetName: z4.boolean().default(false),
478
- removeAvatar: z4.boolean().default(false),
479
- /** True locks the name and avatar, false unlocks them. */
480
- lock: z4.boolean().optional(),
481
- reason: z4.string().trim().min(1).max(1e3)
482
- }).strict().refine(
483
- (value) => value.resetName || value.removeAvatar || value.lock !== void 0,
484
- "Choose an action"
485
- );
486
- var managedProfileSchema = ownProfileSchema.omit({ options: true }).extend({
487
- member: identifier,
488
- lockedAt: count.nullable(),
489
- lockedBy: z4.string().nullable(),
490
- lockedReason: z4.string().nullable(),
491
- updatedAt: count
492
- });
493
- var AVATAR_UPLOAD_LIMIT = 5 * 1024 * 1024;
494
- var avatarUploadTypes = ["image/jpeg", "image/png", "image/webp"];
495
-
496
- // src/leaderboards.ts
497
- import { z as z5 } from "zod";
498
- var integer = z5.number().int().safe();
499
- var timestamp = integer.nonnegative().max(864e13);
500
- var leaderboardWindowSchema = z5.discriminatedUnion("kind", [
501
- z5.object({ kind: z5.literal("all-time") }).strict(),
502
- z5.object({ kind: z5.literal("fixed"), start: timestamp, end: timestamp }).strict().refine((w) => w.end > w.start, "Window end must follow its start"),
503
- z5.object({ kind: z5.literal("rolling"), days: integer.min(1).max(3660) }).strict(),
504
- // Not strict: boards published while a calendar window named its own `timeZone` keep reading,
505
- // and the field drops on parse. The authoring schema refuses it.
506
- z5.object({
507
- kind: z5.literal("calendar"),
508
- /** The current day, week (ISO, starting on Monday) or month of the project calendar. */
509
- period: calendarPeriodSchema.exclude(["lifetime"])
510
- })
511
- ]);
512
- var periodScore = {
513
- window: leaderboardWindowSchema.default({ kind: "all-time" }),
514
- quests: z5.array(identifier).min(1).max(100).optional()
515
- };
516
- var scoreSchema = z5.discriminatedUnion("kind", [
517
- z5.object({ kind: z5.literal("balance") }).strict(),
518
- z5.object({ kind: z5.literal("earned"), ...periodScore }).strict(),
519
- z5.object({
520
- kind: z5.literal("net"),
521
- window: leaderboardWindowSchema.default({ kind: "all-time" })
522
- }).strict()
523
- ]).default({ kind: "balance" });
524
- var leaderboardPrizeRewardSchema = z5.union([
525
- pointsRewardSchema,
526
- tierRewardSchema
527
- ]);
528
- var leaderboardPrizeSchema = z5.object({
529
- ranks: z5.tuple([integer.positive(), integer.positive()]).refine(([first, last]) => last >= first, {
530
- message: "Prize rank range must end at or after it starts"
531
- }),
532
- rewards: z5.array(leaderboardPrizeRewardSchema).min(1).max(20)
533
- }).strict();
534
- var leaderboardSettlementPolicySchema = z5.object({
535
- at: z5.literal("window-end"),
536
- ties: z5.enum(["shared", "earliest"]),
537
- prizes: z5.array(leaderboardPrizeSchema).min(1).max(50)
538
- }).strict().superRefine((policy, context) => {
539
- for (const [index, prize] of policy.prizes.entries()) {
540
- const keys = prize.rewards.map(rewardKey);
541
- if (new Set(keys).size !== keys.length) {
542
- context.addIssue({
543
- code: "custom",
544
- message: "A prize may grant each point ledger or tiered reward only once",
545
- path: ["prizes", index, "rewards"]
546
- });
547
- }
548
- }
549
- for (let index = 1; index < policy.prizes.length; index++) {
550
- const previous = policy.prizes[index - 1];
551
- const current = policy.prizes[index];
552
- if (current.ranks[0] <= previous.ranks[1]) {
553
- context.addIssue({
554
- code: "custom",
555
- message: "Prize rank ranges must be ordered and must not overlap",
556
- path: ["prizes", index, "ranks"]
557
- });
558
- }
559
- }
560
- });
561
- var leaderboardDefinitionObject = z5.object({
562
- id: identifier,
563
- key: identifier.optional(),
564
- title: z5.string().trim().min(1).max(120),
565
- balance: identifier,
566
- score: scoreSchema,
567
- access: z5.enum(["participants", "public"]).default("participants"),
568
- group: identifier.optional(),
569
- settle: leaderboardSettlementPolicySchema.optional()
570
- }).strict();
571
- var validateSettlementWindow = (definition, context) => {
572
- if (definition.settle && (definition.score.kind === "balance" || !["fixed", "calendar"].includes(definition.score.window.kind))) {
573
- context.addIssue({
574
- code: "custom",
575
- message: "Leaderboard prizes require an earned or net score with a fixed or calendar window",
576
- path: ["settle"]
577
- });
578
- }
579
- };
580
- var leaderboardDefinitionSchema = leaderboardDefinitionObject.superRefine(validateSettlementWindow);
581
- var leaderboardDefinitionResponseSchema = responseShape(
582
- leaderboardDefinitionSchema
583
- );
584
- var leaderboardAuthoringSchema = leaderboardDefinitionObject.omit({ id: true }).extend({
585
- ...authoringIdentityShape,
586
- score: z5.preprocess(refuseWindowTimeZone, scoreSchema),
587
- group: identifier.optional()
588
- }).strict().superRefine(validateSettlementWindow);
589
- var leaderboardArtifactSchema = z5.union([
590
- leaderboardAuthoringSchema,
591
- z5.object({ code: z5.string().min(1).max(2e6) }).strict()
592
- ]);
593
- var publishedLeaderboardSchema = z5.object({
594
- archivedAt: z5.number().int().nonnegative().nullable().optional(),
595
- version: identifier,
596
- definition: leaderboardDefinitionResponseSchema,
597
- publishedAt: timestamp,
598
- actor: z5.string().nullable()
599
- });
600
- var leaderboardQuerySchema = z5.object({
601
- limit: z5.coerce.number().int().min(1).max(100).default(25),
602
- cursor: z5.string().max(4096).optional()
603
- }).strict();
604
- var leaderboardRowSchema = z5.object({
605
- /** The row's stable key: a pseudonym per board and member. */
606
- participant: identifier,
607
- member: identifier.optional(),
608
- /** The profile's name where the viewer can see it, otherwise the pseudonym's. */
609
- name: z5.string(),
610
- score: integer,
611
- rank: integer.positive(),
612
- /** The member's profile, where visible to this viewer and not hidden by the member. */
613
- profile: profileSummarySchema.nullable()
614
- });
615
- var leaderboardPageSchema = z5.object({
616
- leaderboard: identifier,
617
- title: z5.string(),
618
- version: identifier,
619
- calculation: z5.enum(["balance", "earned", "net"]),
620
- period: z5.object({ start: timestamp.nullable(), end: timestamp.nullable() }),
621
- calculatedAt: timestamp,
622
- lastEntryAt: timestamp.nullable(),
623
- total: integer.nonnegative(),
624
- items: z5.array(leaderboardRowSchema),
625
- me: leaderboardRowSchema.nullable(),
626
- nearby: z5.array(leaderboardRowSchema),
627
- nextCursor: z5.string().nullable()
628
- });
629
- var leaderboardPlacementSchema = z5.object({
630
- leaderboard: identifier,
631
- key: identifier.optional(),
632
- title: z5.string(),
633
- profile: identifier,
634
- rank: integer.positive().nullable(),
635
- score: integer.nullable(),
636
- /** Ranked participants on the board. */
637
- total: integer.nonnegative()
638
- });
639
- var leaderboardPreviewSchema = z5.object({
640
- published: publishedLeaderboardSchema,
641
- before: leaderboardPageSchema.nullable(),
642
- after: leaderboardPageSchema
643
- });
644
- var mutationBase = {
645
- actionId: identifier,
646
- member: identifier,
647
- balance: identifier,
648
- reason: z5.string().trim().min(1).max(1e3)
649
- };
650
- var datedMutation = { ...mutationBase, effectiveAt: timestamp.optional() };
651
- var pointsMutationSchema = z5.discriminatedUnion("kind", [
652
- z5.object({
653
- ...datedMutation,
654
- kind: z5.literal("award"),
655
- referralEligible: z5.boolean().optional(),
656
- amount: integer.positive()
657
- }).strict(),
658
- z5.object({
659
- ...datedMutation,
660
- kind: z5.literal("spend"),
661
- amount: integer.positive()
662
- }).strict(),
663
- z5.object({
664
- ...datedMutation,
665
- kind: z5.literal("adjust"),
666
- amount: integer.refine((n) => n !== 0)
667
- }).strict(),
668
- z5.object({
669
- ...datedMutation,
670
- kind: z5.literal("set"),
671
- total: integer.nonnegative(),
672
- expectedTotal: integer.nonnegative(),
673
- classification: z5.enum(["earned", "spend"])
674
- }).strict(),
675
- z5.object({
676
- ...mutationBase,
677
- kind: z5.literal("reverse"),
678
- entry: identifier,
679
- amount: integer.positive()
680
- }).strict()
681
- ]);
682
- var pointsEntrySchema = z5.object({
683
- id: identifier,
684
- completion: z5.string().nullable(),
685
- member: identifier,
686
- balance: identifier,
687
- amount: integer,
688
- kind: z5.enum(["award", "spend", "adjust", "reverse"]),
689
- effectiveAt: timestamp,
690
- receivedAt: timestamp,
691
- quest: identifier.nullable(),
692
- original: identifier.nullable(),
693
- reason: z5.string(),
694
- actor: z5.string().nullable()
695
- });
696
- var managedPointHistoryPageSchema = z5.object({
697
- items: z5.array(pointsEntrySchema),
698
- nextCursor: pageCursorSchema.nullable(),
699
- /** @deprecated Use `nextCursor`, passed back as `cursor`. Removed in 2.0.0. */
700
- next: z5.number().nullable()
701
- });
702
- var pointsResultSchema = z5.object({
703
- entry: pointsEntrySchema,
704
- total: integer.nonnegative()
705
- });
706
- var pointsAccountSchema = z5.object({
707
- member: identifier,
708
- balance: identifier,
709
- total: integer.nonnegative(),
710
- held: integer.nonnegative()
711
- });
712
- var leaderboardExclusionSchema = z5.object({
713
- actionId: identifier,
714
- member: identifier,
715
- excluded: z5.boolean(),
716
- reason: z5.string().trim().min(1).max(1e3)
717
- }).strict();
718
- var leaderboardGroupSchema = z5.object({
719
- actionId: identifier,
720
- member: identifier,
721
- included: z5.boolean(),
722
- reason: z5.string().trim().min(1).max(1e3)
723
- }).strict();
724
- var leaderboardSettlementStatusSchema = z5.enum(["pending", "approved"]);
725
- var leaderboardSettlementSummarySchema = z5.object({
726
- id: identifier,
727
- leaderboard: identifier,
728
- version: identifier,
729
- title: z5.string(),
730
- period: z5.object({ start: timestamp, end: timestamp }),
731
- ties: z5.enum(["shared", "earliest"]),
732
- status: leaderboardSettlementStatusSchema,
733
- total: integer.nonnegative(),
734
- winners: integer.nonnegative(),
735
- createdAt: timestamp,
736
- approvedAt: timestamp.nullable(),
737
- approvedBy: z5.string().nullable(),
738
- approvalReason: z5.string().nullable()
739
- });
740
- var leaderboardSettlementRowSchema = z5.object({
741
- member: identifier,
742
- score: integer,
743
- rank: integer.positive(),
744
- position: integer.positive(),
745
- scoredAt: timestamp,
746
- prizes: z5.array(integer.nonnegative()),
747
- completion: identifier.nullable(),
748
- revokedAt: timestamp.nullable()
749
- });
750
- var leaderboardSettlementSchema = leaderboardSettlementSummarySchema.extend({
751
- prizes: z5.array(leaderboardPrizeSchema),
752
- excluded: z5.array(identifier),
753
- rows: z5.array(leaderboardSettlementRowSchema)
754
- });
755
- var leaderboardSettlementApprovalSchema = z5.object({
756
- actionId: identifier,
757
- reason: z5.string().trim().min(1).max(500)
758
- }).strict();
759
-
760
- // src/referrals.ts
761
- import { z as z6 } from "zod";
762
- var rewardSchema = z6.union([pointsRewardSchema, tierRewardSchema]);
763
- var amount2 = z6.number().int().safe().nonnegative();
764
- var reason = z6.string().trim().min(1).max(1e3);
765
- var referralDefinitionSchema = z6.object({
766
- id: identifier,
767
- key: identifier.optional(),
768
- title: z6.string().trim().min(1).max(120),
769
- enabled: z6.boolean().default(true),
770
- qualification: z6.discriminatedUnion("kind", [
771
- z6.object({ kind: z6.literal("signup") }).strict(),
772
- z6.object({ kind: z6.literal("quest"), quest: identifier }).strict(),
773
- z6.object({ kind: z6.literal("external") }).strict()
774
- ]),
775
- inviterGroup: identifier.optional(),
776
- rewards: z6.object({
777
- inviter: z6.array(rewardSchema).max(10).default([]),
778
- invitee: z6.array(rewardSchema).max(10).default([])
779
- }).strict().default({ inviter: [], invitee: [] }),
780
- milestones: z6.array(
781
- z6.object({
782
- id: identifier,
783
- count: amount2.min(1),
784
- rewards: z6.array(rewardSchema).min(1).max(10)
785
- }).strict()
786
- ).max(30).default([]),
787
- bonuses: z6.array(
788
- z6.object({
789
- id: identifier,
790
- balance: identifier,
791
- basisPoints: amount2.min(1).max(1e4),
792
- quests: z6.array(identifier).min(1).max(100).optional(),
793
- external: z6.boolean().default(false),
794
- durationDays: amount2.min(1).max(36500).optional(),
795
- maxPoints: amount2.min(1).optional()
796
- }).strict()
797
- ).max(20).default([])
798
- }).strict().superRefine((value, ctx) => {
799
- for (const entries of [value.milestones, value.bonuses]) {
800
- if (new Set(entries.map((e) => e.id)).size !== entries.length) {
801
- ctx.addIssue({ code: "custom", message: "Rule IDs must be unique" });
802
- }
803
- }
804
- });
805
- var referralAuthoringSchema = z6.object(referralDefinitionSchema.shape).omit({ id: true }).extend({
806
- ...authoringIdentityShape,
807
- inviterGroup: identifier.optional()
808
- }).strict().superRefine((value, ctx) => {
809
- for (const entries of [value.milestones, value.bonuses]) {
810
- if (new Set(entries.map((entry) => entry.id)).size !== entries.length) {
811
- ctx.addIssue({ code: "custom", message: "Rule keys must be unique" });
812
- }
813
- }
814
- });
815
- var referralArtifactSchema = z6.union([
816
- referralAuthoringSchema,
817
- z6.object({ code: z6.string().min(1).max(2e6) }).strict()
818
- ]);
819
- var publishedReferralSchema = z6.object({
820
- archivedAt: z6.number().int().nonnegative().nullable().optional(),
821
- version: identifier,
822
- definition: referralDefinitionSchema,
823
- publishedAt: amount2,
824
- actor: z6.string().nullable()
825
- });
826
- var referralAcceptSchema = z6.object({ actionId: identifier, code: identifier }).strict();
827
- var referralSuspensionSchema = z6.object({ actionId: identifier, suspended: z6.boolean(), reason }).strict();
828
- var referralQualificationSchema = z6.object({ actionId: identifier, qualified: z6.boolean(), reason }).strict();
829
- var referralRewardResolutionSchema = z6.object({ actionId: identifier, reason }).strict();
830
- var referralControlSchema = z6.discriminatedUnion("kind", [
831
- z6.object({
832
- kind: z6.literal("suspend"),
833
- actionId: identifier,
834
- member: identifier,
835
- suspended: z6.boolean(),
836
- reason
837
- }).strict(),
838
- z6.object({
839
- kind: z6.literal("qualify"),
840
- actionId: identifier,
841
- member: identifier,
842
- program: identifier,
843
- qualified: z6.boolean(),
844
- reason
845
- }).strict(),
846
- z6.object({
847
- kind: z6.literal("resolve-reward"),
848
- actionId: identifier,
849
- entitlement: identifier,
850
- reason
851
- }).strict()
852
- ]);
853
- var referralRelationshipSchema = z6.object({
854
- member: identifier,
855
- inviter: identifier,
856
- acceptedAt: amount2,
857
- suspended: z6.boolean()
858
- });
859
- var referralAccountSchema = z6.object({
860
- id: identifier,
861
- program: identifier,
862
- kind: z6.enum(["bonus", "fixed", "milestone"]),
863
- balance: identifier,
864
- earned: amount2,
865
- settled: amount2,
866
- outstanding: amount2
867
- });
868
- var referralSummarySchema = z6.object({
869
- code: identifier,
870
- attributed: amount2,
871
- programs: z6.array(
872
- z6.object({
873
- definition: referralDefinitionSchema,
874
- qualified: amount2,
875
- milestones: z6.array(
876
- z6.object({ id: identifier, count: amount2, reached: z6.boolean() })
877
- )
878
- })
879
- ),
880
- accounts: z6.array(referralAccountSchema)
881
- });
882
- var referralHistorySchema = z6.object({
883
- items: z6.array(
884
- z6.object({
885
- id: amount2,
886
- program: identifier,
887
- balance: identifier,
888
- amount: z6.number().int().safe(),
889
- at: amount2,
890
- reason: z6.string()
891
- })
892
- ),
893
- nextCursor: pageCursorSchema.nullable()
894
- });
895
- var referralManagementSchema = z6.object({
896
- relationships: z6.array(referralRelationshipSchema),
897
- qualifications: z6.array(
898
- z6.object({
899
- member: identifier,
900
- program: identifier,
901
- qualified: z6.boolean(),
902
- qualifiedAt: amount2
903
- })
904
- ),
905
- accounts: z6.array(
906
- referralAccountSchema.extend({ member: identifier, invitee: z6.string() })
907
- ),
908
- reviews: z6.array(
909
- z6.object({
910
- entitlement: identifier,
911
- member: identifier,
912
- program: identifier,
913
- reason: z6.string()
914
- })
915
- ),
916
- nextCursor: pageCursorSchema.nullable().default(null),
917
- /** @deprecated Use `nextCursor`, passed back as `cursor`. Removed in 2.0.0. */
918
- next: amount2.nullable()
919
- });
920
-
921
- // src/offers.ts
922
- import { z as z7 } from "zod";
923
- var quantity = z7.number().int().safe().nonnegative();
924
- var offerPriceSchema = pointsRewardSchema.extend({
925
- amount: z7.number().int().positive().max(1e4)
926
- });
927
- var offerLimitSchema = z7.object({ perMember: z7.number().int().positive().max(1e4) }).strict();
928
- var offerDefinitionSchema = z7.object({
929
- id: identifier,
930
- key: identifier.optional(),
931
- title: z7.string().trim().min(1).max(120),
932
- price: offerPriceSchema,
933
- reward: tierRewardSchema,
934
- stock: quantity.max(1e6),
935
- limit: offerLimitSchema.default({ perMember: 1 }),
936
- enabled: z7.boolean().default(true)
937
- }).strict();
938
- var offerAuthoringSchema = offerDefinitionSchema.omit({ id: true, title: true, enabled: true }).extend({
939
- ...authoringIdentityShape,
940
- title: z7.string().trim().min(1).max(120).optional()
941
- }).strict().transform((offer) => ({
942
- ...offer,
943
- title: offer.title ?? offer.reward.reward.title,
944
- enabled: true
945
- }));
946
- var offerArtifactSchema = z7.union([
947
- offerAuthoringSchema,
948
- z7.object({ code: z7.string().min(1).max(2e6) }).strict()
949
- ]);
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
- );
966
- var redeemOfferSchema = z7.object({ actionId: identifier }).strict();
967
- var redemptionBase = {
968
- id: identifier,
969
- offer: identifier,
970
- member: identifier,
971
- /**
972
- * @deprecated Use `id` to refer to a redemption. A redemption is fulfilled in the request that
973
- * makes it, so nothing is reserved beforehand; the ID refers to no other record. Removed in
974
- * 2.0.0.
975
- */
976
- reservation: identifier,
977
- price: offerPriceSchema,
978
- reward: tierRewardSchema,
979
- entitlement: identifier,
980
- revision: z7.number().int().positive(),
981
- redeemedAt: z7.number().int().safe().nonnegative()
982
- };
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
- );
994
- var offerControlSchema = z7.object({
995
- actionId: identifier,
996
- revision: z7.number().int().positive(),
997
- enabled: z7.boolean(),
998
- reason: z7.string().trim().min(1).max(500)
999
- }).strict();
1000
- var redemptionCancellationSchema = z7.object({
1001
- actionId: identifier,
1002
- revision: z7.number().int().positive(),
1003
- reason: z7.string().trim().min(1).max(500)
1004
- }).strict();
1005
- function defineOffer(input) {
1006
- return resourceHandle("offer", offerAuthoringSchema.parse(input));
1007
- }
1008
-
1009
- // src/wallet.ts
1010
- import { z as z8 } from "zod";
1011
- var solanaAddressSchema = z8.string().min(32).max(44).regex(/^[1-9A-HJ-NP-Za-km-z]+$/);
1012
- var walletChainSchema = z8.enum(["solana", "eip155", "cosmos"]);
1013
- var cosmosNetworkPattern = /^cosmos:[-_a-zA-Z0-9]{1,32}$/;
1014
- var cosmosNetworkSchema = z8.custom(
1015
- (value) => typeof value === "string" && cosmosNetworkPattern.test(value),
1016
- "Use a Cosmos network: cosmos:<chain ID>"
1017
- );
1018
- var cosmosDenomSchema = z8.string().regex(
1019
- /^[a-zA-Z][a-zA-Z0-9/:._-]{2,127}$/,
1020
- "Use a Cosmos bank denomination such as uatom or uosmo"
1021
- );
1022
- function cosmosChain(chain) {
1023
- if (typeof chain === "string" && !chain.startsWith("cosmos:")) {
1024
- throw new Error('Use a Cosmos network such as "cosmos:cosmoshub-4"');
1025
- }
1026
- const value = typeof chain === "string" ? { chainId: chain.slice("cosmos:".length) } : chain;
1027
- if (typeof value?.chainId !== "string") {
1028
- throw new Error(
1029
- 'Pass a Cosmos chain as { chainId } or a network such as "cosmos:cosmoshub-4"'
1030
- );
1031
- }
1032
- const network = `cosmos:${value.chainId}`;
1033
- if (!cosmosNetworkPattern.test(network)) {
1034
- throw new Error(
1035
- "A Cosmos chain ID has 1 to 32 letters, digits, hyphens or underscores"
1036
- );
1037
- }
1038
- if (value.chainInfo && value.chainInfo.chainId !== value.chainId) {
1039
- throw new Error("The chain info describes another chain ID");
1040
- }
1041
- return { ...value, network };
1042
- }
1043
- var solanaMainnet = "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp";
1044
- var evmAddressSchema = z8.string().regex(/^0x[0-9a-fA-F]{40}$/);
1045
- var cosmosAddressSchema = z8.string().min(8).max(90).regex(
1046
- /^(?:[a-z][a-z0-9]{0,82}1[02-9ac-hj-np-z]{38,}|[A-Z][A-Z0-9]{0,82}1[02-9AC-HJ-NP-Z]{38,})$/
1047
- );
1048
- var walletAddressInputSchema = z8.discriminatedUnion("chain", [
1049
- z8.object({ chain: z8.literal("solana"), address: solanaAddressSchema }).strict(),
1050
- z8.object({
1051
- chain: z8.literal("eip155"),
1052
- address: evmAddressSchema,
1053
- /** Shown in the sign-in message's Chain ID line only: links are chain-agnostic. Defaults to 1. */
1054
- chainId: z8.number().int().positive().safe().optional()
1055
- }).strict(),
1056
- z8.object({
1057
- chain: z8.literal("cosmos"),
1058
- network: cosmosNetworkSchema,
1059
- address: cosmosAddressSchema
1060
- }).strict()
1061
- ]);
1062
- var walletMessageChallengeSchema = z8.object({
1063
- id: z8.string().min(1).max(200),
1064
- purpose: z8.enum(["link", "sign-in"]),
1065
- chain: walletChainSchema,
1066
- network: cosmosNetworkSchema.nullable(),
1067
- /** Canonical (base58, EIP-55 or lowercase bech32). The signer must sign with this address. */
1068
- address: z8.string(),
1069
- message: z8.string().max(4096),
1070
- expiresAt: z8.number().int()
1071
- });
1072
- var walletSignatureSchema = z8.object({
1073
- challenge: z8.string().min(1).max(200),
1074
- /** solana: base58, 64 bytes · eip155: 0x and 130 hex digits (65 bytes) · cosmos: base64, 64 bytes (r‖s) */
1075
- signature: z8.string().min(1).max(256),
1076
- /** cosmos only: the base64 33-byte compressed secp256k1 key from signArbitrary's pub_key.value */
1077
- publicKey: z8.string().max(128).optional()
1078
- }).strict();
1079
- var linkedWalletSchema = z8.object({
1080
- chain: walletChainSchema,
1081
- network: cosmosNetworkSchema.nullable(),
1082
- address: z8.string(),
1083
- verifiedAt: z8.number().int().nonnegative(),
1084
- revision: z8.number().int().positive(),
1085
- /** True when this wallet can sign in: it was first used through wallet sign-in. Linking never enables sign-in. */
1086
- signIn: z8.boolean()
1087
- });
1088
- var walletUnlinkInputSchema = z8.object({ chain: walletChainSchema, address: z8.string().min(1).max(100) }).strict();
1089
- async function walletAddressInput(signer) {
1090
- const address = await signer.address();
1091
- switch (signer.chain) {
1092
- case "solana":
1093
- return { chain: "solana", address };
1094
- case "eip155":
1095
- return {
1096
- chain: "eip155",
1097
- address,
1098
- ...signer.chainId ? { chainId: await signer.chainId() } : {}
1099
- };
1100
- case "cosmos":
1101
- if (!signer.network) {
1102
- throw clientError(
1103
- "Choose the Cosmos chain for this wallet",
1104
- RelayErrorCode.InvalidInput
1105
- );
1106
- }
1107
- return { chain: "cosmos", network: signer.network, address };
1108
- }
1109
- }
1110
- var WALLETS_PER_CHAIN = 5;
1111
- var walletSignInFamilies = ["solana", "eip155", "cosmos"];
1112
- var walletSignInNetworkSchema = z8.enum(walletSignInFamilies);
1113
- var walletSignInNetworksSchema = z8.array(walletSignInNetworkSchema).max(walletSignInFamilies.length).refine((values) => new Set(values).size === values.length, {
1114
- message: "Duplicate wallet family"
1115
- }).transform(
1116
- (values) => walletSignInFamilies.filter((family) => values.includes(family))
1117
- );
1118
- function walletSignInNetwork(wallet) {
1119
- return wallet.chain;
1120
- }
1121
- function caip10(wallet, network) {
1122
- if (wallet.chain === "cosmos") {
1123
- if (!wallet.network || network && network !== wallet.network) {
1124
- throw new Error("A Cosmos wallet belongs to its own network");
1125
- }
1126
- return `${wallet.network}:${wallet.address}`;
1127
- }
1128
- const selected = network ?? (wallet.chain === "solana" ? solanaMainnet : "eip155:1");
1129
- const valid = wallet.chain === "solana" ? /^solana:[1-9A-HJ-NP-Za-km-z]{32}$/.test(selected) : isEvmChainId(selected);
1130
- if (!valid) {
1131
- throw new Error(`Use a ${wallet.chain} network for this wallet`);
1132
- }
1133
- return `${selected}:${wallet.address}`;
1134
- }
1135
- function isEvmChainId(value) {
1136
- return /^eip155:[1-9][0-9]{0,15}$/.test(value);
1137
- }
1138
- var evmChainIdSchema = z8.custom(
1139
- (value) => typeof value === "string" && isEvmChainId(value),
1140
- 'Use an EVM chain ID such as "eip155:8453"'
1141
- );
1142
- var units = z8.string().regex(/^(0|[1-9][0-9]*)$/);
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
- );
1161
-
1162
- export {
1163
- RelayErrorCode,
1164
- isRelayError,
1165
- RelayError,
1166
- asRelayError,
1167
- clientError,
1168
- parseInput,
1169
- pointLedgerPropertiesSchema,
1170
- createPointLedgerSchema,
1171
- pointLedgerSchema,
1172
- managedPointLedgerSchema,
1173
- pointLedgerDeclarationSchema,
1174
- pointLedgerArtifactSchema,
1175
- pointLedgerReferenceSchema,
1176
- pointBalanceSchema,
1177
- pointBalancesSchema,
1178
- PointEntryKind,
1179
- pointEntrySchema,
1180
- pointHistoryQuerySchema,
1181
- pointHistoryPageSchema,
1182
- engagementBudgetSchema,
1183
- engagementDefinitionSchema,
1184
- engagementScoreInputSchema,
1185
- engagementScoreSchema,
1186
- engagementPublishSchema,
1187
- engagementRuleSchema,
1188
- engagementPageQuerySchema,
1189
- engagementSettlementSchema,
1190
- engagementPageSchema,
1191
- engagementChangePreviewInputSchema,
1192
- engagementChangeSchema,
1193
- engagementChangePreviewSchema,
1194
- engagementRuleVersionPageSchema,
1195
- engagementVersionPageSchema,
1196
- engagementVersionQuerySchema,
1197
- engagementBoundaryPageSchema,
1198
- engagementArtifactSchema,
1199
- engagementDeploymentEntrySchema,
1200
- profileVisibilitySchema,
1201
- avatarProviderSchema,
1202
- profileDefaultProviderSchema,
1203
- profileDefaultsSchema,
1204
- avatarSeedSchema,
1205
- profileAvatarSchema,
1206
- profileSummarySchema,
1207
- displayNameSchema,
1208
- profileUpdateSchema,
1209
- ownProfileSchema,
1210
- profileCompletionQuerySchema,
1211
- profileCompletionSchema,
1212
- profileCompletionPageSchema,
1213
- profileReferralSchema,
1214
- profileSettingsSchema,
1215
- profileSettingsInputSchema,
1216
- profileModerationSchema,
1217
- managedProfileSchema,
1218
- AVATAR_UPLOAD_LIMIT,
1219
- avatarUploadTypes,
1220
- leaderboardWindowSchema,
1221
- leaderboardPrizeRewardSchema,
1222
- leaderboardPrizeSchema,
1223
- leaderboardSettlementPolicySchema,
1224
- leaderboardDefinitionSchema,
1225
- leaderboardDefinitionResponseSchema,
1226
- leaderboardAuthoringSchema,
1227
- leaderboardArtifactSchema,
1228
- publishedLeaderboardSchema,
1229
- leaderboardQuerySchema,
1230
- leaderboardRowSchema,
1231
- leaderboardPageSchema,
1232
- leaderboardPlacementSchema,
1233
- leaderboardPreviewSchema,
1234
- pointsMutationSchema,
1235
- pointsEntrySchema,
1236
- managedPointHistoryPageSchema,
1237
- pointsResultSchema,
1238
- pointsAccountSchema,
1239
- leaderboardExclusionSchema,
1240
- leaderboardGroupSchema,
1241
- leaderboardSettlementStatusSchema,
1242
- leaderboardSettlementSummarySchema,
1243
- leaderboardSettlementRowSchema,
1244
- leaderboardSettlementSchema,
1245
- leaderboardSettlementApprovalSchema,
1246
- referralDefinitionSchema,
1247
- referralAuthoringSchema,
1248
- referralArtifactSchema,
1249
- publishedReferralSchema,
1250
- referralAcceptSchema,
1251
- referralSuspensionSchema,
1252
- referralQualificationSchema,
1253
- referralRewardResolutionSchema,
1254
- referralControlSchema,
1255
- referralRelationshipSchema,
1256
- referralAccountSchema,
1257
- referralSummarySchema,
1258
- referralHistorySchema,
1259
- referralManagementSchema,
1260
- offerPriceSchema,
1261
- offerLimitSchema,
1262
- offerDefinitionSchema,
1263
- offerAuthoringSchema,
1264
- offerArtifactSchema,
1265
- offerAvailabilitySchema,
1266
- offerSchema,
1267
- redeemOfferSchema,
1268
- redemptionSchema,
1269
- offerControlSchema,
1270
- redemptionCancellationSchema,
1271
- defineOffer,
1272
- solanaAddressSchema,
1273
- walletChainSchema,
1274
- cosmosNetworkSchema,
1275
- cosmosDenomSchema,
1276
- cosmosChain,
1277
- solanaMainnet,
1278
- evmAddressSchema,
1279
- cosmosAddressSchema,
1280
- walletAddressInputSchema,
1281
- walletMessageChallengeSchema,
1282
- walletSignatureSchema,
1283
- linkedWalletSchema,
1284
- walletUnlinkInputSchema,
1285
- walletAddressInput,
1286
- WALLETS_PER_CHAIN,
1287
- walletSignInFamilies,
1288
- walletSignInNetworkSchema,
1289
- walletSignInNetworksSchema,
1290
- walletSignInNetwork,
1291
- caip10,
1292
- isEvmChainId,
1293
- evmChainIdSchema,
1294
- walletBalanceSchema
1295
- };