From eaa5947d3cf6278fd546efeb87681134d9838118 Mon Sep 17 00:00:00 2001 From: lihsai0 Date: Sat, 12 Oct 2024 18:03:49 +0800 Subject: [PATCH 1/4] fix: lost codecov token in github actions --- .github/workflows/ci-test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci-test.yml b/.github/workflows/ci-test.yml index 55e1f32..7afa692 100644 --- a/.github/workflows/ci-test.yml +++ b/.github/workflows/ci-test.yml @@ -32,3 +32,5 @@ jobs: QINIU_TEST_DOMAIN: ${{ secrets.QINIU_TEST_DOMAIN }} - name: Upload coverage reports uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} From b101d52337774fb1247fe5f11d520fb6268c94d2 Mon Sep 17 00:00:00 2001 From: lihsai0 Date: Sat, 12 Oct 2024 18:04:46 +0800 Subject: [PATCH 2/4] fix(type): put policy persistent type --- index.d.ts | 2 +- qiniu/storage/rs.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/index.d.ts b/index.d.ts index 284febc..67c6865 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1779,7 +1779,7 @@ export declare namespace rs { persistentOps?: string; persistentNotifyUrl?: string; persistentPipeline?: string; - persistentType?: string; + persistentType?: number; fsizeLimit?: number; fsizeMin?: number; diff --git a/qiniu/storage/rs.js b/qiniu/storage/rs.js index b5f7fb7..4ed5630 100644 --- a/qiniu/storage/rs.js +++ b/qiniu/storage/rs.js @@ -1695,7 +1695,7 @@ function _putPolicyBuildInKeys () { * @property {string} [persistentOps] * @property {string} [persistentNotifyUrl] * @property {string} [persistentPipeline] - * @property {string} [persistentType] + * @property {number} [persistentType] * @property {number} [fsizeLimit] * @property {number} [fsizeMin] * @property {string} [mimeLimit] From aef3db1db5cd6af100c5ffb6a2a067ff4b549df3 Mon Sep 17 00:00:00 2001 From: lihsai0 Date: Mon, 14 Oct 2024 20:09:45 +0800 Subject: [PATCH 3/4] feat: add workflow template id for pfop --- index.d.ts | 14 +++++-- qiniu/fop.js | 15 ++++++-- qiniu/storage/rs.js | 3 +- test/fop.test.js | 89 +++++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 111 insertions(+), 10 deletions(-) diff --git a/index.d.ts b/index.d.ts index 67c6865..4a68160 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1055,6 +1055,11 @@ export declare namespace fop { * 为 `1` 时开启闲时任务 */ type?: number; + + /** + * 工作流模版 ID,与函数参数中的 fops 参数二选一 + */ + workflowTemplateID?: string } class OperationManager { mac: auth.digest.Mac; @@ -1066,7 +1071,7 @@ export declare namespace fop { * 发送持久化数据处理请求 * @param bucket 空间名称 * @param key 文件名称 - * @param fops 处理指令集合 + * @param fops 处理指令集合,与 options.workflowTemplateID 二选一 * @param pipeline 处理队列名称 * @param options * @param callback @@ -1097,8 +1102,9 @@ export declare namespace fop { reqid: string, inputBucket: string, inputKey: string, - creationDate: string, - type: number, + creationDate?: string, + type?: number, + taskFrom?: string, items: { cmd: string, code: number, @@ -1106,6 +1112,7 @@ export declare namespace fop { returnOld: number, error?: string, hash?: string, + key?: string, }[] }> ): void; @@ -1780,6 +1787,7 @@ export declare namespace rs { persistentNotifyUrl?: string; persistentPipeline?: string; persistentType?: number; + persistentWorkflowTemplateID?: string; fsizeLimit?: number; fsizeMin?: number; diff --git a/qiniu/fop.js b/qiniu/fop.js index a1d35cd..5d540aa 100644 --- a/qiniu/fop.js +++ b/qiniu/fop.js @@ -24,6 +24,7 @@ function OperationManager (mac, config) { * @param {string} [options.notifyURL] 回调业务服务器,通知处理结果 * @param {boolean} [options.force] 是否强制覆盖已有的同名文件 * @param {string} [options.type] 为 `1` 时,开启闲时任务 + * @param {string} [options.workflowTemplateID] 工作流模板 ID * @param {OperationCallback} callbackFunc 回调函数 */ OperationManager.prototype.pfop = function ( @@ -38,9 +39,12 @@ OperationManager.prototype.pfop = function ( // 必须参数 const reqParams = { bucket: bucket, - key: key, - fops: fops.join(';') + key: key }; + // `fops` is optional by could use `options.workflowTemplateID` to work + if (Array.isArray(fops)) { + reqParams.fops = fops.join(';'); + } // pipeline if (!pipeline) { @@ -57,9 +61,14 @@ OperationManager.prototype.pfop = function ( reqParams.force = 1; } + // workflowTemplateID + if (options.workflowTemplateID) { + reqParams.workflowTemplateID = options.workflowTemplateID; + } + const persistentType = parseInt(options.type, 10); if (!isNaN(persistentType)) { - reqParams.type = options.type; + reqParams.type = persistentType; } util.prepareZone(this, this.mac.accessKey, bucket, function (err, ctx) { diff --git a/qiniu/storage/rs.js b/qiniu/storage/rs.js index 4ed5630..b97f206 100644 --- a/qiniu/storage/rs.js +++ b/qiniu/storage/rs.js @@ -1692,10 +1692,11 @@ function _putPolicyBuildInKeys () { * @property {string} [callbackBody] * @property {string} [callbackBodyType] * @property {number} [callbackFetchKey] - * @property {string} [persistentOps] + * @property {string} [persistentOps] conflict with `persistentWorkflowTemplateID` * @property {string} [persistentNotifyUrl] * @property {string} [persistentPipeline] * @property {number} [persistentType] + * @property {string} [persistentWorkflowTemplateID] conflict with `persistentOps` * @property {number} [fsizeLimit] * @property {number} [fsizeMin] * @property {string} [mimeLimit] diff --git a/test/fop.test.js b/test/fop.test.js index 2bab8b8..2439b39 100644 --- a/test/fop.test.js +++ b/test/fop.test.js @@ -129,10 +129,10 @@ describe('test start fop', function () { it(`test pfop with upload; ${msg}`, function () { const formUploader = new qiniu.form_up.FormUploader(config); - const key = 'qiniu-pfop-upload-file'; + const key = 'test-pfop/upload-file'; const persistentKey = [ - 'qiniu-pfop-by-upload', - 'persistentType', + 'test-pfop/test-pfop-by-upload', + 'type', persistentType ].join('_'); @@ -179,4 +179,87 @@ describe('test start fop', function () { }); }); }); + + it('test pfop by templateID with api', function () { + const srcKey = 'qiniu.mp4'; + const srcBucket = bucketName; + + const templateID = 'test-workflow'; + const operationManager = new qiniu.fop.OperationManager(mac, config); + + new Promise((resolve, reject) => { + operationManager.pfop( + srcBucket, + srcKey, + null, + null, + { workflowTemplateID: templateID }, + function (err, respBody, respInfo) { + if (err) { + reject(err); + return; + } + resolve({ data: respBody, resp: respInfo }); + } + ); + }) + .then(({ data }) => { + data.should.have.keys('persistentId'); + return new Promise((resolve, reject) => { + operationManager.prefop( + data.persistentId, + function (err, respBody, respInfo) { + if (err) { + reject(err); + return; + } + resolve({ data: respBody, resp: respInfo }); + } + ); + }); + }) + .then(({ data }) => { + data.should.have.keys( + 'creationDate', + 'taskFrom' + ); + }); + }); + + it('test pfop by templateID with upload', function () { + const formUploader = new qiniu.form_up.FormUploader(config); + const key = 'qiniu-pfop-tplid-upload-file'; + const templateID = 'test-workflow'; + const options = { + scope: bucketName, + persistentWorkflowTemplateID: templateID + }; + const putPolicy = new qiniu.rs.PutPolicy(options); + const uploadToken = putPolicy.uploadToken(mac); + const putExtra = new qiniu.form_up.PutExtra(); + + return formUploader.put(uploadToken, key, testFilePath, putExtra) + .then(({ data }) => { + data.should.have.keys('key', 'persistentId'); + return new Promise((resolve, reject) => { + new qiniu.fop.OperationManager(mac, config) + .prefop( + data.persistentId, + function (err, respBody, respInfo) { + if (err) { + reject(err); + return; + } + resolve({ data: respBody, resp: respInfo }); + } + ); + }); + }) + .then(({ data }) => { + data.should.have.keys( + 'creationDate', + 'taskFrom' + ); + }); + }); }); From ce26905ab249fc3a1358db120c4c466770b9c73e Mon Sep 17 00:00:00 2001 From: lihsai0 Date: Wed, 16 Oct 2024 09:36:40 +0800 Subject: [PATCH 4/4] update version to 7.14.0 and changelog --- CHANGELOG.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d3ce41..04e6e00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## CHANGE LOG +## 7.14.0 +- 对象存储,持久化处理支持工作流模版 +- 对象存储,修复持久化处理闲时任务的类型声明 + ## 7.13.0 - 对象存储,新增空间级别上传加速开关 - 对象存储,优化断点续传开启方式 diff --git a/package.json b/package.json index f3ae9a4..5e7b4e6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "qiniu", - "version": "7.13.0", + "version": "7.14.0", "description": "Node wrapper for Qiniu Resource (Cloud) Storage API", "main": "index.js", "directories": {