@domino-sdk/relay 0.17.1 → 0.18.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 +48 -12
- package/dist/authoring.js +64 -7
- package/dist/browser.d.ts +503 -202
- package/dist/browser.js +5 -5
- package/dist/chunk-23ZZTCDK.js +1511 -0
- package/dist/{chunk-GEJK7LMK.js → chunk-6GH4NC2T.js} +1 -1
- package/dist/{chunk-XNS25KST.js → chunk-FBOW2TLN.js} +265 -272
- package/dist/{chunk-MK2E36HR.js → chunk-MVDIVWR5.js} +1 -1
- package/dist/{chunk-TI22MU2X.js → chunk-TQUK4DIW.js} +85 -10
- package/dist/index.d.ts +1299 -337
- package/dist/index.js +110 -26
- package/dist/portal-proxy.js +5 -3
- package/dist/react/index.d.ts +437 -126
- package/dist/react/index.js +5 -5
- package/dist/schema.d.ts +332 -41
- package/dist/schema.js +7 -1
- package/dist/{submission-input-Cktvl71b.d.ts → submission-input-DWlvrAQY.d.ts} +829 -8
- package/package.json +1 -1
- package/dist/chunk-YUAE6PFY.js +0 -1048
package/dist/authoring.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { O as Observation, T as TrackerReader, X as XReader, D as DiscordMember, a as DiscordMessage, W as WalletConnection, S as SolanaBalance, o as observationTriggerSchema, B as Budget,
|
|
2
|
-
export {
|
|
1
|
+
import { A as AdmittedContent, O as Observation, T as TrackerReader, X as XReader, D as DiscordMember, a as DiscordMessage, W as WalletConnection, S as SolanaBalance, o as observationTriggerSchema, B as Budget, b as AuthoringIdentity, C as ContentMetric, I as IntegrationProvider, c as StreakPolicy, d as TextEvidence, U as UrlEvidence, e as TextOptions, f as UrlOptions } from './submission-input-DWlvrAQY.js';
|
|
2
|
+
export { g as content, h as customSource, i as defineEngagementReward, j as defineLeaderboard, k as defineReferral, l as defineTracker, m as discord, p as perContent, n as pointLedgers, s as settings, q as streak, x } from './submission-input-DWlvrAQY.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { TextReviewInput, TextResult, PhotoResult, rewardSchema, triggerSchema, QuestPresentation, QuizEvidence, Decision, TieredRewardDefinition } from './schema.js';
|
|
5
5
|
|
|
@@ -78,6 +78,7 @@ declare const keyed: (key: (ctx: {
|
|
|
78
78
|
member: {
|
|
79
79
|
id: string;
|
|
80
80
|
};
|
|
81
|
+
content?: AdmittedContent | null;
|
|
81
82
|
observation: Observation | null;
|
|
82
83
|
eligibleAt: number;
|
|
83
84
|
}) => string) => {
|
|
@@ -86,6 +87,7 @@ declare const keyed: (key: (ctx: {
|
|
|
86
87
|
member: {
|
|
87
88
|
id: string;
|
|
88
89
|
};
|
|
90
|
+
content?: AdmittedContent | null;
|
|
89
91
|
observation: Observation | null;
|
|
90
92
|
eligibleAt: number;
|
|
91
93
|
}) => string;
|
|
@@ -157,6 +159,7 @@ type EvaluationContext<T, I = {
|
|
|
157
159
|
id: string;
|
|
158
160
|
};
|
|
159
161
|
input: I;
|
|
162
|
+
content: AdmittedContent | null;
|
|
160
163
|
observation: Observation | null;
|
|
161
164
|
eligibleAt: number;
|
|
162
165
|
trackers: TrackerReader;
|
|
@@ -206,7 +209,10 @@ type QuestInput<T extends Trigger> = T extends {
|
|
|
206
209
|
} ? TextEvidence : T extends {
|
|
207
210
|
input: "url";
|
|
208
211
|
} ? UrlEvidence : Record<string, never>;
|
|
209
|
-
declare function defineQuest<T extends Record<string, z.ZodType>, const G extends Trigger
|
|
212
|
+
declare function defineQuest<T extends Record<string, z.ZodType>, const G extends Trigger, const M extends readonly [ContentMetric, ...ContentMetric[]] = readonly [
|
|
213
|
+
ContentMetric,
|
|
214
|
+
...ContentMetric[]
|
|
215
|
+
]>(definition: AuthoringIdentity & {
|
|
210
216
|
title: string | ((ctx: {
|
|
211
217
|
settings: z.output<z.ZodObject<T>>;
|
|
212
218
|
}) => string);
|
|
@@ -229,6 +235,21 @@ declare function defineQuest<T extends Record<string, z.ZodType>, const G extend
|
|
|
229
235
|
settings: z.output<z.ZodObject<T>>;
|
|
230
236
|
}) => Reward[]);
|
|
231
237
|
evaluate?: Evaluator<z.output<z.ZodObject<T>>, QuestInput<G>>;
|
|
238
|
+
performance?: G extends {
|
|
239
|
+
content: unknown;
|
|
240
|
+
} ? {
|
|
241
|
+
metrics: M;
|
|
242
|
+
maxAgeMs?: number;
|
|
243
|
+
evaluate: (ctx: {
|
|
244
|
+
settings: z.output<z.ZodObject<T>>;
|
|
245
|
+
member: {
|
|
246
|
+
id: string;
|
|
247
|
+
};
|
|
248
|
+
content: AdmittedContent;
|
|
249
|
+
metrics: Record<M[number], number>;
|
|
250
|
+
observedAt: number;
|
|
251
|
+
}) => Outcome | Promise<Outcome>;
|
|
252
|
+
} : never;
|
|
232
253
|
}): {
|
|
233
254
|
key: string;
|
|
234
255
|
/** @deprecated Authoring key alias. Use key. */
|
|
@@ -363,6 +384,22 @@ declare function defineQuest<T extends Record<string, z.ZodType>, const G extend
|
|
|
363
384
|
})[];
|
|
364
385
|
humanReview: boolean;
|
|
365
386
|
trigger: {
|
|
387
|
+
kind: "automatic";
|
|
388
|
+
observation?: {
|
|
389
|
+
source: string;
|
|
390
|
+
type: string;
|
|
391
|
+
} | undefined;
|
|
392
|
+
content?: {
|
|
393
|
+
tracker: string;
|
|
394
|
+
window: {
|
|
395
|
+
start: number;
|
|
396
|
+
end?: number | undefined;
|
|
397
|
+
};
|
|
398
|
+
enrollment: "required" | "none";
|
|
399
|
+
posts: "after-enrollment" | "since-start";
|
|
400
|
+
historical: "staff" | "automatic" | "claim";
|
|
401
|
+
} | undefined;
|
|
402
|
+
} | {
|
|
366
403
|
kind: "manual";
|
|
367
404
|
input: "text";
|
|
368
405
|
constraints: {
|
|
@@ -370,7 +407,7 @@ declare function defineQuest<T extends Record<string, z.ZodType>, const G extend
|
|
|
370
407
|
minLength: number;
|
|
371
408
|
maxLength: number;
|
|
372
409
|
};
|
|
373
|
-
actor?: "
|
|
410
|
+
actor?: "member" | "staff" | undefined;
|
|
374
411
|
} | {
|
|
375
412
|
kind: "manual";
|
|
376
413
|
input: "url";
|
|
@@ -378,17 +415,11 @@ declare function defineQuest<T extends Record<string, z.ZodType>, const G extend
|
|
|
378
415
|
required: boolean;
|
|
379
416
|
allowedHosts?: string[] | undefined;
|
|
380
417
|
};
|
|
381
|
-
actor?: "
|
|
418
|
+
actor?: "member" | "staff" | undefined;
|
|
382
419
|
} | {
|
|
383
420
|
kind: "manual";
|
|
384
421
|
input: "photo" | "quiz" | "none";
|
|
385
|
-
actor?: "
|
|
386
|
-
} | {
|
|
387
|
-
kind: "automatic";
|
|
388
|
-
observation?: {
|
|
389
|
-
source: string;
|
|
390
|
-
type: string;
|
|
391
|
-
} | undefined;
|
|
422
|
+
actor?: "member" | "staff" | undefined;
|
|
392
423
|
};
|
|
393
424
|
requires: {
|
|
394
425
|
quest: string;
|
|
@@ -413,10 +444,15 @@ declare function defineQuest<T extends Record<string, z.ZodType>, const G extend
|
|
|
413
444
|
balance: string;
|
|
414
445
|
};
|
|
415
446
|
}[];
|
|
447
|
+
performance?: {
|
|
448
|
+
metrics: ("likes" | "replies" | "reposts" | "quotes" | "views" | "bookmarks")[];
|
|
449
|
+
maxAgeMs: number;
|
|
450
|
+
} | undefined;
|
|
416
451
|
};
|
|
417
452
|
evaluate(ctx: EvaluationContext<unknown, QuestInput<G>> & {
|
|
418
453
|
rewards: Reward[];
|
|
419
454
|
humanReview: boolean;
|
|
455
|
+
performance?: unknown;
|
|
420
456
|
}): Promise<Decision>;
|
|
421
457
|
};
|
|
422
458
|
/** Publish this artifact as a reusable type. Its key names the type;
|
package/dist/authoring.js
CHANGED
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
2
|
authoringKey,
|
|
3
|
-
|
|
3
|
+
defineEngagementReward,
|
|
4
4
|
defineLeaderboard,
|
|
5
|
-
defineReferral
|
|
6
|
-
|
|
7
|
-
x
|
|
8
|
-
} from "./chunk-XNS25KST.js";
|
|
5
|
+
defineReferral
|
|
6
|
+
} from "./chunk-FBOW2TLN.js";
|
|
9
7
|
import {
|
|
8
|
+
admittedContentSchema,
|
|
10
9
|
budgetSchema,
|
|
10
|
+
content,
|
|
11
|
+
contentPerformancePolicySchema,
|
|
12
|
+
contentPerformanceSnapshotSchema,
|
|
13
|
+
customSource,
|
|
11
14
|
decisionSchema,
|
|
15
|
+
defineTracker,
|
|
12
16
|
discord,
|
|
13
17
|
integrationRewardSchema,
|
|
14
18
|
parseSettings,
|
|
19
|
+
perContent,
|
|
15
20
|
pointLedgers,
|
|
16
21
|
pointsRewardSchema,
|
|
17
22
|
questDescriptionSchema,
|
|
@@ -23,8 +28,9 @@ import {
|
|
|
23
28
|
textOptionsSchema,
|
|
24
29
|
tierRewardSchema,
|
|
25
30
|
tieredRewardDefinitionSchema,
|
|
26
|
-
urlOptionsSchema
|
|
27
|
-
|
|
31
|
+
urlOptionsSchema,
|
|
32
|
+
x
|
|
33
|
+
} from "./chunk-23ZZTCDK.js";
|
|
28
34
|
|
|
29
35
|
// src/authoring.ts
|
|
30
36
|
import { z } from "zod";
|
|
@@ -124,6 +130,16 @@ var evaluators = {
|
|
|
124
130
|
};
|
|
125
131
|
function defineQuest(definition) {
|
|
126
132
|
const key = authoringKey(definition);
|
|
133
|
+
const contentTrigger = definition.trigger.kind === "automatic" && definition.trigger.content !== void 0;
|
|
134
|
+
if (definition.performance && !contentTrigger) {
|
|
135
|
+
throw new Error("Performance requires a content trigger");
|
|
136
|
+
}
|
|
137
|
+
const contentCompletion = "perContent" in definition.completion;
|
|
138
|
+
if (contentTrigger !== contentCompletion) {
|
|
139
|
+
throw new Error(
|
|
140
|
+
"Content triggers require perContent completion, and perContent requires a content trigger"
|
|
141
|
+
);
|
|
142
|
+
}
|
|
127
143
|
if (definition.completion.kind === "streak" && (definition.trigger.kind !== "automatic" || !definition.trigger.observation)) {
|
|
128
144
|
throw new Error("Streaks require an automatic observation trigger");
|
|
129
145
|
}
|
|
@@ -152,6 +168,12 @@ function defineQuest(definition) {
|
|
|
152
168
|
rewards,
|
|
153
169
|
humanReview: definition.review?.({ settings: settings2 })?.enabled ?? true,
|
|
154
170
|
trigger: definition.trigger,
|
|
171
|
+
...definition.performance ? {
|
|
172
|
+
performance: contentPerformancePolicySchema.parse({
|
|
173
|
+
metrics: definition.performance.metrics,
|
|
174
|
+
maxAgeMs: definition.performance.maxAgeMs
|
|
175
|
+
})
|
|
176
|
+
} : {},
|
|
155
177
|
integrations: [
|
|
156
178
|
.../* @__PURE__ */ new Set([
|
|
157
179
|
...definition.integrations ?? [],
|
|
@@ -176,10 +198,42 @@ function defineQuest(definition) {
|
|
|
176
198
|
describe,
|
|
177
199
|
async evaluate(ctx) {
|
|
178
200
|
const settings2 = definition.settings.parse(ctx.settings);
|
|
201
|
+
if (ctx.performance) {
|
|
202
|
+
if (!definition.performance) {
|
|
203
|
+
throw new Error("Quest has no performance evaluator");
|
|
204
|
+
}
|
|
205
|
+
const sample = contentPerformanceSnapshotSchema.parse(ctx.performance);
|
|
206
|
+
const metrics = z.record(
|
|
207
|
+
z.enum(definition.performance.metrics),
|
|
208
|
+
z.number().int().safe().nonnegative()
|
|
209
|
+
).parse(sample.metrics);
|
|
210
|
+
const result2 = await definition.performance.evaluate({
|
|
211
|
+
settings: settings2,
|
|
212
|
+
member: ctx.member,
|
|
213
|
+
content: admittedContentSchema.parse(ctx.content),
|
|
214
|
+
metrics,
|
|
215
|
+
observedAt: sample.observedAt
|
|
216
|
+
});
|
|
217
|
+
if (!result2) {
|
|
218
|
+
throw new Error("Performance evaluator returned no decision");
|
|
219
|
+
}
|
|
220
|
+
return decisionSchema.parse(
|
|
221
|
+
result2.kind === "accept" ? {
|
|
222
|
+
kind: "accept",
|
|
223
|
+
rewards: sample.rewards,
|
|
224
|
+
completionKey: admittedContentSchema.parse(ctx.content).completionKey
|
|
225
|
+
} : result2.kind === "review" && ctx.humanReview ? {
|
|
226
|
+
kind: "review",
|
|
227
|
+
reason: result2.reason,
|
|
228
|
+
rewards: sample.rewards
|
|
229
|
+
} : { kind: "reject", reason: result2.reason }
|
|
230
|
+
);
|
|
231
|
+
}
|
|
179
232
|
const result = definition.evaluate ? await definition.evaluate({
|
|
180
233
|
settings: settings2,
|
|
181
234
|
member: ctx.member,
|
|
182
235
|
input: ctx.input,
|
|
236
|
+
content: contentTrigger ? admittedContentSchema.parse(ctx.content) : null,
|
|
183
237
|
observation: ctx.observation ?? null,
|
|
184
238
|
eligibleAt: ctx.eligibleAt,
|
|
185
239
|
review: ctx.review,
|
|
@@ -209,8 +263,10 @@ export {
|
|
|
209
263
|
automatic,
|
|
210
264
|
budget,
|
|
211
265
|
completed,
|
|
266
|
+
content,
|
|
212
267
|
customSource,
|
|
213
268
|
decision,
|
|
269
|
+
defineEngagementReward,
|
|
214
270
|
defineLeaderboard,
|
|
215
271
|
defineQuest,
|
|
216
272
|
defineQuestType,
|
|
@@ -224,6 +280,7 @@ export {
|
|
|
224
280
|
keyed,
|
|
225
281
|
manual,
|
|
226
282
|
once,
|
|
283
|
+
perContent,
|
|
227
284
|
pointLedgers,
|
|
228
285
|
points,
|
|
229
286
|
settings,
|