@omegup/msync 0.1.61 → 0.1.63

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 (65) hide show
  1. package/adapters/mongodb.d.ts +22 -0
  2. package/adapters/mongodb.esm.js +12 -0
  3. package/adapters/mongodb.esm.js.map +1 -0
  4. package/adapters/mongodb.js +14 -0
  5. package/adapters/mongodb.js.map +1 -0
  6. package/driver-BUCc3b89.js +31 -0
  7. package/driver-BUCc3b89.js.map +1 -0
  8. package/driver-sc6MCG57.esm.js +14 -0
  9. package/driver-sc6MCG57.esm.js.map +1 -0
  10. package/index.d.ts +13 -847
  11. package/index.esm.js +1918 -2239
  12. package/index.esm.js.map +1 -0
  13. package/index.js +1944 -2254
  14. package/index.js.map +1 -0
  15. package/lib/accumulators/index.d.ts +1 -1
  16. package/lib/aggregate/$merge.d.ts +9 -9
  17. package/lib/aggregate/$upsert.d.ts +6 -6
  18. package/lib/aggregate/group/$group-merge.d.ts +9 -10
  19. package/lib/aggregate/group/utils/sub-group.d.ts +1 -1
  20. package/lib/aggregate/group/utils/sub-merge.d.ts +28 -5
  21. package/lib/aggregate/lookup/$lookup-delta.d.ts +2 -2
  22. package/lib/aggregate/lookup/$lookup-raw.d.ts +3 -3
  23. package/lib/aggregate/mongo-stages.d.ts +3 -2
  24. package/lib/aggregate/prefix.d.ts +6 -6
  25. package/lib/aggregate/raws.d.ts +1 -1
  26. package/lib/aggregate/set/$replace-with-each.d.ts +5 -5
  27. package/lib/aggregate/set/$set.d.ts +1 -1
  28. package/lib/aggregate/unwind/$unwind-delta.d.ts +1 -1
  29. package/lib/aggregate/unwind/index.d.ts +2 -2
  30. package/lib/boot/boot-simpl.d.ts +1 -1
  31. package/lib/boot/boot-utils.d.ts +2 -3
  32. package/lib/boot/boot.d.ts +2 -2
  33. package/lib/boot/first-stages.d.ts +1 -2
  34. package/lib/driver.d.ts +5 -0
  35. package/lib/expression/concat.d.ts +4 -4
  36. package/lib/expression/date.d.ts +3 -3
  37. package/lib/expression/expr-base.d.ts +2 -2
  38. package/lib/expression/logic.d.ts +1 -1
  39. package/lib/expression/range.d.ts +2 -2
  40. package/lib/expression/val.d.ts +3 -3
  41. package/lib/field/field.d.ts +1 -1
  42. package/lib/predicate/$eq.d.ts +3 -4
  43. package/lib/types/accumulator.d.ts +4 -4
  44. package/lib/types/aggregate.d.ts +4 -2
  45. package/lib/types/query.d.ts +1 -5
  46. package/lib/types/stream.d.ts +3 -4
  47. package/lib/update/updater.d.ts +1 -1
  48. package/lib/utils/coll.d.ts +2 -2
  49. package/lib/utils/db-indexes.d.ts +2 -2
  50. package/lib/utils/guard.d.ts +2 -12
  51. package/lib/utils/json.d.ts +1 -0
  52. package/lib/utils/map-object.d.ts +1 -5
  53. package/lib/utils/merge/merge.d.ts +5 -4
  54. package/lib/utils/merge/next-winner.d.ts +2 -1
  55. package/lib/utils/merge/types.d.ts +9 -5
  56. package/lib/utils/merge/utils.d.ts +4 -2
  57. package/lib/watch.d.ts +2 -3
  58. package/package.json +21 -2
  59. package/types/global-aug.d.ts +1 -1
  60. package/types/global.d.ts +2 -0
  61. package/types/json.d.ts +13 -4
  62. package/types/mongo.d.ts +83 -23
  63. package/types/view.d.ts +1 -2
  64. package/test/mongodb.d.ts +0 -9
  65. package/test/uri.d.ts +0 -1
@@ -18,7 +18,7 @@ export declare const $pushDict: <D extends O, V, C = unknown>(key: Expr<string,
18
18
  [x: string]: O<{
19
19
  0: import("../..").Arr<AddO<V>>;
20
20
  1: import("../..").Arr<AddO<V>>;
21
- }> | undefined;
21
+ }>;
22
22
  }>, C>;
23
23
  export declare const $keys: <D extends O, K extends string = string, C = unknown>(expr: Expr<AddO<PRRec<K, number>>, D, C>) => Expr<AddO<K[]>, D, C>;
