@goodpeanuts/dsh-sui 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +100 -3
- package/THIRD_PARTY_NOTICES.txt +1064 -0
- package/apps/cli/dist/_virtual/_rolldown/runtime.mjs +35 -0
- package/apps/cli/dist/args.mjs +204 -0
- package/apps/cli/dist/cli.mjs +392 -0
- package/apps/cli/dist/errors.mjs +32 -0
- package/apps/cli/dist/help.mjs +73 -0
- package/apps/cli/dist/io.mjs +37 -0
- package/apps/cli/dist/main.mjs +10 -0
- package/apps/cli/dist/node_modules/.pnpm/@keyv_serialize@1.1.1/node_modules/@keyv/serialize/dist/index.mjs +37 -0
- package/apps/cli/dist/node_modules/.pnpm/@sec-ant_readable-stream@0.4.1/node_modules/@sec-ant/readable-stream/dist/ponyfill/asyncIterator.mjs +81 -0
- package/apps/cli/dist/node_modules/.pnpm/@sec-ant_readable-stream@0.4.1/node_modules/@sec-ant/readable-stream/dist/ponyfill/index.mjs +1 -0
- package/apps/cli/dist/node_modules/.pnpm/@sindresorhus_is@7.2.0/node_modules/@sindresorhus/is/distribution/index.mjs +1015 -0
- package/apps/cli/dist/node_modules/.pnpm/@sindresorhus_is@7.2.0/node_modules/@sindresorhus/is/distribution/utilities.mjs +6 -0
- package/apps/cli/dist/node_modules/.pnpm/boolbase@1.0.0/node_modules/boolbase/index.mjs +15 -0
- package/apps/cli/dist/node_modules/.pnpm/byte-counter@0.1.0/node_modules/byte-counter/utilities.mjs +9 -0
- package/apps/cli/dist/node_modules/.pnpm/cacheable-lookup@7.0.0/node_modules/cacheable-lookup/source/index.mjs +279 -0
- package/apps/cli/dist/node_modules/.pnpm/cacheable-request@13.0.19/node_modules/cacheable-request/dist/index.mjs +274 -0
- package/apps/cli/dist/node_modules/.pnpm/cacheable-request@13.0.19/node_modules/cacheable-request/dist/types.mjs +15 -0
- package/apps/cli/dist/node_modules/.pnpm/cheerio-select@2.1.0/node_modules/cheerio-select/lib/esm/helpers.mjs +15 -0
- package/apps/cli/dist/node_modules/.pnpm/cheerio-select@2.1.0/node_modules/cheerio-select/lib/esm/index.mjs +159 -0
- package/apps/cli/dist/node_modules/.pnpm/cheerio-select@2.1.0/node_modules/cheerio-select/lib/esm/positionals.mjs +33 -0
- package/apps/cli/dist/node_modules/.pnpm/cheerio@1.1.2/node_modules/cheerio/dist/esm/api/attributes.mjs +465 -0
- package/apps/cli/dist/node_modules/.pnpm/cheerio@1.1.2/node_modules/cheerio/dist/esm/api/css.mjs +94 -0
- package/apps/cli/dist/node_modules/.pnpm/cheerio@1.1.2/node_modules/cheerio/dist/esm/api/extract.mjs +39 -0
- package/apps/cli/dist/node_modules/.pnpm/cheerio@1.1.2/node_modules/cheerio/dist/esm/api/forms.mjs +63 -0
- package/apps/cli/dist/node_modules/.pnpm/cheerio@1.1.2/node_modules/cheerio/dist/esm/api/manipulation.mjs +731 -0
- package/apps/cli/dist/node_modules/.pnpm/cheerio@1.1.2/node_modules/cheerio/dist/esm/api/traversing.mjs +828 -0
- package/apps/cli/dist/node_modules/.pnpm/cheerio@1.1.2/node_modules/cheerio/dist/esm/cheerio.mjs +53 -0
- package/apps/cli/dist/node_modules/.pnpm/cheerio@1.1.2/node_modules/cheerio/dist/esm/index.mjs +11 -0
- package/apps/cli/dist/node_modules/.pnpm/cheerio@1.1.2/node_modules/cheerio/dist/esm/load-parse.mjs +25 -0
- package/apps/cli/dist/node_modules/.pnpm/cheerio@1.1.2/node_modules/cheerio/dist/esm/load.mjs +73 -0
- package/apps/cli/dist/node_modules/.pnpm/cheerio@1.1.2/node_modules/cheerio/dist/esm/options.mjs +27 -0
- package/apps/cli/dist/node_modules/.pnpm/cheerio@1.1.2/node_modules/cheerio/dist/esm/parse.mjs +53 -0
- package/apps/cli/dist/node_modules/.pnpm/cheerio@1.1.2/node_modules/cheerio/dist/esm/parsers/parse5-adapter.mjs +42 -0
- package/apps/cli/dist/node_modules/.pnpm/cheerio@1.1.2/node_modules/cheerio/dist/esm/static.mjs +165 -0
- package/apps/cli/dist/node_modules/.pnpm/cheerio@1.1.2/node_modules/cheerio/dist/esm/utils.mjs +78 -0
- package/apps/cli/dist/node_modules/.pnpm/css-select@5.2.2/node_modules/css-select/lib/esm/attributes.mjs +187 -0
- package/apps/cli/dist/node_modules/.pnpm/css-select@5.2.2/node_modules/css-select/lib/esm/compile.mjs +77 -0
- package/apps/cli/dist/node_modules/.pnpm/css-select@5.2.2/node_modules/css-select/lib/esm/general.mjs +89 -0
- package/apps/cli/dist/node_modules/.pnpm/css-select@5.2.2/node_modules/css-select/lib/esm/index.mjs +43 -0
- package/apps/cli/dist/node_modules/.pnpm/css-select@5.2.2/node_modules/css-select/lib/esm/pseudo-selectors/aliases.mjs +32 -0
- package/apps/cli/dist/node_modules/.pnpm/css-select@5.2.2/node_modules/css-select/lib/esm/pseudo-selectors/filters.mjs +114 -0
- package/apps/cli/dist/node_modules/.pnpm/css-select@5.2.2/node_modules/css-select/lib/esm/pseudo-selectors/index.mjs +35 -0
- package/apps/cli/dist/node_modules/.pnpm/css-select@5.2.2/node_modules/css-select/lib/esm/pseudo-selectors/pseudos.mjs +53 -0
- package/apps/cli/dist/node_modules/.pnpm/css-select@5.2.2/node_modules/css-select/lib/esm/pseudo-selectors/subselects.mjs +68 -0
- package/apps/cli/dist/node_modules/.pnpm/css-select@5.2.2/node_modules/css-select/lib/esm/sort.mjs +60 -0
- package/apps/cli/dist/node_modules/.pnpm/css-what@6.2.2/node_modules/css-what/lib/commonjs/index.mjs +50 -0
- package/apps/cli/dist/node_modules/.pnpm/css-what@6.2.2/node_modules/css-what/lib/commonjs/parse.mjs +320 -0
- package/apps/cli/dist/node_modules/.pnpm/css-what@6.2.2/node_modules/css-what/lib/commonjs/stringify.mjs +102 -0
- package/apps/cli/dist/node_modules/.pnpm/css-what@6.2.2/node_modules/css-what/lib/commonjs/types.mjs +45 -0
- package/apps/cli/dist/node_modules/.pnpm/decompress-response@10.0.0/node_modules/decompress-response/index.mjs +59 -0
- package/apps/cli/dist/node_modules/.pnpm/dom-serializer@2.0.0/node_modules/dom-serializer/lib/esm/foreignNames.mjs +103 -0
- package/apps/cli/dist/node_modules/.pnpm/dom-serializer@2.0.0/node_modules/dom-serializer/lib/esm/index.mjs +144 -0
- package/apps/cli/dist/node_modules/.pnpm/domelementtype@2.3.0/node_modules/domelementtype/lib/esm/index.mjs +51 -0
- package/apps/cli/dist/node_modules/.pnpm/domhandler@5.0.3/node_modules/domhandler/lib/esm/index.mjs +128 -0
- package/apps/cli/dist/node_modules/.pnpm/domhandler@5.0.3/node_modules/domhandler/lib/esm/node.mjs +312 -0
- package/apps/cli/dist/node_modules/.pnpm/domutils@3.2.2/node_modules/domutils/lib/esm/feeds.mjs +161 -0
- package/apps/cli/dist/node_modules/.pnpm/domutils@3.2.2/node_modules/domutils/lib/esm/helpers.mjs +113 -0
- package/apps/cli/dist/node_modules/.pnpm/domutils@3.2.2/node_modules/domutils/lib/esm/index.mjs +56 -0
- package/apps/cli/dist/node_modules/.pnpm/domutils@3.2.2/node_modules/domutils/lib/esm/legacy.mjs +141 -0
- package/apps/cli/dist/node_modules/.pnpm/domutils@3.2.2/node_modules/domutils/lib/esm/manipulation.mjs +117 -0
- package/apps/cli/dist/node_modules/.pnpm/domutils@3.2.2/node_modules/domutils/lib/esm/querying.mjs +124 -0
- package/apps/cli/dist/node_modules/.pnpm/domutils@3.2.2/node_modules/domutils/lib/esm/stringify.mjs +69 -0
- package/apps/cli/dist/node_modules/.pnpm/domutils@3.2.2/node_modules/domutils/lib/esm/traversal.mjs +109 -0
- package/apps/cli/dist/node_modules/.pnpm/encoding-sniffer@0.2.1/node_modules/encoding-sniffer/dist/esm/index.mjs +7 -0
- package/apps/cli/dist/node_modules/.pnpm/encoding-sniffer@0.2.1/node_modules/encoding-sniffer/dist/esm/sniffer.mjs +112 -0
- package/apps/cli/dist/node_modules/.pnpm/entities@4.5.0/node_modules/entities/lib/esm/escape.mjs +83 -0
- package/apps/cli/dist/node_modules/.pnpm/entities@6.0.1/node_modules/entities/dist/esm/decode-codepoint.mjs +43 -0
- package/apps/cli/dist/node_modules/.pnpm/entities@6.0.1/node_modules/entities/dist/esm/decode.mjs +330 -0
- package/apps/cli/dist/node_modules/.pnpm/entities@6.0.1/node_modules/entities/dist/esm/escape.mjs +49 -0
- package/apps/cli/dist/node_modules/.pnpm/entities@6.0.1/node_modules/entities/dist/esm/generated/decode-data-html.mjs +4 -0
- package/apps/cli/dist/node_modules/.pnpm/entities@7.0.1/node_modules/entities/dist/esm/decode-codepoint.mjs +57 -0
- package/apps/cli/dist/node_modules/.pnpm/entities@7.0.1/node_modules/entities/dist/esm/decode.mjs +351 -0
- package/apps/cli/dist/node_modules/.pnpm/entities@7.0.1/node_modules/entities/dist/esm/generated/decode-data-html.mjs +5 -0
- package/apps/cli/dist/node_modules/.pnpm/entities@7.0.1/node_modules/entities/dist/esm/generated/decode-data-xml.mjs +5 -0
- package/apps/cli/dist/node_modules/.pnpm/entities@7.0.1/node_modules/entities/dist/esm/internal/bin-trie-flags.mjs +20 -0
- package/apps/cli/dist/node_modules/.pnpm/entities@7.0.1/node_modules/entities/dist/esm/internal/decode-shared.mjs +14 -0
- package/apps/cli/dist/node_modules/.pnpm/fflate@0.8.3/node_modules/fflate/esm/index.mjs +871 -0
- package/apps/cli/dist/node_modules/.pnpm/form-data-encoder@4.1.0/node_modules/form-data-encoder/lib/index.mjs +279 -0
- package/apps/cli/dist/node_modules/.pnpm/get-stream@9.0.1/node_modules/get-stream/source/array-buffer.mjs +54 -0
- package/apps/cli/dist/node_modules/.pnpm/get-stream@9.0.1/node_modules/get-stream/source/buffer.mjs +14 -0
- package/apps/cli/dist/node_modules/.pnpm/get-stream@9.0.1/node_modules/get-stream/source/contents.mjs +80 -0
- package/apps/cli/dist/node_modules/.pnpm/get-stream@9.0.1/node_modules/get-stream/source/stream.mjs +41 -0
- package/apps/cli/dist/node_modules/.pnpm/get-stream@9.0.1/node_modules/get-stream/source/utils.mjs +8 -0
- package/apps/cli/dist/node_modules/.pnpm/got@14.6.5/node_modules/got/dist/source/as-promise/index.mjs +154 -0
- package/apps/cli/dist/node_modules/.pnpm/got@14.6.5/node_modules/got/dist/source/as-promise/types.mjs +20 -0
- package/apps/cli/dist/node_modules/.pnpm/got@14.6.5/node_modules/got/dist/source/core/calculate-retry-delay.mjs +20 -0
- package/apps/cli/dist/node_modules/.pnpm/got@14.6.5/node_modules/got/dist/source/core/diagnostics-channel.mjs +38 -0
- package/apps/cli/dist/node_modules/.pnpm/got@14.6.5/node_modules/got/dist/source/core/errors.mjs +132 -0
- package/apps/cli/dist/node_modules/.pnpm/got@14.6.5/node_modules/got/dist/source/core/index.mjs +923 -0
- package/apps/cli/dist/node_modules/.pnpm/got@14.6.5/node_modules/got/dist/source/core/options.mjs +1622 -0
- package/apps/cli/dist/node_modules/.pnpm/got@14.6.5/node_modules/got/dist/source/core/parse-link-header.mjs +27 -0
- package/apps/cli/dist/node_modules/.pnpm/got@14.6.5/node_modules/got/dist/source/core/response.mjs +36 -0
- package/apps/cli/dist/node_modules/.pnpm/got@14.6.5/node_modules/got/dist/source/core/timed-out.mjs +107 -0
- package/apps/cli/dist/node_modules/.pnpm/got@14.6.5/node_modules/got/dist/source/core/utils/defer-to-connect.mjs +28 -0
- package/apps/cli/dist/node_modules/.pnpm/got@14.6.5/node_modules/got/dist/source/core/utils/get-body-size.mjs +23 -0
- package/apps/cli/dist/node_modules/.pnpm/got@14.6.5/node_modules/got/dist/source/core/utils/is-client-request.mjs +6 -0
- package/apps/cli/dist/node_modules/.pnpm/got@14.6.5/node_modules/got/dist/source/core/utils/is-form-data.mjs +7 -0
- package/apps/cli/dist/node_modules/.pnpm/got@14.6.5/node_modules/got/dist/source/core/utils/is-unix-socket-url.mjs +25 -0
- package/apps/cli/dist/node_modules/.pnpm/got@14.6.5/node_modules/got/dist/source/core/utils/proxy-events.mjs +16 -0
- package/apps/cli/dist/node_modules/.pnpm/got@14.6.5/node_modules/got/dist/source/core/utils/timer.mjs +114 -0
- package/apps/cli/dist/node_modules/.pnpm/got@14.6.5/node_modules/got/dist/source/core/utils/unhandle.mjs +23 -0
- package/apps/cli/dist/node_modules/.pnpm/got@14.6.5/node_modules/got/dist/source/core/utils/url-to-options.mjs +20 -0
- package/apps/cli/dist/node_modules/.pnpm/got@14.6.5/node_modules/got/dist/source/core/utils/weakable-map.mjs +19 -0
- package/apps/cli/dist/node_modules/.pnpm/got@14.6.5/node_modules/got/dist/source/create.mjs +166 -0
- package/apps/cli/dist/node_modules/.pnpm/got@14.6.5/node_modules/got/dist/source/index.mjs +17 -0
- package/apps/cli/dist/node_modules/.pnpm/htmlparser2@10.1.0/node_modules/htmlparser2/dist/esm/Parser.mjs +441 -0
- package/apps/cli/dist/node_modules/.pnpm/htmlparser2@10.1.0/node_modules/htmlparser2/dist/esm/Tokenizer.mjs +661 -0
- package/apps/cli/dist/node_modules/.pnpm/htmlparser2@10.1.0/node_modules/htmlparser2/dist/esm/index.mjs +19 -0
- package/apps/cli/dist/node_modules/.pnpm/http-cache-semantics@4.3.0/node_modules/http-cache-semantics/index.mjs +608 -0
- package/apps/cli/dist/node_modules/.pnpm/http2-wrapper@2.2.1/node_modules/http2-wrapper/source/agent.mjs +441 -0
- package/apps/cli/dist/node_modules/.pnpm/http2-wrapper@2.2.1/node_modules/http2-wrapper/source/auto.mjs +145 -0
- package/apps/cli/dist/node_modules/.pnpm/http2-wrapper@2.2.1/node_modules/http2-wrapper/source/client-request.mjs +318 -0
- package/apps/cli/dist/node_modules/.pnpm/http2-wrapper@2.2.1/node_modules/http2-wrapper/source/incoming-message.mjs +58 -0
- package/apps/cli/dist/node_modules/.pnpm/http2-wrapper@2.2.1/node_modules/http2-wrapper/source/index.mjs +51 -0
- package/apps/cli/dist/node_modules/.pnpm/http2-wrapper@2.2.1/node_modules/http2-wrapper/source/proxies/get-auth-headers.mjs +19 -0
- package/apps/cli/dist/node_modules/.pnpm/http2-wrapper@2.2.1/node_modules/http2-wrapper/source/proxies/h1-over-h2.mjs +84 -0
- package/apps/cli/dist/node_modules/.pnpm/http2-wrapper@2.2.1/node_modules/http2-wrapper/source/proxies/h2-over-h1.mjs +49 -0
- package/apps/cli/dist/node_modules/.pnpm/http2-wrapper@2.2.1/node_modules/http2-wrapper/source/proxies/h2-over-h2.mjs +38 -0
- package/apps/cli/dist/node_modules/.pnpm/http2-wrapper@2.2.1/node_modules/http2-wrapper/source/proxies/h2-over-hx.mjs +39 -0
- package/apps/cli/dist/node_modules/.pnpm/http2-wrapper@2.2.1/node_modules/http2-wrapper/source/proxies/initialize.mjs +23 -0
- package/apps/cli/dist/node_modules/.pnpm/http2-wrapper@2.2.1/node_modules/http2-wrapper/source/proxies/unexpected-status-code-error.mjs +15 -0
- package/apps/cli/dist/node_modules/.pnpm/http2-wrapper@2.2.1/node_modules/http2-wrapper/source/utils/calculate-server-name.mjs +24 -0
- package/apps/cli/dist/node_modules/.pnpm/http2-wrapper@2.2.1/node_modules/http2-wrapper/source/utils/check-type.mjs +17 -0
- package/apps/cli/dist/node_modules/.pnpm/http2-wrapper@2.2.1/node_modules/http2-wrapper/source/utils/delay-async-destroy.mjs +28 -0
- package/apps/cli/dist/node_modules/.pnpm/http2-wrapper@2.2.1/node_modules/http2-wrapper/source/utils/errors.mjs +30 -0
- package/apps/cli/dist/node_modules/.pnpm/http2-wrapper@2.2.1/node_modules/http2-wrapper/source/utils/is-request-pseudo-header.mjs +16 -0
- package/apps/cli/dist/node_modules/.pnpm/http2-wrapper@2.2.1/node_modules/http2-wrapper/source/utils/js-stream-socket.mjs +9 -0
- package/apps/cli/dist/node_modules/.pnpm/http2-wrapper@2.2.1/node_modules/http2-wrapper/source/utils/proxy-events.mjs +10 -0
- package/apps/cli/dist/node_modules/.pnpm/http2-wrapper@2.2.1/node_modules/http2-wrapper/source/utils/proxy-socket-handler.mjs +77 -0
- package/apps/cli/dist/node_modules/.pnpm/http2-wrapper@2.2.1/node_modules/http2-wrapper/source/utils/validate-header-name.mjs +15 -0
- package/apps/cli/dist/node_modules/.pnpm/http2-wrapper@2.2.1/node_modules/http2-wrapper/source/utils/validate-header-value.mjs +14 -0
- package/apps/cli/dist/node_modules/.pnpm/iconv-lite@0.6.3/node_modules/iconv-lite/encodings/dbcs-codec.mjs +355 -0
- package/apps/cli/dist/node_modules/.pnpm/iconv-lite@0.6.3/node_modules/iconv-lite/encodings/dbcs-data.mjs +191 -0
- package/apps/cli/dist/node_modules/.pnpm/iconv-lite@0.6.3/node_modules/iconv-lite/encodings/index.mjs +31 -0
- package/apps/cli/dist/node_modules/.pnpm/iconv-lite@0.6.3/node_modules/iconv-lite/encodings/internal.mjs +140 -0
- package/apps/cli/dist/node_modules/.pnpm/iconv-lite@0.6.3/node_modules/iconv-lite/encodings/sbcs-codec.mjs +50 -0
- package/apps/cli/dist/node_modules/.pnpm/iconv-lite@0.6.3/node_modules/iconv-lite/encodings/sbcs-data-generated.mjs +455 -0
- package/apps/cli/dist/node_modules/.pnpm/iconv-lite@0.6.3/node_modules/iconv-lite/encodings/sbcs-data.mjs +151 -0
- package/apps/cli/dist/node_modules/.pnpm/iconv-lite@0.6.3/node_modules/iconv-lite/encodings/tables/big5-added.mjs +169 -0
- package/apps/cli/dist/node_modules/.pnpm/iconv-lite@0.6.3/node_modules/iconv-lite/encodings/tables/cp936.mjs +2584 -0
- package/apps/cli/dist/node_modules/.pnpm/iconv-lite@0.6.3/node_modules/iconv-lite/encodings/tables/cp949.mjs +2220 -0
- package/apps/cli/dist/node_modules/.pnpm/iconv-lite@0.6.3/node_modules/iconv-lite/encodings/tables/cp950.mjs +227 -0
- package/apps/cli/dist/node_modules/.pnpm/iconv-lite@0.6.3/node_modules/iconv-lite/encodings/tables/eucjp.mjs +425 -0
- package/apps/cli/dist/node_modules/.pnpm/iconv-lite@0.6.3/node_modules/iconv-lite/encodings/tables/gb18030-ranges.mjs +427 -0
- package/apps/cli/dist/node_modules/.pnpm/iconv-lite@0.6.3/node_modules/iconv-lite/encodings/tables/gbk-added.mjs +230 -0
- package/apps/cli/dist/node_modules/.pnpm/iconv-lite@0.6.3/node_modules/iconv-lite/encodings/tables/shiftjis.mjs +292 -0
- package/apps/cli/dist/node_modules/.pnpm/iconv-lite@0.6.3/node_modules/iconv-lite/encodings/utf16.mjs +123 -0
- package/apps/cli/dist/node_modules/.pnpm/iconv-lite@0.6.3/node_modules/iconv-lite/encodings/utf32.mjs +197 -0
- package/apps/cli/dist/node_modules/.pnpm/iconv-lite@0.6.3/node_modules/iconv-lite/encodings/utf7.mjs +182 -0
- package/apps/cli/dist/node_modules/.pnpm/iconv-lite@0.6.3/node_modules/iconv-lite/lib/bom-handling.mjs +42 -0
- package/apps/cli/dist/node_modules/.pnpm/iconv-lite@0.6.3/node_modules/iconv-lite/lib/index.mjs +108 -0
- package/apps/cli/dist/node_modules/.pnpm/iconv-lite@0.6.3/node_modules/iconv-lite/lib/streams.mjs +90 -0
- package/apps/cli/dist/node_modules/.pnpm/is-stream@4.0.1/node_modules/is-stream/index.mjs +9 -0
- package/apps/cli/dist/node_modules/.pnpm/js-sha256@0.11.1/node_modules/js-sha256/src/sha256.mjs +495 -0
- package/apps/cli/dist/node_modules/.pnpm/keyv@5.6.0/node_modules/keyv/dist/index.mjs +740 -0
- package/apps/cli/dist/node_modules/.pnpm/lowercase-keys@3.0.0/node_modules/lowercase-keys/index.mjs +6 -0
- package/apps/cli/dist/node_modules/.pnpm/mimic-response@4.0.0/node_modules/mimic-response/index.mjs +53 -0
- package/apps/cli/dist/node_modules/.pnpm/normalize-url@8.1.1/node_modules/normalize-url/index.mjs +145 -0
- package/apps/cli/dist/node_modules/.pnpm/nth-check@2.1.1/node_modules/nth-check/lib/esm/compile.mjs +37 -0
- package/apps/cli/dist/node_modules/.pnpm/nth-check@2.1.1/node_modules/nth-check/lib/esm/index.mjs +31 -0
- package/apps/cli/dist/node_modules/.pnpm/nth-check@2.1.1/node_modules/nth-check/lib/esm/parse.mjs +60 -0
- package/apps/cli/dist/node_modules/.pnpm/p-cancelable@4.0.1/node_modules/p-cancelable/index.mjs +86 -0
- package/apps/cli/dist/node_modules/.pnpm/parse5-htmlparser2-tree-adapter@7.1.0/node_modules/parse5-htmlparser2-tree-adapter/dist/index.mjs +187 -0
- package/apps/cli/dist/node_modules/.pnpm/parse5-parser-stream@7.1.2/node_modules/parse5-parser-stream/dist/index.mjs +2 -0
- package/apps/cli/dist/node_modules/.pnpm/parse5@7.3.0/node_modules/parse5/dist/common/doctype.mjs +101 -0
- package/apps/cli/dist/node_modules/.pnpm/parse5@7.3.0/node_modules/parse5/dist/common/error-codes.mjs +66 -0
- package/apps/cli/dist/node_modules/.pnpm/parse5@7.3.0/node_modules/parse5/dist/common/foreign-content.mjs +259 -0
- package/apps/cli/dist/node_modules/.pnpm/parse5@7.3.0/node_modules/parse5/dist/common/html.mjs +544 -0
- package/apps/cli/dist/node_modules/.pnpm/parse5@7.3.0/node_modules/parse5/dist/common/token.mjs +19 -0
- package/apps/cli/dist/node_modules/.pnpm/parse5@7.3.0/node_modules/parse5/dist/common/unicode.mjs +91 -0
- package/apps/cli/dist/node_modules/.pnpm/parse5@7.3.0/node_modules/parse5/dist/index.mjs +41 -0
- package/apps/cli/dist/node_modules/.pnpm/parse5@7.3.0/node_modules/parse5/dist/parser/formatting-element-list.mjs +91 -0
- package/apps/cli/dist/node_modules/.pnpm/parse5@7.3.0/node_modules/parse5/dist/parser/index.mjs +2492 -0
- package/apps/cli/dist/node_modules/.pnpm/parse5@7.3.0/node_modules/parse5/dist/parser/open-element-stack.mjs +292 -0
- package/apps/cli/dist/node_modules/.pnpm/parse5@7.3.0/node_modules/parse5/dist/serializer/index.mjs +111 -0
- package/apps/cli/dist/node_modules/.pnpm/parse5@7.3.0/node_modules/parse5/dist/tokenizer/index.mjs +2067 -0
- package/apps/cli/dist/node_modules/.pnpm/parse5@7.3.0/node_modules/parse5/dist/tokenizer/preprocessor.mjs +154 -0
- package/apps/cli/dist/node_modules/.pnpm/parse5@7.3.0/node_modules/parse5/dist/tree-adapters/default.mjs +164 -0
- package/apps/cli/dist/node_modules/.pnpm/quick-lru@5.1.1/node_modules/quick-lru/index.mjs +77 -0
- package/apps/cli/dist/node_modules/.pnpm/resolve-alpn@1.2.1/node_modules/resolve-alpn/index.mjs +47 -0
- package/apps/cli/dist/node_modules/.pnpm/responselike@4.0.2/node_modules/responselike/index.mjs +32 -0
- package/apps/cli/dist/node_modules/.pnpm/safer-buffer@2.1.2/node_modules/safer-buffer/safer.mjs +45 -0
- package/apps/cli/dist/node_modules/.pnpm/tldts@7.4.18/node_modules/tldts/dist/cjs/index.mjs +22542 -0
- package/apps/cli/dist/node_modules/.pnpm/tough-cookie@6.0.0/node_modules/tough-cookie/dist/index.mjs +1761 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/index.mjs +221 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/api/abort-signal.mjs +44 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/api/api-connect.mjs +85 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/api/api-pipeline.mjs +174 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/api/api-request.mjs +155 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/api/api-stream.mjs +136 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/api/api-upgrade.mjs +88 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/api/index.mjs +17 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/api/readable.mjs +418 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/cache/memory-cache-store.mjs +190 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/cache/sqlite-cache-store.mjs +324 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/core/connect.mjs +115 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/core/constants.mjs +134 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/core/diagnostics.mjs +114 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/core/errors.mjs +412 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/core/request.mjs +282 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/core/socks5-client.mjs +288 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/core/socks5-utils.mjs +166 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/core/symbols.mjs +80 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/core/tree.mjs +124 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/core/util.mjs +940 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/dispatcher/agent.mjs +119 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/dispatcher/balanced-pool.mjs +129 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/dispatcher/client-h1.mjs +1091 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/dispatcher/client-h2.mjs +588 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/dispatcher/client.mjs +385 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/dispatcher/dispatcher-base.mjs +121 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/dispatcher/dispatcher.mjs +35 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/dispatcher/env-http-proxy-agent.mjs +105 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/dispatcher/fixed-queue.mjs +75 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/dispatcher/h2c-client.mjs +31 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/dispatcher/pool-base.mjs +155 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/dispatcher/pool.mjs +76 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/dispatcher/proxy-agent.mjs +233 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/dispatcher/retry-agent.mjs +37 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/dispatcher/round-robin-pool.mjs +94 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/dispatcher/socks5-proxy-agent.mjs +194 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/encoding/index.mjs +18 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/global.mjs +48 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/handler/cache-handler.mjs +457 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/handler/cache-revalidation-handler.mjs +82 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/handler/decorator-handler.mjs +57 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/handler/deduplication-handler.mjs +341 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/handler/redirect-handler.mjs +131 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/handler/retry-handler.mjs +332 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/handler/unwrap-handler.mjs +88 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/handler/wrap-handler.mjs +68 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/interceptor/cache.mjs +350 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/interceptor/decompress.mjs +416 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/interceptor/deduplicate.mjs +69 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/interceptor/dns.mjs +323 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/interceptor/dump.mjs +65 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/interceptor/redirect.mjs +20 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/interceptor/response-error.mjs +73 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/interceptor/retry.mjs +25 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/llhttp/constants.mjs +590 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/llhttp/llhttp-wasm.mjs +13 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/llhttp/llhttp_simd-wasm.mjs +13 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/llhttp/utils.mjs +16 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/mock/mock-agent.mjs +154 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/mock/mock-call-history.mjs +159 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/mock/mock-client.mjs +59 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/mock/mock-errors.mjs +28 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/mock/mock-interceptor.mjs +150 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/mock/mock-pool.mjs +59 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/mock/mock-symbols.mjs +37 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/mock/mock-utils.mjs +302 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/mock/pending-interceptors-formatter.mjs +38 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/mock/snapshot-agent.mjs +268 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/mock/snapshot-recorder.mjs +424 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/mock/snapshot-utils.mjs +121 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/util/cache.mjs +440 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/util/date.mjs +332 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/util/promise.mjs +31 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/util/runtime-features.mjs +101 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/util/stats.mjs +31 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/util/timers.mjs +341 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/cache/cache.mjs +462 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/cache/cachestorage.mjs +103 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/cache/util.mjs +39 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/cookies/constants.mjs +11 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/cookies/index.mjs +169 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/cookies/parse.mjs +108 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/cookies/util.mjs +239 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/eventsource/eventsource-stream.mjs +317 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/eventsource/eventsource.mjs +345 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/eventsource/util.mjs +29 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/fetch/body.mjs +271 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/fetch/constants.mjs +224 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/fetch/data-url.mjs +247 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/fetch/formdata-parser.mjs +255 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/fetch/formdata.mjs +153 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/fetch/global.mjs +34 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/fetch/headers.mjs +400 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/fetch/index.mjs +776 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/fetch/request.mjs +602 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/fetch/response.mjs +358 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/fetch/util.mjs +795 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/infra/index.mjs +154 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.mjs +170 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/webidl/index.mjs +505 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/websocket/connection.mjs +166 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/websocket/constants.mjs +47 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/websocket/events.mjs +268 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/websocket/frame.mjs +105 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/websocket/permessage-deflate.mjs +85 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/websocket/receiver.mjs +323 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/websocket/sender.mjs +90 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/websocket/stream/websocketerror.mjs +78 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/websocket/stream/websocketstream.mjs +270 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/websocket/util.mjs +212 -0
- package/apps/cli/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/websocket/websocket.mjs +432 -0
- package/apps/cli/dist/node_modules/.pnpm/whatwg-encoding@3.1.1/node_modules/whatwg-encoding/lib/labels-to-names.mjs +224 -0
- package/apps/cli/dist/node_modules/.pnpm/whatwg-encoding@3.1.1/node_modules/whatwg-encoding/lib/supported-names.mjs +45 -0
- package/apps/cli/dist/node_modules/.pnpm/whatwg-encoding@3.1.1/node_modules/whatwg-encoding/lib/whatwg-encoding.mjs +40 -0
- package/apps/cli/dist/node_modules/.pnpm/whatwg-mimetype@4.0.0/node_modules/whatwg-mimetype/lib/mime-type-parameters.mjs +54 -0
- package/apps/cli/dist/node_modules/.pnpm/whatwg-mimetype@4.0.0/node_modules/whatwg-mimetype/lib/mime-type.mjs +92 -0
- package/apps/cli/dist/node_modules/.pnpm/whatwg-mimetype@4.0.0/node_modules/whatwg-mimetype/lib/parser.mjs +62 -0
- package/apps/cli/dist/node_modules/.pnpm/whatwg-mimetype@4.0.0/node_modules/whatwg-mimetype/lib/serializer.mjs +24 -0
- package/apps/cli/dist/node_modules/.pnpm/whatwg-mimetype@4.0.0/node_modules/whatwg-mimetype/lib/utils.mjs +47 -0
- package/apps/cli/dist/node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/errors.mjs +26 -0
- package/apps/cli/dist/node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/iso.mjs +35 -0
- package/apps/cli/dist/node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/parse.mjs +17 -0
- package/apps/cli/dist/node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/schemas.mjs +800 -0
- package/apps/cli/dist/node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/api.mjs +508 -0
- package/apps/cli/dist/node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/checks.mjs +366 -0
- package/apps/cli/dist/node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/core.mjs +60 -0
- package/apps/cli/dist/node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/doc.mjs +32 -0
- package/apps/cli/dist/node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/errors.mjs +63 -0
- package/apps/cli/dist/node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/json-schema-processors.mjs +253 -0
- package/apps/cli/dist/node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/parse.mjs +118 -0
- package/apps/cli/dist/node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/regexes.mjs +65 -0
- package/apps/cli/dist/node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/registries.mjs +48 -0
- package/apps/cli/dist/node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/schemas.mjs +1235 -0
- package/apps/cli/dist/node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/to-json-schema.mjs +297 -0
- package/apps/cli/dist/node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/util.mjs +316 -0
- package/apps/cli/dist/node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/versions.mjs +8 -0
- package/apps/cli/dist/packages/data-maintenance/src/archive.mjs +143 -0
- package/apps/cli/dist/packages/data-maintenance/src/contracts.mjs +17 -0
- package/apps/cli/dist/packages/data-maintenance/src/files.mjs +121 -0
- package/apps/cli/dist/packages/data-maintenance/src/index.mjs +494 -0
- package/apps/cli/dist/packages/data-maintenance/src/lease.mjs +53 -0
- package/apps/cli/dist/packages/data-maintenance/src/migration-backup.mjs +57 -0
- package/apps/cli/dist/packages/data-maintenance/src/paths.mjs +15 -0
- package/apps/cli/dist/packages/feidee/src/client.mjs +635 -0
- package/apps/cli/dist/packages/feidee/src/hash.mjs +10 -0
- package/apps/cli/dist/packages/feidee/src/index.mjs +8 -0
- package/apps/cli/dist/packages/feidee/src/mutation-gateway.mjs +165 -0
- package/apps/cli/dist/packages/feidee/src/parsers.mjs +634 -0
- package/apps/cli/dist/packages/feidee/src/transaction-text.mjs +39 -0
- package/apps/cli/dist/packages/feidee/src/write-contract.mjs +273 -0
- package/apps/cli/dist/packages/finance/src/date-range.mjs +74 -0
- package/apps/cli/dist/packages/finance/src/domain.mjs +18 -0
- package/apps/cli/dist/packages/finance/src/errors.mjs +221 -0
- package/apps/cli/dist/packages/finance/src/index.mjs +16 -0
- package/apps/cli/dist/packages/finance/src/metadata-query.mjs +32 -0
- package/apps/cli/dist/packages/finance/src/sync/progress.mjs +27 -0
- package/apps/cli/dist/packages/finance/src/sync/service.mjs +282 -0
- package/apps/cli/dist/packages/finance/src/transactions/audit.mjs +104 -0
- package/apps/cli/dist/packages/finance/src/transactions/canary.mjs +85 -0
- package/apps/cli/dist/packages/finance/src/transactions/compare.mjs +76 -0
- package/apps/cli/dist/packages/finance/src/transactions/contracts.mjs +92 -0
- package/apps/cli/dist/packages/finance/src/transactions/memo-policy.mjs +79 -0
- package/apps/cli/dist/packages/finance/src/transactions/mutation.mjs +656 -0
- package/apps/cli/dist/packages/finance/src/transactions/query.mjs +59 -0
- package/apps/cli/dist/packages/finance/src/transactions/statistics.mjs +67 -0
- package/apps/cli/dist/packages/finance/src/write-policy.mjs +4 -0
- package/apps/cli/dist/packages/finance-module/src/balance-preview.mjs +4 -0
- package/apps/cli/dist/packages/finance-module/src/contracts.mjs +13 -0
- package/apps/cli/dist/packages/finance-module/src/database.mjs +1292 -0
- package/apps/cli/dist/packages/finance-module/src/draft-entries.mjs +89 -0
- package/apps/cli/dist/packages/finance-module/src/draft-receipts.mjs +8 -0
- package/apps/cli/dist/packages/finance-module/src/historical-task-archives.mjs +24 -0
- package/apps/cli/dist/packages/finance-module/src/node.mjs +76 -0
- package/apps/cli/dist/packages/finance-module/src/personal-preferences.mjs +29 -0
- package/apps/cli/dist/packages/finance-module/src/route-contracts.mjs +11 -0
- package/apps/cli/dist/packages/finance-module/src/schema-compatibility.mjs +142 -0
- package/apps/cli/dist/packages/finance-module/src/service-record-domain.mjs +16 -0
- package/apps/cli/dist/packages/finance-module/src/service-record-store.mjs +119 -0
- package/apps/cli/dist/packages/finance-module/src/shared-draft-migration.mjs +39 -0
- package/apps/cli/dist/packages/finance-module/src/single-draft-migration.mjs +70 -0
- package/apps/cli/dist/packages/finance-module/src/storage.mjs +282 -0
- package/apps/cli/dist/packages/finance-module/src/web-contracts.mjs +38 -0
- package/apps/cli/dist/packages/local-store/src/checkpoint-backup.mjs +40 -0
- package/apps/cli/dist/packages/local-store/src/checkpoint-history.mjs +77 -0
- package/apps/cli/dist/packages/local-store/src/database.mjs +1523 -0
- package/apps/cli/dist/packages/local-store/src/exchange-rates.mjs +169 -0
- package/apps/cli/dist/packages/local-store/src/node.mjs +71 -0
- package/apps/cli/dist/packages/sdk/src/account-snapshot-service.mjs +582 -0
- package/apps/cli/dist/packages/sdk/src/auth.mjs +89 -0
- package/apps/cli/dist/packages/sdk/src/cache-analysis.mjs +393 -0
- package/apps/cli/dist/packages/sdk/src/config.mjs +64 -0
- package/apps/cli/dist/packages/sdk/src/credential-identity.mjs +8 -0
- package/apps/cli/dist/packages/sdk/src/credentials.mjs +86 -0
- package/apps/cli/dist/packages/sdk/src/exchange-rate-service.mjs +253 -0
- package/apps/cli/dist/packages/sdk/src/finance-cookie-cache.mjs +93 -0
- package/apps/cli/dist/packages/sdk/src/finance-session.mjs +215 -0
- package/apps/cli/dist/packages/sdk/src/frankfurter.mjs +125 -0
- package/apps/cli/dist/packages/sdk/src/node.mjs +53 -0
- package/apps/cli/dist/packages/sdk/src/probe.mjs +65 -0
- package/apps/cli/dist/packages/sdk/src/resource-lease-node.mjs +27 -0
- package/apps/cli/dist/packages/sdk/src/resource-lease-owner-node.mjs +68 -0
- package/apps/cli/dist/packages/sdk/src/resource-lease.mjs +143 -0
- package/apps/cli/dist/packages/sdk/src/runtime.mjs +643 -0
- package/apps/cli/dist/storage.mjs +11 -0
- package/bundles/sui-ledger/dist/_virtual/_rolldown/runtime.mjs +35 -0
- package/bundles/sui-ledger/dist/capabilities/tools.mjs +32 -0
- package/bundles/sui-ledger/dist/client.js +23511 -0
- package/bundles/sui-ledger/dist/finance-prompt.mjs +30 -0
- package/bundles/sui-ledger/dist/finance-state-context.mjs +38 -0
- package/bundles/sui-ledger/dist/index.mjs +198 -0
- package/bundles/sui-ledger/dist/maintenance-cli.mjs +76 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/@deepseek-ai_dsh-home-paths_159c15e70066431314381a350c2ee56a/node_modules/@deepseek-ai/dsh-home-paths/lib/index.mjs +67 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/@keyv_serialize@1.1.1/node_modules/@keyv/serialize/dist/index.mjs +37 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/@sec-ant_readable-stream@0.4.1/node_modules/@sec-ant/readable-stream/dist/ponyfill/asyncIterator.mjs +81 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/@sec-ant_readable-stream@0.4.1/node_modules/@sec-ant/readable-stream/dist/ponyfill/index.mjs +1 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/@sindresorhus_is@7.2.0/node_modules/@sindresorhus/is/distribution/index.mjs +1015 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/@sindresorhus_is@7.2.0/node_modules/@sindresorhus/is/distribution/utilities.mjs +6 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/boolbase@1.0.0/node_modules/boolbase/index.mjs +15 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/byte-counter@0.1.0/node_modules/byte-counter/utilities.mjs +9 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/cacheable-lookup@7.0.0/node_modules/cacheable-lookup/source/index.mjs +279 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/cacheable-request@13.0.19/node_modules/cacheable-request/dist/index.mjs +274 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/cacheable-request@13.0.19/node_modules/cacheable-request/dist/types.mjs +15 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/cheerio-select@2.1.0/node_modules/cheerio-select/lib/esm/helpers.mjs +15 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/cheerio-select@2.1.0/node_modules/cheerio-select/lib/esm/index.mjs +159 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/cheerio-select@2.1.0/node_modules/cheerio-select/lib/esm/positionals.mjs +33 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/cheerio@1.1.2/node_modules/cheerio/dist/esm/api/attributes.mjs +465 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/cheerio@1.1.2/node_modules/cheerio/dist/esm/api/css.mjs +94 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/cheerio@1.1.2/node_modules/cheerio/dist/esm/api/extract.mjs +39 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/cheerio@1.1.2/node_modules/cheerio/dist/esm/api/forms.mjs +63 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/cheerio@1.1.2/node_modules/cheerio/dist/esm/api/manipulation.mjs +731 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/cheerio@1.1.2/node_modules/cheerio/dist/esm/api/traversing.mjs +828 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/cheerio@1.1.2/node_modules/cheerio/dist/esm/cheerio.mjs +53 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/cheerio@1.1.2/node_modules/cheerio/dist/esm/index.mjs +11 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/cheerio@1.1.2/node_modules/cheerio/dist/esm/load-parse.mjs +25 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/cheerio@1.1.2/node_modules/cheerio/dist/esm/load.mjs +73 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/cheerio@1.1.2/node_modules/cheerio/dist/esm/options.mjs +27 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/cheerio@1.1.2/node_modules/cheerio/dist/esm/parse.mjs +53 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/cheerio@1.1.2/node_modules/cheerio/dist/esm/parsers/parse5-adapter.mjs +42 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/cheerio@1.1.2/node_modules/cheerio/dist/esm/static.mjs +165 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/cheerio@1.1.2/node_modules/cheerio/dist/esm/utils.mjs +78 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/css-select@5.2.2/node_modules/css-select/lib/esm/attributes.mjs +187 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/css-select@5.2.2/node_modules/css-select/lib/esm/compile.mjs +77 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/css-select@5.2.2/node_modules/css-select/lib/esm/general.mjs +89 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/css-select@5.2.2/node_modules/css-select/lib/esm/index.mjs +43 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/css-select@5.2.2/node_modules/css-select/lib/esm/pseudo-selectors/aliases.mjs +32 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/css-select@5.2.2/node_modules/css-select/lib/esm/pseudo-selectors/filters.mjs +114 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/css-select@5.2.2/node_modules/css-select/lib/esm/pseudo-selectors/index.mjs +35 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/css-select@5.2.2/node_modules/css-select/lib/esm/pseudo-selectors/pseudos.mjs +53 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/css-select@5.2.2/node_modules/css-select/lib/esm/pseudo-selectors/subselects.mjs +68 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/css-select@5.2.2/node_modules/css-select/lib/esm/sort.mjs +60 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/css-what@6.2.2/node_modules/css-what/lib/commonjs/index.mjs +50 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/css-what@6.2.2/node_modules/css-what/lib/commonjs/parse.mjs +320 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/css-what@6.2.2/node_modules/css-what/lib/commonjs/stringify.mjs +102 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/css-what@6.2.2/node_modules/css-what/lib/commonjs/types.mjs +45 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/decompress-response@10.0.0/node_modules/decompress-response/index.mjs +59 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/dom-serializer@2.0.0/node_modules/dom-serializer/lib/esm/foreignNames.mjs +103 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/dom-serializer@2.0.0/node_modules/dom-serializer/lib/esm/index.mjs +144 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/domelementtype@2.3.0/node_modules/domelementtype/lib/esm/index.mjs +51 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/domhandler@5.0.3/node_modules/domhandler/lib/esm/index.mjs +128 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/domhandler@5.0.3/node_modules/domhandler/lib/esm/node.mjs +312 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/domutils@3.2.2/node_modules/domutils/lib/esm/feeds.mjs +161 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/domutils@3.2.2/node_modules/domutils/lib/esm/helpers.mjs +113 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/domutils@3.2.2/node_modules/domutils/lib/esm/index.mjs +56 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/domutils@3.2.2/node_modules/domutils/lib/esm/legacy.mjs +141 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/domutils@3.2.2/node_modules/domutils/lib/esm/manipulation.mjs +117 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/domutils@3.2.2/node_modules/domutils/lib/esm/querying.mjs +124 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/domutils@3.2.2/node_modules/domutils/lib/esm/stringify.mjs +69 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/domutils@3.2.2/node_modules/domutils/lib/esm/traversal.mjs +109 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/encoding-sniffer@0.2.1/node_modules/encoding-sniffer/dist/esm/index.mjs +7 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/encoding-sniffer@0.2.1/node_modules/encoding-sniffer/dist/esm/sniffer.mjs +112 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/entities@4.5.0/node_modules/entities/lib/esm/escape.mjs +83 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/entities@6.0.1/node_modules/entities/dist/esm/decode-codepoint.mjs +43 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/entities@6.0.1/node_modules/entities/dist/esm/decode.mjs +330 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/entities@6.0.1/node_modules/entities/dist/esm/escape.mjs +49 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/entities@6.0.1/node_modules/entities/dist/esm/generated/decode-data-html.mjs +4 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/entities@7.0.1/node_modules/entities/dist/esm/decode-codepoint.mjs +57 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/entities@7.0.1/node_modules/entities/dist/esm/decode.mjs +351 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/entities@7.0.1/node_modules/entities/dist/esm/generated/decode-data-html.mjs +5 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/entities@7.0.1/node_modules/entities/dist/esm/generated/decode-data-xml.mjs +5 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/entities@7.0.1/node_modules/entities/dist/esm/internal/bin-trie-flags.mjs +20 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/entities@7.0.1/node_modules/entities/dist/esm/internal/decode-shared.mjs +14 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/fflate@0.8.3/node_modules/fflate/esm/index.mjs +871 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/form-data-encoder@4.1.0/node_modules/form-data-encoder/lib/index.mjs +279 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/get-stream@9.0.1/node_modules/get-stream/source/array-buffer.mjs +54 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/get-stream@9.0.1/node_modules/get-stream/source/buffer.mjs +14 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/get-stream@9.0.1/node_modules/get-stream/source/contents.mjs +80 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/get-stream@9.0.1/node_modules/get-stream/source/stream.mjs +41 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/get-stream@9.0.1/node_modules/get-stream/source/utils.mjs +8 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/got@14.6.5/node_modules/got/dist/source/as-promise/index.mjs +154 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/got@14.6.5/node_modules/got/dist/source/as-promise/types.mjs +20 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/got@14.6.5/node_modules/got/dist/source/core/calculate-retry-delay.mjs +20 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/got@14.6.5/node_modules/got/dist/source/core/diagnostics-channel.mjs +38 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/got@14.6.5/node_modules/got/dist/source/core/errors.mjs +132 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/got@14.6.5/node_modules/got/dist/source/core/index.mjs +923 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/got@14.6.5/node_modules/got/dist/source/core/options.mjs +1622 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/got@14.6.5/node_modules/got/dist/source/core/parse-link-header.mjs +27 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/got@14.6.5/node_modules/got/dist/source/core/response.mjs +36 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/got@14.6.5/node_modules/got/dist/source/core/timed-out.mjs +107 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/got@14.6.5/node_modules/got/dist/source/core/utils/defer-to-connect.mjs +28 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/got@14.6.5/node_modules/got/dist/source/core/utils/get-body-size.mjs +23 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/got@14.6.5/node_modules/got/dist/source/core/utils/is-client-request.mjs +6 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/got@14.6.5/node_modules/got/dist/source/core/utils/is-form-data.mjs +7 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/got@14.6.5/node_modules/got/dist/source/core/utils/is-unix-socket-url.mjs +25 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/got@14.6.5/node_modules/got/dist/source/core/utils/proxy-events.mjs +16 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/got@14.6.5/node_modules/got/dist/source/core/utils/timer.mjs +114 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/got@14.6.5/node_modules/got/dist/source/core/utils/unhandle.mjs +23 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/got@14.6.5/node_modules/got/dist/source/core/utils/url-to-options.mjs +20 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/got@14.6.5/node_modules/got/dist/source/core/utils/weakable-map.mjs +19 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/got@14.6.5/node_modules/got/dist/source/create.mjs +166 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/got@14.6.5/node_modules/got/dist/source/index.mjs +17 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/htmlparser2@10.1.0/node_modules/htmlparser2/dist/esm/Parser.mjs +441 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/htmlparser2@10.1.0/node_modules/htmlparser2/dist/esm/Tokenizer.mjs +661 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/htmlparser2@10.1.0/node_modules/htmlparser2/dist/esm/index.mjs +19 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/http-cache-semantics@4.3.0/node_modules/http-cache-semantics/index.mjs +608 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/http2-wrapper@2.2.1/node_modules/http2-wrapper/source/agent.mjs +441 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/http2-wrapper@2.2.1/node_modules/http2-wrapper/source/auto.mjs +145 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/http2-wrapper@2.2.1/node_modules/http2-wrapper/source/client-request.mjs +318 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/http2-wrapper@2.2.1/node_modules/http2-wrapper/source/incoming-message.mjs +58 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/http2-wrapper@2.2.1/node_modules/http2-wrapper/source/index.mjs +51 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/http2-wrapper@2.2.1/node_modules/http2-wrapper/source/proxies/get-auth-headers.mjs +19 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/http2-wrapper@2.2.1/node_modules/http2-wrapper/source/proxies/h1-over-h2.mjs +84 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/http2-wrapper@2.2.1/node_modules/http2-wrapper/source/proxies/h2-over-h1.mjs +49 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/http2-wrapper@2.2.1/node_modules/http2-wrapper/source/proxies/h2-over-h2.mjs +38 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/http2-wrapper@2.2.1/node_modules/http2-wrapper/source/proxies/h2-over-hx.mjs +39 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/http2-wrapper@2.2.1/node_modules/http2-wrapper/source/proxies/initialize.mjs +23 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/http2-wrapper@2.2.1/node_modules/http2-wrapper/source/proxies/unexpected-status-code-error.mjs +15 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/http2-wrapper@2.2.1/node_modules/http2-wrapper/source/utils/calculate-server-name.mjs +24 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/http2-wrapper@2.2.1/node_modules/http2-wrapper/source/utils/check-type.mjs +17 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/http2-wrapper@2.2.1/node_modules/http2-wrapper/source/utils/delay-async-destroy.mjs +28 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/http2-wrapper@2.2.1/node_modules/http2-wrapper/source/utils/errors.mjs +30 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/http2-wrapper@2.2.1/node_modules/http2-wrapper/source/utils/is-request-pseudo-header.mjs +16 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/http2-wrapper@2.2.1/node_modules/http2-wrapper/source/utils/js-stream-socket.mjs +9 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/http2-wrapper@2.2.1/node_modules/http2-wrapper/source/utils/proxy-events.mjs +10 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/http2-wrapper@2.2.1/node_modules/http2-wrapper/source/utils/proxy-socket-handler.mjs +77 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/http2-wrapper@2.2.1/node_modules/http2-wrapper/source/utils/validate-header-name.mjs +15 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/http2-wrapper@2.2.1/node_modules/http2-wrapper/source/utils/validate-header-value.mjs +14 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/iconv-lite@0.6.3/node_modules/iconv-lite/encodings/dbcs-codec.mjs +355 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/iconv-lite@0.6.3/node_modules/iconv-lite/encodings/dbcs-data.mjs +191 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/iconv-lite@0.6.3/node_modules/iconv-lite/encodings/index.mjs +31 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/iconv-lite@0.6.3/node_modules/iconv-lite/encodings/internal.mjs +140 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/iconv-lite@0.6.3/node_modules/iconv-lite/encodings/sbcs-codec.mjs +50 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/iconv-lite@0.6.3/node_modules/iconv-lite/encodings/sbcs-data-generated.mjs +455 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/iconv-lite@0.6.3/node_modules/iconv-lite/encodings/sbcs-data.mjs +151 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/iconv-lite@0.6.3/node_modules/iconv-lite/encodings/tables/big5-added.mjs +169 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/iconv-lite@0.6.3/node_modules/iconv-lite/encodings/tables/cp936.mjs +2584 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/iconv-lite@0.6.3/node_modules/iconv-lite/encodings/tables/cp949.mjs +2220 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/iconv-lite@0.6.3/node_modules/iconv-lite/encodings/tables/cp950.mjs +227 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/iconv-lite@0.6.3/node_modules/iconv-lite/encodings/tables/eucjp.mjs +425 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/iconv-lite@0.6.3/node_modules/iconv-lite/encodings/tables/gb18030-ranges.mjs +427 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/iconv-lite@0.6.3/node_modules/iconv-lite/encodings/tables/gbk-added.mjs +230 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/iconv-lite@0.6.3/node_modules/iconv-lite/encodings/tables/shiftjis.mjs +292 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/iconv-lite@0.6.3/node_modules/iconv-lite/encodings/utf16.mjs +123 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/iconv-lite@0.6.3/node_modules/iconv-lite/encodings/utf32.mjs +197 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/iconv-lite@0.6.3/node_modules/iconv-lite/encodings/utf7.mjs +182 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/iconv-lite@0.6.3/node_modules/iconv-lite/lib/bom-handling.mjs +42 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/iconv-lite@0.6.3/node_modules/iconv-lite/lib/index.mjs +108 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/iconv-lite@0.6.3/node_modules/iconv-lite/lib/streams.mjs +90 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/is-stream@4.0.1/node_modules/is-stream/index.mjs +9 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/js-sha256@0.11.1/node_modules/js-sha256/src/sha256.mjs +495 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/keyv@5.6.0/node_modules/keyv/dist/index.mjs +740 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/lowercase-keys@3.0.0/node_modules/lowercase-keys/index.mjs +6 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/mimic-response@4.0.0/node_modules/mimic-response/index.mjs +53 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/normalize-url@8.1.1/node_modules/normalize-url/index.mjs +145 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/nth-check@2.1.1/node_modules/nth-check/lib/esm/compile.mjs +37 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/nth-check@2.1.1/node_modules/nth-check/lib/esm/index.mjs +31 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/nth-check@2.1.1/node_modules/nth-check/lib/esm/parse.mjs +60 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/p-cancelable@4.0.1/node_modules/p-cancelable/index.mjs +86 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/parse5-htmlparser2-tree-adapter@7.1.0/node_modules/parse5-htmlparser2-tree-adapter/dist/index.mjs +187 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/parse5-parser-stream@7.1.2/node_modules/parse5-parser-stream/dist/index.mjs +2 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/parse5@7.3.0/node_modules/parse5/dist/common/doctype.mjs +101 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/parse5@7.3.0/node_modules/parse5/dist/common/error-codes.mjs +66 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/parse5@7.3.0/node_modules/parse5/dist/common/foreign-content.mjs +259 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/parse5@7.3.0/node_modules/parse5/dist/common/html.mjs +544 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/parse5@7.3.0/node_modules/parse5/dist/common/token.mjs +19 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/parse5@7.3.0/node_modules/parse5/dist/common/unicode.mjs +91 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/parse5@7.3.0/node_modules/parse5/dist/index.mjs +41 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/parse5@7.3.0/node_modules/parse5/dist/parser/formatting-element-list.mjs +91 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/parse5@7.3.0/node_modules/parse5/dist/parser/index.mjs +2492 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/parse5@7.3.0/node_modules/parse5/dist/parser/open-element-stack.mjs +292 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/parse5@7.3.0/node_modules/parse5/dist/serializer/index.mjs +111 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/parse5@7.3.0/node_modules/parse5/dist/tokenizer/index.mjs +2067 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/parse5@7.3.0/node_modules/parse5/dist/tokenizer/preprocessor.mjs +154 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/parse5@7.3.0/node_modules/parse5/dist/tree-adapters/default.mjs +164 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/quick-lru@5.1.1/node_modules/quick-lru/index.mjs +77 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/resolve-alpn@1.2.1/node_modules/resolve-alpn/index.mjs +47 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/responselike@4.0.2/node_modules/responselike/index.mjs +32 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/safer-buffer@2.1.2/node_modules/safer-buffer/safer.mjs +45 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/tldts@7.4.18/node_modules/tldts/dist/cjs/index.mjs +22542 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/tough-cookie@6.0.0/node_modules/tough-cookie/dist/index.mjs +1761 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/index.mjs +221 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/api/abort-signal.mjs +44 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/api/api-connect.mjs +85 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/api/api-pipeline.mjs +174 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/api/api-request.mjs +155 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/api/api-stream.mjs +136 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/api/api-upgrade.mjs +88 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/api/index.mjs +17 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/api/readable.mjs +418 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/cache/memory-cache-store.mjs +190 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/cache/sqlite-cache-store.mjs +324 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/core/connect.mjs +115 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/core/constants.mjs +134 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/core/diagnostics.mjs +114 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/core/errors.mjs +412 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/core/request.mjs +282 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/core/socks5-client.mjs +288 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/core/socks5-utils.mjs +166 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/core/symbols.mjs +80 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/core/tree.mjs +124 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/core/util.mjs +940 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/dispatcher/agent.mjs +119 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/dispatcher/balanced-pool.mjs +129 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/dispatcher/client-h1.mjs +1091 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/dispatcher/client-h2.mjs +588 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/dispatcher/client.mjs +385 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/dispatcher/dispatcher-base.mjs +121 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/dispatcher/dispatcher.mjs +35 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/dispatcher/env-http-proxy-agent.mjs +105 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/dispatcher/fixed-queue.mjs +75 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/dispatcher/h2c-client.mjs +31 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/dispatcher/pool-base.mjs +155 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/dispatcher/pool.mjs +76 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/dispatcher/proxy-agent.mjs +233 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/dispatcher/retry-agent.mjs +37 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/dispatcher/round-robin-pool.mjs +94 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/dispatcher/socks5-proxy-agent.mjs +194 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/encoding/index.mjs +18 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/global.mjs +48 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/handler/cache-handler.mjs +457 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/handler/cache-revalidation-handler.mjs +82 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/handler/decorator-handler.mjs +57 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/handler/deduplication-handler.mjs +341 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/handler/redirect-handler.mjs +131 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/handler/retry-handler.mjs +332 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/handler/unwrap-handler.mjs +88 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/handler/wrap-handler.mjs +68 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/interceptor/cache.mjs +350 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/interceptor/decompress.mjs +416 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/interceptor/deduplicate.mjs +69 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/interceptor/dns.mjs +323 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/interceptor/dump.mjs +65 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/interceptor/redirect.mjs +20 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/interceptor/response-error.mjs +73 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/interceptor/retry.mjs +25 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/llhttp/constants.mjs +590 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/llhttp/llhttp-wasm.mjs +13 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/llhttp/llhttp_simd-wasm.mjs +13 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/llhttp/utils.mjs +16 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/mock/mock-agent.mjs +154 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/mock/mock-call-history.mjs +159 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/mock/mock-client.mjs +59 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/mock/mock-errors.mjs +28 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/mock/mock-interceptor.mjs +150 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/mock/mock-pool.mjs +59 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/mock/mock-symbols.mjs +37 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/mock/mock-utils.mjs +302 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/mock/pending-interceptors-formatter.mjs +38 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/mock/snapshot-agent.mjs +268 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/mock/snapshot-recorder.mjs +424 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/mock/snapshot-utils.mjs +121 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/util/cache.mjs +440 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/util/date.mjs +332 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/util/promise.mjs +31 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/util/runtime-features.mjs +101 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/util/stats.mjs +31 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/util/timers.mjs +341 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/cache/cache.mjs +462 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/cache/cachestorage.mjs +103 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/cache/util.mjs +39 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/cookies/constants.mjs +11 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/cookies/index.mjs +169 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/cookies/parse.mjs +108 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/cookies/util.mjs +239 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/eventsource/eventsource-stream.mjs +317 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/eventsource/eventsource.mjs +345 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/eventsource/util.mjs +29 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/fetch/body.mjs +271 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/fetch/constants.mjs +224 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/fetch/data-url.mjs +247 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/fetch/formdata-parser.mjs +255 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/fetch/formdata.mjs +153 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/fetch/global.mjs +34 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/fetch/headers.mjs +400 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/fetch/index.mjs +776 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/fetch/request.mjs +602 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/fetch/response.mjs +358 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/fetch/util.mjs +795 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/infra/index.mjs +154 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.mjs +170 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/webidl/index.mjs +505 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/websocket/connection.mjs +166 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/websocket/constants.mjs +47 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/websocket/events.mjs +268 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/websocket/frame.mjs +105 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/websocket/permessage-deflate.mjs +85 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/websocket/receiver.mjs +323 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/websocket/sender.mjs +90 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/websocket/stream/websocketerror.mjs +78 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/websocket/stream/websocketstream.mjs +270 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/websocket/util.mjs +212 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/web/websocket/websocket.mjs +432 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/whatwg-encoding@3.1.1/node_modules/whatwg-encoding/lib/labels-to-names.mjs +224 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/whatwg-encoding@3.1.1/node_modules/whatwg-encoding/lib/supported-names.mjs +45 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/whatwg-encoding@3.1.1/node_modules/whatwg-encoding/lib/whatwg-encoding.mjs +40 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/whatwg-mimetype@4.0.0/node_modules/whatwg-mimetype/lib/mime-type-parameters.mjs +54 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/whatwg-mimetype@4.0.0/node_modules/whatwg-mimetype/lib/mime-type.mjs +92 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/whatwg-mimetype@4.0.0/node_modules/whatwg-mimetype/lib/parser.mjs +62 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/whatwg-mimetype@4.0.0/node_modules/whatwg-mimetype/lib/serializer.mjs +24 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/whatwg-mimetype@4.0.0/node_modules/whatwg-mimetype/lib/utils.mjs +47 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/xlsx@0.18.5/node_modules/xlsx/dist/cpexcel.mjs +3348 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/xlsx@0.18.5/node_modules/xlsx/xlsx.mjs +26473 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/errors.mjs +26 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/iso.mjs +35 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/parse.mjs +17 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/schemas.mjs +800 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/api.mjs +508 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/checks.mjs +366 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/core.mjs +60 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/doc.mjs +32 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/errors.mjs +63 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/json-schema-processors.mjs +253 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/parse.mjs +118 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/regexes.mjs +65 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/registries.mjs +48 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/schemas.mjs +1235 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/to-json-schema.mjs +297 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/util.mjs +316 -0
- package/bundles/sui-ledger/dist/node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/versions.mjs +8 -0
- package/bundles/sui-ledger/dist/packages/data-maintenance/src/archive.mjs +143 -0
- package/bundles/sui-ledger/dist/packages/data-maintenance/src/contracts.mjs +17 -0
- package/bundles/sui-ledger/dist/packages/data-maintenance/src/files.mjs +158 -0
- package/bundles/sui-ledger/dist/packages/data-maintenance/src/index.mjs +494 -0
- package/bundles/sui-ledger/dist/packages/data-maintenance/src/lease.mjs +53 -0
- package/bundles/sui-ledger/dist/packages/data-maintenance/src/migration-backup.mjs +57 -0
- package/bundles/sui-ledger/dist/packages/data-maintenance/src/paths.mjs +15 -0
- package/bundles/sui-ledger/dist/packages/data-maintenance/src/runtime.mjs +132 -0
- package/bundles/sui-ledger/dist/packages/feidee/src/client.mjs +635 -0
- package/bundles/sui-ledger/dist/packages/feidee/src/hash.mjs +10 -0
- package/bundles/sui-ledger/dist/packages/feidee/src/index.mjs +8 -0
- package/bundles/sui-ledger/dist/packages/feidee/src/mutation-gateway.mjs +165 -0
- package/bundles/sui-ledger/dist/packages/feidee/src/parsers.mjs +634 -0
- package/bundles/sui-ledger/dist/packages/feidee/src/transaction-text.mjs +39 -0
- package/bundles/sui-ledger/dist/packages/feidee/src/write-contract.mjs +273 -0
- package/bundles/sui-ledger/dist/packages/finance/src/date-range.mjs +74 -0
- package/bundles/sui-ledger/dist/packages/finance/src/domain.mjs +18 -0
- package/bundles/sui-ledger/dist/packages/finance/src/errors.mjs +221 -0
- package/bundles/sui-ledger/dist/packages/finance/src/index.mjs +17 -0
- package/bundles/sui-ledger/dist/packages/finance/src/json-schema.mjs +212 -0
- package/bundles/sui-ledger/dist/packages/finance/src/metadata-query.mjs +32 -0
- package/bundles/sui-ledger/dist/packages/finance/src/money.mjs +39 -0
- package/bundles/sui-ledger/dist/packages/finance/src/public-error.mjs +10 -0
- package/bundles/sui-ledger/dist/packages/finance/src/sync/progress.mjs +27 -0
- package/bundles/sui-ledger/dist/packages/finance/src/sync/service.mjs +282 -0
- package/bundles/sui-ledger/dist/packages/finance/src/transactions/audit.mjs +104 -0
- package/bundles/sui-ledger/dist/packages/finance/src/transactions/canary.mjs +85 -0
- package/bundles/sui-ledger/dist/packages/finance/src/transactions/compare.mjs +76 -0
- package/bundles/sui-ledger/dist/packages/finance/src/transactions/contracts.mjs +83 -0
- package/bundles/sui-ledger/dist/packages/finance/src/transactions/memo-policy.mjs +79 -0
- package/bundles/sui-ledger/dist/packages/finance/src/transactions/mutation.mjs +656 -0
- package/bundles/sui-ledger/dist/packages/finance/src/transactions/query.mjs +59 -0
- package/bundles/sui-ledger/dist/packages/finance/src/transactions/statistics.mjs +67 -0
- package/bundles/sui-ledger/dist/packages/finance/src/write-policy.mjs +4 -0
- package/bundles/sui-ledger/dist/packages/finance-module/src/balance-preview.mjs +119 -0
- package/bundles/sui-ledger/dist/packages/finance-module/src/capabilities.mjs +1306 -0
- package/bundles/sui-ledger/dist/packages/finance-module/src/checkpoint-review.mjs +75 -0
- package/bundles/sui-ledger/dist/packages/finance-module/src/commit-failure.mjs +161 -0
- package/bundles/sui-ledger/dist/packages/finance-module/src/commit-recovery.mjs +41 -0
- package/bundles/sui-ledger/dist/packages/finance-module/src/contracts.mjs +13 -0
- package/bundles/sui-ledger/dist/packages/finance-module/src/data-version.mjs +8 -0
- package/bundles/sui-ledger/dist/packages/finance-module/src/database.mjs +1292 -0
- package/bundles/sui-ledger/dist/packages/finance-module/src/draft-entries.mjs +216 -0
- package/bundles/sui-ledger/dist/packages/finance-module/src/draft-receipts.mjs +16 -0
- package/bundles/sui-ledger/dist/packages/finance-module/src/finance-guidance.mjs +23 -0
- package/bundles/sui-ledger/dist/packages/finance-module/src/historical-task-archives.mjs +24 -0
- package/bundles/sui-ledger/dist/packages/finance-module/src/index.mjs +17 -0
- package/bundles/sui-ledger/dist/packages/finance-module/src/interactions.mjs +229 -0
- package/bundles/sui-ledger/dist/packages/finance-module/src/model-pages.mjs +61 -0
- package/bundles/sui-ledger/dist/packages/finance-module/src/model-views.mjs +206 -0
- package/bundles/sui-ledger/dist/packages/finance-module/src/node.mjs +76 -0
- package/bundles/sui-ledger/dist/packages/finance-module/src/personal-preferences.mjs +103 -0
- package/bundles/sui-ledger/dist/packages/finance-module/src/route-contracts.mjs +11 -0
- package/bundles/sui-ledger/dist/packages/finance-module/src/routes.mjs +427 -0
- package/bundles/sui-ledger/dist/packages/finance-module/src/schema-compatibility.mjs +142 -0
- package/bundles/sui-ledger/dist/packages/finance-module/src/sdk-adapter.mjs +100 -0
- package/bundles/sui-ledger/dist/packages/finance-module/src/service-record-domain.mjs +207 -0
- package/bundles/sui-ledger/dist/packages/finance-module/src/service-record-routes.mjs +91 -0
- package/bundles/sui-ledger/dist/packages/finance-module/src/service-record-store.mjs +119 -0
- package/bundles/sui-ledger/dist/packages/finance-module/src/service-record-tools.mjs +283 -0
- package/bundles/sui-ledger/dist/packages/finance-module/src/service-records.mjs +626 -0
- package/bundles/sui-ledger/dist/packages/finance-module/src/service.mjs +2525 -0
- package/bundles/sui-ledger/dist/packages/finance-module/src/shared-draft-migration.mjs +39 -0
- package/bundles/sui-ledger/dist/packages/finance-module/src/single-draft-migration.mjs +70 -0
- package/bundles/sui-ledger/dist/packages/finance-module/src/source-reader.mjs +354 -0
- package/bundles/sui-ledger/dist/packages/finance-module/src/storage.mjs +282 -0
- package/bundles/sui-ledger/dist/packages/finance-module/src/tool-contracts.mjs +42 -0
- package/bundles/sui-ledger/dist/packages/finance-module/src/web-contracts.mjs +74 -0
- package/bundles/sui-ledger/dist/packages/interaction/src/registry.mjs +36 -0
- package/bundles/sui-ledger/dist/packages/interaction/src/service.mjs +424 -0
- package/bundles/sui-ledger/dist/packages/local-store/src/checkpoint-backup.mjs +40 -0
- package/bundles/sui-ledger/dist/packages/local-store/src/checkpoint-history.mjs +77 -0
- package/bundles/sui-ledger/dist/packages/local-store/src/database.mjs +1523 -0
- package/bundles/sui-ledger/dist/packages/local-store/src/exchange-rates.mjs +169 -0
- package/bundles/sui-ledger/dist/packages/local-store/src/node.mjs +71 -0
- package/bundles/sui-ledger/dist/packages/local-store/src/readonly-node.mjs +486 -0
- package/bundles/sui-ledger/dist/packages/sdk/src/account-snapshot-service.mjs +582 -0
- package/bundles/sui-ledger/dist/packages/sdk/src/cache-analysis.mjs +597 -0
- package/bundles/sui-ledger/dist/packages/sdk/src/config.mjs +64 -0
- package/bundles/sui-ledger/dist/packages/sdk/src/credential-identity.mjs +7 -0
- package/bundles/sui-ledger/dist/packages/sdk/src/credentials.mjs +86 -0
- package/bundles/sui-ledger/dist/packages/sdk/src/exchange-rate-service.mjs +253 -0
- package/bundles/sui-ledger/dist/packages/sdk/src/finance-cookie-cache.mjs +93 -0
- package/bundles/sui-ledger/dist/packages/sdk/src/finance-session.mjs +215 -0
- package/bundles/sui-ledger/dist/packages/sdk/src/frankfurter.mjs +125 -0
- package/bundles/sui-ledger/dist/packages/sdk/src/ledger-money.mjs +183 -0
- package/bundles/sui-ledger/dist/packages/sdk/src/node-readonly.mjs +381 -0
- package/bundles/sui-ledger/dist/packages/sdk/src/node.mjs +53 -0
- package/bundles/sui-ledger/dist/packages/sdk/src/probe.mjs +65 -0
- package/bundles/sui-ledger/dist/packages/sdk/src/resource-lease-node.mjs +27 -0
- package/bundles/sui-ledger/dist/packages/sdk/src/resource-lease-owner-node.mjs +68 -0
- package/bundles/sui-ledger/dist/packages/sdk/src/resource-lease.mjs +143 -0
- package/bundles/sui-ledger/dist/packages/sdk/src/runtime.mjs +643 -0
- package/bundles/sui-ledger/dist/preferences-context.mjs +21 -0
- package/bundles/sui-ledger/dist/remote-write-policy.mjs +51 -0
- package/bundles/sui-ledger/dist/routes/finance-api.mjs +380 -0
- package/bundles/sui-ledger/dist/session/attachment-ownership.mjs +53 -0
- package/bundles/sui-ledger/dist/session/call-context.mjs +14 -0
- package/bundles/sui-ledger/dist/session/source-ports.mjs +74 -0
- package/bundles/sui-ledger/dist/storage/business-runtime.mjs +116 -0
- package/bundles/sui-ledger/dist/storage/maintenance-http.mjs +159 -0
- package/bundles/sui-ledger/dist/storage/paths.mjs +15 -0
- package/bundles/sui-ledger/dist/style.css +15416 -0
- package/bundles/sui-ledger/icon.svg +1 -0
- package/bundles/sui-ledger/locale/en.json +6 -0
- package/bundles/sui-ledger/locale/zh-CN.json +6 -0
- package/cordis.patch.yml +4 -0
- package/package.json +111 -3
|
@@ -0,0 +1,1523 @@
|
|
|
1
|
+
import { financialDateRange } from "../../finance/src/date-range.mjs";
|
|
2
|
+
import { queryMetadataValues } from "../../finance/src/metadata-query.mjs";
|
|
3
|
+
import { auditHash, changedBusinessFields, transactionEvidenceHash, transactionSemanticHash, transactionSnapshot } from "../../finance/src/transactions/audit.mjs";
|
|
4
|
+
import { repairedSourceAccountId, resolveStatisticsAccountIds, transactionIncomeExpense } from "../../finance/src/transactions/statistics.mjs";
|
|
5
|
+
import "../../finance/src/index.mjs";
|
|
6
|
+
import { SqliteExchangeRateStore, migrateExchangeRateSnapshots } from "./exchange-rates.mjs";
|
|
7
|
+
import { CheckpointHistoryStore } from "./checkpoint-history.mjs";
|
|
8
|
+
//#region ../../packages/local-store/src/database.ts
|
|
9
|
+
var LedgerDatabase = class {
|
|
10
|
+
db;
|
|
11
|
+
exchangeRates;
|
|
12
|
+
checkpointHistory;
|
|
13
|
+
constructor(db, prepared = false) {
|
|
14
|
+
this.db = db;
|
|
15
|
+
this.checkpointHistory = new CheckpointHistoryStore(db);
|
|
16
|
+
this.db.exec(prepared ? "PRAGMA foreign_keys = ON; PRAGMA busy_timeout = 50;" : "PRAGMA journal_mode = WAL; PRAGMA foreign_keys = ON; PRAGMA busy_timeout = 5000;");
|
|
17
|
+
try {
|
|
18
|
+
if (!prepared) this.migrate();
|
|
19
|
+
this.exchangeRates = new SqliteExchangeRateStore(db, false);
|
|
20
|
+
} catch (error) {
|
|
21
|
+
db.close();
|
|
22
|
+
throw error;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
close() {
|
|
26
|
+
this.db.close();
|
|
27
|
+
}
|
|
28
|
+
migrate() {
|
|
29
|
+
this.db.exec(`
|
|
30
|
+
CREATE TABLE IF NOT EXISTS books (
|
|
31
|
+
id TEXT PRIMARY KEY,
|
|
32
|
+
name TEXT NOT NULL,
|
|
33
|
+
updated_at TEXT NOT NULL
|
|
34
|
+
);
|
|
35
|
+
CREATE TABLE IF NOT EXISTS metadata (
|
|
36
|
+
book_id TEXT NOT NULL,
|
|
37
|
+
kind TEXT NOT NULL,
|
|
38
|
+
id TEXT NOT NULL,
|
|
39
|
+
name TEXT NOT NULL,
|
|
40
|
+
extra_json TEXT,
|
|
41
|
+
updated_at TEXT NOT NULL,
|
|
42
|
+
PRIMARY KEY (book_id, kind, id)
|
|
43
|
+
);
|
|
44
|
+
CREATE TABLE IF NOT EXISTS transactions (
|
|
45
|
+
book_id TEXT NOT NULL,
|
|
46
|
+
remote_id TEXT NOT NULL,
|
|
47
|
+
occurred_at TEXT NOT NULL,
|
|
48
|
+
type TEXT NOT NULL,
|
|
49
|
+
amount_cents INTEGER NOT NULL,
|
|
50
|
+
content_hash TEXT NOT NULL,
|
|
51
|
+
data_json TEXT NOT NULL,
|
|
52
|
+
memo TEXT,
|
|
53
|
+
updated_at TEXT NOT NULL,
|
|
54
|
+
observed_at TEXT,
|
|
55
|
+
sync_run_id INTEGER REFERENCES sync_runs(id),
|
|
56
|
+
PRIMARY KEY (book_id, remote_id)
|
|
57
|
+
);
|
|
58
|
+
CREATE INDEX IF NOT EXISTS idx_transactions_date ON transactions(book_id, occurred_at);
|
|
59
|
+
CREATE INDEX IF NOT EXISTS idx_transactions_hash ON transactions(book_id, content_hash);
|
|
60
|
+
CREATE TABLE IF NOT EXISTS sync_runs (
|
|
61
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
62
|
+
book_id TEXT NOT NULL,
|
|
63
|
+
mode TEXT NOT NULL,
|
|
64
|
+
started_at TEXT NOT NULL,
|
|
65
|
+
completed_at TEXT,
|
|
66
|
+
status TEXT NOT NULL,
|
|
67
|
+
message TEXT
|
|
68
|
+
);
|
|
69
|
+
CREATE TABLE IF NOT EXISTS sync_scopes (
|
|
70
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
71
|
+
sync_run_id INTEGER NOT NULL REFERENCES sync_runs(id),
|
|
72
|
+
book_id TEXT NOT NULL,
|
|
73
|
+
kind TEXT NOT NULL CHECK (kind IN ('complete_period', 'targeted_transaction')),
|
|
74
|
+
begin_at TEXT,
|
|
75
|
+
end_at TEXT,
|
|
76
|
+
remote_id TEXT,
|
|
77
|
+
remote_count INTEGER NOT NULL,
|
|
78
|
+
page_count INTEGER NOT NULL,
|
|
79
|
+
completed_at TEXT NOT NULL
|
|
80
|
+
);
|
|
81
|
+
CREATE INDEX IF NOT EXISTS idx_sync_scopes_book_range
|
|
82
|
+
ON sync_scopes(book_id, kind, begin_at, end_at, completed_at);
|
|
83
|
+
CREATE TABLE IF NOT EXISTS write_receipts (
|
|
84
|
+
book_id TEXT NOT NULL,
|
|
85
|
+
operation_key TEXT NOT NULL,
|
|
86
|
+
operation TEXT NOT NULL CHECK (operation IN ('create', 'update', 'delete')),
|
|
87
|
+
request_hash TEXT NOT NULL,
|
|
88
|
+
text_protocol_version TEXT,
|
|
89
|
+
memo_policy_version TEXT,
|
|
90
|
+
status TEXT NOT NULL CHECK (status IN ('prepared', 'submitting', 'verified', 'uncertain', 'failed', 'remote_deleted')),
|
|
91
|
+
baseline_remote_ids_json TEXT NOT NULL,
|
|
92
|
+
remote_id TEXT,
|
|
93
|
+
message TEXT,
|
|
94
|
+
deleted_observed_at TEXT,
|
|
95
|
+
created_at TEXT NOT NULL,
|
|
96
|
+
updated_at TEXT NOT NULL,
|
|
97
|
+
PRIMARY KEY (book_id, operation_key)
|
|
98
|
+
);
|
|
99
|
+
CREATE INDEX IF NOT EXISTS idx_write_receipts_remote_id ON write_receipts(book_id, remote_id);
|
|
100
|
+
CREATE TABLE IF NOT EXISTS write_leases (
|
|
101
|
+
scope TEXT PRIMARY KEY CHECK (scope = 'global'),
|
|
102
|
+
owner_id TEXT NOT NULL,
|
|
103
|
+
expires_at TEXT NOT NULL,
|
|
104
|
+
updated_at TEXT NOT NULL
|
|
105
|
+
);
|
|
106
|
+
CREATE TABLE IF NOT EXISTS schema_migrations (
|
|
107
|
+
version TEXT PRIMARY KEY,
|
|
108
|
+
applied_at TEXT NOT NULL,
|
|
109
|
+
checksum TEXT NOT NULL
|
|
110
|
+
);
|
|
111
|
+
DROP TABLE IF EXISTS import_batches;
|
|
112
|
+
DROP TABLE IF EXISTS account_snapshots;
|
|
113
|
+
DELETE FROM schema_migrations WHERE version = '003_account_snapshots';
|
|
114
|
+
`);
|
|
115
|
+
this.migrateLedgerWorkflowFacts();
|
|
116
|
+
this.checkpointHistory.migrate();
|
|
117
|
+
this.migrateWriteReceipts();
|
|
118
|
+
this.addColumnIfMissing("write_receipts", "acknowledged_at", "TEXT");
|
|
119
|
+
this.addColumnIfMissing("write_receipts", "text_protocol_version", "TEXT");
|
|
120
|
+
this.addColumnIfMissing("write_receipts", "memo_policy_version", "TEXT");
|
|
121
|
+
this.addColumnIfMissing("transactions", "observed_at", "TEXT");
|
|
122
|
+
this.addColumnIfMissing("transactions", "sync_run_id", "INTEGER REFERENCES sync_runs(id)");
|
|
123
|
+
this.db.exec("UPDATE transactions SET observed_at=updated_at WHERE observed_at IS NULL;");
|
|
124
|
+
this.migrateAuditHistory();
|
|
125
|
+
this.migrateInitiatorLabel();
|
|
126
|
+
migrateExchangeRateSnapshots(this.db);
|
|
127
|
+
this.migrateCategoryTypeObservations();
|
|
128
|
+
}
|
|
129
|
+
migrateLedgerWorkflowFacts() {
|
|
130
|
+
this.db.exec(`
|
|
131
|
+
CREATE TABLE IF NOT EXISTS ledger_book_state (
|
|
132
|
+
book_id TEXT PRIMARY KEY,
|
|
133
|
+
revision INTEGER NOT NULL CHECK(revision > 0),
|
|
134
|
+
timezone TEXT NOT NULL,
|
|
135
|
+
last_stable_observed_at TEXT,
|
|
136
|
+
updated_at TEXT NOT NULL
|
|
137
|
+
);
|
|
138
|
+
CREATE TABLE IF NOT EXISTS active_checkpoints (
|
|
139
|
+
id TEXT PRIMARY KEY,
|
|
140
|
+
book_id TEXT NOT NULL,
|
|
141
|
+
account_id TEXT NOT NULL,
|
|
142
|
+
revision INTEGER NOT NULL CHECK(revision > 0),
|
|
143
|
+
balance_cents INTEGER NOT NULL,
|
|
144
|
+
currency TEXT NOT NULL,
|
|
145
|
+
cutoff TEXT NOT NULL,
|
|
146
|
+
last_stable_sync_at TEXT NOT NULL,
|
|
147
|
+
ledger_revision INTEGER NOT NULL,
|
|
148
|
+
timezone TEXT NOT NULL,
|
|
149
|
+
created_by TEXT NOT NULL,
|
|
150
|
+
created_at TEXT NOT NULL,
|
|
151
|
+
UNIQUE(book_id,account_id)
|
|
152
|
+
);
|
|
153
|
+
CREATE TABLE IF NOT EXISTS checkpoint_audit_events (
|
|
154
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
155
|
+
event_type TEXT NOT NULL CHECK(event_type IN ('CheckpointCreated','CheckpointDeleted','CommitCheckpointOverride')),
|
|
156
|
+
book_id TEXT NOT NULL,
|
|
157
|
+
account_id TEXT NOT NULL,
|
|
158
|
+
checkpoint_id TEXT NOT NULL,
|
|
159
|
+
checkpoint_revision INTEGER NOT NULL,
|
|
160
|
+
commit_id TEXT,
|
|
161
|
+
operations_hash TEXT,
|
|
162
|
+
deviation_cents INTEGER,
|
|
163
|
+
authority TEXT NOT NULL,
|
|
164
|
+
occurred_at TEXT NOT NULL
|
|
165
|
+
);
|
|
166
|
+
CREATE INDEX IF NOT EXISTS idx_checkpoint_audit_book ON checkpoint_audit_events(book_id,id);
|
|
167
|
+
CREATE TRIGGER IF NOT EXISTS checkpoint_audit_events_no_update
|
|
168
|
+
BEFORE UPDATE ON checkpoint_audit_events BEGIN SELECT RAISE(ABORT,'checkpoint audit is immutable'); END;
|
|
169
|
+
CREATE TRIGGER IF NOT EXISTS checkpoint_audit_events_no_delete
|
|
170
|
+
BEFORE DELETE ON checkpoint_audit_events BEGIN SELECT RAISE(ABORT,'checkpoint audit is immutable'); END;
|
|
171
|
+
`);
|
|
172
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
173
|
+
this.db.prepare(`INSERT OR IGNORE INTO ledger_book_state(book_id,revision,timezone,last_stable_observed_at,updated_at)
|
|
174
|
+
SELECT id,1,'Asia/Shanghai',NULL,? FROM books`).run(now);
|
|
175
|
+
}
|
|
176
|
+
getExchangeRateSnapshot(provider, requestedDate) {
|
|
177
|
+
return this.exchangeRates.getExchangeRateSnapshot(provider, requestedDate);
|
|
178
|
+
}
|
|
179
|
+
getExchangeRateSnapshotForDate(provider, rateDate) {
|
|
180
|
+
return this.exchangeRates.getExchangeRateSnapshotForDate(provider, rateDate);
|
|
181
|
+
}
|
|
182
|
+
countExchangeRateSnapshots(provider) {
|
|
183
|
+
return this.exchangeRates.countExchangeRateSnapshots(provider);
|
|
184
|
+
}
|
|
185
|
+
appendExchangeRateSnapshot(snapshot) {
|
|
186
|
+
return this.exchangeRates.appendExchangeRateSnapshot(snapshot);
|
|
187
|
+
}
|
|
188
|
+
acquireExchangeRateRefreshLease(lease, now) {
|
|
189
|
+
return this.exchangeRates.acquireExchangeRateRefreshLease(lease, now);
|
|
190
|
+
}
|
|
191
|
+
releaseExchangeRateRefreshLease(provider, rateDate, slotKey, ownerId) {
|
|
192
|
+
this.exchangeRates.releaseExchangeRateRefreshLease(provider, rateDate, slotKey, ownerId);
|
|
193
|
+
}
|
|
194
|
+
migrateAuditHistory() {
|
|
195
|
+
this.db.exec(`
|
|
196
|
+
CREATE TABLE IF NOT EXISTS transaction_versions (
|
|
197
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
198
|
+
book_id TEXT NOT NULL,
|
|
199
|
+
remote_id TEXT NOT NULL,
|
|
200
|
+
semantic_hash TEXT NOT NULL,
|
|
201
|
+
evidence_hash TEXT NOT NULL,
|
|
202
|
+
snapshot_json TEXT NOT NULL,
|
|
203
|
+
raw_source_json TEXT,
|
|
204
|
+
observed_at TEXT NOT NULL,
|
|
205
|
+
recorded_at TEXT NOT NULL,
|
|
206
|
+
sync_run_id INTEGER REFERENCES sync_runs(id)
|
|
207
|
+
);
|
|
208
|
+
CREATE INDEX IF NOT EXISTS idx_transaction_versions_remote
|
|
209
|
+
ON transaction_versions(book_id, remote_id, id);
|
|
210
|
+
CREATE TABLE IF NOT EXISTS audit_events (
|
|
211
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
212
|
+
book_id TEXT NOT NULL,
|
|
213
|
+
remote_id TEXT,
|
|
214
|
+
operation_key TEXT,
|
|
215
|
+
event_type TEXT NOT NULL CHECK (event_type IN (
|
|
216
|
+
'baseline_observed','created_observed','updated_observed','deleted_observed','reappeared_observed',
|
|
217
|
+
'write_state_baseline','write_prepared','write_submitting','write_verified','write_uncertain','write_failed','write_remote_deleted'
|
|
218
|
+
)),
|
|
219
|
+
observation_source TEXT NOT NULL CHECK (observation_source IN ('migration','recent_sync','full_sync','targeted_write_verification','write_receipt')),
|
|
220
|
+
initiator TEXT NOT NULL CHECK (initiator IN ('sui-ledger','unknown_remote','system')),
|
|
221
|
+
observed_at TEXT NOT NULL,
|
|
222
|
+
change_window_start_at TEXT,
|
|
223
|
+
before_version_id INTEGER REFERENCES transaction_versions(id),
|
|
224
|
+
after_version_id INTEGER REFERENCES transaction_versions(id),
|
|
225
|
+
changed_fields_json TEXT NOT NULL,
|
|
226
|
+
evidence_json TEXT NOT NULL,
|
|
227
|
+
sync_run_id INTEGER REFERENCES sync_runs(id),
|
|
228
|
+
previous_event_hash TEXT,
|
|
229
|
+
event_hash TEXT NOT NULL UNIQUE,
|
|
230
|
+
recorded_at TEXT NOT NULL
|
|
231
|
+
);
|
|
232
|
+
CREATE INDEX IF NOT EXISTS idx_audit_events_book_id ON audit_events(book_id,id);
|
|
233
|
+
CREATE INDEX IF NOT EXISTS idx_audit_events_remote_id ON audit_events(book_id,remote_id,id);
|
|
234
|
+
CREATE INDEX IF NOT EXISTS idx_audit_events_operation ON audit_events(book_id,operation_key,id);
|
|
235
|
+
CREATE TABLE IF NOT EXISTS audit_book_state (
|
|
236
|
+
book_id TEXT PRIMARY KEY,
|
|
237
|
+
activated_at TEXT NOT NULL,
|
|
238
|
+
baseline_completed_at TEXT,
|
|
239
|
+
baseline_history_start TEXT,
|
|
240
|
+
last_stable_observed_at TEXT,
|
|
241
|
+
last_event_id INTEGER REFERENCES audit_events(id),
|
|
242
|
+
last_event_hash TEXT
|
|
243
|
+
);
|
|
244
|
+
`);
|
|
245
|
+
const version = "001_transaction_audit";
|
|
246
|
+
const expectedChecksum = auditHash({
|
|
247
|
+
version,
|
|
248
|
+
auditFormatVersion: 1
|
|
249
|
+
});
|
|
250
|
+
const migrated = this.db.prepare("SELECT checksum FROM schema_migrations WHERE version=?").get(version);
|
|
251
|
+
if (migrated && migrated.checksum !== expectedChecksum) throw new Error(`Migration checksum mismatch: ${version}`);
|
|
252
|
+
if (!migrated) this.db.transaction(() => {
|
|
253
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
254
|
+
const rows = this.db.prepare("SELECT data_json,COALESCE(observed_at,updated_at) AS observed_at,sync_run_id FROM transactions ORDER BY book_id,remote_id").all();
|
|
255
|
+
for (const row of rows) {
|
|
256
|
+
const transaction = JSON.parse(row.data_json);
|
|
257
|
+
const versionId = this.insertTransactionVersion(transaction, row.observed_at, row.sync_run_id ?? void 0, now);
|
|
258
|
+
this.appendAuditEvent({
|
|
259
|
+
bookId: transaction.bookId,
|
|
260
|
+
remoteId: transaction.remoteId,
|
|
261
|
+
eventType: "baseline_observed",
|
|
262
|
+
observationSource: "migration",
|
|
263
|
+
initiator: "system",
|
|
264
|
+
observedAt: row.observed_at,
|
|
265
|
+
afterVersionId: versionId,
|
|
266
|
+
changedFields: [],
|
|
267
|
+
evidence: {
|
|
268
|
+
coverage: "preexisting_cache",
|
|
269
|
+
notRemoteCreation: true
|
|
270
|
+
},
|
|
271
|
+
...row.sync_run_id ? { syncRunId: row.sync_run_id } : {},
|
|
272
|
+
recordedAt: now
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
const receipts = this.db.prepare("SELECT * FROM write_receipts ORDER BY book_id,operation_key").all();
|
|
276
|
+
for (const receipt of receipts) this.appendWriteReceiptEvent(receipt, "write_state_baseline", receipt.updated_at, "migration");
|
|
277
|
+
this.db.prepare("INSERT INTO schema_migrations(version,applied_at,checksum) VALUES(?,?,?)").run(version, now, expectedChecksum);
|
|
278
|
+
})();
|
|
279
|
+
this.db.exec(`
|
|
280
|
+
CREATE TRIGGER IF NOT EXISTS transaction_versions_no_update
|
|
281
|
+
BEFORE UPDATE ON transaction_versions BEGIN SELECT RAISE(ABORT,'transaction_versions are immutable'); END;
|
|
282
|
+
CREATE TRIGGER IF NOT EXISTS transaction_versions_no_delete
|
|
283
|
+
BEFORE DELETE ON transaction_versions BEGIN SELECT RAISE(ABORT,'transaction_versions are immutable'); END;
|
|
284
|
+
CREATE TRIGGER IF NOT EXISTS audit_events_no_update
|
|
285
|
+
BEFORE UPDATE ON audit_events BEGIN SELECT RAISE(ABORT,'audit_events are immutable'); END;
|
|
286
|
+
CREATE TRIGGER IF NOT EXISTS audit_events_no_delete
|
|
287
|
+
BEFORE DELETE ON audit_events BEGIN SELECT RAISE(ABORT,'audit_events are immutable'); END;
|
|
288
|
+
`);
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* 004 · initiator 枚举值 'fagent' → 'sui-ledger'。
|
|
292
|
+
*
|
|
293
|
+
* initiator 参与事件哈希预像(computeEventHash),所以除了重建表换 CHECK
|
|
294
|
+
* 约束并改写存量行值,还必须按书重算整条哈希链并刷新 audit_book_state
|
|
295
|
+
* 头指针——否则 verifyAuditIntegrity 会报 EVENT_HASH_MISMATCH。重建期间
|
|
296
|
+
* 先摘掉不可变触发器、关掉外键(DROP 父表会触发隐式 DELETE 检查),
|
|
297
|
+
* 完成后恢复。
|
|
298
|
+
*/
|
|
299
|
+
migrateInitiatorLabel() {
|
|
300
|
+
const version = "004_initiator_label";
|
|
301
|
+
if (this.db.prepare("SELECT version FROM schema_migrations WHERE version=?").get(version)) return;
|
|
302
|
+
this.db.exec("DROP TRIGGER IF EXISTS audit_events_no_update; DROP TRIGGER IF EXISTS audit_events_no_delete;");
|
|
303
|
+
this.db.exec("PRAGMA foreign_keys = OFF;");
|
|
304
|
+
try {
|
|
305
|
+
this.db.transaction(() => {
|
|
306
|
+
this.db.exec(`
|
|
307
|
+
CREATE TABLE audit_events_rebuild (
|
|
308
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
309
|
+
book_id TEXT NOT NULL,
|
|
310
|
+
remote_id TEXT,
|
|
311
|
+
operation_key TEXT,
|
|
312
|
+
event_type TEXT NOT NULL CHECK (event_type IN (
|
|
313
|
+
'baseline_observed','created_observed','updated_observed','deleted_observed','reappeared_observed',
|
|
314
|
+
'write_state_baseline','write_prepared','write_submitting','write_verified','write_uncertain','write_failed','write_remote_deleted'
|
|
315
|
+
)),
|
|
316
|
+
observation_source TEXT NOT NULL CHECK (observation_source IN ('migration','recent_sync','full_sync','targeted_write_verification','write_receipt')),
|
|
317
|
+
initiator TEXT NOT NULL CHECK (initiator IN ('sui-ledger','unknown_remote','system')),
|
|
318
|
+
observed_at TEXT NOT NULL,
|
|
319
|
+
change_window_start_at TEXT,
|
|
320
|
+
before_version_id INTEGER REFERENCES transaction_versions(id),
|
|
321
|
+
after_version_id INTEGER REFERENCES transaction_versions(id),
|
|
322
|
+
changed_fields_json TEXT NOT NULL,
|
|
323
|
+
evidence_json TEXT NOT NULL,
|
|
324
|
+
sync_run_id INTEGER REFERENCES sync_runs(id),
|
|
325
|
+
previous_event_hash TEXT,
|
|
326
|
+
event_hash TEXT NOT NULL UNIQUE,
|
|
327
|
+
recorded_at TEXT NOT NULL
|
|
328
|
+
);
|
|
329
|
+
INSERT INTO audit_events_rebuild
|
|
330
|
+
SELECT id, book_id, remote_id, operation_key, event_type, observation_source,
|
|
331
|
+
CASE initiator WHEN 'fagent' THEN 'sui-ledger' ELSE initiator END,
|
|
332
|
+
observed_at, change_window_start_at, before_version_id, after_version_id,
|
|
333
|
+
changed_fields_json, evidence_json, sync_run_id, previous_event_hash, event_hash, recorded_at
|
|
334
|
+
FROM audit_events ORDER BY id;
|
|
335
|
+
DROP TABLE audit_events;
|
|
336
|
+
ALTER TABLE audit_events_rebuild RENAME TO audit_events;
|
|
337
|
+
CREATE INDEX IF NOT EXISTS idx_audit_events_book_id ON audit_events(book_id,id);
|
|
338
|
+
CREATE INDEX IF NOT EXISTS idx_audit_events_remote_id ON audit_events(book_id,remote_id,id);
|
|
339
|
+
CREATE INDEX IF NOT EXISTS idx_audit_events_operation ON audit_events(book_id,operation_key,id);
|
|
340
|
+
`);
|
|
341
|
+
const books = this.db.prepare("SELECT DISTINCT book_id FROM audit_events").all();
|
|
342
|
+
const rehash = this.db.prepare("UPDATE audit_events SET previous_event_hash=?, event_hash=? WHERE id=?");
|
|
343
|
+
for (const { book_id: bookId } of books) {
|
|
344
|
+
const events = this.db.prepare("SELECT * FROM audit_events WHERE book_id=? ORDER BY id").all(bookId);
|
|
345
|
+
let previousHash;
|
|
346
|
+
for (const event of events) {
|
|
347
|
+
const nextHash = this.computeEventHash(event, previousHash);
|
|
348
|
+
rehash.run(previousHash ?? null, nextHash, event.id);
|
|
349
|
+
previousHash = nextHash;
|
|
350
|
+
}
|
|
351
|
+
if (previousHash !== void 0) this.db.prepare("UPDATE audit_book_state SET last_event_id=(SELECT MAX(id) FROM audit_events WHERE book_id=?), last_event_hash=? WHERE book_id=?").run(bookId, previousHash, bookId);
|
|
352
|
+
}
|
|
353
|
+
this.db.prepare("INSERT INTO schema_migrations(version,applied_at,checksum) VALUES(?,?,?)").run(version, (/* @__PURE__ */ new Date()).toISOString(), version);
|
|
354
|
+
})();
|
|
355
|
+
} finally {
|
|
356
|
+
this.db.exec("PRAGMA foreign_keys = ON;");
|
|
357
|
+
}
|
|
358
|
+
this.db.exec(`
|
|
359
|
+
CREATE TRIGGER IF NOT EXISTS audit_events_no_update
|
|
360
|
+
BEFORE UPDATE ON audit_events BEGIN SELECT RAISE(ABORT,'audit_events are immutable'); END;
|
|
361
|
+
CREATE TRIGGER IF NOT EXISTS audit_events_no_delete
|
|
362
|
+
BEFORE DELETE ON audit_events BEGIN SELECT RAISE(ABORT,'audit_events are immutable'); END;
|
|
363
|
+
`);
|
|
364
|
+
}
|
|
365
|
+
addColumnIfMissing(table, column, definition) {
|
|
366
|
+
if (!this.db.prepare(`PRAGMA table_info(${table})`).all().some((item) => item.name === column)) this.db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition};`);
|
|
367
|
+
}
|
|
368
|
+
migrateCategoryTypeObservations() {
|
|
369
|
+
this.db.exec(`
|
|
370
|
+
CREATE TABLE IF NOT EXISTS category_type_observations (
|
|
371
|
+
book_id TEXT NOT NULL,
|
|
372
|
+
category_id TEXT NOT NULL,
|
|
373
|
+
parent_id TEXT,
|
|
374
|
+
observed_type TEXT NOT NULL CHECK (observed_type IN ('expense','income','transfer','unknown')) DEFAULT 'unknown',
|
|
375
|
+
created_at TEXT NOT NULL,
|
|
376
|
+
modified_at TEXT NOT NULL,
|
|
377
|
+
PRIMARY KEY (book_id, category_id)
|
|
378
|
+
);
|
|
379
|
+
`);
|
|
380
|
+
const version = "002_category_type_observations";
|
|
381
|
+
if (!this.db.prepare("SELECT version FROM schema_migrations WHERE version=?").get(version)) this.db.transaction(() => {
|
|
382
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
383
|
+
this.db.prepare(`
|
|
384
|
+
INSERT OR IGNORE INTO category_type_observations(book_id, category_id, parent_id, observed_type, created_at, modified_at)
|
|
385
|
+
SELECT book_id, id, json_extract(extra_json,'$.parentId'), 'unknown', ?, ?
|
|
386
|
+
FROM metadata WHERE kind='category'
|
|
387
|
+
`).run(now, now);
|
|
388
|
+
this.db.prepare(`
|
|
389
|
+
UPDATE category_type_observations
|
|
390
|
+
SET observed_type = subq.type, modified_at = ?
|
|
391
|
+
FROM (
|
|
392
|
+
SELECT book_id, json_extract(data_json,'$.categoryId') AS category_id,
|
|
393
|
+
MAX(type) AS type, COUNT(DISTINCT type) AS type_count
|
|
394
|
+
FROM transactions
|
|
395
|
+
WHERE type IN ('expense','income','transfer')
|
|
396
|
+
AND json_extract(data_json,'$.categoryId') IS NOT NULL
|
|
397
|
+
GROUP BY book_id, json_extract(data_json,'$.categoryId')
|
|
398
|
+
) subq
|
|
399
|
+
WHERE category_type_observations.book_id = subq.book_id
|
|
400
|
+
AND category_type_observations.category_id = subq.category_id
|
|
401
|
+
AND category_type_observations.observed_type = 'unknown'
|
|
402
|
+
AND subq.type_count = 1
|
|
403
|
+
`).run(now);
|
|
404
|
+
const bookIds = this.db.prepare("SELECT DISTINCT book_id FROM category_type_observations").all();
|
|
405
|
+
for (const { book_id } of bookIds) this.propagateCategoryTypesToParents(book_id, now);
|
|
406
|
+
this.db.prepare("INSERT INTO schema_migrations(version,applied_at,checksum) VALUES(?,?,?)").run(version, now, version);
|
|
407
|
+
})();
|
|
408
|
+
}
|
|
409
|
+
migrateWriteReceipts() {
|
|
410
|
+
const table = this.db.prepare("SELECT sql FROM sqlite_master WHERE type='table' AND name='write_receipts'").get();
|
|
411
|
+
if (!table) throw new Error("write_receipts migration failed to create the table");
|
|
412
|
+
if (!table.sql.includes("remote_deleted") || !table.sql.includes("'delete'")) {
|
|
413
|
+
const columns = (table.sql.includes("deleted_observed_at") ? "book_id,operation_key,operation,request_hash,status,baseline_remote_ids_json,remote_id,message,deleted_observed_at,created_at,updated_at" : "book_id,operation_key,operation,request_hash,status,baseline_remote_ids_json,remote_id,message,created_at,updated_at") + (table.sql.includes("text_protocol_version") ? ",text_protocol_version" : "") + (table.sql.includes("memo_policy_version") ? ",memo_policy_version" : "");
|
|
414
|
+
this.db.transaction(() => {
|
|
415
|
+
this.db.exec(`
|
|
416
|
+
ALTER TABLE write_receipts RENAME TO write_receipts_legacy;
|
|
417
|
+
CREATE TABLE write_receipts (
|
|
418
|
+
book_id TEXT NOT NULL,
|
|
419
|
+
operation_key TEXT NOT NULL,
|
|
420
|
+
operation TEXT NOT NULL CHECK (operation IN ('create', 'update', 'delete')),
|
|
421
|
+
request_hash TEXT NOT NULL,
|
|
422
|
+
text_protocol_version TEXT,
|
|
423
|
+
memo_policy_version TEXT,
|
|
424
|
+
status TEXT NOT NULL CHECK (status IN ('prepared', 'submitting', 'verified', 'uncertain', 'failed', 'remote_deleted')),
|
|
425
|
+
baseline_remote_ids_json TEXT NOT NULL,
|
|
426
|
+
remote_id TEXT,
|
|
427
|
+
message TEXT,
|
|
428
|
+
deleted_observed_at TEXT,
|
|
429
|
+
created_at TEXT NOT NULL,
|
|
430
|
+
updated_at TEXT NOT NULL,
|
|
431
|
+
PRIMARY KEY (book_id, operation_key)
|
|
432
|
+
);
|
|
433
|
+
INSERT INTO write_receipts(${columns})
|
|
434
|
+
SELECT ${columns} FROM write_receipts_legacy;
|
|
435
|
+
DROP TABLE write_receipts_legacy;
|
|
436
|
+
CREATE INDEX IF NOT EXISTS idx_write_receipts_remote_id ON write_receipts(book_id, remote_id);
|
|
437
|
+
`);
|
|
438
|
+
})();
|
|
439
|
+
} else this.addColumnIfMissing("write_receipts", "deleted_observed_at", "TEXT");
|
|
440
|
+
}
|
|
441
|
+
recordRemoteBooks(books, observedAt = (/* @__PURE__ */ new Date()).toISOString()) {
|
|
442
|
+
const statement = this.db.prepare("INSERT INTO books(id,name,updated_at) VALUES(?,?,?) ON CONFLICT(id) DO UPDATE SET name=excluded.name, updated_at=excluded.updated_at");
|
|
443
|
+
this.db.transaction(() => {
|
|
444
|
+
for (const book of books) {
|
|
445
|
+
statement.run(book.id, book.name, observedAt);
|
|
446
|
+
this.ensureLedgerBookState(book.id, observedAt);
|
|
447
|
+
}
|
|
448
|
+
})();
|
|
449
|
+
}
|
|
450
|
+
getLedgerBookState(bookId) {
|
|
451
|
+
this.ensureLedgerBookState(bookId, (/* @__PURE__ */ new Date()).toISOString());
|
|
452
|
+
return this.peekLedgerBookState(bookId);
|
|
453
|
+
}
|
|
454
|
+
/** Prompt assembly must never initialize ledger state as a side effect. */
|
|
455
|
+
peekLedgerBookState(bookId) {
|
|
456
|
+
const row = this.db.prepare("SELECT * FROM ledger_book_state WHERE book_id=?").get(bookId);
|
|
457
|
+
if (!row) return void 0;
|
|
458
|
+
return {
|
|
459
|
+
bookId: row.book_id,
|
|
460
|
+
revision: row.revision,
|
|
461
|
+
timezone: row.timezone,
|
|
462
|
+
...row.last_stable_observed_at ? { lastStableObservedAt: row.last_stable_observed_at } : {},
|
|
463
|
+
updatedAt: row.updated_at
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
setBookTimezone(bookId, timezone, now) {
|
|
467
|
+
assertIanaTimezone(timezone);
|
|
468
|
+
this.ensureLedgerBookState(bookId, now);
|
|
469
|
+
this.db.prepare("UPDATE ledger_book_state SET timezone=?,revision=revision+1,updated_at=? WHERE book_id=?").run(timezone, now, bookId);
|
|
470
|
+
return this.getLedgerBookState(bookId);
|
|
471
|
+
}
|
|
472
|
+
listActiveCheckpoints(bookId) {
|
|
473
|
+
return this.db.prepare(`SELECT a.*,json_extract(s.snapshot_json,'$.balanceBasis') AS balance_basis
|
|
474
|
+
FROM active_checkpoints a LEFT JOIN checkpoint_snapshots s ON s.id=a.id WHERE a.book_id=? ORDER BY a.account_id,a.id`).all(bookId).map((row) => ({
|
|
475
|
+
...mapCheckpointRow(row),
|
|
476
|
+
balanceBasis: row.balance_basis === "instant" ? "instant" : "day"
|
|
477
|
+
}));
|
|
478
|
+
}
|
|
479
|
+
listCheckpointHistory(bookId, accountId, offset, limit) {
|
|
480
|
+
return this.checkpointHistory.list(bookId, accountId, offset, limit);
|
|
481
|
+
}
|
|
482
|
+
checkpointConfirmation(confirmationId) {
|
|
483
|
+
return this.checkpointHistory.receipt(confirmationId);
|
|
484
|
+
}
|
|
485
|
+
listCheckpointAudit(bookId) {
|
|
486
|
+
return this.db.prepare("SELECT * FROM checkpoint_audit_events WHERE book_id=? ORDER BY id").all(bookId).map(mapCheckpointAuditRow);
|
|
487
|
+
}
|
|
488
|
+
createCheckpoint(input) {
|
|
489
|
+
assertIso(input.now, "now");
|
|
490
|
+
assertIso(input.cutoff, "cutoff");
|
|
491
|
+
assertIso(input.lastStableSyncAt, "lastStableSyncAt");
|
|
492
|
+
if (input.cutoff !== input.now) throw new Error("checkpoint_historical_cutoff_not_allowed");
|
|
493
|
+
return this.db.transaction(() => {
|
|
494
|
+
if (input.confirmationId) {
|
|
495
|
+
const receipt = this.checkpointHistory.receipt(input.confirmationId);
|
|
496
|
+
if (receipt) {
|
|
497
|
+
if (!input.requestHash || receipt.requestHash !== input.requestHash) throw new Error("finance_checkpoint_request_conflict");
|
|
498
|
+
return receipt.checkpoint;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
const state = this.getLedgerBookState(input.bookId);
|
|
502
|
+
if (state.revision !== input.ledgerRevision || state.timezone !== input.timezone || state.lastStableObservedAt !== input.lastStableSyncAt) throw new Error("checkpoint_ledger_revision_conflict");
|
|
503
|
+
if (Date.parse(input.now) - Date.parse(input.lastStableSyncAt) > 18e5) throw new Error("checkpoint_sync_stale");
|
|
504
|
+
const active = this.db.prepare("SELECT id,revision FROM active_checkpoints WHERE book_id=? AND account_id=?").get(input.bookId, input.accountId);
|
|
505
|
+
if (input.expectedCheckpoint === void 0 && active) throw new Error("checkpoint_already_active");
|
|
506
|
+
if (input.expectedCheckpoint !== void 0 && (active?.id !== input.expectedCheckpoint?.id || active?.revision !== input.expectedCheckpoint?.revision)) throw new Error("finance_checkpoint_revision_conflict");
|
|
507
|
+
if (active) this.db.prepare("DELETE FROM active_checkpoints WHERE id=?").run(active.id);
|
|
508
|
+
const revision = (this.db.prepare(`SELECT MAX(checkpoint_revision) AS revision FROM checkpoint_audit_events
|
|
509
|
+
WHERE book_id=? AND account_id=?`).get(input.bookId, input.accountId).revision ?? 0) + 1;
|
|
510
|
+
const checkpoint = {
|
|
511
|
+
id: input.id,
|
|
512
|
+
bookId: input.bookId,
|
|
513
|
+
accountId: input.accountId,
|
|
514
|
+
revision,
|
|
515
|
+
balanceCents: input.balanceCents,
|
|
516
|
+
currency: input.currency,
|
|
517
|
+
cutoff: input.cutoff,
|
|
518
|
+
lastStableSyncAt: input.lastStableSyncAt,
|
|
519
|
+
ledgerRevision: input.ledgerRevision,
|
|
520
|
+
timezone: input.timezone,
|
|
521
|
+
createdBy: input.createdBy,
|
|
522
|
+
createdAt: input.now,
|
|
523
|
+
balanceBasis: input.balanceBasis ?? "day"
|
|
524
|
+
};
|
|
525
|
+
this.checkpointHistory.save(checkpoint, input.confirmationId, input.requestHash);
|
|
526
|
+
this.db.prepare(`INSERT INTO active_checkpoints(
|
|
527
|
+
id,book_id,account_id,revision,balance_cents,currency,cutoff,last_stable_sync_at,ledger_revision,timezone,created_by,created_at
|
|
528
|
+
) VALUES(?,?,?,?,?,?,?,?,?,?,?,?)`).run(input.id, input.bookId, input.accountId, revision, input.balanceCents, input.currency, input.cutoff, input.lastStableSyncAt, input.ledgerRevision, input.timezone, input.createdBy, input.now);
|
|
529
|
+
this.db.prepare(`INSERT INTO checkpoint_audit_events(
|
|
530
|
+
event_type,book_id,account_id,checkpoint_id,checkpoint_revision,authority,occurred_at
|
|
531
|
+
) VALUES('CheckpointCreated',?,?,?,?,?,?)`).run(input.bookId, input.accountId, input.id, revision, input.createdBy, input.now);
|
|
532
|
+
return checkpoint;
|
|
533
|
+
})();
|
|
534
|
+
}
|
|
535
|
+
deleteCheckpoint(input) {
|
|
536
|
+
assertIso(input.now, "now");
|
|
537
|
+
this.db.transaction(() => {
|
|
538
|
+
const row = this.db.prepare("SELECT * FROM active_checkpoints WHERE id=?").get(input.checkpointId);
|
|
539
|
+
if (!row) throw new Error("checkpoint_not_found");
|
|
540
|
+
const checkpoint = mapCheckpointRow(row);
|
|
541
|
+
if (checkpoint.revision !== input.expectedRevision) throw new Error("checkpoint_revision_conflict");
|
|
542
|
+
this.db.prepare("DELETE FROM active_checkpoints WHERE id=? AND revision=?").run(input.checkpointId, input.expectedRevision);
|
|
543
|
+
this.db.prepare(`INSERT INTO checkpoint_audit_events(
|
|
544
|
+
event_type,book_id,account_id,checkpoint_id,checkpoint_revision,authority,occurred_at
|
|
545
|
+
) VALUES('CheckpointDeleted',?,?,?,?,?,?)`).run(checkpoint.bookId, checkpoint.accountId, checkpoint.id, checkpoint.revision, input.authority, input.now);
|
|
546
|
+
})();
|
|
547
|
+
}
|
|
548
|
+
appendCheckpointOverride(input) {
|
|
549
|
+
assertIso(input.now, "now");
|
|
550
|
+
const checkpointRow = this.db.prepare("SELECT * FROM active_checkpoints WHERE id=? AND revision=?").get(input.checkpointId, input.checkpointRevision);
|
|
551
|
+
if (!checkpointRow) throw new Error("checkpoint_revision_conflict");
|
|
552
|
+
const checkpoint = mapCheckpointRow(checkpointRow);
|
|
553
|
+
const result = this.db.prepare(`INSERT INTO checkpoint_audit_events(
|
|
554
|
+
event_type,book_id,account_id,checkpoint_id,checkpoint_revision,commit_id,operations_hash,deviation_cents,authority,occurred_at
|
|
555
|
+
) VALUES('CommitCheckpointOverride',?,?,?,?,?,?,?,?,?)`).run(checkpoint.bookId, checkpoint.accountId, checkpoint.id, checkpoint.revision, input.commitId, input.operationsHash, input.deviationCents, input.authority, input.now);
|
|
556
|
+
return this.listCheckpointAudit(checkpoint.bookId).find((event) => event.id === Number(result.lastInsertRowid));
|
|
557
|
+
}
|
|
558
|
+
ensureLedgerBookState(bookId, now) {
|
|
559
|
+
this.db.prepare(`INSERT OR IGNORE INTO ledger_book_state(book_id,revision,timezone,last_stable_observed_at,updated_at)
|
|
560
|
+
VALUES(?,1,'Asia/Shanghai',NULL,?)`).run(bookId, now);
|
|
561
|
+
}
|
|
562
|
+
advanceLedgerRevision(bookId, observedAt, stable) {
|
|
563
|
+
this.ensureLedgerBookState(bookId, observedAt);
|
|
564
|
+
this.db.prepare(`UPDATE ledger_book_state SET revision=revision+1,
|
|
565
|
+
last_stable_observed_at=CASE WHEN ?=1 THEN ? ELSE last_stable_observed_at END,updated_at=? WHERE book_id=?`).run(stable ? 1 : 0, observedAt, observedAt, bookId);
|
|
566
|
+
}
|
|
567
|
+
/** @deprecated Remote projection writes must go through SyncService. */
|
|
568
|
+
upsertBooks(books) {
|
|
569
|
+
this.recordRemoteBooks(books);
|
|
570
|
+
}
|
|
571
|
+
hasBook(bookId) {
|
|
572
|
+
return Boolean(this.db.prepare("SELECT 1 AS present FROM books WHERE id=? LIMIT 1").get(bookId));
|
|
573
|
+
}
|
|
574
|
+
listBooks() {
|
|
575
|
+
return this.db.prepare("SELECT id,name FROM books ORDER BY name").all();
|
|
576
|
+
}
|
|
577
|
+
replaceRemoteMetadata(bookId, metadata, observedAt = (/* @__PURE__ */ new Date()).toISOString()) {
|
|
578
|
+
const remove = this.db.prepare("DELETE FROM metadata WHERE book_id=?");
|
|
579
|
+
const insert = this.db.prepare("INSERT INTO metadata(book_id,kind,id,name,extra_json,updated_at) VALUES(?,?,?,?,?,?)");
|
|
580
|
+
const insertCatObs = this.db.prepare(`
|
|
581
|
+
INSERT OR IGNORE INTO category_type_observations(book_id, category_id, parent_id, observed_type, created_at, modified_at)
|
|
582
|
+
VALUES(?, ?, ?, 'unknown', ?, ?)
|
|
583
|
+
`);
|
|
584
|
+
const resetIfParentChanged = this.db.prepare(`
|
|
585
|
+
UPDATE category_type_observations
|
|
586
|
+
SET parent_id=?, observed_type='unknown', modified_at=?
|
|
587
|
+
WHERE book_id=? AND category_id=? AND parent_id IS NOT ?
|
|
588
|
+
`);
|
|
589
|
+
const deleteStale = this.db.prepare(`
|
|
590
|
+
DELETE FROM category_type_observations
|
|
591
|
+
WHERE book_id=? AND category_id NOT IN (SELECT id FROM metadata WHERE book_id=? AND kind='category')
|
|
592
|
+
`);
|
|
593
|
+
this.db.transaction(() => {
|
|
594
|
+
remove.run(bookId);
|
|
595
|
+
const entries = [
|
|
596
|
+
["category", metadata.categories],
|
|
597
|
+
["account", metadata.accounts],
|
|
598
|
+
["store", metadata.stores],
|
|
599
|
+
["project", metadata.projects],
|
|
600
|
+
["member", metadata.members]
|
|
601
|
+
];
|
|
602
|
+
for (const [kind, values] of entries) for (const value of values) {
|
|
603
|
+
const { id, name, ...extra } = value;
|
|
604
|
+
insert.run(bookId, kind, id, name, Object.keys(extra).length ? JSON.stringify(extra) : null, observedAt);
|
|
605
|
+
if (kind === "category") {
|
|
606
|
+
const parentId = extra.parentId ?? null;
|
|
607
|
+
insertCatObs.run(bookId, id, parentId, observedAt, observedAt);
|
|
608
|
+
resetIfParentChanged.run(parentId, observedAt, bookId, id, parentId);
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
deleteStale.run(bookId, bookId);
|
|
612
|
+
this.advanceLedgerRevision(bookId, observedAt, false);
|
|
613
|
+
})();
|
|
614
|
+
}
|
|
615
|
+
/** @deprecated Remote projection writes must go through SyncService. */
|
|
616
|
+
replaceMetadata(bookId, metadata) {
|
|
617
|
+
this.replaceRemoteMetadata(bookId, metadata);
|
|
618
|
+
}
|
|
619
|
+
getMetadata(bookId) {
|
|
620
|
+
const rows = this.db.prepare("SELECT kind,id,name,extra_json FROM metadata WHERE book_id=? ORDER BY kind,name").all(bookId);
|
|
621
|
+
const metadata = {
|
|
622
|
+
categories: [],
|
|
623
|
+
accounts: [],
|
|
624
|
+
stores: [],
|
|
625
|
+
projects: [],
|
|
626
|
+
members: []
|
|
627
|
+
};
|
|
628
|
+
for (const row of rows) {
|
|
629
|
+
const extra = row.extra_json ? JSON.parse(row.extra_json) : {};
|
|
630
|
+
const value = {
|
|
631
|
+
id: row.id,
|
|
632
|
+
name: row.name,
|
|
633
|
+
...extra
|
|
634
|
+
};
|
|
635
|
+
if (row.kind === "category") metadata.categories.push(value);
|
|
636
|
+
else if (row.kind === "account") metadata.accounts.push(value);
|
|
637
|
+
else if (row.kind === "store") metadata.stores.push(value);
|
|
638
|
+
else if (row.kind === "project") metadata.projects.push(value);
|
|
639
|
+
else if (row.kind === "member") metadata.members.push(value);
|
|
640
|
+
}
|
|
641
|
+
return metadata;
|
|
642
|
+
}
|
|
643
|
+
queryMetadata(input) {
|
|
644
|
+
const kind = {
|
|
645
|
+
accounts: "account",
|
|
646
|
+
categories: "category",
|
|
647
|
+
stores: "store",
|
|
648
|
+
projects: "project",
|
|
649
|
+
members: "member"
|
|
650
|
+
}[input.resource];
|
|
651
|
+
if (!kind) throw new Error("finance_metadata_resource_unknown");
|
|
652
|
+
const page = queryMetadataValues(this.getMetadata(input.bookId), input);
|
|
653
|
+
const observed = this.db.prepare("SELECT MAX(updated_at) AS observed_at FROM metadata WHERE book_id=? AND kind=?").get(input.bookId, kind);
|
|
654
|
+
return {
|
|
655
|
+
...page,
|
|
656
|
+
...observed.observed_at ? { observedAt: observed.observed_at } : {}
|
|
657
|
+
};
|
|
658
|
+
}
|
|
659
|
+
applyRemoteTransaction(runId, transaction, observedAt, context = {}) {
|
|
660
|
+
return this.db.transaction(() => {
|
|
661
|
+
const changed = this.writeObservedTransactions([transaction], runId, observedAt, {
|
|
662
|
+
observationSource: context.source ?? "targeted_write_verification",
|
|
663
|
+
initiator: context.initiator ?? "unknown_remote",
|
|
664
|
+
...context.operationKey ? { operationKey: context.operationKey } : {}
|
|
665
|
+
});
|
|
666
|
+
this.db.prepare(`
|
|
667
|
+
INSERT INTO sync_scopes(sync_run_id,book_id,kind,remote_id,remote_count,page_count,completed_at)
|
|
668
|
+
VALUES(?,?,?,?,1,1,?)
|
|
669
|
+
`).run(runId, transaction.bookId, "targeted_transaction", transaction.remoteId, observedAt);
|
|
670
|
+
this.advanceLedgerRevision(transaction.bookId, observedAt, false);
|
|
671
|
+
return changed;
|
|
672
|
+
})();
|
|
673
|
+
}
|
|
674
|
+
applyVerifiedTransactionDeletion(runId, bookId, remoteId, observedAt) {
|
|
675
|
+
return this.db.transaction(() => {
|
|
676
|
+
const receipts = this.receiptsForRemoteId(bookId, remoteId);
|
|
677
|
+
const deletion = receipts.find((receipt) => receipt.operation === "delete" && receipt.status === "verified");
|
|
678
|
+
if (!deletion) throw new Error("verified_delete_receipt_required");
|
|
679
|
+
const current = this.getTransaction(bookId, remoteId);
|
|
680
|
+
if (!current) return 0;
|
|
681
|
+
if (current.contentHash !== deletion.request_hash) throw new Error("verified_delete_projection_changed");
|
|
682
|
+
this.recordDeletedObservation(bookId, remoteId, runId, observedAt, "targeted_write_verification", { receiptVerified: true }, {
|
|
683
|
+
initiator: "sui-ledger",
|
|
684
|
+
operationKey: deletion.operation_key
|
|
685
|
+
});
|
|
686
|
+
const removed = Number(this.db.prepare("DELETE FROM transactions WHERE book_id=? AND remote_id=?").run(bookId, remoteId).changes);
|
|
687
|
+
this.db.prepare(`UPDATE write_receipts SET status='remote_deleted',deleted_observed_at=?,updated_at=?
|
|
688
|
+
WHERE book_id=? AND remote_id=? AND status!='remote_deleted'`).run(observedAt, observedAt, bookId, remoteId);
|
|
689
|
+
for (const receipt of receipts) this.appendWriteReceiptEvent({
|
|
690
|
+
...receipt,
|
|
691
|
+
status: "remote_deleted",
|
|
692
|
+
deleted_observed_at: observedAt,
|
|
693
|
+
updated_at: observedAt
|
|
694
|
+
}, "write_remote_deleted", observedAt);
|
|
695
|
+
this.advanceLedgerRevision(bookId, observedAt, false);
|
|
696
|
+
return removed;
|
|
697
|
+
})();
|
|
698
|
+
}
|
|
699
|
+
replaceRemoteTransactionScope(runId, scope) {
|
|
700
|
+
const unique = [...new Map(scope.value.map((transaction) => [transaction.remoteId, transaction])).values()];
|
|
701
|
+
if (unique.some((transaction) => transaction.bookId !== scope.bookId)) throw new Error("Remote transaction scope contains another book");
|
|
702
|
+
const range = financialDateRange(scope.beginDate, scope.endDate, this.getLedgerBookState(scope.bookId).timezone);
|
|
703
|
+
return this.db.transaction(() => {
|
|
704
|
+
const changed = this.writeObservedTransactions(unique, runId, scope.observedAt, {
|
|
705
|
+
observationSource: "recent_sync",
|
|
706
|
+
initiator: "unknown_remote"
|
|
707
|
+
});
|
|
708
|
+
const existing = this.db.prepare("SELECT remote_id FROM transactions WHERE book_id=? AND julianday(occurred_at)>=julianday(?) AND julianday(occurred_at)<julianday(?)").all(scope.bookId, range.begin, range.endExclusive);
|
|
709
|
+
const observedIds = new Set(unique.map((transaction) => transaction.remoteId));
|
|
710
|
+
const remove = this.db.prepare("DELETE FROM transactions WHERE book_id=? AND remote_id=?");
|
|
711
|
+
const markReceiptDeleted = this.db.prepare(`
|
|
712
|
+
UPDATE write_receipts
|
|
713
|
+
SET status='remote_deleted', deleted_observed_at=?, updated_at=?
|
|
714
|
+
WHERE book_id=? AND remote_id=? AND status!='remote_deleted'
|
|
715
|
+
`);
|
|
716
|
+
let removed = 0;
|
|
717
|
+
for (const row of existing) if (!observedIds.has(row.remote_id)) {
|
|
718
|
+
this.recordDeletedObservation(scope.bookId, row.remote_id, runId, scope.observedAt, "recent_sync", {
|
|
719
|
+
scope: {
|
|
720
|
+
beginDate: isoDate(scope.beginDate),
|
|
721
|
+
endDate: isoDate(scope.endDate)
|
|
722
|
+
},
|
|
723
|
+
legacyScopeConfirmation: true
|
|
724
|
+
});
|
|
725
|
+
removed += Number(remove.run(scope.bookId, row.remote_id).changes);
|
|
726
|
+
const receipts = this.receiptsForRemoteId(scope.bookId, row.remote_id);
|
|
727
|
+
markReceiptDeleted.run(scope.observedAt, scope.observedAt, scope.bookId, row.remote_id);
|
|
728
|
+
for (const receipt of receipts) this.appendWriteReceiptEvent({
|
|
729
|
+
...receipt,
|
|
730
|
+
status: "remote_deleted",
|
|
731
|
+
deleted_observed_at: scope.observedAt,
|
|
732
|
+
updated_at: scope.observedAt
|
|
733
|
+
}, "write_remote_deleted", scope.observedAt);
|
|
734
|
+
}
|
|
735
|
+
this.db.prepare(`
|
|
736
|
+
INSERT INTO sync_scopes(sync_run_id,book_id,kind,begin_at,end_at,remote_count,page_count,completed_at)
|
|
737
|
+
VALUES(?,?,?,?,?,?,?,?)
|
|
738
|
+
`).run(runId, scope.bookId, "complete_period", isoDate(scope.beginDate), isoDate(scope.endDate), unique.length, scope.pageCount, scope.observedAt);
|
|
739
|
+
this.advanceLedgerRevision(scope.bookId, scope.observedAt, true);
|
|
740
|
+
return {
|
|
741
|
+
changed,
|
|
742
|
+
removed
|
|
743
|
+
};
|
|
744
|
+
})();
|
|
745
|
+
}
|
|
746
|
+
replaceRemoteTransactionGeneration(runId, generation) {
|
|
747
|
+
const unique = [...new Map(generation.transactions.map((transaction) => [transaction.remoteId, transaction])).values()];
|
|
748
|
+
if (unique.some((transaction) => transaction.bookId !== generation.bookId)) throw new Error("Remote transaction generation contains another book");
|
|
749
|
+
const range = financialDateRange(generation.beginDate, generation.endDate, this.getLedgerBookState(generation.bookId).timezone);
|
|
750
|
+
return this.db.transaction(() => {
|
|
751
|
+
const eventBefore = this.countRows("audit_events");
|
|
752
|
+
const versionBefore = this.countRows("transaction_versions");
|
|
753
|
+
const existing = this.db.prepare("SELECT remote_id FROM transactions WHERE book_id=? AND julianday(occurred_at)>=julianday(?) AND julianday(occurred_at)<julianday(?)").all(generation.bookId, range.begin, range.endExclusive);
|
|
754
|
+
const changed = this.writeObservedTransactions(unique, runId, generation.observedAt, {
|
|
755
|
+
observationSource: generation.mode === "full" ? "full_sync" : "recent_sync",
|
|
756
|
+
initiator: "unknown_remote"
|
|
757
|
+
});
|
|
758
|
+
const observedIds = new Set(unique.map((transaction) => transaction.remoteId));
|
|
759
|
+
let removed = 0;
|
|
760
|
+
for (const row of existing) {
|
|
761
|
+
if (observedIds.has(row.remote_id)) continue;
|
|
762
|
+
const receipts = this.receiptsForRemoteId(generation.bookId, row.remote_id);
|
|
763
|
+
const directedDelete = receipts.find((receipt) => receipt.operation === "delete" && receipt.status === "verified");
|
|
764
|
+
this.recordDeletedObservation(generation.bookId, row.remote_id, runId, generation.observedAt, generation.mode === "full" ? "full_sync" : "recent_sync", {
|
|
765
|
+
generationFingerprint: generation.fingerprint,
|
|
766
|
+
attempts: generation.attempts,
|
|
767
|
+
globallyConfirmed: true
|
|
768
|
+
}, directedDelete ? {
|
|
769
|
+
initiator: "sui-ledger",
|
|
770
|
+
operationKey: directedDelete.operation_key
|
|
771
|
+
} : {});
|
|
772
|
+
removed += Number(this.db.prepare("DELETE FROM transactions WHERE book_id=? AND remote_id=?").run(generation.bookId, row.remote_id).changes);
|
|
773
|
+
this.db.prepare(`UPDATE write_receipts SET status='remote_deleted',deleted_observed_at=?,updated_at=?
|
|
774
|
+
WHERE book_id=? AND remote_id=? AND status!='remote_deleted'`).run(generation.observedAt, generation.observedAt, generation.bookId, row.remote_id);
|
|
775
|
+
for (const receipt of receipts) this.appendWriteReceiptEvent({
|
|
776
|
+
...receipt,
|
|
777
|
+
status: "remote_deleted",
|
|
778
|
+
deleted_observed_at: generation.observedAt,
|
|
779
|
+
updated_at: generation.observedAt
|
|
780
|
+
}, "write_remote_deleted", generation.observedAt);
|
|
781
|
+
}
|
|
782
|
+
for (const period of generation.periods) this.db.prepare(`INSERT INTO sync_scopes(sync_run_id,book_id,kind,begin_at,end_at,remote_count,page_count,completed_at)
|
|
783
|
+
VALUES(?,?,?,?,?,?,?,?)`).run(runId, generation.bookId, "complete_period", isoDate(period.beginDate), isoDate(period.endDate), period.remoteCount, period.pageCount, generation.observedAt);
|
|
784
|
+
this.ensureAuditBookState(generation.bookId, generation.observedAt);
|
|
785
|
+
this.db.prepare(`UPDATE audit_book_state SET last_stable_observed_at=?,
|
|
786
|
+
baseline_completed_at=CASE WHEN ?=1 AND baseline_completed_at IS NULL THEN ? ELSE baseline_completed_at END,
|
|
787
|
+
baseline_history_start=CASE WHEN ?=1 AND baseline_history_start IS NULL THEN ? ELSE baseline_history_start END
|
|
788
|
+
WHERE book_id=?`).run(generation.observedAt, generation.baselineComplete ? 1 : 0, generation.observedAt, generation.baselineComplete ? 1 : 0, isoDate(generation.beginDate), generation.bookId);
|
|
789
|
+
this.db.prepare("UPDATE sync_runs SET completed_at=?,status='succeeded',message=NULL WHERE id=?").run(generation.observedAt, runId);
|
|
790
|
+
this.syncCategoryTypeObservations(generation.bookId, runId, generation.observedAt);
|
|
791
|
+
this.advanceLedgerRevision(generation.bookId, generation.observedAt, true);
|
|
792
|
+
return {
|
|
793
|
+
changed,
|
|
794
|
+
removed,
|
|
795
|
+
events: this.countRows("audit_events") - eventBefore,
|
|
796
|
+
versions: this.countRows("transaction_versions") - versionBefore
|
|
797
|
+
};
|
|
798
|
+
})();
|
|
799
|
+
}
|
|
800
|
+
/** @deprecated Use a SyncService remote observation path. */
|
|
801
|
+
upsertTransactions(transactions) {
|
|
802
|
+
if (transactions.length === 0) return 0;
|
|
803
|
+
const bookId = transactions[0].bookId;
|
|
804
|
+
const runId = this.startSync(bookId, "legacy-remote-observation");
|
|
805
|
+
try {
|
|
806
|
+
const changed = this.db.transaction(() => this.writeObservedTransactions(transactions, runId, (/* @__PURE__ */ new Date()).toISOString()))();
|
|
807
|
+
this.finishSync(runId, "succeeded");
|
|
808
|
+
return changed;
|
|
809
|
+
} catch (error) {
|
|
810
|
+
this.finishSync(runId, "failed", error instanceof Error ? error.message : String(error));
|
|
811
|
+
throw error;
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
writeObservedTransactions(transactions, runId, observedAt, audit = {
|
|
815
|
+
observationSource: "recent_sync",
|
|
816
|
+
initiator: "unknown_remote"
|
|
817
|
+
}) {
|
|
818
|
+
const existingQuery = this.db.prepare("SELECT content_hash,data_json,observed_at FROM transactions WHERE book_id=? AND remote_id=?");
|
|
819
|
+
const write = this.db.prepare(`
|
|
820
|
+
INSERT INTO transactions(book_id,remote_id,occurred_at,type,amount_cents,content_hash,data_json,memo,updated_at,observed_at,sync_run_id)
|
|
821
|
+
VALUES(?,?,?,?,?,?,?,?,?,?,?)
|
|
822
|
+
ON CONFLICT(book_id,remote_id) DO UPDATE SET
|
|
823
|
+
occurred_at=excluded.occurred_at,
|
|
824
|
+
type=excluded.type,
|
|
825
|
+
amount_cents=excluded.amount_cents,
|
|
826
|
+
content_hash=excluded.content_hash,
|
|
827
|
+
data_json=excluded.data_json,
|
|
828
|
+
memo=excluded.memo,
|
|
829
|
+
updated_at=excluded.updated_at,
|
|
830
|
+
observed_at=excluded.observed_at,
|
|
831
|
+
sync_run_id=excluded.sync_run_id
|
|
832
|
+
`);
|
|
833
|
+
let changed = 0;
|
|
834
|
+
for (const transaction of transactions) {
|
|
835
|
+
const serialized = JSON.stringify(transaction);
|
|
836
|
+
const existing = existingQuery.get(transaction.bookId, transaction.remoteId);
|
|
837
|
+
this.recordTransactionObservation(transaction, existing ? JSON.parse(existing.data_json) : null, existing?.observed_at ?? void 0, runId, observedAt, audit);
|
|
838
|
+
if (!existing || existing.content_hash !== transaction.contentHash || existing.data_json !== serialized) changed += 1;
|
|
839
|
+
write.run(transaction.bookId, transaction.remoteId, transaction.occurredAt, transaction.type, transaction.amountCents, transaction.contentHash, serialized, transaction.memo ?? null, observedAt, observedAt, runId);
|
|
840
|
+
}
|
|
841
|
+
return changed;
|
|
842
|
+
}
|
|
843
|
+
recordTransactionObservation(transaction, previous, previousObservedAt, runId, observedAt, audit) {
|
|
844
|
+
const semanticHash = transactionSemanticHash(transaction);
|
|
845
|
+
if (previous && transactionSemanticHash(previous) === semanticHash) return;
|
|
846
|
+
const lastLifecycle = this.db.prepare(`SELECT event_type FROM audit_events WHERE book_id=? AND remote_id=?
|
|
847
|
+
AND event_type IN ('baseline_observed','created_observed','updated_observed','deleted_observed','reappeared_observed') ORDER BY id DESC LIMIT 1`).get(transaction.bookId, transaction.remoteId);
|
|
848
|
+
const state = this.getAuditStatus(transaction.bookId);
|
|
849
|
+
const eventType = previous ? "updated_observed" : lastLifecycle?.event_type === "deleted_observed" ? "reappeared_observed" : audit.initiator === "sui-ledger" || state?.baselineComplete ? "created_observed" : "baseline_observed";
|
|
850
|
+
const beforeVersionId = previous ? this.latestVersionId(transaction.bookId, transaction.remoteId) : void 0;
|
|
851
|
+
const afterVersionId = this.insertTransactionVersion(transaction, observedAt, runId);
|
|
852
|
+
this.appendAuditEvent({
|
|
853
|
+
bookId: transaction.bookId,
|
|
854
|
+
remoteId: transaction.remoteId,
|
|
855
|
+
...audit.operationKey ? { operationKey: audit.operationKey } : {},
|
|
856
|
+
eventType,
|
|
857
|
+
observationSource: audit.observationSource,
|
|
858
|
+
initiator: audit.initiator,
|
|
859
|
+
observedAt,
|
|
860
|
+
...previousObservedAt ? { changeWindowStartAt: previousObservedAt } : {},
|
|
861
|
+
...beforeVersionId ? { beforeVersionId } : {},
|
|
862
|
+
afterVersionId,
|
|
863
|
+
changedFields: previous ? changedBusinessFields(previous, transaction) : [],
|
|
864
|
+
evidence: {
|
|
865
|
+
semanticHash,
|
|
866
|
+
auditFormatVersion: 1
|
|
867
|
+
},
|
|
868
|
+
syncRunId: runId
|
|
869
|
+
});
|
|
870
|
+
}
|
|
871
|
+
recordDeletedObservation(bookId, remoteId, runId, observedAt, source, evidence, attribution = {}) {
|
|
872
|
+
const current = this.db.prepare("SELECT observed_at FROM transactions WHERE book_id=? AND remote_id=?").get(bookId, remoteId);
|
|
873
|
+
if (!current) return;
|
|
874
|
+
const beforeVersionId = this.latestVersionId(bookId, remoteId);
|
|
875
|
+
this.appendAuditEvent({
|
|
876
|
+
bookId,
|
|
877
|
+
remoteId,
|
|
878
|
+
eventType: "deleted_observed",
|
|
879
|
+
observationSource: source,
|
|
880
|
+
initiator: attribution.initiator ?? "unknown_remote",
|
|
881
|
+
observedAt,
|
|
882
|
+
...attribution.operationKey ? { operationKey: attribution.operationKey } : {},
|
|
883
|
+
...current.observed_at ? { changeWindowStartAt: current.observed_at } : {},
|
|
884
|
+
...beforeVersionId ? { beforeVersionId } : {},
|
|
885
|
+
changedFields: [],
|
|
886
|
+
evidence,
|
|
887
|
+
syncRunId: runId
|
|
888
|
+
});
|
|
889
|
+
}
|
|
890
|
+
listTransactions(input) {
|
|
891
|
+
const where = ["book_id = ?"];
|
|
892
|
+
const params = [input.bookId];
|
|
893
|
+
const range = financialDateRange(input.beginDate, input.endDate, this.getLedgerBookState(input.bookId).timezone);
|
|
894
|
+
if (range.begin) {
|
|
895
|
+
where.push("julianday(occurred_at) >= julianday(?)");
|
|
896
|
+
params.push(range.begin);
|
|
897
|
+
}
|
|
898
|
+
if (range.endExclusive) {
|
|
899
|
+
where.push("julianday(occurred_at) < julianday(?)");
|
|
900
|
+
params.push(range.endExclusive);
|
|
901
|
+
}
|
|
902
|
+
if (input.type) {
|
|
903
|
+
where.push("type = ?");
|
|
904
|
+
params.push(input.type);
|
|
905
|
+
}
|
|
906
|
+
if (input.amountCents !== void 0) {
|
|
907
|
+
where.push("amount_cents = ?");
|
|
908
|
+
params.push(input.amountCents);
|
|
909
|
+
}
|
|
910
|
+
if (input.minAmountCents !== void 0) {
|
|
911
|
+
where.push("amount_cents >= ?");
|
|
912
|
+
params.push(input.minAmountCents);
|
|
913
|
+
}
|
|
914
|
+
if (input.maxAmountCents !== void 0) {
|
|
915
|
+
where.push("amount_cents <= ?");
|
|
916
|
+
params.push(input.maxAmountCents);
|
|
917
|
+
}
|
|
918
|
+
for (const field of [
|
|
919
|
+
"accountId",
|
|
920
|
+
"categoryId",
|
|
921
|
+
"destinationAccountId",
|
|
922
|
+
"projectId",
|
|
923
|
+
"memberId",
|
|
924
|
+
"storeId"
|
|
925
|
+
]) if (input[field]) {
|
|
926
|
+
where.push(`json_extract(data_json, '$.${field}') = ?`);
|
|
927
|
+
params.push(input[field]);
|
|
928
|
+
}
|
|
929
|
+
if (input.text?.trim()) {
|
|
930
|
+
const needle = `%${input.text.trim().toLowerCase().replace(/[\\%_]/g, (match) => `\\${match}`)}%`;
|
|
931
|
+
where.push("(lower(coalesce(memo, '')) LIKE ? ESCAPE '\\' OR lower(json_extract(data_json, '$.transactionName')) LIKE ? ESCAPE '\\' OR lower(json_extract(data_json, '$.content')) LIKE ? ESCAPE '\\')");
|
|
932
|
+
params.push(needle, needle, needle);
|
|
933
|
+
}
|
|
934
|
+
const whereSql = where.join(" AND ");
|
|
935
|
+
const totalRow = this.db.prepare(`SELECT COUNT(*) AS count, MAX(observed_at) AS observed_at FROM transactions WHERE ${whereSql}`).get(...params);
|
|
936
|
+
const limit = Math.min(Math.max(input.limit ?? 100, 1), 500);
|
|
937
|
+
const offset = Math.max(input.offset ?? 0, 0);
|
|
938
|
+
const rows = this.db.prepare(`SELECT data_json FROM transactions WHERE ${whereSql} ORDER BY julianday(occurred_at) DESC, remote_id DESC LIMIT ? OFFSET ?`).all(...params, limit, offset);
|
|
939
|
+
return {
|
|
940
|
+
total: totalRow.count,
|
|
941
|
+
limit,
|
|
942
|
+
offset,
|
|
943
|
+
...totalRow.observed_at ? { observedAt: totalRow.observed_at } : {},
|
|
944
|
+
items: rows.map((row) => {
|
|
945
|
+
const transaction = JSON.parse(row.data_json);
|
|
946
|
+
if (input.includeRaw) return transaction;
|
|
947
|
+
const { rawSource: _rawSource, ...compact } = transaction;
|
|
948
|
+
return compact;
|
|
949
|
+
})
|
|
950
|
+
};
|
|
951
|
+
}
|
|
952
|
+
accountTransactions(bookId, endDate) {
|
|
953
|
+
const range = financialDateRange(void 0, endDate, this.getLedgerBookState(bookId).timezone);
|
|
954
|
+
const rows = this.db.prepare(`SELECT data_json,observed_at FROM transactions
|
|
955
|
+
WHERE book_id=? AND julianday(occurred_at)<julianday(?)`).all(bookId, range.endExclusive);
|
|
956
|
+
let observedAt;
|
|
957
|
+
return {
|
|
958
|
+
transactions: rows.map((row) => {
|
|
959
|
+
if (!observedAt || row.observed_at > observedAt) observedAt = row.observed_at;
|
|
960
|
+
return JSON.parse(row.data_json);
|
|
961
|
+
}),
|
|
962
|
+
...observedAt ? { observedAt } : {}
|
|
963
|
+
};
|
|
964
|
+
}
|
|
965
|
+
getTransaction(bookId, remoteId) {
|
|
966
|
+
const row = this.db.prepare("SELECT data_json FROM transactions WHERE book_id=? AND remote_id=?").get(bookId, remoteId);
|
|
967
|
+
return row ? JSON.parse(row.data_json) : void 0;
|
|
968
|
+
}
|
|
969
|
+
aggregateTransactions(bookId, beginDate, endDate, accountId, accountScope) {
|
|
970
|
+
const conditions = ["book_id=?"];
|
|
971
|
+
const parameters = [bookId];
|
|
972
|
+
const range = financialDateRange(beginDate, endDate, this.getLedgerBookState(bookId).timezone);
|
|
973
|
+
if (range.begin) {
|
|
974
|
+
conditions.push("julianday(occurred_at)>=julianday(?)");
|
|
975
|
+
parameters.push(range.begin);
|
|
976
|
+
}
|
|
977
|
+
if (range.endExclusive) {
|
|
978
|
+
conditions.push("julianday(occurred_at)<julianday(?)");
|
|
979
|
+
parameters.push(range.endExclusive);
|
|
980
|
+
}
|
|
981
|
+
const accountIds = resolveStatisticsAccountIds(accountId ? [accountId] : void 0, accountId ? this.getMetadata(bookId).accounts : [], accountScope);
|
|
982
|
+
if (accountIds) {
|
|
983
|
+
const rows = this.db.prepare(`SELECT data_json,observed_at FROM transactions WHERE ${conditions.join(" AND ")}`).all(...parameters);
|
|
984
|
+
const totals = {
|
|
985
|
+
transactionCount: 0,
|
|
986
|
+
incomeCents: 0,
|
|
987
|
+
expenseCents: 0
|
|
988
|
+
};
|
|
989
|
+
for (const row of rows) {
|
|
990
|
+
const transaction = JSON.parse(row.data_json);
|
|
991
|
+
if (!accountIds.includes(repairedSourceAccountId(transaction) ?? "") && !(transaction.type === "transfer" && accountIds.includes(transaction.destinationAccountId ?? ""))) continue;
|
|
992
|
+
const flow = transactionIncomeExpense(transaction, accountIds);
|
|
993
|
+
totals.transactionCount++;
|
|
994
|
+
totals.incomeCents += flow.incomeCents;
|
|
995
|
+
totals.expenseCents += flow.expenseCents;
|
|
996
|
+
if (row.observed_at && (!totals.observedAt || row.observed_at > totals.observedAt)) totals.observedAt = row.observed_at;
|
|
997
|
+
}
|
|
998
|
+
return totals;
|
|
999
|
+
}
|
|
1000
|
+
const aggregate = this.db.prepare(`SELECT COUNT(*) AS transaction_count,
|
|
1001
|
+
COALESCE(SUM(CASE WHEN type='income' THEN abs(amount_cents) ELSE 0 END),0) AS income_cents,
|
|
1002
|
+
COALESCE(SUM(CASE WHEN type='expense' THEN abs(amount_cents) ELSE 0 END),0) AS expense_cents
|
|
1003
|
+
FROM transactions WHERE ${conditions.join(" AND ")}`).get(...parameters);
|
|
1004
|
+
const observed = this.db.prepare(`SELECT MAX(observed_at) AS observed_at FROM transactions
|
|
1005
|
+
WHERE book_id=?${range.endExclusive ? " AND julianday(occurred_at)<julianday(?)" : ""}`).get(...range.endExclusive ? [bookId, range.endExclusive] : [bookId]);
|
|
1006
|
+
return {
|
|
1007
|
+
transactionCount: aggregate.transaction_count,
|
|
1008
|
+
incomeCents: aggregate.income_cents,
|
|
1009
|
+
expenseCents: aggregate.expense_cents,
|
|
1010
|
+
...observed.observed_at ? { observedAt: observed.observed_at } : {}
|
|
1011
|
+
};
|
|
1012
|
+
}
|
|
1013
|
+
listProjectedTransactionIds(bookId, beginDate, endDate) {
|
|
1014
|
+
const range = financialDateRange(beginDate, endDate, this.getLedgerBookState(bookId).timezone);
|
|
1015
|
+
return this.db.prepare("SELECT remote_id FROM transactions WHERE book_id=? AND julianday(occurred_at)>=julianday(?) AND julianday(occurred_at)<julianday(?) ORDER BY remote_id").all(bookId, range.begin, range.endExclusive).map((row) => row.remote_id);
|
|
1016
|
+
}
|
|
1017
|
+
getFreshness(bookId, beginDate, endDate) {
|
|
1018
|
+
const rows = this.db.prepare(`
|
|
1019
|
+
SELECT begin_at,end_at,completed_at FROM sync_scopes
|
|
1020
|
+
WHERE book_id=? AND kind='complete_period'
|
|
1021
|
+
ORDER BY begin_at,completed_at
|
|
1022
|
+
`).all(bookId);
|
|
1023
|
+
if (rows.length === 0) return { complete: false };
|
|
1024
|
+
const lastSuccessfulSyncAt = rows.reduce((latest, row) => row.completed_at > latest ? row.completed_at : latest, rows[0].completed_at);
|
|
1025
|
+
const valid = rows.filter((row) => Boolean(row.begin_at && row.end_at));
|
|
1026
|
+
const coveredBegin = valid.map((row) => row.begin_at).sort()[0];
|
|
1027
|
+
const coveredEnd = valid.map((row) => row.end_at).sort().at(-1);
|
|
1028
|
+
if (!beginDate || !endDate) return {
|
|
1029
|
+
complete: false,
|
|
1030
|
+
lastSuccessfulSyncAt,
|
|
1031
|
+
...coveredBegin ? { coveredBegin } : {},
|
|
1032
|
+
...coveredEnd ? { coveredEnd } : {}
|
|
1033
|
+
};
|
|
1034
|
+
const targetBegin = dateNumber(beginDate);
|
|
1035
|
+
const targetEnd = dateNumber(endDate);
|
|
1036
|
+
const ranges = valid.map((row) => ({
|
|
1037
|
+
begin: dateNumber(row.begin_at),
|
|
1038
|
+
end: dateNumber(row.end_at)
|
|
1039
|
+
})).sort((left, right) => left.begin - right.begin);
|
|
1040
|
+
let cursor = targetBegin;
|
|
1041
|
+
for (const range of ranges) {
|
|
1042
|
+
if (range.end < cursor) continue;
|
|
1043
|
+
if (range.begin > cursor) break;
|
|
1044
|
+
cursor = Math.max(cursor, nextDay(range.end));
|
|
1045
|
+
if (cursor > targetEnd) break;
|
|
1046
|
+
}
|
|
1047
|
+
return {
|
|
1048
|
+
complete: cursor > targetEnd,
|
|
1049
|
+
lastSuccessfulSyncAt,
|
|
1050
|
+
...coveredBegin ? { coveredBegin } : {},
|
|
1051
|
+
...coveredEnd ? { coveredEnd } : {}
|
|
1052
|
+
};
|
|
1053
|
+
}
|
|
1054
|
+
startSync(bookId, mode) {
|
|
1055
|
+
const result = this.db.prepare("INSERT INTO sync_runs(book_id,mode,started_at,status) VALUES(?,?,?,?)").run(bookId, mode, (/* @__PURE__ */ new Date()).toISOString(), "running");
|
|
1056
|
+
return Number(result.lastInsertRowid);
|
|
1057
|
+
}
|
|
1058
|
+
finishSync(id, status, message) {
|
|
1059
|
+
this.db.prepare("UPDATE sync_runs SET completed_at=?,status=?,message=? WHERE id=?").run((/* @__PURE__ */ new Date()).toISOString(), status, message ?? null, id);
|
|
1060
|
+
}
|
|
1061
|
+
syncStatus() {
|
|
1062
|
+
return this.db.prepare(`
|
|
1063
|
+
SELECT book_id AS bookId, mode, started_at AS startedAt, completed_at AS completedAt, status, message
|
|
1064
|
+
FROM sync_runs WHERE id IN (SELECT MAX(id) FROM sync_runs GROUP BY book_id) ORDER BY book_id
|
|
1065
|
+
`).all();
|
|
1066
|
+
}
|
|
1067
|
+
queryTransactionAudit(input) {
|
|
1068
|
+
const where = ["e.book_id=?"];
|
|
1069
|
+
const params = [input.bookId];
|
|
1070
|
+
if (input.remoteId) {
|
|
1071
|
+
where.push(`(e.remote_id=? OR e.operation_key IN (
|
|
1072
|
+
SELECT operation_key FROM write_receipts WHERE book_id=? AND remote_id=?
|
|
1073
|
+
))`);
|
|
1074
|
+
params.push(input.remoteId, input.bookId, input.remoteId);
|
|
1075
|
+
}
|
|
1076
|
+
if (input.operationKey) {
|
|
1077
|
+
where.push("e.operation_key=?");
|
|
1078
|
+
params.push(input.operationKey);
|
|
1079
|
+
}
|
|
1080
|
+
if (input.eventType) {
|
|
1081
|
+
where.push("e.event_type=?");
|
|
1082
|
+
params.push(input.eventType);
|
|
1083
|
+
}
|
|
1084
|
+
if (input.beginObservedAt) {
|
|
1085
|
+
where.push("e.observed_at>=?");
|
|
1086
|
+
params.push(input.beginObservedAt);
|
|
1087
|
+
}
|
|
1088
|
+
if (input.endObservedAt) {
|
|
1089
|
+
where.push("e.observed_at<=?");
|
|
1090
|
+
params.push(input.endObservedAt);
|
|
1091
|
+
}
|
|
1092
|
+
if (input.beforeEventId !== void 0) {
|
|
1093
|
+
where.push("e.id<?");
|
|
1094
|
+
params.push(input.beforeEventId);
|
|
1095
|
+
}
|
|
1096
|
+
const limit = Math.min(Math.max(input.limit ?? 100, 1), 500);
|
|
1097
|
+
const rows = this.db.prepare(`SELECT e.* FROM audit_events e WHERE ${where.join(" AND ")} ORDER BY e.id DESC LIMIT ?`).all(...params, limit + 1);
|
|
1098
|
+
const hasMore = rows.length > limit;
|
|
1099
|
+
const selected = rows.slice(0, limit);
|
|
1100
|
+
const includeVersions = Boolean(input.includeVersions || input.includeRaw);
|
|
1101
|
+
const events = selected.map((row) => this.mapAuditEvent(row, includeVersions, Boolean(input.includeRaw)));
|
|
1102
|
+
const nextBeforeEventId = hasMore ? selected.at(-1)?.id : void 0;
|
|
1103
|
+
return {
|
|
1104
|
+
bookId: input.bookId,
|
|
1105
|
+
...input.remoteId ? { remoteId: input.remoteId } : {},
|
|
1106
|
+
pagination: {
|
|
1107
|
+
limit,
|
|
1108
|
+
...input.beforeEventId !== void 0 ? { beforeEventId: input.beforeEventId } : {},
|
|
1109
|
+
...nextBeforeEventId ? { nextBeforeEventId } : {},
|
|
1110
|
+
hasMore
|
|
1111
|
+
},
|
|
1112
|
+
events
|
|
1113
|
+
};
|
|
1114
|
+
}
|
|
1115
|
+
getAuditStatus(bookId) {
|
|
1116
|
+
const row = this.db.prepare("SELECT * FROM audit_book_state WHERE book_id=?").get(bookId);
|
|
1117
|
+
return row ? {
|
|
1118
|
+
bookId: row.book_id,
|
|
1119
|
+
activatedAt: row.activated_at,
|
|
1120
|
+
baselineComplete: Boolean(row.baseline_completed_at),
|
|
1121
|
+
...row.baseline_completed_at ? { baselineCompletedAt: row.baseline_completed_at } : {},
|
|
1122
|
+
...row.baseline_history_start ? { baselineHistoryStart: row.baseline_history_start } : {},
|
|
1123
|
+
...row.last_stable_observed_at ? { lastStableObservedAt: row.last_stable_observed_at } : {},
|
|
1124
|
+
...row.last_event_id ? { lastEventId: row.last_event_id } : {},
|
|
1125
|
+
...row.last_event_hash ? { lastEventHash: row.last_event_hash } : {}
|
|
1126
|
+
} : null;
|
|
1127
|
+
}
|
|
1128
|
+
verifyAudit(input = {}) {
|
|
1129
|
+
const errors = [];
|
|
1130
|
+
if (!this.db.prepare("PRAGMA integrity_check").all().some((row) => row.integrity_check === "ok")) errors.push({ code: "SQLITE_INTEGRITY_FAILED" });
|
|
1131
|
+
const foreignKeys = this.db.prepare("PRAGMA foreign_key_check").all();
|
|
1132
|
+
for (const row of foreignKeys) errors.push({
|
|
1133
|
+
code: "SQLITE_FOREIGN_KEY_FAILED",
|
|
1134
|
+
...row.table === "audit_events" ? { eventId: row.rowid } : {}
|
|
1135
|
+
});
|
|
1136
|
+
const versionWhere = ["1=1"];
|
|
1137
|
+
const versionParams = [];
|
|
1138
|
+
if (input.bookId) {
|
|
1139
|
+
versionWhere.push("book_id=?");
|
|
1140
|
+
versionParams.push(input.bookId);
|
|
1141
|
+
}
|
|
1142
|
+
if (input.remoteId) {
|
|
1143
|
+
versionWhere.push("remote_id=?");
|
|
1144
|
+
versionParams.push(input.remoteId);
|
|
1145
|
+
}
|
|
1146
|
+
const versions = this.db.prepare(`SELECT * FROM transaction_versions WHERE ${versionWhere.join(" AND ")} ORDER BY id`).all(...versionParams);
|
|
1147
|
+
for (const row of versions) {
|
|
1148
|
+
const snapshot = JSON.parse(row.snapshot_json);
|
|
1149
|
+
const rawSource = row.raw_source_json ? JSON.parse(row.raw_source_json) : void 0;
|
|
1150
|
+
const transaction = {
|
|
1151
|
+
...snapshot,
|
|
1152
|
+
contentHash: "",
|
|
1153
|
+
...rawSource ? { rawSource } : {}
|
|
1154
|
+
};
|
|
1155
|
+
if (transactionSemanticHash(transaction) !== row.semantic_hash) errors.push({
|
|
1156
|
+
code: "VERSION_SEMANTIC_HASH_MISMATCH",
|
|
1157
|
+
bookId: row.book_id,
|
|
1158
|
+
remoteId: row.remote_id,
|
|
1159
|
+
versionId: row.id
|
|
1160
|
+
});
|
|
1161
|
+
if (transactionEvidenceHash(transaction) !== row.evidence_hash) errors.push({
|
|
1162
|
+
code: "VERSION_EVIDENCE_HASH_MISMATCH",
|
|
1163
|
+
bookId: row.book_id,
|
|
1164
|
+
remoteId: row.remote_id,
|
|
1165
|
+
versionId: row.id
|
|
1166
|
+
});
|
|
1167
|
+
}
|
|
1168
|
+
const bookRows = input.bookId ? [{ book_id: input.bookId }] : this.db.prepare("SELECT book_id FROM audit_book_state ORDER BY book_id").all();
|
|
1169
|
+
let eventsChecked = 0;
|
|
1170
|
+
const referencedVersion = this.db.prepare("SELECT book_id,remote_id FROM transaction_versions WHERE id=?");
|
|
1171
|
+
for (const { book_id: bookId } of bookRows) {
|
|
1172
|
+
const events = this.db.prepare("SELECT * FROM audit_events WHERE book_id=? ORDER BY id").all(bookId);
|
|
1173
|
+
let previousHash;
|
|
1174
|
+
for (const event of events) {
|
|
1175
|
+
eventsChecked += 1;
|
|
1176
|
+
for (const versionId of [event.before_version_id, event.after_version_id]) {
|
|
1177
|
+
if (versionId === null) continue;
|
|
1178
|
+
const reference = referencedVersion.get(versionId);
|
|
1179
|
+
if (!reference) errors.push({
|
|
1180
|
+
code: "EVENT_VERSION_REFERENCE_MISSING",
|
|
1181
|
+
bookId,
|
|
1182
|
+
eventId: event.id,
|
|
1183
|
+
versionId,
|
|
1184
|
+
...event.remote_id ? { remoteId: event.remote_id } : {}
|
|
1185
|
+
});
|
|
1186
|
+
else if (reference.book_id !== bookId || reference.remote_id !== event.remote_id) errors.push({
|
|
1187
|
+
code: "EVENT_VERSION_REFERENCE_MISMATCH",
|
|
1188
|
+
bookId,
|
|
1189
|
+
eventId: event.id,
|
|
1190
|
+
versionId,
|
|
1191
|
+
...event.remote_id ? { remoteId: event.remote_id } : {}
|
|
1192
|
+
});
|
|
1193
|
+
}
|
|
1194
|
+
if ((event.previous_event_hash ?? void 0) !== previousHash) errors.push({
|
|
1195
|
+
code: "EVENT_PREVIOUS_HASH_MISMATCH",
|
|
1196
|
+
bookId,
|
|
1197
|
+
eventId: event.id
|
|
1198
|
+
});
|
|
1199
|
+
if (this.computeEventHash(event, previousHash) !== event.event_hash) errors.push({
|
|
1200
|
+
code: "EVENT_HASH_MISMATCH",
|
|
1201
|
+
bookId,
|
|
1202
|
+
eventId: event.id
|
|
1203
|
+
});
|
|
1204
|
+
previousHash = event.event_hash;
|
|
1205
|
+
}
|
|
1206
|
+
const state = this.getAuditStatus(bookId);
|
|
1207
|
+
const last = events.at(-1);
|
|
1208
|
+
if ((state?.lastEventHash ?? void 0) !== last?.event_hash || (state?.lastEventId ?? void 0) !== last?.id) errors.push({
|
|
1209
|
+
code: "AUDIT_HEAD_MISMATCH",
|
|
1210
|
+
bookId
|
|
1211
|
+
});
|
|
1212
|
+
}
|
|
1213
|
+
return {
|
|
1214
|
+
ok: errors.length === 0,
|
|
1215
|
+
booksChecked: bookRows.length,
|
|
1216
|
+
eventsChecked,
|
|
1217
|
+
versionsChecked: versions.length,
|
|
1218
|
+
errors
|
|
1219
|
+
};
|
|
1220
|
+
}
|
|
1221
|
+
prepareWriteReceipt(receipt) {
|
|
1222
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
1223
|
+
return this.db.transaction(() => {
|
|
1224
|
+
const result = this.db.prepare(`
|
|
1225
|
+
INSERT INTO write_receipts(
|
|
1226
|
+
book_id,operation_key,operation,request_hash,text_protocol_version,memo_policy_version,status,baseline_remote_ids_json,created_at,updated_at
|
|
1227
|
+
) VALUES(?,?,?,?,?,?,?,?,?,?) ON CONFLICT(book_id,operation_key) DO NOTHING
|
|
1228
|
+
`).run(receipt.bookId, receipt.operationKey, receipt.operation, receipt.requestHash, receipt.textProtocolVersion ?? null, receipt.memoPolicyVersion ?? null, "prepared", JSON.stringify([...new Set(receipt.baselineRemoteIds)]), now, now);
|
|
1229
|
+
const row = this.db.prepare("SELECT * FROM write_receipts WHERE book_id=? AND operation_key=?").get(receipt.bookId, receipt.operationKey);
|
|
1230
|
+
if (!row) throw new Error("Failed to prepare the local write receipt");
|
|
1231
|
+
if (Number(result.changes) === 1) this.appendWriteReceiptEvent(row, "write_prepared", now);
|
|
1232
|
+
return mapWriteReceipt(row);
|
|
1233
|
+
})();
|
|
1234
|
+
}
|
|
1235
|
+
getWriteReceipt(bookId, operationKey) {
|
|
1236
|
+
const row = this.db.prepare("SELECT * FROM write_receipts WHERE book_id=? AND operation_key=?").get(bookId, operationKey);
|
|
1237
|
+
return row ? mapWriteReceipt(row) : null;
|
|
1238
|
+
}
|
|
1239
|
+
updateWriteReceipt(bookId, operationKey, status, input = {}) {
|
|
1240
|
+
return this.db.transaction(() => {
|
|
1241
|
+
const before = this.db.prepare("SELECT * FROM write_receipts WHERE book_id=? AND operation_key=?").get(bookId, operationKey);
|
|
1242
|
+
if (!before) throw new Error(`Unknown write receipt: ${bookId}/${operationKey}`);
|
|
1243
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
1244
|
+
this.db.prepare(`UPDATE write_receipts SET status=?,remote_id=COALESCE(?,remote_id),message=?,
|
|
1245
|
+
deleted_observed_at=COALESCE(?,deleted_observed_at),acknowledged_at=COALESCE(?,acknowledged_at),updated_at=? WHERE book_id=? AND operation_key=?`).run(status, input.remoteId ?? null, input.message ?? null, input.deletedObservedAt ?? null, input.acknowledgedAt ?? null, now, bookId, operationKey);
|
|
1246
|
+
const after = this.db.prepare("SELECT * FROM write_receipts WHERE book_id=? AND operation_key=?").get(bookId, operationKey);
|
|
1247
|
+
if (!after) throw new Error("Updated write receipt disappeared");
|
|
1248
|
+
if (before.status !== after.status || before.remote_id !== after.remote_id || before.message !== after.message || before.deleted_observed_at !== after.deleted_observed_at || before.acknowledged_at !== after.acknowledged_at) this.appendWriteReceiptEvent(after, writeEventForStatus(after.status), now);
|
|
1249
|
+
return mapWriteReceipt(after);
|
|
1250
|
+
})();
|
|
1251
|
+
}
|
|
1252
|
+
ensureAuditBookState(bookId, activatedAt) {
|
|
1253
|
+
this.db.prepare(`INSERT INTO audit_book_state(book_id,activated_at) VALUES(?,?)
|
|
1254
|
+
ON CONFLICT(book_id) DO NOTHING`).run(bookId, activatedAt);
|
|
1255
|
+
}
|
|
1256
|
+
insertTransactionVersion(transaction, observedAt, syncRunId, recordedAt = (/* @__PURE__ */ new Date()).toISOString()) {
|
|
1257
|
+
const snapshot = transactionSnapshot(transaction);
|
|
1258
|
+
const result = this.db.prepare(`INSERT INTO transaction_versions(
|
|
1259
|
+
book_id,remote_id,semantic_hash,evidence_hash,snapshot_json,raw_source_json,observed_at,recorded_at,sync_run_id
|
|
1260
|
+
) VALUES(?,?,?,?,?,?,?,?,?)`).run(transaction.bookId, transaction.remoteId, transactionSemanticHash(transaction), transactionEvidenceHash(transaction), JSON.stringify(snapshot), transaction.rawSource ? JSON.stringify(transaction.rawSource) : null, observedAt, recordedAt, syncRunId ?? null);
|
|
1261
|
+
return Number(result.lastInsertRowid);
|
|
1262
|
+
}
|
|
1263
|
+
latestVersionId(bookId, remoteId) {
|
|
1264
|
+
return this.db.prepare("SELECT id FROM transaction_versions WHERE book_id=? AND remote_id=? ORDER BY id DESC LIMIT 1").get(bookId, remoteId)?.id;
|
|
1265
|
+
}
|
|
1266
|
+
appendAuditEvent(input) {
|
|
1267
|
+
const recordedAt = input.recordedAt ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
1268
|
+
this.ensureAuditBookState(input.bookId, recordedAt);
|
|
1269
|
+
const head = this.db.prepare("SELECT last_event_hash FROM audit_book_state WHERE book_id=?").get(input.bookId);
|
|
1270
|
+
const row = {
|
|
1271
|
+
book_id: input.bookId,
|
|
1272
|
+
remote_id: input.remoteId ?? null,
|
|
1273
|
+
operation_key: input.operationKey ?? null,
|
|
1274
|
+
event_type: input.eventType,
|
|
1275
|
+
observation_source: input.observationSource,
|
|
1276
|
+
initiator: input.initiator,
|
|
1277
|
+
observed_at: input.observedAt,
|
|
1278
|
+
change_window_start_at: input.changeWindowStartAt ?? null,
|
|
1279
|
+
before_version_id: input.beforeVersionId ?? null,
|
|
1280
|
+
after_version_id: input.afterVersionId ?? null,
|
|
1281
|
+
changed_fields_json: JSON.stringify([...input.changedFields].sort()),
|
|
1282
|
+
evidence_json: JSON.stringify(input.evidence),
|
|
1283
|
+
sync_run_id: input.syncRunId ?? null,
|
|
1284
|
+
previous_event_hash: head.last_event_hash,
|
|
1285
|
+
recorded_at: recordedAt
|
|
1286
|
+
};
|
|
1287
|
+
const eventHash = this.computeEventHash(row, head.last_event_hash ?? void 0);
|
|
1288
|
+
const result = this.db.prepare(`INSERT INTO audit_events(
|
|
1289
|
+
book_id,remote_id,operation_key,event_type,observation_source,initiator,observed_at,change_window_start_at,
|
|
1290
|
+
before_version_id,after_version_id,changed_fields_json,evidence_json,sync_run_id,previous_event_hash,event_hash,recorded_at
|
|
1291
|
+
) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`).run(row.book_id, row.remote_id, row.operation_key, row.event_type, row.observation_source, row.initiator, row.observed_at, row.change_window_start_at, row.before_version_id, row.after_version_id, row.changed_fields_json, row.evidence_json, row.sync_run_id, row.previous_event_hash, eventHash, row.recorded_at);
|
|
1292
|
+
const eventId = Number(result.lastInsertRowid);
|
|
1293
|
+
this.db.prepare("UPDATE audit_book_state SET last_event_id=?,last_event_hash=? WHERE book_id=?").run(eventId, eventHash, input.bookId);
|
|
1294
|
+
return eventId;
|
|
1295
|
+
}
|
|
1296
|
+
appendWriteReceiptEvent(receipt, eventType, observedAt, source = "write_receipt") {
|
|
1297
|
+
this.appendAuditEvent({
|
|
1298
|
+
bookId: receipt.book_id,
|
|
1299
|
+
...receipt.remote_id ? { remoteId: receipt.remote_id } : {},
|
|
1300
|
+
operationKey: receipt.operation_key,
|
|
1301
|
+
eventType,
|
|
1302
|
+
observationSource: source,
|
|
1303
|
+
initiator: source === "migration" ? "system" : "sui-ledger",
|
|
1304
|
+
observedAt,
|
|
1305
|
+
changedFields: [],
|
|
1306
|
+
evidence: {
|
|
1307
|
+
operation: receipt.operation,
|
|
1308
|
+
status: receipt.status,
|
|
1309
|
+
requestHash: receipt.request_hash,
|
|
1310
|
+
...receipt.message ? { message: receipt.message } : {},
|
|
1311
|
+
...receipt.acknowledged_at ? { acknowledgedAt: receipt.acknowledged_at } : {},
|
|
1312
|
+
...receipt.deleted_observed_at ? { deletedObservedAt: receipt.deleted_observed_at } : {}
|
|
1313
|
+
}
|
|
1314
|
+
});
|
|
1315
|
+
}
|
|
1316
|
+
receiptsForRemoteId(bookId, remoteId) {
|
|
1317
|
+
return this.db.prepare("SELECT * FROM write_receipts WHERE book_id=? AND remote_id=? AND status!='remote_deleted'").all(bookId, remoteId);
|
|
1318
|
+
}
|
|
1319
|
+
mapAuditEvent(row, includeVersions, includeRaw) {
|
|
1320
|
+
const changedFields = JSON.parse(row.changed_fields_json);
|
|
1321
|
+
const evidence = JSON.parse(row.evidence_json);
|
|
1322
|
+
return {
|
|
1323
|
+
id: row.id,
|
|
1324
|
+
bookId: row.book_id,
|
|
1325
|
+
...row.remote_id ? { remoteId: row.remote_id } : {},
|
|
1326
|
+
...row.operation_key ? { operationKey: row.operation_key } : {},
|
|
1327
|
+
eventType: row.event_type,
|
|
1328
|
+
observationSource: row.observation_source,
|
|
1329
|
+
initiator: row.initiator,
|
|
1330
|
+
observedAt: row.observed_at,
|
|
1331
|
+
...row.change_window_start_at ? { changeWindowStartAt: row.change_window_start_at } : {},
|
|
1332
|
+
...row.before_version_id ? { beforeVersionId: row.before_version_id } : {},
|
|
1333
|
+
...row.after_version_id ? { afterVersionId: row.after_version_id } : {},
|
|
1334
|
+
changedFields,
|
|
1335
|
+
evidence,
|
|
1336
|
+
...row.sync_run_id ? { syncRunId: row.sync_run_id } : {},
|
|
1337
|
+
...row.previous_event_hash ? { previousEventHash: row.previous_event_hash } : {},
|
|
1338
|
+
eventHash: row.event_hash,
|
|
1339
|
+
recordedAt: row.recorded_at,
|
|
1340
|
+
...includeVersions && row.before_version_id ? { beforeVersion: this.getVersion(row.before_version_id, includeRaw) } : {},
|
|
1341
|
+
...includeVersions && row.after_version_id ? { afterVersion: this.getVersion(row.after_version_id, includeRaw) } : {}
|
|
1342
|
+
};
|
|
1343
|
+
}
|
|
1344
|
+
getVersion(id, includeRaw) {
|
|
1345
|
+
const row = this.db.prepare("SELECT * FROM transaction_versions WHERE id=?").get(id);
|
|
1346
|
+
if (!row) throw new Error(`Missing transaction version: ${id}`);
|
|
1347
|
+
return {
|
|
1348
|
+
id: row.id,
|
|
1349
|
+
bookId: row.book_id,
|
|
1350
|
+
remoteId: row.remote_id,
|
|
1351
|
+
semanticHash: row.semantic_hash,
|
|
1352
|
+
evidenceHash: row.evidence_hash,
|
|
1353
|
+
snapshot: JSON.parse(row.snapshot_json),
|
|
1354
|
+
...includeRaw && row.raw_source_json ? { rawSource: JSON.parse(row.raw_source_json) } : {},
|
|
1355
|
+
observedAt: row.observed_at,
|
|
1356
|
+
recordedAt: row.recorded_at,
|
|
1357
|
+
...row.sync_run_id ? { syncRunId: row.sync_run_id } : {}
|
|
1358
|
+
};
|
|
1359
|
+
}
|
|
1360
|
+
computeEventHash(row, previousHash) {
|
|
1361
|
+
return auditHash({
|
|
1362
|
+
version: 1,
|
|
1363
|
+
bookId: row.book_id,
|
|
1364
|
+
remoteId: row.remote_id,
|
|
1365
|
+
operationKey: row.operation_key,
|
|
1366
|
+
eventType: row.event_type,
|
|
1367
|
+
observationSource: row.observation_source,
|
|
1368
|
+
initiator: row.initiator,
|
|
1369
|
+
observedAt: row.observed_at,
|
|
1370
|
+
changeWindowStartAt: row.change_window_start_at,
|
|
1371
|
+
beforeVersionId: row.before_version_id,
|
|
1372
|
+
afterVersionId: row.after_version_id,
|
|
1373
|
+
changedFields: JSON.parse(row.changed_fields_json),
|
|
1374
|
+
evidence: JSON.parse(row.evidence_json),
|
|
1375
|
+
syncRunId: row.sync_run_id,
|
|
1376
|
+
previousEventHash: previousHash ?? null,
|
|
1377
|
+
recordedAt: row.recorded_at
|
|
1378
|
+
});
|
|
1379
|
+
}
|
|
1380
|
+
countRows(table) {
|
|
1381
|
+
return Number(this.db.prepare(`SELECT COUNT(*) AS count FROM ${table}`).get().count);
|
|
1382
|
+
}
|
|
1383
|
+
acquireWriteLease(ownerId, now, expiresAt) {
|
|
1384
|
+
return this.db.transaction(() => {
|
|
1385
|
+
const current = this.db.prepare("SELECT owner_id,expires_at FROM write_leases WHERE scope='global'").get();
|
|
1386
|
+
if (current && current.owner_id !== ownerId && current.expires_at > now) return false;
|
|
1387
|
+
this.db.prepare(`
|
|
1388
|
+
INSERT INTO write_leases(scope,owner_id,expires_at,updated_at) VALUES('global',?,?,?)
|
|
1389
|
+
ON CONFLICT(scope) DO UPDATE SET owner_id=excluded.owner_id,expires_at=excluded.expires_at,updated_at=excluded.updated_at
|
|
1390
|
+
`).run(ownerId, expiresAt, now);
|
|
1391
|
+
return true;
|
|
1392
|
+
})();
|
|
1393
|
+
}
|
|
1394
|
+
releaseWriteLease(ownerId) {
|
|
1395
|
+
this.db.prepare("DELETE FROM write_leases WHERE scope='global' AND owner_id=?").run(ownerId);
|
|
1396
|
+
}
|
|
1397
|
+
getCategoryTypeMap(bookId) {
|
|
1398
|
+
const rows = this.db.prepare("SELECT category_id, observed_type FROM category_type_observations WHERE book_id=?").all(bookId);
|
|
1399
|
+
return Object.fromEntries(rows.map((row) => [row.category_id, row.observed_type]));
|
|
1400
|
+
}
|
|
1401
|
+
syncCategoryTypeObservations(bookId, runId, now) {
|
|
1402
|
+
this.db.prepare(`
|
|
1403
|
+
UPDATE category_type_observations
|
|
1404
|
+
SET observed_type = subq.type, modified_at = ?
|
|
1405
|
+
FROM (
|
|
1406
|
+
SELECT json_extract(data_json,'$.categoryId') AS category_id,
|
|
1407
|
+
MAX(type) AS type,
|
|
1408
|
+
COUNT(DISTINCT type) AS type_count
|
|
1409
|
+
FROM transactions
|
|
1410
|
+
WHERE sync_run_id = ? AND book_id = ?
|
|
1411
|
+
AND type IN ('expense','income','transfer')
|
|
1412
|
+
AND json_extract(data_json,'$.categoryId') IS NOT NULL
|
|
1413
|
+
GROUP BY json_extract(data_json,'$.categoryId')
|
|
1414
|
+
) subq
|
|
1415
|
+
WHERE category_type_observations.book_id = ?
|
|
1416
|
+
AND category_type_observations.category_id = subq.category_id
|
|
1417
|
+
AND category_type_observations.observed_type = 'unknown'
|
|
1418
|
+
AND subq.type_count = 1
|
|
1419
|
+
`).run(now, runId, bookId, bookId);
|
|
1420
|
+
this.propagateCategoryTypesToParents(bookId, now);
|
|
1421
|
+
}
|
|
1422
|
+
propagateCategoryTypesToParents(bookId, now) {
|
|
1423
|
+
this.db.prepare(`
|
|
1424
|
+
UPDATE category_type_observations
|
|
1425
|
+
SET observed_type = (
|
|
1426
|
+
SELECT child.observed_type FROM category_type_observations child
|
|
1427
|
+
WHERE child.book_id = category_type_observations.book_id
|
|
1428
|
+
AND child.parent_id = category_type_observations.category_id
|
|
1429
|
+
AND child.observed_type != 'unknown'
|
|
1430
|
+
LIMIT 1
|
|
1431
|
+
), modified_at = ?
|
|
1432
|
+
WHERE book_id = ?
|
|
1433
|
+
AND observed_type = 'unknown'
|
|
1434
|
+
AND parent_id IS NULL
|
|
1435
|
+
AND (
|
|
1436
|
+
SELECT COUNT(DISTINCT child.observed_type) FROM category_type_observations child
|
|
1437
|
+
WHERE child.book_id = category_type_observations.book_id
|
|
1438
|
+
AND child.parent_id = category_type_observations.category_id
|
|
1439
|
+
AND child.observed_type != 'unknown'
|
|
1440
|
+
) = 1
|
|
1441
|
+
`).run(now, bookId);
|
|
1442
|
+
}
|
|
1443
|
+
};
|
|
1444
|
+
function isoDate(value) {
|
|
1445
|
+
return value.slice(0, 10).replaceAll(".", "-");
|
|
1446
|
+
}
|
|
1447
|
+
function dateNumber(value) {
|
|
1448
|
+
return Date.parse(`${isoDate(value)}T00:00:00Z`);
|
|
1449
|
+
}
|
|
1450
|
+
function nextDay(value) {
|
|
1451
|
+
return value + 864e5;
|
|
1452
|
+
}
|
|
1453
|
+
function mapWriteReceipt(row) {
|
|
1454
|
+
const parsed = JSON.parse(row.baseline_remote_ids_json);
|
|
1455
|
+
if (!Array.isArray(parsed) || !parsed.every((value) => typeof value === "string")) throw new Error("Invalid write receipt baseline data");
|
|
1456
|
+
return {
|
|
1457
|
+
bookId: row.book_id,
|
|
1458
|
+
operationKey: row.operation_key,
|
|
1459
|
+
operation: row.operation,
|
|
1460
|
+
requestHash: row.request_hash,
|
|
1461
|
+
...row.text_protocol_version ? { textProtocolVersion: row.text_protocol_version } : {},
|
|
1462
|
+
...row.memo_policy_version ? { memoPolicyVersion: row.memo_policy_version } : {},
|
|
1463
|
+
status: row.status,
|
|
1464
|
+
baselineRemoteIds: parsed,
|
|
1465
|
+
...row.remote_id ? { remoteId: row.remote_id } : {},
|
|
1466
|
+
...row.message ? { message: row.message } : {},
|
|
1467
|
+
...row.deleted_observed_at ? { deletedObservedAt: row.deleted_observed_at } : {},
|
|
1468
|
+
...row.acknowledged_at ? { acknowledgedAt: row.acknowledged_at } : {},
|
|
1469
|
+
createdAt: row.created_at,
|
|
1470
|
+
updatedAt: row.updated_at
|
|
1471
|
+
};
|
|
1472
|
+
}
|
|
1473
|
+
function writeEventForStatus(status) {
|
|
1474
|
+
if (status === "prepared") return "write_prepared";
|
|
1475
|
+
if (status === "submitting") return "write_submitting";
|
|
1476
|
+
if (status === "verified") return "write_verified";
|
|
1477
|
+
if (status === "uncertain") return "write_uncertain";
|
|
1478
|
+
if (status === "failed") return "write_failed";
|
|
1479
|
+
return "write_remote_deleted";
|
|
1480
|
+
}
|
|
1481
|
+
function mapCheckpointRow(row) {
|
|
1482
|
+
return {
|
|
1483
|
+
id: String(row.id),
|
|
1484
|
+
bookId: String(row.book_id),
|
|
1485
|
+
accountId: String(row.account_id),
|
|
1486
|
+
revision: Number(row.revision),
|
|
1487
|
+
balanceCents: Number(row.balance_cents),
|
|
1488
|
+
currency: String(row.currency),
|
|
1489
|
+
cutoff: String(row.cutoff),
|
|
1490
|
+
lastStableSyncAt: String(row.last_stable_sync_at),
|
|
1491
|
+
ledgerRevision: Number(row.ledger_revision),
|
|
1492
|
+
timezone: String(row.timezone),
|
|
1493
|
+
createdBy: String(row.created_by),
|
|
1494
|
+
createdAt: String(row.created_at)
|
|
1495
|
+
};
|
|
1496
|
+
}
|
|
1497
|
+
function mapCheckpointAuditRow(row) {
|
|
1498
|
+
return {
|
|
1499
|
+
id: Number(row.id),
|
|
1500
|
+
eventType: row.event_type,
|
|
1501
|
+
bookId: String(row.book_id),
|
|
1502
|
+
accountId: String(row.account_id),
|
|
1503
|
+
checkpointId: String(row.checkpoint_id),
|
|
1504
|
+
checkpointRevision: Number(row.checkpoint_revision),
|
|
1505
|
+
...row.commit_id ? { commitId: String(row.commit_id) } : {},
|
|
1506
|
+
...row.operations_hash ? { operationsHash: String(row.operations_hash) } : {},
|
|
1507
|
+
...row.deviation_cents !== null && row.deviation_cents !== void 0 ? { deviationCents: Number(row.deviation_cents) } : {},
|
|
1508
|
+
authority: String(row.authority),
|
|
1509
|
+
occurredAt: String(row.occurred_at)
|
|
1510
|
+
};
|
|
1511
|
+
}
|
|
1512
|
+
function assertIanaTimezone(timezone) {
|
|
1513
|
+
try {
|
|
1514
|
+
new Intl.DateTimeFormat("en-US", { timeZone: timezone }).format(/* @__PURE__ */ new Date(0));
|
|
1515
|
+
} catch {
|
|
1516
|
+
throw new Error("ledger_timezone_invalid");
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1519
|
+
function assertIso(value, label) {
|
|
1520
|
+
if (Number.isNaN(Date.parse(value))) throw new Error(`${label} must be an ISO timestamp`);
|
|
1521
|
+
}
|
|
1522
|
+
//#endregion
|
|
1523
|
+
export { LedgerDatabase };
|