@domino-sdk/relay 0.17.1 → 0.18.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 +48 -12
- package/dist/authoring.js +64 -7
- package/dist/browser.d.ts +503 -202
- package/dist/browser.js +5 -5
- package/dist/chunk-23ZZTCDK.js +1511 -0
- package/dist/{chunk-GEJK7LMK.js → chunk-6GH4NC2T.js} +1 -1
- package/dist/{chunk-XNS25KST.js → chunk-FBOW2TLN.js} +265 -272
- package/dist/{chunk-MK2E36HR.js → chunk-MVDIVWR5.js} +1 -1
- package/dist/{chunk-TI22MU2X.js → chunk-TQUK4DIW.js} +85 -10
- package/dist/index.d.ts +1299 -337
- package/dist/index.js +110 -26
- package/dist/portal-proxy.js +5 -3
- package/dist/react/index.d.ts +437 -126
- package/dist/react/index.js +5 -5
- package/dist/schema.d.ts +332 -41
- package/dist/schema.js +7 -1
- package/dist/{submission-input-Cktvl71b.d.ts → submission-input-DWlvrAQY.d.ts} +829 -8
- package/package.json +1 -1
- package/dist/chunk-YUAE6PFY.js +0 -1048
|
@@ -1,11 +1,170 @@
|
|
|
1
1
|
import {
|
|
2
|
+
contentMetricSchema,
|
|
3
|
+
contentMetricsSchema,
|
|
2
4
|
identifier,
|
|
3
5
|
pointsRewardSchema,
|
|
4
6
|
tierRewardSchema
|
|
5
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-23ZZTCDK.js";
|
|
6
8
|
|
|
7
|
-
// src/
|
|
9
|
+
// src/engagement.ts
|
|
8
10
|
import { z } from "zod";
|
|
11
|
+
var amount = z.number().int().safe().nonnegative();
|
|
12
|
+
var engagementDefinitionSchema = z.strictObject({
|
|
13
|
+
key: identifier,
|
|
14
|
+
qualifiedBy: identifier,
|
|
15
|
+
balance: identifier,
|
|
16
|
+
metrics: z.array(contentMetricSchema).min(1).max(6).refine(
|
|
17
|
+
(metrics) => new Set(metrics).size === metrics.length,
|
|
18
|
+
"Metrics must be unique"
|
|
19
|
+
),
|
|
20
|
+
baseline: z.literal("historical"),
|
|
21
|
+
maxAgeMs: z.number().int().positive().max(864e5).default(36e5),
|
|
22
|
+
budget: z.strictObject({
|
|
23
|
+
projectDaily: amount.optional(),
|
|
24
|
+
memberDaily: amount.optional(),
|
|
25
|
+
projectLifetime: amount.optional()
|
|
26
|
+
}).default({})
|
|
27
|
+
});
|
|
28
|
+
var engagementScoreInputSchema = z.strictObject({
|
|
29
|
+
metrics: contentMetricsSchema,
|
|
30
|
+
baseline: contentMetricsSchema
|
|
31
|
+
});
|
|
32
|
+
var engagementScoreSchema = z.strictObject({
|
|
33
|
+
target: amount,
|
|
34
|
+
baseline: amount
|
|
35
|
+
});
|
|
36
|
+
var engagementPublishSchema = z.strictObject({
|
|
37
|
+
actionId: identifier,
|
|
38
|
+
code: z.string().min(1).max(1e6)
|
|
39
|
+
});
|
|
40
|
+
var engagementRuleSchema = z.strictObject({
|
|
41
|
+
version: identifier,
|
|
42
|
+
definition: engagementDefinitionSchema,
|
|
43
|
+
publishedAt: amount
|
|
44
|
+
});
|
|
45
|
+
var engagementPageQuerySchema = z.strictObject({
|
|
46
|
+
rule: identifier,
|
|
47
|
+
content: z.string().min(1).max(256),
|
|
48
|
+
member: identifier.optional(),
|
|
49
|
+
before: z.coerce.number().int().positive().safe().optional()
|
|
50
|
+
});
|
|
51
|
+
var engagementSettlementSchema = z.strictObject({
|
|
52
|
+
id: identifier,
|
|
53
|
+
day: z.string(),
|
|
54
|
+
observation: identifier,
|
|
55
|
+
qualification: identifier,
|
|
56
|
+
earned: amount,
|
|
57
|
+
growth: amount,
|
|
58
|
+
paid: amount,
|
|
59
|
+
excluded: amount,
|
|
60
|
+
entry: identifier.nullable(),
|
|
61
|
+
createdAt: amount
|
|
62
|
+
});
|
|
63
|
+
var engagementPageSchema = z.strictObject({
|
|
64
|
+
rule: engagementRuleSchema,
|
|
65
|
+
account: z.strictObject({
|
|
66
|
+
member: identifier,
|
|
67
|
+
earned: amount,
|
|
68
|
+
accounted: amount,
|
|
69
|
+
paid: amount,
|
|
70
|
+
excluded: amount,
|
|
71
|
+
pending: amount,
|
|
72
|
+
counters: contentMetricsSchema,
|
|
73
|
+
baseline: contentMetricsSchema,
|
|
74
|
+
observation: identifier.nullable(),
|
|
75
|
+
nextSettlementAt: amount.nullable(),
|
|
76
|
+
reason: z.string().nullable()
|
|
77
|
+
}).nullable(),
|
|
78
|
+
items: z.array(engagementSettlementSchema),
|
|
79
|
+
next: amount.nullable()
|
|
80
|
+
});
|
|
81
|
+
function defineEngagementReward(input) {
|
|
82
|
+
const { target, ...config } = input;
|
|
83
|
+
const definition = engagementDefinitionSchema.parse({
|
|
84
|
+
...config,
|
|
85
|
+
qualifiedBy: typeof input.qualifiedBy === "string" ? input.qualifiedBy : input.qualifiedBy.key
|
|
86
|
+
});
|
|
87
|
+
const selected = z.record(z.enum(input.metrics), amount);
|
|
88
|
+
return {
|
|
89
|
+
key: definition.key,
|
|
90
|
+
describe: () => definition,
|
|
91
|
+
score(raw) {
|
|
92
|
+
const sample = engagementScoreInputSchema.parse(raw);
|
|
93
|
+
return engagementScoreSchema.parse({
|
|
94
|
+
target: target({ metrics: selected.parse(sample.metrics) }),
|
|
95
|
+
baseline: target({ metrics: selected.parse(sample.baseline) })
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
var engagementChangePreviewInputSchema = z.strictObject({
|
|
101
|
+
code: z.string().min(1).max(1e6)
|
|
102
|
+
});
|
|
103
|
+
var engagementChangeSchema = engagementPublishSchema.extend({
|
|
104
|
+
expectedVersion: identifier,
|
|
105
|
+
previewHash: identifier
|
|
106
|
+
});
|
|
107
|
+
var total = z.string().regex(/^(0|[1-9][0-9]*)$/);
|
|
108
|
+
var engagementChangePreviewSchema = z.strictObject({
|
|
109
|
+
rule: identifier,
|
|
110
|
+
fromVersion: identifier,
|
|
111
|
+
toVersion: identifier,
|
|
112
|
+
previewHash: identifier,
|
|
113
|
+
definition: engagementDefinitionSchema,
|
|
114
|
+
boundary: z.literal("available-eligible-observation"),
|
|
115
|
+
settlement: z.literal("deferred"),
|
|
116
|
+
summary: z.strictObject({
|
|
117
|
+
knownAdmissions: amount,
|
|
118
|
+
accounts: amount,
|
|
119
|
+
uninitialized: amount,
|
|
120
|
+
pendingTransitions: amount,
|
|
121
|
+
earned: total,
|
|
122
|
+
paid: total,
|
|
123
|
+
excluded: total,
|
|
124
|
+
pending: total
|
|
125
|
+
})
|
|
126
|
+
});
|
|
127
|
+
var engagementVersionPageSchema = z.strictObject({
|
|
128
|
+
items: z.array(
|
|
129
|
+
engagementRuleSchema.extend({ previousVersion: identifier.nullable() })
|
|
130
|
+
),
|
|
131
|
+
next: amount.nullable()
|
|
132
|
+
});
|
|
133
|
+
var engagementVersionQuerySchema = z.strictObject({
|
|
134
|
+
rule: identifier,
|
|
135
|
+
before: z.coerce.number().int().positive().safe().optional()
|
|
136
|
+
});
|
|
137
|
+
var engagementBoundaryPageSchema = z.strictObject({
|
|
138
|
+
current: engagementRuleSchema.nullable(),
|
|
139
|
+
requested: engagementRuleSchema,
|
|
140
|
+
items: z.array(
|
|
141
|
+
z.strictObject({
|
|
142
|
+
from: identifier,
|
|
143
|
+
to: identifier,
|
|
144
|
+
baseline: contentMetricsSchema,
|
|
145
|
+
observedAt: amount,
|
|
146
|
+
settlement: engagementSettlementSchema
|
|
147
|
+
})
|
|
148
|
+
),
|
|
149
|
+
next: amount.nullable()
|
|
150
|
+
});
|
|
151
|
+
var engagementArtifactSchema = engagementPublishSchema.omit({
|
|
152
|
+
actionId: true
|
|
153
|
+
});
|
|
154
|
+
var deploymentEntry = engagementArtifactSchema.extend({
|
|
155
|
+
rule: engagementRuleSchema
|
|
156
|
+
});
|
|
157
|
+
var engagementDeploymentEntrySchema = z.discriminatedUnion("kind", [
|
|
158
|
+
deploymentEntry.extend({ kind: z.literal("create") }),
|
|
159
|
+
deploymentEntry.extend({ kind: z.literal("unchanged") }),
|
|
160
|
+
deploymentEntry.extend({
|
|
161
|
+
kind: z.literal("change"),
|
|
162
|
+
change: engagementChangePreviewSchema
|
|
163
|
+
})
|
|
164
|
+
]);
|
|
165
|
+
|
|
166
|
+
// src/authoring-identity.ts
|
|
167
|
+
import { z as z2 } from "zod";
|
|
9
168
|
var authoringIdentityShape = {
|
|
10
169
|
key: identifier.optional(),
|
|
11
170
|
id: identifier.optional()
|
|
@@ -30,45 +189,45 @@ function normalizeAuthoringIdentity(value) {
|
|
|
30
189
|
const { id, key, ...properties } = value;
|
|
31
190
|
return { ...properties, key: identifier.parse(key ?? id) };
|
|
32
191
|
}
|
|
33
|
-
var identitySchema =
|
|
192
|
+
var identitySchema = z2.object(authoringIdentityShape).superRefine(validateAuthoringIdentity).transform(normalizeAuthoringIdentity);
|
|
34
193
|
var authoringKey = (input) => identitySchema.parse(input).key;
|
|
35
194
|
|
|
36
195
|
// src/referrals.ts
|
|
37
|
-
import { z as
|
|
38
|
-
var rewardSchema =
|
|
39
|
-
var
|
|
40
|
-
var reason =
|
|
41
|
-
var referralDefinitionSchema =
|
|
196
|
+
import { z as z3 } from "zod";
|
|
197
|
+
var rewardSchema = z3.union([pointsRewardSchema, tierRewardSchema]);
|
|
198
|
+
var amount2 = z3.number().int().safe().nonnegative();
|
|
199
|
+
var reason = z3.string().trim().min(1).max(1e3);
|
|
200
|
+
var referralDefinitionSchema = z3.object({
|
|
42
201
|
id: identifier,
|
|
43
202
|
key: identifier.optional(),
|
|
44
|
-
title:
|
|
45
|
-
enabled:
|
|
46
|
-
qualification:
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
203
|
+
title: z3.string().trim().min(1).max(120),
|
|
204
|
+
enabled: z3.boolean().default(true),
|
|
205
|
+
qualification: z3.discriminatedUnion("kind", [
|
|
206
|
+
z3.object({ kind: z3.literal("signup") }).strict(),
|
|
207
|
+
z3.object({ kind: z3.literal("quest"), quest: identifier }).strict(),
|
|
208
|
+
z3.object({ kind: z3.literal("external") }).strict()
|
|
50
209
|
]),
|
|
51
210
|
inviterGroup: identifier.optional(),
|
|
52
|
-
rewards:
|
|
53
|
-
inviter:
|
|
54
|
-
invitee:
|
|
211
|
+
rewards: z3.object({
|
|
212
|
+
inviter: z3.array(rewardSchema).max(10).default([]),
|
|
213
|
+
invitee: z3.array(rewardSchema).max(10).default([])
|
|
55
214
|
}).strict().default({ inviter: [], invitee: [] }),
|
|
56
|
-
milestones:
|
|
57
|
-
|
|
215
|
+
milestones: z3.array(
|
|
216
|
+
z3.object({
|
|
58
217
|
id: identifier,
|
|
59
|
-
count:
|
|
60
|
-
rewards:
|
|
218
|
+
count: amount2.min(1),
|
|
219
|
+
rewards: z3.array(rewardSchema).min(1).max(10)
|
|
61
220
|
}).strict()
|
|
62
221
|
).max(30).default([]),
|
|
63
|
-
bonuses:
|
|
64
|
-
|
|
222
|
+
bonuses: z3.array(
|
|
223
|
+
z3.object({
|
|
65
224
|
id: identifier,
|
|
66
225
|
balance: identifier,
|
|
67
|
-
basisPoints:
|
|
68
|
-
quests:
|
|
69
|
-
external:
|
|
70
|
-
durationDays:
|
|
71
|
-
maxPoints:
|
|
226
|
+
basisPoints: amount2.min(1).max(1e4),
|
|
227
|
+
quests: z3.array(identifier).min(1).max(100).optional(),
|
|
228
|
+
external: z3.boolean().default(false),
|
|
229
|
+
durationDays: amount2.min(1).max(36500).optional(),
|
|
230
|
+
maxPoints: amount2.min(1).optional()
|
|
72
231
|
}).strict()
|
|
73
232
|
).max(20).default([])
|
|
74
233
|
}).strict().superRefine((value, ctx) => {
|
|
@@ -78,7 +237,7 @@ var referralDefinitionSchema = z2.object({
|
|
|
78
237
|
}
|
|
79
238
|
}
|
|
80
239
|
});
|
|
81
|
-
var referralAuthoringSchema =
|
|
240
|
+
var referralAuthoringSchema = z3.object(referralDefinitionSchema.shape).omit({ id: true }).extend(authoringIdentityShape).strict().superRefine(validateAuthoringIdentity).superRefine((value, ctx) => {
|
|
82
241
|
for (const entries of [value.milestones, value.bonuses]) {
|
|
83
242
|
if (new Set(entries.map((entry) => entry.id)).size !== entries.length) {
|
|
84
243
|
ctx.addIssue({ code: "custom", message: "Rule keys must be unique" });
|
|
@@ -93,276 +252,113 @@ function defineReferral(input) {
|
|
|
93
252
|
id: definition.key
|
|
94
253
|
};
|
|
95
254
|
}
|
|
96
|
-
var referralArtifactSchema =
|
|
255
|
+
var referralArtifactSchema = z3.union([
|
|
97
256
|
referralAuthoringSchema,
|
|
98
|
-
|
|
257
|
+
z3.object({ code: z3.string().min(1).max(2e6) }).strict()
|
|
99
258
|
]);
|
|
100
|
-
var publishedReferralSchema =
|
|
259
|
+
var publishedReferralSchema = z3.object({
|
|
101
260
|
version: identifier,
|
|
102
261
|
definition: referralDefinitionSchema,
|
|
103
|
-
publishedAt:
|
|
104
|
-
actor:
|
|
262
|
+
publishedAt: amount2,
|
|
263
|
+
actor: z3.string().nullable()
|
|
105
264
|
});
|
|
106
|
-
var referralAcceptSchema =
|
|
107
|
-
var referralControlSchema =
|
|
108
|
-
|
|
109
|
-
kind:
|
|
265
|
+
var referralAcceptSchema = z3.object({ actionId: identifier, code: identifier }).strict();
|
|
266
|
+
var referralControlSchema = z3.discriminatedUnion("kind", [
|
|
267
|
+
z3.object({
|
|
268
|
+
kind: z3.literal("suspend"),
|
|
110
269
|
actionId: identifier,
|
|
111
270
|
member: identifier,
|
|
112
|
-
suspended:
|
|
271
|
+
suspended: z3.boolean(),
|
|
113
272
|
reason
|
|
114
273
|
}).strict(),
|
|
115
|
-
|
|
116
|
-
kind:
|
|
274
|
+
z3.object({
|
|
275
|
+
kind: z3.literal("qualify"),
|
|
117
276
|
actionId: identifier,
|
|
118
277
|
member: identifier,
|
|
119
278
|
program: identifier,
|
|
120
|
-
qualified:
|
|
279
|
+
qualified: z3.boolean(),
|
|
121
280
|
reason
|
|
122
281
|
}).strict(),
|
|
123
|
-
|
|
124
|
-
kind:
|
|
282
|
+
z3.object({
|
|
283
|
+
kind: z3.literal("resolve-reward"),
|
|
125
284
|
actionId: identifier,
|
|
126
285
|
entitlement: identifier,
|
|
127
286
|
reason
|
|
128
287
|
}).strict()
|
|
129
288
|
]);
|
|
130
|
-
var referralRelationshipSchema =
|
|
289
|
+
var referralRelationshipSchema = z3.object({
|
|
131
290
|
member: identifier,
|
|
132
291
|
inviter: identifier,
|
|
133
|
-
acceptedAt:
|
|
134
|
-
suspended:
|
|
292
|
+
acceptedAt: amount2,
|
|
293
|
+
suspended: z3.boolean()
|
|
135
294
|
});
|
|
136
|
-
var referralAccountSchema =
|
|
295
|
+
var referralAccountSchema = z3.object({
|
|
137
296
|
id: identifier,
|
|
138
297
|
program: identifier,
|
|
139
|
-
kind:
|
|
298
|
+
kind: z3.enum(["bonus", "fixed", "milestone"]),
|
|
140
299
|
balance: identifier,
|
|
141
|
-
earned:
|
|
142
|
-
settled:
|
|
143
|
-
outstanding:
|
|
300
|
+
earned: amount2,
|
|
301
|
+
settled: amount2,
|
|
302
|
+
outstanding: amount2
|
|
144
303
|
});
|
|
145
|
-
var referralSummarySchema =
|
|
304
|
+
var referralSummarySchema = z3.object({
|
|
146
305
|
code: identifier,
|
|
147
|
-
attributed:
|
|
148
|
-
programs:
|
|
149
|
-
|
|
306
|
+
attributed: amount2,
|
|
307
|
+
programs: z3.array(
|
|
308
|
+
z3.object({
|
|
150
309
|
definition: referralDefinitionSchema,
|
|
151
|
-
qualified:
|
|
152
|
-
milestones:
|
|
153
|
-
|
|
310
|
+
qualified: amount2,
|
|
311
|
+
milestones: z3.array(
|
|
312
|
+
z3.object({ id: identifier, count: amount2, reached: z3.boolean() })
|
|
154
313
|
)
|
|
155
314
|
})
|
|
156
315
|
),
|
|
157
|
-
accounts:
|
|
316
|
+
accounts: z3.array(referralAccountSchema)
|
|
158
317
|
});
|
|
159
|
-
var referralHistorySchema =
|
|
160
|
-
items:
|
|
161
|
-
|
|
162
|
-
id:
|
|
318
|
+
var referralHistorySchema = z3.object({
|
|
319
|
+
items: z3.array(
|
|
320
|
+
z3.object({
|
|
321
|
+
id: amount2,
|
|
163
322
|
program: identifier,
|
|
164
323
|
balance: identifier,
|
|
165
|
-
amount:
|
|
166
|
-
at:
|
|
167
|
-
reason:
|
|
324
|
+
amount: z3.number().int().safe(),
|
|
325
|
+
at: amount2,
|
|
326
|
+
reason: z3.string()
|
|
168
327
|
})
|
|
169
328
|
),
|
|
170
|
-
next:
|
|
329
|
+
next: amount2.nullable()
|
|
171
330
|
});
|
|
172
|
-
var referralManagementSchema =
|
|
173
|
-
relationships:
|
|
174
|
-
qualifications:
|
|
175
|
-
|
|
331
|
+
var referralManagementSchema = z3.object({
|
|
332
|
+
relationships: z3.array(referralRelationshipSchema),
|
|
333
|
+
qualifications: z3.array(
|
|
334
|
+
z3.object({
|
|
176
335
|
member: identifier,
|
|
177
336
|
program: identifier,
|
|
178
|
-
qualified:
|
|
179
|
-
qualifiedAt:
|
|
337
|
+
qualified: z3.boolean(),
|
|
338
|
+
qualifiedAt: amount2
|
|
180
339
|
})
|
|
181
340
|
),
|
|
182
|
-
accounts:
|
|
183
|
-
referralAccountSchema.extend({ member: identifier, invitee:
|
|
341
|
+
accounts: z3.array(
|
|
342
|
+
referralAccountSchema.extend({ member: identifier, invitee: z3.string() })
|
|
184
343
|
),
|
|
185
|
-
reviews:
|
|
186
|
-
|
|
344
|
+
reviews: z3.array(
|
|
345
|
+
z3.object({
|
|
187
346
|
entitlement: identifier,
|
|
188
347
|
member: identifier,
|
|
189
348
|
program: identifier,
|
|
190
|
-
reason:
|
|
349
|
+
reason: z3.string()
|
|
191
350
|
})
|
|
192
351
|
),
|
|
193
|
-
next:
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
// src/trackers.ts
|
|
197
|
-
import { z as z3 } from "zod";
|
|
198
|
-
var timestamp = z3.number().int().safe().nonnegative().max(864e13);
|
|
199
|
-
var count = z3.number().int().safe().nonnegative();
|
|
200
|
-
var externalId = z3.string().min(1).max(256);
|
|
201
|
-
var metric = count.nullable().default(null);
|
|
202
|
-
var xTweetSchema = z3.looseObject({
|
|
203
|
-
id: externalId,
|
|
204
|
-
userId: externalId,
|
|
205
|
-
content: z3.string(),
|
|
206
|
-
createdAt: z3.iso.datetime({ offset: true }),
|
|
207
|
-
author: z3.looseObject({
|
|
208
|
-
id: externalId,
|
|
209
|
-
username: z3.string(),
|
|
210
|
-
name: z3.string(),
|
|
211
|
-
verified: z3.boolean().nullable().default(null)
|
|
212
|
-
}),
|
|
213
|
-
likeCount: metric,
|
|
214
|
-
replyCount: metric,
|
|
215
|
-
retweetCount: metric,
|
|
216
|
-
quoteCount: metric,
|
|
217
|
-
viewCount: metric,
|
|
218
|
-
bookmarkCount: metric,
|
|
219
|
-
isReply: z3.boolean(),
|
|
220
|
-
isRetweet: z3.boolean(),
|
|
221
|
-
isQuoteTweet: z3.boolean()
|
|
222
|
-
});
|
|
223
|
-
var trackerSourceSchema = z3.discriminatedUnion("kind", [
|
|
224
|
-
z3.object({
|
|
225
|
-
kind: z3.literal("x-search"),
|
|
226
|
-
query: z3.string().trim().min(1).max(2e3)
|
|
227
|
-
}).strict(),
|
|
228
|
-
z3.object({ kind: z3.literal("custom"), namespace: identifier }).strict()
|
|
229
|
-
]);
|
|
230
|
-
var x = {
|
|
231
|
-
search: (input) => trackerSourceSchema.options[0].parse({ kind: "x-search", ...input })
|
|
232
|
-
};
|
|
233
|
-
var customSource = (namespace) => trackerSourceSchema.options[1].parse({ kind: "custom", namespace });
|
|
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
|
-
);
|
|
238
|
-
var trackerDefinitionSchema = z3.object({
|
|
239
|
-
key: identifier,
|
|
240
|
-
title: z3.string().trim().min(1).max(120),
|
|
241
|
-
source: trackerSourceSchema,
|
|
242
|
-
window: windowSchema,
|
|
243
|
-
refreshSeconds: z3.number().int().min(300).max(86400).default(21600),
|
|
244
|
-
maxPages: z3.number().int().min(1).max(1e3).default(60)
|
|
245
|
-
}).strict();
|
|
246
|
-
var trackerArtifactSchema = z3.union([
|
|
247
|
-
trackerDefinitionSchema,
|
|
248
|
-
z3.object({ code: z3.string().min(1).max(2e6) }).strict()
|
|
249
|
-
]);
|
|
250
|
-
function defineTracker(input) {
|
|
251
|
-
return trackerDefinitionSchema.parse(input);
|
|
252
|
-
}
|
|
253
|
-
var publishedTrackerSchema = z3.object({
|
|
254
|
-
id: identifier,
|
|
255
|
-
version: identifier,
|
|
256
|
-
definition: trackerDefinitionSchema,
|
|
257
|
-
publishedAt: timestamp,
|
|
258
|
-
actor: z3.string().nullable()
|
|
259
|
-
});
|
|
260
|
-
var trackerStatusSchema = z3.object({
|
|
261
|
-
published: publishedTrackerSchema,
|
|
262
|
-
paused: z3.boolean(),
|
|
263
|
-
state: z3.enum(["idle", "syncing", "error", "complete"]),
|
|
264
|
-
lastStartedAt: timestamp.nullable(),
|
|
265
|
-
lastCompletedAt: timestamp.nullable(),
|
|
266
|
-
nextSyncAt: timestamp.nullable(),
|
|
267
|
-
coverage: z3.enum(["unknown", "partial", "complete"]),
|
|
268
|
-
error: z3.string().nullable(),
|
|
269
|
-
records: count
|
|
270
|
-
});
|
|
271
|
-
var trackerControlSchema = z3.object({
|
|
272
|
-
actionId: identifier,
|
|
273
|
-
action: z3.enum(["pause", "resume", "refresh"])
|
|
274
|
-
}).strict();
|
|
275
|
-
var trackerRecordInputSchema = z3.object({
|
|
276
|
-
id: externalId,
|
|
277
|
-
occurredAt: timestamp,
|
|
278
|
-
observedAt: timestamp,
|
|
279
|
-
author: z3.object({
|
|
280
|
-
id: externalId,
|
|
281
|
-
verified: z3.boolean().nullable().default(null)
|
|
282
|
-
}).strict().nullable().default(null),
|
|
283
|
-
data: z3.record(z3.string(), z3.json()),
|
|
284
|
-
removed: z3.boolean().default(false)
|
|
285
|
-
}).strict().refine(
|
|
286
|
-
(v) => new TextEncoder().encode(JSON.stringify(v.data)).byteLength <= 131072,
|
|
287
|
-
"Record exceeds 128 KB"
|
|
288
|
-
);
|
|
289
|
-
var trackerRecordSchema = trackerRecordInputSchema.safeExtend({
|
|
290
|
-
source: z3.string(),
|
|
291
|
-
firstSeenAt: timestamp
|
|
292
|
-
});
|
|
293
|
-
var trackerIngestSchema = z3.object({
|
|
294
|
-
actionId: identifier,
|
|
295
|
-
records: z3.array(trackerRecordInputSchema).min(1).max(100)
|
|
296
|
-
}).strict();
|
|
297
|
-
var trackerIngestResultSchema = z3.object({ stored: count });
|
|
298
|
-
var booleanQuery = z3.union([
|
|
299
|
-
z3.boolean(),
|
|
300
|
-
z3.enum(["true", "false"]).transform((v) => v === "true")
|
|
301
|
-
]);
|
|
302
|
-
var trackerQuerySchema = z3.object({
|
|
303
|
-
author: externalId.optional(),
|
|
304
|
-
member: identifier.optional(),
|
|
305
|
-
verified: booleanQuery.optional(),
|
|
306
|
-
since: z3.coerce.number().int().safe().nonnegative().optional(),
|
|
307
|
-
until: z3.coerce.number().int().safe().nonnegative().optional(),
|
|
308
|
-
removed: booleanQuery.default(false),
|
|
309
|
-
minLikes: z3.coerce.number().int().safe().nonnegative().optional(),
|
|
310
|
-
minViews: z3.coerce.number().int().safe().nonnegative().optional(),
|
|
311
|
-
limit: z3.coerce.number().int().min(1).max(100).default(25),
|
|
312
|
-
cursor: z3.string().max(2048).optional()
|
|
313
|
-
}).strict().refine(
|
|
314
|
-
(q) => q.since === void 0 || q.until === void 0 || q.until > q.since,
|
|
315
|
-
"Until must follow since"
|
|
316
|
-
);
|
|
317
|
-
var trackerPageSchema = z3.object({
|
|
318
|
-
tracker: identifier,
|
|
319
|
-
items: z3.array(trackerRecordSchema),
|
|
320
|
-
nextCursor: z3.string().nullable(),
|
|
321
|
-
total: count,
|
|
322
|
-
status: trackerStatusSchema
|
|
323
|
-
});
|
|
324
|
-
var trackerSummarySchema = z3.object({
|
|
325
|
-
records: count,
|
|
326
|
-
authors: count,
|
|
327
|
-
metrics: z3.object({
|
|
328
|
-
likes: count,
|
|
329
|
-
replies: count,
|
|
330
|
-
reposts: count,
|
|
331
|
-
quotes: count,
|
|
332
|
-
views: count,
|
|
333
|
-
bookmarks: count
|
|
334
|
-
}),
|
|
335
|
-
missingMetrics: count,
|
|
336
|
-
status: trackerStatusSchema
|
|
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()
|
|
352
|
+
next: amount2.nullable()
|
|
357
353
|
});
|
|
358
354
|
|
|
359
355
|
// src/leaderboards.ts
|
|
360
356
|
import { z as z4 } from "zod";
|
|
361
357
|
var integer = z4.number().int().safe();
|
|
362
|
-
var
|
|
358
|
+
var timestamp = integer.nonnegative().max(864e13);
|
|
363
359
|
var leaderboardWindowSchema = z4.discriminatedUnion("kind", [
|
|
364
360
|
z4.object({ kind: z4.literal("all-time") }).strict(),
|
|
365
|
-
z4.object({ kind: z4.literal("fixed"), start:
|
|
361
|
+
z4.object({ kind: z4.literal("fixed"), start: timestamp, end: timestamp }).strict().refine((w) => w.end > w.start, "Window end must follow its start"),
|
|
366
362
|
z4.object({ kind: z4.literal("rolling"), days: integer.min(1).max(3660) }).strict(),
|
|
367
363
|
z4.object({
|
|
368
364
|
kind: z4.literal("calendar"),
|
|
@@ -413,7 +409,7 @@ var leaderboardArtifactSchema = z4.union([
|
|
|
413
409
|
var publishedLeaderboardSchema = z4.object({
|
|
414
410
|
version: identifier,
|
|
415
411
|
definition: leaderboardDefinitionSchema,
|
|
416
|
-
publishedAt:
|
|
412
|
+
publishedAt: timestamp,
|
|
417
413
|
actor: z4.string().nullable()
|
|
418
414
|
});
|
|
419
415
|
var leaderboardQuerySchema = z4.object({
|
|
@@ -432,9 +428,9 @@ var leaderboardPageSchema = z4.object({
|
|
|
432
428
|
title: z4.string(),
|
|
433
429
|
version: identifier,
|
|
434
430
|
calculation: z4.enum(["balance", "earned", "net"]),
|
|
435
|
-
period: z4.object({ start:
|
|
436
|
-
calculatedAt:
|
|
437
|
-
lastEntryAt:
|
|
431
|
+
period: z4.object({ start: timestamp.nullable(), end: timestamp.nullable() }),
|
|
432
|
+
calculatedAt: timestamp,
|
|
433
|
+
lastEntryAt: timestamp.nullable(),
|
|
438
434
|
total: integer.nonnegative(),
|
|
439
435
|
items: z4.array(leaderboardRowSchema),
|
|
440
436
|
me: leaderboardRowSchema.nullable(),
|
|
@@ -452,7 +448,7 @@ var mutationBase = {
|
|
|
452
448
|
balance: identifier,
|
|
453
449
|
reason: z4.string().trim().min(1).max(1e3)
|
|
454
450
|
};
|
|
455
|
-
var datedMutation = { ...mutationBase, effectiveAt:
|
|
451
|
+
var datedMutation = { ...mutationBase, effectiveAt: timestamp.optional() };
|
|
456
452
|
var pointsMutationSchema = z4.discriminatedUnion("kind", [
|
|
457
453
|
z4.object({
|
|
458
454
|
...datedMutation,
|
|
@@ -491,8 +487,8 @@ var pointsEntrySchema = z4.object({
|
|
|
491
487
|
balance: identifier,
|
|
492
488
|
amount: integer,
|
|
493
489
|
kind: z4.enum(["award", "spend", "adjust", "reverse"]),
|
|
494
|
-
effectiveAt:
|
|
495
|
-
receivedAt:
|
|
490
|
+
effectiveAt: timestamp,
|
|
491
|
+
receivedAt: timestamp,
|
|
496
492
|
quest: identifier.nullable(),
|
|
497
493
|
original: identifier.nullable(),
|
|
498
494
|
reason: z4.string(),
|
|
@@ -522,6 +518,23 @@ var leaderboardGroupSchema = z4.object({
|
|
|
522
518
|
}).strict();
|
|
523
519
|
|
|
524
520
|
export {
|
|
521
|
+
engagementDefinitionSchema,
|
|
522
|
+
engagementScoreInputSchema,
|
|
523
|
+
engagementScoreSchema,
|
|
524
|
+
engagementPublishSchema,
|
|
525
|
+
engagementRuleSchema,
|
|
526
|
+
engagementPageQuerySchema,
|
|
527
|
+
engagementSettlementSchema,
|
|
528
|
+
engagementPageSchema,
|
|
529
|
+
defineEngagementReward,
|
|
530
|
+
engagementChangePreviewInputSchema,
|
|
531
|
+
engagementChangeSchema,
|
|
532
|
+
engagementChangePreviewSchema,
|
|
533
|
+
engagementVersionPageSchema,
|
|
534
|
+
engagementVersionQuerySchema,
|
|
535
|
+
engagementBoundaryPageSchema,
|
|
536
|
+
engagementArtifactSchema,
|
|
537
|
+
engagementDeploymentEntrySchema,
|
|
525
538
|
authoringIdentityShape,
|
|
526
539
|
validateAuthoringIdentity,
|
|
527
540
|
normalizeAuthoringIdentity,
|
|
@@ -538,26 +551,6 @@ export {
|
|
|
538
551
|
referralSummarySchema,
|
|
539
552
|
referralHistorySchema,
|
|
540
553
|
referralManagementSchema,
|
|
541
|
-
xTweetSchema,
|
|
542
|
-
trackerSourceSchema,
|
|
543
|
-
x,
|
|
544
|
-
customSource,
|
|
545
|
-
trackerDefinitionSchema,
|
|
546
|
-
trackerArtifactSchema,
|
|
547
|
-
defineTracker,
|
|
548
|
-
publishedTrackerSchema,
|
|
549
|
-
trackerStatusSchema,
|
|
550
|
-
trackerControlSchema,
|
|
551
|
-
trackerRecordInputSchema,
|
|
552
|
-
trackerRecordSchema,
|
|
553
|
-
trackerIngestSchema,
|
|
554
|
-
trackerIngestResultSchema,
|
|
555
|
-
trackerQuerySchema,
|
|
556
|
-
trackerPageSchema,
|
|
557
|
-
trackerSummarySchema,
|
|
558
|
-
trackerPreviewLimits,
|
|
559
|
-
trackerPreviewInputSchema,
|
|
560
|
-
trackerPreviewSchema,
|
|
561
554
|
leaderboardWindowSchema,
|
|
562
555
|
leaderboardDefinitionSchema,
|
|
563
556
|
leaderboardAuthoringSchema,
|