@omegup/msync 0.0.32-test2 → 0.0.32-test3

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
@@ -450,6 +450,31 @@ declare const $groupMerge: <T extends O, Grp extends notArr, V extends O, GG ext
450
450
  declare const $groupId: <T extends O, V extends O, EE = {}, Out extends Loose<string, V, "_id"> = Loose<string, V, "_id">>(id: Expr<string, T>, args: DeltaAccumulators<T, O & Omit<V, Denied>>, out: RWCollection<Replace<Out, Strict<string, V, "_id", EE>>, Out>, extra: ExprsExact<Omit<EE, IdAndTsKeys | keyof Omit<V, IdAndTsKeys>>, doc & Omit<V, IdAndTsKeys>>) => StreamRunnerParam<Delta<T>, "out">;
451
451
  declare const $group: <T extends O, Grp extends notArr, V extends O, EE = {}, Out extends Loose<Grp, V, "_grp"> = Loose<Grp, V, "_grp">>(id: Expr<Grp, T>, args: DeltaAccumulators<T, O & Omit<V, Denied<"_grp">>>, out: RWCollection<Strict<Grp, V, "_grp", EE>, Out>, extra: ExprsExact<Omit<EE, IdAndTsKeys | "_grp" | keyof Omit<V, IdAndTsKeys | "_grp">>, Rec<"_grp", Grp> & Omit<V, IdAndTsKeys | "_grp">>, idPrefix?: string) => StreamRunnerParam<Delta<T>, "out">;
452
452
 
453
+ declare const size: <T, D, C>(expr: Expr<Arr<T>, D, C>) => Expr<number, D, C>;
454
+ declare const filterDefined: <T, D, C = unknown>(expr: Expr<Arr<T | N>, D, C>) => Expr<Arr<T>, D, C>;
455
+ declare const filter: <T, D, K extends string, C = unknown>({ as, cond, expr, limit, }: {
456
+ expr: Expr<Arr<T>, D, C>;
457
+ as: K;
458
+ cond: Expr<unknown, D, C & RORec<K, T>>;
459
+ limit?: Expr<number, D, C>;
460
+ }) => Expr<Arr<T>, D, C>;
461
+ declare const sortArray: <T, D, C, K extends keyof T>({ sortBy, expr, order, }: {
462
+ expr: Expr<Arr<T>, D, C>;
463
+ sortBy: K;
464
+ order?: 1 | -1;
465
+ }) => Expr<Arr<T>, D, C>;
466
+ declare const isArray: <T extends notArr, D, C, F extends HKT<T | Arr<T>>>(expr: Expr<T | Arr<T>, D & (App<F, T> | App<F, Arr<T>>), C>) => BoolExpr<D & App<F, Arr<T>>, D & App<F, T>, C>;
467
+ declare const array: <T, D, C = unknown>(...exprs: Expr<T, D, C>[]) => Expr<Arr<T>, D, C>;
468
+ declare const concatArray: <T, D, C>(...exprs: Expr<Arr<T>, D, C>[]) => Expr<Arr<T>, D, C>;
469
+ declare const first: <T, D, C>(expr: Expr<Arr<T>, D, C>) => Expr<T | null, D, C>;
470
+ declare const firstSure: <T, D, C>(expr: Expr<Arr<T>, D, C>) => Expr<T, D, C>;
471
+ declare const last: <T, D, C>(expr: Expr<Arr<T>, D, C>) => Expr<T | null, D, C>;
472
+ type NullToOBJ<N extends null> = N extends null ? O : N;
473
+ declare const mergeObjects: <T1, T2, D, C = unknown, N extends null = never>(exprs_0: Expr<T1 | N, D, C>, exprs_1: Expr<T2, D, C>) => Expr<(T1 | NullToOBJ<N>) & T2, D, C>;
474
+ declare const inArray: <T, D, C = unknown>(exprs_0: Expr<T, D, C>, exprs_1: Expr<Arr<T>, D, C>) => Expr<boolean, D, C>;
475
+ declare const slice: <T, D, C>(array: Expr<Arr<T>, D, C>, start: Expr<number, D, C>, end: Expr<number, D, C>) => Expr<Arr<T>, D, C>;
476
+ declare const except: <T, D, C>(a: Expr<Arr<T>, D, C>, b: Expr<Arr<T>, D, C>) => Expr<Arr<T>, D, C>;
477
+
453
478
  type Params<As extends string, LQ extends O, RQ extends O, RE extends RQ, S extends notArr> = {
454
479
  localField: Field<LQ, S>;
455
480
  foreignField: Field<RQ, S>;
@@ -457,7 +482,10 @@ type Params<As extends string, LQ extends O, RQ extends O, RE extends RQ, S exte
457
482
  as: AsLiteral<As>;
458
483
  };
