@elsikora/nestjs-crud-config 5.0.0-dev.1 → 5.0.0-dev.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/README.md CHANGED
@@ -175,7 +175,7 @@ import { CrudConfigModule, TOKEN_CONSTANT } from "@elsikora/nestjs-crud-config";
175
175
  // Entity customization
176
176
  entityOptions: {
177
177
  tablePrefix: "app_",
178
- timestampColumnType: "timestamptz", // PostgreSQL; defaults to "timestamp"
178
+ timestampColumnType: "timestamptz", // PostgreSQL; defaults to Date, the timestamp type of the driver
179
179
  configSection: {
180
180
  tableName: "config_sections",
181
181
  maxNameLength: 128,
@@ -1024,7 +1024,7 @@ CrudConfigModule.register({
1024
1024
  });
1025
1025
  ```
1026
1026
 
1027
- `timestampColumnType` applies to all nine temporal columns in the section, data, and migration entities. It defaults to `"timestamp"`; choose a TypeORM `ColumnType` supported by your database driver, such as `"timestamptz"` for PostgreSQL or `"datetime"` for SQL.js/SQLite. Changing it for an existing database still requires the corresponding schema migration.
1027
+ `timestampColumnType` applies to all nine temporal columns in the section, data, and migration entities. It defaults to `Date`, which TypeORM maps to the timestamp type of each driver: `timestamp` on PostgreSQL and `datetime` on MySQL, MariaDB, SQLite (`better-sqlite3`) and SQL.js, so the default entities work on every one of them. Set a driver-specific type, such as `"timestamptz"` for PostgreSQL, only when the application needs it. Changing it for an existing database still requires the corresponding schema migration.
1028
1028
 
1029
1029
  ### What happens if the database is unavailable?
1030
1030
 
package/dist/index.js CHANGED
@@ -9,6 +9,7 @@ export { ConfigMigrationService } from './modules/config/migration/migration.ser
9
9
  export { createConfigSectionEntity } from './modules/config/section/entity/entity.js';
10
10
  export { API_PROPERTY_CONSTANT } from './shared/constant/api-property.constant.js';
11
11
  export { CONFIG_DATA_CONSTANT } from './shared/constant/config/data.constant.js';
12
+ export { CONFIG_ENTITY_CONSTANT } from './shared/constant/config/entity.constant.js';
12
13
  export { CONFIG_MIGRATION_CONSTANT } from './shared/constant/config/migration.constant.js';
13
14
  export { CONFIG_SECTION_CONSTANT } from './shared/constant/config/section.constant.js';
14
15
  export { CRYPTO_CONSTANT } from './shared/constant/crypto.constant.js';
@@ -11,6 +11,7 @@ import { CacheModule } from '@nestjs/cache-manager';
11
11
  import { Global, Module } from '@nestjs/common';
12
12
  import { getRepositoryToken, getDataSourceToken } from '@nestjs/typeorm';
13
13
  import { CONFIG_DATA_CONSTANT } from '../../shared/constant/config/data.constant.js';
14
+ import { CONFIG_ENTITY_CONSTANT } from '../../shared/constant/config/entity.constant.js';
14
15
  import { CONFIG_MIGRATION_CONSTANT } from '../../shared/constant/config/migration.constant.js';
15
16
  import { CONFIG_SECTION_CONSTANT } from '../../shared/constant/config/section.constant.js';
16
17
  import { TOKEN_CONSTANT } from '../../shared/constant/token.constant.js';
@@ -24,7 +25,8 @@ var CrudConfigModule_1;
24
25
  let CrudConfigModule = CrudConfigModule_1 = class CrudConfigModule {
25
26
  static register(options) {
26
27
  const prefix = options.entityOptions?.tablePrefix ?? "";
27
- const timestampColumnType = options.entityOptions?.timestampColumnType ?? "timestamp";
28
+ const timestampColumnType = options.entityOptions?.timestampColumnType ??
29
+ CONFIG_ENTITY_CONSTANT.DEFAULT_TIMESTAMP_COLUMN_TYPE;
28
30
  const sectionEntity = createConfigSectionEntity({
29
31
  maxDescriptionLength: options.entityOptions?.configSection?.maxDescriptionLength ??
30
32
  CONFIG_SECTION_CONSTANT.MAX_DESCRIPTION_LENGTH,
@@ -183,7 +185,7 @@ let CrudConfigModule = CrudConfigModule_1 = class CrudConfigModule {
183
185
  static registerAsync(properties) {
184
186
  const staticEntityOptions = properties.staticOptions?.entityOptions;
185
187
  const prefix = staticEntityOptions?.tablePrefix ?? "";
186
- const timestampColumnType = staticEntityOptions?.timestampColumnType ?? "timestamp";
188
+ const timestampColumnType = staticEntityOptions?.timestampColumnType ?? CONFIG_ENTITY_CONSTANT.DEFAULT_TIMESTAMP_COLUMN_TYPE;
187
189
  const sectionEntity = createConfigSectionEntity({
188
190
  maxDescriptionLength: staticEntityOptions?.configSection?.maxDescriptionLength ??
189
191
  CONFIG_SECTION_CONSTANT.MAX_DESCRIPTION_LENGTH,
@@ -11,7 +11,7 @@ import { IConfigData } from '../interface/index.js';
11
11
  * @param {number} options.maxNameLength - Maximum length for name field
12
12
  * @param {number} options.maxValueLength - Maximum length for value field
13
13
  * @param {string} options.tableName - Name of the database table
14
- * @param {ColumnType} [options.timestampColumnType] - TypeORM type for timestamp fields; defaults to `timestamp`
14
+ * @param {ColumnType} [options.timestampColumnType] - TypeORM type for timestamp fields; defaults to `Date`, the timestamp type of the driver
15
15
  * @returns {TDynamicEntity} Dynamically created ConfigData entity class
16
16
  */
17
17
  export declare function createConfigDataEntity(options: {
@@ -1,5 +1,6 @@
1
1
  import { ApiPropertyDescribe, EApiPropertyDescribeType, EApiPropertyStringType, EApiPropertyDateIdentifier, EApiPropertyDateType } from '@elsikora/nestjs-crud-automator';
2
2
  import { API_PROPERTY_CONSTANT } from '../../../../shared/constant/api-property.constant.js';
3
+ import { CONFIG_ENTITY_CONSTANT } from '../../../../shared/constant/config/entity.constant.js';
3
4
  import { createDynamicEntityClass } from '../../../../shared/utility/create-dynamic/entity.utility.js';
4
5
  import '../../../../external/tslib/tslib.es6.js';
5
6
  import '@nestjs/common';
@@ -17,11 +18,11 @@ import '../../../../shared/utility/logger.utility.js';
17
18
  * @param {number} options.maxNameLength - Maximum length for name field
18
19
  * @param {number} options.maxValueLength - Maximum length for value field
19
20
  * @param {string} options.tableName - Name of the database table
20
- * @param {ColumnType} [options.timestampColumnType] - TypeORM type for timestamp fields; defaults to `timestamp`
21
+ * @param {ColumnType} [options.timestampColumnType] - TypeORM type for timestamp fields; defaults to `Date`, the timestamp type of the driver
21
22
  * @returns {TDynamicEntity} Dynamically created ConfigData entity class
22
23
  */
23
24
  function createConfigDataEntity(options) {
24
- const timestampColumnType = options.timestampColumnType ?? "timestamp";
25
+ const timestampColumnType = options.timestampColumnType ?? CONFIG_ENTITY_CONSTANT.DEFAULT_TIMESTAMP_COLUMN_TYPE;
25
26
  return createDynamicEntityClass({
26
27
  columns: {
27
28
  createdAt: {
@@ -6,7 +6,7 @@ import { IConfigMigration } from '../interface/index.js';
6
6
  * @param {object} options - Configuration options for the entity
7
7
  * @param {number} options.maxNameLength - Maximum length for migration name field
8
8
  * @param {string} options.tableName - Name of the database table
9
- * @param {ColumnType} [options.timestampColumnType] - TypeORM type for timestamp fields; defaults to `timestamp`
9
+ * @param {ColumnType} [options.timestampColumnType] - TypeORM type for timestamp fields; defaults to `Date`, the timestamp type of the driver
10
10
  * @returns {TDynamicEntity} Dynamically created ConfigMigration entity class
11
11
  */
12
12
  export declare function createConfigMigrationEntity(options: {
@@ -1,5 +1,6 @@
1
1
  import { ApiPropertyDescribe, EApiPropertyDescribeType, EApiPropertyDateIdentifier, EApiPropertyDateType, EApiPropertyStringType } from '@elsikora/nestjs-crud-automator';
2
2
  import { API_PROPERTY_CONSTANT } from '../../../../shared/constant/api-property.constant.js';
3
+ import { CONFIG_ENTITY_CONSTANT } from '../../../../shared/constant/config/entity.constant.js';
3
4
  import { CONFIG_MIGRATION_CONSTANT } from '../../../../shared/constant/config/migration.constant.js';
4
5
  import { createDynamicEntityClass } from '../../../../shared/utility/create-dynamic/entity.utility.js';
5
6
  import '../../../../external/tslib/tslib.es6.js';
@@ -14,11 +15,11 @@ import '../../../../shared/utility/logger.utility.js';
14
15
  * @param {object} options - Configuration options for the entity
15
16
  * @param {number} options.maxNameLength - Maximum length for migration name field
16
17
  * @param {string} options.tableName - Name of the database table
17
- * @param {ColumnType} [options.timestampColumnType] - TypeORM type for timestamp fields; defaults to `timestamp`
18
+ * @param {ColumnType} [options.timestampColumnType] - TypeORM type for timestamp fields; defaults to `Date`, the timestamp type of the driver
18
19
  * @returns {TDynamicEntity} Dynamically created ConfigMigration entity class
19
20
  */
20
21
  function createConfigMigrationEntity(options) {
21
- const timestampColumnType = options.timestampColumnType ?? "timestamp";
22
+ const timestampColumnType = options.timestampColumnType ?? CONFIG_ENTITY_CONSTANT.DEFAULT_TIMESTAMP_COLUMN_TYPE;
22
23
  return createDynamicEntityClass({
23
24
  columns: {
24
25
  createdAt: {
@@ -47,7 +48,7 @@ function createConfigMigrationEntity(options) {
47
48
  default: "PENDING",
48
49
  enum: ["PENDING", "RUNNING", "COMPLETED", "FAILED", "STUCK"],
49
50
  nullable: false,
50
- type: "enum",
51
+ type: "simple-enum",
51
52
  },
52
53
  updatedAt: {
53
54
  default: () => "CURRENT_TIMESTAMP",
@@ -1,23 +1,25 @@
1
1
  import { __decorate, __param, __metadata } from '../../../external/tslib/tslib.es6.js';
2
2
  import { ApiFunctionTransactionScope } from '@elsikora/nestjs-crud-automator';
3
3
  import { CrudConfigService } from '../config.service.js';
4
- import { Injectable, Inject, Logger } from '@nestjs/common';
4
+ import { Injectable, Inject } from '@nestjs/common';
5
5
  import { CONFIG_MIGRATION_CONSTANT } from '../../../shared/constant/config/migration.constant.js';
6
6
  import { TOKEN_CONSTANT } from '../../../shared/constant/token.constant.js';
7
7
  import { DataSource } from 'typeorm';
8
+ import '@nestjs/typeorm';
9
+ import '../../../shared/utility/crypto.utility.js';
10
+ import { LoggerUtility } from '../../../shared/utility/logger.utility.js';
8
11
  import { EConfigMigrationStatus } from './enum/status.js';
9
12
 
10
- var ConfigMigrationService_1;
11
13
  /**
12
14
  * Service responsible for coordinating and tracking execution of migrations.
13
15
  * @see {@link https://elsikora.com/docs/nestjs-crud-config/migration-system | Migration System}
14
16
  * @see {@link https://elsikora.com/docs/nestjs-crud-config/api-reference/classes/config-migration-service | API Reference - ConfigMigrationService}
15
17
  */
16
- let ConfigMigrationService = ConfigMigrationService_1 = class ConfigMigrationService {
18
+ let ConfigMigrationService = class ConfigMigrationService {
17
19
  dataSource;
18
20
  options;
19
21
  configService;
20
- LOGGER = new Logger(ConfigMigrationService_1.name);
22
+ LOGGER = LoggerUtility.getLogger("ConfigMigrationService");
21
23
  MIGRATION_SERVICE;
22
24
  constructor(dataSource, options, configService, migrationService) {
23
25
  this.dataSource = dataSource;
@@ -362,7 +364,7 @@ let ConfigMigrationService = ConfigMigrationService_1 = class ConfigMigrationSer
362
364
  }
363
365
  }
364
366
  };
365
- ConfigMigrationService = ConfigMigrationService_1 = __decorate([
367
+ ConfigMigrationService = __decorate([
366
368
  Injectable(),
367
369
  __param(0, Inject(DataSource)),
368
370
  __param(1, Inject(TOKEN_CONSTANT.CONFIG_OPTIONS)),
@@ -7,7 +7,7 @@ import { IConfigSection } from '../interface/index.js';
7
7
  * @param {number} options.maxDescriptionLength - Maximum length for description field
8
8
  * @param {number} options.maxNameLength - Maximum length for name field
9
9
  * @param {string} options.tableName - Name of the database table
10
- * @param {ColumnType} [options.timestampColumnType] - TypeORM type for timestamp fields; defaults to `timestamp`
10
+ * @param {ColumnType} [options.timestampColumnType] - TypeORM type for timestamp fields; defaults to `Date`, the timestamp type of the driver
11
11
  * @returns {TDynamicEntity} Dynamically created ConfigSection entity class
12
12
  */
13
13
  export declare function createConfigSectionEntity(options: {
@@ -1,5 +1,6 @@
1
1
  import { ApiPropertyDescribe, EApiPropertyDescribeType, EApiPropertyDateIdentifier, EApiPropertyDateType, EApiPropertyStringType } from '@elsikora/nestjs-crud-automator';
2
2
  import { API_PROPERTY_CONSTANT } from '../../../../shared/constant/api-property.constant.js';
3
+ import { CONFIG_ENTITY_CONSTANT } from '../../../../shared/constant/config/entity.constant.js';
3
4
  import { createDynamicEntityClass } from '../../../../shared/utility/create-dynamic/entity.utility.js';
4
5
  import '../../../../external/tslib/tslib.es6.js';
5
6
  import '@nestjs/common';
@@ -14,11 +15,11 @@ import '../../../../shared/utility/logger.utility.js';
14
15
  * @param {number} options.maxDescriptionLength - Maximum length for description field
15
16
  * @param {number} options.maxNameLength - Maximum length for name field
16
17
  * @param {string} options.tableName - Name of the database table
17
- * @param {ColumnType} [options.timestampColumnType] - TypeORM type for timestamp fields; defaults to `timestamp`
18
+ * @param {ColumnType} [options.timestampColumnType] - TypeORM type for timestamp fields; defaults to `Date`, the timestamp type of the driver
18
19
  * @returns {TDynamicEntity} Dynamically created ConfigSection entity class
19
20
  */
20
21
  function createConfigSectionEntity(options) {
21
- const timestampColumnType = options.timestampColumnType ?? "timestamp";
22
+ const timestampColumnType = options.timestampColumnType ?? CONFIG_ENTITY_CONSTANT.DEFAULT_TIMESTAMP_COLUMN_TYPE;
22
23
  return createDynamicEntityClass({
23
24
  columns: {
24
25
  createdAt: {
@@ -0,0 +1,4 @@
1
+ import { ColumnType } from 'typeorm';
2
+ export declare const CONFIG_ENTITY_CONSTANT: {
3
+ readonly DEFAULT_TIMESTAMP_COLUMN_TYPE: ColumnType;
4
+ };
@@ -0,0 +1,7 @@
1
+ // TypeORM maps Date to each driver's timestamp type: timestamp on PostgreSQL, datetime on MySQL, MariaDB and SQLite
2
+ const DEFAULT_TIMESTAMP_COLUMN_TYPE = Date;
3
+ const CONFIG_ENTITY_CONSTANT = {
4
+ DEFAULT_TIMESTAMP_COLUMN_TYPE,
5
+ };
6
+
7
+ export { CONFIG_ENTITY_CONSTANT };
@@ -1,3 +1,4 @@
1
1
  export { CONFIG_DATA_CONSTANT } from './data.constant.js';
2
+ export { CONFIG_ENTITY_CONSTANT } from './entity.constant.js';
2
3
  export { CONFIG_MIGRATION_CONSTANT } from './migration.constant.js';
3
4
  export { CONFIG_SECTION_CONSTANT } from './section.constant.js';
@@ -19,7 +19,8 @@ export interface ICrudConfigEntityOptions {
19
19
  tablePrefix?: string;
20
20
  /**
21
21
  * TypeORM column type used by all ConfigSection, ConfigData, and ConfigMigration timestamp fields.
22
- * Defaults to `timestamp`.
22
+ * Defaults to `Date`, which TypeORM maps to the timestamp type of the driver: `timestamp` on PostgreSQL,
23
+ * `datetime` on MySQL, MariaDB and SQLite.
23
24
  */
24
25
  timestampColumnType?: ColumnType;
25
26
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elsikora/nestjs-crud-config",
3
- "version": "5.0.0-dev.1",
3
+ "version": "5.0.0-dev.3",
4
4
  "description": "NestJS application configuration via database storage",
5
5
  "homepage": "https://github.com/ElsiKora/NestJS-Crud-Config#readme",
6
6
  "bugs": {
@@ -8,7 +8,7 @@
8
8
  },
9
9
  "repository": {
10
10
  "type": "git",
11
- "url": "https://github.com/ElsiKora/NestJS-Crud-Config"
11
+ "url": "git+https://github.com/ElsiKora/NestJS-Crud-Config.git"
12
12
  },
13
13
  "license": "MIT",
14
14
  "author": "ElsiKora",
@@ -70,6 +70,7 @@
70
70
  "@fastify/static": "^10.1.8",
71
71
  "@nestjs/cli": "^12.0.11",
72
72
  "@nestjs/common": "^12.3.2",
73
+ "@nestjs/config": "^12.0.1",
73
74
  "@nestjs/core": "^12.3.2",
74
75
  "@nestjs/passport": "^12.0.0",
75
76
  "@nestjs/platform-fastify": "^12.3.2",