diff --git a/.gitignore b/.gitignore index 0f0ef3e..6bbd2f4 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,9 @@ dist # dist/app.cjs app.config.json5 + +apps.config.json + deploy.tar.gz cache-file diff --git a/package.json b/package.json index 611c824..8a6fd56 100644 --- a/package.json +++ b/package.json @@ -37,11 +37,11 @@ "@kevisual/ai-graph": "workspace:^", "@kevisual/ai-lang": "workspace:^", "@kevisual/auth": "1.0.4", - "@kevisual/router": "0.0.5-alpha-2", + "@kevisual/router": "0.0.5", "@supabase/supabase-js": "^2.46.1", "@types/semver": "^7.5.8", "archiver": "^7.0.1", - "bullmq": "^5.26.2", + "bullmq": "^5.29.0", "dayjs": "^1.11.13", "dts-bundle-generator": "^9.5.1", "formidable": "^3.5.2", @@ -69,7 +69,7 @@ }, "devDependencies": { "@abearxiong/use-file-store": "^0.0.1", - "@kevisual/use-config": "^1.0.1", + "@kevisual/use-config": "^1.0.2", "@rollup/plugin-alias": "^5.1.1", "@rollup/plugin-commonjs": "^28.0.1", "@rollup/plugin-json": "^6.1.0", @@ -80,7 +80,7 @@ "@types/formidable": "^3.4.5", "@types/jsonwebtoken": "^9.0.7", "@types/lodash-es": "^4.17.12", - "@types/node": "^22.9.0", + "@types/node": "^22.9.1", "@types/react": "^18.3.12", "@types/uuid": "^10.0.0", "concurrently": "^9.1.0", @@ -89,7 +89,7 @@ "nodemon": "^3.1.7", "pm2": "^5.4.3", "rimraf": "^6.0.1", - "rollup": "^4.27.2", + "rollup": "^4.27.3", "rollup-plugin-copy": "^3.5.0", "rollup-plugin-dts": "^6.1.1", "tape": "^5.9.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1588413..bbe4ab8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -34,10 +34,10 @@ importers: version: link:packages/ai-lang '@kevisual/auth': specifier: 1.0.4 - version: 1.0.4(@kevisual/router@0.0.5-alpha-2) + version: 1.0.4(@kevisual/router@0.0.5) '@kevisual/router': - specifier: 0.0.5-alpha-2 - version: 0.0.5-alpha-2 + specifier: 0.0.5 + version: 0.0.5 '@supabase/supabase-js': specifier: ^2.46.1 version: 2.46.1 @@ -48,8 +48,8 @@ importers: specifier: ^7.0.1 version: 7.0.1 bullmq: - specifier: ^5.26.2 - version: 5.26.2 + specifier: ^5.29.0 + version: 5.29.0 dayjs: specifier: ^1.11.13 version: 1.11.13 @@ -97,7 +97,7 @@ importers: version: 8.13.1 rollup-plugin-esbuild: specifier: ^6.1.1 - version: 6.1.1(esbuild@0.23.1)(rollup@4.27.2) + version: 6.1.1(esbuild@0.23.1)(rollup@4.27.3) semver: specifier: ^7.6.3 version: 7.6.3 @@ -127,23 +127,23 @@ importers: specifier: ^0.0.1 version: 0.0.1(esbuild@0.23.1)(typescript@5.6.3) '@kevisual/use-config': - specifier: ^1.0.1 - version: 1.0.1 + specifier: ^1.0.2 + version: 1.0.2 '@rollup/plugin-alias': specifier: ^5.1.1 - version: 5.1.1(rollup@4.27.2) + version: 5.1.1(rollup@4.27.3) '@rollup/plugin-commonjs': specifier: ^28.0.1 - version: 28.0.1(rollup@4.27.2) + version: 28.0.1(rollup@4.27.3) '@rollup/plugin-json': specifier: ^6.1.0 - version: 6.1.0(rollup@4.27.2) + version: 6.1.0(rollup@4.27.3) '@rollup/plugin-node-resolve': specifier: ^15.3.0 - version: 15.3.0(rollup@4.27.2) + version: 15.3.0(rollup@4.27.3) '@rollup/plugin-typescript': specifier: ^12.1.1 - version: 12.1.1(rollup@4.27.2)(tslib@2.7.0)(typescript@5.6.3) + version: 12.1.1(rollup@4.27.3)(tslib@2.7.0)(typescript@5.6.3) '@types/archiver': specifier: ^6.0.3 version: 6.0.3 @@ -160,8 +160,8 @@ importers: specifier: ^4.17.12 version: 4.17.12 '@types/node': - specifier: ^22.9.0 - version: 22.9.0 + specifier: ^22.9.1 + version: 22.9.1 '@types/react': specifier: ^18.3.12 version: 18.3.12 @@ -187,14 +187,14 @@ importers: specifier: latest version: 6.0.1 rollup: - specifier: ^4.27.2 - version: 4.27.2 + specifier: ^4.27.3 + version: 4.27.3 rollup-plugin-copy: specifier: ^3.5.0 version: 3.5.0 rollup-plugin-dts: specifier: ^6.1.1 - version: 6.1.1(rollup@4.27.2)(typescript@5.6.3) + version: 6.1.1(rollup@4.27.3)(typescript@5.6.3) tape: specifier: ^5.9.0 version: 5.9.0 @@ -1063,11 +1063,11 @@ packages: peerDependencies: '@kevisual/router': ^0.0.4 - '@kevisual/router@0.0.5-alpha-2': - resolution: {integrity: sha512-9cCa7CEji4q2ByMxxaxzqia42EzbBGdNGKqvs25c2qedAvnXbYaRpaiOdNSNiIXg+eTPQ0ah5HDNRcY2XApD8Q==} + '@kevisual/router@0.0.5': + resolution: {integrity: sha512-ALDsOrKwgxKWwwrnWgrcYoCPPSX0D6aU4P784HQslkLMRoQQ4xgsGr95BW+Wk9LeesXWsUhEpDW3QjUSzYoPlA==} - '@kevisual/use-config@1.0.1': - resolution: {integrity: sha512-3osr7pSS/PgvrIGG1Hiv0PUDubkFLei11hI0b9JNHZhnNhqHYv5W21Mr/vUOLJhvn+y5ltlL81ojUePmnYPH7w==} + '@kevisual/use-config@1.0.2': + resolution: {integrity: sha512-vXW07vB2rgnPZWmFSk3jb1R8yjOei7EF67ly4quPfOLOgCNvQ37F597tLQIympfDpOuAL/hDrcuT8WQ55O4l4A==} '@langchain/core@0.3.3': resolution: {integrity: sha512-WAtkmhbdl2T41qzimTzhb3pXCHQxO4onqxzPxgdf3KftQdTwLq0YYBDhozRMZLNAd/+cfH0ymZGaZSsnc9Ogsg==} @@ -1242,100 +1242,199 @@ packages: cpu: [arm] os: [android] + '@rollup/rollup-android-arm-eabi@4.27.3': + resolution: {integrity: sha512-EzxVSkIvCFxUd4Mgm4xR9YXrcp976qVaHnqom/Tgm+vU79k4vV4eYTjmRvGfeoW8m9LVcsAy/lGjcgVegKEhLQ==} + cpu: [arm] + os: [android] + '@rollup/rollup-android-arm64@4.27.2': resolution: {integrity: sha512-xsPeJgh2ThBpUqlLgRfiVYBEf/P1nWlWvReG+aBWfNv3XEBpa6ZCmxSVnxJgLgkNz4IbxpLy64h2gCmAAQLneQ==} cpu: [arm64] os: [android] + '@rollup/rollup-android-arm64@4.27.3': + resolution: {integrity: sha512-LJc5pDf1wjlt9o/Giaw9Ofl+k/vLUaYsE2zeQGH85giX2F+wn/Cg8b3c5CDP3qmVmeO5NzwVUzQQxwZvC2eQKw==} + cpu: [arm64] + os: [android] + '@rollup/rollup-darwin-arm64@4.27.2': resolution: {integrity: sha512-KnXU4m9MywuZFedL35Z3PuwiTSn/yqRIhrEA9j+7OSkji39NzVkgxuxTYg5F8ryGysq4iFADaU5osSizMXhU2A==} cpu: [arm64] os: [darwin] + '@rollup/rollup-darwin-arm64@4.27.3': + resolution: {integrity: sha512-OuRysZ1Mt7wpWJ+aYKblVbJWtVn3Cy52h8nLuNSzTqSesYw1EuN6wKp5NW/4eSre3mp12gqFRXOKTcN3AI3LqA==} + cpu: [arm64] + os: [darwin] + '@rollup/rollup-darwin-x64@4.27.2': resolution: {integrity: sha512-Hj77A3yTvUeCIx/Vi+4d4IbYhyTwtHj07lVzUgpUq9YpJSEiGJj4vXMKwzJ3w5zp5v3PFvpJNgc/J31smZey6g==} cpu: [x64] os: [darwin] + '@rollup/rollup-darwin-x64@4.27.3': + resolution: {integrity: sha512-xW//zjJMlJs2sOrCmXdB4d0uiilZsOdlGQIC/jjmMWT47lkLLoB1nsNhPUcnoqyi5YR6I4h+FjBpILxbEy8JRg==} + cpu: [x64] + os: [darwin] + '@rollup/rollup-freebsd-arm64@4.27.2': resolution: {integrity: sha512-RjgKf5C3xbn8gxvCm5VgKZ4nn0pRAIe90J0/fdHUsgztd3+Zesb2lm2+r6uX4prV2eUByuxJNdt647/1KPRq5g==} cpu: [arm64] os: [freebsd] + '@rollup/rollup-freebsd-arm64@4.27.3': + resolution: {integrity: sha512-58E0tIcwZ+12nK1WiLzHOD8I0d0kdrY/+o7yFVPRHuVGY3twBwzwDdTIBGRxLmyjciMYl1B/U515GJy+yn46qw==} + cpu: [arm64] + os: [freebsd] + '@rollup/rollup-freebsd-x64@4.27.2': resolution: {integrity: sha512-duq21FoXwQtuws+V9H6UZ+eCBc7fxSpMK1GQINKn3fAyd9DFYKPJNcUhdIKOrMFjLEJgQskoMoiuizMt+dl20g==} cpu: [x64] os: [freebsd] + '@rollup/rollup-freebsd-x64@4.27.3': + resolution: {integrity: sha512-78fohrpcVwTLxg1ZzBMlwEimoAJmY6B+5TsyAZ3Vok7YabRBUvjYTsRXPTjGEvv/mfgVBepbW28OlMEz4w8wGA==} + cpu: [x64] + os: [freebsd] + '@rollup/rollup-linux-arm-gnueabihf@4.27.2': resolution: {integrity: sha512-6npqOKEPRZkLrMcvyC/32OzJ2srdPzCylJjiTJT2c0bwwSGm7nz2F9mNQ1WrAqCBZROcQn91Fno+khFhVijmFA==} cpu: [arm] os: [linux] libc: [glibc] + '@rollup/rollup-linux-arm-gnueabihf@4.27.3': + resolution: {integrity: sha512-h2Ay79YFXyQi+QZKo3ISZDyKaVD7uUvukEHTOft7kh00WF9mxAaxZsNs3o/eukbeKuH35jBvQqrT61fzKfAB/Q==} + cpu: [arm] + os: [linux] + libc: [glibc] + '@rollup/rollup-linux-arm-musleabihf@4.27.2': resolution: {integrity: sha512-V9Xg6eXtgBtHq2jnuQwM/jr2mwe2EycnopO8cbOvpzFuySCGtKlPCI3Hj9xup/pJK5Q0388qfZZy2DqV2J8ftw==} cpu: [arm] os: [linux] libc: [musl] + '@rollup/rollup-linux-arm-musleabihf@4.27.3': + resolution: {integrity: sha512-Sv2GWmrJfRY57urktVLQ0VKZjNZGogVtASAgosDZ1aUB+ykPxSi3X1nWORL5Jk0sTIIwQiPH7iE3BMi9zGWfkg==} + cpu: [arm] + os: [linux] + libc: [musl] + '@rollup/rollup-linux-arm64-gnu@4.27.2': resolution: {integrity: sha512-uCFX9gtZJoQl2xDTpRdseYuNqyKkuMDtH6zSrBTA28yTfKyjN9hQ2B04N5ynR8ILCoSDOrG/Eg+J2TtJ1e/CSA==} cpu: [arm64] os: [linux] libc: [glibc] + '@rollup/rollup-linux-arm64-gnu@4.27.3': + resolution: {integrity: sha512-FPoJBLsPW2bDNWjSrwNuTPUt30VnfM8GPGRoLCYKZpPx0xiIEdFip3dH6CqgoT0RnoGXptaNziM0WlKgBc+OWQ==} + cpu: [arm64] + os: [linux] + libc: [glibc] + '@rollup/rollup-linux-arm64-musl@4.27.2': resolution: {integrity: sha512-/PU9P+7Rkz8JFYDHIi+xzHabOu9qEWR07L5nWLIUsvserrxegZExKCi2jhMZRd0ATdboKylu/K5yAXbp7fYFvA==} cpu: [arm64] os: [linux] libc: [musl] + '@rollup/rollup-linux-arm64-musl@4.27.3': + resolution: {integrity: sha512-TKxiOvBorYq4sUpA0JT+Fkh+l+G9DScnG5Dqx7wiiqVMiRSkzTclP35pE6eQQYjP4Gc8yEkJGea6rz4qyWhp3g==} + cpu: [arm64] + os: [linux] + libc: [musl] + '@rollup/rollup-linux-powerpc64le-gnu@4.27.2': resolution: {integrity: sha512-eCHmol/dT5odMYi/N0R0HC8V8QE40rEpkyje/ZAXJYNNoSfrObOvG/Mn+s1F/FJyB7co7UQZZf6FuWnN6a7f4g==} cpu: [ppc64] os: [linux] libc: [glibc] + '@rollup/rollup-linux-powerpc64le-gnu@4.27.3': + resolution: {integrity: sha512-v2M/mPvVUKVOKITa0oCFksnQQ/TqGrT+yD0184/cWHIu0LoIuYHwox0Pm3ccXEz8cEQDLk6FPKd1CCm+PlsISw==} + cpu: [ppc64] + os: [linux] + libc: [glibc] + '@rollup/rollup-linux-riscv64-gnu@4.27.2': resolution: {integrity: sha512-DEP3Njr9/ADDln3kNi76PXonLMSSMiCir0VHXxmGSHxCxDfQ70oWjHcJGfiBugzaqmYdTC7Y+8Int6qbnxPBIQ==} cpu: [riscv64] os: [linux] libc: [glibc] + '@rollup/rollup-linux-riscv64-gnu@4.27.3': + resolution: {integrity: sha512-LdrI4Yocb1a/tFVkzmOE5WyYRgEBOyEhWYJe4gsDWDiwnjYKjNs7PS6SGlTDB7maOHF4kxevsuNBl2iOcj3b4A==} + cpu: [riscv64] + os: [linux] + libc: [glibc] + '@rollup/rollup-linux-s390x-gnu@4.27.2': resolution: {integrity: sha512-NHGo5i6IE/PtEPh5m0yw5OmPMpesFnzMIS/lzvN5vknnC1sXM5Z/id5VgcNPgpD+wHmIcuYYgW+Q53v+9s96lQ==} cpu: [s390x] os: [linux] libc: [glibc] + '@rollup/rollup-linux-s390x-gnu@4.27.3': + resolution: {integrity: sha512-d4wVu6SXij/jyiwPvI6C4KxdGzuZOvJ6y9VfrcleHTwo68fl8vZC5ZYHsCVPUi4tndCfMlFniWgwonQ5CUpQcA==} + cpu: [s390x] + os: [linux] + libc: [glibc] + '@rollup/rollup-linux-x64-gnu@4.27.2': resolution: {integrity: sha512-PaW2DY5Tan+IFvNJGHDmUrORadbe/Ceh8tQxi8cmdQVCCYsLoQo2cuaSj+AU+YRX8M4ivS2vJ9UGaxfuNN7gmg==} cpu: [x64] os: [linux] libc: [glibc] + '@rollup/rollup-linux-x64-gnu@4.27.3': + resolution: {integrity: sha512-/6bn6pp1fsCGEY5n3yajmzZQAh+mW4QPItbiWxs69zskBzJuheb3tNynEjL+mKOsUSFK11X4LYF2BwwXnzWleA==} + cpu: [x64] + os: [linux] + libc: [glibc] + '@rollup/rollup-linux-x64-musl@4.27.2': resolution: {integrity: sha512-dOlWEMg2gI91Qx5I/HYqOD6iqlJspxLcS4Zlg3vjk1srE67z5T2Uz91yg/qA8sY0XcwQrFzWWiZhMNERylLrpQ==} cpu: [x64] os: [linux] libc: [musl] + '@rollup/rollup-linux-x64-musl@4.27.3': + resolution: {integrity: sha512-nBXOfJds8OzUT1qUreT/en3eyOXd2EH5b0wr2bVB5999qHdGKkzGzIyKYaKj02lXk6wpN71ltLIaQpu58YFBoQ==} + cpu: [x64] + os: [linux] + libc: [musl] + '@rollup/rollup-win32-arm64-msvc@4.27.2': resolution: {integrity: sha512-euMIv/4x5Y2/ImlbGl88mwKNXDsvzbWUlT7DFky76z2keajCtcbAsN9LUdmk31hAoVmJJYSThgdA0EsPeTr1+w==} cpu: [arm64] os: [win32] + '@rollup/rollup-win32-arm64-msvc@4.27.3': + resolution: {integrity: sha512-ogfbEVQgIZOz5WPWXF2HVb6En+kWzScuxJo/WdQTqEgeyGkaa2ui5sQav9Zkr7bnNCLK48uxmmK0TySm22eiuw==} + cpu: [arm64] + os: [win32] + '@rollup/rollup-win32-ia32-msvc@4.27.2': resolution: {integrity: sha512-RsnE6LQkUHlkC10RKngtHNLxb7scFykEbEwOFDjr3CeCMG+Rr+cKqlkKc2/wJ1u4u990urRHCbjz31x84PBrSQ==} cpu: [ia32] os: [win32] + '@rollup/rollup-win32-ia32-msvc@4.27.3': + resolution: {integrity: sha512-ecE36ZBMLINqiTtSNQ1vzWc5pXLQHlf/oqGp/bSbi7iedcjcNb6QbCBNG73Euyy2C+l/fn8qKWEwxr+0SSfs3w==} + cpu: [ia32] + os: [win32] + '@rollup/rollup-win32-x64-msvc@4.27.2': resolution: {integrity: sha512-foJM5vv+z2KQmn7emYdDLyTbkoO5bkHZE1oth2tWbQNGW7mX32d46Hz6T0MqXdWS2vBZhaEtHqdy9WYwGfiliA==} cpu: [x64] os: [win32] + '@rollup/rollup-win32-x64-msvc@4.27.3': + resolution: {integrity: sha512-vliZLrDmYKyaUoMzEbMTg2JkerfBjn03KmAw9CykO0Zzkzoyd7o3iZNam/TpyWNjNT+Cz2iO3P9Smv2wgrR+Eg==} + cpu: [x64] + os: [win32] + '@socket.io/component-emitter@3.1.2': resolution: {integrity: sha512-9BCxFwvbGg/RsZK9tjXd8s4UcwR0MWeFQ1XEKIQVVvAGJyINdrqKMcTRyLoK8Rse1GjzLV9cwjWV1olXRWEXVA==} @@ -1434,6 +1533,9 @@ packages: '@types/node@22.9.0': resolution: {integrity: sha512-vuyHg81vvWA1Z1ELfvLko2c8f34gyA0zaic0+Rllc5lbCnbSyuvb2Oxpm6TAUAC/2xZN3QGqxBNggD1nNR2AfQ==} + '@types/node@22.9.1': + resolution: {integrity: sha512-p8Yy/8sw1caA8CdRIQBG5tiLHmxtQKObCijiAa9Ez+d4+PRffM4054xbju0msf+cvhJpnFEeNjxmVT/0ipktrg==} + '@types/phoenix@1.6.5': resolution: {integrity: sha512-xegpDuR+z0UqG9fwHqNoy3rI7JDlvaPh2TY47Fl80oq6g+hXT+c/LEuE43X48clZ6lOfANl5WrPur9fYO1RJ/w==} @@ -1747,8 +1849,8 @@ packages: buffer@6.0.3: resolution: {integrity: sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==} - bullmq@5.26.2: - resolution: {integrity: sha512-UdHBrJoRkpXoF8b/FVEkuRBnaUZoA7+qHQNyTx1n2oNVZ4iWxqGqss+M9xAwXOpBmSNvOSlaBdHpf+5QJTU8GQ==} + bullmq@5.29.0: + resolution: {integrity: sha512-mRA0m+XJvvpB+MG1xSefcbb3VdEhqCenH87fGE01o2VsoRC0VwXROIX23RXha9RJaJ5/iEOsgUICuVvW+MHpqw==} cacache@15.3.0: resolution: {integrity: sha512-VVdYzXEn+cnbXpFgWs5hTT7OScegHVmLhJIR8Ufqk3iFD6A6j5iSX1KuBTfNEv4tdJWE2PzA6IVFtcLC7fN9wQ==} @@ -3391,6 +3493,11 @@ packages: engines: {node: '>=18.0.0', npm: '>=8.0.0'} hasBin: true + rollup@4.27.3: + resolution: {integrity: sha512-SLsCOnlmGt9VoZ9Ek8yBK8tAdmPHeppkw+Xa7yDlCEhDTvwYei03JlWo1fdc7YTfLZ4tD8riJCUyAgTbszk1fQ==} + engines: {node: '>=18.0.0', npm: '>=8.0.0'} + hasBin: true + run-parallel@1.2.0: resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==} @@ -4914,11 +5021,11 @@ snapshots: '@jridgewell/resolve-uri': 3.1.2 '@jridgewell/sourcemap-codec': 1.5.0 - '@kevisual/auth@1.0.4(@kevisual/router@0.0.5-alpha-2)': + '@kevisual/auth@1.0.4(@kevisual/router@0.0.5)': dependencies: - '@kevisual/router': 0.0.5-alpha-2 + '@kevisual/router': 0.0.5 - '@kevisual/router@0.0.5-alpha-2': + '@kevisual/router@0.0.5': dependencies: path-to-regexp: 8.2.0 selfsigned: 2.4.1 @@ -4927,7 +5034,7 @@ snapshots: - bufferutil - utf-8-validate - '@kevisual/use-config@1.0.1': {} + '@kevisual/use-config@1.0.2': {} '@langchain/core@0.3.3(openai@4.65.0(encoding@0.1.13)(zod@3.23.8))': dependencies: @@ -5094,9 +5201,9 @@ snapshots: transitivePeerDependencies: - supports-color - '@rollup/plugin-alias@5.1.1(rollup@4.27.2)': + '@rollup/plugin-alias@5.1.1(rollup@4.27.3)': optionalDependencies: - rollup: 4.27.2 + rollup: 4.27.3 '@rollup/plugin-commonjs@28.0.1(rollup@4.27.2)': dependencies: @@ -5110,12 +5217,30 @@ snapshots: optionalDependencies: rollup: 4.27.2 + '@rollup/plugin-commonjs@28.0.1(rollup@4.27.3)': + dependencies: + '@rollup/pluginutils': 5.1.2(rollup@4.27.3) + commondir: 1.0.1 + estree-walker: 2.0.2 + fdir: 6.3.0(picomatch@4.0.2) + is-reference: 1.2.1 + magic-string: 0.30.11 + picomatch: 4.0.2 + optionalDependencies: + rollup: 4.27.3 + '@rollup/plugin-json@6.1.0(rollup@4.27.2)': dependencies: '@rollup/pluginutils': 5.1.2(rollup@4.27.2) optionalDependencies: rollup: 4.27.2 + '@rollup/plugin-json@6.1.0(rollup@4.27.3)': + dependencies: + '@rollup/pluginutils': 5.1.2(rollup@4.27.3) + optionalDependencies: + rollup: 4.27.3 + '@rollup/plugin-node-resolve@15.3.0(rollup@4.27.2)': dependencies: '@rollup/pluginutils': 5.1.2(rollup@4.27.2) @@ -5126,6 +5251,16 @@ snapshots: optionalDependencies: rollup: 4.27.2 + '@rollup/plugin-node-resolve@15.3.0(rollup@4.27.3)': + dependencies: + '@rollup/pluginutils': 5.1.2(rollup@4.27.3) + '@types/resolve': 1.20.2 + deepmerge: 4.3.1 + is-module: 1.0.0 + resolve: 1.22.8 + optionalDependencies: + rollup: 4.27.3 + '@rollup/plugin-typescript@12.1.1(rollup@4.27.2)(tslib@2.7.0)(typescript@5.6.3)': dependencies: '@rollup/pluginutils': 5.1.2(rollup@4.27.2) @@ -5135,6 +5270,15 @@ snapshots: rollup: 4.27.2 tslib: 2.7.0 + '@rollup/plugin-typescript@12.1.1(rollup@4.27.3)(tslib@2.7.0)(typescript@5.6.3)': + dependencies: + '@rollup/pluginutils': 5.1.2(rollup@4.27.3) + resolve: 1.22.8 + typescript: 5.6.3 + optionalDependencies: + rollup: 4.27.3 + tslib: 2.7.0 + '@rollup/pluginutils@5.1.2(rollup@4.27.2)': dependencies: '@types/estree': 1.0.6 @@ -5143,60 +5287,122 @@ snapshots: optionalDependencies: rollup: 4.27.2 + '@rollup/pluginutils@5.1.2(rollup@4.27.3)': + dependencies: + '@types/estree': 1.0.6 + estree-walker: 2.0.2 + picomatch: 4.0.2 + optionalDependencies: + rollup: 4.27.3 + '@rollup/rollup-android-arm-eabi@4.27.2': optional: true + '@rollup/rollup-android-arm-eabi@4.27.3': + optional: true + '@rollup/rollup-android-arm64@4.27.2': optional: true + '@rollup/rollup-android-arm64@4.27.3': + optional: true + '@rollup/rollup-darwin-arm64@4.27.2': optional: true + '@rollup/rollup-darwin-arm64@4.27.3': + optional: true + '@rollup/rollup-darwin-x64@4.27.2': optional: true + '@rollup/rollup-darwin-x64@4.27.3': + optional: true + '@rollup/rollup-freebsd-arm64@4.27.2': optional: true + '@rollup/rollup-freebsd-arm64@4.27.3': + optional: true + '@rollup/rollup-freebsd-x64@4.27.2': optional: true + '@rollup/rollup-freebsd-x64@4.27.3': + optional: true + '@rollup/rollup-linux-arm-gnueabihf@4.27.2': optional: true + '@rollup/rollup-linux-arm-gnueabihf@4.27.3': + optional: true + '@rollup/rollup-linux-arm-musleabihf@4.27.2': optional: true + '@rollup/rollup-linux-arm-musleabihf@4.27.3': + optional: true + '@rollup/rollup-linux-arm64-gnu@4.27.2': optional: true + '@rollup/rollup-linux-arm64-gnu@4.27.3': + optional: true + '@rollup/rollup-linux-arm64-musl@4.27.2': optional: true + '@rollup/rollup-linux-arm64-musl@4.27.3': + optional: true + '@rollup/rollup-linux-powerpc64le-gnu@4.27.2': optional: true + '@rollup/rollup-linux-powerpc64le-gnu@4.27.3': + optional: true + '@rollup/rollup-linux-riscv64-gnu@4.27.2': optional: true + '@rollup/rollup-linux-riscv64-gnu@4.27.3': + optional: true + '@rollup/rollup-linux-s390x-gnu@4.27.2': optional: true + '@rollup/rollup-linux-s390x-gnu@4.27.3': + optional: true + '@rollup/rollup-linux-x64-gnu@4.27.2': optional: true + '@rollup/rollup-linux-x64-gnu@4.27.3': + optional: true + '@rollup/rollup-linux-x64-musl@4.27.2': optional: true + '@rollup/rollup-linux-x64-musl@4.27.3': + optional: true + '@rollup/rollup-win32-arm64-msvc@4.27.2': optional: true + '@rollup/rollup-win32-arm64-msvc@4.27.3': + optional: true + '@rollup/rollup-win32-ia32-msvc@4.27.2': optional: true + '@rollup/rollup-win32-ia32-msvc@4.27.3': + optional: true + '@rollup/rollup-win32-x64-msvc@4.27.2': optional: true + '@rollup/rollup-win32-x64-msvc@4.27.3': + optional: true + '@socket.io/component-emitter@3.1.2': {} '@supabase/auth-js@2.65.1': @@ -5254,7 +5460,7 @@ snapshots: '@types/cors@2.8.17': dependencies: - '@types/node': 22.9.0 + '@types/node': 22.9.1 '@types/crypto-js@4.2.2': {} @@ -5276,26 +5482,26 @@ snapshots: '@types/formidable@3.4.5': dependencies: - '@types/node': 22.9.0 + '@types/node': 22.9.1 '@types/fs-extra@8.1.5': dependencies: - '@types/node': 22.9.0 + '@types/node': 22.9.1 '@types/glob@7.2.0': dependencies: '@types/minimatch': 5.1.2 - '@types/node': 22.9.0 + '@types/node': 22.9.1 '@types/http-proxy@1.17.15': dependencies: - '@types/node': 22.9.0 + '@types/node': 22.9.1 '@types/json-schema@7.0.15': {} '@types/jsonwebtoken@9.0.7': dependencies: - '@types/node': 22.9.0 + '@types/node': 22.9.1 '@types/lodash-es@4.17.12': dependencies: @@ -5309,12 +5515,12 @@ snapshots: '@types/node-fetch@2.6.11': dependencies: - '@types/node': 22.9.0 + '@types/node': 22.9.1 form-data: 4.0.0 '@types/node-forge@1.3.11': dependencies: - '@types/node': 22.9.0 + '@types/node': 22.9.1 '@types/node@18.19.53': dependencies: @@ -5324,6 +5530,10 @@ snapshots: dependencies: undici-types: 6.19.8 + '@types/node@22.9.1': + dependencies: + undici-types: 6.19.8 + '@types/phoenix@1.6.5': {} '@types/prop-types@15.7.13': {} @@ -5335,7 +5545,7 @@ snapshots: '@types/readdir-glob@1.1.5': dependencies: - '@types/node': 22.9.0 + '@types/node': 22.9.1 '@types/resolve@1.20.2': {} @@ -5355,7 +5565,7 @@ snapshots: '@types/ws@8.5.12': dependencies: - '@types/node': 22.9.0 + '@types/node': 22.9.1 '@webassemblyjs/ast@1.12.1': dependencies: @@ -5685,7 +5895,7 @@ snapshots: base64-js: 1.5.1 ieee754: 1.2.1 - bullmq@5.26.2: + bullmq@5.29.0: dependencies: cron-parser: 4.9.0 ioredis: 5.4.1 @@ -6017,7 +6227,7 @@ snapshots: dependencies: '@types/cookie': 0.4.1 '@types/cors': 2.8.17 - '@types/node': 22.9.0 + '@types/node': 22.9.1 accepts: 1.3.8 base64id: 2.0.0 cookie: 0.4.2 @@ -6658,7 +6868,7 @@ snapshots: jest-worker@27.5.1: dependencies: - '@types/node': 22.9.0 + '@types/node': 22.9.1 merge-stream: 2.0.0 supports-color: 8.1.1 @@ -7537,22 +7747,22 @@ snapshots: globby: 10.0.1 is-plain-object: 3.0.1 - rollup-plugin-dts@6.1.1(rollup@4.27.2)(typescript@5.6.3): + rollup-plugin-dts@6.1.1(rollup@4.27.3)(typescript@5.6.3): dependencies: magic-string: 0.30.11 - rollup: 4.27.2 + rollup: 4.27.3 typescript: 5.6.3 optionalDependencies: '@babel/code-frame': 7.26.2 - rollup-plugin-esbuild@6.1.1(esbuild@0.23.1)(rollup@4.27.2): + rollup-plugin-esbuild@6.1.1(esbuild@0.23.1)(rollup@4.27.3): dependencies: - '@rollup/pluginutils': 5.1.2(rollup@4.27.2) + '@rollup/pluginutils': 5.1.2(rollup@4.27.3) debug: 4.3.7(supports-color@5.5.0) es-module-lexer: 1.5.4 esbuild: 0.23.1 get-tsconfig: 4.8.1 - rollup: 4.27.2 + rollup: 4.27.3 transitivePeerDependencies: - supports-color @@ -7580,6 +7790,30 @@ snapshots: '@rollup/rollup-win32-x64-msvc': 4.27.2 fsevents: 2.3.3 + rollup@4.27.3: + dependencies: + '@types/estree': 1.0.6 + optionalDependencies: + '@rollup/rollup-android-arm-eabi': 4.27.3 + '@rollup/rollup-android-arm64': 4.27.3 + '@rollup/rollup-darwin-arm64': 4.27.3 + '@rollup/rollup-darwin-x64': 4.27.3 + '@rollup/rollup-freebsd-arm64': 4.27.3 + '@rollup/rollup-freebsd-x64': 4.27.3 + '@rollup/rollup-linux-arm-gnueabihf': 4.27.3 + '@rollup/rollup-linux-arm-musleabihf': 4.27.3 + '@rollup/rollup-linux-arm64-gnu': 4.27.3 + '@rollup/rollup-linux-arm64-musl': 4.27.3 + '@rollup/rollup-linux-powerpc64le-gnu': 4.27.3 + '@rollup/rollup-linux-riscv64-gnu': 4.27.3 + '@rollup/rollup-linux-s390x-gnu': 4.27.3 + '@rollup/rollup-linux-x64-gnu': 4.27.3 + '@rollup/rollup-linux-x64-musl': 4.27.3 + '@rollup/rollup-win32-arm64-msvc': 4.27.3 + '@rollup/rollup-win32-ia32-msvc': 4.27.3 + '@rollup/rollup-win32-x64-msvc': 4.27.3 + fsevents: 2.3.3 + run-parallel@1.2.0: dependencies: queue-microtask: 1.2.3 @@ -8254,7 +8488,7 @@ snapshots: wkx@0.5.0: dependencies: - '@types/node': 22.9.0 + '@types/node': 22.9.1 wrap-ansi@7.0.0: dependencies: diff --git a/src/routes/micro-app/lib/app-file.ts b/src/routes/micro-app/lib/app-file.ts index fe9340b..f7965b4 100644 --- a/src/routes/micro-app/lib/app-file.ts +++ b/src/routes/micro-app/lib/app-file.ts @@ -1,22 +1,45 @@ import { useFileStore } from '@abearxiong/use-file-store'; -import glob from 'fast-glob'; -import fs from 'fs'; +import { getConfigFile } from '@kevisual/use-config'; import path from 'path'; +import fs from 'fs'; export const appsPath = useFileStore('apps', { needExists: true }); -export const loadAppInfo = async () => { - const apps = await glob(`${appsPath}/*/\.config.json`, { - cwd: appsPath, - }); - const result = apps.map((app) => { - const json = fs.readFileSync(path.join(appsPath, app), 'utf-8'); - const pkg = JSON.parse(json); - const { name, version, app: appInfo } = pkg; - if (!name || !version || !appInfo) { - throw new Error('Invalid package.json'); - } - return { key: app.split('/')[0], ...appInfo }; - }); - return result; +export type AppInfoConfig = { + list: any[]; + [key: string]: any; +}; +/** + * 加载应用信息 + * @returns + */ +export const loadAppInfo = async (): Promise => { + const pkgs = getConfigFile(); + let configFile = getConfigFile('apps.config.json'); + if (!pkgs) { + console.error('未找到配置文件'); + return; + } + const basePath = path.dirname(pkgs); + if (!configFile) { + configFile = path.join(basePath, 'apps.config.json'); + fs.writeFileSync(configFile, JSON.stringify({})); + return { list: [] }; + } + const config = fs.readFileSync(configFile, 'utf-8'); + return JSON.parse(config); +}; + +/** + * + * 保存应用信息 + * @param data + * @returns + */ +export const saveAppInfo = async (data: any) => { + const configFile = getConfigFile('apps.config.json'); + if (!configFile) { + return; + } + fs.writeFileSync(configFile, JSON.stringify(data)); }; diff --git a/src/routes/micro-app/lib/file.ts b/src/routes/micro-app/lib/file.ts deleted file mode 100644 index 108a36b..0000000 --- a/src/routes/micro-app/lib/file.ts +++ /dev/null @@ -1,10 +0,0 @@ -import fs from 'fs'; -export const fileIsExist = (filePath: string): boolean => { - try { - // 使用 F_OK 检查文件或目录是否存在 - fs.accessSync(filePath, fs.constants.F_OK); - return true; - } catch (err) { - return false; - } -}; diff --git a/src/routes/micro-app/lib/index.ts b/src/routes/micro-app/lib/index.ts index 07721d6..e69de29 100644 --- a/src/routes/micro-app/lib/index.ts +++ b/src/routes/micro-app/lib/index.ts @@ -1 +0,0 @@ -export * from './app-file.ts'; diff --git a/src/routes/micro-app/module/install-app.ts b/src/routes/micro-app/module/install-app.ts index e6963e4..9ee6648 100644 --- a/src/routes/micro-app/module/install-app.ts +++ b/src/routes/micro-app/module/install-app.ts @@ -1,6 +1,7 @@ import { minioClient } from '@/app.ts'; import { bucketName } from '@/modules/minio.ts'; -import { fileIsExist } from '../lib/file.ts'; +import { fileIsExist } from '@kevisual/use-config'; + import fs from 'fs'; import path from 'path'; import * as tar from 'tar'; diff --git a/src/routes/micro-app/module/load-app.ts b/src/routes/micro-app/module/load-app.ts index e0412d8..c3b74ba 100644 --- a/src/routes/micro-app/module/load-app.ts +++ b/src/routes/micro-app/module/load-app.ts @@ -1,4 +1,5 @@ -import { fileIsExist } from '../lib/file.ts'; +import { fileIsExist } from '@kevisual/use-config'; + import { useFileStore } from '@abearxiong/use-file-store'; import fs from 'fs'; import path from 'path'; diff --git a/src/routes/micro-app/module/manager.ts b/src/routes/micro-app/module/manager.ts index e356c2c..8eeb5fe 100644 --- a/src/routes/micro-app/module/manager.ts +++ b/src/routes/micro-app/module/manager.ts @@ -1,20 +1,32 @@ +import { App } from '@kevisual/router'; +import { loadAppInfo, AppInfoConfig, saveAppInfo } from '../lib/app-file.ts'; +import { fork } from 'child_process'; + export enum AppType { SystemApp = 'system-app', MicroApp = 'micro-app', GatewayApp = 'gateway-app', } export type AppInfo = { - status?: 'active' | 'inactive'; // 默认运行状态 + status?: 'inactive' | 'runing' | 'stop' | 'error'; // 运行状态 key: string; type?: AppType; // 默认类型 entry?: string; // 入口文件 path?: string; // 文件路径 + timestamp?: number; // 时间戳, 每次更新更新时间戳 + process?: any; // 进程 +}; +type managerOptions = { + mainApp: App; }; - export class Manager { apps: Map; - constructor() { + mainApp: App; + appInfo: AppInfoConfig; + constructor(opts: managerOptions) { this.apps = new Map(); + this.mainApp = opts.mainApp; + this.appInfo = {} as any; } /** * 检查key是否存在 @@ -28,10 +40,90 @@ export class Manager { * 获取app信息 * @param key */ - add(app: T) { + async loadApp(app: T) { + const mainApp = this.mainApp; this.apps.set(app.key, app); + if (app.status === 'inactive') { + return; + } + const entry = app.entry + `?timestamp=${app?.timestamp}`; + // 注册路由 + if (app.type === AppType.MicroApp) { + const process = fork(entry, [], {}); + app.process = process; + } else if (app.type === AppType.SystemApp) { + const module = await import(entry); + if (module.loadApp) { + await module.loadApp?.(mainApp); + } + } else if (app.type === AppType.GatewayApp) { + console.log('gateway app not support'); + } } - load() { + /** + * create new app info + * @param app + */ + async saveAppInfo(app: T, newTimeData = false) { + const list = this.appInfo.list || []; + if (newTimeData) { + app.timestamp = Date.now(); + } + const { process, ...info } = app; + list.push(info); + this.appInfo.list = list; + await saveAppInfo(this.appInfo); + } + + /** + * 初始化应用的时候加载 + */ + async load() { // 从apps文件夹列表当中中加载app信息 + const appInfos = await loadAppInfo(); + const list = appInfos?.list || []; + for (const app of list) { + try { + this.loadApp(app); + } catch (e) { + console.error('load app', e); + } + } + } + async add(app: T) { + if (this.checkKey(app.key)) { + return false; + } + + this.loadApp(app); + await this.saveAppInfo(app, true); + } + // 启动 + async start(key: string) { + const app = this.apps.get(key); + if (!app) { + return; + } + if (app.status === 'runing') { + return; + } + app.status = 'runing'; + this.loadApp(app); + await this.saveAppInfo(app); + } + // 停止 + async stop(key: string) { + const app = this.apps.get(key); + if (!app) { + return; + } + if (app.status === 'stop') { + return; + } + app.status = 'stop'; + if (app.process) { + app.process.kill(); + } + await this.saveAppInfo(app); } }