@enspirit/bmg-js 1.0.2 → 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/README.md +3 -2
- package/dist/AsyncRelation/Base.d.ts +47 -0
- package/dist/AsyncRelation/index.d.ts +25 -0
- package/dist/Relation/Memory.d.ts +2 -1
- package/dist/Relation/index.d.ts +1 -1
- 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 +14 -3
- package/dist/lib-definitions.d.ts +1 -1
- package/dist/operators/index.d.ts +1 -30
- package/dist/operators/isEqual.d.ts +1 -2
- package/dist/operators/isRelation.d.ts +2 -1
- package/dist/sync/Relation/Memory.d.ts +46 -0
- package/dist/sync/Relation/index.d.ts +1 -0
- package/dist/sync/operators/_helpers.d.ts +142 -0
- package/dist/sync/operators/allbut.d.ts +2 -0
- package/dist/sync/operators/autowrap.d.ts +2 -0
- package/dist/sync/operators/constants.d.ts +2 -0
- package/dist/sync/operators/cross_product.d.ts +3 -0
- package/dist/sync/operators/exclude.d.ts +2 -0
- package/dist/sync/operators/extend.d.ts +2 -0
- package/dist/sync/operators/group.d.ts +2 -0
- package/dist/sync/operators/image.d.ts +2 -0
- package/dist/sync/operators/index.d.ts +30 -0
- package/dist/sync/operators/intersect.d.ts +2 -0
- package/dist/sync/operators/isEqual.d.ts +1 -0
- package/dist/sync/operators/isRelation.d.ts +2 -0
- package/dist/sync/operators/join.d.ts +2 -0
- package/dist/sync/operators/left_join.d.ts +2 -0
- package/dist/sync/operators/matching.d.ts +2 -0
- package/dist/sync/operators/minus.d.ts +2 -0
- package/dist/sync/operators/not_matching.d.ts +2 -0
- package/dist/sync/operators/one.d.ts +2 -0
- package/dist/sync/operators/prefix.d.ts +2 -0
- package/dist/sync/operators/project.d.ts +2 -0
- package/dist/sync/operators/rename.d.ts +2 -0
- package/dist/sync/operators/restrict.d.ts +2 -0
- package/dist/sync/operators/suffix.d.ts +2 -0
- package/dist/sync/operators/summarize.d.ts +2 -0
- package/dist/sync/operators/transform.d.ts +2 -0
- package/dist/sync/operators/ungroup.d.ts +2 -0
- package/dist/sync/operators/union.d.ts +2 -0
- package/dist/sync/operators/unwrap.d.ts +2 -0
- package/dist/sync/operators/wrap.d.ts +2 -0
- package/dist/sync/operators/yByX.d.ts +2 -0
- package/dist/types.d.ts +7 -0
- package/dist/writer/Text.d.ts +40 -0
- package/dist/writer/index.d.ts +1 -0
- package/package.json +1 -1
- 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 +16 -3
- package/src/lib-definitions.ts +11 -0
- package/src/operators/index.ts +2 -31
- package/src/{Relation → sync/Relation}/Memory.ts +9 -1
- package/src/sync/Relation/index.ts +1 -0
- 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/src/sync/operators/where.ts +1 -0
- package/src/{operators → sync/operators}/wrap.ts +1 -1
- package/src/{operators → sync/operators}/yByX.ts +1 -1
- package/src/types.ts +11 -0
- package/src/writer/Text.ts +305 -0
- package/src/writer/index.ts +1 -0
- package/src/operators/isRelation.ts +0 -5
- /package/{src/operators/where.ts → dist/sync/operators/where.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -111,6 +111,7 @@ See the [full type-safe example](./example/index.ts) for more.
|
|
|
111
111
|
| | `toArray()` | Convert relation to array |
|
|
112
112
|
| | `isEqual(other)` | Check set equality |
|
|
113
113
|
| | `yByX(y, x)` | Create `{ x-value: y-value }` mapping |
|
|
114
|
+
| | `toText(options?)` | Render as ASCII table |
|
|
114
115
|
| | `Bmg.isRelation(value)` | Check if value is a Relation (static) |
|
|
115
116
|
|
|
116
117
|
Built-in aggregators for `summarize`: `count`, `sum`, `min`, `max`, `avg`, `collect`
|
|
@@ -139,9 +140,9 @@ This will be provided by [Elo](https://elo-lang.org).
|
|
|
139
140
|
|
|
140
141
|
## Versioning
|
|
141
142
|
|
|
142
|
-
Bmg.js follows [Semantic Versioning](https://semver.org/) (SemVer)
|
|
143
|
+
Bmg.js follows [Semantic Versioning](https://semver.org/) (SemVer). See [API.md](API.md) for the public API reference.
|
|
143
144
|
|
|
144
|
-
- **MAJOR** (x.0.0) - Breaking changes to the API
|
|
145
|
+
- **MAJOR** (x.0.0) - Breaking changes to the public API
|
|
145
146
|
- **MINOR** (0.x.0) - New operators or features, fully backward-compatible
|
|
146
147
|
- **PATCH** (0.0.x) - Bug fixes and performance improvements, no API changes
|
|
147
148
|
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { AsyncRelation, AsyncRelationOperand } from '../async-types';
|
|
2
|
+
import type { Tuple, TypedPredicate, TypedExtension, Relation, RenameMap, Renamed, Prefixed, Suffixed, Transformation, JoinKeys, Aggregators, AutowrapOptions, TextOptions } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Base implementation of AsyncRelation using lazy evaluation.
|
|
5
|
+
* Each operator returns a new BaseAsyncRelation wrapping the transformed iterable.
|
|
6
|
+
*/
|
|
7
|
+
export declare class BaseAsyncRelation<T = Tuple> implements AsyncRelation<T> {
|
|
8
|
+
private source;
|
|
9
|
+
constructor(source: AsyncIterable<T>);
|
|
10
|
+
restrict(p: TypedPredicate<T>): AsyncRelation<T>;
|
|
11
|
+
where(p: TypedPredicate<T>): AsyncRelation<T>;
|
|
12
|
+
exclude(p: TypedPredicate<T>): AsyncRelation<T>;
|
|
13
|
+
project<K extends keyof T>(attrs: K[]): AsyncRelation<Pick<T, K>>;
|
|
14
|
+
allbut<K extends keyof T>(attrs: K[]): AsyncRelation<Omit<T, K>>;
|
|
15
|
+
extend<E extends Record<string, unknown>>(e: TypedExtension<T, E>): AsyncRelation<T & E>;
|
|
16
|
+
constants<C extends Tuple>(consts: C): AsyncRelation<T & C>;
|
|
17
|
+
rename<R extends RenameMap<T>>(r: R): AsyncRelation<Renamed<T, R>>;
|
|
18
|
+
prefix<P extends string, Ex extends keyof T = never>(pfx: P, options?: {
|
|
19
|
+
except?: Ex[];
|
|
20
|
+
}): AsyncRelation<Prefixed<T, P, Ex>>;
|
|
21
|
+
suffix<S extends string, Ex extends keyof T = never>(sfx: S, options?: {
|
|
22
|
+
except?: Ex[];
|
|
23
|
+
}): AsyncRelation<Suffixed<T, S, Ex>>;
|
|
24
|
+
transform(t: Transformation): AsyncRelation<T>;
|
|
25
|
+
union(other: AsyncRelationOperand<T>): AsyncRelation<T>;
|
|
26
|
+
minus(other: AsyncRelationOperand<T>): AsyncRelation<T>;
|
|
27
|
+
intersect(other: AsyncRelationOperand<T>): AsyncRelation<T>;
|
|
28
|
+
matching<U>(other: AsyncRelationOperand<U>, keys?: JoinKeys): AsyncRelation<T>;
|
|
29
|
+
not_matching<U>(other: AsyncRelationOperand<U>, keys?: JoinKeys): AsyncRelation<T>;
|
|
30
|
+
join<U>(other: AsyncRelationOperand<U>, keys?: JoinKeys): AsyncRelation<T & U>;
|
|
31
|
+
left_join<U>(other: AsyncRelationOperand<U>, keys?: JoinKeys): AsyncRelation<T & Partial<U>>;
|
|
32
|
+
cross_product<U>(other: AsyncRelationOperand<U>): AsyncRelation<T & U>;
|
|
33
|
+
cross_join<U>(other: AsyncRelationOperand<U>): AsyncRelation<T & U>;
|
|
34
|
+
group<K extends keyof T>(attrs: K[], as: string): AsyncRelation<Omit<T, K> & Record<string, Relation<Pick<T, K>>>>;
|
|
35
|
+
ungroup(attr: string): AsyncRelation<Tuple>;
|
|
36
|
+
wrap<K extends keyof T>(attrs: K[], as: string): AsyncRelation<Omit<T, K> & Record<string, Pick<T, K>>>;
|
|
37
|
+
unwrap(attr: string): AsyncRelation<Tuple>;
|
|
38
|
+
image<U>(other: AsyncRelationOperand<U>, as: string, keys?: JoinKeys): AsyncRelation<T & Record<string, Relation<U>>>;
|
|
39
|
+
summarize<K extends keyof T>(by: K[], aggs: Aggregators): AsyncRelation<Pick<T, K> & Tuple>;
|
|
40
|
+
autowrap(options?: AutowrapOptions): AsyncRelation<Tuple>;
|
|
41
|
+
one(): Promise<T>;
|
|
42
|
+
toArray(): Promise<T[]>;
|
|
43
|
+
toRelation(): Promise<Relation<T>>;
|
|
44
|
+
yByX(y: string, x: string): Promise<Tuple>;
|
|
45
|
+
toText(options?: TextOptions): Promise<string>;
|
|
46
|
+
[Symbol.asyncIterator](): AsyncIterator<T>;
|
|
47
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { BaseAsyncRelation } from './Base';
|
|
2
|
+
import type { AsyncRelation, AsyncRelationOperand } from '../async-types';
|
|
3
|
+
export { BaseAsyncRelation };
|
|
4
|
+
/**
|
|
5
|
+
* Creates a new async relation from an AsyncIterable source.
|
|
6
|
+
*
|
|
7
|
+
* @typeParam T - The tuple type. Inferred from input or explicitly provided.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* // From an async iterable
|
|
11
|
+
* const suppliers = AsyncBmg(fetchSuppliersFromDB());
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* // Chained operations (lazy - no execution yet)
|
|
15
|
+
* const query = AsyncBmg(source)
|
|
16
|
+
* .restrict({ city: 'London' })
|
|
17
|
+
* .project(['sid', 'name']);
|
|
18
|
+
*
|
|
19
|
+
* // Terminal operation triggers execution
|
|
20
|
+
* const results = await query.toArray();
|
|
21
|
+
*/
|
|
22
|
+
export declare function AsyncBmg<T>(source: AsyncIterable<T>): AsyncRelation<T>;
|
|
23
|
+
export declare namespace AsyncBmg {
|
|
24
|
+
var isEqual: <T, U>(left: AsyncRelationOperand<T>, right: AsyncRelationOperand<U>) => Promise<boolean>;
|
|
25
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AutowrapOptions, Relation, RelationOperand, Transformation, Tuple, TypedPredicate, TypedExtension, RenameMap, Renamed, Prefixed, Suffixed, Joined, LeftJoined, Wrapped, Unwrapped, Ungrouped, AggregatorResults, TypedJoinKeysArray, TypedJoinKeysObject } from "../types";
|
|
1
|
+
import type { AutowrapOptions, Relation, RelationOperand, TextOptions, Transformation, Tuple, TypedPredicate, TypedExtension, RenameMap, Renamed, Prefixed, Suffixed, Joined, LeftJoined, Wrapped, Unwrapped, Ungrouped, AggregatorResults, TypedJoinKeysArray, TypedJoinKeysObject } from "../types";
|
|
2
2
|
/**
|
|
3
3
|
* In-memory implementation of the Relation interface.
|
|
4
4
|
*
|
|
@@ -42,4 +42,5 @@ export declare class MemoryRelation<T = Tuple> implements Relation<T> {
|
|
|
42
42
|
toArray(): T[];
|
|
43
43
|
yByX<Y extends keyof T, X extends keyof T>(y: Y, x: X): Record<T[X] & PropertyKey, T[Y]>;
|
|
44
44
|
isEqual(right: any): boolean;
|
|
45
|
+
toText(options?: TextOptions): string;
|
|
45
46
|
}
|
package/dist/Relation/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from '
|
|
1
|
+
export * from '../sync/Relation';
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { AsyncRelation, AsyncRelationOperand } from '../types';
|
|
2
|
+
import type { Tuple, TypedPredicate, TypedExtension, Relation, RenameMap, Renamed, Prefixed, Suffixed, Transformation, JoinKeys, Aggregators, AutowrapOptions, TextOptions } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Base implementation of AsyncRelation using lazy evaluation.
|
|
5
|
+
* Each operator returns a new BaseAsyncRelation wrapping the transformed iterable.
|
|
6
|
+
*/
|
|
7
|
+
export declare class BaseAsyncRelation<T = Tuple> implements AsyncRelation<T> {
|
|
8
|
+
private source;
|
|
9
|
+
constructor(source: AsyncIterable<T>);
|
|
10
|
+
restrict(p: TypedPredicate<T>): AsyncRelation<T>;
|
|
11
|
+
where(p: TypedPredicate<T>): AsyncRelation<T>;
|
|
12
|
+
exclude(p: TypedPredicate<T>): AsyncRelation<T>;
|
|
13
|
+
project<K extends keyof T>(attrs: K[]): AsyncRelation<Pick<T, K>>;
|
|
14
|
+
allbut<K extends keyof T>(attrs: K[]): AsyncRelation<Omit<T, K>>;
|
|
15
|
+
extend<E extends Record<string, unknown>>(e: TypedExtension<T, E>): AsyncRelation<T & E>;
|
|
16
|
+
constants<C extends Tuple>(consts: C): AsyncRelation<T & C>;
|
|
17
|
+
rename<R extends RenameMap<T>>(r: R): AsyncRelation<Renamed<T, R>>;
|
|
18
|
+
prefix<P extends string, Ex extends keyof T = never>(pfx: P, options?: {
|
|
19
|
+
except?: Ex[];
|
|
20
|
+
}): AsyncRelation<Prefixed<T, P, Ex>>;
|
|
21
|
+
suffix<S extends string, Ex extends keyof T = never>(sfx: S, options?: {
|
|
22
|
+
except?: Ex[];
|
|
23
|
+
}): AsyncRelation<Suffixed<T, S, Ex>>;
|
|
24
|
+
transform(t: Transformation): AsyncRelation<T>;
|
|
25
|
+
union(other: AsyncRelationOperand<T>): AsyncRelation<T>;
|
|
26
|
+
minus(other: AsyncRelationOperand<T>): AsyncRelation<T>;
|
|
27
|
+
intersect(other: AsyncRelationOperand<T>): AsyncRelation<T>;
|
|
28
|
+
matching<U>(other: AsyncRelationOperand<U>, keys?: JoinKeys): AsyncRelation<T>;
|
|
29
|
+
not_matching<U>(other: AsyncRelationOperand<U>, keys?: JoinKeys): AsyncRelation<T>;
|
|
30
|
+
join<U>(other: AsyncRelationOperand<U>, keys?: JoinKeys): AsyncRelation<T & U>;
|
|
31
|
+
left_join<U>(other: AsyncRelationOperand<U>, keys?: JoinKeys): AsyncRelation<T & Partial<U>>;
|
|
32
|
+
cross_product<U>(other: AsyncRelationOperand<U>): AsyncRelation<T & U>;
|
|
33
|
+
cross_join<U>(other: AsyncRelationOperand<U>): AsyncRelation<T & U>;
|
|
34
|
+
group<K extends keyof T>(attrs: K[], as: string): AsyncRelation<Omit<T, K> & Record<string, Relation<Pick<T, K>>>>;
|
|
35
|
+
ungroup(attr: string): AsyncRelation<Tuple>;
|
|
36
|
+
wrap<K extends keyof T>(attrs: K[], as: string): AsyncRelation<Omit<T, K> & Record<string, Pick<T, K>>>;
|
|
37
|
+
unwrap(attr: string): AsyncRelation<Tuple>;
|
|
38
|
+
image<U>(other: AsyncRelationOperand<U>, as: string, keys?: JoinKeys): AsyncRelation<T & Record<string, Relation<U>>>;
|
|
39
|
+
summarize<K extends keyof T>(by: K[], aggs: Aggregators): AsyncRelation<Pick<T, K> & Tuple>;
|
|
40
|
+
autowrap(options?: AutowrapOptions): AsyncRelation<Tuple>;
|
|
41
|
+
one(): Promise<T>;
|
|
42
|
+
toArray(): Promise<T[]>;
|
|
43
|
+
toRelation(): Promise<Relation<T>>;
|
|
44
|
+
yByX(y: string, x: string): Promise<Tuple>;
|
|
45
|
+
toText(options?: TextOptions): Promise<string>;
|
|
46
|
+
[Symbol.asyncIterator](): AsyncIterator<T>;
|
|
47
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { BaseAsyncRelation } from './Base';
|
|
2
|
+
import type { AsyncRelation, AsyncRelationOperand } from '../types';
|
|
3
|
+
export { BaseAsyncRelation };
|
|
4
|
+
/**
|
|
5
|
+
* Creates a new async relation from an AsyncIterable source.
|
|
6
|
+
*
|
|
7
|
+
* @typeParam T - The tuple type. Inferred from input or explicitly provided.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* // From an async iterable
|
|
11
|
+
* const suppliers = AsyncBmg(fetchSuppliersFromDB());
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* // Chained operations (lazy - no execution yet)
|
|
15
|
+
* const query = AsyncBmg(source)
|
|
16
|
+
* .restrict({ city: 'London' })
|
|
17
|
+
* .project(['sid', 'name']);
|
|
18
|
+
*
|
|
19
|
+
* // Terminal operation triggers execution
|
|
20
|
+
* const results = await query.toArray();
|
|
21
|
+
*/
|
|
22
|
+
export declare function AsyncBmg<T>(source: AsyncIterable<T>): AsyncRelation<T>;
|
|
23
|
+
export declare namespace AsyncBmg {
|
|
24
|
+
var isEqual: <T, U>(left: AsyncRelationOperand<T>, right: AsyncRelationOperand<U>) => Promise<boolean>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AsyncRelationOperand, AsyncOperationalOperand, AsyncRelation } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Type guard to check if a value implements AsyncRelation.
|
|
4
|
+
*/
|
|
5
|
+
export declare const isAsyncRelation: <T>(value: unknown) => value is AsyncRelation<T>;
|
|
6
|
+
/**
|
|
7
|
+
* Converts an AsyncRelationOperand to an AsyncOperationalOperand
|
|
8
|
+
* that provides a uniform interface for async iteration and output.
|
|
9
|
+
*/
|
|
10
|
+
export declare const toAsyncOperationalOperand: <T>(operand: AsyncRelationOperand<T>) => AsyncOperationalOperand<T>;
|
|
11
|
+
/**
|
|
12
|
+
* Async generator that removes duplicate tuples.
|
|
13
|
+
* Uses tupleKey() for equality comparison.
|
|
14
|
+
*/
|
|
15
|
+
export declare function deduplicateAsync<T>(source: AsyncIterable<T>): AsyncGenerator<T>;
|
|
16
|
+
export declare const error: (msg: string) => never;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AsyncRelationOperand } from '../types';
|
|
2
|
+
import type { AutowrapOptions, Tuple } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Automatically wraps attributes based on naming convention.
|
|
5
|
+
* Attributes with separator (default '_') are grouped into nested objects.
|
|
6
|
+
*/
|
|
7
|
+
export declare function autowrap<T>(operand: AsyncRelationOperand<T>, options?: AutowrapOptions): AsyncIterable<Tuple>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AsyncRelationOperand } from '../types';
|
|
2
|
+
import type { Tuple } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Cartesian product: combines every left tuple with every right tuple.
|
|
5
|
+
* Left attributes override right on clash. Removes duplicates.
|
|
6
|
+
* Materializes both sides.
|
|
7
|
+
*/
|
|
8
|
+
export declare function cross_product<T, U>(left: AsyncRelationOperand<T>, right: AsyncRelationOperand<U>): AsyncIterable<Tuple>;
|
|
9
|
+
export { cross_product as cross_join };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AsyncRelationOperand } from '../types';
|
|
2
|
+
import type { Extension, Tuple } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Extends each tuple with new attributes.
|
|
5
|
+
* Extension can be functions (computed) or attribute names (copied).
|
|
6
|
+
*/
|
|
7
|
+
export declare const extend: <T>(operand: AsyncRelationOperand<T>, extension: Extension) => AsyncIterable<Tuple>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AsyncRelationOperand } from '../types';
|
|
2
|
+
import type { AttrName, Tuple } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Groups specified attributes into a nested relation.
|
|
5
|
+
* Materializes all tuples to perform grouping.
|
|
6
|
+
*/
|
|
7
|
+
export declare function group<T>(operand: AsyncRelationOperand<T>, attrs: AttrName[], as: AttrName): AsyncIterable<Tuple>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AsyncRelationOperand } from '../types';
|
|
2
|
+
import type { JoinKeys, Tuple, AttrName } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Adds a relation-valued attribute with matching tuples from right.
|
|
5
|
+
* Each left tuple gets a nested relation of matching right tuples.
|
|
6
|
+
* Materializes both sides.
|
|
7
|
+
*/
|
|
8
|
+
export declare function image<T, U>(left: AsyncRelationOperand<T>, right: AsyncRelationOperand<U>, as: AttrName, keys?: JoinKeys): AsyncIterable<Tuple>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export { restrict, where, exclude } from './restrict';
|
|
2
|
+
export { project, allbut } from './project';
|
|
3
|
+
export { extend } from './extend';
|
|
4
|
+
export { constants } from './constants';
|
|
5
|
+
export { rename } from './rename';
|
|
6
|
+
export { prefix } from './prefix';
|
|
7
|
+
export { suffix } from './suffix';
|
|
8
|
+
export { transform } from './transform';
|
|
9
|
+
export { union } from './union';
|
|
10
|
+
export { minus } from './minus';
|
|
11
|
+
export { intersect } from './intersect';
|
|
12
|
+
export { matching } from './matching';
|
|
13
|
+
export { not_matching } from './not_matching';
|
|
14
|
+
export { join } from './join';
|
|
15
|
+
export { left_join } from './left_join';
|
|
16
|
+
export { cross_product, cross_join } from './cross_product';
|
|
17
|
+
export { group } from './group';
|
|
18
|
+
export { ungroup } from './ungroup';
|
|
19
|
+
export { wrap } from './wrap';
|
|
20
|
+
export { unwrap } from './unwrap';
|
|
21
|
+
export { image } from './image';
|
|
22
|
+
export { summarize } from './summarize';
|
|
23
|
+
export { autowrap } from './autowrap';
|
|
24
|
+
export { yByX } from './yByX';
|
|
25
|
+
export { isEqual } from './isEqual';
|
|
26
|
+
export { one } from './one';
|
|
27
|
+
export { toArray } from './toArray';
|
|
28
|
+
export { isAsyncRelation, toAsyncOperationalOperand, deduplicateAsync } from './_helpers';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AsyncRelationOperand } from '../types';
|
|
2
|
+
import type { Tuple } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Set intersection: returns tuples present in both relations.
|
|
5
|
+
* Materializes right side first, then streams left.
|
|
6
|
+
*/
|
|
7
|
+
export declare function intersect<T>(left: AsyncRelationOperand<T>, right: AsyncRelationOperand<T>): AsyncIterable<Tuple>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AsyncRelationOperand } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Compares two async relations for equality.
|
|
4
|
+
* Two relations are equal if they contain the exact same set of tuples.
|
|
5
|
+
* Terminal operation - returns a Promise.
|
|
6
|
+
*/
|
|
7
|
+
export declare const isEqual: <T, U>(left: AsyncRelationOperand<T>, right: AsyncRelationOperand<U>) => Promise<boolean>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AsyncRelationOperand } from '../types';
|
|
2
|
+
import type { JoinKeys, Tuple } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Natural join: combines tuples from left and right where join keys match.
|
|
5
|
+
* Materializes both sides (needed for key detection and nested loop join).
|
|
6
|
+
*/
|
|
7
|
+
export declare function join<T, U>(left: AsyncRelationOperand<T>, right: AsyncRelationOperand<U>, keys?: JoinKeys): AsyncIterable<Tuple>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AsyncRelationOperand } from '../types';
|
|
2
|
+
import type { JoinKeys, Tuple } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Left outer join: combines tuples, keeping all left tuples.
|
|
5
|
+
* Non-matching left tuples have null for right attributes.
|
|
6
|
+
* Materializes both sides.
|
|
7
|
+
*/
|
|
8
|
+
export declare function left_join<T, U>(left: AsyncRelationOperand<T>, right: AsyncRelationOperand<U>, keys?: JoinKeys): AsyncIterable<Tuple>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AsyncRelationOperand } from '../types';
|
|
2
|
+
import type { JoinKeys, Tuple } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Semi-join: returns tuples from left that have a matching tuple in right.
|
|
5
|
+
* Materializes right side first to build key set.
|
|
6
|
+
*/
|
|
7
|
+
export declare function matching<T, U>(left: AsyncRelationOperand<T>, right: AsyncRelationOperand<U>, keys?: JoinKeys): AsyncIterable<Tuple>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AsyncRelationOperand } from '../types';
|
|
2
|
+
import type { Tuple } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Set difference: returns tuples in left but not in right.
|
|
5
|
+
* Materializes right side first, then streams left.
|
|
6
|
+
*/
|
|
7
|
+
export declare function minus<T>(left: AsyncRelationOperand<T>, right: AsyncRelationOperand<T>): AsyncIterable<Tuple>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AsyncRelationOperand } from '../types';
|
|
2
|
+
import type { JoinKeys, Tuple } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Anti semi-join: returns tuples from left that have no matching tuple in right.
|
|
5
|
+
* Materializes right side first to build key set.
|
|
6
|
+
*/
|
|
7
|
+
export declare function not_matching<T, U>(left: AsyncRelationOperand<T>, right: AsyncRelationOperand<U>, keys?: JoinKeys): AsyncIterable<Tuple>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AsyncRelationOperand } from '../types';
|
|
2
|
+
import type { PrefixOptions, Tuple } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Prefixes all attribute names (except those in options.except).
|
|
5
|
+
*/
|
|
6
|
+
export declare const prefix: <T>(operand: AsyncRelationOperand<T>, pfx: string, options?: PrefixOptions) => AsyncIterable<Tuple>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AsyncRelationOperand } from '../types';
|
|
2
|
+
import type { Tuple, AttrName } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Projects tuples to specified attributes with deduplication.
|
|
5
|
+
*/
|
|
6
|
+
export declare const project: <T>(operand: AsyncRelationOperand<T>, attrs: AttrName[]) => AsyncIterable<Tuple>;
|
|
7
|
+
/**
|
|
8
|
+
* Projects out (removes) specified attributes with deduplication.
|
|
9
|
+
*/
|
|
10
|
+
export declare const allbut: <T>(operand: AsyncRelationOperand<T>, attrs: AttrName[]) => AsyncIterable<Tuple>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AsyncRelationOperand } from '../types';
|
|
2
|
+
import type { Renaming, Tuple } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Renames attributes in each tuple.
|
|
5
|
+
*/
|
|
6
|
+
export declare const rename: <T>(operand: AsyncRelationOperand<T>, renaming: Renaming) => AsyncIterable<Tuple>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { AsyncRelationOperand } from '../types';
|
|
2
|
+
import type { Predicate } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Filters tuples that match the predicate.
|
|
5
|
+
*/
|
|
6
|
+
export declare const restrict: <T>(operand: AsyncRelationOperand<T>, p: Predicate) => AsyncIterable<T>;
|
|
7
|
+
/**
|
|
8
|
+
* Alias for restrict.
|
|
9
|
+
*/
|
|
10
|
+
export declare const where: <T>(operand: AsyncRelationOperand<T>, p: Predicate) => AsyncIterable<T>;
|
|
11
|
+
/**
|
|
12
|
+
* Filters tuples that do NOT match the predicate.
|
|
13
|
+
*/
|
|
14
|
+
export declare const exclude: <T>(operand: AsyncRelationOperand<T>, p: Predicate) => AsyncIterable<T>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AsyncRelationOperand } from '../types';
|
|
2
|
+
import type { SuffixOptions, Tuple } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Suffixes all attribute names (except those in options.except).
|
|
5
|
+
*/
|
|
6
|
+
export declare const suffix: <T>(operand: AsyncRelationOperand<T>, sfx: string, options?: SuffixOptions) => AsyncIterable<Tuple>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AsyncRelationOperand } from '../types';
|
|
2
|
+
import type { AttrName, Tuple, Aggregators } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Aggregates tuples by grouping attributes.
|
|
5
|
+
* Supports count, sum, min, max, avg, collect, and custom functions.
|
|
6
|
+
* Materializes all tuples to perform grouping.
|
|
7
|
+
*/
|
|
8
|
+
export declare function summarize<T>(operand: AsyncRelationOperand<T>, by: AttrName[], aggs: Aggregators): AsyncIterable<Tuple>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AsyncRelationOperand } from '../types';
|
|
2
|
+
import type { Transformation, Tuple } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Applies transformation functions to attribute values.
|
|
5
|
+
* - Single function: applies to all values
|
|
6
|
+
* - Array of functions: chains them in order
|
|
7
|
+
* - Object with attr keys: applies per-attribute transformers
|
|
8
|
+
*/
|
|
9
|
+
export declare function transform<T>(operand: AsyncRelationOperand<T>, transformation: Transformation): AsyncIterable<Tuple>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AsyncRelationOperand } from '../types';
|
|
2
|
+
import type { AttrName, Tuple } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Flattens a nested relation attribute back into parent tuples.
|
|
5
|
+
* Materializes all tuples to perform ungrouping.
|
|
6
|
+
*/
|
|
7
|
+
export declare function ungroup<T>(operand: AsyncRelationOperand<T>, attr: AttrName): AsyncIterable<Tuple>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AsyncRelationOperand } from '../types';
|
|
2
|
+
import type { Tuple } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Combines tuples from two relations, removing duplicates.
|
|
5
|
+
*/
|
|
6
|
+
export declare function union<T>(left: AsyncRelationOperand<T>, right: AsyncRelationOperand<T>): AsyncIterable<Tuple>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AsyncRelationOperand } from '../types';
|
|
2
|
+
import type { AttrName, Tuple } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Unwraps a nested object attribute back into the parent tuple.
|
|
5
|
+
*/
|
|
6
|
+
export declare function unwrap<T>(operand: AsyncRelationOperand<T>, attr: AttrName): AsyncIterable<Tuple>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AsyncRelationOperand } from '../types';
|
|
2
|
+
import type { AttrName, Tuple } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Wraps specified attributes into a nested object.
|
|
5
|
+
*/
|
|
6
|
+
export declare function wrap<T>(operand: AsyncRelationOperand<T>, attrs: AttrName[], as: AttrName): AsyncIterable<Tuple>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AsyncRelationOperand } from '../types';
|
|
2
|
+
import type { AttrName, Tuple } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Builds a key-value map from two attributes.
|
|
5
|
+
* Terminal operation - returns a Promise.
|
|
6
|
+
*/
|
|
7
|
+
export declare const yByX: <T>(operand: AsyncRelationOperand<T>, y: AttrName, x: AttrName) => Promise<Tuple>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { Tuple, TypedPredicate, Relation, TypedExtension, RenameMap, Renamed, Prefixed, Suffixed, Transformation, JoinKeys, AttrName, Aggregators, AutowrapOptions, TextOptions } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Async version of the Relation interface.
|
|
4
|
+
* Operations are lazy - they build a pipeline that executes only when
|
|
5
|
+
* a terminal method (one(), toArray()) is awaited.
|
|
6
|
+
*
|
|
7
|
+
* @typeParam T - The tuple type for this relation.
|
|
8
|
+
*/
|
|
9
|
+
export interface AsyncRelation<T = Tuple> {
|
|
10
|
+
restrict(p: TypedPredicate<T>): AsyncRelation<T>;
|
|
11
|
+
where(p: TypedPredicate<T>): AsyncRelation<T>;
|
|
12
|
+
exclude(p: TypedPredicate<T>): AsyncRelation<T>;
|
|
13
|
+
project<K extends keyof T>(attrs: K[]): AsyncRelation<Pick<T, K>>;
|
|
14
|
+
allbut<K extends keyof T>(attrs: K[]): AsyncRelation<Omit<T, K>>;
|
|
15
|
+
extend<E extends Record<string, unknown>>(e: TypedExtension<T, E>): AsyncRelation<T & E>;
|
|
16
|
+
constants<C extends Tuple>(consts: C): AsyncRelation<T & C>;
|
|
17
|
+
rename<R extends RenameMap<T>>(r: R): AsyncRelation<Renamed<T, R>>;
|
|
18
|
+
prefix<P extends string, Ex extends keyof T = never>(pfx: P, options?: {
|
|
19
|
+
except?: Ex[];
|
|
20
|
+
}): AsyncRelation<Prefixed<T, P, Ex>>;
|
|
21
|
+
suffix<S extends string, Ex extends keyof T = never>(sfx: S, options?: {
|
|
22
|
+
except?: Ex[];
|
|
23
|
+
}): AsyncRelation<Suffixed<T, S, Ex>>;
|
|
24
|
+
transform(t: Transformation): AsyncRelation<T>;
|
|
25
|
+
union(other: AsyncRelationOperand<T>): AsyncRelation<T>;
|
|
26
|
+
minus(other: AsyncRelationOperand<T>): AsyncRelation<T>;
|
|
27
|
+
intersect(other: AsyncRelationOperand<T>): AsyncRelation<T>;
|
|
28
|
+
matching<U = Tuple>(other: AsyncRelationOperand<U>, keys?: JoinKeys): AsyncRelation<T>;
|
|
29
|
+
not_matching<U = Tuple>(other: AsyncRelationOperand<U>, keys?: JoinKeys): AsyncRelation<T>;
|
|
30
|
+
join<U = Tuple>(other: AsyncRelationOperand<U>, keys?: JoinKeys): AsyncRelation<T & U>;
|
|
31
|
+
left_join<U = Tuple>(other: AsyncRelationOperand<U>, keys?: JoinKeys): AsyncRelation<T & Partial<U>>;
|
|
32
|
+
cross_product<U = Tuple>(other: AsyncRelationOperand<U>): AsyncRelation<T & U>;
|
|
33
|
+
cross_join<U = Tuple>(other: AsyncRelationOperand<U>): AsyncRelation<T & U>;
|
|
34
|
+
group<K extends keyof T>(attrs: K[], as: AttrName): AsyncRelation<Omit<T, K> & Record<string, Relation<Pick<T, K>>>>;
|
|
35
|
+
ungroup(attr: AttrName): AsyncRelation<Tuple>;
|
|
36
|
+
wrap<K extends keyof T>(attrs: K[], as: AttrName): AsyncRelation<Omit<T, K> & Record<string, Pick<T, K>>>;
|
|
37
|
+
unwrap(attr: AttrName): AsyncRelation<Tuple>;
|
|
38
|
+
image<U = Tuple>(other: AsyncRelationOperand<U>, as: AttrName, keys?: JoinKeys): AsyncRelation<T & Record<string, Relation<U>>>;
|
|
39
|
+
summarize<K extends keyof T>(by: K[], aggs: Aggregators): AsyncRelation<Pick<T, K> & Tuple>;
|
|
40
|
+
autowrap(options?: AutowrapOptions): AsyncRelation<Tuple>;
|
|
41
|
+
one(): Promise<T>;
|
|
42
|
+
toArray(): Promise<T[]>;
|
|
43
|
+
toRelation(): Promise<Relation<T>>;
|
|
44
|
+
yByX(y: AttrName, x: AttrName): Promise<Tuple>;
|
|
45
|
+
toText(options?: TextOptions): Promise<string>;
|
|
46
|
+
[Symbol.asyncIterator](): AsyncIterator<T>;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* What can be passed as an operand to async operators.
|
|
50
|
+
*/
|
|
51
|
+
export type AsyncRelationOperand<T = Tuple> = AsyncRelation<T> | AsyncIterable<T>;
|
|
52
|
+
/**
|
|
53
|
+
* Async version of OperationalOperand for internal use by operators.
|
|
54
|
+
*/
|
|
55
|
+
export interface AsyncOperationalOperand<T = Tuple> {
|
|
56
|
+
tuples(): AsyncIterable<T>;
|
|
57
|
+
output(tuples: AsyncIterable<T>): AsyncRelationOperand<T>;
|
|
58
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AsyncRelationOperand, AsyncOperationalOperand, AsyncRelation } from '../async-types';
|
|
2
|
+
/**
|
|
3
|
+
* Type guard to check if a value implements AsyncRelation.
|
|
4
|
+
*/
|
|
5
|
+
export declare const isAsyncRelation: <T>(value: unknown) => value is AsyncRelation<T>;
|
|
6
|
+
/**
|
|
7
|
+
* Converts an AsyncRelationOperand to an AsyncOperationalOperand
|
|
8
|
+
* that provides a uniform interface for async iteration and output.
|
|
9
|
+
*/
|
|
10
|
+
export declare const toAsyncOperationalOperand: <T>(operand: AsyncRelationOperand<T>) => AsyncOperationalOperand<T>;
|
|
11
|
+
/**
|
|
12
|
+
* Async generator that removes duplicate tuples.
|
|
13
|
+
* Uses tupleKey() for equality comparison.
|
|
14
|
+
*/
|
|
15
|
+
export declare function deduplicateAsync<T>(source: AsyncIterable<T>): AsyncGenerator<T>;
|
|
16
|
+
export declare const error: (msg: string) => never;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AsyncRelationOperand } from '../async-types';
|
|
2
|
+
import type { AutowrapOptions, Tuple } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Automatically wraps attributes based on naming convention.
|
|
5
|
+
* Attributes with separator (default '_') are grouped into nested objects.
|
|
6
|
+
*/
|
|
7
|
+
export declare function autowrap<T>(operand: AsyncRelationOperand<T>, options?: AutowrapOptions): AsyncIterable<Tuple>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AsyncRelationOperand } from '../async-types';
|
|
2
|
+
import type { Tuple } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Cartesian product: combines every left tuple with every right tuple.
|
|
5
|
+
* Left attributes override right on clash. Removes duplicates.
|
|
6
|
+
* Materializes both sides.
|
|
7
|
+
*/
|
|
8
|
+
export declare function cross_product<T, U>(left: AsyncRelationOperand<T>, right: AsyncRelationOperand<U>): AsyncIterable<Tuple>;
|
|
9
|
+
export { cross_product as cross_join };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AsyncRelationOperand } from '../async-types';
|
|
2
|
+
import type { Extension, Tuple } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Extends each tuple with new attributes.
|
|
5
|
+
* Extension can be functions (computed) or attribute names (copied).
|
|
6
|
+
*/
|
|
7
|
+
export declare const extend: <T>(operand: AsyncRelationOperand<T>, extension: Extension) => AsyncIterable<Tuple>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AsyncRelationOperand } from '../async-types';
|
|
2
|
+
import type { AttrName, Tuple } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Groups specified attributes into a nested relation.
|
|
5
|
+
* Materializes all tuples to perform grouping.
|
|
6
|
+
*/
|
|
7
|
+
export declare function group<T>(operand: AsyncRelationOperand<T>, attrs: AttrName[], as: AttrName): AsyncIterable<Tuple>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AsyncRelationOperand } from '../async-types';
|
|
2
|
+
import type { JoinKeys, Tuple, AttrName } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Adds a relation-valued attribute with matching tuples from right.
|
|
5
|
+
* Each left tuple gets a nested relation of matching right tuples.
|
|
6
|
+
* Materializes both sides.
|
|
7
|
+
*/
|
|
8
|
+
export declare function image<T, U>(left: AsyncRelationOperand<T>, right: AsyncRelationOperand<U>, as: AttrName, keys?: JoinKeys): AsyncIterable<Tuple>;
|