uql-orm 0.104.1 → 0.105.0
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 +24 -10
- package/dist/browser/uql-browser.min.js +2 -2
- package/dist/browser/uql-browser.min.js.map +7 -7
- package/dist/dialect/abstractSqlDialect.d.ts +6 -4
- package/dist/dialect/abstractSqlDialect.js +35 -32
- package/dist/dialect/aliases.d.ts +2 -0
- package/dist/dialect/aliases.js +2 -0
- package/dist/dialect/jsonSql.js +2 -2
- package/dist/dialect/mysqlLikeSqlDialect.d.ts +1 -1
- package/dist/dialect/mysqlLikeSqlDialect.js +1 -1
- package/dist/dialect/operators.js +2 -4
- package/dist/dialect/queryJoins.d.ts +2 -0
- package/dist/dialect/vectorSqlDialect.d.ts +1 -1
- package/dist/dialect/vectorSqlDialect.js +1 -1
- package/dist/entity/column.d.ts +3 -0
- package/dist/entity/column.js +3 -0
- package/dist/entity/columnOptionsBuilder.d.ts +54 -0
- package/dist/entity/columnOptionsBuilder.js +108 -0
- package/dist/entity/decorator/bag.d.ts +4 -4
- package/dist/entity/decorator/entity.d.ts +2 -19
- package/dist/entity/decorator/entity.js +3 -37
- package/dist/entity/decorator/members.d.ts +46 -76
- package/dist/entity/decorator/members.js +18 -7
- package/dist/entity/index.d.ts +2 -1
- package/dist/entity/index.js +2 -1
- package/dist/entity/metadata/definition.d.ts +10 -24
- package/dist/entity/metadata/definition.js +329 -147
- package/dist/entity/metadata/schemaFixture/animal.d.ts +54 -0
- package/dist/entity/metadata/schemaFixture/animal.js +7 -0
- package/dist/entity/metadata/schemaFixture/author.d.ts +140 -0
- package/dist/entity/metadata/schemaFixture/author.js +25 -0
- package/dist/entity/metadata/schemaFixture/book.d.ts +192 -0
- package/dist/entity/metadata/schemaFixture/book.js +22 -0
- package/dist/http/query.js +12 -13
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -1
- package/dist/mariadb/mariaDialect.js +1 -1
- package/dist/mariadb/mariadbQuerier.js +1 -3
- package/dist/migrate/builder/columnBuilder.d.ts +20 -68
- package/dist/migrate/builder/columnBuilder.js +104 -110
- package/dist/migrate/builder/migrationBuilder.d.ts +3 -3
- package/dist/migrate/builder/migrationBuilder.js +7 -6
- package/dist/migrate/builder/tableBuilder.d.ts +3 -55
- package/dist/migrate/builder/tableBuilder.js +88 -204
- package/dist/migrate/builder/types.d.ts +52 -151
- package/dist/migrate/builder/types.js +0 -6
- package/dist/migrate/codegen/entityCodeGenerator.d.ts +2 -2
- package/dist/migrate/codegen/entityCodeGenerator.js +24 -24
- package/dist/migrate/codegen/fieldOptionsSource.d.ts +3 -1
- package/dist/migrate/codegen/fieldOptionsSource.js +35 -34
- package/dist/migrate/codegen/indexEntrySource.d.ts +16 -0
- package/dist/migrate/codegen/{indexDecoratorSource.js → indexEntrySource.js} +54 -27
- package/dist/migrate/ddl/defaultSql.js +7 -6
- package/dist/migrate/ddl/indexCapabilities.d.ts +8 -7
- package/dist/migrate/ddl/indexCapabilities.js +26 -13
- package/dist/migrate/ddl/indexDdl.d.ts +13 -13
- package/dist/migrate/ddl/indexDdl.js +33 -30
- package/dist/migrate/ddl/mysqlIndexDdl.d.ts +6 -11
- package/dist/migrate/ddl/mysqlIndexDdl.js +17 -28
- package/dist/migrate/ddl/pgIndexDdl.d.ts +2 -2
- package/dist/migrate/ddl/sqliteIndexDdl.d.ts +2 -2
- package/dist/migrate/drift/driftDetector.js +2 -2
- package/dist/migrate/generator/definitionToNode.d.ts +8 -2
- package/dist/migrate/generator/definitionToNode.js +4 -5
- package/dist/migrate/introspection/abstractSqlSchemaIntrospector.js +11 -2
- package/dist/migrate/introspection/jsonIndexEntry.d.ts +6 -0
- package/dist/migrate/introspection/jsonIndexEntry.js +120 -0
- package/dist/migrate/introspection/mysqlIntrospector.d.ts +4 -4
- package/dist/migrate/introspection/mysqlIntrospector.js +25 -21
- package/dist/migrate/introspection/postgresIntrospector.d.ts +1 -1
- package/dist/migrate/introspection/postgresIntrospector.js +3 -4
- package/dist/migrate/introspection/sqliteIntrospector.js +24 -9
- package/dist/migrate/introspection/tableSchemaAST.js +5 -1
- package/dist/migrate/schemaChange.d.ts +3 -3
- package/dist/migrate/schemaChange.js +3 -2
- package/dist/migrate/schemaGenerator.js +1 -1
- package/dist/migrate/storage/databaseStorage.js +4 -4
- package/dist/mongodb/mongoDialect.d.ts +33 -36
- package/dist/mongodb/mongoDialect.js +118 -32
- package/dist/mongodb/mongoIntrospector.d.ts +3 -1
- package/dist/mongodb/mongoIntrospector.js +11 -5
- package/dist/mongodb/mongoSchemaGenerator.js +35 -27
- package/dist/mongodb/mongodbQuerier.d.ts +1 -11
- package/dist/mongodb/mongodbQuerier.js +9 -43
- package/dist/querier/abstractQuerier.d.ts +0 -1
- package/dist/querier/abstractQuerier.js +1 -20
- package/dist/querier/keyset.js +3 -3
- package/dist/schema/declaredColumn.d.ts +11 -0
- package/dist/schema/declaredColumn.js +21 -0
- package/dist/schema/indexColumns.d.ts +0 -3
- package/dist/schema/indexColumns.js +11 -7
- package/dist/schema/indexDifferences.d.ts +10 -5
- package/dist/schema/indexDifferences.js +42 -28
- package/dist/schema/schemaASTBuilder.js +28 -36
- package/dist/schema/schemaASTDiffer.js +8 -4
- package/dist/schema/sqlExpression.d.ts +21 -17
- package/dist/schema/sqlExpression.js +11 -23
- package/dist/type/column.d.ts +328 -0
- package/dist/type/column.js +2 -0
- package/dist/type/config.d.ts +1 -1
- package/dist/type/dialect.d.ts +2 -1
- package/dist/type/dialect.js +1 -0
- package/dist/type/entity.d.ts +290 -279
- package/dist/type/entity.js +6 -1
- package/dist/type/index.d.ts +2 -0
- package/dist/type/index.js +2 -0
- package/dist/type/migration.d.ts +5 -5
- package/dist/type/query.d.ts +44 -40
- package/dist/type/query.js +2 -3
- package/dist/type/queryAggregate.d.ts +22 -12
- package/dist/type/querySql.d.ts +20 -4
- package/dist/type/querySql.js +27 -9
- package/dist/type/schemaEntity.d.ts +190 -0
- package/dist/type/schemaEntity.js +1 -0
- package/dist/type/utility.d.ts +0 -6
- package/dist/type/vector.d.ts +1 -1
- package/dist/util/ddlExpression.util.d.ts +12 -13
- package/dist/util/ddlExpression.util.js +12 -21
- package/dist/util/dialect.util.d.ts +11 -5
- package/dist/util/dialect.util.js +31 -37
- package/dist/util/field.util.d.ts +10 -9
- package/dist/util/field.util.js +14 -10
- package/dist/util/fieldOption.util.d.ts +11 -95
- package/dist/util/fieldOption.util.js +49 -16
- package/dist/util/hook.util.d.ts +2 -14
- package/dist/util/hook.util.js +3 -16
- package/dist/util/index.d.ts +1 -0
- package/dist/util/index.js +1 -0
- package/dist/util/indexEntry.util.d.ts +45 -0
- package/dist/util/indexEntry.util.js +138 -0
- package/dist/util/relationQuery.util.d.ts +0 -1
- package/dist/util/relationQuery.util.js +0 -5
- package/dist/util/sql.d.ts +10 -7
- package/dist/util/sql.js +34 -16
- package/dist/util/sql.util.d.ts +4 -5
- package/dist/util/sql.util.js +7 -16
- package/dist/util/string.util.d.ts +2 -0
- package/dist/util/string.util.js +4 -0
- package/dist/util/uqlError.d.ts +1 -1
- package/dist/util/uqlError.js +1 -1
- package/package.json +1 -1
- package/skills/uql-orm/SKILL.md +76 -25
- package/dist/migrate/codegen/indexDecoratorSource.d.ts +0 -16
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type { RejectIncompatible } from '../../util/index.js';
|
|
1
|
+
import { type Column, type ComputedRefs, type EntityGetter, type FilledOptions, type filledKey, type HookContext, type IsEqual, type Json, type JsonBrand, type NamedIdKey, type NullOf, type QuerySql, RelationAggregate, type RelationManyToManyOptions, type RelationManyToOneOptions, type RelationOneToManyOptions, type RelationOneToOneOptions, type VersionKey } from '../../type/index.js';
|
|
3
2
|
/** A member decorator that also constrains the property it may be applied to, on a class `O`. */
|
|
4
3
|
type MemberDecorator<V, O = unknown> = (value: undefined, context: ClassFieldDecoratorContext<O, V>) => void;
|
|
5
4
|
/**
|
|
@@ -11,63 +10,45 @@ type MemberDecorator<V, O = unknown> = (value: undefined, context: ClassFieldDec
|
|
|
11
10
|
* family - `jsonb`, whose document the property shapes, or `numeric`, either number kind - is meant to
|
|
12
11
|
* be narrowed. A column insists on its `null`; an aggregate, whose value is exact, insists on all of it.
|
|
13
12
|
*/
|
|
14
|
-
type AdmittingDecorator<V, M, O> = <P extends V | undefined>(value: undefined, context: ClassFieldDecoratorContext<O, P> &
|
|
13
|
+
type AdmittingDecorator<V, M, O, Filled = true, Key = false, Lock = false> = <P extends V | undefined, N extends PropertyKey>(value: undefined, context: ClassFieldDecoratorContext<O, P> & {
|
|
14
|
+
readonly name: N;
|
|
15
|
+
} & ([M] extends [P] ? unknown : {
|
|
15
16
|
readonly __propertyMustAdmit: M;
|
|
16
|
-
})) => void;
|
|
17
|
-
/**
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
*/
|
|
22
|
-
type DeclaredValue<O> = O extends {
|
|
23
|
-
readonly type: infer T extends FieldType;
|
|
24
|
-
} ? O extends {
|
|
25
|
-
readonly enum: infer E extends readonly unknown[];
|
|
26
|
-
} ? EnumValue<Extract<E[number], TsTypeOf<T>>, TsTypeOf<T>> : TsTypeOf<T> : O extends {
|
|
27
|
-
readonly references: EntityGetter<infer E>;
|
|
28
|
-
} ? HasCompositeKey<E> extends true ? {
|
|
29
|
-
readonly __compositeKeyNeedsAColumnPerKey: true;
|
|
30
|
-
} : IdValue<E> : never;
|
|
17
|
+
}) & FilledIfBranded<O, N, Filled> & ([Key] extends [true] ? KeyIsNamed<O> : unknown) & ([Lock] extends [true] ? VersionIsBranded<O> : unknown)) => void;
|
|
18
|
+
/** A field the `filledKey` brand lets an insert leave out, which only a default can then fill. */
|
|
19
|
+
type FilledIfBranded<O, N, Filled> = [Filled] extends [true] ? unknown : typeof filledKey extends keyof O ? N extends O[typeof filledKey] ? {
|
|
20
|
+
readonly __filledKeyNeedsADefault: true;
|
|
21
|
+
} : unknown : unknown;
|
|
31
22
|
/**
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
23
|
+
* Declares a persisted field, the property checked against the column: `@Field(f.string()) name!: string;`, and
|
|
24
|
+
* `@Field(f.string().nullable()) bio?: string | null;` for a column holding `null`. A key is `f.number().id()`.
|
|
25
|
+
* @example `@Field(f.references(() => User).nullable()) userId?: number | null;`
|
|
35
26
|
*/
|
|
36
|
-
|
|
37
|
-
readonly nullable: false;
|
|
38
|
-
} | {
|
|
39
|
-
readonly isId: true;
|
|
40
|
-
} | {
|
|
27
|
+
export declare function Field<This, O, V>(column: Column<O, V>): AdmittingDecorator<Narrowable<V> | NullOf<O>, NullOf<O>, This, O extends FilledOptions ? true : false, IsKey<O>, O extends {
|
|
41
28
|
readonly version: true;
|
|
42
|
-
} ?
|
|
43
|
-
/** The enum's members, or a named complaint where they widened for lack of `as const`, which would check nothing. */
|
|
44
|
-
type EnumValue<Members, Declared> = Declared extends Members ? {
|
|
45
|
-
readonly __enumNeedsAsConst: true;
|
|
46
|
-
} : Members;
|
|
29
|
+
} ? true : false>;
|
|
47
30
|
/**
|
|
48
|
-
* Declares a
|
|
49
|
-
*
|
|
50
|
-
*
|
|
31
|
+
* Declares a field the database computes, read off the entity's refs: SQL as a column,
|
|
32
|
+
* `@Computed((user) => f.string().as(sql`upper(${user.name})`)) readonly shout?: string;`, or a relation
|
|
33
|
+
* aggregate, `@Computed((user) => user.posts.count()) readonly postCount?: number;`, which types itself.
|
|
51
34
|
*/
|
|
52
|
-
export declare function
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
readonly stored?: false;
|
|
68
|
-
};
|
|
35
|
+
export declare function Computed<This, C extends ComputedColumn | RelationAggregate>(expression: (refs: ComputedRefs<This>) => C): AdmittingDecorator<ComputedValue<C>, ComputedAdmits<C>, This>;
|
|
36
|
+
/** A column the database computes, what `as()` returns. */
|
|
37
|
+
type ComputedColumn = Column<{
|
|
38
|
+
readonly computed: QuerySql;
|
|
39
|
+
}>;
|
|
40
|
+
/** What a computed field holds: an aggregate's exact value, or a column's, `null` where it said so. */
|
|
41
|
+
type ComputedValue<C> = C extends RelationAggregate<infer V> ? V : C extends Column<infer O, infer V> ? V | NullOf<O> : never;
|
|
42
|
+
/** What the property has to admit: all of an aggregate's value, which is exact, and a column's `null`. */
|
|
43
|
+
type ComputedAdmits<C> = C extends RelationAggregate<infer V> ? V : C extends Column<infer O> ? NullOf<O> : never;
|
|
44
|
+
/** A JSON column with no shape holds any document, which the property narrows: `Json<Settings>`. */
|
|
45
|
+
type Narrowable<V> = IsEqual<V, Json> extends true ? JsonBrand | readonly JsonBrand[] : V;
|
|
46
|
+
/** Whether the column is a key, which the class has to name. */
|
|
47
|
+
type IsKey<O> = O extends {
|
|
48
|
+
readonly isId: true;
|
|
49
|
+
} ? true : false;
|
|
69
50
|
/**
|
|
70
|
-
* A key the type level cannot name, reported on each
|
|
51
|
+
* A key the type level cannot name, reported on each key column that leaves it unnamed. Where no `idKey`
|
|
71
52
|
* brand and no conventional name applies, `IdKey` falls back to every field, and `IdValue`,
|
|
72
53
|
* `EntityId` and every by-id method are then typed against a column that is not the key.
|
|
73
54
|
*/
|
|
@@ -79,22 +60,9 @@ type KeyIsNamed<This> = [NamedIdKey<This>] extends [never] ? {
|
|
|
79
60
|
* time; the `versionKey` brand is what makes an update payload require it, and a lock only half
|
|
80
61
|
* declared would be a guarantee nothing enforces, so the decorator asks for both.
|
|
81
62
|
*/
|
|
82
|
-
type VersionIsBranded<
|
|
83
|
-
readonly version: true;
|
|
84
|
-
} ? [VersionKey<This>] extends [never] ? {
|
|
63
|
+
type VersionIsBranded<This> = [VersionKey<This>] extends [never] ? {
|
|
85
64
|
readonly __versionNeedsVersionKeyBrand: true;
|
|
86
|
-
} : unknown
|
|
87
|
-
/** {@link MemberDecorator} that also constrains the class, which is where a key is named. */
|
|
88
|
-
type IdDecorator<V> = <This>(value: undefined, context: ClassFieldDecoratorContext<This, V> & KeyIsNamed<This>) => void;
|
|
89
|
-
/**
|
|
90
|
-
* Declares the primary key, checked like `@Field`; a key not named `id`, `_id` or `uuid` needs the `idKey` brand.
|
|
91
|
-
* @example `@Id({ type: 'uuid', onInsert: uuidv7 }) id!: string;`
|
|
92
|
-
*/
|
|
93
|
-
export declare function Id<O extends FieldOptions<DeclaredValue<O>> & {
|
|
94
|
-
type: FieldType;
|
|
95
|
-
} & RejectKeys<Exclude<keyof O, keyof FieldOptions>> & RejectIncompatible<O> & {
|
|
96
|
-
readonly nullable?: false;
|
|
97
|
-
}>(opts: O): IdDecorator<DeclaredValue<O> | undefined>;
|
|
65
|
+
} : unknown;
|
|
98
66
|
/**
|
|
99
67
|
* `E` comes from the mandatory `entity` getter, so the context can insist the property really holds that
|
|
100
68
|
* entity: `@ManyToOne({ entity: () => Other })` on a `Company` field stops compiling, and a to-many
|
|
@@ -108,13 +76,15 @@ export declare function OneToOne<E extends object, O>(opts: WithEntity<E, Relati
|
|
|
108
76
|
export declare function ManyToOne<E extends object, O>(opts: WithEntity<E, RelationManyToOneOptions<E, O>>): MemberDecorator<E | undefined, O>;
|
|
109
77
|
export declare function OneToMany<E extends object, O>(opts: WithEntity<E, RelationOneToManyOptions<E, O>>): MemberDecorator<readonly E[] | undefined, O>;
|
|
110
78
|
export declare function ManyToMany<E extends object, O>(opts: WithEntity<E, RelationManyToManyOptions<E, O>>): MemberDecorator<readonly E[] | undefined, O>;
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
export declare const
|
|
114
|
-
export declare const
|
|
115
|
-
export declare const
|
|
116
|
-
export declare const
|
|
117
|
-
export declare const
|
|
118
|
-
export declare const
|
|
119
|
-
export declare const
|
|
79
|
+
/** What a hook method is called with: the row as `this`, and the querier's context. */
|
|
80
|
+
type HookMethod<This> = (this: This, ctx: HookContext) => unknown;
|
|
81
|
+
export declare const BeforeInsert: () => <This>(_value: HookMethod<This>, context: ClassMethodDecoratorContext<This>) => void;
|
|
82
|
+
export declare const AfterInsert: () => <This>(_value: HookMethod<This>, context: ClassMethodDecoratorContext<This>) => void;
|
|
83
|
+
export declare const BeforeUpdate: () => <This>(_value: HookMethod<This>, context: ClassMethodDecoratorContext<This>) => void;
|
|
84
|
+
export declare const AfterUpdate: () => <This>(_value: HookMethod<This>, context: ClassMethodDecoratorContext<This>) => void;
|
|
85
|
+
export declare const BeforeUpsert: () => <This>(_value: HookMethod<This>, context: ClassMethodDecoratorContext<This>) => void;
|
|
86
|
+
export declare const AfterUpsert: () => <This>(_value: HookMethod<This>, context: ClassMethodDecoratorContext<This>) => void;
|
|
87
|
+
export declare const BeforeDelete: () => <This>(_value: HookMethod<This>, context: ClassMethodDecoratorContext<This>) => void;
|
|
88
|
+
export declare const AfterDelete: () => <This>(_value: HookMethod<This>, context: ClassMethodDecoratorContext<This>) => void;
|
|
89
|
+
export declare const AfterLoad: () => <This>(_value: HookMethod<This>, context: ClassMethodDecoratorContext<This>) => void;
|
|
120
90
|
export {};
|
|
@@ -1,17 +1,28 @@
|
|
|
1
|
+
import { COLUMN_OPTIONS, RelationAggregate, } from '../../type/index.js';
|
|
2
|
+
import { aggregateField } from '../../util/field.util.js';
|
|
3
|
+
import { memberRefs } from '../../util/sql.js';
|
|
1
4
|
import { relationRegistration } from '../metadata/definition.js';
|
|
2
5
|
import { memberRegistrations } from './bag.js';
|
|
3
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Declares a persisted field, the property checked against the column: `@Field(f.string()) name!: string;`, and
|
|
8
|
+
* `@Field(f.string().nullable()) bio?: string | null;` for a column holding `null`. A key is `f.number().id()`.
|
|
9
|
+
* @example `@Field(f.references(() => User).nullable()) userId?: number | null;`
|
|
10
|
+
*/
|
|
11
|
+
export function Field(column) {
|
|
4
12
|
return (_value, context) => {
|
|
5
|
-
memberRegistrations(context.metadata).fields[String(context.name)] =
|
|
13
|
+
memberRegistrations(context.metadata).fields[String(context.name)] = column[COLUMN_OPTIONS];
|
|
6
14
|
};
|
|
7
15
|
}
|
|
8
16
|
/**
|
|
9
|
-
* Declares the
|
|
10
|
-
*
|
|
17
|
+
* Declares a field the database computes, read off the entity's refs: SQL as a column,
|
|
18
|
+
* `@Computed((user) => f.string().as(sql`upper(${user.name})`)) readonly shout?: string;`, or a relation
|
|
19
|
+
* aggregate, `@Computed((user) => user.posts.count()) readonly postCount?: number;`, which types itself.
|
|
11
20
|
*/
|
|
12
|
-
export function
|
|
21
|
+
export function Computed(expression) {
|
|
13
22
|
return (_value, context) => {
|
|
14
|
-
|
|
23
|
+
const computed = expression(memberRefs());
|
|
24
|
+
memberRegistrations(context.metadata).fields[String(context.name)] =
|
|
25
|
+
computed instanceof RelationAggregate ? aggregateField(computed) : computed[COLUMN_OPTIONS];
|
|
15
26
|
};
|
|
16
27
|
}
|
|
17
28
|
function relation(opts) {
|
|
@@ -38,7 +49,7 @@ function hook(event) {
|
|
|
38
49
|
(_value, context) => {
|
|
39
50
|
const { hooks } = memberRegistrations(context.metadata);
|
|
40
51
|
hooks[event] ??= [];
|
|
41
|
-
hooks[event].push(String(context.name));
|
|
52
|
+
hooks[event].push({ methodName: String(context.name) });
|
|
42
53
|
};
|
|
43
54
|
}
|
|
44
55
|
export const BeforeInsert = hook('beforeInsert');
|
package/dist/entity/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * from './column.js';
|
|
1
2
|
export * from './decorator/entity.js';
|
|
2
3
|
export * from './decorator/members.js';
|
|
3
|
-
export { defineEntity,
|
|
4
|
+
export { defineEntity, getEntities, getMeta, removeEntity, assertSoleId, fieldOf, idOf, keyOf, namesKey, relationOf, soleIdOf, } from './metadata/definition.js';
|
package/dist/entity/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * from './column.js';
|
|
1
2
|
export * from './decorator/entity.js';
|
|
2
3
|
export * from './decorator/members.js';
|
|
3
|
-
export { defineEntity,
|
|
4
|
+
export { defineEntity, getEntities, getMeta, removeEntity, assertSoleId, fieldOf, idOf, keyOf, namesKey, relationOf, soleIdOf, } from './metadata/definition.js';
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
export declare function defineId<E>(entity: Type<E>, key: string, opts: FieldOptions): EntityMeta<E>;
|
|
4
|
-
/** `T` is the relation's target, independent of the owner `E`. */
|
|
5
|
-
export declare function defineRelation<E, T extends object>(entity: Type<E>, key: string, opts: RelationOptions<T, E>): EntityMeta<E>;
|
|
1
|
+
import { type EntityGetter, type EntityMeta, type EntityOptions, type FieldMeta, type IdKey, type KeyMap, type RelationKey, type RelationMeta, type RelationOptions, type RelationRegistration, type SchemaEntityOptions, type Brands, type ColumnRow, type SchemaFields, type SchemaKey, type Type, type WrittenId, type SchemaEntity } from '../../type/index.js';
|
|
2
|
+
import { type MemberRegistrations } from '../decorator/bag.js';
|
|
6
3
|
/**
|
|
7
4
|
* `opts` as the registry takes them: `mappedBy` and `references` read off their key maps down to the
|
|
8
5
|
* names they give. The callbacks only read properties, so they run here, before any entity has to
|
|
@@ -14,28 +11,17 @@ export declare function relationRegistration<T extends object, O>({ mappedBy, re
|
|
|
14
11
|
* entity names one, since a selector follows a rename and a string does not.
|
|
15
12
|
*/
|
|
16
13
|
export declare function keyOf<E, K extends keyof E>(pick: (keys: KeyMap<E>) => K): K;
|
|
17
|
-
export declare function defineHook<E>(entity: Type<E>, methodName: string, event: HookEvent): EntityMeta<E>;
|
|
18
14
|
/**
|
|
19
|
-
* Declares
|
|
20
|
-
*
|
|
15
|
+
* Declares an entity by its schema and returns its class, whose row type the schema derives, so nothing is
|
|
16
|
+
* written twice: its columns now, then each section, `.indexes()` and so on, `.relations()` last. It registers on
|
|
17
|
+
* first read, with every section in, and its relations once each target exists.
|
|
21
18
|
*/
|
|
22
|
-
export declare function
|
|
19
|
+
export declare function defineEntity<const F extends SchemaFields, B = object, BK = unknown, BC = unknown>(schema: SchemaEntityOptions<F, B, BK, BC>): SchemaEntity<B & ColumnRow<F> & Brands<F>, SchemaKey<F, BK>, BC & ColumnRow<F>, B>;
|
|
23
20
|
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
21
|
+
* The registration both forms share, a schema's `members` given as the decorators would register them. Built
|
|
22
|
+
* apart and stored once it passes, so a rejected definition leaves the registry as it was.
|
|
26
23
|
*/
|
|
27
|
-
export declare function
|
|
28
|
-
export declare function defineFilter<E, N extends string>(entity: Type<E>, name: FilterName<N>, opts: FilterOptions<E>): EntityMeta<E>;
|
|
29
|
-
/**
|
|
30
|
-
* Feeds fields, relations and hooks into the `define*` primitives, so the decorators and the imperative
|
|
31
|
-
* API converge on one registration path before anything is finalized.
|
|
32
|
-
*/
|
|
33
|
-
export declare function applyMembers<E>(entity: Type<E>, specs: EntityMembers | undefined): void;
|
|
34
|
-
/**
|
|
35
|
-
* Registers a class as an entity from `opts` alone, the decorator-free counterpart of `@Entity()` with
|
|
36
|
-
* `@Field`/`@ManyToOne`/...
|
|
37
|
-
*/
|
|
38
|
-
export declare function defineEntity<E>(entity: Type<E> & BrandsNameFields<E>, opts?: EntityOptions<E>): EntityMeta<E>;
|
|
24
|
+
export declare function registerEntity<E>(entity: Type<E>, opts?: EntityOptions<E>, members?: Partial<MemberRegistrations>): EntityMeta<E>;
|
|
39
25
|
/**
|
|
40
26
|
* Refuses an entity whose primary key is not one column, naming the path that cannot express it.
|
|
41
27
|
*
|
|
@@ -77,7 +63,7 @@ export declare function removeEntity<E>(entity: Type<E>): boolean;
|
|
|
77
63
|
export declare function getEntities(): Type<object>[];
|
|
78
64
|
export declare function getMeta<E>(entity: Type<E>): EntityMeta<E>;
|
|
79
65
|
/**
|
|
80
|
-
* The foreign keys an entity holds: each owning to-one's columns, and each
|
|
66
|
+
* The foreign keys an entity holds: each owning to-one's columns, and each `f.references()` no
|
|
81
67
|
* relation joins on, as the many-to-one it describes, once its target has registered a key. What the
|
|
82
68
|
* schema build constrains and a junction joins by, settling the relations holding them first.
|
|
83
69
|
*/
|