Class: PersistenceStoreInterface

Class: PersistenceStoreInterface

QuickNav

PersistenceStoreInterface

new PersistenceStoreInterface()

Manage persistence of the job during the jobs lifecycle.
This module is responsible for saving the state of the job and managing the state during startup/shutdown & failover.
  • Specifically, it needs to:
    • Keep track of all the jobs.
    • For each job:
      • Store metadata about the job and mapping it to the project in the Language Service Provider.
      • Store/Unpack the zip file provided by the OCE translation job.
      • Store metadata about each file in the zip mapping the file to the entry in the Language Service Provider.
      • Store all the translations for each of the files as they become available.
      • Create a final zip of all the translated files in the format required for ingestion into the OCE translation jobs.
      • On job delete, remove all artifacts associated with the job.
Source:

Methods

addBinaryTranslationFile(args) → {Promise}

Add a translated binary file to the translation repository
Parameters:
Name Type Description
args object JavaScript object containing the "addTranslationFile" parameters.
Properties
Name Type Description
jobId string Identifier of the job.
locale string The locale of the translation for this file.
fileType 'site' | 'assets' Type of file to fetch - whether it's an assets file or a site resource.
filePath string Name of the file on the file system to return.
fileContent string Translated content for the file.
fileName string Descriptive name if failed to write the file contents.
folderPath string Folder path to the binary file.
Source:
Returns:
A Promise that is resolved when the file has been saved to the translation repository.
Type
Promise

addTranslationFile(args) → {Promise}

Add a translated file to the translation repository
Parameters:
Name Type Description
args object JavaScript object containing the "addTranslationFile" parameters.
Properties
Name Type Description
jobId string Identifier of the job.
locale string The locale of the translation for this file.
fileType 'site' | 'assets' Type of file to fetch - whether it's an assets file or a site resource.
filePath string Name of the file on the file system to return.
fileContent string Translated content for the file.
fileName string Descriptive name if failed to write the file contents.
Source:
Returns:
A Promise that is resolved when the file has been saved to the translation repository.
Type
Promise

createFileMetadata(args) → {Promise.<PersistenceApi.fileMetadata>}

Create the metadata to be held for a file being translated.
Parameters:
Name Type Description
args object JavaScript object containing the "createFileMetadata" parameters.
Properties
Name Type Description
jobId string Identifier of the job.
fileType 'site' | 'assets' Type of file to fetch - whether it's an assets file or a site resource.
file SampleJobManager.file Details about the file in the persistence store.
Source:
Returns:
A Promise that is resolved with a details on the metadata for the file
Type
Promise.<PersistenceApi.fileMetadata>

createJob(args) → {Promise.<SampleJobManager.JobConfig>}

Create a translation job
Create an entry for this translation job in the persistence store.
Parameters:
Name Type Description
args object JavaScript object containing the "createJob" parameters.
Properties
Name Type Description
jobName string Name of the OCE translation job.
workflowId string Language Service Provider workflow identifier to use to translate this job.
authToken string Language Service Provider Authorization header to use to communicate with the LSP.
additionalData string Additional Data to apply on each document in the LSP.
Source:
Returns:
The metadata created and stored for this job.
Type
Promise.<SampleJobManager.JobConfig>

createTranslationRepository(args) → {Promise}

Create a repository to hold all the translated files.
Parameters:
Name Type Description
args object JavaScript object containing the "createTranslationRepository" parameters.
Properties
Name Type Description
jobId string Identifier of the job.
Source:
Returns:
A Promise that is resolved when the repository has been setup to receive translations.
Type
Promise

createTranslationZip(args) → {Promise.<SampleJobManager.JobConfig>}

Create the export zip file for the translated files.
Parameters:
Name Type Description
args object JavaScript object containing the "createTranslationZip" parameters.
Properties
Name Type Description
jobId string Identifier of the job.
Source:
Returns:
A Promise that is resolved with the updated job metadata containing the "translatedZipFile" property for the created zip file.
Type
Promise.<SampleJobManager.JobConfig>

deleteJob(args) → {Promise}

Delete all persistence data related to the provided job identifier.
Parameters:
Name Type Description
args object JavaScript object containing the "deleteJob" parameters.
Properties
Name Type Description
jobId string Identifier of the job to be deleted.
Source:
Returns:
A Promise that is resolved when the job has been deleted.
Type
Promise

exportTranslationZip(args) → {Promise.<PersistenceApi.ZipFileStream>}

Export the translated zip file
Parameters:
Name Type Description
args object JavaScript object containing the "exportTranslationZip" parameters.
Properties
Name Type Description
jobId string Identifier of the job.
Source:
Returns:
A Promise that is resolved with a zip file stream that can be returned in an HTTPS response.
Type
Promise.<PersistenceApi.ZipFileStream>

getAllJobs() → {Promise.<Array.<SampleJobManager.JobConfig>>}

Get all the jobs currently tracked by the PersistenceApi
Source:
Returns:
A Promise that returns an array of the metadata for each of the translation jobs.
Type
Promise.<Array.<SampleJobManager.JobConfig>>

getBinaryFile(args) → {Promise.<string>}

