@lossless.org/client 1.18.1 → 1.18.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.
@@ -3,7 +3,7 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@lossless.org/client',
6
- version: '1.18.1',
6
+ version: '1.18.2',
7
7
  description: 'One typed client for NoSQLDB, MongoDB, SQLDB, MariaDB, ClickHouse and S3 object storage.'
8
8
  };
9
9
  //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMDBfY29tbWl0aW5mb19kYXRhLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvMDBfY29tbWl0aW5mb19kYXRhLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBQ0gsTUFBTSxDQUFDLE1BQU0sVUFBVSxHQUFHO0lBQ3hCLElBQUksRUFBRSxzQkFBc0I7SUFDNUIsT0FBTyxFQUFFLFFBQVE7SUFDakIsV0FBVyxFQUFFLDBGQUEwRjtDQUN4RyxDQUFBIn0=
@@ -1,2 +1,6 @@
1
- /** @internal Shared ordinary/exact assertion invariant. */
2
- export declare const assertBsonWithoutMutation: (documentArg: object, assertionArg: (valueArg: unknown) => void, errorArg: (reasonArg: "assertion" | "bson" | "mutation", causeArg?: unknown) => Error) => void;
1
+ /**
2
+ * @internal Shared ordinary/exact assertion invariant. `beforeArg` is the
3
+ * document's BSON encoding before the assertion runs; `encodeArg` encodes it
4
+ * again afterwards, and any difference is a mutation.
5
+ */
6
+ export declare const assertBsonWithoutMutation: (documentArg: object, beforeArg: Uint8Array, encodeArg: (documentArg: object) => Uint8Array, assertionArg: (valueArg: unknown) => void, errorArg: (reasonArg: "assertion" | "bson" | "mutation", causeArg?: unknown) => Error) => void;
@@ -1,7 +1,9 @@
1
- import * as plugins from './plugins.js';
2
- /** @internal Shared ordinary/exact assertion invariant. */
3
- export const assertBsonWithoutMutation = (documentArg, assertionArg, errorArg) => {
4
- const before = plugins.mongodb.BSON.serialize(documentArg);
1
+ /**
2
+ * @internal Shared ordinary/exact assertion invariant. `beforeArg` is the
3
+ * document's BSON encoding before the assertion runs; `encodeArg` encodes it
4
+ * again afterwards, and any difference is a mutation.
5
+ */
6
+ export const assertBsonWithoutMutation = (documentArg, beforeArg, encodeArg, assertionArg, errorArg) => {
5
7
  try {
6
8
  const result = assertionArg(documentArg);
7
9
  if (result !== undefined) {
@@ -17,13 +19,13 @@ export const assertBsonWithoutMutation = (documentArg, assertionArg, errorArg) =
17
19
  }
18
20
  let after;
19
21
  try {
20
- after = plugins.mongodb.BSON.serialize(documentArg);
22
+ after = encodeArg(documentArg);
21
23
  }
22
24
  catch (causeArg) {
23
25
  throw errorArg('bson', causeArg);
24
26
  }
25
- if (before.length !== after.length || before.some((valueArg, indexArg) => valueArg !== after[indexArg])) {
27
+ if (Buffer.compare(beforeArg, after) !== 0) {
26
28
  throw errorArg('mutation');
27
29
  }
28
30
  };
29
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2xhc3Nlcy5ic29uYXNzZXJ0aW9uLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vdHMvbm9zcWxkYi9jbGFzc2VzLmJzb25hc3NlcnRpb24udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLE9BQU8sTUFBTSxjQUFjLENBQUM7QUFFeEMsMkRBQTJEO0FBQzNELE1BQU0sQ0FBQyxNQUFNLHlCQUF5QixHQUFHLENBQ3ZDLFdBQW1CLEVBQ25CLFlBQXlDLEVBQ3pDLFFBQXFGLEVBQy9FLEVBQUU7SUFDUixNQUFNLE1BQU0sR0FBRyxPQUFPLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxTQUFTLENBQUMsV0FBVyxDQUFDLENBQUM7SUFDM0QsSUFBSSxDQUFDO1FBQ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MsT0FBTyxDQUFDLFNBQVMsRUFBRSxLQUFLLENBQUMsS0FBSyxDQUFDLEVBQUUsQ0FBQztRQUMzQyxNQUFNLFFBQVEsQ0FBQyxVQUFVLENBQUMsQ0FBQztJQUM3QixDQUFDO0FBQ0gsQ0FBQyxDQUFDIn0=
@@ -132,16 +132,52 @@ export declare class SmartdataExactCollection<TModel extends SmartDataDbDoc<any,
132
132
  * reconciliation read runs on the interrupted call's budget.
133
133
  */
134
134
  private interruptedWriteError;
135
+ /** The collection's one BSON encoder: every encoding of a row passes here. */
136
+ private encodeBson;
137
+ /** The collection's one BSON decoder: every decoding of a row passes here. */
138
+ private decodeBson;
139
+ /** Decodes proven canonical bytes into a fresh canonical document. */
140
+ private decodeCanonical;
141
+ /**
142
+ * The exactness proof: the document's sorted encoding must decode and
143
+ * encode again to the same bytes. Returns those canonical bytes and the
144
+ * decoding the proof produced, which no caller has seen yet.
145
+ */
135
146
  private canonicalizeDocument;
147
+ /**
148
+ * Whether a document encodes canonically to bytes an earlier proof
149
+ * produced. Equal bytes carry that proof and its assertion over, so the
150
+ * caller needs neither again; on a mismatch the caller runs the full proof
151
+ * to report what is wrong.
152
+ */
153
+ private encodesAs;
136
154
  private assertAllowedTopLevelKeys;
137
- private canonicalizePersistedDocument;
138
- private canonicalizeStoredDocument;
155
+ /**
156
+ * Proves an application body canonical and runs the assertion once, on the
157
+ * proof's own decoding, which is never handed out. Returns the canonical
158
+ * bytes of the body.
159
+ */
160
+ private provePersistedDocument;
161
+ /**
162
+ * Proves a stored envelope canonical, checks its storage metadata and runs
163
+ * the assertion once on its body. The body is the proof's own decoding with
164
+ * the metadata removed, so the assertion never sees a document a caller
165
+ * receives. Returns the canonical bytes of the envelope and of its body.
166
+ */
167
+ private proveStoredDocument;
168
+ /** Proves a stored envelope and returns a fresh canonical decoding of it. */
169
+ private readStoredDocument;
170
+ /**
171
+ * The canonical envelope of a proven body. BSON encodes every element on
172
+ * its own, so a proven body with inert metadata is canonical as a whole;
173
+ * only the canonical key order has to be restored.
174
+ */
175
+ private composeStoredDocument;
139
176
  private assertWithoutMutation;
140
- private getPersistedBody;
141
- private persistedDocumentsEqual;
142
- private storedDocumentsEqual;
143
177
  private validateReconcileIdentity;
178
+ /** The persisted body a model serializes to, before any proof. */
144
179
  private serializeModel;
180
+ /** Proves an insert input and returns the canonical bytes of its body. */
145
181
  private createPersistedDocument;
146
182
  private hydrateStoredDocument;
147
183
  private findByReconcileIdentity;