@domino-sdk/relay 0.6.0 → 0.8.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 +18 -9
- package/dist/authoring.js +19 -9
- package/dist/browser.d.ts +91 -37
- package/dist/browser.js +4 -4
- package/dist/{chunk-PLO5PPLU.js → chunk-2BN7XZH3.js} +1 -1
- package/dist/{chunk-CCLIDCUU.js → chunk-APMYDKEX.js} +211 -189
- package/dist/chunk-XVHWBZRG.js +388 -0
- package/dist/{chunk-MXK7KEDA.js → chunk-Z43O273V.js} +45 -3
- package/dist/index.d.ts +982 -128
- package/dist/index.js +28 -6
- package/dist/portal-proxy.js +2 -2
- package/dist/schema.d.ts +63 -2
- package/dist/schema.js +5 -1
- package/dist/{settings-BrC6C9yl.d.ts → settings-BA8XjT4m.d.ts} +779 -23
- package/package.json +1 -1
- package/dist/chunk-UIC6OF3C.js +0 -337
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
import {
|
|
2
|
+
identifier,
|
|
3
|
+
pointsRewardSchema,
|
|
4
|
+
tierRewardSchema
|
|
5
|
+
} from "./chunk-Z43O273V.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,12 +191,17 @@ 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());
|
|
193
201
|
var resourceId = z7.union([z7.literal(""), z7.string().regex(/^\S{1,200}$/)]);
|
|
194
202
|
var base = { label: z7.string().min(1), description: z7.string().optional() };
|
|
195
203
|
var settingFieldSchema = z7.discriminatedUnion("kind", [
|
|
204
|
+
z7.object({ ...base, kind: z7.literal("point-ledger"), default: identifier }).strict(),
|
|
196
205
|
z7.object({ ...base, kind: z7.literal("datetime"), default: instant }).strict(),
|
|
197
206
|
z7.object({
|
|
198
207
|
...base,
|
|
@@ -233,6 +242,14 @@ var settingsValuesSchema = z7.record(
|
|
|
233
242
|
z7.union([z7.string(), z7.number().finite(), z7.boolean(), quizContentSchema])
|
|
234
243
|
);
|
|
235
244
|
var settings = {
|
|
245
|
+
pointLedger(options) {
|
|
246
|
+
const field = {
|
|
247
|
+
...options,
|
|
248
|
+
kind: "point-ledger",
|
|
249
|
+
default: identifier.parse(options.default)
|
|
250
|
+
};
|
|
251
|
+
return identifier.default(field.default).meta(field);
|
|
252
|
+
},
|
|
236
253
|
datetime(options) {
|
|
237
254
|
const field = {
|
|
238
255
|
...options,
|
|
@@ -281,6 +298,9 @@ function parseSettings(fields, input) {
|
|
|
281
298
|
const shape = {};
|
|
282
299
|
for (const [key, field] of Object.entries(fields)) {
|
|
283
300
|
switch (field.kind) {
|
|
301
|
+
case "point-ledger":
|
|
302
|
+
shape[key] = identifier.default(field.default);
|
|
303
|
+
break;
|
|
284
304
|
case "datetime":
|
|
285
305
|
shape[key] = instant.default(field.default);
|
|
286
306
|
break;
|
|
@@ -310,7 +330,7 @@ function missingResourceSettings(fields, values) {
|
|
|
310
330
|
return Object.entries(fields).filter(([key, field]) => field.kind === "resource" && !values[key]).map(([key]) => key);
|
|
311
331
|
}
|
|
312
332
|
function compatibleSettingKinds(previous, next) {
|
|
313
|
-
return previous.kind === next.kind || previous.kind === "text" && (next.kind === "resource" || next.kind === "datetime");
|
|
333
|
+
return previous.kind === next.kind || previous.kind === "text" && (next.kind === "resource" || next.kind === "datetime" || next.kind === "point-ledger");
|
|
314
334
|
}
|
|
315
335
|
|
|
316
336
|
// src/schema.ts
|
|
@@ -448,6 +468,7 @@ var questSettingsInputSchema = z8.object({
|
|
|
448
468
|
reset: z8.array(z8.string())
|
|
449
469
|
}).strict();
|
|
450
470
|
var storedReleaseSchema = questDescriptionSchema.extend({
|
|
471
|
+
key: identifier.optional(),
|
|
451
472
|
code: z8.string(),
|
|
452
473
|
provider: reviewModeSchema,
|
|
453
474
|
id: identifier,
|
|
@@ -583,7 +604,22 @@ var configurePickupSchema = z8.object({
|
|
|
583
604
|
reward: identifier,
|
|
584
605
|
revision: z8.number().int().nonnegative(),
|
|
585
606
|
actionId: identifier,
|
|
586
|
-
policy:
|
|
607
|
+
policy: z8.discriminatedUnion("kind", [
|
|
608
|
+
z8.object({ kind: z8.literal("untracked") }).strict(),
|
|
609
|
+
z8.object({
|
|
610
|
+
kind: z8.literal("at-pickup"),
|
|
611
|
+
tiers: z8.array(
|
|
612
|
+
z8.object({
|
|
613
|
+
tier: identifier,
|
|
614
|
+
variants: z8.array(
|
|
615
|
+
pickupAllocationSchema.extend({
|
|
616
|
+
item: identifier.optional()
|
|
617
|
+
})
|
|
618
|
+
).min(1).max(100)
|
|
619
|
+
}).strict()
|
|
620
|
+
).min(1).max(100)
|
|
621
|
+
}).strict()
|
|
622
|
+
])
|
|
587
623
|
}).strict();
|
|
588
624
|
var entitlementBase = {
|
|
589
625
|
id: identifier,
|
|
@@ -647,6 +683,7 @@ var memberProgressSchema = z8.object({
|
|
|
647
683
|
quests: z8.array(
|
|
648
684
|
z8.object({
|
|
649
685
|
quest: identifier,
|
|
686
|
+
key: identifier.optional(),
|
|
650
687
|
release: identifier.optional(),
|
|
651
688
|
title: z8.string(),
|
|
652
689
|
presentation: questPresentationSchema.default({}),
|
|
@@ -732,6 +769,8 @@ var memberPageSchema = z8.object({
|
|
|
732
769
|
items: z8.array(z8.object({ member: identifier })).max(100),
|
|
733
770
|
nextCursor: z8.string().nullable()
|
|
734
771
|
});
|
|
772
|
+
var createStockItemSchema = z8.object({ actionId: identifier, name: z8.string().trim().min(1).max(80) }).strict();
|
|
773
|
+
var stockItemSchema = z8.object({ id: identifier, name: z8.string() });
|
|
735
774
|
|
|
736
775
|
export {
|
|
737
776
|
identifier,
|
|
@@ -760,6 +799,7 @@ export {
|
|
|
760
799
|
resourceRequestSchema,
|
|
761
800
|
resourceOptionsSchema,
|
|
762
801
|
discord,
|
|
802
|
+
pointLedgers,
|
|
763
803
|
settingFieldSchema,
|
|
764
804
|
settingsFieldsSchema,
|
|
765
805
|
settingsValuesSchema,
|
|
@@ -815,5 +855,7 @@ export {
|
|
|
815
855
|
memberListSchema,
|
|
816
856
|
reviewItemSchema,
|
|
817
857
|
reviewPageSchema,
|
|
818
|
-
memberPageSchema
|
|
858
|
+
memberPageSchema,
|
|
859
|
+
createStockItemSchema,
|
|
860
|
+
stockItemSchema
|
|
819
861
|
};
|