@domino-sdk/relay 0.7.0 → 0.9.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 +13 -9
- package/dist/authoring.js +19 -9
- package/dist/browser.d.ts +38 -9
- package/dist/browser.js +4 -4
- package/dist/{chunk-36LZ3IOO.js → chunk-MVDE7WKB.js} +1 -1
- package/dist/chunk-Q5VDZVVO.js +388 -0
- package/dist/{chunk-6QUCADMF.js → chunk-XTFCKK2Y.js} +37 -5
- package/dist/{chunk-LXLNC4CN.js → chunk-Y6H4HDQT.js} +42 -28
- package/dist/index.d.ts +854 -114
- package/dist/index.js +28 -6
- package/dist/portal-proxy.js +2 -2
- package/dist/schema.d.ts +45 -19
- package/dist/schema.js +7 -1
- package/dist/{settings-CU_oBcx0.d.ts → settings-BA8XjT4m.d.ts} +766 -23
- package/package.json +1 -1
- package/dist/chunk-TYVT5BPZ.js +0 -337
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
import {
|
|
2
|
+
identifier,
|
|
3
|
+
pointsRewardSchema,
|
|
4
|
+
tierRewardSchema
|
|
5
|
+
} from "./chunk-XTFCKK2Y.js";
|
|
6
|
+
|
|
7
|
+
// src/authoring-identity.ts
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
var authoringIdentityShape = {
|
|
10
|
+
key: identifier.optional(),
|
|
11
|
+
id: identifier.optional()
|
|
12
|
+
};
|
|
13
|
+
function validateAuthoringIdentity(value, ctx) {
|
|
14
|
+
if (!value.key && !value.id)
|
|
15
|
+
ctx.addIssue({
|
|
16
|
+
code: "custom",
|
|
17
|
+
path: ["key"],
|
|
18
|
+
message: "Provide an authoring key. Legacy id is also accepted."
|
|
19
|
+
});
|
|
20
|
+
if (value.key && value.id && value.key !== value.id)
|
|
21
|
+
ctx.addIssue({
|
|
22
|
+
code: "custom",
|
|
23
|
+
path: ["key"],
|
|
24
|
+
message: "id and key must match. Keep the existing authoring name to preserve identity."
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function normalizeAuthoringIdentity(value) {
|
|
28
|
+
const { id, key, ...properties } = value;
|
|
29
|
+
return { ...properties, key: identifier.parse(key ?? id) };
|
|
30
|
+
}
|
|
31
|
+
var identitySchema = z.object(authoringIdentityShape).superRefine(validateAuthoringIdentity).transform(normalizeAuthoringIdentity);
|
|
32
|
+
var authoringKey = (input) => identitySchema.parse(input).key;
|
|
33
|
+
|
|
34
|
+
// src/referrals.ts
|
|
35
|
+
import { z as z2 } from "zod";
|
|
36
|
+
var rewardSchema = z2.union([pointsRewardSchema, tierRewardSchema]);
|
|
37
|
+
var amount = z2.number().int().safe().nonnegative();
|
|
38
|
+
var reason = z2.string().trim().min(1).max(1e3);
|
|
39
|
+
var referralDefinitionSchema = z2.object({
|
|
40
|
+
id: identifier,
|
|
41
|
+
key: identifier.optional(),
|
|
42
|
+
title: z2.string().trim().min(1).max(120),
|
|
43
|
+
enabled: z2.boolean().default(true),
|
|
44
|
+
qualification: z2.discriminatedUnion("kind", [
|
|
45
|
+
z2.object({ kind: z2.literal("signup") }).strict(),
|
|
46
|
+
z2.object({ kind: z2.literal("quest"), quest: identifier }).strict(),
|
|
47
|
+
z2.object({ kind: z2.literal("external") }).strict()
|
|
48
|
+
]),
|
|
49
|
+
inviterGroup: identifier.optional(),
|
|
50
|
+
rewards: z2.object({
|
|
51
|
+
inviter: z2.array(rewardSchema).max(10).default([]),
|
|
52
|
+
invitee: z2.array(rewardSchema).max(10).default([])
|
|
53
|
+
}).strict().default({ inviter: [], invitee: [] }),
|
|
54
|
+
milestones: z2.array(
|
|
55
|
+
z2.object({
|
|
56
|
+
id: identifier,
|
|
57
|
+
count: amount.min(1),
|
|
58
|
+
rewards: z2.array(rewardSchema).min(1).max(10)
|
|
59
|
+
}).strict()
|
|
60
|
+
).max(30).default([]),
|
|
61
|
+
bonuses: z2.array(
|
|
62
|
+
z2.object({
|
|
63
|
+
id: identifier,
|
|
64
|
+
balance: identifier,
|
|
65
|
+
basisPoints: amount.min(1).max(1e4),
|
|
66
|
+
quests: z2.array(identifier).min(1).max(100).optional(),
|
|
67
|
+
external: z2.boolean().default(false),
|
|
68
|
+
durationDays: amount.min(1).max(36500).optional(),
|
|
69
|
+
maxPoints: amount.min(1).optional()
|
|
70
|
+
}).strict()
|
|
71
|
+
).max(20).default([])
|
|
72
|
+
}).strict().superRefine((value, ctx) => {
|
|
73
|
+
for (const entries of [value.milestones, value.bonuses])
|
|
74
|
+
if (new Set(entries.map((e) => e.id)).size !== entries.length)
|
|
75
|
+
ctx.addIssue({ code: "custom", message: "Rule IDs must be unique" });
|
|
76
|
+
});
|
|
77
|
+
var referralAuthoringSchema = z2.object(referralDefinitionSchema.shape).omit({ id: true }).extend(authoringIdentityShape).strict().superRefine(validateAuthoringIdentity).superRefine((value, ctx) => {
|
|
78
|
+
for (const entries of [value.milestones, value.bonuses])
|
|
79
|
+
if (new Set(entries.map((entry) => entry.id)).size !== entries.length)
|
|
80
|
+
ctx.addIssue({ code: "custom", message: "Rule keys must be unique" });
|
|
81
|
+
}).transform(normalizeAuthoringIdentity);
|
|
82
|
+
function defineReferral(input) {
|
|
83
|
+
const definition = referralAuthoringSchema.parse(input);
|
|
84
|
+
return {
|
|
85
|
+
...definition,
|
|
86
|
+
/** @deprecated Use key. */
|
|
87
|
+
id: definition.key
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
var referralArtifactSchema = z2.union([
|
|
91
|
+
referralAuthoringSchema,
|
|
92
|
+
z2.object({ code: z2.string().min(1).max(2e6) }).strict()
|
|
93
|
+
]);
|
|
94
|
+
var publishedReferralSchema = z2.object({
|
|
95
|
+
version: identifier,
|
|
96
|
+
definition: referralDefinitionSchema,
|
|
97
|
+
publishedAt: amount,
|
|
98
|
+
actor: z2.string().nullable()
|
|
99
|
+
});
|
|
100
|
+
var referralAcceptSchema = z2.object({ actionId: identifier, code: identifier }).strict();
|
|
101
|
+
var referralControlSchema = z2.discriminatedUnion("kind", [
|
|
102
|
+
z2.object({
|
|
103
|
+
kind: z2.literal("suspend"),
|
|
104
|
+
actionId: identifier,
|
|
105
|
+
member: identifier,
|
|
106
|
+
suspended: z2.boolean(),
|
|
107
|
+
reason
|
|
108
|
+
}).strict(),
|
|
109
|
+
z2.object({
|
|
110
|
+
kind: z2.literal("qualify"),
|
|
111
|
+
actionId: identifier,
|
|
112
|
+
member: identifier,
|
|
113
|
+
program: identifier,
|
|
114
|
+
qualified: z2.boolean(),
|
|
115
|
+
reason
|
|
116
|
+
}).strict(),
|
|
117
|
+
z2.object({
|
|
118
|
+
kind: z2.literal("resolve-reward"),
|
|
119
|
+
actionId: identifier,
|
|
120
|
+
entitlement: identifier,
|
|
121
|
+
reason
|
|
122
|
+
}).strict()
|
|
123
|
+
]);
|
|
124
|
+
var referralRelationshipSchema = z2.object({
|
|
125
|
+
member: identifier,
|
|
126
|
+
inviter: identifier,
|
|
127
|
+
acceptedAt: amount,
|
|
128
|
+
suspended: z2.boolean()
|
|
129
|
+
});
|
|
130
|
+
var referralAccountSchema = z2.object({
|
|
131
|
+
id: identifier,
|
|
132
|
+
program: identifier,
|
|
133
|
+
kind: z2.enum(["bonus", "fixed", "milestone"]),
|
|
134
|
+
balance: identifier,
|
|
135
|
+
earned: amount,
|
|
136
|
+
settled: amount,
|
|
137
|
+
outstanding: amount
|
|
138
|
+
});
|
|
139
|
+
var referralSummarySchema = z2.object({
|
|
140
|
+
code: identifier,
|
|
141
|
+
attributed: amount,
|
|
142
|
+
programs: z2.array(
|
|
143
|
+
z2.object({
|
|
144
|
+
definition: referralDefinitionSchema,
|
|
145
|
+
qualified: amount,
|
|
146
|
+
milestones: z2.array(
|
|
147
|
+
z2.object({ id: identifier, count: amount, reached: z2.boolean() })
|
|
148
|
+
)
|
|
149
|
+
})
|
|
150
|
+
),
|
|
151
|
+
accounts: z2.array(referralAccountSchema)
|
|
152
|
+
});
|
|
153
|
+
var referralHistorySchema = z2.object({
|
|
154
|
+
items: z2.array(
|
|
155
|
+
z2.object({
|
|
156
|
+
id: amount,
|
|
157
|
+
program: identifier,
|
|
158
|
+
balance: identifier,
|
|
159
|
+
amount: z2.number().int().safe(),
|
|
160
|
+
at: amount,
|
|
161
|
+
reason: z2.string()
|
|
162
|
+
})
|
|
163
|
+
),
|
|
164
|
+
next: amount.nullable()
|
|
165
|
+
});
|
|
166
|
+
var referralManagementSchema = z2.object({
|
|
167
|
+
relationships: z2.array(referralRelationshipSchema),
|
|
168
|
+
qualifications: z2.array(
|
|
169
|
+
z2.object({
|
|
170
|
+
member: identifier,
|
|
171
|
+
program: identifier,
|
|
172
|
+
qualified: z2.boolean(),
|
|
173
|
+
qualifiedAt: amount
|
|
174
|
+
})
|
|
175
|
+
),
|
|
176
|
+
accounts: z2.array(
|
|
177
|
+
referralAccountSchema.extend({ member: identifier, invitee: z2.string() })
|
|
178
|
+
),
|
|
179
|
+
reviews: z2.array(
|
|
180
|
+
z2.object({
|
|
181
|
+
entitlement: identifier,
|
|
182
|
+
member: identifier,
|
|
183
|
+
program: identifier,
|
|
184
|
+
reason: z2.string()
|
|
185
|
+
})
|
|
186
|
+
),
|
|
187
|
+
next: amount.nullable()
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
// src/leaderboards.ts
|
|
191
|
+
import { z as z3 } from "zod";
|
|
192
|
+
var integer = z3.number().int().safe();
|
|
193
|
+
var timestamp = integer.nonnegative().max(864e13);
|
|
194
|
+
var leaderboardWindowSchema = z3.discriminatedUnion("kind", [
|
|
195
|
+
z3.object({ kind: z3.literal("all-time") }).strict(),
|
|
196
|
+
z3.object({ kind: z3.literal("fixed"), start: timestamp, end: timestamp }).strict().refine((w) => w.end > w.start, "Window end must follow its start"),
|
|
197
|
+
z3.object({ kind: z3.literal("rolling"), days: integer.min(1).max(3660) }).strict(),
|
|
198
|
+
z3.object({
|
|
199
|
+
kind: z3.literal("calendar"),
|
|
200
|
+
period: z3.enum(["day", "week", "month"]),
|
|
201
|
+
timeZone: z3.string().min(1).max(100).refine((zone) => {
|
|
202
|
+
try {
|
|
203
|
+
new Intl.DateTimeFormat("en", { timeZone: zone });
|
|
204
|
+
return true;
|
|
205
|
+
} catch {
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
}, "Use an IANA timezone")
|
|
209
|
+
}).strict()
|
|
210
|
+
]);
|
|
211
|
+
var periodScore = {
|
|
212
|
+
window: leaderboardWindowSchema.default({ kind: "all-time" }),
|
|
213
|
+
quests: z3.array(identifier).min(1).max(100).optional()
|
|
214
|
+
};
|
|
215
|
+
var leaderboardDefinitionSchema = z3.object({
|
|
216
|
+
id: identifier,
|
|
217
|
+
key: identifier.optional(),
|
|
218
|
+
title: z3.string().trim().min(1).max(120),
|
|
219
|
+
balance: identifier,
|
|
220
|
+
score: z3.discriminatedUnion("kind", [
|
|
221
|
+
z3.object({ kind: z3.literal("balance") }).strict(),
|
|
222
|
+
z3.object({ kind: z3.literal("earned"), ...periodScore }).strict(),
|
|
223
|
+
z3.object({
|
|
224
|
+
kind: z3.literal("net"),
|
|
225
|
+
window: leaderboardWindowSchema.default({ kind: "all-time" })
|
|
226
|
+
}).strict()
|
|
227
|
+
]).default({ kind: "balance" }),
|
|
228
|
+
access: z3.enum(["participants", "public"]).default("participants"),
|
|
229
|
+
group: identifier.optional()
|
|
230
|
+
}).strict();
|
|
231
|
+
var leaderboardAuthoringSchema = leaderboardDefinitionSchema.omit({ id: true }).extend(authoringIdentityShape).strict().superRefine(validateAuthoringIdentity).transform(normalizeAuthoringIdentity);
|
|
232
|
+
function defineLeaderboard(input) {
|
|
233
|
+
const definition = leaderboardAuthoringSchema.parse(input);
|
|
234
|
+
return {
|
|
235
|
+
...definition,
|
|
236
|
+
/** @deprecated Use key. */
|
|
237
|
+
id: definition.key
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
var leaderboardArtifactSchema = z3.union([
|
|
241
|
+
leaderboardAuthoringSchema,
|
|
242
|
+
z3.object({ code: z3.string().min(1).max(2e6) }).strict()
|
|
243
|
+
]);
|
|
244
|
+
var publishedLeaderboardSchema = z3.object({
|
|
245
|
+
version: identifier,
|
|
246
|
+
definition: leaderboardDefinitionSchema,
|
|
247
|
+
publishedAt: timestamp,
|
|
248
|
+
actor: z3.string().nullable()
|
|
249
|
+
});
|
|
250
|
+
var leaderboardQuerySchema = z3.object({
|
|
251
|
+
limit: z3.coerce.number().int().min(1).max(100).default(25),
|
|
252
|
+
cursor: z3.string().max(4096).optional()
|
|
253
|
+
}).strict();
|
|
254
|
+
var leaderboardRowSchema = z3.object({
|
|
255
|
+
participant: identifier,
|
|
256
|
+
member: identifier.optional(),
|
|
257
|
+
name: z3.string(),
|
|
258
|
+
score: integer,
|
|
259
|
+
rank: integer.positive()
|
|
260
|
+
});
|
|
261
|
+
var leaderboardPageSchema = z3.object({
|
|
262
|
+
leaderboard: identifier,
|
|
263
|
+
title: z3.string(),
|
|
264
|
+
version: identifier,
|
|
265
|
+
calculation: z3.enum(["balance", "earned", "net"]),
|
|
266
|
+
period: z3.object({ start: timestamp.nullable(), end: timestamp.nullable() }),
|
|
267
|
+
calculatedAt: timestamp,
|
|
268
|
+
lastEntryAt: timestamp.nullable(),
|
|
269
|
+
total: integer.nonnegative(),
|
|
270
|
+
items: z3.array(leaderboardRowSchema),
|
|
271
|
+
me: leaderboardRowSchema.nullable(),
|
|
272
|
+
nearby: z3.array(leaderboardRowSchema),
|
|
273
|
+
nextCursor: z3.string().nullable()
|
|
274
|
+
});
|
|
275
|
+
var leaderboardPreviewSchema = z3.object({
|
|
276
|
+
published: publishedLeaderboardSchema,
|
|
277
|
+
before: leaderboardPageSchema.nullable(),
|
|
278
|
+
after: leaderboardPageSchema
|
|
279
|
+
});
|
|
280
|
+
var mutationBase = {
|
|
281
|
+
actionId: identifier,
|
|
282
|
+
member: identifier,
|
|
283
|
+
balance: identifier,
|
|
284
|
+
reason: z3.string().trim().min(1).max(1e3)
|
|
285
|
+
};
|
|
286
|
+
var datedMutation = { ...mutationBase, effectiveAt: timestamp.optional() };
|
|
287
|
+
var pointsMutationSchema = z3.discriminatedUnion("kind", [
|
|
288
|
+
z3.object({
|
|
289
|
+
...datedMutation,
|
|
290
|
+
kind: z3.literal("award"),
|
|
291
|
+
referralEligible: z3.boolean().optional(),
|
|
292
|
+
amount: integer.positive()
|
|
293
|
+
}).strict(),
|
|
294
|
+
z3.object({
|
|
295
|
+
...datedMutation,
|
|
296
|
+
kind: z3.literal("spend"),
|
|
297
|
+
amount: integer.positive()
|
|
298
|
+
}).strict(),
|
|
299
|
+
z3.object({
|
|
300
|
+
...datedMutation,
|
|
301
|
+
kind: z3.literal("adjust"),
|
|
302
|
+
amount: integer.refine((n) => n !== 0)
|
|
303
|
+
}).strict(),
|
|
304
|
+
z3.object({
|
|
305
|
+
...datedMutation,
|
|
306
|
+
kind: z3.literal("set"),
|
|
307
|
+
total: integer.nonnegative(),
|
|
308
|
+
expectedTotal: integer.nonnegative(),
|
|
309
|
+
classification: z3.enum(["earned", "spend"])
|
|
310
|
+
}).strict(),
|
|
311
|
+
z3.object({
|
|
312
|
+
...mutationBase,
|
|
313
|
+
kind: z3.literal("reverse"),
|
|
314
|
+
entry: identifier,
|
|
315
|
+
amount: integer.positive()
|
|
316
|
+
}).strict()
|
|
317
|
+
]);
|
|
318
|
+
var pointsEntrySchema = z3.object({
|
|
319
|
+
id: identifier,
|
|
320
|
+
completion: z3.string().nullable(),
|
|
321
|
+
member: identifier,
|
|
322
|
+
balance: identifier,
|
|
323
|
+
amount: integer,
|
|
324
|
+
kind: z3.enum(["award", "spend", "adjust", "reverse"]),
|
|
325
|
+
effectiveAt: timestamp,
|
|
326
|
+
receivedAt: timestamp,
|
|
327
|
+
quest: identifier.nullable(),
|
|
328
|
+
original: identifier.nullable(),
|
|
329
|
+
reason: z3.string(),
|
|
330
|
+
actor: z3.string().nullable()
|
|
331
|
+
});
|
|
332
|
+
var pointsResultSchema = z3.object({
|
|
333
|
+
entry: pointsEntrySchema,
|
|
334
|
+
total: integer.nonnegative()
|
|
335
|
+
});
|
|
336
|
+
var pointsAccountSchema = z3.object({
|
|
337
|
+
member: identifier,
|
|
338
|
+
balance: identifier,
|
|
339
|
+
total: integer.nonnegative(),
|
|
340
|
+
held: integer.nonnegative()
|
|
341
|
+
});
|
|
342
|
+
var leaderboardExclusionSchema = z3.object({
|
|
343
|
+
actionId: identifier,
|
|
344
|
+
member: identifier,
|
|
345
|
+
excluded: z3.boolean(),
|
|
346
|
+
reason: z3.string().trim().min(1).max(1e3)
|
|
347
|
+
}).strict();
|
|
348
|
+
var leaderboardGroupSchema = z3.object({
|
|
349
|
+
actionId: identifier,
|
|
350
|
+
member: identifier,
|
|
351
|
+
included: z3.boolean(),
|
|
352
|
+
reason: z3.string().trim().min(1).max(1e3)
|
|
353
|
+
}).strict();
|
|
354
|
+
|
|
355
|
+
export {
|
|
356
|
+
authoringIdentityShape,
|
|
357
|
+
validateAuthoringIdentity,
|
|
358
|
+
normalizeAuthoringIdentity,
|
|
359
|
+
authoringKey,
|
|
360
|
+
referralDefinitionSchema,
|
|
361
|
+
referralAuthoringSchema,
|
|
362
|
+
defineReferral,
|
|
363
|
+
referralArtifactSchema,
|
|
364
|
+
publishedReferralSchema,
|
|
365
|
+
referralAcceptSchema,
|
|
366
|
+
referralControlSchema,
|
|
367
|
+
referralRelationshipSchema,
|
|
368
|
+
referralAccountSchema,
|
|
369
|
+
referralSummarySchema,
|
|
370
|
+
referralHistorySchema,
|
|
371
|
+
referralManagementSchema,
|
|
372
|
+
leaderboardWindowSchema,
|
|
373
|
+
leaderboardDefinitionSchema,
|
|
374
|
+
leaderboardAuthoringSchema,
|
|
375
|
+
defineLeaderboard,
|
|
376
|
+
leaderboardArtifactSchema,
|
|
377
|
+
publishedLeaderboardSchema,
|
|
378
|
+
leaderboardQuerySchema,
|
|
379
|
+
leaderboardRowSchema,
|
|
380
|
+
leaderboardPageSchema,
|
|
381
|
+
leaderboardPreviewSchema,
|
|
382
|
+
pointsMutationSchema,
|
|
383
|
+
pointsEntrySchema,
|
|
384
|
+
pointsResultSchema,
|
|
385
|
+
pointsAccountSchema,
|
|
386
|
+
leaderboardExclusionSchema,
|
|
387
|
+
leaderboardGroupSchema
|
|
388
|
+
};
|
|
@@ -145,6 +145,10 @@ var channelSourceSchema = z6.object({
|
|
|
145
145
|
types: z6.array(z6.enum(["text", "announcement"])).min(1)
|
|
146
146
|
}).strict();
|
|
147
147
|
var resourceSourceSchema = z6.union([
|
|
148
|
+
z6.object({
|
|
149
|
+
provider: z6.literal("domino"),
|
|
150
|
+
resource: z6.literal("point-ledger")
|
|
151
|
+
}).strict(),
|
|
148
152
|
channelSourceSchema,
|
|
149
153
|
z6.object({
|
|
150
154
|
provider: z6.literal("discord"),
|
|
@@ -187,6 +191,10 @@ var discord = {
|
|
|
187
191
|
});
|
|
188
192
|
}
|
|
189
193
|
};
|
|
194
|
+
var pointLedgers = () => ({
|
|
195
|
+
provider: "domino",
|
|
196
|
+
resource: "point-ledger"
|
|
197
|
+
});
|
|
190
198
|
|
|
191
199
|
// src/settings.ts
|
|
192
200
|
var instant = z7.iso.datetime({ offset: true }).transform((value) => new Date(value).toISOString());
|
|
@@ -397,7 +405,8 @@ var decisionSchema = z8.discriminatedUnion("kind", [
|
|
|
397
405
|
completionKey: completionKeySchema.optional()
|
|
398
406
|
}).strict()
|
|
399
407
|
]);
|
|
400
|
-
var reviewModeSchema = z8.enum([
|
|
408
|
+
var reviewModeSchema = z8.enum(["workers-ai"]);
|
|
409
|
+
var storedReviewModeSchema = z8.enum([
|
|
401
410
|
"fixture-pass",
|
|
402
411
|
"fixture-fail",
|
|
403
412
|
"fixture-unclear",
|
|
@@ -460,8 +469,9 @@ var questSettingsInputSchema = z8.object({
|
|
|
460
469
|
reset: z8.array(z8.string())
|
|
461
470
|
}).strict();
|
|
462
471
|
var storedReleaseSchema = questDescriptionSchema.extend({
|
|
472
|
+
key: identifier.optional(),
|
|
463
473
|
code: z8.string(),
|
|
464
|
-
provider:
|
|
474
|
+
provider: storedReviewModeSchema,
|
|
465
475
|
id: identifier,
|
|
466
476
|
createdAt: z8.number(),
|
|
467
477
|
legacy: z8.boolean().default(false),
|
|
@@ -480,7 +490,7 @@ var legacyReleaseSchema = z8.object({
|
|
|
480
490
|
humanReview: z8.boolean(),
|
|
481
491
|
rewards: rewardBundleSchema,
|
|
482
492
|
code: z8.string(),
|
|
483
|
-
provider:
|
|
493
|
+
provider: storedReviewModeSchema,
|
|
484
494
|
id: identifier,
|
|
485
495
|
createdAt: z8.number()
|
|
486
496
|
}).transform((r) => {
|
|
@@ -595,7 +605,22 @@ var configurePickupSchema = z8.object({
|
|
|
595
605
|
reward: identifier,
|
|
596
606
|
revision: z8.number().int().nonnegative(),
|
|
597
607
|
actionId: identifier,
|
|
598
|
-
policy:
|
|
608
|
+
policy: z8.discriminatedUnion("kind", [
|
|
609
|
+
z8.object({ kind: z8.literal("untracked") }).strict(),
|
|
610
|
+
z8.object({
|
|
611
|
+
kind: z8.literal("at-pickup"),
|
|
612
|
+
tiers: z8.array(
|
|
613
|
+
z8.object({
|
|
614
|
+
tier: identifier,
|
|
615
|
+
variants: z8.array(
|
|
616
|
+
pickupAllocationSchema.extend({
|
|
617
|
+
item: identifier.optional()
|
|
618
|
+
})
|
|
619
|
+
).min(1).max(100)
|
|
620
|
+
}).strict()
|
|
621
|
+
).min(1).max(100)
|
|
622
|
+
}).strict()
|
|
623
|
+
])
|
|
599
624
|
}).strict();
|
|
600
625
|
var entitlementBase = {
|
|
601
626
|
id: identifier,
|
|
@@ -659,6 +684,7 @@ var memberProgressSchema = z8.object({
|
|
|
659
684
|
quests: z8.array(
|
|
660
685
|
z8.object({
|
|
661
686
|
quest: identifier,
|
|
687
|
+
key: identifier.optional(),
|
|
662
688
|
release: identifier.optional(),
|
|
663
689
|
title: z8.string(),
|
|
664
690
|
presentation: questPresentationSchema.default({}),
|
|
@@ -744,6 +770,8 @@ var memberPageSchema = z8.object({
|
|
|
744
770
|
items: z8.array(z8.object({ member: identifier })).max(100),
|
|
745
771
|
nextCursor: z8.string().nullable()
|
|
746
772
|
});
|
|
773
|
+
var createStockItemSchema = z8.object({ actionId: identifier, name: z8.string().trim().min(1).max(80) }).strict();
|
|
774
|
+
var stockItemSchema = z8.object({ id: identifier, name: z8.string() });
|
|
747
775
|
|
|
748
776
|
export {
|
|
749
777
|
identifier,
|
|
@@ -772,6 +800,7 @@ export {
|
|
|
772
800
|
resourceRequestSchema,
|
|
773
801
|
resourceOptionsSchema,
|
|
774
802
|
discord,
|
|
803
|
+
pointLedgers,
|
|
775
804
|
settingFieldSchema,
|
|
776
805
|
settingsFieldsSchema,
|
|
777
806
|
settingsValuesSchema,
|
|
@@ -790,6 +819,7 @@ export {
|
|
|
790
819
|
photoResultSchema,
|
|
791
820
|
decisionSchema,
|
|
792
821
|
reviewModeSchema,
|
|
822
|
+
storedReviewModeSchema,
|
|
793
823
|
rewardBundleSchema,
|
|
794
824
|
mediaUrlSchema,
|
|
795
825
|
questPresentationSchema,
|
|
@@ -827,5 +857,7 @@ export {
|
|
|
827
857
|
memberListSchema,
|
|
828
858
|
reviewItemSchema,
|
|
829
859
|
reviewPageSchema,
|
|
830
|
-
memberPageSchema
|
|
860
|
+
memberPageSchema,
|
|
861
|
+
createStockItemSchema,
|
|
862
|
+
stockItemSchema
|
|
831
863
|
};
|
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
import {
|
|
2
|
+
authoringIdentityShape,
|
|
2
3
|
leaderboardArtifactSchema,
|
|
3
4
|
leaderboardDefinitionSchema,
|
|
4
5
|
leaderboardPageSchema,
|
|
5
6
|
leaderboardPreviewSchema,
|
|
6
7
|
leaderboardQuerySchema,
|
|
8
|
+
normalizeAuthoringIdentity,
|
|
7
9
|
publishedReferralSchema,
|
|
8
10
|
referralAcceptSchema,
|
|
9
11
|
referralArtifactSchema,
|
|
10
12
|
referralDefinitionSchema,
|
|
11
13
|
referralHistorySchema,
|
|
12
|
-
referralSummarySchema
|
|
13
|
-
|
|
14
|
+
referralSummarySchema,
|
|
15
|
+
validateAuthoringIdentity
|
|
16
|
+
} from "./chunk-Q5VDZVVO.js";
|
|
14
17
|
import {
|
|
15
18
|
authScopeSchema,
|
|
16
19
|
exchangeResultSchema,
|
|
17
20
|
sessionSchema
|
|
18
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-MVDE7WKB.js";
|
|
19
22
|
import {
|
|
20
23
|
accountConnectionSchema,
|
|
21
24
|
attemptSchema,
|
|
@@ -38,16 +41,21 @@ import {
|
|
|
38
41
|
reviewPageSchema,
|
|
39
42
|
settingsValuesSchema,
|
|
40
43
|
snapshotSchema,
|
|
44
|
+
storedReviewModeSchema,
|
|
41
45
|
templateSchema
|
|
42
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-XTFCKK2Y.js";
|
|
43
47
|
|
|
44
48
|
// src/point-ledgers.ts
|
|
45
49
|
import { z } from "zod";
|
|
46
|
-
var
|
|
47
|
-
id: identifier,
|
|
50
|
+
var pointLedgerPropertiesSchema = z.object({
|
|
48
51
|
name: z.string().trim().min(1).max(120),
|
|
49
52
|
description: z.string().trim().max(1e3).default("")
|
|
50
53
|
}).strict();
|
|
54
|
+
var createPointLedgerSchema = pointLedgerPropertiesSchema.extend({ actionId: identifier, key: identifier.optional() }).strict();
|
|
55
|
+
var pointLedgerSchema = pointLedgerPropertiesSchema.extend({
|
|
56
|
+
id: identifier
|
|
57
|
+
});
|
|
58
|
+
var pointLedgerDeclarationSchema = pointLedgerPropertiesSchema.extend({ key: identifier }).strict();
|
|
51
59
|
|
|
52
60
|
// src/reward-deliveries.ts
|
|
53
61
|
import { z as z2 } from "zod";
|
|
@@ -70,19 +78,6 @@ var rewardDeliveriesSchema = z2.object({
|
|
|
70
78
|
deliveries: z2.array(rewardDeliverySchema)
|
|
71
79
|
});
|
|
72
80
|
|
|
73
|
-
// src/resource-id.ts
|
|
74
|
-
var alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
75
|
-
function resourceId(prefix) {
|
|
76
|
-
let suffix = "";
|
|
77
|
-
while (suffix.length < 22) {
|
|
78
|
-
for (const byte of crypto.getRandomValues(new Uint8Array(32))) {
|
|
79
|
-
if (byte < 248) suffix += alphabet[byte % 62];
|
|
80
|
-
if (suffix.length === 22) break;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return `${prefix}_${suffix}`;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
81
|
// src/catalog.ts
|
|
87
82
|
import { z as z3 } from "zod";
|
|
88
83
|
var interactionSchema = z3.enum([
|
|
@@ -96,14 +91,20 @@ function questInteraction(trigger) {
|
|
|
96
91
|
return trigger.kind === "automatic" ? "automatic" : trigger.actor === "staff" ? "staff" : trigger.input === "none" ? "claim" : trigger.input;
|
|
97
92
|
}
|
|
98
93
|
var questTypeVersionSchema = z3.object({
|
|
94
|
+
key: identifier.optional(),
|
|
99
95
|
id: identifier,
|
|
100
96
|
version: identifier,
|
|
101
97
|
code: z3.string(),
|
|
102
98
|
definition: questDescriptionSchema,
|
|
103
|
-
provider:
|
|
99
|
+
provider: storedReviewModeSchema,
|
|
104
100
|
createdAt: z3.number()
|
|
105
101
|
});
|
|
106
|
-
var collectionSlotSchema = z3.object({
|
|
102
|
+
var collectionSlotSchema = z3.object({
|
|
103
|
+
id: identifier,
|
|
104
|
+
key: identifier.optional(),
|
|
105
|
+
title: z3.string().trim().min(1).max(120)
|
|
106
|
+
}).strict();
|
|
107
|
+
var collectionSlotDeclarationSchema = collectionSlotSchema.omit({ id: true }).extend(authoringIdentityShape).strict().superRefine(validateAuthoringIdentity).transform(normalizeAuthoringIdentity);
|
|
107
108
|
var questCollectionSchema = collectionSlotSchema.extend({
|
|
108
109
|
quests: z3.array(identifier).max(100).refine(
|
|
109
110
|
(v) => new Set(v).size === v.length,
|
|
@@ -154,7 +155,7 @@ var catalogDeploymentSchema = z3.object({
|
|
|
154
155
|
provider: reviewModeSchema
|
|
155
156
|
})
|
|
156
157
|
).max(50).default([]),
|
|
157
|
-
collections: z3.array(
|
|
158
|
+
collections: z3.array(collectionSlotDeclarationSchema).max(50).default([]),
|
|
158
159
|
supportedInteractions: z3.array(interactionSchema).min(1).optional()
|
|
159
160
|
}).strict();
|
|
160
161
|
var catalogDeploymentPreviewSchema = z3.object({
|
|
@@ -164,7 +165,8 @@ var catalogDeploymentPreviewSchema = z3.object({
|
|
|
164
165
|
supportedInteractions: z3.array(interactionSchema)
|
|
165
166
|
});
|
|
166
167
|
var saveQuestDraftSchema = z3.object({
|
|
167
|
-
id: identifier,
|
|
168
|
+
id: identifier.optional(),
|
|
169
|
+
actionId: identifier,
|
|
168
170
|
expectedRevision: z3.number().int().nonnegative(),
|
|
169
171
|
baseRevision: z3.number().int().nonnegative(),
|
|
170
172
|
changes: questDraftChangesSchema
|
|
@@ -179,6 +181,7 @@ var questViewSchema = memberProgressSchema.shape.quests.element.extend(
|
|
|
179
181
|
}
|
|
180
182
|
);
|
|
181
183
|
var collectionViewSchema = z3.object({
|
|
184
|
+
key: identifier.optional(),
|
|
182
185
|
id: identifier,
|
|
183
186
|
title: z3.string(),
|
|
184
187
|
quests: z3.array(questViewSchema)
|
|
@@ -193,6 +196,8 @@ var questPublicationPreviewSchema = z3.object({
|
|
|
193
196
|
releases: z3.array(publishedReleaseSchema),
|
|
194
197
|
affectedCollections: z3.array(questCollectionSchema)
|
|
195
198
|
});
|
|
199
|
+
var allocateQuestSchema = z3.object({ actionId: identifier }).strict();
|
|
200
|
+
var allocatedQuestSchema = z3.object({ id: identifier });
|
|
196
201
|
|
|
197
202
|
// src/errors.ts
|
|
198
203
|
var RelayError = class extends Error {
|
|
@@ -727,16 +732,18 @@ function questConfiguration(release) {
|
|
|
727
732
|
// src/deployments.ts
|
|
728
733
|
import { z as z7 } from "zod";
|
|
729
734
|
var projectCatalogArtifactSchema = catalogDeploymentSchema.omit({ expectedRevision: true }).extend({
|
|
735
|
+
pointLedgers: z7.array(pointLedgerDeclarationSchema).max(50).default([]),
|
|
730
736
|
referrals: z7.array(referralArtifactSchema).max(50).default([]),
|
|
731
737
|
leaderboards: z7.array(leaderboardArtifactSchema).max(50).default([])
|
|
732
738
|
});
|
|
733
739
|
var projectDeploymentSchema = projectCatalogArtifactSchema.extend({ releases: z7.array(releaseSchema).max(50).default([]) }).refine(
|
|
734
|
-
(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,
|
|
735
|
-
"No resources configured. Add quests, questTypes, leaderboards, collections, or supportedInteractions to relay.json."
|
|
740
|
+
(value) => value.pointLedgers.length > 0 || value.releases.length > 0 || value.leaderboards.length > 0 || value.referrals.length > 0 || value.types.length > 0 || value.collections.length > 0 || value.supportedInteractions !== void 0,
|
|
741
|
+
"No resources configured. Add quests, questTypes, pointLedgers, leaderboards, referrals, collections, or supportedInteractions to relay.json."
|
|
736
742
|
);
|
|
737
743
|
var deploymentPreviewSchema = z7.object({
|
|
738
744
|
id: identifier,
|
|
739
745
|
baseRevision: z7.number().int().nonnegative(),
|
|
746
|
+
pointLedgers: z7.array(pointLedgerSchema).default([]),
|
|
740
747
|
releases: z7.array(publishedReleaseSchema),
|
|
741
748
|
types: z7.array(questTypeVersionSchema),
|
|
742
749
|
collections: z7.array(questCollectionSchema),
|
|
@@ -878,7 +885,9 @@ function createRelayClient(options) {
|
|
|
878
885
|
}
|
|
879
886
|
const experience = () => request("/v1/me/experience", questExperienceSchema);
|
|
880
887
|
async function getQuest(id) {
|
|
881
|
-
const quest = (await experience()).quests.find(
|
|
888
|
+
const quest = (await experience()).quests.find(
|
|
889
|
+
(q) => q.quest === id || q.key === id
|
|
890
|
+
);
|
|
882
891
|
if (!quest) throw new RelayError("Quest not found", 404);
|
|
883
892
|
return quest;
|
|
884
893
|
}
|
|
@@ -931,7 +940,7 @@ function createRelayClient(options) {
|
|
|
931
940
|
experience,
|
|
932
941
|
collection: async (id) => {
|
|
933
942
|
const collection = (await experience()).collections.find(
|
|
934
|
-
(c) => c.id === id
|
|
943
|
+
(c) => c.id === id || c.key === id
|
|
935
944
|
);
|
|
936
945
|
if (!collection) throw new RelayError("Collection not found", 404);
|
|
937
946
|
return collection;
|
|
@@ -1132,14 +1141,17 @@ function createRelayClient(options) {
|
|
|
1132
1141
|
}
|
|
1133
1142
|
|
|
1134
1143
|
export {
|
|
1144
|
+
pointLedgerPropertiesSchema,
|
|
1145
|
+
createPointLedgerSchema,
|
|
1135
1146
|
pointLedgerSchema,
|
|
1147
|
+
pointLedgerDeclarationSchema,
|
|
1136
1148
|
rewardDeliverySchema,
|
|
1137
1149
|
rewardDeliveriesSchema,
|
|
1138
|
-
resourceId,
|
|
1139
1150
|
interactionSchema,
|
|
1140
1151
|
questInteraction,
|
|
1141
1152
|
questTypeVersionSchema,
|
|
1142
1153
|
collectionSlotSchema,
|
|
1154
|
+
collectionSlotDeclarationSchema,
|
|
1143
1155
|
questCollectionSchema,
|
|
1144
1156
|
questInstanceSchema,
|
|
1145
1157
|
questDraftChangesSchema,
|
|
@@ -1153,6 +1165,8 @@ export {
|
|
|
1153
1165
|
collectionViewSchema,
|
|
1154
1166
|
questExperienceSchema,
|
|
1155
1167
|
questPublicationPreviewSchema,
|
|
1168
|
+
allocateQuestSchema,
|
|
1169
|
+
allocatedQuestSchema,
|
|
1156
1170
|
RelayError,
|
|
1157
1171
|
QuestUpdatedError,
|
|
1158
1172
|
reconcileQuestDraft,
|