@omegup/msync 0.1.2 → 0.1.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 CHANGED
@@ -187,7 +187,10 @@ type DeltaAccumulator<in out Doc, in out T, in out Ctx = unknown> = {
187
187
  merge: <D, C = Ctx>(a: Expr<T | N, D, C>, b: Expr<T, D, C>) => Expr<T, D, C>;
188
188
  };
189
189
 
190
- declare const concat: <D, C>(...expr: Expr<string, D, C>[]) => Expr<string, D, C>;
190
+ declare const concat: {
191
+ <D, C>(...expr: Expr<string, D, C>[]): Expr<string, D, C>;
192
+ <D, C>(...expr: Expr<string | N, D, C>[]): Expr<string | N, D, C>;
193
+ };
191
194
  declare const regex: <D, C>(expr: Expr<string, D, C>, regex: Expr<string, D, C>, options?: Expr<string, D, C>) => Expr<boolean, D, C>;
192
195
  declare const str: <D, C>(expr: Expr<unknown, D, C>) => Expr<string, D, C>;
193
196
  declare const toInt: <D, C>(expr: Expr<unknown, D, C>) => Expr<number, D, C>;
@@ -415,7 +418,7 @@ type MergeInto<T extends O, Out extends O, E = unknown> = {
415
418
  type MergeArgs<T extends O, Out extends O, Ctx, In extends O> = {
416
419
  on: Field<T, jsonItem> & Field<Out, jsonItem>;
417
420
  } & MergeInto<T, Out> & (({
418
- stages?: undefined;
421
+ stages?: never;
419
422
  } & ({
420
423
  whenMatched: 'keepExisting' | 'fail';
421
424
  } | {
@@ -437,6 +440,7 @@ type MergeArgs<T extends O, Out extends O, Ctx, In extends O> = {
437
440
  whenMatched: RawStages<unknown, Out, In, Ctx>;
438
441
  });
439
442
  declare const $merge_: <T extends O, Out extends O = T, Ctx = unknown, In extends O = Out>({ into, on, whenNotMatched, ...notMatched }: MergeArgs<T, Out, Ctx, In>) => RawStages<unknown, T, "out", unknown, number>;
443
+ declare const $merge2: <T extends O, Out extends O = T, Ctx = unknown, In extends O = Out>(args: MergeArgs<T, Out, Ctx, In>) => RawStages<unknown, T, "out", unknown, number>;
440
444
 
441
445
  type GI$1<GG> = Exclude<GG, keyof TS>;
442
446
  type IdAndTsKeys = keyof (TS & ID);
@@ -488,6 +492,7 @@ type s = string;
488
492
  type TOf<TT, K extends string> = doc & Omit<TT, K>;
489
493
  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>>;
490
494
 
495
+ type OutInputE<T, E, A = T | null> = ID & Rec<'after', A> & E;
491
496
  type Allowed$2<K extends string> = Exclude<K, keyof (TS & ID)>;
492
497
  type Patch<V, KK extends StrKey<V> = StrKey<V>> = ((OPick<V, Allowed$2<KK>> & ID) | (Rec<Allowed$2<KK>, N> & ID)) & TS;
493
498
  type TakeDoc<V, E = ID, KK extends StrKey<V> = StrKey<V>> = OPick<V, Allowed$2<KK>> & E;
@@ -495,8 +500,10 @@ type ND$1 = {
495
500
  readonly deletedAt?: null;
496
501
  };
497
502
  type SafeE$1<E> = Omit<E, `$${string}` | keyof ID>;
503
+ declare const $mergeId: <V extends O>() => <SourcePart extends doc, Out extends doc, E = unknown, EEE extends RORec<string, rawItem> = {}>(out: RWCollection<Out | Replace<Out, Patch<V>>, Out>, keys: ExprsExact<TakeDoc<V, unknown>, SourcePart>, id: Expr<string, OutInputE<TakeDoc<V>, E, null>>, ext: Exact<Omit<SafeE$1<EEE>, keyof (ND$1 & TS)>, IdHKT>, whenNotMatched: "fail" | "discard") => StreamRunnerParam<OutInputE<SourcePart, E>, "out">;
498
504
  declare const $simpleMergePart: <V extends O>() => <Source extends doc, Out extends doc, EEE extends RORec<string, rawItem>>(out: RWCollection<Out | Replace<Out, Patch<V>>, Out>, keys: ExprsExact<TakeDoc<V, unknown>, Source>, whenNotMatched: "fail" | "discard", ext: Exact<Omit<SafeE$1<EEE>, keyof (ND$1 & TS)>, IdHKT>) => StreamRunnerParam<Source, "out">;
499
505
  declare const $simpleMerge: <V extends O>() => <Source extends doc, Out extends doc>(out: RWCollection<Out | Replace<Out, Patch<V>>, Out>, keys: ExprsExact<TakeDoc<V, unknown>, Source>, whenNotMatched?: "fail" | "discard") => StreamRunnerParam<Source, "out">;
506
+ declare const $mergePart: <V extends O>() => <Out extends doc, SourcePart extends doc, EEE extends RORec<string, rawItem>>(out: RWCollection<Out | Replace<Out, Patch<V>>, Out>, keys: ExprsExact<TakeDoc<V, unknown>, SourcePart>, ext: Exact<Omit<SafeE$1<EEE>, keyof (ND$1 & TS)>, IdHKT>, whenNotMatched?: "fail" | "discard") => StreamRunnerParam<Delta<SourcePart>, "out">;
500
507
  declare const $merge: <V extends O>() => <Out extends doc, SourcePart extends doc>(out: RWCollection<Out | Replace<Out, Patch<V>>, Out>, keys: ExprsExact<TakeDoc<V, unknown>, SourcePart>, whenNotMatched?: "fail" | "discard") => StreamRunnerParam<Delta<SourcePart>, "out">;
501
508
 
502
509
  type ND = {
@@ -703,4 +710,4 @@ declare const enablePreAndPostImages: <T extends doc>(coll: Collection<T>) => Pr
703
710
  declare const prepare: (testName?: string) => Promise<MongoClient$1>;
704
711
  declare const makeCol: <T extends ID>(docs: readonly OptionalUnlessRequiredId<T>[], database: Db, name?: string) => Promise<Collection<T>>;
705
712
 
706
- export { $accumulator, $and, $countDict, $entries, $eq, $exists, $expr, $getField, $group, $groupId, $groupMerge, $group_, $gt, $gtTs, $gte, $gteTs, $ifNull, $in, $insert, $insertPart, $insertX, $keys, $let, $lookup, $lt, $lte, $map, $map0, $map1, $match, $matchDelta, $merge, $merge_, $ne, $nin, $nor, $or, $outerLookup, $pushDict, $rand, $reduce, $replaceWith, $set, $simpleInsert, $simpleMerge, $simpleMergePart, $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, anyElementTrue, 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, not, type notArr, notNull, now, or, pair, prepare, rand, range, regex, root, set, setField, single, size, slice, sortArray, staging, startOf, str, sub, subtract, to, toInt, val, weekPart, wrap, year };
713
+ export { $accumulator, $and, $countDict, $entries, $eq, $exists, $expr, $getField, $group, $groupId, $groupMerge, $group_, $gt, $gtTs, $gte, $gteTs, $ifNull, $in, $insert, $insertPart, $insertX, $keys, $let, $lookup, $lt, $lte, $map, $map0, $map1, $match, $matchDelta, $merge, $merge2, $mergeId, $mergePart, $merge_, $ne, $nin, $nor, $or, $outerLookup, $pushDict, $rand, $reduce, $replaceWith, $set, $simpleInsert, $simpleMerge, $simpleMergePart, $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, anyElementTrue, 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, not, type notArr, notNull, now, or, pair, prepare, rand, range, regex, root, set, setField, single, size, slice, sortArray, staging, startOf, str, sub, subtract, to, toInt, val, weekPart, wrap, year };
package/index.esm.js CHANGED
@@ -573,6 +573,7 @@ const $merge_ = ({ into, on, whenNotMatched, ...notMatched }) => asStages([
573
573
  },
574
574
  },
575
575
  ]);
576
+ const $merge2 = (args) => $merge_(args);
576
577
 
577
578
  const subMerge = (args, out, gid, extra, idPrefix, first) => {
578
579
  const doubleReplace = (x) => x;
@@ -1399,7 +1400,12 @@ const $mergeX = (out, keys, f, map, whenNotMatched = 'fail', ext) => {
1399
1400
  $cond: {
1400
1401
  if: {
1401
1402
  $eq: [
1402
- { $mergeObjects: ['$old', { deletedAt: { $ifNull: ['$old.deletedAt', null] } }] },
1403
+ {
1404
+ $mergeObjects: [
1405
+ '$old',
1406
+ { deletedAt: { $ifNull: ['$old.deletedAt', null] } },
1407
+ ],
1408
+ },
1403
1409
  { $mergeObjects: ['$merged', { touchedAt: '$old.touchedAt' }] },
1404
1410
  ],
1405
1411
  },
@@ -1435,7 +1441,8 @@ const $mergeId = () => (out, keys, id, ext, whenNotMatched) => {
1435
1441
  };
1436
1442
  const $simpleMergePart = () => (out, keys, whenNotMatched, ext) => $mergeX(out, keys, root(), id$1, whenNotMatched, ext);
1437
1443
  const $simpleMerge = () => (out, keys, whenNotMatched = 'fail') => $mergeX(out, keys, root(), id$1, whenNotMatched, {});
1438
- const $merge = () => (out, keys, whenNotMatched = 'fail') => $mergeId()(out, keys, assertNotNull$1(root().of('before').of('_id').expr()), {}, whenNotMatched);
1444
+ const $mergePart = () => (out, keys, ext, whenNotMatched = 'fail') => $mergeId()(out, keys, assertNotNull$1(root().of('before').of('_id').expr()), ext, whenNotMatched);
1445
+ const $merge = () => (out, keys, whenNotMatched = 'fail') => $mergePart()(out, keys, {}, whenNotMatched);
1439
1446
  const assertNotNull$1 = (expr) => expr;
1440
1447
 
1441
1448
  const $insertX = (out, expr, map, ext, extExpr) => {
@@ -2000,4 +2007,4 @@ const makeCol = async (docs, database, name) => {
2000
2007
  }
2001
2008
  };
2002
2009
 
2003
- export { $accumulator, $and, $countDict, $entries, $eq, $exists, $expr, $getField, $group, $groupId, $groupMerge, $group_, $gt, $gtTs, $gte, $gteTs, $ifNull, $in, $insert, $insertPart, $insertX, $keys, $let, $lookup, $lt, $lte, $map, $map0, $map1, $match, $matchDelta, $merge, $merge_, $ne, $nin, $nor, $or, $outerLookup, $pushDict, $rand, $reduce, $replaceWith, $set, $simpleInsert, $simpleMerge, $simpleMergePart, $sum, $type, $unwind, $unwindDelta, Field, Machine, add, and, anyElementTrue, 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, not, notNull, now, or, pair, prepare, rand, range, regex, root, set, setField, single, size, slice, sortArray, staging, startOf, str, sub, subtract, to, toInt, val, weekPart, wrap, year };
2010
+ export { $accumulator, $and, $countDict, $entries, $eq, $exists, $expr, $getField, $group, $groupId, $groupMerge, $group_, $gt, $gtTs, $gte, $gteTs, $ifNull, $in, $insert, $insertPart, $insertX, $keys, $let, $lookup, $lt, $lte, $map, $map0, $map1, $match, $matchDelta, $merge, $merge2, $mergeId, $mergePart, $merge_, $ne, $nin, $nor, $or, $outerLookup, $pushDict, $rand, $reduce, $replaceWith, $set, $simpleInsert, $simpleMerge, $simpleMergePart, $sum, $type, $unwind, $unwindDelta, Field, Machine, add, and, anyElementTrue, 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, not, notNull, now, or, pair, prepare, rand, range, regex, root, set, setField, single, size, slice, sortArray, staging, startOf, str, sub, subtract, to, toInt, val, weekPart, wrap, year };
package/index.js CHANGED
@@ -575,6 +575,7 @@ const $merge_ = ({ into, on, whenNotMatched, ...notMatched }) => asStages([
575
575
  },
576
576
  },
577
577
  ]);
578
+ const $merge2 = (args) => $merge_(args);
578
579
 
579
580
  const subMerge = (args, out, gid, extra, idPrefix, first) => {
580
581
  const doubleReplace = (x) => x;
@@ -1401,7 +1402,12 @@ const $mergeX = (out, keys, f, map, whenNotMatched = 'fail', ext) => {
1401
1402
  $cond: {
1402
1403
  if: {
1403
1404
  $eq: [
1404
- { $mergeObjects: ['$old', { deletedAt: { $ifNull: ['$old.deletedAt', null] } }] },
1405
+ {
1406
+ $mergeObjects: [
1407
+ '$old',
1408
+ { deletedAt: { $ifNull: ['$old.deletedAt', null] } },
1409
+ ],
1410
+ },
1405
1411
  { $mergeObjects: ['$merged', { touchedAt: '$old.touchedAt' }] },
1406
1412
  ],
1407
1413
  },
@@ -1437,7 +1443,8 @@ const $mergeId = () => (out, keys, id, ext, whenNotMatched) => {
1437
1443
  };
1438
1444
  const $simpleMergePart = () => (out, keys, whenNotMatched, ext) => $mergeX(out, keys, root(), id$1, whenNotMatched, ext);
1439
1445
  const $simpleMerge = () => (out, keys, whenNotMatched = 'fail') => $mergeX(out, keys, root(), id$1, whenNotMatched, {});
1440
- const $merge = () => (out, keys, whenNotMatched = 'fail') => $mergeId()(out, keys, assertNotNull$1(root().of('before').of('_id').expr()), {}, whenNotMatched);
1446
+ const $mergePart = () => (out, keys, ext, whenNotMatched = 'fail') => $mergeId()(out, keys, assertNotNull$1(root().of('before').of('_id').expr()), ext, whenNotMatched);
1447
+ const $merge = () => (out, keys, whenNotMatched = 'fail') => $mergePart()(out, keys, {}, whenNotMatched);
1441
1448
  const assertNotNull$1 = (expr) => expr;
1442
1449
 
1443
1450
  const $insertX = (out, expr, map, ext, extExpr) => {
@@ -2034,6 +2041,9 @@ exports.$map1 = $map1;
2034
2041
  exports.$match = $match;
2035
2042
  exports.$matchDelta = $matchDelta;
2036
2043
  exports.$merge = $merge;
2044
+ exports.$merge2 = $merge2;
2045
+ exports.$mergeId = $mergeId;
2046
+ exports.$mergePart = $mergePart;
2037
2047
  exports.$merge_ = $merge_;
2038
2048
  exports.$ne = $ne;
2039
2049
  exports.$nin = $nin;
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.1.2",
6
+ "version": "0.1.4",
7
7
  "dependencies": {
8
8
  "dayjs": "^1.11.9",
9
9
  "dotenv": "^16.3.1",