@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
|
@@ -0,0 +1,819 @@
|
|
|
1
|
+
// src/identifier.ts
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
var identifier = z.string().min(1).max(100).regex(/^[a-zA-Z0-9_-]+$/);
|
|
4
|
+
|
|
5
|
+
// src/observations.ts
|
|
6
|
+
import { z as z2 } from "zod";
|
|
7
|
+
var name = z2.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,199}$/);
|
|
8
|
+
var observationInputSchema = z2.object({
|
|
9
|
+
id: name,
|
|
10
|
+
source: name,
|
|
11
|
+
type: name,
|
|
12
|
+
member: identifier,
|
|
13
|
+
actor: z2.object({ provider: identifier, subject: z2.string().min(1).max(200) }).strict().optional(),
|
|
14
|
+
occurredAt: z2.number().int().nonnegative().max(864e13),
|
|
15
|
+
data: z2.record(z2.string(), z2.json())
|
|
16
|
+
}).strict().refine(
|
|
17
|
+
(value) => JSON.stringify(value.data).length <= 32768,
|
|
18
|
+
"Observation data exceeds 32 KB"
|
|
19
|
+
);
|
|
20
|
+
var observationSchema = observationInputSchema.safeExtend({
|
|
21
|
+
receivedAt: z2.number().int().nonnegative()
|
|
22
|
+
});
|
|
23
|
+
var observationTriggerSchema = z2.object({ source: name, type: name }).strict();
|
|
24
|
+
var completionPolicySchema = z2.discriminatedUnion("kind", [
|
|
25
|
+
z2.object({ kind: z2.literal("once") }).strict(),
|
|
26
|
+
z2.object({ kind: z2.literal("keyed") }).strict()
|
|
27
|
+
]);
|
|
28
|
+
var completionKeySchema = z2.string().min(1).max(500);
|
|
29
|
+
var budgetSchema = z2.object({
|
|
30
|
+
id: name,
|
|
31
|
+
scope: z2.enum(["member", "project"]),
|
|
32
|
+
period: z2.enum(["lifetime", "day"]),
|
|
33
|
+
limit: z2.number().int().positive().max(Number.MAX_SAFE_INTEGER),
|
|
34
|
+
cost: z2.union([
|
|
35
|
+
z2.number().int().positive().max(Number.MAX_SAFE_INTEGER),
|
|
36
|
+
z2.object({ balance: name }).strict()
|
|
37
|
+
])
|
|
38
|
+
}).strict();
|
|
39
|
+
var observationReceiptSchema = z2.object({
|
|
40
|
+
id: name,
|
|
41
|
+
source: name,
|
|
42
|
+
attempts: z2.array(z2.string()),
|
|
43
|
+
receivedAt: z2.number()
|
|
44
|
+
});
|
|
45
|
+
var discordReactionSchema = z2.object({
|
|
46
|
+
guildId: z2.string(),
|
|
47
|
+
channelId: z2.string(),
|
|
48
|
+
messageId: z2.string(),
|
|
49
|
+
userId: z2.string(),
|
|
50
|
+
messageAuthorId: z2.string().nullable().default(null),
|
|
51
|
+
actorRoles: z2.array(z2.string()).default([]),
|
|
52
|
+
emoji: z2.object({ id: z2.string().nullable(), name: z2.string() }),
|
|
53
|
+
messagePublishedAt: z2.number()
|
|
54
|
+
}).strict();
|
|
55
|
+
var discordMessageSchema = z2.object({
|
|
56
|
+
guildId: z2.string(),
|
|
57
|
+
channelId: z2.string(),
|
|
58
|
+
messageId: z2.string(),
|
|
59
|
+
userId: z2.string(),
|
|
60
|
+
content: z2.string().nullable(),
|
|
61
|
+
replyTo: z2.string().nullable(),
|
|
62
|
+
publishedAt: z2.number()
|
|
63
|
+
}).strict();
|
|
64
|
+
|
|
65
|
+
// src/integrations.ts
|
|
66
|
+
import { z as z3 } from "zod";
|
|
67
|
+
var integrationProviderSchema = z3.enum(["discord"]);
|
|
68
|
+
var discordServerSchema = z3.object({
|
|
69
|
+
id: z3.string().regex(/^[0-9]{1,20}$/),
|
|
70
|
+
name: z3.string().min(1),
|
|
71
|
+
icon: z3.string().nullable()
|
|
72
|
+
});
|
|
73
|
+
var projectIntegrationSchema = z3.object({
|
|
74
|
+
provider: integrationProviderSchema,
|
|
75
|
+
configured: z3.boolean(),
|
|
76
|
+
status: z3.enum(["disconnected", "ready", "attention"]),
|
|
77
|
+
revision: z3.number().int().nonnegative(),
|
|
78
|
+
server: discordServerSchema.nullable(),
|
|
79
|
+
issue: z3.string().nullable(),
|
|
80
|
+
connectedAt: z3.number().default(0)
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
// src/accounts.ts
|
|
84
|
+
import { z as z4 } from "zod";
|
|
85
|
+
var authProviderSchema = z4.enum(["google", "apple", "x", "discord"]);
|
|
86
|
+
var accountConnectionSchema = z4.object({
|
|
87
|
+
provider: authProviderSchema,
|
|
88
|
+
configured: z4.boolean(),
|
|
89
|
+
status: z4.enum(["disconnected", "connected", "reconnect"]),
|
|
90
|
+
subject: z4.string().nullable(),
|
|
91
|
+
revision: z4.number().int().nonnegative()
|
|
92
|
+
});
|
|
93
|
+
var discordMemberInputSchema = z4.object({}).strict();
|
|
94
|
+
var discordMessageInputSchema = z4.object({
|
|
95
|
+
channelId: z4.string().regex(/^[0-9]{1,20}$/),
|
|
96
|
+
messageId: z4.string().regex(/^[0-9]{1,20}$/)
|
|
97
|
+
}).strict();
|
|
98
|
+
var discordMemberSchema = z4.object({
|
|
99
|
+
userId: z4.string().regex(/^[0-9]{1,20}$/).nullable().default(null),
|
|
100
|
+
nickname: z4.string().nullable().default(null),
|
|
101
|
+
displayName: z4.string().nullable().default(null),
|
|
102
|
+
boostingSince: z4.string().datetime({ offset: true }).nullable().default(null),
|
|
103
|
+
roles: z4.array(z4.string().regex(/^[0-9]{1,20}$/)),
|
|
104
|
+
joinedAt: z4.string().datetime({ offset: true }).nullable(),
|
|
105
|
+
pending: z4.boolean()
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
// src/quiz.ts
|
|
109
|
+
import { z as z5 } from "zod";
|
|
110
|
+
var quizId = z5.string().regex(/^[a-zA-Z0-9_-]+$/).max(100);
|
|
111
|
+
var quizChoiceSchema = z5.object({ id: quizId, label: z5.string().trim().min(1).max(500) }).strict();
|
|
112
|
+
var quizQuestionSchema = z5.object({
|
|
113
|
+
id: quizId,
|
|
114
|
+
prompt: z5.string().trim().min(1).max(1e3),
|
|
115
|
+
choices: z5.array(quizChoiceSchema).min(2).max(8).refine(
|
|
116
|
+
(choices) => new Set(choices.map((choice) => choice.id)).size === choices.length,
|
|
117
|
+
"Choice IDs must be unique"
|
|
118
|
+
)
|
|
119
|
+
}).strict();
|
|
120
|
+
var quizQuestionsSchema = z5.array(quizQuestionSchema).min(1).max(20).refine(
|
|
121
|
+
(questions) => new Set(questions.map((question) => question.id)).size === questions.length,
|
|
122
|
+
"Question IDs must be unique"
|
|
123
|
+
);
|
|
124
|
+
var quizContentSchema = z5.array(
|
|
125
|
+
quizQuestionSchema.extend({ correct: quizId }).refine(
|
|
126
|
+
(question) => question.choices.some((choice) => choice.id === question.correct),
|
|
127
|
+
"Choose a correct answer from the available choices"
|
|
128
|
+
)
|
|
129
|
+
).min(1).max(20).refine(
|
|
130
|
+
(questions) => new Set(questions.map((question) => question.id)).size === questions.length,
|
|
131
|
+
"Question IDs must be unique"
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
// src/schema.ts
|
|
135
|
+
import { z as z8 } from "zod";
|
|
136
|
+
|
|
137
|
+
// src/settings.ts
|
|
138
|
+
import { z as z7 } from "zod";
|
|
139
|
+
|
|
140
|
+
// src/resources.ts
|
|
141
|
+
import { z as z6 } from "zod";
|
|
142
|
+
var channelSourceSchema = z6.object({
|
|
143
|
+
provider: z6.literal("discord"),
|
|
144
|
+
resource: z6.literal("channel"),
|
|
145
|
+
types: z6.array(z6.enum(["text", "announcement"])).min(1)
|
|
146
|
+
}).strict();
|
|
147
|
+
var resourceSourceSchema = z6.union([
|
|
148
|
+
channelSourceSchema,
|
|
149
|
+
z6.object({
|
|
150
|
+
provider: z6.literal("discord"),
|
|
151
|
+
resource: z6.literal("role"),
|
|
152
|
+
assignable: z6.boolean().default(false)
|
|
153
|
+
}).strict()
|
|
154
|
+
]);
|
|
155
|
+
var resourceRequestSchema = z6.object({
|
|
156
|
+
source: resourceSourceSchema,
|
|
157
|
+
query: z6.string().max(100).optional(),
|
|
158
|
+
cursor: z6.string().regex(/^\d{1,6}$/).optional(),
|
|
159
|
+
ids: z6.array(z6.string().min(1).max(100)).max(50).optional()
|
|
160
|
+
}).strict();
|
|
161
|
+
var resourceOptionsSchema = z6.object({
|
|
162
|
+
revision: z6.number().int(),
|
|
163
|
+
options: z6.array(
|
|
164
|
+
z6.object({
|
|
165
|
+
id: z6.string(),
|
|
166
|
+
label: z6.string(),
|
|
167
|
+
description: z6.string().optional(),
|
|
168
|
+
group: z6.string().optional(),
|
|
169
|
+
disabledReason: z6.string().optional()
|
|
170
|
+
})
|
|
171
|
+
),
|
|
172
|
+
cursor: z6.string().nullable()
|
|
173
|
+
});
|
|
174
|
+
var discord = {
|
|
175
|
+
roles(options = {}) {
|
|
176
|
+
return resourceSourceSchema.parse({
|
|
177
|
+
provider: "discord",
|
|
178
|
+
resource: "role",
|
|
179
|
+
assignable: options.assignable ?? false
|
|
180
|
+
});
|
|
181
|
+
},
|
|
182
|
+
channels(options = {}) {
|
|
183
|
+
return resourceSourceSchema.parse({
|
|
184
|
+
provider: "discord",
|
|
185
|
+
resource: "channel",
|
|
186
|
+
types: options.types ?? ["text", "announcement"]
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
// src/settings.ts
|
|
192
|
+
var instant = z7.iso.datetime({ offset: true }).transform((value) => new Date(value).toISOString());
|
|
193
|
+
var resourceId = z7.union([z7.literal(""), z7.string().regex(/^\S{1,200}$/)]);
|
|
194
|
+
var base = { label: z7.string().min(1), description: z7.string().optional() };
|
|
195
|
+
var settingFieldSchema = z7.discriminatedUnion("kind", [
|
|
196
|
+
z7.object({ ...base, kind: z7.literal("datetime"), default: instant }).strict(),
|
|
197
|
+
z7.object({
|
|
198
|
+
...base,
|
|
199
|
+
kind: z7.literal("resource"),
|
|
200
|
+
default: resourceId,
|
|
201
|
+
source: resourceSourceSchema
|
|
202
|
+
}).strict(),
|
|
203
|
+
z7.object({ ...base, kind: z7.literal("quiz"), default: quizContentSchema }).strict(),
|
|
204
|
+
z7.object({
|
|
205
|
+
...base,
|
|
206
|
+
kind: z7.literal("text"),
|
|
207
|
+
default: z7.string(),
|
|
208
|
+
minLength: z7.number().int().nonnegative(),
|
|
209
|
+
maxLength: z7.number().int().positive(),
|
|
210
|
+
multiline: z7.boolean()
|
|
211
|
+
}).strict(),
|
|
212
|
+
z7.object({
|
|
213
|
+
...base,
|
|
214
|
+
kind: z7.literal("integer"),
|
|
215
|
+
default: z7.number().int(),
|
|
216
|
+
min: z7.number().int(),
|
|
217
|
+
max: z7.number().int()
|
|
218
|
+
}).strict(),
|
|
219
|
+
z7.object({ ...base, kind: z7.literal("boolean"), default: z7.boolean() }).strict(),
|
|
220
|
+
z7.object({
|
|
221
|
+
...base,
|
|
222
|
+
kind: z7.literal("choice"),
|
|
223
|
+
default: z7.string(),
|
|
224
|
+
options: z7.array(z7.string().min(1)).min(1)
|
|
225
|
+
}).strict()
|
|
226
|
+
]);
|
|
227
|
+
var settingsFieldsSchema = z7.record(
|
|
228
|
+
z7.string().regex(/^[a-zA-Z][a-zA-Z0-9_]*$/),
|
|
229
|
+
settingFieldSchema
|
|
230
|
+
);
|
|
231
|
+
var settingsValuesSchema = z7.record(
|
|
232
|
+
z7.string(),
|
|
233
|
+
z7.union([z7.string(), z7.number().finite(), z7.boolean(), quizContentSchema])
|
|
234
|
+
);
|
|
235
|
+
var settings = {
|
|
236
|
+
datetime(options) {
|
|
237
|
+
const field = {
|
|
238
|
+
...options,
|
|
239
|
+
kind: "datetime",
|
|
240
|
+
default: instant.parse(options.default)
|
|
241
|
+
};
|
|
242
|
+
return instant.default(field.default).meta(field);
|
|
243
|
+
},
|
|
244
|
+
resource(options) {
|
|
245
|
+
const field = {
|
|
246
|
+
...options,
|
|
247
|
+
source: resourceSourceSchema.parse(options.source),
|
|
248
|
+
kind: "resource",
|
|
249
|
+
default: resourceId.parse(options.default ?? "")
|
|
250
|
+
};
|
|
251
|
+
return resourceId.default(field.default).meta(field);
|
|
252
|
+
},
|
|
253
|
+
quiz(options) {
|
|
254
|
+
const value = quizContentSchema.parse(options.default);
|
|
255
|
+
return quizContentSchema.default(value).meta({ ...options, default: value, kind: "quiz" });
|
|
256
|
+
},
|
|
257
|
+
text(options) {
|
|
258
|
+
const field = {
|
|
259
|
+
...options,
|
|
260
|
+
kind: "text",
|
|
261
|
+
minLength: options.minLength ?? 1,
|
|
262
|
+
maxLength: options.maxLength ?? 2e3,
|
|
263
|
+
multiline: options.multiline ?? false
|
|
264
|
+
};
|
|
265
|
+
return z7.string().min(field.minLength).max(field.maxLength).default(field.default).meta(field);
|
|
266
|
+
},
|
|
267
|
+
integer(options) {
|
|
268
|
+
return z7.number().int().min(options.min).max(options.max).default(options.default).meta({ ...options, kind: "integer" });
|
|
269
|
+
},
|
|
270
|
+
boolean(options) {
|
|
271
|
+
return z7.boolean().default(options.default).meta({ ...options, kind: "boolean" });
|
|
272
|
+
},
|
|
273
|
+
choice(options) {
|
|
274
|
+
return z7.enum(options.options).default(options.default).meta({ ...options, kind: "choice" });
|
|
275
|
+
},
|
|
276
|
+
object(shape) {
|
|
277
|
+
return z7.object(shape).strict();
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
function parseSettings(fields, input) {
|
|
281
|
+
const shape = {};
|
|
282
|
+
for (const [key, field] of Object.entries(fields)) {
|
|
283
|
+
switch (field.kind) {
|
|
284
|
+
case "datetime":
|
|
285
|
+
shape[key] = instant.default(field.default);
|
|
286
|
+
break;
|
|
287
|
+
case "resource":
|
|
288
|
+
shape[key] = resourceId.default(field.default);
|
|
289
|
+
break;
|
|
290
|
+
case "quiz":
|
|
291
|
+
shape[key] = quizContentSchema.default(field.default);
|
|
292
|
+
break;
|
|
293
|
+
case "text":
|
|
294
|
+
shape[key] = z7.string().min(field.minLength).max(field.maxLength).default(field.default);
|
|
295
|
+
break;
|
|
296
|
+
case "integer":
|
|
297
|
+
shape[key] = z7.number().int().min(field.min).max(field.max).default(field.default);
|
|
298
|
+
break;
|
|
299
|
+
case "boolean":
|
|
300
|
+
shape[key] = z7.boolean().default(field.default);
|
|
301
|
+
break;
|
|
302
|
+
case "choice":
|
|
303
|
+
shape[key] = z7.enum(field.options).default(field.default);
|
|
304
|
+
break;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
return settingsValuesSchema.parse(z7.object(shape).strict().parse(input));
|
|
308
|
+
}
|
|
309
|
+
function missingResourceSettings(fields, values) {
|
|
310
|
+
return Object.entries(fields).filter(([key, field]) => field.kind === "resource" && !values[key]).map(([key]) => key);
|
|
311
|
+
}
|
|
312
|
+
function compatibleSettingKinds(previous, next) {
|
|
313
|
+
return previous.kind === next.kind || previous.kind === "text" && (next.kind === "resource" || next.kind === "datetime");
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// src/schema.ts
|
|
317
|
+
var pointsRewardSchema = z8.object({
|
|
318
|
+
kind: z8.literal("points").default("points"),
|
|
319
|
+
balance: identifier,
|
|
320
|
+
amount: z8.number().int().min(0).max(1e4)
|
|
321
|
+
}).strict();
|
|
322
|
+
var tieredRewardDefinitionSchema = z8.object({
|
|
323
|
+
id: identifier,
|
|
324
|
+
title: z8.string().min(1).max(120),
|
|
325
|
+
tiers: z8.array(
|
|
326
|
+
z8.object({ id: identifier, title: z8.string().min(1).max(120) }).strict()
|
|
327
|
+
).min(1).max(20).refine(
|
|
328
|
+
(tiers) => new Set(tiers.map((t) => t.id)).size === tiers.length,
|
|
329
|
+
"Tier IDs must be unique"
|
|
330
|
+
),
|
|
331
|
+
inventory: z8.object({ kind: z8.literal("untracked") }).strict(),
|
|
332
|
+
fulfillment: z8.object({ kind: z8.literal("staff-handover") }).strict()
|
|
333
|
+
}).strict();
|
|
334
|
+
var tierRewardSchema = z8.object({
|
|
335
|
+
kind: z8.literal("tier"),
|
|
336
|
+
reward: tieredRewardDefinitionSchema,
|
|
337
|
+
tier: identifier
|
|
338
|
+
}).strict().refine(
|
|
339
|
+
(value) => value.reward.tiers.some((t) => t.id === value.tier),
|
|
340
|
+
"Unknown reward tier"
|
|
341
|
+
);
|
|
342
|
+
var integrationRewardSchema = z8.object({
|
|
343
|
+
kind: z8.literal("integration"),
|
|
344
|
+
provider: z8.literal("discord"),
|
|
345
|
+
action: z8.literal("grant-role"),
|
|
346
|
+
roleId: z8.string().regex(/^[0-9]{1,20}$/)
|
|
347
|
+
}).strict();
|
|
348
|
+
var rewardSchema = z8.union([
|
|
349
|
+
pointsRewardSchema,
|
|
350
|
+
tierRewardSchema,
|
|
351
|
+
integrationRewardSchema
|
|
352
|
+
]);
|
|
353
|
+
function rewardKey(reward) {
|
|
354
|
+
if (reward.kind === "integration")
|
|
355
|
+
return `integration:${reward.provider}:${reward.action}:${reward.roleId}`;
|
|
356
|
+
return reward.kind === "points" ? "points:" + reward.balance : "tier:" + reward.reward.id;
|
|
357
|
+
}
|
|
358
|
+
var triggerSchema = z8.union([
|
|
359
|
+
z8.object({
|
|
360
|
+
kind: z8.literal("manual"),
|
|
361
|
+
input: z8.enum(["photo", "quiz", "none"]),
|
|
362
|
+
actor: z8.enum(["member", "staff"]).optional()
|
|
363
|
+
}).strict(),
|
|
364
|
+
z8.object({
|
|
365
|
+
kind: z8.literal("automatic"),
|
|
366
|
+
observation: observationTriggerSchema.optional()
|
|
367
|
+
}).strict()
|
|
368
|
+
]);
|
|
369
|
+
var prerequisiteSchema = z8.object({ quest: identifier, scope: z8.literal("ever") }).strict();
|
|
370
|
+
var photoResultSchema = z8.object({
|
|
371
|
+
kind: z8.enum(["pass", "fail", "unclear"]),
|
|
372
|
+
reason: z8.string().min(1).max(2e3)
|
|
373
|
+
}).strict();
|
|
374
|
+
var decisionSchema = z8.discriminatedUnion("kind", [
|
|
375
|
+
z8.object({
|
|
376
|
+
kind: z8.literal("accept"),
|
|
377
|
+
rewards: z8.array(rewardSchema).max(10),
|
|
378
|
+
completionKey: completionKeySchema.optional()
|
|
379
|
+
}).strict(),
|
|
380
|
+
z8.object({ kind: z8.literal("reject"), reason: z8.string().min(1).max(2e3) }).strict(),
|
|
381
|
+
z8.object({
|
|
382
|
+
kind: z8.literal("review"),
|
|
383
|
+
reason: z8.string().min(1).max(2e3),
|
|
384
|
+
rewards: z8.array(rewardSchema).max(10).optional(),
|
|
385
|
+
completionKey: completionKeySchema.optional()
|
|
386
|
+
}).strict()
|
|
387
|
+
]);
|
|
388
|
+
var reviewModeSchema = z8.enum([
|
|
389
|
+
"fixture-pass",
|
|
390
|
+
"fixture-fail",
|
|
391
|
+
"fixture-unclear",
|
|
392
|
+
"fixture-error",
|
|
393
|
+
"workers-ai"
|
|
394
|
+
]);
|
|
395
|
+
var rewardBundleSchema = z8.array(rewardSchema).max(10).refine(
|
|
396
|
+
(rewards) => new Set(rewards.map(rewardKey)).size === rewards.length,
|
|
397
|
+
"Use one entry per balance or shared reward"
|
|
398
|
+
);
|
|
399
|
+
var mediaUrlSchema = z8.string().max(2e3).refine((value) => {
|
|
400
|
+
if (/^\/(?!\/)[^\\\s]*$/.test(value)) return true;
|
|
401
|
+
try {
|
|
402
|
+
return new URL(value).protocol === "https:";
|
|
403
|
+
} catch {
|
|
404
|
+
return false;
|
|
405
|
+
}
|
|
406
|
+
}, "Use an HTTPS URL or a same-site path beginning with /");
|
|
407
|
+
var questPresentationSchema = z8.object({
|
|
408
|
+
quiz: quizQuestionsSchema.optional(),
|
|
409
|
+
instructions: z8.string().max(4e3).optional(),
|
|
410
|
+
video: z8.object({
|
|
411
|
+
url: mediaUrlSchema,
|
|
412
|
+
poster: mediaUrlSchema.optional(),
|
|
413
|
+
captions: z8.object({
|
|
414
|
+
url: mediaUrlSchema,
|
|
415
|
+
language: z8.string().min(2).max(20),
|
|
416
|
+
label: z8.string().min(1).max(80)
|
|
417
|
+
}).strict().optional()
|
|
418
|
+
}).strict().optional()
|
|
419
|
+
}).strict();
|
|
420
|
+
var questDescriptionSchema = z8.object({
|
|
421
|
+
quest: identifier,
|
|
422
|
+
runtimeVersion: z8.union([z8.literal(1), z8.literal(2)]).default(1),
|
|
423
|
+
title: z8.string().min(1).max(120),
|
|
424
|
+
presentation: questPresentationSchema.default({}),
|
|
425
|
+
integrations: z8.array(integrationProviderSchema).max(10).default([]),
|
|
426
|
+
fields: settingsFieldsSchema,
|
|
427
|
+
values: settingsValuesSchema,
|
|
428
|
+
rewards: rewardBundleSchema,
|
|
429
|
+
humanReview: z8.boolean(),
|
|
430
|
+
trigger: triggerSchema,
|
|
431
|
+
requires: z8.array(prerequisiteSchema).max(30).default([]),
|
|
432
|
+
completion: completionPolicySchema,
|
|
433
|
+
visibility: z8.enum(["visible", "hidden"]).default("visible"),
|
|
434
|
+
budgets: z8.array(budgetSchema).max(20).default([])
|
|
435
|
+
}).strict();
|
|
436
|
+
var artifactSchema = z8.object({ code: z8.string().min(1).max(1e6) }).strict();
|
|
437
|
+
var releaseSchema = artifactSchema.extend({
|
|
438
|
+
settings: settingsValuesSchema,
|
|
439
|
+
provider: reviewModeSchema,
|
|
440
|
+
expectedRelease: identifier.nullable().optional(),
|
|
441
|
+
settingRenames: z8.record(z8.string(), z8.string()).optional()
|
|
442
|
+
}).strict();
|
|
443
|
+
var batchReleaseSchema = z8.object({ releases: z8.array(releaseSchema).min(1).max(50) }).strict();
|
|
444
|
+
var questSettingsInputSchema = z8.object({
|
|
445
|
+
quest: identifier,
|
|
446
|
+
expectedRelease: identifier,
|
|
447
|
+
set: settingsValuesSchema,
|
|
448
|
+
reset: z8.array(z8.string())
|
|
449
|
+
}).strict();
|
|
450
|
+
var storedReleaseSchema = questDescriptionSchema.extend({
|
|
451
|
+
code: z8.string(),
|
|
452
|
+
provider: reviewModeSchema,
|
|
453
|
+
id: identifier,
|
|
454
|
+
createdAt: z8.number(),
|
|
455
|
+
legacy: z8.boolean().default(false),
|
|
456
|
+
origin: z8.object({ typeVersion: identifier }).strict().optional(),
|
|
457
|
+
lifecycle: z8.enum(["active", "paused", "archived"]).default("active"),
|
|
458
|
+
configuration: z8.object({
|
|
459
|
+
defaults: settingsValuesSchema,
|
|
460
|
+
overrides: settingsValuesSchema,
|
|
461
|
+
preserved: z8.array(z8.string())
|
|
462
|
+
}).strict().optional()
|
|
463
|
+
});
|
|
464
|
+
var legacyReleaseSchema = z8.object({
|
|
465
|
+
quest: identifier,
|
|
466
|
+
title: z8.string(),
|
|
467
|
+
criteria: z8.string(),
|
|
468
|
+
humanReview: z8.boolean(),
|
|
469
|
+
rewards: rewardBundleSchema,
|
|
470
|
+
code: z8.string(),
|
|
471
|
+
provider: reviewModeSchema,
|
|
472
|
+
id: identifier,
|
|
473
|
+
createdAt: z8.number()
|
|
474
|
+
}).transform((r) => {
|
|
475
|
+
const { criteria, ...stored } = r;
|
|
476
|
+
return storedReleaseSchema.parse({
|
|
477
|
+
...stored,
|
|
478
|
+
fields: {},
|
|
479
|
+
values: { criteria, humanReview: r.humanReview },
|
|
480
|
+
trigger: { kind: "manual", input: "photo" },
|
|
481
|
+
completion: { kind: "once" },
|
|
482
|
+
legacy: true
|
|
483
|
+
});
|
|
484
|
+
});
|
|
485
|
+
var publishedReleaseSchema = z8.union([
|
|
486
|
+
storedReleaseSchema,
|
|
487
|
+
legacyReleaseSchema
|
|
488
|
+
]);
|
|
489
|
+
var templateSchema = z8.object({
|
|
490
|
+
code: z8.string(),
|
|
491
|
+
definition: questDescriptionSchema
|
|
492
|
+
});
|
|
493
|
+
var quizAnswersSchema = z8.record(identifier, identifier).refine(
|
|
494
|
+
(answers) => Object.keys(answers).length > 0 && Object.keys(answers).length <= 50,
|
|
495
|
+
"Provide between 1 and 50 answers"
|
|
496
|
+
).transform(
|
|
497
|
+
(answers) => Object.fromEntries(
|
|
498
|
+
Object.entries(answers).sort(([a], [b]) => a.localeCompare(b))
|
|
499
|
+
)
|
|
500
|
+
);
|
|
501
|
+
var quizEvidenceSchema = z8.object({
|
|
502
|
+
kind: z8.literal("quiz"),
|
|
503
|
+
release: identifier.optional(),
|
|
504
|
+
answers: quizAnswersSchema
|
|
505
|
+
}).strict();
|
|
506
|
+
var submitSchema = z8.object({
|
|
507
|
+
actionId: identifier,
|
|
508
|
+
quest: identifier,
|
|
509
|
+
member: identifier,
|
|
510
|
+
evidence: identifier.optional(),
|
|
511
|
+
input: quizEvidenceSchema.optional(),
|
|
512
|
+
release: identifier.optional(),
|
|
513
|
+
faultAfterReview: z8.boolean().optional()
|
|
514
|
+
}).strict();
|
|
515
|
+
var attemptSchema = z8.object({
|
|
516
|
+
id: identifier,
|
|
517
|
+
release: identifier,
|
|
518
|
+
quest: identifier,
|
|
519
|
+
member: identifier,
|
|
520
|
+
evidence: identifier.nullable(),
|
|
521
|
+
input: quizEvidenceSchema.optional(),
|
|
522
|
+
status: z8.enum([
|
|
523
|
+
"queued",
|
|
524
|
+
"evaluating",
|
|
525
|
+
"accepted",
|
|
526
|
+
"rejected",
|
|
527
|
+
"needs-review",
|
|
528
|
+
"failed"
|
|
529
|
+
]),
|
|
530
|
+
reason: z8.string().nullable(),
|
|
531
|
+
retries: z8.number(),
|
|
532
|
+
generation: z8.number(),
|
|
533
|
+
completion: z8.string().nullable(),
|
|
534
|
+
reviewRewards: rewardBundleSchema.nullable().default(null),
|
|
535
|
+
createdAt: z8.number()
|
|
536
|
+
});
|
|
537
|
+
var eventSchema = z8.object({
|
|
538
|
+
id: z8.number(),
|
|
539
|
+
attempt: z8.string().nullable(),
|
|
540
|
+
kind: z8.string(),
|
|
541
|
+
detail: z8.string(),
|
|
542
|
+
actor: z8.string().nullable().default(null),
|
|
543
|
+
at: z8.number()
|
|
544
|
+
});
|
|
545
|
+
var pickupSelectionSchema = z8.object({
|
|
546
|
+
item: identifier,
|
|
547
|
+
revision: z8.number().int().nonnegative()
|
|
548
|
+
}).strict();
|
|
549
|
+
var pickupAllocationSchema = z8.object({
|
|
550
|
+
item: identifier,
|
|
551
|
+
label: z8.string().min(1).max(80)
|
|
552
|
+
}).strict();
|
|
553
|
+
var pickupPolicySchema = z8.discriminatedUnion("kind", [
|
|
554
|
+
z8.object({ kind: z8.literal("untracked") }).strict(),
|
|
555
|
+
z8.object({
|
|
556
|
+
kind: z8.literal("at-pickup"),
|
|
557
|
+
tiers: z8.array(
|
|
558
|
+
z8.object({
|
|
559
|
+
tier: identifier,
|
|
560
|
+
variants: z8.array(pickupAllocationSchema).min(1).max(100)
|
|
561
|
+
}).strict()
|
|
562
|
+
).min(1).max(100)
|
|
563
|
+
}).strict()
|
|
564
|
+
]);
|
|
565
|
+
var pickupCatalogSchema = z8.object({
|
|
566
|
+
reward: tieredRewardDefinitionSchema,
|
|
567
|
+
revision: z8.number().int().nonnegative(),
|
|
568
|
+
policy: pickupPolicySchema
|
|
569
|
+
});
|
|
570
|
+
var pickupAvailabilitySchema = z8.discriminatedUnion("kind", [
|
|
571
|
+
z8.object({ kind: z8.literal("untracked") }).strict(),
|
|
572
|
+
z8.object({
|
|
573
|
+
kind: z8.literal("at-pickup"),
|
|
574
|
+
revision: z8.number().int().nonnegative(),
|
|
575
|
+
variants: z8.array(
|
|
576
|
+
pickupAllocationSchema.extend({
|
|
577
|
+
available: z8.number().int().nonnegative()
|
|
578
|
+
})
|
|
579
|
+
)
|
|
580
|
+
}).strict()
|
|
581
|
+
]);
|
|
582
|
+
var configurePickupSchema = z8.object({
|
|
583
|
+
reward: identifier,
|
|
584
|
+
revision: z8.number().int().nonnegative(),
|
|
585
|
+
actionId: identifier,
|
|
586
|
+
policy: pickupPolicySchema
|
|
587
|
+
}).strict();
|
|
588
|
+
var entitlementBase = {
|
|
589
|
+
id: identifier,
|
|
590
|
+
member: identifier,
|
|
591
|
+
reward: tieredRewardDefinitionSchema,
|
|
592
|
+
earnedTier: identifier,
|
|
593
|
+
tier: identifier,
|
|
594
|
+
revision: z8.number().int().positive()
|
|
595
|
+
};
|
|
596
|
+
var entitlementSchema = z8.discriminatedUnion("status", [
|
|
597
|
+
z8.object({ ...entitlementBase, status: z8.literal("available") }).strict(),
|
|
598
|
+
z8.object({
|
|
599
|
+
...entitlementBase,
|
|
600
|
+
status: z8.literal("handing-over"),
|
|
601
|
+
handover: identifier,
|
|
602
|
+
startedAt: z8.number(),
|
|
603
|
+
allocation: pickupAllocationSchema.optional()
|
|
604
|
+
}).strict(),
|
|
605
|
+
z8.object({
|
|
606
|
+
...entitlementBase,
|
|
607
|
+
status: z8.literal("collected"),
|
|
608
|
+
handover: identifier,
|
|
609
|
+
startedAt: z8.number(),
|
|
610
|
+
allocation: pickupAllocationSchema.optional(),
|
|
611
|
+
collectedAt: z8.number()
|
|
612
|
+
}).strict()
|
|
613
|
+
]);
|
|
614
|
+
var beginHandoverSchema = z8.object({
|
|
615
|
+
actionId: identifier,
|
|
616
|
+
revision: z8.number().int().positive(),
|
|
617
|
+
selection: pickupSelectionSchema.optional()
|
|
618
|
+
}).strict();
|
|
619
|
+
var confirmHandoverSchema = z8.object({ actionId: identifier, handover: identifier }).strict();
|
|
620
|
+
var completionRecordSchema = z8.object({
|
|
621
|
+
key: z8.string().default("once"),
|
|
622
|
+
id: identifier,
|
|
623
|
+
quest: identifier,
|
|
624
|
+
member: identifier
|
|
625
|
+
});
|
|
626
|
+
var questAvailabilitySchema = z8.discriminatedUnion("kind", [
|
|
627
|
+
z8.object({
|
|
628
|
+
kind: z8.literal("available"),
|
|
629
|
+
input: z8.enum(["photo", "quiz", "none"])
|
|
630
|
+
}).strict(),
|
|
631
|
+
z8.object({ kind: z8.literal("completed") }).strict(),
|
|
632
|
+
z8.object({
|
|
633
|
+
kind: z8.literal("locked"),
|
|
634
|
+
missing: z8.array(z8.object({ quest: identifier, title: z8.string() })).min(1)
|
|
635
|
+
}).strict(),
|
|
636
|
+
z8.object({ kind: z8.literal("staff-required") }).strict(),
|
|
637
|
+
z8.object({
|
|
638
|
+
kind: z8.literal("automatic"),
|
|
639
|
+
observation: observationTriggerSchema.optional()
|
|
640
|
+
}).strict(),
|
|
641
|
+
z8.object({ kind: z8.literal("checking"), attempt: identifier }).strict(),
|
|
642
|
+
z8.object({ kind: z8.literal("needs-review"), attempt: identifier }).strict(),
|
|
643
|
+
z8.object({ kind: z8.literal("retryable"), attempt: identifier }).strict()
|
|
644
|
+
]);
|
|
645
|
+
var memberProgressSchema = z8.object({
|
|
646
|
+
member: identifier,
|
|
647
|
+
quests: z8.array(
|
|
648
|
+
z8.object({
|
|
649
|
+
quest: identifier,
|
|
650
|
+
release: identifier.optional(),
|
|
651
|
+
title: z8.string(),
|
|
652
|
+
presentation: questPresentationSchema.default({}),
|
|
653
|
+
connections: z8.array(authProviderSchema).default([]),
|
|
654
|
+
trigger: triggerSchema,
|
|
655
|
+
availability: questAvailabilitySchema,
|
|
656
|
+
completed: z8.boolean(),
|
|
657
|
+
completion: completionPolicySchema.default({ kind: "once" }),
|
|
658
|
+
completionCount: z8.number().int().nonnegative().default(0),
|
|
659
|
+
visibility: z8.enum(["visible", "hidden"]).default("visible"),
|
|
660
|
+
missing: z8.array(z8.object({ quest: identifier, title: z8.string() })),
|
|
661
|
+
attempt: attemptSchema.nullable()
|
|
662
|
+
})
|
|
663
|
+
),
|
|
664
|
+
entitlements: z8.array(entitlementSchema)
|
|
665
|
+
});
|
|
666
|
+
var snapshotSchema = z8.object({
|
|
667
|
+
releases: z8.array(publishedReleaseSchema),
|
|
668
|
+
completions: z8.array(completionRecordSchema),
|
|
669
|
+
entitlements: z8.array(entitlementSchema),
|
|
670
|
+
attempts: z8.array(attemptSchema),
|
|
671
|
+
balances: z8.array(
|
|
672
|
+
z8.object({
|
|
673
|
+
member: z8.string(),
|
|
674
|
+
balance: z8.string(),
|
|
675
|
+
earned: z8.number(),
|
|
676
|
+
held: z8.number(),
|
|
677
|
+
available: z8.number()
|
|
678
|
+
})
|
|
679
|
+
),
|
|
680
|
+
events: z8.array(eventSchema)
|
|
681
|
+
});
|
|
682
|
+
var evidenceSchema = z8.object({
|
|
683
|
+
id: identifier,
|
|
684
|
+
member: identifier,
|
|
685
|
+
type: z8.enum(["image/jpeg", "image/png"]),
|
|
686
|
+
size: z8.number()
|
|
687
|
+
});
|
|
688
|
+
var errorSchema = z8.object({
|
|
689
|
+
error: z8.string(),
|
|
690
|
+
code: z8.enum(["stale-quiz", "quest-updated"]).optional(),
|
|
691
|
+
missing: z8.array(z8.object({ quest: identifier, title: z8.string() })).optional()
|
|
692
|
+
});
|
|
693
|
+
var staffDecisionSchema = z8.object({
|
|
694
|
+
actionId: identifier,
|
|
695
|
+
generation: z8.number().int().nonnegative(),
|
|
696
|
+
decision: z8.enum(["accept", "reject"]),
|
|
697
|
+
reason: z8.string().trim().min(1).max(2e3)
|
|
698
|
+
}).strict();
|
|
699
|
+
var stockSchema = z8.object({ item: identifier, quantity: z8.number().int().min(0).max(1e4) }).strict();
|
|
700
|
+
var reservationSchema = z8.object({
|
|
701
|
+
actionId: identifier,
|
|
702
|
+
member: identifier,
|
|
703
|
+
item: identifier,
|
|
704
|
+
balance: identifier,
|
|
705
|
+
price: z8.number().int().positive().max(1e4)
|
|
706
|
+
}).strict();
|
|
707
|
+
var pageOptions = {
|
|
708
|
+
limit: z8.number().int().min(1).max(100).default(25),
|
|
709
|
+
cursor: z8.string().min(1).max(4096).optional()
|
|
710
|
+
};
|
|
711
|
+
var reviewListSchema = z8.object({
|
|
712
|
+
...pageOptions,
|
|
713
|
+
member: identifier.optional(),
|
|
714
|
+
quest: identifier.optional()
|
|
715
|
+
}).strict();
|
|
716
|
+
var memberListSchema = z8.object({
|
|
717
|
+
...pageOptions,
|
|
718
|
+
prefix: identifier.optional()
|
|
719
|
+
}).strict();
|
|
720
|
+
var reviewItemSchema = z8.object({
|
|
721
|
+
attempt: attemptSchema,
|
|
722
|
+
title: z8.string(),
|
|
723
|
+
checks: z8.array(
|
|
724
|
+
z8.object({ criteria: z8.string(), result: photoResultSchema })
|
|
725
|
+
)
|
|
726
|
+
});
|
|
727
|
+
var reviewPageSchema = z8.object({
|
|
728
|
+
items: z8.array(reviewItemSchema).max(100),
|
|
729
|
+
nextCursor: z8.string().nullable()
|
|
730
|
+
});
|
|
731
|
+
var memberPageSchema = z8.object({
|
|
732
|
+
items: z8.array(z8.object({ member: identifier })).max(100),
|
|
733
|
+
nextCursor: z8.string().nullable()
|
|
734
|
+
});
|
|
735
|
+
|
|
736
|
+
export {
|
|
737
|
+
identifier,
|
|
738
|
+
observationInputSchema,
|
|
739
|
+
observationSchema,
|
|
740
|
+
observationTriggerSchema,
|
|
741
|
+
completionPolicySchema,
|
|
742
|
+
completionKeySchema,
|
|
743
|
+
budgetSchema,
|
|
744
|
+
observationReceiptSchema,
|
|
745
|
+
discordReactionSchema,
|
|
746
|
+
discordMessageSchema,
|
|
747
|
+
integrationProviderSchema,
|
|
748
|
+
discordServerSchema,
|
|
749
|
+
projectIntegrationSchema,
|
|
750
|
+
authProviderSchema,
|
|
751
|
+
accountConnectionSchema,
|
|
752
|
+
discordMemberInputSchema,
|
|
753
|
+
discordMessageInputSchema,
|
|
754
|
+
discordMemberSchema,
|
|
755
|
+
quizChoiceSchema,
|
|
756
|
+
quizQuestionSchema,
|
|
757
|
+
quizQuestionsSchema,
|
|
758
|
+
quizContentSchema,
|
|
759
|
+
resourceSourceSchema,
|
|
760
|
+
resourceRequestSchema,
|
|
761
|
+
resourceOptionsSchema,
|
|
762
|
+
discord,
|
|
763
|
+
settingFieldSchema,
|
|
764
|
+
settingsFieldsSchema,
|
|
765
|
+
settingsValuesSchema,
|
|
766
|
+
settings,
|
|
767
|
+
parseSettings,
|
|
768
|
+
missingResourceSettings,
|
|
769
|
+
compatibleSettingKinds,
|
|
770
|
+
pointsRewardSchema,
|
|
771
|
+
tieredRewardDefinitionSchema,
|
|
772
|
+
tierRewardSchema,
|
|
773
|
+
integrationRewardSchema,
|
|
774
|
+
rewardSchema,
|
|
775
|
+
rewardKey,
|
|
776
|
+
triggerSchema,
|
|
777
|
+
prerequisiteSchema,
|
|
778
|
+
photoResultSchema,
|
|
779
|
+
decisionSchema,
|
|
780
|
+
reviewModeSchema,
|
|
781
|
+
rewardBundleSchema,
|
|
782
|
+
mediaUrlSchema,
|
|
783
|
+
questPresentationSchema,
|
|
784
|
+
questDescriptionSchema,
|
|
785
|
+
artifactSchema,
|
|
786
|
+
releaseSchema,
|
|
787
|
+
batchReleaseSchema,
|
|
788
|
+
questSettingsInputSchema,
|
|
789
|
+
publishedReleaseSchema,
|
|
790
|
+
templateSchema,
|
|
791
|
+
quizAnswersSchema,
|
|
792
|
+
quizEvidenceSchema,
|
|
793
|
+
submitSchema,
|
|
794
|
+
attemptSchema,
|
|
795
|
+
eventSchema,
|
|
796
|
+
pickupSelectionSchema,
|
|
797
|
+
pickupAllocationSchema,
|
|
798
|
+
pickupPolicySchema,
|
|
799
|
+
pickupCatalogSchema,
|
|
800
|
+
pickupAvailabilitySchema,
|
|
801
|
+
configurePickupSchema,
|
|
802
|
+
entitlementSchema,
|
|
803
|
+
beginHandoverSchema,
|
|
804
|
+
confirmHandoverSchema,
|
|
805
|
+
completionRecordSchema,
|
|
806
|
+
questAvailabilitySchema,
|
|
807
|
+
memberProgressSchema,
|
|
808
|
+
snapshotSchema,
|
|
809
|
+
evidenceSchema,
|
|
810
|
+
errorSchema,
|
|
811
|
+
staffDecisionSchema,
|
|
812
|
+
stockSchema,
|
|
813
|
+
reservationSchema,
|
|
814
|
+
reviewListSchema,
|
|
815
|
+
memberListSchema,
|
|
816
|
+
reviewItemSchema,
|
|
817
|
+
reviewPageSchema,
|
|
818
|
+
memberPageSchema
|
|
819
|
+
};
|