feat: 更新静态出库模板与大包上传
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
*.jpeg binary
|
||||
*.gif binary
|
||||
*.webp binary
|
||||
*.zip binary
|
||||
*.ico binary
|
||||
*.woff binary
|
||||
*.woff2 binary
|
||||
|
||||
@@ -120,6 +120,19 @@ python scripts/remote.py # SSH 一键远程部署/升级
|
||||
|
||||
容器入口默认监听 `127.0.0.1:18080`,由外层面板(宝塔/1Panel)反代域名与 HTTPS;数据落在宿主机 `data/` 目录。
|
||||
|
||||
### 大批量出库导入
|
||||
|
||||
批量出库 ZIP 总体没有应用层固定体积上限,但实际容量受服务器磁盘、内存、网络带宽和处理时长约束。ZIP 内单个 xlsx 不超过 100MB;单张图片不超过 100MB,仅支持 JPG/JPEG/PNG/WebP,且不超过 4000 万像素。批量导入只登记出库,不会自动发起上链;需要在导入完成后按业务流程另行执行上链。
|
||||
|
||||
Docker 发布包生成的内层 Nginx 已取消请求体大小限制并设置 1 小时代理读写超时。无论采用 Docker 还是非 Docker 部署,外层宝塔/1Panel/Nginx 反向代理也必须取消请求体大小限制并延长超时,否则大 ZIP 仍会被外层拦截:
|
||||
|
||||
```nginx
|
||||
client_max_body_size 0;
|
||||
proxy_read_timeout 3600s;
|
||||
proxy_send_timeout 3600s;
|
||||
proxy_request_buffering off;
|
||||
```
|
||||
|
||||
## 命令速查
|
||||
|
||||
| 命令 | 说明 |
|
||||
|
||||
@@ -281,7 +281,7 @@
|
||||
- (已清理)`apps/api/src/geo/` 空目录已删除。
|
||||
|
||||
### packages/shared(前后端共用,tsc 构建 CJS,前端 Vite 用 alias 指向 src)
|
||||
- `enums.ts` 与 Prisma enum 字符串一致;`constants.ts`:队列名、`SHORT_CODE_LENGTH=12`、`TRACE_CODE_PATTERN=/^\d{12}$/`、上传大小/类型限制(出库 ZIP 30MB)、`OUTBOUND_IMPORT_COLUMNS`(出库时间必填,已无手工上链列);`error-codes.ts`:`ErrorCode`+中文兜底+`error.*` messageKey;`response.ts`:`ApiResponse`(含 `messageKey/params`)、`PageResult`、`JobProgress`。
|
||||
- `enums.ts` 与 Prisma enum 字符串一致;`constants.ts`:队列名、`SHORT_CODE_LENGTH=12`、`TRACE_CODE_PATTERN=/^\d{12}$/`、常规媒体上传大小/类型限制、`OUTBOUND_IMPORT_COLUMNS`(出库时间必填,已无手工上链列);批量出库 ZIP 不设总上传体积常量,其内容边界由 API 的 `outbound-import.util.ts` 维护。`error-codes.ts`:`ErrorCode`+中文兜底+`error.*` messageKey;`response.ts`:`ApiResponse`(含 `messageKey/params`)、`PageResult`、`JobProgress`。
|
||||
|
||||
### apps/api(NestJS,全局前缀 `/api`,`/t/:shortCode` 例外)
|
||||
- 入口 `main.ts`:按 `isInstallMode()` 选择 `AppModule` 或 `InstallAppModule`;正式态挂载静态 `/uploads`(immutable 强缓存) + SPA `/admin` `/trace`,安装态只挂 `/admin`(admin 路由守卫探测未安装自动进向导)并把 `/` 重定向到 `/admin`;BigInt.toJSON 补丁;Swagger 在 `/api/docs`。
|
||||
@@ -356,13 +356,13 @@
|
||||
|
||||
## 2026-07-13 · 批量出库导入上线加固
|
||||
|
||||
- 导入契约统一为:ZIP 根目录一个 xlsx + `images/`,出库时间必填并按中国标准时间(UTC+8)严格解析;拒绝无效日历日期、缺必填表头、空表、非 12 位追溯码、超长批次/备注、伪装图片和多帧图片。
|
||||
- `outbound-import.util.ts` 集中维护资源边界:最多 10000 行、64 列、20002 个 ZIP 条目、120MB 解压总量、10MB xlsx、50MB xlsx 内部解压量、单图 10MB/4000 万像素、每行 20 图;先读 ZIP 中央目录数量,再交给 AdmZip/ExcelJS,降低压缩炸弹风险。
|
||||
- 导入契约统一为:ZIP 根目录必须且只能有一个 xlsx;存在出库图时放入 `images/`。出库时间必填并按中国标准时间(UTC+8)严格解析;拒绝无效日历日期、缺必填表头、空表、非 12 位追溯码、超长批次/备注、伪装图片和多帧图片。
|
||||
- `outbound-import.util.ts` 集中维护资源边界:批次 ZIP 总量和图片累计字节不设固定上限;最多 10000 行、64 列、20002 个 ZIP 条目、单个 xlsx 100MB(内部实际解压 500MB)、单图 100MB/4000 万像素、每行 20 图、全批次 20000 个图片引用。解析前倒序定位真实 EOCD/ZIP64 记录并校验条目数,xlsx 和图片均按实际解压字节流计数,不能用伪造中央目录大小绕过限制。
|
||||
- 预览阶段把追溯码由逐行查询改为每 1000 个批量查询,导入行每 500 条 `createMany`;同一 ZIP 图片被多行引用时为每行保存独立对象,任一行校验或保存失败会回收该行已创建的临时文件。
|
||||
- 会话提交使用事务内 `READY -> IMPORTING` 条件更新并同时创建 DB Job,BullMQ 使用同一 jobId;同一会话并发提交只允许一个成功。单件登记和正式导入最终均以 `TraceCode.outTime IS NULL` 条件更新,跨会话、单件/批量并发也不会覆盖首次出库数据。
|
||||
- 正式导入把追溯码更新与导入行 `IMPORTED` 状态放在同一事务,提交前再次核对批次;Worker 顶层异常会把剩余行、会话和 DB Job 收口为可诊断终态。结果 xlsx 增加原图片路径和备注,部分失败会回写真实成功/失败统计。
|
||||
- 过期清理由条件更新原子认领 `EXPIRED`,多实例不会与提交竞争;部分成功会话清理时跳过 `IMPORTED` 行图片,成功导入 ZIP 删除失败则由定时任务重试。媒体归位文件名增加毫秒和随机后缀,避免并发重名。
|
||||
- 管理端上传前校验 ZIP/空文件/30MB,上传接口超时单独放宽到 120 秒;轮询准确区分 SUCCESS/PARTIAL/FAILED,最长等待 15 分钟且超时不误报完成。会话/job/阶段按用户保存到 localStorage,刷新可恢复进度和结果,组件卸载会停止旧轮询。
|
||||
- 管理端上传前校验 ZIP/空文件,不再校验批次总体积;上传请求不设 Axios 总超时。轮询准确区分 SUCCESS/PARTIAL/FAILED,最长等待 15 分钟且超时不误报完成。会话/job/阶段按用户保存到 localStorage,刷新可恢复进度和结果,组件卸载会停止旧轮询。
|
||||
- 清理 Prisma 中 `OutboundImportRow.txHash/onchainAt/blockHeight` 三个无引用旧字段;链上结果仍只存正式 `BlockchainProof`,旧备份恢复会忽略这些历史导入字段。批量导入仍不自动触发不可逆上链,需在出库成功后独立操作。
|
||||
- 验证基线已扩展:Prisma generate/validate 通过;真实隔离 MySQL 验证同会话并发提交、跨会话同码竞争、UTC 落库、requestId 并发幂等与两段迁移 schema 一致;真实 LocalStorage 验证同图跨两行生成独立业务文件。最终测试数量见下方 2026-07-14 记录。
|
||||
|
||||
@@ -377,3 +377,14 @@
|
||||
- 管理端:恢复/轮询错误支持 silent 请求,英文 worker 错误补齐;`MainLayout` 在 `<1120px` 取消桌面最小宽度,390×844 实测按钮均在可视区、表格内部横向滚动,控制台无错误。桌面 1440×900 无水平溢出。
|
||||
- 发布:Docker entrypoint、非 Docker install/upgrade 脚本均在启动前执行 `prisma migrate deploy`。迁移压缩只适用于全新安装或已使用 `20260713090000_init` 的环境;执行过压缩前旧迁移的数据库必须另做 baseline。
|
||||
- 最终验证:API 全量 `20` 个测试套件、`132` 个测试全部通过,monorepo 全量构建、Prisma validate、脚本语法检查与 `git diff --check` 通过;临时 MySQL 8 执行两段迁移后与 Prisma schema 无差异,历史 Job 回填及终态计数归一化符合预期,临时数据库已删除。
|
||||
|
||||
## 2026-07-14 · 静态出库模板与大批量上传
|
||||
|
||||
- 出库导入模板改为版本化静态资产 `apps/api/src/assets/templates/outbound-import-template.zip`,下载接口原样返回;Nest assets 会复制到 `dist/assets/templates`,Docker 与非 Docker 发布包都随 API dist 携带。维护约定见同目录 `README.md`,可直接解压修改 Excel 文案、样式和示例图片后替换 ZIP。
|
||||
- 静态模板按真实解析契约重做:第一张“导入模板”仅保留带样式表头,避免示例行误导正式导入;“填写示例”和“字段说明”独立成表,包内含 `说明.txt` 和 3 张有效示例图。自动化测试会解包核对文件清单、工作表顺序、共享表头、样式、100MB 文案、示例图片真实格式及“不自动上链”说明。
|
||||
- 批量 ZIP 总上传体积、外层 ZIP 解压总量和图片累计存储字节不设固定业务上限;单个 xlsx 与单张图片均为 100MB,xlsx 内部实际解压上限 500MB,图片校验扩展名、真实 JPG/JPEG/PNG/WebP 格式、4000 万像素及多帧。数量边界仍为 10000 行、64 列、20002 个 ZIP 条目、每行 20 图、全批次 20000 个图片引用。
|
||||
- 上传由 Multer 临时磁盘接收,服务层按文件流写入私有存储;Worker 把原始 ZIP 下载到应用专属临时目录,以 `unzipper` entry 流按实际字节限流并逐图读取,不再把整包或全部图片放入内存。单个 xlsx 和正在处理的单图仍分别以不超过 100MB 的 Buffer 交给 ExcelJS/sharp。合法长 ZIP 注释和 ZIP64 可解析,伪造中央目录大小会在输出超过限制时立即中止。
|
||||
- OSS 原始 ZIP 使用 `@aws-sdk/lib-storage` multipart 上传,突破单次 PutObject 约 5GiB 限制;正式导入图片通过本地 `copyFile` 或 OSS `CopyObject` 直接复制,不再 `get Buffer -> put`,批量存储操作超时为 1 小时。新增直接依赖为 `@aws-sdk/lib-storage@3.1075.0`、`unzipper@0.10.14`、`multer@2.2.0`;根 `pnpm.overrides` 强制 Nest 内部 Multer 同为 2.2.0,生产审计不再报告 Multer 上传 DoS 漏洞。
|
||||
- Axios 上传不设总超时,Node 接收请求上限为 1 小时。Docker 内层 Nginx 使用 `client_max_body_size 0`、3600 秒代理读写超时和 `proxy_request_buffering off`;外层宝塔/1Panel/Nginx 必须同步。Docker 将应用临时目录挂载到 `data/tmp`,启动时清理崩溃遗留;正常请求与 Worker 均在 `finally` 清理,预览进入终态后立即删除原始 ZIP 并清空 `fileKey`,小时任务重试失败清理。
|
||||
- 预览 Job 每分钟心跳,PROCESSING 失联恢复窗口为 2 小时,避免大包处理时被重复投递。批量导入只登记出库时间、出库实况图和备注,不会触发区块链;天河链上链仍按追溯码另行执行。所谓“无总大小限制”是无固定业务字节上限,实际仍受 1 小时接收窗口、磁盘、内存、网络和对象存储能力约束。
|
||||
- 验证:真实构造 `32,470,414` 字节 ZIP(内含 `32,454,749` 字节 PNG、1080 万像素)经 multipart 接口返回 HTTP 201,预览 Job `SUCCESS`、会话 `READY`、1 行有效,原始 ZIP 已立即释放且 Multer/Worker 临时残留为 0;验收会话、Job、操作日志、Redis Job、图片和本机文件均已删除,测试追溯码保持未出库。API 全量 `20` 个测试套件、`154` 个测试通过;全工作区构建、冻结锁文件安装、Prisma validate、5 个 Python 脚本语法、Docker Compose/Nginx 生成配置、模板源/构建产物哈希及 `git diff --check` 均通过。
|
||||
|
||||
@@ -104,7 +104,7 @@ export const traceCodeApi = {
|
||||
export const outboundApi = {
|
||||
updateSingle: (id: string, data: object) => put(`/outbound/trace-codes/${id}`, data),
|
||||
templateUrl: '/api/outbound/import/template',
|
||||
preview: (data: FormData) => post('/outbound/import/preview', data, { timeout: 120000 }),
|
||||
preview: (data: FormData) => post('/outbound/import/preview', data, { timeout: 0 }),
|
||||
requestSession: (requestId: string, silent = false) =>
|
||||
get(`/outbound/import-requests/${requestId}`, undefined, { silentError: silent }),
|
||||
session: (id: string, silent = false) =>
|
||||
|
||||
@@ -449,7 +449,7 @@
|
||||
"successCount": "Success",
|
||||
"failCount": "Failed",
|
||||
"downloadResult": "Download Details",
|
||||
"tip": "Download the template ZIP, fill it in, and upload. On-chain results are recorded automatically from the blockchain API response.",
|
||||
"tip": "Download and complete the template package, then upload it. Batch import records outbound data only; trigger on-chain processing separately when needed.",
|
||||
"downloadZipTemplate": "Download Template ZIP",
|
||||
"uploadZipPreview": "Upload & Preview",
|
||||
"totalRows": "Rows",
|
||||
@@ -463,7 +463,6 @@
|
||||
"previewFailed": "Preview parsing failed. Check the error details.",
|
||||
"emptyZipFile": "Select a non-empty ZIP file",
|
||||
"zipFileOnly": "Only ZIP files are supported",
|
||||
"zipFileTooLarge": "The ZIP file must not exceed {size}MB",
|
||||
"backgroundProcessing": "Waiting timed out. The task is still running in the background; refresh this page later to continue.",
|
||||
"progressUnavailable": "Task progress is temporarily unavailable. Processing may still be running; refresh this page later.",
|
||||
"activeTaskPending": "The current import task has not finished. A new file cannot be uploaded yet.",
|
||||
@@ -490,8 +489,7 @@
|
||||
"noPendingRows": "The import session has no rows awaiting processing",
|
||||
"xlsxCount": "The ZIP must contain exactly one xlsx file",
|
||||
"xlsxRoot": "The xlsx file must be in the root of the ZIP",
|
||||
"xlsxTooLarge": "The xlsx file exceeds the 10MB limit",
|
||||
"zipExpandedTooLarge": "The expanded ZIP exceeds the allowed size",
|
||||
"xlsxTooLarge": "The xlsx file exceeds the 100MB limit",
|
||||
"worksheetMissing": "The xlsx file does not contain a worksheet",
|
||||
"noRows": "The xlsx file does not contain any importable rows",
|
||||
"previewExpired": "The import preview expired or its status changed",
|
||||
@@ -499,7 +497,7 @@
|
||||
"batchNoMismatch": "Batch number does not match; the actual value is {value}",
|
||||
"tooManyImages": "Each row can contain at most {count} outbound images",
|
||||
"duplicateZipImage": "The ZIP contains a duplicate image path: {path}",
|
||||
"imageTooLarge": "Image exceeds the 10MB limit: {path}",
|
||||
"imageTooLarge": "Image exceeds the 100MB limit: {path}",
|
||||
"tooManyRows": "The import exceeds the {count}-row limit",
|
||||
"tooManyColumns": "The xlsx file exceeds the {count}-column limit",
|
||||
"duplicateHeader": "The xlsx file contains a duplicate header: {value}",
|
||||
@@ -523,7 +521,6 @@
|
||||
"zipEntryLimit": "The ZIP contains more than {count} entries",
|
||||
"xlsxEntryLimit": "The xlsx file contains more than {count} entries",
|
||||
"imageReferenceLimit": "The import contains more than {count} image references",
|
||||
"storedImageSizeLimit": "Referenced images exceed the {count}MB stored-output limit",
|
||||
"incompleteRows": "Import row states are incomplete: {success} succeeded, {fail} failed, {remaining} pending, {total} total",
|
||||
"previewSessionMissing": "The import preview session no longer exists",
|
||||
"previewJobMismatch": "The preview task does not match this import session",
|
||||
|
||||
@@ -449,7 +449,7 @@
|
||||
"successCount": "成功",
|
||||
"failCount": "失败",
|
||||
"downloadResult": "下载结果明细",
|
||||
"tip": "下载模板 ZIP 后按说明填写并上传;链上结果由区块链接口返回后自动记录。",
|
||||
"tip": "下载模板包后按说明填写并上传;批量导入仅登记出库,完成后可按需另行触发上链。",
|
||||
"downloadZipTemplate": "下载模板包",
|
||||
"uploadZipPreview": "上传并预览",
|
||||
"totalRows": "总行数",
|
||||
@@ -463,7 +463,6 @@
|
||||
"previewFailed": "预览解析失败,请查看错误原因",
|
||||
"emptyZipFile": "请选择非空的 ZIP 文件",
|
||||
"zipFileOnly": "仅支持 ZIP 文件",
|
||||
"zipFileTooLarge": "ZIP 文件不能超过 {size}MB",
|
||||
"backgroundProcessing": "等待已超时,任务仍在后台处理,稍后刷新页面可继续查看",
|
||||
"progressUnavailable": "暂时无法获取任务进度,任务可能仍在后台处理,请稍后刷新查看",
|
||||
"activeTaskPending": "当前导入任务尚未结束,不能上传新的文件",
|
||||
@@ -490,8 +489,7 @@
|
||||
"noPendingRows": "导入会话中没有待处理数据",
|
||||
"xlsxCount": "ZIP 中必须且只能包含一个 xlsx 文件",
|
||||
"xlsxRoot": "xlsx 文件必须位于 ZIP 根目录",
|
||||
"xlsxTooLarge": "xlsx 文件超过 10MB",
|
||||
"zipExpandedTooLarge": "ZIP 解压后总大小超过限制",
|
||||
"xlsxTooLarge": "xlsx 文件超过 100MB",
|
||||
"worksheetMissing": "xlsx 中缺少工作表",
|
||||
"noRows": "xlsx 中没有可导入的数据",
|
||||
"previewExpired": "导入预览会话已过期或状态已变化",
|
||||
@@ -499,7 +497,7 @@
|
||||
"batchNoMismatch": "批次编号不匹配,实际为 {value}",
|
||||
"tooManyImages": "每行最多填写 {count} 张出库图",
|
||||
"duplicateZipImage": "ZIP 中存在重复图片路径:{path}",
|
||||
"imageTooLarge": "图片超过 10MB:{path}",
|
||||
"imageTooLarge": "图片超过 100MB:{path}",
|
||||
"tooManyRows": "导入数据超过 {count} 行限制",
|
||||
"tooManyColumns": "xlsx 列数超过 {count} 列限制",
|
||||
"duplicateHeader": "xlsx 表头重复:{value}",
|
||||
@@ -523,7 +521,6 @@
|
||||
"zipEntryLimit": "ZIP 文件数量超过限制(最多 {count} 个)",
|
||||
"xlsxEntryLimit": "xlsx 文件数量超过限制(最多 {count} 个)",
|
||||
"imageReferenceLimit": "出库图片引用总数超过限制(最多 {count} 张)",
|
||||
"storedImageSizeLimit": "出库图片按引用累计大小超过限制(最多 {count}MB)",
|
||||
"incompleteRows": "导入行状态不完整:成功 {success},失败 {fail},待处理 {remaining},总数 {total}",
|
||||
"previewSessionMissing": "导入预览会话不存在",
|
||||
"previewJobMismatch": "导入预览任务与会话不匹配",
|
||||
|
||||
@@ -84,7 +84,6 @@ import { useI18n } from 'vue-i18n';
|
||||
import type { UploadCustomRequestOptions } from 'naive-ui';
|
||||
import { NButton, NIcon, NImage, NTag, NText, type DataTableColumns } from 'naive-ui';
|
||||
import { CloudUploadOutline, DownloadOutline } from '@vicons/ionicons5';
|
||||
import { MAX_OUTBOUND_IMPORT_SIZE } from '@artveris/shared';
|
||||
import { jobApi, outboundApi } from '@/api';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import { message } from '@/utils/feedback';
|
||||
@@ -694,10 +693,6 @@ function validateUploadFile(file: File | null | undefined): file is File {
|
||||
message.error(t('pages.outbound.zipFileOnly'));
|
||||
return false;
|
||||
}
|
||||
if (file.size > MAX_OUTBOUND_IMPORT_SIZE) {
|
||||
message.error(t('pages.outbound.zipFileTooLarge', { size: MAX_OUTBOUND_IMPORT_SIZE / 1024 / 1024 }));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1010,8 +1005,7 @@ const BACKEND_ERROR_KEY_BY_MESSAGE: Record<string, string> = {
|
||||
'导入会话中没有待处理数据': 'noPendingRows',
|
||||
'ZIP 中必须且只能包含一个 xlsx 文件': 'xlsxCount',
|
||||
'xlsx 文件必须位于 ZIP 根目录': 'xlsxRoot',
|
||||
'xlsx 文件超过 10MB': 'xlsxTooLarge',
|
||||
'ZIP 解压后总大小超过限制': 'zipExpandedTooLarge',
|
||||
'xlsx 文件超过 100MB': 'xlsxTooLarge',
|
||||
'xlsx 解压后总大小超过限制': 'xlsxExpandedTooLarge',
|
||||
'ZIP 文件结构无效': 'zipInvalidStructure',
|
||||
'xlsx 文件结构无效': 'xlsxInvalidStructure',
|
||||
@@ -1047,12 +1041,11 @@ function localizeBackendError(value?: unknown) {
|
||||
[/^批次编号不匹配,实际为 (.+)$/, 'batchNoMismatch', 'value'],
|
||||
[/^每行最多填写 (\d+) 张出库图$/, 'tooManyImages', 'count'],
|
||||
[/^ZIP 中存在重复图片路径:(.+)$/, 'duplicateZipImage', 'path'],
|
||||
[/^图片超过 10MB:(.+)$/, 'imageTooLarge', 'path'],
|
||||
[/^图片超过 100MB:(.+)$/, 'imageTooLarge', 'path'],
|
||||
[/^导入数据超过 (\d+) 行限制$/, 'tooManyRows', 'count'],
|
||||
[/^ZIP 文件数量超过限制(最多 (\d+) 个)$/, 'zipEntryLimit', 'count'],
|
||||
[/^xlsx 文件数量超过限制(最多 (\d+) 个)$/, 'xlsxEntryLimit', 'count'],
|
||||
[/^出库图片引用总数超过限制(最多 (\d+) 张)$/, 'imageReferenceLimit', 'count'],
|
||||
[/^出库图片按引用累计大小超过限制(最多 (\d+)MB)$/, 'storedImageSizeLimit', 'count'],
|
||||
[/^xlsx 列数超过 (\d+) 列限制$/, 'tooManyColumns', 'count'],
|
||||
[/^xlsx 表头重复:(.+)$/, 'duplicateHeader', 'value'],
|
||||
[/^xlsx 包含未知表头:(.+)$/, 'unknownHeaders', 'value'],
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
"collection": "@nestjs/schematics",
|
||||
"sourceRoot": "src",
|
||||
"compilerOptions": {
|
||||
"deleteOutDir": true
|
||||
"deleteOutDir": true,
|
||||
"assets": [
|
||||
{
|
||||
"include": "assets/templates/*.zip",
|
||||
"watchAssets": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
"dependencies": {
|
||||
"@artveris/shared": "workspace:*",
|
||||
"@aws-sdk/client-s3": "^3.700.0",
|
||||
"@aws-sdk/lib-storage": "^3.1075.0",
|
||||
"@aws-sdk/s3-request-presigner": "^3.700.0",
|
||||
"@nestjs/bullmq": "^10.2.3",
|
||||
"@nestjs/common": "^10.4.15",
|
||||
@@ -42,12 +43,14 @@
|
||||
"dayjs": "^1.11.13",
|
||||
"exceljs": "^4.4.0",
|
||||
"ioredis": "^5.4.2",
|
||||
"multer": "2.2.0",
|
||||
"nanoid": "^3.3.8",
|
||||
"prisma": "^5.22.0",
|
||||
"qrcode": "^1.5.4",
|
||||
"reflect-metadata": "^0.2.2",
|
||||
"rxjs": "^7.8.1",
|
||||
"sharp": "^0.33.5"
|
||||
"sharp": "^0.33.5",
|
||||
"unzipper": "0.10.14"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nestjs/cli": "^10.4.9",
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
# 出库批量导入模板维护
|
||||
|
||||
`outbound-import-template.zip` 是后台“下载模板包”接口直接返回的静态文件。需要调整 Excel 文案、样式或示例图片时,解压修改后重新压缩并替换该文件即可,不需要修改接口代码。
|
||||
|
||||
模板必须与批量导入解析契约保持一致:
|
||||
|
||||
- ZIP 根目录必须且只能包含一个 `.xlsx` 文件;存在出库图时,图片放在 `images/` 目录。
|
||||
- xlsx 第一张工作表是实际导入表,表头必须使用共享常量 `OUTBOUND_IMPORT_COLUMNS` 定义的列名。
|
||||
- 实际导入表不要预置示例数据;示例可放在后续工作表。
|
||||
- 单个 xlsx、单张图片均不得超过 100MB;图片仅支持 JPG、JPEG、PNG、WebP,且不得超过 4000 万像素,不支持多帧图片。
|
||||
- 更新后运行 `pnpm --filter @artveris/api exec jest --runInBand src/outbound/outbound.service.spec.ts`,测试会校验 ZIP 结构、表头、说明和示例图片。
|
||||
Binary file not shown.
@@ -116,7 +116,9 @@ async function bootstrap(): Promise<void> {
|
||||
SwaggerModule.setup('api/docs', app, document);
|
||||
|
||||
const port = config.get<number>('port') || 3000;
|
||||
await app.listen(port);
|
||||
const server = await app.listen(port);
|
||||
// 大包不设体积上限,但所有请求仍需在一小时内完成接收,避免慢连接无限占用。
|
||||
server.requestTimeout = 60 * 60 * 1000;
|
||||
logger.log(`${installing ? 'Install server' : 'API'} started: http://localhost:${port}/api`);
|
||||
logger.log(`Swagger: http://localhost:${port}/api/docs`);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import AdmZip from 'adm-zip';
|
||||
import * as ExcelJS from 'exceljs';
|
||||
import { writeFile } from 'fs/promises';
|
||||
import sharp from 'sharp';
|
||||
import { JobStatus, OUTBOUND_IMPORT_COLUMNS } from '@artveris/shared';
|
||||
import { ImportPreviewProcessor } from './import-preview.processor';
|
||||
@@ -12,6 +13,7 @@ interface ZipOptions {
|
||||
rows?: SheetCell[][];
|
||||
images?: Record<string, Buffer>;
|
||||
sparseRow?: number;
|
||||
comment?: string;
|
||||
}
|
||||
|
||||
async function buildZip(options: ZipOptions = {}): Promise<Buffer> {
|
||||
@@ -24,6 +26,7 @@ async function buildZip(options: ZipOptions = {}): Promise<Buffer> {
|
||||
const zip = new AdmZip();
|
||||
zip.addFile('outbound.xlsx', Buffer.from(await workbook.xlsx.writeBuffer()));
|
||||
for (const [path, data] of Object.entries(options.images ?? {})) zip.addFile(path, data);
|
||||
if (options.comment) zip.addZipComment(options.comment);
|
||||
return zip.toBuffer();
|
||||
}
|
||||
|
||||
@@ -35,6 +38,12 @@ async function png(): Promise<Buffer> {
|
||||
return sharp({ create: { width: 8, height: 8, channels: 4, background: '#ffffff' } }).png().toBuffer();
|
||||
}
|
||||
|
||||
async function oversizedPng(): Promise<Buffer> {
|
||||
return sharp({ create: { width: 6325, height: 6325, channels: 3, background: '#000000' } })
|
||||
.png({ compressionLevel: 9, palette: true })
|
||||
.toBuffer();
|
||||
}
|
||||
|
||||
function traceCode(shortCode: string, batchNo = 'B1') {
|
||||
return { id: BigInt(shortCode), shortCode, outTime: null, outImages: null, batch: { batchNo } };
|
||||
}
|
||||
@@ -74,7 +83,9 @@ function createHarness(zipBuffer: Buffer, codes: any[] = []) {
|
||||
),
|
||||
};
|
||||
const storage = {
|
||||
read: jest.fn().mockResolvedValue(zipBuffer),
|
||||
downloadToFile: jest.fn().mockImplementation(async (_key: string, filePath: string) => {
|
||||
await writeFile(filePath, zipBuffer);
|
||||
}),
|
||||
save: jest.fn().mockImplementation(async (_data: Buffer, name: string) => {
|
||||
savedSequence += 1;
|
||||
return { key: `temp/${savedSequence}-${name}`, url: `/uploads/${savedSequence}-${name}`, name };
|
||||
@@ -83,6 +94,7 @@ function createHarness(zipBuffer: Buffer, codes: any[] = []) {
|
||||
};
|
||||
const jobs = {
|
||||
start: jest.fn().mockResolvedValue(undefined),
|
||||
progress: jest.fn().mockResolvedValue({ count: 1 }),
|
||||
finish: jest.fn().mockResolvedValue(undefined),
|
||||
};
|
||||
const processor = new ImportPreviewProcessor(prisma as any, storage as any, jobs as any);
|
||||
@@ -96,6 +108,18 @@ async function process(processor: ImportPreviewProcessor): Promise<void> {
|
||||
}
|
||||
|
||||
describe('ImportPreviewProcessor', () => {
|
||||
it('accepts a valid ZIP with a long archive comment', async () => {
|
||||
const zip = await buildZip({
|
||||
rows: [['111111111111', 'B1', '2026-07-04 10:00', '', '']],
|
||||
comment: 'x'.repeat(100),
|
||||
});
|
||||
const harness = createHarness(zip, [traceCode('111111111111')]);
|
||||
|
||||
await process(harness.processor);
|
||||
|
||||
expect(harness.persistedRows[0]).toMatchObject({ status: 'VALID' });
|
||||
});
|
||||
|
||||
it('interprets an Excel date cell as a Shanghai wall-clock value', async () => {
|
||||
const zip = await buildZip({
|
||||
rows: [['111111111111', 'B1', new Date('2026-07-04T10:00:00.000Z'), '', '']],
|
||||
@@ -187,7 +211,7 @@ describe('ImportPreviewProcessor', () => {
|
||||
await process(harness.processor);
|
||||
|
||||
expect(harness.storage.save).not.toHaveBeenCalled();
|
||||
expect(harness.storage.remove).not.toHaveBeenCalled();
|
||||
expect(harness.storage.remove).toHaveBeenCalledWith('zip-key');
|
||||
expect(harness.persistedRows[0]).toMatchObject({
|
||||
status: 'INVALID',
|
||||
reason: '图片不存在:images/missing.jpg',
|
||||
@@ -216,6 +240,33 @@ describe('ImportPreviewProcessor', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('cleans a saved image when the preview heartbeat loses ownership after the storage write', async () => {
|
||||
const zip = await buildZip({
|
||||
rows: [['111111111111', 'B1', '2026-07-04 10:00', 'images/front.jpg', '']],
|
||||
images: { 'images/front.jpg': await jpeg() },
|
||||
});
|
||||
const harness = createHarness(zip, [traceCode('111111111111')]);
|
||||
let now = 0;
|
||||
const clock = jest.spyOn(Date, 'now').mockImplementation(() => now);
|
||||
harness.storage.save.mockImplementationOnce(async () => {
|
||||
now = 61_000;
|
||||
return { key: 'temp/saved-before-heartbeat.jpg', url: '/uploads/saved.jpg', name: 'front.jpg' };
|
||||
});
|
||||
harness.jobs.progress.mockResolvedValueOnce({ count: 1 }).mockResolvedValueOnce({ count: 0 });
|
||||
try {
|
||||
await process(harness.processor);
|
||||
} finally {
|
||||
clock.mockRestore();
|
||||
}
|
||||
|
||||
expect(harness.storage.remove).toHaveBeenCalledWith('temp/saved-before-heartbeat.jpg');
|
||||
expect(harness.persistedRows[0]).toMatchObject({
|
||||
status: 'INVALID',
|
||||
reason: '导入预览任务状态已变化',
|
||||
outImageKeys: null,
|
||||
});
|
||||
});
|
||||
|
||||
it('does not replace rows when a stalled preview worker loses the session claim', async () => {
|
||||
const zip = await buildZip({
|
||||
rows: [['111111111111', 'B1', '2026-07-04 10:00', 'images/front.jpg', '']],
|
||||
@@ -249,7 +300,7 @@ describe('ImportPreviewProcessor', () => {
|
||||
|
||||
await process(harness.processor);
|
||||
|
||||
expect(harness.storage.read).not.toHaveBeenCalled();
|
||||
expect(harness.storage.downloadToFile).not.toHaveBeenCalled();
|
||||
expect(harness.jobs.start).not.toHaveBeenCalled();
|
||||
expect(harness.jobs.finish).toHaveBeenCalledWith('job-1', {
|
||||
status: JobStatus.SUCCESS,
|
||||
@@ -257,6 +308,7 @@ describe('ImportPreviewProcessor', () => {
|
||||
failCount: 0,
|
||||
error: null,
|
||||
});
|
||||
expect(harness.storage.remove).toHaveBeenCalledWith('zip-key');
|
||||
});
|
||||
|
||||
it('keeps images referenced by rows when the preview transaction result is unknown', async () => {
|
||||
@@ -302,6 +354,22 @@ describe('ImportPreviewProcessor', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('rejects an image over 40 million pixels with a localized error', async () => {
|
||||
const zip = await buildZip({
|
||||
rows: [['111111111111', 'B1', '2026-07-04 10:00', 'images/oversized.png', '']],
|
||||
images: { 'images/oversized.png': await oversizedPng() },
|
||||
});
|
||||
const harness = createHarness(zip, [traceCode('111111111111')]);
|
||||
|
||||
await process(harness.processor);
|
||||
|
||||
expect(harness.storage.save).not.toHaveBeenCalled();
|
||||
expect(harness.persistedRows[0]).toMatchObject({
|
||||
status: 'INVALID',
|
||||
reason: '图片像素尺寸超过限制:images/oversized.png',
|
||||
});
|
||||
});
|
||||
|
||||
it('rejects a worksheet whose declared row count exceeds the limit', async () => {
|
||||
const zip = await buildZip({ sparseRow: OUTBOUND_IMPORT_MAX_ROWS + 2 });
|
||||
const harness = createHarness(zip);
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { Processor, WorkerHost } from '@nestjs/bullmq';
|
||||
import { Logger } from '@nestjs/common';
|
||||
import { Job } from 'bullmq';
|
||||
import AdmZip from 'adm-zip';
|
||||
import { mkdtemp, rm } from 'fs/promises';
|
||||
import * as ExcelJS from 'exceljs';
|
||||
import { join } from 'path';
|
||||
import sharp from 'sharp';
|
||||
import { JobStatus, OUTBOUND_IMPORT_COLUMNS, QUEUE_NAMES, TRACE_CODE_PATTERN } from '@artveris/shared';
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
@@ -11,10 +12,13 @@ import { JobsService } from '../jobs/jobs.service';
|
||||
import { isOutbound } from './outbound.util';
|
||||
import {
|
||||
assertArchiveLimits,
|
||||
assertArchiveActualSize,
|
||||
assertStoredImageBudget,
|
||||
assertZipEntryCount,
|
||||
canonicalImagePath,
|
||||
cellToString,
|
||||
ensureOutboundImportTempDir,
|
||||
inspectZipFile,
|
||||
mimeOfImagePath,
|
||||
normalizeImagePath,
|
||||
OUTBOUND_IMPORT_MAX_COLUMNS,
|
||||
@@ -22,14 +26,19 @@ import {
|
||||
OUTBOUND_IMPORT_MAX_IMAGE_SIZE,
|
||||
OUTBOUND_IMPORT_MAX_IMAGES_PER_ROW,
|
||||
OUTBOUND_IMPORT_MAX_ROWS,
|
||||
OUTBOUND_IMPORT_MAX_UNCOMPRESSED_SIZE,
|
||||
OUTBOUND_IMPORT_STORAGE_TIMEOUT_MS,
|
||||
OUTBOUND_IMPORT_PREVIEW_TEMP_PREFIX,
|
||||
OUTBOUND_IMPORT_TEMP_DIR,
|
||||
OUTBOUND_IMPORT_MAX_XLSX_ENTRIES,
|
||||
OUTBOUND_IMPORT_MAX_XLSX_SIZE,
|
||||
OUTBOUND_IMPORT_MAX_XLSX_UNCOMPRESSED_SIZE,
|
||||
OUTBOUND_IMPORT_MAX_ZIP_ENTRIES,
|
||||
parseOutboundDate,
|
||||
readArchiveEntryBuffer,
|
||||
} from './outbound-import.util';
|
||||
|
||||
const unzipper: any = require('unzipper');
|
||||
|
||||
interface PreviewJobData {
|
||||
jobId: string;
|
||||
sessionId: string;
|
||||
@@ -48,6 +57,11 @@ interface StoredImage {
|
||||
type: string;
|
||||
}
|
||||
|
||||
interface ArchivedImage {
|
||||
path: string;
|
||||
entry: { stream: () => NodeJS.ReadableStream };
|
||||
}
|
||||
|
||||
@Processor(QUEUE_NAMES.IMPORT_OUTBOUND_PREVIEW)
|
||||
export class ImportPreviewProcessor extends WorkerHost {
|
||||
private readonly logger = new Logger(ImportPreviewProcessor.name);
|
||||
@@ -64,6 +78,7 @@ export class ImportPreviewProcessor extends WorkerHost {
|
||||
const { jobId, sessionId, fileKey } = job.data;
|
||||
const createdImageKeys = new Set<string>();
|
||||
let rowsPersisted = false;
|
||||
let workingDir = '';
|
||||
try {
|
||||
const session = await this.prisma.outboundImportSession.findUnique({
|
||||
where: { id: sessionId },
|
||||
@@ -78,6 +93,9 @@ export class ImportPreviewProcessor extends WorkerHost {
|
||||
},
|
||||
});
|
||||
if (!session) {
|
||||
await this.storage.remove(fileKey).catch((error) =>
|
||||
this.logger.warn(`清理无会话出库导入 ZIP 失败:${fileKey} ${(error as Error).message}`),
|
||||
);
|
||||
await this.jobs
|
||||
.finish(jobId, { status: JobStatus.FAILED, error: '导入预览会话不存在' })
|
||||
.catch(() => undefined);
|
||||
@@ -99,6 +117,7 @@ export class ImportPreviewProcessor extends WorkerHost {
|
||||
failCount: session.invalidCount,
|
||||
error: session.error,
|
||||
});
|
||||
await this.removeSourceArchive(sessionId, session.fileKey || fileKey);
|
||||
return;
|
||||
}
|
||||
if (session.fileKey !== fileKey) {
|
||||
@@ -117,47 +136,77 @@ export class ImportPreviewProcessor extends WorkerHost {
|
||||
return jobClaim.count === 1;
|
||||
});
|
||||
if (!started) return;
|
||||
const buffer = await this.storage.read(fileKey);
|
||||
assertZipEntryCount(buffer, OUTBOUND_IMPORT_MAX_ZIP_ENTRIES, 'ZIP ');
|
||||
const zip = new AdmZip(buffer);
|
||||
const entries = zip.getEntries();
|
||||
let lastHeartbeatAt = Date.now();
|
||||
const heartbeat = async (successCount: number, failCount: number, force = false) => {
|
||||
if (!force && Date.now() - lastHeartbeatAt < 60_000) return;
|
||||
const touched = await this.jobs.progress(jobId, successCount, failCount);
|
||||
if (touched.count !== 1) throw new Error('导入预览任务状态已变化');
|
||||
lastHeartbeatAt = Date.now();
|
||||
};
|
||||
await ensureOutboundImportTempDir();
|
||||
workingDir = await mkdtemp(join(OUTBOUND_IMPORT_TEMP_DIR, OUTBOUND_IMPORT_PREVIEW_TEMP_PREFIX));
|
||||
const archivePath = join(workingDir, 'source.zip');
|
||||
await this.storage.downloadToFile(fileKey, archivePath, {
|
||||
requestTimeoutMs: OUTBOUND_IMPORT_STORAGE_TIMEOUT_MS,
|
||||
});
|
||||
await heartbeat(0, 0, true);
|
||||
const archiveTailSize = await inspectZipFile(archivePath, OUTBOUND_IMPORT_MAX_ZIP_ENTRIES, 'ZIP ');
|
||||
const archive = await unzipper.Open.file(archivePath, { tailSize: archiveTailSize });
|
||||
const entries: any[] = archive.files;
|
||||
assertArchiveLimits(
|
||||
entries,
|
||||
entries.map((entry) => ({
|
||||
isDirectory: entry.type === 'Directory',
|
||||
header: { size: Number(entry.uncompressedSize) },
|
||||
})),
|
||||
OUTBOUND_IMPORT_MAX_ZIP_ENTRIES,
|
||||
OUTBOUND_IMPORT_MAX_UNCOMPRESSED_SIZE,
|
||||
undefined,
|
||||
'ZIP ',
|
||||
);
|
||||
|
||||
const files = entries.filter((entry) => !entry.isDirectory);
|
||||
const xlsxEntries = files.filter((entry) => entry.entryName.replace(/\\/g, '/').toLowerCase().endsWith('.xlsx'));
|
||||
const files = entries.filter((entry) => entry.type === 'File');
|
||||
const xlsxEntries = files.filter((entry) => entry.path.replace(/\\/g, '/').toLowerCase().endsWith('.xlsx'));
|
||||
if (xlsxEntries.length !== 1) throw new Error('ZIP 中必须且只能包含一个 xlsx 文件');
|
||||
const xlsxName = xlsxEntries[0].entryName.replace(/\\/g, '/');
|
||||
const xlsxName = xlsxEntries[0].path.replace(/\\/g, '/');
|
||||
if (xlsxName.includes('/')) throw new Error('xlsx 文件必须位于 ZIP 根目录');
|
||||
if (Number(xlsxEntries[0].uncompressedSize) > OUTBOUND_IMPORT_MAX_XLSX_SIZE) {
|
||||
throw new Error('xlsx 文件超过 100MB');
|
||||
}
|
||||
|
||||
const xlsxBuffer = xlsxEntries[0].getData();
|
||||
if (xlsxBuffer.length > OUTBOUND_IMPORT_MAX_XLSX_SIZE) throw new Error('xlsx 文件超过 10MB');
|
||||
assertZipEntryCount(xlsxBuffer, OUTBOUND_IMPORT_MAX_XLSX_ENTRIES, 'xlsx ');
|
||||
const xlsxArchive = new AdmZip(xlsxBuffer);
|
||||
const xlsxBuffer = await readArchiveEntryBuffer(
|
||||
xlsxEntries[0],
|
||||
OUTBOUND_IMPORT_MAX_XLSX_SIZE,
|
||||
'xlsx 文件超过 100MB',
|
||||
() => heartbeat(0, 0),
|
||||
);
|
||||
const xlsxTailSize = assertZipEntryCount(xlsxBuffer, OUTBOUND_IMPORT_MAX_XLSX_ENTRIES, 'xlsx ');
|
||||
const xlsxArchive = await unzipper.Open.buffer(xlsxBuffer, { tailSize: xlsxTailSize });
|
||||
const xlsxLimitEntries = xlsxArchive.files.map((entry: any) => ({
|
||||
isDirectory: entry.type === 'Directory',
|
||||
header: { size: Number(entry.uncompressedSize) },
|
||||
stream: () => entry.stream(),
|
||||
}));
|
||||
assertArchiveLimits(
|
||||
xlsxArchive.getEntries(),
|
||||
xlsxLimitEntries,
|
||||
OUTBOUND_IMPORT_MAX_XLSX_ENTRIES,
|
||||
OUTBOUND_IMPORT_MAX_XLSX_UNCOMPRESSED_SIZE,
|
||||
'xlsx ',
|
||||
);
|
||||
await assertArchiveActualSize(
|
||||
xlsxLimitEntries,
|
||||
OUTBOUND_IMPORT_MAX_XLSX_UNCOMPRESSED_SIZE,
|
||||
'xlsx ',
|
||||
() => heartbeat(0, 0),
|
||||
);
|
||||
|
||||
const imageEntries = new Map<string, { path: string; data: Buffer }>();
|
||||
let extractedSize = xlsxBuffer.length;
|
||||
const imageEntries = new Map<string, ArchivedImage>();
|
||||
for (const entry of files) {
|
||||
const name = entry.entryName.replace(/\\/g, '/');
|
||||
const name = entry.path.replace(/\\/g, '/');
|
||||
if (name === xlsxName || name === '说明.txt') continue;
|
||||
const path = normalizeImagePath(name);
|
||||
const canonical = canonicalImagePath(path);
|
||||
if (imageEntries.has(canonical)) throw new Error(`ZIP 中存在重复图片路径:${path}`);
|
||||
const data = entry.getData();
|
||||
extractedSize += data.length;
|
||||
if (extractedSize > OUTBOUND_IMPORT_MAX_UNCOMPRESSED_SIZE) throw new Error('ZIP 解压后总大小超过限制');
|
||||
if (data.length > OUTBOUND_IMPORT_MAX_IMAGE_SIZE) throw new Error(`图片超过 10MB:${path}`);
|
||||
imageEntries.set(canonical, { path, data });
|
||||
if (Number(entry.uncompressedSize) > OUTBOUND_IMPORT_MAX_IMAGE_SIZE) throw new Error(`图片超过 100MB:${path}`);
|
||||
imageEntries.set(canonical, { path, entry });
|
||||
}
|
||||
|
||||
const workbook = new ExcelJS.Workbook();
|
||||
@@ -226,7 +275,6 @@ export class ImportPreviewProcessor extends WorkerHost {
|
||||
let valid = 0;
|
||||
let invalid = 0;
|
||||
let imageReferenceCount = 0;
|
||||
let storedImageBytes = 0;
|
||||
const validatedImagePaths = new Set<string>();
|
||||
|
||||
for (const { rowNo, values } of sheetRows) {
|
||||
@@ -270,7 +318,7 @@ export class ImportPreviewProcessor extends WorkerHost {
|
||||
}
|
||||
const imagePaths = rawImagePaths.map(normalizeImagePath);
|
||||
const imagePathSet = new Set<string>();
|
||||
const images: Array<{ path: string; data: Buffer }> = [];
|
||||
const images: ArchivedImage[] = [];
|
||||
for (const path of imagePaths) {
|
||||
const canonical = canonicalImagePath(path);
|
||||
if (imagePathSet.has(canonical)) throw new Error(`同一行重复引用图片:${path}`);
|
||||
@@ -279,16 +327,29 @@ export class ImportPreviewProcessor extends WorkerHost {
|
||||
if (!image) throw new Error(`图片不存在:${path}`);
|
||||
images.push(image);
|
||||
}
|
||||
const rowImageBytes = images.reduce((sum, image) => sum + image.data.length, 0);
|
||||
imageReferenceCount += images.length;
|
||||
storedImageBytes += rowImageBytes;
|
||||
assertStoredImageBudget(imageReferenceCount, storedImageBytes);
|
||||
assertStoredImageBudget(imageReferenceCount);
|
||||
|
||||
for (const image of images) {
|
||||
const path = image.path;
|
||||
const canonical = canonicalImagePath(path);
|
||||
if (validatedImagePaths.has(canonical)) continue;
|
||||
const metadata = await sharp(image.data, { limitInputPixels: OUTBOUND_IMPORT_MAX_IMAGE_PIXELS }).metadata();
|
||||
const data = await readArchiveEntryBuffer(
|
||||
image.entry as any,
|
||||
OUTBOUND_IMPORT_MAX_IMAGE_SIZE,
|
||||
`图片超过 100MB:${path}`,
|
||||
() => heartbeat(valid, invalid),
|
||||
);
|
||||
let metadata;
|
||||
try {
|
||||
metadata = await sharp(data, { limitInputPixels: OUTBOUND_IMPORT_MAX_IMAGE_PIXELS }).metadata();
|
||||
} catch (error) {
|
||||
if (/pixel limit/i.test((error as Error).message)) {
|
||||
throw new Error(`图片像素尺寸超过限制:${path}`);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
await heartbeat(valid, invalid);
|
||||
const expectedFormat = path.toLowerCase().endsWith('.png')
|
||||
? 'png'
|
||||
: path.toLowerCase().endsWith('.webp')
|
||||
@@ -305,13 +366,21 @@ export class ImportPreviewProcessor extends WorkerHost {
|
||||
const imageItems: StoredImage[] = [];
|
||||
result.outImageKeys = imageItems;
|
||||
for (const image of images) {
|
||||
const data = await readArchiveEntryBuffer(
|
||||
image.entry as any,
|
||||
OUTBOUND_IMPORT_MAX_IMAGE_SIZE,
|
||||
`图片超过 100MB:${image.path}`,
|
||||
() => heartbeat(valid, invalid),
|
||||
);
|
||||
const saved = await this.storage.save(
|
||||
image.data,
|
||||
data,
|
||||
image.path.split('/').pop() || 'outbound.jpg',
|
||||
mimeOfImagePath(image.path),
|
||||
{ requestTimeoutMs: OUTBOUND_IMPORT_STORAGE_TIMEOUT_MS },
|
||||
);
|
||||
createdImageKeys.add(saved.key);
|
||||
imageItems.push({ key: saved.key, url: saved.url, name: saved.name, type: 'image' });
|
||||
await heartbeat(valid, invalid);
|
||||
}
|
||||
|
||||
Object.assign(result, {
|
||||
@@ -339,6 +408,7 @@ export class ImportPreviewProcessor extends WorkerHost {
|
||||
invalid++;
|
||||
}
|
||||
rows.push(result);
|
||||
await heartbeat(valid, invalid);
|
||||
}
|
||||
|
||||
await this.prisma.$transaction(async (tx) => {
|
||||
@@ -369,6 +439,7 @@ export class ImportPreviewProcessor extends WorkerHost {
|
||||
});
|
||||
}, { timeout: 60_000 });
|
||||
rowsPersisted = true;
|
||||
await this.removeSourceArchive(sessionId, fileKey);
|
||||
} catch (error) {
|
||||
const message = (error as Error).message;
|
||||
if (!rowsPersisted) {
|
||||
@@ -396,7 +467,7 @@ export class ImportPreviewProcessor extends WorkerHost {
|
||||
}
|
||||
}
|
||||
}
|
||||
await this.prisma
|
||||
const failed = await this.prisma
|
||||
.$transaction(async (tx) => {
|
||||
const failed = await tx.outboundImportSession.updateMany({
|
||||
where: { id: sessionId, status: 'PARSING', previewJobId: jobId },
|
||||
@@ -405,9 +476,30 @@ export class ImportPreviewProcessor extends WorkerHost {
|
||||
if (failed.count === 1) {
|
||||
await tx.job.update({ where: { id: jobId }, data: { status: JobStatus.FAILED, error: message } });
|
||||
}
|
||||
return failed.count === 1;
|
||||
})
|
||||
.catch(() => undefined);
|
||||
.catch(() => false);
|
||||
if (failed) await this.removeSourceArchive(sessionId, fileKey);
|
||||
this.logger.error(`导入预览失败:${message}`);
|
||||
} finally {
|
||||
if (workingDir) {
|
||||
await rm(workingDir, { recursive: true, force: true }).catch((error) =>
|
||||
this.logger.warn(`清理出库导入 Worker 临时目录失败:${workingDir} ${(error as Error).message}`),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async removeSourceArchive(sessionId: string, fileKey: string): Promise<void> {
|
||||
if (!fileKey) return;
|
||||
try {
|
||||
await this.storage.remove(fileKey);
|
||||
await this.prisma.outboundImportSession.updateMany({
|
||||
where: { id: sessionId, fileKey },
|
||||
data: { fileKey: null },
|
||||
});
|
||||
} catch (error) {
|
||||
this.logger.warn(`清理出库导入原始 ZIP 失败:${fileKey} ${(error as Error).message}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -273,6 +273,7 @@ describe('ImportProcessor', () => {
|
||||
'1/ARTVERIS-000001/111111111111',
|
||||
'出库实况',
|
||||
expect.any(Function),
|
||||
{ requestTimeoutMs: 3_600_000 },
|
||||
);
|
||||
expect(harness.tx.outboundImportRow.updateMany).toHaveBeenCalledWith({
|
||||
where: { id: 1n, status: 'VALID' },
|
||||
|
||||
@@ -8,6 +8,7 @@ import { PrismaService } from '../prisma/prisma.service';
|
||||
import { StorageService } from '../storage/storage.service';
|
||||
import { JobsService } from '../jobs/jobs.service';
|
||||
import { isOutbound } from './outbound.util';
|
||||
import { OUTBOUND_IMPORT_STORAGE_TIMEOUT_MS } from './outbound-import.util';
|
||||
|
||||
interface ImportJobData {
|
||||
jobId: string;
|
||||
@@ -237,7 +238,7 @@ export class ImportProcessor extends WorkerHost {
|
||||
});
|
||||
if (registered.count !== 1) throw new ImportRunSupersededError();
|
||||
});
|
||||
});
|
||||
}, { requestTimeoutMs: OUTBOUND_IMPORT_STORAGE_TIMEOUT_MS });
|
||||
sourceKeys = [...copied.keyMap.keys()];
|
||||
copiedKeys = [...copied.keyMap.values()];
|
||||
imageItems = copied.items.map((item) => ({
|
||||
|
||||
@@ -257,6 +257,43 @@ describe('OutboundImportCleanupService', () => {
|
||||
expect(previewQueue.add).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('uses a longer stale window for large preview processing jobs', async () => {
|
||||
await service.requeuePendingImports();
|
||||
|
||||
expect(prisma.job.findMany).toHaveBeenCalledWith(expect.objectContaining({
|
||||
where: expect.objectContaining({
|
||||
OR: expect.arrayContaining([
|
||||
{
|
||||
type: JobType.IMPORT_OUTBOUND_PREVIEW,
|
||||
status: JobStatus.PROCESSING,
|
||||
updatedAt: { lt: new Date('2026-07-13T06:00:00.000Z') },
|
||||
},
|
||||
]),
|
||||
}),
|
||||
}));
|
||||
});
|
||||
|
||||
it('removes a raw ZIP as soon as its preview session is terminal', async () => {
|
||||
prisma.outboundImportSession.findMany.mockResolvedValue([{
|
||||
id: 'session-ready',
|
||||
status: OutboundImportSessionStatus.READY,
|
||||
fileKey: '.private/import.zip',
|
||||
}]);
|
||||
prisma.outboundImportSession.updateMany.mockResolvedValue({ count: 1 });
|
||||
|
||||
await service.cleanupTerminalArchiveFiles();
|
||||
|
||||
expect(storage.remove).toHaveBeenCalledWith('.private/import.zip');
|
||||
expect(prisma.outboundImportSession.updateMany).toHaveBeenCalledWith({
|
||||
where: {
|
||||
id: 'session-ready',
|
||||
status: OutboundImportSessionStatus.READY,
|
||||
fileKey: '.private/import.zip',
|
||||
},
|
||||
data: { fileKey: null },
|
||||
});
|
||||
});
|
||||
|
||||
it('retries a failed BullMQ preview job without creating a duplicate', async () => {
|
||||
const queued = { getState: jest.fn().mockResolvedValue('failed'), retry: jest.fn().mockResolvedValue(undefined) };
|
||||
prisma.job.findMany.mockResolvedValue([{
|
||||
|
||||
@@ -9,9 +9,17 @@ import {
|
||||
Prisma,
|
||||
} from '@prisma/client';
|
||||
import { Queue } from 'bullmq';
|
||||
import { readdir, rm } from 'fs/promises';
|
||||
import { join } from 'path';
|
||||
import { QUEUE_NAMES } from '@artveris/shared';
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
import { StorageService } from '../storage/storage.service';
|
||||
import {
|
||||
ensureOutboundImportTempDir,
|
||||
OUTBOUND_IMPORT_TEMP_DIR,
|
||||
OUTBOUND_IMPORT_UPLOAD_TEMP_PREFIX,
|
||||
OUTBOUND_IMPORT_PREVIEW_TEMP_PREFIX,
|
||||
} from './outbound-import.util';
|
||||
|
||||
function collectImageKeys(value: Prisma.JsonValue | null): string[] {
|
||||
if (!Array.isArray(value)) return [];
|
||||
@@ -33,6 +41,9 @@ function collectPreviewKeys(value: Prisma.JsonValue | null): string[] {
|
||||
return [...collectImageKeys(preview.images ?? null), ...pending];
|
||||
}
|
||||
|
||||
const IMPORT_PROCESSING_STALE_MS = 15 * 60_000;
|
||||
const PREVIEW_PROCESSING_STALE_MS = 2 * 60 * 60_000;
|
||||
|
||||
@Injectable()
|
||||
export class OutboundImportCleanupService implements OnModuleInit {
|
||||
private readonly logger = new Logger(OutboundImportCleanupService.name);
|
||||
@@ -45,9 +56,52 @@ export class OutboundImportCleanupService implements OnModuleInit {
|
||||
) {}
|
||||
|
||||
async onModuleInit(): Promise<void> {
|
||||
await this.cleanupOrphanedLocalTempFiles();
|
||||
await this.cleanupTerminalArchiveFiles();
|
||||
await this.requeuePendingImports();
|
||||
}
|
||||
|
||||
private async cleanupOrphanedLocalTempFiles(): Promise<void> {
|
||||
await ensureOutboundImportTempDir();
|
||||
const entries = await readdir(OUTBOUND_IMPORT_TEMP_DIR, { withFileTypes: true });
|
||||
let removed = 0;
|
||||
for (const entry of entries) {
|
||||
if (!entry.name.startsWith(OUTBOUND_IMPORT_UPLOAD_TEMP_PREFIX)
|
||||
&& !entry.name.startsWith(OUTBOUND_IMPORT_PREVIEW_TEMP_PREFIX)) continue;
|
||||
try {
|
||||
await rm(join(OUTBOUND_IMPORT_TEMP_DIR, entry.name), { recursive: true, force: true });
|
||||
removed++;
|
||||
} catch (error) {
|
||||
this.logger.warn(`清理遗留出库导入临时文件失败:${entry.name} ${(error as Error).message}`);
|
||||
}
|
||||
}
|
||||
if (removed) this.logger.log(`已清理遗留出库导入临时文件:${removed}`);
|
||||
}
|
||||
|
||||
@Cron(CronExpression.EVERY_HOUR)
|
||||
async cleanupTerminalArchiveFiles(): Promise<void> {
|
||||
const sessions = await this.prisma.outboundImportSession.findMany({
|
||||
where: {
|
||||
fileKey: { not: null },
|
||||
status: { not: OutboundImportSessionStatus.PARSING },
|
||||
},
|
||||
select: { id: true, status: true, fileKey: true },
|
||||
take: 50,
|
||||
});
|
||||
for (const session of sessions) {
|
||||
if (!session.fileKey) continue;
|
||||
try {
|
||||
await this.storage.remove(session.fileKey);
|
||||
await this.prisma.outboundImportSession.updateMany({
|
||||
where: { id: session.id, status: session.status, fileKey: session.fileKey },
|
||||
data: { fileKey: null },
|
||||
});
|
||||
} catch (error) {
|
||||
this.logger.warn(`清理终态出库导入 ZIP 失败:${session.fileKey} ${(error as Error).message}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Cron(CronExpression.EVERY_MINUTE)
|
||||
async requeuePendingImports(): Promise<void> {
|
||||
const now = Date.now();
|
||||
@@ -56,7 +110,16 @@ export class OutboundImportCleanupService implements OnModuleInit {
|
||||
type: { in: [JobType.IMPORT_OUTBOUND, JobType.IMPORT_OUTBOUND_PREVIEW] },
|
||||
OR: [
|
||||
{ status: JobStatus.PENDING, updatedAt: { lt: new Date(now - 30_000) } },
|
||||
{ status: JobStatus.PROCESSING, updatedAt: { lt: new Date(now - 15 * 60_000) } },
|
||||
{
|
||||
type: JobType.IMPORT_OUTBOUND,
|
||||
status: JobStatus.PROCESSING,
|
||||
updatedAt: { lt: new Date(now - IMPORT_PROCESSING_STALE_MS) },
|
||||
},
|
||||
{
|
||||
type: JobType.IMPORT_OUTBOUND_PREVIEW,
|
||||
status: JobStatus.PROCESSING,
|
||||
updatedAt: { lt: new Date(now - PREVIEW_PROCESSING_STALE_MS) },
|
||||
},
|
||||
],
|
||||
},
|
||||
orderBy: { createdAt: 'asc' },
|
||||
|
||||
@@ -1,14 +1,23 @@
|
||||
import {
|
||||
assertArchiveActualSize,
|
||||
assertArchiveLimits,
|
||||
assertStoredImageBudget,
|
||||
assertZipEntryCount,
|
||||
canonicalImagePath,
|
||||
cellToString,
|
||||
inspectZipFile,
|
||||
mimeOfImagePath,
|
||||
normalizeImagePath,
|
||||
OUTBOUND_IMPORT_MAX_IMAGE_SIZE,
|
||||
OUTBOUND_IMPORT_MAX_XLSX_SIZE,
|
||||
parseOutboundDate,
|
||||
readArchiveEntryBuffer,
|
||||
} from './outbound-import.util';
|
||||
import AdmZip from 'adm-zip';
|
||||
import { mkdtemp, rm, writeFile } from 'fs/promises';
|
||||
import { tmpdir } from 'os';
|
||||
import { join } from 'path';
|
||||
import { Readable } from 'stream';
|
||||
|
||||
describe('outbound import utilities', () => {
|
||||
describe('parseOutboundDate', () => {
|
||||
@@ -99,6 +108,41 @@ describe('parseOutboundDate', () => {
|
||||
expect(() => assertZipEntryCount(buffer, 1, 'ZIP')).toThrow('ZIP文件数量超过限制(最多 1 个)');
|
||||
expect(() => assertZipEntryCount(Buffer.from('not a zip'), 2, 'ZIP')).toThrow('ZIP文件结构无效');
|
||||
});
|
||||
|
||||
it('locates the real end record behind a long ZIP comment on disk', async () => {
|
||||
const zip = new AdmZip();
|
||||
zip.addFile('one.txt', Buffer.from('1'));
|
||||
zip.addZipComment('x'.repeat(100));
|
||||
const buffer = zip.toBuffer();
|
||||
const dir = await mkdtemp(join(tmpdir(), 'artveris-zip-inspect-'));
|
||||
const filePath = join(dir, 'commented.zip');
|
||||
await writeFile(filePath, buffer);
|
||||
try {
|
||||
expect(assertZipEntryCount(buffer, 1, 'ZIP')).toBe(122);
|
||||
await expect(inspectZipFile(filePath, 1, 'ZIP')).resolves.toBe(122);
|
||||
} finally {
|
||||
await rm(dir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
it('reads the real entry count from a ZIP64 end record', () => {
|
||||
const buffer = Buffer.alloc(56 + 20 + 22);
|
||||
buffer.writeUInt32LE(0x06064b50, 0);
|
||||
buffer.writeBigUInt64LE(44n, 4);
|
||||
buffer.writeBigUInt64LE(2n, 24);
|
||||
buffer.writeBigUInt64LE(2n, 32);
|
||||
buffer.writeUInt32LE(0x07064b50, 56);
|
||||
buffer.writeBigUInt64LE(0n, 64);
|
||||
buffer.writeUInt32LE(1, 72);
|
||||
buffer.writeUInt32LE(0x06054b50, 76);
|
||||
buffer.writeUInt16LE(0xffff, 84);
|
||||
buffer.writeUInt16LE(0xffff, 86);
|
||||
buffer.writeUInt32LE(0xffffffff, 88);
|
||||
buffer.writeUInt32LE(0xffffffff, 92);
|
||||
|
||||
expect(assertZipEntryCount(buffer, 2, 'ZIP')).toBe(22);
|
||||
expect(() => assertZipEntryCount(buffer, 1, 'ZIP')).toThrow('ZIP文件数量超过限制(最多 1 个)');
|
||||
});
|
||||
});
|
||||
|
||||
describe('assertArchiveLimits', () => {
|
||||
@@ -121,6 +165,10 @@ describe('parseOutboundDate', () => {
|
||||
).not.toThrow();
|
||||
});
|
||||
|
||||
it('validates entry metadata without imposing an aggregate byte limit when none is configured', () => {
|
||||
expect(() => assertArchiveLimits([file(100 * 1024 * 1024), file(100 * 1024 * 1024)], 2, undefined, 'ZIP')).not.toThrow();
|
||||
});
|
||||
|
||||
it.each([-1, Number.NaN, Number.POSITIVE_INFINITY, 1.5, Number.MAX_SAFE_INTEGER + 1])(
|
||||
'rejects an invalid entry size: %s',
|
||||
(size) => {
|
||||
@@ -143,7 +191,33 @@ describe('cellToString', () => {
|
||||
|
||||
describe('assertStoredImageBudget', () => {
|
||||
it('rejects output amplification by repeated image references', () => {
|
||||
expect(() => assertStoredImageBudget(20_001, 1)).toThrow('出库图片引用总数超过限制');
|
||||
expect(() => assertStoredImageBudget(1, 200 * 1024 * 1024 + 1)).toThrow('出库图片按引用累计大小超过限制');
|
||||
expect(() => assertStoredImageBudget(20_001)).toThrow('出库图片引用总数超过限制');
|
||||
});
|
||||
});
|
||||
|
||||
describe('streamed archive limits', () => {
|
||||
const streamed = (...chunks: Buffer[]) => ({
|
||||
isDirectory: false,
|
||||
header: { size: chunks.reduce((total, chunk) => total + chunk.length, 0) },
|
||||
stream: () => Readable.from(chunks),
|
||||
});
|
||||
|
||||
it('allows the exact entry byte limit and rejects the next byte before concatenation', async () => {
|
||||
await expect(readArchiveEntryBuffer(streamed(Buffer.from('ab'), Buffer.from('c')), 3, 'too large'))
|
||||
.resolves.toEqual(Buffer.from('abc'));
|
||||
await expect(readArchiveEntryBuffer(streamed(Buffer.from('ab'), Buffer.from('cd')), 3, 'too large'))
|
||||
.rejects.toThrow('too large');
|
||||
});
|
||||
|
||||
it('measures actual expanded bytes instead of trusting declared archive sizes', async () => {
|
||||
const disguised = { ...streamed(Buffer.from('abcd')), header: { size: 1 } };
|
||||
|
||||
await expect(assertArchiveActualSize([disguised], 3, 'xlsx '))
|
||||
.rejects.toThrow('xlsx 解压后总大小超过限制');
|
||||
});
|
||||
});
|
||||
|
||||
it('allows 100MB for one image and one xlsx file', () => {
|
||||
expect(OUTBOUND_IMPORT_MAX_IMAGE_SIZE).toBe(100 * 1024 * 1024);
|
||||
expect(OUTBOUND_IMPORT_MAX_XLSX_SIZE).toBe(100 * 1024 * 1024);
|
||||
});
|
||||
|
||||
@@ -1,40 +1,129 @@
|
||||
import { mkdir, open } from 'fs/promises';
|
||||
import { tmpdir } from 'os';
|
||||
import { resolve } from 'path';
|
||||
import { Readable } from 'stream';
|
||||
|
||||
export const OUTBOUND_IMPORT_MAX_ROWS = 10_000;
|
||||
export const OUTBOUND_IMPORT_MAX_COLUMNS = 64;
|
||||
export const OUTBOUND_IMPORT_MAX_ZIP_ENTRIES = 20_002;
|
||||
export const OUTBOUND_IMPORT_MAX_UNCOMPRESSED_SIZE = 120 * 1024 * 1024;
|
||||
export const OUTBOUND_IMPORT_MAX_XLSX_SIZE = 10 * 1024 * 1024;
|
||||
export const OUTBOUND_IMPORT_MAX_XLSX_SIZE = 100 * 1024 * 1024;
|
||||
export const OUTBOUND_IMPORT_MAX_XLSX_ENTRIES = 256;
|
||||
export const OUTBOUND_IMPORT_MAX_XLSX_UNCOMPRESSED_SIZE = 50 * 1024 * 1024;
|
||||
export const OUTBOUND_IMPORT_MAX_IMAGE_SIZE = 10 * 1024 * 1024;
|
||||
export const OUTBOUND_IMPORT_MAX_XLSX_UNCOMPRESSED_SIZE = 500 * 1024 * 1024;
|
||||
export const OUTBOUND_IMPORT_MAX_IMAGE_SIZE = 100 * 1024 * 1024;
|
||||
export const OUTBOUND_IMPORT_MAX_IMAGES_PER_ROW = 20;
|
||||
export const OUTBOUND_IMPORT_MAX_IMAGE_PIXELS = 40_000_000;
|
||||
export const OUTBOUND_IMPORT_MAX_IMAGE_REFERENCES = 20_000;
|
||||
export const OUTBOUND_IMPORT_MAX_STORED_IMAGE_SIZE = 200 * 1024 * 1024;
|
||||
export const OUTBOUND_IMPORT_STORAGE_TIMEOUT_MS = 60 * 60 * 1000;
|
||||
export const OUTBOUND_IMPORT_TEMP_DIR = resolve(process.env.ARTVERIS_OUTBOUND_TEMP_DIR || tmpdir());
|
||||
export const OUTBOUND_IMPORT_UPLOAD_TEMP_PREFIX = 'artveris-outbound-upload-';
|
||||
export const OUTBOUND_IMPORT_PREVIEW_TEMP_PREFIX = 'artveris-outbound-preview-';
|
||||
|
||||
const ARCHIVE_PROGRESS_INTERVAL_BYTES = 8 * 1024 * 1024;
|
||||
const ZIP_END_RECORD_MAX_SIZE = 65_557;
|
||||
const ZIP_END_RECORD_MIN_SIZE = 22;
|
||||
const ZIP64_LOCATOR_SIZE = 20;
|
||||
const ZIP64_END_RECORD_MIN_SIZE = 56;
|
||||
const ZIP_END_SIGNATURE = 0x06054b50;
|
||||
const ZIP64_LOCATOR_SIGNATURE = 0x07064b50;
|
||||
const ZIP64_END_SIGNATURE = 0x06064b50;
|
||||
|
||||
export async function ensureOutboundImportTempDir(): Promise<void> {
|
||||
await mkdir(OUTBOUND_IMPORT_TEMP_DIR, { recursive: true });
|
||||
}
|
||||
|
||||
interface ArchiveEntryLike {
|
||||
isDirectory: boolean;
|
||||
header: { size: number };
|
||||
}
|
||||
|
||||
export function assertZipEntryCount(buffer: Buffer, maxEntries: number, label: string): void {
|
||||
const minEndOffset = Math.max(0, buffer.length - 65_557);
|
||||
for (let offset = buffer.length - 22; offset >= minEndOffset; offset--) {
|
||||
if (buffer.readUInt32LE(offset) !== 0x06054b50) continue;
|
||||
interface ArchiveStreamEntryLike extends ArchiveEntryLike {
|
||||
stream: () => Readable;
|
||||
}
|
||||
|
||||
function findZipEndRecordOffset(buffer: Buffer, label: string): number {
|
||||
const minEndOffset = Math.max(0, buffer.length - ZIP_END_RECORD_MAX_SIZE);
|
||||
for (let offset = buffer.length - ZIP_END_RECORD_MIN_SIZE; offset >= minEndOffset; offset--) {
|
||||
if (buffer.readUInt32LE(offset) !== ZIP_END_SIGNATURE) continue;
|
||||
const commentLength = buffer.readUInt16LE(offset + 20);
|
||||
if (offset + 22 + commentLength !== buffer.length) continue;
|
||||
const entries = buffer.readUInt16LE(offset + 10);
|
||||
if (entries === 0xffff || entries > maxEntries) {
|
||||
throw new Error(`${label}文件数量超过限制(最多 ${maxEntries} 个)`);
|
||||
}
|
||||
return;
|
||||
if (offset + ZIP_END_RECORD_MIN_SIZE + commentLength !== buffer.length) continue;
|
||||
return offset;
|
||||
}
|
||||
throw new Error(`${label}文件结构无效`);
|
||||
}
|
||||
|
||||
function assertZipEntryCountValue(entries: bigint, maxEntries: number, label: string): void {
|
||||
if (entries > BigInt(maxEntries)) {
|
||||
throw new Error(`${label}文件数量超过限制(最多 ${maxEntries} 个)`);
|
||||
}
|
||||
}
|
||||
|
||||
function usesZip64(buffer: Buffer, endOffset: number): boolean {
|
||||
return buffer.readUInt16LE(endOffset + 10) === 0xffff
|
||||
|| buffer.readUInt32LE(endOffset + 12) === 0xffffffff
|
||||
|| buffer.readUInt32LE(endOffset + 16) === 0xffffffff;
|
||||
}
|
||||
|
||||
function readZip64EntryCount(buffer: Buffer, endOffset: number, label: string): bigint {
|
||||
const locatorOffset = endOffset - ZIP64_LOCATOR_SIZE;
|
||||
if (locatorOffset < 0 || buffer.readUInt32LE(locatorOffset) !== ZIP64_LOCATOR_SIGNATURE) {
|
||||
throw new Error(`${label}文件结构无效`);
|
||||
}
|
||||
const recordOffset = buffer.readBigUInt64LE(locatorOffset + 8);
|
||||
if (recordOffset > BigInt(Number.MAX_SAFE_INTEGER)) throw new Error(`${label}文件结构无效`);
|
||||
const offset = Number(recordOffset);
|
||||
if (offset < 0 || offset + ZIP64_END_RECORD_MIN_SIZE > buffer.length) throw new Error(`${label}文件结构无效`);
|
||||
if (buffer.readUInt32LE(offset) !== ZIP64_END_SIGNATURE) throw new Error(`${label}文件结构无效`);
|
||||
return buffer.readBigUInt64LE(offset + 32);
|
||||
}
|
||||
|
||||
export function assertZipEntryCount(buffer: Buffer, maxEntries: number, label: string): number {
|
||||
const endOffset = findZipEndRecordOffset(buffer, label);
|
||||
const entries = usesZip64(buffer, endOffset)
|
||||
? readZip64EntryCount(buffer, endOffset, label)
|
||||
: BigInt(buffer.readUInt16LE(endOffset + 10));
|
||||
assertZipEntryCountValue(entries, maxEntries, label);
|
||||
return buffer.length - endOffset;
|
||||
}
|
||||
|
||||
export async function inspectZipFile(filePath: string, maxEntries: number, label: string): Promise<number> {
|
||||
const file = await open(filePath, 'r');
|
||||
try {
|
||||
const { size } = await file.stat();
|
||||
if (size < ZIP_END_RECORD_MIN_SIZE) throw new Error(`${label}文件结构无效`);
|
||||
const tailLength = Math.min(size, ZIP_END_RECORD_MAX_SIZE);
|
||||
const tail = Buffer.allocUnsafe(tailLength);
|
||||
const tailRead = await file.read(tail, 0, tailLength, size - tailLength);
|
||||
if (tailRead.bytesRead !== tailLength) throw new Error(`${label}文件结构无效`);
|
||||
const relativeEndOffset = findZipEndRecordOffset(tail, label);
|
||||
const absoluteEndOffset = size - tailLength + relativeEndOffset;
|
||||
let entries: bigint;
|
||||
if (usesZip64(tail, relativeEndOffset)) {
|
||||
const locator = Buffer.allocUnsafe(ZIP64_LOCATOR_SIZE);
|
||||
if (absoluteEndOffset < ZIP64_LOCATOR_SIZE) throw new Error(`${label}文件结构无效`);
|
||||
const locatorRead = await file.read(locator, 0, locator.length, absoluteEndOffset - ZIP64_LOCATOR_SIZE);
|
||||
if (locatorRead.bytesRead !== locator.length) throw new Error(`${label}文件结构无效`);
|
||||
if (locator.readUInt32LE(0) !== ZIP64_LOCATOR_SIGNATURE) throw new Error(`${label}文件结构无效`);
|
||||
const recordOffset = locator.readBigUInt64LE(8);
|
||||
if (recordOffset > BigInt(Number.MAX_SAFE_INTEGER)) throw new Error(`${label}文件结构无效`);
|
||||
const record = Buffer.allocUnsafe(ZIP64_END_RECORD_MIN_SIZE);
|
||||
const recordRead = await file.read(record, 0, record.length, Number(recordOffset));
|
||||
if (recordRead.bytesRead !== record.length) throw new Error(`${label}文件结构无效`);
|
||||
if (record.readUInt32LE(0) !== ZIP64_END_SIGNATURE) throw new Error(`${label}文件结构无效`);
|
||||
entries = record.readBigUInt64LE(32);
|
||||
} else {
|
||||
entries = BigInt(tail.readUInt16LE(relativeEndOffset + 10));
|
||||
}
|
||||
assertZipEntryCountValue(entries, maxEntries, label);
|
||||
return size - absoluteEndOffset;
|
||||
} finally {
|
||||
await file.close();
|
||||
}
|
||||
}
|
||||
|
||||
export function assertArchiveLimits(
|
||||
entries: ArchiveEntryLike[],
|
||||
maxEntries: number,
|
||||
maxUncompressedSize: number,
|
||||
maxUncompressedSize: number | undefined,
|
||||
label: string,
|
||||
): void {
|
||||
if (entries.length > maxEntries) {
|
||||
@@ -46,18 +135,72 @@ export function assertArchiveLimits(
|
||||
const size = Number(entry.header?.size ?? 0);
|
||||
if (!Number.isSafeInteger(size) || size < 0) throw new Error(`${label}包含无效文件大小`);
|
||||
total += size;
|
||||
if (total > maxUncompressedSize) {
|
||||
if (maxUncompressedSize !== undefined && total > maxUncompressedSize) {
|
||||
throw new Error(`${label}解压后总大小超过限制`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function assertStoredImageBudget(referenceCount: number, totalBytes: number): void {
|
||||
export function assertStoredImageBudget(referenceCount: number): void {
|
||||
if (referenceCount > OUTBOUND_IMPORT_MAX_IMAGE_REFERENCES) {
|
||||
throw new Error(`出库图片引用总数超过限制(最多 ${OUTBOUND_IMPORT_MAX_IMAGE_REFERENCES} 张)`);
|
||||
}
|
||||
if (totalBytes > OUTBOUND_IMPORT_MAX_STORED_IMAGE_SIZE) {
|
||||
throw new Error(`出库图片按引用累计大小超过限制(最多 ${OUTBOUND_IMPORT_MAX_STORED_IMAGE_SIZE / 1024 / 1024}MB)`);
|
||||
}
|
||||
|
||||
export async function readArchiveEntryBuffer(
|
||||
entry: Pick<ArchiveStreamEntryLike, 'stream'>,
|
||||
maxBytes: number,
|
||||
overflowMessage: string,
|
||||
onProgress?: () => Promise<void>,
|
||||
): Promise<Buffer> {
|
||||
const stream = entry.stream();
|
||||
const chunks: Buffer[] = [];
|
||||
let total = 0;
|
||||
let progressBytes = 0;
|
||||
try {
|
||||
for await (const chunk of stream) {
|
||||
const data = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
||||
total += data.length;
|
||||
if (total > maxBytes) throw new Error(overflowMessage);
|
||||
chunks.push(data);
|
||||
progressBytes += data.length;
|
||||
if (onProgress && progressBytes >= ARCHIVE_PROGRESS_INTERVAL_BYTES) {
|
||||
progressBytes = 0;
|
||||
await onProgress();
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
stream.destroy();
|
||||
throw error;
|
||||
}
|
||||
return Buffer.concat(chunks, total);
|
||||
}
|
||||
|
||||
export async function assertArchiveActualSize(
|
||||
entries: ArchiveStreamEntryLike[],
|
||||
maxUncompressedSize: number,
|
||||
label: string,
|
||||
onProgress?: () => Promise<void>,
|
||||
): Promise<void> {
|
||||
let total = 0;
|
||||
let progressBytes = 0;
|
||||
for (const entry of entries) {
|
||||
const stream = entry.stream();
|
||||
try {
|
||||
for await (const chunk of stream) {
|
||||
const size = Buffer.isBuffer(chunk) ? chunk.length : Buffer.byteLength(chunk);
|
||||
total += size;
|
||||
if (total > maxUncompressedSize) throw new Error(`${label}解压后总大小超过限制`);
|
||||
progressBytes += size;
|
||||
if (onProgress && progressBytes >= ARCHIVE_PROGRESS_INTERVAL_BYTES) {
|
||||
progressBytes = 0;
|
||||
await onProgress();
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
stream.destroy();
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,14 +12,25 @@ import {
|
||||
} from '@nestjs/common';
|
||||
import { FileInterceptor } from '@nestjs/platform-express';
|
||||
import { ApiBearerAuth, ApiConsumes, ApiOperation, ApiTags } from '@nestjs/swagger';
|
||||
import { randomUUID } from 'crypto';
|
||||
import { Response } from 'express';
|
||||
import { MAX_OUTBOUND_IMPORT_SIZE, RoleType } from '@artveris/shared';
|
||||
import { mkdirSync } from 'fs';
|
||||
import { diskStorage } from 'multer';
|
||||
import { RoleType } from '@artveris/shared';
|
||||
import { OutboundService } from './outbound.service';
|
||||
import { OutboundDto } from './dto/outbound.dto';
|
||||
import { QueryImportRowsDto } from './dto/import-session.dto';
|
||||
import { Roles } from '../common/decorators/roles.decorator';
|
||||
import { CurrentUser, AuthUser } from '../common/decorators/current-user.decorator';
|
||||
import { parseBigId } from '../common/utils/bigint.util';
|
||||
import { OUTBOUND_IMPORT_TEMP_DIR, OUTBOUND_IMPORT_UPLOAD_TEMP_PREFIX } from './outbound-import.util';
|
||||
|
||||
mkdirSync(OUTBOUND_IMPORT_TEMP_DIR, { recursive: true });
|
||||
|
||||
const outboundImportDiskStorage = diskStorage({
|
||||
destination: OUTBOUND_IMPORT_TEMP_DIR,
|
||||
filename: (_req, _file, callback) => callback(null, `${OUTBOUND_IMPORT_UPLOAD_TEMP_PREFIX}${randomUUID()}.upload`),
|
||||
});
|
||||
|
||||
@ApiTags('出库与上链')
|
||||
@ApiBearerAuth()
|
||||
@@ -44,7 +55,10 @@ export class OutboundController {
|
||||
@Roles(RoleType.OPERATOR)
|
||||
@ApiOperation({ summary: '上传 ZIP 并异步解析预览' })
|
||||
@ApiConsumes('multipart/form-data')
|
||||
@UseInterceptors(FileInterceptor('file', { limits: { fileSize: MAX_OUTBOUND_IMPORT_SIZE } }))
|
||||
@UseInterceptors(FileInterceptor('file', {
|
||||
storage: outboundImportDiskStorage,
|
||||
limits: { files: 1, fields: 1, fieldSize: 128 },
|
||||
}))
|
||||
preview(
|
||||
@UploadedFile() file: Express.Multer.File,
|
||||
@Body('requestId') requestId: string | undefined,
|
||||
@@ -88,7 +102,10 @@ export class OutboundController {
|
||||
@Roles(RoleType.OPERATOR)
|
||||
@ApiOperation({ summary: '兼容旧入口:上传 ZIP 并异步解析预览' })
|
||||
@ApiConsumes('multipart/form-data')
|
||||
@UseInterceptors(FileInterceptor('file', { limits: { fileSize: MAX_OUTBOUND_IMPORT_SIZE } }))
|
||||
@UseInterceptors(FileInterceptor('file', {
|
||||
storage: outboundImportDiskStorage,
|
||||
limits: { files: 1, fields: 0 },
|
||||
}))
|
||||
import(@UploadedFile() file: Express.Multer.File, @CurrentUser() user: AuthUser) {
|
||||
return this.outboundService.startImport(file, user.id);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
import { JobStatus, JobType, RoleType } from '@artveris/shared';
|
||||
import AdmZip from 'adm-zip';
|
||||
import * as ExcelJS from 'exceljs';
|
||||
import { access, mkdtemp, rm, writeFile } from 'fs/promises';
|
||||
import { tmpdir } from 'os';
|
||||
import { join } from 'path';
|
||||
import sharp from 'sharp';
|
||||
import { JobStatus, JobType, OUTBOUND_IMPORT_COLUMNS, RoleType } from '@artveris/shared';
|
||||
import { OutboundService } from './outbound.service';
|
||||
import { OUTBOUND_IMPORT_STORAGE_TIMEOUT_MS } from './outbound-import.util';
|
||||
|
||||
function readySession(overrides: Record<string, unknown> = {}) {
|
||||
return {
|
||||
@@ -40,7 +47,7 @@ function createHarness(session = readySession()) {
|
||||
$transaction: jest.fn().mockImplementation(async (callback: (client: typeof tx) => unknown) => callback(tx)),
|
||||
};
|
||||
const storage = {
|
||||
savePrivate: jest.fn().mockResolvedValue({ key: '.private/import.zip' }),
|
||||
savePrivateFile: jest.fn().mockResolvedValue({ key: '.private/import.zip' }),
|
||||
remove: jest.fn().mockResolvedValue(undefined),
|
||||
};
|
||||
const importQueue = {
|
||||
@@ -62,7 +69,7 @@ describe('OutboundService.startPreview', () => {
|
||||
const file = {
|
||||
originalname: 'outbound.zip',
|
||||
size: 3,
|
||||
buffer: Buffer.from('zip'),
|
||||
path: 'E:\\nonexistent-artveris-test\\outbound.upload',
|
||||
} as Express.Multer.File;
|
||||
|
||||
it('persists the request, session and preview job before enqueueing', async () => {
|
||||
@@ -73,10 +80,11 @@ describe('OutboundService.startPreview', () => {
|
||||
jobId: 'preview-job',
|
||||
});
|
||||
|
||||
expect(harness.storage.savePrivate).toHaveBeenCalledWith(
|
||||
file.buffer,
|
||||
expect(harness.storage.savePrivateFile).toHaveBeenCalledWith(
|
||||
file.path,
|
||||
'outbound.zip',
|
||||
'application/zip',
|
||||
{ requestTimeoutMs: OUTBOUND_IMPORT_STORAGE_TIMEOUT_MS },
|
||||
);
|
||||
expect(harness.tx.outboundImportSession.create).toHaveBeenCalledWith({
|
||||
data: expect.objectContaining({ requestId: 'request_1234567890', fileKey: '.private/import.zip', createdBy: 7 }),
|
||||
@@ -92,6 +100,32 @@ describe('OutboundService.startPreview', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('accepts a ZIP whose declared size is larger than the former 30MB limit', async () => {
|
||||
const harness = createHarness();
|
||||
const largeFile = { ...file, size: 31 * 1024 * 1024 } as Express.Multer.File;
|
||||
|
||||
await expect(harness.service.startPreview(largeFile, 7, 'request_1234567890')).resolves.toEqual({
|
||||
sessionId: 'preview-session',
|
||||
jobId: 'preview-job',
|
||||
});
|
||||
|
||||
expect(harness.storage.savePrivateFile).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('removes the Multer disk file after the upload has been persisted', async () => {
|
||||
const harness = createHarness();
|
||||
const dir = await mkdtemp(join(tmpdir(), 'artveris-outbound-upload-test-'));
|
||||
const filePath = join(dir, 'upload.tmp');
|
||||
await writeFile(filePath, Buffer.from('zip'));
|
||||
try {
|
||||
await harness.service.startPreview({ ...file, path: filePath } as Express.Multer.File, 7, 'request_1234567890');
|
||||
|
||||
await expect(access(filePath)).rejects.toMatchObject({ code: 'ENOENT' });
|
||||
} finally {
|
||||
await rm(dir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
it('returns the persisted request when the client retries after losing the response', async () => {
|
||||
const harness = createHarness();
|
||||
harness.prisma.outboundImportSession.findUnique.mockResolvedValue({
|
||||
@@ -105,7 +139,7 @@ describe('OutboundService.startPreview', () => {
|
||||
jobId: 'existing-job',
|
||||
});
|
||||
|
||||
expect(harness.storage.savePrivate).not.toHaveBeenCalled();
|
||||
expect(harness.storage.savePrivateFile).not.toHaveBeenCalled();
|
||||
expect(harness.prisma.$transaction).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@@ -165,6 +199,55 @@ describe('OutboundService.startPreview', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('OutboundService.generateTemplate', () => {
|
||||
it('returns the maintained static ZIP with an empty import sheet and valid examples', async () => {
|
||||
const harness = createHarness();
|
||||
const res = { setHeader: jest.fn(), end: jest.fn() };
|
||||
|
||||
await harness.service.generateTemplate(res as any);
|
||||
|
||||
const archive = res.end.mock.calls[0][0] as Buffer;
|
||||
const zip = new AdmZip(archive);
|
||||
const names = zip.getEntries().filter((entry) => !entry.isDirectory).map((entry) => entry.entryName).sort();
|
||||
expect(names).toEqual([
|
||||
'images/out-001.jpg',
|
||||
'images/out-002.png',
|
||||
'images/out-003.jpg',
|
||||
'outbound-import-template.xlsx',
|
||||
'说明.txt',
|
||||
]);
|
||||
|
||||
const workbook = new ExcelJS.Workbook();
|
||||
await workbook.xlsx.load(zip.readFile('outbound-import-template.xlsx')! as unknown as ArrayBuffer);
|
||||
expect(workbook.worksheets.map((sheet) => sheet.name)).toEqual(['导入模板', '填写示例', '字段说明']);
|
||||
const importSheet = workbook.getWorksheet('导入模板')!;
|
||||
expect(importSheet.rowCount).toBe(1);
|
||||
expect(importSheet.getRow(1).values).toEqual([
|
||||
undefined,
|
||||
...OUTBOUND_IMPORT_COLUMNS.map((column) => column.header),
|
||||
]);
|
||||
expect(importSheet.getCell('A1').fill).toMatchObject({ fgColor: { argb: 'FF1F4E78' } });
|
||||
expect(importSheet.getCell('A1').font).toMatchObject({ bold: true, color: { argb: 'FFFFFFFF' } });
|
||||
expect(importSheet.views[0]).toMatchObject({ state: 'frozen', ySplit: 1 });
|
||||
const exampleSheet = workbook.getWorksheet('填写示例')!;
|
||||
expect(exampleSheet.getCell('A2').text).toMatch(/^\d{12}$/);
|
||||
expect(exampleSheet.getCell('D3').text).toContain('images/out-002.png;images/out-003.jpg');
|
||||
expect(workbook.getWorksheet('字段说明')?.rowCount).toBe(OUTBOUND_IMPORT_COLUMNS.length + 1);
|
||||
|
||||
const instructions = zip.readAsText('说明.txt');
|
||||
expect(instructions).toContain('单个 xlsx 最大 100MB');
|
||||
expect(instructions).toContain('单张图片最大 100MB');
|
||||
expect(instructions).toContain('支持 JPG、JPEG、PNG、WebP;最多 4000 万像素');
|
||||
expect(instructions).toContain('不会自动触发区块链上链');
|
||||
|
||||
await expect(sharp(zip.readFile('images/out-001.jpg')!).metadata()).resolves.toMatchObject({ format: 'jpeg' });
|
||||
await expect(sharp(zip.readFile('images/out-002.png')!).metadata()).resolves.toMatchObject({ format: 'png' });
|
||||
await expect(sharp(zip.readFile('images/out-003.jpg')!).metadata()).resolves.toMatchObject({ format: 'jpeg' });
|
||||
expect(res.setHeader).toHaveBeenCalledWith('Content-Type', 'application/zip');
|
||||
expect(res.setHeader).toHaveBeenCalledWith('Content-Length', String(archive.length));
|
||||
});
|
||||
});
|
||||
|
||||
describe('OutboundService.commitSession', () => {
|
||||
it('atomically claims a valid READY session, creates one job and enqueues it', async () => {
|
||||
const harness = createHarness();
|
||||
|
||||
@@ -2,17 +2,15 @@ import { Injectable, Logger } from '@nestjs/common';
|
||||
import { InjectQueue } from '@nestjs/bullmq';
|
||||
import { Queue } from 'bullmq';
|
||||
import { randomUUID } from 'crypto';
|
||||
import { readFile, rm } from 'fs/promises';
|
||||
import { resolve } from 'path';
|
||||
import { Response } from 'express';
|
||||
import * as ExcelJS from 'exceljs';
|
||||
import AdmZip from 'adm-zip';
|
||||
import sharp from 'sharp';
|
||||
import { Prisma, RoleType } from '@prisma/client';
|
||||
import {
|
||||
ErrorCode,
|
||||
JobStatus,
|
||||
JobType,
|
||||
MAX_OUTBOUND_IMPORT_SIZE,
|
||||
OUTBOUND_IMPORT_COLUMNS,
|
||||
QUEUE_NAMES,
|
||||
} from '@artveris/shared';
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
@@ -24,8 +22,10 @@ import { AuthUser } from '../common/decorators/current-user.decorator';
|
||||
import { OutboundDto } from './dto/outbound.dto';
|
||||
import { QueryImportRowsDto } from './dto/import-session.dto';
|
||||
import { isOutbound } from './outbound.util';
|
||||
import { OUTBOUND_IMPORT_STORAGE_TIMEOUT_MS } from './outbound-import.util';
|
||||
|
||||
const SESSION_TTL_DAYS = 2;
|
||||
const OUTBOUND_IMPORT_TEMPLATE_PATH = resolve(__dirname, '..', 'assets', 'templates', 'outbound-import-template.zip');
|
||||
|
||||
function jsonArray<T>(value: unknown): T[] {
|
||||
return Array.isArray(value) ? (value as T[]) : [];
|
||||
@@ -124,76 +124,34 @@ export class OutboundService {
|
||||
}
|
||||
|
||||
async generateTemplate(res: Response): Promise<void> {
|
||||
const wb = new ExcelJS.Workbook();
|
||||
const ws = wb.addWorksheet('导入模板');
|
||||
ws.columns = OUTBOUND_IMPORT_COLUMNS.map((c) => ({ header: c.header, key: c.key, width: c.key === 'outImages' ? 36 : 22 }));
|
||||
ws.getRow(1).font = { bold: true };
|
||||
ws.getColumn('shortCode').numFmt = '@';
|
||||
ws.addRow({
|
||||
shortCode: '请替换为真实追溯码',
|
||||
batchNo: 'B20260704001',
|
||||
outTime: '2026-07-04 10:00',
|
||||
outImages: 'images/out-001.jpg',
|
||||
remark: '单图示例',
|
||||
});
|
||||
ws.addRow({
|
||||
shortCode: '请替换为真实追溯码',
|
||||
batchNo: 'B20260704001',
|
||||
outTime: '2026-07-04 11:00',
|
||||
outImages: 'images/out-002.png;images/out-003.jpg',
|
||||
remark: '多图示例',
|
||||
});
|
||||
|
||||
const note = wb.addWorksheet('字段说明');
|
||||
note.columns = [
|
||||
{ header: '列名', key: 'header', width: 18 },
|
||||
{ header: '是否必填', key: 'required', width: 12 },
|
||||
{ header: '说明', key: 'note', width: 70 },
|
||||
];
|
||||
note.getRow(1).font = { bold: true };
|
||||
OUTBOUND_IMPORT_COLUMNS.forEach((c) =>
|
||||
note.addRow({ header: c.header, required: c.required ? '是' : '否', note: c.note }),
|
||||
);
|
||||
|
||||
const zip = new AdmZip();
|
||||
zip.addFile('outbound-import-template.xlsx', Buffer.from(await wb.xlsx.writeBuffer()));
|
||||
zip.addFile(
|
||||
'说明.txt',
|
||||
Buffer.from(
|
||||
[
|
||||
'出库批量导入说明',
|
||||
'',
|
||||
'1. ZIP 根目录必须包含一个 xlsx 文件和 images 文件夹。',
|
||||
'2. 出库实况图路径填写 images/xxx.jpg,多张图片使用英文分号 ; 分隔。',
|
||||
'3. 不允许使用绝对路径、..、反斜杠或 images 目录之外的路径。',
|
||||
'4. 上传 ZIP 后系统会先预览校验,确认无误后才正式导入。',
|
||||
'5. 链上哈希、存证链接和上链时间由天河链接口返回后自动写入,不在导入模板中手工填写。',
|
||||
].join('\r\n'),
|
||||
'utf8',
|
||||
),
|
||||
);
|
||||
zip.addFile('images/out-001.jpg', await this.sampleImage('#13a8a8'));
|
||||
zip.addFile('images/out-002.png', await this.sampleImage('#3b82f6', 'png'));
|
||||
zip.addFile('images/out-003.jpg', await this.sampleImage('#f59e0b'));
|
||||
let archive: Buffer;
|
||||
try {
|
||||
archive = await readFile(OUTBOUND_IMPORT_TEMPLATE_PATH);
|
||||
} catch (error) {
|
||||
this.logger.error(`读取出库导入模板失败:${(error as Error).message}`);
|
||||
throw new BusinessException(ErrorCode.INTERNAL_ERROR, '出库导入模板暂不可用');
|
||||
}
|
||||
|
||||
res.setHeader('Content-Type', 'application/zip');
|
||||
res.setHeader('Content-Disposition', 'attachment; filename="outbound-import-template.zip"');
|
||||
res.end(zip.toBuffer());
|
||||
}
|
||||
|
||||
private sampleImage(color: string, format: 'jpeg' | 'png' = 'jpeg') {
|
||||
const img = sharp({
|
||||
create: {
|
||||
width: 720,
|
||||
height: 480,
|
||||
channels: 3,
|
||||
background: color,
|
||||
},
|
||||
});
|
||||
return format === 'png' ? img.png().toBuffer() : img.jpeg({ quality: 86 }).toBuffer();
|
||||
res.setHeader('Content-Length', String(archive.length));
|
||||
res.setHeader('Cache-Control', 'no-cache');
|
||||
res.end(archive);
|
||||
}
|
||||
|
||||
async startPreview(file: Express.Multer.File, userId: number, requestId?: string) {
|
||||
try {
|
||||
return await this.startPreviewFromUpload(file, userId, requestId);
|
||||
} finally {
|
||||
if (file?.path) {
|
||||
await rm(file.path, { force: true }).catch((error) =>
|
||||
this.logger.warn(`清理出库导入上传临时文件失败:${file.path} ${(error as Error).message}`),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async startPreviewFromUpload(file: Express.Multer.File, userId: number, requestId?: string) {
|
||||
const normalizedRequestId = (requestId || '').trim();
|
||||
if (normalizedRequestId && !/^[A-Za-z0-9_-]{16,64}$/.test(normalizedRequestId)) {
|
||||
throw new BusinessException(ErrorCode.BAD_REQUEST, '导入请求标识格式无效');
|
||||
@@ -209,13 +167,14 @@ export class OutboundService {
|
||||
if (!file) throw new BusinessException(ErrorCode.BAD_REQUEST, '请上传导入 ZIP 文件');
|
||||
const name = (file.originalname || '').toLowerCase();
|
||||
if (!name.endsWith('.zip')) throw new BusinessException(ErrorCode.FILE_TYPE_NOT_ALLOWED, '仅支持 ZIP 文件');
|
||||
const fileSize = file.size || file.buffer?.length || 0;
|
||||
const fileSize = file.size || 0;
|
||||
if (!fileSize) throw new BusinessException(ErrorCode.BAD_REQUEST, '导入 ZIP 文件不能为空');
|
||||
if (fileSize > MAX_OUTBOUND_IMPORT_SIZE) throw new BusinessException(ErrorCode.FILE_TOO_LARGE, 'ZIP 文件不能超过 30MB');
|
||||
const saved = await this.storage.savePrivate(
|
||||
file.buffer,
|
||||
if (!file.path) throw new BusinessException(ErrorCode.INTERNAL_ERROR, '导入 ZIP 临时文件不存在');
|
||||
const saved = await this.storage.savePrivateFile(
|
||||
file.path,
|
||||
file.originalname || 'outbound-import.zip',
|
||||
'application/zip',
|
||||
{ requestTimeoutMs: OUTBOUND_IMPORT_STORAGE_TIMEOUT_MS },
|
||||
);
|
||||
let created: { sessionId: string; jobId: string; fileKey: string };
|
||||
try {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { mkdtempSync, rmSync } from 'fs';
|
||||
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
import { tmpdir } from 'os';
|
||||
import { LocalDriver } from './local.driver';
|
||||
@@ -39,4 +39,28 @@ describe('LocalDriver', () => {
|
||||
'https://cdn.example.com/assets/2026/07/file.jpg',
|
||||
);
|
||||
});
|
||||
|
||||
it('copies large-file uploads and downloads through disk paths', async () => {
|
||||
const driver = createDriver();
|
||||
const workingDir = mkdtempSync(join(tmpdir(), 'artveris-storage-stream-'));
|
||||
tempDirs.push(workingDir);
|
||||
const source = join(workingDir, 'source.zip');
|
||||
const target = join(workingDir, 'target.zip');
|
||||
writeFileSync(source, Buffer.from('streamed-zip'));
|
||||
|
||||
await driver.putFile('.private/import.zip', source, 12);
|
||||
await driver.getFile('.private/import.zip', target);
|
||||
|
||||
expect(readFileSync(target).toString()).toBe('streamed-zip');
|
||||
});
|
||||
|
||||
it('copies a stored file without removing the source', async () => {
|
||||
const driver = createDriver();
|
||||
await driver.put('temp/source.jpg', Buffer.from('image'));
|
||||
|
||||
await driver.copy('temp/source.jpg', 'final/copied.jpg');
|
||||
|
||||
await expect(driver.get('temp/source.jpg')).resolves.toEqual(Buffer.from('image'));
|
||||
await expect(driver.get('final/copied.jpg')).resolves.toEqual(Buffer.from('image'));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { existsSync, mkdirSync, readdirSync, statSync, writeFileSync, rmSync, readFileSync } from 'fs';
|
||||
import { existsSync } from 'fs';
|
||||
import { copyFile, mkdir, readFile, readdir, rm, writeFile } from 'fs/promises';
|
||||
import { dirname, join, relative, resolve } from 'path';
|
||||
import { PutOptions, StorageDriver } from './storage.types';
|
||||
import { PutOptions, StorageDriver, StorageRequestOptions } from './storage.types';
|
||||
|
||||
export interface LocalDriverOptions {
|
||||
localDir: string;
|
||||
@@ -27,36 +28,49 @@ export class LocalDriver implements StorageDriver {
|
||||
|
||||
async put(key: string, buffer: Buffer, _options?: PutOptions): Promise<void> {
|
||||
const full = this.fullPath(key);
|
||||
mkdirSync(dirname(full), { recursive: true });
|
||||
writeFileSync(full, buffer);
|
||||
await mkdir(dirname(full), { recursive: true });
|
||||
await writeFile(full, buffer);
|
||||
}
|
||||
|
||||
async get(key: string): Promise<Buffer> {
|
||||
return readFileSync(this.fullPath(key));
|
||||
async putFile(key: string, filePath: string, _size: number, _options?: PutOptions): Promise<void> {
|
||||
const full = this.fullPath(key);
|
||||
await mkdir(dirname(full), { recursive: true });
|
||||
await copyFile(filePath, full);
|
||||
}
|
||||
|
||||
async copy(sourceKey: string, targetKey: string, _options?: PutOptions): Promise<void> {
|
||||
const target = this.fullPath(targetKey);
|
||||
await mkdir(dirname(target), { recursive: true });
|
||||
await copyFile(this.fullPath(sourceKey), target);
|
||||
}
|
||||
|
||||
async get(key: string, _options?: StorageRequestOptions): Promise<Buffer> {
|
||||
return readFile(this.fullPath(key));
|
||||
}
|
||||
|
||||
async getFile(key: string, filePath: string, _options?: StorageRequestOptions): Promise<void> {
|
||||
await mkdir(dirname(filePath), { recursive: true });
|
||||
await copyFile(this.fullPath(key), filePath);
|
||||
}
|
||||
|
||||
async remove(key: string): Promise<void> {
|
||||
const full = this.fullPath(key);
|
||||
if (existsSync(full)) {
|
||||
rmSync(full, { force: true });
|
||||
}
|
||||
await rm(this.fullPath(key), { force: true });
|
||||
}
|
||||
|
||||
async list(): Promise<string[]> {
|
||||
if (!existsSync(this.root)) return [];
|
||||
const keys: string[] = [];
|
||||
const walk = (dir: string) => {
|
||||
for (const name of readdirSync(dir)) {
|
||||
const full = join(dir, name);
|
||||
const st = statSync(full);
|
||||
if (st.isDirectory()) {
|
||||
walk(full);
|
||||
const walk = async (dir: string): Promise<void> => {
|
||||
for (const entry of await readdir(dir, { withFileTypes: true })) {
|
||||
const full = join(dir, entry.name);
|
||||
if (entry.isDirectory()) {
|
||||
await walk(full);
|
||||
} else {
|
||||
keys.push(relative(this.root, full).replace(/\\/g, '/'));
|
||||
}
|
||||
}
|
||||
};
|
||||
walk(this.root);
|
||||
await walk(this.root);
|
||||
return keys;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
import { Upload } from '@aws-sdk/lib-storage';
|
||||
import { OssDriver } from './oss.driver';
|
||||
|
||||
jest.mock('@aws-sdk/lib-storage', () => ({ Upload: jest.fn() }));
|
||||
|
||||
describe('OssDriver request timeout', () => {
|
||||
beforeEach(() => jest.clearAllMocks());
|
||||
afterEach(() => jest.useRealTimers());
|
||||
|
||||
it('aborts a storage request that never returns', async () => {
|
||||
jest.useFakeTimers();
|
||||
const driver = new OssDriver({
|
||||
function createDriver(): OssDriver {
|
||||
return new OssDriver({
|
||||
endpoint: 'http://127.0.0.1:9000',
|
||||
region: 'us-east-1',
|
||||
bucket: 'artveris',
|
||||
@@ -13,6 +16,11 @@ describe('OssDriver request timeout', () => {
|
||||
accessKeySecret: 'test',
|
||||
cdnBaseUrl: '',
|
||||
});
|
||||
}
|
||||
|
||||
it('aborts a storage request that never returns', async () => {
|
||||
jest.useFakeTimers();
|
||||
const driver = createDriver();
|
||||
(driver as any).client.send = jest.fn((_command: unknown, options: { abortSignal: AbortSignal }) =>
|
||||
new Promise((_resolve, reject) => {
|
||||
options.abortSignal.addEventListener('abort', () => reject(new Error('request aborted')));
|
||||
@@ -25,4 +33,91 @@ describe('OssDriver request timeout', () => {
|
||||
|
||||
await assertion;
|
||||
});
|
||||
|
||||
it('honors a longer timeout for a large private import', async () => {
|
||||
jest.useFakeTimers();
|
||||
const driver = createDriver();
|
||||
let signal: AbortSignal | undefined;
|
||||
(driver as any).client.send = jest.fn((_command: unknown, options: { abortSignal: AbortSignal }) => {
|
||||
signal = options.abortSignal;
|
||||
return new Promise((_resolve, reject) => {
|
||||
options.abortSignal.addEventListener('abort', () => reject(new Error('request aborted')));
|
||||
});
|
||||
});
|
||||
|
||||
const upload = driver.put('large.zip', Buffer.from('zip'), { requestTimeoutMs: 120_000 });
|
||||
const assertion = expect(upload).rejects.toThrow('request aborted');
|
||||
await jest.advanceTimersByTimeAsync(60_000);
|
||||
expect(signal?.aborted).toBe(false);
|
||||
await jest.advanceTimersByTimeAsync(60_000);
|
||||
|
||||
await assertion;
|
||||
});
|
||||
|
||||
it('uses managed multipart upload for a file-backed private import', async () => {
|
||||
const done = jest.fn().mockResolvedValue(undefined);
|
||||
(Upload as unknown as jest.Mock).mockImplementationOnce(() => ({ done }));
|
||||
const driver = createDriver();
|
||||
|
||||
await driver.putFile('large.zip', __filename, 6 * 1024 * 1024, {
|
||||
contentType: 'application/zip',
|
||||
visibility: 'private',
|
||||
requestTimeoutMs: 3_600_000,
|
||||
});
|
||||
|
||||
expect(Upload).toHaveBeenCalledWith(expect.objectContaining({
|
||||
client: expect.any(Object),
|
||||
queueSize: 2,
|
||||
leavePartsOnError: false,
|
||||
abortController: expect.any(AbortController),
|
||||
params: expect.objectContaining({
|
||||
Bucket: 'artveris',
|
||||
Key: 'large.zip',
|
||||
ContentLength: 6 * 1024 * 1024,
|
||||
ContentType: 'application/zip',
|
||||
ACL: 'private',
|
||||
}),
|
||||
}));
|
||||
expect(done).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('aborts a multipart upload when its extended timeout expires', async () => {
|
||||
jest.useFakeTimers();
|
||||
(Upload as unknown as jest.Mock).mockImplementationOnce(({ abortController }) => ({
|
||||
done: () => new Promise((_resolve, reject) => {
|
||||
abortController.signal.addEventListener('abort', () => reject(new Error('multipart aborted')));
|
||||
}),
|
||||
}));
|
||||
const driver = createDriver();
|
||||
|
||||
const upload = driver.putFile('large.zip', __filename, 6 * 1024 * 1024, { requestTimeoutMs: 120_000 });
|
||||
const assertion = expect(upload).rejects.toThrow('multipart aborted');
|
||||
await jest.advanceTimersByTimeAsync(60_000);
|
||||
expect(((Upload as unknown as jest.Mock).mock.calls[0][0].abortController as AbortController).signal.aborted).toBe(false);
|
||||
await jest.advanceTimersByTimeAsync(60_000);
|
||||
|
||||
await assertion;
|
||||
});
|
||||
|
||||
it('copies an object server-side with an encoded source key and caller timeout', async () => {
|
||||
const driver = createDriver();
|
||||
const send = jest.fn().mockResolvedValue({});
|
||||
(driver as any).client.send = send;
|
||||
|
||||
await driver.copy('临时/a b.jpg', 'final/image.jpg', {
|
||||
contentType: 'image/jpeg',
|
||||
cacheControl: 'public, max-age=31536000, immutable',
|
||||
requestTimeoutMs: 3_600_000,
|
||||
});
|
||||
|
||||
const command = send.mock.calls[0][0];
|
||||
expect(command.constructor.name).toBe('CopyObjectCommand');
|
||||
expect(command.input).toMatchObject({
|
||||
Bucket: 'artveris',
|
||||
Key: 'final/image.jpg',
|
||||
CopySource: 'artveris/%E4%B8%B4%E6%97%B6/a%20b.jpg',
|
||||
MetadataDirective: 'REPLACE',
|
||||
ContentType: 'image/jpeg',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
import {
|
||||
CopyObjectCommand,
|
||||
DeleteObjectCommand,
|
||||
GetObjectCommand,
|
||||
ListObjectsV2Command,
|
||||
PutObjectCommand,
|
||||
S3Client,
|
||||
} from '@aws-sdk/client-s3';
|
||||
import { PutOptions, StorageDriver } from './storage.types';
|
||||
import { Upload } from '@aws-sdk/lib-storage';
|
||||
import { createReadStream, createWriteStream } from 'fs';
|
||||
import { pipeline } from 'stream/promises';
|
||||
import { PutOptions, StorageDriver, StorageRequestOptions } from './storage.types';
|
||||
|
||||
export interface OssDriverOptions {
|
||||
endpoint: string;
|
||||
@@ -27,6 +31,7 @@ export class OssDriver implements StorageDriver {
|
||||
region: opts.region || 'us-east-1',
|
||||
endpoint: opts.endpoint || undefined,
|
||||
forcePathStyle: true,
|
||||
requestChecksumCalculation: 'WHEN_REQUIRED',
|
||||
credentials: {
|
||||
accessKeyId: opts.accessKeyId,
|
||||
secretAccessKey: opts.accessKeySecret,
|
||||
@@ -34,11 +39,14 @@ export class OssDriver implements StorageDriver {
|
||||
});
|
||||
}
|
||||
|
||||
private async withRequestTimeout<T>(operation: (signal: AbortSignal) => Promise<T>): Promise<T> {
|
||||
private async withRequestTimeout<T>(
|
||||
operation: (signal: AbortSignal, controller: AbortController) => Promise<T>,
|
||||
timeoutMs = this.requestTimeoutMs,
|
||||
): Promise<T> {
|
||||
const controller = new AbortController();
|
||||
const timer = setTimeout(() => controller.abort(), this.requestTimeoutMs);
|
||||
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
||||
try {
|
||||
return await operation(controller.signal);
|
||||
return await operation(controller.signal, controller);
|
||||
} finally {
|
||||
clearTimeout(timer);
|
||||
}
|
||||
@@ -55,10 +63,47 @@ export class OssDriver implements StorageDriver {
|
||||
ACL: options?.visibility === 'private' ? 'private' : undefined,
|
||||
}),
|
||||
{ abortSignal },
|
||||
));
|
||||
), options?.requestTimeoutMs);
|
||||
}
|
||||
|
||||
async get(key: string): Promise<Buffer> {
|
||||
async putFile(key: string, filePath: string, size: number, options?: PutOptions): Promise<void> {
|
||||
await this.withRequestTimeout(async (_abortSignal, abortController) => {
|
||||
const upload = new Upload({
|
||||
client: this.client,
|
||||
params: {
|
||||
Bucket: this.opts.bucket,
|
||||
Key: key,
|
||||
Body: createReadStream(filePath),
|
||||
ContentLength: size,
|
||||
ContentType: options?.contentType,
|
||||
CacheControl: options?.cacheControl,
|
||||
ACL: options?.visibility === 'private' ? 'private' : undefined,
|
||||
},
|
||||
queueSize: 2,
|
||||
leavePartsOnError: false,
|
||||
abortController,
|
||||
});
|
||||
await upload.done();
|
||||
}, options?.requestTimeoutMs);
|
||||
}
|
||||
|
||||
async copy(sourceKey: string, targetKey: string, options?: PutOptions): Promise<void> {
|
||||
const copySource = `${encodeURIComponent(this.opts.bucket)}/${sourceKey.split('/').map(encodeURIComponent).join('/')}`;
|
||||
await this.withRequestTimeout((abortSignal) => this.client.send(
|
||||
new CopyObjectCommand({
|
||||
Bucket: this.opts.bucket,
|
||||
Key: targetKey,
|
||||
CopySource: copySource,
|
||||
MetadataDirective: 'REPLACE',
|
||||
ContentType: options?.contentType,
|
||||
CacheControl: options?.cacheControl,
|
||||
ACL: options?.visibility === 'private' ? 'private' : undefined,
|
||||
}),
|
||||
{ abortSignal },
|
||||
), options?.requestTimeoutMs);
|
||||
}
|
||||
|
||||
async get(key: string, options?: StorageRequestOptions): Promise<Buffer> {
|
||||
return this.withRequestTimeout(async (abortSignal) => {
|
||||
const res = await this.client.send(
|
||||
new GetObjectCommand({ Bucket: this.opts.bucket, Key: key }),
|
||||
@@ -66,7 +111,17 @@ export class OssDriver implements StorageDriver {
|
||||
);
|
||||
const bytes = await res.Body!.transformToByteArray();
|
||||
return Buffer.from(bytes);
|
||||
});
|
||||
}, options?.requestTimeoutMs);
|
||||
}
|
||||
|
||||
async getFile(key: string, filePath: string, options?: StorageRequestOptions): Promise<void> {
|
||||
await this.withRequestTimeout(async (abortSignal) => {
|
||||
const res = await this.client.send(
|
||||
new GetObjectCommand({ Bucket: this.opts.bucket, Key: key }),
|
||||
{ abortSignal },
|
||||
);
|
||||
await pipeline(res.Body as NodeJS.ReadableStream, createWriteStream(filePath));
|
||||
}, options?.requestTimeoutMs);
|
||||
}
|
||||
|
||||
async remove(key: string): Promise<void> {
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
import { StorageService } from './storage.service';
|
||||
import { mkdtemp, rm, writeFile } from 'fs/promises';
|
||||
import { tmpdir } from 'os';
|
||||
import { join } from 'path';
|
||||
|
||||
function createHarness() {
|
||||
const config = {
|
||||
@@ -10,7 +13,10 @@ function createHarness() {
|
||||
const service = new StorageService(config as any, settings as any);
|
||||
const driver = {
|
||||
get: jest.fn().mockResolvedValue(Buffer.from('image')),
|
||||
getFile: jest.fn().mockResolvedValue(undefined),
|
||||
put: jest.fn().mockResolvedValue(undefined),
|
||||
putFile: jest.fn().mockResolvedValue(undefined),
|
||||
copy: jest.fn().mockResolvedValue(undefined),
|
||||
remove: jest.fn().mockResolvedValue(undefined),
|
||||
getPublicUrl: jest.fn((key: string) => `/uploads/${key}`),
|
||||
};
|
||||
@@ -31,22 +37,23 @@ describe('StorageService.copyMedia', () => {
|
||||
|
||||
const target = copied.keyMap.get('temp/source.jpg');
|
||||
expect(target).toMatch(/^1\/archive\/code\/出库实况_/);
|
||||
expect(driver.get).toHaveBeenCalledWith('temp/source.jpg');
|
||||
expect(driver.put).toHaveBeenCalledWith(target, expect.any(Buffer), expect.any(Object));
|
||||
expect(driver.copy).toHaveBeenCalledWith('temp/source.jpg', target, expect.any(Object));
|
||||
expect(driver.get).not.toHaveBeenCalled();
|
||||
expect(driver.put).not.toHaveBeenCalled();
|
||||
expect(driver.remove).not.toHaveBeenCalledWith('temp/source.jpg');
|
||||
});
|
||||
|
||||
it('cleans copied destinations when a later image copy fails', async () => {
|
||||
const { service, driver } = createHarness();
|
||||
driver.get.mockResolvedValueOnce(Buffer.from('first')).mockRejectedValueOnce(new Error('read failed'));
|
||||
driver.copy.mockResolvedValueOnce(undefined).mockRejectedValueOnce(new Error('copy failed'));
|
||||
|
||||
await expect(service.copyMedia(
|
||||
[{ key: 'temp/first.jpg' }, { key: 'temp/second.jpg' }],
|
||||
'1/archive/code',
|
||||
'出库实况',
|
||||
)).rejects.toThrow('read failed');
|
||||
)).rejects.toThrow('copy failed');
|
||||
|
||||
const copiedTarget = driver.put.mock.calls[0][0];
|
||||
const copiedTarget = driver.copy.mock.calls[0][1];
|
||||
expect(driver.remove).toHaveBeenCalledWith(copiedTarget);
|
||||
expect(driver.remove.mock.calls.map(([key]) => key)).toHaveLength(2);
|
||||
expect(driver.remove).not.toHaveBeenCalledWith('temp/first.jpg');
|
||||
@@ -56,9 +63,8 @@ describe('StorageService.copyMedia', () => {
|
||||
it('publishes every destination key before the first storage copy begins', async () => {
|
||||
const { service, driver } = createHarness();
|
||||
const events: string[] = [];
|
||||
driver.get.mockImplementation(async (key: string) => {
|
||||
events.push(`read:${key}`);
|
||||
return Buffer.from(key);
|
||||
driver.copy.mockImplementation(async (key: string) => {
|
||||
events.push(`copy:${key}`);
|
||||
});
|
||||
|
||||
await service.copyMedia(
|
||||
@@ -72,7 +78,7 @@ describe('StorageService.copyMedia', () => {
|
||||
);
|
||||
|
||||
expect(events[0]).toBe('planned:2');
|
||||
expect(events.slice(1)).toEqual(['read:temp/first.jpg', 'read:temp/second.jpg']);
|
||||
expect(events.slice(1)).toEqual(['copy:temp/first.jpg', 'copy:temp/second.jpg']);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -91,6 +97,49 @@ describe('StorageService.savePrivate', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('streams a private import from disk without loading it into a Buffer', async () => {
|
||||
const { service, driver } = createHarness();
|
||||
const dir = await mkdtemp(join(tmpdir(), 'artveris-storage-test-'));
|
||||
const filePath = join(dir, 'import.zip');
|
||||
await writeFile(filePath, Buffer.from('large-zip-placeholder'));
|
||||
try {
|
||||
const saved = await service.savePrivateFile(
|
||||
filePath,
|
||||
'import.zip',
|
||||
'application/zip',
|
||||
{ requestTimeoutMs: 3_600_000 },
|
||||
);
|
||||
|
||||
expect(saved).toMatchObject({ url: '', size: 21, mime: 'application/zip' });
|
||||
expect(driver.putFile).toHaveBeenCalledWith(
|
||||
saved.key,
|
||||
filePath,
|
||||
21,
|
||||
expect.objectContaining({ visibility: 'private', requestTimeoutMs: 3_600_000 }),
|
||||
);
|
||||
expect(driver.put).not.toHaveBeenCalled();
|
||||
} finally {
|
||||
await rm(dir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
it('passes an extended request timeout only when the caller requests it', async () => {
|
||||
const { service, driver } = createHarness();
|
||||
|
||||
const saved = await service.savePrivate(
|
||||
Buffer.from('zip'),
|
||||
'import.zip',
|
||||
'application/zip',
|
||||
{ requestTimeoutMs: 3_600_000 },
|
||||
);
|
||||
|
||||
expect(driver.put).toHaveBeenCalledWith(
|
||||
saved.key,
|
||||
expect.any(Buffer),
|
||||
expect.objectContaining({ requestTimeoutMs: 3_600_000 }),
|
||||
);
|
||||
});
|
||||
|
||||
it('preserves private visibility when restoring a private storage key', async () => {
|
||||
const { service, driver } = createHarness();
|
||||
|
||||
@@ -119,7 +168,7 @@ describe('StorageService.savePrivate', () => {
|
||||
describe('StorageService.relocateMedia', () => {
|
||||
it('does not delete any source when copying the media set fails', async () => {
|
||||
const { service, driver } = createHarness();
|
||||
driver.get.mockResolvedValueOnce(Buffer.from('first')).mockRejectedValueOnce(new Error('missing source'));
|
||||
driver.copy.mockResolvedValueOnce(undefined).mockRejectedValueOnce(new Error('missing source'));
|
||||
|
||||
await expect(service.relocateMedia(
|
||||
[{ key: 'temp/first.jpg' }, { key: 'temp/missing.jpg' }],
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
import { Injectable, Logger, OnModuleInit } from '@nestjs/common';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { createHash } from 'crypto';
|
||||
import { createReadStream } from 'fs';
|
||||
import { stat } from 'fs/promises';
|
||||
import dayjs from 'dayjs';
|
||||
import { nanoid } from 'nanoid';
|
||||
import { extname } from 'path';
|
||||
import { SettingsService } from '../settings/settings.service';
|
||||
import { LocalDriver } from './local.driver';
|
||||
import { OssDriver } from './oss.driver';
|
||||
import { SavedFile, StorageDriver } from './storage.types';
|
||||
import { SavedFile, StorageDriver, StorageRequestOptions } from './storage.types';
|
||||
|
||||
export const STATIC_ASSET_CACHE_CONTROL = 'public, max-age=31536000, immutable';
|
||||
const STORAGE_EXCLUSIVE_WAIT_MS = 120_000;
|
||||
@@ -173,13 +175,25 @@ export class StorageService implements OnModuleInit {
|
||||
return `${dayjs().format('YYYY/MM/DD')}/${hash.slice(0, 16)}-${nanoid()}${ext}`;
|
||||
}
|
||||
|
||||
async save(buffer: Buffer, originalName: string, mime?: string): Promise<SavedFile> {
|
||||
private async buildFileHash(filePath: string): Promise<string> {
|
||||
const hash = createHash('sha256');
|
||||
for await (const chunk of createReadStream(filePath)) hash.update(chunk as Buffer);
|
||||
return hash.digest('hex');
|
||||
}
|
||||
|
||||
async save(
|
||||
buffer: Buffer,
|
||||
originalName: string,
|
||||
mime?: string,
|
||||
requestOptions: StorageRequestOptions = {},
|
||||
): Promise<SavedFile> {
|
||||
const hash = this.buildHash(buffer);
|
||||
const key = this.buildKey(originalName, hash, mime);
|
||||
const url = await this.withDriverOperation(async (driver) => {
|
||||
await driver.put(key, buffer, {
|
||||
contentType: mime || storageContentType(key),
|
||||
cacheControl: STATIC_ASSET_CACHE_CONTROL,
|
||||
...requestOptions,
|
||||
});
|
||||
return driver.getPublicUrl(key);
|
||||
});
|
||||
@@ -193,13 +207,19 @@ export class StorageService implements OnModuleInit {
|
||||
};
|
||||
}
|
||||
|
||||
async savePrivate(buffer: Buffer, originalName: string, mime?: string): Promise<SavedFile> {
|
||||
async savePrivate(
|
||||
buffer: Buffer,
|
||||
originalName: string,
|
||||
mime?: string,
|
||||
requestOptions: StorageRequestOptions = {},
|
||||
): Promise<SavedFile> {
|
||||
const hash = this.buildHash(buffer);
|
||||
const key = `.private/${this.buildKey(originalName, hash, mime)}`;
|
||||
await this.withDriverOperation((driver) => driver.put(key, buffer, {
|
||||
contentType: mime || storageContentType(key),
|
||||
cacheControl: 'private, no-store',
|
||||
visibility: 'private',
|
||||
...requestOptions,
|
||||
}));
|
||||
return {
|
||||
key,
|
||||
@@ -211,6 +231,31 @@ export class StorageService implements OnModuleInit {
|
||||
};
|
||||
}
|
||||
|
||||
async savePrivateFile(
|
||||
filePath: string,
|
||||
originalName: string,
|
||||
mime?: string,
|
||||
requestOptions: StorageRequestOptions = {},
|
||||
): Promise<SavedFile> {
|
||||
const file = await stat(filePath);
|
||||
const hash = await this.buildFileHash(filePath);
|
||||
const key = `.private/${this.buildKey(originalName, hash, mime)}`;
|
||||
await this.withDriverOperation((driver) => driver.putFile(key, filePath, file.size, {
|
||||
contentType: mime || storageContentType(key),
|
||||
cacheControl: 'private, no-store',
|
||||
visibility: 'private',
|
||||
...requestOptions,
|
||||
}));
|
||||
return {
|
||||
key,
|
||||
url: '',
|
||||
name: originalName,
|
||||
size: file.size,
|
||||
mime: mime || 'application/octet-stream',
|
||||
hash,
|
||||
};
|
||||
}
|
||||
|
||||
async putKey(key: string, buffer: Buffer, mime?: string): Promise<string> {
|
||||
const isPrivate = key.startsWith('.private/');
|
||||
return this.withDriverOperation(async (driver) => {
|
||||
@@ -229,15 +274,13 @@ export class StorageService implements OnModuleInit {
|
||||
return `${base}_${suffix}${ext || '.jpg'}`;
|
||||
}
|
||||
|
||||
async copyKey(oldKey: string, newKey: string): Promise<string> {
|
||||
async copyKey(oldKey: string, newKey: string, requestOptions: StorageRequestOptions = {}): Promise<string> {
|
||||
if (!oldKey || oldKey === newKey) return oldKey;
|
||||
await this.withDriverOperation(async (driver) => {
|
||||
const buffer = await driver.get(oldKey);
|
||||
await driver.put(newKey, buffer, {
|
||||
contentType: storageContentType(newKey),
|
||||
cacheControl: STATIC_ASSET_CACHE_CONTROL,
|
||||
});
|
||||
});
|
||||
await this.withDriverOperation((driver) => driver.copy(oldKey, newKey, {
|
||||
contentType: storageContentType(newKey),
|
||||
cacheControl: STATIC_ASSET_CACHE_CONTROL,
|
||||
...requestOptions,
|
||||
}));
|
||||
return newKey;
|
||||
}
|
||||
|
||||
@@ -285,12 +328,13 @@ export class StorageService implements OnModuleInit {
|
||||
dir: string,
|
||||
baseName: string,
|
||||
onPlanned?: (targetKeys: string[]) => Promise<void>,
|
||||
requestOptions: StorageRequestOptions = {},
|
||||
): Promise<{ items: T[]; changed: boolean; keyMap: Map<string, string> }> {
|
||||
return this.organizeMedia(
|
||||
items,
|
||||
dir,
|
||||
baseName,
|
||||
(oldKey, newKey) => this.copyKey(oldKey, newKey),
|
||||
(oldKey, newKey) => this.copyKey(oldKey, newKey, requestOptions),
|
||||
onPlanned,
|
||||
);
|
||||
}
|
||||
@@ -354,8 +398,12 @@ export class StorageService implements OnModuleInit {
|
||||
return this.driver.getPublicUrl(key);
|
||||
}
|
||||
|
||||
read(key: string): Promise<Buffer> {
|
||||
return this.withDriverOperation((driver) => driver.get(key));
|
||||
read(key: string, requestOptions?: StorageRequestOptions): Promise<Buffer> {
|
||||
return this.withDriverOperation((driver) => driver.get(key, requestOptions));
|
||||
}
|
||||
|
||||
downloadToFile(key: string, filePath: string, requestOptions?: StorageRequestOptions): Promise<void> {
|
||||
return this.withDriverOperation((driver) => driver.getFile(key, filePath, requestOptions));
|
||||
}
|
||||
|
||||
async remove(key: string): Promise<void> {
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
export interface PutOptions {
|
||||
export interface StorageRequestOptions {
|
||||
requestTimeoutMs?: number;
|
||||
}
|
||||
|
||||
export interface PutOptions extends StorageRequestOptions {
|
||||
contentType?: string;
|
||||
cacheControl?: string;
|
||||
visibility?: 'public' | 'private';
|
||||
@@ -6,7 +10,10 @@ export interface PutOptions {
|
||||
|
||||
export interface StorageDriver {
|
||||
put(key: string, buffer: Buffer, options?: PutOptions): Promise<void>;
|
||||
get(key: string): Promise<Buffer>;
|
||||
putFile(key: string, filePath: string, size: number, options?: PutOptions): Promise<void>;
|
||||
copy(sourceKey: string, targetKey: string, options?: PutOptions): Promise<void>;
|
||||
get(key: string, options?: StorageRequestOptions): Promise<Buffer>;
|
||||
getFile(key: string, filePath: string, options?: StorageRequestOptions): Promise<void>;
|
||||
remove(key: string): Promise<void>;
|
||||
getPublicUrl(key: string): string;
|
||||
list?(): Promise<string[]>;
|
||||
|
||||
@@ -18,6 +18,9 @@
|
||||
"lint": "pnpm -r lint"
|
||||
},
|
||||
"pnpm": {
|
||||
"overrides": {
|
||||
"multer": "2.2.0"
|
||||
},
|
||||
"onlyBuiltDependencies": [
|
||||
"@prisma/client",
|
||||
"@prisma/engines",
|
||||
|
||||
@@ -14,7 +14,6 @@ export const TRACE_CODE_PATTERN = /^\d{12}$/;
|
||||
export const MAX_IMAGE_SIZE = 10 * 1024 * 1024;
|
||||
export const MAX_VIDEO_SIZE = 100 * 1024 * 1024;
|
||||
export const MAX_FILE_SIZE = 20 * 1024 * 1024;
|
||||
export const MAX_OUTBOUND_IMPORT_SIZE = 30 * 1024 * 1024;
|
||||
// 不允许上传 SVG:SVG 可内嵌脚本,从同源 /uploads 直接打开会造成存储型 XSS。
|
||||
// 内置默认图标是打包进前端的静态 svg(/admin、/trace 下),不经上传,不受影响。
|
||||
export const ALLOWED_IMAGE_TYPES = ['image/jpeg', 'image/png', 'image/webp', 'image/gif'];
|
||||
@@ -26,7 +25,6 @@ export interface ImportColumn {
|
||||
header: string;
|
||||
required: boolean;
|
||||
note: string;
|
||||
example: string;
|
||||
}
|
||||
|
||||
export const OUTBOUND_IMPORT_COLUMNS: ImportColumn[] = [
|
||||
@@ -35,34 +33,29 @@ export const OUTBOUND_IMPORT_COLUMNS: ImportColumn[] = [
|
||||
header: '追溯码',
|
||||
required: true,
|
||||
note: '必填,生码导出文件中的追溯码,定位到具体一件作品。',
|
||||
example: '482630790612',
|
||||
},
|
||||
{
|
||||
key: 'batchNo',
|
||||
header: '批次编号',
|
||||
required: false,
|
||||
note: '选填,仅作核对;与该码实际批次不符则该行失败。',
|
||||
example: 'B20240601',
|
||||
},
|
||||
{
|
||||
key: 'outTime',
|
||||
header: '出库时间',
|
||||
required: true,
|
||||
note: '必填,中国标准时间,格式 YYYY-MM-DD HH:mm。',
|
||||
example: '2024-06-01 10:00',
|
||||
},
|
||||
{
|
||||
key: 'outImages',
|
||||
header: '出库实况图路径',
|
||||
required: false,
|
||||
note: '选填,ZIP 内 images 目录下的图片路径,多张用 ; 分隔,如 images/out-001.jpg;images/out-002.png。',
|
||||
example: 'images/out-001.jpg;images/out-002.png',
|
||||
note: '选填,ZIP 内 images 目录下的图片路径,多张用 ; 分隔;单张图片最大 100MB。',
|
||||
},
|
||||
{
|
||||
key: 'remark',
|
||||
header: '备注',
|
||||
required: false,
|
||||
note: '选填。',
|
||||
example: '',
|
||||
},
|
||||
];
|
||||
|
||||
Generated
+233
-223
@@ -4,6 +4,9 @@ settings:
|
||||
autoInstallPeers: true
|
||||
excludeLinksFromLockfile: false
|
||||
|
||||
overrides:
|
||||
multer: 2.2.0
|
||||
|
||||
importers:
|
||||
|
||||
.: {}
|
||||
@@ -65,6 +68,9 @@ importers:
|
||||
'@aws-sdk/client-s3':
|
||||
specifier: ^3.700.0
|
||||
version: 3.1075.0
|
||||
'@aws-sdk/lib-storage':
|
||||
specifier: ^3.1075.0
|
||||
version: 3.1075.0(@aws-sdk/client-s3@3.1075.0)
|
||||
'@aws-sdk/s3-request-presigner':
|
||||
specifier: ^3.700.0
|
||||
version: 3.1075.0
|
||||
@@ -125,6 +131,9 @@ importers:
|
||||
ioredis:
|
||||
specifier: ^5.4.2
|
||||
version: 5.11.1
|
||||
multer:
|
||||
specifier: 2.2.0
|
||||
version: 2.2.0
|
||||
nanoid:
|
||||
specifier: ^3.3.8
|
||||
version: 3.3.15
|
||||
@@ -143,6 +152,9 @@ importers:
|
||||
sharp:
|
||||
specifier: ^0.33.5
|
||||
version: 0.33.5
|
||||
unzipper:
|
||||
specifier: 0.10.14
|
||||
version: 0.10.14
|
||||
devDependencies:
|
||||
'@nestjs/cli':
|
||||
specifier: ^10.4.9
|
||||
@@ -250,13 +262,6 @@ packages:
|
||||
resolution: {integrity: sha512-I5wviiIqiFwar9Pdk30Lujk8FczEEc18i22A5c6Z9lbmhPQdTroDnEQdsfXjy404wPe8H62s0I15o4pmMGfTYQ==}
|
||||
engines: {node: ^18.13.0 || >=20.9.0, npm: ^6.11.0 || ^7.5.6 || >=8.0.0, yarn: '>= 1.13.0'}
|
||||
|
||||
'@aws-crypto/crc32@5.2.0':
|
||||
resolution: {integrity: sha512-nLbCWqQNgUiwwtFsen1AdzAtvuLRsQS8rYgMuxCrdKf9kOssamGLuPwyTY9wyYblNr9+1XM8v6zoDTPPSIeANg==}
|
||||
engines: {node: '>=16.0.0'}
|
||||
|
||||
'@aws-crypto/crc32c@5.2.0':
|
||||
resolution: {integrity: sha512-+iWb8qaHLYKrNvGRbiYRHSdKRWhto5XlZUEBwDjYNf+ly5SVYG6zEoYIdxvf5R3zyeP16w4PLBn3rH1xc74Rag==}
|
||||
|
||||
'@aws-crypto/sha1-browser@5.2.0':
|
||||
resolution: {integrity: sha512-OH6lveCFfcDjX4dbAvCFSYUjJZjDr/3XJ3xHtjn3Oj5b9RjojQo8npoLeA/bNwkOkrSQ0wgrHzXk4tDRxGKJeg==}
|
||||
|
||||
@@ -273,88 +278,94 @@ packages:
|
||||
'@aws-crypto/util@5.2.0':
|
||||
resolution: {integrity: sha512-4RkU9EsI6ZpBve5fseQlGNUWKMa1RLPQ1dnjnQoe07ldfIzcsGb5hC5W0Dm7u423KWzawlrpbjXBrXCEv9zazQ==}
|
||||
|
||||
'@aws-sdk/checksums@3.1000.8':
|
||||
resolution: {integrity: sha512-v0U9S7gBIme3OTgt1LdbAF4RpvavCc+4GK1+1xqAcqtbrHsEhjQo6R45LKcjhs/+WrRJij1Y0Gztw7QPAIeUfA==}
|
||||
'@aws-sdk/checksums@3.1000.16':
|
||||
resolution: {integrity: sha512-EKnvkXSmz3IpA99tCNuI+dLFXyZyClSm8zns9sB/elvkU+MTuomAs6toJMPMBf98/fICG/urXDkzGz0/c3yyAQ==}
|
||||
engines: {node: '>=20.0.0'}
|
||||
|
||||
'@aws-sdk/client-s3@3.1075.0':
|
||||
resolution: {integrity: sha512-h1A6nIl1YX6Y45enGsTK7ef3ZrOnBiQJ1qF5R2K/nMWfsu6A9mc2Y5T66nxerABzyjjyyvign3MrzafnFoQKmA==}
|
||||
engines: {node: '>=20.0.0'}
|
||||
|
||||
'@aws-sdk/core@3.974.23':
|
||||
resolution: {integrity: sha512-MiWR/uWjxjFXGzrE0Ghc5lWxUxzHsUWFhV+OX7M4cR9SrmrnZs6TXavnCWnzzdwJeFri34xQo81rvGNzK3c4BQ==}
|
||||
'@aws-sdk/core@3.975.1':
|
||||
resolution: {integrity: sha512-8qh/6EYb7hl/ZwVfQufhbMEZs1gQIc7GbdrIf4eprQJ7cv042+74nE6l3YDfyWNzb9iPXb8fRyYSHkNIk5eE6Q==}
|
||||
engines: {node: '>=20.0.0'}
|
||||
|
||||
'@aws-sdk/credential-provider-env@3.972.49':
|
||||
resolution: {integrity: sha512-liB3yQNHCM9k/gu/w36XHMKPluT7HTlnGUhRbBGSISDQkcr/Sy1zsZabiuvQj8WG5yW573u9RehrBvvnIQ9OEQ==}
|
||||
'@aws-sdk/credential-provider-env@3.972.57':
|
||||
resolution: {integrity: sha512-1RfJaF7SW1TOnvNGU7kaYjwUf5H3sfm+synGH1bHhRlqcnxCt3szebH3dmKEyY4tuGcbQ6ffzUT89cRitBV8OQ==}
|
||||
engines: {node: '>=20.0.0'}
|
||||
|
||||
'@aws-sdk/credential-provider-http@3.972.51':
|
||||
resolution: {integrity: sha512-XET0H2oofciJ5lMRWNIvRjAP7Q3wv2XT+JtJJEdhPWUMwe3TvQ9qcxonpu7vXmNngncvFpi4E2It+Tamas/naA==}
|
||||
'@aws-sdk/credential-provider-http@3.972.59':
|
||||
resolution: {integrity: sha512-sRCkpTiFnCdQvuaRVjQ6SVoHu6i7RUpurVo1c4F81HWhPvUJ7Wdp5MNtSdX1O29CNXc8em3O5m52hCjVtAD9SA==}
|
||||
engines: {node: '>=20.0.0'}
|
||||
|
||||
'@aws-sdk/credential-provider-ini@3.972.56':
|
||||
resolution: {integrity: sha512-IAmc61hbgQiHht9U3x0tnRwz0lzdwOwD/i9voRgdJrKamF+JtmrBOsW9GwB7mfFonNWOWL4qARWYrF8veEMe3w==}
|
||||
'@aws-sdk/credential-provider-ini@3.973.1':
|
||||
resolution: {integrity: sha512-6d8H6ZAh3ZPKZ6fe1nG2OWeZEZPtt9ravoD1dezPdPtsSkJRoxGAnFSHwKT3E/Te6fHE30zRzjV6TD12rvF6yQ==}
|
||||
engines: {node: '>=20.0.0'}
|
||||
|
||||
'@aws-sdk/credential-provider-login@3.972.55':
|
||||
resolution: {integrity: sha512-hBBkANo3cDn+h2qxxzER4a+J8JCO9o9Z/YYmU7iky6AcaarX5RRdRcHNC6SLdwY0vAXQygn6soUbDqPn3GghaA==}
|
||||
'@aws-sdk/credential-provider-login@3.972.63':
|
||||
resolution: {integrity: sha512-GREWRrMj0XnNKMaVa/Mauoaui26qBEHu71WWqXbwZOu/jFQOnPZjTf7u0KtGKC8VGa6VUs9kDWGgocrKNLS9vw==}
|
||||
engines: {node: '>=20.0.0'}
|
||||
|
||||
'@aws-sdk/credential-provider-node@3.972.58':
|
||||
resolution: {integrity: sha512-OyCLVmSI7pZO8hxwNVX6pXhTVlJqRBTp+ijdEfJSUj0RyjHnF602OfAarOzGq6wkGodeFkYBt8MmJ6A6ycRgWw==}
|
||||
'@aws-sdk/credential-provider-node@3.972.67':
|
||||
resolution: {integrity: sha512-oYlzWst56rlhhjbYnexwv5hVLYe1cW4liLObhDfxDLI4RAQzleMVHQgQgx7XsC4HKj4e3kjT8v9DId+Pi/dndw==}
|
||||
engines: {node: '>=20.0.0'}
|
||||
|
||||
'@aws-sdk/credential-provider-process@3.972.49':
|
||||
resolution: {integrity: sha512-C8h36lBuC/RnBSsjlO+dn6xZm3KbAl5vpJaVPAfQnMmz2/OISmKOc8XZcqMQgO2ADwBYNRMM6Kf3vz9G/TulMQ==}
|
||||
'@aws-sdk/credential-provider-process@3.972.57':
|
||||
resolution: {integrity: sha512-TiVQhuU0pbhIZAUZacbPHMyzrIdiH+lnx+PMY/Pu/b93dJrq3wdZwzUJ0TPpvNxaqbHsxJvQZW3/h/beLiKq7Q==}
|
||||
engines: {node: '>=20.0.0'}
|
||||
|
||||
'@aws-sdk/credential-provider-sso@3.972.55':
|
||||
resolution: {integrity: sha512-1FkOz74Ea5QGS9jtIoXp55T/IkSS3spv+nLTT07fRY/+T5xmEOqaYBVIaEmX4zTNvbV6g2lrtlaVKWEoNyJt3w==}
|
||||
'@aws-sdk/credential-provider-sso@3.973.1':
|
||||
resolution: {integrity: sha512-3foTZUJ4821Ij60X7K3NJroygiZLnbBmarN+T//O2cjkISan90zElN3NBmgSlDrTQ7Gs6z/yO8V7h60QNcDZHQ==}
|
||||
engines: {node: '>=20.0.0'}
|
||||
|
||||
'@aws-sdk/credential-provider-web-identity@3.972.55':
|
||||
resolution: {integrity: sha512-g2BoECD1q01kTPByi56+VLVvdWDzMkKIcr77qixpqH0okw2t0U5CoPv+6S8v/D1Y2Wa6QKKtn6XAtDzP+Kfpvg==}
|
||||
'@aws-sdk/credential-provider-web-identity@3.972.63':
|
||||
resolution: {integrity: sha512-8qZLFhM69eKcS37m459ctPR05Qimycm/74OPVioe6wNZabMT54GYhwBju0+J656RkMasNSawWQu+c8CmBe3TUQ==}
|
||||
engines: {node: '>=20.0.0'}
|
||||
|
||||
'@aws-sdk/middleware-flexible-checksums@3.974.33':
|
||||
resolution: {integrity: sha512-qMgQSPemQq2/eW/e/0+SpY4kYR5L7dUgBiVdEc5bd+ztHNv07ZMYiI+sTiir3TgKndFfglSw/VFi7oZJ6bZ63g==}
|
||||
'@aws-sdk/lib-storage@3.1075.0':
|
||||
resolution: {integrity: sha512-Npdac3/Fv994iCdFFeqloPel+95Zv6dRiRUpfey6W/CqpB/QdnYP60U4YBhBgJj6V5020Pm3ad0HV4WzCE5hHQ==}
|
||||
engines: {node: '>=20.0.0'}
|
||||
peerDependencies:
|
||||
'@aws-sdk/client-s3': ^3.1075.0
|
||||
|
||||
'@aws-sdk/middleware-flexible-checksums@3.974.41':
|
||||
resolution: {integrity: sha512-injxTtDHpPU183lcDoLIJbOjhzd9nLBlo1bjMD4zzarNEMhfd/H1aU3N/mKsSsobybSHprd20jhItLwmrHa0cQ==}
|
||||
engines: {node: '>=20.0.0'}
|
||||
|
||||
'@aws-sdk/middleware-sdk-s3@3.972.54':
|
||||
resolution: {integrity: sha512-GDfDQ0gwLFRKN9gWIKcmVrHJ3e7XagnY7N1LLzMVNgnOnuY7f/ALgmy3CuBjosWD95T/Z6e+gs1IeWmLPkyLKQ==}
|
||||
'@aws-sdk/middleware-sdk-s3@3.972.62':
|
||||
resolution: {integrity: sha512-k8JJwYXVYlOOjWnPZDThQS1xDFJgi5Dokt73qFlDtrZAbdcint5aIdjB9XgJAAQVP5OoqcefQmh1FYXiPpvsvw==}
|
||||
engines: {node: '>=20.0.0'}
|
||||
|
||||
'@aws-sdk/nested-clients@3.997.23':
|
||||
resolution: {integrity: sha512-gO93ZPsI2bxeFZD42f1/qjDw6FAZkNZcKRO94LIiT03fzOmcJ9e/tunxjVjA1Rl69ClmVJzz8H3G9CdKef10PA==}
|
||||
'@aws-sdk/nested-clients@3.997.31':
|
||||
resolution: {integrity: sha512-BDHTpwcsZHEBNEJzOg/B1BkFYJxAXY50dau/NyVWs3d51F0WgIUGSWZot/Os+N3KpDhXeaXnz37mWffAvduREw==}
|
||||
engines: {node: '>=20.0.0'}
|
||||
|
||||
'@aws-sdk/s3-request-presigner@3.1075.0':
|
||||
resolution: {integrity: sha512-++ftTvAGZSTuzFVHEPk8lLi7mybBD8PzJ9USWBvwnE4kSrXOyqYVJ5Ixd06xUEWS/xsrhpkI07mzCLGIxrRymA==}
|
||||
engines: {node: '>=20.0.0'}
|
||||
|
||||
'@aws-sdk/signature-v4-multi-region@3.996.35':
|
||||
resolution: {integrity: sha512-6L/VWs+Wch2stHemCGTmUNqKLMzURxQDK5boNG3Jn3kAOp71meDUuS5sbObpEvFxHDq0uWeSLFDNSYsjNt+Dlg==}
|
||||
'@aws-sdk/signature-v4-multi-region@3.996.39':
|
||||
resolution: {integrity: sha512-8+srXqYIF8KYMLC4FxMLEM5Ek7kUNibJu1R4m8/fUhhNYIZZz26oGtKkCr8I/HiG2fFQxBvaGgQZT4/mqRCSnA==}
|
||||
engines: {node: '>=20.0.0'}
|
||||
|
||||
'@aws-sdk/token-providers@3.1074.0':
|
||||
resolution: {integrity: sha512-pv80IzgGW4RnXWtft692chZOM9i6PhebVsLCcnaM4dBEPZva2fE6FXAHs76G7Rc7s3yGyX/68G0nZMrUy+Vmpg==}
|
||||
'@aws-sdk/token-providers@3.1083.0':
|
||||
resolution: {integrity: sha512-s0woKnxuHrExLc5L2ArIH5BMkbonHPtt+5hSBM8oknp9M6QTuUmmAmJ2E0EdzCGONrO+8+ADPqvv6UX0nNcc7A==}
|
||||
engines: {node: '>=20.0.0'}
|
||||
|
||||
'@aws-sdk/types@3.973.13':
|
||||
resolution: {integrity: sha512-pEHZqRkAlHfnfAU9tK+WpKv/gBNjGJrHMgA3A0iYRGyswBS2t0pfez+lWlwktb3Bqa0ovh7w/QJTFwp3fDxLNg==}
|
||||
'@aws-sdk/types@3.974.0':
|
||||
resolution: {integrity: sha512-QIBrw90CDm4O0UaIIzkU6DrFdeJzEb2Va5EPEVpyldj6sHJxB6cshhStJuhZxk3wR3PmjJlYsjPmY1kNb+KGBg==}
|
||||
engines: {node: '>=20.0.0'}
|
||||
|
||||
'@aws-sdk/util-locate-window@3.965.8':
|
||||
resolution: {integrity: sha512-uUbMs1cBZPafD0ohUj6EwNf0fPZ534NvBxHox4hjX+0Rxq5paSYUem7+hi833pYrzrcnBATKIYpR02MDXT5M9g==}
|
||||
engines: {node: '>=20.0.0'}
|
||||
|
||||
'@aws-sdk/xml-builder@3.972.31':
|
||||
resolution: {integrity: sha512-SzE4Pgyl+hDF+BuyuzxUSpwnuUu9lJuO1YGgteG89/4Qv0+2IQiVQqdbPV32IozLvXWQChPQcdkk/sKvb1QHiQ==}
|
||||
'@aws-sdk/xml-builder@3.972.34':
|
||||
resolution: {integrity: sha512-wHhWL1y7sN3enBA8POrPpQM5jCcmu2ozyhbRei4c8OjVcEaEs6yLucLa/pla457ggS/ysuy7bosagz3HaJkZXA==}
|
||||
engines: {node: '>=20.0.0'}
|
||||
|
||||
'@aws/lambda-invoke-store@0.2.4':
|
||||
resolution: {integrity: sha512-iY8yvjE0y651BixKNPgmv1WrQc+GZ142sb0z4gYnChDDY2YqI4P/jsSopBWrKfAt7LOJAkOXt7rC/hms+WclQQ==}
|
||||
'@aws/lambda-invoke-store@0.3.0':
|
||||
resolution: {integrity: sha512-sl4Bm6yiMNYrZKkqqDFWN0UfnWhlS8ivKxrYl+6t0gCLrqr8y3B2IqZZbFRkfaVVp7C/baApyh71P+LeE1A2sQ==}
|
||||
engines: {node: '>=18.0.0'}
|
||||
|
||||
'@babel/code-frame@7.29.7':
|
||||
@@ -1280,32 +1291,32 @@ packages:
|
||||
'@sinonjs/fake-timers@10.3.0':
|
||||
resolution: {integrity: sha512-V4BG07kuYSUkTCSBHG8G8TNhM+F19jXFWnQtzj+we8DrkpSBCee9Z3Ms8yiGer/dlmhe35/Xdgyo3/0rQKg7YA==}
|
||||
|
||||
'@smithy/core@3.26.0':
|
||||
resolution: {integrity: sha512-mLUktFAn+Pa2agl1J7VgtYNFWCX8/b4GMJSK1hCu4YCvtBfM6F8Os3EP4ry+DFFlXOf3wyvlgXhuUdFoy52D3g==}
|
||||
'@smithy/core@3.29.3':
|
||||
resolution: {integrity: sha512-L+Ys6ecjk5vwPMAKHBpPKlJ3DkqwNcnfEISXBZIsVvWG/XKXfsAP8mwIYlTeLcd2ElHdesPI8OuOmJSFAPhm6A==}
|
||||
engines: {node: '>=18.0.0'}
|
||||
|
||||
'@smithy/credential-provider-imds@4.4.2':
|
||||
resolution: {integrity: sha512-18UMDMyrAbDcpmL1gLUA7ww0fRTcdCrSjSJOi2Sbld+tVjwD/pW+OAwjlScFLR7vvBnhZrIPQ7kVuTf1mnJLug==}
|
||||
'@smithy/credential-provider-imds@4.4.8':
|
||||
resolution: {integrity: sha512-q9J7JTiXrAhB8sDp4px97uEPT7CwKH61Co78grdNQvU8QZAdiuaSRhP0tUVf2ogy36RZTrlMU1rBmDEH+cnkiA==}
|
||||
engines: {node: '>=18.0.0'}
|
||||
|
||||
'@smithy/fetch-http-handler@5.5.2':
|
||||
resolution: {integrity: sha512-Ei/UK/QMhq0rKaMqGPlOAkE2yS9DZeYmZdk1RAKc3vp3zxgleZHZyBLlZv8yLsxljX4svCRuMTD6u3LLIcU4Bg==}
|
||||
'@smithy/fetch-http-handler@5.6.5':
|
||||
resolution: {integrity: sha512-SuqeisTyPoiIPtIYru/sGxGyXzmZ+8nnFOhC+qRPglt06Ebd1yH//CDltZB2J/3WBNVhwfUaZ0EtHB3cm2X32g==}
|
||||
engines: {node: '>=18.0.0'}
|
||||
|
||||
'@smithy/is-array-buffer@2.2.0':
|
||||
resolution: {integrity: sha512-GGP3O9QFD24uGeAXYUjwSTXARoqpZykHadOmA8G5vfJPK0/DC67qa//0qvqrJzL1xc8WQWX7/yc7fwudjPHPhA==}
|
||||
engines: {node: '>=14.0.0'}
|
||||
|
||||
'@smithy/node-http-handler@4.8.2':
|
||||
resolution: {integrity: sha512-wfl1uwrAqMH9/pi4kqBo5LBcFwrJLxuDLqL7p7qNcJIFcyZDUc6pzhYk4CYv+DP7fIUpQCZumwNnkhPKS52osQ==}
|
||||
'@smithy/node-http-handler@4.9.5':
|
||||
resolution: {integrity: sha512-bNqdxTQTxmLbomSmlkZFz8L6B/feQ2HHzw4L2zY7Ecp2XffYAZq2uzdWDdxJHJFbEvqd+SRuluJso0P8+xPdbw==}
|
||||
engines: {node: '>=18.0.0'}
|
||||
|
||||
'@smithy/signature-v4@5.5.2':
|
||||
resolution: {integrity: sha512-7xHpmPY4rt0IOmeAA8EfjgEH8isT+587TCdy9H6a7d4OMi5CQ0oEHhWllunvPu4j4Cq0vTFwdxXN/kABWPjdyA==}
|
||||
'@smithy/signature-v4@5.6.4':
|
||||
resolution: {integrity: sha512-B89bpf2t/y/wia6LZ+4JfHXYQT9PnVftsH05rgJKKIStS7r/4XSs9HOjtPoLtgcA6HCW9jVqX5DBbq7E0PAkiQ==}
|
||||
engines: {node: '>=18.0.0'}
|
||||
|
||||
'@smithy/types@4.15.0':
|
||||
resolution: {integrity: sha512-Z5TAOxygoFvybJV3igo5SloFflSokHx2hu1eFA+DxDTcn+FtKxUSui+rbTRG1pAafMA888Z3MVvCWUuvCrTXjg==}
|
||||
'@smithy/types@4.16.1':
|
||||
resolution: {integrity: sha512-0JFs3V2y2M9tKW5na/qxe69Zv+uxLMO7QBbhxF/FHu/Gp2NFZAAL9tWl9PU02xxo07pb3G9FTyjNc6D5uZrJIg==}
|
||||
engines: {node: '>=18.0.0'}
|
||||
|
||||
'@smithy/util-buffer-from@2.2.0':
|
||||
@@ -1762,6 +1773,9 @@ packages:
|
||||
resolution: {integrity: sha512-I7wzHwA3t1/lwXQh+A5PbNvJxgfo5r3xulgpYDB5zckTu/Z9oUK9biouBKQUjEqzaz3HnAT6TYoovmE+GqSf7A==}
|
||||
engines: {node: '>=0.10'}
|
||||
|
||||
buffer@5.6.0:
|
||||
resolution: {integrity: sha512-/gDYp/UtU0eA1ys8bOs9J6a+E/KWIY+DZ+Q2WESNUA0jFRsJOc0SNUO6xJ5SGA1xueg3NL65W6s+NY5l9cunuw==}
|
||||
|
||||
buffer@5.7.1:
|
||||
resolution: {integrity: sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==}
|
||||
|
||||
@@ -2986,8 +3000,8 @@ packages:
|
||||
msgpackr@2.0.4:
|
||||
resolution: {integrity: sha512-o1C5KRmuRt+apqMr1HuGSqWStZoRBUpEsCsl15uM9VdAF1qHLtvMOU2En747EnTyEl6c4pzPewRMFF31s1CNbA==}
|
||||
|
||||
multer@2.0.2:
|
||||
resolution: {integrity: sha512-u7f2xaZ/UG8oLXHvtF/oWTRvT44p9ecwBBqTwgJVq0+4BW1g8OW01TyMEGWBHbyMOYVHXslaut7qEQ1meATXgw==}
|
||||
multer@2.2.0:
|
||||
resolution: {integrity: sha512-6rdyFg2kLrMh9Jee7/BMPuV9lEAd7lLW2YUpF9/YxR7njyoUwwQ0ZPh3TaIY50Sw6vlyD2HW3wGOkTS4P79xrQ==}
|
||||
engines: {node: '>= 10.16.0'}
|
||||
|
||||
mute-stream@0.0.8:
|
||||
@@ -3460,6 +3474,9 @@ packages:
|
||||
resolution: {integrity: sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==}
|
||||
engines: {node: '>= 0.8'}
|
||||
|
||||
stream-browserify@3.0.0:
|
||||
resolution: {integrity: sha512-H73RAHsVBapbim0tU2JwwOiXUj+fikfiaoYAKHF3VJfA0pe2BCzkhAHBlLG6REzE+2WNZcxOXjK7lkso+9euLA==}
|
||||
|
||||
streamsearch@1.1.0:
|
||||
resolution: {integrity: sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==}
|
||||
engines: {node: '>=10.0.0'}
|
||||
@@ -3940,10 +3957,6 @@ packages:
|
||||
xmlchars@2.2.0:
|
||||
resolution: {integrity: sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==}
|
||||
|
||||
xtend@4.0.2:
|
||||
resolution: {integrity: sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==}
|
||||
engines: {node: '>=0.4'}
|
||||
|
||||
y18n@4.0.3:
|
||||
resolution: {integrity: sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==}
|
||||
|
||||
@@ -4019,23 +4032,11 @@ snapshots:
|
||||
transitivePeerDependencies:
|
||||
- chokidar
|
||||
|
||||
'@aws-crypto/crc32@5.2.0':
|
||||
dependencies:
|
||||
'@aws-crypto/util': 5.2.0
|
||||
'@aws-sdk/types': 3.973.13
|
||||
tslib: 2.8.1
|
||||
|
||||
'@aws-crypto/crc32c@5.2.0':
|
||||
dependencies:
|
||||
'@aws-crypto/util': 5.2.0
|
||||
'@aws-sdk/types': 3.973.13
|
||||
tslib: 2.8.1
|
||||
|
||||
'@aws-crypto/sha1-browser@5.2.0':
|
||||
dependencies:
|
||||
'@aws-crypto/supports-web-crypto': 5.2.0
|
||||
'@aws-crypto/util': 5.2.0
|
||||
'@aws-sdk/types': 3.973.13
|
||||
'@aws-sdk/types': 3.974.0
|
||||
'@aws-sdk/util-locate-window': 3.965.8
|
||||
'@smithy/util-utf8': 2.3.0
|
||||
tslib: 2.8.1
|
||||
@@ -4045,7 +4046,7 @@ snapshots:
|
||||
'@aws-crypto/sha256-js': 5.2.0
|
||||
'@aws-crypto/supports-web-crypto': 5.2.0
|
||||
'@aws-crypto/util': 5.2.0
|
||||
'@aws-sdk/types': 3.973.13
|
||||
'@aws-sdk/types': 3.974.0
|
||||
'@aws-sdk/util-locate-window': 3.965.8
|
||||
'@smithy/util-utf8': 2.3.0
|
||||
tslib: 2.8.1
|
||||
@@ -4053,7 +4054,7 @@ snapshots:
|
||||
'@aws-crypto/sha256-js@5.2.0':
|
||||
dependencies:
|
||||
'@aws-crypto/util': 5.2.0
|
||||
'@aws-sdk/types': 3.973.13
|
||||
'@aws-sdk/types': 3.974.0
|
||||
tslib: 2.8.1
|
||||
|
||||
'@aws-crypto/supports-web-crypto@5.2.0':
|
||||
@@ -4062,19 +4063,16 @@ snapshots:
|
||||
|
||||
'@aws-crypto/util@5.2.0':
|
||||
dependencies:
|
||||
'@aws-sdk/types': 3.973.13
|
||||
'@aws-sdk/types': 3.974.0
|
||||
'@smithy/util-utf8': 2.3.0
|
||||
tslib: 2.8.1
|
||||
|
||||
'@aws-sdk/checksums@3.1000.8':
|
||||
'@aws-sdk/checksums@3.1000.16':
|
||||
dependencies:
|
||||
'@aws-crypto/crc32': 5.2.0
|
||||
'@aws-crypto/crc32c': 5.2.0
|
||||
'@aws-crypto/util': 5.2.0
|
||||
'@aws-sdk/core': 3.974.23
|
||||
'@aws-sdk/types': 3.973.13
|
||||
'@smithy/core': 3.26.0
|
||||
'@smithy/types': 4.15.0
|
||||
'@aws-sdk/core': 3.975.1
|
||||
'@aws-sdk/types': 3.974.0
|
||||
'@smithy/core': 3.29.3
|
||||
'@smithy/types': 4.16.1
|
||||
tslib: 2.8.1
|
||||
|
||||
'@aws-sdk/client-s3@3.1075.0':
|
||||
@@ -4082,180 +4080,188 @@ snapshots:
|
||||
'@aws-crypto/sha1-browser': 5.2.0
|
||||
'@aws-crypto/sha256-browser': 5.2.0
|
||||
'@aws-crypto/sha256-js': 5.2.0
|
||||
'@aws-sdk/core': 3.974.23
|
||||
'@aws-sdk/credential-provider-node': 3.972.58
|
||||
'@aws-sdk/middleware-flexible-checksums': 3.974.33
|
||||
'@aws-sdk/middleware-sdk-s3': 3.972.54
|
||||
'@aws-sdk/signature-v4-multi-region': 3.996.35
|
||||
'@aws-sdk/types': 3.973.13
|
||||
'@smithy/core': 3.26.0
|
||||
'@smithy/fetch-http-handler': 5.5.2
|
||||
'@smithy/node-http-handler': 4.8.2
|
||||
'@smithy/types': 4.15.0
|
||||
'@aws-sdk/core': 3.975.1
|
||||
'@aws-sdk/credential-provider-node': 3.972.67
|
||||
'@aws-sdk/middleware-flexible-checksums': 3.974.41
|
||||
'@aws-sdk/middleware-sdk-s3': 3.972.62
|
||||
'@aws-sdk/signature-v4-multi-region': 3.996.39
|
||||
'@aws-sdk/types': 3.974.0
|
||||
'@smithy/core': 3.29.3
|
||||
'@smithy/fetch-http-handler': 5.6.5
|
||||
'@smithy/node-http-handler': 4.9.5
|
||||
'@smithy/types': 4.16.1
|
||||
tslib: 2.8.1
|
||||
|
||||
'@aws-sdk/core@3.974.23':
|
||||
'@aws-sdk/core@3.975.1':
|
||||
dependencies:
|
||||
'@aws-sdk/types': 3.973.13
|
||||
'@aws-sdk/xml-builder': 3.972.31
|
||||
'@aws/lambda-invoke-store': 0.2.4
|
||||
'@smithy/core': 3.26.0
|
||||
'@smithy/signature-v4': 5.5.2
|
||||
'@smithy/types': 4.15.0
|
||||
'@aws-sdk/types': 3.974.0
|
||||
'@aws-sdk/xml-builder': 3.972.34
|
||||
'@aws/lambda-invoke-store': 0.3.0
|
||||
'@smithy/core': 3.29.3
|
||||
'@smithy/signature-v4': 5.6.4
|
||||
'@smithy/types': 4.16.1
|
||||
bowser: 2.14.1
|
||||
tslib: 2.8.1
|
||||
|
||||
'@aws-sdk/credential-provider-env@3.972.49':
|
||||
'@aws-sdk/credential-provider-env@3.972.57':
|
||||
dependencies:
|
||||
'@aws-sdk/core': 3.974.23
|
||||
'@aws-sdk/types': 3.973.13
|
||||
'@smithy/core': 3.26.0
|
||||
'@smithy/types': 4.15.0
|
||||
'@aws-sdk/core': 3.975.1
|
||||
'@aws-sdk/types': 3.974.0
|
||||
'@smithy/core': 3.29.3
|
||||
'@smithy/types': 4.16.1
|
||||
tslib: 2.8.1
|
||||
|
||||
'@aws-sdk/credential-provider-http@3.972.51':
|
||||
'@aws-sdk/credential-provider-http@3.972.59':
|
||||
dependencies:
|
||||
'@aws-sdk/core': 3.974.23
|
||||
'@aws-sdk/types': 3.973.13
|
||||
'@smithy/core': 3.26.0
|
||||
'@smithy/fetch-http-handler': 5.5.2
|
||||
'@smithy/node-http-handler': 4.8.2
|
||||
'@smithy/types': 4.15.0
|
||||
'@aws-sdk/core': 3.975.1
|
||||
'@aws-sdk/types': 3.974.0
|
||||
'@smithy/core': 3.29.3
|
||||
'@smithy/fetch-http-handler': 5.6.5
|
||||
'@smithy/node-http-handler': 4.9.5
|
||||
'@smithy/types': 4.16.1
|
||||
tslib: 2.8.1
|
||||
|
||||
'@aws-sdk/credential-provider-ini@3.972.56':
|
||||
'@aws-sdk/credential-provider-ini@3.973.1':
|
||||
dependencies:
|
||||
'@aws-sdk/core': 3.974.23
|
||||
'@aws-sdk/credential-provider-env': 3.972.49
|
||||
'@aws-sdk/credential-provider-http': 3.972.51
|
||||
'@aws-sdk/credential-provider-login': 3.972.55
|
||||
'@aws-sdk/credential-provider-process': 3.972.49
|
||||
'@aws-sdk/credential-provider-sso': 3.972.55
|
||||
'@aws-sdk/credential-provider-web-identity': 3.972.55
|
||||
'@aws-sdk/nested-clients': 3.997.23
|
||||
'@aws-sdk/types': 3.973.13
|
||||
'@smithy/core': 3.26.0
|
||||
'@smithy/credential-provider-imds': 4.4.2
|
||||
'@smithy/types': 4.15.0
|
||||
'@aws-sdk/core': 3.975.1
|
||||
'@aws-sdk/credential-provider-env': 3.972.57
|
||||
'@aws-sdk/credential-provider-http': 3.972.59
|
||||
'@aws-sdk/credential-provider-login': 3.972.63
|
||||
'@aws-sdk/credential-provider-process': 3.972.57
|
||||
'@aws-sdk/credential-provider-sso': 3.973.1
|
||||
'@aws-sdk/credential-provider-web-identity': 3.972.63
|
||||
'@aws-sdk/nested-clients': 3.997.31
|
||||
'@aws-sdk/types': 3.974.0
|
||||
'@smithy/core': 3.29.3
|
||||
'@smithy/credential-provider-imds': 4.4.8
|
||||
'@smithy/types': 4.16.1
|
||||
tslib: 2.8.1
|
||||
|
||||
'@aws-sdk/credential-provider-login@3.972.55':
|
||||
'@aws-sdk/credential-provider-login@3.972.63':
|
||||
dependencies:
|
||||
'@aws-sdk/core': 3.974.23
|
||||
'@aws-sdk/nested-clients': 3.997.23
|
||||
'@aws-sdk/types': 3.973.13
|
||||
'@smithy/core': 3.26.0
|
||||
'@smithy/types': 4.15.0
|
||||
'@aws-sdk/core': 3.975.1
|
||||
'@aws-sdk/nested-clients': 3.997.31
|
||||
'@aws-sdk/types': 3.974.0
|
||||
'@smithy/core': 3.29.3
|
||||
'@smithy/types': 4.16.1
|
||||
tslib: 2.8.1
|
||||
|
||||
'@aws-sdk/credential-provider-node@3.972.58':
|
||||
'@aws-sdk/credential-provider-node@3.972.67':
|
||||
dependencies:
|
||||
'@aws-sdk/credential-provider-env': 3.972.49
|
||||
'@aws-sdk/credential-provider-http': 3.972.51
|
||||
'@aws-sdk/credential-provider-ini': 3.972.56
|
||||
'@aws-sdk/credential-provider-process': 3.972.49
|
||||
'@aws-sdk/credential-provider-sso': 3.972.55
|
||||
'@aws-sdk/credential-provider-web-identity': 3.972.55
|
||||
'@aws-sdk/types': 3.973.13
|
||||
'@smithy/core': 3.26.0
|
||||
'@smithy/credential-provider-imds': 4.4.2
|
||||
'@smithy/types': 4.15.0
|
||||
'@aws-sdk/credential-provider-env': 3.972.57
|
||||
'@aws-sdk/credential-provider-http': 3.972.59
|
||||
'@aws-sdk/credential-provider-ini': 3.973.1
|
||||
'@aws-sdk/credential-provider-process': 3.972.57
|
||||
'@aws-sdk/credential-provider-sso': 3.973.1
|
||||
'@aws-sdk/credential-provider-web-identity': 3.972.63
|
||||
'@aws-sdk/types': 3.974.0
|
||||
'@smithy/core': 3.29.3
|
||||
'@smithy/credential-provider-imds': 4.4.8
|
||||
'@smithy/types': 4.16.1
|
||||
tslib: 2.8.1
|
||||
|
||||
'@aws-sdk/credential-provider-process@3.972.49':
|
||||
'@aws-sdk/credential-provider-process@3.972.57':
|
||||
dependencies:
|
||||
'@aws-sdk/core': 3.974.23
|
||||
'@aws-sdk/types': 3.973.13
|
||||
'@smithy/core': 3.26.0
|
||||
'@smithy/types': 4.15.0
|
||||
'@aws-sdk/core': 3.975.1
|
||||
'@aws-sdk/types': 3.974.0
|
||||
'@smithy/core': 3.29.3
|
||||
'@smithy/types': 4.16.1
|
||||
tslib: 2.8.1
|
||||
|
||||
'@aws-sdk/credential-provider-sso@3.972.55':
|
||||
'@aws-sdk/credential-provider-sso@3.973.1':
|
||||
dependencies:
|
||||
'@aws-sdk/core': 3.974.23
|
||||
'@aws-sdk/nested-clients': 3.997.23
|
||||
'@aws-sdk/token-providers': 3.1074.0
|
||||
'@aws-sdk/types': 3.973.13
|
||||
'@smithy/core': 3.26.0
|
||||
'@smithy/types': 4.15.0
|
||||
'@aws-sdk/core': 3.975.1
|
||||
'@aws-sdk/nested-clients': 3.997.31
|
||||
'@aws-sdk/token-providers': 3.1083.0
|
||||
'@aws-sdk/types': 3.974.0
|
||||
'@smithy/core': 3.29.3
|
||||
'@smithy/types': 4.16.1
|
||||
tslib: 2.8.1
|
||||
|
||||
'@aws-sdk/credential-provider-web-identity@3.972.55':
|
||||
'@aws-sdk/credential-provider-web-identity@3.972.63':
|
||||
dependencies:
|
||||
'@aws-sdk/core': 3.974.23
|
||||
'@aws-sdk/nested-clients': 3.997.23
|
||||
'@aws-sdk/types': 3.973.13
|
||||
'@smithy/core': 3.26.0
|
||||
'@smithy/types': 4.15.0
|
||||
'@aws-sdk/core': 3.975.1
|
||||
'@aws-sdk/nested-clients': 3.997.31
|
||||
'@aws-sdk/types': 3.974.0
|
||||
'@smithy/core': 3.29.3
|
||||
'@smithy/types': 4.16.1
|
||||
tslib: 2.8.1
|
||||
|
||||
'@aws-sdk/middleware-flexible-checksums@3.974.33':
|
||||
'@aws-sdk/lib-storage@3.1075.0(@aws-sdk/client-s3@3.1075.0)':
|
||||
dependencies:
|
||||
'@aws-sdk/checksums': 3.1000.8
|
||||
'@aws-sdk/client-s3': 3.1075.0
|
||||
'@smithy/core': 3.29.3
|
||||
'@smithy/types': 4.16.1
|
||||
buffer: 5.6.0
|
||||
events: 3.3.0
|
||||
stream-browserify: 3.0.0
|
||||
tslib: 2.8.1
|
||||
|
||||
'@aws-sdk/middleware-sdk-s3@3.972.54':
|
||||
'@aws-sdk/middleware-flexible-checksums@3.974.41':
|
||||
dependencies:
|
||||
'@aws-sdk/core': 3.974.23
|
||||
'@aws-sdk/signature-v4-multi-region': 3.996.35
|
||||
'@aws-sdk/types': 3.973.13
|
||||
'@smithy/core': 3.26.0
|
||||
'@smithy/types': 4.15.0
|
||||
'@aws-sdk/checksums': 3.1000.16
|
||||
tslib: 2.8.1
|
||||
|
||||
'@aws-sdk/nested-clients@3.997.23':
|
||||
'@aws-sdk/middleware-sdk-s3@3.972.62':
|
||||
dependencies:
|
||||
'@aws-crypto/sha256-browser': 5.2.0
|
||||
'@aws-crypto/sha256-js': 5.2.0
|
||||
'@aws-sdk/core': 3.974.23
|
||||
'@aws-sdk/signature-v4-multi-region': 3.996.35
|
||||
'@aws-sdk/types': 3.973.13
|
||||
'@smithy/core': 3.26.0
|
||||
'@smithy/fetch-http-handler': 5.5.2
|
||||
'@smithy/node-http-handler': 4.8.2
|
||||
'@smithy/types': 4.15.0
|
||||
'@aws-sdk/core': 3.975.1
|
||||
'@aws-sdk/signature-v4-multi-region': 3.996.39
|
||||
'@aws-sdk/types': 3.974.0
|
||||
'@smithy/core': 3.29.3
|
||||
'@smithy/types': 4.16.1
|
||||
tslib: 2.8.1
|
||||
|
||||
'@aws-sdk/nested-clients@3.997.31':
|
||||
dependencies:
|
||||
'@aws-sdk/core': 3.975.1
|
||||
'@aws-sdk/signature-v4-multi-region': 3.996.39
|
||||
'@aws-sdk/types': 3.974.0
|
||||
'@smithy/core': 3.29.3
|
||||
'@smithy/fetch-http-handler': 5.6.5
|
||||
'@smithy/node-http-handler': 4.9.5
|
||||
'@smithy/types': 4.16.1
|
||||
tslib: 2.8.1
|
||||
|
||||
'@aws-sdk/s3-request-presigner@3.1075.0':
|
||||
dependencies:
|
||||
'@aws-sdk/core': 3.974.23
|
||||
'@aws-sdk/signature-v4-multi-region': 3.996.35
|
||||
'@aws-sdk/types': 3.973.13
|
||||
'@smithy/core': 3.26.0
|
||||
'@smithy/types': 4.15.0
|
||||
'@aws-sdk/core': 3.975.1
|
||||
'@aws-sdk/signature-v4-multi-region': 3.996.39
|
||||
'@aws-sdk/types': 3.974.0
|
||||
'@smithy/core': 3.29.3
|
||||
'@smithy/types': 4.16.1
|
||||
tslib: 2.8.1
|
||||
|
||||
'@aws-sdk/signature-v4-multi-region@3.996.35':
|
||||
'@aws-sdk/signature-v4-multi-region@3.996.39':
|
||||
dependencies:
|
||||
'@aws-sdk/types': 3.973.13
|
||||
'@smithy/signature-v4': 5.5.2
|
||||
'@smithy/types': 4.15.0
|
||||
'@aws-sdk/types': 3.974.0
|
||||
'@smithy/signature-v4': 5.6.4
|
||||
'@smithy/types': 4.16.1
|
||||
tslib: 2.8.1
|
||||
|
||||
'@aws-sdk/token-providers@3.1074.0':
|
||||
'@aws-sdk/token-providers@3.1083.0':
|
||||
dependencies:
|
||||
'@aws-sdk/core': 3.974.23
|
||||
'@aws-sdk/nested-clients': 3.997.23
|
||||
'@aws-sdk/types': 3.973.13
|
||||
'@smithy/core': 3.26.0
|
||||
'@smithy/types': 4.15.0
|
||||
'@aws-sdk/core': 3.975.1
|
||||
'@aws-sdk/nested-clients': 3.997.31
|
||||
'@aws-sdk/types': 3.974.0
|
||||
'@smithy/core': 3.29.3
|
||||
'@smithy/types': 4.16.1
|
||||
tslib: 2.8.1
|
||||
|
||||
'@aws-sdk/types@3.973.13':
|
||||
'@aws-sdk/types@3.974.0':
|
||||
dependencies:
|
||||
'@smithy/types': 4.15.0
|
||||
'@smithy/types': 4.16.1
|
||||
tslib: 2.8.1
|
||||
|
||||
'@aws-sdk/util-locate-window@3.965.8':
|
||||
dependencies:
|
||||
tslib: 2.8.1
|
||||
|
||||
'@aws-sdk/xml-builder@3.972.31':
|
||||
'@aws-sdk/xml-builder@3.972.34':
|
||||
dependencies:
|
||||
'@smithy/types': 4.15.0
|
||||
'@smithy/types': 4.16.1
|
||||
tslib: 2.8.1
|
||||
|
||||
'@aws/lambda-invoke-store@0.2.4': {}
|
||||
'@aws/lambda-invoke-store@0.3.0': {}
|
||||
|
||||
'@babel/code-frame@7.29.7':
|
||||
dependencies:
|
||||
@@ -4995,7 +5001,7 @@ snapshots:
|
||||
body-parser: 1.20.4
|
||||
cors: 2.8.5
|
||||
express: 4.22.1
|
||||
multer: 2.0.2
|
||||
multer: 2.2.0
|
||||
tslib: 2.8.1
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
@@ -5188,41 +5194,40 @@ snapshots:
|
||||
dependencies:
|
||||
'@sinonjs/commons': 3.0.1
|
||||
|
||||
'@smithy/core@3.26.0':
|
||||
'@smithy/core@3.29.3':
|
||||
dependencies:
|
||||
'@aws-crypto/crc32': 5.2.0
|
||||
'@smithy/types': 4.15.0
|
||||
'@smithy/types': 4.16.1
|
||||
tslib: 2.8.1
|
||||
|
||||
'@smithy/credential-provider-imds@4.4.2':
|
||||
'@smithy/credential-provider-imds@4.4.8':
|
||||
dependencies:
|
||||
'@smithy/core': 3.26.0
|
||||
'@smithy/types': 4.15.0
|
||||
'@smithy/core': 3.29.3
|
||||
'@smithy/types': 4.16.1
|
||||
tslib: 2.8.1
|
||||
|
||||
'@smithy/fetch-http-handler@5.5.2':
|
||||
'@smithy/fetch-http-handler@5.6.5':
|
||||
dependencies:
|
||||
'@smithy/core': 3.26.0
|
||||
'@smithy/types': 4.15.0
|
||||
'@smithy/core': 3.29.3
|
||||
'@smithy/types': 4.16.1
|
||||
tslib: 2.8.1
|
||||
|
||||
'@smithy/is-array-buffer@2.2.0':
|
||||
dependencies:
|
||||
tslib: 2.8.1
|
||||
|
||||
'@smithy/node-http-handler@4.8.2':
|
||||
'@smithy/node-http-handler@4.9.5':
|
||||
dependencies:
|
||||
'@smithy/core': 3.26.0
|
||||
'@smithy/types': 4.15.0
|
||||
'@smithy/core': 3.29.3
|
||||
'@smithy/types': 4.16.1
|
||||
tslib: 2.8.1
|
||||
|
||||
'@smithy/signature-v4@5.5.2':
|
||||
'@smithy/signature-v4@5.6.4':
|
||||
dependencies:
|
||||
'@smithy/core': 3.26.0
|
||||
'@smithy/types': 4.15.0
|
||||
'@smithy/core': 3.29.3
|
||||
'@smithy/types': 4.16.1
|
||||
tslib: 2.8.1
|
||||
|
||||
'@smithy/types@4.15.0':
|
||||
'@smithy/types@4.16.1':
|
||||
dependencies:
|
||||
tslib: 2.8.1
|
||||
|
||||
@@ -5821,6 +5826,11 @@ snapshots:
|
||||
|
||||
buffer-indexof-polyfill@1.0.2: {}
|
||||
|
||||
buffer@5.6.0:
|
||||
dependencies:
|
||||
base64-js: 1.5.1
|
||||
ieee754: 1.2.1
|
||||
|
||||
buffer@5.7.1:
|
||||
dependencies:
|
||||
base64-js: 1.5.1
|
||||
@@ -7274,15 +7284,12 @@ snapshots:
|
||||
optionalDependencies:
|
||||
msgpackr-extract: 3.0.4
|
||||
|
||||
multer@2.0.2:
|
||||
multer@2.2.0:
|
||||
dependencies:
|
||||
append-field: 1.0.0
|
||||
busboy: 1.6.0
|
||||
concat-stream: 2.0.0
|
||||
mkdirp: 0.5.6
|
||||
object-assign: 4.1.1
|
||||
type-is: 1.6.18
|
||||
xtend: 4.0.2
|
||||
|
||||
mute-stream@0.0.8: {}
|
||||
|
||||
@@ -7788,6 +7795,11 @@ snapshots:
|
||||
|
||||
statuses@2.0.2: {}
|
||||
|
||||
stream-browserify@3.0.0:
|
||||
dependencies:
|
||||
inherits: 2.0.4
|
||||
readable-stream: 3.6.2
|
||||
|
||||
streamsearch@1.1.0: {}
|
||||
|
||||
string-length@4.0.2:
|
||||
@@ -8208,8 +8220,6 @@ snapshots:
|
||||
|
||||
xmlchars@2.2.0: {}
|
||||
|
||||
xtend@4.0.2: {}
|
||||
|
||||
y18n@4.0.3: {}
|
||||
|
||||
y18n@5.0.8: {}
|
||||
|
||||
+14
-1
@@ -103,7 +103,20 @@ python scripts/build.py --upgrade # 升级包
|
||||
|
||||
包内不写死数据库、Redis、域名、OSS/CDN、天河链密钥。配置只有一个文件——运行目录下的 `.env`;数据在 `storage/`、`backups/` 与数据库。
|
||||
|
||||
## 五、上线与升级边界
|
||||
## 五、大批量出库导入与反向代理
|
||||
|
||||
批量出库 ZIP 总体没有应用层固定体积上限,但实际容量受服务器磁盘、内存、网络带宽和处理时长约束。ZIP 内单个 xlsx 不超过 100MB;单张图片不超过 100MB,仅支持 JPG/JPEG/PNG/WebP,且不超过 4000 万像素。批量导入只登记出库,不会自动发起上链;需要在导入完成后按业务流程另行执行上链。
|
||||
|
||||
Docker 发布包生成的内层 Nginx 已使用 `client_max_body_size 0;` 取消请求体大小限制,并把代理读写超时设为 1 小时。无论采用 Docker 还是非 Docker 部署,外层宝塔/1Panel/Nginx 反向代理都必须采用同等配置,否则大 ZIP 仍会在到达应用前被拒绝或中断:
|
||||
|
||||
```nginx
|
||||
client_max_body_size 0;
|
||||
proxy_read_timeout 3600s;
|
||||
proxy_send_timeout 3600s;
|
||||
proxy_request_buffering off;
|
||||
```
|
||||
|
||||
## 六、上线与升级边界
|
||||
|
||||
- 当前迁移基线从正式安装前的历史脚本压缩为 `20260713090000_init`,仅可直接用于全新安装,或已经以该 init 为基线的后续升级。执行过压缩前旧迁移的数据库不能直接套用升级包,必须先单独制定 Prisma baseline 方案。
|
||||
- 生产默认单 API 实例。在线存储切换的写入屏障是进程内机制;多实例部署必须先缩容到单实例,完成“测试 → 迁移 → 确认”后再扩容。
|
||||
|
||||
+17
-2
@@ -207,7 +207,20 @@ ARTVERIS_PUBLIC_DIR=./apps/api/public
|
||||
|
||||
如果“项目端口”不是 `3000`,这里的 `API_PORT` 必须改成同一个端口。首次安装向导会在根目录生成 `.env`,服务启动时会自动读取。
|
||||
|
||||
## 4. 首次安装向导
|
||||
## 4. 反向代理与大批量出库导入
|
||||
|
||||
宝塔/1Panel/Nginx 反向代理必须取消请求体大小限制,并将代理读写超时延长到 1 小时,否则大 ZIP 会在到达应用前被拒绝或中断。站点 Nginx 配置至少包含:
|
||||
|
||||
```nginx
|
||||
client_max_body_size 0;
|
||||
proxy_read_timeout 3600s;
|
||||
proxy_send_timeout 3600s;
|
||||
proxy_request_buffering off;
|
||||
```
|
||||
|
||||
批量出库 ZIP 总体没有应用层固定体积上限,但实际容量受服务器磁盘、内存、网络带宽和处理时长约束。ZIP 内单个 xlsx 不超过 100MB;单张图片不超过 100MB,仅支持 JPG/JPEG/PNG/WebP,且不超过 4000 万像素。批量导入只登记出库,不会自动发起上链;需要在导入完成后按业务流程另行执行上链。
|
||||
|
||||
## 5. 首次安装向导
|
||||
|
||||
启动 Node 项目后,打开后台地址(未安装时会自动进入安装向导):
|
||||
|
||||
@@ -243,7 +256,7 @@ http://服务器IP:3000/admin
|
||||
|
||||
安装向导会自动创建数据库、建表并初始化系统数据。安装成功后服务会主动退出一次,由宝塔/PM2 自动拉起。
|
||||
|
||||
## 5. 升级
|
||||
## 6. 升级
|
||||
|
||||
升级请使用「升级包」(`--upgrade` 构建),它自带 `upgrade.sh` / `upgrade.ps1`,会只替换代码并保留根目录 `.env`、`storage/`、`backups/`。切勿删除这三者。
|
||||
|
||||
@@ -257,6 +270,8 @@ README_UPGRADE = """# Artveris 升级包说明
|
||||
|
||||
> **迁移基线限制**:当前迁移历史在正式安装前压缩为 `20260713090000_init`。本包只适用于已经使用该 init 基线的环境;若数据库执行过压缩前旧迁移,请先停止升级并单独制定 Prisma baseline 方案。
|
||||
|
||||
升级后请同时检查外层宝塔/1Panel/Nginx 反向代理:大批量出库导入要求取消请求体大小限制(`client_max_body_size 0;`),将 `proxy_read_timeout`、`proxy_send_timeout` 都设为 `3600s`,并关闭请求缓冲(`proxy_request_buffering off;`)。批量 ZIP 总体没有应用层固定体积上限,但仍受服务器资源约束;单个 xlsx 与单张图片各不超过 100MB,图片仅支持 JPG/JPEG/PNG/WebP 且不超过 4000 万像素。批量导入不会自动发起上链。
|
||||
|
||||
## 一键升级(推荐)
|
||||
|
||||
先解压本包,再执行(把路径换成你的线上部署目录):
|
||||
|
||||
+22
-3
@@ -365,10 +365,12 @@ services:
|
||||
INSTALL_REDIS_HOST: redis
|
||||
INSTALL_REDIS_PORT: "6379"
|
||||
INSTALL_REDIS_PASSWORD: ${REDIS_PASSWORD}
|
||||
ARTVERIS_OUTBOUND_TEMP_DIR: /app/apps/api/tmp
|
||||
volumes:
|
||||
- ./data/config:/app/apps/api/config
|
||||
- ./data/storage:/app/apps/api/storage
|
||||
- ./data/backups:/app/apps/api/backups
|
||||
- ./data/tmp:/app/apps/api/tmp
|
||||
networks:
|
||||
- artveris_private
|
||||
|
||||
@@ -401,11 +403,14 @@ map $http_x_forwarded_proto $artveris_forwarded_proto {
|
||||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
client_max_body_size 120m;
|
||||
client_max_body_size 0;
|
||||
|
||||
location / {
|
||||
proxy_pass http://api:3000;
|
||||
proxy_http_version 1.1;
|
||||
proxy_read_timeout 3600s;
|
||||
proxy_send_timeout 3600s;
|
||||
proxy_request_buffering off;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
@@ -454,7 +459,7 @@ else
|
||||
echo "[up] upgrade 模式:保留服务器已存在的 .env。"
|
||||
fi
|
||||
|
||||
mkdir -p data/mysql data/redis data/storage data/backups data/config
|
||||
mkdir -p data/mysql data/redis data/storage data/backups data/config data/tmp
|
||||
|
||||
sh load.sh
|
||||
|
||||
@@ -504,10 +509,24 @@ up.sh 会:(按需从 .env.sample 生成 .env)-> 创建 data/ 目录 -> 导
|
||||
- 请在外层 1Panel/宝塔把域名 {cfg.base_url} 反向代理到 http://{cfg.bind_host}:{cfg.http_port},并配置 HTTPS。
|
||||
- 后台 /admin、客户端 /trace、接口 /api、短链 /t、资源 /uploads 都由同一入口提供。
|
||||
|
||||
## 大批量出库导入
|
||||
|
||||
- 容器内 Nginx 已取消请求体大小限制,并把代理读写超时设为 1 小时。
|
||||
- 外层 1Panel/宝塔反向代理也必须取消请求体大小限制并延长超时,否则大 ZIP 仍会被外层拦截。站点 Nginx 配置至少包含:
|
||||
|
||||
client_max_body_size 0;
|
||||
proxy_read_timeout 3600s;
|
||||
proxy_send_timeout 3600s;
|
||||
proxy_request_buffering off;
|
||||
|
||||
- 批量出库 ZIP 总体没有应用层固定体积上限,但实际容量受服务器磁盘、内存、网络带宽和处理时长约束。
|
||||
- ZIP 内单个 xlsx 不超过 100MB;单张图片不超过 100MB,仅支持 JPG/JPEG/PNG/WebP,且不超过 4000 万像素。
|
||||
- 批量导入只登记出库,不会自动发起上链;需要在导入完成后按业务流程另行执行上链。
|
||||
|
||||
## 升级与数据
|
||||
|
||||
- 基础设施变量在部署目录根的 `.env`;**应用配置与密钥在 `data/config/.env`(安装向导写入)**;
|
||||
业务数据在 `data/storage`、`data/backups`、`data/mysql`、`data/redis`。
|
||||
业务数据在 `data/storage`、`data/backups`、`data/mysql`、`data/redis`,大包处理临时文件在 `data/tmp`(应用启动时自动清理遗留)。
|
||||
- 升级只需重新导入新镜像并 `sh up.sh upgrade`(默认):**不会覆盖已有 `.env` 与 `data/`**(含 config)。
|
||||
- `sh up.sh clean` 会清空 `data/` 全部数据(数据库/上传/备份/配置),仅在需要重来时使用。
|
||||
- MySQL/Redis 仅在容器专属网络内暴露,不映射宿主机端口,不会与服务器已有服务冲突。
|
||||
|
||||
Reference in New Issue
Block a user