@tstdl/base 0.92.53 → 0.92.55

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.
Files changed (39) hide show
  1. package/authentication/models/index.d.ts +1 -0
  2. package/authentication/models/index.js +1 -0
  3. package/document-management/models/document-property.model.d.ts +8 -6
  4. package/document-management/models/document-property.model.js +8 -8
  5. package/document-management/models/schemas.d.ts +1 -1
  6. package/document-management/server/drizzle/{0000_wakeful_firebrand.sql → 0000_sloppy_fenris.sql} +1 -1
  7. package/document-management/server/drizzle/meta/0000_snapshot.json +5 -5
  8. package/document-management/server/drizzle/meta/_journal.json +2 -2
  9. package/document-management/server/services/document-management.service.js +1 -1
  10. package/mail/drizzle/0000_empty_jubilee.sql +13 -0
  11. package/mail/drizzle/meta/0000_snapshot.json +100 -0
  12. package/mail/drizzle/meta/_journal.json +13 -0
  13. package/mail/drizzle.config.d.ts +2 -0
  14. package/mail/drizzle.config.js +11 -0
  15. package/mail/index.d.ts +0 -1
  16. package/mail/index.js +0 -1
  17. package/mail/mail.service.d.ts +1 -1
  18. package/mail/mail.service.js +21 -21
  19. package/mail/models/index.d.ts +1 -0
  20. package/mail/models/index.js +1 -0
  21. package/mail/models/mail-log.model.d.ts +6 -7
  22. package/mail/models/mail-log.model.js +38 -1
  23. package/mail/models/schemas.d.ts +3 -0
  24. package/mail/models/schemas.js +4 -0
  25. package/mail/module.d.ts +9 -8
  26. package/mail/module.js +25 -11
  27. package/orm/server/database-schema.d.ts +2 -2
  28. package/orm/server/database-schema.js +2 -1
  29. package/orm/server/repository.d.ts +0 -1
  30. package/orm/server/repository.js +0 -3
  31. package/package.json +6 -4
  32. package/mail/repositories/index.d.ts +0 -2
  33. package/mail/repositories/index.js +0 -2
  34. package/mail/repositories/mail-log.repository.d.ts +0 -4
  35. package/mail/repositories/mail-log.repository.js +0 -3
  36. package/mail/repositories/mongo/index.d.ts +0 -1
  37. package/mail/repositories/mongo/index.js +0 -1
  38. package/mail/repositories/mongo/mongo-mail-log.repository.d.ts +0 -16
  39. 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,10 +1,12 @@
1
+ import { type EnumType } from '../../enumeration/enumeration.js';
1
2
  import { Entity } from '../../orm/entity.js';
