@domino-sdk/relay 0.12.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/authoring.d.ts +3 -2
- package/dist/authoring.js +10 -3
- package/dist/browser.d.ts +54 -54
- package/dist/browser.js +2 -2
- package/dist/{chunk-CE5XVIJQ.js → chunk-XOEREIXI.js} +202 -70
- package/dist/{chunk-NLMEK77N.js → chunk-Y7FVHF65.js} +7 -3
- package/dist/index.d.ts +192 -108
- package/dist/index.js +38 -4
- package/dist/{settings-B61jIDDA.d.ts → settings-CgI5nDQr.d.ts} +341 -1
- package/package.json +1 -1
|
@@ -187,18 +187,133 @@ var referralManagementSchema = z2.object({
|
|
|
187
187
|
next: amount.nullable()
|
|
188
188
|
});
|
|
189
189
|
|
|
190
|
-
// src/
|
|
190
|
+
// src/trackers.ts
|
|
191
191
|
import { z as z3 } from "zod";
|
|
192
|
-
var
|
|
193
|
-
var
|
|
194
|
-
var
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
192
|
+
var timestamp = z3.number().int().safe().nonnegative().max(864e13);
|
|
193
|
+
var count = z3.number().int().safe().nonnegative();
|
|
194
|
+
var externalId = z3.string().min(1).max(256);
|
|
195
|
+
var metric = count.nullable().default(null);
|
|
196
|
+
var xTweetSchema = z3.looseObject({
|
|
197
|
+
id: externalId,
|
|
198
|
+
userId: externalId,
|
|
199
|
+
content: z3.string(),
|
|
200
|
+
createdAt: z3.iso.datetime({ offset: true }),
|
|
201
|
+
author: z3.looseObject({
|
|
202
|
+
id: externalId,
|
|
203
|
+
username: z3.string(),
|
|
204
|
+
name: z3.string(),
|
|
205
|
+
verified: z3.boolean().nullable().default(null)
|
|
206
|
+
}),
|
|
207
|
+
likeCount: metric,
|
|
208
|
+
replyCount: metric,
|
|
209
|
+
retweetCount: metric,
|
|
210
|
+
quoteCount: metric,
|
|
211
|
+
viewCount: metric,
|
|
212
|
+
bookmarkCount: metric,
|
|
213
|
+
isReply: z3.boolean(),
|
|
214
|
+
isRetweet: z3.boolean(),
|
|
215
|
+
isQuoteTweet: z3.boolean()
|
|
216
|
+
});
|
|
217
|
+
var trackerSourceSchema = z3.discriminatedUnion("kind", [
|
|
218
|
+
z3.object({ kind: z3.literal("x-search"), query: z3.string().trim().min(1).max(2e3) }).strict(),
|
|
219
|
+
z3.object({ kind: z3.literal("custom"), namespace: identifier }).strict()
|
|
220
|
+
]);
|
|
221
|
+
var x = {
|
|
222
|
+
search: (input) => trackerSourceSchema.options[0].parse({ kind: "x-search", ...input })
|
|
223
|
+
};
|
|
224
|
+
var customSource = (namespace) => trackerSourceSchema.options[1].parse({ kind: "custom", namespace });
|
|
225
|
+
var windowSchema = z3.object({ start: timestamp, end: timestamp.optional() }).strict().refine((w) => w.end === void 0 || w.end > w.start, "End must follow start");
|
|
226
|
+
var trackerDefinitionSchema = z3.object({
|
|
227
|
+
key: identifier,
|
|
228
|
+
title: z3.string().trim().min(1).max(120),
|
|
229
|
+
source: trackerSourceSchema,
|
|
230
|
+
window: windowSchema,
|
|
231
|
+
refreshSeconds: z3.number().int().min(300).max(86400).default(21600),
|
|
232
|
+
maxPages: z3.number().int().min(1).max(1e3).default(60)
|
|
233
|
+
}).strict();
|
|
234
|
+
var trackerArtifactSchema = z3.union([trackerDefinitionSchema, z3.object({ code: z3.string().min(1).max(2e6) }).strict()]);
|
|
235
|
+
function defineTracker(input) {
|
|
236
|
+
return trackerDefinitionSchema.parse(input);
|
|
237
|
+
}
|
|
238
|
+
var publishedTrackerSchema = z3.object({
|
|
239
|
+
id: identifier,
|
|
240
|
+
version: identifier,
|
|
241
|
+
definition: trackerDefinitionSchema,
|
|
242
|
+
publishedAt: timestamp,
|
|
243
|
+
actor: z3.string().nullable()
|
|
244
|
+
});
|
|
245
|
+
var trackerStatusSchema = z3.object({
|
|
246
|
+
published: publishedTrackerSchema,
|
|
247
|
+
paused: z3.boolean(),
|
|
248
|
+
state: z3.enum(["idle", "syncing", "error", "complete"]),
|
|
249
|
+
lastStartedAt: timestamp.nullable(),
|
|
250
|
+
lastCompletedAt: timestamp.nullable(),
|
|
251
|
+
nextSyncAt: timestamp.nullable(),
|
|
252
|
+
coverage: z3.enum(["unknown", "partial", "complete"]),
|
|
253
|
+
error: z3.string().nullable(),
|
|
254
|
+
records: count
|
|
255
|
+
});
|
|
256
|
+
var trackerControlSchema = z3.object({
|
|
257
|
+
actionId: identifier,
|
|
258
|
+
action: z3.enum(["pause", "resume", "refresh"])
|
|
259
|
+
}).strict();
|
|
260
|
+
var trackerRecordInputSchema = z3.object({
|
|
261
|
+
id: externalId,
|
|
262
|
+
occurredAt: timestamp,
|
|
263
|
+
observedAt: timestamp,
|
|
264
|
+
author: z3.object({ id: externalId, verified: z3.boolean().nullable().default(null) }).strict().nullable().default(null),
|
|
265
|
+
data: z3.record(z3.string(), z3.json()),
|
|
266
|
+
removed: z3.boolean().default(false)
|
|
267
|
+
}).strict().refine((v) => new TextEncoder().encode(JSON.stringify(v.data)).byteLength <= 131072, "Record exceeds 128 KB");
|
|
268
|
+
var trackerRecordSchema = trackerRecordInputSchema.safeExtend({
|
|
269
|
+
source: z3.string(),
|
|
270
|
+
firstSeenAt: timestamp
|
|
271
|
+
});
|
|
272
|
+
var trackerIngestSchema = z3.object({
|
|
273
|
+
actionId: identifier,
|
|
274
|
+
records: z3.array(trackerRecordInputSchema).min(1).max(100)
|
|
275
|
+
}).strict();
|
|
276
|
+
var trackerIngestResultSchema = z3.object({ stored: count });
|
|
277
|
+
var booleanQuery = z3.union([z3.boolean(), z3.enum(["true", "false"]).transform((v) => v === "true")]);
|
|
278
|
+
var trackerQuerySchema = z3.object({
|
|
279
|
+
author: externalId.optional(),
|
|
280
|
+
member: identifier.optional(),
|
|
281
|
+
verified: booleanQuery.optional(),
|
|
282
|
+
since: z3.coerce.number().int().safe().nonnegative().optional(),
|
|
283
|
+
until: z3.coerce.number().int().safe().nonnegative().optional(),
|
|
284
|
+
removed: booleanQuery.default(false),
|
|
285
|
+
minLikes: z3.coerce.number().int().safe().nonnegative().optional(),
|
|
286
|
+
minViews: z3.coerce.number().int().safe().nonnegative().optional(),
|
|
287
|
+
limit: z3.coerce.number().int().min(1).max(100).default(25),
|
|
288
|
+
cursor: z3.string().max(2048).optional()
|
|
289
|
+
}).strict().refine((q) => q.since === void 0 || q.until === void 0 || q.until > q.since, "Until must follow since");
|
|
290
|
+
var trackerPageSchema = z3.object({
|
|
291
|
+
tracker: identifier,
|
|
292
|
+
items: z3.array(trackerRecordSchema),
|
|
293
|
+
nextCursor: z3.string().nullable(),
|
|
294
|
+
total: count,
|
|
295
|
+
status: trackerStatusSchema
|
|
296
|
+
});
|
|
297
|
+
var trackerSummarySchema = z3.object({
|
|
298
|
+
records: count,
|
|
299
|
+
authors: count,
|
|
300
|
+
metrics: z3.object({ likes: count, replies: count, reposts: count, quotes: count, views: count, bookmarks: count }),
|
|
301
|
+
missingMetrics: count,
|
|
302
|
+
status: trackerStatusSchema
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
// src/leaderboards.ts
|
|
306
|
+
import { z as z4 } from "zod";
|
|
307
|
+
var integer = z4.number().int().safe();
|
|
308
|
+
var timestamp2 = integer.nonnegative().max(864e13);
|
|
309
|
+
var leaderboardWindowSchema = z4.discriminatedUnion("kind", [
|
|
310
|
+
z4.object({ kind: z4.literal("all-time") }).strict(),
|
|
311
|
+
z4.object({ kind: z4.literal("fixed"), start: timestamp2, end: timestamp2 }).strict().refine((w) => w.end > w.start, "Window end must follow its start"),
|
|
312
|
+
z4.object({ kind: z4.literal("rolling"), days: integer.min(1).max(3660) }).strict(),
|
|
313
|
+
z4.object({
|
|
314
|
+
kind: z4.literal("calendar"),
|
|
315
|
+
period: z4.enum(["day", "week", "month"]),
|
|
316
|
+
timeZone: z4.string().min(1).max(100).refine((zone) => {
|
|
202
317
|
try {
|
|
203
318
|
new Intl.DateTimeFormat("en", { timeZone: zone });
|
|
204
319
|
return true;
|
|
@@ -210,22 +325,22 @@ var leaderboardWindowSchema = z3.discriminatedUnion("kind", [
|
|
|
210
325
|
]);
|
|
211
326
|
var periodScore = {
|
|
212
327
|
window: leaderboardWindowSchema.default({ kind: "all-time" }),
|
|
213
|
-
quests:
|
|
328
|
+
quests: z4.array(identifier).min(1).max(100).optional()
|
|
214
329
|
};
|
|
215
|
-
var leaderboardDefinitionSchema =
|
|
330
|
+
var leaderboardDefinitionSchema = z4.object({
|
|
216
331
|
id: identifier,
|
|
217
332
|
key: identifier.optional(),
|
|
218
|
-
title:
|
|
333
|
+
title: z4.string().trim().min(1).max(120),
|
|
219
334
|
balance: identifier,
|
|
220
|
-
score:
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
kind:
|
|
335
|
+
score: z4.discriminatedUnion("kind", [
|
|
336
|
+
z4.object({ kind: z4.literal("balance") }).strict(),
|
|
337
|
+
z4.object({ kind: z4.literal("earned"), ...periodScore }).strict(),
|
|
338
|
+
z4.object({
|
|
339
|
+
kind: z4.literal("net"),
|
|
225
340
|
window: leaderboardWindowSchema.default({ kind: "all-time" })
|
|
226
341
|
}).strict()
|
|
227
342
|
]).default({ kind: "balance" }),
|
|
228
|
-
access:
|
|
343
|
+
access: z4.enum(["participants", "public"]).default("participants"),
|
|
229
344
|
group: identifier.optional()
|
|
230
345
|
}).strict();
|
|
231
346
|
var leaderboardAuthoringSchema = leaderboardDefinitionSchema.omit({ id: true }).extend(authoringIdentityShape).strict().superRefine(validateAuthoringIdentity).transform(normalizeAuthoringIdentity);
|
|
@@ -237,42 +352,42 @@ function defineLeaderboard(input) {
|
|
|
237
352
|
id: definition.key
|
|
238
353
|
};
|
|
239
354
|
}
|
|
240
|
-
var leaderboardArtifactSchema =
|
|
355
|
+
var leaderboardArtifactSchema = z4.union([
|
|
241
356
|
leaderboardAuthoringSchema,
|
|
242
|
-
|
|
357
|
+
z4.object({ code: z4.string().min(1).max(2e6) }).strict()
|
|
243
358
|
]);
|
|
244
|
-
var publishedLeaderboardSchema =
|
|
359
|
+
var publishedLeaderboardSchema = z4.object({
|
|
245
360
|
version: identifier,
|
|
246
361
|
definition: leaderboardDefinitionSchema,
|
|
247
|
-
publishedAt:
|
|
248
|
-
actor:
|
|
362
|
+
publishedAt: timestamp2,
|
|
363
|
+
actor: z4.string().nullable()
|
|
249
364
|
});
|
|
250
|
-
var leaderboardQuerySchema =
|
|
251
|
-
limit:
|
|
252
|
-
cursor:
|
|
365
|
+
var leaderboardQuerySchema = z4.object({
|
|
366
|
+
limit: z4.coerce.number().int().min(1).max(100).default(25),
|
|
367
|
+
cursor: z4.string().max(4096).optional()
|
|
253
368
|
}).strict();
|
|
254
|
-
var leaderboardRowSchema =
|
|
369
|
+
var leaderboardRowSchema = z4.object({
|
|
255
370
|
participant: identifier,
|
|
256
371
|
member: identifier.optional(),
|
|
257
|
-
name:
|
|
372
|
+
name: z4.string(),
|
|
258
373
|
score: integer,
|
|
259
374
|
rank: integer.positive()
|
|
260
375
|
});
|
|
261
|
-
var leaderboardPageSchema =
|
|
376
|
+
var leaderboardPageSchema = z4.object({
|
|
262
377
|
leaderboard: identifier,
|
|
263
|
-
title:
|
|
378
|
+
title: z4.string(),
|
|
264
379
|
version: identifier,
|
|
265
|
-
calculation:
|
|
266
|
-
period:
|
|
267
|
-
calculatedAt:
|
|
268
|
-
lastEntryAt:
|
|
380
|
+
calculation: z4.enum(["balance", "earned", "net"]),
|
|
381
|
+
period: z4.object({ start: timestamp2.nullable(), end: timestamp2.nullable() }),
|
|
382
|
+
calculatedAt: timestamp2,
|
|
383
|
+
lastEntryAt: timestamp2.nullable(),
|
|
269
384
|
total: integer.nonnegative(),
|
|
270
|
-
items:
|
|
385
|
+
items: z4.array(leaderboardRowSchema),
|
|
271
386
|
me: leaderboardRowSchema.nullable(),
|
|
272
|
-
nearby:
|
|
273
|
-
nextCursor:
|
|
387
|
+
nearby: z4.array(leaderboardRowSchema),
|
|
388
|
+
nextCursor: z4.string().nullable()
|
|
274
389
|
});
|
|
275
|
-
var leaderboardPreviewSchema =
|
|
390
|
+
var leaderboardPreviewSchema = z4.object({
|
|
276
391
|
published: publishedLeaderboardSchema,
|
|
277
392
|
before: leaderboardPageSchema.nullable(),
|
|
278
393
|
after: leaderboardPageSchema
|
|
@@ -281,75 +396,75 @@ var mutationBase = {
|
|
|
281
396
|
actionId: identifier,
|
|
282
397
|
member: identifier,
|
|
283
398
|
balance: identifier,
|
|
284
|
-
reason:
|
|
399
|
+
reason: z4.string().trim().min(1).max(1e3)
|
|
285
400
|
};
|
|
286
|
-
var datedMutation = { ...mutationBase, effectiveAt:
|
|
287
|
-
var pointsMutationSchema =
|
|
288
|
-
|
|
401
|
+
var datedMutation = { ...mutationBase, effectiveAt: timestamp2.optional() };
|
|
402
|
+
var pointsMutationSchema = z4.discriminatedUnion("kind", [
|
|
403
|
+
z4.object({
|
|
289
404
|
...datedMutation,
|
|
290
|
-
kind:
|
|
291
|
-
referralEligible:
|
|
405
|
+
kind: z4.literal("award"),
|
|
406
|
+
referralEligible: z4.boolean().optional(),
|
|
292
407
|
amount: integer.positive()
|
|
293
408
|
}).strict(),
|
|
294
|
-
|
|
409
|
+
z4.object({
|
|
295
410
|
...datedMutation,
|
|
296
|
-
kind:
|
|
411
|
+
kind: z4.literal("spend"),
|
|
297
412
|
amount: integer.positive()
|
|
298
413
|
}).strict(),
|
|
299
|
-
|
|
414
|
+
z4.object({
|
|
300
415
|
...datedMutation,
|
|
301
|
-
kind:
|
|
416
|
+
kind: z4.literal("adjust"),
|
|
302
417
|
amount: integer.refine((n) => n !== 0)
|
|
303
418
|
}).strict(),
|
|
304
|
-
|
|
419
|
+
z4.object({
|
|
305
420
|
...datedMutation,
|
|
306
|
-
kind:
|
|
421
|
+
kind: z4.literal("set"),
|
|
307
422
|
total: integer.nonnegative(),
|
|
308
423
|
expectedTotal: integer.nonnegative(),
|
|
309
|
-
classification:
|
|
424
|
+
classification: z4.enum(["earned", "spend"])
|
|
310
425
|
}).strict(),
|
|
311
|
-
|
|
426
|
+
z4.object({
|
|
312
427
|
...mutationBase,
|
|
313
|
-
kind:
|
|
428
|
+
kind: z4.literal("reverse"),
|
|
314
429
|
entry: identifier,
|
|
315
430
|
amount: integer.positive()
|
|
316
431
|
}).strict()
|
|
317
432
|
]);
|
|
318
|
-
var pointsEntrySchema =
|
|
433
|
+
var pointsEntrySchema = z4.object({
|
|
319
434
|
id: identifier,
|
|
320
|
-
completion:
|
|
435
|
+
completion: z4.string().nullable(),
|
|
321
436
|
member: identifier,
|
|
322
437
|
balance: identifier,
|
|
323
438
|
amount: integer,
|
|
324
|
-
kind:
|
|
325
|
-
effectiveAt:
|
|
326
|
-
receivedAt:
|
|
439
|
+
kind: z4.enum(["award", "spend", "adjust", "reverse"]),
|
|
440
|
+
effectiveAt: timestamp2,
|
|
441
|
+
receivedAt: timestamp2,
|
|
327
442
|
quest: identifier.nullable(),
|
|
328
443
|
original: identifier.nullable(),
|
|
329
|
-
reason:
|
|
330
|
-
actor:
|
|
444
|
+
reason: z4.string(),
|
|
445
|
+
actor: z4.string().nullable()
|
|
331
446
|
});
|
|
332
|
-
var pointsResultSchema =
|
|
447
|
+
var pointsResultSchema = z4.object({
|
|
333
448
|
entry: pointsEntrySchema,
|
|
334
449
|
total: integer.nonnegative()
|
|
335
450
|
});
|
|
336
|
-
var pointsAccountSchema =
|
|
451
|
+
var pointsAccountSchema = z4.object({
|
|
337
452
|
member: identifier,
|
|
338
453
|
balance: identifier,
|
|
339
454
|
total: integer.nonnegative(),
|
|
340
455
|
held: integer.nonnegative()
|
|
341
456
|
});
|
|
342
|
-
var leaderboardExclusionSchema =
|
|
457
|
+
var leaderboardExclusionSchema = z4.object({
|
|
343
458
|
actionId: identifier,
|
|
344
459
|
member: identifier,
|
|
345
|
-
excluded:
|
|
346
|
-
reason:
|
|
460
|
+
excluded: z4.boolean(),
|
|
461
|
+
reason: z4.string().trim().min(1).max(1e3)
|
|
347
462
|
}).strict();
|
|
348
|
-
var leaderboardGroupSchema =
|
|
463
|
+
var leaderboardGroupSchema = z4.object({
|
|
349
464
|
actionId: identifier,
|
|
350
465
|
member: identifier,
|
|
351
|
-
included:
|
|
352
|
-
reason:
|
|
466
|
+
included: z4.boolean(),
|
|
467
|
+
reason: z4.string().trim().min(1).max(1e3)
|
|
353
468
|
}).strict();
|
|
354
469
|
|
|
355
470
|
export {
|
|
@@ -369,6 +484,23 @@ export {
|
|
|
369
484
|
referralSummarySchema,
|
|
370
485
|
referralHistorySchema,
|
|
371
486
|
referralManagementSchema,
|
|
487
|
+
xTweetSchema,
|
|
488
|
+
trackerSourceSchema,
|
|
489
|
+
x,
|
|
490
|
+
customSource,
|
|
491
|
+
trackerDefinitionSchema,
|
|
492
|
+
trackerArtifactSchema,
|
|
493
|
+
defineTracker,
|
|
494
|
+
publishedTrackerSchema,
|
|
495
|
+
trackerStatusSchema,
|
|
496
|
+
trackerControlSchema,
|
|
497
|
+
trackerRecordInputSchema,
|
|
498
|
+
trackerRecordSchema,
|
|
499
|
+
trackerIngestSchema,
|
|
500
|
+
trackerIngestResultSchema,
|
|
501
|
+
trackerQuerySchema,
|
|
502
|
+
trackerPageSchema,
|
|
503
|
+
trackerSummarySchema,
|
|
372
504
|
leaderboardWindowSchema,
|
|
373
505
|
leaderboardDefinitionSchema,
|
|
374
506
|
leaderboardAuthoringSchema,
|
|
@@ -7,13 +7,15 @@ import {
|
|
|
7
7
|
leaderboardQuerySchema,
|
|
8
8
|
normalizeAuthoringIdentity,
|
|
9
9
|
publishedReferralSchema,
|
|
10
|
+
publishedTrackerSchema,
|
|
10
11
|
referralAcceptSchema,
|
|
11
12
|
referralArtifactSchema,
|
|
12
13
|
referralDefinitionSchema,
|
|
13
14
|
referralHistorySchema,
|
|
14
15
|
referralSummarySchema,
|
|
16
|
+
trackerArtifactSchema,
|
|
15
17
|
validateAuthoringIdentity
|
|
16
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-XOEREIXI.js";
|
|
17
19
|
import {
|
|
18
20
|
authScopeSchema,
|
|
19
21
|
exchangeResultSchema,
|
|
@@ -739,16 +741,18 @@ function questConfiguration(release) {
|
|
|
739
741
|
// src/deployments.ts
|
|
740
742
|
import { z as z7 } from "zod";
|
|
741
743
|
var projectCatalogArtifactSchema = catalogDeploymentSchema.omit({ expectedRevision: true }).extend({
|
|
744
|
+
trackers: z7.array(trackerArtifactSchema).max(50).default([]),
|
|
742
745
|
pointLedgers: z7.array(pointLedgerDeclarationSchema).max(50).default([]),
|
|
743
746
|
referrals: z7.array(referralArtifactSchema).max(50).default([]),
|
|
744
747
|
leaderboards: z7.array(leaderboardArtifactSchema).max(50).default([])
|
|
745
748
|
});
|
|
746
749
|
var projectDeploymentSchema = projectCatalogArtifactSchema.extend({ releases: z7.array(releaseSchema).max(50).default([]) }).refine(
|
|
747
|
-
(value) => value.pointLedgers.length > 0 || value.releases.length > 0 || value.leaderboards.length > 0 || value.referrals.length > 0 || value.types.length > 0 || value.collections.length > 0 || value.supportedInteractions !== void 0,
|
|
748
|
-
"No resources configured. Add quests, questTypes, pointLedgers, leaderboards, referrals, collections, or supportedInteractions to relay.json."
|
|
750
|
+
(value) => value.trackers.length > 0 || value.pointLedgers.length > 0 || value.releases.length > 0 || value.leaderboards.length > 0 || value.referrals.length > 0 || value.types.length > 0 || value.collections.length > 0 || value.supportedInteractions !== void 0,
|
|
751
|
+
"No resources configured. Add trackers, quests, questTypes, pointLedgers, leaderboards, referrals, collections, or supportedInteractions to relay.json."
|
|
749
752
|
);
|
|
750
753
|
var deploymentPreviewSchema = z7.object({
|
|
751
754
|
id: identifier,
|
|
755
|
+
trackers: z7.array(publishedTrackerSchema).default([]),
|
|
752
756
|
baseRevision: z7.number().int().nonnegative(),
|
|
753
757
|
pointLedgers: z7.array(pointLedgerSchema).default([]),
|
|
754
758
|
releases: z7.array(publishedReleaseSchema),
|