@domino-sdk/relay 1.0.0-next.0 → 1.0.0-next.10

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 (44) hide show
  1. package/README.md +13 -1
  2. package/build.mjs +18 -1
  3. package/dist/authoring.d.ts +468 -61
  4. package/dist/authoring.js +317 -65
  5. package/dist/avatar.d.ts +29 -0
  6. package/dist/avatar.js +21 -0
  7. package/dist/browser.d.ts +241 -2213
  8. package/dist/browser.js +6 -6
  9. package/dist/chunk-4LBUTHD6.js +171 -0
  10. package/dist/{chunk-OQ4ZNOC7.js → chunk-7Q4BGGT6.js} +26 -5
  11. package/dist/{chunk-BGN3CQC6.js → chunk-P6FK43GG.js} +22 -8
  12. package/dist/chunk-PHU5VDLR.js +1003 -0
  13. package/dist/chunk-QR7ZA2BJ.js +257 -0
  14. package/dist/chunk-V7UKZLHA.js +35 -0
  15. package/dist/chunk-X2F2RAR3.js +1407 -0
  16. package/dist/chunk-YYD4QUBO.js +2348 -0
  17. package/dist/chunk-ZWY3R6B3.js +26 -0
  18. package/dist/client-CT4-S5vc.d.ts +2716 -0
  19. package/dist/collection-BGneJ6Bk.d.ts +114 -0
  20. package/dist/images-BTgk6OmC.d.ts +1564 -0
  21. package/dist/index.d.ts +11 -13133
  22. package/dist/index.js +20 -690
  23. package/dist/integrations-Ba5TtqTv.d.ts +410 -0
  24. package/dist/internal.d.ts +121 -0
  25. package/dist/internal.js +125 -0
  26. package/dist/pages-D3titw5B.d.ts +4193 -0
  27. package/dist/point-ledgers-iS00Z_v0.d.ts +37 -0
  28. package/dist/portal-proxy.js +8 -9
  29. package/dist/profiles-DDMFBRKe.d.ts +297 -0
  30. package/dist/react/index.d.ts +275 -2229
  31. package/dist/react/index.js +23 -19
  32. package/dist/schema-Di3aLSiK.d.ts +3532 -0
  33. package/dist/schema.d.ts +3168 -2395
  34. package/dist/schema.js +561 -3
  35. package/dist/streaks-CwGReWGt.d.ts +73 -0
  36. package/dist/submission-input-0OOGaq8c.d.ts +2672 -0
  37. package/dist/units-CwgsPB_r.d.ts +9 -0
  38. package/dist/wallet-BGOfFkG9.d.ts +231 -0
  39. package/package.json +18 -5
  40. package/dist/chunk-IZYXEXUO.js +0 -1847
  41. package/dist/chunk-QEN4GHL7.js +0 -624
  42. package/dist/chunk-UI4N4XRZ.js +0 -373
  43. package/dist/chunk-UPWID5KS.js +0 -1833
  44. package/dist/submission-input-JDwq3EVK.d.ts +0 -4986
@@ -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-JDwq3EVK.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-JDwq3EVK.js';
3
1
  import { z } from 'zod';
