@domino-sdk/relay 1.1.0 → 1.1.1

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,6 +1,6 @@
1
1
  import { b as QuestEnrollmentInput, Q as QuestClaimInput, f as QuestOutcomeQuery, i as QuestView, P as questExperienceSchema, n as RewardDeliveryAction, A as contentQualificationQuerySchema } from './outcomes-kVB-Juzs.js';
2
2
  import { aG as referralAcceptSchema, g as LeaderboardQuery, b as CampaignEnrollmentInput, d as CampaignWithdrawalInput, m as PointHistoryQuery, k as PointEntryKind, V as engagementPageQuerySchema } from './groups-Ck-OxzjD.js';
3
- import { n as createRelayClient, g as RelayError, m as SubmissionStore, k as RelayRequestOptions, c as QuestController, a as ProgressObservation, b as ProgressObserver, P as PhotoSubmission, e as QuizSubmission, C as ClaimSubmission, V as ValueSubmission } from './client-XiuFnug_.js';
3
+ import { n as createRelayClient, g as RelayError, m as SubmissionStore, k as RelayRequestOptions, c as QuestController, a as ProgressObservation, b as ProgressObserver, P as PhotoSubmission, e as QuizSubmission, C as ClaimSubmission, V as ValueSubmission } from './client-gqnRUHpC.js';
4
4
  import { a as PageQuery, g as exchangeSchema, R as RelayEvent, b as ParticipantActivity } from './pages-BBYD21IE.js';
5
5
  import { a as AuthProvider } from './submission-input-BZkm6ohU.js';
6
6
  import { C as CosmosChain, a as CosmosNetwork, f as WalletSigner, d as WalletSignInNetwork, y as walletAddressInputSchema, I as walletSignatureSchema, L as LinkedWallet } from './wallet-YssWxGg8.js';
package/dist/browser.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  import './outcomes-kVB-Juzs.js';
2
2
  import './groups-Ck-OxzjD.js';
3
- import './client-XiuFnug_.js';
3
+ import './client-gqnRUHpC.js';
4
4
  import './pages-BBYD21IE.js';
5
5
  import './submission-input-BZkm6ohU.js';
6
6
  import './wallet-YssWxGg8.js';
7
7
  import './schema-DfJzH2ci.js';
8
8
  import './profiles-D2aFcOxu.js';
9
- export { C as CosmosChains, D as DiscoveredWallet, f as Eip1193Provider, E as EmailSignInOption, K as KeplrLike, O as OAuthSignInOption, g as SignInClient, e as SignInIcon, S as SignInMethods, a as SignInOption, h as SignInOptions, b as SignInUnavailable, d as SignInWallet, i as SolanaInjectedProvider, j as StandardWallet, k as StandardWalletAccount, W as WalletSignInOption, l as browserSubmissionStore, m as cosmosChainList, n as cosmosSigner, c as createBrowserRelayClient, o as discoverCosmosWallets, p as discoverEvmWallets, q as discoverSignInWallets, r as discoverSolanaWallets, s as evmSigner, t as signInOptions, u as solanaSigner, w as walletStandardSolanaSigner } from './browser-J7tUpXxy.js';
9
+ export { C as CosmosChains, D as DiscoveredWallet, f as Eip1193Provider, E as EmailSignInOption, K as KeplrLike, O as OAuthSignInOption, g as SignInClient, e as SignInIcon, S as SignInMethods, a as SignInOption, h as SignInOptions, b as SignInUnavailable, d as SignInWallet, i as SolanaInjectedProvider, j as StandardWallet, k as StandardWalletAccount, W as WalletSignInOption, l as browserSubmissionStore, m as cosmosChainList, n as cosmosSigner, c as createBrowserRelayClient, o as discoverCosmosWallets, p as discoverEvmWallets, q as discoverSignInWallets, r as discoverSolanaWallets, s as evmSigner, t as signInOptions, u as solanaSigner, w as walletStandardSolanaSigner } from './browser-Cf1opQjX.js';
10
10
  import 'zod';
11
11
  import './request-error-DWduJCGV.js';