24
24
  export declare const $entries: <D extends O, V, C = unknown>(expr: Expr<AddO<PushDict<V>>, D, C>) => Expr<AddO<{
@@ -1,4 +1,4 @@
1
- import type { IdHKT, OPick, RWCollection, Timestamp } from '../../types';
1
+ import type { IdHKT, Omit, Exclude, OPick, RWCollection, Timestamp } from '../../types';
2
2
  import type { doc, ID, N, O, rawItem, Rec, Replace, RORec, StrKey } from '../../types/json';
3
3
  import { type ExprsExact } from '../expression/concat';
4
4
  import type { Delta, Expr, IsDeleted, Model, RawStages, StreamRunnerParam, TS } from '../types';
@@ -19,9 +19,9 @@ type Result<P> = Expr<P, unknown, {
19
19
  }>;
20
20
  type Update<P, Out> = (...args: Args<P, Out>) => Result<P>;
21
21
  type UpdateF<P, Out> = <K extends keyof IsDeleted>(...args: Args<Replace<P, RORec<K, Timestamp>>, Out>) => Result<Replace<P, RORec<K, Timestamp>>>;
22
- export declare const getSubsetMatchForExt: <Out extends Model, P extends Model, E extends Record<keyof E, rawItem>>(ext: Exact<E, IdHKT>) => null | Expr<boolean, Rec<"old" | "merged", Out | Replace<Out, P>>>;
23
- export declare const getWhenMatchedForMerge: <Out extends Model, P extends Model, K extends keyof IsDeleted>(whenNotMatched: "discard" | "fail" | "insert", update: Update<Replace<P, RORec<K, Timestamp>>, Out>, canWrite: Expr<boolean, Rec<"old" | "merged", Out | Replace<Out, P>>> | null) => RawStages<O, Out, Out | Replace<Out, P>, RORec<"new", Replace<P, RORec<K, Timestamp>>>>;
24
- export declare const getWhenMatched: <Out extends Model, P extends Model>(whenNotMatched: "discard" | "fail" | "insert", canWrite: Expr<boolean, Rec<"old" | "merged", Out | Replace<Out, P>>> | null) => RawStages<O, Rec<"old" | "merged", Out | Replace<Out, P>>, Out | Replace<Out, P>>;
22
+ export declare const getSubsetMatchForExt: <Out extends Model, P extends O & ID & TS, E extends Record<keyof E, rawItem>>(ext: Exact<E, IdHKT>) => null | Expr<boolean, Rec<'old' | 'merged', Out | Replace<Out, P>>>;
23
+ export declare const getWhenMatchedForMerge: <Out extends Model, P extends O & ID & TS, K extends keyof IsDeleted>(whenNotMatched: 'discard' | 'fail' | 'insert', update: Update<Replace<P, RORec<K, Timestamp>>, Out>, canWrite: Expr<boolean, Rec<'old' | 'merged', Out | Replace<Out, P>>> | null) => RawStages<O, Out, Out | Replace<Out, P>, RORec<'new', Replace<P, RORec<K, Timestamp>>>>;
24
+ export declare const getWhenMatched: <Out extends Model, P extends O & ID & TS>(whenNotMatched: 'discard' | 'fail' | 'insert', canWrite: Expr<boolean, Rec<'old' | 'merged', Out | Replace<Out, P>>> | null) => RawStages<O, Rec<'old' | 'merged', Out | Replace<Out, P>>, Out | Replace<Out, P>>;
25
25
  type MergeCollection<V extends O, Out extends Model> = {
26
26
  coll: RWCollection<Out | Replace<Out, Patch<V>> | Replace<Patch<V>, IsDeleted>, Out>;
27
27
  whenNotMatched: 'discard';
@@ -30,9 +30,9 @@ type MergeCollection<V extends O, Out extends Model> = {
30
30
  whenNotMatched: 'fail';
31
31
  };
32
32
  type MergeUpdate<V, Out> = UpdateF<((OPick<V, Allowed<StrKey<V>>> & ID) | (Rec<Allowed<StrKey<V>>, N> & ID)) & TS, Out>;
33
- 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>, update?: MergeUpdate<V, Out>) => StreamRunnerParam<OutInputE<SourcePart, E>, "out">;
34
- 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>, update?: MergeUpdate<V, Out>) => StreamRunnerParam<Source, "out">;
35
- 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", update?: MergeUpdate<V, Out>) => StreamRunnerParam<Source, "out">;
36
- 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>, update?: MergeUpdate<V, Out>) => StreamRunnerParam<Delta<SourcePart>, "out">;
37
- 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>, update?: MergeUpdate<V, Out>) => StreamRunnerParam<Delta<SourcePart>, "out">;
33
+ export declare const $mergeId: <V extends O>() => <SourcePart extends doc, Out extends Model, E = unknown, EEE extends { [K in keyof EEE]: 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>, update?: MergeUpdate<V, Out>) => StreamRunnerParam<OutInputE<SourcePart, E>, 'out'>;
34
+ export declare const $simpleMergePart: <V extends O>() => <Source extends doc, Out extends Model, EEE extends { [K in StrKey<EEE>]: rawItem; }>(out: MergeCollection<V, Out>, keys: ExprsExact<TakeDoc<V, unknown>, Source>, ext: Exact<Omit<SafeE<EEE>, keyof (ND & TS)>, IdHKT>, update?: MergeUpdate<V, Out>) => StreamRunnerParam<Source, 'out'>;
35
+ 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', update?: MergeUpdate<V, Out>) => StreamRunnerParam<Source, 'out'>;
36
+ export declare const $mergePart: <V extends O>() => <Out extends Model, SourcePart extends doc, EEE extends { [K in keyof EEE]: rawItem; }>(out: RWCollection<Out | Replace<Out, Patch<V>>, Out>, keys: ExprsExact<TakeDoc<V, unknown>, SourcePart>, ext: Exact<Omit<SafeE<EEE>, keyof (ND & TS)>, IdHKT>, update?: MergeUpdate<V, Out>) => StreamRunnerParam<Delta<SourcePart>, 'out'>;
37
+ 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>, update?: MergeUpdate<V, Out>) => StreamRunnerParam<Delta<SourcePart>, 'out'>;
38
38
  export {};
@@ -1,5 +1,5 @@
1
- import type { IdHKT, Replace, RWCollection } from '../../types';
2
- import type { ID, O, RORec, doc, rawItem } from '../../types/json';
1
+ import type { IdHKT, Omit, Replace, RWCollection } from '../../types';
2
+ import type { ID, O, StrKey, doc, rawItem } from '../../types/json';
3
3
  import { type ExprsExact } from '../expression/concat';
4
4
  import type { Del, Delta, Expr, StreamRunnerParam, TS } from '../types';
5
5
  import { type Exact } from '../utils/map-object';
@@ -12,8 +12,8 @@ type ExprP<P> = Expr<P, unknown, {
12
12
  new: P;
13
13
  }>;
14
14
  type Update<P, Out> = (added: ExprP<P>, old: Expr<Out, Out>) => ExprP<P>;
15
- 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>, update?: Update<Replace<Merge<T, EEE>, {}>, Merge<T, EEE>>) => StreamRunnerParam<D, "out">;
16
- export declare const $simpleInsert: <T extends doc, EEE extends RORec<string, rawItem>>(out: RWCollection<Merge<T, EEE>>, ext: Exact<Omit<SafeE<EEE>, keyof (ND & TS)>, IdHKT>) => StreamRunnerParam<T, "out">;
17
- 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">;
18
- export declare const $insert: <T extends doc>(out: RWCollection<Merge<T, {}>>) => StreamRunnerParam<Delta<T>, "out">;
15
+ export declare const $insertX: <T extends doc, D extends O, EEE extends { [K in StrKey<EEE>]: 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>, update?: Update<Replace<Merge<T, EEE>, {}>, Merge<T, EEE>>) => StreamRunnerParam<D, 'out'>;
16
+ export declare const $simpleInsert: <T extends doc, EEE extends { [K in StrKey<EEE>]: rawItem; }>(out: RWCollection<Merge<T, EEE>>, ext: Exact<Omit<SafeE<EEE>, keyof (ND & TS)>, IdHKT>) => StreamRunnerParam<T, 'out'>;
17
+ export declare const $insertPart: <T extends doc, EEE extends { [K in StrKey<EEE>]: rawItem; }>(out: RWCollection<Merge<T, EEE>>, ext: Exact<Omit<SafeE<EEE>, keyof (ND & TS)>, IdHKT>) => StreamRunnerParam<Delta<T>, 'out'>;
18
+ export declare const $insert: <T extends doc>(out: RWCollection<Merge<T, {}>>) => StreamRunnerParam<Delta<T>, 'out'>;
19
19
  export {};
@@ -1,18 +1,17 @@
1
- import type { RWCollection, WriteonlyCollection } from '../../../types';
1
+ import type { Exclude, Omit } from '../../../types';
2
2
  import type { AsLiteral, ID, O, Rec, doc, notArr } from '../../../types/json';
3
3
  import { type ExprsExact } from '../../expression/concat';
