@enonic-types/lib-export
Version:
Type definitions for lib-export.
94 lines (93 loc) • 3.87 kB
TypeScript
/**
* Export related functions.
*
* @example
* var exportLib = require('/lib/xp/export');
*
* @module export
*/
declare global {
interface XpLibraries {
'/lib/xp/export': typeof import('./export');
}
}
import type { ResourceKey } from '@enonic-types/core';
export type { ResourceKey } from '@enonic-types/core';
export interface ImportNodesParams {
source: string | object;
targetNodePath: string;
xslt?: string | ResourceKey;
xsltParams?: unknown;
includeNodeIds?: boolean;
includePermissions?: boolean;
archive?: boolean;
nodeResolved?: (numberOfNodes: number) => void;
nodeImported?: (numberOfImportedNodes: number) => void;
}
export interface ImportNodesError {
exception: string;
message: string;
stacktrace: string[];
}
export interface ImportNodesResult {
addedNodes: string[];
updatedNodes: string[];
importedBinaries: string[];
importErrors: ImportNodesError[];
}
/**
* Import nodes from a nodes-export.
* Could be used to import node-export from exports directory or from application resource files.
* Optionally pre-transforms node XML node files with XSLT before import.
*
* @example-ref examples/export/importNodes.js
*
* @param {object} params JSON with the parameters.
* @param {string|object} params.source Either name of nodes-export located in exports directory or application resource key.
* @param {string} params.targetNodePath Target path for imported nodes.
* @param {string|object} [params.xslt] XSLT file name in exports directory or application resource key. Used for XSLT transformation.
* @param {object} [params.xsltParams] Parameters used in XSLT transformation.
* @param {boolean} [params.includeNodeIds=false] Set to true to use node IDs from the import, false to generate new node IDs.
* @param {boolean} [params.includePermissions=false] Set to true to use Node permissions from the import, false to use target node permissions.
* @param {boolean} [params.archive=false] Set to true to import from a zip archive.
* @param {function} [params.nodeResolved] A function to be called before import starts with number of nodes to import.
* @param {function} [params.nodeImported] A function to be called during import with number of nodes imported since last call.
*
* @returns {ImportNodesResult} Node import results.
*/
export declare function importNodes(params: ImportNodesParams): ImportNodesResult;
export interface ExportNodesParams {
sourceNodePath: string;
exportName: string;
includeNodeIds?: boolean;
includeVersions?: boolean;
archive?: boolean;
nodeResolved?: (numberOfNodes: number) => void;
nodeExported?: (numberOfExportedNodes: number) => void;
}
export interface ExportNodesError {
message: string;
}
export interface ExportNodesResult {
exportedNodes: string[];
exportedBinaries: string[];
exportErrors: ExportNodesError[];
}
/**
* Export nodes to a nodes-export.
* Export is created in exports directory.
*
* @example-ref examples/export/exportNodes.js
*
* @param {object} params JSON with the parameters.
* @param {string} params.sourceNodePath Source nodes path.
* @param {string} params.exportName Export name.
* @param {boolean} [params.includeNodeIds=true] Set to true to export node IDs.
* @param {boolean} [params.includeVersions=false] Set to true to export all node versions.
* @param {boolean} [params.archive=false] Set to true to export as a zip archive.
* @param {function} [params.nodeResolved] A function to be called before export starts with number of nodes to export.
* @param {function} [params.nodeExported] A function to be called during export with number of nodes exported since last call.
*
* @returns {ExportNodesResult} Node export results.
*/
export declare function exportNodes(params: ExportNodesParams): ExportNodesResult;