2
- export declare enum DocumentPropertyDataType {
3
- Text = 0,
4
- Integer = 1,
5
- Decimal = 2,
6
- Boolean = 3
7
- }
3
+ export declare const DocumentPropertyDataType: {
4
+ readonly Text: "text";
5
+ readonly Integer: "integer";
6
+ readonly Decimal: "decimal";
7
+ readonly Boolean: "boolean";
8
+ };
9
+ export type DocumentPropertyDataType = EnumType<typeof DocumentPropertyDataType>;
8
10
  export declare class DocumentProperty extends Entity {
9
11
  label: string;
10
12
  dataType: DocumentPropertyDataType;
@@ -7,15 +7,15 @@ 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 { defineEnum } from '../../enumeration/enumeration.js';
10
11
  import { Entity } from '../../orm/entity.js';
11
12
  import { Enumeration, StringProperty } from '../../schema/index.js';
12
- export var DocumentPropertyDataType;
13
- (function (DocumentPropertyDataType) {
14
- DocumentPropertyDataType[DocumentPropertyDataType["Text"] = 0] = "Text";
15
- DocumentPropertyDataType[DocumentPropertyDataType["Integer"] = 1] = "Integer";
16
- DocumentPropertyDataType[DocumentPropertyDataType["Decimal"] = 2] = "Decimal";
17
- DocumentPropertyDataType[DocumentPropertyDataType["Boolean"] = 3] = "Boolean";
18
- })(DocumentPropertyDataType || (DocumentPropertyDataType = {}));
13
+ export const DocumentPropertyDataType = defineEnum('DocumentPropertyDataType', {
14
+ Text: 'text',
15
+ Integer: 'integer',
16
+ Decimal: 'decimal',
17
+ Boolean: 'boolean'
18
+ });
19
19
  export class DocumentProperty extends Entity {
20
20
  label;
21
21
  dataType;
@@ -26,5 +26,5 @@ __decorate([
26
26
  ], DocumentProperty.prototype, "label", void 0);
27
27
  __decorate([
28
28
  Enumeration(DocumentPropertyDataType),
29
- __metadata("design:type", Number)
29
+ __metadata("design:type", String)
30
30
  ], DocumentProperty.prototype, "dataType", void 0);
@@ -13,7 +13,7 @@ import { DocumentTypeProperty } from './document-type-property.model.js';
13
13
  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
- export declare const dataType: import("drizzle-orm/pg-core").PgEnum<["0", "1", "3", "2"]>;
16
+ export declare const dataType: import("drizzle-orm/pg-core").PgEnum<["boolean", "decimal", "text", "integer"]>;
17
17
  export declare const documentCategory: import("../../orm/server/drizzle/schema-converter.js").PgTableFromType<"document_management", typeof DocumentCategory>;
18
18
  export declare const documentCollectionDocument: import("../../orm/server/drizzle/schema-converter.js").PgTableFromType<"document_management", typeof DocumentCollectionDocument>;
19
19
  export declare const documentCollection: import("../../orm/server/drizzle/schema-converter.js").PgTableFromType<"document_management", typeof DocumentCollection>;
@@ -1,4 +1,4 @@
1
- CREATE TYPE "document_management"."document_property_data_type" AS ENUM('0', '1', '2', '3');--> statement-breakpoint
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": "dc8f7b3d-dc7e-4e13-b4f0-239d726d3307",
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
- "0",
1522
- "1",
1523
- "2",
1524
- "3"
1521
+ "text",
1522
+ "integer",
1523
+ "decimal",
1524
+ "boolean"
1525
1525
  ]
1526
1526
  }
1527
1527
  },
@@ -5,8 +5,8 @@
5
5
  {
6
6
  "idx": 0,
7
7
  "version": "7",
8
- "when": 1735923279239,
9
- "tag": "0000_wakeful_firebrand",
8
+ "when": 1739990257563,
9
+ "tag": "0000_sloppy_fenris",
10
10
  "breakpoints": true
11
11
  }
12
12
  ]
@@ -371,6 +371,6 @@ const validators = {
371
371
  function validatePropertyValue(propertyId, dataType, value) {
372
372
  const valid = validators[dataType](value);
373
373
  if (!valid) {
374
- throw new BadRequestError(`Invalid value for data type ${DocumentPropertyDataType[dataType]} for property ${propertyId}.`);
374
+ throw new BadRequestError(`Invalid value for data type ${dataType} for property ${propertyId}.`);
375
375
  }
376
376
  }
@@ -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,13 @@
1
+ {
2
+ "version": "7",
3
+ "dialect": "postgresql",
4
+ "entries": [
5
+ {
6
+ "idx": 0,
7
+ "version": "7",
8
+ "when": 1739990201071,
9
+ "tag": "0000_empty_jubilee",
10
+ "breakpoints": true
11
+ }
12
+ ]
13
+ }
@@ -0,0 +1,2 @@
1
+ declare const _default: import("drizzle-kit").Config;
2
+ export default _default;
@@ -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
@@ -8,5 +8,4 @@ export * from './mail.client.js';
8
8
  export * from './mail.service.js';
9
9
  export * from './models/index.js';
10
10
  export * from './module.js';
11
- export * from './repositories/index.js';
12
11
  export * from './tokens.js';
package/mail/index.js CHANGED
@@ -8,5 +8,4 @@ export * from './mail.client.js';
8
8
  export * from './mail.service.js';
9
9
  export * from './models/index.js';
10
10
  export * from './module.js';
11
- export * from './repositories/index.js';
12
11
  export * from './tokens.js';
@@ -1,6 +1,6 @@
1
1
  import type { TypedOmit } from '../types.js';
2
2
  import { MailClientConfig } from './mail.client.js';
3
- import type { MailData, MailSendResult, MailTemplate } from './models/index.js';
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>;
@@ -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, isDefined } from '../utils/type-guards.js';
13
+ import { assertDefined } from '../utils/type-guards.js';
13
14
  import { MailClient, MailClientConfig } from './mail.client.js';
