@omegup/msync 0.0.31 → 0.0.32-test1

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.
Files changed (89) hide show
  1. package/index.d.ts +2 -2
  2. package/index.esm.js +140 -114
  3. package/index.js +140 -114
  4. package/package.json +1 -1
  5. package/lib/accumulators/index.d.ts +0 -10
  6. package/lib/aggregate/$merge.d.ts +0 -10
  7. package/lib/aggregate/$upsert.d.ts +0 -11
  8. package/lib/aggregate/group/$group-merge.d.ts +0 -12
  9. package/lib/aggregate/group/index.d.ts +0 -2
  10. package/lib/aggregate/group/utils/sub-group.d.ts +0 -6
  11. package/lib/aggregate/group/utils/sub-merge.d.ts +0 -15
  12. package/lib/aggregate/index.d.ts +0 -8
  13. package/lib/aggregate/lookup/$lookup-delta.d.ts +0 -10
  14. package/lib/aggregate/lookup/$lookup-raw.d.ts +0 -9
  15. package/lib/aggregate/lookup/index.d.ts +0 -11
  16. package/lib/aggregate/match/$match-delta.d.ts +0 -3
  17. package/lib/aggregate/match/$match.d.ts +0 -3
  18. package/lib/aggregate/match/index.d.ts +0 -2
  19. package/lib/aggregate/mongo-stages.d.ts +0 -13
  20. package/lib/aggregate/out.d.ts +0 -34
  21. package/lib/aggregate/prefix.d.ts +0 -33
  22. package/lib/aggregate/raws.d.ts +0 -17
  23. package/lib/aggregate/set/$replace-with-each.d.ts +0 -12
  24. package/lib/aggregate/set/$set-delta.d.ts +0 -5
  25. package/lib/aggregate/set/$set.d.ts +0 -6
  26. package/lib/aggregate/set/index.d.ts +0 -1
  27. package/lib/aggregate/unwind/$unwind-delta.d.ts +0 -5
  28. package/lib/aggregate/unwind/index.d.ts +0 -5
  29. package/lib/boot/boot-simpl.d.ts +0 -14
  30. package/lib/boot/boot.d.ts +0 -36
  31. package/lib/boot/index.d.ts +0 -2
  32. package/lib/expression/arith.d.ts +0 -26
  33. package/lib/expression/array.d.ts +0 -25
  34. package/lib/expression/concat.d.ts +0 -30
  35. package/lib/expression/date.d.ts +0 -17
  36. package/lib/expression/expr-base.d.ts +0 -5
  37. package/lib/expression/index.d.ts +0 -7
  38. package/lib/expression/logic.d.ts +0 -22
  39. package/lib/expression/range.d.ts +0 -6
  40. package/lib/expression/val.d.ts +0 -25
  41. package/lib/field/field.d.ts +0 -25
  42. package/lib/field/index.d.ts +0 -1
  43. package/lib/machine.d.ts +0 -9
  44. package/lib/predicate/$eq.d.ts +0 -13
  45. package/lib/predicate/$expr.d.ts +0 -3
  46. package/lib/predicate/$in.d.ts +0 -2
  47. package/lib/predicate/index.d.ts +0 -3
  48. package/lib/predicate/utils.d.ts +0 -5
  49. package/lib/query/index.d.ts +0 -1
  50. package/lib/query/logic.d.ts +0 -11
  51. package/lib/stream/aggregate.d.ts +0 -7
  52. package/lib/types/accumulator.d.ts +0 -30
  53. package/lib/types/aggregate.d.ts +0 -9
  54. package/lib/types/expr.d.ts +0 -27
  55. package/lib/types/extern.d.ts +0 -3
  56. package/lib/types/index.d.ts +0 -8
  57. package/lib/types/lookup.d.ts +0 -19
  58. package/lib/types/machine.d.ts +0 -17
  59. package/lib/types/predicate.d.ts +0 -14
  60. package/lib/types/query.d.ts +0 -12
  61. package/lib/types/stream.d.ts +0 -67
  62. package/lib/update/index.d.ts +0 -1
  63. package/lib/update/updater.d.ts +0 -19
  64. package/lib/utils/before.d.ts +0 -3
  65. package/lib/utils/coll.d.ts +0 -5
  66. package/lib/utils/db-indexes.d.ts +0 -4
  67. package/lib/utils/guard.d.ts +0 -18
  68. package/lib/utils/index.d.ts +0 -3
  69. package/lib/utils/json.d.ts +0 -9
  70. package/lib/utils/log.d.ts +0 -1
  71. package/lib/utils/map-object.d.ts +0 -41
  72. package/lib/utils/merge/combiners.d.ts +0 -6
  73. package/lib/utils/merge/index.d.ts +0 -2
  74. package/lib/utils/merge/merge.d.ts +0 -7
  75. package/lib/utils/merge/next-winner.d.ts +0 -3
  76. package/lib/utils/merge/types.d.ts +0 -19
  77. package/lib/utils/merge/utils.d.ts +0 -5
  78. package/lib/utils/tear-down.d.ts +0 -2
  79. package/lib/watch.d.ts +0 -15
  80. package/test/mongodb.d.ts +0 -9
  81. package/test/uri.d.ts +0 -1
  82. package/types/class.d.ts +0 -1
  83. package/types/extern.d.ts +0 -3
  84. package/types/global.d.ts +0 -50
  85. package/types/hkt.d.ts +0 -56
  86. package/types/index.d.ts +0 -6
  87. package/types/json.d.ts +0 -54
  88. package/types/mongo.d.ts +0 -24
  89. package/types/view.d.ts +0 -35
