@domino-sdk/relay 1.0.0-next.9 → 1.0.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 (59) hide show
  1. package/README.md +1 -1
  2. package/dist/activity-DeKJsRry.d.ts +9112 -0
  3. package/dist/authoring.d.ts +1027 -233
  4. package/dist/authoring.js +478 -277
  5. package/dist/automatic-outcomes-B1xrETxm.d.ts +758 -0
  6. package/dist/avatar.d.ts +2 -2
  7. package/dist/browser-DFe7sWSN.d.ts +4154 -0
  8. package/dist/browser.d.ts +11 -2613
  9. package/dist/browser.js +8 -6
  10. package/dist/{integrations-Ba5TtqTv.d.ts → capability-error-DNMwKmlL.d.ts} +124 -76
  11. package/dist/{chunk-PHU5VDLR.js → chunk-36HTX2BM.js} +389 -169
  12. package/dist/chunk-6QJ3LADK.js +112 -0
  13. package/dist/{chunk-4LBUTHD6.js → chunk-BGGKNIRP.js} +1 -1
  14. package/dist/chunk-EYH5RDIE.js +496 -0
  15. package/dist/chunk-GQKYAQM6.js +84 -0
  16. package/dist/chunk-GUP7YRR4.js +42 -0
  17. package/dist/{chunk-X2F2RAR3.js → chunk-GZ6FJAXN.js} +380 -128
  18. package/dist/chunk-JON5SESL.js +2986 -0
  19. package/dist/chunk-MC6V6VMG.js +49 -0
  20. package/dist/chunk-NPGENI7K.js +37 -0
  21. package/dist/chunk-VFHHLN6A.js +284 -0
  22. package/dist/chunk-WJSSJ7AF.js +151 -0
  23. package/dist/{chunk-7Q4BGGT6.js → chunk-XFMSUPNS.js} +1 -1
  24. package/dist/{chunk-P6FK43GG.js → chunk-ZVIRG24J.js} +145 -42
  25. package/dist/{client-CT4-S5vc.d.ts → client-XiuFnug_.d.ts} +2161 -615
  26. package/dist/{submission-input-0OOGaq8c.d.ts → groups-Ck-OxzjD.d.ts} +916 -1139
  27. package/dist/identity-integration-GxAHdKR2.d.ts +58 -0
  28. package/dist/images-Dv-P5VBw.d.ts +234 -0
  29. package/dist/index.d.ts +13 -9
  30. package/dist/index.js +17 -6
  31. package/dist/internal.d.ts +82 -44
  32. package/dist/internal.js +43 -89
  33. package/dist/offers-Cy-e4o5x.d.ts +431 -0
  34. package/dist/{pages-D3titw5B.d.ts → outcomes-kVB-Juzs.d.ts} +2157 -1448
  35. package/dist/pages-BBYD21IE.d.ts +359 -0
  36. package/dist/participant-rewards-3duLb8YJ.d.ts +668 -0
  37. package/dist/portal-proxy.js +22 -4
  38. package/dist/{profiles-DDMFBRKe.d.ts → profiles-D2aFcOxu.d.ts} +15 -15
  39. package/dist/react/index.d.ts +3038 -1029
  40. package/dist/react/index.js +1627 -779
  41. package/dist/request-error-DWduJCGV.d.ts +62 -0
  42. package/dist/schema-DfJzH2ci.d.ts +5644 -0
  43. package/dist/schema.d.ts +15 -4168
  44. package/dist/schema.js +310 -81
  45. package/dist/server/index.d.ts +81498 -0
  46. package/dist/server/index.js +2520 -0
  47. package/dist/{streaks-CwGReWGt.d.ts → streaks-CWyq8Px5.d.ts} +2 -4
  48. package/dist/submission-input-BZkm6ohU.d.ts +290 -0
  49. package/dist/vite.d.ts +1 -1
  50. package/dist/vite.js +1 -0
  51. package/dist/{wallet-BGOfFkG9.d.ts → wallet-YssWxGg8.d.ts} +35 -38
  52. package/package.json +8 -2
  53. package/dist/chunk-QR7ZA2BJ.js +0 -257
  54. package/dist/chunk-YYD4QUBO.js +0 -2348
  55. package/dist/chunk-ZWY3R6B3.js +0 -26
  56. package/dist/collection-BGneJ6Bk.d.ts +0 -114
  57. package/dist/images-BTgk6OmC.d.ts +0 -1564
  58. package/dist/point-ledgers-iS00Z_v0.d.ts +0 -37
  59. package/dist/schema-Di3aLSiK.d.ts +0 -3532
