@domino-sdk/relay 1.0.0-next.14 → 1.0.0-next.16
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/README.md +1 -1
- package/dist/authoring.d.ts +61 -65
- package/dist/authoring.js +64 -45
- package/dist/avatar.d.ts +2 -2
- package/dist/browser.d.ts +102 -142
- package/dist/browser.js +6 -6
- package/dist/{integrations-EjQzIApL.d.ts → capability-error-DO6Q0Qwe.d.ts} +107 -5
- package/dist/{catalog-C85V1NgW.d.ts → catalog-CVXUHxiO.d.ts} +12 -99
- package/dist/{chunk-K4ANDR6G.js → chunk-76F4LSFP.js} +2 -2
- package/dist/{chunk-II7DRZSL.js → chunk-CYD6QMHU.js} +1 -1
- package/dist/chunk-FJ6O44NE.js +51 -0
- package/dist/{chunk-FWRP6YAQ.js → chunk-G3YSBMJH.js} +2 -2
- package/dist/{chunk-CRNQP7NV.js → chunk-J4OYDYJE.js} +693 -676
- package/dist/{chunk-TLGCEVG5.js → chunk-J52HD4AA.js} +1 -1
- package/dist/{chunk-MNQI35OG.js → chunk-JZ74VJX4.js} +13 -8
- package/dist/chunk-MC6V6VMG.js +49 -0
- package/dist/{chunk-HAOW4ERY.js → chunk-NH5ZBM6O.js} +4 -4
- package/dist/{chunk-F5OCJE52.js → chunk-RCBJBFLC.js} +4 -4
- package/dist/{chunk-FXYJ4OMX.js → chunk-WMTROSYF.js} +1 -1
- package/dist/{client-Bf9PNUIi.d.ts → client-DG9qAB4o.d.ts} +10 -50
- package/dist/{deployments-gbA8IZCK.d.ts → deployments-Ds34v0M8.d.ts} +105 -121
- package/dist/{images-BG4pdO4y.d.ts → images-CRxHUuG5.d.ts} +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.js +5 -5
- package/dist/internal.d.ts +13 -4
- package/dist/internal.js +10 -4
- package/dist/portal-proxy.js +2 -2
- package/dist/react/index.d.ts +12 -60
- package/dist/react/index.js +7 -7
- package/dist/{schema-BF_TQsmT.d.ts → schema-C4F2K9cm.d.ts} +9 -74
- package/dist/schema.d.ts +9 -10
- package/dist/schema.js +24 -16
- package/dist/server/index.d.ts +126 -234
- package/dist/server/index.js +17 -22
- package/dist/submission-input-CkmBmSL1.d.ts +167 -0
- package/dist/{trackers-W7nRdRr7.d.ts → trackers-Cg2MzFEf.d.ts} +79 -19
- package/dist/{wallet-BtiG0Xhr.d.ts → wallet-CYK5E2wj.d.ts} +23 -1
- package/package.json +1 -1
- package/dist/observations-CQ6IcNuQ.d.ts +0 -90
- package/dist/submission-input-CccwAl5Z.d.ts +0 -83
- package/dist/{profiles-BtOXMGcC.d.ts → profiles-md0g5fjx.d.ts} +1 -1
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ pnpm add @domino-sdk/relay
|
|
|
13
13
|
| `@domino-sdk/relay/react` | React hooks over the browser client |
|
|
14
14
|
| `@domino-sdk/relay/avatar` | Generated default avatars (`avatarSrc`, `defaultAvatar`) |
|
|
15
15
|
| `@domino-sdk/relay/authoring` | Quest, tracker, leaderboard, referral and engagement definitions, and evaluator types |
|
|
16
|
-
| `@domino-sdk/relay/schema` | Zod schemas of Relay's API bodies, deployments
|
|
16
|
+
| `@domino-sdk/relay/schema` | Zod schemas of Relay's API bodies, deployments and tracker records |
|
|
17
17
|
| `@domino-sdk/relay/build` | Bundling authored modules; needs `esbuild` installed |
|
|
18
18
|
| `@domino-sdk/relay/portal-proxy` | Server proxies and hosted app Workers |
|
|
19
19
|
| `@domino-sdk/relay/vite` | The Vite plugin that keeps server code out of the browser build |
|
package/dist/authoring.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export { z } from 'zod';
|
|
3
3
|
import { e as ContentPolicy, C as ContentMetric, E as EngagementBudget, T as leaderboardDefinitionSchema, a9 as referralAuthoringSchema, A as AdmittedContent } from './referrals-KQfP4pBf.js';
|
|
4
|
+
import { q as discordMessagesSourceSchema, e as DiscordMessageData, f as DiscordMessageTextData, s as discordReactionsSourceSchema, g as DiscordReactionData, h as DiscordReader, T as TextEvidence, U as UrlEvidence, b as TextOptions, c as UrlOptions } from './submission-input-CkmBmSL1.js';
|
|
4
5
|
import { Q as QuizContent, a as StreakPolicy } from './streaks-CWyq8Px5.js';
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
export { E as EvmChainId, r as isEvmChainId } from './wallet-BtiG0Xhr.js';
|
|
6
|
+
import { c as ResourceSource, S as Setting, h as XReader, B as Budget, I as IntegerSettings, b as IntegrationProvider } from './capability-error-DO6Q0Qwe.js';
|
|
7
|
+
export { G as CapabilityError, C as CapabilityErrorCode, j as capabilityErrorCodes } from './capability-error-DO6Q0Qwe.js';
|
|
8
|
+
import { j as TrackerDefinition, I as IdentityKind, L as customSourceSchema, H as WithRecordData, u as TrackerSource, a3 as trackerDefinitionSchema, T as Tracker, g as TrackerData, ax as xSearchSourceSchema, X as XTweet, x as TrackerTriggerContext, z as TrackerTriggerPolicy, r as TrackerReader, W as Where, y as TrackerTriggerMode, G as WhereSetting } from './trackers-Cg2MzFEf.js';
|
|
9
|
+
export { i as TrackerDataSchema, m as TrackerPage, q as TrackerReadQuery, az as trackerDataSchema, an as trackerTriggerContextSchema } from './trackers-Cg2MzFEf.js';
|
|
10
|
+
import { e as ImageReader } from './images-CRxHUuG5.js';
|
|
11
|
+
import { n as TextReviewInput, m as TextResult, P as PhotoResult, ag as rewardSchema, av as triggerSchema, Q as QuestPresentation, a as QuestProfile, b as QuizEvidence, D as Decision, o as TieredRewardDefinition } from './schema-C4F2K9cm.js';
|
|
12
|
+
import { l as WalletReader } from './wallet-CYK5E2wj.js';
|
|
13
|
+
export { E as EvmChainId, i as WalletBalance, j as WalletBalanceQuery, s as isEvmChainId } from './wallet-CYK5E2wj.js';
|
|
14
14
|
export { f as formatUnits, p as parseUnits } from './units-CwgsPB_r.js';
|
|
15
15
|
|
|
16
16
|
/** Legacy `id` names an authoring key, never a server resource ID. */
|
|
@@ -33,7 +33,7 @@ declare function content(tracker: TrackerDefinition, policy?: Partial<Pick<Conte
|
|
|
33
33
|
};
|
|
34
34
|
enrollment: "required" | "none";
|
|
35
35
|
posts: "after-enrollment" | "since-start";
|
|
36
|
-
historical: "
|
|
36
|
+
historical: "automatic" | "claim" | "staff";
|
|
37
37
|
};
|
|
38
38
|
};
|
|
39
39
|
declare function perContent(): {
|
|
@@ -68,7 +68,7 @@ declare function defineEngagementReward<const M extends readonly [ContentMetric,
|
|
|
68
68
|
maxAgeMs: number;
|
|
69
69
|
budgets: {
|
|
70
70
|
scope: "member" | "project";
|
|
71
|
-
period: "
|
|
71
|
+
period: "lifetime" | "day" | "week" | "month";
|
|
72
72
|
limit: number;
|
|
73
73
|
}[];
|
|
74
74
|
};
|
|
@@ -80,8 +80,8 @@ declare function defineEngagementReward<const M extends readonly [ContentMetric,
|
|
|
80
80
|
/**
|
|
81
81
|
* One milestone per quest, after `days` consecutive project calendar days with an accepted
|
|
82
82
|
* attempt. Multiple accepted attempts occupy one day. The day comes from the attempt's trusted
|
|
83
|
-
* occurrence time: a tracker record's
|
|
84
|
-
*
|
|
83
|
+
* occurrence time: a tracker record's `occurredAt` for `automatic({ tracker })`, and the
|
|
84
|
+
* submission's admission time for `manual()`, so a manual streak counts the days a member
|
|
85
85
|
* submitted. Days begin at midnight in the project timezone (`calendar.timeZone` in relay.json, or
|
|
86
86
|
* Console settings). Not available on content quests or prerequisite-only `automatic()`.
|
|
87
87
|
*/
|
|
@@ -252,7 +252,33 @@ declare function defineTracker<S extends TrackerSource>(input: Omit<z.input<type
|
|
|
252
252
|
type ChannelTypes = Extract<ResourceSource, {
|
|
253
253
|
resource: "channel";
|
|
254
254
|
}>["types"];
|
|
255
|
+
type DiscordMessagesSource = z.output<typeof discordMessagesSourceSchema>;
|
|
256
|
+
/**
|
|
257
|
+
* Messages members post in the project's Discord server. The Discord gateway writes one record per
|
|
258
|
+
* message, keyed by the message ID: its `author` is the poster's Discord account, `occurredAt` is
|
|
259
|
+
* when the message arrived, and `data` holds the channel, the replied-to message and the post time.
|
|
260
|
+
* A record is stored only when its author has linked that Discord account in the project, and its
|
|
261
|
+
* text only with `text: true`.
|
|
262
|
+
*/
|
|
263
|
+
declare function messages(options?: {
|
|
264
|
+
text?: false;
|
|
265
|
+
}): DiscordMessagesSource & WithRecordData<DiscordMessageData>;
|
|
266
|
+
declare function messages(options: {
|
|
267
|
+
text: true;
|
|
268
|
+
}): DiscordMessagesSource & WithRecordData<DiscordMessageTextData>;
|
|
269
|
+
/**
|
|
270
|
+
* Reactions members add in the project's Discord server. The Discord gateway writes one record per
|
|
271
|
+
* reaction, keyed by message, reactor and emoji: its `author` is the reactor's Discord account and
|
|
272
|
+
* its `messageAuthor` account the message's author, when Discord names it. `occurredAt` is when
|
|
273
|
+
* the reaction arrived. A record is stored only when the reactor or the message author has linked
|
|
274
|
+
* that Discord account in the project. Pay the message author with
|
|
275
|
+
* `automatic({ tracker, beneficiary: "messageAuthor" })`; reactions to one's own message are
|
|
276
|
+
* skipped.
|
|
277
|
+
*/
|
|
278
|
+
declare function reactions(): z.output<typeof discordReactionsSourceSchema> & WithRecordData<DiscordReactionData>;
|
|
255
279
|
declare const discord: {
|
|
280
|
+
messages: typeof messages;
|
|
281
|
+
reactions: typeof reactions;
|
|
256
282
|
roles(options?: {
|
|
257
283
|
assignable?: boolean;
|
|
258
284
|
}): ResourceSource;
|
|
@@ -370,8 +396,9 @@ type TrackerTriggerInput<T extends Tracker = Tracker, W extends Where<TrackerDat
|
|
|
370
396
|
tracker: T;
|
|
371
397
|
/**
|
|
372
398
|
* Which observations fire. `"new-record"`: each record's first observation (the default for X
|
|
373
|
-
* trackers, where it means each newly collected post
|
|
374
|
-
* that becomes its record's current one (the default for
|
|
399
|
+
* and Discord trackers, where it means each newly collected post, message or reaction).
|
|
400
|
+
* `"new-observation"`: each observation that becomes its record's current one (the default for
|
|
401
|
+
* custom trackers). `"data-changed"`: a
|
|
375
402
|
* new record, or a current observation whose `data` differs from the previous one.
|
|
376
403
|
*/
|
|
377
404
|
on?: TrackerTriggerMode;
|
|
@@ -384,8 +411,9 @@ type TrackerTriggerInput<T extends Tracker = Tracker, W extends Where<TrackerDat
|
|
|
384
411
|
where?: W;
|
|
385
412
|
/**
|
|
386
413
|
* The record account whose member the quest pays: `"author"` (the default), `"inReplyTo"` on
|
|
387
|
-
* an X tracker, or a named account a custom
|
|
388
|
-
* account is the record's author account or
|
|
414
|
+
* an X tracker, `"messageAuthor"` on a Discord reactions tracker, or a named account a custom
|
|
415
|
+
* source declares in `accounts`. Skipped when that account is the record's author account or
|
|
416
|
+
* belongs to the author's member, such as a reaction to one's own message.
|
|
389
417
|
*/
|
|
390
418
|
beneficiary?: string;
|
|
391
419
|
};
|
|
@@ -408,17 +436,13 @@ type TriggerSettings<G> = G extends {
|
|
|
408
436
|
readonly [triggerSettings]?: infer S;
|
|
409
437
|
} ? unknown extends S ? never : Exclude<S, undefined> : never;
|
|
410
438
|
/**
|
|
411
|
-
* An automatic quest. With no argument it runs once its prerequisites are complete; with
|
|
412
|
-
*
|
|
413
|
-
*
|
|
439
|
+
* An automatic quest. With no argument it runs once its prerequisites are complete; with a tracker
|
|
440
|
+
* it runs for each observation its firing mode and filter admit, for the member Relay attributes
|
|
441
|
+
* the beneficiary account to.
|
|
414
442
|
*/
|
|
415
443
|
declare function automatic(): {
|
|
416
444
|
kind: "automatic";
|
|
417
445
|
};
|
|
418
|
-
declare function automatic(observation: z.infer<typeof observationTriggerSchema>): {
|
|
419
|
-
kind: "automatic";
|
|
420
|
-
observation: z.infer<typeof observationTriggerSchema>;
|
|
421
|
-
};
|
|
422
446
|
declare function automatic<T extends Tracker, const W extends Where<TrackerData<T>> | undefined = undefined>(input: TrackerTriggerInput<T, W>): TrackerTrigger<TrackerData<T>, WhereSetting<W>>;
|
|
423
447
|
/**
|
|
424
448
|
* What a trigger `G` supplies under key `K`: `Present` when the trigger has it, null when it cannot,
|
|
@@ -429,8 +453,6 @@ type Supplied<G, K extends string, Present, Base> = unknown extends G ? Base | n
|
|
|
429
453
|
type ContextTracker<G> = Supplied<G, "tracker", TrackerTriggerContext<TriggerData<G>>, TrackerTriggerContext>;
|
|
430
454
|
/** `ctx.content` for a trigger: the admitted post for a content trigger, null for others. */
|
|
431
455
|
type ContextContent<G> = Supplied<G, "content", AdmittedContent, AdmittedContent>;
|
|
432
|
-
/** `ctx.observation` for a trigger: the observation for an observation trigger, null for others. */
|
|
433
|
-
type ContextObservation<G> = Supplied<G, "observation", Observation, Observation>;
|
|
434
456
|
/**
|
|
435
457
|
* What a `keyed()` completion key reads. TypeScript cannot carry the trigger into a completion
|
|
436
458
|
* built inline, so `tracker` stays nullable here; the evaluator's `ctx.tracker` is typed.
|
|
@@ -440,7 +462,6 @@ type KeyedContext = {
|
|
|
440
462
|
id: string;
|
|
441
463
|
};
|
|
442
464
|
content?: AdmittedContent | null;
|
|
443
|
-
observation: Observation | null;
|
|
444
465
|
/** The pinned tracker observation of a tracker-triggered quest; null for other triggers. */
|
|
445
466
|
tracker: TrackerTriggerContext | null;
|
|
446
467
|
eligibleAt: number;
|
|
@@ -450,7 +471,7 @@ type KeyedContext = {
|
|
|
450
471
|
declare const budget: (definition: Budget) => {
|
|
451
472
|
id: string;
|
|
452
473
|
scope: "member" | "project";
|
|
453
|
-
period: "
|
|
474
|
+
period: "lifetime" | "day" | "week" | "month";
|
|
454
475
|
limit: number;
|
|
455
476
|
cost: number | {
|
|
456
477
|
balance: string;
|
|
@@ -549,8 +570,8 @@ declare const decision: {
|
|
|
549
570
|
review: typeof review;
|
|
550
571
|
};
|
|
551
572
|
/**
|
|
552
|
-
* What an evaluator reads. `G` is the quest's trigger: `tracker
|
|
553
|
-
*
|
|
573
|
+
* What an evaluator reads. `G` is the quest's trigger: `tracker` and `content` are non-null for
|
|
574
|
+
* the trigger that supplies them and null otherwise. `G` defaults to `any`, which
|
|
554
575
|
* leaves them nullable and lets a shared evaluator, such as `evaluators.photo()`, fit every quest.
|
|
555
576
|
*/
|
|
556
577
|
type EvaluationContext<T, I = {
|
|
@@ -563,16 +584,14 @@ type EvaluationContext<T, I = {
|
|
|
563
584
|
input: I;
|
|
564
585
|
/** The admitted post of a content quest. */
|
|
565
586
|
content: ContextContent<G>;
|
|
566
|
-
/** The observation of an observation-triggered quest. */
|
|
567
|
-
observation: ContextObservation<G>;
|
|
568
587
|
/**
|
|
569
588
|
* The tracker observation that admitted this attempt, and the member and verified account it
|
|
570
589
|
* was attributed to. Present for a tracker trigger, with `record.data` of the tracker's type.
|
|
571
590
|
*/
|
|
572
591
|
tracker: ContextTracker<G>;
|
|
573
592
|
/**
|
|
574
|
-
* When the activity happened, in epoch milliseconds: the
|
|
575
|
-
*
|
|
593
|
+
* When the activity happened, in epoch milliseconds: the tracker record's occurrence time, else
|
|
594
|
+
* when the attempt was admitted. Budgets and daily keys use it.
|
|
576
595
|
*/
|
|
577
596
|
eligibleAt: number;
|
|
578
597
|
/**
|
|
@@ -592,27 +611,8 @@ type EvaluationContext<T, I = {
|
|
|
592
611
|
criteria: string;
|
|
593
612
|
}): Promise<PhotoResult>;
|
|
594
613
|
};
|
|
595
|
-
discord:
|
|
596
|
-
|
|
597
|
-
message(input: {
|
|
598
|
-
channelId: string;
|
|
599
|
-
messageId: string;
|
|
600
|
-
}): Promise<DiscordMessage | null>;
|
|
601
|
-
};
|
|
602
|
-
wallet: {
|
|
603
|
-
/** The member's newest linked Solana wallet. */
|
|
604
|
-
connection(): Promise<WalletConnection | null>;
|
|
605
|
-
/** SOL held by the newest linked Solana wallet. */
|
|
606
|
-
solanaBalance(): Promise<SolanaBalance | null>;
|
|
607
|
-
/** Every wallet the member has linked to this project, pinned once per attempt. */
|
|
608
|
-
list(): Promise<LinkedWallet[]>;
|
|
609
|
-
/**
|
|
610
|
-
* The native or token balance of the member's pinned linked wallets on one chain: all wallets of
|
|
611
|
-
* that family, or `address` (which must be one of them). No wallets gives `total: "0"` and
|
|
612
|
-
* `wallets: []`. Provider failures throw; they never read as a zero balance.
|
|
613
|
-
*/
|
|
614
|
-
balance(query: WalletBalanceQuery): Promise<WalletBalance>;
|
|
615
|
-
};
|
|
614
|
+
discord: DiscordReader;
|
|
615
|
+
wallet: WalletReader;
|
|
616
616
|
};
|
|
617
617
|
type Evaluator<T, I = {
|
|
618
618
|
photo: string;
|
|
@@ -836,10 +836,6 @@ declare function defineQuest<T extends Record<string, Setting>, const G extends
|
|
|
836
836
|
humanReview: boolean;
|
|
837
837
|
trigger: {
|
|
838
838
|
kind: "automatic";
|
|
839
|
-
observation?: {
|
|
840
|
-
source: string;
|
|
841
|
-
type: string;
|
|
842
|
-
} | undefined;
|
|
843
839
|
content?: {
|
|
844
840
|
tracker: string;
|
|
845
841
|
window: {
|
|
@@ -848,11 +844,11 @@ declare function defineQuest<T extends Record<string, Setting>, const G extends
|
|
|
848
844
|
};
|
|
849
845
|
enrollment: "required" | "none";
|
|
850
846
|
posts: "after-enrollment" | "since-start";
|
|
851
|
-
historical: "
|
|
847
|
+
historical: "automatic" | "claim" | "staff";
|
|
852
848
|
} | undefined;
|
|
853
849
|
tracker?: {
|
|
854
850
|
tracker: string;
|
|
855
|
-
source:
|
|
851
|
+
source: string;
|
|
856
852
|
beneficiary: string;
|
|
857
853
|
on?: "new-record" | "new-observation" | "data-changed" | undefined;
|
|
858
854
|
where?: {
|
|
@@ -910,7 +906,7 @@ declare function defineQuest<T extends Record<string, Setting>, const G extends
|
|
|
910
906
|
actor?: "member" | "staff" | undefined;
|
|
911
907
|
} | {
|
|
912
908
|
kind: "manual";
|
|
913
|
-
input: "
|
|
909
|
+
input: "none" | "quiz" | "photo";
|
|
914
910
|
actor?: "member" | "staff" | undefined;
|
|
915
911
|
};
|
|
916
912
|
requires: {
|
|
@@ -924,11 +920,11 @@ declare function defineQuest<T extends Record<string, Setting>, const G extends
|
|
|
924
920
|
} | {
|
|
925
921
|
kind: "keyed";
|
|
926
922
|
};
|
|
927
|
-
visibility: "
|
|
923
|
+
visibility: "visible" | "hidden";
|
|
928
924
|
budgets: {
|
|
929
925
|
id: string;
|
|
930
926
|
scope: "member" | "project";
|
|
931
|
-
period: "
|
|
927
|
+
period: "lifetime" | "day" | "week" | "month";
|
|
932
928
|
limit: number;
|
|
933
929
|
cost: number | {
|
|
934
930
|
balance: string;
|
|
@@ -952,4 +948,4 @@ declare function defineQuest<T extends Record<string, Setting>, const G extends
|
|
|
952
948
|
* Console instances receive independent quest identities and pinned versions. */
|
|
953
949
|
declare const defineQuestType: typeof defineQuest;
|
|
954
950
|
|
|
955
|
-
export { type EvaluationContext, ImageReader, type KeyedContext, type PerformanceOutcome, Setting, Tracker, TrackerData, TrackerReader, type TrackerTrigger, TrackerTriggerContext, type TrackerTriggerInput,
|
|
951
|
+
export { DiscordMessageData, DiscordMessageTextData, DiscordReactionData, DiscordReader, type EvaluationContext, ImageReader, type KeyedContext, type PerformanceOutcome, Setting, Tracker, TrackerData, TrackerReader, type TrackerTrigger, TrackerTriggerContext, type TrackerTriggerInput, WalletReader, Where, XReader, automatic, budget, completed, content, customSource, decision, defineEngagementReward, defineLeaderboard, defineQuest, defineQuestType, defineReferral, defineTieredReward, defineTracker, discord, discordRole, evaluators, evidence, keyed, manual, once, perContent, pointLedgers, points, settings, staffHandover, streak, untracked, x };
|
package/dist/authoring.js
CHANGED
|
@@ -2,6 +2,14 @@ import {
|
|
|
2
2
|
formatUnits,
|
|
3
3
|
parseUnits
|
|
4
4
|
} from "./chunk-V7UKZLHA.js";
|
|
5
|
+
import {
|
|
6
|
+
CapabilityError,
|
|
7
|
+
capabilityErrorCodes
|
|
8
|
+
} from "./chunk-MC6V6VMG.js";
|
|
9
|
+
import {
|
|
10
|
+
sourceDataSchema,
|
|
11
|
+
sourceRoles
|
|
12
|
+
} from "./chunk-FJ6O44NE.js";
|
|
5
13
|
import {
|
|
6
14
|
authoringKey,
|
|
7
15
|
engagementDefinitionSchema,
|
|
@@ -10,7 +18,7 @@ import {
|
|
|
10
18
|
isEvmChainId,
|
|
11
19
|
leaderboardAuthoringSchema,
|
|
12
20
|
referralAuthoringSchema
|
|
13
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-J52HD4AA.js";
|
|
14
22
|
import {
|
|
15
23
|
admittedContentSchema,
|
|
16
24
|
budgetSchema,
|
|
@@ -20,6 +28,8 @@ import {
|
|
|
20
28
|
customSourceSchema,
|
|
21
29
|
decisionSchema,
|
|
22
30
|
defaultTriggerMode,
|
|
31
|
+
discordMessagesSourceSchema,
|
|
32
|
+
discordReactionsSourceSchema,
|
|
23
33
|
identifier,
|
|
24
34
|
integrationRewardSchema,
|
|
25
35
|
parseSettings,
|
|
@@ -46,9 +56,8 @@ import {
|
|
|
46
56
|
urlOptionsSchema,
|
|
47
57
|
whereSchemaIssue,
|
|
48
58
|
whereSettings,
|
|
49
|
-
xAccountRoles,
|
|
50
59
|
xSearchSourceSchema
|
|
51
|
-
} from "./chunk-
|
|
60
|
+
} from "./chunk-J4OYDYJE.js";
|
|
52
61
|
|
|
53
62
|
// src/builders.ts
|
|
54
63
|
import { z } from "zod";
|
|
@@ -147,7 +156,18 @@ function isZodSchema(value) {
|
|
|
147
156
|
function defineTracker(input) {
|
|
148
157
|
return trackerDefinitionSchema.parse(input);
|
|
149
158
|
}
|
|
159
|
+
function messages(options = {}) {
|
|
160
|
+
return discordMessagesSourceSchema.parse({
|
|
161
|
+
kind: "discord-messages",
|
|
162
|
+
...options.text ? { text: true } : {}
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
function reactions() {
|
|
166
|
+
return discordReactionsSourceSchema.parse({ kind: "discord-reactions" });
|
|
167
|
+
}
|
|
150
168
|
var discord = {
|
|
169
|
+
messages,
|
|
170
|
+
reactions,
|
|
151
171
|
roles(options = {}) {
|
|
152
172
|
return resourceSourceSchema.parse({
|
|
153
173
|
provider: "discord",
|
|
@@ -291,44 +311,43 @@ function automatic(input) {
|
|
|
291
311
|
if (!input) {
|
|
292
312
|
return { kind: "automatic" };
|
|
293
313
|
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
return trigger;
|
|
314
|
+
const { tracker, beneficiary = "author", on, where } = input;
|
|
315
|
+
if (!tracker?.source) {
|
|
316
|
+
throw new Error(
|
|
317
|
+
"automatic() takes no argument, or { tracker } with a tracker handle from defineTracker"
|
|
318
|
+
);
|
|
319
|
+
}
|
|
320
|
+
const { source } = tracker;
|
|
321
|
+
if (!sourceIdentities(source)) {
|
|
322
|
+
throw new Error(
|
|
323
|
+
'Tracker triggers need attributable records: declare customSource(namespace, { identities: ["wallet"] }) or other identity kinds'
|
|
324
|
+
);
|
|
325
|
+
}
|
|
326
|
+
const roles = sourceRoles(source);
|
|
327
|
+
if (!roles.includes(beneficiary)) {
|
|
328
|
+
throw new Error(
|
|
329
|
+
source.kind === "custom" ? `Tracker "${tracker.key}" has no "${beneficiary}" account: declare it in customSource(namespace, { accounts: ["${beneficiary}"] })` : `Tracker "${tracker.key}" pays ${roles.map((role) => `"${role}"`).join(" or ")}, not "${beneficiary}"`
|
|
330
|
+
);
|
|
331
|
+
}
|
|
332
|
+
const policy = trackerTriggerPolicySchema.parse({
|
|
333
|
+
tracker: tracker.key,
|
|
334
|
+
source: source.kind,
|
|
335
|
+
// The source's default mode is left out, so default quests keep the policy shape
|
|
336
|
+
// earlier SDKs and servers read.
|
|
337
|
+
...on && on !== defaultTriggerMode(source.kind) ? { on } : {},
|
|
338
|
+
...where ? { where } : {},
|
|
339
|
+
beneficiary
|
|
340
|
+
});
|
|
341
|
+
const schema = sourceDataSchema(source);
|
|
342
|
+
const issue = schema ? whereSchemaIssue(schema, policy.where) : null;
|
|
343
|
+
if (issue) {
|
|
344
|
+
throw new Error(issue);
|
|
345
|
+
}
|
|
346
|
+
const trigger = { kind: "automatic", tracker: policy };
|
|
347
|
+
if (schema) {
|
|
348
|
+
triggerDataSchemas.set(trigger, schema);
|
|
330
349
|
}
|
|
331
|
-
return
|
|
350
|
+
return trigger;
|
|
332
351
|
}
|
|
333
352
|
var budget = (definition) => budgetSchema.parse(definition);
|
|
334
353
|
var keyed = (key) => ({
|
|
@@ -406,15 +425,15 @@ function defineQuest(definition) {
|
|
|
406
425
|
"Content triggers require perContent completion, and perContent requires a content trigger"
|
|
407
426
|
);
|
|
408
427
|
}
|
|
409
|
-
const bareAutomatic = definition.trigger.kind === "automatic" && !definition.trigger.
|
|
428
|
+
const bareAutomatic = definition.trigger.kind === "automatic" && !definition.trigger.content && !definition.trigger.tracker;
|
|
410
429
|
if (bareAutomatic && !definition.requires?.length) {
|
|
411
430
|
throw new Error(
|
|
412
|
-
"A bare automatic() quest needs at least one requires entry, such as requires: [completed(quest)]. Give it
|
|
431
|
+
"A bare automatic() quest needs at least one requires entry, such as requires: [completed(quest)]. Give it a content or tracker trigger, or a prerequisite."
|
|
413
432
|
);
|
|
414
433
|
}
|
|
415
434
|
if (bareAutomatic && definition.completion.kind !== "once") {
|
|
416
435
|
throw new Error(
|
|
417
|
-
`A bare automatic() quest cannot use ${definition.completion.kind}() completion. Give it a tracker
|
|
436
|
+
`A bare automatic() quest cannot use ${definition.completion.kind}() completion. Give it a tracker trigger, or use once().`
|
|
418
437
|
);
|
|
419
438
|
}
|
|
420
439
|
if (definition.trigger.kind === "manual" && definition.trigger.input !== "none" && !definition.evaluate) {
|
|
@@ -543,7 +562,6 @@ function defineQuest(definition) {
|
|
|
543
562
|
member: ctx.member,
|
|
544
563
|
input: ctx.input,
|
|
545
564
|
content: contentTrigger ? admittedContentSchema.parse(ctx.content) : null,
|
|
546
|
-
observation: ctx.observation ?? null,
|
|
547
565
|
tracker,
|
|
548
566
|
eligibleAt: ctx.eligibleAt,
|
|
549
567
|
now: ctx.now,
|
|
@@ -571,7 +589,6 @@ function defineQuest(definition) {
|
|
|
571
589
|
...definition.completion.kind === "keyed" ? {
|
|
572
590
|
completionKey: definition.completion.key({
|
|
573
591
|
...ctx,
|
|
574
|
-
observation: ctx.observation ?? null,
|
|
575
592
|
tracker: pinned
|
|
576
593
|
})
|
|
577
594
|
} : {}
|
|
@@ -582,8 +599,10 @@ function defineQuest(definition) {
|
|
|
582
599
|
}
|
|
583
600
|
var defineQuestType = defineQuest;
|
|
584
601
|
export {
|
|
602
|
+
CapabilityError,
|
|
585
603
|
automatic,
|
|
586
604
|
budget,
|
|
605
|
+
capabilityErrorCodes,
|
|
587
606
|
completed,
|
|
588
607
|
content,
|
|
589
608
|
customSource,
|
package/dist/avatar.d.ts
CHANGED