@domino-sdk/relay 1.0.0-next.2 → 1.0.0-next.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -1
- package/build.mjs +18 -1
- package/dist/activity-B8k9Sa_a.d.ts +9112 -0
- package/dist/authoring.d.ts +1355 -182
- package/dist/authoring.js +658 -225
- package/dist/automatic-outcomes-B1xrETxm.d.ts +758 -0
- package/dist/avatar.d.ts +29 -0
- package/dist/avatar.js +21 -0
- package/dist/browser-J7tUpXxy.d.ts +4154 -0
- package/dist/browser.d.ts +11 -4580
- package/dist/browser.js +8 -6
- package/dist/capability-error-DNMwKmlL.d.ts +458 -0
- package/dist/chunk-36HTX2BM.js +1223 -0
- package/dist/chunk-6QJ3LADK.js +112 -0
- package/dist/chunk-BGGKNIRP.js +171 -0
- package/dist/chunk-EYH5RDIE.js +496 -0
- package/dist/chunk-GQKYAQM6.js +84 -0
- package/dist/chunk-GUP7YRR4.js +42 -0
- package/dist/chunk-GZ6FJAXN.js +1659 -0
- package/dist/chunk-JON5SESL.js +2986 -0
- package/dist/chunk-MC6V6VMG.js +49 -0
- package/dist/chunk-NPGENI7K.js +37 -0
- package/dist/chunk-V7UKZLHA.js +35 -0
- package/dist/chunk-VFHHLN6A.js +284 -0
- package/dist/chunk-WJSSJ7AF.js +151 -0
- package/dist/{chunk-VH4OQ5VX.js → chunk-XFMSUPNS.js} +26 -5
- package/dist/{chunk-FDWRBMB3.js → chunk-ZVIRG24J.js} +150 -33
- package/dist/client-XiuFnug_.d.ts +4262 -0
- package/dist/groups-Ck-OxzjD.d.ts +2449 -0
- package/dist/identity-integration-GxAHdKR2.d.ts +58 -0
- package/dist/images-Dv-P5VBw.d.ts +234 -0
- package/dist/index.d.ts +15 -13115
- package/dist/index.js +30 -689
- package/dist/internal.d.ts +159 -0
- package/dist/internal.js +79 -0
- package/dist/offers-Cy-e4o5x.d.ts +431 -0
- package/dist/outcomes-kVB-Juzs.d.ts +4902 -0
- package/dist/pages-BBYD21IE.d.ts +359 -0
- package/dist/participant-rewards-3duLb8YJ.d.ts +668 -0
- package/dist/portal-proxy.js +26 -9
- package/dist/profiles-D2aFcOxu.d.ts +297 -0
- package/dist/react/index.d.ts +3378 -3318
- package/dist/react/index.js +1635 -783
- package/dist/request-error-DWduJCGV.d.ts +62 -0
- package/dist/schema-DfJzH2ci.d.ts +5644 -0
- package/dist/schema.d.ts +15 -3388
- package/dist/schema.js +790 -3
- package/dist/server/index.d.ts +81498 -0
- package/dist/server/index.js +2520 -0
- package/dist/streaks-CWyq8Px5.d.ts +71 -0
- package/dist/submission-input-BZkm6ohU.d.ts +290 -0
- package/dist/units-CwgsPB_r.d.ts +9 -0
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +1 -0
- package/dist/wallet-YssWxGg8.d.ts +228 -0
- package/package.json +24 -5
- package/dist/chunk-4KNTMNXA.js +0 -1847
- package/dist/chunk-B76BAJ25.js +0 -624
- package/dist/chunk-NKGJEYZM.js +0 -1833
- package/dist/chunk-ONDBQSMU.js +0 -373
- package/dist/submission-input-JDwq3EVK.d.ts +0 -4986
package/dist/chunk-B76BAJ25.js
DELETED
|
@@ -1,624 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
profileSummarySchema
|
|
3
|
-
} from "./chunk-ONDBQSMU.js";
|
|
4
|
-
import {
|
|
5
|
-
contentMetricSchema,
|
|
6
|
-
contentMetricsSchema,
|
|
7
|
-
identifier,
|
|
8
|
-
pointsRewardSchema,
|
|
9
|
-
tierRewardSchema
|
|
10
|
-
} from "./chunk-NKGJEYZM.js";
|
|
11
|
-
|
|
12
|
-
// src/engagement.ts
|
|
13
|
-
import { z } from "zod";
|
|
14
|
-
var amount = z.number().int().safe().nonnegative();
|
|
15
|
-
var engagementDefinitionSchema = z.strictObject({
|
|
16
|
-
key: identifier,
|
|
17
|
-
qualifiedBy: identifier,
|
|
18
|
-
balance: identifier,
|
|
19
|
-
metrics: z.array(contentMetricSchema).min(1).max(6).refine(
|
|
20
|
-
(metrics) => new Set(metrics).size === metrics.length,
|
|
21
|
-
"Metrics must be unique"
|
|
22
|
-
),
|
|
23
|
-
baseline: z.literal("historical"),
|
|
24
|
-
maxAgeMs: z.number().int().positive().max(864e5).default(36e5),
|
|
25
|
-
budget: z.strictObject({
|
|
26
|
-
projectDaily: amount.optional(),
|
|
27
|
-
memberDaily: amount.optional(),
|
|
28
|
-
projectLifetime: amount.optional()
|
|
29
|
-
}).default({})
|
|
30
|
-
});
|
|
31
|
-
var engagementScoreInputSchema = z.strictObject({
|
|
32
|
-
metrics: contentMetricsSchema,
|
|
33
|
-
baseline: contentMetricsSchema
|
|
34
|
-
});
|
|
35
|
-
var engagementScoreSchema = z.strictObject({
|
|
36
|
-
target: amount,
|
|
37
|
-
baseline: amount
|
|
38
|
-
});
|
|
39
|
-
var engagementPublishSchema = z.strictObject({
|
|
40
|
-
actionId: identifier,
|
|
41
|
-
code: z.string().min(1).max(1e6)
|
|
42
|
-
});
|
|
43
|
-
var engagementRuleSchema = z.strictObject({
|
|
44
|
-
version: identifier,
|
|
45
|
-
definition: engagementDefinitionSchema,
|
|
46
|
-
publishedAt: amount
|
|
47
|
-
});
|
|
48
|
-
var engagementPageQuerySchema = z.strictObject({
|
|
49
|
-
rule: identifier,
|
|
50
|
-
content: z.string().min(1).max(256),
|
|
51
|
-
member: identifier.optional(),
|
|
52
|
-
before: z.coerce.number().int().positive().safe().optional()
|
|
53
|
-
});
|
|
54
|
-
var engagementSettlementSchema = z.strictObject({
|
|
55
|
-
id: identifier,
|
|
56
|
-
day: z.string(),
|
|
57
|
-
observation: identifier,
|
|
58
|
-
qualification: identifier,
|
|
59
|
-
earned: amount,
|
|
60
|
-
growth: amount,
|
|
61
|
-
paid: amount,
|
|
62
|
-
excluded: amount,
|
|
63
|
-
entry: identifier.nullable(),
|
|
64
|
-
createdAt: amount
|
|
65
|
-
});
|
|
66
|
-
var engagementPageSchema = z.strictObject({
|
|
67
|
-
rule: engagementRuleSchema,
|
|
68
|
-
account: z.strictObject({
|
|
69
|
-
member: identifier,
|
|
70
|
-
earned: amount,
|
|
71
|
-
accounted: amount,
|
|
72
|
-
paid: amount,
|
|
73
|
-
excluded: amount,
|
|
74
|
-
pending: amount,
|
|
75
|
-
counters: contentMetricsSchema,
|
|
76
|
-
baseline: contentMetricsSchema,
|
|
77
|
-
observation: identifier.nullable(),
|
|
78
|
-
nextSettlementAt: amount.nullable(),
|
|
79
|
-
reason: z.string().nullable()
|
|
80
|
-
}).nullable(),
|
|
81
|
-
items: z.array(engagementSettlementSchema),
|
|
82
|
-
next: amount.nullable()
|
|
83
|
-
});
|
|
84
|
-
function defineEngagementReward(input) {
|
|
85
|
-
const { target, ...config } = input;
|
|
86
|
-
const definition = engagementDefinitionSchema.parse({
|
|
87
|
-
...config,
|
|
88
|
-
qualifiedBy: typeof input.qualifiedBy === "string" ? input.qualifiedBy : input.qualifiedBy.key
|
|
89
|
-
});
|
|
90
|
-
const selected = z.record(z.enum(input.metrics), amount);
|
|
91
|
-
return {
|
|
92
|
-
key: definition.key,
|
|
93
|
-
describe: () => definition,
|
|
94
|
-
score(raw) {
|
|
95
|
-
const sample = engagementScoreInputSchema.parse(raw);
|
|
96
|
-
return engagementScoreSchema.parse({
|
|
97
|
-
target: target({ metrics: selected.parse(sample.metrics) }),
|
|
98
|
-
baseline: target({ metrics: selected.parse(sample.baseline) })
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
var engagementChangePreviewInputSchema = z.strictObject({
|
|
104
|
-
code: z.string().min(1).max(1e6)
|
|
105
|
-
});
|
|
106
|
-
var engagementChangeSchema = engagementPublishSchema.extend({
|
|
107
|
-
expectedVersion: identifier,
|
|
108
|
-
previewHash: identifier
|
|
109
|
-
});
|
|
110
|
-
var total = z.string().regex(/^(0|[1-9][0-9]*)$/);
|
|
111
|
-
var engagementChangePreviewSchema = z.strictObject({
|
|
112
|
-
rule: identifier,
|
|
113
|
-
fromVersion: identifier,
|
|
114
|
-
toVersion: identifier,
|
|
115
|
-
previewHash: identifier,
|
|
116
|
-
definition: engagementDefinitionSchema,
|
|
117
|
-
boundary: z.literal("available-eligible-observation"),
|
|
118
|
-
settlement: z.literal("deferred"),
|
|
119
|
-
summary: z.strictObject({
|
|
120
|
-
knownAdmissions: amount,
|
|
121
|
-
accounts: amount,
|
|
122
|
-
uninitialized: amount,
|
|
123
|
-
pendingTransitions: amount,
|
|
124
|
-
earned: total,
|
|
125
|
-
paid: total,
|
|
126
|
-
excluded: total,
|
|
127
|
-
pending: total
|
|
128
|
-
})
|
|
129
|
-
});
|
|
130
|
-
var engagementVersionPageSchema = z.strictObject({
|
|
131
|
-
items: z.array(
|
|
132
|
-
engagementRuleSchema.extend({ previousVersion: identifier.nullable() })
|
|
133
|
-
),
|
|
134
|
-
next: amount.nullable()
|
|
135
|
-
});
|
|
136
|
-
var engagementVersionQuerySchema = z.strictObject({
|
|
137
|
-
rule: identifier,
|
|
138
|
-
before: z.coerce.number().int().positive().safe().optional()
|
|
139
|
-
});
|
|
140
|
-
var engagementBoundaryPageSchema = z.strictObject({
|
|
141
|
-
current: engagementRuleSchema.nullable(),
|
|
142
|
-
requested: engagementRuleSchema,
|
|
143
|
-
items: z.array(
|
|
144
|
-
z.strictObject({
|
|
145
|
-
from: identifier,
|
|
146
|
-
to: identifier,
|
|
147
|
-
baseline: contentMetricsSchema,
|
|
148
|
-
observedAt: amount,
|
|
149
|
-
settlement: engagementSettlementSchema
|
|
150
|
-
})
|
|
151
|
-
),
|
|
152
|
-
next: amount.nullable()
|
|
153
|
-
});
|
|
154
|
-
var engagementArtifactSchema = engagementPublishSchema.omit({
|
|
155
|
-
actionId: true
|
|
156
|
-
});
|
|
157
|
-
var deploymentEntry = engagementArtifactSchema.extend({
|
|
158
|
-
rule: engagementRuleSchema
|
|
159
|
-
});
|
|
160
|
-
var engagementDeploymentEntrySchema = z.discriminatedUnion("kind", [
|
|
161
|
-
deploymentEntry.extend({ kind: z.literal("create") }),
|
|
162
|
-
deploymentEntry.extend({ kind: z.literal("unchanged") }),
|
|
163
|
-
deploymentEntry.extend({
|
|
164
|
-
kind: z.literal("change"),
|
|
165
|
-
change: engagementChangePreviewSchema
|
|
166
|
-
})
|
|
167
|
-
]);
|
|
168
|
-
|
|
169
|
-
// src/authoring-identity.ts
|
|
170
|
-
import { z as z2 } from "zod";
|
|
171
|
-
var authoringIdentityShape = {
|
|
172
|
-
key: identifier.optional(),
|
|
173
|
-
id: identifier.optional()
|
|
174
|
-
};
|
|
175
|
-
function validateAuthoringIdentity(value, ctx) {
|
|
176
|
-
if (!value.key && !value.id) {
|
|
177
|
-
ctx.addIssue({
|
|
178
|
-
code: "custom",
|
|
179
|
-
path: ["key"],
|
|
180
|
-
message: "Provide an authoring key. Legacy id is also accepted."
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
if (value.key && value.id && value.key !== value.id) {
|
|
184
|
-
ctx.addIssue({
|
|
185
|
-
code: "custom",
|
|
186
|
-
path: ["key"],
|
|
187
|
-
message: "id and key must match. Keep the existing authoring name to preserve identity."
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
function normalizeAuthoringIdentity(value) {
|
|
192
|
-
const { id, key, ...properties } = value;
|
|
193
|
-
return { ...properties, key: identifier.parse(key ?? id) };
|
|
194
|
-
}
|
|
195
|
-
var identitySchema = z2.object(authoringIdentityShape).superRefine(validateAuthoringIdentity).transform(normalizeAuthoringIdentity);
|
|
196
|
-
var authoringKey = (input) => identitySchema.parse(input).key;
|
|
197
|
-
|
|
198
|
-
// src/referrals.ts
|
|
199
|
-
import { z as z3 } from "zod";
|
|
200
|
-
var rewardSchema = z3.union([pointsRewardSchema, tierRewardSchema]);
|
|
201
|
-
var amount2 = z3.number().int().safe().nonnegative();
|
|
202
|
-
var reason = z3.string().trim().min(1).max(1e3);
|
|
203
|
-
var referralDefinitionSchema = z3.object({
|
|
204
|
-
id: identifier,
|
|
205
|
-
key: identifier.optional(),
|
|
206
|
-
title: z3.string().trim().min(1).max(120),
|
|
207
|
-
enabled: z3.boolean().default(true),
|
|
208
|
-
qualification: z3.discriminatedUnion("kind", [
|
|
209
|
-
z3.object({ kind: z3.literal("signup") }).strict(),
|
|
210
|
-
z3.object({ kind: z3.literal("quest"), quest: identifier }).strict(),
|
|
211
|
-
z3.object({ kind: z3.literal("external") }).strict()
|
|
212
|
-
]),
|
|
213
|
-
inviterGroup: identifier.optional(),
|
|
214
|
-
rewards: z3.object({
|
|
215
|
-
inviter: z3.array(rewardSchema).max(10).default([]),
|
|
216
|
-
invitee: z3.array(rewardSchema).max(10).default([])
|
|
217
|
-
}).strict().default({ inviter: [], invitee: [] }),
|
|
218
|
-
milestones: z3.array(
|
|
219
|
-
z3.object({
|
|
220
|
-
id: identifier,
|
|
221
|
-
count: amount2.min(1),
|
|
222
|
-
rewards: z3.array(rewardSchema).min(1).max(10)
|
|
223
|
-
}).strict()
|
|
224
|
-
).max(30).default([]),
|
|
225
|
-
bonuses: z3.array(
|
|
226
|
-
z3.object({
|
|
227
|
-
id: identifier,
|
|
228
|
-
balance: identifier,
|
|
229
|
-
basisPoints: amount2.min(1).max(1e4),
|
|
230
|
-
quests: z3.array(identifier).min(1).max(100).optional(),
|
|
231
|
-
external: z3.boolean().default(false),
|
|
232
|
-
durationDays: amount2.min(1).max(36500).optional(),
|
|
233
|
-
maxPoints: amount2.min(1).optional()
|
|
234
|
-
}).strict()
|
|
235
|
-
).max(20).default([])
|
|
236
|
-
}).strict().superRefine((value, ctx) => {
|
|
237
|
-
for (const entries of [value.milestones, value.bonuses]) {
|
|
238
|
-
if (new Set(entries.map((e) => e.id)).size !== entries.length) {
|
|
239
|
-
ctx.addIssue({ code: "custom", message: "Rule IDs must be unique" });
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
});
|
|
243
|
-
var referralAuthoringSchema = z3.object(referralDefinitionSchema.shape).omit({ id: true }).extend(authoringIdentityShape).strict().superRefine(validateAuthoringIdentity).superRefine((value, ctx) => {
|
|
244
|
-
for (const entries of [value.milestones, value.bonuses]) {
|
|
245
|
-
if (new Set(entries.map((entry) => entry.id)).size !== entries.length) {
|
|
246
|
-
ctx.addIssue({ code: "custom", message: "Rule keys must be unique" });
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
}).transform(normalizeAuthoringIdentity);
|
|
250
|
-
function defineReferral(input) {
|
|
251
|
-
const definition = referralAuthoringSchema.parse(input);
|
|
252
|
-
return {
|
|
253
|
-
...definition,
|
|
254
|
-
/** @deprecated Use key. */
|
|
255
|
-
id: definition.key
|
|
256
|
-
};
|
|
257
|
-
}
|
|
258
|
-
var referralArtifactSchema = z3.union([
|
|
259
|
-
referralAuthoringSchema,
|
|
260
|
-
z3.object({ code: z3.string().min(1).max(2e6) }).strict()
|
|
261
|
-
]);
|
|
262
|
-
var publishedReferralSchema = z3.object({
|
|
263
|
-
version: identifier,
|
|
264
|
-
definition: referralDefinitionSchema,
|
|
265
|
-
publishedAt: amount2,
|
|
266
|
-
actor: z3.string().nullable()
|
|
267
|
-
});
|
|
268
|
-
var referralAcceptSchema = z3.object({ actionId: identifier, code: identifier }).strict();
|
|
269
|
-
var referralControlSchema = z3.discriminatedUnion("kind", [
|
|
270
|
-
z3.object({
|
|
271
|
-
kind: z3.literal("suspend"),
|
|
272
|
-
actionId: identifier,
|
|
273
|
-
member: identifier,
|
|
274
|
-
suspended: z3.boolean(),
|
|
275
|
-
reason
|
|
276
|
-
}).strict(),
|
|
277
|
-
z3.object({
|
|
278
|
-
kind: z3.literal("qualify"),
|
|
279
|
-
actionId: identifier,
|
|
280
|
-
member: identifier,
|
|
281
|
-
program: identifier,
|
|
282
|
-
qualified: z3.boolean(),
|
|
283
|
-
reason
|
|
284
|
-
}).strict(),
|
|
285
|
-
z3.object({
|
|
286
|
-
kind: z3.literal("resolve-reward"),
|
|
287
|
-
actionId: identifier,
|
|
288
|
-
entitlement: identifier,
|
|
289
|
-
reason
|
|
290
|
-
}).strict()
|
|
291
|
-
]);
|
|
292
|
-
var referralRelationshipSchema = z3.object({
|
|
293
|
-
member: identifier,
|
|
294
|
-
inviter: identifier,
|
|
295
|
-
acceptedAt: amount2,
|
|
296
|
-
suspended: z3.boolean()
|
|
297
|
-
});
|
|
298
|
-
var referralAccountSchema = z3.object({
|
|
299
|
-
id: identifier,
|
|
300
|
-
program: identifier,
|
|
301
|
-
kind: z3.enum(["bonus", "fixed", "milestone"]),
|
|
302
|
-
balance: identifier,
|
|
303
|
-
earned: amount2,
|
|
304
|
-
settled: amount2,
|
|
305
|
-
outstanding: amount2
|
|
306
|
-
});
|
|
307
|
-
var referralSummarySchema = z3.object({
|
|
308
|
-
code: identifier,
|
|
309
|
-
attributed: amount2,
|
|
310
|
-
programs: z3.array(
|
|
311
|
-
z3.object({
|
|
312
|
-
definition: referralDefinitionSchema,
|
|
313
|
-
qualified: amount2,
|
|
314
|
-
milestones: z3.array(
|
|
315
|
-
z3.object({ id: identifier, count: amount2, reached: z3.boolean() })
|
|
316
|
-
)
|
|
317
|
-
})
|
|
318
|
-
),
|
|
319
|
-
accounts: z3.array(referralAccountSchema)
|
|
320
|
-
});
|
|
321
|
-
var referralHistorySchema = z3.object({
|
|
322
|
-
items: z3.array(
|
|
323
|
-
z3.object({
|
|
324
|
-
id: amount2,
|
|
325
|
-
program: identifier,
|
|
326
|
-
balance: identifier,
|
|
327
|
-
amount: z3.number().int().safe(),
|
|
328
|
-
at: amount2,
|
|
329
|
-
reason: z3.string()
|
|
330
|
-
})
|
|
331
|
-
),
|
|
332
|
-
next: amount2.nullable()
|
|
333
|
-
});
|
|
334
|
-
var referralManagementSchema = z3.object({
|
|
335
|
-
relationships: z3.array(referralRelationshipSchema),
|
|
336
|
-
qualifications: z3.array(
|
|
337
|
-
z3.object({
|
|
338
|
-
member: identifier,
|
|
339
|
-
program: identifier,
|
|
340
|
-
qualified: z3.boolean(),
|
|
341
|
-
qualifiedAt: amount2
|
|
342
|
-
})
|
|
343
|
-
),
|
|
344
|
-
accounts: z3.array(
|
|
345
|
-
referralAccountSchema.extend({ member: identifier, invitee: z3.string() })
|
|
346
|
-
),
|
|
347
|
-
reviews: z3.array(
|
|
348
|
-
z3.object({
|
|
349
|
-
entitlement: identifier,
|
|
350
|
-
member: identifier,
|
|
351
|
-
program: identifier,
|
|
352
|
-
reason: z3.string()
|
|
353
|
-
})
|
|
354
|
-
),
|
|
355
|
-
next: amount2.nullable()
|
|
356
|
-
});
|
|
357
|
-
|
|
358
|
-
// src/leaderboards.ts
|
|
359
|
-
import { z as z4 } from "zod";
|
|
360
|
-
var integer = z4.number().int().safe();
|
|
361
|
-
var timestamp = integer.nonnegative().max(864e13);
|
|
362
|
-
var leaderboardWindowSchema = z4.discriminatedUnion("kind", [
|
|
363
|
-
z4.object({ kind: z4.literal("all-time") }).strict(),
|
|
364
|
-
z4.object({ kind: z4.literal("fixed"), start: timestamp, end: timestamp }).strict().refine((w) => w.end > w.start, "Window end must follow its start"),
|
|
365
|
-
z4.object({ kind: z4.literal("rolling"), days: integer.min(1).max(3660) }).strict(),
|
|
366
|
-
z4.object({
|
|
367
|
-
kind: z4.literal("calendar"),
|
|
368
|
-
period: z4.enum(["day", "week", "month"]),
|
|
369
|
-
timeZone: z4.string().min(1).max(100).refine((zone) => {
|
|
370
|
-
try {
|
|
371
|
-
new Intl.DateTimeFormat("en", { timeZone: zone });
|
|
372
|
-
return true;
|
|
373
|
-
} catch {
|
|
374
|
-
return false;
|
|
375
|
-
}
|
|
376
|
-
}, "Use an IANA timezone")
|
|
377
|
-
}).strict()
|
|
378
|
-
]);
|
|
379
|
-
var periodScore = {
|
|
380
|
-
window: leaderboardWindowSchema.default({ kind: "all-time" }),
|
|
381
|
-
quests: z4.array(identifier).min(1).max(100).optional()
|
|
382
|
-
};
|
|
383
|
-
var leaderboardDefinitionSchema = z4.object({
|
|
384
|
-
id: identifier,
|
|
385
|
-
key: identifier.optional(),
|
|
386
|
-
title: z4.string().trim().min(1).max(120),
|
|
387
|
-
balance: identifier,
|
|
388
|
-
score: z4.discriminatedUnion("kind", [
|
|
389
|
-
z4.object({ kind: z4.literal("balance") }).strict(),
|
|
390
|
-
z4.object({ kind: z4.literal("earned"), ...periodScore }).strict(),
|
|
391
|
-
z4.object({
|
|
392
|
-
kind: z4.literal("net"),
|
|
393
|
-
window: leaderboardWindowSchema.default({ kind: "all-time" })
|
|
394
|
-
}).strict()
|
|
395
|
-
]).default({ kind: "balance" }),
|
|
396
|
-
access: z4.enum(["participants", "public"]).default("participants"),
|
|
397
|
-
group: identifier.optional()
|
|
398
|
-
}).strict();
|
|
399
|
-
var leaderboardAuthoringSchema = leaderboardDefinitionSchema.omit({ id: true }).extend(authoringIdentityShape).strict().superRefine(validateAuthoringIdentity).transform(normalizeAuthoringIdentity);
|
|
400
|
-
function defineLeaderboard(input) {
|
|
401
|
-
const definition = leaderboardAuthoringSchema.parse(input);
|
|
402
|
-
return {
|
|
403
|
-
...definition,
|
|
404
|
-
/** @deprecated Use key. */
|
|
405
|
-
id: definition.key
|
|
406
|
-
};
|
|
407
|
-
}
|
|
408
|
-
var leaderboardArtifactSchema = z4.union([
|
|
409
|
-
leaderboardAuthoringSchema,
|
|
410
|
-
z4.object({ code: z4.string().min(1).max(2e6) }).strict()
|
|
411
|
-
]);
|
|
412
|
-
var publishedLeaderboardSchema = z4.object({
|
|
413
|
-
version: identifier,
|
|
414
|
-
definition: leaderboardDefinitionSchema,
|
|
415
|
-
publishedAt: timestamp,
|
|
416
|
-
actor: z4.string().nullable()
|
|
417
|
-
});
|
|
418
|
-
var leaderboardQuerySchema = z4.object({
|
|
419
|
-
limit: z4.coerce.number().int().min(1).max(100).default(25),
|
|
420
|
-
cursor: z4.string().max(4096).optional()
|
|
421
|
-
}).strict();
|
|
422
|
-
var leaderboardRowSchema = z4.object({
|
|
423
|
-
/** The row's stable key: a pseudonym per board and member. */
|
|
424
|
-
participant: identifier,
|
|
425
|
-
member: identifier.optional(),
|
|
426
|
-
/** The profile's name where the viewer can see it, otherwise the pseudonym's. */
|
|
427
|
-
name: z4.string(),
|
|
428
|
-
score: integer,
|
|
429
|
-
rank: integer.positive(),
|
|
430
|
-
/**
|
|
431
|
-
* The member's profile, where the project shows profiles to this viewer and the member has not
|
|
432
|
-
* hidden theirs. Older servers omit it.
|
|
433
|
-
*/
|
|
434
|
-
profile: profileSummarySchema.nullable().default(null)
|
|
435
|
-
});
|
|
436
|
-
var leaderboardPageSchema = z4.object({
|
|
437
|
-
leaderboard: identifier,
|
|
438
|
-
title: z4.string(),
|
|
439
|
-
version: identifier,
|
|
440
|
-
calculation: z4.enum(["balance", "earned", "net"]),
|
|
441
|
-
period: z4.object({ start: timestamp.nullable(), end: timestamp.nullable() }),
|
|
442
|
-
calculatedAt: timestamp,
|
|
443
|
-
lastEntryAt: timestamp.nullable(),
|
|
444
|
-
total: integer.nonnegative(),
|
|
445
|
-
items: z4.array(leaderboardRowSchema),
|
|
446
|
-
me: leaderboardRowSchema.nullable(),
|
|
447
|
-
nearby: z4.array(leaderboardRowSchema),
|
|
448
|
-
nextCursor: z4.string().nullable()
|
|
449
|
-
});
|
|
450
|
-
var leaderboardPlacementSchema = z4.object({
|
|
451
|
-
leaderboard: identifier,
|
|
452
|
-
key: identifier.optional(),
|
|
453
|
-
title: z4.string(),
|
|
454
|
-
profile: identifier,
|
|
455
|
-
rank: integer.positive().nullable(),
|
|
456
|
-
score: integer.nullable(),
|
|
457
|
-
/** Ranked participants on the board. */
|
|
458
|
-
total: integer.nonnegative()
|
|
459
|
-
});
|
|
460
|
-
var leaderboardPreviewSchema = z4.object({
|
|
461
|
-
published: publishedLeaderboardSchema,
|
|
462
|
-
before: leaderboardPageSchema.nullable(),
|
|
463
|
-
after: leaderboardPageSchema
|
|
464
|
-
});
|
|
465
|
-
var mutationBase = {
|
|
466
|
-
actionId: identifier,
|
|
467
|
-
member: identifier,
|
|
468
|
-
balance: identifier,
|
|
469
|
-
reason: z4.string().trim().min(1).max(1e3)
|
|
470
|
-
};
|
|
471
|
-
var datedMutation = { ...mutationBase, effectiveAt: timestamp.optional() };
|
|
472
|
-
var pointsMutationSchema = z4.discriminatedUnion("kind", [
|
|
473
|
-
z4.object({
|
|
474
|
-
...datedMutation,
|
|
475
|
-
kind: z4.literal("award"),
|
|
476
|
-
referralEligible: z4.boolean().optional(),
|
|
477
|
-
amount: integer.positive()
|
|
478
|
-
}).strict(),
|
|
479
|
-
z4.object({
|
|
480
|
-
...datedMutation,
|
|
481
|
-
kind: z4.literal("spend"),
|
|
482
|
-
amount: integer.positive()
|
|
483
|
-
}).strict(),
|
|
484
|
-
z4.object({
|
|
485
|
-
...datedMutation,
|
|
486
|
-
kind: z4.literal("adjust"),
|
|
487
|
-
amount: integer.refine((n) => n !== 0)
|
|
488
|
-
}).strict(),
|
|
489
|
-
z4.object({
|
|
490
|
-
...datedMutation,
|
|
491
|
-
kind: z4.literal("set"),
|
|
492
|
-
total: integer.nonnegative(),
|
|
493
|
-
expectedTotal: integer.nonnegative(),
|
|
494
|
-
classification: z4.enum(["earned", "spend"])
|
|
495
|
-
}).strict(),
|
|
496
|
-
z4.object({
|
|
497
|
-
...mutationBase,
|
|
498
|
-
kind: z4.literal("reverse"),
|
|
499
|
-
entry: identifier,
|
|
500
|
-
amount: integer.positive()
|
|
501
|
-
}).strict()
|
|
502
|
-
]);
|
|
503
|
-
var pointsEntrySchema = z4.object({
|
|
504
|
-
id: identifier,
|
|
505
|
-
completion: z4.string().nullable(),
|
|
506
|
-
member: identifier,
|
|
507
|
-
balance: identifier,
|
|
508
|
-
amount: integer,
|
|
509
|
-
kind: z4.enum(["award", "spend", "adjust", "reverse"]),
|
|
510
|
-
effectiveAt: timestamp,
|
|
511
|
-
receivedAt: timestamp,
|
|
512
|
-
quest: identifier.nullable(),
|
|
513
|
-
original: identifier.nullable(),
|
|
514
|
-
reason: z4.string(),
|
|
515
|
-
actor: z4.string().nullable()
|
|
516
|
-
});
|
|
517
|
-
var pointsResultSchema = z4.object({
|
|
518
|
-
entry: pointsEntrySchema,
|
|
519
|
-
total: integer.nonnegative()
|
|
520
|
-
});
|
|
521
|
-
var pointsAccountSchema = z4.object({
|
|
522
|
-
member: identifier,
|
|
523
|
-
balance: identifier,
|
|
524
|
-
total: integer.nonnegative(),
|
|
525
|
-
held: integer.nonnegative()
|
|
526
|
-
});
|
|
527
|
-
var leaderboardExclusionSchema = z4.object({
|
|
528
|
-
actionId: identifier,
|
|
529
|
-
member: identifier,
|
|
530
|
-
excluded: z4.boolean(),
|
|
531
|
-
reason: z4.string().trim().min(1).max(1e3)
|
|
532
|
-
}).strict();
|
|
533
|
-
var leaderboardGroupSchema = z4.object({
|
|
534
|
-
actionId: identifier,
|
|
535
|
-
member: identifier,
|
|
536
|
-
included: z4.boolean(),
|
|
537
|
-
reason: z4.string().trim().min(1).max(1e3)
|
|
538
|
-
}).strict();
|
|
539
|
-
|
|
540
|
-
// src/units.ts
|
|
541
|
-
function checkDecimals(decimals) {
|
|
542
|
-
if (!Number.isInteger(decimals) || decimals < 0 || decimals > 255) {
|
|
543
|
-
throw new Error("Token decimals must be an integer from 0 to 255");
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
function parseUnits(value, decimals) {
|
|
547
|
-
checkDecimals(decimals);
|
|
548
|
-
const match = /^(\d+)(?:\.(\d+))?$/.exec(value.trim());
|
|
549
|
-
if (!match) {
|
|
550
|
-
throw new Error(`Use a decimal amount such as "1.5", not "${value}"`);
|
|
551
|
-
}
|
|
552
|
-
const [, whole, fraction = ""] = match;
|
|
553
|
-
const significant = fraction.replace(/0+$/, "");
|
|
554
|
-
if (significant.length > decimals) {
|
|
555
|
-
throw new Error(
|
|
556
|
-
`"${value}" has more than ${decimals} decimal places, which this token cannot hold`
|
|
557
|
-
);
|
|
558
|
-
}
|
|
559
|
-
return BigInt(whole + significant.padEnd(decimals, "0"));
|
|
560
|
-
}
|
|
561
|
-
function formatUnits(amount3, decimals) {
|
|
562
|
-
checkDecimals(decimals);
|
|
563
|
-
const value = typeof amount3 === "bigint" ? amount3 : BigInt(amount3);
|
|
564
|
-
const sign = value < 0n ? "-" : "";
|
|
565
|
-
const digits = (value < 0n ? -value : value).toString().padStart(decimals + 1, "0");
|
|
566
|
-
const whole = digits.slice(0, digits.length - decimals);
|
|
567
|
-
const fraction = digits.slice(digits.length - decimals).replace(/0+$/, "");
|
|
568
|
-
return sign + whole + (fraction ? "." + fraction : "");
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
export {
|
|
572
|
-
engagementDefinitionSchema,
|
|
573
|
-
engagementScoreInputSchema,
|
|
574
|
-
engagementScoreSchema,
|
|
575
|
-
engagementPublishSchema,
|
|
576
|
-
engagementRuleSchema,
|
|
577
|
-
engagementPageQuerySchema,
|
|
578
|
-
engagementSettlementSchema,
|
|
579
|
-
engagementPageSchema,
|
|
580
|
-
defineEngagementReward,
|
|
581
|
-
engagementChangePreviewInputSchema,
|
|
582
|
-
engagementChangeSchema,
|
|
583
|
-
engagementChangePreviewSchema,
|
|
584
|
-
engagementVersionPageSchema,
|
|
585
|
-
engagementVersionQuerySchema,
|
|
586
|
-
engagementBoundaryPageSchema,
|
|
587
|
-
engagementArtifactSchema,
|
|
588
|
-
engagementDeploymentEntrySchema,
|
|
589
|
-
authoringIdentityShape,
|
|
590
|
-
validateAuthoringIdentity,
|
|
591
|
-
normalizeAuthoringIdentity,
|
|
592
|
-
authoringKey,
|
|
593
|
-
referralDefinitionSchema,
|
|
594
|
-
referralAuthoringSchema,
|
|
595
|
-
defineReferral,
|
|
596
|
-
referralArtifactSchema,
|
|
597
|
-
publishedReferralSchema,
|
|
598
|
-
referralAcceptSchema,
|
|
599
|
-
referralControlSchema,
|
|
600
|
-
referralRelationshipSchema,
|
|
601
|
-
referralAccountSchema,
|
|
602
|
-
referralSummarySchema,
|
|
603
|
-
referralHistorySchema,
|
|
604
|
-
referralManagementSchema,
|
|
605
|
-
leaderboardWindowSchema,
|
|
606
|
-
leaderboardDefinitionSchema,
|
|
607
|
-
leaderboardAuthoringSchema,
|
|
608
|
-
defineLeaderboard,
|
|
609
|
-
leaderboardArtifactSchema,
|
|
610
|
-
publishedLeaderboardSchema,
|
|
611
|
-
leaderboardQuerySchema,
|
|
612
|
-
leaderboardRowSchema,
|
|
613
|
-
leaderboardPageSchema,
|
|
614
|
-
leaderboardPlacementSchema,
|
|
615
|
-
leaderboardPreviewSchema,
|
|
616
|
-
pointsMutationSchema,
|
|
617
|
-
pointsEntrySchema,
|
|
618
|
-
pointsResultSchema,
|
|
619
|
-
pointsAccountSchema,
|
|
620
|
-
leaderboardExclusionSchema,
|
|
621
|
-
leaderboardGroupSchema,
|
|
622
|
-
parseUnits,
|
|
623
|
-
formatUnits
|
|
624
|
-
};
|