uql-orm 0.104.1 → 0.105.1
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/querier/httpQuerier.d.ts +3 -3
- package/dist/browser/type/clientQuerier.d.ts +1 -1
- package/dist/browser/uql-browser.min.js +2 -2
- package/dist/browser/uql-browser.min.js.map +9 -9
- package/dist/cockroachdb/cockroachDialect.d.ts +2 -2
- package/dist/dialect/abstractDialect.d.ts +3 -3
- package/dist/dialect/abstractSqlDialect.d.ts +39 -37
- 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/mergeSqlDialect.d.ts +2 -2
- package/dist/dialect/mysqlLikeSqlDialect.d.ts +7 -7
- package/dist/dialect/mysqlLikeSqlDialect.js +1 -1
- package/dist/dialect/operators.js +2 -4
- package/dist/dialect/queryJoins.d.ts +4 -2
- 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 +5 -5
- package/dist/entity/decorator/entity.d.ts +3 -20
- 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 +15 -26
- package/dist/entity/metadata/definition.js +344 -148
- 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 +23 -0
- package/dist/http/contract.d.ts +2 -2
- package/dist/http/handler.d.ts +2 -2
- package/dist/http/query.js +12 -13
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -1
- package/dist/mariadb/mariaDialect.d.ts +2 -2
- 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/entityTypes.d.ts +2 -2
- 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/migrator.d.ts +2 -2
- package/dist/migrate/schemaChange.d.ts +3 -3
- package/dist/migrate/schemaChange.js +3 -2
- package/dist/migrate/schemaGenerator.d.ts +5 -5
- package/dist/migrate/schemaGenerator.js +1 -1
- package/dist/migrate/storage/databaseStorage.js +4 -4
- package/dist/mongodb/mongoDialect.d.ts +41 -44
- 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.d.ts +4 -4
- package/dist/mongodb/mongoSchemaGenerator.js +35 -27
- package/dist/mongodb/mongodbQuerier.d.ts +1 -11
- package/dist/mongodb/mongodbQuerier.js +9 -43
- package/dist/mssql/mssqlDialect.d.ts +4 -4
- package/dist/postgres/postgresDialect.d.ts +2 -2
- package/dist/querier/abstractQuerier.d.ts +0 -1
- package/dist/querier/abstractQuerier.js +1 -20
- package/dist/querier/abstractSqlQuerier.d.ts +1 -1
- 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.d.ts +4 -4
- 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 +3 -3
- package/dist/type/dialect.d.ts +15 -14
- package/dist/type/dialect.js +1 -0
- package/dist/type/entity.d.ts +292 -281
- 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 +11 -11
- package/dist/type/querier.d.ts +2 -2
- 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 +22 -6
- package/dist/type/querySql.js +27 -9
- package/dist/type/schemaEntity.d.ts +194 -0
- package/dist/type/schemaEntity.js +1 -0
- package/dist/type/utility.d.ts +4 -7
- 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 +3 -15
- 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 +13 -10
- 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/triggerWrite.d.ts +5 -5
- 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
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export declare const Animal: import("../../../index.js").SchemaEntity<object & {
|
|
2
|
+
id: number;
|
|
3
|
+
name: string;
|
|
4
|
+
} & {} & import("../../../index.js").Brands<{
|
|
5
|
+
readonly id: import("../../../index.js").NumericColumn<{
|
|
6
|
+
readonly type: NumberConstructor;
|
|
7
|
+
} & {
|
|
8
|
+
readonly isId: true;
|
|
9
|
+
}, number>;
|
|
10
|
+
readonly name: import("../../../index.js").StringColumn<{
|
|
11
|
+
readonly type: StringConstructor;
|
|
12
|
+
}, string>;
|
|
13
|
+
}>, number, {
|
|
14
|
+
id: number;
|
|
15
|
+
name: string;
|
|
16
|
+
} & {}, object>;
|
|
17
|
+
export declare const Dog: import("../../../index.js").SchemaEntity<object & {
|
|
18
|
+
id: number;
|
|
19
|
+
name: string;
|
|
20
|
+
} & {} & import("../../../index.js").Brands<{
|
|
21
|
+
readonly id: import("../../../index.js").NumericColumn<{
|
|
22
|
+
readonly type: NumberConstructor;
|
|
23
|
+
} & {
|
|
24
|
+
readonly isId: true;
|
|
25
|
+
}, number>;
|
|
26
|
+
readonly name: import("../../../index.js").StringColumn<{
|
|
27
|
+
readonly type: StringConstructor;
|
|
28
|
+
}, string>;
|
|
29
|
+
}> & {} & {
|
|
30
|
+
tricks?: number | null | undefined;
|
|
31
|
+
} & import("../../../index.js").Brands<{
|
|
32
|
+
readonly tricks: import("../../../index.js").NumericColumn<{
|
|
33
|
+
readonly type: NumberConstructor;
|
|
34
|
+
} & {
|
|
35
|
+
readonly nullable: true;
|
|
36
|
+
}, number>;
|
|
37
|
+
}>, number, {
|
|
38
|
+
id: number;
|
|
39
|
+
name: string;
|
|
40
|
+
} & {} & {} & {
|
|
41
|
+
tricks?: number | null | undefined;
|
|
42
|
+
}, object & {
|
|
43
|
+
id: number;
|
|
44
|
+
name: string;
|
|
45
|
+
} & {} & import("../../../index.js").Brands<{
|
|
46
|
+
readonly id: import("../../../index.js").NumericColumn<{
|
|
47
|
+
readonly type: NumberConstructor;
|
|
48
|
+
} & {
|
|
49
|
+
readonly isId: true;
|
|
50
|
+
}, number>;
|
|
51
|
+
readonly name: import("../../../index.js").StringColumn<{
|
|
52
|
+
readonly type: StringConstructor;
|
|
53
|
+
}, string>;
|
|
54
|
+
}>>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { f } from '../../column.js';
|
|
2
|
+
import { defineEntity } from '../definition.js';
|
|
3
|
+
export const Animal = defineEntity({
|
|
4
|
+
name: 'Animal',
|
|
5
|
+
fields: { id: f.number().id(), name: f.string() },
|
|
6
|
+
});
|
|
7
|
+
export const Dog = defineEntity({ name: 'Dog', extends: Animal, fields: { tricks: f.number().nullable() } });
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
export declare const Author: import("../../../index.js").RelatedEntity<object & {
|
|
2
|
+
id: number;
|
|
3
|
+
name: string;
|
|
4
|
+
createdAt: Date;
|
|
5
|
+
} & {
|
|
6
|
+
bio?: string | null | undefined;
|
|
7
|
+
} & import("../../../index.js").Brands<{
|
|
8
|
+
readonly id: import("../../../index.js").NumericColumn<{
|
|
9
|
+
readonly type: NumberConstructor;
|
|
10
|
+
} & {
|
|
11
|
+
readonly isId: true;
|
|
12
|
+
}, number>;
|
|
13
|
+
readonly name: import("../../../index.js").StringColumn<{
|
|
14
|
+
readonly type: StringConstructor;
|
|
15
|
+
}, string>;
|
|
16
|
+
readonly bio: import("../../../index.js").StringColumn<{
|
|
17
|
+
readonly type: StringConstructor;
|
|
18
|
+
} & {
|
|
19
|
+
readonly nullable: true;
|
|
20
|
+
}, string>;
|
|
21
|
+
readonly createdAt: import("../../../index.js").DateColumn<{
|
|
22
|
+
readonly type: DateConstructor;
|
|
23
|
+
} & {
|
|
24
|
+
readonly defaultValue: unknown;
|
|
25
|
+
}, Date>;
|
|
26
|
+
}> & import("../../../index.js").RelationRow<{
|
|
27
|
+
readonly books: () => import("../../../index.js").SchemaRelation<object & {
|
|
28
|
+
id: number;
|
|
29
|
+
title: string;
|
|
30
|
+
stock: number;
|
|
31
|
+
status: "draft" | "published";
|
|
32
|
+
version: number;
|
|
33
|
+
authorId: number;
|
|
34
|
+
} & {} & import("../../../index.js").Brands<{
|
|
35
|
+
readonly id: import("../../../index.js").NumericColumn<{
|
|
36
|
+
readonly type: NumberConstructor;
|
|
37
|
+
} & {
|
|
38
|
+
readonly isId: true;
|
|
39
|
+
}, number>;
|
|
40
|
+
readonly title: import("../../../index.js").StringColumn<{
|
|
41
|
+
readonly type: StringConstructor;
|
|
42
|
+
}, string>;
|
|
43
|
+
readonly stock: import("../../../index.js").NumericColumn<{
|
|
44
|
+
readonly type: NumberConstructor;
|
|
45
|
+
} & {
|
|
46
|
+
readonly defaultValue: unknown;
|
|
47
|
+
}, number>;
|
|
48
|
+
readonly status: import("../../../index.js").StringColumn<{
|
|
49
|
+
readonly type: StringConstructor;
|
|
50
|
+
readonly enum: readonly ["draft", "published"];
|
|
51
|
+
}, "draft" | "published">;
|
|
52
|
+
readonly version: import("../../../index.js").VersionColumn<{
|
|
53
|
+
readonly type: NumberConstructor;
|
|
54
|
+
readonly version: true;
|
|
55
|
+
}, number>;
|
|
56
|
+
readonly authorId: import("../../../index.js").NumericColumn<{
|
|
57
|
+
readonly type: NumberConstructor;
|
|
58
|
+
}, number>;
|
|
59
|
+
}> & {
|
|
60
|
+
readonly shout?: string | null | undefined;
|
|
61
|
+
} & import("../../../index.js").RelationRow<{
|
|
62
|
+
readonly author: () => import("../../../index.js").SchemaRelation<object & {
|
|
63
|
+
id: number;
|
|
64
|
+
name: string;
|
|
65
|
+
createdAt: Date;
|
|
66
|
+
} & {
|
|
67
|
+
bio?: string | null | undefined;
|
|
68
|
+
} & import("../../../index.js").Brands<{
|
|
69
|
+
readonly id: import("../../../index.js").NumericColumn<{
|
|
70
|
+
readonly type: NumberConstructor;
|
|
71
|
+
} & {
|
|
72
|
+
readonly isId: true;
|
|
73
|
+
}, number>;
|
|
74
|
+
readonly name: import("../../../index.js").StringColumn<{
|
|
75
|
+
readonly type: StringConstructor;
|
|
76
|
+
}, string>;
|
|
77
|
+
readonly bio: import("../../../index.js").StringColumn<{
|
|
78
|
+
readonly type: StringConstructor;
|
|
79
|
+
} & {
|
|
80
|
+
readonly nullable: true;
|
|
81
|
+
}, string>;
|
|
82
|
+
readonly createdAt: import("../../../index.js").DateColumn<{
|
|
83
|
+
readonly type: DateConstructor;
|
|
84
|
+
} & {
|
|
85
|
+
readonly defaultValue: unknown;
|
|
86
|
+
}, Date>;
|
|
87
|
+
}> & import("../../../index.js").RelationRow</*elided*/ any> & import("../../../index.js").AggregateRow<{
|
|
88
|
+
readonly bookCount: () => import("../../../index.js").RelationAggregate<number>;
|
|
89
|
+
readonly topStock: () => import("../../../index.js").RelationAggregate<number | null>;
|
|
90
|
+
}>, "m1", object & {
|
|
91
|
+
id: number;
|
|
92
|
+
name: string;
|
|
93
|
+
createdAt: Date;
|
|
94
|
+
} & {
|
|
95
|
+
bio?: string | null | undefined;
|
|
96
|
+
} & import("../../../index.js").Brands<{
|
|
97
|
+
readonly id: import("../../../index.js").NumericColumn<{
|
|
98
|
+
readonly type: NumberConstructor;
|
|
99
|
+
} & {
|
|
100
|
+
readonly isId: true;
|
|
101
|
+
}, number>;
|
|
102
|
+
readonly name: import("../../../index.js").StringColumn<{
|
|
103
|
+
readonly type: StringConstructor;
|
|
104
|
+
}, string>;
|
|
105
|
+
readonly bio: import("../../../index.js").StringColumn<{
|
|
106
|
+
readonly type: StringConstructor;
|
|
107
|
+
} & {
|
|
108
|
+
readonly nullable: true;
|
|
109
|
+
}, string>;
|
|
110
|
+
readonly createdAt: import("../../../index.js").DateColumn<{
|
|
111
|
+
readonly type: DateConstructor;
|
|
112
|
+
} & {
|
|
113
|
+
readonly defaultValue: unknown;
|
|
114
|
+
}, Date>;
|
|
115
|
+
}> & import("../../../index.js").RelationRow</*elided*/ any> & import("../../../index.js").AggregateRow<{
|
|
116
|
+
readonly bookCount: () => import("../../../index.js").RelationAggregate<number>;
|
|
117
|
+
readonly topStock: () => import("../../../index.js").RelationAggregate<number | null>;
|
|
118
|
+
}>>;
|
|
119
|
+
}> & import("../../../index.js").AggregateRow<{}>, "1m", {
|
|
120
|
+
id: number;
|
|
121
|
+
title: string;
|
|
122
|
+
stock: number;
|
|
123
|
+
status: "draft" | "published";
|
|
124
|
+
version: number;
|
|
125
|
+
authorId: number;
|
|
126
|
+
} & {} & {
|
|
127
|
+
readonly shout?: string | null | undefined;
|
|
128
|
+
}>;
|
|
129
|
+
}> & import("../../../index.js").AggregateRow<{
|
|
130
|
+
readonly bookCount: () => import("../../../index.js").RelationAggregate<number>;
|
|
131
|
+
readonly topStock: () => import("../../../index.js").RelationAggregate<number | null>;
|
|
132
|
+
}>, number, {
|
|
133
|
+
id: number;
|
|
134
|
+
name: string;
|
|
135
|
+
createdAt: Date;
|
|
136
|
+
} & {
|
|
137
|
+
bio?: string | null | undefined;
|
|
138
|
+
}, false>;
|
|
139
|
+
export type Author = InstanceType<typeof Author>;
|
|
140
|
+
export declare const label: (author: Author) => string;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { currentTimestamp } from '../../../util/index.js';
|
|
2
|
+
import { f } from '../../column.js';
|
|
3
|
+
import { defineEntity } from '../definition.js';
|
|
4
|
+
import { Book } from './book.js';
|
|
5
|
+
export const Author = defineEntity({
|
|
6
|
+
name: 'Author',
|
|
7
|
+
fields: {
|
|
8
|
+
id: f.number().id(),
|
|
9
|
+
name: f.string(),
|
|
10
|
+
bio: f.string().nullable(),
|
|
11
|
+
createdAt: f.date().default(currentTimestamp),
|
|
12
|
+
},
|
|
13
|
+
})
|
|
14
|
+
.hooks({
|
|
15
|
+
beforeInsert: [
|
|
16
|
+
(author) => {
|
|
17
|
+
author.bio ??= 'unwritten';
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
})
|
|
21
|
+
.relations((rel) => ({ books: () => rel.oneToMany(Book, { mappedBy: (book) => book.author }) }), (rel) => ({
|
|
22
|
+
bookCount: () => rel.books.count(),
|
|
23
|
+
topStock: () => rel.books.max((book) => book.stock),
|
|
24
|
+
}));
|
|
25
|
+
export const label = (author) => `${author.name} (${author.books?.length ?? 0})`;
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
export declare const Book: import("../../../index.js").SchemaClass<object & {
|
|
2
|
+
id: number;
|
|
3
|
+
title: string;
|
|
4
|
+
stock: number;
|
|
5
|
+
status: "draft" | "published";
|
|
6
|
+
version: number;
|
|
7
|
+
authorId: number;
|
|
8
|
+
} & {} & import("../../../index.js").Brands<{
|
|
9
|
+
readonly id: import("../../../index.js").NumericColumn<{
|
|
10
|
+
readonly type: NumberConstructor;
|
|
11
|
+
} & {
|
|
12
|
+
readonly isId: true;
|
|
13
|
+
}, number>;
|
|
14
|
+
readonly title: import("../../../index.js").StringColumn<{
|
|
15
|
+
readonly type: StringConstructor;
|
|
16
|
+
}, string>;
|
|
17
|
+
readonly stock: import("../../../index.js").NumericColumn<{
|
|
18
|
+
readonly type: NumberConstructor;
|
|
19
|
+
} & {
|
|
20
|
+
readonly defaultValue: unknown;
|
|
21
|
+
}, number>;
|
|
22
|
+
readonly status: import("../../../index.js").StringColumn<{
|
|
23
|
+
readonly type: StringConstructor;
|
|
24
|
+
readonly enum: readonly ["draft", "published"];
|
|
25
|
+
}, "draft" | "published">;
|
|
26
|
+
readonly version: import("../../../index.js").VersionColumn<{
|
|
27
|
+
readonly type: NumberConstructor;
|
|
28
|
+
readonly version: true;
|
|
29
|
+
}, number>;
|
|
30
|
+
readonly authorId: import("../../../index.js").NumericColumn<{
|
|
31
|
+
readonly type: NumberConstructor;
|
|
32
|
+
}, number>;
|
|
33
|
+
}> & {
|
|
34
|
+
readonly shout?: string | null | undefined;
|
|
35
|
+
} & import("../../../index.js").RelationRow<{
|
|
36
|
+
readonly author: () => import("../../../index.js").SchemaRelation<object & {
|
|
37
|
+
id: number;
|
|
38
|
+
name: string;
|
|
39
|
+
createdAt: Date;
|
|
40
|
+
} & {
|
|
41
|
+
bio?: string | null | undefined;
|
|
42
|
+
} & import("../../../index.js").Brands<{
|
|
43
|
+
readonly id: import("../../../index.js").NumericColumn<{
|
|
44
|
+
readonly type: NumberConstructor;
|
|
45
|
+
} & {
|
|
46
|
+
readonly isId: true;
|
|
47
|
+
}, number>;
|
|
48
|
+
readonly name: import("../../../index.js").StringColumn<{
|
|
49
|
+
readonly type: StringConstructor;
|
|
50
|
+
}, string>;
|
|
51
|
+
readonly bio: import("../../../index.js").StringColumn<{
|
|
52
|
+
readonly type: StringConstructor;
|
|
53
|
+
} & {
|
|
54
|
+
readonly nullable: true;
|
|
55
|
+
}, string>;
|
|
56
|
+
readonly createdAt: import("../../../index.js").DateColumn<{
|
|
57
|
+
readonly type: DateConstructor;
|
|
58
|
+
} & {
|
|
59
|
+
readonly defaultValue: unknown;
|
|
60
|
+
}, Date>;
|
|
61
|
+
}> & import("../../../index.js").RelationRow<{
|
|
62
|
+
readonly books: () => import("../../../index.js").SchemaRelation<object & {
|
|
63
|
+
id: number;
|
|
64
|
+
title: string;
|
|
65
|
+
stock: number;
|
|
66
|
+
status: "draft" | "published";
|
|
67
|
+
version: number;
|
|
68
|
+
authorId: number;
|
|
69
|
+
} & {} & import("../../../index.js").Brands<{
|
|
70
|
+
readonly id: import("../../../index.js").NumericColumn<{
|
|
71
|
+
readonly type: NumberConstructor;
|
|
72
|
+
} & {
|
|
73
|
+
readonly isId: true;
|
|
74
|
+
}, number>;
|
|
75
|
+
readonly title: import("../../../index.js").StringColumn<{
|
|
76
|
+
readonly type: StringConstructor;
|
|
77
|
+
}, string>;
|
|
78
|
+
readonly stock: import("../../../index.js").NumericColumn<{
|
|
79
|
+
readonly type: NumberConstructor;
|
|
80
|
+
} & {
|
|
81
|
+
readonly defaultValue: unknown;
|
|
82
|
+
}, number>;
|
|
83
|
+
readonly status: import("../../../index.js").StringColumn<{
|
|
84
|
+
readonly type: StringConstructor;
|
|
85
|
+
readonly enum: readonly ["draft", "published"];
|
|
86
|
+
}, "draft" | "published">;
|
|
87
|
+
readonly version: import("../../../index.js").VersionColumn<{
|
|
88
|
+
readonly type: NumberConstructor;
|
|
89
|
+
readonly version: true;
|
|
90
|
+
}, number>;
|
|
91
|
+
readonly authorId: import("../../../index.js").NumericColumn<{
|
|
92
|
+
readonly type: NumberConstructor;
|
|
93
|
+
}, number>;
|
|
94
|
+
}> & {
|
|
95
|
+
readonly shout?: string | null | undefined;
|
|
96
|
+
} & import("../../../index.js").RelationRow</*elided*/ any> & import("../../../index.js").AggregateRow<{}>, "1m", {
|
|
97
|
+
id: number;
|
|
98
|
+
title: string;
|
|
99
|
+
stock: number;
|
|
100
|
+
status: "draft" | "published";
|
|
101
|
+
version: number;
|
|
102
|
+
authorId: number;
|
|
103
|
+
} & {} & {
|
|
104
|
+
readonly shout?: string | null | undefined;
|
|
105
|
+
}>;
|
|
106
|
+
}> & import("../../../index.js").AggregateRow<{
|
|
107
|
+
readonly bookCount: () => import("../../../index.js").RelationAggregate<number>;
|
|
108
|
+
readonly topStock: () => import("../../../index.js").RelationAggregate<number | null>;
|
|
109
|
+
}>, "m1", object & {
|
|
110
|
+
id: number;
|
|
111
|
+
name: string;
|
|
112
|
+
createdAt: Date;
|
|
113
|
+
} & {
|
|
114
|
+
bio?: string | null | undefined;
|
|
115
|
+
} & import("../../../index.js").Brands<{
|
|
116
|
+
readonly id: import("../../../index.js").NumericColumn<{
|
|
117
|
+
readonly type: NumberConstructor;
|
|
118
|
+
} & {
|
|
119
|
+
readonly isId: true;
|
|
120
|
+
}, number>;
|
|
121
|
+
readonly name: import("../../../index.js").StringColumn<{
|
|
122
|
+
readonly type: StringConstructor;
|
|
123
|
+
}, string>;
|
|
124
|
+
readonly bio: import("../../../index.js").StringColumn<{
|
|
125
|
+
readonly type: StringConstructor;
|
|
126
|
+
} & {
|
|
127
|
+
readonly nullable: true;
|
|
128
|
+
}, string>;
|
|
129
|
+
readonly createdAt: import("../../../index.js").DateColumn<{
|
|
130
|
+
readonly type: DateConstructor;
|
|
131
|
+
} & {
|
|
132
|
+
readonly defaultValue: unknown;
|
|
133
|
+
}, Date>;
|
|
134
|
+
}> & import("../../../index.js").RelationRow<{
|
|
135
|
+
readonly books: () => import("../../../index.js").SchemaRelation<object & {
|
|
136
|
+
id: number;
|
|
137
|
+
title: string;
|
|
138
|
+
stock: number;
|
|
139
|
+
status: "draft" | "published";
|
|
140
|
+
version: number;
|
|
141
|
+
authorId: number;
|
|
142
|
+
} & {} & import("../../../index.js").Brands<{
|
|
143
|
+
readonly id: import("../../../index.js").NumericColumn<{
|
|
144
|
+
readonly type: NumberConstructor;
|
|
145
|
+
} & {
|
|
146
|
+
readonly isId: true;
|
|
147
|
+
}, number>;
|
|
148
|
+
readonly title: import("../../../index.js").StringColumn<{
|
|
149
|
+
readonly type: StringConstructor;
|
|
150
|
+
}, string>;
|
|
151
|
+
readonly stock: import("../../../index.js").NumericColumn<{
|
|
152
|
+
readonly type: NumberConstructor;
|
|
153
|
+
} & {
|
|
154
|
+
readonly defaultValue: unknown;
|
|
155
|
+
}, number>;
|
|
156
|
+
readonly status: import("../../../index.js").StringColumn<{
|
|
157
|
+
readonly type: StringConstructor;
|
|
158
|
+
readonly enum: readonly ["draft", "published"];
|
|
159
|
+
}, "draft" | "published">;
|
|
160
|
+
readonly version: import("../../../index.js").VersionColumn<{
|
|
161
|
+
readonly type: NumberConstructor;
|
|
162
|
+
readonly version: true;
|
|
163
|
+
}, number>;
|
|
164
|
+
readonly authorId: import("../../../index.js").NumericColumn<{
|
|
165
|
+
readonly type: NumberConstructor;
|
|
166
|
+
}, number>;
|
|
167
|
+
}> & {
|
|
168
|
+
readonly shout?: string | null | undefined;
|
|
169
|
+
} & import("../../../index.js").RelationRow<any> & import("../../../index.js").AggregateRow<{}>, "1m", {
|
|
170
|
+
id: number;
|
|
171
|
+
title: string;
|
|
172
|
+
stock: number;
|
|
173
|
+
status: "draft" | "published";
|
|
174
|
+
version: number;
|
|
175
|
+
authorId: number;
|
|
176
|
+
} & {} & {
|
|
177
|
+
readonly shout?: string | null | undefined;
|
|
178
|
+
}>;
|
|
179
|
+
}> & import("../../../index.js").AggregateRow<{
|
|
180
|
+
readonly bookCount: () => import("../../../index.js").RelationAggregate<number>;
|
|
181
|
+
readonly topStock: () => import("../../../index.js").RelationAggregate<number | null>;
|
|
182
|
+
}>>;
|
|
183
|
+
}> & import("../../../index.js").AggregateRow<{}>, number, {
|
|
184
|
+
id: number;
|
|
185
|
+
title: string;
|
|
186
|
+
stock: number;
|
|
187
|
+
status: "draft" | "published";
|
|
188
|
+
version: number;
|
|
189
|
+
authorId: number;
|
|
190
|
+
} & {} & {
|
|
191
|
+
readonly shout?: string | null | undefined;
|
|
192
|
+
}, false>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { sql } from '../../../util/index.js';
|
|
2
|
+
import { f } from '../../column.js';
|
|
3
|
+
import { defineEntity } from '../definition.js';
|
|
4
|
+
import { Author } from './author.js';
|
|
5
|
+
export const Book = defineEntity({
|
|
6
|
+
name: 'Book',
|
|
7
|
+
fields: {
|
|
8
|
+
id: f.number().id(),
|
|
9
|
+
title: f.string(),
|
|
10
|
+
stock: f.number().default(0),
|
|
11
|
+
status: f.enum(['draft', 'published']),
|
|
12
|
+
version: f.version(),
|
|
13
|
+
authorId: f.number(),
|
|
14
|
+
},
|
|
15
|
+
})
|
|
16
|
+
.computed((book) => ({
|
|
17
|
+
shout: f
|
|
18
|
+
.string()
|
|
19
|
+
.nullable()
|
|
20
|
+
.as(sql `upper(${book.title})`),
|
|
21
|
+
}))
|
|
22
|
+
.relations((rel) => ({ author: () => rel.manyToOne(Author, { references: (book) => book.authorId }) }))
|
|
23
|
+
.filters({ byEv: { where: { author: { name: 'Ev' } }, default: false } });
|
package/dist/http/contract.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AbstractType } from '../type/index.js';
|
|
2
2
|
/**
|
|
3
3
|
* Single source of truth for the CRUD-over-HTTP surface, shared by server adapters and the browser client.
|
|
4
4
|
* Keys are constrained to {@link UniversalQuerier} method names, so renaming a querier method
|
|
@@ -69,7 +69,7 @@ export type HttpMethod = CrudRoute['method'] | 'QUERY';
|
|
|
69
69
|
/**
|
|
70
70
|
* URL segment for an entity, e.g. `entityPath(UserProfile) === 'user-profile'`.
|
|
71
71
|
*/
|
|
72
|
-
export declare function entityPath<E>(entity:
|
|
72
|
+
export declare function entityPath<E>(entity: AbstractType<E>): string;
|
|
73
73
|
export type RouteMatch = {
|
|
74
74
|
readonly op: CrudOperation;
|
|
75
75
|
/**
|
package/dist/http/handler.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EntityMeta, QuerierPool, Query, RequestSuccessResponse,
|
|
1
|
+
import type { Type, EntityMeta, QuerierPool, Query, RequestSuccessResponse, AbstractType, UqlContext } from '../type/index.js';
|
|
2
2
|
import { type CrudOperation, type HttpMethod } from './contract.js';
|
|
3
3
|
import { type WireCursors, type WireFlags } from './query.js';
|
|
4
4
|
/**
|
|
@@ -50,7 +50,7 @@ export type RequestHandlerOptions<Ctx = unknown> = {
|
|
|
50
50
|
*/
|
|
51
51
|
include: readonly Type<object>[];
|
|
52
52
|
/** The URL segment an entity is addressed by, its kebab-cased class name by default; the browser client takes the same option. */
|
|
53
|
-
entityPath?: (entity:
|
|
53
|
+
entityPath?: (entity: AbstractType<unknown>) => string;
|
|
54
54
|
/**
|
|
55
55
|
* Allow augment any kind of request before it runs. Hooks may be async
|
|
56
56
|
* and abort the request by throwing (a numeric `status` on the error is honored).
|
package/dist/http/query.js
CHANGED
|
@@ -9,22 +9,21 @@ import { getKeys, isRecord, isWhereMap } from '../util/object.util.js';
|
|
|
9
9
|
import { UqlUsageError } from '../util/uqlError.js';
|
|
10
10
|
/** The flags a request carries beside its query: `hardDelete` on a delete, `count` on a `findMany`. */
|
|
11
11
|
const WIRE_FLAGS = ['hardDelete', 'count'];
|
|
12
|
-
/**
|
|
13
|
-
* Keys that mean something locally but that this transport can never honor, so they are rejected
|
|
14
|
-
* rather than dropped like the rest. Each request runs on its own auto-committing connection, so a
|
|
15
|
-
* row lock taken here is released before the response is written: honoring `$lock` is impossible,
|
|
16
|
-
* and ignoring it would hand the caller a read they believe is serialized and is not.
|
|
17
|
-
*/
|
|
18
|
-
const REJECTED_QUERY_KEYS = new Set(['$lock']);
|
|
19
12
|
/**
|
|
20
13
|
* The keys accepted from the wire, mapped to how each value is decoded: every query clause ({@link QUERY_CLAUSES})
|
|
21
|
-
* plus the {@link WIRE_FLAGS}.
|
|
22
|
-
*
|
|
14
|
+
* HTTP carries, plus the {@link WIRE_FLAGS}. Any other `$` key is refused, since dropping a clause answers a read
|
|
15
|
+
* other than the one asked for; any other key (e.g. `filters`, `context`) is dropped, so a remote client can't
|
|
16
|
+
* bypass a security filter or inject ambient context.
|
|
23
17
|
*/
|
|
24
18
|
const WIRE_VALUES = new Map([
|
|
25
|
-
...getKeys(QUERY_CLAUSES)
|
|
19
|
+
...getKeys(QUERY_CLAUSES)
|
|
20
|
+
.filter((key) => carriedOverHttp(QUERY_CLAUSES[key]))
|
|
21
|
+
.map((key) => [key, QUERY_CLAUSES[key].value]),
|
|
26
22
|
...WIRE_FLAGS.map((flag) => [flag, 'boolean']),
|
|
27
23
|
]);
|
|
24
|
+
function carriedOverHttp(clause) {
|
|
25
|
+
return clause.wire !== false;
|
|
26
|
+
}
|
|
28
27
|
/**
|
|
29
28
|
* Parse raw query-string entries (with JSON-stringified values), or a `QUERY` body, into a UQL query
|
|
30
29
|
* object. Symmetric counterpart of {@link stringifyQuery}. Only the keys in {@link WIRE_VALUES} are honored.
|
|
@@ -35,10 +34,10 @@ export function parseQueryParams(params = {}) {
|
|
|
35
34
|
}
|
|
36
35
|
const query = {};
|
|
37
36
|
for (const key of getKeys(params)) {
|
|
38
|
-
if (REJECTED_QUERY_KEYS.has(key)) {
|
|
39
|
-
throw new UqlUsageError(`'${key}' is not supported over HTTP`);
|
|
40
|
-
}
|
|
41
37
|
const shape = WIRE_VALUES.get(key);
|
|
38
|
+
if (!shape && key.startsWith('$')) {
|
|
39
|
+
throw new UqlUsageError(`'${key}' is not a query key HTTP takes`);
|
|
40
|
+
}
|
|
42
41
|
if (shape && params[key] !== undefined) {
|
|
43
42
|
query[key] = decodeWireValue(key, shape, params[key]);
|
|
44
43
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
export { captureContext, getContext, withContext } from './context/context.js';
|
|
2
2
|
export * from './entity/decorator/entity.js';
|
|
3
3
|
export * from './entity/decorator/members.js';
|
|
4
|
-
export {
|
|
4
|
+
export { f } from './entity/column.js';
|
|
5
|
+
export { defineEntity, getMeta, idOf, keyOf, removeEntity } from './entity/metadata/definition.js';
|
|
5
6
|
export * from './namingStrategy/index.js';
|
|
6
7
|
export { type QueryError, queryErrorKind } from './querier/queryError.js';
|
|
7
8
|
export type * from './type/index.js';
|
|
8
9
|
export { filledKey, idKey, isSqlQuerier, versionKey } from './type/index.js';
|
|
9
10
|
export { withDeleted } from './util/filters.util.js';
|
|
10
11
|
export { sortOf } from './util/query.util.js';
|
|
11
|
-
export type { HookContext } from './util/hook.util.js';
|
|
12
12
|
export { DefaultLogger } from './util/logger.js';
|
|
13
13
|
export { currentDate, currentTime, currentTimestamp, raw, refs, sql, uuid, uuidv7 } from './util/sql.js';
|
|
14
14
|
export { deleteFrom, insertInto, refuse, updateTable, upsertInto } from './util/triggerWrite.js';
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export { captureContext, getContext, withContext } from './context/context.js';
|
|
2
2
|
export * from './entity/decorator/entity.js';
|
|
3
3
|
export * from './entity/decorator/members.js';
|
|
4
|
-
export {
|
|
4
|
+
export { f } from './entity/column.js';
|
|
5
|
+
export { defineEntity, getMeta, idOf, keyOf, removeEntity } from './entity/metadata/definition.js';
|
|
5
6
|
export * from './namingStrategy/index.js';
|
|
6
7
|
export { queryErrorKind } from './querier/queryError.js';
|
|
7
8
|
export { filledKey, idKey, isSqlQuerier, versionKey } from './type/index.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type RelationRows, type SelectTerm } from '../dialect/abstractSqlDialect.js';
|
|
2
2
|
import { type JsonAccessMode, type JsonSlot } from '../dialect/jsonSql.js';
|
|
3
3
|
import { MysqlLikeSqlDialect } from '../dialect/mysqlLikeSqlDialect.js';
|
|
4
|
-
import type { FieldOptions, Query, QueryContext, SqlDialectFeatures, SqlValues,
|
|
4
|
+
import type { FieldOptions, Query, QueryContext, SqlDialectFeatures, SqlValues, AbstractType, VectorDistance, VectorMetric } from '../type/index.js';
|
|
5
5
|
export declare class MariaDialect extends MysqlLikeSqlDialect {
|
|
6
6
|
readonly dialectName = "mariadb";
|
|
7
7
|
readonly insertIdSource = "returning";
|
|
@@ -41,7 +41,7 @@ export declare class MariaDialect extends MysqlLikeSqlDialect {
|
|
|
41
41
|
* neither a transaction nor a restore, and cannot leak to the next query on this pooled connection,
|
|
42
42
|
* which is why the tuning is not `vectorTuningStatements`, Postgres's `SET LOCAL` shape.
|
|
43
43
|
*/
|
|
44
|
-
protected statementSettings<E>(entity:
|
|
44
|
+
protected statementSettings<E>(entity: AbstractType<E>, q: Query<E>): string[];
|
|
45
45
|
/** `SET STATEMENT ... FOR`, which scopes a variable to the statement it prefixes. */
|
|
46
46
|
protected applySettings(sql: string, settings: readonly string[]): string;
|
|
47
47
|
/**
|
|
@@ -29,7 +29,7 @@ export class MariaDialect extends MysqlLikeSqlDialect {
|
|
|
29
29
|
appendRelationArray(ctx, { entity, query, alias, joins }) {
|
|
30
30
|
const meta = getMeta(entity);
|
|
31
31
|
const terms = this.projection(ctx, entity, query, { prefix: alias, json: true }, joins);
|
|
32
|
-
const order = this.buildFragment(ctx, (fragmentCtx) => this.sort(fragmentCtx, entity, query, { prefix: alias, joins }));
|
|
32
|
+
const order = this.buildFragment(ctx, (fragmentCtx) => this.sort(fragmentCtx, entity, query, { prefix: alias, joins, unaliased: true }));
|
|
33
33
|
const page = this.buildFragment(ctx, (fragmentCtx) => this.pager(fragmentCtx, query));
|
|
34
34
|
const from = this.buildFragment(ctx, (fragmentCtx) => {
|
|
35
35
|
this.selectRelationJoins(fragmentCtx, meta, alias, joins);
|