@omegup/msync 0.0.46 → 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 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 = number>(op: "$lte" | "$gte" | "$lt" | "$gt") => <T extends D2>(operand: rawItem & D2) => Predicate<D2>;
633
- declare const $gt: <T extends number>(operand: rawItem & number) => Predicate<number>;
634
- declare const $gtTs: <T extends Timestamp>(operand: rawItem & Timestamp) => Predicate<Timestamp>;
635
- declare const $gteTs: <T extends Timestamp>(operand: rawItem & Timestamp) => Predicate<Timestamp>;
636
- declare const $lt: <T extends number>(operand: rawItem & number) => Predicate<number>;
637
- declare const dateLt: <T extends Date>(operand: rawItem & Date) => Predicate<Date>;
638
- declare const $gte: <T extends number>(operand: rawItem & number) => Predicate<number>;
639
- declare const $lte: <T extends number>(operand: rawItem & number) => Predicate<number>;
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() }),
@@ -1485,7 +1483,12 @@ const executes$1 = (view, input, streamName) => {
1485
1483
  else if (streamNames[streamName] != hash)
1486
1484
  throw new Error(`streamName ${streamName} already used`);
1487
1485
  const { collection, projection, hardMatch: pre, match } = view;
1488
- const removeNotYetSynchronizedFields = Object.values(mapExactToObject(projection, (_, k) => k.startsWith('_') ? root().of(k).has($ne(null)) : null));
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));
1489
1492
  const hardMatch = $and(pre, ...removeNotYetSynchronizedFields);
1490
1493
  const job = {};
1491
1494
  const db = collection.s.db, coll = collection.collectionName;
@@ -1807,4 +1810,4 @@ const makeCol = async (docs, database, name) => {
1807
1810
  }
1808
1811
  };
1809
1812
 
1810
- 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() }),
@@ -1487,7 +1485,12 @@ const executes$1 = (view, input, streamName) => {
1487
1485
  else if (streamNames[streamName] != hash)
1488
1486
  throw new Error(`streamName ${streamName} already used`);
1489
1487
  const { collection, projection, hardMatch: pre, match } = view;
1490
- const removeNotYetSynchronizedFields = Object.values(mapExactToObject(projection, (_, k) => k.startsWith('_') ? root().of(k).has($ne(null)) : null));
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));
1491
1494
  const hardMatch = $and(pre, ...removeNotYetSynchronizedFields);
1492
1495
  const job = {};
1493
1496
  const db = collection.s.db, coll = collection.collectionName;
@@ -1850,6 +1853,7 @@ exports.$set = $set;
1850
1853
  exports.$simpleInsert = $simpleInsert;
1851
1854
  exports.$simpleMerge = $simpleMerge;
1852
1855
  exports.$sum = $sum;
1856
+ exports.$type = $type;
1853
1857
  exports.$unwind = $unwind;
1854
1858
  exports.$unwindDelta = $unwindDelta;
1855
1859
  exports.Field = Field;
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.46",
6
+ "version": "0.0.48",
7
7
  "dependencies": {
8
8
  "dayjs": "^1.11.9",
9
9
  "dotenv": "^16.3.1",