@omegup/msync 0.0.17 → 0.0.19

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
@@ -477,11 +477,10 @@ declare const $unwindDelta: <K1 extends s$1, T extends doc, K2 extends s$1, U ex
477
477
  type s = string;
478
478
  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>>;
479
479
 
480
- type OutInputE<T, E, A = T | null> = ID & Rec<'after', A> & E;
481
480
  type Allowed$2<K extends string> = Exclude<K, keyof (TS & ID)>;
482
481
  type Patch<V, KK extends StrKey<V>> = ((OPick<V, Allowed$2<KK>> & ID) | (Rec<Allowed$2<KK>, N> & ID)) & TS;
483
- declare const $simpleMerge: <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>>) => StreamRunnerParam<OutInputE<OPick<V, Allowed$2<KK>> & ID, unknown>, "out">;
484
- 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>>) => StreamRunnerParam<Delta<OPick<V, Allowed$2<KK>> & ID>, "out">;
482
+ declare const $simpleMerge: <V extends O>() => <KK extends StrKey<V>, Out extends doc, E = unknown>(out: RWCollection<Out | Replace<Out, Patch<V, KK>>, Out>, keys: ExactKeys<Allowed$2<KK>>) => StreamRunnerParam<OPick<V, Allowed$2<KK>> & ID & E, "out">;
483
+ declare const $merge: <V extends O>() => <KK extends StrKey<V>, Out extends doc>(out: RWCollection<Out | Replace<Out, Patch<V, KK>>, Out>, keys: ExactKeys<Allowed$2<KK>>) => StreamRunnerParam<Delta<OPick<V, Allowed$2<KK>> & ID>, "out">;
485
484
 
