@domino-sdk/relay 0.2.0 → 0.4.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.
@@ -1,5 +1,25 @@
1
1
  import {
2
+ leaderboardArtifactSchema,
3
+ leaderboardDefinitionSchema,
4
+ leaderboardPageSchema,
5
+ leaderboardPreviewSchema,
6
+ leaderboardQuerySchema,
7
+ publishedReferralSchema,
8
+ referralAcceptSchema,
9
+ referralArtifactSchema,
10
+ referralDefinitionSchema,
11
+ referralHistorySchema,
12
+ referralSummarySchema
13
+ } from "./chunk-TXL43HL3.js";
14
+ import {
15
+ authScopeSchema,
16
+ exchangeResultSchema,
17
+ sessionSchema
18
+ } from "./chunk-QWRSUSNB.js";
19
+ import {
20
+ accountConnectionSchema,
2
21
  attemptSchema,
22
+ authProviderSchema,
3
23
  entitlementSchema,
4
24
  errorSchema,
5
25
  evidenceSchema,
@@ -19,7 +39,7 @@ import {
19
39
  settingsValuesSchema,
20
40
  snapshotSchema,
21
41
  templateSchema
22
- } from "./chunk-C2KOMNLG.js";
42
+ } from "./chunk-3IQ4KUKF.js";
23
43
 
24
44
  // src/catalog.ts
25
45
  import { z } from "zod";
@@ -322,6 +342,23 @@ function submissions(transport, configuredStore, namespace) {
322
342
  });
323
343
  }
