@enspirit/bmg-js 1.0.1 → 1.1.0
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/LICENSE.md +21 -0
- package/README.md +3 -2
- package/dist/AsyncRelation/Base.d.ts +47 -0
- package/dist/AsyncRelation/index.d.ts +25 -0
- package/dist/{src/Relation → Relation}/Memory.d.ts +46 -46
- package/dist/Relation/index.d.ts +1 -0
- package/dist/async/Relation/Base.d.ts +47 -0
- package/dist/async/Relation/index.d.ts +25 -0
- package/dist/async/operators/_helpers.d.ts +16 -0
- package/dist/async/operators/autowrap.d.ts +7 -0
- package/dist/async/operators/constants.d.ts +6 -0
- package/dist/async/operators/cross_product.d.ts +9 -0
- package/dist/async/operators/extend.d.ts +7 -0
- package/dist/async/operators/group.d.ts +7 -0
- package/dist/async/operators/image.d.ts +8 -0
- package/dist/async/operators/index.d.ts +28 -0
- package/dist/async/operators/intersect.d.ts +7 -0
- package/dist/async/operators/isEqual.d.ts +7 -0
- package/dist/async/operators/join.d.ts +7 -0
- package/dist/async/operators/left_join.d.ts +8 -0
- package/dist/async/operators/matching.d.ts +7 -0
- package/dist/async/operators/minus.d.ts +7 -0
- package/dist/async/operators/not_matching.d.ts +7 -0
- package/dist/async/operators/one.d.ts +6 -0
- package/dist/async/operators/prefix.d.ts +6 -0
- package/dist/async/operators/project.d.ts +10 -0
- package/dist/async/operators/rename.d.ts +6 -0
- package/dist/async/operators/restrict.d.ts +14 -0
- package/dist/async/operators/suffix.d.ts +6 -0
- package/dist/async/operators/summarize.d.ts +8 -0
- package/dist/async/operators/toArray.d.ts +5 -0
- package/dist/async/operators/transform.d.ts +9 -0
- package/dist/async/operators/ungroup.d.ts +7 -0
- package/dist/async/operators/union.d.ts +6 -0
- package/dist/async/operators/unwrap.d.ts +6 -0
- package/dist/async/operators/wrap.d.ts +6 -0
- package/dist/async/operators/yByX.d.ts +7 -0
- package/dist/async/types.d.ts +58 -0
- package/dist/async-operators/_helpers.d.ts +16 -0
- package/dist/async-operators/autowrap.d.ts +7 -0
- package/dist/async-operators/constants.d.ts +6 -0
- package/dist/async-operators/cross_product.d.ts +9 -0
- package/dist/async-operators/extend.d.ts +7 -0
- package/dist/async-operators/group.d.ts +7 -0
- package/dist/async-operators/image.d.ts +8 -0
- package/dist/async-operators/index.d.ts +28 -0
- package/dist/async-operators/intersect.d.ts +7 -0
- package/dist/async-operators/isEqual.d.ts +7 -0
- package/dist/async-operators/join.d.ts +7 -0
- package/dist/async-operators/left_join.d.ts +8 -0
- package/dist/async-operators/matching.d.ts +7 -0
- package/dist/async-operators/minus.d.ts +7 -0
- package/dist/async-operators/not_matching.d.ts +7 -0
- package/dist/async-operators/one.d.ts +6 -0
- package/dist/async-operators/prefix.d.ts +6 -0
- package/dist/async-operators/project.d.ts +10 -0
- package/dist/async-operators/rename.d.ts +6 -0
- package/dist/async-operators/restrict.d.ts +14 -0
- package/dist/async-operators/suffix.d.ts +6 -0
- package/dist/async-operators/summarize.d.ts +8 -0
- package/dist/async-operators/toArray.d.ts +5 -0
- package/dist/async-operators/transform.d.ts +9 -0
- package/dist/async-operators/ungroup.d.ts +7 -0
- package/dist/async-operators/union.d.ts +6 -0
- package/dist/async-operators/unwrap.d.ts +6 -0
- package/dist/async-operators/wrap.d.ts +6 -0
- package/dist/async-operators/yByX.d.ts +7 -0
- package/dist/async-types.d.ts +58 -0
- package/dist/async.d.ts +4 -0
- package/dist/bmg.cjs +1 -1
- package/dist/bmg.cjs.map +1 -1
- package/dist/bmg.modern.js +1 -1
- package/dist/bmg.modern.js.map +1 -1
- package/dist/bmg.module.js +1 -1
- package/dist/bmg.module.js.map +1 -1
- package/dist/bmg.umd.js +1 -1
- package/dist/bmg.umd.js.map +1 -1
- package/dist/index.d.ts +38 -1
- package/dist/lib-definitions.d.ts +1 -0
- package/dist/{src/operators → operators}/_helpers.d.ts +142 -142
- package/dist/{src/operators → operators}/allbut.d.ts +2 -2
- package/dist/{src/operators → operators}/autowrap.d.ts +2 -2
- package/dist/{src/operators → operators}/constants.d.ts +2 -2
- package/dist/{src/operators → operators}/cross_product.d.ts +3 -3
- package/dist/{src/operators → operators}/exclude.d.ts +2 -2
- package/dist/{src/operators → operators}/extend.d.ts +2 -2
- package/dist/{src/src/operators → operators}/group.d.ts +2 -2
- package/dist/{src/operators → operators}/image.d.ts +2 -2
- package/dist/operators/index.d.ts +1 -0
- package/dist/{src/src/operators → operators}/intersect.d.ts +2 -2
- package/dist/operators/isEqual.d.ts +1 -0
- package/dist/operators/isRelation.d.ts +2 -0
- package/dist/{src/operators → operators}/join.d.ts +2 -2
- package/dist/{src/operators → operators}/left_join.d.ts +2 -2
- package/dist/{src/src/operators → operators}/matching.d.ts +2 -2
- package/dist/{src/src/operators → operators}/minus.d.ts +2 -2
- package/dist/{src/src/operators → operators}/not_matching.d.ts +2 -2
- package/dist/{src/operators → operators}/one.d.ts +2 -2
- package/dist/{src/operators → operators}/prefix.d.ts +2 -2
- package/dist/{src/src/operators → operators}/project.d.ts +2 -2
- package/dist/{src/operators → operators}/rename.d.ts +2 -2
- package/dist/{src/operators → operators}/restrict.d.ts +2 -2
- package/dist/{src/operators → operators}/suffix.d.ts +2 -2
- package/dist/{src/operators → operators}/summarize.d.ts +2 -2
- package/dist/{src/operators → operators}/transform.d.ts +2 -2
- package/dist/{src/src/operators → operators}/ungroup.d.ts +2 -2
- package/dist/{src/operators → operators}/union.d.ts +2 -2
- package/dist/{src/operators → operators}/unwrap.d.ts +2 -2
- package/dist/{src/operators → operators}/wrap.d.ts +2 -2
- package/dist/{src/operators → operators}/yByX.d.ts +2 -2
- package/dist/{src/src/support → support}/toPredicateFunc.d.ts +2 -2
- package/dist/{src/src → sync}/Relation/Memory.d.ts +46 -46
- package/dist/{src/src → sync}/Relation/index.d.ts +1 -1
- package/dist/{src/src → sync}/operators/_helpers.d.ts +142 -142
- package/dist/{src/src → sync}/operators/allbut.d.ts +2 -2
- package/dist/{src/src → sync}/operators/autowrap.d.ts +2 -2
- package/dist/{src/src → sync}/operators/constants.d.ts +2 -2
- package/dist/{src/src → sync}/operators/cross_product.d.ts +3 -3
- package/dist/{src/src → sync}/operators/exclude.d.ts +2 -2
- package/dist/{src/src → sync}/operators/extend.d.ts +2 -2
- package/dist/{src → sync}/operators/group.d.ts +2 -2
- package/dist/{src/src → sync}/operators/image.d.ts +2 -2
- package/dist/{src → sync}/operators/index.d.ts +30 -30
- package/dist/{src → sync}/operators/intersect.d.ts +2 -2
- package/dist/sync/operators/isEqual.d.ts +1 -0
- package/dist/sync/operators/isRelation.d.ts +2 -0
- package/dist/{src/src → sync}/operators/join.d.ts +2 -2
- package/dist/{src/src → sync}/operators/left_join.d.ts +2 -2
- package/dist/{src → sync}/operators/matching.d.ts +2 -2
- package/dist/{src → sync}/operators/minus.d.ts +2 -2
- package/dist/{src → sync}/operators/not_matching.d.ts +2 -2
- package/dist/{src/src → sync}/operators/one.d.ts +2 -2
- package/dist/{src/src → sync}/operators/prefix.d.ts +2 -2
- package/dist/{src → sync}/operators/project.d.ts +2 -2
- package/dist/{src/src → sync}/operators/rename.d.ts +2 -2
- package/dist/{src/src → sync}/operators/restrict.d.ts +2 -2
- package/dist/{src/src → sync}/operators/suffix.d.ts +2 -2
- package/dist/{src/src → sync}/operators/summarize.d.ts +2 -2
- package/dist/{src/src → sync}/operators/transform.d.ts +2 -2
- package/dist/{src → sync}/operators/ungroup.d.ts +2 -2
- package/dist/{src/src → sync}/operators/union.d.ts +2 -2
- package/dist/{src/src → sync}/operators/unwrap.d.ts +2 -2
- package/dist/{src → sync}/operators/where.d.ts +1 -1
- package/dist/{src/src → sync}/operators/wrap.d.ts +2 -2
- package/dist/{src/src → sync}/operators/yByX.d.ts +2 -2
- package/dist/{src/src/types.d.ts → types.d.ts} +169 -101
- package/dist/writer/Text.d.ts +40 -0
- package/dist/writer/index.d.ts +1 -0
- package/package.json +6 -4
- package/src/Relation/index.ts +2 -1
- package/src/async/Relation/Base.ts +245 -0
- package/src/async/Relation/index.ts +31 -0
- package/src/async/operators/_helpers.ts +60 -0
- package/src/async/operators/autowrap.ts +31 -0
- package/src/async/operators/constants.ts +26 -0
- package/src/async/operators/cross_product.ts +39 -0
- package/src/async/operators/extend.ts +36 -0
- package/src/async/operators/group.ts +61 -0
- package/src/async/operators/image.ts +42 -0
- package/src/async/operators/index.ts +28 -0
- package/src/async/operators/intersect.ts +28 -0
- package/src/async/operators/isEqual.ts +39 -0
- package/src/async/operators/join.ts +39 -0
- package/src/async/operators/left_join.ts +55 -0
- package/src/async/operators/matching.ts +39 -0
- package/src/async/operators/minus.ts +28 -0
- package/src/async/operators/not_matching.ts +39 -0
- package/src/async/operators/one.ts +25 -0
- package/src/async/operators/prefix.ts +15 -0
- package/src/async/operators/project.ts +64 -0
- package/src/async/operators/rename.ts +33 -0
- package/src/async/operators/restrict.ts +61 -0
- package/src/async/operators/suffix.ts +15 -0
- package/src/async/operators/summarize.ts +90 -0
- package/src/async/operators/toArray.ts +18 -0
- package/src/async/operators/transform.ts +43 -0
- package/src/async/operators/ungroup.ts +43 -0
- package/src/async/operators/union.ts +29 -0
- package/src/async/operators/unwrap.ts +31 -0
- package/src/async/operators/wrap.ts +32 -0
- package/src/async/operators/yByX.ts +19 -0
- package/src/async/types.ts +86 -0
- package/src/async.ts +4 -0
- package/src/index.ts +17 -4
- package/src/lib-definitions.ts +292 -0
- package/src/operators/index.ts +2 -31
- package/src/{Relation → sync/Relation}/Memory.ts +22 -13
- package/{dist/src/Relation/index.d.ts → src/sync/Relation/index.ts} +1 -1
- package/src/{operators → sync/operators}/_helpers.ts +1 -1
- package/src/{operators → sync/operators}/allbut.ts +1 -1
- package/src/{operators → sync/operators}/autowrap.ts +1 -1
- package/src/{operators → sync/operators}/constants.ts +1 -1
- package/src/{operators → sync/operators}/cross_product.ts +1 -1
- package/src/{operators → sync/operators}/exclude.ts +2 -2
- package/src/{operators → sync/operators}/extend.ts +1 -1
- package/src/{operators → sync/operators}/group.ts +2 -2
- package/src/{operators → sync/operators}/image.ts +2 -2
- package/src/sync/operators/index.ts +31 -0
- package/src/{operators → sync/operators}/intersect.ts +1 -1
- package/src/{operators → sync/operators}/isEqual.ts +1 -2
- package/src/sync/operators/isRelation.ts +6 -0
- package/src/{operators → sync/operators}/join.ts +1 -1
- package/src/{operators → sync/operators}/left_join.ts +1 -1
- package/src/{operators → sync/operators}/matching.ts +1 -1
- package/src/{operators → sync/operators}/minus.ts +1 -1
- package/src/{operators → sync/operators}/not_matching.ts +1 -1
- package/src/{operators → sync/operators}/one.ts +1 -1
- package/src/{operators → sync/operators}/prefix.ts +1 -1
- package/src/{operators → sync/operators}/project.ts +1 -1
- package/src/{operators → sync/operators}/rename.ts +1 -1
- package/src/{operators → sync/operators}/restrict.ts +2 -2
- package/src/{operators → sync/operators}/suffix.ts +1 -1
- package/src/{operators → sync/operators}/summarize.ts +1 -1
- package/src/{operators → sync/operators}/transform.ts +1 -1
- package/src/{operators → sync/operators}/ungroup.ts +1 -1
- package/src/{operators → sync/operators}/union.ts +1 -1
- package/src/{operators → sync/operators}/unwrap.ts +1 -1
- package/{dist/src/src/operators/where.d.ts → src/sync/operators/where.ts} +1 -1
- package/src/{operators → sync/operators}/wrap.ts +1 -1
- package/src/{operators → sync/operators}/yByX.ts +1 -1
- package/src/types.ts +153 -54
- package/src/writer/Text.ts +305 -0
- package/src/writer/index.ts +1 -0
- package/dist/src/Relation.d.ts +0 -8
- package/dist/src/index.d.ts +0 -27
- package/dist/src/operators/isEqual.d.ts +0 -2
- package/dist/src/operators/isRelation.d.ts +0 -1
- package/dist/src/src/index.d.ts +0 -27
- package/dist/src/src/operators/index.d.ts +0 -30
- package/dist/src/src/operators/isEqual.d.ts +0 -2
- package/dist/src/src/operators/isRelation.d.ts +0 -1
- package/dist/src/src/utility-types.d.ts +0 -43
- package/dist/src/support/toPredicateFunc.d.ts +0 -2
- package/dist/src/tests/bmg.test.d.ts +0 -1
- package/dist/src/tests/fixtures.d.ts +0 -6
- package/dist/src/tests/operators/allbut.test.d.ts +0 -1
- package/dist/src/tests/operators/autowrap.test.d.ts +0 -1
- package/dist/src/tests/operators/constants.test.d.ts +0 -1
- package/dist/src/tests/operators/cross_product.test.d.ts +0 -1
- package/dist/src/tests/operators/exclude.test.d.ts +0 -1
- package/dist/src/tests/operators/extend.test.d.ts +0 -1
- package/dist/src/tests/operators/group.test.d.ts +0 -1
- package/dist/src/tests/operators/image.test.d.ts +0 -1
- package/dist/src/tests/operators/intersect.test.d.ts +0 -1
- package/dist/src/tests/operators/isEqual.test.d.ts +0 -1
- package/dist/src/tests/operators/join.test.d.ts +0 -1
- package/dist/src/tests/operators/left_join.test.d.ts +0 -1
- package/dist/src/tests/operators/matching.test.d.ts +0 -1
- package/dist/src/tests/operators/minus.test.d.ts +0 -1
- package/dist/src/tests/operators/not_matching.test.d.ts +0 -1
- package/dist/src/tests/operators/one.test.d.ts +0 -1
- package/dist/src/tests/operators/prefix.test.d.ts +0 -1
- package/dist/src/tests/operators/project.test.d.ts +0 -1
- package/dist/src/tests/operators/rename.test.d.ts +0 -1
- package/dist/src/tests/operators/restrict.test.d.ts +0 -1
- package/dist/src/tests/operators/suffix.test.d.ts +0 -1
- package/dist/src/tests/operators/summarize.test.d.ts +0 -1
- package/dist/src/tests/operators/transform.test.d.ts +0 -1
- package/dist/src/tests/operators/ungroup.test.d.ts +0 -1
- package/dist/src/tests/operators/union.test.d.ts +0 -1
- package/dist/src/tests/operators/unwrap.test.d.ts +0 -1
- package/dist/src/tests/operators/where.test.d.ts +0 -1
- package/dist/src/tests/operators/wrap.test.d.ts +0 -1
- package/dist/src/tests/operators/yByX.test.d.ts +0 -1
- package/dist/src/tests/types/relation.test.d.ts +0 -1
- package/dist/src/types.d.ts +0 -101
- package/dist/src/utility-types.d.ts +0 -43
- package/dist/tests/bmg.test.d.ts +0 -1
- package/dist/tests/fixtures.d.ts +0 -6
- package/dist/tests/operators/allbut.test.d.ts +0 -1
- package/dist/tests/operators/autowrap.test.d.ts +0 -1
- package/dist/tests/operators/constants.test.d.ts +0 -1
- package/dist/tests/operators/cross_product.test.d.ts +0 -1
- package/dist/tests/operators/exclude.test.d.ts +0 -1
- package/dist/tests/operators/extend.test.d.ts +0 -1
- package/dist/tests/operators/group.test.d.ts +0 -1
- package/dist/tests/operators/image.test.d.ts +0 -1
- package/dist/tests/operators/intersect.test.d.ts +0 -1
- package/dist/tests/operators/isEqual.test.d.ts +0 -1
- package/dist/tests/operators/join.test.d.ts +0 -1
- package/dist/tests/operators/left_join.test.d.ts +0 -1
- package/dist/tests/operators/matching.test.d.ts +0 -1
- package/dist/tests/operators/minus.test.d.ts +0 -1
- package/dist/tests/operators/not_matching.test.d.ts +0 -1
- package/dist/tests/operators/one.test.d.ts +0 -1
- package/dist/tests/operators/prefix.test.d.ts +0 -1
- package/dist/tests/operators/project.test.d.ts +0 -1
- package/dist/tests/operators/rename.test.d.ts +0 -1
- package/dist/tests/operators/restrict.test.d.ts +0 -1
- package/dist/tests/operators/suffix.test.d.ts +0 -1
- package/dist/tests/operators/summarize.test.d.ts +0 -1
- package/dist/tests/operators/transform.test.d.ts +0 -1
- package/dist/tests/operators/ungroup.test.d.ts +0 -1
- package/dist/tests/operators/union.test.d.ts +0 -1
- package/dist/tests/operators/unwrap.test.d.ts +0 -1
- package/dist/tests/operators/where.test.d.ts +0 -1
- package/dist/tests/operators/wrap.test.d.ts +0 -1
- package/dist/tests/operators/yByX.test.d.ts +0 -1
- package/dist/tests/types/relation.test.d.ts +0 -1
- package/src/operators/isRelation.ts +0 -5
- package/src/utility-types.ts +0 -77
- /package/{src/operators/where.ts → dist/operators/where.d.ts} +0 -0
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
// Auto-generated from types.ts
|
|
2
|
+
// Run 'npm run generate:lib-definitions' to regenerate
|
|
3
|
+
|
|
4
|
+
export const LIB_DEFINITIONS = `
|
|
5
|
+
/**
|
|
6
|
+
* Type definitions for Bmg.js relational algebra library.
|
|
7
|
+
*
|
|
8
|
+
* This file defines all types needed for type-safe relational operations:
|
|
9
|
+
* - Base types (AttrName, Tuple)
|
|
10
|
+
* - Utility types for transformations (Renamed, Prefixed, Joined, etc.)
|
|
11
|
+
* - The Relation interface with all operators
|
|
12
|
+
* - Helper types for predicates, extensions, aggregators, etc.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
// ============================================================================
|
|
16
|
+
// Base Types
|
|
17
|
+
// ============================================================================
|
|
18
|
+
|
|
19
|
+
/** Attribute name in a tuple */
|
|
20
|
+
type AttrName = string
|
|
21
|
+
|
|
22
|
+
/** A tuple is a record mapping attribute names to values */
|
|
23
|
+
type Tuple = Record<AttrName, unknown>
|
|
24
|
+
|
|
25
|
+
// ============================================================================
|
|
26
|
+
// Rename Types
|
|
27
|
+
// ============================================================================
|
|
28
|
+
|
|
29
|
+
/** Map from old attribute names to new attribute names */
|
|
30
|
+
type RenameMap<T> = { [K in keyof T]?: string };
|
|
31
|
+
|
|
32
|
+
/** Transform tuple type by renaming keys according to RenameMap */
|
|
33
|
+
type Renamed<T, R extends RenameMap<T>> = {
|
|
34
|
+
[K in keyof T as K extends keyof R ? (R[K] extends string ? R[K] : K) : K]: T[K];
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// ============================================================================
|
|
38
|
+
// Prefix/Suffix Types
|
|
39
|
+
// ============================================================================
|
|
40
|
+
|
|
41
|
+
/** Prefix all keys except those in Except */
|
|
42
|
+
type Prefixed<T, P extends string, Except extends keyof T = never> = {
|
|
43
|
+
[K in keyof T as K extends Except ? K : \`\${P}\${K & string}\`]: T[K];
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/** Suffix all keys except those in Except */
|
|
47
|
+
type Suffixed<T, S extends string, Except extends keyof T = never> = {
|
|
48
|
+
[K in keyof T as K extends Except ? K : \`\${K & string}\${S}\`]: T[K];
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
// ============================================================================
|
|
52
|
+
// Join Types
|
|
53
|
+
// ============================================================================
|
|
54
|
+
|
|
55
|
+
/** Extract common keys between two tuple types */
|
|
56
|
+
type CommonKeys<L, R> = Extract<keyof L, keyof R>;
|
|
57
|
+
|
|
58
|
+
/** Result of inner join: L & R with R's common keys removed */
|
|
59
|
+
type Joined<L, R> = L & Omit<R, CommonKeys<L, R>>;
|
|
60
|
+
|
|
61
|
+
/** Result of left join: L & optional R attributes (common keys removed) */
|
|
62
|
+
type LeftJoined<L, R> = L & Partial<Omit<R, CommonKeys<L, R>>>;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Typed join keys for array form: keys must exist on BOTH operands.
|
|
66
|
+
* Example: suppliers.join(parts, ['city']) - 'city' must be a key of both.
|
|
67
|
+
*/
|
|
68
|
+
type TypedJoinKeysArray<L, R> = (keyof L & keyof R & string)[];
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Typed join keys for object form: maps left keys to right keys.
|
|
72
|
+
* Example: suppliers.join(parts, { sid: 'supplier_id' })
|
|
73
|
+
* - Left key (sid) must exist on L
|
|
74
|
+
* - Right key (supplier_id) must exist on R
|
|
75
|
+
*/
|
|
76
|
+
type TypedJoinKeysObject<L, R> = { [K in keyof L & string]?: keyof R & string };
|
|
77
|
+
|
|
78
|
+
// ============================================================================
|
|
79
|
+
// Wrap/Unwrap Types
|
|
80
|
+
// ============================================================================
|
|
81
|
+
|
|
82
|
+
/** Result of wrap: remove wrapped attrs, add nested object */
|
|
83
|
+
type Wrapped<T, K extends keyof T, As extends string> =
|
|
84
|
+
Omit<T, K> & Record<As, Pick<T, K>>;
|
|
85
|
+
|
|
86
|
+
/** Result of unwrap: remove object attr, spread its properties */
|
|
87
|
+
type Unwrapped<T, K extends keyof T> =
|
|
88
|
+
T[K] extends Record<string, unknown> ? Omit<T, K> & T[K] : Omit<T, K>;
|
|
89
|
+
|
|
90
|
+
/** Result of ungroup: remove relation attr, flatten its tuple type */
|
|
91
|
+
type Ungrouped<T, K extends keyof T> =
|
|
92
|
+
T[K] extends Relation<infer N> ? Omit<T, K> & N : Omit<T, K>;
|
|
93
|
+
|
|
94
|
+
// ============================================================================
|
|
95
|
+
// Aggregator Types
|
|
96
|
+
// ============================================================================
|
|
97
|
+
|
|
98
|
+
type AggregatorName = 'count' | 'sum' | 'min' | 'max' | 'avg' | 'collect'
|
|
99
|
+
type AggregatorSpec = { op: AggregatorName, attr: AttrName }
|
|
100
|
+
type AggregatorFunc = (tuples: Tuple[]) => unknown
|
|
101
|
+
type Aggregator = AggregatorName | AggregatorSpec | AggregatorFunc
|
|
102
|
+
type Aggregators = Record<AttrName, Aggregator>
|
|
103
|
+
|
|
104
|
+
/** Infer result type from aggregator specification */
|
|
105
|
+
type AggregatorResult<A> =
|
|
106
|
+
A extends 'count' ? number :
|
|
107
|
+
A extends { op: 'count' } ? number :
|
|
108
|
+
A extends { op: 'sum' | 'avg' | 'min' | 'max' } ? number | null :
|
|
109
|
+
A extends { op: 'collect' } ? unknown[] :
|
|
110
|
+
A extends (tuples: Tuple[]) => infer R ? R :
|
|
111
|
+
unknown;
|
|
112
|
+
|
|
113
|
+
/** Map aggregator definitions to their result types */
|
|
114
|
+
type AggregatorResults<Aggs extends Record<string, unknown>> = {
|
|
115
|
+
[K in keyof Aggs]: AggregatorResult<Aggs[K]>;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
// ============================================================================
|
|
119
|
+
// Predicate Types
|
|
120
|
+
// ============================================================================
|
|
121
|
+
|
|
122
|
+
/** Predicate function that receives a typed tuple */
|
|
123
|
+
type TypedPredicateFunc<T> = (t: T) => boolean
|
|
124
|
+
|
|
125
|
+
/** Predicate: either a partial tuple for equality matching, or a function */
|
|
126
|
+
type TypedPredicate<T> = Partial<T> | TypedPredicateFunc<T>
|
|
127
|
+
|
|
128
|
+
// Legacy predicate types (for backwards compatibility with standalone operators)
|
|
129
|
+
type PredicateFunc = ((t: Tuple) => any)
|
|
130
|
+
type Predicate = Tuple | PredicateFunc
|
|
131
|
+
|
|
132
|
+
// ============================================================================
|
|
133
|
+
// Extension Types
|
|
134
|
+
// ============================================================================
|
|
135
|
+
|
|
136
|
+
/** Extension function that receives a typed tuple */
|
|
137
|
+
type TypedExtensionFunc<T, R> = (tuple: T) => R
|
|
138
|
+
|
|
139
|
+
/** Extension definition: function returning value, or attribute name to copy */
|
|
140
|
+
type TypedExtension<T, E extends Record<string, unknown>> = {
|
|
141
|
+
[K in keyof E]: TypedExtensionFunc<T, E[K]> | keyof T;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
type ExtensionFunc = (tuple: Tuple) => unknown
|
|
145
|
+
type Extension = Record<AttrName, ExtensionFunc | AttrName>
|
|
146
|
+
|
|
147
|
+
// ============================================================================
|
|
148
|
+
// Other Helper Types
|
|
149
|
+
// ============================================================================
|
|
150
|
+
|
|
151
|
+
interface PrefixOptions {
|
|
152
|
+
except?: AttrName[]
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
interface TextOptions {
|
|
156
|
+
/** Precision for floating point numbers (default: 3) */
|
|
157
|
+
floatPrecision?: number;
|
|
158
|
+
/** Maximum width to trim output at */
|
|
159
|
+
trimAt?: number;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
interface SuffixOptions {
|
|
163
|
+
except?: AttrName[]
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
interface AutowrapOptions {
|
|
167
|
+
separator?: string
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
type Renaming = RenamingObj | RenamingFunc
|
|
171
|
+
type RenamingFunc = (attr: AttrName) => AttrName
|
|
172
|
+
type RenamingObj = Record<AttrName, AttrName>
|
|
173
|
+
|
|
174
|
+
type JoinKeys = AttrName[] | Record<AttrName, AttrName>
|
|
175
|
+
|
|
176
|
+
type TransformFunc = (value: unknown) => unknown
|
|
177
|
+
type Transformation = TransformFunc | TransformFunc[] | Record<AttrName, TransformFunc | TransformFunc[]>
|
|
178
|
+
|
|
179
|
+
// ============================================================================
|
|
180
|
+
// Relation Interface
|
|
181
|
+
// ============================================================================
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Relation interface with generic type parameter for tuple type.
|
|
185
|
+
* Default parameter \`Tuple\` ensures backwards compatibility.
|
|
186
|
+
*
|
|
187
|
+
* @typeParam T - The tuple type for this relation. Defaults to \`Tuple\` (Record<string, unknown>).
|
|
188
|
+
*
|
|
189
|
+
* @example
|
|
190
|
+
* // Untyped usage (backwards compatible)
|
|
191
|
+
* const r = Bmg([{ id: 1 }]); // Relation<Tuple>
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* // Typed usage with full type safety
|
|
195
|
+
* interface Person { id: number; name: string }
|
|
196
|
+
* const r = Bmg<Person>([{ id: 1, name: 'Alice' }]);
|
|
197
|
+
* r.project(['id']); // Relation<{ id: number }>
|
|
198
|
+
*/
|
|
199
|
+
interface Relation<T = Tuple> {
|
|
200
|
+
// === Type-preserving operators ===
|
|
201
|
+
|
|
202
|
+
restrict(p: TypedPredicate<T>): Relation<T>
|
|
203
|
+
where(p: TypedPredicate<T>): Relation<T>
|
|
204
|
+
exclude(p: TypedPredicate<T>): Relation<T>
|
|
205
|
+
|
|
206
|
+
// === Projection operators ===
|
|
207
|
+
|
|
208
|
+
project<K extends keyof T>(attrs: K[]): Relation<Pick<T, K>>
|
|
209
|
+
allbut<K extends keyof T>(attrs: K[]): Relation<Omit<T, K>>
|
|
210
|
+
|
|
211
|
+
// === Extension operators ===
|
|
212
|
+
|
|
213
|
+
extend<E extends Record<string, unknown>>(e: TypedExtension<T, E>): Relation<T & E>
|
|
214
|
+
constants<C extends Tuple>(consts: C): Relation<T & C>
|
|
215
|
+
|
|
216
|
+
// === Rename operators ===
|
|
217
|
+
|
|
218
|
+
rename<R extends RenameMap<T>>(r: R): Relation<Renamed<T, R>>
|
|
219
|
+
prefix<P extends string, Ex extends keyof T = never>(pfx: P, options?: { except?: Ex[] }): Relation<Prefixed<T, P, Ex>>
|
|
220
|
+
suffix<S extends string, Ex extends keyof T = never>(sfx: S, options?: { except?: Ex[] }): Relation<Suffixed<T, S, Ex>>
|
|
221
|
+
|
|
222
|
+
// === Set operators (require same type) ===
|
|
223
|
+
|
|
224
|
+
union(right: RelationOperand<T>): Relation<T>
|
|
225
|
+
minus(right: RelationOperand<T>): Relation<T>
|
|
226
|
+
intersect(right: RelationOperand<T>): Relation<T>
|
|
227
|
+
|
|
228
|
+
// === Semi-join operators (preserve left type) ===
|
|
229
|
+
|
|
230
|
+
matching<R>(right: RelationOperand<R>, keys?: TypedJoinKeysArray<T, R> | TypedJoinKeysObject<T, R>): Relation<T>
|
|
231
|
+
not_matching<R>(right: RelationOperand<R>, keys?: TypedJoinKeysArray<T, R> | TypedJoinKeysObject<T, R>): Relation<T>
|
|
232
|
+
|
|
233
|
+
// === Join operators ===
|
|
234
|
+
|
|
235
|
+
join<R>(right: RelationOperand<R>, keys?: TypedJoinKeysArray<T, R> | TypedJoinKeysObject<T, R>): Relation<Joined<T, R>>
|
|
236
|
+
left_join<R>(right: RelationOperand<R>, keys?: TypedJoinKeysArray<T, R> | TypedJoinKeysObject<T, R>): Relation<LeftJoined<T, R>>
|
|
237
|
+
cross_product<R>(right: RelationOperand<R>): Relation<T & R>
|
|
238
|
+
cross_join<R>(right: RelationOperand<R>): Relation<T & R>
|
|
239
|
+
|
|
240
|
+
// === Nesting operators ===
|
|
241
|
+
|
|
242
|
+
image<R, As extends string>(right: RelationOperand<R>, as: As, keys?: TypedJoinKeysArray<T, R> | TypedJoinKeysObject<T, R>): Relation<T & Record<As, Relation<Omit<R, keyof T & keyof R>>>>
|
|
243
|
+
group<K extends keyof T, As extends string>(attrs: K[], as: As): Relation<Omit<T, K> & Record<As, Relation<Pick<T, K>>>>
|
|
244
|
+
ungroup<K extends keyof T>(attr: K): Relation<Ungrouped<T, K>>
|
|
245
|
+
wrap<K extends keyof T, As extends string>(attrs: K[], as: As): Relation<Wrapped<T, K, As>>
|
|
246
|
+
unwrap<K extends keyof T>(attr: K): Relation<Unwrapped<T, K>>
|
|
247
|
+
|
|
248
|
+
// === Aggregation ===
|
|
249
|
+
|
|
250
|
+
summarize<By extends keyof T, Aggs extends Aggregators>(by: By[], aggs: Aggs): Relation<Pick<T, By> & AggregatorResults<Aggs>>
|
|
251
|
+
|
|
252
|
+
// === Transform ===
|
|
253
|
+
|
|
254
|
+
transform(t: Transformation): Relation<T>
|
|
255
|
+
|
|
256
|
+
// === Dynamic (loses type precision) ===
|
|
257
|
+
|
|
258
|
+
autowrap(options?: AutowrapOptions): Relation<Tuple>
|
|
259
|
+
|
|
260
|
+
// === Non-relational ===
|
|
261
|
+
|
|
262
|
+
one(): T
|
|
263
|
+
yByX<Y extends keyof T, X extends keyof T>(y: Y, x: X): Record<T[X] & PropertyKey, T[Y]>
|
|
264
|
+
toArray(): T[]
|
|
265
|
+
isEqual(right: any): boolean
|
|
266
|
+
|
|
267
|
+
// === Display ===
|
|
268
|
+
|
|
269
|
+
toText(options?: TextOptions): string
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// ============================================================================
|
|
273
|
+
// Operands
|
|
274
|
+
// ============================================================================
|
|
275
|
+
|
|
276
|
+
type RelationOperand<T = Tuple> = Relation<T> | T[]
|
|
277
|
+
|
|
278
|
+
interface OperationalOperand<T = Tuple> {
|
|
279
|
+
tuples(): Iterable<T>
|
|
280
|
+
output(tuples: T[]): RelationOperand<T>
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
// ============================================================================
|
|
284
|
+
// Bmg Function Declaration
|
|
285
|
+
// ============================================================================
|
|
286
|
+
|
|
287
|
+
/** Create a relation from an array of tuples */
|
|
288
|
+
declare function Bmg<T>(tuples: T[]): Relation<T>
|
|
289
|
+
declare namespace Bmg {
|
|
290
|
+
function isRelation(op: unknown): boolean
|
|
291
|
+
}
|
|
292
|
+
`
|
package/src/operators/index.ts
CHANGED
|
@@ -1,31 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
export * from '
|
|
3
|
-
export * from './exclude'
|
|
4
|
-
export * from './constants'
|
|
5
|
-
export * from './rename'
|
|
6
|
-
export * from './prefix'
|
|
7
|
-
export * from './suffix'
|
|
8
|
-
export * from './project'
|
|
9
|
-
export * from './allbut'
|
|
10
|
-
export * from './extend'
|
|
11
|
-
export * from './union'
|
|
12
|
-
export * from './minus'
|
|
13
|
-
export * from './intersect'
|
|
14
|
-
export * from './matching'
|
|
15
|
-
export * from './not_matching'
|
|
16
|
-
export * from './join'
|
|
17
|
-
export * from './left_join'
|
|
18
|
-
export * from './cross_product'
|
|
19
|
-
export * from './image'
|
|
20
|
-
export * from './summarize'
|
|
21
|
-
export * from './group'
|
|
22
|
-
export * from './ungroup'
|
|
23
|
-
export * from './wrap'
|
|
24
|
-
export * from './unwrap'
|
|
25
|
-
export * from './autowrap'
|
|
26
|
-
export * from './transform'
|
|
27
|
-
|
|
28
|
-
export * from './isRelation'
|
|
29
|
-
export * from './isEqual'
|
|
30
|
-
export * from './one'
|
|
31
|
-
export * from './yByX'
|
|
1
|
+
// Re-export sync operators for backward compatibility
|
|
2
|
+
export * from '../sync/operators';
|
|
@@ -32,9 +32,9 @@ import {
|
|
|
32
32
|
import type {
|
|
33
33
|
AttrName,
|
|
34
34
|
AutowrapOptions,
|
|
35
|
-
JoinKeys,
|
|
36
35
|
Relation,
|
|
37
36
|
RelationOperand,
|
|
37
|
+
TextOptions,
|
|
38
38
|
Transformation,
|
|
39
39
|
Tuple,
|
|
40
40
|
TypedPredicate,
|
|
@@ -48,8 +48,11 @@ import type {
|
|
|
48
48
|
Wrapped,
|
|
49
49
|
Unwrapped,
|
|
50
50
|
Ungrouped,
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
AggregatorResults,
|
|
52
|
+
TypedJoinKeysArray,
|
|
53
|
+
TypedJoinKeysObject,
|
|
54
|
+
} from "../../types";
|
|
55
|
+
import { toText } from "../../writer";
|
|
53
56
|
|
|
54
57
|
/**
|
|
55
58
|
* In-memory implementation of the Relation interface.
|
|
@@ -126,22 +129,22 @@ export class MemoryRelation<T = Tuple> implements Relation<T> {
|
|
|
126
129
|
|
|
127
130
|
// === Semi-join operators ===
|
|
128
131
|
|
|
129
|
-
matching<R>(right: RelationOperand<R>, keys?:
|
|
130
|
-
return matching(this as any, right as any, keys) as unknown as Relation<T>;
|
|
132
|
+
matching<R>(right: RelationOperand<R>, keys?: TypedJoinKeysArray<T, R> | TypedJoinKeysObject<T, R>): Relation<T> {
|
|
133
|
+
return matching(this as any, right as any, keys as any) as unknown as Relation<T>;
|
|
131
134
|
}
|
|
132
135
|
|
|
133
|
-
not_matching<R>(right: RelationOperand<R>, keys?:
|
|
134
|
-
return not_matching(this as any, right as any, keys) as unknown as Relation<T>;
|
|
136
|
+
not_matching<R>(right: RelationOperand<R>, keys?: TypedJoinKeysArray<T, R> | TypedJoinKeysObject<T, R>): Relation<T> {
|
|
137
|
+
return not_matching(this as any, right as any, keys as any) as unknown as Relation<T>;
|
|
135
138
|
}
|
|
136
139
|
|
|
137
140
|
// === Join operators ===
|
|
138
141
|
|
|
139
|
-
join<R>(right: RelationOperand<R>, keys?:
|
|
140
|
-
return join(this as any, right as any, keys) as unknown as Relation<Joined<T, R>>;
|
|
142
|
+
join<R>(right: RelationOperand<R>, keys?: TypedJoinKeysArray<T, R> | TypedJoinKeysObject<T, R>): Relation<Joined<T, R>> {
|
|
143
|
+
return join(this as any, right as any, keys as any) as unknown as Relation<Joined<T, R>>;
|
|
141
144
|
}
|
|
142
145
|
|
|
143
|
-
left_join<R>(right: RelationOperand<R>, keys?:
|
|
144
|
-
return left_join(this as any, right as any, keys) as unknown as Relation<LeftJoined<T, R>>;
|
|
146
|
+
left_join<R>(right: RelationOperand<R>, keys?: TypedJoinKeysArray<T, R> | TypedJoinKeysObject<T, R>): Relation<LeftJoined<T, R>> {
|
|
147
|
+
return left_join(this as any, right as any, keys as any) as unknown as Relation<LeftJoined<T, R>>;
|
|
145
148
|
}
|
|
146
149
|
|
|
147
150
|
cross_product<R>(right: RelationOperand<R>): Relation<T & R> {
|
|
@@ -154,8 +157,8 @@ export class MemoryRelation<T = Tuple> implements Relation<T> {
|
|
|
154
157
|
|
|
155
158
|
// === Nesting operators ===
|
|
156
159
|
|
|
157
|
-
image<R, As extends string>(right: RelationOperand<R>, as: As, keys?:
|
|
158
|
-
return image(this as any, right as any, as, keys) as unknown as Relation<T & Record<As, Relation<Omit<R, keyof T & keyof R>>>>;
|
|
160
|
+
image<R, As extends string>(right: RelationOperand<R>, as: As, keys?: TypedJoinKeysArray<T, R> | TypedJoinKeysObject<T, R>): Relation<T & Record<As, Relation<Omit<R, keyof T & keyof R>>>> {
|
|
161
|
+
return image(this as any, right as any, as, keys as any) as unknown as Relation<T & Record<As, Relation<Omit<R, keyof T & keyof R>>>>;
|
|
159
162
|
}
|
|
160
163
|
|
|
161
164
|
group<K extends keyof T, As extends string>(attrs: K[], as: As): Relation<Omit<T, K> & Record<As, Relation<Pick<T, K>>>> {
|
|
@@ -210,4 +213,10 @@ export class MemoryRelation<T = Tuple> implements Relation<T> {
|
|
|
210
213
|
return isEqual(this as any, right as any);
|
|
211
214
|
}
|
|
212
215
|
|
|
216
|
+
// === Display ===
|
|
217
|
+
|
|
218
|
+
toText(options?: TextOptions): string {
|
|
219
|
+
return toText(this as any, options);
|
|
220
|
+
}
|
|
221
|
+
|
|
213
222
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './Memory';
|
|
1
|
+
export * from './Memory';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OperationalOperand, Relation, RelationOperand, Renaming, RenamingFunc, Tuple, JoinKeys, AttrName } from "@/types";
|
|
2
|
-
import { MemoryRelation } from '@/Relation';
|
|
2
|
+
import { MemoryRelation } from '@/sync/Relation';
|
|
3
3
|
import { isRelation } from "./isRelation";
|
|
4
4
|
|
|
5
5
|
const valueKey = (value: unknown): unknown => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RelationOperand, AttrName, Tuple } from "
|
|
1
|
+
import { RelationOperand, AttrName, Tuple } from "../../types";
|
|
2
2
|
import { toOperationalOperand, deduplicate } from "./_helpers";
|
|
3
3
|
|
|
4
4
|
export const allbut = (operand: RelationOperand, attrs: AttrName[]): RelationOperand => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AutowrapOptions, RelationOperand, Tuple } from "
|
|
1
|
+
import { AutowrapOptions, RelationOperand, Tuple } from "../../types";
|
|
2
2
|
import { toOperationalOperand } from "./_helpers";
|
|
3
3
|
|
|
4
4
|
export const autowrap = (operand: RelationOperand, options?: AutowrapOptions): RelationOperand => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RelationOperand, Tuple } from "
|
|
1
|
+
import { RelationOperand, Tuple } from "../../types";
|
|
2
2
|
import { toOperationalOperand, deduplicate } from "./_helpers";
|
|
3
3
|
|
|
4
4
|
export const cross_product = (left: RelationOperand, right: RelationOperand): RelationOperand => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { toPredicateFunc } from "
|
|
2
|
-
import { RelationOperand, Predicate, Tuple } from "
|
|
1
|
+
import { toPredicateFunc } from "../../support/toPredicateFunc";
|
|
2
|
+
import { RelationOperand, Predicate, Tuple } from "../../types";
|
|
3
3
|
import { toOperationalOperand } from "./_helpers";
|
|
4
4
|
|
|
5
5
|
export const exclude = (operand: RelationOperand, p: Predicate): RelationOperand => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RelationOperand, Extension, Tuple } from "
|
|
1
|
+
import { RelationOperand, Extension, Tuple } from "../../types";
|
|
2
2
|
import { toOperationalOperand } from "./_helpers";
|
|
3
3
|
|
|
4
4
|
export const extend = (operand: RelationOperand, extension: Extension): RelationOperand => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { RelationOperand, AttrName, Tuple } from "
|
|
1
|
+
import { RelationOperand, AttrName, Tuple } from "../../types";
|
|
2
2
|
import { toOperationalOperand } from "./_helpers";
|
|
3
|
-
import { MemoryRelation } from "@/Relation";
|
|
3
|
+
import { MemoryRelation } from "@/sync/Relation";
|
|
4
4
|
|
|
5
5
|
const groupKey = (tuple: Tuple, byAttrs: AttrName[]): string => {
|
|
6
6
|
const keyParts = byAttrs.map(attr => JSON.stringify(tuple[attr]));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { RelationOperand, JoinKeys, Tuple, AttrName } from "
|
|
1
|
+
import { RelationOperand, JoinKeys, Tuple, AttrName } from "../../types";
|
|
2
2
|
import { toOperationalOperand, normalizeKeys, tuplesMatch, projectOutKeys } from "./_helpers";
|
|
3
|
-
import { MemoryRelation } from "@/Relation";
|
|
3
|
+
import { MemoryRelation } from "@/sync/Relation";
|
|
4
4
|
|
|
5
5
|
export const image = (left: RelationOperand, right: RelationOperand, as: AttrName, keys?: JoinKeys): RelationOperand => {
|
|
6
6
|
const opLeft = toOperationalOperand(left);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export * from './restrict'
|
|
2
|
+
export * from './where'
|
|
3
|
+
export * from './exclude'
|
|
4
|
+
export * from './constants'
|
|
5
|
+
export * from './rename'
|
|
6
|
+
export * from './prefix'
|
|
7
|
+
export * from './suffix'
|
|
8
|
+
export * from './project'
|
|
9
|
+
export * from './allbut'
|
|
10
|
+
export * from './extend'
|
|
11
|
+
export * from './union'
|
|
12
|
+
export * from './minus'
|
|
13
|
+
export * from './intersect'
|
|
14
|
+
export * from './matching'
|
|
15
|
+
export * from './not_matching'
|
|
16
|
+
export * from './join'
|
|
17
|
+
export * from './left_join'
|
|
18
|
+
export * from './cross_product'
|
|
19
|
+
export * from './image'
|
|
20
|
+
export * from './summarize'
|
|
21
|
+
export * from './group'
|
|
22
|
+
export * from './ungroup'
|
|
23
|
+
export * from './wrap'
|
|
24
|
+
export * from './unwrap'
|
|
25
|
+
export * from './autowrap'
|
|
26
|
+
export * from './transform'
|
|
27
|
+
|
|
28
|
+
export * from './isRelation'
|
|
29
|
+
export * from './isEqual'
|
|
30
|
+
export * from './one'
|
|
31
|
+
export * from './yByX'
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { RelationOperand } from "../types";
|
|
2
1
|
import { toOperationalOperand, tupleKey } from "./_helpers";
|
|
3
2
|
|
|
4
|
-
export const isEqual = (left:
|
|
3
|
+
export const isEqual = (left: any, right: any): boolean => {
|
|
5
4
|
const opLeft = toOperationalOperand(left);
|
|
6
5
|
const opRight = toOperationalOperand(right);
|
|
7
6
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RelationOperand, JoinKeys, Tuple, AttrName } from "
|
|
1
|
+
import { RelationOperand, JoinKeys, Tuple, AttrName } from "../../types";
|
|
2
2
|
import { toOperationalOperand, normalizeKeys, tuplesMatch, projectOutKeys } from "./_helpers";
|
|
3
3
|
|
|
4
4
|
const mergeTuples = (left: Tuple, right: Tuple, keyMap: Record<AttrName, AttrName>): Tuple => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RelationOperand, JoinKeys, Tuple, AttrName } from "
|
|
1
|
+
import { RelationOperand, JoinKeys, Tuple, AttrName } from "../../types";
|
|
2
2
|
import { toOperationalOperand, normalizeKeys, tuplesMatch } from "./_helpers";
|
|
3
3
|
|
|
4
4
|
const getRightAttrs = (rightTuples: Tuple[], keyMap: Record<AttrName, AttrName>): AttrName[] => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RelationOperand, JoinKeys, Tuple } from "
|
|
1
|
+
import { RelationOperand, JoinKeys, Tuple } from "../../types";
|
|
2
2
|
import { toOperationalOperand, normalizeKeys, matchKey } from "./_helpers";
|
|
3
3
|
|
|
4
4
|
export const matching = (left: RelationOperand, right: RelationOperand, keys?: JoinKeys): RelationOperand => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RelationOperand, JoinKeys, Tuple } from "
|
|
1
|
+
import { RelationOperand, JoinKeys, Tuple } from "../../types";
|
|
2
2
|
import { toOperationalOperand, normalizeKeys, matchKey } from "./_helpers";
|
|
3
3
|
|
|
4
4
|
export const not_matching = (left: RelationOperand, right: RelationOperand, keys?: JoinKeys): RelationOperand => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PrefixOptions, RelationOperand } from "
|
|
1
|
+
import { PrefixOptions, RelationOperand } from "../../types";
|
|
2
2
|
import { rename } from "./rename";
|
|
3
3
|
|
|
4
4
|
export const prefix = (operand: RelationOperand, pfx: string, options?: PrefixOptions): RelationOperand => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RelationOperand, AttrName, Tuple } from "
|
|
1
|
+
import { RelationOperand, AttrName, Tuple } from "../../types";
|
|
2
2
|
import { toOperationalOperand, deduplicate } from "./_helpers";
|
|
3
3
|
|
|
4
4
|
export const project = (operand: RelationOperand, attrs: AttrName[]): RelationOperand => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RelationOperand, Renaming, Tuple } from "
|
|
1
|
+
import { RelationOperand, Renaming, Tuple } from "../../types";
|
|
2
2
|
import { toOperationalOperand, toRenamingFunc } from "./_helpers";
|
|
3
3
|
|
|
4
4
|
export const rename = (operand: RelationOperand, renaming: Renaming): RelationOperand => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { toPredicateFunc } from "
|
|
2
|
-
import { RelationOperand, Predicate, Tuple } from "
|
|
1
|
+
import { toPredicateFunc } from "../../support/toPredicateFunc";
|
|
2
|
+
import { RelationOperand, Predicate, Tuple } from "../../types";
|
|
3
3
|
import { toOperationalOperand } from "./_helpers";
|
|
4
4
|
|
|
5
5
|
export const restrict = (operand: RelationOperand, p: Predicate): RelationOperand => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RelationOperand, SuffixOptions } from "
|
|
1
|
+
import { RelationOperand, SuffixOptions } from "../../types";
|
|
2
2
|
import { rename } from "./rename";
|
|
3
3
|
|
|
4
4
|
export const suffix = (operand: RelationOperand, sfx: string, options?: SuffixOptions): RelationOperand => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RelationOperand, AttrName, Tuple, Aggregator, Aggregators } from "
|
|
1
|
+
import { RelationOperand, AttrName, Tuple, Aggregator, Aggregators } from "../../types";
|
|
2
2
|
import { toOperationalOperand } from "./_helpers";
|
|
3
3
|
|
|
4
4
|
const groupKey = (tuple: Tuple, by: AttrName[]): string => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RelationOperand, Transformation, Tuple } from "
|
|
1
|
+
import { RelationOperand, Transformation, Tuple } from "../../types";
|
|
2
2
|
import { toOperationalOperand } from "./_helpers";
|
|
3
3
|
|
|
4
4
|
export const transform = (operand: RelationOperand, transformation: Transformation): RelationOperand => {
|