459
484
  declare const $lookup: <As extends string, LQ extends doc, RQ extends O, RE extends RQ & doc, S extends notArr>(p: Params<As, LQ, RQ, RE, S>) => <LE extends LQ>(l: SnapshotStream<LQ, LE>) => SnapshotStream<LQ, LE & RORec<As, RE>>;
460
- declare const $outerLookup: <As extends string, LQ extends doc, RQ extends O, RE extends RQ & doc, S extends notArr>(p: Params<As, LQ, RQ, RE, S>) => <LE extends LQ>(l: SnapshotStream<LQ, LE>) => SnapshotStream<LQ, LE & RORec<As, RE | null>>;
485
+ declare const $outerLookup: <As extends string, LQ extends doc, RQ extends O, RE extends RQ & doc, S extends notArr, LNull extends null = never, RNull extends null = never>(p: Params<As, LQ, RQ, RE, S>, outer: {
486
+ left?: LNull;
487
+ right?: RNull;
488
+ }) => <LE extends LQ>(l: SnapshotStream<LQ, LE>) => SnapshotStream<LQ | NullToOBJ<RNull>, (LE | NullToOBJ<RNull>) & RORec<As, RE | LNull>>;
461
489
 
462
490
  declare const $matchDelta: <T extends doc>(query: Expr<boolean, T>) => RawStages<unknown, Delta<T>, Delta<T>, unknown, number>;
463
491
 
@@ -549,30 +577,6 @@ declare function floor<D, C>(expr: Expr<Num, D, C>): Expr<Num, D, C>;
549
577
  declare function ceil<D, C>(expr: Expr<number, D, C>): Expr<number, D, C>;
550
578
  declare function ceil<D, C>(expr: Expr<Num, D, C>): Expr<Num, D, C>;
551
579
 
