@shad0wz7/nestjs-pdf 4.0.0 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +96 -5
- package/dist/index.cjs +519 -176
- package/dist/index.d.cts +142 -88
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +142 -88
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +509 -167
- package/dist/index.mjs.map +1 -1
- package/package.json +35 -25
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { DynamicModule, InjectionToken, ModuleMetadata,
|
|
1
|
+
import { DynamicModule, InjectionToken, ModuleMetadata, OnModuleInit, OptionalFactoryDependency } from "@nestjs/common";
|
|
2
2
|
import { StandardFonts } from "pdf-lib";
|
|
3
|
-
import
|
|
4
|
-
import { Browser as Browser$1 } from "@puppeteer/browsers";
|
|
3
|
+
import "puppeteer";
|
|
5
4
|
import { Data, Options } from "ejs";
|
|
6
5
|
import { EtaConfig } from "eta";
|
|
7
6
|
import Handlebars from "handlebars";
|
|
@@ -9,7 +8,6 @@ import { LiquidOptions as LiquidOptions$1 } from "liquidjs";
|
|
|
9
8
|
import { EscapeFunction } from "mustache";
|
|
10
9
|
import { ConfigureOptions } from "nunjucks";
|
|
11
10
|
import { LocalsObject, Options as Options$1 } from "pug";
|
|
12
|
-
//#region src/exceptions/nestjs-pdf.exception.d.ts
|
|
13
11
|
export declare enum NestjsPdfErrorCode {
|
|
14
12
|
ENGINE_NOT_AVAILABLE = "ENGINE_NOT_AVAILABLE",
|
|
15
13
|
TEMPLATE_CONFIGURATION_ERROR = "TEMPLATE_CONFIGURATION_ERROR",
|
|
@@ -19,7 +17,8 @@ export declare enum NestjsPdfErrorCode {
|
|
|
19
17
|
PDF_GENERATION_ERROR = "PDF_GENERATION_ERROR",
|
|
20
18
|
SIGNATURE_DEPENDENCY_ERROR = "SIGNATURE_DEPENDENCY_ERROR",
|
|
21
19
|
SIGNATURE_PLACEMENT_ERROR = "SIGNATURE_PLACEMENT_ERROR",
|
|
22
|
-
WATERMARK_ERROR = "WATERMARK_ERROR"
|
|
20
|
+
WATERMARK_ERROR = "WATERMARK_ERROR",
|
|
21
|
+
RENDERER_CONFIGURATION_ERROR = "RENDERER_CONFIGURATION_ERROR"
|
|
23
22
|
}
|
|
24
23
|
export declare abstract class NestjsPdfException extends Error {
|
|
25
24
|
abstract readonly code: NestjsPdfErrorCode;
|
|
@@ -27,46 +26,34 @@ export declare abstract class NestjsPdfException extends Error {
|
|
|
27
26
|
cause?: unknown;
|
|
28
27
|
});
|
|
29
28
|
}
|
|
30
|
-
//#endregion
|
|
31
|
-
//#region src/exceptions/browser-installation.exception.d.ts
|
|
32
29
|
export declare class BrowserInstallationException extends NestjsPdfException {
|
|
33
30
|
readonly code = NestjsPdfErrorCode.BROWSER_INSTALLATION_ERROR;
|
|
34
31
|
}
|
|
35
|
-
//#endregion
|
|
36
|
-
//#region src/exceptions/browser-unavailable.exception.d.ts
|
|
37
32
|
export declare class BrowserUnavailableException extends NestjsPdfException {
|
|
38
33
|
readonly code = NestjsPdfErrorCode.BROWSER_UNAVAILABLE;
|
|
39
34
|
}
|
|
40
|
-
//#endregion
|
|
41
|
-
//#region src/exceptions/engine-not-available.exception.d.ts
|
|
42
35
|
export declare class EngineNotAvailableException extends NestjsPdfException {
|
|
43
36
|
readonly code = NestjsPdfErrorCode.ENGINE_NOT_AVAILABLE;
|
|
44
37
|
constructor(engineName: string, packageName?: string, options?: {
|
|
45
38
|
cause?: unknown;
|
|
46
39
|
});
|
|
47
40
|
}
|
|
48
|
-
//#endregion
|
|
49
|
-
//#region src/exceptions/pdf-generation.exception.d.ts
|
|
50
41
|
export declare class PdfGenerationException extends NestjsPdfException {
|
|
51
42
|
readonly code = NestjsPdfErrorCode.PDF_GENERATION_ERROR;
|
|
52
43
|
}
|
|
53
|
-
|
|
54
|
-
|
|
44
|
+
/** The PDF provider is misconfigured, or asked for an option it does not support. */
|
|
45
|
+
export declare class RendererConfigurationException extends NestjsPdfException {
|
|
46
|
+
readonly code = NestjsPdfErrorCode.RENDERER_CONFIGURATION_ERROR;
|
|
47
|
+
}
|
|
55
48
|
export declare class SignatureDependencyException extends NestjsPdfException {
|
|
56
49
|
readonly code = NestjsPdfErrorCode.SIGNATURE_DEPENDENCY_ERROR;
|
|
57
50
|
}
|
|
58
|
-
//#endregion
|
|
59
|
-
//#region src/exceptions/signature-placement.exception.d.ts
|
|
60
51
|
export declare class SignaturePlacementException extends NestjsPdfException {
|
|
61
52
|
readonly code = NestjsPdfErrorCode.SIGNATURE_PLACEMENT_ERROR;
|
|
62
53
|
}
|
|
63
|
-
//#endregion
|
|
64
|
-
//#region src/exceptions/template-configuration.exception.d.ts
|
|
65
54
|
export declare class TemplateConfigurationException extends NestjsPdfException {
|
|
66
55
|
readonly code = NestjsPdfErrorCode.TEMPLATE_CONFIGURATION_ERROR;
|
|
67
56
|
}
|
|
68
|
-
//#endregion
|
|
69
|
-
//#region src/exceptions/template-render.exception.d.ts
|
|
70
57
|
export declare class TemplateRenderException extends NestjsPdfException {
|
|
71
58
|
readonly engine: string;
|
|
72
59
|
readonly code = NestjsPdfErrorCode.TEMPLATE_RENDER_ERROR;
|
|
@@ -74,13 +61,9 @@ export declare class TemplateRenderException extends NestjsPdfException {
|
|
|
74
61
|
cause?: unknown;
|
|
75
62
|
});
|
|
76
63
|
}
|
|
77
|
-
//#endregion
|
|
78
|
-
//#region src/exceptions/watermark.exception.d.ts
|
|
79
64
|
export declare class WatermarkException extends NestjsPdfException {
|
|
80
65
|
readonly code = NestjsPdfErrorCode.WATERMARK_ERROR;
|
|
81
66
|
}
|
|
82
|
-
//#endregion
|
|
83
|
-
//#region src/helpers/getRelativePath.helper.d.ts
|
|
84
67
|
/**
|
|
85
68
|
* Get the relative path to a value from the module directory.
|
|
86
69
|
* @param moduleDir the path of the module, typically __dirname
|
|
@@ -91,8 +74,6 @@ export declare class WatermarkException extends NestjsPdfException {
|
|
|
91
74
|
* // returns 'context/pdf/templates/my-template.hbs' if the current working directory is '/
|
|
92
75
|
*/
|
|
93
76
|
export declare function getRelativePathToValue(moduleDir: string, relativeToModule: string): string;
|
|
94
|
-
//#endregion
|
|
95
|
-
//#region src/helpers/request-guard.helper.d.ts
|
|
96
77
|
/**
|
|
97
78
|
* Filters what the rendered HTML may load (SSRF protection). Disabled unless set:
|
|
98
79
|
* pass `{}` for the defaults (private networks and `file:` blocked).
|
|
@@ -116,8 +97,6 @@ interface PdfSecurityOptions {
|
|
|
116
97
|
/** Set to false to disable JavaScript in the rendered page. Default: true */
|
|
117
98
|
javascriptEnabled?: boolean;
|
|
118
99
|
}
|
|
119
|
-
//#endregion
|
|
120
|
-
//#region src/helpers/watermark.helper.d.ts
|
|
121
100
|
interface WatermarkOptions {
|
|
122
101
|
/** Text to stamp. At least one of `text` or `image` is required. */
|
|
123
102
|
text?: string;
|
|
@@ -142,8 +121,6 @@ interface WatermarkOptions {
|
|
|
142
121
|
/** 1-based page numbers to watermark. Default: all pages */
|
|
143
122
|
pages?: Array<number>;
|
|
144
123
|
}
|
|
145
|
-
//#endregion
|
|
146
|
-
//#region node_modules/.pnpm/@types+mjml-core@5.1.0/node_modules/@types/mjml-core/index.d.ts
|
|
147
124
|
/**
|
|
148
125
|
* Options passed as an object to the mjml2html function
|
|
149
126
|
*
|
|
@@ -266,8 +243,100 @@ interface MJMLMinifyOptions {
|
|
|
266
243
|
minifyJs?: boolean | undefined;
|
|
267
244
|
removeComments?: false | "safe" | "all" | undefined;
|
|
268
245
|
}
|
|
269
|
-
|
|
270
|
-
|
|
246
|
+
type LowerCasePaperFormat = 'letter' | 'legal' | 'tabloid' | 'ledger' | 'a0' | 'a1' | 'a2' | 'a3' | 'a4' | 'a5' | 'a6';
|
|
247
|
+
/** Paper format, as Puppeteer's `PaperFormat`. */
|
|
248
|
+
type PdfPaperFormat = Uppercase<LowerCasePaperFormat> | Capitalize<LowerCasePaperFormat> | LowerCasePaperFormat;
|
|
249
|
+
/** Page margins: a number of pixels, or a string with a px/in/cm/mm unit. */
|
|
250
|
+
interface PdfMargin {
|
|
251
|
+
top?: string | number;
|
|
252
|
+
bottom?: string | number;
|
|
253
|
+
left?: string | number;
|
|
254
|
+
right?: string | number;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Page options, same shape as Puppeteer's `PDFOptions`. Remote providers
|
|
258
|
+
* translate the size, margins, orientation, backgrounds, scale, page ranges
|
|
259
|
+
* and header/footer templates; `path`, `timeout` and `waitForFonts` are
|
|
260
|
+
* Puppeteer only.
|
|
261
|
+
*/
|
|
262
|
+
interface PdfOptions {
|
|
263
|
+
scale?: number;
|
|
264
|
+
displayHeaderFooter?: boolean;
|
|
265
|
+
headerTemplate?: string;
|
|
266
|
+
footerTemplate?: string;
|
|
267
|
+
printBackground?: boolean;
|
|
268
|
+
landscape?: boolean;
|
|
269
|
+
pageRanges?: string;
|
|
270
|
+
format?: PdfPaperFormat;
|
|
271
|
+
width?: string | number;
|
|
272
|
+
height?: string | number;
|
|
273
|
+
preferCSSPageSize?: boolean;
|
|
274
|
+
margin?: PdfMargin;
|
|
275
|
+
path?: string;
|
|
276
|
+
omitBackground?: boolean;
|
|
277
|
+
tagged?: boolean;
|
|
278
|
+
outline?: boolean;
|
|
279
|
+
timeout?: number;
|
|
280
|
+
waitForFonts?: boolean;
|
|
281
|
+
}
|
|
282
|
+
/** Browser to install, as the `Browser` enum of `@puppeteer/browsers` (its values are accepted). */
|
|
283
|
+
type PdfBrowser = 'chrome' | 'chrome-headless-shell' | 'chromium' | 'firefox' | 'chromedriver';
|
|
284
|
+
/** Renders the PDF with a local Chromium driven by Puppeteer (default). */
|
|
285
|
+
interface PuppeteerProviderOptions {
|
|
286
|
+
type: 'puppeteer';
|
|
287
|
+
}
|
|
288
|
+
/** Renders the PDF on a Gotenberg server (https://gotenberg.dev), Chromium route. */
|
|
289
|
+
interface GotenbergProviderOptions {
|
|
290
|
+
type: 'gotenberg';
|
|
291
|
+
/** Base URL of the Gotenberg server, e.g. `http://localhost:3000`. */
|
|
292
|
+
url: string;
|
|
293
|
+
/** Credentials when Gotenberg runs with `--api-enable-basic-auth`. */
|
|
294
|
+
basicAuth?: {
|
|
295
|
+
username: string;
|
|
296
|
+
password: string;
|
|
297
|
+
};
|
|
298
|
+
/** Extra headers sent with every request (e.g. an `Authorization` bearer for a proxy). */
|
|
299
|
+
headers?: Record<string, string>;
|
|
300
|
+
}
|
|
301
|
+
/** Renders the PDF with the Api2Pdf SaaS (https://www.api2pdf.com), Chrome endpoint. */
|
|
302
|
+
interface Api2PdfProviderOptions {
|
|
303
|
+
type: 'api2pdf';
|
|
304
|
+
/** Api2Pdf API key, sent as the `Authorization` header. */
|
|
305
|
+
apiKey: string;
|
|
306
|
+
/** API base URL. Default: `https://v2.api2pdf.com` */
|
|
307
|
+
baseUrl?: string;
|
|
308
|
+
/** Extra headers sent with every request. */
|
|
309
|
+
headers?: Record<string, string>;
|
|
310
|
+
}
|
|
311
|
+
type PdfProviderOptions = PuppeteerProviderOptions | GotenbergProviderOptions | Api2PdfProviderOptions;
|
|
312
|
+
/** A file sent to Gotenberg next to `index.html`, so the HTML can reference it by name. */
|
|
313
|
+
interface GotenbergAsset {
|
|
314
|
+
/** File name, as referenced from the HTML (e.g. `logo.png`, `style.css`). */
|
|
315
|
+
filename: string;
|
|
316
|
+
content: Uint8Array | string;
|
|
317
|
+
/** MIME type. Default: `application/octet-stream` */
|
|
318
|
+
contentType?: string;
|
|
319
|
+
}
|
|
320
|
+
/** Per-call options only read by the Gotenberg provider. */
|
|
321
|
+
interface GotenbergRenderOptions {
|
|
322
|
+
/** Local files (images, fonts, CSS...) the HTML references by relative name. */
|
|
323
|
+
assets?: Array<GotenbergAsset>;
|
|
324
|
+
/**
|
|
325
|
+
* Raw Gotenberg form fields (e.g. `{ pdfa: 'PDF/A-2b', waitDelay: '1s' }`),
|
|
326
|
+
* sent after the ones derived from `pdfOptions`, so they win.
|
|
327
|
+
*/
|
|
328
|
+
formFields?: Record<string, string>;
|
|
329
|
+
}
|
|
330
|
+
/** Per-call options only read by the Api2Pdf provider. */
|
|
331
|
+
interface Api2PdfRenderOptions {
|
|
332
|
+
/** Name of the generated file on Api2Pdf's side. */
|
|
333
|
+
fileName?: string;
|
|
334
|
+
/**
|
|
335
|
+
* Raw Api2Pdf Chrome `options` (e.g. `{ delay: 500 }`), merged over the ones
|
|
336
|
+
* derived from `pdfOptions`, so they win.
|
|
337
|
+
*/
|
|
338
|
+
options?: Record<string, unknown>;
|
|
339
|
+
}
|
|
271
340
|
declare enum BrowserTag {
|
|
272
341
|
LATEST = "latest",
|
|
273
342
|
BETA = "beta",
|
|
@@ -275,31 +344,6 @@ declare enum BrowserTag {
|
|
|
275
344
|
STABLE = "stable",
|
|
276
345
|
CANARY = "canary"
|
|
277
346
|
}
|
|
278
|
-
type Headless = boolean | 'shell' | undefined;
|
|
279
|
-
declare class BrowserService implements OnModuleDestroy {
|
|
280
|
-
#private;
|
|
281
|
-
activeJobs: number;
|
|
282
|
-
totalJobs: number;
|
|
283
|
-
/** Max time to wait for in-flight PDF jobs to finish before closing the browser on shutdown. */
|
|
284
|
-
shutdownDrainTimeoutMs: number;
|
|
285
|
-
constructor(pdfParams: PuppeteerParameters);
|
|
286
|
-
onModuleDestroy(): Promise<void>;
|
|
287
|
-
getBrowserInstance(args: Array<string>, headless: boolean | 'shell' | undefined, executablePathBin: string | undefined): Promise<Browser>;
|
|
288
|
-
createContext(args: Array<string>, headless: Headless, executablePath?: string): Promise<BrowserContext>;
|
|
289
|
-
markJobStarted(): void;
|
|
290
|
-
markJobFinished(): Promise<void>;
|
|
291
|
-
recycleBrowserIfNeeded(): Promise<void>;
|
|
292
|
-
install(lock?: boolean): Promise<import("@puppeteer/browsers").InstalledBrowser | null | undefined>;
|
|
293
|
-
getBrowser(): Browser$1;
|
|
294
|
-
setBrowserTag(browserTag: BrowserTag): void;
|
|
295
|
-
getBrowserTag(): BrowserTag;
|
|
296
|
-
getBuildId(): string | undefined;
|
|
297
|
-
hasBrowserInstalled(browser: Browser$1, buildId: string): Promise<boolean>;
|
|
298
|
-
getExecutablePath(): Promise<string>;
|
|
299
|
-
getLockedBuildId(browser: Browser$1): string | null;
|
|
300
|
-
}
|
|
301
|
-
//#endregion
|
|
302
|
-
//#region src/puppeteer/engines/ejs/ejs.service.d.ts
|
|
303
347
|
export interface EjsOptions extends Omit<Options, 'async'> {
|
|
304
348
|
async?: boolean;
|
|
305
349
|
}
|
|
@@ -308,8 +352,6 @@ export declare class EjsService {
|
|
|
308
352
|
render(template: string, data?: Data, options?: EjsOptions): Promise<string>;
|
|
309
353
|
renderFile(filePath: string, data?: Data, options?: EjsOptions): Promise<string>;
|
|
310
354
|
}
|
|
311
|
-
//#endregion
|
|
312
|
-
//#region src/puppeteer/engines/eta/eta.service.d.ts
|
|
313
355
|
export interface EtaOptions extends Partial<EtaConfig> {
|
|
314
356
|
cache?: boolean;
|
|
315
357
|
autoEscape?: boolean;
|
|
@@ -346,8 +388,6 @@ export declare class EtaService {
|
|
|
346
388
|
*/
|
|
347
389
|
getCacheSize(): number;
|
|
348
390
|
}
|
|
349
|
-
//#endregion
|
|
350
|
-
//#region src/puppeteer/engines/handlebars/handlebars.service.d.ts
|
|
351
391
|
export type HandlebarsHelper = {
|
|
352
392
|
name: string;
|
|
353
393
|
fn: Handlebars.HelperDelegate;
|
|
@@ -373,8 +413,6 @@ export declare class HandlebarsService {
|
|
|
373
413
|
render(template: string, parameters?: unknown, options?: HandlebarsOptions): string;
|
|
374
414
|
renderFile(file: string, parameters?: unknown, options?: HandlebarsOptions): string;
|
|
375
415
|
}
|
|
376
|
-
//#endregion
|
|
377
|
-
//#region src/puppeteer/engines/liquid/liquid.service.d.ts
|
|
378
416
|
export type LiquidOptions = LiquidOptions$1;
|
|
379
417
|
export declare class LiquidService {
|
|
380
418
|
#private;
|
|
@@ -404,8 +442,6 @@ export declare class LiquidService {
|
|
|
404
442
|
*/
|
|
405
443
|
getCacheSize(): number;
|
|
406
444
|
}
|
|
407
|
-
//#endregion
|
|
408
|
-
//#region src/puppeteer/engines/mustache/mustache.service.d.ts
|
|
409
445
|
export interface MustacheOptions {
|
|
410
446
|
tags?: [string, string];
|
|
411
447
|
escape?: EscapeFunction;
|
|
@@ -438,8 +474,6 @@ export declare class MustacheService {
|
|
|
438
474
|
*/
|
|
439
475
|
getCacheSize(): number;
|
|
440
476
|
}
|
|
441
|
-
//#endregion
|
|
442
|
-
//#region src/puppeteer/engines/nunjucks/nunjucks.service.d.ts
|
|
443
477
|
export interface NunjucksOptions extends Partial<ConfigureOptions> {
|
|
444
478
|
noCache?: boolean;
|
|
445
479
|
watch?: boolean;
|
|
@@ -452,18 +486,27 @@ export declare class NunjucksService {
|
|
|
452
486
|
render(template: string, data?: Record<string, unknown>, options?: NunjucksOptions): string;
|
|
453
487
|
renderFile(filePath: string, data?: Record<string, unknown>, options?: NunjucksOptions): string;
|
|
454
488
|
}
|
|
455
|
-
//#endregion
|
|
456
|
-
//#region src/puppeteer/engines/pug/pug.service.d.ts
|
|
457
489
|
export type PugOptions = Options$1;
|
|
458
490
|
export declare class PugService {
|
|
459
491
|
#private;
|
|
460
492
|
render(template: string, data?: LocalsObject, options?: PugOptions): string;
|
|
461
493
|
renderFile(filePath: string, data?: LocalsObject, options?: PugOptions): string;
|
|
462
494
|
}
|
|
463
|
-
//#endregion
|
|
464
|
-
//#region src/puppeteer/puppeteer-parameters.interface.d.ts
|
|
465
495
|
export interface PuppeteerParameters {
|
|
466
|
-
|
|
496
|
+
/**
|
|
497
|
+
* Who prints the PDF: a local Chromium (`puppeteer`, default), a Gotenberg
|
|
498
|
+
* server or the Api2Pdf API. Module-level only: ignored in per-call options.
|
|
499
|
+
*/
|
|
500
|
+
provider?: PdfProviderOptions;
|
|
501
|
+
/**
|
|
502
|
+
* Page options. Remote providers translate the size, margins, orientation,
|
|
503
|
+
* backgrounds, scale, page ranges and header/footer templates.
|
|
504
|
+
*/
|
|
505
|
+
pdfOptions?: PdfOptions;
|
|
506
|
+
/** Options only read by the Gotenberg provider. */
|
|
507
|
+
gotenbergOptions?: GotenbergRenderOptions;
|
|
508
|
+
/** Options only read by the Api2Pdf provider. */
|
|
509
|
+
api2pdfOptions?: Api2PdfRenderOptions;
|
|
467
510
|
/**
|
|
468
511
|
* Cancels the generation when aborted, including while it waits for a free slot.
|
|
469
512
|
* The promise rejects with `signal.reason`; use `AbortSignal.timeout(ms)` for a timeout.
|
|
@@ -471,6 +514,7 @@ export interface PuppeteerParameters {
|
|
|
471
514
|
signal?: AbortSignal;
|
|
472
515
|
/** Watermark stamped on the generated PDF. */
|
|
473
516
|
watermark?: WatermarkOptions;
|
|
517
|
+
/** Request filter (SSRF protection). Puppeteer provider only. */
|
|
474
518
|
security?: PdfSecurityOptions;
|
|
475
519
|
hbsOptions?: HandlebarsOptions;
|
|
476
520
|
mjmlOptions?: MJMLParsingOptions;
|
|
@@ -483,7 +527,7 @@ export interface PuppeteerParameters {
|
|
|
483
527
|
chromiumRevision?: string;
|
|
484
528
|
buildId?: string;
|
|
485
529
|
headless?: boolean | 'shell';
|
|
486
|
-
browser?:
|
|
530
|
+
browser?: PdfBrowser;
|
|
487
531
|
browserTag?: BrowserTag;
|
|
488
532
|
useLockedBrowser?: boolean;
|
|
489
533
|
browserInstallBaseUrl?: string;
|
|
@@ -491,8 +535,6 @@ export interface PuppeteerParameters {
|
|
|
491
535
|
executablePath?: string;
|
|
492
536
|
cleanupBrowserCacheOnExit?: boolean;
|
|
493
537
|
}
|
|
494
|
-
//#endregion
|
|
495
|
-
//#region src/nestjs-pdf.module.d.ts
|
|
496
538
|
export interface PdfLibModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
|
|
497
539
|
inject?: Array<any>;
|
|
498
540
|
useFactory: (...args: Array<any>) => any;
|
|
@@ -501,18 +543,31 @@ export declare class NestjsPdfModule {
|
|
|
501
543
|
static forRoot(options: PuppeteerParameters): DynamicModule;
|
|
502
544
|
static forRootAsync(options: PdfLibModuleAsyncOptions): DynamicModule;
|
|
503
545
|
}
|
|
504
|
-
|
|
505
|
-
|
|
546
|
+
/** Turns an HTML document into a PDF. One implementation per provider. */
|
|
547
|
+
interface PdfRenderer {
|
|
548
|
+
/**
|
|
549
|
+
* @param html the HTML document to print
|
|
550
|
+
* @param options the generation options, already merged with the module defaults
|
|
551
|
+
* @param signal aborts the rendering; the promise then rejects
|
|
552
|
+
*/
|
|
553
|
+
render(html: string, options: PuppeteerParameters, signal?: AbortSignal): Promise<Uint8Array>;
|
|
554
|
+
}
|
|
506
555
|
export declare class MjmlService {
|
|
507
556
|
#private;
|
|
508
557
|
render(template: string, options?: MJMLParsingOptions): Promise<string>;
|
|
509
558
|
renderFile(filePath: string, options?: MJMLParsingOptions): Promise<string>;
|
|
510
559
|
}
|
|
511
|
-
|
|
512
|
-
|
|
560
|
+
/**
|
|
561
|
+
* The part of BrowserService used here. Typed as an interface so the public
|
|
562
|
+
* declarations of PuppeteerService do not pull Puppeteer's types in.
|
|
563
|
+
*/
|
|
564
|
+
interface PdfJobTracker {
|
|
565
|
+
markJobStarted(): void;
|
|
566
|
+
markJobFinished(): Promise<void>;
|
|
567
|
+
}
|
|
513
568
|
export declare class PuppeteerService {
|
|
514
569
|
#private;
|
|
515
|
-
constructor(
|
|
570
|
+
constructor(renderer: PdfRenderer, jobs: PdfJobTracker, options: PuppeteerParameters, hbsService?: HandlebarsService, mjmlService?: MjmlService, pugService?: PugService, ejsService?: EjsService, nunjucksService?: NunjucksService, etaService?: EtaService, mustacheService?: MustacheService, liquidService?: LiquidService);
|
|
516
571
|
generatePdfFromHtml(html: string, options?: PuppeteerParameters): Promise<Uint8Array>;
|
|
517
572
|
generatePdfFromTemplateHbsString(template: string, parameters?: any, options?: PuppeteerParameters): Promise<Uint8Array<ArrayBufferLike>>;
|
|
518
573
|
generatePdfFromTemplateHbsFile(file: string, parameters?: any, options?: PuppeteerParameters): Promise<Uint8Array<ArrayBufferLike>>;
|
|
@@ -531,8 +586,6 @@ export declare class PuppeteerService {
|
|
|
531
586
|
generatePdfFromLiquidString(template: string, data?: Record<string, unknown>, options?: PuppeteerParameters): Promise<Uint8Array<ArrayBufferLike>>;
|
|
532
587
|
generatePdfFromLiquidFile(file: string, data?: Record<string, unknown>, options?: PuppeteerParameters): Promise<Uint8Array<ArrayBufferLike>>;
|
|
533
588
|
}
|
|
534
|
-
//#endregion
|
|
535
|
-
//#region src/nestjs-pdf.service.d.ts
|
|
536
589
|
export declare class NestjsPdfService {
|
|
537
590
|
#private;
|
|
538
591
|
constructor(puppeteerService: PuppeteerService);
|
|
@@ -711,19 +764,20 @@ export declare class NestjsPdfService {
|
|
|
711
764
|
*/
|
|
712
765
|
addWatermark(pdf: Uint8Array | Buffer, options: WatermarkOptions): Promise<Uint8Array<ArrayBufferLike>>;
|
|
713
766
|
}
|
|
714
|
-
//#endregion
|
|
715
|
-
//#region src/puppeteer/puppeteer.module.d.ts
|
|
716
767
|
export interface PuppeteerModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
|
|
717
768
|
inject?: Array<InjectionToken | OptionalFactoryDependency>;
|
|
718
769
|
useFactory: (...args: Array<any>) => Promise<PuppeteerParameters> | PuppeteerParameters;
|
|
719
770
|
}
|
|
771
|
+
/** The part of BrowserService used here: keeps Puppeteer's types out of the public declarations. */
|
|
772
|
+
interface BrowserInstaller {
|
|
773
|
+
install(useLockedBrowser: boolean): Promise<void>;
|
|
774
|
+
}
|
|
720
775
|
export declare class PuppeteerModule implements OnModuleInit {
|
|
721
776
|
#private;
|
|
722
|
-
constructor(browserService:
|
|
777
|
+
constructor(browserService: BrowserInstaller, pdfParams: PuppeteerParameters);
|
|
723
778
|
onModuleInit(): Promise<void>;
|
|
724
779
|
static forRoot(pdfParameters: PuppeteerParameters): DynamicModule;
|
|
725
780
|
static forRootAsync(options: PuppeteerModuleAsyncOptions): DynamicModule;
|
|
726
781
|
}
|
|
727
|
-
|
|
728
|
-
export type { PdfSecurityOptions, WatermarkOptions };
|
|
782
|
+
export type { Api2PdfProviderOptions, Api2PdfRenderOptions, GotenbergAsset, GotenbergProviderOptions, GotenbergRenderOptions, PdfBrowser, PdfMargin, PdfOptions, PdfPaperFormat, PdfProviderOptions, PdfSecurityOptions, PuppeteerProviderOptions, WatermarkOptions };
|
|
729
783
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":["
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":["LiquidJsOptions","Options"],"sources":["../src/exceptions/nestjs-pdf.exception.ts","../src/exceptions/browser-installation.exception.ts","../src/exceptions/browser-unavailable.exception.ts","../src/exceptions/engine-not-available.exception.ts","../src/exceptions/pdf-generation.exception.ts","../src/exceptions/renderer-configuration.exception.ts","../src/exceptions/signature-dependency.exception.ts","../src/exceptions/signature-placement.exception.ts","../src/exceptions/template-configuration.exception.ts","../src/exceptions/template-render.exception.ts","../src/exceptions/watermark.exception.ts","../src/helpers/getRelativePath.helper.ts","../src/helpers/request-guard.helper.ts","../src/helpers/watermark.helper.ts","../node_modules/.pnpm/@types+mjml-core@5.1.1/node_modules/@types/mjml-core/index.d.ts","../src/renderers/pdf-options.interface.ts","../src/renderers/pdf-provider.interface.ts","../src/puppeteer/browser/browser.service.ts","../src/puppeteer/engines/ejs/ejs.service.ts","../src/puppeteer/engines/eta/eta.service.ts","../src/puppeteer/engines/handlebars/handlebars.service.ts","../src/puppeteer/engines/liquid/liquid.service.ts","../src/puppeteer/engines/mustache/mustache.service.ts","../src/puppeteer/engines/nunjucks/nunjucks.service.ts","../src/puppeteer/engines/pug/pug.service.ts","../src/puppeteer/puppeteer-parameters.interface.ts","../src/nestjs-pdf.module.ts","../src/renderers/pdf-renderer.interface.ts","../src/puppeteer/engines/mjml/mjml.service.ts","../src/puppeteer/puppeteer.service.ts","../src/nestjs-pdf.service.ts","../src/puppeteer/puppeteer.module.ts"],"ignoreList":[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