@omegup/msync 0.0.7 → 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 +2 -1
- package/index.esm.js +37 -45
- package/index.js +37 -45
- package/package.json +1 -1
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,
|
|
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
|
@@ -715,53 +715,45 @@ const $unwindDelta = (k1, k2, k) => {
|
|
|
715
715
|
.with(asStages([
|
|
716
716
|
{
|
|
717
717
|
$replaceWith: {
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
`$${
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
: [
|
|
733
|
-
`$${[k1, k2].sort()[0]}.after._id`,
|
|
734
|
-
'.',
|
|
735
|
-
`$${[k1, k2].sort()[1]}.after._id`,
|
|
736
|
-
],
|
|
737
|
-
},
|
|
738
|
-
},
|
|
739
|
-
in: {
|
|
740
|
-
_id: { $ifNull: ['$$afterId', '$$beforeId'] },
|
|
741
|
-
before: {
|
|
742
|
-
$cond: {
|
|
743
|
-
if: { $or: [{ $eq: [`$${k1}.before`, null] }, { $eq: [`$${k2}.before`, null] }] },
|
|
744
|
-
then: null,
|
|
745
|
-
else: {
|
|
746
|
-
_id: '$$beforeId',
|
|
747
|
-
[k1]: `$${k1}.before`,
|
|
748
|
-
[k2]: `$${k2}.before`,
|
|
749
|
-
},
|
|
718
|
+
_id: "$_id",
|
|
719
|
+
before: {
|
|
720
|
+
$cond: {
|
|
721
|
+
if: { $or: [{ $eq: [`$${k1}.before`, null] }, { $eq: [`$${k2}.before`, null] }] },
|
|
722
|
+
then: null,
|
|
723
|
+
else: {
|
|
724
|
+
_id: {
|
|
725
|
+
$concat: k
|
|
726
|
+
? `$${k}.before._id`
|
|
727
|
+
: [
|
|
728
|
+
`$${[k1, k2].sort()[0]}.before._id`,
|
|
729
|
+
'.',
|
|
730
|
+
`$${[k1, k2].sort()[1]}.before._id`,
|
|
731
|
+
],
|
|
750
732
|
},
|
|
733
|
+
[k1]: `$${k1}.before`,
|
|
734
|
+
[k2]: `$${k2}.before`,
|
|
751
735
|
},
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
736
|
+
},
|
|
737
|
+
},
|
|
738
|
+
after: {
|
|
739
|
+
$cond: {
|
|
740
|
+
if: { $or: [{ $eq: [`$${k1}.after`, null] }, { $eq: [`$${k2}.after`, null] }] },
|
|
741
|
+
then: null,
|
|
742
|
+
else: {
|
|
743
|
+
_id: {
|
|
744
|
+
$concat: k
|
|
745
|
+
? `$${k}.after._id`
|
|
746
|
+
: [
|
|
747
|
+
`$${[k1, k2].sort()[0]}.after._id`,
|
|
748
|
+
'.',
|
|
749
|
+
`$${[k1, k2].sort()[1]}.after._id`,
|
|
750
|
+
],
|
|
761
751
|
},
|
|
752
|
+
[k1]: `$${k1}.after`,
|
|
753
|
+
[k2]: `$${k2}.after`,
|
|
762
754
|
},
|
|
763
|
-
}
|
|
764
|
-
}
|
|
755
|
+
},
|
|
756
|
+
},
|
|
765
757
|
},
|
|
766
758
|
},
|
|
767
759
|
])).stages;
|
|
@@ -1018,11 +1010,11 @@ const $replaceWith = (expr) => ({
|
|
|
1018
1010
|
lin: $replaceWith_(expr),
|
|
1019
1011
|
});
|
|
1020
1012
|
|
|
1021
|
-
const $merge = () => (out, keys) => {
|
|
1013
|
+
const $merge = () => (out, keys, id) => {
|
|
1022
1014
|
const omRORec = omitRORec();
|
|
1023
1015
|
const patch = mapExactToObject(keys, (_, k) => [k, root().of('after').of(k).expr()]);
|
|
1024
1016
|
const replacer = ite(eqTyped(root().of('after').expr(), nil), field(omRORec.backward(spread(mapExact(keys, () => nil), {
|
|
1025
|
-
_id: ['_id',
|
|
1017
|
+
_id: ['_id', id],
|
|
1026
1018
|
touchedAt: ['touchedAt', current],
|
|
1027
1019
|
}))), field(omitPick().backward(spread(patch, {
|
|
1028
1020
|
_id: ['_id', root().of('after').of('_id').expr()],
|
package/index.js
CHANGED
|
@@ -717,53 +717,45 @@ const $unwindDelta = (k1, k2, k) => {
|
|
|
717
717
|
.with(asStages([
|
|
718
718
|
{
|
|
719
719
|
$replaceWith: {
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
`$${
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
: [
|
|
735
|
-
`$${[k1, k2].sort()[0]}.after._id`,
|
|
736
|
-
'.',
|
|
737
|
-
`$${[k1, k2].sort()[1]}.after._id`,
|
|
738
|
-
],
|
|
739
|
-
},
|
|
740
|
-
},
|
|
741
|
-
in: {
|
|
742
|
-
_id: { $ifNull: ['$$afterId', '$$beforeId'] },
|
|
743
|
-
before: {
|
|
744
|
-
$cond: {
|
|
745
|
-
if: { $or: [{ $eq: [`$${k1}.before`, null] }, { $eq: [`$${k2}.before`, null] }] },
|
|
746
|
-
then: null,
|
|
747
|
-
else: {
|
|
748
|
-
_id: '$$beforeId',
|
|
749
|
-
[k1]: `$${k1}.before`,
|
|
750
|
-
[k2]: `$${k2}.before`,
|
|
751
|
-
},
|
|
720
|
+
_id: "$_id",
|
|
721
|
+
before: {
|
|
722
|
+
$cond: {
|
|
723
|
+
if: { $or: [{ $eq: [`$${k1}.before`, null] }, { $eq: [`$${k2}.before`, null] }] },
|
|
724
|
+
then: null,
|
|
725
|
+
else: {
|
|
726
|
+
_id: {
|
|
727
|
+
$concat: k
|
|
728
|
+
? `$${k}.before._id`
|
|
729
|
+
: [
|
|
730
|
+
`$${[k1, k2].sort()[0]}.before._id`,
|
|
731
|
+
'.',
|
|
732
|
+
`$${[k1, k2].sort()[1]}.before._id`,
|
|
733
|
+
],
|
|
752
734
|
},
|
|
735
|
+
[k1]: `$${k1}.before`,
|
|
736
|
+
[k2]: `$${k2}.before`,
|
|
753
737
|
},
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
738
|
+
},
|
|
739
|
+
},
|
|
740
|
+
after: {
|
|
741
|
+
$cond: {
|
|
742
|
+
if: { $or: [{ $eq: [`$${k1}.after`, null] }, { $eq: [`$${k2}.after`, null] }] },
|
|
743
|
+
then: null,
|
|
744
|
+
else: {
|
|
745
|
+
_id: {
|
|
746
|
+
$concat: k
|
|
747
|
+
? `$${k}.after._id`
|
|
748
|
+
: [
|
|
749
|
+
`$${[k1, k2].sort()[0]}.after._id`,
|
|
750
|
+
'.',
|
|
751
|
+
`$${[k1, k2].sort()[1]}.after._id`,
|
|
752
|
+
],
|
|
763
753
|
},
|
|
754
|
+
[k1]: `$${k1}.after`,
|
|
755
|
+
[k2]: `$${k2}.after`,
|
|
764
756
|
},
|
|
765
|
-
}
|
|
766
|
-
}
|
|
757
|
+
},
|
|
758
|
+
},
|
|
767
759
|
},
|
|
768
760
|
},
|
|
769
761
|
])).stages;
|
|
@@ -1020,11 +1012,11 @@ const $replaceWith = (expr) => ({
|
|
|
1020
1012
|
lin: $replaceWith_(expr),
|
|
1021
1013
|
});
|
|
1022
1014
|
|
|
1023
|
-
const $merge = () => (out, keys) => {
|
|
1015
|
+
const $merge = () => (out, keys, id) => {
|
|
1024
1016
|
const omRORec = omitRORec();
|
|
1025
1017
|
const patch = mapExactToObject(keys, (_, k) => [k, root().of('after').of(k).expr()]);
|
|
1026
1018
|
const replacer = ite(eqTyped(root().of('after').expr(), nil), field(omRORec.backward(spread(mapExact(keys, () => nil), {
|
|
1027
|
-
_id: ['_id',
|
|
1019
|
+
_id: ['_id', id],
|
|
1028
1020
|
touchedAt: ['touchedAt', current],
|
|
1029
1021
|
}))), field(omitPick().backward(spread(patch, {
|
|
1030
1022
|
_id: ['_id', root().of('after').of('_id').expr()],
|