pdf package
This commit is contained in:
104
index.d.ts
vendored
104
index.d.ts
vendored
@@ -16,7 +16,7 @@ export interface DbReadOptions {
|
||||
offset?: number
|
||||
limit?: number
|
||||
sort?: string[]
|
||||
pipelineMod?: (pipe: {[key: string]: any}[]) => {[key: string]: any}[]
|
||||
pipelineMod?: (pipe: { [key: string]: any }[]) => { [key: string]: any }[]
|
||||
}
|
||||
|
||||
interface GetHookGetOnlyData {
|
||||
@@ -58,7 +58,7 @@ interface GetHookData {
|
||||
/**
|
||||
* pipelineMod is a function to modify the mongodb query pipeline
|
||||
*/
|
||||
pipelineMod?: (pipe: {[key: string]: any}[]) => {[key: string]: any}[]
|
||||
pipelineMod?: (pipe: { [key: string]: any }[]) => { [key: string]: any }[]
|
||||
}
|
||||
|
||||
interface PostHookData {
|
||||
@@ -75,10 +75,7 @@ interface DbPackage {
|
||||
* @param colName collection name
|
||||
* @param options options map
|
||||
*/
|
||||
find(
|
||||
colName: string,
|
||||
options?: DbReadOptions
|
||||
): CollectionDocument[]
|
||||
find(colName: string, options?: DbReadOptions): CollectionDocument[]
|
||||
|
||||
/**
|
||||
* read count of documents for filter from a collection
|
||||
@@ -86,10 +83,7 @@ interface DbPackage {
|
||||
* @param colName collection name
|
||||
* @param options options map (only filter is valid)
|
||||
*/
|
||||
count(
|
||||
colName: string,
|
||||
options?: DbReadOptions
|
||||
): number
|
||||
count(colName: string, options?: DbReadOptions): number
|
||||
|
||||
/**
|
||||
* create a document in a collection
|
||||
@@ -97,10 +91,7 @@ interface DbPackage {
|
||||
* @param colName collection name
|
||||
* @param data data map
|
||||
*/
|
||||
create(
|
||||
colName: string,
|
||||
data: CollectionDocument
|
||||
): CollectionDocument
|
||||
create(colName: string, data: CollectionDocument): CollectionDocument
|
||||
|
||||
/**
|
||||
* update a document in a collection
|
||||
@@ -133,7 +124,6 @@ interface DbPackage {
|
||||
colName: string,
|
||||
options?: DbReadOptions
|
||||
): { message: "ok"; removed: number }
|
||||
|
||||
}
|
||||
|
||||
interface SmtpPackage {
|
||||
@@ -201,7 +191,6 @@ interface FsPackage {
|
||||
* @param path
|
||||
*/
|
||||
remove(path: string): void
|
||||
|
||||
}
|
||||
|
||||
interface TplPackage {
|
||||
@@ -392,7 +381,7 @@ interface ImagePackage {
|
||||
interface XmlPackage {
|
||||
/**
|
||||
* create xml string
|
||||
*
|
||||
*
|
||||
* @param data object or array
|
||||
* @param options options
|
||||
*/
|
||||
@@ -400,38 +389,92 @@ interface XmlPackage {
|
||||
|
||||
/**
|
||||
* parse xml string to json
|
||||
*
|
||||
*
|
||||
* @param xml xml string
|
||||
* @param options options
|
||||
*/
|
||||
parse(xml:string, options?: {}): any
|
||||
parse(xml: string, options?: {}): any
|
||||
}
|
||||
|
||||
interface CookiePackage {
|
||||
/**
|
||||
* get cookie from http header
|
||||
*
|
||||
*
|
||||
* @param name cookie name
|
||||
*/
|
||||
get(name: string): string
|
||||
|
||||
/**
|
||||
* set cookie via http header
|
||||
*
|
||||
*
|
||||
* @param name cookie name
|
||||
* @param value cookie value
|
||||
* @param options cookie options
|
||||
*/
|
||||
set(name: string, value: string, options?:{
|
||||
maxAge?: number
|
||||
path?:string
|
||||
domain?:string
|
||||
secure?:boolean
|
||||
httpOnly?:boolean
|
||||
}): void
|
||||
set(
|
||||
name: string,
|
||||
value: string,
|
||||
options?: {
|
||||
maxAge?: number
|
||||
path?: string
|
||||
domain?: string
|
||||
secure?: boolean
|
||||
httpOnly?: boolean
|
||||
}
|
||||
): void
|
||||
}
|
||||
|
||||
export interface HookContext extends GetHookData, GetHookGetOnlyData, PostHookData {
|
||||
interface PdfPackage {
|
||||
/**
|
||||
* generate pdf from html
|
||||
*
|
||||
* @param html html string
|
||||
* @param options options
|
||||
*/
|
||||
fromHTML(
|
||||
html: string,
|
||||
options?: {
|
||||
copies?: number // Number of copies to print into the pdf file (default 1)
|
||||
dpi?: number // Change the dpi explicitly (this has no effect on X11 based systems)
|
||||
grayscale?: boolean // PDF will be generated in grayscale
|
||||
imageDpi?: number // When embedding images scale them down to this dpi (default 600)
|
||||
imageQuality?: number // When jpeg compressing images use this quality (default 94)
|
||||
lowQuality?: boolean // Generates lower quality pdf/ps. Useful to shrink the result document space
|
||||
marginBottom?: number // Set the page bottom margin
|
||||
marginLeft?: number // Set the page left margin (default 10mm)
|
||||
marginRight?: number // Set the page right margin (default 10mm)
|
||||
marginTop?: number // Set the page top margin
|
||||
noCollate?: boolean // Do not collate when printing multiple copies (default collate)
|
||||
noPdfCompression?: boolean // Do not use lossless compression on pdf objects
|
||||
orientation?: "Portrait" | "Landscape" // Set orientation to Landscape or Portrait (default Portrait)
|
||||
pageHeight?: number // Page height
|
||||
pageSize?: string // Set paper size to: A4, Letter, etc. (default A4)
|
||||
pageWidth?: number // Page width
|
||||
title?: string // The title of the generated pdf file (The title of the first document is used if not specified)
|
||||
// page settings
|
||||
printMediaType?: boolean // Use print media-type instead of screen
|
||||
footerCenter?: string // Centered footer text
|
||||
footerFontName?: string // Set footer font name (default Arial)
|
||||
footerFontSize?: number // Set footer font size (default 12)
|
||||
footerLeft?: string // Left aligned footer text
|
||||
footerLine?: boolean // Display line above the footer
|
||||
footerRight?: string // Right aligned footer text
|
||||
footerSpacing?: number // Spacing between footer and content in mm (default 0)
|
||||
headerCenter?: string // Centered header text
|
||||
headerFontName?: string // Set header font name (default Arial)
|
||||
headerFontSize?: number // Set header font size (default 12)
|
||||
headerLeft?: string // Left aligned header text
|
||||
headerLine?: boolean // Display line below the header
|
||||
headerRight?: string // Right aligned header text
|
||||
headerSpacing?: number // Spacing between header and content in mm (default 0)
|
||||
}
|
||||
): any
|
||||
}
|
||||
|
||||
export interface HookContext
|
||||
extends GetHookData,
|
||||
GetHookGetOnlyData,
|
||||
PostHookData {
|
||||
request(): {
|
||||
method: string
|
||||
remoteAddr: string
|
||||
@@ -462,11 +505,14 @@ export interface HookContext extends GetHookData, GetHookGetOnlyData, PostHookDa
|
||||
image: ImagePackage
|
||||
xml: XmlPackage
|
||||
cookie: CookiePackage
|
||||
pdf: PdfPackage
|
||||
}
|
||||
|
||||
export interface HookException {
|
||||
status?: number
|
||||
html?: string
|
||||
string?: string
|
||||
bytes?: any
|
||||
file?: string
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user