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
13 changes: 7 additions & 6 deletions src/modules/CaaSMapper.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import set from 'lodash.set'
import { FSXAApi, ComparisonQueryOperatorEnum } from './'
import {
CaaSApi_Body,
Expand Down Expand Up @@ -30,7 +29,7 @@ import {
Section
} from '../types'
import { parseISO } from 'date-fns'
import { chunk } from 'lodash'
import { set, chunk } from 'lodash'
import XMLParser from './XMLParser'
import { Logger } from './Logger'

Expand Down Expand Up @@ -76,9 +75,12 @@ export class CaaSMapper {

async mapDataEntry(entry: CaaSApi_DataEntry, path: NestedPath): Promise<DataEntry> {
if (this.customMapper) {
const result = await this.customMapper(entry, {
registerReferencedItem: this.registerReferencedItem,
api: this.api
const result = await this.customMapper(entry, path, {
api: this.api,
xmlParser: this.xmlParser,
registerReferencedItem: this.registerReferencedItem.bind(this),
buildPreviewId: this.buildPreviewId.bind(this),
mapDataEntries: this.mapDataEntries.bind(this)
})
if (typeof result !== 'undefined') return result
}
Expand Down Expand Up @@ -241,7 +243,6 @@ export class CaaSMapper {
case 'Content2Section':
return await this.mapContent2Section(content)
case 'Section':
return await this.mapSection(content, path)
case 'SectionReference':
return await this.mapSection(content, path)
default:
Expand Down
7 changes: 6 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
ComparisonQueryOperatorEnum,
LogicalQueryOperatorEnum
} from './modules/QueryBuilder'
import XMLParser from './modules/XMLParser'

export interface CaaSApi_Template {
fsType: 'PageTemplate' | 'SectionTemplate' | 'LinkTemplate'
Expand Down Expand Up @@ -510,11 +511,15 @@ export type NestedPath = (string | number)[]

export type CustomMapper = (
entry: CaaSApi_DataEntry,
entryPath: NestedPath,
utils: {
api: FSXAApi
xmlParser: XMLParser
registerReferencedItem: (identifier: string, path: NestedPath) => string
buildPreviewId: (identifier: string) => string
mapDataEntries: (entries: CaaSApi_DataEntries, path: NestedPath) => Promise<DataEntries>
}
) => Promise<any | undefined>
) => Promise<any>

export type FSXAApiParams =
| {
Expand Down