package/index.js CHANGED
@@ -467,7 +467,12 @@ const $replaceWith1 = (expr) => f => {
467
467
  { $replaceWith: parts.reduce((v, k) => ({ [k]: v }), expr.raw(f()).get()) },
468
468
  ]);
469
469
  };
470
- const $unwind1 = (k) => f => asStages([{ $unwind: `$${f().of(k).str()}` }]);
470
+ const $unwind1 = (k, includeNull) => f => {
471
+ const path = `$${f().of(k).str()}`;
472
+ return asStages([
473
+ { $unwind: path },
474
+ ]);
475
+ };
471
476
  const $group1 = (id, args) => (f) => asStages([
472
477
  {
473
478
  $group: {
@@ -498,7 +503,7 @@ const $simpleLookup1 = (args) => f => {
498
503
  const $match_ = (query) => $match1(query)(root);
499
504
  const $set_ = (updater) => $set1(updater)(root);
500
505
  const $replaceWith_ = (expr) => $replaceWith1(expr)(root);
501
- const $unwind_ = (k) => $unwind1(k)(root);
506
+ const $unwind_ = (k, includeNull) => $unwind1(k)(root);
502
507
  const $group_ = () => (id, args) => $group1(id, args)(root);
503
508
  const $project_ = $project1;
504
509
  const $simpleLookup_ = (args) => $simpleLookup1(args)(root);
@@ -614,29 +619,6 @@ const $groupMerge = (id, args, out, gid, extra, idPrefix = '') => ({
614
619
  const $groupId = (id, args, out, extra) => $groupMerge(id, args, { into: out, whenNotMatched: 'fail' }, '_id', extra);
615
620
  const $group = (id, args, out, extra, idPrefix = '') => $groupMerge(id, args, { into: out, whenNotMatched: 'insert' }, '_grp', extra, idPrefix);
616
621
 
617
- const $expr = (expr) => ({
618
- raw: f => ({ $expr: expr.raw(f).get() }),
619
- });
620
-
621
- const $lookupRaw = ({ field1, field2 }, { coll, exec, input }, k2, k) => (f) => {
622
- root().of('_id').expr();
623
- root().of(k2).of('_id').expr();
624
- return link()
625
- .with($simpleLookup1({
626
- coll,
627
- k: k2,
628
- vars: map1('local', root().with(field1).expr()),
629
- pipeline: link()
630
- .with(input)
631
- .with($match_($expr(eq(ctx()('local').expr())(root().of('before').with(field2).expr()))))
632
- .with(exec)
633
- .with($replaceWith_(root().of('before').expr())).stages,
634
- })(f))
635
- .with($unwind1(k2)(f))
636
- .with(link().stages
637
- ).stages;
638
- };
639
-
640
622
  const deltaExpr = (expr) => (field) => {
641
623
  return ite(eqTyped($ifNull(root().of(field).expr(), nil), nil), nil, expr(field));
642
624
  };
@@ -666,7 +648,82 @@ const $setDelta = (updater) => {
666
648
  .with($setEach(k => to(nil), dict)).stages;
667
649
  };
668
650
 
669
- const $unwindDelta = (k1, k2, k) => {
651
+ const $unwindDelta = (k1, k2, k, includeNull) => {
652
+ const outer = includeNull === null;
653
+ const newItems = {
654
+ $filter: {
655
+ input: { $ifNull: [`$after.${k2}`, []] },
656
+ as: 'a',
657
+ cond: {
658
+ $not: {
659
+ $in: [
660
+ '$$a._id',
661
+ {
662
+ $map: {
663
+ input: { $ifNull: [`$before.${k2}`, []] },
664
+ as: 'b',
665
+ in: '$$b._id',
666
+ },
667
+ },
668
+ ],
669
+ },
670
+ },
671
+ },
672
+ };
673
+ const oldItems = {
674
+ $filter: {
675
+ input: {
676
+ $map: {
677
+ input: { $ifNull: [`$before.${k2}`, []] },
678
+ as: 'b',
679
+ in: {
680
+ before: '$$b',
681
+ after: {
682
+ $ifNull: [
683
+ {
684
+ $first: {
685
+ $filter: {
686
+ input: `$after.${k2}`,
687
+ as: 'a',
688
+ cond: { $eq: ['$$a._id', '$$b._id'] },
689
+ },
690
+ },
691
+ },
692
+ null,
693
+ ],
694
+ },
695
+ },
696
+ },
697
+ },
698
+ as: 'a',
699
+ cond: { $ne: ['$$a.before', '$$a.after'] },
700
+ },
701
+ };
702
+ const ifNull = (k, part, str = `$${[k1, k2].sort()[0]}.${part}._id`) => outer && k == k2 ? { $ifNull: [str, 'null'] } : str;
703
+ const interDot = ([a, b]) => [a, '.', b];
704
+ const partReplace = (part) => ({
705
+ $cond: {
706
+ if: { $or: [{ $eq: [`$${k1}.${part}`, null] }, { $eq: [`$${k2}.${part}`, null] }] },
707
+ then: null,
708
+ else: {
709
+ _id: k
710
+ ? `$${k}.${part}._id`
711
+ : {
712
+ $concat: interDot([k1, k2].sort().map(k => ifNull(k, part))),
713
+ },
714
+ [k1]: `$${k1}.${part}`,
715
+ [k2]: outer
716
+ ? {
717
+ $cond: {
718
+ if: `$${k2}.${part}._id`,
719
+ then: `$${k2}.${part}`,
720
+ else: null,
721
+ },
722
+ }
723
+ : `$${k2}.${part}`,
724
+ },
725
+ },
726
+ });
670
727
  const stages = link()
671
728
  .with(asStages([
672
729
  {
@@ -677,51 +734,34 @@ const $unwindDelta = (k1, k2, k) => {
677
734
  },
678
735
  [k2]: {
679
736
  $concatArrays: [
680
- {
681
- $map: {
682
- input: { $ifNull: [`$before.${k2}`, []] },
683
- as: 'b',
684
- in: {
685
- before: '$$b',
686
- after: {
687
- $ifNull: [
688
- {
689
- $first: {
690
- $filter: {
691
- input: `$after.${k2}`,
692
- as: 'a',
693
- cond: { $eq: ['$$a._id', '$$b._id'] },
694
- },
695
- },
696
- },
697
- null,
698
- ],
737
+ outer
738
+ ? {
739
+ $cond: {
740
+ if: { $eq: [`$before.${k2}`, []] },
741
+ then: {
742
+ $cond: {
743
+ if: { $eq: [`$after.${k2}`, []] },
744
+ then: [],
745
+ else: [{ before: {}, after: null }],
746
+ },
699
747
  },
748
+ else: oldItems,
700
749
  },
701
- },
702
- },
750
+ }
751
+ : oldItems,
703
752
  {
704
753
  $map: {
705
- input: {
706
- $filter: {
707
- input: { $ifNull: [`$after.${k2}`, []] },
708
- as: 'a',
709
- cond: {
710
- $not: {
711
- $in: [
712
- '$$a._id',
713
- {
714
- $map: {
715
- input: { $ifNull: [`$before.${k2}`, []] },
716
- as: 'b',
717
- in: '$$b._id',
718
- },
719
- },
720
- ],
754
+ input: outer
755
+ ? {
756
+ $cond: {
757
+ if: {
758
+ $and: [{ $ne: [`$before.${k2}`, []] }, { $eq: [`$after.${k2}`, []] }],
721
759
  },
760
+ then: [{}],
761
+ else: newItems,
722
762
  },
723
- },
724
- },
763
+ }
764
+ : newItems,
725
765
  as: 'a',
726
766
  in: { before: null, after: '$$a' },
727
767
  },
@@ -735,45 +775,9 @@ const $unwindDelta = (k1, k2, k) => {
735
775
  .with(asStages([
736
776
  {
737
777
  $replaceWith: {
738
- _id: "$_id",
739
- before: {
740
- $cond: {
741
- if: { $or: [{ $eq: [`$${k1}.before`, null] }, { $eq: [`$${k2}.before`, null] }] },
742
- then: null,
743
- else: {
744
- _id: {
745
- $concat: k
746
- ? `$${k}.before._id`
747
- : [
748
- `$${[k1, k2].sort()[0]}.before._id`,
749
- '.',
750
- `$${[k1, k2].sort()[1]}.before._id`,
751
- ],
752
- },
753
- [k1]: `$${k1}.before`,
754
- [k2]: `$${k2}.before`,
755
- },
756
- },
757
- },
758
- after: {
759
- $cond: {
760
- if: { $or: [{ $eq: [`$${k1}.after`, null] }, { $eq: [`$${k2}.after`, null] }] },
761
- then: null,
762
- else: {
763
- _id: {
764
- $concat: k
765
- ? `$${k}.after._id`
766
- : [
767
- `$${[k1, k2].sort()[0]}.after._id`,
768
- '.',
769
- `$${[k1, k2].sort()[1]}.after._id`,
770
- ],
771
- },
772
- [k1]: `$${k1}.after`,
773
- [k2]: `$${k2}.after`,
774
- },
775
- },
776
- },
778
+ _id: '$_id',
779
+ before: partReplace('before'),
780
+ after: partReplace('after'),
777
781
  },
778
782
  },
779
783
  ])).stages;
@@ -793,7 +797,7 @@ const $unwind = (k, dict) => ({
793
797
  raw: $unwind1(k),
794
798
  });
795
799
 
796
- const $lookupDelta = ({ field1, field2 }, { coll, exec, input }, k1, k2, k) => {
800
+ const $lookupDelta = ({ field1, field2 }, { coll, exec, input }, k1, k2, k, includeNull) => {
797
801
  return link()
798
802
  .with($replaceWithDelta(field(map1(k1, root().expr()))))
799
803
  .with($simpleLookup_({
@@ -822,8 +826,30 @@ const $lookupDelta = ({ field1, field2 }, { coll, exec, input }, k1, k2, k) => {
822
826
  const a = root().of(f1).of('before').expr();
823
827
  const part = root().of(f);
824
828
  return ite(eq(root().of(f).expr())(nil), nil, field(omit.backward(mergeExpr(omit.forward(map1(k2, a)), map1(k1, part.of(k1).expr())))));
825
- }))
826
- .with($unwindDelta(k1, k2, k)).stages;
829
+ })).with($unwindDelta(k1, k2, k, includeNull)).stages;
830
+ };
831
+
832
+ const $expr = (expr) => ({
833
+ raw: f => ({ $expr: expr.raw(f).get() }),
834
+ });
835
+
836
+ const $lookupRaw = ({ field1, field2 }, { coll, exec, input }, k2, k) => (f) => {
837
+ root().of('_id').expr();
838
+ root().of(k2).of('_id').expr();
839
+ return link()
840
+ .with($simpleLookup1({
841
+ coll,
842
+ k: k2,
843
+ vars: map1('local', root().with(field1).expr()),
844
+ pipeline: link()
845
+ .with(input)
846
+ .with($match_($expr(eq(ctx()('local').expr())(root().of('before').with(field2).expr()))))
847
+ .with(exec)
848
+ .with($replaceWith_(root().of('before').expr())).stages,
849
+ })(f))
850
+ .with($unwind1(k2)(f))
851
+ .with(link().stages
852
+ ).stages;
827
853
  };
828
854
 
829
855
  const asBefore = (f) => f(() => root().of('before'));
@@ -939,9 +965,9 @@ const runCont = async ({ next }, cb) => {
939
965
  };
940
966
 
941
967
  const merge = ({ lsource: L, rsource: R, }) => mergeIterators({ sources: { L, R } });
942
- const join = ({ lField, rField, left, right, as }, leftSnapshot, rightSnapshot, stagesUntilNextLookup) => {
943
- createIndex(leftSnapshot.coll, { [lField.str()]: 1 }).catch(e => e.code == 86 || Promise.reject(e));
944
- createIndex(rightSnapshot.coll, { [rField.str()]: 1 }).catch(e => e.code == 86 || Promise.reject(e));
968
+ const join = ({ lField, rField, left, right, as }, leftSnapshot, rightSnapshot, stagesUntilNextLookup, includeNull) => {
969
+ createIndex(leftSnapshot.coll, { [`before.${lField.str()}`]: 1 }).catch(e => e.code == 86 || Promise.reject(e));
970
+ createIndex(rightSnapshot.coll, { [`before.${rField.str()}`]: 1 }).catch(e => e.code == 86 || Promise.reject(e));
945
971
  const rightJoinField = { field1: lField, field2: rField };
946
972
  const joinId = 'left';
947
973
  const joinR_Snapshot = asBefore($lookupRaw(rightJoinField, rightSnapshot, as));
@@ -954,7 +980,7 @@ const join = ({ lField, rField, left, right, as }, leftSnapshot, rightSnapshot,
954
980
  out: (finalInput) => {
955
981
  const leftJoinField = { field1: rField, field2: lField };
956
982
  const joinL_Delta = $lookupDelta(leftJoinField, leftSnapshot, 'right', 'left', joinId);
957
- const joinR_Delta = $lookupDelta(rightJoinField, rightSnapshot, 'left', 'right', joinId);
983
+ const joinR_Delta = $lookupDelta(rightJoinField, rightSnapshot, 'left', 'right', joinId, includeNull);
958
984
  const mergeForeignIntoDoc = concatStages($replaceWithDelta(mergeObjects(root().of('left').expr(), fieldM({ a: root().of('right').expr(), b: root().of('_id').expr() }, dictId))), stagesUntilNextLookup.delta);
959
985
  const lRunnerInput = concatStages(joinR_Delta, mergeForeignIntoDoc);
960
986
  const rRunnerInput = concatStages(joinL_Delta, mergeForeignIntoDoc);
@@ -1188,7 +1214,7 @@ const makeWatchStream = (db, { collection, projection: p, hardMatch: m }, startA
1188
1214
  };
1189
1215
 
1190
1216
  const actions = {
1191
- updateMany: (c, args) => [c.updateMany(...args), [`db['${c.collectionName}'].updateMany(`, ...args, ')']],
1217
+ updateMany: (c, args) => [c.updateMany(...args), [`db['${c.collectionName}'].updateMany(...`, args, ')']],
1192
1218
  };
1193
1219
  const streamNames = {};
1194
1220
  const executes$1 = (view, input, streamName) => {
@@ -1268,9 +1294,9 @@ const executes$1 = (view, input, streamName) => {
1268
1294
  params: p,
1269
1295
  };
1270
1296
  const [action, out] = actions[method](collection, params);
1271
- log('teardown', `db.['${snapshotCollection.collectionName}'].drop()`, ...out);
1297
+ log('teardown', `db['${snapshotCollection.collectionName}'].drop()`, ...out);
1272
1298
  await Promise.all([snapshotCollection.drop(), action]);
1273
- log('teardown done', `db.['${snapshotCollection.collectionName}'].drop()`, ...out);
1299
+ log('teardown done', `db['${snapshotCollection.collectionName}'].drop()`, ...out);
1274
1300
  };
1275
1301
  if (exists && !same)
1276
1302
  await handleTeardown(exists);
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.31",
6
+ "version": "0.0.32-test1",
7
7
  "dependencies": {
8
8
  "dayjs": "^1.11.9",
9
9
  "dotenv": "^16.3.1",
@@ -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,10 +0,0 @@
1
- import type { OPick, RWCollection } from '../../types';
2
- import type { ID, N, O, Rec, Replace, StrKey, doc } from '../../types/json';
3
- import { type ExprsExact } from '../expression/concat';
4
- import type { Delta, StreamRunnerParam, TS } from '../types';
5
- type Allowed<K extends string> = Exclude<K, keyof (TS & ID)>;
6
- type Patch<V, KK extends StrKey<V> = StrKey<V>> = ((OPick<V, Allowed<KK>> & ID) | (Rec<Allowed<KK>, N> & ID)) & TS;
7
- type TakeDoc<V, E = ID, KK extends StrKey<V> = StrKey<V>> = OPick<V, Allowed<KK>> & E;
8
- export 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>) => StreamRunnerParam<Source, "out">;
9
- export 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>) => StreamRunnerParam<Delta<SourcePart>, "out">;
10
- export {};
@@ -1,11 +0,0 @@
1
- import type { RWCollection } from '../../types';
2
- import type { ID, O, doc } from '../../types/json';
3
- import type { Del, Delta, Expr, StreamRunnerParam, TS } from '../types';
4
- type ND = {
5
- readonly deletedAt?: null;
6
- };
7
- export type Merge<T extends ID> = (T & ND & TS) | Del;
8
- export declare const $insertX: <T extends doc, D extends O>(out: RWCollection<Merge<T>>, expr: Expr<T, D>, map: (x: Expr<T & ND & TS, D>) => Expr<Merge<T>, D>) => StreamRunnerParam<D, "out">;
9
- export declare const $simpleInsert: <T extends doc>(out: RWCollection<Merge<T>>) => StreamRunnerParam<T, "out">;
10
- export declare const $insert: <T extends doc>(out: RWCollection<Merge<T>>) => StreamRunnerParam<Delta<T>, "out">;
11
- 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" | keyof Omit<V, IdAndTsKeys | "_grp">>, Rec<"_grp", Grp> & Omit<V, IdAndTsKeys | "_grp">>, idPrefix?: string) => StreamRunnerParam<Delta<T>, "out">;
12
- export {};
@@ -1,2 +0,0 @@
1
- export { $groupMerge, $groupId, $group } from './$group-merge';
2
- export type { Loose, Strict } from './utils/sub-merge';
@@ -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,15 +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
- export type Loose<Grp, VV, GG extends string> = Prepare<Grp, GG> & Partial<V<VV, GG>>;
11
- export type Strict<Grp, VV, GG extends string, EE> = Prepare<Grp, GG> & V<VV, GG> & Omit<EE, IdAndTsKeys | GI<GG> | keyof V<VV, GG>>;
12
- export type V_Grp<VV, GG extends string, Grp> = Rec<GI<GG>, Grp> & V<VV, GG>;
13
- export type Extra<EE, VV, GG extends string> = Omit<EE, IdAndTsKeys | GI<GG> | keyof V<VV, GG>>;
14
- 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">;
15
- export {};
@@ -1,8 +0,0 @@
1
- export * from './group';
2
- export * from './lookup';
3
- export * from './match';
4
- export * from './set';
5
- export * from './unwind';
6
- export * from './$merge';
7
- export * from './$upsert';
8
- export * from './out';
@@ -1,10 +0,0 @@
1
- import type { AsLiteral, ID, N, O, Rec } 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> = Delta<Rec<K1, LE> & Rec<Exclude<KK2, BA | K1>, RE> & ID>;
6
- export declare const $lookupDelta: <LQ extends O, LE extends LQ & O, RQ extends O, RE extends RQ, BRB extends UBefore<RQ>, RS extends UBefore<RQ>, S, K1 extends s, KK2 extends s>({ 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: K1 | Exclude<KK2, BA | K1> | false) => RawStages<unknown, Delta<LE>, Both<K1, LE, KK2, RE>>;
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>({ 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" | "right" | false) => <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,11 +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 {};
@@ -1,3 +0,0 @@
1
- import type { doc } from '../../../types';
2
- import type { Delta, Expr } from '../../types';
3
- export declare const $matchDelta: <T extends doc>(query: Expr<boolean, T>) => import("../../types").RawStages<unknown, Delta<T>, Delta<T>, unknown, number>;
@@ -1,3 +0,0 @@
1
- import type { doc } from '../../../types';
2
- import type { DeltaStages, Expr } from '../../types';
3
- export declare const $match: <T extends doc>(query: Expr<boolean, T>) => DeltaStages<T, T, T>;
@@ -1,2 +0,0 @@
1
- export { $matchDelta } from './$match-delta';
2
- export { $match } from './$match';
@@ -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>(k: K) => RawStages<O<T>, T & Rec<K, Arr<U>>, T & Rec<K, 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/map-object").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>;
@@ -1,34 +0,0 @@
1
- import type { O, RWCollection, ReadonlyCollection, Replace, jsonItem } from '../../types';
2
- import type { ExprsExact } from '../expression/concat';
3
- import { type Field } from '../field';
4
- import type { RawStages } from '../types';
5
- export type MergeInto<T extends O, Out extends O, E = unknown> = {
6
- whenNotMatched: 'insert';
7
- into: RWCollection<T, Out>;
8
- } | {
9
- whenNotMatched: 'discard' | 'fail';
10
- into: ReadonlyCollection<Out> & E;
11
- };
12
- export type MergeArgs<T extends O, Out extends O, Ctx, In extends O> = {
13
- on: Field<T, jsonItem> & Field<Out, jsonItem>;
14
- } & MergeInto<T, Out> & (({
15
- stages?: undefined;
16
- } & ({
17
- whenMatched: 'keepExisting' | 'fail';
18
- } | {
19
- whenMatched: 'replace';
20
- into: RWCollection<T, Out>;
21
- } | {
22
- whenMatched: 'merge';
23
- into: RWCollection<Replace<Out, T>, Out>;
24
- })) | {
25
- stages: true;
26
- into: RWCollection<In, Out>;
27
- whenMatched: RawStages<unknown, Out, In>;
28
- } | {
29
- stages: 'ctx';
30
- vars: ExprsExact<Ctx, T>;
31
- into: RWCollection<In, Out>;
32
- whenMatched: RawStages<unknown, Out, In, Ctx>;
33
- });
34
- export 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>;
@@ -1,33 +0,0 @@
1
- import type { App, HKT, O2, O3, O, RawObj } from '../../types';
2
- import type { Delta, DeltaStages, FRawStages, RawStages, Stream, TStages } from '../types';
3
- import type { Equal } from '../utils/guard';
4
- type n = number;
5
- export declare const asStages: <Q, T extends Q, V extends Q, C = unknown, M extends n = number>(x: readonly RawObj[]) => RawStages<Q, T, V, C, M>;
6
- export declare const same: <T extends Dom, V extends Dom, F extends HKT<Dom, Q>, Dom = unknown, Q = unknown, C = unknown, M extends n = number>(_: Equal<Dom, T, V>) => RawStages<Q, App<F, T>, App<F, V>, C, M>;
7
- export declare const concatStages: <Q, T extends Q, V extends Q, W extends Q, C, M extends n = number>(part1: RawStages<Q, T, V, C, M>, part2: RawStages<Q, V, W, C, M>) => RawStages<Q, T, W, C, M>;
8
- export declare const concatFStages: <Q, T extends Q & O, V extends Q & O, W extends Q & O, C, M extends n = number>(part1: FRawStages<Q, T, V, C, M>, part2: FRawStages<Q, V, W, C, M>) => FRawStages<Q, T, W, C, M>;
9
- export declare const concatDelta: <Q extends O, T extends Q, V extends Q, W extends Q>(part1: DeltaStages<Q, T, V>, part2: DeltaStages<Q, V, W>) => DeltaStages<Q, T, W>;
10
- type Concat<out Q, in T extends Q, out V extends Q, in out C, in out M extends n = n> = {
11
- with: <Q2, W extends Q2>(extra: RawStages<Q | Q2, V, W, C, M>) => Concat<Q | Q2, T, W, C, M>;
12
- stages: RawStages<Q, T, V, C, M>;
13
- };
14
- type FConcat<out Q, in T extends Q & O, out V extends Q & O, in out C, in out M extends n = n> = {
15
- with: <Q2, W extends Q2 & O>(extra: FRawStages<Q | Q2, V, W, C, M>) => FConcat<Q | Q2, T, W, C, M>;
16
- stages: FRawStages<Q, T, V, C, M>;
17
- };
18
- export type DeltaPipe<Q extends O, T extends Q, F extends HKT<O2>, G extends HKT<O3>> = {
19
- with: <Q2 extends O, V extends Q2>(map: (a: Stream<Q, T, F, G>) => Stream<Q | Q2, V, F, G>) => DeltaPipe<Q | Q2, V, F, G>;
20
- then: <Q2 extends O, V extends Q2>(next: App<G, [Q2 | T, T, V]>) => DeltaPipe<Q | Q2, V, F, G>;
21
- get: () => App<F, [Q, T]>;
22
- };
23
- export declare const pipe: <Q extends O, S extends Q, T extends Q, F extends HKT<O2>, G extends HKT<O3>>(stream: Stream<Q, S, F, G>, s: App<G, [Q, S, T]>, concat: <Q_1 extends O, T_1 extends Q_1, V extends Q_1, W extends Q_1>(part1: App<G, [Q_1, T_1, V]>, part2: App<G, [Q_1, V, W]>) => App<G, [Q_1, T_1, W]>, empty: <T_2 extends Q>() => App<G, [Q, T_2, T_2]>) => DeltaPipe<Q, T, F, G>;
24
- type Link = <T, C = unknown, M extends n = n>() => Concat<T, T, T, C, M>;
25
- type FLink = <T extends O, C = unknown, M extends n = n>() => FConcat<T, T, T, C, M>;
26
- export declare const link: Link;
27
- export declare const flink: FLink;
28
- export declare const emptyDelta: <T extends O>() => {
29
- delta: RawStages<Delta<T>, Delta<T>, Delta<T>, unknown, number>;
30
- raw: <F extends HKT<O>>() => RawStages<App<F, T>, App<F, T>, App<F, T>, unknown, number>;
31
- };
32
- export declare const concatTStages: <S, Q, B extends Q, T extends Q, V extends Q>({ coll, exec, input }: TStages<S, Q, B, T>, stages: RawStages<Q, T, V>) => TStages<S, Q, B, V>;
33
- export {};
@@ -1,17 +0,0 @@
1
- import type { App, Arr, ConstHKT, HKT, O, Rec, StrKey, rawItem } from '../../types';
2
- import type { ExprsExact } from '../expression/concat';
3
- import { type Field } from '../field';
4
- import type { Accumulators, Expr, FRawStages, LookupArgs, Query, RawStages } from '../types';
5
- import type { Updater } from '../update/updater';
6
- import { type ExactKeys } from '../utils/map-object';
7
- type s = string;
8
- export declare const $match1: <T extends O, C = unknown>(query?: Query<T, C>) => FRawStages<T, T, T, C>;
9
- export declare const $set1: <Q, T extends Q & O, V extends Q & O, C = unknown>(updater: Updater<T, T, V, C>) => FRawStages<Q, T, V, C, 1>;
10
- export declare const $project1: <T extends O, K extends StrKey<T>>(projection: ExactKeys<K>) => RawStages<T, T, T, unknown, 1>;
11
- export declare const $replaceWith1: <T extends O, V extends O, C = unknown>(expr: Expr<V, T, C>) => FRawStages<O, T, V, C, 1>;
12
- export declare const $unwind1: <T extends O, K extends s, R>(k: K) => FRawStages<T, T & Rec<K, Arr<R>>, T & Rec<K, R>>;
13
- export declare const $group1: <T extends O, ID, V extends O, C>(id: Expr<ID, T, C>, args: Accumulators<T, V, C>) => <F extends HKT<O, O>>(f: <T_1 extends O>() => Field<App<F, T_1>, T_1>) => RawStages<O, App<F, T>, Rec<"_id", ID> & V, C, 1>;
14
- export declare const $documents1: <Q extends O, T extends Q & O, C>(docs: Expr<Arr<T>, unknown, C>) => <F extends HKT<O, O>>(f: <T_1 extends O>() => Field<App<F, T_1>, T_1>) => RawStages<unknown, null, App<F, T>, C, 1>;
15
- export declare const rawVars: <T, Ctx, C, V extends O>(vars: ExprsExact<Ctx, T, C>, f: Field<V, T, unknown>) => import("../utils/map-object").ExactPart1<Ctx, ConstHKT<rawItem, unknown>>;
16
- export declare const $simpleLookup1: <T extends O, U extends O, R, K extends s, Ctx, C = unknown, S = string>(args: LookupArgs<T, U, R, K, Ctx, C, S>) => FRawStages<T, T, T & Rec<K, Arr<U>>, C, 1>;
17
- export {};
@@ -1,12 +0,0 @@
1
- import type { ConstHKT, HKT, I, N, O, RORec, Rec, jsonItem } from '../../../types';
2
- import type { BA, Delta, Expr, FRawStages, RawStages } from '../../types';
3
- import { type Updater } from '../../update/updater';
4
- import { type MapK } from '../../utils/map-object';
5
- export interface ParDeltaHKT<K extends BA, T extends jsonItem, E> extends HKT<jsonItem> {
6
- readonly out: RORec<K, I<jsonItem, this>> & Delta<T> & E;
7
- }
8
- type Delta2<T extends jsonItem, BA2 extends string> = Delta<T> & Partial<RORec<BA2, T | null>>;
9
- export declare const $setEach1: <T extends jsonItem, V extends jsonItem, BA2 extends string, E = unknown, C = unknown>(updater: (k: BA) => Updater<Delta<T> & Partial<RORec<BA2, T | null>> & E, T | N, V | null, C>, dict: MapK<BA2, ConstHKT<BA>>) => FRawStages<unknown, Delta2<T, BA2> & E, Rec<BA2, V | null> & Omit<Delta<T> & E, BA2>, C, 1>;
10
- export declare const $setEach: <T extends O, V extends jsonItem, BA2 extends string, E = unknown, C = unknown>(updater: (k: BA) => Updater<Delta<T> & E, T | N, V | null, C>, dict: MapK<BA2, ConstHKT<BA>>) => RawStages<unknown, Delta2<T, BA2> & E, Rec<BA2, V | null> & Omit<Delta<T> & E, BA2>, C, 1>;
11
- export declare const $replaceWithEach: <T extends O, V extends jsonItem, E = unknown>(expr: <K extends BA>(field: K) => Expr<V | null, Rec<K, T> & Delta<T> & E>) => RawStages<unknown, Delta<T> & E, Delta<V> & Omit<E, BA>>;
12
- export {};
@@ -1,5 +0,0 @@
1
- import type { O, jsonItem } from '../../../types';
2
- import type { Delta, Expr, RawStages } from '../../types';
3
- import { type Updater } from '../../update/updater';
4
- export declare const $replaceWithDelta: <T extends O, V extends jsonItem>(expr: Expr<V, T>) => RawStages<unknown, Delta<T>, Delta<V>>;
5
- export declare const $setDelta: <T extends O, V extends O, C = unknown>(updater: Updater<T, T, V, C>) => RawStages<unknown, Delta<T>, Delta<V>, C, number>;
@@ -1,6 +0,0 @@
1
- import type { O, Replace } from '../../../types';
2
- import type { DeltaStages, Expr, LinStages } from '../../types';
3
- import { type UpdaterHKT } from '../../update/updater';
4
- import type { MapO } from '../../utils/map-object';
5
- export declare const $set: <V extends O>() => <R extends O, C = unknown>(fields: MapO<V, UpdaterHKT<R, R, V, C>>) => DeltaStages<O, R, Replace<R, V>, C> & LinStages<O, R, Replace<R, V>, C>;
6
- export declare const $replaceWith: <T extends O, V extends O>(expr: Expr<V, T>) => DeltaStages<O, T, V> & LinStages<O, T, V>;