@enspirit/bmg-js 1.0.0 → 1.0.1
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/dist/bmg.cjs +2 -0
- package/dist/bmg.cjs.map +1 -0
- package/dist/bmg.modern.js +2 -0
- package/dist/bmg.modern.js.map +1 -0
- package/dist/bmg.module.js +2 -0
- package/dist/bmg.module.js.map +1 -0
- package/dist/bmg.umd.js +2 -0
- package/dist/bmg.umd.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/src/Relation/Memory.d.ts +46 -0
- package/dist/src/Relation/index.d.ts +1 -0
- package/dist/src/Relation.d.ts +8 -0
- package/dist/src/index.d.ts +27 -0
- package/dist/src/operators/_helpers.d.ts +142 -0
- package/dist/src/operators/allbut.d.ts +2 -0
- package/dist/src/operators/autowrap.d.ts +2 -0
- package/dist/src/operators/constants.d.ts +2 -0
- package/dist/src/operators/cross_product.d.ts +3 -0
- package/dist/src/operators/exclude.d.ts +2 -0
- package/dist/src/operators/extend.d.ts +2 -0
- package/dist/src/operators/group.d.ts +2 -0
- package/dist/src/operators/image.d.ts +2 -0
- package/dist/src/operators/index.d.ts +30 -0
- package/dist/src/operators/intersect.d.ts +2 -0
- package/dist/src/operators/isEqual.d.ts +2 -0
- package/dist/src/operators/isRelation.d.ts +1 -0
- package/dist/src/operators/join.d.ts +2 -0
- package/dist/src/operators/left_join.d.ts +2 -0
- package/dist/src/operators/matching.d.ts +2 -0
- package/dist/src/operators/minus.d.ts +2 -0
- package/dist/src/operators/not_matching.d.ts +2 -0
- package/dist/src/operators/one.d.ts +2 -0
- package/dist/src/operators/prefix.d.ts +2 -0
- package/dist/src/operators/project.d.ts +2 -0
- package/dist/src/operators/rename.d.ts +2 -0
- package/dist/src/operators/restrict.d.ts +2 -0
- package/dist/src/operators/suffix.d.ts +2 -0
- package/dist/src/operators/summarize.d.ts +2 -0
- package/dist/src/operators/transform.d.ts +2 -0
- package/dist/src/operators/ungroup.d.ts +2 -0
- package/dist/src/operators/union.d.ts +2 -0
- package/dist/src/operators/unwrap.d.ts +2 -0
- package/dist/src/operators/where.d.ts +1 -0
- package/dist/src/operators/wrap.d.ts +2 -0
- package/dist/src/operators/yByX.d.ts +2 -0
- package/dist/src/src/Relation/Memory.d.ts +46 -0
- package/dist/src/src/Relation/index.d.ts +1 -0
- package/dist/src/src/index.d.ts +27 -0
- package/dist/src/src/operators/_helpers.d.ts +142 -0
- package/dist/src/src/operators/allbut.d.ts +2 -0
- package/dist/src/src/operators/autowrap.d.ts +2 -0
- package/dist/src/src/operators/constants.d.ts +2 -0
- package/dist/src/src/operators/cross_product.d.ts +3 -0
- package/dist/src/src/operators/exclude.d.ts +2 -0
- package/dist/src/src/operators/extend.d.ts +2 -0
- package/dist/src/src/operators/group.d.ts +2 -0
- package/dist/src/src/operators/image.d.ts +2 -0
- package/dist/src/src/operators/index.d.ts +30 -0
- package/dist/src/src/operators/intersect.d.ts +2 -0
- package/dist/src/src/operators/isEqual.d.ts +2 -0
- package/dist/src/src/operators/isRelation.d.ts +1 -0
- package/dist/src/src/operators/join.d.ts +2 -0
- package/dist/src/src/operators/left_join.d.ts +2 -0
- package/dist/src/src/operators/matching.d.ts +2 -0
- package/dist/src/src/operators/minus.d.ts +2 -0
- package/dist/src/src/operators/not_matching.d.ts +2 -0
- package/dist/src/src/operators/one.d.ts +2 -0
- package/dist/src/src/operators/prefix.d.ts +2 -0
- package/dist/src/src/operators/project.d.ts +2 -0
- package/dist/src/src/operators/rename.d.ts +2 -0
- package/dist/src/src/operators/restrict.d.ts +2 -0
- package/dist/src/src/operators/suffix.d.ts +2 -0
- package/dist/src/src/operators/summarize.d.ts +2 -0
- package/dist/src/src/operators/transform.d.ts +2 -0
- package/dist/src/src/operators/ungroup.d.ts +2 -0
- package/dist/src/src/operators/union.d.ts +2 -0
- package/dist/src/src/operators/unwrap.d.ts +2 -0
- package/dist/src/src/operators/where.d.ts +1 -0
- package/dist/src/src/operators/wrap.d.ts +2 -0
- package/dist/src/src/operators/yByX.d.ts +2 -0
- package/dist/src/src/support/toPredicateFunc.d.ts +2 -0
- package/dist/src/src/types.d.ts +101 -0
- package/dist/src/src/utility-types.d.ts +43 -0
- package/dist/src/support/toPredicateFunc.d.ts +2 -0
- package/dist/src/tests/bmg.test.d.ts +1 -0
- package/dist/src/tests/fixtures.d.ts +6 -0
- package/dist/src/tests/operators/allbut.test.d.ts +1 -0
- package/dist/src/tests/operators/autowrap.test.d.ts +1 -0
- package/dist/src/tests/operators/constants.test.d.ts +1 -0
- package/dist/src/tests/operators/cross_product.test.d.ts +1 -0
- package/dist/src/tests/operators/exclude.test.d.ts +1 -0
- package/dist/src/tests/operators/extend.test.d.ts +1 -0
- package/dist/src/tests/operators/group.test.d.ts +1 -0
- package/dist/src/tests/operators/image.test.d.ts +1 -0
- package/dist/src/tests/operators/intersect.test.d.ts +1 -0
- package/dist/src/tests/operators/isEqual.test.d.ts +1 -0
- package/dist/src/tests/operators/join.test.d.ts +1 -0
- package/dist/src/tests/operators/left_join.test.d.ts +1 -0
- package/dist/src/tests/operators/matching.test.d.ts +1 -0
- package/dist/src/tests/operators/minus.test.d.ts +1 -0
- package/dist/src/tests/operators/not_matching.test.d.ts +1 -0
- package/dist/src/tests/operators/one.test.d.ts +1 -0
- package/dist/src/tests/operators/prefix.test.d.ts +1 -0
- package/dist/src/tests/operators/project.test.d.ts +1 -0
- package/dist/src/tests/operators/rename.test.d.ts +1 -0
- package/dist/src/tests/operators/restrict.test.d.ts +1 -0
- package/dist/src/tests/operators/suffix.test.d.ts +1 -0
- package/dist/src/tests/operators/summarize.test.d.ts +1 -0
- package/dist/src/tests/operators/transform.test.d.ts +1 -0
- package/dist/src/tests/operators/ungroup.test.d.ts +1 -0
- package/dist/src/tests/operators/union.test.d.ts +1 -0
- package/dist/src/tests/operators/unwrap.test.d.ts +1 -0
- package/dist/src/tests/operators/where.test.d.ts +1 -0
- package/dist/src/tests/operators/wrap.test.d.ts +1 -0
- package/dist/src/tests/operators/yByX.test.d.ts +1 -0
- package/dist/src/tests/types/relation.test.d.ts +1 -0
- package/dist/src/types.d.ts +101 -0
- package/dist/src/utility-types.d.ts +43 -0
- package/dist/tests/bmg.test.d.ts +1 -0
- package/dist/tests/fixtures.d.ts +6 -0
- package/dist/tests/operators/allbut.test.d.ts +1 -0
- package/dist/tests/operators/autowrap.test.d.ts +1 -0
- package/dist/tests/operators/constants.test.d.ts +1 -0
- package/dist/tests/operators/cross_product.test.d.ts +1 -0
- package/dist/tests/operators/exclude.test.d.ts +1 -0
- package/dist/tests/operators/extend.test.d.ts +1 -0
- package/dist/tests/operators/group.test.d.ts +1 -0
- package/dist/tests/operators/image.test.d.ts +1 -0
- package/dist/tests/operators/intersect.test.d.ts +1 -0
- package/dist/tests/operators/isEqual.test.d.ts +1 -0
- package/dist/tests/operators/join.test.d.ts +1 -0
- package/dist/tests/operators/left_join.test.d.ts +1 -0
- package/dist/tests/operators/matching.test.d.ts +1 -0
- package/dist/tests/operators/minus.test.d.ts +1 -0
- package/dist/tests/operators/not_matching.test.d.ts +1 -0
- package/dist/tests/operators/one.test.d.ts +1 -0
- package/dist/tests/operators/prefix.test.d.ts +1 -0
- package/dist/tests/operators/project.test.d.ts +1 -0
- package/dist/tests/operators/rename.test.d.ts +1 -0
- package/dist/tests/operators/restrict.test.d.ts +1 -0
- package/dist/tests/operators/suffix.test.d.ts +1 -0
- package/dist/tests/operators/summarize.test.d.ts +1 -0
- package/dist/tests/operators/transform.test.d.ts +1 -0
- package/dist/tests/operators/ungroup.test.d.ts +1 -0
- package/dist/tests/operators/union.test.d.ts +1 -0
- package/dist/tests/operators/unwrap.test.d.ts +1 -0
- package/dist/tests/operators/where.test.d.ts +1 -0
- package/dist/tests/operators/wrap.test.d.ts +1 -0
- package/dist/tests/operators/yByX.test.d.ts +1 -0
- package/dist/tests/types/relation.test.d.ts +1 -0
- package/package.json +15 -3
- package/.claude/safe-setup/.env.example +0 -3
- package/.claude/safe-setup/Dockerfile.claude +0 -36
- package/.claude/safe-setup/HACKING.md +0 -63
- package/.claude/safe-setup/Makefile +0 -22
- package/.claude/safe-setup/docker-compose.yml +0 -18
- package/.claude/safe-setup/entrypoint.sh +0 -13
- package/.claude/settings.local.json +0 -9
- package/.claude/typescript-annotations.md +0 -273
- package/.github/workflows/test.yml +0 -26
- package/CLAUDE.md +0 -48
- package/Makefile +0 -2
- package/example/README.md +0 -22
- package/example/index.ts +0 -316
- package/example/package.json +0 -16
- package/example/tsconfig.json +0 -11
- package/tests/bmg.test.ts +0 -16
- package/tests/fixtures.ts +0 -9
- package/tests/operators/allbut.test.ts +0 -51
- package/tests/operators/autowrap.test.ts +0 -82
- package/tests/operators/constants.test.ts +0 -37
- package/tests/operators/cross_product.test.ts +0 -90
- package/tests/operators/exclude.test.ts +0 -43
- package/tests/operators/extend.test.ts +0 -45
- package/tests/operators/group.test.ts +0 -69
- package/tests/operators/image.test.ts +0 -152
- package/tests/operators/intersect.test.ts +0 -53
- package/tests/operators/isEqual.test.ts +0 -111
- package/tests/operators/join.test.ts +0 -116
- package/tests/operators/left_join.test.ts +0 -116
- package/tests/operators/matching.test.ts +0 -91
- package/tests/operators/minus.test.ts +0 -47
- package/tests/operators/not_matching.test.ts +0 -104
- package/tests/operators/one.test.ts +0 -19
- package/tests/operators/prefix.test.ts +0 -37
- package/tests/operators/project.test.ts +0 -48
- package/tests/operators/rename.test.ts +0 -39
- package/tests/operators/restrict.test.ts +0 -27
- package/tests/operators/suffix.test.ts +0 -37
- package/tests/operators/summarize.test.ts +0 -109
- package/tests/operators/transform.test.ts +0 -94
- package/tests/operators/ungroup.test.ts +0 -67
- package/tests/operators/union.test.ts +0 -51
- package/tests/operators/unwrap.test.ts +0 -50
- package/tests/operators/where.test.ts +0 -33
- package/tests/operators/wrap.test.ts +0 -54
- package/tests/operators/yByX.test.ts +0 -32
- package/tests/types/relation.test.ts +0 -296
- package/tsconfig.json +0 -37
- package/tsconfig.node.json +0 -9
- package/vitest.config.ts +0 -15
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { RenameMap, Renamed, Prefixed, Suffixed, Joined, LeftJoined, Wrapped, Unwrapped, AggregatorResults } from './utility-types';
|
|
2
|
+
/** Result of ungroup: remove relation attr, flatten its tuple type */
|
|
3
|
+
export type Ungrouped<T, K extends keyof T> = T[K] extends Relation<infer N> ? Omit<T, K> & N : Omit<T, K>;
|
|
4
|
+
export type AttrName = string;
|
|
5
|
+
export type Tuple = Record<AttrName, unknown>;
|
|
6
|
+
export interface PrefixOptions {
|
|
7
|
+
except?: AttrName[];
|
|
8
|
+
}
|
|
9
|
+
export interface SuffixOptions {
|
|
10
|
+
except?: AttrName[];
|
|
11
|
+
}
|
|
12
|
+
export interface AutowrapOptions {
|
|
13
|
+
separator?: string;
|
|
14
|
+
}
|
|
15
|
+
/** Predicate function that receives a typed tuple */
|
|
16
|
+
export type TypedPredicateFunc<T> = (t: T) => boolean;
|
|
17
|
+
/** Predicate: either a partial tuple for equality matching, or a function */
|
|
18
|
+
export type TypedPredicate<T> = Partial<T> | TypedPredicateFunc<T>;
|
|
19
|
+
/** Extension function that receives a typed tuple */
|
|
20
|
+
export type TypedExtensionFunc<T, R> = (tuple: T) => R;
|
|
21
|
+
/** Extension definition: function returning value, or attribute name to copy */
|
|
22
|
+
export type TypedExtension<T, E extends Record<string, unknown>> = {
|
|
23
|
+
[K in keyof E]: TypedExtensionFunc<T, E[K]> | keyof T;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Relation interface with generic type parameter for tuple type.
|
|
27
|
+
* Default parameter `Tuple` ensures backwards compatibility.
|
|
28
|
+
*
|
|
29
|
+
* @typeParam T - The tuple type for this relation. Defaults to `Tuple` (Record<string, unknown>).
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* // Untyped usage (backwards compatible)
|
|
33
|
+
* const r = Bmg([{ id: 1 }]); // Relation<Tuple>
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* // Typed usage with full type safety
|
|
37
|
+
* interface Person { id: number; name: string }
|
|
38
|
+
* const r = Bmg<Person>([{ id: 1, name: 'Alice' }]);
|
|
39
|
+
* r.project(['id']); // Relation<{ id: number }>
|
|
40
|
+
*/
|
|
41
|
+
export interface Relation<T = Tuple> {
|
|
42
|
+
restrict(p: TypedPredicate<T>): Relation<T>;
|
|
43
|
+
where(p: TypedPredicate<T>): Relation<T>;
|
|
44
|
+
exclude(p: TypedPredicate<T>): Relation<T>;
|
|
45
|
+
project<K extends keyof T>(attrs: K[]): Relation<Pick<T, K>>;
|
|
46
|
+
allbut<K extends keyof T>(attrs: K[]): Relation<Omit<T, K>>;
|
|
47
|
+
extend<E extends Record<string, unknown>>(e: TypedExtension<T, E>): Relation<T & E>;
|
|
48
|
+
constants<C extends Tuple>(consts: C): Relation<T & C>;
|
|
49
|
+
rename<R extends RenameMap<T>>(r: R): Relation<Renamed<T, R>>;
|
|
50
|
+
prefix<P extends string, Ex extends keyof T = never>(pfx: P, options?: {
|
|
51
|
+
except?: Ex[];
|
|
52
|
+
}): Relation<Prefixed<T, P, Ex>>;
|
|
53
|
+
suffix<S extends string, Ex extends keyof T = never>(sfx: S, options?: {
|
|
54
|
+
except?: Ex[];
|
|
55
|
+
}): Relation<Suffixed<T, S, Ex>>;
|
|
56
|
+
union(right: RelationOperand<T>): Relation<T>;
|
|
57
|
+
minus(right: RelationOperand<T>): Relation<T>;
|
|
58
|
+
intersect(right: RelationOperand<T>): Relation<T>;
|
|
59
|
+
matching<R>(right: RelationOperand<R>, keys?: JoinKeys): Relation<T>;
|
|
60
|
+
not_matching<R>(right: RelationOperand<R>, keys?: JoinKeys): Relation<T>;
|
|
61
|
+
join<R>(right: RelationOperand<R>, keys?: JoinKeys): Relation<Joined<T, R>>;
|
|
62
|
+
left_join<R>(right: RelationOperand<R>, keys?: JoinKeys): Relation<LeftJoined<T, R>>;
|
|
63
|
+
cross_product<R>(right: RelationOperand<R>): Relation<T & R>;
|
|
64
|
+
cross_join<R>(right: RelationOperand<R>): Relation<T & R>;
|
|
65
|
+
image<R, As extends string>(right: RelationOperand<R>, as: As, keys?: JoinKeys): Relation<T & Record<As, Relation<Omit<R, keyof T & keyof R>>>>;
|
|
66
|
+
group<K extends keyof T, As extends string>(attrs: K[], as: As): Relation<Omit<T, K> & Record<As, Relation<Pick<T, K>>>>;
|
|
67
|
+
ungroup<K extends keyof T>(attr: K): Relation<Ungrouped<T, K>>;
|
|
68
|
+
wrap<K extends keyof T, As extends string>(attrs: K[], as: As): Relation<Wrapped<T, K, As>>;
|
|
69
|
+
unwrap<K extends keyof T>(attr: K): Relation<Unwrapped<T, K>>;
|
|
70
|
+
summarize<By extends keyof T, Aggs extends Aggregators>(by: By[], aggs: Aggs): Relation<Pick<T, By> & AggregatorResults<Aggs>>;
|
|
71
|
+
transform(t: Transformation): Relation<T>;
|
|
72
|
+
autowrap(options?: AutowrapOptions): Relation<Tuple>;
|
|
73
|
+
one(): T;
|
|
74
|
+
yByX<Y extends keyof T, X extends keyof T>(y: Y, x: X): Record<T[X] & PropertyKey, T[Y]>;
|
|
75
|
+
toArray(): T[];
|
|
76
|
+
isEqual(right: any): boolean;
|
|
77
|
+
}
|
|
78
|
+
export type RelationOperand<T = Tuple> = Relation<T> | T[];
|
|
79
|
+
export interface OperationalOperand<T = Tuple> {
|
|
80
|
+
tuples(): Iterable<T>;
|
|
81
|
+
output(tuples: T[]): RelationOperand<T>;
|
|
82
|
+
}
|
|
83
|
+
export type PredicateFunc = ((t: Tuple) => any);
|
|
84
|
+
export type Predicate = Tuple | PredicateFunc;
|
|
85
|
+
export type Renaming = RenamingObj | RenamingFunc;
|
|
86
|
+
export type RenamingFunc = (attr: AttrName) => AttrName;
|
|
87
|
+
export type RenamingObj = Record<AttrName, AttrName>;
|
|
88
|
+
export type ExtensionFunc = (tuple: Tuple) => unknown;
|
|
89
|
+
export type Extension = Record<AttrName, ExtensionFunc | AttrName>;
|
|
90
|
+
export type JoinKeys = AttrName[] | Record<AttrName, AttrName>;
|
|
91
|
+
export type AggregatorName = 'count' | 'sum' | 'min' | 'max' | 'avg' | 'collect';
|
|
92
|
+
export type AggregatorSpec = {
|
|
93
|
+
op: AggregatorName;
|
|
94
|
+
attr: AttrName;
|
|
95
|
+
};
|
|
96
|
+
export type AggregatorFunc = (tuples: Tuple[]) => unknown;
|
|
97
|
+
export type Aggregator = AggregatorName | AggregatorSpec | AggregatorFunc;
|
|
98
|
+
export type Aggregators = Record<AttrName, Aggregator>;
|
|
99
|
+
export type TransformFunc = (value: unknown) => unknown;
|
|
100
|
+
export type Transformation = TransformFunc | TransformFunc[] | Record<AttrName, TransformFunc | TransformFunc[]>;
|
|
101
|
+
export type { RenameMap, Renamed, Prefixed, Suffixed, Joined, LeftJoined, Wrapped, Unwrapped } from './utility-types';
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility types for type transformations in relational operators.
|
|
3
|
+
* These enable compile-time tracking of how operators transform tuple types.
|
|
4
|
+
*/
|
|
5
|
+
import type { Tuple } from './types';
|
|
6
|
+
/** Map from old attribute names to new attribute names */
|
|
7
|
+
export type RenameMap<T> = {
|
|
8
|
+
[K in keyof T]?: string;
|
|
9
|
+
};
|
|
10
|
+
/** Transform tuple type by renaming keys according to RenameMap */
|
|
11
|
+
export type Renamed<T, R extends RenameMap<T>> = {
|
|
12
|
+
[K in keyof T as K extends keyof R ? (R[K] extends string ? R[K] : K) : K]: T[K];
|
|
13
|
+
};
|
|
14
|
+
/** Prefix all keys except those in Except */
|
|
15
|
+
export type Prefixed<T, P extends string, Except extends keyof T = never> = {
|
|
16
|
+
[K in keyof T as K extends Except ? K : `${P}${K & string}`]: T[K];
|
|
17
|
+
};
|
|
18
|
+
/** Suffix all keys except those in Except */
|
|
19
|
+
export type Suffixed<T, S extends string, Except extends keyof T = never> = {
|
|
20
|
+
[K in keyof T as K extends Except ? K : `${K & string}${S}`]: T[K];
|
|
21
|
+
};
|
|
22
|
+
/** Extract common keys between two tuple types */
|
|
23
|
+
export type CommonKeys<L, R> = Extract<keyof L, keyof R>;
|
|
24
|
+
/** Result of inner join: L & R with R's common keys removed */
|
|
25
|
+
export type Joined<L, R> = L & Omit<R, CommonKeys<L, R>>;
|
|
26
|
+
/** Result of left join: L & optional R attributes (common keys removed) */
|
|
27
|
+
export type LeftJoined<L, R> = L & Partial<Omit<R, CommonKeys<L, R>>>;
|
|
28
|
+
/** Result of wrap: remove wrapped attrs, add nested object */
|
|
29
|
+
export type Wrapped<T, K extends keyof T, As extends string> = Omit<T, K> & Record<As, Pick<T, K>>;
|
|
30
|
+
/** Result of unwrap: remove object attr, spread its properties */
|
|
31
|
+
export type Unwrapped<T, K extends keyof T> = T[K] extends Record<string, unknown> ? Omit<T, K> & T[K] : Omit<T, K>;
|
|
32
|
+
/** Infer result type from aggregator specification */
|
|
33
|
+
export type AggregatorResult<A> = A extends 'count' ? number : A extends {
|
|
34
|
+
op: 'count';
|
|
35
|
+
} ? number : A extends {
|
|
36
|
+
op: 'sum' | 'avg' | 'min' | 'max';
|
|
37
|
+
} ? number | null : A extends {
|
|
38
|
+
op: 'collect';
|
|
39
|
+
} ? unknown[] : A extends (tuples: Tuple[]) => infer R ? R : unknown;
|
|
40
|
+
/** Map aggregator definitions to their result types */
|
|
41
|
+
export type AggregatorResults<Aggs extends Record<string, unknown>> = {
|
|
42
|
+
[K in keyof Aggs]: AggregatorResult<Aggs[K]>;
|
|
43
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enspirit/bmg-js",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Relational algebra for JavaScript/TypeScript - work with arrays of objects using powerful set operations",
|
|
5
|
-
"keywords": [
|
|
5
|
+
"keywords": [
|
|
6
|
+
"relational",
|
|
7
|
+
"algebra",
|
|
8
|
+
"relation",
|
|
9
|
+
"set",
|
|
10
|
+
"query",
|
|
11
|
+
"data",
|
|
12
|
+
"functional"
|
|
13
|
+
],
|
|
6
14
|
"license": "MIT",
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"src"
|
|
18
|
+
],
|
|
7
19
|
"repository": {
|
|
8
20
|
"type": "git",
|
|
9
21
|
"url": "https://github.com/enspirit/bmg.js"
|
|
@@ -28,7 +40,7 @@
|
|
|
28
40
|
"devDependencies": {
|
|
29
41
|
"microbundle": "^0.15.1",
|
|
30
42
|
"vite-tsconfig-paths": "^5.1.4",
|
|
31
|
-
"vitest": "^
|
|
43
|
+
"vitest": "^4.0.16"
|
|
32
44
|
},
|
|
33
45
|
"packageManager": "pnpm@8.11.0+sha1.01bf39424f1008f29012bbae851d2acb8a20a0d0"
|
|
34
46
|
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
FROM alpine:latest
|
|
2
|
-
|
|
3
|
-
# Install packages: base tools, node, ruby, postgresql client
|
|
4
|
-
RUN apk update && apk add --no-cache \
|
|
5
|
-
bash \
|
|
6
|
-
curl \
|
|
7
|
-
git \
|
|
8
|
-
build-base \
|
|
9
|
-
nodejs \
|
|
10
|
-
npm \
|
|
11
|
-
vim \
|
|
12
|
-
sudo
|
|
13
|
-
|
|
14
|
-
# Create non-root user with sudo access
|
|
15
|
-
RUN addgroup -S bmg && adduser -S bmg -G bmg \
|
|
16
|
-
&& echo "bmg ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
|
|
17
|
-
|
|
18
|
-
# Install Claude Code CLI globally
|
|
19
|
-
RUN npm install -g @anthropic-ai/claude-code
|
|
20
|
-
|
|
21
|
-
# Set up working directory
|
|
22
|
-
WORKDIR /workspace
|
|
23
|
-
|
|
24
|
-
# Copy and set up entrypoint
|
|
25
|
-
COPY entrypoint.sh /entrypoint.sh
|
|
26
|
-
RUN chmod +x /entrypoint.sh
|
|
27
|
-
|
|
28
|
-
# Create .claude directory for history persistence
|
|
29
|
-
RUN mkdir -p /home/bmg/.claude && chown -R bmg:bmg /home/bmg/.claude
|
|
30
|
-
|
|
31
|
-
# Switch to non-root user
|
|
32
|
-
USER bmg
|
|
33
|
-
|
|
34
|
-
# Use entrypoint to configure git and run command
|
|
35
|
-
ENTRYPOINT ["/entrypoint.sh"]
|
|
36
|
-
CMD ["bash"]
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
# Hacking on Bmg with Claude Code
|
|
2
|
-
|
|
3
|
-
This Docker setup provides a sandboxed environment with all tools needed to hack on Bmg:
|
|
4
|
-
- Node.js
|
|
5
|
-
- Claude Code CLI
|
|
6
|
-
|
|
7
|
-
## Prerequisites
|
|
8
|
-
|
|
9
|
-
1. Docker and Docker Compose installed
|
|
10
|
-
2. A Claude Code account
|
|
11
|
-
|
|
12
|
-
## Getting Started
|
|
13
|
-
|
|
14
|
-
```bash
|
|
15
|
-
cd .claude/safe-setup
|
|
16
|
-
|
|
17
|
-
# Create your .env file from template
|
|
18
|
-
cp .env.example .env
|
|
19
|
-
|
|
20
|
-
# Edit .env to set your git identity
|
|
21
|
-
# GIT_USER_NAME=Your Name
|
|
22
|
-
# GIT_USER_EMAIL=your.email@example.com
|
|
23
|
-
|
|
24
|
-
# Build and start containers
|
|
25
|
-
make up
|
|
26
|
-
|
|
27
|
-
# Enter the dev environment
|
|
28
|
-
make shell
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## Persistent Data
|
|
32
|
-
|
|
33
|
-
- **Claude history**: Stored in a named Docker volume (`claude-history`) that persists across container restarts
|
|
34
|
-
- **Git configuration**: Automatically set from `GIT_USER_NAME` and `GIT_USER_EMAIL` environment variables
|
|
35
|
-
|
|
36
|
-
## Inside the Container
|
|
37
|
-
|
|
38
|
-
You're now user `bmg` in `/workspace` (the Bmg project root).
|
|
39
|
-
|
|
40
|
-
```bash
|
|
41
|
-
# Install project dependencies
|
|
42
|
-
npm install
|
|
43
|
-
|
|
44
|
-
# Run tests
|
|
45
|
-
npm run test
|
|
46
|
-
|
|
47
|
-
# Use Claude Code
|
|
48
|
-
claude
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
PostgreSQL is pre-configured via environment variables. Just run `psql` to connect.
|
|
52
|
-
|
|
53
|
-
## Commands
|
|
54
|
-
|
|
55
|
-
| Command | Description |
|
|
56
|
-
|---------|-------------|
|
|
57
|
-
| `make up` | Build and start containers |
|
|
58
|
-
| `make down` | Stop containers |
|
|
59
|
-
| `make shell` | Enter dev container |
|
|
60
|
-
| `make restart` | Restart everything |
|
|
61
|
-
| `make logs` | Follow container logs |
|
|
62
|
-
| `make status` | Show container status |
|
|
63
|
-
| `make clean` | Remove containers and images |
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
.PHONY: up down shell restart clean logs status
|
|
2
|
-
|
|
3
|
-
up:
|
|
4
|
-
docker compose up -d --build
|
|
5
|
-
@echo "Containers started. Use 'make shell' to access dev environment"
|
|
6
|
-
|
|
7
|
-
down:
|
|
8
|
-
docker compose down
|
|
9
|
-
|
|
10
|
-
shell:
|
|
11
|
-
docker compose exec dev bash
|
|
12
|
-
|
|
13
|
-
restart: down up
|
|
14
|
-
|
|
15
|
-
clean: down
|
|
16
|
-
docker compose down --rmi all --volumes
|
|
17
|
-
|
|
18
|
-
logs:
|
|
19
|
-
docker compose logs -f
|
|
20
|
-
|
|
21
|
-
status:
|
|
22
|
-
@docker compose ps
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
services:
|
|
2
|
-
|
|
3
|
-
dev:
|
|
4
|
-
build:
|
|
5
|
-
context: .
|
|
6
|
-
dockerfile: Dockerfile.claude
|
|
7
|
-
container_name: claude
|
|
8
|
-
volumes:
|
|
9
|
-
- ../..:/workspace
|
|
10
|
-
- claude-history:/home/bmg/.claude
|
|
11
|
-
environment:
|
|
12
|
-
- GIT_USER_NAME=${GIT_USER_NAME:-}
|
|
13
|
-
- GIT_USER_EMAIL=${GIT_USER_EMAIL:-}
|
|
14
|
-
stdin_open: true
|
|
15
|
-
tty: true
|
|
16
|
-
|
|
17
|
-
volumes:
|
|
18
|
-
claude-history:
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# Configure git user/email from environment variables if provided
|
|
4
|
-
if [ -n "$GIT_USER_NAME" ]; then
|
|
5
|
-
git config --global user.name "$GIT_USER_NAME"
|
|
6
|
-
fi
|
|
7
|
-
|
|
8
|
-
if [ -n "$GIT_USER_EMAIL" ]; then
|
|
9
|
-
git config --global user.email "$GIT_USER_EMAIL"
|
|
10
|
-
fi
|
|
11
|
-
|
|
12
|
-
# Execute the command passed to the container
|
|
13
|
-
exec "$@"
|