@tstdl/base 0.92.42 → 0.92.44
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/orm/decorators.d.ts +2 -0
- package/orm/decorators.js +13 -7
- package/orm/server/drizzle/schema-converter.js +1 -1
- package/orm/types.d.ts +2 -2
- package/orm/types.js +2 -2
- package/package.json +6 -9
package/orm/decorators.d.ts
CHANGED
|
@@ -47,6 +47,8 @@ export declare function References(type: () => EntityType): PropertyDecorator;
|
|
|
47
47
|
export declare function Embedded(type: AbstractConstructor, options?: TypedOmit<NonNullable<OrmColumnReflectionData['embedded']>, 'type'>): PropertyDecorator;
|
|
48
48
|
export declare function Unique(name?: string, options?: UniqueReflectionData['options']): PropertyDecorator;
|
|
49
49
|
export declare function Unique(name: string | undefined, columns: [string, ...string[]], options?: UniqueReflectionData['options']): ClassDecorator;
|
|
50
|
+
export declare function Unique(columns: [string, ...string[]], options?: UniqueReflectionData['options']): ClassDecorator;
|
|
50
51
|
export declare function Index(name?: string, options?: IndexReflectionData['options']): PropertyDecorator;
|
|
51
52
|
export declare function Index(name: string | undefined, columns: [string, ...string[]], options?: IndexReflectionData['options']): ClassDecorator;
|
|
53
|
+
export declare function Index(columns: [string, ...string[]], options?: IndexReflectionData['options']): ClassDecorator;
|
|
52
54
|
export {};
|
package/orm/decorators.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createClassDecorator, createDecorator, createPropertyDecorator } from '../reflection/utils.js';
|
|
2
2
|
import { Property } from '../schema/index.js';
|
|
3
|
-
import { isArray } from '../utils/type-guards.js';
|
|
3
|
+
import { assertNotArrayPass, isArray } from '../utils/type-guards.js';
|
|
4
4
|
export function createTableDecorator(data) {
|
|
5
5
|
return createClassDecorator({ data: { orm: data }, mergeData: true });
|
|
6
6
|
}
|
|
@@ -24,15 +24,21 @@ export function Embedded(type, options) {
|
|
|
24
24
|
include: [Property(type), createColumnDecorator({ embedded: { type, ...options } })]
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
|
-
export function Unique(
|
|
27
|
+
export function Unique(nameOrColumns, columnsOrOptions, options) {
|
|
28
|
+
if (isArray(nameOrColumns)) {
|
|
29
|
+
return createTableDecorator({ unique: [{ columns: nameOrColumns, options: assertNotArrayPass(columnsOrOptions) }] });
|
|
30
|
+
}
|
|
28
31
|
if (isArray(columnsOrOptions)) {
|
|
29
|
-
return createTableDecorator({ unique: [{ name, columns: columnsOrOptions, options }] });
|
|
32
|
+
return createTableDecorator({ unique: [{ name: nameOrColumns, columns: columnsOrOptions, options }] });
|
|
30
33
|
}
|
|
31
|
-
return createColumnDecorator({ unique: { name, options: columnsOrOptions ?? options } });
|
|
34
|
+
return createColumnDecorator({ unique: { name: nameOrColumns, options: columnsOrOptions ?? options } });
|
|
32
35
|
}
|
|
33
|
-
export function Index(
|
|
36
|
+
export function Index(nameOrColumns, columnsOrOptions, options) {
|
|
37
|
+
if (isArray(nameOrColumns)) {
|
|
38
|
+
return createTableDecorator({ index: [{ columns: nameOrColumns, options: assertNotArrayPass(columnsOrOptions) }] });
|
|
39
|
+
}
|
|
34
40
|
if (isArray(columnsOrOptions)) {
|
|
35
|
-
return createTableDecorator({ index: [{ name, columns: columnsOrOptions, options }] });
|
|
41
|
+
return createTableDecorator({ index: [{ name: nameOrColumns, columns: columnsOrOptions, options }] });
|
|
36
42
|
}
|
|
37
|
-
return createColumnDecorator({ index: { name, options: columnsOrOptions ?? options } });
|
|
43
|
+
return createColumnDecorator({ index: { name: nameOrColumns, options: columnsOrOptions ?? options } });
|
|
38
44
|
}
|
|
@@ -46,7 +46,7 @@ export function _getDrizzleTableFromType(type, schemaName, tableName = getDefaul
|
|
|
46
46
|
return column;
|
|
47
47
|
});
|
|
48
48
|
const indexFn = (data.options?.unique == true) ? uniqueIndex : index;
|
|
49
|
-
return indexFn().using(data.options?.using ?? 'btree', ...columns);
|
|
49
|
+
return indexFn(data.name).using(data.options?.using ?? 'btree', ...columns);
|
|
50
50
|
}
|
|
51
51
|
const columnEntries = columnDefinitions.map((entry) => [entry.name, entry.type]);
|
|
52
52
|
const drizzleSchema = dbSchema.table(tableName, fromEntries(columnEntries), (table) => [
|
package/orm/types.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { boolean, date, doublePrecision, integer, jsonb, PgColumnBuilder, P
|
|
|
3
3
|
import type { GetTagMetadata, Tagged, UnwrapTagged } from 'type-fest';
|
|
4
4
|
import { Array, Integer } from '../schema/index.js';
|
|
5
5
|
import type { AbstractConstructor, EnumerationObject, EnumerationValue, ObjectLiteral, UnionToTuple } from '../types.js';
|
|
6
|
-
import { Embedded, Unique } from './decorators.js';
|
|
6
|
+
import { Column, Embedded, Index, PrimaryKey, References, Unique } from './decorators.js';
|
|
7
7
|
import { Json, NumericDate, Timestamp, Uuid } from './schemas/index.js';
|
|
8
8
|
export type IsPrimaryKey<T> = T extends Tagged<unknown, 'column', PgColumnBuilderBase> ? Tagged<UnwrapTagged<T>, 'column', DrizzleIsPrimaryKey<GetTagMetadata<T, 'column'>>> : Tagged<T, 'column', ColumnBuilder<T>>;
|
|
9
9
|
export type HasDefault<T> = T extends Tagged<unknown, 'column', PgColumnBuilderBase> ? Tagged<UnwrapTagged<T>, 'column', DrizzleHasDefault<GetTagMetadata<T, 'column'>>> : Tagged<T, 'column', ColumnBuilder<T>>;
|
|
@@ -28,4 +28,4 @@ export type DoublePrecision = Tagged<number, 'column', ReturnType<typeof doubleP
|
|
|
28
28
|
export type Boolean = Tagged<number, 'column', ReturnType<typeof boolean>>;
|
|
29
29
|
export type NumericDate = Tagged<number, 'column', ReturnType<typeof date>>;
|
|
30
30
|
export type Timestamp = Tagged<number, 'column', ReturnType<typeof timestamp>>;
|
|
31
|
-
export { Array, Embedded, Integer, Json, NumericDate, Timestamp, Unique, Uuid };
|
|
31
|
+
export { Array, Column, Embedded, Index, Integer, Json, NumericDate, PrimaryKey, References, Timestamp, Unique, Uuid };
|
package/orm/types.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-redeclare, @typescript-eslint/naming-convention */
|
|
2
2
|
import { Array, Integer } from '../schema/index.js';
|
|
3
|
-
import { Embedded, Unique } from './decorators.js';
|
|
3
|
+
import { Column, Embedded, Index, PrimaryKey, References, Unique } from './decorators.js';
|
|
4
4
|
import { Json, NumericDate, Timestamp, Uuid } from './schemas/index.js';
|
|
5
|
-
export { Array, Embedded, Integer, Json, NumericDate, Timestamp, Unique, Uuid };
|
|
5
|
+
export { Array, Column, Embedded, Index, Integer, Json, NumericDate, PrimaryKey, References, Timestamp, Unique, Uuid };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tstdl/base",
|
|
3
|
-
"version": "0.92.
|
|
3
|
+
"version": "0.92.44",
|
|
4
4
|
"author": "Patrick Hein",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -124,11 +124,11 @@
|
|
|
124
124
|
"luxon": "^3.5",
|
|
125
125
|
"reflect-metadata": "^0.2",
|
|
126
126
|
"rxjs": "^7.8",
|
|
127
|
-
"type-fest": "4.
|
|
127
|
+
"type-fest": "4.35"
|
|
128
128
|
},
|
|
129
129
|
"devDependencies": {
|
|
130
130
|
"@mxssfd/typedoc-theme": "1.1",
|
|
131
|
-
"@stylistic/eslint-plugin": "3.
|
|
131
|
+
"@stylistic/eslint-plugin": "3.1",
|
|
132
132
|
"@types/chroma-js": "2.4",
|
|
133
133
|
"@types/koa__router": "12.0",
|
|
134
134
|
"@types/luxon": "3.4",
|
|
@@ -137,14 +137,13 @@
|
|
|
137
137
|
"@types/node": "22",
|
|
138
138
|
"@types/nodemailer": "6.4",
|
|
139
139
|
"@types/pg": "8.11",
|
|
140
|
-
"@typescript-eslint/eslint-plugin": "8.
|
|
140
|
+
"@typescript-eslint/eslint-plugin": "8.24",
|
|
141
141
|
"concurrently": "9.1",
|
|
142
142
|
"drizzle-kit": "0.30",
|
|
143
143
|
"eslint": "8.57",
|
|
144
|
-
"eslint-import-resolver-typescript": "3.
|
|
144
|
+
"eslint-import-resolver-typescript": "3.8",
|
|
145
145
|
"eslint-plugin-import": "2.31",
|
|
146
146
|
"tsc-alias": "1.8",
|
|
147
|
-
"tsx": "^4.19.2",
|
|
148
147
|
"typedoc": "0.27",
|
|
149
148
|
"typedoc-plugin-missing-exports": "3.1",
|
|
150
149
|
"typescript": "5.7"
|
|
@@ -152,7 +151,6 @@
|
|
|
152
151
|
"peerDependencies": {
|
|
153
152
|
"@elastic/elasticsearch": "^8.17",
|
|
154
153
|
"@google/generative-ai": "^0.21",
|
|
155
|
-
"@koa/router": "^13.1",
|
|
156
154
|
"@tstdl/angular": "^0.92",
|
|
157
155
|
"@zxcvbn-ts/core": "^3.0",
|
|
158
156
|
"@zxcvbn-ts/language-common": "^3.0",
|
|
@@ -161,14 +159,13 @@
|
|
|
161
159
|
"chroma-js": "^2.6",
|
|
162
160
|
"drizzle-orm": "^0.39",
|
|
163
161
|
"handlebars": "^4.7",
|
|
164
|
-
"koa": "^2.15",
|
|
165
162
|
"minio": "^8.0",
|
|
166
163
|
"mjml": "^4.15",
|
|
167
164
|
"mongodb": "^6.13",
|
|
168
165
|
"nodemailer": "^6.10",
|
|
169
166
|
"pg": "^8.13",
|
|
170
167
|
"playwright": "^1.50",
|
|
171
|
-
"preact": "^10.
|
|
168
|
+
"preact": "^10.26",
|
|
172
169
|
"preact-render-to-string": "^6.5",
|
|
173
170
|
"undici": "^7.3",
|
|
174
171
|
"urlpattern-polyfill": "^10.0"
|