From df4a1822c1a9f49321f38a192efa98965cf76f99 Mon Sep 17 00:00:00 2001 From: longjuan <769022681@qq.com> Date: Thu, 9 Nov 2023 13:39:51 +0000 Subject: [PATCH] feat: unlink s3 attchment --- build.gradle | 2 +- console/package.json | 7 +- console/pnpm-lock.yaml | 315 ++++++++++++++---- console/src/controller/index.ts | 1 + ...pisS3OsHaloRunV1Alpha1AttachmentsByName.ts | 13 + .../controller/s-3-unlink-controller/index.ts | 1 + console/src/index.ts | 26 +- console/src/interface/apiTypes/Attachment.ts | 9 + .../src/interface/apiTypes/AttachmentSpec.ts | 16 + .../interface/apiTypes/AttachmentStatus.ts | 9 + console/src/interface/index.ts | 3 + console/src/swagger.config.json | 2 +- console/src/views/S3Unlink.vue | 42 +++ .../run/halo/s3os/S3UnlinkController.java | 22 ++ .../java/run/halo/s3os/S3UnlinkService.java | 8 + .../run/halo/s3os/S3UnlinkServiceImpl.java | 41 +++ .../extensions/s3os-role-template.yaml | 18 + src/main/resources/plugin.yaml | 2 +- 18 files changed, 458 insertions(+), 79 deletions(-) create mode 100644 console/src/controller/s-3-unlink-controller/deleteApisS3OsHaloRunV1Alpha1AttachmentsByName.ts create mode 100644 console/src/controller/s-3-unlink-controller/index.ts create mode 100644 console/src/interface/apiTypes/Attachment.ts create mode 100644 console/src/interface/apiTypes/AttachmentSpec.ts create mode 100644 console/src/interface/apiTypes/AttachmentStatus.ts create mode 100644 console/src/views/S3Unlink.vue create mode 100644 src/main/java/run/halo/s3os/S3UnlinkController.java create mode 100644 src/main/java/run/halo/s3os/S3UnlinkService.java create mode 100644 src/main/java/run/halo/s3os/S3UnlinkServiceImpl.java diff --git a/build.gradle b/build.gradle index 74b1c6a..7b5c5d8 100644 --- a/build.gradle +++ b/build.gradle @@ -33,7 +33,7 @@ configurations.runtimeClasspath { halo { - version = '2.10.0' + version = '2.10.1' } haloPlugin { diff --git a/console/package.json b/console/package.json index f4d4748..78b9740 100644 --- a/console/package.json +++ b/console/package.json @@ -11,12 +11,13 @@ "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore" }, "dependencies": { - "@halo-dev/components": "^1.5.0", - "@halo-dev/console-shared": "^2.8.0", + "@halo-dev/components": "^1.9.0", + "@halo-dev/console-shared": "^2.10.0", + "@tanstack/vue-query": "4.29.1", "axios": "^1.4.0", "canvas-confetti": "^1.6.0", "path-browserify": "^1.0.1", - "vue": "^3.2.41" + "vue": "^3.3.4" }, "devDependencies": { "@iconify/json": "^2.2.18", diff --git a/console/pnpm-lock.yaml b/console/pnpm-lock.yaml index 7ff48a2..fee6cf1 100644 --- a/console/pnpm-lock.yaml +++ b/console/pnpm-lock.yaml @@ -1,12 +1,19 @@ lockfileVersion: '6.0' +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + dependencies: '@halo-dev/components': - specifier: ^1.5.0 - version: 1.5.0(vue@3.2.41) + specifier: ^1.9.0 + version: 1.9.0(vue-router@4.2.5)(vue@3.3.7) '@halo-dev/console-shared': - specifier: ^2.8.0 - version: 2.8.0(vue@3.2.41) + specifier: ^2.10.0 + version: 2.10.0(vue-router@4.2.5)(vue@3.3.7) + '@tanstack/vue-query': + specifier: 4.29.1 + version: 4.29.1(vue@3.3.7) axios: specifier: ^1.4.0 version: 1.4.0 @@ -17,8 +24,8 @@ dependencies: specifier: ^1.0.1 version: 1.0.1 vue: - specifier: ^3.2.41 - version: 3.2.41 + specifier: ^3.3.4 + version: 3.3.7(typescript@4.7.4) devDependencies: '@iconify/json': @@ -38,10 +45,10 @@ devDependencies: version: 16.18.0 '@vitejs/plugin-vue': specifier: ^3.1.2 - version: 3.1.2(vite@3.1.8)(vue@3.2.41) + version: 3.1.2(vite@3.1.8)(vue@3.3.7) '@vitejs/plugin-vue-jsx': specifier: ^2.0.1 - version: 2.0.1(vite@3.1.8)(vue@3.2.41) + version: 2.0.1(vite@3.1.8)(vue@3.3.7) '@vue/eslint-config-prettier': specifier: ^7.0.0 version: 7.0.0(eslint@8.26.0)(prettier@2.7.1) @@ -50,7 +57,7 @@ devDependencies: version: 11.0.2(eslint-plugin-vue@9.6.0)(eslint@8.26.0)(typescript@4.7.4) '@vue/test-utils': specifier: ^2.2.0 - version: 2.2.0(vue@3.2.41) + version: 2.2.0(vue@3.3.7) '@vue/tsconfig': specifier: ^0.1.3 version: 0.1.3(@types/node@16.18.0) @@ -322,16 +329,15 @@ packages: /@babel/helper-string-parser@7.19.4: resolution: {integrity: sha512-nHtDoQcuqFmwYNYPz3Rah5ph2p8PFeFCsZk9A/48dPc/rGocJ5J3hAAZ7pb76VWX3fZKu+uEr/FhH5jLx7umrw==} engines: {node: '>=6.9.0'} - dev: true /@babel/helper-validator-identifier@7.16.7: resolution: {integrity: sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==} engines: {node: '>=6.9.0'} + dev: true /@babel/helper-validator-identifier@7.19.1: resolution: {integrity: sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==} engines: {node: '>=6.9.0'} - dev: true /@babel/helper-validator-option@7.18.6: resolution: {integrity: sha512-XO7gESt5ouv/LRJdrVjkShckw6STTaB7l9BrpBaAHDeF5YZT+01PCwmR0SJHnkW6i8OwW/EVWRShfi4j2x+KQw==} @@ -364,6 +370,7 @@ packages: hasBin: true dependencies: '@babel/types': 7.18.4 + dev: true /@babel/parser@7.19.6: resolution: {integrity: sha512-h1IUp81s2JYJ3mRkdxJgs4UvmSsRvDrx5ICSJbPvtWYv5i1nTBGcBpnog+89rAFMwvvru6E5NUHdBe01UeSzYA==} @@ -373,6 +380,13 @@ packages: '@babel/types': 7.19.4 dev: true + /@babel/parser@7.23.0: + resolution: {integrity: sha512-vvPKKdMemU85V9WE/l5wZEmImpCtLqbnTvqDS2U1fJ96KrxoW7KrXhNsNCblQlg8Ck4b85yxdTyelsMUgFUXiw==} + engines: {node: '>=6.0.0'} + hasBin: true + dependencies: + '@babel/types': 7.19.4 + /@babel/plugin-syntax-import-meta@7.10.4(@babel/core@7.19.6): resolution: {integrity: sha512-Yqfm+XDx0+Prh3VSeEQCPU81yC+JWZ2pDPFSS4ZdpfZhp4MkFMaDC1UqseovEKwSUpnIL7+vK+Clp7bfh0iD7g==} peerDependencies: @@ -476,6 +490,7 @@ packages: dependencies: '@babel/helper-validator-identifier': 7.16.7 to-fast-properties: 2.0.0 + dev: true /@babel/types@7.19.4: resolution: {integrity: sha512-M5LK7nAeS6+9j7hAq+b3fQs+pNfUtTGq+yFFfHnauFA8zQtLRfmuipmsKDKKLuyG+wC8ABW43A153YNawNTEtw==} @@ -484,7 +499,6 @@ packages: '@babel/helper-string-parser': 7.19.4 '@babel/helper-validator-identifier': 7.19.1 to-fast-properties: 2.0.0 - dev: true /@esbuild/android-arm@0.15.12: resolution: {integrity: sha512-IC7TqIqiyE0MmvAhWkl/8AEzpOtbhRNDo7aph47We1NbE5w2bt/Q+giAhe0YYeVpYnIhGMcuZY92qDK6dQauvA==} @@ -521,38 +535,48 @@ packages: - supports-color dev: true - /@floating-ui/core@0.3.1: - resolution: {integrity: sha512-ensKY7Ub59u16qsVIFEo2hwTCqZ/r9oZZFh51ivcLGHfUwTn8l1Xzng8RJUe91H/UP8PeqeBronAGx0qmzwk2g==} + /@floating-ui/core@1.5.0: + resolution: {integrity: sha512-kK1h4m36DQ0UHGj5Ah4db7R0rHemTqqO0QLvUqi1/mUUp3LuAWbWxdxSIf/XsnH9VS6rRVPLJCncjRzUvyCLXg==} + dependencies: + '@floating-ui/utils': 0.1.6 dev: false - /@floating-ui/dom@0.1.10: - resolution: {integrity: sha512-4kAVoogvQm2N0XE0G6APQJuCNuErjOfPW8Ux7DFxh8+AfugWflwVJ5LDlHOwrwut7z/30NUvdtHzQ3zSip4EzQ==} + /@floating-ui/dom@1.1.1: + resolution: {integrity: sha512-TpIO93+DIujg3g7SykEAGZMDtbJRrmnYRCNYSjJlvIbGhBjRSNTLVbNeDQBrzy9qDgUbiWdc7KA0uZHZ2tJmiw==} dependencies: - '@floating-ui/core': 0.3.1 + '@floating-ui/core': 1.5.0 dev: false - /@halo-dev/api-client@2.8.0: - resolution: {integrity: sha512-mVfYYO437TOshRppCnfYBbc4pvbpNWPmlsv8UAWr3F3Zs3LafcHcF4hb7rq03qfEahsnoLtX8jXVWjmFtf4xqw==} + /@floating-ui/utils@0.1.6: + resolution: {integrity: sha512-OfX7E2oUDYxtBvsuS4e/jSn4Q9Qb6DzgeYtsAdkPZ47znpoNsMgZw0+tVijiv3uGNR6dgNlty6r9rzIzHjtd/A==} dev: false - /@halo-dev/components@1.5.0(vue@3.2.41): - resolution: {integrity: sha512-zVRY2AzeE83fR5omZO8q6R/kAAxZ7iSgVNcLxTjOXSPl0SP3HD4LWXoloO1rWoa/O/JUlFY2WqBAEWnu8miCGA==} + /@halo-dev/api-client@2.10.0: + resolution: {integrity: sha512-c1fgp+xzE1gQ7O36miWU2Oz+Uh1G4Hqs3clxLSxBD7vuvktgndZGZblNDi5morHB9UkiauAIQP0+PH9L9jwBfA==} + dev: false + + /@halo-dev/components@1.9.0(vue-router@4.2.5)(vue@3.3.7): + resolution: {integrity: sha512-Rc6zK7Uno+kLqvmZkv/NIv1EUVcFzS5FR7s0ai3LHbwybFF2BNul9HEEslS3Z5a9C0M0arnvkjpUlyBmrWbfRQ==} peerDependencies: - vue: ^3.2.37 - vue-router: ^4.0.16 + vue: ^3.3.4 + vue-router: ^4.2.4 dependencies: - floating-vue: 2.0.0-beta.20(vue@3.2.41) - vue: 3.2.41 + floating-vue: 2.0.0-beta.24(vue@3.3.7) + vue: 3.3.7(typescript@4.7.4) + vue-router: 4.2.5(vue@3.3.7) + transitivePeerDependencies: + - '@nuxt/kit' dev: false - /@halo-dev/console-shared@2.8.0(vue@3.2.41): - resolution: {integrity: sha512-Zhi5FbVrdzSSaaT6i2xh8JOhmi9keetjg8zrYd+tEp4Iy+mPke4ZA4SIYaO1Bkwr9MD5BZ+sNswgYCPd36wYaw==} + /@halo-dev/console-shared@2.10.0(vue-router@4.2.5)(vue@3.3.7): + resolution: {integrity: sha512-c1Ol/xIU2DZk1MWhxtuk1csD90DPvCLByQyGenLgLPX1kVe6QCodWgPG4Uz0WOE1s+rZ2W6XDV0DBXrIHCYBxg==} peerDependencies: - vue: ^3.2.37 - vue-router: ^4.0.16 + vue: ^3.3.4 + vue-router: ^4.2.4 dependencies: - '@halo-dev/api-client': 2.8.0 - vue: 3.2.41 + '@halo-dev/api-client': 2.10.0 + vue: 3.3.7(typescript@4.7.4) + vue-router: 4.2.5(vue@3.3.7) dev: false /@humanwhocodes/config-array@0.11.6: @@ -630,6 +654,9 @@ packages: resolution: {integrity: sha512-GryiOJmNcWbovBxTfZSF71V/mXbgcV3MewDe3kIMCLyIh5e7SKAeUZs+rMnJ8jkMolZ/4/VsdBmMrw3l+VdZ3w==} dev: true + /@jridgewell/sourcemap-codec@1.4.15: + resolution: {integrity: sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==} + /@jridgewell/trace-mapping@0.3.13: resolution: {integrity: sha512-o1xbKhp9qnIAoHJSWd6KlCZfqslL4valSF81H8ImioOAxluWYWOpWkpyktY2vnt4tbrX9XYaxovq6cgowaJp2w==} dependencies: @@ -662,6 +689,33 @@ packages: resolution: {integrity: sha512-sXo/qW2/pAcmT43VoRKOJbDOfV3cYpq3szSVfIThQXNt+E4DfKj361vaAt3c88U5tPUxzEswam7GW48PJqtKAg==} dev: true + /@tanstack/match-sorter-utils@8.8.4: + resolution: {integrity: sha512-rKH8LjZiszWEvmi01NR72QWZ8m4xmXre0OOwlRGnjU01Eqz/QnN+cqpty2PJ0efHblq09+KilvyR7lsbzmXVEw==} + engines: {node: '>=12'} + dependencies: + remove-accents: 0.4.2 + dev: false + + /@tanstack/query-core@4.29.1: + resolution: {integrity: sha512-vkPewLEG8ua0efo3SsVT0BcBtkq5RZX8oPhDAyKL+k/rdOYSQTEocfGEXSaBwIwsXeOGBUpfKqI+UmHvNqdWXg==} + dev: false + + /@tanstack/vue-query@4.29.1(vue@3.3.7): + resolution: {integrity: sha512-2/F12lOHQw3YQbHVKGZUTEuwxrws6UR3VEXNX/Obw2NLupmCYR7+dcBwwHQ75zUQngxLFQwHCJKX7Ne1Wyk/HA==} + peerDependencies: + '@vue/composition-api': ^1.1.2 + vue: ^2.5.0 || ^3.0.0 + peerDependenciesMeta: + '@vue/composition-api': + optional: true + dependencies: + '@tanstack/match-sorter-utils': 8.8.4 + '@tanstack/query-core': 4.29.1 + '@vue/devtools-api': 6.5.1 + vue: 3.3.7(typescript@4.7.4) + vue-demi: 0.13.11(vue@3.3.7) + dev: false + /@tootallnate/once@2.0.0: resolution: {integrity: sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A==} engines: {node: '>= 10'} @@ -827,7 +881,7 @@ packages: eslint-visitor-keys: 3.3.0 dev: true - /@vitejs/plugin-vue-jsx@2.0.1(vite@3.1.8)(vue@3.2.41): + /@vitejs/plugin-vue-jsx@2.0.1(vite@3.1.8)(vue@3.3.7): resolution: {integrity: sha512-lmiR1k9+lrF7LMczO0pxtQ8mOn6XeppJDHxnpxkJQpT5SiKz4SKhKdeNstXaTNuR8qZhUo5X0pJlcocn72Y4Jg==} engines: {node: ^14.18.0 || >=16.0.0} peerDependencies: @@ -839,12 +893,12 @@ packages: '@babel/plugin-transform-typescript': 7.19.3(@babel/core@7.19.6) '@vue/babel-plugin-jsx': 1.1.1(@babel/core@7.19.6) vite: 3.1.8(sass@1.58.0) - vue: 3.2.41 + vue: 3.3.7(typescript@4.7.4) transitivePeerDependencies: - supports-color dev: true - /@vitejs/plugin-vue@3.1.2(vite@3.1.8)(vue@3.2.41): + /@vitejs/plugin-vue@3.1.2(vite@3.1.8)(vue@3.3.7): resolution: {integrity: sha512-3zxKNlvA3oNaKDYX0NBclgxTQ1xaFdL7PzwF6zj9tGFziKwmBa3Q/6XcJQxudlT81WxDjEhHmevvIC4Orc1LhQ==} engines: {node: ^14.18.0 || >=16.0.0} peerDependencies: @@ -852,7 +906,7 @@ packages: vue: ^3.2.25 dependencies: vite: 3.1.8(sass@1.58.0) - vue: 3.2.41 + vue: 3.3.7(typescript@4.7.4) dev: true /@volar/language-core@1.0.9: @@ -923,12 +977,28 @@ packages: '@vue/shared': 3.2.41 estree-walker: 2.0.2 source-map: 0.6.1 + dev: true + + /@vue/compiler-core@3.3.7: + resolution: {integrity: sha512-pACdY6YnTNVLXsB86YD8OF9ihwpolzhhtdLVHhBL6do/ykr6kKXNYABRtNMGrsQXpEXXyAdwvWWkuTbs4MFtPQ==} + dependencies: + '@babel/parser': 7.23.0 + '@vue/shared': 3.3.7 + estree-walker: 2.0.2 + source-map-js: 1.0.2 /@vue/compiler-dom@3.2.41: resolution: {integrity: sha512-xe5TbbIsonjENxJsYRbDJvthzqxLNk+tb3d/c47zgREDa/PCp6/Y4gC/skM4H6PIuX5DAxm7fFJdbjjUH2QTMw==} dependencies: '@vue/compiler-core': 3.2.41 '@vue/shared': 3.2.41 + dev: true + + /@vue/compiler-dom@3.3.7: + resolution: {integrity: sha512-0LwkyJjnUPssXv/d1vNJ0PKfBlDoQs7n81CbO6Q0zdL7H1EzqYRrTVXDqdBVqro0aJjo/FOa1qBAPVI4PGSHBw==} + dependencies: + '@vue/compiler-core': 3.3.7 + '@vue/shared': 3.3.7 /@vue/compiler-sfc@3.2.41: resolution: {integrity: sha512-+1P2m5kxOeaxVmJNXnBskAn3BenbTmbxBxWOtBq3mQTCokIreuMULFantBUclP0+KnzNCMOvcnKinqQZmiOF8w==} @@ -943,12 +1013,38 @@ packages: magic-string: 0.25.9 postcss: 8.4.14 source-map: 0.6.1 + dev: true + + /@vue/compiler-sfc@3.3.7: + resolution: {integrity: sha512-7pfldWy/J75U/ZyYIXRVqvLRw3vmfxDo2YLMwVtWVNew8Sm8d6wodM+OYFq4ll/UxfqVr0XKiVwti32PCrruAw==} + dependencies: + '@babel/parser': 7.23.0 + '@vue/compiler-core': 3.3.7 + '@vue/compiler-dom': 3.3.7 + '@vue/compiler-ssr': 3.3.7 + '@vue/reactivity-transform': 3.3.7 + '@vue/shared': 3.3.7 + estree-walker: 2.0.2 + magic-string: 0.30.5 + postcss: 8.4.31 + source-map-js: 1.0.2 /@vue/compiler-ssr@3.2.41: resolution: {integrity: sha512-Y5wPiNIiaMz/sps8+DmhaKfDm1xgj6GrH99z4gq2LQenfVQcYXmHIOBcs5qPwl7jaW3SUQWjkAPKMfQemEQZwQ==} dependencies: '@vue/compiler-dom': 3.2.41 '@vue/shared': 3.2.41 + dev: true + + /@vue/compiler-ssr@3.3.7: + resolution: {integrity: sha512-TxOfNVVeH3zgBc82kcUv+emNHo+vKnlRrkv8YvQU5+Y5LJGJwSNzcmLUoxD/dNzv0bhQ/F0s+InlgV0NrApJZg==} + dependencies: + '@vue/compiler-dom': 3.3.7 + '@vue/shared': 3.3.7 + + /@vue/devtools-api@6.5.1: + resolution: {integrity: sha512-+KpckaAQyfbvshdDW5xQylLni1asvNSGme1JFs8I1+/H5pHEhqUKMEQD/qn3Nx5+/nycBq11qAEi8lk+LXI2dA==} + dev: false /@vue/eslint-config-prettier@7.0.0(eslint@8.26.0)(prettier@2.7.1): resolution: {integrity: sha512-/CTc6ML3Wta1tCe1gUeO0EYnVXfo3nJXsIhZ8WJr3sov+cGASr6yuiibJTL6lmIBm7GobopToOuB3B6AWyV0Iw==} @@ -991,43 +1087,63 @@ packages: '@vue/shared': 3.2.41 estree-walker: 2.0.2 magic-string: 0.25.9 + dev: true + + /@vue/reactivity-transform@3.3.7: + resolution: {integrity: sha512-APhRmLVbgE1VPGtoLQoWBJEaQk4V8JUsqrQihImVqKT+8U6Qi3t5ATcg4Y9wGAPb3kIhetpufyZ1RhwbZCIdDA==} + dependencies: + '@babel/parser': 7.23.0 + '@vue/compiler-core': 3.3.7 + '@vue/shared': 3.3.7 + estree-walker: 2.0.2 + magic-string: 0.30.5 /@vue/reactivity@3.2.41: resolution: {integrity: sha512-9JvCnlj8uc5xRiQGZ28MKGjuCoPhhTwcoAdv3o31+cfGgonwdPNuvqAXLhlzu4zwqavFEG5tvaoINQEfxz+l6g==} dependencies: '@vue/shared': 3.2.41 + dev: true - /@vue/runtime-core@3.2.41: - resolution: {integrity: sha512-0LBBRwqnI0p4FgIkO9q2aJBBTKDSjzhnxrxHYengkAF6dMOjeAIZFDADAlcf2h3GDALWnblbeprYYpItiulSVQ==} + /@vue/reactivity@3.3.7: + resolution: {integrity: sha512-cZNVjWiw00708WqT0zRpyAgduG79dScKEPYJXq2xj/aMtk3SKvL3FBt2QKUlh6EHBJ1m8RhBY+ikBUzwc7/khg==} dependencies: - '@vue/reactivity': 3.2.41 - '@vue/shared': 3.2.41 + '@vue/shared': 3.3.7 - /@vue/runtime-dom@3.2.41: - resolution: {integrity: sha512-U7zYuR1NVIP8BL6jmOqmapRAHovEFp7CSw4pR2FacqewXNGqZaRfHoNLQsqQvVQ8yuZNZtxSZy0FFyC70YXPpA==} + /@vue/runtime-core@3.3.7: + resolution: {integrity: sha512-LHq9du3ubLZFdK/BP0Ysy3zhHqRfBn80Uc+T5Hz3maFJBGhci1MafccnL3rpd5/3wVfRHAe6c+PnlO2PAavPTQ==} dependencies: - '@vue/runtime-core': 3.2.41 - '@vue/shared': 3.2.41 - csstype: 2.6.20 + '@vue/reactivity': 3.3.7 + '@vue/shared': 3.3.7 + + /@vue/runtime-dom@3.3.7: + resolution: {integrity: sha512-PFQU1oeJxikdDmrfoNQay5nD4tcPNYixUBruZzVX/l0eyZvFKElZUjW4KctCcs52nnpMGO6UDK+jF5oV4GT5Lw==} + dependencies: + '@vue/runtime-core': 3.3.7 + '@vue/shared': 3.3.7 + csstype: 3.1.2 - /@vue/server-renderer@3.2.41(vue@3.2.41): - resolution: {integrity: sha512-7YHLkfJdTlsZTV0ae5sPwl9Gn/EGr2hrlbcS/8naXm2CDpnKUwC68i1wGlrYAfIgYWL7vUZwk2GkYLQH5CvFig==} + /@vue/server-renderer@3.3.7(vue@3.3.7): + resolution: {integrity: sha512-UlpKDInd1hIZiNuVVVvLgxpfnSouxKQOSE2bOfQpBuGwxRV/JqqTCyyjXUWiwtVMyeRaZhOYYqntxElk8FhBhw==} peerDependencies: - vue: 3.2.41 + vue: 3.3.7 dependencies: - '@vue/compiler-ssr': 3.2.41 - '@vue/shared': 3.2.41 - vue: 3.2.41 + '@vue/compiler-ssr': 3.3.7 + '@vue/shared': 3.3.7 + vue: 3.3.7(typescript@4.7.4) /@vue/shared@3.2.41: resolution: {integrity: sha512-W9mfWLHmJhkfAmV+7gDjcHeAWALQtgGT3JErxULl0oz6R6+3ug91I7IErs93eCFhPCZPHBs4QJS7YWEV7A3sxw==} + dev: true - /@vue/test-utils@2.2.0(vue@3.2.41): + /@vue/shared@3.3.7: + resolution: {integrity: sha512-N/tbkINRUDExgcPTBvxNkvHGu504k8lzlNQRITVnm6YjOjwa4r0nnbd4Jb01sNpur5hAllyRJzSK5PvB9PPwRg==} + + /@vue/test-utils@2.2.0(vue@3.3.7): resolution: {integrity: sha512-EKp5/N7ieNZdoLTkD16j/irUjIEDN63QUIc41vLUMqGvSsTQN0QxbFiQqh5v49RPfS5vZH+DhjNUEkijCMOCSg==} peerDependencies: vue: ^3.0.1 dependencies: - vue: 3.2.41 + vue: 3.3.7(typescript@4.7.4) dev: true /@vue/tsconfig@0.1.3(@types/node@16.18.0): @@ -1354,8 +1470,8 @@ packages: cssom: 0.3.8 dev: true - /csstype@2.6.20: - resolution: {integrity: sha512-/WwNkdXfckNgw6S5R125rrW8ez139lBHWouiBvX8dfMFtcn6V81REDqnH7+CRpRipfYlyU1CmOnOxrmGcFOjeA==} + /csstype@3.1.2: + resolution: {integrity: sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ==} /data-urls@3.0.2: resolution: {integrity: sha512-Jy/tj3ldjZJo63sVAvg6LHt2mHvl4V6AgRAmNDtLdm7faqtsx+aJG42rsyCo9JCoRVKwPFzKlIPx3DIibwSIaQ==} @@ -1978,14 +2094,18 @@ packages: resolution: {integrity: sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg==} dev: true - /floating-vue@2.0.0-beta.20(vue@3.2.41): - resolution: {integrity: sha512-N68otcpp6WwcYC7zP8GeJqNZVdfvS7tEY88lwmuAHeqRgnfWx1Un8enzLxROyVnBDZ3TwUoUdj5IFg+bUT7JeA==} + /floating-vue@2.0.0-beta.24(vue@3.3.7): + resolution: {integrity: sha512-URSzP6YXaF4u1oZ9XGL8Sn8puuM7ivp5jkOUrpy5Q1mfo9BfGppJOn+ierTmsSUfJEeHBae8KT7r5DeI3vQIEw==} peerDependencies: + '@nuxt/kit': ^3.2.0 vue: ^3.2.0 + peerDependenciesMeta: + '@nuxt/kit': + optional: true dependencies: - '@floating-ui/dom': 0.1.10 - vue: 3.2.41 - vue-resize: 2.0.0-alpha.1(vue@3.2.41) + '@floating-ui/dom': 1.1.1 + vue: 3.3.7(typescript@4.7.4) + vue-resize: 2.0.0-alpha.1(vue@3.3.7) dev: false /follow-redirects@1.15.2: @@ -2534,6 +2654,13 @@ packages: resolution: {integrity: sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ==} dependencies: sourcemap-codec: 1.4.8 + dev: true + + /magic-string@0.30.5: + resolution: {integrity: sha512-7xlpfBaQaP/T6Vh8MO/EqXSW5En6INHEvEXQiuff7Gku0PWjU3uf6w/j9o7O+SpB5fOAkrI5HeoNgwjEO0pFsA==} + engines: {node: '>=12'} + dependencies: + '@jridgewell/sourcemap-codec': 1.4.15 /memorystream@0.3.1: resolution: {integrity: sha512-S3UwM3yj5mtUSEfP41UZmt/0SCoVYUcU1rkXv+BQ5Ig8ndL4sPoJNBUJERafdPb5jjHJGuMgytgKvKIf58XNBw==} @@ -2597,6 +2724,12 @@ packages: resolution: {integrity: sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==} engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} hasBin: true + dev: true + + /nanoid@3.3.6: + resolution: {integrity: sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==} + engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} + hasBin: true /natural-compare@1.4.0: resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==} @@ -2834,6 +2967,7 @@ packages: nanoid: 3.3.4 picocolors: 1.0.0 source-map-js: 1.0.2 + dev: true /postcss@8.4.18: resolution: {integrity: sha512-Wi8mWhncLJm11GATDaQKobXSNEYGUHeQLiQqDFG1qQ5UTDPTEvKw0Xt5NsTpktGTwLps3ByrWsBrG0rB8YQ9oA==} @@ -2844,6 +2978,14 @@ packages: source-map-js: 1.0.2 dev: true + /postcss@8.4.31: + resolution: {integrity: sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==} + engines: {node: ^10 || ^12 || >=14} + dependencies: + nanoid: 3.3.6 + picocolors: 1.0.0 + source-map-js: 1.0.2 + /prelude-ls@1.1.2: resolution: {integrity: sha512-ESF23V4SKG6lVSGZgYNpbsiaAkdab6ZgOxe52p7+Kid3W3u3bxR4Vfd/o21dmN7jSt0IwgZ4v5MUd26FEtXE9w==} engines: {node: '>= 0.8.0'} @@ -2914,6 +3056,10 @@ packages: engines: {node: '>=8'} dev: true + /remove-accents@0.4.2: + resolution: {integrity: sha512-7pXIJqJOq5tFgG1A2Zxti3Ht8jJF337m4sowbuHsW30ZnkQFnDzy9qBNhgzX8ZLW4+UBcXiiR7SwR6pokHsxiA==} + dev: false + /resolve-from@4.0.0: resolution: {integrity: sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==} engines: {node: '>=4'} @@ -3058,9 +3204,11 @@ packages: /source-map@0.6.1: resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==} engines: {node: '>=0.10.0'} + dev: true /sourcemap-codec@1.4.8: resolution: {integrity: sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==} + dev: true /spdx-correct@3.1.1: resolution: {integrity: sha512-cOYcUWwhCuHCXi49RhFRCyJEK3iPj1Ziz9DpViV3tbZOwXD49QzIN3MpOLJNxh2qwq2lJJZaKMVw9qNi4jTC0w==} @@ -3251,7 +3399,6 @@ packages: resolution: {integrity: sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==} engines: {node: '>=4.2.0'} hasBin: true - dev: true /unbox-primitive@1.0.2: resolution: {integrity: sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw==} @@ -3402,6 +3549,21 @@ packages: - terser dev: true + /vue-demi@0.13.11(vue@3.3.7): + resolution: {integrity: sha512-IR8HoEEGM65YY3ZJYAjMlKygDQn25D5ajNFNoKh9RSDMQtlzCxtfQjdQgv9jjK+m3377SsJXY8ysq8kLCZL25A==} + engines: {node: '>=12'} + hasBin: true + requiresBuild: true + peerDependencies: + '@vue/composition-api': ^1.0.0-rc.1 + vue: ^3.0.0-0 || ^2.6.0 + peerDependenciesMeta: + '@vue/composition-api': + optional: true + dependencies: + vue: 3.3.7(typescript@4.7.4) + dev: false + /vue-eslint-parser@9.1.0(eslint@8.26.0): resolution: {integrity: sha512-NGn/iQy8/Wb7RrRa4aRkokyCZfOUWk19OP5HP6JEozQFX5AoS/t+Z0ZN7FY4LlmWc4FNI922V7cvX28zctN8dQ==} engines: {node: ^14.17.0 || >=16.0.0} @@ -3420,12 +3582,21 @@ packages: - supports-color dev: true - /vue-resize@2.0.0-alpha.1(vue@3.2.41): + /vue-resize@2.0.0-alpha.1(vue@3.3.7): resolution: {integrity: sha512-7+iqOueLU7uc9NrMfrzbG8hwMqchfVfSzpVlCMeJQe4pyibqyoifDNbKTZvwxZKDvGkB+PdFeKvnGZMoEb8esg==} peerDependencies: vue: ^3.0.0 dependencies: - vue: 3.2.41 + vue: 3.3.7(typescript@4.7.4) + dev: false + + /vue-router@4.2.5(vue@3.3.7): + resolution: {integrity: sha512-DIUpKcyg4+PTQKfFPX88UWhlagBEBEfJ5A8XDXRJLUnZOvcpMF8o/dnL90vpVkGaPbjvXazV/rC1qBKrZlFugw==} + peerDependencies: + vue: ^3.2.0 + dependencies: + '@vue/devtools-api': 6.5.1 + vue: 3.3.7(typescript@4.7.4) dev: false /vue-template-compiler@2.7.13: @@ -3446,14 +3617,20 @@ packages: typescript: 4.7.4 dev: true - /vue@3.2.41: - resolution: {integrity: sha512-uuuvnrDXEeZ9VUPljgHkqB5IaVO8SxhPpqF2eWOukVrBnRBx2THPSGQBnVRt0GrIG1gvCmFXMGbd7FqcT1ixNQ==} + /vue@3.3.7(typescript@4.7.4): + resolution: {integrity: sha512-YEMDia1ZTv1TeBbnu6VybatmSteGOS3A3YgfINOfraCbf85wdKHzscD6HSS/vB4GAtI7sa1XPX7HcQaJ1l24zA==} + peerDependencies: + typescript: '*' + peerDependenciesMeta: + typescript: + optional: true dependencies: - '@vue/compiler-dom': 3.2.41 - '@vue/compiler-sfc': 3.2.41 - '@vue/runtime-dom': 3.2.41 - '@vue/server-renderer': 3.2.41(vue@3.2.41) - '@vue/shared': 3.2.41 + '@vue/compiler-dom': 3.3.7 + '@vue/compiler-sfc': 3.3.7 + '@vue/runtime-dom': 3.3.7 + '@vue/server-renderer': 3.3.7(vue@3.3.7) + '@vue/shared': 3.3.7 + typescript: 4.7.4 /w3c-hr-time@1.0.2: resolution: {integrity: sha512-z8P5DvDNjKDoFIHK7q8r8lackT6l+jo/Ye3HOle7l9nICP9lf1Ci25fy9vHd0JOWewkIFzXIEig3TdKT7JQ5fQ==} diff --git a/console/src/controller/index.ts b/console/src/controller/index.ts index 98050d7..49d55d5 100644 --- a/console/src/controller/index.ts +++ b/console/src/controller/index.ts @@ -1 +1,2 @@ export * from "./s-3-link-controller"; +export * from "./s-3-unlink-controller"; diff --git a/console/src/controller/s-3-unlink-controller/deleteApisS3OsHaloRunV1Alpha1AttachmentsByName.ts b/console/src/controller/s-3-unlink-controller/deleteApisS3OsHaloRunV1Alpha1AttachmentsByName.ts new file mode 100644 index 0000000..e4d42a0 --- /dev/null +++ b/console/src/controller/s-3-unlink-controller/deleteApisS3OsHaloRunV1Alpha1AttachmentsByName.ts @@ -0,0 +1,13 @@ +import request from "@/utils/request"; +import { Attachment, DeepRequired } from "../../interface"; + +/** + * /apis/s3os.halo.run/v1alpha1/attachments/{name} + */ +export function deleteApisS3OsHaloRunV1Alpha1AttachmentsByName(params: DeleteApisS3OsHaloRunV1Alpha1AttachmentsByNameParams) { + return request.delete>(`/apis/s3os.halo.run/v1alpha1/attachments/${params.name}`); +} + +interface DeleteApisS3OsHaloRunV1Alpha1AttachmentsByNameParams { + name: any; +} diff --git a/console/src/controller/s-3-unlink-controller/index.ts b/console/src/controller/s-3-unlink-controller/index.ts new file mode 100644 index 0000000..68f572d --- /dev/null +++ b/console/src/controller/s-3-unlink-controller/index.ts @@ -0,0 +1 @@ +export * from "./deleteApisS3OsHaloRunV1Alpha1AttachmentsByName"; diff --git a/console/src/index.ts b/console/src/index.ts index 3c894dd..6b77ac9 100644 --- a/console/src/index.ts +++ b/console/src/index.ts @@ -1,13 +1,17 @@ -import {definePlugin} from "@halo-dev/console-shared"; -import type {PluginTab} from "@halo-dev/console-shared"; +import { definePlugin } from "@halo-dev/console-shared"; +import type { PluginTab } from "@halo-dev/console-shared"; import S3Link from "./views/S3Link.vue"; -import {markRaw} from "vue"; +import S3Unlink from "./views/S3Unlink.vue" +import { markRaw } from "vue"; + +import type { Attachment } from "./interface"; +import type { Ref } from "vue"; export default definePlugin({ components: {}, routes: [], extensionPoints: { - "plugin:self:tabs:create": () : PluginTab[] => { + "plugin:self:tabs:create": (): PluginTab[] => { return [ { id: "s3-link", @@ -17,5 +21,19 @@ export default definePlugin({ }, ]; }, + // @ts-ignore + "attachment:list-item:operation:create": (attachment: Ref) => { + return [ + { + priority: 21, + component: markRaw(S3Unlink), + permissions: ["plugin:s3os:unlink"], + props: { + "attachment": attachment, + }, + hidden: !(attachment.value.metadata.annotations && attachment.value.metadata.annotations["s3os.plugin.halo.run/object-key"]) + }, + ]; + }, }, }); diff --git a/console/src/interface/apiTypes/Attachment.ts b/console/src/interface/apiTypes/Attachment.ts new file mode 100644 index 0000000..80bbdb5 --- /dev/null +++ b/console/src/interface/apiTypes/Attachment.ts @@ -0,0 +1,9 @@ +import { Metadata, AttachmentSpec, AttachmentStatus } from "../../interface"; + +export interface Attachment { + apiVersion: any; + kind: any; + metadata: Metadata; + spec: AttachmentSpec; + status?: AttachmentStatus; +} diff --git a/console/src/interface/apiTypes/AttachmentSpec.ts b/console/src/interface/apiTypes/AttachmentSpec.ts new file mode 100644 index 0000000..1876920 --- /dev/null +++ b/console/src/interface/apiTypes/AttachmentSpec.ts @@ -0,0 +1,16 @@ +export interface AttachmentSpec { + /** Display name of attachment */ + displayName?: any; + /** Group name */ + groupName?: any; + /** Media type of attachment */ + mediaType?: any; + /** Name of User who uploads the attachment */ + ownerName?: any; + /** Policy name */ + policyName?: any; + /** Size of attachment. Unit is Byte */ + size?: any; + /** Tags of attachment */ + tags?: any; +} diff --git a/console/src/interface/apiTypes/AttachmentStatus.ts b/console/src/interface/apiTypes/AttachmentStatus.ts new file mode 100644 index 0000000..094dd24 --- /dev/null +++ b/console/src/interface/apiTypes/AttachmentStatus.ts @@ -0,0 +1,9 @@ +export interface AttachmentStatus { + /** + * Permalink of attachment. + * If it is in local storage, the public URL will be set. + * If it is in s3 storage, the Object URL will be set. + * + */ + permalink?: any; +} diff --git a/console/src/interface/index.ts b/console/src/interface/index.ts index 6bc4050..319518d 100644 --- a/console/src/interface/index.ts +++ b/console/src/interface/index.ts @@ -6,6 +6,9 @@ export * from "./apiTypes/ObjectVo"; export * from "./apiTypes/Policy"; export * from "./apiTypes/PolicySpec"; export * from "./apiTypes/S3ListResult"; +export * from "./apiTypes/Attachment"; +export * from "./apiTypes/AttachmentSpec"; +export * from "./apiTypes/AttachmentStatus"; export type Primitive = undefined | null | boolean | string | number | symbol; export type DeepRequired = T extends Primitive ? T : keyof T extends never ? T : { [K in keyof T]-?: DeepRequired }; diff --git a/console/src/swagger.config.json b/console/src/swagger.config.json index b899a0a..e246d8d 100644 --- a/console/src/swagger.config.json +++ b/console/src/swagger.config.json @@ -1,6 +1,6 @@ { "docsUrl": "http://localhost:8090/v3/api-docs/extension-api", - "includeTags": ["s-3-link-controller"], + "includeTags": ["s-3-link-controller", "s-3-unlink-controller"], "excludeTags": [], "axiosInstanceUrl": "@/utils/request", "prefix": "" diff --git a/console/src/views/S3Unlink.vue b/console/src/views/S3Unlink.vue new file mode 100644 index 0000000..f7acf66 --- /dev/null +++ b/console/src/views/S3Unlink.vue @@ -0,0 +1,42 @@ + + \ No newline at end of file diff --git a/src/main/java/run/halo/s3os/S3UnlinkController.java b/src/main/java/run/halo/s3os/S3UnlinkController.java new file mode 100644 index 0000000..d46ce6b --- /dev/null +++ b/src/main/java/run/halo/s3os/S3UnlinkController.java @@ -0,0 +1,22 @@ +package run.halo.s3os; + +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; + +import lombok.RequiredArgsConstructor; +import reactor.core.publisher.Mono; +import run.halo.app.core.extension.attachment.Attachment; +import run.halo.app.plugin.ApiVersion; + +@ApiVersion("s3os.halo.run/v1alpha1") +@RestController +@RequiredArgsConstructor +public class S3UnlinkController { + private final S3UnlinkService s3UnlinkService; + + @DeleteMapping("/attachments/{name}") + public Mono unlink(@PathVariable("name") String name) { + return s3UnlinkService.unlink(name); + } +} \ No newline at end of file diff --git a/src/main/java/run/halo/s3os/S3UnlinkService.java b/src/main/java/run/halo/s3os/S3UnlinkService.java new file mode 100644 index 0000000..5245191 --- /dev/null +++ b/src/main/java/run/halo/s3os/S3UnlinkService.java @@ -0,0 +1,8 @@ +package run.halo.s3os; + +import reactor.core.publisher.Mono; +import run.halo.app.core.extension.attachment.Attachment; + +public interface S3UnlinkService { + Mono unlink(String name); +} \ No newline at end of file diff --git a/src/main/java/run/halo/s3os/S3UnlinkServiceImpl.java b/src/main/java/run/halo/s3os/S3UnlinkServiceImpl.java new file mode 100644 index 0000000..5e62425 --- /dev/null +++ b/src/main/java/run/halo/s3os/S3UnlinkServiceImpl.java @@ -0,0 +1,41 @@ +package run.halo.s3os; + +import org.springframework.stereotype.Service; +import org.springframework.web.server.ServerWebInputException; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import reactor.core.publisher.Mono; +import run.halo.app.core.extension.attachment.Attachment; +import run.halo.app.core.extension.attachment.Constant; +import run.halo.app.core.extension.attachment.Policy; +import run.halo.app.extension.ReactiveExtensionClient; + +@Service +@RequiredArgsConstructor +@Slf4j +public class S3UnlinkServiceImpl implements S3UnlinkService{ + private final ReactiveExtensionClient client; + private final S3OsAttachmentHandler handler; + + @Override + public Mono unlink(String name) { + return client.get(Attachment.class, name) + .flatMap((attachment) -> { + return client.get(Policy.class, attachment.getSpec().getPolicyName()) + .doOnNext((policy) -> { + if(!handler.shouldHandle(policy)) { + throw new ServerWebInputException("The policy to which this attachment belongs is not managed by plugin-s3."); + } + }).thenReturn(attachment); + }) + .flatMap(attachment -> { + attachment.getMetadata().getFinalizers().remove(Constant.FINALIZER_NAME); + return client.update(attachment); + }) + .flatMap(attachment -> { + return client.delete(attachment); + }); + } + +} diff --git a/src/main/resources/extensions/s3os-role-template.yaml b/src/main/resources/extensions/s3os-role-template.yaml index b833d2b..df9d8eb 100644 --- a/src/main/resources/extensions/s3os-role-template.yaml +++ b/src/main/resources/extensions/s3os-role-template.yaml @@ -21,3 +21,21 @@ rules: verbs: [ "get", "list" ] - nonResourceURLs: ["/apis/s3os.halo.run/v1alpha1/attachments/link"] verbs: [ "create" ] +--- +apiVersion: v1alpha1 +kind: "Role" +metadata: + name: role-template-s3os-unlink + labels: + halo.run/role-template: "true" + annotations: + rbac.authorization.halo.run/dependencies: | + [ "role-template-manage-attachments" ] + rbac.authorization.halo.run/module: "S3 Attachments Management" + rbac.authorization.halo.run/display-name: "S3 UnLink" + rbac.authorization.halo.run/ui-permissions: | + ["plugin:s3os:unlink"] +rules: + - apiGroups: [ "s3os.halo.run" ] + resources: [ "attachments" ] + verbs: [ "delete" ] diff --git a/src/main/resources/plugin.yaml b/src/main/resources/plugin.yaml index 856c60d..e08b541 100644 --- a/src/main/resources/plugin.yaml +++ b/src/main/resources/plugin.yaml @@ -4,7 +4,7 @@ metadata: name: PluginS3ObjectStorage spec: enabled: true - requires: ">=2.9.0" + requires: ">=2.10.0" author: name: Halo OSS Team website: https://github.com/halo-dev