@domino-sdk/relay 1.63.0 → 1.65.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.
Files changed (69) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/{accounts-nz3mzfRQ.d.ts → accounts-_lNsiR2k.d.ts} +22 -2
  3. package/dist/{attempt-captures-DMi8oR9T.d.ts → attempt-captures-BqPggxTU.d.ts} +1 -1
  4. package/dist/authoring.d.ts +11 -11
  5. package/dist/authoring.js +15 -20
  6. package/dist/{automatic-outcomes-C_LLQU1p.d.ts → automatic-outcomes-BzAvfcpd.d.ts} +2 -2
  7. package/dist/browser.d.ts +9 -9
  8. package/dist/browser.js +11 -14
  9. package/dist/{catalog-BaTOKpNw.d.ts → catalog-ByZMRS7I.d.ts} +1 -1
  10. package/dist/{chunk-VWQGWGCH.js → chunk-4NIV4NPV.js} +1 -1
  11. package/dist/{chunk-ICXZZNPS.js → chunk-7H4MRVQF.js} +1 -1
  12. package/dist/{chunk-NQDEWJWE.js → chunk-CVQZ2YP7.js} +6 -232
  13. package/dist/{chunk-3RFP6GT5.js → chunk-DLABJSBO.js} +2 -2
  14. package/dist/{chunk-AQOL3SK5.js → chunk-E22XSC4L.js} +1 -1
  15. package/dist/{chunk-N4LNEGQX.js → chunk-EDNKKVGU.js} +2 -2
  16. package/dist/{chunk-GLH6MEI2.js → chunk-EOUEAOWJ.js} +28 -2
  17. package/dist/{chunk-MTKRIQEU.js → chunk-EUEW2APU.js} +1 -1
  18. package/dist/{chunk-ID3BZXFZ.js → chunk-HNR6G3GV.js} +1939 -1211
  19. package/dist/{chunk-5XLZ34PV.js → chunk-KCUUHT2V.js} +3 -3
  20. package/dist/{chunk-EHUSD3O2.js → chunk-MPTE7EIV.js} +2 -4
  21. package/dist/{chunk-QR6HH4DI.js → chunk-NG4GZ54I.js} +4 -4
  22. package/dist/chunk-R2KZFX6E.js +405 -0
  23. package/dist/{chunk-4GQW43UU.js → chunk-RD3XJ4DH.js} +26 -30
  24. package/dist/{chunk-7Z4SZ6YM.js → chunk-SE7XHQFP.js} +1 -1
  25. package/dist/{chunk-LZWXCBUB.js → chunk-VBYOAT46.js} +41 -45
  26. package/dist/{chunk-7X67QLPB.js → chunk-XVZ4YOF2.js} +1 -1
  27. package/dist/{chunk-FU5CGNTR.js → chunk-ZQ3IPCI6.js} +44 -5
  28. package/dist/chunk-ZXGBDLVB.js +1510 -0
  29. package/dist/{client-DHmG7rn6.d.ts → client-D7IiwEq2.d.ts} +12 -7
  30. package/dist/{dashboards-CLemT6kj.d.ts → dashboards-pVfclkyh.d.ts} +2 -2
  31. package/dist/{deployments-DTULi7dF.d.ts → deployments-Cr1tfqrr.d.ts} +2 -2
  32. package/dist/{identity-integration-DOeNZaxF.d.ts → identity-integration-Ci2vGKtX.d.ts} +37 -2
  33. package/dist/index.d.ts +10 -10
  34. package/dist/index.js +11 -15
  35. package/dist/internal.d.ts +12 -12
  36. package/dist/internal.js +21 -16
  37. package/dist/{limits-kNzYdZ00.d.ts → limits-pE04y9O2.d.ts} +8 -1
  38. package/dist/{offers-CYeN_I0Y.d.ts → offers-Hw2P6tcK.d.ts} +2 -2
  39. package/dist/{participant-activity-D-Drp24G.d.ts → participant-activity-DXRq4s6K.d.ts} +1 -0
  40. package/dist/portal-proxy.d.ts +4 -2
  41. package/dist/portal-proxy.js +13 -5
  42. package/dist/react/index.d.ts +20 -13
  43. package/dist/react/index.js +11 -14
  44. package/dist/{reward-deliveries-drp-x1G-.d.ts → reward-deliveries-BCV8hznc.d.ts} +1 -1
  45. package/dist/runtime/authoring.js +1 -1
  46. package/dist/runtime/chunks/6EBN6IZU.js +1 -0
  47. package/dist/runtime/manifest.json +3 -3
  48. package/dist/runtime/schema.js +1 -1
  49. package/dist/schema.d.ts +19 -16
  50. package/dist/schema.js +109 -112
  51. package/dist/server/index.d.ts +11 -11
  52. package/dist/server/index.js +775 -1037
  53. package/dist/{sign-in-providers-B1Q9eDRm.d.ts → sign-in-providers-BAkGjSXo.d.ts} +2 -2
  54. package/dist/{submission-input-DZCbjQUH.d.ts → submission-input-ChL1aYNH.d.ts} +2 -2
  55. package/dist/{telegram-browser-NL0Asmsi.d.ts → telegram-browser-K27t4TwM.d.ts} +4 -4
  56. package/dist/telegram.d.ts +8 -8
  57. package/dist/telegram.js +2 -2
  58. package/dist/testing.d.ts +10 -10
  59. package/dist/testing.js +19 -23
  60. package/dist/{tracker-data-esm3WG8R.d.ts → tracker-data-Bl-qPIvZ.d.ts} +3 -1
  61. package/dist/{transport-Czht_irp.d.ts → transport-DC1m73Tp.d.ts} +1065 -14
  62. package/package.json +1 -1
  63. package/dist/chunk-4NOFSGAL.js +0 -320
  64. package/dist/chunk-FO2LCZTL.js +0 -19
  65. package/dist/chunk-KP2MCX3R.js +0 -587
  66. package/dist/chunk-N4BDKS6Y.js +0 -87
  67. package/dist/chunk-TLSQETTY.js +0 -41
  68. package/dist/chunk-W7YSMSGC.js +0 -725
  69. package/dist/runtime/chunks/UGDV5W4N.js +0 -1
