@rws-framework/db 2.3.2 → 2.4.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.
Files changed (92) hide show
  1. package/.bin/add-v.sh +9 -9
  2. package/.bin/emerge.sh +10 -10
  3. package/.eslintrc.json +53 -53
  4. package/README.md +404 -367
  5. package/dist/decorators/InverseRelation.d.ts +12 -12
  6. package/dist/decorators/InverseRelation.js +24 -24
  7. package/dist/decorators/InverseTimeSeries.d.ts +8 -8
  8. package/dist/decorators/InverseTimeSeries.js +13 -13
  9. package/dist/decorators/RWSCollection.d.ts +12 -12
  10. package/dist/decorators/RWSCollection.js +16 -16
  11. package/dist/decorators/Relation.d.ts +19 -19
  12. package/dist/decorators/Relation.js +26 -26
  13. package/dist/decorators/TrackType.d.ts +20 -20
  14. package/dist/decorators/TrackType.js +41 -41
  15. package/dist/decorators/index.d.ts +5 -5
  16. package/dist/decorators/index.js +14 -14
  17. package/dist/helper/DbHelper.d.ts +8 -8
  18. package/dist/helper/DbHelper.js +141 -141
  19. package/dist/helper/FieldsHelper.d.ts +4 -4
  20. package/dist/helper/FieldsHelper.js +35 -35
  21. package/dist/index.d.ts +12 -12
  22. package/dist/index.js +19 -19
  23. package/dist/models/TimeSeriesModel.d.ts +7 -7
  24. package/dist/models/TimeSeriesModel.js +33 -33
  25. package/dist/models/_model.d.ts +6 -6
  26. package/dist/models/_model.js +9 -9
  27. package/dist/models/core/RWSModel.d.ts +66 -66
  28. package/dist/models/core/RWSModel.js +400 -400
  29. package/dist/models/core/TimeSeriesModel.d.ts +1 -1
  30. package/dist/models/core/TimeSeriesModel.js +14 -14
  31. package/dist/models/index.d.ts +7 -7
  32. package/dist/models/index.js +8 -8
  33. package/dist/models/interfaces/IModel.d.ts +11 -11
  34. package/dist/models/interfaces/IModel.js +2 -2
  35. package/dist/models/interfaces/IRWSModelServices.d.ts +6 -6
  36. package/dist/models/interfaces/IRWSModelServices.js +2 -2
  37. package/dist/models/interfaces/OpModelType.d.ts +31 -31
  38. package/dist/models/interfaces/OpModelType.js +2 -2
  39. package/dist/models/types/RelationTypes.d.ts +24 -24
  40. package/dist/models/types/RelationTypes.js +2 -2
  41. package/dist/models/utils/ModelUtils.d.ts +10 -10
  42. package/dist/models/utils/ModelUtils.js +56 -56
  43. package/dist/models/utils/PaginationUtils.d.ts +5 -5
  44. package/dist/models/utils/PaginationUtils.js +32 -32
  45. package/dist/models/utils/RelationUtils.d.ts +14 -14
  46. package/dist/models/utils/RelationUtils.js +65 -65
  47. package/dist/models/utils/TimeSeriesUtils.d.ts +11 -11
  48. package/dist/models/utils/TimeSeriesUtils.js +35 -35
  49. package/dist/services/DBService.d.ts +37 -37
  50. package/dist/services/DBService.js +198 -198
  51. package/dist/types/DbConfigHandler.d.ts +9 -9
  52. package/dist/types/DbConfigHandler.js +2 -2
  53. package/dist/types/FindParams.d.ts +14 -14
  54. package/dist/types/FindParams.js +2 -2
  55. package/dist/types/IRWSModel.d.ts +3 -3
  56. package/dist/types/IRWSModel.js +2 -2
  57. package/dist/types/ITimeSeries.d.ts +6 -6
  58. package/dist/types/ITimeSeries.js +2 -2
  59. package/exec/console.js +110 -110
  60. package/exec/db.rws.webpack.config.js +168 -168
  61. package/exec/src/cli.ts +74 -73
  62. package/exec/tsconfig.json +32 -32
  63. package/exec/webpackFilters.js +17 -17
  64. package/package.json +36 -36
  65. package/src/decorators/InverseRelation.ts +36 -36
  66. package/src/decorators/InverseTimeSeries.ts +21 -21
  67. package/src/decorators/RWSCollection.ts +27 -27
  68. package/src/decorators/Relation.ts +47 -47
  69. package/src/decorators/TrackType.ts +69 -69
  70. package/src/decorators/index.ts +7 -7
  71. package/src/empty.js +0 -0
  72. package/src/helper/DbHelper.ts +177 -177
  73. package/src/helper/FieldsHelper.ts +34 -34
  74. package/src/index.ts +36 -36
  75. package/src/models/_model.ts +29 -29
  76. package/src/models/core/RWSModel.ts +520 -520
  77. package/src/models/core/TimeSeriesModel.ts +19 -19
  78. package/src/models/index.ts +20 -20
  79. package/src/models/interfaces/IModel.ts +12 -12
  80. package/src/models/interfaces/IRWSModelServices.ts +7 -7
  81. package/src/models/interfaces/OpModelType.ts +49 -49
  82. package/src/models/types/RelationTypes.ts +25 -25
  83. package/src/models/utils/ModelUtils.ts +65 -65
  84. package/src/models/utils/PaginationUtils.ts +42 -42
  85. package/src/models/utils/RelationUtils.ts +76 -76
  86. package/src/models/utils/TimeSeriesUtils.ts +38 -38
  87. package/src/services/DBService.ts +277 -277
  88. package/src/types/DbConfigHandler.ts +12 -11
  89. package/src/types/FindParams.ts +13 -13
  90. package/src/types/IRWSModel.ts +2 -2
  91. package/src/types/ITimeSeries.ts +5 -5
  92. package/tsconfig.json +22 -22
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/exec/console.js CHANGED
@@ -1,111 +1,111 @@
1
- #!/usr/bin/env node
2
-
3
- const { rwsShell, rwsPath } = require('@rws-framework/console');
4
- const chalk = require('chalk');
5
- const crypto = require('crypto');
6
- const path = require('path');
7
- const fs = require('fs');
8
-
9
- const params = process.argv.splice(2);
10
- let paramsString = params.length ? (' ' + params.join(' ')) : '';
11
-
12
- const appRoot = process.cwd();
13
- const rwsCliConfigDir = path.resolve(appRoot, 'node_modules', '.rws', 'cli');
14
- const getCachedPath = (key) => path.resolve(rwsCliConfigDir, key);
15
-
16
- const currentCwd = path.resolve(__dirname);
17
-
18
- console.log({params})
19
-
20
-
21
- const commandString = `npx webpack --config db.rws.webpack.config.js --output-path ./build ${process.cwd()} ${params[2]}`;
22
- function needsCacheWarming(){
23
-
24
- if(!fs.existsSync(getCachedPath('paths')) || !fs.existsSync(getCachedPath('checksum'))){
25
- return true;
26
- }
27
-
28
- const fileList = fs.readFileSync(getCachedPath('paths'), 'utf-8').split('\n');
29
-
30
- if(fileList.length){
31
- const fileContents = [];
32
- for(const filePath of fileList){
33
- if(fs.existsSync(filePath)){
34
- fileContents.push(fs.readFileSync(filePath, 'utf-8'));
35
- }
36
- }
37
- const finalMD5 = crypto.createHash('md5').update(fileContents.join('\n')).digest('hex');
38
- const cachedMD5 = fs.readFileSync(getCachedPath('checksum'), 'utf-8');
39
-
40
- if(finalMD5 === cachedMD5){
41
- return false;
42
- }
43
- }
44
-
45
- return true;
46
- }
47
-
48
- async function main()
49
- {
50
- const hasRebuild = paramsString.split(' ').pop().indexOf('--rebuild') > -1;
51
- const doWarmCache = needsCacheWarming() || hasRebuild;
52
-
53
- if(!((params[0] || false) && (params[1] || false) && (params[2] || false))){
54
- throw new Error(`CLI command MUST have 3 parameters: {DB_URL, DB_NAME, MODELS_DIR}`);
55
- }
56
-
57
- if(doWarmCache){
58
- console.log(chalk.yellow('[RWS DB CLI] Building CLI client...'));
59
-
60
- const cacheTypes = ['paths', 'checksum'];
61
-
62
- for(const type of cacheTypes){
63
- if(fs.existsSync(getCachedPath(type))){
64
- fs.unlinkSync(getCachedPath(type));
65
- }
66
- }
67
-
68
- await tsc();
69
-
70
- await rwsShell.runCommand(commandString, currentCwd);
71
-
72
-
73
- }else{
74
- console.log(chalk.blue('[RWS CLI CACHE] Starting command from built CLI client.'));
75
- }
76
-
77
- let startSlice = hasRebuild ? -1 : paramsString.split(' ').length;
78
- let endSlice = hasRebuild ? -1 : null ;
79
-
80
- paramsString = [
81
- ...paramsString.split(' ').slice(0, startSlice),
82
- currentCwd,
83
- endSlice ?
84
- paramsString.split(' ').at(endSlice)
85
- : null
86
- ].filter((item) => item !== null).join(' ');
87
-
88
- await rwsShell.runCommand(`node ${path.join(currentCwd, 'build', 'main.cli.rws.js')}${paramsString}`, process.cwd());
89
- }
90
-
91
- async function tsc (){
92
- const tempConfigContent = {
93
- "extends": "./tsconfig.json",
94
- "include": [
95
- path.join(process.cwd(), params[2], 'index.ts')
96
- ],
97
- };
98
-
99
- const tempConfigPath = path.join(currentCwd, '.tmp.gitignore.json');
100
- fs.writeFileSync(tempConfigPath, JSON.stringify(tempConfigContent, null, 2));
101
-
102
-
103
- await rwsShell.runCommand(`tsc -p ${tempConfigPath}`, currentCwd);
104
- fs.unlinkSync(tempConfigPath);
105
- }
106
-
107
- main().then((data) => {
108
- console.log(chalk.green('[RWS DB CLI] Command complete.'));
109
- }).catch((e) => {
110
- console.error(e.message);
1
+ #!/usr/bin/env node
2
+
3
+ const { rwsShell, rwsPath } = require('@rws-framework/console');
4
+ const chalk = require('chalk');
5
+ const crypto = require('crypto');
6
+ const path = require('path');
7
+ const fs = require('fs');
8
+
9
+ const params = process.argv.splice(2);
10
+ let paramsString = params.length ? (' ' + params.join(' ')) : '';
11
+
12
+ const appRoot = process.cwd();
13
+ const rwsCliConfigDir = path.resolve(appRoot, 'node_modules', '.rws', 'cli');
14
+ const getCachedPath = (key) => path.resolve(rwsCliConfigDir, key);
15
+
16
+ const currentCwd = path.resolve(__dirname);
17
+
18
+ console.log({params})
19
+
20
+
21
+ const commandString = `npx webpack --config db.rws.webpack.config.js --output-path ./build ${process.cwd()} ${params[2]}`;
22
+ function needsCacheWarming(){
23
+
24
+ if(!fs.existsSync(getCachedPath('paths')) || !fs.existsSync(getCachedPath('checksum'))){
25
+ return true;
26
+ }
27
+
28
+ const fileList = fs.readFileSync(getCachedPath('paths'), 'utf-8').split('\n');
29
+
30
+ if(fileList.length){
31
+ const fileContents = [];
32
+ for(const filePath of fileList){
33
+ if(fs.existsSync(filePath)){
34
+ fileContents.push(fs.readFileSync(filePath, 'utf-8'));
35
+ }
36
+ }
37
+ const finalMD5 = crypto.createHash('md5').update(fileContents.join('\n')).digest('hex');
38
+ const cachedMD5 = fs.readFileSync(getCachedPath('checksum'), 'utf-8');
39
+
40
+ if(finalMD5 === cachedMD5){
41
+ return false;
42
+ }
43
+ }
44
+
45
+ return true;
46
+ }
47
+
48
+ async function main()
49
+ {
50
+ const hasRebuild = paramsString.split(' ').pop().indexOf('--rebuild') > -1;
51
+ const doWarmCache = needsCacheWarming() || hasRebuild;
52
+
53
+ if(!((params[0] || false) && (params[1] || false) && (params[2] || false))){
54
+ throw new Error(`CLI command MUST have 3 parameters: {DB_URL, DB_NAME, MODELS_DIR}`);
55
+ }
56
+
57
+ if(doWarmCache){
58
+ console.log(chalk.yellow('[RWS DB CLI] Building CLI client...'));
59
+
60
+ const cacheTypes = ['paths', 'checksum'];
61
+
62
+ for(const type of cacheTypes){
63
+ if(fs.existsSync(getCachedPath(type))){
64
+ fs.unlinkSync(getCachedPath(type));
65
+ }
66
+ }
67
+
68
+ await tsc();
69
+
70
+ await rwsShell.runCommand(commandString, currentCwd);
71
+
72
+
73
+ }else{
74
+ console.log(chalk.blue('[RWS CLI CACHE] Starting command from built CLI client.'));
75
+ }
76
+
77
+ let startSlice = hasRebuild ? -1 : paramsString.split(' ').length;
78
+ let endSlice = hasRebuild ? -1 : null ;
79
+
80
+ paramsString = [
81
+ ...paramsString.split(' ').slice(0, startSlice),
82
+ currentCwd,
83
+ endSlice ?
84
+ paramsString.split(' ').at(endSlice)
85
+ : null
86
+ ].filter((item) => item !== null).join(' ');
87
+
88
+ await rwsShell.runCommand(`node ${path.join(currentCwd, 'build', 'main.cli.rws.js')}${paramsString}`, process.cwd());
89
+ }
90
+
91
+ async function tsc (){
92
+ const tempConfigContent = {
93
+ "extends": "./tsconfig.json",
94
+ "include": [
95
+ path.join(process.cwd(), params[2], 'index.ts')
96
+ ],
97
+ };
98
+
99
+ const tempConfigPath = path.join(currentCwd, '.tmp.gitignore.json');
100
+ fs.writeFileSync(tempConfigPath, JSON.stringify(tempConfigContent, null, 2));
101
+
102
+
103
+ await rwsShell.runCommand(`tsc -p ${tempConfigPath}`, currentCwd);
104
+ fs.unlinkSync(tempConfigPath);
105
+ }
106
+
107
+ main().then((data) => {
108
+ console.log(chalk.green('[RWS DB CLI] Command complete.'));
109
+ }).catch((e) => {
110
+ console.error(e.message);
111
111
  });
@@ -1,168 +1,168 @@
1
- const path = require('path');
2
- const chalk = require('chalk');
3
- const webpackFilters = require('./webpackFilters');
4
- const webpack = require('webpack');
5
- const { rwsPath } = require('@rws-framework/console');
6
- // Get CLI arguments
7
- const args = process.argv.slice(2);
8
- const fs = require('fs');
9
- const appRootPath = args[4] || process.cwd();
10
- const modelsDir = args[5] || '';
11
-
12
- const internalCwd = process.cwd()
13
- const rootPackageNodeModules = path.resolve(rwsPath.findRootWorkspacePath(), 'node_modules');
14
- const thisPackage = path.resolve(__dirname, '..');
15
- const WEBPACK_PLUGINS = [new webpack.optimize.ModuleConcatenationPlugin()];
16
-
17
- const modules_setup = [rootPackageNodeModules, appRootPath];
18
- const isDev = true;
19
-
20
- function prettyLog(data){
21
- for(const key of Object.keys(data)){
22
- const valObject = data[key];
23
-
24
- console.log(`${chalk.yellow('[Log]')} ${chalk.blue(key)}:`, valObject)
25
- }
26
- }
27
-
28
-
29
-
30
- const mainEntry = './' + path.relative(appRootPath, path.join(internalCwd, '/src/cli.ts'));
31
- const vPath = path.relative(__dirname, path.join(__dirname, '../build/vendors'));
32
-
33
- prettyLog({ buildPaths:{
34
- thisPackage,
35
- rootPackageNodeModules,
36
- appRootPath,
37
- internalCwd,
38
- vPath
39
- }});
40
-
41
- if(!fs.existsSync(path.join(appRootPath, modelsDir, 'index.ts'))){
42
- console.log(`${chalk.red('[RWS Structure Error] ')} ${chalk.blue(`
43
- No index.ts in "${path.join(appRootPath, modelsDir)}"\n
44
- RWS DB requires "index.ts" that has default export with array of your models:\n
45
-
46
- ${chalk.blue('import')} RWSModel${chalk.blue(',')} OpModelType ${chalk.blue('from')} ${chalk.green('./src/models/user.model.ts')}${chalk.blue(';')}
47
-
48
- RWSModel<ModelDataInterface> is instance type and
49
- OpModelType<ModelDataInterface> is type for static methods that navigate through db to populate instanced models.`)}\n
50
-
51
- Example: \n
52
-
53
- ${chalk.blue('import')} User ${chalk.blue('from')} ${chalk.green('\'./src/models/user.model.ts\'')}${chalk.blue(';')}
54
- ${chalk.blue('import')} ApiKey ${chalk.blue('from')} ${chalk.green('\'./src/models/apiKey.model.ts\'')}${chalk.blue(';')}
55
-
56
- ${chalk.blue('export')} default ${chalk.magenta('[')}
57
- User${chalk.blue(',')}
58
- ApiKey
59
- ${chalk.magenta(']')}${chalk.blue(';')}
60
- `);
61
-
62
- throw new Error("Build stopped.")
63
- }
64
-
65
- const cfgExport = {
66
- context: appRootPath,
67
- entry: mainEntry,
68
- mode: isDev ? 'development' : 'production',
69
- target: 'node',
70
- devtool: isDev ? 'source-map' : false,
71
- output: {
72
- path: path.resolve(internalCwd, 'build'), // Resolve output path relative to config directory
73
- filename: '[name].cli.rws.js',
74
- sourceMapFilename: '[file].map',
75
- chunkFilename: "[name].chunk.js",
76
- libraryTarget: 'commonjs2',
77
- clean: false
78
- },
79
- resolve: {
80
- extensions: ['.ts', '.js'],
81
- modules: modules_setup,
82
- alias: {
83
- '@V': vPath,
84
- 'src': path.resolve(appRootPath, 'src'), // Add explicit resolution for src directory
85
- },
86
- fallback: {
87
- "kerberos": false,
88
- "mongodb-client-encryption": false
89
- }
90
- },
91
- module: {
92
- rules: [
93
- {
94
- test: /\.(ts)$/,
95
- use: [
96
- {
97
- loader: 'ts-loader',
98
- options: {
99
- transpileOnly: true,
100
- configFile: path.resolve(__dirname, 'tsconfig.json'),
101
- compilerOptions: {
102
- outDir: path.resolve(internalCwd, 'build'),
103
- }
104
- }
105
- }
106
- ],
107
- include: [
108
- path.resolve(appRootPath),
109
- path.resolve(thisPackage),
110
- path.resolve(rootPackageNodeModules, '@rws-framework')
111
- ],
112
- exclude: [
113
- /node_modules\/(?!(@rws-framework)\/).*/,
114
- /\.d\.ts$/
115
- ]
116
- },
117
- {
118
- test: /\.node$/,
119
- use: 'node-loader',
120
- }
121
- ],
122
- },
123
- plugins: [
124
- ...WEBPACK_PLUGINS,
125
- new webpack.DefinePlugin({
126
- 'process.env.APP_ROOT': JSON.stringify(appRootPath),
127
- 'process.env.DB_CLI': JSON.stringify(1)
128
- }),
129
- new webpack.IgnorePlugin({
130
- resourceRegExp: /^kerberos$/,
131
- }),
132
- new webpack.NormalModuleReplacementPlugin(
133
- /.*\/build\/Debug\/kerberos\.node$/,
134
- '@rws-framework/db/src/empty.js'
135
- )
136
- ],
137
- ignoreWarnings: webpackFilters,
138
- optimization: {
139
- minimize: false
140
- },
141
- experiments: {
142
- topLevelAwait: true, // Enable top-level await if needed
143
- }
144
- // stats: 'verbose'
145
-
146
- };
147
-
148
- cfgExport.externals = {
149
- '@nestjs/common': 'commonjs @nestjs/common',
150
- '@nestjs/core': 'commonjs @nestjs/core',
151
- '@nestjs/config': 'commonjs @nestjs/config',
152
- '@anthropic-ai/sdk': 'commonjs @anthropic-ai/sdk',
153
- '@zip.js/zip.js': 'commonjs @zip.js/zip.js',
154
- 'mongodb-client-encryption': 'commonjs mongodb-client-encryption',
155
- 'uuid': 'commonjs uuid',
156
- 'source-map-support': 'commonjs source-map-support'
157
- };
158
-
159
- cfgExport.plugins.push(
160
- new webpack.BannerPlugin({
161
- banner: 'require("source-map-support").install();',
162
- raw: true
163
- })
164
- );
165
-
166
- // console.log('Final config', cfgExport);
167
-
168
- module.exports = cfgExport;
1
+ const path = require('path');
2
+ const chalk = require('chalk');
3
+ const webpackFilters = require('./webpackFilters');
4
+ const webpack = require('webpack');
5
+ const { rwsPath } = require('@rws-framework/console');
6
+ // Get CLI arguments
7
+ const args = process.argv.slice(2);
8
+ const fs = require('fs');
9
+ const appRootPath = args[4] || process.cwd();
10
+ const modelsDir = args[5] || '';
11
+
12
+ const internalCwd = process.cwd()
13
+ const rootPackageNodeModules = path.resolve(rwsPath.findRootWorkspacePath(), 'node_modules');
14
+ const thisPackage = path.resolve(__dirname, '..');
15
+ const WEBPACK_PLUGINS = [new webpack.optimize.ModuleConcatenationPlugin()];
16
+
17
+ const modules_setup = [rootPackageNodeModules, appRootPath];
18
+ const isDev = true;
19
+
20
+ function prettyLog(data){
21
+ for(const key of Object.keys(data)){
22
+ const valObject = data[key];
23
+
24
+ console.log(`${chalk.yellow('[Log]')} ${chalk.blue(key)}:`, valObject)
25
+ }
26
+ }
27
+
28
+
29
+
30
+ const mainEntry = './' + path.relative(appRootPath, path.join(internalCwd, '/src/cli.ts'));
31
+ const vPath = path.relative(__dirname, path.join(__dirname, '../build/vendors'));
32
+
33
+ prettyLog({ buildPaths:{
34
+ thisPackage,
35
+ rootPackageNodeModules,
36
+ appRootPath,
37
+ internalCwd,
38
+ vPath
39
+ }});
40
+
41
+ if(!fs.existsSync(path.join(appRootPath, modelsDir, 'index.ts'))){
42
+ console.log(`${chalk.red('[RWS Structure Error] ')} ${chalk.blue(`
43
+ No index.ts in "${path.join(appRootPath, modelsDir)}"\n
44
+ RWS DB requires "index.ts" that has default export with array of your models:\n
45
+
46
+ ${chalk.blue('import')} RWSModel${chalk.blue(',')} OpModelType ${chalk.blue('from')} ${chalk.green('./src/models/user.model.ts')}${chalk.blue(';')}
47
+
48
+ RWSModel<ModelDataInterface> is instance type and
49
+ OpModelType<ModelDataInterface> is type for static methods that navigate through db to populate instanced models.`)}\n
50
+
51
+ Example: \n
52
+
53
+ ${chalk.blue('import')} User ${chalk.blue('from')} ${chalk.green('\'./src/models/user.model.ts\'')}${chalk.blue(';')}
54
+ ${chalk.blue('import')} ApiKey ${chalk.blue('from')} ${chalk.green('\'./src/models/apiKey.model.ts\'')}${chalk.blue(';')}
55
+
56
+ ${chalk.blue('export')} default ${chalk.magenta('[')}
57
+ User${chalk.blue(',')}
58
+ ApiKey
59
+ ${chalk.magenta(']')}${chalk.blue(';')}
60
+ `);
61
+
62
+ throw new Error("Build stopped.")
63
+ }
64
+
65
+ const cfgExport = {
66
+ context: appRootPath,
67
+ entry: mainEntry,
68
+ mode: isDev ? 'development' : 'production',
69
+ target: 'node',
70
+ devtool: isDev ? 'source-map' : false,
71
+ output: {
72
+ path: path.resolve(internalCwd, 'build'), // Resolve output path relative to config directory
73
+ filename: '[name].cli.rws.js',
74
+ sourceMapFilename: '[file].map',
75
+ chunkFilename: "[name].chunk.js",
76
+ libraryTarget: 'commonjs2',
77
+ clean: false
78
+ },
79
+ resolve: {
80
+ extensions: ['.ts', '.js'],
81
+ modules: modules_setup,
82
+ alias: {
83
+ '@V': vPath,
84
+ 'src': path.resolve(appRootPath, 'src'), // Add explicit resolution for src directory
85
+ },
86
+ fallback: {
87
+ "kerberos": false,
88
+ "mongodb-client-encryption": false
89
+ }
90
+ },
91
+ module: {
92
+ rules: [
93
+ {
94
+ test: /\.(ts)$/,
95
+ use: [
96
+ {
97
+ loader: 'ts-loader',
98
+ options: {
99
+ transpileOnly: true,
100
+ configFile: path.resolve(__dirname, 'tsconfig.json'),
101
+ compilerOptions: {
102
+ outDir: path.resolve(internalCwd, 'build'),
103
+ }
104
+ }
105
+ }
106
+ ],
107
+ include: [
108
+ path.resolve(appRootPath),
109
+ path.resolve(thisPackage),
110
+ path.resolve(rootPackageNodeModules, '@rws-framework')
111
+ ],
112
+ exclude: [
113
+ /node_modules\/(?!(@rws-framework)\/).*/,
114
+ /\.d\.ts$/
115
+ ]
116
+ },
117
+ {
118
+ test: /\.node$/,
119
+ use: 'node-loader',
120
+ }
121
+ ],
122
+ },
123
+ plugins: [
124
+ ...WEBPACK_PLUGINS,
125
+ new webpack.DefinePlugin({
126
+ 'process.env.APP_ROOT': JSON.stringify(appRootPath),
127
+ 'process.env.DB_CLI': JSON.stringify(1)
128
+ }),
129
+ new webpack.IgnorePlugin({
130
+ resourceRegExp: /^kerberos$/,
131
+ }),
132
+ new webpack.NormalModuleReplacementPlugin(
133
+ /.*\/build\/Debug\/kerberos\.node$/,
134
+ '@rws-framework/db/src/empty.js'
135
+ )
136
+ ],
137
+ ignoreWarnings: webpackFilters,
138
+ optimization: {
139
+ minimize: false
140
+ },
141
+ experiments: {
142
+ topLevelAwait: true, // Enable top-level await if needed
143
+ }
144
+ // stats: 'verbose'
145
+
146
+ };
147
+
148
+ cfgExport.externals = {
149
+ '@nestjs/common': 'commonjs @nestjs/common',
150
+ '@nestjs/core': 'commonjs @nestjs/core',
151
+ '@nestjs/config': 'commonjs @nestjs/config',
152
+ '@anthropic-ai/sdk': 'commonjs @anthropic-ai/sdk',
153
+ '@zip.js/zip.js': 'commonjs @zip.js/zip.js',
154
+ 'mongodb-client-encryption': 'commonjs mongodb-client-encryption',
155
+ 'uuid': 'commonjs uuid',
156
+ 'source-map-support': 'commonjs source-map-support'
157
+ };
158
+
159
+ cfgExport.plugins.push(
160
+ new webpack.BannerPlugin({
161
+ banner: 'require("source-map-support").install();',
162
+ raw: true
163
+ })
164
+ );
165
+
166
+ // console.log('Final config', cfgExport);
167
+
168
+ module.exports = cfgExport;