4
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 MergedInput, type Strict, type V_Grp } from './utils/sub-merge';
5
+ import { type Extra, type IdAndTsKeys, type Loose, type SubMergeOut, type V_Grp } from './utils/sub-merge';
7
6
  type Denied<GID = never> = keyof (TS & ID) | GID;
8
7
  type GI<GG> = Exclude<GG, keyof TS>;
9
- export type GroupMergeOut<Grp extends notArr, V extends O, GG extends string, EE = {}, Out extends Loose<Grp, V, GG> = Loose<Grp, V, GG>> = MergeInto<Strict<Grp, V, GG, EE>, Out, WriteonlyCollection<MergedInput<Out, V, Grp, GG, EE>>>;
10
- export type GroupMergeCollection<WhenNotMatched extends MergeInto<never, never>['whenNotMatched'], Grp extends notArr, V extends O, GG extends string, EE = {}, Out extends Loose<Grp, V, GG> = Loose<Grp, V, GG>> = (GroupMergeOut<Grp, V, GG, EE, Out> & {
8
+ export type GroupMergeOut<Grp extends notArr, V extends O, GG extends string, EE = {}, Out extends Loose<Grp, V, GG> = Loose<Grp, V, GG>> = SubMergeOut<Grp, V, GG, EE, Out>;
9
+ export type GroupMergeCollection<WhenNotMatched extends GroupMergeOut<never, never, never>['whenNotMatched'], Grp extends notArr, V extends O, GG extends string, EE = {}, Out extends Loose<Grp, V, GG> = Loose<Grp, V, GG>> = (GroupMergeOut<Grp, V, GG, EE, Out> & {
11
10
  whenNotMatched: WhenNotMatched;
12
11
  })['into'];
13
- 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: GroupMergeOut<Grp, V, GG, EE, Out>, gid: AsLiteral<GI<GG>>, extra: ExprsExact<Extra<EE, V, GG>, V_Grp<V, GG, Grp>>, idPrefix?: string) => StreamRunnerParam<Delta<T>, "out">;
14
- export type GroupIdCollection<V extends O, EE = {}, Out extends Loose<string, V, '_id'> = Loose<string, V, '_id'>> = RWCollection<MergedInput<Out, V, string, '_id', EE>, Out>;
15
- 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: GroupIdCollection<V, EE, Out>, extra: ExprsExact<Omit<EE, IdAndTsKeys | keyof Omit<V, IdAndTsKeys>>, doc & Omit<V, IdAndTsKeys>>) => StreamRunnerParam<Delta<T>, "out">;
16
- export type GroupCollection<Grp extends notArr, V extends O, EE = {}, Out extends Loose<Grp, V, '_grp'> = Loose<Grp, V, '_grp'>> = RWCollection<MergedInput<Out, V, Grp, '_grp', EE> | Strict<Grp, V, '_grp', EE>, Out>;
17
- 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: GroupCollection<Grp, V, 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 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: GroupMergeOut<Grp, V, GG, EE, Out>, gid: AsLiteral<GI<GG>>, extra: ExprsExact<Extra<EE, V, GG>, V_Grp<V, GG, Grp>>, idPrefix?: string) => StreamRunnerParam<Delta<T>, 'out'>;
13
+ export type GroupIdCollection<V extends O, EE = {}, Out extends Loose<string, V, '_id'> = Loose<string, V, '_id'>> = GroupMergeCollection<'fail', string, V, '_id', EE, Out>;
14
+ 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: GroupIdCollection<V, EE, Out>, extra: ExprsExact<Omit<EE, IdAndTsKeys | keyof Omit<V, IdAndTsKeys>>, doc & Omit<V, IdAndTsKeys>>) => StreamRunnerParam<Delta<T>, 'out'>;
15
+ export type GroupCollection<Grp extends notArr, V extends O, EE = {}, Out extends Loose<Grp, V, '_grp'> = Loose<Grp, V, '_grp'>> = GroupMergeCollection<'insert', Grp, V, '_grp', EE, Out>;
16
+ 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: GroupCollection<Grp, V, 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'>;
18
17
  export {};
@@ -3,4 +3,4 @@ import { type ExprsExact } from '../../../expression/concat';
3
3
  import type { Delta, Expr, RawStages } from '../../../types';
4
4
  import type { DeltaAccumulators } from '../../../types/accumulator';
5
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>;
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,8 +1,7 @@
1
- import type { AsLiteral, ID, O, Rec, Replace, WriteonlyCollection, notArr } from '../../../../types';
1
+ import type { AsLiteral, ID, O, RWCollection, Rec, Replace, notArr, Omit, Exclude } from '../../../../types';
2
2
  import { type ExprsExact } from '../../../expression/concat';
3
- import type { Model, RawStages, TS } from '../../../types';
3
+ import type { DeletedAt, IsDeleted, Model, RawStages, TS } from '../../../types';
4
4
  import type { DeltaAccumulators } from '../../../types/accumulator';
5
- import { type MergeInto } from '../../out';
6
5
  type GI<GG> = Exclude<GG, keyof TS>;
7
6
  export type IdAndTsKeys = keyof (TS & ID);
8
7
  type V<VV, GG extends string> = Omit<VV, IdAndTsKeys | GI<GG>>;
@@ -10,11 +9,35 @@ export type Prepare<Grp, GG extends string> = TS & ID & Rec<GI<GG>, Grp>;
10
9
  type Par<T> = {
11
10
  [P in keyof T]?: T[P] | null;
12
11
  };
13
- export type Loose<Grp, VV, GG extends string> = Prepare<Grp, GG> & Par<V<VV, GG>>;
12
+ export type Loose<Grp, VV, GG extends string> = Prepare<Grp, GG> & Par<V<VV, GG>> & DeletedAt;
14
13
  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
14
  export type V_Grp<VV, GG extends string, Grp> = Rec<GI<GG>, Grp> & V<VV, GG>;
16
15
  export type Extra<EE, VV, GG extends string> = Omit<EE, IdAndTsKeys | GI<GG> | keyof V<VV, GG>>;
17
16
  type OrReplace<T, V> = T | Replace<T, V>;
17
+ type ND = {
18
+ readonly deletedAt?: null;
19
+ };
20
+ type StrictReady<Grp extends notArr, VV extends O, GG extends string, EE> = TS & ID & V_Grp<VV, GG, Grp> & Extra<EE, VV, GG>;
21
+ type InsertReady<Grp extends notArr, VV extends O, GG extends string, EE> = Replace<StrictReady<Grp, VV, GG, EE>, ND>;
22
+ type DiscardReady<Grp extends notArr, VV extends O, GG extends string, EE> = Replace<StrictReady<Grp, VV, GG, EE>, IsDeleted>;
23
+ type MatchedReady<Out, VV extends O, GG extends string, EE> = Replace<Out, Replace<V<VV, GG>, Extra<EE, VV, GG>> & Model>;
24
+ type MatchedIn<Out, VV extends O, GG extends string, EE> = Out | MatchedReady<Out, VV, GG, EE>;
18
25
  export type MergedInput<Out, VV, Grp, GG extends string, EE> = OrReplace<Replace<Replace<Out, V<VV, GG>>, Extra<EE, VV, GG>> & Model, TS & ID & V_Grp<VV, GG, Grp> & Extra<EE, VV, GG>>;
