@domino-sdk/relay 1.62.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 (74) hide show
  1. package/CHANGELOG.md +120 -0
  2. package/dist/{accounts-CCqCKCVx.d.ts → accounts-nz3mzfRQ.d.ts} +21 -3
  3. package/dist/{attempt-captures-Cm-5G0PC.d.ts → attempt-captures-DMi8oR9T.d.ts} +1 -1
  4. package/dist/authoring.d.ts +54 -20
  5. package/dist/authoring.js +58 -24
  6. package/dist/{automatic-outcomes-pAsOyIVp.d.ts → automatic-outcomes-C_LLQU1p.d.ts} +11 -1
  7. package/dist/avatar.d.ts +1 -1
  8. package/dist/browser.d.ts +9 -9
  9. package/dist/browser.js +15 -13
  10. package/dist/capability-error-CuI_F7yM.d.ts +296 -0
  11. package/dist/{catalog--ZIlskAo.d.ts → catalog-BaTOKpNw.d.ts} +21 -10
  12. package/dist/{chunk-3PYYGFSB.js → chunk-3RFP6GT5.js} +3 -3
  13. package/dist/{chunk-HTZHBTIL.js → chunk-4GQW43UU.js} +193 -357
  14. package/dist/{chunk-D26YNACF.js → chunk-4NOFSGAL.js} +56 -56
  15. package/dist/{chunk-UW5232GG.js → chunk-5XLZ34PV.js} +5 -5
  16. package/dist/{chunk-QYPMPWVX.js → chunk-7X67QLPB.js} +43 -43
  17. package/dist/{chunk-5TEYFX6X.js → chunk-7Z4SZ6YM.js} +2 -2
  18. package/dist/{chunk-Y322OTCH.js → chunk-AQOL3SK5.js} +1 -1
  19. package/dist/{chunk-CICDIBOF.js → chunk-EHUSD3O2.js} +76 -72
  20. package/dist/chunk-FO2LCZTL.js +19 -0
  21. package/dist/{chunk-3KLC4AMA.js → chunk-FU5CGNTR.js} +135 -173
  22. package/dist/{chunk-K2KS3JLY.js → chunk-GLH6MEI2.js} +7 -2
  23. package/dist/chunk-ICXZZNPS.js +199 -0
  24. package/dist/{chunk-MK425RXJ.js → chunk-ID3BZXFZ.js} +709 -640
  25. package/dist/{chunk-UAKYDVT3.js → chunk-KP2MCX3R.js} +111 -89
  26. package/dist/{chunk-GKIFABGN.js → chunk-LZWXCBUB.js} +74 -247
  27. package/dist/{chunk-6WCIWXUV.js → chunk-MTKRIQEU.js} +2 -2
  28. package/dist/{chunk-4OC7REYX.js → chunk-MWMCQLCG.js} +3 -3
  29. package/dist/{chunk-XJFYAXET.js → chunk-N4BDKS6Y.js} +19 -19
  30. package/dist/{chunk-E6IKQHTX.js → chunk-N4LNEGQX.js} +2 -2
  31. package/dist/chunk-NQDEWJWE.js +554 -0
  32. package/dist/{chunk-GTDW453U.js → chunk-QR6HH4DI.js} +100 -114
  33. package/dist/chunk-TLSQETTY.js +41 -0
  34. package/dist/{chunk-CZFXGGEK.js → chunk-U66GUVSG.js} +2 -2
  35. package/dist/{chunk-KDR2VAJP.js → chunk-UYVJZR33.js} +2 -2
  36. package/dist/chunk-UZ765UGH.js +18 -0
  37. package/dist/{chunk-XNKSSE32.js → chunk-VWQGWGCH.js} +7 -7
  38. package/dist/{chunk-WSBYWVTZ.js → chunk-W7YSMSGC.js} +166 -158
  39. package/dist/{client-B-hbHX30.d.ts → client-DHmG7rn6.d.ts} +25 -61
  40. package/dist/{capability-error-DFMwSuSf.d.ts → dashboards-CLemT6kj.d.ts} +14 -294
  41. package/dist/{deployments-M4OHn7G3.d.ts → deployments-DTULi7dF.d.ts} +46 -3
  42. package/dist/{identity-integration-3mX6b5iH.d.ts → identity-integration-DOeNZaxF.d.ts} +32 -2
  43. package/dist/index.d.ts +10 -10
  44. package/dist/index.js +13 -11
  45. package/dist/internal.d.ts +27 -13
  46. package/dist/internal.js +41 -13
  47. package/dist/{analytics-BwAKLi7O.d.ts → limits-kNzYdZ00.d.ts} +124 -3
  48. package/dist/{offers-DhAtss4_.d.ts → offers-CYeN_I0Y.d.ts} +3 -2
  49. package/dist/portal-proxy.d.ts +19 -3
  50. package/dist/portal-proxy.js +64 -22
  51. package/dist/react/index.d.ts +21 -14
  52. package/dist/react/index.js +55 -29
  53. package/dist/{pages-B8q8Y_dQ.d.ts → reward-deliveries-drp-x1G-.d.ts} +300 -233
  54. package/dist/runtime/authoring.js +1 -1
  55. package/dist/runtime/chunks/UGDV5W4N.js +1 -0
  56. package/dist/runtime/manifest.json +3 -3
  57. package/dist/runtime/schema.js +1 -1
  58. package/dist/schema.d.ts +193 -18
  59. package/dist/schema.js +31 -26
  60. package/dist/server/index.d.ts +13 -13
  61. package/dist/server/index.js +5885 -6224
  62. package/dist/{sign-in-providers-BkjcDsFF.d.ts → sign-in-providers-B1Q9eDRm.d.ts} +7 -2
  63. package/dist/{submission-input-DHGKhXfp.d.ts → submission-input-DZCbjQUH.d.ts} +3 -2
  64. package/dist/{telegram-browser-BCE7zdOb.d.ts → telegram-browser-NL0Asmsi.d.ts} +4 -4
  65. package/dist/telegram.d.ts +8 -8
  66. package/dist/telegram.js +2 -2
  67. package/dist/testing.d.ts +228 -26
  68. package/dist/testing.js +137 -92
  69. package/dist/{tracker-data-Hb1uQnk5.d.ts → tracker-data-esm3WG8R.d.ts} +34 -8
  70. package/dist/{transport-DkhX2Cbs.d.ts → transport-Czht_irp.d.ts} +41259 -39835
  71. package/dist/{wallet-DTO7SXj7.d.ts → wallet-B7e06v4m.d.ts} +14 -4
  72. package/package.json +1 -1
  73. package/dist/chunk-UPQPUJOU.js +0 -457
  74. package/dist/runtime/chunks/Y4OAVXFR.js +0 -1
@@ -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
+ };