@gusto/baerly-storage 0.2.0 → 0.4.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.
Files changed (155) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +29 -0
  3. package/README.md +176 -70
  4. package/dist/API.md +213 -139
  5. package/dist/CHANGELOG.md +434 -0
  6. package/dist/RECIPES.md +125 -0
  7. package/dist/THIRD-PARTY-LICENSES.txt +238 -0
  8. package/dist/{app-config-C0Bbw_Z6.d.ts → app-config-DyiFK3_k.d.ts} +55 -11
  9. package/dist/app-config.d.ts +1 -1
  10. package/dist/auth.d.ts +1 -1
  11. package/dist/auth.js +301 -301
  12. package/dist/auth.js.map +1 -1
  13. package/dist/aws4fetch.esm-p7eEzLCs.js +1702 -0
  14. package/dist/aws4fetch.esm-p7eEzLCs.js.map +1 -0
  15. package/dist/baerly.js +35 -15
  16. package/dist/baerly.js.map +1 -1
  17. package/dist/baerly.spec.json +342 -0
  18. package/dist/bytes-BXdamO3L.js.map +1 -1
  19. package/dist/{client-DYZfoZb9.d.ts → client-Fe8CwB73.d.ts} +10 -10
  20. package/dist/client-react.d.ts +3 -3
  21. package/dist/client-react.js +4 -4
  22. package/dist/client-react.js.map +1 -1
  23. package/dist/client.d.ts +4 -4
  24. package/dist/client.js +3 -3
  25. package/dist/client.js.map +1 -1
  26. package/dist/{cloudflare-CINJPKCW.js → cloudflare-DzKBrUlg.js} +178 -2
  27. package/dist/cloudflare-DzKBrUlg.js.map +1 -0
  28. package/dist/cloudflare.d.ts +49 -6
  29. package/dist/cloudflare.js +59 -26
  30. package/dist/cloudflare.js.map +1 -1
  31. package/dist/config-1tv0-Yzm.js +2693 -0
  32. package/dist/config-1tv0-Yzm.js.map +1 -0
  33. package/dist/constants-CfeMWQWk.js +222 -0
  34. package/dist/constants-CfeMWQWk.js.map +1 -0
  35. package/dist/context-DRZ3tZ5l.js.map +1 -1
  36. package/dist/{cost-CQt1YRkA.js → cost-DSMIVqzL.js} +43 -42
  37. package/dist/cost-DSMIVqzL.js.map +1 -0
  38. package/dist/current-json-C6nhPOm1.js +190 -0
  39. package/dist/current-json-C6nhPOm1.js.map +1 -0
  40. package/dist/{db-BM3y2JQw.d.ts → db-DsPkOVEH.d.ts} +26 -108
  41. package/dist/{deploy-CrAbfgCq.js → deploy-DonTr-CV.js} +12 -5
  42. package/dist/deploy-DonTr-CV.js.map +1 -0
  43. package/dist/dev-vite.d.ts +11 -7
  44. package/dist/dev-vite.js +7 -6
  45. package/dist/dev-vite.js.map +1 -1
  46. package/dist/dev.d.ts +1 -1
  47. package/dist/dev.js +1 -1
  48. package/dist/{doctor-Db-hzPmE.js → doctor-DSIyCDg_.js} +14 -136
  49. package/dist/doctor-DSIyCDg_.js.map +1 -0
  50. package/dist/{dump-BYA55NLP.js → dump-Bh5k26VQ.js} +10 -31
  51. package/dist/dump-Bh5k26VQ.js.map +1 -0
  52. package/dist/{errors-DOdL95kK.js → errors-Dfa3p78c.js} +25 -5
  53. package/dist/errors-Dfa3p78c.js.map +1 -0
  54. package/dist/{export-Bhbz90-z.js → export-DtF5tDIM.js} +11 -32
  55. package/dist/{export-Bhbz90-z.js.map → export-DtF5tDIM.js.map} +1 -1
  56. package/dist/{fsck-CPPZWt9p.js → fsck-D_djMO5D.js} +28 -39
  57. package/dist/fsck-D_djMO5D.js.map +1 -0
  58. package/dist/{http-Cw8p6y5b.js → http-DxM9MflO.js} +151 -79
  59. package/dist/http-DxM9MflO.js.map +1 -0
  60. package/dist/http.d.ts +42 -26
  61. package/dist/http.js +3 -2
  62. package/dist/{index-DwDTWPSU.d.ts → index-0rZcMBwy.d.ts} +10 -7
  63. package/dist/{index-C3JAH1Yo.d.ts → index-B6oexfOB.d.ts} +9 -9
  64. package/dist/{index-cUY-36AN.d.ts → index-BNRh23K9.d.ts} +21 -5
  65. package/dist/{index-DSvwEUeF.d.ts → index-BYk9oCNf.d.ts} +240 -202
  66. package/dist/index.d.ts +6 -6
  67. package/dist/index.js +5 -5
  68. package/dist/{indexes-DAu2AkTW.d.ts → indexes-Dn9hbGQG.d.ts} +2 -2
  69. package/dist/{inspect-Bdbzvi-_.js → inspect-6WZ-pC7-.js} +21 -36
  70. package/dist/inspect-6WZ-pC7-.js.map +1 -0
  71. package/dist/key-Di6yyxFu.js +35 -0
  72. package/dist/key-Di6yyxFu.js.map +1 -0
  73. package/dist/{snapshot-SS8USDUF.js → log-tail-D98U1JBo.js} +179 -84
  74. package/dist/log-tail-D98U1JBo.js.map +1 -0
  75. package/dist/{maintenance-ClzBC1Vv.js → maintenance-B4Dki6Ig.js} +438 -176
  76. package/dist/maintenance-B4Dki6Ig.js.map +1 -0
  77. package/dist/{maintenance-BRrThz8V.d.ts → maintenance-B_e0T99L.d.ts} +114 -26
  78. package/dist/{maintenance-BvOv6BMM.js → maintenance-C7coQp4c.js} +217 -94
  79. package/dist/maintenance-C7coQp4c.js.map +1 -0
  80. package/dist/maintenance.d.ts +3 -2
  81. package/dist/maintenance.js +3 -2
  82. package/dist/node.d.ts +176 -68
  83. package/dist/node.js +3 -2
  84. package/dist/{normalize-XWY25_sG.js → normalize-rjnZLwS4.js} +2 -2
  85. package/dist/normalize-rjnZLwS4.js.map +1 -0
  86. package/dist/{observability-CpOiEN0k.js → observability-wzs3-BL_.js} +279 -109
  87. package/dist/observability-wzs3-BL_.js.map +1 -0
  88. package/dist/observability.d.ts +3 -3
  89. package/dist/observability.js +1 -1
  90. package/dist/{plan-DOTl21vq.js → plan-a7PJHBCy.js} +7 -4
  91. package/dist/plan-a7PJHBCy.js.map +1 -0
  92. package/dist/{query-BmiQy328.js → query-rAtXNQQB.js} +1063 -1202
  93. package/dist/query-rAtXNQQB.js.map +1 -0
  94. package/dist/{rebuild-index-DC_nR6wP.js → rebuild-index-BVzQSZlm.js} +10 -32
  95. package/dist/rebuild-index-BVzQSZlm.js.map +1 -0
  96. package/dist/{request-BEF_OvMh.js → request-u0M51mhJ.js} +3 -3
  97. package/dist/{request-BEF_OvMh.js.map → request-u0M51mhJ.js.map} +1 -1
  98. package/dist/restore-R-4rbciV.js +778 -0
  99. package/dist/restore-R-4rbciV.js.map +1 -0
  100. package/dist/runtime-spec-qL3_lTTU.js +391 -0
  101. package/dist/runtime-spec-qL3_lTTU.js.map +1 -0
  102. package/dist/s3-http-B-z8th6O.d.ts +60 -0
  103. package/dist/s3.d.ts +47 -0
  104. package/dist/s3.js +45 -0
  105. package/dist/s3.js.map +1 -0
  106. package/dist/{shared-secret-BJdSwpgw.js → shared-secret-DgEicd3x.js} +13 -5
  107. package/dist/shared-secret-DgEicd3x.js.map +1 -0
  108. package/dist/src-BG20LZs7.js +2271 -0
  109. package/dist/src-BG20LZs7.js.map +1 -0
  110. package/dist/{src-zhEAmmF7.js → src-CYHFDrKz.js} +82 -99
  111. package/dist/src-CYHFDrKz.js.map +1 -0
  112. package/dist/{src-QQ7jDeL2.js → src-DYZ4H1aF.js} +44 -23
  113. package/dist/src-DYZ4H1aF.js.map +1 -0
  114. package/dist/subcommand-DoDA-K7d.js +197 -0
  115. package/dist/subcommand-DoDA-K7d.js.map +1 -0
  116. package/dist/time-DUqvFMHq.js +119 -0
  117. package/dist/time-DUqvFMHq.js.map +1 -0
  118. package/dist/{usage-CLjirdD-.js → usage-DBV1eQHC.js} +7 -22
  119. package/dist/usage-DBV1eQHC.js.map +1 -0
  120. package/dist/{validate-DCq_0DIn.js → validate-DtljsCh1.js} +51 -51
  121. package/dist/{validate-DCq_0DIn.js.map → validate-DtljsCh1.js.map} +1 -1
  122. package/dist/wire-izfGZDvr.js.map +1 -1
  123. package/package.json +77 -42
  124. package/dist/cloudflare-CINJPKCW.js.map +0 -1
  125. package/dist/config-DVfDGyw1.js +0 -278
  126. package/dist/config-DVfDGyw1.js.map +0 -1
  127. package/dist/cost-CQt1YRkA.js.map +0 -1
  128. package/dist/current-json-C-EyJqs0.js +0 -354
  129. package/dist/current-json-C-EyJqs0.js.map +0 -1
  130. package/dist/deploy-CrAbfgCq.js.map +0 -1
  131. package/dist/doctor-Db-hzPmE.js.map +0 -1
  132. package/dist/dump-BYA55NLP.js.map +0 -1
  133. package/dist/errors-DOdL95kK.js.map +0 -1
  134. package/dist/fsck-CPPZWt9p.js.map +0 -1
  135. package/dist/http-Cw8p6y5b.js.map +0 -1
  136. package/dist/inspect-Bdbzvi-_.js.map +0 -1
  137. package/dist/maintenance-BvOv6BMM.js.map +0 -1
  138. package/dist/maintenance-ClzBC1Vv.js.map +0 -1
  139. package/dist/normalize-XWY25_sG.js.map +0 -1
  140. package/dist/observability-CpOiEN0k.js.map +0 -1
  141. package/dist/plan-DOTl21vq.js.map +0 -1
  142. package/dist/query-BmiQy328.js.map +0 -1
  143. package/dist/rebuild-index-DC_nR6wP.js.map +0 -1
  144. package/dist/restore-C6IcmLeA.js +0 -771
  145. package/dist/restore-C6IcmLeA.js.map +0 -1
  146. package/dist/shared-secret-BJdSwpgw.js.map +0 -1
  147. package/dist/snapshot-SS8USDUF.js.map +0 -1
  148. package/dist/src-DU1sCMlr.js +0 -6236
  149. package/dist/src-DU1sCMlr.js.map +0 -1
  150. package/dist/src-QQ7jDeL2.js.map +0 -1
  151. package/dist/src-zhEAmmF7.js.map +0 -1
  152. package/dist/subcommand-DZcHcsYp.js +0 -5122
  153. package/dist/subcommand-DZcHcsYp.js.map +0 -1
  154. package/dist/usage-CLjirdD-.js.map +0 -1
  155. /package/dist/{chunk-EAsCxrDo.js → rolldown-runtime-EAsCxrDo.js} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aws4fetch.esm-p7eEzLCs.js","names":["#endpoint","#bucket","#fetch","#sign","#retries","#backoffMs","#dispatch","#objectUrl","#retry"],"sources":["../node_modules/.pnpm/@rgrove+parse-xml@4.2.1/node_modules/@rgrove/parse-xml/dist/browser.js","../packages/adapter-node/src/xml.ts","../packages/adapter-node/src/s3-http.ts","../node_modules/.pnpm/aws4fetch@1.0.20/node_modules/aws4fetch/dist/aws4fetch.esm.mjs"],"sourcesContent":["/*! @rgrove/parse-xml v4.2.1 | ISC License | Copyright Ryan Grove */\n\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\n\n// src/index.ts\nvar src_exports = {};\n__export(src_exports, {\n XmlCdata: () => XmlCdata,\n XmlComment: () => XmlComment,\n XmlDeclaration: () => XmlDeclaration,\n XmlDocument: () => XmlDocument,\n XmlDocumentType: () => XmlDocumentType,\n XmlElement: () => XmlElement,\n XmlError: () => XmlError,\n XmlNode: () => XmlNode,\n XmlProcessingInstruction: () => XmlProcessingInstruction,\n XmlText: () => XmlText,\n parseXml: () => parseXml\n});\nmodule.exports = __toCommonJS(src_exports);\n\n// src/lib/StringScanner.ts\nvar emptyString = \"\";\nvar surrogatePair = /[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]/g;\nvar StringScanner = class {\n constructor(string) {\n this.k = this.u(string, true);\n this.d = 0;\n this.length = string.length;\n this.l = this.k !== this.length;\n this.h = string;\n if (this.l) {\n let charsToBytes = [];\n for (let byteIndex = 0, charIndex = 0; charIndex < this.k; ++charIndex) {\n charsToBytes[charIndex] = byteIndex;\n byteIndex += string.codePointAt(byteIndex) > 65535 ? 2 : 1;\n }\n this.A = charsToBytes;\n }\n }\n /**\n * Whether the current character index is at the end of the input string.\n */\n get B() {\n return this.d >= this.k;\n }\n // -- Protected Methods ------------------------------------------------------\n /**\n * Returns the number of characters in the given string, which may differ from\n * the byte length if the string contains multibyte characters.\n */\n u(string, multiByteSafe = this.l) {\n return multiByteSafe ? string.replace(surrogatePair, \"_\").length : string.length;\n }\n // -- Public Methods ---------------------------------------------------------\n /**\n * Advances the scanner by the given number of characters, stopping if the end\n * of the string is reached.\n */\n p(count = 1) {\n this.d = Math.min(this.k, this.d + count);\n }\n /**\n * Returns the byte index of the given character index in the string. The two\n * may differ in strings that contain multibyte characters.\n */\n f(charIndex = this.d) {\n var _a;\n return this.l ? (_a = this.A[charIndex]) != null ? _a : Infinity : charIndex;\n }\n /**\n * Consumes and returns the given number of characters if possible, advancing\n * the scanner and stopping if the end of the string is reached.\n *\n * If no characters could be consumed, an empty string will be returned.\n */\n G(charCount = 1) {\n let chars = this.m(charCount);\n this.p(charCount);\n return chars;\n }\n /**\n * Consumes and returns the given number of bytes if possible, advancing the\n * scanner and stopping if the end of the string is reached.\n *\n * It's up to the caller to ensure that the given byte count doesn't split a\n * multibyte character.\n *\n * If no bytes could be consumed, an empty string will be returned.\n */\n v(byteCount) {\n let byteIndex = this.f();\n let result = this.h.slice(byteIndex, byteIndex + byteCount);\n this.p(this.u(result));\n return result;\n }\n /**\n * Consumes and returns all characters for which the given function returns\n * `true`, stopping when `false` is returned or the end of the input is\n * reached.\n */\n w(fn) {\n let { length, l: multiByteMode, h: string } = this;\n let startByteIndex = this.f();\n let endByteIndex = startByteIndex;\n if (multiByteMode) {\n while (endByteIndex < length) {\n let char = string[endByteIndex];\n let isSurrogatePair = char >= \"\\uD800\" && char <= \"\\uDBFF\";\n if (isSurrogatePair) {\n char += string[endByteIndex + 1];\n }\n if (!fn(char)) {\n break;\n }\n endByteIndex += isSurrogatePair ? 2 : 1;\n }\n } else {\n while (endByteIndex < length && fn(string[endByteIndex])) {\n ++endByteIndex;\n }\n }\n return this.v(endByteIndex - startByteIndex);\n }\n /**\n * Consumes the given string if it exists at the current character index, and\n * advances the scanner.\n *\n * If the given string doesn't exist at the current character index, an empty\n * string will be returned and the scanner will not be advanced.\n */\n b(stringToConsume) {\n let { length } = stringToConsume;\n let byteIndex = this.f();\n if (stringToConsume === this.h.slice(byteIndex, byteIndex + length)) {\n this.p(length === 1 ? 1 : this.u(stringToConsume));\n return stringToConsume;\n }\n return emptyString;\n }\n /**\n * Consumes characters until the given global regex is matched, advancing the\n * scanner up to (but not beyond) the beginning of the match. If the regex\n * doesn't match, nothing will be consumed.\n *\n * Returns the consumed string, or an empty string if nothing was consumed.\n */\n x(regex) {\n let matchByteIndex = this.h.slice(this.f()).search(regex);\n return matchByteIndex > 0 ? this.v(matchByteIndex) : emptyString;\n }\n /**\n * Consumes characters until the given string is found, advancing the scanner\n * up to (but not beyond) that point. If the string is never found, nothing\n * will be consumed.\n *\n * Returns the consumed string, or an empty string if nothing was consumed.\n */\n s(searchString) {\n let byteIndex = this.f();\n let matchByteIndex = this.h.indexOf(searchString, byteIndex);\n return matchByteIndex > 0 ? this.v(matchByteIndex - byteIndex) : emptyString;\n }\n /**\n * Returns the given number of characters starting at the current character\n * index, without advancing the scanner and without exceeding the end of the\n * input string.\n */\n m(count = 1) {\n let { d: charIndex, h: string } = this;\n return this.l ? string.slice(this.f(charIndex), this.f(charIndex + count)) : string.slice(charIndex, charIndex + count);\n }\n /**\n * Resets the scanner position to the given character _index_, or to the start\n * of the input string if no index is given.\n *\n * If _index_ is negative, the scanner position will be moved backward by that\n * many characters, stopping if the beginning of the string is reached.\n */\n n(index = 0) {\n this.d = index >= 0 ? Math.min(this.k, index) : Math.max(0, this.d + index);\n }\n};\n\n// src/lib/syntax.ts\nvar attValueCharDoubleQuote = /[\"&<]/;\nvar attValueCharSingleQuote = /['&<]/;\nvar attValueNormalizedWhitespace = /\\r\\n|[\\n\\r\\t]/g;\nvar endCharData = /<|&|]]>/;\nvar predefinedEntities = Object.freeze(Object.assign(/* @__PURE__ */ Object.create(null), {\n amp: \"&\",\n apos: \"'\",\n gt: \">\",\n lt: \"<\",\n quot: '\"'\n}));\nfunction isNameChar(char) {\n let cp = char.codePointAt(0);\n return cp >= 97 && cp <= 122 || cp >= 65 && cp <= 90 || cp >= 48 && cp <= 57 || cp === 45 || cp === 46 || cp === 183 || cp >= 768 && cp <= 879 || cp === 8255 || cp === 8256 || isNameStartChar(char, cp);\n}\nfunction isNameStartChar(char, cp = char.codePointAt(0)) {\n return cp >= 97 && cp <= 122 || cp >= 65 && cp <= 90 || cp === 58 || cp === 95 || cp >= 192 && cp <= 214 || cp >= 216 && cp <= 246 || cp >= 248 && cp <= 767 || cp >= 880 && cp <= 893 || cp >= 895 && cp <= 8191 || cp === 8204 || cp === 8205 || cp >= 8304 && cp <= 8591 || cp >= 11264 && cp <= 12271 || cp >= 12289 && cp <= 55295 || cp >= 63744 && cp <= 64975 || cp >= 65008 && cp <= 65533 || cp >= 65536 && cp <= 983039;\n}\nfunction isReferenceChar(char) {\n return char === \"#\" || isNameChar(char);\n}\nfunction isWhitespace(char) {\n let cp = char.codePointAt(0);\n return cp === 32 || cp === 9 || cp === 10 || cp === 13;\n}\nfunction isXmlCodePoint(cp) {\n return cp >= 32 && cp <= 55295 || cp === 10 || cp === 9 || cp === 13 || cp >= 57344 && cp <= 65533 || cp >= 65536 && cp <= 1114111;\n}\n\n// src/lib/XmlNode.ts\nvar _XmlNode = class _XmlNode {\n constructor() {\n /**\n * Parent node of this node, or `null` if this node has no parent.\n */\n this.parent = null;\n /**\n * Starting byte offset of this node in the original XML string, or `-1` if\n * the offset is unknown.\n */\n this.start = -1;\n /**\n * Ending byte offset of this node in the original XML string, or `-1` if the\n * offset is unknown.\n */\n this.end = -1;\n }\n /**\n * Document that contains this node, or `null` if this node is not associated\n * with a document.\n */\n get document() {\n var _a, _b;\n return (_b = (_a = this.parent) == null ? void 0 : _a.document) != null ? _b : null;\n }\n /**\n * Whether this node is the root node of the document (also known as the\n * document element).\n */\n get isRootNode() {\n return this.parent !== null && this.parent === this.document && this.type === _XmlNode.TYPE_ELEMENT;\n }\n /**\n * Whether whitespace should be preserved in the content of this element and\n * its children.\n *\n * This is influenced by the value of the special `xml:space` attribute, and\n * will be `true` for any node whose `xml:space` attribute is set to\n * \"preserve\". If a node has no such attribute, it will inherit the value of\n * the nearest ancestor that does (if any).\n *\n * @see https://www.w3.org/TR/2008/REC-xml-20081126/#sec-white-space\n */\n get preserveWhitespace() {\n var _a;\n return !!((_a = this.parent) == null ? void 0 : _a.preserveWhitespace);\n }\n /**\n * Type of this node.\n *\n * The value of this property is a string that matches one of the static\n * `TYPE_*` properties on the `XmlNode` class (e.g. `TYPE_ELEMENT`,\n * `TYPE_TEXT`, etc.).\n *\n * The `XmlNode` class itself is a base class and doesn't have its own type\n * name.\n */\n get type() {\n return \"\";\n }\n /**\n * Returns a JSON-serializable object representing this node, minus properties\n * that could result in circular references.\n */\n toJSON() {\n let json = {\n type: this.type\n };\n if (this.isRootNode) {\n json.isRootNode = true;\n }\n if (this.preserveWhitespace) {\n json.preserveWhitespace = true;\n }\n if (this.start !== -1) {\n json.start = this.start;\n json.end = this.end;\n }\n return json;\n }\n};\n/**\n * Type value for an `XmlCdata` node.\n */\n_XmlNode.TYPE_CDATA = \"cdata\";\n/**\n * Type value for an `XmlComment` node.\n */\n_XmlNode.TYPE_COMMENT = \"comment\";\n/**\n * Type value for an `XmlDocument` node.\n */\n_XmlNode.TYPE_DOCUMENT = \"document\";\n/**\n * Type value for an `XmlDocumentType` node.\n */\n_XmlNode.TYPE_DOCUMENT_TYPE = \"doctype\";\n/**\n * Type value for an `XmlElement` node.\n */\n_XmlNode.TYPE_ELEMENT = \"element\";\n/**\n * Type value for an `XmlProcessingInstruction` node.\n */\n_XmlNode.TYPE_PROCESSING_INSTRUCTION = \"pi\";\n/**\n * Type value for an `XmlText` node.\n */\n_XmlNode.TYPE_TEXT = \"text\";\n/**\n * Type value for an `XmlDeclaration` node.\n */\n_XmlNode.TYPE_XML_DECLARATION = \"xmldecl\";\nvar XmlNode = _XmlNode;\n\n// src/lib/XmlText.ts\nvar XmlText = class extends XmlNode {\n constructor(text = \"\") {\n super();\n this.text = text;\n }\n get type() {\n return XmlNode.TYPE_TEXT;\n }\n toJSON() {\n return Object.assign(XmlNode.prototype.toJSON.call(this), {\n text: this.text\n });\n }\n};\n\n// src/lib/XmlCdata.ts\nvar XmlCdata = class extends XmlText {\n get type() {\n return XmlNode.TYPE_CDATA;\n }\n};\n\n// src/lib/XmlComment.ts\nvar XmlComment = class extends XmlNode {\n constructor(content = \"\") {\n super();\n this.content = content;\n }\n get type() {\n return XmlNode.TYPE_COMMENT;\n }\n toJSON() {\n return Object.assign(XmlNode.prototype.toJSON.call(this), {\n content: this.content\n });\n }\n};\n\n// src/lib/XmlDeclaration.ts\nvar XmlDeclaration = class extends XmlNode {\n constructor(version, encoding, standalone) {\n super();\n this.version = version;\n this.encoding = encoding != null ? encoding : null;\n this.standalone = standalone != null ? standalone : null;\n }\n get type() {\n return XmlNode.TYPE_XML_DECLARATION;\n }\n toJSON() {\n let json = XmlNode.prototype.toJSON.call(this);\n json.version = this.version;\n for (let key of [\"encoding\", \"standalone\"]) {\n if (this[key] !== null) {\n json[key] = this[key];\n }\n }\n return json;\n }\n};\n\n// src/lib/XmlElement.ts\nvar XmlElement = class _XmlElement extends XmlNode {\n constructor(name, attributes = /* @__PURE__ */ Object.create(null), children = []) {\n super();\n this.name = name;\n this.attributes = attributes;\n this.children = children;\n }\n /**\n * Whether this element is empty (meaning it has no children).\n */\n get isEmpty() {\n return this.children.length === 0;\n }\n get preserveWhitespace() {\n let node = this;\n while (node instanceof _XmlElement) {\n if (\"xml:space\" in node.attributes) {\n return node.attributes[\"xml:space\"] === \"preserve\";\n }\n node = node.parent;\n }\n return false;\n }\n /**\n * Text content of this element and all its descendants.\n */\n get text() {\n return this.children.map((child) => \"text\" in child ? child.text : \"\").join(\"\");\n }\n get type() {\n return XmlNode.TYPE_ELEMENT;\n }\n toJSON() {\n return Object.assign(XmlNode.prototype.toJSON.call(this), {\n name: this.name,\n attributes: this.attributes,\n children: this.children.map((child) => child.toJSON())\n });\n }\n};\n\n// src/lib/XmlDocument.ts\nvar XmlDocument = class extends XmlNode {\n constructor(children = []) {\n super();\n this.children = children;\n }\n get document() {\n return this;\n }\n /**\n * Root element of this document, or `null` if this document is empty.\n */\n get root() {\n for (let child of this.children) {\n if (child instanceof XmlElement) {\n return child;\n }\n }\n return null;\n }\n /**\n * Text content of this document and all its descendants.\n */\n get text() {\n return this.children.map((child) => \"text\" in child ? child.text : \"\").join(\"\");\n }\n get type() {\n return XmlNode.TYPE_DOCUMENT;\n }\n toJSON() {\n return Object.assign(XmlNode.prototype.toJSON.call(this), {\n children: this.children.map((child) => child.toJSON())\n });\n }\n};\n\n// src/lib/XmlDocumentType.ts\nvar XmlDocumentType = class extends XmlNode {\n constructor(name, publicId, systemId, internalSubset) {\n super();\n this.name = name;\n this.publicId = publicId != null ? publicId : null;\n this.systemId = systemId != null ? systemId : null;\n this.internalSubset = internalSubset != null ? internalSubset : null;\n }\n get type() {\n return XmlNode.TYPE_DOCUMENT_TYPE;\n }\n toJSON() {\n let json = XmlNode.prototype.toJSON.call(this);\n json.name = this.name;\n for (let key of [\"publicId\", \"systemId\", \"internalSubset\"]) {\n if (this[key] !== null) {\n json[key] = this[key];\n }\n }\n return json;\n }\n};\n\n// src/lib/XmlError.ts\nvar XmlError = class extends Error {\n constructor(message, charIndex, xml) {\n let column = 1;\n let excerpt = \"\";\n let line = 1;\n for (let i = 0; i < charIndex; ++i) {\n let char = xml[i];\n if (char === \"\\n\") {\n column = 1;\n excerpt = \"\";\n line += 1;\n } else {\n column += 1;\n excerpt += char;\n }\n }\n let eol = xml.indexOf(\"\\n\", charIndex);\n excerpt += eol === -1 ? xml.slice(charIndex) : xml.slice(charIndex, eol);\n let excerptStart = 0;\n if (excerpt.length > 50) {\n if (column < 40) {\n excerpt = excerpt.slice(0, 50);\n } else {\n excerptStart = column - 20;\n excerpt = excerpt.slice(excerptStart, column + 30);\n }\n }\n super(\n `${message} (line ${line}, column ${column})\n ${excerpt}\n` + \" \".repeat(column - excerptStart + 1) + \"^\\n\"\n );\n this.column = column;\n this.excerpt = excerpt;\n this.line = line;\n this.name = \"XmlError\";\n this.pos = charIndex;\n }\n};\n\n// src/lib/XmlProcessingInstruction.ts\nvar XmlProcessingInstruction = class extends XmlNode {\n constructor(name, content = \"\") {\n super();\n this.name = name;\n this.content = content;\n }\n get type() {\n return XmlNode.TYPE_PROCESSING_INSTRUCTION;\n }\n toJSON() {\n return Object.assign(XmlNode.prototype.toJSON.call(this), {\n name: this.name,\n content: this.content\n });\n }\n};\n\n// src/lib/Parser.ts\nvar emptyString2 = \"\";\nvar Parser = class {\n /**\n * @param xml XML string to parse.\n * @param options Parser options.\n */\n constructor(xml, options = {}) {\n let doc = this.document = new XmlDocument();\n this.j = doc;\n this.g = options;\n this.c = new StringScanner(xml);\n if (this.g.includeOffsets) {\n doc.start = 0;\n doc.end = xml.length;\n }\n this.parse();\n }\n /**\n * Adds the given `XmlNode` as a child of `this.currentNode`.\n */\n i(node, charIndex) {\n node.parent = this.j;\n if (this.g.includeOffsets) {\n node.start = this.c.f(charIndex);\n node.end = this.c.f();\n }\n this.j.children.push(node);\n return true;\n }\n /**\n * Adds the given _text_ to the document, either by appending it to a\n * preceding `XmlText` node (if possible) or by creating a new `XmlText` node.\n *\n * When _normalize_ is `true` (the default), line breaks in _text_ are\n * normalized per section 2.11 of the XML spec. This must be `false` for text\n * that comes from a character or entity reference, since references aren't\n * subject to line break normalization.\n */\n y(text, charIndex, normalize = true) {\n let { children } = this.j;\n let { length } = children;\n if (normalize) {\n text = normalizeLineBreaks(text);\n }\n if (length > 0) {\n let prevNode = children[length - 1];\n if ((prevNode == null ? void 0 : prevNode.type) === XmlNode.TYPE_TEXT) {\n let textNode = prevNode;\n textNode.text += text;\n if (this.g.includeOffsets) {\n textNode.end = this.c.f();\n }\n return true;\n }\n }\n return this.i(new XmlText(text), charIndex);\n }\n /**\n * Consumes element attributes.\n *\n * @see https://www.w3.org/TR/2008/REC-xml-20081126/#sec-starttags\n */\n H() {\n let attributes = /* @__PURE__ */ Object.create(null);\n while (this.e()) {\n let attrName = this.q();\n if (!attrName) {\n break;\n }\n let attrValue = this.t() && this.I();\n if (attrValue === false) {\n throw this.a(\"Attribute value expected\");\n }\n if (attrName in attributes) {\n throw this.a(`Duplicate attribute: ${attrName}`);\n }\n if (attrName === \"xml:space\" && attrValue !== \"default\" && attrValue !== \"preserve\") {\n throw this.a('Value of the `xml:space` attribute must be \"default\" or \"preserve\"');\n }\n attributes[attrName] = attrValue;\n }\n if (this.g.sortAttributes) {\n let attrNames = Object.keys(attributes).sort();\n let sortedAttributes = /* @__PURE__ */ Object.create(null);\n for (let i = 0; i < attrNames.length; ++i) {\n let attrName = attrNames[i];\n sortedAttributes[attrName] = attributes[attrName];\n }\n attributes = sortedAttributes;\n }\n return attributes;\n }\n /**\n * Consumes an `AttValue` (attribute value) if possible.\n *\n * @returns\n * Contents of the `AttValue` minus quotes, or `false` if nothing was\n * consumed. An empty string indicates that an `AttValue` was consumed but\n * was empty.\n *\n * @see https://www.w3.org/TR/2008/REC-xml-20081126/#NT-AttValue\n */\n I() {\n let { c: scanner } = this;\n let quote = scanner.m();\n if (quote !== '\"' && quote !== \"'\") {\n return false;\n }\n scanner.p();\n let chars;\n let isClosed = false;\n let value = emptyString2;\n let regex = quote === '\"' ? attValueCharDoubleQuote : attValueCharSingleQuote;\n matchLoop: while (!scanner.B) {\n chars = scanner.x(regex);\n if (chars) {\n this.o(chars);\n value += chars.replace(attValueNormalizedWhitespace, \" \");\n }\n switch (scanner.m()) {\n case quote:\n isClosed = true;\n break matchLoop;\n case \"&\":\n value += this.C();\n continue;\n case \"<\":\n throw this.a(\"Unescaped `<` is not allowed in an attribute value\");\n default:\n break matchLoop;\n }\n }\n if (!isClosed) {\n throw this.a(\"Unclosed attribute\");\n }\n scanner.p();\n return value;\n }\n /**\n * Consumes a CDATA section if possible.\n *\n * @returns Whether a CDATA section was consumed.\n * @see https://www.w3.org/TR/2008/REC-xml-20081126/#sec-cdata-sect\n */\n J() {\n let { c: scanner } = this;\n let startIndex = scanner.d;\n if (!scanner.b(\"<![CDATA[\")) {\n return false;\n }\n let text = scanner.s(\"]]>\");\n this.o(text);\n if (!scanner.b(\"]]>\")) {\n throw this.a(\"Unclosed CDATA section\");\n }\n return this.g.preserveCdata ? this.i(new XmlCdata(normalizeLineBreaks(text)), startIndex) : this.y(text, startIndex);\n }\n /**\n * Consumes character data if possible.\n *\n * @returns Whether character data was consumed.\n * @see https://www.w3.org/TR/2008/REC-xml-20081126/#dt-chardata\n */\n K() {\n let { c: scanner } = this;\n let startIndex = scanner.d;\n let charData = scanner.x(endCharData);\n if (!charData) {\n return false;\n }\n this.o(charData);\n if (scanner.m(3) === \"]]>\") {\n throw this.a(\"Element content may not contain the CDATA section close delimiter `]]>`\");\n }\n return this.y(charData, startIndex);\n }\n /**\n * Consumes a comment if possible.\n *\n * @returns Whether a comment was consumed.\n * @see https://www.w3.org/TR/2008/REC-xml-20081126/#NT-Comment\n */\n D() {\n let { c: scanner } = this;\n let startIndex = scanner.d;\n if (!scanner.b(\"<!--\")) {\n return false;\n }\n let content = scanner.s(\"--\");\n this.o(content);\n if (!scanner.b(\"-->\")) {\n if (scanner.m(2) === \"--\") {\n throw this.a(\"The string `--` isn't allowed inside a comment\");\n }\n throw this.a(\"Unclosed comment\");\n }\n return this.g.preserveComments ? this.i(new XmlComment(normalizeLineBreaks(content)), startIndex) : true;\n }\n /**\n * Consumes a reference in a content context if possible.\n *\n * This differs from `consumeReference()` in that a consumed reference will be\n * added to the document as a text node instead of returned.\n *\n * @returns Whether a reference was consumed.\n * @see https://www.w3.org/TR/2008/REC-xml-20081126/#entproc\n */\n L() {\n let startIndex = this.c.d;\n let ref = this.C();\n return ref ? this.y(ref, startIndex, false) : false;\n }\n /**\n * Consumes a doctype declaration if possible.\n *\n * This is a loose implementation since doctype declarations are currently\n * discarded without further parsing.\n *\n * @returns Whether a doctype declaration was consumed.\n * @see https://www.w3.org/TR/2008/REC-xml-20081126/#dtd\n */\n M() {\n let { c: scanner } = this;\n let startIndex = scanner.d;\n if (!scanner.b(\"<!DOCTYPE\")) {\n return false;\n }\n let name = this.e() && this.q();\n if (!name) {\n throw this.a(\"Expected a name\");\n }\n let publicId;\n let systemId;\n if (this.e()) {\n if (scanner.b(\"PUBLIC\")) {\n publicId = this.e() && this.N();\n if (publicId === false) {\n throw this.a(\"Expected a public identifier\");\n }\n this.e();\n }\n if (publicId !== void 0 || scanner.b(\"SYSTEM\")) {\n this.e();\n systemId = this.r();\n if (systemId === false) {\n throw this.a(\"Expected a system identifier\");\n }\n this.e();\n }\n }\n let internalSubset;\n if (scanner.b(\"[\")) {\n internalSubset = scanner.x(/\\][\\x20\\t\\r\\n]*>/);\n if (!scanner.b(\"]\")) {\n throw this.a(\"Unclosed internal subset\");\n }\n this.e();\n }\n if (!scanner.b(\">\")) {\n throw this.a(\"Unclosed doctype declaration\");\n }\n return this.g.preserveDocumentType ? this.i(new XmlDocumentType(name, publicId, systemId, internalSubset), startIndex) : true;\n }\n /**\n * Consumes an element if possible.\n *\n * @returns Whether an element was consumed.\n * @see https://www.w3.org/TR/2008/REC-xml-20081126/#NT-element\n */\n E() {\n let { c: scanner } = this;\n let startIndex = scanner.d;\n if (!scanner.b(\"<\")) {\n return false;\n }\n let name = this.q();\n if (!name) {\n scanner.n(startIndex);\n return false;\n }\n let attributes = this.H();\n let isEmpty = !!scanner.b(\"/>\");\n let element = new XmlElement(name, attributes);\n element.parent = this.j;\n if (!isEmpty) {\n if (!scanner.b(\">\")) {\n throw this.a(`Unclosed start tag for element \\`${name}\\``);\n }\n this.j = element;\n do {\n this.K();\n } while (this.E() || this.L() || this.J() || this.F() || this.D());\n let endTagMark = scanner.d;\n let endTagName;\n if (!scanner.b(\"</\") || !(endTagName = this.q()) || endTagName !== name) {\n scanner.n(endTagMark);\n throw this.a(`Missing end tag for element ${name}`);\n }\n this.e();\n if (!scanner.b(\">\")) {\n throw this.a(`Unclosed end tag for element ${name}`);\n }\n this.j = element.parent;\n }\n return this.i(element, startIndex);\n }\n /**\n * Consumes an `Eq` production if possible.\n *\n * @returns Whether an `Eq` production was consumed.\n * @see https://www.w3.org/TR/2008/REC-xml-20081126/#NT-Eq\n */\n t() {\n this.e();\n if (this.c.b(\"=\")) {\n this.e();\n return true;\n }\n return false;\n }\n /**\n * Consumes `Misc` content if possible.\n *\n * @returns Whether anything was consumed.\n * @see https://www.w3.org/TR/2008/REC-xml-20081126/#NT-Misc\n */\n z() {\n return this.D() || this.F() || this.e();\n }\n /**\n * Consumes one or more `Name` characters if possible.\n *\n * @returns `Name` characters, or an empty string if none were consumed.\n * @see https://www.w3.org/TR/2008/REC-xml-20081126/#NT-Name\n */\n q() {\n return isNameStartChar(this.c.m()) ? this.c.w(isNameChar) : emptyString2;\n }\n /**\n * Consumes a processing instruction if possible.\n *\n * @returns Whether a processing instruction was consumed.\n * @see https://www.w3.org/TR/2008/REC-xml-20081126/#sec-pi\n */\n F() {\n let { c: scanner } = this;\n let startIndex = scanner.d;\n if (!scanner.b(\"<?\")) {\n return false;\n }\n let name = this.q();\n if (name) {\n if (name.toLowerCase() === \"xml\") {\n scanner.n(startIndex);\n throw this.a(\"XML declaration isn't allowed here\");\n }\n } else {\n throw this.a(\"Invalid processing instruction\");\n }\n if (!this.e()) {\n if (scanner.b(\"?>\")) {\n return this.i(new XmlProcessingInstruction(name), startIndex);\n }\n throw this.a(\"Whitespace is required after a processing instruction name\");\n }\n let content = scanner.s(\"?>\");\n this.o(content);\n if (!scanner.b(\"?>\")) {\n throw this.a(\"Unterminated processing instruction\");\n }\n return this.i(new XmlProcessingInstruction(name, normalizeLineBreaks(content)), startIndex);\n }\n /**\n * Consumes a prolog if possible.\n *\n * @returns Whether a prolog was consumed.\n * @see https://www.w3.org/TR/2008/REC-xml-20081126/#sec-prolog-dtd\n */\n O() {\n let { c: scanner } = this;\n let startIndex = scanner.d;\n this.P();\n while (this.z()) {\n }\n if (this.M()) {\n while (this.z()) {\n }\n }\n return startIndex < scanner.d;\n }\n /**\n * Consumes a public identifier literal if possible.\n *\n * @returns\n * Value of the public identifier literal minus quotes, or `false` if\n * nothing was consumed. An empty string indicates that a public id literal\n * was consumed but was empty.\n *\n * @see https://www.w3.org/TR/2008/REC-xml-20081126/#NT-PubidLiteral\n */\n N() {\n let startIndex = this.c.d;\n let value = this.r();\n if (value !== false && !/^[-\\x20\\r\\na-zA-Z0-9'()+,./:=?;!*#@$_%]*$/.test(value)) {\n this.c.n(startIndex);\n throw this.a(\"Invalid character in public identifier\");\n }\n return value;\n }\n /**\n * Consumes a reference if possible.\n *\n * This differs from `consumeContentReference()` in that a consumed reference\n * will be returned rather than added to the document.\n *\n * @returns\n * Parsed reference value, or `false` if nothing was consumed (to\n * distinguish from a reference that resolves to an empty string).\n *\n * @see https://www.w3.org/TR/2008/REC-xml-20081126/#NT-Reference\n */\n C() {\n let { c: scanner } = this;\n if (!scanner.b(\"&\")) {\n return false;\n }\n let ref = scanner.w(isReferenceChar);\n if (scanner.G() !== \";\") {\n throw this.a(\"Unterminated reference (a reference must end with `;`)\");\n }\n let parsedValue;\n if (ref[0] === \"#\") {\n let codePoint = ref[1] === \"x\" ? parseInt(ref.slice(2), 16) : parseInt(ref.slice(1), 10);\n if (isNaN(codePoint)) {\n throw this.a(\"Invalid character reference\");\n }\n if (!isXmlCodePoint(codePoint)) {\n throw this.a(\"Character reference resolves to an invalid character\");\n }\n parsedValue = String.fromCodePoint(codePoint);\n } else {\n parsedValue = predefinedEntities[ref];\n if (parsedValue === void 0) {\n let {\n ignoreUndefinedEntities,\n resolveUndefinedEntity\n } = this.g;\n let wrappedRef = `&${ref};`;\n if (resolveUndefinedEntity) {\n let resolvedValue = resolveUndefinedEntity(wrappedRef);\n if (resolvedValue !== null && resolvedValue !== void 0) {\n let type = typeof resolvedValue;\n if (type !== \"string\") {\n throw new TypeError(`\\`resolveUndefinedEntity()\\` must return a string, \\`null\\`, or \\`undefined\\`, but returned a value of type ${type}`);\n }\n return resolvedValue;\n }\n }\n if (ignoreUndefinedEntities) {\n return wrappedRef;\n }\n scanner.n(-wrappedRef.length);\n throw this.a(`Named entity isn't defined: ${wrappedRef}`);\n }\n }\n return parsedValue;\n }\n /**\n * Consumes a `SystemLiteral` if possible.\n *\n * A `SystemLiteral` is similar to an attribute value, but allows the\n * characters `<` and `&` and doesn't replace references.\n *\n * @returns\n * Value of the `SystemLiteral` minus quotes, or `false` if nothing was\n * consumed. An empty string indicates that a `SystemLiteral` was consumed\n * but was empty.\n *\n * @see https://www.w3.org/TR/2008/REC-xml-20081126/#NT-SystemLiteral\n */\n r() {\n let { c: scanner } = this;\n let quote = scanner.b('\"') || scanner.b(\"'\");\n if (!quote) {\n return false;\n }\n let value = scanner.s(quote);\n this.o(value);\n if (!scanner.b(quote)) {\n throw this.a(\"Missing end quote\");\n }\n return value;\n }\n /**\n * Consumes one or more whitespace characters if possible.\n *\n * @returns Whether any whitespace characters were consumed.\n * @see https://www.w3.org/TR/2008/REC-xml-20081126/#white\n */\n e() {\n return !!this.c.w(isWhitespace);\n }\n /**\n * Consumes an XML declaration if possible.\n *\n * @returns Whether an XML declaration was consumed.\n * @see https://www.w3.org/TR/2008/REC-xml-20081126/#NT-XMLDecl\n */\n P() {\n let { c: scanner } = this;\n let startIndex = scanner.d;\n if (!scanner.b(\"<?xml\")) {\n return false;\n }\n if (!this.e()) {\n throw this.a(\"Invalid XML declaration\");\n }\n let version = !!scanner.b(\"version\") && this.t() && this.r();\n if (version === false) {\n throw this.a(\"XML version is missing or invalid\");\n } else if (!/^1\\.[0-9]+$/.test(version)) {\n throw this.a(\"Invalid character in version number\");\n }\n let encoding;\n let standalone;\n if (this.e()) {\n encoding = !!scanner.b(\"encoding\") && this.t() && this.r();\n if (encoding) {\n if (!/^[A-Za-z][\\w.-]*$/.test(encoding)) {\n throw this.a(\"Invalid character in encoding name\");\n }\n this.e();\n }\n standalone = !!scanner.b(\"standalone\") && this.t() && this.r();\n if (standalone) {\n if (standalone !== \"yes\" && standalone !== \"no\") {\n throw this.a('Only \"yes\" and \"no\" are permitted as values of `standalone`');\n }\n this.e();\n }\n }\n if (!scanner.b(\"?>\")) {\n throw this.a(\"Invalid or unclosed XML declaration\");\n }\n return this.g.preserveXmlDeclaration ? this.i(new XmlDeclaration(\n version,\n encoding || void 0,\n standalone || void 0\n ), startIndex) : true;\n }\n /**\n * Returns an `XmlError` for the current scanner position.\n */\n a(message) {\n let { c: scanner } = this;\n return new XmlError(message, scanner.d, scanner.h);\n }\n /**\n * Parses the XML input.\n */\n parse() {\n this.c.b(\"\\uFEFF\");\n this.O();\n if (!this.E()) {\n throw this.a(\"Root element is missing or invalid\");\n }\n while (this.z()) {\n }\n if (!this.c.B) {\n throw this.a(\"Extra content at the end of the document\");\n }\n }\n /**\n * Throws an invalid character error if any character in the given _string_\n * isn't a valid XML character.\n */\n o(string) {\n let { length } = string;\n for (let i = 0; i < length; ++i) {\n let cp = string.codePointAt(i);\n if (!isXmlCodePoint(cp)) {\n this.c.n(-([...string].length - i));\n throw this.a(\"Invalid character\");\n }\n if (cp > 65535) {\n i += 1;\n }\n }\n }\n};\nfunction normalizeLineBreaks(text) {\n let i = 0;\n while ((i = text.indexOf(\"\\r\", i)) !== -1) {\n text = text[i + 1] === \"\\n\" ? text.slice(0, i) + text.slice(i + 1) : text.slice(0, i) + \"\\n\" + text.slice(i + 1);\n }\n return text;\n}\n\n// src/index.ts\nfunction parseXml(xml, options) {\n return new Parser(xml, options).document;\n}\n//# sourceMappingURL=browser.js.map\n","import { BaerlyError } from \"@baerly/protocol\";\nimport { parseXml, type XmlDocument, type XmlElement, type XmlText } from \"@rgrove/parse-xml\";\n\n/**\n * Subset of S3's `ListObjectsV2CommandOutput` produced by\n * {@link parseListObjectsV2CommandOutput}. Field names mirror the\n * S3 REST API exactly (PascalCase) so the parser stays a thin shape\n * over the wire format.\n */\nexport interface ParsedListObjectsV2Output {\n Contents?: Array<{ ETag?: string; Key?: string; LastModified?: Date }>;\n NextContinuationToken?: string;\n}\n\n/**\n * `<Code>` / `<Message>` extracted from an S3\n * `<Error>…</Error>` response body by {@link parseS3Error}. Field\n * names mirror the S3 REST API (PascalCase), matching the convention\n * of {@link ParsedListObjectsV2Output}.\n */\nexport interface ParsedS3Error {\n Code?: string;\n Message?: string;\n}\n\n// --- parse-xml helpers ---\n\n// Strip any namespace prefix: \"s3:Contents\" -> \"Contents\", \"Contents\" -> \"Contents\".\n// The `includes(\":\")` guard makes the `split(\":\")[1]!` non-null assertion safe.\nconst localName = (name: string): string => (name.includes(\":\") ? name.split(\":\")[1]! : name);\n\n// Type predicates narrowing an XmlNode child to a concrete node class.\n// @rgrove/parse-xml types the `type` discriminant as `string` (not a string\n// literal), so `node.type === \"element\"` does NOT narrow the child union on its\n// own. These localize the one unavoidable assertion behind a checked predicate\n// instead of scattering `as XmlElement` / `as XmlText` casts at each use site.\nconst isElement = (node: XmlElement[\"children\"][number]): node is XmlElement =>\n node.type === \"element\";\nconst isText = (node: XmlElement[\"children\"][number]): node is XmlText => node.type === \"text\";\n\n// Return the first XmlElement child of a document or element whose local name\n// (after any namespace prefix) matches `name`. This makes traversal\n// namespace-agnostic: both `<Error>` and `<ns:Error>` match name \"Error\".\nconst child = (el: XmlElement, name: string): XmlElement | undefined => {\n for (const node of el.children) {\n if (isElement(node) && localName(node.name) === name) {\n return node;\n }\n }\n return undefined;\n};\n\n// Concatenate the direct text child node text values of an element.\n// @rgrove/parse-xml resolves the 5 predefined XML entities (&amp; &lt; &gt;\n// &quot; &apos;) and decimal/hex numeric character references (e.g. Minio's\n// &#34; ETags) by default. Under the default `preserveCdata: false` (which is\n// how we call parseXml), any CDATA section is merged into the element's adjacent\n// text nodes and surfaces as an XmlText (type \"text\"), so the \"text\" branch\n// captures it — there is never a standalone \"cdata\" node. Entities inside a\n// CDATA section are NOT decoded (CDATA is literal), which is the correct S3\n// behavior. We intentionally do NOT decode HTML named entities (&nbsp; etc.) —\n// S3 wire data is XML, not HTML, so this is more spec-correct.\nconst textOf = (el: XmlElement | undefined): string | undefined => {\n if (el === undefined) {\n return undefined;\n }\n let result = \"\";\n for (const node of el.children) {\n if (isText(node)) {\n result += node.text;\n }\n }\n return result === \"\" ? undefined : result;\n};\n\n// Return the first-element-child of an XmlDocument. Unlike `XmlDocument.root`\n// (which is an XmlElement | null getter), this avoids potential null handling\n// confusion by returning undefined on an empty document.\nconst docRoot = (doc: XmlDocument): XmlElement | undefined => doc.root ?? undefined;\n\n// The list request sets `encoding-type=url`, so S3 URL-encodes the **key\n// family only** (Key/Prefix/Delimiter/StartAfter) in the response,\n// including spaces as `+`. Use this to reverse both steps. Do NOT apply it\n// to ETag or NextContinuationToken — S3 leaves those verbatim, and a\n// continuation token routinely contains literal `+` that the `.replace`\n// step would mangle into a space (corrupting pagination on large buckets).\nconst xmlVal = (el: XmlElement | undefined, name: string): string | undefined => {\n const v = el !== undefined ? textOf(child(el, name)) : undefined;\n if (v === undefined || v === \"\") {\n return undefined;\n }\n // A well-formed encoding-type=url response only ever contains valid\n // percent-escapes. A bare `%` or an invalid pair (`%ZZ`) makes\n // decodeURIComponent throw a raw URIError — catch it and re-raise as a\n // typed BaerlyError so the storage layer surfaces a catchable error rather\n // than an unhandled runtime exception. See docs/spec/s3-xml-escaping-cases.md.\n try {\n return decodeURIComponent(v.replace(/\\+/g, \" \"));\n } catch {\n throw new BaerlyError(\"InvalidResponse\", `Malformed percent-escape in S3 <${name}>: ${v}`);\n }\n};\n\n// Read a field verbatim. Used for everything S3 does NOT URL-encode:\n// error-body `Code`/`Message`, list `ETag`/`LastModified`, and\n// `NextContinuationToken` — running any of these through `xmlVal`'s\n// `decodeURIComponent` / `+`→space would corrupt literal `+` and `%`.\nconst rawXmlVal = (el: XmlElement | undefined, name: string): string | undefined => {\n return el !== undefined ? textOf(child(el, name)) : undefined;\n};\n\n/**\n * Build a {@link ParsedS3Error} from the element that directly carries\n * the `<Code>` / `<Message>` children — `<Error>` for S3, the inner\n * `<Error>` for STS. Returns `undefined` when neither child is present\n * so callers can fall back to the raw status. Shared by\n * {@link parseS3Error} and {@link parseStsError}, which differ only in\n * how they locate that element.\n */\nconst codeMessageFrom = (el: XmlElement): ParsedS3Error | undefined => {\n const code = rawXmlVal(el, \"Code\");\n const message = rawXmlVal(el, \"Message\");\n if (code === undefined && message === undefined) {\n return undefined;\n }\n return {\n ...(code !== undefined && { Code: code }),\n ...(message !== undefined && { Message: message }),\n };\n};\n\n/**\n * Parse an S3 `<Error><Code>…</Code><Message>…</Message></Error>`\n * body. Returns `undefined` when the body is not a recognizable S3\n * error document (empty, HTML, a success payload, or a DTD), so\n * callers can fall back to the raw response text. This never throws:\n * it runs on a path that is already reporting an error.\n */\nexport const parseS3Error = (xml: string): ParsedS3Error | undefined => {\n // Skip non-error bodies; refuse DTDs before parsing — see the DTD-guard\n // note above parseListObjectsV2CommandOutput.\n if (!/<Error\\b/i.test(xml) || /<!DOCTYPE\\b/i.test(xml)) {\n return undefined;\n }\n let root: XmlElement | undefined;\n try {\n root = docRoot(parseXml(xml));\n } catch {\n return undefined;\n }\n // The root element must be <Error> (possibly namespace-prefixed).\n if (root === undefined) {\n return undefined;\n }\n if (localName(root.name) !== \"Error\") {\n return undefined;\n }\n return codeMessageFrom(root);\n};\n\n/**\n * Parse an STS `<ErrorResponse><Error><Code>…</Code><Message>…</Message>\n * </Error></ErrorResponse>` body (the shape STS returns on a failed\n * `AssumeRoleWithWebIdentity` — e.g. `InvalidIdentityToken`,\n * `ExpiredTokenException`, `AccessDenied`). Returns `undefined` when the body\n * is not a recognizable STS error document (empty, HTML, a success payload, or\n * a DTD), so callers can fall back to the bare status. Like {@link parseS3Error}\n * this never throws — it runs on a path that is already reporting an error.\n *\n * Note the nesting differs from S3: STS wraps `<Error>` inside `<ErrorResponse>`.\n */\nexport const parseStsError = (xml: string): ParsedS3Error | undefined => {\n if (!/<Error\\b/i.test(xml) || /<!DOCTYPE\\b/i.test(xml)) {\n return undefined;\n }\n let root: XmlElement | undefined;\n try {\n root = docRoot(parseXml(xml));\n } catch {\n return undefined;\n }\n if (root === undefined) {\n return undefined;\n }\n // STS wraps <Error> inside <ErrorResponse>; locate the inner <Error> child.\n const errorEl = child(root, \"Error\");\n if (errorEl === undefined) {\n return undefined;\n }\n return codeMessageFrom(errorEl);\n};\n\n/**\n * `<Credentials>` extracted from an STS\n * `<AssumeRoleWithWebIdentityResponse>` body by\n * {@link parseAssumeRoleWithWebIdentity}. Field names mirror the STS REST\n * API (PascalCase), matching the convention of {@link ParsedS3Error}.\n */\nexport interface ParsedWebIdentityCredentials {\n AccessKeyId?: string;\n SecretAccessKey?: string;\n SessionToken?: string;\n Expiration?: string;\n}\n\n/**\n * Parse an STS `AssumeRoleWithWebIdentity` success body, returning the\n * `<Credentials>` block. Reuses the hardened, DTD-guarded parser;\n * throws `InvalidResponse` on a DTD or unparseable XML. Missing fields come\n * back `undefined` so the caller can map them to its own `InvalidResponse`.\n *\n * Unlike {@link parseListObjectsV2CommandOutput}, the error on unparseable\n * XML must NOT echo the body: a success-shaped STS body carries the plaintext\n * `SecretAccessKey`/`SessionToken`, so folding it into a thrown-then-logged\n * error would leak live credentials.\n */\nexport const parseAssumeRoleWithWebIdentity = (xml: string): ParsedWebIdentityCredentials => {\n if (/<!DOCTYPE\\b/i.test(xml)) {\n throw new BaerlyError(\"InvalidResponse\", \"DTD not allowed in STS XML responses\");\n }\n let root: XmlElement | undefined;\n try {\n root = docRoot(parseXml(xml));\n } catch {\n // No body in the message — see the note above; it may contain live creds.\n throw new BaerlyError(\"InvalidResponse\", \"unparseable STS credentials response\");\n }\n // Traverse: <AssumeRoleWithWebIdentityResponse>\n // <AssumeRoleWithWebIdentityResult>\n // <Credentials>\n const resultEl = root !== undefined ? child(root, \"AssumeRoleWithWebIdentityResult\") : undefined;\n const credsEl = resultEl !== undefined ? child(resultEl, \"Credentials\") : undefined;\n return {\n AccessKeyId: rawXmlVal(credsEl, \"AccessKeyId\"),\n SecretAccessKey: rawXmlVal(credsEl, \"SecretAccessKey\"),\n SessionToken: rawXmlVal(credsEl, \"SessionToken\"),\n Expiration: rawXmlVal(credsEl, \"Expiration\"),\n };\n};\n\n// `new Date(badString)` yields an Invalid Date (a non-null Date whose\n// getTime() is NaN) rather than throwing — surface `undefined` for a\n// malformed `LastModified` so it never leaks into a `StorageListEntry`.\n// GC then falls back to `now()` for the tombstone `due_at` anchor.\nconst parseLastModified = (lm: string | undefined): Date | undefined => {\n if (lm === undefined) {\n return undefined;\n }\n const d = new Date(lm);\n return Number.isNaN(d.getTime()) ? undefined : d;\n};\n\n// DTD guard: reject any DOCTYPE before @rgrove/parse-xml sees the bytes. S3/R2/\n// MinIO/GCS never emit a DOCTYPE here, so one is always a bug or an attack —\n// this defangs the DOCTYPE entity vectors (XXE, billion-laughs, the\n// CVE-2026-25896 entity-shadow). @rgrove/parse-xml is safe-by-design (refuses\n// DTD entity definitions), but the regex guard is parser-independent\n// defense-in-depth and independently covers the entity-expansion CVE class.\nexport const parseListObjectsV2CommandOutput = (xml: string): ParsedListObjectsV2Output => {\n if (/<!DOCTYPE\\b/i.test(xml)) {\n throw new BaerlyError(\"InvalidResponse\", \"DTD not allowed in S3 XML responses\");\n }\n let root: XmlElement | undefined;\n try {\n root = docRoot(parseXml(xml));\n } catch {\n throw new BaerlyError(\"InvalidResponse\", `Invalid XML: ${xml}`);\n }\n if (root === undefined) {\n return {};\n }\n // The root element must be <ListBucketResult> (possibly namespace-prefixed).\n // This restores main's `result.ListBucketResult ?? {}` structural guard and\n // matches the sibling error parsers' root checks: a non-list body returns {}.\n if (localName(root.name) !== \"ListBucketResult\") {\n return {};\n }\n // Force-array for Contents: collect all direct <Contents> element children.\n // This replaces the old `isArray: (name) => name === \"Contents\"` config.\n // Namespace-agnostic (matches `child()`), so `<s3:Contents>` also collects.\n const contentEls = root.children\n .filter(isElement)\n .filter((c) => localName(c.name) === \"Contents\");\n\n return {\n Contents: contentEls.map((contentEl) => {\n return {\n ETag: rawXmlVal(contentEl, \"ETag\"),\n Key: xmlVal(contentEl, \"Key\"),\n LastModified: parseLastModified(rawXmlVal(contentEl, \"LastModified\")),\n };\n }),\n NextContinuationToken: rawXmlVal(root, \"NextContinuationToken\"),\n };\n};\n","import {\n BaerlyError,\n LIST_OBJECT_MAX_RETRIES,\n RATE_LIMIT_BACKOFF_MILLIS,\n RETRY_AFTER_MAX_SECONDS,\n S3_REQUEST_MAX_RETRIES,\n assertValidStorageKey,\n delay,\n type Storage,\n type StorageGetOptions,\n type StorageGetResult,\n type StorageListEntry,\n type StoragePutOptions,\n type StoragePutResult,\n} from \"@baerly/protocol\";\nimport { parseListObjectsV2CommandOutput, parseS3Error } from \"./xml.ts\";\n\n/**\n * Permanent {@link BaerlyError} codes that must short-circuit `retry`.\n * These represent caller- or environment-level faults where retrying\n * cannot succeed: `AccessDenied` (403 — credentials/policy),\n * `InvalidConfig` (bad bucket / unsupported credential type),\n * `InvalidResponse` (server returned unparseable data), and\n * `Conflict` (CAS guard lost — retrying would just re-lose against\n * the same state). `NetworkError` is intentionally absent — it covers\n * transient transport faults and stays retryable.\n *\n * Transport-layer set, distinct from `RETRIABLE_CODES` in `@baerly/protocol`'s\n * `errors.ts` (the default wire `retriable` hint). `Conflict` is \"permanent\"\n * here (a blind re-PUT re-loses the CAS race) yet retryable for logical CAS\n * callers that can fresh-read + re-apply. Same code, two different questions.\n */\nconst PERMANENT_ERROR_CODES: ReadonlySet<string> = new Set([\n \"AccessDenied\",\n \"InvalidConfig\",\n \"InvalidResponse\",\n \"Conflict\",\n]);\n\n/**\n * Parse an HTTP `Retry-After` header into a non-negative seconds value,\n * clamped to {@link RETRY_AFTER_MAX_SECONDS}. Returns `undefined` if\n * the header is absent, malformed, or whitespace.\n *\n * RFC 7231 §7.1.3 admits two forms: delta-seconds (non-negative\n * integer) and HTTP-date. Both are accepted; dates in the past return\n * `0`. Fractional seconds, negatives, and arbitrary strings reject.\n *\n * The `now` injection point exists for the unit test; production\n * callers should pass nothing.\n */\nfunction parseRetryAfter(header: string | null, now: () => number = Date.now): number | undefined {\n if (header === null) {\n return undefined;\n }\n const trimmed = header.trim();\n if (trimmed === \"\") {\n return undefined;\n }\n if (/^\\d+$/.test(trimmed)) {\n const n = Number.parseInt(trimmed, 10);\n return Number.isFinite(n) ? Math.min(n, RETRY_AFTER_MAX_SECONDS) : undefined;\n }\n // RFC 7231 §7.1.1.1 HTTP-date formats (IMF-fixdate, RFC 850, asctime)\n // all contain alphabetic month/day-of-week tokens. Gating on a letter\n // avoids V8's lenient `Date.parse` accepting things like \"5.5\".\n if (!/[a-z]/i.test(trimmed)) {\n return undefined;\n }\n const t = Date.parse(trimmed);\n if (Number.isNaN(t)) {\n return undefined;\n }\n const seconds = Math.max(0, Math.ceil((t - now()) / 1000));\n return Math.min(seconds, RETRY_AFTER_MAX_SECONDS);\n}\n\nconst retryAfterCause = (res: Response): { retryAfterSeconds?: number } => {\n const hint = parseRetryAfter(res.headers.get(\"Retry-After\"));\n return hint !== undefined ? { retryAfterSeconds: hint } : {};\n};\n\n// Detail suffix for a non-status-mapped S3 error response. When the\n// body is a parseable `<Error><Code>…</Error>` document, surface S3's\n// own error code (and message) instead of concatenating the raw XML\n// blob into the thrown message; otherwise fall back to the raw text.\nconst s3ErrorDetail = (status: number, body: string): string => {\n const parsed = parseS3Error(body);\n if (parsed !== undefined) {\n const code = parsed.Code ?? \"UnknownError\";\n return parsed.Message !== undefined\n ? `${status} ${code}: ${parsed.Message}`\n : `${status} ${code}`;\n }\n return `${status} ${body}`;\n};\n\nconst retry = async <T>(\n fn: () => Promise<T>,\n { retries = S3_REQUEST_MAX_RETRIES, backoffMs = 100, maxDelayMs = 10_000 } = {},\n): Promise<T> => {\n let wait = backoffMs;\n for (let attempt = 0; attempt <= retries; attempt++) {\n try {\n return await fn();\n } catch (error) {\n if (error instanceof BaerlyError && PERMANENT_ERROR_CODES.has(error.code)) {\n throw error;\n }\n if (attempt === retries) {\n throw error;\n }\n const hintMs = retryAfterHintMs(error, maxDelayMs);\n await delay(hintMs ?? wait);\n if (hintMs === undefined) {\n wait = Math.min(wait * 1.5, maxDelayMs);\n } else {\n // A server-driven pause is new information about server state;\n // reset the exponential ladder so a subsequent non-hinted\n // transient starts fresh from `backoffMs`.\n wait = backoffMs;\n }\n }\n }\n throw new BaerlyError(\"Internal\", \"s3-http retry loop exited without returning or throwing\");\n};\n\nconst retryAfterHintMs = (e: unknown, maxDelayMs: number): number | undefined => {\n if (!(e instanceof BaerlyError)) {\n return undefined;\n }\n const cause = e.cause as { retryAfterSeconds?: number } | undefined;\n if (cause?.retryAfterSeconds === undefined) {\n return undefined;\n }\n return Math.min(cause.retryAfterSeconds * 1000, maxDelayMs);\n};\n\n/**\n * Construction-time options for {@link S3HttpStorage}. Everything is\n * optional except `endpoint` and `bucket`; the consumer chooses how\n * to satisfy `fetch` (browser/Node global vs. injected) and `sign`\n * (anonymous Minio vs. SigV4-signed via aws4fetch).\n */\nexport interface S3HttpStorageOptions {\n /**\n * S3 endpoint URL, e.g. `https://s3.us-east-1.amazonaws.com` or\n * `http://127.0.0.1:9102` (Minio). Trailing slashes are trimmed.\n */\n endpoint: string;\n /** S3 bucket name. */\n bucket: string;\n /**\n * `fetch` implementation. Defaults to `globalThis.fetch.bind(globalThis)`.\n * Tests pass a `vi.fn()` stub.\n */\n fetch?: typeof fetch;\n /**\n * Signs requests before send. Pass `undefined` for anonymous\n * (Minio without creds). The seam is `(req) => Promise<req>` so\n * SigV4 implementations like `aws4fetch.AwsClient.sign` plug in\n * directly.\n */\n sign?: (req: Request) => Promise<Request>;\n /** Max retries for transient (non-permanent) failures. */\n retries?: number;\n /** Initial backoff in ms. */\n backoffMs?: number;\n}\n\n/**\n * `Storage` impl that speaks the S3 REST API directly. Works against\n * any S3-compatible endpoint — AWS S3, R2 (S3-compat), GCS (S3-compat),\n * Minio. Does not depend on any AWS SDK.\n *\n * Authentication is plugged in via the `sign` callback; this class\n * itself does no SigV4. For Cloudflare Workers, the R2 binding fast\n * path lives in `@baerly/adapter-cloudflare`.\n */\nexport class S3HttpStorage implements Storage {\n readonly #endpoint: string;\n readonly #bucket: string;\n readonly #fetch: typeof fetch;\n readonly #sign?: (req: Request) => Promise<Request>;\n readonly #retries: number;\n readonly #backoffMs: number;\n\n constructor(options: S3HttpStorageOptions) {\n this.#endpoint = options.endpoint.replace(/\\/+$/, \"\");\n this.#bucket = options.bucket;\n this.#fetch = options.fetch ?? globalThis.fetch.bind(globalThis);\n this.#sign = options.sign;\n this.#retries = options.retries ?? S3_REQUEST_MAX_RETRIES;\n this.#backoffMs = options.backoffMs ?? 100;\n }\n\n #objectUrl(key: string, versionId?: string): string {\n // Choke point for every key-addressing verb — reject unaddressable\n // `.`/`..`/empty keys before URL normalization turns them into a\n // bucket-root 403. @see storage-compatibility.md \"Key namespace\".\n assertValidStorageKey(key);\n const base = `${this.#endpoint}/${this.#bucket}/${encodeURIComponent(key)}`;\n return versionId !== undefined ? `${base}?versionId=${encodeURIComponent(versionId)}` : base;\n }\n\n async #dispatch(req: Request): Promise<Response> {\n const signed = this.#sign ? await this.#sign(req) : req;\n try {\n return await this.#fetch(signed);\n } catch (error) {\n if (error instanceof BaerlyError) {\n throw error;\n }\n const msg = error instanceof Error ? error.message : String(error);\n throw new BaerlyError(\"NetworkError\", msg, error);\n }\n }\n\n #retry<T>(fn: () => Promise<T>): Promise<T> {\n return retry(fn, { retries: this.#retries, backoffMs: this.#backoffMs });\n }\n\n async get(key: string, opts?: StorageGetOptions): Promise<StorageGetResult | null> {\n opts?.signal?.throwIfAborted();\n const url = this.#objectUrl(key, opts?.versionId);\n const headers = new Headers();\n if (opts?.ifNoneMatch !== undefined) {\n headers.set(\"If-None-Match\", opts.ifNoneMatch);\n }\n return this.#retry(async () => {\n const res = await this.#dispatch(\n new Request(url, { method: \"GET\", headers, signal: opts?.signal ?? null }),\n );\n switch (res.status) {\n case 200: {\n const etag = res.headers.get(\"ETag\");\n if (etag === null) {\n throw new BaerlyError(\"InvalidResponse\", `GET ${key}: missing ETag`);\n }\n const body = new Uint8Array(await res.arrayBuffer());\n const versionId = res.headers.get(\"x-amz-version-id\") ?? undefined;\n return versionId !== undefined ? { body, etag, versionId } : { body, etag };\n }\n case 304:\n case 404: {\n return null;\n }\n case 403: {\n throw new BaerlyError(\"AccessDenied\", `GET ${key}: 403`);\n }\n default: {\n if (res.status === 429 || res.status >= 500) {\n throw new BaerlyError(\"NetworkError\", `GET ${key}: ${res.status} ${await res.text()}`, {\n status: res.status,\n ...retryAfterCause(res),\n });\n }\n throw new BaerlyError(\n \"InvalidResponse\",\n `GET ${key}: ${s3ErrorDetail(res.status, await res.text())}`,\n );\n }\n }\n });\n }\n\n async put(key: string, body: Uint8Array, opts?: StoragePutOptions): Promise<StoragePutResult> {\n opts?.signal?.throwIfAborted();\n const url = this.#objectUrl(key);\n const headers = new Headers();\n headers.set(\"Content-Type\", opts?.contentType ?? \"application/octet-stream\");\n if (opts?.ifMatch !== undefined) {\n headers.set(\"If-Match\", opts.ifMatch);\n }\n if (opts?.ifNoneMatch === \"*\") {\n headers.set(\"If-None-Match\", \"*\");\n }\n return this.#retry(async () => {\n const res = await this.#dispatch(\n new Request(url, {\n method: \"PUT\",\n headers,\n // TS lib.dom narrows BodyInit and a generic `Uint8Array<ArrayBufferLike>`\n // is not assignable; the runtime accepts it.\n body: body as BodyInit,\n signal: opts?.signal ?? null,\n }),\n );\n if (res.status === 412) {\n throw new BaerlyError(\"Conflict\", `PUT ${key}: precondition failed`);\n }\n // AWS S3 returns 409 ConditionalRequestConflict when a concurrent\n // conditional create (If-None-Match:\"*\") races; Minio returns 412.\n // 409 means the write was contended and may NOT have landed, so it\n // maps to a retryable NetworkError — the single-write-commit writer\n // re-issues the same-seq PUT, which resolves deterministically to 200\n // (we win) or 412 (key now present → Conflict → adopt/re-probe). A\n // direct Conflict here would adopt-read a possibly-absent entry.\n if (res.status === 409 && opts?.ifNoneMatch === \"*\") {\n throw new BaerlyError(\n \"NetworkError\",\n `PUT ${key}: 409 ConditionalRequestConflict (contended conditional create; retryable)`,\n { status: res.status, ...retryAfterCause(res) },\n );\n }\n // S3-compatible servers diverge on `If-Match` against a missing\n // key: AWS S3 returns 412, Minio returns 404 (NoSuchKey). Map\n // 404-with-ifMatch to the same `Conflict` semantic so consumers\n // don't have to special-case the wire reply.\n if (res.status === 404 && opts?.ifMatch !== undefined) {\n throw new BaerlyError(\n \"Conflict\",\n `PUT ${key}: precondition failed (ifMatch=${opts.ifMatch} but key does not exist)`,\n );\n }\n if (res.status === 403) {\n throw new BaerlyError(\"AccessDenied\", `PUT ${key}: 403`);\n }\n if (res.status === 429 || res.status >= 500) {\n throw new BaerlyError(\"NetworkError\", `PUT ${key}: ${res.status} ${await res.text()}`, {\n status: res.status,\n ...retryAfterCause(res),\n });\n }\n if (res.status !== 200 && res.status !== 204) {\n throw new BaerlyError(\n \"InvalidResponse\",\n `PUT ${key}: ${s3ErrorDetail(res.status, await res.text())}`,\n );\n }\n const etag = res.headers.get(\"ETag\");\n if (etag === null) {\n throw new BaerlyError(\"InvalidResponse\", `PUT ${key}: missing ETag`);\n }\n const dateStr = res.headers.get(\"Date\");\n const versionId = res.headers.get(\"x-amz-version-id\") ?? undefined;\n const result: { etag: string; serverDate?: Date; versionId?: string } = { etag };\n if (dateStr !== null) {\n result.serverDate = new Date(dateStr);\n }\n if (versionId !== undefined) {\n result.versionId = versionId;\n }\n return result;\n });\n }\n\n async delete(key: string, opts?: { signal?: AbortSignal }): Promise<void> {\n opts?.signal?.throwIfAborted();\n const url = this.#objectUrl(key);\n await this.#retry(async () => {\n const res = await this.#dispatch(\n new Request(url, { method: \"DELETE\", signal: opts?.signal ?? null }),\n );\n if (res.status === 403) {\n throw new BaerlyError(\"AccessDenied\", `DELETE ${key}: 403`);\n }\n if (res.status === 429 || res.status >= 500) {\n throw new BaerlyError(\"NetworkError\", `DELETE ${key}: ${res.status} ${await res.text()}`, {\n status: res.status,\n ...retryAfterCause(res),\n });\n }\n // 200 / 204 / 404 → success (idempotent).\n });\n }\n\n async *list(\n prefix: string,\n opts?: { startAfter?: string; maxKeys?: number; signal?: AbortSignal },\n ): AsyncIterable<StorageListEntry> {\n opts?.signal?.throwIfAborted();\n let yielded = 0;\n let continuationToken: string | undefined;\n const startAfter = opts?.startAfter ?? \"\";\n while (true) {\n opts?.signal?.throwIfAborted();\n const params = new URLSearchParams();\n params.set(\"list-type\", \"2\");\n params.set(\"prefix\", prefix);\n // Force S3 to URL-encode object keys in the response so keys\n // containing XML-hostile or whitespace bytes survive the round trip.\n // The XML parser (`xmlVal` in ./xml.ts) reverses this on `Key`; only\n // the key family (Key/Prefix/Delimiter/StartAfter) is encoded — ETag\n // and NextContinuationToken come back verbatim.\n params.set(\"encoding-type\", \"url\");\n if (continuationToken !== undefined) {\n params.set(\"continuation-token\", continuationToken);\n } else if (startAfter !== \"\") {\n params.set(\"start-after\", startAfter);\n }\n if (opts?.maxKeys !== undefined) {\n const remaining = opts.maxKeys - yielded;\n params.set(\"max-keys\", String(Math.min(remaining, 1000)));\n }\n const url = `${this.#endpoint}/${this.#bucket}/?${params.toString()}`;\n\n // Per-page 429 retry budget separate from the inner #retry budget:\n // 429 means \"rate-limited, back off and retry the same page\", and\n // a single hot page shouldn't burn the overall transient-failure\n // budget.\n let parsed: Awaited<ReturnType<typeof parseListObjectsV2CommandOutput>> | undefined;\n let lastHint: number | undefined;\n for (let attempt = 0; attempt < LIST_OBJECT_MAX_RETRIES; attempt++) {\n const outcome = await this.#retry(async () => {\n const res = await this.#dispatch(\n new Request(url, { method: \"GET\", signal: opts?.signal ?? null }),\n );\n if (res.status === 200) {\n return { kind: \"ok\" as const, body: await res.text() };\n }\n if (res.status === 429) {\n return {\n kind: \"ratelimited\" as const,\n retryAfterSeconds: parseRetryAfter(res.headers.get(\"Retry-After\")),\n };\n }\n if (res.status === 403) {\n throw new BaerlyError(\"AccessDenied\", `LIST ${prefix}: 403`);\n }\n if (res.status >= 500) {\n throw new BaerlyError(\n \"NetworkError\",\n `LIST ${prefix}: ${res.status} ${await res.text()}`,\n { status: res.status, ...retryAfterCause(res) },\n );\n }\n throw new BaerlyError(\n \"InvalidResponse\",\n `LIST ${prefix}: ${s3ErrorDetail(res.status, await res.text())}`,\n );\n });\n if (outcome.kind === \"ok\") {\n parsed = parseListObjectsV2CommandOutput(outcome.body);\n break;\n }\n lastHint = outcome.retryAfterSeconds;\n const hintMs =\n outcome.retryAfterSeconds !== undefined ? outcome.retryAfterSeconds * 1000 : 0;\n await delay(Math.max(hintMs, RATE_LIMIT_BACKOFF_MILLIS));\n }\n if (parsed === undefined) {\n throw new BaerlyError(\"NetworkError\", `LIST ${prefix}: rate-limited`, {\n status: 429,\n ...(lastHint !== undefined ? { retryAfterSeconds: lastHint } : {}),\n });\n }\n\n for (const entry of parsed.Contents ?? []) {\n if (entry.Key === undefined) {\n continue;\n }\n yield {\n key: entry.Key,\n etag: entry.ETag ?? \"\",\n ...(entry.LastModified !== undefined && { lastModified: entry.LastModified }),\n };\n yielded += 1;\n if (opts?.maxKeys !== undefined && yielded >= opts.maxKeys) {\n return;\n }\n }\n continuationToken = parsed.NextContinuationToken;\n if (continuationToken === undefined || continuationToken === \"\") {\n return;\n }\n }\n }\n}\n","/**\n * @license MIT <https://opensource.org/licenses/MIT>\n * @copyright Michael Hart 2024\n */\nconst encoder = new TextEncoder();\nconst HOST_SERVICES = {\n appstream2: 'appstream',\n cloudhsmv2: 'cloudhsm',\n email: 'ses',\n marketplace: 'aws-marketplace',\n mobile: 'AWSMobileHubService',\n pinpoint: 'mobiletargeting',\n queue: 'sqs',\n 'git-codecommit': 'codecommit',\n 'mturk-requester-sandbox': 'mturk-requester',\n 'personalize-runtime': 'personalize',\n};\nconst UNSIGNABLE_HEADERS = new Set([\n 'authorization',\n 'content-type',\n 'content-length',\n 'user-agent',\n 'presigned-expires',\n 'expect',\n 'x-amzn-trace-id',\n 'range',\n 'connection',\n]);\nclass AwsClient {\n constructor({ accessKeyId, secretAccessKey, sessionToken, service, region, cache, retries, initRetryMs }) {\n if (accessKeyId == null) throw new TypeError('accessKeyId is a required option')\n if (secretAccessKey == null) throw new TypeError('secretAccessKey is a required option')\n this.accessKeyId = accessKeyId;\n this.secretAccessKey = secretAccessKey;\n this.sessionToken = sessionToken;\n this.service = service;\n this.region = region;\n this.cache = cache || new Map();\n this.retries = retries != null ? retries : 10;\n this.initRetryMs = initRetryMs || 50;\n }\n async sign(input, init) {\n if (input instanceof Request) {\n const { method, url, headers, body } = input;\n init = Object.assign({ method, url, headers }, init);\n if (init.body == null && headers.has('Content-Type')) {\n init.body = body != null && headers.has('X-Amz-Content-Sha256') ? body : await input.clone().arrayBuffer();\n }\n input = url;\n }\n const signer = new AwsV4Signer(Object.assign({ url: input.toString() }, init, this, init && init.aws));\n const signed = Object.assign({}, init, await signer.sign());\n delete signed.aws;\n try {\n return new Request(signed.url.toString(), signed)\n } catch (e) {\n if (e instanceof TypeError) {\n return new Request(signed.url.toString(), Object.assign({ duplex: 'half' }, signed))\n }\n throw e\n }\n }\n async fetch(input, init) {\n for (let i = 0; i <= this.retries; i++) {\n const fetched = fetch(await this.sign(input, init));\n if (i === this.retries) {\n return fetched\n }\n const res = await fetched;\n if (res.status < 500 && res.status !== 429) {\n return res\n }\n await new Promise(resolve => setTimeout(resolve, Math.random() * this.initRetryMs * Math.pow(2, i)));\n }\n throw new Error('An unknown error occurred, ensure retries is not negative')\n }\n}\nclass AwsV4Signer {\n constructor({ method, url, headers, body, accessKeyId, secretAccessKey, sessionToken, service, region, cache, datetime, signQuery, appendSessionToken, allHeaders, singleEncode }) {\n if (url == null) throw new TypeError('url is a required option')\n if (accessKeyId == null) throw new TypeError('accessKeyId is a required option')\n if (secretAccessKey == null) throw new TypeError('secretAccessKey is a required option')\n this.method = method || (body ? 'POST' : 'GET');\n this.url = new URL(url);\n this.headers = new Headers(headers || {});\n this.body = body;\n this.accessKeyId = accessKeyId;\n this.secretAccessKey = secretAccessKey;\n this.sessionToken = sessionToken;\n let guessedService, guessedRegion;\n if (!service || !region) {\n[guessedService, guessedRegion] = guessServiceRegion(this.url, this.headers);\n }\n this.service = service || guessedService || '';\n this.region = region || guessedRegion || 'us-east-1';\n this.cache = cache || new Map();\n this.datetime = datetime || new Date().toISOString().replace(/[:-]|\\.\\d{3}/g, '');\n this.signQuery = signQuery;\n this.appendSessionToken = appendSessionToken || this.service === 'iotdevicegateway';\n this.headers.delete('Host');\n if (this.service === 's3' && !this.signQuery && !this.headers.has('X-Amz-Content-Sha256')) {\n this.headers.set('X-Amz-Content-Sha256', 'UNSIGNED-PAYLOAD');\n }\n const params = this.signQuery ? this.url.searchParams : this.headers;\n params.set('X-Amz-Date', this.datetime);\n if (this.sessionToken && !this.appendSessionToken) {\n params.set('X-Amz-Security-Token', this.sessionToken);\n }\n this.signableHeaders = ['host', ...this.headers.keys()]\n .filter(header => allHeaders || !UNSIGNABLE_HEADERS.has(header))\n .sort();\n this.signedHeaders = this.signableHeaders.join(';');\n this.canonicalHeaders = this.signableHeaders\n .map(header => header + ':' + (header === 'host' ? this.url.host : (this.headers.get(header) || '').replace(/\\s+/g, ' ')))\n .join('\\n');\n this.credentialString = [this.datetime.slice(0, 8), this.region, this.service, 'aws4_request'].join('/');\n if (this.signQuery) {\n if (this.service === 's3' && !params.has('X-Amz-Expires')) {\n params.set('X-Amz-Expires', '86400');\n }\n params.set('X-Amz-Algorithm', 'AWS4-HMAC-SHA256');\n params.set('X-Amz-Credential', this.accessKeyId + '/' + this.credentialString);\n params.set('X-Amz-SignedHeaders', this.signedHeaders);\n }\n if (this.service === 's3') {\n try {\n this.encodedPath = decodeURIComponent(this.url.pathname.replace(/\\+/g, ' '));\n } catch (e) {\n this.encodedPath = this.url.pathname;\n }\n } else {\n this.encodedPath = this.url.pathname.replace(/\\/+/g, '/');\n }\n if (!singleEncode) {\n this.encodedPath = encodeURIComponent(this.encodedPath).replace(/%2F/g, '/');\n }\n this.encodedPath = encodeRfc3986(this.encodedPath);\n const seenKeys = new Set();\n this.encodedSearch = [...this.url.searchParams]\n .filter(([k]) => {\n if (!k) return false\n if (this.service === 's3') {\n if (seenKeys.has(k)) return false\n seenKeys.add(k);\n }\n return true\n })\n .map(pair => pair.map(p => encodeRfc3986(encodeURIComponent(p))))\n .sort(([k1, v1], [k2, v2]) => k1 < k2 ? -1 : k1 > k2 ? 1 : v1 < v2 ? -1 : v1 > v2 ? 1 : 0)\n .map(pair => pair.join('='))\n .join('&');\n }\n async sign() {\n if (this.signQuery) {\n this.url.searchParams.set('X-Amz-Signature', await this.signature());\n if (this.sessionToken && this.appendSessionToken) {\n this.url.searchParams.set('X-Amz-Security-Token', this.sessionToken);\n }\n } else {\n this.headers.set('Authorization', await this.authHeader());\n }\n return {\n method: this.method,\n url: this.url,\n headers: this.headers,\n body: this.body,\n }\n }\n async authHeader() {\n return [\n 'AWS4-HMAC-SHA256 Credential=' + this.accessKeyId + '/' + this.credentialString,\n 'SignedHeaders=' + this.signedHeaders,\n 'Signature=' + (await this.signature()),\n ].join(', ')\n }\n async signature() {\n const date = this.datetime.slice(0, 8);\n const cacheKey = [this.secretAccessKey, date, this.region, this.service].join();\n let kCredentials = this.cache.get(cacheKey);\n if (!kCredentials) {\n const kDate = await hmac('AWS4' + this.secretAccessKey, date);\n const kRegion = await hmac(kDate, this.region);\n const kService = await hmac(kRegion, this.service);\n kCredentials = await hmac(kService, 'aws4_request');\n this.cache.set(cacheKey, kCredentials);\n }\n return buf2hex(await hmac(kCredentials, await this.stringToSign()))\n }\n async stringToSign() {\n return [\n 'AWS4-HMAC-SHA256',\n this.datetime,\n this.credentialString,\n buf2hex(await hash(await this.canonicalString())),\n ].join('\\n')\n }\n async canonicalString() {\n return [\n this.method.toUpperCase(),\n this.encodedPath,\n this.encodedSearch,\n this.canonicalHeaders + '\\n',\n this.signedHeaders,\n await this.hexBodyHash(),\n ].join('\\n')\n }\n async hexBodyHash() {\n let hashHeader = this.headers.get('X-Amz-Content-Sha256') || (this.service === 's3' && this.signQuery ? 'UNSIGNED-PAYLOAD' : null);\n if (hashHeader == null) {\n if (this.body && typeof this.body !== 'string' && !('byteLength' in this.body)) {\n throw new Error('body must be a string, ArrayBuffer or ArrayBufferView, unless you include the X-Amz-Content-Sha256 header')\n }\n hashHeader = buf2hex(await hash(this.body || ''));\n }\n return hashHeader\n }\n}\nasync function hmac(key, string) {\n const cryptoKey = await crypto.subtle.importKey(\n 'raw',\n typeof key === 'string' ? encoder.encode(key) : key,\n { name: 'HMAC', hash: { name: 'SHA-256' } },\n false,\n ['sign'],\n );\n return crypto.subtle.sign('HMAC', cryptoKey, encoder.encode(string))\n}\nasync function hash(content) {\n return crypto.subtle.digest('SHA-256', typeof content === 'string' ? encoder.encode(content) : content)\n}\nconst HEX_CHARS = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'];\nfunction buf2hex(arrayBuffer) {\n const buffer = new Uint8Array(arrayBuffer);\n let out = '';\n for (let idx = 0; idx < buffer.length; idx++) {\n const n = buffer[idx];\n out += HEX_CHARS[(n >>> 4) & 0xF];\n out += HEX_CHARS[n & 0xF];\n }\n return out\n}\nfunction encodeRfc3986(urlEncodedStr) {\n return urlEncodedStr.replace(/[!'()*]/g, c => '%' + c.charCodeAt(0).toString(16).toUpperCase())\n}\nfunction guessServiceRegion(url, headers) {\n const { hostname, pathname } = url;\n if (hostname.endsWith('.on.aws')) {\n const match = hostname.match(/^[^.]{1,63}\\.lambda-url\\.([^.]{1,63})\\.on\\.aws$/);\n return match != null ? ['lambda', match[1] || ''] : ['', '']\n }\n if (hostname.endsWith('.r2.cloudflarestorage.com')) {\n return ['s3', 'auto']\n }\n if (hostname.endsWith('.backblazeb2.com')) {\n const match = hostname.match(/^(?:[^.]{1,63}\\.)?s3\\.([^.]{1,63})\\.backblazeb2\\.com$/);\n return match != null ? ['s3', match[1] || ''] : ['', '']\n }\n const match = hostname.replace('dualstack.', '').match(/([^.]{1,63})\\.(?:([^.]{0,63})\\.)?amazonaws\\.com(?:\\.cn)?$/);\n let service = (match && match[1]) || '';\n let region = match && match[2];\n if (region === 'us-gov') {\n region = 'us-gov-west-1';\n } else if (region === 's3' || region === 's3-accelerate') {\n region = 'us-east-1';\n service = 's3';\n } else if (service === 'iot') {\n if (hostname.startsWith('iot.')) {\n service = 'execute-api';\n } else if (hostname.startsWith('data.jobs.iot.')) {\n service = 'iot-jobs-data';\n } else {\n service = pathname === '/mqtt' ? 'iotdevicegateway' : 'iotdata';\n }\n } else if (service === 'autoscaling') {\n const targetPrefix = (headers.get('X-Amz-Target') || '').split('.')[0];\n if (targetPrefix === 'AnyScaleFrontendService') {\n service = 'application-autoscaling';\n } else if (targetPrefix === 'AnyScaleScalingPlannerFrontendService') {\n service = 'autoscaling-plans';\n }\n } else if (region == null && service.startsWith('s3-')) {\n region = service.slice(3).replace(/^fips-|^external-1/, '');\n service = 's3';\n } else if (service.endsWith('-fips')) {\n service = service.slice(0, -5);\n } else if (region && /-\\d$/.test(service) && !/-\\d$/.test(region)) {\n[service, region] = [region, service];\n }\n return [HOST_SERVICES[service] || service, region || '']\n}\n\nexport { AwsClient, AwsV4Signer };\n"],"x_google_ignoreList":[0,3],"mappings":";;;;;;;;;CAEA,IAAI,YAAY,OAAO;CACvB,IAAI,mBAAmB,OAAO;CAC9B,IAAI,oBAAoB,OAAO;CAC/B,IAAI,eAAe,OAAO,UAAU;CACpC,IAAI,YAAY,QAAQ,QAAQ;EAC9B,KAAK,IAAI,QAAQ,KACf,UAAU,QAAQ,MAAM;GAAE,KAAK,IAAI;GAAO,YAAY;EAAK,CAAC;CAChE;CACA,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;EAC5C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS;QACjD,IAAI,OAAO,kBAAkB,IAAI,GACpC,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QACzC,UAAU,IAAI,KAAK;IAAE,WAAW,KAAK;IAAM,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK;GAAW,CAAC;E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AS,WAAW,gBAAgB,GAC7C,UAAU;MAEV,UAAU,aAAa,UAAU,qBAAqB;MAEnD,IAAI,YAAY,eAAe;EACpC,MAAM,gBAAgB,QAAQ,IAAI,cAAc,KAAK,GAAA,CAAI,MAAM,GAAG,CAAC,CAAC;EACpE,IAAI,iBAAiB,2BACnB,UAAU;OACL,IAAI,iBAAiB,yCAC1B,UAAU;CAEd,OAAO,IAAI,UAAU,QAAQ,QAAQ,WAAW,KAAK,GAAG;EACtD,SAAS,QAAQ,MAAM,CAAC,CAAC,CAAC,QAAQ,sBAAsB,EAAE;EAC1D,UAAU;CACZ,OAAO,IAAI,QAAQ,SAAS,OAAO,GACjC,UAAU,QAAQ,MAAM,GAAG,EAAE;MACxB,IAAI,UAAU,OAAO,KAAK,OAAO,KAAK,CAAC,OAAO,KAAK,MAAM,GAClE,CAAC,SAAS,UAAU,CAAC,QAAQ,OAAO;CAElC,OAAO,CAAC,cAAc,YAAY,SAAS,UAAU,EAAE;AACzD"}
