CMS Connector API Guide

New CMS Connector API Guide  

This document serves as a guide for extending the CMS Connector API to support new Content  Management Systems (CMS) and file types. It outlines the process of creating new CMS  packages, updating validator and mapper logic, and handling various file extensions and CMS  configurations in the `/validator` route and `handleFileProcessing` function. The goal is to  maintain a modular and CMS-agnostic architecture, allowing for seamless integration of different  CMS platforms by following a structured approach for validation, processing, and data mapping.  

new icon Creating a Similar CMS Package  

ഇഷ്ടപ്പെടുക migration-contentful, migration-sitecoremigration-wordpress 

To support a new CMS (e.g., Drupal), create a new package like this:  

ടൈപ്പ്സ്ക്രിപ്റ്റ്

 migration-drupal/

Inside it, implement the required structure:  

ടൈപ്പ്സ്ക്രിപ്റ്റ്

// migration-drupal/index.js  

const validator = (data) => {

 // Validate file format, structure, required fields  

};const എക്സ്ട്രാക്റ്റ്Files = async (filePath) => {

 // Unzip or parse content  

};

നിങ്ങൾക്ക് എന്തെങ്കിലും ചോദ്യങ്ങളുണ്ടെങ്കിൽ, ദയവായി ബന്ധപ്പെടുക tso-migration@contentstack.com. 

const contentTypes = {

 // Drupal-specific content type definitions  

};

const reference = {

 // Drupal-specific field references  

};

const extractLocales = (data) => {

 // Return locale array  

};

മൊഡ്യൂൾ.exports = {

 validator,

 എക്സ്ട്രാക്റ്റ്Files,

 contentTypes,

 റഫറൻസ്,

 extractLocales

};

plugged icon Where It’s Plugged In  

Once your package (e.g., migration-drupal) is ready:  

1. Add it to package.json:  

നിങ്ങൾക്ക് എന്തെങ്കിലും ചോദ്യങ്ങളുണ്ടെങ്കിൽ, ദയവായി ബന്ധപ്പെടുക tso-migration@contentstack.com. 

JSON

“migration-drupal”"file:migration-drupal”

2. Update your validator logic:  

ടൈപ്പ്സ്ക്രിപ്റ്റ്

const { validator: drupalValidator } = ആവശ്യപ്പെടുന്നു(‘migration-drupal’);

സ്വിച്ച് (CMSIdentifier) {

 കേസ് ‘drupal-zip’:

 മടങ്ങുക drupalValidator({ data });

}

3. Update createMapper logic and Add the case in createMapper switch::  

ടൈപ്പ്സ്ക്രിപ്റ്റ്

കേസ് ‘drupal’:

 മടങ്ങുക await createDrupalMapper(…);

✅ ✅ സ്ഥാപിതമായത് സംഗ്രഹം  

To add a new CMS, simply:  

  • Scaffold a package like migration-drupal 
  • Follow the existing method structure
  • Add it to validator and mapper switch blocks

This keeps the architecture modular and CMS-agnostic, all the explanations provided in  subTabs. 

നിങ്ങൾക്ക് എന്തെങ്കിലും ചോദ്യങ്ങളുണ്ടെങ്കിൽ, ദയവായി ബന്ധപ്പെടുക tso-migration@contentstack.com. 

validator validator Route  

This route is used to validate and process a file (local or from AWS S3), based on file type and CMS configuration.  

✅ ✅ സ്ഥാപിതമായത് പ്രവർത്തനം കഴിഞ്ഞുview  

  • Accepts a GET request to /validator 
  • ആണോ എന്ന് നിർണ്ണയിക്കുന്നു file source is local or from S3
  • അടിസ്ഥാനമാക്കി file വിപുലീകരണം:
    ○ If XML → reads as string
    ○ Else (e.g., ZIP) → reads as binary buffer
  • Calls handle File Processing with file ഡാറ്റ
  • On success, maps the processed file using create Mapper

ചേർക്കുക Where to Add Support for New File തരങ്ങൾ  

In this route, file extensions are determined using:  

ജാവാസ്ക്രിപ്റ്റ്

const fileExt = fileName?.split?.('.')?.pop() ?? ;

