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