@omegup/msync 0.0.52 → 0.0.54

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/index.esm.js CHANGED
@@ -1193,6 +1193,11 @@ const firstWorksMerge = (iters) => {
1193
1193
  return iterator;
1194
1194
  };
1195
1195
 
1196
+ const T = (s) => `Timestamp(${parseInt(`${BigInt(s) / 2n ** 32n}`)}, ${parseInt(`${BigInt(s) % 2n ** 32n}`)})`;
1197
+ const replace = (s) => s.replace(/\{"\$timestamp":"(\d+)"\}/g, (_, d) => T(d));
1198
+ const json = (a) => replace(JSON.stringify(a));
1199
+ const log = (...args) => console.log(new Date(), ...args.map(a => (typeof a === 'function' ? a(replace) : a && typeof a === 'object' ? json(a) : a)));
1200
+
1196
1201
  class Machine {
1197
1202
  sources;
1198
1203
  constructor(root) {
@@ -1218,6 +1223,7 @@ const runCont = async (it, cb) => {
1218
1223
  const { next, stop, clear } = it();
1219
1224
  const res = await next.then(next => ({ ok: true, next }), err => ({ ok: false, err }));
1220
1225
  if (!res.ok) {
1226
+ log('error', res.err);
1221
1227
  return runCont(stop, cb);
1222
1228
  }
1223
1229
  const { cont, info } = res.next;
@@ -1377,11 +1383,6 @@ const $insert = (out) => $insertX(out, assertNotNull(root().of('after').expr()),
1377
1383
  }), x));
1378
1384
  const assertNotNull = (expr) => expr;
1379
1385
 
1380
- const T = (s) => `Timestamp(${parseInt(`${BigInt(s) / 2n ** 32n}`)}, ${parseInt(`${BigInt(s) % 2n ** 32n}`)})`;
1381
- const replace = (s) => s.replace(/\{"\$timestamp":"(\d+)"\}/g, (_, d) => T(d));
1382
- const json = (a) => replace(JSON.stringify(a));
1383
- const log = (...args) => console.log(new Date(), ...args.map(a => (typeof a === 'function' ? a(replace) : a && typeof a === 'object' ? json(a) : a)));
1384
-
1385
1386
  const aggregate = (streamName, input, snapshot = true, start = Date.now()) => input(({ coll, input }) => {
1386
1387
  const req = {
1387
1388
  aggregate: coll.collectionName,
@@ -1453,8 +1454,8 @@ const makeWatchStream = (db, { collection, projection: p, hardMatch: m }, startA
1453
1454
  { $and: changeKeys.map(k => ({ $eq: [k, null] })) },
1454
1455
  ],
1455
1456
  },
1456
- then: '$clusterTime',
1457
- else: null,
1457
+ then: null,
1458
+ else: '$clusterTime',
1458
1459
  },
1459
1460
  },
1460
1461
  },
package/index.js CHANGED
@@ -1195,6 +1195,11 @@ const firstWorksMerge = (iters) => {
1195
1195
  return iterator;
1196
1196
  };
1197
1197
 
1198
+ const T = (s) => `Timestamp(${parseInt(`${BigInt(s) / 2n ** 32n}`)}, ${parseInt(`${BigInt(s) % 2n ** 32n}`)})`;
1199
+ const replace = (s) => s.replace(/\{"\$timestamp":"(\d+)"\}/g, (_, d) => T(d));
1200
+ const json = (a) => replace(JSON.stringify(a));
1201
+ const log = (...args) => console.log(new Date(), ...args.map(a => (typeof a === 'function' ? a(replace) : a && typeof a === 'object' ? json(a) : a)));
1202
+
1198
1203
  class Machine {
1199
1204
  sources;
1200
1205
  constructor(root) {
@@ -1220,6 +1225,7 @@ const runCont = async (it, cb) => {
1220
1225
  const { next, stop, clear } = it();
1221
1226
  const res = await next.then(next => ({ ok: true, next }), err => ({ ok: false, err }));
1222
1227
  if (!res.ok) {
1228
+ log('error', res.err);
1223
1229
  return runCont(stop, cb);
1224
1230
  }
1225
1231
  const { cont, info } = res.next;
@@ -1379,11 +1385,6 @@ const $insert = (out) => $insertX(out, assertNotNull(root().of('after').expr()),
1379
1385
  }), x));
1380
1386
  const assertNotNull = (expr) => expr;
1381
1387
 
1382
- const T = (s) => `Timestamp(${parseInt(`${BigInt(s) / 2n ** 32n}`)}, ${parseInt(`${BigInt(s) % 2n ** 32n}`)})`;
1383
- const replace = (s) => s.replace(/\{"\$timestamp":"(\d+)"\}/g, (_, d) => T(d));
1384
- const json = (a) => replace(JSON.stringify(a));
1385
- const log = (...args) => console.log(new Date(), ...args.map(a => (typeof a === 'function' ? a(replace) : a && typeof a === 'object' ? json(a) : a)));
1386
-
1387
1388
  const aggregate = (streamName, input, snapshot = true, start = Date.now()) => input(({ coll, input }) => {
1388
1389
  const req = {
1389
1390
  aggregate: coll.collectionName,
@@ -1455,8 +1456,8 @@ const makeWatchStream = (db, { collection, projection: p, hardMatch: m }, startA
1455
1456
  { $and: changeKeys.map(k => ({ $eq: [k, null] })) },
1456
1457
  ],
1457
1458
  },
1458
- then: '$clusterTime',
1459
- else: null,
1459
+ then: null,
1460
+ else: '$clusterTime',
1460
1461
  },
1461
1462
  },
1462
1463
  },
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "module": "index.esm.js",
4
4
  "typings": "index.d.ts",
5
5
  "name": "@omegup/msync",
6
- "version": "0.0.52",
6
+ "version": "0.0.54",
7
7
  "dependencies": {
8
8
  "dayjs": "^1.11.9",
9
9
  "dotenv": "^16.3.1",