turbine-orm 0.19.0 → 0.19.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/README.md +83 -15
- package/dist/adapters/index.d.ts +3 -2
- package/dist/cjs/cli/index.js +43 -13
- package/dist/cjs/cli/loader.js +62 -7
- package/dist/cjs/cli/studio-ui.generated.js +1 -1
- package/dist/cjs/cli/studio.js +25 -35
- package/dist/cjs/client.js +20 -13
- package/dist/cjs/query/builder.js +342 -104
- package/dist/cjs/query/utils.js +1 -0
- package/dist/cli/index.js +45 -15
- package/dist/cli/loader.d.ts +22 -5
- package/dist/cli/loader.js +61 -7
- package/dist/cli/migrate.d.ts +2 -2
- package/dist/cli/studio-ui.generated.js +1 -1
- package/dist/cli/studio.d.ts +9 -14
- package/dist/cli/studio.js +25 -34
- package/dist/client.d.ts +12 -13
- package/dist/client.js +20 -13
- package/dist/index.d.ts +1 -1
- package/dist/query/builder.d.ts +43 -6
- package/dist/query/builder.js +342 -104
- package/dist/query/index.d.ts +1 -1
- package/dist/query/types.d.ts +62 -12
- package/dist/query/utils.js +1 -0
- package/package.json +4 -4
- package/dist/cjs/query.js +0 -2711
- package/dist/query.d.ts +0 -878
- package/dist/query.js +0 -2705
package/dist/query/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* `import { … } from './query/index.js'` is a drop-in replacement for the
|
|
6
6
|
* former monolithic `import { … } from './query.js'`.
|
|
7
7
|
*/
|
|
8
|
-
export type { AggregateArgs, AggregateResult, ArrayFilter, ConnectOrCreateOp, CountArgs, CreateArgs, CreateManyArgs, DeleteArgs, DeleteManyArgs, FieldResult, FindManyArgs, FindManyStreamArgs, FindUniqueArgs, GroupByArgs, JsonFilter, NestedCreateOp, NestedUpdateOp, OmitResult, OrderByClause, OrderDirection, QueryResult, RelationDescriptor, RelationFilter, SelectResult, TextSearchFilter, TypedWithClause, UpdateArgs, UpdateInput, UpdateManyArgs, UpdateOperatorInput, UpsertArgs, VectorDistanceFilter, VectorFilter, VectorMetric, VectorOrderBy, VectorOrderByDistance, WhereClause, WhereOperator, WhereValue, WithClause, WithOptions, WithResult, } from './types.js';
|
|
8
|
+
export type { AggregateArgs, AggregateResult, ArrayFilter, ConnectOrCreateOp, CountArgs, CreateArgs, CreateDataInput, CreateManyArgs, DeleteArgs, DeleteManyArgs, FieldResult, FindManyArgs, FindManyStreamArgs, FindUniqueArgs, GroupByArgs, HavingClause, JsonFilter, NestedCreateOp, NestedUpdateOp, NestedUpdateOpItem, NestedUpsertOpItem, OmitResult, OrderByClause, OrderDirection, QueryResult, RelationDescriptor, RelationFilter, SelectResult, TextSearchFilter, TypedWithClause, UpdateArgs, UpdateDataInput, UpdateInput, UpdateManyArgs, UpdateOperatorInput, UpsertArgs, VectorDistanceFilter, VectorFilter, VectorMetric, VectorOrderBy, VectorOrderByDistance, WhereClause, WhereOperator, WhereValue, WithClause, WithOptions, WithResult, } from './types.js';
|
|
9
9
|
export type { BuiltStatement, BulkInsertStatementInput, ColumnDefinitionInput, ColumnTypeInput, CreateIndexStatementInput, CreateTableStatementInput, Dialect, InsertStatementInput, UpsertStatementInput, } from '../dialect.js';
|
|
10
10
|
export { postgresDialect } from '../dialect.js';
|
|
11
11
|
export type { SqlCacheEntry } from './utils.js';
|
package/dist/query/types.d.ts
CHANGED
|
@@ -6,6 +6,13 @@
|
|
|
6
6
|
export type OrderDirection = 'asc' | 'desc';
|
|
7
7
|
/** Operator object for advanced where filtering */
|
|
8
8
|
export interface WhereOperator<V = unknown> {
|
|
9
|
+
/**
|
|
10
|
+
* Explicit equality: `{ equals: value }` → `column = $n`.
|
|
11
|
+
* `{ equals: null }` → `column IS NULL`.
|
|
12
|
+
* On json/jsonb columns `equals` routes to the JSONB containment filter
|
|
13
|
+
* ({@link JsonFilter}) instead.
|
|
14
|
+
*/
|
|
15
|
+
equals?: V | null;
|
|
9
16
|
gt?: V;
|
|
10
17
|
gte?: V;
|
|
11
18
|
lt?: V;
|
|
@@ -225,8 +232,12 @@ export interface FindManyStreamArgs<T, R extends object = {}, W extends TypedWit
|
|
|
225
232
|
*/
|
|
226
233
|
batchSize?: number;
|
|
227
234
|
}
|
|
228
|
-
export interface CreateArgs<T> {
|
|
229
|
-
|
|
235
|
+
export interface CreateArgs<T, R extends object = {}> {
|
|
236
|
+
/**
|
|
237
|
+
* Row data. On typed clients, relation names additionally accept nested
|
|
238
|
+
* write ops ({@link NestedCreateOp}): `create` / `connect` / `connectOrCreate`.
|
|
239
|
+
*/
|
|
240
|
+
data: CreateDataInput<T, R>;
|
|
230
241
|
/** Query timeout in milliseconds. Rejects with an error if exceeded. */
|
|
231
242
|
timeout?: number;
|
|
232
243
|
}
|
|
@@ -267,9 +278,14 @@ export type UpdateOperatorInput<V> = {
|
|
|
267
278
|
export type UpdateInput<T> = {
|
|
268
279
|
[K in keyof T]?: T[K] | UpdateOperatorInput<T[K]>;
|
|
269
280
|
};
|
|
270
|
-
export interface UpdateArgs<T> {
|
|
281
|
+
export interface UpdateArgs<T, R extends object = {}> {
|
|
271
282
|
where: WhereClause<T>;
|
|
272
|
-
|
|
283
|
+
/**
|
|
284
|
+
* Update data. On typed clients, relation names additionally accept nested
|
|
285
|
+
* write ops ({@link NestedUpdateOp}): `create` / `connect` / `connectOrCreate`
|
|
286
|
+
* / `disconnect` / `set` / `delete` / `update` / `upsert`.
|
|
287
|
+
*/
|
|
288
|
+
data: UpdateDataInput<T, R>;
|
|
273
289
|
/** Query timeout in milliseconds. Rejects with an error if exceeded. */
|
|
274
290
|
timeout?: number;
|
|
275
291
|
/**
|
|
@@ -331,23 +347,57 @@ export interface UpsertArgs<T> {
|
|
|
331
347
|
/** Query timeout in milliseconds. Rejects with an error if exceeded. */
|
|
332
348
|
timeout?: number;
|
|
333
349
|
}
|
|
334
|
-
|
|
350
|
+
/** `connectOrCreate` op: connect to the row matching `where`, or create it. */
|
|
351
|
+
export interface ConnectOrCreateOp<T, TR extends object = {}> {
|
|
335
352
|
where: Partial<T>;
|
|
336
|
-
create:
|
|
353
|
+
create: CreateDataInput<T, TR>;
|
|
337
354
|
}
|
|
338
|
-
|
|
339
|
-
|
|
355
|
+
/** Nested write ops valid inside `create()` data for a relation field. */
|
|
356
|
+
export interface NestedCreateOp<T, TR extends object = {}> {
|
|
357
|
+
create?: CreateDataInput<T, TR> | CreateDataInput<T, TR>[];
|
|
340
358
|
connect?: Partial<T> | Partial<T>[];
|
|
341
|
-
connectOrCreate?: ConnectOrCreateOp<T> | ConnectOrCreateOp<T>[];
|
|
359
|
+
connectOrCreate?: ConnectOrCreateOp<T, TR> | ConnectOrCreateOp<T, TR>[];
|
|
360
|
+
}
|
|
361
|
+
/** A nested `update` op item: update the related row(s) matching `where`. `where` is optional for belongsTo relations (derived from the parent's FK). */
|
|
362
|
+
export interface NestedUpdateOpItem<T, TR extends object = {}> {
|
|
363
|
+
where?: Partial<T>;
|
|
364
|
+
data: UpdateDataInput<T, TR>;
|
|
342
365
|
}
|
|
343
|
-
|
|
344
|
-
|
|
366
|
+
/** A nested `upsert` op item: update the row matching `where` or create it. */
|
|
367
|
+
export interface NestedUpsertOpItem<T, TR extends object = {}> {
|
|
368
|
+
where: Partial<T>;
|
|
369
|
+
create: CreateDataInput<T, TR>;
|
|
370
|
+
update: UpdateDataInput<T, TR>;
|
|
371
|
+
}
|
|
372
|
+
/** Nested write ops valid inside `update()` data for a relation field. */
|
|
373
|
+
export interface NestedUpdateOp<T, TR extends object = {}> {
|
|
374
|
+
create?: CreateDataInput<T, TR> | CreateDataInput<T, TR>[];
|
|
345
375
|
connect?: Partial<T> | Partial<T>[];
|
|
346
|
-
connectOrCreate?: ConnectOrCreateOp<T> | ConnectOrCreateOp<T>[];
|
|
376
|
+
connectOrCreate?: ConnectOrCreateOp<T, TR> | ConnectOrCreateOp<T, TR>[];
|
|
347
377
|
disconnect?: Partial<T> | Partial<T>[];
|
|
348
378
|
set?: Partial<T>[];
|
|
349
379
|
delete?: Partial<T> | Partial<T>[];
|
|
380
|
+
update?: NestedUpdateOpItem<T, TR> | NestedUpdateOpItem<T, TR>[];
|
|
381
|
+
upsert?: NestedUpsertOpItem<T, TR> | NestedUpsertOpItem<T, TR>[];
|
|
350
382
|
}
|
|
383
|
+
/**
|
|
384
|
+
* `create()` data input. When the relations map `R` is known (typed clients),
|
|
385
|
+
* each relation name additionally accepts a {@link NestedCreateOp} for the
|
|
386
|
+
* relation's target entity — recursively, via the target's own relations map.
|
|
387
|
+
* When `R` is `{}` (untyped escape hatch) this collapses to plain `Partial<T>`.
|
|
388
|
+
*/
|
|
389
|
+
export type CreateDataInput<T, R extends object = {}> = [keyof R] extends [never] ? Partial<T> : Partial<T> & {
|
|
390
|
+
[K in keyof R]?: NestedCreateOp<RelationTarget<R[K]> & object, RelationRelations<R[K]> & object>;
|
|
391
|
+
};
|
|
392
|
+
/**
|
|
393
|
+
* `update()` data input. Like {@link CreateDataInput} but relation fields
|
|
394
|
+
* accept the full {@link NestedUpdateOp} surface (disconnect / set / delete /
|
|
395
|
+
* update / upsert in addition to the create-context ops), and scalar fields
|
|
396
|
+
* accept atomic {@link UpdateOperatorInput} objects.
|
|
397
|
+
*/
|
|
398
|
+
export type UpdateDataInput<T, R extends object = {}> = [keyof R] extends [never] ? UpdateInput<T> : UpdateInput<T> & {
|
|
399
|
+
[K in keyof R]?: NestedUpdateOp<RelationTarget<R[K]> & object, RelationRelations<R[K]> & object>;
|
|
400
|
+
};
|
|
351
401
|
export interface CountArgs<T> {
|
|
352
402
|
where?: WhereClause<T>;
|
|
353
403
|
/** Query timeout in milliseconds. Rejects with an error if exceeded. */
|
package/dist/query/utils.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "turbine-orm",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.2",
|
|
4
4
|
"description": "Postgres-native TypeScript ORM — runs on Neon, Vercel Postgres, Cloudflare, Supabase. Streaming cursors, typed errors, single-query nested relations. One dependency, no WASM engine",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"sideEffects": false,
|
|
43
43
|
"scripts": {
|
|
44
44
|
"prebuild": "npm run gen:studio",
|
|
45
|
-
"build": "tsc && tsc --project tsconfig.cjs.json && echo '{\"type\":\"commonjs\"}' > dist/cjs/package.json",
|
|
45
|
+
"build": "rm -rf dist && tsc && tsc --project tsconfig.cjs.json && echo '{\"type\":\"commonjs\"}' > dist/cjs/package.json",
|
|
46
46
|
"dev": "tsc --watch",
|
|
47
47
|
"typecheck": "tsc --noEmit --project tsconfig.test.json",
|
|
48
48
|
"generate": "tsx src/cli/index.ts generate",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"examples": "tsx examples/examples.ts",
|
|
51
51
|
"dogfood": "tsx examples/dogfood.ts",
|
|
52
52
|
"test": "tsx --test --test-concurrency=1 src/test/*.test.ts",
|
|
53
|
-
"test:unit": "tsx --test src/test
|
|
53
|
+
"test:unit": "DATABASE_URL= tsx --test src/test/*.test.ts",
|
|
54
54
|
"test:coverage": "c8 tsx --test --test-concurrency=1 src/test/*.test.ts",
|
|
55
55
|
"lint": "biome check src/",
|
|
56
56
|
"lint:fix": "biome check --write src/",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"prepare": "husky",
|
|
60
60
|
"size": "size-limit",
|
|
61
61
|
"size:check": "size-limit",
|
|
62
|
-
"test:watch": "tsx --watch --test src/test
|
|
62
|
+
"test:watch": "tsx --watch --test src/test/*.test.ts",
|
|
63
63
|
"db:seed": "psql $DATABASE_URL -v ON_ERROR_STOP=1 -f src/test/fixtures/seed.sql",
|
|
64
64
|
"db:reset": "psql $DATABASE_URL -c 'DROP SCHEMA public CASCADE; CREATE SCHEMA public;' && npm run db:seed",
|
|
65
65
|
"site:dev": "cd site && npm run dev",
|