Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 0 additions & 29 deletions .github/workflows/secrets-scan.yml

This file was deleted.

12 changes: 11 additions & 1 deletion CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
* @contentstack/security-admin
* @contentstack/devex-pr-reviewers

.github/workflows/sca-scan.yml @contentstack/security-admin

.github/workflows/codeql-anaylsis.yml @contentstack/security-admin

**/.snyk @contentstack/security-admin

.github/workflows/policy-scan.yml @contentstack/security-admin

.github/workflows/issues-jira.yml @contentstack/security-admin
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/contentstack-import/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"@contentstack/cli-command": "~1.6.1",
"@contentstack/cli-utilities": "~1.14.1",
"@contentstack/management": "~1.22.0",
"@contentstack/cli-variants": "~1.3.1",
"@contentstack/cli-variants": "~1.3.3",
"@oclif/core": "^4.3.0",
"big-json": "^3.2.0",
"bluebird": "^3.7.2",
Expand Down
15 changes: 9 additions & 6 deletions packages/contentstack-import/src/import/module-importer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class ModuleImporter {
}

async import() {
log.info(`Starting to import content version ${this.importConfig.contentVersion}`);
log.info(`Starting to import content version ${this.importConfig.contentVersion}`, this.importConfig.context);

// checks for single module or all modules
if (this.importConfig.singleModuleImport) {
Expand All @@ -96,7 +96,7 @@ class ModuleImporter {
}

async importByModuleByName(moduleName: Modules) {
log.info(`Starting import of ${moduleName} module`);
log.info(`Starting import of ${moduleName} module`, this.importConfig.context);
// import the modules by name
// calls the module runner which inturn calls the module itself
// NOTE: Implement a mechanism to determine whether module is new or old
Expand All @@ -122,7 +122,10 @@ class ModuleImporter {
// use the algorithm to determine the parallel and sequential execution of modules
for (let moduleName of this.importConfig.modules.types) {
if (this.importConfig.globalModules.includes(moduleName) && this.importConfig['exclude-global-modules']) {
log.warn(`Skipping the import of the global module '${moduleName}', as it already exists in the stack.`);
log.warn(
`Skipping the import of the global module '${moduleName}', as it already exists in the stack.`,
this.importConfig.context,
);
continue;
}
await this.importByModuleByName(moduleName);
Expand Down Expand Up @@ -178,9 +181,9 @@ class ModuleImporter {
});
}
args.push('--modules', 'field-rules');
log.info('Starting audit process');
log.info('Starting audit process', this.importConfig.context);
const result = await AuditFix.run(args);
log.info('Audit process completed');
log.info('Audit process completed', this.importConfig.context);

if (result) {
const { hasFix, config } = result;
Expand All @@ -206,7 +209,7 @@ class ModuleImporter {

return true;
} catch (error) {
log.error(`Audit failed with following error. ${error}`);
log.error(`Audit failed with following error. ${error}`, this.importConfig.context);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-variants/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@contentstack/cli-variants",
"version": "1.3.2",
"version": "1.3.3",
"description": "Variants plugin",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down
33 changes: 16 additions & 17 deletions packages/contentstack-variants/src/import/variant-entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,15 @@ export default class VariantEntries extends VariantAdapter<VariantHttpClient<Imp
this.environments = (fsUtil.readFile(envPath, true) || {}) as Record<string, any>;

log.debug(
`Loaded dependency data - Entries: ${Object.keys(this.entriesUidMapper).length}, Assets: ${
Object.keys(this.assetUidMapper).length
}, Taxonomies: ${Object.keys(this.taxonomies).length}`,
`Loaded dependency data - Entries: ${Object.keys(this.entriesUidMapper)?.length}, Assets: ${
Object.keys(this.assetUidMapper)?.length
}, Taxonomies: ${Object.keys(this.taxonomies)?.length}`,
this.config.context,
);

// set the token
await this.variantInstance.init();

log.info(`Processing ${entriesForVariants.length} entries for variant import`, this.config.context);
log.info(`Processing ${entriesForVariants?.length} entries for variant import`, this.config.context);
for (const entriesForVariant of entriesForVariants) {
await this.importVariantEntries(entriesForVariant);
}
Expand All @@ -166,7 +165,7 @@ export default class VariantEntries extends VariantAdapter<VariantHttpClient<Imp
const variantEntry = this.config.modules.variantEntry;
const { content_type, locale, entry_uid } = entriesForVariant;

log.debug(`Importing variant entries for: ${content_type}/${locale}/${entry_uid}`, this.config.context);
log.info(`Importing variant entries for: ${content_type}/${locale}/${entry_uid}`, this.config.context);

const ctConfig = this.config.modules['content-types'];
const contentType: ContentTypeStruct = JSON.parse(
Expand All @@ -188,14 +187,14 @@ export default class VariantEntries extends VariantAdapter<VariantHttpClient<Imp
sanitizePath(entry_uid),
);

log.debug(`Processing variant entries from: ${variantEntryBasePath}`, this.config.context);
log.info(`Processing variant entries from: ${variantEntryBasePath}`, this.config.context);
const fs = new FsUtility({ basePath: variantEntryBasePath, createDirIfNotExist: false });

for (const _ in fs.indexFileContent) {
try {
const variantEntries = (await fs.readChunkFiles.next()) as VariantEntryStruct[];
if (variantEntries?.length) {
log.debug(`Processing batch of ${variantEntries.length} variant entries`, this.config.context);
log.info(`Processing batch of ${variantEntries.length} variant entries`, this.config.context);
await this.handleConcurrency(contentType, variantEntries, entriesForVariant);
}
} catch (error) {
Expand Down Expand Up @@ -234,15 +233,15 @@ export default class VariantEntries extends VariantAdapter<VariantHttpClient<Imp
const batches = chunk(variantEntries, variantEntryConfig.apiConcurrency || 5);
if (isEmpty(batches)) return;

log.debug(`Starting concurrent processing for ${variantEntries.length} variant entries`, this.config.context);
log.debug(`Starting concurrent processing for ${variantEntries?.length} variant entries`, this.config.context);

for (const [, batch] of entries(batches)) {
batchNo += 1;
const allPromise = [];
const start = Date.now();

log.debug(
`Processing batch ${batchNo}/${batches.length} with ${batch.length} variant entries`,
`Processing batch ${batchNo}/${batches?.length} with ${batch?.length} variant entries`,
this.config.context,
);

Expand Down Expand Up @@ -279,7 +278,7 @@ export default class VariantEntries extends VariantAdapter<VariantHttpClient<Imp
};

if (variantId) {
log.debug(`Creating variant entry for variant ID: ${variantId}`, this.config.context);
log.info(`Creating variant entry for variant ID: ${variantId}`, this.config.context);
const promise = this.variantInstance.createVariantEntry(
createVariantReq,
{
Expand All @@ -302,7 +301,7 @@ export default class VariantEntries extends VariantAdapter<VariantHttpClient<Imp
}

// NOTE Handle the API response here
log.debug(`Waiting for ${allPromise.length} variant entry creation promises to complete`, this.config.context);
log.debug(`Waiting for ${allPromise.length} variant entry creation promises to complete`, this.config.context);
await Promise.allSettled(allPromise);
log.debug(`Batch ${batchNo} creation completed`, this.config.context);

Expand Down Expand Up @@ -421,7 +420,7 @@ export default class VariantEntries extends VariantAdapter<VariantHttpClient<Imp
* @param variantEntry - The entry variant to update.
*/
updateFileFields(variantEntry: VariantEntryStruct) {
log.debug(`Updating file fields for variant entry: ${variantEntry.uid}`, this.config.context);
log.info(`Updating file fields for variant entry: ${variantEntry.uid}`, this.config.context);

const setValue = (currentObj: VariantEntryStruct, keys: string[]) => {
if (!currentObj || keys.length === 0) return;
Expand Down Expand Up @@ -455,7 +454,7 @@ export default class VariantEntries extends VariantAdapter<VariantHttpClient<Imp
?.filter((ref: any) => ref._content_type_uid === 'sys_assets')
.map((ref: any) => ref.path) || [];

log.debug(`Found ${pathsToUpdate.length} file field paths to update`, this.config.context);
log.debug(`Found ${pathsToUpdate?.length} file field paths to update`, this.config.context);
pathsToUpdate.forEach((path: string) => setValue(variantEntry, path.split('.')));
}

Expand Down Expand Up @@ -485,12 +484,12 @@ export default class VariantEntries extends VariantAdapter<VariantHttpClient<Imp
}

if (this.failedVariantEntries.has(variantEntryUID)) {
log.debug(`Variant UID not found. Skipping entry variant publish for ${variantEntryUID}`, this.config.context);
log.info(`Variant UID not found. Skipping entry variant publish for ${variantEntryUID}`, this.config.context);
continue;
}

if (this.environments?.length) {
log.debug('No environment found! Skipping entry variant publishing...', this.config.context);
log.info('No environment found! Skipping entry variant publishing...', this.config.context);
return;
}

Expand All @@ -510,7 +509,7 @@ export default class VariantEntries extends VariantAdapter<VariantHttpClient<Imp

const { environments, locales } = this.serializePublishEntries(variantEntry);
if (environments?.length === 0 || locales?.length === 0) {
log.debug(`Skipping publish for variant ${newVariantUid} - no environments or locales`, this.config.context);
log.info(`Skipping publish for variant ${newVariantUid} - no environments or locales`, this.config.context);
continue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export class PersonalizationAdapter<T> extends AdapterHelper<T, HttpClient> impl
log.debug(`Creating project: ${project.name}`, this.exportConfig?.context );
const data = await this.apiClient.post<ProjectStruct>('/projects', project);
const result = (await this.handleVariantAPIRes(data)) as ProjectStruct;
log.debug(`Project created successfully: ${result.uid}`, this.exportConfig?.context );
log.info(`Project created successfully: ${result?.uid}`, this.exportConfig?.context );
return result;
}

Expand All @@ -101,7 +101,7 @@ export class PersonalizationAdapter<T> extends AdapterHelper<T, HttpClient> impl
log.debug(`Creating attribute: ${attribute.name}`, this.exportConfig?.context );
const data = await this.apiClient.post<AttributeStruct>('/attributes', attribute);
const result = (await this.handleVariantAPIRes(data)) as AttributeStruct;
log.debug(`Attribute created successfully: ${result.uid}`, this.exportConfig?.context );
log.info(`Attribute created successfully: ${result?.uid}`, this.exportConfig?.context );
return result;
}

Expand All @@ -110,7 +110,7 @@ export class PersonalizationAdapter<T> extends AdapterHelper<T, HttpClient> impl
const getExperiencesEndPoint = `/experiences`;
const data = await this.apiClient.get(getExperiencesEndPoint);
const result = (await this.handleVariantAPIRes(data)) as ExperienceStruct[];
log.debug(`Fetched ${result?.length || 0} experiences`, this.exportConfig?.context );
log.info(`Fetched ${result?.length || 0} experiences`, this.exportConfig?.context );
return result;
}

Expand All @@ -122,7 +122,7 @@ export class PersonalizationAdapter<T> extends AdapterHelper<T, HttpClient> impl
}
const data = await this.apiClient.get(getExperiencesEndPoint);
const result = (await this.handleVariantAPIRes(data)) as ExperienceStruct;
log.debug(`Experience fetched successfully: ${result?.uid}`, this.exportConfig?.context );
log.info(`Experience fetched successfully: ${result?.uid}`, this.exportConfig?.context );
return result;
}

Expand All @@ -134,7 +134,7 @@ export class PersonalizationAdapter<T> extends AdapterHelper<T, HttpClient> impl
}
const data = await this.apiClient.get(getExperiencesVersionsEndPoint);
const result = (await this.handleVariantAPIRes(data)) as ExperienceStruct;
log.debug(`Experience versions fetched successfully for: ${experienceUid}`, this.exportConfig?.context );
log.info(`Experience versions fetched successfully for: ${experienceUid}`, this.exportConfig?.context );
return result;
}

Expand All @@ -146,7 +146,7 @@ export class PersonalizationAdapter<T> extends AdapterHelper<T, HttpClient> impl
const createExperiencesVersionsEndPoint = `/experiences/${experienceUid}/versions`;
const data = await this.apiClient.post(createExperiencesVersionsEndPoint, input);
const result = (await this.handleVariantAPIRes(data)) as ExperienceStruct;
log.debug(`Experience version created successfully for: ${experienceUid}`, this.exportConfig?.context );
log.info(`Experience version created successfully for: ${experienceUid}`, this.exportConfig?.context );
return result;
}

Expand Down Expand Up @@ -176,7 +176,7 @@ export class PersonalizationAdapter<T> extends AdapterHelper<T, HttpClient> impl
.queryParams({ experience_uid: input.experienceUid })
.get(getVariantGroupEndPoint);
const result = (await this.handleVariantAPIRes(data)) as VariantGroupStruct;
log.debug(`Variant group fetched successfully for experience: ${input.experienceUid}`, this.exportConfig?.context );
log.debug(`Variant group fetched successfully for experience: ${input?.experienceUid}`, this.exportConfig?.context );
return result;
} else {
log.debug('CMA API client not available for variant group fetch', this.exportConfig?.context );
Expand Down Expand Up @@ -208,23 +208,23 @@ export class PersonalizationAdapter<T> extends AdapterHelper<T, HttpClient> impl
log.debug(`Creating event: ${event.key}`, this.exportConfig?.context );
const data = await this.apiClient.post<EventStruct>('/events', event);
const result = (await this.handleVariantAPIRes(data)) as EventStruct;
log.debug(`Event created successfully: ${result.uid}`, this.exportConfig?.context );
log.info(`Event created successfully: ${result?.uid}`, this.exportConfig?.context );
return result;
}

async getAudiences(): Promise<AudienceStruct[] | void> {
log.debug('Fetching audiences from personalization API', this.exportConfig?.context );
const data = await this.apiClient.get<AudienceStruct>('/audiences');
const result = (await this.handleVariantAPIRes(data)) as AudienceStruct[];
log.debug(`Fetched ${result?.length || 0} audiences`, this.exportConfig?.context );
log.info(`Fetched ${result?.length || 0} audiences`, this.exportConfig?.context );
return result;
}

async getAttributes(): Promise<AttributeStruct[] | void> {
log.debug('Fetching attributes from personalization API', this.exportConfig?.context );
const data = await this.apiClient.get<AttributeStruct>('/attributes');
const result = (await this.handleVariantAPIRes(data)) as AttributeStruct[];
log.debug(`Fetched ${result?.length || 0} attributes`, this.exportConfig?.context );
log.info(`Fetched ${result?.length || 0} attributes`, this.exportConfig?.context );
return result;
}

Expand All @@ -240,7 +240,7 @@ export class PersonalizationAdapter<T> extends AdapterHelper<T, HttpClient> impl
log.debug(`Creating audience: ${audience.name}`, this.exportConfig?.context );
const data = await this.apiClient.post<AudienceStruct>('/audiences', audience);
const result = (await this.handleVariantAPIRes(data)) as AudienceStruct;
log.debug(`Audience created successfully: ${result.uid}`, this.exportConfig?.context );
log.info(`Audience created successfully: ${result?.uid}`, this.exportConfig?.context );
return result;
}