552
- declare const size: <T, D, C>(expr: Expr<Arr<T>, D, C>) => Expr<number, D, C>;
553
- declare const filterDefined: <T, D, C = unknown>(expr: Expr<Arr<T | N>, D, C>) => Expr<Arr<T>, D, C>;
554
- declare const filter: <T, D, K extends string, C = unknown>({ as, cond, expr, limit, }: {
555
- expr: Expr<Arr<T>, D, C>;
556
- as: K;
557
- cond: Expr<unknown, D, C & RORec<K, T>>;
558
- limit?: Expr<number, D, C>;
559
- }) => Expr<Arr<T>, D, C>;
560
- declare const sortArray: <T, D, C, K extends keyof T>({ sortBy, expr, order, }: {
561
- expr: Expr<Arr<T>, D, C>;
562
- sortBy: K;
563
- order?: 1 | -1;
564
- }) => Expr<Arr<T>, D, C>;
565
- declare const isArray: <T extends notArr, D, C, F extends HKT<T | Arr<T>>>(expr: Expr<T | Arr<T>, D & (App<F, T> | App<F, Arr<T>>), C>) => BoolExpr<D & App<F, Arr<T>>, D & App<F, T>, C>;
566
- declare const array: <T, D, C = unknown>(...exprs: Expr<T, D, C>[]) => Expr<Arr<T>, D, C>;
567
- declare const concatArray: <T, D, C>(...exprs: Expr<Arr<T>, D, C>[]) => Expr<Arr<T>, D, C>;
568
- declare const first: <T, D, C>(expr: Expr<Arr<T>, D, C>) => Expr<T | null, D, C>;
569
- declare const firstSure: <T, D, C>(expr: Expr<Arr<T>, D, C>) => Expr<T, D, C>;
570
- declare const last: <T, D, C>(expr: Expr<Arr<T>, D, C>) => Expr<T | null, D, C>;
571
- declare const mergeObjects: <T1, T2, D, C = unknown>(exprs_0: Expr<T1, D, C>, exprs_1: Expr<T2, D, C>) => Expr<T1 & T2, D, C>;
572
- declare const inArray: <T, D, C = unknown>(exprs_0: Expr<T, D, C>, exprs_1: Expr<Arr<T>, D, C>) => Expr<boolean, D, C>;
573
- declare const slice: <T, D, C>(array: Expr<Arr<T>, D, C>, start: Expr<number, D, C>, end: Expr<number, D, C>) => Expr<Arr<T>, D, C>;
574
- declare const except: <T, D, C>(a: Expr<Arr<T>, D, C>, b: Expr<Arr<T>, D, C>) => Expr<Arr<T>, D, C>;
575
-
576
580
  declare const dayAndMonthPart: <D, C>(date: Expr<Date, D, C>) => Expr<string, D, C>;
577
581
  declare const now: <D, C>() => Expr<Date, D, C>;
578
582
  declare const monthPart: <D, C>(date: Expr<Date, D, C>) => Expr<string, D, C>;
@@ -663,4 +667,4 @@ declare const enablePreAndPostImages: <T extends doc>(coll: Collection<T>) => Pr
663
667
  declare const prepare: (testName?: string) => Promise<MongoClient$1>;
664
668
  declare const makeCol: <T extends ID>(docs: readonly OptionalUnlessRequiredId<T>[], database: Db, name?: string) => Promise<Collection<T>>;
665
669
 
666
- 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 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 };
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 };
package/index.esm.js CHANGED
@@ -697,7 +697,7 @@ const $unwindDelta = (k1, k2, k, includeNull) => {
697
697
  cond: { $ne: ['$$a.before', '$$a.after'] },
698
698
  },
699
699
  };
700
- const ifNull = (k, part, str = `$${[k1, k2].sort()[0]}.${part}._id`) => outer && k == k2 ? { $ifNull: [str, 'null'] } : str;
700
+ const ifNull = (k, part, str = `$${k}.${part}._id`) => outer && k == k2 ? { $ifNull: [str, 'null'] } : str;
701
701
  const interDot = ([a, b]) => [a, '.', b];
