@omegup/msync 0.0.71 → 0.0.73

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.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { Timestamp, Filter, UpdateFilter, BSON, Db, Collection, IndexSpecification, CreateIndexesOptions, MongoClient as MongoClient$1, OptionalUnlessRequiredId } from 'mongodb';
2
2
  export { Collection, Timestamp } from 'mongodb';
3
- import * as bson from 'bson';
4
3
 
5
4
  type HasJob = {
6
5
  job: object | undefined;
@@ -687,7 +686,7 @@ declare const map1: <K extends string, Im>(k: AsLiteral<K>, to: Im) => { readonl
687
686
  readonly [_: string]: [K, Im];
688
687
  };
689
688
 
690
- declare const enablePreAndPostImages: <T extends doc>(coll: Collection<T>) => Promise<bson.Document>;
689
+ declare const enablePreAndPostImages: <T extends doc>(coll: Collection<T>) => Promise<Document>;
691
690
  declare const prepare: (testName?: string) => Promise<MongoClient$1>;
692
691
  declare const makeCol: <T extends ID>(docs: readonly OptionalUnlessRequiredId<T>[], database: Db, name?: string) => Promise<Collection<T>>;
693
692
 
package/index.esm.js CHANGED
@@ -1,6 +1,6 @@
1
- import { UUID, MongoClient } from 'mongodb';
2
1
  import { SynchronousPromise } from 'synchronous-promise';
3
2
  import crypto$1 from 'crypto';
3
+ import { UUID, MongoClient } from 'mongodb';
4
4
  import { writeFile } from 'fs/promises';
5
5
 
6
6
  const asExprRaw = (raw) => ({ get: () => raw });
@@ -1217,11 +1217,6 @@ const firstWorksMerge = (iters) => {
1217
1217
  return iterator;
1218
1218
  };
1219
1219
 
1220
- const T = (s) => `Timestamp(${parseInt(`${BigInt(s) / 2n ** 32n}`)}, ${parseInt(`${BigInt(s) % 2n ** 32n}`)})`;
1221
- const replace = (s) => s.replace(/\{"\$timestamp":"(\d+)"\}/g, (_, d) => T(d));
1222
- const json = (a) => replace(JSON.stringify(a));
1223
- const log = (...args) => console.log(new Date(), ...args.map(a => (typeof a === 'function' ? a(replace) : a && typeof a === 'object' ? json(a) : a)));
1224
-
1225
1220
  class Machine {
1226
1221
  sources;
1227
1222
  constructor(root) {
@@ -1247,7 +1242,8 @@ const runCont = async (it, cb) => {
1247
1242
  const { next, stop, clear } = it();
1248
1243
  const res = await next.then(next => ({ ok: true, next }), err => ({ ok: false, err }));
1249
1244
  if (!res.ok) {
1250
- log('error', res.err);
1245
+ console.error(res.err);
1246
+ process.exit(1);
1251
1247
  return runCont(stop, cb);
1252
1248
  }
1253
1249
  const { cont, info } = res.next;
@@ -1407,6 +1403,11 @@ const $insert = (out) => $insertX(out, assertNotNull(root().of('after').expr()),
1407
1403
  }), x));
1408
1404
  const assertNotNull = (expr) => expr;
1409
1405
 
1406
+ const T = (s) => `Timestamp(${parseInt(`${BigInt(s) / 2n ** 32n}`)}, ${parseInt(`${BigInt(s) % 2n ** 32n}`)})`;
1407
+ const replace = (s) => s.replace(/\{"\$timestamp":"(\d+)"\}/g, (_, d) => T(d));
1408
+ const json = (a) => replace(JSON.stringify(a));
1409
+ const log = (...args) => console.log(new Date(), ...args.map(a => (typeof a === 'function' ? a(replace) : a && typeof a === 'object' ? json(a) : a)));
1410
+
1410
1411
  const aggregate = (streamName, input, snapshot = true, start = Date.now()) => input(({ coll, input }) => {
1411
1412
  const req = {
1412
1413
  aggregate: coll.collectionName,
package/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var mongodb = require('mongodb');
4
3
  var synchronousPromise = require('synchronous-promise');
5
4
  var crypto$1 = require('crypto');
5
+ var mongodb = require('mongodb');
6
6
  var promises = require('fs/promises');
7
7
 
8
8
  const asExprRaw = (raw) => ({ get: () => raw });
@@ -1219,11 +1219,6 @@ const firstWorksMerge = (iters) => {
1219
1219
  return iterator;
1220
1220
  };
1221
1221
 
1222
- const T = (s) => `Timestamp(${parseInt(`${BigInt(s) / 2n ** 32n}`)}, ${parseInt(`${BigInt(s) % 2n ** 32n}`)})`;
1223
- const replace = (s) => s.replace(/\{"\$timestamp":"(\d+)"\}/g, (_, d) => T(d));
1224
- const json = (a) => replace(JSON.stringify(a));
1225
- const log = (...args) => console.log(new Date(), ...args.map(a => (typeof a === 'function' ? a(replace) : a && typeof a === 'object' ? json(a) : a)));
1226
-
1227
1222
  class Machine {
1228
1223
  sources;
1229
1224
  constructor(root) {
@@ -1249,7 +1244,8 @@ const runCont = async (it, cb) => {
1249
1244
  const { next, stop, clear } = it();
1250
1245
  const res = await next.then(next => ({ ok: true, next }), err => ({ ok: false, err }));
1251
1246
  if (!res.ok) {
1252
- log('error', res.err);
1247
+ console.error(res.err);
1248
+ process.exit(1);
1253
1249
  return runCont(stop, cb);
1254
1250
  }
1255
1251
  const { cont, info } = res.next;
@@ -1409,6 +1405,11 @@ const $insert = (out) => $insertX(out, assertNotNull(root().of('after').expr()),
1409
1405
  }), x));
1410
1406
  const assertNotNull = (expr) => expr;
1411
1407
 
1408
+ const T = (s) => `Timestamp(${parseInt(`${BigInt(s) / 2n ** 32n}`)}, ${parseInt(`${BigInt(s) % 2n ** 32n}`)})`;
1409
+ const replace = (s) => s.replace(/\{"\$timestamp":"(\d+)"\}/g, (_, d) => T(d));
1410
+ const json = (a) => replace(JSON.stringify(a));
1411
+ const log = (...args) => console.log(new Date(), ...args.map(a => (typeof a === 'function' ? a(replace) : a && typeof a === 'object' ? json(a) : a)));
1412
+
1412
1413
  const aggregate = (streamName, input, snapshot = true, start = Date.now()) => input(({ coll, input }) => {
1413
1414
  const req = {
1414
1415
  aggregate: coll.collectionName,
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.71",
6
+ "version": "0.0.73",
7
7
  "dependencies": {
8
8
  "dayjs": "^1.11.9",
9
9
  "dotenv": "^16.3.1",