@domino-sdk/relay 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/authoring.d.ts +88 -5
- package/dist/authoring.js +42 -6
- package/dist/browser.d.ts +382 -1
- package/dist/browser.js +4 -4
- package/dist/{chunk-LUCL63DS.js → chunk-CCLIDCUU.js} +191 -158
- package/dist/chunk-MXK7KEDA.js +819 -0
- package/dist/{chunk-QWRSUSNB.js → chunk-PLO5PPLU.js} +1 -1
- package/dist/{chunk-TXL43HL3.js → chunk-UIC6OF3C.js} +4 -2
- package/dist/index.d.ts +1205 -22
- package/dist/index.js +42 -4
- package/dist/portal-proxy.js +3 -3
- package/dist/schema.d.ts +399 -9
- package/dist/schema.js +3 -1
- package/dist/{settings-B7vsT8nd.d.ts → settings-BrC6C9yl.d.ts} +204 -1
- package/package.json +1 -1
- package/dist/chunk-3IQ4KUKF.js +0 -613
package/dist/browser.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createRelayClient
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-CCLIDCUU.js";
|
|
4
|
+
import "./chunk-UIC6OF3C.js";
|
|
5
|
+
import "./chunk-PLO5PPLU.js";
|
|
6
|
+
import "./chunk-MXK7KEDA.js";
|
|
7
7
|
|
|
8
8
|
// src/browser.ts
|
|
9
9
|
function createBrowserRelayClient(options) {
|
|
@@ -10,12 +10,12 @@ import {
|
|
|
10
10
|
referralDefinitionSchema,
|
|
11
11
|
referralHistorySchema,
|
|
12
12
|
referralSummarySchema
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-UIC6OF3C.js";
|
|
14
14
|
import {
|
|
15
15
|
authScopeSchema,
|
|
16
16
|
exchangeResultSchema,
|
|
17
17
|
sessionSchema
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-PLO5PPLU.js";
|
|
19
19
|
import {
|
|
20
20
|
accountConnectionSchema,
|
|
21
21
|
attemptSchema,
|
|
@@ -39,7 +39,28 @@ import {
|
|
|
39
39
|
settingsValuesSchema,
|
|
40
40
|
snapshotSchema,
|
|
41
41
|
templateSchema
|
|
42
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-MXK7KEDA.js";
|
|
43
|
+
|
|
44
|
+
// src/reward-deliveries.ts
|
|
45
|
+
import { z } from "zod";
|
|
46
|
+
var rewardDeliverySchema = z.object({
|
|
47
|
+
id: z.string(),
|
|
48
|
+
quest: z.string(),
|
|
49
|
+
completion: z.string(),
|
|
50
|
+
member: z.string(),
|
|
51
|
+
provider: z.literal("discord"),
|
|
52
|
+
action: z.literal("grant-role"),
|
|
53
|
+
roleId: z.string(),
|
|
54
|
+
status: z.enum(["pending", "delivered"]),
|
|
55
|
+
attempts: z.number().int(),
|
|
56
|
+
nextAt: z.number(),
|
|
57
|
+
lastError: z.string().nullable(),
|
|
58
|
+
createdAt: z.number(),
|
|
59
|
+
deliveredAt: z.number().nullable()
|
|
60
|
+
});
|
|
61
|
+
var rewardDeliveriesSchema = z.object({
|
|
62
|
+
deliveries: z.array(rewardDeliverySchema)
|
|
63
|
+
});
|
|
43
64
|
|
|
44
65
|
// src/resource-id.ts
|
|
45
66
|
var alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
@@ -55,8 +76,8 @@ function resourceId(prefix) {
|
|
|
55
76
|
}
|
|
56
77
|
|
|
57
78
|
// src/catalog.ts
|
|
58
|
-
import { z } from "zod";
|
|
59
|
-
var interactionSchema =
|
|
79
|
+
import { z as z2 } from "zod";
|
|
80
|
+
var interactionSchema = z2.enum([
|
|
60
81
|
"photo",
|
|
61
82
|
"quiz",
|
|
62
83
|
"claim",
|
|
@@ -66,103 +87,103 @@ var interactionSchema = z.enum([
|
|
|
66
87
|
function questInteraction(trigger) {
|
|
67
88
|
return trigger.kind === "automatic" ? "automatic" : trigger.actor === "staff" ? "staff" : trigger.input === "none" ? "claim" : trigger.input;
|
|
68
89
|
}
|
|
69
|
-
var questTypeVersionSchema =
|
|
90
|
+
var questTypeVersionSchema = z2.object({
|
|
70
91
|
id: identifier,
|
|
71
92
|
version: identifier,
|
|
72
|
-
code:
|
|
93
|
+
code: z2.string(),
|
|
73
94
|
definition: questDescriptionSchema,
|
|
74
95
|
provider: reviewModeSchema,
|
|
75
|
-
createdAt:
|
|
96
|
+
createdAt: z2.number()
|
|
76
97
|
});
|
|
77
|
-
var collectionSlotSchema =
|
|
98
|
+
var collectionSlotSchema = z2.object({ id: identifier, title: z2.string().trim().min(1).max(120) }).strict();
|
|
78
99
|
var questCollectionSchema = collectionSlotSchema.extend({
|
|
79
|
-
quests:
|
|
100
|
+
quests: z2.array(identifier).max(100).refine(
|
|
80
101
|
(v) => new Set(v).size === v.length,
|
|
81
102
|
"A collection can contain a quest only once"
|
|
82
103
|
)
|
|
83
104
|
});
|
|
84
|
-
var questInstanceSchema =
|
|
105
|
+
var questInstanceSchema = z2.object({
|
|
85
106
|
id: identifier,
|
|
86
|
-
title:
|
|
107
|
+
title: z2.string().trim().min(1).max(120),
|
|
87
108
|
typeVersion: identifier,
|
|
88
109
|
settings: settingsValuesSchema,
|
|
89
|
-
requires:
|
|
90
|
-
status:
|
|
110
|
+
requires: z2.array(identifier).max(30),
|
|
111
|
+
status: z2.enum(["active", "paused", "archived"])
|
|
91
112
|
}).strict();
|
|
92
|
-
var questDraftChangesSchema =
|
|
93
|
-
quests:
|
|
113
|
+
var questDraftChangesSchema = z2.object({
|
|
114
|
+
quests: z2.array(
|
|
94
115
|
questInstanceSchema.extend({ expectedRelease: identifier.nullable() })
|
|
95
116
|
).max(50),
|
|
96
|
-
collections:
|
|
117
|
+
collections: z2.array(questCollectionSchema).max(50)
|
|
97
118
|
}).strict();
|
|
98
|
-
var draftBase =
|
|
119
|
+
var draftBase = z2.object({
|
|
99
120
|
id: identifier,
|
|
100
|
-
revision:
|
|
101
|
-
baseRevision:
|
|
121
|
+
revision: z2.number().int().positive(),
|
|
122
|
+
baseRevision: z2.number().int().nonnegative(),
|
|
102
123
|
changes: questDraftChangesSchema
|
|
103
124
|
});
|
|
104
|
-
var questDraftSchema =
|
|
105
|
-
draftBase.extend({ status:
|
|
125
|
+
var questDraftSchema = z2.discriminatedUnion("status", [
|
|
126
|
+
draftBase.extend({ status: z2.literal("draft") }),
|
|
106
127
|
draftBase.extend({
|
|
107
|
-
status:
|
|
108
|
-
releaseIds:
|
|
128
|
+
status: z2.literal("published"),
|
|
129
|
+
releaseIds: z2.array(identifier)
|
|
109
130
|
})
|
|
110
131
|
]);
|
|
111
|
-
var questCatalogSchema =
|
|
112
|
-
revision:
|
|
113
|
-
types:
|
|
114
|
-
collections:
|
|
115
|
-
quests:
|
|
116
|
-
drafts:
|
|
117
|
-
releases:
|
|
118
|
-
supportedInteractions:
|
|
132
|
+
var questCatalogSchema = z2.object({
|
|
133
|
+
revision: z2.number().int().nonnegative(),
|
|
134
|
+
types: z2.array(questTypeVersionSchema),
|
|
135
|
+
collections: z2.array(questCollectionSchema),
|
|
136
|
+
quests: z2.array(questInstanceSchema),
|
|
137
|
+
drafts: z2.array(questDraftSchema),
|
|
138
|
+
releases: z2.array(publishedReleaseSchema).default([]),
|
|
139
|
+
supportedInteractions: z2.array(interactionSchema)
|
|
119
140
|
});
|
|
120
|
-
var catalogDeploymentSchema =
|
|
121
|
-
expectedRevision:
|
|
122
|
-
types:
|
|
123
|
-
|
|
124
|
-
code:
|
|
141
|
+
var catalogDeploymentSchema = z2.object({
|
|
142
|
+
expectedRevision: z2.number().int().nonnegative(),
|
|
143
|
+
types: z2.array(
|
|
144
|
+
z2.object({
|
|
145
|
+
code: z2.string().min(1).max(1e6),
|
|
125
146
|
provider: reviewModeSchema
|
|
126
147
|
})
|
|
127
148
|
).max(50).default([]),
|
|
128
|
-
collections:
|
|
129
|
-
supportedInteractions:
|
|
149
|
+
collections: z2.array(collectionSlotSchema).max(50).default([]),
|
|
150
|
+
supportedInteractions: z2.array(interactionSchema).min(1).optional()
|
|
130
151
|
}).strict();
|
|
131
|
-
var catalogDeploymentPreviewSchema =
|
|
132
|
-
revision:
|
|
133
|
-
types:
|
|
134
|
-
collections:
|
|
135
|
-
supportedInteractions:
|
|
152
|
+
var catalogDeploymentPreviewSchema = z2.object({
|
|
153
|
+
revision: z2.number().int().nonnegative(),
|
|
154
|
+
types: z2.array(questTypeVersionSchema),
|
|
155
|
+
collections: z2.array(collectionSlotSchema),
|
|
156
|
+
supportedInteractions: z2.array(interactionSchema)
|
|
136
157
|
});
|
|
137
|
-
var saveQuestDraftSchema =
|
|
158
|
+
var saveQuestDraftSchema = z2.object({
|
|
138
159
|
id: identifier,
|
|
139
|
-
expectedRevision:
|
|
140
|
-
baseRevision:
|
|
160
|
+
expectedRevision: z2.number().int().nonnegative(),
|
|
161
|
+
baseRevision: z2.number().int().nonnegative(),
|
|
141
162
|
changes: questDraftChangesSchema
|
|
142
163
|
}).strict();
|
|
143
|
-
var publishQuestDraftSchema =
|
|
164
|
+
var publishQuestDraftSchema = z2.object({ id: identifier, expectedRevision: z2.number().int().positive() }).strict();
|
|
144
165
|
var questViewSchema = memberProgressSchema.shape.quests.element.extend(
|
|
145
166
|
{
|
|
146
167
|
release: identifier,
|
|
147
168
|
interaction: interactionSchema,
|
|
148
|
-
lifecycle:
|
|
149
|
-
rewards:
|
|
169
|
+
lifecycle: z2.enum(["active", "paused", "archived"]),
|
|
170
|
+
rewards: z2.array(z2.object({ label: z2.string() }))
|
|
150
171
|
}
|
|
151
172
|
);
|
|
152
|
-
var collectionViewSchema =
|
|
173
|
+
var collectionViewSchema = z2.object({
|
|
153
174
|
id: identifier,
|
|
154
|
-
title:
|
|
155
|
-
quests:
|
|
175
|
+
title: z2.string(),
|
|
176
|
+
quests: z2.array(questViewSchema)
|
|
156
177
|
});
|
|
157
|
-
var questExperienceSchema =
|
|
178
|
+
var questExperienceSchema = z2.object({
|
|
158
179
|
member: identifier,
|
|
159
|
-
quests:
|
|
160
|
-
collections:
|
|
180
|
+
quests: z2.array(questViewSchema),
|
|
181
|
+
collections: z2.array(collectionViewSchema)
|
|
161
182
|
});
|
|
162
|
-
var questPublicationPreviewSchema =
|
|
183
|
+
var questPublicationPreviewSchema = z2.object({
|
|
163
184
|
draft: questDraftSchema,
|
|
164
|
-
releases:
|
|
165
|
-
affectedCollections:
|
|
185
|
+
releases: z2.array(publishedReleaseSchema),
|
|
186
|
+
affectedCollections: z2.array(questCollectionSchema)
|
|
166
187
|
});
|
|
167
188
|
|
|
168
189
|
// src/errors.ts
|
|
@@ -179,43 +200,43 @@ var RelayError = class extends Error {
|
|
|
179
200
|
};
|
|
180
201
|
|
|
181
202
|
// src/submissions.ts
|
|
182
|
-
import { z as
|
|
203
|
+
import { z as z3 } from "zod";
|
|
183
204
|
var common = {
|
|
184
205
|
id: identifier,
|
|
185
206
|
quest: identifier,
|
|
186
207
|
release: identifier.optional()
|
|
187
208
|
};
|
|
188
|
-
var claimInputSchema =
|
|
209
|
+
var claimInputSchema = z3.union([
|
|
189
210
|
quizEvidenceSchema,
|
|
190
|
-
|
|
211
|
+
z3.object({ kind: z3.literal("none") }).strict()
|
|
191
212
|
]);
|
|
192
|
-
var draftSchema =
|
|
213
|
+
var draftSchema = z3.union([
|
|
193
214
|
claimInputSchema,
|
|
194
|
-
|
|
215
|
+
z3.object({ kind: z3.literal("photo"), file: z3.instanceof(Blob) })
|
|
195
216
|
]);
|
|
196
|
-
var recordSchema =
|
|
197
|
-
|
|
217
|
+
var recordSchema = z3.union([
|
|
218
|
+
z3.object({
|
|
198
219
|
...common,
|
|
199
|
-
stage:
|
|
220
|
+
stage: z3.literal("review"),
|
|
200
221
|
draft: draftSchema.nullable()
|
|
201
222
|
}),
|
|
202
|
-
|
|
203
|
-
|
|
223
|
+
z3.object({ ...common, stage: z3.literal("upload"), file: z3.instanceof(Blob) }),
|
|
224
|
+
z3.object({
|
|
204
225
|
...common,
|
|
205
|
-
stage:
|
|
226
|
+
stage: z3.literal("claim"),
|
|
206
227
|
evidence: identifier,
|
|
207
|
-
file:
|
|
228
|
+
file: z3.instanceof(Blob).optional()
|
|
208
229
|
}),
|
|
209
|
-
|
|
230
|
+
z3.object({
|
|
210
231
|
...common,
|
|
211
|
-
stage:
|
|
232
|
+
stage: z3.literal("submitted"),
|
|
212
233
|
evidence: identifier,
|
|
213
234
|
attempt: identifier
|
|
214
235
|
}),
|
|
215
|
-
|
|
216
|
-
|
|
236
|
+
z3.object({ ...common, stage: z3.literal("claim"), input: claimInputSchema }),
|
|
237
|
+
z3.object({
|
|
217
238
|
...common,
|
|
218
|
-
stage:
|
|
239
|
+
stage: z3.literal("submitted"),
|
|
219
240
|
input: claimInputSchema,
|
|
220
241
|
attempt: identifier
|
|
221
242
|
})
|
|
@@ -348,7 +369,8 @@ function submissions(transport, configuredStore, namespace) {
|
|
|
348
369
|
const previous = await claim(existing);
|
|
349
370
|
if (previous.status === "failed")
|
|
350
371
|
return transport.retry(previous.id, sessionId);
|
|
351
|
-
if (previous.status !== "rejected"
|
|
372
|
+
if (previous.status !== "rejected" && !(options.repeatable && previous.status === "accepted"))
|
|
373
|
+
return previous;
|
|
352
374
|
}
|
|
353
375
|
await store.write(key, record);
|
|
354
376
|
return resumeRecord(record);
|
|
@@ -365,7 +387,7 @@ function submissions(transport, configuredStore, namespace) {
|
|
|
365
387
|
"Resume the unfinished submission before starting over."
|
|
366
388
|
);
|
|
367
389
|
const attempt = await claim(record);
|
|
368
|
-
if (attempt.status !== "failed" && attempt.status !== "rejected")
|
|
390
|
+
if (attempt.status !== "failed" && attempt.status !== "rejected" && !(options.repeatable && attempt.status === "accepted"))
|
|
369
391
|
throw new Error(
|
|
370
392
|
"Only a failed or rejected submission can be discarded."
|
|
371
393
|
);
|
|
@@ -486,7 +508,8 @@ function questActions(submission, latest) {
|
|
|
486
508
|
const handle = await submission(view.quest, {
|
|
487
509
|
input: "none",
|
|
488
510
|
release: view.release,
|
|
489
|
-
recoverPrevious: true
|
|
511
|
+
recoverPrevious: true,
|
|
512
|
+
repeatable: view.completion.kind === "keyed"
|
|
490
513
|
});
|
|
491
514
|
return {
|
|
492
515
|
kind: "status",
|
|
@@ -501,7 +524,8 @@ function questActions(submission, latest) {
|
|
|
501
524
|
const handle = await submission(view.quest, {
|
|
502
525
|
input: "photo",
|
|
503
526
|
release: view.release,
|
|
504
|
-
recoverPrevious: true
|
|
527
|
+
recoverPrevious: true,
|
|
528
|
+
repeatable: view.completion.kind === "keyed"
|
|
505
529
|
});
|
|
506
530
|
return {
|
|
507
531
|
kind: "photo",
|
|
@@ -516,7 +540,8 @@ function questActions(submission, latest) {
|
|
|
516
540
|
const handle = await submission(view.quest, {
|
|
517
541
|
input: "quiz",
|
|
518
542
|
release: view.release,
|
|
519
|
-
recoverPrevious: true
|
|
543
|
+
recoverPrevious: true,
|
|
544
|
+
repeatable: view.completion.kind === "keyed"
|
|
520
545
|
});
|
|
521
546
|
return {
|
|
522
547
|
kind: "quiz",
|
|
@@ -531,7 +556,8 @@ function questActions(submission, latest) {
|
|
|
531
556
|
const handle = await submission(view.quest, {
|
|
532
557
|
input: "none",
|
|
533
558
|
release: view.release,
|
|
534
|
-
recoverPrevious: true
|
|
559
|
+
recoverPrevious: true,
|
|
560
|
+
repeatable: view.completion.kind === "keyed"
|
|
535
561
|
});
|
|
536
562
|
return {
|
|
537
563
|
kind: "claim",
|
|
@@ -624,56 +650,56 @@ function observeProgress(transport, listener, options = {}, onDispose = () => {
|
|
|
624
650
|
}
|
|
625
651
|
|
|
626
652
|
// src/index.ts
|
|
627
|
-
import { z as
|
|
653
|
+
import { z as z8 } from "zod";
|
|
628
654
|
|
|
629
655
|
// src/wallet.ts
|
|
630
|
-
import { z as
|
|
631
|
-
var solanaAddressSchema =
|
|
632
|
-
var walletConnectionSchema =
|
|
633
|
-
chain:
|
|
656
|
+
import { z as z4 } from "zod";
|
|
657
|
+
var solanaAddressSchema = z4.string().min(32).max(44).regex(/^[1-9A-HJ-NP-Za-km-z]+$/);
|
|
658
|
+
var walletConnectionSchema = z4.object({
|
|
659
|
+
chain: z4.literal("solana"),
|
|
634
660
|
address: solanaAddressSchema,
|
|
635
|
-
verifiedAt:
|
|
636
|
-
revision:
|
|
661
|
+
verifiedAt: z4.number().int().nonnegative(),
|
|
662
|
+
revision: z4.number().int().positive()
|
|
637
663
|
}).strict();
|
|
638
|
-
var walletChallengeInputSchema =
|
|
639
|
-
chain:
|
|
664
|
+
var walletChallengeInputSchema = z4.object({
|
|
665
|
+
chain: z4.literal("solana"),
|
|
640
666
|
address: solanaAddressSchema
|
|
641
667
|
}).strict();
|
|
642
668
|
var walletChallengeSchema = walletChallengeInputSchema.extend({
|
|
643
|
-
id:
|
|
644
|
-
message:
|
|
645
|
-
expiresAt:
|
|
669
|
+
id: z4.string().uuid(),
|
|
670
|
+
message: z4.string(),
|
|
671
|
+
expiresAt: z4.number()
|
|
646
672
|
});
|
|
647
|
-
var walletProofSchema =
|
|
648
|
-
challenge:
|
|
649
|
-
signature:
|
|
673
|
+
var walletProofSchema = z4.object({
|
|
674
|
+
challenge: z4.string().uuid(),
|
|
675
|
+
signature: z4.string().min(64).max(88).regex(/^[1-9A-HJ-NP-Za-km-z]+$/)
|
|
650
676
|
}).strict();
|
|
651
|
-
var solanaBalanceSchema =
|
|
677
|
+
var solanaBalanceSchema = z4.object({
|
|
652
678
|
address: solanaAddressSchema,
|
|
653
|
-
network:
|
|
654
|
-
lamports:
|
|
655
|
-
slot:
|
|
656
|
-
observedAt:
|
|
679
|
+
network: z4.literal("mainnet-beta"),
|
|
680
|
+
lamports: z4.string().regex(/^(0|[1-9][0-9]*)$/),
|
|
681
|
+
slot: z4.number().int().nonnegative().safe(),
|
|
682
|
+
observedAt: z4.number().int().nonnegative()
|
|
657
683
|
}).strict();
|
|
658
684
|
|
|
659
685
|
// src/collection.ts
|
|
660
|
-
import { z as
|
|
661
|
-
var collectionCodeSchema =
|
|
662
|
-
var collectionPassSchema =
|
|
686
|
+
import { z as z5 } from "zod";
|
|
687
|
+
var collectionCodeSchema = z5.string().regex(/^relay:collect:[a-f0-9]{64}$/);
|
|
688
|
+
var collectionPassSchema = z5.object({
|
|
663
689
|
code: collectionCodeSchema,
|
|
664
|
-
expiresAt:
|
|
690
|
+
expiresAt: z5.number(),
|
|
665
691
|
entitlement: identifier
|
|
666
692
|
});
|
|
667
|
-
var collectionResolveSchema =
|
|
693
|
+
var collectionResolveSchema = z5.object({ code: collectionCodeSchema }).strict();
|
|
668
694
|
var collectionBeginSchema = collectionResolveSchema.extend({
|
|
669
695
|
actionId: identifier,
|
|
670
|
-
revision:
|
|
696
|
+
revision: z5.number().int().positive(),
|
|
671
697
|
selection: pickupSelectionSchema.optional()
|
|
672
698
|
});
|
|
673
|
-
var collectionPreviewSchema =
|
|
699
|
+
var collectionPreviewSchema = z5.object({
|
|
674
700
|
entitlement: entitlementSchema,
|
|
675
701
|
inventory: pickupAvailabilitySchema,
|
|
676
|
-
expiresAt:
|
|
702
|
+
expiresAt: z5.number()
|
|
677
703
|
});
|
|
678
704
|
|
|
679
705
|
// src/configuration.ts
|
|
@@ -691,53 +717,53 @@ function questConfiguration(release) {
|
|
|
691
717
|
}
|
|
692
718
|
|
|
693
719
|
// src/deployments.ts
|
|
694
|
-
import { z as
|
|
720
|
+
import { z as z6 } from "zod";
|
|
695
721
|
var projectCatalogArtifactSchema = catalogDeploymentSchema.omit({ expectedRevision: true }).extend({
|
|
696
|
-
referrals:
|
|
697
|
-
leaderboards:
|
|
722
|
+
referrals: z6.array(referralArtifactSchema).max(50).default([]),
|
|
723
|
+
leaderboards: z6.array(leaderboardArtifactSchema).max(50).default([])
|
|
698
724
|
});
|
|
699
|
-
var projectDeploymentSchema = projectCatalogArtifactSchema.extend({ releases:
|
|
725
|
+
var projectDeploymentSchema = projectCatalogArtifactSchema.extend({ releases: z6.array(releaseSchema).max(50).default([]) }).refine(
|
|
700
726
|
(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,
|
|
701
727
|
"No resources configured. Add quests, questTypes, leaderboards, collections, or supportedInteractions to relay.json."
|
|
702
728
|
);
|
|
703
|
-
var deploymentPreviewSchema =
|
|
729
|
+
var deploymentPreviewSchema = z6.object({
|
|
704
730
|
id: identifier,
|
|
705
|
-
baseRevision:
|
|
706
|
-
releases:
|
|
707
|
-
types:
|
|
708
|
-
collections:
|
|
709
|
-
supportedInteractions:
|
|
710
|
-
referrals:
|
|
711
|
-
leaderboards:
|
|
731
|
+
baseRevision: z6.number().int().nonnegative(),
|
|
732
|
+
releases: z6.array(publishedReleaseSchema),
|
|
733
|
+
types: z6.array(questTypeVersionSchema),
|
|
734
|
+
collections: z6.array(questCollectionSchema),
|
|
735
|
+
supportedInteractions: z6.array(interactionSchema),
|
|
736
|
+
referrals: z6.array(publishedReferralSchema).default([]),
|
|
737
|
+
leaderboards: z6.array(leaderboardPreviewSchema).default([])
|
|
712
738
|
});
|
|
713
|
-
var publishDeploymentSchema =
|
|
739
|
+
var publishDeploymentSchema = z6.object({ id: identifier }).strict();
|
|
714
740
|
var deploymentResultSchema = deploymentPreviewSchema.extend({
|
|
715
|
-
revision:
|
|
741
|
+
revision: z6.number().int().positive()
|
|
716
742
|
});
|
|
717
743
|
|
|
718
744
|
// src/identity-integration.ts
|
|
719
|
-
import { z as
|
|
720
|
-
var identityIntegrationInputSchema =
|
|
721
|
-
name:
|
|
722
|
-
origin:
|
|
745
|
+
import { z as z7 } from "zod";
|
|
746
|
+
var identityIntegrationInputSchema = z7.object({
|
|
747
|
+
name: z7.string().trim().min(1).max(80),
|
|
748
|
+
origin: z7.string().url().refine((value) => {
|
|
723
749
|
const url = new URL(value);
|
|
724
750
|
return url.protocol === "https:" && url.origin === value;
|
|
725
751
|
}, "Use an exact HTTPS application origin")
|
|
726
752
|
}).strict();
|
|
727
753
|
var identityIntegrationSchema = authScopeSchema.extend({
|
|
728
|
-
id:
|
|
729
|
-
name:
|
|
730
|
-
origin:
|
|
731
|
-
expiresAt:
|
|
754
|
+
id: z7.string().uuid(),
|
|
755
|
+
name: z7.string(),
|
|
756
|
+
origin: z7.string(),
|
|
757
|
+
expiresAt: z7.number()
|
|
732
758
|
});
|
|
733
759
|
var identityIntegrationSecretSchema = identityIntegrationSchema.extend(
|
|
734
760
|
{
|
|
735
|
-
token:
|
|
761
|
+
token: z7.string()
|
|
736
762
|
}
|
|
737
763
|
);
|
|
738
|
-
var participantExchangeSchema =
|
|
739
|
-
subject:
|
|
740
|
-
previousToken:
|
|
764
|
+
var participantExchangeSchema = z7.object({
|
|
765
|
+
subject: z7.string().min(1).max(200),
|
|
766
|
+
previousToken: z7.string().max(200).optional()
|
|
741
767
|
}).strict();
|
|
742
768
|
|
|
743
769
|
// src/index.ts
|
|
@@ -850,19 +876,19 @@ function createRelayClient(options) {
|
|
|
850
876
|
}
|
|
851
877
|
return {
|
|
852
878
|
referrals: {
|
|
853
|
-
list: () => request("/v1/referrals",
|
|
879
|
+
list: () => request("/v1/referrals", z8.array(referralDefinitionSchema)),
|
|
854
880
|
summary: () => request("/v1/referrals/me", referralSummarySchema),
|
|
855
881
|
history: (before) => request(
|
|
856
882
|
query("/v1/referrals/history", { before }),
|
|
857
883
|
referralHistorySchema
|
|
858
884
|
),
|
|
859
|
-
accept: (input) => request("/v1/referrals/accept",
|
|
885
|
+
accept: (input) => request("/v1/referrals/accept", z8.object({ ok: z8.literal(true) }), {
|
|
860
886
|
method: "POST",
|
|
861
887
|
body: JSON.stringify(referralAcceptSchema.parse(input))
|
|
862
888
|
})
|
|
863
889
|
},
|
|
864
890
|
leaderboards: {
|
|
865
|
-
list: () => request("/v1/leaderboards",
|
|
891
|
+
list: () => request("/v1/leaderboards", z8.array(leaderboardDefinitionSchema)),
|
|
866
892
|
standings: (board, options2 = {}) => {
|
|
867
893
|
const parsed = leaderboardQuerySchema.parse(options2);
|
|
868
894
|
return request(
|
|
@@ -874,6 +900,10 @@ function createRelayClient(options) {
|
|
|
874
900
|
quests: {
|
|
875
901
|
get: getQuest,
|
|
876
902
|
retry: async (view) => {
|
|
903
|
+
if (view.trigger.kind === "automatic")
|
|
904
|
+
throw new Error(
|
|
905
|
+
"Automatic quests recover without participant retries."
|
|
906
|
+
);
|
|
877
907
|
if (!view.attempt || view.attempt.status !== "failed")
|
|
878
908
|
throw new Error("There is no failed attempt to retry.");
|
|
879
909
|
const session = await request(
|
|
@@ -938,25 +968,25 @@ function createRelayClient(options) {
|
|
|
938
968
|
auth: {
|
|
939
969
|
providers: () => request(
|
|
940
970
|
"/v1/auth/providers",
|
|
941
|
-
|
|
942
|
-
providers:
|
|
943
|
-
|
|
971
|
+
z8.object({
|
|
972
|
+
providers: z8.array(
|
|
973
|
+
z8.object({
|
|
944
974
|
provider: authProviderSchema,
|
|
945
|
-
configured:
|
|
975
|
+
configured: z8.boolean()
|
|
946
976
|
})
|
|
947
977
|
),
|
|
948
|
-
email:
|
|
949
|
-
demo:
|
|
978
|
+
email: z8.boolean(),
|
|
979
|
+
demo: z8.boolean()
|
|
950
980
|
})
|
|
951
981
|
),
|
|
952
982
|
start: (provider, mode) => request(
|
|
953
983
|
"/v1/auth/start",
|
|
954
|
-
|
|
984
|
+
z8.object({ url: z8.string() }),
|
|
955
985
|
json({ provider, mode })
|
|
956
986
|
),
|
|
957
987
|
emailStart: (email) => request(
|
|
958
988
|
"/v1/auth/email/start",
|
|
959
|
-
|
|
989
|
+
z8.object({ challenge: z8.string() }),
|
|
960
990
|
json({ email })
|
|
961
991
|
),
|
|
962
992
|
emailVerify: (challenge, code) => changeSession(
|
|
@@ -966,25 +996,25 @@ function createRelayClient(options) {
|
|
|
966
996
|
json({ challenge, code })
|
|
967
997
|
)
|
|
968
998
|
),
|
|
969
|
-
accounts: () => request("/v1/auth/accounts",
|
|
999
|
+
accounts: () => request("/v1/auth/accounts", z8.array(accountConnectionSchema)),
|
|
970
1000
|
disconnect: (provider) => request(
|
|
971
1001
|
"/v1/auth/accounts/disconnect",
|
|
972
|
-
|
|
1002
|
+
z8.object({ ok: z8.boolean() }),
|
|
973
1003
|
json({ provider })
|
|
974
1004
|
),
|
|
975
1005
|
connections: () => request(
|
|
976
1006
|
"/v1/auth/connections",
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
provider:
|
|
980
|
-
subject:
|
|
981
|
-
signInEnabled:
|
|
1007
|
+
z8.array(
|
|
1008
|
+
z8.object({
|
|
1009
|
+
provider: z8.string(),
|
|
1010
|
+
subject: z8.string(),
|
|
1011
|
+
signInEnabled: z8.boolean()
|
|
982
1012
|
})
|
|
983
1013
|
)
|
|
984
1014
|
),
|
|
985
1015
|
session: () => request("/v1/auth/session", sessionSchema.nullable()),
|
|
986
1016
|
signOut: () => changeSession(
|
|
987
|
-
() => request("/v1/auth/logout",
|
|
1017
|
+
() => request("/v1/auth/logout", z8.object({ ok: z8.boolean() }), json({}))
|
|
988
1018
|
),
|
|
989
1019
|
/** Local development only. Existing hosted apps use createParticipantBackend from /portal-proxy. */
|
|
990
1020
|
exchange: (input) => request("/v1/auth/exchange", exchangeResultSchema, json(input))
|
|
@@ -1018,6 +1048,7 @@ function createRelayClient(options) {
|
|
|
1018
1048
|
}),
|
|
1019
1049
|
linkPass: (code) => request("/v1/me/pass", attemptSchema, json({ code })),
|
|
1020
1050
|
progress: () => request("/v1/me/progress", memberProgressSchema),
|
|
1051
|
+
rewardDeliveries: () => request("/v1/reward-deliveries", rewardDeliveriesSchema),
|
|
1021
1052
|
claim: (input, options2) => request("/v1/me/attempts", attemptSchema, {
|
|
1022
1053
|
...json(input),
|
|
1023
1054
|
headers: {
|
|
@@ -1059,16 +1090,16 @@ function createRelayClient(options) {
|
|
|
1059
1090
|
},
|
|
1060
1091
|
lookupMember: (issuer, subject) => request(
|
|
1061
1092
|
"/v1/members/lookup",
|
|
1062
|
-
|
|
1093
|
+
z8.object({ member: z8.string() }),
|
|
1063
1094
|
json({ issuer, subject })
|
|
1064
1095
|
),
|
|
1065
|
-
journeyTemplate: () => request("/v1/journey-template",
|
|
1096
|
+
journeyTemplate: () => request("/v1/journey-template", z8.array(templateSchema)),
|
|
1066
1097
|
template: () => request("/v1/template", templateSchema),
|
|
1067
1098
|
snapshot: () => request("/v1/snapshot", snapshotSchema),
|
|
1068
1099
|
publish: (release) => request("/v1/releases", publishedReleaseSchema, json(release)),
|
|
1069
1100
|
publishBatch: (releases) => request(
|
|
1070
1101
|
"/v1/releases/batch",
|
|
1071
|
-
|
|
1102
|
+
z8.array(publishedReleaseSchema),
|
|
1072
1103
|
json({ releases })
|
|
1073
1104
|
),
|
|
1074
1105
|
progress: (member) => request(
|
|
@@ -1093,6 +1124,8 @@ function createRelayClient(options) {
|
|
|
1093
1124
|
}
|
|
1094
1125
|
|
|
1095
1126
|
export {
|
|
1127
|
+
rewardDeliverySchema,
|
|
1128
|
+
rewardDeliveriesSchema,
|
|
1096
1129
|
resourceId,
|
|
1097
1130
|
interactionSchema,
|
|
1098
1131
|
questInteraction,
|