@domino-sdk/relay 1.61.0 → 1.63.0

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 (88) hide show
  1. package/CHANGELOG.md +276 -8
  2. package/README.md +3 -2
  3. package/dist/{schema-CZ6Rj0ZF.d.ts → accounts-nz3mzfRQ.d.ts} +3146 -1765
  4. package/dist/action-9Xl0StBg.d.ts +33 -0
  5. package/dist/{attempt-captures-DYnJVkfg.d.ts → attempt-captures-DMi8oR9T.d.ts} +1 -1
  6. package/dist/authoring.d.ts +171 -49
  7. package/dist/authoring.js +158 -49
  8. package/dist/{automatic-outcomes-If88LR9f.d.ts → automatic-outcomes-C_LLQU1p.d.ts} +15 -1
  9. package/dist/avatar.d.ts +1 -1
  10. package/dist/browser.d.ts +15 -11
  11. package/dist/browser.js +18 -12
  12. package/dist/capability-error-CuI_F7yM.d.ts +296 -0
  13. package/dist/{pages-K7-KjSXw.d.ts → catalog-BaTOKpNw.d.ts} +56 -567
  14. package/dist/{chunk-XBV2CK2H.js → chunk-3RFP6GT5.js} +15 -3
  15. package/dist/{chunk-VURRFVNP.js → chunk-4GQW43UU.js} +239 -361
  16. package/dist/chunk-4NOFSGAL.js +320 -0
  17. package/dist/{chunk-24I4R732.js → chunk-5XLZ34PV.js} +34 -19
  18. package/dist/{chunk-L77O64I4.js → chunk-7X67QLPB.js} +43 -43
  19. package/dist/{chunk-RHBS5FJL.js → chunk-7Z4SZ6YM.js} +3 -3
  20. package/dist/{chunk-QEAS4ZGS.js → chunk-AQOL3SK5.js} +1 -1
  21. package/dist/chunk-EHUSD3O2.js +377 -0
  22. package/dist/chunk-FO2LCZTL.js +19 -0
  23. package/dist/{chunk-DYXDZFKA.js → chunk-FU5CGNTR.js} +166 -178
  24. package/dist/chunk-FWLQ5XCS.js +21 -0
  25. package/dist/chunk-GLH6MEI2.js +193 -0
  26. package/dist/chunk-ICXZZNPS.js +199 -0
  27. package/dist/{chunk-ZDJLPN4L.js → chunk-ID3BZXFZ.js} +2696 -2693
  28. package/dist/chunk-KP2MCX3R.js +587 -0
  29. package/dist/{chunk-SKGTNTLF.js → chunk-LZWXCBUB.js} +213 -297
  30. package/dist/chunk-MTKRIQEU.js +31 -0
  31. package/dist/{chunk-4OC7REYX.js → chunk-MWMCQLCG.js} +3 -3
  32. package/dist/{chunk-PPB7HALD.js → chunk-N4BDKS6Y.js} +27 -26
  33. package/dist/{chunk-5I54XBK2.js → chunk-N4LNEGQX.js} +2 -2
  34. package/dist/chunk-NQDEWJWE.js +554 -0
  35. package/dist/chunk-QR6HH4DI.js +508 -0
  36. package/dist/chunk-TLSQETTY.js +41 -0
  37. package/dist/{chunk-MHPKEVEW.js → chunk-U66GUVSG.js} +7 -2
  38. package/dist/{chunk-KDR2VAJP.js → chunk-UYVJZR33.js} +2 -2
  39. package/dist/chunk-UZ765UGH.js +18 -0
  40. package/dist/{chunk-7A4J67ZL.js → chunk-VWQGWGCH.js} +7 -7
  41. package/dist/chunk-W7YSMSGC.js +725 -0
  42. package/dist/{client-C51w7fMb.d.ts → client-DHmG7rn6.d.ts} +126 -93
  43. package/dist/{announcements-CHx3-HBw.d.ts → dashboards-CLemT6kj.d.ts} +14 -137
  44. package/dist/{deployments-kWoHFaqj.d.ts → deployments-DTULi7dF.d.ts} +450 -18
  45. package/dist/identity-integration-DOeNZaxF.d.ts +1271 -0
  46. package/dist/index.d.ts +13 -11
  47. package/dist/index.js +16 -11
  48. package/dist/internal.d.ts +29 -13
  49. package/dist/internal.js +57 -17
  50. package/dist/{integrations-B3y36OaB.d.ts → limits-kNzYdZ00.d.ts} +464 -53
  51. package/dist/{offers-BoV4ryUc.d.ts → offers-CYeN_I0Y.d.ts} +22 -4
  52. package/dist/{participant-activity-DHL8QYks.d.ts → participant-activity-D-Drp24G.d.ts} +16 -3
  53. package/dist/portal-proxy.d.ts +75 -2
  54. package/dist/portal-proxy.js +153 -25
  55. package/dist/react/index.d.ts +214 -27
  56. package/dist/react/index.js +196 -42
  57. package/dist/{action-DBzILFx9.d.ts → request-error-D_dUPLwo.d.ts} +1 -31
  58. package/dist/reward-deliveries-drp-x1G-.d.ts +782 -0
  59. package/dist/runtime/authoring.js +1 -1
  60. package/dist/runtime/chunks/UGDV5W4N.js +1 -0
  61. package/dist/runtime/manifest.json +3 -3
  62. package/dist/runtime/schema.js +1 -1
  63. package/dist/schema.d.ts +330 -31
  64. package/dist/schema.js +147 -91
  65. package/dist/server/index.d.ts +14 -12
  66. package/dist/server/index.js +6425 -6260
  67. package/dist/sign-in-providers-B1Q9eDRm.d.ts +44 -0
  68. package/dist/submission-input-DZCbjQUH.d.ts +343 -0
  69. package/dist/{telegram-browser-BUceZIGZ.d.ts → telegram-browser-NL0Asmsi.d.ts} +46 -6
  70. package/dist/telegram.d.ts +64 -0
  71. package/dist/telegram.js +23 -0
  72. package/dist/testing.d.ts +326 -27
  73. package/dist/testing.js +440 -90
  74. package/dist/tracker-data-esm3WG8R.d.ts +1881 -0
  75. package/dist/{transport-BrX9pIGN.d.ts → transport-Czht_irp.d.ts} +43483 -38512
  76. package/dist/{wallet-CIqFoxdm.d.ts → wallet-B7e06v4m.d.ts} +32 -9
  77. package/package.json +5 -1
  78. package/dist/accounts-DoabriBX.d.ts +0 -306
  79. package/dist/capability-error-DufwG3G0.d.ts +0 -159
  80. package/dist/chunk-3Y3L2F54.js +0 -982
  81. package/dist/chunk-DHXDBAJF.js +0 -544
  82. package/dist/chunk-EN3M5Z4J.js +0 -13
  83. package/dist/chunk-QNUHWK7R.js +0 -602
  84. package/dist/chunk-SE4PFJPT.js +0 -247
  85. package/dist/groups-CqcA2Ycs.d.ts +0 -2827
  86. package/dist/runtime/chunks/5QVFB4TU.js +0 -1
  87. package/dist/submission-input-C54Q8yAD.d.ts +0 -146
  88. package/dist/x-D1PGi8Sq.d.ts +0 -331
