@danceroutine/tango-orm 1.11.10 → 1.11.11

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.
@@ -246,6 +246,7 @@ declare abstract class QuerySet<TModel extends Record<string, unknown>, TBaseRes
246
246
  * reaching into a base-class instance's protected state.
247
247
  */
248
248
  protected static buildOrderSpecs<T extends Record<string, unknown>>(tokens: readonly OrderToken<T>[]): OrderSpec<T>[];
249
+ private static validateQueryWindowBound;
249
250
  private static invertOrderSpec;
250
251
  /**
251
252
  * Add a filter expression to the query.
@@ -1308,4 +1309,4 @@ interface QuerySetState<T, TSourceModel = unknown> {
1308
1309
  }
1309
1310
  //#endregion
1310
1311
  export { QBuilder as A, index_d_exports$2 as B, ReverseSingleRelations as C, ManyToManyRelatedManagerCreateInputs as D, ManyToManyRelatedManager as E, QNode as F, TableMeta as H, FilterInput as I, FilterValue as L, QueryExecutor as M, QuerySet as N, ManyToManyTargetRef as O, OrderToken as P, FilterKey as R, ReverseCollectionRelations as S, SingleRelationHydrationCardinality as T, QueryResult as U, QueryCompiler as V, ManyRelationHydrationCardinality as _, TableMetaFactory as a, RelationHydrationCardinality as b, RelationMeta as c, GeneratedPrefetchRelatedPathKeys as d, GeneratedRelationFilterKeys as f, InternalRelationHydrationCardinality as g, HydratedRelationMap as h, WhereClause as i, ModelQuerySet as j, index_d_exports$1 as k, ForwardSingleRelations as l, HydratedQueryResult as m, OrderSpec as n, Direction as o, GeneratedSelectRelatedPathKeys as p, index_d_exports as r, CompiledQuery as s, QuerySetState as t, GeneratedHydratedRelationMap as u, MaybeHydratedRelationMap as v, SelectRelatedRelations as w, RelationKeys as x, PrefetchRelatedRelations as y, LookupType as z };
1311
- //# sourceMappingURL=QuerySetState-DRL9-rKQ.d.ts.map
1312
+ //# sourceMappingURL=QuerySetState-C8NgnYTc.d.ts.map
@@ -1,4 +1,4 @@
1
- import { a as MaterializedModelRecord, n as ModelManager, r as TangoRuntime, t as registerModelObjects } from "./registerModelObjects-CEqCRlVY.js";
1
+ import { a as MaterializedModelRecord, n as ModelManager, r as TangoRuntime, t as registerModelObjects } from "./registerModelObjects-UMxYImMK.js";
2
2
  import { z } from "zod";
3
3
  import { Model } from "@danceroutine/tango-schema/domain";
4
4
 
@@ -28,4 +28,4 @@ declare global {
28
28
  }
29
29
  //#endregion
30
30
  export { resetTangoRuntime as i, getTangoRuntime as n, initializeTangoRuntime as r, index_d_exports as t };
31
- //# sourceMappingURL=index-CCvYeJt4.d.ts.map
31
+ //# sourceMappingURL=index-O_dY4tRf.d.ts.map
@@ -1,5 +1,5 @@
1
- import { D as ManyToManyRelatedManagerCreateInputs, E as ManyToManyRelatedManager, M as QueryExecutor, N as QuerySet, O as ManyToManyTargetRef, U as QueryResult, t as QuerySetState } from "./QuerySetState-DRL9-rKQ.js";
2
- import { a as MaterializedModelRecord, i as ManagerLike, n as ModelManager, t as registerModelObjects } from "./registerModelObjects-CEqCRlVY.js";
1
+ import { D as ManyToManyRelatedManagerCreateInputs, E as ManyToManyRelatedManager, M as QueryExecutor, N as QuerySet, O as ManyToManyTargetRef, U as QueryResult, t as QuerySetState } from "./QuerySetState-C8NgnYTc.js";
2
+ import { a as MaterializedModelRecord, i as ManagerLike, n as ModelManager, t as registerModelObjects } from "./registerModelObjects-UMxYImMK.js";
3
3
 
4
4
  //#region src/manager/relations/ManyToManyRelatedQuerySet.d.ts
5
5
  /**
@@ -68,4 +68,4 @@ declare namespace index_d_exports {
68
68
  }
69
69
  //#endregion
70
70
  export { ManyToManyRelatedQuerySetBridge as i, index_d_exports$1 as n, ManyToManyRelatedQuerySet as r, index_d_exports as t };
71
- //# sourceMappingURL=index-CJlkeldS.d.ts.map
71
+ //# sourceMappingURL=index-d9NRHwNe.d.ts.map
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { t as DBClient } from "./DBClient-DuYcXolQ.js";
2
2
  import { i as Dialect, n as AdapterConfig, t as Adapter } from "./Adapter-DKxAaL4l.js";
3
3
  import { c as getDefaultAdapterRegistry, l as SqliteAdapter, o as AdapterRegistry, s as connectDB, t as index_d_exports, u as PostgresAdapter } from "./index-o2LFpJ8S.js";
4
- import { A as QBuilder, E as ManyToManyRelatedManager, F as QNode, H as TableMeta, I as FilterInput, L as FilterValue, M as QueryExecutor, N as QuerySet, O as ManyToManyTargetRef, P as OrderToken, R as FilterKey, U as QueryResult, V as QueryCompiler, c as RelationMeta, i as WhereClause, j as ModelQuerySet, k as index_d_exports$2, n as OrderSpec, o as Direction, s as CompiledQuery, t as QuerySetState, z as LookupType } from "./QuerySetState-DRL9-rKQ.js";
5
- import { t as index_d_exports$1 } from "./index-CJlkeldS.js";
6
- import { a as MaterializedModelRecord, i as ManagerLike, n as ModelManager, r as TangoRuntime } from "./registerModelObjects-CEqCRlVY.js";
7
- import { i as resetTangoRuntime, n as getTangoRuntime, r as initializeTangoRuntime, t as index_d_exports$3 } from "./index-CCvYeJt4.js";
4
+ import { A as QBuilder, E as ManyToManyRelatedManager, F as QNode, H as TableMeta, I as FilterInput, L as FilterValue, M as QueryExecutor, N as QuerySet, O as ManyToManyTargetRef, P as OrderToken, R as FilterKey, U as QueryResult, V as QueryCompiler, c as RelationMeta, i as WhereClause, j as ModelQuerySet, k as index_d_exports$2, n as OrderSpec, o as Direction, s as CompiledQuery, t as QuerySetState, z as LookupType } from "./QuerySetState-C8NgnYTc.js";
5
+ import { t as index_d_exports$1 } from "./index-d9NRHwNe.js";
6
+ import { a as MaterializedModelRecord, i as ManagerLike, n as ModelManager, r as TangoRuntime } from "./registerModelObjects-UMxYImMK.js";
7
+ import { i as resetTangoRuntime, n as getTangoRuntime, r as initializeTangoRuntime, t as index_d_exports$3 } from "./index-O_dY4tRf.js";
8
8
  import { a as OnCommitOptions, i as AtomicTransaction, n as UnitOfWork, o as SavepointOptions, r as atomic, s as SavepointResult, t as index_d_exports$4 } from "./index-uuG57Y7C.js";
9
9
  export { type Adapter, type AdapterConfig, AdapterRegistry, type AtomicTransaction, type CompiledQuery, type DBClient, type Dialect, type Direction, type FilterInput, type FilterKey, type FilterValue, type LookupType, type ManagerLike, ManyToManyRelatedManager, type ManyToManyTargetRef, type MaterializedModelRecord, ModelManager, ModelQuerySet, type OnCommitOptions, type OrderSpec, type OrderToken, PostgresAdapter, QBuilder as Q, QBuilder, type QNode, QueryCompiler, type QueryExecutor, QueryResult, QuerySet, type QuerySetState, type RelationMeta, type SavepointOptions, type SavepointResult, SqliteAdapter, type TableMeta, TangoRuntime, UnitOfWork, type WhereClause, atomic, connectDB, index_d_exports as connection, getDefaultAdapterRegistry, getTangoRuntime, initializeTangoRuntime, index_d_exports$1 as manager, index_d_exports$2 as query, resetTangoRuntime, index_d_exports$3 as runtime, index_d_exports$4 as transaction };
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { i as PostgresAdapter, t as SqliteAdapter } from "./SqliteAdapter-CrUhpTDb.js";
2
2
  import { a as connectDB, i as AdapterRegistry, o as getDefaultAdapterRegistry, t as connection_exports } from "./connection-B2cDwZ72.js";
3
- import { d as QueryCompiler, i as QBuilder, l as QueryResult, n as ModelQuerySet, r as QuerySet, t as query_exports } from "./query-B-ooqvSG.js";
4
- import { n as ModelManager, r as ManyToManyRelatedManager } from "./registerModelObjects-BKGs2c_m.js";
5
- import { t as manager_exports } from "./manager-GMmYq4lC.js";
3
+ import { d as QueryCompiler, i as QBuilder, l as QueryResult, n as ModelQuerySet, r as QuerySet, t as query_exports } from "./query-D_93uktq.js";
4
+ import { n as ModelManager, r as ManyToManyRelatedManager } from "./registerModelObjects-41ocGQmv.js";
5
+ import { t as manager_exports } from "./manager-VoPL1sc3.js";
6
6
  import { i as TangoRuntime, n as initializeTangoRuntime, r as resetTangoRuntime, t as getTangoRuntime } from "./defaultRuntime-WIsxnh8K.js";
7
7
  import { t as runtime_exports } from "./runtime/index.js";
8
8
  import { n as UnitOfWork, r as atomic, t as transaction_exports } from "./transaction-DpDXQq5V.js";
@@ -1,4 +1,4 @@
1
- import { D as ManyToManyRelatedManagerCreateInputs, E as ManyToManyRelatedManager, O as ManyToManyTargetRef } from "../QuerySetState-DRL9-rKQ.js";
2
- import { i as ManyToManyRelatedQuerySetBridge, n as index_d_exports, r as ManyToManyRelatedQuerySet } from "../index-CJlkeldS.js";
3
- import { a as MaterializedModelRecord, i as ManagerLike, n as ModelManager, t as registerModelObjects } from "../registerModelObjects-CEqCRlVY.js";
1
+ import { D as ManyToManyRelatedManagerCreateInputs, E as ManyToManyRelatedManager, O as ManyToManyTargetRef } from "../QuerySetState-C8NgnYTc.js";
2
+ import { i as ManyToManyRelatedQuerySetBridge, n as index_d_exports, r as ManyToManyRelatedQuerySet } from "../index-d9NRHwNe.js";
3
+ import { a as MaterializedModelRecord, i as ManagerLike, n as ModelManager, t as registerModelObjects } from "../registerModelObjects-UMxYImMK.js";
4
4
  export { type ManagerLike, ManyToManyRelatedManager, type ManyToManyRelatedManagerCreateInputs, ManyToManyRelatedQuerySet, type ManyToManyRelatedQuerySetBridge, type ManyToManyTargetRef, type MaterializedModelRecord, ModelManager, registerModelObjects, index_d_exports as relations };
@@ -1,3 +1,3 @@
1
- import { i as ManyToManyRelatedQuerySet, n as ModelManager, r as ManyToManyRelatedManager, t as registerModelObjects } from "../registerModelObjects-BKGs2c_m.js";
2
- import { n as relations_exports } from "../manager-GMmYq4lC.js";
1
+ import { i as ManyToManyRelatedQuerySet, n as ModelManager, r as ManyToManyRelatedManager, t as registerModelObjects } from "../registerModelObjects-41ocGQmv.js";
2
+ import { n as relations_exports } from "../manager-VoPL1sc3.js";
3
3
  export { ManyToManyRelatedManager, ManyToManyRelatedQuerySet, ModelManager, registerModelObjects, relations_exports as relations };
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "./chunk-8H4AJuhK.js";
2
- import { i as ManyToManyRelatedQuerySet, n as ModelManager, r as ManyToManyRelatedManager, t as registerModelObjects } from "./registerModelObjects-BKGs2c_m.js";
2
+ import { i as ManyToManyRelatedQuerySet, n as ModelManager, r as ManyToManyRelatedManager, t as registerModelObjects } from "./registerModelObjects-41ocGQmv.js";
3
3
  //#region src/manager/relations/index.ts
4
4
  var relations_exports = /* @__PURE__ */ __exportAll({
5
5
  ManyToManyRelatedManager: () => ManyToManyRelatedManager,
@@ -17,4 +17,4 @@ var manager_exports = /* @__PURE__ */ __exportAll({
17
17
  //#endregion
18
18
  export { relations_exports as n, manager_exports as t };
19
19
 
20
- //# sourceMappingURL=manager-GMmYq4lC.js.map
20
+ //# sourceMappingURL=manager-VoPL1sc3.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"manager-GMmYq4lC.js","names":[],"sources":["../src/manager/relations/index.ts","../src/manager/index.ts"],"sourcesContent":["/**\n * Domain boundary barrel: centralizes ORM relation managers attached to\n * materialized model records.\n */\n\nexport { ManyToManyRelatedQuerySet } from './ManyToManyRelatedQuerySet';\nexport type { ManyToManyRelatedQuerySetBridge } from './ManyToManyRelatedQuerySet';\nexport { ManyToManyRelatedManager } from './ManyToManyRelatedManager';\nexport type { ManyToManyRelatedManagerCreateInputs, ManyToManyTargetRef } from './ManyToManyRelatedManager';\nexport type { MaterializedModelRecord } from './MaterializedModelRecord';\n","/**\n * Domain boundary barrel: centralizes manager-first ORM APIs.\n */\nexport * as relations from './relations/index';\n\nexport type { ManagerLike } from './ManagerLike';\nexport { ModelManager } from './ModelManager';\nexport { registerModelObjects } from './registerModelObjects';\nexport { ManyToManyRelatedQuerySet } from './relations/ManyToManyRelatedQuerySet';\nexport type { ManyToManyRelatedQuerySetBridge } from './relations/ManyToManyRelatedQuerySet';\nexport { ManyToManyRelatedManager } from './relations/ManyToManyRelatedManager';\nexport type { ManyToManyRelatedManagerCreateInputs, ManyToManyTargetRef } from './relations/ManyToManyRelatedManager';\nexport type { MaterializedModelRecord } from './relations/MaterializedModelRecord';\n"],"mappings":""}
1
+ {"version":3,"file":"manager-VoPL1sc3.js","names":[],"sources":["../src/manager/relations/index.ts","../src/manager/index.ts"],"sourcesContent":["/**\n * Domain boundary barrel: centralizes ORM relation managers attached to\n * materialized model records.\n */\n\nexport { ManyToManyRelatedQuerySet } from './ManyToManyRelatedQuerySet';\nexport type { ManyToManyRelatedQuerySetBridge } from './ManyToManyRelatedQuerySet';\nexport { ManyToManyRelatedManager } from './ManyToManyRelatedManager';\nexport type { ManyToManyRelatedManagerCreateInputs, ManyToManyTargetRef } from './ManyToManyRelatedManager';\nexport type { MaterializedModelRecord } from './MaterializedModelRecord';\n","/**\n * Domain boundary barrel: centralizes manager-first ORM APIs.\n */\nexport * as relations from './relations/index';\n\nexport type { ManagerLike } from './ManagerLike';\nexport { ModelManager } from './ModelManager';\nexport { registerModelObjects } from './registerModelObjects';\nexport { ManyToManyRelatedQuerySet } from './relations/ManyToManyRelatedQuerySet';\nexport type { ManyToManyRelatedQuerySetBridge } from './relations/ManyToManyRelatedQuerySet';\nexport { ManyToManyRelatedManager } from './relations/ManyToManyRelatedManager';\nexport type { ManyToManyRelatedManagerCreateInputs, ManyToManyTargetRef } from './relations/ManyToManyRelatedManager';\nexport type { MaterializedModelRecord } from './relations/MaterializedModelRecord';\n"],"mappings":""}
@@ -1,3 +1,3 @@
1
1
  import { i as Dialect } from "../Adapter-DKxAaL4l.js";
2
- import { A as QBuilder, B as index_d_exports, C as ReverseSingleRelations, F as QNode, H as TableMeta, I as FilterInput, L as FilterValue, M as QueryExecutor, N as QuerySet, P as OrderToken, R as FilterKey, S as ReverseCollectionRelations, T as SingleRelationHydrationCardinality, U as QueryResult, V as QueryCompiler, _ as ManyRelationHydrationCardinality, a as TableMetaFactory, b as RelationHydrationCardinality, c as RelationMeta, d as GeneratedPrefetchRelatedPathKeys, f as GeneratedRelationFilterKeys, g as InternalRelationHydrationCardinality, h as HydratedRelationMap, i as WhereClause, j as ModelQuerySet, l as ForwardSingleRelations, m as HydratedQueryResult, n as OrderSpec, o as Direction, p as GeneratedSelectRelatedPathKeys, r as index_d_exports$1, s as CompiledQuery, t as QuerySetState, u as GeneratedHydratedRelationMap, v as MaybeHydratedRelationMap, w as SelectRelatedRelations, x as RelationKeys, y as PrefetchRelatedRelations, z as LookupType } from "../QuerySetState-DRL9-rKQ.js";
2
+ import { A as QBuilder, B as index_d_exports, C as ReverseSingleRelations, F as QNode, H as TableMeta, I as FilterInput, L as FilterValue, M as QueryExecutor, N as QuerySet, P as OrderToken, R as FilterKey, S as ReverseCollectionRelations, T as SingleRelationHydrationCardinality, U as QueryResult, V as QueryCompiler, _ as ManyRelationHydrationCardinality, a as TableMetaFactory, b as RelationHydrationCardinality, c as RelationMeta, d as GeneratedPrefetchRelatedPathKeys, f as GeneratedRelationFilterKeys, g as InternalRelationHydrationCardinality, h as HydratedRelationMap, i as WhereClause, j as ModelQuerySet, l as ForwardSingleRelations, m as HydratedQueryResult, n as OrderSpec, o as Direction, p as GeneratedSelectRelatedPathKeys, r as index_d_exports$1, s as CompiledQuery, t as QuerySetState, u as GeneratedHydratedRelationMap, v as MaybeHydratedRelationMap, w as SelectRelatedRelations, x as RelationKeys, y as PrefetchRelatedRelations, z as LookupType } from "../QuerySetState-C8NgnYTc.js";
3
3
  export { type CompiledQuery, type Dialect, type Direction, type FilterInput, type FilterKey, type FilterValue, type ForwardSingleRelations, type GeneratedHydratedRelationMap, type GeneratedPrefetchRelatedPathKeys, type GeneratedRelationFilterKeys, type GeneratedSelectRelatedPathKeys, type HydratedQueryResult, type HydratedRelationMap, type InternalRelationHydrationCardinality, type LookupType, type ManyRelationHydrationCardinality, type MaybeHydratedRelationMap, ModelQuerySet, type OrderSpec, type OrderToken, type PrefetchRelatedRelations, QBuilder as Q, QBuilder, type QNode, QueryCompiler, type QueryExecutor, QueryResult, QuerySet, type QuerySetState, type RelationHydrationCardinality, type RelationKeys, type RelationMeta, type ReverseCollectionRelations, type ReverseSingleRelations, type SelectRelatedRelations, type SingleRelationHydrationCardinality, type TableMeta, type TableMetaFactory, type WhereClause, index_d_exports as compiler, index_d_exports$1 as domain };
@@ -1,2 +1,2 @@
1
- import { d as QueryCompiler, i as QBuilder, l as QueryResult, n as ModelQuerySet, o as domain_exports, r as QuerySet, u as compiler_exports } from "../query-B-ooqvSG.js";
1
+ import { d as QueryCompiler, i as QBuilder, l as QueryResult, n as ModelQuerySet, o as domain_exports, r as QuerySet, u as compiler_exports } from "../query-D_93uktq.js";
2
2
  export { ModelQuerySet, QBuilder as Q, QBuilder, QueryCompiler, QueryResult, QuerySet, compiler_exports as compiler, domain_exports as domain };
@@ -463,8 +463,9 @@ var QueryCompiler = class QueryCompiler {
463
463
  ].join(", ");
464
464
  const whereSQL = whereParts.length ? ` WHERE ${whereParts.join(" AND ")}` : "";
465
465
  const orderSQL = ` ORDER BY ${state.order?.length ? state.order.map((order) => `${validatedPlan.orderFields[String(order.by)]} ${order.dir.toUpperCase()}`).join(", ") : `${table}.${validatedPlan.meta.pk} ASC`}`;
466
- const limitSQL = state.limit ? ` LIMIT ${state.limit}` : "";
467
- const offsetSQL = state.offset ? ` OFFSET ${state.offset}` : "";
466
+ const hasOffset = state.offset !== void 0;
467
+ const limitSQL = state.limit !== void 0 ? ` LIMIT ${state.limit}` : hasOffset && this.adapter.dialect === InternalDialect.SQLITE ? " LIMIT -1" : "";
468
+ const offsetSQL = state.offset !== void 0 ? ` OFFSET ${state.offset}` : "";
468
469
  return {
469
470
  sql: `SELECT ${select} FROM ${table}${joinCollection.joins.length ? ` ${joinCollection.joins.join(" ")}` : ""}${whereSQL}${orderSQL}${limitSQL}${offsetSQL}`,
470
471
  params,
@@ -1162,6 +1163,11 @@ var QuerySet = class QuerySet {
1162
1163
  };
1163
1164
  });
1164
1165
  }
1166
+ static validateQueryWindowBound(kind, value) {
1167
+ if (typeof value !== "number") throw new TypeError(`QuerySet.${kind}() expects a number.`);
1168
+ if (!Number.isSafeInteger(value) || value < 0) throw new RangeError(`QuerySet.${kind}() expects a non-negative safe integer.`);
1169
+ return value;
1170
+ }
1165
1171
  static invertOrderSpec(order) {
1166
1172
  if (!order?.length) return [];
1167
1173
  return order.map((spec) => ({
@@ -1216,7 +1222,7 @@ var QuerySet = class QuerySet {
1216
1222
  limit(n) {
1217
1223
  return this.spawn({
1218
1224
  ...this.state,
1219
- limit: n
1225
+ limit: QuerySet.validateQueryWindowBound("limit", n)
1220
1226
  });
1221
1227
  }
1222
1228
  /**
@@ -1225,7 +1231,7 @@ var QuerySet = class QuerySet {
1225
1231
  offset(n) {
1226
1232
  return this.spawn({
1227
1233
  ...this.state,
1228
- offset: n
1234
+ offset: QuerySet.validateQueryWindowBound("offset", n)
1229
1235
  });
1230
1236
  }
1231
1237
  select(fields) {
@@ -1590,4 +1596,4 @@ var query_exports = /* @__PURE__ */ __exportAll({
1590
1596
  //#endregion
1591
1597
  export { isQNodeLike as a, InternalRelationKind as c, QueryCompiler as d, OrmSqlSafetyAdapter as f, QBuilder as i, QueryResult as l, InternalQNodeType as m, ModelQuerySet as n, domain_exports as o, InternalSqlValidationPlanKind as p, QuerySet as r, TableMetaFactory as s, query_exports as t, compiler_exports as u };
1592
1598
 
1593
- //# sourceMappingURL=query-B-ooqvSG.js.map
1599
+ //# sourceMappingURL=query-D_93uktq.js.map