@omegup/msync 0.0.2 → 0.0.3

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,4 +1,4 @@
1
- import { Timestamp, BSON, Db, Collection, IndexSpecification, CreateIndexesOptions, MongoClient as MongoClient$1 } from 'mongodb';
1
+ import { Timestamp, BSON, Db, Collection, IndexSpecification, CreateIndexesOptions, MongoClient as MongoClient$1, OptionalUnlessRequiredId } from 'mongodb';
2
2
  export { Collection, Timestamp } from 'mongodb';
3
3
  import * as bson from 'bson';
4
4
 
@@ -636,5 +636,6 @@ declare const map1: <K extends string, Im>(k: AsLiteral<K>, to: Im) => { readonl
636
636
 
637
637
  declare const enablePreAndPostImages: <T extends doc>(coll: Collection<T>) => Promise<bson.Document>;
638
638
  declare const prepare: (testName?: string) => Promise<MongoClient$1>;
639
+ declare const makeCol: <T extends ID>(docs: readonly OptionalUnlessRequiredId<T>[], database: Db, name?: string) => Promise<Collection<T>>;
639
640
 
640
- export { $accumulator, $and, $countDict, $entries, $eq, $expr, $getField, $group, $groupId, $groupMerge, $gt, $gtTs, $gte, $gteTs, $ifNull, $in, $keys, $let, $lookup, $lt, $lte, $map, $map1, $match, $matchDelta, $merge, $merge_, $ne, $nin, $nor, $or, $pushDict, $rand, $replaceWith, $set, $sum, $unwind, $unwindDelta, $upsert, type Accumulators, type Arr, type AsLiteral, type Delta, type DeltaAccumulator, type DeltaAccumulators, Expr, type ExprHKT, type Exprs, type ExprsExact, type ExprsExactHKT, type ExprsPart, Field, type ID, type Loose, Machine, type Merge, type MergeArgs, type MergeInto, type MergeMapOArgs, type Model, type N, type NoRaw, type O, type OPick, type OPickD, type RONoRaw, type RORec, type RawStages, type Rec, type Replace, type SnapshotStreamExecutionResult, type StrKey, type Strict, type TS, Type, type WriteonlyCollection, add, and, array, ceil, comp, concat, concatArray, createIndex, ctx, current, dateAdd, dateDiff, dateLt, datePart, dayAndMonthPart, divide, type doc, enablePreAndPostImages, eq, eqTyped, except, exprMapVal, field, fieldF, fieldM, filter, filterDefined, first, firstSure, floor, from, func, gt, gte, inArray, isArray, ite, last, log, lt, lte, map1, mapVal, max, maxDate, mergeExact, mergeExact0, mergeExpr, mergeObjects, minDate, monthPart, multiply, ne, nil, noop, type notArr, notNull, now, pair, prepare, rand, range, root, set, setField, size, slice, sortArray, staging, startOf, str, sub, subtract, to, toInt, val, wrap };
641
+ export { $accumulator, $and, $countDict, $entries, $eq, $expr, $getField, $group, $groupId, $groupMerge, $gt, $gtTs, $gte, $gteTs, $ifNull, $in, $keys, $let, $lookup, $lt, $lte, $map, $map1, $match, $matchDelta, $merge, $merge_, $ne, $nin, $nor, $or, $pushDict, $rand, $replaceWith, $set, $sum, $unwind, $unwindDelta, $upsert, type Accumulators, type Arr, type AsLiteral, type Delta, type DeltaAccumulator, type DeltaAccumulators, Expr, type ExprHKT, type Exprs, type ExprsExact, type ExprsExactHKT, type ExprsPart, Field, type ID, type Loose, Machine, type Merge, type MergeArgs, type MergeInto, type MergeMapOArgs, type Model, type N, type NoRaw, type O, type OPick, type OPickD, type RONoRaw, type RORec, type RawStages, type Rec, type Replace, type SnapshotStreamExecutionResult, type StrKey, type Strict, type TS, Type, type WriteonlyCollection, add, and, array, ceil, comp, concat, concatArray, createIndex, ctx, current, dateAdd, dateDiff, dateLt, datePart, dayAndMonthPart, divide, type doc, enablePreAndPostImages, eq, eqTyped, except, exprMapVal, field, fieldF, fieldM, filter, filterDefined, first, firstSure, floor, from, func, gt, gte, inArray, isArray, ite, last, log, lt, lte, makeCol, map1, mapVal, max, maxDate, mergeExact, mergeExact0, mergeExpr, mergeObjects, minDate, monthPart, multiply, ne, nil, noop, type notArr, notNull, now, pair, prepare, rand, range, root, set, setField, size, slice, sortArray, staging, startOf, str, sub, subtract, to, toInt, val, wrap };
package/index.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { UUID, MongoClient } from 'mongodb';
2
- import crypto from 'crypto';
2
+ import crypto$1 from 'crypto';
3
3
  import { writeFile } from 'fs/promises';
4
4
 
5
5
  const asExprRaw = (raw) => ({ get: () => raw });
@@ -1127,7 +1127,7 @@ const makeWatchStream = (db, { collection, projection: p, hardMatch: m }, startA
1127
1127
 
1128
1128
  const streamNames = {};
1129
1129
  const executes$1 = (view, input, streamName) => {
1130
- const hash = crypto
1130
+ const hash = crypto$1
1131
1131
  .createHash('md5')
1132
1132
  .update(new Error().stack + '')
1133
1133
  .digest('base64url');
@@ -1263,7 +1263,7 @@ const executes$1 = (view, input, streamName) => {
1263
1263
  const staging = (view, streamName) => pipe(input => executes$1(view, input, streamName), emptyDelta(), concatDelta, emptyDelta);
1264
1264
 
1265
1265
  const executes = (view, input, streamName) => {
1266
- const hash = crypto
1266
+ const hash = crypto$1
1267
1267
  .createHash('md5')
1268
1268
  .update(new Error().stack + '')
1269
1269
  .digest('base64url');
@@ -1590,5 +1590,21 @@ const prepare = async (testName) => {
1590
1590
  });
1591
1591
  return client;
1592
1592
  };
1593
+ const makeCol = async (docs, database, name) => {
1594
+ if (!name) {
1595
+ (name = crypto.randomUUID());
1596
+ }
1597
+ try {
1598
+ const col = await database.createCollection(name, {
1599
+ changeStreamPreAndPostImages: { enabled: true },
1600
+ });
1601
+ if (docs.length)
1602
+ await col.insertMany([...docs]);
1603
+ return col;
1604
+ }
1605
+ catch {
1606
+ return database.collection(name);
1607
+ }
1608
+ };
1593
1609
 
1594
- export { $accumulator, $and, $countDict, $entries, $eq, $expr, $getField, $group, $groupId, $groupMerge, $gt, $gtTs, $gte, $gteTs, $ifNull, $in, $keys, $let, $lookup, $lt, $lte, $map, $map1, $match, $matchDelta, $merge, $merge_, $ne, $nin, $nor, $or, $pushDict, $rand, $replaceWith, $set, $sum, $unwind, $unwindDelta, $upsert, Field, Machine, add, and, array, ceil, comp, concat$1 as concat, concatArray, createIndex, ctx, current, dateAdd, dateDiff, dateLt, datePart, dayAndMonthPart, divide, enablePreAndPostImages, eq, eqTyped, except, exprMapVal, field, fieldF, fieldM, filter, filterDefined, first$1 as first, firstSure, floor, from, func, gt, gte, inArray, isArray, ite, last, log, lt, lte, map1, mapVal, max, maxDate, mergeExact, mergeExact0, mergeExpr, mergeObjects, minDate, monthPart, multiply, ne, nil, noop, notNull, now, pair, prepare, rand, range, root, set, setField, size, slice, sortArray, staging, startOf, str, sub, subtract, to, toInt, val, wrap };
1610
+ export { $accumulator, $and, $countDict, $entries, $eq, $expr, $getField, $group, $groupId, $groupMerge, $gt, $gtTs, $gte, $gteTs, $ifNull, $in, $keys, $let, $lookup, $lt, $lte, $map, $map1, $match, $matchDelta, $merge, $merge_, $ne, $nin, $nor, $or, $pushDict, $rand, $replaceWith, $set, $sum, $unwind, $unwindDelta, $upsert, Field, Machine, add, and, array, ceil, comp, concat$1 as concat, concatArray, createIndex, ctx, current, dateAdd, dateDiff, dateLt, datePart, dayAndMonthPart, divide, enablePreAndPostImages, eq, eqTyped, except, exprMapVal, field, fieldF, fieldM, filter, filterDefined, first$1 as first, firstSure, floor, from, func, gt, gte, inArray, isArray, ite, last, log, lt, lte, makeCol, map1, mapVal, max, maxDate, mergeExact, mergeExact0, mergeExpr, mergeObjects, minDate, monthPart, multiply, ne, nil, noop, notNull, now, pair, prepare, rand, range, root, set, setField, size, slice, sortArray, staging, startOf, str, sub, subtract, to, toInt, val, wrap };
package/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var mongodb = require('mongodb');
4
- var crypto = require('crypto');
4
+ var crypto$1 = require('crypto');
5
5
  var promises = require('fs/promises');
6
6
 
7
7
  const asExprRaw = (raw) => ({ get: () => raw });
@@ -1129,7 +1129,7 @@ const makeWatchStream = (db, { collection, projection: p, hardMatch: m }, startA
1129
1129
 
1130
1130
  const streamNames = {};
1131
1131
  const executes$1 = (view, input, streamName) => {
1132
- const hash = crypto
1132
+ const hash = crypto$1
1133
1133
  .createHash('md5')
1134
1134
  .update(new Error().stack + '')
1135
1135
  .digest('base64url');
@@ -1265,7 +1265,7 @@ const executes$1 = (view, input, streamName) => {
1265
1265
  const staging = (view, streamName) => pipe(input => executes$1(view, input, streamName), emptyDelta(), concatDelta, emptyDelta);
1266
1266
 
1267
1267
  const executes = (view, input, streamName) => {
1268
- const hash = crypto
1268
+ const hash = crypto$1
1269
1269
  .createHash('md5')
1270
1270
  .update(new Error().stack + '')
1271
1271
  .digest('base64url');
@@ -1592,6 +1592,22 @@ const prepare = async (testName) => {
1592
1592
  });
1593
1593
  return client;
1594
1594
  };
1595
+ const makeCol = async (docs, database, name) => {
1596
+ if (!name) {
1597
+ (name = crypto.randomUUID());
1598
+ }
1599
+ try {
1600
+ const col = await database.createCollection(name, {
1601
+ changeStreamPreAndPostImages: { enabled: true },
1602
+ });
1603
+ if (docs.length)
1604
+ await col.insertMany([...docs]);
1605
+ return col;
1606
+ }
1607
+ catch {
1608
+ return database.collection(name);
1609
+ }
1610
+ };
1595
1611
 
1596
1612
  exports.$accumulator = $accumulator;
1597
1613
  exports.$and = $and;
@@ -1674,6 +1690,7 @@ exports.last = last;
1674
1690
  exports.log = log;
1675
1691
  exports.lt = lt;
1676
1692
  exports.lte = lte;
1693
+ exports.makeCol = makeCol;
1677
1694
  exports.map1 = map1;
1678
1695
  exports.mapVal = mapVal;
1679
1696
  exports.max = max;
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.2",
6
+ "version": "0.0.3",
7
7
  "dependencies": {
8
8
  "dayjs": "^1.11.9",
9
9
  "dotenv": "^16.3.1",