@domino-sdk/relay 0.4.0 → 0.6.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 +88 -5
- package/dist/authoring.js +42 -6
- package/dist/browser.d.ts +382 -18
- package/dist/browser.js +4 -4
- package/dist/{chunk-KQVL6MOH.js → chunk-CCLIDCUU.js} +205 -161
- package/dist/chunk-MXK7KEDA.js +819 -0
- package/dist/{chunk-QWRSUSNB.js → chunk-PLO5PPLU.js} +1 -1
- package/dist/{chunk-TXL43HL3.js → chunk-UIC6OF3C.js} +4 -2
- package/dist/index.d.ts +1208 -39
- package/dist/index.js +44 -4
- package/dist/portal-proxy.d.ts +3 -1
- package/dist/portal-proxy.js +6 -4
- package/dist/schema.d.ts +399 -9
- package/dist/schema.js +3 -1
- package/dist/{settings-B7vsT8nd.d.ts → settings-BrC6C9yl.d.ts} +204 -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-BrC6C9yl.js';
|
|
2
|
+
export { d as defineLeaderboard, b as defineReferral, c as discord, s as settings } from './settings-BrC6C9yl.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,25 @@ 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: "datetime";
|
|
233
|
+
default: string;
|
|
234
|
+
label: string;
|
|
235
|
+
description?: string | undefined;
|
|
236
|
+
} | {
|
|
237
|
+
kind: "resource";
|
|
238
|
+
default: string;
|
|
239
|
+
source: {
|
|
240
|
+
provider: "discord";
|
|
241
|
+
resource: "channel";
|
|
242
|
+
types: ("text" | "announcement")[];
|
|
243
|
+
} | {
|
|
244
|
+
provider: "discord";
|
|
245
|
+
resource: "role";
|
|
246
|
+
assignable: boolean;
|
|
247
|
+
};
|
|
248
|
+
label: string;
|
|
249
|
+
description?: string | undefined;
|
|
250
|
+
} | {
|
|
189
251
|
kind: "quiz";
|
|
190
252
|
default: {
|
|
191
253
|
id: string;
|
|
@@ -255,6 +317,11 @@ declare function defineQuest<T extends Record<string, z.ZodType>, const G extend
|
|
|
255
317
|
kind: "points";
|
|
256
318
|
balance: string;
|
|
257
319
|
amount: number;
|
|
320
|
+
} | {
|
|
321
|
+
kind: "integration";
|
|
322
|
+
provider: "discord";
|
|
323
|
+
action: "grant-role";
|
|
324
|
+
roleId: string;
|
|
258
325
|
})[];
|
|
259
326
|
humanReview: boolean;
|
|
260
327
|
trigger: {
|
|
@@ -263,6 +330,10 @@ declare function defineQuest<T extends Record<string, z.ZodType>, const G extend
|
|
|
263
330
|
actor?: "staff" | "member" | undefined;
|
|
264
331
|
} | {
|
|
265
332
|
kind: "automatic";
|
|
333
|
+
observation?: {
|
|
334
|
+
source: string;
|
|
335
|
+
type: string;
|
|
336
|
+
} | undefined;
|
|
266
337
|
};
|
|
267
338
|
requires: {
|
|
268
339
|
quest: string;
|
|
@@ -270,7 +341,19 @@ declare function defineQuest<T extends Record<string, z.ZodType>, const G extend
|
|
|
270
341
|
}[];
|
|
271
342
|
completion: {
|
|
272
343
|
kind: "once";
|
|
344
|
+
} | {
|
|
345
|
+
kind: "keyed";
|
|
273
346
|
};
|
|
347
|
+
visibility: "visible" | "hidden";
|
|
348
|
+
budgets: {
|
|
349
|
+
id: string;
|
|
350
|
+
scope: "member" | "project";
|
|
351
|
+
period: "lifetime" | "day";
|
|
352
|
+
limit: number;
|
|
353
|
+
cost: number | {
|
|
354
|
+
balance: string;
|
|
355
|
+
};
|
|
356
|
+
}[];
|
|
274
357
|
};
|
|
275
358
|
evaluate(ctx: EvaluationContext<unknown, QuestInput<G>> & {
|
|
276
359
|
rewards: Reward[];
|
|
@@ -281,4 +364,4 @@ declare function defineQuest<T extends Record<string, z.ZodType>, const G extend
|
|
|
281
364
|
* Console instances receive independent quest identities and pinned versions. */
|
|
282
365
|
declare const defineQuestType: typeof defineQuest;
|
|
283
366
|
|
|
284
|
-
export { type EvaluationContext, automatic, completed, decision, defineQuest, defineQuestType, defineTieredReward, evaluators, evidence, manual, once, points, staffHandover, untracked };
|
|
367
|
+
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-UIC6OF3C.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-MXK7KEDA.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,
|