Skip to content

Commit a0fef34

Browse files
bhellemaBen Helleman
andauthored
fix: SITES-25634 [Importer] Expose hasCustomImportJs and hasCustomHeaders as two new fields on a import job (#509)
Co-authored-by: Ben Helleman <bhellema@adobe.com>
1 parent 3785e2c commit a0fef34

File tree

4 files changed

+27
-11
lines changed

4 files changed

+27
-11
lines changed

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
"@adobe/helix-shared-wrap": "2.0.2",
6767
"@adobe/helix-status": "10.1.3",
6868
"@adobe/helix-universal-logger": "3.0.20",
69-
"@adobe/spacecat-shared-data-access": "1.44.5",
69+
"@adobe/spacecat-shared-data-access": "1.45.1",
7070
"@adobe/spacecat-shared-http-utils": "1.6.10",
7171
"@adobe/spacecat-shared-ims-client": "1.3.16",
7272
"@adobe/spacecat-shared-rum-api-client": "2.9.4",

src/dto/import-job.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,7 @@ export const ImportJobDto = {
3030
successCount: importJob.getSuccessCount(),
3131
failedCount: importJob.getFailedCount(),
3232
redirectCount: importJob.getFailedCount(),
33+
hasCustomHeaders: importJob.hasCustomHeaders(),
34+
hasCustomImportJs: importJob.hasCustomImportJs(),
3335
}),
3436
};

src/support/import-supervisor.js

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,20 @@ function ImportSupervisor(services, config) {
9494
* @param {string} hashedApiKey - API key used to authenticate the import job request.
9595
* @param {object} options - Client provided options for the import job.
9696
* @param initiatedBy - Details about the initiator of the import job.
97+
* @param {boolean} hasCustomHeaders - Whether custom headers are provided. Defaults to false.
98+
* @param {boolean} hasCustomImportJs - Whether custom import JS is provided. Defaults to false.
9799
* @returns {Promise<ImportJob>}
98100
*/
99-
async function createNewImportJob(urls, importQueueId, hashedApiKey, options, initiatedBy) {
100-
const newJob = {
101+
async function createNewImportJob(
102+
urls,
103+
importQueueId,
104+
hashedApiKey,
105+
options,
106+
initiatedBy,
107+
hasCustomHeaders = false,
108+
hasCustomImportJs = false,
109+
) {
110+
return dataAccess.createNewImportJob({
101111
id: crypto.randomUUID(),
102112
baseURL: determineBaseURL(urls),
103113
importQueueId,
@@ -106,8 +116,9 @@ function ImportSupervisor(services, config) {
106116
urlCount: urls.length,
107117
status: ImportJobStatus.RUNNING,
108118
initiatedBy,
109-
};
110-
return dataAccess.createNewImportJob(newJob);
119+
hasCustomHeaders,
120+
hasCustomImportJs,
121+
});
111122
}
112123

113124
/**
@@ -126,6 +137,7 @@ function ImportSupervisor(services, config) {
126137
* asynchronously.
127138
* @param {Array<string>} urls - Array of URL records to queue.
128139
* @param {object} importJob - The import job record.
140+
* @param {object} customHeaders - Optional custom headers to be sent with each request.
129141
*/
130142
async function queueUrlsForImportWorker(urls, importJob, customHeaders) {
131143
log.info(`Starting a new import job of baseUrl: ${importJob.getBaseURL()} with ${urls.length}`
@@ -159,8 +171,8 @@ function ImportSupervisor(services, config) {
159171
* @param {string} importApiKey - The API key to use for the import job.
160172
* @param {object} options - Optional configuration params for the import job.
161173
* @param {string} importScript - Optional custom Base64 encoded import script.
162-
* @param initiatedBy - Details about the initiator of the import job.
163-
* @param customHeaders - Optional custom headers to be sent with each request.
174+
* @param {object} initiatedBy - Details about the initiator of the import job.
175+
* @param {object} customHeaders - Optional custom headers to be sent with each request.
164176
* @returns {Promise<ImportJob>}
165177
*/
166178
async function startNewJob(
@@ -184,6 +196,8 @@ function ImportSupervisor(services, config) {
184196
hashedApiKey,
185197
options,
186198
initiatedBy,
199+
!!customHeaders,
200+
!!importScript,
187201
);
188202

189203
log.info('New import job created:\n'

0 commit comments

Comments
 (0)