-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MWPW-133692 Promote status action for getting status, files and resul…
…ts (#58) * MWPW-133692 - Promote results Promote Action 1. Storing the start, end time, batchStatus as Completed, Completed with error and In Progress this along with status done. (in instance_info.json) 2. Added a file milo_pink/instance_results.json with merged results data. Promote status action with below parameters 1. Promote Status - This lists all the batches in the promote along with overall status, start and end time 2. Promote results - This will list merged batch results (i.e failed promote, preview, publish) 3. Batch File - This will list the batch-info files in the specific batch (no status per file is being sent) 4. Batch Results - This will list the specific batch results (i.e failed promote, preview, publish) * Updated for start time for batch progress * Added a null handling --------- Co-authored-by: Raghu A <[email protected]>
- Loading branch information
1 parent
58b171c
commit 51492f0
Showing
8 changed files
with
205 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
/* ************************************************************************ | ||
* ADOBE CONFIDENTIAL | ||
* ___________________ | ||
* | ||
* Copyright 2023 Adobe | ||
* All Rights Reserved. | ||
* | ||
* NOTICE: All information contained herein is, and remains | ||
* the property of Adobe and its suppliers, if any. The intellectual | ||
* and technical concepts contained herein are proprietary to Adobe | ||
* and its suppliers and are protected by all applicable intellectual | ||
* property laws, including trade secret and copyright laws. | ||
* Dissemination of this information or reproduction of this material | ||
* is strictly forbidden unless prior written permission is obtained | ||
* from Adobe. | ||
************************************************************************* */ | ||
|
||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
const { | ||
errorResponse, getAioLogger, getInstanceKey, PROMOTE_ACTION | ||
} = require('../utils'); | ||
const appConfig = require('../appConfig'); | ||
const FgUser = require('../fgUser'); | ||
const BatchManager = require('../batchManager'); | ||
|
||
const logger = getAioLogger(); | ||
const BAD_REQUEST_SC = 400; | ||
const AUTH_FAILED_SC = 401; | ||
const GEN_ERROR_SC = 500; | ||
|
||
/** | ||
* Returns promote status. The details of the status needed are passed a arguments. | ||
* Sample Input | ||
* { | ||
* "promoteStatus": true, | ||
* "batchFiles": 2, | ||
* "batchResults": 2, | ||
* "promoteResults": true, | ||
* "fgShareUrl": "https://adobe.sharepoint.com/:f:/r/sites/adobecom/Shared%20Documents/milo-pink<relativePath>?web=1", | ||
* "spToken": "" | ||
* } | ||
* @param {*} args Action arguments | ||
* @returns results based on parameter below | ||
* "promoteStatus": { batchesInfo: [ {"activationId": "", "batchNumber": 1, "done": true, | ||
* "endTime": "2023-09-19T13:53:32.846Z", "startTime": "2023-09-07T10:00:00.333Z", "status": "COMPLETED"}, ] } | ||
* "batchFiles": [ | ||
* "/drafts/fold/lvl1/lvl2/testforfloodgate2.docx", | ||
* "/drafts/fold/lvl11/lvl2/testforfloodgate.docx" | ||
* ] | ||
* "batchResults": { | ||
* "failedPreviews": [ | ||
* "/drafts/fold/lvl11/testforfloodgate2", | ||
* "/drafts/fold/lvl1/lvl2/testforfloodgate" | ||
* ], | ||
* "failedPromotes": [], | ||
* "failedPublishes": [] | ||
* } | ||
* "promoteResults": { | ||
* "failedPreviews": [ | ||
* "/drafts/fold/lvl11/testforfloodgate2", | ||
* "/drafts/fold/lvl1/lvl2/testforfloodgate", | ||
* "/drafts/fold/lvl1/lvl2/testforfloodgate2", | ||
* "/drafts/fold/lvl11/lvl2/testforfloodgate" | ||
* ], | ||
* "failedPromotes": [], | ||
* "failedPublishes": [] | ||
* } | ||
*/ | ||
async function main(args) { | ||
const payload = {}; | ||
try { | ||
appConfig.setAppConfig(args); | ||
const batchNumber = args.batchFiles || args.batchResults; | ||
|
||
// Validations | ||
const fgUser = new FgUser({ at: args.spToken }); | ||
if (!args.fgShareUrl) { | ||
return errorResponse(BAD_REQUEST_SC, 'Mising required fgShareUrl parameter'); | ||
} | ||
|
||
if (!await fgUser.isUser()) { | ||
return errorResponse(AUTH_FAILED_SC, 'Authentication failed. Please refresh page and try again.'); | ||
} | ||
|
||
// Starts | ||
const { siteFgRootPath } = appConfig.getConfig(); | ||
const batchManager = new BatchManager({ key: PROMOTE_ACTION, instanceKey: getInstanceKey({ fgRootFolder: siteFgRootPath }) }); | ||
await batchManager.init({ batchNumber }); | ||
const currentBatch = batchNumber ? await batchManager.getCurrentBatch() : null; | ||
|
||
// Read instance_info.json | ||
if (args.promoteStatus !== undefined) { | ||
const instanceContent = await batchManager.getInstanceFileContent(); | ||
if (!instanceContent || !instanceContent.dtls) { | ||
throw new Error('Missing instance content!'); | ||
} | ||
payload.promoteStatus = { batchesInfo: instanceContent?.dtls?.batchesInfo }; | ||
} | ||
|
||
if (args.batchFiles !== undefined) { | ||
const batchFilesContent = await currentBatch.getFiles(); | ||
payload.batchFiles = batchFilesContent?.map((e) => e.file?.filePath); | ||
} | ||
|
||
if (args.batchResults !== undefined) { | ||
const brC = await currentBatch.getResultsContent(); | ||
if (brC) payload.batchResults = brC; | ||
} | ||
|
||
if (args.promoteResults !== undefined) { | ||
const prC = await batchManager.getResultsContent(); | ||
if (prC) payload.promoteResults = prC; | ||
} | ||
} catch (err) { | ||
logger.error(err); | ||
return errorResponse(GEN_ERROR_SC, `Something went wrong: ${err}`); | ||
} | ||
|
||
return { | ||
payload, | ||
}; | ||
} | ||
|
||
exports.main = main; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters