@domino-sdk/relay 0.15.0 → 0.17.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.
@@ -160,23 +160,112 @@ var discordMemberSchema = z5.object({
160
160
  pending: z5.boolean()
161
161
  });
162
162
 
163
- // src/quiz.ts
163
+ // src/submission-input.ts
164
164
  import { z as z6 } from "zod";
165
- var quizId = z6.string().regex(/^[a-zA-Z0-9_-]+$/).max(100);
166
- var quizChoiceSchema = z6.object({ id: quizId, label: z6.string().trim().min(1).max(500) }).strict();
167
- var quizQuestionSchema = z6.object({
165
+ var textOptionsSchema = z6.object({
166
+ required: z6.boolean().default(true),
167
+ minLength: z6.number().int().min(0).max(1e4).default(1),
168
+ maxLength: z6.number().int().min(1).max(1e4).default(1e4)
169
+ }).strict().refine(
170
+ (v) => v.minLength <= v.maxLength,
171
+ "minLength must not exceed maxLength"
172
+ );
173
+ var hostSchema = z6.string().min(1).max(253).refine((host) => {
174
+ if (!/^[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?$/i.test(host) || host.includes("..")) {
175
+ return false;
176
+ }
177
+ try {
178
+ const url = new URL(`https://${host}`);
179
+ return url.hostname === host.toLowerCase() && !url.port && !url.username && !url.password && url.pathname === "/" && !url.search && !url.hash;
180
+ } catch {
181
+ return false;
182
+ }
183
+ }, "Use a hostname without a scheme, path, port, or wildcard");
184
+ var urlOptionsSchema = z6.object({
185
+ required: z6.boolean().default(true),
186
+ allowedHosts: z6.array(hostSchema).min(1).max(100).optional()
187
+ }).strict();
188
+ var textEvidenceSchema = z6.object({ kind: z6.literal("text"), value: z6.string().max(1e4) }).strict();
189
+ var urlEvidenceSchema = z6.object({ kind: z6.literal("url"), value: z6.string().max(2048) }).strict();
190
+ var valueEvidenceSchema = z6.discriminatedUnion("kind", [
191
+ textEvidenceSchema,
192
+ urlEvidenceSchema
193
+ ]);
194
+ function validateSubmissionValue(input, contract) {
195
+ const maximum = input.kind === "text" ? 1e4 : 2048;
196
+ if (input.value.length > maximum) {
197
+ return `Enter no more than ${maximum} characters`;
198
+ }
199
+ if (input.kind !== contract.input) {
200
+ return `This quest requires ${contract.input} input`;
201
+ }
202
+ if (!input.value.trim()) {
203
+ return contract.constraints.required ? "This field is required" : null;
204
+ }
205
+ if (contract.input === "text") {
206
+ if (input.value.length < contract.constraints.minLength) {
207
+ return `Enter at least ${contract.constraints.minLength} characters`;
208
+ }
209
+ if (input.value.length > contract.constraints.maxLength) {
210
+ return `Enter no more than ${contract.constraints.maxLength} characters`;
211
+ }
212
+ return null;
213
+ }
214
+ const url = parseHttpUrl(input.value);
215
+ if (!url) {
216
+ return "Enter a valid HTTP or HTTPS URL without credentials";
217
+ }
218
+ if (contract.constraints.allowedHosts && !contract.constraints.allowedHosts.some(
219
+ (host) => host.toLowerCase() === url.hostname.toLowerCase()
220
+ )) {
221
+ return `Use a URL hosted on: ${contract.constraints.allowedHosts.join(", ")}`;
222
+ }
223
+ return null;
224
+ }
225
+ function parseHttpUrl(value) {
226
+ if (value !== value.trim() || /[\\\s]/.test(value) || !/^https?:\/\//i.test(value)) {
227
+ return null;
228
+ }
229
+ try {
230
+ const url = new URL(value);
231
+ return ["http:", "https:"].includes(url.protocol) && !url.username && !url.password ? url : null;
232
+ } catch {
233
+ return null;
234
+ }
235
+ }
236
+ function xPostId(value) {
237
+ const url = parseHttpUrl(value);
238
+ if (!url || url.port || ![
239
+ "x.com",
240
+ "www.x.com",
241
+ "twitter.com",
242
+ "www.twitter.com",
243
+ "mobile.twitter.com"
244
+ ].includes(url.hostname)) {
245
+ return null;
246
+ }
247
+ return /^\/(?:[A-Za-z0-9_]+|i\/web)\/status\/([0-9]{1,20})\/?$/.exec(
248
+ url.pathname
249
+ )?.[1] ?? null;
250
+ }
251
+
252
+ // src/quiz.ts
253
+ import { z as z7 } from "zod";
254
+ var quizId = z7.string().regex(/^[a-zA-Z0-9_-]+$/).max(100);
255
+ var quizChoiceSchema = z7.object({ id: quizId, label: z7.string().trim().min(1).max(500) }).strict();
256
+ var quizQuestionSchema = z7.object({
168
257
  id: quizId,
169
- prompt: z6.string().trim().min(1).max(1e3),
170
- choices: z6.array(quizChoiceSchema).min(2).max(8).refine(
258
+ prompt: z7.string().trim().min(1).max(1e3),
259
+ choices: z7.array(quizChoiceSchema).min(2).max(8).refine(
171
260
  (choices) => new Set(choices.map((choice) => choice.id)).size === choices.length,
172
261
  "Choice IDs must be unique"
173
262
  )
174
263
  }).strict();
175
- var quizQuestionsSchema = z6.array(quizQuestionSchema).min(1).max(20).refine(
264
+ var quizQuestionsSchema = z7.array(quizQuestionSchema).min(1).max(20).refine(
176
265
  (questions) => new Set(questions.map((question) => question.id)).size === questions.length,
177
266
  "Question IDs must be unique"
178
267
  );
179
- var quizContentSchema = z6.array(
268
+ var quizContentSchema = z7.array(
180
269
  quizQuestionSchema.extend({ correct: quizId }).refine(
181
270
  (question) => question.choices.some((choice) => choice.id === question.correct),
182
271
  "Choose a correct answer from the available choices"
@@ -187,48 +276,48 @@ var quizContentSchema = z6.array(
187
276
  );
188
277
 
189
278
  // src/schema.ts
190
- import { z as z9 } from "zod";
279
+ import { z as z10 } from "zod";
191
280
 
192
281
  // src/settings.ts
193
- import { z as z8 } from "zod";
282
+ import { z as z9 } from "zod";
194
283
 
195
284
  // src/resources.ts
196
- import { z as z7 } from "zod";
197
- var channelSourceSchema = z7.object({
198
- provider: z7.literal("discord"),
199
- resource: z7.literal("channel"),
200
- types: z7.array(z7.enum(["text", "announcement"])).min(1)
285
+ import { z as z8 } from "zod";
286
+ var channelSourceSchema = z8.object({
287
+ provider: z8.literal("discord"),
288
+ resource: z8.literal("channel"),
289
+ types: z8.array(z8.enum(["text", "announcement"])).min(1)
201
290
  }).strict();
202
- var resourceSourceSchema = z7.union([
203
- z7.object({
204
- provider: z7.literal("domino"),
205
- resource: z7.literal("point-ledger")
291
+ var resourceSourceSchema = z8.union([
292
+ z8.object({
293
+ provider: z8.literal("domino"),
294
+ resource: z8.literal("point-ledger")
206
295
  }).strict(),
207
296
  channelSourceSchema,
208
- z7.object({
209
- provider: z7.literal("discord"),
210
- resource: z7.literal("role"),
211
- assignable: z7.boolean().default(false)
297
+ z8.object({
298
+ provider: z8.literal("discord"),
299
+ resource: z8.literal("role"),
300
+ assignable: z8.boolean().default(false)
212
301
  }).strict()
213
302
  ]);
214
- var resourceRequestSchema = z7.object({
303
+ var resourceRequestSchema = z8.object({
215
304
  source: resourceSourceSchema,
216
- query: z7.string().max(100).optional(),
217
- cursor: z7.string().regex(/^\d{1,6}$/).optional(),
218
- ids: z7.array(z7.string().min(1).max(100)).max(50).optional()
305
+ query: z8.string().max(100).optional(),
306
+ cursor: z8.string().regex(/^\d{1,6}$/).optional(),
307
+ ids: z8.array(z8.string().min(1).max(100)).max(50).optional()
219
308
  }).strict();
220
- var resourceOptionsSchema = z7.object({
221
- revision: z7.number().int(),
222
- options: z7.array(
223
- z7.object({
224
- id: z7.string(),
225
- label: z7.string(),
226
- description: z7.string().optional(),
227
- group: z7.string().optional(),
228
- disabledReason: z7.string().optional()
309
+ var resourceOptionsSchema = z8.object({
310
+ revision: z8.number().int(),
311
+ options: z8.array(
312
+ z8.object({
313
+ id: z8.string(),
314
+ label: z8.string(),
315
+ description: z8.string().optional(),
316
+ group: z8.string().optional(),
317
+ disabledReason: z8.string().optional()
229
318
  })
230
319
  ),
231
- cursor: z7.string().nullable()
320
+ cursor: z8.string().nullable()
232
321
  });
233
322
  var discord = {
234
323
  roles(options = {}) {
@@ -252,49 +341,49 @@ var pointLedgers = () => ({
252
341
  });
253
342
 
254
343
  // src/settings.ts
255
- var instant = z8.iso.datetime({ offset: true }).transform((value) => new Date(value).toISOString());
256
- var resourceId = z8.union([z8.literal(""), z8.string().regex(/^\S{1,200}$/)]);
257
- var base = { label: z8.string().min(1), description: z8.string().optional() };
258
- var settingFieldSchema = z8.discriminatedUnion("kind", [
259
- z8.object({ ...base, kind: z8.literal("point-ledger"), default: identifier }).strict(),
260
- z8.object({ ...base, kind: z8.literal("datetime"), default: instant }).strict(),
261
- z8.object({
344
+ var instant = z9.iso.datetime({ offset: true }).transform((value) => new Date(value).toISOString());
345
+ var resourceId = z9.union([z9.literal(""), z9.string().regex(/^\S{1,200}$/)]);
346
+ var base = { label: z9.string().min(1), description: z9.string().optional() };
347
+ var settingFieldSchema = z9.discriminatedUnion("kind", [
348
+ z9.object({ ...base, kind: z9.literal("point-ledger"), default: identifier }).strict(),
349
+ z9.object({ ...base, kind: z9.literal("datetime"), default: instant }).strict(),
350
+ z9.object({
262
351
  ...base,
263
- kind: z8.literal("resource"),
352
+ kind: z9.literal("resource"),
264
353
  default: resourceId,
265
354
  source: resourceSourceSchema
266
355
  }).strict(),
267
- z8.object({ ...base, kind: z8.literal("quiz"), default: quizContentSchema }).strict(),
268
- z8.object({
356
+ z9.object({ ...base, kind: z9.literal("quiz"), default: quizContentSchema }).strict(),
357
+ z9.object({
269
358
  ...base,
270
- kind: z8.literal("text"),
271
- default: z8.string(),
272
- minLength: z8.number().int().nonnegative(),
273
- maxLength: z8.number().int().positive(),
274
- multiline: z8.boolean()
359
+ kind: z9.literal("text"),
360
+ default: z9.string(),
361
+ minLength: z9.number().int().nonnegative(),
362
+ maxLength: z9.number().int().positive(),
363
+ multiline: z9.boolean()
275
364
  }).strict(),
276
- z8.object({
365
+ z9.object({
277
366
  ...base,
278
- kind: z8.literal("integer"),
279
- default: z8.number().int(),
280
- min: z8.number().int(),
281
- max: z8.number().int()
367
+ kind: z9.literal("integer"),
368
+ default: z9.number().int(),
369
+ min: z9.number().int(),
370
+ max: z9.number().int()
282
371
  }).strict(),
283
- z8.object({ ...base, kind: z8.literal("boolean"), default: z8.boolean() }).strict(),
284
- z8.object({
372
+ z9.object({ ...base, kind: z9.literal("boolean"), default: z9.boolean() }).strict(),
373
+ z9.object({
285
374
  ...base,
286
- kind: z8.literal("choice"),
287
- default: z8.string(),
288
- options: z8.array(z8.string().min(1)).min(1)
375
+ kind: z9.literal("choice"),
376
+ default: z9.string(),
377
+ options: z9.array(z9.string().min(1)).min(1)
289
378
  }).strict()
290
379
  ]);
291
- var settingsFieldsSchema = z8.record(
292
- z8.string().regex(/^[a-zA-Z][a-zA-Z0-9_]*$/),
380
+ var settingsFieldsSchema = z9.record(
381
+ z9.string().regex(/^[a-zA-Z][a-zA-Z0-9_]*$/),
293
382
  settingFieldSchema
294
383
  );
295
- var settingsValuesSchema = z8.record(
296
- z8.string(),
297
- z8.union([z8.string(), z8.number().finite(), z8.boolean(), quizContentSchema])
384
+ var settingsValuesSchema = z9.record(
385
+ z9.string(),
386
+ z9.union([z9.string(), z9.number().finite(), z9.boolean(), quizContentSchema])
298
387
  );
299
388
  var settings = {
300
389
  pointLedger(options) {
@@ -334,19 +423,19 @@ var settings = {
334
423
  maxLength: options.maxLength ?? 2e3,
335
424
  multiline: options.multiline ?? false
336
425
  };
337
- return z8.string().min(field.minLength).max(field.maxLength).default(field.default).meta(field);
426
+ return z9.string().min(field.minLength).max(field.maxLength).default(field.default).meta(field);
338
427
  },
339
428
  integer(options) {
340
- return z8.number().int().min(options.min).max(options.max).default(options.default).meta({ ...options, kind: "integer" });
429
+ return z9.number().int().min(options.min).max(options.max).default(options.default).meta({ ...options, kind: "integer" });
341
430
  },
342
431
  boolean(options) {
343
- return z8.boolean().default(options.default).meta({ ...options, kind: "boolean" });
432
+ return z9.boolean().default(options.default).meta({ ...options, kind: "boolean" });
344
433
  },
345
434
  choice(options) {
346
- return z8.enum(options.options).default(options.default).meta({ ...options, kind: "choice" });
435
+ return z9.enum(options.options).default(options.default).meta({ ...options, kind: "choice" });
347
436
  },
348
437
  object(shape) {
349
- return z8.object(shape).strict();
438
+ return z9.object(shape).strict();
350
439
  }
351
440
  };
352
441
  function parseSettings(fields, input) {
@@ -366,20 +455,20 @@ function parseSettings(fields, input) {
366
455
  shape[key] = quizContentSchema.default(field.default);
367
456
  break;
368
457
  case "text":
369
- shape[key] = z8.string().min(field.minLength).max(field.maxLength).default(field.default);
458
+ shape[key] = z9.string().min(field.minLength).max(field.maxLength).default(field.default);
370
459
  break;
371
460
  case "integer":
372
- shape[key] = z8.number().int().min(field.min).max(field.max).default(field.default);
461
+ shape[key] = z9.number().int().min(field.min).max(field.max).default(field.default);
373
462
  break;
374
463
  case "boolean":
375
- shape[key] = z8.boolean().default(field.default);
464
+ shape[key] = z9.boolean().default(field.default);
376
465
  break;
377
466
  case "choice":
378
- shape[key] = z8.enum(field.options).default(field.default);
467
+ shape[key] = z9.enum(field.options).default(field.default);
379
468
  break;
380
469
  }
381
470
  }
382
- return settingsValuesSchema.parse(z8.object(shape).strict().parse(input));
471
+ return settingsValuesSchema.parse(z9.object(shape).strict().parse(input));
383
472
  }
384
473
  function missingResourceSettings(fields, values) {
385
474
  return Object.entries(fields).filter(([key, field]) => field.kind === "resource" && !values[key]).map(([key]) => key);
@@ -389,38 +478,38 @@ function compatibleSettingKinds(previous, next) {
389
478
  }
390
479
 
391
480
  // src/schema.ts
392
- var pointsRewardSchema = z9.object({
393
- kind: z9.literal("points").default("points"),
481
+ var pointsRewardSchema = z10.object({
482
+ kind: z10.literal("points").default("points"),
394
483
  balance: identifier,
395
- amount: z9.number().int().min(0).max(1e4)
484
+ amount: z10.number().int().min(0).max(1e4)
396
485
  }).strict();
397
- var tieredRewardDefinitionSchema = z9.object({
486
+ var tieredRewardDefinitionSchema = z10.object({
398
487
  id: identifier,
399
- title: z9.string().min(1).max(120),
400
- tiers: z9.array(
401
- z9.object({ id: identifier, title: z9.string().min(1).max(120) }).strict()
488
+ title: z10.string().min(1).max(120),
489
+ tiers: z10.array(
490
+ z10.object({ id: identifier, title: z10.string().min(1).max(120) }).strict()
402
491
  ).min(1).max(20).refine(
403
492
  (tiers) => new Set(tiers.map((t) => t.id)).size === tiers.length,
404
493
  "Tier IDs must be unique"
405
494
  ),
406
- inventory: z9.object({ kind: z9.literal("untracked") }).strict(),
407
- fulfillment: z9.object({ kind: z9.literal("staff-handover") }).strict()
495
+ inventory: z10.object({ kind: z10.literal("untracked") }).strict(),
496
+ fulfillment: z10.object({ kind: z10.literal("staff-handover") }).strict()
408
497
  }).strict();
409
- var tierRewardSchema = z9.object({
410
- kind: z9.literal("tier"),
498
+ var tierRewardSchema = z10.object({
499
+ kind: z10.literal("tier"),
411
500
  reward: tieredRewardDefinitionSchema,
412
501
  tier: identifier
413
502
  }).strict().refine(
414
503
  (value) => value.reward.tiers.some((t) => t.id === value.tier),
415
504
  "Unknown reward tier"
416
505
  );
417
- var integrationRewardSchema = z9.object({
418
- kind: z9.literal("integration"),
419
- provider: z9.literal("discord"),
420
- action: z9.literal("grant-role"),
421
- roleId: z9.string().regex(/^[0-9]{1,20}$/)
506
+ var integrationRewardSchema = z10.object({
507
+ kind: z10.literal("integration"),
508
+ provider: z10.literal("discord"),
509
+ action: z10.literal("grant-role"),
510
+ roleId: z10.string().regex(/^[0-9]{1,20}$/)
422
511
  }).strict();
423
- var rewardSchema = z9.union([
512
+ var rewardSchema = z10.union([
424
513
  pointsRewardSchema,
425
514
  tierRewardSchema,
426
515
  integrationRewardSchema
@@ -431,49 +520,66 @@ function rewardKey(reward) {
431
520
  }
432
521
  return reward.kind === "points" ? "points:" + reward.balance : "tier:" + reward.reward.id;
433
522
  }
434
- var triggerSchema = z9.union([
435
- z9.object({
436
- kind: z9.literal("manual"),
437
- input: z9.enum(["photo", "quiz", "none"]),
438
- actor: z9.enum(["member", "staff"]).optional()
523
+ var triggerSchema = z10.union([
524
+ z10.object({
525
+ kind: z10.literal("manual"),
526
+ input: z10.literal("text"),
527
+ constraints: textOptionsSchema,
528
+ actor: z10.enum(["member", "staff"]).optional()
439
529
  }).strict(),
440
- z9.object({
441
- kind: z9.literal("automatic"),
530
+ z10.object({
531
+ kind: z10.literal("manual"),
532
+ input: z10.literal("url"),
533
+ constraints: urlOptionsSchema,
534
+ actor: z10.enum(["member", "staff"]).optional()
535
+ }).strict(),
536
+ z10.object({
537
+ kind: z10.literal("manual"),
538
+ input: z10.enum(["photo", "quiz", "none"]),
539
+ actor: z10.enum(["member", "staff"]).optional()
540
+ }).strict(),
541
+ z10.object({
542
+ kind: z10.literal("automatic"),
442
543
  observation: observationTriggerSchema.optional()
443
544
  }).strict()
444
545
  ]);
445
- var prerequisiteSchema = z9.object({ quest: identifier, scope: z9.literal("ever") }).strict();
446
- var photoResultSchema = z9.object({
447
- kind: z9.enum(["pass", "fail", "unclear"]),
448
- reason: z9.string().min(1).max(2e3)
546
+ var prerequisiteSchema = z10.object({ quest: identifier, scope: z10.literal("ever") }).strict();
547
+ var photoResultSchema = z10.object({
548
+ kind: z10.enum(["pass", "fail", "unclear"]),
549
+ reason: z10.string().min(1).max(2e3)
449
550
  }).strict();
450
- var decisionSchema = z9.discriminatedUnion("kind", [
451
- z9.object({
452
- kind: z9.literal("accept"),
453
- rewards: z9.array(rewardSchema).max(10),
551
+ var textReviewInputSchema = z10.object({
552
+ text: z10.string().min(1).max(16e3).refine((value) => value.trim().length > 0, "Text must not be blank"),
553
+ criteria: z10.string().trim().min(1).max(2e3)
554
+ }).strict();
555
+ var textResultSchema = photoResultSchema;
556
+ var decisionSchema = z10.discriminatedUnion("kind", [
557
+ z10.object({
558
+ kind: z10.literal("accept"),
559
+ rewards: z10.array(rewardSchema).max(10),
454
560
  completionKey: completionKeySchema.optional()
455
561
  }).strict(),
456
- z9.object({ kind: z9.literal("reject"), reason: z9.string().min(1).max(2e3) }).strict(),
457
- z9.object({
458
- kind: z9.literal("review"),
459
- reason: z9.string().min(1).max(2e3),
460
- rewards: z9.array(rewardSchema).max(10).optional(),
562
+ z10.object({ kind: z10.literal("reject"), reason: z10.string().min(1).max(2e3) }).strict(),
563
+ z10.object({
564
+ kind: z10.literal("review"),
565
+ reason: z10.string().min(1).max(2e3),
566
+ rewards: z10.array(rewardSchema).max(10).optional(),
461
567
  completionKey: completionKeySchema.optional()
462
568
  }).strict()
463
569
  ]);
464
- var reviewModeSchema = z9.enum(["workers-ai"]);
465
- var storedReviewModeSchema = z9.enum([
570
+ var reviewModeSchema = z10.enum(["workers-ai"]);
571
+ var storedReviewModeSchema = z10.enum([
466
572
  "fixture-pass",
467
573
  "fixture-fail",
468
574
  "fixture-unclear",
469
575
  "fixture-error",
470
576
  "workers-ai"
471
577
  ]);
472
- var rewardBundleSchema = z9.array(rewardSchema).max(10).refine(
578
+ var rewardBundleSchema = z10.array(rewardSchema).max(10).refine(
473
579
  (rewards) => new Set(rewards.map(rewardKey)).size === rewards.length,
474
580
  "Use one entry per balance or shared reward"
475
581
  );
476
- var mediaUrlSchema = z9.string().max(2e3).refine((value) => {
582
+ var mediaUrlSchema = z10.string().max(2e3).refine((value) => {
477
583
  if (/^\/(?!\/)[^\\\s]*$/.test(value)) {
478
584
  return true;
479
585
  }
@@ -483,74 +589,74 @@ var mediaUrlSchema = z9.string().max(2e3).refine((value) => {
483
589
  return false;
484
590
  }
485
591
  }, "Use an HTTPS URL or a same-site path beginning with /");
486
- var questPresentationSchema = z9.object({
592
+ var questPresentationSchema = z10.object({
487
593
  quiz: quizQuestionsSchema.optional(),
488
- instructions: z9.string().max(4e3).optional(),
489
- video: z9.object({
594
+ instructions: z10.string().max(4e3).optional(),
595
+ video: z10.object({
490
596
  url: mediaUrlSchema,
491
597
  poster: mediaUrlSchema.optional(),
492
- captions: z9.object({
598
+ captions: z10.object({
493
599
  url: mediaUrlSchema,
494
- language: z9.string().min(2).max(20),
495
- label: z9.string().min(1).max(80)
600
+ language: z10.string().min(2).max(20),
601
+ label: z10.string().min(1).max(80)
496
602
  }).strict().optional()
497
603
  }).strict().optional()
498
604
  }).strict();
499
- var questDescriptionSchema = z9.object({
605
+ var questDescriptionSchema = z10.object({
500
606
  quest: identifier,
501
- runtimeVersion: z9.union([z9.literal(1), z9.literal(2)]).default(1),
502
- title: z9.string().min(1).max(120),
607
+ runtimeVersion: z10.union([z10.literal(1), z10.literal(2)]).default(1),
608
+ title: z10.string().min(1).max(120),
503
609
  presentation: questPresentationSchema.default({}),
504
- integrations: z9.array(integrationProviderSchema).max(10).default([]),
610
+ integrations: z10.array(integrationProviderSchema).max(10).default([]),
505
611
  fields: settingsFieldsSchema,
506
612
  values: settingsValuesSchema,
507
613
  rewards: rewardBundleSchema,
508
- humanReview: z9.boolean(),
614
+ humanReview: z10.boolean(),
509
615
  trigger: triggerSchema,
510
- requires: z9.array(prerequisiteSchema).max(30).default([]),
616
+ requires: z10.array(prerequisiteSchema).max(30).default([]),
511
617
  completion: completionPolicySchema,
512
- visibility: z9.enum(["visible", "hidden"]).default("visible"),
513
- budgets: z9.array(budgetSchema).max(20).default([])
618
+ visibility: z10.enum(["visible", "hidden"]).default("visible"),
619
+ budgets: z10.array(budgetSchema).max(20).default([])
514
620
  }).strict();
515
- var artifactSchema = z9.object({ code: z9.string().min(1).max(1e6) }).strict();
621
+ var artifactSchema = z10.object({ code: z10.string().min(1).max(1e6) }).strict();
516
622
  var releaseSchema = artifactSchema.extend({
517
623
  settings: settingsValuesSchema,
518
624
  provider: reviewModeSchema,
519
625
  expectedRelease: identifier.nullable().optional(),
520
- settingRenames: z9.record(z9.string(), z9.string()).optional()
626
+ settingRenames: z10.record(z10.string(), z10.string()).optional()
521
627
  }).strict();
522
- var batchReleaseSchema = z9.object({ releases: z9.array(releaseSchema).min(1).max(50) }).strict();
523
- var questSettingsInputSchema = z9.object({
628
+ var batchReleaseSchema = z10.object({ releases: z10.array(releaseSchema).min(1).max(50) }).strict();
629
+ var questSettingsInputSchema = z10.object({
524
630
  quest: identifier,
525
631
  expectedRelease: identifier,
526
632
  set: settingsValuesSchema,
527
- reset: z9.array(z9.string())
633
+ reset: z10.array(z10.string())
528
634
  }).strict();
529
635
  var storedReleaseSchema = questDescriptionSchema.extend({
530
636
  key: identifier.optional(),
531
- code: z9.string(),
637
+ code: z10.string(),
532
638
  provider: storedReviewModeSchema,
533
639
  id: identifier,
534
- createdAt: z9.number(),
535
- legacy: z9.boolean().default(false),
536
- origin: z9.object({ typeVersion: identifier }).strict().optional(),
537
- lifecycle: z9.enum(["active", "paused", "archived"]).default("active"),
538
- configuration: z9.object({
640
+ createdAt: z10.number(),
641
+ legacy: z10.boolean().default(false),
642
+ origin: z10.object({ typeVersion: identifier }).strict().optional(),
643
+ lifecycle: z10.enum(["active", "paused", "archived"]).default("active"),
644
+ configuration: z10.object({
539
645
  defaults: settingsValuesSchema,
540
646
  overrides: settingsValuesSchema,
541
- preserved: z9.array(z9.string())
647
+ preserved: z10.array(z10.string())
542
648
  }).strict().optional()
543
649
  });
544
- var legacyReleaseSchema = z9.object({
650
+ var legacyReleaseSchema = z10.object({
545
651
  quest: identifier,
546
- title: z9.string(),
547
- criteria: z9.string(),
548
- humanReview: z9.boolean(),
652
+ title: z10.string(),
653
+ criteria: z10.string(),
654
+ humanReview: z10.boolean(),
549
655
  rewards: rewardBundleSchema,
550
- code: z9.string(),
656
+ code: z10.string(),
551
657
  provider: storedReviewModeSchema,
552
658
  id: identifier,
553
- createdAt: z9.number()
659
+ createdAt: z10.number()
554
660
  }).transform((r) => {
555
661
  const { criteria, ...stored } = r;
556
662
  return storedReleaseSchema.parse({
@@ -562,15 +668,15 @@ var legacyReleaseSchema = z9.object({
562
668
  legacy: true
563
669
  });
564
670
  });
565
- var publishedReleaseSchema = z9.union([
671
+ var publishedReleaseSchema = z10.union([
566
672
  storedReleaseSchema,
567
673
  legacyReleaseSchema
568
674
  ]);
569
- var templateSchema = z9.object({
570
- code: z9.string(),
675
+ var templateSchema = z10.object({
676
+ code: z10.string(),
571
677
  definition: questDescriptionSchema
572
678
  });
573
- var quizAnswersSchema = z9.record(identifier, identifier).refine(
679
+ var quizAnswersSchema = z10.record(identifier, identifier).refine(
574
680
  (answers) => Object.keys(answers).length > 0 && Object.keys(answers).length <= 50,
575
681
  "Provide between 1 and 50 answers"
576
682
  ).transform(
@@ -578,28 +684,33 @@ var quizAnswersSchema = z9.record(identifier, identifier).refine(
578
684
  Object.entries(answers).sort(([a], [b]) => a.localeCompare(b))
579
685
  )
580
686
  );
581
- var quizEvidenceSchema = z9.object({
582
- kind: z9.literal("quiz"),
687
+ var quizEvidenceSchema = z10.object({
688
+ kind: z10.literal("quiz"),
583
689
  release: identifier.optional(),
584
690
  answers: quizAnswersSchema
585
691
  }).strict();
586
- var submitSchema = z9.object({
692
+ var submissionEvidenceSchema = z10.union([
693
+ quizEvidenceSchema,
694
+ textEvidenceSchema,
695
+ urlEvidenceSchema
696
+ ]);
697
+ var submitSchema = z10.object({
587
698
  actionId: identifier,
588
699
  quest: identifier,
589
700
  member: identifier,
590
701
  evidence: identifier.optional(),
591
- input: quizEvidenceSchema.optional(),
702
+ input: submissionEvidenceSchema.optional(),
592
703
  release: identifier.optional(),
593
- faultAfterReview: z9.boolean().optional()
704
+ faultAfterReview: z10.boolean().optional()
594
705
  }).strict();
595
- var attemptSchema = z9.object({
706
+ var attemptSchema = z10.object({
596
707
  id: identifier,
597
708
  release: identifier,
598
709
  quest: identifier,
599
710
  member: identifier,
600
711
  evidence: identifier.nullable(),
601
- input: quizEvidenceSchema.optional(),
602
- status: z9.enum([
712
+ input: submissionEvidenceSchema.optional(),
713
+ status: z10.enum([
603
714
  "queued",
604
715
  "evaluating",
605
716
  "accepted",
@@ -608,70 +719,70 @@ var attemptSchema = z9.object({
608
719
  "needs-review",
609
720
  "failed"
610
721
  ]),
611
- reason: z9.string().nullable(),
612
- retries: z9.number(),
613
- generation: z9.number(),
614
- completion: z9.string().nullable(),
722
+ reason: z10.string().nullable(),
723
+ retries: z10.number(),
724
+ generation: z10.number(),
725
+ completion: z10.string().nullable(),
615
726
  reviewRewards: rewardBundleSchema.nullable().default(null),
616
- createdAt: z9.number()
727
+ createdAt: z10.number()
617
728
  });
618
- var eventSchema = z9.object({
619
- id: z9.number(),
620
- attempt: z9.string().nullable(),
621
- kind: z9.string(),
622
- detail: z9.string(),
623
- actor: z9.string().nullable().default(null),
624
- at: z9.number()
729
+ var eventSchema = z10.object({
730
+ id: z10.number(),
731
+ attempt: z10.string().nullable(),
732
+ kind: z10.string(),
733
+ detail: z10.string(),
734
+ actor: z10.string().nullable().default(null),
735
+ at: z10.number()
625
736
  });
626
- var pickupSelectionSchema = z9.object({
737
+ var pickupSelectionSchema = z10.object({
627
738
  item: identifier,
628
- revision: z9.number().int().nonnegative()
739
+ revision: z10.number().int().nonnegative()
629
740
  }).strict();
630
- var pickupAllocationSchema = z9.object({
741
+ var pickupAllocationSchema = z10.object({
631
742
  item: identifier,
632
- label: z9.string().min(1).max(80)
743
+ label: z10.string().min(1).max(80)
633
744
  }).strict();
634
- var pickupPolicySchema = z9.discriminatedUnion("kind", [
635
- z9.object({ kind: z9.literal("untracked") }).strict(),
636
- z9.object({
637
- kind: z9.literal("at-pickup"),
638
- tiers: z9.array(
639
- z9.object({
745
+ var pickupPolicySchema = z10.discriminatedUnion("kind", [
746
+ z10.object({ kind: z10.literal("untracked") }).strict(),
747
+ z10.object({
748
+ kind: z10.literal("at-pickup"),
749
+ tiers: z10.array(
750
+ z10.object({
640
751
  tier: identifier,
641
- variants: z9.array(pickupAllocationSchema).min(1).max(100)
752
+ variants: z10.array(pickupAllocationSchema).min(1).max(100)
642
753
  }).strict()
643
754
  ).min(1).max(100)
644
755
  }).strict()
645
756
  ]);
646
- var pickupCatalogSchema = z9.object({
757
+ var pickupCatalogSchema = z10.object({
647
758
  reward: tieredRewardDefinitionSchema,
648
- revision: z9.number().int().nonnegative(),
759
+ revision: z10.number().int().nonnegative(),
649
760
  policy: pickupPolicySchema
650
761
  });
651
- var pickupAvailabilitySchema = z9.discriminatedUnion("kind", [
652
- z9.object({ kind: z9.literal("untracked") }).strict(),
653
- z9.object({
654
- kind: z9.literal("at-pickup"),
655
- revision: z9.number().int().nonnegative(),
656
- variants: z9.array(
762
+ var pickupAvailabilitySchema = z10.discriminatedUnion("kind", [
763
+ z10.object({ kind: z10.literal("untracked") }).strict(),
764
+ z10.object({
765
+ kind: z10.literal("at-pickup"),
766
+ revision: z10.number().int().nonnegative(),
767
+ variants: z10.array(
657
768
  pickupAllocationSchema.extend({
658
- available: z9.number().int().nonnegative()
769
+ available: z10.number().int().nonnegative()
659
770
  })
660
771
  )
661
772
  }).strict()
662
773
  ]);
663
- var configurePickupSchema = z9.object({
774
+ var configurePickupSchema = z10.object({
664
775
  reward: identifier,
665
- revision: z9.number().int().nonnegative(),
776
+ revision: z10.number().int().nonnegative(),
666
777
  actionId: identifier,
667
- policy: z9.discriminatedUnion("kind", [
668
- z9.object({ kind: z9.literal("untracked") }).strict(),
669
- z9.object({
670
- kind: z9.literal("at-pickup"),
671
- tiers: z9.array(
672
- z9.object({
778
+ policy: z10.discriminatedUnion("kind", [
779
+ z10.object({ kind: z10.literal("untracked") }).strict(),
780
+ z10.object({
781
+ kind: z10.literal("at-pickup"),
782
+ tiers: z10.array(
783
+ z10.object({
673
784
  tier: identifier,
674
- variants: z9.array(
785
+ variants: z10.array(
675
786
  pickupAllocationSchema.extend({
676
787
  item: identifier.optional()
677
788
  })
@@ -687,151 +798,151 @@ var entitlementBase = {
687
798
  reward: tieredRewardDefinitionSchema,
688
799
  earnedTier: identifier,
689
800
  tier: identifier,
690
- revision: z9.number().int().positive()
801
+ revision: z10.number().int().positive()
691
802
  };
692
- var entitlementSchema = z9.discriminatedUnion("status", [
693
- z9.object({ ...entitlementBase, status: z9.literal("available") }).strict(),
694
- z9.object({
803
+ var entitlementSchema = z10.discriminatedUnion("status", [
804
+ z10.object({ ...entitlementBase, status: z10.literal("available") }).strict(),
805
+ z10.object({
695
806
  ...entitlementBase,
696
- status: z9.literal("handing-over"),
807
+ status: z10.literal("handing-over"),
697
808
  handover: identifier,
698
- startedAt: z9.number(),
809
+ startedAt: z10.number(),
699
810
  allocation: pickupAllocationSchema.optional()
700
811
  }).strict(),
701
- z9.object({
812
+ z10.object({
702
813
  ...entitlementBase,
703
- status: z9.literal("collected"),
814
+ status: z10.literal("collected"),
704
815
  handover: identifier,
705
- startedAt: z9.number(),
816
+ startedAt: z10.number(),
706
817
  allocation: pickupAllocationSchema.optional(),
707
- collectedAt: z9.number()
818
+ collectedAt: z10.number()
708
819
  }).strict()
709
820
  ]);
710
- var beginHandoverSchema = z9.object({
821
+ var beginHandoverSchema = z10.object({
711
822
  actionId: identifier,
712
- revision: z9.number().int().positive(),
823
+ revision: z10.number().int().positive(),
713
824
  selection: pickupSelectionSchema.optional()
714
825
  }).strict();
715
- var confirmHandoverSchema = z9.object({ actionId: identifier, handover: identifier }).strict();
716
- var completionRecordSchema = z9.object({
717
- key: z9.string().default("once"),
826
+ var confirmHandoverSchema = z10.object({ actionId: identifier, handover: identifier }).strict();
827
+ var completionRecordSchema = z10.object({
828
+ key: z10.string().default("once"),
718
829
  id: identifier,
719
830
  quest: identifier,
720
831
  member: identifier
721
832
  });
722
- var questAvailabilitySchema = z9.discriminatedUnion("kind", [
723
- z9.object({
724
- kind: z9.literal("available"),
725
- input: z9.enum(["photo", "quiz", "none"])
833
+ var questAvailabilitySchema = z10.discriminatedUnion("kind", [
834
+ z10.object({
835
+ kind: z10.literal("available"),
836
+ input: z10.enum(["photo", "quiz", "none", "text", "url"])
726
837
  }).strict(),
727
- z9.object({ kind: z9.literal("completed") }).strict(),
728
- z9.object({
729
- kind: z9.literal("locked"),
730
- missing: z9.array(z9.object({ quest: identifier, title: z9.string() })).min(1)
838
+ z10.object({ kind: z10.literal("completed") }).strict(),
839
+ z10.object({
840
+ kind: z10.literal("locked"),
841
+ missing: z10.array(z10.object({ quest: identifier, title: z10.string() })).min(1)
731
842
  }).strict(),
732
- z9.object({ kind: z9.literal("staff-required") }).strict(),
733
- z9.object({
734
- kind: z9.literal("automatic"),
843
+ z10.object({ kind: z10.literal("staff-required") }).strict(),
844
+ z10.object({
845
+ kind: z10.literal("automatic"),
735
846
  observation: observationTriggerSchema.optional()
736
847
  }).strict(),
737
- z9.object({ kind: z9.literal("checking"), attempt: identifier }).strict(),
738
- z9.object({ kind: z9.literal("needs-review"), attempt: identifier }).strict(),
739
- z9.object({ kind: z9.literal("retryable"), attempt: identifier }).strict()
848
+ z10.object({ kind: z10.literal("checking"), attempt: identifier }).strict(),
849
+ z10.object({ kind: z10.literal("needs-review"), attempt: identifier }).strict(),
850
+ z10.object({ kind: z10.literal("retryable"), attempt: identifier }).strict()
740
851
  ]);
741
- var memberProgressSchema = z9.object({
852
+ var memberProgressSchema = z10.object({
742
853
  member: identifier,
743
- quests: z9.array(
744
- z9.object({
854
+ quests: z10.array(
855
+ z10.object({
745
856
  quest: identifier,
746
857
  key: identifier.optional(),
747
858
  release: identifier.optional(),
748
- title: z9.string(),
859
+ title: z10.string(),
749
860
  presentation: questPresentationSchema.default({}),
750
- connections: z9.array(authProviderSchema).default([]),
861
+ connections: z10.array(authProviderSchema).default([]),
751
862
  trigger: triggerSchema,
752
863
  availability: questAvailabilitySchema,
753
- completed: z9.boolean(),
864
+ completed: z10.boolean(),
754
865
  completion: completionPolicySchema.default({ kind: "once" }),
755
866
  streak: streakProgressSchema.nullable().optional(),
756
- completionCount: z9.number().int().nonnegative().default(0),
757
- visibility: z9.enum(["visible", "hidden"]).default("visible"),
758
- missing: z9.array(z9.object({ quest: identifier, title: z9.string() })),
867
+ completionCount: z10.number().int().nonnegative().default(0),
868
+ visibility: z10.enum(["visible", "hidden"]).default("visible"),
869
+ missing: z10.array(z10.object({ quest: identifier, title: z10.string() })),
759
870
  attempt: attemptSchema.nullable()
760
871
  })
761
872
  ),
762
- entitlements: z9.array(entitlementSchema)
873
+ entitlements: z10.array(entitlementSchema)
763
874
  });
764
- var snapshotSchema = z9.object({
765
- releases: z9.array(publishedReleaseSchema),
766
- completions: z9.array(completionRecordSchema),
767
- entitlements: z9.array(entitlementSchema),
768
- attempts: z9.array(attemptSchema),
769
- balances: z9.array(
770
- z9.object({
771
- member: z9.string(),
772
- balance: z9.string(),
773
- earned: z9.number(),
774
- held: z9.number(),
775
- available: z9.number()
875
+ var snapshotSchema = z10.object({
876
+ releases: z10.array(publishedReleaseSchema),
877
+ completions: z10.array(completionRecordSchema),
878
+ entitlements: z10.array(entitlementSchema),
879
+ attempts: z10.array(attemptSchema),
880
+ balances: z10.array(
881
+ z10.object({
882
+ member: z10.string(),
883
+ balance: z10.string(),
884
+ earned: z10.number(),
885
+ held: z10.number(),
886
+ available: z10.number()
776
887
  })
777
888
  ),
778
- events: z9.array(eventSchema)
889
+ events: z10.array(eventSchema)
779
890
  });
780
- var evidenceSchema = z9.object({
891
+ var evidenceSchema = z10.object({
781
892
  id: identifier,
782
893
  member: identifier,
783
- type: z9.enum(["image/jpeg", "image/png"]),
784
- size: z9.number()
894
+ type: z10.enum(["image/jpeg", "image/png"]),
895
+ size: z10.number()
785
896
  });
786
- var errorSchema = z9.object({
787
- error: z9.string(),
788
- code: z9.enum(["stale-quiz", "quest-updated"]).optional(),
789
- missing: z9.array(z9.object({ quest: identifier, title: z9.string() })).optional()
897
+ var errorSchema = z10.object({
898
+ error: z10.string(),
899
+ code: z10.enum(["stale-quiz", "quest-updated", "invalid-submission"]).optional(),
900
+ missing: z10.array(z10.object({ quest: identifier, title: z10.string() })).optional()
790
901
  });
791
- var staffDecisionSchema = z9.object({
902
+ var staffDecisionSchema = z10.object({
792
903
  actionId: identifier,
793
- generation: z9.number().int().nonnegative(),
794
- decision: z9.enum(["accept", "reject"]),
795
- reason: z9.string().trim().min(1).max(2e3)
904
+ generation: z10.number().int().nonnegative(),
905
+ decision: z10.enum(["accept", "reject"]),
906
+ reason: z10.string().trim().min(1).max(2e3)
796
907
  }).strict();
797
- var stockSchema = z9.object({ item: identifier, quantity: z9.number().int().min(0).max(1e4) }).strict();
798
- var reservationSchema = z9.object({
908
+ var stockSchema = z10.object({ item: identifier, quantity: z10.number().int().min(0).max(1e4) }).strict();
909
+ var reservationSchema = z10.object({
799
910
  actionId: identifier,
800
911
  member: identifier,
801
912
  item: identifier,
802
913
  balance: identifier,
803
- price: z9.number().int().positive().max(1e4)
914
+ price: z10.number().int().positive().max(1e4)
804
915
  }).strict();
805
916
  var pageOptions = {
806
- limit: z9.number().int().min(1).max(100).default(25),
807
- cursor: z9.string().min(1).max(4096).optional()
917
+ limit: z10.number().int().min(1).max(100).default(25),
918
+ cursor: z10.string().min(1).max(4096).optional()
808
919
  };
809
- var reviewListSchema = z9.object({
920
+ var reviewListSchema = z10.object({
810
921
  ...pageOptions,
811
922
  member: identifier.optional(),
812
923
  quest: identifier.optional()
813
924
  }).strict();
814
- var memberListSchema = z9.object({
925
+ var memberListSchema = z10.object({
815
926
  ...pageOptions,
816
927
  prefix: identifier.optional()
817
928
  }).strict();
818
- var reviewItemSchema = z9.object({
929
+ var reviewItemSchema = z10.object({
819
930
  attempt: attemptSchema,
820
- title: z9.string(),
821
- checks: z9.array(
822
- z9.object({ criteria: z9.string(), result: photoResultSchema })
931
+ title: z10.string(),
932
+ checks: z10.array(
933
+ z10.object({ criteria: z10.string(), result: photoResultSchema })
823
934
  )
824
935
  });
825
- var reviewPageSchema = z9.object({
826
- items: z9.array(reviewItemSchema).max(100),
827
- nextCursor: z9.string().nullable()
936
+ var reviewPageSchema = z10.object({
937
+ items: z10.array(reviewItemSchema).max(100),
938
+ nextCursor: z10.string().nullable()
828
939
  });
829
- var memberPageSchema = z9.object({
830
- items: z9.array(z9.object({ member: identifier })).max(100),
831
- nextCursor: z9.string().nullable()
940
+ var memberPageSchema = z10.object({
941
+ items: z10.array(z10.object({ member: identifier })).max(100),
942
+ nextCursor: z10.string().nullable()
832
943
  });
833
- var createStockItemSchema = z9.object({ actionId: identifier, name: z9.string().trim().min(1).max(80) }).strict();
834
- var stockItemSchema = z9.object({ id: identifier, name: z9.string() });
944
+ var createStockItemSchema = z10.object({ actionId: identifier, name: z10.string().trim().min(1).max(80) }).strict();
945
+ var stockItemSchema = z10.object({ id: identifier, name: z10.string() });
835
946
 
836
947
  export {
837
948
  communityTimeZoneSchema,
@@ -856,6 +967,13 @@ export {
856
967
  discordMemberInputSchema,
857
968
  discordMessageInputSchema,
858
969
  discordMemberSchema,
970
+ textOptionsSchema,
971
+ urlOptionsSchema,
972
+ textEvidenceSchema,
973
+ urlEvidenceSchema,
974
+ valueEvidenceSchema,
975
+ validateSubmissionValue,
976
+ xPostId,
859
977
  quizChoiceSchema,
860
978
  quizQuestionSchema,
861
979
  quizQuestionsSchema,
@@ -881,6 +999,8 @@ export {
881
999
  triggerSchema,
882
1000
  prerequisiteSchema,
883
1001
  photoResultSchema,
1002
+ textReviewInputSchema,
1003
+ textResultSchema,
884
1004
  decisionSchema,
885
1005
  reviewModeSchema,
886
1006
  storedReviewModeSchema,
@@ -896,6 +1016,7 @@ export {
896
1016
  templateSchema,
897
1017
  quizAnswersSchema,
898
1018
  quizEvidenceSchema,
1019
+ submissionEvidenceSchema,
899
1020
  submitSchema,
900
1021
  attemptSchema,
901
1022
  eventSchema,