Then based on file extension, logic is handled like this:

ജാവാസ്ക്രിപ്റ്റ്

if (fileExt === ‘xml’) {

 // Process XML as string  

വേറെ {

 // Process as buffer (e.g., zip)  

}

If you want to add a new file type, you can add it inside this condition: നിങ്ങൾക്ക് എന്തെങ്കിലും ചോദ്യങ്ങളുണ്ടെങ്കിൽ, ദയവായി ബന്ധപ്പെടുക tso-migration@contentstack.com. 

ജാവാസ്ക്രിപ്റ്റ്

if (fileExt === ‘xml’) {

 //…  

else if (fileExt === ‘yourNewExtension’) {

 // Add logic to read and handle this new file തരം  

വേറെ {

 // Default processing for binary files  

}

You may also need to extend handleFileProcessing to handle the new file തരം.  

ചേർക്കുക Where to Add Support for New CMS Types  

The cmsType is retrieved from:  

const cmsType = config?.cmsType?.toLowerCase();

Later, this variable is passed to:  

const data = await handle File Processing (file Ext, file Data, cms Type, name);

ചൂണ്ടിക്കാട്ടി If you want to add a new CMS, you can extend logic inside handle File Processing or wherever you handle CMS-specific processing.  

Also update:  

createMapper(filePath, projectId, app_token, affix, config); To support your new CMS type, add logic to createMapper to handle it accordingly.  

✅ ✅ സ്ഥാപിതമായത് സംഗ്രഹം  

● You can add new file extensions by modifying the fileExt condition  നിങ്ങൾക്ക് എന്തെങ്കിലും ചോദ്യങ്ങളുണ്ടെങ്കിൽ, ദയവായി ബന്ധപ്പെടുക tso-migration@contentstack.com. 

● You can add new CMS types by extending handleFileProcessing and createMapper  

● The system already separates XML (string) and ZIP (buffer) handling — follow that  structure  

validator കൈകാര്യം ചെയ്യുക File പ്രോസസ്സിംഗ്  

This document explains how to integrate a new CMS platform into the existing file validation and  processing flow using the functions:  

● handleFileProcessing()  

● validator()  

plugged icon ഉദ്ദേശം  

The backend currently supports multiple CMS types (like Sitecore, Contentful, WordPress,  AEM). The goal is to validate uploaded files and transform them into a structured format specific  to each CMS.  

The system identifies a CMS + file type pair using this format:  

സിസ്റ്റം type-extension → e.g., sitecore-zip, contentful-json, wordpress-xml  

ഫംഗ്ഷൻ ഐക്കൺ Where to Add a New CMS  

Step 1: Update the validator () Function  

Located inside:  

ജാവാസ്ക്രിപ്റ്റ്

const validator = ({ data, type, extension }: { data: any; type: string; extension: string }) => { … }

Find the switch statement on CMSIdentifier. Each case handles one CMS-type and  file-extension combination.  

ചൂണ്ടിക്കാട്ടി To add a new CMS, add a new case in this switch block:

ExampLe:  

നിങ്ങൾക്ക് എന്തെങ്കിലും ചോദ്യങ്ങളുണ്ടെങ്കിൽ, ദയവായി ബന്ധപ്പെടുക tso-migration@contentstack.com. 

ജാവാസ്ക്രിപ്റ്റ്

കേസ് ‘newcms-json’: {

 മടങ്ങുക newCMSValidator(data); // Your new validation logic  }

ഉറപ്പാക്കുക:  

● CMSIdentifier format matches the expected {type}-{extension}  

● The validation function (e.g., newCMSValidator) is imported or defined  

brain You can add multiple variations, like:  

case ‘newcms-zip’:  

case ‘newcms-xml’:

Step 2: Create the Validator Function  

In your project, define the validator logic for the new CMS. ExampLe:

ജാവാസ്ക്രിപ്റ്റ്

const newCMSValidator = (data) => {

 // Your custom validation logic for JSON, ZIP, etc.  

 മടങ്ങുക true; // or false if validation fails  

};

ചരട് Input: This could be:  

● A JSZip object (for zip)  

● Raw XML string  

● JSON object/string  

ചരട് Output: Boolean (true = valid, false = rejected)  

നിങ്ങൾക്ക് എന്തെങ്കിലും ചോദ്യങ്ങളുണ്ടെങ്കിൽ, ദയവായി ബന്ധപ്പെടുക tso-migration@contentstack.com. 

Step 3: Test with handleFileProcessing()  

The validator() function is used inside handleFileProcessing():

ജാവാസ്ക്രിപ്റ്റ്

if (await validator({ data: zipBuffer, type: cmsType, extension: fileExt })) {  //…  

}

Make sure your new CMS validator is covered in the condition by passing the correct:  

● cmsType (from config.cmsType)  

● fileExt (from the uploaded file)  

✅ ✅ സ്ഥാപിതമായത് Summary Checklist  

ടാസ്‌ക് വിവരണം

Add new case Update validator() switch block  

Implement logic Write your own newCMSValidator function  

മടങ്ങുക  

ശരി/തെറ്റ്  

Ensure validator returns a boolean  

Use correct key Follow type-extension format (e.g., newcms-zip)  

�� Optional: Debugging Tips  

നിങ്ങൾക്ക് എന്തെങ്കിലും ചോദ്യങ്ങളുണ്ടെങ്കിൽ, ദയവായി ബന്ധപ്പെടുക tso-migration@contentstack.com. 

● Log the CMSIdentifier inside validator() to ensure your case is reached.  

● Ensure handleFileProcessing is passing correct fileExt and cmsType.  

Adding Mapper Support for a New CMS  

After validating and processing a file, the backend prepares mapping data using the  createMapper function. This step transforms the extracted content into a standardized format that can be used to generate dummy data and locale mappings in your CMS.  

How Mapping Works (High-Level Flow)  

1. ✅ ✅ സ്ഥാപിതമായത് File is successfully validated and saved (ZIP, XML, JSON, etc.)  

2. പാത Path to the processed file is determined:  

ജാവാസ്ക്രിപ്റ്റ്

const filePath = path.join(__dirname, '..''..'‘extracted_fileഎസ്', fileName);

3. brain The createMapper function is invoked:  

ജാവാസ്ക്രിപ്റ്റ്

createMapper(filePath, projectId, app_token, affix, config);

4. യുക്തി This function routes logic based on the CMS type (e.g., sitecore, contentful,  wordpress)

ഘടന createMapper Function – Structure  

ജാവാസ്ക്രിപ്റ്റ്

const createMapper = അസിങ്ക്രോണസ് (

 fileപാത,

 projectId,

 app_token,

നിങ്ങൾക്ക് എന്തെങ്കിലും ചോദ്യങ്ങളുണ്ടെങ്കിൽ, ദയവായി ബന്ധപ്പെടുക tso-migration@contentstack.com. 

 affix,

 കോൺഫിഗറേഷൻ

) => {

 const CMSIdentifier = config?.cmsType?.toLowerCase();

 സ്വിച്ച് (CMSIdentifier) {

 കേസ് ‘sitecore’:

 return await createSitecoreMapper(filePath, projectId, app_token, affix, config);

 കേസ് ‘contentful’:

 return await createContentfulMapper(projectId, app_token, affix, config);  കേസ് ‘wordpress’:

 മടങ്ങുക createWordpressMapper(filePath, projectId, app_token, affix);  സ്ഥിരസ്ഥിതി:

 മടങ്ങുക false;

 }

};

സിസ്റ്റം Each case corresponds to a CMS and calls its mapper function.  

new icon How to Add a New CMS  

Step 1: Add Case in createMapper  

Add a new case for your CMS identifier:  

ജാവാസ്ക്രിപ്റ്റ്

കേസ് ‘newcms’: {

 return await createNewCMSMapper(filePath, projectId, app_token, affix, config);

നിങ്ങൾക്ക് എന്തെങ്കിലും ചോദ്യങ്ങളുണ്ടെങ്കിൽ, ദയവായി ബന്ധപ്പെടുക tso-migration@contentstack.com. 

}

Step 2: Create the Mapper Function  

Implement a new function like:  

ജാവാസ്ക്രിപ്റ്റ്

const createNewCMSMapper = അസിങ്ക്രോണസ് (filePath, projectId, app_token, affix, config) => {

 // 1. Read and transform file ഉള്ളടക്കം  

 // 2. Generate field mapping object  

 // 3. Send to /v2/mapper/createDummyData  

 // 4. Generate locale mapping and call /v2/migration/localeMapper  };

Step 3: Make Dummy Data API Call  

Use axios like the existing implementation:  

ജാവാസ്ക്രിപ്റ്റ്

const config = {

 രീതി: ‘post’,

 maxBodyLength: അനന്തത,

 url:

`${process.env.NODE_BACKEND_API}/v2/mapper/createDummyData/${projectId}`,  headers: {

 app_token,

 ‘Content-Type’‘application/json’

 },

 ഡാറ്റ: JSON.stringify(fieldMapping),

നിങ്ങൾക്ക് എന്തെങ്കിലും ചോദ്യങ്ങളുണ്ടെങ്കിൽ, ദയവായി ബന്ധപ്പെടുക tso-migration@contentstack.com. 

};

const { data } = await axios.request(config);

if (data?.data?.content_mapper?.നീളം) {

 deleteFolderSync(infoMap?.path);

 logger.info(‘Validation success:’, {

 status: HTTP_CODES?.OK,

 message: HTTP_TEXTS?.MAPPER_SAVED,

 });

}

ഘട്ടം 4: Handle Locale Mapping  

If your CMS supports localization, add this or add en-us as default:  

ജാവാസ്ക്രിപ്റ്റ്

const mapperConfig = {

 രീതി: ‘post’,

 maxBodyLength: അനന്തത,

 url:

`${process.env.NODE_BACKEND_API}/v2/migration/localeMapper/${projectId}`,  headers: {

 app_token,

 ‘Content-Type’‘application/json’

 },

 ഡാറ്റ: {

നിങ്ങൾക്ക് എന്തെങ്കിലും ചോദ്യങ്ങളുണ്ടെങ്കിൽ, ദയവായി ബന്ധപ്പെടുക tso-migration@contentstack.com. 

 പ്രദേശം: അറേ.from(localeData) ?? []

 }

};

await axios.request(mapperConfig);

പ്രവർത്തിപ്പിക്കുന്നത് upload-api Project on Any Operating  System  

The following instructions will guide you in running the upload-api folder on any operating  system, including Windows and macOS.  

ആരംഭിക്കുന്നു upload-api പദ്ധതി  

There are two methods to start the upload-api പദ്ധതി:  

രീതി 1:  

 Run the following command from the root directory of your project:  

ഷെൽ

npm run upload

This command will directly start the upload-api പാക്കേജ്.  

രീതി 2:  

 എന്നതിലേക്ക് നാവിഗേറ്റ് ചെയ്യുക upload-api directory manually and run the development server:  

ഷെൽ

cd upload-api

npm run start

This approach starts the upload-api from within its own directory.  

Restarting After Termination  

നിങ്ങൾക്ക് എന്തെങ്കിലും ചോദ്യങ്ങളുണ്ടെങ്കിൽ, ദയവായി ബന്ധപ്പെടുക tso-migration@contentstack.com. 

If the project terminates unexpectedly, you can restart it by following the same steps outlined  above. Choose either Method 1 or Method 2 to relaunch the service.  

നിങ്ങൾക്ക് എന്തെങ്കിലും ചോദ്യങ്ങളുണ്ടെങ്കിൽ, ദയവായി ബന്ധപ്പെടുക tso-migration@contentstack.com. 

പ്രമാണങ്ങൾ / വിഭവങ്ങൾ

CONTENTSTACK CMS Connector API Guide [pdf] ഉപയോക്തൃ ഗൈഡ്
CMS Connector API Guide, Connector API Guide, API Guide

റഫറൻസുകൾ

ഒരു അഭിപ്രായം ഇടൂ

നിങ്ങളുടെ ഇമെയിൽ വിലാസം പ്രസിദ്ധീകരിക്കില്ല. ആവശ്യമായ ഫീൽഡുകൾ അടയാളപ്പെടുത്തി *