@tstdl/base 0.93.1 → 0.93.3
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/api/server/api-request-token.provider.d.ts +5 -3
- package/api/server/api-request-token.provider.js +12 -4
- package/api/server/gateway.d.ts +1 -9
- package/api/server/gateway.js +67 -36
- package/api/types.d.ts +5 -1
- package/application/application.d.ts +2 -0
- package/application/application.js +3 -1
- package/application/providers.d.ts +1 -1
- package/application/providers.js +1 -1
- package/audit/audit.model.d.ts +106 -6
- package/audit/audit.model.js +156 -13
- package/audit/auditor.d.ts +115 -30
- package/audit/auditor.js +160 -19
- package/audit/drizzle/0000_bored_stick.sql +26 -0
- package/audit/drizzle/meta/0000_snapshot.json +195 -0
- package/audit/drizzle/meta/_journal.json +13 -0
- package/audit/drizzle.config.d.ts +2 -0
- package/audit/drizzle.config.js +11 -0
- package/audit/index.d.ts +3 -1
- package/audit/index.js +3 -1
- package/audit/module.d.ts +22 -0
- package/audit/module.js +33 -0
- package/audit/schemas.d.ts +6 -0
- package/audit/schemas.js +8 -0
- package/audit/types.d.ts +2 -1
- package/audit/types.js +2 -1
- package/authentication/models/authentication-credentials.model.js +1 -2
- package/authentication/models/authentication-session.model.d.ts +2 -2
- package/authentication/models/authentication-session.model.js +3 -5
- package/authentication/models/index.d.ts +0 -1
- package/authentication/models/index.js +0 -1
- package/authentication/server/authentication-api-request-token.provider.d.ts +2 -2
- package/authentication/server/authentication-api-request-token.provider.js +8 -5
- package/authentication/server/authentication.api-controller.d.ts +8 -8
- package/authentication/server/authentication.api-controller.js +16 -16
- package/authentication/server/authentication.audit.d.ts +34 -0
- package/authentication/server/authentication.audit.js +1 -0
- package/authentication/server/authentication.service.d.ts +19 -10
- package/authentication/server/authentication.service.js +158 -43
- package/authentication/server/drizzle.config.js +1 -1
- package/authentication/server/index.d.ts +1 -0
- package/authentication/server/index.js +1 -0
- package/authentication/server/module.d.ts +1 -1
- package/authentication/{models → server}/schemas.d.ts +2 -3
- package/authentication/{models → server}/schemas.js +2 -3
- package/constants.d.ts +1 -0
- package/constants.js +1 -0
- package/document-management/api/document-management.api.d.ts +74 -74
- package/document-management/models/document-assignment-scope.model.d.ts +1 -2
- package/document-management/models/document-assignment-scope.model.js +4 -6
- package/document-management/models/document-assignment-task.model.d.ts +1 -2
- package/document-management/models/document-assignment-task.model.js +3 -5
- package/document-management/models/document-category.model.d.ts +1 -2
- package/document-management/models/document-category.model.js +3 -4
- package/document-management/models/document-collection-assignment.model.d.ts +1 -2
- package/document-management/models/document-collection-assignment.model.js +5 -7
- package/document-management/models/document-collection.model.d.ts +1 -2
- package/document-management/models/document-collection.model.js +3 -4
- package/document-management/models/document-management-table.d.ts +1 -1
- package/document-management/models/document-management-table.js +1 -1
- package/document-management/models/document-property-value.model.d.ts +1 -2
- package/document-management/models/document-property-value.model.js +5 -8
- package/document-management/models/document-property.model.d.ts +1 -2
- package/document-management/models/document-property.model.js +2 -3
- package/document-management/models/document-request-collection-assignment.model.d.ts +1 -2
- package/document-management/models/document-request-collection-assignment.model.js +4 -6
- package/document-management/models/document-request-template.d.ts +1 -2
- package/document-management/models/document-request-template.js +4 -6
- package/document-management/models/document-request.model.d.ts +1 -1
- package/document-management/models/document-request.model.js +4 -5
- package/document-management/models/document-requests-template.d.ts +1 -1
- package/document-management/models/document-requests-template.js +2 -3
- package/document-management/models/document-tag-assignment.model.d.ts +1 -2
- package/document-management/models/document-tag-assignment.model.js +4 -6
- package/document-management/models/document-tag.model.d.ts +1 -1
- package/document-management/models/document-tag.model.js +2 -3
- package/document-management/models/document-type-property.model.d.ts +1 -2
- package/document-management/models/document-type-property.model.js +4 -6
- package/document-management/models/document-type-validation.model.d.ts +1 -2
- package/document-management/models/document-type-validation.model.js +4 -6
- package/document-management/models/document-type.model.d.ts +1 -2
- package/document-management/models/document-type.model.js +3 -5
- package/document-management/models/document-validation-definition.model.d.ts +1 -2
- package/document-management/models/document-validation-definition.model.js +3 -4
- package/document-management/models/document-validation-execution-related-document.model.d.ts +1 -2
- package/document-management/models/document-validation-execution-related-document.model.js +4 -6
- package/document-management/models/document-validation-execution.model.d.ts +1 -2
- package/document-management/models/document-validation-execution.model.js +6 -8
- package/document-management/models/document-workflow.model.d.ts +1 -2
- package/document-management/models/document-workflow.model.js +5 -7
- package/document-management/models/document.model.d.ts +1 -2
- package/document-management/models/document.model.js +5 -7
- package/document-management/server/api/document-management.api.js +1 -1
- package/document-management/server/module.d.ts +1 -1
- package/document-management/server/module.js +1 -1
- package/document-management/server/schemas.d.ts +1 -1
- package/document-management/server/schemas.js +1 -1
- package/document-management/server/services/document-category-type.service.d.ts +2 -2
- package/document-management/server/services/document-category-type.service.js +1 -2
- package/document-management/server/services/document-collection.service.d.ts +1 -1
- package/document-management/server/services/document-collection.service.js +1 -2
- package/document-management/server/services/document-management.service.js +6 -6
- package/document-management/server/services/document-property.service.d.ts +1 -1
- package/document-management/server/services/document-property.service.js +1 -2
- package/document-management/server/services/document-validation.service.js +2 -2
- package/document-management/server/services/document-workflow.service.d.ts +2 -2
- package/document-management/server/services/document-workflow.service.js +1 -2
- package/document-management/server/services/document.service.d.ts +1 -1
- package/document-management/server/services/document.service.js +1 -2
- package/document-management/server/services/singleton.js +1 -1
- package/document-management/service-models/document.service-model.d.ts +62 -62
- package/document-management/service-models/document.service-model.js +1 -1
- package/document-management/service-models/enriched/enriched-document-management-data.view.js +1 -1
- package/document-management/service-models/enriched/enriched-document.view.d.ts +1 -1
- package/examples/api/authentication.js +2 -2
- package/examples/api/basic-overview.js +2 -2
- package/examples/api/custom-authentication.js +2 -2
- package/examples/api/streaming.js +2 -2
- package/examples/browser/basic.js +2 -2
- package/examples/document-management/main.js +2 -2
- package/examples/http/client.js +2 -2
- package/examples/mail/basic.js +2 -2
- package/examples/pdf/basic.js +2 -2
- package/examples/template/basic.js +2 -2
- package/http/server/http-server-request.d.ts +3 -3
- package/key-value-store/postgres/key-value-store.service.js +1 -2
- package/key-value-store/postgres/models/key-value.model.d.ts +1 -2
- package/key-value-store/postgres/models/key-value.model.js +2 -4
- package/key-value-store/postgres/models/schemas.d.ts +1 -1
- package/key-value-store/postgres/models/schemas.js +1 -1
- package/lock/postgres/lock.js +1 -1
- package/lock/postgres/models/lock.model.d.ts +1 -2
- package/lock/postgres/models/lock.model.js +3 -5
- package/lock/postgres/models/schemas.d.ts +1 -1
- package/lock/postgres/models/schemas.js +1 -1
- package/lock/postgres/provider.js +1 -2
- package/mail/models/mail-log.model.d.ts +1 -1
- package/mail/models/mail-log.model.js +4 -5
- package/mail/models/schemas.d.ts +1 -1
- package/mail/models/schemas.js +1 -1
- package/openid-connect/oidc-state.model.d.ts +1 -1
- package/openid-connect/oidc-state.model.js +2 -3
- package/openid-connect/oidc.service.js +1 -1
- package/orm/data-types/bytea.js +1 -1
- package/orm/data-types/numeric-date.js +1 -1
- package/orm/decorators.d.ts +65 -72
- package/orm/decorators.js +42 -40
- package/orm/entity.d.ts +7 -1
- package/orm/entity.js +25 -11
- package/orm/index.d.ts +2 -1
- package/orm/index.js +2 -1
- package/orm/schemas/json.d.ts +1 -1
- package/orm/schemas/json.js +1 -1
- package/orm/schemas/numeric-date.d.ts +1 -1
- package/orm/schemas/numeric-date.js +1 -1
- package/orm/schemas/timestamp.d.ts +1 -1
- package/orm/schemas/timestamp.js +1 -1
- package/orm/schemas/uuid.d.ts +2 -2
- package/orm/schemas/uuid.js +1 -1
- package/orm/server/drizzle/schema-converter.ts +408 -0
- package/orm/server/repository.d.ts +1 -1
- package/orm/server/repository.js +12 -9
- package/orm/sqls.d.ts +1 -1
- package/orm/sqls.js +1 -1
- package/orm/types.d.ts +2 -6
- package/orm/types.js +1 -4
- package/package.json +15 -24
- package/queue/postgres/job.model.d.ts +3 -3
- package/queue/postgres/job.model.js +5 -6
- package/queue/postgres/queue.js +2 -2
- package/queue/postgres/schemas.d.ts +1 -1
- package/queue/postgres/schemas.js +1 -1
- package/supports.d.ts +1 -0
- package/supports.js +2 -1
- package/types/types.d.ts +12 -1
- package/utils/object/object.d.ts +3 -1
- package/utils/object/object.js +7 -1
- package/orm/server/drizzle/index.js +0 -1
- package/orm/server/drizzle/schema-converter.d.ts +0 -15
- package/orm/server/drizzle/schema-converter.js +0 -300
- /package/orm/server/drizzle/{index.d.ts → index.ts} +0 -0
|
@@ -7,9 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
|
-
import {
|
|
11
|
-
import { EntityWithoutMetadata } from '../../../orm/entity.js';
|
|
12
|
-
import { Timestamp, Unique } from '../../../orm/types.js';
|
|
10
|
+
import { EntityWithoutMetadata, Expires, Table, TimestampProperty, Unique } from '../../../orm/index.js';
|
|
13
11
|
import { StringProperty } from '../../../schema/index.js';
|
|
14
12
|
let PostgresLock = class PostgresLock extends EntityWithoutMetadata {
|
|
15
13
|
resource;
|
|
@@ -26,8 +24,8 @@ __decorate([
|
|
|
26
24
|
__metadata("design:type", String)
|
|
27
25
|
], PostgresLock.prototype, "key", void 0);
|
|
28
26
|
__decorate([
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
Expires(),
|
|
28
|
+
TimestampProperty(),
|
|
31
29
|
__metadata("design:type", Number)
|
|
32
30
|
], PostgresLock.prototype, "expiration", void 0);
|
|
33
31
|
PostgresLock = __decorate([
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { PostgresLock } from './lock.model.js';
|
|
2
|
-
export declare const lockSchema: import("../../../orm/server/
|
|
2
|
+
export declare const lockSchema: import("../../../orm/server/index.js").DatabaseSchema<"lock">;
|
|
3
3
|
export declare const lock: import("../../../orm/server/types.js").PgTableFromType<typeof PostgresLock, "lock">;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { databaseSchema } from '../../../orm/server/
|
|
1
|
+
import { databaseSchema } from '../../../orm/server/index.js';
|
|
2
2
|
import { PostgresLock } from './lock.model.js';
|
|
3
3
|
export const lockSchema = databaseSchema('lock');
|
|
4
4
|
export const lock = lockSchema.getTable(PostgresLock);
|
|
@@ -5,8 +5,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
7
|
import { Singleton, provide } from '../../injector/index.js';
|
|
8
|
-
import { DatabaseConfig } from '../../orm/server/index.js';
|
|
9
|
-
import { EntityRepositoryConfig, injectRepository } from '../../orm/server/repository.js';
|
|
8
|
+
import { DatabaseConfig, EntityRepositoryConfig, injectRepository } from '../../orm/server/index.js';
|
|
10
9
|
import { LockProvider } from '../provider.js';
|
|
11
10
|
import { PostgresLockAdapter } from './lock.js';
|
|
12
11
|
import { PostgresLock } from './models/lock.model.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Entity, Json, Timestamp } from '../../orm/index.js';
|
|
1
|
+
import { Entity, type Json, type Timestamp } from '../../orm/index.js';
|
|
2
2
|
import type { MailData } from './mail-data.model.js';
|
|
3
3
|
import type { MailSendResult } from './mail-send-result.model.js';
|
|
4
4
|
export declare class MailLog extends Entity {
|
|
@@ -7,8 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
|
-
import { Table } from '../../orm/
|
|
11
|
-
import { Entity, Json, Timestamp } from '../../orm/index.js';
|
|
10
|
+
import { Entity, JsonProperty, Table, TimestampProperty } from '../../orm/index.js';
|
|
12
11
|
import { StringProperty } from '../../schema/index.js';
|
|
13
12
|
let MailLog = class MailLog extends Entity {
|
|
14
13
|
timestamp;
|
|
@@ -18,7 +17,7 @@ let MailLog = class MailLog extends Entity {
|
|
|
18
17
|
errors;
|
|
19
18
|
};
|
|
20
19
|
__decorate([
|
|
21
|
-
|
|
20
|
+
TimestampProperty(),
|
|
22
21
|
__metadata("design:type", Number)
|
|
23
22
|
], MailLog.prototype, "timestamp", void 0);
|
|
24
23
|
__decorate([
|
|
@@ -26,11 +25,11 @@ __decorate([
|
|
|
26
25
|
__metadata("design:type", Object)
|
|
27
26
|
], MailLog.prototype, "template", void 0);
|
|
28
27
|
__decorate([
|
|
29
|
-
|
|
28
|
+
JsonProperty(),
|
|
30
29
|
__metadata("design:type", Object)
|
|
31
30
|
], MailLog.prototype, "data", void 0);
|
|
32
31
|
__decorate([
|
|
33
|
-
|
|
32
|
+
JsonProperty({ nullable: true }),
|
|
34
33
|
__metadata("design:type", Object)
|
|
35
34
|
], MailLog.prototype, "sendResult", void 0);
|
|
36
35
|
__decorate([
|
package/mail/models/schemas.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { MailLog } from './mail-log.model.js';
|
|
2
|
-
export declare const mailSchema: import("../../orm/server/
|
|
2
|
+
export declare const mailSchema: import("../../orm/server/index.js").DatabaseSchema<"mail">;
|
|
3
3
|
export declare const mailLog: import("../../orm/server/types.js").PgTableFromType<typeof MailLog, "mail">;
|
package/mail/models/schemas.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { databaseSchema } from '../../orm/server/
|
|
1
|
+
import { databaseSchema } from '../../orm/server/index.js';
|
|
2
2
|
import { MailLog } from './mail-log.model.js';
|
|
3
3
|
export const mailSchema = databaseSchema('mail');
|
|
4
4
|
export const mailLog = mailSchema.getTable(MailLog);
|
|
@@ -7,8 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
|
-
import {
|
|
11
|
-
import { EntityWithoutMetadata, Json, Unique } from '../orm/index.js';
|
|
10
|
+
import { EntityWithoutMetadata, Expires, JsonProperty, Unique } from '../orm/index.js';
|
|
12
11
|
import { any, NumberProperty, StringProperty } from '../schema/index.js';
|
|
13
12
|
export class OidcState extends EntityWithoutMetadata {
|
|
14
13
|
value;
|
|
@@ -46,6 +45,6 @@ __decorate([
|
|
|
46
45
|
__metadata("design:type", Number)
|
|
47
46
|
], OidcState.prototype, "expiration", void 0);
|
|
48
47
|
__decorate([
|
|
49
|
-
|
|
48
|
+
JsonProperty({ schema: any() }),
|
|
50
49
|
__metadata("design:type", Object)
|
|
51
50
|
], OidcState.prototype, "data", void 0);
|
|
@@ -9,7 +9,7 @@ import { NotImplementedError } from '../errors/not-implemented.error.js';
|
|
|
9
9
|
import { HttpClient } from '../http/client/index.js';
|
|
10
10
|
import { HttpHeaders } from '../http/http-headers.js';
|
|
11
11
|
import { inject, Singleton } from '../injector/index.js';
|
|
12
|
-
import { injectRepository } from '../orm/server/
|
|
12
|
+
import { injectRepository } from '../orm/server/index.js';
|
|
13
13
|
import { object, optional, Schema, string } from '../schema/index.js';
|
|
14
14
|
import { Alphabet } from '../utils/alphabet.js';
|
|
15
15
|
import { digest } from '../utils/cryptography.js';
|
package/orm/data-types/bytea.js
CHANGED
package/orm/decorators.d.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { SQL } from 'drizzle-orm';
|
|
6
6
|
import type { LiteralUnion } from 'type-fest';
|
|
7
|
+
import { type SpecificCreateDecoratorOptions } from '../reflection/index.js';
|
|
7
8
|
import type { AbstractConstructor, TypedOmit } from '../types/index.js';
|
|
8
9
|
import type { AnyEntity, Entity, EntityType, EntityWithoutMetadata } from './entity.js';
|
|
9
10
|
import type { Query } from './query.js';
|
|
@@ -14,14 +15,12 @@ type NamingStrategy = 'abbreviated-table';
|
|
|
14
15
|
type Columns<T> = [Extract<keyof T, string>, ...Extract<keyof T, string>[]];
|
|
15
16
|
/**
|
|
16
17
|
* Builder function type for creating SQL check constraints.
|
|
17
|
-
* @param table
|
|
18
|
-
* @returns The SQL check constraint expression.
|
|
18
|
+
* @param table The Drizzle table object.
|
|
19
19
|
*/
|
|
20
20
|
export type CheckBuilder<T extends Entity = any> = (table: PgTableFromType<EntityType<T>>) => SQL;
|
|
21
21
|
/**
|
|
22
22
|
* Builder function type for creating partial index WHERE clauses.
|
|
23
|
-
* @param table
|
|
24
|
-
* @returns The query object representing the WHERE clause.
|
|
23
|
+
* @param table The Drizzle table object.
|
|
25
24
|
*/
|
|
26
25
|
export type WhereBuilder<T extends Entity | EntityWithoutMetadata = any> = (table: PgTableFromType<EntityType<T>>) => Query<T>;
|
|
27
26
|
/**
|
|
@@ -58,6 +57,7 @@ export type OrmColumnReflectionData = {
|
|
|
58
57
|
}[];
|
|
59
58
|
encrypted?: boolean;
|
|
60
59
|
expirationField?: {
|
|
60
|
+
after: number;
|
|
61
61
|
mode: 'soft' | 'hard';
|
|
62
62
|
};
|
|
63
63
|
};
|
|
@@ -74,7 +74,7 @@ export type UniqueReflectionData = {
|
|
|
74
74
|
};
|
|
75
75
|
/**
|
|
76
76
|
* Reflection data for index definitions.
|
|
77
|
-
* @template T
|
|
77
|
+
* @template T The entity type.
|
|
78
78
|
*/
|
|
79
79
|
export type IndexReflectionData<T extends Entity | EntityWithoutMetadata = any> = {
|
|
80
80
|
columns?: (string | [string, 'asc' | 'desc'])[];
|
|
@@ -107,123 +107,116 @@ export type ForeignKeyReflectionData = {
|
|
|
107
107
|
/**
|
|
108
108
|
* Factory function to create a class decorator for ORM table configuration.
|
|
109
109
|
* Merges provided data with existing ORM reflection data on the class metadata.
|
|
110
|
-
* @param data
|
|
111
|
-
* @returns A class decorator.
|
|
110
|
+
* @param data The ORM table reflection data to add.
|
|
112
111
|
*/
|
|
113
112
|
export declare function createTableDecorator(data?: OrmTableReflectionData): ClassDecorator;
|
|
114
113
|
/**
|
|
115
114
|
* Factory function to create a property decorator for ORM column configuration.
|
|
116
115
|
* Merges provided data with existing ORM reflection data on the property metadata.
|
|
117
|
-
* @param data
|
|
118
|
-
* @returns A property decorator.
|
|
116
|
+
* @param data The ORM column reflection data to add.
|
|
119
117
|
*/
|
|
120
|
-
export declare function createColumnDecorator(data?: OrmColumnReflectionData): PropertyDecorator;
|
|
118
|
+
export declare function createColumnDecorator(data?: OrmColumnReflectionData, decoratorOptions?: TypedOmit<SpecificCreateDecoratorOptions<'property'>, 'handler'>): PropertyDecorator;
|
|
121
119
|
/**
|
|
122
120
|
* Factory function to create a decorator applicable to both classes and properties for ORM configuration.
|
|
123
121
|
* Merges provided data with existing ORM reflection data on the target's metadata.
|
|
124
|
-
* @param data
|
|
125
|
-
* @returns A class or property decorator.
|
|
122
|
+
* @param data The ORM reflection data to add.
|
|
126
123
|
*/
|
|
127
124
|
export declare function createTableAndColumnDecorator(data?: OrmColumnReflectionData): PropertyDecorator & ClassDecorator;
|
|
128
125
|
/**
|
|
129
|
-
*
|
|
130
|
-
* @param options
|
|
131
|
-
* @returns A property decorator.
|
|
126
|
+
* Specify ORM column options.
|
|
127
|
+
* @param options Column configuration options.
|
|
132
128
|
*/
|
|
133
129
|
export declare function Column(options: OrmColumnReflectionData): PropertyDecorator;
|
|
134
130
|
/**
|
|
135
|
-
*
|
|
136
|
-
* @returns A property decorator.
|
|
131
|
+
* Mark a property as the primary key column.
|
|
137
132
|
*/
|
|
138
|
-
export declare function
|
|
133
|
+
export declare function PrimaryKeyProperty(): PropertyDecorator;
|
|
139
134
|
/**
|
|
140
|
-
*
|
|
141
|
-
* @param type
|
|
142
|
-
* @returns A property decorator.
|
|
135
|
+
* Define a foreign key relationship.
|
|
136
|
+
* @param type A function returning the referenced entity type.
|
|
143
137
|
*/
|
|
144
138
|
export declare function References(target: () => EntityType): PropertyDecorator;
|
|
145
139
|
export declare function References<T extends AnyEntity>(target: () => EntityType<T>, targetColumn?: TargetColumnPaths<T>): PropertyDecorator;
|
|
146
140
|
/**
|
|
147
|
-
*
|
|
148
|
-
* @template T
|
|
149
|
-
* @param name
|
|
150
|
-
* @param builder
|
|
151
|
-
* @returns A class decorator.
|
|
141
|
+
* Define a table check constraint.
|
|
142
|
+
* @template T The entity type.
|
|
143
|
+
* @param name The name of the check constraint.
|
|
144
|
+
* @param builder A function to build the SQL check expression.
|
|
152
145
|
*/
|
|
153
146
|
export declare function Check<T extends Entity>(name: string, builder: CheckBuilder<T>): ClassDecorator;
|
|
154
147
|
/**
|
|
155
|
-
*
|
|
148
|
+
* Mark a column for encryption.
|
|
156
149
|
* The underlying database type will typically be `bytea`.
|
|
157
|
-
* @returns A property decorator.
|
|
158
150
|
*/
|
|
159
|
-
export declare function
|
|
151
|
+
export declare function EncryptedProperty(): PropertyDecorator;
|
|
160
152
|
/**
|
|
161
|
-
*
|
|
162
|
-
* @param type
|
|
163
|
-
* @param options
|
|
164
|
-
* @returns A property decorator.
|
|
153
|
+
* Embed another class's properties into the current entity's table.
|
|
154
|
+
* @param type The constructor of the class to embed.
|
|
155
|
+
* @param options Embedding options, like prefixing column names.
|
|
165
156
|
*/
|
|
166
|
-
export declare function
|
|
157
|
+
export declare function EmbeddedProperty(type: AbstractConstructor, options?: TypedOmit<NonNullable<OrmColumnReflectionData['embedded']>, 'type'>): PropertyDecorator;
|
|
167
158
|
export type TableOptions = Partial<Pick<OrmTableReflectionData, 'name' | 'schema'>>;
|
|
168
159
|
/**
|
|
169
|
-
*
|
|
170
|
-
* @param name
|
|
171
|
-
* @param options
|
|
172
|
-
* @returns A class decorator.
|
|
160
|
+
* Specify the database table name and optionally the schema.
|
|
161
|
+
* @param name The table name.
|
|
162
|
+
* @param options Additional table options (currently only schema).
|
|
173
163
|
*/
|
|
174
164
|
export declare function Table(name?: string, options?: TypedOmit<TableOptions, 'schema'>): ClassDecorator;
|
|
175
165
|
/**
|
|
176
|
-
*
|
|
177
|
-
* @param options
|
|
178
|
-
* @returns A class decorator.
|
|
166
|
+
* Specify database table options like name and schema.
|
|
167
|
+
* @param options Table options including name and schema.
|
|
179
168
|
*/
|
|
180
169
|
export declare function Table(options?: TableOptions): ClassDecorator;
|
|
181
170
|
/**
|
|
182
|
-
*
|
|
183
|
-
* @param target
|
|
184
|
-
* @param columns
|
|
185
|
-
* @param foreignColumns
|
|
186
|
-
* @param options
|
|
187
|
-
* @template TThis
|
|
188
|
-
* @template TTarget
|
|
189
|
-
* @returns A property decorator.
|
|
171
|
+
* Define a foreign key relationship.
|
|
172
|
+
* @param target A function returning the referenced entity type.
|
|
173
|
+
* @param columns The columns in the current entity that form the foreign key.
|
|
174
|
+
* @param foreignColumns The columns in the referenced entity that the foreign key points to.
|
|
175
|
+
* @param options Additional foreign key options (e.g., name, naming strategy).
|
|
176
|
+
* @template TThis The entity type of the current entity.
|
|
177
|
+
* @template TTarget The entity type of the referenced entity.
|
|
190
178
|
*/
|
|
191
179
|
export declare function ForeignKey<TThis extends AnyEntity, TTarget extends AnyEntity>(target: () => EntityType<TTarget>, columns: Columns<TThis>, foreignColumns: Columns<TTarget>, options?: ForeignKeyReflectionData['options']): ClassDecorator;
|
|
192
180
|
/**
|
|
193
|
-
*
|
|
194
|
-
* @param name
|
|
195
|
-
* @param options
|
|
196
|
-
* @returns A property decorator.
|
|
181
|
+
* Define a unique constraint on a single column.
|
|
182
|
+
* @param name Optional name for the unique constraint.
|
|
183
|
+
* @param options Additional unique constraint options.
|
|
197
184
|
*/
|
|
198
185
|
export declare function Unique(options?: UniqueReflectionData['options']): PropertyDecorator;
|
|
199
186
|
/**
|
|
200
|
-
*
|
|
201
|
-
* @template T
|
|
202
|
-
* @param columns
|
|
203
|
-
* @param options
|
|
204
|
-
* @returns A class decorator.
|
|
187
|
+
* Define a composite unique constraint on multiple columns.
|
|
188
|
+
* @template T The entity type.
|
|
189
|
+
* @param columns An array of property names included in the constraint.
|
|
190
|
+
* @param options Additional unique constraint options.
|
|
205
191
|
*/
|
|
206
192
|
export declare function Unique<T extends AnyEntity>(columns: Columns<T>, options?: UniqueReflectionData['options']): ClassDecorator;
|
|
207
193
|
/**
|
|
208
|
-
*
|
|
209
|
-
* @template T
|
|
210
|
-
* @param name
|
|
211
|
-
* @param options
|
|
212
|
-
* @returns A property decorator.
|
|
194
|
+
* Define an index on a single column.
|
|
195
|
+
* @template T The entity type.
|
|
196
|
+
* @param name Optional name for the index.
|
|
197
|
+
* @param options Additional index options (e.g., method, uniqueness, conditions).
|
|
213
198
|
*/
|
|
214
199
|
export declare function Index<T extends Entity | EntityWithoutMetadata = any>(options?: IndexReflectionData<T>['options']): PropertyDecorator;
|
|
215
200
|
/**
|
|
216
|
-
*
|
|
217
|
-
* @template T
|
|
218
|
-
* @param columns
|
|
219
|
-
* @param options
|
|
220
|
-
* @returns A class decorator.
|
|
201
|
+
* Define a composite index on multiple columns.
|
|
202
|
+
* @template T The entity type.
|
|
203
|
+
* @param columns An array of property names (or tuples with direction) included in the index.
|
|
204
|
+
* @param options Additional index options.
|
|
221
205
|
*/
|
|
222
206
|
export declare function Index<T extends Entity | EntityWithoutMetadata = any>(columns: Columns<T>, options?: IndexReflectionData<T>['options']): ClassDecorator;
|
|
223
207
|
/**
|
|
224
|
-
*
|
|
225
|
-
* @param
|
|
226
|
-
* @
|
|
208
|
+
* Automatically expire records after a certain time to live (TTL) based on the createTimestamp metadata. Requires extension of {@link Entity} instead of {@link EntityWithoutMetadata}.
|
|
209
|
+
* @param ttl Time To Live in milliseconds.
|
|
210
|
+
* @param mode Whether to delete soft or hard.
|
|
227
211
|
*/
|
|
228
|
-
export declare function
|
|
212
|
+
export declare function TimeToLive(ttl: number, mode: 'soft' | 'hard'): ClassDecorator;
|
|
213
|
+
/**
|
|
214
|
+
* Mark a column as an expiration field, automatically deleting records after the specified duration after the column value.
|
|
215
|
+
* @param options.after Time in milliseconds after which the record expires.
|
|
216
|
+
* @param options.mode Whether to delete soft or hard.
|
|
217
|
+
*/
|
|
218
|
+
export declare function Expires(options?: {
|
|
219
|
+
after?: number;
|
|
220
|
+
mode?: 'soft' | 'hard';
|
|
221
|
+
}): PropertyDecorator;
|
|
229
222
|
export {};
|
package/orm/decorators.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { createClassDecorator, createDecorator, createPropertyDecorator } from '../reflection/index.js';
|
|
2
2
|
import { Property } from '../schema/index.js';
|
|
3
|
-
import { filterUndefinedObjectProperties, objectEntries } from '../utils/object/
|
|
3
|
+
import { filterUndefinedObjectProperties, objectEntries, propertyNameOf } from '../utils/object/index.js';
|
|
4
4
|
import { isArray, isString, isUndefined } from '../utils/type-guards.js';
|
|
5
5
|
/**
|
|
6
6
|
* Factory function to create a class decorator for ORM table configuration.
|
|
7
7
|
* Merges provided data with existing ORM reflection data on the class metadata.
|
|
8
|
-
* @param data
|
|
9
|
-
* @returns A class decorator.
|
|
8
|
+
* @param data The ORM table reflection data to add.
|
|
10
9
|
*/
|
|
11
10
|
export function createTableDecorator(data = {}) {
|
|
12
11
|
return createClassDecorator({
|
|
@@ -32,10 +31,9 @@ export function createTableDecorator(data = {}) {
|
|
|
32
31
|
/**
|
|
33
32
|
* Factory function to create a property decorator for ORM column configuration.
|
|
34
33
|
* Merges provided data with existing ORM reflection data on the property metadata.
|
|
35
|
-
* @param data
|
|
36
|
-
* @returns A property decorator.
|
|
34
|
+
* @param data The ORM column reflection data to add.
|
|
37
35
|
*/
|
|
38
|
-
export function createColumnDecorator(data = {}) {
|
|
36
|
+
export function createColumnDecorator(data = {}, decoratorOptions) {
|
|
39
37
|
return createPropertyDecorator({
|
|
40
38
|
handler: (_, metadata) => {
|
|
41
39
|
const reflectionData = metadata.data.tryGet('orm') ?? {};
|
|
@@ -54,60 +52,55 @@ export function createColumnDecorator(data = {}) {
|
|
|
54
52
|
}
|
|
55
53
|
metadata.data.set('orm', reflectionData, true);
|
|
56
54
|
},
|
|
55
|
+
...decoratorOptions,
|
|
57
56
|
});
|
|
58
57
|
}
|
|
59
58
|
/**
|
|
60
59
|
* Factory function to create a decorator applicable to both classes and properties for ORM configuration.
|
|
61
60
|
* Merges provided data with existing ORM reflection data on the target's metadata.
|
|
62
|
-
* @param data
|
|
63
|
-
* @returns A class or property decorator.
|
|
61
|
+
* @param data The ORM reflection data to add.
|
|
64
62
|
*/
|
|
65
63
|
export function createTableAndColumnDecorator(data) {
|
|
66
64
|
return createDecorator({ class: true, property: true, data: { orm: data }, mergeData: true });
|
|
67
65
|
}
|
|
68
66
|
/**
|
|
69
|
-
*
|
|
70
|
-
* @param options
|
|
71
|
-
* @returns A property decorator.
|
|
67
|
+
* Specify ORM column options.
|
|
68
|
+
* @param options Column configuration options.
|
|
72
69
|
*/
|
|
73
70
|
export function Column(options) {
|
|
74
71
|
return createColumnDecorator({ ...options });
|
|
75
72
|
}
|
|
76
73
|
/**
|
|
77
|
-
*
|
|
78
|
-
* @returns A property decorator.
|
|
74
|
+
* Mark a property as the primary key column.
|
|
79
75
|
*/
|
|
80
|
-
export function
|
|
76
|
+
export function PrimaryKeyProperty() {
|
|
81
77
|
return createColumnDecorator({ primaryKey: true });
|
|
82
78
|
}
|
|
83
79
|
export function References(target, targetColumn) {
|
|
84
80
|
return createColumnDecorator({ references: [{ target, targetColumn }] });
|
|
85
81
|
}
|
|
86
82
|
/**
|
|
87
|
-
*
|
|
88
|
-
* @template T
|
|
89
|
-
* @param name
|
|
90
|
-
* @param builder
|
|
91
|
-
* @returns A class decorator.
|
|
83
|
+
* Define a table check constraint.
|
|
84
|
+
* @template T The entity type.
|
|
85
|
+
* @param name The name of the check constraint.
|
|
86
|
+
* @param builder A function to build the SQL check expression.
|
|
92
87
|
*/
|
|
93
88
|
export function Check(name, builder) {
|
|
94
89
|
return createTableDecorator({ checks: [{ name, builder }] });
|
|
95
90
|
}
|
|
96
91
|
/**
|
|
97
|
-
*
|
|
92
|
+
* Mark a column for encryption.
|
|
98
93
|
* The underlying database type will typically be `bytea`.
|
|
99
|
-
* @returns A property decorator.
|
|
100
94
|
*/
|
|
101
|
-
export function
|
|
95
|
+
export function EncryptedProperty() {
|
|
102
96
|
return createColumnDecorator({ encrypted: true });
|
|
103
97
|
}
|
|
104
98
|
/**
|
|
105
|
-
*
|
|
106
|
-
* @param type
|
|
107
|
-
* @param options
|
|
108
|
-
* @returns A property decorator.
|
|
99
|
+
* Embed another class's properties into the current entity's table.
|
|
100
|
+
* @param type The constructor of the class to embed.
|
|
101
|
+
* @param options Embedding options, like prefixing column names.
|
|
109
102
|
*/
|
|
110
|
-
export function
|
|
103
|
+
export function EmbeddedProperty(type, options) {
|
|
111
104
|
return createPropertyDecorator({
|
|
112
105
|
include: [Property(type), createColumnDecorator({ embedded: { type, ...options } })],
|
|
113
106
|
});
|
|
@@ -121,14 +114,13 @@ export function Table(nameOrOptions, optionsOrNothing) {
|
|
|
121
114
|
return createTableDecorator(data);
|
|
122
115
|
}
|
|
123
116
|
/**
|
|
124
|
-
*
|
|
125
|
-
* @param target
|
|
126
|
-
* @param columns
|
|
127
|
-
* @param foreignColumns
|
|
128
|
-
* @param options
|
|
129
|
-
* @template TThis
|
|
130
|
-
* @template TTarget
|
|
131
|
-
* @returns A property decorator.
|
|
117
|
+
* Define a foreign key relationship.
|
|
118
|
+
* @param target A function returning the referenced entity type.
|
|
119
|
+
* @param columns The columns in the current entity that form the foreign key.
|
|
120
|
+
* @param foreignColumns The columns in the referenced entity that the foreign key points to.
|
|
121
|
+
* @param options Additional foreign key options (e.g., name, naming strategy).
|
|
122
|
+
* @template TThis The entity type of the current entity.
|
|
123
|
+
* @template TTarget The entity type of the referenced entity.
|
|
132
124
|
*/
|
|
133
125
|
export function ForeignKey(target, columns, foreignColumns, options) {
|
|
134
126
|
return createTableDecorator({ foreignKeys: [{ target, columns, foreignColumns, options }] });
|
|
@@ -146,10 +138,20 @@ export function Index(columnsOrOptions, options) {
|
|
|
146
138
|
return createColumnDecorator({ index: { options: columnsOrOptions } });
|
|
147
139
|
}
|
|
148
140
|
/**
|
|
149
|
-
*
|
|
150
|
-
* @param
|
|
151
|
-
* @
|
|
141
|
+
* Automatically expire records after a certain time to live (TTL) based on the createTimestamp metadata. Requires extension of {@link Entity} instead of {@link EntityWithoutMetadata}.
|
|
142
|
+
* @param ttl Time To Live in milliseconds.
|
|
143
|
+
* @param mode Whether to delete soft or hard.
|
|
152
144
|
*/
|
|
153
|
-
export function
|
|
154
|
-
return
|
|
145
|
+
export function TimeToLive(ttl, mode) {
|
|
146
|
+
return createClassDecorator({
|
|
147
|
+
handler: (data) => Expires({ after: ttl, mode })(data.prototype, propertyNameOf((entity) => entity.metadata.createTimestamp)),
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Mark a column as an expiration field, automatically deleting records after the specified duration after the column value.
|
|
152
|
+
* @param options.after Time in milliseconds after which the record expires.
|
|
153
|
+
* @param options.mode Whether to delete soft or hard.
|
|
154
|
+
*/
|
|
155
|
+
export function Expires(options) {
|
|
156
|
+
return createColumnDecorator({ expirationField: { after: options?.after ?? 0, mode: options?.mode ?? 'soft' } });
|
|
155
157
|
}
|
package/orm/entity.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Type } from '../types/index.js';
|
|
2
|
-
import { Embedded,
|
|
2
|
+
import type { Embedded, HasDefault, IsPrimaryKey, Json, Timestamp, Uuid } from './types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Represents the type (constructor) of an entity, potentially holding an entity name.
|
|
5
5
|
* @template T - The entity class type.
|
|
@@ -40,3 +40,9 @@ export declare abstract class Entity {
|
|
|
40
40
|
export declare abstract class EntityWithoutMetadata {
|
|
41
41
|
id: IsPrimaryKey<HasDefault<Uuid>>;
|
|
42
42
|
}
|
|
43
|
+
export declare abstract class TenantEntity extends Entity {
|
|
44
|
+
tenantId: Uuid;
|
|
45
|
+
}
|
|
46
|
+
export declare abstract class TenantEntityWithoutMetadata extends EntityWithoutMetadata {
|
|
47
|
+
tenantId: Uuid;
|
|
48
|
+
}
|
package/orm/entity.js
CHANGED
|
@@ -12,8 +12,8 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
12
12
|
* Defines base entity classes and related types for the ORM.
|
|
13
13
|
*/
|
|
14
14
|
import { Defaulted, Integer } from '../schema/index.js';
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
15
|
+
import { EmbeddedProperty, PrimaryKeyProperty } from './decorators.js';
|
|
16
|
+
import { JsonProperty, TimestampProperty, UuidProperty } from './schemas/index.js';
|
|
17
17
|
/**
|
|
18
18
|
* Base class for extensible metadata attributes associated with an entity.
|
|
19
19
|
* Allows storing arbitrary key-value pairs.
|
|
@@ -21,7 +21,7 @@ import { Embedded, Json, Timestamp, Uuid } from './types.js';
|
|
|
21
21
|
let EntityMetadataAttributes = class EntityMetadataAttributes {
|
|
22
22
|
};
|
|
23
23
|
EntityMetadataAttributes = __decorate([
|
|
24
|
-
|
|
24
|
+
JsonProperty()
|
|
25
25
|
], EntityMetadataAttributes);
|
|
26
26
|
export { EntityMetadataAttributes };
|
|
27
27
|
/**
|
|
@@ -39,15 +39,15 @@ __decorate([
|
|
|
39
39
|
__metadata("design:type", Number)
|
|
40
40
|
], EntityMetadata.prototype, "revision", void 0);
|
|
41
41
|
__decorate([
|
|
42
|
-
|
|
42
|
+
TimestampProperty(),
|
|
43
43
|
__metadata("design:type", Number)
|
|
44
44
|
], EntityMetadata.prototype, "revisionTimestamp", void 0);
|
|
45
45
|
__decorate([
|
|
46
|
-
|
|
46
|
+
TimestampProperty(),
|
|
47
47
|
__metadata("design:type", Number)
|
|
48
48
|
], EntityMetadata.prototype, "createTimestamp", void 0);
|
|
49
49
|
__decorate([
|
|
50
|
-
|
|
50
|
+
TimestampProperty({ nullable: true }),
|
|
51
51
|
__metadata("design:type", Object)
|
|
52
52
|
], EntityMetadata.prototype, "deleteTimestamp", void 0);
|
|
53
53
|
__decorate([
|
|
@@ -63,12 +63,12 @@ export class Entity {
|
|
|
63
63
|
metadata;
|
|
64
64
|
}
|
|
65
65
|
__decorate([
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
PrimaryKeyProperty(),
|
|
67
|
+
UuidProperty({ defaultRandom: true }),
|
|
68
68
|
__metadata("design:type", Object)
|
|
69
69
|
], Entity.prototype, "id", void 0);
|
|
70
70
|
__decorate([
|
|
71
|
-
|
|
71
|
+
EmbeddedProperty(EntityMetadata, { prefix: null }),
|
|
72
72
|
__metadata("design:type", Object)
|
|
73
73
|
], Entity.prototype, "metadata", void 0);
|
|
74
74
|
/**
|
|
@@ -79,7 +79,21 @@ export class EntityWithoutMetadata {
|
|
|
79
79
|
id;
|
|
80
80
|
}
|
|
81
81
|
__decorate([
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
PrimaryKeyProperty(),
|
|
83
|
+
UuidProperty({ defaultRandom: true }),
|
|
84
84
|
__metadata("design:type", Object)
|
|
85
85
|
], EntityWithoutMetadata.prototype, "id", void 0);
|
|
86
|
+
export class TenantEntity extends Entity {
|
|
87
|
+
tenantId;
|
|
88
|
+
}
|
|
89
|
+
__decorate([
|
|
90
|
+
UuidProperty(),
|
|
91
|
+
__metadata("design:type", String)
|
|
92
|
+
], TenantEntity.prototype, "tenantId", void 0);
|
|
93
|
+
export class TenantEntityWithoutMetadata extends EntityWithoutMetadata {
|
|
94
|
+
tenantId;
|
|
95
|
+
}
|
|
96
|
+
__decorate([
|
|
97
|
+
UuidProperty(),
|
|
98
|
+
__metadata("design:type", String)
|
|
99
|
+
], TenantEntityWithoutMetadata.prototype, "tenantId", void 0);
|
package/orm/index.d.ts
CHANGED
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module ORM
|
|
5
5
|
*/
|
|
6
|
-
export * from './
|
|
6
|
+
export * from './decorators.js';
|
|
7
7
|
export * from './entity.js';
|
|
8
8
|
export * from './query.js';
|
|
9
9
|
export * from './repository.types.js';
|
|
10
|
+
export * from './schemas/index.js';
|
|
10
11
|
export * from './sqls.js';
|
|
11
12
|
export * from './types.js';
|
|
12
13
|
export * from './utils.js';
|