19
- 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<MergedInput<Out, VV, Grp, 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">;
26
+ type SubMergeInInsert<Out, VV extends O, Grp extends notArr, GG extends string, EE> = MatchedIn<Out, VV, GG, EE> | InsertReady<Grp, VV, GG, EE>;
27
+ type SubMergeInDiscard<Out, VV extends O, Grp extends notArr, GG extends string, EE> = MatchedIn<Out, VV, GG, EE> | DiscardReady<Grp, VV, GG, EE>;
28
+ export type SubMergeInFail<Out, VV extends O, Grp extends notArr, GG extends string, EE> = OrReplace<MatchedReady<Out, VV, GG, EE>, StrictReady<Grp, VV, GG, EE>>;
29
+ type SubMergeIntoFail<Grp extends notArr, VV extends O, GG extends string, EE, Out extends Loose<Grp, VV, GG>> = RWCollection<MatchedIn<Out, VV, GG, EE>, Out>;
30
+ type SubMergeIntoInsert<Grp extends notArr, VV extends O, GG extends string, EE, Out extends Loose<Grp, VV, GG>> = RWCollection<SubMergeInInsert<Out, VV, Grp, GG, EE>, Out>;
31
+ type SubMergeIntoDiscard<Grp extends notArr, VV extends O, GG extends string, EE, Out extends Loose<Grp, VV, GG>> = RWCollection<SubMergeInDiscard<Out, VV, Grp, GG, EE>, Out>;
32
+ export type SubMergeOut<Grp extends notArr, VV extends O, GG extends string, EE = {}, Out extends Loose<Grp, VV, GG> = Loose<Grp, VV, GG>> = {
33
+ whenNotMatched: 'insert';
34
+ into: SubMergeIntoInsert<Grp, VV, GG, EE, Out>;
35
+ } | {
36
+ whenNotMatched: 'discard';
37
+ into: SubMergeIntoDiscard<Grp, VV, GG, EE, Out>;
38
+ } | {
39
+ whenNotMatched: 'fail';
40
+ into: SubMergeIntoFail<Grp, VV, GG, EE, Out>;
41
+ };
42
+ 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: SubMergeOut<Grp, VV, GG, EE, Out>, 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'>;
20
43
  export {};
@@ -1,10 +1,10 @@
1
- import type { Arr, AsLiteral, ID, N, O, Rec, doc, rawItem } from '../../../types';
1
+ import type { Arr, AsLiteral, Exclude, ID, N, O, Rec, doc, notArr } from '../../../types';
2
2
  import { Field } from '../../field';
3
3
  import type { BA, Before, Delta, RawStages, TStages, UBefore } from '../../types';
4
4
  import { type JoinId } from '../unwind';
5
5
  type s = string;
6
6
  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>;
7
- 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
+ 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 notArr, K1 extends s, KK2 extends s, N1 extends null = never, N2 extends null = never>({ field1, field2 }: {
8
8
  field1: Field<LQ, S | N | Arr<S>>;
9
9
  field2: Field<RQ, S | N | Arr<S>>;
10
10
  }, { coll, exec, input }: TStages<RS, UBefore<RQ>, BRB, Before<RE>>, k1: AsLiteral<K1>, k2: AsLiteral<Exclude<KK2, BA | K1>>, k: JoinId<K1, Exclude<KK2, BA | K1>>, includeNull1?: N1, includeNull2?: N2) => RawStages<unknown, Delta<LE>, Both<K1, LE, KK2, RE, N1, N2>>;
@@ -1,10 +1,10 @@
1
- import type { App, Arr, AsLiteral, HKT, ID, O, Rec, rawItem } from '../../../types';
1
+ import type { App, Arr, AsLiteral, HKT, ID, O, Rec, notArr } from '../../../types';
2
2
  import { type Field } from '../../field';
3
3
  import type { Before, RawStages, TStages, UBefore } from '../../types';
4
4
  import { type JoinId } from '../unwind';
5
5
  type s = string;