@@ -1,725 +0,0 @@
1
- import {
2
- authoringIdentityShape,
3
- calendarPeriodSchema,
4
- identifier,
5
- maxPointsAmount,
6
- pageCursorSchema,
7
- pointsRewardSchema,
8
- refuseWindowTimeZone,
9
- responseShape,
10
- rewardKey,
11
- tierRewardSchema
12
- } from "./chunk-ID3BZXFZ.js";
13
-
14
- // src/badges.ts
15
- import * as z from "zod";
16
- var badgePropertiesSchema = /* @__PURE__ */ (() => z.object({
17
- name: z.string().trim().min(1).max(120),
18
- description: z.string().trim().max(1e3).default(""),
19
- image: z.string().url().max(2048)
20
- }).strict())();
21
- var badgeDeclarationSchema = /* @__PURE__ */ (() => badgePropertiesSchema.extend({ key: identifier }).strict())();
22
- var badgeSchema = /* @__PURE__ */ (() => badgePropertiesSchema.extend({ id: identifier, key: identifier.nullable() }).strip())();
23
- var managedBadgeSchema = /* @__PURE__ */ (() => badgeSchema.extend({
24
- archivedAt: z.number().int().nonnegative().nullable()
25
- }))();
26
- var createBadgeSchema = /* @__PURE__ */ (() => badgeDeclarationSchema.extend({ actionId: identifier }).strict())();
27
- var badgeArtifactSchema = /* @__PURE__ */ (() => z.union([
28
- badgeDeclarationSchema,
29
- z.object({ code: z.string().min(1).max(2e6) }).strict()
30
- ]))();
31
- var memberBadgeSchema = /* @__PURE__ */ (() => z.object({
32
- badge: badgeSchema,
33
- awardedAt: z.number().int().nonnegative()
34
- }))();
35
- var memberBadgesSchema = /* @__PURE__ */ (() => z.object({
36
- items: z.array(memberBadgeSchema)
37
- }))();
38
- var badgeCatalogSchema = /* @__PURE__ */ (() => z.object({ items: z.array(badgeSchema) }))();
39
- var badgeMutationSchema = /* @__PURE__ */ (() => z.object({ actionId: identifier, reason: z.string().trim().min(1).max(1e3) }).strict())();
40
- var badgeMutationResultSchema = /* @__PURE__ */ (() => z.object({
41
- badge: identifier,
42
- member: identifier,
43
- awarded: z.boolean(),
44
- changed: z.boolean()
45
- }))();
46
-
47
- // src/point-ledgers.ts
48
- import * as z2 from "zod";
49
- var pointLedgerPropertiesSchema = /* @__PURE__ */ (() => z2.object({
50
- name: z2.string().trim().min(1).max(120),
51
- description: z2.string().trim().max(1e3).default("")
52
- }).strict())();
53
- var createPointLedgerSchema = /* @__PURE__ */ (() => pointLedgerPropertiesSchema.extend({ actionId: identifier, key: identifier.optional() }).strict())();
54
- var pointLedgerSchema = /* @__PURE__ */ (() => pointLedgerPropertiesSchema.extend({
55
- id: identifier
56
- }))();
57
- var managedPointLedgerSchema = /* @__PURE__ */ (() => pointLedgerSchema.extend({
58
- archivedAt: z2.number().int().nonnegative().nullable()
59
- }))();
60
- var pointLedgerDeclarationSchema = /* @__PURE__ */ (() => pointLedgerPropertiesSchema.extend({ key: identifier }).strict())();
61
- var pointLedgerArtifactSchema = /* @__PURE__ */ (() => z2.union([
62
- pointLedgerDeclarationSchema,
63
- z2.object({ code: z2.string().min(1).max(2e6) }).strict()
64
- ]))();
65
- var pointLedgerReferenceSchema = /* @__PURE__ */ (() => z2.object({
66
- id: identifier,
67
- key: identifier.nullable(),
68
- name: z2.string()
69
- }))();
70
- var points = /* @__PURE__ */ (() => z2.number().int().safe())();
71
- var pointBalanceSchema = /* @__PURE__ */ (() => z2.object({
72
- ledger: pointLedgerReferenceSchema,
73
- balance: points,
74
- available: points
75
- }))();
76
- var pointBalancesSchema = /* @__PURE__ */ (() => z2.object({
77
- items: z2.array(pointBalanceSchema)
78
- }))();
79
- var PointEntryKind = {
80
- /** Points a quest completion, an engagement settlement or an operator awarded. */
81
- Award: "award",
82
- /** Points the member spent. */
83
- Spend: "spend",
84
- /** A correction in either direction, by an operator or a referral payout. */
85
- Adjust: "adjust",
86
- /** Undoes part or all of an award or a positive adjustment (`reverses`). */
87
- Reverse: "reverse"
88
- };
89
- var pointEntryKindSchema = /* @__PURE__ */ (() => z2.string().min(1).max(64))();
90
- var pointEntrySchema = /* @__PURE__ */ (() => z2.object({
91
- id: identifier,
92
- amount: points,
93
- kind: pointEntryKindSchema,
94
- /** When the entry took effect, in epoch milliseconds. A reversal keeps its source's. */
95
- at: points.nonnegative(),
96
- quest: identifier.nullable(),
97
- reverses: identifier.nullable(),
98
- /**
99
- * True for an opening balance a member import recorded (an `adjust`). Absent from Relay
100
- * versions without imports.
101
- */
102
- imported: z2.boolean().optional()
103
- }))();
104
- var pointHistoryQuerySchema = /* @__PURE__ */ (() => z2.strictObject({
105
- ledger: identifier,
106
- cursor: pageCursorSchema.optional()
107
- }))();
108
- var pointHistoryPageSchema = /* @__PURE__ */ (() => z2.object({
109
- items: z2.array(pointEntrySchema),
110
- nextCursor: pageCursorSchema.nullable()
111
- }))();
112
-
113
- // src/profiles.ts
114
- import * as z3 from "zod";
115
- var count = /* @__PURE__ */ (() => z3.number().int().nonnegative().safe())();
116
- var profileVisibilitySchema = /* @__PURE__ */ (() => z3.enum([
117
- "private",
118
- "participants",
119
- "public"
120
- ]))();
121
- var avatarProviderSchema = /* @__PURE__ */ (() => z3.enum(["x", "discord", "google"]))();
122
- var profileDefaultProviderSchema = /* @__PURE__ */ (() => z3.enum(["x", "discord"]))();
123
- var profileDefaultsSchema = /* @__PURE__ */ (() => z3.array(profileDefaultProviderSchema).max(profileDefaultProviderSchema.options.length).refine(
124
- (providers) => new Set(providers).size === providers.length,
125
- "List each provider once"
126
- ))();
127
- var avatarSeedSchema = /* @__PURE__ */ (() => z3.string().min(1).max(100))();
128
- var profileAvatarSchema = /* @__PURE__ */ (() => z3.discriminatedUnion("source", [
129
- z3.object({
130
- source: z3.literal("upload"),
131
- url: z3.string().url(),
132
- seed: avatarSeedSchema
133
- }),
134
- z3.object({
135
- source: z3.literal("account"),
136
- provider: avatarProviderSchema,
137
- url: z3.string().url(),
138
- seed: avatarSeedSchema
139
- }),
140
- z3.object({ source: z3.literal("generated"), seed: avatarSeedSchema })
141
- ]))();
142
- var profileSummarySchema = /* @__PURE__ */ (() => z3.object({
143
- id: identifier,
144
- name: z3.string(),
145
- avatar: profileAvatarSchema
146
- }))();
147
- var invisible = /[\p{Cc}؜᠎​-‏‪-‮⁠-⁤⁦-⁩]/u;
148
- var displayNameSchema = /* @__PURE__ */ (() => z3.string().max(200).transform((value) => value.normalize("NFC").replace(/\s+/g, " ").trim()).pipe(
149
- z3.string().min(1, "Enter a name").max(40, "Use at most 40 characters").refine((value) => !invisible.test(value), "Use visible characters only")
150
- ))();
151
- var profileUpdateSchema = /* @__PURE__ */ (() => z3.object({
152
- displayName: displayNameSchema.nullable().optional(),
153
- avatar: z3.discriminatedUnion("source", [
154
- z3.object({
155
- source: z3.literal("account"),
156
- provider: avatarProviderSchema
157
- }).strict(),
158
- z3.object({ source: z3.literal("generated") }).strict()
159
- ]).nullable().optional(),
160
- hidden: z3.boolean().optional()
161
- }).strict().refine(
162
- (value) => Object.values(value).some((field) => field !== void 0),
163
- "Change at least one field"
164
- ))();
165
- var ownProfileSchema = /* @__PURE__ */ (() => profileSummarySchema.extend({
166
- /** The name the member chose, or null for the default. */
167
- displayName: z3.string().nullable(),
168
- /** The avatar the member chose: `default` follows the project's defaults. */
169
- avatarChoice: z3.enum(["default", "upload", "account", "generated"]),
170
- /** The account of an `account` choice. */
171
- avatarProvider: avatarProviderSchema.nullable(),
172
- hidden: z3.boolean(),
173
- /** An operator locked the name and avatar; the member can still hide the profile. */
174
- locked: z3.boolean(),
175
- /** Who can see profiles in this project, so the app can explain it. */
176
- visibility: profileVisibilitySchema,
177
- /** The member's connected accounts a picture or name can come from. */
178
- options: z3.array(
179
- z3.object({
180
- provider: avatarProviderSchema,
181
- name: z3.string().nullable(),
182
- /**
183
- * The account's first name, where the provider sends one (Google does; X and Discord don't).
184
- * Only the member's own profile carries it.
185
- */
186
- givenName: z3.string().nullable().default(null),
187
- imageUrl: z3.string().url().nullable()
188
- })
189
- )
190
- }))();
191
- var cursor = /* @__PURE__ */ (() => z3.string().min(1).max(512))();
192
- var profileCompletionQuerySchema = /* @__PURE__ */ (() => z3.object({
193
- limit: z3.coerce.number().int().min(1).max(100).default(20),
194
- cursor: cursor.optional()
195
- }).strict())();
196
- var profileCompletionSchema = /* @__PURE__ */ (() => z3.object({
197
- quest: identifier,
198
- key: identifier.optional(),
199
- title: z3.string(),
200
- completions: count.positive(),
201
- /** Null for completions recorded before completion times were. */
202
- lastCompletedAt: count.nullable()
203
- }))();
204
- var profileCompletionPageSchema = /* @__PURE__ */ (() => z3.object({
205
- items: z3.array(profileCompletionSchema),
206
- nextCursor: cursor.nullable()
207
- }))();
208
- var profileReferralSchema = /* @__PURE__ */ (() => z3.object({
209
- program: identifier,
210
- key: identifier.optional(),
211
- title: z3.string(),
212
- /** Members this member invited. Invitations are shared by every program. */
213
- invited: count,
214
- /** Invited members who qualified in this program. */
215
- qualified: count,
216
- milestones: z3.array(
217
- z3.object({ id: identifier, count, reached: z3.boolean() })
218
- )
219
- }))();
220
- var profileSettingsSchema = /* @__PURE__ */ (() => z3.object({
221
- visibility: profileVisibilitySchema,
222
- defaults: profileDefaultsSchema,
223
- revision: count,
224
- actor: z3.string().nullable(),
225
- updatedAt: count.nullable()
226
- }))();
227
- var profileSettingsInputSchema = /* @__PURE__ */ (() => profileSettingsSchema.omit({ revision: true, actor: true, updatedAt: true }).extend({
228
- actionId: identifier,
229
- /** The revision the change was made against; a newer one is a 409. */
230
- expectedRevision: count,
231
- reason: z3.string().trim().min(1).max(500)
232
- }).strict())();
233
- var profileModerationSchema = /* @__PURE__ */ (() => z3.object({
234
- actionId: identifier,
235
- resetName: z3.boolean().default(false),
236
- removeAvatar: z3.boolean().default(false),
237
- /** True locks the name and avatar, false unlocks them. */
238
- lock: z3.boolean().optional(),
239
- reason: z3.string().trim().min(1).max(1e3)
240
- }).strict().refine(
241
- (value) => value.resetName || value.removeAvatar || value.lock !== void 0,
242
- "Choose an action"
243
- ))();
244
- var managedProfileSchema = /* @__PURE__ */ (() => ownProfileSchema.omit({ options: true }).extend({
245
- member: identifier,
246
- lockedAt: count.nullable(),
247
- lockedBy: z3.string().nullable(),
248
- lockedReason: z3.string().nullable(),
249
- updatedAt: count
250
- }))();
251
- var AVATAR_UPLOAD_LIMIT = 5 * 1024 * 1024;
252
- var avatarUploadTypes = ["image/jpeg", "image/png", "image/webp"];
253
-
254
- // src/leaderboards.ts
255
- import * as z4 from "zod";
256
- var integer = /* @__PURE__ */ (() => z4.number().int().safe())();
257
- var timestamp = /* @__PURE__ */ (() => integer.nonnegative().max(864e13))();
258
- var leaderboardWindowSchema = /* @__PURE__ */ (() => z4.discriminatedUnion("kind", [
259
- z4.object({ kind: z4.literal("all-time") }).strict(),
260
- z4.object({ kind: z4.literal("fixed"), start: timestamp, end: timestamp }).strict().refine((w) => w.end > w.start, "Window end must follow its start"),
261
- z4.object({ kind: z4.literal("rolling"), days: integer.min(1).max(3660) }).strict(),
262
- // Not strict: boards published while a calendar window named its own `timeZone` keep reading,
263
- // and the field drops on parse. The authoring schema refuses it.
264
- z4.object({
265
- kind: z4.literal("calendar"),
266
- /** The current day, week (ISO, starting on Monday) or month of the project calendar. */
267
- period: calendarPeriodSchema.exclude(["lifetime"])
268
- })
269
- ]))();
270
- var periodScore = /* @__PURE__ */ (() => ({
271
- window: leaderboardWindowSchema.default({ kind: "all-time" }),
272
- quests: z4.array(identifier).min(1).max(100).optional()
273
- }))();
274
- var scoreSchema = /* @__PURE__ */ (() => z4.discriminatedUnion("kind", [
275
- z4.object({ kind: z4.literal("balance") }).strict(),
276
- z4.object({ kind: z4.literal("earned"), ...periodScore }).strict(),
277
- z4.object({
278
- kind: z4.literal("net"),
279
- window: leaderboardWindowSchema.default({ kind: "all-time" })
280
- }).strict()
281
- ]).default({ kind: "balance" }))();
282
- var leaderboardPrizeRewardSchema = /* @__PURE__ */ (() => z4.union([
283
- pointsRewardSchema,
284
- tierRewardSchema
285
- ]))();
286
- var leaderboardPrizeSchema = /* @__PURE__ */ (() => z4.object({
287
- ranks: z4.tuple([integer.positive(), integer.positive()]).refine(([first, last]) => last >= first, {
288
- message: "Prize rank range must end at or after it starts"
289
- }),
290
- rewards: z4.array(leaderboardPrizeRewardSchema).min(1).max(20)
291
- }).strict())();
292
- var baseUnitsSchema = /* @__PURE__ */ (() => z4.string().regex(
293
- /^(0|[1-9]\d{0,77})$/,
294
- 'Use a whole number of base units, such as "1000000"'
295
- ))();
296
- var leaderboardPoolUnitSchema = /* @__PURE__ */ (() => z4.union([
297
- z4.literal("points"),
298
- z4.object({
299
- code: z4.string().trim().min(1).max(32),
300
- decimals: integer.min(0).max(36)
301
- }).strict()
302
- ]))();
303
- var poolShape = /* @__PURE__ */ (() => ({
304
- /** The whole pool in base units. */
305
- amount: baseUnitsSchema.refine((amount) => amount !== "0", {
306
- message: "A pool must hold a positive amount"
307
- }),
308
- unit: leaderboardPoolUnitSchema,
309
- /**
310
- * The point ledger a points pool pays into. Only points pools take one, and they require it. It
311
- * can differ from the leaderboard's `balance`, the ledger it ranks.
312
- */
313
- ledger: identifier.optional(),
314
- /** Members scoring at or below this get no share. Members scoring 0 or less never do. */
315
- minScore: integer.optional()
316
- }))();
317
- var refinePool = (pool, context) => {
318
- if (pool.unit === "points") {
319
- if (!pool.ledger) {
320
- context.addIssue({
321
- code: "custom",
322
- message: "A points pool names the point ledger it pays into",
323
- path: ["ledger"]
324
- });
325
- }
326
- if (/^\d+$/.test(pool.amount) && BigInt(pool.amount) > maxPointsAmount) {
327
- context.addIssue({
328
- code: "custom",
329
- message: `A points pool holds at most ${maxPointsAmount} points`,
330
- path: ["amount"]
331
- });
332
- }
333
- } else if (pool.ledger !== void 0) {
334
- context.addIssue({
335
- code: "custom",
336
- message: "Only a points pool pays into a point ledger",
337
- path: ["ledger"]
338
- });
339
- }
340
- };
341
- var leaderboardPoolSchema = /* @__PURE__ */ (() => z4.object(poolShape).strict().superRefine(refinePool))();
342
- var leaderboardSettlementPolicySchema = /* @__PURE__ */ (() => z4.object({
343
- at: z4.literal("window-end"),
344
- ties: z4.enum(["shared", "earliest"]),
345
- /** Rank prizes. A board with a pool may list none. */
346
- prizes: z4.array(leaderboardPrizeSchema).max(50),
347
- pool: leaderboardPoolSchema.optional()
348
- }).strict().superRefine((policy, context) => {
349
- if (!policy.prizes.length && !policy.pool) {
350
- context.addIssue({
351
- code: "custom",
352
- message: "A settlement awards rank prizes, a pool, or both",
353
- path: ["prizes"]
354
- });
355
- }
356
- for (const [index, prize] of policy.prizes.entries()) {
357
- const keys = prize.rewards.map(rewardKey);
358
- if (new Set(keys).size !== keys.length) {
359
- context.addIssue({
360
- code: "custom",
361
- message: "A prize may grant each point ledger or tiered reward only once",
362
- path: ["prizes", index, "rewards"]
363
- });
364
- }
365
- }
366
- for (let index = 1; index < policy.prizes.length; index++) {
367
- const previous = policy.prizes[index - 1];
368
- const current = policy.prizes[index];
369
- if (current.ranks[0] <= previous.ranks[1]) {
370
- context.addIssue({
371
- code: "custom",
372
- message: "Prize rank ranges must be ordered and must not overlap",
373
- path: ["prizes", index, "ranks"]
374
- });
375
- }
376
- }
377
- }))();
378
- var leaderboardDefinitionObject = /* @__PURE__ */ (() => z4.object({
379
- id: identifier,
380
- key: identifier.optional(),
381
- title: z4.string().trim().min(1).max(120),
382
- /**
383
- * The point ledger the leaderboard ranks members by. Named `balance` from before ledger fields
384
- * were named `ledger` (docs/management-api.md#field-names); a points pool's `ledger` is the
385
- * ledger the pool pays into.
386
- */
387
- balance: identifier,
388
- score: scoreSchema,
389
- access: z4.enum(["participants", "public"]).default("participants"),
390
- group: identifier.optional(),
391
- /**
392
- * List the project's eligible members who have no qualifying points, with a score of 0, ranked
393
- * after every member who scored and ordered by member ID. Omitted or false lists only members
394
- * with a qualifying entry. Settlements never include them.
395
- */
396
- includeUnscored: z4.boolean().optional(),
397
- /**
398
- * How the live standings order equal scores. Omitted or `"shared"`: they share a rank. With
399
- * `"earliest"`, the member whose last counted entry is earlier ranks first (then member ID), and
400
- * every scored member gets its own rank: the order `settle.ties: "earliest"` uses.
401
- */
402
- ties: z4.enum(["shared", "earliest"]).optional(),
403
- settle: leaderboardSettlementPolicySchema.optional()
404
- }).strict())();
405
- var validateSettlementWindow = (definition, context) => {
406
- if (definition.settle && (definition.score.kind === "balance" || !["fixed", "calendar"].includes(definition.score.window.kind))) {
407
- context.addIssue({
408
- code: "custom",
409
- message: "Leaderboard prizes require an earned or net score with a fixed or calendar window",
410
- path: ["settle"]
411
- });
412
- }
413
- };
414
- var leaderboardDefinitionSchema = /* @__PURE__ */ (() => leaderboardDefinitionObject.superRefine(validateSettlementWindow))();
415
- var leaderboardDefinitionResponseSchema = /* @__PURE__ */ (() => responseShape(
416
- leaderboardDefinitionSchema
417
- ))();
418
- var leaderboardAuthoringSchema = /* @__PURE__ */ (() => leaderboardDefinitionObject.omit({ id: true }).extend({
419
- ...authoringIdentityShape,
420
- score: z4.preprocess(refuseWindowTimeZone, scoreSchema),
421
- group: identifier.optional()
422
- }).strict().superRefine(validateSettlementWindow))();
423
- var leaderboardArtifactSchema = /* @__PURE__ */ (() => z4.union([
424
- leaderboardAuthoringSchema,
425
- z4.object({ code: z4.string().min(1).max(2e6) }).strict()
426
- ]))();
427
- var publishedLeaderboardSchema = /* @__PURE__ */ (() => z4.object({
428
- archivedAt: z4.number().int().nonnegative().nullable().optional(),
429
- version: identifier,
430
- definition: leaderboardDefinitionResponseSchema,
431
- publishedAt: timestamp,
432
- actor: z4.string().nullable()
433
- }))();
434
- var leaderboardQuerySchema = /* @__PURE__ */ (() => z4.object({
435
- limit: z4.coerce.number().int().min(1).max(100).default(25),
436
- cursor: z4.string().max(4096).optional()
437
- }).strict())();
438
- var leaderboardRowSchema = /* @__PURE__ */ (() => z4.object({
439
- /** The row's stable key: a pseudonym per board and member. */
440
- participant: identifier,
441
- member: identifier.optional(),
442
- /** The profile's name where the viewer can see it, otherwise the pseudonym's. */
443
- name: z4.string(),
444
- score: integer,
445
- rank: integer.positive(),
446
- /** The member's profile, where visible to this viewer and not hidden by the member. */
447
- profile: profileSummarySchema.nullable()
448
- }))();
449
- var leaderboardPageSchema = /* @__PURE__ */ (() => z4.object({
450
- leaderboard: identifier,
451
- title: z4.string(),
452
- version: identifier,
453
- calculation: z4.enum(["balance", "earned", "net"]),
454
- period: z4.object({ start: timestamp.nullable(), end: timestamp.nullable() }),
455
- calculatedAt: timestamp,
456
- lastEntryAt: timestamp.nullable(),
457
- total: integer.nonnegative(),
458
- items: z4.array(leaderboardRowSchema),
459
- me: leaderboardRowSchema.nullable(),
460
- nearby: z4.array(leaderboardRowSchema),
461
- nextCursor: z4.string().nullable()
462
- }))();
463
- var leaderboardPlacementSchema = /* @__PURE__ */ (() => z4.object({
464
- leaderboard: identifier,
465
- key: identifier.optional(),
466
- title: z4.string(),
467
- profile: identifier,
468
- rank: integer.positive().nullable(),
469
- score: integer.nullable(),
470
- /** Ranked participants on the board. */
471
- total: integer.nonnegative()
472
- }))();
473
- var leaderboardHistoryQuerySchema = /* @__PURE__ */ (() => z4.strictObject({
474
- board: identifier,
475
- cursor: pageCursorSchema.optional()
476
- }))();
477
- var leaderboardHistoryPageSchema = /* @__PURE__ */ (() => z4.object({
478
- leaderboard: identifier,
479
- period: z4.object({ start: timestamp.nullable(), end: timestamp.nullable() }),
480
- items: z4.array(pointEntrySchema),
481
- nextCursor: pageCursorSchema.nullable()
482
- }))();
483
- var leaderboardPreviewSchema = /* @__PURE__ */ (() => z4.object({
484
- published: publishedLeaderboardSchema,
485
- before: leaderboardPageSchema.nullable(),
486
- after: leaderboardPageSchema
487
- }))();
488
- var mutationBase = /* @__PURE__ */ (() => ({
489
- actionId: identifier,
490
- member: identifier,
491
- balance: identifier,
492
- reason: z4.string().trim().min(1).max(1e3)
493
- }))();
494
- var datedMutation = /* @__PURE__ */ (() => ({ ...mutationBase, effectiveAt: timestamp.optional() }))();
495
- var pointsMutationSchema = /* @__PURE__ */ (() => z4.discriminatedUnion("kind", [
496
- z4.object({
497
- ...datedMutation,
498
- kind: z4.literal("award"),
499
- referralEligible: z4.boolean().optional(),
500
- amount: integer.positive()
501
- }).strict(),
502
- z4.object({
503
- ...datedMutation,
504
- kind: z4.literal("spend"),
505
- amount: integer.positive()
506
- }).strict(),
507
- z4.object({
508
- ...datedMutation,
509
- kind: z4.literal("adjust"),
510
- amount: integer.refine((n) => n !== 0)
511
- }).strict(),
512
- z4.object({
513
- ...datedMutation,
514
- kind: z4.literal("set"),
515
- total: integer.nonnegative(),
516
- expectedTotal: integer.nonnegative(),
517
- classification: z4.enum(["earned", "spend"])
518
- }).strict(),
519
- z4.object({
520
- ...mutationBase,
521
- kind: z4.literal("reverse"),
522
- entry: identifier,
523
- amount: integer.positive()
524
- }).strict()
525
- ]))();
526
- var pointsEntrySchema = /* @__PURE__ */ (() => z4.object({
527
- id: identifier,
528
- completion: z4.string().nullable(),
529
- member: identifier,
530
- balance: identifier,
531
- amount: integer,
532
- kind: z4.enum(["award", "spend", "adjust", "reverse"]),
533
- effectiveAt: timestamp,
534
- receivedAt: timestamp,
535
- quest: identifier.nullable(),
536
- original: identifier.nullable(),
537
- reason: z4.string(),
538
- actor: z4.string().nullable(),
539
- /**
540
- * The member import whose opening balance this `adjust` is, or null. Imported entries emit no
541
- * `points.awarded` and count on balance leaderboards only. Absent from Relay versions without
542
- * imports.
543
- */
544
- import: identifier.nullable().optional()
545
- }))();
546
- var managedPointHistoryPageSchema = /* @__PURE__ */ (() => z4.object({
547
- items: z4.array(pointsEntrySchema),
548
- nextCursor: pageCursorSchema.nullable(),
549
- /** @deprecated Use `nextCursor`, passed back as `cursor`. Removed in 2.0.0. */
550
- next: z4.number().nullable()
551
- }))();
552
- var pointsResultSchema = /* @__PURE__ */ (() => z4.object({
553
- entry: pointsEntrySchema,
554
- total: integer.nonnegative()
555
- }))();
556
- var pointsAccountSchema = /* @__PURE__ */ (() => z4.object({
557
- member: identifier,
558
- balance: identifier,
559
- total: integer.nonnegative(),
560
- held: integer.nonnegative()
561
- }))();
562
- var leaderboardExclusionSchema = /* @__PURE__ */ (() => z4.object({
563
- actionId: identifier,
564
- member: identifier,
565
- excluded: z4.boolean(),
566
- reason: z4.string().trim().min(1).max(1e3)
567
- }).strict())();
568
- var leaderboardExclusionGroupSchema = /* @__PURE__ */ (() => z4.object({
569
- leaderboard: identifier,
570
- group: identifier,
571
- generated: z4.boolean(),
572
- boundAt: timestamp.nullable()
573
- }))();
574
- var leaderboardExclusionGroupBindingSchema = /* @__PURE__ */ (() => z4.object({
575
- actionId: identifier,
576
- group: identifier,
577
- reason: z4.string().trim().min(1).max(1e3)
578
- }).strict())();
579
- var leaderboardGroupSchema = /* @__PURE__ */ (() => z4.object({
580
- actionId: identifier,
581
- member: identifier,
582
- included: z4.boolean(),
583
- reason: z4.string().trim().min(1).max(1e3)
584
- }).strict())();
585
- var leaderboardSettlementStatusSchema = /* @__PURE__ */ (() => z4.enum(["pending", "approved"]))();
586
- var leaderboardSettlementSummarySchema = /* @__PURE__ */ (() => z4.object({
587
- id: identifier,
588
- leaderboard: identifier,
589
- version: identifier,
590
- title: z4.string(),
591
- period: z4.object({ start: timestamp, end: timestamp }),
592
- ties: z4.enum(["shared", "earliest"]),
593
- status: leaderboardSettlementStatusSchema,
594
- total: integer.nonnegative(),
595
- winners: integer.nonnegative(),
596
- createdAt: timestamp,
597
- approvedAt: timestamp.nullable(),
598
- approvedBy: z4.string().nullable(),
599
- approvalReason: z4.string().nullable()
600
- }))();
601
- var leaderboardSettlementRowSchema = /* @__PURE__ */ (() => z4.object({
602
- member: identifier,
603
- score: integer,
604
- rank: integer.positive(),
605
- position: integer.positive(),
606
- scoredAt: timestamp,
607
- prizes: z4.array(integer.nonnegative()),
608
- completion: identifier.nullable(),
609
- revokedAt: timestamp.nullable(),
610
- /**
611
- * The member's pool share in the pool's base units, frozen with the row: `"0"` for a member the
612
- * pool leaves out. Absent when the settlement has no pool.
613
- */
614
- share: baseUnitsSchema.optional()
615
- }))();
616
- var leaderboardSettlementPoolSchema = /* @__PURE__ */ (() => z4.object({
617
- ...poolShape,
618
- allocated: baseUnitsSchema,
619
- unallocated: baseUnitsSchema
620
- }))();
621
- var leaderboardSettlementUnmeasuredSchema = /* @__PURE__ */ (() => z4.object({
622
- content: z4.string(),
623
- member: identifier,
624
- /** When the last good measurement was observed, if Relay has one. */
625
- observedAt: timestamp.nullable()
626
- }))();
627
- var leaderboardSettlementSchema = /* @__PURE__ */ (() => leaderboardSettlementSummarySchema.extend({
628
- prizes: z4.array(leaderboardPrizeSchema),
629
- excluded: z4.array(identifier),
630
- /**
631
- * Content frozen at its last good measurement because its closing measurement never came; a
632
- * reviewer can retry measurement. Relay sends it for every settlement, empty when nothing is
633
- * missing.
634
- */
635
- unmeasured: z4.array(leaderboardSettlementUnmeasuredSchema).optional(),
636
- /** The settlement's pool prize, or null without one. Absent from Relay versions without pools. */
637
- pool: leaderboardSettlementPoolSchema.nullable().optional(),
638
- rows: z4.array(leaderboardSettlementRowSchema)
639
- }))();
640
- var leaderboardSettlementApprovalSchema = /* @__PURE__ */ (() => z4.object({
641
- actionId: identifier,
642
- reason: z4.string().trim().min(1).max(500)
643
- }).strict())();
644
-
645
- export {
646
- badgePropertiesSchema,
647
- badgeDeclarationSchema,
648
- badgeSchema,
649
- managedBadgeSchema,
650
- createBadgeSchema,
651
- badgeArtifactSchema,
652
- memberBadgeSchema,
653
- memberBadgesSchema,
654
- badgeCatalogSchema,
655
- badgeMutationSchema,
656
- badgeMutationResultSchema,
657
- pointLedgerPropertiesSchema,
658
- createPointLedgerSchema,
659
- pointLedgerSchema,
660
- managedPointLedgerSchema,
661
- pointLedgerDeclarationSchema,
662
- pointLedgerArtifactSchema,
663
- pointLedgerReferenceSchema,
664
- pointBalanceSchema,
665
- pointBalancesSchema,
666
- PointEntryKind,
667
- pointEntrySchema,
668
- pointHistoryQuerySchema,
669
- pointHistoryPageSchema,
670
- profileVisibilitySchema,
671
- avatarProviderSchema,
672
- profileDefaultProviderSchema,
673
- profileDefaultsSchema,
674
- avatarSeedSchema,
675
- profileAvatarSchema,
676
- profileSummarySchema,
677
- displayNameSchema,
678
- profileUpdateSchema,
679
- ownProfileSchema,
680
- profileCompletionQuerySchema,
681
- profileCompletionSchema,
682
- profileCompletionPageSchema,
683
- profileReferralSchema,
684
- profileSettingsSchema,
685
- profileSettingsInputSchema,
686
- profileModerationSchema,
687
- managedProfileSchema,
688
- AVATAR_UPLOAD_LIMIT,
689
- avatarUploadTypes,
690
- leaderboardWindowSchema,
691
- leaderboardPrizeRewardSchema,
692
- leaderboardPrizeSchema,
693
- baseUnitsSchema,
694
- leaderboardPoolUnitSchema,
695
- leaderboardPoolSchema,
696
- leaderboardSettlementPolicySchema,
697
- leaderboardDefinitionSchema,
698
- leaderboardDefinitionResponseSchema,
699
- leaderboardAuthoringSchema,
700
- leaderboardArtifactSchema,
701
- publishedLeaderboardSchema,
702
- leaderboardQuerySchema,
703
- leaderboardRowSchema,
704
- leaderboardPageSchema,
705
- leaderboardPlacementSchema,
706
- leaderboardHistoryQuerySchema,
707
- leaderboardHistoryPageSchema,
708
- leaderboardPreviewSchema,
709
- pointsMutationSchema,
710
- pointsEntrySchema,
711
- managedPointHistoryPageSchema,
712
- pointsResultSchema,
713
- pointsAccountSchema,
714
- leaderboardExclusionSchema,
715
- leaderboardExclusionGroupSchema,
716
- leaderboardExclusionGroupBindingSchema,
717
- leaderboardGroupSchema,
718
- leaderboardSettlementStatusSchema,
719
- leaderboardSettlementSummarySchema,
720
- leaderboardSettlementRowSchema,
721
- leaderboardSettlementPoolSchema,
722
- leaderboardSettlementUnmeasuredSchema,
723
- leaderboardSettlementSchema,
724
- leaderboardSettlementApprovalSchema
725
- };