@enspirit/bmg-js 1.0.1 → 1.0.2
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/dist/{src/Relation → Relation}/Memory.d.ts +45 -46
- package/dist/{src/src/Relation → Relation}/index.d.ts +1 -1
- 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 +27 -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/{src/operators → operators}/index.d.ts +30 -30
- package/dist/{src/src/operators → operators}/intersect.d.ts +2 -2
- package/dist/{src/src/operators → operators}/isEqual.d.ts +2 -2
- package/dist/{src/operators → operators}/isRelation.d.ts +1 -1
- 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}/where.d.ts +1 -1
- 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/types.d.ts → types.d.ts} +162 -101
- package/package.json +6 -4
- package/src/Relation/Memory.ts +13 -12
- package/src/index.ts +1 -1
- package/src/lib-definitions.ts +281 -0
- package/src/types.ts +142 -54
- package/dist/src/Relation/index.d.ts +0 -1
- package/dist/src/Relation.d.ts +0 -8
- package/dist/src/index.d.ts +0 -27
- package/dist/src/operators/group.d.ts +0 -2
- package/dist/src/operators/intersect.d.ts +0 -2
- package/dist/src/operators/isEqual.d.ts +0 -2
- package/dist/src/operators/matching.d.ts +0 -2
- package/dist/src/operators/minus.d.ts +0 -2
- package/dist/src/operators/not_matching.d.ts +0 -2
- package/dist/src/operators/project.d.ts +0 -2
- package/dist/src/operators/ungroup.d.ts +0 -2
- package/dist/src/src/Relation/Memory.d.ts +0 -46
- package/dist/src/src/index.d.ts +0 -27
- package/dist/src/src/operators/_helpers.d.ts +0 -142
- package/dist/src/src/operators/allbut.d.ts +0 -2
- package/dist/src/src/operators/autowrap.d.ts +0 -2
- package/dist/src/src/operators/constants.d.ts +0 -2
- package/dist/src/src/operators/cross_product.d.ts +0 -3
- package/dist/src/src/operators/exclude.d.ts +0 -2
- package/dist/src/src/operators/extend.d.ts +0 -2
- package/dist/src/src/operators/image.d.ts +0 -2
- package/dist/src/src/operators/index.d.ts +0 -30
- package/dist/src/src/operators/isRelation.d.ts +0 -1
- package/dist/src/src/operators/join.d.ts +0 -2
- package/dist/src/src/operators/left_join.d.ts +0 -2
- package/dist/src/src/operators/one.d.ts +0 -2
- package/dist/src/src/operators/prefix.d.ts +0 -2
- package/dist/src/src/operators/rename.d.ts +0 -2
- package/dist/src/src/operators/restrict.d.ts +0 -2
- package/dist/src/src/operators/suffix.d.ts +0 -2
- package/dist/src/src/operators/summarize.d.ts +0 -2
- package/dist/src/src/operators/transform.d.ts +0 -2
- package/dist/src/src/operators/union.d.ts +0 -2
- package/dist/src/src/operators/unwrap.d.ts +0 -2
- package/dist/src/src/operators/where.d.ts +0 -1
- package/dist/src/src/operators/wrap.d.ts +0 -2
- package/dist/src/src/operators/yByX.d.ts +0 -2
- 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/utility-types.ts +0 -77
|
@@ -1,142 +1,142 @@
|
|
|
1
|
-
import { OperationalOperand, RelationOperand, Renaming, RenamingFunc, Tuple, JoinKeys, AttrName } from "@/types";
|
|
2
|
-
/**
|
|
3
|
-
* Generates a unique string key for a tuple, used for equality comparison and deduplication.
|
|
4
|
-
* Handles nested relations by converting them to sorted tuple keys.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* tupleKey({ name: 'Alice', age: 30 })
|
|
8
|
-
* // => '[["age",30],["name","Alice"]]'
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* tupleKey({ id: 1, items: Bmg([{ x: 1 }, { x: 2 }]) })
|
|
12
|
-
* // => '[["id",1],["items",[...]]]' (nested relation converted to sorted keys)
|
|
13
|
-
*/
|
|
14
|
-
export declare const tupleKey: (tuple: Tuple) => string;
|
|
15
|
-
/**
|
|
16
|
-
* Removes duplicate tuples from an array, preserving order of first occurrence.
|
|
17
|
-
* Uses tupleKey() for equality comparison.
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* deduplicate([
|
|
21
|
-
* { id: 1, name: 'Alice' },
|
|
22
|
-
* { id: 2, name: 'Bob' },
|
|
23
|
-
* { id: 1, name: 'Alice' }, // duplicate
|
|
24
|
-
* ])
|
|
25
|
-
* // => [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }]
|
|
26
|
-
*/
|
|
27
|
-
export declare const deduplicate: (tuples: Tuple[]) => Tuple[];
|
|
28
|
-
/**
|
|
29
|
-
* Converts a RelationOperand (Relation or Tuple[]) to an OperationalOperand
|
|
30
|
-
* that provides a uniform interface for iteration and output.
|
|
31
|
-
*
|
|
32
|
-
* @example
|
|
33
|
-
* // With array input, output remains array
|
|
34
|
-
* const op = toOperationalOperand([{ id: 1 }]);
|
|
35
|
-
* [...op.tuples()]; // => [{ id: 1 }]
|
|
36
|
-
* op.output([{ id: 2 }]); // => [{ id: 2 }]
|
|
37
|
-
*
|
|
38
|
-
* @example
|
|
39
|
-
* // With Relation input, output is a new Relation
|
|
40
|
-
* const op = toOperationalOperand(Bmg([{ id: 1 }]));
|
|
41
|
-
* [...op.tuples()]; // => [{ id: 1 }]
|
|
42
|
-
* op.output([{ id: 2 }]); // => Bmg([{ id: 2 }])
|
|
43
|
-
*/
|
|
44
|
-
export declare const toOperationalOperand: (operand: RelationOperand) => OperationalOperand;
|
|
45
|
-
/**
|
|
46
|
-
* Converts a Renaming (object or function) to a RenamingFunc.
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* // Object renaming
|
|
50
|
-
* const fn = toRenamingFunc({ name: 'fullName', age: 'years' });
|
|
51
|
-
* fn('name'); // => 'fullName'
|
|
52
|
-
* fn('age'); // => 'years'
|
|
53
|
-
* fn('other'); // => 'other' (unchanged)
|
|
54
|
-
*
|
|
55
|
-
* @example
|
|
56
|
-
* // Function renaming (passed through)
|
|
57
|
-
* const fn = toRenamingFunc(attr => attr.toUpperCase());
|
|
58
|
-
* fn('name'); // => 'NAME'
|
|
59
|
-
*/
|
|
60
|
-
export declare const toRenamingFunc: (renaming: Renaming) => RenamingFunc;
|
|
61
|
-
export declare const error: (msg: string) => never;
|
|
62
|
-
/**
|
|
63
|
-
* Finds attribute names that exist in both left and right tuple arrays.
|
|
64
|
-
* Used for natural joins when no explicit keys are provided.
|
|
65
|
-
*
|
|
66
|
-
* @example
|
|
67
|
-
* const left = [{ id: 1, name: 'Alice', city: 'NYC' }];
|
|
68
|
-
* const right = [{ city: 'NYC', country: 'USA' }];
|
|
69
|
-
* getCommonAttrs(left, right);
|
|
70
|
-
* // => ['city']
|
|
71
|
-
*
|
|
72
|
-
* @example
|
|
73
|
-
* const left = [{ a: 1, b: 2 }];
|
|
74
|
-
* const right = [{ b: 2, c: 3 }];
|
|
75
|
-
* getCommonAttrs(left, right);
|
|
76
|
-
* // => ['b']
|
|
77
|
-
*/
|
|
78
|
-
export declare const getCommonAttrs: (left: Tuple[], right: Tuple[]) => AttrName[];
|
|
79
|
-
/**
|
|
80
|
-
* Normalizes JoinKeys to a Record<AttrName, AttrName> mapping left attrs to right attrs.
|
|
81
|
-
*
|
|
82
|
-
* @example
|
|
83
|
-
* // undefined => use common attributes
|
|
84
|
-
* normalizeKeys(undefined, [{ id: 1, city: 'NYC' }], [{ city: 'NYC' }]);
|
|
85
|
-
* // => { city: 'city' }
|
|
86
|
-
*
|
|
87
|
-
* @example
|
|
88
|
-
* // Array of common attribute names
|
|
89
|
-
* normalizeKeys(['city', 'country'], leftTuples, rightTuples);
|
|
90
|
-
* // => { city: 'city', country: 'country' }
|
|
91
|
-
*
|
|
92
|
-
* @example
|
|
93
|
-
* // Object mapping left attr to right attr
|
|
94
|
-
* normalizeKeys({ city: 'location' }, leftTuples, rightTuples);
|
|
95
|
-
* // => { city: 'location' }
|
|
96
|
-
*/
|
|
97
|
-
export declare const normalizeKeys: (keys: JoinKeys | undefined, leftTuples: Tuple[], rightTuples: Tuple[]) => Record<AttrName, AttrName>;
|
|
98
|
-
/**
|
|
99
|
-
* Checks if two tuples match on the specified key mapping.
|
|
100
|
-
*
|
|
101
|
-
* @example
|
|
102
|
-
* const keyMap = { city: 'location' };
|
|
103
|
-
* tuplesMatch({ id: 1, city: 'NYC' }, { location: 'NYC', pop: 8 }, keyMap);
|
|
104
|
-
* // => true (left.city === right.location)
|
|
105
|
-
*
|
|
106
|
-
* @example
|
|
107
|
-
* const keyMap = { city: 'city' };
|
|
108
|
-
* tuplesMatch({ city: 'NYC' }, { city: 'LA' }, keyMap);
|
|
109
|
-
* // => false
|
|
110
|
-
*/
|
|
111
|
-
export declare const tuplesMatch: (left: Tuple, right: Tuple, keyMap: Record<AttrName, AttrName>) => boolean;
|
|
112
|
-
/**
|
|
113
|
-
* Creates a string key from a tuple's join attributes for fast Set-based lookups.
|
|
114
|
-
* Used by matching/not_matching for efficient semi-join operations.
|
|
115
|
-
*
|
|
116
|
-
* @example
|
|
117
|
-
* const keyMap = { first: 'fname', last: 'lname' };
|
|
118
|
-
*
|
|
119
|
-
* // Left side uses left attr names (keys of keyMap)
|
|
120
|
-
* matchKey({ id: 1, first: 'John', last: 'Doe' }, keyMap, 'left');
|
|
121
|
-
* // => '"John"|"Doe"'
|
|
122
|
-
*
|
|
123
|
-
* // Right side uses right attr names (values of keyMap)
|
|
124
|
-
* matchKey({ fname: 'John', lname: 'Doe', age: 30 }, keyMap, 'right');
|
|
125
|
-
* // => '"John"|"Doe"'
|
|
126
|
-
*/
|
|
127
|
-
export declare const matchKey: (tuple: Tuple, keyMap: Record<AttrName, AttrName>, side: 'left' | 'right') => string;
|
|
128
|
-
/**
|
|
129
|
-
* Removes join key attributes from a right tuple when merging.
|
|
130
|
-
* Used to avoid duplicate columns in join results.
|
|
131
|
-
*
|
|
132
|
-
* @example
|
|
133
|
-
* const keyMap = { city: 'location' };
|
|
134
|
-
* projectOutKeys({ location: 'NYC', country: 'USA', pop: 8 }, keyMap);
|
|
135
|
-
* // => { country: 'USA', pop: 8 } (location removed)
|
|
136
|
-
*
|
|
137
|
-
* @example
|
|
138
|
-
* const keyMap = { a: 'a', b: 'b' };
|
|
139
|
-
* projectOutKeys({ a: 1, b: 2, c: 3 }, keyMap);
|
|
140
|
-
* // => { c: 3 } (a and b removed)
|
|
141
|
-
*/
|
|
142
|
-
export declare const projectOutKeys: (tuple: Tuple, keyMap: Record<AttrName, AttrName>) => Tuple;
|
|
1
|
+
import { OperationalOperand, RelationOperand, Renaming, RenamingFunc, Tuple, JoinKeys, AttrName } from "@/types";
|
|
2
|
+
/**
|
|
3
|
+
* Generates a unique string key for a tuple, used for equality comparison and deduplication.
|
|
4
|
+
* Handles nested relations by converting them to sorted tuple keys.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* tupleKey({ name: 'Alice', age: 30 })
|
|
8
|
+
* // => '[["age",30],["name","Alice"]]'
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* tupleKey({ id: 1, items: Bmg([{ x: 1 }, { x: 2 }]) })
|
|
12
|
+
* // => '[["id",1],["items",[...]]]' (nested relation converted to sorted keys)
|
|
13
|
+
*/
|
|
14
|
+
export declare const tupleKey: (tuple: Tuple) => string;
|
|
15
|
+
/**
|
|
16
|
+
* Removes duplicate tuples from an array, preserving order of first occurrence.
|
|
17
|
+
* Uses tupleKey() for equality comparison.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* deduplicate([
|
|
21
|
+
* { id: 1, name: 'Alice' },
|
|
22
|
+
* { id: 2, name: 'Bob' },
|
|
23
|
+
* { id: 1, name: 'Alice' }, // duplicate
|
|
24
|
+
* ])
|
|
25
|
+
* // => [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }]
|
|
26
|
+
*/
|
|
27
|
+
export declare const deduplicate: (tuples: Tuple[]) => Tuple[];
|
|
28
|
+
/**
|
|
29
|
+
* Converts a RelationOperand (Relation or Tuple[]) to an OperationalOperand
|
|
30
|
+
* that provides a uniform interface for iteration and output.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* // With array input, output remains array
|
|
34
|
+
* const op = toOperationalOperand([{ id: 1 }]);
|
|
35
|
+
* [...op.tuples()]; // => [{ id: 1 }]
|
|
36
|
+
* op.output([{ id: 2 }]); // => [{ id: 2 }]
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* // With Relation input, output is a new Relation
|
|
40
|
+
* const op = toOperationalOperand(Bmg([{ id: 1 }]));
|
|
41
|
+
* [...op.tuples()]; // => [{ id: 1 }]
|
|
42
|
+
* op.output([{ id: 2 }]); // => Bmg([{ id: 2 }])
|
|
43
|
+
*/
|
|
44
|
+
export declare const toOperationalOperand: (operand: RelationOperand) => OperationalOperand;
|
|
45
|
+
/**
|
|
46
|
+
* Converts a Renaming (object or function) to a RenamingFunc.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* // Object renaming
|
|
50
|
+
* const fn = toRenamingFunc({ name: 'fullName', age: 'years' });
|
|
51
|
+
* fn('name'); // => 'fullName'
|
|
52
|
+
* fn('age'); // => 'years'
|
|
53
|
+
* fn('other'); // => 'other' (unchanged)
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* // Function renaming (passed through)
|
|
57
|
+
* const fn = toRenamingFunc(attr => attr.toUpperCase());
|
|
58
|
+
* fn('name'); // => 'NAME'
|
|
59
|
+
*/
|
|
60
|
+
export declare const toRenamingFunc: (renaming: Renaming) => RenamingFunc;
|
|
61
|
+
export declare const error: (msg: string) => never;
|
|
62
|
+
/**
|
|
63
|
+
* Finds attribute names that exist in both left and right tuple arrays.
|
|
64
|
+
* Used for natural joins when no explicit keys are provided.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* const left = [{ id: 1, name: 'Alice', city: 'NYC' }];
|
|
68
|
+
* const right = [{ city: 'NYC', country: 'USA' }];
|
|
69
|
+
* getCommonAttrs(left, right);
|
|
70
|
+
* // => ['city']
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* const left = [{ a: 1, b: 2 }];
|
|
74
|
+
* const right = [{ b: 2, c: 3 }];
|
|
75
|
+
* getCommonAttrs(left, right);
|
|
76
|
+
* // => ['b']
|
|
77
|
+
*/
|
|
78
|
+
export declare const getCommonAttrs: (left: Tuple[], right: Tuple[]) => AttrName[];
|
|
79
|
+
/**
|
|
80
|
+
* Normalizes JoinKeys to a Record<AttrName, AttrName> mapping left attrs to right attrs.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* // undefined => use common attributes
|
|
84
|
+
* normalizeKeys(undefined, [{ id: 1, city: 'NYC' }], [{ city: 'NYC' }]);
|
|
85
|
+
* // => { city: 'city' }
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* // Array of common attribute names
|
|
89
|
+
* normalizeKeys(['city', 'country'], leftTuples, rightTuples);
|
|
90
|
+
* // => { city: 'city', country: 'country' }
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* // Object mapping left attr to right attr
|
|
94
|
+
* normalizeKeys({ city: 'location' }, leftTuples, rightTuples);
|
|
95
|
+
* // => { city: 'location' }
|
|
96
|
+
*/
|
|
97
|
+
export declare const normalizeKeys: (keys: JoinKeys | undefined, leftTuples: Tuple[], rightTuples: Tuple[]) => Record<AttrName, AttrName>;
|
|
98
|
+
/**
|
|
99
|
+
* Checks if two tuples match on the specified key mapping.
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* const keyMap = { city: 'location' };
|
|
103
|
+
* tuplesMatch({ id: 1, city: 'NYC' }, { location: 'NYC', pop: 8 }, keyMap);
|
|
104
|
+
* // => true (left.city === right.location)
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* const keyMap = { city: 'city' };
|
|
108
|
+
* tuplesMatch({ city: 'NYC' }, { city: 'LA' }, keyMap);
|
|
109
|
+
* // => false
|
|
110
|
+
*/
|
|
111
|
+
export declare const tuplesMatch: (left: Tuple, right: Tuple, keyMap: Record<AttrName, AttrName>) => boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Creates a string key from a tuple's join attributes for fast Set-based lookups.
|
|
114
|
+
* Used by matching/not_matching for efficient semi-join operations.
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* const keyMap = { first: 'fname', last: 'lname' };
|
|
118
|
+
*
|
|
119
|
+
* // Left side uses left attr names (keys of keyMap)
|
|
120
|
+
* matchKey({ id: 1, first: 'John', last: 'Doe' }, keyMap, 'left');
|
|
121
|
+
* // => '"John"|"Doe"'
|
|
122
|
+
*
|
|
123
|
+
* // Right side uses right attr names (values of keyMap)
|
|
124
|
+
* matchKey({ fname: 'John', lname: 'Doe', age: 30 }, keyMap, 'right');
|
|
125
|
+
* // => '"John"|"Doe"'
|
|
126
|
+
*/
|
|
127
|
+
export declare const matchKey: (tuple: Tuple, keyMap: Record<AttrName, AttrName>, side: 'left' | 'right') => string;
|
|
128
|
+
/**
|
|
129
|
+
* Removes join key attributes from a right tuple when merging.
|
|
130
|
+
* Used to avoid duplicate columns in join results.
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* const keyMap = { city: 'location' };
|
|
134
|
+
* projectOutKeys({ location: 'NYC', country: 'USA', pop: 8 }, keyMap);
|
|
135
|
+
* // => { country: 'USA', pop: 8 } (location removed)
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* const keyMap = { a: 'a', b: 'b' };
|
|
139
|
+
* projectOutKeys({ a: 1, b: 2, c: 3 }, keyMap);
|
|
140
|
+
* // => { c: 3 } (a and b removed)
|
|
141
|
+
*/
|
|
142
|
+
export declare const projectOutKeys: (tuple: Tuple, keyMap: Record<AttrName, AttrName>) => Tuple;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { RelationOperand, AttrName } from "../types";
|
|
2
|
-
export declare const allbut: (operand: RelationOperand, attrs: AttrName[]) => RelationOperand;
|
|
1
|
+
import { RelationOperand, AttrName } from "../types";
|
|
2
|
+
export declare const allbut: (operand: RelationOperand, attrs: AttrName[]) => RelationOperand;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { AutowrapOptions, RelationOperand } from "../types";
|
|
2
|
-
export declare const autowrap: (operand: RelationOperand, options?: AutowrapOptions) => RelationOperand;
|
|
1
|
+
import { AutowrapOptions, RelationOperand } from "../types";
|
|
2
|
+
export declare const autowrap: (operand: RelationOperand, options?: AutowrapOptions) => RelationOperand;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { RelationOperand, Tuple } from "../types";
|
|
2
|
-
export declare const constants: (operand: RelationOperand, consts: Tuple) => RelationOperand;
|
|
1
|
+
import { RelationOperand, Tuple } from "../types";
|
|
2
|
+
export declare const constants: (operand: RelationOperand, consts: Tuple) => RelationOperand;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { RelationOperand } from "../types";
|
|
2
|
-
export declare const cross_product: (left: RelationOperand, right: RelationOperand) => RelationOperand;
|
|
3
|
-
export { cross_product as cross_join };
|
|
1
|
+
import { RelationOperand } from "../types";
|
|
2
|
+
export declare const cross_product: (left: RelationOperand, right: RelationOperand) => RelationOperand;
|
|
3
|
+
export { cross_product as cross_join };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { RelationOperand, Predicate } from "../types";
|
|
2
|
-
export declare const exclude: (operand: RelationOperand, p: Predicate) => RelationOperand;
|
|
1
|
+
import { RelationOperand, Predicate } from "../types";
|
|
2
|
+
export declare const exclude: (operand: RelationOperand, p: Predicate) => RelationOperand;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { RelationOperand, Extension } from "../types";
|
|
2
|
-
export declare const extend: (operand: RelationOperand, extension: Extension) => RelationOperand;
|
|
1
|
+
import { RelationOperand, Extension } from "../types";
|
|
2
|
+
export declare const extend: (operand: RelationOperand, extension: Extension) => RelationOperand;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { RelationOperand, AttrName } from "../types";
|
|
2
|
-
export declare const group: (operand: RelationOperand, attrs: AttrName[], as: AttrName) => RelationOperand;
|
|
1
|
+
import { RelationOperand, AttrName } from "../types";
|
|
2
|
+
export declare const group: (operand: RelationOperand, attrs: AttrName[], as: AttrName) => RelationOperand;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { RelationOperand, JoinKeys, AttrName } from "../types";
|
|
2
|
-
export declare const image: (left: RelationOperand, right: RelationOperand, as: AttrName, keys?: JoinKeys) => RelationOperand;
|
|
1
|
+
import { RelationOperand, JoinKeys, AttrName } from "../types";
|
|
2
|
+
export declare const image: (left: RelationOperand, right: RelationOperand, as: AttrName, keys?: JoinKeys) => RelationOperand;
|
|
@@ -1,30 +1,30 @@
|
|
|
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
|
-
export * from './isRelation';
|
|
28
|
-
export * from './isEqual';
|
|
29
|
-
export * from './one';
|
|
30
|
-
export * from './yByX';
|
|
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
|
+
export * from './isRelation';
|
|
28
|
+
export * from './isEqual';
|
|
29
|
+
export * from './one';
|
|
30
|
+
export * from './yByX';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { RelationOperand } from "../types";
|
|
2
|
-
export declare const intersect: (left: RelationOperand, right: RelationOperand) => RelationOperand;
|
|
1
|
+
import { RelationOperand } from "../types";
|
|
2
|
+
export declare const intersect: (left: RelationOperand, right: RelationOperand) => RelationOperand;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { RelationOperand } from "../types";
|
|
2
|
-
export declare const isEqual: (left: RelationOperand, right: RelationOperand) => boolean;
|
|
1
|
+
import { RelationOperand } from "../types";
|
|
2
|
+
export declare const isEqual: (left: RelationOperand, right: RelationOperand) => boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const isRelation: (op: any) => boolean;
|
|
1
|
+
export declare const isRelation: (op: any) => boolean;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { RelationOperand, JoinKeys } from "../types";
|
|
2
|
-
export declare const join: (left: RelationOperand, right: RelationOperand, keys?: JoinKeys) => RelationOperand;
|
|
1
|
+
import { RelationOperand, JoinKeys } from "../types";
|
|
2
|
+
export declare const join: (left: RelationOperand, right: RelationOperand, keys?: JoinKeys) => RelationOperand;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { RelationOperand, JoinKeys } from "../types";
|
|
2
|
-
export declare const left_join: (left: RelationOperand, right: RelationOperand, keys?: JoinKeys) => RelationOperand;
|
|
1
|
+
import { RelationOperand, JoinKeys } from "../types";
|
|
2
|
+
export declare const left_join: (left: RelationOperand, right: RelationOperand, keys?: JoinKeys) => RelationOperand;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { RelationOperand, JoinKeys } from "../types";
|
|
2
|
-
export declare const matching: (left: RelationOperand, right: RelationOperand, keys?: JoinKeys) => RelationOperand;
|
|
1
|
+
import { RelationOperand, JoinKeys } from "../types";
|
|
2
|
+
export declare const matching: (left: RelationOperand, right: RelationOperand, keys?: JoinKeys) => RelationOperand;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { RelationOperand } from "../types";
|
|
2
|
-
export declare const minus: (left: RelationOperand, right: RelationOperand) => RelationOperand;
|
|
1
|
+
import { RelationOperand } from "../types";
|
|
2
|
+
export declare const minus: (left: RelationOperand, right: RelationOperand) => RelationOperand;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { RelationOperand, JoinKeys } from "../types";
|
|
2
|
-
export declare const not_matching: (left: RelationOperand, right: RelationOperand, keys?: JoinKeys) => RelationOperand;
|
|
1
|
+
import { RelationOperand, JoinKeys } from "../types";
|
|
2
|
+
export declare const not_matching: (left: RelationOperand, right: RelationOperand, keys?: JoinKeys) => RelationOperand;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { RelationOperand, Tuple } from "../types";
|
|
2
|
-
export declare const one: (operand: RelationOperand) => Tuple;
|
|
1
|
+
import { RelationOperand, Tuple } from "../types";
|
|
2
|
+
export declare const one: (operand: RelationOperand) => Tuple;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { PrefixOptions, RelationOperand } from "../types";
|
|
2
|
-
export declare const prefix: (operand: RelationOperand, pfx: string, options?: PrefixOptions) => RelationOperand;
|
|
1
|
+
import { PrefixOptions, RelationOperand } from "../types";
|
|
2
|
+
export declare const prefix: (operand: RelationOperand, pfx: string, options?: PrefixOptions) => RelationOperand;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { RelationOperand, AttrName } from "../types";
|
|
2
|
-
export declare const project: (operand: RelationOperand, attrs: AttrName[]) => RelationOperand;
|
|
1
|
+
import { RelationOperand, AttrName } from "../types";
|
|
2
|
+
export declare const project: (operand: RelationOperand, attrs: AttrName[]) => RelationOperand;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { RelationOperand, Renaming } from "../types";
|
|
2
|
-
export declare const rename: (operand: RelationOperand, renaming: Renaming) => RelationOperand;
|
|
1
|
+
import { RelationOperand, Renaming } from "../types";
|
|
2
|
+
export declare const rename: (operand: RelationOperand, renaming: Renaming) => RelationOperand;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { RelationOperand, Predicate } from "../types";
|
|
2
|
-
export declare const restrict: (operand: RelationOperand, p: Predicate) => RelationOperand;
|
|
1
|
+
import { RelationOperand, Predicate } from "../types";
|
|
2
|
+
export declare const restrict: (operand: RelationOperand, p: Predicate) => RelationOperand;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { RelationOperand, SuffixOptions } from "../types";
|
|
2
|
-
export declare const suffix: (operand: RelationOperand, sfx: string, options?: SuffixOptions) => RelationOperand;
|
|
1
|
+
import { RelationOperand, SuffixOptions } from "../types";
|
|
2
|
+
export declare const suffix: (operand: RelationOperand, sfx: string, options?: SuffixOptions) => RelationOperand;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { RelationOperand, AttrName, Aggregators } from "../types";
|
|
2
|
-
export declare const summarize: (operand: RelationOperand, by: AttrName[], aggs: Aggregators) => RelationOperand;
|
|
1
|
+
import { RelationOperand, AttrName, Aggregators } from "../types";
|
|
2
|
+
export declare const summarize: (operand: RelationOperand, by: AttrName[], aggs: Aggregators) => RelationOperand;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { RelationOperand, Transformation } from "../types";
|
|
2
|
-
export declare const transform: (operand: RelationOperand, transformation: Transformation) => RelationOperand;
|
|
1
|
+
import { RelationOperand, Transformation } from "../types";
|
|
2
|
+
export declare const transform: (operand: RelationOperand, transformation: Transformation) => RelationOperand;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { RelationOperand, AttrName } from "../types";
|
|
2
|
-
export declare const ungroup: (operand: RelationOperand, attr: AttrName) => RelationOperand;
|
|
1
|
+
import { RelationOperand, AttrName } from "../types";
|
|
2
|
+
export declare const ungroup: (operand: RelationOperand, attr: AttrName) => RelationOperand;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { RelationOperand } from "../types";
|
|
2
|
-
export declare const union: (left: RelationOperand, right: RelationOperand) => RelationOperand;
|
|
1
|
+
import { RelationOperand } from "../types";
|
|
2
|
+
export declare const union: (left: RelationOperand, right: RelationOperand) => RelationOperand;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { RelationOperand, AttrName } from "../types";
|
|
2
|
-
export declare const unwrap: (operand: RelationOperand, attr: AttrName) => RelationOperand;
|
|
1
|
+
import { RelationOperand, AttrName } from "../types";
|
|
2
|
+
export declare const unwrap: (operand: RelationOperand, attr: AttrName) => RelationOperand;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { restrict as where } from './restrict';
|
|
1
|
+
export { restrict as where } from './restrict';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { RelationOperand, AttrName } from "../types";
|
|
2
|
-
export declare const wrap: (operand: RelationOperand, attrs: AttrName[], as: AttrName) => RelationOperand;
|
|
1
|
+
import { RelationOperand, AttrName } from "../types";
|
|
2
|
+
export declare const wrap: (operand: RelationOperand, attrs: AttrName[], as: AttrName) => RelationOperand;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { AttrName, RelationOperand, Tuple } from "../types";
|
|
2
|
-
export declare const yByX: (operand: RelationOperand, y: AttrName, x: AttrName) => Tuple;
|
|
1
|
+
import { AttrName, RelationOperand, Tuple } from "../types";
|
|
2
|
+
export declare const yByX: (operand: RelationOperand, y: AttrName, x: AttrName) => Tuple;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Predicate, PredicateFunc } from '../types';
|
|
2
|
-
export declare const toPredicateFunc: (p: Predicate) => PredicateFunc;
|
|
1
|
+
import { Predicate, PredicateFunc } from '../types';
|
|
2
|
+
export declare const toPredicateFunc: (p: Predicate) => PredicateFunc;
|