@tstdl/base 0.93.20 → 0.93.22
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/application/application.js +1 -1
- package/audit/auditor.js +1 -1
- package/authentication/server/authentication.service.js +1 -1
- package/authentication/server/module.d.ts +1 -1
- package/authentication/server/module.js +1 -6
- package/document-management/api/document-management.api.d.ts +0 -4
- package/document-management/server/services/singleton.js +1 -1
- package/document-management/service-models/document.service-model.d.ts +0 -2
- package/injector/injector.d.ts +1 -1
- package/injector/injector.js +25 -13
- package/injector/types.d.ts +1 -1
- package/key-value-store/postgres/key-value-store.service.js +1 -1
- package/lock/postgres/provider.js +1 -1
- package/logger/manager.js +3 -3
- package/mail/mail.service.js +1 -1
- package/orm/data-types/bytea.d.ts +4 -14
- package/orm/data-types/bytea.js +2 -2
- package/orm/data-types/common.d.ts +18 -0
- package/orm/data-types/common.js +11 -0
- package/orm/data-types/index.d.ts +1 -0
- package/orm/data-types/index.js +1 -0
- package/orm/data-types/numeric-date.d.ts +4 -15
- package/orm/data-types/numeric-date.js +2 -2
- package/orm/data-types/timestamp.d.ts +4 -15
- package/orm/data-types/timestamp.js +2 -2
- package/orm/data-types/tsvector.d.ts +3 -13
- package/orm/data-types/tsvector.js +2 -2
- package/orm/decorators.d.ts +16 -54
- package/orm/decorators.js +24 -37
- package/orm/entity.d.ts +6 -9
- package/orm/entity.js +1 -2
- package/orm/query.d.ts +199 -61
- package/orm/query.js +2 -2
- package/orm/repository.types.d.ts +38 -9
- package/orm/server/drizzle/schema-converter.js +40 -118
- package/orm/server/query-converter.d.ts +21 -7
- package/orm/server/query-converter.js +194 -38
- package/orm/server/repository.d.ts +39 -22
- package/orm/server/repository.js +141 -71
- package/orm/server/types.d.ts +10 -2
- package/orm/sqls.d.ts +14 -16
- package/orm/sqls.js +34 -17
- package/package.json +2 -2
- package/queue/postgres/queue.js +1 -1
- package/test/drizzle/0000_nervous_iron_monger.sql +9 -0
- package/test/drizzle/meta/0000_snapshot.json +27 -7
- package/test/drizzle/meta/_journal.json +2 -44
- package/test/test.model.js +2 -6
- package/test1.js +18 -5
- package/test6.js +21 -35
- package/types/types.d.ts +8 -5
- package/utils/equals.js +2 -2
- package/utils/format-error.js +2 -2
- package/utils/helpers.js +3 -2
- package/utils/object/object.d.ts +4 -4
- package/test/drizzle/0000_sudden_sphinx.sql +0 -9
- package/test/drizzle/0001_organic_rhodey.sql +0 -2
- package/test/drizzle/0002_nice_squadron_supreme.sql +0 -1
- package/test/drizzle/0003_serious_mockingbird.sql +0 -1
- package/test/drizzle/0004_complete_pixie.sql +0 -1
- package/test/drizzle/0005_bumpy_sabra.sql +0 -1
- package/test/drizzle/0006_overrated_post.sql +0 -6
- package/test/drizzle/meta/0001_snapshot.json +0 -79
- package/test/drizzle/meta/0002_snapshot.json +0 -63
- package/test/drizzle/meta/0003_snapshot.json +0 -73
- package/test/drizzle/meta/0004_snapshot.json +0 -89
- package/test/drizzle/meta/0005_snapshot.json +0 -104
- package/test/drizzle/meta/0006_snapshot.json +0 -104
|
@@ -29,7 +29,7 @@ let Application = Application_1 = class Application {
|
|
|
29
29
|
#shutdownPromise = new DeferredPromise();
|
|
30
30
|
#shutdownToken = inject(CancellationSignal, undefined, { optional: true })?.createChild() ?? new CancellationToken();
|
|
31
31
|
static create(name, providers = []) {
|
|
32
|
-
const injector = new Injector(`${name}
|
|
32
|
+
const injector = new Injector(`${name}ApplicationInjector`);
|
|
33
33
|
injector.register(APPLICATION_INSTANCE_ID, { useValue: crypto.randomUUID() });
|
|
34
34
|
injector.register(APPLICATION_NAME, { useValue: name });
|
|
35
35
|
for (const providersItem of providers.flat()) {
|
package/audit/auditor.js
CHANGED
|
@@ -233,7 +233,7 @@ Auditor = Auditor_1 = __decorate([
|
|
|
233
233
|
Injectable({
|
|
234
234
|
providers: [
|
|
235
235
|
provide(EntityRepositoryConfig, { useValue: { schema: 'audit' } }),
|
|
236
|
-
{ provide: DatabaseConfig, useFactory: (_, context) => context.resolve(AuditModuleConfig).database ?? context.resolve(DatabaseConfig, undefined, { skipSelf:
|
|
236
|
+
{ provide: DatabaseConfig, useFactory: (_, context) => context.resolve(AuditModuleConfig).database ?? context.resolve(DatabaseConfig, undefined, { skipSelf: true }) },
|
|
237
237
|
],
|
|
238
238
|
})
|
|
239
239
|
], Auditor);
|
|
@@ -630,7 +630,7 @@ AuthenticationService = AuthenticationService_1 = __decorate([
|
|
|
630
630
|
Singleton({
|
|
631
631
|
providers: [
|
|
632
632
|
provide(EntityRepositoryConfig, { useValue: { schema: 'authentication' } }),
|
|
633
|
-
provide(DatabaseConfig, { useFactory: (_, context) => context.resolve(AuthenticationModuleConfig).database ?? context.resolve(DatabaseConfig, undefined, { skipSelf:
|
|
633
|
+
provide(DatabaseConfig, { useFactory: (_, context) => context.resolve(AuthenticationModuleConfig).database ?? context.resolve(DatabaseConfig, undefined, { skipSelf: true }) }),
|
|
634
634
|
],
|
|
635
635
|
})
|
|
636
636
|
], AuthenticationService);
|
|
@@ -15,7 +15,7 @@ export declare class AuthenticationModuleConfig {
|
|
|
15
15
|
/**
|
|
16
16
|
* Options for {@link AuthenticationService}.
|
|
17
17
|
*/
|
|
18
|
-
serviceOptions
|
|
18
|
+
serviceOptions: AuthenticationServiceOptions | Provider<AuthenticationServiceOptions>;
|
|
19
19
|
/**
|
|
20
20
|
* Override default {@link AuthenticationService}.
|
|
21
21
|
*/
|
|
@@ -33,12 +33,7 @@ export class AuthenticationModuleConfig {
|
|
|
33
33
|
*/
|
|
34
34
|
export function configureAuthenticationServer(config) {
|
|
35
35
|
Injector.register(AuthenticationModuleConfig, { useValue: config });
|
|
36
|
-
|
|
37
|
-
Injector.register(AuthenticationServiceOptions, isProvider(config.serviceOptions) ? config.serviceOptions : { useValue: config.serviceOptions });
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
throw new Error('Either serviceOptions or serviceOptionsToken must be provided.');
|
|
41
|
-
}
|
|
36
|
+
Injector.register(AuthenticationServiceOptions, isProvider(config.serviceOptions) ? config.serviceOptions : { useValue: config.serviceOptions });
|
|
42
37
|
if (isDefined(config.authenticationService)) {
|
|
43
38
|
Injector.registerSingleton(AuthenticationService, { useToken: config.authenticationService });
|
|
44
39
|
}
|
|
@@ -179,7 +179,6 @@ export declare const documentManagementApiDefinition: {
|
|
|
179
179
|
parameters: import("../../schema/index.js").ObjectSchema<{
|
|
180
180
|
id: import("../../orm/types.js").IsPrimaryKey<import("../../orm/types.js").HasDefault<import("../../orm/types.js").Uuid>>;
|
|
181
181
|
description?: string | null | undefined;
|
|
182
|
-
readonly __entityMeta__?: import("../../orm/entity.js").EntityMeta | undefined;
|
|
183
182
|
tenantId?: string | null | undefined;
|
|
184
183
|
label?: string | undefined;
|
|
185
184
|
metadata?: Partial<{
|
|
@@ -233,7 +232,6 @@ export declare const documentManagementApiDefinition: {
|
|
|
233
232
|
method: "PATCH";
|
|
234
233
|
parameters: import("../../schema/index.js").ObjectSchema<{
|
|
235
234
|
id: import("../../orm/types.js").IsPrimaryKey<import("../../orm/types.js").HasDefault<import("../../orm/types.js").Uuid>>;
|
|
236
|
-
readonly __entityMeta__?: import("../../orm/entity.js").EntityMeta | undefined;
|
|
237
235
|
tenantId?: string | null | undefined;
|
|
238
236
|
typeId?: import("../../orm/types.js").Uuid | undefined;
|
|
239
237
|
comment?: string | null | undefined;
|
|
@@ -581,7 +579,6 @@ declare const _DocumentManagementApi: import("../../api/client/index.js").ApiCli
|
|
|
581
579
|
parameters: import("../../schema/index.js").ObjectSchema<{
|
|
582
580
|
id: import("../../orm/types.js").IsPrimaryKey<import("../../orm/types.js").HasDefault<import("../../orm/types.js").Uuid>>;
|
|
583
581
|
description?: string | null | undefined;
|
|
584
|
-
readonly __entityMeta__?: import("../../orm/entity.js").EntityMeta | undefined;
|
|
585
582
|
tenantId?: string | null | undefined;
|
|
586
583
|
label?: string | undefined;
|
|
587
584
|
metadata?: Partial<{
|
|
@@ -635,7 +632,6 @@ declare const _DocumentManagementApi: import("../../api/client/index.js").ApiCli
|
|
|
635
632
|
method: "PATCH";
|
|
636
633
|
parameters: import("../../schema/index.js").ObjectSchema<{
|
|
637
634
|
id: import("../../orm/types.js").IsPrimaryKey<import("../../orm/types.js").HasDefault<import("../../orm/types.js").Uuid>>;
|
|
638
|
-
readonly __entityMeta__?: import("../../orm/entity.js").EntityMeta | undefined;
|
|
639
635
|
tenantId?: string | null | undefined;
|
|
640
636
|
typeId?: import("../../orm/types.js").Uuid | undefined;
|
|
641
637
|
comment?: string | null | undefined;
|
|
@@ -3,7 +3,7 @@ import { provide } from '../../../injector/injector.js';
|
|
|
3
3
|
import { factoryProvider } from '../../../injector/provider.js';
|
|
4
4
|
import { DatabaseConfig } from '../../../orm/server/index.js';
|
|
5
5
|
import { DocumentManagementConfiguration } from '../module.js';
|
|
6
|
-
export const documentManagementDatabaseConfigFactoryProvider = factoryProvider((_, context) => context.resolve(DocumentManagementConfiguration).database ?? context.resolve(DatabaseConfig, undefined, { skipSelf:
|
|
6
|
+
export const documentManagementDatabaseConfigFactoryProvider = factoryProvider((_, context) => context.resolve(DocumentManagementConfiguration).database ?? context.resolve(DatabaseConfig, undefined, { skipSelf: true }));
|
|
7
7
|
export const documentManagementDatabaseConfigProvider = provide(DatabaseConfig, documentManagementDatabaseConfigFactoryProvider);
|
|
8
8
|
export function DocumentManagementSingleton() {
|
|
9
9
|
return Singleton({ providers: [documentManagementDatabaseConfigProvider] });
|
|
@@ -97,7 +97,6 @@ export declare const createDocumentRequestsTemplateParametersSchema: import("../
|
|
|
97
97
|
export declare const updateDocumentRequestsTemplateParametersSchema: import("../../schema/index.js").ObjectSchema<{
|
|
98
98
|
id: import("../../orm/index.js").IsPrimaryKey<import("../../orm/index.js").HasDefault<import("../../orm/index.js").Uuid>>;
|
|
99
99
|
description?: string | null | undefined;
|
|
100
|
-
readonly __entityMeta__?: import("../../orm/index.js").EntityMeta | undefined;
|
|
101
100
|
tenantId?: string | null | undefined;
|
|
102
101
|
label?: string | undefined;
|
|
103
102
|
metadata?: Partial<{
|
|
@@ -127,7 +126,6 @@ export declare const createDocumentRequestTemplateParametersSchema: import("../.
|
|
|
127
126
|
}>;
|
|
128
127
|
export declare const updateDocumentRequestTemplateParametersSchema: import("../../schema/index.js").ObjectSchema<{
|
|
129
128
|
id: import("../../orm/index.js").IsPrimaryKey<import("../../orm/index.js").HasDefault<import("../../orm/index.js").Uuid>>;
|
|
130
|
-
readonly __entityMeta__?: import("../../orm/index.js").EntityMeta | undefined;
|
|
131
129
|
tenantId?: string | null | undefined;
|
|
132
130
|
typeId?: import("../../orm/index.js").Uuid | undefined;
|
|
133
131
|
comment?: string | null | undefined;
|
package/injector/injector.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export type Registration<T = any, A = any> = GlobalRegistration<T, A> & {
|
|
|
22
22
|
resolutions: Map<any, T>;
|
|
23
23
|
};
|
|
24
24
|
export type GetRegistrationOptions = {
|
|
25
|
-
skipSelf?: boolean
|
|
25
|
+
skipSelf?: boolean;
|
|
26
26
|
onlySelf?: boolean;
|
|
27
27
|
};
|
|
28
28
|
export type ResolveManyArrayItem<T, A> = [token: InjectionToken<T, A>, argument?: ResolveArgument<T, A>, options?: InjectOptions<T, A>];
|
package/injector/injector.js
CHANGED
|
@@ -145,9 +145,8 @@ export class Injector {
|
|
|
145
145
|
this.register(globalRegistration.token, globalRegistration.provider, globalRegistration.options);
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
return this.#parent?.tryGetRegistration(token, { ...options, skipSelf: skipLevels - 1 });
|
|
148
|
+
if (options?.skipSelf == true) {
|
|
149
|
+
return this.#parent?.tryGetRegistration(token, { ...options, skipSelf: false });
|
|
151
150
|
}
|
|
152
151
|
const ownRegistration = this.#registrations.get(token);
|
|
153
152
|
if (isDefined(ownRegistration)) {
|
|
@@ -271,6 +270,12 @@ export class Injector {
|
|
|
271
270
|
}
|
|
272
271
|
_resolve(token, argument, options, context, chain) {
|
|
273
272
|
this.assertNotDisposed();
|
|
273
|
+
if (options.skipSelf == true) {
|
|
274
|
+
if (isNull(this.#parent) && (options.optional != true)) {
|
|
275
|
+
throw new ResolveError(`No parent injector available.`, chain);
|
|
276
|
+
}
|
|
277
|
+
return this.#parent?._resolve(token, argument, { ...options, skipSelf: false }, context, chain);
|
|
278
|
+
}
|
|
274
279
|
if (isDefined(options.forwardRef) && (options.forwardRef != false)) {
|
|
275
280
|
assert(options.optional != true, 'ForwardRef does not support optional without resolveAll/injectAll as undefined is not forwardable.');
|
|
276
281
|
const forwardToken = isFunction(options.forwardRef) ? options.forwardRef() : token;
|
|
@@ -287,6 +292,9 @@ export class Injector {
|
|
|
287
292
|
const singleRegistration = isArray(registration) ? registration[0] : registration;
|
|
288
293
|
return this._resolveRegistration(singleRegistration, argument, options, context, chain);
|
|
289
294
|
}
|
|
295
|
+
if ((options.onlySelf != true) && isNotNull(this.#parent)) {
|
|
296
|
+
return this.#parent._resolve(token, argument, options, context, chain);
|
|
297
|
+
}
|
|
290
298
|
if (options.optional == true) {
|
|
291
299
|
return undefined;
|
|
292
300
|
}
|
|
@@ -294,6 +302,12 @@ export class Injector {
|
|
|
294
302
|
}
|
|
295
303
|
_resolveAll(token, argument, options, context, chain) {
|
|
296
304
|
this.assertNotDisposed();
|
|
305
|
+
if (options.skipSelf == true) {
|
|
306
|
+
if (isNull(this.#parent) && (options.optional != true)) {
|
|
307
|
+
throw new ResolveError(`No parent injector available.`, chain);
|
|
308
|
+
}
|
|
309
|
+
return this.#parent?._resolveAll(token, argument, { ...options, skipSelf: false }, context, chain) ?? [];
|
|
310
|
+
}
|
|
297
311
|
if (isDefined(options.forwardRef) && (options.forwardRef != false)) {
|
|
298
312
|
const forwardToken = isFunction(options.forwardRef) ? options.forwardRef() : token;
|
|
299
313
|
const forwardRef = ForwardRef.create({ typeHint: options.forwardRefTypeHint ?? isFunction(forwardToken) ? forwardToken : undefined });
|
|
@@ -306,16 +320,14 @@ export class Injector {
|
|
|
306
320
|
}
|
|
307
321
|
const ownValues = [];
|
|
308
322
|
const parentValues = [];
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
ownValues.push(...resolved);
|
|
315
|
-
}
|
|
323
|
+
const registration = this.tryGetRegistration(token, options);
|
|
324
|
+
if (isDefined(registration)) {
|
|
325
|
+
const registrations = isArray(registration) ? registration : [registration];
|
|
326
|
+
const resolved = registrations.map((reg) => this._resolveRegistration(reg, argument, options, context, chain));
|
|
327
|
+
ownValues.push(...resolved);
|
|
316
328
|
}
|
|
317
|
-
if (
|
|
318
|
-
parentValues.push(...this.#parent._resolveAll(token, argument,
|
|
329
|
+
if ((options.onlySelf != true) && isNotNull(this.#parent)) {
|
|
330
|
+
parentValues.push(...this.#parent._resolveAll(token, argument, options, context, chain));
|
|
319
331
|
}
|
|
320
332
|
const allValues = [...ownValues, ...parentValues];
|
|
321
333
|
if ((allValues.length == 0) && (options.optional != true)) {
|
|
@@ -346,7 +358,7 @@ export class Injector {
|
|
|
346
358
|
}
|
|
347
359
|
// A new scope is only needed if we are instantiating a class, running a factory, or if the registration explicitly defines scoped providers.
|
|
348
360
|
const needsNewScope = isClassProvider(provider) || isFactoryProvider(provider) || (providers.length > 0);
|
|
349
|
-
const injector = needsNewScope ? this.fork(
|
|
361
|
+
const injector = needsNewScope ? this.fork(`[${getTokenName(token)}]ResolutionInjector`) : this;
|
|
350
362
|
for (const nestedProvider of providers) {
|
|
351
363
|
injector.registerSingleton(nestedProvider.provide, nestedProvider, { multi: nestedProvider.multi });
|
|
352
364
|
}
|
package/injector/types.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export type ArgumentProvider<T = unknown, D extends Record = Record> = (context:
|
|
|
26
26
|
export type ForwardRefInjectionToken<T = any, A = any> = Exclude<InjectionToken<T, A>, Function> | (() => InjectionToken<T, A>);
|
|
27
27
|
export type ResolveOptions<T, A> = {
|
|
28
28
|
optional?: boolean;
|
|
29
|
-
skipSelf?: boolean
|
|
29
|
+
skipSelf?: boolean;
|
|
30
30
|
onlySelf?: boolean;
|
|
31
31
|
/** If defined, resolve the token using ForwardRef strategy instead of resolving the token directly can be used to circumvent circular dependency problems */
|
|
32
32
|
forwardRef?: boolean | ForwardRefInjectionToken<T, A>;
|
|
@@ -57,7 +57,7 @@ PostgresKeyValueStore = __decorate([
|
|
|
57
57
|
Singleton({
|
|
58
58
|
providers: [
|
|
59
59
|
provide(EntityRepositoryConfig, { useValue: { schema: 'key_value_store' } }),
|
|
60
|
-
{ provide: DatabaseConfig, useFactory: (_, context) => context.resolve(PostgresKeyValueStoreModuleConfig).database ?? context.resolve(DatabaseConfig, undefined, { skipSelf:
|
|
60
|
+
{ provide: DatabaseConfig, useFactory: (_, context) => context.resolve(PostgresKeyValueStoreModuleConfig).database ?? context.resolve(DatabaseConfig, undefined, { skipSelf: true }) },
|
|
61
61
|
],
|
|
62
62
|
})
|
|
63
63
|
], PostgresKeyValueStore);
|
|
@@ -21,7 +21,7 @@ PostgresLockProvider = __decorate([
|
|
|
21
21
|
Singleton({
|
|
22
22
|
providers: [
|
|
23
23
|
provide(EntityRepositoryConfig, { useValue: { schema: 'lock' } }),
|
|
24
|
-
{ provide: DatabaseConfig, useFactory: (_, context) => context.resolve(PostgresLockModuleConfig).database ?? context.resolve(DatabaseConfig, undefined, { skipSelf:
|
|
24
|
+
{ provide: DatabaseConfig, useFactory: (_, context) => context.resolve(PostgresLockModuleConfig).database ?? context.resolve(DatabaseConfig, undefined, { skipSelf: true }) },
|
|
25
25
|
],
|
|
26
26
|
})
|
|
27
27
|
], PostgresLockProvider);
|
package/logger/manager.js
CHANGED
|
@@ -6,7 +6,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
};
|
|
7
7
|
import { Singleton } from '../injector/decorators.js';
|
|
8
8
|
import { inject, injectAll } from '../injector/inject.js';
|
|
9
|
-
import { isDefined } from '../utils/type-guards.js';
|
|
9
|
+
import { isArray, isDefined } from '../utils/type-guards.js';
|
|
10
10
|
import { LogLevel } from './level.js';
|
|
11
11
|
import { DEFAULT_LOG_LEVEL } from './tokens.js';
|
|
12
12
|
import { LogTransport } from './transport.js';
|
|
@@ -41,7 +41,7 @@ let LogManager = class LogManager {
|
|
|
41
41
|
* @param level The log level to set
|
|
42
42
|
*/
|
|
43
43
|
setModuleLevel(module, level) {
|
|
44
|
-
const moduleString =
|
|
44
|
+
const moduleString = isArray(module) ? module.join('.') : module;
|
|
45
45
|
if (this.#moduleLevelRules.get(moduleString) === level) {
|
|
46
46
|
return;
|
|
47
47
|
}
|
|
@@ -58,7 +58,7 @@ let LogManager = class LogManager {
|
|
|
58
58
|
if (!isDefined(module) || (module.length == 0)) {
|
|
59
59
|
return this.#defaultLevel;
|
|
60
60
|
}
|
|
61
|
-
const path =
|
|
61
|
+
const path = isArray(module) ? module.join('.') : module;
|
|
62
62
|
const cachedLevel = this.#moduleLevelCache.get(path);
|
|
63
63
|
if (isDefined(cachedLevel)) {
|
|
64
64
|
return cachedLevel;
|
package/mail/mail.service.js
CHANGED
|
@@ -60,7 +60,7 @@ MailService = __decorate([
|
|
|
60
60
|
Singleton({
|
|
61
61
|
providers: [
|
|
62
62
|
provide(EntityRepositoryConfig, { useValue: { schema: 'mail' } }),
|
|
63
|
-
provide(DatabaseConfig, { useFactory: (_, context) => context.resolve(MailModuleConfig).database ?? context.resolve(DatabaseConfig, undefined, { skipSelf:
|
|
63
|
+
provide(DatabaseConfig, { useFactory: (_, context) => context.resolve(MailModuleConfig).database ?? context.resolve(DatabaseConfig, undefined, { skipSelf: true }) }),
|
|
64
64
|
],
|
|
65
65
|
})
|
|
66
66
|
], MailService);
|
|
@@ -1,18 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module
|
|
3
|
-
* Defines a custom Drizzle type for handling PostgreSQL `bytea` columns.
|
|
4
|
-
*/
|
|
5
|
-
import { type ConvertCustomConfig, type PgCustomColumnBuilder } from 'drizzle-orm/pg-core';
|
|
6
|
-
type Config = {
|
|
7
|
-
data: Uint8Array;
|
|
8
|
-
driverData: Uint8Array;
|
|
9
|
-
};
|
|
10
1
|
/**
|
|
11
2
|
* Custom Drizzle type for PostgreSQL `bytea` columns.
|
|
12
3
|
* Maps between `Uint8Array` in JavaScript and `bytea` in the database.
|
|
13
4
|
*/
|
|
14
|
-
export declare const bytea: {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
export {};
|
|
5
|
+
export declare const bytea: import("./common.js").CustomTypeBuilder<{
|
|
6
|
+
data: Uint8Array;
|
|
7
|
+
driverData: Uint8Array;
|
|
8
|
+
}>;
|
package/orm/data-types/bytea.js
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
* @module
|
|
3
3
|
* Defines a custom Drizzle type for handling PostgreSQL `bytea` columns.
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import { createCustomType } from './common.js';
|
|
6
6
|
/**
|
|
7
7
|
* Custom Drizzle type for PostgreSQL `bytea` columns.
|
|
8
8
|
* Maps between `Uint8Array` in JavaScript and `bytea` in the database.
|
|
9
9
|
*/
|
|
10
|
-
export const bytea =
|
|
10
|
+
export const bytea = createCustomType({
|
|
11
11
|
dataType() {
|
|
12
12
|
return 'bytea';
|
|
13
13
|
},
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type ConvertCustomConfig, type CustomTypeParams, type CustomTypeValues, type PgCustomColumnBuilder } from 'drizzle-orm/pg-core';
|
|
2
|
+
/**
|
|
3
|
+
* A generic type for a custom Drizzle column builder function.
|
|
4
|
+
* This provides the overloads for creating a column with or without a specific database name.
|
|
5
|
+
* @template TConfig The configuration object for the custom type, containing `data` and `driverData` types.
|
|
6
|
+
*/
|
|
7
|
+
export type CustomTypeBuilder<TConfig extends Partial<CustomTypeValues>> = {
|
|
8
|
+
(): PgCustomColumnBuilder<ConvertCustomConfig<'', TConfig>>;
|
|
9
|
+
<TName extends string>(dbName: TName): PgCustomColumnBuilder<ConvertCustomConfig<TName, TConfig>>;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Factory function to create a custom Drizzle type with the standard builder overloads.
|
|
13
|
+
* This reduces boilerplate by wrapping `drizzle-orm/pg-core#customType` and applying a common type cast.
|
|
14
|
+
* @template TConfig The configuration object for the custom type.
|
|
15
|
+
* @param params The parameters for the custom type, including `dataType`, `toDriver`, and `fromDriver`.
|
|
16
|
+
* @returns A custom type builder function.
|
|
17
|
+
*/
|
|
18
|
+
export declare function createCustomType<TConfig extends CustomTypeValues>(params: CustomTypeParams<TConfig>): CustomTypeBuilder<TConfig>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { customType, } from 'drizzle-orm/pg-core';
|
|
2
|
+
/**
|
|
3
|
+
* Factory function to create a custom Drizzle type with the standard builder overloads.
|
|
4
|
+
* This reduces boilerplate by wrapping `drizzle-orm/pg-core#customType` and applying a common type cast.
|
|
5
|
+
* @template TConfig The configuration object for the custom type.
|
|
6
|
+
* @param params The parameters for the custom type, including `dataType`, `toDriver`, and `fromDriver`.
|
|
7
|
+
* @returns A custom type builder function.
|
|
8
|
+
*/
|
|
9
|
+
export function createCustomType(params) {
|
|
10
|
+
return customType(params);
|
|
11
|
+
}
|
package/orm/data-types/index.js
CHANGED
|
@@ -1,19 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module
|
|
3
|
-
* Defines a custom Drizzle type for handling PostgreSQL `date` columns
|
|
4
|
-
* using numeric representation (YYYYMMDD).
|
|
5
|
-
*/
|
|
6
|
-
import { type ConvertCustomConfig, type PgCustomColumnBuilder } from 'drizzle-orm/pg-core';
|
|
7
|
-
type Config = {
|
|
8
|
-
data: number;
|
|
9
|
-
driverData: string;
|
|
10
|
-
};
|
|
11
1
|
/**
|
|
12
2
|
* Custom Drizzle type for PostgreSQL `date` columns, storing dates as numeric values (YYYYMMDD).
|
|
13
3
|
* Converts between JavaScript `number` (YYYYMMDD) and database `date` (ISO string).
|
|
14
4
|
*/
|
|
15
|
-
export declare const numericDate: {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
export {};
|
|
5
|
+
export declare const numericDate: import("./common.js").CustomTypeBuilder<{
|
|
6
|
+
data: number;
|
|
7
|
+
driverData: string;
|
|
8
|
+
}>;
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
* Defines a custom Drizzle type for handling PostgreSQL `date` columns
|
|
4
4
|
* using numeric representation (YYYYMMDD).
|
|
5
5
|
*/
|
|
6
|
-
import { customType } from 'drizzle-orm/pg-core';
|
|
7
6
|
import { dateToNumericDate, numericDateToDateObject } from '../../utils/date-time.js';
|
|
7
|
+
import { createCustomType } from './common.js';
|
|
8
8
|
/**
|
|
9
9
|
* Custom Drizzle type for PostgreSQL `date` columns, storing dates as numeric values (YYYYMMDD).
|
|
10
10
|
* Converts between JavaScript `number` (YYYYMMDD) and database `date` (ISO string).
|
|
11
11
|
*/
|
|
12
|
-
export const numericDate =
|
|
12
|
+
export const numericDate = createCustomType({
|
|
13
13
|
dataType() {
|
|
14
14
|
return 'date';
|
|
15
15
|
},
|
|
@@ -1,19 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module
|
|
3
|
-
* Defines a custom Drizzle type for handling PostgreSQL `timestamp with time zone` columns
|
|
4
|
-
* using numeric representation (Unix timestamp in milliseconds).
|
|
5
|
-
*/
|
|
6
|
-
import { type ConvertCustomConfig, type PgCustomColumnBuilder } from 'drizzle-orm/pg-core';
|
|
7
|
-
type Config = {
|
|
8
|
-
data: number;
|
|
9
|
-
driverData: string;
|
|
10
|
-
};
|
|
11
1
|
/**
|
|
12
2
|
* Custom Drizzle type for PostgreSQL `timestamp with time zone` columns, storing timestamps as numeric values (Unix timestamp in milliseconds).
|
|
13
3
|
* Converts between JavaScript `number` (milliseconds since epoch) and database `timestamp with time zone` (ISO string).
|
|
14
4
|
*/
|
|
15
|
-
export declare const timestamp: {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
export {};
|
|
5
|
+
export declare const timestamp: import("./common.js").CustomTypeBuilder<{
|
|
6
|
+
data: number;
|
|
7
|
+
driverData: string;
|
|
8
|
+
}>;
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
* Defines a custom Drizzle type for handling PostgreSQL `timestamp with time zone` columns
|
|
4
4
|
* using numeric representation (Unix timestamp in milliseconds).
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
6
|
+
import { createCustomType } from './common.js';
|
|
7
7
|
/**
|
|
8
8
|
* Custom Drizzle type for PostgreSQL `timestamp with time zone` columns, storing timestamps as numeric values (Unix timestamp in milliseconds).
|
|
9
9
|
* Converts between JavaScript `number` (milliseconds since epoch) and database `timestamp with time zone` (ISO string).
|
|
10
10
|
*/
|
|
11
|
-
export const timestamp =
|
|
11
|
+
export const timestamp = createCustomType({
|
|
12
12
|
dataType() {
|
|
13
13
|
return 'timestamp with time zone';
|
|
14
14
|
},
|
|
@@ -1,16 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module
|
|
3
|
-
* Defines a custom Drizzle type for handling PostgreSQL `tsvector` columns.
|
|
4
|
-
*/
|
|
5
|
-
import { type ConvertCustomConfig, type PgCustomColumnBuilder } from 'drizzle-orm/pg-core';
|
|
6
|
-
type Config = {
|
|
7
|
-
data: unknown;
|
|
8
|
-
};
|
|
9
1
|
/**
|
|
10
2
|
* Custom Drizzle type for PostgreSQL `tsvector` columns.
|
|
11
3
|
*/
|
|
12
|
-
export declare const tsvector: {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
};
|
|
16
|
-
export {};
|
|
4
|
+
export declare const tsvector: import("./common.js").CustomTypeBuilder<{
|
|
5
|
+
data: unknown;
|
|
6
|
+
}>;
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* @module
|
|
3
3
|
* Defines a custom Drizzle type for handling PostgreSQL `tsvector` columns.
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import { createCustomType } from './common.js';
|
|
6
6
|
/**
|
|
7
7
|
* Custom Drizzle type for PostgreSQL `tsvector` columns.
|
|
8
8
|
*/
|
|
9
|
-
export const tsvector =
|
|
9
|
+
export const tsvector = createCustomType({
|
|
10
10
|
dataType() {
|
|
11
11
|
return 'tsvector';
|
|
12
12
|
},
|
package/orm/decorators.d.ts
CHANGED
|
@@ -3,29 +3,30 @@
|
|
|
3
3
|
* Defines decorators for ORM entities and columns, used to configure database schema mapping.
|
|
4
4
|
*/
|
|
5
5
|
import type { SQL } from 'drizzle-orm';
|
|
6
|
+
import type { ExtraConfigColumn } from 'drizzle-orm/pg-core';
|
|
6
7
|
import type { LiteralUnion } from 'type-fest';
|
|
7
8
|
import { type SpecificCreateDecoratorOptions } from '../reflection/index.js';
|
|
8
9
|
import type { AbstractConstructor, Record, TypedOmit } from '../types/index.js';
|
|
9
10
|
import type { ValueOrProvider } from '../utils/value-or-provider.js';
|
|
10
11
|
import type { AnyEntity, BaseEntity, Entity, EntityType } from './entity.js';
|
|
11
12
|
import type { Query } from './query.js';
|
|
12
|
-
import type {
|
|
13
|
-
import type {
|
|
14
|
-
type IndexMethod = LiteralUnion<'hash' | 'btree' | 'gist' | 'spgist' | 'gin' | 'brin' | 'hnsw' | 'ivfflat', string>;
|
|
13
|
+
import type { TargetColumnPath } from './repository.types.js';
|
|
14
|
+
import type { ExtraConfigColumnsFromType } from './server/types.js';
|
|
15
|
+
type IndexMethod = LiteralUnion<'hash' | 'btree' | 'gist' | 'spgist' | 'gin' | 'brin' | 'hnsw' | 'ivfflat' | 'bm25', string>;
|
|
15
16
|
type NamingStrategy = 'abbreviated-table';
|
|
16
|
-
type Column<T> =
|
|
17
|
-
type Columns<T> = [Column<T>, ...Column<T>[]];
|
|
18
|
-
export type SqlBuilder<T extends BaseEntity = any, R = SQL> = (table:
|
|
17
|
+
type Column<T extends BaseEntity> = TargetColumnPath<T>;
|
|
18
|
+
type Columns<T extends BaseEntity> = [Column<T>, ...Column<T>[]];
|
|
19
|
+
export type SqlBuilder<T extends BaseEntity = any, R = SQL> = (table: ExtraConfigColumnsFromType<EntityType<T>>) => R;
|
|
19
20
|
/**
|
|
20
21
|
* Builder function type for creating SQL check constraints.
|
|
21
22
|
* @param table The Drizzle table object.
|
|
22
23
|
*/
|
|
23
|
-
export type CheckBuilder<T extends BaseEntity =
|
|
24
|
+
export type CheckBuilder<T extends BaseEntity = BaseEntity> = SqlBuilder<T>;
|
|
24
25
|
/**
|
|
25
26
|
* Builder function type for creating partial index WHERE clauses.
|
|
26
27
|
* @param table The Drizzle table object.
|
|
27
28
|
*/
|
|
28
|
-
export type WhereBuilder<T extends BaseEntity =
|
|
29
|
+
export type WhereBuilder<T extends BaseEntity = BaseEntity> = SqlBuilder<T, Query<T>>;
|
|
29
30
|
/**
|
|
30
31
|
* Reflection data stored for ORM table decorators.
|
|
31
32
|
*/
|
|
@@ -36,7 +37,6 @@ export type OrmTableReflectionData = {
|
|
|
36
37
|
compundPrimaryKeyNaming?: NamingStrategy;
|
|
37
38
|
unique?: UniqueReflectionData[];
|
|
38
39
|
index?: IndexReflectionData[];
|
|
39
|
-
fullTextSearch?: FullTextSearchReflectionData[];
|
|
40
40
|
checks?: CheckReflectionData[];
|
|
41
41
|
foreignKeys?: ForeignKeyReflectionData[];
|
|
42
42
|
};
|
|
@@ -57,7 +57,7 @@ export type OrmColumnReflectionData = {
|
|
|
57
57
|
};
|
|
58
58
|
references?: {
|
|
59
59
|
target: () => EntityType;
|
|
60
|
-
targetColumn?:
|
|
60
|
+
targetColumn?: TargetColumnPath<any>;
|
|
61
61
|
}[];
|
|
62
62
|
encrypted?: boolean;
|
|
63
63
|
expirationField?: {
|
|
@@ -81,7 +81,7 @@ export type UniqueReflectionData = {
|
|
|
81
81
|
* @template T The entity type.
|
|
82
82
|
*/
|
|
83
83
|
export type IndexReflectionData<T extends BaseEntity = any> = {
|
|
84
|
-
columns?: (
|
|
84
|
+
columns?: ValueOrProvider<(TargetColumnPath<T> | [TargetColumnPath<T>, 'asc' | 'desc'] | SQL | ExtraConfigColumn)[], ExtraConfigColumnsFromType<EntityType<T>>>;
|
|
85
85
|
order?: 'asc' | 'desc';
|
|
86
86
|
options?: {
|
|
87
87
|
name?: string;
|
|
@@ -89,48 +89,11 @@ export type IndexReflectionData<T extends BaseEntity = any> = {
|
|
|
89
89
|
using?: IndexMethod;
|
|
90
90
|
unique?: boolean;
|
|
91
91
|
where?: WhereBuilder<T>;
|
|
92
|
+
with?: Record<string, number | string | boolean | SQL>;
|
|
93
|
+
concurrently?: boolean;
|
|
92
94
|
nulls?: 'first' | 'last';
|
|
93
95
|
};
|
|
94
96
|
};
|
|
95
|
-
export type FullTextSearchFeature = 'vector' | 'trigram';
|
|
96
|
-
export type FullTextSearchReflectionData<T extends BaseEntity = BaseEntity> = {
|
|
97
|
-
name: string;
|
|
98
|
-
/**
|
|
99
|
-
* Columns or SQL expression to use as the text source.
|
|
100
|
-
*/
|
|
101
|
-
source?: ValueOrProvider<TargetColumnPaths<T>[] | SQL<string>, PgTableFromType<EntityType<T>>>;
|
|
102
|
-
parade?: {};
|
|
103
|
-
/**
|
|
104
|
-
* Configuration for vector search (tsvector).
|
|
105
|
-
*/
|
|
106
|
-
vector?: {
|
|
107
|
-
/**
|
|
108
|
-
* Raw SQL or builder function for generating the tsvector source.
|
|
109
|
-
*/
|
|
110
|
-
rawVectorSource?: ValueOrProvider<SQL, PgTableFromType<EntityType<T>>>;
|
|
111
|
-
/**
|
|
112
|
-
* Language configuration, used for stemming, stop-words, etc.
|
|
113
|
-
* Can be a string (e.g., 'simple', 'english') or a SQL expression / builder.
|
|
114
|
-
* Not applicable if `rawVectorSource` is provided.
|
|
115
|
-
*/
|
|
116
|
-
language?: string | SQL | SqlBuilder<T>;
|
|
117
|
-
/**
|
|
118
|
-
* Weights for columns in source.
|
|
119
|
-
* Keys are column names, values are 'A', 'B', 'C', or 'D'.
|
|
120
|
-
* Not applicable if `rawVectorSource` is provided.
|
|
121
|
-
*/
|
|
122
|
-
weights?: Partial<Record<TargetColumnPaths<T>, 'A' | 'B' | 'C' | 'D'>>;
|
|
123
|
-
};
|
|
124
|
-
/**
|
|
125
|
-
* Configuration for trigram search (pg_trgm).
|
|
126
|
-
*/
|
|
127
|
-
trigram?: {
|
|
128
|
-
/**
|
|
129
|
-
* Similarity threshold between 0 and 1 for trigram matching.
|
|
130
|
-
*/
|
|
131
|
-
threshold?: number;
|
|
132
|
-
};
|
|
133
|
-
};
|
|
134
97
|
type CheckReflectionData = {
|
|
135
98
|
name: string;
|
|
136
99
|
builder: CheckBuilder;
|
|
@@ -140,8 +103,8 @@ type CheckReflectionData = {
|
|
|
140
103
|
};
|
|
141
104
|
export type ForeignKeyReflectionData = {
|
|
142
105
|
target: () => EntityType;
|
|
143
|
-
columns:
|
|
144
|
-
foreignColumns:
|
|
106
|
+
columns: TargetColumnPath<any>[];
|
|
107
|
+
foreignColumns: TargetColumnPath<any>[];
|
|
145
108
|
options?: {
|
|
146
109
|
name?: string;
|
|
147
110
|
naming?: NamingStrategy;
|
|
@@ -179,7 +142,7 @@ export declare function PrimaryKeyProperty(): PropertyDecorator;
|
|
|
179
142
|
* @param type A function returning the referenced entity type.
|
|
180
143
|
*/
|
|
181
144
|
export declare function References(target: () => EntityType): PropertyDecorator;
|
|
182
|
-
export declare function References<T extends AnyEntity>(target: () => EntityType<T>, targetColumn?:
|
|
145
|
+
export declare function References<T extends AnyEntity>(target: () => EntityType<T>, targetColumn?: TargetColumnPath<T>): PropertyDecorator;
|
|
183
146
|
/**
|
|
184
147
|
* Define a table check constraint.
|
|
185
148
|
* @template T The entity type.
|
|
@@ -247,7 +210,6 @@ export declare function Index<T extends BaseEntity = any>(options?: IndexReflect
|
|
|
247
210
|
* @param options Additional index options.
|
|
248
211
|
*/
|
|
249
212
|
export declare function Index<T extends BaseEntity = any>(columns: Columns<T>, options?: IndexReflectionData<T>['options']): ClassDecorator;
|
|
250
|
-
export declare function FullTextSearch<T extends BaseEntity>(name: string, options: TypedOmit<FullTextSearchReflectionData<T>, 'name'>): ClassDecorator;
|
|
251
213
|
/**
|
|
252
214
|
* Automatically expire records after a certain time to live (TTL) based on the createTimestamp metadata. Requires extension of {@link Entity} instead of {@link BaseEntity}.
|
|
253
215
|
* @param ttl Time To Live in milliseconds.
|