package/dist/browser.js CHANGED
@@ -11,8 +11,8 @@ import {
11
11
  signInOptions,
12
12
  solanaSigner,
13
13
  walletStandardSolanaSigner
14
- } from "./chunk-ZVIRG24J.js";
15
- import "./chunk-GZ6FJAXN.js";
14
+ } from "./chunk-24AFCBZN.js";
15
+ import "./chunk-DGWMLN35.js";
16
16
  import "./chunk-EYH5RDIE.js";
17
17
  import "./chunk-36HTX2BM.js";
18
18
  import "./chunk-6QJ3LADK.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createRelayClient
3
- } from "./chunk-GZ6FJAXN.js";
3
+ } from "./chunk-DGWMLN35.js";
4
4
  import {
5
5
  RelayErrorCode,
6
6
  asRelayError,
@@ -22,6 +22,7 @@ import {
22
22
  engagementBoundaryPageSchema,
23
23
  engagementPageQuerySchema,
24
24
  engagementPageSchema,
25
+ isRelayError,
25
26
  leaderboardDefinitionSchema,
26
27
  leaderboardPageSchema,
27
28
  leaderboardPlacementSchema,
@@ -104,7 +105,7 @@ var draftSchema = z.union([
104
105
  claimInputSchema,
105
106
  z.object({ kind: z.literal("photo"), file: z.instanceof(Blob) })
106
107
  ]);
107
- var recordSchema = z.union([
108
+ var activeRecordSchema = z.union([
108
109
  z.object({
109
110
  ...common,
110
111
  stage: z.literal("review"),
@@ -131,6 +132,14 @@ var recordSchema = z.union([
131
132
  attempt: identifier
132
133
  })
133
134
  ]);
135
+ var recordSchema = z.union([
136
+ activeRecordSchema,
137
+ z.object({
138
+ ...common,
139
+ stage: z.literal("retired"),
140
+ previous: activeRecordSchema
141
+ })
142
+ ]);
134
143
  function submissions(transport, configuredStore, namespace) {
135
144
  async function open(quest, options = {
136
145
  input: "photo"
@@ -184,7 +193,7 @@ function submissions(transport, configuredStore, namespace) {
184
193
  }
185
194
  const record = parsed.data;
186
195
  const input = record.stage === "review" ? record.draft?.kind : "input" in record ? record.input.kind : "photo";
187
- if (!options.recoverPrevious && input !== options.input) {
196
+ if (record.stage !== "retired" && !options.recoverPrevious && input !== options.input) {
188
197
  throw clientError(
189
198
  "Saved submission uses a different input type. Reopen it with its original type to recover it.",
190
199
  RelayErrorCode.SubmissionConflict
@@ -192,18 +201,40 @@ function submissions(transport, configuredStore, namespace) {
192
201
  }
193
202
  return record;
194
203
  }
195
- function claim(record) {
196
- return transport.claim(
197
- {
198
- quest,
199
- actionId: record.id,
200
- ...record.release ? { release: record.release } : {},
201
- ..."evidence" in record ? { evidence: record.evidence } : record.input.kind !== "none" ? { input: record.input } : {}
202
- },
203
- sessionId
204
+ async function claim(record) {
205
+ try {
206
+ return await transport.claim(
207
+ {
208
+ quest,
209
+ actionId: record.id,
210
+ ...record.release ? { release: record.release } : {},
211
+ ..."evidence" in record ? { evidence: record.evidence } : record.input.kind !== "none" ? { input: record.input } : {}
212
+ },
213
+ sessionId
214
+ );
215
+ } catch (error) {
216
+ if (isRelayError(error) && error.kind === "http" && !error.uncertain && error.status === 409 && error.code === "operation-retired") {
217
+ await store.write(key, {
218
+ id: record.id,
219
+ quest,
220
+ release: record.release,
221
+ stage: "retired",
222
+ previous: record
223
+ });
224
+ }
225
+ throw error;
226
+ }
227
+ }
228
+ function retiredError() {
229
+ return clientError(
230
+ "This saved submission was retired. Review the current quest, then discard it before starting a new submission.",
231
+ "operation-retired"
204
232
  );
205
233
  }
206
234
  async function resumeRecord(saved) {
235
+ if (saved.stage === "retired") {
236
+ throw retiredError();
237
+ }
207
238
  if (saved.stage === "review") {
208
239
  throw new QuestUpdatedError(
209
240
  "This quest changed. Review it before submitting again.",
@@ -267,6 +298,9 @@ function submissions(transport, configuredStore, namespace) {
267
298
  return store.exclusive(key, async () => {
268
299
  await currentSession();
269
300
  const existing = await read();
301
+ if (existing?.stage === "retired") {
302
+ throw retiredError();
303
+ }
270
304
  if (existing?.stage === "review" && existing.release === record.release) {
271
305
  throw new QuestUpdatedError(
272
306
  "Review the latest quest before submitting again.",
@@ -301,6 +335,10 @@ function submissions(transport, configuredStore, namespace) {
301
335
  if (!record) {
302
336
  return;
303
337
  }
338
+ if (record.stage === "retired") {
339
+ await store.write(key, null);
340
+ return;
341
+ }
304
342
  if (record.stage !== "submitted") {
305
343
  throw clientError(
306
344
  "Resume the unfinished submission before starting over.",
@@ -323,6 +361,9 @@ function submissions(transport, configuredStore, namespace) {
323
361
  if (!record) {
324
362
  return { kind: "empty" };
325
363
  }
364
+ if (record.stage === "retired") {
365
+ return { kind: "needs-review", reason: "operation-retired" };
366
+ }
326
367
  if (record.stage === "review") {
327
368
  return { kind: "needs-review" };
328
369
  }
@@ -99,6 +99,7 @@ type SubmissionStatus = {
99
99
  kind: "empty";
100
100
  } | {
101
101
  kind: "needs-review";
102
+ reason?: "operation-retired";
102
103
  } | {
103
104
  kind: "pending";
104
105
  stage: "upload" | "claim";
@@ -3415,7 +3416,17 @@ declare function createRelayClient(options: RelayClientOptions): {
3415
3416
  (quest: string, options?: {
3416
3417
  input: "photo";
3417
3418
  release?: string;
3418
- recoverPrevious?: boolean;
3419
+ recoverPrevious
3420
+ /**
3421
+ * The session ID the app read (`auth.session()`). Relay refuses the call with a `RelayError`
3422
+ * whose code is `stale-session` if the member's session changed since. Calls Relay binds to a
3423
+ * session (wallet linking, collection passes, retries) read the current session when omitted.
3424
+ */
3425
+ ? /**
3426
+ * The session ID the app read (`auth.session()`). Relay refuses the call with a `RelayError`
3427
+ * whose code is `stale-session` if the member's session changed since. Calls Relay binds to a
3428
+ * session (wallet linking, collection passes, retries) read the current session when omitted.
3429
+ */: boolean;
3419
3430
  repeatable?: boolean;
3420
3431
  }): Promise<PhotoSubmission>;
3421
3432
  (quest: string, options: {
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { C as ClaimSubmission, K as KnownRelayErrorCode, P as PhotoSubmission, a as ProgressObservation, b as ProgressObserver, Q as QuestActionResult, c as QuestController, d as QuestUpdatedError, e as QuizSubmission, R as RelayClient, f as RelayClientOptions, g as RelayError, h as RelayErrorCode, i as RelayErrorDetails, j as RelayErrorKind, k as RelayRequestOptions, S as SubmissionDraft, l as SubmissionStatus, m as SubmissionStore, V as ValueSubmission, n as createRelayClient, o as isRelayError } from './client-XiuFnug_.js';
1
+ export { C as ClaimSubmission, K as KnownRelayErrorCode, P as PhotoSubmission, a as ProgressObservation, b as ProgressObserver, Q as QuestActionResult, c as QuestController, d as QuestUpdatedError, e as QuizSubmission, R as RelayClient, f as RelayClientOptions, g as RelayError, h as RelayErrorCode, i as RelayErrorDetails, j as RelayErrorKind, k as RelayRequestOptions, S as SubmissionDraft, l as SubmissionStatus, m as SubmissionStore, V as ValueSubmission, n as createRelayClient, o as isRelayError } from './client-gqnRUHpC.js';
2
2
  export { R as RequestError, a as RequestErrorDetails, b as RequestErrorKind, c as RequestRecovery, i as isRequestError } from './request-error-DWduJCGV.js';
3
3
  export { A as Attempt, a as AttemptStatus, E as Entitlement, b as EvaluatorProgress, K as KnownAttemptStatus, c as KnownTrackerSkipCode, M as MemberProgress, Q as QuestBudgetView, d as QuestPresentation, e as QuestProfile, f as QuizEvidence, R as Reward, S as SubmissionEvidence, g as SubmitInput, T as TieredRewardReference, h as TrackerSkipCode } from './schema-DfJzH2ci.js';
4
4
  export { f as formatUnits, p as parseUnits } from './units-CwgsPB_r.js';
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  import {
6
6
  QuestUpdatedError,
7
7
  createRelayClient
8
- } from "./chunk-GZ6FJAXN.js";
8
+ } from "./chunk-DGWMLN35.js";
9
9
  import {
10
10
  QuestOutcomeState
11
11
  } from "./chunk-EYH5RDIE.js";
@@ -1,5 +1,5 @@
1
1
  import { P as Page, d as ParticipantSession, R as RelayEvent, b as ParticipantActivity, a as PageQuery, g as exchangeSchema, M as MemberSummary } from '../pages-BBYD21IE.js';
2
- import { g as RelayError, k as RelayRequestOptions, c as QuestController, a as ProgressObservation, b as ProgressObserver, P as PhotoSubmission, e as QuizSubmission, C as ClaimSubmission, V as ValueSubmission, S as SubmissionDraft } from '../client-XiuFnug_.js';
2
+ import { g as RelayError, k as RelayRequestOptions, c as QuestController, a as ProgressObservation, b as ProgressObserver, P as PhotoSubmission, e as QuizSubmission, C as ClaimSubmission, V as ValueSubmission, S as SubmissionDraft } from '../client-gqnRUHpC.js';
3
3
  import * as react from 'react';
4
4
  import { ReactNode } from 'react';
5
5
  import { i as QuestView, b as QuestEnrollmentInput, Q as QuestClaimInput, f as QuestOutcomeQuery, P as questExperienceSchema, n as RewardDeliveryAction, A as contentQualificationQuerySchema, d as QuestOutcome } from '../outcomes-kVB-Juzs.js';
@@ -7,8 +7,8 @@ import { aG as referralAcceptSchema, g as LeaderboardQuery, b as CampaignEnrollm
7
7
  import { E as Entitlement, a as AttemptStatus, h as TrackerSkipCode, bI as submitSchema, aI as contentPerformanceQuerySchema, T as TieredRewardReference } from '../schema-DfJzH2ci.js';
8
8
  import { y as walletAddressInputSchema, I as walletSignatureSchema, L as LinkedWallet, f as WalletSigner, d as WalletSignInNetwork } from '../wallet-YssWxGg8.js';
9
9
  import { F as profileUpdateSchema, c as ProfileCompletionQuery, f as ProfileUpdate, e as ProfileSummary, a as ProfileCompletion, d as ProfileReferral } from '../profiles-D2aFcOxu.js';
10
- import { c as createBrowserRelayClient, J as JSONType, S as SignInMethods, C as CosmosChains, a as SignInOption, b as SignInUnavailable, d as SignInWallet, D as DiscoveredWallet } from '../browser-J7tUpXxy.js';
11
- export { E as EmailSignInOption, O as OAuthSignInOption, e as SignInIcon, W as WalletSignInOption } from '../browser-J7tUpXxy.js';
10
+ import { c as createBrowserRelayClient, J as JSONType, S as SignInMethods, C as CosmosChains, a as SignInOption, b as SignInUnavailable, d as SignInWallet, D as DiscoveredWallet } from '../browser-Cf1opQjX.js';
11
+ export { E as EmailSignInOption, O as OAuthSignInOption, e as SignInIcon, W as WalletSignInOption } from '../browser-Cf1opQjX.js';
12
12
  import * as zod from 'zod';
13
13
  import { z } from 'zod';
14
14
  import { a as AuthProvider, A as AccountConnection } from '../submission-input-BZkm6ohU.js';
@@ -4971,6 +4971,8 @@ declare function useQuest(observed: QuestView): {
4971
4971
  error: RelayError | null;
4972
4972
  busy: boolean;
4973
4973
  saved: SavedSubmission;
4974
+ /** Review and explicitly restart this terminally retired saved submission. */
4975
+ retired: boolean;
4974
4976
  /** The attempt the last "received" notice is about. */
4975
4977
  receipt: string | null;
4976
4978
  startingFresh: boolean;
@@ -8,8 +8,8 @@ import {
8
8
  discoverSolanaWallets,
9
9
  readSignInMethods,
10
10
  signInOptionsFrom
11
- } from "../chunk-ZVIRG24J.js";
12
- import "../chunk-GZ6FJAXN.js";
11
+ } from "../chunk-24AFCBZN.js";
12
+ import "../chunk-DGWMLN35.js";
13
13
  import "../chunk-EYH5RDIE.js";
14
14
  import {
15
15
  RelayErrorCode,
@@ -1447,6 +1447,8 @@ function useQuest(observed) {
1447
1447
  const [busy, setBusy] = useState4(false);
1448
1448
  const [discardedAttempt, setDiscardedAttempt] = useState4(null);
1449
1449
  const [saved, setSaved] = useState4("none");
1450
+ const [recoveryRevision, setRecoveryRevision] = useState4(0);
1451
+ const [retired, setRetired] = useState4(false);
1450
1452
  const [receipt, setReceipt] = useState4(null);
1451
1453
  useEffect5(() => setLatest(null), [observed.release]);
1452
1454
  const view = latest ?? observed;
@@ -1459,6 +1461,9 @@ function useQuest(observed) {
1459
1461
  if (!active) {
1460
1462
  return;
1461
1463
  }
1464
+ setRetired(
1465
+ !completed && status.kind === "needs-review" && status.reason === "operation-retired"
1466
+ );
1462
1467
  setSaved(
1463
1468
  completed || status.kind === "empty" || status.kind === "submitted" ? "none" : status.kind === "needs-review" ? "outdated" : "interrupted"
1464
1469
  );
@@ -1467,7 +1472,7 @@ function useQuest(observed) {
1467
1472
  return () => {
1468
1473
  active = false;
1469
1474
  };
1470
- }, [relay, quest, release, completed, attempt, busy]);
1475
+ }, [relay, quest, release, completed, attempt, busy, recoveryRevision]);
1471
1476
  const run = useCallback4(
1472
1477
  async (action) => {
1473
1478
  setBusy(true);
@@ -1489,6 +1494,7 @@ function useQuest(observed) {
1489
1494
  setError(asRelayError(cause, "Something went wrong."));
1490
1495
  } finally {
1491
1496
  setBusy(false);
1497
+ setRecoveryRevision((revision) => revision + 1);
1492
1498
  }
1493
1499
  },
1494
1500
  [store]
@@ -1507,12 +1513,14 @@ function useQuest(observed) {
1507
1513
  await (await relay.quests.open(current)).discard();
1508
1514
  setDiscardedAttempt(current.attempt?.id ?? null);
1509
1515
  setSaved("none");
1516
+ setRetired(false);
1510
1517
  setDraft(null);
1511
1518
  setNotice(null);
1512
1519
  } catch (cause) {
1513
1520
  setError(asRelayError(cause, "Could not start a new submission."));
1514
1521
  } finally {
1515
1522
  setBusy(false);
1523
+ setRecoveryRevision((revision) => revision + 1);
1516
1524
  }
1517
1525
  },
1518
1526
  submit: (input) => run(async () => {
@@ -1573,12 +1581,25 @@ function useQuest(observed) {
1573
1581
  error,
1574
1582
  busy,
1575
1583
  saved,
1584
+ /** Review and explicitly restart this terminally retired saved submission. */
1585
+ retired,
1576
1586
  /** The attempt the last "received" notice is about. */
1577
1587
  receipt,
1578
1588
  startingFresh,
1579
1589
  ...actions
1580
1590
  }),
1581
- [view, draft, notice, error, busy, saved, receipt, startingFresh, actions]
1591
+ [
1592
+ view,
1593
+ draft,
1594
+ notice,
1595
+ error,
1596
+ busy,
1597
+ saved,
1598
+ retired,
1599
+ receipt,
1600
+ startingFresh,
1601
+ actions
1602
+ ]
1582
1603
  );
1583
1604
  }
1584
1605
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domino-sdk/relay",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {