uql-orm 0.109.1 → 0.109.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/dist/index.d.ts CHANGED
@@ -10,6 +10,6 @@ export { filledKey, idKey, isSqlQuerier, versionKey } from './type/index.js';
10
10
  export { withDeleted } from './util/filters.util.js';
11
11
  export { sortOf } from './util/query.util.js';
12
12
  export { DefaultLogger } from './util/logger.js';
13
- export { aliasOf, currentDate, currentTime, currentTimestamp, raw, refs, sql, tableOf, uuid, uuidv7, } from './util/sql.js';
13
+ export { aliasOf, currentDate, currentTime, currentTimestamp, refs, sql, tableOf, uuid, uuidv7 } from './util/sql.js';
14
14
  export { deleteFrom, insertInto, refuse, type TriggerUpsert, updateTable, upsertInto } from './util/triggerWrite.js';
15
15
  export { type QueryErrorKind, UqlError, UqlOptimisticLockError, UqlSecurityError, UqlUsageError, } from './util/uqlError.js';
package/dist/index.js CHANGED
@@ -9,6 +9,6 @@ export { filledKey, idKey, isSqlQuerier, versionKey } from './type/index.js';
9
9
  export { withDeleted } from './util/filters.util.js';
10
10
  export { sortOf } from './util/query.util.js';
11
11
  export { DefaultLogger } from './util/logger.js';
12
- export { aliasOf, currentDate, currentTime, currentTimestamp, raw, refs, sql, tableOf, uuid, uuidv7, } from './util/sql.js';
12
+ export { aliasOf, currentDate, currentTime, currentTimestamp, refs, sql, tableOf, uuid, uuidv7 } from './util/sql.js';
13
13
  export { deleteFrom, insertInto, refuse, updateTable, upsertInto } from './util/triggerWrite.js';
14
14
  export { UqlError, UqlOptimisticLockError, UqlSecurityError, UqlUsageError, } from './util/uqlError.js';
@@ -1,31 +1,25 @@
1
1
  import type { EntityMeta, EntityWhereMeta, FieldOptions, AbstractType } from '../type/index.js';
2
2
  import { SchemaAST } from './schemaAST.js';
3
3
  import { type ForeignKeyAction, type TriggerSchema } from './types.js';
4
- /**
5
- * Options for building SchemaAST from entities.
6
- */
4
+ /** What a build needs from its dialect, which `SqlSchemaGenerator.buildAST` supplies. */
7
5
  export interface BuildSchemaASTOptions {
8
- /** Custom resolver for a table's own name, unqualified. */
9
- resolveTableName?: (meta: EntityMeta<object>) => string;
10
- /** Custom resolver for the schema a table lives in; `undefined` leaves it unqualified. */
11
- resolveSchema?: (meta: EntityMeta<object>) => string | undefined;
12
- /** Custom column name resolver */
13
- resolveColumnName?: (key: string, field: FieldOptions) => string;
6
+ /** A table's own name, unqualified. */
7
+ resolveTableName: (meta: EntityMeta<object>) => string;
8
+ /** The schema a table lives in; `undefined` leaves it unqualified. */
9
+ resolveSchema: (meta: EntityMeta<object>) => string | undefined;
10
+ resolveColumnName: (key: string, field: FieldOptions) => string;
14
11
  /** Default action for foreign key ON DELETE and ON UPDATE clauses */
15
- defaultForeignKeyAction?: ForeignKeyAction;
16
- /**
17
- * The text of SQL an entity declares - a check, a stored computed column, an index expression or
18
- * predicate - which only a dialect can render. `SqlSchemaGenerator.buildAST` supplies it.
19
- */
20
- compileDdl?: (sql: EntityWhereMeta<object>, entity: AbstractType<object>) => string;
21
- /** A partial index's predicate as the engine writes it, `compileDdl` where none is given. */
22
- compileIndexPredicate?: (where: EntityWhereMeta<object>, entity: AbstractType<object>, indexName: string) => string;
12
+ defaultForeignKeyAction: ForeignKeyAction;
13
+ /** The text of SQL an entity declares: a check, a stored computed column, an index expression or predicate. */
14
+ compileDdl: (sql: EntityWhereMeta<object>, entity: AbstractType<object>) => string;
15
+ /** A partial index's predicate as the engine writes it. */
16
+ compileIndexPredicate: (where: EntityWhereMeta<object>, entity: AbstractType<object>, indexName: string) => string;
23
17
  /** Whether a weighted fulltext index declares one of its own for each heavier column, as MySQL scores through one. */
24
- textScoreIndexes?: boolean;
18
+ textScoreIndexes: boolean;
25
19
  /** Whether a column a vector index covers is `NOT NULL` whatever the entity declares, as MariaDB demands. */
26
- vectorIndexRequiresNotNull?: boolean;
27
- /** The triggers an entity's table carries, as its dialect renders them; none where no dialect renders any. */
28
- renderTriggers?: (meta: EntityMeta<object>) => TriggerSchema[];
20
+ vectorIndexRequiresNotNull: boolean;
21
+ /** The triggers an entity's table carries, as its dialect renders them. */
22
+ renderTriggers: (meta: EntityMeta<object>) => TriggerSchema[];
29
23
  }
30
24
  /**
31
25
  * Build a SchemaAST from entity classes (decorated with `@Entity`, `@Field`, etc.).
@@ -33,4 +27,4 @@ export interface BuildSchemaASTOptions {
33
27
  * Three passes, because each needs the one before it to have finished for *every* entity: a relation
34
28
  * resolves against a table another entity declares, and an index against the columns of its own.
35
29
  */
