@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.
- package/CHANGELOG.md +120 -0
- package/dist/{accounts-CCqCKCVx.d.ts → accounts-nz3mzfRQ.d.ts} +21 -3
- package/dist/{attempt-captures-Cm-5G0PC.d.ts → attempt-captures-DMi8oR9T.d.ts} +1 -1
- package/dist/authoring.d.ts +54 -20
- package/dist/authoring.js +58 -24
- package/dist/{automatic-outcomes-pAsOyIVp.d.ts → automatic-outcomes-C_LLQU1p.d.ts} +11 -1
- package/dist/avatar.d.ts +1 -1
- package/dist/browser.d.ts +9 -9
- package/dist/browser.js +15 -13
- package/dist/capability-error-CuI_F7yM.d.ts +296 -0
- package/dist/{catalog--ZIlskAo.d.ts → catalog-BaTOKpNw.d.ts} +21 -10
- package/dist/{chunk-3PYYGFSB.js → chunk-3RFP6GT5.js} +3 -3
- package/dist/{chunk-HTZHBTIL.js → chunk-4GQW43UU.js} +193 -357
- package/dist/{chunk-D26YNACF.js → chunk-4NOFSGAL.js} +56 -56
- package/dist/{chunk-UW5232GG.js → chunk-5XLZ34PV.js} +5 -5
- package/dist/{chunk-QYPMPWVX.js → chunk-7X67QLPB.js} +43 -43
- package/dist/{chunk-5TEYFX6X.js → chunk-7Z4SZ6YM.js} +2 -2
- package/dist/{chunk-Y322OTCH.js → chunk-AQOL3SK5.js} +1 -1
- package/dist/{chunk-CICDIBOF.js → chunk-EHUSD3O2.js} +76 -72
- package/dist/chunk-FO2LCZTL.js +19 -0
- package/dist/{chunk-3KLC4AMA.js → chunk-FU5CGNTR.js} +135 -173
- package/dist/{chunk-K2KS3JLY.js → chunk-GLH6MEI2.js} +7 -2
- package/dist/chunk-ICXZZNPS.js +199 -0
- package/dist/{chunk-MK425RXJ.js → chunk-ID3BZXFZ.js} +709 -640
- package/dist/{chunk-UAKYDVT3.js → chunk-KP2MCX3R.js} +111 -89
- package/dist/{chunk-GKIFABGN.js → chunk-LZWXCBUB.js} +74 -247
- package/dist/{chunk-6WCIWXUV.js → chunk-MTKRIQEU.js} +2 -2
- package/dist/{chunk-4OC7REYX.js → chunk-MWMCQLCG.js} +3 -3
- package/dist/{chunk-XJFYAXET.js → chunk-N4BDKS6Y.js} +19 -19
- package/dist/{chunk-E6IKQHTX.js → chunk-N4LNEGQX.js} +2 -2
- package/dist/chunk-NQDEWJWE.js +554 -0
- package/dist/{chunk-GTDW453U.js → chunk-QR6HH4DI.js} +100 -114
- package/dist/chunk-TLSQETTY.js +41 -0
- package/dist/{chunk-CZFXGGEK.js → chunk-U66GUVSG.js} +2 -2
- package/dist/{chunk-KDR2VAJP.js → chunk-UYVJZR33.js} +2 -2
- package/dist/chunk-UZ765UGH.js +18 -0
- package/dist/{chunk-XNKSSE32.js → chunk-VWQGWGCH.js} +7 -7
- package/dist/{chunk-WSBYWVTZ.js → chunk-W7YSMSGC.js} +166 -158
- package/dist/{client-B-hbHX30.d.ts → client-DHmG7rn6.d.ts} +25 -61
- package/dist/{capability-error-DFMwSuSf.d.ts → dashboards-CLemT6kj.d.ts} +14 -294
- package/dist/{deployments-M4OHn7G3.d.ts → deployments-DTULi7dF.d.ts} +46 -3
- package/dist/{identity-integration-3mX6b5iH.d.ts → identity-integration-DOeNZaxF.d.ts} +32 -2
- package/dist/index.d.ts +10 -10
- package/dist/index.js +13 -11
- package/dist/internal.d.ts +27 -13
- package/dist/internal.js +41 -13
- package/dist/{analytics-BwAKLi7O.d.ts → limits-kNzYdZ00.d.ts} +124 -3
- package/dist/{offers-DhAtss4_.d.ts → offers-CYeN_I0Y.d.ts} +3 -2
- package/dist/portal-proxy.d.ts +19 -3
- package/dist/portal-proxy.js +64 -22
- package/dist/react/index.d.ts +21 -14
- package/dist/react/index.js +55 -29
- package/dist/{pages-B8q8Y_dQ.d.ts → reward-deliveries-drp-x1G-.d.ts} +300 -233
- 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 +193 -18
- package/dist/schema.js +31 -26
- package/dist/server/index.d.ts +13 -13
- package/dist/server/index.js +5885 -6224
- package/dist/{sign-in-providers-BkjcDsFF.d.ts → sign-in-providers-B1Q9eDRm.d.ts} +7 -2
- package/dist/{submission-input-DHGKhXfp.d.ts → submission-input-DZCbjQUH.d.ts} +3 -2
- package/dist/{telegram-browser-BCE7zdOb.d.ts → telegram-browser-NL0Asmsi.d.ts} +4 -4
- package/dist/telegram.d.ts +8 -8
- package/dist/telegram.js +2 -2
- package/dist/testing.d.ts +228 -26
- package/dist/testing.js +137 -92
- package/dist/{tracker-data-Hb1uQnk5.d.ts → tracker-data-esm3WG8R.d.ts} +34 -8
- package/dist/{transport-DkhX2Cbs.d.ts → transport-Czht_irp.d.ts} +41259 -39835
- package/dist/{wallet-DTO7SXj7.d.ts → wallet-B7e06v4m.d.ts} +14 -4
- package/package.json +1 -1
- package/dist/chunk-UPQPUJOU.js +0 -457
- package/dist/runtime/chunks/Y4OAVXFR.js +0 -1
|
@@ -425,6 +425,8 @@ declare function walletAddressInput(signer: WalletSigner): Promise<WalletAddress
|
|
|
425
425
|
/**
|
|
426
426
|
* The most wallets of one chain family a member can have linked to one project at a time. Sign-in
|
|
427
427
|
* wallets do not count: signing in always links the wallet.
|
|
428
|
+
*
|
|
429
|
+
* @deprecated Use `limits.walletsPerChain`, which a 1.x release can raise.
|
|
428
430
|
*/
|
|
429
431
|
declare const WALLETS_PER_CHAIN = 5;
|
|
430
432
|
/** The wallet families a project can enable for sign-in, in their stored order. */
|
|
@@ -743,7 +745,11 @@ declare function isContractEvent(value: string): value is ContractEvent;
|
|
|
743
745
|
type WalletEventCondition = string | boolean | {
|
|
744
746
|
gte: string;
|
|
745
747
|
};
|
|
746
|
-
/**
|
|
748
|
+
/**
|
|
749
|
+
* The most logs one `ctx.wallet.events()` read may match before `where` filters them.
|
|
750
|
+
*
|
|
751
|
+
* @deprecated Use `limits.walletEventLogs`, which a 1.x release can raise.
|
|
752
|
+
*/
|
|
747
753
|
declare const maxWalletEventLogs = 1000;
|
|
748
754
|
/** How far before the evaluation `ctx.wallet.events()` may look back: 30 days. */
|
|
749
755
|
declare const maxWalletEventLookback: number;
|
|
@@ -769,7 +775,7 @@ type WalletEventsQuery = {
|
|
|
769
775
|
address?: string;
|
|
770
776
|
/**
|
|
771
777
|
* Return only the newest matching events, at most this many: from 1 to
|
|
772
|
-
* {@link
|
|
778
|
+
* {@link limits.walletEventLogs}. Relay reads back from the newest block and stops at its caps
|
|
773
779
|
* (1,000 logs, 3,000,000 blocks) instead of throwing, and the result's `complete` is false when
|
|
774
780
|
* older matching events may be left out. Without it, a read that reaches a cap throws
|
|
775
781
|
* `author-error`.
|
|
@@ -841,7 +847,11 @@ declare const solanaProgramIdlSchema: z.ZodObject<{
|
|
|
841
847
|
idl: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
|
|
842
848
|
}, z.core.$strict>;
|
|
843
849
|
type SolanaProgramIdl = z.infer<typeof solanaProgramIdlSchema>;
|
|
844
|
-
/**
|
|
850
|
+
/**
|
|
851
|
+
* The most transactions one `ctx.wallet.transactions()` read fetches per wallet.
|
|
852
|
+
*
|
|
853
|
+
* @deprecated Use `limits.walletTransactions`, which a 1.x release can raise.
|
|
854
|
+
*/
|
|
845
855
|
declare const maxWalletTransactions = 1000;
|
|
846
856
|
/** How far before the evaluation `ctx.wallet.transactions()` may look back: 30 days. */
|
|
847
857
|
declare const maxWalletTransactionLookback: number;
|
|
@@ -989,4 +999,4 @@ interface WalletReader {
|
|
|
989
999
|
transactions?(query: WalletTransactionsQuery): Promise<WalletTransactions | null>;
|
|
990
1000
|
}
|
|
991
1001
|
|
|
992
|
-
export { type WalletTransactions as $, type AvatarProvider as A, type
|
|
1002
|
+
export { type WalletTransactions as $, type AvatarProvider as A, type ContractFunction as B, type CosmosChain as C, type CosmosDenom as D, type EvmChainId as E, type NftCollectionParts as F, type NftStandard as G, type WalletBalance as H, type WalletBalanceChange as I, type WalletBalanceSample as J, type WalletCall as K, type LinkedWallet as L, type WalletCallArgument as M, type NftCollection as N, type OwnProfile as O, type ProfileAvatar as P, type WalletCallQuery as Q, type WalletDelegations as R, type SolanaIdlSource as S, type WalletDelegationsQuery as T, type WalletEventCondition as U, type WalletEventValue as V, type WalletAddressInput as W, type WalletEvents as X, type WalletEventsQuery as Y, type WalletNfts as Z, type WalletNftsQuery as _, type CosmosNetwork as a, walletDelegationsSchema as a$, type WalletTransactionsQuery as a0, cosmosDenomSchema as a1, cosmosNetworkSchema as a2, isContractCall as a3, isContractEvent as a4, isEvmChainId as a5, isNftCollection as a6, isSolanaProgram as a7, maxWalletEventLogs as a8, maxWalletEventLookback as a9, cosmosChain as aA, displayNameSchema as aB, evmAddressSchema as aC, evmChainIdSchema as aD, linkedWalletSchema as aE, managedProfileSchema as aF, ownProfileSchema as aG, profileAvatarSchema as aH, profileCompletionPageSchema as aI, profileCompletionQuerySchema as aJ, profileCompletionSchema as aK, profileDefaultProviderSchema as aL, profileDefaultsSchema as aM, profileModerationSchema as aN, profileReferralSchema as aO, profileSettingsInputSchema as aP, profileSettingsSchema as aQ, profileSummarySchema as aR, profileVisibilitySchema as aS, solanaAddressSchema as aT, solanaMainnet as aU, solanaProgramIdlSchema as aV, walletAddressInput as aW, walletBalanceSampleSchema as aX, walletBalanceSchema as aY, walletCallSchema as aZ, walletChainSchema as a_, maxWalletTransactionLookback as aa, maxWalletTransactions as ab, parseContractCall as ac, parseContractEvent as ad, parseContractFunction as ae, parseNftCollection as af, profileUpdateSchema as ag, walletAddressInputSchema as ah, walletSignatureSchema as ai, AVATAR_UPLOAD_LIMIT as aj, type AnchorIdl as ak, type KnownSolanaIdlSource as al, type ManagedProfile as am, type ProfileDefaultProvider as an, type ProfileDefaults as ao, type ProfileModeration as ap, type ProfileSettings as aq, type ProfileSettingsInput as ar, type SolanaProgramIdl as as, WALLETS_PER_CHAIN as at, anchorIdlSchema as au, avatarProviderSchema as av, avatarSeedSchema as aw, avatarUploadTypes as ax, caip10 as ay, cosmosAddressSchema as az, type ProfileCompletion as b, walletEventsSchema as b0, walletMessageChallengeSchema as b1, walletNftsSchema as b2, walletSignInFamilies as b3, walletSignInNetwork as b4, walletSignInNetworkSchema as b5, walletSignInNetworksSchema as b6, walletTransactionsSchema as b7, walletUnlinkInputSchema as b8, type ProfileCompletionPage as c, type ProfileCompletionQuery as d, type ProfileReferral as e, type ProfileSummary as f, type ProfileUpdate as g, type ProfileVisibility as h, type WalletChain as i, type WalletMessageChallenge as j, type WalletSignInNetwork as k, type WalletSignature as l, type WalletSigner as m, type WalletUnlinkInput as n, type WalletBalanceQuery as o, type ContractCall as p, type ContractEvent as q, type SolanaProgram as r, type WalletBalanceSourceQuery as s, type WalletTransaction as t, type WalletInstruction as u, type WalletReader as v, type ContractCallParts as w, type ContractCallReturnType as x, type ContractEventInput as y, type ContractEventParts as z };
|
package/package.json
CHANGED
package/dist/chunk-UPQPUJOU.js
DELETED
|
@@ -1,457 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
MANAGEMENT_TIMEOUT,
|
|
3
|
-
clientIdentity,
|
|
4
|
-
lifetime,
|
|
5
|
-
retryAfter,
|
|
6
|
-
retrying,
|
|
7
|
-
validTimeout
|
|
8
|
-
} from "./chunk-3PYYGFSB.js";
|
|
9
|
-
import {
|
|
10
|
-
knownResponse
|
|
11
|
-
} from "./chunk-MK425RXJ.js";
|
|
12
|
-
import {
|
|
13
|
-
RequestError,
|
|
14
|
-
isRequestError
|
|
15
|
-
} from "./chunk-K2KS3JLY.js";
|
|
16
|
-
|
|
17
|
-
// src/configuration.ts
|
|
18
|
-
function questConfiguration(release) {
|
|
19
|
-
return release.configuration ?? {
|
|
20
|
-
defaults: Object.fromEntries(
|
|
21
|
-
Object.entries(release.fields).map(([key, field]) => [
|
|
22
|
-
key,
|
|
23
|
-
field.default
|
|
24
|
-
])
|
|
25
|
-
),
|
|
26
|
-
overrides: { ...release.values },
|
|
27
|
-
preserved: Object.keys(release.values)
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// src/server/errors.ts
|
|
32
|
-
import * as z from "zod";
|
|
33
|
-
var ManagementErrorCode = {
|
|
34
|
-
/** The input or an option failed validation before anything was sent (kind `client`). */
|
|
35
|
-
InvalidInput: "invalid-input",
|
|
36
|
-
/** The client's `getToken` failed before anything was sent (kind `client` or `network`). */
|
|
37
|
-
Credential: "credential",
|
|
38
|
-
Network: "network",
|
|
39
|
-
Timeout: "timeout",
|
|
40
|
-
Aborted: "aborted",
|
|
41
|
-
InvalidResponse: "invalid-response"
|
|
42
|
-
};
|
|
43
|
-
var managementErrorSchema = z.looseObject({
|
|
44
|
-
error: z.string(),
|
|
45
|
-
code: z.string().optional()
|
|
46
|
-
});
|
|
47
|
-
var uncertainStatuses = /* @__PURE__ */ new Set([500, 502, 504]);
|
|
48
|
-
function uncertainOutcome(init) {
|
|
49
|
-
if (init.method === void 0 || init.method === "GET") {
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
switch (init.kind) {
|
|
53
|
-
case "network":
|
|
54
|
-
case "timeout":
|
|
55
|
-
case "aborted":
|
|
56
|
-
return true;
|
|
57
|
-
case "http":
|
|
58
|
-
return uncertainStatuses.has(init.status ?? 0);
|
|
59
|
-
case "invalid-response":
|
|
60
|
-
return (init.status ?? 0) >= 200 && (init.status ?? 0) < 300;
|
|
61
|
-
default:
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
var managementErrorBrand = /* @__PURE__ */ Symbol.for("@domino-sdk/relay.ManagementError");
|
|
66
|
-
function isManagementError(value) {
|
|
67
|
-
return isRequestError(value) && value[managementErrorBrand] === true;
|
|
68
|
-
}
|
|
69
|
-
var ManagementError = class extends RequestError {
|
|
70
|
-
name = "ManagementError";
|
|
71
|
-
[managementErrorBrand] = true;
|
|
72
|
-
/** The rest of the server's error body besides `error` and `code`, such as `moved`; absent when there is none. */
|
|
73
|
-
details;
|
|
74
|
-
/** The request's method; absent when the call failed before forming a request. */
|
|
75
|
-
method;
|
|
76
|
-
/** The management API path, below `/management/v1`, without its query; absent like `method`. */
|
|
77
|
-
path;
|
|
78
|
-
constructor(init) {
|
|
79
|
-
super(init.message, {
|
|
80
|
-
kind: init.kind,
|
|
81
|
-
uncertain: init.uncertain ?? uncertainOutcome(init),
|
|
82
|
-
status: init.status,
|
|
83
|
-
code: init.code,
|
|
84
|
-
operationId: init.actionId,
|
|
85
|
-
replaySafe: init.replaySafe,
|
|
86
|
-
retryAfter: init.retryAfter,
|
|
87
|
-
cause: init.cause
|
|
88
|
-
});
|
|
89
|
-
this.details = init.details && Object.keys(init.details).length ? init.details : void 0;
|
|
90
|
-
this.method = init.method;
|
|
91
|
-
this.path = init.path;
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
var DEFAULT_MANAGEMENT_TIMEOUT = MANAGEMENT_TIMEOUT;
|
|
95
|
-
|
|
96
|
-
// src/server/transport.ts
|
|
97
|
-
import * as z2 from "zod";
|
|
98
|
-
var ManagementUploadBody = class {
|
|
99
|
-
constructor(body, headers, actionId) {
|
|
100
|
-
this.body = body;
|
|
101
|
-
this.headers = headers;
|
|
102
|
-
this.actionId = actionId;
|
|
103
|
-
}
|
|
104
|
-
body;
|
|
105
|
-
headers;
|
|
106
|
-
actionId;
|
|
107
|
-
};
|
|
108
|
-
function failureCause(error) {
|
|
109
|
-
if (typeof error !== "object" || error === null || !("cause" in error)) {
|
|
110
|
-
return {};
|
|
111
|
-
}
|
|
112
|
-
const { cause } = error;
|
|
113
|
-
return typeof cause === "object" && cause !== null ? cause : {};
|
|
114
|
-
}
|
|
115
|
-
function actionIdOf(input) {
|
|
116
|
-
if (input instanceof ManagementUploadBody) {
|
|
117
|
-
return input.actionId;
|
|
118
|
-
}
|
|
119
|
-
return typeof input === "object" && input !== null && "actionId" in input && typeof input.actionId === "string" ? input.actionId : void 0;
|
|
120
|
-
}
|
|
121
|
-
function unsent(error) {
|
|
122
|
-
const code = String(failureCause(error).code ?? "");
|
|
123
|
-
return /^(ECONNREFUSED|ENOTFOUND|EAI_AGAIN|ENETUNREACH|EHOSTUNREACH|UND_ERR_CONNECT_TIMEOUT)$|CERT|TLS|SSL/.test(
|
|
124
|
-
code
|
|
125
|
-
);
|
|
126
|
-
}
|
|
127
|
-
function redirected(error) {
|
|
128
|
-
return /redirect/i.test(String(failureCause(error).message ?? ""));
|
|
129
|
-
}
|
|
130
|
-
function checkedTimeout(timeout) {
|
|
131
|
-
if (timeout !== void 0 && !validTimeout(timeout)) {
|
|
132
|
-
throw new ManagementError({
|
|
133
|
-
kind: "client",
|
|
134
|
-
code: ManagementErrorCode.InvalidInput,
|
|
135
|
-
message: "Management timeout must be a positive, finite number of milliseconds"
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
return timeout;
|
|
139
|
-
}
|
|
140
|
-
function managementTransport(options) {
|
|
141
|
-
const clientTimeout = checkedTimeout(options.timeout) ?? DEFAULT_MANAGEMENT_TIMEOUT;
|
|
142
|
-
try {
|
|
143
|
-
const headers = new Headers(options.headers);
|
|
144
|
-
headers.set("X-Relay-Organization", options.organization ?? "");
|
|
145
|
-
headers.set("X-Relay-Project", options.project ?? "");
|
|
146
|
-
} catch (error) {
|
|
147
|
-
throw new ManagementError({
|
|
148
|
-
kind: "client",
|
|
149
|
-
code: ManagementErrorCode.InvalidInput,
|
|
150
|
-
message: "Management headers, organization and project must be valid HTTP header values",
|
|
151
|
-
cause: error
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
function callLifetime(call) {
|
|
155
|
-
return lifetime(
|
|
156
|
-
checkedTimeout(call?.timeout) ?? clientTimeout,
|
|
157
|
-
call?.signal ?? void 0
|
|
158
|
-
);
|
|
159
|
-
}
|
|
160
|
-
function transportFailure(error, context, life, sent, status, refused = false, headers) {
|
|
161
|
-
if (error instanceof ManagementError) {
|
|
162
|
-
return error;
|
|
163
|
-
}
|
|
164
|
-
const unsent2 = {
|
|
165
|
-
retryAfter: headers ? retryAfter(headers) : void 0,
|
|
166
|
-
// A redirect fetch refused to follow was answered without being applied.
|
|
167
|
-
...!sent || redirected(error) ? { uncertain: false } : refused ? {
|
|
168
|
-
uncertain: context.method !== "GET" && [500, 502, 504].includes(status ?? 0)
|
|
169
|
-
} : {},
|
|
170
|
-
...status === void 0 ? {} : { status }
|
|
171
|
-
};
|
|
172
|
-
const ended = life.ended();
|
|
173
|
-
if (ended === "aborted") {
|
|
174
|
-
return new ManagementError({
|
|
175
|
-
...context,
|
|
176
|
-
...unsent2,
|
|
177
|
-
kind: "aborted",
|
|
178
|
-
code: ManagementErrorCode.Aborted,
|
|
179
|
-
message: "The management request was cancelled",
|
|
180
|
-
cause: life.reason()
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
if (ended === "timeout") {
|
|
184
|
-
return new ManagementError({
|
|
185
|
-
...context,
|
|
186
|
-
...unsent2,
|
|
187
|
-
kind: "timeout",
|
|
188
|
-
code: ManagementErrorCode.Timeout,
|
|
189
|
-
message: `The management request did not finish within ${life.timeout} ms`,
|
|
190
|
-
cause: error
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
return new ManagementError({
|
|
194
|
-
...context,
|
|
195
|
-
...unsent2,
|
|
196
|
-
kind: "network",
|
|
197
|
-
code: ManagementErrorCode.Network,
|
|
198
|
-
message: "The management request failed before Domino answered",
|
|
199
|
-
cause: error
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
async function credential(context, life) {
|
|
203
|
-
if (!options.getToken) {
|
|
204
|
-
return null;
|
|
205
|
-
}
|
|
206
|
-
const getToken = options.getToken;
|
|
207
|
-
try {
|
|
208
|
-
return await new Promise((resolve, reject) => {
|
|
209
|
-
const stop = () => reject(life.signal.reason);
|
|
210
|
-
life.signal.addEventListener("abort", stop, { once: true });
|
|
211
|
-
getToken().then(resolve, reject).finally(() => life.signal.removeEventListener("abort", stop));
|
|
212
|
-
});
|
|
213
|
-
} catch (error) {
|
|
214
|
-
if (life.signal.aborted) {
|
|
215
|
-
throw transportFailure(error, context, life, false);
|
|
216
|
-
}
|
|
217
|
-
throw new ManagementError({
|
|
218
|
-
...context,
|
|
219
|
-
// A token source that could not reach its own service failed like a network call.
|
|
220
|
-
kind: error instanceof TypeError ? "network" : "client",
|
|
221
|
-
code: ManagementErrorCode.Credential,
|
|
222
|
-
uncertain: false,
|
|
223
|
-
message: "Could not get a management credential",
|
|
224
|
-
cause: error
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
async function send(path, fetchInit, context, life) {
|
|
229
|
-
if (life.signal.aborted) {
|
|
230
|
-
throw transportFailure(life.reason(), context, life, false);
|
|
231
|
-
}
|
|
232
|
-
const headers = new Headers(options.headers);
|
|
233
|
-
new Headers(fetchInit.headers).forEach(
|
|
234
|
-
(value, name) => headers.set(name, value)
|
|
235
|
-
);
|
|
236
|
-
headers.set("X-Domino-Client", options.client ?? clientIdentity());
|
|
237
|
-
const token = await credential(context, life);
|
|
238
|
-
if (token) {
|
|
239
|
-
try {
|
|
240
|
-
headers.set("Authorization", `Bearer ${token}`);
|
|
241
|
-
} catch (error) {
|
|
242
|
-
throw new ManagementError({
|
|
243
|
-
...context,
|
|
244
|
-
kind: "client",
|
|
245
|
-
code: ManagementErrorCode.Credential,
|
|
246
|
-
uncertain: false,
|
|
247
|
-
message: "getToken returned a value that is not a token",
|
|
248
|
-
cause: error
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
} else if (options.getToken) {
|
|
252
|
-
headers.delete("Authorization");
|
|
253
|
-
}
|
|
254
|
-
if (options.organization) {
|
|
255
|
-
headers.set("X-Relay-Organization", options.organization);
|
|
256
|
-
}
|
|
257
|
-
if (options.project) {
|
|
258
|
-
headers.set("X-Relay-Project", options.project);
|
|
259
|
-
}
|
|
260
|
-
if (options.environment) {
|
|
261
|
-
headers.set("X-Relay-Environment", options.environment);
|
|
262
|
-
}
|
|
263
|
-
let response;
|
|
264
|
-
try {
|
|
265
|
-
response = await (options.fetch ?? fetch)(
|
|
266
|
-
`${options.baseUrl}/management/v1${path}`,
|
|
267
|
-
{
|
|
268
|
-
...fetchInit,
|
|
269
|
-
headers,
|
|
270
|
-
signal: life.signal,
|
|
271
|
-
...options.redirect ? { redirect: options.redirect } : {}
|
|
272
|
-
}
|
|
273
|
-
);
|
|
274
|
-
} catch (error) {
|
|
275
|
-
throw transportFailure(error, context, life, !unsent(error));
|
|
276
|
-
}
|
|
277
|
-
if (!response.ok) {
|
|
278
|
-
let text;
|
|
279
|
-
try {
|
|
280
|
-
text = await response.text();
|
|
281
|
-
} catch (error2) {
|
|
282
|
-
throw transportFailure(
|
|
283
|
-
error2,
|
|
284
|
-
context,
|
|
285
|
-
life,
|
|
286
|
-
true,
|
|
287
|
-
response.status,
|
|
288
|
-
true,
|
|
289
|
-
response.headers
|
|
290
|
-
);
|
|
291
|
-
}
|
|
292
|
-
let body = null;
|
|
293
|
-
try {
|
|
294
|
-
body = JSON.parse(text);
|
|
295
|
-
} catch {
|
|
296
|
-
}
|
|
297
|
-
const parsed = managementErrorSchema.safeParse(body);
|
|
298
|
-
const { error, code, ...details } = parsed.success ? parsed.data : { error: `Request failed (${response.status})`, code: void 0 };
|
|
299
|
-
throw new ManagementError({
|
|
300
|
-
...context,
|
|
301
|
-
kind: "http",
|
|
302
|
-
status: response.status,
|
|
303
|
-
message: error,
|
|
304
|
-
...code === void 0 ? {} : { code },
|
|
305
|
-
details,
|
|
306
|
-
retryAfter: retryAfter(response.headers)
|
|
307
|
-
});
|
|
308
|
-
}
|
|
309
|
-
return response;
|
|
310
|
-
}
|
|
311
|
-
async function raw(path, init) {
|
|
312
|
-
const { timeout, signal, ...fetchInit } = init ?? {};
|
|
313
|
-
const life = callLifetime({ timeout, signal: signal ?? void 0 });
|
|
314
|
-
try {
|
|
315
|
-
return await send(
|
|
316
|
-
path,
|
|
317
|
-
fetchInit,
|
|
318
|
-
{
|
|
319
|
-
method: (fetchInit.method ?? "GET").toUpperCase(),
|
|
320
|
-
path: path.split("?")[0],
|
|
321
|
-
replaySafe: false
|
|
322
|
-
},
|
|
323
|
-
life
|
|
324
|
-
);
|
|
325
|
-
} finally {
|
|
326
|
-
life.end();
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
async function exchange(path, schema, input, method, call, replaySafe, tolerant = false) {
|
|
330
|
-
const actionId = actionIdOf(input);
|
|
331
|
-
const context = {
|
|
332
|
-
method,
|
|
333
|
-
replaySafe,
|
|
334
|
-
path: path.split("?")[0],
|
|
335
|
-
...actionId ? { actionId } : {}
|
|
336
|
-
};
|
|
337
|
-
const fetchInit = {
|
|
338
|
-
method,
|
|
339
|
-
headers: tolerant ? { "X-Domino-Response": "tolerant-v1" } : void 0,
|
|
340
|
-
...input === void 0 ? {} : input instanceof ManagementUploadBody ? {
|
|
341
|
-
headers: {
|
|
342
|
-
"Content-Type": input.body.type,
|
|
343
|
-
...input.headers,
|
|
344
|
-
...tolerant ? { "X-Domino-Response": "tolerant-v1" } : {}
|
|
345
|
-
},
|
|
346
|
-
body: input.body
|
|
347
|
-
} : {
|
|
348
|
-
headers: {
|
|
349
|
-
"Content-Type": "application/json",
|
|
350
|
-
...tolerant ? { "X-Domino-Response": "tolerant-v1" } : {}
|
|
351
|
-
},
|
|
352
|
-
body: JSON.stringify(input)
|
|
353
|
-
}
|
|
354
|
-
};
|
|
355
|
-
const life = callLifetime(call);
|
|
356
|
-
try {
|
|
357
|
-
return await retrying(
|
|
358
|
-
life,
|
|
359
|
-
{ replaySafe: method === "GET" || replaySafe },
|
|
360
|
-
async () => {
|
|
361
|
-
const response = await send(path, fetchInit, context, life);
|
|
362
|
-
let body;
|
|
363
|
-
try {
|
|
364
|
-
body = response.status === 204 ? null : await response.json();
|
|
365
|
-
} catch (error) {
|
|
366
|
-
if (error instanceof SyntaxError && !life.signal.aborted) {
|
|
367
|
-
throw new ManagementError({
|
|
368
|
-
...context,
|
|
369
|
-
kind: "invalid-response",
|
|
370
|
-
code: ManagementErrorCode.InvalidResponse,
|
|
371
|
-
status: response.status,
|
|
372
|
-
message: "Domino answered with a body that is not JSON",
|
|
373
|
-
cause: error
|
|
374
|
-
});
|
|
375
|
-
}
|
|
376
|
-
throw transportFailure(
|
|
377
|
-
error,
|
|
378
|
-
context,
|
|
379
|
-
life,
|
|
380
|
-
true,
|
|
381
|
-
response.status,
|
|
382
|
-
false,
|
|
383
|
-
response.headers
|
|
384
|
-
);
|
|
385
|
-
}
|
|
386
|
-
const parsed = knownResponse(schema).safeParse(
|
|
387
|
-
tolerant ? { status: response.status, operationId: actionId, result: body } : body
|
|
388
|
-
);
|
|
389
|
-
if (!parsed.success) {
|
|
390
|
-
throw new ManagementError({
|
|
391
|
-
...context,
|
|
392
|
-
kind: "invalid-response",
|
|
393
|
-
code: ManagementErrorCode.InvalidResponse,
|
|
394
|
-
status: response.status,
|
|
395
|
-
message: "Domino answered with a response this client does not recognize",
|
|
396
|
-
cause: parsed.error
|
|
397
|
-
});
|
|
398
|
-
}
|
|
399
|
-
return parsed.data;
|
|
400
|
-
}
|
|
401
|
-
);
|
|
402
|
-
} finally {
|
|
403
|
-
life.end();
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
const json = ({
|
|
407
|
-
path,
|
|
408
|
-
method,
|
|
409
|
-
body,
|
|
410
|
-
replaySafe
|
|
411
|
-
}) => exchange(
|
|
412
|
-
path,
|
|
413
|
-
z2.unknown(),
|
|
414
|
-
body,
|
|
415
|
-
method,
|
|
416
|
-
void 0,
|
|
417
|
-
method === "GET" || replaySafe
|
|
418
|
-
);
|
|
419
|
-
return { raw, exchange, json };
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
// src/sequence-cursor.ts
|
|
423
|
-
import * as z3 from "zod";
|
|
424
|
-
var sequenceCursorSchema = z3.string().regex(/^[1-9][0-9]{0,15}$/, "Invalid cursor").transform(Number).pipe(z3.number().int().positive().safe());
|
|
425
|
-
|
|
426
|
-
// src/referral-reward-kinds.ts
|
|
427
|
-
var REFERRAL_INTEGRATION_REWARD_ERROR = "Referral programs can grant points and tiered rewards; Discord roles need a quest";
|
|
428
|
-
var isRecord = (value) => typeof value === "object" && value !== null;
|
|
429
|
-
function containsReferralIntegrationReward(value) {
|
|
430
|
-
if (Array.isArray(value)) {
|
|
431
|
-
return value.some(
|
|
432
|
-
(reward) => isRecord(reward) && reward.kind === "integration"
|
|
433
|
-
);
|
|
434
|
-
}
|
|
435
|
-
if (!isRecord(value)) {
|
|
436
|
-
return false;
|
|
437
|
-
}
|
|
438
|
-
const definition = isRecord(value.definition) ? value.definition : value;
|
|
439
|
-
return isRecord(definition.rewards) && (containsReferralIntegrationReward(definition.rewards.inviter) || containsReferralIntegrationReward(definition.rewards.invitee)) || Array.isArray(definition.milestones) && definition.milestones.some(
|
|
440
|
-
(milestone) => isRecord(milestone) && containsReferralIntegrationReward(milestone.rewards)
|
|
441
|
-
);
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
export {
|
|
445
|
-
questConfiguration,
|
|
446
|
-
ManagementErrorCode,
|
|
447
|
-
managementErrorSchema,
|
|
448
|
-
isManagementError,
|
|
449
|
-
ManagementError,
|
|
450
|
-
DEFAULT_MANAGEMENT_TIMEOUT,
|
|
451
|
-
ManagementUploadBody,
|
|
452
|
-
actionIdOf,
|
|
453
|
-
managementTransport,
|
|
454
|
-
sequenceCursorSchema,
|
|
455
|
-
REFERRAL_INTEGRATION_REWARD_ERROR,
|
|
456
|
-
containsReferralIntegrationReward
|
|
457
|
-
};
|