@omegup/msync 0.1.9 → 0.1.11
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 +6 -4
- package/index.esm.js +211 -212
- package/index.js +211 -212
- package/package.json +1 -1
- package/lib/accumulators/index.d.ts +0 -10
- package/lib/aggregate/$merge.d.ts +0 -27
- package/lib/aggregate/$upsert.d.ts +0 -15
- package/lib/aggregate/group/$group-merge.d.ts +0 -12
- package/lib/aggregate/group/index.d.ts +0 -2
- package/lib/aggregate/group/utils/sub-group.d.ts +0 -6
- package/lib/aggregate/group/utils/sub-merge.d.ts +0 -18
- package/lib/aggregate/index.d.ts +0 -9
- package/lib/aggregate/lookup/$lookup-delta.d.ts +0 -10
- package/lib/aggregate/lookup/$lookup-raw.d.ts +0 -9
- package/lib/aggregate/lookup/index.d.ts +0 -12
- package/lib/aggregate/match/$match-delta.d.ts +0 -3
- package/lib/aggregate/match/$match.d.ts +0 -3
- package/lib/aggregate/match/index.d.ts +0 -2
- package/lib/aggregate/mongo-stages.d.ts +0 -13
- package/lib/aggregate/out.d.ts +0 -37
- package/lib/aggregate/prefix.d.ts +0 -33
- package/lib/aggregate/raws.d.ts +0 -17
- package/lib/aggregate/set/$replace-with-each.d.ts +0 -13
- package/lib/aggregate/set/$set-delta.d.ts +0 -5
- package/lib/aggregate/set/$set.d.ts +0 -6
- package/lib/aggregate/set/index.d.ts +0 -1
- package/lib/aggregate/unwind/$unwind-delta.d.ts +0 -5
- package/lib/aggregate/unwind/index.d.ts +0 -6
- package/lib/boot/boot-simpl.d.ts +0 -14
- package/lib/boot/boot-utils.d.ts +0 -26
- package/lib/boot/boot.d.ts +0 -16
- package/lib/boot/first-stages.d.ts +0 -12
- package/lib/boot/index.d.ts +0 -3
- package/lib/boot/single.d.ts +0 -11
- package/lib/expression/arith.d.ts +0 -32
- package/lib/expression/array.d.ts +0 -30
- package/lib/expression/concat.d.ts +0 -34
- package/lib/expression/date.d.ts +0 -17
- package/lib/expression/expr-base.d.ts +0 -5
- package/lib/expression/index.d.ts +0 -7
- package/lib/expression/logic.d.ts +0 -23
- package/lib/expression/range.d.ts +0 -11
- package/lib/expression/val.d.ts +0 -25
- package/lib/field/field.d.ts +0 -25
- package/lib/field/index.d.ts +0 -1
- package/lib/machine.d.ts +0 -9
- package/lib/predicate/$eq.d.ts +0 -24
- package/lib/predicate/$expr.d.ts +0 -3
- package/lib/predicate/$in.d.ts +0 -2
- package/lib/predicate/index.d.ts +0 -3
- package/lib/predicate/utils.d.ts +0 -5
- package/lib/query/index.d.ts +0 -1
- package/lib/query/logic.d.ts +0 -11
- package/lib/stream/aggregate.d.ts +0 -7
- package/lib/types/accumulator.d.ts +0 -30
- package/lib/types/aggregate.d.ts +0 -9
- package/lib/types/expr.d.ts +0 -27
- package/lib/types/extern.d.ts +0 -3
- package/lib/types/index.d.ts +0 -8
- package/lib/types/lookup.d.ts +0 -19
- package/lib/types/machine.d.ts +0 -17
- package/lib/types/predicate.d.ts +0 -11
- package/lib/types/query.d.ts +0 -12
- package/lib/types/stream.d.ts +0 -71
- package/lib/update/index.d.ts +0 -1
- package/lib/update/updater.d.ts +0 -19
- package/lib/utils/before.d.ts +0 -3
- package/lib/utils/coll.d.ts +0 -5
- package/lib/utils/db-indexes.d.ts +0 -4
- package/lib/utils/guard.d.ts +0 -19
- package/lib/utils/index.d.ts +0 -4
- package/lib/utils/json.d.ts +0 -9
- package/lib/utils/log.d.ts +0 -1
- package/lib/utils/map-object.d.ts +0 -41
- package/lib/utils/merge/combiners.d.ts +0 -6
- package/lib/utils/merge/index.d.ts +0 -2
- package/lib/utils/merge/merge.d.ts +0 -7
- package/lib/utils/merge/next-winner.d.ts +0 -3
- package/lib/utils/merge/types.d.ts +0 -19
- package/lib/utils/merge/utils.d.ts +0 -4
- package/lib/utils/tear-down.d.ts +0 -2
- package/lib/watch.d.ts +0 -15
- package/test/mongodb.d.ts +0 -9
- package/test/uri.d.ts +0 -1
- package/types/class.d.ts +0 -1
- package/types/extern.d.ts +0 -3
- package/types/global.d.ts +0 -50
- package/types/hkt.d.ts +0 -56
- package/types/index.d.ts +0 -6
- package/types/json.d.ts +0 -54
- package/types/mongo.d.ts +0 -24
- package/types/view.d.ts +0 -35
package/index.js
CHANGED
|
@@ -546,134 +546,6 @@ const subGroup = (id, args, addGrp) => {
|
|
|
546
546
|
.with(replaceWith(field(addGrp(mapExact(args, (_, k) => $getField(root().expr(), k)))))).stages;
|
|
547
547
|
};
|
|
548
548
|
|
|
549
|
-
const subUpdater = (a, f) => ({ raw: (g) => a.raw(g.with(f)) });
|
|
550
|
-
const set = () => (fields) => ({
|
|
551
|
-
raw: f => {
|
|
552
|
-
return Object.entries(mapExactToObject0(fields, v => v)).flatMap(([k, v]) => v.raw(f).map(([l, v]) => [`.${k}${l}`, v]));
|
|
553
|
-
},
|
|
554
|
-
});
|
|
555
|
-
const weaken = (updater) => ({ raw: f => updater.raw(f) });
|
|
556
|
-
const to = (expr) => ({
|
|
557
|
-
raw: f => [['', expr.raw(f).get()]],
|
|
558
|
-
});
|
|
559
|
-
|
|
560
|
-
const dbcoll = (x) => ({
|
|
561
|
-
db: x.dbName,
|
|
562
|
-
coll: x.collectionName,
|
|
563
|
-
});
|
|
564
|
-
|
|
565
|
-
const $merge_ = ({ into, on, whenNotMatched, ...notMatched }) => asStages([
|
|
566
|
-
{
|
|
567
|
-
$merge: {
|
|
568
|
-
into: dbcoll(into),
|
|
569
|
-
on: on.str(),
|
|
570
|
-
...(whenNotMatched && { whenNotMatched }),
|
|
571
|
-
...(notMatched.stages && {
|
|
572
|
-
whenMatched: notMatched.whenMatched,
|
|
573
|
-
...(notMatched.stages === 'ctx' && { let: rawVars(notMatched.vars, root()) }),
|
|
574
|
-
}),
|
|
575
|
-
},
|
|
576
|
-
},
|
|
577
|
-
]);
|
|
578
|
-
const $merge2 = (args) => $merge_(args);
|
|
579
|
-
|
|
580
|
-
const subMerge = (args, out, gid, extra, idPrefix, first) => {
|
|
581
|
-
const doubleReplace = (x) => x;
|
|
582
|
-
const mergeAggregates = $set_(set()(mapExact0(args, (v, k) => to(first
|
|
583
|
-
? ctx()('new').of(k).expr()
|
|
584
|
-
: v.merge(root().of(k).expr(), ctx()('new').of(k).expr())))));
|
|
585
|
-
const gidPath = root().of(gid).expr();
|
|
586
|
-
const mapId = (k, v) => map1(k, v);
|
|
587
|
-
const F1 = {
|
|
588
|
-
_id: ['_id', to(idPrefix ? concat$1(val(idPrefix), $rand) : $rand)],
|
|
589
|
-
touchedAt: ['touchedAt', to(current)],
|
|
590
|
-
};
|
|
591
|
-
const F2 = mapId(gid, to(gidPath));
|
|
592
|
-
const addExtraAndMerge = {
|
|
593
|
-
...mapExact0(extra, to),
|
|
594
|
-
...F1,
|
|
595
|
-
...F2,
|
|
596
|
-
};
|
|
597
|
-
const addTSAndExtra = {
|
|
598
|
-
...mapExact0(extra, to),
|
|
599
|
-
touchedAt: ['touchedAt', to(current)],
|
|
600
|
-
};
|
|
601
|
-
const updater = set()(addTSAndExtra);
|
|
602
|
-
return (link()
|
|
603
|
-
.with($set_(set()(addExtraAndMerge)))
|
|
604
|
-
.with($merge_({
|
|
605
|
-
...out,
|
|
606
|
-
on: root().of(gid),
|
|
607
|
-
vars: { new: ['new', root().expr()] },
|
|
608
|
-
stages: 'ctx',
|
|
609
|
-
whenMatched: link()
|
|
610
|
-
.with(mergeAggregates)
|
|
611
|
-
.with(doubleReplace($set_(updater))).stages,
|
|
612
|
-
})).stages);
|
|
613
|
-
};
|
|
614
|
-
|
|
615
|
-
const addGrp = (gid) => (expr) => {
|
|
616
|
-
const omit = omitPick();
|
|
617
|
-
return omit.backward(mergeExpr(omit.forward(expr), map1(gid, root().of('_id').expr())));
|
|
618
|
-
};
|
|
619
|
-
const $groupMerge = (id, args, out, gid, extra, idPrefix = '') => ({
|
|
620
|
-
raw: (first) => link()
|
|
621
|
-
.with(subGroup(id, args, addGrp(gid)))
|
|
622
|
-
.with(subMerge(args, out, gid, extra, idPrefix, first)).stages,
|
|
623
|
-
teardown: c => c(out.whenNotMatched === 'insert'
|
|
624
|
-
? {
|
|
625
|
-
collection: out.into,
|
|
626
|
-
method: 'deleteMany',
|
|
627
|
-
params: [{}],
|
|
628
|
-
}
|
|
629
|
-
: {
|
|
630
|
-
collection: out.into,
|
|
631
|
-
method: 'updateMany',
|
|
632
|
-
params: [
|
|
633
|
-
{},
|
|
634
|
-
[
|
|
635
|
-
{
|
|
636
|
-
$unset: Object.keys({
|
|
637
|
-
...mapExactToObject(extra, () => 1),
|
|
638
|
-
...mapExactToObject(args, () => 1),
|
|
639
|
-
}),
|
|
640
|
-
},
|
|
641
|
-
],
|
|
642
|
-
],
|
|
643
|
-
}),
|
|
644
|
-
});
|
|
645
|
-
const $groupId = (id, args, out, extra) => $groupMerge(id, args, { into: out, whenNotMatched: 'fail' }, '_id', extra);
|
|
646
|
-
const $group = (id, args, out, extra, idPrefix = '') => $groupMerge(id, args, { into: out, whenNotMatched: 'insert' }, '_grp', extra, idPrefix);
|
|
647
|
-
|
|
648
|
-
const deltaExpr = (expr) => (field) => {
|
|
649
|
-
return ite(eqTyped($ifNull(root().of(field).expr(), nil), nil), nil, expr(field));
|
|
650
|
-
};
|
|
651
|
-
const $setEach1 = (updater, dict) => {
|
|
652
|
-
return $set1(set()(mapExact1(dict, updater)));
|
|
653
|
-
};
|
|
654
|
-
const $setEach = (updater, dict) => $setEach1(updater, dict)(root);
|
|
655
|
-
const $replaceWithEach1 = (t) => {
|
|
656
|
-
return $setEach(k => to(t(k)), {
|
|
657
|
-
after: ['after', 'after'],
|
|
658
|
-
before: ['before', 'before'],
|
|
659
|
-
});
|
|
660
|
-
};
|
|
661
|
-
const $replaceWithEach = (expr) => $replaceWithEach1(deltaExpr(expr));
|
|
662
|
-
|
|
663
|
-
const $replaceWithDelta = (expr) => $replaceWithEach((field) => sub(expr, root().of(field)));
|
|
664
|
-
const $setDelta = (updater) => {
|
|
665
|
-
const dict = {
|
|
666
|
-
after1: ['after1', 'after'],
|
|
667
|
-
before1: ['before1', 'before'],
|
|
668
|
-
};
|
|
669
|
-
const update = (k) => subUpdater(weaken(updater), root().of(k));
|
|
670
|
-
return link()
|
|
671
|
-
.with($setEach(k => to(root().of(k).expr()), dict))
|
|
672
|
-
.with($setEach(update, dict))
|
|
673
|
-
.with($replaceWithEach(field => root().of(`${field}1`).expr()))
|
|
674
|
-
.with($setEach(k => to(nil), dict)).stages;
|
|
675
|
-
};
|
|
676
|
-
|
|
677
549
|
const dayAndMonthPart = (date) => asExpr({
|
|
678
550
|
raw: f => asExprRaw({ $dateToString: { date: date.raw(f).get(), format: '%m-%d' } }),
|
|
679
551
|
});
|
|
@@ -910,6 +782,217 @@ const $map0 = ({ as, expr, input, }) => asExpr({
|
|
|
910
782
|
const $map1 = (ex, map) => $map0({ input: ex, as: 'item', expr: map(ctx()('item')) });
|
|
911
783
|
const $map = (ex, map) => $map1(ex, i => map(i.expr()));
|
|
912
784
|
|
|
785
|
+
const subUpdater = (a, f) => ({ raw: (g) => a.raw(g.with(f)) });
|
|
786
|
+
const set = () => (fields) => ({
|
|
787
|
+
raw: f => {
|
|
788
|
+
return Object.entries(mapExactToObject0(fields, v => v)).flatMap(([k, v]) => v.raw(f).map(([l, v]) => [`.${k}${l}`, v]));
|
|
789
|
+
},
|
|
790
|
+
});
|
|
791
|
+
const weaken = (updater) => ({ raw: f => updater.raw(f) });
|
|
792
|
+
const to = (expr) => ({
|
|
793
|
+
raw: f => [['', expr.raw(f).get()]],
|
|
794
|
+
});
|
|
795
|
+
|
|
796
|
+
const dbcoll = (x) => ({
|
|
797
|
+
db: x.dbName,
|
|
798
|
+
coll: x.collectionName,
|
|
799
|
+
});
|
|
800
|
+
|
|
801
|
+
const $merge_ = ({ into, on, whenNotMatched, ...notMatched }) => asStages([
|
|
802
|
+
{
|
|
803
|
+
$merge: {
|
|
804
|
+
into: dbcoll(into),
|
|
805
|
+
on: on.str(),
|
|
806
|
+
...(whenNotMatched && { whenNotMatched }),
|
|
807
|
+
...(notMatched.stages && {
|
|
808
|
+
whenMatched: notMatched.whenMatched,
|
|
809
|
+
...(notMatched.stages === 'ctx' && { let: rawVars(notMatched.vars, root()) }),
|
|
810
|
+
}),
|
|
811
|
+
},
|
|
812
|
+
},
|
|
813
|
+
]);
|
|
814
|
+
const $merge2 = (args) => $merge_(args);
|
|
815
|
+
|
|
816
|
+
const getWhenMatched = (whenNotMatched) => {
|
|
817
|
+
const setDeleted = whenNotMatched === 'discard';
|
|
818
|
+
const orNull = (e) => (setDeleted ? $ifNull(e, nil) : e);
|
|
819
|
+
const preMergeOld = setDeleted
|
|
820
|
+
? mergeObjects(root().of('old').expr(), field({
|
|
821
|
+
deletedAt: ['deletedAt', orNull(root().of('old').of('deletedAt').expr())],
|
|
822
|
+
touchedAt: ['touchedAt', root().of('merged').of('touchedAt').expr()],
|
|
823
|
+
}))
|
|
824
|
+
: root().of('old').expr();
|
|
825
|
+
const same = eq(preMergeOld)(root().of('merged').expr());
|
|
826
|
+
const newOrOld = whenNotMatched ===
|
|
827
|
+
'insert'
|
|
828
|
+
? ctx()('new')
|
|
829
|
+
: root();
|
|
830
|
+
const merged = mergeObjects(root().expr(), ctx()('new').expr(), field({
|
|
831
|
+
deletedAt: ['deletedAt', orNull(newOrOld.of('deletedAt').expr())],
|
|
832
|
+
}));
|
|
833
|
+
return link()
|
|
834
|
+
.with($replaceWith_(field({
|
|
835
|
+
old: ['old', root().expr()],
|
|
836
|
+
merged: ['merged', merged],
|
|
837
|
+
})))
|
|
838
|
+
.with($replaceWith_(ite(same, root().of('old').expr(), root().of('merged').expr()))).stages;
|
|
839
|
+
};
|
|
840
|
+
const $mergeX = (out, keys, f, map, ext) => {
|
|
841
|
+
const patch = mapExact(keys, v => sub(v, f));
|
|
842
|
+
const filter = mapExactToObject(ext, v => ({ $eq: v }));
|
|
843
|
+
const setDeleted = out.whenNotMatched === 'discard';
|
|
844
|
+
const replacer = map(field(omitPick().backward(spread(patch, {
|
|
845
|
+
_id: ['_id', f.of('_id').expr()],
|
|
846
|
+
touchedAt: ['touchedAt', current],
|
|
847
|
+
}))));
|
|
848
|
+
const sss = setDeleted
|
|
849
|
+
? link()
|
|
850
|
+
.with($set_(set()({
|
|
851
|
+
deletedAt: ['deletedAt', to(current)],
|
|
852
|
+
})))
|
|
853
|
+
.with($merge_({
|
|
854
|
+
into: out.coll,
|
|
855
|
+
on: root().of('_id'),
|
|
856
|
+
whenNotMatched: 'insert',
|
|
857
|
+
stages: true,
|
|
858
|
+
whenMatched: getWhenMatched(out.whenNotMatched),
|
|
859
|
+
})).stages
|
|
860
|
+
: link().with($merge_({
|
|
861
|
+
into: out.coll,
|
|
862
|
+
on: root().of('_id'),
|
|
863
|
+
whenNotMatched: 'fail',
|
|
864
|
+
stages: true,
|
|
865
|
+
whenMatched: getWhenMatched(out.whenNotMatched),
|
|
866
|
+
})).stages;
|
|
867
|
+
const teardown = (coll) => ({
|
|
868
|
+
collection: coll,
|
|
869
|
+
method: 'updateMany',
|
|
870
|
+
params: [
|
|
871
|
+
filter,
|
|
872
|
+
[
|
|
873
|
+
{
|
|
874
|
+
$unset: Object.keys(mapExactToObject(keys, () => 1)),
|
|
875
|
+
},
|
|
876
|
+
],
|
|
877
|
+
],
|
|
878
|
+
});
|
|
879
|
+
return {
|
|
880
|
+
raw: (first) => link().with($replaceWith_(replacer)).with(sss)
|
|
881
|
+
.stages,
|
|
882
|
+
teardown: c => (setDeleted ? c(teardown(out.coll)) : c(teardown(out.coll))),
|
|
883
|
+
};
|
|
884
|
+
};
|
|
885
|
+
const $mergeId = () => (out, keys, id, ext) => {
|
|
886
|
+
const omRORec = omitRORec();
|
|
887
|
+
return $mergeX(out, keys, root().of('after'), or => {
|
|
888
|
+
return ite(eqTyped(root().of('after').expr(), nil), field(omRORec.backward(spread(mapExact(keys, () => nil), {
|
|
889
|
+
_id: ['_id', id],
|
|
890
|
+
touchedAt: ['touchedAt', current],
|
|
891
|
+
}))), or);
|
|
892
|
+
}, ext);
|
|
893
|
+
};
|
|
894
|
+
const $simpleMergePart = () => (out, keys, ext) => $mergeX(out, keys, root(), id$1, ext);
|
|
895
|
+
const $simpleMerge = () => (out, keys, whenNotMatched = 'fail') => $mergeX({ coll: out, whenNotMatched }, keys, root(), id$1, {});
|
|
896
|
+
const $mergePart = () => (out, keys, ext) => $mergeId()({ coll: out, whenNotMatched: 'fail' }, keys, assertNotNull$1(root().of('before').of('_id').expr()), ext);
|
|
897
|
+
const $merge = () => (out, keys) => $mergePart()(out, keys, {});
|
|
898
|
+
const assertNotNull$1 = (expr) => expr;
|
|
899
|
+
|
|
900
|
+
const subMerge = (args, out, gid, extra, idPrefix, first) => {
|
|
901
|
+
const e = extra;
|
|
902
|
+
const mergeAggregates = $set_(set()(mapExact0(args, (v, k) => to(first
|
|
903
|
+
? ctx()('new').of(k).expr()
|
|
904
|
+
: v.merge(root().of(k).expr(), ctx()('new').of(k).expr())))));
|
|
905
|
+
const gidPath = root().of(gid).expr();
|
|
906
|
+
const mapId = (k, v) => map1(k, v);
|
|
907
|
+
const F1 = {
|
|
908
|
+
_id: ['_id', to(idPrefix ? concat$1(val(idPrefix), $rand) : $rand)],
|
|
909
|
+
touchedAt: ['touchedAt', to(current)],
|
|
910
|
+
};
|
|
911
|
+
const F2 = mapId(gid, to(gidPath));
|
|
912
|
+
const addExtraAndMerge = {
|
|
913
|
+
...mapExact0(extra, to),
|
|
914
|
+
...F1,
|
|
915
|
+
...F2,
|
|
916
|
+
};
|
|
917
|
+
const addExtra = mapExact0(e, to);
|
|
918
|
+
const updater = set()(addExtra);
|
|
919
|
+
return link()
|
|
920
|
+
.with($set_(set()(addExtraAndMerge)))
|
|
921
|
+
.with($merge_({
|
|
922
|
+
...out,
|
|
923
|
+
whenNotMatched: 'fail',
|
|
924
|
+
on: root().of(gid),
|
|
925
|
+
vars: { new: ['new', root().expr()] },
|
|
926
|
+
stages: 'ctx',
|
|
927
|
+
whenMatched: link()
|
|
928
|
+
.with(mergeAggregates)
|
|
929
|
+
.with($set_(updater))
|
|
930
|
+
.with(getWhenMatched(out.whenNotMatched)).stages,
|
|
931
|
+
})).stages;
|
|
932
|
+
};
|
|
933
|
+
|
|
934
|
+
const addGrp = (gid) => (expr) => {
|
|
935
|
+
const omit = omitPick();
|
|
936
|
+
return omit.backward(mergeExpr(omit.forward(expr), map1(gid, root().of('_id').expr())));
|
|
937
|
+
};
|
|
938
|
+
const $groupMerge = (id, args, out, gid, extra, idPrefix = '') => ({
|
|
939
|
+
raw: (first) => link()
|
|
940
|
+
.with(subGroup(id, args, addGrp(gid)))
|
|
941
|
+
.with(subMerge(args, out, gid, extra, idPrefix, first)).stages,
|
|
942
|
+
teardown: c => c(out.whenNotMatched === 'insert'
|
|
943
|
+
? {
|
|
944
|
+
collection: out.into,
|
|
945
|
+
method: 'deleteMany',
|
|
946
|
+
params: [{}],
|
|
947
|
+
}
|
|
948
|
+
: {
|
|
949
|
+
collection: out.into,
|
|
950
|
+
method: 'updateMany',
|
|
951
|
+
params: [
|
|
952
|
+
{},
|
|
953
|
+
[
|
|
954
|
+
{
|
|
955
|
+
$unset: Object.keys({
|
|
956
|
+
...mapExactToObject(extra, () => 1),
|
|
957
|
+
...mapExactToObject(args, () => 1),
|
|
958
|
+
}),
|
|
959
|
+
},
|
|
960
|
+
],
|
|
961
|
+
],
|
|
962
|
+
}),
|
|
963
|
+
});
|
|
964
|
+
const $groupId = (id, args, out, extra) => $groupMerge(id, args, { into: out, whenNotMatched: 'fail' }, '_id', extra);
|
|
965
|
+
const $group = (id, args, out, extra, idPrefix = '') => $groupMerge(id, args, { into: out, whenNotMatched: 'insert' }, '_grp', extra, idPrefix);
|
|
966
|
+
|
|
967
|
+
const deltaExpr = (expr) => (field) => {
|
|
968
|
+
return ite(eqTyped($ifNull(root().of(field).expr(), nil), nil), nil, expr(field));
|
|
969
|
+
};
|
|
970
|
+
const $setEach1 = (updater, dict) => {
|
|
971
|
+
return $set1(set()(mapExact1(dict, updater)));
|
|
972
|
+
};
|
|
973
|
+
const $setEach = (updater, dict) => $setEach1(updater, dict)(root);
|
|
974
|
+
const $replaceWithEach1 = (t) => {
|
|
975
|
+
return $setEach(k => to(t(k)), {
|
|
976
|
+
after: ['after', 'after'],
|
|
977
|
+
before: ['before', 'before'],
|
|
978
|
+
});
|
|
979
|
+
};
|
|
980
|
+
const $replaceWithEach = (expr) => $replaceWithEach1(deltaExpr(expr));
|
|
981
|
+
|
|
982
|
+
const $replaceWithDelta = (expr) => $replaceWithEach((field) => sub(expr, root().of(field)));
|
|
983
|
+
const $setDelta = (updater) => {
|
|
984
|
+
const dict = {
|
|
985
|
+
after1: ['after1', 'after'],
|
|
986
|
+
before1: ['before1', 'before'],
|
|
987
|
+
};
|
|
988
|
+
const update = (k) => subUpdater(weaken(updater), root().of(k));
|
|
989
|
+
return link()
|
|
990
|
+
.with($setEach(k => to(root().of(k).expr()), dict))
|
|
991
|
+
.with($setEach(update, dict))
|
|
992
|
+
.with($replaceWithEach(field => root().of(`${field}1`).expr()))
|
|
993
|
+
.with($setEach(k => to(nil), dict)).stages;
|
|
994
|
+
};
|
|
995
|
+
|
|
913
996
|
const operator = () => (op) => (operand) => {
|
|
914
997
|
return {
|
|
915
998
|
raw: { [op]: operand },
|
|
@@ -1367,90 +1450,6 @@ const $replaceWith = (expr) => ({
|
|
|
1367
1450
|
lin: $replaceWith_(expr),
|
|
1368
1451
|
});
|
|
1369
1452
|
|
|
1370
|
-
const getWhenMatched = (whenNotMatched) => {
|
|
1371
|
-
const setDeleted = whenNotMatched === 'discard';
|
|
1372
|
-
const orNull = (e) => (setDeleted ? $ifNull(e, nil) : e);
|
|
1373
|
-
const preMergeOld = setDeleted
|
|
1374
|
-
? mergeObjects(root().of('old').expr(), field({
|
|
1375
|
-
deletedAt: ['deletedAt', orNull(root().of('old').of('deletedAt').expr())],
|
|
1376
|
-
touchedAt: ['touchedAt', root().of('merged').of('touchedAt').expr()],
|
|
1377
|
-
}))
|
|
1378
|
-
: root().of('old').expr();
|
|
1379
|
-
const same = eq(preMergeOld)(root().of('merged').expr());
|
|
1380
|
-
const newOrOld = whenNotMatched ===
|
|
1381
|
-
'insert'
|
|
1382
|
-
? ctx()('new')
|
|
1383
|
-
: root();
|
|
1384
|
-
const merged = mergeObjects(root().expr(), ctx()('new').expr(), field({
|
|
1385
|
-
deletedAt: ['deletedAt', orNull(newOrOld.of('deletedAt').expr())],
|
|
1386
|
-
}));
|
|
1387
|
-
return link()
|
|
1388
|
-
.with($replaceWith_(field({
|
|
1389
|
-
old: ['old', root().expr()],
|
|
1390
|
-
merged: ['merged', merged],
|
|
1391
|
-
})))
|
|
1392
|
-
.with($replaceWith_(ite(same, root().of('old').expr(), root().of('merged').expr()))).stages;
|
|
1393
|
-
};
|
|
1394
|
-
const $mergeX = (out, keys, f, map, ext) => {
|
|
1395
|
-
const patch = mapExact(keys, v => sub(v, f));
|
|
1396
|
-
const filter = mapExactToObject(ext, v => ({ $eq: v }));
|
|
1397
|
-
const setDeleted = out.whenNotMatched === 'discard';
|
|
1398
|
-
const replacer = map(field(omitPick().backward(spread(patch, {
|
|
1399
|
-
_id: ['_id', f.of('_id').expr()],
|
|
1400
|
-
touchedAt: ['touchedAt', current],
|
|
1401
|
-
}))));
|
|
1402
|
-
const sss = setDeleted
|
|
1403
|
-
? link()
|
|
1404
|
-
.with($set_(set()({
|
|
1405
|
-
deletedAt: ['deletedAt', to(current)],
|
|
1406
|
-
})))
|
|
1407
|
-
.with($merge_({
|
|
1408
|
-
into: out.coll,
|
|
1409
|
-
on: root().of('_id'),
|
|
1410
|
-
whenNotMatched: 'insert',
|
|
1411
|
-
stages: true,
|
|
1412
|
-
whenMatched: getWhenMatched(out.whenNotMatched),
|
|
1413
|
-
})).stages
|
|
1414
|
-
: link().with($merge_({
|
|
1415
|
-
into: out.coll,
|
|
1416
|
-
on: root().of('_id'),
|
|
1417
|
-
whenNotMatched: 'fail',
|
|
1418
|
-
stages: true,
|
|
1419
|
-
whenMatched: getWhenMatched(out.whenNotMatched),
|
|
1420
|
-
})).stages;
|
|
1421
|
-
const teardown = (coll) => ({
|
|
1422
|
-
collection: coll,
|
|
1423
|
-
method: 'updateMany',
|
|
1424
|
-
params: [
|
|
1425
|
-
filter,
|
|
1426
|
-
[
|
|
1427
|
-
{
|
|
1428
|
-
$unset: Object.keys(mapExactToObject(keys, () => 1)),
|
|
1429
|
-
},
|
|
1430
|
-
],
|
|
1431
|
-
],
|
|
1432
|
-
});
|
|
1433
|
-
return {
|
|
1434
|
-
raw: (first) => link().with($replaceWith_(replacer)).with(sss)
|
|
1435
|
-
.stages,
|
|
1436
|
-
teardown: c => (setDeleted ? c(teardown(out.coll)) : c(teardown(out.coll))),
|
|
1437
|
-
};
|
|
1438
|
-
};
|
|
1439
|
-
const $mergeId = () => (out, keys, id, ext) => {
|
|
1440
|
-
const omRORec = omitRORec();
|
|
1441
|
-
return $mergeX(out, keys, root().of('after'), or => {
|
|
1442
|
-
return ite(eqTyped(root().of('after').expr(), nil), field(omRORec.backward(spread(mapExact(keys, () => nil), {
|
|
1443
|
-
_id: ['_id', id],
|
|
1444
|
-
touchedAt: ['touchedAt', current],
|
|
1445
|
-
}))), or);
|
|
1446
|
-
}, ext);
|
|
1447
|
-
};
|
|
1448
|
-
const $simpleMergePart = () => (out, keys, ext) => $mergeX(out, keys, root(), id$1, ext);
|
|
1449
|
-
const $simpleMerge = () => (out, keys, whenNotMatched = 'fail') => $mergeX({ coll: out, whenNotMatched }, keys, root(), id$1, {});
|
|
1450
|
-
const $mergePart = () => (out, keys, ext) => $mergeId()({ coll: out, whenNotMatched: 'fail' }, keys, assertNotNull$1(root().of('before').of('_id').expr()), ext);
|
|
1451
|
-
const $merge = () => (out, keys) => $mergePart()(out, keys, {});
|
|
1452
|
-
const assertNotNull$1 = (expr) => expr;
|
|
1453
|
-
|
|
1454
1453
|
const $insertX = (out, expr, map, ext, extExpr) => {
|
|
1455
1454
|
const filter = mapExactToObject(ext, v => ({ $eq: v }));
|
|
1456
1455
|
return {
|
package/package.json
CHANGED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { AppMap, Arr, N, O, Rec } from '../../types';
|
|
2
|
-
import type { ExprHKT } from '../expression/concat';
|
|
3
|
-
import { type NoRaw } from '../expression/val';
|
|
4
|
-
import type { DeltaAccumulator, Expr, Part } from '../types';
|
|
5
|
-
export declare const $sum: <D extends O, C = unknown>(expr: Expr<number | N, D, C>) => DeltaAccumulator<D, number, C>;
|
|
6
|
-
export declare const $accumulator: <D, T, Ctx, A extends readonly unknown[]>(init: () => NoRaw<T>, accumulateArgs: AppMap<ExprHKT<Part<D>, Ctx>, A>, accumulate: (a: NoRaw<T>, ...args: NoRaw<A>) => NoRaw<T>, merge: (...args: NoRaw<[T | N, T]>) => NoRaw<T>) => DeltaAccumulator<D, T, Ctx>;
|
|
7
|
-
export declare const $countDict: <D extends O, C = unknown>(expr: Expr<string, D, C>) => DeltaAccumulator<D, Rec<string, number>, C>;
|
|
8
|
-
export declare const $pushDict: <D extends O, V, C = unknown>(key: Expr<string, D, C>, value: Expr<V, D, C>) => DeltaAccumulator<D, Rec<string, Rec<"0" | "1", Arr<V>>>, C>;
|
|
9
|
-
export declare const $keys: <D extends O, C = unknown>(expr: Expr<Rec<string, number>, D, C>) => Expr<Arr<string>, D, C>;
|
|
10
|
-
export declare const $entries: <D extends O, V, C = unknown>(expr: Expr<Rec<string, Rec<"1" | "0", Arr<V>>>, D, C>) => Expr<Arr<Rec<"k", string> & Rec<"v", V>>, D, C>;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { IdHKT, OPick, RWCollection, Timestamp } from '../../types';
|
|
2
|
-
import type { doc, ID, N, O, rawItem, Rec, Replace, RORec, StrKey } from '../../types/json';
|
|
3
|
-
import { type ExprsExact } from '../expression/concat';
|
|
4
|
-
import type { Delta, Expr, IsDeleted, Model, RawStages, StreamRunnerParam, TS } from '../types';
|
|
5
|
-
import { type Exact } from '../utils/map-object';
|
|
6
|
-
type OutInputE<T, E, A = T | null> = ID & Rec<'after', A> & E;
|
|
7
|
-
type Allowed<K extends string> = Exclude<K, keyof (TS & ID)>;
|
|
8
|
-
export type Patch<V, KK extends StrKey<V> = StrKey<V>> = ((OPick<V, Allowed<KK>> & ID) | (Rec<Allowed<KK>, N> & ID)) & TS;
|
|
9
|
-
type TakeDoc<V, E = ID, KK extends StrKey<V> = StrKey<V>> = OPick<V, Allowed<KK>> & E;
|
|
10
|
-
type ND = {
|
|
11
|
-
readonly deletedAt?: null;
|
|
12
|
-
};
|
|
13
|
-
type SafeE<E> = Omit<E, `$${string}` | keyof ID>;
|
|
14
|
-
export declare const getWhenMatched: <Out extends Model, P extends Model, K extends keyof IsDeleted>(whenNotMatched: "discard" | "fail" | "insert") => RawStages<O, Out, Out | Replace<Out, P>, RORec<"new", Replace<P, RORec<K, Timestamp>>>>;
|
|
15
|
-
type MergeCollection<V extends O, Out extends Model> = {
|
|
16
|
-
coll: RWCollection<Out | Replace<Out, Patch<V>> | Replace<Patch<V>, IsDeleted>, Out>;
|
|
17
|
-
whenNotMatched: 'discard';
|
|
18
|
-
} | {
|
|
19
|
-
coll: RWCollection<Out | Replace<Out, Patch<V>>, Out>;
|
|
20
|
-
whenNotMatched: 'fail';
|
|
21
|
-
};
|
|
22
|
-
export declare const $mergeId: <V extends O>() => <SourcePart extends doc, Out extends Model, E = unknown, EEE extends RORec<string, rawItem> = {}>(out: MergeCollection<V, Out>, keys: ExprsExact<TakeDoc<V, unknown>, SourcePart>, id: Expr<string, OutInputE<TakeDoc<V>, E, null>>, ext: Exact<Omit<SafeE<EEE>, keyof (ND & TS)>, IdHKT>) => StreamRunnerParam<OutInputE<SourcePart, E>, "out">;
|
|
23
|
-
export declare const $simpleMergePart: <V extends O>() => <Source extends doc, Out extends Model, EEE extends RORec<string, rawItem>>(out: MergeCollection<V, Out>, keys: ExprsExact<TakeDoc<V, unknown>, Source>, ext: Exact<Omit<SafeE<EEE>, keyof (ND & TS)>, IdHKT>) => StreamRunnerParam<Source, "out">;
|
|
24
|
-
export declare const $simpleMerge: <V extends O>() => <Source extends doc, Out extends Model>(out: RWCollection<Out | Replace<Out, Patch<V>> | Replace<Patch<V>, IsDeleted>, Out>, keys: ExprsExact<TakeDoc<V, unknown>, Source>, whenNotMatched?: "fail" | "discard") => StreamRunnerParam<Source, "out">;
|
|
25
|
-
export declare const $mergePart: <V extends O>() => <Out extends Model, 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<EEE>, keyof (ND & TS)>, IdHKT>) => StreamRunnerParam<Delta<SourcePart>, "out">;
|
|
26
|
-
export declare const $merge: <V extends O>() => <Out extends Model, SourcePart extends doc>(out: RWCollection<Out | Replace<Out, Patch<V>>, Out>, keys: ExprsExact<TakeDoc<V, unknown>, SourcePart>) => StreamRunnerParam<Delta<SourcePart>, "out">;
|
|
27
|
-
export {};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { IdHKT, RWCollection } from '../../types';
|
|
2
|
-
import type { ID, O, RORec, doc, rawItem } from '../../types/json';
|
|
3
|
-
import { type ExprsExact } from '../expression/concat';
|
|
4
|
-
import type { Del, Delta, Expr, StreamRunnerParam, TS } from '../types';
|
|
5
|
-
import { type Exact } from '../utils/map-object';
|
|
6
|
-
type ND = {
|
|
7
|
-
readonly deletedAt?: null;
|
|
8
|
-
};
|
|
9
|
-
type SafeE<E> = Omit<E, `$${string}` | keyof ID>;
|
|
10
|
-
export type Merge<T extends doc, E> = Omit<SafeE<E>, keyof (ND & TS)> & ((T & ND & TS) | Del);
|
|
11
|
-
export declare const $insertX: <T extends doc, D extends O, EEE extends RORec<string, rawItem>>(out: RWCollection<Merge<T, EEE>>, expr: Expr<T, D>, map: (x: Expr<T & ND & TS & Omit<SafeE<EEE>, keyof (ND & TS)>, D>) => Expr<Merge<T, EEE>, D>, ext: Exact<Omit<SafeE<EEE>, keyof (ND & TS)>, IdHKT>, extExpr: ExprsExact<Omit<SafeE<EEE>, keyof (ND & TS)>, unknown>) => StreamRunnerParam<D, "out">;
|
|
12
|
-
export declare const $simpleInsert: <T extends doc>(out: RWCollection<Merge<T, {}>>) => StreamRunnerParam<T, "out">;
|
|
13
|
-
export declare const $insertPart: <T extends doc, EEE extends RORec<string, rawItem>>(out: RWCollection<Merge<T, EEE>>, ext: Exact<Omit<SafeE<EEE>, keyof (ND & TS)>, IdHKT>) => StreamRunnerParam<Delta<T>, "out">;
|
|
14
|
-
export declare const $insert: <T extends doc>(out: RWCollection<Merge<T, {}>>) => StreamRunnerParam<Delta<T>, "out">;
|
|
15
|
-
export {};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { RWCollection, WriteonlyCollection } from '../../../types';
|
|
2
|
-
import type { AsLiteral, ID, O, Rec, Replace, doc, notArr } from '../../../types/json';
|
|
3
|
-
import { type ExprsExact } from '../../expression/concat';
|
|
4
|
-
import type { Delta, DeltaAccumulators, Expr, StreamRunnerParam, TS } from '../../types';
|
|
5
|
-
import type { MergeInto } from '../out';
|
|
6
|
-
import { type Extra, type IdAndTsKeys, type Loose, type Strict, type V_Grp } from './utils/sub-merge';
|
|
7
|
-
type Denied<GID = never> = keyof (TS & ID) | GID;
|
|
8
|
-
type GI<GG> = Exclude<GG, keyof TS>;
|
|
9
|
-
export declare const $groupMerge: <T extends O, Grp extends notArr, V extends O, GG extends string, EE = {}, Out extends Loose<Grp, V, GG> = Loose<Grp, V, GG>>(id: Expr<Grp, T>, args: DeltaAccumulators<T, O & Omit<V, Denied<GI<GG>>>>, out: MergeInto<Strict<Grp, V, GG, EE>, Out, WriteonlyCollection<Replace<Out, Strict<Grp, V, GG, EE>>>>, gid: AsLiteral<GI<GG>>, extra: ExprsExact<Extra<EE, V, GG>, V_Grp<V, GG, Grp>>, idPrefix?: string) => StreamRunnerParam<Delta<T>, "out">;
|
|
10
|
-
export declare const $groupId: <T extends O, V extends O, EE = {}, Out extends Loose<string, V, "_id"> = Loose<string, V, "_id">>(id: Expr<string, T>, args: DeltaAccumulators<T, O & Omit<V, Denied>>, out: RWCollection<Replace<Out, Strict<string, V, "_id", EE>>, Out>, extra: ExprsExact<Omit<EE, IdAndTsKeys | keyof Omit<V, IdAndTsKeys>>, doc & Omit<V, IdAndTsKeys>>) => StreamRunnerParam<Delta<T>, "out">;
|
|
11
|
-
export declare const $group: <T extends O, Grp extends notArr, V extends O, EE = {}, Out extends Loose<Grp, V, "_grp"> = Loose<Grp, V, "_grp">>(id: Expr<Grp, T>, args: DeltaAccumulators<T, O & Omit<V, Denied<"_grp">>>, out: RWCollection<Strict<Grp, V, "_grp", EE>, Out>, extra: ExprsExact<Omit<EE, IdAndTsKeys | "_grp" | Exclude<keyof V, IdAndTsKeys | "_grp">>, Rec<"_grp", Grp> & Omit<V, IdAndTsKeys | "_grp">>, idPrefix?: string) => StreamRunnerParam<Delta<T>, "out">;
|
|
12
|
-
export {};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { O, RORec, Rec } from '../../../../types';
|
|
2
|
-
import { type ExprsExact } from '../../../expression/concat';
|
|
3
|
-
import type { Delta, Expr, RawStages } from '../../../types';
|
|
4
|
-
import type { DeltaAccumulators } from '../../../types/accumulator';
|
|
5
|
-
export type WithItem<V, Grp> = Rec<'_id', Grp> & Rec<'item', O<V>>;
|
|
6
|
-
export declare const subGroup: <T extends O, Grp, V extends O, GID extends string>(id: Expr<Grp, T>, args: DeltaAccumulators<T, V>, addGrp: <D extends Rec<"_id", Grp>>(src: ExprsExact<V, D>) => ExprsExact<RORec<GID, Grp> & V, D>) => RawStages<unknown, Delta<T>, Rec<GID, Grp> & V>;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { AsLiteral, ID, O, Rec, Replace, WriteonlyCollection, notArr } from '../../../../types';
|
|
2
|
-
import { type ExprsExact } from '../../../expression/concat';
|
|
3
|
-
import type { RawStages, TS } from '../../../types';
|
|
4
|
-
import type { DeltaAccumulators } from '../../../types/accumulator';
|
|
5
|
-
import { type MergeInto } from '../../out';
|
|
6
|
-
type GI<GG> = Exclude<GG, keyof TS>;
|
|
7
|
-
export type IdAndTsKeys = keyof (TS & ID);
|
|
8
|
-
type V<VV, GG extends string> = Omit<VV, IdAndTsKeys | GI<GG>>;
|
|
9
|
-
export type Prepare<Grp, GG extends string> = TS & ID & Rec<GI<GG>, Grp>;
|
|
10
|
-
type Par<T> = {
|
|
11
|
-
[P in keyof T]?: T[P] | null;
|
|
12
|
-
};
|
|
13
|
-
export type Loose<Grp, VV, GG extends string> = Prepare<Grp, GG> & Par<V<VV, GG>>;
|
|
14
|
-
export type Strict<Grp, VV, GG extends string, EE> = Prepare<Grp, GG> & V<VV, GG> & Omit<EE, IdAndTsKeys | GI<GG> | keyof V<VV, GG>>;
|
|
15
|
-
export type V_Grp<VV, GG extends string, Grp> = Rec<GI<GG>, Grp> & V<VV, GG>;
|
|
16
|
-
export type Extra<EE, VV, GG extends string> = Omit<EE, IdAndTsKeys | GI<GG> | keyof V<VV, GG>>;
|
|
17
|
-
export declare const subMerge: <T extends O, Grp extends notArr, VV extends O, GG extends string, EE = {}, Out extends Loose<Grp, VV, GG> = Loose<Grp, VV, GG>>(args: DeltaAccumulators<T, V<VV, GG>>, out: MergeInto<Strict<Grp, VV, GG, EE>, Out, WriteonlyCollection<Replace<Out, Strict<Grp, VV, GG, EE>>>>, gid: AsLiteral<GI<GG>>, extra: ExprsExact<Extra<EE, VV, GG>, V_Grp<VV, GG, Grp>>, idPrefix: string, first: boolean) => RawStages<unknown, V_Grp<VV, GG, Grp>, "out">;
|
|
18
|
-
export {};
|
package/lib/aggregate/index.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { AsLiteral, ID, N, O, Rec, doc, rawItem } from '../../../types';
|
|
2
|
-
import { Field } from '../../field';
|
|
3
|
-
import type { BA, Before, Delta, RawStages, TStages, UBefore } from '../../types';
|
|
4
|
-
type s = string;
|
|
5
|
-
type Both<K1 extends s, LE, KK2 extends s, RE, N1 extends null = never, N2 extends null = never> = Delta<Rec<K1, LE | N1> & Rec<Exclude<KK2, BA | K1>, RE | N2> & ID>;
|
|
6
|
-
export declare const $lookupDelta: <LQ extends O, LE extends LQ & doc, RQ extends O, RE extends RQ & doc, BRB extends UBefore<RQ>, RS extends UBefore<RQ>, S extends rawItem, K1 extends s, KK2 extends s, N1 extends null = never, N2 extends null = never>({ field1, field2 }: {
|
|
7
|
-
field1: Field<LQ, S | N>;
|
|
8
|
-
field2: Field<RQ, S | N>;
|
|
9
|
-
}, { coll, exec, input }: TStages<RS, UBefore<RQ>, BRB, Before<RE>>, k1: AsLiteral<K1>, k2: AsLiteral<Exclude<KK2, BA | K1>>, k: ([N1] extends [never] ? K1 : never) | ([N2] extends [never] ? Exclude<KK2, BA | K1> : never) | false, includeNull1?: N1, includeNull2?: N2) => RawStages<unknown, Delta<LE>, Both<K1, LE, KK2, RE, N1, N2>>;
|
|
10
|
-
export {};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { App, AsLiteral, HKT, ID, O, Rec } from '../../../types';
|
|
2
|
-
import { type Field } from '../../field';
|
|
3
|
-
import type { Before, RawStages, TStages } from '../../types';
|
|
4
|
-
type s = string;
|
|
5
|
-
export declare const $lookupRaw: <LQ extends O, LE extends LQ & ID, RQ extends O, RE extends RQ & ID, BRB extends Before<RQ>, RS, S, As extends s, Null extends null = never>({ field1, field2 }: {
|
|
6
|
-
field1: Field<LQ, S>;
|
|
7
|
-
field2: Field<RQ, S>;
|
|
8
|
-
}, { coll, exec, input }: TStages<RS, Before<RQ>, BRB, Before<RE>>, k2: AsLiteral<As>, k: "left", includeNull?: Null) => <F extends HKT<O, O>>(f: <T extends O>() => Field<App<F, T>, T>) => RawStages<App<F, LQ>, App<F, LE>, App<F, LE & Rec<As, RE> & ID>>;
|
|
9
|
-
export {};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { AsLiteral, O, RORec, doc, notArr } from '../../../types';
|
|
2
|
-
import { type Field } from '../../field';
|
|
3
|
-
import type { SnapshotStream, SnapshotStreamExecutionResult } from '../../types/stream';
|
|
4
|
-
type Params<As extends string, LQ extends O, RQ extends O, RE extends RQ, S extends notArr> = {
|
|
5
|
-
localField: Field<LQ, S>;
|
|
6
|
-
foreignField: Field<RQ, S>;
|
|
7
|
-
from: SnapshotStreamExecutionResult<RQ, RE>;
|
|
8
|
-
as: AsLiteral<As>;
|
|
9
|
-
};
|
|
10
|
-
export declare const $lookup: <As extends string, LQ extends doc, RQ extends O, RE extends RQ & doc, S extends notArr>(p: Params<As, LQ, RQ, RE, S>) => <LE extends LQ>(l: SnapshotStream<LQ, LE>) => SnapshotStream<LQ, LE & RORec<As, RE>>;
|
|
11
|
-
export declare const $outerLookup: <As extends string, LQ extends doc, RQ extends O, RE extends RQ & doc, S extends notArr>(p: Params<As, LQ, RQ, RE, S>) => <LE extends LQ>(l: SnapshotStream<LQ, LE>) => SnapshotStream<LQ, LE & RORec<As, RE | null>>;
|
|
12
|
-
export {};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Arr, O, Rec } from '../../types';
|
|
2
|
-
import type { Accumulators, Expr, LookupArgs, Query, RawStages } from '../types';
|
|
3
|
-
import type { Updater } from '../update/updater';
|
|
4
|
-
export * from './raws';
|
|
5
|
-
type s = string;
|
|
6
|
-
export declare const $match_: <Q, T extends Q & O, C = unknown>(query?: Query<T, C>) => RawStages<O<T>, T, T, C>;
|
|
7
|
-
export declare const $set_: <Q, T extends Q & O, V extends Q & O, C = unknown>(updater: Updater<T, T, V, C>) => RawStages<O<Q>, T, V, C, 1>;
|
|
8
|
-
export declare const $replaceWith_: <T extends O, V extends O, C = unknown>(expr: Expr<V, T, C>) => RawStages<O, T, V, C, 1>;
|
|
9
|
-
export declare const $unwind_: <T extends O, K extends s, U, Null extends null = never>(k: K, includeNull?: Null) => RawStages<O<T>, T & Rec<K, Arr<U>>, T & Rec<K, Null | U>>;
|
|
10
|
-
export declare const $group_: <V extends O>() => <ID, T extends O, C = unknown>(id: Expr<ID, T, C>, args: Accumulators<T, V, C>) => RawStages<O, T, Rec<"_id", ID> & V, C, 1>;
|
|
11
|
-
export declare const $documents_: <T extends O, C>(docs: Expr<Arr<T>, unknown, C>) => RawStages<unknown, null, T, C, 1>;
|
|
12
|
-
export declare const $project_: <T extends O, K extends import("../..").StrKey<T>>(projection: import("../utils").ExactKeys<K>) => RawStages<T, T, T, unknown, 1>;
|
|
13
|
-
export declare const $simpleLookup_: <T extends O, U extends O, R, K extends s, Ctx, C = unknown, S = string>(args: LookupArgs<T, U, R, K, Ctx, C, S>) => RawStages<O<T>, T, T & Rec<K, Arr<U>>, C, 1>;
|