@lensmcp/cluster 1.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.
Files changed (69) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +130 -0
  3. package/basic-ssl.d.ts +7 -0
  4. package/basic-ssl.d.ts.map +1 -0
  5. package/basic-ssl.js +158 -0
  6. package/build-scope-patterns.d.ts +12 -0
  7. package/build-scope-patterns.d.ts.map +1 -0
  8. package/build-scope-patterns.js +40 -0
  9. package/create-webpack-dev.d.ts +27 -0
  10. package/create-webpack-dev.d.ts.map +1 -0
  11. package/create-webpack-dev.js +151 -0
  12. package/create-webpack-prod.d.ts +28 -0
  13. package/create-webpack-prod.d.ts.map +1 -0
  14. package/create-webpack-prod.js +169 -0
  15. package/executors/build/build.impl.d.ts +19 -0
  16. package/executors/build/build.impl.d.ts.map +1 -0
  17. package/executors/build/build.impl.js +98 -0
  18. package/executors/build/schema.d.ts +35 -0
  19. package/executors/build/schema.json +135 -0
  20. package/executors/gateway/gateway.impl.d.ts +23 -0
  21. package/executors/gateway/gateway.impl.d.ts.map +1 -0
  22. package/executors/gateway/gateway.impl.js +39 -0
  23. package/executors/gateway/gateway.lib.d.ts +130 -0
  24. package/executors/gateway/gateway.lib.d.ts.map +1 -0
  25. package/executors/gateway/gateway.lib.js +797 -0
  26. package/executors/gateway/jwks-verify.d.ts +28 -0
  27. package/executors/gateway/jwks-verify.d.ts.map +1 -0
  28. package/executors/gateway/jwks-verify.js +121 -0
  29. package/executors/gateway/main.prod-gateway.d.ts +2 -0
  30. package/executors/gateway/main.prod-gateway.d.ts.map +1 -0
  31. package/executors/gateway/main.prod-gateway.js +290 -0
  32. package/executors/gateway/main.rollout.d.ts +2 -0
  33. package/executors/gateway/main.rollout.d.ts.map +1 -0
  34. package/executors/gateway/main.rollout.js +130 -0
  35. package/executors/gateway/manifest.d.ts +275 -0
  36. package/executors/gateway/manifest.d.ts.map +1 -0
  37. package/executors/gateway/manifest.js +344 -0
  38. package/executors/gateway/prod-gateway.lib.d.ts +58 -0
  39. package/executors/gateway/prod-gateway.lib.d.ts.map +1 -0
  40. package/executors/gateway/prod-gateway.lib.js +535 -0
  41. package/executors/gateway/providers-prod.d.ts +46 -0
  42. package/executors/gateway/providers-prod.d.ts.map +1 -0
  43. package/executors/gateway/providers-prod.js +199 -0
  44. package/executors/gateway/registry-source.d.ts +68 -0
  45. package/executors/gateway/registry-source.d.ts.map +1 -0
  46. package/executors/gateway/registry-source.js +131 -0
  47. package/executors/gateway/rollout-ops.d.ts +54 -0
  48. package/executors/gateway/rollout-ops.d.ts.map +1 -0
  49. package/executors/gateway/rollout-ops.js +167 -0
  50. package/executors/gateway/schema.d.ts +10 -0
  51. package/executors/gateway/schema.json +30 -0
  52. package/executors/serve/schema.d.ts +53 -0
  53. package/executors/serve/schema.json +196 -0
  54. package/executors/serve/serve.impl.d.ts +25 -0
  55. package/executors/serve/serve.impl.d.ts.map +1 -0
  56. package/executors/serve/serve.impl.js +243 -0
  57. package/executors/trust/schema.d.ts +6 -0
  58. package/executors/trust/schema.json +20 -0
  59. package/executors/trust/trust.impl.d.ts +42 -0
  60. package/executors/trust/trust.impl.d.ts.map +1 -0
  61. package/executors/trust/trust.impl.js +126 -0
  62. package/executors.json +24 -0
  63. package/index.d.ts +4 -0
  64. package/index.d.ts.map +1 -0
  65. package/index.js +9 -0
  66. package/main.devserver.d.ts +16 -0
  67. package/main.devserver.d.ts.map +1 -0
  68. package/main.devserver.js +812 -0
  69. package/package.json +66 -0
