uql-orm 0.101.3 → 0.101.5
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.
|
@@ -200,9 +200,6 @@ export function defineEntity(entity, opts = {}) {
|
|
|
200
200
|
for (const [name, filter] of definedEntries(opts.filters ?? {})) {
|
|
201
201
|
defineFilter(entity, name, filter);
|
|
202
202
|
}
|
|
203
|
-
if (!hasKeys(meta.fields)) {
|
|
204
|
-
throw new UqlUsageError(`'${entity.name}' must have fields`);
|
|
205
|
-
}
|
|
206
203
|
// A later call composes onto the entity, so a name is only ever set, and `derivedName` records that
|
|
207
204
|
// the class name stood in, which is what a naming strategy derives from.
|
|
208
205
|
if (opts.name !== undefined) {
|
|
@@ -218,6 +215,9 @@ export function defineEntity(entity, opts = {}) {
|
|
|
218
215
|
// is the nearer, and nearer wins every merge.
|
|
219
216
|
inheritFrom(meta, parentOf(entity));
|
|
220
217
|
inheritFrom(meta, opts.extends);
|
|
218
|
+
if (!hasKeys(meta.fields)) {
|
|
219
|
+
throw new UqlUsageError(`'${entity.name}' must have fields`);
|
|
220
|
+
}
|
|
221
221
|
// Derive soft-delete from the (inheritance-merged) fields, so own and inherited markers are handled
|
|
222
222
|
// uniformly. Exactly one field may be marked; it auto-registers the built-in `softDelete` read
|
|
223
223
|
// filter (a reserved name - see defineFilter - so it never clobbers a user filter).
|
|
@@ -560,11 +560,20 @@ function extendMeta(target, source) {
|
|
|
560
560
|
if (source.filters) {
|
|
561
561
|
target.filters = { ...source.filters, ...target.filters };
|
|
562
562
|
}
|
|
563
|
-
//
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
563
|
+
// A base's hooks fire first, as its triggers do: they are the entries written before the child's own.
|
|
564
|
+
for (const [event, sourceList] of definedEntries(source.hooks ?? {})) {
|
|
565
|
+
(target.hooks ??= {})[event] = inheritedEntries(sourceList, target.hooks?.[event], (hook) => hook.methodName);
|
|
566
|
+
}
|
|
567
|
+
target.indexes = inheritedEntries(source.indexes, target.indexes, (index) => index.name);
|
|
568
|
+
target.checks = inheritedEntries(source.checks, target.checks, (check) => check.name);
|
|
569
|
+
target.triggers = inheritedEntries(source.triggers, target.triggers, (trigger) => trigger.name);
|
|
570
|
+
}
|
|
571
|
+
/** `source`'s entries ahead of `own`, each once, and a same-named `own` entry replaces its base's. */
|
|
572
|
+
function inheritedEntries(source, own, nameOf) {
|
|
573
|
+
if (!source?.length) {
|
|
574
|
+
return own && [...own];
|
|
569
575
|
}
|
|
576
|
+
const taken = new Set((own ?? []).map(nameOf));
|
|
577
|
+
const inherited = source.filter((entry) => nameOf(entry) === undefined || !taken.has(nameOf(entry)));
|
|
578
|
+
return [...new Set([...inherited, ...(own ?? [])])];
|
|
570
579
|
}
|
package/dist/migrate/index.d.ts
CHANGED
|
@@ -2,10 +2,5 @@ export type { Change, ColumnSchema, Config, DialectName, ForeignKeySchema, Index
|
|
|
2
2
|
export * from './builder/index.js';
|
|
3
3
|
export { EntityCodeGenerator, type EntityCodeGeneratorOptions, type GeneratedEntity, } from './codegen/entityCodeGenerator.js';
|
|
4
4
|
export { buildMigrationModule, type MigrationModuleOptions, type MigrationQuerierType, } from './codegen/migrationFile.js';
|
|
5
|
-
export { AbstractSqlSchemaIntrospector } from './introspection/abstractSqlSchemaIntrospector.js';
|
|
6
|
-
export { MsSqlSchemaIntrospector } from './introspection/mssqlIntrospector.js';
|
|
7
|
-
export { MariadbSchemaIntrospector, MysqlSchemaIntrospector } from './introspection/mysqlIntrospector.js';
|
|
8
|
-
export { CockroachSchemaIntrospector, PostgresSchemaIntrospector } from './introspection/postgresIntrospector.js';
|
|
9
|
-
export { SqliteSchemaIntrospector } from './introspection/sqliteIntrospector.js';
|
|
10
5
|
export { type BuilderMigrationDefinition, defineBuilderMigration, defineMigration, Migrator } from './migrator.js';
|
|
11
6
|
export { SqlSchemaGenerator } from './schemaGenerator.js';
|
package/dist/migrate/index.js
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
export * from './builder/index.js';
|
|
2
2
|
export { EntityCodeGenerator, } from './codegen/entityCodeGenerator.js';
|
|
3
3
|
export { buildMigrationModule, } from './codegen/migrationFile.js';
|
|
4
|
-
export { AbstractSqlSchemaIntrospector } from './introspection/abstractSqlSchemaIntrospector.js';
|
|
5
|
-
export { MsSqlSchemaIntrospector } from './introspection/mssqlIntrospector.js';
|
|
6
|
-
export { MariadbSchemaIntrospector, MysqlSchemaIntrospector } from './introspection/mysqlIntrospector.js';
|
|
7
|
-
export { CockroachSchemaIntrospector, PostgresSchemaIntrospector } from './introspection/postgresIntrospector.js';
|
|
8
|
-
export { SqliteSchemaIntrospector } from './introspection/sqliteIntrospector.js';
|
|
9
4
|
export { defineBuilderMigration, defineMigration, Migrator } from './migrator.js';
|
|
10
5
|
export { SqlSchemaGenerator } from './schemaGenerator.js';
|
package/dist/nestjs/index.d.ts
CHANGED
package/dist/nestjs/index.js
CHANGED
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.101.
|
|
6
|
+
"version": "0.101.5",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"engines": {
|
|
9
9
|
"node": ">=22.18"
|
package/skills/uql-orm/SKILL.md
CHANGED
|
@@ -72,6 +72,7 @@ export class Post {
|
|
|
72
72
|
}
|
|
73
73
|
```
|
|
74
74
|
|
|
75
|
+
- A class inherits everything its base declares (fields, relations, hooks, filters, indexes, checks, triggers), and the base needs no `@Entity()` unless it is a table. The child's own entry of the same name replaces the base's.
|
|
75
76
|
- Every `@Field` states its `type`: `String`, `Number`, `Boolean`, `Date`, `BigInt`, or a column type such as `'uuid'`, `'text'`, `'jsonb'`. A foreign key takes `references` instead and inherits the target key's type. A `Date` is an instant, stored in UTC to the millisecond on every engine; `precision` sets other fractional digits. A `'decimal'` is exact text (`price?: string | null`); `type: Number` with `precision`/`scale` opts in to a rounding JS number. A JSON column of no fixed shape is a bare `Json`.
|
|
76
77
|
- A column is nullable unless it says `nullable: false`, and its property must admit `null` to match: `title?: string | null`. A property typed without `| null` on a nullable column is a compile error.
|
|
77
78
|
- Declare a `nullable: false` column `!` (`email!: string`): reads have it and inserts must name it, except a single-column key and a `version`, which uql fills. Declare `?` whatever an insert may leave out: a nullable, `onInsert`, `defaultValue`, `eager: false` or `computed` field, and relations.
|