@domino-sdk/relay 1.67.0 → 1.69.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.
- package/CHANGELOG.md +65 -0
- package/dist/{accounts-C2O8mpB8.d.ts → accounts-DD4gAOCe.d.ts} +232 -3
- package/dist/{action-9Xl0StBg.d.ts → action-BDFKqGlH.d.ts} +3 -2
- package/dist/{attempt-captures-ClHAoo_n.d.ts → attempt-captures-CbuCmthd.d.ts} +11 -2
- package/dist/authoring.d.ts +534 -48
- package/dist/authoring.js +192 -29
- package/dist/{automatic-outcomes-BEnPn4Uh.d.ts → automatic-outcomes-DE3vfi8g.d.ts} +11 -3
- package/dist/avatar.d.ts +2 -1
- package/dist/browser.d.ts +15 -13
- package/dist/browser.js +12 -13
- package/dist/{capability-error-CuI_F7yM.d.ts → capability-error-db7kO8-P.d.ts} +2 -1
- package/dist/{catalog-CbiftcxQ.d.ts → catalog-Cf3fHDNn.d.ts} +69 -3
- package/dist/{chunk-5DZNMLDM.js → chunk-2A3BJ262.js} +2 -2
- package/dist/{chunk-BQXRCJ3N.js → chunk-5RLIPTL7.js} +1 -1
- package/dist/{chunk-MVQQDPQX.js → chunk-AZDZEQFK.js} +14 -2
- package/dist/{chunk-JK3XV2CR.js → chunk-BRROI4CH.js} +50 -8
- package/dist/{chunk-P33ZAJMS.js → chunk-CQVKOD3B.js} +1266 -677
- package/dist/{chunk-QYC3CZVD.js → chunk-CZ23KRVK.js} +2 -2
- package/dist/{chunk-X3FMVRMM.js → chunk-DIXYVGXO.js} +1 -1
- package/dist/{chunk-RDUSFUXX.js → chunk-GEVARKEV.js} +9 -1
- package/dist/{chunk-2HHZV7U3.js → chunk-LDO5GP7G.js} +1 -1
- package/dist/{chunk-Z2Z5DBNW.js → chunk-LGGD7S5T.js} +45 -9
- package/dist/{chunk-U66GUVSG.js → chunk-LZXDYSUH.js} +2 -0
- package/dist/{chunk-NRMQVK2W.js → chunk-ME2KUAVJ.js} +1 -1
- package/dist/{chunk-KUNPCDN6.js → chunk-ODJGTFPY.js} +16 -9
- package/dist/{chunk-DSJ46QLB.js → chunk-PO2ZDY27.js} +1 -1
- package/dist/{chunk-RWR2LOPA.js → chunk-RKTMSTT7.js} +2 -2
- package/dist/{chunk-5SBA6X5X.js → chunk-SWLW4VN3.js} +2 -2
- package/dist/{chunk-BMJHFWVT.js → chunk-TCREFRPK.js} +10 -43
- package/dist/{chunk-Q5QVAF7R.js → chunk-UGM6DUB2.js} +42 -25
- package/dist/chunk-VAGGGB6B.js +87 -0
- package/dist/{chunk-FGXLXENM.js → chunk-VNEJH4NT.js} +47 -3
- package/dist/chunk-WNEQEDMU.js +427 -0
- package/dist/{chunk-Q6KTTVOI.js → chunk-WVK3G2J2.js} +1 -1
- package/dist/{client-CZPewB9h.d.ts → client-6eSYOl8h.d.ts} +159 -11
- package/dist/{dashboards-jGPM3AxF.d.ts → dashboards-DCOAXL54.d.ts} +6 -5
- package/dist/{deployments-BVFd7ddA.d.ts → deployments-BIfdCMd5.d.ts} +911 -309
- package/dist/{host-environment-FN4zg3hw.d.ts → host-environment-DUw5-Cvj.d.ts} +2 -1
- package/dist/{identity-integration-W1Vo3Ql9.d.ts → identity-integration-BlfOn8rc.d.ts} +3 -2
- package/dist/index.d.ts +16 -15
- package/dist/index.js +10 -10
- package/dist/internal.d.ts +155 -17
- package/dist/internal.js +266 -19
- package/dist/{limits-C4RzrOV4.d.ts → limits-Ctaeq23J.d.ts} +8 -2
- package/dist/{offers-BpYenB9i.d.ts → offers-COqHGbHm.d.ts} +4 -3
- package/dist/{participant-activity-DXRq4s6K.d.ts → participant-activity-BznrcePT.d.ts} +2 -1
- package/dist/{participant-rewards-BcWkBRn_.d.ts → participant-rewards-s5Gn23qb.d.ts} +23 -1
- package/dist/portal-proxy.d.ts +7 -4
- package/dist/portal-proxy.js +14 -18
- package/dist/profiles-CLDKZVFx.d.ts +370 -0
- package/dist/react/index.d.ts +71 -30
- package/dist/react/index.js +12 -13
- package/dist/{request-error-D_dUPLwo.d.ts → request-error-C24SY7n9.d.ts} +2 -1
- package/dist/{reward-deliveries-BOWpMytr.d.ts → reward-deliveries-DFhYGJdx.d.ts} +3 -2
- package/dist/runtime/authoring.js +1 -1
- package/dist/runtime/chunks/HKAI5OQA.js +1 -0
- package/dist/runtime/manifest.json +3 -3
- package/dist/runtime/schema.js +1 -1
- package/dist/schema.d.ts +556 -180
- package/dist/schema.js +70 -8
- package/dist/server/index.d.ts +15 -14
- package/dist/server/index.js +2053 -893
- package/dist/{sign-in-providers-BRYVOSlG.d.ts → sign-in-providers-C97mRNbG.d.ts} +4 -3
- package/dist/solana.d.ts +287 -0
- package/dist/solana.js +699 -0
- package/dist/{streaks-0YuipsUQ.d.ts → streaks-MAqKHbHC.d.ts} +2 -1
- package/dist/{submission-input-C152xIdn.d.ts → submission-input-BD7nORuh.d.ts} +4 -3
- package/dist/{telegram-browser-657QqiQl.d.ts → telegram-browser-gRMgGs7B.d.ts} +8 -109
- package/dist/telegram.d.ts +14 -12
- package/dist/telegram.js +2 -2
- package/dist/testing.d.ts +99 -18
- package/dist/testing.js +101 -11
- package/dist/{tracker-data-BqY-9Vu-.d.ts → tracker-data-DQgX3FIc.d.ts} +493 -1
- package/dist/{transport-CthYgZXK.d.ts → transport-BLU8jrhg.d.ts} +7340 -2134
- package/dist/vite.d.ts +2 -1
- package/dist/{wallet-Btng186v.d.ts → wallet-CPAjrW4k.d.ts} +339 -308
- package/dist/wallet-browser-BzPt_Qb5.d.ts +107 -0
- package/package.json +21 -3
- package/dist/chunk-UWUS4OOV.js +0 -59
- package/dist/chunk-UYVJZR33.js +0 -34
- package/dist/runtime/chunks/C2MGLQXC.js +0 -1
package/dist/server/index.js
CHANGED
|
@@ -1,7 +1,47 @@
|
|
|
1
1
|
import {
|
|
2
2
|
attemptCaptureSchema,
|
|
3
3
|
capturedFactSchema
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-GEVARKEV.js";
|
|
5
|
+
import {
|
|
6
|
+
PayoutSourceKind,
|
|
7
|
+
RestoredDeliveryOutcome,
|
|
8
|
+
RestoredEntitlementOutcome,
|
|
9
|
+
RestoredReferralOutcome,
|
|
10
|
+
RevokedDeliveryOutcome,
|
|
11
|
+
RevokedEntitlementOutcome,
|
|
12
|
+
RevokedReferralOutcome,
|
|
13
|
+
WEBHOOK_MAX_BYTES,
|
|
14
|
+
completionReceiptInputSchema,
|
|
15
|
+
completionReceiptListSchema,
|
|
16
|
+
completionReceiptSchema,
|
|
17
|
+
completionRestorationSchema,
|
|
18
|
+
completionRestoreSchema,
|
|
19
|
+
completionRevocationSchema,
|
|
20
|
+
completionRevocationShortfallSchema,
|
|
21
|
+
completionRevokeSchema,
|
|
22
|
+
maxCompletionReceipts,
|
|
23
|
+
memberCompletionPageSchema,
|
|
24
|
+
memberCompletionQuerySchema,
|
|
25
|
+
memberCompletionSchema,
|
|
26
|
+
revokedCompletionSchema,
|
|
27
|
+
verifyWebhook,
|
|
28
|
+
walletLinkedEventDataSchema,
|
|
29
|
+
webhookControlInputSchema,
|
|
30
|
+
webhookCreateInputSchema,
|
|
31
|
+
webhookDeleteInputSchema,
|
|
32
|
+
webhookDeliveryPageSchema,
|
|
33
|
+
webhookDeliverySchema,
|
|
34
|
+
webhookEndpointSchema,
|
|
35
|
+
webhookEndpointStateSchema,
|
|
36
|
+
webhookEventSchema,
|
|
37
|
+
webhookInputSchema,
|
|
38
|
+
webhookQuerySchema,
|
|
39
|
+
webhookRotateInputSchema,
|
|
40
|
+
webhookSecretSchema,
|
|
41
|
+
webhookStatePageSchema,
|
|
42
|
+
webhookStateQuerySchema,
|
|
43
|
+
webhookUpdateSchema
|
|
44
|
+
} from "../chunk-WNEQEDMU.js";
|
|
5
45
|
import {
|
|
6
46
|
DEFAULT_MANAGEMENT_TIMEOUT,
|
|
7
47
|
ManagementError,
|
|
@@ -17,17 +57,18 @@ import {
|
|
|
17
57
|
managementTransport,
|
|
18
58
|
questConfiguration,
|
|
19
59
|
sequenceCursorSchema,
|
|
60
|
+
solanaRpc,
|
|
20
61
|
walletSignatureValid
|
|
21
|
-
} from "../chunk-
|
|
62
|
+
} from "../chunk-BRROI4CH.js";
|
|
22
63
|
import {
|
|
23
64
|
parseImageExtraction,
|
|
24
65
|
parseImageResult
|
|
25
|
-
} from "../chunk-
|
|
66
|
+
} from "../chunk-RKTMSTT7.js";
|
|
26
67
|
import {
|
|
27
68
|
sourceDataSchema,
|
|
28
69
|
sourceRoles,
|
|
29
70
|
validateQuestShape
|
|
30
|
-
} from "../chunk-
|
|
71
|
+
} from "../chunk-AZDZEQFK.js";
|
|
31
72
|
import {
|
|
32
73
|
APP_KV_LIMIT,
|
|
33
74
|
APP_MIGRATION_FILE_BYTES,
|
|
@@ -79,6 +120,7 @@ import {
|
|
|
79
120
|
appStorageTablesSchema,
|
|
80
121
|
appStorageValueSchema,
|
|
81
122
|
assetPathSchema,
|
|
123
|
+
boundedBodyText,
|
|
82
124
|
buildArtifactsSchema,
|
|
83
125
|
buildIdentitySchema,
|
|
84
126
|
buildPhaseSchema,
|
|
@@ -155,13 +197,13 @@ import {
|
|
|
155
197
|
starterTemplates,
|
|
156
198
|
starters,
|
|
157
199
|
verifyScheduledRequest
|
|
158
|
-
} from "../chunk-
|
|
200
|
+
} from "../chunk-UGM6DUB2.js";
|
|
159
201
|
import {
|
|
160
202
|
isIntegrationParticipantPath,
|
|
161
203
|
isParticipantRoute,
|
|
162
204
|
participantRoutePattern,
|
|
163
205
|
participantRoutes
|
|
164
|
-
} from "../chunk-
|
|
206
|
+
} from "../chunk-LZXDYSUH.js";
|
|
165
207
|
import {
|
|
166
208
|
activityTypeSchema,
|
|
167
209
|
activityTypes,
|
|
@@ -187,12 +229,12 @@ import {
|
|
|
187
229
|
publishDeploymentSchema,
|
|
188
230
|
rejectDeploymentSchema,
|
|
189
231
|
submitDeploymentSchema
|
|
190
|
-
} from "../chunk-
|
|
232
|
+
} from "../chunk-ODJGTFPY.js";
|
|
191
233
|
import {
|
|
192
234
|
xUserLookupInputSchema,
|
|
193
235
|
xUserSchema,
|
|
194
236
|
xUsernameSchema
|
|
195
|
-
} from "../chunk-
|
|
237
|
+
} from "../chunk-DIXYVGXO.js";
|
|
196
238
|
import {
|
|
197
239
|
analyticsBreakdowns,
|
|
198
240
|
analyticsCatalog,
|
|
@@ -207,18 +249,15 @@ import {
|
|
|
207
249
|
analyticsRanges,
|
|
208
250
|
analyticsReadSchema,
|
|
209
251
|
dashboardDefinitionSchema
|
|
210
|
-
} from "../chunk-
|
|
252
|
+
} from "../chunk-CZ23KRVK.js";
|
|
211
253
|
import "../chunk-MWMCQLCG.js";
|
|
212
254
|
import {
|
|
213
255
|
withActionId
|
|
214
|
-
} from "../chunk-
|
|
215
|
-
import {
|
|
216
|
-
base58
|
|
217
|
-
} from "../chunk-UWUS4OOV.js";
|
|
256
|
+
} from "../chunk-5RLIPTL7.js";
|
|
218
257
|
import {
|
|
219
258
|
withQuery
|
|
220
|
-
} from "../chunk-
|
|
221
|
-
import "../chunk-
|
|
259
|
+
} from "../chunk-WVK3G2J2.js";
|
|
260
|
+
import "../chunk-SWLW4VN3.js";
|
|
222
261
|
import {
|
|
223
262
|
collectionBeginSchema,
|
|
224
263
|
collectionPreviewSchema,
|
|
@@ -233,7 +272,7 @@ import {
|
|
|
233
272
|
rewardDeliveriesSchema,
|
|
234
273
|
rewardDeliveryQuerySchema,
|
|
235
274
|
rewardDeliverySchema
|
|
236
|
-
} from "../chunk-
|
|
275
|
+
} from "../chunk-ME2KUAVJ.js";
|
|
237
276
|
import {
|
|
238
277
|
allocateQuestSchema,
|
|
239
278
|
allocatedQuestSchema,
|
|
@@ -244,7 +283,7 @@ import {
|
|
|
244
283
|
questDraftSchema,
|
|
245
284
|
questPublicationPreviewSchema,
|
|
246
285
|
saveQuestDraftSchema
|
|
247
|
-
} from "../chunk-
|
|
286
|
+
} from "../chunk-PO2ZDY27.js";
|
|
248
287
|
import {
|
|
249
288
|
engagementBoundaryPageSchema,
|
|
250
289
|
engagementChangePreviewInputSchema,
|
|
@@ -270,7 +309,7 @@ import {
|
|
|
270
309
|
referralQualificationSchema,
|
|
271
310
|
referralRewardResolutionSchema,
|
|
272
311
|
referralSuspensionSchema
|
|
273
|
-
} from "../chunk-
|
|
312
|
+
} from "../chunk-2A3BJ262.js";
|
|
274
313
|
import {
|
|
275
314
|
CompletionSourceKind,
|
|
276
315
|
acceptAnywaySchema,
|
|
@@ -281,12 +320,13 @@ import {
|
|
|
281
320
|
badgeMutationResultSchema,
|
|
282
321
|
badgeMutationSchema,
|
|
283
322
|
badgePropertiesSchema,
|
|
323
|
+
base58,
|
|
324
|
+
base58Bytes,
|
|
284
325
|
baseUnitsSchema,
|
|
285
326
|
beginHandoverSchema,
|
|
286
327
|
caip10,
|
|
287
328
|
campaignEnrollmentSchema,
|
|
288
329
|
completionKeySchema,
|
|
289
|
-
completionSourceSchema,
|
|
290
330
|
configurePickupSchema,
|
|
291
331
|
confirmHandoverSchema,
|
|
292
332
|
contentPerformancePageSchema,
|
|
@@ -340,15 +380,18 @@ import {
|
|
|
340
380
|
managedProfileSchema,
|
|
341
381
|
managedTrackerCreateSchema,
|
|
342
382
|
managementStateQuerySchema,
|
|
383
|
+
maxSolanaActionReference,
|
|
343
384
|
memberBadgesSchema,
|
|
344
385
|
memberCampaignEnrollmentInputSchema,
|
|
345
386
|
memberCampaignWithdrawalInputSchema,
|
|
346
387
|
memberIdentitySchema,
|
|
347
388
|
memberProgressSchema,
|
|
389
|
+
nftTrackerCreateSchema,
|
|
348
390
|
organizationDiscordServersSchema,
|
|
349
391
|
pageCursorSchema,
|
|
350
392
|
pageLimit,
|
|
351
393
|
pageQuerySchema,
|
|
394
|
+
parseSolanaActionMemo,
|
|
352
395
|
pickupAvailabilitySchema,
|
|
353
396
|
pickupCatalogSchema,
|
|
354
397
|
pointLedgerPropertiesSchema,
|
|
@@ -359,6 +402,8 @@ import {
|
|
|
359
402
|
profileModerationSchema,
|
|
360
403
|
profileSettingsInputSchema,
|
|
361
404
|
profileSettingsSchema,
|
|
405
|
+
programAccountTrackerCreateSchema,
|
|
406
|
+
programActivityTrackerCreateSchema,
|
|
362
407
|
projectCalendarInputSchema,
|
|
363
408
|
projectCalendarSchema,
|
|
364
409
|
projectGroupKey,
|
|
@@ -369,17 +414,26 @@ import {
|
|
|
369
414
|
questSubmissionSchema,
|
|
370
415
|
removeGroupMemberSchema,
|
|
371
416
|
responseTables,
|
|
417
|
+
settlementPaymentSchema,
|
|
372
418
|
signInProviderInputSchema,
|
|
373
419
|
signInProviderOptionSchema,
|
|
374
420
|
signInProviderSchema,
|
|
375
421
|
snapshotSchema,
|
|
422
|
+
solanaActionMemo,
|
|
376
423
|
solanaAddressSchema,
|
|
377
424
|
solanaDevnet,
|
|
378
425
|
solanaMainnet,
|
|
426
|
+
solanaMemoProgram,
|
|
427
|
+
solanaSignatureSchema2 as solanaSignatureSchema,
|
|
428
|
+
solanaTransactionFixtureInputSchema,
|
|
429
|
+
solanaTransactionSubmissionSchema,
|
|
379
430
|
staffDecisionSchema,
|
|
431
|
+
stakeTrackerCreateSchema,
|
|
432
|
+
stationRefusal,
|
|
380
433
|
stockItemSchema,
|
|
381
434
|
streakProgressSchema,
|
|
382
435
|
submitSchema,
|
|
436
|
+
takesSolanaTransaction,
|
|
383
437
|
telegramChatConnectionSchema,
|
|
384
438
|
telegramChatIdSchema,
|
|
385
439
|
telegramChatsSchema,
|
|
@@ -407,12 +461,13 @@ import {
|
|
|
407
461
|
walletBalanceSchema,
|
|
408
462
|
walletChainSchema,
|
|
409
463
|
walletSignInNetworksSchema,
|
|
464
|
+
walletTransactionsSchema,
|
|
410
465
|
walletUnlinkInputSchema,
|
|
411
466
|
whereSchemaIssue
|
|
412
|
-
} from "../chunk-
|
|
467
|
+
} from "../chunk-CQVKOD3B.js";
|
|
413
468
|
import {
|
|
414
469
|
issueText
|
|
415
|
-
} from "../chunk-
|
|
470
|
+
} from "../chunk-VNEJH4NT.js";
|
|
416
471
|
|
|
417
472
|
// src/server/identity-links.ts
|
|
418
473
|
import * as z from "zod";
|
|
@@ -701,7 +756,9 @@ var leaderboardSettlementExportSchema = /* @__PURE__ */ (() => z6.object({
|
|
|
701
756
|
/** EVM smart-contract wallets only: the CAIP-2 network that proved it, the one chain to pay it on. */
|
|
702
757
|
provedOn: evmChainIdSchema.optional()
|
|
703
758
|
})
|
|
704
|
-
)
|
|
759
|
+
),
|
|
760
|
+
/** How a non-zero share in a non-points pool was paid on chain; absent otherwise. */
|
|
761
|
+
payment: settlementPaymentSchema.optional()
|
|
705
762
|
})
|
|
706
763
|
)
|
|
707
764
|
}))();
|
|
@@ -935,8 +992,8 @@ var accountReference = /* @__PURE__ */ (() => z9.object({
|
|
|
935
992
|
actionId: identifier,
|
|
936
993
|
kind: z9.enum(["x", "discord"]),
|
|
937
994
|
subject: z9.string().regex(/^[1-9][0-9]{0,19}$/, "Use the numeric user ID")
|
|
938
|
-
}).strict().transform(({ actionId:
|
|
939
|
-
actionId:
|
|
995
|
+
}).strict().transform(({ actionId: actionId3, kind, subject }) => ({
|
|
996
|
+
actionId: actionId3,
|
|
940
997
|
provider: kind,
|
|
941
998
|
id: subject
|
|
942
999
|
})))();
|
|
@@ -1065,135 +1122,9 @@ var testMemberHistorySchema = /* @__PURE__ */ (() => z9.object({
|
|
|
1065
1122
|
complete: z9.boolean()
|
|
1066
1123
|
}))();
|
|
1067
1124
|
|
|
1068
|
-
// src/server/webhooks.ts
|
|
1069
|
-
import * as z10 from "zod";
|
|
1070
|
-
var PayoutSourceKind = {
|
|
1071
|
-
Quest: "quest",
|
|
1072
|
-
Leaderboard: "leaderboard",
|
|
1073
|
-
Engagement: "engagement",
|
|
1074
|
-
Manual: "manual"
|
|
1075
|
-
};
|
|
1076
|
-
var webhookEventSchema = /* @__PURE__ */ (() => z10.object({
|
|
1077
|
-
id: z10.string().uuid(),
|
|
1078
|
-
version: z10.literal(1),
|
|
1079
|
-
type: activityTypeSchema,
|
|
1080
|
-
createdAt: z10.number().int().nonnegative(),
|
|
1081
|
-
organization: z10.string(),
|
|
1082
|
-
project: z10.string(),
|
|
1083
|
-
environment: z10.enum(["test", "live"]),
|
|
1084
|
-
data: z10.record(z10.string(), z10.json())
|
|
1085
|
-
}))();
|
|
1086
|
-
var webhookControlInputSchema = /* @__PURE__ */ (() => z10.object({ actionId: z10.string().uuid().optional() }).strict())();
|
|
1087
|
-
var webhookInputSchema = /* @__PURE__ */ (() => z10.object({
|
|
1088
|
-
url: z10.url().max(2048).refine((value) => {
|
|
1089
|
-
const url2 = new URL(value);
|
|
1090
|
-
return url2.protocol === "https:" && !url2.username && !url2.password && !url2.hash;
|
|
1091
|
-
}, "Use an HTTPS URL without credentials or a fragment"),
|
|
1092
|
-
types: z10.array(activityTypeSchema).min(1).max(100).refine((v) => new Set(v).size === v.length)
|
|
1093
|
-
}).strict())();
|
|
1094
|
-
var webhookCreateInputSchema = /* @__PURE__ */ (() => webhookInputSchema.extend({ actionId: z10.string().uuid().optional() }).strict())();
|
|
1095
|
-
var webhookRotateInputSchema = /* @__PURE__ */ (() => z10.object({ actionId: z10.string().uuid().optional() }).strict())();
|
|
1096
|
-
var webhookUpdateSchema = /* @__PURE__ */ (() => webhookInputSchema.partial().extend({ enabled: z10.boolean().optional() }).strict())();
|
|
1097
|
-
var webhookEndpointSchema = /* @__PURE__ */ (() => z10.object({
|
|
1098
|
-
...webhookInputSchema.shape,
|
|
1099
|
-
id: z10.string().uuid(),
|
|
1100
|
-
enabled: z10.boolean(),
|
|
1101
|
-
disabledReason: z10.string().nullable(),
|
|
1102
|
-
consecutiveFailures: z10.number().int().nonnegative(),
|
|
1103
|
-
createdAt: z10.number(),
|
|
1104
|
-
updatedAt: z10.number()
|
|
1105
|
-
}))();
|
|
1106
|
-
var webhookEndpointStateSchema = /* @__PURE__ */ (() => webhookEndpointSchema.extend({
|
|
1107
|
-
revision: z10.number().int().nonnegative(),
|
|
1108
|
-
deletedAt: z10.number().int().safe().nonnegative().nullable()
|
|
1109
|
-
}))();
|
|
1110
|
-
var webhookDeleteInputSchema = /* @__PURE__ */ (() => z10.strictObject({
|
|
1111
|
-
actionId: z10.string().uuid().default(() => crypto.randomUUID()),
|
|
1112
|
-
expectedRevision: z10.number().int().nonnegative(),
|
|
1113
|
-
reason: z10.string().trim().min(1).max(500)
|
|
1114
|
-
}))();
|
|
1115
|
-
var webhookStateQuerySchema = /* @__PURE__ */ (() => z10.strictObject({
|
|
1116
|
-
cursor: pageCursorSchema.optional(),
|
|
1117
|
-
limit: z10.coerce.number().int().min(1).max(100).default(50)
|
|
1118
|
-
}))();
|
|
1119
|
-
var webhookStatePageSchema = /* @__PURE__ */ (() => z10.object({
|
|
1120
|
-
items: z10.array(webhookEndpointStateSchema),
|
|
1121
|
-
nextCursor: pageCursorSchema.nullable()
|
|
1122
|
-
}))();
|
|
1123
|
-
var webhookSecretSchema = /* @__PURE__ */ (() => z10.object({
|
|
1124
|
-
endpoint: webhookEndpointSchema,
|
|
1125
|
-
secret: z10.string(),
|
|
1126
|
-
previousValidUntil: z10.number().nullable()
|
|
1127
|
-
}))();
|
|
1128
|
-
var webhookDeliverySchema = /* @__PURE__ */ (() => z10.object({
|
|
1129
|
-
id: z10.string().uuid(),
|
|
1130
|
-
endpoint: z10.string().uuid(),
|
|
1131
|
-
event: webhookEventSchema,
|
|
1132
|
-
status: z10.enum(["pending", "delivered", "failed", "skipped"]),
|
|
1133
|
-
attempts: z10.number().int().nonnegative(),
|
|
1134
|
-
responseStatus: z10.number().nullable(),
|
|
1135
|
-
lastError: z10.string().nullable(),
|
|
1136
|
-
createdAt: z10.number(),
|
|
1137
|
-
deliveredAt: z10.number().nullable(),
|
|
1138
|
-
replayOf: z10.string().uuid().nullable()
|
|
1139
|
-
}))();
|
|
1140
|
-
var webhookQuerySchema = /* @__PURE__ */ (() => z10.object({
|
|
1141
|
-
/** A page's `nextCursor`: the deliveries after it, newest first. */
|
|
1142
|
-
cursor: pageCursorSchema.optional(),
|
|
1143
|
-
/** @deprecated Use `cursor`. Removed in 2.0.0. */
|
|
1144
|
-
before: z10.string().uuid().optional(),
|
|
1145
|
-
limit: z10.coerce.number().int().min(1).max(100).default(50)
|
|
1146
|
-
}).strict())();
|
|
1147
|
-
var webhookDeliveryPageSchema = /* @__PURE__ */ (() => z10.object({
|
|
1148
|
-
items: z10.array(webhookDeliverySchema),
|
|
1149
|
-
nextCursor: pageCursorSchema.nullable().default(null),
|
|
1150
|
-
/** @deprecated Use `nextCursor`, passed back as `cursor`. Removed in 2.0.0. */
|
|
1151
|
-
next: z10.string().uuid().nullable()
|
|
1152
|
-
}))();
|
|
1153
|
-
var WEBHOOK_MAX_BYTES = 64 * 1024;
|
|
1154
|
-
async function verifyWebhook(input) {
|
|
1155
|
-
const bytes = new TextEncoder().encode(input.body);
|
|
1156
|
-
const tolerance = input.toleranceSeconds ?? 300;
|
|
1157
|
-
const now = input.now ?? Date.now();
|
|
1158
|
-
if (bytes.length > WEBHOOK_MAX_BYTES || !Number.isFinite(now) || !Number.isFinite(tolerance) || tolerance < 0 || tolerance > 300) {
|
|
1159
|
-
throw new Error("Invalid webhook verification input");
|
|
1160
|
-
}
|
|
1161
|
-
const parts = input.signature.split(",");
|
|
1162
|
-
const timestamps = parts.filter((part) => part.startsWith("t="));
|
|
1163
|
-
const timestamp2 = timestamps[0]?.slice(2) ?? "";
|
|
1164
|
-
const signatures = parts.filter((part) => /^v1=[a-f0-9]{64}$/.test(part)).map((part) => part.slice(3));
|
|
1165
|
-
if (timestamps.length !== 1 || !/^\d{1,12}$/.test(timestamp2) || Math.abs(now / 1e3 - Number(timestamp2)) > tolerance || signatures.length < 1 || signatures.length > 2) {
|
|
1166
|
-
throw new Error("Invalid or expired webhook signature");
|
|
1167
|
-
}
|
|
1168
|
-
const secrets3 = typeof input.secret === "string" ? [input.secret] : input.secret;
|
|
1169
|
-
const message = new TextEncoder().encode(`${timestamp2}.${input.body}`);
|
|
1170
|
-
for (const secret of secrets3) {
|
|
1171
|
-
if (!secret) {
|
|
1172
|
-
continue;
|
|
1173
|
-
}
|
|
1174
|
-
const key = await crypto.subtle.importKey(
|
|
1175
|
-
"raw",
|
|
1176
|
-
new TextEncoder().encode(secret),
|
|
1177
|
-
{ name: "HMAC", hash: "SHA-256" },
|
|
1178
|
-
false,
|
|
1179
|
-
["verify"]
|
|
1180
|
-
);
|
|
1181
|
-
for (const signature of signatures) {
|
|
1182
|
-
const digest = Uint8Array.from(
|
|
1183
|
-
signature.match(/../g) ?? [],
|
|
1184
|
-
(byte) => Number.parseInt(byte, 16)
|
|
1185
|
-
);
|
|
1186
|
-
if (await crypto.subtle.verify("HMAC", key, digest, message)) {
|
|
1187
|
-
return webhookEventSchema.parse(JSON.parse(input.body));
|
|
1188
|
-
}
|
|
1189
|
-
}
|
|
1190
|
-
}
|
|
1191
|
-
throw new Error("Invalid webhook signature");
|
|
1192
|
-
}
|
|
1193
|
-
|
|
1194
1125
|
// src/server/resource-lifecycle.ts
|
|
1195
|
-
import * as
|
|
1196
|
-
var resourceLifecycleKindSchema = /* @__PURE__ */ (() =>
|
|
1126
|
+
import * as z10 from "zod";
|
|
1127
|
+
var resourceLifecycleKindSchema = /* @__PURE__ */ (() => z10.enum([
|
|
1197
1128
|
"tracker",
|
|
1198
1129
|
"referral",
|
|
1199
1130
|
"leaderboard",
|
|
@@ -1203,51 +1134,51 @@ var resourceLifecycleKindSchema = /* @__PURE__ */ (() => z11.enum([
|
|
|
1203
1134
|
"image",
|
|
1204
1135
|
"point-ledger"
|
|
1205
1136
|
]))();
|
|
1206
|
-
var managedResourceSchema = /* @__PURE__ */ (() =>
|
|
1137
|
+
var managedResourceSchema = /* @__PURE__ */ (() => z10.object({
|
|
1207
1138
|
kind: resourceLifecycleKindSchema,
|
|
1208
1139
|
id: identifier,
|
|
1209
1140
|
key: identifier.nullable(),
|
|
1210
|
-
title:
|
|
1211
|
-
archivedAt:
|
|
1141
|
+
title: z10.string(),
|
|
1142
|
+
archivedAt: z10.number().int().nonnegative().nullable()
|
|
1212
1143
|
}))();
|
|
1213
|
-
var resourceLifecycleInputSchema = /* @__PURE__ */ (() =>
|
|
1214
|
-
actionId:
|
|
1144
|
+
var resourceLifecycleInputSchema = /* @__PURE__ */ (() => z10.object({
|
|
1145
|
+
actionId: z10.string().uuid(),
|
|
1215
1146
|
kind: resourceLifecycleKindSchema,
|
|
1216
1147
|
resource: identifier,
|
|
1217
|
-
archived:
|
|
1148
|
+
archived: z10.boolean(),
|
|
1218
1149
|
reason: lifecycleReasonSchema,
|
|
1219
|
-
expectedArchivedAt:
|
|
1150
|
+
expectedArchivedAt: z10.number().int().nonnegative().nullable().optional()
|
|
1220
1151
|
}).strict())();
|
|
1221
|
-
var resourceLifecycleResultSchema = /* @__PURE__ */ (() =>
|
|
1152
|
+
var resourceLifecycleResultSchema = /* @__PURE__ */ (() => z10.object({
|
|
1222
1153
|
resource: managedResourceSchema,
|
|
1223
|
-
changed:
|
|
1154
|
+
changed: z10.boolean()
|
|
1224
1155
|
}))();
|
|
1225
1156
|
var managedOfferSchema = /* @__PURE__ */ (() => managedResourceSchema.extend({
|
|
1226
|
-
kind:
|
|
1157
|
+
kind: z10.literal("offer")
|
|
1227
1158
|
}))();
|
|
1228
1159
|
var managedTieredRewardSchema = /* @__PURE__ */ (() => managedResourceSchema.extend({
|
|
1229
|
-
kind:
|
|
1160
|
+
kind: z10.literal("tiered-reward")
|
|
1230
1161
|
}))();
|
|
1231
|
-
var managedResourceListSchema = /* @__PURE__ */ (() =>
|
|
1232
|
-
resources:
|
|
1233
|
-
offers:
|
|
1162
|
+
var managedResourceListSchema = /* @__PURE__ */ (() => z10.object({
|
|
1163
|
+
resources: z10.array(managedResourceSchema),
|
|
1164
|
+
offers: z10.array(managedOfferSchema).default([]),
|
|
1234
1165
|
/** Absent from a Relay older than tiered reward archiving; treat it as none. */
|
|
1235
|
-
tieredRewards:
|
|
1166
|
+
tieredRewards: z10.array(managedTieredRewardSchema).optional()
|
|
1236
1167
|
}))();
|
|
1237
|
-
var offerLifecycleResultSchema = /* @__PURE__ */ (() =>
|
|
1168
|
+
var offerLifecycleResultSchema = /* @__PURE__ */ (() => z10.object({
|
|
1238
1169
|
resource: managedOfferSchema,
|
|
1239
|
-
changed:
|
|
1170
|
+
changed: z10.boolean()
|
|
1240
1171
|
}))();
|
|
1241
|
-
var offerLifecycleInputSchema = /* @__PURE__ */ (() =>
|
|
1242
|
-
actionId:
|
|
1172
|
+
var offerLifecycleInputSchema = /* @__PURE__ */ (() => z10.strictObject({
|
|
1173
|
+
actionId: z10.string().uuid(),
|
|
1243
1174
|
offer: identifier,
|
|
1244
|
-
archived:
|
|
1245
|
-
reason:
|
|
1246
|
-
expectedArchivedAt:
|
|
1175
|
+
archived: z10.boolean(),
|
|
1176
|
+
reason: z10.string().trim().min(1).max(500),
|
|
1177
|
+
expectedArchivedAt: z10.number().int().nonnegative().nullable().optional()
|
|
1247
1178
|
}))();
|
|
1248
|
-
var tieredRewardLifecycleResultSchema = /* @__PURE__ */ (() =>
|
|
1179
|
+
var tieredRewardLifecycleResultSchema = /* @__PURE__ */ (() => z10.object({
|
|
1249
1180
|
resource: managedTieredRewardSchema,
|
|
1250
|
-
changed:
|
|
1181
|
+
changed: z10.boolean()
|
|
1251
1182
|
}))();
|
|
1252
1183
|
var tieredRewardLifecycleInputSchema = /* @__PURE__ */ (() => offerLifecycleInputSchema.omit({ offer: true }).extend({ reward: identifier }))();
|
|
1253
1184
|
var resourceLifecyclePaths = {
|
|
@@ -1267,46 +1198,46 @@ var resourceArchiveInputSchema = /* @__PURE__ */ (() => resourceLifecycleInputSc
|
|
|
1267
1198
|
}))();
|
|
1268
1199
|
|
|
1269
1200
|
// src/server/dashboards.ts
|
|
1270
|
-
import * as
|
|
1271
|
-
var dashboardListQuerySchema = /* @__PURE__ */ (() =>
|
|
1272
|
-
includeArchived:
|
|
1201
|
+
import * as z11 from "zod";
|
|
1202
|
+
var dashboardListQuerySchema = /* @__PURE__ */ (() => z11.strictObject({
|
|
1203
|
+
includeArchived: z11.union([z11.boolean(), z11.enum(["true", "false"])]).transform((value) => value === true || value === "true").optional()
|
|
1273
1204
|
}))();
|
|
1274
1205
|
var summaryFields = /* @__PURE__ */ (() => ({
|
|
1275
1206
|
key: identifier,
|
|
1276
|
-
title:
|
|
1277
|
-
description:
|
|
1207
|
+
title: z11.string(),
|
|
1208
|
+
description: z11.string().nullable(),
|
|
1278
1209
|
/** Lists order by it, dashboards without one last, then by title. */
|
|
1279
|
-
position:
|
|
1280
|
-
archivedAt:
|
|
1210
|
+
position: z11.number().int().nullable(),
|
|
1211
|
+
archivedAt: z11.number().int().nonnegative().nullable(),
|
|
1281
1212
|
/** When the current version was published. */
|
|
1282
|
-
updatedAt:
|
|
1213
|
+
updatedAt: z11.number().int().nonnegative()
|
|
1283
1214
|
}))();
|
|
1284
|
-
var dashboardSummarySchema = /* @__PURE__ */ (() =>
|
|
1285
|
-
var dashboardListSchema = /* @__PURE__ */ (() =>
|
|
1286
|
-
var dashboardLifecycleInputSchema = /* @__PURE__ */ (() =>
|
|
1287
|
-
actionId:
|
|
1215
|
+
var dashboardSummarySchema = /* @__PURE__ */ (() => z11.object(summaryFields))();
|
|
1216
|
+
var dashboardListSchema = /* @__PURE__ */ (() => z11.array(dashboardSummarySchema))();
|
|
1217
|
+
var dashboardLifecycleInputSchema = /* @__PURE__ */ (() => z11.strictObject({
|
|
1218
|
+
actionId: z11.string().uuid(),
|
|
1288
1219
|
dashboard: identifier,
|
|
1289
|
-
archived:
|
|
1290
|
-
reason:
|
|
1291
|
-
expectedArchivedAt:
|
|
1220
|
+
archived: z11.boolean(),
|
|
1221
|
+
reason: z11.string().trim().min(1).max(500),
|
|
1222
|
+
expectedArchivedAt: z11.number().int().nonnegative().nullable().optional()
|
|
1292
1223
|
}))();
|
|
1293
|
-
var dashboardLifecycleResultSchema = /* @__PURE__ */ (() =>
|
|
1224
|
+
var dashboardLifecycleResultSchema = /* @__PURE__ */ (() => z11.object({
|
|
1294
1225
|
dashboard: dashboardSummarySchema,
|
|
1295
|
-
changed:
|
|
1226
|
+
changed: z11.boolean()
|
|
1296
1227
|
}))();
|
|
1297
|
-
var dashboardReadQuerySchema = /* @__PURE__ */ (() =>
|
|
1228
|
+
var dashboardReadQuerySchema = /* @__PURE__ */ (() => z11.strictObject({
|
|
1298
1229
|
key: identifier,
|
|
1299
|
-
range:
|
|
1230
|
+
range: z11.enum(analyticsRanges).optional()
|
|
1300
1231
|
}))();
|
|
1301
|
-
var dashboardReadSchema = /* @__PURE__ */ (() =>
|
|
1232
|
+
var dashboardReadSchema = /* @__PURE__ */ (() => z11.object({
|
|
1302
1233
|
...summaryFields,
|
|
1303
1234
|
definition: dashboardDefinitionSchema,
|
|
1304
|
-
range:
|
|
1305
|
-
panels:
|
|
1306
|
-
|
|
1235
|
+
range: z11.enum(analyticsRanges),
|
|
1236
|
+
panels: z11.array(
|
|
1237
|
+
z11.object({
|
|
1307
1238
|
key: identifier,
|
|
1308
1239
|
result: analyticsMetricResultSchema.optional(),
|
|
1309
|
-
error:
|
|
1240
|
+
error: z11.object({ code: z11.string(), message: z11.string() }).optional()
|
|
1310
1241
|
})
|
|
1311
1242
|
)
|
|
1312
1243
|
}))();
|
|
@@ -1315,33 +1246,33 @@ var dashboardReadSchema = /* @__PURE__ */ (() => z12.object({
|
|
|
1315
1246
|
import * as z62 from "zod";
|
|
1316
1247
|
|
|
1317
1248
|
// src/server/client/http.ts
|
|
1318
|
-
import * as
|
|
1249
|
+
import * as z14 from "zod";
|
|
1319
1250
|
|
|
1320
1251
|
// src/server/operations.ts
|
|
1321
|
-
import * as
|
|
1322
|
-
var operationSchema = /* @__PURE__ */ (() =>
|
|
1323
|
-
target:
|
|
1324
|
-
paused:
|
|
1325
|
-
revision:
|
|
1326
|
-
reason:
|
|
1327
|
-
actor:
|
|
1328
|
-
changedAt:
|
|
1329
|
-
}))();
|
|
1330
|
-
var operationInputSchema = /* @__PURE__ */ (() =>
|
|
1331
|
-
target:
|
|
1332
|
-
|
|
1333
|
-
|
|
1252
|
+
import * as z12 from "zod";
|
|
1253
|
+
var operationSchema = /* @__PURE__ */ (() => z12.object({
|
|
1254
|
+
target: z12.string(),
|
|
1255
|
+
paused: z12.boolean(),
|
|
1256
|
+
revision: z12.number().int(),
|
|
1257
|
+
reason: z12.string(),
|
|
1258
|
+
actor: z12.string().nullable(),
|
|
1259
|
+
changedAt: z12.number()
|
|
1260
|
+
}))();
|
|
1261
|
+
var operationInputSchema = /* @__PURE__ */ (() => z12.object({
|
|
1262
|
+
target: z12.union([
|
|
1263
|
+
z12.literal("redemptions"),
|
|
1264
|
+
z12.string().regex(/^quest:[\w-]+$/)
|
|
1334
1265
|
]),
|
|
1335
|
-
paused:
|
|
1336
|
-
revision:
|
|
1337
|
-
reason:
|
|
1266
|
+
paused: z12.boolean(),
|
|
1267
|
+
revision: z12.number().int().nonnegative(),
|
|
1268
|
+
reason: z12.string().trim().min(1).max(500),
|
|
1338
1269
|
actionId: identifier
|
|
1339
1270
|
}).strict())();
|
|
1340
1271
|
|
|
1341
1272
|
// src/server/revision-fence.ts
|
|
1342
|
-
import * as
|
|
1273
|
+
import * as z13 from "zod";
|
|
1343
1274
|
function expectedRevision(schema) {
|
|
1344
|
-
return
|
|
1275
|
+
return z13.preprocess((body, context) => {
|
|
1345
1276
|
if (body === null || typeof body !== "object" || Array.isArray(body) || !("expectedRevision" in body)) {
|
|
1346
1277
|
return body;
|
|
1347
1278
|
}
|
|
@@ -1352,7 +1283,7 @@ function expectedRevision(schema) {
|
|
|
1352
1283
|
message: "expectedRevision and revision name different revisions",
|
|
1353
1284
|
path: ["expectedRevision"]
|
|
1354
1285
|
});
|
|
1355
|
-
return
|
|
1286
|
+
return z13.NEVER;
|
|
1356
1287
|
}
|
|
1357
1288
|
return { ...rest, revision: expectedRevision2 };
|
|
1358
1289
|
}, schema);
|
|
@@ -1384,7 +1315,7 @@ function managementHttp(options) {
|
|
|
1384
1315
|
}
|
|
1385
1316
|
return { request, get, post, create, raw, exchange };
|
|
1386
1317
|
}
|
|
1387
|
-
var ok = /* @__PURE__ */ (() =>
|
|
1318
|
+
var ok = /* @__PURE__ */ (() => z14.object({ ok: z14.literal(true) }))();
|
|
1388
1319
|
function createPointLedger({ create }) {
|
|
1389
1320
|
function run(input, call) {
|
|
1390
1321
|
return create(
|
|
@@ -1397,12 +1328,12 @@ function createPointLedger({ create }) {
|
|
|
1397
1328
|
}
|
|
1398
1329
|
return run;
|
|
1399
1330
|
}
|
|
1400
|
-
function pathFirst(
|
|
1331
|
+
function pathFirst(key2, send) {
|
|
1401
1332
|
function run(first, second, call) {
|
|
1402
1333
|
if (typeof first === "string") {
|
|
1403
1334
|
return send(first, second, call);
|
|
1404
1335
|
}
|
|
1405
|
-
const { [
|
|
1336
|
+
const { [key2]: id, ...input } = first;
|
|
1406
1337
|
return send(
|
|
1407
1338
|
id,
|
|
1408
1339
|
input,
|
|
@@ -1459,10 +1390,10 @@ var operationVerb = ({ post }, target, paused, input, call) => {
|
|
|
1459
1390
|
};
|
|
1460
1391
|
|
|
1461
1392
|
// src/server/client/badges.ts
|
|
1462
|
-
import * as
|
|
1393
|
+
import * as z15 from "zod";
|
|
1463
1394
|
function badges({ create, get, post }) {
|
|
1464
1395
|
return {
|
|
1465
|
-
list: (call) => get("/badges",
|
|
1396
|
+
list: (call) => get("/badges", z15.array(managedBadgeSchema), call),
|
|
1466
1397
|
create: (input, call) => create("/badges", managedBadgeSchema, createBadgeSchema, input, call),
|
|
1467
1398
|
update: (badge, input, call) => {
|
|
1468
1399
|
const body = badgePropertiesSchema.extend(badgeMutationSchema.shape).parse(withActionId(input));
|
|
@@ -1524,7 +1455,7 @@ function content({ get }) {
|
|
|
1524
1455
|
var contentApi = (http) => content(http);
|
|
1525
1456
|
|
|
1526
1457
|
// src/server/client/deployments.ts
|
|
1527
|
-
import * as
|
|
1458
|
+
import * as z16 from "zod";
|
|
1528
1459
|
function deployments({ get, post }) {
|
|
1529
1460
|
function publishDeployment(target, call) {
|
|
1530
1461
|
const id = typeof target === "string" ? identifier.parse(target) : publishDeploymentSchema.parse(target).id;
|
|
@@ -1570,7 +1501,7 @@ function deployments({ get, post }) {
|
|
|
1570
1501
|
*
|
|
1571
1502
|
* @deprecated Use `history`, which pages by `cursor` and `nextCursor`. Removed in 2.0.0.
|
|
1572
1503
|
*/
|
|
1573
|
-
list: (call) => get("/deployments",
|
|
1504
|
+
list: (call) => get("/deployments", z16.array(deploymentRecordSchema), call),
|
|
1574
1505
|
/**
|
|
1575
1506
|
* The project environment's deployments, newest first, one page at a time, with the two
|
|
1576
1507
|
* newest published deployments beside every page. Pass a page's `nextCursor` back as
|
|
@@ -1609,7 +1540,7 @@ function deployments({ get, post }) {
|
|
|
1609
1540
|
var deploymentsApi = (http) => deployments(http);
|
|
1610
1541
|
|
|
1611
1542
|
// src/server/client/engagement.ts
|
|
1612
|
-
import * as
|
|
1543
|
+
import * as z17 from "zod";
|
|
1613
1544
|
function engagement(http) {
|
|
1614
1545
|
const { get, post } = http;
|
|
1615
1546
|
return {
|
|
@@ -1655,7 +1586,7 @@ function engagement(http) {
|
|
|
1655
1586
|
engagementPublishSchema.parse(withActionId(input)),
|
|
1656
1587
|
call
|
|
1657
1588
|
),
|
|
1658
|
-
list: (call) => get("/engagement",
|
|
1589
|
+
list: (call) => get("/engagement", z17.array(engagementRuleSchema), call),
|
|
1659
1590
|
page: (input, call) => get(
|
|
1660
1591
|
"/engagement/history" + queryString(engagementPageQuerySchema.parse(input)),
|
|
1661
1592
|
engagementPageSchema,
|
|
@@ -1735,6 +1666,152 @@ var groupsApi = (http) => groups(http);
|
|
|
1735
1666
|
|
|
1736
1667
|
// src/server/client/leaderboards.ts
|
|
1737
1668
|
import * as z19 from "zod";
|
|
1669
|
+
|
|
1670
|
+
// src/server/settlement-payouts.ts
|
|
1671
|
+
import * as z18 from "zod";
|
|
1672
|
+
var timestamp2 = /* @__PURE__ */ (() => z18.number().int().safe().nonnegative())();
|
|
1673
|
+
var index = /* @__PURE__ */ (() => z18.number().int().safe().nonnegative())();
|
|
1674
|
+
var actionId = /* @__PURE__ */ (() => z18.string().uuid().default(() => crypto.randomUUID()))();
|
|
1675
|
+
var signatureSchema = /* @__PURE__ */ (() => z18.string().min(64).max(88).regex(/^[1-9A-HJ-NP-Za-km-z]+$/))();
|
|
1676
|
+
var solanaPayoutMintSchema = /* @__PURE__ */ (() => z18.union([
|
|
1677
|
+
z18.literal("SOL"),
|
|
1678
|
+
solanaAddressSchema
|
|
1679
|
+
]))();
|
|
1680
|
+
var solanaPayoutSquadsSchema = /* @__PURE__ */ (() => z18.strictObject({
|
|
1681
|
+
/** The multisig account (not its vault). */
|
|
1682
|
+
multisig: solanaAddressSchema,
|
|
1683
|
+
/** The vault the payout pays from; Squads' default vault is 0. */
|
|
1684
|
+
vaultIndex: z18.number().int().min(0).max(255).default(0),
|
|
1685
|
+
/** The member that signs each batch's proposal transaction and pays its fees and rent. */
|
|
1686
|
+
proposer: solanaAddressSchema
|
|
1687
|
+
}))();
|
|
1688
|
+
var solanaPayoutInputSchema = /* @__PURE__ */ (() => z18.strictObject({
|
|
1689
|
+
actionId,
|
|
1690
|
+
/** The cluster, by CAIP-2 ID. */
|
|
1691
|
+
network: z18.enum([solanaMainnet, solanaDevnet]),
|
|
1692
|
+
mint: solanaPayoutMintSchema,
|
|
1693
|
+
/** The wallet that signs every batch, pays its fees and rent, and holds the tokens. */
|
|
1694
|
+
payer: solanaAddressSchema.optional(),
|
|
1695
|
+
/** The Squads multisig whose vault pays, instead of a wallet. */
|
|
1696
|
+
squads: solanaPayoutSquadsSchema.optional()
|
|
1697
|
+
}).refine((input) => input.payer === void 0 !== !input.squads, {
|
|
1698
|
+
message: "Pass payer to pay from a wallet, or squads to pay from a multisig",
|
|
1699
|
+
path: ["payer"]
|
|
1700
|
+
}))();
|
|
1701
|
+
var solanaPayoutConfirmationSchema = /* @__PURE__ */ (() => z18.strictObject({
|
|
1702
|
+
actionId,
|
|
1703
|
+
/** Signatures of transactions the team sent, which Relay reads first. */
|
|
1704
|
+
signatures: z18.array(signatureSchema).max(100).default([])
|
|
1705
|
+
}))();
|
|
1706
|
+
var batchSchema = /* @__PURE__ */ (() => z18.object({
|
|
1707
|
+
index,
|
|
1708
|
+
/** The SPL Memo text the batch carries, which Relay finds it by. */
|
|
1709
|
+
memo: z18.string(),
|
|
1710
|
+
/**
|
|
1711
|
+
* The unsigned v0 transaction, base64. Its fee payer and only signer signs it: the payer, or for
|
|
1712
|
+
* a Squads payout the proposer.
|
|
1713
|
+
*/
|
|
1714
|
+
transaction: z18.string(),
|
|
1715
|
+
status: z18.string(),
|
|
1716
|
+
/** The transaction Relay found for the batch; null while pending or expired. */
|
|
1717
|
+
signature: z18.string().nullable(),
|
|
1718
|
+
/** Base units the batch pays. */
|
|
1719
|
+
amount: baseUnitsSchema,
|
|
1720
|
+
/** Lamports for the token accounts the batch creates. */
|
|
1721
|
+
rent: baseUnitsSchema,
|
|
1722
|
+
/** The Squads vault transaction's index in its multisig; null for a wallet payout. */
|
|
1723
|
+
transactionIndex: z18.string().nullable().default(null),
|
|
1724
|
+
/** The address of the batch's Squads proposal account; null for a wallet payout. */
|
|
1725
|
+
proposal: z18.string().nullable().default(null),
|
|
1726
|
+
payments: z18.array(
|
|
1727
|
+
z18.object({
|
|
1728
|
+
member: identifier,
|
|
1729
|
+
/** The member's proven Solana wallet the share goes to. */
|
|
1730
|
+
wallet: z18.string(),
|
|
1731
|
+
amount: baseUnitsSchema
|
|
1732
|
+
})
|
|
1733
|
+
)
|
|
1734
|
+
}))();
|
|
1735
|
+
var solanaPayoutSchema = /* @__PURE__ */ (() => z18.object({
|
|
1736
|
+
id: identifier,
|
|
1737
|
+
settlement: identifier,
|
|
1738
|
+
network: z18.string(),
|
|
1739
|
+
/** `"SOL"` or the mint address. */
|
|
1740
|
+
mint: z18.string(),
|
|
1741
|
+
/** The mint's token program; null for SOL. */
|
|
1742
|
+
tokenProgram: z18.string().nullable(),
|
|
1743
|
+
/** What pays: `wallet`, or `squads`, whose vault is `payer`. */
|
|
1744
|
+
source: z18.string().default("wallet"),
|
|
1745
|
+
/** The account that holds the tokens and pays: the wallet, or the multisig's vault. */
|
|
1746
|
+
payer: z18.string(),
|
|
1747
|
+
/** The Squads multisig, for a payout from its vault; null for a wallet payout. */
|
|
1748
|
+
squads: z18.object({
|
|
1749
|
+
multisig: z18.string(),
|
|
1750
|
+
vaultIndex: z18.number().int().min(0).max(255),
|
|
1751
|
+
proposer: z18.string(),
|
|
1752
|
+
/**
|
|
1753
|
+
* Lamports the proposer puts into each batch's vault transaction and proposal accounts,
|
|
1754
|
+
* together. Squads returns them to the multisig's rent collector when the accounts close.
|
|
1755
|
+
*/
|
|
1756
|
+
accountRent: baseUnitsSchema
|
|
1757
|
+
}).nullable().default(null),
|
|
1758
|
+
decimals: index,
|
|
1759
|
+
/** Base units the batches pay together. */
|
|
1760
|
+
total: baseUnitsSchema,
|
|
1761
|
+
/** Lamports the payer spends on token accounts the batches create, at the build's rent. */
|
|
1762
|
+
rent: baseUnitsSchema,
|
|
1763
|
+
/**
|
|
1764
|
+
* Lamports spent on signature fees, one signature per batch: by the payer, or by the proposer of
|
|
1765
|
+
* a Squads payout.
|
|
1766
|
+
*/
|
|
1767
|
+
fees: baseUnitsSchema,
|
|
1768
|
+
/**
|
|
1769
|
+
* The last block height at which the batches can land; after it, they expire. For a Squads
|
|
1770
|
+
* payout, the height by which the proposals must be created.
|
|
1771
|
+
*/
|
|
1772
|
+
lastValidBlockHeight: z18.string(),
|
|
1773
|
+
createdAt: timestamp2,
|
|
1774
|
+
createdBy: z18.string(),
|
|
1775
|
+
batches: z18.array(batchSchema),
|
|
1776
|
+
/** Winners with a non-zero, unpaid share this payout leaves out. */
|
|
1777
|
+
skipped: z18.array(
|
|
1778
|
+
z18.object({
|
|
1779
|
+
member: identifier,
|
|
1780
|
+
share: baseUnitsSchema,
|
|
1781
|
+
reason: z18.string()
|
|
1782
|
+
})
|
|
1783
|
+
)
|
|
1784
|
+
}))();
|
|
1785
|
+
var solanaPayoutQuerySchema = /* @__PURE__ */ (() => z18.strictObject({
|
|
1786
|
+
cursor: pageCursorSchema.optional(),
|
|
1787
|
+
limit: z18.coerce.number().int().min(1).max(25).default(10)
|
|
1788
|
+
}))();
|
|
1789
|
+
var solanaPayoutPageSchema = /* @__PURE__ */ (() => z18.object({
|
|
1790
|
+
items: z18.array(solanaPayoutSchema),
|
|
1791
|
+
nextCursor: pageCursorSchema.nullable()
|
|
1792
|
+
}))();
|
|
1793
|
+
var solanaPayoutConfirmationResultSchema = /* @__PURE__ */ (() => z18.object({
|
|
1794
|
+
settlement: identifier,
|
|
1795
|
+
batches: z18.array(
|
|
1796
|
+
z18.object({
|
|
1797
|
+
payout: identifier,
|
|
1798
|
+
index,
|
|
1799
|
+
status: z18.string(),
|
|
1800
|
+
signature: z18.string().nullable()
|
|
1801
|
+
})
|
|
1802
|
+
),
|
|
1803
|
+
paid: index,
|
|
1804
|
+
pending: index,
|
|
1805
|
+
unpaid: index
|
|
1806
|
+
}))();
|
|
1807
|
+
function squadsProposalUrl(payout, batch) {
|
|
1808
|
+
if (payout.source !== "squads" || !batch.proposal) {
|
|
1809
|
+
return null;
|
|
1810
|
+
}
|
|
1811
|
+
return payout.network === solanaDevnet ? `https://explorer.solana.com/address/${batch.proposal}?cluster=devnet` : `https://app.squads.so/squads/${payout.payer}/transactions`;
|
|
1812
|
+
}
|
|
1813
|
+
|
|
1814
|
+
// src/server/client/leaderboards.ts
|
|
1738
1815
|
function leaderboards(http) {
|
|
1739
1816
|
const { get, post } = http;
|
|
1740
1817
|
return {
|
|
@@ -1825,6 +1902,41 @@ function leaderboards(http) {
|
|
|
1825
1902
|
leaderboardSettlementExportSchema,
|
|
1826
1903
|
call
|
|
1827
1904
|
),
|
|
1905
|
+
/**
|
|
1906
|
+
* Builds unsigned Solana transfer batches that pay an approved settlement's unpaid token pool
|
|
1907
|
+
* shares from `payer`, to each winner's most recently linked proven Solana wallet. The team
|
|
1908
|
+
* signs and sends them; then call `confirmSolanaPayout`. Requires review permission.
|
|
1909
|
+
*
|
|
1910
|
+
* @experimental A minor release can change this method and its result.
|
|
1911
|
+
*/
|
|
1912
|
+
buildSolanaPayout: (settlement, input, call) => post(
|
|
1913
|
+
`/leaderboard-settlements/${identifier.parse(settlement)}/solana-payouts`,
|
|
1914
|
+
solanaPayoutSchema,
|
|
1915
|
+
solanaPayoutInputSchema.parse(withActionId(input)),
|
|
1916
|
+
call
|
|
1917
|
+
),
|
|
1918
|
+
/**
|
|
1919
|
+
* Reads the outcome of a settlement's unsettled payout batches on chain and marks the shares
|
|
1920
|
+
* they paid. Safe to repeat. Requires review permission.
|
|
1921
|
+
*
|
|
1922
|
+
* @experimental A minor release can change this method and its result.
|
|
1923
|
+
*/
|
|
1924
|
+
confirmSolanaPayout: (settlement, input = {}, call) => post(
|
|
1925
|
+
`/leaderboard-settlements/${identifier.parse(settlement)}/solana-payouts/confirm`,
|
|
1926
|
+
solanaPayoutConfirmationResultSchema,
|
|
1927
|
+
solanaPayoutConfirmationSchema.parse(withActionId(input)),
|
|
1928
|
+
call
|
|
1929
|
+
),
|
|
1930
|
+
/**
|
|
1931
|
+
* A settlement's Solana payouts with their batches, newest first. Requires read permission.
|
|
1932
|
+
*
|
|
1933
|
+
* @experimental A minor release can change this method and its result.
|
|
1934
|
+
*/
|
|
1935
|
+
solanaPayouts: (settlement, query = {}, call) => get(
|
|
1936
|
+
`/leaderboard-settlements/${identifier.parse(settlement)}/solana-payouts${queryString(solanaPayoutQuerySchema.parse(query))}`,
|
|
1937
|
+
solanaPayoutPageSchema,
|
|
1938
|
+
call
|
|
1939
|
+
),
|
|
1828
1940
|
rejectSettlement: (settlement, input, call) => post(
|
|
1829
1941
|
`/leaderboard-settlements/${identifier.parse(settlement)}/reject`,
|
|
1830
1942
|
leaderboardSettlementReviewSchema,
|
|
@@ -2018,12 +2130,12 @@ function referrals(http) {
|
|
|
2018
2130
|
/** @deprecated Use `pause` or `resume`, `qualify` or `resolveReward`. Removed in 2.0.0. */
|
|
2019
2131
|
control: (input, call) => {
|
|
2020
2132
|
const parsed = referralControlSchema.parse(withActionId(input));
|
|
2021
|
-
const { actionId:
|
|
2133
|
+
const { actionId: actionId3, reason } = parsed;
|
|
2022
2134
|
if (parsed.kind === "suspend") {
|
|
2023
2135
|
return post(
|
|
2024
2136
|
`/referral-relationships/${parsed.member}/suspend`,
|
|
2025
2137
|
ok,
|
|
2026
|
-
{ actionId:
|
|
2138
|
+
{ actionId: actionId3, suspended: parsed.suspended, reason },
|
|
2027
2139
|
call
|
|
2028
2140
|
);
|
|
2029
2141
|
}
|
|
@@ -2031,14 +2143,14 @@ function referrals(http) {
|
|
|
2031
2143
|
return post(
|
|
2032
2144
|
`/referral-programs/${parsed.program}/members/${parsed.member}/qualify`,
|
|
2033
2145
|
ok,
|
|
2034
|
-
{ actionId:
|
|
2146
|
+
{ actionId: actionId3, qualified: parsed.qualified, reason },
|
|
2035
2147
|
call
|
|
2036
2148
|
);
|
|
2037
2149
|
}
|
|
2038
2150
|
return post(
|
|
2039
2151
|
`/referral-rewards/${parsed.entitlement}/resolve`,
|
|
2040
2152
|
ok,
|
|
2041
|
-
{ actionId:
|
|
2153
|
+
{ actionId: actionId3, reason },
|
|
2042
2154
|
call
|
|
2043
2155
|
);
|
|
2044
2156
|
}
|
|
@@ -2048,23 +2160,38 @@ var referralsApi = (http) => referrals(http);
|
|
|
2048
2160
|
|
|
2049
2161
|
// src/server/client/trackers.ts
|
|
2050
2162
|
import * as z23 from "zod";
|
|
2163
|
+
var sampledCreateSchemas = {
|
|
2164
|
+
"wallet-program-activity": programActivityTrackerCreateSchema,
|
|
2165
|
+
"wallet-nfts": nftTrackerCreateSchema,
|
|
2166
|
+
"wallet-stake": stakeTrackerCreateSchema,
|
|
2167
|
+
"wallet-program-accounts": programAccountTrackerCreateSchema
|
|
2168
|
+
};
|
|
2051
2169
|
function trackers(http) {
|
|
2052
2170
|
const { create, get, post } = http;
|
|
2053
2171
|
return {
|
|
2054
2172
|
/**
|
|
2055
2173
|
* Creates a tracker as data in test, with the same validation as `defineTracker`; requires
|
|
2056
2174
|
* `publish`. Name its source with `source`, such as `{ kind: "discord-messages", text: true }`,
|
|
2057
|
-
* or an X search with `query` alone
|
|
2058
|
-
* `
|
|
2059
|
-
* a
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2175
|
+
* or an X search with `query` alone, a `wallet.programActivity()` source with
|
|
2176
|
+
* `{ kind: "wallet-program-activity", chain, program, instruction, mint, minAmount, anySigner }`,
|
|
2177
|
+
* a `wallet.nfts()` source with `{ kind: "wallet-nfts", collection }`, a `wallet.stake()`
|
|
2178
|
+
* source with `{ kind: "wallet-stake", chain, voteAccount }`, or a `wallet.programAccounts()`
|
|
2179
|
+
* source with `{ kind: "wallet-program-accounts", chain, program, account, seeds, field, idl }`.
|
|
2180
|
+
* An X tracker's first collection searches from `window.start`. Live refuses it with
|
|
2181
|
+
* `promotion-required`: the tracker reaches live through a promotion. A key a deployment
|
|
2182
|
+
* already publishes is refused with `tracker-owned-by-code`.
|
|
2183
|
+
*/
|
|
2184
|
+
create: (input, call) => {
|
|
2185
|
+
const kind = input.source?.kind;
|
|
2186
|
+
const schema = kind !== void 0 && Object.hasOwn(sampledCreateSchemas, kind) ? sampledCreateSchemas[kind] : managedTrackerCreateSchema;
|
|
2187
|
+
return create(
|
|
2188
|
+
"/trackers",
|
|
2189
|
+
trackerStatusSchema,
|
|
2190
|
+
schema,
|
|
2191
|
+
input,
|
|
2192
|
+
call
|
|
2193
|
+
);
|
|
2194
|
+
},
|
|
2068
2195
|
/**
|
|
2069
2196
|
* Changes a tracker created with `create`, in test; fields left out keep their value. `source`
|
|
2070
2197
|
* replaces the source's settings but never its kind (`validation-failed`). A new query or
|
|
@@ -2426,7 +2553,13 @@ var billingSubscriptionSchema = /* @__PURE__ */ (() => subscriptionSchema(billin
|
|
|
2426
2553
|
var projectBillingSchema = /* @__PURE__ */ (() => z25.object({
|
|
2427
2554
|
available: z25.boolean(),
|
|
2428
2555
|
reason: z25.enum(["admin-required", "staff-only", "not-configured"]).nullable(),
|
|
2429
|
-
subscription: billingSubscriptionSchema.nullable()
|
|
2556
|
+
subscription: billingSubscriptionSchema.nullable(),
|
|
2557
|
+
offer: z25.object({
|
|
2558
|
+
id: z25.string(),
|
|
2559
|
+
plan: billingPlanSchema,
|
|
2560
|
+
interval: z25.enum(billingIntervals),
|
|
2561
|
+
freeMonths: z25.number().int()
|
|
2562
|
+
}).nullable().optional()
|
|
2430
2563
|
}))();
|
|
2431
2564
|
var projectPlanSchema = /* @__PURE__ */ (() => z25.object({
|
|
2432
2565
|
plan: z25.string(),
|
|
@@ -2681,9 +2814,9 @@ function dashboards({ get, post }) {
|
|
|
2681
2814
|
* other panels still have results. Requires `read` permission.
|
|
2682
2815
|
*/
|
|
2683
2816
|
read: (query, call) => {
|
|
2684
|
-
const { key, ...rest } = dashboardReadQuerySchema.parse(query);
|
|
2817
|
+
const { key: key2, ...rest } = dashboardReadQuerySchema.parse(query);
|
|
2685
2818
|
return get(
|
|
2686
|
-
`/dashboards/${
|
|
2819
|
+
`/dashboards/${key2}${queryString(rest)}`,
|
|
2687
2820
|
dashboardReadSchema,
|
|
2688
2821
|
call
|
|
2689
2822
|
);
|
|
@@ -2693,15 +2826,15 @@ function dashboards({ get, post }) {
|
|
|
2693
2826
|
* `includeArchived`, stays readable, and stays archived when its code deploys again. Live
|
|
2694
2827
|
* gets the change through a promotion. Requires `publish` permission.
|
|
2695
2828
|
*/
|
|
2696
|
-
archive: (
|
|
2697
|
-
`/dashboards/${identifier.parse(
|
|
2829
|
+
archive: (key2, input, call) => post(
|
|
2830
|
+
`/dashboards/${identifier.parse(key2)}/archive`,
|
|
2698
2831
|
dashboardLifecycleResultSchema,
|
|
2699
2832
|
resourceArchiveInputSchema.parse(withActionId(input)),
|
|
2700
2833
|
call
|
|
2701
2834
|
),
|
|
2702
2835
|
/** Restore an archived dashboard in test. Requires `publish` permission. */
|
|
2703
|
-
unarchive: (
|
|
2704
|
-
`/dashboards/${identifier.parse(
|
|
2836
|
+
unarchive: (key2, input, call) => post(
|
|
2837
|
+
`/dashboards/${identifier.parse(key2)}/unarchive`,
|
|
2705
2838
|
dashboardLifecycleResultSchema,
|
|
2706
2839
|
resourceArchiveInputSchema.parse(withActionId(input)),
|
|
2707
2840
|
call
|
|
@@ -2898,6 +3031,35 @@ function attempts({ get, post }) {
|
|
|
2898
3031
|
submitSchema.parse(withActionId(input)),
|
|
2899
3032
|
call
|
|
2900
3033
|
),
|
|
3034
|
+
/**
|
|
3035
|
+
* Completes a quest from a Solana transaction a member signed: Relay reads the transaction at
|
|
3036
|
+
* `finalized` on `chain` (mainnet by default) and runs a normal attempt for the member whose
|
|
3037
|
+
* linked wallet signed it, which the quest's evaluator decides, with the transaction in
|
|
3038
|
+
* `ctx.action`. Requires `ingest` permission. The transaction must have succeeded and carry the
|
|
3039
|
+
* quest's memo (`solanaActionMemo({ quest, reference? })` in an SPL Memo instruction); only a
|
|
3040
|
+
* member-submitted `manual()` quest without input accepts one. Resolves with the queued attempt,
|
|
3041
|
+
* or with the first attempt when the signature was already submitted.
|
|
3042
|
+
*
|
|
3043
|
+
* Refusals: 409 `transaction-not-final` (with `Retry-After`) until the transaction is
|
|
3044
|
+
* finalized, about 13 seconds after it lands, so retry it; 422 `transaction-failed`; 422
|
|
3045
|
+
* `transaction-not-for-quest` when it carries no memo for this quest; 404 `wallet-not-linked`
|
|
3046
|
+
* when no signer is a member's linked wallet; 409 `account-ambiguous` when signers belong to
|
|
3047
|
+
* different members; 422 `quest-not-transaction-completable` for any other kind of quest; on a
|
|
3048
|
+
* quest with check-in stations, 422 `station-unknown` when the memo names none of them and 409
|
|
3049
|
+
* `station-closed` when the station was closed at the transaction's block time, or 409
|
|
3050
|
+
* `station-revoked` when an operator revoked it (`quests.stations.revoke`), whenever it was
|
|
3051
|
+
* signed; 502
|
|
3052
|
+
* `unavailable` when the Solana read failed, so retry it; 429 `rate-limited` past the project
|
|
3053
|
+
* environment's budget of 1,500 reads per 10 minutes.
|
|
3054
|
+
*
|
|
3055
|
+
* @experimental A minor release can change this method and its result.
|
|
3056
|
+
*/
|
|
3057
|
+
submitSolanaTransaction: (input, call) => post(
|
|
3058
|
+
"/attempts/solana-transaction",
|
|
3059
|
+
attemptSchema,
|
|
3060
|
+
solanaTransactionSubmissionSchema.parse(input),
|
|
3061
|
+
call
|
|
3062
|
+
),
|
|
2901
3063
|
/**
|
|
2902
3064
|
* Accepts or rejects an attempt waiting for review, at the `generation` the reviewer saw,
|
|
2903
3065
|
* with a reason; requires `review` permission.
|
|
@@ -3025,181 +3187,22 @@ function passes({ post }) {
|
|
|
3025
3187
|
}
|
|
3026
3188
|
var passesApi = (http) => passes(http);
|
|
3027
3189
|
|
|
3028
|
-
// src/server/completions.ts
|
|
3029
|
-
import * as z31 from "zod";
|
|
3030
|
-
var completionRevokeSchema = /* @__PURE__ */ (() => z31.object({
|
|
3031
|
-
actionId: identifier,
|
|
3032
|
-
reason: z31.string().trim().min(1).max(500),
|
|
3033
|
-
freeOccurrence: z31.boolean().default(false)
|
|
3034
|
-
}).strict())();
|
|
3035
|
-
var RevokedEntitlementOutcome = {
|
|
3036
|
-
/** No other completion grants the reward: it is void, after cancelling a handover in progress. */
|
|
3037
|
-
Voided: "voided",
|
|
3038
|
-
/** Lowered to the best tier another completion grants, after cancelling a handover in progress. */
|
|
3039
|
-
Downgraded: "downgraded",
|
|
3040
|
-
/** Another completion grants the same tier, or it was already void. */
|
|
3041
|
-
Kept: "kept",
|
|
3042
|
-
/** Already collected: its earned tier follows the other completions, and the item stays handed over. */
|
|
3043
|
-
Flagged: "flagged"
|
|
3044
|
-
};
|
|
3045
|
-
var RevokedDeliveryOutcome = {
|
|
3046
|
-
/** The role was delivered and stays: remove it in Discord if appropriate. */
|
|
3047
|
-
Flagged: "flagged",
|
|
3048
|
-
/** The grant was stopped before any call to Discord. */
|
|
3049
|
-
Cancelled: "cancelled",
|
|
3050
|
-
/** The grant was stopped, but a call to Discord may already have been sent and can still land. */
|
|
3051
|
-
InFlight: "in-flight",
|
|
3052
|
-
/** The grant had failed, so Discord never received the role. */
|
|
3053
|
-
NotDelivered: "not-delivered"
|
|
3054
|
-
};
|
|
3055
|
-
var RevokedReferralOutcome = {
|
|
3056
|
-
/** The inviter's rewards for this member are reversed. */
|
|
3057
|
-
Unqualified: "unqualified",
|
|
3058
|
-
/** Qualified on another accepted completion of the program's quest instead. */
|
|
3059
|
-
Requalified: "requalified"
|
|
3060
|
-
};
|
|
3061
|
-
var entitlementOutcomeSchema = /* @__PURE__ */ (() => z31.string().min(1).max(64))();
|
|
3062
|
-
var deliveryOutcomeSchema = /* @__PURE__ */ (() => z31.string().min(1).max(64))();
|
|
3063
|
-
var referralOutcomeSchema = /* @__PURE__ */ (() => z31.string().min(1).max(64))();
|
|
3064
|
-
var completionRevocationSchema = /* @__PURE__ */ (() => z31.object({
|
|
3065
|
-
completion: identifier,
|
|
3066
|
-
/** The quest ID, or the board ID when `source.kind` is `leaderboard`. */
|
|
3067
|
-
quest: identifier,
|
|
3068
|
-
member: identifier,
|
|
3069
|
-
/** What paid the revoked completion. `source.id` repeats `quest`. */
|
|
3070
|
-
source: completionSourceSchema.optional(),
|
|
3071
|
-
revokedAt: z31.number(),
|
|
3072
|
-
occurrenceFreed: z31.boolean(),
|
|
3073
|
-
badges: z31.array(z31.object({ badge: identifier, stillAwarded: z31.boolean() })).optional(),
|
|
3074
|
-
groups: z31.array(z31.object({ group: identifier, stillMember: z31.boolean() })).optional(),
|
|
3075
|
-
points: z31.array(
|
|
3076
|
-
z31.object({
|
|
3077
|
-
entry: identifier,
|
|
3078
|
-
balance: identifier,
|
|
3079
|
-
reversal: identifier.nullable(),
|
|
3080
|
-
reversed: z31.number().int(),
|
|
3081
|
-
unreversed: z31.number().int()
|
|
3082
|
-
})
|
|
3083
|
-
),
|
|
3084
|
-
entitlements: z31.array(
|
|
3085
|
-
z31.object({
|
|
3086
|
-
entitlement: identifier,
|
|
3087
|
-
reward: identifier,
|
|
3088
|
-
outcome: entitlementOutcomeSchema,
|
|
3089
|
-
status: z31.string()
|
|
3090
|
-
})
|
|
3091
|
-
),
|
|
3092
|
-
deliveries: z31.array(
|
|
3093
|
-
z31.object({
|
|
3094
|
-
delivery: z31.string(),
|
|
3095
|
-
roleId: z31.string(),
|
|
3096
|
-
outcome: deliveryOutcomeSchema,
|
|
3097
|
-
/**
|
|
3098
|
-
* By Relay's records, another accepted, unrevoked completion of the member also granted this
|
|
3099
|
-
* role to the same Discord account and server. Relay does not read Discord's membership.
|
|
3100
|
-
*/
|
|
3101
|
-
stillGranted: z31.boolean()
|
|
3102
|
-
})
|
|
3103
|
-
),
|
|
3104
|
-
referrals: z31.array(
|
|
3105
|
-
z31.object({
|
|
3106
|
-
program: identifier,
|
|
3107
|
-
outcome: referralOutcomeSchema
|
|
3108
|
-
})
|
|
3109
|
-
),
|
|
3110
|
-
streakMilestone: z31.boolean(),
|
|
3111
|
-
budgets: z31.array(
|
|
3112
|
-
z31.object({ budget: identifier, released: z31.number().int().nonnegative() })
|
|
3113
|
-
).optional()
|
|
3114
|
-
}))();
|
|
3115
|
-
var completionRestoreSchema = /* @__PURE__ */ (() => z31.object({
|
|
3116
|
-
actionId: identifier,
|
|
3117
|
-
reason: z31.string().trim().min(1).max(500)
|
|
3118
|
-
}).strict())();
|
|
3119
|
-
var RestoredEntitlementOutcome = {
|
|
3120
|
-
/** The revocation voided it, and it is available again. */
|
|
3121
|
-
Restored: "restored",
|
|
3122
|
-
/** The revocation lowered or flagged it: its earned tier is the completion's again. */
|
|
3123
|
-
Raised: "raised",
|
|
3124
|
-
/** It changed since the revocation (an operator restored, voided or corrected it), so it stays. */
|
|
3125
|
-
Kept: "kept"
|
|
3126
|
-
};
|
|
3127
|
-
var RestoredDeliveryOutcome = {
|
|
3128
|
-
/** The grant had not reached Discord, and it is queued again. */
|
|
3129
|
-
Requeued: "requeued",
|
|
3130
|
-
/** The grant counts again for reconciliation, and its delivery status stays. */
|
|
3131
|
-
Kept: "kept"
|
|
3132
|
-
};
|
|
3133
|
-
var RestoredReferralOutcome = {
|
|
3134
|
-
/** The member qualifies on this completion again. */
|
|
3135
|
-
Qualified: "qualified",
|
|
3136
|
-
/** The program is disabled or gone, or the referral is suspended, so nothing changed. */
|
|
3137
|
-
Kept: "kept"
|
|
3138
|
-
};
|
|
3139
|
-
var openOutcome = /* @__PURE__ */ (() => z31.string().min(1).max(64))();
|
|
3140
|
-
var completionRestorationSchema = /* @__PURE__ */ (() => z31.object({
|
|
3141
|
-
completion: identifier,
|
|
3142
|
-
/** The quest ID, or the board ID when `source.kind` is `leaderboard`. */
|
|
3143
|
-
quest: identifier,
|
|
3144
|
-
member: identifier,
|
|
3145
|
-
source: completionSourceSchema.optional(),
|
|
3146
|
-
restoredAt: z31.number(),
|
|
3147
|
-
points: z31.array(
|
|
3148
|
-
z31.object({
|
|
3149
|
-
entry: identifier,
|
|
3150
|
-
balance: identifier,
|
|
3151
|
-
reversal: identifier,
|
|
3152
|
-
amount: z31.number().int()
|
|
3153
|
-
})
|
|
3154
|
-
),
|
|
3155
|
-
badges: z31.array(z31.object({ badge: identifier })),
|
|
3156
|
-
groups: z31.array(z31.object({ group: identifier, added: z31.boolean() })),
|
|
3157
|
-
entitlements: z31.array(
|
|
3158
|
-
z31.object({
|
|
3159
|
-
entitlement: identifier,
|
|
3160
|
-
reward: identifier,
|
|
3161
|
-
outcome: openOutcome,
|
|
3162
|
-
status: z31.string()
|
|
3163
|
-
})
|
|
3164
|
-
),
|
|
3165
|
-
deliveries: z31.array(
|
|
3166
|
-
z31.object({
|
|
3167
|
-
delivery: z31.string(),
|
|
3168
|
-
roleId: z31.string(),
|
|
3169
|
-
outcome: openOutcome
|
|
3170
|
-
})
|
|
3171
|
-
),
|
|
3172
|
-
referrals: z31.array(
|
|
3173
|
-
z31.object({
|
|
3174
|
-
program: identifier,
|
|
3175
|
-
outcome: openOutcome
|
|
3176
|
-
})
|
|
3177
|
-
),
|
|
3178
|
-
streakMilestone: z31.boolean(),
|
|
3179
|
-
budgets: z31.array(
|
|
3180
|
-
z31.object({ budget: identifier, charged: z31.number().int().nonnegative() })
|
|
3181
|
-
).optional()
|
|
3182
|
-
}))();
|
|
3183
|
-
var completionRevocationShortfallSchema = /* @__PURE__ */ (() => z31.object({
|
|
3184
|
-
completion: identifier,
|
|
3185
|
-
quest: identifier,
|
|
3186
|
-
revokedAt: z31.number().int().nonnegative().safe(),
|
|
3187
|
-
unreversedPoints: z31.record(identifier, z31.number().int().positive().safe())
|
|
3188
|
-
}))();
|
|
3189
|
-
var revokedCompletionSchema = /* @__PURE__ */ (() => z31.object({
|
|
3190
|
-
completion: identifier,
|
|
3191
|
-
quest: identifier,
|
|
3192
|
-
/** The completion key: its occurrence, such as `once` or a day. */
|
|
3193
|
-
key: z31.string(),
|
|
3194
|
-
revokedAt: z31.number().int().nonnegative().safe(),
|
|
3195
|
-
/** Why it was revoked, and what the revoke did, which a restore re-applies. */
|
|
3196
|
-
reason: z31.string().optional(),
|
|
3197
|
-
revocation: completionRevocationSchema.optional()
|
|
3198
|
-
}))();
|
|
3199
|
-
|
|
3200
3190
|
// src/server/client/completions.ts
|
|
3201
|
-
function completions({ post }) {
|
|
3191
|
+
function completions({ get, post }) {
|
|
3202
3192
|
return {
|
|
3193
|
+
/**
|
|
3194
|
+
* One page of a member's completions that count (not revoked), of every quest and leaderboard
|
|
3195
|
+
* prize or of one `quest`, ordered by quest ID, then completion ID; requires `read`
|
|
3196
|
+
* permission. Pass a page's `nextCursor` back as `cursor` for the next page. Fails with 404
|
|
3197
|
+
* `not-found` for a member who has not joined the project.
|
|
3198
|
+
*
|
|
3199
|
+
* @experimental A minor release can change the completions list.
|
|
3200
|
+
*/
|
|
3201
|
+
list: (query, call) => get(
|
|
3202
|
+
`/completions${queryString(memberCompletionQuerySchema.parse(query))}`,
|
|
3203
|
+
memberCompletionPageSchema,
|
|
3204
|
+
call
|
|
3205
|
+
),
|
|
3203
3206
|
/**
|
|
3204
3207
|
* Revokes an accepted completion with a reason; requires `review` permission. In one
|
|
3205
3208
|
* transaction it reverses the completion's points, voids its undelivered tiered rewards and
|
|
@@ -3239,6 +3242,35 @@ function completions({ post }) {
|
|
|
3239
3242
|
completionRestoreSchema.parse(withActionId(body)),
|
|
3240
3243
|
call
|
|
3241
3244
|
)
|
|
3245
|
+
),
|
|
3246
|
+
/**
|
|
3247
|
+
* Records what your server did off-platform for a completion, such as minting a badge or
|
|
3248
|
+
* sending a payout, by the transaction that did it; requires `points` permission. A completion
|
|
3249
|
+
* holds one receipt per `key`: the same key with the same values answers the stored receipt, so
|
|
3250
|
+
* a retry is safe, and other values fail with 409 `receipt-conflict`. A completion holds at most
|
|
3251
|
+
* 20 receipts (409 `receipt-limit`). Relay does not read the chain. Console shows the receipt
|
|
3252
|
+
* on the completion, with an explorer link on Solana mainnet and devnet, and the audit history
|
|
3253
|
+
* records it. A revoked completion keeps its receipts, and takes new ones. Erasing the member
|
|
3254
|
+
* deletes them.
|
|
3255
|
+
*
|
|
3256
|
+
* @experimental A minor release can change completion receipts.
|
|
3257
|
+
*/
|
|
3258
|
+
recordReceipt: (completion, body, call) => post(
|
|
3259
|
+
`/completions/${identifier.parse(completion)}/receipts`,
|
|
3260
|
+
completionReceiptSchema,
|
|
3261
|
+
completionReceiptInputSchema.parse(withActionId(body)),
|
|
3262
|
+
call
|
|
3263
|
+
),
|
|
3264
|
+
/**
|
|
3265
|
+
* The completion's receipts, oldest first; requires `read` permission. Fails with 404
|
|
3266
|
+
* `not-found` for a completion this project and environment don't have.
|
|
3267
|
+
*
|
|
3268
|
+
* @experimental A minor release can change completion receipts.
|
|
3269
|
+
*/
|
|
3270
|
+
receipts: (completion, call) => get(
|
|
3271
|
+
`/completions/${identifier.parse(completion)}/receipts`,
|
|
3272
|
+
completionReceiptListSchema,
|
|
3273
|
+
call
|
|
3242
3274
|
)
|
|
3243
3275
|
};
|
|
3244
3276
|
}
|
|
@@ -3278,20 +3310,20 @@ function handover({ post }) {
|
|
|
3278
3310
|
var handoverApi = (http) => handover(http);
|
|
3279
3311
|
|
|
3280
3312
|
// src/server/entitlements.ts
|
|
3281
|
-
import * as
|
|
3282
|
-
var managedEntitlementQuerySchema = /* @__PURE__ */ (() =>
|
|
3283
|
-
q:
|
|
3284
|
-
status:
|
|
3313
|
+
import * as z31 from "zod";
|
|
3314
|
+
var managedEntitlementQuerySchema = /* @__PURE__ */ (() => z31.strictObject({
|
|
3315
|
+
q: z31.string().max(200).optional(),
|
|
3316
|
+
status: z31.string().min(1).max(50).optional(),
|
|
3285
3317
|
limit: pageLimit,
|
|
3286
3318
|
cursor: pageCursorSchema.optional()
|
|
3287
3319
|
}))();
|
|
3288
|
-
var managedEntitlementPageSchema = /* @__PURE__ */ (() =>
|
|
3289
|
-
items:
|
|
3290
|
-
people:
|
|
3291
|
-
total:
|
|
3292
|
-
nextCursor:
|
|
3320
|
+
var managedEntitlementPageSchema = /* @__PURE__ */ (() => z31.object({
|
|
3321
|
+
items: z31.array(entitlementSchema),
|
|
3322
|
+
people: z31.array(personSchema),
|
|
3323
|
+
total: z31.number().int().nonnegative(),
|
|
3324
|
+
nextCursor: z31.string().nullable()
|
|
3293
3325
|
}))();
|
|
3294
|
-
var managedEntitlementSchema = /* @__PURE__ */ (() =>
|
|
3326
|
+
var managedEntitlementSchema = /* @__PURE__ */ (() => z31.object({
|
|
3295
3327
|
entitlement: entitlementSchema,
|
|
3296
3328
|
person: personSchema
|
|
3297
3329
|
}))();
|
|
@@ -3383,11 +3415,11 @@ function collection({ post }) {
|
|
|
3383
3415
|
var collectionApi = (http) => collection(http);
|
|
3384
3416
|
|
|
3385
3417
|
// src/server/client/operations.ts
|
|
3386
|
-
import * as
|
|
3418
|
+
import * as z32 from "zod";
|
|
3387
3419
|
function operations({ get, post }) {
|
|
3388
3420
|
return {
|
|
3389
3421
|
/** Every paused or resumed operation: redemptions and each quest's participation; requires `read`. */
|
|
3390
|
-
list: (call) => get("/operations",
|
|
3422
|
+
list: (call) => get("/operations", z32.array(operationSchema), call),
|
|
3391
3423
|
/**
|
|
3392
3424
|
* Pauses or resumes redemptions or one quest's participation, against the `revision` the
|
|
3393
3425
|
* operator saw, with a reason; requires `publish` permission.
|
|
@@ -3423,7 +3455,7 @@ function redemptions(http) {
|
|
|
3423
3455
|
var redemptionsApi = (http) => redemptions(http);
|
|
3424
3456
|
|
|
3425
3457
|
// src/server/client/inventory.ts
|
|
3426
|
-
import * as
|
|
3458
|
+
import * as z33 from "zod";
|
|
3427
3459
|
function inventory({ create, get, post }) {
|
|
3428
3460
|
return {
|
|
3429
3461
|
/** Includes archived items and revision fences; requires read permission. */
|
|
@@ -3457,7 +3489,7 @@ function inventory({ create, get, post }) {
|
|
|
3457
3489
|
call
|
|
3458
3490
|
),
|
|
3459
3491
|
/** Every stock item with its counts and the offers that sell it; requires `read` permission. */
|
|
3460
|
-
list: (call) => get("/stock-items",
|
|
3492
|
+
list: (call) => get("/stock-items", z33.array(managedStockItemSchema), call),
|
|
3461
3493
|
createItem: (input, call) => create(
|
|
3462
3494
|
"/stock-items",
|
|
3463
3495
|
stockItemSchema,
|
|
@@ -3472,7 +3504,7 @@ function inventory({ create, get, post }) {
|
|
|
3472
3504
|
stockInputSchema.parse(withActionId(input)),
|
|
3473
3505
|
call
|
|
3474
3506
|
),
|
|
3475
|
-
catalog: (call) => get("/pickup-inventory",
|
|
3507
|
+
catalog: (call) => get("/pickup-inventory", z33.array(pickupCatalogSchema), call),
|
|
3476
3508
|
configure: (input, call) => post(
|
|
3477
3509
|
"/pickup-inventory",
|
|
3478
3510
|
pickupCatalogSchema,
|
|
@@ -3489,7 +3521,7 @@ function inventory({ create, get, post }) {
|
|
|
3489
3521
|
var inventoryApi = (http) => inventory(http);
|
|
3490
3522
|
|
|
3491
3523
|
// src/server/client/offers.ts
|
|
3492
|
-
import * as
|
|
3524
|
+
import * as z34 from "zod";
|
|
3493
3525
|
function offers({ get, post }) {
|
|
3494
3526
|
return {
|
|
3495
3527
|
/**
|
|
@@ -3527,7 +3559,7 @@ function offers({ get, post }) {
|
|
|
3527
3559
|
),
|
|
3528
3560
|
call
|
|
3529
3561
|
),
|
|
3530
|
-
list: (call) => get("/offers",
|
|
3562
|
+
list: (call) => get("/offers", z34.array(offerSchema), call),
|
|
3531
3563
|
/**
|
|
3532
3564
|
* Every redemption, or one member's, newest first, in one unbounded response.
|
|
3533
3565
|
*
|
|
@@ -3535,7 +3567,7 @@ function offers({ get, post }) {
|
|
|
3535
3567
|
*/
|
|
3536
3568
|
redemptions: (input = {}, call) => get(
|
|
3537
3569
|
`/redemptions${queryString({ member: input.member })}`,
|
|
3538
|
-
|
|
3570
|
+
z34.array(redemptionSchema),
|
|
3539
3571
|
call
|
|
3540
3572
|
),
|
|
3541
3573
|
/** Pauses or resumes an offer at the revision the operator saw. */
|
|
@@ -3560,16 +3592,16 @@ function offers({ get, post }) {
|
|
|
3560
3592
|
var offersApi = (http) => offers(http);
|
|
3561
3593
|
|
|
3562
3594
|
// src/server/client/tokens.ts
|
|
3563
|
-
import * as
|
|
3595
|
+
import * as z37 from "zod";
|
|
3564
3596
|
|
|
3565
3597
|
// src/server/api-keys.ts
|
|
3566
|
-
import * as
|
|
3598
|
+
import * as z36 from "zod";
|
|
3567
3599
|
|
|
3568
3600
|
// src/server/permissions.ts
|
|
3569
|
-
import * as
|
|
3570
|
-
var environmentSchema = /* @__PURE__ */ (() =>
|
|
3571
|
-
var roleSchema = /* @__PURE__ */ (() =>
|
|
3572
|
-
var permissionSchema = /* @__PURE__ */ (() =>
|
|
3601
|
+
import * as z35 from "zod";
|
|
3602
|
+
var environmentSchema = /* @__PURE__ */ (() => z35.enum(["test", "live"]))();
|
|
3603
|
+
var roleSchema = /* @__PURE__ */ (() => z35.enum(["editor", "reviewer", "staff"]))();
|
|
3604
|
+
var permissionSchema = /* @__PURE__ */ (() => z35.enum([
|
|
3573
3605
|
"read",
|
|
3574
3606
|
"publish",
|
|
3575
3607
|
"review",
|
|
@@ -3589,7 +3621,7 @@ var permissionSchema = /* @__PURE__ */ (() => z36.enum([
|
|
|
3589
3621
|
*/
|
|
3590
3622
|
"enroll"
|
|
3591
3623
|
]))();
|
|
3592
|
-
var permissionListSchema = /* @__PURE__ */ (() =>
|
|
3624
|
+
var permissionListSchema = /* @__PURE__ */ (() => z35.array(z35.string()).transform(
|
|
3593
3625
|
(values) => values.filter(
|
|
3594
3626
|
(value) => permissionSchema.safeParse(value).success
|
|
3595
3627
|
)
|
|
@@ -3599,8 +3631,8 @@ var rolePermissions = {
|
|
|
3599
3631
|
reviewer: ["read", "review"],
|
|
3600
3632
|
staff: ["read", "confirm", "handover"]
|
|
3601
3633
|
};
|
|
3602
|
-
var projectRoleSchema = /* @__PURE__ */ (() =>
|
|
3603
|
-
var projectPermissionSchema = /* @__PURE__ */ (() =>
|
|
3634
|
+
var projectRoleSchema = /* @__PURE__ */ (() => z35.enum([...roleSchema.options, "viewer"]))();
|
|
3635
|
+
var projectPermissionSchema = /* @__PURE__ */ (() => z35.enum([
|
|
3604
3636
|
...permissionSchema.options,
|
|
3605
3637
|
"dashboards"
|
|
3606
3638
|
]))();
|
|
@@ -3612,55 +3644,55 @@ var projectRolePermissions = {
|
|
|
3612
3644
|
};
|
|
3613
3645
|
|
|
3614
3646
|
// src/server/api-keys.ts
|
|
3615
|
-
var ingestTrackerScopeSchema = /* @__PURE__ */ (() =>
|
|
3616
|
-
var tokenScopeInputSchema = /* @__PURE__ */ (() =>
|
|
3617
|
-
var tokenInputSchema = /* @__PURE__ */ (() =>
|
|
3618
|
-
name:
|
|
3647
|
+
var ingestTrackerScopeSchema = /* @__PURE__ */ (() => z36.array(identifier).min(1).max(100).nullable())();
|
|
3648
|
+
var tokenScopeInputSchema = /* @__PURE__ */ (() => z36.object({ ingestTrackers: ingestTrackerScopeSchema }).strict())();
|
|
3649
|
+
var tokenInputSchema = /* @__PURE__ */ (() => z36.object({
|
|
3650
|
+
name: z36.string().trim().min(1).max(80),
|
|
3619
3651
|
project: identifier,
|
|
3620
3652
|
environment: environmentSchema,
|
|
3621
|
-
permissions:
|
|
3653
|
+
permissions: z36.array(permissionSchema).min(1),
|
|
3622
3654
|
ingestTrackers: ingestTrackerScopeSchema.optional(),
|
|
3623
|
-
days:
|
|
3655
|
+
days: z36.number().int().min(1).max(90).default(30)
|
|
3624
3656
|
}).strict())();
|
|
3625
|
-
var tokenSchema = /* @__PURE__ */ (() =>
|
|
3626
|
-
id:
|
|
3627
|
-
name:
|
|
3628
|
-
project:
|
|
3657
|
+
var tokenSchema = /* @__PURE__ */ (() => z36.object({
|
|
3658
|
+
id: z36.string(),
|
|
3659
|
+
name: z36.string(),
|
|
3660
|
+
project: z36.string(),
|
|
3629
3661
|
environment: environmentSchema,
|
|
3630
3662
|
permissions: permissionListSchema,
|
|
3631
3663
|
ingestTrackers: ingestTrackerScopeSchema.optional(),
|
|
3632
|
-
expiresAt:
|
|
3664
|
+
expiresAt: z36.number()
|
|
3633
3665
|
}))();
|
|
3634
|
-
var issuedTokenSchema = /* @__PURE__ */ (() => tokenSchema.extend({ token:
|
|
3635
|
-
var serviceKeyInputSchema = /* @__PURE__ */ (() =>
|
|
3636
|
-
name:
|
|
3637
|
-
permissions:
|
|
3666
|
+
var issuedTokenSchema = /* @__PURE__ */ (() => tokenSchema.extend({ token: z36.string() }))();
|
|
3667
|
+
var serviceKeyInputSchema = /* @__PURE__ */ (() => z36.object({
|
|
3668
|
+
name: z36.string().trim().min(1).max(80),
|
|
3669
|
+
permissions: z36.array(permissionSchema).min(1).refine(
|
|
3638
3670
|
(permissions) => !permissions.includes("access"),
|
|
3639
3671
|
"Service keys cannot hold the access permission"
|
|
3640
3672
|
),
|
|
3641
3673
|
/** Days until the first secret expires. Omit it for a key that never expires. */
|
|
3642
|
-
expiresInDays:
|
|
3674
|
+
expiresInDays: z36.number().int().min(1).max(3650).optional()
|
|
3643
3675
|
}).strict())();
|
|
3644
|
-
var serviceKeySchema = /* @__PURE__ */ (() =>
|
|
3645
|
-
id:
|
|
3646
|
-
organization:
|
|
3647
|
-
project:
|
|
3676
|
+
var serviceKeySchema = /* @__PURE__ */ (() => z36.object({
|
|
3677
|
+
id: z36.string().uuid(),
|
|
3678
|
+
organization: z36.string(),
|
|
3679
|
+
project: z36.string(),
|
|
3648
3680
|
environment: environmentSchema,
|
|
3649
|
-
name:
|
|
3681
|
+
name: z36.string(),
|
|
3650
3682
|
permissions: permissionListSchema,
|
|
3651
3683
|
/** The Clerk user ID of the administrator who created it. */
|
|
3652
|
-
createdBy:
|
|
3653
|
-
createdAt:
|
|
3684
|
+
createdBy: z36.string(),
|
|
3685
|
+
createdAt: z36.number(),
|
|
3654
3686
|
/** The latest use of any of its secrets, revoked ones included; null when none was used. */
|
|
3655
|
-
lastUsedAt:
|
|
3687
|
+
lastUsedAt: z36.number().nullable(),
|
|
3656
3688
|
/** Its working secrets, oldest first. Any of them authenticates the key. */
|
|
3657
|
-
secrets:
|
|
3689
|
+
secrets: z36.array(credentialSecretSchema)
|
|
3658
3690
|
}))();
|
|
3659
3691
|
var issuedServiceKeySchema = /* @__PURE__ */ (() => serviceKeySchema.extend({
|
|
3660
|
-
secret:
|
|
3661
|
-
token:
|
|
3692
|
+
secret: z36.string().uuid(),
|
|
3693
|
+
token: z36.string()
|
|
3662
3694
|
}))();
|
|
3663
|
-
var automationKeyPermissionSchema = /* @__PURE__ */ (() =>
|
|
3695
|
+
var automationKeyPermissionSchema = /* @__PURE__ */ (() => z36.enum([
|
|
3664
3696
|
"read",
|
|
3665
3697
|
"publish",
|
|
3666
3698
|
"inventory",
|
|
@@ -3668,47 +3700,47 @@ var automationKeyPermissionSchema = /* @__PURE__ */ (() => z37.enum([
|
|
|
3668
3700
|
"ingest",
|
|
3669
3701
|
"enroll"
|
|
3670
3702
|
]))();
|
|
3671
|
-
var automationKeyInputSchema = /* @__PURE__ */ (() =>
|
|
3672
|
-
name:
|
|
3673
|
-
permissions:
|
|
3703
|
+
var automationKeyInputSchema = /* @__PURE__ */ (() => z36.object({
|
|
3704
|
+
name: z36.string().trim().min(1).max(80),
|
|
3705
|
+
permissions: z36.array(automationKeyPermissionSchema).min(1),
|
|
3674
3706
|
/**
|
|
3675
3707
|
* The projects it reaches. Omit it for every project of the organization, current and future.
|
|
3676
3708
|
* An empty list, allowed only with `createProjects`, reaches only the projects it creates.
|
|
3677
3709
|
*/
|
|
3678
|
-
projects:
|
|
3710
|
+
projects: z36.array(identifier).max(100).optional(),
|
|
3679
3711
|
/** Whether it may create projects. A project it creates joins its `projects` list. */
|
|
3680
|
-
createProjects:
|
|
3712
|
+
createProjects: z36.boolean().default(false),
|
|
3681
3713
|
/** Days until the first secret expires. Omit it for a key that never expires. */
|
|
3682
|
-
expiresInDays:
|
|
3683
|
-
}).strict().refine((
|
|
3714
|
+
expiresInDays: z36.number().int().min(1).max(3650).optional()
|
|
3715
|
+
}).strict().refine((key2) => key2.projects?.length !== 0 || key2.createProjects, {
|
|
3684
3716
|
message: "Choose a project, or let the key create projects",
|
|
3685
3717
|
path: ["projects"]
|
|
3686
3718
|
}))();
|
|
3687
|
-
var automationKeySchema = /* @__PURE__ */ (() =>
|
|
3688
|
-
id:
|
|
3689
|
-
organization:
|
|
3690
|
-
name:
|
|
3719
|
+
var automationKeySchema = /* @__PURE__ */ (() => z36.object({
|
|
3720
|
+
id: z36.string().uuid(),
|
|
3721
|
+
organization: z36.string(),
|
|
3722
|
+
name: z36.string(),
|
|
3691
3723
|
permissions: permissionListSchema,
|
|
3692
3724
|
/** The projects it reaches; null for every project of the organization. */
|
|
3693
|
-
projects:
|
|
3694
|
-
createProjects:
|
|
3725
|
+
projects: z36.array(z36.string()).nullable(),
|
|
3726
|
+
createProjects: z36.boolean(),
|
|
3695
3727
|
/** The Clerk user ID of the administrator who created it. */
|
|
3696
|
-
createdBy:
|
|
3697
|
-
createdAt:
|
|
3728
|
+
createdBy: z36.string(),
|
|
3729
|
+
createdAt: z36.number(),
|
|
3698
3730
|
/** The latest use of any of its secrets, revoked ones included; null when none was used. */
|
|
3699
|
-
lastUsedAt:
|
|
3731
|
+
lastUsedAt: z36.number().nullable(),
|
|
3700
3732
|
/** Its working secrets, oldest first. Any of them authenticates the key. */
|
|
3701
|
-
secrets:
|
|
3733
|
+
secrets: z36.array(credentialSecretSchema)
|
|
3702
3734
|
}))();
|
|
3703
3735
|
var issuedAutomationKeySchema = /* @__PURE__ */ (() => automationKeySchema.extend({
|
|
3704
|
-
secret:
|
|
3705
|
-
token:
|
|
3736
|
+
secret: z36.string().uuid(),
|
|
3737
|
+
token: z36.string()
|
|
3706
3738
|
}))();
|
|
3707
3739
|
|
|
3708
3740
|
// src/server/client/tokens.ts
|
|
3709
3741
|
function tokens({ get, post, request }) {
|
|
3710
3742
|
return {
|
|
3711
|
-
list: (call) => get("/tokens",
|
|
3743
|
+
list: (call) => get("/tokens", z37.array(tokenSchema), call),
|
|
3712
3744
|
/**
|
|
3713
3745
|
* Issues a key for one project and environment, limited to permissions the caller holds
|
|
3714
3746
|
* there. It expires after `days`, 1 to 90 (default 30). The secret `token` is in this
|
|
@@ -3717,14 +3749,14 @@ function tokens({ get, post, request }) {
|
|
|
3717
3749
|
create: (input, call) => post("/tokens", issuedTokenSchema, tokenInputSchema.parse(input), call),
|
|
3718
3750
|
/** Replace a personal key's ingestion restriction without changing its secret. */
|
|
3719
3751
|
scope: (id, input, call) => request(
|
|
3720
|
-
`/tokens/${encodeURIComponent(
|
|
3752
|
+
`/tokens/${encodeURIComponent(z37.string().min(1).parse(id))}/scope`,
|
|
3721
3753
|
tokenSchema,
|
|
3722
3754
|
tokenScopeInputSchema.parse(input),
|
|
3723
3755
|
"PUT",
|
|
3724
3756
|
call
|
|
3725
3757
|
),
|
|
3726
3758
|
revoke: (id, call) => request(
|
|
3727
|
-
`/tokens/${encodeURIComponent(
|
|
3759
|
+
`/tokens/${encodeURIComponent(z37.string().min(1).parse(id))}`,
|
|
3728
3760
|
ok,
|
|
3729
3761
|
void 0,
|
|
3730
3762
|
"DELETE",
|
|
@@ -3735,10 +3767,10 @@ function tokens({ get, post, request }) {
|
|
|
3735
3767
|
var tokensApi = (http) => tokens(http);
|
|
3736
3768
|
|
|
3737
3769
|
// src/server/client/service-keys.ts
|
|
3738
|
-
import * as
|
|
3770
|
+
import * as z38 from "zod";
|
|
3739
3771
|
function serviceKeys({ get, post, request }) {
|
|
3740
3772
|
return {
|
|
3741
|
-
list: (call) => get("/service-keys",
|
|
3773
|
+
list: (call) => get("/service-keys", z38.array(serviceKeySchema), call),
|
|
3742
3774
|
/** The secret `token` is in this response only. */
|
|
3743
3775
|
create: (input, call) => post(
|
|
3744
3776
|
"/service-keys",
|
|
@@ -3751,14 +3783,14 @@ function serviceKeys({ get, post, request }) {
|
|
|
3751
3783
|
* them with `revokeSecret`. The new `token` is in this response only.
|
|
3752
3784
|
*/
|
|
3753
3785
|
addSecret: (id, input = {}, call) => post(
|
|
3754
|
-
`/service-keys/${
|
|
3786
|
+
`/service-keys/${z38.string().uuid().parse(id)}/secrets`,
|
|
3755
3787
|
issuedServiceKeySchema,
|
|
3756
3788
|
credentialSecretInputSchema.parse(input),
|
|
3757
3789
|
call
|
|
3758
3790
|
),
|
|
3759
3791
|
/** Stops one secret working. A key's last secret cannot be revoked; revoke the key instead. */
|
|
3760
3792
|
revokeSecret: (id, secret, call) => request(
|
|
3761
|
-
`/service-keys/${
|
|
3793
|
+
`/service-keys/${z38.string().uuid().parse(id)}/secrets/${z38.string().uuid().parse(secret)}`,
|
|
3762
3794
|
serviceKeySchema,
|
|
3763
3795
|
void 0,
|
|
3764
3796
|
"DELETE",
|
|
@@ -3766,8 +3798,8 @@ function serviceKeys({ get, post, request }) {
|
|
|
3766
3798
|
),
|
|
3767
3799
|
/** Deletes the key; every secret stops working. */
|
|
3768
3800
|
revoke: (id, call) => request(
|
|
3769
|
-
`/service-keys/${
|
|
3770
|
-
|
|
3801
|
+
`/service-keys/${z38.string().uuid().parse(id)}`,
|
|
3802
|
+
z38.null(),
|
|
3771
3803
|
void 0,
|
|
3772
3804
|
"DELETE",
|
|
3773
3805
|
call
|
|
@@ -3777,10 +3809,10 @@ function serviceKeys({ get, post, request }) {
|
|
|
3777
3809
|
var serviceKeysApi = (http) => serviceKeys(http);
|
|
3778
3810
|
|
|
3779
3811
|
// src/server/client/automation-keys.ts
|
|
3780
|
-
import * as
|
|
3812
|
+
import * as z39 from "zod";
|
|
3781
3813
|
function automationKeys({ get, post, request }) {
|
|
3782
3814
|
return {
|
|
3783
|
-
list: (call) => get("/automation-keys",
|
|
3815
|
+
list: (call) => get("/automation-keys", z39.array(automationKeySchema), call),
|
|
3784
3816
|
/** The secret `token` is in this response only. */
|
|
3785
3817
|
create: (input, call) => post(
|
|
3786
3818
|
"/automation-keys",
|
|
@@ -3793,14 +3825,14 @@ function automationKeys({ get, post, request }) {
|
|
|
3793
3825
|
* them with `revokeSecret`. The new `token` is in this response only.
|
|
3794
3826
|
*/
|
|
3795
3827
|
addSecret: (id, input = {}, call) => post(
|
|
3796
|
-
`/automation-keys/${
|
|
3828
|
+
`/automation-keys/${z39.string().uuid().parse(id)}/secrets`,
|
|
3797
3829
|
issuedAutomationKeySchema,
|
|
3798
3830
|
credentialSecretInputSchema.parse(input),
|
|
3799
3831
|
call
|
|
3800
3832
|
),
|
|
3801
3833
|
/** Stops one secret working. A key's last secret cannot be revoked; revoke the key instead. */
|
|
3802
3834
|
revokeSecret: (id, secret, call) => request(
|
|
3803
|
-
`/automation-keys/${
|
|
3835
|
+
`/automation-keys/${z39.string().uuid().parse(id)}/secrets/${z39.string().uuid().parse(secret)}`,
|
|
3804
3836
|
automationKeySchema,
|
|
3805
3837
|
void 0,
|
|
3806
3838
|
"DELETE",
|
|
@@ -3808,8 +3840,8 @@ function automationKeys({ get, post, request }) {
|
|
|
3808
3840
|
),
|
|
3809
3841
|
/** Deletes the key; every secret stops working. */
|
|
3810
3842
|
revoke: (id, call) => request(
|
|
3811
|
-
`/automation-keys/${
|
|
3812
|
-
|
|
3843
|
+
`/automation-keys/${z39.string().uuid().parse(id)}`,
|
|
3844
|
+
z39.null(),
|
|
3813
3845
|
void 0,
|
|
3814
3846
|
"DELETE",
|
|
3815
3847
|
call
|
|
@@ -3819,26 +3851,26 @@ function automationKeys({ get, post, request }) {
|
|
|
3819
3851
|
var automationKeysApi = (http) => automationKeys(http);
|
|
3820
3852
|
|
|
3821
3853
|
// src/server/client/grants.ts
|
|
3822
|
-
import * as
|
|
3854
|
+
import * as z41 from "zod";
|
|
3823
3855
|
|
|
3824
3856
|
// src/server/grants.ts
|
|
3825
|
-
import * as
|
|
3826
|
-
var grantSchema = /* @__PURE__ */ (() =>
|
|
3827
|
-
subject:
|
|
3828
|
-
roles:
|
|
3829
|
-
environments:
|
|
3857
|
+
import * as z40 from "zod";
|
|
3858
|
+
var grantSchema = /* @__PURE__ */ (() => z40.object({
|
|
3859
|
+
subject: z40.string().min(1).max(200),
|
|
3860
|
+
roles: z40.array(roleSchema),
|
|
3861
|
+
environments: z40.array(environmentSchema)
|
|
3830
3862
|
}).strict())();
|
|
3831
|
-
var projectGrantSchema = /* @__PURE__ */ (() =>
|
|
3863
|
+
var projectGrantSchema = /* @__PURE__ */ (() => z40.object({
|
|
3832
3864
|
subject: grantSchema.shape.subject,
|
|
3833
|
-
roles:
|
|
3865
|
+
roles: z40.array(projectRoleSchema),
|
|
3834
3866
|
environments: grantSchema.shape.environments,
|
|
3835
3867
|
/**
|
|
3836
3868
|
* When the grant stops giving access (epoch ms). Omit it, or send null, for a grant without
|
|
3837
3869
|
* an end. An ended grant stays listed, so the project's access shows who had it and until when.
|
|
3838
3870
|
*/
|
|
3839
|
-
expiresAt:
|
|
3871
|
+
expiresAt: z40.number().int().positive().nullable().optional()
|
|
3840
3872
|
}).strict())();
|
|
3841
|
-
var grantRecordSchema = /* @__PURE__ */ (() =>
|
|
3873
|
+
var grantRecordSchema = /* @__PURE__ */ (() => z40.object({
|
|
3842
3874
|
...grantSchema.shape,
|
|
3843
3875
|
/**
|
|
3844
3876
|
* Every role the grant gives, `viewer` included, which `roles` leaves out. Absent from Relay
|
|
@@ -3846,23 +3878,23 @@ var grantRecordSchema = /* @__PURE__ */ (() => z41.object({
|
|
|
3846
3878
|
*
|
|
3847
3879
|
* @experimental
|
|
3848
3880
|
*/
|
|
3849
|
-
projectRoles:
|
|
3881
|
+
projectRoles: z40.array(z40.string()).optional(),
|
|
3850
3882
|
/**
|
|
3851
3883
|
* When the grant stops giving access (epoch ms), or null for no end. A grant past it is still
|
|
3852
3884
|
* listed and gives no permission.
|
|
3853
3885
|
*
|
|
3854
3886
|
* @experimental
|
|
3855
3887
|
*/
|
|
3856
|
-
expiresAt:
|
|
3888
|
+
expiresAt: z40.number().nullable().optional()
|
|
3857
3889
|
}))();
|
|
3858
|
-
var teamSchema = /* @__PURE__ */ (() =>
|
|
3859
|
-
|
|
3890
|
+
var teamSchema = /* @__PURE__ */ (() => z40.array(
|
|
3891
|
+
z40.object({ id: z40.string(), label: z40.string() })
|
|
3860
3892
|
))();
|
|
3861
3893
|
|
|
3862
3894
|
// src/server/client/grants.ts
|
|
3863
3895
|
function grants({ get, request }) {
|
|
3864
3896
|
return {
|
|
3865
|
-
list: (call) => get("/grants",
|
|
3897
|
+
list: (call) => get("/grants", z41.array(grantRecordSchema), call),
|
|
3866
3898
|
/**
|
|
3867
3899
|
* Replaces one person's roles, environments and end date on the project. The audit log
|
|
3868
3900
|
* records it. `viewer` and `expiresAt` are experimental.
|
|
@@ -3887,14 +3919,14 @@ function team({ get }) {
|
|
|
3887
3919
|
var teamApi = (http) => team(http);
|
|
3888
3920
|
|
|
3889
3921
|
// src/server/client/webhooks.ts
|
|
3890
|
-
import * as
|
|
3922
|
+
import * as z42 from "zod";
|
|
3891
3923
|
function webhooks({ get, post, request }) {
|
|
3892
3924
|
function rotateWebhookSecret(id, inputOrCall, call) {
|
|
3893
3925
|
const isInput = call !== void 0 || inputOrCall !== void 0 && "actionId" in inputOrCall;
|
|
3894
3926
|
const input = isInput ? inputOrCall ?? {} : {};
|
|
3895
3927
|
const options = isInput ? call : inputOrCall;
|
|
3896
3928
|
return post(
|
|
3897
|
-
`/webhooks/${
|
|
3929
|
+
`/webhooks/${z42.string().uuid().parse(id)}/rotate-secret`,
|
|
3898
3930
|
webhookSecretSchema,
|
|
3899
3931
|
webhookRotateInputSchema.parse(withActionId(input)),
|
|
3900
3932
|
options
|
|
@@ -3902,7 +3934,7 @@ function webhooks({ get, post, request }) {
|
|
|
3902
3934
|
}
|
|
3903
3935
|
return {
|
|
3904
3936
|
state: (id, call) => get(
|
|
3905
|
-
`/webhooks/${
|
|
3937
|
+
`/webhooks/${z42.string().uuid().parse(id)}/state`,
|
|
3906
3938
|
webhookEndpointStateSchema,
|
|
3907
3939
|
call
|
|
3908
3940
|
),
|
|
@@ -3913,24 +3945,24 @@ function webhooks({ get, post, request }) {
|
|
|
3913
3945
|
call
|
|
3914
3946
|
),
|
|
3915
3947
|
delete: (id, input, call) => post(
|
|
3916
|
-
`/webhooks/${
|
|
3948
|
+
`/webhooks/${z42.string().uuid().parse(id)}/delete`,
|
|
3917
3949
|
webhookEndpointStateSchema,
|
|
3918
3950
|
webhookDeleteInputSchema.parse(withActionId(input)),
|
|
3919
3951
|
call
|
|
3920
3952
|
),
|
|
3921
3953
|
pause: (id, input = {}, call) => post(
|
|
3922
|
-
`/webhooks/${
|
|
3954
|
+
`/webhooks/${z42.string().uuid().parse(id)}/pause`,
|
|
3923
3955
|
webhookEndpointSchema,
|
|
3924
3956
|
webhookControlInputSchema.parse(withActionId(input)),
|
|
3925
3957
|
call
|
|
3926
3958
|
),
|
|
3927
3959
|
resume: (id, input = {}, call) => post(
|
|
3928
|
-
`/webhooks/${
|
|
3960
|
+
`/webhooks/${z42.string().uuid().parse(id)}/resume`,
|
|
3929
3961
|
webhookEndpointSchema,
|
|
3930
3962
|
webhookControlInputSchema.parse(withActionId(input)),
|
|
3931
3963
|
call
|
|
3932
3964
|
),
|
|
3933
|
-
list: (call) => get("/webhooks",
|
|
3965
|
+
list: (call) => get("/webhooks", z42.array(webhookEndpointSchema), call),
|
|
3934
3966
|
/** Pass an `actionId` to recover the endpoint and its secret after a lost answer. */
|
|
3935
3967
|
create: (input, call) => post(
|
|
3936
3968
|
"/webhooks",
|
|
@@ -3939,7 +3971,7 @@ function webhooks({ get, post, request }) {
|
|
|
3939
3971
|
call
|
|
3940
3972
|
),
|
|
3941
3973
|
update: (id, input, call) => request(
|
|
3942
|
-
`/webhooks/${
|
|
3974
|
+
`/webhooks/${z42.string().uuid().parse(id)}`,
|
|
3943
3975
|
webhookEndpointSchema,
|
|
3944
3976
|
webhookUpdateSchema.parse(input),
|
|
3945
3977
|
"PUT",
|
|
@@ -3947,14 +3979,14 @@ function webhooks({ get, post, request }) {
|
|
|
3947
3979
|
),
|
|
3948
3980
|
/** @deprecated Use pause. Removed in 2.0.0. */
|
|
3949
3981
|
disable: (id, call) => post(
|
|
3950
|
-
`/webhooks/${
|
|
3982
|
+
`/webhooks/${z42.string().uuid().parse(id)}/disable`,
|
|
3951
3983
|
webhookEndpointSchema,
|
|
3952
3984
|
{},
|
|
3953
3985
|
call
|
|
3954
3986
|
),
|
|
3955
3987
|
rotateSecret: rotateWebhookSecret,
|
|
3956
3988
|
deliveries: (id, query = {}, call) => get(
|
|
3957
|
-
`/webhooks/${
|
|
3989
|
+
`/webhooks/${z42.string().uuid().parse(id)}/deliveries${queryString(webhookQuerySchema.parse(query))}`,
|
|
3958
3990
|
webhookDeliveryPageSchema,
|
|
3959
3991
|
call
|
|
3960
3992
|
),
|
|
@@ -3964,7 +3996,7 @@ function webhooks({ get, post, request }) {
|
|
|
3964
3996
|
*/
|
|
3965
3997
|
replay: (id, delivery, ...rest) => actionCommand(
|
|
3966
3998
|
(webhook, input, call) => post(
|
|
3967
|
-
`/webhooks/${
|
|
3999
|
+
`/webhooks/${z42.string().uuid().parse(webhook)}/deliveries/${z42.string().uuid().parse(delivery)}/replay`,
|
|
3968
4000
|
webhookDeliverySchema,
|
|
3969
4001
|
webhookControlInputSchema.parse(input),
|
|
3970
4002
|
call
|
|
@@ -3975,7 +4007,7 @@ function webhooks({ get, post, request }) {
|
|
|
3975
4007
|
var webhooksApi = (http) => webhooks(http);
|
|
3976
4008
|
|
|
3977
4009
|
// src/server/client/identity-integrations.ts
|
|
3978
|
-
import * as
|
|
4010
|
+
import * as z43 from "zod";
|
|
3979
4011
|
function identityIntegrations({
|
|
3980
4012
|
exchange,
|
|
3981
4013
|
get,
|
|
@@ -3983,7 +4015,7 @@ function identityIntegrations({
|
|
|
3983
4015
|
request
|
|
3984
4016
|
}) {
|
|
3985
4017
|
return {
|
|
3986
|
-
list: (call) => get("/identity-integrations",
|
|
4018
|
+
list: (call) => get("/identity-integrations", z43.array(identityIntegrationSchema), call),
|
|
3987
4019
|
/** The secret `token` is in this response only. */
|
|
3988
4020
|
create: (input, call) => post(
|
|
3989
4021
|
"/identity-integrations",
|
|
@@ -4013,7 +4045,7 @@ function identityIntegrations({
|
|
|
4013
4045
|
* @deprecated Use `addSecret`, then `revokeSecret` the old secret once your app uses the new one.
|
|
4014
4046
|
*/
|
|
4015
4047
|
rotate: (id, call) => post(
|
|
4016
|
-
`/identity-integrations/${
|
|
4048
|
+
`/identity-integrations/${z43.string().uuid().parse(id)}/rotate`,
|
|
4017
4049
|
identityIntegrationSecretSchema,
|
|
4018
4050
|
{},
|
|
4019
4051
|
call
|
|
@@ -4023,7 +4055,7 @@ function identityIntegrations({
|
|
|
4023
4055
|
* revoke them with `revokeSecret`. The new `token` is in this response only.
|
|
4024
4056
|
*/
|
|
4025
4057
|
addSecret: (id, input = {}, call) => post(
|
|
4026
|
-
`/identity-integrations/${
|
|
4058
|
+
`/identity-integrations/${z43.string().uuid().parse(id)}/secrets`,
|
|
4027
4059
|
identityIntegrationSecretSchema,
|
|
4028
4060
|
credentialSecretInputSchema.parse(input),
|
|
4029
4061
|
call
|
|
@@ -4033,7 +4065,7 @@ function identityIntegrations({
|
|
|
4033
4065
|
* environment instead of answering it, as `createIntoAppSecret` does.
|
|
4034
4066
|
*/
|
|
4035
4067
|
addSecretIntoAppSecret: (id, appSecret, input = {}, call) => post(
|
|
4036
|
-
`/identity-integrations/${
|
|
4068
|
+
`/identity-integrations/${z43.string().uuid().parse(id)}/secrets`,
|
|
4037
4069
|
identityIntegrationAppSecretSchema,
|
|
4038
4070
|
{
|
|
4039
4071
|
...credentialSecretInputSchema.parse(input),
|
|
@@ -4046,7 +4078,7 @@ function identityIntegrations({
|
|
|
4046
4078
|
* revoked; disconnect the integration with `revoke` instead.
|
|
4047
4079
|
*/
|
|
4048
4080
|
revokeSecret: (id, secret, call) => request(
|
|
4049
|
-
`/identity-integrations/${
|
|
4081
|
+
`/identity-integrations/${z43.string().uuid().parse(id)}/secrets/${z43.string().uuid().parse(secret)}`,
|
|
4050
4082
|
identityIntegrationSchema,
|
|
4051
4083
|
void 0,
|
|
4052
4084
|
"DELETE",
|
|
@@ -4054,7 +4086,7 @@ function identityIntegrations({
|
|
|
4054
4086
|
),
|
|
4055
4087
|
/** Makes one secret never expire. */
|
|
4056
4088
|
removeSecretExpiry: (id, secret, call) => request(
|
|
4057
|
-
`/identity-integrations/${
|
|
4089
|
+
`/identity-integrations/${z43.string().uuid().parse(id)}/secrets/${z43.string().uuid().parse(secret)}/expiry`,
|
|
4058
4090
|
identityIntegrationSchema,
|
|
4059
4091
|
void 0,
|
|
4060
4092
|
"DELETE",
|
|
@@ -4067,7 +4099,7 @@ function identityIntegrations({
|
|
|
4067
4099
|
*/
|
|
4068
4100
|
kinds: (call) => get(
|
|
4069
4101
|
"/identity-integrations/kinds",
|
|
4070
|
-
|
|
4102
|
+
z43.array(identityKindClaimSchema),
|
|
4071
4103
|
call
|
|
4072
4104
|
),
|
|
4073
4105
|
/**
|
|
@@ -4079,7 +4111,7 @@ function identityIntegrations({
|
|
|
4079
4111
|
setAccountVouching: (id, input, call) => (
|
|
4080
4112
|
// The action ID's receipt makes a repeat apply once, so the client may resend it.
|
|
4081
4113
|
exchange(
|
|
4082
|
-
`/identity-integrations/${
|
|
4114
|
+
`/identity-integrations/${z43.string().uuid().parse(id)}/account-vouching`,
|
|
4083
4115
|
identityIntegrationSchema,
|
|
4084
4116
|
identityIntegrationAccountVouchingInputSchema.parse(
|
|
4085
4117
|
withActionId(input)
|
|
@@ -4094,8 +4126,8 @@ function identityIntegrations({
|
|
|
4094
4126
|
* and keep attributing tracker records; unlink them on the member to stop that.
|
|
4095
4127
|
*/
|
|
4096
4128
|
revoke: (id, call) => request(
|
|
4097
|
-
`/identity-integrations/${
|
|
4098
|
-
|
|
4129
|
+
`/identity-integrations/${z43.string().uuid().parse(id)}`,
|
|
4130
|
+
z43.null(),
|
|
4099
4131
|
void 0,
|
|
4100
4132
|
"DELETE",
|
|
4101
4133
|
call
|
|
@@ -4105,35 +4137,35 @@ function identityIntegrations({
|
|
|
4105
4137
|
var identityIntegrationsApi = (http) => identityIntegrations(http);
|
|
4106
4138
|
|
|
4107
4139
|
// src/server/audit.ts
|
|
4108
|
-
import * as
|
|
4109
|
-
var auditRecordSchema = /* @__PURE__ */ (() =>
|
|
4110
|
-
id:
|
|
4111
|
-
action:
|
|
4112
|
-
actor:
|
|
4140
|
+
import * as z44 from "zod";
|
|
4141
|
+
var auditRecordSchema = /* @__PURE__ */ (() => z44.object({
|
|
4142
|
+
id: z44.string(),
|
|
4143
|
+
action: z44.string(),
|
|
4144
|
+
actor: z44.string().nullable(),
|
|
4113
4145
|
user: operatorUserSchema.nullable().optional(),
|
|
4114
|
-
detail:
|
|
4115
|
-
at:
|
|
4116
|
-
attempt:
|
|
4117
|
-
}).refine((
|
|
4146
|
+
detail: z44.string(),
|
|
4147
|
+
at: z44.number(),
|
|
4148
|
+
attempt: z44.string().nullable()
|
|
4149
|
+
}).refine((record3) => !record3.user || record3.user.id === record3.actor, {
|
|
4118
4150
|
message: "User profile must match the recorded actor",
|
|
4119
4151
|
path: ["user"]
|
|
4120
4152
|
}))();
|
|
4121
|
-
var auditQuerySchema = /* @__PURE__ */ (() =>
|
|
4122
|
-
category:
|
|
4123
|
-
q:
|
|
4153
|
+
var auditQuerySchema = /* @__PURE__ */ (() => z44.strictObject({
|
|
4154
|
+
category: z44.enum(["reviews", "rewards", "configuration"]).optional(),
|
|
4155
|
+
q: z44.string().max(200).optional(),
|
|
4124
4156
|
limit: pageLimit,
|
|
4125
4157
|
cursor: pageCursorSchema.optional()
|
|
4126
4158
|
}))();
|
|
4127
4159
|
var auditListQuerySchema = /* @__PURE__ */ (() => auditQuerySchema.extend({
|
|
4128
|
-
category:
|
|
4160
|
+
category: z44.enum(["reviews", "rewards", "configuration", "test-members"]).optional()
|
|
4129
4161
|
}))();
|
|
4130
4162
|
var accessHistoryQuerySchema = /* @__PURE__ */ (() => auditQuerySchema.omit({
|
|
4131
4163
|
category: true
|
|
4132
4164
|
}))();
|
|
4133
|
-
var auditPageSchema = /* @__PURE__ */ (() =>
|
|
4134
|
-
items:
|
|
4135
|
-
total:
|
|
4136
|
-
nextCursor:
|
|
4165
|
+
var auditPageSchema = /* @__PURE__ */ (() => z44.object({
|
|
4166
|
+
items: z44.array(auditRecordSchema),
|
|
4167
|
+
total: z44.number().int().nonnegative(),
|
|
4168
|
+
nextCursor: z44.string().nullable()
|
|
4137
4169
|
}))();
|
|
4138
4170
|
|
|
4139
4171
|
// src/server/client/audit.ts
|
|
@@ -4230,7 +4262,7 @@ function discordRoles({ get, post }) {
|
|
|
4230
4262
|
var discordRolesApi = (http) => discordRoles(http);
|
|
4231
4263
|
|
|
4232
4264
|
// src/server/client/test-members.ts
|
|
4233
|
-
import * as
|
|
4265
|
+
import * as z45 from "zod";
|
|
4234
4266
|
function testMembers({ get, post }) {
|
|
4235
4267
|
return {
|
|
4236
4268
|
create: (input, call) => post(
|
|
@@ -4239,7 +4271,7 @@ function testMembers({ get, post }) {
|
|
|
4239
4271
|
testMemberCreateSchema.parse(withActionId(input)),
|
|
4240
4272
|
call
|
|
4241
4273
|
),
|
|
4242
|
-
list: (call) => get("/test-members",
|
|
4274
|
+
list: (call) => get("/test-members", z45.array(testMemberSchema), call),
|
|
4243
4275
|
history: (member, query = {}, call) => get(
|
|
4244
4276
|
`/test-members/${identifier.parse(member)}/history${queryString(testMemberHistoryQuerySchema.parse(query))}`,
|
|
4245
4277
|
testMemberHistorySchema,
|
|
@@ -4257,16 +4289,16 @@ function testMembers({ get, post }) {
|
|
|
4257
4289
|
* and file store one image, so pass `act`'s action ID to replay both. Reset deletes it.
|
|
4258
4290
|
*/
|
|
4259
4291
|
uploadEvidence: (member, file, input = {}, call) => {
|
|
4260
|
-
const { actionId:
|
|
4261
|
-
|
|
4292
|
+
const { actionId: actionId3 } = withActionId(
|
|
4293
|
+
z45.object({ actionId: identifier.optional() }).strict().parse(input)
|
|
4262
4294
|
);
|
|
4263
4295
|
return post(
|
|
4264
4296
|
`/test-members/${identifier.parse(member)}/evidence`,
|
|
4265
4297
|
evidenceSchema,
|
|
4266
4298
|
new ManagementUploadBody(
|
|
4267
4299
|
file,
|
|
4268
|
-
{ "X-Relay-Upload-ID":
|
|
4269
|
-
|
|
4300
|
+
{ "X-Relay-Upload-ID": actionId3 },
|
|
4301
|
+
actionId3
|
|
4270
4302
|
),
|
|
4271
4303
|
call
|
|
4272
4304
|
);
|
|
@@ -4517,79 +4549,79 @@ function memberImports({ get, post }) {
|
|
|
4517
4549
|
var memberImportsApi = (http) => memberImports(http);
|
|
4518
4550
|
|
|
4519
4551
|
// src/server/client/members.ts
|
|
4520
|
-
import * as
|
|
4552
|
+
import * as z50 from "zod";
|
|
4521
4553
|
|
|
4522
4554
|
// src/server/members.ts
|
|
4523
|
-
import * as
|
|
4555
|
+
import * as z48 from "zod";
|
|
4524
4556
|
|
|
4525
4557
|
// src/server/member-bans.ts
|
|
4526
|
-
import * as
|
|
4527
|
-
var memberBanRollbackSchema = /* @__PURE__ */ (() =>
|
|
4528
|
-
completions:
|
|
4529
|
-
referralPayouts:
|
|
4530
|
-
pointAwards:
|
|
4558
|
+
import * as z46 from "zod";
|
|
4559
|
+
var memberBanRollbackSchema = /* @__PURE__ */ (() => z46.object({
|
|
4560
|
+
completions: z46.boolean().default(false),
|
|
4561
|
+
referralPayouts: z46.boolean().default(false),
|
|
4562
|
+
pointAwards: z46.boolean().default(false)
|
|
4531
4563
|
}).strict())();
|
|
4532
|
-
var banReason = /* @__PURE__ */ (() =>
|
|
4533
|
-
var memberBanInputSchema = /* @__PURE__ */ (() =>
|
|
4564
|
+
var banReason = /* @__PURE__ */ (() => z46.string().trim().min(1).max(500))();
|
|
4565
|
+
var memberBanInputSchema = /* @__PURE__ */ (() => z46.object({
|
|
4534
4566
|
actionId: identifier,
|
|
4535
4567
|
reason: banReason,
|
|
4536
4568
|
rollback: memberBanRollbackSchema.optional()
|
|
4537
4569
|
}).strict())();
|
|
4538
|
-
var memberBanPreviewInputSchema = /* @__PURE__ */ (() =>
|
|
4539
|
-
var memberUnbanInputSchema = /* @__PURE__ */ (() =>
|
|
4570
|
+
var memberBanPreviewInputSchema = /* @__PURE__ */ (() => z46.object({ rollback: memberBanRollbackSchema.optional() }).strict())();
|
|
4571
|
+
var memberUnbanInputSchema = /* @__PURE__ */ (() => z46.object({
|
|
4540
4572
|
actionId: identifier,
|
|
4541
4573
|
reason: banReason,
|
|
4542
|
-
restoreCompletions:
|
|
4574
|
+
restoreCompletions: z46.boolean().default(false)
|
|
4543
4575
|
}).strict())();
|
|
4544
|
-
var points2 = /* @__PURE__ */ (() =>
|
|
4545
|
-
var memberBanOutcomeSchema = /* @__PURE__ */ (() =>
|
|
4576
|
+
var points2 = /* @__PURE__ */ (() => z46.number().int().nonnegative())();
|
|
4577
|
+
var memberBanOutcomeSchema = /* @__PURE__ */ (() => z46.object({
|
|
4546
4578
|
attemptsRejected: points2,
|
|
4547
4579
|
completionsRevoked: points2,
|
|
4548
4580
|
completionsRestored: points2,
|
|
4549
|
-
completionsKept:
|
|
4550
|
-
|
|
4581
|
+
completionsKept: z46.array(
|
|
4582
|
+
z46.object({ completion: identifier, code: z46.string() })
|
|
4551
4583
|
),
|
|
4552
4584
|
entriesReversed: points2,
|
|
4553
4585
|
referralAccounts: points2,
|
|
4554
|
-
points:
|
|
4555
|
-
|
|
4586
|
+
points: z46.array(
|
|
4587
|
+
z46.object({ ledger: identifier, reversed: points2, unreversed: points2 })
|
|
4556
4588
|
),
|
|
4557
|
-
referralDebt:
|
|
4589
|
+
referralDebt: z46.array(z46.object({ ledger: identifier, amount: points2 }))
|
|
4558
4590
|
}))();
|
|
4559
|
-
var runStatusSchema = /* @__PURE__ */ (() =>
|
|
4560
|
-
var runSchema = /* @__PURE__ */ (() =>
|
|
4591
|
+
var runStatusSchema = /* @__PURE__ */ (() => z46.string())();
|
|
4592
|
+
var runSchema = /* @__PURE__ */ (() => z46.object({
|
|
4561
4593
|
status: runStatusSchema,
|
|
4562
|
-
finishedAt:
|
|
4594
|
+
finishedAt: z46.number().int().nullable(),
|
|
4563
4595
|
outcome: memberBanOutcomeSchema.nullable()
|
|
4564
4596
|
}))();
|
|
4565
|
-
var memberBanSchema = /* @__PURE__ */ (() =>
|
|
4597
|
+
var memberBanSchema = /* @__PURE__ */ (() => z46.object({
|
|
4566
4598
|
id: identifier,
|
|
4567
4599
|
member: identifier,
|
|
4568
|
-
reason:
|
|
4569
|
-
bannedAt:
|
|
4570
|
-
bannedBy:
|
|
4600
|
+
reason: z46.string(),
|
|
4601
|
+
bannedAt: z46.number().int(),
|
|
4602
|
+
bannedBy: z46.string().nullable(),
|
|
4571
4603
|
rollback: runSchema.extend({
|
|
4572
|
-
completions:
|
|
4573
|
-
referralPayouts:
|
|
4574
|
-
pointAwards:
|
|
4604
|
+
completions: z46.boolean(),
|
|
4605
|
+
referralPayouts: z46.boolean(),
|
|
4606
|
+
pointAwards: z46.boolean()
|
|
4575
4607
|
}),
|
|
4576
|
-
unban:
|
|
4577
|
-
reason:
|
|
4578
|
-
unbannedAt:
|
|
4579
|
-
by:
|
|
4580
|
-
restoreCompletions:
|
|
4608
|
+
unban: z46.object({
|
|
4609
|
+
reason: z46.string(),
|
|
4610
|
+
unbannedAt: z46.number().int(),
|
|
4611
|
+
by: z46.string().nullable(),
|
|
4612
|
+
restoreCompletions: z46.boolean(),
|
|
4581
4613
|
restore: runSchema.nullable()
|
|
4582
4614
|
}).nullable()
|
|
4583
4615
|
}))();
|
|
4584
|
-
var memberBanPreviewSchema = /* @__PURE__ */ (() =>
|
|
4616
|
+
var memberBanPreviewSchema = /* @__PURE__ */ (() => z46.object({
|
|
4585
4617
|
member: identifier,
|
|
4586
|
-
banned:
|
|
4618
|
+
banned: z46.boolean(),
|
|
4587
4619
|
attempts: points2,
|
|
4588
4620
|
completions: points2,
|
|
4589
4621
|
entries: points2,
|
|
4590
4622
|
referralAccounts: points2,
|
|
4591
|
-
points:
|
|
4592
|
-
|
|
4623
|
+
points: z46.array(
|
|
4624
|
+
z46.object({
|
|
4593
4625
|
ledger: identifier,
|
|
4594
4626
|
completions: points2,
|
|
4595
4627
|
pointAwards: points2,
|
|
@@ -4600,11 +4632,11 @@ var memberBanPreviewSchema = /* @__PURE__ */ (() => z47.object({
|
|
|
4600
4632
|
referralDebt: points2
|
|
4601
4633
|
})
|
|
4602
4634
|
),
|
|
4603
|
-
inviters:
|
|
4604
|
-
|
|
4635
|
+
inviters: z46.array(
|
|
4636
|
+
z46.object({
|
|
4605
4637
|
member: identifier,
|
|
4606
|
-
ledgers:
|
|
4607
|
-
|
|
4638
|
+
ledgers: z46.array(
|
|
4639
|
+
z46.object({
|
|
4608
4640
|
ledger: identifier,
|
|
4609
4641
|
bonus: points2,
|
|
4610
4642
|
reversed: points2,
|
|
@@ -4616,23 +4648,31 @@ var memberBanPreviewSchema = /* @__PURE__ */ (() => z47.object({
|
|
|
4616
4648
|
}))();
|
|
4617
4649
|
|
|
4618
4650
|
// src/server/wallets.ts
|
|
4619
|
-
import * as
|
|
4651
|
+
import * as z47 from "zod";
|
|
4620
4652
|
var managedWalletSchema = /* @__PURE__ */ (() => linkedWalletSchema.extend({
|
|
4621
4653
|
/**
|
|
4622
4654
|
* True when the organization vouched for the wallet (a member import, or an app login's server at
|
|
4623
4655
|
* sign-in), and the member has not proved it since. Absent from Relay versions without imports.
|
|
4624
4656
|
*/
|
|
4625
|
-
imported:
|
|
4657
|
+
imported: z47.boolean().optional(),
|
|
4626
4658
|
/**
|
|
4627
4659
|
* The app login that vouched for the wallet at sign-in, while `imported` is true and no member
|
|
4628
4660
|
* import attached it. Absent from Relay versions without it.
|
|
4629
4661
|
*/
|
|
4630
4662
|
vouchedBy: accountVouchedBySchema.optional(),
|
|
4631
4663
|
...identitySourceFields,
|
|
4632
|
-
|
|
4633
|
-
|
|
4664
|
+
/**
|
|
4665
|
+
* A linked Solana wallet's primary `.sol` name (SNS), such as `"toly.sol"`, while the wallet owns the
|
|
4666
|
+
* domain, as Relay last read it from mainnet. For display only: `address` stays the wallet's
|
|
4667
|
+
* identity. Absent when it has none or Relay has not read it yet.
|
|
4668
|
+
*
|
|
4669
|
+
* @experimental A minor release can change `.sol` names.
|
|
4670
|
+
*/
|
|
4671
|
+
name: z47.string().optional(),
|
|
4672
|
+
status: z47.enum(["linked", "unlinked"]),
|
|
4673
|
+
unlinkedAt: z47.number().int().nullable(),
|
|
4634
4674
|
/** "member", or the operator or key that unlinked it. */
|
|
4635
|
-
unlinkedBy:
|
|
4675
|
+
unlinkedBy: z47.string().nullable()
|
|
4636
4676
|
}))();
|
|
4637
4677
|
var balanceCheckSchema = /* @__PURE__ */ (() => walletBalanceSchema.pick({
|
|
4638
4678
|
chain: true,
|
|
@@ -4642,66 +4682,66 @@ var balanceCheckSchema = /* @__PURE__ */ (() => walletBalanceSchema.pick({
|
|
|
4642
4682
|
wallets: true,
|
|
4643
4683
|
observedAt: true
|
|
4644
4684
|
}).extend({ attempt: identifier }))();
|
|
4645
|
-
var walletBalanceChainsSchema = /* @__PURE__ */ (() =>
|
|
4646
|
-
chains:
|
|
4647
|
-
|
|
4648
|
-
chain:
|
|
4649
|
-
|
|
4650
|
-
|
|
4685
|
+
var walletBalanceChainsSchema = /* @__PURE__ */ (() => z47.object({
|
|
4686
|
+
chains: z47.array(
|
|
4687
|
+
z47.object({
|
|
4688
|
+
chain: z47.union([
|
|
4689
|
+
z47.literal(solanaMainnet),
|
|
4690
|
+
z47.literal(solanaDevnet),
|
|
4651
4691
|
cosmosNetworkSchema,
|
|
4652
4692
|
evmChainIdSchema
|
|
4653
4693
|
]),
|
|
4654
|
-
name:
|
|
4655
|
-
testnet:
|
|
4694
|
+
name: z47.string(),
|
|
4695
|
+
testnet: z47.boolean()
|
|
4656
4696
|
})
|
|
4657
4697
|
)
|
|
4658
4698
|
}))();
|
|
4659
|
-
var memberWalletUnlinkInputSchema = /* @__PURE__ */ (() => walletUnlinkInputSchema.extend({ reason:
|
|
4699
|
+
var memberWalletUnlinkInputSchema = /* @__PURE__ */ (() => walletUnlinkInputSchema.extend({ reason: z47.string().trim().min(1).max(500) }).strict())();
|
|
4660
4700
|
var memberWalletSignInInputSchema = /* @__PURE__ */ (() => walletUnlinkInputSchema.extend({
|
|
4661
|
-
enabled:
|
|
4662
|
-
reason:
|
|
4701
|
+
enabled: z47.boolean(),
|
|
4702
|
+
reason: z47.string().trim().min(1).max(500)
|
|
4663
4703
|
}).strict())();
|
|
4664
4704
|
|
|
4665
4705
|
// src/server/members.ts
|
|
4666
|
-
var memberSchema = /* @__PURE__ */ (() =>
|
|
4667
|
-
id:
|
|
4668
|
-
test:
|
|
4669
|
-
name:
|
|
4670
|
-
accounts:
|
|
4706
|
+
var memberSchema = /* @__PURE__ */ (() => z48.object({
|
|
4707
|
+
id: z48.string(),
|
|
4708
|
+
test: z48.boolean().optional(),
|
|
4709
|
+
name: z48.string().nullable().optional(),
|
|
4710
|
+
accounts: z48.array(memberAccountSchema).default([]),
|
|
4671
4711
|
/** The member's linked app identities, by kind. Absent from Relay versions without it. */
|
|
4672
|
-
appIdentities:
|
|
4673
|
-
attempts:
|
|
4674
|
-
completions:
|
|
4675
|
-
rewards:
|
|
4676
|
-
lastActivity:
|
|
4712
|
+
appIdentities: z48.array(memberAppIdentitySchema).optional(),
|
|
4713
|
+
attempts: z48.number(),
|
|
4714
|
+
completions: z48.number(),
|
|
4715
|
+
rewards: z48.number(),
|
|
4716
|
+
lastActivity: z48.number().nullable(),
|
|
4677
4717
|
/**
|
|
4678
4718
|
* When the customer erased the member (`members.erase`), in Unix milliseconds: it keeps its ID
|
|
4679
4719
|
* and accounting, with no profile, accounts or identities. Absent on a member that was not erased.
|
|
4680
4720
|
*/
|
|
4681
|
-
erasedAt:
|
|
4721
|
+
erasedAt: z48.number().optional(),
|
|
4682
4722
|
/**
|
|
4683
4723
|
* When an operator banned the member (`members.ban`), in Unix milliseconds. Absent on a member
|
|
4684
4724
|
* who is not banned now.
|
|
4685
4725
|
*
|
|
4686
4726
|
* @experimental A minor release can change member bans.
|
|
4687
4727
|
*/
|
|
4688
|
-
bannedAt:
|
|
4728
|
+
bannedAt: z48.number().optional()
|
|
4689
4729
|
}))();
|
|
4690
|
-
var managedOAuthAccountBaseSchema = /* @__PURE__ */ (() =>
|
|
4691
|
-
provider:
|
|
4692
|
-
revision:
|
|
4730
|
+
var managedOAuthAccountBaseSchema = /* @__PURE__ */ (() => z48.object({
|
|
4731
|
+
provider: z48.enum(["x", "discord"]),
|
|
4732
|
+
revision: z48.number().int().nonnegative()
|
|
4693
4733
|
}))();
|
|
4694
|
-
var managedOAuthAccountSchema = /* @__PURE__ */ (() =>
|
|
4734
|
+
var managedOAuthAccountSchema = /* @__PURE__ */ (() => z48.discriminatedUnion("status", [
|
|
4695
4735
|
managedOAuthAccountBaseSchema.extend({
|
|
4696
|
-
status:
|
|
4697
|
-
subject:
|
|
4698
|
-
linkedAt:
|
|
4736
|
+
status: z48.literal("connected"),
|
|
4737
|
+
subject: z48.string().min(1),
|
|
4738
|
+
linkedAt: z48.number(),
|
|
4699
4739
|
/**
|
|
4700
4740
|
* True when the organization vouched for the account, not the member's proof: a member import
|
|
4701
4741
|
* attached it, or an app login's server did at sign-in (`vouchedBy`). Absent from Relay
|
|
4702
4742
|
* versions without imports.
|
|
4703
4743
|
*/
|
|
4704
|
-
imported:
|
|
4744
|
+
imported: z48.boolean().optional(),
|
|
4705
4745
|
/**
|
|
4706
4746
|
* The app login that vouched for the account at sign-in, for an account with `imported` set
|
|
4707
4747
|
* that no member import attached. Absent from Relay versions without it.
|
|
@@ -4711,26 +4751,26 @@ var managedOAuthAccountSchema = /* @__PURE__ */ (() => z49.discriminatedUnion("s
|
|
|
4711
4751
|
* True for a real account an operator linked to a test member without OAuth
|
|
4712
4752
|
* (`testMembers.linkAccount`). Absent from Relay versions without it.
|
|
4713
4753
|
*/
|
|
4714
|
-
testLinked:
|
|
4754
|
+
testLinked: z48.boolean().optional(),
|
|
4715
4755
|
...identitySourceFields
|
|
4716
4756
|
}),
|
|
4717
|
-
managedOAuthAccountBaseSchema.extend({ status:
|
|
4757
|
+
managedOAuthAccountBaseSchema.extend({ status: z48.literal("disconnected") })
|
|
4718
4758
|
]))();
|
|
4719
4759
|
var managedTelegramAccountBaseSchema = /* @__PURE__ */ (() => managedOAuthAccountBaseSchema.extend({
|
|
4720
|
-
provider:
|
|
4760
|
+
provider: z48.literal("telegram")
|
|
4721
4761
|
}))();
|
|
4722
|
-
var managedTelegramAccountSchema = /* @__PURE__ */ (() =>
|
|
4762
|
+
var managedTelegramAccountSchema = /* @__PURE__ */ (() => z48.discriminatedUnion("status", [
|
|
4723
4763
|
managedTelegramAccountBaseSchema.extend({
|
|
4724
|
-
status:
|
|
4764
|
+
status: z48.literal("connected"),
|
|
4725
4765
|
/** The numeric Telegram user ID. */
|
|
4726
|
-
subject:
|
|
4727
|
-
linkedAt:
|
|
4766
|
+
subject: z48.string().min(1),
|
|
4767
|
+
linkedAt: z48.number(),
|
|
4728
4768
|
/**
|
|
4729
4769
|
* True when the organization vouched for the account, not the member's proof: a member import
|
|
4730
4770
|
* attached it, or an app login's server did at sign-in (`vouchedBy`). Absent from Relay
|
|
4731
4771
|
* versions without it.
|
|
4732
4772
|
*/
|
|
4733
|
-
imported:
|
|
4773
|
+
imported: z48.boolean().optional(),
|
|
4734
4774
|
/**
|
|
4735
4775
|
* The app login that vouched for the account at sign-in, for an account with `imported` set
|
|
4736
4776
|
* that no member import attached. Absent from Relay versions without it.
|
|
@@ -4739,14 +4779,14 @@ var managedTelegramAccountSchema = /* @__PURE__ */ (() => z49.discriminatedUnion
|
|
|
4739
4779
|
...identitySourceFields
|
|
4740
4780
|
}),
|
|
4741
4781
|
managedTelegramAccountBaseSchema.extend({
|
|
4742
|
-
status:
|
|
4782
|
+
status: z48.literal("disconnected")
|
|
4743
4783
|
})
|
|
4744
4784
|
]))();
|
|
4745
|
-
var memberOAuthUnlinkInputSchema = /* @__PURE__ */ (() =>
|
|
4746
|
-
provider:
|
|
4747
|
-
subject:
|
|
4748
|
-
revision:
|
|
4749
|
-
reason:
|
|
4785
|
+
var memberOAuthUnlinkInputSchema = /* @__PURE__ */ (() => z48.object({
|
|
4786
|
+
provider: z48.enum(["x", "discord"]),
|
|
4787
|
+
subject: z48.string().min(1).max(4096),
|
|
4788
|
+
revision: z48.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER - 1),
|
|
4789
|
+
reason: z48.string().trim().min(1).max(500)
|
|
4750
4790
|
}).strict())();
|
|
4751
4791
|
var memberTelegramUnlinkInputSchema = /* @__PURE__ */ (() => memberOAuthUnlinkInputSchema.omit({ provider: true }).strict())();
|
|
4752
4792
|
var managedMemberIdentitySchema = /* @__PURE__ */ (() => memberIdentitySchema.extend({
|
|
@@ -4755,7 +4795,7 @@ var managedMemberIdentitySchema = /* @__PURE__ */ (() => memberIdentitySchema.ex
|
|
|
4755
4795
|
* login's server at sign-in), until the member links that provider's account, or signs in with
|
|
4756
4796
|
* the X account, through Domino. Absent from Relay versions without imports.
|
|
4757
4797
|
*/
|
|
4758
|
-
imported:
|
|
4798
|
+
imported: z48.boolean().optional(),
|
|
4759
4799
|
/**
|
|
4760
4800
|
* The app login that vouched for the account at sign-in, for an `imported` account no member
|
|
4761
4801
|
* import attached. Absent from Relay versions without it.
|
|
@@ -4765,40 +4805,40 @@ var managedMemberIdentitySchema = /* @__PURE__ */ (() => memberIdentitySchema.ex
|
|
|
4765
4805
|
* True for a real X or Discord account an operator linked to a test member without OAuth
|
|
4766
4806
|
* (`testMembers.linkAccount`). Absent from Relay versions without it.
|
|
4767
4807
|
*/
|
|
4768
|
-
testLinked:
|
|
4808
|
+
testLinked: z48.boolean().optional(),
|
|
4769
4809
|
...identitySourceFields,
|
|
4770
|
-
status:
|
|
4771
|
-
unlinkedAt:
|
|
4810
|
+
status: z48.enum(["linked", "unlinked"]),
|
|
4811
|
+
unlinkedAt: z48.number().int().nullable(),
|
|
4772
4812
|
/** The operator or key that unlinked it. */
|
|
4773
|
-
unlinkedBy:
|
|
4813
|
+
unlinkedBy: z48.string().nullable()
|
|
4774
4814
|
}))();
|
|
4775
|
-
var memberIdentityChangeInputSchema = /* @__PURE__ */ (() =>
|
|
4815
|
+
var memberIdentityChangeInputSchema = /* @__PURE__ */ (() => z48.object({
|
|
4776
4816
|
kind: appIdentityKindSchema,
|
|
4777
|
-
subject:
|
|
4778
|
-
reason:
|
|
4817
|
+
subject: z48.string().min(1).max(256),
|
|
4818
|
+
reason: z48.string().trim().min(1).max(500)
|
|
4779
4819
|
}).strict())();
|
|
4780
|
-
var memberDetailSchema = /* @__PURE__ */ (() =>
|
|
4820
|
+
var memberDetailSchema = /* @__PURE__ */ (() => z48.object({
|
|
4781
4821
|
snapshot: snapshotSchema,
|
|
4782
4822
|
member: memberSchema,
|
|
4783
4823
|
progress: memberProgressSchema,
|
|
4784
4824
|
/** Up to 25 revoked completions with an unreversed point remainder, newest first. */
|
|
4785
|
-
revocationShortfalls:
|
|
4825
|
+
revocationShortfalls: z48.array(completionRevocationShortfallSchema).default([]),
|
|
4786
4826
|
/** Up to 25 revoked completions, newest first. Relay older than restore leaves it out. */
|
|
4787
|
-
revokedCompletions:
|
|
4827
|
+
revokedCompletions: z48.array(revokedCompletionSchema).optional(),
|
|
4788
4828
|
/** Current and historical campaign enrollment state, including inactive enrollments. */
|
|
4789
|
-
campaignEnrollments:
|
|
4790
|
-
passes:
|
|
4791
|
-
|
|
4792
|
-
provider:
|
|
4793
|
-
event:
|
|
4794
|
-
subject:
|
|
4829
|
+
campaignEnrollments: z48.array(campaignEnrollmentSchema).default([]),
|
|
4830
|
+
passes: z48.array(
|
|
4831
|
+
z48.object({
|
|
4832
|
+
provider: z48.string(),
|
|
4833
|
+
event: z48.string(),
|
|
4834
|
+
subject: z48.string(),
|
|
4795
4835
|
attempt: identifier.nullable()
|
|
4796
4836
|
})
|
|
4797
4837
|
).default([]),
|
|
4798
4838
|
/** Linked and unlinked wallets. */
|
|
4799
|
-
wallets:
|
|
4839
|
+
wallets: z48.array(managedWalletSchema),
|
|
4800
4840
|
/** The member's 10 most recent recorded balance reads, newest first. */
|
|
4801
|
-
balanceChecks:
|
|
4841
|
+
balanceChecks: z48.array(balanceCheckSchema),
|
|
4802
4842
|
/** The member's participant profile in this project. */
|
|
4803
4843
|
profile: managedProfileSchema.nullable(),
|
|
4804
4844
|
/**
|
|
@@ -4806,20 +4846,20 @@ var memberDetailSchema = /* @__PURE__ */ (() => z49.object({
|
|
|
4806
4846
|
* member ID: their selected X and Discord accounts and their `app:<name>` identities in this
|
|
4807
4847
|
* project, including app identities an operator unlinked, by kind.
|
|
4808
4848
|
*/
|
|
4809
|
-
identities:
|
|
4849
|
+
identities: z48.array(managedMemberIdentitySchema),
|
|
4810
4850
|
/**
|
|
4811
4851
|
* The creator accounts the member linked (a YouTube channel), whose content managed tracker
|
|
4812
4852
|
* sources attribute to them. Absent from Relay versions without creator accounts.
|
|
4813
4853
|
*/
|
|
4814
|
-
creatorAccounts:
|
|
4854
|
+
creatorAccounts: z48.array(managedCreatorAccountSchema).optional(),
|
|
4815
4855
|
/**
|
|
4816
4856
|
* Who invited the member, when they accepted, and the member import that recorded it, or null
|
|
4817
4857
|
* when nobody invited them. Absent from Relay versions before imported referrals.
|
|
4818
4858
|
*/
|
|
4819
|
-
referral:
|
|
4859
|
+
referral: z48.object({
|
|
4820
4860
|
inviter: identifier,
|
|
4821
|
-
acceptedAt:
|
|
4822
|
-
suspended:
|
|
4861
|
+
acceptedAt: z48.number().int().nonnegative(),
|
|
4862
|
+
suspended: z48.boolean(),
|
|
4823
4863
|
import: identifier.nullable()
|
|
4824
4864
|
}).nullable().optional(),
|
|
4825
4865
|
/**
|
|
@@ -4830,9 +4870,9 @@ var memberDetailSchema = /* @__PURE__ */ (() => z49.object({
|
|
|
4830
4870
|
*/
|
|
4831
4871
|
ban: memberBanSchema.nullable().optional()
|
|
4832
4872
|
}))();
|
|
4833
|
-
var managedMemberProgressSchema = /* @__PURE__ */ (() =>
|
|
4873
|
+
var managedMemberProgressSchema = /* @__PURE__ */ (() => z48.object({
|
|
4834
4874
|
member: identifier,
|
|
4835
|
-
quests:
|
|
4875
|
+
quests: z48.array(
|
|
4836
4876
|
memberProgressSchema.shape.quests.element.extend({
|
|
4837
4877
|
/** The streak as `members.get` reports it, without the list of qualifying days. */
|
|
4838
4878
|
streak: streakProgressSchema.omit({ days: true }).nullable().optional()
|
|
@@ -4843,10 +4883,10 @@ var managedMemberProgressSchema = /* @__PURE__ */ (() => z49.object({
|
|
|
4843
4883
|
/** Each point balance the member has, by balance ID. */
|
|
4844
4884
|
balances: snapshotSchema.shape.balances
|
|
4845
4885
|
}))();
|
|
4846
|
-
var memberLookupSchema = /* @__PURE__ */ (() =>
|
|
4847
|
-
|
|
4848
|
-
provider:
|
|
4849
|
-
subject:
|
|
4886
|
+
var memberLookupSchema = /* @__PURE__ */ (() => z48.union([
|
|
4887
|
+
z48.object({
|
|
4888
|
+
provider: z48.string().min(1).max(200),
|
|
4889
|
+
subject: z48.string().min(1).max(2048)
|
|
4850
4890
|
}).strict(),
|
|
4851
4891
|
identityReferenceSchema.transform(
|
|
4852
4892
|
(reference) => reference.kind === "wallet" ? { provider: reference.chain, subject: reference.address } : { provider: reference.kind, subject: reference.subject }
|
|
@@ -4857,50 +4897,50 @@ var memberLookupSchema = /* @__PURE__ */ (() => z49.union([
|
|
|
4857
4897
|
subject: address
|
|
4858
4898
|
}))
|
|
4859
4899
|
]))();
|
|
4860
|
-
var booleanQuery = /* @__PURE__ */ (() =>
|
|
4861
|
-
|
|
4862
|
-
|
|
4900
|
+
var booleanQuery = /* @__PURE__ */ (() => z48.union([
|
|
4901
|
+
z48.boolean(),
|
|
4902
|
+
z48.enum(["true", "false"]).transform((v) => v === "true")
|
|
4863
4903
|
]))();
|
|
4864
|
-
var managedMemberQuerySchema = /* @__PURE__ */ (() =>
|
|
4865
|
-
q:
|
|
4904
|
+
var managedMemberQuerySchema = /* @__PURE__ */ (() => z48.strictObject({
|
|
4905
|
+
q: z48.string().max(200).optional(),
|
|
4866
4906
|
needsReview: booleanQuery.optional(),
|
|
4867
|
-
limit:
|
|
4907
|
+
limit: z48.coerce.number().int().min(1).max(100).optional(),
|
|
4868
4908
|
cursor: pageCursorSchema.optional()
|
|
4869
4909
|
}))();
|
|
4870
|
-
var managedMemberPageSchema = /* @__PURE__ */ (() =>
|
|
4871
|
-
items:
|
|
4872
|
-
total:
|
|
4873
|
-
nextCursor:
|
|
4910
|
+
var managedMemberPageSchema = /* @__PURE__ */ (() => z48.object({
|
|
4911
|
+
items: z48.array(memberSchema),
|
|
4912
|
+
total: z48.number().int().nonnegative(),
|
|
4913
|
+
nextCursor: z48.string().nullable()
|
|
4874
4914
|
}))();
|
|
4875
4915
|
|
|
4876
4916
|
// src/server/member-erasure.ts
|
|
4877
|
-
import * as
|
|
4917
|
+
import * as z49 from "zod";
|
|
4878
4918
|
var memberErasureInputSchema = evidenceRedactionInputSchema;
|
|
4879
|
-
var memberErasureDeletedSchema = /* @__PURE__ */ (() =>
|
|
4919
|
+
var memberErasureDeletedSchema = /* @__PURE__ */ (() => z49.object({
|
|
4880
4920
|
/** The profile: display name and avatar. 0 or 1. */
|
|
4881
|
-
profiles:
|
|
4921
|
+
profiles: z49.number().int().nonnegative(),
|
|
4882
4922
|
/** Sign-in identities. */
|
|
4883
|
-
identities:
|
|
4923
|
+
identities: z49.number().int().nonnegative(),
|
|
4884
4924
|
/** Linked X, Discord, Telegram, Google, Apple and email accounts. */
|
|
4885
|
-
accounts:
|
|
4925
|
+
accounts: z49.number().int().nonnegative(),
|
|
4886
4926
|
/** `app:<name>` identities your app's integration or an import gave. */
|
|
4887
|
-
appIdentities:
|
|
4927
|
+
appIdentities: z49.number().int().nonnegative(),
|
|
4888
4928
|
/** Linked wallet addresses. */
|
|
4889
|
-
wallets:
|
|
4929
|
+
wallets: z49.number().int().nonnegative(),
|
|
4890
4930
|
/** Signed-in sessions, ended at once. */
|
|
4891
|
-
sessions:
|
|
4931
|
+
sessions: z49.number().int().nonnegative(),
|
|
4892
4932
|
/** Marketing consent records. */
|
|
4893
|
-
consents:
|
|
4933
|
+
consents: z49.number().int().nonnegative(),
|
|
4894
4934
|
/** Leaderboard aliases. */
|
|
4895
|
-
aliases:
|
|
4935
|
+
aliases: z49.number().int().nonnegative(),
|
|
4896
4936
|
/** Attempts whose submitted evidence (photo, text, URL or answers) was deleted. */
|
|
4897
|
-
evidence:
|
|
4937
|
+
evidence: z49.number().int().nonnegative(),
|
|
4898
4938
|
/** Tracker records the member's accounts authored, whose stored content was forgotten. */
|
|
4899
|
-
records:
|
|
4939
|
+
records: z49.number().int().nonnegative()
|
|
4900
4940
|
}))();
|
|
4901
|
-
var memberErasureResultSchema = /* @__PURE__ */ (() =>
|
|
4941
|
+
var memberErasureResultSchema = /* @__PURE__ */ (() => z49.object({
|
|
4902
4942
|
member: identifier,
|
|
4903
|
-
erasedAt:
|
|
4943
|
+
erasedAt: z49.number().int(),
|
|
4904
4944
|
deleted: memberErasureDeletedSchema
|
|
4905
4945
|
}))();
|
|
4906
4946
|
|
|
@@ -5123,7 +5163,7 @@ function members({ get, post }) {
|
|
|
5123
5163
|
/** Who each member is: up to 100 distinct IDs; unknown IDs come back without accounts. */
|
|
5124
5164
|
people: (members2, call) => get(
|
|
5125
5165
|
`/people${queryString({ ids: members2.join(",") })}`,
|
|
5126
|
-
|
|
5166
|
+
z50.array(personSchema),
|
|
5127
5167
|
call
|
|
5128
5168
|
),
|
|
5129
5169
|
/**
|
|
@@ -5133,7 +5173,7 @@ function members({ get, post }) {
|
|
|
5133
5173
|
*/
|
|
5134
5174
|
oauthAccounts: (member, call) => get(
|
|
5135
5175
|
`/members/${encodeURIComponent(member)}/oauth-accounts`,
|
|
5136
|
-
|
|
5176
|
+
z50.array(managedOAuthAccountSchema),
|
|
5137
5177
|
call
|
|
5138
5178
|
),
|
|
5139
5179
|
/**
|
|
@@ -5145,7 +5185,7 @@ function members({ get, post }) {
|
|
|
5145
5185
|
*/
|
|
5146
5186
|
unlinkOAuthAccount: (member, input, call) => post(
|
|
5147
5187
|
`/members/${encodeURIComponent(member)}/oauth-accounts/unlink`,
|
|
5148
|
-
|
|
5188
|
+
z50.array(managedOAuthAccountSchema),
|
|
5149
5189
|
expectedRevision(memberOAuthUnlinkInputSchema).parse(input),
|
|
5150
5190
|
call
|
|
5151
5191
|
),
|
|
@@ -5228,7 +5268,7 @@ function members({ get, post }) {
|
|
|
5228
5268
|
*/
|
|
5229
5269
|
unlinkWallet: (member, input, call) => post(
|
|
5230
5270
|
`/members/${encodeURIComponent(member)}/wallets/unlink`,
|
|
5231
|
-
|
|
5271
|
+
z50.array(managedWalletSchema),
|
|
5232
5272
|
memberWalletUnlinkInputSchema.parse(input),
|
|
5233
5273
|
call
|
|
5234
5274
|
),
|
|
@@ -5241,7 +5281,7 @@ function members({ get, post }) {
|
|
|
5241
5281
|
*/
|
|
5242
5282
|
unlinkIdentity: (member, input, call) => post(
|
|
5243
5283
|
`/members/${encodeURIComponent(member)}/identities/unlink`,
|
|
5244
|
-
|
|
5284
|
+
z50.array(managedMemberIdentitySchema),
|
|
5245
5285
|
memberIdentityChangeInputSchema.parse(input),
|
|
5246
5286
|
call
|
|
5247
5287
|
),
|
|
@@ -5252,7 +5292,7 @@ function members({ get, post }) {
|
|
|
5252
5292
|
*/
|
|
5253
5293
|
relinkIdentity: (member, input, call) => post(
|
|
5254
5294
|
`/members/${encodeURIComponent(member)}/identities/relink`,
|
|
5255
|
-
|
|
5295
|
+
z50.array(managedMemberIdentitySchema),
|
|
5256
5296
|
memberIdentityChangeInputSchema.parse(input),
|
|
5257
5297
|
call
|
|
5258
5298
|
),
|
|
@@ -5264,7 +5304,7 @@ function members({ get, post }) {
|
|
|
5264
5304
|
*/
|
|
5265
5305
|
setWalletSignIn: (member, input, call) => post(
|
|
5266
5306
|
`/members/${encodeURIComponent(member)}/wallets/sign-in`,
|
|
5267
|
-
|
|
5307
|
+
z50.array(managedWalletSchema),
|
|
5268
5308
|
memberWalletSignInInputSchema.parse(input),
|
|
5269
5309
|
call
|
|
5270
5310
|
)
|
|
@@ -5314,77 +5354,77 @@ function domains({ get, post, raw }) {
|
|
|
5314
5354
|
var domainsApi = (http) => domains(http);
|
|
5315
5355
|
|
|
5316
5356
|
// src/server/connections.ts
|
|
5317
|
-
import { z as
|
|
5318
|
-
var connectionPluginSchema = /* @__PURE__ */ (() =>
|
|
5357
|
+
import { z as z51 } from "zod";
|
|
5358
|
+
var connectionPluginSchema = /* @__PURE__ */ (() => z51.string().max(40).regex(/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/, "Use a kebab-case plugin ID"))();
|
|
5319
5359
|
var knownConnectionStatuses = [
|
|
5320
5360
|
"disconnected",
|
|
5321
5361
|
"ready",
|
|
5322
5362
|
"attention"
|
|
5323
5363
|
];
|
|
5324
|
-
var connectionStatusSchema = /* @__PURE__ */ (() =>
|
|
5364
|
+
var connectionStatusSchema = /* @__PURE__ */ (() => z51.string().min(1))();
|
|
5325
5365
|
var knownConnectionReconnectReasons = ["revoked", "expired"];
|
|
5326
|
-
var reconnectReasonSchema = /* @__PURE__ */ (() =>
|
|
5327
|
-
var connectionSecretFieldSchema = /* @__PURE__ */ (() =>
|
|
5328
|
-
name:
|
|
5329
|
-
label:
|
|
5330
|
-
help:
|
|
5331
|
-
set:
|
|
5332
|
-
}))();
|
|
5333
|
-
var connectionSchema = /* @__PURE__ */ (() =>
|
|
5334
|
-
plugin:
|
|
5335
|
-
name:
|
|
5336
|
-
environment:
|
|
5366
|
+
var reconnectReasonSchema = /* @__PURE__ */ (() => z51.string().min(1))();
|
|
5367
|
+
var connectionSecretFieldSchema = /* @__PURE__ */ (() => z51.object({
|
|
5368
|
+
name: z51.string(),
|
|
5369
|
+
label: z51.string(),
|
|
5370
|
+
help: z51.string().nullable(),
|
|
5371
|
+
set: z51.boolean()
|
|
5372
|
+
}))();
|
|
5373
|
+
var connectionSchema = /* @__PURE__ */ (() => z51.object({
|
|
5374
|
+
plugin: z51.string(),
|
|
5375
|
+
name: z51.string(),
|
|
5376
|
+
environment: z51.enum(["test", "live"]),
|
|
5337
5377
|
status: connectionStatusSchema,
|
|
5338
|
-
issue:
|
|
5339
|
-
config:
|
|
5340
|
-
configSchema:
|
|
5341
|
-
secrets:
|
|
5342
|
-
revision:
|
|
5343
|
-
connectedAt:
|
|
5344
|
-
connectedBy:
|
|
5345
|
-
updatedAt:
|
|
5378
|
+
issue: z51.string().nullable(),
|
|
5379
|
+
config: z51.record(z51.string(), z51.unknown()).nullable(),
|
|
5380
|
+
configSchema: z51.record(z51.string(), z51.unknown()),
|
|
5381
|
+
secrets: z51.array(connectionSecretFieldSchema),
|
|
5382
|
+
revision: z51.number().int().nonnegative(),
|
|
5383
|
+
connectedAt: z51.number().nullable(),
|
|
5384
|
+
connectedBy: z51.string().nullable(),
|
|
5385
|
+
updatedAt: z51.number().nullable(),
|
|
5346
5386
|
// A Relay from before OAuth connections answers none.
|
|
5347
5387
|
reconnectReason: reconnectReasonSchema.nullable().default(null),
|
|
5348
5388
|
// A Relay from before dry runs answers none.
|
|
5349
|
-
dryRun:
|
|
5389
|
+
dryRun: z51.boolean().default(false)
|
|
5350
5390
|
}))();
|
|
5351
|
-
var connectionPageSchema = /* @__PURE__ */ (() =>
|
|
5352
|
-
items:
|
|
5353
|
-
nextCursor:
|
|
5391
|
+
var connectionPageSchema = /* @__PURE__ */ (() => z51.object({
|
|
5392
|
+
items: z51.array(connectionSchema),
|
|
5393
|
+
nextCursor: z51.string().nullable()
|
|
5354
5394
|
}))();
|
|
5355
|
-
var
|
|
5356
|
-
var config = /* @__PURE__ */ (() =>
|
|
5357
|
-
var secrets = /* @__PURE__ */ (() =>
|
|
5358
|
-
var connectionConnectInputSchema = /* @__PURE__ */ (() =>
|
|
5395
|
+
var actionId2 = /* @__PURE__ */ (() => z51.string().uuid().default(() => crypto.randomUUID()))();
|
|
5396
|
+
var config = /* @__PURE__ */ (() => z51.record(z51.string(), z51.unknown()))();
|
|
5397
|
+
var secrets = /* @__PURE__ */ (() => z51.record(z51.string().max(64), z51.string().min(1).max(8192)))();
|
|
5398
|
+
var connectionConnectInputSchema = /* @__PURE__ */ (() => z51.strictObject({
|
|
5359
5399
|
config,
|
|
5360
5400
|
secrets: secrets.default({}),
|
|
5361
|
-
dryRun:
|
|
5362
|
-
actionId
|
|
5401
|
+
dryRun: z51.boolean().optional(),
|
|
5402
|
+
actionId: actionId2
|
|
5363
5403
|
}))();
|
|
5364
|
-
var connectionAuthorizeInputSchema = /* @__PURE__ */ (() =>
|
|
5404
|
+
var connectionAuthorizeInputSchema = /* @__PURE__ */ (() => z51.strictObject({
|
|
5365
5405
|
config: config.default({}),
|
|
5366
|
-
returnTo:
|
|
5367
|
-
actionId
|
|
5406
|
+
returnTo: z51.string().url().max(2048).optional(),
|
|
5407
|
+
actionId: actionId2
|
|
5368
5408
|
}))();
|
|
5369
|
-
var connectionAuthorizationSchema = /* @__PURE__ */ (() =>
|
|
5370
|
-
authorizationUrl:
|
|
5371
|
-
expiresAt:
|
|
5409
|
+
var connectionAuthorizationSchema = /* @__PURE__ */ (() => z51.object({
|
|
5410
|
+
authorizationUrl: z51.string().url(),
|
|
5411
|
+
expiresAt: z51.number()
|
|
5372
5412
|
}))();
|
|
5373
|
-
var connectionAuthorizationCompleteInputSchema = /* @__PURE__ */ (() =>
|
|
5374
|
-
code:
|
|
5413
|
+
var connectionAuthorizationCompleteInputSchema = /* @__PURE__ */ (() => z51.strictObject({
|
|
5414
|
+
code: z51.string().min(1).max(200)
|
|
5375
5415
|
}))();
|
|
5376
|
-
var connectionUpdateInputSchema = /* @__PURE__ */ (() =>
|
|
5416
|
+
var connectionUpdateInputSchema = /* @__PURE__ */ (() => z51.strictObject({
|
|
5377
5417
|
config: config.optional(),
|
|
5378
5418
|
secrets: secrets.optional(),
|
|
5379
|
-
expectedRevision:
|
|
5380
|
-
actionId
|
|
5419
|
+
expectedRevision: z51.number().int().nonnegative().optional(),
|
|
5420
|
+
actionId: actionId2
|
|
5381
5421
|
}).refine(
|
|
5382
5422
|
(input) => input.config !== void 0 || Object.keys(input.secrets ?? {}).length,
|
|
5383
5423
|
{ message: "Change the config, a secret, or both" }
|
|
5384
5424
|
))();
|
|
5385
|
-
var connectionDisconnectInputSchema = /* @__PURE__ */ (() =>
|
|
5386
|
-
expectedRevision:
|
|
5387
|
-
actionId
|
|
5425
|
+
var connectionDisconnectInputSchema = /* @__PURE__ */ (() => z51.strictObject({
|
|
5426
|
+
expectedRevision: z51.number().int().nonnegative().optional(),
|
|
5427
|
+
actionId: actionId2
|
|
5388
5428
|
}))();
|
|
5389
5429
|
var knownPluginSlots = [
|
|
5390
5430
|
"connection",
|
|
@@ -5394,29 +5434,29 @@ var knownPluginSlots = [
|
|
|
5394
5434
|
"evaluator-capability",
|
|
5395
5435
|
"identity"
|
|
5396
5436
|
];
|
|
5397
|
-
var pluginSlotSchema = /* @__PURE__ */ (() =>
|
|
5398
|
-
var pluginSchema = /* @__PURE__ */ (() =>
|
|
5399
|
-
id:
|
|
5400
|
-
name:
|
|
5401
|
-
slots:
|
|
5402
|
-
configSchema:
|
|
5403
|
-
secrets:
|
|
5404
|
-
|
|
5405
|
-
name:
|
|
5406
|
-
label:
|
|
5407
|
-
help:
|
|
5437
|
+
var pluginSlotSchema = /* @__PURE__ */ (() => z51.string().min(1))();
|
|
5438
|
+
var pluginSchema = /* @__PURE__ */ (() => z51.object({
|
|
5439
|
+
id: z51.string(),
|
|
5440
|
+
name: z51.string(),
|
|
5441
|
+
slots: z51.array(pluginSlotSchema),
|
|
5442
|
+
configSchema: z51.record(z51.string(), z51.unknown()),
|
|
5443
|
+
secrets: z51.array(
|
|
5444
|
+
z51.object({
|
|
5445
|
+
name: z51.string(),
|
|
5446
|
+
label: z51.string(),
|
|
5447
|
+
help: z51.string().nullable()
|
|
5408
5448
|
})
|
|
5409
5449
|
),
|
|
5410
|
-
events:
|
|
5450
|
+
events: z51.array(z51.string()),
|
|
5411
5451
|
// A Relay from before OAuth connections answers none.
|
|
5412
|
-
oauth:
|
|
5413
|
-
console:
|
|
5452
|
+
oauth: z51.object({ configured: z51.boolean(), scopes: z51.array(z51.string()) }).nullable().default(null),
|
|
5453
|
+
console: z51.object({ component: z51.string() }).nullable().default(null),
|
|
5414
5454
|
// A Relay from before dry runs answers none.
|
|
5415
|
-
dryRun:
|
|
5455
|
+
dryRun: z51.boolean().default(false)
|
|
5416
5456
|
}))();
|
|
5417
|
-
var pluginPageSchema = /* @__PURE__ */ (() =>
|
|
5418
|
-
items:
|
|
5419
|
-
nextCursor:
|
|
5457
|
+
var pluginPageSchema = /* @__PURE__ */ (() => z51.object({
|
|
5458
|
+
items: z51.array(pluginSchema),
|
|
5459
|
+
nextCursor: z51.string().nullable()
|
|
5420
5460
|
}))();
|
|
5421
5461
|
var knownConnectionSyncKinds = ["connect", "resync"];
|
|
5422
5462
|
var knownConnectionSyncStatuses = [
|
|
@@ -5424,53 +5464,53 @@ var knownConnectionSyncStatuses = [
|
|
|
5424
5464
|
"finished",
|
|
5425
5465
|
"failed"
|
|
5426
5466
|
];
|
|
5427
|
-
var connectionSyncSchema = /* @__PURE__ */ (() =>
|
|
5428
|
-
kind:
|
|
5429
|
-
status:
|
|
5430
|
-
done:
|
|
5431
|
-
total:
|
|
5432
|
-
startedAt:
|
|
5433
|
-
finishedAt:
|
|
5434
|
-
}))();
|
|
5435
|
-
var connectionActivitySchema = /* @__PURE__ */ (() =>
|
|
5436
|
-
plugin:
|
|
5437
|
-
environment:
|
|
5467
|
+
var connectionSyncSchema = /* @__PURE__ */ (() => z51.object({
|
|
5468
|
+
kind: z51.string().min(1),
|
|
5469
|
+
status: z51.string().min(1),
|
|
5470
|
+
done: z51.number().int().nonnegative(),
|
|
5471
|
+
total: z51.number().int().nonnegative().nullable(),
|
|
5472
|
+
startedAt: z51.number(),
|
|
5473
|
+
finishedAt: z51.number().nullable()
|
|
5474
|
+
}))();
|
|
5475
|
+
var connectionActivitySchema = /* @__PURE__ */ (() => z51.object({
|
|
5476
|
+
plugin: z51.string(),
|
|
5477
|
+
environment: z51.enum(["test", "live"]),
|
|
5438
5478
|
status: connectionStatusSchema,
|
|
5439
|
-
dryRun:
|
|
5440
|
-
lastSyncAt:
|
|
5441
|
-
failingSince:
|
|
5442
|
-
consecutiveFailures:
|
|
5443
|
-
members:
|
|
5444
|
-
synced:
|
|
5445
|
-
skipped:
|
|
5446
|
-
|
|
5447
|
-
reason:
|
|
5448
|
-
members:
|
|
5479
|
+
dryRun: z51.boolean(),
|
|
5480
|
+
lastSyncAt: z51.number().nullable(),
|
|
5481
|
+
failingSince: z51.number().nullable(),
|
|
5482
|
+
consecutiveFailures: z51.number().int().nonnegative(),
|
|
5483
|
+
members: z51.object({
|
|
5484
|
+
synced: z51.number().int().nonnegative(),
|
|
5485
|
+
skipped: z51.array(
|
|
5486
|
+
z51.object({
|
|
5487
|
+
reason: z51.string(),
|
|
5488
|
+
members: z51.number().int().nonnegative()
|
|
5449
5489
|
})
|
|
5450
5490
|
)
|
|
5451
5491
|
}),
|
|
5452
5492
|
sync: connectionSyncSchema.nullable(),
|
|
5453
|
-
errors:
|
|
5454
|
-
|
|
5493
|
+
errors: z51.array(
|
|
5494
|
+
z51.object({ at: z51.number(), kind: z51.string(), message: z51.string() })
|
|
5455
5495
|
)
|
|
5456
5496
|
}))();
|
|
5457
|
-
var connectionDryRunRequestSchema = /* @__PURE__ */ (() =>
|
|
5458
|
-
id:
|
|
5459
|
-
at:
|
|
5460
|
-
member:
|
|
5461
|
-
method:
|
|
5462
|
-
path:
|
|
5463
|
-
body:
|
|
5497
|
+
var connectionDryRunRequestSchema = /* @__PURE__ */ (() => z51.object({
|
|
5498
|
+
id: z51.string(),
|
|
5499
|
+
at: z51.number(),
|
|
5500
|
+
member: z51.string().nullable(),
|
|
5501
|
+
method: z51.string(),
|
|
5502
|
+
path: z51.string(),
|
|
5503
|
+
body: z51.unknown()
|
|
5464
5504
|
}))();
|
|
5465
|
-
var connectionDryRunPageSchema = /* @__PURE__ */ (() =>
|
|
5466
|
-
items:
|
|
5467
|
-
nextCursor:
|
|
5505
|
+
var connectionDryRunPageSchema = /* @__PURE__ */ (() => z51.object({
|
|
5506
|
+
items: z51.array(connectionDryRunRequestSchema),
|
|
5507
|
+
nextCursor: z51.string().nullable()
|
|
5468
5508
|
}))();
|
|
5469
|
-
var connectionDryRunQuerySchema = /* @__PURE__ */ (() =>
|
|
5470
|
-
cursor:
|
|
5471
|
-
limit:
|
|
5509
|
+
var connectionDryRunQuerySchema = /* @__PURE__ */ (() => z51.strictObject({
|
|
5510
|
+
cursor: z51.string().min(1).max(40).optional(),
|
|
5511
|
+
limit: z51.number().int().min(1).max(100).optional()
|
|
5472
5512
|
}))();
|
|
5473
|
-
var connectionResyncInputSchema = /* @__PURE__ */ (() =>
|
|
5513
|
+
var connectionResyncInputSchema = /* @__PURE__ */ (() => z51.strictObject({ actionId: actionId2 }))();
|
|
5474
5514
|
|
|
5475
5515
|
// src/server/client/connections.ts
|
|
5476
5516
|
function connectionPath(plugin) {
|
|
@@ -5652,7 +5692,7 @@ function schedules({ request, get, post }) {
|
|
|
5652
5692
|
var schedulesApi = (http) => schedules(http);
|
|
5653
5693
|
|
|
5654
5694
|
// src/server/client/storage.ts
|
|
5655
|
-
import * as
|
|
5695
|
+
import * as z52 from "zod";
|
|
5656
5696
|
function storage({ get, post, raw }) {
|
|
5657
5697
|
function clear(kind, name, input, call) {
|
|
5658
5698
|
const path = `/storage/${kind}/${appSecretNameSchema.parse(name)}/clear`;
|
|
@@ -5696,7 +5736,7 @@ function storage({ get, post, raw }) {
|
|
|
5696
5736
|
`/storage/sql/${appSecretNameSchema.parse(name)}/cell?${new URLSearchParams(
|
|
5697
5737
|
{
|
|
5698
5738
|
table,
|
|
5699
|
-
row: String(
|
|
5739
|
+
row: String(z52.number().int().min(0).parse(options.row)),
|
|
5700
5740
|
column: options.column,
|
|
5701
5741
|
...options.cursor === void 0 ? {} : { cursor: pageCursorSchema.parse(options.cursor) }
|
|
5702
5742
|
}
|
|
@@ -5715,8 +5755,8 @@ function storage({ get, post, raw }) {
|
|
|
5715
5755
|
call
|
|
5716
5756
|
),
|
|
5717
5757
|
/** A KV value's size and, when it is UTF-8 text, a preview. */
|
|
5718
|
-
value: (name,
|
|
5719
|
-
`/storage/kv/${appSecretNameSchema.parse(name)}/value?${new URLSearchParams({ key })}`,
|
|
5758
|
+
value: (name, key2, call) => get(
|
|
5759
|
+
`/storage/kv/${appSecretNameSchema.parse(name)}/value?${new URLSearchParams({ key: key2 })}`,
|
|
5720
5760
|
appStorageValueSchema,
|
|
5721
5761
|
call
|
|
5722
5762
|
),
|
|
@@ -5811,26 +5851,64 @@ var campaignsApi = (http) => campaigns(http);
|
|
|
5811
5851
|
import * as z55 from "zod";
|
|
5812
5852
|
|
|
5813
5853
|
// src/server/quests.ts
|
|
5814
|
-
import * as
|
|
5815
|
-
var questLifecycleInputSchema = /* @__PURE__ */ (() =>
|
|
5854
|
+
import * as z53 from "zod";
|
|
5855
|
+
var questLifecycleInputSchema = /* @__PURE__ */ (() => z53.object({
|
|
5816
5856
|
quest: identifier,
|
|
5817
5857
|
expectedRelease: identifier.optional(),
|
|
5818
|
-
archived:
|
|
5819
|
-
reason:
|
|
5858
|
+
archived: z53.boolean(),
|
|
5859
|
+
reason: z53.string().trim().min(1).max(500),
|
|
5820
5860
|
actionId: identifier
|
|
5821
5861
|
}).strict())();
|
|
5822
|
-
var questLifecycleSchema = /* @__PURE__ */ (() =>
|
|
5862
|
+
var questLifecycleSchema = /* @__PURE__ */ (() => z53.object({
|
|
5823
5863
|
quest: identifier,
|
|
5824
5864
|
key: identifier.nullable(),
|
|
5825
|
-
title:
|
|
5865
|
+
title: z53.string(),
|
|
5826
5866
|
release: identifier,
|
|
5827
|
-
lifecycle:
|
|
5867
|
+
lifecycle: z53.enum(["active", "paused", "archived"]),
|
|
5868
|
+
changed: z53.boolean()
|
|
5869
|
+
}))();
|
|
5870
|
+
|
|
5871
|
+
// src/server/quest-stations.ts
|
|
5872
|
+
import * as z54 from "zod";
|
|
5873
|
+
var stationOperationTarget = (quest, station) => `station:${quest}:${station}`;
|
|
5874
|
+
var stationRevocationInputSchema = /* @__PURE__ */ (() => z54.object({
|
|
5875
|
+
reason: z54.string().trim().min(1).max(500),
|
|
5876
|
+
actionId: identifier
|
|
5877
|
+
}).strict())();
|
|
5878
|
+
var stationRevocationSchema = /* @__PURE__ */ (() => z54.object({
|
|
5879
|
+
quest: identifier,
|
|
5880
|
+
station: z54.string(),
|
|
5881
|
+
revoked: z54.boolean(),
|
|
5882
|
+
reason: z54.string().nullable(),
|
|
5883
|
+
actor: z54.string().nullable(),
|
|
5884
|
+
/** When it was last revoked or restored, epoch milliseconds. */
|
|
5885
|
+
changedAt: z54.number().nullable(),
|
|
5828
5886
|
changed: z54.boolean()
|
|
5829
5887
|
}))();
|
|
5888
|
+
var questStationStateSchema = /* @__PURE__ */ (() => z54.object({
|
|
5889
|
+
key: z54.string(),
|
|
5890
|
+
label: z54.string(),
|
|
5891
|
+
opensAt: z54.number().optional(),
|
|
5892
|
+
closesAt: z54.number().optional(),
|
|
5893
|
+
status: z54.string(),
|
|
5894
|
+
revocation: z54.object({
|
|
5895
|
+
revoked: z54.boolean(),
|
|
5896
|
+
reason: z54.string(),
|
|
5897
|
+
actor: z54.string().nullable(),
|
|
5898
|
+
changedAt: z54.number()
|
|
5899
|
+
}).nullable(),
|
|
5900
|
+
completions: z54.number().int().nonnegative()
|
|
5901
|
+
}))();
|
|
5830
5902
|
|
|
5831
5903
|
// src/server/client/quests.ts
|
|
5832
5904
|
function quests(http) {
|
|
5833
5905
|
const { get, post } = http;
|
|
5906
|
+
const station = (verb) => (quest, key2, input, call) => post(
|
|
5907
|
+
`/quests/${identifier.parse(quest)}/stations/${encodeURIComponent(key2)}/${verb}`,
|
|
5908
|
+
stationRevocationSchema,
|
|
5909
|
+
stationRevocationInputSchema.parse(withActionId(input)),
|
|
5910
|
+
call
|
|
5911
|
+
);
|
|
5834
5912
|
return {
|
|
5835
5913
|
pause: (quest, input, call) => operationVerb(
|
|
5836
5914
|
http,
|
|
@@ -5846,6 +5924,41 @@ function quests(http) {
|
|
|
5846
5924
|
input,
|
|
5847
5925
|
call
|
|
5848
5926
|
),
|
|
5927
|
+
/**
|
|
5928
|
+
* A quest's check-in stations.
|
|
5929
|
+
*
|
|
5930
|
+
* @experimental A minor release can change check-in stations.
|
|
5931
|
+
*/
|
|
5932
|
+
stations: {
|
|
5933
|
+
/**
|
|
5934
|
+
* Each check-in station of the quest's current release, in its order, with its status now,
|
|
5935
|
+
* its last revoke or restore, and its completions; requires `read`.
|
|
5936
|
+
*
|
|
5937
|
+
* @experimental A minor release can change check-in stations.
|
|
5938
|
+
*/
|
|
5939
|
+
list: (quest, call) => get(
|
|
5940
|
+
`/quests/${identifier.parse(quest)}/stations`,
|
|
5941
|
+
z55.array(questStationStateSchema),
|
|
5942
|
+
call
|
|
5943
|
+
),
|
|
5944
|
+
/**
|
|
5945
|
+
* Revokes a check-in station, such as one whose code leaked, with a reason; requires
|
|
5946
|
+
* `publish`, as pausing a quest does. From then on a transaction naming the station is
|
|
5947
|
+
* refused with `station-revoked`, whenever it was signed. It is an operation: it applies in
|
|
5948
|
+
* this environment at once, and a promotion never changes it. Revoking a revoked station
|
|
5949
|
+
* changes nothing.
|
|
5950
|
+
*
|
|
5951
|
+
* @experimental A minor release can change check-in stations.
|
|
5952
|
+
*/
|
|
5953
|
+
revoke: station("revoke"),
|
|
5954
|
+
/**
|
|
5955
|
+
* Restores a revoked check-in station, with a reason; requires `publish`. Restoring a
|
|
5956
|
+
* station that is not revoked changes nothing.
|
|
5957
|
+
*
|
|
5958
|
+
* @experimental A minor release can change check-in stations.
|
|
5959
|
+
*/
|
|
5960
|
+
restore: station("restore")
|
|
5961
|
+
},
|
|
5849
5962
|
/**
|
|
5850
5963
|
* Each quest's current release, the most recently published first, archived quests
|
|
5851
5964
|
* included; requires `read` permission.
|
|
@@ -5988,6 +6101,31 @@ function x({ get }) {
|
|
|
5988
6101
|
}
|
|
5989
6102
|
var xApi = (http) => x(http);
|
|
5990
6103
|
|
|
6104
|
+
// src/server/client/solana.ts
|
|
6105
|
+
function solana({ post }) {
|
|
6106
|
+
return {
|
|
6107
|
+
/**
|
|
6108
|
+
* Finalized, successful transactions as `ctx.wallet.transactions()` returns them, for a
|
|
6109
|
+
* testing kit's `facts.wallet.transactions`: Relay reads them through its Solana RPC and
|
|
6110
|
+
* decodes the program's instructions with the IDL a `settings.solanaProgram()` setting would
|
|
6111
|
+
* store (or `idl`); requires `read` permission and stores nothing. Each transaction is seen
|
|
6112
|
+
* by `wallet` (the fee payer by default) and must call `program`. Fails with 404
|
|
6113
|
+
* `transaction-not-found` for a signature the cluster has no transaction for, 409
|
|
6114
|
+
* `transaction-not-final` for one not finalized yet, and 422 `transaction-failed` for a
|
|
6115
|
+
* failed one.
|
|
6116
|
+
*
|
|
6117
|
+
* @experimental A minor release can change this method and its result.
|
|
6118
|
+
*/
|
|
6119
|
+
transactionFixture: (input, call) => post(
|
|
6120
|
+
"/solana/transaction-fixtures",
|
|
6121
|
+
walletTransactionsSchema,
|
|
6122
|
+
solanaTransactionFixtureInputSchema.parse(input),
|
|
6123
|
+
call
|
|
6124
|
+
)
|
|
6125
|
+
};
|
|
6126
|
+
}
|
|
6127
|
+
var solanaApi = (http) => solana(http);
|
|
6128
|
+
|
|
5991
6129
|
// src/server/client/discord.ts
|
|
5992
6130
|
import * as z56 from "zod";
|
|
5993
6131
|
function discord({ get, post }) {
|
|
@@ -6285,29 +6423,29 @@ function parse(message) {
|
|
|
6285
6423
|
}
|
|
6286
6424
|
const [, scheme, domain, family] = header;
|
|
6287
6425
|
const address = lines[1] ?? "";
|
|
6288
|
-
let
|
|
6426
|
+
let index2 = 2;
|
|
6289
6427
|
let statement = null;
|
|
6290
|
-
if (
|
|
6291
|
-
if (lines[
|
|
6428
|
+
if (index2 < lines.length) {
|
|
6429
|
+
if (lines[index2] !== "") {
|
|
6292
6430
|
throw invalid("The address is not followed by an empty line");
|
|
6293
6431
|
}
|
|
6294
|
-
|
|
6295
|
-
if (lines[
|
|
6296
|
-
|
|
6297
|
-
} else if (
|
|
6298
|
-
statement = lines[
|
|
6299
|
-
|
|
6300
|
-
if (lines[
|
|
6432
|
+
index2++;
|
|
6433
|
+
if (lines[index2] === "") {
|
|
6434
|
+
index2++;
|
|
6435
|
+
} else if (index2 < lines.length && !fieldLine.test(lines[index2])) {
|
|
6436
|
+
statement = lines[index2];
|
|
6437
|
+
index2++;
|
|
6438
|
+
if (lines[index2] !== "") {
|
|
6301
6439
|
throw invalid("The statement is not followed by an empty line");
|
|
6302
6440
|
}
|
|
6303
|
-
|
|
6441
|
+
index2++;
|
|
6304
6442
|
}
|
|
6305
6443
|
}
|
|
6306
6444
|
const fields = {};
|
|
6307
6445
|
const resources2 = [];
|
|
6308
6446
|
let position = -1;
|
|
6309
|
-
for (;
|
|
6310
|
-
const line = lines[
|
|
6447
|
+
for (; index2 < lines.length; index2++) {
|
|
6448
|
+
const line = lines[index2];
|
|
6311
6449
|
const field = fieldLine.exec(line);
|
|
6312
6450
|
const name = field?.[1];
|
|
6313
6451
|
const at = name ? fieldOrder.indexOf(name) : -1;
|
|
@@ -6319,8 +6457,8 @@ function parse(message) {
|
|
|
6319
6457
|
if (field[2] !== void 0) {
|
|
6320
6458
|
throw invalid("Resources are listed one per line");
|
|
6321
6459
|
}
|
|
6322
|
-
while (lines[
|
|
6323
|
-
resources2.push(lines[++
|
|
6460
|
+
while (lines[index2 + 1]?.startsWith("- ")) {
|
|
6461
|
+
resources2.push(lines[++index2].slice(2));
|
|
6324
6462
|
}
|
|
6325
6463
|
} else if (field[2] === void 0 || field[2] === "") {
|
|
6326
6464
|
throw invalid(`${name} has no value`);
|
|
@@ -6447,40 +6585,336 @@ async function verifyWalletSignIn(input) {
|
|
|
6447
6585
|
};
|
|
6448
6586
|
}
|
|
6449
6587
|
|
|
6450
|
-
// src/
|
|
6451
|
-
|
|
6452
|
-
var
|
|
6453
|
-
|
|
6454
|
-
|
|
6455
|
-
|
|
6456
|
-
|
|
6457
|
-
|
|
6458
|
-
|
|
6459
|
-
|
|
6460
|
-
|
|
6461
|
-
|
|
6462
|
-
|
|
6463
|
-
|
|
6464
|
-
|
|
6465
|
-
|
|
6466
|
-
|
|
6467
|
-
|
|
6468
|
-
|
|
6469
|
-
|
|
6470
|
-
|
|
6471
|
-
|
|
6472
|
-
|
|
6473
|
-
|
|
6474
|
-
|
|
6475
|
-
|
|
6476
|
-
|
|
6477
|
-
|
|
6478
|
-
}
|
|
6588
|
+
// src/solana-transaction-messages.ts
|
|
6589
|
+
var maxSolanaTransactionBytes = 1232;
|
|
6590
|
+
var SolanaTransactionShapeError = class extends Error {
|
|
6591
|
+
name = "SolanaTransactionShapeError";
|
|
6592
|
+
};
|
|
6593
|
+
var refuse2 = (message) => {
|
|
6594
|
+
throw new SolanaTransactionShapeError(message);
|
|
6595
|
+
};
|
|
6596
|
+
function key(address, what) {
|
|
6597
|
+
return base58Bytes(address, 32) ?? refuse2(`${what} is not a Solana address`);
|
|
6598
|
+
}
|
|
6599
|
+
function shortVec(value) {
|
|
6600
|
+
const bytes = [];
|
|
6601
|
+
for (let rest = value; ; ) {
|
|
6602
|
+
const byte = rest & 127;
|
|
6603
|
+
rest >>= 7;
|
|
6604
|
+
if (rest === 0) {
|
|
6605
|
+
bytes.push(byte);
|
|
6606
|
+
return bytes;
|
|
6607
|
+
}
|
|
6608
|
+
bytes.push(byte | 128);
|
|
6609
|
+
}
|
|
6610
|
+
}
|
|
6611
|
+
function reader(bytes) {
|
|
6612
|
+
let offset = 0;
|
|
6613
|
+
const take = (length2) => {
|
|
6614
|
+
if (offset + length2 > bytes.length) {
|
|
6615
|
+
refuse2("The transaction ends early");
|
|
6616
|
+
}
|
|
6617
|
+
const slice = bytes.slice(offset, offset + length2);
|
|
6618
|
+
offset += length2;
|
|
6619
|
+
return slice;
|
|
6620
|
+
};
|
|
6621
|
+
const byte = () => take(1)[0];
|
|
6622
|
+
const length = () => {
|
|
6623
|
+
let value = 0;
|
|
6624
|
+
for (let shift = 0; shift < 21; shift += 7) {
|
|
6625
|
+
const next = byte();
|
|
6626
|
+
value |= (next & 127) << shift;
|
|
6627
|
+
if (!(next & 128)) {
|
|
6628
|
+
return value;
|
|
6629
|
+
}
|
|
6630
|
+
}
|
|
6631
|
+
return refuse2("The transaction has a malformed length");
|
|
6632
|
+
};
|
|
6633
|
+
const list = (item) => Array.from({ length: length() }, () => item());
|
|
6634
|
+
return {
|
|
6635
|
+
take,
|
|
6636
|
+
byte,
|
|
6637
|
+
length,
|
|
6638
|
+
list,
|
|
6639
|
+
rest: () => take(bytes.length - offset),
|
|
6640
|
+
done: () => offset === bytes.length
|
|
6641
|
+
};
|
|
6642
|
+
}
|
|
6643
|
+
function decodeMessage(bytes) {
|
|
6644
|
+
const read = reader(bytes);
|
|
6645
|
+
const first = bytes[0];
|
|
6646
|
+
let version = "legacy";
|
|
6647
|
+
if (first !== void 0 && first & 128) {
|
|
6648
|
+
if ((first & 127) !== 0) {
|
|
6649
|
+
refuse2(
|
|
6650
|
+
`Version ${first & 127} transactions are not supported: use a legacy or version 0 message`
|
|
6651
|
+
);
|
|
6652
|
+
}
|
|
6653
|
+
read.byte();
|
|
6654
|
+
version = 0;
|
|
6655
|
+
}
|
|
6656
|
+
const header = [
|
|
6657
|
+
read.byte(),
|
|
6658
|
+
read.byte(),
|
|
6659
|
+
read.byte()
|
|
6660
|
+
];
|
|
6661
|
+
const accounts = read.list(() => read.take(32));
|
|
6662
|
+
const blockhash = read.take(32);
|
|
6663
|
+
const instructions = read.list(() => ({
|
|
6664
|
+
program: read.byte(),
|
|
6665
|
+
accounts: read.list(read.byte),
|
|
6666
|
+
data: read.take(read.length())
|
|
6667
|
+
}));
|
|
6668
|
+
const lookups = version === 0 ? read.list(() => ({
|
|
6669
|
+
table: read.take(32),
|
|
6670
|
+
writable: read.list(read.byte),
|
|
6671
|
+
readonly: read.list(read.byte)
|
|
6672
|
+
})) : [];
|
|
6673
|
+
if (!read.done()) {
|
|
6674
|
+
refuse2("The transaction has bytes after its message");
|
|
6675
|
+
}
|
|
6676
|
+
return { version, header, accounts, blockhash, instructions, lookups };
|
|
6677
|
+
}
|
|
6678
|
+
function encodeMessage(message) {
|
|
6679
|
+
const indexes = (values) => [...shortVec(values.length), ...values];
|
|
6680
|
+
const bytes = [
|
|
6681
|
+
...message.version === 0 ? [128] : [],
|
|
6682
|
+
...message.header,
|
|
6683
|
+
...shortVec(message.accounts.length),
|
|
6684
|
+
...message.accounts.flatMap((account2) => [...account2]),
|
|
6685
|
+
...message.blockhash,
|
|
6686
|
+
...shortVec(message.instructions.length),
|
|
6687
|
+
...message.instructions.flatMap((instruction) => [
|
|
6688
|
+
instruction.program,
|
|
6689
|
+
...indexes(instruction.accounts),
|
|
6690
|
+
...shortVec(instruction.data.length),
|
|
6691
|
+
...instruction.data
|
|
6692
|
+
])
|
|
6693
|
+
];
|
|
6694
|
+
if (message.version === 0) {
|
|
6695
|
+
bytes.push(...shortVec(message.lookups.length));
|
|
6696
|
+
for (const lookup of message.lookups) {
|
|
6697
|
+
bytes.push(
|
|
6698
|
+
...lookup.table,
|
|
6699
|
+
...indexes(lookup.writable),
|
|
6700
|
+
...indexes(lookup.readonly)
|
|
6701
|
+
);
|
|
6702
|
+
}
|
|
6703
|
+
}
|
|
6704
|
+
return Uint8Array.from(bytes);
|
|
6705
|
+
}
|
|
6706
|
+
function compileKitMessage(message) {
|
|
6707
|
+
const version = message.version === "legacy" ? "legacy" : message.version === 0 ? 0 : refuse2(
|
|
6708
|
+
`Version ${String(message.version)} transactions are not supported: use a legacy or version 0 message`
|
|
6709
|
+
);
|
|
6710
|
+
const payer = message.feePayer?.address ?? refuse2("Set the transaction message's fee payer");
|
|
6711
|
+
const lifetime = message.lifetimeConstraint;
|
|
6712
|
+
const blockhash = lifetime && "blockhash" in lifetime ? lifetime.blockhash : lifetime && "nonce" in lifetime ? lifetime.nonce : refuse2("Set the transaction message's blockhash or nonce lifetime");
|
|
6713
|
+
const statics = /* @__PURE__ */ new Map([[payer, 3]]);
|
|
6714
|
+
const looked = /* @__PURE__ */ new Map();
|
|
6715
|
+
const add = (address, role) => statics.set(address, (statics.get(address) ?? 0) | role);
|
|
6716
|
+
for (const instruction of message.instructions) {
|
|
6717
|
+
add(instruction.programAddress, 0);
|
|
6718
|
+
for (const account2 of instruction.accounts ?? []) {
|
|
6719
|
+
if (account2.lookupTableAddress === void 0 || account2.role & 2) {
|
|
6720
|
+
add(account2.address, account2.role);
|
|
6721
|
+
continue;
|
|
6722
|
+
}
|
|
6723
|
+
if (version === "legacy") {
|
|
6724
|
+
refuse2("A legacy message can't load accounts from a lookup table");
|
|
6725
|
+
}
|
|
6726
|
+
const known = looked.get(account2.address);
|
|
6727
|
+
looked.set(account2.address, {
|
|
6728
|
+
table: account2.lookupTableAddress,
|
|
6729
|
+
index: account2.addressIndex ?? refuse2("A lookup table account needs its addressIndex"),
|
|
6730
|
+
writable: !!(account2.role & 1) || !!known?.writable
|
|
6731
|
+
});
|
|
6732
|
+
}
|
|
6733
|
+
}
|
|
6734
|
+
for (const [address, entry] of looked) {
|
|
6735
|
+
if (statics.has(address)) {
|
|
6736
|
+
add(address, entry.writable ? 1 : 0);
|
|
6737
|
+
looked.delete(address);
|
|
6738
|
+
}
|
|
6739
|
+
}
|
|
6740
|
+
const rank = (role) => 3 - role;
|
|
6741
|
+
const [first, ...rest] = [...statics];
|
|
6742
|
+
const ordered = [first, ...rest.sort(([, a], [, b]) => rank(a) - rank(b))];
|
|
6743
|
+
const count = (match) => ordered.filter(([, role]) => match(role)).length;
|
|
6744
|
+
const tables = /* @__PURE__ */ new Map();
|
|
6745
|
+
for (const [address, entry] of looked) {
|
|
6746
|
+
const table = tables.get(entry.table) ?? { writable: [], readonly: [] };
|
|
6747
|
+
table[entry.writable ? "writable" : "readonly"].push([address, entry.index]);
|
|
6748
|
+
tables.set(entry.table, table);
|
|
6749
|
+
}
|
|
6750
|
+
const position = new Map(ordered.map(([address], index2) => [address, index2]));
|
|
6751
|
+
let next = ordered.length;
|
|
6752
|
+
for (const kind of ["writable", "readonly"]) {
|
|
6753
|
+
for (const table of tables.values()) {
|
|
6754
|
+
for (const [address] of table[kind]) {
|
|
6755
|
+
position.set(address, next++);
|
|
6756
|
+
}
|
|
6757
|
+
}
|
|
6758
|
+
}
|
|
6759
|
+
if (next > 256) {
|
|
6760
|
+
refuse2("The transaction names more than 256 accounts");
|
|
6761
|
+
}
|
|
6762
|
+
const at = (address) => position.get(address);
|
|
6763
|
+
return {
|
|
6764
|
+
version,
|
|
6765
|
+
header: [
|
|
6766
|
+
count((role) => (role & 2) !== 0),
|
|
6767
|
+
count((role) => role === 2),
|
|
6768
|
+
count((role) => (role & 2) === 0 && (role & 1) === 0)
|
|
6769
|
+
],
|
|
6770
|
+
accounts: ordered.map(([address]) => key(address, address)),
|
|
6771
|
+
blockhash: key(blockhash, "The transaction's blockhash"),
|
|
6772
|
+
instructions: message.instructions.map((instruction) => ({
|
|
6773
|
+
program: at(instruction.programAddress),
|
|
6774
|
+
accounts: (instruction.accounts ?? []).map(({ address }) => at(address)),
|
|
6775
|
+
data: Uint8Array.from(instruction.data ?? [])
|
|
6776
|
+
})),
|
|
6777
|
+
lookups: [...tables].map(([table, entries]) => ({
|
|
6778
|
+
table: key(table, "A lookup table address"),
|
|
6779
|
+
writable: entries.writable.map(([, index2]) => index2),
|
|
6780
|
+
readonly: entries.readonly.map(([, index2]) => index2)
|
|
6781
|
+
}))
|
|
6782
|
+
};
|
|
6783
|
+
}
|
|
6784
|
+
function withInstruction(message, program, data) {
|
|
6785
|
+
const programKey = key(program, "The program");
|
|
6786
|
+
const existing = message.accounts.findIndex(
|
|
6787
|
+
(account2) => account2.every((byte, index2) => byte === programKey[index2])
|
|
6788
|
+
);
|
|
6789
|
+
if (existing >= 0) {
|
|
6790
|
+
return {
|
|
6791
|
+
...message,
|
|
6792
|
+
instructions: [
|
|
6793
|
+
...message.instructions,
|
|
6794
|
+
{ program: existing, accounts: [], data }
|
|
6795
|
+
]
|
|
6796
|
+
};
|
|
6797
|
+
}
|
|
6798
|
+
const statics = message.accounts.length;
|
|
6799
|
+
const shift = (index2) => index2 >= statics ? index2 + 1 : index2;
|
|
6800
|
+
return {
|
|
6801
|
+
...message,
|
|
6802
|
+
header: [message.header[0], message.header[1], message.header[2] + 1],
|
|
6803
|
+
accounts: [...message.accounts, programKey],
|
|
6804
|
+
instructions: [
|
|
6805
|
+
...message.instructions.map((instruction) => ({
|
|
6806
|
+
program: shift(instruction.program),
|
|
6807
|
+
accounts: instruction.accounts.map(shift),
|
|
6808
|
+
data: instruction.data
|
|
6809
|
+
})),
|
|
6810
|
+
{ program: statics, accounts: [], data }
|
|
6811
|
+
]
|
|
6812
|
+
};
|
|
6813
|
+
}
|
|
6814
|
+
function base64(bytes) {
|
|
6815
|
+
let binary = "";
|
|
6816
|
+
for (const byte of bytes) {
|
|
6817
|
+
binary += String.fromCharCode(byte);
|
|
6818
|
+
}
|
|
6819
|
+
return btoa(binary);
|
|
6820
|
+
}
|
|
6821
|
+
function fromBase64(value) {
|
|
6822
|
+
let binary;
|
|
6823
|
+
try {
|
|
6824
|
+
binary = atob(value);
|
|
6825
|
+
} catch {
|
|
6826
|
+
return refuse2("The transaction is not base64");
|
|
6827
|
+
}
|
|
6828
|
+
return Uint8Array.from(binary, (character) => character.charCodeAt(0));
|
|
6829
|
+
}
|
|
6830
|
+
function splitWire(bytes) {
|
|
6831
|
+
const read = reader(bytes);
|
|
6832
|
+
const signatures = read.list(() => read.take(64));
|
|
6833
|
+
return { signatures, message: read.rest() };
|
|
6834
|
+
}
|
|
6835
|
+
var isBytes = (value) => value instanceof Uint8Array;
|
|
6836
|
+
function messageOf(transaction2) {
|
|
6837
|
+
if (typeof transaction2 === "string" || isBytes(transaction2)) {
|
|
6838
|
+
const wire = typeof transaction2 === "string" ? fromBase64(transaction2) : Uint8Array.from(transaction2);
|
|
6839
|
+
const { signatures, message } = splitWire(wire);
|
|
6840
|
+
const decoded = decodeMessage(message);
|
|
6841
|
+
if (signatures.length !== decoded.header[0]) {
|
|
6842
|
+
refuse2(
|
|
6843
|
+
`The transaction has ${signatures.length} signatures where its message needs ${decoded.header[0]}`
|
|
6844
|
+
);
|
|
6845
|
+
}
|
|
6846
|
+
return {
|
|
6847
|
+
message: decoded,
|
|
6848
|
+
signed: signatures.some((signature) => signature.some(Boolean))
|
|
6849
|
+
};
|
|
6850
|
+
}
|
|
6851
|
+
if ("messageBytes" in transaction2) {
|
|
6852
|
+
return {
|
|
6853
|
+
message: decodeMessage(Uint8Array.from(transaction2.messageBytes)),
|
|
6854
|
+
signed: Object.values(transaction2.signatures).some(
|
|
6855
|
+
(signature) => signature !== null && signature.some(Boolean)
|
|
6856
|
+
)
|
|
6857
|
+
};
|
|
6858
|
+
}
|
|
6859
|
+
if (Array.isArray(transaction2.instructions)) {
|
|
6860
|
+
return { message: compileKitMessage(transaction2), signed: false };
|
|
6861
|
+
}
|
|
6862
|
+
return refuse2(
|
|
6863
|
+
"Return a @solana/kit transaction message, a compiled transaction, or the transaction's bytes"
|
|
6864
|
+
);
|
|
6865
|
+
}
|
|
6866
|
+
function appendSolanaInstruction(transaction2, program, data) {
|
|
6867
|
+
const { message, signed } = messageOf(transaction2);
|
|
6868
|
+
if (signed) {
|
|
6869
|
+
refuse2(
|
|
6870
|
+
"The transaction is already signed, and Domino's memo would void the signature: return it unsigned"
|
|
6871
|
+
);
|
|
6872
|
+
}
|
|
6873
|
+
if (!message.instructions.length) {
|
|
6874
|
+
refuse2("The transaction has no instructions");
|
|
6875
|
+
}
|
|
6876
|
+
const bytes = encodeMessage(withInstruction(message, program, data));
|
|
6877
|
+
const signatures = message.header[0];
|
|
6878
|
+
const wire = Uint8Array.from([
|
|
6879
|
+
...shortVec(signatures),
|
|
6880
|
+
...new Uint8Array(signatures * 64),
|
|
6881
|
+
...bytes
|
|
6882
|
+
]);
|
|
6883
|
+
if (wire.length > maxSolanaTransactionBytes) {
|
|
6884
|
+
refuse2(
|
|
6885
|
+
`The transaction takes ${wire.length} bytes with Domino's memo, more than Solana's ${maxSolanaTransactionBytes}`
|
|
6886
|
+
);
|
|
6887
|
+
}
|
|
6888
|
+
return base64(wire);
|
|
6889
|
+
}
|
|
6890
|
+
function decodeSolanaTransaction(transaction2) {
|
|
6891
|
+
const { signatures, message } = splitWire(fromBase64(transaction2));
|
|
6892
|
+
const decoded = decodeMessage(message);
|
|
6893
|
+
const loaded = ["writable", "readonly"].flatMap(
|
|
6894
|
+
(kind) => decoded.lookups.flatMap(
|
|
6895
|
+
({ table, ...indexes }) => indexes[kind].map((index2) => `${base58(table)}#${index2}`)
|
|
6896
|
+
)
|
|
6897
|
+
);
|
|
6898
|
+
const names = [...decoded.accounts.map(base58), ...loaded];
|
|
6899
|
+
return {
|
|
6900
|
+
version: decoded.version,
|
|
6901
|
+
signatures: signatures.length,
|
|
6902
|
+
feePayer: names[0],
|
|
6903
|
+
blockhash: base58(decoded.blockhash),
|
|
6904
|
+
instructions: decoded.instructions.map(
|
|
6905
|
+
(instruction) => ({
|
|
6906
|
+
program: names[instruction.program],
|
|
6907
|
+
accounts: instruction.accounts.map((index2) => names[index2]),
|
|
6908
|
+
data: instruction.data
|
|
6909
|
+
})
|
|
6910
|
+
)
|
|
6911
|
+
};
|
|
6912
|
+
}
|
|
6479
6913
|
|
|
6480
6914
|
// src/server/hosted.ts
|
|
6481
|
-
import * as
|
|
6915
|
+
import * as z60 from "zod";
|
|
6482
6916
|
var hostedKeyPermissions = ["read", "points", "ingest"];
|
|
6483
|
-
var hostedKeyPermissionList = /* @__PURE__ */ (() =>
|
|
6917
|
+
var hostedKeyPermissionList = /* @__PURE__ */ (() => z60.array(z60.string()).transform(
|
|
6484
6918
|
(values) => values.filter(
|
|
6485
6919
|
(value) => hostedKeyPermissions.includes(value)
|
|
6486
6920
|
)
|
|
@@ -6492,17 +6926,17 @@ var hostedManagementBindings = [
|
|
|
6492
6926
|
"DOMINO_PROJECT",
|
|
6493
6927
|
"DOMINO_ENVIRONMENT"
|
|
6494
6928
|
];
|
|
6495
|
-
var hostedKeySecretSchema = /* @__PURE__ */ (() =>
|
|
6496
|
-
var hostedKeySchema = /* @__PURE__ */ (() =>
|
|
6497
|
-
id:
|
|
6929
|
+
var hostedKeySecretSchema = /* @__PURE__ */ (() => z60.string().regex(/^dhk_[A-Za-z0-9_-]{43}$/, "Expected a hosted app key"))();
|
|
6930
|
+
var hostedKeySchema = /* @__PURE__ */ (() => z60.object({
|
|
6931
|
+
id: z60.string().uuid(),
|
|
6498
6932
|
token: hostedKeySecretSchema,
|
|
6499
6933
|
organization: identifier,
|
|
6500
6934
|
project: identifier,
|
|
6501
|
-
environment:
|
|
6935
|
+
environment: z60.enum(["test", "live"]),
|
|
6502
6936
|
permissions: hostedKeyPermissionList,
|
|
6503
|
-
expiresAt:
|
|
6937
|
+
expiresAt: z60.number().nullable()
|
|
6504
6938
|
}).strict())();
|
|
6505
|
-
var hostedDeploymentKeySchema = /* @__PURE__ */ (() => hostedKeySchema.extend({ apiUrl:
|
|
6939
|
+
var hostedDeploymentKeySchema = /* @__PURE__ */ (() => hostedKeySchema.extend({ apiUrl: z60.string().url() }).strict())();
|
|
6506
6940
|
function hostedManagementClient(env) {
|
|
6507
6941
|
const missing = hostedManagementBindings.filter((name) => !env[name]);
|
|
6508
6942
|
if (missing.length) {
|
|
@@ -6510,7 +6944,7 @@ function hostedManagementClient(env) {
|
|
|
6510
6944
|
`Missing ${missing.join(", ")}. Domino sets these for hosted apps and domino dev; update the project's vite.config.ts to forward them in development.`
|
|
6511
6945
|
);
|
|
6512
6946
|
}
|
|
6513
|
-
const environment =
|
|
6947
|
+
const environment = z60.enum(["test", "live"]).parse(env.DOMINO_ENVIRONMENT);
|
|
6514
6948
|
const token = env.DOMINO_MANAGEMENT_KEY;
|
|
6515
6949
|
return createManagementClient({
|
|
6516
6950
|
baseUrl: env.DOMINO_API_URL.replace(/\/+$/, ""),
|
|
@@ -6521,6 +6955,690 @@ function hostedManagementClient(env) {
|
|
|
6521
6955
|
});
|
|
6522
6956
|
}
|
|
6523
6957
|
|
|
6958
|
+
// src/server/quest-actions.ts
|
|
6959
|
+
var solanaActionVersion = "2.4";
|
|
6960
|
+
var step = "domino-step";
|
|
6961
|
+
var maxBody = 16 * 1024;
|
|
6962
|
+
var metadataTtl = 6e4;
|
|
6963
|
+
var defaultConfirmTimeout = 45e3;
|
|
6964
|
+
var pollInterval = 1500;
|
|
6965
|
+
var refusalBrand = /* @__PURE__ */ (() => /* @__PURE__ */ Symbol.for("@domino-sdk/relay.QuestActionRefusal"))();
|
|
6966
|
+
var QuestActionRefusal = class extends Error {
|
|
6967
|
+
constructor(message, status = 422) {
|
|
6968
|
+
super(message);
|
|
6969
|
+
this.status = status;
|
|
6970
|
+
}
|
|
6971
|
+
status;
|
|
6972
|
+
name = "QuestActionRefusal";
|
|
6973
|
+
[refusalBrand] = true;
|
|
6974
|
+
};
|
|
6975
|
+
function isRefusal(value) {
|
|
6976
|
+
return value instanceof Error && value[refusalBrand] === true;
|
|
6977
|
+
}
|
|
6978
|
+
function solanaActionHeaders(chain) {
|
|
6979
|
+
return new Headers({
|
|
6980
|
+
"Access-Control-Allow-Origin": "*",
|
|
6981
|
+
"Access-Control-Allow-Methods": "GET,POST,PUT,OPTIONS",
|
|
6982
|
+
"Access-Control-Allow-Headers": "Content-Type, Authorization, Content-Encoding, Accept-Encoding, X-Accept-Action-Version, X-Accept-Blockchain-Ids",
|
|
6983
|
+
"Access-Control-Expose-Headers": "X-Action-Version, X-Blockchain-Ids",
|
|
6984
|
+
"X-Action-Version": solanaActionVersion,
|
|
6985
|
+
"X-Blockchain-Ids": chain
|
|
6986
|
+
});
|
|
6987
|
+
}
|
|
6988
|
+
function json2(chain, body, status = 200) {
|
|
6989
|
+
const headers = solanaActionHeaders(chain);
|
|
6990
|
+
headers.set("Content-Type", "application/json");
|
|
6991
|
+
return new Response(JSON.stringify(body), { status, headers });
|
|
6992
|
+
}
|
|
6993
|
+
var failure = (chain, message, status) => json2(chain, { message }, status);
|
|
6994
|
+
async function readBody(request) {
|
|
6995
|
+
const text = request.body ? await boundedBodyText(request.body, maxBody) : "";
|
|
6996
|
+
if (text === null) {
|
|
6997
|
+
return null;
|
|
6998
|
+
}
|
|
6999
|
+
if (!text.trim()) {
|
|
7000
|
+
return {};
|
|
7001
|
+
}
|
|
7002
|
+
try {
|
|
7003
|
+
const value = JSON.parse(text);
|
|
7004
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
7005
|
+
} catch {
|
|
7006
|
+
return null;
|
|
7007
|
+
}
|
|
7008
|
+
}
|
|
7009
|
+
function stepHref(request, value, extra = {}) {
|
|
7010
|
+
const url = new URL(request.url);
|
|
7011
|
+
url.searchParams.set(step, value);
|
|
7012
|
+
for (const [name, item] of Object.entries(extra)) {
|
|
7013
|
+
url.searchParams.set(name, item);
|
|
7014
|
+
}
|
|
7015
|
+
return url.pathname + url.search;
|
|
7016
|
+
}
|
|
7017
|
+
var wait = (ms) => new Promise((resolve) => setTimeout(resolve, Math.max(0, ms)));
|
|
7018
|
+
function defineQuestAction(options) {
|
|
7019
|
+
const chain = solanaTransactionSubmissionSchema.shape.chain.parse(options.chain);
|
|
7020
|
+
const confirmTimeout = options.confirmTimeout ?? defaultConfirmTimeout;
|
|
7021
|
+
const { clientFor, cardFor } = questActionContext(options);
|
|
7022
|
+
return async function questAction(request, env) {
|
|
7023
|
+
if (request.method === "OPTIONS") {
|
|
7024
|
+
return new Response(null, {
|
|
7025
|
+
status: 204,
|
|
7026
|
+
headers: solanaActionHeaders(chain)
|
|
7027
|
+
});
|
|
7028
|
+
}
|
|
7029
|
+
if (request.method !== "GET" && request.method !== "POST") {
|
|
7030
|
+
return failure(chain, `${request.method} is not an action method`, 405);
|
|
7031
|
+
}
|
|
7032
|
+
try {
|
|
7033
|
+
const client = clientFor(env);
|
|
7034
|
+
const card = await cardFor(client, request);
|
|
7035
|
+
if (request.method === "GET") {
|
|
7036
|
+
return json2(chain, actionCard(card, options.metadata, request));
|
|
7037
|
+
}
|
|
7038
|
+
const body = await readBody(request);
|
|
7039
|
+
if (!body) {
|
|
7040
|
+
return failure(chain, "Send a JSON body of at most 16 KB", 400);
|
|
7041
|
+
}
|
|
7042
|
+
const url = new URL(request.url);
|
|
7043
|
+
switch (url.searchParams.get(step)) {
|
|
7044
|
+
case null:
|
|
7045
|
+
return await transaction(chain, card, options, request, url, body);
|
|
7046
|
+
case "complete":
|
|
7047
|
+
return await complete(
|
|
7048
|
+
chain,
|
|
7049
|
+
client,
|
|
7050
|
+
card,
|
|
7051
|
+
options,
|
|
7052
|
+
request,
|
|
7053
|
+
confirmTimeout,
|
|
7054
|
+
body
|
|
7055
|
+
);
|
|
7056
|
+
case "link":
|
|
7057
|
+
return json2(chain, {
|
|
7058
|
+
type: "external-link",
|
|
7059
|
+
externalLink: new URL(options.linkUrl, request.url).href
|
|
7060
|
+
});
|
|
7061
|
+
case "recheck":
|
|
7062
|
+
return json2(chain, {
|
|
7063
|
+
type: "post",
|
|
7064
|
+
links: {
|
|
7065
|
+
next: {
|
|
7066
|
+
type: "post",
|
|
7067
|
+
href: stepHref(request, "complete")
|
|
7068
|
+
}
|
|
7069
|
+
}
|
|
7070
|
+
});
|
|
7071
|
+
default:
|
|
7072
|
+
return failure(chain, "Unknown action step", 400);
|
|
7073
|
+
}
|
|
7074
|
+
} catch (error) {
|
|
7075
|
+
return questActionError(chain, error);
|
|
7076
|
+
}
|
|
7077
|
+
};
|
|
7078
|
+
}
|
|
7079
|
+
function questActionContext(options) {
|
|
7080
|
+
let cached;
|
|
7081
|
+
let hosted;
|
|
7082
|
+
const clientFor = (env) => {
|
|
7083
|
+
if (options.management) {
|
|
7084
|
+
return options.management;
|
|
7085
|
+
}
|
|
7086
|
+
const source = options.env ?? (env && typeof env === "object" && hostedManagementBindings.some((name) => name in env) ? env : globalThis.process?.env ?? {});
|
|
7087
|
+
const bindings = JSON.stringify(
|
|
7088
|
+
hostedManagementBindings.map((name) => source[name] ?? null)
|
|
7089
|
+
);
|
|
7090
|
+
if (hosted?.bindings !== bindings) {
|
|
7091
|
+
hosted = { bindings, client: hostedManagementClient(source) };
|
|
7092
|
+
}
|
|
7093
|
+
return hosted.client;
|
|
7094
|
+
};
|
|
7095
|
+
const cardFor = (client, request) => {
|
|
7096
|
+
const now = Date.now();
|
|
7097
|
+
if (!cached || cached.client !== client || now - cached.at > metadataTtl) {
|
|
7098
|
+
const card = questCard(client, options.quest, request);
|
|
7099
|
+
cached = { at: now, client, card };
|
|
7100
|
+
card.catch(() => {
|
|
7101
|
+
if (cached?.card === card) {
|
|
7102
|
+
cached = void 0;
|
|
7103
|
+
}
|
|
7104
|
+
});
|
|
7105
|
+
}
|
|
7106
|
+
return cached.card;
|
|
7107
|
+
};
|
|
7108
|
+
return { clientFor, cardFor };
|
|
7109
|
+
}
|
|
7110
|
+
function questActionError(chain, error) {
|
|
7111
|
+
if (isRefusal(error)) {
|
|
7112
|
+
return failure(chain, error.message, error.status);
|
|
7113
|
+
}
|
|
7114
|
+
if (isManagementError(error)) {
|
|
7115
|
+
return failure(
|
|
7116
|
+
chain,
|
|
7117
|
+
error.status === void 0 || error.status >= 500 ? "Domino could not be reached. Try again in a minute." : `Domino refused the app's request: ${error.message}`,
|
|
7118
|
+
502
|
|
7119
|
+
);
|
|
7120
|
+
}
|
|
7121
|
+
console.error(error);
|
|
7122
|
+
return failure(chain, "The action failed. Try again in a minute.", 500);
|
|
7123
|
+
}
|
|
7124
|
+
async function questCard(client, quest, request) {
|
|
7125
|
+
const [releases2, operations2] = await Promise.all([
|
|
7126
|
+
client.quests.listWithoutCode(),
|
|
7127
|
+
client.operations.list()
|
|
7128
|
+
]);
|
|
7129
|
+
const release = releases2.find(
|
|
7130
|
+
(item) => item.quest === quest || item.key === quest
|
|
7131
|
+
);
|
|
7132
|
+
if (!release) {
|
|
7133
|
+
throw new QuestActionRefusal(
|
|
7134
|
+
`Quest ${quest} does not exist in this project`,
|
|
7135
|
+
404
|
|
7136
|
+
);
|
|
7137
|
+
}
|
|
7138
|
+
return {
|
|
7139
|
+
id: release.quest,
|
|
7140
|
+
key: release.key ?? null,
|
|
7141
|
+
title: release.title,
|
|
7142
|
+
description: release.presentation.instructions ?? "",
|
|
7143
|
+
image: release.presentation.image ? new URL(release.presentation.image, request.url).href : null,
|
|
7144
|
+
closed: release.lifecycle === "archived" ? "This quest has ended." : release.lifecycle === "paused" || operations2.some(
|
|
7145
|
+
(item) => item.target === `quest:${release.quest}` && item.paused
|
|
7146
|
+
) ? "This quest is paused." : takesSolanaTransaction(release.trigger) ? null : "This quest can't be completed from a wallet transaction.",
|
|
7147
|
+
stations: release.stations ?? null,
|
|
7148
|
+
revoked: new Set(
|
|
7149
|
+
(release.stations ?? []).flatMap(
|
|
7150
|
+
(station) => operations2.some(
|
|
7151
|
+
(item) => item.target === stationOperationTarget(release.quest, station.key) && item.paused
|
|
7152
|
+
) ? [station.key] : []
|
|
7153
|
+
)
|
|
7154
|
+
)
|
|
7155
|
+
};
|
|
7156
|
+
}
|
|
7157
|
+
function questIcon(card, icon, request, option) {
|
|
7158
|
+
const url = icon ? new URL(icon, request.url).href : card.image;
|
|
7159
|
+
if (!url) {
|
|
7160
|
+
throw new QuestActionRefusal(
|
|
7161
|
+
`The quest has no image: give it one, or set ${option}`,
|
|
7162
|
+
500
|
|
7163
|
+
);
|
|
7164
|
+
}
|
|
7165
|
+
return url;
|
|
7166
|
+
}
|
|
7167
|
+
function memberAccount(body) {
|
|
7168
|
+
const account2 = body.account;
|
|
7169
|
+
if (typeof account2 !== "string" || !base58Bytes(account2, 32)) {
|
|
7170
|
+
throw new QuestActionRefusal("Send the wallet's address as account", 400);
|
|
7171
|
+
}
|
|
7172
|
+
return account2;
|
|
7173
|
+
}
|
|
7174
|
+
function actionCard(card, metadata = {}, request) {
|
|
7175
|
+
return {
|
|
7176
|
+
type: "action",
|
|
7177
|
+
icon: questIcon(card, metadata.icon, request, "metadata.icon"),
|
|
7178
|
+
title: metadata.title ?? card.title,
|
|
7179
|
+
description: metadata.description ?? card.description,
|
|
7180
|
+
label: metadata.label ?? "Complete quest",
|
|
7181
|
+
...card.closed ? { disabled: true, error: { message: card.closed } } : {},
|
|
7182
|
+
...metadata.actions?.length ? {
|
|
7183
|
+
links: {
|
|
7184
|
+
actions: metadata.actions.map((action) => ({
|
|
7185
|
+
type: "transaction",
|
|
7186
|
+
...action
|
|
7187
|
+
}))
|
|
7188
|
+
}
|
|
7189
|
+
} : {}
|
|
7190
|
+
};
|
|
7191
|
+
}
|
|
7192
|
+
function paramsOf(url, body) {
|
|
7193
|
+
const params = {};
|
|
7194
|
+
for (const [name, value] of url.searchParams) {
|
|
7195
|
+
if (name !== step) {
|
|
7196
|
+
params[name] = value;
|
|
7197
|
+
}
|
|
7198
|
+
}
|
|
7199
|
+
const data = body.data;
|
|
7200
|
+
if (data && typeof data === "object" && !Array.isArray(data)) {
|
|
7201
|
+
for (const [name, value] of Object.entries(data)) {
|
|
7202
|
+
if (typeof value === "string" || Array.isArray(value) && value.every((item) => typeof item === "string")) {
|
|
7203
|
+
params[name] = value;
|
|
7204
|
+
}
|
|
7205
|
+
}
|
|
7206
|
+
}
|
|
7207
|
+
return params;
|
|
7208
|
+
}
|
|
7209
|
+
function questMemo(card, reference) {
|
|
7210
|
+
try {
|
|
7211
|
+
return solanaActionMemo({ quest: card.key ?? card.id, reference });
|
|
7212
|
+
} catch {
|
|
7213
|
+
throw new QuestActionRefusal(
|
|
7214
|
+
`The reference must be 1 to ${maxSolanaActionReference} letters, digits, _ or -`,
|
|
7215
|
+
400
|
|
7216
|
+
);
|
|
7217
|
+
}
|
|
7218
|
+
}
|
|
7219
|
+
function withQuestMemo(built, memo) {
|
|
7220
|
+
let serialized;
|
|
7221
|
+
try {
|
|
7222
|
+
serialized = appendSolanaInstruction(
|
|
7223
|
+
built,
|
|
7224
|
+
solanaMemoProgram,
|
|
7225
|
+
new TextEncoder().encode(memo)
|
|
7226
|
+
);
|
|
7227
|
+
} catch (error) {
|
|
7228
|
+
if (error instanceof SolanaTransactionShapeError) {
|
|
7229
|
+
throw new QuestActionRefusal(error.message, 500);
|
|
7230
|
+
}
|
|
7231
|
+
throw error;
|
|
7232
|
+
}
|
|
7233
|
+
const instructions = decodeSolanaTransaction(serialized).instructions;
|
|
7234
|
+
if (instructions.slice(0, -1).some(
|
|
7235
|
+
({ program, data }) => program === solanaMemoProgram && parseSolanaActionMemo(new TextDecoder().decode(data)) !== null
|
|
7236
|
+
)) {
|
|
7237
|
+
throw new QuestActionRefusal(
|
|
7238
|
+
"The transaction already carries a Domino quest memo: return it without one, and the helper adds it",
|
|
7239
|
+
500
|
|
7240
|
+
);
|
|
7241
|
+
}
|
|
7242
|
+
return serialized;
|
|
7243
|
+
}
|
|
7244
|
+
async function transaction(chain, card, options, request, url, body) {
|
|
7245
|
+
const account2 = memberAccount(body);
|
|
7246
|
+
if (card.closed) {
|
|
7247
|
+
return failure(chain, card.closed, 422);
|
|
7248
|
+
}
|
|
7249
|
+
const reference = await options.reference?.(request) ?? void 0;
|
|
7250
|
+
const memo = questMemo(card, reference);
|
|
7251
|
+
const built = await options.build({
|
|
7252
|
+
account: account2,
|
|
7253
|
+
params: paramsOf(url, body),
|
|
7254
|
+
quest: { id: card.id, key: card.key, title: card.title },
|
|
7255
|
+
request
|
|
7256
|
+
});
|
|
7257
|
+
const serialized = withQuestMemo(built, memo);
|
|
7258
|
+
return json2(chain, {
|
|
7259
|
+
type: "transaction",
|
|
7260
|
+
transaction: serialized,
|
|
7261
|
+
message: options.metadata?.message ?? `Completes "${card.title}"`,
|
|
7262
|
+
links: {
|
|
7263
|
+
next: { type: "post", href: stepHref(request, "complete") }
|
|
7264
|
+
}
|
|
7265
|
+
});
|
|
7266
|
+
}
|
|
7267
|
+
var passingRefusals = [
|
|
7268
|
+
"transaction-not-final",
|
|
7269
|
+
"attempt-pending",
|
|
7270
|
+
"conflict",
|
|
7271
|
+
"unavailable"
|
|
7272
|
+
];
|
|
7273
|
+
async function submitQuestTransaction(client, input, deadline, retried = passingRefusals) {
|
|
7274
|
+
for (; ; ) {
|
|
7275
|
+
try {
|
|
7276
|
+
return {
|
|
7277
|
+
attempt: await client.attempts.submitSolanaTransaction(input, {
|
|
7278
|
+
timeout: Math.max(deadline - Date.now(), 5e3)
|
|
7279
|
+
})
|
|
7280
|
+
};
|
|
7281
|
+
} catch (error) {
|
|
7282
|
+
if (!isManagementError(error) || error.status === void 0 || !error.code || !retried.includes(error.code)) {
|
|
7283
|
+
throw error;
|
|
7284
|
+
}
|
|
7285
|
+
const pause = Math.min(Math.max(error.retryAfter ?? 2e3, 500), 5e3);
|
|
7286
|
+
if (deadline - Date.now() <= pause) {
|
|
7287
|
+
return { waiting: error };
|
|
7288
|
+
}
|
|
7289
|
+
await wait(pause);
|
|
7290
|
+
}
|
|
7291
|
+
}
|
|
7292
|
+
}
|
|
7293
|
+
async function complete(chain, client, card, options, request, confirmTimeout, body) {
|
|
7294
|
+
const signature = solanaSignatureSchema.safeParse(
|
|
7295
|
+
body.signature ?? new URL(request.url).searchParams.get("signature")
|
|
7296
|
+
);
|
|
7297
|
+
if (!signature.success) {
|
|
7298
|
+
return failure(chain, "Send the transaction's signature", 400);
|
|
7299
|
+
}
|
|
7300
|
+
const shown = actionCard(card, options.metadata, request);
|
|
7301
|
+
const done = (label, description) => ({
|
|
7302
|
+
type: "completed",
|
|
7303
|
+
icon: shown.icon,
|
|
7304
|
+
title: shown.title,
|
|
7305
|
+
label,
|
|
7306
|
+
description
|
|
7307
|
+
});
|
|
7308
|
+
const deadline = Date.now() + confirmTimeout;
|
|
7309
|
+
const left = () => deadline - Date.now();
|
|
7310
|
+
const later = done(
|
|
7311
|
+
"Confirming on Solana",
|
|
7312
|
+
"Confirming on Solana: check the quest in the app in a minute."
|
|
7313
|
+
);
|
|
7314
|
+
let attempt;
|
|
7315
|
+
try {
|
|
7316
|
+
const submitted = await submitQuestTransaction(
|
|
7317
|
+
client,
|
|
7318
|
+
{ quest: card.id, signature: signature.data, chain },
|
|
7319
|
+
deadline
|
|
7320
|
+
);
|
|
7321
|
+
if ("waiting" in submitted) {
|
|
7322
|
+
return json2(
|
|
7323
|
+
chain,
|
|
7324
|
+
submitted.waiting.code === "transaction-not-final" ? later : submitted.waiting.code === "attempt-pending" ? done(
|
|
7325
|
+
"Still checking",
|
|
7326
|
+
"Your previous try on this quest is still being checked: check the quest in the app in a minute."
|
|
7327
|
+
) : done("Try again", "Domino is busy. Try again in a minute.")
|
|
7328
|
+
);
|
|
7329
|
+
}
|
|
7330
|
+
attempt = submitted.attempt;
|
|
7331
|
+
} catch (error) {
|
|
7332
|
+
if (!isManagementError(error) || error.status === void 0) {
|
|
7333
|
+
throw error;
|
|
7334
|
+
}
|
|
7335
|
+
if (error.code === "wallet-not-linked") {
|
|
7336
|
+
return json2(chain, {
|
|
7337
|
+
...shown,
|
|
7338
|
+
label: "Link your wallet",
|
|
7339
|
+
description: "This wallet is not linked to a member yet. Link it in the app, then check again.",
|
|
7340
|
+
disabled: false,
|
|
7341
|
+
error: { message: "Wallet not linked" },
|
|
7342
|
+
links: {
|
|
7343
|
+
actions: [
|
|
7344
|
+
{
|
|
7345
|
+
type: "external-link",
|
|
7346
|
+
href: stepHref(request, "link"),
|
|
7347
|
+
label: "Link your wallet"
|
|
7348
|
+
},
|
|
7349
|
+
{
|
|
7350
|
+
type: "post",
|
|
7351
|
+
href: stepHref(request, "recheck", {
|
|
7352
|
+
signature: signature.data
|
|
7353
|
+
}),
|
|
7354
|
+
label: "Check again"
|
|
7355
|
+
}
|
|
7356
|
+
]
|
|
7357
|
+
}
|
|
7358
|
+
});
|
|
7359
|
+
}
|
|
7360
|
+
if (error.status >= 400 && error.status < 500) {
|
|
7361
|
+
return json2(chain, done("Not completed", error.message));
|
|
7362
|
+
}
|
|
7363
|
+
throw error;
|
|
7364
|
+
}
|
|
7365
|
+
for (; ; ) {
|
|
7366
|
+
switch (attempt.status) {
|
|
7367
|
+
case "accepted": {
|
|
7368
|
+
const managed = await client.attempts.get(attempt.id);
|
|
7369
|
+
const rewards = managed.attempt.reviewRewards ?? managed.release?.rewards ?? [];
|
|
7370
|
+
const points3 = rewards.reduce(
|
|
7371
|
+
(sum, reward) => sum + (reward.kind === "points" ? reward.amount : 0),
|
|
7372
|
+
0
|
|
7373
|
+
);
|
|
7374
|
+
return json2(
|
|
7375
|
+
chain,
|
|
7376
|
+
done(
|
|
7377
|
+
points3 ? `+${points3} points` : "Quest complete",
|
|
7378
|
+
`You completed "${card.title}".`
|
|
7379
|
+
)
|
|
7380
|
+
);
|
|
7381
|
+
}
|
|
7382
|
+
case "rejected":
|
|
7383
|
+
return json2(
|
|
7384
|
+
chain,
|
|
7385
|
+
done(
|
|
7386
|
+
"Not completed",
|
|
7387
|
+
attempt.reason ?? "The quest's check did not pass."
|
|
7388
|
+
)
|
|
7389
|
+
);
|
|
7390
|
+
case "progressed":
|
|
7391
|
+
return json2(
|
|
7392
|
+
chain,
|
|
7393
|
+
done("Progress saved", attempt.reason ?? "Your progress is saved.")
|
|
7394
|
+
);
|
|
7395
|
+
case "needs-review":
|
|
7396
|
+
return json2(
|
|
7397
|
+
chain,
|
|
7398
|
+
done(
|
|
7399
|
+
"Submitted for review",
|
|
7400
|
+
"A reviewer checks it: see the quest in the app."
|
|
7401
|
+
)
|
|
7402
|
+
);
|
|
7403
|
+
case "failed":
|
|
7404
|
+
return json2(
|
|
7405
|
+
chain,
|
|
7406
|
+
done(
|
|
7407
|
+
"Couldn't check",
|
|
7408
|
+
attempt.reason ?? "Domino could not check the quest. Try it in the app."
|
|
7409
|
+
)
|
|
7410
|
+
);
|
|
7411
|
+
}
|
|
7412
|
+
if (left() <= pollInterval) {
|
|
7413
|
+
return json2(
|
|
7414
|
+
chain,
|
|
7415
|
+
done("Submitted", "Submitted: check the quest in the app in a minute.")
|
|
7416
|
+
);
|
|
7417
|
+
}
|
|
7418
|
+
await wait(pollInterval);
|
|
7419
|
+
attempt = (await client.attempts.get(attempt.id)).attempt;
|
|
7420
|
+
}
|
|
7421
|
+
}
|
|
7422
|
+
function actionsJson(rules = [
|
|
7423
|
+
{ pathPattern: "/api/actions/**", apiPath: "/api/actions/**" }
|
|
7424
|
+
], chain = "solana") {
|
|
7425
|
+
const network = solanaTransactionSubmissionSchema.shape.chain.parse(chain);
|
|
7426
|
+
return async (request) => request.method === "OPTIONS" ? new Response(null, {
|
|
7427
|
+
status: 204,
|
|
7428
|
+
headers: solanaActionHeaders(network)
|
|
7429
|
+
}) : request.method === "GET" || request.method === "HEAD" ? json2(network, { rules }) : failure(network, `${request.method} is not allowed`, 405);
|
|
7430
|
+
}
|
|
7431
|
+
|
|
7432
|
+
// src/server/station-actions.ts
|
|
7433
|
+
var systemProgram = "11111111111111111111111111111111";
|
|
7434
|
+
var zeroTransfer = /* @__PURE__ */ (() => Uint8Array.of(2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))();
|
|
7435
|
+
var defaultFindTimeout = 9e4;
|
|
7436
|
+
var findInterval = 2e3;
|
|
7437
|
+
var submitTimeout = 6e4;
|
|
7438
|
+
var workerBudget = 28e3;
|
|
7439
|
+
function defineStationAction(options) {
|
|
7440
|
+
const chain = solanaTransactionSubmissionSchema.shape.chain.parse(options.chain);
|
|
7441
|
+
const findTimeout = options.findTimeout ?? defaultFindTimeout;
|
|
7442
|
+
const { clientFor, cardFor } = questActionContext(options);
|
|
7443
|
+
return async function stationAction(request, env, context) {
|
|
7444
|
+
if (request.method === "OPTIONS") {
|
|
7445
|
+
return new Response(null, {
|
|
7446
|
+
status: 204,
|
|
7447
|
+
headers: solanaActionHeaders(chain)
|
|
7448
|
+
});
|
|
7449
|
+
}
|
|
7450
|
+
if (request.method !== "GET" && request.method !== "POST") {
|
|
7451
|
+
return failure(
|
|
7452
|
+
chain,
|
|
7453
|
+
`${request.method} is not a transaction request method`,
|
|
7454
|
+
405
|
|
7455
|
+
);
|
|
7456
|
+
}
|
|
7457
|
+
try {
|
|
7458
|
+
const client = clientFor(env);
|
|
7459
|
+
const card = await cardFor(client, request);
|
|
7460
|
+
const station = openStation(card, request);
|
|
7461
|
+
if (request.method === "GET") {
|
|
7462
|
+
return json2(chain, {
|
|
7463
|
+
label: options.label ?? card.title,
|
|
7464
|
+
icon: questIcon(card, options.icon, request, "the icon option")
|
|
7465
|
+
});
|
|
7466
|
+
}
|
|
7467
|
+
const body = await readBody(request);
|
|
7468
|
+
if (!body) {
|
|
7469
|
+
return failure(chain, "Send a JSON body of at most 16 KB", 400);
|
|
7470
|
+
}
|
|
7471
|
+
const account2 = memberAccount(body);
|
|
7472
|
+
if (card.closed) {
|
|
7473
|
+
return failure(chain, card.closed, 422);
|
|
7474
|
+
}
|
|
7475
|
+
const memo = questMemo(card, station.key);
|
|
7476
|
+
const own = await options.instructions?.({
|
|
7477
|
+
account: account2,
|
|
7478
|
+
station,
|
|
7479
|
+
quest: { id: card.id, key: card.key, title: card.title },
|
|
7480
|
+
request
|
|
7481
|
+
}) ?? [];
|
|
7482
|
+
const { value } = await solanaRpc(
|
|
7483
|
+
options.rpcUrl,
|
|
7484
|
+
"getLatestBlockhash",
|
|
7485
|
+
[{ commitment: "confirmed" }]
|
|
7486
|
+
);
|
|
7487
|
+
const reference = base58(crypto.getRandomValues(new Uint8Array(32)));
|
|
7488
|
+
const message = {
|
|
7489
|
+
// Legacy, which every wallet that takes transaction requests reads.
|
|
7490
|
+
version: "legacy",
|
|
7491
|
+
feePayer: { address: account2 },
|
|
7492
|
+
lifetimeConstraint: { blockhash: value.blockhash },
|
|
7493
|
+
instructions: [...own, referenceTransfer(account2, reference)]
|
|
7494
|
+
};
|
|
7495
|
+
const transaction2 = withQuestMemo(message, memo);
|
|
7496
|
+
const worker = !options.waitUntil && context?.waitUntil !== void 0;
|
|
7497
|
+
const now = Date.now();
|
|
7498
|
+
const task = findAndSubmit(client, card, chain, {
|
|
7499
|
+
rpcUrl: options.rpcUrl,
|
|
7500
|
+
reference,
|
|
7501
|
+
deadline: now + findTimeout,
|
|
7502
|
+
stopAt: worker ? now + workerBudget : Infinity
|
|
7503
|
+
});
|
|
7504
|
+
const keep = options.waitUntil ?? context?.waitUntil?.bind(context);
|
|
7505
|
+
keep?.(task);
|
|
7506
|
+
return json2(chain, {
|
|
7507
|
+
transaction: transaction2,
|
|
7508
|
+
message: `Checks you in at ${station.label} for "${card.title}". Wallet not linked yet? Sign in at ${new URL(options.linkUrl, request.url).href} first.`
|
|
7509
|
+
});
|
|
7510
|
+
} catch (error) {
|
|
7511
|
+
return questActionError(chain, error);
|
|
7512
|
+
}
|
|
7513
|
+
};
|
|
7514
|
+
}
|
|
7515
|
+
function openStation(card, request) {
|
|
7516
|
+
const key2 = new URL(request.url).searchParams.get("station");
|
|
7517
|
+
if (!card.stations) {
|
|
7518
|
+
throw new QuestActionRefusal(
|
|
7519
|
+
`"${card.title}" has no check-in stations`,
|
|
7520
|
+
422
|
|
7521
|
+
);
|
|
7522
|
+
}
|
|
7523
|
+
if (!key2) {
|
|
7524
|
+
throw new QuestActionRefusal(
|
|
7525
|
+
"Name the station in the URL, as ?station=<key>",
|
|
7526
|
+
400
|
|
7527
|
+
);
|
|
7528
|
+
}
|
|
7529
|
+
const refusal = stationRefusal(card.stations, key2, Date.now());
|
|
7530
|
+
if (refusal?.code === "station-unknown") {
|
|
7531
|
+
throw new QuestActionRefusal(`"${card.title}" has no station "${key2}"`, 404);
|
|
7532
|
+
}
|
|
7533
|
+
const station = card.stations.find((item) => item.key === key2);
|
|
7534
|
+
if (refusal) {
|
|
7535
|
+
throw new QuestActionRefusal(`${station.label} is closed`, 409);
|
|
7536
|
+
}
|
|
7537
|
+
if (card.revoked.has(station.key)) {
|
|
7538
|
+
throw new QuestActionRefusal(
|
|
7539
|
+
`${station.label} no longer takes check-ins`,
|
|
7540
|
+
409
|
|
7541
|
+
);
|
|
7542
|
+
}
|
|
7543
|
+
return station;
|
|
7544
|
+
}
|
|
7545
|
+
function referenceTransfer(account2, reference) {
|
|
7546
|
+
return {
|
|
7547
|
+
programAddress: systemProgram,
|
|
7548
|
+
accounts: [
|
|
7549
|
+
{ address: account2, role: 3 },
|
|
7550
|
+
{ address: account2, role: 1 },
|
|
7551
|
+
{ address: reference, role: 0 }
|
|
7552
|
+
],
|
|
7553
|
+
data: zeroTransfer
|
|
7554
|
+
};
|
|
7555
|
+
}
|
|
7556
|
+
async function findAndSubmit(client, card, chain, find) {
|
|
7557
|
+
const deadline = Math.min(find.deadline, find.stopAt);
|
|
7558
|
+
let found;
|
|
7559
|
+
let lastError;
|
|
7560
|
+
try {
|
|
7561
|
+
while (!found && Date.now() < deadline) {
|
|
7562
|
+
try {
|
|
7563
|
+
;
|
|
7564
|
+
[found] = await solanaRpc(
|
|
7565
|
+
find.rpcUrl,
|
|
7566
|
+
"getSignaturesForAddress",
|
|
7567
|
+
[find.reference, { commitment: "confirmed", limit: 1 }]
|
|
7568
|
+
);
|
|
7569
|
+
} catch (error) {
|
|
7570
|
+
lastError = error;
|
|
7571
|
+
}
|
|
7572
|
+
if (!found) {
|
|
7573
|
+
await wait(Math.min(findInterval, deadline - Date.now()));
|
|
7574
|
+
}
|
|
7575
|
+
}
|
|
7576
|
+
if (!found) {
|
|
7577
|
+
if (lastError) {
|
|
7578
|
+
console.error(
|
|
7579
|
+
"Station check-in: the reference lookup failed",
|
|
7580
|
+
lastError
|
|
7581
|
+
);
|
|
7582
|
+
}
|
|
7583
|
+
return;
|
|
7584
|
+
}
|
|
7585
|
+
if (found.err) {
|
|
7586
|
+
console.error(
|
|
7587
|
+
`Station check-in: transaction ${found.signature} failed on chain`,
|
|
7588
|
+
found.err
|
|
7589
|
+
);
|
|
7590
|
+
return;
|
|
7591
|
+
}
|
|
7592
|
+
const submitted = await submitQuestTransaction(
|
|
7593
|
+
client,
|
|
7594
|
+
{ quest: card.id, signature: found.signature, chain },
|
|
7595
|
+
Math.min(Date.now() + submitTimeout, find.stopAt),
|
|
7596
|
+
passingRefusals
|
|
7597
|
+
);
|
|
7598
|
+
if ("waiting" in submitted) {
|
|
7599
|
+
console.error(
|
|
7600
|
+
`Station check-in: Domino did not take transaction ${found.signature} in time`,
|
|
7601
|
+
submitted.waiting
|
|
7602
|
+
);
|
|
7603
|
+
}
|
|
7604
|
+
} catch (error) {
|
|
7605
|
+
console.error(
|
|
7606
|
+
`Station check-in: submitting ${found?.signature ?? "the transaction"} failed`,
|
|
7607
|
+
error
|
|
7608
|
+
);
|
|
7609
|
+
}
|
|
7610
|
+
}
|
|
7611
|
+
|
|
7612
|
+
// src/server/development.ts
|
|
7613
|
+
import * as z61 from "zod";
|
|
7614
|
+
var developmentPreflightSchema = /* @__PURE__ */ (() => z61.object({
|
|
7615
|
+
organization: z61.string(),
|
|
7616
|
+
project: z61.string(),
|
|
7617
|
+
environment: z61.enum(["test", "live"]),
|
|
7618
|
+
identity: z61.object({
|
|
7619
|
+
exchange: z61.literal("supported"),
|
|
7620
|
+
activeIntegrations: z61.number().int().nonnegative()
|
|
7621
|
+
}).optional(),
|
|
7622
|
+
staging: z61.enum(["configured", "blocked"]),
|
|
7623
|
+
development: z61.object({
|
|
7624
|
+
status: z61.enum(["configured", "blocked"]),
|
|
7625
|
+
// How `domino dev` reaches the preview origin: a Cloudflare tunnel, or a direct route on a
|
|
7626
|
+
// local development stack. APIs that predate the field use tunnels.
|
|
7627
|
+
transport: z61.enum(["tunnel", "direct"]).default("tunnel"),
|
|
7628
|
+
missing: z61.array(z61.string()),
|
|
7629
|
+
authentication: z61.array(z61.string())
|
|
7630
|
+
}),
|
|
7631
|
+
checks: z61.array(
|
|
7632
|
+
z61.object({
|
|
7633
|
+
id: z61.string(),
|
|
7634
|
+
status: z61.enum(["ok", "error"]),
|
|
7635
|
+
message: z61.string(),
|
|
7636
|
+
missing: z61.array(z61.string()).optional(),
|
|
7637
|
+
issues: z61.array(z61.string()).optional()
|
|
7638
|
+
})
|
|
7639
|
+
)
|
|
7640
|
+
}))();
|
|
7641
|
+
|
|
6524
7642
|
// src/server/index.ts
|
|
6525
7643
|
function clientFailure(error) {
|
|
6526
7644
|
if (error instanceof ManagementError) {
|
|
@@ -6535,8 +7653,8 @@ function clientFailure(error) {
|
|
|
6535
7653
|
}
|
|
6536
7654
|
function guarded(api) {
|
|
6537
7655
|
return Object.fromEntries(
|
|
6538
|
-
Object.entries(api).map(([
|
|
6539
|
-
|
|
7656
|
+
Object.entries(api).map(([key2, value]) => [
|
|
7657
|
+
key2,
|
|
6540
7658
|
typeof value === "function" ? (...args) => {
|
|
6541
7659
|
try {
|
|
6542
7660
|
return Promise.resolve(value(...args)).catch((error) => {
|
|
@@ -6832,6 +7950,8 @@ function managementClient(options) {
|
|
|
6832
7950
|
quests: questsApi(http),
|
|
6833
7951
|
/** Public X data the project's configuration refers to by ID. */
|
|
6834
7952
|
x: xApi(http),
|
|
7953
|
+
/** Solana reads for quest development. */
|
|
7954
|
+
solana: solanaApi(http),
|
|
6835
7955
|
/**
|
|
6836
7956
|
* This project and environment's Discord connection. An organization administrator installs
|
|
6837
7957
|
* Domino's bot into a new server in Console; once one project of the organization connects a
|
|
@@ -6917,6 +8037,8 @@ var managementResponseTables = /* @__PURE__ */ (() => responseTables({
|
|
|
6917
8037
|
collectionPreviewSchema: () => collectionPreviewSchema,
|
|
6918
8038
|
completionRevocationSchema: () => completionRevocationSchema,
|
|
6919
8039
|
completionRestorationSchema: () => completionRestorationSchema,
|
|
8040
|
+
completionReceiptSchema: () => completionReceiptSchema,
|
|
8041
|
+
completionReceiptListSchema: () => completionReceiptListSchema,
|
|
6920
8042
|
connectionPageSchema: () => connectionPageSchema,
|
|
6921
8043
|
connectionSchema: () => connectionSchema,
|
|
6922
8044
|
connectionAuthorizationSchema: () => connectionAuthorizationSchema,
|
|
@@ -6967,6 +8089,7 @@ var managementResponseTables = /* @__PURE__ */ (() => responseTables({
|
|
|
6967
8089
|
managedMemberIdentitySchema: () => managedMemberIdentitySchema,
|
|
6968
8090
|
managedMemberPageSchema: () => managedMemberPageSchema,
|
|
6969
8091
|
managedMemberProgressSchema: () => managedMemberProgressSchema,
|
|
8092
|
+
memberCompletionPageSchema: () => memberCompletionPageSchema,
|
|
6970
8093
|
memberConsentHistorySchema: () => memberConsentHistorySchema,
|
|
6971
8094
|
memberConsentListSchema: () => memberConsentListSchema,
|
|
6972
8095
|
memberImportPageSchema: () => memberImportPageSchema,
|
|
@@ -7047,6 +8170,7 @@ var managementResponseTables = /* @__PURE__ */ (() => responseTables({
|
|
|
7047
8170
|
trackerSummarySchema: () => trackerSummarySchema,
|
|
7048
8171
|
trackerTriggerOutcomePageSchema: () => trackerTriggerOutcomePageSchema,
|
|
7049
8172
|
walletBalanceChainsSchema: () => walletBalanceChainsSchema,
|
|
8173
|
+
walletTransactionsSchema: () => walletTransactionsSchema,
|
|
7050
8174
|
webhookDeliveryPageSchema: () => webhookDeliveryPageSchema,
|
|
7051
8175
|
webhookDeliverySchema: () => webhookDeliverySchema,
|
|
7052
8176
|
webhookEndpointSchema: () => webhookEndpointSchema,
|
|
@@ -7077,6 +8201,7 @@ export {
|
|
|
7077
8201
|
MemberImportRefusalCode,
|
|
7078
8202
|
MemberImportState,
|
|
7079
8203
|
PayoutSourceKind,
|
|
8204
|
+
QuestActionRefusal,
|
|
7080
8205
|
REFERRAL_INTEGRATION_REWARD_ERROR2 as REFERRAL_INTEGRATION_REWARD_ERROR,
|
|
7081
8206
|
RestoredDeliveryOutcome,
|
|
7082
8207
|
RestoredEntitlementOutcome,
|
|
@@ -7091,6 +8216,7 @@ export {
|
|
|
7091
8216
|
accessSchema,
|
|
7092
8217
|
accountProfileSchema,
|
|
7093
8218
|
accountVouchedBySchema,
|
|
8219
|
+
actionsJson,
|
|
7094
8220
|
activeMemberMonthSchema,
|
|
7095
8221
|
activeMemberUsageSchema,
|
|
7096
8222
|
activityTypeSchema,
|
|
@@ -7169,6 +8295,9 @@ export {
|
|
|
7169
8295
|
capturedFactSchema,
|
|
7170
8296
|
commitSchema,
|
|
7171
8297
|
compareAppMigrations,
|
|
8298
|
+
completionReceiptInputSchema,
|
|
8299
|
+
completionReceiptListSchema,
|
|
8300
|
+
completionReceiptSchema,
|
|
7172
8301
|
completionRestorationSchema,
|
|
7173
8302
|
completionRestoreSchema,
|
|
7174
8303
|
completionRevocationSchema,
|
|
@@ -7208,6 +8337,9 @@ export {
|
|
|
7208
8337
|
dashboardReadQuerySchema,
|
|
7209
8338
|
dashboardReadSchema,
|
|
7210
8339
|
dashboardSummarySchema,
|
|
8340
|
+
decodeSolanaTransaction,
|
|
8341
|
+
defineQuestAction,
|
|
8342
|
+
defineStationAction,
|
|
7211
8343
|
deploymentActionSchema,
|
|
7212
8344
|
deploymentRejectionSchema,
|
|
7213
8345
|
developmentPreflightSchema,
|
|
@@ -7308,6 +8440,9 @@ export {
|
|
|
7308
8440
|
managementResponseSchemas,
|
|
7309
8441
|
managementResponses,
|
|
7310
8442
|
managementStateQuerySchema,
|
|
8443
|
+
maxCompletionReceipts,
|
|
8444
|
+
maxSolanaActionReference,
|
|
8445
|
+
maxSolanaTransactionBytes,
|
|
7311
8446
|
memberAccountSchema,
|
|
7312
8447
|
memberAccountUnlinkInputSchema,
|
|
7313
8448
|
memberAppIdentitySchema,
|
|
@@ -7317,6 +8452,9 @@ export {
|
|
|
7317
8452
|
memberBanPreviewSchema,
|
|
7318
8453
|
memberBanRollbackSchema,
|
|
7319
8454
|
memberBanSchema,
|
|
8455
|
+
memberCompletionPageSchema,
|
|
8456
|
+
memberCompletionQuerySchema,
|
|
8457
|
+
memberCompletionSchema,
|
|
7320
8458
|
memberCreatorAccountUnlinkInputSchema,
|
|
7321
8459
|
memberDetailSchema,
|
|
7322
8460
|
memberErasureDeletedSchema,
|
|
@@ -7376,6 +8514,7 @@ export {
|
|
|
7376
8514
|
pageSchema,
|
|
7377
8515
|
parseImageExtraction,
|
|
7378
8516
|
parseImageResult,
|
|
8517
|
+
parseSolanaActionMemo,
|
|
7379
8518
|
participantExchangeAccountResultSchema,
|
|
7380
8519
|
participantExchangeResultSchema,
|
|
7381
8520
|
participantExchangeSchema,
|
|
@@ -7421,6 +8560,7 @@ export {
|
|
|
7421
8560
|
questEnrollmentWithdrawalInputSchema,
|
|
7422
8561
|
questLifecycleInputSchema,
|
|
7423
8562
|
questLifecycleSchema,
|
|
8563
|
+
questStationStateSchema,
|
|
7424
8564
|
readinessSchema,
|
|
7425
8565
|
realPeopleInTestUsageSchema,
|
|
7426
8566
|
referralManagementSchema,
|
|
@@ -7445,8 +8585,23 @@ export {
|
|
|
7445
8585
|
serviceKeySchema,
|
|
7446
8586
|
settlementPayoutCsv,
|
|
7447
8587
|
shortensEvidenceRetention,
|
|
8588
|
+
solanaActionHeaders,
|
|
8589
|
+
solanaActionMemo,
|
|
8590
|
+
solanaActionVersion,
|
|
8591
|
+
solanaMemoProgram,
|
|
8592
|
+
solanaPayoutConfirmationResultSchema,
|
|
8593
|
+
solanaPayoutConfirmationSchema,
|
|
8594
|
+
solanaPayoutInputSchema,
|
|
8595
|
+
solanaPayoutMintSchema,
|
|
8596
|
+
solanaPayoutPageSchema,
|
|
8597
|
+
solanaPayoutQuerySchema,
|
|
8598
|
+
solanaPayoutSchema,
|
|
8599
|
+
solanaPayoutSquadsSchema,
|
|
8600
|
+
solanaSignatureSchema,
|
|
8601
|
+
solanaTransactionSubmissionSchema,
|
|
7448
8602
|
sourceDataSchema2 as sourceDataSchema,
|
|
7449
8603
|
sourceRoles,
|
|
8604
|
+
squadsProposalUrl,
|
|
7450
8605
|
stageRequestSchema,
|
|
7451
8606
|
stagedDeploymentContentSchema,
|
|
7452
8607
|
stagedDeploymentKey,
|
|
@@ -7460,8 +8615,12 @@ export {
|
|
|
7460
8615
|
starterIdSchema,
|
|
7461
8616
|
starterTemplates,
|
|
7462
8617
|
starters,
|
|
8618
|
+
stationOperationTarget,
|
|
8619
|
+
stationRevocationInputSchema,
|
|
8620
|
+
stationRevocationSchema,
|
|
7463
8621
|
stockAdditionSchema,
|
|
7464
8622
|
stockInputSchema,
|
|
8623
|
+
takesSolanaTransaction,
|
|
7465
8624
|
teamSchema,
|
|
7466
8625
|
telegramBotIdSchema,
|
|
7467
8626
|
telegramIdentitySelectorSchema,
|
|
@@ -7508,6 +8667,7 @@ export {
|
|
|
7508
8667
|
verifyWebhook,
|
|
7509
8668
|
walletBalanceChainsSchema,
|
|
7510
8669
|
walletIdentitySelectorSchema,
|
|
8670
|
+
walletLinkedEventDataSchema,
|
|
7511
8671
|
webhookControlInputSchema,
|
|
7512
8672
|
webhookCreateInputSchema,
|
|
7513
8673
|
webhookDeleteInputSchema,
|