4
- import { TextReviewInput, TextResult, PhotoResult, rewardSchema, triggerSchema, QuestPresentation, QuestProfile, QuizEvidence, Decision, TieredRewardDefinition } from './schema.js';
2
+ export { z } from 'zod';
3
+ 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-0OOGaq8c.js';
4
+ import { Q as QuizContent, a as StreakPolicy } from './streaks-CwGReWGt.js';
5
+ import { R as ResourceSource, S as Setting, O as Observation, X as XReader, D as DiscordMessage, o as observationTriggerSchema, B as Budget, I as IntegerSettings, a as IntegrationProvider } from './integrations-Ba5TtqTv.js';
6
+ import { T as TrackerDefinition, I as IdentityKind, c as customSourceSchema, W as WithRecordData, a as TrackerSource, t as trackerDefinitionSchema, b as Tracker, d as TrackerData, x as xSearchSourceSchema, X as XTweet, e as TrackerTriggerContext, f as TrackerTriggerPolicy, g as TrackerReader, h as ImageReader, i as Where, j as TrackerTriggerMode, k as WhereSetting } from './images-BTgk6OmC.js';
7
+ export { l as TrackerDataSchema, m as TrackerPage, n as trackerDataSchema, o as trackerTriggerContextSchema } from './images-BTgk6OmC.js';
8
+ 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-Di3aLSiK.js';
9
+ import { h as WalletConnection, S as SolanaBalance, L as LinkedWallet, i as WalletBalanceQuery, j as WalletBalance } from './wallet-BGOfFkG9.js';
10
+ export { E as EvmChainId, k as isEvmChainId } from './wallet-BGOfFkG9.js';
11
+ export { f as formatUnits, p as parseUnits } from './units-CwgsPB_r.js';
12
+
13
+ /** Legacy `id` names an authoring key, never a server resource ID. */
14
+ type AuthoringIdentity = {
15
+ key: string;
16
+ id?: string;
17
+ } | {
18
+ key?: never; /** @deprecated Use key. */
19
+ id: string;
20
+ };
21
+
22
+ /** Discover posts automatically; historical release remains an explicit policy. */
23
+ declare function content(tracker: TrackerDefinition, policy?: Partial<Pick<ContentPolicy, "enrollment" | "posts" | "historical">>): {
24
+ kind: "automatic";
25
+ content: {
26
+ tracker: string;
27
+ window: {
28
+ start: number;
29
+ end?: number | undefined;
30
+ };
31
+ enrollment: "required" | "none";
32
+ posts: "after-enrollment" | "since-start";
33
+ historical: "automatic" | "claim" | "staff";
34
+ };
35
+ };
36
+ declare function perContent(): {
37
+ kind: "keyed";
38
+ perContent: true;
39
+ key: (ctx: {
40
+ content?: AdmittedContent | null;
41
+ }) => string;
42
+ };
43
+ /** One independent cumulative formula; management changes capture a new scoring boundary. */
44
+ declare function defineEngagementReward<const M extends readonly [ContentMetric, ...ContentMetric[]]>(input: {
45
+ key: string;
46
+ qualifiedBy: string | {
47
+ key: string;
48
+ };
49
+ balance: string;
50
+ metrics: M;
51
+ baseline: "historical";
52
+ maxAgeMs?: number;
53
+ budget?: EngagementDefinition["budget"];
54
+ target: (input: {
55
+ metrics: Record<M[number], number>;
56
+ }) => number;
57
+ }): {
58
+ key: string;
59
+ describe: () => {
60
+ key: string;
61
+ qualifiedBy: string;
62
+ balance: string;
63
+ metrics: ("likes" | "replies" | "reposts" | "quotes" | "views" | "bookmarks")[];
64
+ baseline: "historical";
65
+ maxAgeMs: number;
66
+ budget: {
67
+ projectDaily?: number | undefined;
68
+ memberDaily?: number | undefined;
69
+ projectLifetime?: number | undefined;
70
+ };
71
+ };
72
+ score(raw: unknown): {
73
+ target: number;
74
+ baseline: number;
75
+ };
76
+ };
77
+ /**
78
+ * One milestone per quest, after `days` consecutive community days with an accepted attempt.
79
+ * Multiple accepted attempts occupy one day. The day comes from the attempt's trusted occurrence
80
+ * time: a tracker record's (or observation's) `occurredAt` for `automatic({ tracker })`, and the
81
+ * submission's admission time for `manual()`, so a manual streak counts the days a member
82
+ * submitted. Not available on content quests or prerequisite-only `automatic()`.
83
+ */
84
+ declare const streak: (options: Omit<StreakPolicy, "kind">) => StreakPolicy;
85
+ declare function defineReferral(input: Omit<z.input<typeof referralAuthoringSchema>, "key" | "id"> & AuthoringIdentity): {
86
+ id: string;
87
+ title: string;
88
+ rewards: {
89
+ inviter: ({
90
+ kind: "tier";
91
+ reward: {
92
+ id: string;
93
+ title: string;
94
+ tiers: {
95
+ id: string;
96
+ title: string;
97
+ }[];
98
+ inventory: {
99
+ kind: "untracked";
100
+ };
101
+ fulfillment: {
102
+ kind: "staff-handover";
103
+ };
104
+ };
105
+ tier: string;
106
+ } | {
107
+ kind: "points";
108
+ balance: string;
109
+ amount: number;
110
+ })[];
111
+ invitee: ({
112
+ kind: "tier";
113
+ reward: {
114
+ id: string;
115
+ title: string;
116
+ tiers: {
117
+ id: string;
118
+ title: string;
119
+ }[];
120
+ inventory: {
121
+ kind: "untracked";
122
+ };
123
+ fulfillment: {
124
+ kind: "staff-handover";
125
+ };
126
+ };
127
+ tier: string;
128
+ } | {
129
+ kind: "points";
130
+ balance: string;
131
+ amount: number;
132
+ })[];
133
+ };
134
+ qualification: {
135
+ kind: "signup";
136
+ } | {
137
+ kind: "quest";
138
+ quest: string;
139
+ } | {
140
+ kind: "external";
141
+ };
142
+ enabled: boolean;
143
+ inviterGroup?: string | undefined;
144
+ milestones: {
145
+ id: string;
146
+ count: number;
147
+ rewards: ({
148
+ kind: "tier";
149
+ reward: {
150
+ id: string;
151
+ title: string;
152
+ tiers: {
153
+ id: string;
154
+ title: string;
155
+ }[];
156
+ inventory: {
157
+ kind: "untracked";
158
+ };
159
+ fulfillment: {
160
+ kind: "staff-handover";
161
+ };
162
+ };
163
+ tier: string;
164
+ } | {
165
+ kind: "points";
166
+ balance: string;
167
+ amount: number;
168
+ })[];
169
+ }[];
170
+ bonuses: {
171
+ id: string;
172
+ balance: string;
173
+ basisPoints: number;
174
+ external: boolean;
175
+ quests?: string[] | undefined;
176
+ durationDays?: number | undefined;
177
+ maxPoints?: number | undefined;
178
+ }[];
179
+ key: string;
180
+ };
181
+ declare function defineLeaderboard(input: Omit<z.input<typeof leaderboardAuthoringSchema>, "key" | "id"> & AuthoringIdentity): {
182
+ id: string;
183
+ title: string;
184
+ balance: string;
185
+ group?: string | undefined;
186
+ score: {
187
+ kind: "balance";
188
+ } | {
189
+ window: {
190
+ kind: "fixed";
191
+ start: number;
192
+ end: number;
193
+ } | {
194
+ kind: "all-time";
195
+ } | {
196
+ kind: "rolling";
197
+ days: number;
198
+ } | {
199
+ kind: "calendar";
200
+ period: "day" | "week" | "month";
201
+ timeZone: string;
202
+ };
203
+ kind: "earned";
204
+ quests?: string[] | undefined;
205
+ } | {
206
+ kind: "net";
207
+ window: {
208
+ kind: "fixed";
209
+ start: number;
210
+ end: number;
211
+ } | {
212
+ kind: "all-time";
213
+ } | {
214
+ kind: "rolling";
215
+ days: number;
216
+ } | {
217
+ kind: "calendar";
218
+ period: "day" | "week" | "month";
219
+ timeZone: string;
220
+ };
221
+ };
222
+ access: "participants" | "public";
223
+ key: string;
224
+ };
225
+ declare const x: {
226
+ /** Posts matching an X search. Each record's `data` is the provider's post payload. */
227
+ search: (input: {
228
+ query: string;
229
+ }) => z.output<typeof xSearchSourceSchema> & WithRecordData<XTweet>;
230
+ };
231
+ /**
232
+ * Records your own code sends with `trackers.ingest`. `data` is a zod object schema that every
233
+ * record's `data` must match: Relay stores its JSON Schema form with the tracker and rejects
234
+ * records that do not match it, and quests read each record's data with its type. With
235
+ * `identities`, each record's author, and each named account in `accounts`, is a verified identity
236
+ * of one of those kinds, which Relay attributes to the member who verified it, so quests can
237
+ * trigger from the tracker. A record states each account's `kind` unless the source names exactly
238
+ * one.
239
+ */
240
+ declare function customSource<S extends z.ZodObject>(namespace: string, options: {
241
+ identities?: IdentityKind[];
242
+ accounts?: string[];
243
+ data: S;
244
+ }): z.output<typeof customSourceSchema> & WithRecordData<z.input<S>>;
245
+ declare function defineTracker<S extends TrackerSource>(input: Omit<z.input<typeof trackerDefinitionSchema>, "source"> & {
246
+ source: S;
247
+ }): Tracker<TrackerData<S>>;
248
+ type ChannelTypes = Extract<ResourceSource, {
249
+ resource: "channel";
250
+ }>["types"];
251
+ declare const discord: {
252
+ roles(options?: {
253
+ assignable?: boolean;
254
+ }): ResourceSource;
255
+ channels(options?: {
256
+ types?: ChannelTypes;
257
+ }): ResourceSource;
258
+ };
259
+ declare const pointLedgers: () => ResourceSource;
260
+ type Label = {
261
+ label: string;
262
+ description?: string;
263
+ };
264
+ declare const settings: {
265
+ pointLedger(options: Label & {
266
+ default: string;
267
+ }): Setting<"point-ledger", z.ZodDefault<z.ZodString>>;
268
+ datetime(options: Label & {
269
+ default: string;
270
+ }): Setting<"datetime", z.ZodDefault<z.ZodPipe<z.ZodISODateTime, z.ZodTransform<string, string>>>>;
271
+ resource(options: Label & {
272
+ source: ResourceSource;
273
+ default?: string;
274
+ }): Setting<"resource", z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<"">, z.ZodString]>>>;
275
+ quiz(options: Label & {
276
+ default: QuizContent;
277
+ }): Setting<"quiz", z.ZodDefault<z.ZodArray<z.ZodObject<{
278
+ id: z.ZodString;
279
+ prompt: z.ZodString;
280
+ choices: z.ZodArray<z.ZodObject<{
281
+ id: z.ZodString;
282
+ label: z.ZodString;
283
+ }, z.core.$strict>>;
284
+ correct: z.ZodString;
285
+ }, z.core.$strict>>>>;
286
+ text(options: Label & {
287
+ default: string;
288
+ minLength?: number;
289
+ maxLength?: number;
290
+ multiline?: boolean;
291
+ }): Setting<"text", z.ZodDefault<z.ZodString>>;
292
+ integer(options: Label & {
293
+ default: number;
294
+ min: number;
295
+ max: number;
296
+ }): Setting<"integer", z.ZodDefault<z.ZodNumber>>;
297
+ boolean(options: Label & {
298
+ default: boolean;
299
+ }): Setting<"boolean", z.ZodDefault<z.ZodBoolean>>;
300
+ choice<const T extends readonly [string, ...string[]]>(options: Label & {
301
+ options: T;
302
+ default: T[number];
303
+ }): Setting<"choice", z.ZodDefault<z.ZodEnum<{ [k_1 in T[number]]: k_1; } extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never>>>;
304
+ /** A quest's settings: every field is built with one of the builders above. */
305
+ object<T extends Record<string, Setting>>(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) => {
@@ -59,8 +361,9 @@ declare function manual(options: {
59
361
  actor: "staff";
60
362
  };
61
363
  /** A tracker trigger: which observations of which tracker run the quest, and for whom. */
62
- type TrackerTriggerInput = {
63
- tracker: TrackerDefinition;
364
+ type TrackerTriggerInput<T extends Tracker = Tracker, W extends Where<TrackerData<T>> | undefined = Where<TrackerData<T>> | undefined> = {
365
+ /** The tracker handle `defineTracker` returns. */
366
+ tracker: T;
64
367
  /**
65
368
  * Which observations fire. `"new-record"`: each record's first observation (the default for X
66
369
  * trackers, where it means each newly collected post). `"new-observation"`: each observation
@@ -70,9 +373,11 @@ type TrackerTriggerInput = {
70
373
  on?: TrackerTriggerMode;
71
374
  /**
72
375
  * Admit only observations whose `data` matches, such as `{ path: "amount", gte: 1000 }` or
73
- * `{ path: "amount", gte: { setting: "threshold" } }`. Others record no outcome.
376
+ * `{ path: "amount", gte: { setting: "threshold" } }`, or a list of at most 10 such conditions
377
+ * that must all hold. Paths and values are checked against the tracker's data type, and a
378
+ * `setting` must name one of the quest's integer settings. Others record no outcome.
74
379
  */
75
- where?: TrackerWhere;
380
+ where?: W;
76
381
  /**
77
382
  * The record account whose member the quest pays: `"author"` (the default), `"inReplyTo"` on
78
383
  * an X tracker, or a named account a custom source declares in `accounts`. Skipped when that
@@ -80,6 +385,24 @@ type TrackerTriggerInput = {
80
385
  */
81
386
  beneficiary?: string;
82
387
  };
388
+ /** Type-only markers a tracker trigger carries into `defineQuest`. They never exist at runtime. */
389
+ declare const triggerData: unique symbol;
390
+ declare const triggerSettings: unique symbol;
391
+ /**
392
+ * A tracker trigger whose records carry `data` of type `D` and whose filter compares with the
393
+ * settings `S`. `defineQuest` types `ctx.tracker` from `D` and checks `S` against its integer
394
+ * settings.
395
+ */
396
+ type TrackerTrigger<D = unknown, S extends string = never> = {
397
+ kind: "automatic";
398
+ tracker: TrackerTriggerPolicy;
399
+ readonly [triggerData]?: D;
400
+ readonly [triggerSettings]?: S;
401
+ };
402
+ type TriggerData<G> = G extends TrackerTrigger<infer D, string> ? unknown extends D ? unknown : D : unknown;
403
+ type TriggerSettings<G> = G extends {
404
+ readonly [triggerSettings]?: infer S;
405
+ } ? unknown extends S ? never : Exclude<S, undefined> : never;
83
406
  /**
84
407
  * An automatic quest. With no argument it runs once its prerequisites are complete; with an
85
408
  * observation it runs for each matching observation; with a tracker it runs for each observation
@@ -92,44 +415,49 @@ declare function automatic(observation: z.infer<typeof observationTriggerSchema>
92
415
  kind: "automatic";
93
416
  observation: z.infer<typeof observationTriggerSchema>;
94
417
  };
95
- declare function automatic(input: TrackerTriggerInput): {
96
- kind: "automatic";
97
- tracker: TrackerTriggerPolicy;
418
+ declare function automatic<T extends Tracker, const W extends Where<TrackerData<T>> | undefined = undefined>(input: TrackerTriggerInput<T, W>): TrackerTrigger<TrackerData<T>, WhereSetting<W>>;
419
+ /**
420
+ * What a trigger `G` supplies under key `K`: `Present` when the trigger has it, null when it cannot,
421
+ * and `Present | null` when `G` is not known.
422
+ */
423
+ type Supplied<G, K extends string, Present, Base> = unknown extends G ? Base | null : G extends unknown ? K extends keyof G ? [G[K]] extends [object] ? Present : Base | null : null : never;
424
+ /** `ctx.tracker` for a trigger: non-null and typed for a tracker trigger, null for others. */
425
+ type ContextTracker<G> = Supplied<G, "tracker", TrackerTriggerContext<TriggerData<G>>, TrackerTriggerContext>;
426
+ /** `ctx.content` for a trigger: the admitted post for a content trigger, null for others. */
427
+ type ContextContent<G> = Supplied<G, "content", AdmittedContent, AdmittedContent>;
428
+ /** `ctx.observation` for a trigger: the observation for an observation trigger, null for others. */
429
+ type ContextObservation<G> = Supplied<G, "observation", Observation, Observation>;
430
+ /**
431
+ * What a `keyed()` completion key reads. TypeScript cannot carry the trigger into a completion
432
+ * built inline, so `tracker` stays nullable here; the evaluator's `ctx.tracker` is typed.
433
+ */
434
+ type KeyedContext = {
435
+ member: {
436
+ id: string;
437
+ };
438
+ content?: AdmittedContent | null;
439
+ observation: Observation | null;
440
+ /** The pinned tracker observation of a tracker-triggered quest; null for other triggers. */
441
+ tracker: TrackerTriggerContext | null;
442
+ eligibleAt: number;
443
+ /** The attempt's evaluation time; see {@link EvaluationContext.now}. */
444
+ now: number;
98
445
  };
99
446
  declare const budget: (definition: Budget) => {
100
447
  id: string;
101
448
  scope: "member" | "project";
102
- period: "lifetime" | "day" | "week";
449
+ period: "day" | "lifetime" | "week";
103
450
  limit: number;
104
451
  cost: number | {
105
452
  balance: string;
106
453
  };
107
454
  };
108
- declare const keyed: (key: (ctx: {
109
- member: {
110
- id: string;
111
- };
112
- content?: AdmittedContent | null;
113
- observation: Observation | null;
114
- /** The pinned tracker observation of a tracker-triggered quest. */
115
- tracker?: TrackerTriggerContext | null;
116
- eligibleAt: number;
117
- }) => string) => {
455
+ declare const keyed: (key: (ctx: KeyedContext) => string) => {
118
456
  kind: "keyed";
119
- key: (ctx: {
120
- member: {
121
- id: string;
122
- };
123
- content?: AdmittedContent | null;
124
- observation: Observation | null;
125
- /** The pinned tracker observation of a tracker-triggered quest. */
126
- tracker?: TrackerTriggerContext | null;
127
- eligibleAt: number;
128
- }) => string;
457
+ key: (ctx: KeyedContext) => string;
129
458
  };
130
459
  declare const completed: (quest: AuthoringIdentity | string) => {
131
460
  quest: string;
132
- scope: "ever";
133
461
  };
134
462
  declare const untracked: () => {
135
463
  kind: "untracked";
@@ -174,34 +502,82 @@ type Outcome = {
174
502
  kind: "reject";
175
503
  reason: string;
176
504
  };
505
+ /**
506
+ * A performance evaluator's answer. It gates the rewards content evaluation already selected, so
507
+ * it carries none: a `rewards` value fails the evaluation.
508
+ */
509
+ type PerformanceOutcome = {
510
+ kind: "accept";
511
+ rewards?: never;
512
+ } | {
513
+ kind: "review";
514
+ reason: string;
515
+ rewards?: never;
516
+ } | {
517
+ kind: "reject";
518
+ reason: string;
519
+ };
520
+ declare function accept(): {
521
+ kind: "accept";
522
+ };
523
+ declare function accept(options: {
524
+ rewards?: Reward[];
525
+ }): Outcome;
526
+ declare function review(options: {
527
+ reason: string;
528
+ rewards?: undefined;
529
+ }): {
530
+ kind: "review";
531
+ reason: string;
532
+ };
533
+ declare function review(options: {
534
+ reason: string;
535
+ rewards?: Reward[];
536
+ }): Outcome;
177
537
  declare const decision: {
178
- accept: (options?: {
179
- rewards?: Reward[];
180
- }) => Outcome;
538
+ accept: typeof accept;
181
539
  reject: (options: {
182
540
  reason: string;
183
- }) => Outcome;
184
- review: (options: {
541
+ }) => {
542
+ kind: "reject";
185
543
  reason: string;
186
- rewards?: Reward[];
187
- }) => Outcome;
544
+ };
545
+ review: typeof review;
188
546
  };
547
+ /**
548
+ * What an evaluator reads. `G` is the quest's trigger: `tracker`, `content` and `observation` are
549
+ * non-null for the trigger that supplies them and null otherwise. `G` defaults to `any`, which
550
+ * leaves them nullable and lets a shared evaluator, such as `evaluators.photo()`, fit every quest.
551
+ */
189
552
  type EvaluationContext<T, I = {
190
553
  photo: string;
191
- }> = {
554
+ }, G = any> = {
192
555
  settings: T;
193
556
  member: {
194
557
  id: string;
195
558
  };
196
559
  input: I;
197
- content: AdmittedContent | null;
198
- observation: Observation | null;
560
+ /** The admitted post of a content quest. */
561
+ content: ContextContent<G>;
562
+ /** The observation of an observation-triggered quest. */
563
+ observation: ContextObservation<G>;
199
564
  /**
200
565
  * The tracker observation that admitted this attempt, and the member and verified account it
201
- * was attributed to. Null unless the quest has a tracker trigger.
566
+ * was attributed to. Present for a tracker trigger, with `record.data` of the tracker's type.
567
+ */
568
+ tracker: ContextTracker<G>;
569
+ /**
570
+ * When the activity happened, in epoch milliseconds: the observation's or tracker record's
571
+ * occurrence time, else when the attempt was admitted. Budgets and daily keys use it.
202
572
  */
203
- tracker: TrackerTriggerContext | null;
204
573
  eligibleAt: number;
574
+ /**
575
+ * The attempt's evaluation time, in epoch milliseconds: when its first evaluation started.
576
+ * Every retry and replay of the attempt receives the same value, and the sandbox freezes
577
+ * `Date.now()` and `new Date()` at it. Use `eligibleAt` for when the activity
578
+ * happened.
579
+ */
580
+ now: number;
205
581
  trackers: TrackerReader;
206
582
  x: XReader;
207
583
  images: ImageReader;
@@ -236,7 +612,7 @@ type EvaluationContext<T, I = {
236
612
  };
237
613
  type Evaluator<T, I = {
238
614
  photo: string;
239
- }> = (ctx: EvaluationContext<T, I>) => Promise<Outcome>;
615
+ }, G = any> = (ctx: EvaluationContext<T, I, G>) => Promise<Outcome>;
240
616
  declare const evaluators: {
241
617
  quiz(answerKey: QuizEvidence["answers"], options?: {
242
618
  minimumCorrect?: number;
@@ -260,7 +636,16 @@ type QuestInput<T extends Trigger> = T extends {
260
636
  } ? TextEvidence : T extends {
261
637
  input: "url";
262
638
  } ? UrlEvidence : Record<string, never>;
263
- declare function defineQuest<T extends Record<string, z.ZodType>, const G extends Trigger, const M extends readonly [ContentMetric, ...ContentMetric[]] = readonly [
639
+ /**
640
+ * Rejects a trigger whose filter compares with settings that are not integer settings of the
641
+ * quest, naming them.
642
+ */
643
+ type IntegerSettingBounds<G, T> = [
644
+ Exclude<TriggerSettings<G>, IntegerSettings<T>>
645
+ ] extends [never] ? unknown : {
646
+ readonly "The tracker filter compares with settings that are not integer settings of this quest": Exclude<TriggerSettings<G>, IntegerSettings<T>>;
647
+ };
648
+ declare function defineQuest<T extends Record<string, Setting>, const G extends Trigger, const M extends readonly [ContentMetric, ...ContentMetric[]] = readonly [
264
649
  ContentMetric,
265
650
  ...ContentMetric[]
266
651
  ]>(definition: AuthoringIdentity & {
@@ -271,7 +656,7 @@ declare function defineQuest<T extends Record<string, z.ZodType>, const G extend
271
656
  presentation?: (ctx: {
272
657
  settings: z.output<z.ZodObject<T>>;
273
658
  }) => QuestPresentation;
274
- trigger: G;
659
+ trigger: G & NoInfer<IntegerSettingBounds<G, T>>;
275
660
  integrations?: IntegrationProvider[];
276
661
  requires?: ReturnType<typeof completed>[];
277
662
  completion: ReturnType<typeof once> | ReturnType<typeof keyed> | StreakPolicy;
@@ -282,6 +667,12 @@ declare function defineQuest<T extends Record<string, z.ZodType>, const G extend
282
667
  */
283
668
  profile?: QuestProfile;
284
669
  budgets?: Budget[];
670
+ /**
671
+ * Whether staff can review this quest's attempts. Human review is on unless this returns
672
+ * `{ enabled: false }`. With it off, `decision.review(...)` becomes a reject that keeps the
673
+ * review reason, and the attempt records `requestedReview: true`; Console shows "Would have
674
+ * gone to review; human review is off".
675
+ */
285
676
  review?: (ctx: {
286
677
  settings: z.output<z.ZodObject<T>>;
287
678
  }) => {
@@ -290,7 +681,7 @@ declare function defineQuest<T extends Record<string, z.ZodType>, const G extend
290
681
  rewards: Reward[] | ((ctx: {
291
682
  settings: z.output<z.ZodObject<T>>;
292
683
  }) => Reward[]);
293
- evaluate?: Evaluator<z.output<z.ZodObject<T>>, QuestInput<G>>;
684
+ evaluate?: Evaluator<z.output<z.ZodObject<T>>, QuestInput<G>, NoInfer<G>>;
294
685
  performance?: G extends {
295
686
  content: unknown;
296
687
  } ? {
@@ -304,7 +695,7 @@ declare function defineQuest<T extends Record<string, z.ZodType>, const G extend
304
695
  content: AdmittedContent;
305
696
  metrics: Record<M[number], number>;
306
697
  observedAt: number;
307
- }) => Outcome | Promise<Outcome>;
698
+ }) => PerformanceOutcome | Promise<PerformanceOutcome>;
308
699
  } : never;
309
700
  }): {
310
701
  key: string;
@@ -349,12 +740,12 @@ declare function defineQuest<T extends Record<string, z.ZodType>, const G extend
349
740
  kind: "resource";
350
741
  default: string;
351
742
  source: {
352
- provider: "domino";
353
- resource: "point-ledger";
354
- } | {
355
743
  provider: "discord";
356
744
  resource: "channel";
357
745
  types: ("text" | "announcement")[];
746
+ } | {
747
+ provider: "domino";
748
+ resource: "point-ledger";
358
749
  } | {
359
750
  provider: "discord";
360
751
  resource: "role";
@@ -453,7 +844,7 @@ declare function defineQuest<T extends Record<string, z.ZodType>, const G extend
453
844
  };
454
845
  enrollment: "required" | "none";
455
846
  posts: "after-enrollment" | "since-start";
456
- historical: "staff" | "automatic" | "claim";
847
+ historical: "automatic" | "claim" | "staff";
457
848
  } | undefined;
458
849
  tracker?: {
459
850
  tracker: string;
@@ -477,7 +868,24 @@ declare function defineQuest<T extends Record<string, z.ZodType>, const G extend
477
868
  } | {
478
869
  path: string;
479
870
  equals: string | number | boolean;
480
- } | undefined;
871
+ } | ({
872
+ path: string;
873
+ gt?: number | {
874
+ setting: string;
875
+ } | undefined;
876
+ gte?: number | {
877
+ setting: string;
878
+ } | undefined;
879
+ lt?: number | {
880
+ setting: string;
881
+ } | undefined;
882
+ lte?: number | {
883
+ setting: string;
884
+ } | undefined;
885
+ } | {
886
+ path: string;
887
+ equals: string | number | boolean;
888
+ })[] | undefined;
481
889
  } | undefined;
482
890
  } | {
483
891
  kind: "manual";
@@ -487,7 +895,7 @@ declare function defineQuest<T extends Record<string, z.ZodType>, const G extend
487
895
  minLength: number;
488
896
  maxLength: number;
489
897
  };
490
- actor?: "staff" | "member" | undefined;
898
+ actor?: "member" | "staff" | undefined;
491
899
  } | {
492
900
  kind: "manual";
493
901
  input: "url";
@@ -495,15 +903,14 @@ declare function defineQuest<T extends Record<string, z.ZodType>, const G extend
495
903
  required: boolean;
496
904
  allowedHosts?: string[] | undefined;
497
905
  };
