@tinycloud/sdk-services 3.2.0-beta.3 → 3.2.0-beta.7
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/dist/{BaseService-BDQXjWMx.d.cts → BaseService-4wwJq1Gn.d.cts} +1 -1
- package/dist/{BaseService-Di_hVfUV.d.ts → BaseService-BGr2slUz.d.ts} +1 -1
- package/dist/encryption/index.cjs +5 -1
- package/dist/encryption/index.cjs.map +1 -1
- package/dist/encryption/index.d.cts +2 -2
- package/dist/encryption/index.d.ts +2 -2
- package/dist/encryption/index.js +5 -1
- package/dist/encryption/index.js.map +1 -1
- package/dist/index.cjs +190 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +157 -6
- package/dist/index.d.ts +157 -6
- package/dist/index.js +184 -11
- package/dist/index.js.map +1 -1
- package/dist/internal/decrypt-transport-response-error.d.cts +1 -1
- package/dist/internal/decrypt-transport-response-error.d.ts +1 -1
- package/dist/kv/index.cjs +56 -11
- package/dist/kv/index.cjs.map +1 -1
- package/dist/kv/index.d.cts +5 -4
- package/dist/kv/index.d.ts +5 -4
- package/dist/kv/index.js +56 -11
- package/dist/kv/index.js.map +1 -1
- package/dist/kv/replication/index.cjs +44 -19
- package/dist/kv/replication/index.cjs.map +1 -1
- package/dist/kv/replication/index.d.cts +4 -3
- package/dist/kv/replication/index.d.ts +4 -3
- package/dist/kv/replication/index.js +44 -19
- package/dist/kv/replication/index.js.map +1 -1
- package/dist/kv/replication/prefix.cjs +43 -0
- package/dist/kv/replication/prefix.cjs.map +1 -0
- package/dist/kv/replication/prefix.d.cts +6 -0
- package/dist/kv/replication/prefix.d.ts +6 -0
- package/dist/kv/replication/prefix.js +17 -0
- package/dist/kv/replication/prefix.js.map +1 -0
- package/dist/{scope-BmLxwyl-.d.ts → scope-CoKKmMiI.d.ts} +5 -5
- package/dist/{scope-D855kRDx.d.cts → scope-D7wmjbMH.d.cts} +5 -5
- package/dist/sql/index.cjs +44 -2
- package/dist/sql/index.cjs.map +1 -1
- package/dist/sql/index.d.cts +2 -2
- package/dist/sql/index.d.ts +2 -2
- package/dist/sql/index.js +44 -2
- package/dist/sql/index.js.map +1 -1
- package/dist/{types-7A5rHWRY.d.cts → types-D-9A3Sut.d.cts} +6 -0
- package/dist/{types-7A5rHWRY.d.ts → types-D-9A3Sut.d.ts} +6 -0
- package/package.json +14 -1
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/kv/replication/prefix.ts
|
|
21
|
+
var prefix_exports = {};
|
|
22
|
+
__export(prefix_exports, {
|
|
23
|
+
assertFolderPrefix: () => assertFolderPrefix,
|
|
24
|
+
kvPrefixCovers: () => kvPrefixCovers
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(prefix_exports);
|
|
27
|
+
function kvPrefixCovers(prefix, key) {
|
|
28
|
+
return prefix === "/" || key.startsWith(prefix);
|
|
29
|
+
}
|
|
30
|
+
function assertFolderPrefix(prefix) {
|
|
31
|
+
const validFolder = typeof prefix === "string" && prefix.length > 0 && !prefix.startsWith("/") && !prefix.includes("//") && prefix.endsWith("/");
|
|
32
|
+
if (prefix !== "/" && !validFolder) {
|
|
33
|
+
const folderHint = typeof prefix === "string" ? prefix.replace(/^\/+/, "").replace(/\/+$/, "") : "";
|
|
34
|
+
const suggestion = folderHint.length > 0 && !folderHint.includes("//") ? ` Use ${JSON.stringify(`${folderHint}/`)}.` : ' Use "/" or a slash-terminated folder path such as "notes/".';
|
|
35
|
+
throw new TypeError(`Replication prefix must be "/" or a non-empty slash-terminated folder path without empty segments.${suggestion}`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
+
0 && (module.exports = {
|
|
40
|
+
assertFolderPrefix,
|
|
41
|
+
kvPrefixCovers
|
|
42
|
+
});
|
|
43
|
+
//# sourceMappingURL=prefix.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/kv/replication/prefix.ts"],"sourcesContent":["/** Shared prefix boundary and configuration rules; no runtime dependencies. */\nexport function kvPrefixCovers(prefix: string, key: string): boolean {\n return prefix === \"/\" || key.startsWith(prefix);\n}\n\n/** Replication scopes are `/` or non-empty, slash-terminated folder paths. */\nexport function assertFolderPrefix(prefix: unknown): asserts prefix is string {\n const validFolder = typeof prefix === \"string\" &&\n prefix.length > 0 &&\n !prefix.startsWith(\"/\") &&\n !prefix.includes(\"//\") &&\n prefix.endsWith(\"/\");\n if (prefix !== \"/\" && !validFolder) {\n const folderHint = typeof prefix === \"string\"\n ? prefix.replace(/^\\/+/, \"\").replace(/\\/+$/, \"\")\n : \"\";\n const suggestion = folderHint.length > 0 && !folderHint.includes(\"//\")\n ? ` Use ${JSON.stringify(`${folderHint}/`)}.`\n : ' Use \"/\" or a slash-terminated folder path such as \"notes/\".';\n throw new TypeError(`Replication prefix must be \"/\" or a non-empty slash-terminated folder path without empty segments.${suggestion}`);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACO,SAAS,eAAe,QAAgB,KAAsB;AACnE,SAAO,WAAW,OAAO,IAAI,WAAW,MAAM;AAChD;AAGO,SAAS,mBAAmB,QAA2C;AAC5E,QAAM,cAAc,OAAO,WAAW,YACpC,OAAO,SAAS,KAChB,CAAC,OAAO,WAAW,GAAG,KACtB,CAAC,OAAO,SAAS,IAAI,KACrB,OAAO,SAAS,GAAG;AACrB,MAAI,WAAW,OAAO,CAAC,aAAa;AAClC,UAAM,aAAa,OAAO,WAAW,WACjC,OAAO,QAAQ,QAAQ,EAAE,EAAE,QAAQ,QAAQ,EAAE,IAC7C;AACJ,UAAM,aAAa,WAAW,SAAS,KAAK,CAAC,WAAW,SAAS,IAAI,IACjE,QAAQ,KAAK,UAAU,GAAG,UAAU,GAAG,CAAC,MACxC;AACJ,UAAM,IAAI,UAAU,qGAAqG,UAAU,EAAE;AAAA,EACvI;AACF;","names":[]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Shared prefix boundary and configuration rules; no runtime dependencies. */
|
|
2
|
+
declare function kvPrefixCovers(prefix: string, key: string): boolean;
|
|
3
|
+
/** Replication scopes are `/` or non-empty, slash-terminated folder paths. */
|
|
4
|
+
declare function assertFolderPrefix(prefix: unknown): asserts prefix is string;
|
|
5
|
+
|
|
6
|
+
export { assertFolderPrefix, kvPrefixCovers };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Shared prefix boundary and configuration rules; no runtime dependencies. */
|
|
2
|
+
declare function kvPrefixCovers(prefix: string, key: string): boolean;
|
|
3
|
+
/** Replication scopes are `/` or non-empty, slash-terminated folder paths. */
|
|
4
|
+
declare function assertFolderPrefix(prefix: unknown): asserts prefix is string;
|
|
5
|
+
|
|
6
|
+
export { assertFolderPrefix, kvPrefixCovers };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// src/kv/replication/prefix.ts
|
|
2
|
+
function kvPrefixCovers(prefix, key) {
|
|
3
|
+
return prefix === "/" || key.startsWith(prefix);
|
|
4
|
+
}
|
|
5
|
+
function assertFolderPrefix(prefix) {
|
|
6
|
+
const validFolder = typeof prefix === "string" && prefix.length > 0 && !prefix.startsWith("/") && !prefix.includes("//") && prefix.endsWith("/");
|
|
7
|
+
if (prefix !== "/" && !validFolder) {
|
|
8
|
+
const folderHint = typeof prefix === "string" ? prefix.replace(/^\/+/, "").replace(/\/+$/, "") : "";
|
|
9
|
+
const suggestion = folderHint.length > 0 && !folderHint.includes("//") ? ` Use ${JSON.stringify(`${folderHint}/`)}.` : ' Use "/" or a slash-terminated folder path such as "notes/".';
|
|
10
|
+
throw new TypeError(`Replication prefix must be "/" or a non-empty slash-terminated folder path without empty segments.${suggestion}`);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
assertFolderPrefix,
|
|
15
|
+
kvPrefixCovers
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=prefix.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/kv/replication/prefix.ts"],"sourcesContent":["/** Shared prefix boundary and configuration rules; no runtime dependencies. */\nexport function kvPrefixCovers(prefix: string, key: string): boolean {\n return prefix === \"/\" || key.startsWith(prefix);\n}\n\n/** Replication scopes are `/` or non-empty, slash-terminated folder paths. */\nexport function assertFolderPrefix(prefix: unknown): asserts prefix is string {\n const validFolder = typeof prefix === \"string\" &&\n prefix.length > 0 &&\n !prefix.startsWith(\"/\") &&\n !prefix.includes(\"//\") &&\n prefix.endsWith(\"/\");\n if (prefix !== \"/\" && !validFolder) {\n const folderHint = typeof prefix === \"string\"\n ? prefix.replace(/^\\/+/, \"\").replace(/\\/+$/, \"\")\n : \"\";\n const suggestion = folderHint.length > 0 && !folderHint.includes(\"//\")\n ? ` Use ${JSON.stringify(`${folderHint}/`)}.`\n : ' Use \"/\" or a slash-terminated folder path such as \"notes/\".';\n throw new TypeError(`Replication prefix must be \"/\" or a non-empty slash-terminated folder path without empty segments.${suggestion}`);\n }\n}\n"],"mappings":";AACO,SAAS,eAAe,QAAgB,KAAsB;AACnE,SAAO,WAAW,OAAO,IAAI,WAAW,MAAM;AAChD;AAGO,SAAS,mBAAmB,QAA2C;AAC5E,QAAM,cAAc,OAAO,WAAW,YACpC,OAAO,SAAS,KAChB,CAAC,OAAO,WAAW,GAAG,KACtB,CAAC,OAAO,SAAS,IAAI,KACrB,OAAO,SAAS,GAAG;AACrB,MAAI,WAAW,OAAO,CAAC,aAAa;AAClC,UAAM,aAAa,OAAO,WAAW,WACjC,OAAO,QAAQ,QAAQ,EAAE,EAAE,QAAQ,QAAQ,EAAE,IAC7C;AACJ,UAAM,aAAa,WAAW,SAAS,KAAK,CAAC,WAAW,SAAS,IAAI,IACjE,QAAQ,KAAK,UAAU,GAAG,UAAU,GAAG,CAAC,MACxC;AACJ,UAAM,IAAI,UAAU,qGAAqG,UAAU,EAAE;AAAA,EACvI;AACF;","names":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as Result, F as FetchFunction } from './types-
|
|
1
|
+
import { R as Result, F as FetchFunction } from './types-D-9A3Sut.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* KV Service Types
|
|
@@ -729,6 +729,8 @@ interface KVReplicationDeps {
|
|
|
729
729
|
* after restart. Pending-state failures also fail closed to network reads.
|
|
730
730
|
*/
|
|
731
731
|
pending: PendingWriteStore;
|
|
732
|
+
/** Node `/info` features discovered on sign-in for protocol gating. */
|
|
733
|
+
nodeFeatures?: readonly string[];
|
|
732
734
|
scheduler: ReplicationScheduler;
|
|
733
735
|
emit(event: ReplicationEvent): void;
|
|
734
736
|
fetch?: FetchFunction;
|
|
@@ -818,7 +820,7 @@ interface ReplicationControl {
|
|
|
818
820
|
}
|
|
819
821
|
interface ReplicationOptions {
|
|
820
822
|
enabled: boolean;
|
|
821
|
-
/** Non-empty
|
|
823
|
+
/** Non-empty list of folder prefixes ending in `/`, or `/` for the whole space. */
|
|
822
824
|
prefixes: string[];
|
|
823
825
|
/** Required for prefixes/spaces where requiresSecretsOptIn returns true. */
|
|
824
826
|
allowSecrets?: boolean;
|
|
@@ -949,9 +951,7 @@ declare function canonicalReplicationIdentity(raw: ReplicationIdentity): Replica
|
|
|
949
951
|
/** Stable in-memory key; durable adapters hash its UTF-8 bytes with their platform crypto. */
|
|
950
952
|
declare function replicationIdentityKey(id: ReplicationIdentity): string;
|
|
951
953
|
|
|
952
|
-
/** Published replica selector semantics: exact key plus descendants by segment. */
|
|
953
|
-
declare function kvPrefixCovers(prefix: string, key: string): boolean;
|
|
954
954
|
/** Whether replicating this space/prefix can copy encrypted secret material to disk. */
|
|
955
955
|
declare function requiresSecretsOptIn(space: string, prefix: string): boolean;
|
|
956
956
|
|
|
957
|
-
export { type
|
|
957
|
+
export { type KVListResponse as $, type AuthorityRefusal as A, type ReplicationScheduler as B, CLEAR_PENDING_WARNING as C, type ResolvedReplicationOptions as D, canonicalReplicationIdentity as E, replicationIdentityKey as F, requiresSecretsOptIn as G, DEFAULT_SIGNED_READ_URL_EXPIRY_MS as H, KVAction as I, type KVActionType as J, type KVReplicationDeps as K, type LocalGetResult as L, type KVBatchPutItem as M, type KVBatchPutOptions as N, type KVBatchPutResponse as O, type PendingWriteStore as P, type KVBatchReadResponse as Q, type ReplicationIdentity as R, type KVChange as S, type KVChangesAuthority as T, type KVChangesOptions as U, type KVChangesResponse as V, type KVCreateSignedReadUrlOptions as W, type KVDeleteOptions as X, type KVGetOptions as Y, type KVHeadOptions as Z, type KVListOptions as _, type KVReplicationController as a, type KVPutOptions as a0, type KVResponse as a1, type KVResponseHeaders as a2, type KVServiceConfig as a3, type KVSignedReadUrlResponse as a4, type KVListPage as b, type KVReadThrough as c, type KVReplicaHandle as d, type KVReplicaSpec as e, type KVReplicaStorage as f, type LocalListResult as g, type LocalReadMeta as h, type LocalReplicaStatus as i, type LocalSyncResult as j, type PendingWriteRecord as k, type PendingWriteState as l, type PinnedKey as m, type PurgeTarget as n, type ReplicaAuthorityState as o, type ReplicaCoverage as p, type ReplicaDevice as q, type ReplicaGrantInfo as r, type ReplicaState as s, type ReplicaStatusEntry as t, type ReplicationAuthority as u, type ReplicationControl as v, type ReplicationEvent as w, type ReplicationOptions as x, type ReplicationPurgeReport as y, type ReplicationReason as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as Result, F as FetchFunction } from './types-
|
|
1
|
+
import { R as Result, F as FetchFunction } from './types-D-9A3Sut.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* KV Service Types
|
|
@@ -729,6 +729,8 @@ interface KVReplicationDeps {
|
|
|
729
729
|
* after restart. Pending-state failures also fail closed to network reads.
|
|
730
730
|
*/
|
|
731
731
|
pending: PendingWriteStore;
|
|
732
|
+
/** Node `/info` features discovered on sign-in for protocol gating. */
|
|
733
|
+
nodeFeatures?: readonly string[];
|
|
732
734
|
scheduler: ReplicationScheduler;
|
|
733
735
|
emit(event: ReplicationEvent): void;
|
|
734
736
|
fetch?: FetchFunction;
|
|
@@ -818,7 +820,7 @@ interface ReplicationControl {
|
|
|
818
820
|
}
|
|
819
821
|
interface ReplicationOptions {
|
|
820
822
|
enabled: boolean;
|
|
821
|
-
/** Non-empty
|
|
823
|
+
/** Non-empty list of folder prefixes ending in `/`, or `/` for the whole space. */
|
|
822
824
|
prefixes: string[];
|
|
823
825
|
/** Required for prefixes/spaces where requiresSecretsOptIn returns true. */
|
|
824
826
|
allowSecrets?: boolean;
|
|
@@ -949,9 +951,7 @@ declare function canonicalReplicationIdentity(raw: ReplicationIdentity): Replica
|
|
|
949
951
|
/** Stable in-memory key; durable adapters hash its UTF-8 bytes with their platform crypto. */
|
|
950
952
|
declare function replicationIdentityKey(id: ReplicationIdentity): string;
|
|
951
953
|
|
|
952
|
-
/** Published replica selector semantics: exact key plus descendants by segment. */
|
|
953
|
-
declare function kvPrefixCovers(prefix: string, key: string): boolean;
|
|
954
954
|
/** Whether replicating this space/prefix can copy encrypted secret material to disk. */
|
|
955
955
|
declare function requiresSecretsOptIn(space: string, prefix: string): boolean;
|
|
956
956
|
|
|
957
|
-
export { type
|
|
957
|
+
export { type KVListResponse as $, type AuthorityRefusal as A, type ReplicationScheduler as B, CLEAR_PENDING_WARNING as C, type ResolvedReplicationOptions as D, canonicalReplicationIdentity as E, replicationIdentityKey as F, requiresSecretsOptIn as G, DEFAULT_SIGNED_READ_URL_EXPIRY_MS as H, KVAction as I, type KVActionType as J, type KVReplicationDeps as K, type LocalGetResult as L, type KVBatchPutItem as M, type KVBatchPutOptions as N, type KVBatchPutResponse as O, type PendingWriteStore as P, type KVBatchReadResponse as Q, type ReplicationIdentity as R, type KVChange as S, type KVChangesAuthority as T, type KVChangesOptions as U, type KVChangesResponse as V, type KVCreateSignedReadUrlOptions as W, type KVDeleteOptions as X, type KVGetOptions as Y, type KVHeadOptions as Z, type KVListOptions as _, type KVReplicationController as a, type KVPutOptions as a0, type KVResponse as a1, type KVResponseHeaders as a2, type KVServiceConfig as a3, type KVSignedReadUrlResponse as a4, type KVListPage as b, type KVReadThrough as c, type KVReplicaHandle as d, type KVReplicaSpec as e, type KVReplicaStorage as f, type LocalListResult as g, type LocalReadMeta as h, type LocalReplicaStatus as i, type LocalSyncResult as j, type PendingWriteRecord as k, type PendingWriteState as l, type PinnedKey as m, type PurgeTarget as n, type ReplicaAuthorityState as o, type ReplicaCoverage as p, type ReplicaDevice as q, type ReplicaGrantInfo as r, type ReplicaState as s, type ReplicaStatusEntry as t, type ReplicationAuthority as u, type ReplicationControl as v, type ReplicationEvent as w, type ReplicationOptions as x, type ReplicationPurgeReport as y, type ReplicationReason as z };
|
package/dist/sql/index.cjs
CHANGED
|
@@ -65,6 +65,8 @@ var ErrorCodes = {
|
|
|
65
65
|
// Storage quota errors
|
|
66
66
|
STORAGE_QUOTA_EXCEEDED: "STORAGE_QUOTA_EXCEEDED",
|
|
67
67
|
STORAGE_LIMIT_REACHED: "STORAGE_LIMIT_REACHED",
|
|
68
|
+
/** The node answered the usage read without usage numbers (it predates the read). */
|
|
69
|
+
STORAGE_STATUS_UNAVAILABLE: "STORAGE_STATUS_UNAVAILABLE",
|
|
68
70
|
// DuckDB-specific errors
|
|
69
71
|
DUCKDB_ERROR: "DUCKDB_ERROR",
|
|
70
72
|
DUCKDB_PERMISSION_DENIED: "DUCKDB_PERMISSION_DENIED",
|
|
@@ -94,7 +96,9 @@ var TelemetryEvents = {
|
|
|
94
96
|
REPLICATION_WRITE: "replication.write",
|
|
95
97
|
REPLICATION_SYNC: "replication.sync",
|
|
96
98
|
REPLICATION_STATE: "replication.state",
|
|
97
|
-
REPLICATION_DIVERGENCE: "replication.divergence"
|
|
99
|
+
REPLICATION_DIVERGENCE: "replication.divergence",
|
|
100
|
+
/** Emitted once, on the first write rejected because storage is full. */
|
|
101
|
+
STORAGE_FULL: "storage.full"
|
|
98
102
|
};
|
|
99
103
|
function ok(data) {
|
|
100
104
|
return { ok: true, data };
|
|
@@ -194,8 +198,43 @@ function parseStorageQuotaBytes(responseText) {
|
|
|
194
198
|
limitBytes: parseInt(match[2], 10)
|
|
195
199
|
};
|
|
196
200
|
}
|
|
201
|
+
var STORAGE_REJECTION_BODY_ERRORS = {
|
|
202
|
+
storage_quota_exceeded: true,
|
|
203
|
+
storage_limit_reached: true
|
|
204
|
+
};
|
|
205
|
+
function isByteCount(value) {
|
|
206
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
|
|
207
|
+
}
|
|
208
|
+
function byteCountsOf(value) {
|
|
209
|
+
if (typeof value !== "object" || value === null) return void 0;
|
|
210
|
+
const { usedBytes, limitBytes } = value;
|
|
211
|
+
return isByteCount(usedBytes) && isByteCount(limitBytes) ? { usedBytes, limitBytes } : void 0;
|
|
212
|
+
}
|
|
213
|
+
function parseStorageRejection(responseText) {
|
|
214
|
+
let body;
|
|
215
|
+
try {
|
|
216
|
+
body = JSON.parse(responseText);
|
|
217
|
+
} catch {
|
|
218
|
+
return parseStorageQuotaBytes(responseText);
|
|
219
|
+
}
|
|
220
|
+
if (typeof body !== "object" || body === null) return void 0;
|
|
221
|
+
const record = body;
|
|
222
|
+
const message = typeof record.message === "string" ? record.message : "";
|
|
223
|
+
const space = byteCountsOf(record.space) ?? parseStorageQuotaBytes(message);
|
|
224
|
+
const isStorageBody = typeof record.error === "string" && STORAGE_REJECTION_BODY_ERRORS[record.error] === true;
|
|
225
|
+
if (!space && !isStorageBody) {
|
|
226
|
+
return void 0;
|
|
227
|
+
}
|
|
228
|
+
const details = { ...space };
|
|
229
|
+
const account = byteCountsOf(record.account);
|
|
230
|
+
if (account) {
|
|
231
|
+
const plan = record.account.plan;
|
|
232
|
+
details.account = typeof plan === "string" && plan !== "" ? { ...account, plan } : account;
|
|
233
|
+
}
|
|
234
|
+
return details;
|
|
235
|
+
}
|
|
197
236
|
function storageRejectionError(service, status, meta, responseText) {
|
|
198
|
-
const quotaMeta = { ...meta, ...
|
|
237
|
+
const quotaMeta = { ...meta, ...parseStorageRejection(responseText) };
|
|
199
238
|
return status === 402 ? storageQuotaExceededError(service, STORAGE_FULL_MESSAGE, quotaMeta) : storageLimitReachedError(service, STORAGE_WRITE_TOO_LARGE_MESSAGE, quotaMeta);
|
|
200
239
|
}
|
|
201
240
|
function wrapError(service, error, defaultCode = ErrorCodes.NETWORK_ERROR) {
|
|
@@ -927,6 +966,9 @@ var SQLService = class extends BaseService {
|
|
|
927
966
|
if (response.status === 402) {
|
|
928
967
|
return err(storageRejectionError("sql", 402, meta, errorText));
|
|
929
968
|
}
|
|
969
|
+
if (response.status === 413 && parseStorageRejection(errorText)) {
|
|
970
|
+
return err(storageRejectionError("sql", 413, meta, errorText));
|
|
971
|
+
}
|
|
930
972
|
const errorBody = parseServiceErrorBody(errorText);
|
|
931
973
|
const errorCode = this.mapHttpStatusToErrorCode(
|
|
932
974
|
response.status,
|