@@ -0,0 +1,193 @@
1
+ // src/request-error.ts
2
+ var requestErrorBrand = /* @__PURE__ */ (() => /* @__PURE__ */ Symbol.for("@domino-sdk/relay.RequestError"))();
3
+ function isRequestError(value) {
4
+ return typeof value === "object" && value !== null && value[requestErrorBrand] === true;
5
+ }
6
+ var RequestError = class extends Error {
7
+ name = "RequestError";
8
+ [requestErrorBrand] = true;
9
+ kind;
10
+ uncertain;
11
+ status;
12
+ code;
13
+ operationId;
14
+ /** `replay` for a replay-safe operation ID, else `reconcile`; only when `uncertain`. */
15
+ recovery;
16
+ /**
17
+ * Milliseconds the server asked the client to wait before trying again, from the `Retry-After`
18
+ * header of an error answer such as a 429 or 503. The client's own retries never wait past the
19
+ * call's deadline, so a longer wait is left to the caller.
20
+ */
21
+ retryAfter;
22
+ constructor(message, details) {
23
+ super(message, details.cause === void 0 ? {} : { cause: details.cause });
24
+ this.kind = details.kind;
25
+ this.uncertain = details.uncertain ?? false;
26
+ this.status = details.status;
27
+ this.code = details.code;
28
+ this.operationId = details.operationId;
29
+ this.retryAfter = details.retryAfter;
30
+ this.recovery = this.uncertain ? details.operationId && (details.replaySafe ?? true) ? "replay" : "reconcile" : void 0;
31
+ }
32
+ };
33
+
34
+ // src/errors.ts
35
+ import * as z from "zod";
36
+ var RelayErrorCode = {
37
+ /** The call needs a signed-in member. */
38
+ NotSignedIn: "not-signed-in",
39
+ /** The session changed since the app read it (the `session` option). Reload before retrying. */
40
+ StaleSession: "stale-session",
41
+ /**
42
+ * A participant backend (`createParticipantBackend`) refused the call because the app's own
43
+ * sign-in ended. The SDK treats it like `not-signed-in`: the member is signed out.
44
+ */
45
+ Unauthenticated: "unauthenticated",
46
+ /** The input failed validation before it was sent. */
47
+ InvalidInput: "invalid-input",
48
+ /** Relay's answer was not JSON or not the expected shape (kind `invalid-response`). */
49
+ InvalidResponse: "invalid-response",
50
+ /** The transport failed, before a response or while reading its body (kind `network`). */
51
+ Network: "network",
52
+ /** The client's deadline elapsed (kind `timeout`). */
53
+ Timeout: "timeout",
54
+ /** The caller cancelled the request (kind `aborted`). */
55
+ Aborted: "aborted",
56
+ /** A quest or collection the call named is not in the member's experience. */
57
+ NotFound: "not-found",
58
+ /** The quest has no failed attempt the member can retry. */
59
+ RetryUnavailable: "retry-unavailable",
60
+ /**
61
+ * Durable submission storage is missing, blocked or unreadable. Nothing was lost: call the
62
+ * handle's `status()` or `resume()` again once storage is available.
63
+ */
64
+ SubmissionStorage: "submission-storage",
65
+ /** Browser storage is full, so submission progress was not saved. Free space, then resume. */
66
+ SubmissionStorageQuota: "submission-storage-quota",
67
+ /** The saved submission is in a state that does not allow this action. */
68
+ SubmissionConflict: "submission-conflict",
69
+ /**
70
+ * The saved submission's operation belongs to a retired contract and cannot continue. Show the
71
+ * current quest and let the member `discard()` it before submitting again.
72
+ */
73
+ OperationRetired: "operation-retired",
74
+ /** The quest changed since the member saw it; review it before submitting again. */
75
+ QuestUpdated: "quest-updated",
76
+ /** Wait for the deferred attempt before submitting another action. */
77
+ AttemptPending: "attempt-pending",
78
+ /**
79
+ * The member's last attempt was rejected and the quest's retry cooldown is running; `retryAt`
80
+ * says when they may submit again.
81
+ */
82
+ RetryCooldown: "retry-cooldown",
83
+ /**
84
+ * The member's last accepted completion of the quest is more recent than its completion
85
+ * cooldown; `retryAt` says when they may submit again.
86
+ */
87
+ CompletionCooldown: "completion-cooldown",
88
+ /** The quiz changed since the member answered it. */
89
+ StaleQuiz: "stale-quiz",
90
+ /** Relay refused the submitted evidence. */
91
+ InvalidSubmission: "invalid-submission",
92
+ /** A page cursor Relay cannot read; start again from the first page. */
93
+ InvalidCursor: "invalid-cursor",
94
+ /** No point ledger in the project has the key or ID the call named. */
95
+ PointLedgerNotFound: "point-ledger-not-found",
96
+ /** The member has not joined this project, so it holds no points here. */
97
+ NotJoined: "not-joined",
98
+ /** The quest or campaign is not open at this time. */
99
+ OutsideWindow: "outside-window",
100
+ /** The signed-in member must enroll in the campaign first. */
101
+ EnrollmentRequired: "enrollment-required",
102
+ /** The quest's current reward budget has no remaining capacity. */
103
+ BudgetExhausted: "budget-exhausted",
104
+ /** No published offer has the key or ID the call named. */
105
+ OfferNotFound: "offer-not-found",
106
+ /** The operator paused this offer. */
107
+ OfferPaused: "offer-paused",
108
+ /** This member has already used the offer's allowed number of redemptions. */
109
+ OfferLimitReached: "offer-limit-reached",
110
+ /** No declared units remain. */
111
+ OfferOutOfStock: "offer-out-of-stock",
112
+ /** The participant's available point balance is below the offer price. */
113
+ InsufficientPoints: "insufficient-points",
114
+ /** The client's `getToken` failed before anything was sent; `cause` is its own error. */
115
+ Credential: "credential",
116
+ /** A wallet signer failed or the member refused to sign; `cause` is the wallet's own error. */
117
+ WalletSigner: "wallet-signer",
118
+ /** The member has not met the quest's or offer's prerequisites; `missing` lists them. */
119
+ PrerequisitesIncomplete: "prerequisites-incomplete",
120
+ /** The quest is archived or retired: it takes no new participation. */
121
+ QuestClosed: "quest-closed",
122
+ /** An operator paused the quest. */
123
+ QuestPaused: "quest-paused",
124
+ /** An operator locked the member's profile; hiding it is still allowed. */
125
+ ProfileLocked: "profile-locked",
126
+ /** No member in the project has the invitation code the member accepted. */
127
+ InvitationNotFound: "invitation-not-found",
128
+ /** The email sign-in code is wrong; the member can type it again. */
129
+ InvalidCode: "invalid-code",
130
+ /** The email sign-in code expired, was used or had too many attempts; request another. */
131
+ CodeExpired: "code-expired",
132
+ /** The wallet sign-in challenge expired, was used or changed; start sign-in again. */
133
+ ChallengeExpired: "challenge-expired",
134
+ /** Too many requests; `retryAfter` says how long to wait when Relay knows. */
135
+ RateLimited: "rate-limited"
136
+ };
137
+ var relayErrorBrand = /* @__PURE__ */ (() => /* @__PURE__ */ Symbol.for("@domino-sdk/relay.RelayError"))();
138
+ function isRelayError(value) {
139
+ return isRequestError(value) && value[relayErrorBrand] === true;
140
+ }
141
+ var RelayError = class extends RequestError {
142
+ name = "RelayError";
143
+ [relayErrorBrand] = true;
144
+ /** Which window refused admission when `code` is `outside-window`. */
145
+ window;
146
+ /** Prerequisites the member does not currently meet, when Relay refused for that reason. */
147
+ missing;
148
+ /**
149
+ * Unix milliseconds when the member may submit again, when `code` is `retry-cooldown` or
150
+ * `completion-cooldown`.
151
+ */
152
+ retryAt;
153
+ constructor(message, details) {
154
+ super(message, details);
155
+ this.window = details.window;
156
+ this.missing = details.missing ?? [];
157
+ this.retryAt = details.retryAt;
158
+ }
159
+ };
160
+ function asRelayError(cause, fallback = "Request failed") {
161
+ if (isRelayError(cause)) {
162
+ return cause;
163
+ }
164
+ return new RelayError(
165
+ cause instanceof Error && cause.message ? cause.message : fallback,
166
+ { kind: "client", cause }
167
+ );
168
+ }
169
+ function clientError(message, code, details = {}) {
170
+ return new RelayError(message, { ...details, kind: "client", code });
171
+ }
172
+ function parseInput(schema, value) {
173
+ const parsed = schema.safeParse(value);
174
+ if (!parsed.success) {
175
+ throw clientError(
176
+ z.prettifyError(parsed.error),
177
+ RelayErrorCode.InvalidInput,
178
+ { cause: parsed.error }
179
+ );
180
+ }
181
+ return parsed.data;
182
+ }
183
+
184
+ export {
185
+ isRequestError,
186
+ RequestError,
187
+ RelayErrorCode,
188
+ isRelayError,
189
+ RelayError,
190
+ asRelayError,
191
+ clientError,
192
+ parseInput
193
+ };
@@ -0,0 +1,199 @@
1
+ import {
2
+ clientIdentity,
3
+ retryAfter
4
+ } from "./chunk-3RFP6GT5.js";
5
+
6
+ // src/http-exchange.ts
7
+ var uncertainStatuses = /* @__PURE__ */ (() => /* @__PURE__ */ new Set([500, 502, 504]))();
8
+ function withQuery(path, values) {
9
+ const query = new URLSearchParams(
10
+ Object.entries(values).flatMap(
11
+ ([key, value]) => value === void 0 ? [] : [[key, String(value)]]
12
+ )
13
+ ).toString();
14
+ return query ? path + "?" + query : path;
15
+ }
16
+ function untilAborted(step, signal) {
17
+ return new Promise((resolve, reject) => {
18
+ const stop = () => reject(signal.reason);
19
+ if (signal?.aborted) {
20
+ return stop();
21
+ }
22
+ signal?.addEventListener("abort", stop, { once: true });
23
+ step().then(resolve, reject).finally(() => signal?.removeEventListener("abort", stop));
24
+ });
25
+ }
26
+ function createHttpExchange(options, policy) {
27
+ const { messages, makeError } = policy;
28
+ const failure = (kind, code, message, cause, context) => makeError(message, { kind, code, uncertain: false, cause }, context);
29
+ try {
30
+ const headers = new Headers(options.headers);
31
+ if (options.token) {
32
+ headers.set("Authorization", `Bearer ${options.token}`);
33
+ }
34
+ headers.set("X-Relay-Organization", options.organization ?? "");
35
+ headers.set("X-Relay-Project", options.project ?? "");
36
+ } catch (error) {
37
+ throw failure("client", "invalid-input", messages.invalidOptions, error);
38
+ }
39
+ function interrupted(error, method, context, life, stage) {
40
+ const kind = life.ended() ?? "network";
41
+ return makeError(
42
+ kind === "aborted" ? messages.aborted : kind === "timeout" ? messages.timeout(life.timeout) : messages.network(stage.status),
43
+ {
44
+ kind,
45
+ code: kind,
46
+ uncertain: stage.sent && method !== "GET" && // An error status whose body broke off still refused the write, unless the status itself
47
+ // does not prove that.
48
+ (!stage.refused || uncertainStatuses.has(stage.status ?? 0)),
49
+ status: stage.status,
50
+ retryAfter: stage.headers ? retryAfter(stage.headers) : void 0,
51
+ cause: kind === "aborted" && policy.abortReason ? life.reason() : error
52
+ },
53
+ context
54
+ );
55
+ }
56
+ async function credential(method, context, life) {
57
+ const getToken = options.getToken;
58
+ if (!getToken) {
59
+ return options.token;
60
+ }
61
+ try {
62
+ return await untilAborted(getToken, life.signal);
63
+ } catch (error) {
64
+ throw life.signal.aborted ? interrupted(error, method, context, life, { sent: false }) : failure(
65
+ // A token source that could not reach its own service failed like a network call.
66
+ error instanceof TypeError ? "network" : "client",
67
+ "credential",
68
+ messages.credential,
69
+ error,
70
+ context
71
+ );
72
+ }
73
+ }
74
+ async function send(path, request, context, life) {
75
+ const { json } = request;
76
+ const method = (request.method ?? (json === void 0 ? "GET" : "POST")).toUpperCase();
77
+ if (life.signal.aborted) {
78
+ throw interrupted(life.reason(), method, context, life, { sent: false });
79
+ }
80
+ const last = policy.credentialLast;
81
+ let token = last ? void 0 : await credential(method, context, life);
82
+ const headers = new Headers();
83
+ let body = request.body;
84
+ let invalidToken;
85
+ const authorize = () => {
86
+ if (token) {
87
+ try {
88
+ headers.set("Authorization", `Bearer ${token}`);
89
+ } catch (error) {
90
+ throw invalidToken = failure(
91
+ "client",
92
+ "credential",
93
+ messages.invalidToken,
94
+ error,
95
+ context
96
+ );
97
+ }
98
+ } else if (options.getToken) {
99
+ headers.delete("Authorization");
100
+ }
101
+ };
102
+ try {
103
+ for (const source of [options.headers, request.headers]) {
104
+ new Headers(source).forEach((value, name) => headers.set(name, value));
105
+ }
106
+ headers.set("X-Domino-Client", policy.client ?? clientIdentity());
107
+ if (!last) {
108
+ authorize();
109
+ }
110
+ const scope = [
111
+ ["X-Relay-Organization", options.organization],
112
+ ["X-Relay-Project", options.project],
113
+ ["X-Relay-Environment", options.environment],
114
+ ["X-Relay-Session", policy.session?.(context)]
115
+ ];
116
+ for (const [name, value] of scope) {
117
+ if (value) {
118
+ headers.set(name, value);
119
+ }
120
+ }
121
+ if (json !== void 0) {
122
+ headers.set("Content-Type", "application/json");
123
+ body = JSON.stringify(json);
124
+ }
125
+ if (policy.csrf && method !== "GET") {
126
+ headers.set("X-Relay-CSRF", "1");
127
+ }
128
+ } catch (error) {
129
+ throw error === invalidToken || !messages.unsendable ? error : failure(
130
+ "client",
131
+ "invalid-input",
132
+ messages.unsendable,
133
+ error,
134
+ context
135
+ );
136
+ }
137
+ if (last) {
138
+ token = await credential(method, context, life);
139
+ authorize();
140
+ }
141
+ if (life.signal.aborted) {
142
+ throw interrupted(life.reason(), method, context, life, { sent: false });
143
+ }
144
+ let response;
145
+ try {
146
+ response = await (options.fetch ?? fetch)(options.baseUrl + path, {
147
+ ...request.init,
148
+ method: request.method ?? method,
149
+ headers,
150
+ body,
151
+ signal: life.signal
152
+ });
153
+ } catch (error) {
154
+ throw interrupted(error, method, context, life, {
155
+ sent: !policy.neverSent?.(error)
156
+ });
157
+ }
158
+ if (!response.ok) {
159
+ let text;
160
+ try {
161
+ text = await response.text();
162
+ } catch (error) {
163
+ throw interrupted(error, method, context, life, {
164
+ sent: true,
165
+ status: response.status,
166
+ headers: response.headers,
167
+ refused: true
168
+ });
169
+ }
170
+ let value = null;
171
+ try {
172
+ value = JSON.parse(text);
173
+ } catch {
174
+ }
175
+ const { status } = response;
176
+ const { message, ...refusal } = policy.parseRefusal(value);
177
+ throw makeError(
178
+ message ?? `Request failed (${status})`,
179
+ {
180
+ ...refusal,
181
+ kind: "http",
182
+ status,
183
+ retryAfter: retryAfter(response.headers),
184
+ uncertain: method !== "GET" && uncertainStatuses.has(status)
185
+ },
186
+ context
187
+ );
188
+ }
189
+ return response;
190
+ }
191
+ return { send, interrupted };
192
+ }
193
+
194
+ export {
195
+ uncertainStatuses,
196
+ withQuery,
197
+ untilAborted,
198
+ createHttpExchange
199
+ };