@domino-sdk/relay 1.0.0-next.1 → 1.0.0-next.2
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 +39 -11
- package/dist/authoring.js +33 -13
- package/dist/browser.d.ts +95 -100
- package/dist/browser.js +6 -6
- package/dist/{chunk-IZYXEXUO.js → chunk-4KNTMNXA.js} +4 -4
- package/dist/{chunk-QEN4GHL7.js → chunk-B76BAJ25.js} +2 -2
- package/dist/{chunk-BGN3CQC6.js → chunk-FDWRBMB3.js} +2 -2
- package/dist/{chunk-UPWID5KS.js → chunk-NKGJEYZM.js} +1 -1
- package/dist/{chunk-UI4N4XRZ.js → chunk-ONDBQSMU.js} +1 -1
- package/dist/{chunk-OQ4ZNOC7.js → chunk-VH4OQ5VX.js} +1 -1
- package/dist/index.d.ts +229 -247
- package/dist/index.js +5 -5
- package/dist/portal-proxy.js +3 -3
- package/dist/react/index.d.ts +0 -5
- package/dist/react/index.js +6 -6
- package/dist/schema.d.ts +5 -12
- package/dist/schema.js +1 -1
- package/package.json +1 -1
package/dist/authoring.d.ts
CHANGED
|
@@ -129,7 +129,6 @@ declare const keyed: (key: (ctx: {
|
|
|
129
129
|
};
|
|
130
130
|
declare const completed: (quest: AuthoringIdentity | string) => {
|
|
131
131
|
quest: string;
|
|
132
|
-
scope: "ever";
|
|
133
132
|
};
|
|
134
133
|
declare const untracked: () => {
|
|
135
134
|
kind: "untracked";
|
|
@@ -174,17 +173,47 @@ type Outcome = {
|
|
|
174
173
|
kind: "reject";
|
|
175
174
|
reason: string;
|
|
176
175
|
};
|
|
176
|
+
/**
|
|
177
|
+
* A performance evaluator's answer. It gates the rewards content evaluation already selected, so
|
|
178
|
+
* it carries none: a `rewards` value fails the evaluation.
|
|
179
|
+
*/
|
|
180
|
+
type PerformanceOutcome = {
|
|
181
|
+
kind: "accept";
|
|
182
|
+
rewards?: never;
|
|
183
|
+
} | {
|
|
184
|
+
kind: "review";
|
|
185
|
+
reason: string;
|
|
186
|
+
rewards?: never;
|
|
187
|
+
} | {
|
|
188
|
+
kind: "reject";
|
|
189
|
+
reason: string;
|
|
190
|
+
};
|
|
191
|
+
declare function accept(): {
|
|
192
|
+
kind: "accept";
|
|
193
|
+
};
|
|
194
|
+
declare function accept(options: {
|
|
195
|
+
rewards?: Reward[];
|
|
196
|
+
}): Outcome;
|
|
197
|
+
declare function review(options: {
|
|
198
|
+
reason: string;
|
|
199
|
+
rewards?: undefined;
|
|
200
|
+
}): {
|
|
201
|
+
kind: "review";
|
|
202
|
+
reason: string;
|
|
203
|
+
};
|
|
204
|
+
declare function review(options: {
|
|
205
|
+
reason: string;
|
|
206
|
+
rewards?: Reward[];
|
|
207
|
+
}): Outcome;
|
|
177
208
|
declare const decision: {
|
|
178
|
-
accept:
|
|
179
|
-
rewards?: Reward[];
|
|
180
|
-
}) => Outcome;
|
|
209
|
+
accept: typeof accept;
|
|
181
210
|
reject: (options: {
|
|
182
211
|
reason: string;
|
|
183
|
-
}) =>
|
|
184
|
-
|
|
212
|
+
}) => {
|
|
213
|
+
kind: "reject";
|
|
185
214
|
reason: string;
|
|
186
|
-
|
|
187
|
-
|
|
215
|
+
};
|
|
216
|
+
review: typeof review;
|
|
188
217
|
};
|
|
189
218
|
type EvaluationContext<T, I = {
|
|
190
219
|
photo: string;
|
|
@@ -304,7 +333,7 @@ declare function defineQuest<T extends Record<string, z.ZodType>, const G extend
|
|
|
304
333
|
content: AdmittedContent;
|
|
305
334
|
metrics: Record<M[number], number>;
|
|
306
335
|
observedAt: number;
|
|
307
|
-
}) =>
|
|
336
|
+
}) => PerformanceOutcome | Promise<PerformanceOutcome>;
|
|
308
337
|
} : never;
|
|
309
338
|
}): {
|
|
310
339
|
key: string;
|
|
@@ -503,7 +532,6 @@ declare function defineQuest<T extends Record<string, z.ZodType>, const G extend
|
|
|
503
532
|
};
|
|
504
533
|
requires: {
|
|
505
534
|
quest: string;
|
|
506
|
-
scope: "ever";
|
|
507
535
|
}[];
|
|
508
536
|
completion: {
|
|
509
537
|
kind: "streak";
|
|
@@ -542,4 +570,4 @@ declare function defineQuest<T extends Record<string, z.ZodType>, const G extend
|
|
|
542
570
|
* Console instances receive independent quest identities and pinned versions. */
|
|
543
571
|
declare const defineQuestType: typeof defineQuest;
|
|
544
572
|
|
|
545
|
-
export { type EvaluationContext, TrackerTriggerContext, type TrackerTriggerInput, WalletBalance, WalletBalanceQuery, automatic, budget, completed, decision, defineQuest, defineQuestType, defineTieredReward, discordRole, evaluators, evidence, keyed, manual, once, points, staffHandover, untracked };
|
|
573
|
+
export { type EvaluationContext, type PerformanceOutcome, TrackerTriggerContext, type TrackerTriggerInput, WalletBalance, WalletBalanceQuery, automatic, budget, completed, decision, defineQuest, defineQuestType, defineTieredReward, discordRole, evaluators, evidence, keyed, manual, once, points, staffHandover, untracked };
|
package/dist/authoring.js
CHANGED
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
defineReferral,
|
|
6
6
|
formatUnits,
|
|
7
7
|
parseUnits
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-B76BAJ25.js";
|
|
9
9
|
import {
|
|
10
10
|
isEvmChainId
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-ONDBQSMU.js";
|
|
12
12
|
import {
|
|
13
13
|
admittedContentSchema,
|
|
14
14
|
budgetSchema,
|
|
@@ -40,7 +40,7 @@ import {
|
|
|
40
40
|
urlOptionsSchema,
|
|
41
41
|
x,
|
|
42
42
|
xAccountRoles
|
|
43
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-NKGJEYZM.js";
|
|
44
44
|
|
|
45
45
|
// src/authoring.ts
|
|
46
46
|
import { z } from "zod";
|
|
@@ -64,6 +64,11 @@ var evidence = {
|
|
|
64
64
|
quiz: () => "quiz"
|
|
65
65
|
};
|
|
66
66
|
function manual(options) {
|
|
67
|
+
if (options?.actor && options.input !== void 0) {
|
|
68
|
+
throw new Error(
|
|
69
|
+
'manual() cannot combine actor "staff" with input: staff-captured evidence is not supported. Use manual({ actor: "staff" }) for a staff confirmation, or manual({ input }) for evidence the participant submits.'
|
|
70
|
+
);
|
|
71
|
+
}
|
|
67
72
|
if (typeof options?.input === "object") {
|
|
68
73
|
return { kind: "manual", ...options.input };
|
|
69
74
|
}
|
|
@@ -113,8 +118,7 @@ function automatic(input) {
|
|
|
113
118
|
var budget = (definition) => budgetSchema.parse(definition);
|
|
114
119
|
var keyed = (key) => ({ kind: "keyed", key });
|
|
115
120
|
var completed = (quest) => ({
|
|
116
|
-
quest: typeof quest === "string" ? quest : authoringKey(quest)
|
|
117
|
-
scope: "ever"
|
|
121
|
+
quest: typeof quest === "string" ? quest : authoringKey(quest)
|
|
118
122
|
});
|
|
119
123
|
var untracked = () => ({ kind: "untracked" });
|
|
120
124
|
var staffHandover = () => ({ kind: "staff-handover" });
|
|
@@ -130,19 +134,19 @@ function defineTieredReward(input) {
|
|
|
130
134
|
};
|
|
131
135
|
}
|
|
132
136
|
var once = () => ({ kind: "once" });
|
|
137
|
+
function accept(options = {}) {
|
|
138
|
+
return { kind: "accept", ...options };
|
|
139
|
+
}
|
|
140
|
+
function review(options) {
|
|
141
|
+
return { kind: "review", ...options };
|
|
142
|
+
}
|
|
133
143
|
var decision = {
|
|
134
|
-
accept
|
|
135
|
-
kind: "accept",
|
|
136
|
-
...options
|
|
137
|
-
}),
|
|
144
|
+
accept,
|
|
138
145
|
reject: (options) => ({
|
|
139
146
|
kind: "reject",
|
|
140
147
|
...options
|
|
141
148
|
}),
|
|
142
|
-
review
|
|
143
|
-
kind: "review",
|
|
144
|
-
...options
|
|
145
|
-
})
|
|
149
|
+
review
|
|
146
150
|
};
|
|
147
151
|
var evaluators = {
|
|
148
152
|
quiz(answerKey, options = {}) {
|
|
@@ -190,6 +194,17 @@ function defineQuest(definition) {
|
|
|
190
194
|
if (definition.completion.kind === "streak" && (definition.trigger.kind !== "automatic" || !definition.trigger.observation)) {
|
|
191
195
|
throw new Error("Streaks require an automatic observation trigger");
|
|
192
196
|
}
|
|
197
|
+
const bareAutomatic = definition.trigger.kind === "automatic" && !definition.trigger.observation && !definition.trigger.content && !definition.trigger.tracker;
|
|
198
|
+
if (bareAutomatic && !definition.requires?.length) {
|
|
199
|
+
throw new Error(
|
|
200
|
+
"A bare automatic() quest needs at least one requires entry, such as requires: [completed(quest)]. Give it an observation, content or tracker trigger, or a prerequisite."
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
if (bareAutomatic && definition.completion.kind === "keyed") {
|
|
204
|
+
throw new Error(
|
|
205
|
+
"A bare automatic() quest cannot use keyed() completion. Give it an observation, content or tracker trigger, or use once()."
|
|
206
|
+
);
|
|
207
|
+
}
|
|
193
208
|
if (definition.trigger.kind === "manual" && definition.trigger.input !== "none" && !definition.evaluate) {
|
|
194
209
|
throw new Error("Evidence quests require an evaluator");
|
|
195
210
|
}
|
|
@@ -275,6 +290,11 @@ function defineQuest(definition) {
|
|
|
275
290
|
if (!result2) {
|
|
276
291
|
throw new Error("Performance evaluator returned no decision");
|
|
277
292
|
}
|
|
293
|
+
if (result2.rewards !== void 0) {
|
|
294
|
+
throw new Error(
|
|
295
|
+
"A performance evaluator cannot select rewards. It gates the rewards content evaluation selected: return accept, review or reject with a reason only."
|
|
296
|
+
);
|
|
297
|
+
}
|
|
278
298
|
return decisionSchema.parse(
|
|
279
299
|
result2.kind === "accept" ? {
|
|
280
300
|
kind: "accept",
|