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.
- package/README.md +292 -26
- package/dist/cjs/cli/config.js +5 -15
- package/dist/cjs/cli/index.js +311 -43
- package/dist/cjs/cli/loader.js +129 -0
- package/dist/cjs/cli/migrate.js +96 -47
- package/dist/cjs/cli/ui.js +5 -9
- package/dist/cjs/client.js +158 -49
- package/dist/cjs/errors.js +424 -0
- package/dist/cjs/generate.js +145 -14
- package/dist/cjs/index.js +43 -20
- package/dist/cjs/introspect.js +3 -5
- package/dist/cjs/pipeline.js +9 -2
- package/dist/cjs/query.js +544 -115
- package/dist/cjs/schema-builder.js +150 -30
- package/dist/cjs/schema-sql.js +241 -37
- package/dist/cjs/schema.js +5 -2
- package/dist/cjs/serverless.js +88 -176
- package/dist/cli/config.js +6 -16
- package/dist/cli/index.js +316 -48
- package/dist/cli/loader.d.ts +45 -0
- package/dist/cli/loader.js +91 -0
- package/dist/cli/migrate.d.ts +13 -2
- package/dist/cli/migrate.js +97 -48
- package/dist/cli/ui.d.ts +1 -1
- package/dist/cli/ui.js +5 -9
- package/dist/client.d.ts +92 -4
- package/dist/client.js +158 -49
- package/dist/errors.d.ts +225 -0
- package/dist/errors.js +405 -0
- package/dist/generate.d.ts +7 -1
- package/dist/generate.js +148 -18
- package/dist/index.d.ts +11 -9
- package/dist/index.js +16 -12
- package/dist/introspect.d.ts +1 -1
- package/dist/introspect.js +4 -6
- package/dist/pipeline.d.ts +1 -1
- package/dist/pipeline.js +9 -2
- package/dist/query.d.ts +374 -38
- package/dist/query.js +545 -116
- package/dist/schema-builder.d.ts +38 -5
- package/dist/schema-builder.js +150 -31
- package/dist/schema-sql.d.ts +7 -3
- package/dist/schema-sql.js +241 -37
- package/dist/schema.d.ts +1 -1
- package/dist/schema.js +5 -2
- package/dist/serverless.d.ts +92 -139
- package/dist/serverless.js +87 -173
- package/package.json +33 -16
- package/dist/types.d.ts +0 -93
- package/dist/types.js +0 -126
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* turbine-orm
|
|
3
3
|
*
|
|
4
4
|
* Turbine TypeScript SDK — type-safe Postgres queries with nested relations
|
|
5
5
|
* and pipeline batching. Feels like Prisma, runs at raw-SQL speed.
|
|
@@ -32,13 +32,15 @@
|
|
|
32
32
|
* await db.disconnect();
|
|
33
33
|
* ```
|
|
34
34
|
*/
|
|
35
|
-
export {
|
|
36
|
-
export {
|
|
35
|
+
export { type Middleware, type MiddlewareNext, type MiddlewareParams, type PgCompatPool, type PgCompatPoolClient, type PgCompatQueryResult, TransactionClient, type TransactionOptions, TurbineClient, type TurbineConfig, } from './client.js';
|
|
36
|
+
export { CheckConstraintError, CircularRelationError, ConnectionError, DeadlockError, type ErrorMessageMode, ForeignKeyError, getErrorMessageMode, MigrationError, NotFoundError, NotNullViolationError, RelationError, SerializationFailureError, setErrorMessageMode, TimeoutError, TurbineError, TurbineErrorCode, UniqueConstraintError, ValidationError, wrapPgError, } from './errors.js';
|
|
37
|
+
export { type GenerateOptions, generate } from './generate.js';
|
|
38
|
+
export { type IntrospectOptions, introspect } from './introspect.js';
|
|
37
39
|
export { executePipeline, type PipelineResults } from './pipeline.js';
|
|
38
|
-
export type
|
|
39
|
-
export {
|
|
40
|
-
export {
|
|
41
|
-
export {
|
|
42
|
-
export {
|
|
43
|
-
export {
|
|
40
|
+
export { type AggregateArgs, type AggregateResult, type ArrayFilter, type CountArgs, type CreateArgs, type CreateManyArgs, type DeferredQuery, type DeleteArgs, type DeleteManyArgs, type FindManyArgs, type FindManyStreamArgs, type FindUniqueArgs, type GroupByArgs, type JsonFilter, type OrderDirection, QueryInterface, type RelationDescriptor, type RelationFilter, type TypedWithClause, type UpdateArgs, type UpdateInput, type UpdateManyArgs, type UpdateOperatorInput, type UpsertArgs, type WithClause, type WithOptions, type WithResult, } from './query.js';
|
|
41
|
+
export type { ColumnMetadata, IndexMetadata, RelationDef, SchemaMetadata, TableMetadata, } from './schema.js';
|
|
42
|
+
export { camelToSnake, isDateType, pgArrayType, pgTypeToTs, singularize, snakeToCamel, snakeToPascal, } from './schema.js';
|
|
43
|
+
export { ColumnBuilder, type ColumnConfig, type ColumnDef, type ColumnType, type ColumnTypeName, column, defineSchema, type SchemaDef, type TableDef, table, } from './schema-builder.js';
|
|
44
|
+
export { type AlterColumnDef, type AlterDef, type DiffResult, type PushResult, schemaDiff, schemaPush, schemaToSQL, schemaToSQLString, } from './schema-sql.js';
|
|
45
|
+
export { type TurbineHttpOptions, turbineHttp } from './serverless.js';
|
|
44
46
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* turbine-orm
|
|
3
3
|
*
|
|
4
4
|
* Turbine TypeScript SDK — type-safe Postgres queries with nested relations
|
|
5
5
|
* and pipeline batching. Feels like Prisma, runs at raw-SQL speed.
|
|
@@ -33,21 +33,25 @@
|
|
|
33
33
|
* ```
|
|
34
34
|
*/
|
|
35
35
|
// Client
|
|
36
|
-
export {
|
|
37
|
-
//
|
|
38
|
-
export {
|
|
36
|
+
export { TransactionClient, TurbineClient, } from './client.js';
|
|
37
|
+
// Error types
|
|
38
|
+
export { CheckConstraintError, CircularRelationError, ConnectionError, DeadlockError, ForeignKeyError, getErrorMessageMode, MigrationError, NotFoundError, NotNullViolationError, RelationError, SerializationFailureError, setErrorMessageMode, TimeoutError, TurbineError, TurbineErrorCode, UniqueConstraintError, ValidationError, wrapPgError, } from './errors.js';
|
|
39
|
+
// Code generation
|
|
40
|
+
export { generate } from './generate.js';
|
|
41
|
+
// Introspection
|
|
42
|
+
export { introspect } from './introspect.js';
|
|
39
43
|
// Pipeline
|
|
40
44
|
export { executePipeline } from './pipeline.js';
|
|
45
|
+
// Query builder
|
|
46
|
+
export { QueryInterface, } from './query.js';
|
|
41
47
|
// Schema utilities
|
|
42
|
-
export {
|
|
43
|
-
// Introspection
|
|
44
|
-
export { introspect } from './introspect.js';
|
|
45
|
-
// Code generation
|
|
46
|
-
export { generate } from './generate.js';
|
|
48
|
+
export { camelToSnake, isDateType, pgArrayType, pgTypeToTs, singularize, snakeToCamel, snakeToPascal, } from './schema.js';
|
|
47
49
|
// Schema builder — define schemas in TypeScript
|
|
48
|
-
export { defineSchema,
|
|
50
|
+
export { ColumnBuilder, column, defineSchema,
|
|
49
51
|
// Legacy compat (deprecated — use object format with defineSchema)
|
|
50
|
-
table,
|
|
52
|
+
table, } from './schema-builder.js';
|
|
51
53
|
// Schema SQL — generate DDL, diff, and push
|
|
52
|
-
export {
|
|
54
|
+
export { schemaDiff, schemaPush, schemaToSQL, schemaToSQLString, } from './schema-sql.js';
|
|
55
|
+
// Serverless / edge factory
|
|
56
|
+
export { turbineHttp } from './serverless.js';
|
|
53
57
|
//# sourceMappingURL=index.js.map
|
package/dist/introspect.d.ts
CHANGED
package/dist/introspect.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* turbine-orm — Schema introspection
|
|
3
3
|
*
|
|
4
4
|
* Connects to a live Postgres database, reads information_schema + pg_catalog,
|
|
5
5
|
* and produces a SchemaMetadata object describing every table, column, relation,
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* This is the foundation of `npx turbine generate`.
|
|
9
9
|
*/
|
|
10
10
|
import pg from 'pg';
|
|
11
|
-
import {
|
|
11
|
+
import { isDateType, pgArrayType, pgTypeToTs, singularize, snakeToCamel, } from './schema.js';
|
|
12
12
|
// ---------------------------------------------------------------------------
|
|
13
13
|
// SQL queries (all parameterized, no interpolation)
|
|
14
14
|
// ---------------------------------------------------------------------------
|
|
@@ -99,7 +99,7 @@ export async function introspect(options) {
|
|
|
99
99
|
});
|
|
100
100
|
try {
|
|
101
101
|
// Run all information_schema queries in parallel
|
|
102
|
-
const [tablesResult, columnsResult, pkResult, fkResult, uniqueResult, indexResult, enumResult
|
|
102
|
+
const [tablesResult, columnsResult, pkResult, fkResult, uniqueResult, indexResult, enumResult] = await Promise.all([
|
|
103
103
|
pool.query(SQL_TABLES, [schema]),
|
|
104
104
|
pool.query(SQL_COLUMNS, [schema]),
|
|
105
105
|
pool.query(SQL_PRIMARY_KEYS, [schema]),
|
|
@@ -172,9 +172,7 @@ export async function introspect(options) {
|
|
|
172
172
|
const isUnique = row.indexdef.includes('UNIQUE');
|
|
173
173
|
// Extract column names from indexdef (e.g. "CREATE INDEX idx ON tbl USING btree (col1, col2)")
|
|
174
174
|
const colMatch = row.indexdef.match(/\((.+)\)/);
|
|
175
|
-
const columns = colMatch
|
|
176
|
-
? colMatch[1].split(',').map((c) => c.trim().replace(/ (ASC|DESC)/i, ''))
|
|
177
|
-
: [];
|
|
175
|
+
const columns = colMatch ? colMatch[1].split(',').map((c) => c.trim().replace(/ (ASC|DESC)/i, '')) : [];
|
|
178
176
|
indexesByTable.get(row.tablename).push({
|
|
179
177
|
name: row.indexname,
|
|
180
178
|
columns,
|
package/dist/pipeline.d.ts
CHANGED
package/dist/pipeline.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* turbine-orm — Pipeline execution
|
|
3
3
|
*
|
|
4
4
|
* Pipelines batch multiple independent queries into a single database round-trip.
|
|
5
5
|
* Instead of N sequential awaits (N round-trips), you get 1 round-trip for all N queries.
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
* we simulate it by running queries concurrently on a single connection or via
|
|
16
16
|
* a multi-statement batch.
|
|
17
17
|
*/
|
|
18
|
+
import { wrapPgError } from './errors.js';
|
|
18
19
|
// ---------------------------------------------------------------------------
|
|
19
20
|
// Pipeline executor
|
|
20
21
|
// ---------------------------------------------------------------------------
|
|
@@ -52,7 +53,13 @@ export async function executePipeline(pool, queries) {
|
|
|
52
53
|
// Future: use actual Postgres pipeline protocol for true pipelining.
|
|
53
54
|
const results = [];
|
|
54
55
|
for (const q of queries) {
|
|
55
|
-
|
|
56
|
+
let raw;
|
|
57
|
+
try {
|
|
58
|
+
raw = await client.query(q.sql, q.params);
|
|
59
|
+
}
|
|
60
|
+
catch (err) {
|
|
61
|
+
throw wrapPgError(err);
|
|
62
|
+
}
|
|
56
63
|
results.push(q.transform(raw));
|
|
57
64
|
}
|
|
58
65
|
await client.query('COMMIT');
|