@shad0wz7/nestjs-pdf 1.1.1 → 2.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/dist/index.mjs CHANGED
@@ -2575,10 +2575,10 @@ var require_config = __commonJS({
2575
2575
  import { Module as Module2 } from "@nestjs/common";
2576
2576
 
2577
2577
  // src/nestjs-pdf.service.ts
2578
- import { Injectable as Injectable3 } from "@nestjs/common";
2578
+ import { Injectable as Injectable6 } from "@nestjs/common";
2579
2579
 
2580
2580
  // src/puppeteer/puppeteer.service.ts
2581
- import { Inject as Inject2, Injectable as Injectable2, Logger as Logger2 } from "@nestjs/common";
2581
+ import { Inject as Inject2, Injectable as Injectable5, Logger as Logger2, Optional } from "@nestjs/common";
2582
2582
 
2583
2583
  // src/puppeteer/helpers/tokens.ts
2584
2584
  var PDF_PARAMETERS = "PDF_PARAMETERS";
@@ -2937,6 +2937,11 @@ __name(mergePuppeteerParameters, "mergePuppeteerParameters");
2937
2937
  // src/puppeteer/puppeteer.service.ts
2938
2938
  import pLimit from "p-limit";
2939
2939
  import { HandlebarsService } from "@gboutte/nestjs-hbs";
2940
+
2941
+ // src/puppeteer/services/mjml.service.ts
2942
+ import { Injectable as Injectable2 } from "@nestjs/common";
2943
+ import mjml from "mjml";
2944
+ import { readFileSync as readFileSync2 } from "fs";
2940
2945
  function _ts_decorate2(decorators, target, key, desc) {
2941
2946
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2942
2947
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -2944,6 +2949,116 @@ function _ts_decorate2(decorators, target, key, desc) {
2944
2949
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2945
2950
  }
2946
2951
  __name(_ts_decorate2, "_ts_decorate");
2952
+ var MjmlService = class {
2953
+ static {
2954
+ __name(this, "MjmlService");
2955
+ }
2956
+ async render(template, options) {
2957
+ const { html } = await mjml(template, options);
2958
+ return html;
2959
+ }
2960
+ async renderFile(filePath, options) {
2961
+ const template = readFileSync2(filePath, "utf-8");
2962
+ return await this.render(template, options);
2963
+ }
2964
+ };
2965
+ MjmlService = _ts_decorate2([
2966
+ Injectable2()
2967
+ ], MjmlService);
2968
+
2969
+ // src/puppeteer/services/pug.service.ts
2970
+ import { Injectable as Injectable3 } from "@nestjs/common";
2971
+ import pug from "pug";
2972
+ import { readFileSync as readFileSync3 } from "fs";
2973
+ function _ts_decorate3(decorators, target, key, desc) {
2974
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2975
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
2976
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2977
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2978
+ }
2979
+ __name(_ts_decorate3, "_ts_decorate");
2980
+ var PugService = class {
2981
+ static {
2982
+ __name(this, "PugService");
2983
+ }
2984
+ render(template, data = {}, options) {
2985
+ try {
2986
+ const compiledFn = pug.compile(template, {
2987
+ ...options
2988
+ });
2989
+ return compiledFn(data);
2990
+ } catch (error) {
2991
+ throw new Error(`Pug rendering failed: ${String(error)}`, {
2992
+ cause: error
2993
+ });
2994
+ }
2995
+ }
2996
+ renderFile(filePath, data = {}, options) {
2997
+ try {
2998
+ const template = readFileSync3(filePath, "utf-8");
2999
+ return this.render(template, data, options);
3000
+ } catch (error) {
3001
+ throw new Error(`Pug file rendering failed: ${String(error)}`, {
3002
+ cause: error
3003
+ });
3004
+ }
3005
+ }
3006
+ };
3007
+ PugService = _ts_decorate3([
3008
+ Injectable3()
3009
+ ], PugService);
3010
+
3011
+ // src/puppeteer/services/ejs.service.ts
3012
+ import { Injectable as Injectable4 } from "@nestjs/common";
3013
+ import { render, renderFile } from "ejs";
3014
+ function _ts_decorate4(decorators, target, key, desc) {
3015
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3016
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3017
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3018
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
3019
+ }
3020
+ __name(_ts_decorate4, "_ts_decorate");
3021
+ var EjsService = class {
3022
+ static {
3023
+ __name(this, "EjsService");
3024
+ }
3025
+ async render(template, data = {}, options) {
3026
+ try {
3027
+ return await render(template, data, {
3028
+ async: true,
3029
+ ...options
3030
+ });
3031
+ } catch (error) {
3032
+ throw new Error(`EJS rendering failed: ${String(error)}`, {
3033
+ cause: error
3034
+ });
3035
+ }
3036
+ }
3037
+ async renderFile(filePath, data = {}, options) {
3038
+ try {
3039
+ return await renderFile(filePath, data, {
3040
+ async: true,
3041
+ ...options
3042
+ });
3043
+ } catch (error) {
3044
+ throw new Error(`EJS file rendering failed: ${String(error)}`, {
3045
+ cause: error
3046
+ });
3047
+ }
3048
+ }
3049
+ };
3050
+ EjsService = _ts_decorate4([
3051
+ Injectable4()
3052
+ ], EjsService);
3053
+
3054
+ // src/puppeteer/puppeteer.service.ts
3055
+ function _ts_decorate5(decorators, target, key, desc) {
3056
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3057
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3058
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3059
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
3060
+ }
3061
+ __name(_ts_decorate5, "_ts_decorate");
2947
3062
  function _ts_metadata2(k, v) {
2948
3063
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
2949
3064
  }
@@ -2961,10 +3076,16 @@ var PuppeteerService = class {
2961
3076
  hbsService;
2962
3077
  browserService;
2963
3078
  options;
2964
- constructor(hbsService, browserService, options) {
3079
+ mjmlService;
3080
+ pugService;
3081
+ ejsService;
3082
+ constructor(hbsService, browserService, options, mjmlService, pugService, ejsService) {
2965
3083
  this.hbsService = hbsService;
2966
3084
  this.browserService = browserService;
2967
3085
  this.options = options;
3086
+ this.mjmlService = mjmlService;
3087
+ this.pugService = pugService;
3088
+ this.ejsService = ejsService;
2968
3089
  }
2969
3090
  limit = pLimit(3);
2970
3091
  async generatePdfFromHtml(html, options) {
@@ -3045,23 +3166,71 @@ var PuppeteerService = class {
3045
3166
  }
3046
3167
  });
3047
3168
  }
3048
- async generatePdfFromTemplateString(template, parameters = {}, options) {
3169
+ async generatePdfFromTemplateHbsString(template, parameters = {}, options) {
3049
3170
  const html = this.hbsService.render(template, parameters);
3050
3171
  return this.generatePdfFromHtml(html, options);
3051
3172
  }
3052
- async generatePdfFromTemplateFile(file, parameters = {}, options) {
3173
+ async generatePdfFromTemplateHbsFile(file, parameters = {}, options) {
3053
3174
  const html = this.hbsService.renderFile(file, parameters);
3054
3175
  return this.generatePdfFromHtml(html, options);
3055
3176
  }
3177
+ async generatePdfFromMjmlString(template, options) {
3178
+ if (!this.mjmlService) {
3179
+ throw new Error("MJML service is not available. If the problem persists, open an issue in the repo.");
3180
+ }
3181
+ const html = await this.mjmlService.render(template, options?.mjmlOptions ?? this.options.mjmlOptions);
3182
+ return this.generatePdfFromHtml(html, options);
3183
+ }
3184
+ async generatePdfFromMjmlFile(file, options) {
3185
+ if (!this.mjmlService) {
3186
+ throw new Error("MJML service is not available. If the problem persists, open an issue in the repo.");
3187
+ }
3188
+ const html = await this.mjmlService.renderFile(file, options?.mjmlOptions ?? this.options.mjmlOptions);
3189
+ return this.generatePdfFromHtml(html, options);
3190
+ }
3191
+ async generatePdfFromPugString(template, data = {}, options) {
3192
+ if (!this.pugService) {
3193
+ throw new Error("Pug service is not available. If the problem persists, open an issue in the repo.");
3194
+ }
3195
+ const html = this.pugService.render(template, data, options?.pugOptions ?? this.options.pugOptions);
3196
+ return this.generatePdfFromHtml(html, options);
3197
+ }
3198
+ async generatePdfFromPugFile(file, data = {}, options) {
3199
+ if (!this.pugService) {
3200
+ throw new Error("Pug service is not available. If the problem persists, open an issue in the repo.");
3201
+ }
3202
+ const html = this.pugService.renderFile(file, data, options?.pugOptions ?? this.options.pugOptions);
3203
+ return this.generatePdfFromHtml(html, options);
3204
+ }
3205
+ async generatePdfFromEjsString(template, data = {}, options) {
3206
+ if (!this.ejsService) {
3207
+ throw new Error("EJS service is not available. If the problem persists, open an issue in the repo.");
3208
+ }
3209
+ const html = await this.ejsService.render(template, data, options?.ejsOptions ?? this.options.ejsOptions);
3210
+ return this.generatePdfFromHtml(html, options);
3211
+ }
3212
+ async generatePdfFromEjsFile(file, data = {}, options) {
3213
+ if (!this.ejsService) {
3214
+ throw new Error("EJS service is not available. If the problem persists, open an issue in the repo.");
3215
+ }
3216
+ const html = await this.ejsService.renderFile(file, data, options?.ejsOptions ?? this.options.ejsOptions);
3217
+ return this.generatePdfFromHtml(html, options);
3218
+ }
3056
3219
  };
3057
- PuppeteerService = _ts_decorate2([
3058
- Injectable2(),
3220
+ PuppeteerService = _ts_decorate5([
3221
+ Injectable5(),
3059
3222
  _ts_param2(2, Inject2(PDF_PARAMETERS)),
3223
+ _ts_param2(3, Optional()),
3224
+ _ts_param2(4, Optional()),
3225
+ _ts_param2(5, Optional()),
3060
3226
  _ts_metadata2("design:type", Function),
3061
3227
  _ts_metadata2("design:paramtypes", [
3062
3228
  typeof HandlebarsService === "undefined" ? Object : HandlebarsService,
3063
3229
  typeof BrowserService === "undefined" ? Object : BrowserService,
3064
- typeof PuppeteerParameters === "undefined" ? Object : PuppeteerParameters
3230
+ typeof PuppeteerParameters === "undefined" ? Object : PuppeteerParameters,
3231
+ typeof MjmlService === "undefined" ? Object : MjmlService,
3232
+ typeof PugService === "undefined" ? Object : PugService,
3233
+ typeof EjsService === "undefined" ? Object : EjsService
3065
3234
  ])
3066
3235
  ], PuppeteerService);
3067
3236
 
@@ -3219,13 +3388,13 @@ async function addSignatureFieldUsingAnchor(pdf, fieldName = "SignatureDebtor",
3219
3388
  __name(addSignatureFieldUsingAnchor, "addSignatureFieldUsingAnchor");
3220
3389
 
3221
3390
  // src/nestjs-pdf.service.ts
3222
- function _ts_decorate3(decorators, target, key, desc) {
3391
+ function _ts_decorate6(decorators, target, key, desc) {
3223
3392
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3224
3393
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3225
3394
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3226
3395
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3227
3396
  }
3228
- __name(_ts_decorate3, "_ts_decorate");
3397
+ __name(_ts_decorate6, "_ts_decorate");
3229
3398
  function _ts_metadata3(k, v) {
3230
3399
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
3231
3400
  }
@@ -3248,6 +3417,7 @@ var NestjsPdfService = class {
3248
3417
  return this.puppeteerService.generatePdfFromHtml(html, options);
3249
3418
  }
3250
3419
  /**
3420
+ * @deprecated Use the new method generatePdfFromTemplateHbsString
3251
3421
  * @param template Handlebars template string
3252
3422
  * @param parameters Data parameters to inject into the template
3253
3423
  * @param options PDF generation options (optional)
@@ -3255,9 +3425,10 @@ var NestjsPdfService = class {
3255
3425
  * @description This method generates a PDF from a Handlebars template provided as a string. The parameters to inject into the template are passed in the `parameters` object, which is used to render the template before converting it to PDF. PDF generation options can also be customized by passing a `PuppeteerParameters` object as the third argument. This allows you to control various aspects of PDF rendering, such as page size, margins, background display, etc. If no options are provided, the default parameters defined in the Puppeteer service will be used.
3256
3426
  */
3257
3427
  generatePdfFromTemplateString(template, parameters = {}, options) {
3258
- return this.puppeteerService.generatePdfFromTemplateString(template, parameters, options);
3428
+ return this.generatePdfFromTemplateHbsString(template, parameters, options);
3259
3429
  }
3260
3430
  /**
3431
+ * @deprecated Use the new method generatePdfFromTemplateHbsFile
3261
3432
  * @param file Path to the Handlebars template file
3262
3433
  * @param parameters Data parameters to inject into the template
3263
3434
  * @param options PDF generation options (optional)
@@ -3265,7 +3436,85 @@ var NestjsPdfService = class {
3265
3436
  * @description This method generates a PDF from a Handlebars template located at the specified file path. The file path is passed as a string in the `file` parameter. The parameters to inject into the template are passed in the `parameters` object, which is used to render the template before converting it to PDF. PDF generation options can also be customized by passing a `PuppeteerParameters` object as the third argument. This allows you to control various aspects of PDF rendering, such as page size, margins, background display, etc. If no options are provided, the default parameters defined in the Puppeteer service will be used.
3266
3437
  */
3267
3438
  generatePdfFromTemplateFile(file, parameters = {}, options) {
3268
- return this.puppeteerService.generatePdfFromTemplateFile(file, parameters, options);
3439
+ return this.generatePdfFromTemplateHbsFile(file, parameters, options);
3440
+ }
3441
+ /**
3442
+ * @param template Handlebars template string
3443
+ * @param parameters Data parameters to inject into the template
3444
+ * @param options PDF generation options (optional)
3445
+ * @returns PDF generated from the provided Handlebars template with parameters applied
3446
+ * @description This method generates a PDF from a Handlebars template provided as a string. The parameters to inject into the template are passed in the `parameters` object, which is used to render the template before converting it to PDF. PDF generation options can also be customized by passing a `PuppeteerParameters` object as the third argument. This allows you to control various aspects of PDF rendering, such as page size, margins, background display, etc. If no options are provided, the default parameters defined in the Puppeteer service will be used.
3447
+ */
3448
+ generatePdfFromTemplateHbsString(template, parameters = {}, options) {
3449
+ return this.puppeteerService.generatePdfFromTemplateHbsString(template, parameters, options);
3450
+ }
3451
+ /**
3452
+ * @param file Path to the Handlebars template file
3453
+ * @param parameters Data parameters to inject into the template
3454
+ * @param options PDF generation options (optional)
3455
+ * @returns PDF generated from the Handlebars template at the provided file path with parameters applied
3456
+ * @description This method generates a PDF from a Handlebars template located at the specified file path. The file path is passed as a string in the `file` parameter. The parameters to inject into the template are passed in the `parameters` object, which is used to render the template before converting it to PDF. PDF generation options can also be customized by passing a `PuppeteerParameters` object as the third argument. This allows you to control various aspects of PDF rendering, such as page size, margins, background display, etc. If no options are provided, the default parameters defined in the Puppeteer service will be used.
3457
+ */
3458
+ generatePdfFromTemplateHbsFile(file, parameters = {}, options) {
3459
+ return this.puppeteerService.generatePdfFromTemplateHbsFile(file, parameters, options);
3460
+ }
3461
+ /**
3462
+ * @param template MJML template string
3463
+ * @param options PDF generation options (optional)
3464
+ * @returns PDF generated from the provided MJML template
3465
+ * @description This method generates a PDF from an MJML template provided as a string. MJML (MJML Markup Language) is a markup language designed to reduce the pain of coding a responsive email. The template is first rendered to HTML using the MJML renderer, then converted to PDF. PDF generation options can be customized by passing a `PuppeteerParameters` object as the second argument.
3466
+ */
3467
+ generatePdfFromMjmlString(template, options) {
3468
+ return this.puppeteerService.generatePdfFromMjmlString(template, options);
3469
+ }
3470
+ /**
3471
+ * @param file Path to the MJML template file
3472
+ * @param options PDF generation options (optional)
3473
+ * @returns PDF generated from the MJML template at the provided file path
3474
+ * @description This method generates a PDF from an MJML template located at the specified file path. The file path is passed as a string in the `file` parameter. The template is first rendered to HTML using the MJML renderer, then converted to PDF. PDF generation options can be customized by passing a `PuppeteerParameters` object as the second argument.
3475
+ */
3476
+ generatePdfFromMjmlFile(file, options) {
3477
+ return this.puppeteerService.generatePdfFromMjmlFile(file, options);
3478
+ }
3479
+ /**
3480
+ * @param template EJS template string
3481
+ * @param data Data to inject into the template
3482
+ * @param options PDF generation options (optional)
3483
+ * @returns PDF generated from the provided EJS template with data applied
3484
+ * @description This method generates a PDF from an EJS (Embedded JavaScript) template provided as a string. EJS is a templating language with a simple, straightforward syntax. The data to inject into the template is passed in the `data` object, which is used to render the template before converting it to PDF. PDF generation options can be customized by passing a `PuppeteerParameters` object as the third argument.
3485
+ */
3486
+ generatePdfFromEjsString(template, data = {}, options) {
3487
+ return this.puppeteerService.generatePdfFromEjsString(template, data, options);
3488
+ }
3489
+ /**
3490
+ * @param file Path to the EJS template file
3491
+ * @param data Data to inject into the template
3492
+ * @param options PDF generation options (optional)
3493
+ * @returns PDF generated from the EJS template at the provided file path with data applied
3494
+ * @description This method generates a PDF from an EJS template located at the specified file path. The file path is passed as a string in the `file` parameter. The data to inject into the template is passed in the `data` object, which is used to render the template before converting it to PDF. PDF generation options can be customized by passing a `PuppeteerParameters` object as the third argument.
3495
+ */
3496
+ generatePdfFromEjsFile(file, data = {}, options) {
3497
+ return this.puppeteerService.generatePdfFromEjsFile(file, data, options);
3498
+ }
3499
+ /**
3500
+ * @param template Pug template string
3501
+ * @param data Data to inject into the template
3502
+ * @param options PDF generation options (optional)
3503
+ * @returns PDF generated from the provided Pug template with data applied
3504
+ * @description This method generates a PDF from a Pug template provided as a string. Pug is a clean, whitespace-sensitive syntax for writing HTML. The data to inject into the template is passed in the `data` object, which is used to render the template before converting it to PDF. PDF generation options can be customized by passing a `PuppeteerParameters` object as the third argument.
3505
+ */
3506
+ generatePdfFromPugString(template, data = {}, options) {
3507
+ return this.puppeteerService.generatePdfFromPugString(template, data, options);
3508
+ }
3509
+ /**
3510
+ * @param file Path to the Pug template file
3511
+ * @param data Data to inject into the template
3512
+ * @param options PDF generation options (optional)
3513
+ * @returns PDF generated from the Pug template at the provided file path with data applied
3514
+ * @description This method generates a PDF from a Pug template located at the specified file path. The file path is passed as a string in the `file` parameter. The data to inject into the template is passed in the `data` object, which is used to render the template before converting it to PDF. PDF generation options can be customized by passing a `PuppeteerParameters` object as the third argument.
3515
+ */
3516
+ generatePdfFromPugFile(file, data = {}, options) {
3517
+ return this.puppeteerService.generatePdfFromPugFile(file, data, options);
3269
3518
  }
3270
3519
  /**
3271
3520
  * @param pdf The PDF bytes to modify
@@ -3293,8 +3542,8 @@ var NestjsPdfService = class {
3293
3542
  return await addSignatureFieldUsingAnchor(pdf, fieldName, anchorText);
3294
3543
  }
3295
3544
  };
3296
- NestjsPdfService = _ts_decorate3([
3297
- Injectable3(),
3545
+ NestjsPdfService = _ts_decorate6([
3546
+ Injectable6(),
3298
3547
  _ts_metadata3("design:type", Function),
3299
3548
  _ts_metadata3("design:paramtypes", [
3300
3549
  typeof PuppeteerService === "undefined" ? Object : PuppeteerService
@@ -3305,13 +3554,13 @@ NestjsPdfService = _ts_decorate3([
3305
3554
  import { Inject as Inject3, Module } from "@nestjs/common";
3306
3555
  var import_config = __toESM(require_config());
3307
3556
  import { HandlebarsService as HandlebarsService2 } from "@gboutte/nestjs-hbs";
3308
- function _ts_decorate4(decorators, target, key, desc) {
3557
+ function _ts_decorate7(decorators, target, key, desc) {
3309
3558
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3310
3559
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3311
3560
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3312
3561
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3313
3562
  }
3314
- __name(_ts_decorate4, "_ts_decorate");
3563
+ __name(_ts_decorate7, "_ts_decorate");
3315
3564
  function _ts_metadata4(k, v) {
3316
3565
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
3317
3566
  }
@@ -3345,7 +3594,10 @@ var PuppeteerModule = class _PuppeteerModule {
3345
3594
  provide: HANDLEBARS_PARAMETERS,
3346
3595
  useValue: pdfParameters.hbsOptions ?? {}
3347
3596
  },
3348
- HandlebarsService2
3597
+ HandlebarsService2,
3598
+ MjmlService,
3599
+ PugService,
3600
+ EjsService
3349
3601
  ];
3350
3602
  return {
3351
3603
  module: _PuppeteerModule,
@@ -3354,7 +3606,10 @@ var PuppeteerModule = class _PuppeteerModule {
3354
3606
  ],
3355
3607
  providers,
3356
3608
  exports: [
3357
- PuppeteerService
3609
+ PuppeteerService,
3610
+ MjmlService,
3611
+ PugService,
3612
+ EjsService
3358
3613
  ]
3359
3614
  };
3360
3615
  }
@@ -3382,22 +3637,34 @@ var PuppeteerModule = class _PuppeteerModule {
3382
3637
  hbsParamsProvider,
3383
3638
  PuppeteerService,
3384
3639
  BrowserService,
3385
- HandlebarsService2
3640
+ HandlebarsService2,
3641
+ MjmlService,
3642
+ PugService,
3643
+ EjsService
3386
3644
  ],
3387
3645
  exports: [
3388
- PuppeteerService
3646
+ PuppeteerService,
3647
+ MjmlService,
3648
+ PugService,
3649
+ EjsService
3389
3650
  ]
3390
3651
  };
3391
3652
  }
3392
3653
  };
3393
- PuppeteerModule = _ts_decorate4([
3654
+ PuppeteerModule = _ts_decorate7([
3394
3655
  Module({
3395
3656
  providers: [
3396
3657
  PuppeteerService,
3397
- BrowserService
3658
+ BrowserService,
3659
+ MjmlService,
3660
+ PugService,
3661
+ EjsService
3398
3662
  ],
3399
3663
  exports: [
3400
- PuppeteerService
3664
+ PuppeteerService,
3665
+ MjmlService,
3666
+ PugService,
3667
+ EjsService
3401
3668
  ]
3402
3669
  }),
3403
3670
  _ts_param3(1, Inject3(PDF_PARAMETERS)),
@@ -3409,13 +3676,13 @@ PuppeteerModule = _ts_decorate4([
3409
3676
  ], PuppeteerModule);
3410
3677
 
3411
3678
  // src/nestjs-pdf.module.ts
3412
- function _ts_decorate5(decorators, target, key, desc) {
3679
+ function _ts_decorate8(decorators, target, key, desc) {
3413
3680
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3414
3681
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3415
3682
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3416
3683
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3417
3684
  }
3418
- __name(_ts_decorate5, "_ts_decorate");
3685
+ __name(_ts_decorate8, "_ts_decorate");
3419
3686
  var NestjsPdfModule = class _NestjsPdfModule {
3420
3687
  static {
3421
3688
  __name(this, "NestjsPdfModule");
@@ -3449,67 +3716,10 @@ var NestjsPdfModule = class _NestjsPdfModule {
3449
3716
  };
3450
3717
  }
3451
3718
  };
3452
- NestjsPdfModule = _ts_decorate5([
3719
+ NestjsPdfModule = _ts_decorate8([
3453
3720
  Module2({})
3454
3721
  ], NestjsPdfModule);
3455
3722
 
3456
- // src/puppeteer/external/puppeteer-handlebars.module.ts
3457
- import { Module as Module3 } from "@nestjs/common";
3458
- import { HandlebarsService as HandlebarsService3 } from "@gboutte/nestjs-hbs";
3459
- function _ts_decorate6(decorators, target, key, desc) {
3460
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3461
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3462
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3463
- return c > 3 && r && Object.defineProperty(target, key, r), r;
3464
- }
3465
- __name(_ts_decorate6, "_ts_decorate");
3466
- var PuppeteerHandlebarsModule = class _PuppeteerHandlebarsModule {
3467
- static {
3468
- __name(this, "PuppeteerHandlebarsModule");
3469
- }
3470
- static forRoot(handlebarsOptions) {
3471
- return {
3472
- module: _PuppeteerHandlebarsModule,
3473
- providers: [
3474
- {
3475
- provide: "HANDLEBARS_PARAMETERS",
3476
- useValue: handlebarsOptions
3477
- }
3478
- ],
3479
- exports: [
3480
- HandlebarsService3
3481
- ]
3482
- };
3483
- }
3484
- static forRootAsync(options) {
3485
- const provider = {
3486
- provide: "HANDLEBARS_PARAMETERS",
3487
- inject: options.inject ?? [],
3488
- useFactory: /* @__PURE__ */ __name(async (...args) => options.useFactory(...args), "useFactory")
3489
- };
3490
- return {
3491
- module: _PuppeteerHandlebarsModule,
3492
- imports: options.imports ?? [],
3493
- providers: [
3494
- provider
3495
- ],
3496
- exports: [
3497
- HandlebarsService3
3498
- ]
3499
- };
3500
- }
3501
- };
3502
- PuppeteerHandlebarsModule = _ts_decorate6([
3503
- Module3({
3504
- providers: [
3505
- HandlebarsService3
3506
- ],
3507
- exports: [
3508
- HandlebarsService3
3509
- ]
3510
- })
3511
- ], PuppeteerHandlebarsModule);
3512
-
3513
3723
  // src/helpers/getRelativePath.helper.ts
3514
3724
  import { relative, resolve as resolve2 } from "path";
3515
3725
  function getRelativePathToValue(moduleDir, relativeToModule) {
@@ -3518,9 +3728,11 @@ function getRelativePathToValue(moduleDir, relativeToModule) {
3518
3728
  }
3519
3729
  __name(getRelativePathToValue, "getRelativePathToValue");
3520
3730
  export {
3731
+ EjsService,
3732
+ MjmlService,
3521
3733
  NestjsPdfModule,
3522
3734
  NestjsPdfService,
3523
- PuppeteerHandlebarsModule,
3735
+ PugService,
3524
3736
  PuppeteerModule,
3525
3737
  PuppeteerService,
3526
3738
  getRelativePathToValue
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shad0wz7/nestjs-pdf",
3
- "version": "1.1.1",
3
+ "version": "2.0.0",
4
4
  "description": "A NestJS library for generating PDFs with Puppeteer and Handlebars.",
5
5
  "author": "Emmanuel Boisset",
6
6
  "license": "MIT",
@@ -46,9 +46,12 @@
46
46
  "@gboutte/nestjs-hbs": "^0.2.0",
47
47
  "@puppeteer/browsers": "^2.13.2",
48
48
  "deepmerge-ts": "^7.1.5",
49
+ "ejs": "^5.0.2",
50
+ "mjml": "^5.2.1",
51
+ "p-limit": "^7.3.0",
49
52
  "pdf-lib": "^1.17.1",
50
53
  "pdfjs-dist": "^5.7.284",
51
- "p-limit": "^7.3.0",
54
+ "pug": "^3.0.3",
52
55
  "puppeteer": "^24.43.1"
53
56
  },
54
57
  "devDependencies": {
@@ -62,15 +65,20 @@
62
65
  "@nestjs/schematics": "^11.1.0",
63
66
  "@nestjs/testing": "^11.1.19",
64
67
  "@swc/core": "^1.15.33",
68
+ "@types/ejs": "^3.1.5",
65
69
  "@types/express": "^5.0.6",
66
70
  "@types/jest": "^30.0.0",
71
+ "@types/mjml": "^5.0.0",
72
+ "@types/mjml-core": "^5.0.0",
67
73
  "@types/node": "^25.6.2",
74
+ "@types/pug": "^2.0.10",
68
75
  "@types/supertest": "^7.2.0",
69
76
  "eslint": "^10.3.0",
70
77
  "eslint-config-prettier": "^10.1.8",
71
78
  "eslint-plugin-prettier": "^5.5.5",
72
79
  "globals": "^17.6.0",
73
80
  "jest": "^30.4.2",
81
+ "mjml-core": "^5.2.0",
74
82
  "prettier": "^3.8.3",
75
83
  "reflect-metadata": "^0.2.2",
76
84
  "source-map-support": "^0.5.21",