@domino-sdk/relay 1.61.0 → 1.63.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/CHANGELOG.md +276 -8
- package/README.md +3 -2
- package/dist/{schema-CZ6Rj0ZF.d.ts → accounts-nz3mzfRQ.d.ts} +3146 -1765
- package/dist/action-9Xl0StBg.d.ts +33 -0
- package/dist/{attempt-captures-DYnJVkfg.d.ts → attempt-captures-DMi8oR9T.d.ts} +1 -1
- package/dist/authoring.d.ts +171 -49
- package/dist/authoring.js +158 -49
- package/dist/{automatic-outcomes-If88LR9f.d.ts → automatic-outcomes-C_LLQU1p.d.ts} +15 -1
- package/dist/avatar.d.ts +1 -1
- package/dist/browser.d.ts +15 -11
- package/dist/browser.js +18 -12
- package/dist/capability-error-CuI_F7yM.d.ts +296 -0
- package/dist/{pages-K7-KjSXw.d.ts → catalog-BaTOKpNw.d.ts} +56 -567
- package/dist/{chunk-XBV2CK2H.js → chunk-3RFP6GT5.js} +15 -3
- package/dist/{chunk-VURRFVNP.js → chunk-4GQW43UU.js} +239 -361
- package/dist/chunk-4NOFSGAL.js +320 -0
- package/dist/{chunk-24I4R732.js → chunk-5XLZ34PV.js} +34 -19
- package/dist/{chunk-L77O64I4.js → chunk-7X67QLPB.js} +43 -43
- package/dist/{chunk-RHBS5FJL.js → chunk-7Z4SZ6YM.js} +3 -3
- package/dist/{chunk-QEAS4ZGS.js → chunk-AQOL3SK5.js} +1 -1
- package/dist/chunk-EHUSD3O2.js +377 -0
- package/dist/chunk-FO2LCZTL.js +19 -0
- package/dist/{chunk-DYXDZFKA.js → chunk-FU5CGNTR.js} +166 -178
- package/dist/chunk-FWLQ5XCS.js +21 -0
- package/dist/chunk-GLH6MEI2.js +193 -0
- package/dist/chunk-ICXZZNPS.js +199 -0
- package/dist/{chunk-ZDJLPN4L.js → chunk-ID3BZXFZ.js} +2696 -2693
- package/dist/chunk-KP2MCX3R.js +587 -0
- package/dist/{chunk-SKGTNTLF.js → chunk-LZWXCBUB.js} +213 -297
- package/dist/chunk-MTKRIQEU.js +31 -0
- package/dist/{chunk-4OC7REYX.js → chunk-MWMCQLCG.js} +3 -3
- package/dist/{chunk-PPB7HALD.js → chunk-N4BDKS6Y.js} +27 -26
- package/dist/{chunk-5I54XBK2.js → chunk-N4LNEGQX.js} +2 -2
- package/dist/chunk-NQDEWJWE.js +554 -0
- package/dist/chunk-QR6HH4DI.js +508 -0
- package/dist/chunk-TLSQETTY.js +41 -0
- package/dist/{chunk-MHPKEVEW.js → chunk-U66GUVSG.js} +7 -2
- package/dist/{chunk-KDR2VAJP.js → chunk-UYVJZR33.js} +2 -2
- package/dist/chunk-UZ765UGH.js +18 -0
- package/dist/{chunk-7A4J67ZL.js → chunk-VWQGWGCH.js} +7 -7
- package/dist/chunk-W7YSMSGC.js +725 -0
- package/dist/{client-C51w7fMb.d.ts → client-DHmG7rn6.d.ts} +126 -93
- package/dist/{announcements-CHx3-HBw.d.ts → dashboards-CLemT6kj.d.ts} +14 -137
- package/dist/{deployments-kWoHFaqj.d.ts → deployments-DTULi7dF.d.ts} +450 -18
- package/dist/identity-integration-DOeNZaxF.d.ts +1271 -0
- package/dist/index.d.ts +13 -11
- package/dist/index.js +16 -11
- package/dist/internal.d.ts +29 -13
- package/dist/internal.js +57 -17
- package/dist/{integrations-B3y36OaB.d.ts → limits-kNzYdZ00.d.ts} +464 -53
- package/dist/{offers-BoV4ryUc.d.ts → offers-CYeN_I0Y.d.ts} +22 -4
- package/dist/{participant-activity-DHL8QYks.d.ts → participant-activity-D-Drp24G.d.ts} +16 -3
- package/dist/portal-proxy.d.ts +75 -2
- package/dist/portal-proxy.js +153 -25
- package/dist/react/index.d.ts +214 -27
- package/dist/react/index.js +196 -42
- package/dist/{action-DBzILFx9.d.ts → request-error-D_dUPLwo.d.ts} +1 -31
- package/dist/reward-deliveries-drp-x1G-.d.ts +782 -0
- package/dist/runtime/authoring.js +1 -1
- package/dist/runtime/chunks/UGDV5W4N.js +1 -0
- package/dist/runtime/manifest.json +3 -3
- package/dist/runtime/schema.js +1 -1
- package/dist/schema.d.ts +330 -31
- package/dist/schema.js +147 -91
- package/dist/server/index.d.ts +14 -12
- package/dist/server/index.js +6425 -6260
- package/dist/sign-in-providers-B1Q9eDRm.d.ts +44 -0
- package/dist/submission-input-DZCbjQUH.d.ts +343 -0
- package/dist/{telegram-browser-BUceZIGZ.d.ts → telegram-browser-NL0Asmsi.d.ts} +46 -6
- package/dist/telegram.d.ts +64 -0
- package/dist/telegram.js +23 -0
- package/dist/testing.d.ts +326 -27
- package/dist/testing.js +440 -90
- package/dist/tracker-data-esm3WG8R.d.ts +1881 -0
- package/dist/{transport-BrX9pIGN.d.ts → transport-Czht_irp.d.ts} +43483 -38512
- package/dist/{wallet-CIqFoxdm.d.ts → wallet-B7e06v4m.d.ts} +32 -9
- package/package.json +5 -1
- package/dist/accounts-DoabriBX.d.ts +0 -306
- package/dist/capability-error-DufwG3G0.d.ts +0 -159
- package/dist/chunk-3Y3L2F54.js +0 -982
- package/dist/chunk-DHXDBAJF.js +0 -544
- package/dist/chunk-EN3M5Z4J.js +0 -13
- package/dist/chunk-QNUHWK7R.js +0 -602
- package/dist/chunk-SE4PFJPT.js +0 -247
- package/dist/groups-CqcA2Ycs.d.ts +0 -2827
- package/dist/runtime/chunks/5QVFB4TU.js +0 -1
- package/dist/submission-input-C54Q8yAD.d.ts +0 -146
- package/dist/x-D1PGi8Sq.d.ts +0 -331
package/dist/chunk-3Y3L2F54.js
DELETED
|
@@ -1,982 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
pointEntrySchema,
|
|
3
|
-
profileSummarySchema
|
|
4
|
-
} from "./chunk-SE4PFJPT.js";
|
|
5
|
-
import {
|
|
6
|
-
authoringIdentityShape,
|
|
7
|
-
calendarPeriodSchema,
|
|
8
|
-
contentMetricSchema,
|
|
9
|
-
contentMetricsSchema,
|
|
10
|
-
identifier,
|
|
11
|
-
maxPointsAmount,
|
|
12
|
-
missingPrerequisiteSchema,
|
|
13
|
-
pageCursorSchema,
|
|
14
|
-
pointsRewardSchema,
|
|
15
|
-
prerequisiteSchema,
|
|
16
|
-
refuseWindowTimeZone,
|
|
17
|
-
resourceHandle,
|
|
18
|
-
responseShape,
|
|
19
|
-
rewardKey,
|
|
20
|
-
tierRewardSchema
|
|
21
|
-
} from "./chunk-ZDJLPN4L.js";
|
|
22
|
-
|
|
23
|
-
// src/badges.ts
|
|
24
|
-
import * as z from "zod";
|
|
25
|
-
var badgePropertiesSchema = z.object({
|
|
26
|
-
name: z.string().trim().min(1).max(120),
|
|
27
|
-
description: z.string().trim().max(1e3).default(""),
|
|
28
|
-
image: z.string().url().max(2048)
|
|
29
|
-
}).strict();
|
|
30
|
-
var badgeDeclarationSchema = badgePropertiesSchema.extend({ key: identifier }).strict();
|
|
31
|
-
var badgeSchema = badgePropertiesSchema.extend({ id: identifier, key: identifier.nullable() }).strip();
|
|
32
|
-
var managedBadgeSchema = badgeSchema.extend({
|
|
33
|
-
archivedAt: z.number().int().nonnegative().nullable()
|
|
34
|
-
});
|
|
35
|
-
var createBadgeSchema = badgeDeclarationSchema.extend({ actionId: identifier }).strict();
|
|
36
|
-
var badgeArtifactSchema = z.union([
|
|
37
|
-
badgeDeclarationSchema,
|
|
38
|
-
z.object({ code: z.string().min(1).max(2e6) }).strict()
|
|
39
|
-
]);
|
|
40
|
-
var memberBadgeSchema = z.object({
|
|
41
|
-
badge: badgeSchema,
|
|
42
|
-
awardedAt: z.number().int().nonnegative()
|
|
43
|
-
});
|
|
44
|
-
var memberBadgesSchema = z.object({
|
|
45
|
-
items: z.array(memberBadgeSchema)
|
|
46
|
-
});
|
|
47
|
-
var badgeMutationSchema = z.object({ actionId: identifier, reason: z.string().trim().min(1).max(1e3) }).strict();
|
|
48
|
-
var badgeMutationResultSchema = z.object({
|
|
49
|
-
badge: identifier,
|
|
50
|
-
member: identifier,
|
|
51
|
-
awarded: z.boolean(),
|
|
52
|
-
changed: z.boolean()
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
// src/engagement.ts
|
|
56
|
-
import * as z2 from "zod";
|
|
57
|
-
var amount = z2.number().int().safe().nonnegative();
|
|
58
|
-
var engagementBudgetSchema = z2.strictObject({
|
|
59
|
-
scope: z2.enum(["member", "project"]),
|
|
60
|
-
period: calendarPeriodSchema,
|
|
61
|
-
limit: amount
|
|
62
|
-
});
|
|
63
|
-
var engagementDefinitionSchema = z2.strictObject({
|
|
64
|
-
key: identifier,
|
|
65
|
-
qualifiedBy: identifier,
|
|
66
|
-
balance: identifier,
|
|
67
|
-
metrics: z2.array(contentMetricSchema).min(1).max(10).refine(
|
|
68
|
-
(metrics) => new Set(metrics).size === metrics.length,
|
|
69
|
-
"Metrics must be unique"
|
|
70
|
-
),
|
|
71
|
-
baseline: z2.literal("historical"),
|
|
72
|
-
maxAgeMs: z2.number().int().positive().max(864e5).default(36e5),
|
|
73
|
-
budgets: z2.array(engagementBudgetSchema).max(8).default([]).refine(
|
|
74
|
-
(budgets) => new Set(budgets.map((b) => b.scope + ":" + b.period)).size === budgets.length,
|
|
75
|
-
"Give each scope and period one budget"
|
|
76
|
-
)
|
|
77
|
-
});
|
|
78
|
-
var engagementScoreInputSchema = z2.strictObject({
|
|
79
|
-
metrics: contentMetricsSchema,
|
|
80
|
-
baseline: contentMetricsSchema
|
|
81
|
-
});
|
|
82
|
-
var engagementScoreSchema = z2.strictObject({
|
|
83
|
-
target: amount,
|
|
84
|
-
baseline: amount
|
|
85
|
-
});
|
|
86
|
-
var engagementPublishSchema = z2.strictObject({
|
|
87
|
-
actionId: identifier,
|
|
88
|
-
code: z2.string().min(1).max(1e6)
|
|
89
|
-
});
|
|
90
|
-
var engagementRuleSchema = z2.strictObject({
|
|
91
|
-
version: identifier,
|
|
92
|
-
definition: engagementDefinitionSchema,
|
|
93
|
-
publishedAt: amount
|
|
94
|
-
});
|
|
95
|
-
var engagementPageQuerySchema = z2.strictObject({
|
|
96
|
-
rule: identifier,
|
|
97
|
-
content: z2.string().min(1).max(256),
|
|
98
|
-
member: identifier.optional(),
|
|
99
|
-
cursor: pageCursorSchema.optional()
|
|
100
|
-
});
|
|
101
|
-
var engagementSettlementSchema = z2.strictObject({
|
|
102
|
-
id: identifier,
|
|
103
|
-
day: z2.string(),
|
|
104
|
-
observation: identifier,
|
|
105
|
-
qualification: identifier,
|
|
106
|
-
earned: amount,
|
|
107
|
-
growth: amount,
|
|
108
|
-
paid: amount,
|
|
109
|
-
excluded: amount,
|
|
110
|
-
entry: identifier.nullable(),
|
|
111
|
-
createdAt: amount
|
|
112
|
-
});
|
|
113
|
-
var engagementPageSchema = z2.strictObject({
|
|
114
|
-
rule: engagementRuleSchema,
|
|
115
|
-
account: z2.strictObject({
|
|
116
|
-
member: identifier,
|
|
117
|
-
earned: amount,
|
|
118
|
-
accounted: amount,
|
|
119
|
-
paid: amount,
|
|
120
|
-
excluded: amount,
|
|
121
|
-
pending: amount,
|
|
122
|
-
counters: contentMetricsSchema,
|
|
123
|
-
baseline: contentMetricsSchema,
|
|
124
|
-
observation: identifier.nullable(),
|
|
125
|
-
nextSettlementAt: amount.nullable(),
|
|
126
|
-
reason: z2.string().nullable()
|
|
127
|
-
}).nullable(),
|
|
128
|
-
items: z2.array(engagementSettlementSchema),
|
|
129
|
-
nextCursor: pageCursorSchema.nullable()
|
|
130
|
-
});
|
|
131
|
-
var engagementChangePreviewInputSchema = z2.strictObject({
|
|
132
|
-
code: z2.string().min(1).max(1e6)
|
|
133
|
-
});
|
|
134
|
-
var engagementChangeSchema = engagementPublishSchema.extend({
|
|
135
|
-
expectedVersion: identifier,
|
|
136
|
-
previewHash: identifier
|
|
137
|
-
});
|
|
138
|
-
var total = z2.string().regex(/^(0|[1-9][0-9]*)$/);
|
|
139
|
-
var engagementChangePreviewSchema = z2.strictObject({
|
|
140
|
-
rule: identifier,
|
|
141
|
-
fromVersion: identifier,
|
|
142
|
-
toVersion: identifier,
|
|
143
|
-
previewHash: identifier,
|
|
144
|
-
definition: engagementDefinitionSchema,
|
|
145
|
-
boundary: z2.literal("available-eligible-observation"),
|
|
146
|
-
settlement: z2.literal("deferred"),
|
|
147
|
-
summary: z2.strictObject({
|
|
148
|
-
knownAdmissions: amount,
|
|
149
|
-
accounts: amount,
|
|
150
|
-
uninitialized: amount,
|
|
151
|
-
pendingTransitions: amount,
|
|
152
|
-
earned: total,
|
|
153
|
-
paid: total,
|
|
154
|
-
excluded: total,
|
|
155
|
-
pending: total
|
|
156
|
-
})
|
|
157
|
-
});
|
|
158
|
-
var engagementVersionSchema = engagementRuleSchema.extend({
|
|
159
|
-
previousVersion: identifier.nullable()
|
|
160
|
-
});
|
|
161
|
-
var engagementRuleVersionPageSchema = z2.object({
|
|
162
|
-
items: z2.array(
|
|
163
|
-
z2.object({
|
|
164
|
-
version: identifier,
|
|
165
|
-
definition: z2.object({
|
|
166
|
-
...engagementDefinitionSchema.shape,
|
|
167
|
-
budgets: z2.array(z2.object(engagementBudgetSchema.shape)).max(8).default([])
|
|
168
|
-
}),
|
|
169
|
-
publishedAt: amount,
|
|
170
|
-
previousVersion: identifier.nullable()
|
|
171
|
-
})
|
|
172
|
-
),
|
|
173
|
-
nextCursor: pageCursorSchema.nullable()
|
|
174
|
-
});
|
|
175
|
-
var engagementVersionPageSchema = z2.strictObject({
|
|
176
|
-
items: z2.array(engagementVersionSchema),
|
|
177
|
-
next: amount.nullable()
|
|
178
|
-
});
|
|
179
|
-
var engagementVersionQuerySchema = z2.strictObject({
|
|
180
|
-
rule: identifier,
|
|
181
|
-
before: z2.coerce.number().int().positive().safe().optional()
|
|
182
|
-
});
|
|
183
|
-
var engagementBoundaryPageSchema = z2.strictObject({
|
|
184
|
-
current: engagementRuleSchema.nullable(),
|
|
185
|
-
requested: engagementRuleSchema,
|
|
186
|
-
items: z2.array(
|
|
187
|
-
z2.strictObject({
|
|
188
|
-
from: identifier,
|
|
189
|
-
to: identifier,
|
|
190
|
-
baseline: contentMetricsSchema,
|
|
191
|
-
observedAt: amount,
|
|
192
|
-
settlement: engagementSettlementSchema
|
|
193
|
-
})
|
|
194
|
-
),
|
|
195
|
-
nextCursor: pageCursorSchema.nullable()
|
|
196
|
-
});
|
|
197
|
-
var engagementArtifactSchema = engagementPublishSchema.omit({
|
|
198
|
-
actionId: true
|
|
199
|
-
});
|
|
200
|
-
var deploymentEntry = engagementArtifactSchema.extend({
|
|
201
|
-
rule: engagementRuleSchema
|
|
202
|
-
});
|
|
203
|
-
var engagementDeploymentEntrySchema = z2.discriminatedUnion("kind", [
|
|
204
|
-
deploymentEntry.extend({ kind: z2.literal("create") }),
|
|
205
|
-
deploymentEntry.extend({ kind: z2.literal("unchanged") }),
|
|
206
|
-
deploymentEntry.extend({
|
|
207
|
-
kind: z2.literal("change"),
|
|
208
|
-
change: engagementChangePreviewSchema
|
|
209
|
-
})
|
|
210
|
-
]);
|
|
211
|
-
|
|
212
|
-
// src/leaderboards.ts
|
|
213
|
-
import * as z3 from "zod";
|
|
214
|
-
var integer = z3.number().int().safe();
|
|
215
|
-
var timestamp = integer.nonnegative().max(864e13);
|
|
216
|
-
var leaderboardWindowSchema = z3.discriminatedUnion("kind", [
|
|
217
|
-
z3.object({ kind: z3.literal("all-time") }).strict(),
|
|
218
|
-
z3.object({ kind: z3.literal("fixed"), start: timestamp, end: timestamp }).strict().refine((w) => w.end > w.start, "Window end must follow its start"),
|
|
219
|
-
z3.object({ kind: z3.literal("rolling"), days: integer.min(1).max(3660) }).strict(),
|
|
220
|
-
// Not strict: boards published while a calendar window named its own `timeZone` keep reading,
|
|
221
|
-
// and the field drops on parse. The authoring schema refuses it.
|
|
222
|
-
z3.object({
|
|
223
|
-
kind: z3.literal("calendar"),
|
|
224
|
-
/** The current day, week (ISO, starting on Monday) or month of the project calendar. */
|
|
225
|
-
period: calendarPeriodSchema.exclude(["lifetime"])
|
|
226
|
-
})
|
|
227
|
-
]);
|
|
228
|
-
var periodScore = {
|
|
229
|
-
window: leaderboardWindowSchema.default({ kind: "all-time" }),
|
|
230
|
-
quests: z3.array(identifier).min(1).max(100).optional()
|
|
231
|
-
};
|
|
232
|
-
var scoreSchema = z3.discriminatedUnion("kind", [
|
|
233
|
-
z3.object({ kind: z3.literal("balance") }).strict(),
|
|
234
|
-
z3.object({ kind: z3.literal("earned"), ...periodScore }).strict(),
|
|
235
|
-
z3.object({
|
|
236
|
-
kind: z3.literal("net"),
|
|
237
|
-
window: leaderboardWindowSchema.default({ kind: "all-time" })
|
|
238
|
-
}).strict()
|
|
239
|
-
]).default({ kind: "balance" });
|
|
240
|
-
var leaderboardPrizeRewardSchema = z3.union([
|
|
241
|
-
pointsRewardSchema,
|
|
242
|
-
tierRewardSchema
|
|
243
|
-
]);
|
|
244
|
-
var leaderboardPrizeSchema = z3.object({
|
|
245
|
-
ranks: z3.tuple([integer.positive(), integer.positive()]).refine(([first, last]) => last >= first, {
|
|
246
|
-
message: "Prize rank range must end at or after it starts"
|
|
247
|
-
}),
|
|
248
|
-
rewards: z3.array(leaderboardPrizeRewardSchema).min(1).max(20)
|
|
249
|
-
}).strict();
|
|
250
|
-
var baseUnitsSchema = z3.string().regex(
|
|
251
|
-
/^(0|[1-9]\d{0,77})$/,
|
|
252
|
-
'Use a whole number of base units, such as "1000000"'
|
|
253
|
-
);
|
|
254
|
-
var leaderboardPoolUnitSchema = z3.union([
|
|
255
|
-
z3.literal("points"),
|
|
256
|
-
z3.object({
|
|
257
|
-
code: z3.string().trim().min(1).max(32),
|
|
258
|
-
decimals: integer.min(0).max(36)
|
|
259
|
-
}).strict()
|
|
260
|
-
]);
|
|
261
|
-
var poolShape = {
|
|
262
|
-
/** The whole pool in base units. */
|
|
263
|
-
amount: baseUnitsSchema.refine((amount3) => amount3 !== "0", {
|
|
264
|
-
message: "A pool must hold a positive amount"
|
|
265
|
-
}),
|
|
266
|
-
unit: leaderboardPoolUnitSchema,
|
|
267
|
-
/** The point ledger a points pool pays into. Only points pools take one, and they require it. */
|
|
268
|
-
ledger: identifier.optional(),
|
|
269
|
-
/** Members scoring at or below this get no share. Members scoring 0 or less never do. */
|
|
270
|
-
minScore: integer.optional()
|
|
271
|
-
};
|
|
272
|
-
var refinePool = (pool, context) => {
|
|
273
|
-
if (pool.unit === "points") {
|
|
274
|
-
if (!pool.ledger) {
|
|
275
|
-
context.addIssue({
|
|
276
|
-
code: "custom",
|
|
277
|
-
message: "A points pool names the point ledger it pays into",
|
|
278
|
-
path: ["ledger"]
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
if (/^\d+$/.test(pool.amount) && BigInt(pool.amount) > maxPointsAmount) {
|
|
282
|
-
context.addIssue({
|
|
283
|
-
code: "custom",
|
|
284
|
-
message: `A points pool holds at most ${maxPointsAmount} points`,
|
|
285
|
-
path: ["amount"]
|
|
286
|
-
});
|
|
287
|
-
}
|
|
288
|
-
} else if (pool.ledger !== void 0) {
|
|
289
|
-
context.addIssue({
|
|
290
|
-
code: "custom",
|
|
291
|
-
message: "Only a points pool pays into a point ledger",
|
|
292
|
-
path: ["ledger"]
|
|
293
|
-
});
|
|
294
|
-
}
|
|
295
|
-
};
|
|
296
|
-
var leaderboardPoolSchema = z3.object(poolShape).strict().superRefine(refinePool);
|
|
297
|
-
var leaderboardSettlementPolicySchema = z3.object({
|
|
298
|
-
at: z3.literal("window-end"),
|
|
299
|
-
ties: z3.enum(["shared", "earliest"]),
|
|
300
|
-
/** Rank prizes. A board with a pool may list none. */
|
|
301
|
-
prizes: z3.array(leaderboardPrizeSchema).max(50),
|
|
302
|
-
pool: leaderboardPoolSchema.optional()
|
|
303
|
-
}).strict().superRefine((policy, context) => {
|
|
304
|
-
if (!policy.prizes.length && !policy.pool) {
|
|
305
|
-
context.addIssue({
|
|
306
|
-
code: "custom",
|
|
307
|
-
message: "A settlement awards rank prizes, a pool, or both",
|
|
308
|
-
path: ["prizes"]
|
|
309
|
-
});
|
|
310
|
-
}
|
|
311
|
-
for (const [index, prize] of policy.prizes.entries()) {
|
|
312
|
-
const keys = prize.rewards.map(rewardKey);
|
|
313
|
-
if (new Set(keys).size !== keys.length) {
|
|
314
|
-
context.addIssue({
|
|
315
|
-
code: "custom",
|
|
316
|
-
message: "A prize may grant each point ledger or tiered reward only once",
|
|
317
|
-
path: ["prizes", index, "rewards"]
|
|
318
|
-
});
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
for (let index = 1; index < policy.prizes.length; index++) {
|
|
322
|
-
const previous = policy.prizes[index - 1];
|
|
323
|
-
const current = policy.prizes[index];
|
|
324
|
-
if (current.ranks[0] <= previous.ranks[1]) {
|
|
325
|
-
context.addIssue({
|
|
326
|
-
code: "custom",
|
|
327
|
-
message: "Prize rank ranges must be ordered and must not overlap",
|
|
328
|
-
path: ["prizes", index, "ranks"]
|
|
329
|
-
});
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
});
|
|
333
|
-
var leaderboardDefinitionObject = z3.object({
|
|
334
|
-
id: identifier,
|
|
335
|
-
key: identifier.optional(),
|
|
336
|
-
title: z3.string().trim().min(1).max(120),
|
|
337
|
-
balance: identifier,
|
|
338
|
-
score: scoreSchema,
|
|
339
|
-
access: z3.enum(["participants", "public"]).default("participants"),
|
|
340
|
-
group: identifier.optional(),
|
|
341
|
-
/**
|
|
342
|
-
* List the project's eligible members who have no qualifying points, with a score of 0, ranked
|
|
343
|
-
* after every member who scored and ordered by member ID. Omitted or false lists only members
|
|
344
|
-
* with a qualifying entry. Settlements never include them.
|
|
345
|
-
*/
|
|
346
|
-
includeUnscored: z3.boolean().optional(),
|
|
347
|
-
settle: leaderboardSettlementPolicySchema.optional()
|
|
348
|
-
}).strict();
|
|
349
|
-
var validateSettlementWindow = (definition, context) => {
|
|
350
|
-
if (definition.settle && (definition.score.kind === "balance" || !["fixed", "calendar"].includes(definition.score.window.kind))) {
|
|
351
|
-
context.addIssue({
|
|
352
|
-
code: "custom",
|
|
353
|
-
message: "Leaderboard prizes require an earned or net score with a fixed or calendar window",
|
|
354
|
-
path: ["settle"]
|
|
355
|
-
});
|
|
356
|
-
}
|
|
357
|
-
};
|
|
358
|
-
var leaderboardDefinitionSchema = leaderboardDefinitionObject.superRefine(validateSettlementWindow);
|
|
359
|
-
var leaderboardDefinitionResponseSchema = responseShape(
|
|
360
|
-
leaderboardDefinitionSchema
|
|
361
|
-
);
|
|
362
|
-
var leaderboardAuthoringSchema = leaderboardDefinitionObject.omit({ id: true }).extend({
|
|
363
|
-
...authoringIdentityShape,
|
|
364
|
-
score: z3.preprocess(refuseWindowTimeZone, scoreSchema),
|
|
365
|
-
group: identifier.optional()
|
|
366
|
-
}).strict().superRefine(validateSettlementWindow);
|
|
367
|
-
var leaderboardArtifactSchema = z3.union([
|
|
368
|
-
leaderboardAuthoringSchema,
|
|
369
|
-
z3.object({ code: z3.string().min(1).max(2e6) }).strict()
|
|
370
|
-
]);
|
|
371
|
-
var publishedLeaderboardSchema = z3.object({
|
|
372
|
-
archivedAt: z3.number().int().nonnegative().nullable().optional(),
|
|
373
|
-
version: identifier,
|
|
374
|
-
definition: leaderboardDefinitionResponseSchema,
|
|
375
|
-
publishedAt: timestamp,
|
|
376
|
-
actor: z3.string().nullable()
|
|
377
|
-
});
|
|
378
|
-
var leaderboardQuerySchema = z3.object({
|
|
379
|
-
limit: z3.coerce.number().int().min(1).max(100).default(25),
|
|
380
|
-
cursor: z3.string().max(4096).optional()
|
|
381
|
-
}).strict();
|
|
382
|
-
var leaderboardRowSchema = z3.object({
|
|
383
|
-
/** The row's stable key: a pseudonym per board and member. */
|
|
384
|
-
participant: identifier,
|
|
385
|
-
member: identifier.optional(),
|
|
386
|
-
/** The profile's name where the viewer can see it, otherwise the pseudonym's. */
|
|
387
|
-
name: z3.string(),
|
|
388
|
-
score: integer,
|
|
389
|
-
rank: integer.positive(),
|
|
390
|
-
/** The member's profile, where visible to this viewer and not hidden by the member. */
|
|
391
|
-
profile: profileSummarySchema.nullable()
|
|
392
|
-
});
|
|
393
|
-
var leaderboardPageSchema = z3.object({
|
|
394
|
-
leaderboard: identifier,
|
|
395
|
-
title: z3.string(),
|
|
396
|
-
version: identifier,
|
|
397
|
-
calculation: z3.enum(["balance", "earned", "net"]),
|
|
398
|
-
period: z3.object({ start: timestamp.nullable(), end: timestamp.nullable() }),
|
|
399
|
-
calculatedAt: timestamp,
|
|
400
|
-
lastEntryAt: timestamp.nullable(),
|
|
401
|
-
total: integer.nonnegative(),
|
|
402
|
-
items: z3.array(leaderboardRowSchema),
|
|
403
|
-
me: leaderboardRowSchema.nullable(),
|
|
404
|
-
nearby: z3.array(leaderboardRowSchema),
|
|
405
|
-
nextCursor: z3.string().nullable()
|
|
406
|
-
});
|
|
407
|
-
var leaderboardPlacementSchema = z3.object({
|
|
408
|
-
leaderboard: identifier,
|
|
409
|
-
key: identifier.optional(),
|
|
410
|
-
title: z3.string(),
|
|
411
|
-
profile: identifier,
|
|
412
|
-
rank: integer.positive().nullable(),
|
|
413
|
-
score: integer.nullable(),
|
|
414
|
-
/** Ranked participants on the board. */
|
|
415
|
-
total: integer.nonnegative()
|
|
416
|
-
});
|
|
417
|
-
var leaderboardHistoryQuerySchema = z3.strictObject({
|
|
418
|
-
board: identifier,
|
|
419
|
-
cursor: pageCursorSchema.optional()
|
|
420
|
-
});
|
|
421
|
-
var leaderboardHistoryPageSchema = z3.object({
|
|
422
|
-
leaderboard: identifier,
|
|
423
|
-
period: z3.object({ start: timestamp.nullable(), end: timestamp.nullable() }),
|
|
424
|
-
items: z3.array(pointEntrySchema),
|
|
425
|
-
nextCursor: pageCursorSchema.nullable()
|
|
426
|
-
});
|
|
427
|
-
var leaderboardPreviewSchema = z3.object({
|
|
428
|
-
published: publishedLeaderboardSchema,
|
|
429
|
-
before: leaderboardPageSchema.nullable(),
|
|
430
|
-
after: leaderboardPageSchema
|
|
431
|
-
});
|
|
432
|
-
var mutationBase = {
|
|
433
|
-
actionId: identifier,
|
|
434
|
-
member: identifier,
|
|
435
|
-
balance: identifier,
|
|
436
|
-
reason: z3.string().trim().min(1).max(1e3)
|
|
437
|
-
};
|
|
438
|
-
var datedMutation = { ...mutationBase, effectiveAt: timestamp.optional() };
|
|
439
|
-
var pointsMutationSchema = z3.discriminatedUnion("kind", [
|
|
440
|
-
z3.object({
|
|
441
|
-
...datedMutation,
|
|
442
|
-
kind: z3.literal("award"),
|
|
443
|
-
referralEligible: z3.boolean().optional(),
|
|
444
|
-
amount: integer.positive()
|
|
445
|
-
}).strict(),
|
|
446
|
-
z3.object({
|
|
447
|
-
...datedMutation,
|
|
448
|
-
kind: z3.literal("spend"),
|
|
449
|
-
amount: integer.positive()
|
|
450
|
-
}).strict(),
|
|
451
|
-
z3.object({
|
|
452
|
-
...datedMutation,
|
|
453
|
-
kind: z3.literal("adjust"),
|
|
454
|
-
amount: integer.refine((n) => n !== 0)
|
|
455
|
-
}).strict(),
|
|
456
|
-
z3.object({
|
|
457
|
-
...datedMutation,
|
|
458
|
-
kind: z3.literal("set"),
|
|
459
|
-
total: integer.nonnegative(),
|
|
460
|
-
expectedTotal: integer.nonnegative(),
|
|
461
|
-
classification: z3.enum(["earned", "spend"])
|
|
462
|
-
}).strict(),
|
|
463
|
-
z3.object({
|
|
464
|
-
...mutationBase,
|
|
465
|
-
kind: z3.literal("reverse"),
|
|
466
|
-
entry: identifier,
|
|
467
|
-
amount: integer.positive()
|
|
468
|
-
}).strict()
|
|
469
|
-
]);
|
|
470
|
-
var pointsEntrySchema = z3.object({
|
|
471
|
-
id: identifier,
|
|
472
|
-
completion: z3.string().nullable(),
|
|
473
|
-
member: identifier,
|
|
474
|
-
balance: identifier,
|
|
475
|
-
amount: integer,
|
|
476
|
-
kind: z3.enum(["award", "spend", "adjust", "reverse"]),
|
|
477
|
-
effectiveAt: timestamp,
|
|
478
|
-
receivedAt: timestamp,
|
|
479
|
-
quest: identifier.nullable(),
|
|
480
|
-
original: identifier.nullable(),
|
|
481
|
-
reason: z3.string(),
|
|
482
|
-
actor: z3.string().nullable(),
|
|
483
|
-
/**
|
|
484
|
-
* The member import whose opening balance this `adjust` is, or null. Imported entries emit no
|
|
485
|
-
* `points.awarded` and count on balance leaderboards only. Absent from Relay versions without
|
|
486
|
-
* imports.
|
|
487
|
-
*/
|
|
488
|
-
import: identifier.nullable().optional()
|
|
489
|
-
});
|
|
490
|
-
var managedPointHistoryPageSchema = z3.object({
|
|
491
|
-
items: z3.array(pointsEntrySchema),
|
|
492
|
-
nextCursor: pageCursorSchema.nullable(),
|
|
493
|
-
/** @deprecated Use `nextCursor`, passed back as `cursor`. Removed in 2.0.0. */
|
|
494
|
-
next: z3.number().nullable()
|
|
495
|
-
});
|
|
496
|
-
var pointsResultSchema = z3.object({
|
|
497
|
-
entry: pointsEntrySchema,
|
|
498
|
-
total: integer.nonnegative()
|
|
499
|
-
});
|
|
500
|
-
var pointsAccountSchema = z3.object({
|
|
501
|
-
member: identifier,
|
|
502
|
-
balance: identifier,
|
|
503
|
-
total: integer.nonnegative(),
|
|
504
|
-
held: integer.nonnegative()
|
|
505
|
-
});
|
|
506
|
-
var leaderboardExclusionSchema = z3.object({
|
|
507
|
-
actionId: identifier,
|
|
508
|
-
member: identifier,
|
|
509
|
-
excluded: z3.boolean(),
|
|
510
|
-
reason: z3.string().trim().min(1).max(1e3)
|
|
511
|
-
}).strict();
|
|
512
|
-
var leaderboardExclusionGroupSchema = z3.object({
|
|
513
|
-
leaderboard: identifier,
|
|
514
|
-
group: identifier,
|
|
515
|
-
generated: z3.boolean(),
|
|
516
|
-
boundAt: timestamp.nullable()
|
|
517
|
-
});
|
|
518
|
-
var leaderboardExclusionGroupBindingSchema = z3.object({
|
|
519
|
-
actionId: identifier,
|
|
520
|
-
group: identifier,
|
|
521
|
-
reason: z3.string().trim().min(1).max(1e3)
|
|
522
|
-
}).strict();
|
|
523
|
-
var leaderboardGroupSchema = z3.object({
|
|
524
|
-
actionId: identifier,
|
|
525
|
-
member: identifier,
|
|
526
|
-
included: z3.boolean(),
|
|
527
|
-
reason: z3.string().trim().min(1).max(1e3)
|
|
528
|
-
}).strict();
|
|
529
|
-
var leaderboardSettlementStatusSchema = z3.enum(["pending", "approved"]);
|
|
530
|
-
var leaderboardSettlementSummarySchema = z3.object({
|
|
531
|
-
id: identifier,
|
|
532
|
-
leaderboard: identifier,
|
|
533
|
-
version: identifier,
|
|
534
|
-
title: z3.string(),
|
|
535
|
-
period: z3.object({ start: timestamp, end: timestamp }),
|
|
536
|
-
ties: z3.enum(["shared", "earliest"]),
|
|
537
|
-
status: leaderboardSettlementStatusSchema,
|
|
538
|
-
total: integer.nonnegative(),
|
|
539
|
-
winners: integer.nonnegative(),
|
|
540
|
-
createdAt: timestamp,
|
|
541
|
-
approvedAt: timestamp.nullable(),
|
|
542
|
-
approvedBy: z3.string().nullable(),
|
|
543
|
-
approvalReason: z3.string().nullable()
|
|
544
|
-
});
|
|
545
|
-
var leaderboardSettlementRowSchema = z3.object({
|
|
546
|
-
member: identifier,
|
|
547
|
-
score: integer,
|
|
548
|
-
rank: integer.positive(),
|
|
549
|
-
position: integer.positive(),
|
|
550
|
-
scoredAt: timestamp,
|
|
551
|
-
prizes: z3.array(integer.nonnegative()),
|
|
552
|
-
completion: identifier.nullable(),
|
|
553
|
-
revokedAt: timestamp.nullable(),
|
|
554
|
-
/**
|
|
555
|
-
* The member's pool share in the pool's base units, frozen with the row: `"0"` for a member the
|
|
556
|
-
* pool leaves out. Absent when the settlement has no pool.
|
|
557
|
-
*/
|
|
558
|
-
share: baseUnitsSchema.optional()
|
|
559
|
-
});
|
|
560
|
-
var leaderboardSettlementPoolSchema = z3.object({
|
|
561
|
-
...poolShape,
|
|
562
|
-
allocated: baseUnitsSchema,
|
|
563
|
-
unallocated: baseUnitsSchema
|
|
564
|
-
});
|
|
565
|
-
var leaderboardSettlementUnmeasuredSchema = z3.object({
|
|
566
|
-
content: z3.string(),
|
|
567
|
-
member: identifier,
|
|
568
|
-
/** When the last good measurement was observed, if Relay has one. */
|
|
569
|
-
observedAt: timestamp.nullable()
|
|
570
|
-
});
|
|
571
|
-
var leaderboardSettlementSchema = leaderboardSettlementSummarySchema.extend({
|
|
572
|
-
prizes: z3.array(leaderboardPrizeSchema),
|
|
573
|
-
excluded: z3.array(identifier),
|
|
574
|
-
/**
|
|
575
|
-
* Content frozen at its last good measurement because its closing measurement never came; a
|
|
576
|
-
* reviewer can retry measurement. Relay sends it for every settlement, empty when nothing is
|
|
577
|
-
* missing.
|
|
578
|
-
*/
|
|
579
|
-
unmeasured: z3.array(leaderboardSettlementUnmeasuredSchema).optional(),
|
|
580
|
-
/** The settlement's pool prize, or null without one. Absent from Relay versions without pools. */
|
|
581
|
-
pool: leaderboardSettlementPoolSchema.nullable().optional(),
|
|
582
|
-
rows: z3.array(leaderboardSettlementRowSchema)
|
|
583
|
-
});
|
|
584
|
-
var leaderboardSettlementApprovalSchema = z3.object({
|
|
585
|
-
actionId: identifier,
|
|
586
|
-
reason: z3.string().trim().min(1).max(500)
|
|
587
|
-
}).strict();
|
|
588
|
-
|
|
589
|
-
// src/referrals.ts
|
|
590
|
-
import * as z4 from "zod";
|
|
591
|
-
var rewardSchema = z4.union([pointsRewardSchema, tierRewardSchema]);
|
|
592
|
-
var amount2 = z4.number().int().safe().nonnegative();
|
|
593
|
-
var reason = z4.string().trim().min(1).max(1e3);
|
|
594
|
-
var referralDefinitionSchema = z4.object({
|
|
595
|
-
id: identifier,
|
|
596
|
-
key: identifier.optional(),
|
|
597
|
-
title: z4.string().trim().min(1).max(120),
|
|
598
|
-
enabled: z4.boolean().default(true),
|
|
599
|
-
qualification: z4.discriminatedUnion("kind", [
|
|
600
|
-
z4.object({ kind: z4.literal("signup") }).strict(),
|
|
601
|
-
z4.object({ kind: z4.literal("quest"), quest: identifier }).strict(),
|
|
602
|
-
z4.object({ kind: z4.literal("external") }).strict()
|
|
603
|
-
]),
|
|
604
|
-
inviterGroup: identifier.optional(),
|
|
605
|
-
rewards: z4.object({
|
|
606
|
-
inviter: z4.array(rewardSchema).max(10).default([]),
|
|
607
|
-
invitee: z4.array(rewardSchema).max(10).default([])
|
|
608
|
-
}).strict().default({ inviter: [], invitee: [] }),
|
|
609
|
-
milestones: z4.array(
|
|
610
|
-
z4.object({
|
|
611
|
-
id: identifier,
|
|
612
|
-
count: amount2.min(1),
|
|
613
|
-
rewards: z4.array(rewardSchema).min(1).max(10)
|
|
614
|
-
}).strict()
|
|
615
|
-
).max(30).default([]),
|
|
616
|
-
bonuses: z4.array(
|
|
617
|
-
z4.object({
|
|
618
|
-
id: identifier,
|
|
619
|
-
balance: identifier,
|
|
620
|
-
basisPoints: amount2.min(1).max(1e4),
|
|
621
|
-
quests: z4.array(identifier).min(1).max(100).optional(),
|
|
622
|
-
external: z4.boolean().default(false),
|
|
623
|
-
durationDays: amount2.min(1).max(36500).optional(),
|
|
624
|
-
maxPoints: amount2.min(1).optional()
|
|
625
|
-
}).strict()
|
|
626
|
-
).max(20).default([])
|
|
627
|
-
}).strict().superRefine((value, ctx) => {
|
|
628
|
-
for (const entries of [value.milestones, value.bonuses]) {
|
|
629
|
-
if (new Set(entries.map((e) => e.id)).size !== entries.length) {
|
|
630
|
-
ctx.addIssue({ code: "custom", message: "Rule IDs must be unique" });
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
|
-
});
|
|
634
|
-
var referralAuthoringSchema = z4.object(referralDefinitionSchema.shape).omit({ id: true }).extend({
|
|
635
|
-
...authoringIdentityShape,
|
|
636
|
-
inviterGroup: identifier.optional()
|
|
637
|
-
}).strict().superRefine((value, ctx) => {
|
|
638
|
-
for (const entries of [value.milestones, value.bonuses]) {
|
|
639
|
-
if (new Set(entries.map((entry) => entry.id)).size !== entries.length) {
|
|
640
|
-
ctx.addIssue({ code: "custom", message: "Rule keys must be unique" });
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
});
|
|
644
|
-
var referralArtifactSchema = z4.union([
|
|
645
|
-
referralAuthoringSchema,
|
|
646
|
-
z4.object({ code: z4.string().min(1).max(2e6) }).strict()
|
|
647
|
-
]);
|
|
648
|
-
var publishedReferralSchema = z4.object({
|
|
649
|
-
archivedAt: z4.number().int().nonnegative().nullable().optional(),
|
|
650
|
-
version: identifier,
|
|
651
|
-
definition: referralDefinitionSchema,
|
|
652
|
-
publishedAt: amount2,
|
|
653
|
-
actor: z4.string().nullable()
|
|
654
|
-
});
|
|
655
|
-
var referralAcceptSchema = z4.object({ actionId: identifier, code: identifier }).strict();
|
|
656
|
-
var referralSuspensionSchema = z4.object({ actionId: identifier, suspended: z4.boolean(), reason }).strict();
|
|
657
|
-
var referralQualificationSchema = z4.object({ actionId: identifier, qualified: z4.boolean(), reason }).strict();
|
|
658
|
-
var referralRewardResolutionSchema = z4.object({ actionId: identifier, reason }).strict();
|
|
659
|
-
var referralControlSchema = z4.discriminatedUnion("kind", [
|
|
660
|
-
z4.object({
|
|
661
|
-
kind: z4.literal("suspend"),
|
|
662
|
-
actionId: identifier,
|
|
663
|
-
member: identifier,
|
|
664
|
-
suspended: z4.boolean(),
|
|
665
|
-
reason
|
|
666
|
-
}).strict(),
|
|
667
|
-
z4.object({
|
|
668
|
-
kind: z4.literal("qualify"),
|
|
669
|
-
actionId: identifier,
|
|
670
|
-
member: identifier,
|
|
671
|
-
program: identifier,
|
|
672
|
-
qualified: z4.boolean(),
|
|
673
|
-
reason
|
|
674
|
-
}).strict(),
|
|
675
|
-
z4.object({
|
|
676
|
-
kind: z4.literal("resolve-reward"),
|
|
677
|
-
actionId: identifier,
|
|
678
|
-
entitlement: identifier,
|
|
679
|
-
reason
|
|
680
|
-
}).strict()
|
|
681
|
-
]);
|
|
682
|
-
var referralRelationshipSchema = z4.object({
|
|
683
|
-
member: identifier,
|
|
684
|
-
inviter: identifier,
|
|
685
|
-
acceptedAt: amount2,
|
|
686
|
-
suspended: z4.boolean(),
|
|
687
|
-
/** The member import that recorded this referral, or null when the friend accepted an invitation. */
|
|
688
|
-
import: identifier.nullable().optional()
|
|
689
|
-
});
|
|
690
|
-
var referralAccountSchema = z4.object({
|
|
691
|
-
id: identifier,
|
|
692
|
-
program: identifier,
|
|
693
|
-
kind: z4.enum(["bonus", "fixed", "milestone"]),
|
|
694
|
-
balance: identifier,
|
|
695
|
-
earned: amount2,
|
|
696
|
-
settled: amount2,
|
|
697
|
-
outstanding: amount2
|
|
698
|
-
});
|
|
699
|
-
var referralSummarySchema = z4.object({
|
|
700
|
-
code: identifier,
|
|
701
|
-
attributed: amount2,
|
|
702
|
-
programs: z4.array(
|
|
703
|
-
z4.object({
|
|
704
|
-
definition: referralDefinitionSchema,
|
|
705
|
-
qualified: amount2,
|
|
706
|
-
milestones: z4.array(
|
|
707
|
-
z4.object({ id: identifier, count: amount2, reached: z4.boolean() })
|
|
708
|
-
)
|
|
709
|
-
})
|
|
710
|
-
),
|
|
711
|
-
accounts: z4.array(referralAccountSchema)
|
|
712
|
-
});
|
|
713
|
-
var referralHistorySchema = z4.object({
|
|
714
|
-
items: z4.array(
|
|
715
|
-
z4.object({
|
|
716
|
-
id: amount2,
|
|
717
|
-
program: identifier,
|
|
718
|
-
balance: identifier,
|
|
719
|
-
amount: z4.number().int().safe(),
|
|
720
|
-
at: amount2,
|
|
721
|
-
reason: z4.string()
|
|
722
|
-
})
|
|
723
|
-
),
|
|
724
|
-
nextCursor: pageCursorSchema.nullable()
|
|
725
|
-
});
|
|
726
|
-
var referralManagementSchema = z4.object({
|
|
727
|
-
relationships: z4.array(referralRelationshipSchema),
|
|
728
|
-
qualifications: z4.array(
|
|
729
|
-
z4.object({
|
|
730
|
-
member: identifier,
|
|
731
|
-
program: identifier,
|
|
732
|
-
qualified: z4.boolean(),
|
|
733
|
-
qualifiedAt: amount2,
|
|
734
|
-
/** The member import that recorded this qualification, which paid no reward, or null. */
|
|
735
|
-
import: identifier.nullable().optional()
|
|
736
|
-
})
|
|
737
|
-
),
|
|
738
|
-
accounts: z4.array(
|
|
739
|
-
referralAccountSchema.extend({ member: identifier, invitee: z4.string() })
|
|
740
|
-
),
|
|
741
|
-
reviews: z4.array(
|
|
742
|
-
z4.object({
|
|
743
|
-
entitlement: identifier,
|
|
744
|
-
member: identifier,
|
|
745
|
-
program: identifier,
|
|
746
|
-
reason: z4.string()
|
|
747
|
-
})
|
|
748
|
-
),
|
|
749
|
-
nextCursor: pageCursorSchema.nullable().default(null),
|
|
750
|
-
/** @deprecated Use `nextCursor`, passed back as `cursor`. Removed in 2.0.0. */
|
|
751
|
-
next: amount2.nullable()
|
|
752
|
-
});
|
|
753
|
-
|
|
754
|
-
// src/definition-error.ts
|
|
755
|
-
function issueText(issues) {
|
|
756
|
-
return issues.map(
|
|
757
|
-
(issue) => issue.path.length ? issue.path.map(String).join(".") + ": " + issue.message : issue.message
|
|
758
|
-
).join("; ");
|
|
759
|
-
}
|
|
760
|
-
function parseDefinition(kind, schema, input) {
|
|
761
|
-
const parsed = schema.safeParse(input);
|
|
762
|
-
if (parsed.success) {
|
|
763
|
-
return parsed.data;
|
|
764
|
-
}
|
|
765
|
-
const key = typeof input === "object" && input !== null && "key" in input && typeof input.key === "string" ? ` "${input.key}"` : "";
|
|
766
|
-
parsed.error.message = `${kind}${key} is invalid: ${issueText(parsed.error.issues)}`;
|
|
767
|
-
throw parsed.error;
|
|
768
|
-
}
|
|
769
|
-
|
|
770
|
-
// src/offers.ts
|
|
771
|
-
import * as z5 from "zod";
|
|
772
|
-
var quantity = z5.number().int().safe().nonnegative();
|
|
773
|
-
var offerPriceSchema = pointsRewardSchema.extend({
|
|
774
|
-
amount: z5.number().int().positive().max(maxPointsAmount)
|
|
775
|
-
});
|
|
776
|
-
var offerLimitSchema = z5.object({ perMember: z5.number().int().positive().max(1e4) }).strict();
|
|
777
|
-
var offerDefinitionSchema = z5.object({
|
|
778
|
-
id: identifier,
|
|
779
|
-
key: identifier.optional(),
|
|
780
|
-
title: z5.string().trim().min(1).max(120),
|
|
781
|
-
price: offerPriceSchema,
|
|
782
|
-
reward: tierRewardSchema,
|
|
783
|
-
stock: quantity.max(1e6),
|
|
784
|
-
limit: offerLimitSchema.default({ perMember: 1 }),
|
|
785
|
-
/**
|
|
786
|
-
* What a member must meet to redeem, the same prerequisites quests take: `completed`,
|
|
787
|
-
* `balanceAtLeast` and `inGroup`. Checked when the member redeems; absent, anyone can.
|
|
788
|
-
*/
|
|
789
|
-
requires: z5.array(prerequisiteSchema).max(30).optional(),
|
|
790
|
-
enabled: z5.boolean().default(true)
|
|
791
|
-
}).strict();
|
|
792
|
-
var offerAuthoringSchema = offerDefinitionSchema.omit({ id: true, title: true, enabled: true }).extend({
|
|
793
|
-
...authoringIdentityShape,
|
|
794
|
-
title: z5.string().trim().min(1).max(120).optional(),
|
|
795
|
-
// `defineOffer` returns `enabled: true`, and a deployment describes the module's default
|
|
796
|
-
// export and parses it again, so the output has to read back. Pause an offer in Console.
|
|
797
|
-
enabled: z5.literal(true).optional()
|
|
798
|
-
}).strict().transform(({ enabled: _, ...offer }) => ({
|
|
799
|
-
...offer,
|
|
800
|
-
title: offer.title ?? offer.reward.reward.title,
|
|
801
|
-
enabled: true
|
|
802
|
-
}));
|
|
803
|
-
var offerArtifactSchema = z5.union([
|
|
804
|
-
offerAuthoringSchema,
|
|
805
|
-
z5.object({ code: z5.string().min(1).max(2e6) }).strict()
|
|
806
|
-
]);
|
|
807
|
-
var offerAvailabilitySchema = responseShape(
|
|
808
|
-
z5.discriminatedUnion("kind", [
|
|
809
|
-
z5.object({ kind: z5.literal("available"), remaining: quantity }).strict(),
|
|
810
|
-
z5.object({ kind: z5.literal("out-of-stock") }).strict(),
|
|
811
|
-
z5.object({ kind: z5.literal("limit-reached") }).strict(),
|
|
812
|
-
z5.object({ kind: z5.literal("paused") }).strict()
|
|
813
|
-
])
|
|
814
|
-
);
|
|
815
|
-
var offerSchema = responseShape(
|
|
816
|
-
offerDefinitionSchema.extend({
|
|
817
|
-
revision: z5.number().int().positive(),
|
|
818
|
-
available: quantity,
|
|
819
|
-
redeemed: quantity,
|
|
820
|
-
availability: offerAvailabilitySchema,
|
|
821
|
-
/**
|
|
822
|
-
* When an operator archived the offer, or `null`. Only management reads carry it and list an
|
|
823
|
-
* archived offer; it refuses new redemptions with `offer-paused` until it is restored.
|
|
824
|
-
*/
|
|
825
|
-
archivedAt: z5.number().int().nonnegative().nullable().optional(),
|
|
826
|
-
/**
|
|
827
|
-
* The prerequisites the signed-in member has not met yet, so an app can show the offer locked
|
|
828
|
-
* and why. Empty when nothing is missing or the read has no member; redeeming while it is not
|
|
829
|
-
* empty fails with `prerequisites-incomplete`.
|
|
830
|
-
*/
|
|
831
|
-
missing: z5.array(missingPrerequisiteSchema).default([])
|
|
832
|
-
})
|
|
833
|
-
);
|
|
834
|
-
var redeemOfferSchema = z5.object({ actionId: identifier }).strict();
|
|
835
|
-
var redemptionBase = {
|
|
836
|
-
id: identifier,
|
|
837
|
-
offer: identifier,
|
|
838
|
-
member: identifier,
|
|
839
|
-
/**
|
|
840
|
-
* @deprecated Use `id` to refer to a redemption. A redemption is fulfilled in the request that
|
|
841
|
-
* makes it, so nothing is reserved beforehand; the ID refers to no other record. Removed in
|
|
842
|
-
* 2.0.0.
|
|
843
|
-
*/
|
|
844
|
-
reservation: identifier,
|
|
845
|
-
price: offerPriceSchema,
|
|
846
|
-
reward: tierRewardSchema,
|
|
847
|
-
entitlement: identifier,
|
|
848
|
-
revision: z5.number().int().positive(),
|
|
849
|
-
redeemedAt: z5.number().int().safe().nonnegative()
|
|
850
|
-
};
|
|
851
|
-
var redemptionSchema = responseShape(
|
|
852
|
-
z5.discriminatedUnion("status", [
|
|
853
|
-
z5.object({ ...redemptionBase, status: z5.literal("fulfilled") }).strict(),
|
|
854
|
-
z5.object({
|
|
855
|
-
...redemptionBase,
|
|
856
|
-
status: z5.literal("canceled"),
|
|
857
|
-
canceledAt: z5.number().int().safe().nonnegative(),
|
|
858
|
-
reason: z5.string().min(1).max(500)
|
|
859
|
-
}).strict()
|
|
860
|
-
])
|
|
861
|
-
);
|
|
862
|
-
var redemptionQuerySchema = z5.strictObject({
|
|
863
|
-
member: identifier.optional(),
|
|
864
|
-
cursor: pageCursorSchema.optional(),
|
|
865
|
-
limit: z5.coerce.number().int().min(1).max(100).optional()
|
|
866
|
-
});
|
|
867
|
-
var redemptionPageSchema = z5.object({
|
|
868
|
-
items: z5.array(redemptionSchema),
|
|
869
|
-
nextCursor: pageCursorSchema.nullable()
|
|
870
|
-
});
|
|
871
|
-
var offerControlSchema = z5.object({
|
|
872
|
-
actionId: identifier,
|
|
873
|
-
revision: z5.number().int().positive(),
|
|
874
|
-
enabled: z5.boolean(),
|
|
875
|
-
reason: z5.string().trim().min(1).max(500)
|
|
876
|
-
}).strict();
|
|
877
|
-
var redemptionCancellationSchema = z5.object({
|
|
878
|
-
actionId: identifier,
|
|
879
|
-
revision: z5.number().int().positive(),
|
|
880
|
-
reason: z5.string().trim().min(1).max(500)
|
|
881
|
-
}).strict();
|
|
882
|
-
function defineOffer(input) {
|
|
883
|
-
return resourceHandle(
|
|
884
|
-
"offer",
|
|
885
|
-
parseDefinition("Offer", offerAuthoringSchema, input)
|
|
886
|
-
);
|
|
887
|
-
}
|
|
888
|
-
|
|
889
|
-
export {
|
|
890
|
-
badgePropertiesSchema,
|
|
891
|
-
badgeDeclarationSchema,
|
|
892
|
-
badgeSchema,
|
|
893
|
-
managedBadgeSchema,
|
|
894
|
-
createBadgeSchema,
|
|
895
|
-
badgeArtifactSchema,
|
|
896
|
-
memberBadgeSchema,
|
|
897
|
-
memberBadgesSchema,
|
|
898
|
-
badgeMutationSchema,
|
|
899
|
-
badgeMutationResultSchema,
|
|
900
|
-
engagementBudgetSchema,
|
|
901
|
-
engagementDefinitionSchema,
|
|
902
|
-
engagementScoreInputSchema,
|
|
903
|
-
engagementScoreSchema,
|
|
904
|
-
engagementPublishSchema,
|
|
905
|
-
engagementRuleSchema,
|
|
906
|
-
engagementPageQuerySchema,
|
|
907
|
-
engagementSettlementSchema,
|
|
908
|
-
engagementPageSchema,
|
|
909
|
-
engagementChangePreviewInputSchema,
|
|
910
|
-
engagementChangeSchema,
|
|
911
|
-
engagementChangePreviewSchema,
|
|
912
|
-
engagementRuleVersionPageSchema,
|
|
913
|
-
engagementVersionPageSchema,
|
|
914
|
-
engagementVersionQuerySchema,
|
|
915
|
-
engagementBoundaryPageSchema,
|
|
916
|
-
engagementArtifactSchema,
|
|
917
|
-
engagementDeploymentEntrySchema,
|
|
918
|
-
leaderboardWindowSchema,
|
|
919
|
-
leaderboardPrizeRewardSchema,
|
|
920
|
-
leaderboardPrizeSchema,
|
|
921
|
-
baseUnitsSchema,
|
|
922
|
-
leaderboardPoolUnitSchema,
|
|
923
|
-
leaderboardPoolSchema,
|
|
924
|
-
leaderboardSettlementPolicySchema,
|
|
925
|
-
leaderboardDefinitionSchema,
|
|
926
|
-
leaderboardDefinitionResponseSchema,
|
|
927
|
-
leaderboardAuthoringSchema,
|
|
928
|
-
leaderboardArtifactSchema,
|
|
929
|
-
publishedLeaderboardSchema,
|
|
930
|
-
leaderboardQuerySchema,
|
|
931
|
-
leaderboardRowSchema,
|
|
932
|
-
leaderboardPageSchema,
|
|
933
|
-
leaderboardPlacementSchema,
|
|
934
|
-
leaderboardHistoryQuerySchema,
|
|
935
|
-
leaderboardHistoryPageSchema,
|
|
936
|
-
leaderboardPreviewSchema,
|
|
937
|
-
pointsMutationSchema,
|
|
938
|
-
pointsEntrySchema,
|
|
939
|
-
managedPointHistoryPageSchema,
|
|
940
|
-
pointsResultSchema,
|
|
941
|
-
pointsAccountSchema,
|
|
942
|
-
leaderboardExclusionSchema,
|
|
943
|
-
leaderboardExclusionGroupSchema,
|
|
944
|
-
leaderboardExclusionGroupBindingSchema,
|
|
945
|
-
leaderboardGroupSchema,
|
|
946
|
-
leaderboardSettlementStatusSchema,
|
|
947
|
-
leaderboardSettlementSummarySchema,
|
|
948
|
-
leaderboardSettlementRowSchema,
|
|
949
|
-
leaderboardSettlementPoolSchema,
|
|
950
|
-
leaderboardSettlementUnmeasuredSchema,
|
|
951
|
-
leaderboardSettlementSchema,
|
|
952
|
-
leaderboardSettlementApprovalSchema,
|
|
953
|
-
referralDefinitionSchema,
|
|
954
|
-
referralAuthoringSchema,
|
|
955
|
-
referralArtifactSchema,
|
|
956
|
-
publishedReferralSchema,
|
|
957
|
-
referralAcceptSchema,
|
|
958
|
-
referralSuspensionSchema,
|
|
959
|
-
referralQualificationSchema,
|
|
960
|
-
referralRewardResolutionSchema,
|
|
961
|
-
referralControlSchema,
|
|
962
|
-
referralRelationshipSchema,
|
|
963
|
-
referralAccountSchema,
|
|
964
|
-
referralSummarySchema,
|
|
965
|
-
referralHistorySchema,
|
|
966
|
-
referralManagementSchema,
|
|
967
|
-
parseDefinition,
|
|
968
|
-
offerPriceSchema,
|
|
969
|
-
offerLimitSchema,
|
|
970
|
-
offerDefinitionSchema,
|
|
971
|
-
offerAuthoringSchema,
|
|
972
|
-
offerArtifactSchema,
|
|
973
|
-
offerAvailabilitySchema,
|
|
974
|
-
offerSchema,
|
|
975
|
-
redeemOfferSchema,
|
|
976
|
-
redemptionSchema,
|
|
977
|
-
redemptionQuerySchema,
|
|
978
|
-
redemptionPageSchema,
|
|
979
|
-
offerControlSchema,
|
|
980
|
-
redemptionCancellationSchema,
|
|
981
|
-
defineOffer
|
|
982
|
-
};
|