@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.
- package/CHANGELOG.md +276 -8
- package/README.md +3 -2
- package/dist/{schema-CZ6Rj0ZF.d.ts → accounts-nz3mzfRQ.d.ts} +3146 -1765
- package/dist/action-9Xl0StBg.d.ts +33 -0
- package/dist/{attempt-captures-DYnJVkfg.d.ts → attempt-captures-DMi8oR9T.d.ts} +1 -1
- package/dist/authoring.d.ts +171 -49
- package/dist/authoring.js +158 -49
- package/dist/{automatic-outcomes-If88LR9f.d.ts → automatic-outcomes-C_LLQU1p.d.ts} +15 -1
- package/dist/avatar.d.ts +1 -1
- package/dist/browser.d.ts +15 -11
- package/dist/browser.js +18 -12
- package/dist/capability-error-CuI_F7yM.d.ts +296 -0
- package/dist/{pages-K7-KjSXw.d.ts → catalog-BaTOKpNw.d.ts} +56 -567
- package/dist/{chunk-XBV2CK2H.js → chunk-3RFP6GT5.js} +15 -3
- package/dist/{chunk-VURRFVNP.js → chunk-4GQW43UU.js} +239 -361
- package/dist/chunk-4NOFSGAL.js +320 -0
- package/dist/{chunk-24I4R732.js → chunk-5XLZ34PV.js} +34 -19
- package/dist/{chunk-L77O64I4.js → chunk-7X67QLPB.js} +43 -43
- package/dist/{chunk-RHBS5FJL.js → chunk-7Z4SZ6YM.js} +3 -3
- package/dist/{chunk-QEAS4ZGS.js → chunk-AQOL3SK5.js} +1 -1
- package/dist/chunk-EHUSD3O2.js +377 -0
- package/dist/chunk-FO2LCZTL.js +19 -0
- package/dist/{chunk-DYXDZFKA.js → chunk-FU5CGNTR.js} +166 -178
- package/dist/chunk-FWLQ5XCS.js +21 -0
- package/dist/chunk-GLH6MEI2.js +193 -0
- package/dist/chunk-ICXZZNPS.js +199 -0
- package/dist/{chunk-ZDJLPN4L.js → chunk-ID3BZXFZ.js} +2696 -2693
- package/dist/chunk-KP2MCX3R.js +587 -0
- package/dist/{chunk-SKGTNTLF.js → chunk-LZWXCBUB.js} +213 -297
- package/dist/chunk-MTKRIQEU.js +31 -0
- package/dist/{chunk-4OC7REYX.js → chunk-MWMCQLCG.js} +3 -3
- package/dist/{chunk-PPB7HALD.js → chunk-N4BDKS6Y.js} +27 -26
- package/dist/{chunk-5I54XBK2.js → chunk-N4LNEGQX.js} +2 -2
- package/dist/chunk-NQDEWJWE.js +554 -0
- package/dist/chunk-QR6HH4DI.js +508 -0
- package/dist/chunk-TLSQETTY.js +41 -0
- package/dist/{chunk-MHPKEVEW.js → chunk-U66GUVSG.js} +7 -2
- package/dist/{chunk-KDR2VAJP.js → chunk-UYVJZR33.js} +2 -2
- package/dist/chunk-UZ765UGH.js +18 -0
- package/dist/{chunk-7A4J67ZL.js → chunk-VWQGWGCH.js} +7 -7
- package/dist/chunk-W7YSMSGC.js +725 -0
- package/dist/{client-C51w7fMb.d.ts → client-DHmG7rn6.d.ts} +126 -93
- package/dist/{announcements-CHx3-HBw.d.ts → dashboards-CLemT6kj.d.ts} +14 -137
- package/dist/{deployments-kWoHFaqj.d.ts → deployments-DTULi7dF.d.ts} +450 -18
- package/dist/identity-integration-DOeNZaxF.d.ts +1271 -0
- package/dist/index.d.ts +13 -11
- package/dist/index.js +16 -11
- package/dist/internal.d.ts +29 -13
- package/dist/internal.js +57 -17
- package/dist/{integrations-B3y36OaB.d.ts → limits-kNzYdZ00.d.ts} +464 -53
- package/dist/{offers-BoV4ryUc.d.ts → offers-CYeN_I0Y.d.ts} +22 -4
- package/dist/{participant-activity-DHL8QYks.d.ts → participant-activity-D-Drp24G.d.ts} +16 -3
- package/dist/portal-proxy.d.ts +75 -2
- package/dist/portal-proxy.js +153 -25
- package/dist/react/index.d.ts +214 -27
- package/dist/react/index.js +196 -42
- package/dist/{action-DBzILFx9.d.ts → request-error-D_dUPLwo.d.ts} +1 -31
- package/dist/reward-deliveries-drp-x1G-.d.ts +782 -0
- package/dist/runtime/authoring.js +1 -1
- package/dist/runtime/chunks/UGDV5W4N.js +1 -0
- package/dist/runtime/manifest.json +3 -3
- package/dist/runtime/schema.js +1 -1
- package/dist/schema.d.ts +330 -31
- package/dist/schema.js +147 -91
- package/dist/server/index.d.ts +14 -12
- package/dist/server/index.js +6425 -6260
- package/dist/sign-in-providers-B1Q9eDRm.d.ts +44 -0
- package/dist/submission-input-DZCbjQUH.d.ts +343 -0
- package/dist/{telegram-browser-BUceZIGZ.d.ts → telegram-browser-NL0Asmsi.d.ts} +46 -6
- package/dist/telegram.d.ts +64 -0
- package/dist/telegram.js +23 -0
- package/dist/testing.d.ts +326 -27
- package/dist/testing.js +440 -90
- package/dist/tracker-data-esm3WG8R.d.ts +1881 -0
- package/dist/{transport-BrX9pIGN.d.ts → transport-Czht_irp.d.ts} +43483 -38512
- package/dist/{wallet-CIqFoxdm.d.ts → wallet-B7e06v4m.d.ts} +32 -9
- package/package.json +5 -1
- package/dist/accounts-DoabriBX.d.ts +0 -306
- package/dist/capability-error-DufwG3G0.d.ts +0 -159
- package/dist/chunk-3Y3L2F54.js +0 -982
- package/dist/chunk-DHXDBAJF.js +0 -544
- package/dist/chunk-EN3M5Z4J.js +0 -13
- package/dist/chunk-QNUHWK7R.js +0 -602
- package/dist/chunk-SE4PFJPT.js +0 -247
- package/dist/groups-CqcA2Ycs.d.ts +0 -2827
- package/dist/runtime/chunks/5QVFB4TU.js +0 -1
- package/dist/submission-input-C54Q8yAD.d.ts +0 -146
- package/dist/x-D1PGi8Sq.d.ts +0 -331
package/dist/chunk-DHXDBAJF.js
DELETED
|
@@ -1,544 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
MANAGEMENT_TIMEOUT,
|
|
3
|
-
lifetime,
|
|
4
|
-
retryAfter,
|
|
5
|
-
retrying,
|
|
6
|
-
validTimeout
|
|
7
|
-
} from "./chunk-XBV2CK2H.js";
|
|
8
|
-
import {
|
|
9
|
-
clientIdentity
|
|
10
|
-
} from "./chunk-EN3M5Z4J.js";
|
|
11
|
-
import {
|
|
12
|
-
authScopeSchema
|
|
13
|
-
} from "./chunk-PPB7HALD.js";
|
|
14
|
-
import {
|
|
15
|
-
RequestError,
|
|
16
|
-
appIdentityKindSchema,
|
|
17
|
-
isRequestError,
|
|
18
|
-
knownResponse,
|
|
19
|
-
openIdentityKindSchema
|
|
20
|
-
} from "./chunk-ZDJLPN4L.js";
|
|
21
|
-
|
|
22
|
-
// src/configuration.ts
|
|
23
|
-
function questConfiguration(release) {
|
|
24
|
-
return release.configuration ?? {
|
|
25
|
-
defaults: Object.fromEntries(
|
|
26
|
-
Object.entries(release.fields).map(([key, field]) => [
|
|
27
|
-
key,
|
|
28
|
-
field.default
|
|
29
|
-
])
|
|
30
|
-
),
|
|
31
|
-
overrides: { ...release.values },
|
|
32
|
-
preserved: Object.keys(release.values)
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// src/credential-secrets.ts
|
|
37
|
-
import * as z from "zod";
|
|
38
|
-
var credentialSecretSchema = z.object({
|
|
39
|
-
id: z.string().uuid(),
|
|
40
|
-
/** The secret's last four characters, to tell secrets apart; null for one issued before hints. */
|
|
41
|
-
hint: z.string().nullable(),
|
|
42
|
-
createdAt: z.number(),
|
|
43
|
-
/** When the secret stops working; null when it never expires. */
|
|
44
|
-
expiresAt: z.number().nullable(),
|
|
45
|
-
/** When the secret last authenticated a request; null when it never has. */
|
|
46
|
-
lastUsedAt: z.number().nullable()
|
|
47
|
-
});
|
|
48
|
-
var credentialSecretInputSchema = z.object({
|
|
49
|
-
expiresInDays: z.number().int().min(1).max(3650).optional()
|
|
50
|
-
}).strict();
|
|
51
|
-
|
|
52
|
-
// src/identity-integration.ts
|
|
53
|
-
import * as z2 from "zod";
|
|
54
|
-
var identityIntegrationInputSchema = z2.object({
|
|
55
|
-
name: z2.string().trim().min(1).max(80),
|
|
56
|
-
origin: z2.string().url().refine((value) => {
|
|
57
|
-
const url = new URL(value);
|
|
58
|
-
return url.protocol === "https:" && url.origin === value;
|
|
59
|
-
}, "Use an exact HTTPS application origin"),
|
|
60
|
-
/**
|
|
61
|
-
* The identity kind this integration owns in the project and environment, such as
|
|
62
|
-
* `app:telegram`. Each member it signs in gets the exchanged subject as an identity of this
|
|
63
|
-
* kind, which tracker attribution and `ctx.member.identities()` read. Its kind cannot change.
|
|
64
|
-
* Omit it for an integration that only signs members in.
|
|
65
|
-
*
|
|
66
|
-
* A kind belongs to the integration that first claimed it, also after that integration is
|
|
67
|
-
* disconnected. A new integration takes a kind that already has identities only by adopting
|
|
68
|
-
* them with `adoptIdentitiesFrom`.
|
|
69
|
-
*/
|
|
70
|
-
identityKind: appIdentityKindSchema.optional(),
|
|
71
|
-
/**
|
|
72
|
-
* Adopt the identities of a disconnected integration's `identityKind`: its ID, as
|
|
73
|
-
* `identityIntegrations.kinds()` lists it. Adopt only when this app's user IDs mean the same
|
|
74
|
-
* users as that integration's, because each one then signs in as the member that ID is linked
|
|
75
|
-
* to. Needs `reason`, which the audit log keeps.
|
|
76
|
-
*/
|
|
77
|
-
adoptIdentitiesFrom: z2.string().uuid().optional(),
|
|
78
|
-
/** Why the identities are adopted; required with `adoptIdentitiesFrom`. */
|
|
79
|
-
reason: z2.string().trim().min(1).max(500).optional(),
|
|
80
|
-
/** Days until the first secret expires. Omit it for a key that never expires. */
|
|
81
|
-
expiresInDays: z2.number().int().min(1).max(3650).optional()
|
|
82
|
-
}).strict().refine(
|
|
83
|
-
(input) => !input.adoptIdentitiesFrom || input.identityKind,
|
|
84
|
-
"Adopting identities needs the identityKind they have"
|
|
85
|
-
).refine(
|
|
86
|
-
(input) => !input.adoptIdentitiesFrom === !input.reason,
|
|
87
|
-
"Give a reason when adopting identities, and only then"
|
|
88
|
-
);
|
|
89
|
-
var identityIntegrationSchema = z2.object({
|
|
90
|
-
...authScopeSchema.shape,
|
|
91
|
-
id: z2.string().uuid(),
|
|
92
|
-
name: z2.string(),
|
|
93
|
-
origin: z2.string(),
|
|
94
|
-
/**
|
|
95
|
-
* When the integration's last working secret expires: 8640000000000000 (the latest date
|
|
96
|
-
* JavaScript represents) when one never does.
|
|
97
|
-
*
|
|
98
|
-
* @deprecated Read `secrets`, which gives each secret's own expiry.
|
|
99
|
-
*/
|
|
100
|
-
expiresAt: z2.number(),
|
|
101
|
-
/** The integration's working secrets, oldest first. Any of them authenticates it. */
|
|
102
|
-
secrets: z2.array(credentialSecretSchema).default([]),
|
|
103
|
-
/** The latest use of any of its secrets, revoked ones included; null when none was used. */
|
|
104
|
-
lastUsedAt: z2.number().nullable().default(null),
|
|
105
|
-
/** The identity kind the integration owns; null when it only signs members in. */
|
|
106
|
-
identityKind: openIdentityKindSchema.nullable().default(null)
|
|
107
|
-
});
|
|
108
|
-
var identityIntegrationSecretSchema = identityIntegrationSchema.extend(
|
|
109
|
-
{
|
|
110
|
-
token: z2.string()
|
|
111
|
-
}
|
|
112
|
-
);
|
|
113
|
-
var identityKindClaimSchema = z2.object({
|
|
114
|
-
kind: openIdentityKindSchema,
|
|
115
|
-
/** The owning integration's ID; it stays after the integration is disconnected. */
|
|
116
|
-
integration: z2.string(),
|
|
117
|
-
/** The owning integration's name when it claimed or adopted the kind. */
|
|
118
|
-
integrationName: z2.string(),
|
|
119
|
-
/** Whether the owning integration is still connected. */
|
|
120
|
-
connected: z2.boolean(),
|
|
121
|
-
/** Linked identities of the kind; adopting them is required to reuse the kind. */
|
|
122
|
-
linked: z2.number().int().nonnegative(),
|
|
123
|
-
/** Identities an operator unlinked. */
|
|
124
|
-
unlinked: z2.number().int().nonnegative(),
|
|
125
|
-
claimedAt: z2.number().int().nonnegative()
|
|
126
|
-
});
|
|
127
|
-
var participantExchangeSchema = z2.object({
|
|
128
|
-
subject: z2.string().min(1).max(200),
|
|
129
|
-
previousToken: z2.string().max(200).optional()
|
|
130
|
-
}).strict();
|
|
131
|
-
|
|
132
|
-
// src/server/errors.ts
|
|
133
|
-
import * as z3 from "zod";
|
|
134
|
-
var ManagementErrorCode = {
|
|
135
|
-
/** The input or an option failed validation before anything was sent (kind `client`). */
|
|
136
|
-
InvalidInput: "invalid-input",
|
|
137
|
-
/** The client's `getToken` failed before anything was sent (kind `client` or `network`). */
|
|
138
|
-
Credential: "credential",
|
|
139
|
-
Network: "network",
|
|
140
|
-
Timeout: "timeout",
|
|
141
|
-
Aborted: "aborted",
|
|
142
|
-
InvalidResponse: "invalid-response"
|
|
143
|
-
};
|
|
144
|
-
var managementErrorSchema = z3.looseObject({
|
|
145
|
-
error: z3.string(),
|
|
146
|
-
code: z3.string().optional()
|
|
147
|
-
});
|
|
148
|
-
var uncertainStatuses = /* @__PURE__ */ new Set([500, 502, 504]);
|
|
149
|
-
function uncertainOutcome(init) {
|
|
150
|
-
if (init.method === void 0 || init.method === "GET") {
|
|
151
|
-
return false;
|
|
152
|
-
}
|
|
153
|
-
switch (init.kind) {
|
|
154
|
-
case "network":
|
|
155
|
-
case "timeout":
|
|
156
|
-
case "aborted":
|
|
157
|
-
return true;
|
|
158
|
-
case "http":
|
|
159
|
-
return uncertainStatuses.has(init.status ?? 0);
|
|
160
|
-
case "invalid-response":
|
|
161
|
-
return (init.status ?? 0) >= 200 && (init.status ?? 0) < 300;
|
|
162
|
-
default:
|
|
163
|
-
return false;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
var managementErrorBrand = /* @__PURE__ */ Symbol.for("@domino-sdk/relay.ManagementError");
|
|
167
|
-
function isManagementError(value) {
|
|
168
|
-
return isRequestError(value) && value[managementErrorBrand] === true;
|
|
169
|
-
}
|
|
170
|
-
var ManagementError = class extends RequestError {
|
|
171
|
-
name = "ManagementError";
|
|
172
|
-
[managementErrorBrand] = true;
|
|
173
|
-
/** The rest of the server's error body besides `error` and `code`, such as `moved`; absent when there is none. */
|
|
174
|
-
details;
|
|
175
|
-
/** The request's method; absent when the call failed before forming a request. */
|
|
176
|
-
method;
|
|
177
|
-
/** The management API path, below `/management/v1`, without its query; absent like `method`. */
|
|
178
|
-
path;
|
|
179
|
-
constructor(init) {
|
|
180
|
-
super(init.message, {
|
|
181
|
-
kind: init.kind,
|
|
182
|
-
uncertain: init.uncertain ?? uncertainOutcome(init),
|
|
183
|
-
status: init.status,
|
|
184
|
-
code: init.code,
|
|
185
|
-
operationId: init.actionId,
|
|
186
|
-
replaySafe: init.replaySafe,
|
|
187
|
-
retryAfter: init.retryAfter,
|
|
188
|
-
cause: init.cause
|
|
189
|
-
});
|
|
190
|
-
this.details = init.details && Object.keys(init.details).length ? init.details : void 0;
|
|
191
|
-
this.method = init.method;
|
|
192
|
-
this.path = init.path;
|
|
193
|
-
}
|
|
194
|
-
};
|
|
195
|
-
var DEFAULT_MANAGEMENT_TIMEOUT = MANAGEMENT_TIMEOUT;
|
|
196
|
-
|
|
197
|
-
// src/server/transport.ts
|
|
198
|
-
import * as z4 from "zod";
|
|
199
|
-
function failureCause(error) {
|
|
200
|
-
if (typeof error !== "object" || error === null || !("cause" in error)) {
|
|
201
|
-
return {};
|
|
202
|
-
}
|
|
203
|
-
const { cause } = error;
|
|
204
|
-
return typeof cause === "object" && cause !== null ? cause : {};
|
|
205
|
-
}
|
|
206
|
-
function actionIdOf(input) {
|
|
207
|
-
return typeof input === "object" && input !== null && "actionId" in input && typeof input.actionId === "string" ? input.actionId : void 0;
|
|
208
|
-
}
|
|
209
|
-
function unsent(error) {
|
|
210
|
-
const code = String(failureCause(error).code ?? "");
|
|
211
|
-
return /^(ECONNREFUSED|ENOTFOUND|EAI_AGAIN|ENETUNREACH|EHOSTUNREACH|UND_ERR_CONNECT_TIMEOUT)$|CERT|TLS|SSL/.test(
|
|
212
|
-
code
|
|
213
|
-
);
|
|
214
|
-
}
|
|
215
|
-
function redirected(error) {
|
|
216
|
-
return /redirect/i.test(String(failureCause(error).message ?? ""));
|
|
217
|
-
}
|
|
218
|
-
function checkedTimeout(timeout) {
|
|
219
|
-
if (timeout !== void 0 && !validTimeout(timeout)) {
|
|
220
|
-
throw new ManagementError({
|
|
221
|
-
kind: "client",
|
|
222
|
-
code: ManagementErrorCode.InvalidInput,
|
|
223
|
-
message: "Management timeout must be a positive, finite number of milliseconds"
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
return timeout;
|
|
227
|
-
}
|
|
228
|
-
function managementTransport(options) {
|
|
229
|
-
const clientTimeout = checkedTimeout(options.timeout) ?? DEFAULT_MANAGEMENT_TIMEOUT;
|
|
230
|
-
try {
|
|
231
|
-
const headers = new Headers(options.headers);
|
|
232
|
-
headers.set("X-Relay-Organization", options.organization ?? "");
|
|
233
|
-
headers.set("X-Relay-Project", options.project ?? "");
|
|
234
|
-
} catch (error) {
|
|
235
|
-
throw new ManagementError({
|
|
236
|
-
kind: "client",
|
|
237
|
-
code: ManagementErrorCode.InvalidInput,
|
|
238
|
-
message: "Management headers, organization and project must be valid HTTP header values",
|
|
239
|
-
cause: error
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
function callLifetime(call) {
|
|
243
|
-
return lifetime(
|
|
244
|
-
checkedTimeout(call?.timeout) ?? clientTimeout,
|
|
245
|
-
call?.signal ?? void 0
|
|
246
|
-
);
|
|
247
|
-
}
|
|
248
|
-
function transportFailure(error, context, life, sent, status, refused = false, headers) {
|
|
249
|
-
if (error instanceof ManagementError) {
|
|
250
|
-
return error;
|
|
251
|
-
}
|
|
252
|
-
const unsent2 = {
|
|
253
|
-
retryAfter: headers ? retryAfter(headers) : void 0,
|
|
254
|
-
// A redirect fetch refused to follow was answered without being applied.
|
|
255
|
-
...!sent || redirected(error) ? { uncertain: false } : refused ? {
|
|
256
|
-
uncertain: context.method !== "GET" && [500, 502, 504].includes(status ?? 0)
|
|
257
|
-
} : {},
|
|
258
|
-
...status === void 0 ? {} : { status }
|
|
259
|
-
};
|
|
260
|
-
const ended = life.ended();
|
|
261
|
-
if (ended === "aborted") {
|
|
262
|
-
return new ManagementError({
|
|
263
|
-
...context,
|
|
264
|
-
...unsent2,
|
|
265
|
-
kind: "aborted",
|
|
266
|
-
code: ManagementErrorCode.Aborted,
|
|
267
|
-
message: "The management request was cancelled",
|
|
268
|
-
cause: life.reason()
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
if (ended === "timeout") {
|
|
272
|
-
return new ManagementError({
|
|
273
|
-
...context,
|
|
274
|
-
...unsent2,
|
|
275
|
-
kind: "timeout",
|
|
276
|
-
code: ManagementErrorCode.Timeout,
|
|
277
|
-
message: `The management request did not finish within ${life.timeout} ms`,
|
|
278
|
-
cause: error
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
return new ManagementError({
|
|
282
|
-
...context,
|
|
283
|
-
...unsent2,
|
|
284
|
-
kind: "network",
|
|
285
|
-
code: ManagementErrorCode.Network,
|
|
286
|
-
message: "The management request failed before Domino answered",
|
|
287
|
-
cause: error
|
|
288
|
-
});
|
|
289
|
-
}
|
|
290
|
-
async function credential(context, life) {
|
|
291
|
-
if (!options.getToken) {
|
|
292
|
-
return null;
|
|
293
|
-
}
|
|
294
|
-
const getToken = options.getToken;
|
|
295
|
-
try {
|
|
296
|
-
return await new Promise((resolve, reject) => {
|
|
297
|
-
const stop = () => reject(life.signal.reason);
|
|
298
|
-
life.signal.addEventListener("abort", stop, { once: true });
|
|
299
|
-
getToken().then(resolve, reject).finally(() => life.signal.removeEventListener("abort", stop));
|
|
300
|
-
});
|
|
301
|
-
} catch (error) {
|
|
302
|
-
if (life.signal.aborted) {
|
|
303
|
-
throw transportFailure(error, context, life, false);
|
|
304
|
-
}
|
|
305
|
-
throw new ManagementError({
|
|
306
|
-
...context,
|
|
307
|
-
// A token source that could not reach its own service failed like a network call.
|
|
308
|
-
kind: error instanceof TypeError ? "network" : "client",
|
|
309
|
-
code: ManagementErrorCode.Credential,
|
|
310
|
-
uncertain: false,
|
|
311
|
-
message: "Could not get a management credential",
|
|
312
|
-
cause: error
|
|
313
|
-
});
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
async function send(path, fetchInit, context, life) {
|
|
317
|
-
if (life.signal.aborted) {
|
|
318
|
-
throw transportFailure(life.reason(), context, life, false);
|
|
319
|
-
}
|
|
320
|
-
const headers = new Headers(options.headers);
|
|
321
|
-
new Headers(fetchInit.headers).forEach(
|
|
322
|
-
(value, name) => headers.set(name, value)
|
|
323
|
-
);
|
|
324
|
-
headers.set("X-Domino-Client", options.client ?? clientIdentity());
|
|
325
|
-
const token = await credential(context, life);
|
|
326
|
-
if (token) {
|
|
327
|
-
try {
|
|
328
|
-
headers.set("Authorization", `Bearer ${token}`);
|
|
329
|
-
} catch (error) {
|
|
330
|
-
throw new ManagementError({
|
|
331
|
-
...context,
|
|
332
|
-
kind: "client",
|
|
333
|
-
code: ManagementErrorCode.Credential,
|
|
334
|
-
uncertain: false,
|
|
335
|
-
message: "getToken returned a value that is not a token",
|
|
336
|
-
cause: error
|
|
337
|
-
});
|
|
338
|
-
}
|
|
339
|
-
} else if (options.getToken) {
|
|
340
|
-
headers.delete("Authorization");
|
|
341
|
-
}
|
|
342
|
-
if (options.organization) {
|
|
343
|
-
headers.set("X-Relay-Organization", options.organization);
|
|
344
|
-
}
|
|
345
|
-
if (options.project) {
|
|
346
|
-
headers.set("X-Relay-Project", options.project);
|
|
347
|
-
}
|
|
348
|
-
if (options.environment) {
|
|
349
|
-
headers.set("X-Relay-Environment", options.environment);
|
|
350
|
-
}
|
|
351
|
-
let response;
|
|
352
|
-
try {
|
|
353
|
-
response = await (options.fetch ?? fetch)(
|
|
354
|
-
`${options.baseUrl}/management/v1${path}`,
|
|
355
|
-
{
|
|
356
|
-
...fetchInit,
|
|
357
|
-
headers,
|
|
358
|
-
signal: life.signal,
|
|
359
|
-
...options.redirect ? { redirect: options.redirect } : {}
|
|
360
|
-
}
|
|
361
|
-
);
|
|
362
|
-
} catch (error) {
|
|
363
|
-
throw transportFailure(error, context, life, !unsent(error));
|
|
364
|
-
}
|
|
365
|
-
if (!response.ok) {
|
|
366
|
-
let text;
|
|
367
|
-
try {
|
|
368
|
-
text = await response.text();
|
|
369
|
-
} catch (error2) {
|
|
370
|
-
throw transportFailure(
|
|
371
|
-
error2,
|
|
372
|
-
context,
|
|
373
|
-
life,
|
|
374
|
-
true,
|
|
375
|
-
response.status,
|
|
376
|
-
true,
|
|
377
|
-
response.headers
|
|
378
|
-
);
|
|
379
|
-
}
|
|
380
|
-
let body = null;
|
|
381
|
-
try {
|
|
382
|
-
body = JSON.parse(text);
|
|
383
|
-
} catch {
|
|
384
|
-
}
|
|
385
|
-
const parsed = managementErrorSchema.safeParse(body);
|
|
386
|
-
const { error, code, ...details } = parsed.success ? parsed.data : { error: `Request failed (${response.status})`, code: void 0 };
|
|
387
|
-
throw new ManagementError({
|
|
388
|
-
...context,
|
|
389
|
-
kind: "http",
|
|
390
|
-
status: response.status,
|
|
391
|
-
message: error,
|
|
392
|
-
...code === void 0 ? {} : { code },
|
|
393
|
-
details,
|
|
394
|
-
retryAfter: retryAfter(response.headers)
|
|
395
|
-
});
|
|
396
|
-
}
|
|
397
|
-
return response;
|
|
398
|
-
}
|
|
399
|
-
async function raw(path, init) {
|
|
400
|
-
const { timeout, signal, ...fetchInit } = init ?? {};
|
|
401
|
-
const life = callLifetime({ timeout, signal: signal ?? void 0 });
|
|
402
|
-
try {
|
|
403
|
-
return await send(
|
|
404
|
-
path,
|
|
405
|
-
fetchInit,
|
|
406
|
-
{
|
|
407
|
-
method: (fetchInit.method ?? "GET").toUpperCase(),
|
|
408
|
-
path: path.split("?")[0],
|
|
409
|
-
replaySafe: false
|
|
410
|
-
},
|
|
411
|
-
life
|
|
412
|
-
);
|
|
413
|
-
} finally {
|
|
414
|
-
life.end();
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
async function exchange(path, schema, input, method, call, replaySafe, tolerant = false) {
|
|
418
|
-
const actionId = actionIdOf(input);
|
|
419
|
-
const context = {
|
|
420
|
-
method,
|
|
421
|
-
replaySafe,
|
|
422
|
-
path: path.split("?")[0],
|
|
423
|
-
...actionId ? { actionId } : {}
|
|
424
|
-
};
|
|
425
|
-
const fetchInit = {
|
|
426
|
-
method,
|
|
427
|
-
headers: tolerant ? { "X-Domino-Response": "tolerant-v1" } : void 0,
|
|
428
|
-
...input === void 0 ? {} : {
|
|
429
|
-
headers: {
|
|
430
|
-
"Content-Type": "application/json",
|
|
431
|
-
...tolerant ? { "X-Domino-Response": "tolerant-v1" } : {}
|
|
432
|
-
},
|
|
433
|
-
body: JSON.stringify(input)
|
|
434
|
-
}
|
|
435
|
-
};
|
|
436
|
-
const life = callLifetime(call);
|
|
437
|
-
try {
|
|
438
|
-
return await retrying(
|
|
439
|
-
life,
|
|
440
|
-
{ replaySafe: method === "GET" || replaySafe },
|
|
441
|
-
async () => {
|
|
442
|
-
const response = await send(path, fetchInit, context, life);
|
|
443
|
-
let body;
|
|
444
|
-
try {
|
|
445
|
-
body = response.status === 204 ? null : await response.json();
|
|
446
|
-
} catch (error) {
|
|
447
|
-
if (error instanceof SyntaxError && !life.signal.aborted) {
|
|
448
|
-
throw new ManagementError({
|
|
449
|
-
...context,
|
|
450
|
-
kind: "invalid-response",
|
|
451
|
-
code: ManagementErrorCode.InvalidResponse,
|
|
452
|
-
status: response.status,
|
|
453
|
-
message: "Domino answered with a body that is not JSON",
|
|
454
|
-
cause: error
|
|
455
|
-
});
|
|
456
|
-
}
|
|
457
|
-
throw transportFailure(
|
|
458
|
-
error,
|
|
459
|
-
context,
|
|
460
|
-
life,
|
|
461
|
-
true,
|
|
462
|
-
response.status,
|
|
463
|
-
false,
|
|
464
|
-
response.headers
|
|
465
|
-
);
|
|
466
|
-
}
|
|
467
|
-
const parsed = knownResponse(schema).safeParse(
|
|
468
|
-
tolerant ? { status: response.status, operationId: actionId, result: body } : body
|
|
469
|
-
);
|
|
470
|
-
if (!parsed.success) {
|
|
471
|
-
throw new ManagementError({
|
|
472
|
-
...context,
|
|
473
|
-
kind: "invalid-response",
|
|
474
|
-
code: ManagementErrorCode.InvalidResponse,
|
|
475
|
-
status: response.status,
|
|
476
|
-
message: "Domino answered with a response this client does not recognize",
|
|
477
|
-
cause: parsed.error
|
|
478
|
-
});
|
|
479
|
-
}
|
|
480
|
-
return parsed.data;
|
|
481
|
-
}
|
|
482
|
-
);
|
|
483
|
-
} finally {
|
|
484
|
-
life.end();
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
const json = ({
|
|
488
|
-
path,
|
|
489
|
-
method,
|
|
490
|
-
body,
|
|
491
|
-
replaySafe
|
|
492
|
-
}) => exchange(
|
|
493
|
-
path,
|
|
494
|
-
z4.unknown(),
|
|
495
|
-
body,
|
|
496
|
-
method,
|
|
497
|
-
void 0,
|
|
498
|
-
method === "GET" || replaySafe
|
|
499
|
-
);
|
|
500
|
-
return { raw, exchange, json };
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
// src/sequence-cursor.ts
|
|
504
|
-
import * as z5 from "zod";
|
|
505
|
-
var sequenceCursorSchema = z5.string().regex(/^[1-9][0-9]{0,15}$/, "Invalid cursor").transform(Number).pipe(z5.number().int().positive().safe());
|
|
506
|
-
|
|
507
|
-
// src/referral-reward-kinds.ts
|
|
508
|
-
var REFERRAL_INTEGRATION_REWARD_ERROR = "Referral programs can grant points and tiered rewards; Discord roles need a quest";
|
|
509
|
-
var isRecord = (value) => typeof value === "object" && value !== null;
|
|
510
|
-
function containsReferralIntegrationReward(value) {
|
|
511
|
-
if (Array.isArray(value)) {
|
|
512
|
-
return value.some(
|
|
513
|
-
(reward) => isRecord(reward) && reward.kind === "integration"
|
|
514
|
-
);
|
|
515
|
-
}
|
|
516
|
-
if (!isRecord(value)) {
|
|
517
|
-
return false;
|
|
518
|
-
}
|
|
519
|
-
const definition = isRecord(value.definition) ? value.definition : value;
|
|
520
|
-
return isRecord(definition.rewards) && (containsReferralIntegrationReward(definition.rewards.inviter) || containsReferralIntegrationReward(definition.rewards.invitee)) || Array.isArray(definition.milestones) && definition.milestones.some(
|
|
521
|
-
(milestone) => isRecord(milestone) && containsReferralIntegrationReward(milestone.rewards)
|
|
522
|
-
);
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
export {
|
|
526
|
-
questConfiguration,
|
|
527
|
-
credentialSecretSchema,
|
|
528
|
-
credentialSecretInputSchema,
|
|
529
|
-
identityIntegrationInputSchema,
|
|
530
|
-
identityIntegrationSchema,
|
|
531
|
-
identityIntegrationSecretSchema,
|
|
532
|
-
identityKindClaimSchema,
|
|
533
|
-
participantExchangeSchema,
|
|
534
|
-
ManagementErrorCode,
|
|
535
|
-
managementErrorSchema,
|
|
536
|
-
isManagementError,
|
|
537
|
-
ManagementError,
|
|
538
|
-
DEFAULT_MANAGEMENT_TIMEOUT,
|
|
539
|
-
actionIdOf,
|
|
540
|
-
managementTransport,
|
|
541
|
-
sequenceCursorSchema,
|
|
542
|
-
REFERRAL_INTEGRATION_REWARD_ERROR,
|
|
543
|
-
containsReferralIntegrationReward
|
|
544
|
-
};
|
package/dist/chunk-EN3M5Z4J.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
// package.json
|
|
2
|
-
var name = "@domino-sdk/relay";
|
|
3
|
-
var version = "1.61.0";
|
|
4
|
-
|
|
5
|
-
// src/client-identity.ts
|
|
6
|
-
function clientIdentity() {
|
|
7
|
-
const runtime = typeof document === "undefined" ? "server" : "browser";
|
|
8
|
-
return `${name}/${version} (${runtime})`;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export {
|
|
12
|
-
clientIdentity
|
|
13
|
-
};
|