@relyio/sdk 0.18.0 → 0.20.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 +30 -0
- package/dist/automations/index.cjs +18 -17
- package/dist/automations/index.d.cts +2 -1307
- package/dist/automations/index.d.ts +2 -1307
- package/dist/automations/index.js +3 -2
- package/dist/{chunk-ZAMAR3X2.cjs → chunk-5F3YYPLZ.cjs} +11249 -10771
- package/dist/{chunk-ZO6QDYJG.cjs → chunk-5WGMIQBH.cjs} +2 -2
- package/dist/{chunk-LSI26ZN2.cjs → chunk-DBYMG6MQ.cjs} +5 -5
- package/dist/{chunk-W2A4OTCI.js → chunk-EQUZNVAR.js} +2 -2
- package/dist/{chunk-IFKF72VJ.cjs → chunk-K66MBRI4.cjs} +147 -71
- package/dist/{chunk-ZHTJ7GXH.js → chunk-L42C4G2S.js} +106 -31
- package/dist/{chunk-EDE2H37D.js → chunk-OUR7OUUZ.js} +174 -12
- package/dist/{chunk-W7JFHSFM.js → chunk-PZCDJFMA.js} +11249 -10772
- package/dist/{chunk-SHSK7UUY.cjs → chunk-UO2QRYKV.cjs} +177 -11
- package/dist/{chunk-R6E4HE7R.js → chunk-W2GRVXDG.js} +3 -3
- package/dist/client/index.cjs +5 -5
- package/dist/client/index.d.cts +4 -4
- package/dist/client/index.d.ts +4 -4
- package/dist/client/index.js +3 -3
- package/dist/{define-content-type-NEQDrvdq.d.cts → define-content-type-C2HnCYYX.d.cts} +1324 -156
- package/dist/{define-content-type-fb-WCD5e.d.ts → define-content-type-CVLUusfx.d.ts} +1324 -156
- package/dist/dev-handshake/index.cjs +8 -8
- package/dist/dev-handshake/index.d.cts +1 -1
- package/dist/dev-handshake/index.d.ts +1 -1
- package/dist/dev-handshake/index.js +1 -1
- package/dist/extensions/index.cjs +26 -6
- package/dist/extensions/index.d.cts +3 -791
- package/dist/extensions/index.d.ts +3 -791
- package/dist/extensions/index.js +24 -4
- package/dist/functions/index.cjs +7 -4
- package/dist/functions/index.d.cts +2 -4
- package/dist/functions/index.d.ts +2 -4
- package/dist/functions/index.js +5 -2
- package/dist/{index-DwHcL6x5.d.cts → index-BLVNMYUU.d.cts} +142 -79
- package/dist/{index-C4LqrNd1.d.ts → index-BY1xU93u.d.ts} +1 -1
- package/dist/{index-Dnmt_UOo.d.cts → index-Cmup6HJY.d.cts} +1 -1
- package/dist/index-D1fiaQlK.d.ts +2284 -0
- package/dist/index-DImzg3ew.d.cts +2284 -0
- package/dist/{index-M3luH06A.d.ts → index-IjSyBr8f.d.ts} +142 -79
- package/dist/index.cjs +89 -85
- package/dist/index.d.cts +64 -15
- package/dist/index.d.ts +64 -15
- package/dist/index.js +5 -5
- package/dist/preview/index.cjs +3 -3
- package/dist/preview/index.js +1 -1
- package/dist/rich-text/index.d.cts +2 -2
- package/dist/rich-text/index.d.ts +2 -2
- package/dist/schema/index.cjs +41 -40
- package/dist/schema/index.d.cts +948 -118
- package/dist/schema/index.d.ts +948 -118
- package/dist/schema/index.js +2 -1
- package/dist/types/index.d.cts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +5 -5
- package/dist/define-schema-DZhtvLiK.d.cts +0 -846
- package/dist/define-schema-Dlwh6l_J.d.ts +0 -846
- package/dist/register-B53i97A9.d.ts +0 -677
- package/dist/register-BYCs0FpF.d.cts +0 -677
|
@@ -85,5 +85,5 @@ exports.DEV_ENV = DEV_ENV;
|
|
|
85
85
|
exports.buildDevEnv = buildDevEnv;
|
|
86
86
|
exports.parseDevContextFile = parseDevContextFile;
|
|
87
87
|
exports.parseDevEnv = parseDevEnv;
|
|
88
|
-
//# sourceMappingURL=chunk-
|
|
89
|
-
//# sourceMappingURL=chunk-
|
|
88
|
+
//# sourceMappingURL=chunk-5WGMIQBH.cjs.map
|
|
89
|
+
//# sourceMappingURL=chunk-5WGMIQBH.cjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk5F3YYPLZ_cjs = require('./chunk-5F3YYPLZ.cjs');
|
|
4
4
|
var chunkL6DXCKVQ_cjs = require('./chunk-L6DXCKVQ.cjs');
|
|
5
5
|
|
|
6
6
|
/* RelyIO SDK - Built with ❤️ by the RelyIO Team */
|
|
@@ -30,7 +30,7 @@ function refAt(root, path, becomes) {
|
|
|
30
30
|
get(_target, key) {
|
|
31
31
|
if (key === REF) return { kind: "ref", root, path };
|
|
32
32
|
if (typeof key !== "string" || key === "then") return void 0;
|
|
33
|
-
if (TESTS.has(key)) return
|
|
33
|
+
if (TESTS.has(key)) return chunk5F3YYPLZ_cjs.conditionRoot(root, path)[key];
|
|
34
34
|
if (becomes && key === "becomes") {
|
|
35
35
|
return (value) => ({
|
|
36
36
|
root: "event",
|
|
@@ -362,7 +362,7 @@ var STEP_BUILDER = {
|
|
|
362
362
|
...config.agent === void 0 ? {} : { agent: config.agent },
|
|
363
363
|
instructions: valueOf(config.instructions, `${name}.instructions`),
|
|
364
364
|
context: inputOf(config.context ?? {}, `${name}.context`),
|
|
365
|
-
output:
|
|
365
|
+
output: chunk5F3YYPLZ_cjs.compileKeyedMembers(config.output),
|
|
366
366
|
...propose === void 0 ? {} : {
|
|
367
367
|
propose: propose.map(
|
|
368
368
|
(type, index) => proposeTargetOf(type, `${name}.propose[${index}]`)
|
|
@@ -531,5 +531,5 @@ exports.records = records;
|
|
|
531
531
|
exports.resolveAutomation = resolveAutomation;
|
|
532
532
|
exports.schedule = schedule;
|
|
533
533
|
exports.tpl = tpl;
|
|
534
|
-
//# sourceMappingURL=chunk-
|
|
535
|
-
//# sourceMappingURL=chunk-
|
|
534
|
+
//# sourceMappingURL=chunk-DBYMG6MQ.cjs.map
|
|
535
|
+
//# sourceMappingURL=chunk-DBYMG6MQ.cjs.map
|
|
@@ -77,5 +77,5 @@ function parseDevEnv(env, now) {
|
|
|
77
77
|
__name(parseDevEnv, "parseDevEnv");
|
|
78
78
|
|
|
79
79
|
export { DEV_CONTEXT_DIR, DEV_CONTEXT_FILE, DEV_CONTEXT_FILENAME, DEV_ENV, buildDevEnv, parseDevContextFile, parseDevEnv };
|
|
80
|
-
//# sourceMappingURL=chunk-
|
|
81
|
-
//# sourceMappingURL=chunk-
|
|
80
|
+
//# sourceMappingURL=chunk-EQUZNVAR.js.map
|
|
81
|
+
//# sourceMappingURL=chunk-EQUZNVAR.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkM7MWNV3Q_cjs = require('./chunk-M7MWNV3Q.cjs');
|
|
4
|
-
var
|
|
4
|
+
var chunk5WGMIQBH_cjs = require('./chunk-5WGMIQBH.cjs');
|
|
5
5
|
var chunk7I3SC7SV_cjs = require('./chunk-7I3SC7SV.cjs');
|
|
6
|
-
var
|
|
6
|
+
var chunkUO2QRYKV_cjs = require('./chunk-UO2QRYKV.cjs');
|
|
7
7
|
var chunkL6DXCKVQ_cjs = require('./chunk-L6DXCKVQ.cjs');
|
|
8
8
|
|
|
9
9
|
/* RelyIO SDK - Built with ❤️ by the RelyIO Team */
|
|
@@ -171,13 +171,13 @@ var _ReadOnlyKeyError = class _ReadOnlyKeyError extends SDKError {
|
|
|
171
171
|
chunkL6DXCKVQ_cjs.__name(_ReadOnlyKeyError, "ReadOnlyKeyError");
|
|
172
172
|
var ReadOnlyKeyError = _ReadOnlyKeyError;
|
|
173
173
|
var _PublishableKeyRefusedError = class _PublishableKeyRefusedError extends SDKError {
|
|
174
|
-
constructor(message = "A publishable key
|
|
174
|
+
constructor(message = "A publishable key writes a Record only for a signed-in End user", context) {
|
|
175
175
|
super(message, 403, void 0, context);
|
|
176
176
|
chunkL6DXCKVQ_cjs.__publicField(this, "code", "PUBLISHABLE_KEY_REFUSED");
|
|
177
177
|
chunkL6DXCKVQ_cjs.__publicField(this, "retryable", false);
|
|
178
178
|
}
|
|
179
179
|
getUserMessage() {
|
|
180
|
-
return "A publishable key
|
|
180
|
+
return "A publishable key writes a Record only with a signed-in End user's token, and runs only a Function declaring endUsers. Send the End user's token, declare endUsers on the Function, or call it from your server with a secret key.";
|
|
181
181
|
}
|
|
182
182
|
};
|
|
183
183
|
chunkL6DXCKVQ_cjs.__name(_PublishableKeyRefusedError, "PublishableKeyRefusedError");
|
|
@@ -394,6 +394,19 @@ var _InvalidApiKeyError = class _InvalidApiKeyError extends SDKError {
|
|
|
394
394
|
};
|
|
395
395
|
chunkL6DXCKVQ_cjs.__name(_InvalidApiKeyError, "InvalidApiKeyError");
|
|
396
396
|
var InvalidApiKeyError = _InvalidApiKeyError;
|
|
397
|
+
var _EndUserTokenInvalidError = class _EndUserTokenInvalidError extends SDKError {
|
|
398
|
+
constructor(message, reason, context) {
|
|
399
|
+
super(message, 401, void 0, context);
|
|
400
|
+
this.reason = reason;
|
|
401
|
+
chunkL6DXCKVQ_cjs.__publicField(this, "code", "END_USER_TOKEN_INVALID");
|
|
402
|
+
chunkL6DXCKVQ_cjs.__publicField(this, "retryable", false);
|
|
403
|
+
}
|
|
404
|
+
getUserMessage() {
|
|
405
|
+
return "Your session is not valid. Please sign in again.";
|
|
406
|
+
}
|
|
407
|
+
};
|
|
408
|
+
chunkL6DXCKVQ_cjs.__name(_EndUserTokenInvalidError, "EndUserTokenInvalidError");
|
|
409
|
+
var EndUserTokenInvalidError = _EndUserTokenInvalidError;
|
|
397
410
|
|
|
398
411
|
// src/errors/network-errors.ts
|
|
399
412
|
var _NetworkError = class _NetworkError extends SDKError {
|
|
@@ -581,7 +594,7 @@ var _ErrorMapper = class _ErrorMapper {
|
|
|
581
594
|
return new NetworkError(`HTTP ${status}: ${statusText}`.trim(), status, void 0, context);
|
|
582
595
|
}
|
|
583
596
|
const retryAfterMs = parseRetryAfterMs(
|
|
584
|
-
headerValue(headers,
|
|
597
|
+
headerValue(headers, chunkUO2QRYKV_cjs.HEADER_RETRY_AFTER.name),
|
|
585
598
|
Date.now()
|
|
586
599
|
);
|
|
587
600
|
return this.fromContractCode(refusal, status, context, retryAfterMs);
|
|
@@ -595,6 +608,9 @@ var _ErrorMapper = class _ErrorMapper {
|
|
|
595
608
|
case "INVALID_API_KEY": {
|
|
596
609
|
return new InvalidApiKeyError(message, void 0, context);
|
|
597
610
|
}
|
|
611
|
+
case "END_USER_TOKEN_INVALID": {
|
|
612
|
+
return new EndUserTokenInvalidError(message, endUserTokenReasonOf(refusal), context);
|
|
613
|
+
}
|
|
598
614
|
case "ACCESS_DENIED": {
|
|
599
615
|
return new AuthorizationError(message, 403, void 0, context);
|
|
600
616
|
}
|
|
@@ -802,6 +818,15 @@ function violationsOf(refusal) {
|
|
|
802
818
|
}));
|
|
803
819
|
}
|
|
804
820
|
chunkL6DXCKVQ_cjs.__name(violationsOf, "violationsOf");
|
|
821
|
+
function endUserTokenReasonOf(refusal) {
|
|
822
|
+
const reason = detailString(refusal, "reason");
|
|
823
|
+
return isEndUserTokenReason(reason) ? reason : void 0;
|
|
824
|
+
}
|
|
825
|
+
chunkL6DXCKVQ_cjs.__name(endUserTokenReasonOf, "endUserTokenReasonOf");
|
|
826
|
+
function isEndUserTokenReason(value) {
|
|
827
|
+
return value !== void 0 && chunkUO2QRYKV_cjs.END_USER_TOKEN_REFUSAL_REASONS.includes(value);
|
|
828
|
+
}
|
|
829
|
+
chunkL6DXCKVQ_cjs.__name(isEndUserTokenReason, "isEndUserTokenReason");
|
|
805
830
|
|
|
806
831
|
// src/http/api-routes.ts
|
|
807
832
|
function fillPath(template, params) {
|
|
@@ -977,7 +1002,7 @@ var IDEMPOTENT_METHODS = /* @__PURE__ */ new Set([
|
|
|
977
1002
|
]);
|
|
978
1003
|
function isReplaySafe(request) {
|
|
979
1004
|
if (IDEMPOTENT_METHODS.has(request.method.toUpperCase())) return true;
|
|
980
|
-
return headerValue(request.headers,
|
|
1005
|
+
return headerValue(request.headers, chunkUO2QRYKV_cjs.HEADER_IDEMPOTENCY_KEY.name) !== void 0;
|
|
981
1006
|
}
|
|
982
1007
|
chunkL6DXCKVQ_cjs.__name(isReplaySafe, "isReplaySafe");
|
|
983
1008
|
var UNREACHABLE_CODES = /* @__PURE__ */ new Set(["ECONNREFUSED", "ENOTFOUND"]);
|
|
@@ -1174,22 +1199,33 @@ var _HttpClient = class _HttpClient {
|
|
|
1174
1199
|
* constructor accepts one so that a module-scope client can be evaluated by a
|
|
1175
1200
|
* build that holds no key (REL-1120) — and so does one whose `setApiKey` was
|
|
1176
1201
|
* given none.
|
|
1202
|
+
*
|
|
1203
|
+
* The End user's token is asked for once, after the key is known to be there and before the first
|
|
1204
|
+
* attempt — of `getToken`, the nearest view's function, or the configuration's — so every retry
|
|
1205
|
+
* of one call sends the token its first attempt sent. See `RelyIOConfig.getToken`.
|
|
1177
1206
|
*/
|
|
1178
|
-
async request(config) {
|
|
1207
|
+
async request(config, getToken) {
|
|
1179
1208
|
if (this.view !== void 0) {
|
|
1180
|
-
return this.view.client.request(
|
|
1181
|
-
...config,
|
|
1182
|
-
|
|
1183
|
-
|
|
1209
|
+
return this.view.client.request(
|
|
1210
|
+
{ ...config, headers: layerHeaders(this.view.headers, config.headers) },
|
|
1211
|
+
getToken ?? this.view.getToken
|
|
1212
|
+
);
|
|
1184
1213
|
}
|
|
1185
1214
|
if (config.timeout !== void 0) assertRequestTimeout(config.timeout);
|
|
1186
1215
|
const mergedConfig = this.mergeRequestConfig(config);
|
|
1187
|
-
if (
|
|
1216
|
+
if (presentCredential(headerValue(mergedConfig.headers, API_KEY_HEADER)) === void 0) {
|
|
1188
1217
|
throw new MissingApiKeyError(
|
|
1189
1218
|
"`apiKey` is missing: this client holds no API key, so the request was not sent. Pass `apiKey` to createClient \u2014 the documented setup reads it from RELYIO_API_KEY.",
|
|
1190
1219
|
{ url: mergedConfig.url, method: mergedConfig.method, sent: false }
|
|
1191
1220
|
);
|
|
1192
1221
|
}
|
|
1222
|
+
const tokenSource = getToken ?? this.connection.config.getToken;
|
|
1223
|
+
if (tokenSource !== void 0) {
|
|
1224
|
+
const token = presentCredential(await tokenSource());
|
|
1225
|
+
mergedConfig.headers = layerHeaders(mergedConfig.headers ?? {}, {
|
|
1226
|
+
[END_USER_HEADER]: token ?? null
|
|
1227
|
+
});
|
|
1228
|
+
}
|
|
1193
1229
|
this.log("debug", "Making request", {
|
|
1194
1230
|
method: mergedConfig.method,
|
|
1195
1231
|
url: mergedConfig.url
|
|
@@ -1233,7 +1269,7 @@ var _HttpClient = class _HttpClient {
|
|
|
1233
1269
|
});
|
|
1234
1270
|
if (preview !== void 0 && answersUnknownDataset(sdkError, preview)) {
|
|
1235
1271
|
rememberUnknownPreview(preview);
|
|
1236
|
-
return this.request(config);
|
|
1272
|
+
return this.request(config, getToken);
|
|
1237
1273
|
}
|
|
1238
1274
|
this.log("error", "Request failed after all retries", {
|
|
1239
1275
|
error: sdkError.toJSON(),
|
|
@@ -1454,10 +1490,17 @@ var _ControlledHttpClient = class _ControlledHttpClient extends HttpClient {
|
|
|
1454
1490
|
* retries and `fetch` are this client's as they are when each request is sent, so a later
|
|
1455
1491
|
* `configure()` or `setApiKey()` on this client reaches the view, and one on the view reaches
|
|
1456
1492
|
* this client. `client.with({ dataset })` is one (REL-2417).
|
|
1493
|
+
*
|
|
1494
|
+
* `options.getToken` is the End user's token function the view asks in place of this client's,
|
|
1495
|
+
* and of any view it is made from: `client.with({ getToken })` (REL-3882).
|
|
1457
1496
|
*/
|
|
1458
|
-
withHeaders(headers) {
|
|
1497
|
+
withHeaders(headers, options = {}) {
|
|
1459
1498
|
const view = new _ControlledHttpClient(this.connection.config);
|
|
1460
|
-
view.view = {
|
|
1499
|
+
view.view = {
|
|
1500
|
+
client: this,
|
|
1501
|
+
headers: { ...headers },
|
|
1502
|
+
...options.getToken === void 0 ? {} : { getToken: options.getToken }
|
|
1503
|
+
};
|
|
1461
1504
|
return view;
|
|
1462
1505
|
}
|
|
1463
1506
|
/**
|
|
@@ -1479,7 +1522,7 @@ var _ControlledHttpClient = class _ControlledHttpClient extends HttpClient {
|
|
|
1479
1522
|
* Replace the key every later request sends as `X-API-Key`, and the `apiKey` the configuration
|
|
1480
1523
|
* reports.
|
|
1481
1524
|
*
|
|
1482
|
-
* The key is read the way construction reads it (`
|
|
1525
|
+
* The key is read the way construction reads it (`presentCredential`): an absent, empty or blank key is
|
|
1483
1526
|
* no key, so the header is dropped and the next request is refused with `MissingApiKeyError`
|
|
1484
1527
|
* before anything is sent. A key header of any other spelling — one given in `headers` — goes
|
|
1485
1528
|
* too, from the headers sent and from the headers the configuration reports, so the old key is
|
|
@@ -1500,7 +1543,7 @@ var _ControlledHttpClient = class _ControlledHttpClient extends HttpClient {
|
|
|
1500
1543
|
this.connection = {
|
|
1501
1544
|
...this.connection,
|
|
1502
1545
|
defaultHeaders: layerHeaders(this.connection.defaultHeaders, {
|
|
1503
|
-
[API_KEY_HEADER]:
|
|
1546
|
+
[API_KEY_HEADER]: presentCredential(apiKey) ?? null
|
|
1504
1547
|
})
|
|
1505
1548
|
};
|
|
1506
1549
|
}
|
|
@@ -1509,6 +1552,7 @@ chunkL6DXCKVQ_cjs.__name(_ControlledHttpClient, "ControlledHttpClient");
|
|
|
1509
1552
|
var ControlledHttpClient = _ControlledHttpClient;
|
|
1510
1553
|
var API_KEY_HEADER = "X-API-Key";
|
|
1511
1554
|
var DATASET_HEADER = "X-RelyIO-Dataset";
|
|
1555
|
+
var END_USER_HEADER = chunkUO2QRYKV_cjs.HEADER_END_USER.name;
|
|
1512
1556
|
function derivedPreviewIn(headers) {
|
|
1513
1557
|
const dataset = headerValue(headers, DATASET_HEADER);
|
|
1514
1558
|
return dataset !== void 0 && isDerivedPreview(dataset) ? dataset : void 0;
|
|
@@ -1527,7 +1571,7 @@ function connectionFor(config) {
|
|
|
1527
1571
|
const defaultHeaders = layerHeaders(
|
|
1528
1572
|
layerHeaders({ "Content-Type": "application/json" }, config.headers),
|
|
1529
1573
|
{
|
|
1530
|
-
[API_KEY_HEADER]:
|
|
1574
|
+
[API_KEY_HEADER]: presentCredential(config.apiKey),
|
|
1531
1575
|
[DATASET_HEADER]: config.dataset,
|
|
1532
1576
|
// Only outside a browser, which controls this header. "A browser" is the core's one
|
|
1533
1577
|
// definition, `isBrowser()` — every environment question in this file asks it.
|
|
@@ -1559,10 +1603,10 @@ function layerHeaders(base, over) {
|
|
|
1559
1603
|
return layered;
|
|
1560
1604
|
}
|
|
1561
1605
|
chunkL6DXCKVQ_cjs.__name(layerHeaders, "layerHeaders");
|
|
1562
|
-
function
|
|
1606
|
+
function presentCredential(value) {
|
|
1563
1607
|
return typeof value === "string" && value.trim() !== "" ? value : void 0;
|
|
1564
1608
|
}
|
|
1565
|
-
chunkL6DXCKVQ_cjs.__name(
|
|
1609
|
+
chunkL6DXCKVQ_cjs.__name(presentCredential, "presentCredential");
|
|
1566
1610
|
function credentialsModeFor(includeCredentials) {
|
|
1567
1611
|
return includeCredentials ? "include" : "same-origin";
|
|
1568
1612
|
}
|
|
@@ -1571,7 +1615,7 @@ chunkL6DXCKVQ_cjs.__name(credentialsModeFor, "credentialsModeFor");
|
|
|
1571
1615
|
// src/http/write-options.ts
|
|
1572
1616
|
function versionCheckOf(entry) {
|
|
1573
1617
|
const { id, locale, version, sharedVersion } = entry._metadata;
|
|
1574
|
-
return { id, locale, ifMatch:
|
|
1618
|
+
return { id, locale, ifMatch: chunkUO2QRYKV_cjs.entityTag({ entryUid: id, locale, version, sharedVersion }) };
|
|
1575
1619
|
}
|
|
1576
1620
|
chunkL6DXCKVQ_cjs.__name(versionCheckOf, "versionCheckOf");
|
|
1577
1621
|
function mintIdempotencyKey() {
|
|
@@ -1583,11 +1627,11 @@ chunkL6DXCKVQ_cjs.__name(mintIdempotencyKey, "mintIdempotencyKey");
|
|
|
1583
1627
|
function writeHeaders(options) {
|
|
1584
1628
|
const headers = {};
|
|
1585
1629
|
if (options?.ifMatch !== void 0) {
|
|
1586
|
-
headers[
|
|
1630
|
+
headers[chunkUO2QRYKV_cjs.HEADER_IF_MATCH.name] = options.ifMatch;
|
|
1587
1631
|
}
|
|
1588
1632
|
const idempotencyKey = options?.idempotencyKey ?? mintIdempotencyKey();
|
|
1589
1633
|
if (idempotencyKey !== void 0) {
|
|
1590
|
-
headers[
|
|
1634
|
+
headers[chunkUO2QRYKV_cjs.HEADER_IDEMPOTENCY_KEY.name] = idempotencyKey;
|
|
1591
1635
|
}
|
|
1592
1636
|
return Object.keys(headers).length > 0 ? headers : void 0;
|
|
1593
1637
|
}
|
|
@@ -1684,7 +1728,7 @@ function writeDocumentTerms(query, options, clientLocale) {
|
|
|
1684
1728
|
query.include = options.include.join(",");
|
|
1685
1729
|
}
|
|
1686
1730
|
writeLocale(query, options.locale ?? clientLocale);
|
|
1687
|
-
if (typeof options.fresh === "string") query[
|
|
1731
|
+
if (typeof options.fresh === "string") query[chunkUO2QRYKV_cjs.FRESH_PARAMETER] = options.fresh;
|
|
1688
1732
|
}
|
|
1689
1733
|
chunkL6DXCKVQ_cjs.__name(writeDocumentTerms, "writeDocumentTerms");
|
|
1690
1734
|
function writeLocale(query, locale) {
|
|
@@ -1974,6 +2018,18 @@ var _ContentClient = class _ContentClient extends EntryHandle {
|
|
|
1974
2018
|
chunkL6DXCKVQ_cjs.__name(_ContentClient, "ContentClient");
|
|
1975
2019
|
var ContentClient = _ContentClient;
|
|
1976
2020
|
|
|
2021
|
+
// src/errors/mime-matches.ts
|
|
2022
|
+
function mimeMatches(fileType, pattern) {
|
|
2023
|
+
const actual = (fileType.split(";")[0] ?? "").trim().toLowerCase();
|
|
2024
|
+
const allowed = (pattern.split(";")[0] ?? "").trim().toLowerCase();
|
|
2025
|
+
if (allowed === "*" || allowed === "*/*") return true;
|
|
2026
|
+
if (allowed === actual) return true;
|
|
2027
|
+
const [allowedType, allowedSubtype] = allowed.split("/");
|
|
2028
|
+
const [actualType] = actual.split("/");
|
|
2029
|
+
return allowedSubtype === "*" && allowedType === actualType;
|
|
2030
|
+
}
|
|
2031
|
+
chunkL6DXCKVQ_cjs.__name(mimeMatches, "mimeMatches");
|
|
2032
|
+
|
|
1977
2033
|
// src/errors/file-errors.ts
|
|
1978
2034
|
var _FileUploadError = class _FileUploadError extends SDKError {
|
|
1979
2035
|
constructor(code, message, options = {}) {
|
|
@@ -2004,12 +2060,13 @@ var FileValidationError = _FileValidationError;
|
|
|
2004
2060
|
function validateFile(file, constraints = {}) {
|
|
2005
2061
|
const violations = [];
|
|
2006
2062
|
const { allowedMimeTypes, maxSizeBytes } = constraints;
|
|
2007
|
-
|
|
2063
|
+
const { type } = file;
|
|
2064
|
+
if (allowedMimeTypes && allowedMimeTypes.length > 0 && type != null && type !== "" && !allowedMimeTypes.some((pattern) => mimeMatches(type, pattern))) {
|
|
2008
2065
|
violations.push({
|
|
2009
2066
|
field: "file",
|
|
2010
2067
|
code: "UNSUPPORTED_MIME",
|
|
2011
|
-
message: `Unsupported file type "${
|
|
2012
|
-
value:
|
|
2068
|
+
message: `Unsupported file type "${type}". Allowed: ${allowedMimeTypes.join(", ")}`,
|
|
2069
|
+
value: type
|
|
2013
2070
|
});
|
|
2014
2071
|
}
|
|
2015
2072
|
if (typeof maxSizeBytes === "number" && maxSizeBytes > 0 && typeof file.size === "number" && file.size > maxSizeBytes) {
|
|
@@ -2878,7 +2935,8 @@ var _RecordsClient = class _RecordsClient {
|
|
|
2878
2935
|
* Store a Record, live the moment it lands. Values that break the Record type's fields are
|
|
2879
2936
|
* refused with `ValidationError` naming each field, and nothing is stored. Values a unique set of
|
|
2880
2937
|
* the type claims, held by another Record, are refused with `ResourceConflictError` — its
|
|
2881
|
-
* `blockage` is `{ kind: 'value-taken', facts: { fields, recordId } }` (REL-3782)
|
|
2938
|
+
* `blockage` is `{ kind: 'value-taken', facts: { fields, recordId } }` (REL-3782) — with no
|
|
2939
|
+
* `recordId` for an End user's write, whose read Policy may hide the holder (REL-3863).
|
|
2882
2940
|
*/
|
|
2883
2941
|
async create(fields, options = {}) {
|
|
2884
2942
|
return this.httpClient.fetchPayload(
|
|
@@ -3272,7 +3330,7 @@ chunkL6DXCKVQ_cjs.__name(originOf, "originOf");
|
|
|
3272
3330
|
|
|
3273
3331
|
// src/changes/live-edge.ts
|
|
3274
3332
|
var LIVE_KEEPALIVE_INTERVAL_MS = 3e4;
|
|
3275
|
-
var LIVE_SOCKET_OPEN_TIMEOUT_MS =
|
|
3333
|
+
var LIVE_SOCKET_OPEN_TIMEOUT_MS = chunkUO2QRYKV_cjs.VISITOR_POLL_INTERVAL_MS;
|
|
3276
3334
|
var LIVE_POLLS_BEFORE_SOCKET = 4;
|
|
3277
3335
|
async function* subscribeLiveEdge(client, options = {}) {
|
|
3278
3336
|
const { signal } = options;
|
|
@@ -3342,12 +3400,12 @@ async function* followSocket(socket, reach, options) {
|
|
|
3342
3400
|
return "unopened";
|
|
3343
3401
|
}
|
|
3344
3402
|
case "message": {
|
|
3345
|
-
if (event.data ===
|
|
3346
|
-
const frame = typeof event.data === "string" ?
|
|
3403
|
+
if (event.data === chunkUO2QRYKV_cjs.VISITOR_KEEPALIVE.response) continue;
|
|
3404
|
+
const frame = typeof event.data === "string" ? chunkUO2QRYKV_cjs.parseVisitorFrame(event.data) : null;
|
|
3347
3405
|
if (frame === null)
|
|
3348
3406
|
throw unreadable(`a frame the wire does not declare: ${sample(event.data)}`);
|
|
3349
3407
|
switch (frame.type) {
|
|
3350
|
-
case
|
|
3408
|
+
case chunkUO2QRYKV_cjs.VISITOR_FRAMES.opened: {
|
|
3351
3409
|
caughtUp = true;
|
|
3352
3410
|
inbox.caughtUp();
|
|
3353
3411
|
reach.position = frame.cursor;
|
|
@@ -3355,7 +3413,7 @@ async function* followSocket(socket, reach, options) {
|
|
|
3355
3413
|
options.reached?.(frame.cursor);
|
|
3356
3414
|
continue;
|
|
3357
3415
|
}
|
|
3358
|
-
case
|
|
3416
|
+
case chunkUO2QRYKV_cjs.VISITOR_FRAMES.changes: {
|
|
3359
3417
|
const prior = reach.position;
|
|
3360
3418
|
if (prior === void 0) throw unreadable("changes before the socket had a position");
|
|
3361
3419
|
for (const change of changesOf(frame.changes, frame.cursor, prior)) {
|
|
@@ -3366,7 +3424,7 @@ async function* followSocket(socket, reach, options) {
|
|
|
3366
3424
|
if (frame.changes.length === 0) options.reached?.(frame.cursor);
|
|
3367
3425
|
continue;
|
|
3368
3426
|
}
|
|
3369
|
-
case
|
|
3427
|
+
case chunkUO2QRYKV_cjs.VISITOR_FRAMES.resync: {
|
|
3370
3428
|
await expire(frame.reason, frame.cursor, options);
|
|
3371
3429
|
if (isAborted(signal)) return "aborted";
|
|
3372
3430
|
reach.position = frame.cursor;
|
|
@@ -3438,7 +3496,7 @@ function socketInbox(socket, signal) {
|
|
|
3438
3496
|
return;
|
|
3439
3497
|
}
|
|
3440
3498
|
heard = false;
|
|
3441
|
-
if (socket.readyState === SOCKET_OPEN) socket.send(
|
|
3499
|
+
if (socket.readyState === SOCKET_OPEN) socket.send(chunkUO2QRYKV_cjs.VISITOR_KEEPALIVE.request);
|
|
3442
3500
|
}, LIVE_KEEPALIVE_INTERVAL_MS);
|
|
3443
3501
|
},
|
|
3444
3502
|
caughtUp() {
|
|
@@ -3474,19 +3532,19 @@ var AFTER_A_CLOSE = {
|
|
|
3474
3532
|
"back-off": "Retrying after a back-off of at least a minute, without polling, which the same admission refuses."
|
|
3475
3533
|
};
|
|
3476
3534
|
function closeRetryOf(code) {
|
|
3477
|
-
if (hasOwn(
|
|
3535
|
+
if (hasOwn(chunkUO2QRYKV_cjs.VISITOR_CLOSE_RETRY, code)) return chunkUO2QRYKV_cjs.VISITOR_CLOSE_RETRY[code];
|
|
3478
3536
|
return code < 4e3 ? "retry" : "stop";
|
|
3479
3537
|
}
|
|
3480
3538
|
chunkL6DXCKVQ_cjs.__name(closeRetryOf, "closeRetryOf");
|
|
3481
3539
|
var CLOSE_MEANING = {
|
|
3482
|
-
[
|
|
3483
|
-
[
|
|
3484
|
-
[
|
|
3485
|
-
[
|
|
3486
|
-
[
|
|
3487
|
-
[
|
|
3488
|
-
[
|
|
3489
|
-
[
|
|
3540
|
+
[chunkUO2QRYKV_cjs.VISITOR_CLOSE_CODES.requestInvalid]: "the edge could not read the request \u2014 a malformed cursor or filter",
|
|
3541
|
+
[chunkUO2QRYKV_cjs.VISITOR_CLOSE_CODES.keyRefused]: "the key is not a publishable key the edge accepts \u2014 unknown, revoked or expired",
|
|
3542
|
+
[chunkUO2QRYKV_cjs.VISITOR_CLOSE_CODES.originRefused]: "this page\u2019s origin is not on the publishable key\u2019s allowed origins",
|
|
3543
|
+
[chunkUO2QRYKV_cjs.VISITOR_CLOSE_CODES.datasetRefused]: "`dataset` names no dataset the key reaches",
|
|
3544
|
+
[chunkUO2QRYKV_cjs.VISITOR_CLOSE_CODES.unavailable]: "the edge could not serve this connection just now \u2014 it could not reach what it needed",
|
|
3545
|
+
[chunkUO2QRYKV_cjs.VISITOR_CLOSE_CODES.allowanceReached]: "the project holds as many live connections as its plan allows",
|
|
3546
|
+
[chunkUO2QRYKV_cjs.VISITOR_CLOSE_CODES.addressLimitReached]: "this address holds as many live connections to the project as one address may",
|
|
3547
|
+
[chunkUO2QRYKV_cjs.VISITOR_CLOSE_CODES.ceilingReached]: "the project is at its safety ceiling of live connections"
|
|
3490
3548
|
};
|
|
3491
3549
|
async function* followPolls(client, request, reach, options) {
|
|
3492
3550
|
const { signal } = options;
|
|
@@ -3514,7 +3572,7 @@ async function* followPolls(client, request, reach, options) {
|
|
|
3514
3572
|
if (starting) options.reached?.(answer.cursor);
|
|
3515
3573
|
}
|
|
3516
3574
|
starting = false;
|
|
3517
|
-
await sleep(
|
|
3575
|
+
await sleep(chunkUO2QRYKV_cjs.VISITOR_POLL_INTERVAL_MS, signal);
|
|
3518
3576
|
}
|
|
3519
3577
|
return isAborted(signal) ? "aborted" : "socket";
|
|
3520
3578
|
}
|
|
@@ -3556,7 +3614,7 @@ async function pollOnce2(client, request, since, signal) {
|
|
|
3556
3614
|
}
|
|
3557
3615
|
const body = parseJson(text);
|
|
3558
3616
|
if (!response.ok) throw refusedPoll(response, body, context);
|
|
3559
|
-
const answer =
|
|
3617
|
+
const answer = chunkUO2QRYKV_cjs.readVisitorPollAnswer(isRecord(body) ? body["data"] : void 0);
|
|
3560
3618
|
if (answer === null)
|
|
3561
3619
|
throw unreadable(`a poll answer the wire does not declare: ${sample(text)}`);
|
|
3562
3620
|
return answer;
|
|
@@ -3576,13 +3634,13 @@ function refusedPoll(response, body, context) {
|
|
|
3576
3634
|
{ ...context, method: "GET" }
|
|
3577
3635
|
);
|
|
3578
3636
|
const refusal = readError(body);
|
|
3579
|
-
if (refusal === void 0 || !hasOwn(
|
|
3637
|
+
if (refusal === void 0 || !hasOwn(chunkUO2QRYKV_cjs.VISITOR_POLL_RETRY, refusal.code)) return mapped;
|
|
3580
3638
|
const code = refusal.code;
|
|
3581
3639
|
const retryAfterMs = parseRetryAfterMs(headerValue(headers, "Retry-After"), Date.now());
|
|
3582
3640
|
return new LiveEdgeError(
|
|
3583
3641
|
`The live edge refused a poll (${code}): ${refusal.messages[0] ?? mapped.message}`,
|
|
3584
3642
|
{ kind: "refused", code },
|
|
3585
|
-
|
|
3643
|
+
chunkUO2QRYKV_cjs.VISITOR_POLL_RETRY[code],
|
|
3586
3644
|
{
|
|
3587
3645
|
statusCode: response.status,
|
|
3588
3646
|
cause: mapped,
|
|
@@ -3610,17 +3668,17 @@ function edgeRequest(client, filter) {
|
|
|
3610
3668
|
chunkL6DXCKVQ_cjs.__name(edgeRequest, "edgeRequest");
|
|
3611
3669
|
function edgeUrl(request, since, transport, clientId) {
|
|
3612
3670
|
const url = new URL(request.base.href);
|
|
3613
|
-
url.pathname = `${url.pathname.replace(/\/+$/, "")}${
|
|
3671
|
+
url.pathname = `${url.pathname.replace(/\/+$/, "")}${chunkUO2QRYKV_cjs.VISITOR_LIVE_PATH}`;
|
|
3614
3672
|
if (transport === "socket") url.protocol = url.protocol === "http:" ? "ws:" : "wss:";
|
|
3615
3673
|
const query = new URLSearchParams();
|
|
3616
|
-
if (request.key !== void 0) query.set(
|
|
3674
|
+
if (request.key !== void 0) query.set(chunkUO2QRYKV_cjs.VISITOR_QUERY.key, request.key);
|
|
3617
3675
|
if (request.dataset !== void 0 && request.dataset !== "") {
|
|
3618
|
-
query.set(
|
|
3676
|
+
query.set(chunkUO2QRYKV_cjs.VISITOR_QUERY.dataset, request.dataset);
|
|
3619
3677
|
}
|
|
3620
|
-
if (since !== void 0) query.set(
|
|
3621
|
-
if (request.types !== void 0) query.set(
|
|
3622
|
-
if (request.ids !== void 0) query.set(
|
|
3623
|
-
if (transport === "poll" && clientId !== void 0) query.set(
|
|
3678
|
+
if (since !== void 0) query.set(chunkUO2QRYKV_cjs.VISITOR_QUERY.since, since);
|
|
3679
|
+
if (request.types !== void 0) query.set(chunkUO2QRYKV_cjs.VISITOR_QUERY.types, request.types.join(","));
|
|
3680
|
+
if (request.ids !== void 0) query.set(chunkUO2QRYKV_cjs.VISITOR_QUERY.ids, request.ids.join(","));
|
|
3681
|
+
if (transport === "poll" && clientId !== void 0) query.set(chunkUO2QRYKV_cjs.VISITOR_QUERY.client, clientId);
|
|
3624
3682
|
url.search = query.toString();
|
|
3625
3683
|
return url.href;
|
|
3626
3684
|
}
|
|
@@ -3683,7 +3741,7 @@ async function callFunction(http, name, input, options) {
|
|
|
3683
3741
|
body: { input },
|
|
3684
3742
|
headers: {
|
|
3685
3743
|
...readHeaders({ dataset: options.dataset }),
|
|
3686
|
-
...options.idempotencyKey === void 0 ? {} : { [
|
|
3744
|
+
...options.idempotencyKey === void 0 ? {} : { [chunkUO2QRYKV_cjs.HEADER_IDEMPOTENCY_KEY.name]: options.idempotencyKey }
|
|
3687
3745
|
},
|
|
3688
3746
|
timeout: options.timeout ?? FUNCTION_CALL_TIMEOUT_MS,
|
|
3689
3747
|
...signalOf(options)
|
|
@@ -3733,7 +3791,7 @@ function transportOf(options) {
|
|
|
3733
3791
|
return {
|
|
3734
3792
|
...signalOf(options),
|
|
3735
3793
|
...headers === void 0 ? {} : { headers },
|
|
3736
|
-
...typeof options.fresh === "string" ? { query: { [
|
|
3794
|
+
...typeof options.fresh === "string" ? { query: { [chunkUO2QRYKV_cjs.FRESH_PARAMETER]: options.fresh } } : {}
|
|
3737
3795
|
};
|
|
3738
3796
|
}
|
|
3739
3797
|
chunkL6DXCKVQ_cjs.__name(transportOf, "transportOf");
|
|
@@ -3914,7 +3972,7 @@ async function runAdhocQuery(http, query, clientLocale) {
|
|
|
3914
3972
|
const terms = {};
|
|
3915
3973
|
if (query.cursor !== void 0) terms.cursor = query.cursor;
|
|
3916
3974
|
writeLocale(terms, query.locale ?? clientLocale);
|
|
3917
|
-
if (typeof query.fresh === "string") terms[
|
|
3975
|
+
if (typeof query.fresh === "string") terms[chunkUO2QRYKV_cjs.FRESH_PARAMETER] = query.fresh;
|
|
3918
3976
|
const parameters = { ...query.params };
|
|
3919
3977
|
const body = {
|
|
3920
3978
|
query: {
|
|
@@ -3949,7 +4007,7 @@ async function runNamedQuery(http, name, options, clientLocale) {
|
|
|
3949
4007
|
const locale = options.locale ?? clientLocale;
|
|
3950
4008
|
const terms = {};
|
|
3951
4009
|
if (locale !== void 0 && locale !== "") terms.locale = locale;
|
|
3952
|
-
if (typeof options.fresh === "string") terms[
|
|
4010
|
+
if (typeof options.fresh === "string") terms[chunkUO2QRYKV_cjs.FRESH_PARAMETER] = options.fresh;
|
|
3953
4011
|
const headers = readHeaders(options);
|
|
3954
4012
|
const response = await http.send(
|
|
3955
4013
|
"/v1/queries/{name}",
|
|
@@ -3989,7 +4047,7 @@ function isProduction(proc) {
|
|
|
3989
4047
|
}
|
|
3990
4048
|
chunkL6DXCKVQ_cjs.__name(isProduction, "isProduction");
|
|
3991
4049
|
function resolveFromEnv(proc, now) {
|
|
3992
|
-
const verdict =
|
|
4050
|
+
const verdict = chunk5WGMIQBH_cjs.parseDevEnv(proc?.env, now);
|
|
3993
4051
|
switch (verdict.state) {
|
|
3994
4052
|
case "active":
|
|
3995
4053
|
return {
|
|
@@ -4019,7 +4077,7 @@ function resolveFromFile(proc, now) {
|
|
|
4019
4077
|
if (fs == null || path == null) return { state: "absent" };
|
|
4020
4078
|
let dir = proc.cwd();
|
|
4021
4079
|
for (; ; ) {
|
|
4022
|
-
const candidate = path.join(dir,
|
|
4080
|
+
const candidate = path.join(dir, chunk5WGMIQBH_cjs.DEV_CONTEXT_DIR, chunk5WGMIQBH_cjs.DEV_CONTEXT_FILENAME);
|
|
4023
4081
|
let raw = null;
|
|
4024
4082
|
try {
|
|
4025
4083
|
if (fs.existsSync(candidate)) raw = fs.readFileSync(candidate, "utf8");
|
|
@@ -4027,7 +4085,7 @@ function resolveFromFile(proc, now) {
|
|
|
4027
4085
|
return { state: "absent" };
|
|
4028
4086
|
}
|
|
4029
4087
|
if (raw !== null) {
|
|
4030
|
-
const verdict =
|
|
4088
|
+
const verdict = chunk5WGMIQBH_cjs.parseDevContextFile(raw, now);
|
|
4031
4089
|
switch (verdict.state) {
|
|
4032
4090
|
case "active":
|
|
4033
4091
|
return {
|
|
@@ -4119,6 +4177,9 @@ function validateConfig(config) {
|
|
|
4119
4177
|
if (config.webSocket != null && typeof config.webSocket !== "function") {
|
|
4120
4178
|
throw new Error("webSocket must be a WebSocket class");
|
|
4121
4179
|
}
|
|
4180
|
+
if (config.getToken != null && typeof config.getToken !== "function") {
|
|
4181
|
+
throw new Error("getToken must be a function that answers the End user\u2019s token, or null");
|
|
4182
|
+
}
|
|
4122
4183
|
if (config.timeout != null) assertRequestTimeout(config.timeout);
|
|
4123
4184
|
if (config.retryAttempts != null && !(Number.isInteger(config.retryAttempts) && config.retryAttempts >= 1)) {
|
|
4124
4185
|
throw new Error(
|
|
@@ -4180,7 +4241,7 @@ function withPreview(configured) {
|
|
|
4180
4241
|
if (configured.dataset !== void 0 || !isPreviewKey(configured.apiKey)) return configured;
|
|
4181
4242
|
const preview = readPreviewAtRequest();
|
|
4182
4243
|
if (preview.state !== "preview") return configured;
|
|
4183
|
-
const dataset =
|
|
4244
|
+
const dataset = chunkUO2QRYKV_cjs.previewDatasetSlug(preview.branch);
|
|
4184
4245
|
noteDerivedPreview(dataset);
|
|
4185
4246
|
if (!previewNotified) {
|
|
4186
4247
|
previewNotified = true;
|
|
@@ -4247,7 +4308,10 @@ var _TypedRelyIOClient = class _TypedRelyIOClient {
|
|
|
4247
4308
|
* `createClient()` made, which reads its own.
|
|
4248
4309
|
*/
|
|
4249
4310
|
chunkL6DXCKVQ_cjs.__publicField(this, "parent");
|
|
4250
|
-
/**
|
|
4311
|
+
/**
|
|
4312
|
+
* What `with()` gave this client over its parent's: the locale, dataset and End user's token
|
|
4313
|
+
* function it names, and no other.
|
|
4314
|
+
*/
|
|
4251
4315
|
chunkL6DXCKVQ_cjs.__publicField(this, "defaults", {});
|
|
4252
4316
|
/** The live edge's poll client id: chosen once, when first needed, and kept for this client's life. */
|
|
4253
4317
|
chunkL6DXCKVQ_cjs.__publicField(this, "_liveClientId");
|
|
@@ -4258,7 +4322,9 @@ var _TypedRelyIOClient = class _TypedRelyIOClient {
|
|
|
4258
4322
|
* all or none (REL-3774).
|
|
4259
4323
|
*
|
|
4260
4324
|
* A Record is an app's data, written by your server with a secret key and live the moment it
|
|
4261
|
-
* lands
|
|
4325
|
+
* lands. A publishable key reads the Records a Record type's read Policy grants it (spec 4,
|
|
4326
|
+
* REL-3883), and writes them only for the End user whose token it carries, as the type's write
|
|
4327
|
+
* Policy allows (REL-3884); with no token it writes nothing (`PUBLISHABLE_KEY_REFUSED`).
|
|
4262
4328
|
*
|
|
4263
4329
|
* @example
|
|
4264
4330
|
* ```typescript
|
|
@@ -4286,9 +4352,13 @@ var _TypedRelyIOClient = class _TypedRelyIOClient {
|
|
|
4286
4352
|
* `FunctionRunFailedError` and one past five minutes `FunctionRunTimedOutError`, each naming the
|
|
4287
4353
|
* run. Never retried: a Function may write.
|
|
4288
4354
|
*
|
|
4355
|
+
* Once `relyio generate-types` has run, its `schema.ts` registers each Function's input and output
|
|
4356
|
+
* Fields (REL-4059): only the project's Functions are named here, and each call takes and answers
|
|
4357
|
+
* what its Fields declare, so a misnamed or mistyped input field is a type error.
|
|
4358
|
+
*
|
|
4289
4359
|
* @example
|
|
4290
4360
|
* ```typescript
|
|
4291
|
-
* const { orderId } =
|
|
4361
|
+
* const { orderId } = await relyio.functions.checkout({ cartId })
|
|
4292
4362
|
* ```
|
|
4293
4363
|
*/
|
|
4294
4364
|
// Read when called, never when made: `with()` and `updateConfig()` move `httpClient`
|
|
@@ -4742,6 +4812,9 @@ var _TypedRelyIOClient = class _TypedRelyIOClient {
|
|
|
4742
4812
|
* const { data } = await staging.content('post').list({ limit: 10 })
|
|
4743
4813
|
*
|
|
4744
4814
|
* const french = relyio.with({ locale: 'fr-FR' }) // ← autocompletes the schema's locales
|
|
4815
|
+
*
|
|
4816
|
+
* // Every request this one sends carries the signed-in End user's token (REL-3882)
|
|
4817
|
+
* const visitor = relyio.with({ getToken: () => session.getToken() })
|
|
4745
4818
|
* ```
|
|
4746
4819
|
*/
|
|
4747
4820
|
with(defaults) {
|
|
@@ -4755,14 +4828,16 @@ var _TypedRelyIOClient = class _TypedRelyIOClient {
|
|
|
4755
4828
|
}
|
|
4756
4829
|
/** Make this client one `with()` made from `parent`: see {@link with}. */
|
|
4757
4830
|
follow(parent, defaults) {
|
|
4758
|
-
const { locale, dataset } = defaults;
|
|
4831
|
+
const { locale, dataset, getToken } = defaults;
|
|
4759
4832
|
this.parent = parent;
|
|
4760
4833
|
this.defaults = {
|
|
4761
4834
|
...locale === void 0 ? {} : { locale },
|
|
4762
|
-
...dataset === void 0 ? {} : { dataset }
|
|
4835
|
+
...dataset === void 0 ? {} : { dataset },
|
|
4836
|
+
...getToken === void 0 ? {} : { getToken }
|
|
4763
4837
|
};
|
|
4764
4838
|
this.httpClient = parent.httpClient.withHeaders(
|
|
4765
|
-
dataset === void 0 ? {} : { [DATASET_HEADER]: dataset }
|
|
4839
|
+
dataset === void 0 ? {} : { [DATASET_HEADER]: dataset },
|
|
4840
|
+
getToken === void 0 ? {} : { getToken }
|
|
4766
4841
|
);
|
|
4767
4842
|
}
|
|
4768
4843
|
/**
|
|
@@ -4822,6 +4897,7 @@ exports.ChangesExpiredError = ChangesExpiredError;
|
|
|
4822
4897
|
exports.ConnectionError = ConnectionError;
|
|
4823
4898
|
exports.ContentClient = ContentClient;
|
|
4824
4899
|
exports.DefaultRetryPolicy = DefaultRetryPolicy;
|
|
4900
|
+
exports.EndUserTokenInvalidError = EndUserTokenInvalidError;
|
|
4825
4901
|
exports.ErrorMapper = ErrorMapper;
|
|
4826
4902
|
exports.FileUploadError = FileUploadError;
|
|
4827
4903
|
exports.FileValidationError = FileValidationError;
|
|
@@ -4874,5 +4950,5 @@ exports.serviceInstructedDelayMs = serviceInstructedDelayMs;
|
|
|
4874
4950
|
exports.sleep = sleep;
|
|
4875
4951
|
exports.validateFile = validateFile;
|
|
4876
4952
|
exports.versionCheckOf = versionCheckOf;
|
|
4877
|
-
//# sourceMappingURL=chunk-
|
|
4878
|
-
//# sourceMappingURL=chunk-
|
|
4953
|
+
//# sourceMappingURL=chunk-K66MBRI4.cjs.map
|
|
4954
|
+
//# sourceMappingURL=chunk-K66MBRI4.cjs.map
|