add types for more jsreport extensions (#47327)

This commit is contained in:
Jan Blaha 2020-09-08 13:44:42 +02:00 committed by GitHub
parent f649f4a87e
commit 2f53935499
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
34 changed files with 563 additions and 2 deletions

19
types/jsreport-assets/index.d.ts vendored Normal file
View File

@ -0,0 +1,19 @@
// Type definitions for jsreport-assets 1.7
// Project: https://github.com/jsreport/jsreport-assets
// Definitions by: pofider <https://github.com/pofider>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { ExtensionDefinition } from 'jsreport-core';
declare namespace JsReportAssets {
interface Configuration {
allowedFiles?: string;
searchOnDiskIfNotFoundInStore?: boolean;
rootUrlForLinks?: string;
publicAccessEnabled?: boolean;
}
}
declare function JsReportAssets(cfg?: JsReportAssets.Configuration): ExtensionDefinition;
export = JsReportAssets;

View File

@ -0,0 +1,11 @@
import JsReport = require('jsreport-core');
import JsReportAssets = require('jsreport-assets');
(async () => {
const jsreport = JsReport();
jsreport.use(JsReportAssets({
publicAccessEnabled: true
}));
await jsreport.init();
await jsreport.close();
})();

View File

@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"jsreport-assets-tests.ts"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

20
types/jsreport-client/index.d.ts vendored Normal file
View File

@ -0,0 +1,20 @@
// Type definitions for jsreport-client 1.2
// Project: https://github.com/jsreport/nodejs-client
// Definitions by: pofider <https://github.com/pofider>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import jsreport = require('jsreport');
import JsReport = require('jsreport-core');
import { ServerResponse } from 'http';
declare module 'jsreport-core' {
interface ClientRenderResponse extends ServerResponse {
body(): Promise<Buffer>;
}
interface Client {
render(req: Partial<Request>, options?: object): Promise<ClientRenderResponse>;
}
}
declare function CreateJsReportClient(url: string, username?: string, password?: string): JsReport.Client;
export = CreateJsReportClient;

View File

@ -0,0 +1,18 @@
import JsReport = require('jsreport');
import Client = require('jsreport-client');
(async () => {
const jsreport = JsReport();
await jsreport.init();
const client = Client('http://localhost:5488');
await client.render({
template: {
recipe: 'html',
engine: 'none',
content: 'html'
}
});
await jsreport.close();
})();

View File

@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"jsreport-client-tests.ts"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

View File

@ -1,6 +1,7 @@
// Type definitions for jsreport-core 1.5
// Project: http://jsreport.net
// Definitions by: taoqf <https://github.com/taoqf>
// pofider <https://github.com/pofider>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
@ -20,9 +21,13 @@ declare namespace JsReport {
recipe: Recipe | string;
}
interface Options {
preview?: boolean;
}
interface Request {
template: Partial<Template>;
options: object;
options?: Options;
data: any;
}
@ -79,6 +84,7 @@ declare namespace JsReport {
render(options: Partial<Request>): Promise<Response>;
discover(): Reporter;
createListenerCollection(): ListenerCollection;
close(): Promise<void>;
}
interface Configuration {

34
types/jsreport-docx/index.d.ts vendored Normal file
View File

@ -0,0 +1,34 @@
// Type definitions for jsreport-docx 2.8
// Project: https://github.com/jsreport/jsreport-docx
// Definitions by: pofider <https://github.com/pofider>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { ExtensionDefinition } from 'jsreport-core';
declare module 'jsreport-core' {
interface Template {
docx?: JsReportDocx.DocxTemplate;
}
}
declare namespace JsReportDocx {
interface Configuration {
preview?: {
enabled: true;
publicUri: string;
showWarning: false;
};
}
interface DocxTemplate {
templateAsetShortid?: string;
templateAsset?: {
content: string;
encoding: string;
};
}
}
declare function JSReportDocx(cfg?: JsReportDocx.Configuration): ExtensionDefinition;
export = JSReportDocx;

View File

@ -0,0 +1,25 @@
import JsReport = require('jsreport-core');
import JsReportDocx = require('jsreport-docx');
(async () => {
const jsreport = JsReport();
jsreport.use(JsReportDocx());
try {
await jsreport.render({
template: {
content: '',
recipe: 'docx',
engine: 'handlebars',
docx: {
templateAsetShortid: 'aaaa'
}
}
});
} catch (e) {
// intentional
}
await jsreport.init();
await jsreport.close();
})();

View File

@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"jsreport-docx-tests.ts"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

10
types/jsreport-handlebars/index.d.ts vendored Normal file
View File

@ -0,0 +1,10 @@
// Type definitions for jsreport-handlebars 2.1
// Project: https://github.com/jsreport/jsreport-handlebars
// Definitions by: pofider <https://github.com/pofider>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { ExtensionDefinition } from 'jsreport-core';
declare function JsReportHandlebars(): ExtensionDefinition;
export = JsReportHandlebars;

View File

@ -0,0 +1,9 @@
import JsReport = require('jsreport-core');
import JsReportHandlebars = require('jsreport-handlebars');
(async () => {
const jsreport = JsReport();
jsreport.use(JsReportHandlebars());
await jsreport.init();
await jsreport.close();
})();

View File

@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"jsreport-handlebars-tests.ts"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

58
types/jsreport-pdf-utils/index.d.ts vendored Normal file
View File

@ -0,0 +1,58 @@
// Type definitions for jsreport-pdf-utils 1.9
// Project: https://github.com/jsreport/jsreport-pdf-utils
// Definitions by: pofider <https://github.com/pofider>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { ExtensionDefinition, Template } from 'jsreport-core';
declare module 'jsreport-core' {
interface Template {
pdfOperations?: JsReportPdfUtils.PdfOperation[];
pdfMeta?: JsReportPdfUtils.PdfMeta;
pdfSign?: JsReportPdfUtils.PdfSign;
pdfPassword?: JsReportPdfUtils.PdfPassword;
}
}
declare namespace JsReportPdfUtils {
interface PdfOperation {
type: "merge" | "append" | "prepend";
mergeWholeDocument?: boolean;
renderForEveryPage?: boolean;
templateShortid?: string;
template?: Template;
}
interface PdfMeta {
title?: string;
author?: string;
subject?: string;
keywords?: string;
creator?: string;
producer?: string;
}
interface PdfSign {
certificateAsset: {
contrent: string;
encoding: string;
password: string;
};
reason: string;
}
interface PdfPassword {
password: string;
ownerPassword: string;
printing: "HighResolution" | "NotAllowed" | "LowResolution";
modifying: boolean;
copying: boolean;
fillingForms: boolean;
contentAccessibility: boolean;
documentAssembly: true;
}
}
declare function JSReportPdfUtils(): ExtensionDefinition;
export = JSReportPdfUtils;

View File

@ -0,0 +1,25 @@
import JsReport = require('jsreport-core');
import JsReportPdfUtils = require('jsreport-pdf-utils');
(async () => {
const jsreport = JsReport();
jsreport.use(JsReportPdfUtils());
try {
await jsreport.render({
template: {
content: '',
recipe: 'docx',
engine: 'handlebars',
pdfOperations: [{
type: 'merge'
}]
}
});
} catch (e) {
// intentional
}
await jsreport.init();
await jsreport.close();
})();

View File

@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"jsreport-pdf-utils-tests.ts"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

29
types/jsreport-reports/index.d.ts vendored Normal file
View File

@ -0,0 +1,29 @@
// Type definitions for jsreport-reports 2.5
// Project: https://github.com/jsreport/jsreport-reports
// Definitions by: pofider <https://github.com/pofider>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { ExtensionDefinition } from 'jsreport-core';
declare module 'jsreport-core' {
interface Options {
reports?: JsReportReports.ReportsOptions;
}
}
declare namespace JsReportReports {
interface Configuration {
cleanInterval?: string;
cleanTreshold?: string;
}
interface ReportsOptions {
save?: boolean;
async?: boolean;
public?: boolean;
}
}
declare function JsReportReports(cfg?: JsReportReports.Configuration): ExtensionDefinition;
export = JsReportReports;

View File

@ -0,0 +1,23 @@
import JsReport = require('jsreport-core');
import JsReportReports = require('jsreport-reports');
(async () => {
const jsreport = JsReport();
jsreport.use(JsReportReports());
await jsreport.render({
template: {
content: '',
recipe: 'html',
engine: 'handlebars',
},
options: {
reports: {
save: true
}
}
});
await jsreport.init();
await jsreport.close();
})();

View File

@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"jsreport-reports-tests.ts"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

28
types/jsreport-scripts/index.d.ts vendored Normal file
View File

@ -0,0 +1,28 @@
// Type definitions for jsreport-scripts 2.6
// Project: https://github.com/jsreport/jsreport-scripts
// Definitions by: pofider <https://github.com/pofider>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { ExtensionDefinition } from 'jsreport-core';
declare module 'jsreport-core' {
interface Template {
scripts?: JsReportScripts.TemplateScript[];
}
}
declare namespace JsReportScripts {
interface TemplateScript {
shortid?: string;
name?: string;
content?: string;
}
interface Configuration {
allowedModules?: string[] | "*";
}
}
declare function JsReportScripts(cfg?: JsReportScripts.Configuration): ExtensionDefinition;
export = JsReportScripts;

View File

@ -0,0 +1,21 @@
import JsReport = require('jsreport-core');
import JsReportScripts = require('jsreport-scripts');
(async () => {
const jsreport = JsReport();
jsreport.use(JsReportScripts());
await jsreport.render({
template: {
content: '',
recipe: 'html',
engine: 'handlebars',
scripts: [{
content: `function beforeRender(req, res) {}`
}]
}
});
await jsreport.init();
await jsreport.close();
})();

View File

@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"jsreport-scripts-tests.ts"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

16
types/jsreport-templates/index.d.ts vendored Normal file
View File

@ -0,0 +1,16 @@
// Type definitions for jsreport-templates 2.4
// Project: https://github.com/jsreport/jsreport-templates
// Definitions by: pofider <https://github.com/pofider>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { ExtensionDefinition } from 'jsreport-core';
declare module 'jsreport-core' {
interface Template {
name?: string;
}
}
declare function JsReportTemplates(): ExtensionDefinition;
export = JsReportTemplates;

View File

@ -0,0 +1,10 @@
import JsReport = require('jsreport-core');
import JsReportTemplates = require('jsreport-templates');
(async () => {
const jsreport = JsReport();
jsreport.use(JsReportTemplates());
await jsreport.init();
await jsreport.close();
})();

View File

@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"jsreport-templates-tests.ts"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

View File

@ -4,9 +4,16 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// import all availible types for jsreport included extensions
import JsReportAssets = require('jsreport-assets');
import JsReportChromePdf = require('jsreport-chrome-pdf');
import JsReportJsRender = require('jsreport-jsrender');
import JsReportDocx = require('jsreport-docx');
import JsReportHandlebars = require('jsreport-handlebars');
import JReportHtmlToXlsx = require('jsreport-html-to-xlsx');
import JsReportJsRender = require('jsreport-jsrender');
import JReportPdfUtils = require('jsreport-pdf-utils');
import JsReportReports = require('jsreport-reports');
import JsReportScripts = require('jsreport-scripts');
import JsReportTemplates = require('jsreport-templates');
import JsReportXlsx = require('jsreport-xlsx');
// just reexport types from core