702
702
  const partReplace = (part) => ({
703
703
  $cond: {
@@ -705,7 +705,7 @@ const $unwindDelta = (k1, k2, k, includeNull) => {
705
705
  then: null,
706
706
  else: {
707
707
  _id: k
708
- ? `$${k}.${part}._id`
708
+ ? ifNull(k, part)
709
709
  : {
710
710
  $concat: interDot([k1, k2].sort().map(k => ifNull(k, part))),
711
711
  },
@@ -963,7 +963,7 @@ const runCont = async ({ next }, cb) => {
963
963
  };
964
964
 
965
965
  const merge = ({ lsource: L, rsource: R, }) => mergeIterators({ sources: { L, R } });
966
- const join = ({ lField, rField, left, right, as }, leftSnapshot, rightSnapshot, stagesUntilNextLookup, includeNull) => {
966
+ const join = ({ lField, rField, left, right, as }, leftSnapshot, rightSnapshot, stagesUntilNextLookup, outerLeft, outerRight) => {
967
967
  createIndex(leftSnapshot.coll, { [`before.${lField.str()}`]: 1 }).catch(e => e.code == 86 || Promise.reject(e));
968
968
  createIndex(rightSnapshot.coll, { [`before.${rField.str()}`]: 1 }).catch(e => e.code == 86 || Promise.reject(e));
969
969
  const rightJoinField = { field1: lField, field2: rField };
@@ -977,8 +977,8 @@ const join = ({ lField, rField, left, right, as }, leftSnapshot, rightSnapshot,
977
977
  stages: consume => consume(concatTStages(resultingSnapshot, asBefore(stagesUntilNextLookup.raw))),
978
978
  out: (finalInput) => {
979
979
  const leftJoinField = { field1: rField, field2: lField };
980
- const joinL_Delta = $lookupDelta(leftJoinField, leftSnapshot, 'right', 'left', joinId);
981
- const joinR_Delta = $lookupDelta(rightJoinField, rightSnapshot, 'left', 'right', joinId, includeNull);
980
+ const joinL_Delta = $lookupDelta(leftJoinField, leftSnapshot, 'right', 'left', joinId, outerRight);
981
+ const joinR_Delta = $lookupDelta(rightJoinField, rightSnapshot, 'left', 'right', joinId, outerLeft);
982
982
  const mergeForeignIntoDoc = concatStages($replaceWithDelta(mergeObjects(root().of('left').expr(), fieldM({ a: root().of('right').expr(), b: root().of('_id').expr() }, dictId))), stagesUntilNextLookup.delta);
983
983
  const lRunnerInput = concatStages(joinR_Delta, mergeForeignIntoDoc);
984
984
  const rRunnerInput = concatStages(joinL_Delta, mergeForeignIntoDoc);
@@ -992,7 +992,7 @@ const join = ({ lField, rField, left, right, as }, leftSnapshot, rightSnapshot,
992
992
  },
993
993
  };
994
994
  };
995
- const $lookup1 = (p, includeNull) => (input) => p.left.stages((lStages) => p.right.stages((rStages) => join(p, lStages, rStages, input, includeNull)));
995
+ const $lookup1 = (p, outer) => (input) => p.left.stages((lStages) => p.right.stages((rStages) => join(p, lStages, rStages, input, outer?.left, outer?.right)));
996
996
  const $lookup = (p) => (l) => $lookup1({
997
997
  right: p.from,
998
998
  as: p.as,
@@ -1000,13 +1000,13 @@ const $lookup = (p) => (l) => $lookup1({
1000
1000
  rField: p.foreignField,
1001
1001
  left: l(emptyDelta()),
1002
1002
  });
1003
- const $outerLookup = (p) => (l) => $lookup1({
1003
+ const $outerLookup = (p, outer) => (l) => $lookup1({
1004
1004
  right: p.from,
1005
1005
  as: p.as,
1006
1006
  lField: p.localField,
1007
1007
  rField: p.foreignField,
1008
1008
  left: l(emptyDelta()),
1009
- }, null);
1009
+ }, outer);
1010
1010
 
1011
1011
  const operator = () => (op) => (operand) => {
1012
1012
  return {
package/index.js CHANGED
@@ -699,7 +699,7 @@ const $unwindDelta = (k1, k2, k, includeNull) => {
699
699
  cond: { $ne: ['$$a.before', '$$a.after'] },
700
700
  },
701
701
  };
702
- const ifNull = (k, part, str = `$${[k1, k2].sort()[0]}.${part}._id`) => outer && k == k2 ? { $ifNull: [str, 'null'] } : str;
702
+ const ifNull = (k, part, str = `$${k}.${part}._id`) => outer && k == k2 ? { $ifNull: [str, 'null'] } : str;
703
703
  const interDot = ([a, b]) => [a, '.', b];
704
704
  const partReplace = (part) => ({
705
705
  $cond: {
@@ -707,7 +707,7 @@ const $unwindDelta = (k1, k2, k, includeNull) => {
707
707
  then: null,
708
708
  else: {
709
709
  _id: k
710
- ? `$${k}.${part}._id`
710
+ ? ifNull(k, part)
711
711
  : {
712
712
  $concat: interDot([k1, k2].sort().map(k => ifNull(k, part))),
713
713
  },
@@ -965,7 +965,7 @@ const runCont = async ({ next }, cb) => {
965
965
  };
966
966
 
967
967
  const merge = ({ lsource: L, rsource: R, }) => mergeIterators({ sources: { L, R } });
968
- const join = ({ lField, rField, left, right, as }, leftSnapshot, rightSnapshot, stagesUntilNextLookup, includeNull) => {
968
+ const join = ({ lField, rField, left, right, as }, leftSnapshot, rightSnapshot, stagesUntilNextLookup, outerLeft, outerRight) => {
969
969
  createIndex(leftSnapshot.coll, { [`before.${lField.str()}`]: 1 }).catch(e => e.code == 86 || Promise.reject(e));
970
970
  createIndex(rightSnapshot.coll, { [`before.${rField.str()}`]: 1 }).catch(e => e.code == 86 || Promise.reject(e));
971
971
  const rightJoinField = { field1: lField, field2: rField };
@@ -979,8 +979,8 @@ const join = ({ lField, rField, left, right, as }, leftSnapshot, rightSnapshot,
979
979
  stages: consume => consume(concatTStages(resultingSnapshot, asBefore(stagesUntilNextLookup.raw))),
980
980
  out: (finalInput) => {
981
981
  const leftJoinField = { field1: rField, field2: lField };
982
- const joinL_Delta = $lookupDelta(leftJoinField, leftSnapshot, 'right', 'left', joinId);
983
- const joinR_Delta = $lookupDelta(rightJoinField, rightSnapshot, 'left', 'right', joinId, includeNull);
982
+ const joinL_Delta = $lookupDelta(leftJoinField, leftSnapshot, 'right', 'left', joinId, outerRight);
983
+ const joinR_Delta = $lookupDelta(rightJoinField, rightSnapshot, 'left', 'right', joinId, outerLeft);
984
984
  const mergeForeignIntoDoc = concatStages($replaceWithDelta(mergeObjects(root().of('left').expr(), fieldM({ a: root().of('right').expr(), b: root().of('_id').expr() }, dictId))), stagesUntilNextLookup.delta);
985
985
  const lRunnerInput = concatStages(joinR_Delta, mergeForeignIntoDoc);
986
986
  const rRunnerInput = concatStages(joinL_Delta, mergeForeignIntoDoc);
@@ -994,7 +994,7 @@ const join = ({ lField, rField, left, right, as }, leftSnapshot, rightSnapshot,
994
994
  },
995
995
  };
996
996
  };
997
- const $lookup1 = (p, includeNull) => (input) => p.left.stages((lStages) => p.right.stages((rStages) => join(p, lStages, rStages, input, includeNull)));
997
+ const $lookup1 = (p, outer) => (input) => p.left.stages((lStages) => p.right.stages((rStages) => join(p, lStages, rStages, input, outer?.left, outer?.right)));
998
998
  const $lookup = (p) => (l) => $lookup1({
999
999
  right: p.from,
1000
1000
  as: p.as,
@@ -1002,13 +1002,13 @@ const $lookup = (p) => (l) => $lookup1({
1002
1002
  rField: p.foreignField,
1003
1003
  left: l(emptyDelta()),
1004
1004
  });
1005
- const $outerLookup = (p) => (l) => $lookup1({
1005
+ const $outerLookup = (p, outer) => (l) => $lookup1({
1006
1006
  right: p.from,
1007
1007
  as: p.as,
1008
1008
  lField: p.localField,
1009
1009
  rField: p.foreignField,
1010
1010
  left: l(emptyDelta()),
1011
- }, null);
1011
+ }, outer);
1012
1012
 
1013
1013
  const operator = () => (op) => (operand) => {
1014
1014
  return {
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.32-test2",
6
+ "version": "0.0.32-test3",
7
7
  "dependencies": {
8
8
  "dayjs": "^1.11.9",
9
9
  "dotenv": "^16.3.1",