diff --git a/packages/cli/package.json b/packages/cli/package.json index 5c589116ee..92fa2ee075 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -77,6 +77,7 @@ "@types/yamljs": "^0.2.31", "@vvo/tzdb": "^6.141.0", "concurrently": "^8.2.0", + "func-loc": "^0.1.16", "ioredis-mock": "^8.8.1", "mjml": "^4.15.3", "ts-essentials": "^7.0.3" diff --git a/packages/cli/src/commands/base-command.ts b/packages/cli/src/commands/base-command.ts index 2eb818b736..7f21f8846f 100644 --- a/packages/cli/src/commands/base-command.ts +++ b/packages/cli/src/commands/base-command.ts @@ -356,6 +356,7 @@ export abstract class BaseCommand extends Command { const { Push } = await import('@/push'); const push = Container.get(Push); + // #region Hot-reload for nodes Object.values(this.loadNodesAndCredentials.loaders).forEach(async (loader) => { try { await fsAccess(loader.directory); @@ -398,5 +399,34 @@ export abstract class BaseCommand extends Command { }); watcher.on('add', reloader).on('change', reloader).on('unlink', reloader); }); + // #endregion + + // #region Hot-reload for Backend DI services + // eslint-disable-next-line import/no-extraneous-dependencies + const { locate } = await import('func-loc'); + + // @ts-expect-error globalInstance is marked as private + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment + const { services } = Container.of() as { + services: Array<{ type: (...args: any[]) => any; value: object }>; + }; + services.forEach(async (service) => { + const file = await locate(service.type); + if (!file?.path) return; + watch(file.path).on( + 'change', + debounce(() => { + console.info(picocolors.green('тно Reloading service'), picocolors.bold(service.type.name)); + delete require.cache[file.path]; + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-var-requires, @typescript-eslint/no-unsafe-member-access + const updatedClass = require(file.path)[service.type.name]; + // @ts-expect-error + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access + service.value.__proto__ = updatedClass.prototype; + }, 1000), + ); + }); + + // #endregion } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 10e0fbf08b..c6b2c12616 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -265,7 +265,7 @@ importers: version: 4.0.7 axios: specifier: 'catalog:' - version: 1.7.4 + version: 1.7.4(debug@4.3.7) dotenv: specifier: 8.6.0 version: 8.6.0 @@ -333,7 +333,7 @@ importers: dependencies: axios: specifier: 'catalog:' - version: 1.7.4 + version: 1.7.4(debug@4.3.7) packages/@n8n/codemirror-lang: dependencies: @@ -407,7 +407,7 @@ importers: version: 3.666.0(@aws-sdk/client-sts@3.666.0) '@getzep/zep-cloud': specifier: 1.0.12 - version: 1.0.12(@langchain/core@0.3.15(openai@4.69.0(encoding@0.1.13)(zod@3.23.8)))(encoding@0.1.13)(langchain@0.3.5(7umjwzmwnymi4lyinuvazmp6ki)) + version: 1.0.12(@langchain/core@0.3.15(openai@4.69.0(encoding@0.1.13)(zod@3.23.8)))(encoding@0.1.13)(langchain@0.3.5(4ubssgvn2k3t3hxnzmxuoc2aja)) '@getzep/zep-js': specifier: 0.9.0 version: 0.9.0 @@ -434,7 +434,7 @@ importers: version: 0.3.1(@aws-sdk/client-sso-oidc@3.666.0(@aws-sdk/client-sts@3.666.0))(@langchain/core@0.3.15(openai@4.69.0(encoding@0.1.13)(zod@3.23.8)))(encoding@0.1.13) '@langchain/community': specifier: 0.3.11 - version: 0.3.11(simkpjwqw7qnwbripe37u5qu7a) + version: 0.3.11(tzffvezibmkr4px5bpuitcp7xu) '@langchain/core': specifier: 'catalog:' version: 0.3.15(openai@4.69.0(encoding@0.1.13)(zod@3.23.8)) @@ -521,7 +521,7 @@ importers: version: 23.0.1 langchain: specifier: 0.3.5 - version: 0.3.5(7umjwzmwnymi4lyinuvazmp6ki) + version: 0.3.5(4ubssgvn2k3t3hxnzmxuoc2aja) lodash: specifier: 'catalog:' version: 4.17.21 @@ -774,7 +774,7 @@ importers: version: 1.11.0 axios: specifier: 'catalog:' - version: 1.7.4 + version: 1.7.4(debug@4.3.7) bcryptjs: specifier: 2.4.3 version: 2.4.3 @@ -1079,6 +1079,9 @@ importers: concurrently: specifier: ^8.2.0 version: 8.2.0 + func-loc: + specifier: ^0.1.16 + version: 0.1.16 ioredis-mock: specifier: ^8.8.1 version: 8.8.1(@types/ioredis-mock@8.2.2)(ioredis@5.3.2) @@ -1105,7 +1108,7 @@ importers: version: 1.11.0 axios: specifier: 'catalog:' - version: 1.7.4 + version: 1.7.4(debug@4.3.7) concat-stream: specifier: 2.0.0 version: 2.0.0 @@ -1395,7 +1398,7 @@ importers: version: 10.11.0(vue@3.5.11(typescript@5.6.2)) axios: specifier: 'catalog:' - version: 1.7.4 + version: 1.7.4(debug@4.3.7) bowser: specifier: 2.11.0 version: 2.11.0 @@ -1872,7 +1875,7 @@ importers: version: 0.15.2 axios: specifier: 'catalog:' - version: 1.7.4 + version: 1.7.4(debug@4.3.7) callsites: specifier: 3.1.0 version: 3.1.0 @@ -6502,6 +6505,10 @@ packages: resolution: {integrity: sha512-jRFi8UDGo6j+odZiEpjazZaWqEal3w/basFjQHQEwVtZJGDpxbH1MeYluwCS8Xq5wmLJooDlMgvVarmWfGM44g==} engines: {node: '>=0.10'} + data-urls@2.0.0: + resolution: {integrity: sha512-X5eWTSXO/BJmpdIKCRuKUgSCgAN0OwliVK3yPKbwIWU1Tdw5BRajxlzMidvh+gwko9AfQ9zIj52pzF91Q3YAvQ==} + engines: {node: '>=10'} + data-urls@3.0.2: resolution: {integrity: sha512-Jy/tj3ldjZJo63sVAvg6LHt2mHvl4V6AgRAmNDtLdm7faqtsx+aJG42rsyCo9JCoRVKwPFzKlIPx3DIibwSIaQ==} engines: {node: '>=12'} @@ -7531,6 +7538,10 @@ packages: engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} os: [darwin] + func-loc@0.1.16: + resolution: {integrity: sha512-xxKNe8YQ1++4WhCVLZo9ASrP0gjlO0WmhGz/brwyXyTm4Xk8QzuNi50ZeBsVxxTVXl5r51eW6Niu53aaJCAaIA==} + engines: {node: '>= 8.0.0'} + function-bind@1.1.2: resolution: {integrity: sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==} @@ -10994,6 +11005,10 @@ packages: resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==} engines: {node: '>=0.10.0'} + source-map@0.7.4: + resolution: {integrity: sha512-l3BikUxvPOcn5E74dZiq5BGsTb5yEwhaTSzccU6t4sDOH8NWJCstKO5QT2CvtFoK6F0saL7p9xHAqHOlCPJygA==} + engines: {node: '>= 8'} + space-separated-tokens@2.0.2: resolution: {integrity: sha512-PEGlAwrG8yXGXRjW32fGbg66JAlOAwbObuqVoJpv/mRgoWDQfgH1wDPvtzWyUSNAXBGSk8h755YDbbcEy3SH2Q==} @@ -11454,6 +11469,10 @@ packages: tr46@0.0.3: resolution: {integrity: sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==} + tr46@2.1.0: + resolution: {integrity: sha512-15Ih7phfcdP5YxqiB+iDtLoaTz4Nd35+IiAv0kQ5FNKHzXgdWqPoTIqEDDJmXceQt4JZk6lVPT8lnDlPpGDppw==} + engines: {node: '>=8'} + tr46@3.0.0: resolution: {integrity: sha512-l7FvfAHlcmulp8kr+flpQZmVwtu7nfRV7NZujtN0OqES8EL4O4e0qqzL0DC5gAvx/ZC/9lk6rhcUwYvkBnBnYA==} engines: {node: '>=12'} @@ -12152,6 +12171,10 @@ packages: webidl-conversions@3.0.1: resolution: {integrity: sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==} + webidl-conversions@6.1.0: + resolution: {integrity: sha512-qBIvFLGiBpLjfwmYAaHPXsn+ho5xZnGvyGvsarywGNc8VyQJUMHJ8OBKGGrPER0okBeMDaan4mNBlgBROxuI8w==} + engines: {node: '>=10.4'} + webidl-conversions@7.0.0: resolution: {integrity: sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==} engines: {node: '>=12'} @@ -12174,6 +12197,9 @@ packages: whatwg-fetch@3.6.20: resolution: {integrity: sha512-EqhiFU6daOA8kpjOWTL0olhVOF3i7OrFzSYiGsEMB8GcXS+RrzauAERX65xMeNWVqxA6HXH2m69Z9LaKKdisfg==} + whatwg-mimetype@2.3.0: + resolution: {integrity: sha512-M4yMwr6mAnQz76TbJm914+gPpB/nCwvZbJU28cUD6dR004SAxDLOOSUaB1JDRqLtaOV/vi0IC5lEAGFgrjGv/g==} + whatwg-mimetype@3.0.0: resolution: {integrity: sha512-nt+N2dzIutVRxARx1nghPKGv1xHikU7HKdfafKkLNLindmPU/ch3U31NOCGGA/dmPcmb1VlofO0vnKAcsm0o/Q==} engines: {node: '>=12'} @@ -12197,6 +12223,10 @@ packages: whatwg-url@5.0.0: resolution: {integrity: sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==} + whatwg-url@8.7.0: + resolution: {integrity: sha512-gAojqb/m9Q8a5IV96E3fHJM70AzCkgt4uXYX2O7EmuyOnLrViCQlsEBmF9UQIu3/aeAIp2U17rtbpZWNntQqdg==} + engines: {node: '>=10'} + which-boxed-primitive@1.0.2: resolution: {integrity: sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg==} @@ -14066,7 +14096,7 @@ snapshots: '@gar/promisify@1.1.3': optional: true - '@getzep/zep-cloud@1.0.12(@langchain/core@0.3.15(openai@4.69.0(encoding@0.1.13)(zod@3.23.8)))(encoding@0.1.13)(langchain@0.3.5(7umjwzmwnymi4lyinuvazmp6ki))': + '@getzep/zep-cloud@1.0.12(@langchain/core@0.3.15(openai@4.69.0(encoding@0.1.13)(zod@3.23.8)))(encoding@0.1.13)(langchain@0.3.5(4ubssgvn2k3t3hxnzmxuoc2aja))': dependencies: form-data: 4.0.0 node-fetch: 2.7.0(encoding@0.1.13) @@ -14075,7 +14105,7 @@ snapshots: zod: 3.23.8 optionalDependencies: '@langchain/core': 0.3.15(openai@4.69.0(encoding@0.1.13)(zod@3.23.8)) - langchain: 0.3.5(7umjwzmwnymi4lyinuvazmp6ki) + langchain: 0.3.5(4ubssgvn2k3t3hxnzmxuoc2aja) transitivePeerDependencies: - encoding @@ -14542,7 +14572,7 @@ snapshots: - aws-crt - encoding - '@langchain/community@0.3.11(simkpjwqw7qnwbripe37u5qu7a)': + '@langchain/community@0.3.11(tzffvezibmkr4px5bpuitcp7xu)': dependencies: '@ibm-cloud/watsonx-ai': 1.1.2 '@langchain/core': 0.3.15(openai@4.69.0(encoding@0.1.13)(zod@3.23.8)) @@ -14552,7 +14582,7 @@ snapshots: flat: 5.0.2 ibm-cloud-sdk-core: 5.1.0 js-yaml: 4.1.0 - langchain: 0.3.5(7umjwzmwnymi4lyinuvazmp6ki) + langchain: 0.3.5(4ubssgvn2k3t3hxnzmxuoc2aja) langsmith: 0.2.3(openai@4.69.0(encoding@0.1.13)(zod@3.23.8)) uuid: 10.0.0 zod: 3.23.8 @@ -14565,7 +14595,7 @@ snapshots: '@aws-sdk/client-s3': 3.666.0 '@aws-sdk/credential-provider-node': 3.666.0(@aws-sdk/client-sso-oidc@3.666.0(@aws-sdk/client-sts@3.666.0))(@aws-sdk/client-sts@3.666.0) '@azure/storage-blob': 12.18.0(encoding@0.1.13) - '@getzep/zep-cloud': 1.0.12(@langchain/core@0.3.15(openai@4.69.0(encoding@0.1.13)(zod@3.23.8)))(encoding@0.1.13)(langchain@0.3.5(7umjwzmwnymi4lyinuvazmp6ki)) + '@getzep/zep-cloud': 1.0.12(@langchain/core@0.3.15(openai@4.69.0(encoding@0.1.13)(zod@3.23.8)))(encoding@0.1.13)(langchain@0.3.5(4ubssgvn2k3t3hxnzmxuoc2aja)) '@getzep/zep-js': 0.9.0 '@google-ai/generativelanguage': 2.6.0(encoding@0.1.13) '@google-cloud/storage': 7.12.1(encoding@0.1.13) @@ -15278,7 +15308,7 @@ snapshots: '@rudderstack/rudder-sdk-node@2.0.9(tslib@2.6.2)': dependencies: - axios: 1.7.4 + axios: 1.7.4(debug@4.3.7) axios-retry: 3.7.0 component-type: 1.2.1 join-component: 1.1.0 @@ -17534,17 +17564,9 @@ snapshots: '@babel/runtime': 7.24.7 is-retry-allowed: 2.2.0 - axios@1.7.4: - dependencies: - follow-redirects: 1.15.6(debug@4.3.6) - form-data: 4.0.0 - proxy-from-env: 1.1.0 - transitivePeerDependencies: - - debug - axios@1.7.4(debug@4.3.7): dependencies: - follow-redirects: 1.15.6(debug@4.3.7) + follow-redirects: 1.15.6(debug@4.3.6) form-data: 4.0.0 proxy-from-env: 1.1.0 transitivePeerDependencies: @@ -18511,6 +18533,12 @@ snapshots: dependencies: assert-plus: 1.0.0 + data-urls@2.0.0: + dependencies: + abab: 2.0.6 + whatwg-mimetype: 2.3.0 + whatwg-url: 8.7.0 + data-urls@3.0.2: dependencies: abab: 2.0.6 @@ -19856,6 +19884,12 @@ snapshots: fsevents@2.3.3: optional: true + func-loc@0.1.16: + dependencies: + data-urls: 2.0.0 + source-map: 0.7.4 + uuid: 8.3.2 + function-bind@1.1.2: {} function.prototype.name@1.1.5: @@ -21378,7 +21412,7 @@ snapshots: kuler@2.0.0: {} - langchain@0.3.5(7umjwzmwnymi4lyinuvazmp6ki): + langchain@0.3.5(4ubssgvn2k3t3hxnzmxuoc2aja): dependencies: '@langchain/core': 0.3.15(openai@4.69.0(encoding@0.1.13)(zod@3.23.8)) '@langchain/openai': 0.3.11(@langchain/core@0.3.15(openai@4.69.0(encoding@0.1.13)(zod@3.23.8)))(encoding@0.1.13) @@ -21402,7 +21436,7 @@ snapshots: '@langchain/groq': 0.1.2(@langchain/core@0.3.15(openai@4.69.0(encoding@0.1.13)(zod@3.23.8)))(encoding@0.1.13) '@langchain/mistralai': 0.1.1(@langchain/core@0.3.15(openai@4.69.0(encoding@0.1.13)(zod@3.23.8)))(encoding@0.1.13) '@langchain/ollama': 0.1.1(@langchain/core@0.3.15(openai@4.69.0(encoding@0.1.13)(zod@3.23.8))) - axios: 1.7.4 + axios: 1.7.4(debug@4.3.7) cheerio: 1.0.0 handlebars: 4.7.8 transitivePeerDependencies: @@ -24242,6 +24276,8 @@ snapshots: source-map@0.6.1: {} + source-map@0.7.4: {} + space-separated-tokens@2.0.2: {} sparse-bitfield@3.0.3: @@ -24804,6 +24840,10 @@ snapshots: tr46@0.0.3: {} + tr46@2.1.0: + dependencies: + punycode: 2.3.1 + tr46@3.0.0: dependencies: punycode: 2.3.1 @@ -25506,6 +25546,8 @@ snapshots: webidl-conversions@3.0.1: {} + webidl-conversions@6.1.0: {} + webidl-conversions@7.0.0: {} webpack-sources@3.2.3: {} @@ -25522,6 +25564,8 @@ snapshots: whatwg-fetch@3.6.20: {} + whatwg-mimetype@2.3.0: {} + whatwg-mimetype@3.0.0: {} whatwg-mimetype@4.0.0: {} @@ -25546,6 +25590,12 @@ snapshots: tr46: 0.0.3 webidl-conversions: 3.0.1 + whatwg-url@8.7.0: + dependencies: + lodash: 4.17.21 + tr46: 2.1.0 + webidl-conversions: 6.1.0 + which-boxed-primitive@1.0.2: dependencies: is-bigint: 1.0.4