@domino-sdk/relay 1.63.0 → 1.65.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/{accounts-nz3mzfRQ.d.ts → accounts-_lNsiR2k.d.ts} +22 -2
  3. package/dist/{attempt-captures-DMi8oR9T.d.ts → attempt-captures-BqPggxTU.d.ts} +1 -1
  4. package/dist/authoring.d.ts +11 -11
  5. package/dist/authoring.js +15 -20
  6. package/dist/{automatic-outcomes-C_LLQU1p.d.ts → automatic-outcomes-BzAvfcpd.d.ts} +2 -2
  7. package/dist/browser.d.ts +9 -9
  8. package/dist/browser.js +11 -14
  9. package/dist/{catalog-BaTOKpNw.d.ts → catalog-ByZMRS7I.d.ts} +1 -1
  10. package/dist/{chunk-VWQGWGCH.js → chunk-4NIV4NPV.js} +1 -1
  11. package/dist/{chunk-ICXZZNPS.js → chunk-7H4MRVQF.js} +1 -1
  12. package/dist/{chunk-NQDEWJWE.js → chunk-CVQZ2YP7.js} +6 -232
  13. package/dist/{chunk-3RFP6GT5.js → chunk-DLABJSBO.js} +2 -2
  14. package/dist/{chunk-AQOL3SK5.js → chunk-E22XSC4L.js} +1 -1
  15. package/dist/{chunk-N4LNEGQX.js → chunk-EDNKKVGU.js} +2 -2
  16. package/dist/{chunk-GLH6MEI2.js → chunk-EOUEAOWJ.js} +28 -2
  17. package/dist/{chunk-MTKRIQEU.js → chunk-EUEW2APU.js} +1 -1
  18. package/dist/{chunk-ID3BZXFZ.js → chunk-HNR6G3GV.js} +1939 -1211
  19. package/dist/{chunk-5XLZ34PV.js → chunk-KCUUHT2V.js} +3 -3
  20. package/dist/{chunk-EHUSD3O2.js → chunk-MPTE7EIV.js} +2 -4
  21. package/dist/{chunk-QR6HH4DI.js → chunk-NG4GZ54I.js} +4 -4
  22. package/dist/chunk-R2KZFX6E.js +405 -0
  23. package/dist/{chunk-4GQW43UU.js → chunk-RD3XJ4DH.js} +26 -30
  24. package/dist/{chunk-7Z4SZ6YM.js → chunk-SE7XHQFP.js} +1 -1
  25. package/dist/{chunk-LZWXCBUB.js → chunk-VBYOAT46.js} +41 -45
  26. package/dist/{chunk-7X67QLPB.js → chunk-XVZ4YOF2.js} +1 -1
  27. package/dist/{chunk-FU5CGNTR.js → chunk-ZQ3IPCI6.js} +44 -5
  28. package/dist/chunk-ZXGBDLVB.js +1510 -0
  29. package/dist/{client-DHmG7rn6.d.ts → client-D7IiwEq2.d.ts} +12 -7
  30. package/dist/{dashboards-CLemT6kj.d.ts → dashboards-pVfclkyh.d.ts} +2 -2
  31. package/dist/{deployments-DTULi7dF.d.ts → deployments-Cr1tfqrr.d.ts} +2 -2
  32. package/dist/{identity-integration-DOeNZaxF.d.ts → identity-integration-Ci2vGKtX.d.ts} +37 -2
  33. package/dist/index.d.ts +10 -10
  34. package/dist/index.js +11 -15
  35. package/dist/internal.d.ts +12 -12
  36. package/dist/internal.js +21 -16
  37. package/dist/{limits-kNzYdZ00.d.ts → limits-pE04y9O2.d.ts} +8 -1
  38. package/dist/{offers-CYeN_I0Y.d.ts → offers-Hw2P6tcK.d.ts} +2 -2
  39. package/dist/{participant-activity-D-Drp24G.d.ts → participant-activity-DXRq4s6K.d.ts} +1 -0
  40. package/dist/portal-proxy.d.ts +4 -2
  41. package/dist/portal-proxy.js +13 -5
  42. package/dist/react/index.d.ts +20 -13
  43. package/dist/react/index.js +11 -14
  44. package/dist/{reward-deliveries-drp-x1G-.d.ts → reward-deliveries-BCV8hznc.d.ts} +1 -1
  45. package/dist/runtime/authoring.js +1 -1
  46. package/dist/runtime/chunks/6EBN6IZU.js +1 -0
  47. package/dist/runtime/manifest.json +3 -3
  48. package/dist/runtime/schema.js +1 -1
  49. package/dist/schema.d.ts +19 -16
  50. package/dist/schema.js +109 -112
  51. package/dist/server/index.d.ts +11 -11
  52. package/dist/server/index.js +775 -1037
  53. package/dist/{sign-in-providers-B1Q9eDRm.d.ts → sign-in-providers-BAkGjSXo.d.ts} +2 -2
  54. package/dist/{submission-input-DZCbjQUH.d.ts → submission-input-ChL1aYNH.d.ts} +2 -2
  55. package/dist/{telegram-browser-NL0Asmsi.d.ts → telegram-browser-K27t4TwM.d.ts} +4 -4
  56. package/dist/telegram.d.ts +8 -8
  57. package/dist/telegram.js +2 -2
  58. package/dist/testing.d.ts +10 -10
  59. package/dist/testing.js +19 -23
  60. package/dist/{tracker-data-esm3WG8R.d.ts → tracker-data-Bl-qPIvZ.d.ts} +3 -1
  61. package/dist/{transport-Czht_irp.d.ts → transport-DC1m73Tp.d.ts} +1065 -14
  62. package/package.json +1 -1
  63. package/dist/chunk-4NOFSGAL.js +0 -320
  64. package/dist/chunk-FO2LCZTL.js +0 -19
  65. package/dist/chunk-KP2MCX3R.js +0 -587
  66. package/dist/chunk-N4BDKS6Y.js +0 -87
  67. package/dist/chunk-TLSQETTY.js +0 -41
  68. package/dist/chunk-W7YSMSGC.js +0 -725
  69. package/dist/runtime/chunks/UGDV5W4N.js +0 -1