14
- import { MailLogRepository } from './repositories/mail-log.repository.js';
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 = inject(MailLogRepository, undefined, { optional: true });
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
- if (isDefined(this.#mailLogRepository)) {
30
- const log = {
31
- timestamp: currentTimestamp(),
32
- template: templateName ?? null,
33
- data,
34
- sendResult: null,
35
- errors: null
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
- if (isDefined(mailLog)) {
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
- if (isDefined(mailLog)) {
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 };
@@ -4,3 +4,4 @@ export * from './mail-data.model.js';
4
4
  export * from './mail-log.model.js';
5
5
  export * from './mail-send-result.model.js';
6
6
  export * from './mail-template.model.js';
7
+ export * from './schemas.js';
@@ -4,3 +4,4 @@ export * from './mail-data.model.js';
4
4
  export * from './mail-log.model.js';
5
5
  export * from './mail-send-result.model.js';
6
6
  export * from './mail-template.model.js';
7
+ export * from './schemas.js';
@@ -1,11 +1,10 @@
1
- import type { Entity, NewEntity } from '../../database/index.js';
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 type MailLog = Entity & {
5
- timestamp: number;
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
- export {};
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);
@@ -0,0 +1,3 @@
1
+ import { MailLog } from './mail-log.model.js';
2
+ export declare const mailSchema: import("../../orm/server/database-schema.js").DatabaseSchema<"mail">;
3
+ export declare const mailLog: import("../../orm/server/drizzle/schema-converter.js").PgTableFromType<"mail", typeof MailLog>;
@@ -0,0 +1,4 @@
1
+ import { databaseSchema } from '../../orm/server/database-schema.js';
2
+ import { MailLog } from './mail-log.model.js';
3
+ export const mailSchema = databaseSchema('mail');
4
+ export const mailLog = mailSchema.getTable(MailLog);
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
- import { MailLogRepository } from './repositories/mail-log.repository.js';
5
- export type MailModuleConfig = {
6
- defaultClientConfig: MailClientConfig;
7
- client: Type<MailClient>;
8
- logRepository: Type<MailLogRepository>;
9
- defaultData: DefaultMailData;
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({ defaultClientConfig, client, logRepository, defaultData }: Partial<MailModuleConfig>): void;
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({ defaultClientConfig, client, logRepository, defaultData }) {
10
- if (isDefined(defaultClientConfig)) {
11
- Injector.registerSingleton(MailClientConfig, { useValue: defaultClientConfig });
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(logRepository)) {
17
- Injector.registerSingleton(MailLogRepository, { useToken: logRepository });
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
+ }
@@ -1,11 +1,11 @@
1
1
  import type { PgEnum } from 'drizzle-orm/pg-core';
2
2
  import type { Enumeration, EnumerationValue, UnionToTuple } from '../../types.js';
3
- import { type PgTableFromType } from './drizzle/schema-converter.js';
4
3
  import type { EntityType } from '../entity.js';
4
+ import { type PgTableFromType } from './drizzle/schema-converter.js';
5
5
  export declare class DatabaseSchema<Name extends string> {
6
6
  readonly name: Name;
7
7
  constructor(name: Name);
8
8
  getTable<T extends EntityType>(type: T): PgTableFromType<Name, T>;
9
- getEnum<T extends Enumeration>(enumeration: T, name: string): PgEnum<UnionToTuple<`${EnumerationValue<T>}`> extends [string, ...string[]] ? UnionToTuple<`${EnumerationValue<T>}`> : never>;
9
+ getEnum<T extends Enumeration>(enumeration: T, name?: string): PgEnum<UnionToTuple<`${EnumerationValue<T>}`> extends [string, ...string[]] ? UnionToTuple<`${EnumerationValue<T>}`> : never>;
10
10
  }
11
11
  export declare function databaseSchema<Name extends string>(name: Name): DatabaseSchema<Name>;
@@ -1,3 +1,4 @@
1
+ import { getEnumName } from '../../enumeration/enumeration.js';
1
2
  import { getDrizzleTableFromType, getPgEnum, registerEnum } from './drizzle/schema-converter.js';
2
3
  export class DatabaseSchema {
3
4
  name;
@@ -7,7 +8,7 @@ export class DatabaseSchema {
7
8
  getTable(type) {
8
9
  return getDrizzleTableFromType(type, this.name);
9
10
  }
10
- getEnum(enumeration, name) {
11
+ getEnum(enumeration, name = getEnumName(enumeration)) {
11
12
  registerEnum(enumeration, name);
12
13
  return getPgEnum(this.name, enumeration); // eslint-disable-line @typescript-eslint/no-unsafe-return
13
14
  }
@@ -39,7 +39,6 @@ export declare class EntityRepository<T extends Entity = Entity> implements Reso
39
39
  readonly columnDefinitionsMap: Map<string, ColumnDefinition>;
40
40
  readonly session: Database | PgTransaction;
41
41
  readonly isInTransaction: boolean;
42
- get tx(): PgTransaction;
43
42
  readonly [resolveArgumentType]: EntityType<T>;
44
43
  constructor(type?: EntityType<T>, table?: PgTableFromType<string, EntityType>, columnDefinitions?: ColumnDefinition[], columnDefinitionsMap?: Map<string, ColumnDefinition>, session?: Database | PgTransaction);
45
44
  withOptionalTransaction(transaction: Transaction | undefined): EntityRepository<T>;
@@ -38,9 +38,6 @@ let EntityRepository = class EntityRepository {
38
38
  columnDefinitionsMap;
39
39
  session;
40
40
  isInTransaction;
41
- get tx() {
42
- return this.session;
43
- }
44
41
  constructor(type, table, columnDefinitions, columnDefinitionsMap, session) {
45
42
  this.#repositoryConstructor = new.target;
46
43
  this.type = type ?? injectArgument(this, { optional: true }) ?? inject(ENTITY_TYPE);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tstdl/base",
3
- "version": "0.92.53",
3
+ "version": "0.92.55",
4
4
  "author": "Patrick Hein",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -17,12 +17,14 @@
17
17
  "pub": "npm run build:production && rm -vf dist/test* && rm -vrf dist/tools/ && npm publish dist/",
18
18
  "tsc:watch": "tsc --watch",
19
19
  "tsc-alias:watch": "tsc-alias --watch",
20
- "generate:orm": "npm run generate:drizzle:document-management && npm run generate:drizzle:authentication",
20
+ "generate:orm": "npm run generate:drizzle:document-management && npm run generate:drizzle:authentication && npm run generate:drizzle:mail",
21
21
  "generate:drizzle:document-management": "drizzle-kit generate --config dist/document-management/server/drizzle.config.js",
22
22
  "generate:drizzle:authentication": "drizzle-kit generate --config dist/authentication/server/drizzle.config.js",
23
- "copy:orm": "npm run copy:document-management && npm run copy:authentication",
23
+ "generate:drizzle:mail": "drizzle-kit generate --config dist/mail/drizzle.config.js",
24
+ "copy:orm": "npm run copy:document-management && npm run copy:authentication && npm run copy:mail",
24
25
  "copy:document-management": "rm -rf ./dist/document-management/server/drizzle && cp -r ./source/document-management/server/drizzle ./dist/document-management/server/",
25
- "copy:authentication": "rm -rf ./dist/authentication/server/drizzle && cp -r ./source/authentication/server/drizzle ./dist/authentication/server/"
26
+ "copy:authentication": "rm -rf ./dist/authentication/server/drizzle && cp -r ./source/authentication/server/drizzle ./dist/authentication/server/",
27
+ "copy:mail": "rm -rf ./dist/mail/drizzle && cp -r ./source/mail/drizzle ./dist/mail/"
26
28
  },
27
29
  "exports": {
28
30
  "./tsconfig.json": "./tsconfig.json",
@@ -1,2 +0,0 @@
1
- export * from './mail-log.repository.js';
2
- export * from './mongo/index.js';
@@ -1,2 +0,0 @@
1
- export * from './mail-log.repository.js';
2
- export * from './mongo/index.js';
@@ -1,4 +0,0 @@
1
- import { EntityRepository } from '../../database/index.js';
2
- import type { MailLog } from '../models/mail-log.model.js';
3
- export declare abstract class MailLogRepository extends EntityRepository<MailLog> {
4
- }
@@ -1,3 +0,0 @@
1
- import { EntityRepository } from '../../database/index.js';
2
- export class MailLogRepository extends EntityRepository {
3
- }
@@ -1 +0,0 @@
1
- export * from './mongo-mail-log.repository.js';
@@ -1 +0,0 @@
1
- export * from './mongo-mail-log.repository.js';
@@ -1,16 +0,0 @@
1
- import type { CollectionArgument } from '../../../database/mongo/index.js';
2
- import { Collection, MongoEntityRepository } from '../../../database/mongo/index.js';
3
- import { resolveArgumentType } from '../../../injector/index.js';
4
- import type { Resolvable } from '../../../injector/interfaces.js';
5
- import { Logger } from '../../../logger/index.js';
6
- import type { MailLog } from '../../models/mail-log.model.js';
7
- export type MongoMailLogRepositoryConfig = {
8
- config?: MongoMailLogRepositoryArgument;
9
- };
10
- export type MongoMailLogRepositoryArgument = CollectionArgument<MailLog>;
11
- export declare const mongoMailLogRepositoryConfig: MongoMailLogRepositoryConfig;
12
- export declare class MongoMailLogRepository extends MongoEntityRepository<MailLog> implements Resolvable<MongoMailLogRepositoryArgument> {
13
- readonly [resolveArgumentType]: MongoMailLogRepositoryArgument;
14
- constructor(collection: Collection<MailLog>, logger: Logger);
15
- }
16
- export declare function configureMongoMailLogRepository(config?: Partial<MongoMailLogRepositoryConfig>): void;
@@ -1,33 +0,0 @@
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
- var __param = (this && this.__param) || function (paramIndex, decorator) {
11
- return function (target, key) { decorator(target, key, paramIndex); }
12
- };
13
- import { Collection, MongoEntityRepository, noopTransformer } from '../../../database/mongo/index.js';
14
- import { ForwardArg, Singleton, resolveArgumentType } from '../../../injector/index.js';
15
- import { Logger } from '../../../logger/index.js';
16
- export const mongoMailLogRepositoryConfig = {};
17
- const indexes = [];
18
- let MongoMailLogRepository = class MongoMailLogRepository extends MongoEntityRepository {
19
- constructor(collection, logger) {
20
- super(collection, noopTransformer, { logger, indexes });
21
- }
22
- };
23
- MongoMailLogRepository = __decorate([
24
- Singleton({
25
- defaultArgumentProvider: () => mongoMailLogRepositoryConfig.config
26
- }),
27
- __param(0, ForwardArg()),
28
- __metadata("design:paramtypes", [Collection, Logger])
29
- ], MongoMailLogRepository);
30
- export { MongoMailLogRepository };
31
- export function configureMongoMailLogRepository(config = {}) {
32
- mongoMailLogRepositoryConfig.config = config.config ?? mongoMailLogRepositoryConfig.config;
33
- }