@maioradv/nestjs-core 2.3.9 → 2.4.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.
@@ -12,10 +12,12 @@ export declare class PushNotificationBuilder {
12
12
  init(): Promise<{
13
13
  title: string;
14
14
  template: HandlebarsTemplateDelegate<any>;
15
+ options: Record<string, unknown>;
15
16
  }>;
16
17
  build(args?: Record<string, any>): Promise<{
17
18
  title: string;
18
19
  body: string;
20
+ options: Record<string, unknown>;
19
21
  }>;
20
22
  replace(ctx: string, replace?: Record<string, any>): string;
21
23
  }
@@ -29,6 +29,7 @@ class PushNotificationBuilder {
29
29
  (0, path_1.join)(mainPath, 'doc.hbs'),
30
30
  (0, path_1.join)(mainPath, 'partials', `${this.pattern}.hbs`),
31
31
  (0, path_1.join)(mainPath, 'locales', `${this.locale}.json`),
32
+ (0, path_1.join)(mainPath, 'options', `${this.pattern}.json`),
32
33
  ];
33
34
  }
34
35
  async safeCheck() {
@@ -46,8 +47,9 @@ class PushNotificationBuilder {
46
47
  return path.split('.').reduce((acc, key) => acc?.[key], obj) ?? path;
47
48
  }
48
49
  async init() {
49
- const [Container, Body, Labels] = await Promise.all(this.paths().map(path => (0, promises_1.readFile)(path, 'utf-8')));
50
+ const [Container, Body, Labels, Options] = await Promise.all(this.paths().map(path => (0, promises_1.readFile)(path, 'utf-8')));
50
51
  const labels = JSON.parse(Labels);
52
+ const options = JSON.parse(Options);
51
53
  const title = this.getNestedValue(labels, `${this.pattern}.title`);
52
54
  handlebars_1.default.registerHelper('fullDateTime', function (date, locale) {
53
55
  return new Date(date).toLocaleString(locale, { dateStyle: 'full', timeStyle: 'short' });
@@ -66,17 +68,19 @@ class PushNotificationBuilder {
66
68
  const template = handlebars_1.default.compile(Container);
67
69
  return {
68
70
  title,
69
- template
71
+ template,
72
+ options
70
73
  };
71
74
  }
72
75
  async build(args) {
73
- const { title, template } = await this.init();
76
+ const { title, template, options } = await this.init();
74
77
  return {
75
78
  title,
76
79
  body: template({
77
80
  ...args,
78
81
  locale: this.locale
79
- })
82
+ }),
83
+ options
80
84
  };
81
85
  }
82
86
  replace(ctx, replace) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maioradv/nestjs-core",
3
- "version": "2.3.9",
3
+ "version": "2.4.0",
4
4
  "description": "NestJS helpers by MaiorADV",
5
5
  "repository": "https://github.com/maioradv/nestjs-core.git",
6
6
  "author": "Maior ADV Srl",