@domino-sdk/relay 1.11.1 → 1.14.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/README.md +1 -0
- package/build.mjs +15 -0
- package/dist/accounts-5ciAkCMP.d.ts +147 -0
- package/dist/{activity-CNiPDPK6.d.ts → activity-D_R3J-gU.d.ts} +115 -115
- package/dist/attempt-captures-DZldPZJc.d.ts +285 -0
- package/dist/authoring.d.ts +49 -47
- package/dist/authoring.js +6 -4
- package/dist/{automatic-outcomes-kPIDv6X_.d.ts → automatic-outcomes-6lJGnSDe.d.ts} +1 -1
- package/dist/browser.d.ts +8 -7
- package/dist/browser.js +7 -6
- package/dist/capability-error-oTd3eYFH.d.ts +151 -0
- package/dist/chunk-2UAVZCMH.js +314 -0
- package/dist/chunk-5TS3OAWS.js +470 -0
- package/dist/{chunk-PUDL4JBY.js → chunk-6DD7DVNQ.js} +2 -2
- package/dist/{chunk-AGFUDCNM.js → chunk-C3CB4WIQ.js} +1 -1
- package/dist/{chunk-T657WO56.js → chunk-LLMJ2SUT.js} +6 -2
- package/dist/chunk-NIYCAW2I.js +79 -0
- package/dist/chunk-UJACD6K2.js +987 -0
- package/dist/{chunk-XK5E4HAS.js → chunk-VBHFJH3P.js} +80 -28
- package/dist/chunk-W335CWYJ.js +53 -0
- package/dist/{chunk-X7ECZ3AK.js → chunk-XMBM2XD5.js} +1 -1
- package/dist/{chunk-2K2QBPAD.js → chunk-ZLYBUM7K.js} +6 -4
- package/dist/{client-fUSERMAC.d.ts → client-BTd_CyX3.d.ts} +26 -6
- package/dist/{groups-BK8ts2yK.d.ts → groups-4Jb3uYFO.d.ts} +1 -1
- package/dist/{images-aw6W7vFZ.d.ts → images-D5kpqHxv.d.ts} +1 -1
- package/dist/index.d.ts +9 -8
- package/dist/index.js +8 -6
- package/dist/{capability-error-ty3SqD_b.d.ts → integrations-Cr9EhGI_.d.ts} +1 -149
- package/dist/internal.d.ts +32 -5
- package/dist/internal.js +8 -3
- package/dist/{offers-C2FANzrG.d.ts → offers-BFI5t-e-.d.ts} +2 -2
- package/dist/{pages-Chb6OZSB.d.ts → pages-nIoMT9J3.d.ts} +1 -1
- package/dist/{participant-activity-DkL3nY5a.d.ts → participant-activity-DYdUUhw2.d.ts} +1 -0
- package/dist/portal-proxy.js +1 -1
- package/dist/react/index.d.ts +246 -177
- package/dist/react/index.js +954 -383
- package/dist/{referral-reward-kinds-M3f0PdiR.d.ts → referral-reward-kinds-DnvQXL8L.d.ts} +100 -3
- package/dist/{schema-DEM8y8Fm.d.ts → schema-K-Pg5lPz.d.ts} +1 -1
- package/dist/schema.d.ts +316 -314
- package/dist/schema.js +16 -14
- package/dist/server/index.d.ts +2546 -377
- package/dist/server/index.js +594 -841
- package/dist/{sign-in-options-iWOp9puZ.d.ts → sign-in-options-DBjMzgnu.d.ts} +2 -2
- package/dist/submission-input-CPIsJt-_.d.ts +146 -0
- package/dist/testing.d.ts +641 -0
- package/dist/testing.js +1282 -0
- package/package.json +6 -2
- package/dist/chunk-OCXGG75K.js +0 -171
- package/dist/chunk-ZFABFKIY.js +0 -1295
- package/dist/submission-input-BbBJTVlT.d.ts +0 -290
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MANAGEMENT_TIMEOUT,
|
|
3
|
+
lifetime,
|
|
4
|
+
retryAfter,
|
|
5
|
+
retrying,
|
|
6
|
+
validTimeout
|
|
7
|
+
} from "./chunk-6QJ3LADK.js";
|
|
8
|
+
import {
|
|
9
|
+
RequestError,
|
|
10
|
+
isRequestError
|
|
11
|
+
} from "./chunk-NPGENI7K.js";
|
|
12
|
+
import {
|
|
13
|
+
clientIdentity
|
|
14
|
+
} from "./chunk-C3CB4WIQ.js";
|
|
15
|
+
import {
|
|
16
|
+
authScopeSchema
|
|
17
|
+
} from "./chunk-PT5STHFH.js";
|
|
18
|
+
import {
|
|
19
|
+
appIdentityKindSchema,
|
|
20
|
+
knownResponse,
|
|
21
|
+
openIdentityKindSchema
|
|
22
|
+
} from "./chunk-46C33ASD.js";
|
|
23
|
+
|
|
24
|
+
// src/configuration.ts
|
|
25
|
+
function questConfiguration(release) {
|
|
26
|
+
return release.configuration ?? {
|
|
27
|
+
defaults: Object.fromEntries(
|
|
28
|
+
Object.entries(release.fields).map(([key, field]) => [
|
|
29
|
+
key,
|
|
30
|
+
field.default
|
|
31
|
+
])
|
|
32
|
+
),
|
|
33
|
+
overrides: { ...release.values },
|
|
34
|
+
preserved: Object.keys(release.values)
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// src/identity-integration.ts
|
|
39
|
+
import { z } from "zod";
|
|
40
|
+
var identityIntegrationInputSchema = z.object({
|
|
41
|
+
name: z.string().trim().min(1).max(80),
|
|
42
|
+
origin: z.string().url().refine((value) => {
|
|
43
|
+
const url = new URL(value);
|
|
44
|
+
return url.protocol === "https:" && url.origin === value;
|
|
45
|
+
}, "Use an exact HTTPS application origin"),
|
|
46
|
+
/**
|
|
47
|
+
* The identity kind this integration owns in the project and environment, such as
|
|
48
|
+
* `app:telegram`. Each member it signs in gets the exchanged subject as an identity of this
|
|
49
|
+
* kind, which tracker attribution and `ctx.member.identities()` read. Its kind cannot change.
|
|
50
|
+
* Omit it for an integration that only signs members in.
|
|
51
|
+
*
|
|
52
|
+
* A kind belongs to the integration that first claimed it, also after that integration is
|
|
53
|
+
* disconnected. A new integration takes a kind that already has identities only by adopting
|
|
54
|
+
* them with `adoptIdentitiesFrom`.
|
|
55
|
+
*/
|
|
56
|
+
identityKind: appIdentityKindSchema.optional(),
|
|
57
|
+
/**
|
|
58
|
+
* Adopt the identities of a disconnected integration's `identityKind`: its ID, as
|
|
59
|
+
* `identityIntegrations.kinds()` lists it. Adopt only when this app's user IDs mean the same
|
|
60
|
+
* users as that integration's, because each one then signs in as the member that ID is linked
|
|
61
|
+
* to. Needs `reason`, which the audit log keeps.
|
|
62
|
+
*/
|
|
63
|
+
adoptIdentitiesFrom: z.string().uuid().optional(),
|
|
64
|
+
/** Why the identities are adopted; required with `adoptIdentitiesFrom`. */
|
|
65
|
+
reason: z.string().trim().min(1).max(500).optional()
|
|
66
|
+
}).strict().refine(
|
|
67
|
+
(input) => !input.adoptIdentitiesFrom || input.identityKind,
|
|
68
|
+
"Adopting identities needs the identityKind they have"
|
|
69
|
+
).refine(
|
|
70
|
+
(input) => !input.adoptIdentitiesFrom === !input.reason,
|
|
71
|
+
"Give a reason when adopting identities, and only then"
|
|
72
|
+
);
|
|
73
|
+
var identityIntegrationSchema = z.object({
|
|
74
|
+
...authScopeSchema.shape,
|
|
75
|
+
id: z.string().uuid(),
|
|
76
|
+
name: z.string(),
|
|
77
|
+
origin: z.string(),
|
|
78
|
+
expiresAt: z.number(),
|
|
79
|
+
/** The identity kind the integration owns; null when it only signs members in. */
|
|
80
|
+
identityKind: openIdentityKindSchema.nullable().default(null)
|
|
81
|
+
});
|
|
82
|
+
var identityIntegrationSecretSchema = identityIntegrationSchema.extend(
|
|
83
|
+
{
|
|
84
|
+
token: z.string()
|
|
85
|
+
}
|
|
86
|
+
);
|
|
87
|
+
var identityKindClaimSchema = z.object({
|
|
88
|
+
kind: openIdentityKindSchema,
|
|
89
|
+
/** The owning integration's ID; it stays after the integration is disconnected. */
|
|
90
|
+
integration: z.string(),
|
|
91
|
+
/** The owning integration's name when it claimed or adopted the kind. */
|
|
92
|
+
integrationName: z.string(),
|
|
93
|
+
/** Whether the owning integration is still connected. */
|
|
94
|
+
connected: z.boolean(),
|
|
95
|
+
/** Linked identities of the kind; adopting them is required to reuse the kind. */
|
|
96
|
+
linked: z.number().int().nonnegative(),
|
|
97
|
+
/** Identities an operator unlinked. */
|
|
98
|
+
unlinked: z.number().int().nonnegative(),
|
|
99
|
+
claimedAt: z.number().int().nonnegative()
|
|
100
|
+
});
|
|
101
|
+
var participantExchangeSchema = z.object({
|
|
102
|
+
subject: z.string().min(1).max(200),
|
|
103
|
+
previousToken: z.string().max(200).optional()
|
|
104
|
+
}).strict();
|
|
105
|
+
|
|
106
|
+
// src/server/errors.ts
|
|
107
|
+
import { z as z2 } from "zod";
|
|
108
|
+
var ManagementErrorCode = {
|
|
109
|
+
/** The input or an option failed validation before anything was sent (kind `client`). */
|
|
110
|
+
InvalidInput: "invalid-input",
|
|
111
|
+
/** The client's `getToken` failed before anything was sent (kind `client` or `network`). */
|
|
112
|
+
Credential: "credential",
|
|
113
|
+
Network: "network",
|
|
114
|
+
Timeout: "timeout",
|
|
115
|
+
Aborted: "aborted",
|
|
116
|
+
InvalidResponse: "invalid-response"
|
|
117
|
+
};
|
|
118
|
+
var managementErrorSchema = z2.looseObject({
|
|
119
|
+
error: z2.string(),
|
|
120
|
+
code: z2.string().optional()
|
|
121
|
+
});
|
|
122
|
+
var uncertainStatuses = /* @__PURE__ */ new Set([500, 502, 504]);
|
|
123
|
+
function uncertainOutcome(init) {
|
|
124
|
+
if (init.method === void 0 || init.method === "GET") {
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
switch (init.kind) {
|
|
128
|
+
case "network":
|
|
129
|
+
case "timeout":
|
|
130
|
+
case "aborted":
|
|
131
|
+
return true;
|
|
132
|
+
case "http":
|
|
133
|
+
return uncertainStatuses.has(init.status ?? 0);
|
|
134
|
+
case "invalid-response":
|
|
135
|
+
return (init.status ?? 0) >= 200 && (init.status ?? 0) < 300;
|
|
136
|
+
default:
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
var managementErrorBrand = /* @__PURE__ */ Symbol.for("@domino-sdk/relay.ManagementError");
|
|
141
|
+
function isManagementError(value) {
|
|
142
|
+
return isRequestError(value) && value[managementErrorBrand] === true;
|
|
143
|
+
}
|
|
144
|
+
var ManagementError = class extends RequestError {
|
|
145
|
+
name = "ManagementError";
|
|
146
|
+
[managementErrorBrand] = true;
|
|
147
|
+
/** The rest of the server's error body besides `error` and `code`, such as `moved`; absent when there is none. */
|
|
148
|
+
details;
|
|
149
|
+
/** The request's method; absent when the call failed before forming a request. */
|
|
150
|
+
method;
|
|
151
|
+
/** The management API path, below `/management/v1`, without its query; absent like `method`. */
|
|
152
|
+
path;
|
|
153
|
+
constructor(init) {
|
|
154
|
+
super(init.message, {
|
|
155
|
+
kind: init.kind,
|
|
156
|
+
uncertain: init.uncertain ?? uncertainOutcome(init),
|
|
157
|
+
status: init.status,
|
|
158
|
+
code: init.code,
|
|
159
|
+
operationId: init.actionId,
|
|
160
|
+
replaySafe: init.replaySafe,
|
|
161
|
+
retryAfter: init.retryAfter,
|
|
162
|
+
cause: init.cause
|
|
163
|
+
});
|
|
164
|
+
this.details = init.details && Object.keys(init.details).length ? init.details : void 0;
|
|
165
|
+
this.method = init.method;
|
|
166
|
+
this.path = init.path;
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
var DEFAULT_MANAGEMENT_TIMEOUT = MANAGEMENT_TIMEOUT;
|
|
170
|
+
|
|
171
|
+
// src/server/transport.ts
|
|
172
|
+
function actionIdOf(input) {
|
|
173
|
+
return typeof input === "object" && input !== null && "actionId" in input && typeof input.actionId === "string" ? input.actionId : void 0;
|
|
174
|
+
}
|
|
175
|
+
function unsent(error) {
|
|
176
|
+
const code = String(
|
|
177
|
+
error?.cause?.code ?? ""
|
|
178
|
+
);
|
|
179
|
+
return /^(ECONNREFUSED|ENOTFOUND|EAI_AGAIN|ENETUNREACH|EHOSTUNREACH|UND_ERR_CONNECT_TIMEOUT)$|CERT|TLS|SSL/.test(
|
|
180
|
+
code
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
function redirected(error) {
|
|
184
|
+
const cause = error?.cause;
|
|
185
|
+
return /redirect/i.test(String(cause?.message ?? ""));
|
|
186
|
+
}
|
|
187
|
+
function checkedTimeout(timeout) {
|
|
188
|
+
if (timeout !== void 0 && !validTimeout(timeout)) {
|
|
189
|
+
throw new ManagementError({
|
|
190
|
+
kind: "client",
|
|
191
|
+
code: ManagementErrorCode.InvalidInput,
|
|
192
|
+
message: "Management timeout must be a positive, finite number of milliseconds"
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
return timeout;
|
|
196
|
+
}
|
|
197
|
+
function managementTransport(options) {
|
|
198
|
+
const clientTimeout = checkedTimeout(options.timeout) ?? DEFAULT_MANAGEMENT_TIMEOUT;
|
|
199
|
+
function callLifetime(call) {
|
|
200
|
+
return lifetime(
|
|
201
|
+
checkedTimeout(call?.timeout) ?? clientTimeout,
|
|
202
|
+
call?.signal ?? void 0
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
function transportFailure(error, context, life, sent, status, refused = false, headers) {
|
|
206
|
+
if (error instanceof ManagementError) {
|
|
207
|
+
return error;
|
|
208
|
+
}
|
|
209
|
+
const unsent2 = {
|
|
210
|
+
retryAfter: headers ? retryAfter(headers) : void 0,
|
|
211
|
+
// A redirect fetch refused to follow was answered without being applied.
|
|
212
|
+
...!sent || redirected(error) ? { uncertain: false } : refused ? {
|
|
213
|
+
uncertain: context.method !== "GET" && [500, 502, 504].includes(status ?? 0)
|
|
214
|
+
} : {},
|
|
215
|
+
...status === void 0 ? {} : { status }
|
|
216
|
+
};
|
|
217
|
+
const ended = life.ended();
|
|
218
|
+
if (ended === "aborted") {
|
|
219
|
+
return new ManagementError({
|
|
220
|
+
...context,
|
|
221
|
+
...unsent2,
|
|
222
|
+
kind: "aborted",
|
|
223
|
+
code: ManagementErrorCode.Aborted,
|
|
224
|
+
message: "The management request was cancelled",
|
|
225
|
+
cause: life.reason()
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
if (ended === "timeout") {
|
|
229
|
+
return new ManagementError({
|
|
230
|
+
...context,
|
|
231
|
+
...unsent2,
|
|
232
|
+
kind: "timeout",
|
|
233
|
+
code: ManagementErrorCode.Timeout,
|
|
234
|
+
message: `The management request did not finish within ${life.timeout} ms`,
|
|
235
|
+
cause: error
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
return new ManagementError({
|
|
239
|
+
...context,
|
|
240
|
+
...unsent2,
|
|
241
|
+
kind: "network",
|
|
242
|
+
code: ManagementErrorCode.Network,
|
|
243
|
+
message: "The management request failed before Domino answered",
|
|
244
|
+
cause: error
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
async function credential(context, life) {
|
|
248
|
+
if (!options.getToken) {
|
|
249
|
+
return null;
|
|
250
|
+
}
|
|
251
|
+
const getToken = options.getToken;
|
|
252
|
+
try {
|
|
253
|
+
return await new Promise((resolve, reject) => {
|
|
254
|
+
const stop = () => reject(life.signal.reason);
|
|
255
|
+
life.signal.addEventListener("abort", stop, { once: true });
|
|
256
|
+
getToken().then(resolve, reject).finally(() => life.signal.removeEventListener("abort", stop));
|
|
257
|
+
});
|
|
258
|
+
} catch (error) {
|
|
259
|
+
if (life.signal.aborted) {
|
|
260
|
+
throw transportFailure(error, context, life, false);
|
|
261
|
+
}
|
|
262
|
+
throw new ManagementError({
|
|
263
|
+
...context,
|
|
264
|
+
// A token source that could not reach its own service failed like a network call.
|
|
265
|
+
kind: error instanceof TypeError ? "network" : "client",
|
|
266
|
+
code: ManagementErrorCode.Credential,
|
|
267
|
+
uncertain: false,
|
|
268
|
+
message: "Could not get a management credential",
|
|
269
|
+
cause: error
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
async function send(path, fetchInit, context, life) {
|
|
274
|
+
if (life.signal.aborted) {
|
|
275
|
+
throw transportFailure(life.reason(), context, life, false);
|
|
276
|
+
}
|
|
277
|
+
const headers = new Headers(fetchInit.headers);
|
|
278
|
+
headers.set("X-Domino-Client", options.client ?? clientIdentity());
|
|
279
|
+
const token = await credential(context, life);
|
|
280
|
+
if (token) {
|
|
281
|
+
headers.set("Authorization", `Bearer ${token}`);
|
|
282
|
+
}
|
|
283
|
+
if (options.organization) {
|
|
284
|
+
headers.set("X-Relay-Organization", options.organization);
|
|
285
|
+
}
|
|
286
|
+
if (options.project) {
|
|
287
|
+
headers.set("X-Relay-Project", options.project);
|
|
288
|
+
}
|
|
289
|
+
if (options.environment) {
|
|
290
|
+
headers.set("X-Relay-Environment", options.environment);
|
|
291
|
+
}
|
|
292
|
+
let response;
|
|
293
|
+
try {
|
|
294
|
+
response = await fetch(`${options.baseUrl}/management/v1${path}`, {
|
|
295
|
+
...fetchInit,
|
|
296
|
+
headers,
|
|
297
|
+
signal: life.signal,
|
|
298
|
+
...options.redirect ? { redirect: options.redirect } : {}
|
|
299
|
+
});
|
|
300
|
+
} catch (error) {
|
|
301
|
+
throw transportFailure(error, context, life, !unsent(error));
|
|
302
|
+
}
|
|
303
|
+
if (!response.ok) {
|
|
304
|
+
let text;
|
|
305
|
+
try {
|
|
306
|
+
text = await response.text();
|
|
307
|
+
} catch (error2) {
|
|
308
|
+
throw transportFailure(
|
|
309
|
+
error2,
|
|
310
|
+
context,
|
|
311
|
+
life,
|
|
312
|
+
true,
|
|
313
|
+
response.status,
|
|
314
|
+
true,
|
|
315
|
+
response.headers
|
|
316
|
+
);
|
|
317
|
+
}
|
|
318
|
+
let body = null;
|
|
319
|
+
try {
|
|
320
|
+
body = JSON.parse(text);
|
|
321
|
+
} catch {
|
|
322
|
+
}
|
|
323
|
+
const parsed = managementErrorSchema.safeParse(body);
|
|
324
|
+
const { error, code, ...details } = parsed.success ? parsed.data : { error: `Request failed (${response.status})`, code: void 0 };
|
|
325
|
+
throw new ManagementError({
|
|
326
|
+
...context,
|
|
327
|
+
kind: "http",
|
|
328
|
+
status: response.status,
|
|
329
|
+
message: error,
|
|
330
|
+
...code === void 0 ? {} : { code },
|
|
331
|
+
details,
|
|
332
|
+
retryAfter: retryAfter(response.headers)
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
return response;
|
|
336
|
+
}
|
|
337
|
+
async function raw(path, init) {
|
|
338
|
+
const { timeout, signal, ...fetchInit } = init ?? {};
|
|
339
|
+
const life = callLifetime({ timeout, signal: signal ?? void 0 });
|
|
340
|
+
try {
|
|
341
|
+
return await send(
|
|
342
|
+
path,
|
|
343
|
+
fetchInit,
|
|
344
|
+
{
|
|
345
|
+
method: (fetchInit.method ?? "GET").toUpperCase(),
|
|
346
|
+
path: path.split("?")[0],
|
|
347
|
+
replaySafe: false
|
|
348
|
+
},
|
|
349
|
+
life
|
|
350
|
+
);
|
|
351
|
+
} finally {
|
|
352
|
+
life.end();
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
async function exchange(path, schema, input, method, call, replaySafe, tolerant = false) {
|
|
356
|
+
const actionId = actionIdOf(input);
|
|
357
|
+
const context = {
|
|
358
|
+
method,
|
|
359
|
+
replaySafe,
|
|
360
|
+
path: path.split("?")[0],
|
|
361
|
+
...actionId ? { actionId } : {}
|
|
362
|
+
};
|
|
363
|
+
const fetchInit = {
|
|
364
|
+
method,
|
|
365
|
+
headers: tolerant ? { "X-Domino-Response": "tolerant-v1" } : void 0,
|
|
366
|
+
...input === void 0 ? {} : {
|
|
367
|
+
headers: {
|
|
368
|
+
"Content-Type": "application/json",
|
|
369
|
+
...tolerant ? { "X-Domino-Response": "tolerant-v1" } : {}
|
|
370
|
+
},
|
|
371
|
+
body: JSON.stringify(input)
|
|
372
|
+
}
|
|
373
|
+
};
|
|
374
|
+
const life = callLifetime(call);
|
|
375
|
+
try {
|
|
376
|
+
return await retrying(
|
|
377
|
+
life,
|
|
378
|
+
{ replaySafe: method === "GET" || replaySafe },
|
|
379
|
+
async () => {
|
|
380
|
+
const response = await send(path, fetchInit, context, life);
|
|
381
|
+
let body;
|
|
382
|
+
try {
|
|
383
|
+
body = response.status === 204 ? null : await response.json();
|
|
384
|
+
} catch (error) {
|
|
385
|
+
if (error instanceof SyntaxError && !life.signal.aborted) {
|
|
386
|
+
throw new ManagementError({
|
|
387
|
+
...context,
|
|
388
|
+
kind: "invalid-response",
|
|
389
|
+
code: ManagementErrorCode.InvalidResponse,
|
|
390
|
+
status: response.status,
|
|
391
|
+
message: "Domino answered with a body that is not JSON",
|
|
392
|
+
cause: error
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
throw transportFailure(
|
|
396
|
+
error,
|
|
397
|
+
context,
|
|
398
|
+
life,
|
|
399
|
+
true,
|
|
400
|
+
response.status,
|
|
401
|
+
false,
|
|
402
|
+
response.headers
|
|
403
|
+
);
|
|
404
|
+
}
|
|
405
|
+
if (schema === void 0) {
|
|
406
|
+
return body;
|
|
407
|
+
}
|
|
408
|
+
const parsed = knownResponse(schema).safeParse(
|
|
409
|
+
tolerant ? { status: response.status, operationId: actionId, result: body } : body
|
|
410
|
+
);
|
|
411
|
+
if (!parsed.success) {
|
|
412
|
+
throw new ManagementError({
|
|
413
|
+
...context,
|
|
414
|
+
kind: "invalid-response",
|
|
415
|
+
code: ManagementErrorCode.InvalidResponse,
|
|
416
|
+
status: response.status,
|
|
417
|
+
message: "Domino answered with a response this client does not recognize",
|
|
418
|
+
cause: parsed.error
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
return parsed.data;
|
|
422
|
+
}
|
|
423
|
+
);
|
|
424
|
+
} finally {
|
|
425
|
+
life.end();
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
return { raw, exchange };
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
// src/sequence-cursor.ts
|
|
432
|
+
import { z as z3 } from "zod";
|
|
433
|
+
var sequenceCursorSchema = z3.string().regex(/^[1-9][0-9]{0,15}$/, "Invalid cursor").transform(Number).pipe(z3.number().int().positive().safe());
|
|
434
|
+
|
|
435
|
+
// src/referral-reward-kinds.ts
|
|
436
|
+
var REFERRAL_INTEGRATION_REWARD_ERROR = "Referral programs can grant points and tiered rewards; Discord roles need a quest";
|
|
437
|
+
var isRecord = (value) => typeof value === "object" && value !== null;
|
|
438
|
+
function containsReferralIntegrationReward(value) {
|
|
439
|
+
if (Array.isArray(value)) {
|
|
440
|
+
return value.some(
|
|
441
|
+
(reward) => isRecord(reward) && reward.kind === "integration"
|
|
442
|
+
);
|
|
443
|
+
}
|
|
444
|
+
if (!isRecord(value)) {
|
|
445
|
+
return false;
|
|
446
|
+
}
|
|
447
|
+
const definition = isRecord(value.definition) ? value.definition : value;
|
|
448
|
+
return isRecord(definition.rewards) && (containsReferralIntegrationReward(definition.rewards.inviter) || containsReferralIntegrationReward(definition.rewards.invitee)) || Array.isArray(definition.milestones) && definition.milestones.some(
|
|
449
|
+
(milestone) => isRecord(milestone) && containsReferralIntegrationReward(milestone.rewards)
|
|
450
|
+
);
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
export {
|
|
454
|
+
questConfiguration,
|
|
455
|
+
identityIntegrationInputSchema,
|
|
456
|
+
identityIntegrationSchema,
|
|
457
|
+
identityIntegrationSecretSchema,
|
|
458
|
+
identityKindClaimSchema,
|
|
459
|
+
participantExchangeSchema,
|
|
460
|
+
ManagementErrorCode,
|
|
461
|
+
managementErrorSchema,
|
|
462
|
+
isManagementError,
|
|
463
|
+
ManagementError,
|
|
464
|
+
DEFAULT_MANAGEMENT_TIMEOUT,
|
|
465
|
+
actionIdOf,
|
|
466
|
+
managementTransport,
|
|
467
|
+
sequenceCursorSchema,
|
|
468
|
+
REFERRAL_INTEGRATION_REWARD_ERROR,
|
|
469
|
+
containsReferralIntegrationReward
|
|
470
|
+
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createRelayClient
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-VBHFJH3P.js";
|
|
4
4
|
import {
|
|
5
5
|
RelayErrorCode,
|
|
6
6
|
asRelayError,
|
|
7
7
|
clientError,
|
|
8
8
|
cosmosChain
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-2UAVZCMH.js";
|
|
10
10
|
|
|
11
11
|
// src/base58.ts
|
|
12
12
|
var alphabet = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
pointLedgerReferenceSchema
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-UJACD6K2.js";
|
|
4
4
|
import {
|
|
5
5
|
authoringIdentityShape,
|
|
6
6
|
entitlementSchema,
|
|
@@ -90,8 +90,12 @@ var relayEventSchema = z.union([
|
|
|
90
90
|
]);
|
|
91
91
|
var participantActivityQuerySchema = z.object({
|
|
92
92
|
cursor: pageCursorSchema.optional(),
|
|
93
|
+
/** `latest` answers no events and the cursor of the newest one, to follow only what comes next. */
|
|
94
|
+
start: z.literal("latest").optional(),
|
|
93
95
|
limit: z.number().int().min(1).max(100).default(50)
|
|
94
|
-
}).strict()
|
|
96
|
+
}).strict().refine((query) => !(query.cursor && query.start), {
|
|
97
|
+
message: "Pass either cursor or start, not both"
|
|
98
|
+
});
|
|
95
99
|
var participantActivitySchema = z.object({
|
|
96
100
|
member: z.string(),
|
|
97
101
|
items: z.array(relayEventSchema),
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import {
|
|
2
|
+
capabilityFailureSchema
|
|
3
|
+
} from "./chunk-MC6V6VMG.js";
|
|
4
|
+
import {
|
|
5
|
+
contentPerformanceSnapshotSchema,
|
|
6
|
+
decisionSchema,
|
|
7
|
+
identifier,
|
|
8
|
+
rewardBundleSchema,
|
|
9
|
+
settingsValuesSchema,
|
|
10
|
+
trackerTriggerContextSchema
|
|
11
|
+
} from "./chunk-46C33ASD.js";
|
|
12
|
+
|
|
13
|
+
// src/server/attempt-captures.ts
|
|
14
|
+
import { z } from "zod";
|
|
15
|
+
var timestamp = z.number().int().nonnegative().safe();
|
|
16
|
+
var capturedFactSchema = z.object({
|
|
17
|
+
/** The call's position in the run, from 0. */
|
|
18
|
+
sequence: z.number().int().nonnegative(),
|
|
19
|
+
/** The capability request quest code sent, after validation. */
|
|
20
|
+
request: z.record(z.string(), z.json()),
|
|
21
|
+
/**
|
|
22
|
+
* The answer every retry of the run receives: the result, or the failure quest code saw. Absent
|
|
23
|
+
* while the call has no answer, such as when the run stopped during it.
|
|
24
|
+
*/
|
|
25
|
+
outcome: z.union([
|
|
26
|
+
z.object({ value: z.json() }),
|
|
27
|
+
z.object({ error: capabilityFailureSchema })
|
|
28
|
+
]).optional(),
|
|
29
|
+
/**
|
|
30
|
+
* False when a retry of the run asks the provider again: a retryable failure Relay recorded but
|
|
31
|
+
* did not keep, or a call without an answer. A replay cannot answer such a call.
|
|
32
|
+
*/
|
|
33
|
+
captured: z.boolean()
|
|
34
|
+
});
|
|
35
|
+
var attemptCaptureSchema = z.object({
|
|
36
|
+
format: z.literal(1),
|
|
37
|
+
attempt: identifier,
|
|
38
|
+
environment: z.literal("test"),
|
|
39
|
+
quest: z.object({
|
|
40
|
+
id: identifier,
|
|
41
|
+
/** The quest's authoring key; null for a quest created in Console. */
|
|
42
|
+
key: identifier.nullable()
|
|
43
|
+
}),
|
|
44
|
+
release: identifier,
|
|
45
|
+
evaluationRun: z.number().int().nonnegative(),
|
|
46
|
+
/** The evaluator protocol the release was built for. */
|
|
47
|
+
protocol: z.number().int().positive(),
|
|
48
|
+
/** The seed of the run's `Math.random()` and `crypto.randomUUID()` streams. */
|
|
49
|
+
seed: z.string().min(1),
|
|
50
|
+
/** The run's frozen start time, `ctx.now`. */
|
|
51
|
+
now: timestamp,
|
|
52
|
+
context: z.object({
|
|
53
|
+
settings: settingsValuesSchema,
|
|
54
|
+
rewards: rewardBundleSchema,
|
|
55
|
+
humanReview: z.boolean(),
|
|
56
|
+
integrations: z.array(z.string()),
|
|
57
|
+
member: identifier,
|
|
58
|
+
input: z.record(z.string(), z.json()),
|
|
59
|
+
tracker: trackerTriggerContextSchema.nullable(),
|
|
60
|
+
eligibleAt: timestamp,
|
|
61
|
+
calendar: z.object({
|
|
62
|
+
segments: z.array(
|
|
63
|
+
z.looseObject({ effectiveAt: timestamp, timeZone: z.string() })
|
|
64
|
+
)
|
|
65
|
+
}),
|
|
66
|
+
performance: contentPerformanceSnapshotSchema.nullable()
|
|
67
|
+
}),
|
|
68
|
+
facts: z.array(capturedFactSchema),
|
|
69
|
+
/**
|
|
70
|
+
* What quest code decided in the run, before Relay amended, claimed or reviewed it. Null while it
|
|
71
|
+
* has decided nothing, and for runs decided before Relay kept decisions.
|
|
72
|
+
*/
|
|
73
|
+
recorded: decisionSchema.nullable()
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
export {
|
|
77
|
+
capturedFactSchema,
|
|
78
|
+
attemptCaptureSchema
|
|
79
|
+
};
|