@domino-sdk/relay 0.2.0 → 0.4.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/build.mjs +3 -1
- package/dist/authoring.d.ts +7 -2
- package/dist/authoring.js +10 -2
- package/dist/browser.d.ts +330 -2
- package/dist/browser.js +4 -2
- package/dist/chunk-3IQ4KUKF.js +613 -0
- package/dist/{chunk-NC3UAP6T.js → chunk-KQVL6MOH.js} +147 -74
- package/dist/chunk-QWRSUSNB.js +37 -0
- package/dist/chunk-TXL43HL3.js +335 -0
- package/dist/index.d.ts +1277 -49
- package/dist/index.js +87 -7
- package/dist/portal-proxy.d.ts +17 -2
- package/dist/portal-proxy.js +77 -2
- package/dist/schema.d.ts +20 -0
- package/dist/schema.js +1 -1
- package/dist/settings-B7vsT8nd.d.ts +1383 -0
- package/package.json +1 -1
- package/dist/chunk-C2KOMNLG.js +0 -570
- package/dist/settings-BEbCiuhH.d.ts +0 -195
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
import {
|
|
2
|
+
identifier,
|
|
3
|
+
rewardSchema
|
|
4
|
+
} from "./chunk-3IQ4KUKF.js";
|
|
5
|
+
|
|
6
|
+
// src/referrals.ts
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
var amount = z.number().int().safe().nonnegative();
|
|
9
|
+
var reason = z.string().trim().min(1).max(1e3);
|
|
10
|
+
var referralDefinitionSchema = z.object({
|
|
11
|
+
id: identifier,
|
|
12
|
+
title: z.string().trim().min(1).max(120),
|
|
13
|
+
enabled: z.boolean().default(true),
|
|
14
|
+
qualification: z.discriminatedUnion("kind", [
|
|
15
|
+
z.object({ kind: z.literal("signup") }).strict(),
|
|
16
|
+
z.object({ kind: z.literal("quest"), quest: identifier }).strict(),
|
|
17
|
+
z.object({ kind: z.literal("external") }).strict()
|
|
18
|
+
]),
|
|
19
|
+
inviterGroup: identifier.optional(),
|
|
20
|
+
rewards: z.object({
|
|
21
|
+
inviter: z.array(rewardSchema).max(10).default([]),
|
|
22
|
+
invitee: z.array(rewardSchema).max(10).default([])
|
|
23
|
+
}).strict().default({ inviter: [], invitee: [] }),
|
|
24
|
+
milestones: z.array(
|
|
25
|
+
z.object({
|
|
26
|
+
id: identifier,
|
|
27
|
+
count: amount.min(1),
|
|
28
|
+
rewards: z.array(rewardSchema).min(1).max(10)
|
|
29
|
+
}).strict()
|
|
30
|
+
).max(30).default([]),
|
|
31
|
+
bonuses: z.array(
|
|
32
|
+
z.object({
|
|
33
|
+
id: identifier,
|
|
34
|
+
balance: identifier,
|
|
35
|
+
basisPoints: amount.min(1).max(1e4),
|
|
36
|
+
quests: z.array(identifier).min(1).max(100).optional(),
|
|
37
|
+
external: z.boolean().default(false),
|
|
38
|
+
durationDays: amount.min(1).max(36500).optional(),
|
|
39
|
+
maxPoints: amount.min(1).optional()
|
|
40
|
+
}).strict()
|
|
41
|
+
).max(20).default([])
|
|
42
|
+
}).strict().superRefine((value, ctx) => {
|
|
43
|
+
for (const entries of [value.milestones, value.bonuses])
|
|
44
|
+
if (new Set(entries.map((e) => e.id)).size !== entries.length)
|
|
45
|
+
ctx.addIssue({ code: "custom", message: "Rule IDs must be unique" });
|
|
46
|
+
});
|
|
47
|
+
function defineReferral(input) {
|
|
48
|
+
return referralDefinitionSchema.parse(input);
|
|
49
|
+
}
|
|
50
|
+
var referralArtifactSchema = z.union([
|
|
51
|
+
referralDefinitionSchema,
|
|
52
|
+
z.object({ code: z.string().min(1).max(2e6) }).strict()
|
|
53
|
+
]);
|
|
54
|
+
var publishedReferralSchema = z.object({
|
|
55
|
+
version: identifier,
|
|
56
|
+
definition: referralDefinitionSchema,
|
|
57
|
+
publishedAt: amount,
|
|
58
|
+
actor: z.string().nullable()
|
|
59
|
+
});
|
|
60
|
+
var referralAcceptSchema = z.object({ actionId: identifier, code: identifier }).strict();
|
|
61
|
+
var referralControlSchema = z.discriminatedUnion("kind", [
|
|
62
|
+
z.object({
|
|
63
|
+
kind: z.literal("suspend"),
|
|
64
|
+
actionId: identifier,
|
|
65
|
+
member: identifier,
|
|
66
|
+
suspended: z.boolean(),
|
|
67
|
+
reason
|
|
68
|
+
}).strict(),
|
|
69
|
+
z.object({
|
|
70
|
+
kind: z.literal("qualify"),
|
|
71
|
+
actionId: identifier,
|
|
72
|
+
member: identifier,
|
|
73
|
+
program: identifier,
|
|
74
|
+
qualified: z.boolean(),
|
|
75
|
+
reason
|
|
76
|
+
}).strict(),
|
|
77
|
+
z.object({
|
|
78
|
+
kind: z.literal("resolve-reward"),
|
|
79
|
+
actionId: identifier,
|
|
80
|
+
entitlement: identifier,
|
|
81
|
+
reason
|
|
82
|
+
}).strict()
|
|
83
|
+
]);
|
|
84
|
+
var referralRelationshipSchema = z.object({
|
|
85
|
+
member: identifier,
|
|
86
|
+
inviter: identifier,
|
|
87
|
+
acceptedAt: amount,
|
|
88
|
+
suspended: z.boolean()
|
|
89
|
+
});
|
|
90
|
+
var referralAccountSchema = z.object({
|
|
91
|
+
id: identifier,
|
|
92
|
+
program: identifier,
|
|
93
|
+
kind: z.enum(["bonus", "fixed", "milestone"]),
|
|
94
|
+
balance: identifier,
|
|
95
|
+
earned: amount,
|
|
96
|
+
settled: amount,
|
|
97
|
+
outstanding: amount
|
|
98
|
+
});
|
|
99
|
+
var referralSummarySchema = z.object({
|
|
100
|
+
code: identifier,
|
|
101
|
+
attributed: amount,
|
|
102
|
+
programs: z.array(
|
|
103
|
+
z.object({
|
|
104
|
+
definition: referralDefinitionSchema,
|
|
105
|
+
qualified: amount,
|
|
106
|
+
milestones: z.array(
|
|
107
|
+
z.object({ id: identifier, count: amount, reached: z.boolean() })
|
|
108
|
+
)
|
|
109
|
+
})
|
|
110
|
+
),
|
|
111
|
+
accounts: z.array(referralAccountSchema)
|
|
112
|
+
});
|
|
113
|
+
var referralHistorySchema = z.object({
|
|
114
|
+
items: z.array(
|
|
115
|
+
z.object({
|
|
116
|
+
id: amount,
|
|
117
|
+
program: identifier,
|
|
118
|
+
balance: identifier,
|
|
119
|
+
amount: z.number().int().safe(),
|
|
120
|
+
at: amount,
|
|
121
|
+
reason: z.string()
|
|
122
|
+
})
|
|
123
|
+
),
|
|
124
|
+
next: amount.nullable()
|
|
125
|
+
});
|
|
126
|
+
var referralManagementSchema = z.object({
|
|
127
|
+
relationships: z.array(referralRelationshipSchema),
|
|
128
|
+
qualifications: z.array(
|
|
129
|
+
z.object({
|
|
130
|
+
member: identifier,
|
|
131
|
+
program: identifier,
|
|
132
|
+
qualified: z.boolean(),
|
|
133
|
+
qualifiedAt: amount
|
|
134
|
+
})
|
|
135
|
+
),
|
|
136
|
+
accounts: z.array(
|
|
137
|
+
referralAccountSchema.extend({ member: identifier, invitee: z.string() })
|
|
138
|
+
),
|
|
139
|
+
reviews: z.array(
|
|
140
|
+
z.object({
|
|
141
|
+
entitlement: identifier,
|
|
142
|
+
member: identifier,
|
|
143
|
+
program: identifier,
|
|
144
|
+
reason: z.string()
|
|
145
|
+
})
|
|
146
|
+
),
|
|
147
|
+
next: amount.nullable()
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
// src/leaderboards.ts
|
|
151
|
+
import { z as z2 } from "zod";
|
|
152
|
+
var integer = z2.number().int().safe();
|
|
153
|
+
var timestamp = integer.nonnegative().max(864e13);
|
|
154
|
+
var leaderboardWindowSchema = z2.discriminatedUnion("kind", [
|
|
155
|
+
z2.object({ kind: z2.literal("all-time") }).strict(),
|
|
156
|
+
z2.object({ kind: z2.literal("fixed"), start: timestamp, end: timestamp }).strict().refine((w) => w.end > w.start, "Window end must follow its start"),
|
|
157
|
+
z2.object({ kind: z2.literal("rolling"), days: integer.min(1).max(3660) }).strict(),
|
|
158
|
+
z2.object({
|
|
159
|
+
kind: z2.literal("calendar"),
|
|
160
|
+
period: z2.enum(["day", "week", "month"]),
|
|
161
|
+
timeZone: z2.string().min(1).max(100).refine((zone) => {
|
|
162
|
+
try {
|
|
163
|
+
new Intl.DateTimeFormat("en", { timeZone: zone });
|
|
164
|
+
return true;
|
|
165
|
+
} catch {
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
}, "Use an IANA timezone")
|
|
169
|
+
}).strict()
|
|
170
|
+
]);
|
|
171
|
+
var periodScore = {
|
|
172
|
+
window: leaderboardWindowSchema.default({ kind: "all-time" }),
|
|
173
|
+
quests: z2.array(identifier).min(1).max(100).optional()
|
|
174
|
+
};
|
|
175
|
+
var leaderboardDefinitionSchema = z2.object({
|
|
176
|
+
id: identifier,
|
|
177
|
+
title: z2.string().trim().min(1).max(120),
|
|
178
|
+
balance: identifier,
|
|
179
|
+
score: z2.discriminatedUnion("kind", [
|
|
180
|
+
z2.object({ kind: z2.literal("balance") }).strict(),
|
|
181
|
+
z2.object({ kind: z2.literal("earned"), ...periodScore }).strict(),
|
|
182
|
+
z2.object({
|
|
183
|
+
kind: z2.literal("net"),
|
|
184
|
+
window: leaderboardWindowSchema.default({ kind: "all-time" })
|
|
185
|
+
}).strict()
|
|
186
|
+
]).default({ kind: "balance" }),
|
|
187
|
+
access: z2.enum(["participants", "public"]).default("participants"),
|
|
188
|
+
group: identifier.optional()
|
|
189
|
+
}).strict();
|
|
190
|
+
function defineLeaderboard(input) {
|
|
191
|
+
return leaderboardDefinitionSchema.parse(input);
|
|
192
|
+
}
|
|
193
|
+
var leaderboardArtifactSchema = z2.union([
|
|
194
|
+
leaderboardDefinitionSchema,
|
|
195
|
+
z2.object({ code: z2.string().min(1).max(2e6) }).strict()
|
|
196
|
+
]);
|
|
197
|
+
var publishedLeaderboardSchema = z2.object({
|
|
198
|
+
version: identifier,
|
|
199
|
+
definition: leaderboardDefinitionSchema,
|
|
200
|
+
publishedAt: timestamp,
|
|
201
|
+
actor: z2.string().nullable()
|
|
202
|
+
});
|
|
203
|
+
var leaderboardQuerySchema = z2.object({
|
|
204
|
+
limit: z2.coerce.number().int().min(1).max(100).default(25),
|
|
205
|
+
cursor: z2.string().max(4096).optional()
|
|
206
|
+
}).strict();
|
|
207
|
+
var leaderboardRowSchema = z2.object({
|
|
208
|
+
participant: identifier,
|
|
209
|
+
member: identifier.optional(),
|
|
210
|
+
name: z2.string(),
|
|
211
|
+
score: integer,
|
|
212
|
+
rank: integer.positive()
|
|
213
|
+
});
|
|
214
|
+
var leaderboardPageSchema = z2.object({
|
|
215
|
+
leaderboard: identifier,
|
|
216
|
+
title: z2.string(),
|
|
217
|
+
version: identifier,
|
|
218
|
+
calculation: z2.enum(["balance", "earned", "net"]),
|
|
219
|
+
period: z2.object({ start: timestamp.nullable(), end: timestamp.nullable() }),
|
|
220
|
+
calculatedAt: timestamp,
|
|
221
|
+
lastEntryAt: timestamp.nullable(),
|
|
222
|
+
total: integer.nonnegative(),
|
|
223
|
+
items: z2.array(leaderboardRowSchema),
|
|
224
|
+
me: leaderboardRowSchema.nullable(),
|
|
225
|
+
nearby: z2.array(leaderboardRowSchema),
|
|
226
|
+
nextCursor: z2.string().nullable()
|
|
227
|
+
});
|
|
228
|
+
var leaderboardPreviewSchema = z2.object({
|
|
229
|
+
published: publishedLeaderboardSchema,
|
|
230
|
+
before: leaderboardPageSchema.nullable(),
|
|
231
|
+
after: leaderboardPageSchema
|
|
232
|
+
});
|
|
233
|
+
var mutationBase = {
|
|
234
|
+
actionId: identifier,
|
|
235
|
+
member: identifier,
|
|
236
|
+
balance: identifier,
|
|
237
|
+
reason: z2.string().trim().min(1).max(1e3)
|
|
238
|
+
};
|
|
239
|
+
var datedMutation = { ...mutationBase, effectiveAt: timestamp.optional() };
|
|
240
|
+
var pointsMutationSchema = z2.discriminatedUnion("kind", [
|
|
241
|
+
z2.object({
|
|
242
|
+
...datedMutation,
|
|
243
|
+
kind: z2.literal("award"),
|
|
244
|
+
referralEligible: z2.boolean().optional(),
|
|
245
|
+
amount: integer.positive()
|
|
246
|
+
}).strict(),
|
|
247
|
+
z2.object({
|
|
248
|
+
...datedMutation,
|
|
249
|
+
kind: z2.literal("spend"),
|
|
250
|
+
amount: integer.positive()
|
|
251
|
+
}).strict(),
|
|
252
|
+
z2.object({
|
|
253
|
+
...datedMutation,
|
|
254
|
+
kind: z2.literal("adjust"),
|
|
255
|
+
amount: integer.refine((n) => n !== 0)
|
|
256
|
+
}).strict(),
|
|
257
|
+
z2.object({
|
|
258
|
+
...datedMutation,
|
|
259
|
+
kind: z2.literal("set"),
|
|
260
|
+
total: integer.nonnegative(),
|
|
261
|
+
expectedTotal: integer.nonnegative(),
|
|
262
|
+
classification: z2.enum(["earned", "spend"])
|
|
263
|
+
}).strict(),
|
|
264
|
+
z2.object({
|
|
265
|
+
...mutationBase,
|
|
266
|
+
kind: z2.literal("reverse"),
|
|
267
|
+
entry: identifier,
|
|
268
|
+
amount: integer.positive()
|
|
269
|
+
}).strict()
|
|
270
|
+
]);
|
|
271
|
+
var pointsEntrySchema = z2.object({
|
|
272
|
+
id: identifier,
|
|
273
|
+
completion: z2.string().nullable(),
|
|
274
|
+
member: identifier,
|
|
275
|
+
balance: identifier,
|
|
276
|
+
amount: integer,
|
|
277
|
+
kind: z2.enum(["award", "spend", "adjust", "reverse"]),
|
|
278
|
+
effectiveAt: timestamp,
|
|
279
|
+
receivedAt: timestamp,
|
|
280
|
+
quest: identifier.nullable(),
|
|
281
|
+
original: identifier.nullable(),
|
|
282
|
+
reason: z2.string(),
|
|
283
|
+
actor: z2.string().nullable()
|
|
284
|
+
});
|
|
285
|
+
var pointsResultSchema = z2.object({
|
|
286
|
+
entry: pointsEntrySchema,
|
|
287
|
+
total: integer.nonnegative()
|
|
288
|
+
});
|
|
289
|
+
var pointsAccountSchema = z2.object({
|
|
290
|
+
member: identifier,
|
|
291
|
+
balance: identifier,
|
|
292
|
+
total: integer.nonnegative(),
|
|
293
|
+
held: integer.nonnegative()
|
|
294
|
+
});
|
|
295
|
+
var leaderboardExclusionSchema = z2.object({
|
|
296
|
+
actionId: identifier,
|
|
297
|
+
member: identifier,
|
|
298
|
+
excluded: z2.boolean(),
|
|
299
|
+
reason: z2.string().trim().min(1).max(1e3)
|
|
300
|
+
}).strict();
|
|
301
|
+
var leaderboardGroupSchema = z2.object({
|
|
302
|
+
actionId: identifier,
|
|
303
|
+
member: identifier,
|
|
304
|
+
included: z2.boolean(),
|
|
305
|
+
reason: z2.string().trim().min(1).max(1e3)
|
|
306
|
+
}).strict();
|
|
307
|
+
|
|
308
|
+
export {
|
|
309
|
+
referralDefinitionSchema,
|
|
310
|
+
defineReferral,
|
|
311
|
+
referralArtifactSchema,
|
|
312
|
+
publishedReferralSchema,
|
|
313
|
+
referralAcceptSchema,
|
|
314
|
+
referralControlSchema,
|
|
315
|
+
referralRelationshipSchema,
|
|
316
|
+
referralAccountSchema,
|
|
317
|
+
referralSummarySchema,
|
|
318
|
+
referralHistorySchema,
|
|
319
|
+
referralManagementSchema,
|
|
320
|
+
leaderboardWindowSchema,
|
|
321
|
+
leaderboardDefinitionSchema,
|
|
322
|
+
defineLeaderboard,
|
|
323
|
+
leaderboardArtifactSchema,
|
|
324
|
+
publishedLeaderboardSchema,
|
|
325
|
+
leaderboardQuerySchema,
|
|
326
|
+
leaderboardRowSchema,
|
|
327
|
+
leaderboardPageSchema,
|
|
328
|
+
leaderboardPreviewSchema,
|
|
329
|
+
pointsMutationSchema,
|
|
330
|
+
pointsEntrySchema,
|
|
331
|
+
pointsResultSchema,
|
|
332
|
+
pointsAccountSchema,
|
|
333
|
+
leaderboardExclusionSchema,
|
|
334
|
+
leaderboardGroupSchema
|
|
335
|
+
};
|