@domino-sdk/relay 0.13.0 → 0.14.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.
@@ -2,7 +2,7 @@ import {
2
2
  identifier,
3
3
  pointsRewardSchema,
4
4
  tierRewardSchema
5
- } from "./chunk-3UOTI4IU.js";
5
+ } from "./chunk-FUQYKTOJ.js";
6
6
 
7
7
  // src/authoring-identity.ts
8
8
  import { z } from "zod";
@@ -11,18 +11,20 @@ var authoringIdentityShape = {
11
11
  id: identifier.optional()
12
12
  };
13
13
  function validateAuthoringIdentity(value, ctx) {
14
- if (!value.key && !value.id)
14
+ if (!value.key && !value.id) {
15
15
  ctx.addIssue({
16
16
  code: "custom",
17
17
  path: ["key"],
18
18
  message: "Provide an authoring key. Legacy id is also accepted."
19
19
  });
20
- if (value.key && value.id && value.key !== value.id)
20
+ }
21
+ if (value.key && value.id && value.key !== value.id) {
21
22
  ctx.addIssue({
22
23
  code: "custom",
23
24
  path: ["key"],
24
25
  message: "id and key must match. Keep the existing authoring name to preserve identity."
25
26
  });
27
+ }
26
28
  }
27
29
  function normalizeAuthoringIdentity(value) {
28
30
  const { id, key, ...properties } = value;
@@ -70,14 +72,18 @@ var referralDefinitionSchema = z2.object({
70
72
  }).strict()
71
73
  ).max(20).default([])
72
74
  }).strict().superRefine((value, ctx) => {
73
- for (const entries of [value.milestones, value.bonuses])
74
- if (new Set(entries.map((e) => e.id)).size !== entries.length)
75
+ for (const entries of [value.milestones, value.bonuses]) {
76
+ if (new Set(entries.map((e) => e.id)).size !== entries.length) {
75
77
  ctx.addIssue({ code: "custom", message: "Rule IDs must be unique" });
78
+ }
79
+ }
76
80
  });
77
81
  var referralAuthoringSchema = z2.object(referralDefinitionSchema.shape).omit({ id: true }).extend(authoringIdentityShape).strict().superRefine(validateAuthoringIdentity).superRefine((value, ctx) => {
78
- for (const entries of [value.milestones, value.bonuses])
79
- if (new Set(entries.map((entry) => entry.id)).size !== entries.length)
82
+ for (const entries of [value.milestones, value.bonuses]) {
83
+ if (new Set(entries.map((entry) => entry.id)).size !== entries.length) {
80
84
  ctx.addIssue({ code: "custom", message: "Rule keys must be unique" });
85
+ }
86
+ }
81
87
  }).transform(normalizeAuthoringIdentity);
