@omegup/msync 0.1.62 → 0.1.64
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/adapters/mongodb.d.ts +22 -0
- package/adapters/mongodb.esm.js +12 -0
- package/adapters/mongodb.esm.js.map +1 -0
- package/adapters/mongodb.js +14 -0
- package/adapters/mongodb.js.map +1 -0
- package/driver-BUCc3b89.js +31 -0
- package/driver-BUCc3b89.js.map +1 -0
- package/driver-sc6MCG57.esm.js +14 -0
- package/driver-sc6MCG57.esm.js.map +1 -0
- package/index.d.ts +1 -1
- package/index.esm.js +29 -103
- package/index.esm.js.map +1 -1
- package/index.js +29 -87
- package/index.js.map +1 -1
- package/lib/accumulators/index.d.ts +1 -1
- package/lib/aggregate/$merge.d.ts +5 -5
- package/lib/aggregate/group/utils/sub-merge.d.ts +2 -2
- package/lib/aggregate/prefix.d.ts +2 -2
- package/lib/boot/boot-utils.d.ts +2 -3
- package/lib/boot/boot.d.ts +2 -2
- package/lib/boot/first-stages.d.ts +1 -2
- package/lib/driver.d.ts +5 -0
- package/lib/expression/val.d.ts +1 -1
- package/lib/predicate/$eq.d.ts +1 -2
- package/lib/types/accumulator.d.ts +2 -2
- package/lib/types/aggregate.d.ts +4 -2
- package/lib/types/query.d.ts +1 -5
- package/lib/types/stream.d.ts +3 -4
- package/lib/utils/db-indexes.d.ts +1 -1
- package/lib/utils/map-object.d.ts +0 -4
- package/lib/utils/merge/combiners.d.ts +3 -2
- package/lib/utils/merge/merge.d.ts +3 -3
- package/lib/utils/merge/types.d.ts +4 -1
- package/lib/utils/merge/utils.d.ts +1 -0
- package/lib/watch.d.ts +2 -3
- package/package.json +41 -22
- package/types/global-aug.d.ts +4 -1
- package/types/json.d.ts +12 -4
- package/types/mongo.d.ts +84 -23
- package/types/view.d.ts +1 -2
- package/test/mongodb.d.ts +0 -9
- package/test/uri.d.ts +0 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import 'mongodb';
|
|
2
|
+
import type { BSON } from 'mongodb';
|
|
3
|
+
import type { Driver, RawStage } from '../types';
|
|
4
|
+
declare module 'mongodb' {
|
|
5
|
+
interface Collection<TSchema extends BSON.Document = BSON.Document> {
|
|
6
|
+
[RawStage]: {
|
|
7
|
+
(_: 2): TSchema;
|
|
8
|
+
(_: 1, x: TSchema): TSchema;
|
|
9
|
+
};
|
|
10
|
+
s: {
|
|
11
|
+
db: Db;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
interface Db {
|
|
15
|
+
s: {
|
|
16
|
+
client?: MongoClient;
|
|
17
|
+
};
|
|
18
|
+
client: MongoClient;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export declare const mongodbDriver: Driver;
|
|
22
|
+
export declare const useMongoDB: () => void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { n as useDriver } from "../driver-sc6MCG57.esm.js";
|
|
2
|
+
import { Timestamp, UUID } from "mongodb";
|
|
3
|
+
//#region .build/adapters/mongodb.js
|
|
4
|
+
const mongodbDriver = {
|
|
5
|
+
Timestamp,
|
|
6
|
+
UUID
|
|
7
|
+
};
|
|
8
|
+
const useMongoDB = () => useDriver(mongodbDriver);
|
|
9
|
+
//#endregion
|
|
10
|
+
export { mongodbDriver, useMongoDB };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=mongodb.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mongodb.esm.js","names":[],"sources":["../../.build/adapters/mongodb.js"],"sourcesContent":["import 'mongodb';\nimport { Timestamp, UUID } from 'mongodb';\nimport { useDriver } from '../lib/driver';\nexport const mongodbDriver = { Timestamp, UUID };\nexport const useMongoDB = () => useDriver(mongodbDriver);\n//# sourceMappingURL=mongodb.js.map"],"mappings":";;;AAGA,MAAa,gBAAgB;CAAE;CAAW;AAAK;AAC/C,MAAa,mBAAmB,UAAU,aAAa"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_driver = require("../driver-BUCc3b89.js");
|
|
3
|
+
let mongodb = require("mongodb");
|
|
4
|
+
//#region .build/adapters/mongodb.js
|
|
5
|
+
const mongodbDriver = {
|
|
6
|
+
Timestamp: mongodb.Timestamp,
|
|
7
|
+
UUID: mongodb.UUID
|
|
8
|
+
};
|
|
9
|
+
const useMongoDB = () => require_driver.useDriver(mongodbDriver);
|
|
10
|
+
//#endregion
|
|
11
|
+
exports.mongodbDriver = mongodbDriver;
|
|
12
|
+
exports.useMongoDB = useMongoDB;
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=mongodb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mongodb.js","names":["useDriver"],"sources":["../../.build/adapters/mongodb.js"],"sourcesContent":["import 'mongodb';\nimport { Timestamp, UUID } from 'mongodb';\nimport { useDriver } from '../lib/driver';\nexport const mongodbDriver = { Timestamp, UUID };\nexport const useMongoDB = () => useDriver(mongodbDriver);\n//# sourceMappingURL=mongodb.js.map"],"mappings":";;;;AAGA,MAAa,gBAAgB;CAAE,WAAA,QAAA;CAAW,MAAA,QAAA;AAAK;AAC/C,MAAa,mBAAmBA,eAAAA,UAAU,aAAa"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
//#region .build/lib/driver.js
|
|
2
|
+
let current;
|
|
3
|
+
const useDriver = (driver) => {
|
|
4
|
+
current = driver;
|
|
5
|
+
};
|
|
6
|
+
const driver = () => {
|
|
7
|
+
if (!current) throw new Error("msync: call useDriver({ Timestamp, UUID }) before running");
|
|
8
|
+
return current;
|
|
9
|
+
};
|
|
10
|
+
const uuid = () => new (driver()).UUID().toString("base64");
|
|
11
|
+
//#endregion
|
|
12
|
+
Object.defineProperty(exports, "driver", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function() {
|
|
15
|
+
return driver;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "useDriver", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function() {
|
|
21
|
+
return useDriver;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "uuid", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function() {
|
|
27
|
+
return uuid;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=driver-BUCc3b89.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"driver-BUCc3b89.js","names":[],"sources":["../.build/lib/driver.js"],"sourcesContent":["let current;\nexport const useDriver = (driver) => {\n current = driver;\n};\nexport const driver = () => {\n if (!current)\n throw new Error('msync: call useDriver({ Timestamp, UUID }) before running');\n return current;\n};\nexport const uuid = () => new (driver().UUID)().toString('base64');\n//# sourceMappingURL=driver.js.map"],"mappings":";AAAA,IAAI;AACJ,MAAa,aAAa,WAAW;CACjC,UAAU;AACd;AACA,MAAa,eAAe;CACxB,IAAI,CAAC,SACD,MAAM,IAAI,MAAM,2DAA2D;CAC/E,OAAO;AACX;AACA,MAAa,aAAa,KAAK,OAAO,EAAA,CAAE,KAAM,CAAC,CAAC,SAAS,QAAQ"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region .build/lib/driver.js
|
|
2
|
+
let current;
|
|
3
|
+
const useDriver = (driver) => {
|
|
4
|
+
current = driver;
|
|
5
|
+
};
|
|
6
|
+
const driver = () => {
|
|
7
|
+
if (!current) throw new Error("msync: call useDriver({ Timestamp, UUID }) before running");
|
|
8
|
+
return current;
|
|
9
|
+
};
|
|
10
|
+
const uuid = () => new (driver()).UUID().toString("base64");
|
|
11
|
+
//#endregion
|
|
12
|
+
export { useDriver as n, uuid as r, driver as t };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=driver-sc6MCG57.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"driver-sc6MCG57.esm.js","names":[],"sources":["../.build/lib/driver.js"],"sourcesContent":["let current;\nexport const useDriver = (driver) => {\n current = driver;\n};\nexport const driver = () => {\n if (!current)\n throw new Error('msync: call useDriver({ Timestamp, UUID }) before running');\n return current;\n};\nexport const uuid = () => new (driver().UUID)().toString('base64');\n//# sourceMappingURL=driver.js.map"],"mappings":";AAAA,IAAI;AACJ,MAAa,aAAa,WAAW;CACjC,UAAU;AACd;AACA,MAAa,eAAe;CACxB,IAAI,CAAC,SACD,MAAM,IAAI,MAAM,2DAA2D;CAC/E,OAAO;AACX;AACA,MAAa,aAAa,KAAK,OAAO,EAAA,CAAE,KAAM,CAAC,CAAC,SAAS,QAAQ"}
|
package/index.d.ts
CHANGED
|
@@ -10,4 +10,4 @@ export * from './lib/query';
|
|
|
10
10
|
export * from './lib/utils';
|
|
11
11
|
export * from './lib/types/extern';
|
|
12
12
|
export * from './types/extern';
|
|
13
|
-
export {
|
|
13
|
+
export { useDriver, type Driver } from './lib/driver';
|
package/index.esm.js
CHANGED
|
@@ -1,35 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { MongoClient, Timestamp, UUID } from "mongodb";
|
|
1
|
+
import { n as useDriver, r as uuid, t as driver } from "./driver-sc6MCG57.esm.js";
|
|
3
2
|
import crypto$1 from "crypto";
|
|
4
3
|
import { canonicalize } from "json-canonicalize";
|
|
5
|
-
import { writeFile } from "fs/promises";
|
|
6
|
-
//#region \0rolldown/runtime.js
|
|
7
|
-
var __defProp = Object.defineProperty;
|
|
8
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
9
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
10
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
-
var __exportAll = (all, no_symbols) => {
|
|
12
|
-
let target = {};
|
|
13
|
-
for (var name in all) __defProp(target, name, {
|
|
14
|
-
get: all[name],
|
|
15
|
-
enumerable: true
|
|
16
|
-
});
|
|
17
|
-
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
18
|
-
return target;
|
|
19
|
-
};
|
|
20
|
-
var __copyProps = (to, from, except, desc) => {
|
|
21
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
22
|
-
key = keys[i];
|
|
23
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
24
|
-
get: ((k) => from[k]).bind(null, key),
|
|
25
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
return to;
|
|
29
|
-
};
|
|
30
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
31
|
-
var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
|
|
32
|
-
//#endregion
|
|
33
4
|
//#region .build/lib/expression/expr-base.js
|
|
34
5
|
const asExprRaw = (raw) => ({ get: () => raw });
|
|
35
6
|
const asExpr = (r) => r;
|
|
@@ -74,7 +45,6 @@ const map1 = (k, to) => {
|
|
|
74
45
|
};
|
|
75
46
|
//#endregion
|
|
76
47
|
//#region .build/lib/utils/map-object.js
|
|
77
|
-
const map = (x, f) => Object.fromEntries(Object.entries(x).map(([k, v]) => [k, f(v, k)]));
|
|
78
48
|
const mapExactToObject0 = (x, f) => {
|
|
79
49
|
const filter = (x) => x.filter((x) => x[0] === x[1][0]);
|
|
80
50
|
const matched = filter(Object.entries(x));
|
|
@@ -660,8 +630,8 @@ const getSubsetMatchForExt = (ext) => {
|
|
|
660
630
|
};
|
|
661
631
|
const getWhenMatchedForMerge = (whenNotMatched, update, canWrite) => {
|
|
662
632
|
const orNull = (e) => whenNotMatched === "discard" ? $ifNull(e, nil) : e;
|
|
663
|
-
const
|
|
664
|
-
const merged = mergeObjects(root().expr(), update(ctx()("new").expr(), root().expr()), field({ deletedAt: ["deletedAt",
|
|
633
|
+
const deletedAt = orNull((whenNotMatched === "insert" ? ctx()("new") : root()).of("deletedAt").expr());
|
|
634
|
+
const merged = mergeObjects(root().expr(), update(ctx()("new").expr(), root().expr()), field({ deletedAt: ["deletedAt", deletedAt] }));
|
|
665
635
|
return link().with($replaceWith_(field({
|
|
666
636
|
old: ["old", root().expr()],
|
|
667
637
|
merged: ["merged", merged]
|
|
@@ -674,7 +644,7 @@ const getWhenMatched = (whenNotMatched, canWrite) => {
|
|
|
674
644
|
touchedAt: ["touchedAt", root().of("merged").of("touchedAt").expr()]
|
|
675
645
|
}));
|
|
676
646
|
const diff = ne(preMergeOld)(root().of("merged").expr());
|
|
677
|
-
const useNew = canWrite ? and(diff, canWrite) : diff;
|
|
647
|
+
const useNew = canWrite ? and(diff, or(notNull(root().of("old").of("deletedAt").expr()), canWrite)) : diff;
|
|
678
648
|
return link().with($replaceWith_(ite(useNew, root().of("merged").expr(), root().of("old").expr()))).stages;
|
|
679
649
|
};
|
|
680
650
|
const $mergeX = (out, keys, f, map, ext, update) => {
|
|
@@ -819,15 +789,6 @@ const $group = (id, args, out, extra, idPrefix = "") => $groupMerge(id, args, {
|
|
|
819
789
|
whenNotMatched: "insert"
|
|
820
790
|
}, "_grp", extra, idPrefix);
|
|
821
791
|
//#endregion
|
|
822
|
-
//#region .build/types/mongo.js
|
|
823
|
-
var mongo_exports = /* @__PURE__ */ __exportAll({});
|
|
824
|
-
import * as import_mongodb from "mongodb";
|
|
825
|
-
__reExport(mongo_exports, import_mongodb);
|
|
826
|
-
//#endregion
|
|
827
|
-
//#region .build/types/index.js
|
|
828
|
-
var types_exports = /* @__PURE__ */ __exportAll({});
|
|
829
|
-
__reExport(types_exports, mongo_exports);
|
|
830
|
-
//#endregion
|
|
831
792
|
//#region .build/lib/aggregate/set/$replace-with-each.js
|
|
832
793
|
const deltaExpr = (expr) => (field) => {
|
|
833
794
|
return ite(eqTyped($ifNull(root().of(field).expr(), nil), nil), nil, expr(field));
|
|
@@ -1177,6 +1138,7 @@ const ensureCollection = async (db, collectionName) => {
|
|
|
1177
1138
|
};
|
|
1178
1139
|
//#endregion
|
|
1179
1140
|
//#region .build/lib/utils/merge/utils.js
|
|
1141
|
+
const map = (x, f) => Object.fromEntries(Object.entries(x).map(([k, v]) => [k, f(v, k)]));
|
|
1180
1142
|
const patch = ({ ...x }, k, v) => {
|
|
1181
1143
|
delete x[k];
|
|
1182
1144
|
return {
|
|
@@ -1188,10 +1150,12 @@ const restart = (sources) => {
|
|
|
1188
1150
|
return map(sources, (x) => x.stop());
|
|
1189
1151
|
};
|
|
1190
1152
|
const race = (sources) => {
|
|
1191
|
-
const promises = Object.values(map(sources, (
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1153
|
+
const promises = Object.values(map(sources, (p, key) => {
|
|
1154
|
+
return p.next.then((frame) => ({
|
|
1155
|
+
key,
|
|
1156
|
+
frame
|
|
1157
|
+
}), (error) => new Error(error));
|
|
1158
|
+
}));
|
|
1195
1159
|
return Promise.any(promises).then((result) => {
|
|
1196
1160
|
if (result instanceof Error) throw result;
|
|
1197
1161
|
else return result;
|
|
@@ -1247,7 +1211,7 @@ const mergeIterators = (params) => {
|
|
|
1247
1211
|
}),
|
|
1248
1212
|
next: select(sources).then(makeReiterate(sources, interrupt, hooks)),
|
|
1249
1213
|
clear: async () => {
|
|
1250
|
-
for (const key in sources) await sources[key]
|
|
1214
|
+
for (const key in sources) await sources[key]?.clear();
|
|
1251
1215
|
}
|
|
1252
1216
|
};
|
|
1253
1217
|
};
|
|
@@ -1370,9 +1334,9 @@ const join = (params, leftSnapshot, rightSnapshot, stagesUntilNextLookup, outerL
|
|
|
1370
1334
|
teardown: final.teardown
|
|
1371
1335
|
}, async () => {
|
|
1372
1336
|
log("Creating indexes for lookup left", leftSnapshot.coll.collectionName, { [`before.${lField.str()}`]: 1 });
|
|
1373
|
-
await createIndex(leftSnapshot.coll, { [`before.${lField.str()}`]: 1 }, { name: "left_" + new
|
|
1337
|
+
await createIndex(leftSnapshot.coll, { [`before.${lField.str()}`]: 1 }, { name: "left_" + new (driver()).UUID().toString("base64") });
|
|
1374
1338
|
log("Creating indexes for lookup right", rightSnapshot.coll.collectionName, { [`before.${rField.str()}`]: 1 });
|
|
1375
|
-
await createIndex(rightSnapshot.coll, { [`before.${rField.str()}`]: 1 }, { name: "right_" + new
|
|
1339
|
+
await createIndex(rightSnapshot.coll, { [`before.${rField.str()}`]: 1 }, { name: "right_" + new (driver()).UUID().toString("base64") });
|
|
1376
1340
|
});
|
|
1377
1341
|
const lRunner = getRunner(left, lRunnerInput, finalInput);
|
|
1378
1342
|
const rRunner = getRunner(right, rRunnerInput, finalInput);
|
|
@@ -1518,12 +1482,12 @@ const addTeardown = (it, tr) => {
|
|
|
1518
1482
|
//#endregion
|
|
1519
1483
|
//#region .build/lib/watch.js
|
|
1520
1484
|
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
1521
|
-
const maxTimestamp = new Timestamp(18446744073709551615n);
|
|
1485
|
+
const maxTimestamp = () => new (driver()).Timestamp(18446744073709551615n);
|
|
1522
1486
|
const getCurrentTimestamp = async (db) => {
|
|
1523
|
-
return (await db.admin().command({ serverStatus: 1 }))
|
|
1487
|
+
return (await db.admin().command({ serverStatus: 1 })).operationTime;
|
|
1524
1488
|
};
|
|
1525
1489
|
async function getLastCommittedTs(adminDb) {
|
|
1526
|
-
return (await adminDb.command({ replSetGetStatus: 1 }))
|
|
1490
|
+
return (await adminDb.command({ replSetGetStatus: 1 })).optimes?.lastCommittedOpTime?.ts ?? null;
|
|
1527
1491
|
}
|
|
1528
1492
|
async function waitUntilStablePast(db, oplogTs, { pollMs = 0, timeoutMs = 1e4 } = {}) {
|
|
1529
1493
|
const adminDb = db.client.db("admin");
|
|
@@ -1666,7 +1630,7 @@ const register = (coll, keys, match, cb) => {
|
|
|
1666
1630
|
let maxKeysRemoved = null;
|
|
1667
1631
|
const makeWatchStream = async ({ collection, projection: p, hardMatch: m }, streamName) => {
|
|
1668
1632
|
const { db } = collection.s;
|
|
1669
|
-
await (maxKeysRemoved ??= Promise.all((await db.listCollections({}, { nameOnly: true }).toArray()).map((x) => void db.collection(x.name).updateMany({ touchedAt: maxTimestamp }, [{ $set: { touchedAt: "$$CLUSTER_TIME" } }]))).then(() => {}));
|
|
1633
|
+
await (maxKeysRemoved ??= Promise.all((await db.listCollections({}, { nameOnly: true }).toArray()).map((x) => void db.collection(x.name).updateMany({ touchedAt: maxTimestamp() }, [{ $set: { touchedAt: "$$CLUSTER_TIME" } }]))).then(() => {}));
|
|
1670
1634
|
const projection = {
|
|
1671
1635
|
...p ? mapExactToObject(p, (v) => v) : {},
|
|
1672
1636
|
deletedAt: 1
|
|
@@ -1717,7 +1681,7 @@ const $nor = combine("$nor", filterUndefined(all));
|
|
|
1717
1681
|
const $or = combine("$or", filterUndefined(first$1));
|
|
1718
1682
|
//#endregion
|
|
1719
1683
|
//#region .build/lib/boot/first-stages.js
|
|
1720
|
-
const previous = (ts) => new Timestamp({
|
|
1684
|
+
const previous = (ts) => new (driver()).Timestamp({
|
|
1721
1685
|
t: ts.high - 60,
|
|
1722
1686
|
i: 0
|
|
1723
1687
|
});
|
|
@@ -1825,11 +1789,11 @@ const executes$2 = (view, input, streamName, skip = false, after, needs = {}) =>
|
|
|
1825
1789
|
log("creating indexes");
|
|
1826
1790
|
await createIndex(snapshotCollection, { before: 1 }, {
|
|
1827
1791
|
partialFilterExpression: { before: null },
|
|
1828
|
-
name: "before_" +
|
|
1792
|
+
name: "before_" + uuid()
|
|
1829
1793
|
});
|
|
1830
1794
|
await createIndex(snapshotCollection, { updated: 1 }, {
|
|
1831
1795
|
partialFilterExpression: { updated: true },
|
|
1832
|
-
name: "updated_" +
|
|
1796
|
+
name: "updated_" + uuid()
|
|
1833
1797
|
});
|
|
1834
1798
|
await createIndex(snapshotCollection, {
|
|
1835
1799
|
updated: 1,
|
|
@@ -1841,7 +1805,7 @@ const executes$2 = (view, input, streamName, skip = false, after, needs = {}) =>
|
|
|
1841
1805
|
after: null,
|
|
1842
1806
|
before: null
|
|
1843
1807
|
},
|
|
1844
|
-
name: "updated_nulls_" +
|
|
1808
|
+
name: "updated_nulls_" + uuid()
|
|
1845
1809
|
});
|
|
1846
1810
|
await createIndex(snapshotCollection, {
|
|
1847
1811
|
updated: 1,
|
|
@@ -1851,7 +1815,7 @@ const executes$2 = (view, input, streamName, skip = false, after, needs = {}) =>
|
|
|
1851
1815
|
updated: true,
|
|
1852
1816
|
after: null
|
|
1853
1817
|
},
|
|
1854
|
-
name: "updated_no_after_" +
|
|
1818
|
+
name: "updated_no_after_" + uuid()
|
|
1855
1819
|
});
|
|
1856
1820
|
await createIndex(snapshotCollection, { updated: 1 }, {
|
|
1857
1821
|
partialFilterExpression: {
|
|
@@ -1859,7 +1823,7 @@ const executes$2 = (view, input, streamName, skip = false, after, needs = {}) =>
|
|
|
1859
1823
|
after: null,
|
|
1860
1824
|
before: null
|
|
1861
1825
|
},
|
|
1862
|
-
name: "updated_nulls_" +
|
|
1826
|
+
name: "updated_nulls_" + uuid()
|
|
1863
1827
|
});
|
|
1864
1828
|
await ensureCollection(db, coll);
|
|
1865
1829
|
await db.command({
|
|
@@ -1868,7 +1832,7 @@ const executes$2 = (view, input, streamName, skip = false, after, needs = {}) =>
|
|
|
1868
1832
|
});
|
|
1869
1833
|
await createIndex(collection, { touchedAt: 1 }, hardMatch ? {
|
|
1870
1834
|
partialFilterExpression: hardMatch.raw(root()),
|
|
1871
|
-
name: "touchedAt_hard_" +
|
|
1835
|
+
name: "touchedAt_hard_" + uuid()
|
|
1872
1836
|
} : {});
|
|
1873
1837
|
await setup?.();
|
|
1874
1838
|
await after?.();
|
|
@@ -1912,7 +1876,8 @@ const executes$2 = (view, input, streamName, skip = false, after, needs = {}) =>
|
|
|
1912
1876
|
}), "run the aggregation", () => stream.close());
|
|
1913
1877
|
};
|
|
1914
1878
|
const makeStream = () => makeWatchStream(view, streamName);
|
|
1915
|
-
const step4 = (
|
|
1879
|
+
const step4 = (args) => async () => {
|
|
1880
|
+
const { result, ts, stream } = args;
|
|
1916
1881
|
const start = Date.now();
|
|
1917
1882
|
log("snapshot", streamName, "ensure before null", Date.now() - start);
|
|
1918
1883
|
const first = ts === void 0;
|
|
@@ -2049,7 +2014,7 @@ const executes$1 = (view, input, streamName, needs) => {
|
|
|
2049
2014
|
});
|
|
2050
2015
|
await createIndex(collection, { touchedAt: 1 }, {
|
|
2051
2016
|
partialFilterExpression: { deletedAt: { $eq: null } },
|
|
2052
|
-
name: "touchedAt_" + new UUID().toString("base64")
|
|
2017
|
+
name: "touchedAt_" + new (driver()).UUID().toString("base64")
|
|
2053
2018
|
});
|
|
2054
2019
|
log("stream started", {
|
|
2055
2020
|
streamName,
|
|
@@ -2154,45 +2119,6 @@ const executes = (view, input, needs) => {
|
|
|
2154
2119
|
};
|
|
2155
2120
|
const single = (view, needs = {}) => pipe((input) => executes(view, input, needs), emptyDelta(), concatDelta, emptyDelta);
|
|
2156
2121
|
//#endregion
|
|
2157
|
-
|
|
2158
|
-
__require("dotenv").config();
|
|
2159
|
-
const uri = process.env["MONGO_URL"];
|
|
2160
|
-
//#endregion
|
|
2161
|
-
//#region .build/test/mongodb.js
|
|
2162
|
-
const enablePreAndPostImages = (coll) => coll.s.db.command({
|
|
2163
|
-
collMod: coll.collectionName,
|
|
2164
|
-
changeStreamPreAndPostImages: { enabled: true }
|
|
2165
|
-
});
|
|
2166
|
-
const prepare = async (testName) => {
|
|
2167
|
-
const client = new MongoClient(uri, testName ? { monitorCommands: true } : {});
|
|
2168
|
-
if (testName) {
|
|
2169
|
-
const handler = (c) => {
|
|
2170
|
-
writeFile(`./out/${testName}.log`, JSON.stringify(c.command) + ",\n", { flag: "w" });
|
|
2171
|
-
};
|
|
2172
|
-
client.on("commandStarted", handler);
|
|
2173
|
-
client.on("commandSucceeded", handler);
|
|
2174
|
-
}
|
|
2175
|
-
await client.connect();
|
|
2176
|
-
await client.db("admin").command({ setClusterParameter: { changeStreamOptions: { preAndPostImages: { expireAfterSeconds: 60 } } } });
|
|
2177
|
-
return client;
|
|
2178
|
-
};
|
|
2179
|
-
const clears = [];
|
|
2180
|
-
const makeCol = async (docs, database, name) => {
|
|
2181
|
-
if (!name) {
|
|
2182
|
-
const n = name = crypto.randomUUID();
|
|
2183
|
-
clears.push(async () => {
|
|
2184
|
-
await database.collection(n).drop({ ignoreUndefined: true });
|
|
2185
|
-
});
|
|
2186
|
-
}
|
|
2187
|
-
try {
|
|
2188
|
-
const col = await database.createCollection(name, { changeStreamPreAndPostImages: { enabled: true } });
|
|
2189
|
-
if (docs.length) await col.insertMany([...docs]);
|
|
2190
|
-
return col;
|
|
2191
|
-
} catch {
|
|
2192
|
-
return database.collection(name);
|
|
2193
|
-
}
|
|
2194
|
-
};
|
|
2195
|
-
//#endregion
|
|
2196
|
-
export { $accumulator, $and, $countDict, $countDictArray, $entries, $eq, $exists, $expr, $getField, $group, $groupId, $groupMerge, $group_, $gt, $gtTs, $gte, $gteTs, $ifNull, $in, $insert, $insertPart, $insertX, $keys, $let, $lookup, $lt, $lte, $map, $map0, $map1, $match, $matchDelta, $merge, $merge2, $mergeId, $mergePart, $merge_, $ne, $nin, $nor, $or, $outerLookup, $pushDict, $rand, $reduce, $replaceWith, $set, $simpleInsert, $simpleMerge, $simpleMergePart, $substr, $sum, $type, $unwind, $unwindDelta, Field, Machine, add, and, anyElementTrue, array, ceil, comp, concat, concatArray, createIndex, ctx, current, dateAdd, dateDiff, dateLt, datePart, dayAndMonthPart, divide, emptyDelta, enablePreAndPostImages, eq, eqTyped, except, exprMapVal, field, fieldF, fieldM, filter, filterDefined, first, firstSure, floor, from, fromEq, func, getSubsetMatchForExt, getWhenMatched, getWhenMatchedForMerge, gt, gte, inArray, isArray, ite, joinIdOf, last, literalsEqaul, log, lt, lte, makeCol, map, map1, mapExact, mapExact0, mapExact1, mapExactToObject, mapExactToObject0, mapExactToObject1, mapFromPlainDateTime, mapToPlainDateTime, mapVal, matchDelta, max, maxDate, mergeExact, mergeExact0, mergeExpr, mergeObjects, min, minDate, monthPart, multiply, ne, nil, noop, not, notNull, now, or, padLeft, prepare, rand, range, reflex, regex, root, set, setField, single, size, slice, sortArray, spread, spread0, staging, startOf, str, sub, subtract, sym, to, toInt, val, weekPart, wrap, year };
|
|
2122
|
+
export { $accumulator, $and, $countDict, $countDictArray, $entries, $eq, $exists, $expr, $getField, $group, $groupId, $groupMerge, $group_, $gt, $gtTs, $gte, $gteTs, $ifNull, $in, $insert, $insertPart, $insertX, $keys, $let, $lookup, $lt, $lte, $map, $map0, $map1, $match, $matchDelta, $merge, $merge2, $mergeId, $mergePart, $merge_, $ne, $nin, $nor, $or, $outerLookup, $pushDict, $rand, $reduce, $replaceWith, $set, $simpleInsert, $simpleMerge, $simpleMergePart, $substr, $sum, $type, $unwind, $unwindDelta, Field, Machine, add, and, anyElementTrue, array, ceil, comp, concat, concatArray, createIndex, ctx, current, dateAdd, dateDiff, dateLt, datePart, dayAndMonthPart, divide, emptyDelta, eq, eqTyped, except, exprMapVal, field, fieldF, fieldM, filter, filterDefined, first, firstSure, floor, from, fromEq, func, getSubsetMatchForExt, getWhenMatched, getWhenMatchedForMerge, gt, gte, inArray, isArray, ite, joinIdOf, last, literalsEqaul, log, lt, lte, map1, mapExact, mapExact0, mapExact1, mapExactToObject, mapExactToObject0, mapExactToObject1, mapFromPlainDateTime, mapToPlainDateTime, mapVal, matchDelta, max, maxDate, mergeExact, mergeExact0, mergeExpr, mergeObjects, min, minDate, monthPart, multiply, ne, nil, noop, not, notNull, now, or, padLeft, rand, range, reflex, regex, root, set, setField, single, size, slice, sortArray, spread, spread0, staging, startOf, str, sub, subtract, sym, to, toInt, useDriver, val, weekPart, wrap, year };
|
|
2197
2123
|
|
|
2198
2124
|
//# sourceMappingURL=index.esm.js.map
|