@domino-sdk/relay 1.0.0-next.2 → 1.0.0-next.4

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.
@@ -1,5 +1,5 @@
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';
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
3
  import { z } from 'zod';
4
4
  import { TextReviewInput, TextResult, PhotoResult, rewardSchema, triggerSchema, QuestPresentation, QuestProfile, QuizEvidence, Decision, TieredRewardDefinition } from './schema.js';
5
5
 
@@ -114,6 +114,8 @@ declare const keyed: (key: (ctx: {
114
114
  /** The pinned tracker observation of a tracker-triggered quest. */
115
115
  tracker?: TrackerTriggerContext | null;
116
116
  eligibleAt: number;
117
+ /** The attempt's evaluation time; see {@link EvaluationContext.now}. */
118
+ now: number;
117
119
  }) => string) => {
118
120
  kind: "keyed";
119
121
  key: (ctx: {
@@ -125,6 +127,8 @@ declare const keyed: (key: (ctx: {
125
127
  /** The pinned tracker observation of a tracker-triggered quest. */
126
128
  tracker?: TrackerTriggerContext | null;
127
129
  eligibleAt: number;
130
+ /** The attempt's evaluation time; see {@link EvaluationContext.now}. */
131
+ now: number;
128
132
  }) => string;
129
133
  };
130
134
  declare const completed: (quest: AuthoringIdentity | string) => {
@@ -230,7 +234,18 @@ type EvaluationContext<T, I = {
230
234
  * was attributed to. Null unless the quest has a tracker trigger.
231
235
  */
232
236
  tracker: TrackerTriggerContext | null;
237
+ /**
238
+ * When the activity happened, in epoch milliseconds: the observation's or tracker record's
239
+ * occurrence time, else when the attempt was admitted. Budgets and daily keys use it.
240
+ */
233
241
  eligibleAt: number;
242
+ /**
243
+ * The attempt's evaluation time, in epoch milliseconds: when its first evaluation started.
244
+ * Every retry and replay of the attempt receives the same value, and the sandbox freezes
245
+ * `Date.now()` and `new Date()` at it. Use `eligibleAt` for when the activity
246
+ * happened.
247
+ */
248
+ now: number;
234
249
  trackers: TrackerReader;
235
250
  x: XReader;
236
251
  images: ImageReader;
package/dist/authoring.js CHANGED
@@ -182,27 +182,21 @@ function defineQuest(definition) {
182
182
  throw new Error("Performance requires a content trigger");
183
183
  }
184
184
  const trackerTrigger = definition.trigger.kind === "automatic" && definition.trigger.tracker !== void 0;
185
- if (trackerTrigger && definition.completion.kind === "streak") {
186
- throw new Error("Tracker triggers complete once() or keyed()");
187
- }
188
185
  const contentCompletion = "perContent" in definition.completion;
189
186
  if (contentTrigger !== contentCompletion) {
190
187
  throw new Error(
191
188
  "Content triggers require perContent completion, and perContent requires a content trigger"
192
189
  );
193
190
  }
194
- if (definition.completion.kind === "streak" && (definition.trigger.kind !== "automatic" || !definition.trigger.observation)) {
195
- throw new Error("Streaks require an automatic observation trigger");
196
- }
197
191
  const bareAutomatic = definition.trigger.kind === "automatic" && !definition.trigger.observation && !definition.trigger.content && !definition.trigger.tracker;
198
192
  if (bareAutomatic && !definition.requires?.length) {
199
193
  throw new Error(
200
194
  "A bare automatic() quest needs at least one requires entry, such as requires: [completed(quest)]. Give it an observation, content or tracker trigger, or a prerequisite."
201
195
  );
202
196
  }
203
- if (bareAutomatic && definition.completion.kind === "keyed") {
197
+ if (bareAutomatic && definition.completion.kind !== "once") {
204
198
  throw new Error(
205
- "A bare automatic() quest cannot use keyed() completion. Give it an observation, content or tracker trigger, or use once()."
199
+ `A bare automatic() quest cannot use ${definition.completion.kind}() completion. Give it a tracker or observation trigger, or use once().`
206
200
  );
207
201
  }
208
202
  if (definition.trigger.kind === "manual" && definition.trigger.input !== "none" && !definition.evaluate) {
@@ -315,6 +309,7 @@ function defineQuest(definition) {
315
309
  observation: ctx.observation ?? null,
316
310
  tracker,
317
311
  eligibleAt: ctx.eligibleAt,
312
+ now: ctx.now,
318
313
  review: ctx.review,
319
314
  trackers: ctx.trackers,
320
315
  wallet: ctx.wallet,