Solved type issues in traverseOperations etc. Changed functions to take a object single parameter. Condensed endpoints into a function call
This commit is contained in:
@@ -1,16 +1,25 @@
|
||||
|
||||
import {
|
||||
sortPagesWithPreset, SortPagesWithPresetParamsType,
|
||||
rearrangePages, RearrangePagesParamsType,
|
||||
selectPages, SelectPagesParamsType,
|
||||
removePages, RemovePagesParamsType,
|
||||
removeBlankPages, RemoveBlankPagesParamsType
|
||||
} from "./functions/subDocumentFunctions";
|
||||
import { impose, ImposeParamsBaseType, ImposeParamsType } from "./functions/impose";
|
||||
import { mergePDFs, MergeParamsType } from './functions/mergePDFs';
|
||||
import { rotatePages, RotateParamsType } from './functions/rotatePages';
|
||||
import { scaleContent, ScaleContentParamsType} from './functions/scaleContent';
|
||||
import { scalePage, ScalePageParamsType } from './functions/scalePage';
|
||||
import { splitOn, SplitOnParamsType } from './functions/splitOn';
|
||||
import { splitPDF, SplitPdfParamsType } from './functions/splitPDF';
|
||||
import { updateMetadata, UpdateMetadataParams } from "./functions/updateMetadata";
|
||||
import { PdfFile } from "./wrappers/PdfFile";
|
||||
|
||||
import { Override } from '../declarations/TypeScriptUtils'
|
||||
|
||||
// Import injected libraries here!
|
||||
|
||||
import { sortPagesWithPreset, rearrangePages, selectPages, removePages, removeBlankPages } from "./functions/subDocumentFunctions";
|
||||
import { impose } from "./functions/impose";
|
||||
import { mergePDFs } from './functions/mergePDFs';
|
||||
import { rotatePages } from './functions/rotatePages';
|
||||
import { scaleContent} from './functions/scaleContent';
|
||||
import { scalePage } from './functions/scalePage';
|
||||
import { splitOn } from './functions/splitOn';
|
||||
import { splitPDF } from './functions/splitPDF';
|
||||
import { updateMetadata } from "./functions/updateMetadata";
|
||||
|
||||
const toExport = {
|
||||
sortPagesWithPreset, rearrangePages, selectPages, removePages, removeBlankPages,
|
||||
impose,
|
||||
@@ -24,9 +33,29 @@ const toExport = {
|
||||
}
|
||||
export default toExport;
|
||||
|
||||
export type OperationsParametersBaseType = {
|
||||
sortPagesWithPreset: SortPagesWithPresetParamsType;
|
||||
rearrangePages: RearrangePagesParamsType;
|
||||
selectPages: SelectPagesParamsType;
|
||||
removePages: RemovePagesParamsType;
|
||||
removeBlankPages: RemoveBlankPagesParamsType;
|
||||
impose: ImposeParamsBaseType;
|
||||
mergePDFs: MergeParamsType;
|
||||
rotatePages: RotateParamsType;
|
||||
scaleContent: ScaleContentParamsType;
|
||||
scalePage: ScalePageParamsType;
|
||||
splitOn: SplitOnParamsType;
|
||||
splitPDF: SplitPdfParamsType;
|
||||
updateMetadata: UpdateMetadataParams;
|
||||
}
|
||||
|
||||
export type OperationsBaseType = typeof toExport;
|
||||
|
||||
// Overide fields in the type of toExport, with the given fields and types. This seems to magically work!
|
||||
// https://dev.to/vborodulin/ts-how-to-override-properties-with-type-intersection-554l
|
||||
type Override<T1, T2> = Omit<T1, keyof T2> & T2;
|
||||
export type OperationsUseages = Override<typeof toExport, {
|
||||
impose: (snapshot: any, nup: number, format: string) => any;
|
||||
}>;
|
||||
export type OperationsType = Override<OperationsBaseType, {
|
||||
impose: (params: ImposeParamsType) => Promise<PdfFile>;
|
||||
}>;
|
||||
|
||||
export type OperationsParametersType = Override<OperationsParametersBaseType, {
|
||||
impose: ImposeParamsType;
|
||||
}>;
|
||||
|
||||
Reference in New Issue
Block a user