Get binary file.
Parameters:
Name Type Description
args object JavaScript object containing the "getSourceFile" parameters.
Properties
Name Type Description
jobId string Identifier of the job.
fileType 'site' | 'assets' Type of file to fetch - whether it's an assets file or a site resource.
folderPath string Folder path of the binary file directory.
file SampleJobManager.file Details about the file to return from the persistence store.
Source:
Returns:
binary file.
Type
Promise.<string>

getBinaryFilePath() → {string}

Get path to the binary files folder of the digital asset.
Parameters:
Name Type Description
args.contentItemId string Digital Asset Id
Source:
Returns:
path to the binary files folder of the digital asset.
Type
string

getBinaryFileSpec(args) → {string}

Get binary file spec of the binary file.
Parameters:
Name Type Description
args object JavaScript object containing the "getSourceFile" parameters.
Properties
Name Type Description
jobId string Identifier of the job.
fileType 'site' | 'assets' Type of file to fetch - whether it's an assets file or a site resource.
folderPath string Folder path of the binary file directory.
file SampleJobManager.file Details about the file to return from the persistence store.
Source:
Returns:
binary file spec of the digital asset.
Type
string

getFileMetadata(args) → {Promise.<PersistenceApi.fileMetadata>}

Get the meta-data for a file being translated.
Parameters:
Name Type Description
args object JavaScript object containing the "getFileMetadata" parameters.
Properties
Name Type Description
jobId string Identifier of the job.
fileType 'site' | 'assets' Type of file to fetch - whether it's an assets file or a site resource.
file SampleJobManager.file Details about the file in the persistence store.
Source:
Returns:
A Promise that is resolved with a details on the metadata for the file
Type
Promise.<PersistenceApi.fileMetadata>

getFolderFiles(args) → {Array.<string>}

Get list of files in the binary files folder of the digital asset.
Parameters:
Name Type Description
args object JavaScript object containing the "getSourceFile" parameters.
Properties
Name Type Description
jobId string Identifier of the job.
fileType 'site' | 'assets' Type of file to fetch - whether it's an assets file or a site resource.
folderPath string Folder path of the binary file directory.
file SampleJobManager.file Details about the file to return from the persistence store.
Source:
Returns:
list of files in the binary files folder of the digital asset.
Type
Array.<string>

getJob(args) → {Promise.<SampleJobManager.JobConfig>}

Get a translation job.
Retrieve the job metadata from the persistence store for this job.
Parameters:
Name Type Description
args object JavaScript object containing the "getJob" parameters.
Properties
Name Type Description
jobId string Identifier for the job in the persistence store.
Source:
Returns:
The metadata created and stored for this job.
Type
Promise.<SampleJobManager.JobConfig>

getSourceFile(args) → {Promise.<string>}

Get the requested source file from the job.
Parameters:
Name Type Description
args object JavaScript object containing the "getSourceFile" parameters.
Properties
Name Type Description
jobId string Identifier of the job.
fileType 'site' | 'assets' Type of file to fetch - whether it's an assets file or a site resource.
filePath string Name of the file on the file system to return.
file SampleJobManager.file Details about the file to return from the persistence store.
Source:
Returns:
A Promise that is resolved with the file content.
Type
Promise.<string>

getSourceJobJSON(args) → {Promise.<SampleJobManager.JobDetails>}

Get the source job.json files that are in the zip file.
The job can be either:
  • "assets" job type, which has a structure of:
    • job.json
    • root
  • "site" job type, which has a structure of:
    • assets
      • job.json
      • root
    • site
      • job.json
      • root
Parameters:
Name Type Description
args object JavaScript object containing the "getSourceJobJSON" parameters.
Properties
Name Type Description
jobId string Identifier of the job to retrieve the job.json information.
Source:
Returns:
A Promise that is resolved with the combined job.json files.
Type
Promise.<SampleJobManager.JobDetails>

importSourceZip(args) → {Promise}

Import the source zip file and expand it into the "translation-source" folder in the persistence store.
Parameters:
Name Type Description
args object JavaScript object containing the "importSourceZip" parameters.
Properties
Name Type Description
jobId string Identifier of the job to be deleted.
zipFile stream The contents of the zip file to write to the filesystem
Source:
Returns:
A Promise that is resolved when the zip file has been written to the filesystem and expanded.
Type
Promise

updateFileMetadata(args) → {Promise.<PersistenceApi.fileMetadata>}

Update the metadata for a file being translated.
Parameters:
Name Type Description
args object JavaScript object containing the "updateFileMetadata" parameters.
Properties
Name Type Description
jobId string Identifier of the job.
fileType 'site' | 'assets' Type of file to fetch - whether it's an assets file or a site resource.
file SampleJobManager.file Details about the file in the persistence store.
Source:
Returns:
A Promise that is resolved with a details on the metadata for the file
Type
Promise.<PersistenceApi.fileMetadata>

updateJob(args) → {Promise.<SampleJobManager.JobConfig>}

Update a translation job.
Update the translation job with new metadata about the jobs state.
Note: This currently supports only updating the following properties in the metadata:
  • status
  • statusMessage
  • translatedZipFile
  • progress
Parameters:
Name Type Description
args SampleJobManager.JobConfig JavaScript object containing the metadata to update for this job.
Source:
Returns:
The updated metadata stored for this job.
Type
Promise.<SampleJobManager.JobConfig>