package/dist/baerly.js CHANGED
@@ -144,7 +144,7 @@ function parseRawArgs(args = [], opts = {}) {
144
144
  for (const alias of aliases) if (strings.has(alias)) return true;
145
145
  return false;
146
146
  }
147
- const allOptions = new Set([
147
+ const allOptions = /* @__PURE__ */ new Set([
148
148
  ...booleans,
149
149
  ...strings,
150
150
  ...Object.keys(aliasMap),
@@ -447,7 +447,15 @@ function renderDescription(arg, required) {
447
447
  //#endregion
448
448
  //#region ../protocol/src/errors.ts
449
449
  /**
450
- * The single error class thrown by Baerly. Discriminate by `code`, not
450
+ * Codes whose default failure class is resolved by retrying with a fresh read.
451
+ * Throw sites may override this when the same code is context-sensitive
452
+ * (notably caller-supplied `_id` collisions, which also use `Conflict`).
453
+ */
454
+ const RETRIABLE_CODES = /* @__PURE__ */ new Set(["NetworkError", "Conflict"]);
455
+ /** True iff this error code's default failure class is retriable. */
456
+ const isRetriableCode = (code) => RETRIABLE_CODES.has(code);
457
+ /**
458
+ * The single error class thrown by baerly-storage. Discriminate by `code`, not
451
459
  * `instanceof`: the code string survives `JSON.stringify` round-trips
452
460
  * across Worker / iframe / postMessage realm boundaries, where each
453
461
  * realm has its own `BaerlyError` constructor identity. IDB-restored
@@ -460,7 +468,7 @@ function renderDescription(arg, required) {
460
468
  * await db.collection("tickets").insert({ title: "hi" });
461
469
  * } catch (err) {
462
470
  * if (err instanceof BaerlyError && err.code === "Conflict") {
463
- * // ... CAS lost; retry
471
+ * // Check err.retriable; CAS can retry, duplicate _id cannot.
464
472
  * }
465
473
  * throw err;
466
474
  * }
@@ -490,13 +498,25 @@ var BaerlyError = class extends Error {
490
498
  * you genuinely need the wire value.
491
499
  */
492
500
  status;
493
- constructor(code, message, cause, issues, status) {
501
+ /** Canonical corrective action; crosses the wire via `HttpErrorEnvelope.error.resolution`. */
502
+ resolution;
503
+ retriableOverride;
504
+ /**
505
+ * Whether this error instance is retriable. Defaults from `code`, but
506
+ * context-sensitive throw sites can override it.
507
+ */
508
+ get retriable() {
509
+ return this.retriableOverride ?? isRetriableCode(this.code);
510
+ }
511
+ constructor(code, message, cause, issues, status, resolution, retriableOverride) {
494
512
  super(message);
495
513
  this.name = "BaerlyError";
496
514
  this.code = code;
497
515
  this.cause = cause;
516
+ this.retriableOverride = retriableOverride;
498
517
  if (issues !== void 0) this.issues = issues;
499
518
  if (status !== void 0) this.status = status;
519
+ if (resolution !== void 0) this.resolution = resolution;
500
520
  }
501
521
  };
502
522
  //#endregion
@@ -735,27 +755,27 @@ runBin(defineCommand({
735
755
  description: "Vendorless document database CLI."
736
756
  },
737
757
  subCommands: {
738
- deploy: () => import("./deploy-CrAbfgCq.js").then((m) => m.deploy),
739
- doctor: () => import("./doctor-Db-hzPmE.js").then((m) => m.doctor),
740
- inspect: () => import("./inspect-Bdbzvi-_.js").then((m) => m.inspect),
741
- export: () => import("./export-Bhbz90-z.js").then((m) => m.exportCmd),
742
- cost: () => import("./cost-CQt1YRkA.js").then((m) => m.cost),
758
+ deploy: () => import("./deploy-DonTr-CV.js").then((m) => m.deploy),
759
+ doctor: () => import("./doctor-DSIyCDg_.js").then((m) => m.doctor),
760
+ inspect: () => import("./inspect-6WZ-pC7-.js").then((m) => m.inspect),
761
+ export: () => import("./export-DtF5tDIM.js").then((m) => m.exportCmd),
762
+ cost: () => import("./cost-DSMIVqzL.js").then((m) => m.cost),
743
763
  admin: defineCommand({
744
764
  meta: {
745
765
  name: "admin",
746
766
  description: "Operator commands — reconciliation and inspection."
747
767
  },
748
768
  subCommands: {
749
- "rebuild-index": () => import("./rebuild-index-DC_nR6wP.js").then((m) => m.rebuildIndexCmd),
750
- dump: () => import("./dump-BYA55NLP.js").then((m) => m.dumpCmd),
751
- restore: () => import("./restore-C6IcmLeA.js").then((m) => m.restoreCmd),
752
- fsck: () => import("./fsck-CPPZWt9p.js").then((m) => m.fsckCmd),
753
- usage: () => import("./usage-CLjirdD-.js").then((m) => m.usageCmd)
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)
754
774
  }
755
775
  })
756
776
  }
757
777
  }), process.argv.slice(2), "baerly");
758
778
  //#endregion
759
- export { setJsonMode as a, parseArgs$1 as c, isJsonMode as i, emitError as n, BaerlyError as o, emitSuccess as r, defineCommand as s, color as t };
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 };
760
780
 
761
781
  //# sourceMappingURL=baerly.js.map