498
- actor?: "staff" | "member" | undefined;
906
+ actor?: "member" | "staff" | undefined;
499
907
  } | {
500
908
  kind: "manual";
501
- input: "photo" | "quiz" | "none";
502
- actor?: "staff" | "member" | undefined;
909
+ input: "none" | "quiz" | "photo";
910
+ actor?: "member" | "staff" | undefined;
503
911
  };
504
912
  requires: {
505
913
  quest: string;
506
- scope: "ever";
507
914
  }[];
508
915
  completion: {
509
916
  kind: "streak";
@@ -518,7 +925,7 @@ declare function defineQuest<T extends Record<string, z.ZodType>, const G extend
518
925
  budgets: {
519
926
  id: string;
520
927
  scope: "member" | "project";
521
- period: "lifetime" | "day" | "week";
928
+ period: "day" | "lifetime" | "week";
522
929
  limit: number;
523
930
  cost: number | {
524
931
  balance: string;
@@ -542,4 +949,4 @@ declare function defineQuest<T extends Record<string, z.ZodType>, const G extend
542
949
  * Console instances receive independent quest identities and pinned versions. */
543
950
  declare const defineQuestType: typeof defineQuest;
544
951
 
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 };
952
+ export { type EvaluationContext, ImageReader, type KeyedContext, type PerformanceOutcome, Setting, Tracker, TrackerData, TrackerReader, type TrackerTrigger, TrackerTriggerContext, type TrackerTriggerInput, WalletBalance, WalletBalanceQuery, 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 };