@domino-sdk/relay 1.0.0-next.9 → 1.0.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/README.md +1 -1
- package/dist/activity-DeKJsRry.d.ts +9112 -0
- package/dist/authoring.d.ts +1027 -233
- package/dist/authoring.js +478 -277
- package/dist/automatic-outcomes-B1xrETxm.d.ts +758 -0
- package/dist/avatar.d.ts +2 -2
- package/dist/browser-DFe7sWSN.d.ts +4154 -0
- package/dist/browser.d.ts +11 -2613
- package/dist/browser.js +8 -6
- package/dist/{integrations-Ba5TtqTv.d.ts → capability-error-DNMwKmlL.d.ts} +124 -76
- package/dist/{chunk-PHU5VDLR.js → chunk-36HTX2BM.js} +389 -169
- package/dist/chunk-6QJ3LADK.js +112 -0
- package/dist/{chunk-4LBUTHD6.js → chunk-BGGKNIRP.js} +1 -1
- package/dist/chunk-EYH5RDIE.js +496 -0
- package/dist/chunk-GQKYAQM6.js +84 -0
- package/dist/chunk-GUP7YRR4.js +42 -0
- package/dist/{chunk-X2F2RAR3.js → chunk-GZ6FJAXN.js} +380 -128
- package/dist/chunk-JON5SESL.js +2986 -0
- package/dist/chunk-MC6V6VMG.js +49 -0
- package/dist/chunk-NPGENI7K.js +37 -0
- package/dist/chunk-VFHHLN6A.js +284 -0
- package/dist/chunk-WJSSJ7AF.js +151 -0
- package/dist/{chunk-7Q4BGGT6.js → chunk-XFMSUPNS.js} +1 -1
- package/dist/{chunk-P6FK43GG.js → chunk-ZVIRG24J.js} +145 -42
- package/dist/{client-CT4-S5vc.d.ts → client-XiuFnug_.d.ts} +2161 -615
- package/dist/{submission-input-0OOGaq8c.d.ts → groups-Ck-OxzjD.d.ts} +916 -1139
- package/dist/identity-integration-GxAHdKR2.d.ts +58 -0
- package/dist/images-Dv-P5VBw.d.ts +234 -0
- package/dist/index.d.ts +13 -9
- package/dist/index.js +17 -6
- package/dist/internal.d.ts +82 -44
- package/dist/internal.js +43 -89
- package/dist/offers-Cy-e4o5x.d.ts +431 -0
- package/dist/{pages-D3titw5B.d.ts → outcomes-kVB-Juzs.d.ts} +2157 -1448
- package/dist/pages-BBYD21IE.d.ts +359 -0
- package/dist/participant-rewards-3duLb8YJ.d.ts +668 -0
- package/dist/portal-proxy.js +22 -4
- package/dist/{profiles-DDMFBRKe.d.ts → profiles-D2aFcOxu.d.ts} +15 -15
- package/dist/react/index.d.ts +3038 -1029
- package/dist/react/index.js +1627 -779
- package/dist/request-error-DWduJCGV.d.ts +62 -0
- package/dist/schema-DfJzH2ci.d.ts +5644 -0
- package/dist/schema.d.ts +15 -4168
- package/dist/schema.js +310 -81
- package/dist/server/index.d.ts +81498 -0
- package/dist/server/index.js +2520 -0
- package/dist/{streaks-CwGReWGt.d.ts → streaks-CWyq8Px5.d.ts} +2 -4
- package/dist/submission-input-BZkm6ohU.d.ts +290 -0
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +1 -0
- package/dist/{wallet-BGOfFkG9.d.ts → wallet-YssWxGg8.d.ts} +35 -38
- package/package.json +8 -2
- package/dist/chunk-QR7ZA2BJ.js +0 -257
- package/dist/chunk-YYD4QUBO.js +0 -2348
- package/dist/chunk-ZWY3R6B3.js +0 -26
- package/dist/collection-BGneJ6Bk.d.ts +0 -114
- package/dist/images-BTgk6OmC.d.ts +0 -1564
- package/dist/point-ledgers-iS00Z_v0.d.ts +0 -37
- package/dist/schema-Di3aLSiK.d.ts +0 -3532
package/dist/chunk-YYD4QUBO.js
DELETED
|
@@ -1,2348 +0,0 @@
|
|
|
1
|
-
// src/accounts.ts
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
var authProviderSchema = z.enum(["google", "apple", "x", "discord"]);
|
|
4
|
-
var accountConnectionSchema = z.object({
|
|
5
|
-
provider: authProviderSchema,
|
|
6
|
-
configured: z.boolean(),
|
|
7
|
-
status: z.enum(["disconnected", "connected", "reconnect"]),
|
|
8
|
-
subject: z.string().nullable(),
|
|
9
|
-
revision: z.number().int().nonnegative()
|
|
10
|
-
});
|
|
11
|
-
var discordMemberInputSchema = z.object({}).strict();
|
|
12
|
-
var discordMessageInputSchema = z.object({
|
|
13
|
-
channelId: z.string().regex(/^[0-9]{1,20}$/),
|
|
14
|
-
messageId: z.string().regex(/^[0-9]{1,20}$/)
|
|
15
|
-
}).strict();
|
|
16
|
-
var discordMemberSchema = z.object({
|
|
17
|
-
userId: z.string().regex(/^[0-9]{1,20}$/).nullable().default(null),
|
|
18
|
-
nickname: z.string().nullable().default(null),
|
|
19
|
-
displayName: z.string().nullable().default(null),
|
|
20
|
-
boostingSince: z.string().datetime({ offset: true }).nullable().default(null),
|
|
21
|
-
roles: z.array(z.string().regex(/^[0-9]{1,20}$/)),
|
|
22
|
-
joinedAt: z.string().datetime({ offset: true }).nullable(),
|
|
23
|
-
pending: z.boolean()
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
// src/identifier.ts
|
|
27
|
-
import { z as z2 } from "zod";
|
|
28
|
-
var identifier = z2.string().min(1).max(100).regex(/^[a-zA-Z0-9_-]+$/);
|
|
29
|
-
|
|
30
|
-
// src/pages.ts
|
|
31
|
-
import { z as z3 } from "zod";
|
|
32
|
-
var pageCursorSchema = z3.string().min(1).max(4096);
|
|
33
|
-
var pageQuerySchema = z3.strictObject({
|
|
34
|
-
cursor: pageCursorSchema.optional()
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
// src/tracker-data.ts
|
|
38
|
-
import { z as z4 } from "zod";
|
|
39
|
-
var maxDepth = 16;
|
|
40
|
-
var maxBytes = 32768;
|
|
41
|
-
var trackerDataMaxBranches = 16;
|
|
42
|
-
var trackerDataMaxEntries = 256;
|
|
43
|
-
var scalar = z4.union([z4.string(), z4.number().finite(), z4.boolean(), z4.null()]);
|
|
44
|
-
var size = z4.number().int().safe().nonnegative();
|
|
45
|
-
var bound = z4.number().finite();
|
|
46
|
-
var branches = () => z4.array(node).min(1).max(trackerDataMaxBranches);
|
|
47
|
-
var node = z4.lazy(
|
|
48
|
-
() => z4.strictObject({
|
|
49
|
-
type: z4.enum([
|
|
50
|
-
"object",
|
|
51
|
-
"array",
|
|
52
|
-
"string",
|
|
53
|
-
"number",
|
|
54
|
-
"integer",
|
|
55
|
-
"boolean",
|
|
56
|
-
"null"
|
|
57
|
-
]).optional(),
|
|
58
|
-
properties: z4.record(z4.string(), node).refine(
|
|
59
|
-
(properties) => Object.keys(properties).length <= trackerDataMaxEntries,
|
|
60
|
-
`An object schema lists at most ${trackerDataMaxEntries} properties`
|
|
61
|
-
).optional(),
|
|
62
|
-
required: z4.array(z4.string()).max(trackerDataMaxEntries).optional(),
|
|
63
|
-
additionalProperties: z4.union([z4.boolean(), node]).optional(),
|
|
64
|
-
propertyNames: z4.strictObject({
|
|
65
|
-
type: z4.literal("string"),
|
|
66
|
-
enum: z4.array(z4.string()).max(trackerDataMaxEntries).optional()
|
|
67
|
-
}).optional(),
|
|
68
|
-
items: node.optional(),
|
|
69
|
-
minItems: size.optional(),
|
|
70
|
-
maxItems: size.optional(),
|
|
71
|
-
minLength: size.optional(),
|
|
72
|
-
maxLength: size.optional(),
|
|
73
|
-
minimum: bound.optional(),
|
|
74
|
-
maximum: bound.optional(),
|
|
75
|
-
exclusiveMinimum: bound.optional(),
|
|
76
|
-
exclusiveMaximum: bound.optional(),
|
|
77
|
-
enum: z4.array(scalar).min(1).max(trackerDataMaxEntries).optional(),
|
|
78
|
-
const: scalar.optional(),
|
|
79
|
-
anyOf: branches().optional(),
|
|
80
|
-
oneOf: branches().optional(),
|
|
81
|
-
allOf: branches().optional()
|
|
82
|
-
})
|
|
83
|
-
);
|
|
84
|
-
function shapeIssue(value) {
|
|
85
|
-
const pending = [[value, 0]];
|
|
86
|
-
while (pending.length) {
|
|
87
|
-
const [current, level] = pending.pop();
|
|
88
|
-
if (typeof current !== "object" || current === null) {
|
|
89
|
-
continue;
|
|
90
|
-
}
|
|
91
|
-
if (level >= maxDepth) {
|
|
92
|
-
return "Tracker data schemas are at most 32 KB and 16 levels deep";
|
|
93
|
-
}
|
|
94
|
-
if (!Array.isArray(current) && Object.hasOwn(current, "__proto__")) {
|
|
95
|
-
return "Tracker data schemas cannot name a property __proto__";
|
|
96
|
-
}
|
|
97
|
-
for (const child of Object.values(current)) {
|
|
98
|
-
pending.push([child, level + 1]);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
return new TextEncoder().encode(JSON.stringify(value)).byteLength > maxBytes ? "Tracker data schemas are at most 32 KB and 16 levels deep" : null;
|
|
102
|
-
}
|
|
103
|
-
var unions = (s) => [
|
|
104
|
-
...s.anyOf ?? [],
|
|
105
|
-
...s.oneOf ?? [],
|
|
106
|
-
...s.allOf ?? []
|
|
107
|
-
];
|
|
108
|
-
var compound = (s) => s.properties !== void 0 || s.items !== void 0 || typeof s.additionalProperties === "object" || unions(s).length > 0;
|
|
109
|
-
function nestedUnionIssue(schema, path, insideUnion) {
|
|
110
|
-
const own = unions(schema);
|
|
111
|
-
if (insideUnion && own.filter(compound).length > 1) {
|
|
112
|
-
return path;
|
|
113
|
-
}
|
|
114
|
-
const children = [
|
|
115
|
-
...Object.entries(schema.properties ?? {}).map(
|
|
116
|
-
([key, child]) => [child, `${path}.${key}`]
|
|
117
|
-
)
|
|
118
|
-
];
|
|
119
|
-
if (schema.items) {
|
|
120
|
-
children.push([schema.items, path]);
|
|
121
|
-
}
|
|
122
|
-
if (typeof schema.additionalProperties === "object") {
|
|
123
|
-
children.push([schema.additionalProperties, path]);
|
|
124
|
-
}
|
|
125
|
-
for (const [child, at] of children) {
|
|
126
|
-
const found = nestedUnionIssue(child, at, insideUnion);
|
|
127
|
-
if (found) {
|
|
128
|
-
return found;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
for (const branch of own) {
|
|
132
|
-
const found = nestedUnionIssue(branch, path, true);
|
|
133
|
-
if (found) {
|
|
134
|
-
return found;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
return null;
|
|
138
|
-
}
|
|
139
|
-
var trackerDataSchemaSchema = z4.unknown().superRefine((value, ctx) => {
|
|
140
|
-
const issue = shapeIssue(value);
|
|
141
|
-
if (issue) {
|
|
142
|
-
ctx.addIssue({ code: "custom", message: issue, abort: true });
|
|
143
|
-
}
|
|
144
|
-
}).pipe(node).refine(
|
|
145
|
-
(schema) => schema.type === "object",
|
|
146
|
-
"A tracker's record data is an object: declare it with z.object({ ... })"
|
|
147
|
-
).superRefine((schema, ctx) => {
|
|
148
|
-
const at = nestedUnionIssue(schema, "data", false);
|
|
149
|
-
if (at) {
|
|
150
|
-
ctx.addIssue({
|
|
151
|
-
code: "custom",
|
|
152
|
-
message: `Tracker data schemas cannot nest a union with several object, array or union branches inside another union's branch (${at}): flatten it into one union`
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
var unsupported = {
|
|
157
|
-
pattern: "check string patterns in your evaluator",
|
|
158
|
-
format: "use z.string() and check the format in your evaluator",
|
|
159
|
-
prefixItems: "use an array or an object instead of a tuple",
|
|
160
|
-
multipleOf: "check divisibility in your evaluator",
|
|
161
|
-
not: "describe the allowed values instead",
|
|
162
|
-
$ref: "inline the schema instead of registering or reusing it by ID",
|
|
163
|
-
$defs: "inline the schema instead of registering or reusing it by ID",
|
|
164
|
-
definitions: "inline the schema instead of registering or reusing it by ID",
|
|
165
|
-
if: "use a union instead",
|
|
166
|
-
then: "use a union instead",
|
|
167
|
-
else: "use a union instead",
|
|
168
|
-
contains: "check array contents in your evaluator",
|
|
169
|
-
minContains: "check array contents in your evaluator",
|
|
170
|
-
maxContains: "check array contents in your evaluator",
|
|
171
|
-
uniqueItems: "check uniqueness in your evaluator",
|
|
172
|
-
minProperties: "check key counts in your evaluator",
|
|
173
|
-
maxProperties: "check key counts in your evaluator",
|
|
174
|
-
patternProperties: "use z.record(z.string(), value) instead",
|
|
175
|
-
dependentRequired: "use a union instead",
|
|
176
|
-
dependentSchemas: "use a union instead",
|
|
177
|
-
unevaluatedProperties: "use a strict object instead",
|
|
178
|
-
unevaluatedItems: "use an array instead"
|
|
179
|
-
};
|
|
180
|
-
var nested = /* @__PURE__ */ new Set(["additionalProperties", "items", "propertyNames"]);
|
|
181
|
-
var listed = /* @__PURE__ */ new Set(["anyOf", "oneOf", "allOf"]);
|
|
182
|
-
var supported = /* @__PURE__ */ new Set([
|
|
183
|
-
"type",
|
|
184
|
-
"properties",
|
|
185
|
-
"required",
|
|
186
|
-
"minItems",
|
|
187
|
-
"maxItems",
|
|
188
|
-
"minLength",
|
|
189
|
-
"maxLength",
|
|
190
|
-
"minimum",
|
|
191
|
-
"maximum",
|
|
192
|
-
"exclusiveMinimum",
|
|
193
|
-
"exclusiveMaximum",
|
|
194
|
-
"enum",
|
|
195
|
-
"const",
|
|
196
|
-
...nested,
|
|
197
|
-
...listed
|
|
198
|
-
]);
|
|
199
|
-
var annotations = /* @__PURE__ */ new Set([
|
|
200
|
-
"$schema",
|
|
201
|
-
"$id",
|
|
202
|
-
"$comment",
|
|
203
|
-
"title",
|
|
204
|
-
"description",
|
|
205
|
-
"default",
|
|
206
|
-
"examples",
|
|
207
|
-
"deprecated",
|
|
208
|
-
"readOnly",
|
|
209
|
-
"writeOnly"
|
|
210
|
-
]);
|
|
211
|
-
function subset(schema, path) {
|
|
212
|
-
if (typeof schema !== "object" || schema === null || Array.isArray(schema)) {
|
|
213
|
-
return schema;
|
|
214
|
-
}
|
|
215
|
-
const kept = {};
|
|
216
|
-
for (const [key, value] of Object.entries(schema)) {
|
|
217
|
-
if (Object.hasOwn(unsupported, key)) {
|
|
218
|
-
throw new Error(
|
|
219
|
-
`Tracker data schemas cannot use ${key} (${path}): ${unsupported[key]}`
|
|
220
|
-
);
|
|
221
|
-
}
|
|
222
|
-
if (annotations.has(key)) {
|
|
223
|
-
continue;
|
|
224
|
-
}
|
|
225
|
-
if (!supported.has(key)) {
|
|
226
|
-
throw new Error(
|
|
227
|
-
`Tracker data schemas cannot use the keyword ${key} (${path}): keep metadata to title, description, default and examples`
|
|
228
|
-
);
|
|
229
|
-
}
|
|
230
|
-
if (key === "properties" && Object.hasOwn(value, "__proto__") || key === "required" && value.includes("__proto__")) {
|
|
231
|
-
throw new Error(
|
|
232
|
-
`Tracker data schemas cannot name a property __proto__ (${path})`
|
|
233
|
-
);
|
|
234
|
-
}
|
|
235
|
-
kept[key] = key === "properties" ? Object.fromEntries(
|
|
236
|
-
Object.entries(value).map(
|
|
237
|
-
([name2, child]) => [name2, subset(child, `${path}.${name2}`)]
|
|
238
|
-
)
|
|
239
|
-
) : nested.has(key) ? subset(value, path) : listed.has(key) ? value.map((child) => subset(child, path)) : value;
|
|
240
|
-
}
|
|
241
|
-
return kept;
|
|
242
|
-
}
|
|
243
|
-
function trackerDataSchema(schema) {
|
|
244
|
-
let json;
|
|
245
|
-
try {
|
|
246
|
-
json = z4.toJSONSchema(schema, {
|
|
247
|
-
target: "draft-2020-12",
|
|
248
|
-
io: "input",
|
|
249
|
-
unrepresentable: "throw",
|
|
250
|
-
cycles: "throw",
|
|
251
|
-
reused: "inline",
|
|
252
|
-
override: ({ zodSchema, path }) => {
|
|
253
|
-
const def = zodSchema._zod.def;
|
|
254
|
-
const at = ["data", ...path].join(".");
|
|
255
|
-
if (def.type === "pipe" || def.type === "transform") {
|
|
256
|
-
throw new Error(
|
|
257
|
-
`Tracker data schemas cannot transform values (${at}): records are stored as sent`
|
|
258
|
-
);
|
|
259
|
-
}
|
|
260
|
-
if (def.checks?.some((check) => check._zod.def.check === "custom")) {
|
|
261
|
-
throw new Error(
|
|
262
|
-
`Tracker data schemas cannot use refinements (${at}): check the value in your evaluator`
|
|
263
|
-
);
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
});
|
|
267
|
-
} catch (error) {
|
|
268
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
269
|
-
throw new Error(
|
|
270
|
-
message.startsWith("Tracker data schemas") ? message : `Tracker data schemas describe JSON: ${message}. Use z.unknown() for any JSON value.`
|
|
271
|
-
);
|
|
272
|
-
}
|
|
273
|
-
const parsed = trackerDataSchemaSchema.safeParse(subset(json, "data"));
|
|
274
|
-
if (!parsed.success) {
|
|
275
|
-
throw new Error(
|
|
276
|
-
parsed.error.issues.map((issue) => issue.message).join("; ")
|
|
277
|
-
);
|
|
278
|
-
}
|
|
279
|
-
return parsed.data;
|
|
280
|
-
}
|
|
281
|
-
var trackerDataRecordSteps = 25e4;
|
|
282
|
-
var trackerDataBatchSteps = 6e6;
|
|
283
|
-
var BudgetSpent = class extends Error {
|
|
284
|
-
};
|
|
285
|
-
function charge(budget, steps) {
|
|
286
|
-
budget.steps -= steps;
|
|
287
|
-
if (budget.steps < 0) {
|
|
288
|
-
throw new BudgetSpent();
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
var maxKeyText = 64;
|
|
292
|
-
var maxPathText = 256;
|
|
293
|
-
function clip(text, limit) {
|
|
294
|
-
return text.length > limit ? text.slice(0, limit - 1) + "\u2026" : text;
|
|
295
|
-
}
|
|
296
|
-
function pathText(path) {
|
|
297
|
-
const keys = [];
|
|
298
|
-
for (let at = path; at; at = at.parent) {
|
|
299
|
-
keys.push(clip(String(at.key), maxKeyText));
|
|
300
|
-
}
|
|
301
|
-
return clip(["data", ...keys.reverse()].join("."), maxPathText);
|
|
302
|
-
}
|
|
303
|
-
var describe = (value) => value === null ? "null" : Array.isArray(value) ? "an array" : typeof value;
|
|
304
|
-
var shownValues = 10;
|
|
305
|
-
function oneOf(values) {
|
|
306
|
-
const shown = values.slice(0, shownValues).map((value) => JSON.stringify(value)).join(", ");
|
|
307
|
-
return values.length > shownValues ? `expected one of ${shown}, or ${values.length - shownValues} more` : `expected one of ${shown}`;
|
|
308
|
-
}
|
|
309
|
-
var enumSets = /* @__PURE__ */ new WeakMap();
|
|
310
|
-
var literalLists = /* @__PURE__ */ new WeakMap();
|
|
311
|
-
function setOf(owner, values) {
|
|
312
|
-
let found = enumSets.get(owner);
|
|
313
|
-
if (!found) {
|
|
314
|
-
found = new Set(values);
|
|
315
|
-
enumSets.set(owner, found);
|
|
316
|
-
}
|
|
317
|
-
return found;
|
|
318
|
-
}
|
|
319
|
-
function literalsOf(schema) {
|
|
320
|
-
let found = literalLists.get(schema);
|
|
321
|
-
if (!found) {
|
|
322
|
-
found = Object.entries(schema.properties ?? {}).filter(
|
|
323
|
-
([, property]) => property.const !== void 0
|
|
324
|
-
);
|
|
325
|
-
literalLists.set(schema, found);
|
|
326
|
-
}
|
|
327
|
-
return found;
|
|
328
|
-
}
|
|
329
|
-
function matches(schema, value, at, budget) {
|
|
330
|
-
charge(budget, 1);
|
|
331
|
-
const issue = (reason) => ({ at, reason });
|
|
332
|
-
if (schema.const !== void 0 && value !== schema.const) {
|
|
333
|
-
return issue(() => `expected ${JSON.stringify(schema.const)}`);
|
|
334
|
-
}
|
|
335
|
-
if (schema.enum && !setOf(schema, schema.enum).has(value)) {
|
|
336
|
-
const values = schema.enum;
|
|
337
|
-
return issue(() => oneOf(values));
|
|
338
|
-
}
|
|
339
|
-
switch (schema.type) {
|
|
340
|
-
case "null":
|
|
341
|
-
if (value !== null) {
|
|
342
|
-
return issue(() => `expected null, got ${describe(value)}`);
|
|
343
|
-
}
|
|
344
|
-
break;
|
|
345
|
-
case "boolean":
|
|
346
|
-
case "string":
|
|
347
|
-
if (typeof value !== schema.type) {
|
|
348
|
-
const type = schema.type;
|
|
349
|
-
return issue(() => `expected a ${type}, got ${describe(value)}`);
|
|
350
|
-
}
|
|
351
|
-
break;
|
|
352
|
-
case "number":
|
|
353
|
-
if (typeof value !== "number") {
|
|
354
|
-
return issue(() => `expected a number, got ${describe(value)}`);
|
|
355
|
-
}
|
|
356
|
-
break;
|
|
357
|
-
case "integer":
|
|
358
|
-
if (!Number.isInteger(value)) {
|
|
359
|
-
return issue(
|
|
360
|
-
() => typeof value === "number" ? "expected an integer" : `expected an integer, got ${describe(value)}`
|
|
361
|
-
);
|
|
362
|
-
}
|
|
363
|
-
break;
|
|
364
|
-
case "array":
|
|
365
|
-
if (!Array.isArray(value)) {
|
|
366
|
-
return issue(() => `expected an array, got ${describe(value)}`);
|
|
367
|
-
}
|
|
368
|
-
break;
|
|
369
|
-
case "object":
|
|
370
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
371
|
-
return issue(() => `expected an object, got ${describe(value)}`);
|
|
372
|
-
}
|
|
373
|
-
break;
|
|
374
|
-
}
|
|
375
|
-
if (typeof value === "string") {
|
|
376
|
-
const { minLength, maxLength } = schema;
|
|
377
|
-
if (minLength !== void 0 && value.length < minLength) {
|
|
378
|
-
return issue(() => `expected at least ${minLength} characters`);
|
|
379
|
-
}
|
|
380
|
-
if (maxLength !== void 0 && value.length > maxLength) {
|
|
381
|
-
return issue(() => `expected at most ${maxLength} characters`);
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
if (typeof value === "number") {
|
|
385
|
-
const limits = [
|
|
386
|
-
[schema.minimum, (limit) => value >= limit, "at least"],
|
|
387
|
-
[schema.exclusiveMinimum, (limit) => value > limit, "more than"],
|
|
388
|
-
[schema.maximum, (limit) => value <= limit, "at most"],
|
|
389
|
-
[schema.exclusiveMaximum, (limit) => value < limit, "less than"]
|
|
390
|
-
];
|
|
391
|
-
for (const [limit, holds, label] of limits) {
|
|
392
|
-
if (limit !== void 0 && !holds(limit)) {
|
|
393
|
-
return issue(() => `expected ${label} ${limit}`);
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
if (Array.isArray(value)) {
|
|
398
|
-
const { minItems, maxItems } = schema;
|
|
399
|
-
if (minItems !== void 0 && value.length < minItems) {
|
|
400
|
-
return issue(() => `expected at least ${minItems} items`);
|
|
401
|
-
}
|
|
402
|
-
if (maxItems !== void 0 && value.length > maxItems) {
|
|
403
|
-
return issue(() => `expected at most ${maxItems} items`);
|
|
404
|
-
}
|
|
405
|
-
if (schema.items) {
|
|
406
|
-
for (let index = 0; index < value.length; index++) {
|
|
407
|
-
const found = matches(
|
|
408
|
-
schema.items,
|
|
409
|
-
value[index],
|
|
410
|
-
{ parent: at, key: index },
|
|
411
|
-
budget
|
|
412
|
-
);
|
|
413
|
-
if (found) {
|
|
414
|
-
return found;
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
420
|
-
const object = value;
|
|
421
|
-
const properties = schema.properties ?? {};
|
|
422
|
-
const required = schema.required ?? [];
|
|
423
|
-
charge(budget, required.length);
|
|
424
|
-
for (const key of required) {
|
|
425
|
-
if (!Object.hasOwn(object, key)) {
|
|
426
|
-
return issue(() => `missing required key "${clip(key, maxKeyText)}"`);
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
const literals = literalsOf(schema);
|
|
430
|
-
charge(budget, literals.length);
|
|
431
|
-
for (const [key, property] of literals) {
|
|
432
|
-
if (Object.hasOwn(object, key) && object[key] !== property.const) {
|
|
433
|
-
return {
|
|
434
|
-
at: { parent: at, key },
|
|
435
|
-
reason: () => `expected ${JSON.stringify(property.const)}`
|
|
436
|
-
};
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
const keys = Object.keys(object);
|
|
440
|
-
charge(budget, keys.length);
|
|
441
|
-
const names = schema.propertyNames?.enum;
|
|
442
|
-
const allowed = names && setOf(schema.propertyNames, names);
|
|
443
|
-
for (const key of keys) {
|
|
444
|
-
if (allowed && !allowed.has(key)) {
|
|
445
|
-
return {
|
|
446
|
-
at: { parent: at, key },
|
|
447
|
-
reason: () => "is not an allowed key"
|
|
448
|
-
};
|
|
449
|
-
}
|
|
450
|
-
const property = Object.hasOwn(properties, key) ? properties[key] : schema.additionalProperties;
|
|
451
|
-
if (property === false) {
|
|
452
|
-
return {
|
|
453
|
-
at: { parent: at, key },
|
|
454
|
-
reason: () => "is not an allowed key"
|
|
455
|
-
};
|
|
456
|
-
}
|
|
457
|
-
if (property && property !== true) {
|
|
458
|
-
const found = matches(
|
|
459
|
-
property,
|
|
460
|
-
object[key],
|
|
461
|
-
{ parent: at, key },
|
|
462
|
-
budget
|
|
463
|
-
);
|
|
464
|
-
if (found) {
|
|
465
|
-
return found;
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
for (const branch of schema.allOf ?? []) {
|
|
471
|
-
const found = matches(branch, value, at, budget);
|
|
472
|
-
if (found) {
|
|
473
|
-
return found;
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
if (schema.anyOf && !schema.anyOf.some((branch) => !matches(branch, value, at, budget))) {
|
|
477
|
-
return issue(() => "matches none of the allowed shapes");
|
|
478
|
-
}
|
|
479
|
-
if (schema.oneOf) {
|
|
480
|
-
let count3 = 0;
|
|
481
|
-
for (const branch of schema.oneOf) {
|
|
482
|
-
if (!matches(branch, value, at, budget) && ++count3 > 1) {
|
|
483
|
-
return issue(() => "matches more than one of the allowed shapes");
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
if (!count3) {
|
|
487
|
-
return issue(() => "matches none of the allowed shapes");
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
return null;
|
|
491
|
-
}
|
|
492
|
-
function trackerDataIssue(schema, data, budget = { steps: trackerDataRecordSteps }) {
|
|
493
|
-
try {
|
|
494
|
-
const found = matches(schema, data, null, budget);
|
|
495
|
-
return found && {
|
|
496
|
-
kind: "mismatch",
|
|
497
|
-
path: pathText(found.at),
|
|
498
|
-
reason: found.reason()
|
|
499
|
-
};
|
|
500
|
-
} catch (error) {
|
|
501
|
-
if (error instanceof BudgetSpent) {
|
|
502
|
-
return {
|
|
503
|
-
kind: "too-complex",
|
|
504
|
-
path: "data",
|
|
505
|
-
reason: "is too complex to validate against the tracker's schema"
|
|
506
|
-
};
|
|
507
|
-
}
|
|
508
|
-
throw error;
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
function trackerDataIssues(schema, records) {
|
|
512
|
-
const batch = { steps: trackerDataBatchSteps };
|
|
513
|
-
return records.map((data) => {
|
|
514
|
-
const budget = { steps: Math.min(trackerDataRecordSteps, batch.steps) };
|
|
515
|
-
const allowance = budget.steps;
|
|
516
|
-
const found = trackerDataIssue(schema, data, budget);
|
|
517
|
-
batch.steps -= allowance - Math.max(budget.steps, 0);
|
|
518
|
-
return found;
|
|
519
|
-
});
|
|
520
|
-
}
|
|
521
|
-
function alternatives(schemas) {
|
|
522
|
-
return schemas.flatMap(
|
|
523
|
-
(s) => s.anyOf || s.oneOf || s.allOf ? alternatives([
|
|
524
|
-
...s.anyOf ?? [],
|
|
525
|
-
...s.oneOf ?? [],
|
|
526
|
-
...s.allOf ?? []
|
|
527
|
-
]) : [s]
|
|
528
|
-
);
|
|
529
|
-
}
|
|
530
|
-
var unconstrained = (s) => s.type === void 0 && s.properties === void 0 && s.const === void 0 && s.enum === void 0;
|
|
531
|
-
function trackerDataPathTypes(schema, path) {
|
|
532
|
-
const any = /* @__PURE__ */ new Set([
|
|
533
|
-
"string",
|
|
534
|
-
"number",
|
|
535
|
-
"boolean",
|
|
536
|
-
"null",
|
|
537
|
-
"object",
|
|
538
|
-
"array"
|
|
539
|
-
]);
|
|
540
|
-
let current = [schema];
|
|
541
|
-
for (const key of path.split(".")) {
|
|
542
|
-
const next = [];
|
|
543
|
-
for (const s of alternatives(current)) {
|
|
544
|
-
if (unconstrained(s)) {
|
|
545
|
-
next.push({});
|
|
546
|
-
} else if (s.type !== "object") {
|
|
547
|
-
continue;
|
|
548
|
-
} else if (s.properties && Object.hasOwn(s.properties, key)) {
|
|
549
|
-
next.push(s.properties[key]);
|
|
550
|
-
} else if (s.additionalProperties === true) {
|
|
551
|
-
next.push({});
|
|
552
|
-
} else if (s.additionalProperties) {
|
|
553
|
-
next.push(s.additionalProperties);
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
if (!next.length) {
|
|
557
|
-
return null;
|
|
558
|
-
}
|
|
559
|
-
current = next;
|
|
560
|
-
}
|
|
561
|
-
const types = /* @__PURE__ */ new Set();
|
|
562
|
-
for (const s of alternatives(current)) {
|
|
563
|
-
if (unconstrained(s)) {
|
|
564
|
-
return any;
|
|
565
|
-
}
|
|
566
|
-
if (s.type) {
|
|
567
|
-
types.add(s.type === "integer" ? "number" : s.type);
|
|
568
|
-
}
|
|
569
|
-
for (const value of [
|
|
570
|
-
...s.const !== void 0 ? [s.const] : [],
|
|
571
|
-
...s.enum ?? []
|
|
572
|
-
]) {
|
|
573
|
-
types.add(value === null ? "null" : typeof value);
|
|
574
|
-
}
|
|
575
|
-
}
|
|
576
|
-
return types;
|
|
577
|
-
}
|
|
578
|
-
function schemaCheckedReader(reader) {
|
|
579
|
-
return {
|
|
580
|
-
content: (reference, query) => reader.content(reference, query),
|
|
581
|
-
summary: (reference, query) => reader.summary(reference, query),
|
|
582
|
-
records: (async (reference, query) => {
|
|
583
|
-
const page = await reader.records(reference, query);
|
|
584
|
-
const source = typeof reference === "object" ? reference.source : void 0;
|
|
585
|
-
const schema = source?.kind === "custom" ? source.data : void 0;
|
|
586
|
-
if (!schema) {
|
|
587
|
-
return page;
|
|
588
|
-
}
|
|
589
|
-
const issues = trackerDataIssues(
|
|
590
|
-
schema,
|
|
591
|
-
page.items.map((record) => record.data)
|
|
592
|
-
);
|
|
593
|
-
const items = page.items.filter((_, index) => !issues[index]);
|
|
594
|
-
return { ...page, items, excluded: page.items.length - items.length };
|
|
595
|
-
})
|
|
596
|
-
};
|
|
597
|
-
}
|
|
598
|
-
function whereSchemaIssue(schema, where) {
|
|
599
|
-
const conditions = where === void 0 ? [] : Array.isArray(where) ? where : [where];
|
|
600
|
-
for (const condition of conditions) {
|
|
601
|
-
const types = trackerDataPathTypes(schema, condition.path);
|
|
602
|
-
if (!types) {
|
|
603
|
-
return `The tracker filter reads data.${condition.path}, which the tracker's data schema does not declare`;
|
|
604
|
-
}
|
|
605
|
-
const wanted = "equals" in condition ? [typeof condition.equals] : ["number", "string"];
|
|
606
|
-
if (!wanted.some((type) => types.has(type))) {
|
|
607
|
-
return `The tracker filter compares data.${condition.path} with ${"equals" in condition ? JSON.stringify(condition.equals) : "a number"}, but the field holds ${[...types].join(" or ")}`;
|
|
608
|
-
}
|
|
609
|
-
}
|
|
610
|
-
return null;
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
// src/trackers.ts
|
|
614
|
-
import { z as z5 } from "zod";
|
|
615
|
-
var timestamp = z5.number().int().safe().nonnegative().max(864e13);
|
|
616
|
-
var count = z5.number().int().safe().nonnegative();
|
|
617
|
-
var externalId = z5.string().min(1).max(256);
|
|
618
|
-
var metric = count.nullable().default(null);
|
|
619
|
-
var xTweetSchema = z5.looseObject({
|
|
620
|
-
id: externalId,
|
|
621
|
-
userId: externalId,
|
|
622
|
-
content: z5.string(),
|
|
623
|
-
createdAt: z5.iso.datetime({ offset: true }),
|
|
624
|
-
author: z5.looseObject({
|
|
625
|
-
id: externalId,
|
|
626
|
-
username: z5.string(),
|
|
627
|
-
name: z5.string(),
|
|
628
|
-
verified: z5.boolean().nullable().default(null)
|
|
629
|
-
}),
|
|
630
|
-
likeCount: metric,
|
|
631
|
-
replyCount: metric,
|
|
632
|
-
retweetCount: metric,
|
|
633
|
-
quoteCount: metric,
|
|
634
|
-
viewCount: metric,
|
|
635
|
-
bookmarkCount: metric,
|
|
636
|
-
isReply: z5.boolean(),
|
|
637
|
-
isRetweet: z5.boolean(),
|
|
638
|
-
isQuoteTweet: z5.boolean()
|
|
639
|
-
});
|
|
640
|
-
var xContentBodySchema = z5.strictObject({
|
|
641
|
-
version: z5.literal(1),
|
|
642
|
-
id: z5.string().min(1),
|
|
643
|
-
authorId: z5.string().min(1),
|
|
644
|
-
publishedAt: timestamp,
|
|
645
|
-
text: z5.string(),
|
|
646
|
-
isReply: z5.boolean(),
|
|
647
|
-
isRetweet: z5.boolean(),
|
|
648
|
-
isQuoteTweet: z5.boolean(),
|
|
649
|
-
media: z5.array(z5.strictObject({ type: z5.string(), url: z5.string() })).nullable(),
|
|
650
|
-
mentionedAuthorIds: z5.array(z5.string().min(1)).nullable(),
|
|
651
|
-
videoLengthSeconds: z5.number().nonnegative().nullable(),
|
|
652
|
-
references: z5.strictObject({
|
|
653
|
-
replyId: z5.string().nullable(),
|
|
654
|
-
replyAuthorId: z5.string().nullable(),
|
|
655
|
-
quoteId: z5.string().nullable(),
|
|
656
|
-
quoteAuthorId: z5.string().nullable(),
|
|
657
|
-
repostId: z5.string().nullable(),
|
|
658
|
-
repostAuthorId: z5.string().nullable()
|
|
659
|
-
})
|
|
660
|
-
});
|
|
661
|
-
var trackerContentQuerySchema = z5.strictObject({
|
|
662
|
-
id: externalId,
|
|
663
|
-
observation: z5.string().regex(/^observation_[a-f0-9]{64}$/)
|
|
664
|
-
});
|
|
665
|
-
var trackerContentReadSchema = trackerContentQuerySchema.extend({
|
|
666
|
-
member: identifier
|
|
667
|
-
});
|
|
668
|
-
var attributionContext = { member: identifier, capturedAt: timestamp };
|
|
669
|
-
var trackerEvidenceSchema = z5.strictObject({
|
|
670
|
-
contentRevision: identifier,
|
|
671
|
-
observation: identifier
|
|
672
|
-
});
|
|
673
|
-
var trackerContentSchema = z5.strictObject({
|
|
674
|
-
tracker: identifier,
|
|
675
|
-
source: z5.literal("x"),
|
|
676
|
-
evidence: trackerEvidenceSchema,
|
|
677
|
-
content: xContentBodySchema,
|
|
678
|
-
observedAt: timestamp,
|
|
679
|
-
removed: z5.boolean(),
|
|
680
|
-
attribution: z5.discriminatedUnion("kind", [
|
|
681
|
-
z5.strictObject({
|
|
682
|
-
...attributionContext,
|
|
683
|
-
kind: z5.literal("linked"),
|
|
684
|
-
account: z5.strictObject({
|
|
685
|
-
provider: z5.literal("x"),
|
|
686
|
-
issuer: z5.string().min(1),
|
|
687
|
-
subject: externalId,
|
|
688
|
-
revision: count,
|
|
689
|
-
linkedAt: timestamp.nullable()
|
|
690
|
-
})
|
|
691
|
-
}),
|
|
692
|
-
z5.strictObject({ ...attributionContext, kind: z5.literal("unlinked") }),
|
|
693
|
-
z5.strictObject({
|
|
694
|
-
...attributionContext,
|
|
695
|
-
kind: z5.literal("different-author")
|
|
696
|
-
})
|
|
697
|
-
])
|
|
698
|
-
});
|
|
699
|
-
var identityKindSchema = z5.enum(["wallet", "x", "discord", "member"]);
|
|
700
|
-
var accountRoleSchema = z5.string().regex(
|
|
701
|
-
/^[a-zA-Z][a-zA-Z0-9_]{0,39}$/,
|
|
702
|
-
"Name roles like author or recipient: a letter, then letters, digits or underscores"
|
|
703
|
-
);
|
|
704
|
-
var xAccountRoles = ["author", "inReplyTo"];
|
|
705
|
-
var distinct = (values) => new Set(values).size === values.length;
|
|
706
|
-
var xSearchSourceSchema = z5.object({
|
|
707
|
-
kind: z5.literal("x-search"),
|
|
708
|
-
query: z5.string().trim().min(1).max(2e3)
|
|
709
|
-
}).strict();
|
|
710
|
-
var customSourceSchema = z5.object({
|
|
711
|
-
kind: z5.literal("custom"),
|
|
712
|
-
namespace: identifier,
|
|
713
|
-
/**
|
|
714
|
-
* The identity kinds a record's author and named accounts can be, attributed to members
|
|
715
|
-
* through verified links. Omitted when authors are opaque IDs, which no quest can pay.
|
|
716
|
-
*/
|
|
717
|
-
identities: z5.array(identityKindSchema).min(1).max(4).refine(distinct, "List each identity kind once").optional(),
|
|
718
|
-
/** Roles of the named accounts records can carry besides their author, such as `recipient`. */
|
|
719
|
-
accounts: z5.array(accountRoleSchema).min(1).max(10).refine(distinct, "List each account role once").refine(
|
|
720
|
-
(roles) => !roles.includes("author"),
|
|
721
|
-
"author is every record's own role; name other accounts"
|
|
722
|
-
).optional(),
|
|
723
|
-
/**
|
|
724
|
-
* How trackers published before identity kinds stored `identities: ["wallet"]`. Reads return
|
|
725
|
-
* those definitions as stored; write `identities` instead.
|
|
726
|
-
*
|
|
727
|
-
* @deprecated Use `identities: ["wallet"]`.
|
|
728
|
-
*/
|
|
729
|
-
authors: z5.literal("wallet").optional(),
|
|
730
|
-
/**
|
|
731
|
-
* The schema every record's `data` matches, which ingestion enforces. `customSource()`
|
|
732
|
-
* requires it. Trackers published before typed data have none, and take no records until
|
|
733
|
-
* they are published with one.
|
|
734
|
-
*/
|
|
735
|
-
data: trackerDataSchemaSchema.optional()
|
|
736
|
-
}).strict().refine(
|
|
737
|
-
(source) => !(source.authors && source.identities),
|
|
738
|
-
"Use identities, not authors"
|
|
739
|
-
).refine(
|
|
740
|
-
(source) => !source.accounts || source.identities,
|
|
741
|
-
"Named accounts need identities"
|
|
742
|
-
);
|
|
743
|
-
var trackerSourceSchema = z5.discriminatedUnion("kind", [
|
|
744
|
-
xSearchSourceSchema,
|
|
745
|
-
customSourceSchema
|
|
746
|
-
]);
|
|
747
|
-
function sourceIdentities(source) {
|
|
748
|
-
if (source.kind === "x-search") {
|
|
749
|
-
return ["x"];
|
|
750
|
-
}
|
|
751
|
-
return source.identities ?? (source.authors === "wallet" ? ["wallet"] : void 0);
|
|
752
|
-
}
|
|
753
|
-
var windowSchema = z5.object({ start: timestamp, end: timestamp.optional() }).strict().refine(
|
|
754
|
-
(w) => w.end === void 0 || w.end > w.start,
|
|
755
|
-
"End must follow start"
|
|
756
|
-
);
|
|
757
|
-
var trackerDefinitionSchema = z5.object({
|
|
758
|
-
key: identifier,
|
|
759
|
-
title: z5.string().trim().min(1).max(120),
|
|
760
|
-
source: trackerSourceSchema,
|
|
761
|
-
window: windowSchema,
|
|
762
|
-
refreshSeconds: z5.number().int().min(300).max(86400).default(21600),
|
|
763
|
-
maxPages: z5.number().int().min(1).max(1e3).default(60)
|
|
764
|
-
}).strict();
|
|
765
|
-
var trackerArtifactSchema = z5.union([
|
|
766
|
-
trackerDefinitionSchema,
|
|
767
|
-
z5.object({ code: z5.string().min(1).max(2e6) }).strict()
|
|
768
|
-
]);
|
|
769
|
-
var publishedTrackerSchema = z5.object({
|
|
770
|
-
id: identifier,
|
|
771
|
-
version: identifier,
|
|
772
|
-
definition: trackerDefinitionSchema,
|
|
773
|
-
publishedAt: timestamp,
|
|
774
|
-
actor: z5.string().nullable()
|
|
775
|
-
});
|
|
776
|
-
var trackerStatusSchema = z5.object({
|
|
777
|
-
published: publishedTrackerSchema,
|
|
778
|
-
paused: z5.boolean(),
|
|
779
|
-
state: z5.enum(["idle", "syncing", "error", "complete"]),
|
|
780
|
-
lastStartedAt: timestamp.nullable(),
|
|
781
|
-
lastCompletedAt: timestamp.nullable(),
|
|
782
|
-
nextSyncAt: timestamp.nullable(),
|
|
783
|
-
coverage: z5.enum(["unknown", "partial", "complete"]),
|
|
784
|
-
error: z5.string().nullable(),
|
|
785
|
-
records: count
|
|
786
|
-
});
|
|
787
|
-
var trackerControlSchema = z5.object({
|
|
788
|
-
actionId: identifier,
|
|
789
|
-
action: z5.enum(["pause", "resume", "refresh"])
|
|
790
|
-
}).strict();
|
|
791
|
-
var trackerAccountSchema = z5.strictObject({
|
|
792
|
-
kind: identityKindSchema.optional(),
|
|
793
|
-
id: externalId
|
|
794
|
-
});
|
|
795
|
-
var trackerRecordInputSchema = z5.object({
|
|
796
|
-
id: externalId,
|
|
797
|
-
occurredAt: timestamp,
|
|
798
|
-
observedAt: timestamp,
|
|
799
|
-
author: z5.object({
|
|
800
|
-
id: externalId,
|
|
801
|
-
verified: z5.boolean().nullable().default(null),
|
|
802
|
-
/** The author's identity kind; needed when the source names more than one. */
|
|
803
|
-
kind: identityKindSchema.optional()
|
|
804
|
-
}).strict().nullable().default(null),
|
|
805
|
-
/** Named accounts besides the author, by the roles the custom source declares. */
|
|
806
|
-
accounts: z5.record(accountRoleSchema, trackerAccountSchema).refine(
|
|
807
|
-
(accounts) => Object.keys(accounts).length <= 10,
|
|
808
|
-
"At most 10 accounts"
|
|
809
|
-
).optional(),
|
|
810
|
-
data: z5.record(z5.string(), z5.json()),
|
|
811
|
-
removed: z5.boolean().default(false)
|
|
812
|
-
}).strict().refine(
|
|
813
|
-
(v) => new TextEncoder().encode(JSON.stringify(v.data)).byteLength <= 131072,
|
|
814
|
-
"Record exceeds 128 KB"
|
|
815
|
-
);
|
|
816
|
-
var trackerRecordSchema = trackerRecordInputSchema.safeExtend({
|
|
817
|
-
source: z5.string(),
|
|
818
|
-
firstSeenAt: timestamp,
|
|
819
|
-
/** Present only when includeEvidence is true; custom sources have no X evidence. */
|
|
820
|
-
evidence: trackerEvidenceSchema.nullable().optional()
|
|
821
|
-
});
|
|
822
|
-
var trackerIngestSchema = z5.object({
|
|
823
|
-
actionId: identifier,
|
|
824
|
-
records: z5.array(trackerRecordInputSchema).min(1).max(100)
|
|
825
|
-
}).strict();
|
|
826
|
-
var trackerIngestResultSchema = z5.object({
|
|
827
|
-
stored: count,
|
|
828
|
-
/** Tracker-trigger decisions this ingest caused. Absent from servers without tracker triggers. */
|
|
829
|
-
admissions: z5.object({
|
|
830
|
-
admitted: count,
|
|
831
|
-
skipped: count,
|
|
832
|
-
/**
|
|
833
|
-
* Observations a quest's firing mode selected but its `where` filter did not match, counted
|
|
834
|
-
* per quest like `admitted` and `skipped`. They record no outcome. Present only when
|
|
835
|
-
* nonzero.
|
|
836
|
-
*/
|
|
837
|
-
filtered: count.optional()
|
|
838
|
-
}).optional()
|
|
839
|
-
});
|
|
840
|
-
var trackerOutcomeFields = {
|
|
841
|
-
/** Stable quest ID. */
|
|
842
|
-
quest: identifier,
|
|
843
|
-
/** Stable tracker ID. */
|
|
844
|
-
tracker: identifier,
|
|
845
|
-
record: externalId,
|
|
846
|
-
observedAt: timestamp,
|
|
847
|
-
/** The release admitted, or the one active when the observation was skipped. */
|
|
848
|
-
release: identifier,
|
|
849
|
-
/** The account attribution resolved or failed to resolve, such as a CAIP-10 wallet ID. */
|
|
850
|
-
account: z5.string().nullable(),
|
|
851
|
-
createdAt: timestamp,
|
|
852
|
-
updatedAt: timestamp,
|
|
853
|
-
/** Null for automatic decisions; the staff actor after a retry. */
|
|
854
|
-
actor: z5.string().nullable()
|
|
855
|
-
};
|
|
856
|
-
var trackerSkipCodes = [
|
|
857
|
-
/** The quest is paused or no longer active. */
|
|
858
|
-
"quest-paused",
|
|
859
|
-
/** The record occurred before the quest was published. */
|
|
860
|
-
"before-activation",
|
|
861
|
-
/** The record is marked removed. */
|
|
862
|
-
"record-removed",
|
|
863
|
-
/**
|
|
864
|
-
* The record's data does not match the tracker's current data schema, such as a record stored
|
|
865
|
-
* before the schema changed. Staff can retry it once the schema accepts the data.
|
|
866
|
-
*/
|
|
867
|
-
"invalid-record-data",
|
|
868
|
-
/** The captured X post of this observation cannot be read. */
|
|
869
|
-
"content-unavailable",
|
|
870
|
-
/** The record has no account in the beneficiary role, such as a post that is not a reply. */
|
|
871
|
-
"no-account",
|
|
872
|
-
/**
|
|
873
|
-
* The beneficiary account is the record's author account, such as a reply to oneself, or both
|
|
874
|
-
* belong to the same member. A different account is judged once it resolves to a member, after
|
|
875
|
-
* `unlinked-account` and `ambiguous-account`.
|
|
876
|
-
*/
|
|
877
|
-
"beneficiary-is-author",
|
|
878
|
-
/** No member has verified the beneficiary account. */
|
|
879
|
-
"unlinked-account",
|
|
880
|
-
/** More than one member has the beneficiary account. */
|
|
881
|
-
"ambiguous-account",
|
|
882
|
-
/** The attributed member has not joined the project. */
|
|
883
|
-
"not-joined",
|
|
884
|
-
/** The attributed member has not completed the quest's prerequisites. */
|
|
885
|
-
"prerequisites-incomplete"
|
|
886
|
-
];
|
|
887
|
-
var trackerOutcomeSchema = z5.discriminatedUnion("state", [
|
|
888
|
-
z5.strictObject({
|
|
889
|
-
...trackerOutcomeFields,
|
|
890
|
-
state: z5.literal("admitted"),
|
|
891
|
-
code: z5.null(),
|
|
892
|
-
reason: z5.null(),
|
|
893
|
-
/** The attributed member. */
|
|
894
|
-
member: identifier,
|
|
895
|
-
/** The admitted attempt. Its evaluation, decision and rewards live on the attempt. */
|
|
896
|
-
attempt: identifier
|
|
897
|
-
}),
|
|
898
|
-
z5.strictObject({
|
|
899
|
-
...trackerOutcomeFields,
|
|
900
|
-
state: z5.literal("skipped"),
|
|
901
|
-
/** Why the observation was skipped, as one of `trackerSkipCodes`. */
|
|
902
|
-
code: z5.string().min(1),
|
|
903
|
-
/** Why the observation was skipped, for people. */
|
|
904
|
-
reason: z5.string(),
|
|
905
|
-
/** The attributed member, when attribution got that far. */
|
|
906
|
-
member: identifier.nullable(),
|
|
907
|
-
attempt: identifier.nullable()
|
|
908
|
-
})
|
|
909
|
-
]);
|
|
910
|
-
var trackerOutcomeQuerySchema = z5.strictObject({
|
|
911
|
-
/** Quest key or ID. */
|
|
912
|
-
quest: identifier.optional(),
|
|
913
|
-
record: externalId.optional(),
|
|
914
|
-
member: identifier.optional(),
|
|
915
|
-
state: z5.enum(["admitted", "skipped"]).optional(),
|
|
916
|
-
/** Only skips with this code, such as `unlinked-account`. */
|
|
917
|
-
code: z5.string().min(1).max(100).optional(),
|
|
918
|
-
limit: z5.coerce.number().int().min(1).max(100).default(25),
|
|
919
|
-
/** Opaque cursor from `next`: older outcomes. */
|
|
920
|
-
before: z5.string().max(512).optional()
|
|
921
|
-
});
|
|
922
|
-
var trackerOutcomePageSchema = z5.strictObject({
|
|
923
|
-
/** Newest first. */
|
|
924
|
-
items: z5.array(trackerOutcomeSchema).max(100),
|
|
925
|
-
next: z5.string().nullable()
|
|
926
|
-
});
|
|
927
|
-
var trackerOutcomeRetrySchema = z5.strictObject({
|
|
928
|
-
actionId: identifier,
|
|
929
|
-
/** Quest key or ID. */
|
|
930
|
-
quest: identifier,
|
|
931
|
-
record: externalId,
|
|
932
|
-
observedAt: timestamp
|
|
933
|
-
});
|
|
934
|
-
var booleanQuery = z5.union([
|
|
935
|
-
z5.boolean(),
|
|
936
|
-
z5.enum(["true", "false"]).transform((v) => v === "true")
|
|
937
|
-
]);
|
|
938
|
-
var trackerQuerySchema = z5.object({
|
|
939
|
-
author: externalId.optional(),
|
|
940
|
-
member: identifier.optional(),
|
|
941
|
-
verified: booleanQuery.optional(),
|
|
942
|
-
since: z5.coerce.number().int().safe().nonnegative().optional(),
|
|
943
|
-
until: z5.coerce.number().int().safe().nonnegative().optional(),
|
|
944
|
-
removed: booleanQuery.default(false),
|
|
945
|
-
minLikes: z5.coerce.number().int().safe().nonnegative().optional(),
|
|
946
|
-
minViews: z5.coerce.number().int().safe().nonnegative().optional(),
|
|
947
|
-
limit: z5.coerce.number().int().min(1).max(100).default(25),
|
|
948
|
-
cursor: z5.string().max(2048).optional(),
|
|
949
|
-
includeEvidence: booleanQuery.optional()
|
|
950
|
-
}).strict().refine(
|
|
951
|
-
(q) => q.since === void 0 || q.until === void 0 || q.until > q.since,
|
|
952
|
-
"Until must follow since"
|
|
953
|
-
);
|
|
954
|
-
var trackerPageSchema = z5.object({
|
|
955
|
-
tracker: identifier,
|
|
956
|
-
items: z5.array(trackerRecordSchema),
|
|
957
|
-
nextCursor: z5.string().nullable(),
|
|
958
|
-
total: count,
|
|
959
|
-
status: trackerStatusSchema
|
|
960
|
-
});
|
|
961
|
-
var trackerSummarySchema = z5.object({
|
|
962
|
-
records: count,
|
|
963
|
-
authors: count,
|
|
964
|
-
metrics: z5.object({
|
|
965
|
-
likes: count,
|
|
966
|
-
replies: count,
|
|
967
|
-
reposts: count,
|
|
968
|
-
quotes: count,
|
|
969
|
-
views: count,
|
|
970
|
-
bookmarks: count
|
|
971
|
-
}),
|
|
972
|
-
missingMetrics: count,
|
|
973
|
-
status: trackerStatusSchema
|
|
974
|
-
});
|
|
975
|
-
var trackerPreviewLimits = {
|
|
976
|
-
pages: 3,
|
|
977
|
-
posts: 100,
|
|
978
|
-
days: 30
|
|
979
|
-
};
|
|
980
|
-
var trackerPreviewInputSchema = z5.object({
|
|
981
|
-
query: xSearchSourceSchema.shape.query,
|
|
982
|
-
/** Start of the searched window. The window ends when the sample is fetched. */
|
|
983
|
-
since: timestamp
|
|
984
|
-
}).strict();
|
|
985
|
-
var trackerPreviewSchema = z5.object({
|
|
986
|
-
query: z5.string(),
|
|
987
|
-
since: timestamp,
|
|
988
|
-
fetchedAt: timestamp,
|
|
989
|
-
pages: count,
|
|
990
|
-
/** Every match in the sample, newest first, verified or not. */
|
|
991
|
-
posts: z5.array(xTweetSchema).max(trackerPreviewLimits.posts),
|
|
992
|
-
/** X had more matches than the sample holds. */
|
|
993
|
-
more: z5.boolean()
|
|
994
|
-
});
|
|
995
|
-
|
|
996
|
-
// src/content.ts
|
|
997
|
-
import { z as z6 } from "zod";
|
|
998
|
-
var timestamp2 = z6.number().int().safe().nonnegative().max(864e13);
|
|
999
|
-
var contentPolicySchema = z6.strictObject({
|
|
1000
|
-
tracker: identifier,
|
|
1001
|
-
window: trackerDefinitionSchema.shape.window,
|
|
1002
|
-
enrollment: z6.enum(["none", "required"]).default("none"),
|
|
1003
|
-
posts: z6.enum(["after-enrollment", "since-start"]).default("after-enrollment"),
|
|
1004
|
-
historical: z6.enum(["automatic", "claim", "staff"]).default("claim")
|
|
1005
|
-
});
|
|
1006
|
-
var admittedContentSchema = xContentBodySchema.extend({
|
|
1007
|
-
tracker: identifier,
|
|
1008
|
-
revision: identifier,
|
|
1009
|
-
observation: identifier,
|
|
1010
|
-
attribution: trackerContentSchema.shape.attribution.options[0],
|
|
1011
|
-
enrolledAt: timestamp2.nullable(),
|
|
1012
|
-
completionKey: z6.string().min(1).max(200)
|
|
1013
|
-
});
|
|
1014
|
-
var contentEnrollmentInputSchema = z6.strictObject({
|
|
1015
|
-
actionId: identifier,
|
|
1016
|
-
quest: identifier,
|
|
1017
|
-
member: identifier
|
|
1018
|
-
});
|
|
1019
|
-
var contentEnrollmentSchema = z6.strictObject({
|
|
1020
|
-
quest: identifier,
|
|
1021
|
-
member: identifier,
|
|
1022
|
-
enrolledAt: timestamp2
|
|
1023
|
-
});
|
|
1024
|
-
var contentReleaseInputSchema = contentEnrollmentInputSchema.extend({
|
|
1025
|
-
content: z6.string().min(1).max(256)
|
|
1026
|
-
});
|
|
1027
|
-
var contentAdmissionSchema = z6.strictObject({
|
|
1028
|
-
quest: identifier,
|
|
1029
|
-
content: z6.string().min(1).max(256),
|
|
1030
|
-
release: identifier,
|
|
1031
|
-
state: z6.enum(["pending", "admitted", "excluded"]),
|
|
1032
|
-
reason: z6.string().nullable(),
|
|
1033
|
-
attempt: identifier.nullable()
|
|
1034
|
-
});
|
|
1035
|
-
var contentAdmissionQuerySchema = z6.strictObject({
|
|
1036
|
-
quest: identifier,
|
|
1037
|
-
member: identifier.optional(),
|
|
1038
|
-
content: z6.string().min(1).max(256).optional(),
|
|
1039
|
-
cursor: pageCursorSchema.optional()
|
|
1040
|
-
});
|
|
1041
|
-
var contentAdmissionPageSchema = z6.strictObject({
|
|
1042
|
-
items: z6.array(contentAdmissionSchema),
|
|
1043
|
-
nextCursor: pageCursorSchema.nullable()
|
|
1044
|
-
});
|
|
1045
|
-
var contentQualificationDecisionSchema = z6.strictObject({
|
|
1046
|
-
kind: z6.enum(["accept", "reject", "review", "superseded"]),
|
|
1047
|
-
reason: z6.string().nullable()
|
|
1048
|
-
});
|
|
1049
|
-
var contentQualificationQuerySchema = z6.strictObject({
|
|
1050
|
-
quest: identifier,
|
|
1051
|
-
member: identifier.optional(),
|
|
1052
|
-
content: z6.string().min(1).max(256).optional(),
|
|
1053
|
-
cursor: pageCursorSchema.optional()
|
|
1054
|
-
});
|
|
1055
|
-
var contentQualificationSchema = z6.strictObject({
|
|
1056
|
-
quest: identifier,
|
|
1057
|
-
content: z6.string(),
|
|
1058
|
-
member: identifier,
|
|
1059
|
-
release: identifier,
|
|
1060
|
-
attempt: identifier,
|
|
1061
|
-
revision: identifier,
|
|
1062
|
-
observation: identifier,
|
|
1063
|
-
current: z6.boolean(),
|
|
1064
|
-
state: z6.enum([
|
|
1065
|
-
"pending",
|
|
1066
|
-
"qualified",
|
|
1067
|
-
"unqualified",
|
|
1068
|
-
"needs-review",
|
|
1069
|
-
"failed",
|
|
1070
|
-
"superseded",
|
|
1071
|
-
"stale",
|
|
1072
|
-
"blocked",
|
|
1073
|
-
"unavailable"
|
|
1074
|
-
]),
|
|
1075
|
-
reason: z6.string().nullable(),
|
|
1076
|
-
reward: z6.strictObject({
|
|
1077
|
-
attempt: identifier.nullable(),
|
|
1078
|
-
completion: identifier.nullable(),
|
|
1079
|
-
state: z6.enum(["unresolved", "awarded", "excluded"])
|
|
1080
|
-
})
|
|
1081
|
-
});
|
|
1082
|
-
var contentQualificationPageSchema = z6.strictObject({
|
|
1083
|
-
items: z6.array(contentQualificationSchema),
|
|
1084
|
-
nextCursor: pageCursorSchema.nullable()
|
|
1085
|
-
});
|
|
1086
|
-
var contentMetricSchema = z6.enum([
|
|
1087
|
-
"likes",
|
|
1088
|
-
"replies",
|
|
1089
|
-
"reposts",
|
|
1090
|
-
"quotes",
|
|
1091
|
-
"views",
|
|
1092
|
-
"bookmarks"
|
|
1093
|
-
]);
|
|
1094
|
-
var contentMetricsSchema = z6.partialRecord(
|
|
1095
|
-
contentMetricSchema,
|
|
1096
|
-
z6.number().int().safe().nonnegative()
|
|
1097
|
-
);
|
|
1098
|
-
var contentPerformancePolicySchema = z6.strictObject({
|
|
1099
|
-
metrics: z6.array(contentMetricSchema).min(1).max(6).refine(
|
|
1100
|
-
(values) => new Set(values).size === values.length,
|
|
1101
|
-
"Metrics must be unique"
|
|
1102
|
-
),
|
|
1103
|
-
maxAgeMs: z6.number().int().positive().max(864e5).default(36e5)
|
|
1104
|
-
});
|
|
1105
|
-
|
|
1106
|
-
// src/streaks.ts
|
|
1107
|
-
import { z as z7 } from "zod";
|
|
1108
|
-
var communityTimeZoneSchema = z7.string().min(1).max(100).refine((zone) => {
|
|
1109
|
-
try {
|
|
1110
|
-
if (/^[+-]/.test(zone)) {
|
|
1111
|
-
return false;
|
|
1112
|
-
}
|
|
1113
|
-
new Intl.DateTimeFormat("en", { timeZone: zone });
|
|
1114
|
-
return true;
|
|
1115
|
-
} catch {
|
|
1116
|
-
return false;
|
|
1117
|
-
}
|
|
1118
|
-
}, "Use an IANA community timezone, such as Europe/Budapest");
|
|
1119
|
-
var streakPolicySchema = z7.object({
|
|
1120
|
-
kind: z7.literal("streak"),
|
|
1121
|
-
days: z7.number().int().min(1).max(3650),
|
|
1122
|
-
timeZone: communityTimeZoneSchema
|
|
1123
|
-
}).strict();
|
|
1124
|
-
var streakProgressSchema = z7.object({
|
|
1125
|
-
goal: z7.number().int().positive(),
|
|
1126
|
-
current: z7.number().int().nonnegative(),
|
|
1127
|
-
best: z7.number().int().nonnegative(),
|
|
1128
|
-
today: z7.string(),
|
|
1129
|
-
todayQualified: z7.boolean(),
|
|
1130
|
-
timeZone: communityTimeZoneSchema,
|
|
1131
|
-
nextBoundary: z7.number().int(),
|
|
1132
|
-
pendingTimeZone: z7.object({
|
|
1133
|
-
timeZone: communityTimeZoneSchema,
|
|
1134
|
-
effectiveAt: z7.number().int()
|
|
1135
|
-
}).nullable(),
|
|
1136
|
-
days: z7.array(
|
|
1137
|
-
z7.object({
|
|
1138
|
-
day: z7.number().int(),
|
|
1139
|
-
date: z7.string(),
|
|
1140
|
-
timeZone: communityTimeZoneSchema,
|
|
1141
|
-
occurredAt: z7.number().int()
|
|
1142
|
-
})
|
|
1143
|
-
),
|
|
1144
|
-
milestone: z7.discriminatedUnion("status", [
|
|
1145
|
-
z7.object({ status: z7.literal("pending") }),
|
|
1146
|
-
z7.object({
|
|
1147
|
-
status: z7.literal("awarded"),
|
|
1148
|
-
completion: z7.string(),
|
|
1149
|
-
achievedAt: z7.number().int()
|
|
1150
|
-
}),
|
|
1151
|
-
z7.object({
|
|
1152
|
-
status: z7.literal("budget-exhausted"),
|
|
1153
|
-
budget: z7.string(),
|
|
1154
|
-
achievedAt: z7.number().int()
|
|
1155
|
-
})
|
|
1156
|
-
])
|
|
1157
|
-
});
|
|
1158
|
-
|
|
1159
|
-
// src/tracker-triggers.ts
|
|
1160
|
-
import { z as z8 } from "zod";
|
|
1161
|
-
var timestamp3 = z8.number().int().safe().nonnegative().max(864e13);
|
|
1162
|
-
var count2 = z8.number().int().safe().nonnegative();
|
|
1163
|
-
var trackerTriggerModeSchema = z8.enum([
|
|
1164
|
-
"new-record",
|
|
1165
|
-
"new-observation",
|
|
1166
|
-
"data-changed"
|
|
1167
|
-
]);
|
|
1168
|
-
function defaultTriggerMode(source) {
|
|
1169
|
-
return source === "x-search" ? "new-record" : "new-observation";
|
|
1170
|
-
}
|
|
1171
|
-
var trackerBoundSchema = z8.union([
|
|
1172
|
-
z8.number().finite(),
|
|
1173
|
-
z8.strictObject({ setting: z8.string().regex(/^[a-zA-Z][a-zA-Z0-9_]*$/) })
|
|
1174
|
-
]);
|
|
1175
|
-
var dataPath = z8.string().max(200).regex(
|
|
1176
|
-
/^[^.\s]+(\.[^.\s]+)*$/,
|
|
1177
|
-
"Use dot-separated keys, such as metrics.likes"
|
|
1178
|
-
);
|
|
1179
|
-
var trackerConditionSchema = z8.union([
|
|
1180
|
-
z8.strictObject({
|
|
1181
|
-
path: dataPath,
|
|
1182
|
-
equals: z8.union([z8.string().max(1e3), z8.number().finite(), z8.boolean()])
|
|
1183
|
-
}),
|
|
1184
|
-
z8.strictObject({
|
|
1185
|
-
path: dataPath,
|
|
1186
|
-
gt: trackerBoundSchema.optional(),
|
|
1187
|
-
gte: trackerBoundSchema.optional(),
|
|
1188
|
-
lt: trackerBoundSchema.optional(),
|
|
1189
|
-
lte: trackerBoundSchema.optional()
|
|
1190
|
-
}).refine(
|
|
1191
|
-
(where) => [where.gt, where.gte, where.lt, where.lte].some(
|
|
1192
|
-
(bound2) => bound2 !== void 0
|
|
1193
|
-
),
|
|
1194
|
-
"Compare with equals, gt, gte, lt or lte"
|
|
1195
|
-
)
|
|
1196
|
-
]);
|
|
1197
|
-
var trackerWhereSchema = z8.union([
|
|
1198
|
-
trackerConditionSchema,
|
|
1199
|
-
z8.array(trackerConditionSchema).min(1).max(10)
|
|
1200
|
-
]);
|
|
1201
|
-
function whereConditions(where) {
|
|
1202
|
-
return where === void 0 ? [] : Array.isArray(where) ? where : [where];
|
|
1203
|
-
}
|
|
1204
|
-
function whereSettings(where) {
|
|
1205
|
-
return whereConditions(where).flatMap(
|
|
1206
|
-
(condition) => "equals" in condition ? [] : [condition.gt, condition.gte, condition.lt, condition.lte].flatMap(
|
|
1207
|
-
(bound2) => typeof bound2 === "object" ? [bound2.setting] : []
|
|
1208
|
-
)
|
|
1209
|
-
);
|
|
1210
|
-
}
|
|
1211
|
-
var trackerTriggerPolicySchema = z8.strictObject({
|
|
1212
|
-
/** The tracker's authoring key; publication binds it to the tracker's stable ID. */
|
|
1213
|
-
tracker: identifier,
|
|
1214
|
-
source: z8.enum(["x-search", "custom"]),
|
|
1215
|
-
/** Which observations fire; absent means the source's default (`defaultTriggerMode`). */
|
|
1216
|
-
on: trackerTriggerModeSchema.optional(),
|
|
1217
|
-
where: trackerWhereSchema.optional(),
|
|
1218
|
-
/**
|
|
1219
|
-
* The record account the quest pays: `author`, `inReplyTo` for an X post, or a named account of
|
|
1220
|
-
* a custom record. Relay attributes it through verified links; evaluators cannot redirect it.
|
|
1221
|
-
* Releases published before account roles store `"replied-to"` for `inReplyTo`.
|
|
1222
|
-
*/
|
|
1223
|
-
beneficiary: z8.union([accountRoleSchema, z8.literal("replied-to")])
|
|
1224
|
-
});
|
|
1225
|
-
function triggerMode(policy) {
|
|
1226
|
-
return policy.on ?? defaultTriggerMode(policy.source);
|
|
1227
|
-
}
|
|
1228
|
-
function beneficiaryRole(policy) {
|
|
1229
|
-
return policy.beneficiary === "replied-to" ? "inReplyTo" : policy.beneficiary;
|
|
1230
|
-
}
|
|
1231
|
-
var xLink = {
|
|
1232
|
-
issuer: z8.string().min(1),
|
|
1233
|
-
/** The account's stable user ID. */
|
|
1234
|
-
subject: z8.string().min(1).max(256),
|
|
1235
|
-
/** The member's account selection revision. */
|
|
1236
|
-
revision: count2,
|
|
1237
|
-
/** When the member linked the account; null when unknown. */
|
|
1238
|
-
linkedAt: timestamp3.nullable()
|
|
1239
|
-
};
|
|
1240
|
-
var trackerAttributionSchema = z8.strictObject({
|
|
1241
|
-
member: identifier,
|
|
1242
|
-
capturedAt: timestamp3,
|
|
1243
|
-
account: z8.discriminatedUnion("provider", [
|
|
1244
|
-
z8.strictObject({
|
|
1245
|
-
provider: z8.literal("wallet"),
|
|
1246
|
-
/** Canonical CAIP-10 account ID, as the record names it. */
|
|
1247
|
-
id: z8.string().min(5).max(256),
|
|
1248
|
-
/** The wallet link's revision. */
|
|
1249
|
-
revision: count2,
|
|
1250
|
-
/** When the member verified the wallet. */
|
|
1251
|
-
linkedAt: timestamp3.nullable()
|
|
1252
|
-
}),
|
|
1253
|
-
z8.strictObject({ provider: z8.literal("x"), ...xLink }),
|
|
1254
|
-
z8.strictObject({ provider: z8.literal("discord"), ...xLink }),
|
|
1255
|
-
z8.strictObject({
|
|
1256
|
-
provider: z8.literal("member"),
|
|
1257
|
-
/** The member ID the record names. */
|
|
1258
|
-
id: identifier
|
|
1259
|
-
})
|
|
1260
|
-
])
|
|
1261
|
-
});
|
|
1262
|
-
var trackerTriggerRecordSchema = z8.strictObject({
|
|
1263
|
-
id: z8.string().min(1).max(256),
|
|
1264
|
-
source: z8.string(),
|
|
1265
|
-
occurredAt: timestamp3,
|
|
1266
|
-
observedAt: timestamp3,
|
|
1267
|
-
firstSeenAt: timestamp3,
|
|
1268
|
-
author: z8.strictObject({
|
|
1269
|
-
id: z8.string().min(1).max(256),
|
|
1270
|
-
verified: z8.boolean().nullable(),
|
|
1271
|
-
kind: identityKindSchema.optional()
|
|
1272
|
-
}).nullable(),
|
|
1273
|
-
accounts: z8.record(accountRoleSchema, trackerAccountSchema).optional(),
|
|
1274
|
-
data: z8.record(z8.string(), z8.json()),
|
|
1275
|
-
removed: z8.boolean()
|
|
1276
|
-
});
|
|
1277
|
-
var trackerTriggerContextSchema = z8.strictObject({
|
|
1278
|
-
/** The tracker's stable ID. */
|
|
1279
|
-
tracker: identifier,
|
|
1280
|
-
/** The tracker's authoring key. */
|
|
1281
|
-
key: identifier,
|
|
1282
|
-
/**
|
|
1283
|
-
* The record account the attempt pays, as the quest's release names it. Releases published
|
|
1284
|
-
* before account roles name `inReplyTo` `"replied-to"`, which their bundled evaluators expect.
|
|
1285
|
-
*/
|
|
1286
|
-
beneficiary: z8.union([accountRoleSchema, z8.literal("replied-to")]),
|
|
1287
|
-
record: trackerTriggerRecordSchema,
|
|
1288
|
-
/** The captured X post of this observation; null for custom trackers. */
|
|
1289
|
-
x: z8.strictObject({
|
|
1290
|
-
evidence: trackerEvidenceSchema,
|
|
1291
|
-
content: xContentBodySchema
|
|
1292
|
-
}).nullable(),
|
|
1293
|
-
attribution: trackerAttributionSchema
|
|
1294
|
-
});
|
|
1295
|
-
|
|
1296
|
-
// src/observations.ts
|
|
1297
|
-
import { z as z9 } from "zod";
|
|
1298
|
-
var name = z9.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,199}$/);
|
|
1299
|
-
var observationInputSchema = z9.object({
|
|
1300
|
-
id: name,
|
|
1301
|
-
source: name,
|
|
1302
|
-
type: name,
|
|
1303
|
-
member: identifier,
|
|
1304
|
-
actor: z9.object({ provider: identifier, subject: z9.string().min(1).max(200) }).strict().optional(),
|
|
1305
|
-
occurredAt: z9.number().int().nonnegative().max(864e13),
|
|
1306
|
-
data: z9.record(z9.string(), z9.json())
|
|
1307
|
-
}).strict().refine(
|
|
1308
|
-
(value) => JSON.stringify(value.data).length <= 32768,
|
|
1309
|
-
"Observation data exceeds 32 KB"
|
|
1310
|
-
);
|
|
1311
|
-
var observationSchema = observationInputSchema.safeExtend({
|
|
1312
|
-
receivedAt: z9.number().int().nonnegative()
|
|
1313
|
-
});
|
|
1314
|
-
var observationTriggerSchema = z9.object({ source: name, type: name }).strict();
|
|
1315
|
-
var completionPolicySchema = z9.discriminatedUnion("kind", [
|
|
1316
|
-
streakPolicySchema,
|
|
1317
|
-
z9.object({ kind: z9.literal("once") }).strict(),
|
|
1318
|
-
z9.object({ kind: z9.literal("keyed") }).strict()
|
|
1319
|
-
]);
|
|
1320
|
-
var completionKeySchema = z9.string().min(1).max(500);
|
|
1321
|
-
var budgetSchema = z9.object({
|
|
1322
|
-
id: name,
|
|
1323
|
-
scope: z9.enum(["member", "project"]),
|
|
1324
|
-
/**
|
|
1325
|
-
* `"day"` buckets by UTC date and `"week"` by ISO week (UTC, weeks start on Monday), both of
|
|
1326
|
-
* the attempt's eligibility time; `"lifetime"` never resets.
|
|
1327
|
-
*/
|
|
1328
|
-
period: z9.enum(["lifetime", "day", "week"]),
|
|
1329
|
-
limit: z9.number().int().positive().max(Number.MAX_SAFE_INTEGER),
|
|
1330
|
-
cost: z9.union([
|
|
1331
|
-
z9.number().int().positive().max(Number.MAX_SAFE_INTEGER),
|
|
1332
|
-
z9.object({ balance: name }).strict()
|
|
1333
|
-
])
|
|
1334
|
-
}).strict();
|
|
1335
|
-
var observationReceiptSchema = z9.object({
|
|
1336
|
-
id: name,
|
|
1337
|
-
source: name,
|
|
1338
|
-
attempts: z9.array(z9.string()),
|
|
1339
|
-
receivedAt: z9.number()
|
|
1340
|
-
});
|
|
1341
|
-
var discordReactionSchema = z9.object({
|
|
1342
|
-
guildId: z9.string(),
|
|
1343
|
-
channelId: z9.string(),
|
|
1344
|
-
messageId: z9.string(),
|
|
1345
|
-
userId: z9.string(),
|
|
1346
|
-
messageAuthorId: z9.string().nullable().default(null),
|
|
1347
|
-
actorRoles: z9.array(z9.string()).default([]),
|
|
1348
|
-
emoji: z9.object({ id: z9.string().nullable(), name: z9.string() }),
|
|
1349
|
-
messagePublishedAt: z9.number()
|
|
1350
|
-
}).strict();
|
|
1351
|
-
var discordMessageSchema = z9.object({
|
|
1352
|
-
guildId: z9.string(),
|
|
1353
|
-
channelId: z9.string(),
|
|
1354
|
-
messageId: z9.string(),
|
|
1355
|
-
userId: z9.string(),
|
|
1356
|
-
content: z9.string().nullable(),
|
|
1357
|
-
replyTo: z9.string().nullable(),
|
|
1358
|
-
publishedAt: z9.number()
|
|
1359
|
-
}).strict();
|
|
1360
|
-
|
|
1361
|
-
// src/integrations.ts
|
|
1362
|
-
import { z as z10 } from "zod";
|
|
1363
|
-
var integrationProviderSchema = z10.enum(["discord"]);
|
|
1364
|
-
var discordServerSchema = z10.object({
|
|
1365
|
-
id: z10.string().regex(/^[0-9]{1,20}$/),
|
|
1366
|
-
name: z10.string().min(1),
|
|
1367
|
-
icon: z10.string().nullable()
|
|
1368
|
-
});
|
|
1369
|
-
var projectIntegrationSchema = z10.object({
|
|
1370
|
-
provider: integrationProviderSchema,
|
|
1371
|
-
configured: z10.boolean(),
|
|
1372
|
-
status: z10.enum(["disconnected", "ready", "attention"]),
|
|
1373
|
-
revision: z10.number().int().nonnegative(),
|
|
1374
|
-
server: discordServerSchema.nullable(),
|
|
1375
|
-
issue: z10.string().nullable(),
|
|
1376
|
-
connectedAt: z10.number().default(0)
|
|
1377
|
-
});
|
|
1378
|
-
|
|
1379
|
-
// src/submission-input.ts
|
|
1380
|
-
import { z as z11 } from "zod";
|
|
1381
|
-
var textOptionsSchema = z11.object({
|
|
1382
|
-
required: z11.boolean().default(true),
|
|
1383
|
-
minLength: z11.number().int().min(0).max(1e4).default(1),
|
|
1384
|
-
maxLength: z11.number().int().min(1).max(1e4).default(1e4)
|
|
1385
|
-
}).strict().refine(
|
|
1386
|
-
(v) => v.minLength <= v.maxLength,
|
|
1387
|
-
"minLength must not exceed maxLength"
|
|
1388
|
-
);
|
|
1389
|
-
var hostSchema = z11.string().min(1).max(253).refine((host) => {
|
|
1390
|
-
if (!/^[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?$/i.test(host) || host.includes("..")) {
|
|
1391
|
-
return false;
|
|
1392
|
-
}
|
|
1393
|
-
try {
|
|
1394
|
-
const url = new URL(`https://${host}`);
|
|
1395
|
-
return url.hostname === host.toLowerCase() && !url.port && !url.username && !url.password && url.pathname === "/" && !url.search && !url.hash;
|
|
1396
|
-
} catch {
|
|
1397
|
-
return false;
|
|
1398
|
-
}
|
|
1399
|
-
}, "Use a hostname without a scheme, path, port, or wildcard");
|
|
1400
|
-
var urlOptionsSchema = z11.object({
|
|
1401
|
-
required: z11.boolean().default(true),
|
|
1402
|
-
allowedHosts: z11.array(hostSchema).min(1).max(100).optional()
|
|
1403
|
-
}).strict();
|
|
1404
|
-
var textEvidenceSchema = z11.object({ kind: z11.literal("text"), value: z11.string().max(1e4) }).strict();
|
|
1405
|
-
var urlEvidenceSchema = z11.object({ kind: z11.literal("url"), value: z11.string().max(2048) }).strict();
|
|
1406
|
-
var valueEvidenceSchema = z11.discriminatedUnion("kind", [
|
|
1407
|
-
textEvidenceSchema,
|
|
1408
|
-
urlEvidenceSchema
|
|
1409
|
-
]);
|
|
1410
|
-
function validateSubmissionValue(input, contract) {
|
|
1411
|
-
const maximum = input.kind === "text" ? 1e4 : 2048;
|
|
1412
|
-
if (input.value.length > maximum) {
|
|
1413
|
-
return `Enter no more than ${maximum} characters`;
|
|
1414
|
-
}
|
|
1415
|
-
if (input.kind !== contract.input) {
|
|
1416
|
-
return `This quest requires ${contract.input} input`;
|
|
1417
|
-
}
|
|
1418
|
-
if (!input.value.trim()) {
|
|
1419
|
-
return contract.constraints.required ? "This field is required" : null;
|
|
1420
|
-
}
|
|
1421
|
-
if (contract.input === "text") {
|
|
1422
|
-
if (input.value.length < contract.constraints.minLength) {
|
|
1423
|
-
return `Enter at least ${contract.constraints.minLength} characters`;
|
|
1424
|
-
}
|
|
1425
|
-
if (input.value.length > contract.constraints.maxLength) {
|
|
1426
|
-
return `Enter no more than ${contract.constraints.maxLength} characters`;
|
|
1427
|
-
}
|
|
1428
|
-
return null;
|
|
1429
|
-
}
|
|
1430
|
-
const url = parseHttpUrl(input.value);
|
|
1431
|
-
if (!url) {
|
|
1432
|
-
return "Enter a valid HTTP or HTTPS URL without credentials";
|
|
1433
|
-
}
|
|
1434
|
-
if (contract.constraints.allowedHosts && !contract.constraints.allowedHosts.some(
|
|
1435
|
-
(host) => host.toLowerCase() === url.hostname.toLowerCase()
|
|
1436
|
-
)) {
|
|
1437
|
-
return `Use a URL hosted on: ${contract.constraints.allowedHosts.join(", ")}`;
|
|
1438
|
-
}
|
|
1439
|
-
return null;
|
|
1440
|
-
}
|
|
1441
|
-
function parseHttpUrl(value) {
|
|
1442
|
-
if (value !== value.trim() || /[\\\s]/.test(value) || !/^https?:\/\//i.test(value)) {
|
|
1443
|
-
return null;
|
|
1444
|
-
}
|
|
1445
|
-
try {
|
|
1446
|
-
const url = new URL(value);
|
|
1447
|
-
return ["http:", "https:"].includes(url.protocol) && !url.username && !url.password ? url : null;
|
|
1448
|
-
} catch {
|
|
1449
|
-
return null;
|
|
1450
|
-
}
|
|
1451
|
-
}
|
|
1452
|
-
function xPostId(value) {
|
|
1453
|
-
const url = parseHttpUrl(value);
|
|
1454
|
-
if (!url || url.port || ![
|
|
1455
|
-
"x.com",
|
|
1456
|
-
"www.x.com",
|
|
1457
|
-
"twitter.com",
|
|
1458
|
-
"www.twitter.com",
|
|
1459
|
-
"mobile.twitter.com"
|
|
1460
|
-
].includes(url.hostname)) {
|
|
1461
|
-
return null;
|
|
1462
|
-
}
|
|
1463
|
-
return /^\/(?:[A-Za-z0-9_]+|i\/web)\/status\/([0-9]{1,20})\/?$/.exec(
|
|
1464
|
-
url.pathname
|
|
1465
|
-
)?.[1] ?? null;
|
|
1466
|
-
}
|
|
1467
|
-
|
|
1468
|
-
// src/quiz.ts
|
|
1469
|
-
import { z as z12 } from "zod";
|
|
1470
|
-
var quizId = z12.string().regex(/^[a-zA-Z0-9_-]+$/).max(100);
|
|
1471
|
-
var quizChoiceSchema = z12.object({ id: quizId, label: z12.string().trim().min(1).max(500) }).strict();
|
|
1472
|
-
var quizQuestionSchema = z12.object({
|
|
1473
|
-
id: quizId,
|
|
1474
|
-
prompt: z12.string().trim().min(1).max(1e3),
|
|
1475
|
-
choices: z12.array(quizChoiceSchema).min(2).max(8).refine(
|
|
1476
|
-
(choices) => new Set(choices.map((choice) => choice.id)).size === choices.length,
|
|
1477
|
-
"Choice IDs must be unique"
|
|
1478
|
-
)
|
|
1479
|
-
}).strict();
|
|
1480
|
-
var quizQuestionsSchema = z12.array(quizQuestionSchema).min(1).max(20).refine(
|
|
1481
|
-
(questions) => new Set(questions.map((question) => question.id)).size === questions.length,
|
|
1482
|
-
"Question IDs must be unique"
|
|
1483
|
-
);
|
|
1484
|
-
var quizContentSchema = z12.array(
|
|
1485
|
-
quizQuestionSchema.extend({ correct: quizId }).refine(
|
|
1486
|
-
(question) => question.choices.some((choice) => choice.id === question.correct),
|
|
1487
|
-
"Choose a correct answer from the available choices"
|
|
1488
|
-
)
|
|
1489
|
-
).min(1).max(20).refine(
|
|
1490
|
-
(questions) => new Set(questions.map((question) => question.id)).size === questions.length,
|
|
1491
|
-
"Question IDs must be unique"
|
|
1492
|
-
);
|
|
1493
|
-
|
|
1494
|
-
// src/resources.ts
|
|
1495
|
-
import { z as z13 } from "zod";
|
|
1496
|
-
var channelSourceSchema = z13.object({
|
|
1497
|
-
provider: z13.literal("discord"),
|
|
1498
|
-
resource: z13.literal("channel"),
|
|
1499
|
-
types: z13.array(z13.enum(["text", "announcement"])).min(1)
|
|
1500
|
-
}).strict();
|
|
1501
|
-
var resourceSourceSchema = z13.union([
|
|
1502
|
-
z13.object({
|
|
1503
|
-
provider: z13.literal("domino"),
|
|
1504
|
-
resource: z13.literal("point-ledger")
|
|
1505
|
-
}).strict(),
|
|
1506
|
-
channelSourceSchema,
|
|
1507
|
-
z13.object({
|
|
1508
|
-
provider: z13.literal("discord"),
|
|
1509
|
-
resource: z13.literal("role"),
|
|
1510
|
-
assignable: z13.boolean().default(false)
|
|
1511
|
-
}).strict()
|
|
1512
|
-
]);
|
|
1513
|
-
var resourceRequestSchema = z13.object({
|
|
1514
|
-
source: resourceSourceSchema,
|
|
1515
|
-
query: z13.string().max(100).optional(),
|
|
1516
|
-
cursor: z13.string().regex(/^\d{1,6}$/).optional(),
|
|
1517
|
-
ids: z13.array(z13.string().min(1).max(100)).max(50).optional()
|
|
1518
|
-
}).strict();
|
|
1519
|
-
var resourceOptionsSchema = z13.object({
|
|
1520
|
-
revision: z13.number().int(),
|
|
1521
|
-
options: z13.array(
|
|
1522
|
-
z13.object({
|
|
1523
|
-
id: z13.string(),
|
|
1524
|
-
label: z13.string(),
|
|
1525
|
-
description: z13.string().optional(),
|
|
1526
|
-
group: z13.string().optional(),
|
|
1527
|
-
disabledReason: z13.string().optional()
|
|
1528
|
-
})
|
|
1529
|
-
),
|
|
1530
|
-
cursor: z13.string().nullable()
|
|
1531
|
-
});
|
|
1532
|
-
|
|
1533
|
-
// src/settings.ts
|
|
1534
|
-
import { z as z15 } from "zod";
|
|
1535
|
-
|
|
1536
|
-
// src/setting-values.ts
|
|
1537
|
-
import { z as z14 } from "zod";
|
|
1538
|
-
var settingInstant = z14.iso.datetime({ offset: true }).transform((value) => new Date(value).toISOString());
|
|
1539
|
-
var settingResourceId = z14.union([
|
|
1540
|
-
z14.literal(""),
|
|
1541
|
-
z14.string().regex(/^\S{1,200}$/)
|
|
1542
|
-
]);
|
|
1543
|
-
|
|
1544
|
-
// src/settings.ts
|
|
1545
|
-
var base = { label: z15.string().min(1), description: z15.string().optional() };
|
|
1546
|
-
var settingFieldSchema = z15.discriminatedUnion("kind", [
|
|
1547
|
-
z15.object({ ...base, kind: z15.literal("point-ledger"), default: identifier }).strict(),
|
|
1548
|
-
z15.object({ ...base, kind: z15.literal("datetime"), default: settingInstant }).strict(),
|
|
1549
|
-
z15.object({
|
|
1550
|
-
...base,
|
|
1551
|
-
kind: z15.literal("resource"),
|
|
1552
|
-
default: settingResourceId,
|
|
1553
|
-
source: resourceSourceSchema
|
|
1554
|
-
}).strict(),
|
|
1555
|
-
z15.object({ ...base, kind: z15.literal("quiz"), default: quizContentSchema }).strict(),
|
|
1556
|
-
z15.object({
|
|
1557
|
-
...base,
|
|
1558
|
-
kind: z15.literal("text"),
|
|
1559
|
-
default: z15.string(),
|
|
1560
|
-
minLength: z15.number().int().nonnegative(),
|
|
1561
|
-
maxLength: z15.number().int().positive(),
|
|
1562
|
-
multiline: z15.boolean()
|
|
1563
|
-
}).strict(),
|
|
1564
|
-
z15.object({
|
|
1565
|
-
...base,
|
|
1566
|
-
kind: z15.literal("integer"),
|
|
1567
|
-
default: z15.number().int(),
|
|
1568
|
-
min: z15.number().int(),
|
|
1569
|
-
max: z15.number().int()
|
|
1570
|
-
}).strict(),
|
|
1571
|
-
z15.object({ ...base, kind: z15.literal("boolean"), default: z15.boolean() }).strict(),
|
|
1572
|
-
z15.object({
|
|
1573
|
-
...base,
|
|
1574
|
-
kind: z15.literal("choice"),
|
|
1575
|
-
default: z15.string(),
|
|
1576
|
-
options: z15.array(z15.string().min(1)).min(1)
|
|
1577
|
-
}).strict()
|
|
1578
|
-
]);
|
|
1579
|
-
var settingsFieldsSchema = z15.record(
|
|
1580
|
-
z15.string().regex(/^[a-zA-Z][a-zA-Z0-9_]*$/),
|
|
1581
|
-
settingFieldSchema
|
|
1582
|
-
);
|
|
1583
|
-
var settingsValuesSchema = z15.record(
|
|
1584
|
-
z15.string(),
|
|
1585
|
-
z15.union([z15.string(), z15.number().finite(), z15.boolean(), quizContentSchema])
|
|
1586
|
-
);
|
|
1587
|
-
function parseSettings(fields, input) {
|
|
1588
|
-
const shape = {};
|
|
1589
|
-
for (const [key, field] of Object.entries(fields)) {
|
|
1590
|
-
switch (field.kind) {
|
|
1591
|
-
case "point-ledger":
|
|
1592
|
-
shape[key] = identifier.default(field.default);
|
|
1593
|
-
break;
|
|
1594
|
-
case "datetime":
|
|
1595
|
-
shape[key] = settingInstant.default(field.default);
|
|
1596
|
-
break;
|
|
1597
|
-
case "resource":
|
|
1598
|
-
shape[key] = settingResourceId.default(field.default);
|
|
1599
|
-
break;
|
|
1600
|
-
case "quiz":
|
|
1601
|
-
shape[key] = quizContentSchema.default(field.default);
|
|
1602
|
-
break;
|
|
1603
|
-
case "text":
|
|
1604
|
-
shape[key] = z15.string().min(field.minLength).max(field.maxLength).default(field.default);
|
|
1605
|
-
break;
|
|
1606
|
-
case "integer":
|
|
1607
|
-
shape[key] = z15.number().int().min(field.min).max(field.max).default(field.default);
|
|
1608
|
-
break;
|
|
1609
|
-
case "boolean":
|
|
1610
|
-
shape[key] = z15.boolean().default(field.default);
|
|
1611
|
-
break;
|
|
1612
|
-
case "choice":
|
|
1613
|
-
shape[key] = z15.enum(field.options).default(field.default);
|
|
1614
|
-
break;
|
|
1615
|
-
}
|
|
1616
|
-
}
|
|
1617
|
-
return settingsValuesSchema.parse(z15.object(shape).strict().parse(input));
|
|
1618
|
-
}
|
|
1619
|
-
function missingResourceSettings(fields, values) {
|
|
1620
|
-
return Object.entries(fields).filter(([key, field]) => field.kind === "resource" && !values[key]).map(([key]) => key);
|
|
1621
|
-
}
|
|
1622
|
-
function compatibleSettingKinds(previous, next) {
|
|
1623
|
-
return previous.kind === next.kind || previous.kind === "text" && (next.kind === "resource" || next.kind === "datetime" || next.kind === "point-ledger");
|
|
1624
|
-
}
|
|
1625
|
-
|
|
1626
|
-
// src/schema.ts
|
|
1627
|
-
import { z as z16 } from "zod";
|
|
1628
|
-
var pointsRewardSchema = z16.object({
|
|
1629
|
-
kind: z16.literal("points").default("points"),
|
|
1630
|
-
balance: identifier,
|
|
1631
|
-
amount: z16.number().int().min(0).max(1e4)
|
|
1632
|
-
}).strict();
|
|
1633
|
-
var tieredRewardDefinitionSchema = z16.object({
|
|
1634
|
-
id: identifier,
|
|
1635
|
-
title: z16.string().min(1).max(120),
|
|
1636
|
-
tiers: z16.array(
|
|
1637
|
-
z16.object({ id: identifier, title: z16.string().min(1).max(120) }).strict()
|
|
1638
|
-
).min(1).max(20).refine(
|
|
1639
|
-
(tiers) => new Set(tiers.map((t) => t.id)).size === tiers.length,
|
|
1640
|
-
"Tier IDs must be unique"
|
|
1641
|
-
),
|
|
1642
|
-
inventory: z16.object({ kind: z16.literal("untracked") }).strict(),
|
|
1643
|
-
fulfillment: z16.object({ kind: z16.literal("staff-handover") }).strict()
|
|
1644
|
-
}).strict();
|
|
1645
|
-
var tieredRewardReferenceSchema = z16.object({
|
|
1646
|
-
id: identifier,
|
|
1647
|
-
key: identifier.nullable()
|
|
1648
|
-
});
|
|
1649
|
-
var tierRewardSchema = z16.object({
|
|
1650
|
-
kind: z16.literal("tier"),
|
|
1651
|
-
reward: tieredRewardDefinitionSchema,
|
|
1652
|
-
tier: identifier
|
|
1653
|
-
}).strict().refine(
|
|
1654
|
-
(value) => value.reward.tiers.some((t) => t.id === value.tier),
|
|
1655
|
-
"Unknown reward tier"
|
|
1656
|
-
);
|
|
1657
|
-
var integrationRewardSchema = z16.object({
|
|
1658
|
-
kind: z16.literal("integration"),
|
|
1659
|
-
provider: z16.literal("discord"),
|
|
1660
|
-
action: z16.literal("grant-role"),
|
|
1661
|
-
roleId: z16.string().regex(/^[0-9]{1,20}$/)
|
|
1662
|
-
}).strict();
|
|
1663
|
-
var rewardSchema = z16.union([
|
|
1664
|
-
pointsRewardSchema,
|
|
1665
|
-
tierRewardSchema,
|
|
1666
|
-
integrationRewardSchema
|
|
1667
|
-
]);
|
|
1668
|
-
function rewardKey(reward) {
|
|
1669
|
-
if (reward.kind === "integration") {
|
|
1670
|
-
return `integration:${reward.provider}:${reward.action}:${reward.roleId}`;
|
|
1671
|
-
}
|
|
1672
|
-
return reward.kind === "points" ? "points:" + reward.balance : "tier:" + reward.reward.id;
|
|
1673
|
-
}
|
|
1674
|
-
var triggerSchema = z16.union([
|
|
1675
|
-
z16.object({
|
|
1676
|
-
kind: z16.literal("manual"),
|
|
1677
|
-
input: z16.literal("text"),
|
|
1678
|
-
constraints: textOptionsSchema,
|
|
1679
|
-
actor: z16.enum(["member", "staff"]).optional()
|
|
1680
|
-
}).strict(),
|
|
1681
|
-
z16.object({
|
|
1682
|
-
kind: z16.literal("manual"),
|
|
1683
|
-
input: z16.literal("url"),
|
|
1684
|
-
constraints: urlOptionsSchema,
|
|
1685
|
-
actor: z16.enum(["member", "staff"]).optional()
|
|
1686
|
-
}).strict(),
|
|
1687
|
-
z16.object({
|
|
1688
|
-
kind: z16.literal("manual"),
|
|
1689
|
-
input: z16.enum(["photo", "quiz", "none"]),
|
|
1690
|
-
actor: z16.enum(["member", "staff"]).optional()
|
|
1691
|
-
}).strict(),
|
|
1692
|
-
z16.object({
|
|
1693
|
-
kind: z16.literal("automatic"),
|
|
1694
|
-
observation: observationTriggerSchema.optional(),
|
|
1695
|
-
content: contentPolicySchema.optional(),
|
|
1696
|
-
tracker: trackerTriggerPolicySchema.optional()
|
|
1697
|
-
}).strict().refine(
|
|
1698
|
-
(value) => [value.observation, value.content, value.tracker].filter(Boolean).length <= 1,
|
|
1699
|
-
"Choose one automatic trigger source"
|
|
1700
|
-
)
|
|
1701
|
-
]);
|
|
1702
|
-
var prerequisiteSchema = z16.object({ quest: identifier });
|
|
1703
|
-
var photoResultSchema = z16.object({
|
|
1704
|
-
kind: z16.enum(["pass", "fail", "unclear"]),
|
|
1705
|
-
reason: z16.string().min(1).max(2e3)
|
|
1706
|
-
}).strict();
|
|
1707
|
-
var textReviewInputSchema = z16.object({
|
|
1708
|
-
text: z16.string().min(1).max(16e3).refine((value) => value.trim().length > 0, "Text must not be blank"),
|
|
1709
|
-
criteria: z16.string().trim().min(1).max(2e3)
|
|
1710
|
-
}).strict();
|
|
1711
|
-
var textResultSchema = photoResultSchema;
|
|
1712
|
-
var decisionSchema = z16.discriminatedUnion("kind", [
|
|
1713
|
-
z16.object({
|
|
1714
|
-
kind: z16.literal("accept"),
|
|
1715
|
-
rewards: z16.array(rewardSchema).max(10),
|
|
1716
|
-
completionKey: completionKeySchema.optional()
|
|
1717
|
-
}).strict(),
|
|
1718
|
-
z16.object({
|
|
1719
|
-
kind: z16.literal("reject"),
|
|
1720
|
-
reason: z16.string().min(1).max(2e3),
|
|
1721
|
-
/** The evaluator asked for human review, but review is off for the quest, so this is a reject. */
|
|
1722
|
-
requestedReview: z16.literal(true).optional()
|
|
1723
|
-
}).strict(),
|
|
1724
|
-
z16.object({
|
|
1725
|
-
kind: z16.literal("review"),
|
|
1726
|
-
reason: z16.string().min(1).max(2e3),
|
|
1727
|
-
rewards: z16.array(rewardSchema).max(10).optional(),
|
|
1728
|
-
completionKey: completionKeySchema.optional()
|
|
1729
|
-
}).strict()
|
|
1730
|
-
]);
|
|
1731
|
-
var reviewModeSchema = z16.enum(["workers-ai"]);
|
|
1732
|
-
var storedReviewModeSchema = z16.enum([
|
|
1733
|
-
"fixture-pass",
|
|
1734
|
-
"fixture-fail",
|
|
1735
|
-
"fixture-unclear",
|
|
1736
|
-
"fixture-error",
|
|
1737
|
-
"workers-ai"
|
|
1738
|
-
]);
|
|
1739
|
-
var rewardBundleSchema = z16.array(rewardSchema).max(10).refine(
|
|
1740
|
-
(rewards) => new Set(rewards.map(rewardKey)).size === rewards.length,
|
|
1741
|
-
"Use one entry per balance or shared reward"
|
|
1742
|
-
);
|
|
1743
|
-
var mediaUrlSchema = z16.string().max(2e3).refine((value) => {
|
|
1744
|
-
if (/^\/(?!\/)[^\\\s]*$/.test(value)) {
|
|
1745
|
-
return true;
|
|
1746
|
-
}
|
|
1747
|
-
try {
|
|
1748
|
-
return new URL(value).protocol === "https:";
|
|
1749
|
-
} catch {
|
|
1750
|
-
return false;
|
|
1751
|
-
}
|
|
1752
|
-
}, "Use an HTTPS URL or a same-site path beginning with /");
|
|
1753
|
-
var questPresentationSchema = z16.object({
|
|
1754
|
-
quiz: quizQuestionsSchema.optional(),
|
|
1755
|
-
instructions: z16.string().max(4e3).optional(),
|
|
1756
|
-
video: z16.object({
|
|
1757
|
-
url: mediaUrlSchema,
|
|
1758
|
-
poster: mediaUrlSchema.optional(),
|
|
1759
|
-
captions: z16.object({
|
|
1760
|
-
url: mediaUrlSchema,
|
|
1761
|
-
language: z16.string().min(2).max(20),
|
|
1762
|
-
label: z16.string().min(1).max(80)
|
|
1763
|
-
}).strict().optional()
|
|
1764
|
-
}).strict().optional()
|
|
1765
|
-
}).strict();
|
|
1766
|
-
var questProfileSchema = z16.object({ visible: z16.boolean() }).strict();
|
|
1767
|
-
var questDescriptionSchema = z16.object({
|
|
1768
|
-
quest: identifier,
|
|
1769
|
-
runtimeVersion: z16.union([z16.literal(1), z16.literal(2)]).default(1),
|
|
1770
|
-
title: z16.string().min(1).max(120),
|
|
1771
|
-
presentation: questPresentationSchema.default({}),
|
|
1772
|
-
integrations: z16.array(integrationProviderSchema).max(10).default([]),
|
|
1773
|
-
fields: settingsFieldsSchema,
|
|
1774
|
-
values: settingsValuesSchema,
|
|
1775
|
-
rewards: rewardBundleSchema,
|
|
1776
|
-
humanReview: z16.boolean(),
|
|
1777
|
-
trigger: triggerSchema,
|
|
1778
|
-
performance: contentPerformancePolicySchema.optional(),
|
|
1779
|
-
requires: z16.array(prerequisiteSchema).max(30).default([]),
|
|
1780
|
-
completion: completionPolicySchema,
|
|
1781
|
-
visibility: z16.enum(["visible", "hidden"]).default("visible"),
|
|
1782
|
-
/**
|
|
1783
|
-
* Whether completions show on participant profiles (`/v1/profiles/:id/completions`). Absent
|
|
1784
|
-
* is hidden. Optional, not defaulted: releases carry the key only when the author sets it, so
|
|
1785
|
-
* clients and pods that predate it (strict release schemas) still read every other release.
|
|
1786
|
-
*/
|
|
1787
|
-
profile: questProfileSchema.optional(),
|
|
1788
|
-
budgets: z16.array(budgetSchema).max(20).default([])
|
|
1789
|
-
}).strict();
|
|
1790
|
-
var artifactSchema = z16.object({ code: z16.string().min(1).max(1e6) }).strict();
|
|
1791
|
-
var releaseSchema = artifactSchema.extend({
|
|
1792
|
-
settings: settingsValuesSchema,
|
|
1793
|
-
provider: reviewModeSchema,
|
|
1794
|
-
expectedRelease: identifier.nullable().optional(),
|
|
1795
|
-
settingRenames: z16.record(z16.string(), z16.string()).optional()
|
|
1796
|
-
}).strict();
|
|
1797
|
-
var batchReleaseSchema = z16.object({ releases: z16.array(releaseSchema).min(1).max(50) }).strict();
|
|
1798
|
-
var questSettingsInputSchema = z16.object({
|
|
1799
|
-
quest: identifier,
|
|
1800
|
-
expectedRelease: identifier,
|
|
1801
|
-
set: settingsValuesSchema,
|
|
1802
|
-
reset: z16.array(z16.string())
|
|
1803
|
-
}).strict();
|
|
1804
|
-
var storedReleaseSchema = questDescriptionSchema.extend({
|
|
1805
|
-
key: identifier.optional(),
|
|
1806
|
-
code: z16.string(),
|
|
1807
|
-
provider: storedReviewModeSchema,
|
|
1808
|
-
id: identifier,
|
|
1809
|
-
createdAt: z16.number(),
|
|
1810
|
-
legacy: z16.boolean().default(false),
|
|
1811
|
-
origin: z16.object({ typeVersion: identifier }).strict().optional(),
|
|
1812
|
-
lifecycle: z16.enum(["active", "paused", "archived"]).default("active"),
|
|
1813
|
-
configuration: z16.object({
|
|
1814
|
-
defaults: settingsValuesSchema,
|
|
1815
|
-
overrides: settingsValuesSchema,
|
|
1816
|
-
preserved: z16.array(z16.string())
|
|
1817
|
-
}).strict().optional()
|
|
1818
|
-
});
|
|
1819
|
-
var legacyReleaseSchema = z16.object({
|
|
1820
|
-
quest: identifier,
|
|
1821
|
-
title: z16.string(),
|
|
1822
|
-
criteria: z16.string(),
|
|
1823
|
-
humanReview: z16.boolean(),
|
|
1824
|
-
rewards: rewardBundleSchema,
|
|
1825
|
-
code: z16.string(),
|
|
1826
|
-
provider: storedReviewModeSchema,
|
|
1827
|
-
id: identifier,
|
|
1828
|
-
createdAt: z16.number()
|
|
1829
|
-
}).transform((r) => {
|
|
1830
|
-
const { criteria, ...stored } = r;
|
|
1831
|
-
return storedReleaseSchema.parse({
|
|
1832
|
-
...stored,
|
|
1833
|
-
fields: {},
|
|
1834
|
-
values: { criteria, humanReview: r.humanReview },
|
|
1835
|
-
trigger: { kind: "manual", input: "photo" },
|
|
1836
|
-
completion: { kind: "once" },
|
|
1837
|
-
legacy: true
|
|
1838
|
-
});
|
|
1839
|
-
});
|
|
1840
|
-
var publishedReleaseSchema = z16.union([
|
|
1841
|
-
storedReleaseSchema,
|
|
1842
|
-
legacyReleaseSchema
|
|
1843
|
-
]);
|
|
1844
|
-
var templateSchema = z16.object({
|
|
1845
|
-
code: z16.string(),
|
|
1846
|
-
definition: questDescriptionSchema
|
|
1847
|
-
});
|
|
1848
|
-
var quizAnswersSchema = z16.record(identifier, identifier).refine(
|
|
1849
|
-
(answers) => Object.keys(answers).length > 0 && Object.keys(answers).length <= 50,
|
|
1850
|
-
"Provide between 1 and 50 answers"
|
|
1851
|
-
).transform(
|
|
1852
|
-
(answers) => Object.fromEntries(
|
|
1853
|
-
Object.entries(answers).sort(([a], [b]) => a.localeCompare(b))
|
|
1854
|
-
)
|
|
1855
|
-
);
|
|
1856
|
-
var quizEvidenceSchema = z16.object({
|
|
1857
|
-
kind: z16.literal("quiz"),
|
|
1858
|
-
release: identifier.optional(),
|
|
1859
|
-
answers: quizAnswersSchema
|
|
1860
|
-
}).strict();
|
|
1861
|
-
var submissionEvidenceSchema = z16.union([
|
|
1862
|
-
quizEvidenceSchema,
|
|
1863
|
-
textEvidenceSchema,
|
|
1864
|
-
urlEvidenceSchema
|
|
1865
|
-
]);
|
|
1866
|
-
var submitSchema = z16.object({
|
|
1867
|
-
actionId: identifier,
|
|
1868
|
-
quest: identifier,
|
|
1869
|
-
member: identifier,
|
|
1870
|
-
evidence: identifier.optional(),
|
|
1871
|
-
input: submissionEvidenceSchema.optional(),
|
|
1872
|
-
release: identifier.optional(),
|
|
1873
|
-
faultAfterReview: z16.boolean().optional()
|
|
1874
|
-
}).strict();
|
|
1875
|
-
var attemptSchema = z16.object({
|
|
1876
|
-
id: identifier,
|
|
1877
|
-
release: identifier,
|
|
1878
|
-
quest: identifier,
|
|
1879
|
-
member: identifier,
|
|
1880
|
-
evidence: identifier.nullable(),
|
|
1881
|
-
input: submissionEvidenceSchema.optional(),
|
|
1882
|
-
status: z16.enum([
|
|
1883
|
-
"queued",
|
|
1884
|
-
"evaluating",
|
|
1885
|
-
"accepted",
|
|
1886
|
-
"progressed",
|
|
1887
|
-
"rejected",
|
|
1888
|
-
"needs-review",
|
|
1889
|
-
"failed"
|
|
1890
|
-
]),
|
|
1891
|
-
reason: z16.string().nullable(),
|
|
1892
|
-
retries: z16.number(),
|
|
1893
|
-
generation: z16.number(),
|
|
1894
|
-
completion: z16.string().nullable(),
|
|
1895
|
-
reviewRewards: rewardBundleSchema.nullable().default(null),
|
|
1896
|
-
/**
|
|
1897
|
-
* The evaluator asked for human review of a quest with review off, so Domino rejected the attempt
|
|
1898
|
-
* with the evaluator's reason. Only set on a rejected attempt.
|
|
1899
|
-
*/
|
|
1900
|
-
requestedReview: z16.boolean().default(false),
|
|
1901
|
-
createdAt: z16.number()
|
|
1902
|
-
});
|
|
1903
|
-
var eventSchema = z16.object({
|
|
1904
|
-
id: z16.number(),
|
|
1905
|
-
attempt: z16.string().nullable(),
|
|
1906
|
-
kind: z16.string(),
|
|
1907
|
-
detail: z16.string(),
|
|
1908
|
-
actor: z16.string().nullable().default(null),
|
|
1909
|
-
at: z16.number()
|
|
1910
|
-
});
|
|
1911
|
-
var pickupSelectionSchema = z16.object({
|
|
1912
|
-
item: identifier,
|
|
1913
|
-
revision: z16.number().int().nonnegative()
|
|
1914
|
-
}).strict();
|
|
1915
|
-
var pickupAllocationSchema = z16.object({
|
|
1916
|
-
item: identifier,
|
|
1917
|
-
label: z16.string().min(1).max(80)
|
|
1918
|
-
}).strict();
|
|
1919
|
-
var pickupPolicySchema = z16.discriminatedUnion("kind", [
|
|
1920
|
-
z16.object({ kind: z16.literal("untracked") }).strict(),
|
|
1921
|
-
z16.object({
|
|
1922
|
-
kind: z16.literal("at-pickup"),
|
|
1923
|
-
tiers: z16.array(
|
|
1924
|
-
z16.object({
|
|
1925
|
-
tier: identifier,
|
|
1926
|
-
variants: z16.array(pickupAllocationSchema).min(1).max(100)
|
|
1927
|
-
}).strict()
|
|
1928
|
-
).min(1).max(100)
|
|
1929
|
-
}).strict()
|
|
1930
|
-
]);
|
|
1931
|
-
var pickupCatalogSchema = z16.object({
|
|
1932
|
-
reward: tieredRewardDefinitionSchema,
|
|
1933
|
-
revision: z16.number().int().nonnegative(),
|
|
1934
|
-
policy: pickupPolicySchema
|
|
1935
|
-
});
|
|
1936
|
-
var pickupAvailabilitySchema = z16.discriminatedUnion("kind", [
|
|
1937
|
-
z16.object({ kind: z16.literal("untracked") }).strict(),
|
|
1938
|
-
z16.object({
|
|
1939
|
-
kind: z16.literal("at-pickup"),
|
|
1940
|
-
revision: z16.number().int().nonnegative(),
|
|
1941
|
-
variants: z16.array(
|
|
1942
|
-
pickupAllocationSchema.extend({
|
|
1943
|
-
available: z16.number().int().nonnegative()
|
|
1944
|
-
})
|
|
1945
|
-
)
|
|
1946
|
-
}).strict()
|
|
1947
|
-
]);
|
|
1948
|
-
var configurePickupSchema = z16.object({
|
|
1949
|
-
reward: identifier,
|
|
1950
|
-
revision: z16.number().int().nonnegative(),
|
|
1951
|
-
actionId: identifier,
|
|
1952
|
-
policy: z16.discriminatedUnion("kind", [
|
|
1953
|
-
z16.object({ kind: z16.literal("untracked") }).strict(),
|
|
1954
|
-
z16.object({
|
|
1955
|
-
kind: z16.literal("at-pickup"),
|
|
1956
|
-
tiers: z16.array(
|
|
1957
|
-
z16.object({
|
|
1958
|
-
tier: identifier,
|
|
1959
|
-
variants: z16.array(
|
|
1960
|
-
pickupAllocationSchema.extend({
|
|
1961
|
-
item: identifier.optional()
|
|
1962
|
-
})
|
|
1963
|
-
).min(1).max(100)
|
|
1964
|
-
}).strict()
|
|
1965
|
-
).min(1).max(100)
|
|
1966
|
-
}).strict()
|
|
1967
|
-
])
|
|
1968
|
-
}).strict();
|
|
1969
|
-
var entitlementBase = {
|
|
1970
|
-
id: identifier,
|
|
1971
|
-
member: identifier,
|
|
1972
|
-
reward: tieredRewardDefinitionSchema,
|
|
1973
|
-
earnedTier: identifier,
|
|
1974
|
-
tier: identifier,
|
|
1975
|
-
revision: z16.number().int().positive()
|
|
1976
|
-
};
|
|
1977
|
-
var entitlementSchema = z16.discriminatedUnion("status", [
|
|
1978
|
-
z16.object({ ...entitlementBase, status: z16.literal("available") }).strict(),
|
|
1979
|
-
z16.object({
|
|
1980
|
-
...entitlementBase,
|
|
1981
|
-
status: z16.literal("handing-over"),
|
|
1982
|
-
handover: identifier,
|
|
1983
|
-
startedAt: z16.number(),
|
|
1984
|
-
allocation: pickupAllocationSchema.optional()
|
|
1985
|
-
}).strict(),
|
|
1986
|
-
z16.object({
|
|
1987
|
-
...entitlementBase,
|
|
1988
|
-
status: z16.literal("collected"),
|
|
1989
|
-
handover: identifier,
|
|
1990
|
-
startedAt: z16.number(),
|
|
1991
|
-
allocation: pickupAllocationSchema.optional(),
|
|
1992
|
-
collectedAt: z16.number()
|
|
1993
|
-
}).strict()
|
|
1994
|
-
]);
|
|
1995
|
-
var beginHandoverSchema = z16.object({
|
|
1996
|
-
actionId: identifier,
|
|
1997
|
-
revision: z16.number().int().positive(),
|
|
1998
|
-
selection: pickupSelectionSchema.optional()
|
|
1999
|
-
}).strict();
|
|
2000
|
-
var confirmHandoverSchema = z16.object({ actionId: identifier, handover: identifier }).strict();
|
|
2001
|
-
var completionRecordSchema = z16.object({
|
|
2002
|
-
key: z16.string().default("once"),
|
|
2003
|
-
id: identifier,
|
|
2004
|
-
quest: identifier,
|
|
2005
|
-
member: identifier
|
|
2006
|
-
});
|
|
2007
|
-
var questAvailabilitySchema = z16.discriminatedUnion("kind", [
|
|
2008
|
-
z16.object({
|
|
2009
|
-
kind: z16.literal("available"),
|
|
2010
|
-
input: z16.enum(["photo", "quiz", "none", "text", "url"])
|
|
2011
|
-
}).strict(),
|
|
2012
|
-
z16.object({ kind: z16.literal("completed") }).strict(),
|
|
2013
|
-
z16.object({
|
|
2014
|
-
kind: z16.literal("locked"),
|
|
2015
|
-
missing: z16.array(z16.object({ quest: identifier, title: z16.string() })).min(1)
|
|
2016
|
-
}).strict(),
|
|
2017
|
-
z16.object({ kind: z16.literal("staff-required") }).strict(),
|
|
2018
|
-
z16.object({
|
|
2019
|
-
kind: z16.literal("automatic"),
|
|
2020
|
-
observation: observationTriggerSchema.optional()
|
|
2021
|
-
}).strict(),
|
|
2022
|
-
z16.object({ kind: z16.literal("checking"), attempt: identifier }).strict(),
|
|
2023
|
-
z16.object({ kind: z16.literal("needs-review"), attempt: identifier }).strict(),
|
|
2024
|
-
z16.object({ kind: z16.literal("retryable"), attempt: identifier }).strict()
|
|
2025
|
-
]);
|
|
2026
|
-
var memberProgressSchema = z16.object({
|
|
2027
|
-
member: identifier,
|
|
2028
|
-
quests: z16.array(
|
|
2029
|
-
z16.object({
|
|
2030
|
-
quest: identifier,
|
|
2031
|
-
key: identifier.optional(),
|
|
2032
|
-
release: identifier.optional(),
|
|
2033
|
-
title: z16.string(),
|
|
2034
|
-
presentation: questPresentationSchema.default({}),
|
|
2035
|
-
connections: z16.array(authProviderSchema).default([]),
|
|
2036
|
-
trigger: triggerSchema,
|
|
2037
|
-
availability: questAvailabilitySchema,
|
|
2038
|
-
completed: z16.boolean(),
|
|
2039
|
-
completion: completionPolicySchema.default({ kind: "once" }),
|
|
2040
|
-
streak: streakProgressSchema.nullable().optional(),
|
|
2041
|
-
completionCount: z16.number().int().nonnegative().default(0),
|
|
2042
|
-
visibility: z16.enum(["visible", "hidden"]).default("visible"),
|
|
2043
|
-
missing: z16.array(z16.object({ quest: identifier, title: z16.string() })),
|
|
2044
|
-
attempt: attemptSchema.nullable()
|
|
2045
|
-
})
|
|
2046
|
-
),
|
|
2047
|
-
entitlements: z16.array(entitlementSchema)
|
|
2048
|
-
});
|
|
2049
|
-
var snapshotSchema = z16.object({
|
|
2050
|
-
releases: z16.array(publishedReleaseSchema),
|
|
2051
|
-
completions: z16.array(completionRecordSchema),
|
|
2052
|
-
entitlements: z16.array(entitlementSchema),
|
|
2053
|
-
attempts: z16.array(attemptSchema),
|
|
2054
|
-
balances: z16.array(
|
|
2055
|
-
z16.object({
|
|
2056
|
-
member: z16.string(),
|
|
2057
|
-
balance: z16.string(),
|
|
2058
|
-
earned: z16.number(),
|
|
2059
|
-
held: z16.number(),
|
|
2060
|
-
available: z16.number()
|
|
2061
|
-
})
|
|
2062
|
-
),
|
|
2063
|
-
events: z16.array(eventSchema)
|
|
2064
|
-
});
|
|
2065
|
-
var evidenceSchema = z16.object({
|
|
2066
|
-
id: identifier,
|
|
2067
|
-
member: identifier,
|
|
2068
|
-
type: z16.enum(["image/jpeg", "image/png"]),
|
|
2069
|
-
size: z16.number()
|
|
2070
|
-
});
|
|
2071
|
-
var errorSchema = z16.object({
|
|
2072
|
-
error: z16.string(),
|
|
2073
|
-
code: z16.string().optional(),
|
|
2074
|
-
missing: z16.array(z16.object({ quest: identifier, title: z16.string() })).optional()
|
|
2075
|
-
});
|
|
2076
|
-
var staffDecisionSchema = z16.object({
|
|
2077
|
-
actionId: identifier,
|
|
2078
|
-
generation: z16.number().int().nonnegative(),
|
|
2079
|
-
decision: z16.enum(["accept", "reject"]),
|
|
2080
|
-
reason: z16.string().trim().min(1).max(2e3)
|
|
2081
|
-
}).strict();
|
|
2082
|
-
var stockSchema = z16.object({ item: identifier, quantity: z16.number().int().min(0).max(1e4) }).strict();
|
|
2083
|
-
var reservationSchema = z16.object({
|
|
2084
|
-
actionId: identifier,
|
|
2085
|
-
member: identifier,
|
|
2086
|
-
item: identifier,
|
|
2087
|
-
balance: identifier,
|
|
2088
|
-
price: z16.number().int().positive().max(1e4)
|
|
2089
|
-
}).strict();
|
|
2090
|
-
var pageOptions = {
|
|
2091
|
-
limit: z16.number().int().min(1).max(100).default(25),
|
|
2092
|
-
cursor: z16.string().min(1).max(4096).optional()
|
|
2093
|
-
};
|
|
2094
|
-
var reviewListSchema = z16.object({
|
|
2095
|
-
...pageOptions,
|
|
2096
|
-
member: identifier.optional(),
|
|
2097
|
-
quest: identifier.optional()
|
|
2098
|
-
}).strict();
|
|
2099
|
-
var memberListSchema = z16.object({
|
|
2100
|
-
...pageOptions,
|
|
2101
|
-
prefix: identifier.optional()
|
|
2102
|
-
}).strict();
|
|
2103
|
-
var reviewItemSchema = z16.object({
|
|
2104
|
-
attempt: attemptSchema,
|
|
2105
|
-
title: z16.string(),
|
|
2106
|
-
checks: z16.array(
|
|
2107
|
-
z16.object({ criteria: z16.string(), result: photoResultSchema })
|
|
2108
|
-
)
|
|
2109
|
-
});
|
|
2110
|
-
var reviewPageSchema = z16.object({
|
|
2111
|
-
items: z16.array(reviewItemSchema).max(100),
|
|
2112
|
-
nextCursor: z16.string().nullable()
|
|
2113
|
-
});
|
|
2114
|
-
var memberPageSchema = z16.object({
|
|
2115
|
-
items: z16.array(z16.object({ member: identifier })).max(100),
|
|
2116
|
-
nextCursor: z16.string().nullable()
|
|
2117
|
-
});
|
|
2118
|
-
var createStockItemSchema = z16.object({ actionId: identifier, name: z16.string().trim().min(1).max(80) }).strict();
|
|
2119
|
-
var stockItemSchema = z16.object({ id: identifier, name: z16.string() });
|
|
2120
|
-
var contentPerformanceSnapshotSchema = z16.strictObject({
|
|
2121
|
-
contentAttempt: identifier,
|
|
2122
|
-
observation: identifier,
|
|
2123
|
-
observedAt: z16.number().int().safe().nonnegative(),
|
|
2124
|
-
metrics: contentMetricsSchema,
|
|
2125
|
-
rewards: rewardBundleSchema
|
|
2126
|
-
});
|
|
2127
|
-
var contentPerformanceQuerySchema = contentQualificationQuerySchema.extend({
|
|
2128
|
-
content: z16.string().min(1).max(256)
|
|
2129
|
-
});
|
|
2130
|
-
var contentPerformancePageSchema = z16.strictObject({
|
|
2131
|
-
current: z16.strictObject({
|
|
2132
|
-
state: z16.enum([
|
|
2133
|
-
"content-pending",
|
|
2134
|
-
"content-unqualified",
|
|
2135
|
-
"waiting",
|
|
2136
|
-
"pending",
|
|
2137
|
-
"qualified",
|
|
2138
|
-
"unqualified",
|
|
2139
|
-
"needs-review",
|
|
2140
|
-
"failed",
|
|
2141
|
-
"superseded"
|
|
2142
|
-
]),
|
|
2143
|
-
reason: z16.string().nullable(),
|
|
2144
|
-
contentAttempt: identifier,
|
|
2145
|
-
attempt: identifier.nullable(),
|
|
2146
|
-
reward: contentQualificationSchema.shape.reward
|
|
2147
|
-
}),
|
|
2148
|
-
items: z16.array(
|
|
2149
|
-
z16.strictObject({
|
|
2150
|
-
attempt: identifier,
|
|
2151
|
-
contentAttempt: identifier,
|
|
2152
|
-
observation: identifier,
|
|
2153
|
-
observedAt: z16.number(),
|
|
2154
|
-
metrics: contentMetricsSchema,
|
|
2155
|
-
state: z16.enum([
|
|
2156
|
-
"pending",
|
|
2157
|
-
"qualified",
|
|
2158
|
-
"unqualified",
|
|
2159
|
-
"needs-review",
|
|
2160
|
-
"failed",
|
|
2161
|
-
"superseded"
|
|
2162
|
-
]),
|
|
2163
|
-
reason: z16.string().nullable()
|
|
2164
|
-
})
|
|
2165
|
-
),
|
|
2166
|
-
nextCursor: pageCursorSchema.nullable()
|
|
2167
|
-
});
|
|
2168
|
-
|
|
2169
|
-
export {
|
|
2170
|
-
authProviderSchema,
|
|
2171
|
-
accountConnectionSchema,
|
|
2172
|
-
discordMemberInputSchema,
|
|
2173
|
-
discordMessageInputSchema,
|
|
2174
|
-
discordMemberSchema,
|
|
2175
|
-
identifier,
|
|
2176
|
-
pageCursorSchema,
|
|
2177
|
-
pageQuerySchema,
|
|
2178
|
-
trackerDataMaxBranches,
|
|
2179
|
-
trackerDataMaxEntries,
|
|
2180
|
-
trackerDataSchemaSchema,
|
|
2181
|
-
trackerDataSchema,
|
|
2182
|
-
trackerDataRecordSteps,
|
|
2183
|
-
trackerDataBatchSteps,
|
|
2184
|
-
trackerDataIssue,
|
|
2185
|
-
trackerDataIssues,
|
|
2186
|
-
trackerDataPathTypes,
|
|
2187
|
-
schemaCheckedReader,
|
|
2188
|
-
whereSchemaIssue,
|
|
2189
|
-
xTweetSchema,
|
|
2190
|
-
xContentBodySchema,
|
|
2191
|
-
trackerContentQuerySchema,
|
|
2192
|
-
trackerContentReadSchema,
|
|
2193
|
-
trackerEvidenceSchema,
|
|
2194
|
-
trackerContentSchema,
|
|
2195
|
-
identityKindSchema,
|
|
2196
|
-
accountRoleSchema,
|
|
2197
|
-
xAccountRoles,
|
|
2198
|
-
xSearchSourceSchema,
|
|
2199
|
-
customSourceSchema,
|
|
2200
|
-
trackerSourceSchema,
|
|
2201
|
-
sourceIdentities,
|
|
2202
|
-
trackerDefinitionSchema,
|
|
2203
|
-
trackerArtifactSchema,
|
|
2204
|
-
publishedTrackerSchema,
|
|
2205
|
-
trackerStatusSchema,
|
|
2206
|
-
trackerControlSchema,
|
|
2207
|
-
trackerAccountSchema,
|
|
2208
|
-
trackerRecordInputSchema,
|
|
2209
|
-
trackerRecordSchema,
|
|
2210
|
-
trackerIngestSchema,
|
|
2211
|
-
trackerIngestResultSchema,
|
|
2212
|
-
trackerSkipCodes,
|
|
2213
|
-
trackerOutcomeSchema,
|
|
2214
|
-
trackerOutcomeQuerySchema,
|
|
2215
|
-
trackerOutcomePageSchema,
|
|
2216
|
-
trackerOutcomeRetrySchema,
|
|
2217
|
-
trackerQuerySchema,
|
|
2218
|
-
trackerPageSchema,
|
|
2219
|
-
trackerSummarySchema,
|
|
2220
|
-
trackerPreviewLimits,
|
|
2221
|
-
trackerPreviewInputSchema,
|
|
2222
|
-
trackerPreviewSchema,
|
|
2223
|
-
contentPolicySchema,
|
|
2224
|
-
admittedContentSchema,
|
|
2225
|
-
contentEnrollmentInputSchema,
|
|
2226
|
-
contentEnrollmentSchema,
|
|
2227
|
-
contentReleaseInputSchema,
|
|
2228
|
-
contentAdmissionSchema,
|
|
2229
|
-
contentAdmissionQuerySchema,
|
|
2230
|
-
contentAdmissionPageSchema,
|
|
2231
|
-
contentQualificationDecisionSchema,
|
|
2232
|
-
contentQualificationQuerySchema,
|
|
2233
|
-
contentQualificationSchema,
|
|
2234
|
-
contentQualificationPageSchema,
|
|
2235
|
-
contentMetricSchema,
|
|
2236
|
-
contentMetricsSchema,
|
|
2237
|
-
contentPerformancePolicySchema,
|
|
2238
|
-
communityTimeZoneSchema,
|
|
2239
|
-
streakPolicySchema,
|
|
2240
|
-
streakProgressSchema,
|
|
2241
|
-
trackerTriggerModeSchema,
|
|
2242
|
-
defaultTriggerMode,
|
|
2243
|
-
trackerBoundSchema,
|
|
2244
|
-
trackerConditionSchema,
|
|
2245
|
-
trackerWhereSchema,
|
|
2246
|
-
whereConditions,
|
|
2247
|
-
whereSettings,
|
|
2248
|
-
trackerTriggerPolicySchema,
|
|
2249
|
-
triggerMode,
|
|
2250
|
-
beneficiaryRole,
|
|
2251
|
-
trackerAttributionSchema,
|
|
2252
|
-
trackerTriggerRecordSchema,
|
|
2253
|
-
trackerTriggerContextSchema,
|
|
2254
|
-
observationInputSchema,
|
|
2255
|
-
observationSchema,
|
|
2256
|
-
observationTriggerSchema,
|
|
2257
|
-
completionPolicySchema,
|
|
2258
|
-
completionKeySchema,
|
|
2259
|
-
budgetSchema,
|
|
2260
|
-
observationReceiptSchema,
|
|
2261
|
-
discordReactionSchema,
|
|
2262
|
-
discordMessageSchema,
|
|
2263
|
-
integrationProviderSchema,
|
|
2264
|
-
discordServerSchema,
|
|
2265
|
-
projectIntegrationSchema,
|
|
2266
|
-
textOptionsSchema,
|
|
2267
|
-
urlOptionsSchema,
|
|
2268
|
-
textEvidenceSchema,
|
|
2269
|
-
urlEvidenceSchema,
|
|
2270
|
-
valueEvidenceSchema,
|
|
2271
|
-
validateSubmissionValue,
|
|
2272
|
-
xPostId,
|
|
2273
|
-
quizChoiceSchema,
|
|
2274
|
-
quizQuestionSchema,
|
|
2275
|
-
quizQuestionsSchema,
|
|
2276
|
-
quizContentSchema,
|
|
2277
|
-
resourceSourceSchema,
|
|
2278
|
-
resourceRequestSchema,
|
|
2279
|
-
resourceOptionsSchema,
|
|
2280
|
-
settingInstant,
|
|
2281
|
-
settingResourceId,
|
|
2282
|
-
settingFieldSchema,
|
|
2283
|
-
settingsFieldsSchema,
|
|
2284
|
-
settingsValuesSchema,
|
|
2285
|
-
parseSettings,
|
|
2286
|
-
missingResourceSettings,
|
|
2287
|
-
compatibleSettingKinds,
|
|
2288
|
-
pointsRewardSchema,
|
|
2289
|
-
tieredRewardDefinitionSchema,
|
|
2290
|
-
tieredRewardReferenceSchema,
|
|
2291
|
-
tierRewardSchema,
|
|
2292
|
-
integrationRewardSchema,
|
|
2293
|
-
rewardSchema,
|
|
2294
|
-
rewardKey,
|
|
2295
|
-
triggerSchema,
|
|
2296
|
-
prerequisiteSchema,
|
|
2297
|
-
photoResultSchema,
|
|
2298
|
-
textReviewInputSchema,
|
|
2299
|
-
textResultSchema,
|
|
2300
|
-
decisionSchema,
|
|
2301
|
-
reviewModeSchema,
|
|
2302
|
-
storedReviewModeSchema,
|
|
2303
|
-
rewardBundleSchema,
|
|
2304
|
-
mediaUrlSchema,
|
|
2305
|
-
questPresentationSchema,
|
|
2306
|
-
questProfileSchema,
|
|
2307
|
-
questDescriptionSchema,
|
|
2308
|
-
artifactSchema,
|
|
2309
|
-
releaseSchema,
|
|
2310
|
-
batchReleaseSchema,
|
|
2311
|
-
questSettingsInputSchema,
|
|
2312
|
-
publishedReleaseSchema,
|
|
2313
|
-
templateSchema,
|
|
2314
|
-
quizAnswersSchema,
|
|
2315
|
-
quizEvidenceSchema,
|
|
2316
|
-
submissionEvidenceSchema,
|
|
2317
|
-
submitSchema,
|
|
2318
|
-
attemptSchema,
|
|
2319
|
-
eventSchema,
|
|
2320
|
-
pickupSelectionSchema,
|
|
2321
|
-
pickupAllocationSchema,
|
|
2322
|
-
pickupPolicySchema,
|
|
2323
|
-
pickupCatalogSchema,
|
|
2324
|
-
pickupAvailabilitySchema,
|
|
2325
|
-
configurePickupSchema,
|
|
2326
|
-
entitlementSchema,
|
|
2327
|
-
beginHandoverSchema,
|
|
2328
|
-
confirmHandoverSchema,
|
|
2329
|
-
completionRecordSchema,
|
|
2330
|
-
questAvailabilitySchema,
|
|
2331
|
-
memberProgressSchema,
|
|
2332
|
-
snapshotSchema,
|
|
2333
|
-
evidenceSchema,
|
|
2334
|
-
errorSchema,
|
|
2335
|
-
staffDecisionSchema,
|
|
2336
|
-
stockSchema,
|
|
2337
|
-
reservationSchema,
|
|
2338
|
-
reviewListSchema,
|
|
2339
|
-
memberListSchema,
|
|
2340
|
-
reviewItemSchema,
|
|
2341
|
-
reviewPageSchema,
|
|
2342
|
-
memberPageSchema,
|
|
2343
|
-
createStockItemSchema,
|
|
2344
|
-
stockItemSchema,
|
|
2345
|
-
contentPerformanceSnapshotSchema,
|
|
2346
|
-
contentPerformanceQuerySchema,
|
|
2347
|
-
contentPerformancePageSchema
|
|
2348
|
-
};
|