@domino-sdk/relay 1.0.0-next.5 → 1.0.0-next.7

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.
Files changed (42) hide show
  1. package/README.md +13 -1
  2. package/build.mjs +18 -1
  3. package/dist/authoring.d.ts +322 -14
  4. package/dist/authoring.js +187 -25
  5. package/dist/avatar.d.ts +29 -0
  6. package/dist/avatar.js +21 -0
  7. package/dist/browser.d.ts +19 -3
  8. package/dist/browser.js +6 -6
  9. package/dist/catalog-C09gnPYT.d.ts +3948 -0
  10. package/dist/chunk-7HSTFBMO.js +24 -0
  11. package/dist/{chunk-VH4OQ5VX.js → chunk-ADSP377G.js} +1 -1
  12. package/dist/{chunk-FDWRBMB3.js → chunk-AWLLGCKU.js} +2 -2
  13. package/dist/chunk-DJZB5RY5.js +901 -0
  14. package/dist/chunk-SKETUPST.js +171 -0
  15. package/dist/chunk-UFXBQ6FN.js +257 -0
  16. package/dist/{chunk-NKGJEYZM.js → chunk-UW6R2QGT.js} +610 -719
  17. package/dist/chunk-V7UKZLHA.js +35 -0
  18. package/dist/{chunk-4KNTMNXA.js → chunk-X6FJIPXR.js} +166 -724
  19. package/dist/client-BufGakEt.d.ts +4577 -0
  20. package/dist/collection-BGneJ6Bk.d.ts +114 -0
  21. package/dist/images-e6FW9QSx.d.ts +234 -0
  22. package/dist/index.d.ts +11 -13115
  23. package/dist/index.js +11 -693
  24. package/dist/integrations-C3Sp558f.d.ts +1297 -0
  25. package/dist/internal.d.ts +109 -0
  26. package/dist/internal.js +104 -0
  27. package/dist/point-ledgers-iS00Z_v0.d.ts +37 -0
  28. package/dist/portal-proxy.js +5 -6
  29. package/dist/profiles-BtOXMGcC.d.ts +297 -0
  30. package/dist/react/index.d.ts +51 -34
  31. package/dist/react/index.js +7 -13
  32. package/dist/schema-DCapSPHz.d.ts +3396 -0
  33. package/dist/schema.d.ts +3194 -2366
  34. package/dist/schema.js +539 -3
  35. package/dist/streaks-CwGReWGt.d.ts +73 -0
  36. package/dist/submission-input-Bter6XiI.d.ts +2672 -0
  37. package/dist/units-CwgsPB_r.d.ts +9 -0
  38. package/dist/wallet-Bu6sqJvQ.d.ts +231 -0
  39. package/package.json +17 -4
  40. package/dist/chunk-B76BAJ25.js +0 -624
  41. package/dist/chunk-ONDBQSMU.js +0 -373
  42. package/dist/submission-input-CZDukyb3.d.ts +0 -4998
package/README.md CHANGED
@@ -6,6 +6,18 @@ Author quests and connect an application to Domino Relay.
6
6
  pnpm add @domino-sdk/relay
