@gusto/baerly-storage 0.1.0 → 0.1.2
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 +9 -5
- package/dist/API.md +161 -10
- package/dist/{app-config-Cb5dO2s9.d.ts → app-config-C0Bbw_Z6.d.ts} +18 -9
- package/dist/app-config.d.ts +1 -1
- package/dist/app-config.js.map +1 -1
- package/dist/auth.d.ts +1 -1
- package/dist/baerly.js +10 -10
- package/dist/baerly.js.map +1 -1
- package/dist/bytes-BXdamO3L.js +11 -0
- package/dist/bytes-BXdamO3L.js.map +1 -0
- package/dist/{client-BLf3Ae5s.d.ts → client-DYZfoZb9.d.ts} +3 -3
- package/dist/client-react.d.ts +3 -3
- package/dist/client.d.ts +3 -3
- package/dist/cloudflare.d.ts +31 -4
- package/dist/cloudflare.js +72 -6
- package/dist/cloudflare.js.map +1 -1
- package/dist/{config-Bsg8wgwo.js → config-DVfDGyw1.js} +82 -2
- package/dist/config-DVfDGyw1.js.map +1 -0
- package/dist/{context-Oj7ffwD-.js → context-DRZ3tZ5l.js} +3 -2
- package/dist/{context-Oj7ffwD-.js.map → context-DRZ3tZ5l.js.map} +1 -1
- package/dist/{cost-B1WiZxlf.js → cost-CQt1YRkA.js} +3 -4
- package/dist/{cost-B1WiZxlf.js.map → cost-CQt1YRkA.js.map} +1 -1
- package/dist/{current-json-BkatBzF7.js → current-json-C-EyJqs0.js} +107 -5
- package/dist/current-json-C-EyJqs0.js.map +1 -0
- package/dist/{db-D62JguBc.d.ts → db-BM3y2JQw.d.ts} +3 -3
- package/dist/{deploy-BB-wqbhf.js → deploy-CrAbfgCq.js} +2 -2
- package/dist/{deploy-BB-wqbhf.js.map → deploy-CrAbfgCq.js.map} +1 -1
- package/dist/dev-vite.d.ts +3 -3
- package/dist/dev-vite.js +3 -3
- package/dist/dev.d.ts +1 -1
- package/dist/dev.js +1 -1
- package/dist/{doctor-B8h9GCN9.js → doctor-Db-hzPmE.js} +144 -7
- package/dist/doctor-Db-hzPmE.js.map +1 -0
- package/dist/{dump-BHo_sIMZ.js → dump-BYA55NLP.js} +3 -4
- package/dist/{dump-BHo_sIMZ.js.map → dump-BYA55NLP.js.map} +1 -1
- package/dist/errors-DOdL95kK.js.map +1 -1
- package/dist/{export-Dz2PZKSR.js → export-Bhbz90-z.js} +4 -5
- package/dist/{export-Dz2PZKSR.js.map → export-Bhbz90-z.js.map} +1 -1
- package/dist/{fsck-DEz9lyCy.js → fsck-CPPZWt9p.js} +5 -8
- package/dist/fsck-CPPZWt9p.js.map +1 -0
- package/dist/{http-CjUO1Bec.js → http-Cw8p6y5b.js} +8 -8
- package/dist/{http-CjUO1Bec.js.map → http-Cw8p6y5b.js.map} +1 -1
- package/dist/http.d.ts +6 -6
- package/dist/http.js +1 -1
- package/dist/{index-BYv0hb8M.d.ts → index-C3JAH1Yo.d.ts} +14 -2
- package/dist/{index-BGC-ENnj.d.ts → index-DSvwEUeF.d.ts} +63 -54
- package/dist/{index-BquQkhJi.d.ts → index-DwDTWPSU.d.ts} +2 -2
- package/dist/{index-COsQ-Mlz.d.ts → index-cUY-36AN.d.ts} +3 -3
- package/dist/index.d.ts +5 -5
- package/dist/index.js +3 -3
- package/dist/{indexes-DwOXkn1Y.d.ts → indexes-DAu2AkTW.d.ts} +2 -2
- package/dist/{inspect-x02aFWnh.js → inspect-Bdbzvi-_.js} +5 -6
- package/dist/{inspect-x02aFWnh.js.map → inspect-Bdbzvi-_.js.map} +1 -1
- package/dist/maintenance-BRrThz8V.d.ts +449 -0
- package/dist/maintenance-BvOv6BMM.js +1295 -0
- package/dist/maintenance-BvOv6BMM.js.map +1 -0
- package/dist/maintenance-ClzBC1Vv.js +1895 -0
- package/dist/maintenance-ClzBC1Vv.js.map +1 -0
- package/dist/maintenance.d.ts +2 -323
- package/dist/maintenance.js +2 -2
- package/dist/node.d.ts +20 -79
- package/dist/node.js +2 -2
- package/dist/{observability-2IDYRuZK.js → observability-CpOiEN0k.js} +2 -2
- package/dist/{observability-2IDYRuZK.js.map → observability-CpOiEN0k.js.map} +1 -1
- package/dist/observability.d.ts +2 -2
- package/dist/observability.js +2 -2
- package/dist/{plan-Cs17VqjU.js → plan-DOTl21vq.js} +3 -4
- package/dist/{plan-Cs17VqjU.js.map → plan-DOTl21vq.js.map} +1 -1
- package/dist/{query-DcSbFLJt.js → query-BmiQy328.js} +58 -26
- package/dist/query-BmiQy328.js.map +1 -0
- package/dist/{rebuild-index-DwXM0WfA.js → rebuild-index-DC_nR6wP.js} +4 -5
- package/dist/{rebuild-index-DwXM0WfA.js.map → rebuild-index-DC_nR6wP.js.map} +1 -1
- package/dist/{restore-CbKVMMpm.js → restore-C6IcmLeA.js} +44 -120
- package/dist/restore-C6IcmLeA.js.map +1 -0
- package/dist/{log-walk-DIru96UT.js → snapshot-SS8USDUF.js} +187 -20
- package/dist/snapshot-SS8USDUF.js.map +1 -0
- package/dist/{src-DyET_VPP.js → src-DU1sCMlr.js} +315 -278
- package/dist/src-DU1sCMlr.js.map +1 -0
- package/dist/{src-n0Te1r98.js → src-QQ7jDeL2.js} +25 -6
- package/dist/src-QQ7jDeL2.js.map +1 -0
- package/dist/{src-Chafbw8r.js → src-zhEAmmF7.js} +35 -4
- package/dist/src-zhEAmmF7.js.map +1 -0
- package/dist/{bucket-uri-BrDEYvzy.js → subcommand-DZcHcsYp.js} +222 -22
- package/dist/subcommand-DZcHcsYp.js.map +1 -0
- package/dist/{usage-RVUQMLop.js → usage-CLjirdD-.js} +4 -4
- package/dist/{usage-RVUQMLop.js.map → usage-CLjirdD-.js.map} +1 -1
- package/dist/{validate-DhH1lO8I.js → validate-DCq_0DIn.js} +2 -2
- package/dist/validate-DCq_0DIn.js.map +1 -0
- package/package.json +13 -6
- package/dist/bucket-uri-BrDEYvzy.js.map +0 -1
- package/dist/config-Bsg8wgwo.js.map +0 -1
- package/dist/current-json-BkatBzF7.js.map +0 -1
- package/dist/doctor-B8h9GCN9.js.map +0 -1
- package/dist/fsck-DEz9lyCy.js.map +0 -1
- package/dist/indexes-BXn7a06a.js +0 -297
- package/dist/indexes-BXn7a06a.js.map +0 -1
- package/dist/log-walk-DIru96UT.js.map +0 -1
- package/dist/maintenance-Bn6ul9aV.js +0 -758
- package/dist/maintenance-Bn6ul9aV.js.map +0 -1
- package/dist/query-DcSbFLJt.js.map +0 -1
- package/dist/rebuild-index-C5gTXryd.js +0 -119
- package/dist/rebuild-index-C5gTXryd.js.map +0 -1
- package/dist/restore-CbKVMMpm.js.map +0 -1
- package/dist/snapshot-D7C4_FSl.js +0 -71
- package/dist/snapshot-D7C4_FSl.js.map +0 -1
- package/dist/snapshot-z_N9hpTe.js +0 -917
- package/dist/snapshot-z_N9hpTe.js.map +0 -1
- package/dist/src-Chafbw8r.js.map +0 -1
- package/dist/src-DyET_VPP.js.map +0 -1
- package/dist/src-n0Te1r98.js.map +0 -1
- package/dist/subcommand-BWs6K7zb.js +0 -110
- package/dist/subcommand-BWs6K7zb.js.map +0 -1
- package/dist/validate-DhH1lO8I.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { f as DocumentData, m as JSONValue, p as DocumentValue } from "./app-config-
|
|
1
|
+
import { f as DocumentData, m as JSONValue, p as DocumentValue } from "./app-config-C0Bbw_Z6.js";
|
|
2
2
|
//#region packages/protocol/src/storage/types.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Object-storage abstraction. The protocol kernel writes through
|
|
@@ -105,12 +105,16 @@ interface StorageListEntry {
|
|
|
105
105
|
readonly key: string;
|
|
106
106
|
readonly etag: string;
|
|
107
107
|
/**
|
|
108
|
-
* Server's `Last-Modified` for the listed object
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
108
|
+
* Server's `Last-Modified` for the listed object, when the backend
|
|
109
|
+
* surfaces it. GC uses it to anchor a tombstone's `due_at` to the
|
|
110
|
+
* object's server-side write time (`gc.ts`); when absent, GC falls
|
|
111
|
+
* back to the local clock (`now()`). It is therefore an optional
|
|
112
|
+
* precision hint, never load-bearing for correctness — impls
|
|
113
|
+
* without a server clock (e.g. {@link MemoryStorage}) may omit it.
|
|
114
|
+
*
|
|
115
|
+
* The protocol's clock-skew handling rides on
|
|
116
|
+
* {@link StoragePutResult.serverDate} (the write-time server clock),
|
|
117
|
+
* not on this field.
|
|
114
118
|
*/
|
|
115
119
|
readonly lastModified?: Date;
|
|
116
120
|
}
|
|
@@ -127,16 +131,16 @@ interface StorageListEntry {
|
|
|
127
131
|
*
|
|
128
132
|
* The schema is forward-compatible: adding a new optional field is
|
|
129
133
|
* non-breaking. Renaming or removing a field requires bumping
|
|
130
|
-
* {@link CURRENT_JSON_SCHEMA_VERSION}
|
|
134
|
+
* {@link CURRENT_JSON_SCHEMA_VERSION}; readers MUST reject
|
|
131
135
|
* unknown major versions with `BaerlyError{code:"InvalidResponse"}`.
|
|
132
136
|
*/
|
|
133
137
|
interface CurrentJson {
|
|
134
138
|
/**
|
|
135
|
-
* Schema version. Today: `
|
|
139
|
+
* Schema version. Today: `2`. Bump on any breaking change to
|
|
136
140
|
* field semantics; readers must reject unknown major versions
|
|
137
141
|
* with `BaerlyError{code:"InvalidResponse"}`.
|
|
138
142
|
*/
|
|
139
|
-
schema_version:
|
|
143
|
+
schema_version: 2;
|
|
140
144
|
/**
|
|
141
145
|
* Pointer to the current snapshot generation. `null` before the
|
|
142
146
|
* first compaction has produced a snapshot — readers fall back
|
|
@@ -171,6 +175,20 @@ interface CurrentJson {
|
|
|
171
175
|
* Embedded write-fence epoch. See {@link WriterFence}.
|
|
172
176
|
*/
|
|
173
177
|
writer_fence: WriterFence;
|
|
178
|
+
/** EXACT byte size of the live log tail [log_seq_start, next_seq). Maintained exactly
|
|
179
|
+
* by the full-fence CAS on BOTH paths: each write adds its log bytes; a successful
|
|
180
|
+
* fold (which proves no concurrent write) resets to 0 from a known-empty tail. */
|
|
181
|
+
tail_bytes: number;
|
|
182
|
+
/** Byte size of the snapshot pointed to by `snapshot`. */
|
|
183
|
+
snapshot_bytes: number;
|
|
184
|
+
/** Row count of the snapshot (= compactor `base.size`, free). With next_seq - log_seq_start
|
|
185
|
+
* (tail entries) this gives the fold's entry count for the ENTRY ceiling `E`. Seeded 0. */
|
|
186
|
+
snapshot_rows: number;
|
|
187
|
+
/** Baseline for rate-limiting the graduation defer-warn off SHARED durable state, not
|
|
188
|
+
* per-isolate memory. The warn fires when next_seq - last_warned_seq >=
|
|
189
|
+
* MAINTENANCE_WARN_INTERVAL_WRITES, and that firing CASes last_warned_seq = next_seq.
|
|
190
|
+
* Absent → 0. */
|
|
191
|
+
last_warned_seq?: number;
|
|
174
192
|
}
|
|
175
193
|
/**
|
|
176
194
|
* Fence-token sub-shape embedded in {@link CurrentJson}. The
|
|
@@ -799,6 +817,17 @@ declare class BaerlyError extends Error {
|
|
|
799
817
|
* ETags are a monotonically increasing hex counter formatted in the
|
|
800
818
|
* `"<hex>"` shape S3 returns (the surrounding double-quotes are part
|
|
801
819
|
* of the ETag header value). Keys are stored verbatim.
|
|
820
|
+
*
|
|
821
|
+
* **Test-confidence caveat:** every method resolves on the microtask
|
|
822
|
+
* queue with no real concurrency, so `put` reads `existing` and writes
|
|
823
|
+
* back with no interleaving. MemoryStorage therefore CANNOT exercise the
|
|
824
|
+
* compare-and-swap race the writer-fence model depends on — two writers
|
|
825
|
+
* contending on one `current.json` always serialize here, so a green run
|
|
826
|
+
* is necessary but not sufficient. That race is covered only by the
|
|
827
|
+
* randomized integration tests against real S3 / Minio
|
|
828
|
+
* (`tests/integration/randomized.test.ts`, `node-minio` variant).
|
|
829
|
+
* Relatedly, `serverDate` returns the local clock, not an independent
|
|
830
|
+
* server clock (see the `put` return below).
|
|
802
831
|
*/
|
|
803
832
|
declare class MemoryStorage implements Storage {
|
|
804
833
|
#private;
|
|
@@ -915,19 +944,20 @@ type Verifier = (req: Request) => Promise<VerifierResult | null>;
|
|
|
915
944
|
//#endregion
|
|
916
945
|
//#region packages/protocol/src/log.d.ts
|
|
917
946
|
/**
|
|
918
|
-
*
|
|
947
|
+
* Debezium-style JSON CDC envelope using pgoutput's message-tag (`I`/`U`/`D`) vocabulary. One per mutation.
|
|
919
948
|
*
|
|
920
|
-
* **
|
|
921
|
-
*
|
|
922
|
-
*
|
|
923
|
-
* a major-version
|
|
949
|
+
* **Pre-launch: the shape may still narrow.** Once the first production
|
|
950
|
+
* consumer ships, this becomes a frozen migration contract behind
|
|
951
|
+
* `baerly export --target=postgres` — the keys will be public, consumers
|
|
952
|
+
* ack on `lsn`, and any rename / removal will be a major-version
|
|
953
|
+
* migration.
|
|
924
954
|
*
|
|
925
955
|
* Field requirement matrix:
|
|
926
|
-
* - Always: `lsn`, `commit_ts`, `op`, `collection`, `
|
|
927
|
-
* `
|
|
956
|
+
* - Always: `lsn`, `commit_ts`, `op`, `collection`, `session`,
|
|
957
|
+
* `seq`.
|
|
928
958
|
* - For I/U/D: `doc_id`.
|
|
929
|
-
* - For I/U: `
|
|
930
|
-
* - Optional: `
|
|
959
|
+
* - For I/U: `after` (full post-image).
|
|
960
|
+
* - Optional: `before` (when `replica_identity === "FULL"`), `key_old`
|
|
931
961
|
* (U/D when `replica_identity !== "PATCH_ONLY"`), `origin`.
|
|
932
962
|
*
|
|
933
963
|
* @see docs/spec/log-entry-shape.md
|
|
@@ -952,16 +982,8 @@ interface LogEntry {
|
|
|
952
982
|
lsn: string;
|
|
953
983
|
/** ISO-8601 ms timestamp. Redundant with `lsn` but cheap. */
|
|
954
984
|
commit_ts: string;
|
|
955
|
-
/**
|
|
956
|
-
|
|
957
|
-
* `pg_logical_emit_message` analogue — useful for app-defined
|
|
958
|
-
* markers like deploy boundaries, snapshots, or out-of-band
|
|
959
|
-
* schema announcements consumed via `schema_version`. `T`
|
|
960
|
-
* truncates a whole collection. Today the emitter only produces
|
|
961
|
-
* `I`/`U`/`D`; `T` and `M` are shape-only for forward
|
|
962
|
-
* compatibility.
|
|
963
|
-
*/
|
|
964
|
-
op: "I" | "U" | "D" | "T" | "M";
|
|
985
|
+
/** Insert / Update / Delete. */
|
|
986
|
+
op: "I" | "U" | "D";
|
|
965
987
|
/**
|
|
966
988
|
* Collection name — the pgoutput RELATION analogue. Today derived
|
|
967
989
|
* from the path segment immediately under the manifest prefix
|
|
@@ -970,33 +992,20 @@ interface LogEntry {
|
|
|
970
992
|
* makes collections first-class.
|
|
971
993
|
*/
|
|
972
994
|
collection: string;
|
|
973
|
-
/** Required for I/U/D; omitted for T (TRUNCATE) and M (MESSAGE). */
|
|
974
|
-
doc_id?: string;
|
|
975
|
-
/**
|
|
976
|
-
* Monotonic per collection. Schema for the doc body is announced
|
|
977
|
-
* out-of-band via `M` (MESSAGE) entries; this field lets the
|
|
978
|
-
* consumer match a log entry to the schema in effect at write
|
|
979
|
-
* time. Forward-only — renaming or removing the field is a
|
|
980
|
-
* major-version migration; bumping the value is non-breaking.
|
|
981
|
-
* Inlining the schema in every entry was rejected as bloat for a
|
|
982
|
-
* field that changes rarely. Always `0` today; reserved for a
|
|
983
|
-
* future schema-versioning scheme.
|
|
984
|
-
*/
|
|
985
|
-
schema_version: number;
|
|
986
|
-
/** Required for I, U. The post-image. */
|
|
987
|
-
new?: DocumentData;
|
|
988
995
|
/**
|
|
989
|
-
*
|
|
990
|
-
* `
|
|
991
|
-
*
|
|
996
|
+
* The document key (`ref.key`). Required for every op — `op` is
|
|
997
|
+
* `I | U | D` and all three carry it — so the wire type is required,
|
|
998
|
+
* not optional, matching `log-entry-shape.md`.
|
|
992
999
|
*/
|
|
993
|
-
|
|
1000
|
+
doc_id: string;
|
|
1001
|
+
/** Required for I, U. The post-image (Debezium's `after`). */
|
|
1002
|
+
after?: DocumentData;
|
|
994
1003
|
/**
|
|
995
|
-
* The pre-image. Present iff the
|
|
996
|
-
* is `FULL`. ~2× log size on
|
|
997
|
-
* default.
|
|
1004
|
+
* The pre-image (Debezium's `before`). Present iff the
|
|
1005
|
+
* collection's `replica_identity` is `FULL`. ~2× log size on
|
|
1006
|
+
* update-heavy collections; off by default.
|
|
998
1007
|
*/
|
|
999
|
-
|
|
1008
|
+
before?: DocumentData;
|
|
1000
1009
|
/**
|
|
1001
1010
|
* Pre-image of the primary key. U/D always carry this when
|
|
1002
1011
|
* `replica_identity` is not `PATCH_ONLY`. (For Baerly today,
|
|
@@ -1061,5 +1070,5 @@ interface MetricsRecorder {
|
|
|
1061
1070
|
histogram(name: string, value: number, labels?: Readonly<Record<string, string>>): void;
|
|
1062
1071
|
}
|
|
1063
1072
|
//#endregion
|
|
1064
|
-
export {
|
|
1065
|
-
//# sourceMappingURL=index-
|
|
1073
|
+
export { StorageGetResult as _, MemoryStorage as a, StoragePutResult as b, Collection as c, Query as d, PredicateArg as f, StorageGetOptions as g, Storage as h, VerifierResult as i, OrderSpec as l, CurrentJsonRead as m, LogEntry as n, BaerlyError as o, CurrentJson as p, Verifier as r, BaerlyErrorCode as s, MetricsRecorder as t, Predicate as u, StorageListEntry as v, StoragePutOptions as y };
|
|
1074
|
+
//# sourceMappingURL=index-DSvwEUeF.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as
|
|
1
|
+
import { _ as StorageGetResult, b as StoragePutResult, g as StorageGetOptions, h as Storage, v as StorageListEntry, y as StoragePutOptions } from "./index-DSvwEUeF.js";
|
|
2
2
|
|
|
3
3
|
//#region packages/dev/src/dev-landing.d.ts
|
|
4
4
|
/**
|
|
@@ -109,4 +109,4 @@ declare class LocalFsStorage implements Storage {
|
|
|
109
109
|
}
|
|
110
110
|
//#endregion
|
|
111
111
|
export { renderDevLanding as a, DevLandingOptions as i, LocalFsStorageOptions as n, ensureTable as r, LocalFsStorage as t };
|
|
112
|
-
//# sourceMappingURL=index-
|
|
112
|
+
//# sourceMappingURL=index-DwDTWPSU.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { d as IndexDefinition, f as DocumentData, n as BaerlyAppConfig, r as BaerlyConfig, u as SchemaValidator } from "./app-config-
|
|
2
|
-
import {
|
|
1
|
+
import { d as IndexDefinition, f as DocumentData, n as BaerlyAppConfig, r as BaerlyConfig, u as SchemaValidator } from "./app-config-C0Bbw_Z6.js";
|
|
2
|
+
import { h as Storage, n as LogEntry, r as Verifier } from "./index-DSvwEUeF.js";
|
|
3
3
|
//#region packages/server/src/config.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Flatten `BaerlyConfig.collections` into the per-collection
|
|
@@ -143,4 +143,4 @@ declare const walkLogRange: (storage: Storage, logPrefix: string, fromSeq: numbe
|
|
|
143
143
|
}) => Promise<LogEntry[]>;
|
|
144
144
|
//#endregion
|
|
145
145
|
export { snapshotKey as a, loadSnapshotAsMap as i, SnapshotBody as n, resolveVerifier as o, encodeSnapshotBody as r, collectionsToMaps as s, walkLogRange as t };
|
|
146
|
-
//# sourceMappingURL=index-
|
|
146
|
+
//# sourceMappingURL=index-cUY-36AN.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as CollectionNames, c as defineConfig, d as IndexDefinition, f as DocumentData, i as CollectionDefinition, l as SchemaIssue, n as BaerlyAppConfig, o as RowOf, r as BaerlyConfig, s as UnboundConfig, u as SchemaValidator } from "./app-config-
|
|
2
|
-
import { _ as
|
|
3
|
-
import {
|
|
4
|
-
import { t as
|
|
5
|
-
import { n as validateOrThrow, t as Db } from "./db-
|
|
1
|
+
import { a as CollectionNames, c as defineConfig, d as IndexDefinition, f as DocumentData, i as CollectionDefinition, l as SchemaIssue, n as BaerlyAppConfig, o as RowOf, r as BaerlyConfig, s as UnboundConfig, u as SchemaValidator } from "./app-config-C0Bbw_Z6.js";
|
|
2
|
+
import { _ as StorageGetResult, a as MemoryStorage, b as StoragePutResult, c as Collection, d as Query, h as Storage, i as VerifierResult, o as BaerlyError, r as Verifier, s as BaerlyErrorCode, v as StorageListEntry } from "./index-DSvwEUeF.js";
|
|
3
|
+
import { t as allIndexKeysFor } from "./indexes-DAu2AkTW.js";
|
|
4
|
+
import { a as snapshotKey, i as loadSnapshotAsMap, n as SnapshotBody, o as resolveVerifier, r as encodeSnapshotBody, s as collectionsToMaps, t as walkLogRange } from "./index-cUY-36AN.js";
|
|
5
|
+
import { n as validateOrThrow, t as Db } from "./db-BM3y2JQw.js";
|
|
6
6
|
export { type BaerlyAppConfig, type BaerlyConfig, BaerlyError, type BaerlyErrorCode, type Collection, type CollectionDefinition, type CollectionNames, Db, type DocumentData, type IndexDefinition, MemoryStorage, type Query, type RowOf, type SchemaIssue, type SchemaValidator, type SnapshotBody, type Storage, type StorageGetResult, type StorageListEntry, type StoragePutResult, type UnboundConfig, type Verifier, type VerifierResult, allIndexKeysFor, collectionsToMaps, defineConfig, encodeSnapshotBody, loadSnapshotAsMap, resolveVerifier, snapshotKey, validateOrThrow, walkLogRange };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineConfig } from "./app-config.js";
|
|
2
2
|
import { t as BaerlyError } from "./errors-DOdL95kK.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { i as MemoryStorage, n as resolveVerifier, r as collectionsToMaps, t as Db } from "./src-
|
|
3
|
+
import { d as loadSnapshotAsMap, f as snapshotKey, g as allIndexKeysFor, h as walkLogRange, u as encodeSnapshotBody } from "./maintenance-ClzBC1Vv.js";
|
|
4
|
+
import { o as validateOrThrow } from "./query-BmiQy328.js";
|
|
5
|
+
import { i as MemoryStorage, n as resolveVerifier, r as collectionsToMaps, t as Db } from "./src-zhEAmmF7.js";
|
|
6
6
|
export { BaerlyError, Db, MemoryStorage, allIndexKeysFor, collectionsToMaps, defineConfig, encodeSnapshotBody, loadSnapshotAsMap, resolveVerifier, snapshotKey, validateOrThrow, walkLogRange };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as IndexDefinition, f as DocumentData } from "./app-config-
|
|
1
|
+
import { d as IndexDefinition, f as DocumentData } from "./app-config-C0Bbw_Z6.js";
|
|
2
2
|
//#region packages/server/src/indexes.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Compute the full index-key set a single doc produces under every
|
|
@@ -19,4 +19,4 @@ import { d as IndexDefinition, f as DocumentData } from "./app-config-Cb5dO2s9.j
|
|
|
19
19
|
declare const allIndexKeysFor: (logPrefix: string, defs: ReadonlyArray<IndexDefinition>, body: DocumentData | undefined, docId: string) => string[];
|
|
20
20
|
//#endregion
|
|
21
21
|
export { allIndexKeysFor as t };
|
|
22
|
-
//# sourceMappingURL=indexes-
|
|
22
|
+
//# sourceMappingURL=indexes-DAu2AkTW.d.ts.map
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { n as loadCollectionIndexes } from "./config-DVfDGyw1.js";
|
|
2
|
+
import { f as readCurrentJson } from "./snapshot-SS8USDUF.js";
|
|
3
|
+
import { n as parseBucketUri, t as defineBaerlySubcommand } from "./subcommand-DZcHcsYp.js";
|
|
4
4
|
import { i as isJsonMode, o as BaerlyError, r as emitSuccess } from "./baerly.js";
|
|
5
|
-
import { n as loadMaterialisedView } from "./plan-
|
|
6
|
-
import { t as defineBaerlySubcommand } from "./subcommand-BWs6K7zb.js";
|
|
5
|
+
import { n as loadMaterialisedView } from "./plan-DOTl21vq.js";
|
|
7
6
|
//#region src/inspect.ts
|
|
8
7
|
const INSPECT_ARGS = {
|
|
9
8
|
bucket: {
|
|
@@ -146,4 +145,4 @@ bundle.run;
|
|
|
146
145
|
//#endregion
|
|
147
146
|
export { inspect };
|
|
148
147
|
|
|
149
|
-
//# sourceMappingURL=inspect-
|
|
148
|
+
//# sourceMappingURL=inspect-Bdbzvi-_.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inspect-x02aFWnh.js","names":[],"sources":["../packages/cli/src/inspect.ts"],"sourcesContent":["/**\n * `baerly inspect` — read-only summary for one collection.\n *\n * Args:\n * --bucket Required. Bucket URI.\n * --app Required (or via baerly.config.ts).\n * --tenant Required (or via baerly.config.ts).\n * --collection Required. Collection name.\n * --config Optional path to baerly.config.{js,mjs,json} for index info.\n * --json JSON envelope.\n *\n * Reports, per-collection:\n * - currentJsonKey path.\n * - schema_version, next_seq, log_seq_start (default 0).\n * - live_log_tail (= next_seq - log_seq_start).\n * - snapshot key (or null).\n * - writer_fence (epoch, owner, claimed_at).\n * - materialised row count (via export/loadMaterialisedView).\n * - per-declared-index key count (when --config supplied).\n * - well-formed status: \"ok\" or \"error\" with an `errors` array.\n *\n * For projected monthly Class A / $ trajectories, use\n * `baerly cost --collection=<name>` — the projection used to live as a\n * footer here but moved to its own verb so inspect stays a glance\n * command (no GET-storm over the trailing log sample).\n *\n * Cost shape:\n * 1 GET current.json\n * + 1 GET snapshot (if any)\n * + N GETs log tail (= next_seq - log_seq_start)\n * + K LISTs (one per declared index, when --config supplied)\n * + 1 LIST snapshot/ prefix (orphan detection)\n *\n * Never mutates anything.\n *\n * Exit codes:\n * 0 — inspection ran (status may be \"ok\" or \"error\"; both exit 0).\n * 1 — InvalidConfig (bad bucket URI, missing args, unknown flag).\n * 2 — Storage / Network error.\n * 3 — Protocol invariant (Conflict / Internal / InvalidResponse).\n */\n\nimport { type ArgsDef } from \"citty\";\nimport { BaerlyError, readCurrentJson, type CurrentJson, type Storage } from \"@baerly/protocol\";\nimport { loadMaterialisedView } from \"./export/index.ts\";\nimport { loadCollectionIndexes } from \"./config.ts\";\nimport { parseBucketUri } from \"./bucket-uri.ts\";\nimport { emitSuccess, isJsonMode } from \"./output.ts\";\nimport { defineBaerlySubcommand } from \"./subcommand.ts\";\n\nconst INSPECT_ARGS = {\n bucket: {\n type: \"string\",\n required: true,\n description: \"Bucket URI (s3://<bucket>[/<prefix>], file:///<abs>, memory://<bucket>)\",\n valueHint: \"bucket-uri\",\n },\n app: {\n type: \"string\",\n required: false,\n description: \"Application name segment (defaults to baerly.config.ts).\",\n valueHint: \"app\",\n },\n tenant: {\n type: \"string\",\n required: false,\n description: \"Tenant name segment (defaults to baerly.config.ts).\",\n valueHint: \"tenant\",\n },\n collection: {\n type: \"string\",\n required: true,\n description: \"Collection name.\",\n valueHint: \"name\",\n },\n config: {\n type: \"string\",\n required: false,\n description:\n \"Path to baerly.config.{js,mjs,json}; pulls declared indexes for key-count probes.\",\n valueHint: \"path\",\n },\n json: {\n type: \"boolean\",\n description: \"Emit a structured JSON envelope to stdout (success) or stderr (error)\",\n },\n} as const satisfies ArgsDef;\n\nconst countListEntries = async (\n storage: Storage,\n prefix: string,\n): Promise<{ count: number; keys: string[] }> => {\n let count = 0;\n const keys: string[] = [];\n for await (const entry of storage.list(prefix)) {\n count++;\n keys.push(entry.key);\n }\n return { count, keys };\n};\n\ninterface InspectResult {\n currentJsonKey: string;\n schema_version: number;\n next_seq: number;\n log_seq_start: number;\n live_log_tail: number;\n snapshot: string | null;\n writer_fence: CurrentJson[\"writer_fence\"];\n materialised_rows: number;\n indexes: { name: string; count: number }[];\n status: \"ok\" | \"error\";\n errors: string[];\n}\n\nconst renderText = (r: InspectResult, collection: string): string => {\n const lines: string[] = [];\n lines.push(`baerly inspect ${collection}`);\n lines.push(` current.json: ${r.currentJsonKey}`);\n lines.push(` schema_version: ${r.schema_version}`);\n lines.push(` next_seq: ${r.next_seq}`);\n lines.push(` log_seq_start: ${r.log_seq_start}`);\n lines.push(` live_log_tail: ${r.live_log_tail}`);\n lines.push(` snapshot: ${r.snapshot ?? \"(none)\"}`);\n lines.push(\n ` writer_fence: epoch=${r.writer_fence.epoch} owner=${JSON.stringify(r.writer_fence.owner)} claimed_at=${JSON.stringify(r.writer_fence.claimed_at)}`,\n );\n lines.push(` materialised_rows: ${r.materialised_rows}`);\n if (r.indexes.length > 0) {\n const formatted = r.indexes.map((i) => `${i.name} (count=${i.count})`).join(\", \");\n lines.push(` indexes: ${formatted}`);\n } else {\n lines.push(` indexes: (none declared)`);\n }\n lines.push(` status: ${r.status}`);\n if (r.errors.length > 0) {\n for (const e of r.errors) {\n lines.push(` error: ${e}`);\n }\n }\n return lines.join(\"\\n\") + \"\\n\";\n};\n\nconst bundle = defineBaerlySubcommand({\n name: \"inspect\",\n meta: {\n description: \"Read-only summary of one collection's snapshot + log state.\",\n },\n args: INSPECT_ARGS,\n handler: async (args, ctx) => {\n const bucket = await parseBucketUri(args.bucket);\n const { app, tenant } = await ctx.resolveAppTenant({ app: args.app, tenant: args.tenant });\n const collectionPrefix = `${bucket.keyPrefix}app/${app}/tenant/${tenant}/manifests/${args.collection}`;\n const currentJsonKey = `${collectionPrefix}/current.json`;\n\n const read = await readCurrentJson(bucket.storage, currentJsonKey);\n if (read === null) {\n throw new BaerlyError(\n \"InvalidConfig\",\n `baerly inspect: current.json not found at ${currentJsonKey}`,\n );\n }\n const cur = read.json;\n const log_seq_start = cur.log_seq_start ?? 0;\n\n const errors: string[] = [];\n let materialisedRows = 0;\n try {\n const view = await loadMaterialisedView({\n storage: bucket.storage,\n currentJsonKey,\n collection: args.collection,\n });\n materialisedRows = view?.size ?? 0;\n } catch (error) {\n if (error instanceof BaerlyError) {\n errors.push(`${error.code}: ${error.message}`);\n } else {\n errors.push((error as Error).message);\n }\n }\n\n // Orphan-snapshot detection: list every file under <collectionPrefix>/snapshot/\n // and flag anything that isn't the currently-pointed-at snapshot.\n try {\n const snapshotPrefix = `${collectionPrefix}/snapshot/`;\n const { keys } = await countListEntries(bucket.storage, snapshotPrefix);\n for (const k of keys) {\n if (cur.snapshot !== k) {\n errors.push(`orphan snapshot: ${k}`);\n }\n }\n } catch (error) {\n if (error instanceof BaerlyError) {\n errors.push(`${error.code}: ${error.message}`);\n }\n }\n\n const indexes: { name: string; count: number }[] = [];\n if (typeof args.config === \"string\" && args.config.length > 0) {\n const defs = await loadCollectionIndexes(args.config, args.collection, \"baerly inspect\");\n for (const def of defs) {\n const prefix = `${collectionPrefix}/index/${def.name}/`;\n const { count } = await countListEntries(bucket.storage, prefix);\n indexes.push({ name: def.name, count });\n }\n }\n\n const result: InspectResult = {\n currentJsonKey,\n schema_version: cur.schema_version,\n next_seq: cur.next_seq,\n log_seq_start,\n live_log_tail: cur.next_seq - log_seq_start,\n snapshot: cur.snapshot,\n writer_fence: cur.writer_fence,\n materialised_rows: materialisedRows,\n indexes,\n status: errors.length === 0 ? \"ok\" : \"error\",\n errors,\n };\n\n if (isJsonMode()) {\n emitSuccess({ command: \"inspect\", ...result });\n } else {\n process.stdout.write(renderText(result, args.collection));\n }\n return 0;\n },\n});\n\n/** citty `defineCommand` block for `baerly inspect`. */\nexport const inspect = bundle.cmd;\n\n/**\n * Programmatic entry used by tests. Bypasses citty's `run` wrapper\n * (which would call `process.exit` and kill vitest) and returns the\n * integer exit code directly.\n */\nexport const runInspect = bundle.run;\n"],"mappings":";;;;;;;AAkDA,MAAM,eAAe;CACnB,QAAQ;EACN,MAAM;EACN,UAAU;EACV,aAAa;EACb,WAAW;CACb;CACA,KAAK;EACH,MAAM;EACN,UAAU;EACV,aAAa;EACb,WAAW;CACb;CACA,QAAQ;EACN,MAAM;EACN,UAAU;EACV,aAAa;EACb,WAAW;CACb;CACA,YAAY;EACV,MAAM;EACN,UAAU;EACV,aAAa;EACb,WAAW;CACb;CACA,QAAQ;EACN,MAAM;EACN,UAAU;EACV,aACE;EACF,WAAW;CACb;CACA,MAAM;EACJ,MAAM;EACN,aAAa;CACf;AACF;AAEA,MAAM,mBAAmB,OACvB,SACA,WAC+C;CAC/C,IAAI,QAAQ;CACZ,MAAM,OAAiB,CAAC;CACxB,WAAW,MAAM,SAAS,QAAQ,KAAK,MAAM,GAAG;EAC9C;EACA,KAAK,KAAK,MAAM,GAAG;CACrB;CACA,OAAO;EAAE;EAAO;CAAK;AACvB;AAgBA,MAAM,cAAc,GAAkB,eAA+B;CACnE,MAAM,QAAkB,CAAC;CACzB,MAAM,KAAK,kBAAkB,YAAY;CACzC,MAAM,KAAK,0BAA0B,EAAE,gBAAgB;CACvD,MAAM,KAAK,0BAA0B,EAAE,gBAAgB;CACvD,MAAM,KAAK,0BAA0B,EAAE,UAAU;CACjD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ACT;AACF,CAAC;;AAGD,MAAa,UAAU,OAAO;AAOJ,OAAO"}
|
|
1
|
+
{"version":3,"file":"inspect-Bdbzvi-_.js","names":[],"sources":["../packages/cli/src/inspect.ts"],"sourcesContent":["/**\n * `baerly inspect` — read-only summary for one collection.\n *\n * Args:\n * --bucket Required. Bucket URI.\n * --app Required (or via baerly.config.ts).\n * --tenant Required (or via baerly.config.ts).\n * --collection Required. Collection name.\n * --config Optional path to baerly.config.{js,mjs,json} for index info.\n * --json JSON envelope.\n *\n * Reports, per-collection:\n * - currentJsonKey path.\n * - schema_version, next_seq, log_seq_start (default 0).\n * - live_log_tail (= next_seq - log_seq_start).\n * - snapshot key (or null).\n * - writer_fence (epoch, owner, claimed_at).\n * - materialised row count (via export/loadMaterialisedView).\n * - per-declared-index key count (when --config supplied).\n * - well-formed status: \"ok\" or \"error\" with an `errors` array.\n *\n * For projected monthly Class A / $ trajectories, use\n * `baerly cost --collection=<name>` — the projection used to live as a\n * footer here but moved to its own verb so inspect stays a glance\n * command (no GET-storm over the trailing log sample).\n *\n * Cost shape:\n * 1 GET current.json\n * + 1 GET snapshot (if any)\n * + N GETs log tail (= next_seq - log_seq_start)\n * + K LISTs (one per declared index, when --config supplied)\n * + 1 LIST snapshot/ prefix (orphan detection)\n *\n * Never mutates anything.\n *\n * Exit codes:\n * 0 — inspection ran (status may be \"ok\" or \"error\"; both exit 0).\n * 1 — InvalidConfig (bad bucket URI, missing args, unknown flag).\n * 2 — Storage / Network error.\n * 3 — Protocol invariant (Conflict / Internal / InvalidResponse).\n */\n\nimport { type ArgsDef } from \"citty\";\nimport { BaerlyError, readCurrentJson, type CurrentJson, type Storage } from \"@baerly/protocol\";\nimport { loadMaterialisedView } from \"./export/index.ts\";\nimport { loadCollectionIndexes } from \"./config.ts\";\nimport { parseBucketUri } from \"./bucket-uri.ts\";\nimport { emitSuccess, isJsonMode } from \"./output.ts\";\nimport { defineBaerlySubcommand } from \"./subcommand.ts\";\n\nconst INSPECT_ARGS = {\n bucket: {\n type: \"string\",\n required: true,\n description: \"Bucket URI (s3://<bucket>[/<prefix>], file:///<abs>, memory://<bucket>)\",\n valueHint: \"bucket-uri\",\n },\n app: {\n type: \"string\",\n required: false,\n description: \"Application name segment (defaults to baerly.config.ts).\",\n valueHint: \"app\",\n },\n tenant: {\n type: \"string\",\n required: false,\n description: \"Tenant name segment (defaults to baerly.config.ts).\",\n valueHint: \"tenant\",\n },\n collection: {\n type: \"string\",\n required: true,\n description: \"Collection name.\",\n valueHint: \"name\",\n },\n config: {\n type: \"string\",\n required: false,\n description:\n \"Path to baerly.config.{js,mjs,json}; pulls declared indexes for key-count probes.\",\n valueHint: \"path\",\n },\n json: {\n type: \"boolean\",\n description: \"Emit a structured JSON envelope to stdout (success) or stderr (error)\",\n },\n} as const satisfies ArgsDef;\n\nconst countListEntries = async (\n storage: Storage,\n prefix: string,\n): Promise<{ count: number; keys: string[] }> => {\n let count = 0;\n const keys: string[] = [];\n for await (const entry of storage.list(prefix)) {\n count++;\n keys.push(entry.key);\n }\n return { count, keys };\n};\n\ninterface InspectResult {\n currentJsonKey: string;\n schema_version: number;\n next_seq: number;\n log_seq_start: number;\n live_log_tail: number;\n snapshot: string | null;\n writer_fence: CurrentJson[\"writer_fence\"];\n materialised_rows: number;\n indexes: { name: string; count: number }[];\n status: \"ok\" | \"error\";\n errors: string[];\n}\n\nconst renderText = (r: InspectResult, collection: string): string => {\n const lines: string[] = [];\n lines.push(`baerly inspect ${collection}`);\n lines.push(` current.json: ${r.currentJsonKey}`);\n lines.push(` schema_version: ${r.schema_version}`);\n lines.push(` next_seq: ${r.next_seq}`);\n lines.push(` log_seq_start: ${r.log_seq_start}`);\n lines.push(` live_log_tail: ${r.live_log_tail}`);\n lines.push(` snapshot: ${r.snapshot ?? \"(none)\"}`);\n lines.push(\n ` writer_fence: epoch=${r.writer_fence.epoch} owner=${JSON.stringify(r.writer_fence.owner)} claimed_at=${JSON.stringify(r.writer_fence.claimed_at)}`,\n );\n lines.push(` materialised_rows: ${r.materialised_rows}`);\n if (r.indexes.length > 0) {\n const formatted = r.indexes.map((i) => `${i.name} (count=${i.count})`).join(\", \");\n lines.push(` indexes: ${formatted}`);\n } else {\n lines.push(` indexes: (none declared)`);\n }\n lines.push(` status: ${r.status}`);\n if (r.errors.length > 0) {\n for (const e of r.errors) {\n lines.push(` error: ${e}`);\n }\n }\n return lines.join(\"\\n\") + \"\\n\";\n};\n\nconst bundle = defineBaerlySubcommand({\n name: \"inspect\",\n meta: {\n description: \"Read-only summary of one collection's snapshot + log state.\",\n },\n args: INSPECT_ARGS,\n handler: async (args, ctx) => {\n const bucket = await parseBucketUri(args.bucket);\n const { app, tenant } = await ctx.resolveAppTenant({ app: args.app, tenant: args.tenant });\n const collectionPrefix = `${bucket.keyPrefix}app/${app}/tenant/${tenant}/manifests/${args.collection}`;\n const currentJsonKey = `${collectionPrefix}/current.json`;\n\n const read = await readCurrentJson(bucket.storage, currentJsonKey);\n if (read === null) {\n throw new BaerlyError(\n \"InvalidConfig\",\n `baerly inspect: current.json not found at ${currentJsonKey}`,\n );\n }\n const cur = read.json;\n const log_seq_start = cur.log_seq_start ?? 0;\n\n const errors: string[] = [];\n let materialisedRows = 0;\n try {\n const view = await loadMaterialisedView({\n storage: bucket.storage,\n currentJsonKey,\n collection: args.collection,\n });\n materialisedRows = view?.size ?? 0;\n } catch (error) {\n if (error instanceof BaerlyError) {\n errors.push(`${error.code}: ${error.message}`);\n } else {\n errors.push((error as Error).message);\n }\n }\n\n // Orphan-snapshot detection: list every file under <collectionPrefix>/snapshot/\n // and flag anything that isn't the currently-pointed-at snapshot.\n try {\n const snapshotPrefix = `${collectionPrefix}/snapshot/`;\n const { keys } = await countListEntries(bucket.storage, snapshotPrefix);\n for (const k of keys) {\n if (cur.snapshot !== k) {\n errors.push(`orphan snapshot: ${k}`);\n }\n }\n } catch (error) {\n if (error instanceof BaerlyError) {\n errors.push(`${error.code}: ${error.message}`);\n }\n }\n\n const indexes: { name: string; count: number }[] = [];\n if (typeof args.config === \"string\" && args.config.length > 0) {\n const defs = await loadCollectionIndexes(args.config, args.collection, \"baerly inspect\");\n for (const def of defs) {\n const prefix = `${collectionPrefix}/index/${def.name}/`;\n const { count } = await countListEntries(bucket.storage, prefix);\n indexes.push({ name: def.name, count });\n }\n }\n\n const result: InspectResult = {\n currentJsonKey,\n schema_version: cur.schema_version,\n next_seq: cur.next_seq,\n log_seq_start,\n live_log_tail: cur.next_seq - log_seq_start,\n snapshot: cur.snapshot,\n writer_fence: cur.writer_fence,\n materialised_rows: materialisedRows,\n indexes,\n status: errors.length === 0 ? \"ok\" : \"error\",\n errors,\n };\n\n if (isJsonMode()) {\n emitSuccess({ command: \"inspect\", ...result });\n } else {\n process.stdout.write(renderText(result, args.collection));\n }\n return 0;\n },\n});\n\n/** citty `defineCommand` block for `baerly inspect`. */\nexport const inspect = bundle.cmd;\n\n/**\n * Programmatic entry used by tests. Bypasses citty's `run` wrapper\n * (which would call `process.exit` and kill vitest) and returns the\n * integer exit code directly.\n */\nexport const runInspect = bundle.run;\n"],"mappings":";;;;;;AAkDA,MAAM,eAAe;CACnB,QAAQ;EACN,MAAM;EACN,UAAU;EACV,aAAa;EACb,WAAW;CACb;CACA,KAAK;EACH,MAAM;EACN,UAAU;EACV,aAAa;EACb,WAAW;CACb;CACA,QAAQ;EACN,MAAM;EACN,UAAU;EACV,aAAa;EACb,WAAW;CACb;CACA,YAAY;EACV,MAAM;EACN,UAAU;EACV,aAAa;EACb,WAAW;CACb;CACA,QAAQ;EACN,MAAM;EACN,UAAU;EACV,aACE;EACF,WAAW;CACb;CACA,MAAM;EACJ,MAAM;EACN,aAAa;CACf;AACF;AAEA,MAAM,mBAAmB,OACvB,SACA,WAC+C;CAC/C,IAAI,QAAQ;CACZ,MAAM,OAAiB,CAAC;CACxB,WAAW,MAAM,SAAS,QAAQ,KAAK,MAAM,GAAG;EAC9C;EACA,KAAK,KAAK,MAAM,GAAG;CACrB;CACA,OAAO;EAAE;EAAO;CA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