turbine-orm 0.32.0 → 0.32.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 +28 -19
- package/dist/cjs/cli/config.js +76 -16
- package/dist/cjs/cli/index.js +174 -19
- package/dist/cjs/client.js +16 -0
- package/dist/cjs/errors.js +62 -4
- package/dist/cjs/generate.js +2 -1
- package/dist/cjs/powql.js +12 -1
- package/dist/cjs/query/builder.js +332 -44
- package/dist/cli/config.d.ts +53 -1
- package/dist/cli/config.js +73 -16
- package/dist/cli/index.d.ts +68 -0
- package/dist/cli/index.js +173 -21
- package/dist/client.js +16 -0
- package/dist/errors.d.ts +22 -2
- package/dist/errors.js +62 -4
- package/dist/generate.js +2 -1
- package/dist/powql.js +12 -1
- package/dist/query/builder.d.ts +57 -0
- package/dist/query/builder.js +332 -44
- package/dist/query/deferred.d.ts +10 -1
- package/dist/query/types.d.ts +40 -2
- package/package.json +3 -2
package/dist/query/types.d.ts
CHANGED
|
@@ -657,6 +657,37 @@ export interface GroupByDistinctOn<T> {
|
|
|
657
657
|
/** Which row survives per combination (required for determinism). */
|
|
658
658
|
orderBy: Record<string, OrderDirection | OrderBySpec | JsonPathOrderBy>;
|
|
659
659
|
}
|
|
660
|
+
/** A per-field aggregate ordering block: field/alias → direction or sort spec. */
|
|
661
|
+
export type GroupByAggregateOrderBy = Record<string, OrderDirection | OrderBySpec>;
|
|
662
|
+
/**
|
|
663
|
+
* {@link GroupByArgs.orderBy}: order the result groups by any column the
|
|
664
|
+
* groupBy result contains.
|
|
665
|
+
*
|
|
666
|
+
* - A plain **by-column** field name, or a **JSON group-key alias** (explicit
|
|
667
|
+
* `alias`, else the last path segment): `{ region: 'asc' }`.
|
|
668
|
+
* - An **aggregate block**: `_count` takes a direction/spec directly
|
|
669
|
+
* (`{ _count: 'desc' }`); `_sum`/`_avg`/`_min`/`_max` take a field map keyed
|
|
670
|
+
* by a requested aggregate field/alias (`{ _sum: { amount: 'desc' } }`).
|
|
671
|
+
*
|
|
672
|
+
* An aggregate ordering that references an aggregate not requested in the same
|
|
673
|
+
* call (or an unknown by-key) throws {@link ValidationError} (E003). Every
|
|
674
|
+
* value accepts an {@link OrderBySpec} for `NULLS FIRST/LAST` placement
|
|
675
|
+
* (PostgreSQL / SQLite only).
|
|
676
|
+
*/
|
|
677
|
+
export interface GroupByOrderBy {
|
|
678
|
+
/** Order by the group's row count (requires `_count` to be selected). */
|
|
679
|
+
_count?: OrderDirection | OrderBySpec;
|
|
680
|
+
/** Order by a requested `_sum` aggregate, keyed by its field/alias. */
|
|
681
|
+
_sum?: GroupByAggregateOrderBy;
|
|
682
|
+
/** Order by a requested `_avg` aggregate, keyed by its field/alias. */
|
|
683
|
+
_avg?: GroupByAggregateOrderBy;
|
|
684
|
+
/** Order by a requested `_min` aggregate, keyed by its field/alias. */
|
|
685
|
+
_min?: GroupByAggregateOrderBy;
|
|
686
|
+
/** Order by a requested `_max` aggregate, keyed by its field/alias. */
|
|
687
|
+
_max?: GroupByAggregateOrderBy;
|
|
688
|
+
/** A by-column field name or JSON group-key alias → direction or sort spec. */
|
|
689
|
+
[key: string]: OrderDirection | OrderBySpec | GroupByAggregateOrderBy | undefined;
|
|
690
|
+
}
|
|
660
691
|
export interface GroupByArgs<T> {
|
|
661
692
|
/** Group keys: plain column field names and/or JSON-path keys ({@link JsonPathGroupKey}). */
|
|
662
693
|
by: ((keyof T & string) | JsonPathGroupKey)[];
|
|
@@ -678,8 +709,15 @@ export interface GroupByArgs<T> {
|
|
|
678
709
|
_max?: GroupByAggregateSpec<T>;
|
|
679
710
|
/** Filter whole groups by their aggregate values (SQL HAVING). JSON-path aggregates key by their alias. */
|
|
680
711
|
having?: HavingClause<T>;
|
|
681
|
-
/**
|
|
682
|
-
|
|
712
|
+
/**
|
|
713
|
+
* Order the result groups. Keys may be any column the groupBy result actually
|
|
714
|
+
* contains: a plain by-column field name, a JSON group-key alias (explicit
|
|
715
|
+
* `alias`, or the last path segment when unaliased), or an aggregate block
|
|
716
|
+
* (`_count`, or `_sum`/`_avg`/`_min`/`_max` mapping a requested field/alias to
|
|
717
|
+
* its direction). Every value supports {@link OrderBySpec} for NULLS
|
|
718
|
+
* placement. See {@link GroupByOrderBy}.
|
|
719
|
+
*/
|
|
720
|
+
orderBy?: GroupByOrderBy;
|
|
683
721
|
/** Query timeout in milliseconds. Rejects with an error if exceeded. */
|
|
684
722
|
timeout?: number;
|
|
685
723
|
/** Opt out of configured {@link GlobalFilters}. See {@link SkipGlobalFilters}. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "turbine-orm",
|
|
3
|
-
"version": "0.32.
|
|
3
|
+
"version": "0.32.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": {
|
|
@@ -75,7 +75,8 @@
|
|
|
75
75
|
"lint:fix": "biome check --write src/",
|
|
76
76
|
"format": "biome format --write src/",
|
|
77
77
|
"prepublishOnly": "npm run build && npm run typecheck && npm run lint && npm run test:unit",
|
|
78
|
-
"
|
|
78
|
+
"prepack": "node scripts/strip-prepare.mjs",
|
|
79
|
+
"postpack": "node scripts/restore-prepare.mjs",
|
|
79
80
|
"size": "size-limit",
|
|
80
81
|
"size:check": "size-limit",
|
|
81
82
|
"test:watch": "tsx --watch --test src/test/*.test.ts",
|