82
88
  function defineReferral(input) {
83
89
  const definition = referralAuthoringSchema.parse(input);
@@ -215,14 +221,20 @@ var xTweetSchema = z3.looseObject({
215
221
  isQuoteTweet: z3.boolean()
216
222
  });
217
223
  var trackerSourceSchema = z3.discriminatedUnion("kind", [
218
- z3.object({ kind: z3.literal("x-search"), query: z3.string().trim().min(1).max(2e3) }).strict(),
224
+ z3.object({
225
+ kind: z3.literal("x-search"),
226
+ query: z3.string().trim().min(1).max(2e3)
227
+ }).strict(),
219
228
  z3.object({ kind: z3.literal("custom"), namespace: identifier }).strict()
220
229
  ]);
221
230
  var x = {
222
231
  search: (input) => trackerSourceSchema.options[0].parse({ kind: "x-search", ...input })
223
232
  };
224
233
  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");
234
+ var windowSchema = z3.object({ start: timestamp, end: timestamp.optional() }).strict().refine(
235
+ (w) => w.end === void 0 || w.end > w.start,
236
+ "End must follow start"
237
+ );
226
238
  var trackerDefinitionSchema = z3.object({
227
239
  key: identifier,
228
240
  title: z3.string().trim().min(1).max(120),
@@ -231,7 +243,10 @@ var trackerDefinitionSchema = z3.object({
231
243
  refreshSeconds: z3.number().int().min(300).max(86400).default(21600),
232
244
  maxPages: z3.number().int().min(1).max(1e3).default(60)
233
245
  }).strict();
234
- var trackerArtifactSchema = z3.union([trackerDefinitionSchema, z3.object({ code: z3.string().min(1).max(2e6) }).strict()]);
246
+ var trackerArtifactSchema = z3.union([
247
+ trackerDefinitionSchema,
248
+ z3.object({ code: z3.string().min(1).max(2e6) }).strict()
249
+ ]);
235
250
  function defineTracker(input) {
236
251
  return trackerDefinitionSchema.parse(input);
237
252
  }
@@ -261,10 +276,16 @@ var trackerRecordInputSchema = z3.object({
261
276
  id: externalId,
262
277
  occurredAt: timestamp,
263
278
  observedAt: timestamp,
264
- author: z3.object({ id: externalId, verified: z3.boolean().nullable().default(null) }).strict().nullable().default(null),
279
+ author: z3.object({
280
+ id: externalId,
281
+ verified: z3.boolean().nullable().default(null)
282
+ }).strict().nullable().default(null),
265
283
  data: z3.record(z3.string(), z3.json()),
266
284
  removed: z3.boolean().default(false)
267
- }).strict().refine((v) => new TextEncoder().encode(JSON.stringify(v.data)).byteLength <= 131072, "Record exceeds 128 KB");
285
+ }).strict().refine(
286
+ (v) => new TextEncoder().encode(JSON.stringify(v.data)).byteLength <= 131072,
287
+ "Record exceeds 128 KB"
288
+ );
268
289
  var trackerRecordSchema = trackerRecordInputSchema.safeExtend({
269
290
  source: z3.string(),
270
291
  firstSeenAt: timestamp
@@ -274,7 +295,10 @@ var trackerIngestSchema = z3.object({
274
295
  records: z3.array(trackerRecordInputSchema).min(1).max(100)
275
296
  }).strict();
276
297
  var trackerIngestResultSchema = z3.object({ stored: count });
277
- var booleanQuery = z3.union([z3.boolean(), z3.enum(["true", "false"]).transform((v) => v === "true")]);
298
+ var booleanQuery = z3.union([
299
+ z3.boolean(),
300
+ z3.enum(["true", "false"]).transform((v) => v === "true")
301
+ ]);
278
302
  var trackerQuerySchema = z3.object({
279
303
  author: externalId.optional(),
280
304
  member: identifier.optional(),
@@ -286,7 +310,10 @@ var trackerQuerySchema = z3.object({
286
310
  minViews: z3.coerce.number().int().safe().nonnegative().optional(),
287
311
  limit: z3.coerce.number().int().min(1).max(100).default(25),
288
312
  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");
313
+ }).strict().refine(
314
+ (q) => q.since === void 0 || q.until === void 0 || q.until > q.since,
315
+ "Until must follow since"
316
+ );
290
317
  var trackerPageSchema = z3.object({
291
318
  tracker: identifier,
292
319
  items: z3.array(trackerRecordSchema),
@@ -297,10 +324,37 @@ var trackerPageSchema = z3.object({
297
324
  var trackerSummarySchema = z3.object({
298
325
  records: count,
299
326
  authors: count,
300
- metrics: z3.object({ likes: count, replies: count, reposts: count, quotes: count, views: count, bookmarks: count }),
327
+ metrics: z3.object({
328
+ likes: count,
329
+ replies: count,
330
+ reposts: count,
331
+ quotes: count,
332
+ views: count,
333
+ bookmarks: count
334
+ }),
301
335
  missingMetrics: count,
302
336
  status: trackerStatusSchema
303
337
  });
338
+ var trackerPreviewLimits = {
339
+ pages: 3,
340
+ posts: 100,
341
+ days: 30
342
+ };
343
+ var trackerPreviewInputSchema = z3.object({
344
+ query: trackerSourceSchema.options[0].shape.query,
345
+ /** Start of the searched window. The window ends when the sample is fetched. */
346
+ since: timestamp
347
+ }).strict();
348
+ var trackerPreviewSchema = z3.object({
349
+ query: z3.string(),
350
+ since: timestamp,
351
+ fetchedAt: timestamp,
352
+ pages: count,
353
+ /** Every match in the sample, newest first, verified or not. */
354
+ posts: z3.array(xTweetSchema).max(trackerPreviewLimits.posts),
355
+ /** X had more matches than the sample holds. */
356
+ more: z3.boolean()
357
+ });
304
358
 
305
359
  // src/leaderboards.ts
306
360
  import { z as z4 } from "zod";
@@ -501,6 +555,9 @@ export {
501
555
  trackerQuerySchema,
502
556
  trackerPageSchema,
503
557
  trackerSummarySchema,
558
+ trackerPreviewLimits,
559
+ trackerPreviewInputSchema,
560
+ trackerPreviewSchema,
504
561
  leaderboardWindowSchema,
505
562
  leaderboardDefinitionSchema,
506
563
  leaderboardAuthoringSchema,
@@ -2,7 +2,9 @@
2
2
  import { z } from "zod";
3
3
  var communityTimeZoneSchema = z.string().min(1).max(100).refine((zone) => {
4
4
  try {
5
- if (/^[+-]/.test(zone)) return false;
5
+ if (/^[+-]/.test(zone)) {
6
+ return false;
7
+ }
6
8
  new Intl.DateTimeFormat("en", { timeZone: zone });
7
9
  return true;
8
10
  } catch {
@@ -23,12 +25,30 @@ var streakProgressSchema = z.object({
23
25
  todayQualified: z.boolean(),
24
26
  timeZone: communityTimeZoneSchema,
25
27
  nextBoundary: z.number().int(),
26
- pendingTimeZone: z.object({ timeZone: communityTimeZoneSchema, effectiveAt: z.number().int() }).nullable(),
27
- days: z.array(z.object({ day: z.number().int(), date: z.string(), timeZone: communityTimeZoneSchema, occurredAt: z.number().int() })),
28
+ pendingTimeZone: z.object({
29
+ timeZone: communityTimeZoneSchema,
30
+ effectiveAt: z.number().int()
31
+ }).nullable(),
32
+ days: z.array(
33
+ z.object({
34
+ day: z.number().int(),
35
+ date: z.string(),
36
+ timeZone: communityTimeZoneSchema,
37
+ occurredAt: z.number().int()
38
+ })
39
+ ),
28
40
  milestone: z.discriminatedUnion("status", [
29
41
  z.object({ status: z.literal("pending") }),
30
- z.object({ status: z.literal("awarded"), completion: z.string(), achievedAt: z.number().int() }),
31
- z.object({ status: z.literal("budget-exhausted"), budget: z.string(), achievedAt: z.number().int() })
42
+ z.object({
43
+ status: z.literal("awarded"),
44
+ completion: z.string(),
45
+ achievedAt: z.number().int()
46
+ }),
47
+ z.object({
48
+ status: z.literal("budget-exhausted"),
49
+ budget: z.string(),
50
+ achievedAt: z.number().int()
51
+ })
32
52
  ])
33
53
  });
34
54
 
@@ -406,8 +426,9 @@ var rewardSchema = z9.union([
406
426
  integrationRewardSchema
407
427
  ]);
408
428
  function rewardKey(reward) {
409
- if (reward.kind === "integration")
429
+ if (reward.kind === "integration") {
410
430
  return `integration:${reward.provider}:${reward.action}:${reward.roleId}`;
431
+ }
411
432
  return reward.kind === "points" ? "points:" + reward.balance : "tier:" + reward.reward.id;
412
433
  }
413
434
  var triggerSchema = z9.union([
@@ -453,7 +474,9 @@ var rewardBundleSchema = z9.array(rewardSchema).max(10).refine(
453
474
  "Use one entry per balance or shared reward"
454
475
  );
455
476
  var mediaUrlSchema = z9.string().max(2e3).refine((value) => {
456
- if (/^\/(?!\/)[^\\\s]*$/.test(value)) return true;
477
+ if (/^\/(?!\/)[^\\\s]*$/.test(value)) {
478
+ return true;
479
+ }
457
480
  try {
458
481
  return new URL(value).protocol === "https:";
459
482
  } catch {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  identifier
3
- } from "./chunk-3UOTI4IU.js";
3
+ } from "./chunk-FUQYKTOJ.js";
4
4
 
5
5
  // src/auth.ts
6
6
  import { z } from "zod";