@domino-sdk/relay 1.9.0 → 1.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{activity-CCe1e_7a.d.ts → activity-C0O3g7VJ.d.ts} +115 -115
- package/dist/authoring.d.ts +49 -49
- package/dist/authoring.js +3 -3
- package/dist/{automatic-outcomes-Dyk0VTUs.d.ts → automatic-outcomes-kPIDv6X_.d.ts} +1 -1
- package/dist/avatar.d.ts +2 -2
- package/dist/browser.d.ts +8 -8
- package/dist/browser.js +8 -7
- package/dist/{capability-error-Bv996M-h.d.ts → capability-error-ty3SqD_b.d.ts} +1 -1
- package/dist/chunk-2M3HLQFP.js +13 -0
- package/dist/{chunk-KGJSKGKI.js → chunk-5WK4EB5I.js} +1120 -910
- package/dist/{chunk-5ECM6AWV.js → chunk-A2KXEGGD.js} +3 -3
- package/dist/{chunk-L3QFIRGO.js → chunk-FH7ZFHDB.js} +2 -2
- package/dist/{chunk-FWSSMSIA.js → chunk-MDN5EJY2.js} +37 -8
- package/dist/{chunk-2V74CHDL.js → chunk-MJMFGTVV.js} +52 -37
- package/dist/{chunk-2N464DDE.js → chunk-NM2ZAWTF.js} +48 -37
- package/dist/{chunk-ETPL6AAJ.js → chunk-PFKV2M4B.js} +1 -1
- package/dist/{chunk-6ON4RMEN.js → chunk-PRLGLZM4.js} +1 -1
- package/dist/{chunk-JW4G3SY5.js → chunk-S4IHOJEP.js} +60 -47
- package/dist/{chunk-23QJ7WH4.js → chunk-WZJQ7XAT.js} +1 -1
- package/dist/{chunk-734LYHWP.js → chunk-XMZNIFXH.js} +232 -7
- package/dist/{client-CbASImpi.d.ts → client-Yq11HA_f.d.ts} +26 -11
- package/dist/{groups-Dvmd4CYk.d.ts → groups-BK8ts2yK.d.ts} +94 -6
- package/dist/{images-Dekv3DYF.d.ts → images-aw6W7vFZ.d.ts} +2 -2
- package/dist/index.d.ts +9 -9
- package/dist/index.js +7 -6
- package/dist/internal.d.ts +3 -3
- package/dist/internal.js +5 -5
- package/dist/{offers-BEGVSOTD.d.ts → offers-C2FANzrG.d.ts} +3 -3
- package/dist/{pages-HmS6eedC.d.ts → pages-D00JDZB-.d.ts} +33 -2
- package/dist/portal-proxy.js +8 -2
- package/dist/react/index.d.ts +14 -17
- package/dist/react/index.js +8 -7
- package/dist/{referral-reward-kinds-Flbb1D2q.d.ts → referral-reward-kinds-M3f0PdiR.d.ts} +2 -2
- package/dist/{schema-BCuiO7eD.d.ts → schema-DEM8y8Fm.d.ts} +1 -1
- package/dist/schema.d.ts +11239 -13
- package/dist/schema.js +38 -6
- package/dist/server/index.d.ts +43117 -22
- package/dist/server/index.js +303 -14
- package/dist/{sign-in-options-z3wsfizk.d.ts → sign-in-options-Coim0G1u.d.ts} +3 -3
- package/dist/{submission-input-Bs14jIsu.d.ts → submission-input-BbBJTVlT.d.ts} +3 -3
- package/dist/util.d-w9f9t3ua.d.ts +5 -0
- package/dist/{wallet-YssWxGg8.d.ts → wallet-CDyo-U4n.d.ts} +1 -1
- package/package.json +1 -1
- package/dist/{profiles-D2aFcOxu.d.ts → profiles-BHMVj0kM.d.ts} +5 -5
|
@@ -1,114 +1,313 @@
|
|
|
1
|
-
// src/
|
|
1
|
+
// src/response.ts
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
var
|
|
4
|
-
|
|
3
|
+
var responseFormat = /* @__PURE__ */ Symbol("domino.response.tolerant-v1");
|
|
4
|
+
function markResponseSchema(schema) {
|
|
5
|
+
return Object.assign(schema, { [responseFormat]: true });
|
|
6
|
+
}
|
|
7
|
+
var shapes = /* @__PURE__ */ new WeakMap();
|
|
8
|
+
function responseShape(schema) {
|
|
9
|
+
const existing = shapes.get(schema);
|
|
10
|
+
if (existing) {
|
|
11
|
+
return existing;
|
|
12
|
+
}
|
|
13
|
+
const definition = { ...schema._zod.def };
|
|
14
|
+
if (schema instanceof z.ZodObject) {
|
|
15
|
+
Object.assign(definition, {
|
|
16
|
+
shape: Object.fromEntries(
|
|
17
|
+
Object.entries(schema.shape).map(([key, child]) => [
|
|
18
|
+
key,
|
|
19
|
+
responseShape(child)
|
|
20
|
+
])
|
|
21
|
+
),
|
|
22
|
+
catchall: schema._zod.def.catchall instanceof z.ZodNever || !schema._zod.def.catchall ? void 0 : responseShape(schema._zod.def.catchall)
|
|
23
|
+
});
|
|
24
|
+
} else if (schema instanceof z.ZodNumber) {
|
|
25
|
+
Object.assign(definition, {
|
|
26
|
+
checks: schema._zod.def.checks?.filter((check) => {
|
|
27
|
+
const rule = check._zod.def;
|
|
28
|
+
return rule.check !== "less_than" || !("value" in rule) || rule.value === Number.MAX_SAFE_INTEGER || rule.value === 864e13;
|
|
29
|
+
})
|
|
30
|
+
});
|
|
31
|
+
} else if (schema instanceof z.ZodArray) {
|
|
32
|
+
Object.assign(definition, {
|
|
33
|
+
element: responseShape(schema.element),
|
|
34
|
+
checks: []
|
|
35
|
+
});
|
|
36
|
+
} else if (schema instanceof z.ZodUnion) {
|
|
37
|
+
Object.assign(definition, { options: schema.options.map(responseShape) });
|
|
38
|
+
} else if (schema instanceof z.ZodTuple) {
|
|
39
|
+
Object.assign(definition, {
|
|
40
|
+
items: schema._zod.def.items.map(responseShape),
|
|
41
|
+
rest: schema._zod.def.rest ? responseShape(schema._zod.def.rest) : null
|
|
42
|
+
});
|
|
43
|
+
} else if (schema instanceof z.ZodIntersection) {
|
|
44
|
+
Object.assign(definition, {
|
|
45
|
+
left: responseShape(schema._zod.def.left),
|
|
46
|
+
right: responseShape(schema._zod.def.right)
|
|
47
|
+
});
|
|
48
|
+
} else if (schema instanceof z.ZodLazy) {
|
|
49
|
+
Object.assign(definition, {
|
|
50
|
+
getter: () => responseShape(schema._zod.def.getter())
|
|
51
|
+
});
|
|
52
|
+
} else if (schema instanceof z.ZodRecord) {
|
|
53
|
+
Object.assign(definition, { valueType: responseShape(schema.valueType) });
|
|
54
|
+
} else if (schema instanceof z.ZodPipe) {
|
|
55
|
+
Object.assign(definition, {
|
|
56
|
+
in: responseShape(schema.in),
|
|
57
|
+
out: responseShape(schema.out)
|
|
58
|
+
});
|
|
59
|
+
} else if ("innerType" in definition && definition.innerType instanceof z.ZodType) {
|
|
60
|
+
Object.assign(definition, {
|
|
61
|
+
innerType: responseShape(definition.innerType)
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
const reader = z.clone(schema, definition);
|
|
65
|
+
shapes.set(schema, reader);
|
|
66
|
+
shapes.set(reader, reader);
|
|
67
|
+
return reader;
|
|
68
|
+
}
|
|
69
|
+
function knownResponse(schema) {
|
|
70
|
+
return responseShape(schema);
|
|
71
|
+
}
|
|
72
|
+
function fields(schema) {
|
|
73
|
+
if (schema instanceof z.ZodObject) {
|
|
74
|
+
return schema.shape;
|
|
75
|
+
}
|
|
76
|
+
if ("innerType" in schema._zod.def && schema._zod.def.innerType instanceof z.ZodType) {
|
|
77
|
+
return fields(schema._zod.def.innerType);
|
|
78
|
+
}
|
|
79
|
+
return void 0;
|
|
80
|
+
}
|
|
81
|
+
function values(schema) {
|
|
82
|
+
if (schema instanceof z.ZodLiteral) {
|
|
83
|
+
return [...schema.values];
|
|
84
|
+
}
|
|
85
|
+
if (schema instanceof z.ZodEnum) {
|
|
86
|
+
return schema.options;
|
|
87
|
+
}
|
|
88
|
+
if ("innerType" in schema._zod.def && schema._zod.def.innerType instanceof z.ZodType) {
|
|
89
|
+
return values(schema._zod.def.innerType);
|
|
90
|
+
}
|
|
91
|
+
return void 0;
|
|
92
|
+
}
|
|
93
|
+
function unknownVariant(schema, input) {
|
|
94
|
+
if (schema instanceof z.ZodLiteral) {
|
|
95
|
+
return typeof input === "string" && [...schema.values].every((value) => typeof value === "string") && !schema.values.has(input);
|
|
96
|
+
}
|
|
97
|
+
if (schema instanceof z.ZodEnum) {
|
|
98
|
+
return typeof input === "string" && !schema.options.includes(input);
|
|
99
|
+
}
|
|
100
|
+
if (schema instanceof z.ZodArray && Array.isArray(input)) {
|
|
101
|
+
return input.some((item) => unknownVariant(schema.element, item));
|
|
102
|
+
}
|
|
103
|
+
if (schema instanceof z.ZodTuple && Array.isArray(input)) {
|
|
104
|
+
return input.some((item, index) => {
|
|
105
|
+
const child = schema._zod.def.items[index] ?? schema._zod.def.rest;
|
|
106
|
+
return child ? unknownVariant(child, item) : false;
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
if (schema instanceof z.ZodIntersection) {
|
|
110
|
+
return unknownVariant(schema._zod.def.left, input) || unknownVariant(schema._zod.def.right, input);
|
|
111
|
+
}
|
|
112
|
+
if (schema instanceof z.ZodLazy) {
|
|
113
|
+
return unknownVariant(schema._zod.def.getter(), input);
|
|
114
|
+
}
|
|
115
|
+
if (schema instanceof z.ZodRecord && input !== null && typeof input === "object" && !Array.isArray(input)) {
|
|
116
|
+
return Object.entries(input).some(
|
|
117
|
+
([key, value]) => unknownVariant(schema.keyType, key) || unknownVariant(schema.valueType, value)
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
if (schema instanceof z.ZodUnion) {
|
|
121
|
+
let options = [...schema.options];
|
|
122
|
+
if (typeof input === "string") {
|
|
123
|
+
const choices = options.flatMap((option) => values(option) ?? []);
|
|
124
|
+
if (choices.some((choice) => typeof choice === "string") && !choices.includes(input)) {
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (input !== null && typeof input === "object" && !Array.isArray(input)) {
|
|
129
|
+
const raw = z.record(z.string(), z.unknown()).parse(input);
|
|
130
|
+
const keys = ["kind", "status", "provider", "input", "type", "mode"];
|
|
131
|
+
for (const key of keys) {
|
|
132
|
+
if (typeof raw[key] !== "string") {
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
const choices = options.map((option) => {
|
|
136
|
+
const field = fields(option)?.[key];
|
|
137
|
+
return field ? values(field) : void 0;
|
|
138
|
+
});
|
|
139
|
+
if (choices.some((choice) => !choice)) {
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
const matching = options.filter(
|
|
143
|
+
(_, index) => choices[index]?.includes(raw[key])
|
|
144
|
+
);
|
|
145
|
+
if (!matching.length) {
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
options = matching;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return options.every((option) => unknownVariant(option, input));
|
|
152
|
+
}
|
|
153
|
+
if (schema instanceof z.ZodObject && input !== null && typeof input === "object" && !Array.isArray(input)) {
|
|
154
|
+
const raw = z.record(z.string(), z.unknown()).parse(input);
|
|
155
|
+
return Object.entries(schema.shape).some(
|
|
156
|
+
([key, child]) => unknownVariant(child, raw[key])
|
|
157
|
+
) || Object.entries(raw).some(
|
|
158
|
+
([key, value]) => !(key in schema.shape) && !!schema._zod.def.catchall && unknownVariant(schema._zod.def.catchall, value)
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
if (schema instanceof z.ZodPipe) {
|
|
162
|
+
if (unknownVariant(schema.in, input)) {
|
|
163
|
+
return true;
|
|
164
|
+
}
|
|
165
|
+
const intermediate = z.safeParse(schema.in, input);
|
|
166
|
+
return intermediate.success && unknownVariant(schema.out, intermediate.data);
|
|
167
|
+
}
|
|
168
|
+
if ("innerType" in schema._zod.def && schema._zod.def.innerType instanceof z.ZodType) {
|
|
169
|
+
return unknownVariant(schema._zod.def.innerType, input);
|
|
170
|
+
}
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
function responseSchema(schema) {
|
|
174
|
+
const reader = knownResponse(schema);
|
|
175
|
+
return markResponseSchema(
|
|
176
|
+
z.json().transform((raw, context) => {
|
|
177
|
+
const parsed = reader.safeParse(raw);
|
|
178
|
+
if (parsed.success) {
|
|
179
|
+
return { kind: "supported", value: parsed.data };
|
|
180
|
+
}
|
|
181
|
+
if (unknownVariant(reader, raw)) {
|
|
182
|
+
return { kind: "unsupported", raw };
|
|
183
|
+
}
|
|
184
|
+
for (const issue of parsed.error.issues) {
|
|
185
|
+
context.addIssue({ ...issue });
|
|
186
|
+
}
|
|
187
|
+
return z.NEVER;
|
|
188
|
+
})
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
function responseListSchema(schema) {
|
|
192
|
+
return markResponseSchema(
|
|
193
|
+
z.array(responseSchema(schema)).transform((items) => ({
|
|
194
|
+
items,
|
|
195
|
+
unsupportedCount: items.filter((item) => item.kind === "unsupported").length
|
|
196
|
+
}))
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// src/pages.ts
|
|
201
|
+
import { z as z2 } from "zod";
|
|
202
|
+
var pageCursorSchema = z2.string().min(1).max(4096);
|
|
203
|
+
var pageQuerySchema = z2.strictObject({
|
|
5
204
|
cursor: pageCursorSchema.optional()
|
|
6
205
|
});
|
|
7
206
|
|
|
8
207
|
// src/accounts.ts
|
|
9
|
-
import { z as
|
|
10
|
-
var authProviderSchema =
|
|
11
|
-
var accountConnectionSchema =
|
|
208
|
+
import { z as z3 } from "zod";
|
|
209
|
+
var authProviderSchema = z3.enum(["google", "apple", "x", "discord"]);
|
|
210
|
+
var accountConnectionSchema = z3.object({
|
|
12
211
|
provider: authProviderSchema,
|
|
13
|
-
configured:
|
|
14
|
-
status:
|
|
15
|
-
subject:
|
|
16
|
-
revision:
|
|
17
|
-
});
|
|
18
|
-
var discordMemberInputSchema =
|
|
19
|
-
var discordMessageInputSchema =
|
|
20
|
-
channelId:
|
|
21
|
-
messageId:
|
|
212
|
+
configured: z3.boolean(),
|
|
213
|
+
status: z3.enum(["disconnected", "connected", "reconnect"]),
|
|
214
|
+
subject: z3.string().nullable(),
|
|
215
|
+
revision: z3.number().int().nonnegative()
|
|
216
|
+
});
|
|
217
|
+
var discordMemberInputSchema = z3.object({}).strict();
|
|
218
|
+
var discordMessageInputSchema = z3.object({
|
|
219
|
+
channelId: z3.string().regex(/^[0-9]{1,20}$/),
|
|
220
|
+
messageId: z3.string().regex(/^[0-9]{1,20}$/)
|
|
22
221
|
}).strict();
|
|
23
|
-
var discordMemberSchema =
|
|
24
|
-
userId:
|
|
25
|
-
nickname:
|
|
26
|
-
displayName:
|
|
27
|
-
boostingSince:
|
|
28
|
-
roles:
|
|
29
|
-
joinedAt:
|
|
30
|
-
pending:
|
|
222
|
+
var discordMemberSchema = z3.object({
|
|
223
|
+
userId: z3.string().regex(/^[0-9]{1,20}$/).nullable().default(null),
|
|
224
|
+
nickname: z3.string().nullable().default(null),
|
|
225
|
+
displayName: z3.string().nullable().default(null),
|
|
226
|
+
boostingSince: z3.string().datetime({ offset: true }).nullable().default(null),
|
|
227
|
+
roles: z3.array(z3.string().regex(/^[0-9]{1,20}$/)),
|
|
228
|
+
joinedAt: z3.string().datetime({ offset: true }).nullable(),
|
|
229
|
+
pending: z3.boolean()
|
|
31
230
|
});
|
|
32
231
|
|
|
33
232
|
// src/identifier.ts
|
|
34
|
-
import { z as
|
|
35
|
-
var identifier =
|
|
233
|
+
import { z as z4 } from "zod";
|
|
234
|
+
var identifier = z4.string().min(1).max(100).regex(/^[a-zA-Z0-9_-]+$/);
|
|
36
235
|
|
|
37
236
|
// src/discord.ts
|
|
38
|
-
import { z as
|
|
39
|
-
var discordMessageSchema =
|
|
40
|
-
guildId:
|
|
41
|
-
channelId:
|
|
42
|
-
messageId:
|
|
43
|
-
userId:
|
|
44
|
-
content:
|
|
45
|
-
replyTo:
|
|
46
|
-
publishedAt:
|
|
237
|
+
import { z as z5 } from "zod";
|
|
238
|
+
var discordMessageSchema = z5.object({
|
|
239
|
+
guildId: z5.string(),
|
|
240
|
+
channelId: z5.string(),
|
|
241
|
+
messageId: z5.string(),
|
|
242
|
+
userId: z5.string(),
|
|
243
|
+
content: z5.string().nullable(),
|
|
244
|
+
replyTo: z5.string().nullable(),
|
|
245
|
+
publishedAt: z5.number()
|
|
47
246
|
}).strict();
|
|
48
|
-
var discordMessagesSourceSchema =
|
|
49
|
-
kind:
|
|
247
|
+
var discordMessagesSourceSchema = z5.strictObject({
|
|
248
|
+
kind: z5.literal("discord-messages"),
|
|
50
249
|
/** Store each message's text in `data.text`. Off unless set. */
|
|
51
|
-
text:
|
|
250
|
+
text: z5.boolean().optional()
|
|
52
251
|
});
|
|
53
|
-
var discordReactionsSourceSchema =
|
|
54
|
-
kind:
|
|
252
|
+
var discordReactionsSourceSchema = z5.strictObject({
|
|
253
|
+
kind: z5.literal("discord-reactions")
|
|
55
254
|
});
|
|
56
|
-
var discordMessageDataSchema =
|
|
57
|
-
guildId:
|
|
58
|
-
channelId:
|
|
59
|
-
messageId:
|
|
255
|
+
var discordMessageDataSchema = z5.object({
|
|
256
|
+
guildId: z5.string(),
|
|
257
|
+
channelId: z5.string(),
|
|
258
|
+
messageId: z5.string(),
|
|
60
259
|
/** The ID of the message this one replies to, or null. */
|
|
61
|
-
replyTo:
|
|
260
|
+
replyTo: z5.string().nullable(),
|
|
62
261
|
/** When Discord says the message was posted, in epoch milliseconds. */
|
|
63
|
-
publishedAt:
|
|
262
|
+
publishedAt: z5.number()
|
|
64
263
|
});
|
|
65
264
|
var discordMessageTextDataSchema = discordMessageDataSchema.extend({
|
|
66
|
-
text:
|
|
265
|
+
text: z5.string().nullable()
|
|
67
266
|
});
|
|
68
|
-
var discordReactionDataSchema =
|
|
69
|
-
guildId:
|
|
70
|
-
channelId:
|
|
267
|
+
var discordReactionDataSchema = z5.object({
|
|
268
|
+
guildId: z5.string(),
|
|
269
|
+
channelId: z5.string(),
|
|
71
270
|
/** The message reacted to. */
|
|
72
|
-
messageId:
|
|
271
|
+
messageId: z5.string(),
|
|
73
272
|
/** A custom emoji's ID, or null for a Unicode emoji, whose `name` is the emoji itself. */
|
|
74
|
-
emoji:
|
|
273
|
+
emoji: z5.object({ id: z5.string().nullable(), name: z5.string() }),
|
|
75
274
|
/** The role IDs the reactor held in the server when reacting. */
|
|
76
|
-
reactorRoles:
|
|
275
|
+
reactorRoles: z5.array(z5.string()),
|
|
77
276
|
/** When the reacted-to message was posted, in epoch milliseconds. */
|
|
78
|
-
messagePublishedAt:
|
|
79
|
-
});
|
|
80
|
-
var discordRewardSchema =
|
|
81
|
-
kind:
|
|
82
|
-
provider:
|
|
83
|
-
action:
|
|
84
|
-
roleId:
|
|
85
|
-
});
|
|
86
|
-
var discordResourceSourceSchema =
|
|
87
|
-
|
|
88
|
-
provider:
|
|
89
|
-
resource:
|
|
90
|
-
types:
|
|
277
|
+
messagePublishedAt: z5.number()
|
|
278
|
+
});
|
|
279
|
+
var discordRewardSchema = z5.strictObject({
|
|
280
|
+
kind: z5.literal("integration"),
|
|
281
|
+
provider: z5.literal("discord"),
|
|
282
|
+
action: z5.literal("grant-role"),
|
|
283
|
+
roleId: z5.string().regex(/^[0-9]{1,20}$/)
|
|
284
|
+
});
|
|
285
|
+
var discordResourceSourceSchema = z5.union([
|
|
286
|
+
z5.strictObject({
|
|
287
|
+
provider: z5.literal("discord"),
|
|
288
|
+
resource: z5.literal("channel"),
|
|
289
|
+
types: z5.array(z5.enum(["text", "announcement"])).min(1)
|
|
91
290
|
}),
|
|
92
|
-
|
|
93
|
-
provider:
|
|
94
|
-
resource:
|
|
95
|
-
assignable:
|
|
291
|
+
z5.strictObject({
|
|
292
|
+
provider: z5.literal("discord"),
|
|
293
|
+
resource: z5.literal("role"),
|
|
294
|
+
assignable: z5.boolean().default(false)
|
|
96
295
|
})
|
|
97
296
|
]);
|
|
98
297
|
|
|
99
298
|
// src/tracker-data.ts
|
|
100
|
-
import { z as
|
|
299
|
+
import { z as z6 } from "zod";
|
|
101
300
|
var maxDepth = 16;
|
|
102
301
|
var maxBytes = 32768;
|
|
103
302
|
var trackerDataMaxBranches = 16;
|
|
104
303
|
var trackerDataMaxEntries = 256;
|
|
105
|
-
var scalar =
|
|
106
|
-
var size =
|
|
107
|
-
var bound =
|
|
108
|
-
var branches = () =>
|
|
109
|
-
var node =
|
|
110
|
-
() =>
|
|
111
|
-
type:
|
|
304
|
+
var scalar = z6.union([z6.string(), z6.number().finite(), z6.boolean(), z6.null()]);
|
|
305
|
+
var size = z6.number().int().safe().nonnegative();
|
|
306
|
+
var bound = z6.number().finite();
|
|
307
|
+
var branches = () => z6.array(node).min(1).max(trackerDataMaxBranches);
|
|
308
|
+
var node = z6.lazy(
|
|
309
|
+
() => z6.strictObject({
|
|
310
|
+
type: z6.enum([
|
|
112
311
|
"object",
|
|
113
312
|
"array",
|
|
114
313
|
"string",
|
|
@@ -117,15 +316,15 @@ var node = z5.lazy(
|
|
|
117
316
|
"boolean",
|
|
118
317
|
"null"
|
|
119
318
|
]).optional(),
|
|
120
|
-
properties:
|
|
319
|
+
properties: z6.record(z6.string(), node).refine(
|
|
121
320
|
(properties) => Object.keys(properties).length <= trackerDataMaxEntries,
|
|
122
321
|
`An object schema lists at most ${trackerDataMaxEntries} properties`
|
|
123
322
|
).optional(),
|
|
124
|
-
required:
|
|
125
|
-
additionalProperties:
|
|
126
|
-
propertyNames:
|
|
127
|
-
type:
|
|
128
|
-
enum:
|
|
323
|
+
required: z6.array(z6.string()).max(trackerDataMaxEntries).optional(),
|
|
324
|
+
additionalProperties: z6.union([z6.boolean(), node]).optional(),
|
|
325
|
+
propertyNames: z6.strictObject({
|
|
326
|
+
type: z6.literal("string"),
|
|
327
|
+
enum: z6.array(z6.string()).max(trackerDataMaxEntries).optional()
|
|
129
328
|
}).optional(),
|
|
130
329
|
items: node.optional(),
|
|
131
330
|
minItems: size.optional(),
|
|
@@ -136,7 +335,7 @@ var node = z5.lazy(
|
|
|
136
335
|
maximum: bound.optional(),
|
|
137
336
|
exclusiveMinimum: bound.optional(),
|
|
138
337
|
exclusiveMaximum: bound.optional(),
|
|
139
|
-
enum:
|
|
338
|
+
enum: z6.array(scalar).min(1).max(trackerDataMaxEntries).optional(),
|
|
140
339
|
const: scalar.optional(),
|
|
141
340
|
anyOf: branches().optional(),
|
|
142
341
|
oneOf: branches().optional(),
|
|
@@ -198,7 +397,7 @@ function nestedUnionIssue(schema, path, insideUnion) {
|
|
|
198
397
|
}
|
|
199
398
|
return null;
|
|
200
399
|
}
|
|
201
|
-
var trackerDataSchemaSchema =
|
|
400
|
+
var trackerDataSchemaSchema = z6.unknown().superRefine((value, ctx) => {
|
|
202
401
|
const issue = shapeIssue(value);
|
|
203
402
|
if (issue) {
|
|
204
403
|
ctx.addIssue({ code: "custom", message: issue, abort: true });
|
|
@@ -305,7 +504,7 @@ function subset(schema, path) {
|
|
|
305
504
|
function trackerDataSchema(schema) {
|
|
306
505
|
let json;
|
|
307
506
|
try {
|
|
308
|
-
json =
|
|
507
|
+
json = z6.toJSONSchema(schema, {
|
|
309
508
|
target: "draft-2020-12",
|
|
310
509
|
io: "input",
|
|
311
510
|
unrepresentable: "throw",
|
|
@@ -364,16 +563,16 @@ function pathText(path) {
|
|
|
364
563
|
}
|
|
365
564
|
var describe = (value) => value === null ? "null" : Array.isArray(value) ? "an array" : typeof value;
|
|
366
565
|
var shownValues = 10;
|
|
367
|
-
function oneOf(
|
|
368
|
-
const shown =
|
|
369
|
-
return
|
|
566
|
+
function oneOf(values2) {
|
|
567
|
+
const shown = values2.slice(0, shownValues).map((value) => JSON.stringify(value)).join(", ");
|
|
568
|
+
return values2.length > shownValues ? `expected one of ${shown}, or ${values2.length - shownValues} more` : `expected one of ${shown}`;
|
|
370
569
|
}
|
|
371
570
|
var enumSets = /* @__PURE__ */ new WeakMap();
|
|
372
571
|
var literalLists = /* @__PURE__ */ new WeakMap();
|
|
373
|
-
function setOf(owner,
|
|
572
|
+
function setOf(owner, values2) {
|
|
374
573
|
let found = enumSets.get(owner);
|
|
375
574
|
if (!found) {
|
|
376
|
-
found = new Set(
|
|
575
|
+
found = new Set(values2);
|
|
377
576
|
enumSets.set(owner, found);
|
|
378
577
|
}
|
|
379
578
|
return found;
|
|
@@ -395,8 +594,8 @@ function matches(schema, value, at, budget) {
|
|
|
395
594
|
return issue(() => `expected ${JSON.stringify(schema.const)}`);
|
|
396
595
|
}
|
|
397
596
|
if (schema.enum && !setOf(schema, schema.enum).has(value)) {
|
|
398
|
-
const
|
|
399
|
-
return issue(() => oneOf(
|
|
597
|
+
const values2 = schema.enum;
|
|
598
|
+
return issue(() => oneOf(values2));
|
|
400
599
|
}
|
|
401
600
|
switch (schema.type) {
|
|
402
601
|
case "null":
|
|
@@ -673,21 +872,21 @@ function whereSchemaIssue(schema, where) {
|
|
|
673
872
|
}
|
|
674
873
|
|
|
675
874
|
// src/trackers.ts
|
|
676
|
-
import { z as
|
|
677
|
-
var timestamp =
|
|
678
|
-
var count =
|
|
679
|
-
var externalId =
|
|
875
|
+
import { z as z7 } from "zod";
|
|
876
|
+
var timestamp = z7.number().int().safe().nonnegative().max(864e13);
|
|
877
|
+
var count = z7.number().int().safe().nonnegative();
|
|
878
|
+
var externalId = z7.string().min(1).max(256);
|
|
680
879
|
var metric = count.nullable().default(null);
|
|
681
|
-
var xTweetSchema =
|
|
880
|
+
var xTweetSchema = z7.looseObject({
|
|
682
881
|
id: externalId,
|
|
683
882
|
userId: externalId,
|
|
684
|
-
content:
|
|
685
|
-
createdAt:
|
|
686
|
-
author:
|
|
883
|
+
content: z7.string(),
|
|
884
|
+
createdAt: z7.iso.datetime({ offset: true }),
|
|
885
|
+
author: z7.looseObject({
|
|
687
886
|
id: externalId,
|
|
688
|
-
username:
|
|
689
|
-
name:
|
|
690
|
-
verified:
|
|
887
|
+
username: z7.string(),
|
|
888
|
+
name: z7.string(),
|
|
889
|
+
verified: z7.boolean().nullable().default(null)
|
|
691
890
|
}),
|
|
692
891
|
likeCount: metric,
|
|
693
892
|
replyCount: metric,
|
|
@@ -695,84 +894,84 @@ var xTweetSchema = z6.looseObject({
|
|
|
695
894
|
quoteCount: metric,
|
|
696
895
|
viewCount: metric,
|
|
697
896
|
bookmarkCount: metric,
|
|
698
|
-
isReply:
|
|
699
|
-
isRetweet:
|
|
700
|
-
isQuoteTweet:
|
|
701
|
-
});
|
|
702
|
-
var xContentBodySchema =
|
|
703
|
-
version:
|
|
704
|
-
id:
|
|
705
|
-
authorId:
|
|
897
|
+
isReply: z7.boolean(),
|
|
898
|
+
isRetweet: z7.boolean(),
|
|
899
|
+
isQuoteTweet: z7.boolean()
|
|
900
|
+
});
|
|
901
|
+
var xContentBodySchema = z7.strictObject({
|
|
902
|
+
version: z7.literal(1),
|
|
903
|
+
id: z7.string().min(1),
|
|
904
|
+
authorId: z7.string().min(1),
|
|
706
905
|
publishedAt: timestamp,
|
|
707
|
-
text:
|
|
708
|
-
isReply:
|
|
709
|
-
isRetweet:
|
|
710
|
-
isQuoteTweet:
|
|
711
|
-
media:
|
|
712
|
-
mentionedAuthorIds:
|
|
713
|
-
videoLengthSeconds:
|
|
714
|
-
references:
|
|
715
|
-
replyId:
|
|
716
|
-
replyAuthorId:
|
|
717
|
-
quoteId:
|
|
718
|
-
quoteAuthorId:
|
|
719
|
-
repostId:
|
|
720
|
-
repostAuthorId:
|
|
906
|
+
text: z7.string(),
|
|
907
|
+
isReply: z7.boolean(),
|
|
908
|
+
isRetweet: z7.boolean(),
|
|
909
|
+
isQuoteTweet: z7.boolean(),
|
|
910
|
+
media: z7.array(z7.strictObject({ type: z7.string(), url: z7.string() })).nullable(),
|
|
911
|
+
mentionedAuthorIds: z7.array(z7.string().min(1)).nullable(),
|
|
912
|
+
videoLengthSeconds: z7.number().nonnegative().nullable(),
|
|
913
|
+
references: z7.strictObject({
|
|
914
|
+
replyId: z7.string().nullable(),
|
|
915
|
+
replyAuthorId: z7.string().nullable(),
|
|
916
|
+
quoteId: z7.string().nullable(),
|
|
917
|
+
quoteAuthorId: z7.string().nullable(),
|
|
918
|
+
repostId: z7.string().nullable(),
|
|
919
|
+
repostAuthorId: z7.string().nullable()
|
|
721
920
|
})
|
|
722
921
|
});
|
|
723
|
-
var trackerContentQuerySchema =
|
|
922
|
+
var trackerContentQuerySchema = z7.strictObject({
|
|
724
923
|
id: externalId,
|
|
725
|
-
observation:
|
|
924
|
+
observation: z7.string().regex(/^observation_[a-f0-9]{64}$/)
|
|
726
925
|
});
|
|
727
926
|
var trackerContentReadSchema = trackerContentQuerySchema.extend({
|
|
728
927
|
member: identifier
|
|
729
928
|
});
|
|
730
929
|
var attributionContext = { member: identifier, capturedAt: timestamp };
|
|
731
|
-
var trackerEvidenceSchema =
|
|
930
|
+
var trackerEvidenceSchema = z7.strictObject({
|
|
732
931
|
contentRevision: identifier,
|
|
733
932
|
observation: identifier
|
|
734
933
|
});
|
|
735
|
-
var trackerContentSchema =
|
|
934
|
+
var trackerContentSchema = z7.strictObject({
|
|
736
935
|
tracker: identifier,
|
|
737
|
-
source:
|
|
936
|
+
source: z7.literal("x"),
|
|
738
937
|
evidence: trackerEvidenceSchema,
|
|
739
938
|
content: xContentBodySchema,
|
|
740
939
|
observedAt: timestamp,
|
|
741
|
-
removed:
|
|
742
|
-
attribution:
|
|
743
|
-
|
|
940
|
+
removed: z7.boolean(),
|
|
941
|
+
attribution: z7.discriminatedUnion("kind", [
|
|
942
|
+
z7.strictObject({
|
|
744
943
|
...attributionContext,
|
|
745
|
-
kind:
|
|
746
|
-
account:
|
|
747
|
-
provider:
|
|
748
|
-
issuer:
|
|
944
|
+
kind: z7.literal("linked"),
|
|
945
|
+
account: z7.strictObject({
|
|
946
|
+
provider: z7.literal("x"),
|
|
947
|
+
issuer: z7.string().min(1),
|
|
749
948
|
subject: externalId,
|
|
750
949
|
revision: count,
|
|
751
950
|
linkedAt: timestamp.nullable()
|
|
752
951
|
})
|
|
753
952
|
}),
|
|
754
|
-
|
|
755
|
-
|
|
953
|
+
z7.strictObject({ ...attributionContext, kind: z7.literal("unlinked") }),
|
|
954
|
+
z7.strictObject({
|
|
756
955
|
...attributionContext,
|
|
757
|
-
kind:
|
|
956
|
+
kind: z7.literal("different-author")
|
|
758
957
|
})
|
|
759
958
|
])
|
|
760
959
|
});
|
|
761
960
|
var knownIdentityKinds = ["wallet", "x", "discord", "member"];
|
|
762
|
-
var appIdentityKindSchema =
|
|
961
|
+
var appIdentityKindSchema = z7.templateLiteral([
|
|
763
962
|
"app:",
|
|
764
|
-
|
|
963
|
+
z7.string().regex(
|
|
765
964
|
/^[a-z0-9][a-z0-9_-]{0,39}$/,
|
|
766
965
|
"Name an app identity kind like app:telegram: lowercase letters, digits, _ or -, at most 40"
|
|
767
966
|
)
|
|
768
967
|
]);
|
|
769
|
-
var identityKindSchema =
|
|
770
|
-
|
|
968
|
+
var identityKindSchema = z7.union([
|
|
969
|
+
z7.enum(knownIdentityKinds),
|
|
771
970
|
appIdentityKindSchema
|
|
772
971
|
]);
|
|
773
972
|
var isAppIdentityKind = (kind) => kind.startsWith("app:");
|
|
774
|
-
var openIdentityKindSchema =
|
|
775
|
-
var memberIdentitySchema =
|
|
973
|
+
var openIdentityKindSchema = z7.string().min(1).max(64);
|
|
974
|
+
var memberIdentitySchema = z7.object({
|
|
776
975
|
kind: openIdentityKindSchema,
|
|
777
976
|
/** The stable user ID for `x` and `discord`; the subject your app signed the member in with for `app:<name>`. */
|
|
778
977
|
subject: externalId,
|
|
@@ -784,13 +983,13 @@ var memberIdentitySchema = z6.object({
|
|
|
784
983
|
/** The latest link time, refreshed on app identity relink; null when the link time is unknown. */
|
|
785
984
|
linkedAt: timestamp.nullable()
|
|
786
985
|
});
|
|
787
|
-
var accountRoleSchema =
|
|
986
|
+
var accountRoleSchema = z7.string().regex(
|
|
788
987
|
/^[a-zA-Z][a-zA-Z0-9_]{0,39}$/,
|
|
789
988
|
"Name roles like author or recipient: a letter, then letters, digits or underscores"
|
|
790
989
|
);
|
|
791
990
|
var xAccountRoles = ["author", "inReplyTo"];
|
|
792
|
-
var distinct = (
|
|
793
|
-
var contentMetricNameSchema =
|
|
991
|
+
var distinct = (values2) => new Set(values2).size === values2.length;
|
|
992
|
+
var contentMetricNameSchema = z7.string().regex(
|
|
794
993
|
/^[a-z][a-zA-Z0-9]{0,39}$/,
|
|
795
994
|
"Name metrics like likes or watchTime: a lowercase letter, then letters or digits"
|
|
796
995
|
);
|
|
@@ -802,24 +1001,24 @@ var xContentMetrics = [
|
|
|
802
1001
|
"views",
|
|
803
1002
|
"bookmarks"
|
|
804
1003
|
];
|
|
805
|
-
var customContentSchema =
|
|
806
|
-
metrics:
|
|
1004
|
+
var customContentSchema = z7.strictObject({
|
|
1005
|
+
metrics: z7.array(contentMetricNameSchema).max(10).refine(distinct, "List each metric once")
|
|
807
1006
|
});
|
|
808
|
-
var xSearchSourceSchema =
|
|
809
|
-
kind:
|
|
810
|
-
query:
|
|
1007
|
+
var xSearchSourceSchema = z7.object({
|
|
1008
|
+
kind: z7.literal("x-search"),
|
|
1009
|
+
query: z7.string().trim().min(1).max(2e3)
|
|
811
1010
|
}).strict();
|
|
812
|
-
var customSourceSchema =
|
|
813
|
-
kind:
|
|
1011
|
+
var customSourceSchema = z7.object({
|
|
1012
|
+
kind: z7.literal("custom"),
|
|
814
1013
|
namespace: identifier,
|
|
815
1014
|
/**
|
|
816
1015
|
* The identity kinds a record's author and named accounts can be, attributed to members
|
|
817
1016
|
* through verified links: `wallet`, `x`, `discord`, `member`, or your app's own `app:<name>`.
|
|
818
1017
|
* Omitted when authors are opaque IDs, which no quest can pay.
|
|
819
1018
|
*/
|
|
820
|
-
identities:
|
|
1019
|
+
identities: z7.array(identityKindSchema).min(1).max(8).refine(distinct, "List each identity kind once").optional(),
|
|
821
1020
|
/** Roles of the named accounts records can carry besides their author, such as `recipient`. */
|
|
822
|
-
accounts:
|
|
1021
|
+
accounts: z7.array(accountRoleSchema).min(1).max(10).refine(distinct, "List each account role once").refine(
|
|
823
1022
|
(roles) => !roles.includes("author"),
|
|
824
1023
|
"author is every record's own role; name other accounts"
|
|
825
1024
|
).optional(),
|
|
@@ -842,7 +1041,7 @@ var customSourceSchema = z6.object({
|
|
|
842
1041
|
(source) => !source.accounts || source.identities,
|
|
843
1042
|
"Named accounts need identities"
|
|
844
1043
|
);
|
|
845
|
-
var trackerSourceSchema =
|
|
1044
|
+
var trackerSourceSchema = z7.discriminatedUnion("kind", [
|
|
846
1045
|
xSearchSourceSchema,
|
|
847
1046
|
customSourceSchema,
|
|
848
1047
|
discordMessagesSourceSchema,
|
|
@@ -879,125 +1078,125 @@ function sourceContent(source) {
|
|
|
879
1078
|
return void 0;
|
|
880
1079
|
}
|
|
881
1080
|
}
|
|
882
|
-
var windowSchema =
|
|
1081
|
+
var windowSchema = z7.object({ start: timestamp, end: timestamp.optional() }).strict().refine(
|
|
883
1082
|
(w) => w.end === void 0 || w.end > w.start,
|
|
884
1083
|
"End must follow start"
|
|
885
1084
|
);
|
|
886
|
-
var trackerDefinitionSchema =
|
|
1085
|
+
var trackerDefinitionSchema = z7.object({
|
|
887
1086
|
key: identifier,
|
|
888
|
-
title:
|
|
1087
|
+
title: z7.string().trim().min(1).max(120),
|
|
889
1088
|
source: trackerSourceSchema,
|
|
890
1089
|
window: windowSchema,
|
|
891
|
-
refreshSeconds:
|
|
892
|
-
maxPages:
|
|
1090
|
+
refreshSeconds: z7.number().int().min(300).max(86400).default(21600),
|
|
1091
|
+
maxPages: z7.number().int().min(1).max(1e3).default(60)
|
|
893
1092
|
}).strict();
|
|
894
|
-
var trackerArtifactSchema =
|
|
1093
|
+
var trackerArtifactSchema = z7.union([
|
|
895
1094
|
trackerDefinitionSchema,
|
|
896
|
-
|
|
1095
|
+
z7.object({ code: z7.string().min(1).max(2e6) }).strict()
|
|
897
1096
|
]);
|
|
898
|
-
var knownTrackerSourceResponseSchema =
|
|
899
|
-
|
|
900
|
-
|
|
1097
|
+
var knownTrackerSourceResponseSchema = z7.discriminatedUnion("kind", [
|
|
1098
|
+
z7.object(xSearchSourceSchema.shape),
|
|
1099
|
+
z7.object({
|
|
901
1100
|
...customSourceSchema.shape,
|
|
902
|
-
identities:
|
|
1101
|
+
identities: z7.array(openIdentityKindSchema).optional()
|
|
903
1102
|
}),
|
|
904
|
-
|
|
905
|
-
|
|
1103
|
+
z7.object(discordMessagesSourceSchema.shape),
|
|
1104
|
+
z7.object(discordReactionsSourceSchema.shape)
|
|
906
1105
|
]);
|
|
907
|
-
var trackerSourceResponseSchema =
|
|
1106
|
+
var trackerSourceResponseSchema = z7.union([
|
|
908
1107
|
knownTrackerSourceResponseSchema,
|
|
909
|
-
|
|
910
|
-
kind:
|
|
1108
|
+
z7.object({
|
|
1109
|
+
kind: z7.string().min(1).refine(
|
|
911
1110
|
(kind) => !trackerSourceKinds.some((known) => known === kind),
|
|
912
1111
|
"Known source kinds must match their schema"
|
|
913
1112
|
)
|
|
914
|
-
}).catchall(
|
|
1113
|
+
}).catchall(z7.json())
|
|
915
1114
|
]);
|
|
916
1115
|
function isKnownTrackerSource(source) {
|
|
917
1116
|
return knownTrackerSourceResponseSchema.safeParse(source).success;
|
|
918
1117
|
}
|
|
919
|
-
var trackerDefinitionResponseSchema =
|
|
1118
|
+
var trackerDefinitionResponseSchema = z7.object({
|
|
920
1119
|
...trackerDefinitionSchema.shape,
|
|
921
1120
|
source: trackerSourceResponseSchema,
|
|
922
|
-
window:
|
|
1121
|
+
window: z7.object(windowSchema.shape)
|
|
923
1122
|
});
|
|
924
|
-
var publishedTrackerSchema =
|
|
1123
|
+
var publishedTrackerSchema = z7.object({
|
|
925
1124
|
id: identifier,
|
|
926
1125
|
version: identifier,
|
|
927
1126
|
definition: trackerDefinitionResponseSchema,
|
|
928
1127
|
publishedAt: timestamp,
|
|
929
|
-
actor:
|
|
1128
|
+
actor: z7.string().nullable()
|
|
930
1129
|
});
|
|
931
|
-
var trackerStatusSchema =
|
|
932
|
-
archivedAt:
|
|
1130
|
+
var trackerStatusSchema = z7.object({
|
|
1131
|
+
archivedAt: z7.number().int().nonnegative().nullable().optional(),
|
|
933
1132
|
published: publishedTrackerSchema,
|
|
934
|
-
paused:
|
|
935
|
-
state:
|
|
1133
|
+
paused: z7.boolean(),
|
|
1134
|
+
state: z7.enum(["idle", "syncing", "error", "complete"]),
|
|
936
1135
|
lastStartedAt: timestamp.nullable(),
|
|
937
1136
|
lastCompletedAt: timestamp.nullable(),
|
|
938
1137
|
nextSyncAt: timestamp.nullable(),
|
|
939
|
-
coverage:
|
|
940
|
-
error:
|
|
1138
|
+
coverage: z7.enum(["unknown", "partial", "complete"]),
|
|
1139
|
+
error: z7.string().nullable(),
|
|
941
1140
|
records: count
|
|
942
1141
|
});
|
|
943
|
-
var trackerControlSchema =
|
|
1142
|
+
var trackerControlSchema = z7.object({
|
|
944
1143
|
actionId: identifier,
|
|
945
|
-
action:
|
|
1144
|
+
action: z7.enum(["pause", "resume", "refresh"])
|
|
946
1145
|
}).strict();
|
|
947
|
-
var trackerAccountSchema =
|
|
1146
|
+
var trackerAccountSchema = z7.strictObject({
|
|
948
1147
|
kind: identityKindSchema.optional(),
|
|
949
1148
|
id: externalId
|
|
950
1149
|
});
|
|
951
|
-
var trackerRecordInputSchema =
|
|
1150
|
+
var trackerRecordInputSchema = z7.object({
|
|
952
1151
|
id: externalId,
|
|
953
1152
|
occurredAt: timestamp,
|
|
954
1153
|
observedAt: timestamp,
|
|
955
|
-
author:
|
|
1154
|
+
author: z7.object({
|
|
956
1155
|
id: externalId,
|
|
957
|
-
verified:
|
|
1156
|
+
verified: z7.boolean().nullable().default(null),
|
|
958
1157
|
/** The author's identity kind; needed when the source names more than one. */
|
|
959
1158
|
kind: identityKindSchema.optional()
|
|
960
1159
|
}).strict().nullable().default(null),
|
|
961
1160
|
/** Named accounts besides the author, by the roles the custom source declares. */
|
|
962
|
-
accounts:
|
|
1161
|
+
accounts: z7.record(accountRoleSchema, trackerAccountSchema).refine(
|
|
963
1162
|
(accounts) => Object.keys(accounts).length <= 10,
|
|
964
1163
|
"At most 10 accounts"
|
|
965
1164
|
).optional(),
|
|
966
|
-
data:
|
|
967
|
-
removed:
|
|
1165
|
+
data: z7.record(z7.string(), z7.json()),
|
|
1166
|
+
removed: z7.boolean().default(false)
|
|
968
1167
|
}).strict().refine(
|
|
969
1168
|
(v) => new TextEncoder().encode(JSON.stringify(v.data)).byteLength <= 131072,
|
|
970
1169
|
"Record exceeds 128 KB"
|
|
971
1170
|
);
|
|
972
|
-
var trackerRecordAccountSchema =
|
|
1171
|
+
var trackerRecordAccountSchema = z7.object({
|
|
973
1172
|
kind: openIdentityKindSchema.optional(),
|
|
974
|
-
id:
|
|
1173
|
+
id: z7.string()
|
|
975
1174
|
});
|
|
976
|
-
var trackerRecordSchema =
|
|
977
|
-
id:
|
|
1175
|
+
var trackerRecordSchema = z7.object({
|
|
1176
|
+
id: z7.string(),
|
|
978
1177
|
occurredAt: timestamp,
|
|
979
1178
|
observedAt: timestamp,
|
|
980
|
-
author:
|
|
981
|
-
id:
|
|
982
|
-
verified:
|
|
1179
|
+
author: z7.object({
|
|
1180
|
+
id: z7.string(),
|
|
1181
|
+
verified: z7.boolean().nullable().default(null),
|
|
983
1182
|
kind: openIdentityKindSchema.optional()
|
|
984
1183
|
}).nullable().default(null),
|
|
985
|
-
accounts:
|
|
986
|
-
data:
|
|
987
|
-
removed:
|
|
988
|
-
source:
|
|
1184
|
+
accounts: z7.record(z7.string(), trackerRecordAccountSchema).optional(),
|
|
1185
|
+
data: z7.record(z7.string(), z7.json()),
|
|
1186
|
+
removed: z7.boolean().default(false),
|
|
1187
|
+
source: z7.string(),
|
|
989
1188
|
firstSeenAt: timestamp,
|
|
990
1189
|
/** Present only when includeEvidence is true; custom sources have no X evidence. */
|
|
991
1190
|
evidence: trackerEvidenceSchema.nullable().optional()
|
|
992
1191
|
});
|
|
993
|
-
var trackerIngestSchema =
|
|
1192
|
+
var trackerIngestSchema = z7.object({
|
|
994
1193
|
actionId: identifier,
|
|
995
|
-
records:
|
|
1194
|
+
records: z7.array(trackerRecordInputSchema).min(1).max(100)
|
|
996
1195
|
}).strict();
|
|
997
|
-
var trackerIngestResultSchema =
|
|
1196
|
+
var trackerIngestResultSchema = z7.object({
|
|
998
1197
|
stored: count,
|
|
999
1198
|
/** Tracker-trigger decisions this ingest caused. Absent from servers without tracker triggers. */
|
|
1000
|
-
admissions:
|
|
1199
|
+
admissions: z7.object({
|
|
1001
1200
|
admitted: count,
|
|
1002
1201
|
skipped: count,
|
|
1003
1202
|
/**
|
|
@@ -1018,11 +1217,11 @@ var trackerOutcomeFields = {
|
|
|
1018
1217
|
/** The release admitted, or the one active when the observation was skipped. */
|
|
1019
1218
|
release: identifier,
|
|
1020
1219
|
/** The account attribution resolved or failed to resolve, such as a CAIP-10 wallet ID. */
|
|
1021
|
-
account:
|
|
1220
|
+
account: z7.string().nullable(),
|
|
1022
1221
|
createdAt: timestamp,
|
|
1023
1222
|
updatedAt: timestamp,
|
|
1024
1223
|
/** Null for automatic decisions; the staff actor after a retry. */
|
|
1025
|
-
actor:
|
|
1224
|
+
actor: z7.string().nullable()
|
|
1026
1225
|
};
|
|
1027
1226
|
var trackerSkipCodes = [
|
|
1028
1227
|
/** The quest is paused or no longer active. Catch-up after a pause is an operator decision. */
|
|
@@ -1077,26 +1276,26 @@ var trackerSkipCodes = [
|
|
|
1077
1276
|
/** A prerequisite quest was not complete when the record occurred. */
|
|
1078
1277
|
"prerequisites-incomplete"
|
|
1079
1278
|
];
|
|
1080
|
-
var trackerOutcomeSchema =
|
|
1081
|
-
|
|
1279
|
+
var trackerOutcomeSchema = z7.discriminatedUnion("state", [
|
|
1280
|
+
z7.object({
|
|
1082
1281
|
...trackerOutcomeFields,
|
|
1083
|
-
state:
|
|
1084
|
-
code:
|
|
1085
|
-
reason:
|
|
1282
|
+
state: z7.literal("admitted"),
|
|
1283
|
+
code: z7.null(),
|
|
1284
|
+
reason: z7.null(),
|
|
1086
1285
|
/** The attributed member. */
|
|
1087
1286
|
member: identifier,
|
|
1088
1287
|
/** The admitted attempt. Its evaluation, decision and rewards live on the attempt. */
|
|
1089
1288
|
attempt: identifier
|
|
1090
1289
|
}),
|
|
1091
|
-
|
|
1290
|
+
z7.object({
|
|
1092
1291
|
...trackerOutcomeFields,
|
|
1093
|
-
state:
|
|
1292
|
+
state: z7.literal("skipped"),
|
|
1094
1293
|
/** Why the observation was skipped, as one of `trackerSkipCodes`. */
|
|
1095
|
-
code:
|
|
1294
|
+
code: z7.string().min(1),
|
|
1096
1295
|
/** Why the observation was skipped, for people. */
|
|
1097
|
-
reason:
|
|
1296
|
+
reason: z7.string(),
|
|
1098
1297
|
/** Which window refused admission when `code` is `outside-window`. */
|
|
1099
|
-
window:
|
|
1298
|
+
window: z7.enum(["tracker", "quest"]).optional(),
|
|
1100
1299
|
/** The attributed member, when attribution got that far. */
|
|
1101
1300
|
member: identifier.nullable(),
|
|
1102
1301
|
attempt: identifier.nullable()
|
|
@@ -1107,67 +1306,67 @@ var trackerOutcomeFilters = {
|
|
|
1107
1306
|
quest: identifier.optional(),
|
|
1108
1307
|
record: externalId.optional(),
|
|
1109
1308
|
member: identifier.optional(),
|
|
1110
|
-
state:
|
|
1309
|
+
state: z7.enum(["admitted", "skipped"]).optional(),
|
|
1111
1310
|
/** Only skips with this code, such as `unlinked-account`. */
|
|
1112
|
-
code:
|
|
1113
|
-
limit:
|
|
1311
|
+
code: z7.string().min(1).max(100).optional(),
|
|
1312
|
+
limit: z7.coerce.number().int().min(1).max(100).default(25)
|
|
1114
1313
|
};
|
|
1115
|
-
var trackerTriggerOutcomeQuerySchema =
|
|
1314
|
+
var trackerTriggerOutcomeQuerySchema = z7.strictObject({
|
|
1116
1315
|
...trackerOutcomeFilters,
|
|
1117
1316
|
cursor: pageCursorSchema.optional()
|
|
1118
1317
|
});
|
|
1119
|
-
var trackerTriggerOutcomePageSchema =
|
|
1120
|
-
items:
|
|
1318
|
+
var trackerTriggerOutcomePageSchema = z7.object({
|
|
1319
|
+
items: z7.array(trackerOutcomeSchema).max(100),
|
|
1121
1320
|
nextCursor: pageCursorSchema.nullable()
|
|
1122
1321
|
});
|
|
1123
|
-
var trackerOutcomeQuerySchema =
|
|
1322
|
+
var trackerOutcomeQuerySchema = z7.strictObject({
|
|
1124
1323
|
...trackerOutcomeFilters,
|
|
1125
1324
|
/** Opaque cursor from `next`: older outcomes. */
|
|
1126
|
-
before:
|
|
1325
|
+
before: z7.string().max(512).optional()
|
|
1127
1326
|
});
|
|
1128
|
-
var trackerOutcomePageSchema =
|
|
1327
|
+
var trackerOutcomePageSchema = z7.strictObject({
|
|
1129
1328
|
/** Newest first. */
|
|
1130
|
-
items:
|
|
1131
|
-
next:
|
|
1329
|
+
items: z7.array(trackerOutcomeSchema).max(100),
|
|
1330
|
+
next: z7.string().nullable()
|
|
1132
1331
|
});
|
|
1133
|
-
var trackerOutcomeRetrySchema =
|
|
1332
|
+
var trackerOutcomeRetrySchema = z7.strictObject({
|
|
1134
1333
|
actionId: identifier,
|
|
1135
1334
|
/** Quest key or ID. */
|
|
1136
1335
|
quest: identifier,
|
|
1137
1336
|
record: externalId,
|
|
1138
1337
|
observedAt: timestamp
|
|
1139
1338
|
});
|
|
1140
|
-
var booleanQuery =
|
|
1141
|
-
|
|
1142
|
-
|
|
1339
|
+
var booleanQuery = z7.union([
|
|
1340
|
+
z7.boolean(),
|
|
1341
|
+
z7.enum(["true", "false"]).transform((v) => v === "true")
|
|
1143
1342
|
]);
|
|
1144
|
-
var trackerQuerySchema =
|
|
1343
|
+
var trackerQuerySchema = z7.object({
|
|
1145
1344
|
author: externalId.optional(),
|
|
1146
1345
|
member: identifier.optional(),
|
|
1147
1346
|
verified: booleanQuery.optional(),
|
|
1148
|
-
since:
|
|
1149
|
-
until:
|
|
1347
|
+
since: z7.coerce.number().int().safe().nonnegative().optional(),
|
|
1348
|
+
until: z7.coerce.number().int().safe().nonnegative().optional(),
|
|
1150
1349
|
removed: booleanQuery.default(false),
|
|
1151
|
-
minLikes:
|
|
1152
|
-
minViews:
|
|
1153
|
-
limit:
|
|
1154
|
-
cursor:
|
|
1350
|
+
minLikes: z7.coerce.number().int().safe().nonnegative().optional(),
|
|
1351
|
+
minViews: z7.coerce.number().int().safe().nonnegative().optional(),
|
|
1352
|
+
limit: z7.coerce.number().int().min(1).max(100).default(25),
|
|
1353
|
+
cursor: z7.string().max(2048).optional(),
|
|
1155
1354
|
includeEvidence: booleanQuery.optional()
|
|
1156
1355
|
}).strict().refine(
|
|
1157
1356
|
(q) => q.since === void 0 || q.until === void 0 || q.until > q.since,
|
|
1158
1357
|
"Until must follow since"
|
|
1159
1358
|
);
|
|
1160
|
-
var trackerPageSchema =
|
|
1359
|
+
var trackerPageSchema = z7.object({
|
|
1161
1360
|
tracker: identifier,
|
|
1162
|
-
items:
|
|
1163
|
-
nextCursor:
|
|
1361
|
+
items: z7.array(trackerRecordSchema),
|
|
1362
|
+
nextCursor: z7.string().nullable(),
|
|
1164
1363
|
total: count,
|
|
1165
1364
|
status: trackerStatusSchema
|
|
1166
1365
|
});
|
|
1167
|
-
var trackerSummarySchema =
|
|
1366
|
+
var trackerSummarySchema = z7.object({
|
|
1168
1367
|
records: count,
|
|
1169
1368
|
authors: count,
|
|
1170
|
-
metrics:
|
|
1369
|
+
metrics: z7.object({
|
|
1171
1370
|
likes: count,
|
|
1172
1371
|
replies: count,
|
|
1173
1372
|
reposts: count,
|
|
@@ -1183,26 +1382,26 @@ var trackerPreviewLimits = {
|
|
|
1183
1382
|
posts: 100,
|
|
1184
1383
|
days: 30
|
|
1185
1384
|
};
|
|
1186
|
-
var trackerPreviewInputSchema =
|
|
1385
|
+
var trackerPreviewInputSchema = z7.object({
|
|
1187
1386
|
query: xSearchSourceSchema.shape.query,
|
|
1188
1387
|
/** Start of the searched window. The window ends when the sample is fetched. */
|
|
1189
1388
|
since: timestamp
|
|
1190
1389
|
}).strict();
|
|
1191
|
-
var trackerPreviewSchema =
|
|
1192
|
-
query:
|
|
1390
|
+
var trackerPreviewSchema = z7.object({
|
|
1391
|
+
query: z7.string(),
|
|
1193
1392
|
since: timestamp,
|
|
1194
1393
|
fetchedAt: timestamp,
|
|
1195
1394
|
pages: count,
|
|
1196
1395
|
/** Every match in the sample, newest first, verified or not. */
|
|
1197
|
-
posts:
|
|
1396
|
+
posts: z7.array(xTweetSchema).max(trackerPreviewLimits.posts),
|
|
1198
1397
|
/** X had more matches than the sample holds. */
|
|
1199
|
-
more:
|
|
1398
|
+
more: z7.boolean()
|
|
1200
1399
|
});
|
|
1201
1400
|
|
|
1202
1401
|
// src/content.ts
|
|
1203
|
-
import { z as
|
|
1204
|
-
var contentQualificationDecisionSchema =
|
|
1205
|
-
kind:
|
|
1402
|
+
import { z as z8 } from "zod";
|
|
1403
|
+
var contentQualificationDecisionSchema = z8.strictObject({
|
|
1404
|
+
kind: z8.enum([
|
|
1206
1405
|
"accept",
|
|
1207
1406
|
"reject",
|
|
1208
1407
|
"review",
|
|
@@ -1210,26 +1409,26 @@ var contentQualificationDecisionSchema = z7.strictObject({
|
|
|
1210
1409
|
"progress",
|
|
1211
1410
|
"superseded"
|
|
1212
1411
|
]),
|
|
1213
|
-
reason:
|
|
1412
|
+
reason: z8.string().nullable()
|
|
1214
1413
|
});
|
|
1215
|
-
var contentQualificationQuerySchema =
|
|
1414
|
+
var contentQualificationQuerySchema = z8.strictObject({
|
|
1216
1415
|
quest: identifier,
|
|
1217
1416
|
member: identifier.optional(),
|
|
1218
1417
|
/** A content item's record ID in the quest's tracker. */
|
|
1219
|
-
content:
|
|
1418
|
+
content: z8.string().min(1).max(256).optional(),
|
|
1220
1419
|
cursor: pageCursorSchema.optional()
|
|
1221
1420
|
});
|
|
1222
|
-
var contentQualificationSchema =
|
|
1421
|
+
var contentQualificationSchema = z8.strictObject({
|
|
1223
1422
|
quest: identifier,
|
|
1224
1423
|
/** The content item's record ID in the quest's tracker. */
|
|
1225
|
-
content:
|
|
1424
|
+
content: z8.string(),
|
|
1226
1425
|
member: identifier,
|
|
1227
1426
|
release: identifier,
|
|
1228
1427
|
attempt: identifier,
|
|
1229
1428
|
revision: identifier,
|
|
1230
1429
|
observation: identifier,
|
|
1231
|
-
current:
|
|
1232
|
-
state:
|
|
1430
|
+
current: z8.boolean(),
|
|
1431
|
+
state: z8.enum([
|
|
1233
1432
|
"pending",
|
|
1234
1433
|
"qualified",
|
|
1235
1434
|
"unqualified",
|
|
@@ -1240,117 +1439,117 @@ var contentQualificationSchema = z7.strictObject({
|
|
|
1240
1439
|
"blocked",
|
|
1241
1440
|
"unavailable"
|
|
1242
1441
|
]),
|
|
1243
|
-
reason:
|
|
1244
|
-
reward:
|
|
1442
|
+
reason: z8.string().nullable(),
|
|
1443
|
+
reward: z8.strictObject({
|
|
1245
1444
|
attempt: identifier.nullable(),
|
|
1246
1445
|
completion: identifier.nullable(),
|
|
1247
|
-
state:
|
|
1446
|
+
state: z8.enum(["unresolved", "awarded", "excluded"])
|
|
1248
1447
|
})
|
|
1249
1448
|
});
|
|
1250
|
-
var contentQualificationPageSchema =
|
|
1251
|
-
items:
|
|
1449
|
+
var contentQualificationPageSchema = z8.strictObject({
|
|
1450
|
+
items: z8.array(contentQualificationSchema),
|
|
1252
1451
|
nextCursor: pageCursorSchema.nullable()
|
|
1253
1452
|
});
|
|
1254
1453
|
var contentMetricSchema = contentMetricNameSchema;
|
|
1255
|
-
var contentMetricsSchema =
|
|
1454
|
+
var contentMetricsSchema = z8.record(
|
|
1256
1455
|
contentMetricSchema,
|
|
1257
|
-
|
|
1456
|
+
z8.number().int().safe().nonnegative()
|
|
1258
1457
|
);
|
|
1259
|
-
var contentPerformancePolicySchema =
|
|
1260
|
-
metrics:
|
|
1261
|
-
(
|
|
1458
|
+
var contentPerformancePolicySchema = z8.strictObject({
|
|
1459
|
+
metrics: z8.array(contentMetricSchema).min(1).max(10).refine(
|
|
1460
|
+
(values2) => new Set(values2).size === values2.length,
|
|
1262
1461
|
"Metrics must be unique"
|
|
1263
1462
|
),
|
|
1264
|
-
maxAgeMs:
|
|
1463
|
+
maxAgeMs: z8.number().int().positive().max(864e5).default(36e5)
|
|
1265
1464
|
});
|
|
1266
1465
|
|
|
1267
1466
|
// src/counters.ts
|
|
1268
|
-
import { z as
|
|
1467
|
+
import { z as z9 } from "zod";
|
|
1269
1468
|
var day = 864e5;
|
|
1270
|
-
var counterGoalSchema =
|
|
1271
|
-
kind:
|
|
1272
|
-
count:
|
|
1469
|
+
var counterGoalSchema = z9.object({
|
|
1470
|
+
kind: z9.literal("count"),
|
|
1471
|
+
count: z9.number().int().min(1).max(1e4)
|
|
1273
1472
|
}).strict();
|
|
1274
|
-
var counterWindowSchema =
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
kind:
|
|
1278
|
-
period:
|
|
1279
|
-
latenessMs:
|
|
1473
|
+
var counterWindowSchema = z9.discriminatedUnion("kind", [
|
|
1474
|
+
z9.object({ kind: z9.literal("lifetime") }).strict(),
|
|
1475
|
+
z9.object({
|
|
1476
|
+
kind: z9.literal("calendar"),
|
|
1477
|
+
period: z9.enum(["day", "week", "month"]),
|
|
1478
|
+
latenessMs: z9.number().int().min(0).max(90 * day).default(7 * day)
|
|
1280
1479
|
}).strict(),
|
|
1281
|
-
|
|
1282
|
-
kind:
|
|
1283
|
-
durationMs:
|
|
1480
|
+
z9.object({
|
|
1481
|
+
kind: z9.literal("rolling"),
|
|
1482
|
+
durationMs: z9.number().int().min(1).max(365 * day)
|
|
1284
1483
|
}).strict()
|
|
1285
1484
|
]);
|
|
1286
|
-
var counterPolicySchema =
|
|
1287
|
-
kind:
|
|
1485
|
+
var counterPolicySchema = z9.object({
|
|
1486
|
+
kind: z9.literal("progress"),
|
|
1288
1487
|
goal: counterGoalSchema,
|
|
1289
1488
|
window: counterWindowSchema,
|
|
1290
|
-
repeat:
|
|
1489
|
+
repeat: z9.enum(["once", "repeat"]).default("once")
|
|
1291
1490
|
}).strict();
|
|
1292
|
-
var achievementBase =
|
|
1491
|
+
var achievementBase = z9.object({
|
|
1293
1492
|
id: identifier,
|
|
1294
|
-
ordinal:
|
|
1295
|
-
achievedAt:
|
|
1296
|
-
window:
|
|
1493
|
+
ordinal: z9.number().int().positive(),
|
|
1494
|
+
achievedAt: z9.number().int(),
|
|
1495
|
+
window: z9.string()
|
|
1297
1496
|
});
|
|
1298
|
-
var counterAchievementSchema =
|
|
1497
|
+
var counterAchievementSchema = z9.discriminatedUnion("status", [
|
|
1299
1498
|
achievementBase.extend({
|
|
1300
|
-
status:
|
|
1499
|
+
status: z9.literal("revoked"),
|
|
1301
1500
|
completion: identifier,
|
|
1302
|
-
revokedAt:
|
|
1501
|
+
revokedAt: z9.number().int()
|
|
1303
1502
|
}),
|
|
1304
1503
|
achievementBase.extend({
|
|
1305
|
-
status:
|
|
1504
|
+
status: z9.literal("awarded"),
|
|
1306
1505
|
completion: identifier
|
|
1307
1506
|
}),
|
|
1308
1507
|
achievementBase.extend({
|
|
1309
|
-
status:
|
|
1508
|
+
status: z9.literal("budget-exhausted"),
|
|
1310
1509
|
budget: identifier
|
|
1311
1510
|
})
|
|
1312
1511
|
]);
|
|
1313
|
-
var counterProgressSchema =
|
|
1314
|
-
goal:
|
|
1315
|
-
current:
|
|
1316
|
-
window:
|
|
1317
|
-
key:
|
|
1318
|
-
start:
|
|
1319
|
-
end:
|
|
1512
|
+
var counterProgressSchema = z9.object({
|
|
1513
|
+
goal: z9.number().int().positive(),
|
|
1514
|
+
current: z9.number().int().nonnegative(),
|
|
1515
|
+
window: z9.object({
|
|
1516
|
+
key: z9.string(),
|
|
1517
|
+
start: z9.number().int().nullable(),
|
|
1518
|
+
end: z9.number().int().nullable()
|
|
1320
1519
|
}),
|
|
1321
|
-
repeat:
|
|
1322
|
-
settled:
|
|
1520
|
+
repeat: z9.enum(["once", "repeat"]),
|
|
1521
|
+
settled: z9.number().int().nonnegative(),
|
|
1323
1522
|
latest: counterAchievementSchema.nullable()
|
|
1324
1523
|
});
|
|
1325
|
-
var counterContributionSchema =
|
|
1524
|
+
var counterContributionSchema = z9.object({
|
|
1326
1525
|
id: identifier,
|
|
1327
|
-
distinct:
|
|
1526
|
+
distinct: z9.string(),
|
|
1328
1527
|
attempt: identifier,
|
|
1329
|
-
occurredAt:
|
|
1330
|
-
recordedAt:
|
|
1331
|
-
window:
|
|
1332
|
-
status:
|
|
1528
|
+
occurredAt: z9.number().int(),
|
|
1529
|
+
recordedAt: z9.number().int(),
|
|
1530
|
+
window: z9.string(),
|
|
1531
|
+
status: z9.enum(["counted", "late", "future", "excluded"]),
|
|
1333
1532
|
achievement: counterAchievementSchema.nullable(),
|
|
1334
|
-
reason:
|
|
1533
|
+
reason: z9.string().nullable()
|
|
1335
1534
|
});
|
|
1336
|
-
var counterHistorySchema =
|
|
1337
|
-
items:
|
|
1338
|
-
nextCursor:
|
|
1535
|
+
var counterHistorySchema = z9.object({
|
|
1536
|
+
items: z9.array(counterContributionSchema),
|
|
1537
|
+
nextCursor: z9.string().nullable()
|
|
1339
1538
|
});
|
|
1340
|
-
var counterModerationSchema =
|
|
1341
|
-
actionId:
|
|
1342
|
-
excluded:
|
|
1343
|
-
reason:
|
|
1539
|
+
var counterModerationSchema = z9.object({
|
|
1540
|
+
actionId: z9.uuid(),
|
|
1541
|
+
excluded: z9.boolean(),
|
|
1542
|
+
reason: z9.string().trim().min(1).max(2e3)
|
|
1344
1543
|
}).strict();
|
|
1345
|
-
var counterHistoryQuerySchema =
|
|
1346
|
-
cursor:
|
|
1347
|
-
limit:
|
|
1544
|
+
var counterHistoryQuerySchema = z9.object({
|
|
1545
|
+
cursor: z9.string().max(2e3).optional(),
|
|
1546
|
+
limit: z9.coerce.number().int().min(1).max(100).optional()
|
|
1348
1547
|
}).strict();
|
|
1349
|
-
var counterModerationResultSchema =
|
|
1548
|
+
var counterModerationResultSchema = z9.object({ excluded: z9.boolean() });
|
|
1350
1549
|
|
|
1351
1550
|
// src/calendar.ts
|
|
1352
|
-
import { z as
|
|
1353
|
-
var timestamp2 =
|
|
1551
|
+
import { z as z10 } from "zod";
|
|
1552
|
+
var timestamp2 = z10.number().int().safe();
|
|
1354
1553
|
var fixedOffset = /^(?:[+-]|(?:Etc\/)?GMT[+-]\d|(?:EST|MST|HST)$)/i;
|
|
1355
1554
|
function canonicalTimeZone(zone) {
|
|
1356
1555
|
let resolved;
|
|
@@ -1366,18 +1565,18 @@ function canonicalTimeZone(zone) {
|
|
|
1366
1565
|
}
|
|
1367
1566
|
return fixedOffset.test(zone) || fixedOffset.test(resolved) ? null : resolved;
|
|
1368
1567
|
}
|
|
1369
|
-
var timeZoneSchema =
|
|
1568
|
+
var timeZoneSchema = z10.string().min(1).max(100).transform((zone, ctx) => {
|
|
1370
1569
|
const canonical = canonicalTimeZone(zone);
|
|
1371
1570
|
if (canonical === null) {
|
|
1372
1571
|
ctx.addIssue({
|
|
1373
1572
|
code: "custom",
|
|
1374
1573
|
message: fixedOffset.test(zone) ? "Use a named IANA timezone, such as Europe/Budapest or UTC. Fixed offsets have no daylight-saving rules." : "Use an IANA timezone name, such as Europe/Budapest or UTC"
|
|
1375
1574
|
});
|
|
1376
|
-
return
|
|
1575
|
+
return z10.NEVER;
|
|
1377
1576
|
}
|
|
1378
1577
|
return canonical;
|
|
1379
1578
|
});
|
|
1380
|
-
var timeZoneNameSchema =
|
|
1579
|
+
var timeZoneNameSchema = z10.string().min(1).max(100);
|
|
1381
1580
|
var movedTimeZone = (what) => `${what} no longer take a timeZone: they follow the project calendar. Set calendar.timeZone in relay.json or in Console settings.`;
|
|
1382
1581
|
var record = (value) => typeof value === "object" && value !== null;
|
|
1383
1582
|
function refuseStreakTimeZone(value, ctx) {
|
|
@@ -1401,78 +1600,78 @@ function refuseWindowTimeZone(value, ctx) {
|
|
|
1401
1600
|
}
|
|
1402
1601
|
return value;
|
|
1403
1602
|
}
|
|
1404
|
-
var calendarPeriodSchema =
|
|
1405
|
-
var projectCalendarSchema =
|
|
1603
|
+
var calendarPeriodSchema = z10.enum(["lifetime", "day", "week", "month"]);
|
|
1604
|
+
var projectCalendarSchema = z10.object({
|
|
1406
1605
|
/** The timezone of the current calendar day. */
|
|
1407
1606
|
timeZone: timeZoneNameSchema,
|
|
1408
1607
|
/** The current calendar date, such as `2026-10-01`. */
|
|
1409
|
-
today:
|
|
1608
|
+
today: z10.string(),
|
|
1410
1609
|
/** When the current calendar day ends, in epoch milliseconds. */
|
|
1411
1610
|
nextBoundary: timestamp2,
|
|
1412
1611
|
/** A change that takes effect at the next day boundary, or null. */
|
|
1413
|
-
pending:
|
|
1612
|
+
pending: z10.object({ timeZone: timeZoneNameSchema, effectiveAt: timestamp2 }).nullable(),
|
|
1414
1613
|
/** The `calendar.timeZone` the last deployment that declared one set, or null. */
|
|
1415
1614
|
declared: timeZoneNameSchema.nullable(),
|
|
1416
1615
|
/**
|
|
1417
1616
|
* A stored timezone the calendar no longer accepts, such as a fixed offset a streak named before
|
|
1418
1617
|
* v1. The calendar reads it as UTC until an operator chooses a timezone. Null otherwise.
|
|
1419
1618
|
*/
|
|
1420
|
-
unsupported:
|
|
1619
|
+
unsupported: z10.string().nullable().default(null)
|
|
1421
1620
|
});
|
|
1422
|
-
var projectCalendarInputSchema =
|
|
1621
|
+
var projectCalendarInputSchema = z10.object({
|
|
1423
1622
|
actionId: identifier,
|
|
1424
1623
|
timeZone: timeZoneSchema,
|
|
1425
|
-
reason:
|
|
1624
|
+
reason: z10.string().trim().min(1).max(500)
|
|
1426
1625
|
}).strict();
|
|
1427
|
-
var projectCalendarDeclarationSchema =
|
|
1626
|
+
var projectCalendarDeclarationSchema = z10.object({ timeZone: timeZoneSchema }).strict();
|
|
1428
1627
|
|
|
1429
1628
|
// src/streaks.ts
|
|
1430
|
-
import { z as
|
|
1431
|
-
var streakPolicySchema =
|
|
1432
|
-
kind:
|
|
1433
|
-
days:
|
|
1434
|
-
});
|
|
1435
|
-
var streakProgressSchema =
|
|
1436
|
-
goal:
|
|
1437
|
-
current:
|
|
1438
|
-
best:
|
|
1439
|
-
today:
|
|
1440
|
-
todayQualified:
|
|
1629
|
+
import { z as z11 } from "zod";
|
|
1630
|
+
var streakPolicySchema = z11.object({
|
|
1631
|
+
kind: z11.literal("streak"),
|
|
1632
|
+
days: z11.number().int().min(1).max(3650)
|
|
1633
|
+
});
|
|
1634
|
+
var streakProgressSchema = z11.object({
|
|
1635
|
+
goal: z11.number().int().positive(),
|
|
1636
|
+
current: z11.number().int().nonnegative(),
|
|
1637
|
+
best: z11.number().int().nonnegative(),
|
|
1638
|
+
today: z11.string(),
|
|
1639
|
+
todayQualified: z11.boolean(),
|
|
1441
1640
|
timeZone: timeZoneNameSchema,
|
|
1442
|
-
nextBoundary:
|
|
1443
|
-
pendingTimeZone:
|
|
1641
|
+
nextBoundary: z11.number().int(),
|
|
1642
|
+
pendingTimeZone: z11.object({
|
|
1444
1643
|
timeZone: timeZoneNameSchema,
|
|
1445
|
-
effectiveAt:
|
|
1644
|
+
effectiveAt: z11.number().int()
|
|
1446
1645
|
}).nullable(),
|
|
1447
|
-
days:
|
|
1448
|
-
|
|
1449
|
-
day:
|
|
1450
|
-
date:
|
|
1646
|
+
days: z11.array(
|
|
1647
|
+
z11.object({
|
|
1648
|
+
day: z11.number().int(),
|
|
1649
|
+
date: z11.string(),
|
|
1451
1650
|
// The zone the day was recorded in, as stored: days from before v1 can name a fixed offset.
|
|
1452
|
-
timeZone:
|
|
1453
|
-
occurredAt:
|
|
1651
|
+
timeZone: z11.string(),
|
|
1652
|
+
occurredAt: z11.number().int()
|
|
1454
1653
|
})
|
|
1455
1654
|
),
|
|
1456
|
-
milestone:
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
status:
|
|
1460
|
-
completion:
|
|
1461
|
-
achievedAt:
|
|
1655
|
+
milestone: z11.discriminatedUnion("status", [
|
|
1656
|
+
z11.object({ status: z11.literal("pending") }),
|
|
1657
|
+
z11.object({
|
|
1658
|
+
status: z11.literal("awarded"),
|
|
1659
|
+
completion: z11.string(),
|
|
1660
|
+
achievedAt: z11.number().int()
|
|
1462
1661
|
}),
|
|
1463
|
-
|
|
1464
|
-
status:
|
|
1465
|
-
budget:
|
|
1466
|
-
achievedAt:
|
|
1662
|
+
z11.object({
|
|
1663
|
+
status: z11.literal("budget-exhausted"),
|
|
1664
|
+
budget: z11.string(),
|
|
1665
|
+
achievedAt: z11.number().int()
|
|
1467
1666
|
})
|
|
1468
1667
|
])
|
|
1469
1668
|
});
|
|
1470
1669
|
|
|
1471
1670
|
// src/tracker-triggers.ts
|
|
1472
|
-
import { z as
|
|
1473
|
-
var timestamp3 =
|
|
1474
|
-
var count2 =
|
|
1475
|
-
var trackerTriggerModeSchema =
|
|
1671
|
+
import { z as z12 } from "zod";
|
|
1672
|
+
var timestamp3 = z12.number().int().safe().nonnegative().max(864e13);
|
|
1673
|
+
var count2 = z12.number().int().safe().nonnegative();
|
|
1674
|
+
var trackerTriggerModeSchema = z12.enum([
|
|
1476
1675
|
"new-record",
|
|
1477
1676
|
"new-observation",
|
|
1478
1677
|
"data-changed"
|
|
@@ -1480,20 +1679,20 @@ var trackerTriggerModeSchema = z11.enum([
|
|
|
1480
1679
|
function defaultTriggerMode(source) {
|
|
1481
1680
|
return source === "custom" ? "new-observation" : "new-record";
|
|
1482
1681
|
}
|
|
1483
|
-
var trackerBoundSchema =
|
|
1484
|
-
|
|
1485
|
-
|
|
1682
|
+
var trackerBoundSchema = z12.union([
|
|
1683
|
+
z12.number().finite(),
|
|
1684
|
+
z12.strictObject({ setting: z12.string().regex(/^[a-zA-Z][a-zA-Z0-9_]*$/) })
|
|
1486
1685
|
]);
|
|
1487
|
-
var dataPath =
|
|
1686
|
+
var dataPath = z12.string().max(200).regex(
|
|
1488
1687
|
/^[^.\s]+(\.[^.\s]+)*$/,
|
|
1489
1688
|
"Use dot-separated keys, such as metrics.likes"
|
|
1490
1689
|
);
|
|
1491
|
-
var trackerConditionSchema =
|
|
1492
|
-
|
|
1690
|
+
var trackerConditionSchema = z12.union([
|
|
1691
|
+
z12.strictObject({
|
|
1493
1692
|
path: dataPath,
|
|
1494
|
-
equals:
|
|
1693
|
+
equals: z12.union([z12.string().max(1e3), z12.number().finite(), z12.boolean()])
|
|
1495
1694
|
}),
|
|
1496
|
-
|
|
1695
|
+
z12.strictObject({
|
|
1497
1696
|
path: dataPath,
|
|
1498
1697
|
gt: trackerBoundSchema.optional(),
|
|
1499
1698
|
gte: trackerBoundSchema.optional(),
|
|
@@ -1506,9 +1705,9 @@ var trackerConditionSchema = z11.union([
|
|
|
1506
1705
|
"Compare with equals, gt, gte, lt or lte"
|
|
1507
1706
|
)
|
|
1508
1707
|
]);
|
|
1509
|
-
var trackerWhereSchema =
|
|
1708
|
+
var trackerWhereSchema = z12.union([
|
|
1510
1709
|
trackerConditionSchema,
|
|
1511
|
-
|
|
1710
|
+
z12.array(trackerConditionSchema).min(1).max(10)
|
|
1512
1711
|
]);
|
|
1513
1712
|
function whereConditions(where) {
|
|
1514
1713
|
return where === void 0 ? [] : Array.isArray(where) ? where : [where];
|
|
@@ -1520,17 +1719,17 @@ function whereSettings(where) {
|
|
|
1520
1719
|
)
|
|
1521
1720
|
);
|
|
1522
1721
|
}
|
|
1523
|
-
var triggerEnrollmentSchema =
|
|
1524
|
-
var triggerSinceSchema =
|
|
1525
|
-
var triggerHistoricalSchema =
|
|
1526
|
-
var trackerTriggerPolicySchema =
|
|
1722
|
+
var triggerEnrollmentSchema = z12.enum(["none", "required"]);
|
|
1723
|
+
var triggerSinceSchema = z12.enum(["activation", "window", "enrollment"]);
|
|
1724
|
+
var triggerHistoricalSchema = z12.enum(["staff", "claim", "automatic"]);
|
|
1725
|
+
var trackerTriggerPolicySchema = z12.strictObject({
|
|
1527
1726
|
/** The tracker's authoring key; publication binds it to the tracker's stable ID. */
|
|
1528
1727
|
tracker: identifier,
|
|
1529
1728
|
/**
|
|
1530
1729
|
* The tracker's source kind, one of `trackerSourceKinds` today. An open string, so readers of
|
|
1531
1730
|
* releases keep parsing them when a later Relay adds a managed source.
|
|
1532
1731
|
*/
|
|
1533
|
-
source:
|
|
1732
|
+
source: z12.string().min(1).max(100),
|
|
1534
1733
|
/** Which observations fire. */
|
|
1535
1734
|
on: trackerTriggerModeSchema,
|
|
1536
1735
|
where: trackerWhereSchema.optional(),
|
|
@@ -1551,7 +1750,7 @@ var trackerTriggerPolicySchema = z11.strictObject({
|
|
|
1551
1750
|
* that re-evaluates edits and runs `performance`, firing on each new record and paying its
|
|
1552
1751
|
* author.
|
|
1553
1752
|
*/
|
|
1554
|
-
content:
|
|
1753
|
+
content: z12.literal(true).optional()
|
|
1555
1754
|
}).refine(
|
|
1556
1755
|
(policy) => policy.since !== "enrollment" || policy.enrollment === "required",
|
|
1557
1756
|
'since: "enrollment" needs enrollment: "required"'
|
|
@@ -1570,72 +1769,72 @@ function beneficiaryRole(policy) {
|
|
|
1570
1769
|
return policy.beneficiary;
|
|
1571
1770
|
}
|
|
1572
1771
|
var xLink = {
|
|
1573
|
-
issuer:
|
|
1772
|
+
issuer: z12.string().min(1),
|
|
1574
1773
|
/** The account's stable user ID. */
|
|
1575
|
-
subject:
|
|
1774
|
+
subject: z12.string().min(1).max(256),
|
|
1576
1775
|
/** The member's account selection revision. */
|
|
1577
1776
|
revision: count2,
|
|
1578
1777
|
/** When the member linked the account; null when unknown. */
|
|
1579
1778
|
linkedAt: timestamp3.nullable()
|
|
1580
1779
|
};
|
|
1581
|
-
var trackerAttributionSchema =
|
|
1780
|
+
var trackerAttributionSchema = z12.object({
|
|
1582
1781
|
member: identifier,
|
|
1583
1782
|
capturedAt: timestamp3,
|
|
1584
|
-
account:
|
|
1585
|
-
|
|
1586
|
-
provider:
|
|
1783
|
+
account: z12.union([
|
|
1784
|
+
z12.object({
|
|
1785
|
+
provider: z12.literal("wallet"),
|
|
1587
1786
|
/** Canonical CAIP-10 account ID, as the record names it. */
|
|
1588
|
-
id:
|
|
1787
|
+
id: z12.string().min(5).max(256),
|
|
1589
1788
|
/** The wallet link's revision. */
|
|
1590
1789
|
revision: count2,
|
|
1591
1790
|
/** When the member verified the wallet. */
|
|
1592
1791
|
linkedAt: timestamp3.nullable()
|
|
1593
1792
|
}),
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
provider:
|
|
1793
|
+
z12.object({ provider: z12.literal("x"), ...xLink }),
|
|
1794
|
+
z12.object({ provider: z12.literal("discord"), ...xLink }),
|
|
1795
|
+
z12.object({
|
|
1796
|
+
provider: z12.literal("member"),
|
|
1598
1797
|
/** The member ID the record names. */
|
|
1599
1798
|
id: identifier
|
|
1600
1799
|
}),
|
|
1601
|
-
|
|
1800
|
+
z12.object({
|
|
1602
1801
|
/** Your app's identity kind, such as `app:telegram`. */
|
|
1603
1802
|
provider: appIdentityKindSchema,
|
|
1604
1803
|
/** The subject your app signed the member in with, as the record names it. */
|
|
1605
|
-
subject:
|
|
1804
|
+
subject: z12.string().min(1).max(256),
|
|
1606
1805
|
/** The identity's revision in the project. */
|
|
1607
1806
|
revision: count2,
|
|
1608
1807
|
/** When the identity was linked to the member. */
|
|
1609
1808
|
linkedAt: timestamp3.nullable()
|
|
1610
1809
|
}),
|
|
1611
1810
|
/** A kind a later Relay adds. */
|
|
1612
|
-
|
|
1811
|
+
z12.object({ provider: z12.string().min(1) })
|
|
1613
1812
|
])
|
|
1614
1813
|
});
|
|
1615
|
-
var trackerTriggerRecordSchema =
|
|
1616
|
-
id:
|
|
1617
|
-
source:
|
|
1814
|
+
var trackerTriggerRecordSchema = z12.object({
|
|
1815
|
+
id: z12.string().min(1).max(256),
|
|
1816
|
+
source: z12.string(),
|
|
1618
1817
|
occurredAt: timestamp3,
|
|
1619
1818
|
observedAt: timestamp3,
|
|
1620
1819
|
firstSeenAt: timestamp3,
|
|
1621
|
-
author:
|
|
1622
|
-
id:
|
|
1623
|
-
verified:
|
|
1820
|
+
author: z12.object({
|
|
1821
|
+
id: z12.string().min(1).max(256),
|
|
1822
|
+
verified: z12.boolean().nullable(),
|
|
1624
1823
|
kind: openIdentityKindSchema.optional()
|
|
1625
1824
|
}).nullable(),
|
|
1626
|
-
accounts:
|
|
1627
|
-
data:
|
|
1628
|
-
removed:
|
|
1825
|
+
accounts: z12.record(accountRoleSchema, trackerRecordAccountSchema).optional(),
|
|
1826
|
+
data: z12.record(z12.string(), z12.json()),
|
|
1827
|
+
removed: z12.boolean()
|
|
1629
1828
|
});
|
|
1630
|
-
var trackerContentStageSchema =
|
|
1829
|
+
var trackerContentStageSchema = z12.object({
|
|
1631
1830
|
/** The body's revision: the hash of its canonical JSON. Edits make a new one. */
|
|
1632
1831
|
revision: identifier,
|
|
1633
1832
|
/** The captured observation that carried this body. */
|
|
1634
1833
|
observation: identifier,
|
|
1635
1834
|
/** The body: an X post's normalized body, or a custom record's `data.body`. */
|
|
1636
|
-
body:
|
|
1835
|
+
body: z12.record(z12.string(), z12.json())
|
|
1637
1836
|
});
|
|
1638
|
-
var trackerTriggerContextSchema =
|
|
1837
|
+
var trackerTriggerContextSchema = z12.object({
|
|
1639
1838
|
/** The tracker's stable ID. */
|
|
1640
1839
|
tracker: identifier,
|
|
1641
1840
|
/** The tracker's authoring key. */
|
|
@@ -1657,61 +1856,61 @@ var trackerTriggerContextSchema = z11.object({
|
|
|
1657
1856
|
});
|
|
1658
1857
|
|
|
1659
1858
|
// src/completion.ts
|
|
1660
|
-
import { z as
|
|
1661
|
-
var name =
|
|
1662
|
-
var completionPolicySchema =
|
|
1859
|
+
import { z as z13 } from "zod";
|
|
1860
|
+
var name = z13.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,199}$/);
|
|
1861
|
+
var completionPolicySchema = z13.discriminatedUnion("kind", [
|
|
1663
1862
|
streakPolicySchema,
|
|
1664
1863
|
counterPolicySchema,
|
|
1665
|
-
|
|
1666
|
-
|
|
1864
|
+
z13.object({ kind: z13.literal("once") }).strict(),
|
|
1865
|
+
z13.object({ kind: z13.literal("keyed") }).strict()
|
|
1667
1866
|
]);
|
|
1668
|
-
var completionKeySchema =
|
|
1669
|
-
var budgetSchema =
|
|
1867
|
+
var completionKeySchema = z13.string().min(1).max(500);
|
|
1868
|
+
var budgetSchema = z13.object({
|
|
1670
1869
|
id: name,
|
|
1671
|
-
scope:
|
|
1870
|
+
scope: z13.enum(["member", "project"]),
|
|
1672
1871
|
/**
|
|
1673
1872
|
* The project calendar period of the attempt's eligibility time that one bucket covers:
|
|
1674
1873
|
* `"day"`, `"week"` (ISO, starting on Monday) or `"month"` in the project timezone.
|
|
1675
1874
|
* `"lifetime"` never resets.
|
|
1676
1875
|
*/
|
|
1677
1876
|
period: calendarPeriodSchema,
|
|
1678
|
-
limit:
|
|
1679
|
-
cost:
|
|
1680
|
-
|
|
1681
|
-
|
|
1877
|
+
limit: z13.number().int().positive().max(Number.MAX_SAFE_INTEGER),
|
|
1878
|
+
cost: z13.union([
|
|
1879
|
+
z13.number().int().positive().max(Number.MAX_SAFE_INTEGER),
|
|
1880
|
+
z13.object({ balance: name }).strict()
|
|
1682
1881
|
])
|
|
1683
1882
|
}).strict();
|
|
1684
1883
|
|
|
1685
1884
|
// src/integrations.ts
|
|
1686
|
-
import { z as
|
|
1687
|
-
var evaluatorIntegrationProviderSchema =
|
|
1688
|
-
var integrationProviderSchema =
|
|
1689
|
-
var discordServerSchema =
|
|
1690
|
-
id:
|
|
1691
|
-
name:
|
|
1692
|
-
icon:
|
|
1693
|
-
});
|
|
1694
|
-
var projectIntegrationSchema =
|
|
1885
|
+
import { z as z14 } from "zod";
|
|
1886
|
+
var evaluatorIntegrationProviderSchema = z14.enum(["discord", "x"]);
|
|
1887
|
+
var integrationProviderSchema = z14.enum(["discord"]);
|
|
1888
|
+
var discordServerSchema = z14.object({
|
|
1889
|
+
id: z14.string().regex(/^[0-9]{1,20}$/),
|
|
1890
|
+
name: z14.string().min(1),
|
|
1891
|
+
icon: z14.string().nullable()
|
|
1892
|
+
});
|
|
1893
|
+
var projectIntegrationSchema = z14.object({
|
|
1695
1894
|
provider: integrationProviderSchema,
|
|
1696
|
-
configured:
|
|
1697
|
-
status:
|
|
1698
|
-
revision:
|
|
1895
|
+
configured: z14.boolean(),
|
|
1896
|
+
status: z14.enum(["disconnected", "ready", "attention"]),
|
|
1897
|
+
revision: z14.number().int().nonnegative(),
|
|
1699
1898
|
server: discordServerSchema.nullable(),
|
|
1700
|
-
issue:
|
|
1701
|
-
connectedAt:
|
|
1899
|
+
issue: z14.string().nullable(),
|
|
1900
|
+
connectedAt: z14.number().default(0)
|
|
1702
1901
|
});
|
|
1703
1902
|
|
|
1704
1903
|
// src/submission-input.ts
|
|
1705
|
-
import { z as
|
|
1706
|
-
var textOptionsSchema =
|
|
1707
|
-
required:
|
|
1708
|
-
minLength:
|
|
1709
|
-
maxLength:
|
|
1904
|
+
import { z as z15 } from "zod";
|
|
1905
|
+
var textOptionsSchema = z15.object({
|
|
1906
|
+
required: z15.boolean().default(true),
|
|
1907
|
+
minLength: z15.number().int().min(0).max(1e4).default(1),
|
|
1908
|
+
maxLength: z15.number().int().min(1).max(1e4).default(1e4)
|
|
1710
1909
|
}).strict().refine(
|
|
1711
1910
|
(v) => v.minLength <= v.maxLength,
|
|
1712
1911
|
"minLength must not exceed maxLength"
|
|
1713
1912
|
);
|
|
1714
|
-
var hostSchema =
|
|
1913
|
+
var hostSchema = z15.string().min(1).max(253).refine((host) => {
|
|
1715
1914
|
if (!/^[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?$/i.test(host) || host.includes("..")) {
|
|
1716
1915
|
return false;
|
|
1717
1916
|
}
|
|
@@ -1722,13 +1921,13 @@ var hostSchema = z14.string().min(1).max(253).refine((host) => {
|
|
|
1722
1921
|
return false;
|
|
1723
1922
|
}
|
|
1724
1923
|
}, "Use a hostname without a scheme, path, port, or wildcard");
|
|
1725
|
-
var urlOptionsSchema =
|
|
1726
|
-
required:
|
|
1727
|
-
allowedHosts:
|
|
1924
|
+
var urlOptionsSchema = z15.object({
|
|
1925
|
+
required: z15.boolean().default(true),
|
|
1926
|
+
allowedHosts: z15.array(hostSchema).min(1).max(100).optional()
|
|
1728
1927
|
}).strict();
|
|
1729
|
-
var textEvidenceSchema =
|
|
1730
|
-
var urlEvidenceSchema =
|
|
1731
|
-
var valueEvidenceSchema =
|
|
1928
|
+
var textEvidenceSchema = z15.object({ kind: z15.literal("text"), value: z15.string().max(1e4) }).strict();
|
|
1929
|
+
var urlEvidenceSchema = z15.object({ kind: z15.literal("url"), value: z15.string().max(2048) }).strict();
|
|
1930
|
+
var valueEvidenceSchema = z15.discriminatedUnion("kind", [
|
|
1732
1931
|
textEvidenceSchema,
|
|
1733
1932
|
urlEvidenceSchema
|
|
1734
1933
|
]);
|
|
@@ -1791,22 +1990,22 @@ function xPostId(value) {
|
|
|
1791
1990
|
}
|
|
1792
1991
|
|
|
1793
1992
|
// src/quiz.ts
|
|
1794
|
-
import { z as
|
|
1795
|
-
var quizId =
|
|
1796
|
-
var quizChoiceSchema =
|
|
1797
|
-
var quizQuestionSchema =
|
|
1993
|
+
import { z as z16 } from "zod";
|
|
1994
|
+
var quizId = z16.string().regex(/^[a-zA-Z0-9_-]+$/).max(100);
|
|
1995
|
+
var quizChoiceSchema = z16.object({ id: quizId, label: z16.string().trim().min(1).max(500) }).strict();
|
|
1996
|
+
var quizQuestionSchema = z16.object({
|
|
1798
1997
|
id: quizId,
|
|
1799
|
-
prompt:
|
|
1800
|
-
choices:
|
|
1998
|
+
prompt: z16.string().trim().min(1).max(1e3),
|
|
1999
|
+
choices: z16.array(quizChoiceSchema).min(2).max(8).refine(
|
|
1801
2000
|
(choices) => new Set(choices.map((choice) => choice.id)).size === choices.length,
|
|
1802
2001
|
"Choice IDs must be unique"
|
|
1803
2002
|
)
|
|
1804
2003
|
}).strict();
|
|
1805
|
-
var quizQuestionsSchema =
|
|
2004
|
+
var quizQuestionsSchema = z16.array(quizQuestionSchema).min(1).max(20).refine(
|
|
1806
2005
|
(questions) => new Set(questions.map((question) => question.id)).size === questions.length,
|
|
1807
2006
|
"Question IDs must be unique"
|
|
1808
2007
|
);
|
|
1809
|
-
var quizContentSchema =
|
|
2008
|
+
var quizContentSchema = z16.array(
|
|
1810
2009
|
quizQuestionSchema.extend({ correct: quizId }).refine(
|
|
1811
2010
|
(question) => question.choices.some((choice) => choice.id === question.correct),
|
|
1812
2011
|
"Choose a correct answer from the available choices"
|
|
@@ -1817,98 +2016,98 @@ var quizContentSchema = z15.array(
|
|
|
1817
2016
|
);
|
|
1818
2017
|
|
|
1819
2018
|
// src/resources.ts
|
|
1820
|
-
import { z as
|
|
1821
|
-
var resourceSourceSchema =
|
|
1822
|
-
|
|
1823
|
-
provider:
|
|
1824
|
-
resource:
|
|
2019
|
+
import { z as z17 } from "zod";
|
|
2020
|
+
var resourceSourceSchema = z17.union([
|
|
2021
|
+
z17.strictObject({
|
|
2022
|
+
provider: z17.literal("domino"),
|
|
2023
|
+
resource: z17.literal("point-ledger")
|
|
1825
2024
|
}),
|
|
1826
2025
|
discordResourceSourceSchema
|
|
1827
2026
|
]);
|
|
1828
|
-
var resourceRequestSchema =
|
|
2027
|
+
var resourceRequestSchema = z17.object({
|
|
1829
2028
|
source: resourceSourceSchema,
|
|
1830
|
-
query:
|
|
1831
|
-
cursor:
|
|
1832
|
-
ids:
|
|
2029
|
+
query: z17.string().max(100).optional(),
|
|
2030
|
+
cursor: z17.string().regex(/^\d{1,6}$/).optional(),
|
|
2031
|
+
ids: z17.array(z17.string().min(1).max(100)).max(50).optional()
|
|
1833
2032
|
}).strict();
|
|
1834
|
-
var resourceOptionsSchema =
|
|
1835
|
-
revision:
|
|
1836
|
-
options:
|
|
1837
|
-
|
|
1838
|
-
id:
|
|
1839
|
-
label:
|
|
1840
|
-
description:
|
|
1841
|
-
group:
|
|
1842
|
-
disabledReason:
|
|
2033
|
+
var resourceOptionsSchema = z17.object({
|
|
2034
|
+
revision: z17.number().int(),
|
|
2035
|
+
options: z17.array(
|
|
2036
|
+
z17.object({
|
|
2037
|
+
id: z17.string(),
|
|
2038
|
+
label: z17.string(),
|
|
2039
|
+
description: z17.string().optional(),
|
|
2040
|
+
group: z17.string().optional(),
|
|
2041
|
+
disabledReason: z17.string().optional()
|
|
1843
2042
|
})
|
|
1844
2043
|
),
|
|
1845
2044
|
/** Pass back as `cursor` for the next page; null on the last one. */
|
|
1846
|
-
nextCursor:
|
|
2045
|
+
nextCursor: z17.string().nullable().default(null),
|
|
1847
2046
|
/** @deprecated Use `nextCursor`. Removed in 2.0.0. */
|
|
1848
|
-
cursor:
|
|
2047
|
+
cursor: z17.string().nullable()
|
|
1849
2048
|
});
|
|
1850
2049
|
|
|
1851
2050
|
// src/settings.ts
|
|
1852
|
-
import { z as
|
|
2051
|
+
import { z as z19 } from "zod";
|
|
1853
2052
|
|
|
1854
2053
|
// src/setting-values.ts
|
|
1855
|
-
import { z as
|
|
1856
|
-
var settingInstant =
|
|
1857
|
-
var settingResourceId =
|
|
1858
|
-
|
|
1859
|
-
|
|
2054
|
+
import { z as z18 } from "zod";
|
|
2055
|
+
var settingInstant = z18.iso.datetime({ offset: true }).transform((value) => new Date(value).toISOString());
|
|
2056
|
+
var settingResourceId = z18.union([
|
|
2057
|
+
z18.literal(""),
|
|
2058
|
+
z18.string().regex(/^\S{1,200}$/)
|
|
1860
2059
|
]);
|
|
1861
2060
|
|
|
1862
2061
|
// src/settings.ts
|
|
1863
|
-
var base = { label:
|
|
1864
|
-
var settingFieldSchema =
|
|
1865
|
-
|
|
2062
|
+
var base = { label: z19.string().min(1), description: z19.string().optional() };
|
|
2063
|
+
var settingFieldSchema = z19.discriminatedUnion("kind", [
|
|
2064
|
+
z19.object({
|
|
1866
2065
|
...base,
|
|
1867
|
-
kind:
|
|
1868
|
-
default: identifier.or(
|
|
2066
|
+
kind: z19.literal("point-ledger"),
|
|
2067
|
+
default: identifier.or(z19.literal(""))
|
|
1869
2068
|
}).strict(),
|
|
1870
|
-
|
|
1871
|
-
|
|
2069
|
+
z19.object({ ...base, kind: z19.literal("datetime"), default: settingInstant }).strict(),
|
|
2070
|
+
z19.object({
|
|
1872
2071
|
...base,
|
|
1873
|
-
kind:
|
|
2072
|
+
kind: z19.literal("resource"),
|
|
1874
2073
|
default: settingResourceId,
|
|
1875
2074
|
source: resourceSourceSchema
|
|
1876
2075
|
}).strict(),
|
|
1877
|
-
|
|
1878
|
-
|
|
2076
|
+
z19.object({ ...base, kind: z19.literal("quiz"), default: quizContentSchema }).strict(),
|
|
2077
|
+
z19.object({
|
|
1879
2078
|
...base,
|
|
1880
|
-
kind:
|
|
1881
|
-
default:
|
|
1882
|
-
minLength:
|
|
1883
|
-
maxLength:
|
|
1884
|
-
multiline:
|
|
2079
|
+
kind: z19.literal("text"),
|
|
2080
|
+
default: z19.string(),
|
|
2081
|
+
minLength: z19.number().int().nonnegative(),
|
|
2082
|
+
maxLength: z19.number().int().positive(),
|
|
2083
|
+
multiline: z19.boolean()
|
|
1885
2084
|
}).strict(),
|
|
1886
|
-
|
|
2085
|
+
z19.object({
|
|
1887
2086
|
...base,
|
|
1888
|
-
kind:
|
|
1889
|
-
default:
|
|
1890
|
-
min:
|
|
1891
|
-
max:
|
|
2087
|
+
kind: z19.literal("integer"),
|
|
2088
|
+
default: z19.number().int(),
|
|
2089
|
+
min: z19.number().int(),
|
|
2090
|
+
max: z19.number().int()
|
|
1892
2091
|
}).strict(),
|
|
1893
|
-
|
|
1894
|
-
|
|
2092
|
+
z19.object({ ...base, kind: z19.literal("boolean"), default: z19.boolean() }).strict(),
|
|
2093
|
+
z19.object({
|
|
1895
2094
|
...base,
|
|
1896
|
-
kind:
|
|
1897
|
-
default:
|
|
1898
|
-
options:
|
|
2095
|
+
kind: z19.literal("choice"),
|
|
2096
|
+
default: z19.string(),
|
|
2097
|
+
options: z19.array(z19.string().min(1)).min(1)
|
|
1899
2098
|
}).strict()
|
|
1900
2099
|
]);
|
|
1901
|
-
var settingsFieldsSchema =
|
|
1902
|
-
|
|
2100
|
+
var settingsFieldsSchema = z19.record(
|
|
2101
|
+
z19.string().regex(/^[a-zA-Z][a-zA-Z0-9_]*$/),
|
|
1903
2102
|
settingFieldSchema
|
|
1904
2103
|
);
|
|
1905
|
-
var settingsValuesSchema =
|
|
1906
|
-
|
|
1907
|
-
|
|
2104
|
+
var settingsValuesSchema = z19.record(
|
|
2105
|
+
z19.string(),
|
|
2106
|
+
z19.union([z19.string(), z19.number().finite(), z19.boolean(), quizContentSchema])
|
|
1908
2107
|
);
|
|
1909
|
-
function parseSettings(
|
|
2108
|
+
function parseSettings(fields2, input) {
|
|
1910
2109
|
const shape = {};
|
|
1911
|
-
for (const [key, field] of Object.entries(
|
|
2110
|
+
for (const [key, field] of Object.entries(fields2)) {
|
|
1912
2111
|
switch (field.kind) {
|
|
1913
2112
|
case "point-ledger":
|
|
1914
2113
|
shape[key] = settingResourceId.default(field.default);
|
|
@@ -1923,24 +2122,24 @@ function parseSettings(fields, input) {
|
|
|
1923
2122
|
shape[key] = quizContentSchema.default(field.default);
|
|
1924
2123
|
break;
|
|
1925
2124
|
case "text":
|
|
1926
|
-
shape[key] =
|
|
2125
|
+
shape[key] = z19.string().min(field.minLength).max(field.maxLength).default(field.default);
|
|
1927
2126
|
break;
|
|
1928
2127
|
case "integer":
|
|
1929
|
-
shape[key] =
|
|
2128
|
+
shape[key] = z19.number().int().min(field.min).max(field.max).default(field.default);
|
|
1930
2129
|
break;
|
|
1931
2130
|
case "boolean":
|
|
1932
|
-
shape[key] =
|
|
2131
|
+
shape[key] = z19.boolean().default(field.default);
|
|
1933
2132
|
break;
|
|
1934
2133
|
case "choice":
|
|
1935
|
-
shape[key] =
|
|
2134
|
+
shape[key] = z19.enum(field.options).default(field.default);
|
|
1936
2135
|
break;
|
|
1937
2136
|
}
|
|
1938
2137
|
}
|
|
1939
|
-
return settingsValuesSchema.parse(
|
|
2138
|
+
return settingsValuesSchema.parse(z19.object(shape).strict().parse(input));
|
|
1940
2139
|
}
|
|
1941
|
-
function missingResourceSettings(
|
|
1942
|
-
return Object.entries(
|
|
1943
|
-
([key, field]) => (field.kind === "resource" || field.kind === "point-ledger") && !
|
|
2140
|
+
function missingResourceSettings(fields2, values2) {
|
|
2141
|
+
return Object.entries(fields2).filter(
|
|
2142
|
+
([key, field]) => (field.kind === "resource" || field.kind === "point-ledger") && !values2[key]
|
|
1944
2143
|
).map(([key]) => key);
|
|
1945
2144
|
}
|
|
1946
2145
|
function compatibleSettingKinds(previous, next) {
|
|
@@ -1957,21 +2156,21 @@ function authoringKey(input) {
|
|
|
1957
2156
|
}
|
|
1958
2157
|
|
|
1959
2158
|
// src/campaigns.ts
|
|
1960
|
-
import { z as
|
|
1961
|
-
var timestamp4 =
|
|
1962
|
-
var availabilityWindowSchema =
|
|
2159
|
+
import { z as z20 } from "zod";
|
|
2160
|
+
var timestamp4 = z20.number().int().safe().nonnegative();
|
|
2161
|
+
var availabilityWindowSchema = z20.object({ from: timestamp4, until: timestamp4 }).strict().refine((window) => window.until > window.from, {
|
|
1963
2162
|
message: "Window end must follow its start",
|
|
1964
2163
|
path: ["until"]
|
|
1965
2164
|
});
|
|
1966
|
-
var campaignDefinitionSchema =
|
|
2165
|
+
var campaignDefinitionSchema = z20.object({
|
|
1967
2166
|
key: identifier,
|
|
1968
|
-
title:
|
|
2167
|
+
title: z20.string().trim().min(1).max(120),
|
|
1969
2168
|
window: availabilityWindowSchema.optional(),
|
|
1970
|
-
enrollment:
|
|
2169
|
+
enrollment: z20.enum(["none", "required"]).default("none")
|
|
1971
2170
|
}).strict();
|
|
1972
2171
|
var campaignAuthoringSchema = campaignDefinitionSchema.omit({ key: true, title: true }).extend({
|
|
1973
2172
|
...authoringIdentityShape,
|
|
1974
|
-
title:
|
|
2173
|
+
title: z20.string().trim().min(1).max(120).optional()
|
|
1975
2174
|
}).strict().transform((value) => {
|
|
1976
2175
|
const normalized = value;
|
|
1977
2176
|
return campaignDefinitionSchema.parse({
|
|
@@ -1985,42 +2184,42 @@ function defineCampaign(input) {
|
|
|
1985
2184
|
var campaignViewSchema = campaignDefinitionSchema.extend({
|
|
1986
2185
|
enrolledAt: timestamp4.nullable(),
|
|
1987
2186
|
withdrawnAt: timestamp4.nullable().default(null),
|
|
1988
|
-
withdrawalReason:
|
|
2187
|
+
withdrawalReason: z20.string().nullable().default(null)
|
|
1989
2188
|
});
|
|
1990
|
-
var campaignEnrollmentInputSchema =
|
|
2189
|
+
var campaignEnrollmentInputSchema = z20.object({ actionId: identifier, campaign: identifier }).strict();
|
|
1991
2190
|
var memberCampaignEnrollmentInputSchema = campaignEnrollmentInputSchema.extend({ member: identifier });
|
|
1992
2191
|
var campaignWithdrawalInputSchema = campaignEnrollmentInputSchema;
|
|
1993
2192
|
var memberCampaignWithdrawalInputSchema = campaignWithdrawalInputSchema.extend({
|
|
1994
2193
|
member: identifier,
|
|
1995
|
-
reason:
|
|
2194
|
+
reason: z20.string().trim().min(1).max(500)
|
|
1996
2195
|
});
|
|
1997
|
-
var campaignEnrollmentSchema =
|
|
2196
|
+
var campaignEnrollmentSchema = z20.object({
|
|
1998
2197
|
campaign: identifier,
|
|
1999
2198
|
member: identifier,
|
|
2000
2199
|
enrolledAt: timestamp4,
|
|
2001
2200
|
withdrawnAt: timestamp4.nullable().default(null),
|
|
2002
|
-
withdrawalReason:
|
|
2201
|
+
withdrawalReason: z20.string().nullable().default(null)
|
|
2003
2202
|
});
|
|
2004
2203
|
|
|
2005
2204
|
// src/resource-handle.ts
|
|
2006
|
-
import { z as
|
|
2205
|
+
import { z as z21 } from "zod";
|
|
2007
2206
|
function resourceHandle(_kind, definition) {
|
|
2008
2207
|
return definition;
|
|
2009
2208
|
}
|
|
2010
|
-
var ledgerSettingSchema = identifier.or(
|
|
2209
|
+
var ledgerSettingSchema = identifier.or(z21.literal("")).brand();
|
|
2011
2210
|
function ledgerKey(ledger) {
|
|
2012
2211
|
return typeof ledger === "string" ? ledger : ledger.key;
|
|
2013
2212
|
}
|
|
2014
2213
|
|
|
2015
2214
|
// src/groups.ts
|
|
2016
|
-
import { z as
|
|
2017
|
-
var projectGroupSchema =
|
|
2215
|
+
import { z as z22 } from "zod";
|
|
2216
|
+
var projectGroupSchema = z22.object({
|
|
2018
2217
|
key: identifier,
|
|
2019
|
-
title:
|
|
2218
|
+
title: z22.string().trim().min(1).max(120)
|
|
2020
2219
|
}).strict();
|
|
2021
2220
|
var projectGroupAuthoringSchema = projectGroupSchema.omit({ key: true, title: true }).extend({
|
|
2022
2221
|
...authoringIdentityShape,
|
|
2023
|
-
title:
|
|
2222
|
+
title: z22.string().trim().min(1).max(120).optional()
|
|
2024
2223
|
}).strict().transform((value) => {
|
|
2025
2224
|
return projectGroupSchema.parse({
|
|
2026
2225
|
...value,
|
|
@@ -2033,92 +2232,92 @@ function defineGroup(input) {
|
|
|
2033
2232
|
function projectGroupKey(group) {
|
|
2034
2233
|
return identifier.parse(group.key);
|
|
2035
2234
|
}
|
|
2036
|
-
var groupTitle =
|
|
2037
|
-
var reason =
|
|
2038
|
-
var timestamp5 =
|
|
2039
|
-
var createGroupSchema =
|
|
2040
|
-
var updateGroupSchema =
|
|
2041
|
-
var addGroupMemberSchema =
|
|
2042
|
-
var removeGroupMemberSchema =
|
|
2043
|
-
var groupPageQuerySchema =
|
|
2235
|
+
var groupTitle = z22.string().trim().min(1).max(120);
|
|
2236
|
+
var reason = z22.string().trim().min(1).max(1e3);
|
|
2237
|
+
var timestamp5 = z22.number().int().nonnegative().max(864e13);
|
|
2238
|
+
var createGroupSchema = z22.object({ actionId: identifier, key: identifier, title: groupTitle }).strict();
|
|
2239
|
+
var updateGroupSchema = z22.object({ title: groupTitle }).strict();
|
|
2240
|
+
var addGroupMemberSchema = z22.object({ actionId: identifier, member: identifier, reason }).strict();
|
|
2241
|
+
var removeGroupMemberSchema = z22.object({ actionId: identifier, reason }).strict();
|
|
2242
|
+
var groupPageQuerySchema = z22.strictObject({
|
|
2044
2243
|
cursor: pageCursorSchema.optional(),
|
|
2045
2244
|
/** Items per page, 1–100; the default is 50. */
|
|
2046
|
-
limit:
|
|
2245
|
+
limit: z22.number().int().min(1).max(100).optional()
|
|
2047
2246
|
});
|
|
2048
|
-
var managedGroupSchema =
|
|
2247
|
+
var managedGroupSchema = z22.object({
|
|
2049
2248
|
key: identifier,
|
|
2050
|
-
title:
|
|
2051
|
-
members:
|
|
2249
|
+
title: z22.string(),
|
|
2250
|
+
members: z22.number().int().nonnegative(),
|
|
2052
2251
|
createdAt: timestamp5,
|
|
2053
2252
|
archivedAt: timestamp5.nullable()
|
|
2054
2253
|
});
|
|
2055
|
-
var groupPageSchema =
|
|
2056
|
-
items:
|
|
2254
|
+
var groupPageSchema = z22.object({
|
|
2255
|
+
items: z22.array(managedGroupSchema),
|
|
2057
2256
|
nextCursor: pageCursorSchema.nullable()
|
|
2058
2257
|
});
|
|
2059
|
-
var groupMemberSchema =
|
|
2258
|
+
var groupMemberSchema = z22.object({
|
|
2060
2259
|
member: identifier,
|
|
2061
2260
|
addedAt: timestamp5.nullable()
|
|
2062
2261
|
});
|
|
2063
|
-
var groupMemberPageSchema =
|
|
2064
|
-
items:
|
|
2262
|
+
var groupMemberPageSchema = z22.object({
|
|
2263
|
+
items: z22.array(groupMemberSchema),
|
|
2065
2264
|
nextCursor: pageCursorSchema.nullable()
|
|
2066
2265
|
});
|
|
2067
2266
|
|
|
2068
2267
|
// src/prerequisites.ts
|
|
2069
|
-
import { z as
|
|
2070
|
-
var amount =
|
|
2268
|
+
import { z as z23 } from "zod";
|
|
2269
|
+
var amount = z23.number().int().safe().nonnegative();
|
|
2071
2270
|
var threshold = amount.positive();
|
|
2072
|
-
var completionPrerequisiteSchema =
|
|
2073
|
-
|
|
2074
|
-
kind:
|
|
2271
|
+
var completionPrerequisiteSchema = z23.discriminatedUnion("scope", [
|
|
2272
|
+
z23.object({
|
|
2273
|
+
kind: z23.literal("completion"),
|
|
2075
2274
|
quest: identifier,
|
|
2076
|
-
scope:
|
|
2275
|
+
scope: z23.literal("ever")
|
|
2077
2276
|
}).strict(),
|
|
2078
|
-
|
|
2079
|
-
kind:
|
|
2277
|
+
z23.object({
|
|
2278
|
+
kind: z23.literal("completion"),
|
|
2080
2279
|
quest: identifier,
|
|
2081
|
-
scope:
|
|
2280
|
+
scope: z23.literal("period"),
|
|
2082
2281
|
period: calendarPeriodSchema.exclude(["lifetime"])
|
|
2083
2282
|
}).strict()
|
|
2084
2283
|
]);
|
|
2085
|
-
var balancePrerequisiteSchema =
|
|
2086
|
-
kind:
|
|
2284
|
+
var balancePrerequisiteSchema = z23.object({
|
|
2285
|
+
kind: z23.literal("balance"),
|
|
2087
2286
|
balance: identifier,
|
|
2088
2287
|
minimum: threshold
|
|
2089
2288
|
}).strict();
|
|
2090
|
-
var groupPrerequisiteSchema =
|
|
2091
|
-
var prerequisiteSchema =
|
|
2289
|
+
var groupPrerequisiteSchema = z23.object({ kind: z23.literal("group"), group: identifier, title: z23.string() }).strict();
|
|
2290
|
+
var prerequisiteSchema = z23.discriminatedUnion("kind", [
|
|
2092
2291
|
completionPrerequisiteSchema,
|
|
2093
2292
|
balancePrerequisiteSchema,
|
|
2094
2293
|
groupPrerequisiteSchema
|
|
2095
2294
|
]);
|
|
2096
|
-
var missingPrerequisiteSchema =
|
|
2097
|
-
|
|
2098
|
-
kind:
|
|
2295
|
+
var missingPrerequisiteSchema = z23.union([
|
|
2296
|
+
z23.object({
|
|
2297
|
+
kind: z23.literal("completion"),
|
|
2099
2298
|
quest: identifier,
|
|
2100
|
-
title:
|
|
2101
|
-
scope:
|
|
2299
|
+
title: z23.string(),
|
|
2300
|
+
scope: z23.literal("ever")
|
|
2102
2301
|
}),
|
|
2103
|
-
|
|
2104
|
-
kind:
|
|
2302
|
+
z23.object({
|
|
2303
|
+
kind: z23.literal("completion"),
|
|
2105
2304
|
quest: identifier,
|
|
2106
|
-
title:
|
|
2107
|
-
scope:
|
|
2305
|
+
title: z23.string(),
|
|
2306
|
+
scope: z23.literal("period"),
|
|
2108
2307
|
period: calendarPeriodSchema.exclude(["lifetime"]),
|
|
2109
|
-
resetsAt:
|
|
2308
|
+
resetsAt: z23.number().int().safe()
|
|
2110
2309
|
}),
|
|
2111
|
-
|
|
2112
|
-
kind:
|
|
2310
|
+
z23.object({
|
|
2311
|
+
kind: z23.literal("balance"),
|
|
2113
2312
|
balance: identifier,
|
|
2114
|
-
title:
|
|
2313
|
+
title: z23.string(),
|
|
2115
2314
|
minimum: threshold,
|
|
2116
2315
|
current: amount
|
|
2117
2316
|
}),
|
|
2118
|
-
|
|
2119
|
-
kind:
|
|
2317
|
+
z23.object({
|
|
2318
|
+
kind: z23.literal("group"),
|
|
2120
2319
|
group: identifier,
|
|
2121
|
-
title:
|
|
2320
|
+
title: z23.string()
|
|
2122
2321
|
})
|
|
2123
2322
|
]);
|
|
2124
2323
|
function completed(quest, options = {}) {
|
|
@@ -2146,33 +2345,33 @@ function inGroup(group) {
|
|
|
2146
2345
|
}
|
|
2147
2346
|
|
|
2148
2347
|
// src/schema.ts
|
|
2149
|
-
import { z as
|
|
2150
|
-
var pointsRewardSchema =
|
|
2151
|
-
kind:
|
|
2348
|
+
import { z as z24 } from "zod";
|
|
2349
|
+
var pointsRewardSchema = z24.object({
|
|
2350
|
+
kind: z24.literal("points").default("points"),
|
|
2152
2351
|
balance: identifier,
|
|
2153
|
-
amount:
|
|
2352
|
+
amount: z24.number().int().min(0).max(1e4)
|
|
2154
2353
|
}).strict();
|
|
2155
|
-
var tieredRewardDefinitionSchema =
|
|
2354
|
+
var tieredRewardDefinitionSchema = z24.object({
|
|
2156
2355
|
id: identifier,
|
|
2157
|
-
title:
|
|
2158
|
-
tiers:
|
|
2159
|
-
|
|
2356
|
+
title: z24.string().min(1).max(120),
|
|
2357
|
+
tiers: z24.array(
|
|
2358
|
+
z24.object({ id: identifier, title: z24.string().min(1).max(120) }).strict()
|
|
2160
2359
|
).min(1).max(20).refine(
|
|
2161
2360
|
(tiers) => new Set(tiers.map((t) => t.id)).size === tiers.length,
|
|
2162
2361
|
"Tier IDs must be unique"
|
|
2163
2362
|
),
|
|
2164
|
-
inventory:
|
|
2165
|
-
fulfillment:
|
|
2166
|
-
|
|
2167
|
-
|
|
2363
|
+
inventory: z24.object({ kind: z24.literal("untracked") }).strict(),
|
|
2364
|
+
fulfillment: z24.discriminatedUnion("kind", [
|
|
2365
|
+
z24.object({ kind: z24.literal("staff-handover") }).strict(),
|
|
2366
|
+
z24.object({ kind: z24.literal("automatic") }).strict()
|
|
2168
2367
|
])
|
|
2169
2368
|
}).strict();
|
|
2170
|
-
var tieredRewardReferenceSchema =
|
|
2369
|
+
var tieredRewardReferenceSchema = z24.object({
|
|
2171
2370
|
id: identifier,
|
|
2172
2371
|
key: identifier.nullable()
|
|
2173
2372
|
});
|
|
2174
|
-
var tierRewardSchema =
|
|
2175
|
-
kind:
|
|
2373
|
+
var tierRewardSchema = z24.object({
|
|
2374
|
+
kind: z24.literal("tier"),
|
|
2176
2375
|
reward: tieredRewardDefinitionSchema,
|
|
2177
2376
|
tier: identifier
|
|
2178
2377
|
}).strict().refine(
|
|
@@ -2180,7 +2379,7 @@ var tierRewardSchema = z23.object({
|
|
|
2180
2379
|
"Unknown reward tier"
|
|
2181
2380
|
);
|
|
2182
2381
|
var integrationRewardSchema = discordRewardSchema;
|
|
2183
|
-
var rewardSchema =
|
|
2382
|
+
var rewardSchema = z24.union([
|
|
2184
2383
|
pointsRewardSchema,
|
|
2185
2384
|
tierRewardSchema,
|
|
2186
2385
|
integrationRewardSchema
|
|
@@ -2191,39 +2390,39 @@ function rewardKey(reward) {
|
|
|
2191
2390
|
}
|
|
2192
2391
|
return reward.kind === "points" ? "points:" + reward.balance : "tier:" + reward.reward.id;
|
|
2193
2392
|
}
|
|
2194
|
-
var triggerSchema =
|
|
2195
|
-
|
|
2196
|
-
kind:
|
|
2197
|
-
input:
|
|
2393
|
+
var triggerSchema = z24.union([
|
|
2394
|
+
z24.object({
|
|
2395
|
+
kind: z24.literal("manual"),
|
|
2396
|
+
input: z24.literal("text"),
|
|
2198
2397
|
constraints: textOptionsSchema,
|
|
2199
|
-
actor:
|
|
2398
|
+
actor: z24.enum(["member", "staff"]).optional()
|
|
2200
2399
|
}).strict(),
|
|
2201
|
-
|
|
2202
|
-
kind:
|
|
2203
|
-
input:
|
|
2400
|
+
z24.object({
|
|
2401
|
+
kind: z24.literal("manual"),
|
|
2402
|
+
input: z24.literal("url"),
|
|
2204
2403
|
constraints: urlOptionsSchema,
|
|
2205
|
-
actor:
|
|
2404
|
+
actor: z24.enum(["member", "staff"]).optional()
|
|
2206
2405
|
}).strict(),
|
|
2207
|
-
|
|
2208
|
-
kind:
|
|
2209
|
-
input:
|
|
2210
|
-
actor:
|
|
2406
|
+
z24.object({
|
|
2407
|
+
kind: z24.literal("manual"),
|
|
2408
|
+
input: z24.enum(["photo", "quiz", "none"]),
|
|
2409
|
+
actor: z24.enum(["member", "staff"]).optional()
|
|
2211
2410
|
}).strict(),
|
|
2212
|
-
|
|
2213
|
-
kind:
|
|
2411
|
+
z24.object({
|
|
2412
|
+
kind: z24.literal("automatic"),
|
|
2214
2413
|
tracker: trackerTriggerPolicySchema.optional()
|
|
2215
2414
|
}).strict()
|
|
2216
2415
|
]);
|
|
2217
|
-
var triggerResponseSchema =
|
|
2416
|
+
var triggerResponseSchema = z24.union(
|
|
2218
2417
|
triggerSchema.options.map((option) => option.strip())
|
|
2219
2418
|
);
|
|
2220
|
-
var photoResultSchema =
|
|
2221
|
-
kind:
|
|
2222
|
-
reason:
|
|
2419
|
+
var photoResultSchema = z24.object({
|
|
2420
|
+
kind: z24.enum(["pass", "fail", "unclear"]),
|
|
2421
|
+
reason: z24.string().min(1).max(2e3)
|
|
2223
2422
|
}).strict();
|
|
2224
|
-
var textReviewInputSchema =
|
|
2225
|
-
text:
|
|
2226
|
-
criteria:
|
|
2423
|
+
var textReviewInputSchema = z24.object({
|
|
2424
|
+
text: z24.string().min(1).max(16e3).refine((value) => value.trim().length > 0, "Text must not be blank"),
|
|
2425
|
+
criteria: z24.string().trim().min(1).max(2e3)
|
|
2227
2426
|
}).strict();
|
|
2228
2427
|
var textResultSchema = photoResultSchema;
|
|
2229
2428
|
var deferPolicy = {
|
|
@@ -2233,53 +2432,53 @@ var deferPolicy = {
|
|
|
2233
2432
|
horizonMs: 864e5,
|
|
2234
2433
|
maxDefers: 100
|
|
2235
2434
|
};
|
|
2236
|
-
var evaluatorProgressSchema =
|
|
2237
|
-
current:
|
|
2238
|
-
target:
|
|
2239
|
-
reason:
|
|
2435
|
+
var evaluatorProgressSchema = z24.object({
|
|
2436
|
+
current: z24.number().finite().nonnegative(),
|
|
2437
|
+
target: z24.number().finite().positive(),
|
|
2438
|
+
reason: z24.string().min(1).max(2e3)
|
|
2240
2439
|
}).refine((value) => value.current <= value.target, {
|
|
2241
2440
|
message: "Progress current must not exceed target"
|
|
2242
2441
|
});
|
|
2243
|
-
var decisionSchema =
|
|
2244
|
-
|
|
2245
|
-
kind:
|
|
2246
|
-
reason:
|
|
2247
|
-
retryAfterMs:
|
|
2442
|
+
var decisionSchema = z24.discriminatedUnion("kind", [
|
|
2443
|
+
z24.strictObject({
|
|
2444
|
+
kind: z24.literal("defer"),
|
|
2445
|
+
reason: z24.string().min(1).max(2e3),
|
|
2446
|
+
retryAfterMs: z24.number().int().min(deferPolicy.minRetryAfterMs).max(deferPolicy.maxRetryAfterMs).optional(),
|
|
2248
2447
|
/** Absolute Unix milliseconds; the platform can only shorten its existing deadline. */
|
|
2249
|
-
until:
|
|
2448
|
+
until: z24.number().int().safe().nonnegative().optional()
|
|
2250
2449
|
}),
|
|
2251
|
-
evaluatorProgressSchema.safeExtend({ kind:
|
|
2252
|
-
|
|
2253
|
-
kind:
|
|
2254
|
-
rewards:
|
|
2450
|
+
evaluatorProgressSchema.safeExtend({ kind: z24.literal("progress") }).strict(),
|
|
2451
|
+
z24.object({
|
|
2452
|
+
kind: z24.literal("accept"),
|
|
2453
|
+
rewards: z24.array(rewardSchema).max(10),
|
|
2255
2454
|
completionKey: completionKeySchema.optional()
|
|
2256
2455
|
}).strict(),
|
|
2257
|
-
|
|
2258
|
-
kind:
|
|
2259
|
-
reason:
|
|
2456
|
+
z24.object({
|
|
2457
|
+
kind: z24.literal("reject"),
|
|
2458
|
+
reason: z24.string().min(1).max(2e3),
|
|
2260
2459
|
/** The evaluator asked for human review, but review is off for the quest, so this is a reject. */
|
|
2261
|
-
requestedReview:
|
|
2460
|
+
requestedReview: z24.literal(true).optional()
|
|
2262
2461
|
}).strict(),
|
|
2263
|
-
|
|
2264
|
-
kind:
|
|
2265
|
-
reason:
|
|
2266
|
-
rewards:
|
|
2462
|
+
z24.object({
|
|
2463
|
+
kind: z24.literal("review"),
|
|
2464
|
+
reason: z24.string().min(1).max(2e3),
|
|
2465
|
+
rewards: z24.array(rewardSchema).max(10).optional(),
|
|
2267
2466
|
completionKey: completionKeySchema.optional()
|
|
2268
2467
|
}).strict()
|
|
2269
2468
|
]);
|
|
2270
|
-
var reviewModeSchema =
|
|
2271
|
-
var storedReviewModeSchema =
|
|
2469
|
+
var reviewModeSchema = z24.enum(["workers-ai"]);
|
|
2470
|
+
var storedReviewModeSchema = z24.enum([
|
|
2272
2471
|
"fixture-pass",
|
|
2273
2472
|
"fixture-fail",
|
|
2274
2473
|
"fixture-unclear",
|
|
2275
2474
|
"fixture-error",
|
|
2276
2475
|
"workers-ai"
|
|
2277
2476
|
]);
|
|
2278
|
-
var rewardBundleSchema =
|
|
2477
|
+
var rewardBundleSchema = z24.array(rewardSchema).max(10).refine(
|
|
2279
2478
|
(rewards) => new Set(rewards.map(rewardKey)).size === rewards.length,
|
|
2280
2479
|
"Use one entry per balance or shared reward"
|
|
2281
2480
|
);
|
|
2282
|
-
var mediaUrlSchema =
|
|
2481
|
+
var mediaUrlSchema = z24.string().max(2e3).refine((value) => {
|
|
2283
2482
|
if (/^\/(?!\/)[^\\\s]*$/.test(value)) {
|
|
2284
2483
|
return true;
|
|
2285
2484
|
}
|
|
@@ -2289,79 +2488,81 @@ var mediaUrlSchema = z23.string().max(2e3).refine((value) => {
|
|
|
2289
2488
|
return false;
|
|
2290
2489
|
}
|
|
2291
2490
|
}, "Use an HTTPS URL or a same-site path beginning with /");
|
|
2292
|
-
var questPresentationSchema =
|
|
2491
|
+
var questPresentationSchema = z24.object({
|
|
2293
2492
|
quiz: quizQuestionsSchema.optional(),
|
|
2294
|
-
instructions:
|
|
2295
|
-
video:
|
|
2493
|
+
instructions: z24.string().max(4e3).optional(),
|
|
2494
|
+
video: z24.object({
|
|
2296
2495
|
url: mediaUrlSchema,
|
|
2297
2496
|
poster: mediaUrlSchema.optional(),
|
|
2298
|
-
captions:
|
|
2497
|
+
captions: z24.object({
|
|
2299
2498
|
url: mediaUrlSchema,
|
|
2300
|
-
language:
|
|
2301
|
-
label:
|
|
2499
|
+
language: z24.string().min(2).max(20),
|
|
2500
|
+
label: z24.string().min(1).max(80)
|
|
2302
2501
|
}).strict().optional()
|
|
2303
2502
|
}).strict().optional()
|
|
2304
2503
|
}).strict();
|
|
2305
|
-
var questProfileSchema =
|
|
2504
|
+
var questProfileSchema = z24.object({ visible: z24.boolean() }).strict();
|
|
2306
2505
|
var evaluatorProtocol = 2;
|
|
2307
|
-
var evaluatorProtocolSchema =
|
|
2308
|
-
var questDescriptionSchema =
|
|
2506
|
+
var evaluatorProtocolSchema = z24.literal(evaluatorProtocol);
|
|
2507
|
+
var questDescriptionSchema = z24.object({
|
|
2309
2508
|
quest: identifier,
|
|
2310
2509
|
evaluatorProtocol: evaluatorProtocolSchema,
|
|
2311
|
-
title:
|
|
2510
|
+
title: z24.string().min(1).max(120),
|
|
2312
2511
|
presentation: questPresentationSchema.default({}),
|
|
2313
|
-
integrations:
|
|
2512
|
+
integrations: z24.array(evaluatorIntegrationProviderSchema).max(10).default([]),
|
|
2314
2513
|
fields: settingsFieldsSchema,
|
|
2315
2514
|
values: settingsValuesSchema,
|
|
2316
2515
|
rewards: rewardBundleSchema,
|
|
2317
|
-
humanReview:
|
|
2516
|
+
humanReview: z24.boolean(),
|
|
2318
2517
|
trigger: triggerSchema,
|
|
2319
2518
|
performance: contentPerformancePolicySchema.optional(),
|
|
2320
|
-
requires:
|
|
2519
|
+
requires: z24.array(prerequisiteSchema).max(30).default([]),
|
|
2321
2520
|
campaign: campaignDefinitionSchema.optional(),
|
|
2322
2521
|
availability: availabilityWindowSchema.optional(),
|
|
2323
|
-
completion:
|
|
2324
|
-
visibility:
|
|
2522
|
+
completion: z24.preprocess(refuseStreakTimeZone, completionPolicySchema),
|
|
2523
|
+
visibility: z24.enum(["visible", "hidden"]).default("visible"),
|
|
2325
2524
|
/** Whether completions show on participant profiles (`/v1/profiles/:id/completions`). */
|
|
2326
2525
|
profile: questProfileSchema.default({ visible: false }),
|
|
2327
|
-
budgets:
|
|
2526
|
+
budgets: z24.array(budgetSchema).max(20).default([])
|
|
2328
2527
|
}).strict();
|
|
2329
|
-
var artifactSchema =
|
|
2528
|
+
var artifactSchema = z24.object({ code: z24.string().min(1).max(1e6) }).strict();
|
|
2330
2529
|
var releaseSchema = artifactSchema.extend({
|
|
2331
2530
|
settings: settingsValuesSchema,
|
|
2332
2531
|
provider: reviewModeSchema,
|
|
2333
2532
|
expectedRelease: identifier.nullable().optional(),
|
|
2334
|
-
settingRenames:
|
|
2533
|
+
settingRenames: z24.record(z24.string(), z24.string()).optional()
|
|
2335
2534
|
}).strict();
|
|
2336
|
-
var batchReleaseSchema =
|
|
2337
|
-
var questSettingsInputSchema =
|
|
2535
|
+
var batchReleaseSchema = z24.object({ releases: z24.array(releaseSchema).min(1).max(50) }).strict();
|
|
2536
|
+
var questSettingsInputSchema = z24.object({
|
|
2338
2537
|
quest: identifier,
|
|
2339
2538
|
expectedRelease: identifier,
|
|
2340
2539
|
set: settingsValuesSchema,
|
|
2341
|
-
reset:
|
|
2540
|
+
reset: z24.array(z24.string())
|
|
2342
2541
|
}).strict();
|
|
2343
2542
|
var storedQuestDescriptionSchema = questDescriptionSchema.extend({
|
|
2344
2543
|
completion: completionPolicySchema
|
|
2345
2544
|
});
|
|
2346
|
-
var publishedReleaseSchema =
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
})
|
|
2360
|
-
|
|
2361
|
-
|
|
2545
|
+
var publishedReleaseSchema = responseShape(
|
|
2546
|
+
storedQuestDescriptionSchema.extend({
|
|
2547
|
+
key: identifier.optional(),
|
|
2548
|
+
code: z24.string(),
|
|
2549
|
+
provider: storedReviewModeSchema,
|
|
2550
|
+
id: identifier,
|
|
2551
|
+
createdAt: z24.number(),
|
|
2552
|
+
origin: z24.object({ typeVersion: identifier }).strict().optional(),
|
|
2553
|
+
lifecycle: z24.enum(["active", "paused", "archived"]).default("active"),
|
|
2554
|
+
configuration: z24.object({
|
|
2555
|
+
defaults: settingsValuesSchema,
|
|
2556
|
+
overrides: settingsValuesSchema,
|
|
2557
|
+
preserved: z24.array(z24.string())
|
|
2558
|
+
}).strict().optional()
|
|
2559
|
+
})
|
|
2560
|
+
);
|
|
2561
|
+
var templateSchema = z24.object({
|
|
2562
|
+
code: z24.string(),
|
|
2362
2563
|
definition: questDescriptionSchema
|
|
2363
2564
|
});
|
|
2364
|
-
var quizAnswersSchema =
|
|
2565
|
+
var quizAnswersSchema = z24.record(identifier, identifier).refine(
|
|
2365
2566
|
(answers) => Object.keys(answers).length > 0 && Object.keys(answers).length <= 50,
|
|
2366
2567
|
"Provide between 1 and 50 answers"
|
|
2367
2568
|
).transform(
|
|
@@ -2369,17 +2570,17 @@ var quizAnswersSchema = z23.record(identifier, identifier).refine(
|
|
|
2369
2570
|
Object.entries(answers).sort(([a], [b]) => a.localeCompare(b))
|
|
2370
2571
|
)
|
|
2371
2572
|
);
|
|
2372
|
-
var quizEvidenceSchema =
|
|
2373
|
-
kind:
|
|
2573
|
+
var quizEvidenceSchema = z24.object({
|
|
2574
|
+
kind: z24.literal("quiz"),
|
|
2374
2575
|
release: identifier.optional(),
|
|
2375
2576
|
answers: quizAnswersSchema
|
|
2376
2577
|
}).strict();
|
|
2377
|
-
var submissionEvidenceSchema =
|
|
2578
|
+
var submissionEvidenceSchema = z24.union([
|
|
2378
2579
|
quizEvidenceSchema,
|
|
2379
2580
|
textEvidenceSchema,
|
|
2380
2581
|
urlEvidenceSchema
|
|
2381
2582
|
]);
|
|
2382
|
-
var submitSchema =
|
|
2583
|
+
var submitSchema = z24.object({
|
|
2383
2584
|
actionId: identifier,
|
|
2384
2585
|
quest: identifier,
|
|
2385
2586
|
member: identifier,
|
|
@@ -2387,7 +2588,7 @@ var submitSchema = z23.object({
|
|
|
2387
2588
|
input: submissionEvidenceSchema.optional(),
|
|
2388
2589
|
release: identifier.optional(),
|
|
2389
2590
|
/** @deprecated Relay refuses a submission that sets it to `true` and ignores `false`. Removed in 2.0.0. */
|
|
2390
|
-
faultAfterReview:
|
|
2591
|
+
faultAfterReview: z24.boolean().optional()
|
|
2391
2592
|
}).strict();
|
|
2392
2593
|
var AttemptStatus = {
|
|
2393
2594
|
Queued: "queued",
|
|
@@ -2399,8 +2600,8 @@ var AttemptStatus = {
|
|
|
2399
2600
|
NeedsReview: "needs-review",
|
|
2400
2601
|
Failed: "failed"
|
|
2401
2602
|
};
|
|
2402
|
-
var attemptStatusSchema =
|
|
2403
|
-
var attemptSchema =
|
|
2603
|
+
var attemptStatusSchema = z24.string();
|
|
2604
|
+
var attemptSchema = z24.object({
|
|
2404
2605
|
id: identifier,
|
|
2405
2606
|
release: identifier,
|
|
2406
2607
|
quest: identifier,
|
|
@@ -2408,83 +2609,83 @@ var attemptSchema = z23.object({
|
|
|
2408
2609
|
evidence: identifier.nullable(),
|
|
2409
2610
|
input: submissionEvidenceSchema.optional(),
|
|
2410
2611
|
status: attemptStatusSchema,
|
|
2411
|
-
reason:
|
|
2412
|
-
retries:
|
|
2413
|
-
generation:
|
|
2414
|
-
completion:
|
|
2612
|
+
reason: z24.string().nullable(),
|
|
2613
|
+
retries: z24.number(),
|
|
2614
|
+
generation: z24.number(),
|
|
2615
|
+
completion: z24.string().nullable(),
|
|
2415
2616
|
reviewRewards: rewardBundleSchema.nullable().default(null),
|
|
2416
2617
|
/** Scheduled reruns advance this number; failure retries preserve it. */
|
|
2417
|
-
evaluationRun:
|
|
2418
|
-
deferCount:
|
|
2419
|
-
deferUntil:
|
|
2420
|
-
nextEvaluationAt:
|
|
2618
|
+
evaluationRun: z24.number().int().nonnegative().default(0),
|
|
2619
|
+
deferCount: z24.number().int().nonnegative().default(0),
|
|
2620
|
+
deferUntil: z24.number().int().safe().nullable().default(null),
|
|
2621
|
+
nextEvaluationAt: z24.number().int().safe().nullable().default(null),
|
|
2421
2622
|
/** Open code: consumers must tolerate new values. */
|
|
2422
|
-
code:
|
|
2623
|
+
code: z24.string().nullable().default(null),
|
|
2423
2624
|
progress: evaluatorProgressSchema.nullable().default(null),
|
|
2424
2625
|
/**
|
|
2425
2626
|
* The evaluator asked for human review of a quest with review off, so Domino rejected the attempt
|
|
2426
2627
|
* with the evaluator's reason. Only set on a rejected attempt.
|
|
2427
2628
|
*/
|
|
2428
|
-
requestedReview:
|
|
2429
|
-
createdAt:
|
|
2430
|
-
});
|
|
2431
|
-
var eventSchema =
|
|
2432
|
-
id:
|
|
2433
|
-
attempt:
|
|
2434
|
-
kind:
|
|
2435
|
-
detail:
|
|
2436
|
-
actor:
|
|
2437
|
-
at:
|
|
2438
|
-
});
|
|
2439
|
-
var pickupSelectionSchema =
|
|
2629
|
+
requestedReview: z24.boolean().default(false),
|
|
2630
|
+
createdAt: z24.number()
|
|
2631
|
+
});
|
|
2632
|
+
var eventSchema = z24.object({
|
|
2633
|
+
id: z24.number(),
|
|
2634
|
+
attempt: z24.string().nullable(),
|
|
2635
|
+
kind: z24.string(),
|
|
2636
|
+
detail: z24.string(),
|
|
2637
|
+
actor: z24.string().nullable().default(null),
|
|
2638
|
+
at: z24.number()
|
|
2639
|
+
});
|
|
2640
|
+
var pickupSelectionSchema = z24.object({
|
|
2440
2641
|
item: identifier,
|
|
2441
|
-
revision:
|
|
2642
|
+
revision: z24.number().int().nonnegative()
|
|
2442
2643
|
}).strict();
|
|
2443
|
-
var pickupAllocationSchema =
|
|
2644
|
+
var pickupAllocationSchema = z24.object({
|
|
2444
2645
|
item: identifier,
|
|
2445
|
-
label:
|
|
2646
|
+
label: z24.string().min(1).max(80)
|
|
2446
2647
|
}).strict();
|
|
2447
|
-
var pickupPolicySchema =
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
kind:
|
|
2451
|
-
tiers:
|
|
2452
|
-
|
|
2648
|
+
var pickupPolicySchema = z24.discriminatedUnion("kind", [
|
|
2649
|
+
z24.object({ kind: z24.literal("untracked") }).strict(),
|
|
2650
|
+
z24.object({
|
|
2651
|
+
kind: z24.literal("at-pickup"),
|
|
2652
|
+
tiers: z24.array(
|
|
2653
|
+
z24.object({
|
|
2453
2654
|
tier: identifier,
|
|
2454
|
-
variants:
|
|
2655
|
+
variants: z24.array(pickupAllocationSchema).min(1).max(100)
|
|
2455
2656
|
}).strict()
|
|
2456
2657
|
).min(1).max(100)
|
|
2457
2658
|
}).strict()
|
|
2458
2659
|
]);
|
|
2459
|
-
var pickupCatalogSchema =
|
|
2660
|
+
var pickupCatalogSchema = z24.object({
|
|
2460
2661
|
reward: tieredRewardDefinitionSchema,
|
|
2461
|
-
revision:
|
|
2662
|
+
revision: z24.number().int().nonnegative(),
|
|
2462
2663
|
policy: pickupPolicySchema
|
|
2463
2664
|
});
|
|
2464
|
-
var pickupAvailabilitySchema =
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
kind:
|
|
2468
|
-
revision:
|
|
2469
|
-
variants:
|
|
2665
|
+
var pickupAvailabilitySchema = z24.discriminatedUnion("kind", [
|
|
2666
|
+
z24.object({ kind: z24.literal("untracked") }).strict(),
|
|
2667
|
+
z24.object({
|
|
2668
|
+
kind: z24.literal("at-pickup"),
|
|
2669
|
+
revision: z24.number().int().nonnegative(),
|
|
2670
|
+
variants: z24.array(
|
|
2470
2671
|
pickupAllocationSchema.extend({
|
|
2471
|
-
available:
|
|
2672
|
+
available: z24.number().int().nonnegative()
|
|
2472
2673
|
})
|
|
2473
2674
|
)
|
|
2474
2675
|
}).strict()
|
|
2475
2676
|
]);
|
|
2476
|
-
var configurePickupSchema =
|
|
2677
|
+
var configurePickupSchema = z24.object({
|
|
2477
2678
|
reward: identifier,
|
|
2478
|
-
revision:
|
|
2679
|
+
revision: z24.number().int().nonnegative(),
|
|
2479
2680
|
actionId: identifier,
|
|
2480
|
-
policy:
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
kind:
|
|
2484
|
-
tiers:
|
|
2485
|
-
|
|
2681
|
+
policy: z24.discriminatedUnion("kind", [
|
|
2682
|
+
z24.object({ kind: z24.literal("untracked") }).strict(),
|
|
2683
|
+
z24.object({
|
|
2684
|
+
kind: z24.literal("at-pickup"),
|
|
2685
|
+
tiers: z24.array(
|
|
2686
|
+
z24.object({
|
|
2486
2687
|
tier: identifier,
|
|
2487
|
-
variants:
|
|
2688
|
+
variants: z24.array(
|
|
2488
2689
|
pickupAllocationSchema.extend({
|
|
2489
2690
|
item: identifier.optional()
|
|
2490
2691
|
})
|
|
@@ -2494,10 +2695,10 @@ var configurePickupSchema = z23.object({
|
|
|
2494
2695
|
}).strict()
|
|
2495
2696
|
])
|
|
2496
2697
|
}).strict();
|
|
2497
|
-
var entitlementRecoverySchema =
|
|
2698
|
+
var entitlementRecoverySchema = z24.object({
|
|
2498
2699
|
completion: identifier,
|
|
2499
|
-
reason:
|
|
2500
|
-
flaggedAt:
|
|
2700
|
+
reason: z24.string(),
|
|
2701
|
+
flaggedAt: z24.number(),
|
|
2501
2702
|
/** Null means no accepted completion currently earns this reward. */
|
|
2502
2703
|
remainingTier: identifier.nullable()
|
|
2503
2704
|
});
|
|
@@ -2507,40 +2708,40 @@ var entitlementBase = {
|
|
|
2507
2708
|
reward: tieredRewardDefinitionSchema,
|
|
2508
2709
|
earnedTier: identifier,
|
|
2509
2710
|
tier: identifier,
|
|
2510
|
-
revision:
|
|
2711
|
+
revision: z24.number().int().positive()
|
|
2511
2712
|
};
|
|
2512
|
-
var entitlementStateSchema =
|
|
2513
|
-
|
|
2514
|
-
|
|
2713
|
+
var entitlementStateSchema = z24.discriminatedUnion("status", [
|
|
2714
|
+
z24.object({ ...entitlementBase, status: z24.literal("available") }).strict(),
|
|
2715
|
+
z24.object({
|
|
2515
2716
|
...entitlementBase,
|
|
2516
|
-
status:
|
|
2717
|
+
status: z24.literal("handing-over"),
|
|
2517
2718
|
handover: identifier,
|
|
2518
|
-
startedAt:
|
|
2719
|
+
startedAt: z24.number(),
|
|
2519
2720
|
allocation: pickupAllocationSchema.optional()
|
|
2520
2721
|
}).strict(),
|
|
2521
|
-
|
|
2722
|
+
z24.object({
|
|
2522
2723
|
...entitlementBase,
|
|
2523
|
-
status:
|
|
2724
|
+
status: z24.literal("collected"),
|
|
2524
2725
|
handover: identifier,
|
|
2525
|
-
startedAt:
|
|
2726
|
+
startedAt: z24.number(),
|
|
2526
2727
|
allocation: pickupAllocationSchema.optional(),
|
|
2527
|
-
collectedAt:
|
|
2728
|
+
collectedAt: z24.number(),
|
|
2528
2729
|
recovery: entitlementRecoverySchema.optional()
|
|
2529
2730
|
}).strict(),
|
|
2530
2731
|
// An operator voided it: it can no longer be handed over. A quest grant of the same reward to
|
|
2531
2732
|
// the member (the same grant key) makes it available again; a voided referral reward stays void.
|
|
2532
|
-
|
|
2733
|
+
z24.object({
|
|
2533
2734
|
...entitlementBase,
|
|
2534
|
-
status:
|
|
2535
|
-
voidedAt:
|
|
2735
|
+
status: z24.literal("void"),
|
|
2736
|
+
voidedAt: z24.number()
|
|
2536
2737
|
}).strict()
|
|
2537
2738
|
]);
|
|
2538
|
-
var tieredRewardReadSchema =
|
|
2739
|
+
var tieredRewardReadSchema = z24.object({
|
|
2539
2740
|
id: identifier,
|
|
2540
|
-
title:
|
|
2541
|
-
tiers:
|
|
2542
|
-
inventory:
|
|
2543
|
-
fulfillment:
|
|
2741
|
+
title: z24.string(),
|
|
2742
|
+
tiers: z24.array(z24.object({ id: identifier, title: z24.string() }).loose()),
|
|
2743
|
+
inventory: z24.object({ kind: z24.string() }).loose(),
|
|
2744
|
+
fulfillment: z24.object({ kind: z24.string() }).loose()
|
|
2544
2745
|
}).loose();
|
|
2545
2746
|
var entitlementReadBase = {
|
|
2546
2747
|
id: identifier,
|
|
@@ -2548,63 +2749,63 @@ var entitlementReadBase = {
|
|
|
2548
2749
|
reward: tieredRewardReadSchema,
|
|
2549
2750
|
earnedTier: identifier,
|
|
2550
2751
|
tier: identifier,
|
|
2551
|
-
revision:
|
|
2752
|
+
revision: z24.number().int()
|
|
2552
2753
|
};
|
|
2553
|
-
var allocationReadSchema =
|
|
2554
|
-
var entitlementSchema =
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2754
|
+
var allocationReadSchema = z24.object({ item: identifier, label: z24.string() }).loose();
|
|
2755
|
+
var entitlementSchema = z24.union([
|
|
2756
|
+
z24.discriminatedUnion("status", [
|
|
2757
|
+
z24.object({ ...entitlementReadBase, status: z24.literal("available") }).loose(),
|
|
2758
|
+
z24.object({
|
|
2558
2759
|
...entitlementReadBase,
|
|
2559
|
-
status:
|
|
2760
|
+
status: z24.literal("handing-over"),
|
|
2560
2761
|
handover: identifier,
|
|
2561
|
-
startedAt:
|
|
2762
|
+
startedAt: z24.number(),
|
|
2562
2763
|
allocation: allocationReadSchema.optional()
|
|
2563
2764
|
}).loose(),
|
|
2564
|
-
|
|
2765
|
+
z24.object({
|
|
2565
2766
|
...entitlementReadBase,
|
|
2566
|
-
status:
|
|
2767
|
+
status: z24.literal("collected"),
|
|
2567
2768
|
handover: identifier,
|
|
2568
|
-
startedAt:
|
|
2769
|
+
startedAt: z24.number(),
|
|
2569
2770
|
allocation: allocationReadSchema.optional(),
|
|
2570
|
-
collectedAt:
|
|
2771
|
+
collectedAt: z24.number(),
|
|
2571
2772
|
recovery: entitlementRecoverySchema.optional()
|
|
2572
2773
|
}).loose(),
|
|
2573
|
-
|
|
2774
|
+
z24.object({
|
|
2574
2775
|
...entitlementReadBase,
|
|
2575
|
-
status:
|
|
2576
|
-
voidedAt:
|
|
2776
|
+
status: z24.literal("void"),
|
|
2777
|
+
voidedAt: z24.number()
|
|
2577
2778
|
}).loose()
|
|
2578
2779
|
]),
|
|
2579
|
-
|
|
2780
|
+
z24.object({ ...entitlementReadBase, status: z24.string() }).loose().transform(({ status, ...entitlement }) => ({
|
|
2580
2781
|
...entitlement,
|
|
2581
2782
|
status: "unsupported",
|
|
2582
2783
|
reportedStatus: status
|
|
2583
2784
|
}))
|
|
2584
2785
|
]);
|
|
2585
|
-
var beginHandoverSchema =
|
|
2786
|
+
var beginHandoverSchema = z24.object({
|
|
2586
2787
|
actionId: identifier,
|
|
2587
|
-
revision:
|
|
2788
|
+
revision: z24.number().int().positive(),
|
|
2588
2789
|
selection: pickupSelectionSchema.optional()
|
|
2589
2790
|
}).strict();
|
|
2590
|
-
var confirmHandoverSchema =
|
|
2591
|
-
var entitlementCorrectionSchema =
|
|
2791
|
+
var confirmHandoverSchema = z24.object({ actionId: identifier, handover: identifier }).strict();
|
|
2792
|
+
var entitlementCorrectionSchema = z24.object({
|
|
2592
2793
|
actionId: identifier,
|
|
2593
|
-
revision:
|
|
2594
|
-
reason:
|
|
2794
|
+
revision: z24.number().int().positive(),
|
|
2795
|
+
reason: z24.string().trim().min(1).max(500)
|
|
2595
2796
|
}).strict();
|
|
2596
2797
|
var CompletionSourceKind = {
|
|
2597
2798
|
Quest: "quest",
|
|
2598
2799
|
Leaderboard: "leaderboard"
|
|
2599
2800
|
};
|
|
2600
|
-
var completionSourceKindSchema =
|
|
2601
|
-
var completionSourceSchema =
|
|
2801
|
+
var completionSourceKindSchema = z24.string().min(1).max(64);
|
|
2802
|
+
var completionSourceSchema = z24.object({
|
|
2602
2803
|
kind: completionSourceKindSchema,
|
|
2603
2804
|
id: identifier
|
|
2604
2805
|
});
|
|
2605
|
-
var completionRecordSchema =
|
|
2806
|
+
var completionRecordSchema = z24.object({
|
|
2606
2807
|
/** The occurrence the completion consumed. For a leaderboard prize, the settlement ID. */
|
|
2607
|
-
key:
|
|
2808
|
+
key: z24.string().default("once"),
|
|
2608
2809
|
id: identifier,
|
|
2609
2810
|
/** The quest ID, or the board ID when `source.kind` is `leaderboard`. */
|
|
2610
2811
|
quest: identifier,
|
|
@@ -2612,19 +2813,19 @@ var completionRecordSchema = z23.object({
|
|
|
2612
2813
|
/** What paid the completion. `source.id` repeats `quest`. */
|
|
2613
2814
|
source: completionSourceSchema.optional()
|
|
2614
2815
|
});
|
|
2615
|
-
var questAvailabilitySchema =
|
|
2616
|
-
|
|
2617
|
-
kind:
|
|
2618
|
-
input:
|
|
2816
|
+
var questAvailabilitySchema = z24.discriminatedUnion("kind", [
|
|
2817
|
+
z24.object({
|
|
2818
|
+
kind: z24.literal("available"),
|
|
2819
|
+
input: z24.enum(["photo", "quiz", "none", "text", "url"])
|
|
2619
2820
|
}).strict(),
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
kind:
|
|
2623
|
-
missing:
|
|
2821
|
+
z24.object({ kind: z24.literal("completed") }).strict(),
|
|
2822
|
+
z24.object({
|
|
2823
|
+
kind: z24.literal("locked"),
|
|
2824
|
+
missing: z24.array(missingPrerequisiteSchema).min(1)
|
|
2624
2825
|
}).strict(),
|
|
2625
|
-
|
|
2626
|
-
kind:
|
|
2627
|
-
reason:
|
|
2826
|
+
z24.object({
|
|
2827
|
+
kind: z24.literal("blocked"),
|
|
2828
|
+
reason: z24.enum([
|
|
2628
2829
|
"budget-exhausted",
|
|
2629
2830
|
"connection-required",
|
|
2630
2831
|
"wallet-required",
|
|
@@ -2633,140 +2834,144 @@ var questAvailabilitySchema = z23.discriminatedUnion("kind", [
|
|
|
2633
2834
|
"enrollment-required"
|
|
2634
2835
|
]),
|
|
2635
2836
|
/** Which window refused admission when `reason` is `outside-window`. */
|
|
2636
|
-
window:
|
|
2637
|
-
resetsAt:
|
|
2837
|
+
window: z24.enum(["tracker", "quest"]).optional(),
|
|
2838
|
+
resetsAt: z24.number().int().safe().optional()
|
|
2638
2839
|
}).strict(),
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2840
|
+
z24.object({ kind: z24.literal("staff-required") }).strict(),
|
|
2841
|
+
z24.object({ kind: z24.literal("automatic") }).strict(),
|
|
2842
|
+
z24.object({ kind: z24.literal("checking"), attempt: identifier }).strict(),
|
|
2843
|
+
z24.object({ kind: z24.literal("needs-review"), attempt: identifier }).strict(),
|
|
2844
|
+
z24.object({ kind: z24.literal("retryable"), attempt: identifier }).strict()
|
|
2644
2845
|
]);
|
|
2645
|
-
var questAvailabilityResponseSchema =
|
|
2846
|
+
var questAvailabilityResponseSchema = z24.union(
|
|
2646
2847
|
questAvailabilitySchema.options.map((option) => option.strip())
|
|
2647
2848
|
);
|
|
2648
|
-
var questBudgetViewSchema =
|
|
2849
|
+
var questBudgetViewSchema = z24.object({
|
|
2649
2850
|
id: identifier,
|
|
2650
|
-
scope:
|
|
2651
|
-
period:
|
|
2652
|
-
remaining:
|
|
2653
|
-
resetsAt:
|
|
2654
|
-
});
|
|
2655
|
-
var memberProgressSchema = z23.object({
|
|
2656
|
-
member: identifier,
|
|
2657
|
-
quests: z23.array(
|
|
2658
|
-
z23.object({
|
|
2659
|
-
quest: identifier,
|
|
2660
|
-
key: identifier.optional(),
|
|
2661
|
-
release: identifier.optional(),
|
|
2662
|
-
title: z23.string(),
|
|
2663
|
-
presentation: questPresentationSchema.default({}),
|
|
2664
|
-
connections: z23.array(authProviderSchema).default([]),
|
|
2665
|
-
trigger: triggerResponseSchema,
|
|
2666
|
-
availability: questAvailabilityResponseSchema,
|
|
2667
|
-
completed: z23.boolean(),
|
|
2668
|
-
completion: completionPolicySchema.default({ kind: "once" }),
|
|
2669
|
-
streak: streakProgressSchema.nullable().optional(),
|
|
2670
|
-
counter: counterProgressSchema.nullable().optional(),
|
|
2671
|
-
/** Latest attempt's committed evaluator progress, while it remains deferred/evaluating. */
|
|
2672
|
-
progress: evaluatorProgressSchema.nullable().default(null),
|
|
2673
|
-
completionCount: z23.number().int().nonnegative().default(0),
|
|
2674
|
-
visibility: z23.enum(["visible", "hidden"]).default("visible"),
|
|
2675
|
-
missing: z23.array(missingPrerequisiteSchema),
|
|
2676
|
-
campaign: campaignViewSchema.nullable().default(null),
|
|
2677
|
-
window: availabilityWindowSchema.nullable().default(null),
|
|
2678
|
-
budgets: z23.array(questBudgetViewSchema).default([]),
|
|
2679
|
-
attempt: attemptSchema.nullable()
|
|
2680
|
-
})
|
|
2681
|
-
),
|
|
2682
|
-
entitlements: z23.array(entitlementSchema)
|
|
2683
|
-
});
|
|
2684
|
-
var snapshotSchema = z23.object({
|
|
2685
|
-
releases: z23.array(publishedReleaseSchema),
|
|
2686
|
-
completions: z23.array(completionRecordSchema),
|
|
2687
|
-
entitlements: z23.array(entitlementSchema),
|
|
2688
|
-
attempts: z23.array(attemptSchema),
|
|
2689
|
-
balances: z23.array(
|
|
2690
|
-
z23.object({
|
|
2691
|
-
member: z23.string(),
|
|
2692
|
-
balance: z23.string(),
|
|
2693
|
-
earned: z23.number(),
|
|
2694
|
-
held: z23.number(),
|
|
2695
|
-
available: z23.number()
|
|
2696
|
-
})
|
|
2697
|
-
),
|
|
2698
|
-
events: z23.array(eventSchema)
|
|
2851
|
+
scope: z24.enum(["member", "project"]),
|
|
2852
|
+
period: z24.enum(["day", "week", "month", "lifetime"]),
|
|
2853
|
+
remaining: z24.number().int().safe().nonnegative(),
|
|
2854
|
+
resetsAt: z24.number().int().safe().nullable()
|
|
2699
2855
|
});
|
|
2700
|
-
var
|
|
2856
|
+
var memberProgressSchema = responseShape(
|
|
2857
|
+
z24.object({
|
|
2858
|
+
member: identifier,
|
|
2859
|
+
quests: z24.array(
|
|
2860
|
+
z24.object({
|
|
2861
|
+
quest: identifier,
|
|
2862
|
+
key: identifier.optional(),
|
|
2863
|
+
release: identifier.optional(),
|
|
2864
|
+
title: z24.string(),
|
|
2865
|
+
presentation: questPresentationSchema.default({}),
|
|
2866
|
+
connections: z24.array(authProviderSchema).default([]),
|
|
2867
|
+
trigger: triggerResponseSchema,
|
|
2868
|
+
availability: questAvailabilityResponseSchema,
|
|
2869
|
+
completed: z24.boolean(),
|
|
2870
|
+
completion: completionPolicySchema.default({ kind: "once" }),
|
|
2871
|
+
streak: streakProgressSchema.nullable().optional(),
|
|
2872
|
+
counter: counterProgressSchema.nullable().optional(),
|
|
2873
|
+
/** Latest attempt's committed evaluator progress, while it remains deferred/evaluating. */
|
|
2874
|
+
progress: evaluatorProgressSchema.nullable().default(null),
|
|
2875
|
+
completionCount: z24.number().int().nonnegative().default(0),
|
|
2876
|
+
visibility: z24.enum(["visible", "hidden"]).default("visible"),
|
|
2877
|
+
missing: z24.array(missingPrerequisiteSchema),
|
|
2878
|
+
campaign: campaignViewSchema.nullable().default(null),
|
|
2879
|
+
window: availabilityWindowSchema.nullable().default(null),
|
|
2880
|
+
budgets: z24.array(questBudgetViewSchema).default([]),
|
|
2881
|
+
attempt: attemptSchema.nullable()
|
|
2882
|
+
})
|
|
2883
|
+
),
|
|
2884
|
+
entitlements: z24.array(entitlementSchema)
|
|
2885
|
+
})
|
|
2886
|
+
);
|
|
2887
|
+
var snapshotSchema = responseShape(
|
|
2888
|
+
z24.object({
|
|
2889
|
+
releases: z24.array(publishedReleaseSchema),
|
|
2890
|
+
completions: z24.array(completionRecordSchema),
|
|
2891
|
+
entitlements: z24.array(entitlementSchema),
|
|
2892
|
+
attempts: z24.array(attemptSchema),
|
|
2893
|
+
balances: z24.array(
|
|
2894
|
+
z24.object({
|
|
2895
|
+
member: z24.string(),
|
|
2896
|
+
balance: z24.string(),
|
|
2897
|
+
earned: z24.number(),
|
|
2898
|
+
held: z24.number(),
|
|
2899
|
+
available: z24.number()
|
|
2900
|
+
})
|
|
2901
|
+
),
|
|
2902
|
+
events: z24.array(eventSchema)
|
|
2903
|
+
})
|
|
2904
|
+
);
|
|
2905
|
+
var evidenceSchema = z24.object({
|
|
2701
2906
|
id: identifier,
|
|
2702
2907
|
member: identifier,
|
|
2703
|
-
type:
|
|
2704
|
-
size:
|
|
2908
|
+
type: z24.enum(["image/jpeg", "image/png"]),
|
|
2909
|
+
size: z24.number()
|
|
2705
2910
|
});
|
|
2706
|
-
var errorSchema =
|
|
2707
|
-
error:
|
|
2708
|
-
code:
|
|
2911
|
+
var errorSchema = z24.object({
|
|
2912
|
+
error: z24.string(),
|
|
2913
|
+
code: z24.string().optional(),
|
|
2709
2914
|
/** Which window refused admission when `code` is `outside-window`. */
|
|
2710
|
-
window:
|
|
2711
|
-
missing:
|
|
2915
|
+
window: z24.enum(["tracker", "quest"]).optional(),
|
|
2916
|
+
missing: z24.array(missingPrerequisiteSchema).optional()
|
|
2712
2917
|
});
|
|
2713
|
-
var staffDecisionSchema =
|
|
2918
|
+
var staffDecisionSchema = z24.object({
|
|
2714
2919
|
actionId: identifier,
|
|
2715
|
-
generation:
|
|
2716
|
-
decision:
|
|
2717
|
-
reason:
|
|
2920
|
+
generation: z24.number().int().nonnegative(),
|
|
2921
|
+
decision: z24.enum(["accept", "reject"]),
|
|
2922
|
+
reason: z24.string().trim().min(1).max(2e3)
|
|
2718
2923
|
}).strict();
|
|
2719
|
-
var stockSchema =
|
|
2720
|
-
var reservationSchema =
|
|
2924
|
+
var stockSchema = z24.object({ item: identifier, quantity: z24.number().int().min(0).max(1e4) }).strict();
|
|
2925
|
+
var reservationSchema = z24.object({
|
|
2721
2926
|
actionId: identifier,
|
|
2722
2927
|
member: identifier,
|
|
2723
2928
|
item: identifier,
|
|
2724
2929
|
balance: identifier,
|
|
2725
|
-
price:
|
|
2930
|
+
price: z24.number().int().positive().max(1e4)
|
|
2726
2931
|
}).strict();
|
|
2727
2932
|
var pageOptions = {
|
|
2728
|
-
limit:
|
|
2729
|
-
cursor:
|
|
2933
|
+
limit: z24.number().int().min(1).max(100).default(25),
|
|
2934
|
+
cursor: z24.string().min(1).max(4096).optional()
|
|
2730
2935
|
};
|
|
2731
|
-
var reviewListSchema =
|
|
2936
|
+
var reviewListSchema = z24.object({
|
|
2732
2937
|
...pageOptions,
|
|
2733
2938
|
member: identifier.optional(),
|
|
2734
2939
|
quest: identifier.optional()
|
|
2735
2940
|
}).strict();
|
|
2736
|
-
var memberListSchema =
|
|
2941
|
+
var memberListSchema = z24.object({
|
|
2737
2942
|
...pageOptions,
|
|
2738
2943
|
prefix: identifier.optional()
|
|
2739
2944
|
}).strict();
|
|
2740
|
-
var reviewItemSchema =
|
|
2945
|
+
var reviewItemSchema = z24.object({
|
|
2741
2946
|
attempt: attemptSchema,
|
|
2742
|
-
title:
|
|
2743
|
-
checks:
|
|
2744
|
-
|
|
2947
|
+
title: z24.string(),
|
|
2948
|
+
checks: z24.array(
|
|
2949
|
+
z24.object({ criteria: z24.string(), result: photoResultSchema })
|
|
2745
2950
|
)
|
|
2746
2951
|
});
|
|
2747
|
-
var reviewPageSchema =
|
|
2748
|
-
items:
|
|
2749
|
-
nextCursor:
|
|
2952
|
+
var reviewPageSchema = z24.object({
|
|
2953
|
+
items: z24.array(reviewItemSchema).max(100),
|
|
2954
|
+
nextCursor: z24.string().nullable()
|
|
2750
2955
|
});
|
|
2751
|
-
var memberPageSchema =
|
|
2752
|
-
items:
|
|
2753
|
-
nextCursor:
|
|
2956
|
+
var memberPageSchema = z24.object({
|
|
2957
|
+
items: z24.array(z24.object({ member: identifier })).max(100),
|
|
2958
|
+
nextCursor: z24.string().nullable()
|
|
2754
2959
|
});
|
|
2755
|
-
var createStockItemSchema =
|
|
2756
|
-
var stockItemSchema =
|
|
2757
|
-
var contentPerformanceSnapshotSchema =
|
|
2960
|
+
var createStockItemSchema = z24.object({ actionId: identifier, name: z24.string().trim().min(1).max(80) }).strict();
|
|
2961
|
+
var stockItemSchema = z24.object({ id: identifier, name: z24.string() });
|
|
2962
|
+
var contentPerformanceSnapshotSchema = z24.strictObject({
|
|
2758
2963
|
contentAttempt: identifier,
|
|
2759
2964
|
observation: identifier,
|
|
2760
|
-
observedAt:
|
|
2965
|
+
observedAt: z24.number().int().safe().nonnegative(),
|
|
2761
2966
|
metrics: contentMetricsSchema,
|
|
2762
2967
|
rewards: rewardBundleSchema
|
|
2763
2968
|
});
|
|
2764
2969
|
var contentPerformanceQuerySchema = contentQualificationQuerySchema.extend({
|
|
2765
|
-
content:
|
|
2970
|
+
content: z24.string().min(1).max(256)
|
|
2766
2971
|
});
|
|
2767
|
-
var contentPerformancePageSchema =
|
|
2768
|
-
current:
|
|
2769
|
-
state:
|
|
2972
|
+
var contentPerformancePageSchema = z24.strictObject({
|
|
2973
|
+
current: z24.strictObject({
|
|
2974
|
+
state: z24.enum([
|
|
2770
2975
|
"content-pending",
|
|
2771
2976
|
"content-unqualified",
|
|
2772
2977
|
"waiting",
|
|
@@ -2777,19 +2982,19 @@ var contentPerformancePageSchema = z23.strictObject({
|
|
|
2777
2982
|
"failed",
|
|
2778
2983
|
"superseded"
|
|
2779
2984
|
]),
|
|
2780
|
-
reason:
|
|
2985
|
+
reason: z24.string().nullable(),
|
|
2781
2986
|
contentAttempt: identifier,
|
|
2782
2987
|
attempt: identifier.nullable(),
|
|
2783
2988
|
reward: contentQualificationSchema.shape.reward
|
|
2784
2989
|
}),
|
|
2785
|
-
items:
|
|
2786
|
-
|
|
2990
|
+
items: z24.array(
|
|
2991
|
+
z24.strictObject({
|
|
2787
2992
|
attempt: identifier,
|
|
2788
2993
|
contentAttempt: identifier,
|
|
2789
2994
|
observation: identifier,
|
|
2790
|
-
observedAt:
|
|
2995
|
+
observedAt: z24.number(),
|
|
2791
2996
|
metrics: contentMetricsSchema,
|
|
2792
|
-
state:
|
|
2997
|
+
state: z24.enum([
|
|
2793
2998
|
"pending",
|
|
2794
2999
|
"qualified",
|
|
2795
3000
|
"unqualified",
|
|
@@ -2797,13 +3002,18 @@ var contentPerformancePageSchema = z23.strictObject({
|
|
|
2797
3002
|
"failed",
|
|
2798
3003
|
"superseded"
|
|
2799
3004
|
]),
|
|
2800
|
-
reason:
|
|
3005
|
+
reason: z24.string().nullable()
|
|
2801
3006
|
})
|
|
2802
3007
|
),
|
|
2803
3008
|
nextCursor: pageCursorSchema.nullable()
|
|
2804
3009
|
});
|
|
2805
3010
|
|
|
2806
3011
|
export {
|
|
3012
|
+
markResponseSchema,
|
|
3013
|
+
responseShape,
|
|
3014
|
+
knownResponse,
|
|
3015
|
+
responseSchema,
|
|
3016
|
+
responseListSchema,
|
|
2807
3017
|
pageCursorSchema,
|
|
2808
3018
|
pageQuerySchema,
|
|
2809
3019
|
authProviderSchema,
|