turbine-orm 0.5.0 → 0.7.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.
Files changed (50) hide show
  1. package/README.md +292 -26
  2. package/dist/cjs/cli/config.js +5 -15
  3. package/dist/cjs/cli/index.js +311 -43
  4. package/dist/cjs/cli/loader.js +129 -0
  5. package/dist/cjs/cli/migrate.js +96 -47
  6. package/dist/cjs/cli/ui.js +5 -9
  7. package/dist/cjs/client.js +158 -49
  8. package/dist/cjs/errors.js +424 -0
  9. package/dist/cjs/generate.js +145 -14
  10. package/dist/cjs/index.js +43 -20
  11. package/dist/cjs/introspect.js +3 -5
  12. package/dist/cjs/pipeline.js +9 -2
  13. package/dist/cjs/query.js +544 -115
  14. package/dist/cjs/schema-builder.js +150 -30
  15. package/dist/cjs/schema-sql.js +241 -37
  16. package/dist/cjs/schema.js +5 -2
  17. package/dist/cjs/serverless.js +88 -176
  18. package/dist/cli/config.js +6 -16
  19. package/dist/cli/index.js +316 -48
  20. package/dist/cli/loader.d.ts +45 -0
  21. package/dist/cli/loader.js +91 -0
  22. package/dist/cli/migrate.d.ts +13 -2
  23. package/dist/cli/migrate.js +97 -48
  24. package/dist/cli/ui.d.ts +1 -1
  25. package/dist/cli/ui.js +5 -9
  26. package/dist/client.d.ts +92 -4
  27. package/dist/client.js +158 -49
  28. package/dist/errors.d.ts +225 -0
  29. package/dist/errors.js +405 -0
  30. package/dist/generate.d.ts +7 -1
  31. package/dist/generate.js +148 -18
  32. package/dist/index.d.ts +11 -9
  33. package/dist/index.js +16 -12
  34. package/dist/introspect.d.ts +1 -1
  35. package/dist/introspect.js +4 -6
  36. package/dist/pipeline.d.ts +1 -1
  37. package/dist/pipeline.js +9 -2
  38. package/dist/query.d.ts +374 -38
  39. package/dist/query.js +545 -116
  40. package/dist/schema-builder.d.ts +38 -5
  41. package/dist/schema-builder.js +150 -31
  42. package/dist/schema-sql.d.ts +7 -3
  43. package/dist/schema-sql.js +241 -37
  44. package/dist/schema.d.ts +1 -1
  45. package/dist/schema.js +5 -2
  46. package/dist/serverless.d.ts +92 -139
  47. package/dist/serverless.js +87 -173
  48. package/package.json +33 -16
  49. package/dist/types.d.ts +0 -93
  50. package/dist/types.js +0 -126
