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