@webda/core 2.0.0-beta.3 → 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.
Files changed (276) hide show
  1. package/lib/application.d.ts +5 -5
  2. package/lib/application.js +71 -84
  3. package/lib/application.js.map +1 -1
  4. package/lib/application.spec.js +121 -140
  5. package/lib/application.spec.js.map +1 -1
  6. package/lib/core.d.ts +20 -24
  7. package/lib/core.js +222 -315
  8. package/lib/core.js.map +1 -1
  9. package/lib/core.spec.js +332 -406
  10. package/lib/core.spec.js.map +1 -1
  11. package/lib/index.d.ts +49 -48
  12. package/lib/index.js +53 -70
  13. package/lib/index.js.map +1 -1
  14. package/lib/models/aclmodel.d.ts +2 -2
  15. package/lib/models/aclmodel.js +63 -90
  16. package/lib/models/aclmodel.js.map +1 -1
  17. package/lib/models/aclmodel.spec.js +127 -152
  18. package/lib/models/aclmodel.spec.js.map +1 -1
  19. package/lib/models/coremodel.d.ts +7 -6
  20. package/lib/models/coremodel.js +65 -113
  21. package/lib/models/coremodel.js.map +1 -1
  22. package/lib/models/coremodel.spec.js +88 -107
  23. package/lib/models/coremodel.spec.js.map +1 -1
  24. package/lib/models/deployment.js +1 -2
  25. package/lib/models/ident.d.ts +3 -3
  26. package/lib/models/ident.js +4 -9
  27. package/lib/models/ident.js.map +1 -1
  28. package/lib/models/ident.spec.js +9 -11
  29. package/lib/models/ident.spec.js.map +1 -1
  30. package/lib/models/ownermodel.d.ts +2 -2
  31. package/lib/models/ownermodel.js +39 -62
  32. package/lib/models/ownermodel.js.map +1 -1
  33. package/lib/models/ownermodel.spec.js +126 -168
  34. package/lib/models/ownermodel.spec.js.map +1 -1
  35. package/lib/models/rolemodel.d.ts +1 -1
  36. package/lib/models/rolemodel.js +24 -40
  37. package/lib/models/rolemodel.js.map +1 -1
  38. package/lib/models/rolemodel.spec.js +44 -63
  39. package/lib/models/rolemodel.spec.js.map +1 -1
  40. package/lib/models/user.d.ts +3 -3
  41. package/lib/models/user.js +3 -8
  42. package/lib/models/user.js.map +1 -1
  43. package/lib/models/user.spec.js +14 -16
  44. package/lib/models/user.spec.js.map +1 -1
  45. package/lib/queues/filequeue.d.ts +2 -2
  46. package/lib/queues/filequeue.js +72 -93
  47. package/lib/queues/filequeue.js.map +1 -1
  48. package/lib/queues/filequeue.spec.js +53 -70
  49. package/lib/queues/filequeue.spec.js.map +1 -1
  50. package/lib/queues/memoryqueue.d.ts +2 -2
  51. package/lib/queues/memoryqueue.js +37 -61
  52. package/lib/queues/memoryqueue.js.map +1 -1
  53. package/lib/queues/memoryqueue.spec.js +142 -165
  54. package/lib/queues/memoryqueue.spec.js.map +1 -1
  55. package/lib/queues/pubsubservice.d.ts +2 -2
  56. package/lib/queues/pubsubservice.js +3 -7
  57. package/lib/queues/pubsubservice.js.map +1 -1
  58. package/lib/queues/queue.spec.d.ts +1 -1
  59. package/lib/queues/queue.spec.js +42 -56
  60. package/lib/queues/queue.spec.js.map +1 -1
  61. package/lib/queues/queueservice.d.ts +3 -3
  62. package/lib/queues/queueservice.js +51 -67
  63. package/lib/queues/queueservice.js.map +1 -1
  64. package/lib/router.d.ts +3 -3
  65. package/lib/router.js +46 -47
  66. package/lib/router.js.map +1 -1
  67. package/lib/router.spec.js +64 -61
  68. package/lib/router.spec.js.map +1 -1
  69. package/lib/services/asyncevents.d.ts +2 -2
  70. package/lib/services/asyncevents.js +44 -64
  71. package/lib/services/asyncevents.js.map +1 -1
  72. package/lib/services/asyncevents.spec.js +81 -98
  73. package/lib/services/asyncevents.spec.js.map +1 -1
  74. package/lib/services/authentication.d.ts +23 -13
  75. package/lib/services/authentication.js +537 -563
  76. package/lib/services/authentication.js.map +1 -1
  77. package/lib/services/authentication.spec.js +411 -447
  78. package/lib/services/authentication.spec.js.map +1 -1
  79. package/lib/services/binary.d.ts +7 -5
  80. package/lib/services/binary.js +211 -244
  81. package/lib/services/binary.js.map +1 -1
  82. package/lib/services/binary.spec.d.ts +3 -3
  83. package/lib/services/binary.spec.js +390 -443
  84. package/lib/services/binary.spec.js.map +1 -1
  85. package/lib/services/cloudbinary.d.ts +3 -3
  86. package/lib/services/cloudbinary.js +45 -70
  87. package/lib/services/cloudbinary.js.map +1 -1
  88. package/lib/services/cloudbinary.spec.d.ts +3 -3
  89. package/lib/services/cloudbinary.spec.js +133 -162
  90. package/lib/services/cloudbinary.spec.js.map +1 -1
  91. package/lib/services/configuration.d.ts +1 -1
  92. package/lib/services/configuration.js +78 -105
  93. package/lib/services/configuration.js.map +1 -1
  94. package/lib/services/configuration.spec.js +63 -83
  95. package/lib/services/configuration.spec.js.map +1 -1
  96. package/lib/services/cron.d.ts +3 -2
  97. package/lib/services/cron.js +9 -13
  98. package/lib/services/cron.js.map +1 -1
  99. package/lib/services/cron.spec.js +18 -21
  100. package/lib/services/cron.spec.js.map +1 -1
  101. package/lib/services/cryptoservice.d.ts +9 -4
  102. package/lib/services/cryptoservice.js +187 -221
  103. package/lib/services/cryptoservice.js.map +1 -1
  104. package/lib/services/cryptoservice.spec.js +88 -115
  105. package/lib/services/cryptoservice.spec.js.map +1 -1
  106. package/lib/services/debugmailer.d.ts +1 -1
  107. package/lib/services/debugmailer.js +13 -34
  108. package/lib/services/debugmailer.js.map +1 -1
  109. package/lib/services/debugmailer.spec.js +16 -29
  110. package/lib/services/debugmailer.spec.js.map +1 -1
  111. package/lib/services/echo.d.ts +2 -2
  112. package/lib/services/echo.js +15 -31
  113. package/lib/services/echo.js.map +1 -1
  114. package/lib/services/echo.spec.js +27 -40
  115. package/lib/services/echo.spec.js.map +1 -1
  116. package/lib/services/filebinary.d.ts +5 -5
  117. package/lib/services/filebinary.js +165 -210
  118. package/lib/services/filebinary.js.map +1 -1
  119. package/lib/services/filebinary.spec.d.ts +2 -1
  120. package/lib/services/filebinary.spec.js +106 -116
  121. package/lib/services/filebinary.spec.js.map +1 -1
  122. package/lib/services/fileconfiguration.d.ts +1 -1
  123. package/lib/services/fileconfiguration.js +25 -44
  124. package/lib/services/fileconfiguration.js.map +1 -1
  125. package/lib/services/fileconfiguration.spec.js +79 -109
  126. package/lib/services/fileconfiguration.spec.js.map +1 -1
  127. package/lib/services/invitationservice.d.ts +7 -7
  128. package/lib/services/invitationservice.js +274 -314
  129. package/lib/services/invitationservice.js.map +1 -1
  130. package/lib/services/invitationservice.spec.js +442 -448
  131. package/lib/services/invitationservice.spec.js.map +1 -1
  132. package/lib/services/kubernetesconfiguration.d.ts +1 -1
  133. package/lib/services/kubernetesconfiguration.js +41 -60
  134. package/lib/services/kubernetesconfiguration.js.map +1 -1
  135. package/lib/services/kubernetesconfiguration.spec.js +80 -98
  136. package/lib/services/kubernetesconfiguration.spec.js.map +1 -1
  137. package/lib/services/mailer.d.ts +4 -4
  138. package/lib/services/mailer.js +62 -86
  139. package/lib/services/mailer.js.map +1 -1
  140. package/lib/services/mailer.spec.js +86 -127
  141. package/lib/services/mailer.spec.js.map +1 -1
  142. package/lib/services/notificationservice.d.ts +3 -3
  143. package/lib/services/notificationservice.js +21 -42
  144. package/lib/services/notificationservice.js.map +1 -1
  145. package/lib/services/notificationservice.spec.js +47 -73
  146. package/lib/services/notificationservice.spec.js.map +1 -1
  147. package/lib/services/oauth.d.ts +4 -4
  148. package/lib/services/oauth.js +68 -83
  149. package/lib/services/oauth.js.map +1 -1
  150. package/lib/services/oauth.spec.js +130 -156
  151. package/lib/services/oauth.spec.js.map +1 -1
  152. package/lib/services/proxy.d.ts +2 -6
  153. package/lib/services/proxy.js +45 -58
  154. package/lib/services/proxy.js.map +1 -1
  155. package/lib/services/proxy.spec.js +34 -53
  156. package/lib/services/proxy.spec.js.map +1 -1
  157. package/lib/services/resource.d.ts +2 -2
  158. package/lib/services/resource.js +12 -18
  159. package/lib/services/resource.js.map +1 -1
  160. package/lib/services/resource.spec.js +67 -99
  161. package/lib/services/resource.spec.js.map +1 -1
  162. package/lib/services/service.d.ts +26 -3
  163. package/lib/services/service.js +68 -40
  164. package/lib/services/service.js.map +1 -1
  165. package/lib/services/service.spec.js +62 -67
  166. package/lib/services/service.spec.js.map +1 -1
  167. package/lib/services/version.d.ts +1 -1
  168. package/lib/services/version.js +3 -8
  169. package/lib/services/version.js.map +1 -1
  170. package/lib/services/version.spec.js +11 -24
  171. package/lib/services/version.spec.js.map +1 -1
  172. package/lib/stores/aggregator.d.ts +2 -2
  173. package/lib/stores/aggregator.js +37 -58
  174. package/lib/stores/aggregator.js.map +1 -1
  175. package/lib/stores/file.d.ts +3 -3
  176. package/lib/stores/file.js +93 -131
  177. package/lib/stores/file.js.map +1 -1
  178. package/lib/stores/file.spec.d.ts +2 -2
  179. package/lib/stores/file.spec.js +261 -289
  180. package/lib/stores/file.spec.js.map +1 -1
  181. package/lib/stores/mapper.d.ts +3 -3
  182. package/lib/stores/mapper.js +110 -137
  183. package/lib/stores/mapper.js.map +1 -1
  184. package/lib/stores/mapper.spec.js +131 -150
  185. package/lib/stores/mapper.spec.js.map +1 -1
  186. package/lib/stores/memory.d.ts +3 -3
  187. package/lib/stores/memory.js +98 -144
  188. package/lib/stores/memory.js.map +1 -1
  189. package/lib/stores/memory.spec.d.ts +2 -2
  190. package/lib/stores/memory.spec.js +124 -145
  191. package/lib/stores/memory.spec.js.map +1 -1
  192. package/lib/stores/store.d.ts +17 -13
  193. package/lib/stores/store.js +819 -847
  194. package/lib/stores/store.js.map +1 -1
  195. package/lib/stores/store.spec.d.ts +5 -4
  196. package/lib/stores/store.spec.js +624 -669
  197. package/lib/stores/store.spec.js.map +1 -1
  198. package/lib/stores/webdaql/WebdaQLLexer.d.ts +4 -4
  199. package/lib/stores/webdaql/WebdaQLLexer.js +9 -13
  200. package/lib/stores/webdaql/WebdaQLLexer.js.map +1 -1
  201. package/lib/stores/webdaql/WebdaQLParserLexer.d.ts +4 -4
  202. package/lib/stores/webdaql/WebdaQLParserLexer.js +9 -13
  203. package/lib/stores/webdaql/WebdaQLParserLexer.js.map +1 -1
  204. package/lib/stores/webdaql/WebdaQLParserListener.d.ts +2 -2
  205. package/lib/stores/webdaql/WebdaQLParserListener.js +1 -2
  206. package/lib/stores/webdaql/WebdaQLParserListener.js.map +1 -1
  207. package/lib/stores/webdaql/WebdaQLParserParser.d.ts +10 -10
  208. package/lib/stores/webdaql/WebdaQLParserParser.js +62 -91
  209. package/lib/stores/webdaql/WebdaQLParserParser.js.map +1 -1
  210. package/lib/stores/webdaql/WebdaQLParserVisitor.d.ts +2 -2
  211. package/lib/stores/webdaql/WebdaQLParserVisitor.js +1 -2
  212. package/lib/stores/webdaql/WebdaQLParserVisitor.js.map +1 -1
  213. package/lib/stores/webdaql/query.d.ts +4 -5
  214. package/lib/stores/webdaql/query.js +16 -19
  215. package/lib/stores/webdaql/query.js.map +1 -1
  216. package/lib/stores/webdaql/query.spec.js +30 -32
  217. package/lib/stores/webdaql/query.spec.js.map +1 -1
  218. package/lib/test.d.ts +3 -3
  219. package/lib/test.js +73 -100
  220. package/lib/test.js.map +1 -1
  221. package/lib/unpackedapplication.d.ts +1 -1
  222. package/lib/unpackedapplication.js +25 -31
  223. package/lib/unpackedapplication.js.map +1 -1
  224. package/lib/utils/abstractdeployer.js +1 -5
  225. package/lib/utils/abstractdeployer.js.map +1 -1
  226. package/lib/utils/abstractdeployer.spec.js +6 -8
  227. package/lib/utils/abstractdeployer.spec.js.map +1 -1
  228. package/lib/utils/context.d.ts +7 -5
  229. package/lib/utils/context.js +95 -103
  230. package/lib/utils/context.js.map +1 -1
  231. package/lib/utils/context.spec.js +139 -163
  232. package/lib/utils/context.spec.js.map +1 -1
  233. package/lib/utils/cookie.d.ts +3 -3
  234. package/lib/utils/cookie.js +42 -61
  235. package/lib/utils/cookie.js.map +1 -1
  236. package/lib/utils/cookie.spec.js +42 -64
  237. package/lib/utils/cookie.spec.js.map +1 -1
  238. package/lib/utils/esm.d.ts +4 -0
  239. package/lib/utils/esm.js +10 -0
  240. package/lib/utils/esm.js.map +1 -0
  241. package/lib/utils/httpcontext.d.ts +3 -0
  242. package/lib/utils/httpcontext.js +48 -65
  243. package/lib/utils/httpcontext.js.map +1 -1
  244. package/lib/utils/httpcontext.spec.js +37 -56
  245. package/lib/utils/httpcontext.spec.js.map +1 -1
  246. package/lib/utils/logger.d.ts +2 -2
  247. package/lib/utils/logger.js +15 -28
  248. package/lib/utils/logger.js.map +1 -1
  249. package/lib/utils/logger.spec.js +9 -11
  250. package/lib/utils/logger.spec.js.map +1 -1
  251. package/lib/utils/serializers.js +17 -20
  252. package/lib/utils/serializers.js.map +1 -1
  253. package/lib/utils/serializers.spec.js +43 -44
  254. package/lib/utils/serializers.spec.js.map +1 -1
  255. package/lib/utils/session.d.ts +6 -6
  256. package/lib/utils/session.js +37 -59
  257. package/lib/utils/session.js.map +1 -1
  258. package/lib/utils/session.spec.js +38 -51
  259. package/lib/utils/session.spec.js.map +1 -1
  260. package/lib/utils/waiter.d.ts +1 -1
  261. package/lib/utils/waiter.js +32 -52
  262. package/lib/utils/waiter.js.map +1 -1
  263. package/lib/utils/waiter.spec.js +75 -92
  264. package/lib/utils/waiter.spec.js.map +1 -1
  265. package/package.json +17 -12
  266. package/test/config-invitation.json +1 -3
  267. package/test/config.json +1 -2
  268. package/test/config.old.json +1 -2
  269. package/test/moddas/annotatedservice.js +5 -5
  270. package/test/moddas/debugmailer.js +2 -3
  271. package/test/moddas/fakeservice.js +2 -3
  272. package/test/moddas/voidstore.js +6 -4
  273. package/test/models/ident.js +2 -6
  274. package/test/models/task.js +3 -7
  275. package/test/package.json +2 -1
  276. package/webda.module.json +956 -189