@@ -0,0 +1,1510 @@
1
+ import {
2
+ imageAssetArtifactSchema
3
+ } from "./chunk-XVZ4YOF2.js";
4
+ import {
5
+ authScopeSchema,
6
+ exchangeResultSchema
7
+ } from "./chunk-R2KZFX6E.js";
8
+ import {
9
+ appIdentityKindSchema,
10
+ cosmosAddressSchema,
11
+ cosmosNetworkSchema,
12
+ evmAddressSchema,
13
+ identifier,
14
+ lifecycleReasonSchema,
15
+ limits,
16
+ offsetDateTimeSchema,
17
+ openIdentityKindSchema,
18
+ pageCursorSchema,
19
+ solanaAddressSchema
20
+ } from "./chunk-HNR6G3GV.js";
21
+
22
+ // src/credential-secrets.ts
23
+ import * as z from "zod";
24
+ var credentialSecretSchema = /* @__PURE__ */ (() => z.object({
25
+ id: z.string().uuid(),
26
+ /** The secret's last four characters, to tell secrets apart; null for one issued before hints. */
27
+ hint: z.string().nullable(),
28
+ createdAt: z.number(),
29
+ /** When the secret stops working; null when it never expires. */
30
+ expiresAt: z.number().nullable(),
31
+ /** When the secret last authenticated a request; null when it never has. */
32
+ lastUsedAt: z.number().nullable()
33
+ }))();
34
+ var credentialSecretInputSchema = /* @__PURE__ */ (() => z.object({
35
+ expiresInDays: z.number().int().min(1).max(3650).optional()
36
+ }).strict())();
37
+
38
+ // src/server/member-imports.ts
39
+ import * as z2 from "zod";
40
+ var importTimeSchema = /* @__PURE__ */ (() => z2.union([
41
+ z2.number().int().nonnegative().safe(),
42
+ offsetDateTimeSchema().transform((value) => Date.parse(value))
43
+ ]))();
44
+ var importWalletSchema = /* @__PURE__ */ (() => z2.discriminatedUnion("chain", [
45
+ z2.object({
46
+ kind: z2.literal("wallet"),
47
+ chain: z2.literal("solana"),
48
+ address: solanaAddressSchema
49
+ }).strict(),
50
+ z2.object({
51
+ kind: z2.literal("wallet"),
52
+ chain: z2.literal("eip155"),
53
+ address: evmAddressSchema
54
+ }).strict(),
55
+ z2.object({
56
+ kind: z2.literal("wallet"),
57
+ chain: z2.literal("cosmos"),
58
+ network: cosmosNetworkSchema,
59
+ address: cosmosAddressSchema
60
+ }).strict()
61
+ ]))();
62
+ var importXSchema = /* @__PURE__ */ (() => z2.object({
63
+ kind: z2.literal("x"),
64
+ subject: z2.string().regex(/^[1-9][0-9]{0,19}$/, "Use the numeric X user ID")
65
+ }).strict())();
66
+ var importTelegramSchema = /* @__PURE__ */ (() => z2.object({
67
+ kind: z2.literal("telegram"),
68
+ subject: z2.string().regex(/^[1-9][0-9]{0,19}$/, "Use the numeric Telegram user ID")
69
+ }).strict())();
70
+ var importDiscordSchema = /* @__PURE__ */ (() => z2.object({
71
+ kind: z2.literal("discord"),
72
+ subject: z2.string().regex(/^[1-9][0-9]{0,19}$/, "Use the numeric Discord user ID")
73
+ }).strict())();
74
+ var importAppIdentitySchema = /* @__PURE__ */ (() => z2.object({ kind: appIdentityKindSchema, subject: z2.string().min(1).max(256) }).strict())();
75
+ var memberImportIdentitySchema = /* @__PURE__ */ (() => z2.union([
76
+ importAppIdentitySchema,
77
+ importWalletSchema,
78
+ importXSchema
79
+ ]))();
80
+ var memberImportAccountSchema = /* @__PURE__ */ (() => z2.union([
81
+ importWalletSchema,
82
+ importXSchema
83
+ ]))();
84
+ var memberImportVouchedAccountSchema = /* @__PURE__ */ (() => z2.union([
85
+ importWalletSchema,
86
+ importXSchema,
87
+ importTelegramSchema,
88
+ importDiscordSchema
89
+ ]))();
90
+ var identityReferenceSchema = /* @__PURE__ */ (() => z2.union([
91
+ importAppIdentitySchema,
92
+ importWalletSchema,
93
+ importXSchema,
94
+ importTelegramSchema,
95
+ importDiscordSchema
96
+ ]))();
97
+ var memberImportActionSchema = /* @__PURE__ */ (() => z2.object({
98
+ at: importTimeSchema,
99
+ key: z2.string().min(1).max(200).optional()
100
+ }).strict())();
101
+ var memberImportReferralSchema = /* @__PURE__ */ (() => z2.object({
102
+ /**
103
+ * The inviter: the `ref` of another row of this import, or the sign-in identity of a member
104
+ * who already exists in this environment.
105
+ */
106
+ inviter: z2.union([
107
+ z2.string().trim().min(1).max(200),
108
+ memberImportIdentitySchema
109
+ ]),
110
+ /** When the member accepted the invitation. */
111
+ acceptedAt: importTimeSchema,
112
+ /** Referral programs, by authoring key or ID, the member qualified in, and when. */
113
+ qualified: z2.array(
114
+ z2.object({ program: z2.string().min(1).max(200), at: importTimeSchema }).strict()
115
+ ).max(50).default([])
116
+ }).strict())();
117
+ var memberImportConsentSchema = /* @__PURE__ */ (() => z2.object({
118
+ /** The channel, such as `email`. */
119
+ channel: z2.string().min(1).max(64),
120
+ state: z2.enum(["granted", "withdrawn"]),
121
+ /** When the member chose, on the platform they come from. */
122
+ at: importTimeSchema,
123
+ /**
124
+ * The text the member saw, verbatim: required to grant, at most `consentWordingMaxLength`
125
+ * characters.
126
+ */
127
+ // The 2,000-character limit is a row refusal at check, so a long wording refuses its row
128
+ // instead of the batch; this bound only caps what a row stores.
129
+ wording: z2.string().max(8e3).optional()
130
+ }).strict())();
131
+ var memberImportRowSchema = /* @__PURE__ */ (() => z2.object({
132
+ /** The member's ID on the platform they come from. Unique within an import. */
133
+ ref: z2.string().trim().min(1).max(200),
134
+ identity: memberImportIdentitySchema,
135
+ accounts: z2.array(memberImportAccountSchema).max(20).default([]),
136
+ /** Opening balances, credited once per ledger as an imported entry. */
137
+ points: z2.array(
138
+ z2.object({
139
+ ledger: z2.string().min(1).max(200),
140
+ balance: z2.number().int().positive().safe()
141
+ }).strict()
142
+ ).max(50).default([]),
143
+ /** Quest progress, by quest authoring key or ID. */
144
+ quests: z2.array(
145
+ z2.object({
146
+ quest: z2.string().min(1).max(200),
147
+ actions: z2.array(memberImportActionSchema).min(1).max(3660)
148
+ }).strict()
149
+ ).max(200).default([]),
150
+ referral: memberImportReferralSchema.optional(),
151
+ /** The member's marketing consent, per channel, as the platform they come from recorded it. */
152
+ consent: z2.array(memberImportConsentSchema).max(10).optional()
153
+ }).strict())();
154
+ var memberImportFullRowSchema = /* @__PURE__ */ (() => memberImportRowSchema.extend({
155
+ accounts: z2.array(memberImportVouchedAccountSchema).max(20).default([])
156
+ }).strict())();
157
+ var memberImportCreateSchema = /* @__PURE__ */ (() => z2.object({
158
+ actionId: identifier,
159
+ /** Where the members come from, such as "legacy-domino". */
160
+ source: z2.string().trim().min(1).max(100)
161
+ }).strict())();
162
+ var memberImportRowsInputSchema = /* @__PURE__ */ (() => z2.object({ rows: z2.array(memberImportRowSchema).min(1).max(500) }).strict())();
163
+ var memberImportFullRowsInputSchema = /* @__PURE__ */ (() => z2.object({ rows: z2.array(memberImportFullRowSchema).min(1).max(500) }).strict())();
164
+ var MemberImportRefusalCode = {
165
+ /** An account or identity belongs to another member in the project. */
166
+ AccountLinkedElsewhere: "account-linked-elsewhere",
167
+ /** An operator unlinked the row's app identity. */
168
+ IdentityUnlinked: "identity-unlinked",
169
+ /** The row's identity names a member an operator banned (`members.ban`). */
170
+ MemberBanned: "member-banned",
171
+ /** An earlier row of the import names the same account. */
172
+ DuplicateAccount: "duplicate-account",
173
+ /** The row names two X accounts, or the member already has another X account selected. */
174
+ XAccountSelected: "x-account-selected",
175
+ /** The row names two Telegram accounts, or the member already has another one selected. */
176
+ TelegramAccountSelected: "telegram-account-selected",
177
+ /** The row names two Discord accounts, or the member already has another one selected. */
178
+ DiscordAccountSelected: "discord-account-selected",
179
+ /** The member would hold more wallets of a chain family than a member can link. */
180
+ LimitReached: "limit-reached",
181
+ UnknownLedger: "unknown-ledger",
182
+ UnknownQuest: "unknown-quest",
183
+ /** The quest has no active release in this environment. */
184
+ QuestNotPublished: "quest-not-published",
185
+ /** The quest's completions are decided per content item, which an import cannot record. */
186
+ QuestNotImportable: "quest-not-importable",
187
+ /** A keyed quest's action has no `key`. */
188
+ KeyRequired: "key-required",
189
+ /**
190
+ * An action's key, on a quest whose keys are unique across members, is used by another member's
191
+ * completion or by an earlier row of the import.
192
+ */
193
+ KeyUsed: "key-used",
194
+ /** An action, a referral or a consent is dated in the future. */
195
+ FutureAction: "future-action",
196
+ /** A consent names a channel Relay does not record consent for. */
197
+ UnsupportedConsentChannel: "unsupported-consent-channel",
198
+ /** A granted consent has no wording. */
199
+ ConsentWordingRequired: "consent-wording-required",
200
+ /** A consent's wording is longer than `consentWordingMaxLength` characters. */
201
+ ConsentWordingTooLong: "consent-wording-too-long",
202
+ /** A consent's wording is not plain text: it has a NUL or a lone surrogate. */
203
+ ConsentWordingInvalid: "consent-wording-invalid",
204
+ /** The row's sign-in wallet or X account is linked to its member without sign-in. */
205
+ SignInDisabled: "sign-in-disabled",
206
+ /**
207
+ * The row names one point ledger, quest or referral program twice, by any of its names, or one
208
+ * consent channel twice.
209
+ */
210
+ DuplicateEntry: "duplicate-entry",
211
+ /** The inviter is no row of this import, and no member of the environment signs in with it. */
212
+ UnknownInviter: "unknown-inviter",
213
+ /** The row names its own member as the inviter. */
214
+ SelfReferral: "self-referral",
215
+ /** The member already has an inviter. An import never replaces one. */
216
+ InviterAlreadyAccepted: "inviter-already-accepted",
217
+ /** The inviter was invited, directly or through others, by this row's member. */
218
+ ReferralCycle: "referral-cycle",
219
+ /** The row that names the inviter was refused, so the inviter is never imported. */
220
+ InviterRefused: "inviter-refused",
221
+ /** No referral program of that key or ID in this environment, or it is archived. */
222
+ UnknownReferralProgram: "unknown-referral-program"
223
+ };
224
+ var refusalCodeSchema = /* @__PURE__ */ (() => z2.string())();
225
+ var memberImportRefusalSchema = /* @__PURE__ */ (() => z2.object({
226
+ code: refusalCodeSchema,
227
+ message: z2.string()
228
+ }))();
229
+ var memberImportRowResultSchema = /* @__PURE__ */ (() => z2.object({
230
+ line: z2.number().int().positive(),
231
+ ref: z2.string(),
232
+ status: z2.enum(["pending", "ready", "applied", "refused"]),
233
+ /** The member the row resolves to: an existing member, or the one applying created. */
234
+ member: identifier.nullable(),
235
+ /** Whether the row's identity names a member who already exists. Null until checked. */
236
+ existing: z2.boolean().nullable(),
237
+ refusals: z2.array(memberImportRefusalSchema),
238
+ /**
239
+ * Whether the import's revert went through this applied row. Absent from a Relay older than
240
+ * this field.
241
+ */
242
+ reverted: z2.boolean().optional()
243
+ }))();
244
+ var memberImportRowPageSchema = /* @__PURE__ */ (() => z2.object({
245
+ items: z2.array(memberImportRowResultSchema),
246
+ nextCursor: z2.string().nullable()
247
+ }))();
248
+ var memberImportRowQuerySchema = /* @__PURE__ */ (() => z2.object({
249
+ status: z2.enum(["pending", "ready", "applied", "refused"]).optional(),
250
+ cursor: z2.string().max(200).optional(),
251
+ limit: z2.coerce.number().int().min(1).max(500).optional()
252
+ }).strict())();
253
+ var memberImportSummarySchema = /* @__PURE__ */ (() => z2.object({
254
+ rows: z2.number().int().nonnegative(),
255
+ ready: z2.number().int().nonnegative(),
256
+ refused: z2.number().int().nonnegative(),
257
+ members: z2.object({
258
+ created: z2.number().int().nonnegative(),
259
+ existing: z2.number().int().nonnegative()
260
+ }),
261
+ /** Identities and accounts the ready rows attach, sign-in identities included. */
262
+ accounts: z2.number().int().nonnegative(),
263
+ /** Opening balance totals, by ledger as the rows name it. */
264
+ points: z2.array(
265
+ z2.object({ ledger: z2.string(), total: z2.number().int().nonnegative() })
266
+ ),
267
+ /** Imported actions, by quest as the rows name it. */
268
+ actions: z2.array(
269
+ z2.object({ quest: z2.string(), total: z2.number().int().nonnegative() })
270
+ ),
271
+ /**
272
+ * Accepted referrals the ready rows record, and their qualifications by program as the rows
273
+ * name it. Absent from a summary written before imports carried referrals.
274
+ */
275
+ referrals: z2.object({
276
+ accepted: z2.number().int().nonnegative(),
277
+ qualified: z2.array(
278
+ z2.object({
279
+ program: z2.string(),
280
+ total: z2.number().int().nonnegative()
281
+ })
282
+ )
283
+ }).optional(),
284
+ /** Refused rows, by refusal code. A row can have several. */
285
+ refusals: z2.array(
286
+ z2.object({ code: refusalCodeSchema, rows: z2.number().int().nonnegative() })
287
+ )
288
+ }))();
289
+ var memberImportCommandSchema = /* @__PURE__ */ (() => z2.object({ actionId: identifier.optional() }).strict())();
290
+ var memberImportRevertInputSchema = /* @__PURE__ */ (() => z2.object({
291
+ actionId: identifier,
292
+ reason: z2.string().trim().min(1).max(500)
293
+ }).strict())();
294
+ var memberImportRevertOutcomeSchema = /* @__PURE__ */ (() => z2.object({
295
+ reversed: z2.object({
296
+ /** Applied rows the revert went through. */
297
+ rows: z2.number().int().nonnegative(),
298
+ /** Opening balance entries reversed. */
299
+ entries: z2.number().int().nonnegative(),
300
+ /** Imported completions revoked. */
301
+ completions: z2.number().int().nonnegative(),
302
+ /** Links the rows created that the revert removed. */
303
+ links: z2.number().int().nonnegative()
304
+ }),
305
+ /**
306
+ * Imported points the revert could not take back, by member and point ledger: the member had
307
+ * spent or reserved them. A revert takes only free points, as a completion's revocation does,
308
+ * so no balance goes below zero and Relay records no debt.
309
+ */
310
+ unreversedPoints: z2.array(
311
+ z2.object({
312
+ member: identifier,
313
+ ledger: identifier,
314
+ amount: z2.number().int().positive()
315
+ })
316
+ ),
317
+ /**
318
+ * Links the rows created that stay, because the member relied on them since: `signed-in` with
319
+ * it, or `proved` a vouched wallet. `kind` is `wallet`, the provider (`x`, `telegram`,
320
+ * `discord`) or `app:<name>`; `account` is the address or subject. A row whose member was erased
321
+ * (`members.erase`) is passed over whole: one entry with `kind: "member"`, the member ID as
322
+ * `account` and reason `member-erased`, and nothing of that row is reversed.
323
+ */
324
+ keptLinks: z2.array(
325
+ z2.object({
326
+ member: identifier,
327
+ kind: z2.string(),
328
+ account: z2.string(),
329
+ reason: z2.string()
330
+ })
331
+ ),
332
+ /**
333
+ * True when rows were applied before imports recorded the links they created: those rows'
334
+ * links all stay, and only their balances and completions were reversed.
335
+ */
336
+ linksUntracked: z2.boolean()
337
+ }))();
338
+ var memberImportRevertSchema = /* @__PURE__ */ (() => z2.object({
339
+ reason: z2.string(),
340
+ requestedAt: z2.number().int(),
341
+ requestedBy: z2.string().nullable(),
342
+ /** Applied rows reverted so far. */
343
+ rows: z2.number().int().nonnegative(),
344
+ revertedAt: z2.number().int().nullable(),
345
+ outcome: memberImportRevertOutcomeSchema.nullable()
346
+ }))();
347
+ var MemberImportState = {
348
+ /** Rows are being added. */
349
+ Open: "open",
350
+ /** The check (the dry run) is running. */
351
+ Checking: "checking",
352
+ /** Checked, with a summary; it can be applied. */
353
+ Checked: "checked",
354
+ /** Applying its ready rows, in the background. */
355
+ Applying: "applying",
356
+ /** Every ready row was applied or refused. */
357
+ Applied: "applied",
358
+ /** Stopped while applying: the rows it did not reach stay `ready`, and it can't be applied again. */
359
+ Stopped: "stopped",
360
+ /** Its revert is taking back what its applied rows granted, in the background. */
361
+ Reverting: "reverting",
362
+ /** Its revert went through every applied row. */
363
+ Reverted: "reverted",
364
+ /** Canceled before it was applied. */
365
+ Canceled: "canceled"
366
+ };
367
+ var memberImportStateSchema = /* @__PURE__ */ (() => z2.string())();
368
+ var memberImportSchema = /* @__PURE__ */ (() => z2.object({
369
+ id: identifier,
370
+ source: z2.string(),
371
+ /**
372
+ * The import's state, open to states Relay adds. Absent from a Relay older than this field;
373
+ * `status` then holds the state, folded as below.
374
+ */
375
+ state: memberImportStateSchema.optional(),
376
+ /**
377
+ * The state as SDK 1.0 typed it: `applied` for a stopped, reverting or reverted import too, so
378
+ * filtering on `applied` includes them. Read `state` instead.
379
+ */
380
+ status: z2.enum([
381
+ "open",
382
+ "checking",
383
+ "checked",
384
+ "applying",
385
+ "applied",
386
+ "canceled"
387
+ ]),
388
+ rows: z2.number().int().nonnegative(),
389
+ /** The latest check's summary, or null before the first check and after rows change. */
390
+ summary: memberImportSummarySchema.nullable(),
391
+ /** While applying and after, stopped included: rows applied and refused so far. */
392
+ progress: z2.object({
393
+ applied: z2.number().int().nonnegative(),
394
+ refused: z2.number().int().nonnegative()
395
+ }),
396
+ createdAt: z2.number().int(),
397
+ createdBy: z2.string().nullable(),
398
+ checkedAt: z2.number().int().nullable(),
399
+ appliedAt: z2.number().int().nullable(),
400
+ appliedBy: z2.string().nullable(),
401
+ canceledAt: z2.number().int().nullable(),
402
+ canceledBy: z2.string().nullable(),
403
+ /** Set when the import was stopped while applying; `appliedAt` stays null. */
404
+ stoppedAt: z2.number().int().nullish(),
405
+ stoppedBy: z2.string().nullish(),
406
+ /** Set once a revert was asked for: the import is `reverting`, then `reverted`. */
407
+ revert: memberImportRevertSchema.nullish()
408
+ }))();
409
+ var memberImportPageSchema = /* @__PURE__ */ (() => z2.object({
410
+ items: z2.array(memberImportSchema),
411
+ nextCursor: z2.string().nullable()
412
+ }))();
413
+ var memberImportListQuerySchema = /* @__PURE__ */ (() => z2.object({
414
+ cursor: z2.string().max(200).optional(),
415
+ limit: z2.coerce.number().int().min(1).max(100).optional()
416
+ }).strict())();
417
+
418
+ // src/server/schedules.ts
419
+ import * as z3 from "zod";
420
+ import { Cron } from "croner";
421
+ var APP_SCHEDULE_LIMIT = 10;
422
+ var APP_SCHEDULE_MIN_INTERVAL = 3e5;
423
+ var APP_SCHEDULE_TIMEOUT = 3e4;
424
+ var appScheduleNameSchema = /* @__PURE__ */ (() => z3.string().regex(/^[a-z][a-z0-9-]{0,63}$/))();
425
+ var appSchedulePathSchema = /* @__PURE__ */ (() => z3.string().min(2).max(512).refine((path) => {
426
+ if (!/^\/[a-zA-Z0-9_/-]+$/.test(path) || path.startsWith("//")) {
427
+ return false;
428
+ }
429
+ return path.split("/").slice(1).every((part) => part.length > 0) && new URL(path, "https://app.invalid").pathname === path;
430
+ }, "Expected an absolute route path without a query or hidden segments"))();
431
+ function interval(value) {
432
+ const amount = Number(value.slice(0, -1));
433
+ const unit = value.slice(-1);
434
+ return amount * (unit === "m" ? 6e4 : unit === "h" ? 36e5 : 864e5);
435
+ }
436
+ var everySchema = /* @__PURE__ */ (() => z3.string().regex(/^[1-9]\d{0,3}[mhd]$/).refine(
437
+ (value) => interval(value) >= limits.apps.scheduleMinIntervalMs && interval(value) <= 365 * 864e5,
438
+ "Use an interval from 5 minutes to 365 days, such as 5m, 1h or 1d"
439
+ ))();
440
+ var cronSchema = /* @__PURE__ */ (() => z3.string().max(120).refine((value) => {
441
+ const fields = value.trim().split(/\s+/);
442
+ if (fields.length !== 5 || fields.some((field) => !/^[\d*,/-]+$/.test(field))) {
443
+ return false;
444
+ }
445
+ try {
446
+ const job = new Cron(value, { paused: true, timezone: "UTC" });
447
+ if (!job.nextRun()) {
448
+ return false;
449
+ }
450
+ const minutes = new Cron(`${fields[0]} * * * *`, {
451
+ paused: true,
452
+ timezone: "UTC"
453
+ });
454
+ const times = minutes.nextRuns(13, /* @__PURE__ */ new Date("2024-01-01T00:00:00Z"));
455
+ return times.every(
456
+ (time, i) => i === 0 || time.getTime() - times[i - 1].getTime() >= limits.apps.scheduleMinIntervalMs
457
+ );
458
+ } catch {
459
+ return false;
460
+ }
461
+ }, "Expected a five-field UTC cron expression with minute slots at least five minutes apart"))();
462
+ var declaration = /* @__PURE__ */ (() => ({
463
+ name: appScheduleNameSchema,
464
+ path: appSchedulePathSchema,
465
+ description: z3.string().min(1).max(500)
466
+ }))();
467
+ var everySchedule = /* @__PURE__ */ (() => z3.object({ ...declaration, every: everySchema }))();
468
+ var cronSchedule = /* @__PURE__ */ (() => z3.object({ ...declaration, cron: cronSchema }))();
469
+ var appScheduleSchema = /* @__PURE__ */ (() => z3.union([
470
+ everySchedule.strict(),
471
+ cronSchedule.strict()
472
+ ]))();
473
+ var appSchedulesSchema = /* @__PURE__ */ (() => z3.array(appScheduleSchema).max(limits.apps.schedules).refine(
474
+ (items) => new Set(items.map((item) => item.name)).size === items.length,
475
+ "Schedule names must be unique"
476
+ ))();
477
+ function nextScheduleRun(schedule, after) {
478
+ if ("every" in schedule) {
479
+ return after + interval(schedule.every);
480
+ }
481
+ const next = new Cron(schedule.cron, {
482
+ paused: true,
483
+ timezone: "UTC"
484
+ }).nextRun(new Date(after));
485
+ if (!next) {
486
+ throw new Error("Schedule has no next occurrence");
487
+ }
488
+ return next.getTime();
489
+ }
490
+ var appScheduleStateSchema = /* @__PURE__ */ (() => z3.enum(["active", "paused", "archived"]))();
491
+ var appScheduleStateInputSchema = /* @__PURE__ */ (() => z3.object({
492
+ state: appScheduleStateSchema,
493
+ reason: lifecycleReasonSchema.optional()
494
+ }).strict())();
495
+ var APP_SCHEDULE_RESULT_BYTES = 16384;
496
+ var appScheduleDiagnosticSchema = /* @__PURE__ */ (() => z3.object({
497
+ level: z3.enum(["error", "warning", "info"]),
498
+ message: z3.string().min(1).max(500),
499
+ /** What the line is about, such as a member, record or tracker ID. */
500
+ subject: z3.string().min(1).max(200).optional(),
501
+ /** A stable code the app chooses, such as `ingest-timeout`. */
502
+ code: z3.string().min(1).max(100).optional()
503
+ }))();
504
+ var appScheduleResultSchema = /* @__PURE__ */ (() => z3.object({
505
+ outcome: z3.enum(["succeeded", "partial", "failed"]),
506
+ summary: z3.string().min(1).max(500).optional(),
507
+ /** Counts and gauges, such as processed and failed members. */
508
+ metrics: z3.record(z3.string().regex(/^[A-Za-z][\w.-]{0,63}$/), z3.number()).refine(
509
+ (metrics) => Object.keys(metrics).length <= 50,
510
+ "Report at most 50 metrics"
511
+ ).optional(),
512
+ diagnostics: z3.array(appScheduleDiagnosticSchema).max(50).optional()
513
+ }))();
514
+ function scheduleResult(result) {
515
+ const body = JSON.stringify(appScheduleResultSchema.parse(result));
516
+ if (new TextEncoder().encode(body).byteLength > limits.apps.scheduleResultBytes) {
517
+ throw new Error(
518
+ `A schedule result must be at most ${limits.apps.scheduleResultBytes.toLocaleString("en-US")} bytes of JSON: send fewer or shorter diagnostics`
519
+ );
520
+ }
521
+ return new Response(body, {
522
+ headers: { "Content-Type": "application/json" }
523
+ });
524
+ }
525
+ var appScheduleRunSchema = /* @__PURE__ */ (() => z3.object({
526
+ id: z3.string().uuid(),
527
+ build: z3.string().uuid(),
528
+ startedAt: z3.number(),
529
+ scheduledAt: z3.number(),
530
+ manual: z3.boolean(),
531
+ status: z3.enum(["queued", "running", "succeeded", "failed", "uncertain"]),
532
+ duration: z3.number().nullable(),
533
+ /** Why the run failed or is uncertain, or why Relay ignored the app's result. */
534
+ error: z3.string().nullable(),
535
+ /** The app's JSON answer when it sent a valid result. Absent on runs from before results. */
536
+ result: appScheduleResultSchema.nullable().optional()
537
+ }))();
538
+ var appScheduleRunsSchema = /* @__PURE__ */ (() => z3.object({
539
+ /** Newest first: the latest twenty runs of one schedule, including a queued or running one. */
540
+ runs: z3.array(appScheduleRunSchema)
541
+ }))();
542
+ var appScheduleListSchema = /* @__PURE__ */ (() => z3.object({
543
+ state: appScheduleStateSchema,
544
+ schedules: z3.array(
545
+ z3.object({
546
+ declaration: z3.union([everySchedule, cronSchedule]),
547
+ nextRun: z3.number().nullable(),
548
+ blocked: z3.boolean(),
549
+ lastRun: appScheduleRunSchema.nullable()
550
+ })
551
+ )
552
+ }))();
553
+ var scheduledInvocationSchema = /* @__PURE__ */ (() => z3.object({
554
+ id: z3.string().uuid(),
555
+ build: z3.string().uuid(),
556
+ name: appScheduleNameSchema,
557
+ scheduledAt: z3.number().int(),
558
+ startedAt: z3.number().int(),
559
+ manual: z3.boolean()
560
+ }).strict())();
561
+ async function verifyScheduledRequest(request, key) {
562
+ const signature = request.headers.get("X-Domino-Schedule-Signature");
563
+ const url = new URL(request.url);
564
+ if (request.method !== "POST" || url.search !== "" || url.hash !== "" || !key || !signature || !/^[a-f0-9]{64}$/.test(signature)) {
565
+ return null;
566
+ }
567
+ const reader = request.clone().body?.getReader();
568
+ if (!reader) {
569
+ return null;
570
+ }
571
+ let body = "";
572
+ let size = 0;
573
+ const decoder = new TextDecoder();
574
+ try {
575
+ for (; ; ) {
576
+ const chunk = await reader.read();
577
+ if (chunk.done) {
578
+ break;
579
+ }
580
+ size += chunk.value.byteLength;
581
+ if (size > 4096) {
582
+ void reader.cancel().catch(() => {
583
+ });
584
+ return null;
585
+ }
586
+ body += decoder.decode(chunk.value, { stream: true });
587
+ }
588
+ body += decoder.decode();
589
+ } catch {
590
+ return null;
591
+ }
592
+ const secret = await crypto.subtle.importKey(
593
+ "raw",
594
+ new TextEncoder().encode(key),
595
+ { name: "HMAC", hash: "SHA-256" },
596
+ false,
597
+ ["verify"]
598
+ );
599
+ const bytes = Uint8Array.from(
600
+ signature.match(/../g) ?? [],
601
+ (byte) => Number.parseInt(byte, 16)
602
+ );
603
+ const valid = await crypto.subtle.verify(
604
+ "HMAC",
605
+ secret,
606
+ bytes,
607
+ new TextEncoder().encode(`POST
608
+ ${url.pathname}
609
+ ${body}`)
610
+ );
611
+ if (!valid) {
612
+ return null;
613
+ }
614
+ const parsed = scheduledInvocationSchema.safeParse(
615
+ await new Response(body).json().catch(() => null)
616
+ );
617
+ if (!parsed.success || Math.abs(Date.now() - parsed.data.startedAt) > 6e4) {
618
+ return null;
619
+ }
620
+ return parsed.data;
621
+ }
622
+
623
+ // src/server/starters.ts
624
+ import * as z4 from "zod";
625
+ var starters = [
626
+ {
627
+ id: "campaign",
628
+ title: "Campaign tour",
629
+ summary: "A neutral quest app with a guided tour of every quest kind. The blank canvas for anything."
630
+ },
631
+ {
632
+ id: "classic",
633
+ title: "Classic questboard",
634
+ summary: "The familiar Domino portal: quests in a grid grouped by section, a claim page, points, and a leaderboard."
635
+ },
636
+ {
637
+ id: "waitlist",
638
+ title: "Waitlist",
639
+ summary: "Collect sign-ups before launch. People move up the line by inviting friends."
640
+ },
641
+ {
642
+ id: "referral",
643
+ title: "Referral program",
644
+ summary: "Give every member an invite link and reward them when friends join and qualify."
645
+ },
646
+ {
647
+ id: "discord",
648
+ title: "Discord activation",
649
+ summary: "Turn new Discord members into regulars with quests for joining, introducing themselves, and taking part, rewarded with roles."
650
+ },
651
+ {
652
+ id: "loyalty",
653
+ title: "Loyalty program",
654
+ summary: "Members earn points in a campaign, qualify into a members' group, and spend points on offers, some for members only."
655
+ },
656
+ {
657
+ id: "api",
658
+ title: "API",
659
+ summary: "A headless Worker with typed routes and interactive API docs, for plugging Domino into your own product."
660
+ }
661
+ ];
662
+ var offeredStarterSchema = /* @__PURE__ */ (() => z4.string().refine((id) => starters.some((starter) => starter.id === id), {
663
+ error: `Unknown starter. Choose one of: ${starters.map((starter) => starter.id).join(", ")}.`
664
+ }))();
665
+ var starterTemplates = [
666
+ {
667
+ id: "campaign",
668
+ title: "Campaign tour",
669
+ summary: "A neutral quest app with a guided tour of every quest kind. The blank canvas for anything."
670
+ },
671
+ {
672
+ id: "classic",
673
+ title: "Classic questboard",
674
+ summary: "The familiar Domino portal: quests in a grid grouped by section, a claim page, points, and a leaderboard."
675
+ },
676
+ {
677
+ id: "waitlist",
678
+ title: "Waitlist",
679
+ summary: "Collect sign-ups before launch. People move up the line by inviting friends."
680
+ },
681
+ {
682
+ id: "referral",
683
+ title: "Referral program",
684
+ summary: "Give every member an invite link and reward them when friends join and qualify."
685
+ },
686
+ {
687
+ id: "discord",
688
+ title: "Discord activation",
689
+ summary: "Turn new Discord members into regulars with quests for joining, introducing themselves, and taking part, rewarded with roles."
690
+ },
691
+ {
692
+ id: "api",
693
+ title: "API",
694
+ summary: "A headless Worker with typed routes and interactive API docs, for plugging Domino into your own product."
695
+ }
696
+ ];
697
+ var starterIdSchema = /* @__PURE__ */ (() => z4.enum(
698
+ starterTemplates.map((template) => template.id)
699
+ ))();
700
+
701
+ // src/server/hosting.ts
702
+ import * as z5 from "zod";
703
+ var outputPathSchema = /* @__PURE__ */ (() => z5.string().min(1).max(512).refine(
704
+ (path) => path.split("/").every(
705
+ (part) => /^[\w-][\w.-]*$/.test(part) && part !== "node_modules"
706
+ ),
707
+ "Expected a relative build output path without hidden segments"
708
+ ))();
709
+ var appRoutingSchema = /* @__PURE__ */ (() => z5.enum(["legacy", "transparent"]).default("legacy"))();
710
+ var APP_SECRET_LIMIT = 50;
711
+ var APP_KV_LIMIT = 5;
712
+ var APP_SQL_LIMIT = 5;
713
+ var APP_MIGRATION_LIMIT = 100;
714
+ var APP_MIGRATION_FILE_BYTES = 9e4;
715
+ var APP_MIGRATION_TOTAL_BYTES = 1e6;
716
+ var appSecretNameSchema = /* @__PURE__ */ (() => z5.string().regex(
717
+ /^[A-Z_][A-Z0-9_]{0,63}$/,
718
+ "Use 1-64 uppercase letters, digits, and underscores, not starting with a digit"
719
+ ).refine(
720
+ (name) => !name.startsWith("DOMINO_") && name !== "ASSETS",
721
+ "DOMINO_ names and ASSETS are reserved for Domino's own bindings"
722
+ ))();
723
+ var appSecretValueSchema = /* @__PURE__ */ (() => z5.string().min(1).refine(
724
+ (value) => new TextEncoder().encode(value).length <= 5120,
725
+ "Secret values can be at most 5 KiB"
726
+ ))();
727
+ var appSecretInputSchema = /* @__PURE__ */ (() => z5.object({ value: appSecretValueSchema }).strict())();
728
+ var appSecretSchema = /* @__PURE__ */ (() => z5.object({
729
+ name: appSecretNameSchema,
730
+ updatedAt: z5.number(),
731
+ updatedBy: z5.string()
732
+ }))();
733
+ var appSecretDeclarationSchema = /* @__PURE__ */ (() => z5.object({
734
+ description: z5.string().trim().min(1).max(500),
735
+ required: z5.boolean().default(true)
736
+ }).strict())();
737
+ var appSecretDeclarationsSchema = /* @__PURE__ */ (() => z5.record(appSecretNameSchema, appSecretDeclarationSchema).refine(
738
+ (secrets) => Object.keys(secrets).length <= limits.apps.secrets,
739
+ `Declare at most ${limits.apps.secrets} app secrets`
740
+ ))();
741
+ var appSecretListSchema = /* @__PURE__ */ (() => z5.object({
742
+ secrets: z5.array(appSecretSchema),
743
+ declared: z5.array(appSecretDeclarationSchema.extend({ name: appSecretNameSchema })).default([])
744
+ }))();
745
+ var hostedAppSecretsSchema = /* @__PURE__ */ (() => z5.object({ secrets: z5.record(appSecretNameSchema, appSecretValueSchema) }).strict())();
746
+ var storageDescription = /* @__PURE__ */ (() => z5.object({
747
+ description: z5.string().trim().min(1).max(500)
748
+ }).strict())();
749
+ var appStorageSchema = /* @__PURE__ */ (() => z5.object({
750
+ kv: z5.record(appSecretNameSchema, storageDescription).refine(
751
+ (stores) => Object.keys(stores).length <= limits.apps.kvStores,
752
+ `Declare at most ${limits.apps.kvStores} KV stores`
753
+ ).default({}),
754
+ sql: z5.record(
755
+ appSecretNameSchema,
756
+ storageDescription.extend({
757
+ migrations: outputPathSchema.optional()
758
+ }).strict()
759
+ ).refine(
760
+ (stores) => Object.keys(stores).length <= limits.apps.sqlStores,
761
+ `Declare at most ${limits.apps.sqlStores} SQL stores`
762
+ ).default({})
763
+ }).strict())();
764
+ var appStorageKindSchema = /* @__PURE__ */ (() => z5.enum(["kv", "sql"]))();
765
+ var appStorageListSchema = /* @__PURE__ */ (() => z5.object({
766
+ stores: z5.array(
767
+ z5.object({
768
+ kind: z5.string(),
769
+ name: appSecretNameSchema,
770
+ createdAt: z5.number().nullable(),
771
+ declared: z5.boolean(),
772
+ description: z5.string().optional()
773
+ })
774
+ )
775
+ }))();
776
+ var APP_STORAGE_ROW_LIMIT = 50;
777
+ var APP_STORAGE_PREVIEW_CHARACTERS = 2e3;
778
+ var appStorageCellSchema = /* @__PURE__ */ (() => z5.union([
779
+ z5.string(),
780
+ z5.number(),
781
+ z5.null(),
782
+ z5.object({ text: z5.string(), truncated: z5.literal(true) }),
783
+ z5.object({ blob: z5.number().int().min(0) })
784
+ ]))();
785
+ var appStorageTablesSchema = /* @__PURE__ */ (() => z5.object({
786
+ tables: z5.array(
787
+ /** `kind` is SQLite's: `table` or `view`. */
788
+ z5.object({ name: z5.string(), kind: z5.string() })
789
+ )
790
+ }))();
791
+ var appStorageRowsSchema = /* @__PURE__ */ (() => z5.object({
792
+ table: z5.string(),
793
+ columns: z5.array(z5.string()),
794
+ rows: z5.array(z5.array(appStorageCellSchema)),
795
+ /** How many rows come before this page in storage order. */
796
+ offset: z5.number().int().min(0),
797
+ total: z5.number().int().min(0),
798
+ /** Pass back as `cursor` for the next page; null on the last one. */
799
+ nextCursor: pageCursorSchema.nullable().default(null)
800
+ }))();
801
+ var appStorageKeysSchema = /* @__PURE__ */ (() => z5.object({
802
+ keys: z5.array(
803
+ z5.object({ name: z5.string(), expiration: z5.number().nullable() })
804
+ ),
805
+ /** Pass back as `cursor` for the next page; null on the last one. */
806
+ nextCursor: pageCursorSchema.nullable().default(null),
807
+ /** @deprecated Use `nextCursor`. Removed in 2.0.0. */
808
+ cursor: z5.string().nullable()
809
+ }))();
810
+ var appStorageValueSchema = /* @__PURE__ */ (() => z5.object({
811
+ key: z5.string(),
812
+ size: z5.number().int().min(0),
813
+ /** Null when the value is not UTF-8 text. */
814
+ text: z5.string().nullable(),
815
+ truncated: z5.boolean()
816
+ }))();
817
+ var APP_STORAGE_CELL_CHARACTERS = 1e5;
818
+ var appStorageCellPageSchema = /* @__PURE__ */ (() => z5.object({
819
+ table: z5.string(),
820
+ column: z5.string(),
821
+ /** The row's position in storage order: a rows page's `offset` plus its index on that page. */
822
+ row: z5.number().int().min(0),
823
+ /** SQLite's storage class. */
824
+ type: z5.enum(["text", "integer", "real", "blob", "null"]),
825
+ /** Characters of text, or of a number's text form; bytes of a BLOB; null for NULL. */
826
+ length: z5.number().int().min(0).nullable(),
827
+ /** How many characters come before this page. */
828
+ offset: z5.number().int().min(0),
829
+ /** Up to 100,000 characters from `offset`. Null for a BLOB, whose bytes are never read, and NULL. */
830
+ text: z5.string().nullable(),
831
+ /** Pass back as `cursor` for the next page; null on the last one. */
832
+ nextCursor: pageCursorSchema.nullable().default(null)
833
+ }))();
834
+ var storageTableNameSchema = /* @__PURE__ */ (() => z5.string().min(1).max(512))();
835
+ var appStorageSqlClearSchema = /* @__PURE__ */ (() => z5.union([
836
+ z5.object({
837
+ dryRun: z5.boolean().optional(),
838
+ tables: z5.array(storageTableNameSchema).min(1).max(50)
839
+ }).strict(),
840
+ z5.object({
841
+ dryRun: z5.boolean().optional(),
842
+ allTables: z5.literal(true),
843
+ keepTables: z5.array(storageTableNameSchema).max(50).optional()
844
+ }).strict()
845
+ ]))();
846
+ var appStorageKvClearSchema = /* @__PURE__ */ (() => z5.union([
847
+ z5.object({
848
+ dryRun: z5.boolean().optional(),
849
+ prefix: z5.string().min(1).max(512)
850
+ }).strict(),
851
+ z5.object({ dryRun: z5.boolean().optional(), all: z5.literal(true) }).strict()
852
+ ]))();
853
+ var appStorageSqlClearResultSchema = /* @__PURE__ */ (() => z5.object({
854
+ environment: z5.string(),
855
+ kind: z5.literal("sql"),
856
+ store: z5.string(),
857
+ dryRun: z5.boolean(),
858
+ /** Each table cleared, or counted by a dry run, with its row count before the clear. */
859
+ tables: z5.array(
860
+ z5.object({ name: z5.string(), rows: z5.number().int().min(0) })
861
+ )
862
+ }))();
863
+ var appStorageKvClearResultSchema = /* @__PURE__ */ (() => z5.object({
864
+ environment: z5.string(),
865
+ kind: z5.literal("kv"),
866
+ store: z5.string(),
867
+ dryRun: z5.boolean(),
868
+ /** Empty when every key was selected. */
869
+ prefix: z5.string(),
870
+ /** Keys deleted by this call, or counted by a dry run. */
871
+ keys: z5.number().int().min(0),
872
+ /**
873
+ * False when keys remain: a clear deletes at most `limits.apps.storageClearKeys` (10,000) keys a
874
+ * call, so call again until it is true. On a dry run, false means `keys` stopped counting at
875
+ * `limits.apps.storageClearCountKeys` (100,000).
876
+ */
877
+ complete: z5.boolean()
878
+ }))();
879
+ var appMigrationNameSchema = /* @__PURE__ */ (() => z5.string().max(255).regex(/^[\w-][\w.-]*\.sql$/))();
880
+ function compareAppMigrations(a, b) {
881
+ const left = Number.parseInt(a.split("_")[0], 10);
882
+ const right = Number.parseInt(b.split("_")[0], 10);
883
+ if (left !== right) {
884
+ if (Number.isFinite(left) && Number.isFinite(right)) {
885
+ return left - right;
886
+ }
887
+ if (Number.isFinite(left)) {
888
+ return -1;
889
+ }
890
+ if (Number.isFinite(right)) {
891
+ return 1;
892
+ }
893
+ }
894
+ return a < b ? -1 : a > b ? 1 : 0;
895
+ }
896
+ var appMigrationsSchema = /* @__PURE__ */ (() => z5.record(
897
+ appSecretNameSchema,
898
+ z5.array(
899
+ z5.object({
900
+ name: appMigrationNameSchema,
901
+ sql: z5.string().min(1).refine(
902
+ (sql) => new TextEncoder().encode(sql).length <= limits.apps.migrationFileBytes,
903
+ `A migration file must not exceed ${limits.apps.migrationFileBytes} bytes`
904
+ )
905
+ }).strict()
906
+ ).max(limits.apps.migrations).refine(
907
+ (files) => new Set(files.map((file) => file.name)).size === files.length,
908
+ "Duplicate migration filenames"
909
+ )
910
+ ).refine(
911
+ (stores) => Object.values(stores).flat().reduce(
912
+ (total, file) => total + new TextEncoder().encode(file.sql).length,
913
+ 0
914
+ ) <= limits.apps.migrationTotalBytes,
915
+ `Migrations must not exceed ${limits.apps.migrationTotalBytes} bytes in total`
916
+ ))();
917
+ var appScripts = /* @__PURE__ */ (() => ({
918
+ routing: appRoutingSchema,
919
+ devScript: z5.string().regex(/^[\w:-]+$/),
920
+ checkScript: z5.string().regex(/^[\w:-]+$/),
921
+ buildScript: z5.string().regex(/^[\w:-]+$/)
922
+ }))();
923
+ var workerSettings = /* @__PURE__ */ (() => ({
924
+ runWorkerFirst: z5.boolean().default(false),
925
+ main: outputPathSchema.refine(
926
+ (path) => /\.m?js$/.test(path),
927
+ "Expected a compiled JavaScript entry"
928
+ ),
929
+ compatibilityDate: z5.string().regex(/^\d{4}-\d{2}-\d{2}$/),
930
+ compatibilityFlags: z5.array(z5.string().min(1)).max(50).default([]),
931
+ vars: z5.record(
932
+ z5.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/).refine((name) => name !== "ASSETS"),
933
+ z5.string()
934
+ ).default({}),
935
+ secrets: appSecretDeclarationsSchema.default({}),
936
+ storage: appStorageSchema.optional(),
937
+ schedules: appSchedulesSchema.optional()
938
+ }))();
939
+ var distinctBindings = (worker, ctx) => {
940
+ const owners = /* @__PURE__ */ new Map();
941
+ const sources = [
942
+ ["vars", "an app var", Object.keys(worker.vars)],
943
+ ["secrets", "a declared secret", Object.keys(worker.secrets)],
944
+ ["storage", "a KV store", Object.keys(worker.storage?.kv ?? {})],
945
+ ["storage", "a SQL store", Object.keys(worker.storage?.sql ?? {})]
946
+ ];
947
+ for (const [path, owner, names] of sources) {
948
+ for (const name of names) {
949
+ const first = owners.get(name);
950
+ if (first) {
951
+ ctx.addIssue({
952
+ code: "custom",
953
+ message: `Binding name ${name} is used by both ${first} and ${owner}`,
954
+ path: [path]
955
+ });
956
+ } else {
957
+ owners.set(name, owner);
958
+ }
959
+ }
960
+ }
961
+ };
962
+ var hostedAppSchema = /* @__PURE__ */ (() => z5.discriminatedUnion("kind", [
963
+ z5.object({
964
+ kind: z5.literal("static"),
965
+ directory: outputPathSchema,
966
+ ...appScripts
967
+ }).strict(),
968
+ z5.object({
969
+ kind: z5.literal("worker"),
970
+ directory: outputPathSchema,
971
+ assetsDirectory: outputPathSchema.optional(),
972
+ ...appScripts,
973
+ ...workerSettings
974
+ }).strict().superRefine(distinctBindings)
975
+ ]))();
976
+ var repositorySchema = /* @__PURE__ */ (() => z5.object({
977
+ id: z5.string().uuid(),
978
+ organization: identifier,
979
+ project: identifier,
980
+ remote: z5.string().url(),
981
+ defaultBranch: z5.string(),
982
+ status: z5.enum(["provisioning", "ready"])
983
+ }))();
984
+ var repositoryCreateSchema = /* @__PURE__ */ (() => z5.object({
985
+ /** Omitted: the starter chosen at project setup, else `campaign`. */
986
+ starter: offeredStarterSchema.optional()
987
+ }).strict())();
988
+ var createRepositorySchema = /* @__PURE__ */ (() => z5.object({
989
+ /** Omitted: the starter chosen at project setup, else `campaign`. */
990
+ starter: starterIdSchema.optional()
991
+ }).strict())();
992
+ var deviceStartSchema = /* @__PURE__ */ (() => z5.object({
993
+ challenge: z5.string().regex(/^[a-f0-9]{64}$/)
994
+ }).strict())();
995
+ var deviceRedeemSchema = /* @__PURE__ */ (() => z5.object({
996
+ id: z5.string().uuid(),
997
+ verifier: z5.string().min(43).max(128)
998
+ }).strict())();
999
+ var deviceApproveSchema = /* @__PURE__ */ (() => z5.object({
1000
+ id: z5.string().uuid(),
1001
+ code: z5.string().regex(/^[A-F0-9]{4}-[A-F0-9]{4}$/)
1002
+ }).strict())();
1003
+ var commitSchema = /* @__PURE__ */ (() => z5.string().regex(/^[a-f0-9]{40}$/))();
1004
+ var stageRequestSchema = /* @__PURE__ */ (() => z5.object({
1005
+ commit: commitSchema,
1006
+ requestId: z5.string().uuid()
1007
+ }).strict())();
1008
+ var buildIdentitySchema = /* @__PURE__ */ (() => z5.object({
1009
+ routing: appRoutingSchema,
1010
+ slug: z5.string().min(1).max(35).regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/).optional(),
1011
+ runtime: z5.enum(["simulation", "hosted-test"]).default("simulation"),
1012
+ id: z5.string().uuid(),
1013
+ repository: z5.string().uuid(),
1014
+ organization: identifier,
1015
+ project: identifier,
1016
+ commit: commitSchema,
1017
+ createdAt: z5.number(),
1018
+ actor: z5.string(),
1019
+ commitMessage: z5.string().max(500).optional()
1020
+ }))();
1021
+ var buildPhaseSchema = /* @__PURE__ */ (() => z5.enum([
1022
+ "queued",
1023
+ "source",
1024
+ "install",
1025
+ "check",
1026
+ "build",
1027
+ "deploy",
1028
+ "ready",
1029
+ "failed"
1030
+ ]))();
1031
+ var buildStatusSchema = /* @__PURE__ */ (() => z5.object({
1032
+ phase: buildPhaseSchema,
1033
+ failedPhase: buildPhaseSchema.optional(),
1034
+ updatedAt: z5.number(),
1035
+ message: z5.string()
1036
+ }))();
1037
+ var hostedBuildSchema = /* @__PURE__ */ (() => buildIdentitySchema.extend({
1038
+ ...buildStatusSchema.shape,
1039
+ finished: z5.boolean(),
1040
+ current: z5.boolean(),
1041
+ stagingUrl: z5.string().url(),
1042
+ /**
1043
+ * The test deployment the build published from its quest artifacts when it activated, readable
1044
+ * with `GET /deployments/{id}`; null until it activates. A build whose bundle declares no
1045
+ * resources publishes none, so its ID is not found. Only `GET /builds/{id}` includes it.
1046
+ */
1047
+ deployment: z5.string().nullable().optional()
1048
+ }))();
1049
+ var liveAppSchema = /* @__PURE__ */ (() => z5.object({
1050
+ url: z5.string().url().nullable(),
1051
+ state: z5.enum(["none", "deploying", "live", "failed"]),
1052
+ /** The build the address serves, or null before the first one goes live. */
1053
+ build: z5.string().uuid().nullable(),
1054
+ /** The build the last approved promotion asked for, while it differs from `build`. */
1055
+ requested: z5.string().uuid().nullable(),
1056
+ failure: z5.string().nullable()
1057
+ }))();
1058
+ var customDomainStateSchema = /* @__PURE__ */ (() => z5.enum([
1059
+ "awaiting-dns",
1060
+ "provisioning",
1061
+ "active",
1062
+ "attention",
1063
+ "suspended"
1064
+ ]))();
1065
+ var customDomainRecordSchema = /* @__PURE__ */ (() => z5.object({
1066
+ type: z5.enum(["CNAME", "TXT"]),
1067
+ name: z5.string(),
1068
+ value: z5.string(),
1069
+ /** The values public DNS returned: empty when it had none, null before Domino looked. */
1070
+ found: z5.array(z5.string()).nullable(),
1071
+ matches: z5.boolean()
1072
+ }))();
1073
+ var domainTimeMs = /* @__PURE__ */ (() => z5.number().int().nonnegative().nullish())();
1074
+ var customDomainSchema = /* @__PURE__ */ (() => z5.object({
1075
+ id: z5.string().uuid(),
1076
+ hostname: z5.string(),
1077
+ url: z5.string().url(),
1078
+ state: customDomainStateSchema,
1079
+ /** What to fix, in plain words, while the domain needs attention or is suspended. */
1080
+ issue: z5.object({ code: z5.string(), message: z5.string() }).nullable(),
1081
+ records: z5.array(customDomainRecordSchema),
1082
+ /** Cloudflare's statuses and errors in its own words, once the domain is proven. */
1083
+ cloudflare: z5.object({
1084
+ hostnameStatus: z5.string(),
1085
+ certificateStatus: z5.string().nullable(),
1086
+ validationErrors: z5.array(z5.string()),
1087
+ verificationErrors: z5.array(z5.string()),
1088
+ certificateExpiresAt: z5.string().nullable(),
1089
+ certificateExpiresAtMs: domainTimeMs
1090
+ }).nullable(),
1091
+ checkedAt: z5.string().nullable(),
1092
+ checkedAtMs: domainTimeMs,
1093
+ nextCheckAt: z5.string().nullable(),
1094
+ nextCheckAtMs: domainTimeMs,
1095
+ createdAt: z5.string(),
1096
+ createdAtMs: z5.number().int().nonnegative().optional()
1097
+ }))();
1098
+ var customDomainListSchema = /* @__PURE__ */ (() => z5.object({
1099
+ domains: z5.array(customDomainSchema)
1100
+ }))();
1101
+ var customDomainInputSchema = /* @__PURE__ */ (() => z5.object({ hostname: z5.string().min(1).max(300) }).strict())();
1102
+ var stagingAccessModeSchema = /* @__PURE__ */ (() => z5.enum(["console", "password"]))();
1103
+ var stagingAccessSchema = /* @__PURE__ */ (() => z5.object({ mode: stagingAccessModeSchema }))();
1104
+ var stagingAccessInputSchema = /* @__PURE__ */ (() => z5.discriminatedUnion("mode", [
1105
+ z5.object({ mode: z5.literal("console") }).strict(),
1106
+ z5.object({
1107
+ mode: z5.literal("password"),
1108
+ password: z5.string().min(8).max(128)
1109
+ }).strict()
1110
+ ]))();
1111
+ var stagingOrigin = "https://staging.invalid";
1112
+ var stagingPathSchema = /* @__PURE__ */ (() => z5.string().max(2048).refine((path) => {
1113
+ if (!path.startsWith("/") || path.startsWith("//") || path.includes("\\") || // oxlint-disable-next-line no-control-regex
1114
+ /[\u0000-\u001f\u007f]/.test(path)) {
1115
+ return false;
1116
+ }
1117
+ try {
1118
+ return new URL(path, stagingOrigin).origin === stagingOrigin;
1119
+ } catch {
1120
+ return false;
1121
+ }
1122
+ }, "Expected a path on the staging host"))();
1123
+ var stagingLinkSchema = /* @__PURE__ */ (() => z5.object({
1124
+ url: z5.string().url(),
1125
+ expiresAt: z5.number()
1126
+ }))();
1127
+ var buildSnapshotSchema = /* @__PURE__ */ (() => z5.object({
1128
+ builds: z5.array(hostedBuildSchema),
1129
+ current: hostedBuildSchema.nullable(),
1130
+ selected: hostedBuildSchema.nullable(),
1131
+ logs: z5.string()
1132
+ }))();
1133
+ var assetPathSchema = /* @__PURE__ */ (() => z5.string().max(512).refine(
1134
+ (path) => path.startsWith("/") && // oxlint-disable-next-line no-control-regex -- Asset paths must reject control characters.
1135
+ !/[\\\u0000-\u001f?#%]/.test(path) && path.slice(1).split("/").every((part) => part.length > 0 && !part.startsWith(".")),
1136
+ "Expected a public asset path without hidden segments"
1137
+ ))();
1138
+ var base64Schema = /* @__PURE__ */ (() => z5.string().regex(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/))();
1139
+ var stagedDeploymentLimits = {
1140
+ /** Bytes of JSON, uncompressed. */
1141
+ size: 64e6,
1142
+ /** Bytes of the Brotli-compressed object. */
1143
+ compressedSize: 1e7
1144
+ };
1145
+ var stagedDeploymentSchema = /* @__PURE__ */ (() => z5.object({
1146
+ encoding: z5.literal("br"),
1147
+ sha256: z5.string().regex(/^[0-9a-f]{64}$/),
1148
+ compressedSize: z5.number().int().positive().max(limits.stagedDeployment.compressedSize),
1149
+ size: z5.number().int().positive().max(limits.stagedDeployment.size)
1150
+ }).strict())();
1151
+ var stagedDeploymentContentSchema = /* @__PURE__ */ (() => stagedDeploymentSchema.extend({
1152
+ content: z5.string().max(Math.ceil(limits.stagedDeployment.compressedSize / 3) * 4)
1153
+ }).strict())();
1154
+ var stagedDeploymentKey = (build, sha256) => `builds/${build}/deployment/${sha256}.br`;
1155
+ var artifactFields = /* @__PURE__ */ (() => ({
1156
+ routing: appRoutingSchema,
1157
+ worker: z5.object({
1158
+ ...workerSettings,
1159
+ migrations: appMigrationsSchema.optional(),
1160
+ modules: z5.array(
1161
+ z5.object({
1162
+ path: outputPathSchema.refine((path) => path !== "metadata"),
1163
+ type: z5.enum([
1164
+ "application/javascript+module",
1165
+ "application/wasm",
1166
+ "text/plain",
1167
+ "application/octet-stream"
1168
+ ]),
1169
+ content: base64Schema.max(14e6)
1170
+ }).strict()
1171
+ ).min(1).max(500)
1172
+ }).strict().superRefine(distinctBindings).optional(),
1173
+ assets: z5.array(
1174
+ z5.object({
1175
+ path: assetPathSchema,
1176
+ content: base64Schema.max(14e6),
1177
+ size: z5.number().int().min(0).max(1e7)
1178
+ }).strict()
1179
+ ).max(500)
1180
+ }))();
1181
+ var inlineCode = () => z5.unknown().optional().transform((value) => value);
1182
+ var buildArtifactsSchema = /* @__PURE__ */ (() => z5.discriminatedUnion("format", [
1183
+ z5.object({
1184
+ format: z5.literal(1),
1185
+ ...artifactFields,
1186
+ quests: inlineCode(),
1187
+ catalog: inlineCode()
1188
+ }).strict(),
1189
+ z5.object({
1190
+ format: z5.literal(2),
1191
+ ...artifactFields,
1192
+ deployment: stagedDeploymentSchema,
1193
+ images: z5.array(imageAssetArtifactSchema).max(10)
1194
+ }).strict()
1195
+ ]).superRefine((value, ctx) => {
1196
+ if (value.worker) {
1197
+ const modules = value.worker.modules;
1198
+ for (const name of Object.keys(value.worker.migrations ?? {})) {
1199
+ if (!value.worker.storage?.sql[name]?.migrations) {
1200
+ ctx.addIssue({
1201
+ code: "custom",
1202
+ message: `Migrations for undeclared SQL store ${name}`
1203
+ });
1204
+ }
1205
+ }
1206
+ if (new Set(modules.map((m) => m.path)).size !== modules.length) {
1207
+ ctx.addIssue({
1208
+ code: "custom",
1209
+ message: "Duplicate Worker module paths"
1210
+ });
1211
+ }
1212
+ if (!modules.some(
1213
+ (m) => m.path === value.worker?.main && m.type === "application/javascript+module"
1214
+ )) {
1215
+ ctx.addIssue({
1216
+ code: "custom",
1217
+ message: "Worker entry module is missing"
1218
+ });
1219
+ }
1220
+ if (modules.reduce(
1221
+ (sum, m) => sum + m.content.length * 3 / 4 - (m.content.endsWith("==") ? 2 : m.content.endsWith("=") ? 1 : 0),
1222
+ 0
1223
+ ) > 1e7) {
1224
+ ctx.addIssue({
1225
+ code: "custom",
1226
+ message: "Worker modules exceed 10 MB"
1227
+ });
1228
+ }
1229
+ }
1230
+ if (new Set(value.assets.map((a) => a.path)).size !== value.assets.length) {
1231
+ ctx.addIssue({ code: "custom", message: "Duplicate asset paths" });
1232
+ }
1233
+ if (!value.worker && !value.assets.some((a) => a.path === "/index.html")) {
1234
+ ctx.addIssue({
1235
+ code: "custom",
1236
+ message: "Build must include index.html"
1237
+ });
1238
+ }
1239
+ if (value.assets.reduce((sum, a) => sum + a.size, 0) > 1e7) {
1240
+ ctx.addIssue({ code: "custom", message: "Staging assets exceed 10 MB" });
1241
+ }
1242
+ }))();
1243
+
1244
+ // src/identity-integration.ts
1245
+ import * as z6 from "zod";
1246
+ var identityIntegrationInputSchema = /* @__PURE__ */ (() => z6.object({
1247
+ name: z6.string().trim().min(1).max(80),
1248
+ origin: z6.string().url().superRefine((value, context) => {
1249
+ const url = new URL(value);
1250
+ if (url.protocol !== "https:") {
1251
+ context.addIssue({ code: "custom", message: "Use an HTTPS origin." });
1252
+ } else if (url.origin !== value) {
1253
+ context.addIssue({
1254
+ code: "custom",
1255
+ message: `Use the exact origin ${url.origin}, without a path, query or trailing slash.`
1256
+ });
1257
+ }
1258
+ }),
1259
+ /**
1260
+ * The identity kind this integration owns in the project and environment, such as
1261
+ * `app:game`. Each member it signs in gets the exchanged subject as an identity of this
1262
+ * kind, which tracker attribution and `ctx.member.identities()` read. Its kind cannot change.
1263
+ * Omit it for an integration that only signs members in.
1264
+ *
1265
+ * A kind belongs to the integration that first claimed it, also after that integration is
1266
+ * disconnected. A new integration takes a kind that already has identities only by adopting
1267
+ * them with `adoptIdentitiesFrom`.
1268
+ */
1269
+ identityKind: appIdentityKindSchema.optional(),
1270
+ /**
1271
+ * Adopt the identities of a disconnected integration's `identityKind`: its ID, as
1272
+ * `identityIntegrations.kinds()` lists it. Adopt only when this app's user IDs mean the same
1273
+ * users as that integration's, because each one then signs in as the member that ID is linked
1274
+ * to. Needs `reason`, which the audit log keeps.
1275
+ */
1276
+ adoptIdentitiesFrom: z6.string().uuid().optional(),
1277
+ /** Why the identities are adopted; required with `adoptIdentitiesFrom`. */
1278
+ reason: z6.string().trim().min(1).max(500).optional(),
1279
+ /** Days until the first secret expires. Omit it for a key that never expires. */
1280
+ expiresInDays: z6.number().int().min(1).max(3650).optional()
1281
+ }).strict().refine(
1282
+ (input) => !input.adoptIdentitiesFrom || input.identityKind,
1283
+ "Adopting identities needs the identityKind they have"
1284
+ ).refine(
1285
+ (input) => !input.adoptIdentitiesFrom === !input.reason,
1286
+ "Give a reason when adopting identities, and only then"
1287
+ ))();
1288
+ var identityIntegrationSchema = /* @__PURE__ */ (() => z6.object({
1289
+ ...authScopeSchema.shape,
1290
+ id: z6.string().uuid(),
1291
+ name: z6.string(),
1292
+ origin: z6.string(),
1293
+ /**
1294
+ * When the integration's last working secret expires: 8640000000000000 (the latest date
1295
+ * JavaScript represents) when one never does.
1296
+ *
1297
+ * @deprecated Read `secrets`, which gives each secret's own expiry.
1298
+ */
1299
+ expiresAt: z6.number(),
1300
+ /** The integration's working secrets, oldest first. Any of them authenticates it. */
1301
+ secrets: z6.array(credentialSecretSchema).default([]),
1302
+ /** The latest use of any of its secrets, revoked ones included; null when none was used. */
1303
+ lastUsedAt: z6.number().nullable().default(null),
1304
+ /** The identity kind the integration owns; null when it only signs members in. */
1305
+ identityKind: openIdentityKindSchema.nullable().default(null),
1306
+ /**
1307
+ * Whether the app's server may vouch for its members' accounts when it signs them in
1308
+ * (`accounts` on the exchange). False in Relay versions without it.
1309
+ */
1310
+ vouchesAccounts: z6.boolean().default(false)
1311
+ }))();
1312
+ var identityIntegrationSecretSchema = /* @__PURE__ */ (() => identityIntegrationSchema.extend(
1313
+ {
1314
+ token: z6.string()
1315
+ }
1316
+ ))();
1317
+ var identityIntegrationAppSecretSchema = /* @__PURE__ */ (() => identityIntegrationSchema.extend({ appSecret: appSecretSchema }))();
1318
+ var identityKindClaimSchema = /* @__PURE__ */ (() => z6.object({
1319
+ kind: openIdentityKindSchema,
1320
+ /** The owning integration's ID; it stays after the integration is disconnected. */
1321
+ integration: z6.string(),
1322
+ /** The owning integration's name when it claimed or adopted the kind. */
1323
+ integrationName: z6.string(),
1324
+ /** Whether the owning integration is still connected. */
1325
+ connected: z6.boolean(),
1326
+ /** Linked identities of the kind; adopting them is required to reuse the kind. */
1327
+ linked: z6.number().int().nonnegative(),
1328
+ /** Identities an operator unlinked. */
1329
+ unlinked: z6.number().int().nonnegative(),
1330
+ claimedAt: z6.number().int().nonnegative()
1331
+ }))();
1332
+ var identityIntegrationAccountVouchingInputSchema = /* @__PURE__ */ (() => z6.object({
1333
+ enabled: z6.boolean(),
1334
+ reason: z6.string().trim().min(1).max(500),
1335
+ actionId: identifier.optional()
1336
+ }).strict())();
1337
+ var vouchedProviders = ["x", "telegram", "discord"];
1338
+ var participantExchangeAccountsSchema = /* @__PURE__ */ (() => z6.array(memberImportVouchedAccountSchema).max(20).refine(
1339
+ (accounts) => vouchedProviders.every(
1340
+ (kind) => accounts.filter((entry) => entry.kind === kind).length <= 1
1341
+ ),
1342
+ "Vouch for at most one X, Telegram and Discord account each"
1343
+ ))();
1344
+ var participantExchangeSchema = /* @__PURE__ */ (() => z6.object({
1345
+ subject: z6.string().min(1).max(200),
1346
+ previousToken: z6.string().max(200).optional(),
1347
+ /**
1348
+ * Accounts the app vouches belong to this member, attached on the organization's word like an
1349
+ * import's. Needs an integration with `vouchesAccounts`; otherwise the exchange is refused with
1350
+ * `ACCOUNT_VOUCHING_OFF`.
1351
+ */
1352
+ accounts: participantExchangeAccountsSchema.optional()
1353
+ }).strict())();
1354
+ var participantExchangeAccountResultSchema = /* @__PURE__ */ (() => z6.object({
1355
+ account: memberImportVouchedAccountSchema,
1356
+ status: z6.string(),
1357
+ code: z6.string().optional(),
1358
+ message: z6.string().optional()
1359
+ }))();
1360
+ var participantExchangeResultSchema = /* @__PURE__ */ (() => exchangeResultSchema.extend({
1361
+ accounts: z6.array(participantExchangeAccountResultSchema).optional()
1362
+ }))();
1363
+ var identityIntegrationKeySchema = /* @__PURE__ */ (() => z6.object({
1364
+ id: z6.string(),
1365
+ name: z6.string(),
1366
+ organization: z6.string(),
1367
+ project: z6.string(),
1368
+ environment: z6.string(),
1369
+ origin: z6.string(),
1370
+ identityKind: openIdentityKindSchema.nullable().default(null),
1371
+ vouchesAccounts: z6.boolean().default(false),
1372
+ secretExpiresAt: z6.number().nullable().default(null),
1373
+ appOrigins: z6.array(z6.string()).default([])
1374
+ }))();
1375
+ var accountVouchedBySchema = /* @__PURE__ */ (() => z6.object({
1376
+ /** The integration's ID; it stays after the integration is disconnected. */
1377
+ integration: z6.string(),
1378
+ /** The integration's name when it vouched for the account. */
1379
+ integrationName: z6.string()
1380
+ }))();
1381
+
1382
+ export {
1383
+ credentialSecretSchema,
1384
+ credentialSecretInputSchema,
1385
+ memberImportIdentitySchema,
1386
+ memberImportAccountSchema,
1387
+ memberImportVouchedAccountSchema,
1388
+ identityReferenceSchema,
1389
+ memberImportActionSchema,
1390
+ memberImportReferralSchema,
1391
+ memberImportConsentSchema,
1392
+ memberImportRowSchema,
1393
+ memberImportFullRowSchema,
1394
+ memberImportCreateSchema,
1395
+ memberImportRowsInputSchema,
1396
+ memberImportFullRowsInputSchema,
1397
+ MemberImportRefusalCode,
1398
+ memberImportRefusalSchema,
1399
+ memberImportRowResultSchema,
1400
+ memberImportRowPageSchema,
1401
+ memberImportRowQuerySchema,
1402
+ memberImportSummarySchema,
1403
+ memberImportCommandSchema,
1404
+ memberImportRevertInputSchema,
1405
+ memberImportRevertOutcomeSchema,
1406
+ memberImportRevertSchema,
1407
+ MemberImportState,
1408
+ memberImportSchema,
1409
+ memberImportPageSchema,
1410
+ memberImportListQuerySchema,
1411
+ APP_SCHEDULE_LIMIT,
1412
+ APP_SCHEDULE_MIN_INTERVAL,
1413
+ APP_SCHEDULE_TIMEOUT,
1414
+ appScheduleNameSchema,
1415
+ appSchedulePathSchema,
1416
+ appScheduleSchema,
1417
+ appSchedulesSchema,
1418
+ nextScheduleRun,
1419
+ appScheduleStateSchema,
1420
+ appScheduleStateInputSchema,
1421
+ APP_SCHEDULE_RESULT_BYTES,
1422
+ appScheduleDiagnosticSchema,
1423
+ appScheduleResultSchema,
1424
+ scheduleResult,
1425
+ appScheduleRunSchema,
1426
+ appScheduleRunsSchema,
1427
+ appScheduleListSchema,
1428
+ scheduledInvocationSchema,
1429
+ verifyScheduledRequest,
1430
+ starters,
1431
+ offeredStarterSchema,
1432
+ starterTemplates,
1433
+ starterIdSchema,
1434
+ appRoutingSchema,
1435
+ APP_SECRET_LIMIT,
1436
+ APP_KV_LIMIT,
1437
+ APP_SQL_LIMIT,
1438
+ APP_MIGRATION_LIMIT,
1439
+ APP_MIGRATION_FILE_BYTES,
1440
+ APP_MIGRATION_TOTAL_BYTES,
1441
+ appSecretNameSchema,
1442
+ appSecretValueSchema,
1443
+ appSecretInputSchema,
1444
+ appSecretSchema,
1445
+ appSecretDeclarationSchema,
1446
+ appSecretDeclarationsSchema,
1447
+ appSecretListSchema,
1448
+ hostedAppSecretsSchema,
1449
+ appStorageSchema,
1450
+ appStorageKindSchema,
1451
+ appStorageListSchema,
1452
+ APP_STORAGE_ROW_LIMIT,
1453
+ APP_STORAGE_PREVIEW_CHARACTERS,
1454
+ appStorageCellSchema,
1455
+ appStorageTablesSchema,
1456
+ appStorageRowsSchema,
1457
+ appStorageKeysSchema,
1458
+ appStorageValueSchema,
1459
+ APP_STORAGE_CELL_CHARACTERS,
1460
+ appStorageCellPageSchema,
1461
+ appStorageSqlClearSchema,
1462
+ appStorageKvClearSchema,
1463
+ appStorageSqlClearResultSchema,
1464
+ appStorageKvClearResultSchema,
1465
+ appMigrationNameSchema,
1466
+ compareAppMigrations,
1467
+ hostedAppSchema,
1468
+ repositorySchema,
1469
+ repositoryCreateSchema,
1470
+ createRepositorySchema,
1471
+ deviceStartSchema,
1472
+ deviceRedeemSchema,
1473
+ deviceApproveSchema,
1474
+ commitSchema,
1475
+ stageRequestSchema,
1476
+ buildIdentitySchema,
1477
+ buildPhaseSchema,
1478
+ buildStatusSchema,
1479
+ hostedBuildSchema,
1480
+ liveAppSchema,
1481
+ customDomainStateSchema,
1482
+ customDomainRecordSchema,
1483
+ customDomainSchema,
1484
+ customDomainListSchema,
1485
+ customDomainInputSchema,
1486
+ stagingAccessModeSchema,
1487
+ stagingAccessSchema,
1488
+ stagingAccessInputSchema,
1489
+ stagingPathSchema,
1490
+ stagingLinkSchema,
1491
+ buildSnapshotSchema,
1492
+ assetPathSchema,
1493
+ stagedDeploymentLimits,
1494
+ stagedDeploymentSchema,
1495
+ stagedDeploymentContentSchema,
1496
+ stagedDeploymentKey,
1497
+ buildArtifactsSchema,
1498
+ identityIntegrationInputSchema,
1499
+ identityIntegrationSchema,
1500
+ identityIntegrationSecretSchema,
1501
+ identityIntegrationAppSecretSchema,
1502
+ identityKindClaimSchema,
1503
+ identityIntegrationAccountVouchingInputSchema,
1504
+ participantExchangeAccountsSchema,
1505
+ participantExchangeSchema,
1506
+ participantExchangeAccountResultSchema,
1507
+ participantExchangeResultSchema,
1508
+ identityIntegrationKeySchema,
1509
+ accountVouchedBySchema
1510
+ };