7
7
  ```
8
8
 
9
- Use `@domino-sdk/relay/authoring` for quest definitions, `/browser` for browser integrations, `/portal-proxy` for server proxies, and `/build` for bundling authored modules.
9
+ | Import | For |
10
+ | -------------------------------- | ------------------------------------------------------------------------------------------ |
11
+ | `@domino-sdk/relay` | The participant client (`createRelayClient`), `RelayError`, and the types it returns |
12
+ | `@domino-sdk/relay/browser` | The browser client with durable submission recovery, wallet signers and sign-in options |
13
+ | `@domino-sdk/relay/react` | React hooks over the browser client |
14
+ | `@domino-sdk/relay/avatar` | Generated default avatars (`avatarSrc`, `defaultAvatar`) |
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, tracker records and observations |
17
+ | `@domino-sdk/relay/build` | Bundling authored modules; needs `esbuild` installed |
18
+ | `@domino-sdk/relay/portal-proxy` | Server proxies and hosted app Workers |
19
+ | `@domino-sdk/relay/vite` | The Vite plugin that keeps server code out of the browser build |
20
+
21
+ `@domino-sdk/relay/internal` is shared by Relay's own services and Console. It is not a supported API and can change in any release.
10
22
 
11
23
  Requires Node.js 24 for tooling. Proprietary software; `UNLICENSED`.
package/build.mjs CHANGED
@@ -1,5 +1,21 @@
1
1
  import { resolve, dirname } from "node:path"
2
- import { build } from "esbuild"
2
+
3
+ // esbuild is an optional peer dependency: only quest builds need it, so apps that use the runtime
4
+ // client do not install its native binary. `@domino-sdk/relay-cli` depends on it.
5
+ async function esbuild() {
6
+ try {
7
+ return await import("esbuild")
8
+ } catch (error) {
9
+ if (error?.code === "ERR_MODULE_NOT_FOUND") {
10
+ throw new Error(
11
+ "@domino-sdk/relay/build needs esbuild. Install it next to @domino-sdk/relay, or build with the domino CLI (@domino-sdk/relay-cli).",
12
+ { cause: error }
13
+ )
14
+ }
15
+
16
+ throw error
17
+ }
18
+ }
3
19
 
4
20
  /** Bundle an authored quest without evaluating developer code in the build process. */
5
21
  export async function buildQuest(entry, options = {}) {
@@ -10,6 +26,7 @@ export async function buildQuest(entry, options = {}) {
10
26
  throw new Error("Invalid quest export name")
11
27
  }
12
28
 
29
+ const { build } = await esbuild()
13
30
  const result = await build({
14
31
  ...(options.exportName
15
32
  ? {
@@ -1,7 +1,309 @@
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-CZDukyb3.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-CZDukyb3.js';
3
1
  import { z } from 'zod';
4
- import { TextReviewInput, TextResult, PhotoResult, rewardSchema, triggerSchema, QuestPresentation, QuestProfile, QuizEvidence, Decision, TieredRewardDefinition } from './schema.js';
2
+ import { C as ContentPolicy, g as ContentMetric, E as EngagementDefinition, l as leaderboardAuthoringSchema, r as referralAuthoringSchema, h as AdmittedContent, D as DiscordMember, T as TextEvidence, U as UrlEvidence, e as TextOptions, f as UrlOptions } from './submission-input-Bter6XiI.js';
3
+ import { Q as QuizContent, a as StreakPolicy } from './streaks-CwGReWGt.js';
4
+ import { T as TrackerDefinition, I as IdentityKind, t as trackerDefinitionSchema, R as ResourceSource, O as Observation, a as TrackerTriggerContext, b as TrackerReader, X as XReader, D as DiscordMessage, c as TrackerTriggerMode, d as TrackerWhere, o as observationTriggerSchema, e as TrackerTriggerPolicy, B as Budget, f as IntegrationProvider } from './integrations-C3Sp558f.js';
5
+ export { g as trackerTriggerContextSchema } from './integrations-C3Sp558f.js';
6
+ import { I as ImageReader } from './images-e6FW9QSx.js';
7
+ import { d as TextReviewInput, e as TextResult, P as PhotoResult, r as rewardSchema, t as triggerSchema, Q as QuestPresentation, a as QuestProfile, b as QuizEvidence, D as Decision, f as TieredRewardDefinition } from './schema-DCapSPHz.js';
8
+ import { c as WalletConnection, S as SolanaBalance, L as LinkedWallet, i as WalletBalanceQuery, j as WalletBalance } from './wallet-Bu6sqJvQ.js';
9
+ export { E as EvmChainId, k as isEvmChainId } from './wallet-Bu6sqJvQ.js';
10
+ export { f as formatUnits, p as parseUnits } from './units-CwgsPB_r.js';
11
+
12
+ /** Legacy `id` names an authoring key, never a server resource ID. */
13
+ type AuthoringIdentity = {
14
+ key: string;
15
+ id?: string;
16
+ } | {
17
+ key?: never; /** @deprecated Use key. */
18
+ id: string;
19
+ };
20
+
21
+ /** Discover posts automatically; historical release remains an explicit policy. */
22
+ declare function content(tracker: TrackerDefinition, policy?: Partial<Pick<ContentPolicy, "enrollment" | "posts" | "historical">>): {
23
+ kind: "automatic";
24
+ content: {
25
+ tracker: string;
26
+ window: {
27
+ start: number;
28
+ end?: number | undefined;
29
+ };
30
+ enrollment: "required" | "none";
31
+ posts: "after-enrollment" | "since-start";
32
+ historical: "staff" | "automatic" | "claim";
33
+ };
34
+ };
35
+ declare function perContent(): {
36
+ kind: "keyed";
37
+ perContent: true;
38
+ key: (ctx: {
39
+ content?: AdmittedContent | null;
40
+ }) => string;
41
+ };
42
+ /** One independent cumulative formula; management changes capture a new scoring boundary. */
43
+ declare function defineEngagementReward<const M extends readonly [ContentMetric, ...ContentMetric[]]>(input: {
44
+ key: string;
45
+ qualifiedBy: string | {
46
+ key: string;
47
+ };
48
+ balance: string;
49
+ metrics: M;
50
+ baseline: "historical";
51
+ maxAgeMs?: number;
52
+ budget?: EngagementDefinition["budget"];
53
+ target: (input: {
54
+ metrics: Record<M[number], number>;
55
+ }) => number;
56
+ }): {
57
+ key: string;
58
+ describe: () => {
59
+ key: string;
60
+ qualifiedBy: string;
61
+ balance: string;
62
+ metrics: ("likes" | "replies" | "reposts" | "quotes" | "views" | "bookmarks")[];
63
+ baseline: "historical";
64
+ maxAgeMs: number;
65
+ budget: {
66
+ projectDaily?: number | undefined;
67
+ memberDaily?: number | undefined;
68
+ projectLifetime?: number | undefined;
69
+ };
70
+ };
71
+ score(raw: unknown): {
72
+ target: number;
73
+ baseline: number;
74
+ };
75
+ };
76
+ /**
77
+ * One milestone per quest, after `days` consecutive community days with an accepted attempt.
78
+ * Multiple accepted attempts occupy one day. The day comes from the attempt's trusted occurrence
79
+ * time: a tracker record's (or observation's) `occurredAt` for `automatic({ tracker })`, and the
80
+ * submission's admission time for `manual()`, so a manual streak counts the days a member
81
+ * submitted. Not available on content quests or prerequisite-only `automatic()`.
82
+ */
83
+ declare const streak: (options: Omit<StreakPolicy, "kind">) => StreakPolicy;
84
+ declare function defineReferral(input: Omit<z.input<typeof referralAuthoringSchema>, "key" | "id"> & AuthoringIdentity): {
85
+ id: string;
86
+ title: string;
87
+ rewards: {
88
+ inviter: ({
89
+ kind: "tier";
90
+ reward: {
91
+ id: string;
92
+ title: string;
93
+ tiers: {
94
+ id: string;
95
+ title: string;
96
+ }[];
97
+ inventory: {
98
+ kind: "untracked";
99
+ };
100
+ fulfillment: {
101
+ kind: "staff-handover";
102
+ };
103
+ };
104
+ tier: string;
105
+ } | {
106
+ kind: "points";
107
+ balance: string;
108
+ amount: number;
109
+ })[];
110
+ invitee: ({
111
+ kind: "tier";
112
+ reward: {
113
+ id: string;
114
+ title: string;
115
+ tiers: {
116
+ id: string;
117
+ title: string;
118
+ }[];
119
+ inventory: {
120
+ kind: "untracked";
121
+ };
122
+ fulfillment: {
123
+ kind: "staff-handover";
124
+ };
125
+ };
126
+ tier: string;
127
+ } | {
128
+ kind: "points";
129
+ balance: string;
130
+ amount: number;
131
+ })[];
132
+ };
133
+ qualification: {
134
+ kind: "signup";
135
+ } | {
136
+ kind: "quest";
137
+ quest: string;
138
+ } | {
139
+ kind: "external";
140
+ };
141
+ enabled: boolean;
142
+ inviterGroup?: string | undefined;
143
+ milestones: {
144
+ id: string;
145
+ count: number;
146
+ rewards: ({
147
+ kind: "tier";
148
+ reward: {
149
+ id: string;
150
+ title: string;
151
+ tiers: {
152
+ id: string;
153
+ title: string;
154
+ }[];
155
+ inventory: {
156
+ kind: "untracked";
157
+ };
158
+ fulfillment: {
159
+ kind: "staff-handover";
160
+ };
161
+ };
162
+ tier: string;
163
+ } | {
164
+ kind: "points";
165
+ balance: string;
166
+ amount: number;
167
+ })[];
168
+ }[];
169
+ bonuses: {
170
+ id: string;
171
+ balance: string;
172
+ basisPoints: number;
173
+ external: boolean;
174
+ quests?: string[] | undefined;
175
+ durationDays?: number | undefined;
176
+ maxPoints?: number | undefined;
177
+ }[];
178
+ key: string;
179
+ };
180
+ declare function defineLeaderboard(input: Omit<z.input<typeof leaderboardAuthoringSchema>, "key" | "id"> & AuthoringIdentity): {
181
+ id: string;
182
+ title: string;
183
+ balance: string;
184
+ group?: string | undefined;
185
+ score: {
186
+ kind: "balance";
187
+ } | {
188
+ window: {
189
+ kind: "fixed";
190
+ start: number;
191
+ end: number;
192
+ } | {
193
+ kind: "all-time";
194
+ } | {
195
+ kind: "rolling";
196
+ days: number;
197
+ } | {
198
+ kind: "calendar";
199
+ period: "day" | "week" | "month";
200
+ timeZone: string;
201
+ };
202
+ kind: "earned";
203
+ quests?: string[] | undefined;
204
+ } | {
205
+ kind: "net";
206
+ window: {
207
+ kind: "fixed";
208
+ start: number;
209
+ end: number;
210
+ } | {
211
+ kind: "all-time";
212
+ } | {
213
+ kind: "rolling";
214
+ days: number;
215
+ } | {
216
+ kind: "calendar";
217
+ period: "day" | "week" | "month";
218
+ timeZone: string;
219
+ };
220
+ };
221
+ access: "participants" | "public";
222
+ key: string;
223
+ };
224
+ declare const x: {
225
+ search: (input: {
226
+ query: string;
227
+ }) => {
228
+ kind: "x-search";
229
+ query: string;
230
+ };
231
+ };
232
+ /**
233
+ * Records your own code sends with `trackers.ingest`. With `identities`, each record's author, and
234
+ * each named account in `accounts`, is a verified identity of one of those kinds, which Relay
235
+ * attributes to the member who verified it, so quests can trigger from the tracker. A record states
236
+ * each account's `kind` unless the source names exactly one.
237
+ */
238
+ declare const customSource: (namespace: string, options?: {
239
+ identities?: IdentityKind[];
240
+ accounts?: string[];
241
+ }) => {
242
+ kind: "custom";
243
+ namespace: string;
244
+ identities?: ("x" | "discord" | "member" | "wallet")[] | undefined;
245
+ accounts?: string[] | undefined;
246
+ authors?: "wallet" | undefined;
247
+ };
248
+ declare function defineTracker(input: z.input<typeof trackerDefinitionSchema>): TrackerDefinition;
249
+ type ChannelTypes = Extract<ResourceSource, {
250
+ resource: "channel";
251
+ }>["types"];
252
+ declare const discord: {
253
+ roles(options?: {
254
+ assignable?: boolean;
255
+ }): ResourceSource;
256
+ channels(options?: {
257
+ types?: ChannelTypes;
258
+ }): ResourceSource;
259
+ };
260
+ declare const pointLedgers: () => ResourceSource;
261
+ type Label = {
262
+ label: string;
263
+ description?: string;
264
+ };
265
+ declare const settings: {
266
+ pointLedger(options: Label & {
267
+ default: string;
268
+ }): z.ZodDefault<z.ZodString>;
269
+ datetime(options: Label & {
270
+ default: string;
271
+ }): z.ZodDefault<z.ZodPipe<z.ZodISODateTime, z.ZodTransform<string, string>>>;
272
+ resource(options: Label & {
273
+ source: ResourceSource;
274
+ default?: string;
275
+ }): z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<"">, z.ZodString]>>;
276
+ quiz(options: Label & {
277
+ default: QuizContent;
278
+ }): z.ZodDefault<z.ZodArray<z.ZodObject<{
279
+ id: z.ZodString;
280
+ prompt: z.ZodString;
281
+ choices: z.ZodArray<z.ZodObject<{
282
+ id: z.ZodString;
283
+ label: z.ZodString;
284
+ }, z.core.$strict>>;
285
+ correct: z.ZodString;
286
+ }, z.core.$strict>>>;
287
+ text(options: Label & {
288
+ default: string;
289
+ minLength?: number;
290
+ maxLength?: number;
291
+ multiline?: boolean;
292
+ }): z.ZodDefault<z.ZodString>;
293
+ integer(options: Label & {
294
+ default: number;
295
+ min: number;
296
+ max: number;
297
+ }): z.ZodDefault<z.ZodNumber>;
298
+ boolean(options: Label & {
299
+ default: boolean;
300
+ }): z.ZodDefault<z.ZodBoolean>;
301
+ choice<const T extends readonly [string, ...string[]]>(options: Label & {
302
+ options: T;
303
+ default: T[number];
304
+ }): z.ZodDefault<z.ZodEnum<{ [k_1 in T[number]]: k_1; } extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never>>;
305
+ object<T extends Record<string, z.ZodType>>(shape: T): z.ZodObject<{ -readonly [P in keyof T]: T[P]; }, z.core.$strict>;
306
+ };
5
307
 
6
308
  type Reward = z.infer<typeof rewardSchema>;
7
309
  declare const points: (balance: string, amount: number) => {
@@ -99,7 +401,7 @@ declare function automatic(input: TrackerTriggerInput): {
99
401
  declare const budget: (definition: Budget) => {
100
402
  id: string;
101
403
  scope: "member" | "project";
102
- period: "lifetime" | "day" | "week";
404
+ period: "day" | "lifetime" | "week";
103
405
  limit: number;
104
406
  cost: number | {
105
407
  balance: string;
@@ -326,6 +628,12 @@ declare function defineQuest<T extends Record<string, z.ZodType>, const G extend
326
628
  */
327
629
  profile?: QuestProfile;
328
630
  budgets?: Budget[];
631
+ /**
632
+ * Whether staff can review this quest's attempts. Human review is on unless this returns
633
+ * `{ enabled: false }`. With it off, `decision.review(...)` becomes a reject that keeps the
634
+ * review reason, and the attempt records `requestedReview: true`; Console shows "Would have
635
+ * gone to review; human review is off".
636
+ */
329
637
  review?: (ctx: {
330
638
  settings: z.output<z.ZodObject<T>>;
331
639
  }) => {
@@ -393,12 +701,12 @@ declare function defineQuest<T extends Record<string, z.ZodType>, const G extend
393
701
  kind: "resource";
394
702
  default: string;
395
703
  source: {
396
- provider: "domino";
397
- resource: "point-ledger";
398
- } | {
399
704
  provider: "discord";
400
705
  resource: "channel";
401
706
  types: ("text" | "announcement")[];
707
+ } | {
708
+ provider: "domino";
709
+ resource: "point-ledger";
402
710
  } | {
403
711
  provider: "discord";
404
712
  resource: "role";
@@ -531,7 +839,7 @@ declare function defineQuest<T extends Record<string, z.ZodType>, const G extend
531
839
  minLength: number;
532
840
  maxLength: number;
533
841
  };
534
- actor?: "staff" | "member" | undefined;
842
+ actor?: "member" | "staff" | undefined;
535
843
  } | {
536
844
  kind: "manual";
537
845
  input: "url";
@@ -539,11 +847,11 @@ declare function defineQuest<T extends Record<string, z.ZodType>, const G extend
539
847
  required: boolean;
540
848
  allowedHosts?: string[] | undefined;
541
849
  };
542
- actor?: "staff" | "member" | undefined;
850
+ actor?: "member" | "staff" | undefined;
543
851
  } | {
544
852
  kind: "manual";
545
- input: "photo" | "quiz" | "none";
546
- actor?: "staff" | "member" | undefined;
853
+ input: "quiz" | "photo" | "none";
854
+ actor?: "member" | "staff" | undefined;
547
855
  };
548
856
  requires: {
549
857
  quest: string;
@@ -557,11 +865,11 @@ declare function defineQuest<T extends Record<string, z.ZodType>, const G extend
557
865
  } | {
558
866
  kind: "keyed";
559
867
  };
560
- visibility: "visible" | "hidden";
868
+ visibility: "hidden" | "visible";
561
869
  budgets: {
562
870
  id: string;
563
871
  scope: "member" | "project";
564
- period: "lifetime" | "day" | "week";
872
+ period: "day" | "lifetime" | "week";
565
873
  limit: number;
566
874
  cost: number | {
567
875
  balance: string;
@@ -585,4 +893,4 @@ declare function defineQuest<T extends Record<string, z.ZodType>, const G extend
585
893
  * Console instances receive independent quest identities and pinned versions. */
586
894
  declare const defineQuestType: typeof defineQuest;
587
895
 
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 };
896
+ export { type EvaluationContext, ImageReader, type PerformanceOutcome, TrackerReader, TrackerTriggerContext, type TrackerTriggerInput, WalletBalance, WalletBalanceQuery, 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 };