6
- export declare const $lookupRaw: <LQ extends O, LE extends LQ & ID, RQ extends O, RE extends RQ & ID, BRB extends Before<RQ>, RS extends UBefore<RQ>, S extends rawItem, As extends s, Null extends null = never>({ field1, field2 }: {
6
+ export declare const $lookupRaw: <LQ extends O, LE extends LQ & ID, RQ extends O, RE extends RQ & ID, BRB extends Before<RQ>, RS extends UBefore<RQ>, S extends notArr, As extends s, Null extends null = never>({ field1, field2 }: {
7
7
  field1: Field<LQ, S | Arr<S>>;
8
8
  field2: Field<RQ, S | Arr<S>>;
9
- }, { coll, exec, input }: TStages<RS, Before<RQ>, BRB, Before<RE>>, k2: AsLiteral<As>, k: JoinId<"left", "right">, 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 | Null> & ID>>;
9
+ }, { coll, exec, input }: TStages<RS, Before<RQ>, BRB, Before<RE>>, k2: AsLiteral<As>, k: JoinId<'left', 'right'>, 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 | Null> & ID>>;
10
10
  export {};
@@ -1,13 +1,14 @@
1
1
  import type { Arr, O, Rec } from '../../types';
2
2
  import type { Accumulators, Expr, LookupArgs, Query, RawStages } from '../types';
3
3
  import type { Updater } from '../update/updater';
4
+ import { $project1 } from './raws';
4
5
  export * from './raws';
5
6
  type s = string;
6
7
  export declare const $match_: <T extends O, C = unknown>(query?: Query<T, C>) => RawStages<O<T>, T, T, C>;
7
8
  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
9
  export declare const $replaceWith_: <T extends O, V extends O, C = unknown>(expr: Expr<V, T, C>) => RawStages<O, T, V, C, 1>;
9
10
  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 $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
12
  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 $project_: typeof $project1;
13
14
  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,11 +1,11 @@
1
- import type { App, HKT, O2, O3, O, RawObj } from '../../types';
1
+ import type { App, HKT, O2, O3, O } from '../../types';
2
2
  import type { Delta, DeltaStages, FRawStages, RawStages, Stream, TStages } from '../types';
3
3
  import type { Equal } from '../utils/guard';
4
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>;
5
+ export declare const asStages: <Q, T extends Q, V extends Q, C = unknown, M extends n = n>(x: RawStages<Q, T, V, C, M>) => 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 = n>(_: 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 = n>(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 = n>(part1: FRawStages<Q, T, V, C, M>, part2: FRawStages<Q, V, W, C, M>) => FRawStages<Q, T, W, C, M>;
9
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
10
  export type Concat<out Q, in T extends Q, out V extends Q, in out C, in out M extends n = n> = {
11
11
  with: <Q2, W extends Q2>(extra: RawStages<Q | Q2, V, W, C, M>) => Concat<Q | Q2, T, W, C, M>;
@@ -20,7 +20,7 @@ export type DeltaPipe<Q extends O, T extends Q, F extends HKT<O2>, G extends HKT
20
20
  then: <Q2 extends O, V extends Q2>(next: App<G, [Q2 | T, T, V]>) => DeltaPipe<Q | Q2, V, F, G>;
21
21
  get: () => App<F, [Q, T]>;
22
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>;
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_1 extends Q>() => App<G, [Q, T_1, T_1]>) => DeltaPipe<Q, T, F, G>;
24
24
  type Link = <T, C = unknown, M extends n = n>() => Concat<T, T, T, C, M>;
25
25
  type FLink = <T extends O, C = unknown, M extends n = n>() => FConcat<T, T, T, C, M>;
26
26
  export declare const link: Link;
@@ -10,7 +10,7 @@ export declare const $set1: <Q, T extends Q & O, V extends Q & O, C = unknown>(u
10
10
  export declare const $project1: <T extends O, K extends StrKey<T>>(projection: ExactKeys<K>) => RawStages<T, T, T, unknown, 1>;
11
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
12
  export declare const $unwind1: <T extends O, K extends s, R, Null extends null = never>(k: K, includeNull?: Null) => FRawStages<T, T & Rec<K, Arr<R>>, T & Rec<K, R | Null>>;
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>;
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
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
15
  export declare const rawVars: <T, Ctx, C, V extends O>(vars: ExprsExact<Ctx, T, C>, f: Field<V, T, unknown>) => import("../utils").ExactPart1<Ctx, ConstHKT<rawItem, unknown>>;
16
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>;
@@ -1,13 +1,13 @@
1
- import type { ConstHKT, HKT, I, N, O, RORec, Rec, jsonItem } from '../../../types';
1
+ import type { ConstHKT, HKT, I, N, O, Omit, RORec, Rec, jsonItem } from '../../../types';
2
2
  import type { BA, Delta, Expr, FRawStages, RawStages } from '../../types';
3
3
  import { type Updater } from '../../update/updater';
4
- import { type MapK } from '../../utils/map-object';
4
+ import { type MapOPart } from '../../utils/map-object';
5
5
  export interface ParDeltaHKT<K extends BA, T extends jsonItem, E> extends HKT<jsonItem> {
6
6
  readonly out: RORec<K, I<jsonItem, this>> & Delta<T> & E;
7
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, Delta<T> & E, Delta<T> & Rec<BA2, V | null> & Omit<E, BA2>, C, 1>;
8
+ type Delta2<T extends jsonItem, BA2 extends string> = Delta<T> & 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> & RORec<BA2, T | null> & E, T | N, V | null, C>, dict: MapOPart<RORec<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: MapOPart<RORec<BA2>, ConstHKT<BA>>) => RawStages<unknown, Delta<T> & E, Delta<T> & Rec<BA2, V | null> & Omit<E, BA2>, C, 1>;
11
11
  export declare const $replaceWithEach1: <T extends O, V extends jsonItem, E = unknown>(t: <K extends BA>(field: K) => Expr<V | null, Delta<T> & E>) => RawStages<unknown, Delta<T> & E, Delta<V> & Omit<E, BA>>;
12
12
  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>>;
13
13
  export {};
@@ -1,4 +1,4 @@
1
- import type { O, ReplaceQ, StrKey } from '../../../types';
1
+ import type { Exclude, O, Omit, ReplaceQ, StrKey } from '../../../types';
2
2
  import type { DeltaStages, Expr, LinStages } from '../../types';
3
3
  import { type UpdaterQHKT } from '../../update/updater';
4
4
  import type { MapO } from '../../utils/map-object';
@@ -1,4 +1,4 @@
1
- import type { Arr, AsLiteral, doc, ID, Rec } from '../../../types';
1
+ import type { Arr, AsLiteral, doc, Exclude, ID, Rec } from '../../../types';
2
2
  import type { BA, Delta, Expr, RawStages } from '../../types';
3
3
  type s = string;
4
4
  export type JoinId<K1 extends s, K2 extends s> = K1 | K2 | readonly [K1, middle: s, K2] | readonly [K2, middle: s, K1];
@@ -1,6 +1,6 @@
1
- import type { Arr, AsLiteral, doc, O, Rec, RORec } from '../../../types';
1
+ import type { Arr, AsLiteral, doc, O, Omit, Rec, RORec } from '../../../types';
2
2
  import type { DeltaStages } from '../../types';
3
3
  export { $unwindDelta, joinIdOf, type JoinId } from './$unwind-delta';
4
4
  type s = string;
5
5
  type TOf<TT, K extends string> = doc & Omit<TT, K>;
6
- export declare const $unwind: <TT extends O, K extends s, U extends doc>(k: AsLiteral<K>, dict: RORec<K, "key"> & RORec<"_id", "id">, middle?: string) => DeltaStages<O, TOf<TT, K> & Rec<K, Arr<U>>, TOf<TT, K> & Rec<K, U>>;
6
+ export declare const $unwind: <TT extends O, K extends s, U extends doc>(k: AsLiteral<K>, dict: RORec<K, 'key'> & RORec<'_id', 'id'>, middle?: string) => DeltaStages<O, TOf<TT, K> & Rec<K, Arr<U>>, TOf<TT, K> & Rec<K, U>>;
@@ -1,4 +1,4 @@
1
- import type { O2, O3, OPickD, RORec, StrKey, View } from '../../types';
1
+ import type { Exclude, O2, O3, OPickD, RORec, StrKey, View } from '../../types';
2
2
  import type { HKT, I } from '../../types/hkt';
3
3
  import type { RawStages } from '../types';
4
4
  import type { Model, SimpleStreamExecutionResult } from '../types/stream';
@@ -1,5 +1,4 @@
1
- import { Collection, type Timestamp } from 'mongodb';
2
- import type { BSON, OPickD, rawItem, RawObj, StrKey } from '../../types';
1
+ import type { Collection, Document, Exclude, OPickD, rawItem, RawObj, StrKey, Timestamp } from '../../types';
3
2
  import type { Actions, Model } from '../types/stream';
4
3
  export type AllowedPick<V extends Model, K extends StrKey<V>> = OPickD<V, Allowed<K>>;
5
4
  export type Allowed<K> = Exclude<K, 'deletedAt' | '_id'>;
@@ -23,5 +22,5 @@ export type Last = {
23
22
  job?: 1 | null;
24
23
  };
25
24
  export declare const actions: {
26
- [K in keyof Actions<unknown>]: <W extends BSON.Document>(col: Collection<W>, x: Actions<W>[K]) => [Promise<unknown>, unknown[]];
25
+ [K in keyof Actions<unknown>]: <W extends Document>(col: Collection<W>, x: Actions<W>[K]) => [Promise<unknown>, unknown[]];
27
26
  };
@@ -1,10 +1,10 @@
1
- import type { O2, O3, StrKey, View } from '../../types';
1
+ import type { Dict, O2, O3, StrKey, View } from '../../types';
2
2
  import type { HKT, I } from '../../types/hkt';
3
3
  import { type DeltaPipe } from '../aggregate/prefix';
4
4
  import type { SnapshotStreamExecutionResult } from '../types';
5
5
  import type { DeltaStages, Model } from '../types/stream';
6
6
  import type { Allowed, AllowedPick } from './boot-utils';
7
- export declare const streamNames: Record<string, string>;
7
+ export declare const streamNames: Dict<string>;
8
8
  export interface SnapshotStreamHKT extends HKT<O2> {
9
9
  readonly out: SnapshotStreamExecutionResult<I<O2, this>[0], I<O2, this>[1]>;
10
10
  }
@@ -1,5 +1,4 @@
1
- import { Timestamp } from 'mongodb';
2
- import type { O, StrKey, View } from '../../types';
1
+ import type { O, StrKey, Timestamp, View } from '../../types';
3
2
  import { type Concat } from '../aggregate/prefix';
4
3
  import type { Query } from '../types';
5
4
  import type { Del, Model } from '../types/stream';
@@ -0,0 +1,5 @@
1
+ import type { Driver } from '../types';
2
+ export type { Driver } from '../types';
3
+ export declare const useDriver: (driver: Driver) => void;
4
+ export declare const driver: () => Driver;
5
+ export declare const uuid: () => string;
@@ -1,4 +1,4 @@
1
- import type { App, HKT, I, IdHKT, N, O, RORec, StrKey } from '../../types';
1
+ import type { App, HKT, I, IdHKT, N, O, Omit, RORec, StrKey } from '../../types';
2
2
  import type { Expr } from '../types';
3
3
  import { type Exact, type ExactPart, type MapO, type MergeHKT } from '../utils/map-object';
4
4
  export declare const concat: {
@@ -18,10 +18,10 @@ type MergeExactArgs<T1, T2, F extends HKT<T1[StrKey<T1>] | T2[StrKey<T2>]>> = re
18
18
  Exact<Omit<T1, keyof T2>, F>,
19
19
  Exact<T2, F>
20
20
  ];
21
- export declare const mergeExact: <T1, T2, F extends HKT<T1[StrKey<T1>] | T2[StrKey<T2>]>, EK extends symbol = never, EE = unknown>(exprsExact1: Exact<Omit<T1, keyof T2>, F>, exprsExact2: Exact<T2, F>) => Exact<T2 & Omit<T1, keyof T2> & Record<EK, EE>, F>;
21
+ export declare const mergeExact: <T1, T2, F extends HKT<T1[StrKey<T1>] | T2[StrKey<T2>]>, EK extends symbol = never, EE = unknown>(...[exprsExact1, exprsExact2]: MergeExactArgs<T1, T2, F>) => Exact<T2 & Omit<T1, keyof T2> & Record<EK, EE>, F>;
22
22
  export type MergeMapOArgs<T1, T2, F1 extends HKT<StrKey<Omit<T1, StrKey<T2>>>>, F2 extends HKT<StrKey<T2>>> = readonly [MapO<Omit<T1, StrKey<T2>>, F1>, MapO<T2, F2>];
23
- export declare const mergeExact0: <T1, T2, F1 extends HKT<StrKey<Omit<T1, StrKey<T2>>>>, F2 extends HKT<StrKey<T2>>, E = unknown>(exprsExact1: MapO<Omit<T1, StrKey<T2>>, F1>, exprsExact2: MapO<T2, F2>) => MapO<T2 & Omit<T1, StrKey<T2>> & Pick<E, symbol & keyof E>, MergeHKT<T1, T2, F1, F2, StrKey<T2>>>;
24
- export declare const mergeExpr: <T1, T2, D, C = unknown, EK extends symbol = never, EE = unknown>(exprs_0: Exact<Omit<T1, keyof T2>, ExprHKT<D, C, IdHKT<unknown>>>, exprs_1: Exact<T2, ExprHKT<D, C, IdHKT<unknown>>>) => ExprsExact<T2 & Omit<T1, keyof T2> & Record<EK, EE>, D, C>;
23
+ export declare const mergeExact0: <T1, T2, F1 extends HKT<StrKey<Omit<T1, StrKey<T2>>>>, F2 extends HKT<StrKey<T2>>, E = unknown>(...[exprsExact1, exprsExact2]: MergeMapOArgs<T1, T2, F1, F2>) => MapO<T2 & Omit<T1, StrKey<T2>> & Pick<E, symbol & keyof E>, MergeHKT<T1, T2, F1, F2, StrKey<T2>>>;
24
+ export declare const mergeExpr: <T1, T2, D, C = unknown, EK extends symbol = never, EE = unknown>(...exprs: MergeExactArgs<T1, T2, ExprHKT<D, C>>) => ExprsExact<T2 & Omit<T1, keyof T2> & Record<EK, EE>, D, C>;
25
25
  export type ExprsPart<T, D, C> = ExactPart<T, ExprHKT<D, C>>;
26
26
  export interface ExprHKT<D, C = unknown, F extends HKT = IdHKT> extends HKT<unknown> {
27
27
  readonly out: Expr<App<F, I<unknown, this>>, D, C>;
@@ -5,15 +5,15 @@ export declare const now: <D, C>() => Expr<Date, D, C>;
5
5
  export declare const monthPart: <D, C>(date: Expr<Date, D, C>) => Expr<string, D, C>;
6
6
  export declare const weekPart: <D, C>(date: Expr<Date, D, C>) => Expr<string, D, C>;
7
7
  export declare const year: <D, C>(date: Expr<Date, D, C>) => Expr<number, D, C>;
8
- export declare const dateAdd: <D, C>(date: Expr<Date, D, C>, amount: Expr<number, D, C>, unit: Expr<"year" | "week" | "month" | "day" | "hour" | "minute" | "second", D, C>) => Expr<Date, D, C>;
8
+ export declare const dateAdd: <D, C>(date: Expr<Date, D, C>, amount: Expr<number, D, C>, unit: Expr<'year' | 'week' | 'month' | 'day' | 'hour' | 'minute' | 'second', D, C>) => Expr<Date, D, C>;
9
9
  export declare const maxDate: <D, C>(expr: Expr<Arr<Date>, D, C>) => Expr<Date, D, C>;
10
10
  export declare const minDate: <D, C>(expr: Expr<Arr<Date>, D, C>) => Expr<Date, D, C>;
11
11
  export declare const datePart: <D, C>(date: Expr<Date, D, C>) => Expr<string, D, C>;
12
- export declare const startOf: <D, C>(startDate: Expr<Date, D, C>, freq: Expr<"week" | "day" | "month" | "year", D, C>, offset: Expr<number, D, C>) => Expr<Date, D, C>;
12
+ export declare const startOf: <D, C>(startDate: Expr<Date, D, C>, freq: Expr<'week' | 'day' | 'month' | 'year', D, C>, offset: Expr<number, D, C>) => Expr<Date, D, C>;
13
13
  export declare const dateDiff: <D, C>({ end, unit, start, }: {
14
14
  start: Expr<Date, D, C>;
15
15
  end: Expr<Date, D, C>;
16
- unit: Expr<"week" | "day" | "month" | "year", D, C>;
16
+ unit: Expr<'week' | 'day' | 'month' | 'year', D, C>;
17
17
  }) => Expr<number, D, C>;
18
18
  export declare const mapFromPlainDateTime: <D, C>({ plainDate, timezone, }: {
19
19
  plainDate: Expr<Date, D, C>;
@@ -1,5 +1,5 @@
1
1
  import type { rawItem } from '../../types';
2
2
  import type { BoolExpr, Expr, ExprRaw } from '../types';
3
3
  export declare const asExprRaw: <T, Doc, Ctx>(raw: rawItem) => ExprRaw<T, Doc, Ctx>;
4
- export declare const asExpr: <T, Doc, Ctx = unknown>(r: Pick<Expr<T, Doc, Ctx>, "raw">) => Expr<T, Doc, Ctx>;
5
- export declare const asBoolExpr: <D1, D2, Ctx = unknown>(r: Pick<BoolExpr<D1, D2, Ctx>, "raw">) => BoolExpr<D1, D2, Ctx>;
4
+ export declare const asExpr: <T, Doc, Ctx = unknown>(r: Pick<Expr<T, Doc, Ctx>, 'raw'>) => Expr<T, Doc, Ctx>;
5
+ export declare const asBoolExpr: <D1, D2, Ctx = unknown>(r: Pick<BoolExpr<D1, D2, Ctx>, 'raw'>) => BoolExpr<D1, D2, Ctx>;
@@ -10,7 +10,7 @@ export declare const or: <D, C = unknown>(...expr: Expr<boolean, D, C>[]) => Exp
10
10
  export declare const not: <D, C = unknown>(expr: Expr<boolean, D, C>) => Expr<boolean, D, C>;
11
11
  export declare const eq: <T, D, C = unknown>(a: Expr<T, D, C>) => (b: Expr<T, D, C>) => Expr<boolean, D, C>;
12
12
  export declare const sub: <T, D, Ctx, P extends O>(a: Expr<T, D, Ctx>, f: Field<P, D, Ctx>) => Expr<T, P, Ctx>;
13
- export declare const eqTyped: <T1 extends Dom, T2 extends Dom, F extends HKT<Dom>, C = unknown, Dom = unknown>(a: Expr<T1 | T2, App<F, T1 | T2>, C>, b: Expr<T1, App<F, T1 | T2>, C>) => BoolExpr<App<F, T1>, App<F, T2>, C>;
13
+ export declare const eqTyped: <T1 extends Dom, T2 extends Dom, F extends HKT<Dom>, C = unknown, Dom = jsonItem>(a: Expr<T1 | T2, App<F, T1 | T2>, C>, b: Expr<T1, App<F, T1 | T2>, C>) => BoolExpr<App<F, T1>, App<F, T2>, C>;
14
14
  export declare const ne: <T, D, C = unknown>(a: Expr<T, D, C>) => <K>(b: Expr<K, D, C>) => Expr<boolean, D, C>;
15
15
  export declare const notNull: <T, D, C>(a: Expr<T, D, C>) => Expr<boolean, D, C>;
16
16
  export declare const $ifNull: {
@@ -7,5 +7,5 @@ export declare const $map0: <K extends string, T, R, D, C>({ as, expr, input, }:
7
7
  as: K;
8
8
  expr: Expr<R, D, RORec<K, T> & C>;
9
9
  }) => Expr<Arr<R>, D, C>;
10
- export declare const $map1: <T, R, D, C>(ex: Expr<Arr<T>, D, C>, map: (i: Field<unknown, T, RORec<"item", T>>) => Expr<R, D, RORec<"item", T> & C>) => Expr<Arr<R>, D, C>;
11
- export declare const $map: <T, R, D, C = unknown>(ex: Expr<Arr<T>, D, C>, map: (i: Expr<T, D, RORec<"item", T>>) => Expr<R, D, RORec<"item", T> & C>) => Expr<Arr<R>, D, C>;
10
+ export declare const $map1: <T, R, D, C>(ex: Expr<Arr<T>, D, C>, map: (i: Field<unknown, T, RORec<'item', T>>) => Expr<R, D, RORec<'item', T> & C>) => Expr<Arr<R>, D, C>;
11
+ export declare const $map: <T, R, D, C = unknown>(ex: Expr<Arr<T>, D, C>, map: (i: Expr<T, D, RORec<'item', T>>) => Expr<R, D, RORec<'item', T> & C>) => Expr<Arr<R>, D, C>;
@@ -1,10 +1,10 @@
1
- import type { Timestamp } from 'mongodb';
2
- import type { Arr, N, O, RORec, StrKey, jsonItem, notObj, rawItem } from '../../types';
1
+ import type { Timestamp } from '../../types';
2
+ import type { Arr, N, O, StrKey, jsonItem, notObj, rawItem } from '../../types';
3
3
  import type { Expr } from '../types';
4
4
  import type { ExprsExact } from './concat';
5
5
  export declare const val: <T extends rawItem>(val: T) => Expr<T, unknown>;
6
6
  export declare const current: Expr<Timestamp, unknown>;
7
- export declare const $let: <T, D, C, V extends RORec<string, jsonItem>>(vars: ExprsExact<V, D, C>, inExpr: Expr<T, D, C & V>) => Expr<T, D, C>;
7
+ export declare const $let: <T, D, C, V extends object>(vars: ExprsExact<V, D, C>, inExpr: Expr<T, D, C & V>) => Expr<T, D, C>;
8
8
  export declare const nil: Expr<null, unknown>;
9
9
  export declare const $getField: {
10
10
  <T, K extends StrKey<T>, D, C = unknown>(expr: Expr<T, D, C>, field: K): Expr<T[K], D, C>;
@@ -22,4 +22,4 @@ export declare class Field<in R, out V, in C = unknown> {
22
22
  private exprRaw;
23
23
  expr<R, V, C = unknown>(this: Field<R, V, C>): Expr<V, R, C>;
24
24
  }
25
- export declare const root: <T extends O>() => Field<T, T, unknown>, ctx: <T>() => <K extends string>(k: K) => Field<unknown, T, RORec<K, T>>;
25
+ export declare const { root, ctx }: typeof Field;
@@ -1,9 +1,8 @@
1
- import type { Timestamp } from 'mongodb';
2
- import type { Arr, N, rawItem, RawObj } from '../../types';
1
+ import type { Arr, N, rawItem, RawObj, Timestamp } from '../../types';
3
2
  export declare const $eq: <T extends unknown>(operand: rawItem & T) => import("../types").Predicate<T>;
4
3
  export declare const $ne: <T extends unknown>(operand: rawItem & T) => import("../types").Predicate<T>;
5
4
  type Numeric = number | Timestamp | Date;
6
- export declare const comp: <D2 extends Numeric = Numeric>(op: "$lt" | "$gt" | "$lte" | "$gte") => <T extends Numeric>(operand: rawItem & D2) => import("../types").Predicate<D2>;
5
+ export declare const comp: <D2 extends Numeric = Numeric>(op: "$gt" | "$gte" | "$lt" | "$lte") => <T extends Numeric>(operand: rawItem & D2) => import("../types").Predicate<D2>;
7
6
  export declare const $gt: <T extends Numeric>(operand: rawItem & Numeric) => import("../types").Predicate<Numeric>;
8
7
  export declare const $gtTs: <T extends Numeric>(operand: rawItem & Timestamp) => import("../types").Predicate<Timestamp>;
9
8
  export declare const $gteTs: <T extends Numeric>(operand: rawItem & Timestamp) => import("../types").Predicate<Timestamp>;
@@ -19,6 +18,6 @@ type MongoTypes = {
19
18
  [i: number]: unknown;
20
19
  };
21
20
  export type MongoTypeNames = keyof MongoTypes;
22
- export declare const $type: <T extends keyof MongoTypes>(operand: rawItem & readonly T[]) => import("../types").Predicate<N | MongoTypes[T]>;
21
+ export declare const $type: <T extends keyof MongoTypes>(operand: rawItem & readonly T[]) => import("../types").Predicate<MongoTypes[T] | N>;
23
22
  export declare const $exists: <T extends keyof MongoTypes>(operand: rawItem & boolean) => import("../types").Predicate<unknown>;
24
23
  export {};
@@ -1,5 +1,5 @@
1
1
  import type { Expr } from './expr';
2
- import type { HKT, I, N, O, RORec, RawObj, Rec, Type, U, Undef, jsonItem } from '../../types';
2
+ import type { HKT, I, N, O, PRRec, RORec, RawObj, Rec, Type, U, Undef, jsonItem } from '../../types';
3
3
  import type { Field } from '../field';
4
4
  import type { Exact } from '../utils/map-object';
5
5
  declare const AccumulatorRaw: unique symbol;
@@ -10,12 +10,12 @@ export interface AccumulatorRaw<in Doc, out T, in C = unknown> extends RawObj {
10
10
  export interface AccumulatorHKT<T, C = unknown> extends HKT<unknown> {
11
11
  readonly out: Accumulator<T, I<unknown, this>, C>;
12
12
  }
13
- export type Accumulators<T, V extends RORec<string, jsonItem>, C = unknown> = Exact<V, AccumulatorHKT<T, C>>;
13
+ export type Accumulators<T, V extends object, C = unknown> = Exact<V, AccumulatorHKT<T, C>>;
14
14
  export interface DeltaAccumulatorHKT<T, C = unknown> extends HKT<unknown> {
15
15
  readonly out: DeltaAccumulator<T, I<unknown, this>, C>;
16
16
  }
17
- export type DeltaAccumulators<T, V extends RORec<string, jsonItem>, C = unknown> = Exact<V, DeltaAccumulatorHKT<T, C>>;
18
- export type AccumulatorsRoot<Acc extends Accumulators<never, RORec<string, jsonItem>, never>> = Acc extends Accumulators<infer T extends O, RORec<string, jsonItem>, never> ? T : never;
17
+ export type DeltaAccumulators<T, V extends object, C = unknown> = Exact<V, DeltaAccumulatorHKT<T, C>>;
18
+ export type AccumulatorsRoot<Acc extends Accumulators<never, PRRec<string, jsonItem>, never>> = Acc extends Accumulators<infer T extends O, PRRec<string, jsonItem>, never> ? T : never;
19
19
  export type Accumulator<in Doc, out T, in Ctx = unknown> = {
20
20
  [Type]?(_: typeof Accumulator): typeof Accumulator;
21
21
  raw: {
@@ -1,7 +1,9 @@
1
- import type { Long, Timestamp } from 'mongodb';
1
+ import type { Timestamp } from '../../types';
2
2
  export type AggregateCommand<T> = {
3
3
  cursor: {
4
- id: Long | number;
4
+ id: number | {
5
+ toString(): string;
6
+ };
5
7
  firstBatch: T[];
6
8
  atClusterTime: Timestamp;
7
9
  ns: string;
@@ -1,12 +1,8 @@
1
1
  import type { O, RawObj, Type } from '../../types';
2
2
  import type { Field } from '../field';
3
3
  declare const Query: unique symbol;
4
- declare const QueryRaw: unique symbol;
5
- export type QueryRaw<T, C = unknown> = RawObj & {
6
- [Type]?(x: typeof QueryRaw, y: T, c: C): void;
7
- };
8
4
  export type Query<in T extends O, in C = unknown> = {
9
5
  [Type]?(x: typeof Query, y: T, c: C): void;
10
- raw: <DeltaT extends O>(f: Field<DeltaT, T>) => QueryRaw<DeltaT, C>;
6
+ raw: <DeltaT extends O>(f: Field<DeltaT, T>) => RawObj;
11
7
  };
12
8
  export {};
@@ -1,5 +1,4 @@
1
- import type { BSON, Filter, Timestamp, UpdateFilter } from 'mongodb';
2
- import type { App, HKT, ID, N, O, RawObj, ReadonlyCollection, Rec, Type, WriteonlyCollection } from '../../types';
1
+ import type { App, Document, Timestamp, HKT, ID, N, O, RawObj, ReadonlyCollection, Rec, Type, WriteonlyCollection } from '../../types';
3
2
  import type { Field } from '../field';
4
3
  import type { HasJob, Runner } from './machine';
5
4
  declare const RawStage: unique symbol;
@@ -22,8 +21,8 @@ export type TStages<in out S, out Q, in out B extends Q, out R extends Q, M exte
22
21
  };
23
22
  export type Stages<out Q, out R extends Q, out SDom> = <E>(consume: <S extends SDom, B extends Q>(value: TStages<S, Q, B, R>) => E) => E;
24
23
  export type Actions<W> = {
25
- updateMany: [Filter<W>, UpdateFilter<W> | BSON.Document[]];
26
- deleteMany: [Filter<W>];
24
+ updateMany: [Document, Document | readonly Document[]];
25
+ deleteMany: [Document];
27
26
  };
28
27
  export type TeardownRecord<W, M extends keyof Actions<W>> = {
29
28
  collection: WriteonlyCollection<W>;
@@ -1,4 +1,4 @@
1
- import type { Arr, HKT, I, N, O, StrKey, Type, notArr, rawItem } from '../../types';
1
+ import type { Arr, Exclude, HKT, I, N, O, StrKey, Type, notArr, rawItem } from '../../types';
2
2
  import { Field } from '../field';
3
3
  import type { Expr } from '../types';
4
4
  import { type MapO } from '../utils/map-object';