@gusto/baerly-storage 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/API.md +3 -2
- package/dist/CHANGELOG.md +82 -0
- package/dist/THIRD-PARTY-LICENSES.txt +1 -1
- package/dist/auth.d.ts +1 -1
- package/dist/aws4fetch.esm-CXE5ZbAa.js +460 -0
- package/dist/aws4fetch.esm-CXE5ZbAa.js.map +1 -0
- package/dist/baerly.js +10 -10
- package/dist/baerly.spec.json +1 -1
- package/dist/client-react.d.ts +2 -2
- package/dist/{client-Fe8CwB73.d.ts → client-ypCm3zjt.d.ts} +2 -2
- package/dist/client.d.ts +2 -2
- package/dist/{cloudflare-DzKBrUlg.js → cloudflare-wrVYf4bb.js} +457 -56
- package/dist/cloudflare-wrVYf4bb.js.map +1 -0
- package/dist/cloudflare.d.ts +3 -3
- package/dist/cloudflare.js +5 -5
- package/dist/{config-1tv0-Yzm.js → config-B6nTy8e2.js} +435 -33
- package/dist/config-B6nTy8e2.js.map +1 -0
- package/dist/constants-CfeMWQWk.js.map +1 -1
- package/dist/{cost-DSMIVqzL.js → cost-_SE_SVgZ.js} +4 -4
- package/dist/{cost-DSMIVqzL.js.map → cost-_SE_SVgZ.js.map} +1 -1
- package/dist/{db-DsPkOVEH.d.ts → db-DjjthkTi.d.ts} +2 -2
- package/dist/{deploy-DonTr-CV.js → deploy-Di_Q01qx.js} +5 -5
- package/dist/deploy-Di_Q01qx.js.map +1 -0
- package/dist/dev-vite.d.ts +31 -27
- package/dist/dev-vite.js +60 -30
- package/dist/dev-vite.js.map +1 -1
- package/dist/dev.d.ts +1 -1
- package/dist/doctor-RWVRpvat.js +102 -0
- package/dist/doctor-RWVRpvat.js.map +1 -0
- package/dist/{dump-Bh5k26VQ.js → dump-m2vEYDNY.js} +4 -4
- package/dist/{dump-Bh5k26VQ.js.map → dump-m2vEYDNY.js.map} +1 -1
- package/dist/{export-DtF5tDIM.js → export-DenKwEQu.js} +4 -4
- package/dist/{export-DtF5tDIM.js.map → export-DenKwEQu.js.map} +1 -1
- package/dist/{fsck-D_djMO5D.js → fsck-2Vq-7-e2.js} +5 -5
- package/dist/{fsck-D_djMO5D.js.map → fsck-2Vq-7-e2.js.map} +1 -1
- package/dist/gcs-admin-Bx6xSNJj.d.ts +123 -0
- package/dist/gcs.d.ts +18 -0
- package/dist/gcs.js +2 -0
- package/dist/goog4-signer-Z7KnJ1su.js +321 -0
- package/dist/goog4-signer-Z7KnJ1su.js.map +1 -0
- package/dist/{http-DGd5tbNs.js → http-7zT29K3P.js} +4 -4
- package/dist/{http-DGd5tbNs.js.map → http-7zT29K3P.js.map} +1 -1
- package/dist/{aws4fetch.esm-p7eEzLCs.js → http-transport-BTgVCY5r.js} +24 -476
- package/dist/http-transport-BTgVCY5r.js.map +1 -0
- package/dist/http.d.ts +2 -2
- package/dist/http.js +2 -2
- package/dist/{index-BNRh23K9.d.ts → index-BHz92Acj.d.ts} +2 -2
- package/dist/{index-BYk9oCNf.d.ts → index-CEZKQsKt.d.ts} +3 -2
- package/dist/{index-CuA9Mi3K.d.ts → index-DP3ClvcA.d.ts} +7 -7
- package/dist/{index-0rZcMBwy.d.ts → index-uE-w2dgj.d.ts} +2 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/{inspect-6WZ-pC7-.js → inspect-BpYbH1DM.js} +5 -5
- package/dist/{inspect-6WZ-pC7-.js.map → inspect-BpYbH1DM.js.map} +1 -1
- package/dist/{log-tail-D98U1JBo.js → log-tail-QWU4wlu-.js} +3 -11
- package/dist/log-tail-QWU4wlu-.js.map +1 -0
- package/dist/{maintenance-B_e0T99L.d.ts → maintenance-BGHGt2Yg.d.ts} +2 -2
- package/dist/{maintenance-B4Dki6Ig.js → maintenance-DULFcpd1.js} +4 -17
- package/dist/maintenance-DULFcpd1.js.map +1 -0
- package/dist/{maintenance-C7coQp4c.js → maintenance-fEi-UZ2o.js} +5 -11
- package/dist/maintenance-fEi-UZ2o.js.map +1 -0
- package/dist/maintenance.d.ts +1 -1
- package/dist/maintenance.js +1 -1
- package/dist/node.d.ts +21 -60
- package/dist/node.js +4 -3
- package/dist/{observability-BmflLCdF.js → observability-Ch-VQJyE.js} +38 -16
- package/dist/{observability-BmflLCdF.js.map → observability-Ch-VQJyE.js.map} +1 -1
- package/dist/observability.d.ts +2 -2
- package/dist/observability.js +1 -1
- package/dist/{plan-a7PJHBCy.js → plan-C4qgiXSg.js} +2 -2
- package/dist/{plan-a7PJHBCy.js.map → plan-C4qgiXSg.js.map} +1 -1
- package/dist/{query-rAtXNQQB.js → query-C43r-6ib.js} +2 -2
- package/dist/{query-rAtXNQQB.js.map → query-C43r-6ib.js.map} +1 -1
- package/dist/{rebuild-index-BVzQSZlm.js → rebuild-index-BH1dc1p6.js} +4 -4
- package/dist/{rebuild-index-BVzQSZlm.js.map → rebuild-index-BH1dc1p6.js.map} +1 -1
- package/dist/{restore-R-4rbciV.js → restore-D0VYWzfP.js} +5 -5
- package/dist/{restore-R-4rbciV.js.map → restore-D0VYWzfP.js.map} +1 -1
- package/dist/{runtime-spec-Dsw2-n8S.js → runtime-spec--LykAdl1.js} +2 -2
- package/dist/{runtime-spec-Dsw2-n8S.js.map → runtime-spec--LykAdl1.js.map} +1 -1
- package/dist/{s3-http-B-z8th6O.d.ts → s3-http-DD5gDc7t.d.ts} +6 -4
- package/dist/s3.d.ts +1 -1
- package/dist/s3.js +1 -1
- package/dist/sha256-CqcKTjw9.js +22 -0
- package/dist/sha256-CqcKTjw9.js.map +1 -0
- package/dist/{src-BL_JoPTn.js → src-BMFfDUI2.js} +68 -28
- package/dist/{src-BL_JoPTn.js.map → src-BMFfDUI2.js.map} +1 -1
- package/dist/{src-CYHFDrKz.js → src-DvbTEya2.js} +3 -3
- package/dist/{src-CYHFDrKz.js.map → src-DvbTEya2.js.map} +1 -1
- package/dist/{subcommand-DoDA-K7d.js → subcommand-BV68pqwJ.js} +2 -2
- package/dist/{subcommand-DoDA-K7d.js.map → subcommand-BV68pqwJ.js.map} +1 -1
- package/dist/{usage-DBV1eQHC.js → usage-BMZR8o6U.js} +3 -3
- package/dist/{usage-DBV1eQHC.js.map → usage-BMZR8o6U.js.map} +1 -1
- package/package.json +10 -4
- package/dist/aws4fetch.esm-p7eEzLCs.js.map +0 -1
- package/dist/cloudflare-DzKBrUlg.js.map +0 -1
- package/dist/config-1tv0-Yzm.js.map +0 -1
- 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/log-tail-D98U1JBo.js.map +0 -1
- package/dist/maintenance-B4Dki6Ig.js.map +0 -1
- package/dist/maintenance-C7coQp4c.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-transport-BTgVCY5r.js","names":[],"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/http-transport.ts"],"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; Generation?: string }>;\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 (& < >\n// " ') and decimal/hex numeric character references (e.g. Minio's\n// " 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 ( 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 // GCS's list XML carries a `<Generation>` element per object (its\n // opaque version token) that S3/R2 never emit — undefined there, so\n // this is inert for the S3 path. `GcsHttpStorage.list` prefers it as\n // the entry etag so a list etag equals the generation `get`/`put`\n // return, matching the universal list-etag == version-token contract.\n Generation: rawXmlVal(contentEl, \"Generation\"),\n };\n }),\n NextContinuationToken: rawXmlVal(root, \"NextContinuationToken\"),\n };\n};\n","import {\n BaerlyError,\n RETRY_AFTER_MAX_SECONDS,\n S3_REQUEST_MAX_RETRIES,\n delay,\n} from \"@baerly/protocol\";\nimport { 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 */\nexport function parseRetryAfter(\n header: string | null,\n now: () => number = Date.now,\n): 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\nexport const 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 XML error response (S3 and GCS's\n// native XML API share the same `<Error><Code>…</Error>` body shape). When\n// the body is a parseable document, surface the store's own error code (and\n// message) instead of concatenating the raw XML blob into the thrown\n// message; otherwise fall back to the raw text.\nexport const xmlErrorDetail = (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\n/**\n * Shared status→{@link BaerlyError} mapping for the S3/GCS XML adapters, so\n * the retryable set (`429`/`≥500`) can't drift between them. Store-specific\n * statuses (GCS `412`; S3 `409`/`404`-with-`If-Match`) are handled inline\n * first; the rest route here: `403`→AccessDenied (permanent), `429`/`≥500`→\n * retryable NetworkError carrying `{status, retryAfterSeconds?}`, else\n * InvalidResponse. Callers `throw` the result; consumes `res.text()` on the\n * non-`403` paths.\n */\nexport const mapStorageError = async (\n res: Response,\n verb: string,\n key: string,\n): Promise<BaerlyError> => {\n if (res.status === 403) {\n return new BaerlyError(\"AccessDenied\", `${verb} ${key}: 403`);\n }\n if (res.status === 429 || res.status >= 500) {\n return new BaerlyError(\"NetworkError\", `${verb} ${key}: ${res.status} ${await res.text()}`, {\n status: res.status,\n ...retryAfterCause(res),\n });\n }\n return new BaerlyError(\n \"InvalidResponse\",\n `${verb} ${key}: ${xmlErrorDetail(res.status, await res.text())}`,\n );\n};\n\nexport const 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(\n \"Internal\",\n \"http-transport retry loop exited without returning or throwing\",\n );\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"],"x_google_ignoreList":[0],"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;EAAA;EAEvH,OAAO;CACT;CACA,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;CAGzF,IAAI,cAAc,CAAC;CACnB,SAAS,aAAa;EACpB,gB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AAO,GAAG,MAAM,IAAI,KAAK,KAAK;EAC1F,QAAQ,IAAI;EACZ,GAAG,gBAAgB,GAAG;CACxB,CAAC;CAEH,OAAO,IAAI,YACT,mBACA,GAAG,KAAK,GAAG,IAAI,IAAI,eAAe,IAAI,QAAQ,MAAM,IAAI,KAAK,CAAC,GAChE;AACF;AAEA,MAAa,QAAQ,OACnB,IACA,EAAE,UAAA,GAAkC,YAAY,KAAK,aAAa,QAAW,CAAC,MAC/D;CACf,IAAI,OAAO;CACX,KAAK,IAAI,UAAU,GAAG,WAAW,SAAS,WACxC,IAAI;EACF,OAAO,MAAM,GAAG;CAClB,SAAS,OAAO;EACd,IAAI,iBAAiB,eAAe,sBAAsB,IAAI,MAAM,IAAI,GACtE,MAAM;EAER,IAAI,YAAY,SACd,MAAM;EAER,MAAM,SAAS,iBAAiB,OAAO,UAAU;EACjD,MAAM,MAAM,UAAU,IAAI;EAC1B,IAAI,WAAW,KAAA,GACb,OAAO,KAAK,IAAI,OAAO,KAAK,UAAU;OAKtC,OAAO;CAEX;CAEF,MAAM,IAAI,YACR,YACA,gEACF;AACF;AAEA,MAAM,oBAAoB,GAAY,eAA2C;CAC/E,IAAI,EAAE,aAAa,cACjB;CAEF,MAAM,QAAQ,EAAE;CAChB,IAAI,OAAO,sBAAsB,KAAA,GAC/B;CAEF,OAAO,KAAK,IAAI,MAAM,oBAAoB,KAAM,UAAU;AAC5D"}
|
package/dist/http.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { r as BaerlyConfig } from "./app-config-DyiFK3_k.js";
|
|
2
|
-
import { b as BaerlyErrorCode, n as LogEntry } from "./index-
|
|
3
|
-
import { t as Db } from "./db-
|
|
2
|
+
import { b as BaerlyErrorCode, n as LogEntry } from "./index-CEZKQsKt.js";
|
|
3
|
+
import { t as Db } from "./db-DjjthkTi.js";
|
|
4
4
|
|
|
5
5
|
//#region node_modules/.pnpm/hono@4.12.27/node_modules/hono/dist/types/request/constants.d.ts
|
|
6
6
|
declare const GET_MATCH_RESULT: unique symbol;
|
package/dist/http.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { u as errorEnvelope } from "./observability-
|
|
2
|
-
import { a as longPollSince, i as listEventsSince, n as createRouter, r as mapError, t as MAX_BODY_BYTES } from "./http-
|
|
1
|
+
import { u as errorEnvelope } from "./observability-Ch-VQJyE.js";
|
|
2
|
+
import { a as longPollSince, i as listEventsSince, n as createRouter, r as mapError, t as MAX_BODY_BYTES } from "./http-7zT29K3P.js";
|
|
3
3
|
export { MAX_BODY_BYTES, createRouter, errorEnvelope, listEventsSince, longPollSince, mapError };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { d as IndexDefinition, f as DocumentData, n as BaerlyAppConfig, r as BaerlyConfig, u as SchemaValidator, v as SNAPSHOT_SCHEMA_VERSION } from "./app-config-DyiFK3_k.js";
|
|
2
|
-
import { n as LogEntry, p as Storage, r as Verifier } from "./index-
|
|
2
|
+
import { n as LogEntry, p as Storage, r as Verifier } from "./index-CEZKQsKt.js";
|
|
3
3
|
//#region packages/server/src/config.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Flatten `BaerlyConfig.collections` into the per-collection
|
|
@@ -159,4 +159,4 @@ declare const probeTailFrom: (storage: Storage, logPrefix: string, hint: number,
|
|
|
159
159
|
}>;
|
|
160
160
|
//#endregion
|
|
161
161
|
export { loadSnapshotAsMap as a, collectionsToMaps as c, encodeSnapshotBody as i, walkLogRange as n, snapshotKey as o, SnapshotBody as r, resolveVerifier as s, probeTailFrom as t };
|
|
162
|
-
//# sourceMappingURL=index-
|
|
162
|
+
//# sourceMappingURL=index-BHz92Acj.d.ts.map
|
|
@@ -164,7 +164,8 @@ declare class BaerlyError extends Error {
|
|
|
164
164
|
/**
|
|
165
165
|
* Object-storage abstraction. The protocol kernel writes through
|
|
166
166
|
* this and only this. Implementations: in-memory (testing), S3 HTTP
|
|
167
|
-
* (production), R2 binding (
|
|
167
|
+
* and native GCS HTTP (production), R2 binding (production), local-fs
|
|
168
|
+
* (dev).
|
|
168
169
|
*
|
|
169
170
|
* Cancellation: every method accepts an optional AbortSignal.
|
|
170
171
|
* Implementations should respect it where feasible; consumers may
|
|
@@ -1109,4 +1110,4 @@ interface MetricsRecorder {
|
|
|
1109
1110
|
}
|
|
1110
1111
|
//#endregion
|
|
1111
1112
|
export { StoragePutOptions as _, MemoryStorage as a, BaerlyErrorCode as b, Predicate as c, CurrentJson as d, CurrentJsonRead as f, StorageListEntry as g, StorageGetResult as h, VerifierResult as i, Query as l, StorageGetOptions as m, LogEntry as n, Collection as o, Storage as p, Verifier as r, OrderSpec as s, MetricsRecorder as t, PredicateArg as u, StoragePutResult as v, BaerlyError as y };
|
|
1112
|
-
//# sourceMappingURL=index-
|
|
1113
|
+
//# sourceMappingURL=index-CEZKQsKt.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { p as Storage, t as MetricsRecorder } from "./index-
|
|
2
|
-
import { o as MaintenanceDispatch } from "./maintenance-
|
|
1
|
+
import { p as Storage, t as MetricsRecorder } from "./index-CEZKQsKt.js";
|
|
2
|
+
import { o as MaintenanceDispatch } from "./maintenance-BGHGt2Yg.js";
|
|
3
3
|
|
|
4
4
|
//#region packages/server/src/observability/recorder.d.ts
|
|
5
5
|
/** One observation row, kept in insertion order. */
|
|
@@ -133,7 +133,7 @@ declare const runWithContext: <T>(ctx: ObservabilityContext, fn: () => T | Promi
|
|
|
133
133
|
/** Returns the currently-active context, or `undefined` outside one. */
|
|
134
134
|
declare const getCurrentContext: () => ObservabilityContext | undefined;
|
|
135
135
|
//#endregion
|
|
136
|
-
//#region node_modules/.pnpm/@logtape+logtape@2.2.
|
|
136
|
+
//#region node_modules/.pnpm/@logtape+logtape@2.2.4/node_modules/@logtape/logtape/dist/level.d.ts
|
|
137
137
|
//#region src/level.d.ts
|
|
138
138
|
declare const logLevels: readonly ["trace", "debug", "info", "warning", "error", "fatal"];
|
|
139
139
|
/**
|
|
@@ -147,7 +147,7 @@ type LogLevel = typeof logLevels[number];
|
|
|
147
147
|
* @since 1.0.0
|
|
148
148
|
*/
|
|
149
149
|
//#endregion
|
|
150
|
-
//#region node_modules/.pnpm/@logtape+logtape@2.2.
|
|
150
|
+
//#region node_modules/.pnpm/@logtape+logtape@2.2.4/node_modules/@logtape/logtape/dist/record.d.ts
|
|
151
151
|
//#region src/record.d.ts
|
|
152
152
|
/**
|
|
153
153
|
* A log record.
|
|
@@ -193,7 +193,7 @@ interface LogRecord {
|
|
|
193
193
|
} //# sourceMappingURL=record.d.ts.map
|
|
194
194
|
//#endregion
|
|
195
195
|
//#endregion
|
|
196
|
-
//#region node_modules/.pnpm/@logtape+logtape@2.2.
|
|
196
|
+
//#region node_modules/.pnpm/@logtape+logtape@2.2.4/node_modules/@logtape/logtape/dist/sink.d.ts
|
|
197
197
|
//#region src/sink.d.ts
|
|
198
198
|
/**
|
|
199
199
|
* A sink is a function that accepts a log record and prints it somewhere.
|
|
@@ -215,7 +215,7 @@ type Sink = (record: LogRecord) => void;
|
|
|
215
215
|
* @since 1.0.0
|
|
216
216
|
*/
|
|
217
217
|
//#endregion
|
|
218
|
-
//#region node_modules/.pnpm/@logtape+logtape@2.2.
|
|
218
|
+
//#region node_modules/.pnpm/@logtape+logtape@2.2.4/node_modules/@logtape/logtape/dist/logger.d.ts
|
|
219
219
|
/**
|
|
220
220
|
* A logger interface. It provides methods to log messages at different
|
|
221
221
|
* severity levels.
|
|
@@ -1468,4 +1468,4 @@ type Outcome = "read" | "committed" | "conflict" | "error";
|
|
|
1468
1468
|
declare const deriveOutcome: (method: string, status: number, error?: unknown) => Outcome;
|
|
1469
1469
|
//#endregion
|
|
1470
1470
|
export { ObservabilityContextInit as _, flushCanonicalLine as a, runWithContext as b, CATEGORY as c, ObservabilityConfig as d, configureObservability as f, ObservabilityContext as g, LogRecord as h, FlushCanonicalLineOptions as i, CategoryName as l, Sink as m, deriveOutcome as n, flushUnauthorizedAndRespond as o, getLogger as p, observableStorage as r, withHttpObservability as s, Outcome as t, FriendlyLogLevel as u, createObservabilityContext as v, getCurrentContext as y };
|
|
1471
|
-
//# sourceMappingURL=index-
|
|
1471
|
+
//# sourceMappingURL=index-DP3ClvcA.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as StoragePutOptions, g as StorageListEntry, h as StorageGetResult, m as StorageGetOptions, p as Storage, v as StoragePutResult } from "./index-
|
|
1
|
+
import { _ as StoragePutOptions, g as StorageListEntry, h as StorageGetResult, m as StorageGetOptions, p as Storage, v as StoragePutResult } from "./index-CEZKQsKt.js";
|
|
2
2
|
|
|
3
3
|
//#region packages/dev/src/dev-landing.d.ts
|
|
4
4
|
/**
|
|
@@ -112,4 +112,4 @@ declare class LocalFsStorage implements Storage {
|
|
|
112
112
|
}
|
|
113
113
|
//#endregion
|
|
114
114
|
export { renderDevLanding as a, DevLandingOptions as i, LocalFsStorageOptions as n, ensureTable as r, LocalFsStorage as t };
|
|
115
|
-
//# sourceMappingURL=index-
|
|
115
|
+
//# sourceMappingURL=index-uE-w2dgj.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as CollectionNames, c as defineConfig, d as IndexDefinition, f as DocumentData, i as CollectionDefinition, l as SchemaIssue, n as BaerlyAppConfig, o as RowOf, r as BaerlyConfig, s as UnboundConfig, u as SchemaValidator } from "./app-config-DyiFK3_k.js";
|
|
2
|
-
import { a as MemoryStorage, b as BaerlyErrorCode, c as Predicate, g as StorageListEntry, h as StorageGetResult, i as VerifierResult, l as Query, o as Collection, p as Storage, r as Verifier, u as PredicateArg, v as StoragePutResult, y as BaerlyError } from "./index-
|
|
2
|
+
import { a as MemoryStorage, b as BaerlyErrorCode, c as Predicate, g as StorageListEntry, h as StorageGetResult, i as VerifierResult, l as Query, o as Collection, p as Storage, r as Verifier, u as PredicateArg, v as StoragePutResult, y as BaerlyError } from "./index-CEZKQsKt.js";
|
|
3
3
|
import { t as allIndexKeysFor } from "./indexes-Dn9hbGQG.js";
|
|
4
|
-
import { a as loadSnapshotAsMap, c as collectionsToMaps, i as encodeSnapshotBody, n as walkLogRange, o as snapshotKey, r as SnapshotBody, s as resolveVerifier, t as probeTailFrom } from "./index-
|
|
5
|
-
import { n as validateOrThrow, t as Db } from "./db-
|
|
4
|
+
import { a as loadSnapshotAsMap, c as collectionsToMaps, i as encodeSnapshotBody, n as walkLogRange, o as snapshotKey, r as SnapshotBody, s as resolveVerifier, t as probeTailFrom } from "./index-BHz92Acj.js";
|
|
5
|
+
import { n as validateOrThrow, t as Db } from "./db-DjjthkTi.js";
|
|
6
6
|
export { type BaerlyAppConfig, type BaerlyConfig, BaerlyError, type BaerlyErrorCode, type Collection, type CollectionDefinition, type CollectionNames, Db, type DocumentData, type IndexDefinition, MemoryStorage, type Predicate, type PredicateArg, type Query, type RowOf, type SchemaIssue, type SchemaValidator, type SnapshotBody, type Storage, type StorageGetResult, type StorageListEntry, type StoragePutResult, type UnboundConfig, type Verifier, type VerifierResult, allIndexKeysFor, collectionsToMaps, defineConfig, encodeSnapshotBody, loadSnapshotAsMap, probeTailFrom, resolveVerifier, snapshotKey, validateOrThrow, walkLogRange };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineConfig } from "./app-config.js";
|
|
2
2
|
import { t as BaerlyError } from "./errors-Dfa3p78c.js";
|
|
3
|
-
import { b as loadSnapshotAsMap, g as allIndexKeysFor, h as walkLogRange, w as probeTailFrom, x as snapshotKey, y as encodeSnapshotBody } from "./maintenance-
|
|
4
|
-
import { i as MemoryStorage, n as resolveVerifier, r as collectionsToMaps, t as Db } from "./src-
|
|
5
|
-
import { o as validateOrThrow } from "./query-
|
|
3
|
+
import { b as loadSnapshotAsMap, g as allIndexKeysFor, h as walkLogRange, w as probeTailFrom, x as snapshotKey, y as encodeSnapshotBody } from "./maintenance-DULFcpd1.js";
|
|
4
|
+
import { i as MemoryStorage, n as resolveVerifier, r as collectionsToMaps, t as Db } from "./src-DvbTEya2.js";
|
|
5
|
+
import { o as validateOrThrow } from "./query-C43r-6ib.js";
|
|
6
6
|
export { BaerlyError, Db, MemoryStorage, allIndexKeysFor, collectionsToMaps, defineConfig, encodeSnapshotBody, loadSnapshotAsMap, probeTailFrom, resolveVerifier, snapshotKey, validateOrThrow, walkLogRange };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { n as loadCollectionIndexes, r as parseBucketUri } from "./config-
|
|
2
|
-
import { h as readCurrentJson, n as probeTailFrom } from "./log-tail-
|
|
1
|
+
import { n as loadCollectionIndexes, r as parseBucketUri } from "./config-B6nTy8e2.js";
|
|
2
|
+
import { h as readCurrentJson, n as probeTailFrom } from "./log-tail-QWU4wlu-.js";
|
|
3
3
|
import { i as isJsonMode, o as BaerlyError, r as emitSuccess } from "./baerly.js";
|
|
4
|
-
import { n as loadMaterialisedView } from "./plan-
|
|
5
|
-
import { a as TENANT_ARG, i as JSON_ARG, n as BUCKET_ARG, o as assertCollectionArg, r as COLLECTION_ARG, s as defineBaerlySubcommand, t as APP_ARG } from "./subcommand-
|
|
4
|
+
import { n as loadMaterialisedView } from "./plan-C4qgiXSg.js";
|
|
5
|
+
import { a as TENANT_ARG, i as JSON_ARG, n as BUCKET_ARG, o as assertCollectionArg, r as COLLECTION_ARG, s as defineBaerlySubcommand, t as APP_ARG } from "./subcommand-BV68pqwJ.js";
|
|
6
6
|
//#region src/inspect.ts
|
|
7
7
|
const INSPECT_ARGS = {
|
|
8
8
|
bucket: BUCKET_ARG,
|
|
@@ -130,4 +130,4 @@ bundle.run;
|
|
|
130
130
|
//#endregion
|
|
131
131
|
export { inspect };
|
|
132
132
|
|
|
133
|
-
//# sourceMappingURL=inspect-
|
|
133
|
+
//# sourceMappingURL=inspect-BpYbH1DM.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inspect-6WZ-pC7-.js","names":[],"sources":["../packages/cli/src/inspect.ts"],"sourcesContent":["/**\n * `baerly inspect` — read-only summary for one collection.\n *\n * Args:\n * --bucket Required. Bucket URI.\n * --app Required (or via baerly.config.ts).\n * --tenant Required (or via baerly.config.ts).\n * --collection Required. Collection name.\n * --config Optional path to baerly.config.{js,mjs,json} for index info.\n * --json JSON envelope.\n *\n * Reports, per-collection:\n * - currentJsonKey path.\n * - schema_version, tail_hint, log_seq_start (default 0).\n * - live_log_tail (= tail_hint - log_seq_start).\n * - snapshot key (or null).\n * - snapshot_bytes / snapshot_rows (the fold-ceiling inputs C / E\n * are compared against; see graduation.md).\n * - writer_fence (epoch, owner, claimed_at).\n * - materialised row count (via export/loadMaterialisedView).\n * - per-declared-index key count (when --config supplied).\n * - well-formed status: \"ok\" or \"error\" with an `errors` array.\n *\n * For projected monthly Class A / $ trajectories, use\n * `baerly cost --bucket=<uri> --collection=<name>` — the projection\n * used to live as a footer here but moved to its own verb so inspect\n * stays a glance command (no GET-storm over the trailing log sample).\n *\n * Cost shape:\n * 1 GET current.json\n * + 1 GET snapshot (if any)\n * + N GETs log tail (= tail_hint - log_seq_start)\n * + K LISTs (one per declared index, when --config supplied)\n * + 1 LIST snapshot/ prefix (orphan detection)\n *\n * Never mutates anything.\n *\n * Exit codes:\n * 0 — inspection ran (status may be \"ok\" or \"error\"; both exit 0).\n * 1 — InvalidConfig (bad bucket URI, missing args, unknown flag).\n * 2 — Storage / Network error.\n * 3 — Protocol invariant (Conflict / Internal / InvalidResponse).\n */\n\nimport { type ArgsDef } from \"citty\";\nimport { BaerlyError, readCurrentJson, type CurrentJson, type Storage } from \"@baerly/protocol\";\nimport { probeTailFrom } from \"@baerly/server\";\nimport { loadMaterialisedView } from \"./export/index.ts\";\nimport { loadCollectionIndexes } from \"./config.ts\";\nimport { parseBucketUri } from \"./bucket-uri.ts\";\nimport { emitSuccess, isJsonMode } from \"./output.ts\";\nimport {\n APP_ARG,\n assertCollectionArg,\n BUCKET_ARG,\n COLLECTION_ARG,\n defineBaerlySubcommand,\n JSON_ARG,\n TENANT_ARG,\n} from \"./subcommand.ts\";\n\nconst INSPECT_ARGS = {\n bucket: BUCKET_ARG,\n app: APP_ARG,\n tenant: TENANT_ARG,\n collection: COLLECTION_ARG,\n config: {\n type: \"string\",\n required: false,\n description:\n \"Path to baerly.config.{js,mjs,json}; pulls declared indexes for key-count probes.\",\n valueHint: \"path\",\n },\n json: JSON_ARG,\n} as const satisfies ArgsDef;\n\nconst countListEntries = async (\n storage: Storage,\n prefix: string,\n): Promise<{ count: number; keys: string[] }> => {\n let count = 0;\n const keys: string[] = [];\n for await (const entry of storage.list(prefix)) {\n count++;\n keys.push(entry.key);\n }\n return { count, keys };\n};\n\ninterface InspectResult {\n currentJsonKey: string;\n schema_version: number;\n /** The stored, compactor-advanced lower-bound hint (`current.json.tail_hint`). */\n tail_hint: number;\n /** The TRUE committed tail, discovered by forward-probe past `tail_hint`. */\n discovered_tail: number;\n log_seq_start: number;\n live_log_tail: number;\n snapshot: string | null;\n snapshot_bytes: number;\n snapshot_rows: number;\n writer_fence: CurrentJson[\"writer_fence\"];\n materialised_rows: number;\n indexes: { name: string; count: number }[];\n status: \"ok\" | \"error\";\n errors: string[];\n}\n\nconst renderText = (r: InspectResult, collection: string): string => {\n const lines: string[] = [];\n lines.push(`baerly inspect ${collection}`);\n lines.push(` current.json: ${r.currentJsonKey}`);\n lines.push(` schema_version: ${r.schema_version}`);\n lines.push(` tail_hint (stored): ${r.tail_hint}`);\n lines.push(` discovered_tail: ${r.discovered_tail}`);\n lines.push(` log_seq_start: ${r.log_seq_start}`);\n lines.push(` live_log_tail: ${r.live_log_tail}`);\n lines.push(` snapshot: ${r.snapshot ?? \"(none)\"}`);\n lines.push(` snapshot_bytes: ${r.snapshot_bytes}`);\n lines.push(` snapshot_rows: ${r.snapshot_rows}`);\n lines.push(\n ` writer_fence: epoch=${r.writer_fence.epoch} owner=${JSON.stringify(r.writer_fence.owner)} claimed_at=${JSON.stringify(r.writer_fence.claimed_at)}`,\n );\n lines.push(` materialised_rows: ${r.materialised_rows}`);\n if (r.indexes.length > 0) {\n const formatted = r.indexes.map((i) => `${i.name} (count=${i.count})`).join(\", \");\n lines.push(` indexes: ${formatted}`);\n } else {\n lines.push(` indexes: (none declared)`);\n }\n lines.push(` status: ${r.status}`);\n if (r.errors.length > 0) {\n for (const e of r.errors) {\n lines.push(` error: ${e}`);\n }\n }\n return lines.join(\"\\n\") + \"\\n\";\n};\n\nconst bundle = defineBaerlySubcommand({\n name: \"inspect\",\n meta: {\n description: \"Read-only summary of one collection's snapshot + log state.\",\n },\n args: INSPECT_ARGS,\n handler: async (args, ctx) => {\n const bucket = await parseBucketUri(args.bucket);\n const { app, tenant } = await ctx.resolveAppTenant({ app: args.app, tenant: args.tenant });\n assertCollectionArg(args.collection, \"baerly inspect\");\n const collectionPrefix = `${bucket.keyPrefix}app/${app}/tenant/${tenant}/manifests/${args.collection}`;\n const currentJsonKey = `${collectionPrefix}/current.json`;\n\n const read = await readCurrentJson(bucket.storage, currentJsonKey);\n if (read === null) {\n throw new BaerlyError(\n \"InvalidConfig\",\n `baerly inspect: current.json not found at ${currentJsonKey}`,\n );\n }\n const cur = read.json;\n const log_seq_start = cur.log_seq_start ?? 0;\n // Discover the TRUE tail by forward-probe — under single-write commit\n // the stored `tail_hint` is only a lower bound (compactor-advanced),\n // so an accurate operator summary must probe past it.\n const tailProbe = await probeTailFrom(\n bucket.storage,\n collectionPrefix,\n Math.max(log_seq_start, cur.tail_hint),\n );\n const discoveredTail = tailProbe.tail;\n\n const errors: string[] = [];\n let materialisedRows = 0;\n try {\n const view = await loadMaterialisedView({\n storage: bucket.storage,\n currentJsonKey,\n collection: args.collection,\n });\n materialisedRows = view?.size ?? 0;\n } catch (error) {\n if (error instanceof BaerlyError) {\n errors.push(`${error.code}: ${error.message}`);\n } else {\n errors.push((error as Error).message);\n }\n }\n\n // Orphan-snapshot detection: list every file under <collectionPrefix>/snapshot/\n // and flag anything that isn't the currently-pointed-at snapshot.\n try {\n const snapshotPrefix = `${collectionPrefix}/snapshot/`;\n const { keys } = await countListEntries(bucket.storage, snapshotPrefix);\n for (const k of keys) {\n if (cur.snapshot !== k) {\n errors.push(`orphan snapshot: ${k}`);\n }\n }\n } catch (error) {\n if (error instanceof BaerlyError) {\n errors.push(`${error.code}: ${error.message}`);\n }\n }\n\n const indexes: { name: string; count: number }[] = [];\n if (typeof args.config === \"string\" && args.config.length > 0) {\n const defs = await loadCollectionIndexes(args.config, args.collection, \"baerly inspect\");\n for (const def of defs) {\n const prefix = `${collectionPrefix}/index/${def.name}/`;\n const { count } = await countListEntries(bucket.storage, prefix);\n indexes.push({ name: def.name, count });\n }\n }\n\n const result: InspectResult = {\n currentJsonKey,\n schema_version: cur.schema_version,\n tail_hint: cur.tail_hint,\n discovered_tail: discoveredTail,\n log_seq_start,\n live_log_tail: discoveredTail - log_seq_start,\n snapshot: cur.snapshot,\n snapshot_bytes: cur.snapshot_bytes,\n snapshot_rows: cur.snapshot_rows,\n writer_fence: cur.writer_fence,\n materialised_rows: materialisedRows,\n indexes,\n status: errors.length === 0 ? \"ok\" : \"error\",\n errors,\n };\n\n if (isJsonMode()) {\n emitSuccess({ command: \"inspect\", ...result });\n } else {\n process.stdout.write(renderText(result, args.collection));\n }\n return 0;\n },\n});\n\n/** citty `defineCommand` block for `baerly inspect`. */\nexport const inspect = bundle.cmd;\n\n/**\n * Programmatic entry used by tests. Bypasses citty's `run` wrapper\n * (which would call `process.exit` and kill vitest) and returns the\n * integer exit code directly.\n */\nexport const runInspect = bundle.run;\n"],"mappings":";;;;;;AA6DA,MAAM,eAAe;CACnB,QAAQ;CACR,KAAK;CACL,QAAQ;CACR,YAAY;CACZ,QAAQ;EACN,MAAM;EACN,UAAU;EACV,aACE;EACF,WAAW;CACb;CACA,MAAM;AACR;AAEA,MAAM,mBAAmB,OACvB,SACA,WAC+C;CAC/C,IAAI,QAAQ;CACZ,MAAM,OAAiB,CAAC;CACxB,WAAW,MAAM,SAAS,QAAQ,KAAK,MAAM,GAAG;E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KAAK,YAAY,gBAAgB;GACvF,KAAK,MAAM,OAAO,MAAM;IACtB,MAAM,SAAS,GAAG,iBAAiB,SAAS,IAAI,KAAK;IACrD,MAAM,EAAE,UAAU,MAAM,iBAAiB,OAAO,SAAS,MAAM;IAC/D,QAAQ,KAAK;KAAE,MAAM,IAAI;KAAM;IAAM,CAAC;GACxC;EACF;EAEA,MAAM,SAAwB;GAC5B;GACA,gBAAgB,IAAI;GACpB,WAAW,IAAI;GACf,iBAAiB;GACjB;GACA,eAAe,iBAAiB;GAChC,UAAU,IAAI;GACd,gBAAgB,IAAI;GACpB,eAAe,IAAI;GACnB,cAAc,IAAI;GAClB,mBAAmB;GACnB;GACA,QAAQ,OAAO,WAAW,IAAI,OAAO;GACrC;EACF;EAEA,IAAI,WAAW,GACb,YAAY;GAAE,SAAS;GAAW,GAAG;EAAO,CAAC;OAE7C,QAAQ,OAAO,MAAM,WAAW,QAAQ,KAAK,UAAU,CAAC;EAE1D,OAAO;CACT;AACF,CAAC;;AAGD,MAAa,UAAU,OAAO;AAOJ,OAAO"}
|
|
1
|
+
{"version":3,"file":"inspect-BpYbH1DM.js","names":[],"sources":["../packages/cli/src/inspect.ts"],"sourcesContent":["/**\n * `baerly inspect` — read-only summary for one collection.\n *\n * Args:\n * --bucket Required. Bucket URI.\n * --app Required (or via baerly.config.ts).\n * --tenant Required (or via baerly.config.ts).\n * --collection Required. Collection name.\n * --config Optional path to baerly.config.{js,mjs,json} for index info.\n * --json JSON envelope.\n *\n * Reports, per-collection:\n * - currentJsonKey path.\n * - schema_version, tail_hint, log_seq_start (default 0).\n * - live_log_tail (= tail_hint - log_seq_start).\n * - snapshot key (or null).\n * - snapshot_bytes / snapshot_rows (the fold-ceiling inputs C / E\n * are compared against; see graduation.md).\n * - writer_fence (epoch, owner, claimed_at).\n * - materialised row count (via export/loadMaterialisedView).\n * - per-declared-index key count (when --config supplied).\n * - well-formed status: \"ok\" or \"error\" with an `errors` array.\n *\n * For projected monthly Class A / $ trajectories, use\n * `baerly cost --bucket=<uri> --collection=<name>` — the projection\n * used to live as a footer here but moved to its own verb so inspect\n * stays a glance command (no GET-storm over the trailing log sample).\n *\n * Cost shape:\n * 1 GET current.json\n * + 1 GET snapshot (if any)\n * + N GETs log tail (= tail_hint - log_seq_start)\n * + K LISTs (one per declared index, when --config supplied)\n * + 1 LIST snapshot/ prefix (orphan detection)\n *\n * Never mutates anything.\n *\n * Exit codes:\n * 0 — inspection ran (status may be \"ok\" or \"error\"; both exit 0).\n * 1 — InvalidConfig (bad bucket URI, missing args, unknown flag).\n * 2 — Storage / Network error.\n * 3 — Protocol invariant (Conflict / Internal / InvalidResponse).\n */\n\nimport { type ArgsDef } from \"citty\";\nimport { BaerlyError, readCurrentJson, type CurrentJson, type Storage } from \"@baerly/protocol\";\nimport { probeTailFrom } from \"@baerly/server\";\nimport { loadMaterialisedView } from \"./export/index.ts\";\nimport { loadCollectionIndexes } from \"./config.ts\";\nimport { parseBucketUri } from \"./bucket-uri.ts\";\nimport { emitSuccess, isJsonMode } from \"./output.ts\";\nimport {\n APP_ARG,\n assertCollectionArg,\n BUCKET_ARG,\n COLLECTION_ARG,\n defineBaerlySubcommand,\n JSON_ARG,\n TENANT_ARG,\n} from \"./subcommand.ts\";\n\nconst INSPECT_ARGS = {\n bucket: BUCKET_ARG,\n app: APP_ARG,\n tenant: TENANT_ARG,\n collection: COLLECTION_ARG,\n config: {\n type: \"string\",\n required: false,\n description:\n \"Path to baerly.config.{js,mjs,json}; pulls declared indexes for key-count probes.\",\n valueHint: \"path\",\n },\n json: JSON_ARG,\n} as const satisfies ArgsDef;\n\nconst countListEntries = async (\n storage: Storage,\n prefix: string,\n): Promise<{ count: number; keys: string[] }> => {\n let count = 0;\n const keys: string[] = [];\n for await (const entry of storage.list(prefix)) {\n count++;\n keys.push(entry.key);\n }\n return { count, keys };\n};\n\ninterface InspectResult {\n currentJsonKey: string;\n schema_version: number;\n /** The stored, compactor-advanced lower-bound hint (`current.json.tail_hint`). */\n tail_hint: number;\n /** The TRUE committed tail, discovered by forward-probe past `tail_hint`. */\n discovered_tail: number;\n log_seq_start: number;\n live_log_tail: number;\n snapshot: string | null;\n snapshot_bytes: number;\n snapshot_rows: number;\n writer_fence: CurrentJson[\"writer_fence\"];\n materialised_rows: number;\n indexes: { name: string; count: number }[];\n status: \"ok\" | \"error\";\n errors: string[];\n}\n\nconst renderText = (r: InspectResult, collection: string): string => {\n const lines: string[] = [];\n lines.push(`baerly inspect ${collection}`);\n lines.push(` current.json: ${r.currentJsonKey}`);\n lines.push(` schema_version: ${r.schema_version}`);\n lines.push(` tail_hint (stored): ${r.tail_hint}`);\n lines.push(` discovered_tail: ${r.discovered_tail}`);\n lines.push(` log_seq_start: ${r.log_seq_start}`);\n lines.push(` live_log_tail: ${r.live_log_tail}`);\n lines.push(` snapshot: ${r.snapshot ?? \"(none)\"}`);\n lines.push(` snapshot_bytes: ${r.snapshot_bytes}`);\n lines.push(` snapshot_rows: ${r.snapshot_rows}`);\n lines.push(\n ` writer_fence: epoch=${r.writer_fence.epoch} owner=${JSON.stringify(r.writer_fence.owner)} claimed_at=${JSON.stringify(r.writer_fence.claimed_at)}`,\n );\n lines.push(` materialised_rows: ${r.materialised_rows}`);\n if (r.indexes.length > 0) {\n const formatted = r.indexes.map((i) => `${i.name} (count=${i.count})`).join(\", \");\n lines.push(` indexes: ${formatted}`);\n } else {\n lines.push(` indexes: (none declared)`);\n }\n lines.push(` status: ${r.status}`);\n if (r.errors.length > 0) {\n for (const e of r.errors) {\n lines.push(` error: ${e}`);\n }\n }\n return lines.join(\"\\n\") + \"\\n\";\n};\n\nconst bundle = defineBaerlySubcommand({\n name: \"inspect\",\n meta: {\n description: \"Read-only summary of one collection's snapshot + log state.\",\n },\n args: INSPECT_ARGS,\n handler: async (args, ctx) => {\n const bucket = await parseBucketUri(args.bucket);\n const { app, tenant } = await ctx.resolveAppTenant({ app: args.app, tenant: args.tenant });\n assertCollectionArg(args.collection, \"baerly inspect\");\n const collectionPrefix = `${bucket.keyPrefix}app/${app}/tenant/${tenant}/manifests/${args.collection}`;\n const currentJsonKey = `${collectionPrefix}/current.json`;\n\n const read = await readCurrentJson(bucket.storage, currentJsonKey);\n if (read === null) {\n throw new BaerlyError(\n \"InvalidConfig\",\n `baerly inspect: current.json not found at ${currentJsonKey}`,\n );\n }\n const cur = read.json;\n const log_seq_start = cur.log_seq_start ?? 0;\n // Discover the TRUE tail by forward-probe — under single-write commit\n // the stored `tail_hint` is only a lower bound (compactor-advanced),\n // so an accurate operator summary must probe past it.\n const tailProbe = await probeTailFrom(\n bucket.storage,\n collectionPrefix,\n Math.max(log_seq_start, cur.tail_hint),\n );\n const discoveredTail = tailProbe.tail;\n\n const errors: string[] = [];\n let materialisedRows = 0;\n try {\n const view = await loadMaterialisedView({\n storage: bucket.storage,\n currentJsonKey,\n collection: args.collection,\n });\n materialisedRows = view?.size ?? 0;\n } catch (error) {\n if (error instanceof BaerlyError) {\n errors.push(`${error.code}: ${error.message}`);\n } else {\n errors.push((error as Error).message);\n }\n }\n\n // Orphan-snapshot detection: list every file under <collectionPrefix>/snapshot/\n // and flag anything that isn't the currently-pointed-at snapshot.\n try {\n const snapshotPrefix = `${collectionPrefix}/snapshot/`;\n const { keys } = await countListEntries(bucket.storage, snapshotPrefix);\n for (const k of keys) {\n if (cur.snapshot !== k) {\n errors.push(`orphan snapshot: ${k}`);\n }\n }\n } catch (error) {\n if (error instanceof BaerlyError) {\n errors.push(`${error.code}: ${error.message}`);\n }\n }\n\n const indexes: { name: string; count: number }[] = [];\n if (typeof args.config === \"string\" && args.config.length > 0) {\n const defs = await loadCollectionIndexes(args.config, args.collection, \"baerly inspect\");\n for (const def of defs) {\n const prefix = `${collectionPrefix}/index/${def.name}/`;\n const { count } = await countListEntries(bucket.storage, prefix);\n indexes.push({ name: def.name, count });\n }\n }\n\n const result: InspectResult = {\n currentJsonKey,\n schema_version: cur.schema_version,\n tail_hint: cur.tail_hint,\n discovered_tail: discoveredTail,\n log_seq_start,\n live_log_tail: discoveredTail - log_seq_start,\n snapshot: cur.snapshot,\n snapshot_bytes: cur.snapshot_bytes,\n snapshot_rows: cur.snapshot_rows,\n writer_fence: cur.writer_fence,\n materialised_rows: materialisedRows,\n indexes,\n status: errors.length === 0 ? \"ok\" : \"error\",\n errors,\n };\n\n if (isJsonMode()) {\n emitSuccess({ command: \"inspect\", ...result });\n } else {\n process.stdout.write(renderText(result, args.collection));\n }\n return 0;\n },\n});\n\n/** citty `defineCommand` block for `baerly inspect`. */\nexport const inspect = bundle.cmd;\n\n/**\n * Programmatic entry used by tests. Bypasses citty's `run` wrapper\n * (which would call `process.exit` and kill vitest) and returns the\n * integer exit code directly.\n */\nexport const runInspect = bundle.run;\n"],"mappings":";;;;;;AA6DA,MAAM,eAAe;CACnB,QAAQ;CACR,KAAK;CACL,QAAQ;CACR,YAAY;CACZ,QAAQ;EACN,MAAM;EACN,UAAU;EACV,aACE;EACF,WAAW;CACb;CACA,MAAM;AACR;AAEA,MAAM,mBAAmB,OACvB,SACA,WAC+C;CAC/C,IAAI,QAAQ;CACZ,MAAM,OAAiB,CAAC;CACxB,WAAW,MAAM,SAAS,QAAQ,KAAK,MAAM,GAAG;EAC9C;EACA,KAAK,KAAK,MAAM,GAAG;CACrB;CACA,OAAO;EAAE;EAAO;CAAK;AACvB;AAqBA,MAAM,cAAc,GAAkB,eAA+B;CACnE,MAAM,QAAkB,CAAC;CACzB,MAAM,KAAK,kBAAkB,YAAY;CACzC,MAAM,KAAK,0BAA0B,EAAE,gBAAgB;CACvD,MAAM,KAAK,0BAA0B,EAAE,gBAAgB;CACvD,MAAM,KAAK,0BAA0B,EAAE,WAAW;CAClD,MAAM,KAAK,0BAA0B,EAAE,iBAAiB;CACxD,MAAM,KAAK,0BAA0B,EAAE,eAAe;CACtD,MAAM,KAAK,0BAA0B,EAAE,eAAe;CACtD,MAAM,KAAK,0BAA0B,EAAE,YAAY,UAAU;CAC7D,MAAM,KAAK,0BAA0B,EAAE,gBAAgB;CAC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Y;GAAE,SAAS;GAAW,GAAG;EAAO,CAAC;OAE7C,QAAQ,OAAO,MAAM,WAAW,QAAQ,KAAK,UAAU,CAAC;EAE1D,OAAO;CACT;AACF,CAAC;;AAGD,MAAa,UAAU,OAAO;AAOJ,OAAO"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as encodeJsonBytes, t as decodeJsonBytes } from "./bytes-BXdamO3L.js";
|
|
2
|
-
import {
|
|
2
|
+
import { l as sha256Hex, m as LOG_FORWARD_PROBE_CAP, u as CURRENT_JSON_CONTENT_TYPE } from "./config-B6nTy8e2.js";
|
|
3
3
|
import { o as BaerlyError } from "./baerly.js";
|
|
4
4
|
//#region ../protocol/src/coordination/current-json.ts
|
|
5
5
|
/**
|
|
@@ -196,15 +196,7 @@ const logObjectKey = (manifestPrefix, seq) => `${manifestPrefix}/log/${seq}.json
|
|
|
196
196
|
* content keys) — snapshot bodies are larger and longer-lived;
|
|
197
197
|
* 256-bit collision resistance matters here.
|
|
198
198
|
*/
|
|
199
|
-
const snapshotHash =
|
|
200
|
-
const view = new Uint8Array(bytes.byteLength);
|
|
201
|
-
view.set(bytes);
|
|
202
|
-
const digest = await crypto.subtle.digest("SHA-256", view);
|
|
203
|
-
const out = new Uint8Array(digest);
|
|
204
|
-
let hex = "";
|
|
205
|
-
for (let i = 0; i < out.length; i++) hex += out[i].toString(16).padStart(2, "0");
|
|
206
|
-
return hex;
|
|
207
|
-
};
|
|
199
|
+
const snapshotHash = (bytes) => sha256Hex(bytes);
|
|
208
200
|
//#endregion
|
|
209
201
|
//#region ../server/src/snapshot.ts
|
|
210
202
|
/**
|
|
@@ -519,4 +511,4 @@ const findLogTail = async (storage, logPrefix, hint, opts) => {
|
|
|
519
511
|
//#endregion
|
|
520
512
|
export { walkLogRange as a, loadSnapshotAsMap as c, logObjectKey as d, casUpdateCurrentJson as f, readCurrentJson as h, readLogEntry as i, snapshotKey as l, logSeqStartOf as m, probeTailFrom as n, walkLogRangeWithBytes as o, createCurrentJson as p, foldLogEntriesOnto as r, encodeSnapshotBody as s, findLogTail as t, snapshotHash as u };
|
|
521
513
|
|
|
522
|
-
//# sourceMappingURL=log-tail-
|
|
514
|
+
//# sourceMappingURL=log-tail-QWU4wlu-.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log-tail-QWU4wlu-.js","names":[],"sources":["../packages/protocol/src/coordination/current-json.ts","../packages/protocol/src/log-key.ts","../packages/protocol/src/snapshot-hash.ts","../packages/server/src/snapshot.ts","../packages/server/src/log-walk.ts","../packages/server/src/log-tail.ts"],"sourcesContent":["/**\n * `current.json` — the per-collection compaction-state control object —\n * and its embedded, currently dormant {@link WriterFence} epoch token.\n *\n * A dedicated `coordination/` namespace (parallel to `storage/`) holds\n * primitives whose contract is \"atomic agreement over a small JSON\n * object\" rather than \"byte I/O.\" Future siblings (compactor\n * manifest, sweeper checkpoint) join here, not at the top\n * level. The module lives inside `@baerly/protocol` because it is pure\n * (no Node imports, no `node:fs`, no `Buffer`, no `node:crypto`,\n * no implicit globals) and must remain Worker-bundleable — every byte\n * of network traffic threads through the {@link Storage} seam.\n *\n * Contract surface:\n * - {@link readCurrentJson} — fetch + parse + validate\n * - {@link createCurrentJson} — create-only (CAS via `If-None-Match:\"*\"`)\n * - {@link casUpdateCurrentJson} — read-modify-write (CAS via `If-Match`)\n * - {@link claimWriter} — bump epoch + stamp server-clock claim time\n *\n * Why the two-round-trip claim protocol: `claimed_at` MUST come from\n * `StoragePutResult.serverDate` (the single shared clock across\n * instances), not the local clock. `serverDate` is only known *after*\n * the CAS PUT lands, so {@link claimWriter} writes the record with\n * `claimed_at: \"\"` first, then overwrites itself with the correct\n * `serverDate.toISOString()` in a second CAS. The epoch bump is\n * already durable from the first put either way; a peer landing\n * between the two writes loses cleanly with `Conflict`.\n *\n * Why CAS errors are wrapped: every in-tree {@link Storage} impl\n * surfaces a lost CAS as `BaerlyError{code:\"Conflict\"}`. Downstream\n * callers — the Writer, the compactor, the sweeper —\n * discriminate by `code` to decide whether to retry.\n * We re-wrap here only to add the `current.json at <key>` location\n * context to the message; the `code` is unchanged.\n */\n\nimport { encodeJsonBytes } from \"../bytes.ts\";\nimport { CURRENT_JSON_CONTENT_TYPE, CURRENT_JSON_SCHEMA_VERSION } from \"../constants.ts\";\nimport { BaerlyError } from \"../errors.ts\";\nimport type { Storage, StoragePutOptions, StoragePutResult } from \"../storage/types.ts\";\n\n/**\n * Per-collection control object. CAS-protected. One per\n * `(tenant, collection)` key — for example\n * `<tenant>/<collection>/current.json`. The compactor swaps snapshot\n * generations by CAS-writing this object; the Writer reads it on every\n * commit to find the snapshot pointer and a non-authoritative\n * tail-probe floor. The numbered log create mints the next integer\n * `seq`; no commit-path code CAS-advances `current.json`.\n *\n * The schema is forward-compatible: adding a new optional field is\n * non-breaking. Renaming or removing a field requires bumping\n * {@link CURRENT_JSON_SCHEMA_VERSION}; readers MUST reject\n * unknown major versions with `BaerlyError{code:\"InvalidResponse\"}`.\n */\nexport interface CurrentJson {\n /**\n * Schema version. Today: `3`. Bump on any breaking change to\n * field semantics; readers must reject unknown major versions\n * with `BaerlyError{code:\"InvalidResponse\"}`.\n */\n schema_version: 3;\n\n /**\n * Pointer to the current snapshot generation. `null` before the\n * first compaction has produced a snapshot — readers fall back\n * to log-only replay. Shape is opaque-to-this-module; the\n * compactor owns its interpretation.\n */\n snapshot: string | null;\n\n /**\n * Non-authoritative monotone lower bound on the committed log tail.\n * The authoritative tail is discovered by forward-probe (log-tail.ts);\n * never trust this as the head. Durable advancement is owned by\n * compaction folds, write-tick tail refreshes, and explicit\n * operator/import paths; ordinary writer commits do not refresh it.\n */\n tail_hint: number;\n\n /**\n * Lowest live log sequence number. Entries with `seq < log_seq_start`\n * have been folded into the snapshot at {@link snapshot} (or, if\n * `snapshot === null`, have been dropped because the collection was\n * truncated). Readers walk `[log_seq_start, tail_hint)`. Always\n * present on disk — fresh `current.json` writes via\n * {@link createCurrentJson} set this to `0`; the compactor advances\n * it on every fold.\n *\n * Invariants the compactor maintains:\n * - `0 <= log_seq_start <= tail_hint`\n * - `log_seq_start` advances monotonically (never decreases)\n * - `log_seq_start > 0` implies `snapshot !== null` (the snapshot\n * covers `[0, log_seq_start)`)\n */\n log_seq_start: number;\n\n /**\n * Embedded write-fence epoch. See {@link WriterFence}.\n */\n writer_fence: WriterFence;\n\n // New in v2:\n\n /** Byte size of the snapshot pointed to by `snapshot`. */\n snapshot_bytes: number;\n\n /**\n * Row count of the snapshot (= compactor `base.size`, free). With\n * `tail_hint - log_seq_start` (trusted tail entries) this gives the\n * fold's entry count for the ENTRY ceiling `E`. Seeded 0.\n */\n snapshot_rows: number;\n\n /**\n * Optional compactor-stamped mean folded-entry byte size. Maintenance\n * derives live-tail bytes as `entry_count × mean_entry_bytes` without\n * an exact stored counter; absent until first fold.\n */\n mean_entry_bytes?: number;\n\n /**\n * Baseline for rate-limiting the graduation defer-warn off SHARED\n * durable state, not per-isolate memory. The warn fires when the\n * observed/probed tail minus `last_warned_seq` reaches\n * MAINTENANCE_WARN_INTERVAL_WRITES, and that firing CASes\n * `last_warned_seq` to the observed/probed tail. Absent → 0.\n */\n last_warned_seq?: number;\n}\n\n/**\n * Fence-token sub-shape embedded in {@link CurrentJson}. The\n * monotonically-bumped `epoch` is the only safety-critical field —\n * `owner` is informational and may be missing in older records;\n * `claimed_at` is the server response date at claim time, NOT the\n * local clock; `lease_until` is reserved for manual rotation and is not\n * consumed by the current kernel. Log entries are not stamped with this\n * epoch; the fence is dormant authority metadata, not a reader replay\n * filter.\n *\n * Borrowed from FoundationDB's `recoveryCount` on cstate, IsleDB's\n * `writer_fence` on `manifest/CURRENT`, and TigerBeetle's VSR view\n * number. In the earlier two-write commit design, every commit checked\n * the epoch before continuing under `current.json` authority. Under\n * single-write commit no production path reads or writes the fence.\n */\nexport interface WriterFence {\n /**\n * Monotonic unsigned integer. Bumped only by an explicit\n * {@link claimWriter} call — do NOT bump on every cold start, do\n * NOT bump on every commit. Under single-write commit this is retained\n * as an explicit admin/testing primitive only; no production commit\n * path claims or verifies the fence.\n */\n epoch: number;\n\n /**\n * Owner identifier — debug only, NOT consulted for safety.\n * Suggested shape: `<worker_id>@<deploy_id>`. May be the empty\n * string when claim provenance is unknown (e.g. initial\n * creation). Safety derives from `epoch`, not from `owner`.\n */\n owner: string;\n\n /**\n * ISO-8601 timestamp from the `StoragePutResult.serverDate` on\n * the successful CAS PUT. **Never use `new Date()` or\n * `Date.now()` to populate this field** — under multi-instance\n * deployment the local clock may disagree with peers; the\n * server's clock is the only one all instances share. Format\n * via `serverDate.toISOString()`. The empty string `\"\"` means\n * \"claim time unknown\" — readers MUST treat it as such rather\n * than parsing it.\n */\n claimed_at: string;\n\n /**\n * Optional explicit lease horizon, also ISO-8601. Reserved for\n * future manual rotation workflows; current code only writes\n * the field through if a caller supplies it and does not read\n * it.\n */\n lease_until?: string;\n}\n\n/**\n * Return shape from {@link readCurrentJson} et al.: the parsed JSON\n * plus the ETag needed for a follow-up CAS write.\n */\nexport interface CurrentJsonRead {\n readonly json: CurrentJson;\n readonly etag: string;\n}\n\n/**\n * Read + parse `current.json` at `key`. Returns `null` on not-found.\n *\n * @throws BaerlyError{code:\"InvalidResponse\"} — body is not valid\n * JSON, or `schema_version` is unknown, or the shape fails\n * the runtime guard.\n */\nexport async function readCurrentJson(\n storage: Storage,\n key: string,\n opts?: { signal?: AbortSignal },\n): Promise<CurrentJsonRead | null> {\n const got = await storage.get(key, opts);\n if (got === null) {\n return null;\n }\n const text = new TextDecoder().decode(got.body);\n let parsed: unknown;\n try {\n parsed = JSON.parse(text);\n } catch (error) {\n throw new BaerlyError(\n \"InvalidResponse\",\n `current.json at ${key}: body is not valid JSON`,\n error,\n );\n }\n return { json: assertCurrentJson(parsed, key), etag: got.etag };\n}\n\n/**\n * Create `current.json` if-and-only-if it does not exist (S3\n * `If-None-Match: \"*\"`). Use this once per collection at provisioning\n * time; subsequent updates go through {@link casUpdateCurrentJson}.\n *\n * @throws BaerlyError{code:\"Conflict\"} — the key already exists.\n * Caller decides whether to read + reconcile or surface.\n * @throws BaerlyError{code:\"InvalidResponse\"} — `initial` fails the\n * runtime shape guard.\n */\nexport async function createCurrentJson(\n storage: Storage,\n key: string,\n initial: CurrentJson,\n opts?: { signal?: AbortSignal },\n): Promise<CurrentJsonRead> {\n // Catch shape bugs in callers before they hit storage. Cheap.\n assertCurrentJson(initial, key);\n const body = encodeJson(initial);\n const putOpts: StoragePutOptions = {\n ifNoneMatch: \"*\",\n contentType: CURRENT_JSON_CONTENT_TYPE,\n ...(opts?.signal !== undefined && { signal: opts.signal }),\n };\n let result: StoragePutResult;\n try {\n result = await storage.put(key, body, putOpts);\n } catch (error) {\n throw translateCasError(error, key);\n }\n return { json: initial, etag: result.etag };\n}\n\n/**\n * Read-modify-write `current.json` under CAS. The `mutator` receives\n * a deep clone of the current parsed JSON (mutate freely) and returns\n * the new state. The new state is written with `If-Match:\n * <currentEtag>`; on conflict, throws.\n *\n * `mutator` MUST be synchronous and deterministic — it may be called\n * multiple times if the caller wraps this in a retry loop, so it\n * must not have side effects.\n *\n * @throws BaerlyError{code:\"Conflict\"} — another writer landed a write\n * between this function's read and write. Caller decides\n * whether to retry (read + remutate + rewrite).\n * @throws BaerlyError{code:\"InvalidResponse\"} — `key` does not exist\n * (use {@link createCurrentJson} instead) or body doesn't\n * parse / fails the shape guard.\n */\nexport async function casUpdateCurrentJson(\n storage: Storage,\n key: string,\n mutator: (current: CurrentJson) => CurrentJson,\n opts?: { signal?: AbortSignal },\n): Promise<CurrentJsonRead> {\n const existing = await readCurrentJson(storage, key, opts);\n if (existing === null) {\n throw new BaerlyError(\n \"InvalidResponse\",\n `current.json at ${key} does not exist; use createCurrentJson first`,\n );\n }\n // Defensive deep clone so a mutator that mutates its argument can't\n // corrupt the original record on the caller's retry path.\n // `structuredClone` is a global on Node ≥17 and Workers; the package\n // targets Node ≥24 so it is safe.\n const next = mutator(structuredClone(existing.json));\n assertCurrentJson(next, key);\n const body = encodeJson(next);\n const putOpts: StoragePutOptions = {\n ifMatch: existing.etag,\n contentType: CURRENT_JSON_CONTENT_TYPE,\n ...(opts?.signal !== undefined && { signal: opts.signal }),\n };\n let result: StoragePutResult;\n try {\n result = await storage.put(key, body, putOpts);\n } catch (error) {\n throw translateCasError(error, key);\n }\n return { json: next, etag: result.etag };\n}\n\n/**\n * Claim ownership of the dormant write fence by bumping `epoch` and\n * stamping `claimed_at` from `StoragePutResult.serverDate`. Under\n * single-write commit there is no production commit-path call site;\n * this is retained for explicit admin/testing workflows and future\n * rotation designs.\n *\n * `owner` is informational — see {@link WriterFence.owner}. Safety\n * derives from the monotonic `epoch`, not from `owner`.\n *\n * Implementation note (two round-trips): because\n * `StoragePutResult.serverDate` is only known *after* the CAS PUT\n * lands, this function writes the record with `claimed_at: \"\"`\n * first, then overwrites itself with the correct\n * `serverDate.toISOString()` in a second CAS. A peer landing between\n * the two writes loses cleanly with `Conflict` — the epoch bump is\n * already durable from the first put either way. If `serverDate` is\n * `undefined` on the first PUT (impl doesn't surface it), the second\n * write is skipped and `claimed_at` remains the empty string;\n * readers MUST treat the empty string as \"unknown claim time\"\n * rather than parsing it.\n *\n * @see {@link ../../../../docs/spec/writer-fence-adversarial-model.md} —\n * the full failure envelope (absent / lying / non-monotonic Date,\n * peer-between-PUTs, bounded clock skew).\n * @see {@link ../../../../docs/spec/writer-fence-adversarial-model.md} —\n * the \"Differentiation from mps3\" subsection that frames the §103\n * non-obviousness story.\n * @see {@link ../../../../docs/spec/prior-art.md} —\n * IDS-shaped prior-art differentiation against mps3, SlateDB,\n * Iceberg, Delta, and the broader S3-leader-election literature.\n *\n * @throws BaerlyError{code:\"Conflict\"} — another writer claimed the\n * fence between this call's read and write. Caller decides\n * whether to retry.\n * @throws BaerlyError{code:\"InvalidResponse\"} — `key` does not exist.\n */\nexport async function claimWriter(\n storage: Storage,\n key: string,\n owner: string,\n opts?: { signal?: AbortSignal },\n): Promise<CurrentJsonRead> {\n const existing = await readCurrentJson(storage, key, opts);\n if (existing === null) {\n throw new BaerlyError(\n \"InvalidResponse\",\n `current.json at ${key} does not exist; use createCurrentJson first`,\n );\n }\n const provisional: CurrentJson = {\n ...existing.json,\n writer_fence: {\n epoch: existing.json.writer_fence.epoch + 1,\n owner,\n // Will be overwritten with serverDate.toISOString() once the put\n // returns, when the impl surfaces it. Stays `\"\"` (\"unknown\") if\n // the impl doesn't.\n claimed_at: \"\",\n // Stryker disable next-line ConditionalExpression: `→true` spreads `{lease_until: undefined}` which JSON.stringify omits, so the stored bytes are identical to the normal `→false` path (no key emitted). Genuine equivalent mutant.\n ...(existing.json.writer_fence.lease_until !== undefined && {\n lease_until: existing.json.writer_fence.lease_until,\n }),\n },\n };\n const body = encodeJson(provisional);\n const putOpts: StoragePutOptions = {\n ifMatch: existing.etag,\n contentType: CURRENT_JSON_CONTENT_TYPE,\n ...(opts?.signal !== undefined && { signal: opts.signal }),\n };\n let result: StoragePutResult;\n try {\n result = await storage.put(key, body, putOpts);\n } catch (error) {\n throw translateCasError(error, key);\n }\n // No server clock surfaced — leave `claimed_at` empty. The epoch\n // bump is durable; safety is unaffected.\n if (result.serverDate === undefined) {\n return { json: provisional, etag: result.etag };\n }\n // Stamp the server clock through a second CAS-on-our-own-etag. A\n // peer landing between the two writes loses cleanly with Conflict\n // (the fence is safe — next claim will bump past both).\n const stamped: CurrentJson = {\n ...provisional,\n writer_fence: {\n ...provisional.writer_fence,\n claimed_at: result.serverDate.toISOString(),\n },\n };\n const stampedBody = encodeJson(stamped);\n const stampPutOpts: StoragePutOptions = {\n ifMatch: result.etag,\n contentType: CURRENT_JSON_CONTENT_TYPE,\n ...(opts?.signal !== undefined && { signal: opts.signal }),\n };\n let stampResult: StoragePutResult;\n try {\n stampResult = await storage.put(key, stampedBody, stampPutOpts);\n } catch (error) {\n throw translateCasError(error, key);\n }\n return { json: stamped, etag: stampResult.etag };\n}\n\n/**\n * Read `current.json.log_seq_start` — the low-water mark of the live\n * log range `[log_seq_start, tail_hint)`. The field is always present\n * on disk (every `createCurrentJson` write seeds it; the compactor\n * advances it on every fold); this helper exists to document intent\n * at call sites that walk the log range or assert the snapshot\n * invariants.\n */\nexport const logSeqStartOf = (c: CurrentJson): number => c.log_seq_start;\n\n// ---------------------------------------------------------------------\n// Internals\n// ---------------------------------------------------------------------\n\nconst encodeJson = (json: CurrentJson): Uint8Array => encodeJsonBytes(json);\n\n/**\n * Runtime guard for `parsed` to be a {@link CurrentJson}. Throws\n * `BaerlyError{code:\"InvalidResponse\"}` rather than coercing. Tolerant\n * reader: unknown keys ignored, new required fields bump\n * `schema_version` (move (b), ADR-003).\n */\nconst assertCurrentJson = (parsed: unknown, key: string): CurrentJson => {\n if (parsed === null || typeof parsed !== \"object\") {\n throw new BaerlyError(\n \"InvalidResponse\",\n `current.json at ${key}: parsed body is not an object`,\n );\n }\n const r = parsed as Record<string, unknown>;\n if (r[\"schema_version\"] === 1 || r[\"schema_version\"] === 2) {\n throw new BaerlyError(\n \"InvalidResponse\",\n `current.json at ${key} uses schema v${String(r[\"schema_version\"])} from a pre-0.3.0 internal build; this build requires schema v${CURRENT_JSON_SCHEMA_VERSION}. Dump/restore with the old build, or re-provision scratch/local buckets.`,\n );\n }\n if (r[\"schema_version\"] !== CURRENT_JSON_SCHEMA_VERSION) {\n throw new BaerlyError(\n \"InvalidResponse\",\n `current.json at ${key}: unsupported schema_version ${String(r[\"schema_version\"])}; this build requires ${CURRENT_JSON_SCHEMA_VERSION}. This almost always means stale scratch data from a different build — wipe the local dev bucket (e.g. \\`rm -rf .baerly-data\\`) or recreate the R2/S3 bucket, then retry.`,\n );\n }\n if (!(typeof r[\"snapshot\"] === \"string\" || r[\"snapshot\"] === null)) {\n throw new BaerlyError(\n \"InvalidResponse\",\n `current.json at ${key}: snapshot must be string|null`,\n );\n }\n // Stryker disable next-line ConditionalExpression,StringLiteral: three equivalent mutants on this line — (1) `typeof r[\"tail_hint\"] !== \"number\"` → false is subsumed by !Number.isInteger (which rejects all non-numbers); (2) `r[\"tail_hint\"] < 0` → false is subsumed by the downstream `log_seq_start > tail_hint` cross-check (log_seq_start ≥ 0, so log_seq_start > negative_tail_hint always fires); (3) StringLiteral \"tail_hint\" → \"\" turns r[\"\"] → undefined → !Number.isInteger(undefined) still true → still throws.\n if (\n typeof r[\"tail_hint\"] !== \"number\" ||\n !Number.isInteger(r[\"tail_hint\"]) ||\n r[\"tail_hint\"] < 0\n ) {\n throw new BaerlyError(\n \"InvalidResponse\",\n `current.json at ${key}: tail_hint must be a non-negative integer`,\n );\n }\n if (\n // Stryker disable next-line ConditionalExpression: `typeof r[\"log_seq_start\"] !== \"number\"` → false is equivalent — !Number.isInteger rejects all non-numbers anyway, making the typeof check fully subsumed.\n typeof r[\"log_seq_start\"] !== \"number\" ||\n !Number.isInteger(r[\"log_seq_start\"]) ||\n r[\"log_seq_start\"] < 0\n ) {\n throw new BaerlyError(\n \"InvalidResponse\",\n `current.json at ${key}: log_seq_start must be a non-negative integer`,\n );\n }\n if (r[\"log_seq_start\"] > r[\"tail_hint\"]) {\n throw new BaerlyError(\n \"InvalidResponse\",\n `current.json at ${key}: log_seq_start ${String(r[\"log_seq_start\"])} > tail_hint ${String(r[\"tail_hint\"])}`,\n );\n }\n const fence = r[\"writer_fence\"];\n if (fence === null || typeof fence !== \"object\") {\n throw new BaerlyError(\"InvalidResponse\", `current.json at ${key}: writer_fence missing`);\n }\n const f = fence as Record<string, unknown>;\n // Stryker disable next-line ConditionalExpression: `typeof f[\"epoch\"] !== \"number\"` → false is equivalent — !Number.isInteger rejects all non-numbers, making the typeof guard fully subsumed.\n if (typeof f[\"epoch\"] !== \"number\" || !Number.isInteger(f[\"epoch\"]) || f[\"epoch\"] < 0) {\n throw new BaerlyError(\n \"InvalidResponse\",\n `current.json at ${key}: writer_fence.epoch must be a non-negative integer`,\n );\n }\n if (typeof f[\"owner\"] !== \"string\") {\n throw new BaerlyError(\n \"InvalidResponse\",\n `current.json at ${key}: writer_fence.owner must be a string`,\n );\n }\n if (typeof f[\"claimed_at\"] !== \"string\") {\n throw new BaerlyError(\n \"InvalidResponse\",\n `current.json at ${key}: writer_fence.claimed_at must be a string`,\n );\n }\n if (f[\"lease_until\"] !== undefined && typeof f[\"lease_until\"] !== \"string\") {\n throw new BaerlyError(\n \"InvalidResponse\",\n `current.json at ${key}: writer_fence.lease_until must be string if present`,\n );\n }\n if (\n // Stryker disable next-line ConditionalExpression: `typeof r[\"snapshot_bytes\"] !== \"number\"` → false is equivalent — !Number.isInteger rejects all non-numbers, making the typeof check fully subsumed.\n typeof r[\"snapshot_bytes\"] !== \"number\" ||\n !Number.isInteger(r[\"snapshot_bytes\"]) ||\n r[\"snapshot_bytes\"] < 0\n ) {\n throw new BaerlyError(\n \"InvalidResponse\",\n `current.json at ${key}: snapshot_bytes must be a non-negative integer`,\n );\n }\n if (\n // Stryker disable next-line ConditionalExpression: `typeof r[\"snapshot_rows\"] !== \"number\"` → false is equivalent — !Number.isInteger rejects all non-numbers, making the typeof check fully subsumed.\n typeof r[\"snapshot_rows\"] !== \"number\" ||\n !Number.isInteger(r[\"snapshot_rows\"]) ||\n r[\"snapshot_rows\"] < 0\n ) {\n throw new BaerlyError(\n \"InvalidResponse\",\n `current.json at ${key}: snapshot_rows must be a non-negative integer`,\n );\n }\n if (\n r[\"last_warned_seq\"] !== undefined &&\n // Stryker disable next-line ConditionalExpression: `typeof r[\"last_warned_seq\"] !== \"number\"` → false is equivalent — !Number.isInteger rejects all non-numbers, making the typeof check fully subsumed.\n (typeof r[\"last_warned_seq\"] !== \"number\" ||\n !Number.isInteger(r[\"last_warned_seq\"]) ||\n r[\"last_warned_seq\"] < 0)\n ) {\n throw new BaerlyError(\n \"InvalidResponse\",\n `current.json at ${key}: last_warned_seq must be a non-negative integer if present`,\n );\n }\n if (\n r[\"mean_entry_bytes\"] !== undefined &&\n // Stryker disable next-line ConditionalExpression: typeof → false is subsumed by !Number.isInteger.\n (typeof r[\"mean_entry_bytes\"] !== \"number\" ||\n !Number.isInteger(r[\"mean_entry_bytes\"]) ||\n r[\"mean_entry_bytes\"] < 0)\n ) {\n throw new BaerlyError(\n \"InvalidResponse\",\n `current.json at ${key}: mean_entry_bytes must be a non-negative integer if present`,\n );\n }\n return parsed as CurrentJson;\n};\n\n/**\n * Wrap a storage-level error with `current.json at <key>` location\n * context. `Conflict` (the storage layer's CAS-lost signal) is\n * re-thrown with an annotated message; other `BaerlyError`s pass\n * through; non-`BaerlyError` falls through as `InvalidResponse` (in\n * practice unreachable — every in-tree `Storage` impl wraps).\n */\nconst translateCasError = (e: unknown, key: string): BaerlyError => {\n if (e instanceof BaerlyError && e.code === \"Conflict\") {\n return new BaerlyError(\"Conflict\", `current.json CAS lost at ${key}: ${e.message}`, e);\n }\n if (e instanceof BaerlyError) {\n return e;\n }\n return new BaerlyError(\"InvalidResponse\", `current.json write at ${key} failed: ${String(e)}`, e);\n};\n","/**\n * Log-object key construction — a zero-import leaf module.\n *\n * Kept separate from `log.ts` on purpose: `log.ts` carries the heavier\n * `lsn` parsing runtime (`lsnParts`, the LSN regex, `str2uintDesc`).\n * Routing `gc` / `writer` / `log-walk` through a key helper that lived in\n * `log.ts` dragged that whole module into the `maintenance.js` bundle\n * closure (+3.8 KB raw). This module imports nothing, so consumers that\n * only need the key shape pull only the key shape.\n */\n\n/** S3 path segment for log entries, under the manifest prefix. */\nexport const LOG_KEY_PREFIX = \"log\";\n\n/**\n * The single constructor for a log-object key:\n * `<manifestPrefix>/log/<seq>.json`. `manifestPrefix` is the\n * `<…>/manifests/<collection>` segment — this helper adds `/log/`.\n * Route all callers here so the key shape lives in one place.\n */\nexport const logObjectKey = (manifestPrefix: string, seq: number): string =>\n `${manifestPrefix}/${LOG_KEY_PREFIX}/${seq}.json`;\n","import { sha256Hex } from \"./sha256.ts\";\n\n/**\n * SHA-256 of `bytes` as a 64-char lowercase hex string. Used to seal\n * snapshot filenames so a crashed mid-PUT can't produce a body that\n * readers consume as truth: the filename embeds the hash; readers\n * recompute on load and reject any mismatch as \"file missing.\"\n *\n * Distinct from {@link versionFromContent} (truncated to 32 chars for\n * content keys) — snapshot bodies are larger and longer-lived;\n * 256-bit collision resistance matters here.\n */\nexport const snapshotHash = (bytes: Uint8Array): Promise<string> => sha256Hex(bytes);\n","/**\n * Snapshot file shape + parse. Lifted out of `./compactor.ts` so that\n * the kernel barrel (`packages/server/src/index.ts`) — which re-exports\n * these four symbols — does not transitively pull `withObservability`\n * via `compact()`. `./compactor.ts` imports its own snapshot primitives\n * back from this module; the public API surface is unchanged.\n *\n * @see ../../../docs/spec/sync-protocol.md\n */\n\nimport {\n BaerlyError,\n decodeJsonBytes,\n type DocumentData,\n encodeJsonBytes,\n snapshotHash,\n SNAPSHOT_SCHEMA_VERSION,\n type Storage,\n} from \"@baerly/protocol\";\n\n/**\n * Single-level snapshot at L9; the level prefix is forward-compatible\n * with future L0..L9 rolling merges without a wire change.\n */\nconst SNAPSHOT_LEVEL = 9 as const;\n\n/**\n * `minSeq` and `maxSeq` are padded to {@link SEQ_DIGITS} digits so\n * `list(prefix)` returns snapshots in seq order without needing to\n * parse the filename. 12 digits caps at ~10^12 entries per collection;\n * a real bucket hits S3's per-prefix QPS ceiling long before that.\n */\nconst SEQ_DIGITS = 12 as const;\n\nconst MAX_SEQ = 10 ** SEQ_DIGITS - 1;\n\n/**\n * Build the on-bucket key for a snapshot file. `sha256` must be the\n * lowercase hex digest of the canonical body\n * ({@link encodeSnapshotBody}); the filename embeds it so a crashed\n * mid-PUT body that doesn't match its own filename hash is rejected\n * by readers as \"missing.\"\n *\n * @throws BaerlyError code=\"InvalidConfig\" — `minSeq`/`maxSeq` are\n * out of range or `sha256` is not 64 hex chars.\n */\nexport const snapshotKey = (\n collectionPrefix: string,\n minSeq: number,\n maxSeq: number,\n sha256: string,\n): string => {\n if (minSeq < 0 || maxSeq < 0 || minSeq > maxSeq || maxSeq > MAX_SEQ) {\n throw new BaerlyError(\"InvalidConfig\", `snapshotKey: invalid range [${minSeq}, ${maxSeq})`);\n }\n if (!/^[0-9a-f]{64}$/.test(sha256)) {\n throw new BaerlyError(\"InvalidConfig\", \"snapshotKey: sha256 must be 64 hex chars\");\n }\n const pad = (n: number): string => n.toString().padStart(SEQ_DIGITS, \"0\");\n return `${collectionPrefix}/snapshot/L${SNAPSHOT_LEVEL}/${pad(minSeq)}-${pad(maxSeq)}-${sha256}.json`;\n};\n\n/**\n * On-bucket body of a snapshot file. The reader recomputes the SHA-256\n * over the canonical serialisation ({@link encodeSnapshotBody}) and\n * rejects any mismatch with the filename hash.\n *\n * `docs` is sorted by `_id` for deterministic byte output — two\n * compactions over the same fold produce byte-identical snapshots,\n * which means same filename, which means an idempotent re-run never\n * leaves an orphan.\n */\nexport interface SnapshotBody {\n readonly schema_version: typeof SNAPSHOT_SCHEMA_VERSION;\n readonly min_seq: number;\n readonly max_seq: number;\n readonly collection: string;\n readonly docs: ReadonlyArray<{\n readonly _id: string;\n readonly body: DocumentData;\n }>;\n}\n\n/**\n * Canonical byte encoding of a {@link SnapshotBody}. Only the\n * compactor produces snapshots, and only this function does the\n * serialisation — so the byte output is deterministic for a given\n * `SnapshotBody` (identical input ⇒ identical bytes ⇒ identical\n * filename hash).\n */\nexport const encodeSnapshotBody = (s: SnapshotBody): Uint8Array => encodeJsonBytes(s);\n\n/**\n * Load a snapshot file as a `Map<_id, DocumentData>`. Verifies the\n * body hash against the filename, checks the schema version, and\n * cross-checks `body.collection` against the caller's expectation.\n *\n * @example\n * ```ts\n * import { loadSnapshotAsMap } from \"@gusto/baerly-storage\";\n *\n * const map =\n * srcCurrent.snapshot === null\n * ? new Map<string, DocumentData>()\n * : await loadSnapshotAsMap(src.storage, srcCurrent.snapshot, \"tickets\");\n * ```\n *\n * @throws BaerlyError code=\"Internal\" — pointer resolves to no body,\n * or the body's SHA-256 doesn't match the hash embedded in the\n * filename. (Protocol invariant violation; a corrupted snapshot\n * the reader cannot continue past.)\n * @throws BaerlyError code=\"InvalidResponse\" — body isn't valid JSON,\n * isn't an object, has an unsupported `schema_version`, or carries a\n * `collection` that doesn't match `expectedCollection`.\n */\nexport const loadSnapshotAsMap = async (\n storage: Storage,\n key: string,\n expectedCollection: string,\n signal?: AbortSignal,\n): Promise<Map<string, DocumentData>> => {\n const got = await storage.get(key, signal !== undefined ? { signal } : undefined);\n if (got === null) {\n throw new BaerlyError(\n \"Internal\",\n `compact: snapshot pointer ${key} resolves to no body; protocol violation`,\n );\n }\n // Verify hash: the filename shape is\n // `<...>/snapshot/L<n>/<min>-<max>-<sha256>.json`. The sha256 is\n // the segment after the LAST `-` (the two seq fields don't contain\n // dashes), with `.json` stripped.\n const filename = key.slice(key.lastIndexOf(\"/\") + 1).replace(/\\.json$/, \"\");\n const lastDash = filename.lastIndexOf(\"-\");\n const expectedHash = filename.slice(lastDash + 1);\n const actualHash = await snapshotHash(got.body);\n if (actualHash !== expectedHash) {\n throw new BaerlyError(\n \"Internal\",\n `compact: snapshot ${key} body hash mismatch (got ${actualHash}); protocol violation`,\n );\n }\n let parsed: unknown;\n try {\n parsed = decodeJsonBytes(got.body);\n } catch (error) {\n throw new BaerlyError(\n \"InvalidResponse\",\n `compact: snapshot ${key} body is not valid JSON`,\n error,\n );\n }\n if (parsed === null || typeof parsed !== \"object\") {\n throw new BaerlyError(\"InvalidResponse\", `compact: snapshot ${key} body is not an object`);\n }\n const body = parsed as SnapshotBody;\n if (body.schema_version !== SNAPSHOT_SCHEMA_VERSION) {\n throw new BaerlyError(\n \"InvalidResponse\",\n `compact: snapshot ${key} has unsupported schema_version ${String(body.schema_version)}`,\n );\n }\n if (body.collection !== expectedCollection) {\n throw new BaerlyError(\n \"InvalidResponse\",\n `compact: snapshot ${key} carries collection ${body.collection}, expected ${expectedCollection}`,\n );\n }\n if (!Array.isArray(body.docs)) {\n throw new BaerlyError(\"InvalidResponse\", `compact: snapshot ${key} body.docs is not an array`);\n }\n const out = new Map<string, DocumentData>();\n for (const row of body.docs) {\n out.set(row._id, row.body);\n }\n return out;\n};\n","/**\n * Shared log-walk primitives consumed by the read path (`query.ts`),\n * the compactor (`compactor.ts`), and the optional integrity walk in\n * `Writer.#singleAttemptCommit` (`writer.ts`).\n *\n * Two operations: read one log entry, or walk a contiguous range of\n * log entries with bounded parallelism. Each kernel call site\n * previously inlined the same range-build + unbounded `Promise.all`\n * pattern; on a free-tier collection where the compactor lags the\n * tail to 50-100 entries, that fans out 50-100 concurrent GETs per\n * call — and a contended writer multiplies that by the CAS retry\n * budget. `walkLogRange` caps concurrency at\n * {@link MAX_PARALLEL_LOG_READS} so a single call costs at most that\n * many simultaneous GETs against the storage backend.\n *\n * Order invariant: results are returned in seq order regardless of\n * resolution order. The read-side fold is order-sensitive (`U` then\n * `D` on the same doc must apply in that order); callers may iterate\n * the returned array as-is.\n *\n * Signal invariant: when the caller's `AbortSignal` fires, no further\n * chunks dispatch. In-flight reads see the signal via the underlying\n * `Storage.get` call.\n */\n\nimport {\n type DocumentData,\n type LogEntry,\n type Storage,\n BaerlyError,\n decodeJsonBytes,\n logObjectKey,\n MAX_PARALLEL_LOG_READS,\n} from \"@baerly/protocol\";\n\n/**\n * Fetch a single log entry. Centralises the \"missing entry inside the\n * visible log range is a protocol-invariant violation\" rule used by\n * every caller.\n *\n * @throws BaerlyError code=\"Internal\" when the key resolves to no\n * body — a hole inside `[log_seq_start, tail_hint)` is a corruption\n * the kernel can't continue past.\n * @throws BaerlyError code=\"InvalidResponse\" when the body isn't\n * valid JSON.\n */\nexport const readLogEntry = async (\n storage: Storage,\n key: string,\n opts?: { signal?: AbortSignal },\n): Promise<LogEntry> => {\n const got = await readLogEntryWithBytes(storage, key, opts);\n return got.entry;\n};\n\n/**\n * Like {@link readLogEntry}, but also surfaces `bytes` — the\n * byteLength of the STORED log-object body exactly as it was GET back\n * from storage (`got.body.byteLength`).\n *\n * The compactor uses this to sum the byte cost of the folded slice.\n * The stored body byteLength IS what the writer PUT for each entry,\n * so summing `got.body.byteLength` over the folded range yields the\n * exact cost — no re-encode, no round-trip assumption (a re-encode\n * of the parsed `LogEntry` could drift if key-order/whitespace ever\n * diverged from what was PUT).\n *\n * Same error semantics as {@link readLogEntry}.\n */\nconst readLogEntryWithBytes = async (\n storage: Storage,\n key: string,\n opts?: { signal?: AbortSignal },\n): Promise<{ entry: LogEntry; bytes: number }> => {\n const got = await storage.get(\n key,\n opts?.signal !== undefined ? { signal: opts.signal } : undefined,\n );\n if (got === null) {\n throw new BaerlyError(\n \"Internal\",\n `log-walk: missing log entry at ${key}; protocol invariant violation`,\n );\n }\n try {\n return { entry: decodeJsonBytes<LogEntry>(got.body), bytes: got.body.byteLength };\n } catch (error) {\n throw new BaerlyError(\"InvalidResponse\", `log-walk: malformed log entry at ${key}`, error);\n }\n};\n\n/**\n * Walk `[fromSeq, toSeqExclusive)` of `${logPrefix}/log/<seq>.json`\n * in chunks of {@link MAX_PARALLEL_LOG_READS} concurrent GETs.\n * Returns the materialised entries in seq order.\n *\n * Empty range (`fromSeq >= toSeqExclusive`) returns `[]` and issues\n * zero GETs.\n *\n * Same error semantics as {@link readLogEntry}: a missing entry\n * throws `Internal`, a malformed body throws `InvalidResponse`.\n */\nexport const walkLogRange = async (\n storage: Storage,\n logPrefix: string,\n fromSeq: number,\n toSeqExclusive: number,\n opts?: { signal?: AbortSignal },\n): Promise<LogEntry[]> => {\n const withBytes = await walkLogRangeWithBytes(storage, logPrefix, fromSeq, toSeqExclusive, opts);\n return withBytes.map((r) => r.entry);\n};\n\n/**\n * Like {@link walkLogRange}, but each element also carries `bytes` —\n * the STORED log-object body byteLength (see {@link readLogEntryWithBytes}).\n * Same seq-order, empty-range, error, and bounded-parallelism\n * ({@link MAX_PARALLEL_LOG_READS}) guarantees as {@link walkLogRange};\n * this is the bytes-aware core `walkLogRange` is implemented on top of.\n *\n * The compactor consumes this so it gets BOTH the parsed entries (for\n * the fold) AND the exact byte sum (for `mean_entry_bytes` stamping) from a\n * single walk.\n */\nexport const walkLogRangeWithBytes = async (\n storage: Storage,\n logPrefix: string,\n fromSeq: number,\n toSeqExclusive: number,\n opts?: { signal?: AbortSignal },\n): Promise<Array<{ entry: LogEntry; bytes: number }>> => {\n if (fromSeq >= toSeqExclusive) {\n return [];\n }\n const total = toSeqExclusive - fromSeq;\n const out: Array<{ entry: LogEntry; bytes: number }> = Array.from({ length: total });\n for (let chunkStart = 0; chunkStart < total; chunkStart += MAX_PARALLEL_LOG_READS) {\n opts?.signal?.throwIfAborted();\n const chunkEnd = Math.min(chunkStart + MAX_PARALLEL_LOG_READS, total);\n const promises: Array<Promise<{ entry: LogEntry; bytes: number }>> = [];\n for (let i = chunkStart; i < chunkEnd; i++) {\n const seq = fromSeq + i;\n promises.push(readLogEntryWithBytes(storage, logObjectKey(logPrefix, seq), opts));\n }\n const results = await Promise.all(promises);\n for (let i = 0; i < results.length; i++) {\n out[chunkStart + i] = results[i]!;\n }\n }\n return out;\n};\n\n/**\n * Fold a sequence of `LogEntry` records onto a doc-id-keyed map,\n * applying the protocol's per-doc-replace semantics:\n *\n * - `I` / `U`: when `entry.after !== undefined`, set\n * `map.set(entry.doc_id, entry.after)`. Entries with `after ===\n * undefined` (the partial-merge writer's future patch-only shape)\n * are ignored — today's writer always emits `after`, so this is a\n * forward-compat guard, not a live branch.\n * - `D`: tombstone — `map.delete(entry.doc_id)`.\n *\n * Entries whose `collection` does not match `opts.collection`, or\n * whose `doc_id` is `undefined`, are skipped. When\n * `opts.docIdFilter` is provided, only entries whose `doc_id` is\n * present in the filter set are folded — used by the index-walk\n * read path to scope the fold to the docs the planner already\n * resolved.\n *\n * This is the canonical fold used by the read path\n * (`query.ts`) and the index reconciler (`rebuild-index.ts`).\n * Centralising it keeps the\n * \"straight `set` on I/U; tombstone on D\" protocol invariant in one place.\n *\n * @see ../../../docs/spec/sync-protocol.md\n */\nexport const foldLogEntriesOnto = <T extends DocumentData>(\n map: Map<string, T>,\n entries: Iterable<LogEntry>,\n opts: {\n readonly collection: string;\n readonly docIdFilter?: ReadonlySet<string>;\n },\n): void => {\n const { collection, docIdFilter } = opts;\n for (const entry of entries) {\n if (entry.collection !== collection) {\n continue;\n }\n if (entry.doc_id === undefined) {\n continue;\n }\n if (docIdFilter !== undefined && !docIdFilter.has(entry.doc_id)) {\n continue;\n }\n switch (entry.op) {\n case \"I\":\n case \"U\": {\n if (entry.after === undefined) {\n continue;\n }\n map.set(entry.doc_id, entry.after as T);\n break;\n }\n case \"D\": {\n map.delete(entry.doc_id);\n break;\n }\n }\n }\n};\n","/**\n * Tolerant forward-probe for the true committed log tail. The strict\n * `[log_seq_start, hint)` range is dense (a hole is corruption, owned\n * by `walkLogRange`); this owns only the tolerant `[hint, ∞)` probe,\n * where `hint` is a lower bound — the real tail may sit at or past it.\n */\n\nimport {\n type LogEntry,\n type Storage,\n BaerlyError,\n decodeJsonBytes,\n LOG_FORWARD_PROBE_CAP,\n logObjectKey,\n} from \"@baerly/protocol\";\n\n/**\n * Discover the true committed tail and fold entries in `[hint, tail)`.\n * `tail` is the first empty seq (>= hint); `entries` are the\n * LogEntries in `[hint, tail)` in seq order. `cap` bounds the walk;\n * exhausting it THROWS `Internal` (never silently truncates) — see\n * the cap-exhaustion comment below.\n */\nexport const probeTailFrom = async (\n storage: Storage,\n logPrefix: string,\n hint: number,\n opts?: { signal?: AbortSignal; cap?: number },\n): Promise<{ tail: number; entries: LogEntry[] }> => {\n const cap = opts?.cap ?? LOG_FORWARD_PROBE_CAP;\n const getOpts = opts?.signal !== undefined ? { signal: opts.signal } : undefined;\n const entries: LogEntry[] = [];\n for (let i = 0; i < cap; i++) {\n const seq = hint + i;\n const key = logObjectKey(logPrefix, seq);\n const got = await storage.get(key, getOpts);\n if (got === null) {\n return { tail: seq, entries };\n }\n try {\n entries.push(decodeJsonBytes<LogEntry>(got.body));\n } catch (error) {\n // A malformed body at an occupied slot is a protocol violation —\n // surface it as InvalidResponse (the same code readLogEntry uses)\n // rather than a raw SyntaxError leaking out of the probe.\n throw new BaerlyError(\n \"InvalidResponse\",\n `probeTailFrom: malformed log entry at ${key}: ${(error as Error).message}`,\n { cause: error },\n );\n }\n }\n // Cap exhausted without hitting a 404 — the true tail is past `cap`.\n // Returning `hint+cap` here would silently truncate every downstream\n // read (since.ts / query.ts / GC / export / rebuild-index), so we\n // THROW instead, mirroring `findLogTail`'s cap-exhaustion guard. With\n // the maintenance tick keeping `tail_hint` within\n // `MAINTENANCE_TAIL_HINT_REFRESH_WRITES` of the true tail (HR-2), this\n // is a pure runaway alarm — a >cap gap means maintenance is\n // broken/disabled (a graduation/operator concern), never normal\n // operation. No partial-accept escape hatch: no caller legitimately\n // needs to walk past the cap.\n throw new BaerlyError(\n \"Internal\",\n `probeTailFrom: forward probe exceeded ${cap} from hint ${hint} on ${logPrefix}`,\n );\n};\n\n/**\n * First empty log seq at/after `hint` — the slot a new commit creates —\n * found by galloping search (`O(log gap)` GETs vs `probeTailFrom`'s\n * `O(gap)`). Used by the writer's per-commit tail-find, where `tail_hint`\n * can lag the true tail. Position only; no bodies.\n *\n * PRECONDITION: occupancy MUST be a dense prefix from `hint` (galloping\n * assumes monotone occupied→empty; a hole ABOVE `hint` would be skipped\n * and the gallop could return a tail past live entries). Contrast\n * `probeTailFrom`, which stops at the first 404 and is hole-tolerant.\n */\nexport const findLogTail = async (\n storage: Storage,\n logPrefix: string,\n hint: number,\n opts?: { signal?: AbortSignal },\n): Promise<number> => {\n const getOpts = opts?.signal !== undefined ? { signal: opts.signal } : undefined;\n const exists = async (seq: number): Promise<boolean> =>\n (await storage.get(logObjectKey(logPrefix, seq), getOpts)) !== null;\n if (!(await exists(hint))) {\n return hint;\n }\n // Gallop to bracket the tail in `(lo, hi]` (lo occupied, hi empty).\n let lo = hint;\n let step = 1;\n let hi = hint + step;\n while (await exists(hi)) {\n lo = hi;\n step *= 2;\n hi = lo + step;\n if (step > LOG_FORWARD_PROBE_CAP) {\n throw new BaerlyError(\n \"Internal\",\n `findLogTail: galloping probe exceeded ${LOG_FORWARD_PROBE_CAP} from hint ${hint} on ${logPrefix}`,\n );\n }\n }\n while (hi - lo > 1) {\n const mid = lo + Math.floor((hi -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;CAGT,IAAI,KAAK;CACT,IAAI,OAAO;CACX,IAAI,KAAK,OAAO;CAChB,OAAO,MAAM,OAAO,EAAE,GAAG;EACvB,KAAK;EACL,QAAQ;EACR,KAAK,KAAK;EACV,IAAI,OAAA,KACF,MAAM,IAAI,YACR,YACA,yCAAyC,sBAAsB,aAAa,KAAK,MAAM,WACzF;CAEJ;CACA,OAAO,KAAK,KAAK,GAAG;EAClB,MAAM,MAAM,KAAK,KAAK,OAAO,KAAK,MAAM,CAAC;EACzC,IAAI,MAAM,OAAO,GAAG,GAClB,KAAK;OAEL,KAAK;CAET;CACA,OAAO;AACT"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { d as IndexDefinition } from "./app-config-DyiFK3_k.js";
|
|
2
|
-
import { d as CurrentJson, p as Storage } from "./index-
|
|
2
|
+
import { d as CurrentJson, p as Storage } from "./index-CEZKQsKt.js";
|
|
3
3
|
//#region packages/server/src/compactor.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Public configuration knobs for {@link compact}. All optional; the
|
|
@@ -534,4 +534,4 @@ declare const parseMaintenanceEnv: (readEnv: (key: string) => string | undefined
|
|
|
534
534
|
};
|
|
535
535
|
//#endregion
|
|
536
536
|
export { CompactOptions as C, runGc as S, compact as T, RebuildIndexOptions as _, MaintenanceArgs as a, RunGcOptions as b, MaintenanceProfile as c, dispatchInlineAwaited as d, estimateTailBytes as f, shouldFireMaintenance as g, runScheduledMaintenance as h, InternalMaintenanceOptions as i, MaintenanceResult as l, runBoundedMaintenance as m, CLOUDFLARE_FREE_TIER as n, MaintenanceDispatch as o, parseMaintenanceEnv as p, CLOUDFLARE_PAID_TIER as r, MaintenanceOptions as s, BoundedMaintenanceOptions as t, crossesGcBoundary as u, RebuildIndexResult as v, CompactResult as w, RunGcResult as x, rebuildIndex as y };
|
|
537
|
-
//# sourceMappingURL=maintenance-
|
|
537
|
+
//# sourceMappingURL=maintenance-BGHGt2Yg.d.ts.map
|