@tstdl/base 0.92.54 → 0.92.56
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/authentication/models/index.d.ts +1 -0
- package/authentication/models/index.js +1 -0
- package/authentication/models/schemas.d.ts +2 -2
- package/document-management/models/schemas.d.ts +17 -17
- package/document-management/server/drizzle/{0000_wakeful_firebrand.sql → 0000_sloppy_fenris.sql} +1 -1
- package/document-management/server/drizzle/meta/0000_snapshot.json +5 -5
- package/document-management/server/drizzle/meta/_journal.json +2 -2
- package/examples/orm/schemas.d.ts +1 -1
- package/mail/drizzle/0000_empty_jubilee.sql +13 -0
- package/mail/drizzle/meta/0000_snapshot.json +100 -0
- package/mail/drizzle/meta/_journal.json +13 -0
- package/mail/drizzle.config.d.ts +2 -0
- package/mail/drizzle.config.js +11 -0
- package/mail/index.d.ts +0 -1
- package/mail/index.js +0 -1
- package/mail/mail.service.d.ts +1 -1
- package/mail/mail.service.js +21 -21
- package/mail/models/index.d.ts +1 -0
- package/mail/models/index.js +1 -0
- package/mail/models/mail-log.model.d.ts +6 -7
- package/mail/models/mail-log.model.js +38 -1
- package/mail/models/schemas.d.ts +3 -0
- package/mail/models/schemas.js +4 -0
- package/mail/module.d.ts +9 -8
- package/mail/module.js +25 -11
- package/orm/decorators.d.ts +2 -0
- package/orm/decorators.js +3 -0
- package/orm/server/database-schema.d.ts +1 -1
- package/orm/server/drizzle/schema-converter.d.ts +3 -36
- package/orm/server/drizzle/schema-converter.js +18 -1
- package/orm/server/encryption.d.ts +2 -0
- package/orm/server/encryption.js +30 -0
- package/orm/server/module.d.ts +3 -1
- package/orm/server/module.js +4 -0
- package/orm/server/query-converter.d.ts +1 -1
- package/orm/server/query-converter.js +0 -1
- package/orm/server/repository.d.ts +9 -5
- package/orm/server/repository.js +72 -30
- package/orm/server/tokens.d.ts +1 -0
- package/orm/server/tokens.js +2 -0
- package/orm/server/types.d.ts +43 -0
- package/orm/server/types.js +1 -0
- package/orm/types.d.ts +2 -1
- package/package.json +6 -4
- package/mail/repositories/index.d.ts +0 -2
- package/mail/repositories/index.js +0 -2
- package/mail/repositories/mail-log.repository.d.ts +0 -4
- package/mail/repositories/mail-log.repository.js +0 -3
- package/mail/repositories/mongo/index.d.ts +0 -1
- package/mail/repositories/mongo/index.js +0 -1
- package/mail/repositories/mongo/mongo-mail-log.repository.d.ts +0 -16
- package/mail/repositories/mongo/mongo-mail-log.repository.js +0 -33
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './authentication-credentials.model.js';
|
|
2
2
|
export * from './authentication-session.model.js';
|
|
3
3
|
export * from './init-secret-reset-data.model.js';
|
|
4
|
+
export * from './schemas.js';
|
|
4
5
|
export * from './secret-check-result.model.js';
|
|
5
6
|
export * from './token-payload-base.model.js';
|
|
6
7
|
export * from './token.model.js';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './authentication-credentials.model.js';
|
|
2
2
|
export * from './authentication-session.model.js';
|
|
3
3
|
export * from './init-secret-reset-data.model.js';
|
|
4
|
+
export * from './schemas.js';
|
|
4
5
|
export * from './secret-check-result.model.js';
|
|
5
6
|
export * from './token-payload-base.model.js';
|
|
6
7
|
export * from './token.model.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AuthenticationCredentials } from './authentication-credentials.model.js';
|
|
2
2
|
import { AuthenticationSession } from './authentication-session.model.js';
|
|
3
3
|
export declare const authenticationSchema: import("../../orm/server/database-schema.js").DatabaseSchema<"authentication">;
|
|
4
|
-
export declare const authenticationCredentials: import("../../orm/server/
|
|
5
|
-
export declare const authenticationSession: import("../../orm/server/
|
|
4
|
+
export declare const authenticationCredentials: import("../../orm/server/types.js").PgTableFromType<"authentication", typeof AuthenticationCredentials>;
|
|
5
|
+
export declare const authenticationSession: import("../../orm/server/types.js").PgTableFromType<"authentication", typeof AuthenticationSession>;
|
|
@@ -14,20 +14,20 @@ import { DocumentType } from './document-type.model.js';
|
|
|
14
14
|
import { Document } from './document.model.js';
|
|
15
15
|
export declare const documentManagementSchema: import("../../orm/server/database-schema.js").DatabaseSchema<"document_management">;
|
|
16
16
|
export declare const dataType: import("drizzle-orm/pg-core").PgEnum<["boolean", "decimal", "text", "integer"]>;
|
|
17
|
-
export declare const documentCategory: import("../../orm/server/
|
|
18
|
-
export declare const documentCollectionDocument: import("../../orm/server/
|
|
19
|
-
export declare const documentCollection: import("../../orm/server/
|
|
20
|
-
export declare const documentFile: import("../../orm/server/
|
|
21
|
-
export declare const documentPropertyTextValue: import("../../orm/server/
|
|
22
|
-
export declare const documentPropertyIntegerValue: import("../../orm/server/
|
|
23
|
-
export declare const documentPropertyDecimalValue: import("../../orm/server/
|
|
24
|
-
export declare const documentPropertyBooleanValue: import("../../orm/server/
|
|
25
|
-
export declare const documentProperty: import("../../orm/server/
|
|
26
|
-
export declare const documentRequestCollection: import("../../orm/server/
|
|
27
|
-
export declare const documentRequestFile: import("../../orm/server/
|
|
28
|
-
export declare const documentRequestTemplate: import("../../orm/server/
|
|
29
|
-
export declare const documentRequest: import("../../orm/server/
|
|
30
|
-
export declare const documentRequestsTemplate: import("../../orm/server/
|
|
31
|
-
export declare const documentTypeProperty: import("../../orm/server/
|
|
32
|
-
export declare const documentType: import("../../orm/server/
|
|
33
|
-
export declare const document: import("../../orm/server/
|
|
17
|
+
export declare const documentCategory: import("../../orm/server/types.js").PgTableFromType<"document_management", typeof DocumentCategory>;
|
|
18
|
+
export declare const documentCollectionDocument: import("../../orm/server/types.js").PgTableFromType<"document_management", typeof DocumentCollectionDocument>;
|
|
19
|
+
export declare const documentCollection: import("../../orm/server/types.js").PgTableFromType<"document_management", typeof DocumentCollection>;
|
|
20
|
+
export declare const documentFile: import("../../orm/server/types.js").PgTableFromType<"document_management", typeof DocumentFile>;
|
|
21
|
+
export declare const documentPropertyTextValue: import("../../orm/server/types.js").PgTableFromType<"document_management", typeof DocumentPropertyTextValue>;
|
|
22
|
+
export declare const documentPropertyIntegerValue: import("../../orm/server/types.js").PgTableFromType<"document_management", typeof DocumentPropertyIntegerValue>;
|
|
23
|
+
export declare const documentPropertyDecimalValue: import("../../orm/server/types.js").PgTableFromType<"document_management", typeof DocumentPropertyDecimalValue>;
|
|
24
|
+
export declare const documentPropertyBooleanValue: import("../../orm/server/types.js").PgTableFromType<"document_management", typeof DocumentPropertyBooleanValue>;
|
|
25
|
+
export declare const documentProperty: import("../../orm/server/types.js").PgTableFromType<"document_management", typeof DocumentProperty>;
|
|
26
|
+
export declare const documentRequestCollection: import("../../orm/server/types.js").PgTableFromType<"document_management", typeof DocumentRequestCollection>;
|
|
27
|
+
export declare const documentRequestFile: import("../../orm/server/types.js").PgTableFromType<"document_management", typeof DocumentRequestFile>;
|
|
28
|
+
export declare const documentRequestTemplate: import("../../orm/server/types.js").PgTableFromType<"document_management", typeof DocumentRequestTemplate>;
|
|
29
|
+
export declare const documentRequest: import("../../orm/server/types.js").PgTableFromType<"document_management", typeof DocumentRequest>;
|
|
30
|
+
export declare const documentRequestsTemplate: import("../../orm/server/types.js").PgTableFromType<"document_management", typeof DocumentRequestsTemplate>;
|
|
31
|
+
export declare const documentTypeProperty: import("../../orm/server/types.js").PgTableFromType<"document_management", typeof DocumentTypeProperty>;
|
|
32
|
+
export declare const documentType: import("../../orm/server/types.js").PgTableFromType<"document_management", typeof DocumentType>;
|
|
33
|
+
export declare const document: import("../../orm/server/types.js").PgTableFromType<"document_management", typeof Document>;
|
package/document-management/server/drizzle/{0000_wakeful_firebrand.sql → 0000_sloppy_fenris.sql}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
CREATE TYPE "document_management"."document_property_data_type" AS ENUM('
|
|
1
|
+
CREATE TYPE "document_management"."document_property_data_type" AS ENUM('text', 'integer', 'decimal', 'boolean');--> statement-breakpoint
|
|
2
2
|
CREATE TABLE "document_management"."document" (
|
|
3
3
|
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
4
4
|
"file_id" uuid NOT NULL,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"id": "
|
|
2
|
+
"id": "8b44dbd1-5662-4e8f-9a42-3057c61bdaa3",
|
|
3
3
|
"prevId": "00000000-0000-0000-0000-000000000000",
|
|
4
4
|
"version": "7",
|
|
5
5
|
"dialect": "postgresql",
|
|
@@ -1518,10 +1518,10 @@
|
|
|
1518
1518
|
"name": "document_property_data_type",
|
|
1519
1519
|
"schema": "document_management",
|
|
1520
1520
|
"values": [
|
|
1521
|
-
"
|
|
1522
|
-
"
|
|
1523
|
-
"
|
|
1524
|
-
"
|
|
1521
|
+
"text",
|
|
1522
|
+
"integer",
|
|
1523
|
+
"decimal",
|
|
1524
|
+
"boolean"
|
|
1525
1525
|
]
|
|
1526
1526
|
}
|
|
1527
1527
|
},
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { User } from './user.model.js';
|
|
2
2
|
export declare const mySchema: import("../../orm/server/database-schema.js").DatabaseSchema<"my_application">;
|
|
3
|
-
export declare const user: import("../../orm/server/
|
|
3
|
+
export declare const user: import("../../orm/server/types.js").PgTableFromType<"my_application", typeof User>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
CREATE TABLE "mail"."mail_log" (
|
|
2
|
+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
3
|
+
"timestamp" timestamp with time zone NOT NULL,
|
|
4
|
+
"template" text,
|
|
5
|
+
"data" jsonb NOT NULL,
|
|
6
|
+
"send_result" jsonb,
|
|
7
|
+
"errors" text[],
|
|
8
|
+
"revision" integer NOT NULL,
|
|
9
|
+
"revision_timestamp" timestamp with time zone NOT NULL,
|
|
10
|
+
"create_timestamp" timestamp with time zone NOT NULL,
|
|
11
|
+
"delete_timestamp" timestamp with time zone,
|
|
12
|
+
"attributes" jsonb DEFAULT '{}'::jsonb NOT NULL
|
|
13
|
+
);
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "a6ce7d17-ce0b-4511-b503-b2ac69ff8923",
|
|
3
|
+
"prevId": "00000000-0000-0000-0000-000000000000",
|
|
4
|
+
"version": "7",
|
|
5
|
+
"dialect": "postgresql",
|
|
6
|
+
"tables": {
|
|
7
|
+
"mail.mail_log": {
|
|
8
|
+
"name": "mail_log",
|
|
9
|
+
"schema": "mail",
|
|
10
|
+
"columns": {
|
|
11
|
+
"id": {
|
|
12
|
+
"name": "id",
|
|
13
|
+
"type": "uuid",
|
|
14
|
+
"primaryKey": true,
|
|
15
|
+
"notNull": true,
|
|
16
|
+
"default": "gen_random_uuid()"
|
|
17
|
+
},
|
|
18
|
+
"timestamp": {
|
|
19
|
+
"name": "timestamp",
|
|
20
|
+
"type": "timestamp with time zone",
|
|
21
|
+
"primaryKey": false,
|
|
22
|
+
"notNull": true
|
|
23
|
+
},
|
|
24
|
+
"template": {
|
|
25
|
+
"name": "template",
|
|
26
|
+
"type": "text",
|
|
27
|
+
"primaryKey": false,
|
|
28
|
+
"notNull": false
|
|
29
|
+
},
|
|
30
|
+
"data": {
|
|
31
|
+
"name": "data",
|
|
32
|
+
"type": "jsonb",
|
|
33
|
+
"primaryKey": false,
|
|
34
|
+
"notNull": true
|
|
35
|
+
},
|
|
36
|
+
"send_result": {
|
|
37
|
+
"name": "send_result",
|
|
38
|
+
"type": "jsonb",
|
|
39
|
+
"primaryKey": false,
|
|
40
|
+
"notNull": false
|
|
41
|
+
},
|
|
42
|
+
"errors": {
|
|
43
|
+
"name": "errors",
|
|
44
|
+
"type": "text[]",
|
|
45
|
+
"primaryKey": false,
|
|
46
|
+
"notNull": false
|
|
47
|
+
},
|
|
48
|
+
"revision": {
|
|
49
|
+
"name": "revision",
|
|
50
|
+
"type": "integer",
|
|
51
|
+
"primaryKey": false,
|
|
52
|
+
"notNull": true
|
|
53
|
+
},
|
|
54
|
+
"revision_timestamp": {
|
|
55
|
+
"name": "revision_timestamp",
|
|
56
|
+
"type": "timestamp with time zone",
|
|
57
|
+
"primaryKey": false,
|
|
58
|
+
"notNull": true
|
|
59
|
+
},
|
|
60
|
+
"create_timestamp": {
|
|
61
|
+
"name": "create_timestamp",
|
|
62
|
+
"type": "timestamp with time zone",
|
|
63
|
+
"primaryKey": false,
|
|
64
|
+
"notNull": true
|
|
65
|
+
},
|
|
66
|
+
"delete_timestamp": {
|
|
67
|
+
"name": "delete_timestamp",
|
|
68
|
+
"type": "timestamp with time zone",
|
|
69
|
+
"primaryKey": false,
|
|
70
|
+
"notNull": false
|
|
71
|
+
},
|
|
72
|
+
"attributes": {
|
|
73
|
+
"name": "attributes",
|
|
74
|
+
"type": "jsonb",
|
|
75
|
+
"primaryKey": false,
|
|
76
|
+
"notNull": true,
|
|
77
|
+
"default": "'{}'::jsonb"
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
"indexes": {},
|
|
81
|
+
"foreignKeys": {},
|
|
82
|
+
"compositePrimaryKeys": {},
|
|
83
|
+
"uniqueConstraints": {},
|
|
84
|
+
"policies": {},
|
|
85
|
+
"checkConstraints": {},
|
|
86
|
+
"isRLSEnabled": false
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
"enums": {},
|
|
90
|
+
"schemas": {},
|
|
91
|
+
"sequences": {},
|
|
92
|
+
"roles": {},
|
|
93
|
+
"policies": {},
|
|
94
|
+
"views": {},
|
|
95
|
+
"_meta": {
|
|
96
|
+
"columns": {},
|
|
97
|
+
"schemas": {},
|
|
98
|
+
"tables": {}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { relative, resolve } from 'node:path';
|
|
2
|
+
import { defineConfig } from 'drizzle-kit';
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
dialect: 'postgresql',
|
|
5
|
+
out: relative('./', resolve(__dirname, './drizzle/').replace('dist', 'source')),
|
|
6
|
+
schema: resolve(__dirname, './models/schemas.js'),
|
|
7
|
+
migrations: {
|
|
8
|
+
schema: 'authentication',
|
|
9
|
+
table: '_migrations'
|
|
10
|
+
}
|
|
11
|
+
});
|
package/mail/index.d.ts
CHANGED
package/mail/index.js
CHANGED
package/mail/mail.service.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { TypedOmit } from '../types.js';
|
|
2
2
|
import { MailClientConfig } from './mail.client.js';
|
|
3
|
-
import type
|
|
3
|
+
import { type MailData, type MailSendResult, type MailTemplate } from './models/index.js';
|
|
4
4
|
export declare class MailService {
|
|
5
5
|
#private;
|
|
6
6
|
send(mailData: MailData, clientConfig?: MailClientConfig): Promise<MailSendResult>;
|
package/mail/mail.service.js
CHANGED
|
@@ -4,19 +4,21 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { Singleton, inject } from '../injector/index.js';
|
|
7
|
+
import { Singleton, inject, provide } from '../injector/index.js';
|
|
8
8
|
import { Logger } from '../logger/index.js';
|
|
9
|
+
import { DatabaseConfig, EntityRepositoryConfig, injectRepository } from '../orm/server/index.js';
|
|
9
10
|
import { TemplateService } from '../templates/template.service.js';
|
|
10
11
|
import { currentTimestamp } from '../utils/date-time.js';
|
|
11
12
|
import { formatError } from '../utils/format-error.js';
|
|
12
|
-
import { assertDefined
|
|
13
|
+
import { assertDefined } from '../utils/type-guards.js';
|
|
13
14
|
import { MailClient, MailClientConfig } from './mail.client.js';
|
|
14
|
-
import {
|
|
15
|
+
import { MailLog } from './models/index.js';
|
|
16
|
+
import { MailModuleConfig } from './module.js';
|
|
15
17
|
import { MAIL_DEFAULT_DATA } from './tokens.js';
|
|
16
18
|
let MailService = class MailService {
|
|
17
19
|
#mailClient = inject(MailClient);
|
|
18
20
|
#templateService = inject(TemplateService);
|
|
19
|
-
#mailLogRepository =
|
|
21
|
+
#mailLogRepository = injectRepository(MailLog);
|
|
20
22
|
#defaultClientConfig = inject(MailClientConfig, undefined, { optional: true });
|
|
21
23
|
#defaultData = inject(MAIL_DEFAULT_DATA, undefined, { optional: true });
|
|
22
24
|
#logger = inject(Logger, 'MailService');
|
|
@@ -26,28 +28,21 @@ let MailService = class MailService {
|
|
|
26
28
|
assertDefined(clientConfig, 'No mail client config provided.');
|
|
27
29
|
const data = { ...this.#defaultData, ...mailData };
|
|
28
30
|
let mailLog;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
};
|
|
37
|
-
mailLog = await this.#mailLogRepository.insert(log);
|
|
38
|
-
}
|
|
31
|
+
mailLog = await this.#mailLogRepository.insert({
|
|
32
|
+
timestamp: currentTimestamp(),
|
|
33
|
+
template: templateName ?? null,
|
|
34
|
+
data,
|
|
35
|
+
sendResult: null,
|
|
36
|
+
errors: null
|
|
37
|
+
});
|
|
39
38
|
try {
|
|
40
39
|
const result = await this.#mailClient.send(data, clientConfig);
|
|
41
|
-
|
|
42
|
-
await this.#mailLogRepository.patch(mailLog, { sendResult: result });
|
|
43
|
-
}
|
|
40
|
+
await this.#mailLogRepository.update(mailLog.id, { sendResult: result });
|
|
44
41
|
return result;
|
|
45
42
|
}
|
|
46
43
|
catch (error) {
|
|
47
44
|
try {
|
|
48
|
-
|
|
49
|
-
await this.#mailLogRepository.patch(mailLog, { errors: [formatError(error)] });
|
|
50
|
-
}
|
|
45
|
+
await this.#mailLogRepository.update(mailLog.id, { errors: [formatError(error)] });
|
|
51
46
|
}
|
|
52
47
|
catch (logError) {
|
|
53
48
|
this.#logger.error(logError);
|
|
@@ -62,6 +57,11 @@ let MailService = class MailService {
|
|
|
62
57
|
}
|
|
63
58
|
};
|
|
64
59
|
MailService = __decorate([
|
|
65
|
-
Singleton(
|
|
60
|
+
Singleton({
|
|
61
|
+
providers: [
|
|
62
|
+
provide(EntityRepositoryConfig, { useValue: { schema: 'mail' } }),
|
|
63
|
+
provide(DatabaseConfig, { useFactory: (_, context) => context.resolve(MailModuleConfig).database ?? context.resolve(DatabaseConfig, undefined, { skipSelf: true }) })
|
|
64
|
+
]
|
|
65
|
+
})
|
|
66
66
|
], MailService);
|
|
67
67
|
export { MailService };
|
package/mail/models/index.d.ts
CHANGED
package/mail/models/index.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Entity, Json, 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
|
-
export
|
|
5
|
-
timestamp:
|
|
4
|
+
export declare class MailLog extends Entity {
|
|
5
|
+
timestamp: Timestamp;
|
|
6
6
|
template: string | null;
|
|
7
|
-
data: MailData
|
|
8
|
-
sendResult: MailSendResult | null;
|
|
7
|
+
data: Json<MailData>;
|
|
8
|
+
sendResult: Json<MailSendResult> | null;
|
|
9
9
|
errors: string[] | null;
|
|
10
|
-
}
|
|
11
|
-
export type NewMailLog = NewEntity<MailLog>;
|
|
10
|
+
}
|
|
@@ -1 +1,38 @@
|
|
|
1
|
-
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { Entity, Json, Timestamp } from '../../orm/index.js';
|
|
11
|
+
import { StringProperty } from '../../schema/index.js';
|
|
12
|
+
export class MailLog extends Entity {
|
|
13
|
+
timestamp;
|
|
14
|
+
template;
|
|
15
|
+
data;
|
|
16
|
+
sendResult;
|
|
17
|
+
errors;
|
|
18
|
+
}
|
|
19
|
+
__decorate([
|
|
20
|
+
Timestamp(),
|
|
21
|
+
__metadata("design:type", Number)
|
|
22
|
+
], MailLog.prototype, "timestamp", void 0);
|
|
23
|
+
__decorate([
|
|
24
|
+
StringProperty({ nullable: true }),
|
|
25
|
+
__metadata("design:type", Object)
|
|
26
|
+
], MailLog.prototype, "template", void 0);
|
|
27
|
+
__decorate([
|
|
28
|
+
Json(),
|
|
29
|
+
__metadata("design:type", Object)
|
|
30
|
+
], MailLog.prototype, "data", void 0);
|
|
31
|
+
__decorate([
|
|
32
|
+
Json({ nullable: true }),
|
|
33
|
+
__metadata("design:type", Object)
|
|
34
|
+
], MailLog.prototype, "sendResult", void 0);
|
|
35
|
+
__decorate([
|
|
36
|
+
StringProperty({ array: true, nullable: true }),
|
|
37
|
+
__metadata("design:type", Object)
|
|
38
|
+
], MailLog.prototype, "errors", void 0);
|
package/mail/module.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
import { type DatabaseConfig } from '../orm/server/index.js';
|
|
1
2
|
import type { Type } from '../types.js';
|
|
2
3
|
import { MailClient, MailClientConfig } from './mail.client.js';
|
|
3
4
|
import type { DefaultMailData } from './models/index.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
defaultClientConfig
|
|
7
|
-
client
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
5
|
+
export declare class MailModuleConfig {
|
|
6
|
+
database?: DatabaseConfig;
|
|
7
|
+
defaultClientConfig?: MailClientConfig;
|
|
8
|
+
client?: Type<MailClient>;
|
|
9
|
+
defaultData?: DefaultMailData;
|
|
10
|
+
}
|
|
11
11
|
/**
|
|
12
12
|
* configure mail module
|
|
13
13
|
*/
|
|
14
|
-
export declare function configureMail(
|
|
14
|
+
export declare function configureMail(config: MailModuleConfig): void;
|
|
15
|
+
export declare function migrateMailSchema(): Promise<void>;
|
package/mail/module.js
CHANGED
|
@@ -1,22 +1,36 @@
|
|
|
1
|
+
import { inject } from '../injector/index.js';
|
|
1
2
|
import { Injector } from '../injector/injector.js';
|
|
3
|
+
import { Database, migrate } from '../orm/server/index.js';
|
|
2
4
|
import { isDefined } from '../utils/type-guards.js';
|
|
3
5
|
import { MailClient, MailClientConfig } from './mail.client.js';
|
|
4
|
-
import { MailLogRepository } from './repositories/mail-log.repository.js';
|
|
5
6
|
import { MAIL_DEFAULT_DATA } from './tokens.js';
|
|
7
|
+
export class MailModuleConfig {
|
|
8
|
+
database;
|
|
9
|
+
defaultClientConfig;
|
|
10
|
+
client;
|
|
11
|
+
defaultData;
|
|
12
|
+
}
|
|
6
13
|
/**
|
|
7
14
|
* configure mail module
|
|
8
15
|
*/
|
|
9
|
-
export function configureMail(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
if (isDefined(client)) {
|
|
14
|
-
Injector.registerSingleton(MailClient, { useToken: client });
|
|
16
|
+
export function configureMail(config) {
|
|
17
|
+
Injector.register(MailModuleConfig, { useValue: config });
|
|
18
|
+
if (isDefined(config.defaultClientConfig)) {
|
|
19
|
+
Injector.registerSingleton(MailClientConfig, { useValue: config.defaultClientConfig });
|
|
15
20
|
}
|
|
16
|
-
if (isDefined(
|
|
17
|
-
Injector.registerSingleton(
|
|
21
|
+
if (isDefined(config.client)) {
|
|
22
|
+
Injector.registerSingleton(MailClient, { useToken: config.client });
|
|
18
23
|
}
|
|
19
|
-
if (isDefined(defaultData)) {
|
|
20
|
-
Injector.registerSingleton(MAIL_DEFAULT_DATA, { useValue: defaultData });
|
|
24
|
+
if (isDefined(config.defaultData)) {
|
|
25
|
+
Injector.registerSingleton(MAIL_DEFAULT_DATA, { useValue: config.defaultData });
|
|
21
26
|
}
|
|
22
27
|
}
|
|
28
|
+
export async function migrateMailSchema() {
|
|
29
|
+
const connection = inject(MailModuleConfig, undefined, { optional: true })?.database?.connection;
|
|
30
|
+
const database = inject(Database, connection);
|
|
31
|
+
await migrate(database, {
|
|
32
|
+
migrationsSchema: 'mail',
|
|
33
|
+
migrationsTable: '_migrations',
|
|
34
|
+
migrationsFolder: import.meta.resolve('./drizzle').replace('file://', '')
|
|
35
|
+
});
|
|
36
|
+
}
|
package/orm/decorators.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export type OrmColumnReflectionData = {
|
|
|
20
20
|
prefix?: string | null;
|
|
21
21
|
};
|
|
22
22
|
references?: () => EntityType;
|
|
23
|
+
encrypted?: boolean;
|
|
23
24
|
};
|
|
24
25
|
export type UniqueReflectionData = {
|
|
25
26
|
name?: string;
|
|
@@ -44,6 +45,7 @@ export declare function createTableAndColumnDecorator(data?: OrmColumnReflection
|
|
|
44
45
|
export declare function Column(options: OrmColumnReflectionData): PropertyDecorator;
|
|
45
46
|
export declare function PrimaryKey(): PropertyDecorator;
|
|
46
47
|
export declare function References(type: () => EntityType): PropertyDecorator;
|
|
48
|
+
export declare function Encrypted(): PropertyDecorator;
|
|
47
49
|
export declare function Embedded(type: AbstractConstructor, options?: TypedOmit<NonNullable<OrmColumnReflectionData['embedded']>, 'type'>): PropertyDecorator;
|
|
48
50
|
export declare function Unique(name?: string, options?: UniqueReflectionData['options']): PropertyDecorator;
|
|
49
51
|
export declare function Unique(name: string | undefined, columns: [string, ...string[]], options?: UniqueReflectionData['options']): ClassDecorator;
|
package/orm/decorators.js
CHANGED
|
@@ -19,6 +19,9 @@ export function PrimaryKey() {
|
|
|
19
19
|
export function References(type) {
|
|
20
20
|
return createColumnDecorator({ references: type });
|
|
21
21
|
}
|
|
22
|
+
export function Encrypted() {
|
|
23
|
+
return createColumnDecorator({ encrypted: true });
|
|
24
|
+
}
|
|
22
25
|
export function Embedded(type, options) {
|
|
23
26
|
return createPropertyDecorator({
|
|
24
27
|
include: [Property(type), createColumnDecorator({ embedded: { type, ...options } })]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { PgEnum } from 'drizzle-orm/pg-core';
|
|
2
2
|
import type { Enumeration, EnumerationValue, UnionToTuple } from '../../types.js';
|
|
3
3
|
import type { EntityType } from '../entity.js';
|
|
4
|
-
import {
|
|
4
|
+
import type { PgTableFromType } from './types.js';
|
|
5
5
|
export declare class DatabaseSchema<Name extends string> {
|
|
6
6
|
readonly name: Name;
|
|
7
7
|
constructor(name: Name);
|
|
@@ -1,45 +1,12 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import
|
|
3
|
-
import type { CamelCase, ConditionalPick, SnakeCase } from 'type-fest';
|
|
4
|
-
import { JsonPath } from '../../../json-path/json-path.js';
|
|
5
|
-
import { type Record } from '../../../schema/index.js';
|
|
6
|
-
import type { AbstractConstructor, Enumeration, UnionToIntersection } from '../../../types.js';
|
|
7
|
-
import type { Tagged } from '../../../types/index.js';
|
|
8
|
-
import type { OrmColumnReflectionData } from '../../decorators.js';
|
|
1
|
+
import { type PgEnum, type PgSchema, type PgTableWithColumns } from 'drizzle-orm/pg-core';
|
|
2
|
+
import type { AbstractConstructor, Enumeration } from '../../../types.js';
|
|
9
3
|
import type { EntityType } from '../../entity.js';
|
|
10
|
-
import type {
|
|
11
|
-
type Column<Name extends string, T> = null extends T ? ColumnBuilder<T, Name> : NotNull<ColumnBuilder<T, Name>>;
|
|
4
|
+
import type { ColumnDefinition, PgTableFromType } from '../types.js';
|
|
12
5
|
type ConverterContext = {
|
|
13
6
|
type: AbstractConstructor;
|
|
14
7
|
property: string;
|
|
15
8
|
};
|
|
16
|
-
export type ColumnDefinition = {
|
|
17
|
-
name: string;
|
|
18
|
-
objectPath: JsonPath;
|
|
19
|
-
type: PgColumnBuilder<any, any, any, any>;
|
|
20
|
-
reflectionData: OrmColumnReflectionData | undefined;
|
|
21
|
-
dereferenceObjectPath: (obj: Record) => any;
|
|
22
|
-
};
|
|
23
9
|
export declare const getDrizzleTableFromType: typeof _getDrizzleTableFromType;
|
|
24
|
-
export type ColumnPrefix<T> = T extends Tagged<unknown, EmbeddedConfigTag, {
|
|
25
|
-
prefix: infer Prefix;
|
|
26
|
-
}> ? Prefix extends string ? Prefix : '' : '';
|
|
27
|
-
export type PgTableFromType<S extends string, T extends AbstractConstructor, TableName extends string = T extends Required<EntityType> ? SnakeCase<T['entityName']> : string> = PgTableWithColumns<{
|
|
28
|
-
name: TableName;
|
|
29
|
-
schema: S;
|
|
30
|
-
columns: BuildColumns<TableName, {
|
|
31
|
-
[P in Exclude<keyof InstanceType<T>, keyof EmbeddedProperties<InstanceType<T>>>]: Column<CamelCase<Extract<P, string>>, InstanceType<T>[P]>;
|
|
32
|
-
} & UnionToIntersection<{
|
|
33
|
-
[P in keyof EmbeddedProperties<InstanceType<T>>]: EmbeddedColumns<InstanceType<T>[P], ColumnPrefix<InstanceType<T>[P]>>;
|
|
34
|
-
}[keyof EmbeddedProperties<InstanceType<T>>]>, 'pg'>;
|
|
35
|
-
dialect: 'pg';
|
|
36
|
-
}>;
|
|
37
|
-
export type EmbeddedProperties<T> = ConditionalPick<T, Tagged<unknown, EmbeddedConfigTag, {
|
|
38
|
-
prefix: any;
|
|
39
|
-
}>>;
|
|
40
|
-
export type EmbeddedColumns<T, Prefix extends string> = {
|
|
41
|
-
[P in keyof T as CamelCase<`${Prefix}${Extract<P, string>}`>]: Column<CamelCase<`${Prefix}${Extract<P, string>}`>, T[P]>;
|
|
42
|
-
};
|
|
43
10
|
export declare function getColumnDefinitions(table: PgTableWithColumns<any>): ColumnDefinition[];
|
|
44
11
|
export declare function _getDrizzleTableFromType<T extends EntityType, S extends string>(type: T, schemaName: S, tableName?: string): PgTableFromType<S, T>;
|
|
45
12
|
export declare function registerEnum(enumeration: Enumeration, name: string): void;
|