@omegup/msync 0.0.78 → 0.0.80

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
@@ -483,7 +483,8 @@ type s$1 = string;
483
483
  declare const $unwindDelta: <K1 extends s$1, T extends doc, K2 extends s$1, U extends doc, Null extends null = never>(k1: AsLiteral<K1>, k2: AsLiteral<K2>, k: K1 | K2 | false, includeNull?: Null, middle?: string) => RawStages<Delta<Rec<K1, T>>, Delta<Rec<K1, T> & Rec<K2, Arr<U>>>, Delta<Rec<K1, T> & Rec<K2, U | Null> & ID>>;
484
484
 
485
485
  type s = string;
486
- declare const $unwind: <T extends doc, K extends s, U extends doc>(k: AsLiteral<K>, dict: RORec<K, "key">, middle?: string) => DeltaStages<O, T & Rec<K, Arr<U>>, T & Rec<K, U>>;
486
+ type TOf<TT, K extends string> = doc & Omit<TT, K>;
487
+ declare const $unwind: <TT extends O, K extends s, U extends doc>(k: AsLiteral<K>, dict: RORec<K, "key"> & RORec<"_id", "id">, middle?: string) => DeltaStages<O, TOf<TT, K> & Rec<K, Arr<U>>, TOf<TT, K> & Rec<K, U>>;
487
488
 
488
489
  type Allowed$2<K extends string> = Exclude<K, keyof (TS & ID)>;
489
490
  type Patch<V, KK extends StrKey<V> = StrKey<V>> = ((OPick<V, Allowed$2<KK>> & ID) | (Rec<Allowed$2<KK>, N> & ID)) & TS;
package/index.esm.js CHANGED
@@ -313,10 +313,10 @@ const toInt = (expr) => asExpr({
313
313
  raw: f => asExprRaw({ $toInt: expr.raw(f).get() }),
314
314
  });
315
315
  const fieldM = (expr, m) => asExpr({
316
- raw: (f) => asExprRaw(Object.fromEntries(Object.entries(m).map(([dom, ref]) => [
317
- dom,
318
- expr[ref].raw(f).get(),
319
- ]))),
316
+ raw: (f) => asExprRaw(Object.fromEntries(Object.entries(m).flatMap(([dom, ref]) => expr[ref] ? [[
317
+ dom,
318
+ expr[ref].raw(f).get(),
319
+ ]] : []))),
320
320
  });
321
321
  const mergeExact = (...[exprsExact1, exprsExact2]) => spread(exprsExact1, exprsExact2);
322
322
  const mergeExact0 = (...[exprsExact1, exprsExact2]) => spread0(exprsExact1, exprsExact2);
@@ -1059,30 +1059,28 @@ const $unwindDelta = (k1, k2, k, includeNull, middle) => {
1059
1059
  after: partReplace('after'),
1060
1060
  },
1061
1061
  },
1062
- ...(!k && middle
1063
- ? [
1064
- {
1065
- $set: { _id: { $ifNull: ['$before._id', '$after._id'] } },
1066
- },
1067
- ]
1068
- : []),
1062
+ ...(!k && middle ? [{ $set: { _id: { $ifNull: ['$before._id', '$after._id'] } } }] : []),
1069
1063
  ]))
1070
1064
  .with($match_($expr(ne(part('before'))(part('after'))))).stages;
1071
1065
  return stages;
1072
1066
  };
1073
1067
 
1074
- const $unwind = (k, dict, middle) => ({
1075
- delta: link()
1076
- .with($replaceWithDelta(field({
1077
- left: ['left', root().expr()],
1078
- right: ['right', root().of(k).expr()],
1079
- })))
1080
- .with($unwindDelta('left', 'right', false, undefined, middle))
1081
- .with($replaceWithDelta(mergeObjects(root().of('left').expr(), fieldM({
1082
- key: root().of('right').expr(),
1083
- }, dict)))).stages,
1084
- raw: $unwind1(k),
1085
- });
1068
+ const $unwind = (k, dict, middle) => {
1069
+ return {
1070
+ delta: link()
1071
+ .with($replaceWithDelta(field({
1072
+ _id: ['_id', root().of('_id').expr()],
1073
+ left: ['left', root().expr()],
1074
+ right: ['right', root().of(k).expr()],
1075
+ })))
1076
+ .with($unwindDelta('left', 'right', false, undefined, middle))
1077
+ .with($replaceWithDelta(mergeObjects(root().of('left').expr(), fieldM({
1078
+ key: root().of('right').expr(),
1079
+ id: root().of('_id').expr(),
1080
+ }, dict)))).stages,
1081
+ raw: $unwind1(k),
1082
+ };
1083
+ };
1086
1084
 
