@omegup/msync 0.0.2 → 0.0.4
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 +4 -2
- package/index.esm.js +23 -4
- package/index.js +24 -3
- package/package.json +1 -1
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
|
|
|
@@ -554,6 +554,7 @@ declare const except: <T, D, C>(a: Expr<Arr<T>, D, C>, b: Expr<Arr<T>, D, C>) =>
|
|
|
554
554
|
declare const dayAndMonthPart: <D, C>(date: Expr<Date, D, C>) => Expr<string, D, C>;
|
|
555
555
|
declare const now: <D, C>() => Expr<Date, D, C>;
|
|
556
556
|
declare const monthPart: <D, C>(date: Expr<Date, D, C>) => Expr<string, D, C>;
|
|
557
|
+
declare const weekPart: <D, C>(date: Expr<Date, D, C>) => Expr<string, D, C>;
|
|
557
558
|
declare const dateAdd: <D, C>(date: Expr<Date, D, C>, amount: Expr<number, D, C>, unit: Expr<"year" | "week" | "month" | "day" | "hour" | "minute" | "second", D, C>) => Expr<Date, D, C>;
|
|
558
559
|
declare const maxDate: <D, C>(expr: Expr<Arr<Date>, D, C>) => Expr<Date, D, C>;
|
|
559
560
|
declare const minDate: <D, C>(expr: Expr<Arr<Date>, D, C>) => Expr<Date, D, C>;
|
|
@@ -636,5 +637,6 @@ declare const map1: <K extends string, Im>(k: AsLiteral<K>, to: Im) => { readonl
|
|
|
636
637
|
|
|
637
638
|
declare const enablePreAndPostImages: <T extends doc>(coll: Collection<T>) => Promise<bson.Document>;
|
|
638
639
|
declare const prepare: (testName?: string) => Promise<MongoClient$1>;
|
|
640
|
+
declare const makeCol: <T extends ID>(docs: readonly OptionalUnlessRequiredId<T>[], database: Db, name?: string) => Promise<Collection<T>>;
|
|
639
641
|
|
|
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 };
|
|
642
|
+
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, weekPart, 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');
|
|
@@ -1344,6 +1344,9 @@ const now = () => asExpr({
|
|
|
1344
1344
|
const monthPart = (date) => asExpr({
|
|
1345
1345
|
raw: f => asExprRaw({ $dateToString: { date: date.raw(f).get(), format: '%Y-%m' } }),
|
|
1346
1346
|
});
|
|
1347
|
+
const weekPart = (date) => asExpr({
|
|
1348
|
+
raw: f => asExprRaw({ $dateToString: { date: date.raw(f).get(), format: '%Y-%U' } }),
|
|
1349
|
+
});
|
|
1347
1350
|
const dateAdd = (date, amount, unit) => asExpr({
|
|
1348
1351
|
raw: f => asExprRaw({
|
|
1349
1352
|
$dateAdd: {
|
|
@@ -1590,5 +1593,21 @@ const prepare = async (testName) => {
|
|
|
1590
1593
|
});
|
|
1591
1594
|
return client;
|
|
1592
1595
|
};
|
|
1596
|
+
const makeCol = async (docs, database, name) => {
|
|
1597
|
+
if (!name) {
|
|
1598
|
+
(name = crypto.randomUUID());
|
|
1599
|
+
}
|
|
1600
|
+
try {
|
|
1601
|
+
const col = await database.createCollection(name, {
|
|
1602
|
+
changeStreamPreAndPostImages: { enabled: true },
|
|
1603
|
+
});
|
|
1604
|
+
if (docs.length)
|
|
1605
|
+
await col.insertMany([...docs]);
|
|
1606
|
+
return col;
|
|
1607
|
+
}
|
|
1608
|
+
catch {
|
|
1609
|
+
return database.collection(name);
|
|
1610
|
+
}
|
|
1611
|
+
};
|
|
1593
1612
|
|
|
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 };
|
|
1613
|
+
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, weekPart, 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');
|
|
@@ -1346,6 +1346,9 @@ const now = () => asExpr({
|
|
|
1346
1346
|
const monthPart = (date) => asExpr({
|
|
1347
1347
|
raw: f => asExprRaw({ $dateToString: { date: date.raw(f).get(), format: '%Y-%m' } }),
|
|
1348
1348
|
});
|
|
1349
|
+
const weekPart = (date) => asExpr({
|
|
1350
|
+
raw: f => asExprRaw({ $dateToString: { date: date.raw(f).get(), format: '%Y-%U' } }),
|
|
1351
|
+
});
|
|
1349
1352
|
const dateAdd = (date, amount, unit) => asExpr({
|
|
1350
1353
|
raw: f => asExprRaw({
|
|
1351
1354
|
$dateAdd: {
|
|
@@ -1592,6 +1595,22 @@ const prepare = async (testName) => {
|
|
|
1592
1595
|
});
|
|
1593
1596
|
return client;
|
|
1594
1597
|
};
|
|
1598
|
+
const makeCol = async (docs, database, name) => {
|
|
1599
|
+
if (!name) {
|
|
1600
|
+
(name = crypto.randomUUID());
|
|
1601
|
+
}
|
|
1602
|
+
try {
|
|
1603
|
+
const col = await database.createCollection(name, {
|
|
1604
|
+
changeStreamPreAndPostImages: { enabled: true },
|
|
1605
|
+
});
|
|
1606
|
+
if (docs.length)
|
|
1607
|
+
await col.insertMany([...docs]);
|
|
1608
|
+
return col;
|
|
1609
|
+
}
|
|
1610
|
+
catch {
|
|
1611
|
+
return database.collection(name);
|
|
1612
|
+
}
|
|
1613
|
+
};
|
|
1595
1614
|
|
|
1596
1615
|
exports.$accumulator = $accumulator;
|
|
1597
1616
|
exports.$and = $and;
|
|
@@ -1674,6 +1693,7 @@ exports.last = last;
|
|
|
1674
1693
|
exports.log = log;
|
|
1675
1694
|
exports.lt = lt;
|
|
1676
1695
|
exports.lte = lte;
|
|
1696
|
+
exports.makeCol = makeCol;
|
|
1677
1697
|
exports.map1 = map1;
|
|
1678
1698
|
exports.mapVal = mapVal;
|
|
1679
1699
|
exports.max = max;
|
|
@@ -1708,4 +1728,5 @@ exports.subtract = subtract;
|
|
|
1708
1728
|
exports.to = to;
|
|
1709
1729
|
exports.toInt = toInt;
|
|
1710
1730
|
exports.val = val;
|
|
1731
|
+
exports.weekPart = weekPart;
|
|
1711
1732
|
exports.wrap = wrap;
|