36
- export declare function buildSchemaAST(entities: readonly AbstractType<object>[], options?: BuildSchemaASTOptions): SchemaAST;
30
+ export declare function buildSchemaAST(entities: readonly AbstractType<object>[], options: BuildSchemaASTOptions): SchemaAST;
@@ -3,34 +3,20 @@ import { declaredIndexes, enumCheck, ownedCheck, renderIndex } from '../util/ddl
3
3
  import { fulltextWeights, textWeightSteps } from '../util/dialect.util.js';
4
4
  import { isInlinedExpression } from '../util/field.util.js';
5
5
  import { entryColumn, entryColumns, renamedEntry } from '../util/indexEntry.util.js';
6
- import { definedEntries, entityName } from '../util/object.util.js';
6
+ import { definedEntries } from '../util/object.util.js';
7
7
  import { derivedForeignKeyName, derivedIndexName } from '../util/sql.util.js';
8
- import { UqlUsageError } from '../util/uqlError.js';
9
8
  import { declaredColumn } from './declaredColumn.js';
10
9
  import { lookupColumns } from './indexColumns.js';
11
10
  import { createTableNode, keyOfColumns, SchemaAST } from './schemaAST.js';
12
- import { DEFAULT_FOREIGN_KEY_ACTION, } from './types.js';
11
+ import {} from './types.js';
13
12
  /**
14
13
  * Build a SchemaAST from entity classes (decorated with `@Entity`, `@Field`, etc.).
15
14
  *
16
15
  * Three passes, because each needs the one before it to have finished for *every* entity: a relation
17
16
  * resolves against a table another entity declares, and an index against the columns of its own.
18
17
  */
19
- export function buildSchemaAST(entities, options = {}) {
20
- const compileDdl = options.compileDdl ?? refuseDdl;
21
- const ctx = {
22
- ast: new SchemaAST(),
23
- tables: new Map(),
24
- resolveTableName: options.resolveTableName ?? entityName,
25
- resolveSchema: options.resolveSchema ?? ((m) => m.schema),
26
- resolveColumnName: options.resolveColumnName ?? ((key, field) => field.name ?? key),
27
- defaultForeignKeyAction: options.defaultForeignKeyAction ?? DEFAULT_FOREIGN_KEY_ACTION,
28
- compileDdl,
29
- compileIndexPredicate: options.compileIndexPredicate ?? compileDdl,
30
- textScoreIndexes: options.textScoreIndexes ?? false,
31
- vectorIndexRequiresNotNull: options.vectorIndexRequiresNotNull ?? false,
32
- renderTriggers: options.renderTriggers ?? (() => []),
33
- };
18
+ export function buildSchemaAST(entities, options) {
19
+ const ctx = { ...options, ast: new SchemaAST(), tables: new Map() };
34
20
  for (const entity of entities) {
35
21
  const meta = getMeta(entity);
36
22
  ctx.tables.set(meta, addTableFromEntity(ctx, meta));
@@ -42,10 +28,6 @@ export function buildSchemaAST(entities, options = {}) {
42
28
  }
43
29
  return ctx.ast;
44
30
  }
45
- /** The `compileDdl` of a build given no dialect, which has nothing to render an entity's SQL with. */
46
- function refuseDdl() {
47
- throw new UqlUsageError('building the schema of an entity that declares SQL (a check, a stored computed column, an index expression or predicate) needs a dialect to render it: pass `compileDdl`, as `SqlSchemaGenerator.buildAST` does');
48
- }
49
31
  /** The members a vector index of `meta` covers by name. */
50
32
  function vectorIndexedEntries(meta) {
51
33
  return new Set((meta.indexes ?? []).filter((index) => index.type === 'vector').flatMap((index) => entryColumns(index.entries)));
@@ -85,6 +85,4 @@ export declare function columnRef(entity: EntitySource<unknown> | undefined, key
85
85
  export declare function refOwner(entity: AbstractType<unknown> | undefined, key: string, scope: {
86
86
  readonly entity?: AbstractType<unknown>;
87
87
  }): AbstractType<unknown>;
88
- /** @deprecated Renamed to {@link sql}, the tag editors recognise for SQL highlighting. */
89
- export declare const raw: typeof sql;
90
88
  export {};
package/dist/util/sql.js CHANGED
@@ -292,8 +292,6 @@ function qualifiedBy({ row, alias }, { dialect }) {
292
292
  function grouped(computed) {
293
293
  return computed instanceof RelationAggregate ? computed : sql `(${computed})`;
294
294
  }
295
- /** @deprecated Renamed to {@link sql}, the tag editors recognise for SQL highlighting. */
296
- export const raw = sql;
297
295
  /** A tag call passes the frozen strings array, which carries its own `sql` counterpart. */
298
296
  function isTemplateStrings(value) {
299
297
  return Array.isArray(value) && Array.isArray(Reflect.get(value, 'raw'));
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "homepage": "https://uql-orm.dev",
4
4
  "description": "JSON-native TypeScript ORM for Bun, Browsers, Edge, Node, Workers. Supports PostgreSQL, PGlite, MySQL, MariaDB, SQLite, CockroachDB, SQL Server, Turso, Neon, Cloudflare D1 and MongoDB. Queries are plain JSON, typed to the leaf.",
5
5
  "license": "MIT",
6
- "version": "0.109.1",
6
+ "version": "0.109.2",
7
7
  "type": "module",
8
8
  "engines": {
9
9
  "node": ">=22.18"