1087
1085
  const $lookupDelta = ({ field1, field2 }, { coll, exec, input }, k1, k2, k, includeNull) => {
1088
1086
  return link()
package/index.js CHANGED
@@ -315,10 +315,10 @@ const toInt = (expr) => asExpr({
315
315
  raw: f => asExprRaw({ $toInt: expr.raw(f).get() }),
316
316
  });
317
317
  const fieldM = (expr, m) => asExpr({
318
- raw: (f) => asExprRaw(Object.fromEntries(Object.entries(m).map(([dom, ref]) => [
319
- dom,
320
- expr[ref].raw(f).get(),
321
- ]))),
318
+ raw: (f) => asExprRaw(Object.fromEntries(Object.entries(m).flatMap(([dom, ref]) => expr[ref] ? [[
319
+ dom,
320
+ expr[ref].raw(f).get(),
321
+ ]] : []))),
322
322
  });
323
323
  const mergeExact = (...[exprsExact1, exprsExact2]) => spread(exprsExact1, exprsExact2);
324
324
  const mergeExact0 = (...[exprsExact1, exprsExact2]) => spread0(exprsExact1, exprsExact2);
@@ -1061,30 +1061,28 @@ const $unwindDelta = (k1, k2, k, includeNull, middle) => {
1061
1061
  after: partReplace('after'),
1062
1062
  },
1063
1063
  },
1064
- ...(!k && middle
1065
- ? [
1066
- {
1067
- $set: { _id: { $ifNull: ['$before._id', '$after._id'] } },
1068
- },
1069
- ]
1070
- : []),
1064
+ ...(!k && middle ? [{ $set: { _id: { $ifNull: ['$before._id', '$after._id'] } } }] : []),
1071
1065
  ]))
1072
1066
  .with($match_($expr(ne(part('before'))(part('after'))))).stages;
1073
1067
  return stages;
1074
1068
  };
1075
1069
 
1076
- const $unwind = (k, dict, middle) => ({
1077
- delta: link()
1078
- .with($replaceWithDelta(field({
1079
- left: ['left', root().expr()],
1080
- right: ['right', root().of(k).expr()],
1081
- })))
1082
- .with($unwindDelta('left', 'right', false, undefined, middle))
1083
- .with($replaceWithDelta(mergeObjects(root().of('left').expr(), fieldM({
1084
- key: root().of('right').expr(),
1085
- }, dict)))).stages,
1086
- raw: $unwind1(k),
1087
- });
1070
+ const $unwind = (k, dict, middle) => {
1071
+ return {
1072
+ delta: link()
1073
+ .with($replaceWithDelta(field({
1074
+ _id: ['_id', root().of('_id').expr()],
1075
+ left: ['left', root().expr()],
1076
+ right: ['right', root().of(k).expr()],
1077
+ })))
1078
+ .with($unwindDelta('left', 'right', false, undefined, middle))
1079
+ .with($replaceWithDelta(mergeObjects(root().of('left').expr(), fieldM({
1080
+ key: root().of('right').expr(),
1081
+ id: root().of('_id').expr(),
1082
+ }, dict)))).stages,
1083
+ raw: $unwind1(k),
1084
+ };
1085
+ };
1088
1086
 
1089
1087
  const $lookupDelta = ({ field1, field2 }, { coll, exec, input }, k1, k2, k, includeNull) => {
1090
1088
  return link()
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.78",
6
+ "version": "0.0.80",
7
7
  "dependencies": {
8
8
  "dayjs": "^1.11.9",
9
9
  "dotenv": "^16.3.1",