Expand All @@ -256,7 +256,7 @@ export class PersonalizationAdapter<T> extends AdapterHelper<T, HttpClient> impl
log.debug(`Creating experience: ${experience.name}`, this.exportConfig?.context );
const data = await this.apiClient.post<ExperienceStruct>('/experiences', experience);
const result = (await this.handleVariantAPIRes(data)) as ExperienceStruct;
log.debug(`Experience created successfully: ${result.uid}`, this.exportConfig?.context );
log.info(`Experience created successfully: ${result?.uid}`, this.exportConfig?.context );
return result;
}

Expand All @@ -273,7 +273,7 @@ export class PersonalizationAdapter<T> extends AdapterHelper<T, HttpClient> impl
const updateCTInExpEndPoint = `/experiences/${experienceUid}/cms-integration/variant-group`;
const data = await this.apiClient.post<CMSExperienceStruct>(updateCTInExpEndPoint, experience);
const result = (await this.handleVariantAPIRes(data)) as CMSExperienceStruct;
log.debug(`Content types updated successfully in experience: ${experienceUid}`, this.exportConfig?.context );
log.info(`Content types updated successfully in experience: ${experienceUid}`, this.exportConfig?.context );
return result;
}

Expand All @@ -287,7 +287,7 @@ export class PersonalizationAdapter<T> extends AdapterHelper<T, HttpClient> impl
const getCTFromExpEndPoint = `/experiences/${experienceUid}/cms-integration/variant-group`;
const data = await this.apiClient.get<CMSExperienceStruct>(getCTFromExpEndPoint);
const result = (await this.handleVariantAPIRes(data)) as CMSExperienceStruct;
log.debug(`Content types fetched successfully from experience: ${experienceUid}`, this.exportConfig?.context );
log.info(`Content types fetched successfully from experience: ${experienceUid}`, this.exportConfig?.context );
return result;
}

Expand Down
Loading
Loading