cabloy 5.1.97 → 5.1.99
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.
- package/.cabloy-version +1 -1
- package/.claude/hooks/contract-loop-gate.ts +151 -44
- package/CHANGELOG.md +48 -0
- package/CLAUDE.md +2 -0
- package/cabloy-docs/.vitepress/config.mjs +11 -0
- package/cabloy-docs/backend/controller-aop-guide.md +0 -1
- package/cabloy-docs/backend/image-guide.md +544 -0
- package/cabloy-docs/frontend/a-openapi-under-the-hood.md +1 -1
- package/cabloy-docs/frontend/generated-contract-consumption-entry-branch.md +1 -1
- package/cabloy-docs/frontend/generated-contract-consumption-list-branch.md +1 -1
- package/cabloy-docs/frontend/generated-contract-consumption-verify-playbook.md +1 -1
- package/cabloy-docs/frontend/image-guide.md +512 -0
- package/cabloy-docs/frontend/introduction.md +2 -0
- package/cabloy-docs/frontend/ioc-and-beans.md +34 -3
- package/cabloy-docs/frontend/model-architecture.md +2 -0
- package/cabloy-docs/frontend/model-resource-owner-pattern.md +3 -1
- package/cabloy-docs/frontend/model-state-guide.md +5 -1
- package/cabloy-docs/frontend/reading-zova-for-vue-developers.md +10 -8
- package/cabloy-docs/frontend/resource-entry-page-deep-dive.md +2 -2
- package/cabloy-docs/frontend/resource-list-page-deep-dive.md +1 -1
- package/cabloy-docs/frontend/rest-resource-source-reading-map.md +2 -2
- package/cabloy-docs/frontend/rest-resource-under-the-hood.md +4 -4
- package/cabloy-docs/frontend/server-data.md +2 -0
- package/cabloy-docs/frontend/state-architecture-for-vue-developers.md +218 -0
- package/cabloy-docs/frontend/system-startup-guide.md +2 -0
- package/cabloy-docs/frontend/use-state-data-best-practices.md +384 -0
- package/cabloy-docs/frontend/zova-vs-vue3-comparison.md +11 -10
- package/cabloy-docs/fullstack/image-workflow.md +403 -0
- package/cabloy-docs/fullstack/introduction.md +1 -0
- package/package.json +1 -1
- package/scripts/upgrade.ts +2 -0
- package/vona/package.original.json +0 -1
- package/vona/packages-cli/cli/package.json +1 -1
- package/vona/packages-cli/cli-set-api/package.json +1 -1
- package/vona/packages-vona/vona/package.json +1 -1
- package/vona/packages-vona/vona-core/package.json +1 -1
- package/vona/packages-vona/vona-core/src/lib/bean/beanBase.ts +9 -9
- package/vona/packages-vona/vona-mock/package.json +1 -1
- package/vona/pnpm-lock.yaml +424 -47
- package/vona/src/suite/a-training/modules/training-record/src/bean/fileScene.dossierFile.ts +22 -0
- package/vona/src/suite/a-training/modules/training-record/src/bean/meta.version.ts +1 -0
- package/vona/src/suite/a-training/modules/training-record/src/config/locale/en-us.ts +1 -0
- package/vona/src/suite/a-training/modules/training-record/src/config/locale/zh-cn.ts +1 -0
- package/vona/src/suite/a-training/modules/training-record/src/dto/recordDossierFileView.ts +47 -0
- package/vona/src/suite/a-training/modules/training-record/src/dto/recordSelectResItem.tsx +13 -0
- package/vona/src/suite/a-training/modules/training-record/src/dto/recordView.tsx +13 -0
- package/vona/src/suite/a-training/modules/training-record/src/entity/record.tsx +16 -5
- package/vona/src/suite/a-training/modules/training-record/src/index.ts +2 -0
- package/vona/src/suite/a-training/modules/training-record/src/lib/index.ts +1 -0
- package/vona/src/suite/a-training/modules/training-record/src/lib/resolveDossierFiles.ts +34 -0
- package/vona/src/suite/a-training/modules/training-record/test/record.test.ts +209 -123
- package/vona/src/suite/a-training/modules/training-student/src/config/locale/en-us.ts +1 -0
- package/vona/src/suite/a-training/modules/training-student/src/config/locale/zh-cn.ts +1 -0
- package/vona/src/suite/a-training/modules/training-student/src/dto/detailRecordBase.tsx +18 -1
- package/vona/src/suite/a-training/modules/training-student/src/entity/student.tsx +0 -2
- package/vona/src/suite/a-training/modules/training-student/src/model/student.ts +1 -0
- package/vona/src/suite/cabloy-basic/modules/basic-siteadmin/src/bean/ssrSite.admin.ts +4 -0
- package/vona/src/suite/cabloy-basic/modules/basic-siteweb/src/bean/ssrSite.web.ts +4 -0
- package/vona/src/suite-vendor/a-cabloy/modules/a-ssr/cli/ssrSite/boilerplate/{{sceneName}}.{{beanName}}.ts_ +3 -0
- package/vona/src/suite-vendor/a-cabloy/modules/a-ssr/package.json +1 -1
- package/vona/src/suite-vendor/a-cabloy/modules/a-ssr/src/service/ssrHandler.ts +11 -2
- package/vona/src/suite-vendor/a-cabloy/modules/a-ssr/src/types/ssrSite.ts +6 -0
- package/vona/src/suite-vendor/a-cabloy/package.json +1 -1
- package/vona/src/suite-vendor/a-file/modules/a-file/cli/fileProvider/boilerplate/{{sceneName}}.{{beanName}}.ts_ +23 -0
- package/vona/src/suite-vendor/a-file/modules/a-file/cli/fileScene/boilerplate/{{sceneName}}.{{beanName}}.ts_ +5 -0
- package/vona/src/suite-vendor/a-file/modules/a-file/package.json +68 -0
- package/vona/src/suite-vendor/a-file/modules/a-file/src/.metadata/index.ts +425 -0
- package/vona/src/suite-vendor/a-file/modules/a-file/src/.metadata/locales.ts +18 -0
- package/vona/src/suite-vendor/a-file/modules/a-file/src/.metadata/this.ts +2 -0
- package/vona/src/suite-vendor/a-file/modules/a-file/src/bean/bean.file.ts +322 -0
- package/vona/src/suite-vendor/a-file/modules/a-file/src/bean/bean.fileProvider.ts +62 -0
- package/vona/src/suite-vendor/a-file/modules/a-file/src/bean/bean.fileUploadPolicy.ts +224 -0
- package/vona/src/suite-vendor/a-file/modules/a-file/src/bean/meta.redlock.ts +11 -0
- package/vona/src/suite-vendor/a-file/modules/a-file/src/bean/meta.version.ts +38 -0
- package/vona/src/suite-vendor/a-file/modules/a-file/src/config/config.ts +16 -0
- package/vona/src/suite-vendor/a-file/modules/a-file/src/config/locale/en-us.ts +1 -0
- package/vona/src/suite-vendor/a-file/modules/a-file/src/config/locale/zh-cn.ts +1 -0
- package/vona/src/suite-vendor/a-file/modules/a-file/src/controller/file.ts +175 -0
- package/vona/src/suite-vendor/a-file/modules/a-file/src/dto/fileDirectUploadRequest.ts +33 -0
- package/vona/src/suite-vendor/a-file/modules/a-file/src/dto/fileDirectUploadResponse.ts +41 -0
- package/vona/src/suite-vendor/a-file/modules/a-file/src/dto/fileDownloadRequest.ts +12 -0
- package/vona/src/suite-vendor/a-file/modules/a-file/src/dto/fileUploadPolicyRequest.ts +15 -0
- package/vona/src/suite-vendor/a-file/modules/a-file/src/dto/fileUploadPolicyResponse.ts +30 -0
- package/vona/src/suite-vendor/a-file/modules/a-file/src/dto/fileUploadResponse.ts +59 -0
- package/vona/src/suite-vendor/a-file/modules/a-file/src/dto/fileUploadTokenRequest.ts +24 -0
- package/vona/src/suite-vendor/a-file/modules/a-file/src/dto/fileUploadTokenResponse.ts +16 -0
- package/vona/src/suite-vendor/a-file/modules/a-file/src/dto/fileUploadUrlRequest.ts +33 -0
- package/vona/src/suite-vendor/a-file/modules/a-file/src/entity/file.ts +55 -0
- package/vona/src/suite-vendor/a-file/modules/a-file/src/entity/fileProvider.ts +24 -0
- package/vona/src/suite-vendor/a-file/modules/a-file/src/index.ts +4 -0
- package/vona/src/suite-vendor/a-file/modules/a-file/src/lib/fileProvider.ts +7 -0
- package/vona/src/suite-vendor/a-file/modules/a-file/src/lib/fileScene.ts +7 -0
- package/vona/src/suite-vendor/a-file/modules/a-file/src/lib/fileUploadValidation.ts +15 -0
- package/vona/src/suite-vendor/a-file/modules/a-file/src/lib/index.ts +3 -0
- package/vona/src/suite-vendor/a-file/modules/a-file/src/model/file.ts +10 -0
- package/vona/src/suite-vendor/a-file/modules/a-file/src/model/fileProvider.ts +10 -0
- package/vona/src/suite-vendor/a-file/modules/a-file/src/types/file.ts +144 -0
- package/vona/src/suite-vendor/a-file/modules/a-file/src/types/fileProvider.ts +111 -0
- package/vona/src/suite-vendor/a-file/modules/a-file/src/types/fileScene.ts +53 -0
- package/vona/src/suite-vendor/a-file/modules/a-file/src/types/index.ts +3 -0
- package/vona/src/suite-vendor/a-file/modules/a-file/tsconfig.build.json +11 -0
- package/vona/src/suite-vendor/a-file/modules/a-file/tsconfig.json +7 -0
- package/vona/src/suite-vendor/a-file/modules/file-cloudflare/package.json +53 -0
- package/vona/src/suite-vendor/a-file/modules/file-cloudflare/src/.metadata/index.ts +104 -0
- package/vona/src/suite-vendor/a-file/modules/file-cloudflare/src/.metadata/this.ts +2 -0
- package/vona/src/suite-vendor/a-file/modules/file-cloudflare/src/bean/fileProvider.cloudflare.ts +123 -0
- package/vona/src/suite-vendor/a-file/modules/file-cloudflare/src/index.ts +1 -0
- package/vona/src/suite-vendor/a-file/modules/file-cloudflare/src/service/fileCloudflare.ts +245 -0
- package/vona/src/suite-vendor/a-file/modules/file-cloudflare/tsconfig.build.json +11 -0
- package/vona/src/suite-vendor/a-file/modules/file-cloudflare/tsconfig.json +7 -0
- package/vona/src/suite-vendor/a-file/modules/file-native/package.json +50 -0
- package/vona/src/suite-vendor/a-file/modules/file-native/src/.metadata/index.ts +111 -0
- package/vona/src/suite-vendor/a-file/modules/file-native/src/.metadata/this.ts +2 -0
- package/vona/src/suite-vendor/a-file/modules/file-native/src/bean/fileProvider.native.ts +125 -0
- package/vona/src/suite-vendor/a-file/modules/file-native/src/config/config.ts +7 -0
- package/vona/src/suite-vendor/a-file/modules/file-native/src/index.ts +1 -0
- package/vona/src/suite-vendor/a-file/modules/file-native/src/service/fileNative.ts +125 -0
- package/vona/src/suite-vendor/a-file/modules/file-native/tsconfig.build.json +11 -0
- package/vona/src/suite-vendor/a-file/modules/file-native/tsconfig.json +7 -0
- package/vona/src/suite-vendor/a-file/package.json +14 -0
- package/vona/src/suite-vendor/a-file/tsconfig.base.json +4 -0
- package/vona/src/suite-vendor/a-file/tsconfig.json +16 -0
- package/vona/src/suite-vendor/a-image/modules/a-image/package.json +4 -1
- package/vona/src/suite-vendor/a-image/modules/a-image/src/.metadata/index.ts +61 -3
- package/vona/src/suite-vendor/a-image/modules/a-image/src/bean/bean.image.ts +336 -152
- package/vona/src/suite-vendor/a-image/modules/a-image/src/bean/bean.imageProvider.ts +21 -14
- package/vona/src/suite-vendor/a-image/modules/a-image/src/bean/bean.imageUploadPolicy.ts +86 -11
- package/vona/src/suite-vendor/a-image/modules/a-image/src/bean/meta.index.ts +12 -0
- package/vona/src/suite-vendor/a-image/modules/a-image/src/bean/meta.redlock.ts +1 -1
- package/vona/src/suite-vendor/a-image/modules/a-image/src/bean/meta.version.ts +3 -0
- package/vona/src/suite-vendor/a-image/modules/a-image/src/bean/schedule.imageDraftPrune.ts +29 -0
- package/vona/src/suite-vendor/a-image/modules/a-image/src/config/config.ts +3 -0
- package/vona/src/suite-vendor/a-image/modules/a-image/src/controller/image.ts +32 -54
- package/vona/src/suite-vendor/a-image/modules/a-image/src/dto/imageDirectUploadFinalizeRequest.ts +13 -0
- package/vona/src/suite-vendor/a-image/modules/a-image/src/dto/imageDirectUploadFinalizeResponse.ts +10 -0
- package/vona/src/suite-vendor/a-image/modules/a-image/src/dto/imageDirectUploadResponse.ts +10 -0
- package/vona/src/suite-vendor/a-image/modules/a-image/src/dto/imageUploadPolicyRequest.ts +15 -0
- package/vona/src/suite-vendor/a-image/modules/a-image/src/dto/imageUploadPolicyResponse.ts +27 -0
- package/vona/src/suite-vendor/a-image/modules/a-image/src/dto/imageUploadResponse.ts +10 -1
- package/vona/src/suite-vendor/a-image/modules/a-image/src/dto/imageView.ts +10 -1
- package/vona/src/suite-vendor/a-image/modules/a-image/src/entity/image.ts +10 -1
- package/vona/src/suite-vendor/a-image/modules/a-image/src/lib/imageUploadValidation.ts +15 -0
- package/vona/src/suite-vendor/a-image/modules/a-image/src/lib/index.ts +1 -0
- package/vona/src/suite-vendor/a-image/modules/a-image/src/types/image.ts +18 -0
- package/vona/src/suite-vendor/a-image/modules/a-image/src/types/imageProvider.ts +28 -2
- package/vona/src/suite-vendor/a-image/modules/image-cloudflare/package.json +1 -1
- package/vona/src/suite-vendor/a-image/modules/image-cloudflare/src/bean/imageProvider.cloudflare.ts +13 -1
- package/vona/src/suite-vendor/a-image/modules/image-cloudflare/src/service/imageCloudflare.ts +26 -0
- package/vona/src/suite-vendor/a-image/modules/image-native/package.json +6 -2
- package/vona/src/suite-vendor/a-image/modules/image-native/src/.metadata/index.ts +37 -0
- package/vona/src/suite-vendor/a-image/modules/image-native/src/bean/imageProvider.native.ts +21 -1
- package/vona/src/suite-vendor/a-image/modules/image-native/src/controller/image.ts +57 -0
- package/vona/src/suite-vendor/a-image/modules/image-native/src/service/imageNative.ts +142 -34
- package/vona/src/suite-vendor/a-image/package.json +1 -1
- package/vona/src/suite-vendor/a-vona/modules/a-core/package.json +1 -1
- package/vona/src/suite-vendor/a-vona/modules/a-orm/package.json +1 -1
- package/vona/src/suite-vendor/a-vona/modules/a-orm/src/types/entity.ts +2 -4
- package/vona/src/suite-vendor/a-vona/modules/a-ormutils/package.json +1 -1
- package/vona/src/suite-vendor/a-vona/modules/a-ormutils/src/lib/columns.ts +7 -3
- package/vona/src/suite-vendor/a-vona/modules/a-permission/package.json +1 -1
- package/vona/src/suite-vendor/a-vona/modules/a-permission/src/.metadata/index.ts +24 -9
- package/vona/src/suite-vendor/a-vona/modules/a-permission/src/bean/bean.permission.ts +87 -73
- package/vona/src/suite-vendor/a-vona/modules/a-permission/src/bean/summerCache.permissionActionByRoles.ts +27 -0
- package/vona/src/suite-vendor/a-vona/modules/a-permission/src/bean/summerCache.permissionUser.ts +20 -0
- package/vona/src/suite-vendor/a-vona/modules/a-startup/package.json +1 -1
- package/vona/src/suite-vendor/a-vona/modules/a-startup/src/service/startup.ts +4 -3
- package/vona/src/suite-vendor/a-vona/modules/a-upload/package.json +1 -1
- package/vona/src/suite-vendor/a-vona/modules/a-upload/src/bean/interceptor.upload.ts +5 -1
- package/vona/src/suite-vendor/a-vona/modules/a-user/package.json +1 -1
- package/vona/src/suite-vendor/a-vona/modules/a-user/src/.metadata/index.ts +0 -13
- package/vona/src/suite-vendor/a-vona/modules/a-user/src/lib/passport.ts +0 -7
- package/vona/src/suite-vendor/a-vona/modules/a-version/package.json +1 -1
- package/vona/src/suite-vendor/a-vona/modules/a-version/src/bean/meta.version.ts +2 -24
- package/vona/src/suite-vendor/a-vona/package.json +1 -1
- package/zova/packages-utils/zova-jsx/package.json +2 -2
- package/zova/packages-zova/zova/package.json +3 -3
- package/zova/packages-zova/zova-core/package.json +1 -1
- package/zova/packages-zova/zova-core/src/bean/beanBase.ts +9 -13
- package/zova/pnpm-lock.yaml +418 -411
- package/zova/src/suite/a-demo/modules/demo-basic/src/page/toolOne/controller.tsx +2 -2
- package/zova/src/suite/a-demo/modules/demo-todo/src/page/todo/controller.tsx +2 -2
- package/zova/src/suite/a-home/modules/home-layoutadmin/src/component/layoutAdmin/controller.tsx +2 -2
- package/zova/src/suite/a-home/modules/home-layoutweb/src/component/layoutWeb/controller.tsx +2 -2
- package/zova/src/suite/a-home/modules/home-login/src/page/login/controller.tsx +2 -2
- package/zova/src/suite/cabloy-basic/modules/basic-details/src/component/blockDetails/controller.tsx +5 -1
- package/zova/src/suite/cabloy-basic/modules/basic-details/src/component/blockTable/controller.tsx +20 -15
- package/zova/src/suite/cabloy-basic/modules/basic-details/src/service/detail.tsx +6 -1
- package/zova/src/suite/cabloy-basic/modules/basic-file/cli/openapi.config.ts +9 -0
- package/zova/src/suite/cabloy-basic/modules/basic-file/package.json +58 -0
- package/zova/src/suite/cabloy-basic/modules/basic-file/src/.metadata/component/formFieldFile.ts +31 -0
- package/zova/src/suite/cabloy-basic/modules/basic-file/src/.metadata/index.ts +222 -0
- package/zova/src/suite/cabloy-basic/modules/basic-file/src/.metadata/locales.ts +7 -0
- package/zova/src/suite/cabloy-basic/modules/basic-file/src/.metadata/this.ts +2 -0
- package/zova/src/suite/cabloy-basic/modules/basic-file/src/api/file.ts +121 -0
- package/zova/src/suite/cabloy-basic/modules/basic-file/src/api/openapi/baseURL.ts +5 -0
- package/zova/src/suite/cabloy-basic/modules/basic-file/src/api/openapi/index.ts +3 -0
- package/zova/src/suite/cabloy-basic/modules/basic-file/src/api/openapi/schemas.ts +306 -0
- package/zova/src/suite/cabloy-basic/modules/basic-file/src/api/openapi/types.ts +5718 -0
- package/zova/src/suite/cabloy-basic/modules/basic-file/src/apiSchema/file.ts +40 -0
- package/zova/src/suite/cabloy-basic/modules/basic-file/src/bean/tableCell.file.tsx +187 -0
- package/zova/src/suite/cabloy-basic/modules/basic-file/src/component/formFieldFile/controller.tsx +534 -0
- package/zova/src/suite/cabloy-basic/modules/basic-file/src/config/locale/en-us.ts +15 -0
- package/zova/src/suite/cabloy-basic/modules/basic-file/src/config/locale/zh-cn.ts +15 -0
- package/zova/src/suite/cabloy-basic/modules/basic-file/src/index.ts +4 -0
- package/zova/src/suite/cabloy-basic/modules/basic-file/src/lib/file.ts +74 -0
- package/zova/src/suite/cabloy-basic/modules/basic-file/src/lib/index.ts +1 -0
- package/zova/src/suite/cabloy-basic/modules/basic-file/src/model/file.ts +23 -0
- package/zova/src/suite/cabloy-basic/modules/basic-file/src/types/file.ts +12 -0
- package/zova/src/suite/cabloy-basic/modules/basic-file/src/types/index.ts +1 -0
- package/zova/src/suite/cabloy-basic/modules/basic-file/tsconfig.build.json +13 -0
- package/zova/src/suite/cabloy-basic/modules/basic-file/tsconfig.json +5 -0
- package/zova/src/suite/cabloy-basic/modules/basic-image/src/.metadata/index.ts +61 -0
- package/zova/src/suite/cabloy-basic/modules/basic-image/src/api/image.ts +38 -1
- package/zova/src/suite/cabloy-basic/modules/basic-image/src/api/imageNativeImage.ts +31 -0
- package/zova/src/suite/cabloy-basic/modules/basic-image/src/api/openapi/schemas.ts +52 -0
- package/zova/src/suite/cabloy-basic/modules/basic-image/src/api/openapi/types.ts +614 -1
- package/zova/src/suite/cabloy-basic/modules/basic-image/src/apiSchema/image.ts +10 -0
- package/zova/src/suite/cabloy-basic/modules/basic-image/src/apiSchema/imageNativeImage.ts +13 -0
- package/zova/src/suite/cabloy-basic/modules/basic-image/src/component/formFieldImage/controller.tsx +126 -62
- package/zova/src/suite/cabloy-basic/modules/basic-image/src/model/image.ts +23 -0
- package/zova/src/suite/cabloy-basic/modules/basic-page/src/component/blockPage/controller.tsx +44 -4
- package/zova/src/suite/cabloy-basic/modules/basic-page/src/component/blockTable/controller.tsx +17 -12
- package/zova/src/suite/cabloy-basic/modules/basic-pageentry/src/component/blockPageEntry/controller.tsx +2 -2
- package/zova/src/suite/cabloy-basic/modules/basic-resource/src/component/formFieldResourcePicker/controller.tsx +2 -2
- package/zova/src/suite/cabloy-basic/modules/basic-table/src/component/table/controller.tsx +7 -2
- package/zova/src/suite/cabloy-basic/modules/basic-table/src/component/table/render.tsx +34 -33
- package/zova/src/suite/cabloy-basic/package.json +1 -0
- package/zova/src/suite-vendor/a-cabloy/modules/rest-resource/package.json +1 -1
- package/zova/src/suite-vendor/a-cabloy/modules/rest-resource/src/model/resource.ts +5 -3
- package/zova/src/suite-vendor/a-cabloy/modules/rest-resource/src/page/entry/controller.tsx +2 -2
- package/zova/src/suite-vendor/a-cabloy/modules/rest-resource/src/page/resource/controller.tsx +2 -2
- package/zova/src/suite-vendor/a-cabloy/package.json +2 -2
- package/zova/src/suite-vendor/a-zova/modules/a-model/package.json +1 -1
- package/zova/src/suite-vendor/a-zova/modules/a-model/src/lib/utils.ts +17 -17
- package/zova/src/suite-vendor/a-zova/modules/a-openapi/package.json +1 -1
- package/zova/src/suite-vendor/a-zova/modules/a-openapi/src/model/sdk.ts +8 -3
- package/zova/src/suite-vendor/a-zova/modules/a-zova/package.json +2 -2
- package/zova/src/suite-vendor/a-zova/package.json +4 -4
- package/vona/src/suite-vendor/a-vona/modules/a-permission/src/bean/summerCache.permission.ts +0 -17
- package/vona/src/suite-vendor/a-vona/modules/a-user/src/bean/guard.userName.ts +0 -35
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import type { IUploadFile } from 'vona-module-a-upload';
|
|
2
|
+
import type { IDecoratorControllerOptions } from 'vona-module-a-web';
|
|
3
|
+
|
|
4
|
+
import { BeanBase } from 'vona';
|
|
5
|
+
import { Core } from 'vona-module-a-core';
|
|
6
|
+
import { Api, v } from 'vona-module-a-openapiutils';
|
|
7
|
+
import { Passport } from 'vona-module-a-user';
|
|
8
|
+
import { Arg, Controller, Web } from 'vona-module-a-web';
|
|
9
|
+
|
|
10
|
+
import { DtoFileDirectUploadRequest } from '../dto/fileDirectUploadRequest.ts';
|
|
11
|
+
import { DtoFileDirectUploadResponse } from '../dto/fileDirectUploadResponse.ts';
|
|
12
|
+
import { DtoFileDownloadRequest } from '../dto/fileDownloadRequest.ts';
|
|
13
|
+
import { DtoFileUploadPolicyRequest } from '../dto/fileUploadPolicyRequest.ts';
|
|
14
|
+
import { DtoFileUploadPolicyResponse } from '../dto/fileUploadPolicyResponse.ts';
|
|
15
|
+
import { DtoFileUploadResponse } from '../dto/fileUploadResponse.ts';
|
|
16
|
+
import { DtoFileUploadTokenRequest } from '../dto/fileUploadTokenRequest.ts';
|
|
17
|
+
import { DtoFileUploadTokenResponse } from '../dto/fileUploadTokenResponse.ts';
|
|
18
|
+
import { DtoFileUploadUrlRequest } from '../dto/fileUploadUrlRequest.ts';
|
|
19
|
+
|
|
20
|
+
export interface IControllerOptionsFile extends IDecoratorControllerOptions {}
|
|
21
|
+
|
|
22
|
+
@Controller<IControllerOptionsFile>({ path: 'file' })
|
|
23
|
+
export class ControllerFile extends BeanBase {
|
|
24
|
+
@Web.post('upload-policy')
|
|
25
|
+
@Api.body(DtoFileUploadPolicyResponse)
|
|
26
|
+
async getUploadPolicy(@Arg.body() data: DtoFileUploadPolicyRequest) {
|
|
27
|
+
return await this.bean.fileUploadPolicy.resolveSceneUploadPolicy(data);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@Web.post('upload-token')
|
|
31
|
+
@Api.body(DtoFileUploadTokenResponse)
|
|
32
|
+
async createUploadToken(@Arg.body() data: DtoFileUploadTokenRequest) {
|
|
33
|
+
return await this.bean.fileUploadPolicy.createUploadToken(data);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@Web.post('upload')
|
|
37
|
+
@Core.fileUpload()
|
|
38
|
+
@Api.body(DtoFileUploadResponse)
|
|
39
|
+
@Api.contentType('application/json')
|
|
40
|
+
async upload(@Arg.field('token') token: string, @Arg.file('file') file: IUploadFile) {
|
|
41
|
+
const payload = await this.bean.fileUploadPolicy.verifyUploadToken(
|
|
42
|
+
token,
|
|
43
|
+
this.ctx.route.routePathRaw,
|
|
44
|
+
);
|
|
45
|
+
await this.bean.fileUploadPolicy.validateUploadFile(
|
|
46
|
+
{
|
|
47
|
+
file: file.file,
|
|
48
|
+
filename: file.info.filename,
|
|
49
|
+
mimeType: file.info.mimeType,
|
|
50
|
+
},
|
|
51
|
+
payload,
|
|
52
|
+
);
|
|
53
|
+
const uploadedFile = await this.bean.file.upload(
|
|
54
|
+
payload.providerName,
|
|
55
|
+
{
|
|
56
|
+
file: file.file,
|
|
57
|
+
filename: file.info.filename,
|
|
58
|
+
contentType: file.info.mimeType,
|
|
59
|
+
public: payload.public,
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
clientName: payload.clientName,
|
|
63
|
+
meta: payload.meta,
|
|
64
|
+
public: payload.public,
|
|
65
|
+
fileScene: payload.fileScene,
|
|
66
|
+
},
|
|
67
|
+
);
|
|
68
|
+
return {
|
|
69
|
+
...uploadedFile,
|
|
70
|
+
url: await this.bean.file.getDownloadUrl(uploadedFile.id),
|
|
71
|
+
signed: !uploadedFile.public,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
@Web.post('direct-upload')
|
|
76
|
+
@Api.body(DtoFileDirectUploadResponse)
|
|
77
|
+
async createDirectUpload(@Arg.body() data: DtoFileDirectUploadRequest) {
|
|
78
|
+
const policy = await this.bean.fileUploadPolicy.resolveUploadPolicy({
|
|
79
|
+
fileScene: data.fileScene,
|
|
80
|
+
size: data.size,
|
|
81
|
+
mimeType: data.mimeType,
|
|
82
|
+
});
|
|
83
|
+
return await this.bean.file.createDirectUpload(
|
|
84
|
+
policy.providerName,
|
|
85
|
+
{
|
|
86
|
+
filename: data.filename,
|
|
87
|
+
contentType: data.contentType,
|
|
88
|
+
size: data.size,
|
|
89
|
+
objectKey: data.objectKey,
|
|
90
|
+
public: policy.public,
|
|
91
|
+
expiry: data.expiry,
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
clientName: policy.clientName,
|
|
95
|
+
meta: policy.meta,
|
|
96
|
+
public: policy.public,
|
|
97
|
+
fileScene: policy.fileScene,
|
|
98
|
+
},
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
@Web.post('upload-url')
|
|
103
|
+
@Api.body(DtoFileUploadResponse)
|
|
104
|
+
async uploadUrl(@Arg.body() data: DtoFileUploadUrlRequest) {
|
|
105
|
+
const policy = await this.bean.fileUploadPolicy.resolveUploadPolicy({
|
|
106
|
+
fileScene: data.fileScene,
|
|
107
|
+
size: data.size,
|
|
108
|
+
mimeType: data.mimeType,
|
|
109
|
+
});
|
|
110
|
+
const uploadedFile = await this.bean.file.uploadUrl(
|
|
111
|
+
policy.providerName,
|
|
112
|
+
{
|
|
113
|
+
url: data.url,
|
|
114
|
+
filename: data.filename,
|
|
115
|
+
contentType: data.contentType,
|
|
116
|
+
size: data.size,
|
|
117
|
+
objectKey: data.objectKey,
|
|
118
|
+
public: policy.public,
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
clientName: policy.clientName,
|
|
122
|
+
meta: policy.meta,
|
|
123
|
+
public: policy.public,
|
|
124
|
+
fileScene: policy.fileScene,
|
|
125
|
+
},
|
|
126
|
+
);
|
|
127
|
+
return {
|
|
128
|
+
...uploadedFile,
|
|
129
|
+
url: await this.bean.file.getDownloadUrl(uploadedFile.id),
|
|
130
|
+
signed: !uploadedFile.public,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
@Web.get('download/:fileId')
|
|
135
|
+
@Passport.public()
|
|
136
|
+
async download(
|
|
137
|
+
@Arg.param('fileId', v.tableIdentity()) fileId: number,
|
|
138
|
+
@Arg.query(v.object(DtoFileDownloadRequest)) query: DtoFileDownloadRequest,
|
|
139
|
+
) {
|
|
140
|
+
const file = await this.bean.file.get(fileId);
|
|
141
|
+
if (!file) return this.app.throw(404);
|
|
142
|
+
if (!file.public) {
|
|
143
|
+
const payload = await this.bean.fileUploadPolicy.verifyDownloadToken(
|
|
144
|
+
query.token,
|
|
145
|
+
this.scope.util.combineApiPath(`file/download/${fileId}`, false, true),
|
|
146
|
+
);
|
|
147
|
+
if (String(payload.fileId) !== String(fileId)) {
|
|
148
|
+
return this.app.throw(401);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
const result = await this.bean.file.download(
|
|
152
|
+
fileId,
|
|
153
|
+
file.public
|
|
154
|
+
? undefined
|
|
155
|
+
: {
|
|
156
|
+
signed: false,
|
|
157
|
+
responseMode: 'buffer',
|
|
158
|
+
},
|
|
159
|
+
);
|
|
160
|
+
if (result.kind === 'url') {
|
|
161
|
+
if (!result.url) {
|
|
162
|
+
throw new Error(`file download url missing: ${fileId}`);
|
|
163
|
+
}
|
|
164
|
+
this.ctx.redirect(result.url);
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
if (result.contentType) {
|
|
168
|
+
this.ctx.type = result.contentType;
|
|
169
|
+
}
|
|
170
|
+
if (result.filename) {
|
|
171
|
+
this.ctx.attachment(result.filename);
|
|
172
|
+
}
|
|
173
|
+
this.ctx.body = result.buffer;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { IDecoratorDtoOptions } from 'vona-module-a-web';
|
|
2
|
+
|
|
3
|
+
import { Api, v } from 'vona-module-a-openapiutils';
|
|
4
|
+
import { Dto } from 'vona-module-a-web';
|
|
5
|
+
import z from 'zod';
|
|
6
|
+
|
|
7
|
+
import type { IFileSceneRecord } from '../types/fileScene.ts';
|
|
8
|
+
|
|
9
|
+
export interface IDtoOptionsFileDirectUploadRequest extends IDecoratorDtoOptions {}
|
|
10
|
+
|
|
11
|
+
@Dto<IDtoOptionsFileDirectUploadRequest>()
|
|
12
|
+
export class DtoFileDirectUploadRequest {
|
|
13
|
+
@Api.field(z.string())
|
|
14
|
+
fileScene: keyof IFileSceneRecord;
|
|
15
|
+
|
|
16
|
+
@Api.field(v.optional())
|
|
17
|
+
filename?: string;
|
|
18
|
+
|
|
19
|
+
@Api.field(z.number().int().positive())
|
|
20
|
+
size: number;
|
|
21
|
+
|
|
22
|
+
@Api.field(z.string())
|
|
23
|
+
mimeType: string;
|
|
24
|
+
|
|
25
|
+
@Api.field(v.optional())
|
|
26
|
+
contentType?: string;
|
|
27
|
+
|
|
28
|
+
@Api.field(v.optional())
|
|
29
|
+
objectKey?: string;
|
|
30
|
+
|
|
31
|
+
@Api.field(v.optional())
|
|
32
|
+
expiry?: string;
|
|
33
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { TableIdentity } from 'table-identity';
|
|
2
|
+
import type { IDecoratorDtoOptions } from 'vona-module-a-web';
|
|
3
|
+
|
|
4
|
+
import { Api, v } from 'vona-module-a-openapiutils';
|
|
5
|
+
import { Dto } from 'vona-module-a-web';
|
|
6
|
+
import z from 'zod';
|
|
7
|
+
|
|
8
|
+
import type { IFileProviderRecord } from '../types/fileProvider.ts';
|
|
9
|
+
import type { IFileSceneRecord } from '../types/fileScene.ts';
|
|
10
|
+
|
|
11
|
+
export interface IDtoOptionsFileDirectUploadResponse extends IDecoratorDtoOptions {}
|
|
12
|
+
|
|
13
|
+
@Dto<IDtoOptionsFileDirectUploadResponse>()
|
|
14
|
+
export class DtoFileDirectUploadResponse {
|
|
15
|
+
@Api.field(v.tableIdentity())
|
|
16
|
+
id: TableIdentity;
|
|
17
|
+
|
|
18
|
+
@Api.field(z.string())
|
|
19
|
+
provider: keyof IFileProviderRecord;
|
|
20
|
+
|
|
21
|
+
@Api.field()
|
|
22
|
+
clientName: string;
|
|
23
|
+
|
|
24
|
+
@Api.field()
|
|
25
|
+
resourceId: string;
|
|
26
|
+
|
|
27
|
+
@Api.field()
|
|
28
|
+
uploadUrl: string;
|
|
29
|
+
|
|
30
|
+
@Api.field(v.optional(), z.record(z.string(), z.string()))
|
|
31
|
+
headers?: Record<string, string>;
|
|
32
|
+
|
|
33
|
+
@Api.field(v.optional(), z.enum(['PUT', 'POST']))
|
|
34
|
+
method?: 'PUT' | 'POST';
|
|
35
|
+
|
|
36
|
+
@Api.field(v.optional())
|
|
37
|
+
filename?: string;
|
|
38
|
+
|
|
39
|
+
@Api.field(v.optional(), z.string())
|
|
40
|
+
fileScene?: keyof IFileSceneRecord;
|
|
41
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { IDecoratorDtoOptions } from 'vona-module-a-web';
|
|
2
|
+
|
|
3
|
+
import { Api, v } from 'vona-module-a-openapiutils';
|
|
4
|
+
import { Dto } from 'vona-module-a-web';
|
|
5
|
+
|
|
6
|
+
export interface IDtoOptionsFileDownloadRequest extends IDecoratorDtoOptions {}
|
|
7
|
+
|
|
8
|
+
@Dto<IDtoOptionsFileDownloadRequest>()
|
|
9
|
+
export class DtoFileDownloadRequest {
|
|
10
|
+
@Api.field(v.optional())
|
|
11
|
+
token?: string;
|
|
12
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { IDecoratorDtoOptions } from 'vona-module-a-web';
|
|
2
|
+
|
|
3
|
+
import { Api } from 'vona-module-a-openapiutils';
|
|
4
|
+
import { Dto } from 'vona-module-a-web';
|
|
5
|
+
import z from 'zod';
|
|
6
|
+
|
|
7
|
+
import type { IFileSceneRecord } from '../types/fileScene.ts';
|
|
8
|
+
|
|
9
|
+
export interface IDtoOptionsFileUploadPolicyRequest extends IDecoratorDtoOptions {}
|
|
10
|
+
|
|
11
|
+
@Dto<IDtoOptionsFileUploadPolicyRequest>()
|
|
12
|
+
export class DtoFileUploadPolicyRequest {
|
|
13
|
+
@Api.field(z.string())
|
|
14
|
+
fileScene: keyof IFileSceneRecord;
|
|
15
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { IDecoratorDtoOptions } from 'vona-module-a-web';
|
|
2
|
+
|
|
3
|
+
import { Api, v } from 'vona-module-a-openapiutils';
|
|
4
|
+
import { Dto } from 'vona-module-a-web';
|
|
5
|
+
import z from 'zod';
|
|
6
|
+
|
|
7
|
+
import type { IFileSceneRecord } from '../types/fileScene.ts';
|
|
8
|
+
|
|
9
|
+
export interface IDtoOptionsFileUploadPolicyResponse extends IDecoratorDtoOptions {}
|
|
10
|
+
|
|
11
|
+
@Dto<IDtoOptionsFileUploadPolicyResponse>()
|
|
12
|
+
export class DtoFileUploadPolicyResponse {
|
|
13
|
+
@Api.field(z.string())
|
|
14
|
+
fileScene: keyof IFileSceneRecord;
|
|
15
|
+
|
|
16
|
+
@Api.field(v.optional(), z.number().int().positive())
|
|
17
|
+
maxSize?: number;
|
|
18
|
+
|
|
19
|
+
@Api.field(v.optional(), z.array(z.string()))
|
|
20
|
+
mimeTypes?: string[];
|
|
21
|
+
|
|
22
|
+
@Api.field(v.optional(), z.array(z.string()))
|
|
23
|
+
extensions?: string[];
|
|
24
|
+
|
|
25
|
+
@Api.field(v.optional(), z.boolean())
|
|
26
|
+
multiple?: boolean;
|
|
27
|
+
|
|
28
|
+
@Api.field(v.optional(), z.boolean())
|
|
29
|
+
public?: boolean;
|
|
30
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { TableIdentity } from 'table-identity';
|
|
2
|
+
import type { IDecoratorDtoOptions } from 'vona-module-a-web';
|
|
3
|
+
|
|
4
|
+
import { Api, v } from 'vona-module-a-openapiutils';
|
|
5
|
+
import { Dto } from 'vona-module-a-web';
|
|
6
|
+
import z from 'zod';
|
|
7
|
+
|
|
8
|
+
import type { IFileProviderRecord } from '../types/fileProvider.ts';
|
|
9
|
+
import type { IFileSceneRecord } from '../types/fileScene.ts';
|
|
10
|
+
|
|
11
|
+
export interface IDtoOptionsFileUploadResponse extends IDecoratorDtoOptions {}
|
|
12
|
+
|
|
13
|
+
@Dto<IDtoOptionsFileUploadResponse>()
|
|
14
|
+
export class DtoFileUploadResponse {
|
|
15
|
+
@Api.field(v.tableIdentity())
|
|
16
|
+
id: TableIdentity;
|
|
17
|
+
|
|
18
|
+
@Api.field(z.string())
|
|
19
|
+
provider: keyof IFileProviderRecord;
|
|
20
|
+
|
|
21
|
+
@Api.field()
|
|
22
|
+
clientName: string;
|
|
23
|
+
|
|
24
|
+
@Api.field()
|
|
25
|
+
resourceId: string;
|
|
26
|
+
|
|
27
|
+
@Api.field(v.optional())
|
|
28
|
+
bucket?: string;
|
|
29
|
+
|
|
30
|
+
@Api.field(v.optional())
|
|
31
|
+
objectKey?: string;
|
|
32
|
+
|
|
33
|
+
@Api.field(v.optional())
|
|
34
|
+
filename?: string;
|
|
35
|
+
|
|
36
|
+
@Api.field(v.optional())
|
|
37
|
+
contentType?: string;
|
|
38
|
+
|
|
39
|
+
@Api.field(v.optional())
|
|
40
|
+
size?: number;
|
|
41
|
+
|
|
42
|
+
@Api.field(v.optional())
|
|
43
|
+
etag?: string;
|
|
44
|
+
|
|
45
|
+
@Api.field(v.optional())
|
|
46
|
+
public?: boolean;
|
|
47
|
+
|
|
48
|
+
@Api.field(v.optional(), z.string())
|
|
49
|
+
fileScene?: keyof IFileSceneRecord;
|
|
50
|
+
|
|
51
|
+
@Api.field(v.optional())
|
|
52
|
+
uploadedAt?: Date;
|
|
53
|
+
|
|
54
|
+
@Api.field(v.optional())
|
|
55
|
+
url?: string;
|
|
56
|
+
|
|
57
|
+
@Api.field(v.optional())
|
|
58
|
+
signed?: boolean;
|
|
59
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { IDecoratorDtoOptions } from 'vona-module-a-web';
|
|
2
|
+
|
|
3
|
+
import { Api, v } from 'vona-module-a-openapiutils';
|
|
4
|
+
import { Dto } from 'vona-module-a-web';
|
|
5
|
+
import z from 'zod';
|
|
6
|
+
|
|
7
|
+
import type { IFileSceneRecord } from '../types/fileScene.ts';
|
|
8
|
+
|
|
9
|
+
export interface IDtoOptionsFileUploadTokenRequest extends IDecoratorDtoOptions {}
|
|
10
|
+
|
|
11
|
+
@Dto<IDtoOptionsFileUploadTokenRequest>()
|
|
12
|
+
export class DtoFileUploadTokenRequest {
|
|
13
|
+
@Api.field(z.string())
|
|
14
|
+
fileScene: keyof IFileSceneRecord;
|
|
15
|
+
|
|
16
|
+
@Api.field(z.number().int().positive())
|
|
17
|
+
size: number;
|
|
18
|
+
|
|
19
|
+
@Api.field(z.string())
|
|
20
|
+
mimeType: string;
|
|
21
|
+
|
|
22
|
+
@Api.field(v.optional(), z.number().int().positive())
|
|
23
|
+
expiresIn?: number;
|
|
24
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { IDecoratorDtoOptions } from 'vona-module-a-web';
|
|
2
|
+
|
|
3
|
+
import { Api, v } from 'vona-module-a-openapiutils';
|
|
4
|
+
import { Dto } from 'vona-module-a-web';
|
|
5
|
+
import z from 'zod';
|
|
6
|
+
|
|
7
|
+
export interface IDtoOptionsFileUploadTokenResponse extends IDecoratorDtoOptions {}
|
|
8
|
+
|
|
9
|
+
@Dto<IDtoOptionsFileUploadTokenResponse>()
|
|
10
|
+
export class DtoFileUploadTokenResponse {
|
|
11
|
+
@Api.field(z.string())
|
|
12
|
+
token: string;
|
|
13
|
+
|
|
14
|
+
@Api.field(v.optional(), z.number().int().positive())
|
|
15
|
+
expiresIn?: number;
|
|
16
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { IDecoratorDtoOptions } from 'vona-module-a-web';
|
|
2
|
+
|
|
3
|
+
import { Api, v } from 'vona-module-a-openapiutils';
|
|
4
|
+
import { Dto } from 'vona-module-a-web';
|
|
5
|
+
import z from 'zod';
|
|
6
|
+
|
|
7
|
+
import type { IFileSceneRecord } from '../types/fileScene.ts';
|
|
8
|
+
|
|
9
|
+
export interface IDtoOptionsFileUploadUrlRequest extends IDecoratorDtoOptions {}
|
|
10
|
+
|
|
11
|
+
@Dto<IDtoOptionsFileUploadUrlRequest>()
|
|
12
|
+
export class DtoFileUploadUrlRequest {
|
|
13
|
+
@Api.field(z.string())
|
|
14
|
+
fileScene: keyof IFileSceneRecord;
|
|
15
|
+
|
|
16
|
+
@Api.field(z.string().url())
|
|
17
|
+
url: string;
|
|
18
|
+
|
|
19
|
+
@Api.field(z.number().int().positive())
|
|
20
|
+
size: number;
|
|
21
|
+
|
|
22
|
+
@Api.field(z.string())
|
|
23
|
+
mimeType: string;
|
|
24
|
+
|
|
25
|
+
@Api.field(v.optional())
|
|
26
|
+
filename?: string;
|
|
27
|
+
|
|
28
|
+
@Api.field(v.optional())
|
|
29
|
+
contentType?: string;
|
|
30
|
+
|
|
31
|
+
@Api.field(v.optional())
|
|
32
|
+
objectKey?: string;
|
|
33
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { IDecoratorEntityOptions } from 'vona-module-a-orm';
|
|
2
|
+
|
|
3
|
+
import { Api, v } from 'vona-module-a-openapiutils';
|
|
4
|
+
import { Entity, EntityBase } from 'vona-module-a-orm';
|
|
5
|
+
import z from 'zod';
|
|
6
|
+
|
|
7
|
+
import type { IFileProviderRecord } from '../types/fileProvider.ts';
|
|
8
|
+
import type { IFileSceneRecord } from '../types/fileScene.ts';
|
|
9
|
+
|
|
10
|
+
export interface IEntityOptionsFile extends IDecoratorEntityOptions {}
|
|
11
|
+
|
|
12
|
+
@Entity<IEntityOptionsFile>('aFile')
|
|
13
|
+
export class EntityFile extends EntityBase {
|
|
14
|
+
@Api.field(z.string())
|
|
15
|
+
providerName: keyof IFileProviderRecord;
|
|
16
|
+
|
|
17
|
+
@Api.field()
|
|
18
|
+
clientName: string;
|
|
19
|
+
|
|
20
|
+
@Api.field()
|
|
21
|
+
resourceId: string;
|
|
22
|
+
|
|
23
|
+
@Api.field(v.optional())
|
|
24
|
+
bucket?: string;
|
|
25
|
+
|
|
26
|
+
@Api.field(v.optional())
|
|
27
|
+
objectKey?: string;
|
|
28
|
+
|
|
29
|
+
@Api.field(v.optional())
|
|
30
|
+
filename?: string;
|
|
31
|
+
|
|
32
|
+
@Api.field(v.optional())
|
|
33
|
+
contentType?: string;
|
|
34
|
+
|
|
35
|
+
@Api.field(v.optional())
|
|
36
|
+
size?: number;
|
|
37
|
+
|
|
38
|
+
@Api.field(v.optional())
|
|
39
|
+
etag?: string;
|
|
40
|
+
|
|
41
|
+
@Api.field(v.optional())
|
|
42
|
+
public?: boolean;
|
|
43
|
+
|
|
44
|
+
@Api.field(v.optional())
|
|
45
|
+
meta?: Record<string, any>;
|
|
46
|
+
|
|
47
|
+
@Api.field(v.optional())
|
|
48
|
+
storagePath?: string;
|
|
49
|
+
|
|
50
|
+
@Api.field(v.optional())
|
|
51
|
+
deliveryBaseUrl?: string;
|
|
52
|
+
|
|
53
|
+
@Api.field(v.optional(), z.string())
|
|
54
|
+
fileScene?: keyof IFileSceneRecord;
|
|
55
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { IDecoratorEntityOptions } from 'vona-module-a-orm';
|
|
2
|
+
|
|
3
|
+
import { Api, v } from 'vona-module-a-openapiutils';
|
|
4
|
+
import { Entity, EntityBaseSimple } from 'vona-module-a-orm';
|
|
5
|
+
import z from 'zod';
|
|
6
|
+
|
|
7
|
+
import type { IFileProviderClientOptions, IFileProviderRecord } from '../types/fileProvider.ts';
|
|
8
|
+
|
|
9
|
+
export interface IEntityOptionsFileProvider extends IDecoratorEntityOptions {}
|
|
10
|
+
|
|
11
|
+
@Entity<IEntityOptionsFileProvider>('aFileProvider')
|
|
12
|
+
export class EntityFileProvider extends EntityBaseSimple {
|
|
13
|
+
@Api.field(v.default(false))
|
|
14
|
+
disabled: boolean;
|
|
15
|
+
|
|
16
|
+
@Api.field(z.string())
|
|
17
|
+
providerName: keyof IFileProviderRecord;
|
|
18
|
+
|
|
19
|
+
@Api.field()
|
|
20
|
+
clientName: string;
|
|
21
|
+
|
|
22
|
+
@Api.field(v.optional())
|
|
23
|
+
clientOptions?: IFileProviderClientOptions;
|
|
24
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createBeanDecorator } from 'vona';
|
|
2
|
+
|
|
3
|
+
import type { IDecoratorFileProviderOptions } from '../types/fileProvider.ts';
|
|
4
|
+
|
|
5
|
+
export function FileProvider<T extends IDecoratorFileProviderOptions>(options?: T): ClassDecorator {
|
|
6
|
+
return createBeanDecorator('fileProvider', options);
|
|
7
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
|
|
3
|
+
export function matchesFileMimeType(mimeType: string, mimeTypes: string[]) {
|
|
4
|
+
return mimeTypes.some(item => {
|
|
5
|
+
if (item === mimeType) return true;
|
|
6
|
+
if (item.endsWith('/*')) {
|
|
7
|
+
return mimeType.startsWith(`${item.slice(0, -1)}`);
|
|
8
|
+
}
|
|
9
|
+
return false;
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function getFileExtension(filename?: string) {
|
|
14
|
+
return path.extname(filename ?? '').toLowerCase();
|
|
15
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { IDecoratorModelOptions } from 'vona-module-a-orm';
|
|
2
|
+
|
|
3
|
+
import { BeanModelBase, Model } from 'vona-module-a-orm';
|
|
4
|
+
|
|
5
|
+
import { EntityFile } from '../entity/file.ts';
|
|
6
|
+
|
|
7
|
+
export interface IModelOptionsFile extends IDecoratorModelOptions<EntityFile> {}
|
|
8
|
+
|
|
9
|
+
@Model<IModelOptionsFile>({ entity: EntityFile, disableDeleted: true })
|
|
10
|
+
export class ModelFile extends BeanModelBase<EntityFile> {}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { IDecoratorModelOptions } from 'vona-module-a-orm';
|
|
2
|
+
|
|
3
|
+
import { BeanModelBase, Model } from 'vona-module-a-orm';
|
|
4
|
+
|
|
5
|
+
import { EntityFileProvider } from '../entity/fileProvider.ts';
|
|
6
|
+
|
|
7
|
+
export interface IModelOptionsFileProvider extends IDecoratorModelOptions<EntityFileProvider> {}
|
|
8
|
+
|
|
9
|
+
@Model<IModelOptionsFileProvider>({ entity: EntityFileProvider, disableDeleted: true })
|
|
10
|
+
export class ModelFileProvider extends BeanModelBase<EntityFileProvider> {}
|