@tinycloud/cli 1.2.0-beta.8 → 1.2.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/dist/courier-entry.js +39 -3
- package/dist/courier-entry.js.map +1 -1
- package/dist/legacy-entry.js +54 -11
- package/dist/legacy-entry.js.map +1 -1
- package/package.json +6 -6
- package/skills/courier/SKILL.md +1 -0
package/dist/legacy-entry.js
CHANGED
|
@@ -6877,8 +6877,39 @@ function parseStorageQuotaBytes(responseText) {
|
|
|
6877
6877
|
limitBytes: parseInt(match[2], 10)
|
|
6878
6878
|
};
|
|
6879
6879
|
}
|
|
6880
|
+
function isByteCount2(value) {
|
|
6881
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
|
|
6882
|
+
}
|
|
6883
|
+
function byteCountsOf(value) {
|
|
6884
|
+
if (typeof value !== "object" || value === null) return void 0;
|
|
6885
|
+
const { usedBytes, limitBytes } = value;
|
|
6886
|
+
return isByteCount2(usedBytes) && isByteCount2(limitBytes) ? { usedBytes, limitBytes } : void 0;
|
|
6887
|
+
}
|
|
6888
|
+
function parseStorageRejection(responseText) {
|
|
6889
|
+
let body;
|
|
6890
|
+
try {
|
|
6891
|
+
body = JSON.parse(responseText);
|
|
6892
|
+
} catch {
|
|
6893
|
+
return parseStorageQuotaBytes(responseText);
|
|
6894
|
+
}
|
|
6895
|
+
if (typeof body !== "object" || body === null) return void 0;
|
|
6896
|
+
const record2 = body;
|
|
6897
|
+
const message = typeof record2.message === "string" ? record2.message : "";
|
|
6898
|
+
const space = byteCountsOf(record2.space) ?? parseStorageQuotaBytes(message);
|
|
6899
|
+
const isStorageBody = typeof record2.error === "string" && STORAGE_REJECTION_BODY_ERRORS[record2.error] === true;
|
|
6900
|
+
if (!space && !isStorageBody) {
|
|
6901
|
+
return void 0;
|
|
6902
|
+
}
|
|
6903
|
+
const details = { ...space };
|
|
6904
|
+
const account = byteCountsOf(record2.account);
|
|
6905
|
+
if (account) {
|
|
6906
|
+
const plan = record2.account.plan;
|
|
6907
|
+
details.account = typeof plan === "string" && plan !== "" ? { ...account, plan } : account;
|
|
6908
|
+
}
|
|
6909
|
+
return details;
|
|
6910
|
+
}
|
|
6880
6911
|
function storageRejectionError(service, status, meta, responseText) {
|
|
6881
|
-
const quotaMeta = { ...meta, ...
|
|
6912
|
+
const quotaMeta = { ...meta, ...parseStorageRejection(responseText) };
|
|
6882
6913
|
return status === 402 ? storageQuotaExceededError(service, STORAGE_FULL_MESSAGE, quotaMeta) : storageLimitReachedError(service, STORAGE_WRITE_TOO_LARGE_MESSAGE, quotaMeta);
|
|
6883
6914
|
}
|
|
6884
6915
|
function wrapError2(service, error, defaultCode = ErrorCodes.NETWORK_ERROR) {
|
|
@@ -7232,14 +7263,12 @@ async function responseError(service, message, response) {
|
|
|
7232
7263
|
}
|
|
7233
7264
|
} catch {
|
|
7234
7265
|
}
|
|
7235
|
-
|
|
7266
|
+
return serviceError(
|
|
7267
|
+
response.status === 408 || response.status === 504 ? ErrorCodes.TIMEOUT : ErrorCodes.NETWORK_ERROR,
|
|
7268
|
+
`${message}: ${response.status} ${detail}`,
|
|
7236
7269
|
service,
|
|
7237
|
-
|
|
7270
|
+
{ meta: { status: response.status, statusText: response.statusText } }
|
|
7238
7271
|
);
|
|
7239
|
-
return {
|
|
7240
|
-
...error,
|
|
7241
|
-
meta: { ...error.meta, status: response.status, statusText: response.statusText }
|
|
7242
|
-
};
|
|
7243
7272
|
}
|
|
7244
7273
|
async function* parseSseStream(body, signal) {
|
|
7245
7274
|
if (!body) {
|
|
@@ -8438,7 +8467,7 @@ function encOk(data) {
|
|
|
8438
8467
|
function encErr(error) {
|
|
8439
8468
|
return { ok: false, error };
|
|
8440
8469
|
}
|
|
8441
|
-
var import_decrypt_transport_response_error, ErrorCodes, defaultRetryPolicy, TelemetryEvents, REDACTED, SAFE_NUMBER_FIELDS, SAFE_BOOLEAN_FIELDS, SAFE_REPLICATION_FIELDS, DEBUG_FLAG, MAX_EVENTS, TinyCloudDebugLogger, tinyCloudDebugLogger, ServiceErrorSchema, GenericResultSchema, KVResponseHeadersSchema, GenericKVResponseSchema, KVListResponseSchema, KVListResultSchema, ServiceRequestEventSchema, ServiceResponseEventSchema, ServiceErrorEventSchema, ServiceRetryEventSchema, TelemetrySpanEventSchema, RetryPolicySchema, ServiceSessionSchema, URN_PREFIX, NETWORK_NAME_RE, PKH_EIP155_DID_RE, NetworkIdError, RequestTimeoutError, grantableActions, capabilityServices, MAX_CAUSE_DEPTH2, STORAGE_FULL_MESSAGE, STORAGE_WRITE_TOO_LARGE_MESSAGE, MAX_TIMER_DELAY_MS, BaseService, PrefixedKVService, DEFAULT_SIGNED_READ_URL_EXPIRY_MS, KVAction, MAX_KV_BATCH_READ_ITEMS, pathByteEncoder, REVOKED_BODY, KVService, SQLMigrations, DatabaseHandle, SQLAction, DDL_TOKENS, MIGRATIONS_TABLE, MIGRATIONS_SCHEMA, MIGRATIONS_META_NAMESPACE, MIGRATIONS_META_ID, SQLService, DuckDbDatabaseHandle, DuckDbAction, DuckDbService, AsyncQueue, HOOK_STREAM_RETRY_BASE_DELAY_MS, HOOK_STREAM_RETRY_MAX_DELAY_MS, HOOK_STREAM_HEALTHY_MS, HooksService, SUPERSEDED, STREAM_ERROR_NAMES, STREAM_ERROR_CODES, VaultVersionConfig, CURRENT_VAULT_VERSION, VaultHeaders, DB_NAME, DB_VERSION, STORE_NAME, WRAP_KEY_ID, DataVaultService, SECRET_NAME_RE, SECRET_PREFIX, SCOPED_SECRET_PREFIX, RESERVED_SECRET_SCOPES, TC832_RESERVED_SCOPES, HEX, DEFAULT_ENCRYPTION_ALG, ENVELOPE_VERSION, DEFAULT_KEY_VERSION, DECRYPT_FACT_TYPE, DECRYPT_RESULT_TYPE, EncryptionService;
|
|
8470
|
+
var import_decrypt_transport_response_error, ErrorCodes, defaultRetryPolicy, TelemetryEvents, REDACTED, SAFE_NUMBER_FIELDS, SAFE_BOOLEAN_FIELDS, SAFE_REPLICATION_FIELDS, DEBUG_FLAG, MAX_EVENTS, TinyCloudDebugLogger, tinyCloudDebugLogger, ServiceErrorSchema, GenericResultSchema, KVResponseHeadersSchema, GenericKVResponseSchema, KVListResponseSchema, KVListResultSchema, ServiceRequestEventSchema, ServiceResponseEventSchema, ServiceErrorEventSchema, ServiceRetryEventSchema, TelemetrySpanEventSchema, RetryPolicySchema, ServiceSessionSchema, URN_PREFIX, NETWORK_NAME_RE, PKH_EIP155_DID_RE, NetworkIdError, RequestTimeoutError, grantableActions, capabilityServices, MAX_CAUSE_DEPTH2, STORAGE_FULL_MESSAGE, STORAGE_WRITE_TOO_LARGE_MESSAGE, STORAGE_REJECTION_BODY_ERRORS, MAX_TIMER_DELAY_MS, BaseService, PrefixedKVService, DEFAULT_SIGNED_READ_URL_EXPIRY_MS, KVAction, MAX_KV_BATCH_READ_ITEMS, pathByteEncoder, REVOKED_BODY, KVService, SQLMigrations, DatabaseHandle, SQLAction, DDL_TOKENS, MIGRATIONS_TABLE, MIGRATIONS_SCHEMA, MIGRATIONS_META_NAMESPACE, MIGRATIONS_META_ID, SQLService, DuckDbDatabaseHandle, DuckDbAction, DuckDbService, AsyncQueue, HOOK_STREAM_RETRY_BASE_DELAY_MS, HOOK_STREAM_RETRY_MAX_DELAY_MS, HOOK_STREAM_HEALTHY_MS, HooksService, SUPERSEDED, STREAM_ERROR_NAMES, STREAM_ERROR_CODES, VaultVersionConfig, CURRENT_VAULT_VERSION, VaultHeaders, DB_NAME, DB_VERSION, STORE_NAME, WRAP_KEY_ID, DataVaultService, SECRET_NAME_RE, SECRET_PREFIX, SCOPED_SECRET_PREFIX, RESERVED_SECRET_SCOPES, TC832_RESERVED_SCOPES, HEX, DEFAULT_ENCRYPTION_ALG, ENVELOPE_VERSION, DEFAULT_KEY_VERSION, DECRYPT_FACT_TYPE, DECRYPT_RESULT_TYPE, EncryptionService;
|
|
8442
8471
|
var init_dist2 = __esm({
|
|
8443
8472
|
"../sdk-services/dist/index.js"() {
|
|
8444
8473
|
"use strict";
|
|
@@ -8484,6 +8513,8 @@ var init_dist2 = __esm({
|
|
|
8484
8513
|
// Storage quota errors
|
|
8485
8514
|
STORAGE_QUOTA_EXCEEDED: "STORAGE_QUOTA_EXCEEDED",
|
|
8486
8515
|
STORAGE_LIMIT_REACHED: "STORAGE_LIMIT_REACHED",
|
|
8516
|
+
/** The node answered the usage read without usage numbers (it predates the read). */
|
|
8517
|
+
STORAGE_STATUS_UNAVAILABLE: "STORAGE_STATUS_UNAVAILABLE",
|
|
8487
8518
|
// DuckDB-specific errors
|
|
8488
8519
|
DUCKDB_ERROR: "DUCKDB_ERROR",
|
|
8489
8520
|
DUCKDB_PERMISSION_DENIED: "DUCKDB_PERMISSION_DENIED",
|
|
@@ -8513,7 +8544,9 @@ var init_dist2 = __esm({
|
|
|
8513
8544
|
REPLICATION_WRITE: "replication.write",
|
|
8514
8545
|
REPLICATION_SYNC: "replication.sync",
|
|
8515
8546
|
REPLICATION_STATE: "replication.state",
|
|
8516
|
-
REPLICATION_DIVERGENCE: "replication.divergence"
|
|
8547
|
+
REPLICATION_DIVERGENCE: "replication.divergence",
|
|
8548
|
+
/** Emitted once, on the first write rejected because storage is full. */
|
|
8549
|
+
STORAGE_FULL: "storage.full"
|
|
8517
8550
|
};
|
|
8518
8551
|
REDACTED = "[REDACTED]";
|
|
8519
8552
|
SAFE_NUMBER_FIELDS = /* @__PURE__ */ new Set([
|
|
@@ -8785,6 +8818,10 @@ var init_dist2 = __esm({
|
|
|
8785
8818
|
MAX_CAUSE_DEPTH2 = 8;
|
|
8786
8819
|
STORAGE_FULL_MESSAGE = "TinyCloud storage is full, so this change was not saved. Reading still works. Free up space or upgrade your plan to save again.";
|
|
8787
8820
|
STORAGE_WRITE_TOO_LARGE_MESSAGE = "This change is larger than the TinyCloud storage you have left, so it was not saved. Reading still works. Free up space or upgrade your plan to save it.";
|
|
8821
|
+
STORAGE_REJECTION_BODY_ERRORS = {
|
|
8822
|
+
storage_quota_exceeded: true,
|
|
8823
|
+
storage_limit_reached: true
|
|
8824
|
+
};
|
|
8788
8825
|
MAX_TIMER_DELAY_MS = 2147483647;
|
|
8789
8826
|
BaseService = class {
|
|
8790
8827
|
constructor() {
|
|
@@ -9241,7 +9278,7 @@ var init_dist2 = __esm({
|
|
|
9241
9278
|
if (response.status !== 402 && response.status !== 413) {
|
|
9242
9279
|
return void 0;
|
|
9243
9280
|
}
|
|
9244
|
-
if (response.status === 413 && !
|
|
9281
|
+
if (response.status === 413 && !parseStorageRejection(errorText)) {
|
|
9245
9282
|
return void 0;
|
|
9246
9283
|
}
|
|
9247
9284
|
return err(
|
|
@@ -11057,6 +11094,9 @@ var init_dist2 = __esm({
|
|
|
11057
11094
|
if (response.status === 402) {
|
|
11058
11095
|
return err(storageRejectionError("sql", 402, meta, errorText));
|
|
11059
11096
|
}
|
|
11097
|
+
if (response.status === 413 && parseStorageRejection(errorText)) {
|
|
11098
|
+
return err(storageRejectionError("sql", 413, meta, errorText));
|
|
11099
|
+
}
|
|
11060
11100
|
const errorBody = parseServiceErrorBody(errorText);
|
|
11061
11101
|
const errorCode2 = this.mapHttpStatusToErrorCode(
|
|
11062
11102
|
response.status,
|
|
@@ -11434,6 +11474,9 @@ var init_dist2 = __esm({
|
|
|
11434
11474
|
if (response.status === 402) {
|
|
11435
11475
|
return err(storageRejectionError("duckdb", 402, meta, errorText));
|
|
11436
11476
|
}
|
|
11477
|
+
if (response.status === 413 && parseStorageRejection(errorText)) {
|
|
11478
|
+
return err(storageRejectionError("duckdb", 413, meta, errorText));
|
|
11479
|
+
}
|
|
11437
11480
|
const errorBody = parseServiceErrorBody(errorText);
|
|
11438
11481
|
const errorCode2 = this.mapHttpStatusToErrorCode(
|
|
11439
11482
|
response.status,
|
|
@@ -20355,7 +20398,7 @@ async function delegationFromInput(input, did, options) {
|
|
|
20355
20398
|
redirect: "error"
|
|
20356
20399
|
});
|
|
20357
20400
|
if (!response.ok) {
|
|
20358
|
-
throw new Error(response.status === 404 ? "Delegation code not found or expired. Use the full code shown in OpenKey instead." : `Could not retrieve delegation code (HTTP ${response.status}).`);
|
|
20401
|
+
throw Object.assign(new Error(response.status === 404 ? "Delegation code not found or expired. Use the full code shown in OpenKey instead." : `Could not retrieve delegation code (HTTP ${response.status}).`), { status: response.status });
|
|
20359
20402
|
}
|
|
20360
20403
|
const result = await response.json();
|
|
20361
20404
|
parsed = result.delegation;
|