@gusto/baerly-storage 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -124
- package/dist/API.md +161 -511
- package/dist/CHANGELOG.md +1148 -307
- package/dist/RECIPES.md +398 -80
- package/dist/THIRD-PARTY-LICENSES.txt +5 -26
- package/dist/{app-config-DyiFK3_k.d.ts → app-config-C6qW7m8S.d.ts} +119 -111
- package/dist/app-config.d.ts +31 -1
- package/dist/app-config.js +1 -2
- package/dist/app-config.js.map +1 -1
- package/dist/auth.d.ts +33 -28
- package/dist/auth.js +549 -985
- package/dist/auth.js.map +1 -1
- package/dist/baerly.js +130 -138
- package/dist/baerly.js.map +1 -1
- package/dist/baerly.spec.json +97 -22
- package/dist/capacity-warning-header-BlVopyiI.js +16 -0
- package/dist/capacity-warning-header-BlVopyiI.js.map +1 -0
- package/dist/{client-Fe8CwB73.d.ts → client-CHQTXpef.d.ts} +121 -36
- package/dist/client-react.d.ts +67 -20
- package/dist/client-react.js +240 -54
- package/dist/client-react.js.map +1 -1
- package/dist/client.d.ts +5 -4
- package/dist/client.js +51 -16
- package/dist/client.js.map +1 -1
- package/dist/{cloudflare-DzKBrUlg.js → cloudflare-CKHYXccw.js} +504 -124
- package/dist/cloudflare-CKHYXccw.js.map +1 -0
- package/dist/cloudflare.d.ts +106 -71
- package/dist/cloudflare.js +334 -271
- package/dist/cloudflare.js.map +1 -1
- package/dist/code-resolution-CL_7L0wS.js +22 -0
- package/dist/code-resolution-CL_7L0wS.js.map +1 -0
- package/dist/collection-api-DbyhLAY8.d.ts +1001 -0
- package/dist/config-DEzInG6M.js +4035 -0
- package/dist/config-DEzInG6M.js.map +1 -0
- package/dist/constants-D3GSH3tc.js +469 -0
- package/dist/constants-D3GSH3tc.js.map +1 -0
- package/dist/{context-DRZ3tZ5l.js → context-rlpSnHFA.js} +17 -17
- package/dist/context-rlpSnHFA.js.map +1 -0
- package/dist/cost-B52llVDx.js +330 -0
- package/dist/cost-B52llVDx.js.map +1 -0
- package/dist/{current-json-C6nhPOm1.js → current-json-CC6lE4Aj.js} +115 -32
- package/dist/current-json-CC6lE4Aj.js.map +1 -0
- package/dist/db-plFUNTSF.d.ts +130 -0
- package/dist/db-read-seams-BSs0m1z1.js +3261 -0
- package/dist/db-read-seams-BSs0m1z1.js.map +1 -0
- package/dist/{deploy-DonTr-CV.js → deploy-Obj4nE-Z.js} +12 -16
- package/dist/deploy-Obj4nE-Z.js.map +1 -0
- package/dist/{dev-banner-CWHIk8tH.d.ts → dev-banner-B5AUHmu1.d.ts} +1 -4
- package/dist/dev-landing-BI5UdmOb.d.ts +32 -0
- package/dist/dev-landing-CD-si4dW.js +50 -0
- package/dist/dev-landing-CD-si4dW.js.map +1 -0
- package/dist/dev-vite.d.ts +38 -39
- package/dist/dev-vite.js +67 -36
- package/dist/dev-vite.js.map +1 -1
- package/dist/dev.d.ts +3 -2
- package/dist/dev.js +2 -1
- package/dist/doctor-BA0i-YAN.js +270 -0
- package/dist/doctor-BA0i-YAN.js.map +1 -0
- package/dist/dump-D1vX8ozg.js +133 -0
- package/dist/dump-D1vX8ozg.js.map +1 -0
- package/dist/errors-7Rk1HGCE.js +160 -0
- package/dist/errors-7Rk1HGCE.js.map +1 -0
- package/dist/{validate-DtljsCh1.js → export-BVL2EvYE.js} +409 -19
- package/dist/export-BVL2EvYE.js.map +1 -0
- package/dist/fsck-BWkPgov4.js +145 -0
- package/dist/fsck-BWkPgov4.js.map +1 -0
- package/dist/gcs-admin-Dso1HWQj.d.ts +127 -0
- package/dist/gcs.d.ts +30 -0
- package/dist/gcs.js +1 -0
- package/dist/goog4-signer-CeLIABoE.js +331 -0
- package/dist/goog4-signer-CeLIABoE.js.map +1 -0
- package/dist/{http-DGd5tbNs.js → http-Z5rZyYMX.js} +898 -271
- package/dist/http-Z5rZyYMX.js.map +1 -0
- package/dist/http-transport-DNUM8kU-.js +1299 -0
- package/dist/http-transport-DNUM8kU-.js.map +1 -0
- package/dist/http.d.ts +366 -294
- package/dist/http.js +2 -2
- package/dist/index-JJrIu1pO.d.ts +135 -0
- package/dist/index-LEgHN0qJ.d.ts +50 -0
- package/dist/{index-CuA9Mi3K.d.ts → index-RiEYj8t0.d.ts} +291 -78
- package/dist/index.d.ts +27 -6
- package/dist/index.js +3 -5
- package/dist/inspect-BTsVYZKd.js +196 -0
- package/dist/inspect-BTsVYZKd.js.map +1 -0
- package/dist/{key-Di6yyxFu.js → key-C4FPZ9Io.js} +3 -4
- package/dist/{key-Di6yyxFu.js.map → key-C4FPZ9Io.js.map} +1 -1
- package/dist/ledger-Dj_bGgo0.js +192 -0
- package/dist/ledger-Dj_bGgo0.js.map +1 -0
- package/dist/legacy-names-DgZBtgOh.js +47 -0
- package/dist/legacy-names-DgZBtgOh.js.map +1 -0
- package/dist/log-C9W15Dfo.d.ts +94 -0
- package/dist/log-tail-DWJbneBF.js +142 -0
- package/dist/log-tail-DWJbneBF.js.map +1 -0
- package/dist/log-walk-C-vA-WGJ.js +111 -0
- package/dist/log-walk-C-vA-WGJ.js.map +1 -0
- package/dist/maintenance-Dd-Yakqj.js +1709 -0
- package/dist/maintenance-Dd-Yakqj.js.map +1 -0
- package/dist/maintenance-DevB6z4e.js +2237 -0
- package/dist/maintenance-DevB6z4e.js.map +1 -0
- package/dist/maintenance.d.ts +100 -3
- package/dist/maintenance.js +1 -3
- package/dist/node.d.ts +130 -142
- package/dist/node.js +4 -3
- package/dist/{observability-BmflLCdF.js → observability-C-ISCCLE.js} +1275 -332
- package/dist/observability-C-ISCCLE.js.map +1 -0
- package/dist/observability.d.ts +27 -3
- package/dist/observability.js +3 -3
- package/dist/path-segment-DBXG26PW.js +363 -0
- package/dist/path-segment-DBXG26PW.js.map +1 -0
- package/dist/{plan-a7PJHBCy.js → plan-BvQbaNMe.js} +19 -11
- package/dist/plan-BvQbaNMe.js.map +1 -0
- package/dist/request-CRWiTrza.js +272 -0
- package/dist/request-CRWiTrza.js.map +1 -0
- package/dist/restore-U6Im8V1V.js +1467 -0
- package/dist/restore-U6Im8V1V.js.map +1 -0
- package/dist/retry-OBtLB2GC.js +126 -0
- package/dist/retry-OBtLB2GC.js.map +1 -0
- package/dist/rolldown-runtime-D3KUYPsf.js +12 -0
- package/dist/{runtime-spec-Dsw2-n8S.js → runtime-spec-B5mg3pHF.js} +189 -28
- package/dist/runtime-spec-B5mg3pHF.js.map +1 -0
- package/dist/{s3-http-B-z8th6O.d.ts → s3-http-DBC_wiCL.d.ts} +18 -10
- package/dist/s3.d.ts +20 -7
- package/dist/s3.js +4 -5
- package/dist/s3.js.map +1 -1
- package/dist/sha256-4FfGQNPw.js +22 -0
- package/dist/sha256-4FfGQNPw.js.map +1 -0
- package/dist/{shared-secret-DgEicd3x.js → shared-secret-Vkur-8r0.js} +27 -15
- package/dist/shared-secret-Vkur-8r0.js.map +1 -0
- package/dist/sigv4-sign-5IUflUD_.js +507 -0
- package/dist/sigv4-sign-5IUflUD_.js.map +1 -0
- package/dist/snapshot-CknzkDM0.js +148 -0
- package/dist/snapshot-CknzkDM0.js.map +1 -0
- package/dist/{src-BL_JoPTn.js → src-Actga-bO.js} +1004 -378
- package/dist/src-Actga-bO.js.map +1 -0
- package/dist/src-D0MQfvOp.js +812 -0
- package/dist/src-D0MQfvOp.js.map +1 -0
- package/dist/src-Dr9uo3dc.js +501 -0
- package/dist/src-Dr9uo3dc.js.map +1 -0
- package/dist/{subcommand-DoDA-K7d.js → subcommand-BLoF66dG.js} +89 -16
- package/dist/subcommand-BLoF66dG.js.map +1 -0
- package/dist/{time-DUqvFMHq.js → time-DRxTP9iv.js} +15 -34
- package/dist/time-DRxTP9iv.js.map +1 -0
- package/dist/types-suVbsEWS.d.ts +116 -0
- package/dist/{usage-DBV1eQHC.js → usage-CPzVhrQr.js} +40 -45
- package/dist/usage-CPzVhrQr.js.map +1 -0
- package/dist/uuid-BuT_c404.js +333 -0
- package/dist/uuid-BuT_c404.js.map +1 -0
- package/dist/verifier-Bmlmndzo.d.ts +95 -0
- package/dist/{wire-izfGZDvr.js → wire-DndvKU-K.js} +2 -3
- package/dist/wire-DndvKU-K.js.map +1 -0
- package/package.json +96 -69
- package/dist/aws4fetch.esm-p7eEzLCs.js +0 -1702
- package/dist/aws4fetch.esm-p7eEzLCs.js.map +0 -1
- package/dist/bytes-BXdamO3L.js +0 -11
- package/dist/bytes-BXdamO3L.js.map +0 -1
- package/dist/cloudflare-DzKBrUlg.js.map +0 -1
- package/dist/config-1tv0-Yzm.js +0 -2693
- package/dist/config-1tv0-Yzm.js.map +0 -1
- package/dist/constants-CfeMWQWk.js +0 -222
- package/dist/constants-CfeMWQWk.js.map +0 -1
- package/dist/context-DRZ3tZ5l.js.map +0 -1
- package/dist/cost-DSMIVqzL.js +0 -203
- package/dist/cost-DSMIVqzL.js.map +0 -1
- package/dist/current-json-C6nhPOm1.js.map +0 -1
- package/dist/db-DsPkOVEH.d.ts +0 -254
- package/dist/deploy-DonTr-CV.js.map +0 -1
- package/dist/doctor-DSIyCDg_.js +0 -346
- package/dist/doctor-DSIyCDg_.js.map +0 -1
- package/dist/dump-Bh5k26VQ.js +0 -94
- package/dist/dump-Bh5k26VQ.js.map +0 -1
- package/dist/errors-Dfa3p78c.js +0 -78
- package/dist/errors-Dfa3p78c.js.map +0 -1
- package/dist/export-DtF5tDIM.js +0 -401
- package/dist/export-DtF5tDIM.js.map +0 -1
- package/dist/fsck-D_djMO5D.js +0 -279
- package/dist/fsck-D_djMO5D.js.map +0 -1
- package/dist/http-DGd5tbNs.js.map +0 -1
- package/dist/index-0rZcMBwy.d.ts +0 -115
- package/dist/index-BNRh23K9.d.ts +0 -162
- package/dist/index-BYk9oCNf.d.ts +0 -1112
- package/dist/indexes-Dn9hbGQG.d.ts +0 -22
- package/dist/inspect-6WZ-pC7-.js +0 -133
- package/dist/inspect-6WZ-pC7-.js.map +0 -1
- package/dist/log-tail-D98U1JBo.js +0 -522
- package/dist/log-tail-D98U1JBo.js.map +0 -1
- package/dist/maintenance-B4Dki6Ig.js +0 -2157
- package/dist/maintenance-B4Dki6Ig.js.map +0 -1
- package/dist/maintenance-B_e0T99L.d.ts +0 -537
- package/dist/maintenance-C7coQp4c.js +0 -1418
- package/dist/maintenance-C7coQp4c.js.map +0 -1
- package/dist/normalize-rjnZLwS4.js +0 -133
- package/dist/normalize-rjnZLwS4.js.map +0 -1
- package/dist/observability-BmflLCdF.js.map +0 -1
- package/dist/plan-a7PJHBCy.js.map +0 -1
- package/dist/query-rAtXNQQB.js +0 -1773
- package/dist/query-rAtXNQQB.js.map +0 -1
- package/dist/rebuild-index-BVzQSZlm.js +0 -81
- package/dist/rebuild-index-BVzQSZlm.js.map +0 -1
- package/dist/request-u0M51mhJ.js +0 -72
- package/dist/request-u0M51mhJ.js.map +0 -1
- package/dist/restore-R-4rbciV.js +0 -778
- package/dist/restore-R-4rbciV.js.map +0 -1
- package/dist/rolldown-runtime-EAsCxrDo.js +0 -14
- package/dist/runtime-spec-Dsw2-n8S.js.map +0 -1
- package/dist/shared-secret-DgEicd3x.js.map +0 -1
- package/dist/src-BL_JoPTn.js.map +0 -1
- package/dist/src-CYHFDrKz.js +0 -536
- package/dist/src-CYHFDrKz.js.map +0 -1
- package/dist/src-DYZ4H1aF.js +0 -392
- package/dist/src-DYZ4H1aF.js.map +0 -1
- package/dist/subcommand-DoDA-K7d.js.map +0 -1
- package/dist/time-DUqvFMHq.js.map +0 -1
- package/dist/usage-DBV1eQHC.js.map +0 -1
- package/dist/validate-DtljsCh1.js.map +0 -1
- package/dist/wire-izfGZDvr.js.map +0 -1
package/dist/baerly.js
CHANGED
|
@@ -1,29 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { parseArgs } from "node:util";
|
|
3
|
-
|
|
4
|
-
var __create = Object.create;
|
|
5
|
-
var __defProp = Object.defineProperty;
|
|
6
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
-
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
13
|
-
key = keys[i];
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
|
-
get: ((k) => from[k]).bind(null, key),
|
|
16
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
return to;
|
|
20
|
-
};
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
22
|
-
value: mod,
|
|
23
|
-
enumerable: true
|
|
24
|
-
}) : target, mod));
|
|
25
|
-
//#endregion
|
|
26
|
-
//#region ../../node_modules/.pnpm/citty@0.2.2/node_modules/citty/dist/_chunks/libs/scule.mjs
|
|
2
|
+
import { parseArgs as parseArgs$1, styleText } from "node:util";
|
|
3
|
+
// ../../node_modules/.pnpm/citty@0.2.2/node_modules/citty/dist/_chunks/libs/scule.mjs
|
|
27
4
|
const NUMBER_CHAR_RE = /\d/;
|
|
28
5
|
const STR_SPLITTERS = [
|
|
29
6
|
"-",
|
|
@@ -91,8 +68,7 @@ function kebabCase(str, joiner) {
|
|
|
91
68
|
function snakeCase(str) {
|
|
92
69
|
return kebabCase(str || "", "_");
|
|
93
70
|
}
|
|
94
|
-
|
|
95
|
-
//#region ../../node_modules/.pnpm/citty@0.2.2/node_modules/citty/dist/index.mjs
|
|
71
|
+
// ../../node_modules/.pnpm/citty@0.2.2/node_modules/citty/dist/index.mjs
|
|
96
72
|
function toArray(val) {
|
|
97
73
|
if (Array.isArray(val)) return val;
|
|
98
74
|
return val === void 0 ? [] : [val];
|
|
@@ -173,7 +149,7 @@ function parseRawArgs(args = [], opts = {}) {
|
|
|
173
149
|
}
|
|
174
150
|
let parsed;
|
|
175
151
|
try {
|
|
176
|
-
parsed = parseArgs({
|
|
152
|
+
parsed = parseArgs$1({
|
|
177
153
|
args: processedArgs,
|
|
178
154
|
options: Object.keys(options).length > 0 ? options : void 0,
|
|
179
155
|
allowPositionals: true,
|
|
@@ -216,7 +192,7 @@ const bold = /* @__PURE__ */ _c(1, 22);
|
|
|
216
192
|
const cyan = /* @__PURE__ */ _c(36);
|
|
217
193
|
const gray = /* @__PURE__ */ _c(90);
|
|
218
194
|
const underline = /* @__PURE__ */ _c(4, 24);
|
|
219
|
-
function parseArgs
|
|
195
|
+
function parseArgs(rawArgs, argsDef) {
|
|
220
196
|
const parseOptions = {
|
|
221
197
|
boolean: [],
|
|
222
198
|
string: [],
|
|
@@ -240,7 +216,7 @@ function parseArgs$1(rawArgs, argsDef) {
|
|
|
240
216
|
}
|
|
241
217
|
}
|
|
242
218
|
const parsed = parseRawArgs(rawArgs, parseOptions);
|
|
243
|
-
const [
|
|
219
|
+
const [...positionalArguments] = parsed._;
|
|
244
220
|
const parsedArgsProxy = new Proxy(parsed, { get(target, prop) {
|
|
245
221
|
return target[prop] ?? target[camelCase(prop)] ?? target[kebabCase(prop)];
|
|
246
222
|
} });
|
|
@@ -273,7 +249,7 @@ function defineCommand(def) {
|
|
|
273
249
|
}
|
|
274
250
|
async function runCommand(cmd, opts) {
|
|
275
251
|
const cmdArgs = await resolveValue(cmd.args || {});
|
|
276
|
-
const parsedArgs = parseArgs
|
|
252
|
+
const parsedArgs = parseArgs(opts.rawArgs, cmdArgs);
|
|
277
253
|
const context = {
|
|
278
254
|
rawArgs: opts.rawArgs,
|
|
279
255
|
args: parsedArgs,
|
|
@@ -444,15 +420,25 @@ function renderDescription(arg, required) {
|
|
|
444
420
|
defaultHint
|
|
445
421
|
].filter(Boolean).join(" ");
|
|
446
422
|
}
|
|
447
|
-
|
|
448
|
-
|
|
423
|
+
// ../protocol/src/errors.ts
|
|
424
|
+
/**
|
|
425
|
+
* Codes whose failure can clear on retry. `BaerlyError.retriable` is
|
|
426
|
+
* exactly membership in this set; there are no per-instance overrides.
|
|
427
|
+
*/
|
|
428
|
+
const RETRIABLE_CODES = /* @__PURE__ */ new Set([
|
|
429
|
+
"NetworkError",
|
|
430
|
+
"WriteConflict",
|
|
431
|
+
"MaintenancePending"
|
|
432
|
+
]);
|
|
449
433
|
/**
|
|
450
|
-
*
|
|
451
|
-
*
|
|
452
|
-
*
|
|
434
|
+
* True iff `err` is a `WriteConflict`: a lost conditional write or CAS
|
|
435
|
+
* race. The one predicate every kernel catch site uses, so the code's
|
|
436
|
+
* meaning is tested in one place. Matches on `name` and `code` rather
|
|
437
|
+
* than `instanceof`, so an error from a second loaded copy of this module
|
|
438
|
+
* or another realm still classifies.
|
|
453
439
|
*/
|
|
454
|
-
const
|
|
455
|
-
/** True iff this error code
|
|
440
|
+
const isWriteConflict = (err) => typeof err === "object" && err !== null && err.name === "BaerlyError" && err.code === "WriteConflict";
|
|
441
|
+
/** True iff this error code is retriable (membership in {@link RETRIABLE_CODES}). */
|
|
456
442
|
const isRetriableCode = (code) => RETRIABLE_CODES.has(code);
|
|
457
443
|
/**
|
|
458
444
|
* The single error class thrown by baerly-storage. Discriminate by `code`, not
|
|
@@ -465,12 +451,18 @@ const isRetriableCode = (code) => RETRIABLE_CODES.has(code);
|
|
|
465
451
|
* @example
|
|
466
452
|
* ```ts
|
|
467
453
|
* try {
|
|
468
|
-
* await db.collection("tickets").insert({ title: "hi" });
|
|
454
|
+
* await db.collection("tickets").insert({ _id: "t-1", title: "hi" });
|
|
469
455
|
* } catch (err) {
|
|
470
|
-
* if (err instanceof BaerlyError
|
|
471
|
-
*
|
|
456
|
+
* if (!(err instanceof BaerlyError)) throw err;
|
|
457
|
+
* if (err.code === "AlreadyExists") {
|
|
458
|
+
* // t-1 is taken; retrying cannot succeed.
|
|
459
|
+
* } else if (err.code === "AmbiguousCommit") {
|
|
460
|
+
* // May have landed: re-read err._id before deciding.
|
|
461
|
+
* } else if (err.retriable) {
|
|
462
|
+
* // WriteConflict or NetworkError: retry with bounded backoff.
|
|
463
|
+
* } else {
|
|
464
|
+
* throw err;
|
|
472
465
|
* }
|
|
473
|
-
* throw err;
|
|
474
466
|
* }
|
|
475
467
|
* ```
|
|
476
468
|
*/
|
|
@@ -489,6 +481,14 @@ var BaerlyError = class extends Error {
|
|
|
489
481
|
*/
|
|
490
482
|
issues;
|
|
491
483
|
/**
|
|
484
|
+
* The `_id` of the row whose commit outcome is unknown, set only when
|
|
485
|
+
* `code === "AmbiguousCommit"`. For an auto-ID insert it is the minted
|
|
486
|
+
* id, so the caller can re-read the row and retry with the same `_id`
|
|
487
|
+
* rather than mint a second document. A missing row does not prove the
|
|
488
|
+
* write failed. The HTTP layer carries it in `HttpErrorEnvelope`.
|
|
489
|
+
*/
|
|
490
|
+
_id;
|
|
491
|
+
/**
|
|
492
492
|
* Raw HTTP status, set only by the client-side wire decoder when
|
|
493
493
|
* inflating an `HttpErrorEnvelope` into this class. Server-side
|
|
494
494
|
* throws never set it (the HTTP layer's `mapError` derives the
|
|
@@ -500,78 +500,64 @@ var BaerlyError = class extends Error {
|
|
|
500
500
|
status;
|
|
501
501
|
/** Canonical corrective action; crosses the wire via `HttpErrorEnvelope.error.resolution`. */
|
|
502
502
|
resolution;
|
|
503
|
-
|
|
503
|
+
/** Suggested delay in seconds before retrying; set only for `MaintenancePending`. Crosses the wire via `HttpErrorEnvelope.error.retryAfter` and the `Retry-After` header. */
|
|
504
|
+
retryAfter;
|
|
504
505
|
/**
|
|
505
|
-
*
|
|
506
|
-
*
|
|
506
|
+
* `true` iff re-running the operation from its read step can succeed:
|
|
507
|
+
* `NetworkError` (retry with backoff) and `WriteConflict` (re-read, then
|
|
508
|
+
* write again). A `Collection` / `Query` verb re-reads on every call, so
|
|
509
|
+
* calling it again is the retry; a blind resend of the same conditional
|
|
510
|
+
* `Storage` put loses again. A pure function of `code`
|
|
511
|
+
* ({@link isRetriableCode}): every instance of a code gives the same
|
|
512
|
+
* answer. `AmbiguousCommit` is `false` because the write may have landed;
|
|
513
|
+
* reconcile by `_id` first.
|
|
507
514
|
*/
|
|
508
515
|
get retriable() {
|
|
509
|
-
return
|
|
516
|
+
return isRetriableCode(this.code);
|
|
510
517
|
}
|
|
511
|
-
|
|
518
|
+
/**
|
|
519
|
+
* `code` and `message` are positional; everything else goes in `options`,
|
|
520
|
+
* as with `new Error(message, { cause })`. Passing an `Error` (or any
|
|
521
|
+
* non-options value) as the third argument does not compile; the
|
|
522
|
+
* options object is where `cause` goes.
|
|
523
|
+
*
|
|
524
|
+
* @example
|
|
525
|
+
* ```ts
|
|
526
|
+
* throw new BaerlyError("NetworkError", "PUT failed", { cause: err });
|
|
527
|
+
* throw new BaerlyError("AmbiguousCommit", "commit outcome unknown", { _id: "t-1" });
|
|
528
|
+
* ```
|
|
529
|
+
*/
|
|
530
|
+
constructor(code, message, options) {
|
|
512
531
|
super(message);
|
|
513
532
|
this.name = "BaerlyError";
|
|
514
533
|
this.code = code;
|
|
515
|
-
this.cause = cause;
|
|
516
|
-
|
|
534
|
+
this.cause = options?.cause;
|
|
535
|
+
const { issues, status, resolution, _id, retryAfter } = options ?? {};
|
|
517
536
|
if (issues !== void 0) this.issues = issues;
|
|
518
537
|
if (status !== void 0) this.status = status;
|
|
519
538
|
if (resolution !== void 0) this.resolution = resolution;
|
|
539
|
+
if (_id !== void 0) this._id = _id;
|
|
540
|
+
if (retryAfter !== void 0) this.retryAfter = retryAfter;
|
|
520
541
|
}
|
|
521
542
|
};
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
yellow: x,
|
|
541
|
-
blue: x,
|
|
542
|
-
magenta: x,
|
|
543
|
-
cyan: x,
|
|
544
|
-
white: x,
|
|
545
|
-
gray: x,
|
|
546
|
-
bgBlack: x,
|
|
547
|
-
bgRed: x,
|
|
548
|
-
bgGreen: x,
|
|
549
|
-
bgYellow: x,
|
|
550
|
-
bgBlue: x,
|
|
551
|
-
bgMagenta: x,
|
|
552
|
-
bgCyan: x,
|
|
553
|
-
bgWhite: x,
|
|
554
|
-
blackBright: x,
|
|
555
|
-
redBright: x,
|
|
556
|
-
greenBright: x,
|
|
557
|
-
yellowBright: x,
|
|
558
|
-
blueBright: x,
|
|
559
|
-
magentaBright: x,
|
|
560
|
-
cyanBright: x,
|
|
561
|
-
whiteBright: x,
|
|
562
|
-
bgBlackBright: x,
|
|
563
|
-
bgRedBright: x,
|
|
564
|
-
bgGreenBright: x,
|
|
565
|
-
bgYellowBright: x,
|
|
566
|
-
bgBlueBright: x,
|
|
567
|
-
bgMagentaBright: x,
|
|
568
|
-
bgCyanBright: x,
|
|
569
|
-
bgWhiteBright: x
|
|
570
|
-
};
|
|
571
|
-
};
|
|
572
|
-
module.exports = create();
|
|
573
|
-
module.exports.createColors = create;
|
|
574
|
-
})))(), 1);
|
|
543
|
+
// src/output.ts
|
|
544
|
+
/**
|
|
545
|
+
* Output contract for `baerly`. Two modes:
|
|
546
|
+
*
|
|
547
|
+
* - text (default): preserves the legacy `baerly <cmd>: <code>:
|
|
548
|
+
* <msg>\n` shape on stderr (asserted by `copy.test.ts`); stdout
|
|
549
|
+
* stays silent on success.
|
|
550
|
+
* - JSON (`--json`): one structured envelope per invocation —
|
|
551
|
+
* `{result,...}` on stdout for success, `{error:{code,message,
|
|
552
|
+
* command}}` on stderr for failure. Picked up by agents that
|
|
553
|
+
* drive the CLI programmatically.
|
|
554
|
+
*
|
|
555
|
+
* Detection of `--json` happens twice — once in `baerly.ts` before
|
|
556
|
+
* `runMain` (so a parse-time error from citty also honors the flag)
|
|
557
|
+
* and once inside each subcommand's `run` handler (so programmatic
|
|
558
|
+
* `runCopy` callers like `copy.test.ts` work without going through
|
|
559
|
+
* the entry).
|
|
560
|
+
*/
|
|
575
561
|
let jsonMode = false;
|
|
576
562
|
/** Toggle JSON-envelope output mode. Called from `baerly.ts` and each subcommand. */
|
|
577
563
|
const setJsonMode = (v) => {
|
|
@@ -580,13 +566,13 @@ const setJsonMode = (v) => {
|
|
|
580
566
|
const isJsonMode = () => jsonMode;
|
|
581
567
|
/**
|
|
582
568
|
* Color helpers — no-ops in JSON mode (so emitted JSON stays
|
|
583
|
-
* machine-parseable) and when `
|
|
569
|
+
* machine-parseable) and when `util.styleText` detects a non-TTY or
|
|
584
570
|
* `NO_COLOR`.
|
|
585
571
|
*/
|
|
586
572
|
const color = {
|
|
587
|
-
red: (s) => jsonMode ? s :
|
|
588
|
-
yellow: (s) => jsonMode ? s :
|
|
589
|
-
dim: (s) => jsonMode ? s :
|
|
573
|
+
red: (s) => jsonMode ? s : styleText("red", s),
|
|
574
|
+
yellow: (s) => jsonMode ? s : styleText("yellow", s),
|
|
575
|
+
dim: (s) => jsonMode ? s : styleText("dim", s)
|
|
590
576
|
};
|
|
591
577
|
/**
|
|
592
578
|
* Emit an error. Text mode preserves the legacy `baerly <cmd>:
|
|
@@ -628,8 +614,13 @@ const emitError = (command, code, message) => {
|
|
|
628
614
|
const emitSuccess = (data) => {
|
|
629
615
|
if (jsonMode) process.stdout.write(`${JSON.stringify({ result: data })}\n`);
|
|
630
616
|
};
|
|
631
|
-
|
|
632
|
-
|
|
617
|
+
/** Shared exit-code mapping for caught `BaerlyError`s. */
|
|
618
|
+
const errorToExitCode = (code) => {
|
|
619
|
+
if (code === "InvalidConfig") return 1;
|
|
620
|
+
if (code === "WriteConflict" || code === "AlreadyExists" || code === "Internal" || code === "InvalidResponse" || code === "AmbiguousCommit") return 3;
|
|
621
|
+
return 2;
|
|
622
|
+
};
|
|
623
|
+
// src/bin-runner.ts
|
|
633
624
|
/**
|
|
634
625
|
* `runBin` — bin-entry shim around citty 0.2.2's `runCommand`.
|
|
635
626
|
*
|
|
@@ -657,13 +648,8 @@ const emitSuccess = (data) => {
|
|
|
657
648
|
* …)` semantics.
|
|
658
649
|
* - Maps `BaerlyError.code` through the same 3-bucket exit-code
|
|
659
650
|
* table the per-subcommand wrappers use (`InvalidConfig → 1`,
|
|
660
|
-
* `
|
|
651
|
+
* `WriteConflict|AlreadyExists|Internal|InvalidResponse|AmbiguousCommit → 3`, else 2).
|
|
661
652
|
*/
|
|
662
|
-
const errorToExitCode = (code) => {
|
|
663
|
-
if (code === "InvalidConfig") return 1;
|
|
664
|
-
if (code === "Conflict" || code === "Internal" || code === "InvalidResponse") return 3;
|
|
665
|
-
return 2;
|
|
666
|
-
};
|
|
667
653
|
const resolve = async (v) => {
|
|
668
654
|
if (typeof v === "function") return v();
|
|
669
655
|
return v;
|
|
@@ -726,12 +712,14 @@ const runBin = async (cmd, argv, brand = "baerly") => {
|
|
|
726
712
|
emitError(brand, error.code, error.message);
|
|
727
713
|
process.exit(errorToExitCode(error.code));
|
|
728
714
|
}
|
|
729
|
-
|
|
715
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
716
|
+
emitError(brand, "InvalidConfig", message);
|
|
730
717
|
process.exit(1);
|
|
731
718
|
}
|
|
732
719
|
};
|
|
733
|
-
|
|
734
|
-
|
|
720
|
+
// ../../package.json
|
|
721
|
+
var version = "0.7.0";
|
|
722
|
+
// src/baerly.ts
|
|
735
723
|
/**
|
|
736
724
|
* `baerly` — vendorless document database CLI. Entry point bundled
|
|
737
725
|
* to `dist/baerly.js` by `rolldown.config.ts` with a `#!/usr/bin/env
|
|
@@ -748,34 +736,38 @@ const runBin = async (cmd, argv, brand = "baerly") => {
|
|
|
748
736
|
* Exit codes are documented in `packages/cli/README.md` and per-
|
|
749
737
|
* subcommand in each module's docstring.
|
|
750
738
|
*/
|
|
739
|
+
/**
|
|
740
|
+
* `baerly admin <command>` — operator-side reconciliation, inspection,
|
|
741
|
+
* data-shovel, and maintenance tools. Today: `dump`, `restore`,
|
|
742
|
+
* `fsck`, `usage`.
|
|
743
|
+
*/
|
|
744
|
+
const admin = defineCommand({
|
|
745
|
+
meta: {
|
|
746
|
+
name: "admin",
|
|
747
|
+
description: "Operator commands — reconciliation and inspection."
|
|
748
|
+
},
|
|
749
|
+
subCommands: {
|
|
750
|
+
dump: () => import("./dump-D1vX8ozg.js").then((m) => m.dumpCmd),
|
|
751
|
+
restore: () => import("./restore-U6Im8V1V.js").then((m) => m.restoreCmd),
|
|
752
|
+
fsck: () => import("./fsck-BWkPgov4.js").then((m) => m.fsckCmd),
|
|
753
|
+
usage: () => import("./usage-CPzVhrQr.js").then((m) => m.usageCmd)
|
|
754
|
+
}
|
|
755
|
+
});
|
|
751
756
|
runBin(defineCommand({
|
|
752
757
|
meta: {
|
|
753
758
|
name: "baerly",
|
|
754
|
-
version
|
|
759
|
+
version,
|
|
755
760
|
description: "Vendorless document database CLI."
|
|
756
761
|
},
|
|
757
762
|
subCommands: {
|
|
758
|
-
deploy: () => import("./deploy-
|
|
759
|
-
doctor: () => import("./doctor-
|
|
760
|
-
inspect: () => import("./inspect-
|
|
761
|
-
export: () => import("./export-
|
|
762
|
-
cost: () => import("./cost-
|
|
763
|
-
admin
|
|
764
|
-
meta: {
|
|
765
|
-
name: "admin",
|
|
766
|
-
description: "Operator commands — reconciliation and inspection."
|
|
767
|
-
},
|
|
768
|
-
subCommands: {
|
|
769
|
-
"rebuild-index": () => import("./rebuild-index-BVzQSZlm.js").then((m) => m.rebuildIndexCmd),
|
|
770
|
-
dump: () => import("./dump-Bh5k26VQ.js").then((m) => m.dumpCmd),
|
|
771
|
-
restore: () => import("./restore-R-4rbciV.js").then((m) => m.restoreCmd),
|
|
772
|
-
fsck: () => import("./fsck-D_djMO5D.js").then((m) => m.fsckCmd),
|
|
773
|
-
usage: () => import("./usage-DBV1eQHC.js").then((m) => m.usageCmd)
|
|
774
|
-
}
|
|
775
|
-
})
|
|
763
|
+
deploy: () => import("./deploy-Obj4nE-Z.js").then((m) => m.deploy),
|
|
764
|
+
doctor: () => import("./doctor-BA0i-YAN.js").then((m) => m.doctor),
|
|
765
|
+
inspect: () => import("./inspect-BTsVYZKd.js").then((m) => m.inspect),
|
|
766
|
+
export: () => import("./export-BVL2EvYE.js").then((m) => m.exportCmd),
|
|
767
|
+
cost: () => import("./cost-B52llVDx.js").then((m) => m.cost),
|
|
768
|
+
admin
|
|
776
769
|
}
|
|
777
770
|
}), process.argv.slice(2), "baerly");
|
|
778
|
-
|
|
779
|
-
export { setJsonMode as a, parseArgs$1 as c, isJsonMode as i, __commonJSMin as l, emitError as n, BaerlyError as o, emitSuccess as r, defineCommand as s, color as t };
|
|
771
|
+
export { isJsonMode as a, isWriteConflict as c, errorToExitCode as i, defineCommand as l, emitError as n, setJsonMode as o, emitSuccess as r, BaerlyError as s, color as t, parseArgs as u };
|
|
780
772
|
|
|
781
773
|
//# sourceMappingURL=baerly.js.map
|