@domino-sdk/relay 0.5.0 → 0.7.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 +93 -5
- package/dist/authoring.js +42 -6
- package/dist/browser.d.ts +438 -32
- package/dist/browser.js +4 -4
- package/dist/{chunk-QWRSUSNB.js → chunk-36LZ3IOO.js} +1 -1
- package/dist/chunk-6QUCADMF.js +831 -0
- package/dist/{chunk-LUCL63DS.js → chunk-LXLNC4CN.js} +200 -158
- package/dist/{chunk-TXL43HL3.js → chunk-TYVT5BPZ.js} +4 -2
- package/dist/index.d.ts +1358 -77
- package/dist/index.js +44 -4
- package/dist/portal-proxy.js +3 -3
- package/dist/schema.d.ts +429 -9
- package/dist/schema.js +3 -1
- package/dist/{settings-B7vsT8nd.d.ts → settings-CU_oBcx0.d.ts} +217 -1
- package/package.json +1 -1
- package/dist/chunk-3IQ4KUKF.js +0 -613
package/dist/authoring.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as DiscordMember, W as WalletConnection, S as SolanaBalance, I as IntegrationProvider } from './settings-
|
|
2
|
-
export { d as defineLeaderboard,
|
|
1
|
+
import { O as Observation, D as DiscordMember, a as DiscordMessage, W as WalletConnection, S as SolanaBalance, o as observationTriggerSchema, B as Budget, I as IntegrationProvider } from './settings-CU_oBcx0.js';
|
|
2
|
+
export { d as defineLeaderboard, b as defineReferral, c as discord, s as settings } from './settings-CU_oBcx0.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { PhotoResult, rewardSchema, triggerSchema, QuestPresentation, QuizEvidence, Decision, TieredRewardDefinition } from './schema.js';
|
|
5
5
|
|
|
@@ -9,6 +9,12 @@ declare const points: (balance: string, amount: number) => {
|
|
|
9
9
|
balance: string;
|
|
10
10
|
amount: number;
|
|
11
11
|
};
|
|
12
|
+
declare const discordRole: (roleId: string) => {
|
|
13
|
+
kind: "integration";
|
|
14
|
+
provider: "discord";
|
|
15
|
+
action: "grant-role";
|
|
16
|
+
roleId: string;
|
|
17
|
+
};
|
|
12
18
|
declare const evidence: {
|
|
13
19
|
photo: () => "photo";
|
|
14
20
|
quiz: () => "quiz";
|
|
@@ -30,9 +36,38 @@ declare function manual(options: {
|
|
|
30
36
|
input: "none";
|
|
31
37
|
actor: "staff";
|
|
32
38
|
};
|
|
33
|
-
declare const automatic: () => {
|
|
39
|
+
declare const automatic: (observation?: z.infer<typeof observationTriggerSchema>) => {
|
|
40
|
+
observation?: {
|
|
41
|
+
source: string;
|
|
42
|
+
type: string;
|
|
43
|
+
} | undefined;
|
|
34
44
|
kind: "automatic";
|
|
35
45
|
};
|
|
46
|
+
declare const budget: (definition: Budget) => {
|
|
47
|
+
id: string;
|
|
48
|
+
scope: "member" | "project";
|
|
49
|
+
period: "lifetime" | "day";
|
|
50
|
+
limit: number;
|
|
51
|
+
cost: number | {
|
|
52
|
+
balance: string;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
declare const keyed: (key: (ctx: {
|
|
56
|
+
member: {
|
|
57
|
+
id: string;
|
|
58
|
+
};
|
|
59
|
+
observation: Observation | null;
|
|
60
|
+
eligibleAt: number;
|
|
61
|
+
}) => string) => {
|
|
62
|
+
kind: "keyed";
|
|
63
|
+
key: (ctx: {
|
|
64
|
+
member: {
|
|
65
|
+
id: string;
|
|
66
|
+
};
|
|
67
|
+
observation: Observation | null;
|
|
68
|
+
eligibleAt: number;
|
|
69
|
+
}) => string;
|
|
70
|
+
};
|
|
36
71
|
declare const completed: (quest: {
|
|
37
72
|
id: string;
|
|
38
73
|
} | string) => {
|
|
@@ -100,6 +135,8 @@ type EvaluationContext<T, I = {
|
|
|
100
135
|
id: string;
|
|
101
136
|
};
|
|
102
137
|
input: I;
|
|
138
|
+
observation: Observation | null;
|
|
139
|
+
eligibleAt: number;
|
|
103
140
|
review: {
|
|
104
141
|
photo(options: {
|
|
105
142
|
image: string;
|
|
@@ -108,6 +145,10 @@ type EvaluationContext<T, I = {
|
|
|
108
145
|
};
|
|
109
146
|
discord: {
|
|
110
147
|
member(): Promise<DiscordMember | null>;
|
|
148
|
+
message(input: {
|
|
149
|
+
channelId: string;
|
|
150
|
+
messageId: string;
|
|
151
|
+
}): Promise<DiscordMessage | null>;
|
|
111
152
|
};
|
|
112
153
|
wallet: {
|
|
113
154
|
connection(): Promise<WalletConnection | null>;
|
|
@@ -148,7 +189,9 @@ declare function defineQuest<T extends Record<string, z.ZodType>, const G extend
|
|
|
148
189
|
trigger: G;
|
|
149
190
|
integrations?: IntegrationProvider[];
|
|
150
191
|
requires?: ReturnType<typeof completed>[];
|
|
151
|
-
completion: ReturnType<typeof once>;
|
|
192
|
+
completion: ReturnType<typeof once> | ReturnType<typeof keyed>;
|
|
193
|
+
visibility?: "visible" | "hidden";
|
|
194
|
+
budgets?: Budget[];
|
|
152
195
|
review?: (ctx: {
|
|
153
196
|
settings: z.output<z.ZodObject<T>>;
|
|
154
197
|
}) => {
|
|
@@ -186,6 +229,30 @@ declare function defineQuest<T extends Record<string, z.ZodType>, const G extend
|
|
|
186
229
|
};
|
|
187
230
|
integrations: "discord"[];
|
|
188
231
|
fields: Record<string, {
|
|
232
|
+
kind: "point-ledger";
|
|
233
|
+
default: string;
|
|
234
|
+
label: string;
|
|
235
|
+
description?: string | undefined;
|
|
236
|
+
} | {
|
|
237
|
+
kind: "datetime";
|
|
238
|
+
default: string;
|
|
239
|
+
label: string;
|
|
240
|
+
description?: string | undefined;
|
|
241
|
+
} | {
|
|
242
|
+
kind: "resource";
|
|
243
|
+
default: string;
|
|
244
|
+
source: {
|
|
245
|
+
provider: "discord";
|
|
246
|
+
resource: "channel";
|
|
247
|
+
types: ("text" | "announcement")[];
|
|
248
|
+
} | {
|
|
249
|
+
provider: "discord";
|
|
250
|
+
resource: "role";
|
|
251
|
+
assignable: boolean;
|
|
252
|
+
};
|
|
253
|
+
label: string;
|
|
254
|
+
description?: string | undefined;
|
|
255
|
+
} | {
|
|
189
256
|
kind: "quiz";
|
|
190
257
|
default: {
|
|
191
258
|
id: string;
|
|
@@ -255,6 +322,11 @@ declare function defineQuest<T extends Record<string, z.ZodType>, const G extend
|
|
|
255
322
|
kind: "points";
|
|
256
323
|
balance: string;
|
|
257
324
|
amount: number;
|
|
325
|
+
} | {
|
|
326
|
+
kind: "integration";
|
|
327
|
+
provider: "discord";
|
|
328
|
+
action: "grant-role";
|
|
329
|
+
roleId: string;
|
|
258
330
|
})[];
|
|
259
331
|
humanReview: boolean;
|
|
260
332
|
trigger: {
|
|
@@ -263,6 +335,10 @@ declare function defineQuest<T extends Record<string, z.ZodType>, const G extend
|
|
|
263
335
|
actor?: "staff" | "member" | undefined;
|
|
264
336
|
} | {
|
|
265
337
|
kind: "automatic";
|
|
338
|
+
observation?: {
|
|
339
|
+
source: string;
|
|
340
|
+
type: string;
|
|
341
|
+
} | undefined;
|
|
266
342
|
};
|
|
267
343
|
requires: {
|
|
268
344
|
quest: string;
|
|
@@ -270,7 +346,19 @@ declare function defineQuest<T extends Record<string, z.ZodType>, const G extend
|
|
|
270
346
|
}[];
|
|
271
347
|
completion: {
|
|
272
348
|
kind: "once";
|
|
349
|
+
} | {
|
|
350
|
+
kind: "keyed";
|
|
273
351
|
};
|
|
352
|
+
visibility: "visible" | "hidden";
|
|
353
|
+
budgets: {
|
|
354
|
+
id: string;
|
|
355
|
+
scope: "member" | "project";
|
|
356
|
+
period: "lifetime" | "day";
|
|
357
|
+
limit: number;
|
|
358
|
+
cost: number | {
|
|
359
|
+
balance: string;
|
|
360
|
+
};
|
|
361
|
+
}[];
|
|
274
362
|
};
|
|
275
363
|
evaluate(ctx: EvaluationContext<unknown, QuestInput<G>> & {
|
|
276
364
|
rewards: Reward[];
|
|
@@ -281,4 +369,4 @@ declare function defineQuest<T extends Record<string, z.ZodType>, const G extend
|
|
|
281
369
|
* Console instances receive independent quest identities and pinned versions. */
|
|
282
370
|
declare const defineQuestType: typeof defineQuest;
|
|
283
371
|
|
|
284
|
-
export { type EvaluationContext, automatic, completed, decision, defineQuest, defineQuestType, defineTieredReward, evaluators, evidence, manual, once, points, staffHandover, untracked };
|
|
372
|
+
export { type EvaluationContext, automatic, budget, completed, decision, defineQuest, defineQuestType, defineTieredReward, discordRole, evaluators, evidence, keyed, manual, once, points, staffHandover, untracked };
|
package/dist/authoring.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
defineLeaderboard,
|
|
3
3
|
defineReferral
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-TYVT5BPZ.js";
|
|
5
5
|
import {
|
|
6
|
+
budgetSchema,
|
|
6
7
|
decisionSchema,
|
|
8
|
+
discord,
|
|
9
|
+
integrationRewardSchema,
|
|
7
10
|
parseSettings,
|
|
8
11
|
pointsRewardSchema,
|
|
9
12
|
questDescriptionSchema,
|
|
@@ -13,11 +16,17 @@ import {
|
|
|
13
16
|
settings,
|
|
14
17
|
tierRewardSchema,
|
|
15
18
|
tieredRewardDefinitionSchema
|
|
16
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-6QUCADMF.js";
|
|
17
20
|
|
|
18
21
|
// src/authoring.ts
|
|
19
22
|
import { z } from "zod";
|
|
20
23
|
var points = (balance, amount) => pointsRewardSchema.parse({ kind: "points", balance, amount });
|
|
24
|
+
var discordRole = (roleId) => integrationRewardSchema.parse({
|
|
25
|
+
kind: "integration",
|
|
26
|
+
provider: "discord",
|
|
27
|
+
action: "grant-role",
|
|
28
|
+
roleId
|
|
29
|
+
});
|
|
21
30
|
var evidence = {
|
|
22
31
|
photo: () => "photo",
|
|
23
32
|
quiz: () => "quiz"
|
|
@@ -29,7 +38,12 @@ function manual(options) {
|
|
|
29
38
|
...options?.actor ? { actor: options.actor } : {}
|
|
30
39
|
};
|
|
31
40
|
}
|
|
32
|
-
var automatic = () => ({
|
|
41
|
+
var automatic = (observation) => ({
|
|
42
|
+
kind: "automatic",
|
|
43
|
+
...observation ? { observation } : {}
|
|
44
|
+
});
|
|
45
|
+
var budget = (definition) => budgetSchema.parse(definition);
|
|
46
|
+
var keyed = (key) => ({ kind: "keyed", key });
|
|
33
47
|
var completed = (quest) => ({
|
|
34
48
|
quest: typeof quest === "string" ? quest : quest.id,
|
|
35
49
|
scope: "ever"
|
|
@@ -109,8 +123,20 @@ function defineQuest(definition) {
|
|
|
109
123
|
rewards,
|
|
110
124
|
humanReview: definition.review?.({ settings: settings2 })?.enabled ?? true,
|
|
111
125
|
trigger: definition.trigger,
|
|
112
|
-
integrations:
|
|
113
|
-
|
|
126
|
+
integrations: [
|
|
127
|
+
.../* @__PURE__ */ new Set([
|
|
128
|
+
...definition.integrations ?? [],
|
|
129
|
+
...rewards.flatMap(
|
|
130
|
+
(reward) => reward.kind === "integration" ? [reward.provider] : []
|
|
131
|
+
),
|
|
132
|
+
...Object.values(fields).flatMap(
|
|
133
|
+
(field) => field.kind === "resource" ? [field.source.provider] : []
|
|
134
|
+
)
|
|
135
|
+
])
|
|
136
|
+
],
|
|
137
|
+
completion: { kind: definition.completion.kind },
|
|
138
|
+
visibility: definition.visibility ?? "visible",
|
|
139
|
+
budgets: definition.budgets ?? [],
|
|
114
140
|
requires: definition.requires ?? []
|
|
115
141
|
});
|
|
116
142
|
}
|
|
@@ -123,6 +149,8 @@ function defineQuest(definition) {
|
|
|
123
149
|
settings: settings2,
|
|
124
150
|
member: ctx.member,
|
|
125
151
|
input: ctx.input,
|
|
152
|
+
observation: ctx.observation ?? null,
|
|
153
|
+
eligibleAt: ctx.eligibleAt,
|
|
126
154
|
review: ctx.review,
|
|
127
155
|
wallet: ctx.wallet,
|
|
128
156
|
discord: ctx.discord
|
|
@@ -131,7 +159,11 @@ function defineQuest(definition) {
|
|
|
131
159
|
if (result.kind === "review" && !ctx.humanReview)
|
|
132
160
|
return decisionSchema.parse({ kind: "reject", reason: result.reason });
|
|
133
161
|
return decisionSchema.parse(
|
|
134
|
-
result.kind === "accept" || result.kind === "review" ? {
|
|
162
|
+
result.kind === "accept" || result.kind === "review" ? {
|
|
163
|
+
...result,
|
|
164
|
+
rewards: result.rewards ?? ctx.rewards,
|
|
165
|
+
...definition.completion.kind === "keyed" ? { completionKey: definition.completion.key(ctx) } : {}
|
|
166
|
+
} : result
|
|
135
167
|
);
|
|
136
168
|
}
|
|
137
169
|
};
|
|
@@ -139,6 +171,7 @@ function defineQuest(definition) {
|
|
|
139
171
|
var defineQuestType = defineQuest;
|
|
140
172
|
export {
|
|
141
173
|
automatic,
|
|
174
|
+
budget,
|
|
142
175
|
completed,
|
|
143
176
|
decision,
|
|
144
177
|
defineLeaderboard,
|
|
@@ -146,8 +179,11 @@ export {
|
|
|
146
179
|
defineQuestType,
|
|
147
180
|
defineReferral,
|
|
148
181
|
defineTieredReward,
|
|
182
|
+
discord,
|
|
183
|
+
discordRole,
|
|
149
184
|
evaluators,
|
|
150
185
|
evidence,
|
|
186
|
+
keyed,
|
|
151
187
|
manual,
|
|
152
188
|
once,
|
|
153
189
|
points,
|