import { IdObjectSkeletonInterface } from '../api/ApiTypes'; import { State } from '../shared/State'; import { ExportMetaData } from './OpsTypes'; export type Mapping = { /** * Create an empty mapping export template * @returns {MappingExportInterface} an empty mapping export template */ createMappingExportTemplate(): MappingExportInterface; /** * Read mappings from sync.json (legacy) * @returns {Promise} a promise that resolves to an array of mapping objects */ readSyncMappings(): Promise; /** * Read mappings * @param {string} connectorId limit mappings to connector * @param {string} moType limit mappings to managed object type * @returns {Promise} a promise that resolves to an array of mapping objects */ readMappings(connectorId?: string, moType?: string): Promise; /** * Read mapping * @param {string} mappingId id of the mapping (new: 'mapping/\', legacy: 'sync/\') * @returns {Promise} a promise that resolves an mapping object */ readMapping(mappingId: string): Promise; /** * Create mapping * @param {string} mappingId id of the mapping (new: 'mapping/\', legacy: 'sync/\') * @param {MappingSkeleton} mappingData mapping object * @returns {Promise} a promise that resolves to an mapping object */ createMapping(mappingId: string, mappingData: MappingSkeleton): Promise; /** * Update or create mapping * @param {string} mappingId id of the mapping (new: 'mapping/\', legacy: 'sync/\') * @param {MappingSkeleton} mappingData mapping object * @returns {Promise} a promise that resolves to an mapping object */ updateMapping(mappingId: string, mappingData: MappingSkeleton): Promise; /** * Update or create mappings in sync.json (legacy) * @param {MappingSkeleton} mappingData mapping object * @returns {Promise} a promise that resolves to an mapping object */ updateSyncMappings(mappings: MappingSkeleton[]): Promise; /** * Delete all mappings * @param {string} connectorId limit mappings to connector * @param {string} moType limit mappings to managed object type * @returns {Promise} a promise that resolves to an array of mapping objects */ deleteMappings(connectorId?: string, moType?: string): Promise; /** * Delete mapping * @param {string} mappingId id of the mapping (new: 'mapping/\', legacy: 'sync/\') * @returns {Promise} a promise that resolves an mapping object */ deleteMapping(mappingId: string): Promise; /** * Export mapping * @param {string} mappingId id of the mapping (new: 'mapping/\', legacy: 'sync/\') * @param {MappingExportOptions} options export options * @returns {Promise} a promise that resolves to a MappingExportInterface object */ exportMapping(mappingId: string, options?: MappingExportOptions): Promise; /** * Export all mappings * @param {MappingExportOptions} options export options * @returns {Promise} a promise that resolves to a MappingExportInterface object */ exportMappings(options?: MappingExportOptions): Promise; /** * Import mapping * @param {string} mappingId id of the mapping (new: 'mapping/\', legacy: 'sync/\') * @param {MappingExportInterface} importData import data * @param {MappingImportOptions} options import options * @returns {Promise} a promise resolving to a MappingSkeleton object */ importMapping(mappingId: string, importData: MappingExportInterface, options?: MappingImportOptions): Promise; /** * Import first mapping * @param {MappingExportInterface} importData import data * @param {MappingImportOptions} options import options * @returns {Promise} a promise resolving to a MappingSkeleton object */ importFirstMapping(importData: MappingExportInterface, options?: MappingImportOptions): Promise; /** * Import all mappings * @param {MappingExportInterface} importData import data * @param {MappingImportOptions} options import options * @returns {Promise} a promise resolving to an array of MappingSkeleton objects */ importMappings(importData: MappingExportInterface, options?: MappingImportOptions): Promise; /** * Helper that returns a boolean indicating whether the mapping is a legacy mapping or not given the id * @param {string} mappingId the mapping id * @returns {boolean} true if the mapping is a legacy mapping, false otherwise * @throws {FrodoError} if the id is invalid */ isLegacyMapping(mappingId: string): boolean; }; declare const _default: (state: State) => Mapping; export default _default; export type MappingPolicy = { action: 'CREATE' | 'DELETE' | 'EXCEPTION' | 'IGNORE' | 'UPDATE'; situation: 'ABSENT' | 'ALL_GONE' | 'AMBIGUOUS' | 'CONFIRMED' | 'FOUND' | 'FOUND_ALREADY_LINKED' | 'LINK_ONLY' | 'MISSING' | 'SOURCE_IGNORED' | 'SOURCE_MISSING' | 'TARGET_IGNORED' | 'UNASSIGNED' | 'UNQUALIFIED'; }; export type MappingProperty = { source?: string; target: string; transform?: { globals: any; source: string; type: string; }; }; export type MappingSkeleton = IdObjectSkeletonInterface & { name: string; displayName?: string; linkQualifiers?: string[]; consentRequired?: boolean; policies?: MappingPolicy[]; properties?: MappingProperty[]; source?: string; target?: string; syncAfter?: string[]; }; export type SyncSkeleton = IdObjectSkeletonInterface & { mappings: MappingSkeleton[]; }; export interface MappingExportInterface { meta?: ExportMetaData; mapping: Record; sync: SyncSkeleton; } /** * Mapping export options */ export interface MappingExportOptions { /** * Use string arrays to store multi-line text in scripts. */ useStringArrays: boolean; /** * Include any dependencies. */ deps: boolean; /** * limit mappings to connector */ connectorId?: string; /** * limit mappings to managed object type */ moType?: string; } /** * Mapping import options */ export interface MappingImportOptions { /** * Include any dependencies. */ deps: boolean; } export declare function createMappingExportTemplate({ state, }: { state: State; }): MappingExportInterface; /** * Read mappings from sync.json (legacy) * @returns {Promise} a promise that resolves to an array of mapping objects */ export declare function readSyncMappings({ state, }: { state: State; }): Promise; /** * Read the new mappings that are not legacy (i.e. those not from sync.json) * @returns {Promise} a promise that resolves to an array of mapping objects */ export declare function readNewMappings({ state, }: { state: State; }): Promise; /** * Read mappings in order of which they are synced. * @param {string} connectorId limit mappings to connector * @param {string} moType limit mappings to managed object type * @returns {Promise} a promise that resolves to an array of mapping objects */ export declare function readMappings({ connectorId, moType, state, }: { connectorId?: string; moType?: string; state: State; }): Promise; /** * Read mapping * @param {string} mappingId id of the mapping (new: 'mapping/\', legacy: 'sync/\') * @returns {Promise} a promise that resolves an mapping object */ export declare function readMapping({ mappingId, state, }: { mappingId: string; state: State; }): Promise; /** * Create mapping * @param {string} mappingId id of the mapping (new: 'mapping/\', legacy: 'sync/\') * @param {MappingSkeleton} mappingData mapping object * @returns {Promise} a promise that resolves to an mapping object */ export declare function createMapping({ mappingId, mappingData, state, }: { mappingId: string; mappingData: MappingSkeleton; state: State; }): Promise; /** * Update or create mapping * @param {string} mappingId id of the mapping (new: 'mapping/\', legacy: 'sync/\') * @param {MappingSkeleton} mappingData mapping object * @returns {Promise} a promise that resolves to an mapping object */ export declare function updateMapping({ mappingId, mappingData, state, }: { mappingId: string; mappingData: MappingSkeleton; state: State; }): Promise; /** * Update or create multiple mappings * @param {MappingSkeleton[]} mappings array of mapping objects * @returns {Promise} a promise that resolves to an array of mapping objects */ export declare function updateLegacyMappings({ mappings, state, }: { mappings: MappingSkeleton[]; state: State; }): Promise; /** * Delete mappings * @param {string} connectorId limit mappings to connector * @param {string} moType limit mappings to managed object type * @returns {Promise} a promise that resolves to an array of mapping objects */ export declare function deleteMappings({ connectorId, moType, state, }: { connectorId?: string; moType?: string; state: State; }): Promise; /** * Delete mapping * @param {string} mappingId id of the mapping (new: 'mapping/\', legacy: 'sync/\') * @returns {Promise} a promise that resolves an mapping object */ export declare function deleteMapping({ mappingId, state, }: { mappingId: string; state: State; }): Promise; /** * Export mapping * @param {string} mappingId id of the mapping (new: 'mapping/\', legacy: 'sync/\') * @param {MappingExportOptions} options export options * @returns {Promise} a promise that resolves to a MappingExportInterface object */ export declare function exportMapping({ mappingId, options, state, }: { mappingId: string; options?: MappingExportOptions; state: State; }): Promise; /** * Export all mappings * @param {MappingExportOptions} options export options * @returns {Promise} a promise that resolves to a MappingExportInterface object */ export declare function exportMappings({ options, state, }: { options?: MappingExportOptions; state: State; }): Promise; /** * Import mapping * @param {string} mappingId id of the mapping (new: 'mapping/\', legacy: 'sync/\') * @param {MappingExportInterface} importData import data * @param {MappingImportOptions} options import options * @returns {Promise} a promise resolving to a MappingSkeleton object */ export declare function importMapping({ mappingId, importData, options, state, }: { mappingId: string; importData: MappingExportInterface; options?: MappingImportOptions; state: State; }): Promise; /** * Import first mapping * @param {MappingExportInterface} importData import data * @param {MappingImportOptions} options import options * @returns {Promise} a promise resolving to a MappingSkeleton object */ export declare function importFirstMapping({ importData, options, state, }: { importData: MappingExportInterface; options?: MappingImportOptions; state: State; }): Promise; /** * Import all mappings * @param {MappingExportInterface} importData import data * @param {MappingImportOptions} options import options * @returns {Promise} a promise resolving to an array of MappingSkeleton objects */ export declare function importMappings({ importData, options, state, }: { importData: MappingExportInterface; options?: MappingImportOptions; state: State; }): Promise; /** * Helper that returns a boolean indicating whether the mapping is a legacy mapping or not given the id * @param {string} mappingId the mapping id * @returns {boolean} true if the mapping is a legacy mapping, false otherwise * @throws {FrodoError} if the id is invalid */ export declare function isLegacyMapping(mappingId: string): boolean; /** * Helper that sorts an array of mappings in place and returns the sorted array. It sorts first by mapping type (legacy mappings come before non-legacy mappings), and then by the syncAfter property. * If syncAfter doesn't exist, it prioritizes mappings without the syncAfter property (note that the behavior that should happen in this instance is not specified in the documentation, at least as of July 9, 2024). * * See sync order documentation: https://backstage.forgerock.com/docs/idm/7.5/synchronization-guide/mappings.html * * Note: According to the documentation, then endpoint /openidm/sync/mappings?_queryFilter=true should return all mappings (legacy and new) in the correct order, which would make this method unnecessary when reading mappings. However, this doesn't * seem to always be the case. The endpoint prioritizes non-legacy mappings over legacy mappings which is opposite what the documentation says the correct sync order should be. Additionally, the endpoint does not always return all the mappings. * In the future, if the endpoint is fixed, we may instead want to use /openidm/sync/mappings?_queryFilter=true to determine correct ordering. * * @param {MappingSkeleton[]} mappings The list of mappings to sort in place * @returns The sorted list of mappings */ export declare function sortMappings(mappings: MappingSkeleton[]): MappingSkeleton[]; //# sourceMappingURL=MappingOps.d.ts.map