From e331d014b2fac1318dd45d15e925cfa014710532 Mon Sep 17 00:00:00 2001 From: Peter van Gulik Date: Mon, 29 Apr 2024 17:03:59 +0200 Subject: [PATCH] fix: batch service does not correctly include properties to report batch status --- packages/core/package.json | 2 +- packages/salesforce/package.json | 2 +- .../salesforce/src/salesforceBatchService.ts | 45 ++++--- packages/vlocity-deploy/package.json | 2 +- packages/vscode-extension/package.json | 2 +- pnpm-lock.yaml | 121 +++++++++++------- 6 files changed, 108 insertions(+), 66 deletions(-) diff --git a/packages/core/package.json b/packages/core/package.json index 0b568035..d9b57144 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -54,7 +54,7 @@ "@vlocode/util": "workspace:*", "chalk": "^4.1.1", "globby": "^11.0.4", - "luxon": "^3.4.0", + "luxon": "^3.4.4", "memfs": "^3.2.2", "minimatch": "^9.0.3", "reflect-metadata": "^0.1.13", diff --git a/packages/salesforce/package.json b/packages/salesforce/package.json index 31c2a670..ce4d95a0 100644 --- a/packages/salesforce/package.json +++ b/packages/salesforce/package.json @@ -74,7 +74,7 @@ "fs-extra": "^11.0", "jsforce": "1.11.0", "jszip": "^3.7.0", - "luxon": "^3.4.0", + "luxon": "^3.4.4", "tough-cookie": "^4.1.2" }, "publisher": "curlybracket", diff --git a/packages/salesforce/src/salesforceBatchService.ts b/packages/salesforce/src/salesforceBatchService.ts index 145df22f..c83470e0 100644 --- a/packages/salesforce/src/salesforceBatchService.ts +++ b/packages/salesforce/src/salesforceBatchService.ts @@ -10,8 +10,8 @@ export type SalesforceBatchStatus = 'Processing' | 'Aborted' | 'Queued' | 'Compl export interface SalesforceBatchJob { id: string; createdById: string; - createdDate: string; - completedDate?: string; + createdDate: Date; + completedDate: Date | null; apexClass: { name: string; namespacePrefix: string; @@ -24,6 +24,10 @@ export interface SalesforceBatchJob { } export interface SalesforceBatchJobStatus { + /** + * ID of the batch job + */ + id: string; /** * Name of the APEX class executed by the batch */ @@ -193,22 +197,27 @@ export class SalesforceBatchService { */ public async getBatchStatus(filter: string | QueryFilterCondition) : Promise { const job = (await this.getBatchJobs(filter)).pop(); - return ( - job && { - elapsedTime: (job.completedDate ? DateTime.fromISO(job.completedDate) : DateTime.now()).diff(DateTime.fromISO(job.createdDate)).toMillis(), - apexClass: job.apexClass.name, - done: job.status === 'Completed' || job.status === 'Aborted', - status: job.status, - progress: job.jobItemsProcessed ?? 0, - total: job.totalJobItems ?? 0, - progressString: job.totalJobItems && job.jobItemsProcessed - ? `${job.status} (${job.jobItemsProcessed}/${job.totalJobItems})` - : job?.status, - toString() { - return `${this.apexClass} (${this.id}) -- ${this.progressString} [${(this.elapsedTime / 1000).toFixed(1)}s]`; - } - } as any - ); + if (!job) { + return; + } + + const progressText = job.totalJobItems && job.jobItemsProcessed + ? `${job.status} (${job.jobItemsProcessed}/${job.totalJobItems})` + : job?.status; + + return { + id: job.id, + elapsedTime: (job.completedDate ? DateTime.fromJSDate(job.completedDate) : DateTime.now()).diff(DateTime.fromJSDate(job.createdDate)).toMillis(), + apexClass: job.apexClass.name, + done: job.status === 'Completed' || job.status === 'Aborted', + status: job.status, + progress: job.jobItemsProcessed ?? 0, + total: job.totalJobItems ?? 0, + // @ts-ignore ts(2322) -- allow toString to be added to the object + toString() { + return `${this.apexClass} (${this.id}) -- ${progressText} [${(this.elapsedTime / 1000).toFixed(1)}s]`; + } + }; } /** diff --git a/packages/vlocity-deploy/package.json b/packages/vlocity-deploy/package.json index 0d3353bd..9e52ee70 100644 --- a/packages/vlocity-deploy/package.json +++ b/packages/vlocity-deploy/package.json @@ -64,7 +64,7 @@ "@vlocode/util": "workspace:*", "@vlocode/vlocity": "workspace:*", "fs-extra": "^11", - "luxon": "^3.4.0", + "luxon": "^3.4.4", "moment": "^2.29.4", "sass": "^1.59.3" }, diff --git a/packages/vscode-extension/package.json b/packages/vscode-extension/package.json index 5f7508db..111d40c6 100644 --- a/packages/vscode-extension/package.json +++ b/packages/vscode-extension/package.json @@ -1547,7 +1547,7 @@ "js-yaml": "^4.1.0", "jsforce": "^1.11.0", "log-symbols": "^4.0.0", - "luxon": "^3.4.0", + "luxon": "^3.4.4", "open": "^8.2.1", "reflect-metadata": "^0.1.13", "shx": "^0.3.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1d496346..f2eabdba 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -119,7 +119,7 @@ importers: version: 2.6.2 ts-jest: specifier: ^29.1.1 - version: 29.1.1(@babel/core@7.24.0)(jest@29.7.0)(typescript@5.1.6) + version: 29.1.1(@babel/core@7.24.4)(jest@29.7.0)(typescript@5.1.6) typedoc: specifier: ^0.24.8 version: 0.24.8(typescript@5.1.6) @@ -237,7 +237,7 @@ importers: version: 0.5.21 ts-jest: specifier: ^29.1.1 - version: 29.1.1(@babel/core@7.24.0)(jest@29.7.0)(typescript@5.1.6) + version: 29.1.1(@babel/core@7.24.4)(jest@29.7.0)(typescript@5.1.6) ts-loader: specifier: ^9.3.1 version: 9.4.0(typescript@5.1.6)(webpack@5.88.2) @@ -281,8 +281,8 @@ importers: specifier: ^11.0.4 version: 11.1.0 luxon: - specifier: ^3.4.0 - version: 3.4.0 + specifier: ^3.4.4 + version: 3.4.4 memfs: specifier: ^3.2.2 version: 3.4.1 @@ -313,7 +313,7 @@ importers: version: 0.3.4 ts-jest: specifier: ^29.1.1 - version: 29.1.1(@babel/core@7.24.0)(jest@29.7.0)(typescript@5.1.6) + version: 29.1.1(@babel/core@7.24.4)(jest@29.7.0)(typescript@5.1.6) typescript: specifier: 5.1.6 version: 5.1.6(patch_hash=sjs4irdv5ckbkl3gggmzheybku) @@ -353,7 +353,7 @@ importers: version: 0.3.4 ts-jest: specifier: ^29.1.1 - version: 29.1.1(@babel/core@7.24.0)(jest@29.7.0)(typescript@5.1.6) + version: 29.1.1(@babel/core@7.24.4)(jest@29.7.0)(typescript@5.1.6) typescript: specifier: 5.1.6 version: 5.1.6(patch_hash=sjs4irdv5ckbkl3gggmzheybku) @@ -385,8 +385,8 @@ importers: specifier: ^3.7.0 version: 3.9.1 luxon: - specifier: ^3.4.0 - version: 3.4.0 + specifier: ^3.4.4 + version: 3.4.4 tough-cookie: specifier: ^4.1.2 version: 4.1.2 @@ -423,7 +423,7 @@ importers: version: 0.3.4 ts-jest: specifier: ^29.1.1 - version: 29.1.1(@babel/core@7.24.0)(jest@29.7.0)(typescript@5.1.6) + version: 29.1.1(@babel/core@7.24.4)(jest@29.7.0)(typescript@5.1.6) typescript: specifier: 5.1.6 version: 5.1.6(patch_hash=sjs4irdv5ckbkl3gggmzheybku) @@ -472,7 +472,7 @@ importers: version: 0.3.4 ts-jest: specifier: ^29.1.1 - version: 29.1.1(@babel/core@7.24.0)(jest@29.7.0)(typescript@5.1.6) + version: 29.1.1(@babel/core@7.24.4)(jest@29.7.0)(typescript@5.1.6) typescript: specifier: 5.1.6 version: 5.1.6(patch_hash=sjs4irdv5ckbkl3gggmzheybku) @@ -509,7 +509,7 @@ importers: version: 0.3.4 ts-jest: specifier: ^29.1.1 - version: 29.1.1(@babel/core@7.24.0)(jest@29.7.0)(typescript@5.1.6) + version: 29.1.1(@babel/core@7.24.4)(jest@29.7.0)(typescript@5.1.6) typescript: specifier: 5.1.6 version: 5.1.6(patch_hash=sjs4irdv5ckbkl3gggmzheybku) @@ -535,8 +535,8 @@ importers: specifier: '11' version: 11.2.0 luxon: - specifier: ^3.4.0 - version: 3.4.0 + specifier: ^3.4.4 + version: 3.4.4 moment: specifier: '>=2.29.4' version: 2.29.4 @@ -564,7 +564,7 @@ importers: version: 0.3.4 ts-jest: specifier: ^29.1.1 - version: 29.1.1(@babel/core@7.24.0)(jest@29.7.0)(typescript@5.1.6) + version: 29.1.1(@babel/core@7.24.4)(jest@29.7.0)(typescript@5.1.6) typescript: specifier: 5.1.6 version: 5.1.6(patch_hash=sjs4irdv5ckbkl3gggmzheybku) @@ -659,8 +659,8 @@ importers: specifier: ^4.0.0 version: 4.1.0 luxon: - specifier: ^3.4.0 - version: 3.4.0 + specifier: ^3.4.4 + version: 3.4.4 open: specifier: ^8.2.1 version: 8.4.0 @@ -675,7 +675,7 @@ importers: version: 0.5.21 ts-jest: specifier: ^29.1.1 - version: 29.1.1(@babel/core@7.24.0)(jest@29.7.0)(typescript@5.1.6) + version: 29.1.1(@babel/core@7.24.4)(jest@29.7.0)(typescript@5.1.6) ts-loader: specifier: ^9.4.0 version: 9.4.0(typescript@5.1.6)(webpack@5.88.2) @@ -744,6 +744,14 @@ packages: chalk: 4.1.2 dev: true + /@babel/code-frame@7.24.2: + resolution: {integrity: sha512-y5+tLQyV8pg3fsiln67BVLD1P13Eg4lh5RW9mF0zUuvLrv9uIQ4MCL+CRT+FTsBlBjcIan6PGsLcBN0m3ClUyQ==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/highlight': 7.24.2 + picocolors: 1.0.0 + dev: true + /@babel/compat-data@7.23.5: resolution: {integrity: sha512-uU27kfDRlhfKl+w1U6vp16IuvSLtjAxdArVXPa9BvLkrr7CYIsxH5adpHObeAGY/41+syctUWOZ140a2Rvkgjw==} engines: {node: '>=6.9.0'} @@ -772,19 +780,19 @@ packages: - supports-color dev: true - /@babel/core@7.24.0: - resolution: {integrity: sha512-fQfkg0Gjkza3nf0c7/w6Xf34BW4YvzNfACRLmmb7XRLa6XHdR+K9AlJlxneFfWYf6uhOzuzZVTjF/8KfndZANw==} + /@babel/core@7.24.4: + resolution: {integrity: sha512-MBVlMXP+kkl5394RBLSxxk/iLTeVGuXTV3cIDXavPpMMqnSnt6apKgan/U8O3USWZCWZT/TbgfEpKa4uMgN4Dg==} engines: {node: '>=6.9.0'} dependencies: '@ampproject/remapping': 2.3.0 - '@babel/code-frame': 7.23.5 - '@babel/generator': 7.23.6 + '@babel/code-frame': 7.24.2 + '@babel/generator': 7.24.4 '@babel/helper-compilation-targets': 7.23.6 - '@babel/helper-module-transforms': 7.23.3(@babel/core@7.24.0) - '@babel/helpers': 7.24.0 - '@babel/parser': 7.24.0 + '@babel/helper-module-transforms': 7.23.3(@babel/core@7.24.4) + '@babel/helpers': 7.24.4 + '@babel/parser': 7.24.4 '@babel/template': 7.24.0 - '@babel/traverse': 7.24.0 + '@babel/traverse': 7.24.1 '@babel/types': 7.24.0 convert-source-map: 2.0.0 debug: 4.3.4(supports-color@8.1.1) @@ -805,6 +813,16 @@ packages: jsesc: 2.5.2 dev: true + /@babel/generator@7.24.4: + resolution: {integrity: sha512-Xd6+v6SnjWVx/nus+y0l1sxMOTOMBkyL4+BIdbALyatQnAe/SRVjANeDPSCYaX+i1iJmuGSKf3Z+E+V/va1Hvw==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/types': 7.24.0 + '@jridgewell/gen-mapping': 0.3.5 + '@jridgewell/trace-mapping': 0.3.25 + jsesc: 2.5.2 + dev: true + /@babel/helper-compilation-targets@7.23.6: resolution: {integrity: sha512-9JB548GZoQVmzrFgp8o7KxdgkTGm6xs9DW0o/Pim72UDjzr5ObUQ6ZzYPqA+g9OTS2bBQoctLJrky0RDCAWRgQ==} engines: {node: '>=6.9.0'} @@ -857,13 +875,13 @@ packages: '@babel/helper-validator-identifier': 7.22.20 dev: true - /@babel/helper-module-transforms@7.23.3(@babel/core@7.24.0): + /@babel/helper-module-transforms@7.23.3(@babel/core@7.24.4): resolution: {integrity: sha512-7bBs4ED9OmswdfDzpz4MpWgSrV7FXlc3zIagvLFjS5H+Mk7Snr21vQ6QwrsoCGMfNC4e4LQPdoULEt4ykz0SRQ==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0 dependencies: - '@babel/core': 7.24.0 + '@babel/core': 7.24.4 '@babel/helper-environment-visitor': 7.22.20 '@babel/helper-module-imports': 7.22.15 '@babel/helper-simple-access': 7.22.5 @@ -895,6 +913,11 @@ packages: engines: {node: '>=6.9.0'} dev: true + /@babel/helper-string-parser@7.24.1: + resolution: {integrity: sha512-2ofRCjnnA9y+wk8b9IAREroeUP02KHp431N2mhKniy2yKIDKpbrHv9eXwm8cBeWQYcJmzv5qKCu65P47eCF7CQ==} + engines: {node: '>=6.9.0'} + dev: true + /@babel/helper-validator-identifier@7.22.20: resolution: {integrity: sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==} engines: {node: '>=6.9.0'} @@ -916,12 +939,12 @@ packages: - supports-color dev: true - /@babel/helpers@7.24.0: - resolution: {integrity: sha512-ulDZdc0Aj5uLc5nETsa7EPx2L7rM0YJM8r7ck7U73AXi7qOV44IHHRAYZHY6iU1rr3C5N4NtTmMRUJP6kwCWeA==} + /@babel/helpers@7.24.4: + resolution: {integrity: sha512-FewdlZbSiwaVGlgT1DPANDuCHaDMiOo+D/IDYRFYjHOuv66xMSJ7fQwwODwRNAPkADIO/z1EoF/l2BCWlWABDw==} engines: {node: '>=6.9.0'} dependencies: '@babel/template': 7.24.0 - '@babel/traverse': 7.24.0 + '@babel/traverse': 7.24.1 '@babel/types': 7.24.0 transitivePeerDependencies: - supports-color @@ -936,6 +959,16 @@ packages: js-tokens: 4.0.0 dev: true + /@babel/highlight@7.24.2: + resolution: {integrity: sha512-Yac1ao4flkTxTteCDZLEvdxg2fZfz1v8M4QpaGypq/WPDqg3ijHYbDfs+LG5hvzSoqaSZ9/Z9lKSP3CjZjv+pA==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/helper-validator-identifier': 7.22.20 + chalk: 4.1.2 + js-tokens: 4.0.0 + picocolors: 1.0.0 + dev: true + /@babel/parser@7.23.6: resolution: {integrity: sha512-Z2uID7YJ7oNvAI20O9X0bblw7Qqs8Q2hFy0R9tAfnfLkp5MW0UH9eUvnDSnFwKZ0AvgS1ucqR4KzvVHgnke1VQ==} engines: {node: '>=6.0.0'} @@ -944,8 +977,8 @@ packages: '@babel/types': 7.23.6 dev: true - /@babel/parser@7.24.0: - resolution: {integrity: sha512-QuP/FxEAzMSjXygs8v4N9dvdXzEHN4W1oF3PxuWAtPo08UdM17u89RDMgjLn/mlc56iM0HlLmVkO/wgR+rDgHg==} + /@babel/parser@7.24.4: + resolution: {integrity: sha512-zTvEBcghmeBma9QIGunWevvBAp4/Qu9Bdq+2k0Ot4fVMD6v3dsC9WOcRSKk7tRRyBM/53yKMJko9xOatGQAwSg==} engines: {node: '>=6.0.0'} hasBin: true dependencies: @@ -1107,8 +1140,8 @@ packages: resolution: {integrity: sha512-Bkf2q8lMB0AFpX0NFEqSbx1OkTHf0f+0j82mkw+ZpzBnkk7e9Ql0891vlfgi+kHwOk8tQjiQHpqh4LaSa0fKEA==} engines: {node: '>=6.9.0'} dependencies: - '@babel/code-frame': 7.23.5 - '@babel/parser': 7.24.0 + '@babel/code-frame': 7.24.2 + '@babel/parser': 7.24.4 '@babel/types': 7.24.0 dev: true @@ -1130,17 +1163,17 @@ packages: - supports-color dev: true - /@babel/traverse@7.24.0: - resolution: {integrity: sha512-HfuJlI8qq3dEDmNU5ChzzpZRWq+oxCZQyMzIMEqLho+AQnhMnKQUzH6ydo3RBl/YjPCuk68Y6s0Gx0AeyULiWw==} + /@babel/traverse@7.24.1: + resolution: {integrity: sha512-xuU6o9m68KeqZbQuDt2TcKSxUw/mrsvavlEqQ1leZ/B+C9tk6E4sRWy97WaXgvq5E+nU3cXMxv3WKOCanVMCmQ==} engines: {node: '>=6.9.0'} dependencies: - '@babel/code-frame': 7.23.5 - '@babel/generator': 7.23.6 + '@babel/code-frame': 7.24.2 + '@babel/generator': 7.24.4 '@babel/helper-environment-visitor': 7.22.20 '@babel/helper-function-name': 7.23.0 '@babel/helper-hoist-variables': 7.22.5 '@babel/helper-split-export-declaration': 7.22.6 - '@babel/parser': 7.24.0 + '@babel/parser': 7.24.4 '@babel/types': 7.24.0 debug: 4.3.4(supports-color@8.1.1) globals: 11.12.0 @@ -1161,7 +1194,7 @@ packages: resolution: {integrity: sha512-+j7a5c253RfKh8iABBhywc8NSfP5LURe7Uh4qpsh6jc+aLJguvmIUBdjSdEMQv2bENrCR5MfRdjGo7vzS/ob7w==} engines: {node: '>=6.9.0'} dependencies: - '@babel/helper-string-parser': 7.23.4 + '@babel/helper-string-parser': 7.24.1 '@babel/helper-validator-identifier': 7.22.20 to-fast-properties: 2.0.0 dev: true @@ -8713,8 +8746,8 @@ packages: resolution: {integrity: sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow==} dev: true - /luxon@3.4.0: - resolution: {integrity: sha512-7eDo4Pt7aGhoCheGFIuq4Xa2fJm4ZpmldpGhjTYBNUYNCN6TIEP6v7chwwwt3KRp7YR+rghbfvjyo3V5y9hgBw==} + /luxon@3.4.4: + resolution: {integrity: sha512-zobTr7akeGHnv7eBOXcRgMeCP6+uyYsczwmeRCauvpvaAltgNyTbLH/+VaEAPUeWBT+1GuNmz4wC/6jtQzbbVA==} engines: {node: '>=12'} /make-dir@2.1.0: @@ -11948,7 +11981,7 @@ packages: yargs-parser: 21.1.1 dev: true - /ts-jest@29.1.1(@babel/core@7.24.0)(jest@29.7.0)(typescript@5.1.6): + /ts-jest@29.1.1(@babel/core@7.24.4)(jest@29.7.0)(typescript@5.1.6): resolution: {integrity: sha512-D6xjnnbP17cC85nliwGiL+tpoKN0StpgE0TeOjXQTU6MVCfsB4v7aW05CgQ/1OywGb0x/oy9hHFnN+sczTiRaA==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} hasBin: true @@ -11969,7 +12002,7 @@ packages: esbuild: optional: true dependencies: - '@babel/core': 7.24.0 + '@babel/core': 7.24.4 bs-logger: 0.2.6 fast-json-stable-stringify: 2.1.0 jest: 29.7.0(@types/node@20.4.2)(ts-node@10.7.0)