package/dist/types.d.ts DELETED
@@ -1,93 +0,0 @@
1
- /**
2
- * @batadata/turbine — Generated entity types
3
- *
4
- * These types mirror the Postgres schema and would normally be auto-generated
5
- * by `npx turbine generate` from your database schema or Rust entity definitions.
6
- *
7
- * Schema: turbine/sql/schema.sql
8
- */
9
- export interface Organization {
10
- id: number;
11
- name: string;
12
- slug: string;
13
- plan: string;
14
- createdAt: Date;
15
- }
16
- export interface User {
17
- id: number;
18
- orgId: number;
19
- email: string;
20
- name: string;
21
- role: string;
22
- avatarUrl: string | null;
23
- lastLoginAt: Date | null;
24
- createdAt: Date;
25
- }
26
- export interface Post {
27
- id: number;
28
- userId: number;
29
- orgId: number;
30
- title: string;
31
- content: string;
32
- published: boolean;
33
- viewCount: number;
34
- createdAt: Date;
35
- updatedAt: Date;
36
- }
37
- export interface Comment {
38
- id: number;
39
- postId: number;
40
- userId: number;
41
- body: string;
42
- createdAt: Date;
43
- }
44
- export type OrganizationCreate = Omit<Organization, 'id' | 'createdAt'>;
45
- export type OrganizationUpdate = Partial<Omit<Organization, 'id' | 'createdAt'>>;
46
- export type UserCreate = Omit<User, 'id' | 'createdAt'>;
47
- export type UserUpdate = Partial<Omit<User, 'id' | 'createdAt'>>;
48
- export type PostCreate = Omit<Post, 'id' | 'createdAt' | 'updatedAt' | 'viewCount'>;
49
- export type PostUpdate = Partial<Omit<Post, 'id' | 'createdAt' | 'updatedAt'>>;
50
- export type CommentCreate = Omit<Comment, 'id' | 'createdAt'>;
51
- export type CommentUpdate = Partial<Omit<Comment, 'id' | 'createdAt'>>;
52
- /** User with their posts loaded */
53
- export interface UserWithPosts extends User {
54
- posts: Post[];
55
- }
56
- /** User with posts and each post's comments */
57
- export interface UserWithPostsAndComments extends User {
58
- posts: (Post & {
59
- comments: Comment[];
60
- })[];
61
- }
62
- /** Post with its comments loaded */
63
- export interface PostWithComments extends Post {
64
- comments: Comment[];
65
- }
66
- /** Organization with all nested relations (full tree) */
67
- export interface OrgWithEverything extends Organization {
68
- users: (User & {
69
- posts: (Post & {
70
- comments: Comment[];
71
- })[];
72
- })[];
73
- }
74
- /** Organization with users loaded */
75
- export interface OrgWithUsers extends Organization {
76
- users: User[];
77
- }
78
- /** Maps camelCase field names to snake_case column names */
79
- export declare const COLUMN_MAP: Record<string, Record<string, string>>;
80
- /** Reverse map: snake_case column -> camelCase field */
81
- export declare function snakeToCamel(s: string): string;
82
- /** Forward map: camelCase field -> snake_case column */
83
- export declare function camelToSnake(s: string): string;
84
- export interface RelationDef {
85
- type: 'hasMany' | 'hasOne' | 'belongsTo';
86
- from: string;
87
- to: string;
88
- foreignKey: string;
89
- referenceKey: string;
90
- }
91
- export declare const RELATIONS: Record<string, Record<string, RelationDef>>;
92
- export declare const DATE_COLUMNS: Record<string, Set<string>>;
93
- //# sourceMappingURL=types.d.ts.map
package/dist/types.js DELETED
@@ -1,126 +0,0 @@
1
- /**
2
- * @batadata/turbine — Generated entity types
3
- *
4
- * These types mirror the Postgres schema and would normally be auto-generated
5
- * by `npx turbine generate` from your database schema or Rust entity definitions.
6
- *
7
- * Schema: turbine/sql/schema.sql
8
- */
9
- // ---------------------------------------------------------------------------
10
- // Column-name mappings (camelCase <-> snake_case)
11
- // ---------------------------------------------------------------------------
12
- /** Maps camelCase field names to snake_case column names */
13
- export const COLUMN_MAP = {
14
- organizations: {
15
- id: 'id',
16
- name: 'name',
17
- slug: 'slug',
18
- plan: 'plan',
19
- createdAt: 'created_at',
20
- },
21
- users: {
22
- id: 'id',
23
- orgId: 'org_id',
24
- email: 'email',
25
- name: 'name',
26
- role: 'role',
27
- avatarUrl: 'avatar_url',
28
- lastLoginAt: 'last_login_at',
29
- createdAt: 'created_at',
30
- },
31
- posts: {
32
- id: 'id',
33
- userId: 'user_id',
34
- orgId: 'org_id',
35
- title: 'title',
36
- content: 'content',
37
- published: 'published',
38
- viewCount: 'view_count',
39
- createdAt: 'created_at',
40
- updatedAt: 'updated_at',
41
- },
42
- comments: {
43
- id: 'id',
44
- postId: 'post_id',
45
- userId: 'user_id',
46
- body: 'body',
47
- createdAt: 'created_at',
48
- },
49
- };
50
- /** Reverse map: snake_case column -> camelCase field */
51
- export function snakeToCamel(s) {
52
- return s.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
53
- }
54
- /** Forward map: camelCase field -> snake_case column */
55
- export function camelToSnake(s) {
56
- return s.replace(/[A-Z]/g, (c) => `_${c.toLowerCase()}`);
57
- }
58
- export const RELATIONS = {
59
- organizations: {
60
- users: {
61
- type: 'hasMany',
62
- from: 'organizations',
63
- to: 'users',
64
- foreignKey: 'org_id',
65
- referenceKey: 'id',
66
- },
67
- },
68
- users: {
69
- organization: {
70
- type: 'belongsTo',
71
- from: 'users',
72
- to: 'organizations',
73
- foreignKey: 'org_id',
74
- referenceKey: 'id',
75
- },
76
- posts: {
77
- type: 'hasMany',
78
- from: 'users',
79
- to: 'posts',
80
- foreignKey: 'user_id',
81
- referenceKey: 'id',
82
- },
83
- },
84
- posts: {
85
- user: {
86
- type: 'belongsTo',
87
- from: 'posts',
88
- to: 'users',
89
- foreignKey: 'user_id',
90
- referenceKey: 'id',
91
- },
92
- comments: {
93
- type: 'hasMany',
94
- from: 'posts',
95
- to: 'comments',
96
- foreignKey: 'post_id',
97
- referenceKey: 'id',
98
- },
99
- },
100
- comments: {
101
- post: {
102
- type: 'belongsTo',
103
- from: 'comments',
104
- to: 'posts',
105
- foreignKey: 'post_id',
106
- referenceKey: 'id',
107
- },
108
- user: {
109
- type: 'belongsTo',
110
- from: 'comments',
111
- to: 'users',
112
- foreignKey: 'user_id',
113
- referenceKey: 'id',
114
- },
115
- },
116
- };
117
- // ---------------------------------------------------------------------------
118
- // Timestamp columns that need Date parsing
119
- // ---------------------------------------------------------------------------
120
- export const DATE_COLUMNS = {
121
- organizations: new Set(['created_at']),
122
- users: new Set(['last_login_at', 'created_at']),
123
- posts: new Set(['created_at', 'updated_at']),
124
- comments: new Set(['created_at']),
125
- };
126
- //# sourceMappingURL=types.js.map