@@ -1,66 +1,49 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.Mailer = exports.AbstractMailer = exports.MailerParameters = void 0;
13
- const Email = require("email-templates");
14
- const fs = require("fs");
15
- const nodemailer = require("nodemailer");
16
- const path = require("path");
17
- const service_1 = require("./service");
18
- class MailerParameters extends service_1.ServiceParameters {
1
+ import Email from "email-templates";
2
+ import * as fs from "fs";
3
+ import * as nodemailer from "nodemailer";
4
+ import * as path from "path";
5
+ import { Service, ServiceParameters } from "./service.js";
6
+ export class MailerParameters extends ServiceParameters {
19
7
  constructor(params) {
20
- var _a, _b, _c, _d, _e, _f;
21
- var _g, _h, _j;
8
+ var _a, _b, _c;
22
9
  super(params);
23
- (_a = this.templates) !== null && _a !== void 0 ? _a : (this.templates = "./templates");
10
+ this.templates ?? (this.templates = "./templates");
24
11
  if (!this.templates.endsWith("/")) {
25
12
  this.templates += "/";
26
13
  }
27
- (_b = this.templatesEngine) !== null && _b !== void 0 ? _b : (this.templatesEngine = "mustache");
28
- (_c = this.emailTemplateOptions) !== null && _c !== void 0 ? _c : (this.emailTemplateOptions = {});
29
- (_d = (_g = this.emailTemplateOptions).juiceResources) !== null && _d !== void 0 ? _d : (_g.juiceResources = {});
30
- (_e = (_h = this.emailTemplateOptions.juiceResources).webResources) !== null && _e !== void 0 ? _e : (_h.webResources = {});
31
- (_f = (_j = this.emailTemplateOptions.juiceResources.webResources).relativeTo) !== null && _f !== void 0 ? _f : (_j.relativeTo = path.resolve(this.templates));
14
+ this.templatesEngine ?? (this.templatesEngine = "mustache");
15
+ this.emailTemplateOptions ?? (this.emailTemplateOptions = {});
16
+ (_a = this.emailTemplateOptions).juiceResources ?? (_a.juiceResources = {});
17
+ (_b = this.emailTemplateOptions.juiceResources).webResources ?? (_b.webResources = {});
18
+ (_c = this.emailTemplateOptions.juiceResources.webResources).relativeTo ?? (_c.relativeTo = path.resolve(this.templates));
32
19
  }
33
20
  }
34
- exports.MailerParameters = MailerParameters;
35
- class AbstractMailer extends service_1.Service {
21
+ export class AbstractMailer extends Service {
36
22
  /**
37
23
  * If user has an email
38
24
  * @param user
39
25
  * @returns
40
26
  */
41
- handleNotificationFor(user) {
42
- return __awaiter(this, void 0, void 0, function* () {
43
- return user.getEmail() !== null;
44
- });
27
+ async handleNotificationFor(user) {
28
+ return user.getEmail() !== null;
45
29
  }
46
30
  /**
47
31
  * @override
48
32
  */
49
- sendNotification(user, notification, replacements) {
50
- return __awaiter(this, void 0, void 0, function* () {
51
- let email = user.getEmail();
52
- if (!email) {
53
- throw new Error(`Cannot find a valid email for ${user.__type} '${user.getUuid()}'`);
54
- }
55
- return this.send({
56
- template: notification,
57
- replacements: Object.assign({}, replacements),
58
- to: email
59
- });
33
+ async sendNotification(user, notification, replacements) {
34
+ let email = user.getEmail();
35
+ if (!email) {
36
+ throw new Error(`Cannot find a valid email for ${user.__type} '${user.getUuid()}'`);
37
+ }
38
+ return this.send({
39
+ template: notification,
40
+ replacements: {
41
+ ...replacements
42
+ },
43
+ to: email
60
44
  });
61
45
  }
62
46
  }
63
- exports.AbstractMailer = AbstractMailer;
64
47
  /**
65
48
  * A basic Mailer based on the nodemailer module
66
49
  *
@@ -90,17 +73,9 @@ class Mailer extends AbstractMailer {
90
73
  /**
91
74
  * Compute parameters
92
75
  */
93
- computeParameters() {
94
- let config = {};
95
- Object.assign(config, this.parameters);
96
- if (config.transport === "ses" && !config.SES) {
97
- let aws = require("aws-sdk");
98
- aws.config.update(config);
99
- config.SES = new aws.SES({
100
- apiVersion: "2010-12-01"
101
- });
102
- }
103
- this._transporter = nodemailer.createTransport(config);
76
+ async init() {
77
+ this._transporter = nodemailer.createTransport(this.parameters);
78
+ return this;
104
79
  }
105
80
  /**
106
81
  * Get a template by name
@@ -114,12 +89,15 @@ class Mailer extends AbstractMailer {
114
89
  this._webda.log("WARN", "No template found for", name);
115
90
  return;
116
91
  }
117
- this._templates[name] = new Email(Object.assign(Object.assign({}, this.parameters.emailTemplateOptions), { views: {
92
+ this._templates[name] = new Email({
93
+ ...this.parameters.emailTemplateOptions,
94
+ views: {
118
95
  root: this.parameters.templates,
119
96
  options: {
120
97
  extension: this.parameters.templatesEngine
121
98
  }
122
- } }));
99
+ }
100
+ });
123
101
  }
124
102
  return this._templates[name];
125
103
  }
@@ -138,40 +116,38 @@ class Mailer extends AbstractMailer {
138
116
  * @params options Options to pass to the sendMail option of the nodemailer module
139
117
  * @params callback to pass to the sendMail
140
118
  */
141
- send(options, callback = undefined) {
142
- return __awaiter(this, void 0, void 0, function* () {
143
- if (this._transporter === undefined) {
144
- this._webda.log("ERROR", "Cannot send email as no transporter is defined");
145
- return Promise.reject("Cannot send email as no transporter is defined");
146
- }
147
- if (!options.from) {
148
- options.from = this.parameters.sender;
119
+ async send(options, callback = undefined) {
120
+ if (this._transporter === undefined) {
121
+ this._webda.log("ERROR", "Cannot send email as no transporter is defined");
122
+ return Promise.reject("Cannot send email as no transporter is defined");
123
+ }
124
+ if (!options.from) {
125
+ options.from = this.parameters.sender;
126
+ }
127
+ if (options.template) {
128
+ if (!options.replacements) {
129
+ options.replacements = {};
149
130
  }
150
- if (options.template) {
151
- if (!options.replacements) {
152
- options.replacements = {};
131
+ options.replacements.now = new Date();
132
+ let template = this._getTemplate(options.template);
133
+ if (template) {
134
+ let result = await template.renderAll(options.template, options.replacements);
135
+ if (result.subject) {
136
+ options.subject = result.subject;
153
137
  }
154
- options.replacements.now = new Date();
155
- let template = this._getTemplate(options.template);
156
- if (template) {
157
- let result = yield template.renderAll(options.template, options.replacements);
158
- if (result.subject) {
159
- options.subject = result.subject;
160
- }
161
- if (result.html) {
162
- options.html = result.html;
163
- }
164
- if (result.text) {
165
- options.text = result.text;
166
- }
138
+ if (result.html) {
139
+ options.html = result.html;
167
140
  }
168
- else {
169
- throw Error("Unknown mail template");
141
+ if (result.text) {
142
+ options.text = result.text;
170
143
  }
171
144
  }
172
- return this._transporter.sendMail(options, callback);
173
- });
145
+ else {
146
+ throw Error("Unknown mail template");
147
+ }
148
+ }
149
+ return this._transporter.sendMail(options, callback);
174
150
  }
175
151
  }
176
- exports.Mailer = Mailer;
152
+ export { Mailer };
177
153
  //# sourceMappingURL=mailer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mailer.js","sourceRoot":"","sources":["../../src/services/mailer.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAyC;AACzC,yBAAyB;AACzB,yCAAyC;AACzC,6BAA6B;AAG7B,uCAAuD;AA6DvD,MAAa,gBAAiB,SAAQ,2BAAiB;IA8BrD,YAAY,MAAW;;;QACrB,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,MAAA,IAAI,CAAC,SAAS,oCAAd,IAAI,CAAC,SAAS,GAAK,aAAa,EAAC;QACjC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;YACjC,IAAI,CAAC,SAAS,IAAI,GAAG,CAAC;SACvB;QACD,MAAA,IAAI,CAAC,eAAe,oCAApB,IAAI,CAAC,eAAe,GAAK,UAAU,EAAC;QACpC,MAAA,IAAI,CAAC,oBAAoB,oCAAzB,IAAI,CAAC,oBAAoB,GAAK,EAAE,EAAC;QACjC,YAAA,IAAI,CAAC,oBAAoB,EAAC,cAAc,uCAAd,cAAc,GAAK,EAAE,EAAC;QAChD,YAAA,IAAI,CAAC,oBAAoB,CAAC,cAAc,EAAC,YAAY,uCAAZ,YAAY,GAAK,EAAE,EAAC;QAC7D,YAAA,IAAI,CAAC,oBAAoB,CAAC,cAAc,CAAC,YAAY,EAAC,UAAU,uCAAV,UAAU,GAAK,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,EAAC;IACpG,CAAC;CACF;AA1CD,4CA0CC;AAED,MAAsB,cACpB,SAAQ,iBAAU;IAYlB;;;;OAIG;IACG,qBAAqB,CAAC,IAAkB;;YAC5C,OAAO,IAAI,CAAC,QAAQ,EAAE,KAAK,IAAI,CAAC;QAClC,CAAC;K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D,CAAC,CAAC;YAC3E,OAAO,OAAO,CAAC,MAAM,CAAC,gDAAgD,CAAC,CAAC;SACzE;QACD,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE;YACjB,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;SACvC;QACD,IAAI,OAAO,CAAC,QAAQ,EAAE;YACpB,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE;gBACzB,OAAO,CAAC,YAAY,GAAG,EAAE,CAAC;aAC3B;YACD,OAAO,CAAC,YAAY,CAAC,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;YACtC,IAAI,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YACnD,IAAI,QAAQ,EAAE;gBACZ,IAAI,MAAM,GAAG,MAAM,QAAQ,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;gBAC9E,IAAI,MAAM,CAAC,OAAO,EAAE;oBAClB,OAAO,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;iBAClC;gBACD,IAAI,MAAM,CAAC,IAAI,EAAE;oBACf,OAAO,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;iBAC5B;gBACD,IAAI,MAAM,CAAC,IAAI,EAAE;oBACf,OAAO,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;iBAC5B;aACF;iBAAM;gBACL,MAAM,KAAK,CAAC,uBAAuB,CAAC,CAAC;aACtC;SACF;QACD,OAAO,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACvD,CAAC;CACF;AAED,OAAO,EAAE,MAAM,EAAgC,CAAC"}
@@ -5,63 +5,45 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  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;
6
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
7
  };
8
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
9
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
10
- return new (P || (P = Promise))(function (resolve, reject) {
11
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
12
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
13
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
14
- step((generator = generator.apply(thisArg, _arguments || [])).next());
15
- });
16
- };
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- const mocha_1 = require("@testdeck/mocha");
19
- const assert = require("assert");
20
- const sinon = require("sinon");
21
- const __1 = require("..");
22
- const test_1 = require("../test");
23
- const mailer_1 = require("./mailer");
24
- let MailerTest = class MailerTest extends test_1.WebdaTest {
25
- before() {
26
- const _super = Object.create(null, {
27
- before: { get: () => super.before }
28
- });
29
- return __awaiter(this, void 0, void 0, function* () {
30
- yield _super.before.call(this);
31
- this.lastLevel = this.lastInfo = this.lastOptions = this.lastCallback = undefined;
32
- this.ctx = yield this.newContext();
33
- this.mailer = this.getService("TrueMailer");
34
- // Mocking the transporter
35
- this.mailer._transporter = {};
36
- this.mailer._transporter.sendMail = (options, callback) => {
37
- this.lastOptions = options;
38
- this.lastCallback = callback;
39
- return Promise.resolve();
40
- };
41
- // Mocking the logger
42
- this.mailer._webda.log = (level, ...args) => {
43
- this.lastLevel = level;
44
- this.lastInfo = args;
45
- };
46
- });
8
+ import { suite, test } from "@testdeck/mocha";
9
+ import * as assert from "assert";
10
+ import * as sinon from "sinon";
11
+ import { MailerParameters, User } from "...js";
12
+ import { WebdaTest } from "../test.js";
13
+ let MailerTest = class MailerTest extends WebdaTest {
14
+ async before() {
15
+ await super.before();
16
+ this.lastLevel = this.lastInfo = this.lastOptions = this.lastCallback = undefined;
17
+ this.ctx = await this.newContext();
18
+ this.mailer = this.getService("TrueMailer");
19
+ // Mocking the transporter
20
+ this.mailer._transporter = {};
21
+ this.mailer._transporter.sendMail = (options, callback) => {
22
+ this.lastOptions = options;
23
+ this.lastCallback = callback;
24
+ return Promise.resolve();
25
+ };
26
+ // Mocking the logger
27
+ this.mailer._webda.log = (level, ...args) => {
28
+ this.lastLevel = level;
29
+ this.lastInfo = args;
30
+ };
47
31
  }
48
32
  params() {
49
- let params = new __1.MailerParameters({ templates: "ts", templatesEngine: "b" });
33
+ let params = new MailerParameters({ templates: "ts", templatesEngine: "b" });
50
34
  assert.strictEqual(params.templates, "ts/");
51
35
  assert.strictEqual(params.templatesEngine, "b");
52
36
  }
53
- unknownTemplate() {
54
- return __awaiter(this, void 0, void 0, function* () {
55
- this.mailer._getTemplate("plop");
56
- assert.strictEqual(this.lastLevel, "WARN");
57
- assert.strictEqual(this.lastInfo[0], "No template found for");
58
- assert.strictEqual(this.lastInfo[1], "plop");
59
- yield assert.rejects(() => this.mailer.send({
60
- template: "plop",
61
- from: "test@webda.io",
62
- replacements: {}
63
- }), /Unknown mail template/);
64
- });
37
+ async unknownTemplate() {
38
+ this.mailer._getTemplate("plop");
39
+ assert.strictEqual(this.lastLevel, "WARN");
40
+ assert.strictEqual(this.lastInfo[0], "No template found for");
41
+ assert.strictEqual(this.lastInfo[1], "plop");
42
+ await assert.rejects(() => this.mailer.send({
43
+ template: "plop",
44
+ from: "test@webda.io",
45
+ replacements: {}
46
+ }), /Unknown mail template/);
65
47
  }
66
48
  knownTemplate() {
67
49
  this.mailer._getTemplate("PASSPORT_EMAIL_RECOVERY");
@@ -69,109 +51,86 @@ let MailerTest = class MailerTest extends test_1.WebdaTest {
69
51
  this.mailer._getTemplate("PASSPORT_EMAIL_RECOVERY");
70
52
  assert.strictEqual(this.lastLevel, undefined);
71
53
  }
72
- knownTemplateOnSend() {
73
- return __awaiter(this, void 0, void 0, function* () {
74
- yield this.mailer.send({
75
- template: "PASSPORT_EMAIL_RECOVERY"
76
- });
77
- assert.notStrictEqual(this.lastOptions, undefined);
78
- assert.notStrictEqual(this.lastOptions.subject, undefined);
79
- assert.notStrictEqual(this.lastOptions.html, undefined);
80
- assert.notStrictEqual(this.lastOptions.text, undefined);
54
+ async knownTemplateOnSend() {
55
+ await this.mailer.send({
56
+ template: "PASSPORT_EMAIL_RECOVERY"
81
57
  });
58
+ assert.notStrictEqual(this.lastOptions, undefined);
59
+ assert.notStrictEqual(this.lastOptions.subject, undefined);
60
+ assert.notStrictEqual(this.lastOptions.html, undefined);
61
+ assert.notStrictEqual(this.lastOptions.text, undefined);
82
62
  }
83
- sendManual() {
84
- return __awaiter(this, void 0, void 0, function* () {
85
- yield this.mailer.send({ subject: "mine" });
86
- assert.notStrictEqual(this.lastOptions, undefined);
87
- assert.strictEqual(this.lastOptions.subject, "mine");
88
- });
63
+ async sendManual() {
64
+ await this.mailer.send({ subject: "mine" });
65
+ assert.notStrictEqual(this.lastOptions, undefined);
66
+ assert.strictEqual(this.lastOptions.subject, "mine");
89
67
  }
90
- templateNoResult() {
91
- return __awaiter(this, void 0, void 0, function* () {
92
- this.mailer._getTemplate = () => {
93
- return {
94
- renderAll: () => __awaiter(this, void 0, void 0, function* () {
95
- return {};
96
- })
97
- };
68
+ async templateNoResult() {
69
+ this.mailer._getTemplate = () => {
70
+ return {
71
+ renderAll: async () => {
72
+ return {};
73
+ }
98
74
  };
99
- yield this.mailer.send({ template: "mine" });
100
- assert.notStrictEqual(this.lastOptions, undefined);
101
- assert.strictEqual(this.lastOptions.subject, undefined);
102
- });
75
+ };
76
+ await this.mailer.send({ template: "mine" });
77
+ assert.notStrictEqual(this.lastOptions, undefined);
78
+ assert.strictEqual(this.lastOptions.subject, undefined);
103
79
  }
104
- computeParameters() {
105
- let mailer = new mailer_1.Mailer(this.webda, "m", { SES: {}, transport: "ses" });
106
- mailer.computeParameters();
107
- mailer = new mailer_1.Mailer(this.webda, "m", { transport: "ses" });
108
- mailer.computeParameters();
109
- mailer = new mailer_1.Mailer(this.webda, "m", { transport: "unknown" });
110
- mailer.computeParameters();
80
+ async noTransporter() {
81
+ this.mailer._transporter = undefined;
82
+ await assert.rejects(() => this.mailer.send({
83
+ template: "PASSPORT_EMAIL_RECOVERY",
84
+ from: "test@webda.io"
85
+ }), /Cannot send email as no transporter is defined/);
111
86
  }
112
- noTransporter() {
113
- return __awaiter(this, void 0, void 0, function* () {
114
- this.mailer._transporter = undefined;
115
- yield assert.rejects(() => this.mailer.send({
116
- template: "PASSPORT_EMAIL_RECOVERY",
117
- from: "test@webda.io"
118
- }), /Cannot send email as no transporter is defined/);
119
- });
87
+ async handleNotificationFor() {
88
+ const user = new User();
89
+ assert.strictEqual(await this.mailer.handleNotificationFor(user), false);
90
+ user.load({ email: "test@test.com" });
91
+ assert.strictEqual(await this.mailer.handleNotificationFor(user), true);
120
92
  }
121
- handleNotificationFor() {
122
- return __awaiter(this, void 0, void 0, function* () {
123
- const user = new __1.User();
124
- assert.strictEqual(yield this.mailer.handleNotificationFor(user), false);
93
+ async sendNotification() {
94
+ let stub = sinon.stub(this.mailer, "send").callsFake(async () => { });
95
+ try {
96
+ const user = new User();
97
+ assert.rejects(() => this.mailer.sendNotification(user, "", undefined, undefined), /Cannot find a valid email for user/);
125
98
  user.load({ email: "test@test.com" });
126
- assert.strictEqual(yield this.mailer.handleNotificationFor(user), true);
127
- });
128
- }
129
- sendNotification() {
130
- return __awaiter(this, void 0, void 0, function* () {
131
- let stub = sinon.stub(this.mailer, "send").callsFake(() => __awaiter(this, void 0, void 0, function* () { }));
132
- try {
133
- const user = new __1.User();
134
- assert.rejects(() => this.mailer.sendNotification(user, "", undefined, undefined), /Cannot find a valid email for user/);
135
- user.load({ email: "test@test.com" });
136
- yield this.mailer.sendNotification(user, "", undefined, undefined);
137
- }
138
- finally {
139
- stub.restore();
140
- }
141
- });
99
+ await this.mailer.sendNotification(user, "", undefined, undefined);
100
+ }
101
+ finally {
102
+ stub.restore();
103
+ }
142
104
  }
143
105
  };
144
106
  __decorate([
145
- mocha_1.test
107
+ test
146
108
  ], MailerTest.prototype, "params", null);
147
109
  __decorate([
148
- mocha_1.test
110
+ test
149
111
  ], MailerTest.prototype, "unknownTemplate", null);
150
112
  __decorate([
151
- mocha_1.test
113
+ test
152
114
  ], MailerTest.prototype, "knownTemplate", null);
153
115
  __decorate([
154
- mocha_1.test
116
+ test
155
117
  ], MailerTest.prototype, "knownTemplateOnSend", null);
156
118
  __decorate([
157
- mocha_1.test
119
+ test
158
120
  ], MailerTest.prototype, "sendManual", null);
159
121
  __decorate([
160
- mocha_1.test
122
+ test
161
123
  ], MailerTest.prototype, "templateNoResult", null);
162
124
  __decorate([
163
- mocha_1.test
164
- ], MailerTest.prototype, "computeParameters", null);
165
- __decorate([
166
- mocha_1.test
125
+ test
167
126
  ], MailerTest.prototype, "noTransporter", null);
168
127
  __decorate([
169
- mocha_1.test
128
+ test
170
129
  ], MailerTest.prototype, "handleNotificationFor", null);
171
130
  __decorate([
172
- mocha_1.test
131
+ test
173
132
  ], MailerTest.prototype, "sendNotification", null);
174
133
  MailerTest = __decorate([
175
- mocha_1.suite
134
+ suite
176
135
  ], MailerTest);
177
136
  //# sourceMappingURL=mailer.spec.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mailer.spec.js","sourceRoot":"","sources":["../../src/services/mailer.spec.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;AAEb,2CAA8C;AAC9C,iCAAiC;AACjC,+BAA+B;AAC/B,0BAA4C;AAC5C,kCAAoC;AAEpC,qCAAkC;AAGlC,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,gBAAS;IAO1B,MAAM;;;;;YACV,MAAM,OAAM,MAAM,WAAE,CAAC;YACrB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,YAAY,GAAG,SAAS,CAAC;YAClF,IAAI,CAAC,GAAG,GAAG,MAAM,I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E,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;SACpE;gBAAS;YACR,IAAI,CAAC,OAAO,EAAE,CAAC;SAChB;IACH,CAAC;CACF,CAAA;AAjGC;IADC,IAAI;wCAKJ;AAGD;IADC,IAAI;iDAeJ;AAED;IADC,IAAI;+CAMJ;AAED;IADC,IAAI;qDASJ;AAGD;IADC,IAAI;4CAKJ;AAGD;IADC,IAAI;kDAYJ;AAGD;IADC,IAAI;+CAWJ;AAGD;IADC,IAAI;uDAMJ;AAGD;IADC,IAAI;kDAcJ;AA3HG,UAAU;IADf,KAAK;GACA,UAAU,CA4Hf"}
@@ -1,6 +1,6 @@
1
- import { Ident } from "../models/ident";
2
- import { User } from "../models/user";
3
- import { Service, ServiceParameters } from "./service";
1
+ import { Ident } from "../models/ident.js";
2
+ import { User } from "../models/user.js";
3
+ import { Service, ServiceParameters } from "./service.js";
4
4
  /**
5
5
  * Define a service that can notify a user based on his info
6
6
  * It can use email or SMS or any other media
@@ -1,37 +1,23 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.MultiNotificationService = exports.MultiNotificationParameters = void 0;
13
- const service_1 = require("./service");
1
+ import { Service, ServiceParameters } from "./service.js";
14
2
  /**
15
3
  * Parameters for multi notification service
16
4
  */
17
- class MultiNotificationParameters extends service_1.ServiceParameters {
5
+ export class MultiNotificationParameters extends ServiceParameters {
18
6
  /**
19
7
  * @override
20
8
  */
21
9
  constructor(params) {
22
- var _a;
23
10
  super(params);
24
- (_a = this.senders) !== null && _a !== void 0 ? _a : (this.senders = []);
11
+ this.senders ?? (this.senders = []);
25
12
  }
26
13
  }
27
- exports.MultiNotificationParameters = MultiNotificationParameters;
28
14
  /**
29
15
  * Allow an aggregation of Notification to send via multiple media
30
16
  * like SMS and Email
31
17
  *
32
18
  * @WebdaModda
33
19
  */
34
- class MultiNotificationService extends service_1.Service {
20
+ export default class MultiNotificationService extends Service {
35
21
  /**
36
22
  * @override
37
23
  */
@@ -55,39 +41,32 @@ class MultiNotificationService extends service_1.Service {
55
41
  /**
56
42
  * @override
57
43
  */
58
- sendNotification(user, notification, replacements) {
59
- return __awaiter(this, void 0, void 0, function* () {
60
- const selectedSenders = (yield Promise.all(this.senders.map((s) => __awaiter(this, void 0, void 0, function* () {
61
- if ((yield s.hasNotification(notification)) && (yield s.handleNotificationFor(user))) {
62
- return s;
63
- }
64
- })))).filter(s => s !== undefined);
65
- if (!selectedSenders.length) {
66
- return;
44
+ async sendNotification(user, notification, replacements) {
45
+ const selectedSenders = (await Promise.all(this.senders.map(async (s) => {
46
+ if ((await s.hasNotification(notification)) && (await s.handleNotificationFor(user))) {
47
+ return s;
67
48
  }
68
- if (!this.parameters.multiple) {
69
- return selectedSenders.shift().sendNotification(user, notification, replacements);
70
- }
71
- yield Promise.all(selectedSenders.map(s => s.sendNotification(user, notification, replacements)));
72
- });
49
+ }))).filter(s => s !== undefined);
50
+ if (!selectedSenders.length) {
51
+ return;
52
+ }
53
+ if (!this.parameters.multiple) {
54
+ return selectedSenders.shift().sendNotification(user, notification, replacements);
55
+ }
56
+ await Promise.all(selectedSenders.map(s => s.sendNotification(user, notification, replacements)));
73
57
  }
74
58
  /**
75
59
  * @override
76
60
  */
77
- handleNotificationFor(user) {
78
- return __awaiter(this, void 0, void 0, function* () {
79
- return (yield Promise.all(this.senders.map(s => s.handleNotificationFor(user)))).some(s => s);
80
- });
61
+ async handleNotificationFor(user) {
62
+ return (await Promise.all(this.senders.map(s => s.handleNotificationFor(user)))).some(s => s);
81
63
  }
82
64
  /**
83
65
  * @override
84
66
  */
85
- hasNotification(notification) {
86
- return __awaiter(this, void 0, void 0, function* () {
87
- return (yield Promise.all(this.senders.map(s => s.hasNotification(notification)))).some(s => s);
88
- });
67
+ async hasNotification(notification) {
68
+ return (await Promise.all(this.senders.map(s => s.hasNotification(notification)))).some(s => s);
89
69
  }
90
70
  }
91
- exports.default = MultiNotificationService;
92
- exports.MultiNotificationService = MultiNotificationService;
71
+ export { MultiNotificationService };
93
72
  //# sourceMappingURL=notificationservice.js.map