@domino-sdk/relay 1.0.0-next.1 → 1.0.0-next.3
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 +56 -13
- package/dist/authoring.js +34 -13
- package/dist/browser.d.ts +186 -191
- 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 +410 -428
- package/dist/index.js +5 -5
- package/dist/portal-proxy.js +3 -3
- package/dist/react/index.d.ts +1 -6
- package/dist/react/index.js +6 -6
- package/dist/schema.d.ts +5 -12
- package/dist/schema.js +1 -1
- package/dist/{submission-input-JDwq3EVK.d.ts → submission-input-jVvTh4Ed.d.ts} +6 -0
- package/package.json +2 -2
package/dist/authoring.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as AdmittedContent, O as Observation, T as TrackerTriggerContext, a as TrackerReader, X as XReader, I as ImageReader, D as DiscordMember, b as DiscordMessage, W as WalletConnection, S as SolanaBalance, L as LinkedWallet, c as WalletBalanceQuery, d as WalletBalance, e as TrackerDefinition, f as TrackerTriggerMode, g as TrackerWhere, o as observationTriggerSchema, h as TrackerTriggerPolicy, B as Budget, i as AuthoringIdentity, C as ContentMetric, j as IntegrationProvider, k as StreakPolicy, l as TextEvidence, U as UrlEvidence, m as TextOptions, n as UrlOptions } from './submission-input-
|
|
2
|
-
export { E as EvmChainId, p as content, q as customSource, r as defineEngagementReward, s as defineLeaderboard, t as defineReferral, u as defineTracker, v as discord, w as formatUnits, x as isEvmChainId, y as parseUnits, z as perContent, F as pointLedgers, G as settings, H as streak, J as trackerTriggerContextSchema, K as x } from './submission-input-
|
|
1
|
+
import { A as AdmittedContent, O as Observation, T as TrackerTriggerContext, a as TrackerReader, X as XReader, I as ImageReader, D as DiscordMember, b as DiscordMessage, W as WalletConnection, S as SolanaBalance, L as LinkedWallet, c as WalletBalanceQuery, d as WalletBalance, e as TrackerDefinition, f as TrackerTriggerMode, g as TrackerWhere, o as observationTriggerSchema, h as TrackerTriggerPolicy, B as Budget, i as AuthoringIdentity, C as ContentMetric, j as IntegrationProvider, k as StreakPolicy, l as TextEvidence, U as UrlEvidence, m as TextOptions, n as UrlOptions } from './submission-input-jVvTh4Ed.js';
|
|
2
|
+
export { E as EvmChainId, p as content, q as customSource, r as defineEngagementReward, s as defineLeaderboard, t as defineReferral, u as defineTracker, v as discord, w as formatUnits, x as isEvmChainId, y as parseUnits, z as perContent, F as pointLedgers, G as settings, H as streak, J as trackerTriggerContextSchema, K as x } from './submission-input-jVvTh4Ed.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { TextReviewInput, TextResult, PhotoResult, rewardSchema, triggerSchema, QuestPresentation, QuestProfile, QuizEvidence, Decision, TieredRewardDefinition } from './schema.js';
|
|
5
5
|
|
|
@@ -114,6 +114,8 @@ declare const keyed: (key: (ctx: {
|
|
|
114
114
|
/** The pinned tracker observation of a tracker-triggered quest. */
|
|
115
115
|
tracker?: TrackerTriggerContext | null;
|
|
116
116
|
eligibleAt: number;
|
|
117
|
+
/** The attempt's evaluation time; see {@link EvaluationContext.now}. */
|
|
118
|
+
now: number;
|
|
117
119
|
}) => string) => {
|
|
118
120
|
kind: "keyed";
|
|
119
121
|
key: (ctx: {
|
|
@@ -125,11 +127,12 @@ declare const keyed: (key: (ctx: {
|
|
|
125
127
|
/** The pinned tracker observation of a tracker-triggered quest. */
|
|
126
128
|
tracker?: TrackerTriggerContext | null;
|
|
127
129
|
eligibleAt: number;
|
|
130
|
+
/** The attempt's evaluation time; see {@link EvaluationContext.now}. */
|
|
131
|
+
now: number;
|
|
128
132
|
}) => string;
|
|
129
133
|
};
|
|
130
134
|
declare const completed: (quest: AuthoringIdentity | string) => {
|
|
131
135
|
quest: string;
|
|
132
|
-
scope: "ever";
|
|
133
136
|
};
|
|
134
137
|
declare const untracked: () => {
|
|
135
138
|
kind: "untracked";
|
|
@@ -174,17 +177,47 @@ type Outcome = {
|
|
|
174
177
|
kind: "reject";
|
|
175
178
|
reason: string;
|
|
176
179
|
};
|
|
180
|
+
/**
|
|
181
|
+
* A performance evaluator's answer. It gates the rewards content evaluation already selected, so
|
|
182
|
+
* it carries none: a `rewards` value fails the evaluation.
|
|
183
|
+
*/
|
|
184
|
+
type PerformanceOutcome = {
|
|
185
|
+
kind: "accept";
|
|
186
|
+
rewards?: never;
|
|
187
|
+
} | {
|
|
188
|
+
kind: "review";
|
|
189
|
+
reason: string;
|
|
190
|
+
rewards?: never;
|
|
191
|
+
} | {
|
|
192
|
+
kind: "reject";
|
|
193
|
+
reason: string;
|
|
194
|
+
};
|
|
195
|
+
declare function accept(): {
|
|
196
|
+
kind: "accept";
|
|
197
|
+
};
|
|
198
|
+
declare function accept(options: {
|
|
199
|
+
rewards?: Reward[];
|
|
200
|
+
}): Outcome;
|
|
201
|
+
declare function review(options: {
|
|
202
|
+
reason: string;
|
|
203
|
+
rewards?: undefined;
|
|
204
|
+
}): {
|
|
205
|
+
kind: "review";
|
|
206
|
+
reason: string;
|
|
207
|
+
};
|
|
208
|
+
declare function review(options: {
|
|
209
|
+
reason: string;
|
|
210
|
+
rewards?: Reward[];
|
|
211
|
+
}): Outcome;
|
|
177
212
|
declare const decision: {
|
|
178
|
-
accept:
|
|
179
|
-
rewards?: Reward[];
|
|
180
|
-
}) => Outcome;
|
|
213
|
+
accept: typeof accept;
|
|
181
214
|
reject: (options: {
|
|
182
215
|
reason: string;
|
|
183
|
-
}) =>
|
|
184
|
-
|
|
216
|
+
}) => {
|
|
217
|
+
kind: "reject";
|
|
185
218
|
reason: string;
|
|
186
|
-
|
|
187
|
-
|
|
219
|
+
};
|
|
220
|
+
review: typeof review;
|
|
188
221
|
};
|
|
189
222
|
type EvaluationContext<T, I = {
|
|
190
223
|
photo: string;
|
|
@@ -201,7 +234,18 @@ type EvaluationContext<T, I = {
|
|
|
201
234
|
* was attributed to. Null unless the quest has a tracker trigger.
|
|
202
235
|
*/
|
|
203
236
|
tracker: TrackerTriggerContext | null;
|
|
237
|
+
/**
|
|
238
|
+
* When the activity happened, in epoch milliseconds: the observation's or tracker record's
|
|
239
|
+
* occurrence time, else when the attempt was admitted. Budgets and daily keys use it.
|
|
240
|
+
*/
|
|
204
241
|
eligibleAt: number;
|
|
242
|
+
/**
|
|
243
|
+
* The attempt's evaluation time, in epoch milliseconds: when its first evaluation started.
|
|
244
|
+
* Every retry and replay of the attempt receives the same value, and the sandbox freezes
|
|
245
|
+
* `Date.now()` and `new Date()` at it. Use `eligibleAt` for when the activity
|
|
246
|
+
* happened.
|
|
247
|
+
*/
|
|
248
|
+
now: number;
|
|
205
249
|
trackers: TrackerReader;
|
|
206
250
|
x: XReader;
|
|
207
251
|
images: ImageReader;
|
|
@@ -304,7 +348,7 @@ declare function defineQuest<T extends Record<string, z.ZodType>, const G extend
|
|
|
304
348
|
content: AdmittedContent;
|
|
305
349
|
metrics: Record<M[number], number>;
|
|
306
350
|
observedAt: number;
|
|
307
|
-
}) =>
|
|
351
|
+
}) => PerformanceOutcome | Promise<PerformanceOutcome>;
|
|
308
352
|
} : never;
|
|
309
353
|
}): {
|
|
310
354
|
key: string;
|
|
@@ -503,7 +547,6 @@ declare function defineQuest<T extends Record<string, z.ZodType>, const G extend
|
|
|
503
547
|
};
|
|
504
548
|
requires: {
|
|
505
549
|
quest: string;
|
|
506
|
-
scope: "ever";
|
|
507
550
|
}[];
|
|
508
551
|
completion: {
|
|
509
552
|
kind: "streak";
|
|
@@ -542,4 +585,4 @@ declare function defineQuest<T extends Record<string, z.ZodType>, const G extend
|
|
|
542
585
|
* Console instances receive independent quest identities and pinned versions. */
|
|
543
586
|
declare const defineQuestType: typeof defineQuest;
|
|
544
587
|
|
|
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 };
|
|
588
|
+
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",
|
|
@@ -295,6 +315,7 @@ function defineQuest(definition) {
|
|
|
295
315
|
observation: ctx.observation ?? null,
|
|
296
316
|
tracker,
|
|
297
317
|
eligibleAt: ctx.eligibleAt,
|
|
318
|
+
now: ctx.now,
|
|
298
319
|
review: ctx.review,
|
|
299
320
|
trackers: ctx.trackers,
|
|
300
321
|
wallet: ctx.wallet,
|