@@ -0,0 +1,151 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createDevWebpackConfig = createDevWebpackConfig;
4
+ const tslib_1 = require("tslib");
5
+ const app_plugin_1 = require("@nx/webpack/app-plugin");
6
+ const fs = tslib_1.__importStar(require("node:fs"));
7
+ const path = tslib_1.__importStar(require("node:path"));
8
+ const webpack_node_externals_1 = tslib_1.__importDefault(require("webpack-node-externals"));
9
+ const build_scope_patterns_1 = require("./build-scope-patterns");
10
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
11
+ const webpack = require('webpack');
12
+ class DevServerReloadPlugin {
13
+ constructor(port, secure = false) {
14
+ // When the parent terminates TLS (gateway.https), notify over https with the
15
+ // self-signed cert accepted — the cert is ours (basic-ssl style, cached locally).
16
+ this.secure = secure;
17
+ this.url = `${secure ? 'https' : 'http'}://localhost:${port}/webpack/reload`;
18
+ }
19
+ notify() {
20
+ return new Promise((resolve, reject) => {
21
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
22
+ const mod = (this.secure ? require('node:https') : require('node:http'));
23
+ const req = mod.request(this.url, { method: 'POST', headers: { 'content-type': 'application/json' }, rejectUnauthorized: false }, (res) => { res.resume(); res.on('end', resolve); });
24
+ req.on('error', reject);
25
+ req.end('{}');
26
+ });
27
+ }
28
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
29
+ apply(compiler) {
30
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
31
+ compiler.hooks.done.tap('DevServerReloadPlugin', async (stats) => {
32
+ try {
33
+ if (stats.hasErrors())
34
+ return;
35
+ await this.notify();
36
+ console.log('[DevServerReloadPlugin] notified devserver to reload');
37
+ }
38
+ catch {
39
+ console.log('[DevServerReloadPlugin] devserver not running yet');
40
+ }
41
+ });
42
+ }
43
+ }
44
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
45
+ function createDevWebpackConfig(options) {
46
+ const { appRoot, outputDir, main, tsConfig, workspaceRoot, assets = [], port, memoryLimit = 8192, buildLibsFromSource = true, orgScopes = [], bundlePackages = [], additionalEntryPoints = [], nodeExternalsConfig: userNodeExternalsConfig, webpackConfigPath, } = options;
47
+ const { allowlistPatterns, scopePrefixes, scopePatterns } = (0, build_scope_patterns_1.buildScopePatterns)(orgScopes);
48
+ // Build combined allowlist: orgScopes + bundlePackages + user-provided
49
+ const bundlePatterns = bundlePackages.map((pkg) => new RegExp(`^${pkg.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}(/|$)`));
50
+ const combinedAllowlist = [
51
+ /webpack\/hot\/poll\?100/,
52
+ ...allowlistPatterns,
53
+ ...bundlePatterns,
54
+ ...(userNodeExternalsConfig?.allowlist || []),
55
+ ];
56
+ const config = {
57
+ output: {
58
+ path: outputDir,
59
+ ...(process.env.NODE_ENV !== 'production' && {
60
+ devtoolModuleFilenameTemplate: '[absolute-resource-path]',
61
+ }),
62
+ clean: true,
63
+ },
64
+ externals: [
65
+ (0, webpack_node_externals_1.default)({
66
+ allowlist: combinedAllowlist,
67
+ additionalModuleDirs: userNodeExternalsConfig?.additionalModuleDirs || [],
68
+ ...(userNodeExternalsConfig?.importType && { importType: userNodeExternalsConfig.importType }),
69
+ }),
70
+ ({ request }, callback) => {
71
+ // Workspace-internal absolute requests are SOURCE regardless of the
72
+ // bucket layout (apps/, libs/, server/, shared/, web/, …) — bundle them.
73
+ // The apps/libs prefix checks below stay for explicitness/back-compat.
74
+ if (request &&
75
+ path.isAbsolute(request) &&
76
+ request.startsWith(workspaceRoot) &&
77
+ !request.includes('node_modules')) {
78
+ return callback();
79
+ }
80
+ if (request &&
81
+ (request.startsWith(path.join(workspaceRoot, 'apps')) ||
82
+ request.startsWith(path.join(workspaceRoot, 'libs')))) {
83
+ return callback();
84
+ }
85
+ if (request && scopePrefixes.some((prefix) => request.startsWith(prefix))) {
86
+ return callback();
87
+ }
88
+ if (request && scopePatterns.some((pattern) => pattern.test(request))) {
89
+ return callback();
90
+ }
91
+ if (request && bundlePatterns.some((pattern) => pattern.test(request))) {
92
+ return callback();
93
+ }
94
+ if (request && !(request.startsWith('./') || request.startsWith('..'))) {
95
+ // Bare specifier: only a real node_modules package may stay external —
96
+ // tsconfig-path aliases (e.g. @org/contracts → workspace source) must bundle.
97
+ const rootSegment = request.startsWith('@')
98
+ ? request.split('/').slice(0, 2).join('/')
99
+ : request.split('/')[0];
100
+ if (!fs.existsSync(path.join(workspaceRoot, 'node_modules', rootSegment))) {
101
+ return callback();
102
+ }
103
+ return callback(null, `commonjs ${request}`);
104
+ }
105
+ return callback();
106
+ },
107
+ ],
108
+ mode: 'development',
109
+ devtool: 'eval-cheap-module-source-map',
110
+ plugins: [
111
+ new webpack.HotModuleReplacementPlugin(),
112
+ new app_plugin_1.NxAppWebpackPlugin({
113
+ target: 'node22',
114
+ compiler: 'tsc',
115
+ main,
116
+ additionalEntryPoints,
117
+ verbose: true,
118
+ sourceMap: 'eval-cheap-module-source-map',
119
+ mergeExternals: true,
120
+ externalDependencies: [],
121
+ memoryLimit,
122
+ tsConfig,
123
+ assets,
124
+ optimization: false,
125
+ progress: false,
126
+ outputHashing: 'none',
127
+ generatePackageJson: false,
128
+ watchDependencies: true,
129
+ typeCheckOptions: {
130
+ async: true,
131
+ },
132
+ buildLibsFromSource,
133
+ }),
134
+ new DevServerReloadPlugin(port, options.httpsReload === true),
135
+ ],
136
+ snapshot: { managedPaths: [/^(.+?[\\/])?node_modules[\\/]/] },
137
+ watch: true,
138
+ watchOptions: {
139
+ ignored: ['**/*.env.template', '**/config.template.json', '**/*.md', '**/dist/**', '**/migrations/**'],
140
+ },
141
+ cache: { type: 'filesystem' },
142
+ };
143
+ // Apply user webpack overrides if configured
144
+ if (webpackConfigPath) {
145
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
146
+ const overrideModule = require(path.resolve(appRoot, webpackConfigPath));
147
+ const overrideFn = overrideModule.default || overrideModule;
148
+ return overrideFn(config);
149
+ }
150
+ return config;
151
+ }
@@ -0,0 +1,28 @@
1
+ import { type NodeExternalsConfig } from './build-scope-patterns';
2
+ type Configuration = Record<string, any>;
3
+ export interface ProdWebpackOptions {
4
+ appName: string;
5
+ appRoot: string;
6
+ outputDir: string;
7
+ main: string;
8
+ tsConfig: string;
9
+ workspaceRoot: string;
10
+ assets?: string[];
11
+ additionalEntryPoints?: Array<{
12
+ entryName: string;
13
+ entryPath: string;
14
+ }>;
15
+ runtimeDependencies?: string[];
16
+ memoryLimit?: number;
17
+ generatePackageJson?: boolean;
18
+ buildLibsFromSource?: boolean;
19
+ ormConfigPath?: string;
20
+ migrationsDir?: string;
21
+ orgScopes?: string[];
22
+ bundlePackages?: string[];
23
+ nodeExternalsConfig?: NodeExternalsConfig;
24
+ webpackConfigPath?: string;
25
+ }
26
+ export declare function createProdWebpackConfig(options: ProdWebpackOptions): Configuration[];
27
+ export {};
28
+ //# sourceMappingURL=create-webpack-prod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-webpack-prod.d.ts","sourceRoot":"","sources":["../../../libs/cluster/src/create-webpack-prod.ts"],"names":[],"mappings":"AAKA,OAAO,EAAsB,KAAK,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAMtF,KAAK,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAEzC,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,qBAAqB,CAAC,EAAE,KAAK,CAAC;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACxE,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,kBAAkB,GAAG,aAAa,EAAE,CAiMpF"}
@@ -0,0 +1,169 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createProdWebpackConfig = createProdWebpackConfig;
4
+ const tslib_1 = require("tslib");
5
+ const app_plugin_1 = require("@nx/webpack/app-plugin");
6
+ const fs = tslib_1.__importStar(require("node:fs"));
7
+ const path = tslib_1.__importStar(require("node:path"));
8
+ const glob_1 = require("glob");
9
+ const webpack_node_externals_1 = tslib_1.__importDefault(require("webpack-node-externals"));
10
+ const build_scope_patterns_1 = require("./build-scope-patterns");
11
+ function createProdWebpackConfig(options) {
12
+ const { appRoot, outputDir, main, tsConfig, workspaceRoot, assets = [], additionalEntryPoints = [], runtimeDependencies = [], memoryLimit = 8192, generatePackageJson = true, buildLibsFromSource = false, ormConfigPath, migrationsDir = './src/migrations', orgScopes = [], bundlePackages = [], nodeExternalsConfig: userNodeExternalsConfig, webpackConfigPath, } = options;
13
+ const { allowlistPatterns, scopePrefixes, scopePatterns } = (0, build_scope_patterns_1.buildScopePatterns)(orgScopes);
14
+ // Build combined allowlist: orgScopes + bundlePackages + user-provided
15
+ const bundlePatterns = bundlePackages.map((pkg) => new RegExp(`^${pkg.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}(/|$)`));
16
+ const combinedAllowlist = [
17
+ ...allowlistPatterns,
18
+ ...bundlePatterns,
19
+ ...(userNodeExternalsConfig?.allowlist || []),
20
+ ];
21
+ // Detect ormconfig.ts for the app so we can build it for TypeORM CLI in production
22
+ let resolvedOrmConfigPath;
23
+ if (ormConfigPath !== undefined) {
24
+ resolvedOrmConfigPath = ormConfigPath ? path.join(appRoot, ormConfigPath) : null;
25
+ }
26
+ else {
27
+ const candidate = path.join(appRoot, './src/ormconfig.ts');
28
+ resolvedOrmConfigPath = fs.existsSync(candidate) ? candidate : null;
29
+ }
30
+ const hasOrmconfig = resolvedOrmConfigPath && fs.existsSync(resolvedOrmConfigPath);
31
+ const webpackConfigs = [];
32
+ const externalsConfig = [
33
+ (0, webpack_node_externals_1.default)({
34
+ allowlist: combinedAllowlist,
35
+ additionalModuleDirs: userNodeExternalsConfig?.additionalModuleDirs || [],
36
+ ...(userNodeExternalsConfig?.importType && { importType: userNodeExternalsConfig.importType }),
37
+ }),
38
+ ({ request }, callback) => {
39
+ // Workspace-internal absolute requests are SOURCE regardless of the
40
+ // bucket layout (apps/, libs/, server/, shared/, web/, …) — bundle them.
41
+ if (request &&
42
+ path.isAbsolute(request) &&
43
+ request.startsWith(workspaceRoot) &&
44
+ !request.includes('node_modules')) {
45
+ return callback();
46
+ }
47
+ if (request &&
48
+ (request.startsWith(path.join(workspaceRoot, 'apps')) ||
49
+ request.startsWith(path.join(workspaceRoot, 'libs')))) {
50
+ return callback();
51
+ }
52
+ if (request && scopePrefixes.some((prefix) => request.startsWith(prefix))) {
53
+ return callback();
54
+ }
55
+ if (request && scopePatterns.some((pattern) => pattern.test(request))) {
56
+ return callback();
57
+ }
58
+ if (request && bundlePatterns.some((pattern) => pattern.test(request))) {
59
+ return callback();
60
+ }
61
+ if (request && !(request.startsWith('./') || request.startsWith('..'))) {
62
+ // Bare specifier: only a real node_modules package may stay external —
63
+ // tsconfig-path aliases (e.g. @org/contracts → workspace source) must bundle.
64
+ const rootSegment = request.startsWith('@')
65
+ ? request.split('/').slice(0, 2).join('/')
66
+ : request.split('/')[0];
67
+ if (!fs.existsSync(path.join(workspaceRoot, 'node_modules', rootSegment))) {
68
+ return callback();
69
+ }
70
+ return callback(null, `commonjs ${request}`);
71
+ }
72
+ return callback();
73
+ },
74
+ ];
75
+ const productionBuildConfig = {
76
+ externals: externalsConfig,
77
+ output: {
78
+ path: outputDir,
79
+ clean: false,
80
+ },
81
+ devtool: 'inline-source-map',
82
+ mode: 'production',
83
+ plugins: [
84
+ new app_plugin_1.NxAppWebpackPlugin({
85
+ target: 'node22',
86
+ compiler: 'tsc',
87
+ main,
88
+ additionalEntryPoints,
89
+ externalDependencies: [],
90
+ mergeExternals: true,
91
+ memoryLimit,
92
+ tsConfig,
93
+ assets,
94
+ namedChunks: true,
95
+ optimization: true,
96
+ outputHashing: 'none',
97
+ generatePackageJson,
98
+ runtimeDependencies,
99
+ buildLibsFromSource,
100
+ typeCheckOptions: {
101
+ async: false,
102
+ },
103
+ sourceMap: 'inline-source-map',
104
+ progress: false,
105
+ }),
106
+ ],
107
+ };
108
+ webpackConfigs.push(productionBuildConfig);
109
+ if (hasOrmconfig && resolvedOrmConfigPath) {
110
+ const migrationsEntryPoints = [];
111
+ const migrationsGlobPath = path.join(appRoot, migrationsDir, '*.ts');
112
+ const migrationFiles = (0, glob_1.globSync)(migrationsGlobPath);
113
+ migrationFiles.forEach((filename) => {
114
+ const migrationName = path.basename(filename, '.ts');
115
+ migrationsEntryPoints.push({
116
+ entryName: `migrations/${migrationName}`,
117
+ entryPath: filename,
118
+ });
119
+ });
120
+ const ormconfigRelative = './' + path.relative(appRoot, resolvedOrmConfigPath);
121
+ const ormconfigBuildConfig = {
122
+ ...productionBuildConfig,
123
+ output: {
124
+ ...productionBuildConfig.output,
125
+ filename: (pathData) => {
126
+ if (pathData.runtime === 'main') {
127
+ return 'ormconfig.js';
128
+ }
129
+ return '[name].js';
130
+ },
131
+ library: {
132
+ type: 'commonjs',
133
+ },
134
+ clean: false,
135
+ },
136
+ devtool: false,
137
+ plugins: [
138
+ new app_plugin_1.NxAppWebpackPlugin({
139
+ target: 'node22',
140
+ compiler: 'tsc',
141
+ main: ormconfigRelative,
142
+ externalDependencies: [],
143
+ additionalEntryPoints: migrationsEntryPoints,
144
+ mergeExternals: true,
145
+ tsConfig,
146
+ assets: [],
147
+ namedChunks: true,
148
+ memoryLimit,
149
+ optimization: false,
150
+ outputHashing: 'none',
151
+ generatePackageJson: false,
152
+ buildLibsFromSource,
153
+ skipTypeChecking: true,
154
+ sourceMap: false,
155
+ progress: !process.env.CI,
156
+ }),
157
+ ],
158
+ };
159
+ webpackConfigs.push(ormconfigBuildConfig);
160
+ }
161
+ // Apply user webpack overrides if configured
162
+ if (webpackConfigPath) {
163
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
164
+ const overrideModule = require(path.resolve(appRoot, webpackConfigPath));
165
+ const overrideFn = overrideModule.default || overrideModule;
166
+ return webpackConfigs.map((config) => overrideFn(config));
167
+ }
168
+ return webpackConfigs;
169
+ }
@@ -0,0 +1,19 @@
1
+ import type { BuildExecutorSchema } from './schema';
2
+ interface ExecutorContext {
3
+ root: string;
4
+ projectName?: string;
5
+ projectsConfigurations?: {
6
+ projects: Record<string, {
7
+ root: string;
8
+ }>;
9
+ };
10
+ }
11
+ /**
12
+ * Production webpack build executor for NestJS applications.
13
+ */
14
+ declare function buildExecutor(options: BuildExecutorSchema, context: ExecutorContext): AsyncGenerator<{
15
+ success: boolean;
16
+ outfile?: string;
17
+ }>;
18
+ export default buildExecutor;
19
+ //# sourceMappingURL=build.impl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build.impl.d.ts","sourceRoot":"","sources":["../../../../../libs/cluster/src/executors/build/build.impl.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAKpD,UAAU,eAAe;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sBAAsB,CAAC,EAAE;QACvB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE;YAAE,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;KAC5C,CAAC;CACH;AAED;;GAEG;AACH,iBAAgB,aAAa,CAC3B,OAAO,EAAE,mBAAmB,EAC5B,OAAO,EAAE,eAAe,GACvB,cAAc,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CA2FxD;AAED,eAAe,aAAa,CAAC"}
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const fs = tslib_1.__importStar(require("node:fs"));
5
+ const path = tslib_1.__importStar(require("node:path"));
6
+ const create_webpack_prod_1 = require("../../create-webpack-prod");
7
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
8
+ const webpack = require('webpack');
9
+ /**
10
+ * Production webpack build executor for NestJS applications.
11
+ */
12
+ async function* buildExecutor(options, context) {
13
+ process.env.NODE_ENV = 'production';
14
+ const projectConfig = context.projectsConfigurations.projects[context.projectName];
15
+ const workspaceRoot = context.root;
16
+ const projectRoot = path.join(workspaceRoot, projectConfig.root);
17
+ const outputPath = options.outputPath
18
+ ? path.join(workspaceRoot, options.outputPath)
19
+ : path.join(workspaceRoot, 'dist', projectConfig.root);
20
+ // Resolve entry/tsconfig relative to project root (absolute paths avoid
21
+ // NxAppWebpackPlugin's normalizeRelativePaths collision with executor options)
22
+ const entryFile = options.entryFile || './src/deployments/service/main.ts';
23
+ const tsConfigFile = options.tsConfigFile || './tsconfig.app.json';
24
+ const resolvedMain = path.resolve(projectRoot, entryFile);
25
+ const resolvedTsConfig = path.resolve(projectRoot, tsConfigFile);
26
+ const configs = (0, create_webpack_prod_1.createProdWebpackConfig)({
27
+ appName: context.projectName,
28
+ appRoot: projectRoot,
29
+ outputDir: outputPath,
30
+ main: resolvedMain,
31
+ tsConfig: resolvedTsConfig,
32
+ assets: options.assets || [],
33
+ additionalEntryPoints: [
34
+ ...(options.workers || []).map((w) => ({ entryName: w.name, entryPath: w.entryPath })),
35
+ ...(options.additionalEntryPoints || []),
36
+ ],
37
+ runtimeDependencies: options.runtimeDependencies || [],
38
+ memoryLimit: options.memoryLimit || 8192,
39
+ generatePackageJson: options.generatePackageJson !== false,
40
+ buildLibsFromSource: options.buildLibsFromSource || false,
41
+ ormConfigPath: options.ormConfigPath,
42
+ migrationsDir: options.migrationsDir || './src/migrations',
43
+ workspaceRoot,
44
+ orgScopes: options.orgScopes || [],
45
+ bundlePackages: options.bundlePackages || [],
46
+ nodeExternalsConfig: options.nodeExternalsConfig,
47
+ webpackConfigPath: options.webpackConfigPath,
48
+ });
49
+ const configArray = Array.isArray(configs) ? configs : [configs];
50
+ for (const config of configArray) {
51
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
52
+ const { watch: _watch, ...normalizedConfig } = config;
53
+ const compiler = webpack(normalizedConfig);
54
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
55
+ const stats = await new Promise((resolve, reject) => {
56
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
57
+ compiler.run((err, stats) => {
58
+ if (err)
59
+ return reject(err);
60
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
61
+ compiler.close((closeErr) => {
62
+ if (closeErr)
63
+ console.error('[build] webpack close error:', closeErr);
64
+ });
65
+ resolve(stats);
66
+ });
67
+ });
68
+ console.info(stats.toString(config.stats || { colors: true, chunks: false }));
69
+ if (stats.hasErrors()) {
70
+ yield { success: false };
71
+ return;
72
+ }
73
+ }
74
+ // Post-process: minify worker outputs (NxAppWebpackPlugin doesn't minify additional entries)
75
+ const workerEntries = options.workers || [];
76
+ if (workerEntries.length > 0) {
77
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
78
+ const { minify } = require('terser');
79
+ for (const worker of workerEntries) {
80
+ const filePath = path.join(outputPath, `${worker.name}.js`);
81
+ if (fs.existsSync(filePath)) {
82
+ const code = fs.readFileSync(filePath, 'utf-8');
83
+ const result = await minify(code, {
84
+ keep_classnames: true,
85
+ sourceMap: { content: 'inline', url: 'inline' },
86
+ });
87
+ if (result.code) {
88
+ fs.writeFileSync(filePath, result.code);
89
+ console.info(`[build] minified ${worker.name}.js`);
90
+ }
91
+ }
92
+ }
93
+ }
94
+ yield { success: true, outfile: path.join(outputPath, 'main.js') };
95
+ }
96
+ exports.default = buildExecutor;
97
+ module.exports = buildExecutor;
98
+ module.exports.default = buildExecutor;
@@ -0,0 +1,35 @@
1
+ export interface WorkerEntryPoint {
2
+ name: string;
3
+ entryPath: string;
4
+ }
5
+
6
+ export interface AdditionalEntryPoint {
7
+ entryName: string;
8
+ entryPath: string;
9
+ }
10
+
11
+ export interface NodeExternalsConfig {
12
+ allowlist?: string[];
13
+ additionalModuleDirs?: string[];
14
+ importType?: string;
15
+ }
16
+
17
+ export interface BuildExecutorSchema {
18
+ entryFile: string;
19
+ tsConfigFile: string;
20
+ outputPath?: string;
21
+ assets?: string[];
22
+ workers?: WorkerEntryPoint[];
23
+ /** @deprecated Use `workers` instead. */
24
+ additionalEntryPoints?: AdditionalEntryPoint[];
25
+ runtimeDependencies?: string[];
26
+ ormConfigPath?: string;
27
+ migrationsDir?: string;
28
+ memoryLimit?: number;
29
+ generatePackageJson?: boolean;
30
+ buildLibsFromSource?: boolean;
31
+ orgScopes?: string[];
32
+ bundlePackages?: string[];
33
+ nodeExternalsConfig?: NodeExternalsConfig;
34
+ webpackConfigPath?: string;
35
+ }
@@ -0,0 +1,135 @@
1
+ {
2
+ "$schema": "https://json-schema.org/schema",
3
+ "$id": "DavnxWebpackBuild",
4
+ "version": 2,
5
+ "outputCapture": "direct-nodejs",
6
+ "title": "NestJS Webpack Build",
7
+ "description": "Build a NestJS application using webpack.",
8
+ "cli": "nx",
9
+ "type": "object",
10
+ "properties": {
11
+ "entryFile": {
12
+ "type": "string",
13
+ "description": "Path to the main entry-point file, relative to project root.",
14
+ "x-completion-type": "file",
15
+ "x-completion-glob": "**/*@(.js|.ts)",
16
+ "x-priority": "important",
17
+ "default": "./src/deployments/service/main.ts"
18
+ },
19
+ "tsConfigFile": {
20
+ "type": "string",
21
+ "description": "Path to the TypeScript configuration file, relative to project root.",
22
+ "x-completion-type": "file",
23
+ "x-completion-glob": "tsconfig*.json",
24
+ "x-priority": "important",
25
+ "default": "./tsconfig.app.json"
26
+ },
27
+ "outputPath": {
28
+ "type": "string",
29
+ "description": "Output directory path, relative to workspace root.",
30
+ "x-completion-type": "directory"
31
+ },
32
+ "assets": {
33
+ "type": "array",
34
+ "description": "List of static assets to copy.",
35
+ "items": { "type": "string" },
36
+ "default": []
37
+ },
38
+ "workers": {
39
+ "type": "array",
40
+ "description": "Worker entry points. Each produces a self-contained, minified [name].js bundle.",
41
+ "items": {
42
+ "type": "object",
43
+ "properties": {
44
+ "name": { "type": "string", "description": "Output filename (without .js extension)." },
45
+ "entryPath": { "type": "string", "description": "Path to the worker entry file. './' paths are relative to project root, otherwise relative to workspace root." }
46
+ },
47
+ "required": ["name", "entryPath"]
48
+ },
49
+ "default": []
50
+ },
51
+ "additionalEntryPoints": {
52
+ "type": "array",
53
+ "description": "Additional webpack entry points (deprecated, use 'workers' instead).",
54
+ "x-deprecated": "Use 'workers' instead.",
55
+ "items": {
56
+ "type": "object",
57
+ "properties": {
58
+ "entryName": { "type": "string" },
59
+ "entryPath": { "type": "string" }
60
+ }
61
+ },
62
+ "default": []
63
+ },
64
+ "runtimeDependencies": {
65
+ "type": "array",
66
+ "description": "Runtime dependencies to include in generated package.json.",
67
+ "items": { "type": "string" },
68
+ "default": []
69
+ },
70
+ "ormConfigPath": {
71
+ "type": "string",
72
+ "description": "Path to ormconfig.ts relative to project root. Auto-detected from src/ormconfig.ts if not specified."
73
+ },
74
+ "migrationsDir": {
75
+ "type": "string",
76
+ "description": "Path to migrations directory relative to project root.",
77
+ "default": "./src/migrations"
78
+ },
79
+ "memoryLimit": {
80
+ "type": "number",
81
+ "description": "Memory limit in MB for TypeScript type checker.",
82
+ "default": 8192
83
+ },
84
+ "generatePackageJson": {
85
+ "type": "boolean",
86
+ "description": "Generate package.json in output.",
87
+ "default": true
88
+ },
89
+ "buildLibsFromSource": {
90
+ "type": "boolean",
91
+ "description": "Read buildable libraries from source.",
92
+ "default": false
93
+ },
94
+ "orgScopes": {
95
+ "type": "array",
96
+ "description": "Patterns to bundle rather than externalize. Supports 4 modes: org scope ('@myorg' → @myorg/*), prefix ('@myorg/prefix' → @myorg/prefix*), regex ('/^pattern/' → custom regex), exact package name ('lodash' → lodash and lodash/subpath).",
97
+ "items": { "type": "string" },
98
+ "default": []
99
+ },
100
+ "bundlePackages": {
101
+ "type": "array",
102
+ "description": "Explicit package names to force-bundle into the output instead of externalizing (e.g. ['lodash', 'my-pkg']).",
103
+ "items": { "type": "string" },
104
+ "default": []
105
+ },
106
+ "nodeExternalsConfig": {
107
+ "type": "object",
108
+ "description": "Override options for webpack-node-externals. Merged with defaults — allowlist entries are appended to orgScopes and bundlePackages.",
109
+ "properties": {
110
+ "allowlist": {
111
+ "type": "array",
112
+ "description": "Additional patterns to allowlist (bundle instead of externalize).",
113
+ "items": { "type": "string" }
114
+ },
115
+ "additionalModuleDirs": {
116
+ "type": "array",
117
+ "description": "Additional directories to scan for modules to externalize.",
118
+ "items": { "type": "string" }
119
+ },
120
+ "importType": {
121
+ "type": "string",
122
+ "description": "Module import type for externalized packages (default: 'commonjs')."
123
+ }
124
+ }
125
+ },
126
+ "webpackConfigPath": {
127
+ "type": "string",
128
+ "description": "Path to a JS/TS file (relative to project root) that exports a (config) => config function for custom webpack overrides.",
129
+ "x-completion-type": "file",
130
+ "x-completion-glob": "webpack*@(.js|.ts)"
131
+ }
132
+ },
133
+ "required": ["entryFile", "tsConfigFile"],
134
+ "additionalProperties": false
135
+ }
@@ -0,0 +1,23 @@
1
+ import type { GatewayExecutorSchema } from './schema';
2
+ import { type GatewayContext } from './gateway.lib';
3
+ /**
4
+ * `gateway` executor — ONE https front door for the whole workspace,
5
+ * assembled dynamically from every project's `cluster` declaration:
6
+ *
7
+ * "cluster": { "host": "api.tetros.ai.local", "service": "api", "prependPrefix": "/api" }
8
+ * "cluster": { "host": "tetros.ai.local", "port": 5173, "default": true }
9
+ *
10
+ * Socket-pool services get production-shaped treatment: the gateway is the
11
+ * load balancer, round-robining each request across the service's child
12
+ * sockets (the pods), with serverless lifecycle (eager/minPods/maxPods/
13
+ * idleKillSec) and an auto `internal.<host>` domain for east-west calls
14
+ * that bypass the middleware (JWT) — a full prod demo on localhost. All of
15
+ * it is published to the LensMCP bus (source `gateway`, category `cluster`).
16
+ *
17
+ * The runtime lives in `gateway.lib.ts` (`startGateway`) so it is testable
18
+ * without signals; this wrapper only adds the executor contract.
19
+ */
20
+ export default function gatewayExecutor(options: GatewayExecutorSchema, context: GatewayContext): Promise<{
21
+ success: boolean;
22
+ }>;
23
+ //# sourceMappingURL=gateway.impl.d.ts.map