324
344
  const handle = {
345
+ async discard() {
346
+ return store.exclusive(key, async () => {
347
+ await currentSession();
348
+ const record = await read();
349
+ if (!record) return;
350
+ if (record.stage !== "submitted")
351
+ throw new Error(
352
+ "Resume the unfinished submission before starting over."
353
+ );
354
+ const attempt = await claim(record);
355
+ if (attempt.status !== "failed" && attempt.status !== "rejected")
356
+ throw new Error(
357
+ "Only a failed or rejected submission can be discarded."
358
+ );
359
+ await store.write(key, null);
360
+ });
361
+ },
325
362
  async status() {
326
363
  await currentSession();
327
364
  const record = await read();
@@ -442,6 +479,7 @@ function questActions(submission, latest) {
442
479
  kind: "status",
443
480
  view,
444
481
  status: handle.status,
482
+ discard: handle.discard,
445
483
  resume: () => run(handle.resume)
446
484
  };
447
485
  }
@@ -456,6 +494,7 @@ function questActions(submission, latest) {
456
494
  kind: "photo",
457
495
  view,
458
496
  status: handle.status,
497
+ discard: handle.discard,
459
498
  resume: () => run(handle.resume),
460
499
  submit: (file) => run(() => handle.submit(file))
461
500
  };
@@ -470,6 +509,7 @@ function questActions(submission, latest) {
470
509
  kind: "quiz",
471
510
  view,
472
511
  status: handle.status,
512
+ discard: handle.discard,
473
513
  resume: () => run(handle.resume),
474
514
  submit: (answers) => run(() => handle.submit(answers, { release: view.release }))
475
515
  };
@@ -484,6 +524,7 @@ function questActions(submission, latest) {
484
524
  kind: "claim",
485
525
  view,
486
526
  status: handle.status,
527
+ discard: handle.discard,
487
528
  resume: () => run(handle.resume),
488
529
  submit: () => run(handle.submit)
489
530
  };
@@ -572,80 +613,54 @@ function observeProgress(transport, listener, options = {}, onDispose = () => {
572
613
  // src/index.ts
573
614
  import { z as z7 } from "zod";
574
615
 
575
- // src/auth.ts
576
- import { z as z3 } from "zod";
577
- var authScopeSchema = z3.object({
578
- organization: identifier,
579
- project: identifier,
580
- environment: z3.enum(["test", "live"])
581
- }).strict();
582
- var principalSchema = z3.discriminatedUnion("kind", [
583
- z3.object({ kind: z3.literal("member"), member: identifier }).strict(),
584
- z3.object({ kind: z3.literal("staff"), subject: identifier }).strict(),
585
- z3.object({ kind: z3.literal("operator"), subject: identifier }).strict()
586
- ]);
587
- var sessionSchema = authScopeSchema.extend({
588
- id: identifier,
589
- principal: principalSchema,
590
- expiresAt: z3.number()
591
- });
592
- var exchangeSchema = authScopeSchema.extend({
593
- identity: z3.object({ issuer: identifier, subject: z3.string().min(1).max(200) }).strict(),
594
- role: z3.enum(["member", "staff", "operator"])
595
- }).strict();
596
- var exchangeResultSchema = z3.object({
597
- token: z3.string(),
598
- session: sessionSchema
599
- });
600
-
601
616
  // src/wallet.ts
602
- import { z as z4 } from "zod";
603
- var solanaAddressSchema = z4.string().min(32).max(44).regex(/^[1-9A-HJ-NP-Za-km-z]+$/);
604
- var walletConnectionSchema = z4.object({
605
- chain: z4.literal("solana"),
617
+ import { z as z3 } from "zod";
618
+ var solanaAddressSchema = z3.string().min(32).max(44).regex(/^[1-9A-HJ-NP-Za-km-z]+$/);
619
+ var walletConnectionSchema = z3.object({
620
+ chain: z3.literal("solana"),
606
621
  address: solanaAddressSchema,
607
- verifiedAt: z4.number().int().nonnegative(),
608
- revision: z4.number().int().positive()
622
+ verifiedAt: z3.number().int().nonnegative(),
623
+ revision: z3.number().int().positive()
609
624
  }).strict();
610
- var walletChallengeInputSchema = z4.object({
611
- chain: z4.literal("solana"),
625
+ var walletChallengeInputSchema = z3.object({
626
+ chain: z3.literal("solana"),
612
627
  address: solanaAddressSchema
613
628
  }).strict();
614
629
  var walletChallengeSchema = walletChallengeInputSchema.extend({
615
- id: z4.string().uuid(),
616
- message: z4.string(),
617
- expiresAt: z4.number()
630
+ id: z3.string().uuid(),
631
+ message: z3.string(),
632
+ expiresAt: z3.number()
618
633
  });
619
- var walletProofSchema = z4.object({
620
- challenge: z4.string().uuid(),
621
- signature: z4.string().min(64).max(88).regex(/^[1-9A-HJ-NP-Za-km-z]+$/)
634
+ var walletProofSchema = z3.object({
635
+ challenge: z3.string().uuid(),
636
+ signature: z3.string().min(64).max(88).regex(/^[1-9A-HJ-NP-Za-km-z]+$/)
622
637
  }).strict();
623
- var solanaBalanceSchema = z4.object({
638
+ var solanaBalanceSchema = z3.object({
624
639
  address: solanaAddressSchema,
625
- network: z4.literal("mainnet-beta"),
626
- lamports: z4.string().regex(/^(0|[1-9][0-9]*)$/),
627
- slot: z4.number().int().nonnegative().safe(),
628
- observedAt: z4.number().int().nonnegative()
640
+ network: z3.literal("mainnet-beta"),
641
+ lamports: z3.string().regex(/^(0|[1-9][0-9]*)$/),
642
+ slot: z3.number().int().nonnegative().safe(),
643
+ observedAt: z3.number().int().nonnegative()
629
644
  }).strict();
630
645
 
631
646
  // src/collection.ts
632
- import { z as z5 } from "zod";
633
- var collectionCodeSchema = z5.string().regex(/^relay:collect:[a-f0-9]{64}$/);
634
- var collectionPassSchema = z5.object({
647
+ import { z as z4 } from "zod";
648
+ var collectionCodeSchema = z4.string().regex(/^relay:collect:[a-f0-9]{64}$/);
649
+ var collectionPassSchema = z4.object({
635
650
  code: collectionCodeSchema,
636
- expiresAt: z5.number(),
651
+ expiresAt: z4.number(),
637
652
  entitlement: identifier
638
653
  });
639
- var collectionResolveSchema = z5.object({ code: collectionCodeSchema }).strict();
654
+ var collectionResolveSchema = z4.object({ code: collectionCodeSchema }).strict();
640
655
  var collectionBeginSchema = collectionResolveSchema.extend({
641
656
  actionId: identifier,
642
- revision: z5.number().int().positive(),
657
+ revision: z4.number().int().positive(),
643
658
  selection: pickupSelectionSchema.optional()
644
659
  });
645
- var collectionPreviewSchema = z5.object({
660
+ var collectionPreviewSchema = z4.object({
646
661
  entitlement: entitlementSchema,
647
662
  inventory: pickupAvailabilitySchema,
648
- expiresAt: z5.number()
663
+ expiresAt: z4.number()
649
664
  });
650
665
 
651
666
  // src/configuration.ts
@@ -663,26 +678,55 @@ function questConfiguration(release) {
663
678
  }
664
679
 
665
680
  // src/deployments.ts
666
- import { z as z6 } from "zod";
667
- var projectDeploymentSchema = catalogDeploymentSchema.omit({ expectedRevision: true }).extend({
668
- releases: z6.array(releaseSchema).max(50).default([])
669
- }).refine(
670
- (value) => value.releases.length > 0 || value.types.length > 0 || value.collections.length > 0 || value.supportedInteractions !== void 0,
671
- "No resources configured. Add quests, questTypes, collections, or supportedInteractions to relay.json."
681
+ import { z as z5 } from "zod";
682
+ var projectCatalogArtifactSchema = catalogDeploymentSchema.omit({ expectedRevision: true }).extend({
683
+ referrals: z5.array(referralArtifactSchema).max(50).default([]),
684
+ leaderboards: z5.array(leaderboardArtifactSchema).max(50).default([])
685
+ });
686
+ var projectDeploymentSchema = projectCatalogArtifactSchema.extend({ releases: z5.array(releaseSchema).max(50).default([]) }).refine(
687
+ (value) => value.releases.length > 0 || value.leaderboards.length > 0 || value.referrals.length > 0 || value.types.length > 0 || value.collections.length > 0 || value.supportedInteractions !== void 0,
688
+ "No resources configured. Add quests, questTypes, leaderboards, collections, or supportedInteractions to relay.json."
672
689
  );
673
- var deploymentPreviewSchema = z6.object({
690
+ var deploymentPreviewSchema = z5.object({
674
691
  id: identifier,
675
- baseRevision: z6.number().int().nonnegative(),
676
- releases: z6.array(publishedReleaseSchema),
677
- types: z6.array(questTypeVersionSchema),
678
- collections: z6.array(questCollectionSchema),
679
- supportedInteractions: z6.array(interactionSchema)
692
+ baseRevision: z5.number().int().nonnegative(),
693
+ releases: z5.array(publishedReleaseSchema),
694
+ types: z5.array(questTypeVersionSchema),
695
+ collections: z5.array(questCollectionSchema),
696
+ supportedInteractions: z5.array(interactionSchema),
697
+ referrals: z5.array(publishedReferralSchema).default([]),
698
+ leaderboards: z5.array(leaderboardPreviewSchema).default([])
680
699
  });
681
- var publishDeploymentSchema = z6.object({ id: identifier }).strict();
700
+ var publishDeploymentSchema = z5.object({ id: identifier }).strict();
682
701
  var deploymentResultSchema = deploymentPreviewSchema.extend({
683
- revision: z6.number().int().positive()
702
+ revision: z5.number().int().positive()
684
703
  });
685
704
 
705
+ // src/identity-integration.ts
706
+ import { z as z6 } from "zod";
707
+ var identityIntegrationInputSchema = z6.object({
708
+ name: z6.string().trim().min(1).max(80),
709
+ origin: z6.string().url().refine((value) => {
710
+ const url = new URL(value);
711
+ return url.protocol === "https:" && url.origin === value;
712
+ }, "Use an exact HTTPS application origin")
713
+ }).strict();
714
+ var identityIntegrationSchema = authScopeSchema.extend({
715
+ id: z6.string().uuid(),
716
+ name: z6.string(),
717
+ origin: z6.string(),
718
+ expiresAt: z6.number()
719
+ });
720
+ var identityIntegrationSecretSchema = identityIntegrationSchema.extend(
721
+ {
722
+ token: z6.string()
723
+ }
724
+ );
725
+ var participantExchangeSchema = z6.object({
726
+ subject: z6.string().min(1).max(200),
727
+ previousToken: z6.string().max(200).optional()
728
+ }).strict();
729
+
686
730
  // src/index.ts
687
731
  function createRelayClient(options) {
688
732
  async function send(path, init = {}) {
@@ -792,6 +836,28 @@ function createRelayClient(options) {
792
836
  return quest;
793
837
  }
794
838
  return {
839
+ referrals: {
840
+ list: () => request("/v1/referrals", z7.array(referralDefinitionSchema)),
841
+ summary: () => request("/v1/referrals/me", referralSummarySchema),
842
+ history: (before) => request(
843
+ query("/v1/referrals/history", { before }),
844
+ referralHistorySchema
845
+ ),
846
+ accept: (input) => request("/v1/referrals/accept", z7.object({ ok: z7.literal(true) }), {
847
+ method: "POST",
848
+ body: JSON.stringify(referralAcceptSchema.parse(input))
849
+ })
850
+ },
851
+ leaderboards: {
852
+ list: () => request("/v1/leaderboards", z7.array(leaderboardDefinitionSchema)),
853
+ standings: (board, options2 = {}) => {
854
+ const parsed = leaderboardQuerySchema.parse(options2);
855
+ return request(
856
+ query(`/v1/leaderboards/${identifier.parse(board)}`, parsed),
857
+ leaderboardPageSchema
858
+ );
859
+ }
860
+ },
795
861
  quests: {
796
862
  get: getQuest,
797
863
  retry: async (view) => {
@@ -862,7 +928,7 @@ function createRelayClient(options) {
862
928
  z7.object({
863
929
  providers: z7.array(
864
930
  z7.object({
865
- provider: z7.enum(["google", "apple", "x", "discord"]),
931
+ provider: authProviderSchema,
866
932
  configured: z7.boolean()
867
933
  })
868
934
  ),
@@ -887,6 +953,12 @@ function createRelayClient(options) {
887
953
  json({ challenge, code })
888
954
  )
889
955
  ),
956
+ accounts: () => request("/v1/auth/accounts", z7.array(accountConnectionSchema)),
957
+ disconnect: (provider) => request(
958
+ "/v1/auth/accounts/disconnect",
959
+ z7.object({ ok: z7.boolean() }),
960
+ json({ provider })
961
+ ),
890
962
  connections: () => request(
891
963
  "/v1/auth/connections",
892
964
  z7.array(
@@ -904,6 +976,7 @@ function createRelayClient(options) {
904
976
  signOut: () => changeSession(
905
977
  () => request("/v1/auth/logout", z7.object({ ok: z7.boolean() }), json({}))
906
978
  ),
979
+ /** Local development only. Existing hosted apps use createParticipantBackend from /portal-proxy. */
907
980
  exchange: (input) => request("/v1/auth/exchange", exchangeResultSchema, json(input))
908
981
  },
909
982
  me: {
@@ -1031,11 +1104,6 @@ export {
1031
1104
  QuestUpdatedError,
1032
1105
  reconcileQuestDraft,
1033
1106
  questActions,
1034
- authScopeSchema,
1035
- principalSchema,
1036
- sessionSchema,
1037
- exchangeSchema,
1038
- exchangeResultSchema,
1039
1107
  solanaAddressSchema,
1040
1108
  walletConnectionSchema,
1041
1109
  walletChallengeInputSchema,
@@ -1048,9 +1116,14 @@ export {
1048
1116
  collectionBeginSchema,
1049
1117
  collectionPreviewSchema,
1050
1118
  questConfiguration,
1119
+ projectCatalogArtifactSchema,
1051
1120
  projectDeploymentSchema,
1052
1121
  deploymentPreviewSchema,
1053
1122
  publishDeploymentSchema,
1054
1123
  deploymentResultSchema,
1124
+ identityIntegrationInputSchema,
1125
+ identityIntegrationSchema,
1126
+ identityIntegrationSecretSchema,
1127
+ participantExchangeSchema,
1055
1128
  createRelayClient
1056
1129
  };
@@ -0,0 +1,37 @@
1
+ import {
2
+ identifier
3
+ } from "./chunk-3IQ4KUKF.js";
4
+
5
+ // src/auth.ts
6
+ import { z } from "zod";
7
+ var authScopeSchema = z.object({
8
+ organization: identifier,
9
+ project: identifier,
10
+ environment: z.enum(["test", "live"])
11
+ }).strict();
12
+ var principalSchema = z.discriminatedUnion("kind", [
13
+ z.object({ kind: z.literal("member"), member: identifier }).strict(),
14
+ z.object({ kind: z.literal("staff"), subject: identifier }).strict(),
15
+ z.object({ kind: z.literal("operator"), subject: identifier }).strict()
16
+ ]);
17
+ var sessionSchema = authScopeSchema.extend({
18
+ id: identifier,
19
+ principal: principalSchema,
20
+ expiresAt: z.number()
21
+ });
22
+ var exchangeSchema = authScopeSchema.extend({
23
+ identity: z.object({ issuer: identifier, subject: z.string().min(1).max(200) }).strict(),
24
+ role: z.enum(["member", "staff", "operator"])
25
+ }).strict();
26
+ var exchangeResultSchema = z.object({
27
+ token: z.string(),
28
+ session: sessionSchema
29
+ });
30
+
31
+ export {
32
+ authScopeSchema,
33
+ principalSchema,
34
+ sessionSchema,
35
+ exchangeSchema,
36
+ exchangeResultSchema
37
+ };