@omegup/msync 0.0.6 → 0.0.8

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
@@ -466,9 +466,10 @@ declare const $unwindDelta: <K1 extends s$1, T extends doc, K2 extends s$1, U ex
466
466
  type s = string;
467
467
  declare const $unwind: <T extends doc, K extends s, U extends doc>(k: AsLiteral<K>, dict: RORec<K, "key">) => DeltaStages<O, T & Rec<K, Arr<U>>, T & Rec<K, U>>;
468
468
 
469
+ type OutInputE<T, E, A = T | null> = ID & Rec<'after', A> & E;
469
470
  type Allowed$2<K extends string> = Exclude<K, keyof (TS & ID)>;
470
471
  type Patch<V, KK extends StrKey<V>> = ((OPick<V, Allowed$2<KK>> & ID) | (Rec<Allowed$2<KK>, N> & ID)) & TS;
471
- declare const $merge: <V extends Model & ID>() => <KK extends StrKey<V>, Out extends doc>(out: RWCollection<Out | Replace<Out, Patch<V, KK>>, Out>, keys: ExactKeys<Allowed$2<KK>>) => RawStages<unknown, OutInput<OPick<V, Allowed$2<KK>> & ID>, "out">;
472
+ declare const $merge: <V extends Model & ID>() => <KK extends StrKey<V>, Out extends doc, E = unknown>(out: RWCollection<Out | Replace<Out, Patch<V, KK>>, Out>, keys: ExactKeys<Allowed$2<KK>>, id: Expr<string, OutInputE<OPick<V, Allowed$2<KK>> & ID, E, null>>) => RawStages<unknown, OutInputE<OPick<V, Allowed$2<KK>> & ID, E>, "out">;
472
473
 
473
474
  type ND = {
474
475
  readonly deletedAt?: null;
package/index.esm.js CHANGED
@@ -1010,11 +1010,11 @@ const $replaceWith = (expr) => ({
1010
1010
  lin: $replaceWith_(expr),
1011
1011
  });
1012
1012
 
1013
- const $merge = () => (out, keys) => {
1013
+ const $merge = () => (out, keys, id) => {
1014
1014
  const omRORec = omitRORec();
1015
1015
  const patch = mapExactToObject(keys, (_, k) => [k, root().of('after').of(k).expr()]);
1016
1016
  const replacer = ite(eqTyped(root().of('after').expr(), nil), field(omRORec.backward(spread(mapExact(keys, () => nil), {
1017
- _id: ['_id', root().of('_id').expr()],
1017
+ _id: ['_id', id],
1018
1018
  touchedAt: ['touchedAt', current],
1019
1019
  }))), field(omitPick().backward(spread(patch, {
1020
1020
  _id: ['_id', root().of('after').of('_id').expr()],
@@ -1088,7 +1088,7 @@ const addTeardown = (it, tr) => {
1088
1088
  const changeKeys = ['fullDocument', 'fullDocumentBeforeChange'];
1089
1089
  const subQ = (a, f) => ({ raw: g => a.raw(g.with(f)) });
1090
1090
  const makeWatchStream = (db, { collection, projection: p, hardMatch: m }, startAt) => {
1091
- const projection = mapExactToObject(p, v => v);
1091
+ const projection = { ...mapExactToObject(p, v => v), deletedAt: 1 };
1092
1092
  const pipeline = [];
1093
1093
  if (m) {
1094
1094
  const q = $or(...changeKeys.map((k) => subQ(m, root().of(k))));
package/index.js CHANGED
@@ -1012,11 +1012,11 @@ const $replaceWith = (expr) => ({
1012
1012
  lin: $replaceWith_(expr),
1013
1013
  });
1014
1014
 
1015
- const $merge = () => (out, keys) => {
1015
+ const $merge = () => (out, keys, id) => {
1016
1016
  const omRORec = omitRORec();
1017
1017
  const patch = mapExactToObject(keys, (_, k) => [k, root().of('after').of(k).expr()]);
1018
1018
  const replacer = ite(eqTyped(root().of('after').expr(), nil), field(omRORec.backward(spread(mapExact(keys, () => nil), {
1019
- _id: ['_id', root().of('_id').expr()],
1019
+ _id: ['_id', id],
1020
1020
  touchedAt: ['touchedAt', current],
1021
1021
  }))), field(omitPick().backward(spread(patch, {
1022
1022
  _id: ['_id', root().of('after').of('_id').expr()],
@@ -1090,7 +1090,7 @@ const addTeardown = (it, tr) => {
1090
1090
  const changeKeys = ['fullDocument', 'fullDocumentBeforeChange'];
1091
1091
  const subQ = (a, f) => ({ raw: g => a.raw(g.with(f)) });
1092
1092
  const makeWatchStream = (db, { collection, projection: p, hardMatch: m }, startAt) => {
1093
- const projection = mapExactToObject(p, v => v);
1093
+ const projection = { ...mapExactToObject(p, v => v), deletedAt: 1 };
1094
1094
  const pipeline = [];
1095
1095
  if (m) {
1096
1096
  const q = $or(...changeKeys.map((k) => subQ(m, root().of(k))));
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.6",
6
+ "version": "0.0.8",
7
7
  "dependencies": {
8
8
  "dayjs": "^1.11.9",
9
9
  "dotenv": "^16.3.1",