486
485
  type ND = {
487
486
  readonly deletedAt?: null;
package/index.esm.js CHANGED
@@ -1033,17 +1033,14 @@ const $replaceWith = (expr) => ({
1033
1033
  lin: $replaceWith_(expr),
1034
1034
  });
1035
1035
 
1036
- const $mergeId = () => (out, keys, id) => ({
1036
+ const $mergeX = (out, keys, f, map) => ({
1037
1037
  raw: (first) => {
1038
- const omRORec = omitRORec();
1039
- const patch = mapExactToObject(keys, (_, k) => [k, root().of('after').of(k).expr()]);
1040
- const replacer = ite(eqTyped(root().of('after').expr(), nil), field(omRORec.backward(spread(mapExact(keys, () => nil), {
1041
- _id: ['_id', id],
1042
- touchedAt: ['touchedAt', current],
1043
- }))), field(omitPick().backward(spread(patch, {
1044
- _id: ['_id', root().of('after').of('_id').expr()],
1038
+ const patch = mapExactToObject(keys, (_, k) => [k, f.of(k).expr()]);
1039
+ const or = field(omitPick().backward(spread(patch, {
1040
+ _id: ['_id', f.of('_id').expr()],
1045
1041
  touchedAt: ['touchedAt', current],
1046
- }))));
1042
+ })));
1043
+ const replacer = map(or);
1047
1044
  return link()
1048
1045
  .with($replaceWith_(replacer))
1049
1046
  .with($merge_({
@@ -1066,7 +1063,16 @@ const $mergeId = () => (out, keys, id) => ({
1066
1063
  ],
1067
1064
  }),
1068
1065
  });
1069
- const $simpleMerge = () => (out, keys) => $mergeId()(out, keys, root().of('_id').expr());
1066
+ const $mergeId = () => (out, keys, id) => {
1067
+ const omRORec = omitRORec();
1068
+ return $mergeX(out, keys, root().of('after'), or => {
1069
+ return ite(eqTyped(root().of('after').expr(), nil), field(omRORec.backward(spread(mapExact(keys, () => nil), {
1070
+ _id: ['_id', id],
1071
+ touchedAt: ['touchedAt', current],
1072
+ }))), or);
1073
+ });
1074
+ };
1075
+ const $simpleMerge = () => (out, keys) => $mergeX(out, keys, root(), id$1);
1070
1076
  const $merge = () => (out, keys) => $mergeId()(out, keys, assertNotNull$1(root()
1071
1077
  .of('before')
1072
1078
  .of('_id')
package/index.js CHANGED
@@ -1035,17 +1035,14 @@ const $replaceWith = (expr) => ({
1035
1035
  lin: $replaceWith_(expr),
1036
1036
  });
1037
1037
 
1038
- const $mergeId = () => (out, keys, id) => ({
1038
+ const $mergeX = (out, keys, f, map) => ({
1039
1039
  raw: (first) => {
1040
- const omRORec = omitRORec();
1041
- const patch = mapExactToObject(keys, (_, k) => [k, root().of('after').of(k).expr()]);
1042
- const replacer = ite(eqTyped(root().of('after').expr(), nil), field(omRORec.backward(spread(mapExact(keys, () => nil), {
1043
- _id: ['_id', id],
1044
- touchedAt: ['touchedAt', current],
1045
- }))), field(omitPick().backward(spread(patch, {
1046
- _id: ['_id', root().of('after').of('_id').expr()],
1040
+ const patch = mapExactToObject(keys, (_, k) => [k, f.of(k).expr()]);
1041
+ const or = field(omitPick().backward(spread(patch, {
1042
+ _id: ['_id', f.of('_id').expr()],
1047
1043
  touchedAt: ['touchedAt', current],
1048
- }))));
1044
+ })));
1045
+ const replacer = map(or);
1049
1046
  return link()
1050
1047
  .with($replaceWith_(replacer))
1051
1048
  .with($merge_({
@@ -1068,7 +1065,16 @@ const $mergeId = () => (out, keys, id) => ({
1068
1065
  ],
1069
1066
  }),
1070
1067
  });
1071
- const $simpleMerge = () => (out, keys) => $mergeId()(out, keys, root().of('_id').expr());
1068
+ const $mergeId = () => (out, keys, id) => {
1069
+ const omRORec = omitRORec();
1070
+ return $mergeX(out, keys, root().of('after'), or => {
1071
+ return ite(eqTyped(root().of('after').expr(), nil), field(omRORec.backward(spread(mapExact(keys, () => nil), {
1072
+ _id: ['_id', id],
1073
+ touchedAt: ['touchedAt', current],
1074
+ }))), or);
1075
+ });
1076
+ };
1077
+ const $simpleMerge = () => (out, keys) => $mergeX(out, keys, root(), id$1);
1072
1078
  const $merge = () => (out, keys) => $mergeId()(out, keys, assertNotNull$1(root()
1073
1079
  .of('before')
1074
1080
  .of('_id')
@@ -1,10 +1,9 @@
1
1
  import type { OPick, RWCollection } from '../../types';
2
- import type { ID, N, Rec, Replace, StrKey, doc } from '../../types/json';
3
- import type { Delta, Model, StreamRunnerParam, TS } from '../types';
2
+ import type { ID, N, O, Rec, Replace, StrKey, doc } from '../../types/json';
3
+ import type { Delta, StreamRunnerParam, TS } from '../types';
4
4
  import { type ExactKeys } from '../utils/map-object';
5
- type OutInputE<T, E, A = T | null> = ID & Rec<'after', A> & E;
6
5
  type Allowed<K extends string> = Exclude<K, keyof (TS & ID)>;
7
6
  type Patch<V, KK extends StrKey<V>> = ((OPick<V, Allowed<KK>> & ID) | (Rec<Allowed<KK>, N> & ID)) & TS;
8
- export declare const $simpleMerge: <V extends Model & ID>() => <KK extends StrKey<V>, Out extends doc>(out: RWCollection<Out | Replace<Out, Patch<V, KK>>, Out>, keys: ExactKeys<Allowed<KK>>) => StreamRunnerParam<OutInputE<OPick<V, Allowed<KK>> & ID, unknown>, "out">;
9
- export 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<KK>>) => StreamRunnerParam<Delta<OPick<V, Allowed<KK>> & ID>, "out">;
7
+ export declare const $simpleMerge: <V extends O>() => <KK extends StrKey<V>, Out extends doc, E = unknown>(out: RWCollection<Out | Replace<Out, Patch<V, KK>>, Out>, keys: ExactKeys<Allowed<KK>>) => StreamRunnerParam<OPick<V, Allowed<KK>> & ID & E, "out">;
8
+ export declare const $merge: <V extends O>() => <KK extends StrKey<V>, Out extends doc>(out: RWCollection<Out | Replace<Out, Patch<V, KK>>, Out>, keys: ExactKeys<Allowed<KK>>) => StreamRunnerParam<Delta<OPick<V, Allowed<KK>> & ID>, "out">;
10
9
  export {};
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.17",
6
+ "version": "0.0.19",
7
7
  "dependencies": {
8
8
  "dayjs": "^1.11.9",
9
9
  "dotenv": "^16.3.1",