@flusys/nestjs-core 7.1.0 → 8.0.0
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 +2 -2
- package/config/index.d.ts +1 -1
- package/constants/index.d.ts +1 -1
- package/docs/docs.config.d.ts +1 -1
- package/docs/index.d.ts +1 -1
- package/fesm/229.js +729 -0
- package/fesm/config/index.js +126 -1
- package/fesm/constants/index.js +29 -1
- package/fesm/docs/index.js +288 -1
- package/fesm/index.js +124 -5
- package/fesm/interfaces/index.js +18 -4
- package/fesm/migration/cli.js +19 -2
- package/fesm/migration/index.js +45 -3
- package/fesm/runtime.js +85 -0
- package/fesm/utils/index.js +131 -1
- package/index.d.ts +5 -5
- package/interfaces/app-config.interfaces.d.ts +1 -1
- package/interfaces/index.d.ts +4 -4
- package/interfaces/migration.interface.d.ts +2 -2
- package/migration/cli.d.ts +0 -1
- package/migration/datasource.factory.d.ts +1 -1
- package/migration/index.d.ts +3 -3
- package/migration/migration.cli.d.ts +1 -1
- package/migration/migration.runner.d.ts +1 -1
- package/package.json +24 -32
- package/utils/datasource-config.builder.d.ts +2 -2
- package/utils/index.d.ts +1 -1
- package/cjs/config/env-config.service.js +0 -162
- package/cjs/config/env-config.service.spec.js +0 -325
- package/cjs/config/index.js +0 -18
- package/cjs/constants/database.constants.js +0 -20
- package/cjs/constants/index.js +0 -18
- package/cjs/docs/docs.config.js +0 -276
- package/cjs/docs/docs.config.spec.js +0 -923
- package/cjs/docs/index.js +0 -18
- package/cjs/index.js +0 -23
- package/cjs/interfaces/app-config.interfaces.js +0 -4
- package/cjs/interfaces/base-entity.interface.js +0 -9
- package/cjs/interfaces/database.interface.js +0 -4
- package/cjs/interfaces/index.js +0 -21
- package/cjs/interfaces/migration.interface.js +0 -4
- package/cjs/migration/cli.js +0 -10
- package/cjs/migration/datasource.factory.js +0 -43
- package/cjs/migration/datasource.factory.spec.js +0 -113
- package/cjs/migration/index.js +0 -45
- package/cjs/migration/migration.cli.js +0 -231
- package/cjs/migration/migration.cli.spec.js +0 -293
- package/cjs/migration/migration.runner.js +0 -276
- package/cjs/migration/migration.runner.spec.js +0 -268
- package/cjs/utils/datasource-config.builder.js +0 -103
- package/cjs/utils/datasource-config.builder.spec.js +0 -232
- package/cjs/utils/index.js +0 -18
- package/fesm/config/env-config.service.js +0 -112
- package/fesm/config/env-config.service.spec.js +0 -321
- package/fesm/constants/database.constants.js +0 -2
- package/fesm/docs/docs.config.js +0 -258
- package/fesm/docs/docs.config.spec.js +0 -919
- package/fesm/interfaces/app-config.interfaces.js +0 -1
- package/fesm/interfaces/base-entity.interface.js +0 -6
- package/fesm/interfaces/database.interface.js +0 -1
- package/fesm/interfaces/migration.interface.js +0 -1
- package/fesm/migration/datasource.factory.js +0 -25
- package/fesm/migration/datasource.factory.spec.js +0 -109
- package/fesm/migration/migration.cli.js +0 -180
- package/fesm/migration/migration.cli.spec.js +0 -289
- package/fesm/migration/migration.runner.js +0 -202
- package/fesm/migration/migration.runner.spec.js +0 -264
- package/fesm/utils/datasource-config.builder.js +0 -84
- package/fesm/utils/datasource-config.builder.spec.js +0 -228
package/fesm/migration/index.js
CHANGED
|
@@ -1,3 +1,45 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
1
|
+
export const __rspack_esm_id = 545;
|
|
2
|
+
export const __rspack_esm_ids = [545];
|
|
3
|
+
export const __webpack_modules__ = {
|
|
4
|
+
256(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
5
|
+
/* import */ var _datasource_factory_js__rspack_import_0 = __webpack_require__(193);
|
|
6
|
+
/* import */ var _migration_cli_js__rspack_import_1 = __webpack_require__(164);
|
|
7
|
+
/* import */ var _migration_runner_js__rspack_import_2 = __webpack_require__(654);
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
13
|
+
$7: () => (/* reexport safe */ _migration_runner_js__rspack_import_2.$7),
|
|
14
|
+
$N: () => (/* reexport safe */ _migration_runner_js__rspack_import_2.$N),
|
|
15
|
+
Mg: () => (/* reexport safe */ _migration_runner_js__rspack_import_2.Mg),
|
|
16
|
+
O7: () => (/* reexport safe */ _datasource_factory_js__rspack_import_0.O),
|
|
17
|
+
XR: () => (/* reexport safe */ _migration_runner_js__rspack_import_2.XR),
|
|
18
|
+
iL: () => (/* reexport safe */ _migration_runner_js__rspack_import_2.iL),
|
|
19
|
+
vI: () => (/* reexport safe */ _migration_runner_js__rspack_import_2.vI),
|
|
20
|
+
vd: () => (/* reexport safe */ _migration_runner_js__rspack_import_2.vd),
|
|
21
|
+
wX: () => (/* reexport safe */ _migration_cli_js__rspack_import_1.w),
|
|
22
|
+
ws: () => (/* reexport safe */ _datasource_factory_js__rspack_import_0.w)
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
};
|
|
29
|
+
import { __webpack_require__ } from '../runtime.js';
|
|
30
|
+
var __webpack_exec__ = function(moduleId) { return __webpack_require__(__webpack_require__.s = moduleId); }
|
|
31
|
+
import * as __rspack_chunk_1 from '../229.js';
|
|
32
|
+
__webpack_require__.C(__rspack_chunk_1);
|
|
33
|
+
import * as __rspack_chunk_2 from './index.js';
|
|
34
|
+
__webpack_require__.C(__rspack_chunk_2);
|
|
35
|
+
var __webpack_exports__ = __webpack_exec__(256);var __webpack_exports__createMigrationDataSource = __webpack_exports__.O7;
|
|
36
|
+
var __webpack_exports__ensureMigrationsFolder = __webpack_exports__.Mg;
|
|
37
|
+
var __webpack_exports__generateMigration = __webpack_exports__.iL;
|
|
38
|
+
var __webpack_exports__initializeDataSource = __webpack_exports__.ws;
|
|
39
|
+
var __webpack_exports__migrationStatus = __webpack_exports__.vd;
|
|
40
|
+
var __webpack_exports__resetDatabase = __webpack_exports__.$7;
|
|
41
|
+
var __webpack_exports__revertMigration = __webpack_exports__.$N;
|
|
42
|
+
var __webpack_exports__runForAllTenants = __webpack_exports__.XR;
|
|
43
|
+
var __webpack_exports__runMigrationCli = __webpack_exports__.wX;
|
|
44
|
+
var __webpack_exports__runMigrations = __webpack_exports__.vI;
|
|
45
|
+
export { __webpack_exports__createMigrationDataSource as createMigrationDataSource, __webpack_exports__ensureMigrationsFolder as ensureMigrationsFolder, __webpack_exports__generateMigration as generateMigration, __webpack_exports__initializeDataSource as initializeDataSource, __webpack_exports__migrationStatus as migrationStatus, __webpack_exports__resetDatabase as resetDatabase, __webpack_exports__revertMigration as revertMigration, __webpack_exports__runForAllTenants as runForAllTenants, __webpack_exports__runMigrationCli as runMigrationCli, __webpack_exports__runMigrations as runMigrations };
|
package/fesm/runtime.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
var __webpack_modules__ = ({});
|
|
2
|
+
// The module cache
|
|
3
|
+
var __webpack_module_cache__ = {};
|
|
4
|
+
|
|
5
|
+
// The require function
|
|
6
|
+
function __webpack_require__(moduleId) {
|
|
7
|
+
|
|
8
|
+
// Check if module is in cache
|
|
9
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
10
|
+
if (cachedModule !== undefined) {
|
|
11
|
+
return cachedModule.exports;
|
|
12
|
+
}
|
|
13
|
+
// Create a new module (and put it into the cache)
|
|
14
|
+
var module = (__webpack_module_cache__[moduleId] = {
|
|
15
|
+
exports: {}
|
|
16
|
+
});
|
|
17
|
+
// Execute the module function
|
|
18
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
19
|
+
|
|
20
|
+
// Return the exports of the module
|
|
21
|
+
return module.exports;
|
|
22
|
+
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// expose the modules object (__webpack_modules__)
|
|
26
|
+
__webpack_require__.m = __webpack_modules__;
|
|
27
|
+
|
|
28
|
+
// webpack/runtime/define_property_getters
|
|
29
|
+
(() => {
|
|
30
|
+
__webpack_require__.d = (exports, getters, values) => {
|
|
31
|
+
var define = (defs, kind) => {
|
|
32
|
+
for(var key in defs) {
|
|
33
|
+
if(__webpack_require__.o(defs, key) && !__webpack_require__.o(exports, key)) {
|
|
34
|
+
Object.defineProperty(exports, key, { enumerable: true, [kind]: defs[key] });
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
define(getters, "get");
|
|
39
|
+
define(values, "value");
|
|
40
|
+
};
|
|
41
|
+
})();
|
|
42
|
+
// webpack/runtime/export_webpack_require
|
|
43
|
+
var __webpack_require__temp = __webpack_require__;
|
|
44
|
+
export { __webpack_require__temp as __webpack_require__ };
|
|
45
|
+
// webpack/runtime/has_own_property
|
|
46
|
+
(() => {
|
|
47
|
+
__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
48
|
+
})();
|
|
49
|
+
// webpack/runtime/module_chunk_loading
|
|
50
|
+
(() => {
|
|
51
|
+
// no BaseURI
|
|
52
|
+
// object to store loaded and loading chunks
|
|
53
|
+
// undefined = chunk not loaded, null = chunk preloaded/prefetched
|
|
54
|
+
// [resolve, Promise] = chunk loading, 0 = chunk loaded
|
|
55
|
+
var moduleInstalledChunks = {146: 0,};
|
|
56
|
+
var moduleInstallChunk = (data) => {
|
|
57
|
+
var __rspack_esm_ids = data.__rspack_esm_ids;
|
|
58
|
+
var moreModules = data.__webpack_modules__;
|
|
59
|
+
var __rspack_esm_runtime = data.__rspack_esm_runtime;
|
|
60
|
+
// add "modules" to the modules object,
|
|
61
|
+
// then flag all "ids" as loaded and fire callback
|
|
62
|
+
var moduleId, chunkId, i = 0;
|
|
63
|
+
for (moduleId in moreModules) {
|
|
64
|
+
if (__webpack_require__.o(moreModules, moduleId)) {
|
|
65
|
+
__webpack_require__.m[moduleId] = moreModules[moduleId];
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (__rspack_esm_runtime) __rspack_esm_runtime(__webpack_require__);
|
|
69
|
+
for (; i < __rspack_esm_ids.length; i++) {
|
|
70
|
+
chunkId = __rspack_esm_ids[i];
|
|
71
|
+
if (__webpack_require__.o(moduleInstalledChunks, chunkId) && moduleInstalledChunks[chunkId]) {
|
|
72
|
+
moduleInstalledChunks[chunkId][0]();
|
|
73
|
+
}
|
|
74
|
+
moduleInstalledChunks[__rspack_esm_ids[i]] = 0;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
};
|
|
78
|
+
// no chunk on demand loading
|
|
79
|
+
|
|
80
|
+
__webpack_require__.C = moduleInstallChunk;
|
|
81
|
+
// no on chunks loaded
|
|
82
|
+
// no HMR
|
|
83
|
+
// no HMR manifest
|
|
84
|
+
|
|
85
|
+
})();
|
package/fesm/utils/index.js
CHANGED
|
@@ -1 +1,131 @@
|
|
|
1
|
-
export
|
|
1
|
+
export const __rspack_esm_id = 152;
|
|
2
|
+
export const __rspack_esm_ids = [152];
|
|
3
|
+
export const __webpack_modules__ = {
|
|
4
|
+
722(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
5
|
+
/**
|
|
6
|
+
* Build DataSource options from database config
|
|
7
|
+
*/ function buildDataSourceOptions(config, entities, migrationsPath, migrationsTableName = 'migrations') {
|
|
8
|
+
return {
|
|
9
|
+
type: config.type,
|
|
10
|
+
host: config.host,
|
|
11
|
+
port: config.port,
|
|
12
|
+
username: config.username,
|
|
13
|
+
password: config.password,
|
|
14
|
+
database: config.database || '',
|
|
15
|
+
entities,
|
|
16
|
+
migrations: [
|
|
17
|
+
migrationsPath
|
|
18
|
+
],
|
|
19
|
+
migrationsTableName,
|
|
20
|
+
synchronize: false
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Get migration folder path for a tenant
|
|
25
|
+
*/ function getMigrationsFolderPath(basePath, tenantId) {
|
|
26
|
+
const folder = tenantId || 'default';
|
|
27
|
+
return `${basePath}/${folder}`;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Get migrations glob pattern for a tenant
|
|
31
|
+
*/ function getMigrationsGlobPattern(basePath, tenantId) {
|
|
32
|
+
return `${getMigrationsFolderPath(basePath, tenantId)}/*{.ts,.js}`;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Get database and config for a tenant (or default)
|
|
36
|
+
*/ function getDatabaseForTenant(config, tenantId) {
|
|
37
|
+
if (tenantId && config.tenants) {
|
|
38
|
+
const tenant = config.tenants.find((t)=>t.id === tenantId);
|
|
39
|
+
if (!tenant) {
|
|
40
|
+
throw new Error(`Tenant '${tenantId}' not found. Available: ${config.tenants.map((t)=>t.id).join(', ')}`);
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
database: tenant.database,
|
|
44
|
+
tenant,
|
|
45
|
+
tenantConfig: tenant
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
// Default config - use bootstrapAppConfig for feature flags
|
|
49
|
+
const defaultTenantConfig = {
|
|
50
|
+
id: 'default',
|
|
51
|
+
database: config.defaultDatabaseConfig.database || 'default',
|
|
52
|
+
enableCompanyFeature: config.bootstrapAppConfig?.enableCompanyFeature ?? false,
|
|
53
|
+
permissionMode: config.bootstrapAppConfig?.permissionMode ?? 'FULL'
|
|
54
|
+
};
|
|
55
|
+
return {
|
|
56
|
+
database: defaultTenantConfig.database,
|
|
57
|
+
tenantConfig: defaultTenantConfig
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Resolve full connection details for a tenant.
|
|
62
|
+
*/ function resolveDatabaseConnection(config, tenantId) {
|
|
63
|
+
const { database, tenant } = getDatabaseForTenant(config, tenantId);
|
|
64
|
+
return tenant ? {
|
|
65
|
+
...config.defaultDatabaseConfig,
|
|
66
|
+
host: tenant.host ?? config.defaultDatabaseConfig.host,
|
|
67
|
+
port: tenant.port ?? config.defaultDatabaseConfig.port,
|
|
68
|
+
username: tenant.username ?? config.defaultDatabaseConfig.username,
|
|
69
|
+
password: tenant.password ?? config.defaultDatabaseConfig.password,
|
|
70
|
+
database: tenant.database
|
|
71
|
+
} : {
|
|
72
|
+
...config.defaultDatabaseConfig,
|
|
73
|
+
database
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Resolve entities based on tenant config
|
|
78
|
+
*/ function resolveEntities(config, tenantConfig) {
|
|
79
|
+
if (typeof config.entities === 'function') {
|
|
80
|
+
return config.entities(tenantConfig);
|
|
81
|
+
}
|
|
82
|
+
return config.entities;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Get active tenants from config
|
|
86
|
+
*/ function getActiveTenants(config) {
|
|
87
|
+
return config.tenants || [];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
91
|
+
LH: () => (getDatabaseForTenant),
|
|
92
|
+
Md: () => (resolveEntities),
|
|
93
|
+
Q0: () => (getMigrationsGlobPattern),
|
|
94
|
+
QP: () => (buildDataSourceOptions),
|
|
95
|
+
SP: () => (getActiveTenants),
|
|
96
|
+
jr: () => (getMigrationsFolderPath),
|
|
97
|
+
ul: () => (resolveDatabaseConnection)
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
},
|
|
102
|
+
313(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
103
|
+
/* import */ var _datasource_config_builder_js__rspack_import_0 = __webpack_require__(722);
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
107
|
+
LH: () => (/* reexport safe */ _datasource_config_builder_js__rspack_import_0.LH),
|
|
108
|
+
Md: () => (/* reexport safe */ _datasource_config_builder_js__rspack_import_0.Md),
|
|
109
|
+
Q0: () => (/* reexport safe */ _datasource_config_builder_js__rspack_import_0.Q0),
|
|
110
|
+
QP: () => (/* reexport safe */ _datasource_config_builder_js__rspack_import_0.QP),
|
|
111
|
+
SP: () => (/* reexport safe */ _datasource_config_builder_js__rspack_import_0.SP),
|
|
112
|
+
jr: () => (/* reexport safe */ _datasource_config_builder_js__rspack_import_0.jr),
|
|
113
|
+
ul: () => (/* reexport safe */ _datasource_config_builder_js__rspack_import_0.ul)
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
},
|
|
118
|
+
|
|
119
|
+
};
|
|
120
|
+
import { __webpack_require__ } from '../runtime.js';
|
|
121
|
+
var __webpack_exec__ = function(moduleId) { return __webpack_require__(__webpack_require__.s = moduleId); }
|
|
122
|
+
import * as __rspack_chunk_1 from './index.js';
|
|
123
|
+
__webpack_require__.C(__rspack_chunk_1);
|
|
124
|
+
var __webpack_exports__ = __webpack_exec__(313);var __webpack_exports__buildDataSourceOptions = __webpack_exports__.QP;
|
|
125
|
+
var __webpack_exports__getActiveTenants = __webpack_exports__.SP;
|
|
126
|
+
var __webpack_exports__getDatabaseForTenant = __webpack_exports__.LH;
|
|
127
|
+
var __webpack_exports__getMigrationsFolderPath = __webpack_exports__.jr;
|
|
128
|
+
var __webpack_exports__getMigrationsGlobPattern = __webpack_exports__.Q0;
|
|
129
|
+
var __webpack_exports__resolveDatabaseConnection = __webpack_exports__.ul;
|
|
130
|
+
var __webpack_exports__resolveEntities = __webpack_exports__.Md;
|
|
131
|
+
export { __webpack_exports__buildDataSourceOptions as buildDataSourceOptions, __webpack_exports__getActiveTenants as getActiveTenants, __webpack_exports__getDatabaseForTenant as getDatabaseForTenant, __webpack_exports__getMigrationsFolderPath as getMigrationsFolderPath, __webpack_exports__getMigrationsGlobPattern as getMigrationsGlobPattern, __webpack_exports__resolveDatabaseConnection as resolveDatabaseConnection, __webpack_exports__resolveEntities as resolveEntities };
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './interfaces';
|
|
2
|
-
export * from './constants';
|
|
3
|
-
export * from './utils';
|
|
4
|
-
export * from './migration';
|
|
5
|
-
export * from './config';
|
|
1
|
+
export * from './interfaces/index.js';
|
|
2
|
+
export * from './constants/index.js';
|
|
3
|
+
export * from './utils/index.js';
|
|
4
|
+
export * from './migration/index.js';
|
|
5
|
+
export * from './config/index.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DatabaseMode, IDatabaseConfig, ITenantDatabaseConfig } from './database.interface';
|
|
1
|
+
import { type DatabaseMode, type IDatabaseConfig, type ITenantDatabaseConfig } from './database.interface.js';
|
|
2
2
|
export interface IBootstrapAppConfig {
|
|
3
3
|
databaseMode: DatabaseMode;
|
|
4
4
|
enableCompanyFeature: boolean;
|
package/interfaces/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './app-config.interfaces';
|
|
2
|
-
export * from './base-entity.interface';
|
|
3
|
-
export * from './database.interface';
|
|
4
|
-
export * from './migration.interface';
|
|
1
|
+
export * from './app-config.interfaces.js';
|
|
2
|
+
export * from './base-entity.interface.js';
|
|
3
|
+
export * from './database.interface.js';
|
|
4
|
+
export * from './migration.interface.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IBootstrapAppConfig } from './app-config.interfaces';
|
|
2
|
-
import { IDatabaseConfig, ITenantDatabaseConfig } from './database.interface';
|
|
1
|
+
import { type IBootstrapAppConfig } from './app-config.interfaces.js';
|
|
2
|
+
import { type IDatabaseConfig, type ITenantDatabaseConfig } from './database.interface.js';
|
|
3
3
|
export type EntityResolver = (tenantConfig?: ITenantDatabaseConfig) => any[];
|
|
4
4
|
export interface IMigrationConfig {
|
|
5
5
|
defaultDatabaseConfig: IDatabaseConfig;
|
package/migration/cli.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DataSource } from 'typeorm';
|
|
2
|
-
import { IMigrationConfig } from '../interfaces/migration.interface';
|
|
2
|
+
import { type IMigrationConfig } from '../interfaces/migration.interface.js';
|
|
3
3
|
export interface CreateDataSourceOptions {
|
|
4
4
|
config: IMigrationConfig;
|
|
5
5
|
tenantId?: string;
|
package/migration/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { createMigrationDataSource, initializeDataSource } from './datasource.factory';
|
|
2
|
-
export { runMigrationCli } from './migration.cli';
|
|
3
|
-
export { generateMigration, runMigrations, revertMigration, resetDatabase, migrationStatus, runForAllTenants, ensureMigrationsFolder, } from './migration.runner';
|
|
1
|
+
export { createMigrationDataSource, initializeDataSource } from './datasource.factory.js';
|
|
2
|
+
export { runMigrationCli } from './migration.cli.js';
|
|
3
|
+
export { generateMigration, runMigrations, revertMigration, resetDatabase, migrationStatus, runForAllTenants, ensureMigrationsFolder, } from './migration.runner.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { IMigrationConfig } from '../interfaces/migration.interface';
|
|
1
|
+
import { type IMigrationConfig } from '../interfaces/migration.interface.js';
|
|
2
2
|
export declare function runMigrationCli(configOrPath?: IMigrationConfig | string): Promise<void>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IMigrationConfig, IMigrationResult } from '../interfaces/migration.interface';
|
|
1
|
+
import { type IMigrationConfig, type IMigrationResult } from '../interfaces/migration.interface.js';
|
|
2
2
|
export declare function ensureMigrationsFolder(basePath: string, tenantId?: string): string;
|
|
3
3
|
export declare function generateMigration(config: IMigrationConfig, name: string, tenantId?: string, datasourcePath?: string): Promise<void>;
|
|
4
4
|
export declare function runMigrations(config: IMigrationConfig, tenantId?: string): Promise<IMigrationResult>;
|
package/package.json
CHANGED
|
@@ -1,72 +1,64 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flusys/nestjs-core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"description": "Core types, interfaces, and constants for Flusys NestJS packages",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./fesm/index.js",
|
|
7
|
+
"module": "./fesm/index.js",
|
|
8
|
+
"types": "./index.d.ts",
|
|
8
9
|
"sideEffects": false,
|
|
9
10
|
"keywords": [
|
|
10
11
|
"nestjs",
|
|
12
|
+
"@flusys",
|
|
11
13
|
"typescript",
|
|
12
14
|
"core",
|
|
13
|
-
"types"
|
|
14
|
-
"@flusys"
|
|
15
|
+
"types"
|
|
15
16
|
],
|
|
16
17
|
"license": "UNLICENSED",
|
|
17
18
|
"bin": {
|
|
18
|
-
"flusys-migration": "./
|
|
19
|
-
"flusys-seed": "./cjs/seeders/cli.js"
|
|
19
|
+
"flusys-migration": "./fesm/migration/cli.js"
|
|
20
20
|
},
|
|
21
21
|
"exports": {
|
|
22
22
|
".": {
|
|
23
23
|
"types": "./index.d.ts",
|
|
24
|
-
"import": "./fesm/index.js"
|
|
25
|
-
"require": "./cjs/index.js"
|
|
24
|
+
"import": "./fesm/index.js"
|
|
26
25
|
},
|
|
27
26
|
"./config": {
|
|
28
27
|
"types": "./config/index.d.ts",
|
|
29
|
-
"import": "./fesm/config/index.js"
|
|
30
|
-
"require": "./cjs/config/index.js"
|
|
28
|
+
"import": "./fesm/config/index.js"
|
|
31
29
|
},
|
|
32
30
|
"./constants": {
|
|
33
31
|
"types": "./constants/index.d.ts",
|
|
34
|
-
"import": "./fesm/constants/index.js"
|
|
35
|
-
"require": "./cjs/constants/index.js"
|
|
32
|
+
"import": "./fesm/constants/index.js"
|
|
36
33
|
},
|
|
37
34
|
"./docs": {
|
|
38
35
|
"types": "./docs/index.d.ts",
|
|
39
|
-
"import": "./fesm/docs/index.js"
|
|
40
|
-
"require": "./cjs/docs/index.js"
|
|
36
|
+
"import": "./fesm/docs/index.js"
|
|
41
37
|
},
|
|
42
38
|
"./interfaces": {
|
|
43
39
|
"types": "./interfaces/index.d.ts",
|
|
44
|
-
"import": "./fesm/interfaces/index.js"
|
|
45
|
-
"require": "./cjs/interfaces/index.js"
|
|
40
|
+
"import": "./fesm/interfaces/index.js"
|
|
46
41
|
},
|
|
47
42
|
"./migration": {
|
|
48
43
|
"types": "./migration/index.d.ts",
|
|
49
|
-
"import": "./fesm/migration/index.js"
|
|
50
|
-
"require": "./cjs/migration/index.js"
|
|
51
|
-
},
|
|
52
|
-
"./seeders": {
|
|
53
|
-
"types": "./seeders/index.d.ts",
|
|
54
|
-
"import": "./fesm/seeders/index.js",
|
|
55
|
-
"require": "./cjs/seeders/index.js"
|
|
44
|
+
"import": "./fesm/migration/index.js"
|
|
56
45
|
},
|
|
57
46
|
"./utils": {
|
|
58
47
|
"types": "./utils/index.d.ts",
|
|
59
|
-
"import": "./fesm/utils/index.js"
|
|
60
|
-
|
|
48
|
+
"import": "./fesm/utils/index.js"
|
|
49
|
+
},
|
|
50
|
+
"./*": {
|
|
51
|
+
"types": "./*.d.ts",
|
|
52
|
+
"import": "./fesm/*.js"
|
|
61
53
|
}
|
|
62
54
|
},
|
|
63
55
|
"peerDependencies": {
|
|
64
56
|
"@faker-js/faker": "^10.0.0",
|
|
65
|
-
"@nestjs/common": "^
|
|
66
|
-
"@nestjs/config": "^
|
|
67
|
-
"@nestjs/core": "^
|
|
68
|
-
"@nestjs/swagger": "^
|
|
69
|
-
"@nestjs/typeorm": "^
|
|
57
|
+
"@nestjs/common": "^12.0.0",
|
|
58
|
+
"@nestjs/config": "^12.0.0",
|
|
59
|
+
"@nestjs/core": "^12.0.0",
|
|
60
|
+
"@nestjs/swagger": "^12.0.0",
|
|
61
|
+
"@nestjs/typeorm": "^12.0.0",
|
|
70
62
|
"dotenv": "^17.1.0",
|
|
71
63
|
"typeorm": "^0.3.0",
|
|
72
64
|
"typeorm-naming-strategies": "^4.1.0"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IDatabaseConfig, IDataSourceBuildOptions, ITenantDatabaseConfig } from '../interfaces/database.interface';
|
|
2
|
-
import { IMigrationConfig } from '../interfaces/migration.interface';
|
|
1
|
+
import { type IDatabaseConfig, type IDataSourceBuildOptions, type ITenantDatabaseConfig } from '../interfaces/database.interface.js';
|
|
2
|
+
import { type IMigrationConfig } from '../interfaces/migration.interface.js';
|
|
3
3
|
export declare function buildDataSourceOptions(config: IDatabaseConfig, entities: any[], migrationsPath: string, migrationsTableName?: string): IDataSourceBuildOptions;
|
|
4
4
|
export declare function getMigrationsFolderPath(basePath: string, tenantId?: string): string;
|
|
5
5
|
export declare function getMigrationsGlobPattern(basePath: string, tenantId?: string): string;
|
package/utils/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './datasource-config.builder';
|
|
1
|
+
export * from './datasource-config.builder.js';
|
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "envConfig", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return envConfig;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _dotenv = /*#__PURE__*/ _interop_require_wildcard(require("dotenv"));
|
|
12
|
-
function _define_property(obj, key, value) {
|
|
13
|
-
if (key in obj) {
|
|
14
|
-
Object.defineProperty(obj, key, {
|
|
15
|
-
value: value,
|
|
16
|
-
enumerable: true,
|
|
17
|
-
configurable: true,
|
|
18
|
-
writable: true
|
|
19
|
-
});
|
|
20
|
-
} else {
|
|
21
|
-
obj[key] = value;
|
|
22
|
-
}
|
|
23
|
-
return obj;
|
|
24
|
-
}
|
|
25
|
-
function _getRequireWildcardCache(nodeInterop) {
|
|
26
|
-
if (typeof WeakMap !== "function") return null;
|
|
27
|
-
var cacheBabelInterop = new WeakMap();
|
|
28
|
-
var cacheNodeInterop = new WeakMap();
|
|
29
|
-
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
30
|
-
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
31
|
-
})(nodeInterop);
|
|
32
|
-
}
|
|
33
|
-
function _interop_require_wildcard(obj, nodeInterop) {
|
|
34
|
-
if (!nodeInterop && obj && obj.__esModule) {
|
|
35
|
-
return obj;
|
|
36
|
-
}
|
|
37
|
-
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
38
|
-
return {
|
|
39
|
-
default: obj
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
var cache = _getRequireWildcardCache(nodeInterop);
|
|
43
|
-
if (cache && cache.has(obj)) {
|
|
44
|
-
return cache.get(obj);
|
|
45
|
-
}
|
|
46
|
-
var newObj = {
|
|
47
|
-
__proto__: null
|
|
48
|
-
};
|
|
49
|
-
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
50
|
-
for(var key in obj){
|
|
51
|
-
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
52
|
-
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
53
|
-
if (desc && (desc.get || desc.set)) {
|
|
54
|
-
Object.defineProperty(newObj, key, desc);
|
|
55
|
-
} else {
|
|
56
|
-
newObj[key] = obj[key];
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
newObj.default = obj;
|
|
61
|
-
if (cache) {
|
|
62
|
-
cache.set(obj, newObj);
|
|
63
|
-
}
|
|
64
|
-
return newObj;
|
|
65
|
-
}
|
|
66
|
-
_dotenv.config();
|
|
67
|
-
let EnvConfigService = class EnvConfigService {
|
|
68
|
-
getValue(key, throwOnMissing = true) {
|
|
69
|
-
const value = this.env[key];
|
|
70
|
-
if (!value && throwOnMissing) {
|
|
71
|
-
throw new Error(`Config error - missing env.${key}`);
|
|
72
|
-
}
|
|
73
|
-
return value ?? '';
|
|
74
|
-
}
|
|
75
|
-
tryGetValue(key, throwOnMissing = false) {
|
|
76
|
-
if (this.restrictedKeys[key]) {
|
|
77
|
-
throw new Error(`Access denied for env key "${key}". Use the method \`${this.restrictedKeys[key]}()\` instead.`);
|
|
78
|
-
}
|
|
79
|
-
return this.getValue(key, throwOnMissing);
|
|
80
|
-
}
|
|
81
|
-
getNumber(key, throwOnMissing = true) {
|
|
82
|
-
return Number(this.getValue(key, throwOnMissing));
|
|
83
|
-
}
|
|
84
|
-
getBoolean(key, throwOnMissing = true) {
|
|
85
|
-
return this.getValue(key, throwOnMissing).toLowerCase() === 'true';
|
|
86
|
-
}
|
|
87
|
-
getPort() {
|
|
88
|
-
return this.getNumber('PORT', false) || 3000;
|
|
89
|
-
}
|
|
90
|
-
isProduction() {
|
|
91
|
-
return this.getValue('MODE', false).toUpperCase() !== 'DEV';
|
|
92
|
-
}
|
|
93
|
-
getOrigins() {
|
|
94
|
-
const origins = this.getValue('ALLOW_ORIGINS');
|
|
95
|
-
return origins ? origins.split(',').map((o)=>o.trim()) : [];
|
|
96
|
-
}
|
|
97
|
-
getTypeOrmConfig() {
|
|
98
|
-
const type = this.getValue('DB_TYPE', false) || 'mysql';
|
|
99
|
-
const defaultPort = type === 'postgres' ? 5432 : 3306;
|
|
100
|
-
return {
|
|
101
|
-
type,
|
|
102
|
-
host: this.getValue('DB_HOST', false) || 'localhost',
|
|
103
|
-
port: this.getNumber('DB_PORT', false) || defaultPort,
|
|
104
|
-
username: this.getValue('DB_USER', false) || 'root',
|
|
105
|
-
password: this.getValue('DB_PASSWORD', false) || '',
|
|
106
|
-
database: this.getValue('DB_NAME', false) || 'flusys_main'
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
getJwtConfig() {
|
|
110
|
-
return {
|
|
111
|
-
secret: this.getValue('JWT_SECRET'),
|
|
112
|
-
expiration: this.getValue('JWT_EXPIRATION', false) || '1h',
|
|
113
|
-
refreshSecret: this.getValue('REFRESH_TOKEN_SECRET'),
|
|
114
|
-
refreshExpiration: this.getValue('REFRESH_TOKEN_EXPIRATION', false) || '7d'
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
getRedisUrl() {
|
|
118
|
-
return this.getValue('REDIS_URL', false) || 'redis://localhost:6379';
|
|
119
|
-
}
|
|
120
|
-
getMailConfig() {
|
|
121
|
-
return {
|
|
122
|
-
MAIL_FROM: this.getValue('MAIL_FROM', false) || '',
|
|
123
|
-
MAIL_APP_PASSWORD: this.getValue('MAIL_APP_PASSWORD', false) || ''
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
getTenantId() {
|
|
127
|
-
return this.getValue('TENANT_ID', false) || null;
|
|
128
|
-
}
|
|
129
|
-
useTenantMode() {
|
|
130
|
-
return this.getValue('USE_TENANT_MODE', false).toLowerCase() === 'true';
|
|
131
|
-
}
|
|
132
|
-
getLogConfig() {
|
|
133
|
-
return {
|
|
134
|
-
dir: this.getValue('LOG_DIR', false) || 'logs',
|
|
135
|
-
level: this.getValue('LOG_LEVEL', false) || (this.isProduction() ? 'info' : 'debug'),
|
|
136
|
-
maxSize: this.getValue('LOG_MAX_SIZE', false) || '20m',
|
|
137
|
-
maxFiles: this.getValue('LOG_MAX_FILES', false) || '14d',
|
|
138
|
-
disableHttpLogging: this.getValue('DISABLE_HTTP_LOGGING', false).toLowerCase() === 'true'
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
getEnv() {
|
|
142
|
-
return process.env;
|
|
143
|
-
}
|
|
144
|
-
constructor(env){
|
|
145
|
-
_define_property(this, "env", void 0);
|
|
146
|
-
_define_property(this, "restrictedKeys", void 0);
|
|
147
|
-
this.env = env;
|
|
148
|
-
this.restrictedKeys = {
|
|
149
|
-
FRONTEND_URL: 'getFrontendUrl',
|
|
150
|
-
ALLOW_ORIGINS: 'getOrigins',
|
|
151
|
-
PORT: 'getPort',
|
|
152
|
-
MODE: 'isProduction',
|
|
153
|
-
DB_TYPE: 'getTypeOrmConfig',
|
|
154
|
-
DB_HOST: 'getTypeOrmConfig',
|
|
155
|
-
DB_PORT: 'getTypeOrmConfig',
|
|
156
|
-
DB_USER: 'getTypeOrmConfig',
|
|
157
|
-
DB_PASSWORD: 'getTypeOrmConfig',
|
|
158
|
-
DB_NAME: 'getTypeOrmConfig'
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
};
|
|
162
|
-
const envConfig = new EnvConfigService(process.env);
|