@@ -0,0 +1,2520 @@
1
+ import {
2
+ activityTypeSchema,
3
+ activityTypes,
4
+ automaticCatchUpConfirmSchema,
5
+ automaticCatchUpInputSchema,
6
+ automaticCatchUpPreviewSchema,
7
+ automaticCatchUpResultSchema,
8
+ automaticOutcomePageSchema,
9
+ automaticOutcomeQuerySchema,
10
+ automaticSchedulingPageSchema,
11
+ automaticSchedulingQuerySchema,
12
+ automaticSchedulingRetrySchema,
13
+ automaticSchedulingSchema,
14
+ deploymentPreviewSchema,
15
+ deploymentRecordSchema,
16
+ deploymentResultSchema,
17
+ projectDeploymentSchema,
18
+ promoteDeploymentSchema,
19
+ publishDeploymentSchema,
20
+ rejectDeploymentSchema,
21
+ rollbackDeploymentSchema,
22
+ submitDeploymentSchema
23
+ } from "../chunk-VFHHLN6A.js";
24
+ import "../chunk-MC6V6VMG.js";
25
+ import {
26
+ identityIntegrationInputSchema,
27
+ identityIntegrationSchema,
28
+ identityIntegrationSecretSchema,
29
+ identityKindClaimSchema
30
+ } from "../chunk-WJSSJ7AF.js";
31
+ import {
32
+ imageAssetArtifactSchema
33
+ } from "../chunk-BGGKNIRP.js";
34
+ import "../chunk-GQKYAQM6.js";
35
+ import "../chunk-GUP7YRR4.js";
36
+ import {
37
+ allocateQuestSchema,
38
+ allocatedQuestSchema,
39
+ catalogDeploymentPreviewSchema,
40
+ catalogDeploymentSchema,
41
+ collectionBeginSchema,
42
+ collectionPreviewSchema,
43
+ collectionResolveSchema,
44
+ memberEnrollmentInputSchema,
45
+ publishQuestDraftSchema,
46
+ questCatalogSchema,
47
+ questDraftSchema,
48
+ questEnrollmentSchema,
49
+ questPublicationPreviewSchema,
50
+ rewardDeliveriesSchema,
51
+ rewardDeliverySchema,
52
+ saveQuestDraftSchema
53
+ } from "../chunk-EYH5RDIE.js";
54
+ import {
55
+ cosmosNetworkSchema,
56
+ createPointLedgerSchema,
57
+ engagementBoundaryPageSchema,
58
+ engagementChangePreviewInputSchema,
59
+ engagementChangePreviewSchema,
60
+ engagementChangeSchema,
61
+ engagementPageQuerySchema,
62
+ engagementPageSchema,
63
+ engagementPublishSchema,
64
+ engagementRuleSchema,
65
+ engagementVersionPageSchema,
66
+ engagementVersionQuerySchema,
67
+ evmChainIdSchema,
68
+ leaderboardExclusionSchema,
69
+ leaderboardGroupSchema,
70
+ leaderboardPageSchema,
71
+ leaderboardQuerySchema,
72
+ leaderboardSettlementApprovalSchema,
73
+ leaderboardSettlementSchema,
74
+ leaderboardSettlementSummarySchema,
75
+ linkedWalletSchema,
76
+ managedPointLedgerSchema,
77
+ managedProfileSchema,
78
+ offerControlSchema,
79
+ offerSchema,
80
+ pointLedgerSchema,
81
+ pointsAccountSchema,
82
+ pointsEntrySchema,
83
+ pointsMutationSchema,
84
+ pointsResultSchema,
85
+ profileModerationSchema,
86
+ profileSettingsInputSchema,
87
+ profileSettingsSchema,
88
+ publishedLeaderboardSchema,
89
+ publishedReferralSchema,
90
+ redemptionCancellationSchema,
91
+ redemptionSchema,
92
+ referralControlSchema,
93
+ referralHistorySchema,
94
+ referralManagementSchema,
95
+ solanaMainnet,
96
+ walletBalanceSchema,
97
+ walletSignInNetworksSchema,
98
+ walletUnlinkInputSchema
99
+ } from "../chunk-36HTX2BM.js";
100
+ import {
101
+ MANAGEMENT_TIMEOUT,
102
+ lifetime,
103
+ retryAfter,
104
+ retrying,
105
+ validTimeout
106
+ } from "../chunk-6QJ3LADK.js";
107
+ import {
108
+ RequestError,
109
+ isRequestError
110
+ } from "../chunk-NPGENI7K.js";
111
+ import "../chunk-XFMSUPNS.js";
112
+ import {
113
+ appIdentityKindSchema,
114
+ attemptSchema,
115
+ authProviderSchema,
116
+ beginHandoverSchema,
117
+ campaignEnrollmentSchema,
118
+ configurePickupSchema,
119
+ confirmHandoverSchema,
120
+ contentPerformancePageSchema,
121
+ contentPerformanceQuerySchema,
122
+ contentQualificationPageSchema,
123
+ contentQualificationQuerySchema,
124
+ counterHistoryQuerySchema,
125
+ counterHistorySchema,
126
+ counterModerationResultSchema,
127
+ counterModerationSchema,
128
+ createStockItemSchema,
129
+ entitlementCorrectionSchema,
130
+ entitlementSchema,
131
+ identifier,
132
+ memberCampaignEnrollmentInputSchema,
133
+ memberCampaignWithdrawalInputSchema,
134
+ memberIdentitySchema,
135
+ memberProgressSchema,
136
+ pickupAvailabilitySchema,
137
+ pickupCatalogSchema,
138
+ projectCalendarInputSchema,
139
+ projectCalendarSchema,
140
+ projectGroupKey,
141
+ publishedReleaseSchema,
142
+ questSettingsInputSchema,
143
+ snapshotSchema,
144
+ staffDecisionSchema,
145
+ stockItemSchema,
146
+ submitSchema,
147
+ trackerContentReadSchema,
148
+ trackerContentSchema,
149
+ trackerControlSchema,
150
+ trackerIngestResultSchema,
151
+ trackerIngestSchema,
152
+ trackerOutcomePageSchema,
153
+ trackerOutcomeQuerySchema,
154
+ trackerOutcomeRetrySchema,
155
+ trackerOutcomeSchema,
156
+ trackerPageSchema,
157
+ trackerPreviewInputSchema,
158
+ trackerPreviewSchema,
159
+ trackerQuerySchema,
160
+ trackerStatusSchema,
161
+ trackerSummarySchema
162
+ } from "../chunk-JON5SESL.js";
163
+
164
+ // src/server/webhooks.ts
165
+ import { z } from "zod";
166
+ var webhookEventSchema = z.object({
167
+ id: z.string().uuid(),
168
+ version: z.literal(1),
169
+ type: activityTypeSchema,
170
+ createdAt: z.number().int().nonnegative(),
171
+ organization: z.string(),
172
+ project: z.string(),
173
+ environment: z.enum(["test", "live"]),
174
+ data: z.record(z.string(), z.json())
175
+ });
176
+ var webhookInputSchema = z.object({
177
+ url: z.url().max(2048).refine((value) => {
178
+ const url = new URL(value);
179
+ return url.protocol === "https:" && !url.username && !url.password && !url.hash;
180
+ }, "Use an HTTPS URL without credentials or a fragment"),
181
+ types: z.array(activityTypeSchema).min(1).max(100).refine((v) => new Set(v).size === v.length)
182
+ }).strict();
183
+ var webhookUpdateSchema = webhookInputSchema.partial().extend({ enabled: z.boolean().optional() }).strict();
184
+ var webhookEndpointSchema = z.object({
185
+ ...webhookInputSchema.shape,
186
+ id: z.string().uuid(),
187
+ enabled: z.boolean(),
188
+ disabledReason: z.string().nullable(),
189
+ consecutiveFailures: z.number().int().nonnegative(),
190
+ createdAt: z.number(),
191
+ updatedAt: z.number()
192
+ });
193
+ var webhookSecretSchema = z.object({
194
+ endpoint: webhookEndpointSchema,
195
+ secret: z.string(),
196
+ previousValidUntil: z.number().nullable()
197
+ });
198
+ var webhookDeliverySchema = z.object({
199
+ id: z.string().uuid(),
200
+ endpoint: z.string().uuid(),
201
+ event: webhookEventSchema,
202
+ status: z.enum(["pending", "delivered", "failed", "skipped"]),
203
+ attempts: z.number().int().nonnegative(),
204
+ responseStatus: z.number().nullable(),
205
+ lastError: z.string().nullable(),
206
+ createdAt: z.number(),
207
+ deliveredAt: z.number().nullable(),
208
+ replayOf: z.string().uuid().nullable()
209
+ });
210
+ var webhookQuerySchema = z.object({
211
+ before: z.string().uuid().optional(),
212
+ limit: z.coerce.number().int().min(1).max(100).default(50)
213
+ }).strict();
214
+ var webhookDeliveryPageSchema = z.object({
215
+ items: z.array(webhookDeliverySchema),
216
+ next: z.string().uuid().nullable()
217
+ });
218
+ var WEBHOOK_MAX_BYTES = 64 * 1024;
219
+ async function verifyWebhook(input) {
220
+ const bytes = new TextEncoder().encode(input.body);
221
+ const tolerance = input.toleranceSeconds ?? 300;
222
+ const now = input.now ?? Date.now();
223
+ if (bytes.length > WEBHOOK_MAX_BYTES || !Number.isFinite(now) || !Number.isFinite(tolerance) || tolerance < 0 || tolerance > 300) {
224
+ throw new Error("Invalid webhook verification input");
225
+ }
226
+ const parts = input.signature.split(",");
227
+ const timestamps = parts.filter((part) => part.startsWith("t="));
228
+ const timestamp = timestamps[0]?.slice(2) ?? "";
229
+ const signatures = parts.filter((part) => /^v1=[a-f0-9]{64}$/.test(part)).map((part) => part.slice(3));
230
+ if (timestamps.length !== 1 || !/^\d{1,12}$/.test(timestamp) || Math.abs(now / 1e3 - Number(timestamp)) > tolerance || signatures.length < 1 || signatures.length > 2) {
231
+ throw new Error("Invalid or expired webhook signature");
232
+ }
233
+ const secrets = typeof input.secret === "string" ? [input.secret] : input.secret;
234
+ const message = new TextEncoder().encode(`${timestamp}.${input.body}`);
235
+ for (const secret of secrets) {
236
+ if (!secret) {
237
+ continue;
238
+ }
239
+ const key = await crypto.subtle.importKey(
240
+ "raw",
241
+ new TextEncoder().encode(secret),
242
+ { name: "HMAC", hash: "SHA-256" },
243
+ false,
244
+ ["verify"]
245
+ );
246
+ for (const signature of signatures) {
247
+ const digest = Uint8Array.from(
248
+ signature.match(/../g) ?? [],
249
+ (byte) => Number.parseInt(byte, 16)
250
+ );
251
+ if (await crypto.subtle.verify("HMAC", key, digest, message)) {
252
+ return webhookEventSchema.parse(JSON.parse(input.body));
253
+ }
254
+ }
255
+ }
256
+ throw new Error("Invalid webhook signature");
257
+ }
258
+
259
+ // src/server/resource-lifecycle.ts
260
+ import { z as z2 } from "zod";
261
+ var resourceLifecycleKindSchema = z2.enum([
262
+ "tracker",
263
+ "referral",
264
+ "leaderboard",
265
+ "engagement",
266
+ "collection",
267
+ "quest-type",
268
+ "image",
269
+ "point-ledger"
270
+ ]);
271
+ var managedResourceSchema = z2.object({
272
+ kind: resourceLifecycleKindSchema,
273
+ id: identifier,
274
+ key: identifier.nullable(),
275
+ title: z2.string(),
276
+ archivedAt: z2.number().int().nonnegative().nullable()
277
+ });
278
+ var resourceLifecycleInputSchema = z2.object({
279
+ actionId: z2.string().uuid(),
280
+ kind: resourceLifecycleKindSchema,
281
+ resource: identifier,
282
+ archived: z2.boolean(),
283
+ reason: z2.string().trim().min(1).max(500),
284
+ expectedArchivedAt: z2.number().int().nonnegative().nullable().optional()
285
+ }).strict();
286
+ var resourceLifecycleResultSchema = z2.object({
287
+ resource: managedResourceSchema,
288
+ changed: z2.boolean()
289
+ });
290
+
291
+ // src/server/index.ts
292
+ import { z as z7 } from "zod";
293
+
294
+ // src/server/errors.ts
295
+ var ManagementErrorCode = {
296
+ /** The input or an option failed validation before anything was sent (kind `client`). */
297
+ InvalidInput: "invalid-input",
298
+ /** The client's `getToken` failed before anything was sent (kind `client` or `network`). */
299
+ Credential: "credential",
300
+ Network: "network",
301
+ Timeout: "timeout",
302
+ Aborted: "aborted",
303
+ InvalidResponse: "invalid-response"
304
+ };
305
+ var uncertainStatuses = /* @__PURE__ */ new Set([500, 502, 504]);
306
+ function uncertainOutcome(init) {
307
+ if (init.method === void 0 || init.method === "GET") {
308
+ return false;
309
+ }
310
+ switch (init.kind) {
311
+ case "network":
312
+ case "timeout":
313
+ case "aborted":
314
+ return true;
315
+ case "http":
316
+ return uncertainStatuses.has(init.status ?? 0);
317
+ case "invalid-response":
318
+ return (init.status ?? 0) >= 200 && (init.status ?? 0) < 300;
319
+ default:
320
+ return false;
321
+ }
322
+ }
323
+ var managementErrorBrand = /* @__PURE__ */ Symbol.for("@domino-sdk/relay.ManagementError");
324
+ function isManagementError(value) {
325
+ return isRequestError(value) && value[managementErrorBrand] === true;
326
+ }
327
+ var ManagementError = class extends RequestError {
328
+ name = "ManagementError";
329
+ [managementErrorBrand] = true;
330
+ /** The rest of the server's error body besides `error` and `code`, such as `moved`; absent when there is none. */
331
+ details;
332
+ /** The request's method; absent when the call failed before forming a request. */
333
+ method;
334
+ /** The management API path, below `/management/v1`, without its query; absent like `method`. */
335
+ path;
336
+ constructor(init) {
337
+ super(init.message, {
338
+ kind: init.kind,
339
+ uncertain: init.uncertain ?? uncertainOutcome(init),
340
+ status: init.status,
341
+ code: init.code,
342
+ operationId: init.actionId,
343
+ replaySafe: init.replaySafe,
344
+ retryAfter: init.retryAfter,
345
+ cause: init.cause
346
+ });
347
+ this.details = init.details && Object.keys(init.details).length ? init.details : void 0;
348
+ this.method = init.method;
349
+ this.path = init.path;
350
+ }
351
+ };
352
+ var DEFAULT_MANAGEMENT_TIMEOUT = MANAGEMENT_TIMEOUT;
353
+
354
+ // src/server/hosting.ts
355
+ import { z as z4 } from "zod";
356
+
357
+ // src/server/starters.ts
358
+ import { z as z3 } from "zod";
359
+ var starterTemplates = [
360
+ {
361
+ id: "campaign",
362
+ title: "Campaign tour",
363
+ summary: "A neutral quest app with a guided tour of every quest kind. The blank canvas for anything."
364
+ },
365
+ {
366
+ id: "classic",
367
+ title: "Classic questboard",
368
+ summary: "The familiar Domino portal: quests in a grid grouped by section, a claim page, points, and a leaderboard."
369
+ },
370
+ {
371
+ id: "waitlist",
372
+ title: "Waitlist",
373
+ summary: "Collect sign-ups before launch. People move up the line by inviting friends."
374
+ },
375
+ {
376
+ id: "referral",
377
+ title: "Referral program",
378
+ summary: "Give every member an invite link and reward them when friends join and qualify."
379
+ },
380
+ {
381
+ id: "discord",
382
+ title: "Discord activation",
383
+ summary: "Turn new Discord members into regulars with quests for joining, introducing themselves, and taking part, rewarded with roles."
384
+ },
385
+ {
386
+ id: "api",
387
+ title: "API",
388
+ summary: "A headless Worker with typed routes and interactive API docs, for plugging Domino into your own product."
389
+ }
390
+ ];
391
+ var starterIdSchema = z3.enum(
392
+ starterTemplates.map((template) => template.id)
393
+ );
394
+
395
+ // src/server/hosting.ts
396
+ var outputPathSchema = z4.string().min(1).max(512).refine(
397
+ (path) => path.split("/").every(
398
+ (part) => /^[\w-][\w.-]*$/.test(part) && part !== "node_modules"
399
+ ),
400
+ "Expected a relative build output path without hidden segments"
401
+ );
402
+ var appRoutingSchema = z4.enum(["legacy", "transparent"]).default("legacy");
403
+ var APP_SECRET_LIMIT = 50;
404
+ var appSecretNameSchema = z4.string().regex(
405
+ /^[A-Z_][A-Z0-9_]{0,63}$/,
406
+ "Use 1-64 uppercase letters, digits, and underscores, not starting with a digit"
407
+ ).refine(
408
+ (name) => !name.startsWith("DOMINO_") && name !== "ASSETS",
409
+ "DOMINO_ names and ASSETS are reserved for Domino's own bindings"
410
+ );
411
+ var appSecretValueSchema = z4.string().min(1).refine(
412
+ (value) => new TextEncoder().encode(value).length <= 5120,
413
+ "Secret values can be at most 5 KiB"
414
+ );
415
+ var appSecretInputSchema = z4.object({ value: appSecretValueSchema }).strict();
416
+ var appSecretSchema = z4.object({
417
+ name: appSecretNameSchema,
418
+ updatedAt: z4.number(),
419
+ updatedBy: z4.string()
420
+ });
421
+ var appSecretDeclarationSchema = z4.object({
422
+ description: z4.string().trim().min(1).max(500),
423
+ required: z4.boolean().default(true)
424
+ }).strict();
425
+ var appSecretDeclarationsSchema = z4.record(appSecretNameSchema, appSecretDeclarationSchema).refine(
426
+ (secrets) => Object.keys(secrets).length <= APP_SECRET_LIMIT,
427
+ `Declare at most ${APP_SECRET_LIMIT} app secrets`
428
+ );
429
+ var appSecretListSchema = z4.object({
430
+ secrets: z4.array(appSecretSchema),
431
+ declared: z4.array(appSecretDeclarationSchema.extend({ name: appSecretNameSchema })).default([])
432
+ });
433
+ var hostedAppSecretsSchema = z4.object({ secrets: z4.record(appSecretNameSchema, appSecretValueSchema) }).strict();
434
+ var appScripts = {
435
+ routing: appRoutingSchema,
436
+ devScript: z4.string().regex(/^[\w:-]+$/),
437
+ checkScript: z4.string().regex(/^[\w:-]+$/),
438
+ buildScript: z4.string().regex(/^[\w:-]+$/)
439
+ };
440
+ var workerSettings = {
441
+ runWorkerFirst: z4.boolean().default(false),
442
+ main: outputPathSchema.refine(
443
+ (path) => /\.m?js$/.test(path),
444
+ "Expected a compiled JavaScript entry"
445
+ ),
446
+ compatibilityDate: z4.string().regex(/^\d{4}-\d{2}-\d{2}$/),
447
+ compatibilityFlags: z4.array(z4.string().min(1)).max(50).default([]),
448
+ vars: z4.record(
449
+ z4.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/).refine((name) => name !== "ASSETS"),
450
+ z4.string()
451
+ ).default({}),
452
+ secrets: appSecretDeclarationsSchema.default({})
453
+ };
454
+ var distinctBindings = (worker) => !Object.keys(worker.secrets).some((name) => name in worker.vars);
455
+ var distinctBindingsMessage = {
456
+ message: "A name can't be both an app var and a declared secret",
457
+ path: ["secrets"]
458
+ };
459
+ var hostedAppSchema = z4.discriminatedUnion("kind", [
460
+ z4.object({
461
+ kind: z4.literal("static"),
462
+ directory: outputPathSchema,
463
+ ...appScripts
464
+ }).strict(),
465
+ z4.object({
466
+ kind: z4.literal("worker"),
467
+ directory: outputPathSchema,
468
+ assetsDirectory: outputPathSchema.optional(),
469
+ ...appScripts,
470
+ ...workerSettings
471
+ }).strict().refine(distinctBindings, distinctBindingsMessage)
472
+ ]);
473
+ var repositorySchema = z4.object({
474
+ id: z4.string().uuid(),
475
+ organization: identifier,
476
+ project: identifier,
477
+ remote: z4.string().url(),
478
+ defaultBranch: z4.string(),
479
+ status: z4.enum(["provisioning", "ready"])
480
+ });
481
+ var createRepositorySchema = z4.object({
482
+ /** Omitted: the starter chosen at project setup, else `campaign`. */
483
+ starter: starterIdSchema.optional()
484
+ }).strict();
485
+ var deviceStartSchema = z4.object({
486
+ challenge: z4.string().regex(/^[a-f0-9]{64}$/)
487
+ }).strict();
488
+ var deviceRedeemSchema = z4.object({
489
+ id: z4.string().uuid(),
490
+ verifier: z4.string().min(43).max(128)
491
+ }).strict();
492
+ var deviceApproveSchema = z4.object({
493
+ id: z4.string().uuid(),
494
+ code: z4.string().regex(/^[A-F0-9]{4}-[A-F0-9]{4}$/)
495
+ }).strict();
496
+ var commitSchema = z4.string().regex(/^[a-f0-9]{40}$/);
497
+ var stageRequestSchema = z4.object({
498
+ commit: commitSchema,
499
+ requestId: z4.string().uuid()
500
+ }).strict();
501
+ var buildIdentitySchema = z4.object({
502
+ routing: appRoutingSchema,
503
+ slug: z4.string().min(1).max(35).regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/).optional(),
504
+ runtime: z4.enum(["simulation", "hosted-test"]).default("simulation"),
505
+ id: z4.string().uuid(),
506
+ repository: z4.string().uuid(),
507
+ organization: identifier,
508
+ project: identifier,
509
+ commit: commitSchema,
510
+ createdAt: z4.number(),
511
+ actor: z4.string(),
512
+ commitMessage: z4.string().max(500).optional()
513
+ });
514
+ var buildPhaseSchema = z4.enum([
515
+ "queued",
516
+ "source",
517
+ "install",
518
+ "check",
519
+ "build",
520
+ "deploy",
521
+ "ready",
522
+ "failed"
523
+ ]);
524
+ var buildStatusSchema = z4.object({
525
+ phase: buildPhaseSchema,
526
+ failedPhase: buildPhaseSchema.optional(),
527
+ updatedAt: z4.number(),
528
+ message: z4.string()
529
+ });
530
+ var hostedBuildSchema = buildIdentitySchema.extend({
531
+ ...buildStatusSchema.shape,
532
+ finished: z4.boolean(),
533
+ current: z4.boolean(),
534
+ stagingUrl: z4.string().url()
535
+ });
536
+ var stagingAccessModeSchema = z4.enum(["console", "password"]);
537
+ var stagingAccessSchema = z4.object({ mode: stagingAccessModeSchema });
538
+ var stagingAccessInputSchema = z4.discriminatedUnion("mode", [
539
+ z4.object({ mode: z4.literal("console") }).strict(),
540
+ z4.object({
541
+ mode: z4.literal("password"),
542
+ password: z4.string().min(8).max(128)
543
+ }).strict()
544
+ ]);
545
+ var stagingPathSchema = z4.string().max(2048).refine(
546
+ (path) => path.startsWith("/") && !path.startsWith("//") && !path.includes("\\"),
547
+ "Expected a path on the staging host"
548
+ );
549
+ var stagingLinkSchema = z4.object({
550
+ url: z4.string().url(),
551
+ expiresAt: z4.number()
552
+ });
553
+ var buildSnapshotSchema = z4.object({
554
+ builds: z4.array(hostedBuildSchema),
555
+ current: hostedBuildSchema.nullable(),
556
+ selected: hostedBuildSchema.nullable(),
557
+ logs: z4.string()
558
+ });
559
+ var assetPathSchema = z4.string().max(512).refine(
560
+ (path) => path.startsWith("/") && // oxlint-disable-next-line no-control-regex -- Asset paths must reject control characters.
561
+ !/[\\\u0000-\u001f?#%]/.test(path) && path.slice(1).split("/").every((part) => part.length > 0 && !part.startsWith(".")),
562
+ "Expected a public asset path without hidden segments"
563
+ );
564
+ var base64Schema = z4.string().regex(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/);
565
+ var stagedDeploymentLimits = {
566
+ /** Bytes of JSON, uncompressed. */
567
+ size: 64e6,
568
+ /** Bytes of the Brotli-compressed object. */
569
+ compressedSize: 1e7
570
+ };
571
+ var stagedDeploymentSchema = z4.object({
572
+ encoding: z4.literal("br"),
573
+ sha256: z4.string().regex(/^[0-9a-f]{64}$/),
574
+ compressedSize: z4.number().int().positive().max(stagedDeploymentLimits.compressedSize),
575
+ size: z4.number().int().positive().max(stagedDeploymentLimits.size)
576
+ }).strict();
577
+ var stagedDeploymentContentSchema = stagedDeploymentSchema.extend({
578
+ content: z4.string().max(Math.ceil(stagedDeploymentLimits.compressedSize / 3) * 4)
579
+ }).strict();
580
+ var stagedDeploymentKey = (build, sha256) => `builds/${build}/deployment/${sha256}.br`;
581
+ var artifactFields = {
582
+ routing: appRoutingSchema,
583
+ worker: z4.object({
584
+ ...workerSettings,
585
+ modules: z4.array(
586
+ z4.object({
587
+ path: outputPathSchema.refine((path) => path !== "metadata"),
588
+ type: z4.enum([
589
+ "application/javascript+module",
590
+ "application/wasm",
591
+ "text/plain",
592
+ "application/octet-stream"
593
+ ]),
594
+ content: base64Schema.max(14e6)
595
+ }).strict()
596
+ ).min(1).max(500)
597
+ }).strict().refine(distinctBindings, distinctBindingsMessage).optional(),
598
+ assets: z4.array(
599
+ z4.object({
600
+ path: assetPathSchema,
601
+ content: base64Schema.max(14e6),
602
+ size: z4.number().int().min(0).max(1e7)
603
+ }).strict()
604
+ ).max(500)
605
+ };
606
+ var buildArtifactsSchema = z4.discriminatedUnion("format", [
607
+ z4.object({
608
+ format: z4.literal(1),
609
+ ...artifactFields,
610
+ quests: z4.unknown(),
611
+ catalog: z4.unknown()
612
+ }).strict(),
613
+ z4.object({
614
+ format: z4.literal(2),
615
+ ...artifactFields,
616
+ deployment: stagedDeploymentSchema,
617
+ images: z4.array(imageAssetArtifactSchema).max(10)
618
+ }).strict()
619
+ ]).superRefine((value, ctx) => {
620
+ if (value.worker) {
621
+ const modules = value.worker.modules;
622
+ if (new Set(modules.map((m) => m.path)).size !== modules.length) {
623
+ ctx.addIssue({
624
+ code: "custom",
625
+ message: "Duplicate Worker module paths"
626
+ });
627
+ }
628
+ if (!modules.some(
629
+ (m) => m.path === value.worker?.main && m.type === "application/javascript+module"
630
+ )) {
631
+ ctx.addIssue({
632
+ code: "custom",
633
+ message: "Worker entry module is missing"
634
+ });
635
+ }
636
+ if (modules.reduce(
637
+ (sum, m) => sum + m.content.length * 3 / 4 - (m.content.endsWith("==") ? 2 : m.content.endsWith("=") ? 1 : 0),
638
+ 0
639
+ ) > 1e7) {
640
+ ctx.addIssue({
641
+ code: "custom",
642
+ message: "Worker modules exceed 10 MB"
643
+ });
644
+ }
645
+ }
646
+ if (new Set(value.assets.map((a) => a.path)).size !== value.assets.length) {
647
+ ctx.addIssue({ code: "custom", message: "Duplicate asset paths" });
648
+ }
649
+ if (!value.worker && !value.assets.some((a) => a.path === "/index.html")) {
650
+ ctx.addIssue({
651
+ code: "custom",
652
+ message: "Build must include index.html"
653
+ });
654
+ }
655
+ if (value.assets.reduce((sum, a) => sum + a.size, 0) > 1e7) {
656
+ ctx.addIssue({ code: "custom", message: "Staging assets exceed 10 MB" });
657
+ }
658
+ });
659
+
660
+ // src/server/development.ts
661
+ import { z as z5 } from "zod";
662
+ var developmentPreflightSchema = z5.object({
663
+ organization: z5.string(),
664
+ project: z5.string(),
665
+ environment: z5.enum(["test", "live"]),
666
+ identity: z5.object({
667
+ exchange: z5.literal("supported"),
668
+ activeIntegrations: z5.number().int().nonnegative()
669
+ }).optional(),
670
+ staging: z5.enum(["configured", "blocked"]),
671
+ development: z5.object({
672
+ status: z5.enum(["configured", "blocked"]),
673
+ // How `domino dev` reaches the preview origin: a Cloudflare tunnel, or a direct route on a
674
+ // local development stack. APIs that predate the field use tunnels.
675
+ transport: z5.enum(["tunnel", "direct"]).default("tunnel"),
676
+ missing: z5.array(z5.string()),
677
+ authentication: z5.array(z5.string())
678
+ }),
679
+ checks: z5.array(
680
+ z5.object({
681
+ id: z5.string(),
682
+ status: z5.enum(["ok", "error"]),
683
+ message: z5.string(),
684
+ missing: z5.array(z5.string()).optional(),
685
+ issues: z5.array(z5.string()).optional()
686
+ })
687
+ )
688
+ });
689
+
690
+ // src/server/hosted.ts
691
+ import { z as z6 } from "zod";
692
+ var hostedKeyPermissions = ["read", "points", "ingest"];
693
+ var hostedKeyPermissionList = z6.array(z6.string()).transform(
694
+ (values) => values.filter(
695
+ (value) => hostedKeyPermissions.includes(value)
696
+ )
697
+ );
698
+ var hostedManagementBindings = [
699
+ "DOMINO_MANAGEMENT_KEY",
700
+ "DOMINO_API_URL",
701
+ "DOMINO_ORGANIZATION",
702
+ "DOMINO_PROJECT",
703
+ "DOMINO_ENVIRONMENT"
704
+ ];
705
+ var hostedKeySecretSchema = z6.string().regex(/^dhk_[A-Za-z0-9_-]{43}$/, "Expected a hosted app key");
706
+ var hostedKeySchema = z6.object({
707
+ id: z6.string().uuid(),
708
+ token: hostedKeySecretSchema,
709
+ organization: identifier,
710
+ project: identifier,
711
+ environment: z6.enum(["test", "live"]),
712
+ permissions: hostedKeyPermissionList,
713
+ expiresAt: z6.number().nullable()
714
+ }).strict();
715
+ var hostedDeploymentKeySchema = hostedKeySchema.extend({ apiUrl: z6.string().url() }).strict();
716
+ function hostedManagementClient(env) {
717
+ const missing = hostedManagementBindings.filter((name) => !env[name]);
718
+ if (missing.length) {
719
+ throw new Error(
720
+ `Missing ${missing.join(", ")}. Domino sets these for hosted apps and domino dev; update the project's vite.config.ts to forward them in development.`
721
+ );
722
+ }
723
+ const environment = z6.enum(["test", "live"]).parse(env.DOMINO_ENVIRONMENT);
724
+ const token = env.DOMINO_MANAGEMENT_KEY;
725
+ return createManagementClient({
726
+ baseUrl: env.DOMINO_API_URL.replace(/\/+$/, ""),
727
+ getToken: async () => token,
728
+ organization: env.DOMINO_ORGANIZATION,
729
+ project: env.DOMINO_PROJECT,
730
+ environment
731
+ });
732
+ }
733
+
734
+ // src/server/index.ts
735
+ var environmentSchema = z7.enum(["test", "live"]);
736
+ var roleSchema = z7.enum(["editor", "reviewer", "staff"]);
737
+ var permissionSchema = z7.enum([
738
+ "read",
739
+ "publish",
740
+ "review",
741
+ "confirm",
742
+ "handover",
743
+ "inventory",
744
+ "access",
745
+ "points",
746
+ /**
747
+ * Custom tracker ingestion only (`trackers.ingest`), such as for an indexer's key. Editors and
748
+ * hosted-app keys hold it.
749
+ */
750
+ "ingest",
751
+ /**
752
+ * Enrolling members from a server (`quests.enroll`), which vouches for their consent. Editors
753
+ * hold it; hosted-app keys do not.
754
+ */
755
+ "enroll"
756
+ ]);
757
+ var permissionListSchema = z7.array(z7.string()).transform(
758
+ (values) => values.filter(
759
+ (value) => permissionSchema.safeParse(value).success
760
+ )
761
+ );
762
+ var rolePermissions = {
763
+ editor: ["read", "publish", "inventory", "points", "ingest", "enroll"],
764
+ reviewer: ["read", "review"],
765
+ staff: ["read", "confirm", "handover"]
766
+ };
767
+ var projectSetupSchema = z7.object({
768
+ mode: z7.enum(["new", "existing"]),
769
+ brief: z7.string().trim().min(1).max(4e3)
770
+ }).strict();
771
+ var projectSchema = z7.object({
772
+ slug: z7.string().min(1).max(35).regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),
773
+ /** A response, so fields a newer server adds to the setup are dropped, not rejected. */
774
+ setup: z7.object(projectSetupSchema.shape).optional(),
775
+ /** The starter chosen at setup. A plain string, so later starters still parse. */
776
+ starter: z7.string().optional(),
777
+ id: z7.string().min(1),
778
+ organization: identifier,
779
+ project: identifier,
780
+ name: z7.string(),
781
+ subtitle: z7.string(),
782
+ initials: z7.string(),
783
+ color: z7.string(),
784
+ permissions: permissionListSchema,
785
+ environments: z7.array(environmentSchema)
786
+ });
787
+ var projectInputSchema = z7.object({
788
+ actionId: identifier,
789
+ name: z7.string().trim().min(1).max(80),
790
+ setup: projectSetupSchema.optional(),
791
+ /** The starter a new hosted app begins from, with `setup.mode` "new". */
792
+ starter: starterIdSchema.optional()
793
+ }).strict();
794
+ var projectDeletionInputSchema = z7.object({ confirm: z7.string().min(1).max(80) }).strict();
795
+ var projectDeletionSchema = z7.object({
796
+ project: identifier,
797
+ purgeAfter: z7.number().int()
798
+ });
799
+ var projectTransferInputSchema = z7.object({ organization: identifier, confirm: z7.string().min(1).max(80) }).strict();
800
+ var projectTransferSchema = z7.object({
801
+ organization: identifier,
802
+ project: identifier
803
+ });
804
+ var grantSchema = z7.object({
805
+ subject: z7.string().min(1).max(200),
806
+ roles: z7.array(roleSchema),
807
+ environments: z7.array(environmentSchema)
808
+ }).strict();
809
+ var grantRecordSchema = z7.object(grantSchema.shape);
810
+ var stockAdditionSchema = z7.object({
811
+ item: identifier,
812
+ quantity: z7.number().int(),
813
+ actionId: identifier
814
+ });
815
+ var completionRevokeSchema = z7.object({
816
+ actionId: identifier,
817
+ reason: z7.string().trim().min(1).max(500),
818
+ freeOccurrence: z7.boolean().default(false)
819
+ }).strict();
820
+ var RevokedEntitlementOutcome = {
821
+ /** No other completion grants the reward: it is void, after cancelling a handover in progress. */
822
+ Voided: "voided",
823
+ /** Lowered to the best tier another completion grants, after cancelling a handover in progress. */
824
+ Downgraded: "downgraded",
825
+ /** Another completion grants the same tier, or it was already void. */
826
+ Kept: "kept",
827
+ /** Already collected: its earned tier follows the other completions, and the item stays handed over. */
828
+ Flagged: "flagged"
829
+ };
830
+ var RevokedDeliveryOutcome = {
831
+ /** The role was delivered and stays: remove it in Discord if appropriate. */
832
+ Flagged: "flagged",
833
+ /** The grant was stopped before any call to Discord. */
834
+ Cancelled: "cancelled",
835
+ /** The grant was stopped, but a call to Discord may already have been sent and can still land. */
836
+ InFlight: "in-flight",
837
+ /** The grant had failed, so Discord never received the role. */
838
+ NotDelivered: "not-delivered"
839
+ };
840
+ var RevokedReferralOutcome = {
841
+ /** The inviter's rewards for this member are reversed. */
842
+ Unqualified: "unqualified",
843
+ /** Qualified on another accepted completion of the program's quest instead. */
844
+ Requalified: "requalified"
845
+ };
846
+ var entitlementOutcomeSchema = z7.string().min(1).max(64);
847
+ var deliveryOutcomeSchema = z7.string().min(1).max(64);
848
+ var referralOutcomeSchema = z7.string().min(1).max(64);
849
+ var completionRevocationSchema = z7.object({
850
+ completion: identifier,
851
+ quest: identifier,
852
+ member: identifier,
853
+ revokedAt: z7.number(),
854
+ occurrenceFreed: z7.boolean(),
855
+ points: z7.array(
856
+ z7.object({
857
+ entry: identifier,
858
+ balance: identifier,
859
+ reversal: identifier.nullable(),
860
+ reversed: z7.number().int(),
861
+ unreversed: z7.number().int()
862
+ })
863
+ ),
864
+ entitlements: z7.array(
865
+ z7.object({
866
+ entitlement: identifier,
867
+ reward: identifier,
868
+ outcome: entitlementOutcomeSchema,
869
+ status: z7.string()
870
+ })
871
+ ),
872
+ deliveries: z7.array(
873
+ z7.object({
874
+ delivery: z7.string(),
875
+ roleId: z7.string(),
876
+ outcome: deliveryOutcomeSchema,
877
+ /**
878
+ * By Relay's records, another accepted, unrevoked completion of the member also granted this
879
+ * role to the same Discord account and server. Relay does not read Discord's membership.
880
+ */
881
+ stillGranted: z7.boolean()
882
+ })
883
+ ),
884
+ referrals: z7.array(
885
+ z7.object({
886
+ program: identifier,
887
+ outcome: referralOutcomeSchema
888
+ })
889
+ ),
890
+ streakMilestone: z7.boolean()
891
+ });
892
+ var accessSchema = z7.object({
893
+ actor: z7.string(),
894
+ organization: z7.string(),
895
+ admin: z7.boolean(),
896
+ local: z7.boolean(),
897
+ projects: z7.array(projectSchema)
898
+ });
899
+ var querySchema = z7.object({
900
+ q: z7.string().max(200).default(""),
901
+ filter: z7.string().max(50).default("all"),
902
+ offset: z7.coerce.number().int().min(0).max(1e6).default(0),
903
+ limit: z7.coerce.number().int().min(1).max(100).default(25)
904
+ });
905
+ var accountProfileSchema = z7.object({
906
+ name: z7.string().optional(),
907
+ /** The account's handle, where the provider has one (X and Discord). */
908
+ username: z7.string().optional(),
909
+ email: z7.string().optional(),
910
+ emailVerified: z7.boolean().default(false),
911
+ imageUrl: z7.string().url().optional()
912
+ });
913
+ var memberAccountSchema = z7.object({
914
+ /** `wallet` for wallet sign-in, `account` for every other connected account. */
915
+ kind: z7.enum(["account", "wallet"]),
916
+ provider: z7.string(),
917
+ subject: z7.string(),
918
+ signInEnabled: z7.boolean(),
919
+ profile: accountProfileSchema.optional()
920
+ });
921
+ var operationSchema = z7.object({
922
+ target: z7.string(),
923
+ paused: z7.boolean(),
924
+ revision: z7.number().int(),
925
+ reason: z7.string(),
926
+ actor: z7.string().nullable(),
927
+ changedAt: z7.number()
928
+ });
929
+ var operationInputSchema = z7.object({
930
+ target: z7.union([
931
+ z7.literal("redemptions"),
932
+ z7.string().regex(/^quest:[\w-]+$/)
933
+ ]),
934
+ paused: z7.boolean(),
935
+ revision: z7.number().int().nonnegative(),
936
+ reason: z7.string().trim().min(1).max(500),
937
+ actionId: identifier
938
+ }).strict();
939
+ var questLifecycleInputSchema = z7.object({
940
+ quest: identifier,
941
+ expectedRelease: identifier.optional(),
942
+ archived: z7.boolean(),
943
+ reason: z7.string().trim().min(1).max(500),
944
+ actionId: identifier
945
+ }).strict();
946
+ var questLifecycleSchema = z7.object({
947
+ quest: identifier,
948
+ key: identifier.nullable(),
949
+ title: z7.string(),
950
+ release: identifier,
951
+ lifecycle: z7.enum(["active", "paused", "archived"]),
952
+ changed: z7.boolean()
953
+ });
954
+ var memberSchema = z7.object({
955
+ id: z7.string(),
956
+ accounts: z7.array(memberAccountSchema).default([]),
957
+ attempts: z7.number(),
958
+ completions: z7.number(),
959
+ rewards: z7.number(),
960
+ lastActivity: z7.number().nullable()
961
+ });
962
+ var personSchema = z7.object({
963
+ id: z7.string(),
964
+ accounts: z7.array(memberAccountSchema).default([])
965
+ });
966
+ var metricsSchema = z7.object({
967
+ quests: z7.number(),
968
+ members: z7.number(),
969
+ attempts: z7.number(),
970
+ completions: z7.number(),
971
+ review: z7.number(),
972
+ failed: z7.number(),
973
+ entitlements: z7.number()
974
+ });
975
+ var readinessSchema = z7.object({
976
+ checks: z7.array(
977
+ z7.object({
978
+ id: z7.string(),
979
+ status: z7.enum(["ready", "blocked"]),
980
+ title: z7.string(),
981
+ detail: z7.string()
982
+ })
983
+ )
984
+ });
985
+ var inventorySchema = z7.object({
986
+ item: z7.string(),
987
+ name: z7.string().nullable().default(null),
988
+ available: z7.number(),
989
+ reserved: z7.number(),
990
+ allocated: z7.number().default(0)
991
+ });
992
+ var auditRecordSchema = z7.object({
993
+ id: z7.string(),
994
+ action: z7.string(),
995
+ actor: z7.string().nullable(),
996
+ detail: z7.string(),
997
+ at: z7.number(),
998
+ attempt: z7.string().nullable()
999
+ });
1000
+ var pageSchema = z7.object({
1001
+ snapshot: snapshotSchema,
1002
+ members: z7.array(memberSchema),
1003
+ people: z7.array(personSchema).default([]),
1004
+ metrics: metricsSchema,
1005
+ total: z7.number(),
1006
+ offset: z7.number(),
1007
+ limit: z7.number(),
1008
+ inventory: z7.array(inventorySchema),
1009
+ operations: z7.array(operationSchema).default([]),
1010
+ audit: z7.array(auditRecordSchema).default([]),
1011
+ questCounts: z7.record(z7.string(), z7.number())
1012
+ });
1013
+ var managedOAuthAccountBaseSchema = z7.object({
1014
+ provider: z7.enum(["x", "discord"]),
1015
+ revision: z7.number().int().nonnegative()
1016
+ });
1017
+ var managedOAuthAccountSchema = z7.discriminatedUnion("status", [
1018
+ managedOAuthAccountBaseSchema.extend({
1019
+ status: z7.literal("connected"),
1020
+ subject: z7.string().min(1),
1021
+ linkedAt: z7.number()
1022
+ }),
1023
+ managedOAuthAccountBaseSchema.extend({ status: z7.literal("disconnected") })
1024
+ ]);
1025
+ var memberOAuthUnlinkInputSchema = z7.object({
1026
+ provider: z7.enum(["x", "discord"]),
1027
+ subject: z7.string().min(1).max(4096),
1028
+ revision: z7.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER - 1),
1029
+ reason: z7.string().trim().min(1).max(500)
1030
+ }).strict();
1031
+ var managedWalletSchema = linkedWalletSchema.extend({
1032
+ status: z7.enum(["linked", "unlinked"]),
1033
+ unlinkedAt: z7.number().int().nullable(),
1034
+ /** "member", or the operator or key that unlinked it. */
1035
+ unlinkedBy: z7.string().nullable()
1036
+ });
1037
+ var managedMemberIdentitySchema = memberIdentitySchema.extend({
1038
+ status: z7.enum(["linked", "unlinked"]),
1039
+ unlinkedAt: z7.number().int().nullable(),
1040
+ /** The operator or key that unlinked it. */
1041
+ unlinkedBy: z7.string().nullable()
1042
+ });
1043
+ var memberIdentityChangeInputSchema = z7.object({
1044
+ kind: appIdentityKindSchema,
1045
+ subject: z7.string().min(1).max(256),
1046
+ reason: z7.string().trim().min(1).max(500)
1047
+ }).strict();
1048
+ var balanceCheckSchema = walletBalanceSchema.pick({
1049
+ chain: true,
1050
+ token: true,
1051
+ decimals: true,
1052
+ total: true,
1053
+ wallets: true,
1054
+ observedAt: true
1055
+ }).extend({ attempt: identifier });
1056
+ var walletBalanceChainsSchema = z7.object({
1057
+ chains: z7.array(
1058
+ z7.object({
1059
+ chain: z7.union([
1060
+ z7.literal(solanaMainnet),
1061
+ cosmosNetworkSchema,
1062
+ evmChainIdSchema
1063
+ ]),
1064
+ name: z7.string(),
1065
+ testnet: z7.boolean()
1066
+ })
1067
+ )
1068
+ });
1069
+ var memberWalletUnlinkInputSchema = walletUnlinkInputSchema.extend({ reason: z7.string().trim().min(1).max(500) }).strict();
1070
+ var memberWalletSignInInputSchema = walletUnlinkInputSchema.extend({
1071
+ enabled: z7.boolean(),
1072
+ reason: z7.string().trim().min(1).max(500)
1073
+ }).strict();
1074
+ var participantSignInSchema = z7.object({
1075
+ providers: z7.array(
1076
+ z7.object({ provider: authProviderSchema, configured: z7.boolean() })
1077
+ ),
1078
+ email: z7.boolean(),
1079
+ /** Wallet families: `"solana"`, `"eip155"`, `"cosmos"`. */
1080
+ wallets: walletSignInNetworksSchema,
1081
+ /** Why participants cannot sign in to this project, or null. */
1082
+ issue: z7.string().nullable(),
1083
+ updatedAt: z7.number().nullable(),
1084
+ updatedBy: z7.string().nullable()
1085
+ });
1086
+ var participantSignInInputSchema = z7.object({
1087
+ wallets: walletSignInNetworksSchema
1088
+ }).strict();
1089
+ var memberDetailSchema = z7.object({
1090
+ snapshot: snapshotSchema,
1091
+ member: memberSchema,
1092
+ progress: memberProgressSchema,
1093
+ /** Current and historical campaign enrollment state, including inactive enrollments. */
1094
+ campaignEnrollments: z7.array(campaignEnrollmentSchema).default([]),
1095
+ passes: z7.array(
1096
+ z7.object({
1097
+ provider: z7.string(),
1098
+ event: z7.string(),
1099
+ subject: z7.string(),
1100
+ attempt: identifier.nullable()
1101
+ })
1102
+ ).default([]),
1103
+ /** Linked and unlinked wallets. */
1104
+ wallets: z7.array(managedWalletSchema),
1105
+ /** The member's 10 most recent recorded balance reads, newest first. */
1106
+ balanceChecks: z7.array(balanceCheckSchema),
1107
+ /** The member's participant profile in this project. */
1108
+ profile: managedProfileSchema.nullable(),
1109
+ /**
1110
+ * The identities trackers attribute records to this member through, besides wallets and the
1111
+ * member ID: their selected X and Discord accounts and their `app:<name>` identities in this
1112
+ * project, including app identities an operator unlinked, by kind.
1113
+ */
1114
+ identities: z7.array(managedMemberIdentitySchema)
1115
+ });
1116
+ var stockInputSchema = z7.object({
1117
+ item: identifier,
1118
+ quantity: z7.number().int().positive().max(1e6),
1119
+ actionId: identifier
1120
+ }).strict();
1121
+ var ingestTrackerScopeSchema = z7.array(identifier).min(1).max(100).nullable();
1122
+ var tokenScopeInputSchema = z7.object({ ingestTrackers: ingestTrackerScopeSchema }).strict();
1123
+ var tokenInputSchema = z7.object({
1124
+ name: z7.string().trim().min(1).max(80),
1125
+ project: identifier,
1126
+ environment: environmentSchema,
1127
+ permissions: z7.array(permissionSchema).min(1),
1128
+ ingestTrackers: ingestTrackerScopeSchema.optional(),
1129
+ days: z7.number().int().min(1).max(90).default(30)
1130
+ }).strict();
1131
+ var tokenSchema = z7.object({
1132
+ id: z7.string(),
1133
+ name: z7.string(),
1134
+ project: z7.string(),
1135
+ environment: environmentSchema,
1136
+ permissions: permissionListSchema,
1137
+ ingestTrackers: ingestTrackerScopeSchema.optional(),
1138
+ expiresAt: z7.number()
1139
+ });
1140
+ var issuedTokenSchema = tokenSchema.extend({ token: z7.string() });
1141
+ var teamSchema = z7.array(
1142
+ z7.object({ id: z7.string(), label: z7.string() })
1143
+ );
1144
+ var memberLookupSchema = z7.object({
1145
+ provider: z7.string().min(1).max(200),
1146
+ subject: z7.string().min(1).max(2048)
1147
+ }).strict();
1148
+ var verifiedPassSchema = z7.object({
1149
+ provider: identifier,
1150
+ event: identifier,
1151
+ subject: z7.string().min(1).max(2048),
1152
+ member: identifier,
1153
+ quest: identifier
1154
+ }).strict();
1155
+ function withActionId(input) {
1156
+ return { ...input, actionId: input.actionId ?? crypto.randomUUID() };
1157
+ }
1158
+ function actionIdOf(input) {
1159
+ return typeof input === "object" && input !== null && "actionId" in input && typeof input.actionId === "string" ? input.actionId : void 0;
1160
+ }
1161
+ function queryString(values) {
1162
+ const query = new URLSearchParams(
1163
+ Object.entries(values).flatMap(
1164
+ ([key, value]) => value === void 0 ? [] : [[key, String(value)]]
1165
+ )
1166
+ ).toString();
1167
+ return query ? "?" + query : "";
1168
+ }
1169
+ var serverErrorSchema = z7.looseObject({
1170
+ error: z7.string(),
1171
+ code: z7.string().optional()
1172
+ });
1173
+ function checkedTimeout(timeout) {
1174
+ if (timeout !== void 0 && !validTimeout(timeout)) {
1175
+ throw new ManagementError({
1176
+ kind: "client",
1177
+ code: ManagementErrorCode.InvalidInput,
1178
+ message: "Management timeout must be a positive, finite number of milliseconds"
1179
+ });
1180
+ }
1181
+ return timeout;
1182
+ }
1183
+ function clientFailure(error) {
1184
+ if (error instanceof ManagementError) {
1185
+ return error;
1186
+ }
1187
+ return new ManagementError({
1188
+ kind: "client",
1189
+ code: ManagementErrorCode.InvalidInput,
1190
+ message: error instanceof z7.ZodError ? `Invalid management request: ${z7.prettifyError(error)}` : error instanceof Error ? error.message : "Invalid management request",
1191
+ cause: error
1192
+ });
1193
+ }
1194
+ function guarded(api) {
1195
+ return Object.fromEntries(
1196
+ Object.entries(api).map(([key, value]) => [
1197
+ key,
1198
+ typeof value === "function" ? (...args) => {
1199
+ try {
1200
+ return Promise.resolve(value(...args)).catch((error) => {
1201
+ throw clientFailure(error);
1202
+ });
1203
+ } catch (error) {
1204
+ return Promise.reject(clientFailure(error));
1205
+ }
1206
+ } : value && typeof value === "object" ? guarded(value) : value
1207
+ ])
1208
+ );
1209
+ }
1210
+ function createManagementClient(options) {
1211
+ const clientTimeout = checkedTimeout(options.timeout) ?? DEFAULT_MANAGEMENT_TIMEOUT;
1212
+ function callLifetime(call) {
1213
+ return lifetime(
1214
+ checkedTimeout(call?.timeout) ?? clientTimeout,
1215
+ call?.signal ?? void 0
1216
+ );
1217
+ }
1218
+ function transportFailure(error, context, life, sent, status, refused = false, headers) {
1219
+ if (error instanceof ManagementError) {
1220
+ return error;
1221
+ }
1222
+ const unsent = {
1223
+ retryAfter: headers ? retryAfter(headers) : void 0,
1224
+ ...!sent ? { uncertain: false } : refused ? {
1225
+ uncertain: context.method !== "GET" && [500, 502, 504].includes(status ?? 0)
1226
+ } : {},
1227
+ ...status === void 0 ? {} : { status }
1228
+ };
1229
+ const ended = life.ended();
1230
+ if (ended === "aborted") {
1231
+ return new ManagementError({
1232
+ ...context,
1233
+ ...unsent,
1234
+ kind: "aborted",
1235
+ code: ManagementErrorCode.Aborted,
1236
+ message: "The management request was cancelled",
1237
+ cause: life.reason()
1238
+ });
1239
+ }
1240
+ if (ended === "timeout") {
1241
+ return new ManagementError({
1242
+ ...context,
1243
+ ...unsent,
1244
+ kind: "timeout",
1245
+ code: ManagementErrorCode.Timeout,
1246
+ message: `The management request did not finish within ${life.timeout} ms`,
1247
+ cause: error
1248
+ });
1249
+ }
1250
+ return new ManagementError({
1251
+ ...context,
1252
+ ...unsent,
1253
+ kind: "network",
1254
+ code: ManagementErrorCode.Network,
1255
+ message: "The management request failed before Domino answered",
1256
+ cause: error
1257
+ });
1258
+ }
1259
+ async function credential(context, life) {
1260
+ if (!options.getToken) {
1261
+ return null;
1262
+ }
1263
+ const getToken = options.getToken;
1264
+ try {
1265
+ return await new Promise((resolve, reject) => {
1266
+ const stop = () => reject(life.signal.reason);
1267
+ life.signal.addEventListener("abort", stop, { once: true });
1268
+ getToken().then(resolve, reject).finally(() => life.signal.removeEventListener("abort", stop));
1269
+ });
1270
+ } catch (error) {
1271
+ if (life.signal.aborted) {
1272
+ throw transportFailure(error, context, life, false);
1273
+ }
1274
+ throw new ManagementError({
1275
+ ...context,
1276
+ // A token source that could not reach its own service failed like a network call.
1277
+ kind: error instanceof TypeError ? "network" : "client",
1278
+ code: ManagementErrorCode.Credential,
1279
+ uncertain: false,
1280
+ message: "Could not get a management credential",
1281
+ cause: error
1282
+ });
1283
+ }
1284
+ }
1285
+ async function send(path, fetchInit, context, life) {
1286
+ if (life.signal.aborted) {
1287
+ throw transportFailure(life.reason(), context, life, false);
1288
+ }
1289
+ const headers = new Headers(fetchInit.headers);
1290
+ const token = await credential(context, life);
1291
+ if (token) {
1292
+ headers.set("Authorization", `Bearer ${token}`);
1293
+ }
1294
+ if (options.organization) {
1295
+ headers.set("X-Relay-Organization", options.organization);
1296
+ }
1297
+ if (options.project) {
1298
+ headers.set("X-Relay-Project", options.project);
1299
+ }
1300
+ if (options.environment) {
1301
+ headers.set("X-Relay-Environment", options.environment);
1302
+ }
1303
+ let response;
1304
+ try {
1305
+ response = await fetch(`${options.baseUrl}/management/v1${path}`, {
1306
+ ...fetchInit,
1307
+ headers,
1308
+ signal: life.signal
1309
+ });
1310
+ } catch (error) {
1311
+ throw transportFailure(error, context, life, true);
1312
+ }
1313
+ if (!response.ok) {
1314
+ let text;
1315
+ try {
1316
+ text = await response.text();
1317
+ } catch (error2) {
1318
+ throw transportFailure(
1319
+ error2,
1320
+ context,
1321
+ life,
1322
+ true,
1323
+ response.status,
1324
+ true,
1325
+ response.headers
1326
+ );
1327
+ }
1328
+ let body = null;
1329
+ try {
1330
+ body = JSON.parse(text);
1331
+ } catch {
1332
+ }
1333
+ const parsed = serverErrorSchema.safeParse(body);
1334
+ const { error, code, ...details } = parsed.success ? parsed.data : { error: `Request failed (${response.status})`, code: void 0 };
1335
+ throw new ManagementError({
1336
+ ...context,
1337
+ kind: "http",
1338
+ status: response.status,
1339
+ message: error,
1340
+ ...code === void 0 ? {} : { code },
1341
+ details,
1342
+ retryAfter: retryAfter(response.headers)
1343
+ });
1344
+ }
1345
+ return response;
1346
+ }
1347
+ async function raw(path, init) {
1348
+ const { timeout, signal, ...fetchInit } = init ?? {};
1349
+ const life = callLifetime({ timeout, signal: signal ?? void 0 });
1350
+ try {
1351
+ return await send(
1352
+ path,
1353
+ fetchInit,
1354
+ {
1355
+ method: (fetchInit.method ?? "GET").toUpperCase(),
1356
+ path: path.split("?")[0],
1357
+ replaySafe: false
1358
+ },
1359
+ life
1360
+ );
1361
+ } finally {
1362
+ life.end();
1363
+ }
1364
+ }
1365
+ async function exchange(path, schema, input, method, call, replaySafe) {
1366
+ const actionId = actionIdOf(input);
1367
+ const context = {
1368
+ method,
1369
+ replaySafe,
1370
+ path: path.split("?")[0],
1371
+ ...actionId ? { actionId } : {}
1372
+ };
1373
+ const fetchInit = {
1374
+ method,
1375
+ ...input === void 0 ? {} : {
1376
+ headers: { "Content-Type": "application/json" },
1377
+ body: JSON.stringify(input)
1378
+ }
1379
+ };
1380
+ const life = callLifetime(call);
1381
+ try {
1382
+ return await retrying(
1383
+ life,
1384
+ { replaySafe: method === "GET" || replaySafe },
1385
+ async () => {
1386
+ const response = await send(path, fetchInit, context, life);
1387
+ let body;
1388
+ try {
1389
+ body = await response.json();
1390
+ } catch (error) {
1391
+ if (error instanceof SyntaxError && !life.signal.aborted) {
1392
+ throw new ManagementError({
1393
+ ...context,
1394
+ kind: "invalid-response",
1395
+ code: ManagementErrorCode.InvalidResponse,
1396
+ status: response.status,
1397
+ message: "Domino answered with a body that is not JSON",
1398
+ cause: error
1399
+ });
1400
+ }
1401
+ throw transportFailure(
1402
+ error,
1403
+ context,
1404
+ life,
1405
+ true,
1406
+ response.status,
1407
+ false,
1408
+ response.headers
1409
+ );
1410
+ }
1411
+ const parsed = schema.safeParse(body);
1412
+ if (!parsed.success) {
1413
+ throw new ManagementError({
1414
+ ...context,
1415
+ kind: "invalid-response",
1416
+ code: ManagementErrorCode.InvalidResponse,
1417
+ status: response.status,
1418
+ message: "Domino answered with a response this client does not recognize",
1419
+ cause: parsed.error
1420
+ });
1421
+ }
1422
+ return parsed.data;
1423
+ }
1424
+ );
1425
+ } finally {
1426
+ life.end();
1427
+ }
1428
+ }
1429
+ async function request(path, schema, input, method = input === void 0 ? "GET" : "POST", call) {
1430
+ return exchange(path, schema, input, method.toUpperCase(), call, false);
1431
+ }
1432
+ const get = (path, schema, call) => exchange(path, schema, void 0, "GET", call, true);
1433
+ const post = (path, schema, input, call) => exchange(path, schema, input, "POST", call, actionIdOf(input) !== void 0);
1434
+ async function create(path, responseSchema, inputSchema, input, call) {
1435
+ return post(
1436
+ path,
1437
+ responseSchema,
1438
+ inputSchema.parse(withActionId(input)),
1439
+ call
1440
+ );
1441
+ }
1442
+ const ok = z7.object({ ok: z7.literal(true) });
1443
+ return guarded({
1444
+ raw,
1445
+ request,
1446
+ trackers: {
1447
+ list: (call) => get("/trackers", z7.array(trackerStatusSchema), call),
1448
+ get: (reference, call) => get(
1449
+ `/trackers/${identifier.parse(reference)}`,
1450
+ trackerStatusSchema,
1451
+ call
1452
+ ),
1453
+ records: (reference, query = {}, call) => get(
1454
+ `/trackers/${identifier.parse(reference)}/records${queryString(trackerQuerySchema.parse(query))}`,
1455
+ trackerPageSchema,
1456
+ call
1457
+ ),
1458
+ summary: (reference, query = {}, call) => get(
1459
+ `/trackers/${identifier.parse(reference)}/summary${queryString(trackerQuerySchema.parse(query))}`,
1460
+ trackerSummarySchema,
1461
+ call
1462
+ ),
1463
+ content: (reference, query, call) => get(
1464
+ `/trackers/${identifier.parse(reference)}/content${queryString(trackerContentReadSchema.parse(query))}`,
1465
+ trackerContentSchema,
1466
+ call
1467
+ ),
1468
+ control: (reference, input, call) => post(
1469
+ `/trackers/${identifier.parse(reference)}/control`,
1470
+ trackerStatusSchema,
1471
+ trackerControlSchema.parse(input),
1472
+ call
1473
+ ),
1474
+ ingest: (reference, input, call) => post(
1475
+ `/trackers/${identifier.parse(reference)}/records`,
1476
+ trackerIngestResultSchema,
1477
+ trackerIngestSchema.parse(input),
1478
+ call
1479
+ ),
1480
+ /** Why each tracker-triggered quest admitted or skipped a record observation, newest first. */
1481
+ outcomes: (reference, query = {}, call) => get(
1482
+ `/trackers/${identifier.parse(reference)}/outcomes${queryString(trackerOutcomeQuerySchema.parse(query))}`,
1483
+ trackerOutcomePageSchema,
1484
+ call
1485
+ ),
1486
+ /**
1487
+ * Re-runs admission for a skipped observation under the quest's current release, links,
1488
+ * membership and enrollment, releasing historical activity whatever the quest's historical
1489
+ * policy; requires `review` permission. Fails with 409, the current reason and its `skip`
1490
+ * code when it still cannot admit.
1491
+ */
1492
+ retryOutcome: (reference, input, call) => post(
1493
+ `/trackers/${identifier.parse(reference)}/outcomes/retry`,
1494
+ trackerOutcomeSchema,
1495
+ trackerOutcomeRetrySchema.parse(input),
1496
+ call
1497
+ ),
1498
+ /** A bounded X search sample to explore a query before defining a tracker. Stores nothing. */
1499
+ preview: (input, call) => post(
1500
+ "/tracker-preview",
1501
+ trackerPreviewSchema,
1502
+ trackerPreviewInputSchema.parse(input),
1503
+ call
1504
+ )
1505
+ },
1506
+ engagement: {
1507
+ previewChange: (input, call) => post(
1508
+ "/engagement/preview-change",
1509
+ engagementChangePreviewSchema,
1510
+ engagementChangePreviewInputSchema.parse(input),
1511
+ call
1512
+ ),
1513
+ change: (input, call) => post(
1514
+ "/engagement/change",
1515
+ engagementRuleSchema,
1516
+ engagementChangeSchema.parse(input),
1517
+ call
1518
+ ),
1519
+ versions: (input, call) => get(
1520
+ "/engagement/versions" + queryString(engagementVersionQuerySchema.parse(input)),
1521
+ engagementVersionPageSchema,
1522
+ call
1523
+ ),
1524
+ boundaries: (input, call) => get(
1525
+ "/engagement/boundaries" + queryString(engagementPageQuerySchema.parse(input)),
1526
+ engagementBoundaryPageSchema,
1527
+ call
1528
+ ),
1529
+ publish: (input, call) => post(
1530
+ "/engagement/publish",
1531
+ engagementRuleSchema,
1532
+ engagementPublishSchema.parse(input),
1533
+ call
1534
+ ),
1535
+ list: (call) => get("/engagement", z7.array(engagementRuleSchema), call),
1536
+ page: (input, call) => get(
1537
+ "/engagement/history" + queryString(engagementPageQuerySchema.parse(input)),
1538
+ engagementPageSchema,
1539
+ call
1540
+ )
1541
+ },
1542
+ content: {
1543
+ performance: (input, call) => get(
1544
+ "/content/performance" + queryString(contentPerformanceQuerySchema.parse(input)),
1545
+ contentPerformancePageSchema,
1546
+ call
1547
+ ),
1548
+ qualifications: (input, call) => get(
1549
+ "/content/qualifications" + queryString(contentQualificationQuerySchema.parse(input)),
1550
+ contentQualificationPageSchema,
1551
+ call
1552
+ )
1553
+ },
1554
+ pointLedgers: {
1555
+ list: (call) => get("/point-ledgers", z7.array(managedPointLedgerSchema), call),
1556
+ save: (input, call) => post(
1557
+ "/point-ledgers/update",
1558
+ managedPointLedgerSchema,
1559
+ pointLedgerSchema.parse(input),
1560
+ call
1561
+ ),
1562
+ archive: (ledger, call) => post(
1563
+ `/point-ledgers/${identifier.parse(ledger)}/archive`,
1564
+ managedPointLedgerSchema,
1565
+ {},
1566
+ call
1567
+ )
1568
+ },
1569
+ points: {
1570
+ ledgers: (call) => get("/point-ledgers", z7.array(managedPointLedgerSchema), call),
1571
+ createLedger: (input, call) => create(
1572
+ "/point-ledgers",
1573
+ pointLedgerSchema,
1574
+ createPointLedgerSchema,
1575
+ input,
1576
+ call
1577
+ ),
1578
+ update: (input, call) => post(
1579
+ "/points",
1580
+ pointsResultSchema,
1581
+ pointsMutationSchema.parse(input),
1582
+ call
1583
+ ),
1584
+ balance: (member, balance, call) => get(
1585
+ `/points/${identifier.parse(member)}/${identifier.parse(balance)}`,
1586
+ pointsAccountSchema,
1587
+ call
1588
+ ),
1589
+ history: (member, balance, before, call) => get(
1590
+ `/points/${identifier.parse(member)}/${identifier.parse(balance)}/history${queryString({ before })}`,
1591
+ z7.object({
1592
+ items: z7.array(pointsEntrySchema),
1593
+ next: z7.number().nullable()
1594
+ }),
1595
+ call
1596
+ )
1597
+ },
1598
+ referrals: {
1599
+ /** A member's referral point history, newest first. Pass `nextCursor` as `cursor`. */
1600
+ history: (member, query = {}, call) => get(
1601
+ `/referrals/history/${identifier.parse(member)}${queryString({ cursor: query.cursor })}`,
1602
+ referralHistorySchema,
1603
+ call
1604
+ ),
1605
+ list: (call) => get("/referrals", z7.array(publishedReferralSchema), call),
1606
+ participants: (before, call) => get(
1607
+ `/referrals/participants${queryString({ before })}`,
1608
+ referralManagementSchema,
1609
+ call
1610
+ ),
1611
+ control: (input, call) => post(
1612
+ "/referrals/control",
1613
+ ok,
1614
+ referralControlSchema.parse(input),
1615
+ call
1616
+ )
1617
+ },
1618
+ leaderboards: {
1619
+ list: (call) => get("/leaderboards", z7.array(publishedLeaderboardSchema), call),
1620
+ standings: (board, input = {}, call) => {
1621
+ const query = leaderboardQuerySchema.parse(input);
1622
+ return get(
1623
+ `/leaderboards/${identifier.parse(board)}${queryString({
1624
+ limit: query.limit,
1625
+ cursor: query.cursor || void 0
1626
+ })}`,
1627
+ leaderboardPageSchema,
1628
+ call
1629
+ );
1630
+ },
1631
+ history: (board, call) => get(
1632
+ `/leaderboards/${identifier.parse(board)}/history`,
1633
+ z7.array(publishedLeaderboardSchema),
1634
+ call
1635
+ ),
1636
+ exclusions: (board, call) => get(
1637
+ `/leaderboards/${identifier.parse(board)}/exclusions`,
1638
+ z7.array(z7.object({ member: identifier })),
1639
+ call
1640
+ ),
1641
+ exclude: (board, input, call) => post(
1642
+ `/leaderboards/${identifier.parse(board)}/exclusions`,
1643
+ ok,
1644
+ leaderboardExclusionSchema.parse(input),
1645
+ call
1646
+ ),
1647
+ group: (group, input, call) => post(
1648
+ `/leaderboard-groups/${identifier.parse(typeof group === "string" ? group : projectGroupKey(group))}`,
1649
+ ok,
1650
+ leaderboardGroupSchema.parse(input),
1651
+ call
1652
+ ),
1653
+ settlements: (board, call) => get(
1654
+ `/leaderboards/${identifier.parse(board)}/settlements`,
1655
+ z7.array(leaderboardSettlementSummarySchema),
1656
+ call
1657
+ ),
1658
+ settlement: (settlement, call) => get(
1659
+ `/leaderboard-settlements/${identifier.parse(settlement)}`,
1660
+ leaderboardSettlementSchema,
1661
+ call
1662
+ ),
1663
+ approveSettlement: (settlement, input, call) => post(
1664
+ `/leaderboard-settlements/${identifier.parse(settlement)}/approve`,
1665
+ leaderboardSettlementSchema,
1666
+ leaderboardSettlementApprovalSchema.parse(withActionId(input)),
1667
+ call
1668
+ )
1669
+ },
1670
+ deployments: {
1671
+ list: (call) => get("/deployments", z7.array(deploymentRecordSchema), call),
1672
+ get: (deployment, call) => get(
1673
+ `/deployments/${identifier.parse(deployment)}`,
1674
+ deploymentRecordSchema,
1675
+ call
1676
+ ),
1677
+ preview: (input, call) => {
1678
+ const { engagement, ...deployment } = projectDeploymentSchema.parse(input);
1679
+ return post(
1680
+ "/deployments/preview",
1681
+ deploymentPreviewSchema,
1682
+ { ...deployment, ...engagement.length ? { engagement } : {} },
1683
+ call
1684
+ );
1685
+ },
1686
+ publish: (input, call) => post(
1687
+ "/deployments/publish",
1688
+ deploymentResultSchema,
1689
+ publishDeploymentSchema.parse(input),
1690
+ call
1691
+ ),
1692
+ submit: (input, call) => post(
1693
+ "/deployments/submit",
1694
+ deploymentRecordSchema,
1695
+ submitDeploymentSchema.parse(input),
1696
+ call
1697
+ ),
1698
+ reject: (input, call) => post(
1699
+ "/deployments/reject",
1700
+ deploymentRecordSchema,
1701
+ rejectDeploymentSchema.parse(input),
1702
+ call
1703
+ ),
1704
+ promote: (input, call) => {
1705
+ const parsed = promoteDeploymentSchema.parse(withActionId(input));
1706
+ return post(
1707
+ "/deployments/promote",
1708
+ deploymentRecordSchema,
1709
+ parsed,
1710
+ call
1711
+ );
1712
+ },
1713
+ rollback: (input, call) => {
1714
+ const parsed = rollbackDeploymentSchema.parse(withActionId(input));
1715
+ return post(
1716
+ "/deployments/rollback",
1717
+ deploymentRecordSchema,
1718
+ parsed,
1719
+ call
1720
+ );
1721
+ }
1722
+ },
1723
+ catalog: {
1724
+ allocateQuest: (input = {}, call) => create(
1725
+ "/catalog/quests",
1726
+ allocatedQuestSchema,
1727
+ allocateQuestSchema,
1728
+ input,
1729
+ call
1730
+ ),
1731
+ read: (call) => get("/catalog", questCatalogSchema, call),
1732
+ previewDeployment: (input, call) => post(
1733
+ "/catalog/deploy/preview",
1734
+ catalogDeploymentPreviewSchema,
1735
+ catalogDeploymentSchema.parse(input),
1736
+ call
1737
+ ),
1738
+ deploy: (input, call) => post(
1739
+ "/catalog/deploy",
1740
+ questCatalogSchema,
1741
+ catalogDeploymentSchema.parse(input),
1742
+ call
1743
+ ),
1744
+ saveDraft: (input, call) => post(
1745
+ "/catalog/drafts",
1746
+ questDraftSchema,
1747
+ saveQuestDraftSchema.parse(input),
1748
+ call
1749
+ ),
1750
+ preview: (input, call) => post(
1751
+ "/catalog/preview",
1752
+ questPublicationPreviewSchema,
1753
+ publishQuestDraftSchema.parse(input),
1754
+ call
1755
+ ),
1756
+ publish: (input, call) => post(
1757
+ "/catalog/publish",
1758
+ questPublicationPreviewSchema,
1759
+ publishQuestDraftSchema.parse(input),
1760
+ call
1761
+ )
1762
+ },
1763
+ /** Staff-confirmed quests and reviews. */
1764
+ attempts: {
1765
+ /**
1766
+ * Submits a staff-confirmed quest (`manual({ actor: "staff" })`) for a member; requires
1767
+ * `confirm` permission. Resolves with the queued attempt, or with the original attempt when
1768
+ * the action ID repeats. Any other quest fails with 403.
1769
+ */
1770
+ confirm: (input, call) => post(
1771
+ "/attempts",
1772
+ attemptSchema,
1773
+ submitSchema.parse(withActionId(input)),
1774
+ call
1775
+ ),
1776
+ /**
1777
+ * Accepts or rejects an attempt waiting for review, at the `generation` the reviewer saw,
1778
+ * with a reason; requires `review` permission.
1779
+ */
1780
+ review: (attempt, input, call) => post(
1781
+ `/attempts/${identifier.parse(attempt)}/review`,
1782
+ attemptSchema,
1783
+ staffDecisionSchema.parse(withActionId(input)),
1784
+ call
1785
+ ),
1786
+ /** Evaluates a failed attempt again under a new generation; requires `review` permission. */
1787
+ retry: (attempt, call) => post(
1788
+ `/attempts/${identifier.parse(attempt)}/retry`,
1789
+ attemptSchema,
1790
+ {},
1791
+ call
1792
+ )
1793
+ },
1794
+ passes: {
1795
+ /**
1796
+ * Records a member's external event pass, which the app verified, and submits the entry
1797
+ * quest (`manual({ actor: "staff" })`); requires `confirm` permission. The same pass for
1798
+ * the same member resolves with the original attempt.
1799
+ */
1800
+ verify: (input, call) => post(
1801
+ "/passes/verify",
1802
+ attemptSchema,
1803
+ verifiedPassSchema.parse(input),
1804
+ call
1805
+ )
1806
+ },
1807
+ completions: {
1808
+ /**
1809
+ * Revokes an accepted completion with a reason; requires `review` permission. In one
1810
+ * transaction it reverses the completion's points, voids its undelivered tiered rewards and
1811
+ * flags collected ones, stops Discord role grants not yet delivered and flags delivered roles for
1812
+ * an operator to remove in Discord (Relay never removes roles), re-evaluates referral
1813
+ * qualification on it, and revokes a streak milestone. `freeOccurrence` lets the member
1814
+ * complete the quest again for the same occurrence. Replaying the action ID returns the
1815
+ * first result.
1816
+ */
1817
+ revoke: (input, call) => {
1818
+ const { completion, ...body } = input;
1819
+ return post(
1820
+ `/completions/${identifier.parse(completion)}/revoke`,
1821
+ completionRevocationSchema,
1822
+ completionRevokeSchema.parse(withActionId(body)),
1823
+ call
1824
+ );
1825
+ }
1826
+ },
1827
+ /** Staff handover of a member's reward entitlement; requires `handover` permission. */
1828
+ handover: {
1829
+ /** Starts handing over an entitlement at the `revision` staff saw, with an optional pickup selection. */
1830
+ begin: (entitlement, input, call) => post(
1831
+ `/entitlements/${identifier.parse(entitlement)}/begin`,
1832
+ entitlementSchema,
1833
+ beginHandoverSchema.parse(withActionId(input)),
1834
+ call
1835
+ ),
1836
+ /** Completes the handover `begin` started; the entitlement becomes collected. */
1837
+ confirm: (entitlement, input, call) => post(
1838
+ `/entitlements/${identifier.parse(entitlement)}/confirm`,
1839
+ entitlementSchema,
1840
+ confirmHandoverSchema.parse(withActionId(input)),
1841
+ call
1842
+ ),
1843
+ /**
1844
+ * Cancels a handover that was started but not confirmed, at the `revision` staff saw, with a
1845
+ * reason. The entitlement is available again and any pickup size it held returns to stock.
1846
+ */
1847
+ cancel: (entitlement, input, call) => post(
1848
+ `/entitlements/${identifier.parse(entitlement)}/cancel`,
1849
+ entitlementSchema,
1850
+ entitlementCorrectionSchema.parse(withActionId(input)),
1851
+ call
1852
+ )
1853
+ },
1854
+ /** Operator corrections of a member's reward entitlement; require `review` permission. */
1855
+ entitlements: {
1856
+ /**
1857
+ * Voids an available entitlement granted by mistake, at the `revision` the operator saw, with
1858
+ * a reason. It can no longer be handed over. A quest that grants the member the same reward
1859
+ * again makes it available as a fresh grant; a voided referral reward stays void.
1860
+ */
1861
+ void: (entitlement, input, call) => post(
1862
+ `/entitlements/${identifier.parse(entitlement)}/void`,
1863
+ entitlementSchema,
1864
+ entitlementCorrectionSchema.parse(withActionId(input)),
1865
+ call
1866
+ ),
1867
+ /**
1868
+ * Corrects a collection recorded by mistake, at the `revision` the operator saw, with a
1869
+ * reason. The entitlement is available again and any pickup size it held returns to stock.
1870
+ */
1871
+ correctCollection: (entitlement, input, call) => post(
1872
+ `/entitlements/${identifier.parse(entitlement)}/correct`,
1873
+ entitlementSchema,
1874
+ entitlementCorrectionSchema.parse(withActionId(input)),
1875
+ call
1876
+ )
1877
+ },
1878
+ collection: {
1879
+ resolve: (code, call) => post(
1880
+ "/collection/resolve",
1881
+ collectionPreviewSchema,
1882
+ collectionResolveSchema.parse({ code }),
1883
+ call
1884
+ ),
1885
+ begin: (input, call) => post(
1886
+ "/collection/begin",
1887
+ entitlementSchema,
1888
+ collectionBeginSchema.parse(input),
1889
+ call
1890
+ )
1891
+ },
1892
+ operations: {
1893
+ /**
1894
+ * Pauses or resumes redemptions or one quest's participation, against the `revision` the
1895
+ * operator saw, with a reason; requires `publish` permission.
1896
+ */
1897
+ configure: (input, call) => post(
1898
+ "/operations",
1899
+ operationSchema,
1900
+ operationInputSchema.parse(withActionId(input)),
1901
+ call
1902
+ )
1903
+ },
1904
+ inventory: {
1905
+ createItem: (input, call) => create(
1906
+ "/stock-items",
1907
+ stockItemSchema,
1908
+ createStockItemSchema,
1909
+ input,
1910
+ call
1911
+ ),
1912
+ /** Adds `quantity` units to a stock item; requires `inventory` permission. */
1913
+ addStock: (input, call) => post(
1914
+ "/stock",
1915
+ stockAdditionSchema,
1916
+ stockInputSchema.parse(withActionId(input)),
1917
+ call
1918
+ ),
1919
+ catalog: (call) => get("/pickup-inventory", z7.array(pickupCatalogSchema), call),
1920
+ configure: (input, call) => post(
1921
+ "/pickup-inventory",
1922
+ pickupCatalogSchema,
1923
+ configurePickupSchema.parse(input),
1924
+ call
1925
+ ),
1926
+ availability: (entitlement, call) => get(
1927
+ `/pickup-inventory/${encodeURIComponent(entitlement)}`,
1928
+ pickupAvailabilitySchema,
1929
+ call
1930
+ )
1931
+ },
1932
+ offers: {
1933
+ list: (call) => get("/offers", z7.array(offerSchema), call),
1934
+ redemptions: (input = {}, call) => get(
1935
+ `/redemptions${queryString({ member: input.member })}`,
1936
+ z7.array(redemptionSchema),
1937
+ call
1938
+ ),
1939
+ /** Pauses or resumes an offer at the revision the operator saw. */
1940
+ control: (offer, input, call) => post(
1941
+ `/offers/${identifier.parse(offer)}/control`,
1942
+ offerSchema,
1943
+ offerControlSchema.parse(withActionId(input)),
1944
+ call
1945
+ ),
1946
+ /** Cancels fulfillment, refunds points and returns the unit to stock. */
1947
+ cancelRedemption: (redemption, input, call) => post(
1948
+ `/redemptions/${identifier.parse(redemption)}/cancel`,
1949
+ redemptionSchema,
1950
+ redemptionCancellationSchema.parse(withActionId(input)),
1951
+ call
1952
+ )
1953
+ },
1954
+ readiness: (call) => get("/readiness", readinessSchema, call),
1955
+ access: (call) => get("/access", accessSchema, call),
1956
+ createProject: (input, call) => create("/projects", projectSchema, projectInputSchema, input, call),
1957
+ /** Delete the client's current project. Domino support can restore it for 30 days. */
1958
+ deleteProject: (input, call) => request(
1959
+ "/project",
1960
+ projectDeletionSchema,
1961
+ projectDeletionInputSchema.parse(input),
1962
+ "DELETE",
1963
+ call
1964
+ ),
1965
+ /** Move the client's current project to another organization the caller administers. */
1966
+ transferProject: (input, call) => post(
1967
+ "/project/transfer",
1968
+ projectTransferSchema,
1969
+ projectTransferInputSchema.parse(input),
1970
+ call
1971
+ ),
1972
+ /**
1973
+ * The signed-in person's personal API keys. Console and unscoped human CLI sessions manage
1974
+ * them; API keys and project-scoped playground sessions cannot.
1975
+ */
1976
+ tokens: {
1977
+ list: (call) => get("/tokens", z7.array(tokenSchema), call),
1978
+ /**
1979
+ * Issues a key for one project and environment, limited to permissions the caller holds
1980
+ * there. The secret `token` is in this response only.
1981
+ */
1982
+ create: (input, call) => post("/tokens", issuedTokenSchema, tokenInputSchema.parse(input), call),
1983
+ /** Replace a personal key's ingestion restriction without changing its secret. */
1984
+ scope: (id, input, call) => request(
1985
+ `/tokens/${encodeURIComponent(z7.string().min(1).parse(id))}/scope`,
1986
+ tokenSchema,
1987
+ tokenScopeInputSchema.parse(input),
1988
+ "PUT",
1989
+ call
1990
+ ),
1991
+ revoke: (id, call) => request(
1992
+ `/tokens/${encodeURIComponent(z7.string().min(1).parse(id))}`,
1993
+ ok,
1994
+ void 0,
1995
+ "DELETE",
1996
+ call
1997
+ )
1998
+ },
1999
+ /** Who holds which roles on the client's project; organization administrators only. */
2000
+ grants: {
2001
+ list: (call) => get("/grants", z7.array(grantRecordSchema), call),
2002
+ /** Replaces one person's roles and environments on the project. The audit log records it. */
2003
+ set: (input, call) => request(
2004
+ "/grants",
2005
+ grantRecordSchema,
2006
+ grantSchema.parse(input),
2007
+ "PUT",
2008
+ call
2009
+ )
2010
+ },
2011
+ /** The organization's people, to choose a grant's `subject`; organization administrators only. */
2012
+ team: {
2013
+ list: (call) => get("/team", teamSchema, call)
2014
+ },
2015
+ /** Signed activity notifications for one project/environment; writes require publish permission. */
2016
+ webhooks: {
2017
+ list: (call) => get("/webhooks", z7.array(webhookEndpointSchema), call),
2018
+ create: (input, call) => post(
2019
+ "/webhooks",
2020
+ webhookSecretSchema,
2021
+ webhookInputSchema.parse(input),
2022
+ call
2023
+ ),
2024
+ update: (id, input, call) => request(
2025
+ `/webhooks/${z7.string().uuid().parse(id)}`,
2026
+ webhookEndpointSchema,
2027
+ webhookUpdateSchema.parse(input),
2028
+ "PUT",
2029
+ call
2030
+ ),
2031
+ disable: (id, call) => post(
2032
+ `/webhooks/${z7.string().uuid().parse(id)}/disable`,
2033
+ webhookEndpointSchema,
2034
+ {},
2035
+ call
2036
+ ),
2037
+ rotateSecret: (id, call) => post(
2038
+ `/webhooks/${z7.string().uuid().parse(id)}/rotate-secret`,
2039
+ webhookSecretSchema,
2040
+ {},
2041
+ call
2042
+ ),
2043
+ deliveries: (id, query = {}, call) => get(
2044
+ `/webhooks/${z7.string().uuid().parse(id)}/deliveries${queryString(webhookQuerySchema.parse(query))}`,
2045
+ webhookDeliveryPageSchema,
2046
+ call
2047
+ ),
2048
+ replay: (id, delivery, call) => post(
2049
+ `/webhooks/${z7.string().uuid().parse(id)}/deliveries/${z7.string().uuid().parse(delivery)}/replay`,
2050
+ webhookDeliverySchema,
2051
+ {},
2052
+ call
2053
+ )
2054
+ },
2055
+ /**
2056
+ * Keys that let an existing app exchange its own login for member sessions, per project and
2057
+ * environment. Organization administrators, from a Console session only.
2058
+ */
2059
+ identityIntegrations: {
2060
+ list: (call) => get("/identity-integrations", z7.array(identityIntegrationSchema), call),
2061
+ /** The secret `token` is in this response only. */
2062
+ create: (input, call) => post(
2063
+ "/identity-integrations",
2064
+ identityIntegrationSecretSchema,
2065
+ identityIntegrationInputSchema.parse(input),
2066
+ call
2067
+ ),
2068
+ /** Replaces the key's secret and extends it by 90 days; the old secret stops working. */
2069
+ rotate: (id, call) => post(
2070
+ `/identity-integrations/${z7.string().uuid().parse(id)}/rotate`,
2071
+ identityIntegrationSecretSchema,
2072
+ {},
2073
+ call
2074
+ ),
2075
+ /**
2076
+ * The `app:<name>` kinds claimed in the project and environment, each with the integration
2077
+ * that owns its identities, connected or not, and how many it has. A new integration reusing
2078
+ * a kind with identities adopts them from that integration (`adoptIdentitiesFrom`).
2079
+ */
2080
+ kinds: (call) => get(
2081
+ "/identity-integrations/kinds",
2082
+ z7.array(identityKindClaimSchema),
2083
+ call
2084
+ ),
2085
+ /**
2086
+ * Deletes the key and ends every member session it issued. Its kind's identities stay linked
2087
+ * and keep attributing tracker records; unlink them on the member to stop that.
2088
+ */
2089
+ revoke: (id, call) => request(
2090
+ `/identity-integrations/${z7.string().uuid().parse(id)}`,
2091
+ z7.null(),
2092
+ void 0,
2093
+ "DELETE",
2094
+ call
2095
+ )
2096
+ },
2097
+ page: (page, query, call) => get(`/${page}${queryString(query)}`, pageSchema, call),
2098
+ resources: {
2099
+ list: (call) => get(
2100
+ "/resources",
2101
+ z7.object({ resources: z7.array(managedResourceSchema) }),
2102
+ call
2103
+ ),
2104
+ lifecycle: (input, call) => post(
2105
+ "/resources/lifecycle",
2106
+ resourceLifecycleResultSchema,
2107
+ resourceLifecycleInputSchema.parse(input),
2108
+ call
2109
+ )
2110
+ },
2111
+ rewardDeliveries: (member, call) => get(
2112
+ `/reward-deliveries${queryString({ member })}`,
2113
+ rewardDeliveriesSchema,
2114
+ call
2115
+ ),
2116
+ /** Relinquish automatic removal for an external assignment; requires `review` and an audited reason. */
2117
+ preserveRewardRole: (id, body, call) => post(
2118
+ `/reward-deliveries/${encodeURIComponent(id)}/preserve`,
2119
+ rewardDeliverySchema,
2120
+ body,
2121
+ call
2122
+ ),
2123
+ retryRewardDelivery: (id, call) => post(
2124
+ `/reward-deliveries/${encodeURIComponent(id)}/retry`,
2125
+ rewardDeliverySchema,
2126
+ {},
2127
+ call
2128
+ ),
2129
+ /** The project's members, as operators see them. */
2130
+ members: {
2131
+ counters: {
2132
+ history: (member, quest, query = {}, call) => get(
2133
+ `/members/${identifier.parse(member)}/counters/${identifier.parse(quest)}${queryString(counterHistoryQuerySchema.parse(query))}`,
2134
+ counterHistorySchema,
2135
+ call
2136
+ ),
2137
+ moderate: (member, quest, contribution, input, call) => post(
2138
+ `/members/${identifier.parse(member)}/counters/${identifier.parse(quest)}/${identifier.parse(contribution)}/moderate`,
2139
+ counterModerationResultSchema,
2140
+ counterModerationSchema.parse(input),
2141
+ call
2142
+ )
2143
+ },
2144
+ /** A member's detail: accounts, progress, passes, wallets and profile. */
2145
+ get: (member, call) => get(`/members/${encodeURIComponent(member)}`, memberDetailSchema, call),
2146
+ /**
2147
+ * The one member of the client's project holding exactly this account, with `provider` and `subject` as a member's
2148
+ * `accounts` list them; requires `read` permission. Fails with 404 `member-not-found` when
2149
+ * nobody holds it. Unlike the members page's `q` search, it never matches part of a value
2150
+ * or another letter case.
2151
+ */
2152
+ lookup: (input, call) => get(
2153
+ `/members/lookup${queryString(memberLookupSchema.parse(input))}`,
2154
+ personSchema,
2155
+ call
2156
+ ),
2157
+ /** Who each member is: up to 100 distinct IDs; unknown IDs come back without accounts. */
2158
+ people: (members, call) => get(
2159
+ `/people${queryString({ ids: members.join(",") })}`,
2160
+ z7.array(personSchema),
2161
+ call
2162
+ ),
2163
+ /** Current X and Discord quest account selections; requires read permission. */
2164
+ oauthAccounts: (member, call) => get(
2165
+ `/members/${encodeURIComponent(member)}/oauth-accounts`,
2166
+ z7.array(managedOAuthAccountSchema),
2167
+ call
2168
+ ),
2169
+ /** Unlinks the reviewed selection across this organization/environment, preserving ownership and sign-in. */
2170
+ unlinkOAuthAccount: (member, input, call) => post(
2171
+ `/members/${encodeURIComponent(member)}/oauth-accounts/unlink`,
2172
+ z7.array(managedOAuthAccountSchema),
2173
+ memberOAuthUnlinkInputSchema.parse(input),
2174
+ call
2175
+ ),
2176
+ /** Unlinks a member's wallet from the project with a reason; requires `review` permission. The address stays bound to the member. */
2177
+ unlinkWallet: (member, input, call) => post(
2178
+ `/members/${encodeURIComponent(member)}/wallets/unlink`,
2179
+ z7.array(managedWalletSchema),
2180
+ memberWalletUnlinkInputSchema.parse(input),
2181
+ call
2182
+ ),
2183
+ /**
2184
+ * Unlinks one of a member's `app:<name>` identities with a reason; requires `review`
2185
+ * permission. It stops attributing tracker records, the member's sessions that the kind's
2186
+ * integration issued for it end, and signing in with it fails until it is relinked.
2187
+ */
2188
+ unlinkIdentity: (member, input, call) => post(
2189
+ `/members/${encodeURIComponent(member)}/identities/unlink`,
2190
+ z7.array(managedMemberIdentitySchema),
2191
+ memberIdentityChangeInputSchema.parse(input),
2192
+ call
2193
+ ),
2194
+ /** Relinks an `app:<name>` identity an operator unlinked from this member, with a reason; requires `review` permission. */
2195
+ relinkIdentity: (member, input, call) => post(
2196
+ `/members/${encodeURIComponent(member)}/identities/relink`,
2197
+ z7.array(managedMemberIdentitySchema),
2198
+ memberIdentityChangeInputSchema.parse(input),
2199
+ call
2200
+ ),
2201
+ /**
2202
+ * Enables or disables sign-in with a member's wallet, across the organization and environment,
2203
+ * with a reason; requires `review` permission. Sessions it already issued run out within 8 hours.
2204
+ */
2205
+ setWalletSignIn: (member, input, call) => post(
2206
+ `/members/${encodeURIComponent(member)}/wallets/sign-in`,
2207
+ z7.array(managedWalletSchema),
2208
+ memberWalletSignInInputSchema.parse(input),
2209
+ call
2210
+ )
2211
+ },
2212
+ /** The hosted app's secrets. Values are write-only; builds staged after a change receive it. */
2213
+ secrets: {
2214
+ list: (call) => get("/secrets", appSecretListSchema, call),
2215
+ set: (name, value, call) => request(
2216
+ `/secrets/${appSecretNameSchema.parse(name)}`,
2217
+ appSecretSchema,
2218
+ appSecretInputSchema.parse({ value }),
2219
+ "PUT",
2220
+ call
2221
+ ),
2222
+ delete: async (name, call) => {
2223
+ await raw(`/secrets/${appSecretNameSchema.parse(name)}`, {
2224
+ ...call,
2225
+ method: "DELETE"
2226
+ });
2227
+ }
2228
+ },
2229
+ /**
2230
+ * The chains quest code can read token balances on with `ctx.wallet.balance()`, with their
2231
+ * names; requires `read` permission. Any other chain fails the evaluation.
2232
+ */
2233
+ walletBalanceChains: (call) => get("/wallet-balance-chains", walletBalanceChainsSchema, call),
2234
+ /**
2235
+ * The project calendar in this environment: the timezone that sets where days, weeks and months
2236
+ * begin for budgets, streaks and leaderboards.
2237
+ */
2238
+ calendar: {
2239
+ /**
2240
+ * The timezone in effect, today's date, when today ends, any pending change, and a stored
2241
+ * timezone the calendar no longer accepts (`unsupported`, read as UTC).
2242
+ */
2243
+ read: (call) => get("/calendar", projectCalendarSchema, call),
2244
+ /**
2245
+ * Changes the project timezone from the next day boundary, with a reason; requires `publish`
2246
+ * permission. The current timezone cancels a pending change; a call that changes nothing
2247
+ * records nothing. In live, only a person in Console can change it, not an API key.
2248
+ */
2249
+ configure: (input, call) => post(
2250
+ "/calendar",
2251
+ projectCalendarSchema,
2252
+ projectCalendarInputSchema.parse(withActionId(input)),
2253
+ call
2254
+ )
2255
+ },
2256
+ /** Participant profiles in this project and environment. */
2257
+ profiles: {
2258
+ /** Who sees profiles, and which accounts supply default names and pictures, in order. */
2259
+ settings: (call) => get("/profile-settings", profileSettingsSchema, call),
2260
+ /**
2261
+ * Changes the profile settings against `expectedRevision`, with a reason; requires `publish`
2262
+ * permission. In live, only a person in Console can change them, not an API key.
2263
+ */
2264
+ configure: (input, call) => post(
2265
+ "/profile-settings",
2266
+ profileSettingsSchema,
2267
+ profileSettingsInputSchema.parse(withActionId(input)),
2268
+ call
2269
+ ),
2270
+ /**
2271
+ * Resets a member's name, removes their picture, or locks or unlocks their profile, with a
2272
+ * reason; requires `review` permission.
2273
+ */
2274
+ moderate: (member, input, call) => post(
2275
+ `/members/${identifier.parse(member)}/profile`,
2276
+ managedProfileSchema,
2277
+ profileModerationSchema.parse(withActionId(input)),
2278
+ call
2279
+ )
2280
+ },
2281
+ /**
2282
+ * Code-authored quests. Quests created in Console change participation through a catalog draft
2283
+ * instead. Except `enroll`, these methods require `publish` permission; in live, only a person
2284
+ * in Console can use them.
2285
+ */
2286
+ campaigns: {
2287
+ /** Enrolls or restores a member in every quest of a campaign that requires enrollment. */
2288
+ enroll: (input, call) => post(
2289
+ "/campaigns/enrollments",
2290
+ campaignEnrollmentSchema,
2291
+ memberCampaignEnrollmentInputSchema.parse(input),
2292
+ call
2293
+ ),
2294
+ /** Pauses a member's new campaign admissions while preserving history and completed work. */
2295
+ withdraw: (input, call) => post(
2296
+ "/campaigns/enrollments/withdraw",
2297
+ campaignEnrollmentSchema,
2298
+ memberCampaignWithdrawalInputSchema.parse(input),
2299
+ call
2300
+ )
2301
+ },
2302
+ quests: {
2303
+ /** Pending and exhausted asynchronous balance checks. Requires read. */
2304
+ automaticScheduling: (query = {}, call) => get(
2305
+ `/quests/automatic-scheduling${queryString(automaticSchedulingQuerySchema.parse(query))}`,
2306
+ automaticSchedulingPageSchema,
2307
+ call
2308
+ ),
2309
+ /** Requeues a failed balance check with its original durable event identity. Requires review. */
2310
+ retryAutomaticScheduling: (input, call) => post(
2311
+ "/quests/automatic-scheduling/retry",
2312
+ automaticSchedulingSchema,
2313
+ automaticSchedulingRetrySchema.parse(input),
2314
+ call
2315
+ ),
2316
+ /** Prerequisite-only automatic decisions, including stable skip reasons. Requires read. */
2317
+ automaticOutcomes: (query = {}, call) => get(
2318
+ `/quests/automatic-outcomes${queryString(automaticOutcomeQuerySchema.parse(query))}`,
2319
+ automaticOutcomePageSchema,
2320
+ call
2321
+ ),
2322
+ /** Preview selected paused outcomes under current rules and budget usage. Requires review. */
2323
+ previewAutomaticCatchUp: (input, call) => post(
2324
+ "/quests/automatic-outcomes/preview",
2325
+ automaticCatchUpPreviewSchema,
2326
+ automaticCatchUpInputSchema.parse(input),
2327
+ call
2328
+ ),
2329
+ /** Confirm the exact preview; changed eligibility requires another preview. Requires review. */
2330
+ catchUpAutomatic: (input, call) => post(
2331
+ "/quests/automatic-outcomes/catch-up",
2332
+ automaticCatchUpResultSchema,
2333
+ automaticCatchUpConfirmSchema.parse(input),
2334
+ call
2335
+ ),
2336
+ /**
2337
+ * Enrolls a member in a quest whose tracker trigger requires enrollment, vouching for their
2338
+ * consent; requires `enroll` permission. The member must have joined the project. Enrolling
2339
+ * again returns the first enrollment. The member's skips recorded as `not-enrolled` on the
2340
+ * quest are decided again.
2341
+ */
2342
+ enroll: (input, call) => post(
2343
+ "/quests/enrollments",
2344
+ questEnrollmentSchema,
2345
+ memberEnrollmentInputSchema.parse(input),
2346
+ call
2347
+ ),
2348
+ /**
2349
+ * Stops new participation and hides the quest from collections, with a reason. Completions,
2350
+ * attempts and rewards stay. Deploying the quest's code again keeps it archived.
2351
+ */
2352
+ archive: (quest, input, call) => post(
2353
+ "/releases/lifecycle",
2354
+ questLifecycleSchema,
2355
+ questLifecycleInputSchema.parse(
2356
+ withActionId({ ...input, quest, archived: true })
2357
+ ),
2358
+ call
2359
+ ),
2360
+ /**
2361
+ * Opens an archived quest again, with a reason. It must pass the prerequisite graph and the
2362
+ * app's supported interactions; it stays paused while a resource setting is empty.
2363
+ */
2364
+ unarchive: (quest, input, call) => post(
2365
+ "/releases/lifecycle",
2366
+ questLifecycleSchema,
2367
+ questLifecycleInputSchema.parse(
2368
+ withActionId({ ...input, quest, archived: false })
2369
+ ),
2370
+ call
2371
+ ),
2372
+ /**
2373
+ * Changes a quest's settings values (`set`) or returns them to their defaults (`reset`),
2374
+ * publishing a new release from `expectedRelease`, the release the operator saw.
2375
+ */
2376
+ updateSettings: (input, call) => post(
2377
+ "/releases/settings",
2378
+ publishedReleaseSchema,
2379
+ questSettingsInputSchema.parse(input),
2380
+ call
2381
+ )
2382
+ },
2383
+ /** How participants sign in to this project and environment. */
2384
+ participantSignIn: (call) => get("/participant-sign-in", participantSignInSchema, call),
2385
+ /** Sets the wallet networks participants can sign in with; requires `publish` permission. */
2386
+ configureParticipantSignIn: (input, call) => request(
2387
+ "/participant-sign-in",
2388
+ participantSignInSchema,
2389
+ participantSignInInputSchema.parse(input),
2390
+ "PUT",
2391
+ call
2392
+ )
2393
+ });
2394
+ }
2395
+ export {
2396
+ APP_SECRET_LIMIT,
2397
+ DEFAULT_MANAGEMENT_TIMEOUT,
2398
+ ManagementError,
2399
+ ManagementErrorCode,
2400
+ RevokedDeliveryOutcome,
2401
+ RevokedEntitlementOutcome,
2402
+ RevokedReferralOutcome,
2403
+ WEBHOOK_MAX_BYTES,
2404
+ accessSchema,
2405
+ accountProfileSchema,
2406
+ activityTypeSchema,
2407
+ activityTypes,
2408
+ appRoutingSchema,
2409
+ appSecretDeclarationSchema,
2410
+ appSecretDeclarationsSchema,
2411
+ appSecretInputSchema,
2412
+ appSecretListSchema,
2413
+ appSecretNameSchema,
2414
+ appSecretSchema,
2415
+ appSecretValueSchema,
2416
+ assetPathSchema,
2417
+ auditRecordSchema,
2418
+ balanceCheckSchema,
2419
+ buildArtifactsSchema,
2420
+ buildIdentitySchema,
2421
+ buildPhaseSchema,
2422
+ buildSnapshotSchema,
2423
+ buildStatusSchema,
2424
+ commitSchema,
2425
+ completionRevocationSchema,
2426
+ completionRevokeSchema,
2427
+ createManagementClient,
2428
+ createRepositorySchema,
2429
+ developmentPreflightSchema,
2430
+ deviceApproveSchema,
2431
+ deviceRedeemSchema,
2432
+ deviceStartSchema,
2433
+ entitlementCorrectionSchema,
2434
+ entitlementSchema,
2435
+ environmentSchema,
2436
+ grantRecordSchema,
2437
+ grantSchema,
2438
+ hostedAppSchema,
2439
+ hostedAppSecretsSchema,
2440
+ hostedBuildSchema,
2441
+ hostedDeploymentKeySchema,
2442
+ hostedKeyPermissions,
2443
+ hostedKeySchema,
2444
+ hostedKeySecretSchema,
2445
+ hostedManagementBindings,
2446
+ hostedManagementClient,
2447
+ identityIntegrationSchema,
2448
+ identityKindClaimSchema,
2449
+ ingestTrackerScopeSchema,
2450
+ inventorySchema,
2451
+ isManagementError,
2452
+ issuedTokenSchema,
2453
+ managedMemberIdentitySchema,
2454
+ managedOAuthAccountSchema,
2455
+ managedResourceSchema,
2456
+ managedWalletSchema,
2457
+ memberAccountSchema,
2458
+ memberDetailSchema,
2459
+ memberIdentityChangeInputSchema,
2460
+ memberIdentitySchema,
2461
+ memberLookupSchema,
2462
+ memberOAuthUnlinkInputSchema,
2463
+ memberSchema,
2464
+ memberWalletSignInInputSchema,
2465
+ memberWalletUnlinkInputSchema,
2466
+ metricsSchema,
2467
+ operationInputSchema,
2468
+ operationSchema,
2469
+ pageSchema,
2470
+ participantSignInInputSchema,
2471
+ participantSignInSchema,
2472
+ permissionSchema,
2473
+ personSchema,
2474
+ projectDeletionInputSchema,
2475
+ projectDeletionSchema,
2476
+ projectInputSchema,
2477
+ projectSchema,
2478
+ projectSetupSchema,
2479
+ projectTransferInputSchema,
2480
+ projectTransferSchema,
2481
+ querySchema,
2482
+ questLifecycleInputSchema,
2483
+ questLifecycleSchema,
2484
+ readinessSchema,
2485
+ repositorySchema,
2486
+ resourceLifecycleInputSchema,
2487
+ resourceLifecycleKindSchema,
2488
+ resourceLifecycleResultSchema,
2489
+ rolePermissions,
2490
+ roleSchema,
2491
+ stageRequestSchema,
2492
+ stagedDeploymentContentSchema,
2493
+ stagedDeploymentKey,
2494
+ stagedDeploymentLimits,
2495
+ stagedDeploymentSchema,
2496
+ stagingAccessInputSchema,
2497
+ stagingAccessModeSchema,
2498
+ stagingAccessSchema,
2499
+ stagingLinkSchema,
2500
+ stagingPathSchema,
2501
+ starterIdSchema,
2502
+ starterTemplates,
2503
+ stockAdditionSchema,
2504
+ stockInputSchema,
2505
+ teamSchema,
2506
+ tokenInputSchema,
2507
+ tokenSchema,
2508
+ tokenScopeInputSchema,
2509
+ verifiedPassSchema,
2510
+ verifyWebhook,
2511
+ walletBalanceChainsSchema,
2512
+ webhookDeliveryPageSchema,
2513
+ webhookDeliverySchema,
2514
+ webhookEndpointSchema,
2515
+ webhookEventSchema,
2516
+ webhookInputSchema,
2517
+ webhookQuerySchema,
2518
+ webhookSecretSchema,
2519
+ webhookUpdateSchema
2520
+ };