@domino-sdk/relay 0.24.0 → 0.25.1
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 +52 -10
- package/dist/authoring.js +48 -8
- package/dist/browser.d.ts +431 -27
- package/dist/browser.js +22 -7
- package/dist/chunk-7QICEKC2.js +229 -0
- package/dist/{chunk-ZOL7RYHW.js → chunk-AKB266O5.js} +46 -3
- package/dist/chunk-D6BX627V.js +175 -0
- package/dist/{chunk-UYS522ER.js → chunk-IXLY3A7B.js} +550 -396
- package/dist/chunk-MZFUQQDP.js +355 -0
- package/dist/{chunk-RTBIXGMH.js → chunk-S44XSDW2.js} +779 -46
- package/dist/index.d.ts +1186 -56
- package/dist/index.js +123 -11
- package/dist/portal-proxy.js +10 -5
- package/dist/react/index.d.ts +498 -13
- package/dist/react/index.js +316 -40
- package/dist/schema.d.ts +82 -2
- package/dist/schema.js +1 -1
- package/dist/{submission-input-CK4Dy19H.d.ts → submission-input-Ckpb4sBv.d.ts} +1899 -2
- package/package.json +5 -3
- package/dist/chunk-57TGYC5Y.js +0 -37
- package/dist/chunk-ND3CVNIW.js +0 -61
package/dist/authoring.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as AdmittedContent, O as Observation, T as TrackerReader, X as XReader, I as ImageReader, D as DiscordMember,
|
|
2
|
-
export {
|
|
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, o as observationTriggerSchema, e as TrackerDefinition, f as TrackerBeneficiary, g as TrackerTriggerPolicy, B as Budget, h as AuthoringIdentity, C as ContentMetric, i as IntegrationProvider, j as StreakPolicy, k as TextEvidence, U as UrlEvidence, l as TextOptions, m as UrlOptions } from './submission-input-Ckpb4sBv.js';
|
|
2
|
+
export { n as content, p as customSource, q as defineEngagementReward, r as defineLeaderboard, s as defineReferral, t as defineTracker, u as discord, v as formatUnits, w as parseUnits, x as perContent, y as pointLedgers, z as settings, E as streak, F as trackerTriggerContextSchema, G as x } from './submission-input-Ckpb4sBv.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { TextReviewInput, TextResult, PhotoResult, rewardSchema, triggerSchema, QuestPresentation, QuizEvidence, Decision, TieredRewardDefinition } from './schema.js';
|
|
5
5
|
|
|
@@ -58,17 +58,35 @@ declare function manual(options: {
|
|
|
58
58
|
input: "none";
|
|
59
59
|
actor: "staff";
|
|
60
60
|
};
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
61
|
+
/**
|
|
62
|
+
* An automatic quest. With no argument it runs once its prerequisites are complete; with an
|
|
63
|
+
* observation it runs for each matching observation; with a tracker it runs for each new record
|
|
64
|
+
* observation (each newly discovered post, for an X tracker), for the member Relay attributes the
|
|
65
|
+
* record to.
|
|
66
|
+
*/
|
|
67
|
+
declare function automatic(): {
|
|
66
68
|
kind: "automatic";
|
|
67
69
|
};
|
|
70
|
+
declare function automatic(observation: z.infer<typeof observationTriggerSchema>): {
|
|
71
|
+
kind: "automatic";
|
|
72
|
+
observation: z.infer<typeof observationTriggerSchema>;
|
|
73
|
+
};
|
|
74
|
+
declare function automatic(input: {
|
|
75
|
+
tracker: TrackerDefinition;
|
|
76
|
+
/**
|
|
77
|
+
* Whose quest each record is. `"author"` (the default): the member who verified the record
|
|
78
|
+
* author's wallet (custom trackers) or X account (X trackers). `"replied-to"`: the member whose
|
|
79
|
+
* verified X account an X post replies to.
|
|
80
|
+
*/
|
|
81
|
+
beneficiary?: TrackerBeneficiary;
|
|
82
|
+
}): {
|
|
83
|
+
kind: "automatic";
|
|
84
|
+
tracker: TrackerTriggerPolicy;
|
|
85
|
+
};
|
|
68
86
|
declare const budget: (definition: Budget) => {
|
|
69
87
|
id: string;
|
|
70
88
|
scope: "member" | "project";
|
|
71
|
-
period: "lifetime" | "day";
|
|
89
|
+
period: "lifetime" | "day" | "week";
|
|
72
90
|
limit: number;
|
|
73
91
|
cost: number | {
|
|
74
92
|
balance: string;
|
|
@@ -80,6 +98,8 @@ declare const keyed: (key: (ctx: {
|
|
|
80
98
|
};
|
|
81
99
|
content?: AdmittedContent | null;
|
|
82
100
|
observation: Observation | null;
|
|
101
|
+
/** The pinned tracker observation of a tracker-triggered quest. */
|
|
102
|
+
tracker?: TrackerTriggerContext | null;
|
|
83
103
|
eligibleAt: number;
|
|
84
104
|
}) => string) => {
|
|
85
105
|
kind: "keyed";
|
|
@@ -89,6 +109,8 @@ declare const keyed: (key: (ctx: {
|
|
|
89
109
|
};
|
|
90
110
|
content?: AdmittedContent | null;
|
|
91
111
|
observation: Observation | null;
|
|
112
|
+
/** The pinned tracker observation of a tracker-triggered quest. */
|
|
113
|
+
tracker?: TrackerTriggerContext | null;
|
|
92
114
|
eligibleAt: number;
|
|
93
115
|
}) => string;
|
|
94
116
|
};
|
|
@@ -161,6 +183,11 @@ type EvaluationContext<T, I = {
|
|
|
161
183
|
input: I;
|
|
162
184
|
content: AdmittedContent | null;
|
|
163
185
|
observation: Observation | null;
|
|
186
|
+
/**
|
|
187
|
+
* The tracker observation that admitted this attempt, and the member and verified account it
|
|
188
|
+
* was attributed to. Null unless the quest has a tracker trigger.
|
|
189
|
+
*/
|
|
190
|
+
tracker: TrackerTriggerContext | null;
|
|
164
191
|
eligibleAt: number;
|
|
165
192
|
trackers: TrackerReader;
|
|
166
193
|
x: XReader;
|
|
@@ -180,8 +207,18 @@ type EvaluationContext<T, I = {
|
|
|
180
207
|
}): Promise<DiscordMessage | null>;
|
|
181
208
|
};
|
|
182
209
|
wallet: {
|
|
210
|
+
/** The member's newest linked Solana wallet. */
|
|
183
211
|
connection(): Promise<WalletConnection | null>;
|
|
212
|
+
/** SOL held by the newest linked Solana wallet. */
|
|
184
213
|
solanaBalance(): Promise<SolanaBalance | null>;
|
|
214
|
+
/** Every wallet the member has linked to this project, pinned once per attempt. */
|
|
215
|
+
list(): Promise<LinkedWallet[]>;
|
|
216
|
+
/**
|
|
217
|
+
* The native or token balance of the member's pinned linked wallets on one chain: all wallets of
|
|
218
|
+
* that family, or `address` (which must be one of them). No wallets gives `total: "0"` and
|
|
219
|
+
* `wallets: []`. Provider failures throw; they never read as a zero balance.
|
|
220
|
+
*/
|
|
221
|
+
balance(query: WalletBalanceQuery): Promise<WalletBalance>;
|
|
185
222
|
};
|
|
186
223
|
};
|
|
187
224
|
type Evaluator<T, I = {
|
|
@@ -400,6 +437,11 @@ declare function defineQuest<T extends Record<string, z.ZodType>, const G extend
|
|
|
400
437
|
posts: "after-enrollment" | "since-start";
|
|
401
438
|
historical: "staff" | "automatic" | "claim";
|
|
402
439
|
} | undefined;
|
|
440
|
+
tracker?: {
|
|
441
|
+
tracker: string;
|
|
442
|
+
source: "custom" | "x-search";
|
|
443
|
+
beneficiary: "author" | "replied-to";
|
|
444
|
+
} | undefined;
|
|
403
445
|
} | {
|
|
404
446
|
kind: "manual";
|
|
405
447
|
input: "text";
|
|
@@ -439,7 +481,7 @@ declare function defineQuest<T extends Record<string, z.ZodType>, const G extend
|
|
|
439
481
|
budgets: {
|
|
440
482
|
id: string;
|
|
441
483
|
scope: "member" | "project";
|
|
442
|
-
period: "lifetime" | "day";
|
|
484
|
+
period: "lifetime" | "day" | "week";
|
|
443
485
|
limit: number;
|
|
444
486
|
cost: number | {
|
|
445
487
|
balance: string;
|
|
@@ -460,4 +502,4 @@ declare function defineQuest<T extends Record<string, z.ZodType>, const G extend
|
|
|
460
502
|
* Console instances receive independent quest identities and pinned versions. */
|
|
461
503
|
declare const defineQuestType: typeof defineQuest;
|
|
462
504
|
|
|
463
|
-
export { type EvaluationContext, automatic, budget, completed, decision, defineQuest, defineQuestType, defineTieredReward, discordRole, evaluators, evidence, keyed, manual, once, points, staffHandover, untracked };
|
|
505
|
+
export { type EvaluationContext, TrackerTriggerContext, WalletBalance, WalletBalanceQuery, automatic, budget, completed, decision, defineQuest, defineQuestType, defineTieredReward, discordRole, evaluators, evidence, keyed, manual, once, points, staffHandover, untracked };
|
package/dist/authoring.js
CHANGED
|
@@ -2,8 +2,11 @@ import {
|
|
|
2
2
|
authoringKey,
|
|
3
3
|
defineEngagementReward,
|
|
4
4
|
defineLeaderboard,
|
|
5
|
-
defineReferral
|
|
6
|
-
|
|
5
|
+
defineReferral,
|
|
6
|
+
formatUnits,
|
|
7
|
+
parseUnits
|
|
8
|
+
} from "./chunk-AKB266O5.js";
|
|
9
|
+
import "./chunk-D6BX627V.js";
|
|
7
10
|
import {
|
|
8
11
|
admittedContentSchema,
|
|
9
12
|
budgetSchema,
|
|
@@ -28,9 +31,11 @@ import {
|
|
|
28
31
|
textOptionsSchema,
|
|
29
32
|
tierRewardSchema,
|
|
30
33
|
tieredRewardDefinitionSchema,
|
|
34
|
+
trackerTriggerContextSchema,
|
|
35
|
+
trackerTriggerPolicySchema,
|
|
31
36
|
urlOptionsSchema,
|
|
32
37
|
x
|
|
33
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-IXLY3A7B.js";
|
|
34
39
|
|
|
35
40
|
// src/authoring.ts
|
|
36
41
|
import { z } from "zod";
|
|
@@ -63,10 +68,31 @@ function manual(options) {
|
|
|
63
68
|
...options?.actor ? { actor: options.actor } : {}
|
|
64
69
|
};
|
|
65
70
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
71
|
+
function automatic(input) {
|
|
72
|
+
if (!input) {
|
|
73
|
+
return { kind: "automatic" };
|
|
74
|
+
}
|
|
75
|
+
if ("tracker" in input) {
|
|
76
|
+
const { tracker, beneficiary = "author" } = input;
|
|
77
|
+
if (beneficiary === "replied-to" && tracker.source.kind !== "x-search") {
|
|
78
|
+
throw new Error('"replied-to" requires an X tracker');
|
|
79
|
+
}
|
|
80
|
+
if (tracker.source.kind === "custom" && tracker.source.authors !== "wallet") {
|
|
81
|
+
throw new Error(
|
|
82
|
+
'Tracker triggers need attributable authors: use customSource(namespace, { authors: "wallet" })'
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
kind: "automatic",
|
|
87
|
+
tracker: trackerTriggerPolicySchema.parse({
|
|
88
|
+
tracker: tracker.key,
|
|
89
|
+
source: tracker.source.kind,
|
|
90
|
+
beneficiary
|
|
91
|
+
})
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
return { kind: "automatic", observation: input };
|
|
95
|
+
}
|
|
70
96
|
var budget = (definition) => budgetSchema.parse(definition);
|
|
71
97
|
var keyed = (key) => ({ kind: "keyed", key });
|
|
72
98
|
var completed = (quest) => ({
|
|
@@ -134,6 +160,10 @@ function defineQuest(definition) {
|
|
|
134
160
|
if (definition.performance && !contentTrigger) {
|
|
135
161
|
throw new Error("Performance requires a content trigger");
|
|
136
162
|
}
|
|
163
|
+
const trackerTrigger = definition.trigger.kind === "automatic" && definition.trigger.tracker !== void 0;
|
|
164
|
+
if (trackerTrigger && definition.completion.kind === "streak") {
|
|
165
|
+
throw new Error("Tracker triggers complete once() or keyed()");
|
|
166
|
+
}
|
|
137
167
|
const contentCompletion = "perContent" in definition.completion;
|
|
138
168
|
if (contentTrigger !== contentCompletion) {
|
|
139
169
|
throw new Error(
|
|
@@ -198,6 +228,7 @@ function defineQuest(definition) {
|
|
|
198
228
|
describe,
|
|
199
229
|
async evaluate(ctx) {
|
|
200
230
|
const settings2 = definition.settings.parse(ctx.settings);
|
|
231
|
+
const tracker = trackerTrigger ? trackerTriggerContextSchema.parse(ctx.tracker) : null;
|
|
201
232
|
if (ctx.performance) {
|
|
202
233
|
if (!definition.performance) {
|
|
203
234
|
throw new Error("Quest has no performance evaluator");
|
|
@@ -235,6 +266,7 @@ function defineQuest(definition) {
|
|
|
235
266
|
input: ctx.input,
|
|
236
267
|
content: contentTrigger ? admittedContentSchema.parse(ctx.content) : null,
|
|
237
268
|
observation: ctx.observation ?? null,
|
|
269
|
+
tracker,
|
|
238
270
|
eligibleAt: ctx.eligibleAt,
|
|
239
271
|
review: ctx.review,
|
|
240
272
|
trackers: ctx.trackers,
|
|
@@ -253,7 +285,12 @@ function defineQuest(definition) {
|
|
|
253
285
|
result.kind === "accept" || result.kind === "review" ? {
|
|
254
286
|
...result,
|
|
255
287
|
rewards: result.rewards ?? ctx.rewards,
|
|
256
|
-
...definition.completion.kind === "keyed" ? {
|
|
288
|
+
...definition.completion.kind === "keyed" ? {
|
|
289
|
+
completionKey: definition.completion.key({
|
|
290
|
+
...ctx,
|
|
291
|
+
tracker
|
|
292
|
+
})
|
|
293
|
+
} : {}
|
|
257
294
|
} : result
|
|
258
295
|
);
|
|
259
296
|
}
|
|
@@ -278,15 +315,18 @@ export {
|
|
|
278
315
|
discordRole,
|
|
279
316
|
evaluators,
|
|
280
317
|
evidence,
|
|
318
|
+
formatUnits,
|
|
281
319
|
keyed,
|
|
282
320
|
manual,
|
|
283
321
|
once,
|
|
322
|
+
parseUnits,
|
|
284
323
|
perContent,
|
|
285
324
|
pointLedgers,
|
|
286
325
|
points,
|
|
287
326
|
settings,
|
|
288
327
|
staffHandover,
|
|
289
328
|
streak,
|
|
329
|
+
trackerTriggerContextSchema,
|
|
290
330
|
untracked,
|
|
291
331
|
x
|
|
292
332
|
};
|