@omegup/msync 0.0.47 → 0.0.48
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 +18 -10
- package/index.esm.js +11 -7
- package/index.js +11 -6
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -27,7 +27,6 @@ declare const Predicate: unique symbol;
|
|
|
27
27
|
interface Predicate<in V> {
|
|
28
28
|
[Type]?(x: typeof Predicate, _: V): void;
|
|
29
29
|
raw: PredicateRaw;
|
|
30
|
-
expr: <D extends O, C>(field: Field<D, V, C>) => Expr<boolean, D, C>;
|
|
31
30
|
}
|
|
32
31
|
|
|
33
32
|
declare class Field<in R, out V, in C = unknown> {
|
|
@@ -629,14 +628,23 @@ declare const wrap: <Result>(root: Machine<Result>) => Machine<Result>;
|
|
|
629
628
|
declare const $eq: <T extends unknown>(operand: rawItem & T) => Predicate<T>;
|
|
630
629
|
declare const $ne: <T extends unknown>(operand: rawItem & T) => Predicate<T>;
|
|
631
630
|
type Numeric = number | Timestamp | Date;
|
|
632
|
-
declare const comp: <D2 extends Numeric =
|
|
633
|
-
declare const $gt: <T extends
|
|
634
|
-
declare const $gtTs: <T extends
|
|
635
|
-
declare const $gteTs: <T extends
|
|
636
|
-
declare const $lt: <T extends
|
|
637
|
-
declare const dateLt: <T extends
|
|
638
|
-
declare const $gte: <T extends
|
|
639
|
-
declare const $lte: <T extends
|
|
631
|
+
declare const comp: <D2 extends Numeric = Numeric>(op: "$lte" | "$gte" | "$lt" | "$gt") => <T extends Numeric>(operand: rawItem & D2) => Predicate<D2>;
|
|
632
|
+
declare const $gt: <T extends Numeric>(operand: rawItem & Numeric) => Predicate<Numeric>;
|
|
633
|
+
declare const $gtTs: <T extends Numeric>(operand: rawItem & Timestamp) => Predicate<Timestamp>;
|
|
634
|
+
declare const $gteTs: <T extends Numeric>(operand: rawItem & Timestamp) => Predicate<Timestamp>;
|
|
635
|
+
declare const $lt: <T extends Numeric>(operand: rawItem & number) => Predicate<number>;
|
|
636
|
+
declare const dateLt: <T extends Numeric>(operand: rawItem & Date) => Predicate<Date>;
|
|
637
|
+
declare const $gte: <T extends Numeric>(operand: rawItem & number) => Predicate<number>;
|
|
638
|
+
declare const $lte: <T extends Numeric>(operand: rawItem & number) => Predicate<number>;
|
|
639
|
+
type MongoTypes = {
|
|
640
|
+
number: number;
|
|
641
|
+
array: readonly rawItem[];
|
|
642
|
+
string: string;
|
|
643
|
+
object: RawObj;
|
|
644
|
+
[i: number]: unknown;
|
|
645
|
+
};
|
|
646
|
+
type MongoTypeNames = keyof MongoTypes;
|
|
647
|
+
declare const $type: <T extends keyof MongoTypes>(operand: rawItem & readonly T[]) => Predicate<N | MongoTypes[T]>;
|
|
640
648
|
|
|
641
649
|
declare const $expr: <D extends O, C>(expr: Expr<boolean, D, C>) => Query<D, C>;
|
|
642
650
|
|
|
@@ -667,4 +675,4 @@ declare const enablePreAndPostImages: <T extends doc>(coll: Collection<T>) => Pr
|
|
|
667
675
|
declare const prepare: (testName?: string) => Promise<MongoClient$1>;
|
|
668
676
|
declare const makeCol: <T extends ID>(docs: readonly OptionalUnlessRequiredId<T>[], database: Db, name?: string) => Promise<Collection<T>>;
|
|
669
677
|
|
|
670
|
-
export { $accumulator, $and, $countDict, $entries, $eq, $expr, $getField, $group, $groupId, $groupMerge, $gt, $gtTs, $gte, $gteTs, $ifNull, $in, $insert, $insertX, $keys, $let, $lookup, $lt, $lte, $map, $map1, $match, $matchDelta, $merge, $merge_, $ne, $nin, $nor, $or, $outerLookup, $pushDict, $rand, $replaceWith, $set, $simpleInsert, $simpleMerge, $sum, $unwind, $unwindDelta, 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 NullToOBJ, 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, or, pair, prepare, rand, range, root, set, setField, size, slice, sortArray, staging, startOf, str, sub, subtract, to, toInt, val, weekPart, wrap, year };
|
|
678
|
+
export { $accumulator, $and, $countDict, $entries, $eq, $expr, $getField, $group, $groupId, $groupMerge, $gt, $gtTs, $gte, $gteTs, $ifNull, $in, $insert, $insertX, $keys, $let, $lookup, $lt, $lte, $map, $map1, $match, $matchDelta, $merge, $merge_, $ne, $nin, $nor, $or, $outerLookup, $pushDict, $rand, $replaceWith, $set, $simpleInsert, $simpleMerge, $sum, $type, $unwind, $unwindDelta, 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 MongoTypeNames, type N, type NoRaw, type NullToOBJ, 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, or, pair, prepare, rand, range, root, set, setField, size, slice, sortArray, staging, startOf, str, sub, subtract, to, toInt, val, weekPart, wrap, year };
|
package/index.esm.js
CHANGED
|
@@ -885,9 +885,6 @@ const $map = (ex, map) => $map1(ex, i => map(i.expr()));
|
|
|
885
885
|
const operator = () => (op) => (operand) => {
|
|
886
886
|
return {
|
|
887
887
|
raw: { [op]: operand },
|
|
888
|
-
expr: (field) => asExpr({
|
|
889
|
-
raw: f => asExprRaw({ [op]: [$ifNull(field.expr(), nil).raw(f).get(), operand] }),
|
|
890
|
-
}),
|
|
891
888
|
};
|
|
892
889
|
};
|
|
893
890
|
|
|
@@ -902,6 +899,7 @@ const $lt = comp('$lt');
|
|
|
902
899
|
const dateLt = comp('$lt');
|
|
903
900
|
const $gte = comp('$gte');
|
|
904
901
|
const $lte = comp('$lte');
|
|
902
|
+
const $type = operator()('$type');
|
|
905
903
|
|
|
906
904
|
const $expr = (expr) => ({
|
|
907
905
|
raw: f => ({ $expr: expr.raw(f).get() }),
|
|
@@ -1484,8 +1482,14 @@ const executes$1 = (view, input, streamName) => {
|
|
|
1484
1482
|
streamNames[streamName] = hash;
|
|
1485
1483
|
else if (streamNames[streamName] != hash)
|
|
1486
1484
|
throw new Error(`streamName ${streamName} already used`);
|
|
1487
|
-
const { collection, projection, hardMatch, match } = view;
|
|
1488
|
-
const
|
|
1485
|
+
const { collection, projection, hardMatch: pre, match } = view;
|
|
1486
|
+
const types = Array.from({ length: 19 }).map((_, i) => i + 1);
|
|
1487
|
+
const removeNotYetSynchronizedFields = Object.values(mapExactToObject(projection, (_, k) => k.startsWith('_')
|
|
1488
|
+
? root()
|
|
1489
|
+
.of(k)
|
|
1490
|
+
.has($type(types.filter(x => x != 10)))
|
|
1491
|
+
: null));
|
|
1492
|
+
const hardMatch = $and(pre, ...removeNotYetSynchronizedFields);
|
|
1489
1493
|
const job = {};
|
|
1490
1494
|
const db = collection.s.db, coll = collection.collectionName;
|
|
1491
1495
|
db.command({
|
|
@@ -1569,7 +1573,7 @@ const executes$1 = (view, input, streamName) => {
|
|
|
1569
1573
|
const step3 = (lastTS) => async () => {
|
|
1570
1574
|
const hardQuery = $and(lastTS
|
|
1571
1575
|
? root().of('touchedAt').has($gteTs(lastTS.ts))
|
|
1572
|
-
: root().of('deletedAt').has($eq(null)), lastTS ? null : match && $expr(match), hardMatch
|
|
1576
|
+
: root().of('deletedAt').has($eq(null)), lastTS ? null : match && $expr(match), hardMatch);
|
|
1573
1577
|
const notDeleted = eq($ifNull(root().of('deletedAt').expr(), nil))(nil);
|
|
1574
1578
|
const query = match ? and(notDeleted, match) : notDeleted;
|
|
1575
1579
|
const replaceRaw = $replaceWith_(field({
|
|
@@ -1806,4 +1810,4 @@ const makeCol = async (docs, database, name) => {
|
|
|
1806
1810
|
}
|
|
1807
1811
|
};
|
|
1808
1812
|
|
|
1809
|
-
export { $accumulator, $and, $countDict, $entries, $eq, $expr, $getField, $group, $groupId, $groupMerge, $gt, $gtTs, $gte, $gteTs, $ifNull, $in, $insert, $insertX, $keys, $let, $lookup, $lt, $lte, $map, $map1, $match, $matchDelta, $merge, $merge_, $ne, $nin, $nor, $or, $outerLookup, $pushDict, $rand, $replaceWith, $set, $simpleInsert, $simpleMerge, $sum, $unwind, $unwindDelta, 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, or, pair, prepare, rand, range, root, set, setField, size, slice, sortArray, staging, startOf, str, sub, subtract, to, toInt, val, weekPart, wrap, year };
|
|
1813
|
+
export { $accumulator, $and, $countDict, $entries, $eq, $expr, $getField, $group, $groupId, $groupMerge, $gt, $gtTs, $gte, $gteTs, $ifNull, $in, $insert, $insertX, $keys, $let, $lookup, $lt, $lte, $map, $map1, $match, $matchDelta, $merge, $merge_, $ne, $nin, $nor, $or, $outerLookup, $pushDict, $rand, $replaceWith, $set, $simpleInsert, $simpleMerge, $sum, $type, $unwind, $unwindDelta, 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, or, pair, prepare, rand, range, root, set, setField, size, slice, sortArray, staging, startOf, str, sub, subtract, to, toInt, val, weekPart, wrap, year };
|
package/index.js
CHANGED
|
@@ -887,9 +887,6 @@ const $map = (ex, map) => $map1(ex, i => map(i.expr()));
|
|
|
887
887
|
const operator = () => (op) => (operand) => {
|
|
888
888
|
return {
|
|
889
889
|
raw: { [op]: operand },
|
|
890
|
-
expr: (field) => asExpr({
|
|
891
|
-
raw: f => asExprRaw({ [op]: [$ifNull(field.expr(), nil).raw(f).get(), operand] }),
|
|
892
|
-
}),
|
|
893
890
|
};
|
|
894
891
|
};
|
|
895
892
|
|
|
@@ -904,6 +901,7 @@ const $lt = comp('$lt');
|
|
|
904
901
|
const dateLt = comp('$lt');
|
|
905
902
|
const $gte = comp('$gte');
|
|
906
903
|
const $lte = comp('$lte');
|
|
904
|
+
const $type = operator()('$type');
|
|
907
905
|
|
|
908
906
|
const $expr = (expr) => ({
|
|
909
907
|
raw: f => ({ $expr: expr.raw(f).get() }),
|
|
@@ -1486,8 +1484,14 @@ const executes$1 = (view, input, streamName) => {
|
|
|
1486
1484
|
streamNames[streamName] = hash;
|
|
1487
1485
|
else if (streamNames[streamName] != hash)
|
|
1488
1486
|
throw new Error(`streamName ${streamName} already used`);
|
|
1489
|
-
const { collection, projection, hardMatch, match } = view;
|
|
1490
|
-
const
|
|
1487
|
+
const { collection, projection, hardMatch: pre, match } = view;
|
|
1488
|
+
const types = Array.from({ length: 19 }).map((_, i) => i + 1);
|
|
1489
|
+
const removeNotYetSynchronizedFields = Object.values(mapExactToObject(projection, (_, k) => k.startsWith('_')
|
|
1490
|
+
? root()
|
|
1491
|
+
.of(k)
|
|
1492
|
+
.has($type(types.filter(x => x != 10)))
|
|
1493
|
+
: null));
|
|
1494
|
+
const hardMatch = $and(pre, ...removeNotYetSynchronizedFields);
|
|
1491
1495
|
const job = {};
|
|
1492
1496
|
const db = collection.s.db, coll = collection.collectionName;
|
|
1493
1497
|
db.command({
|
|
@@ -1571,7 +1575,7 @@ const executes$1 = (view, input, streamName) => {
|
|
|
1571
1575
|
const step3 = (lastTS) => async () => {
|
|
1572
1576
|
const hardQuery = $and(lastTS
|
|
1573
1577
|
? root().of('touchedAt').has($gteTs(lastTS.ts))
|
|
1574
|
-
: root().of('deletedAt').has($eq(null)), lastTS ? null : match && $expr(match), hardMatch
|
|
1578
|
+
: root().of('deletedAt').has($eq(null)), lastTS ? null : match && $expr(match), hardMatch);
|
|
1575
1579
|
const notDeleted = eq($ifNull(root().of('deletedAt').expr(), nil))(nil);
|
|
1576
1580
|
const query = match ? and(notDeleted, match) : notDeleted;
|
|
1577
1581
|
const replaceRaw = $replaceWith_(field({
|
|
@@ -1849,6 +1853,7 @@ exports.$set = $set;
|
|
|
1849
1853
|
exports.$simpleInsert = $simpleInsert;
|
|
1850
1854
|
exports.$simpleMerge = $simpleMerge;
|
|
1851
1855
|
exports.$sum = $sum;
|
|
1856
|
+
exports.$type = $type;
|
|
1852
1857
|
exports.$unwind = $unwind;
|
|
1853
1858
|
exports.$unwindDelta = $unwindDelta;
|
|
1854
1859
|
exports.Field = Field;
|