@webda/core 2.0.0-beta.2 → 2.0.1

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 (279) hide show
  1. package/lib/application.d.ts +5 -21
  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 +44 -45
  7. package/lib/core.js +239 -320
  8. package/lib/core.js.map +1 -1
  9. package/lib/core.spec.js +326 -391
  10. package/lib/core.spec.js.map +1 -1
  11. package/lib/index.d.ts +49 -45
  12. package/lib/index.js +54 -67
  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 +128 -151
  18. package/lib/models/aclmodel.spec.js.map +1 -1
  19. package/lib/models/coremodel.d.ts +39 -17
  20. package/lib/models/coremodel.js +160 -117
  21. package/lib/models/coremodel.js.map +1 -1
  22. package/lib/models/coremodel.spec.js +143 -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 -166
  34. package/lib/models/ownermodel.spec.js.map +1 -1
  35. package/lib/models/rolemodel.d.ts +2 -2
  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 -61
  39. package/lib/models/rolemodel.spec.js.map +1 -1
  40. package/lib/models/user.d.ts +9 -9
  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 +4 -4
  62. package/lib/queues/queueservice.js +52 -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 +28 -19
  75. package/lib/services/authentication.js +542 -574
  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 +9 -7
  80. package/lib/services/binary.js +213 -245
  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 +6 -3
  92. package/lib/services/configuration.js +78 -103
  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 +258 -0
  102. package/lib/services/cryptoservice.js +312 -0
  103. package/lib/services/cryptoservice.js.map +1 -0
  104. package/lib/services/cryptoservice.spec.d.ts +1 -0
  105. package/lib/services/cryptoservice.spec.js +137 -0
  106. package/lib/services/cryptoservice.spec.js.map +1 -0
  107. package/lib/services/debugmailer.d.ts +1 -1
  108. package/lib/services/debugmailer.js +13 -34
  109. package/lib/services/debugmailer.js.map +1 -1
  110. package/lib/services/debugmailer.spec.js +16 -29
  111. package/lib/services/debugmailer.spec.js.map +1 -1
  112. package/lib/services/echo.d.ts +2 -2
  113. package/lib/services/echo.js +15 -31
  114. package/lib/services/echo.js.map +1 -1
  115. package/lib/services/echo.spec.js +27 -40
  116. package/lib/services/echo.spec.js.map +1 -1
  117. package/lib/services/filebinary.d.ts +10 -5
  118. package/lib/services/filebinary.js +171 -205
  119. package/lib/services/filebinary.js.map +1 -1
  120. package/lib/services/filebinary.spec.d.ts +2 -1
  121. package/lib/services/filebinary.spec.js +106 -117
  122. package/lib/services/filebinary.spec.js.map +1 -1
  123. package/lib/services/fileconfiguration.d.ts +2 -2
  124. package/lib/services/fileconfiguration.js +25 -43
  125. package/lib/services/fileconfiguration.js.map +1 -1
  126. package/lib/services/fileconfiguration.spec.js +79 -109
  127. package/lib/services/fileconfiguration.spec.js.map +1 -1
  128. package/lib/services/invitationservice.d.ts +10 -10
  129. package/lib/services/invitationservice.js +275 -313
  130. package/lib/services/invitationservice.js.map +1 -1
  131. package/lib/services/invitationservice.spec.js +443 -449
  132. package/lib/services/invitationservice.spec.js.map +1 -1
  133. package/lib/services/kubernetesconfiguration.d.ts +2 -2
  134. package/lib/services/kubernetesconfiguration.js +41 -59
  135. package/lib/services/kubernetesconfiguration.js.map +1 -1
  136. package/lib/services/kubernetesconfiguration.spec.js +80 -98
  137. package/lib/services/kubernetesconfiguration.spec.js.map +1 -1
  138. package/lib/services/mailer.d.ts +4 -4
  139. package/lib/services/mailer.js +62 -86
  140. package/lib/services/mailer.js.map +1 -1
  141. package/lib/services/mailer.spec.js +86 -127
  142. package/lib/services/mailer.spec.js.map +1 -1
  143. package/lib/services/notificationservice.d.ts +4 -4
  144. package/lib/services/notificationservice.js +23 -42
  145. package/lib/services/notificationservice.js.map +1 -1
  146. package/lib/services/notificationservice.spec.js +47 -73
  147. package/lib/services/notificationservice.spec.js.map +1 -1
  148. package/lib/services/oauth.d.ts +32 -6
  149. package/lib/services/oauth.js +73 -78
  150. package/lib/services/oauth.js.map +1 -1
  151. package/lib/services/oauth.spec.js +128 -148
  152. package/lib/services/oauth.spec.js.map +1 -1
  153. package/lib/services/proxy.d.ts +74 -0
  154. package/lib/services/proxy.js +126 -0
  155. package/lib/services/proxy.js.map +1 -0
  156. package/lib/services/proxy.spec.d.ts +1 -0
  157. package/lib/services/proxy.spec.js +59 -0
  158. package/lib/services/proxy.spec.js.map +1 -0
  159. package/lib/services/resource.d.ts +2 -2
  160. package/lib/services/resource.js +12 -18
  161. package/lib/services/resource.js.map +1 -1
  162. package/lib/services/resource.spec.js +67 -99
  163. package/lib/services/resource.spec.js.map +1 -1
  164. package/lib/services/service.d.ts +29 -6
  165. package/lib/services/service.js +69 -39
  166. package/lib/services/service.js.map +1 -1
  167. package/lib/services/service.spec.js +62 -67
  168. package/lib/services/service.spec.js.map +1 -1
  169. package/lib/services/version.d.ts +1 -1
  170. package/lib/services/version.js +3 -8
  171. package/lib/services/version.js.map +1 -1
  172. package/lib/services/version.spec.js +11 -24
  173. package/lib/services/version.spec.js.map +1 -1
  174. package/lib/stores/aggregator.d.ts +3 -3
  175. package/lib/stores/aggregator.js +37 -57
  176. package/lib/stores/aggregator.js.map +1 -1
  177. package/lib/stores/file.d.ts +3 -3
  178. package/lib/stores/file.js +93 -131
  179. package/lib/stores/file.js.map +1 -1
  180. package/lib/stores/file.spec.d.ts +2 -2
  181. package/lib/stores/file.spec.js +262 -289
  182. package/lib/stores/file.spec.js.map +1 -1
  183. package/lib/stores/mapper.d.ts +4 -4
  184. package/lib/stores/mapper.js +111 -137
  185. package/lib/stores/mapper.js.map +1 -1
  186. package/lib/stores/mapper.spec.js +133 -150
  187. package/lib/stores/mapper.spec.js.map +1 -1
  188. package/lib/stores/memory.d.ts +67 -6
  189. package/lib/stores/memory.js +155 -117
  190. package/lib/stores/memory.js.map +1 -1
  191. package/lib/stores/memory.spec.d.ts +3 -2
  192. package/lib/stores/memory.spec.js +127 -105
  193. package/lib/stores/memory.spec.js.map +1 -1
  194. package/lib/stores/store.d.ts +40 -16
  195. package/lib/stores/store.js +847 -830
  196. package/lib/stores/store.js.map +1 -1
  197. package/lib/stores/store.spec.d.ts +6 -4
  198. package/lib/stores/store.spec.js +628 -647
  199. package/lib/stores/store.spec.js.map +1 -1
  200. package/lib/stores/webdaql/WebdaQLLexer.d.ts +4 -4
  201. package/lib/stores/webdaql/WebdaQLLexer.js +9 -13
  202. package/lib/stores/webdaql/WebdaQLLexer.js.map +1 -1
  203. package/lib/stores/webdaql/WebdaQLParserLexer.d.ts +4 -4
  204. package/lib/stores/webdaql/WebdaQLParserLexer.js +9 -13
  205. package/lib/stores/webdaql/WebdaQLParserLexer.js.map +1 -1
  206. package/lib/stores/webdaql/WebdaQLParserListener.d.ts +2 -2
  207. package/lib/stores/webdaql/WebdaQLParserListener.js +1 -2
  208. package/lib/stores/webdaql/WebdaQLParserListener.js.map +1 -1
  209. package/lib/stores/webdaql/WebdaQLParserParser.d.ts +10 -10
  210. package/lib/stores/webdaql/WebdaQLParserParser.js +62 -91
  211. package/lib/stores/webdaql/WebdaQLParserParser.js.map +1 -1
  212. package/lib/stores/webdaql/WebdaQLParserVisitor.d.ts +2 -2
  213. package/lib/stores/webdaql/WebdaQLParserVisitor.js +1 -2
  214. package/lib/stores/webdaql/WebdaQLParserVisitor.js.map +1 -1
  215. package/lib/stores/webdaql/query.d.ts +4 -5
  216. package/lib/stores/webdaql/query.js +16 -19
  217. package/lib/stores/webdaql/query.js.map +1 -1
  218. package/lib/stores/webdaql/query.spec.js +30 -32
  219. package/lib/stores/webdaql/query.spec.js.map +1 -1
  220. package/lib/test.d.ts +3 -3
  221. package/lib/test.js +74 -94
  222. package/lib/test.js.map +1 -1
  223. package/lib/unpackedapplication.d.ts +1 -1
  224. package/lib/unpackedapplication.js +44 -38
  225. package/lib/unpackedapplication.js.map +1 -1
  226. package/lib/utils/abstractdeployer.js +1 -5
  227. package/lib/utils/abstractdeployer.js.map +1 -1
  228. package/lib/utils/abstractdeployer.spec.js +6 -8
  229. package/lib/utils/abstractdeployer.spec.js.map +1 -1
  230. package/lib/utils/context.d.ts +61 -29
  231. package/lib/utils/context.js +133 -127
  232. package/lib/utils/context.js.map +1 -1
  233. package/lib/utils/context.spec.js +144 -153
  234. package/lib/utils/context.spec.js.map +1 -1
  235. package/lib/utils/cookie.d.ts +66 -45
  236. package/lib/utils/cookie.js +69 -158
  237. package/lib/utils/cookie.js.map +1 -1
  238. package/lib/utils/cookie.spec.js +220 -238
  239. package/lib/utils/cookie.spec.js.map +1 -1
  240. package/lib/utils/esm.d.ts +4 -0
  241. package/lib/utils/esm.js +10 -0
  242. package/lib/utils/esm.js.map +1 -0
  243. package/lib/utils/httpcontext.d.ts +3 -0
  244. package/lib/utils/httpcontext.js +48 -65
  245. package/lib/utils/httpcontext.js.map +1 -1
  246. package/lib/utils/httpcontext.spec.js +37 -56
  247. package/lib/utils/httpcontext.spec.js.map +1 -1
  248. package/lib/utils/logger.d.ts +2 -2
  249. package/lib/utils/logger.js +15 -28
  250. package/lib/utils/logger.js.map +1 -1
  251. package/lib/utils/logger.spec.js +9 -11
  252. package/lib/utils/logger.spec.js.map +1 -1
  253. package/lib/utils/serializers.js +17 -20
  254. package/lib/utils/serializers.js.map +1 -1
  255. package/lib/utils/serializers.spec.js +43 -44
  256. package/lib/utils/serializers.spec.js.map +1 -1
  257. package/lib/utils/session.d.ts +120 -0
  258. package/lib/utils/session.js +155 -0
  259. package/lib/utils/session.js.map +1 -0
  260. package/lib/utils/session.spec.d.ts +1 -0
  261. package/lib/utils/session.spec.js +66 -0
  262. package/lib/utils/session.spec.js.map +1 -0
  263. package/lib/utils/waiter.d.ts +1 -1
  264. package/lib/utils/waiter.js +32 -52
  265. package/lib/utils/waiter.js.map +1 -1
  266. package/lib/utils/waiter.spec.js +75 -92
  267. package/lib/utils/waiter.spec.js.map +1 -1
  268. package/package.json +22 -14
  269. package/test/config-invitation.json +1 -3
  270. package/test/config.json +3 -3
  271. package/test/config.old.json +1 -2
  272. package/test/moddas/annotatedservice.js +5 -5
  273. package/test/moddas/debugmailer.js +2 -3
  274. package/test/moddas/fakeservice.js +2 -3
  275. package/test/moddas/voidstore.js +6 -4
  276. package/test/models/ident.js +2 -6
  277. package/test/models/task.js +3 -7
  278. package/test/package.json +2 -1
  279. package/webda.module.json +895 -189
@@ -1,35 +1,21 @@
1
- "use strict";
2
1
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
2
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
3
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
4
  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
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
6
  };
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 assert = require("assert");
19
- const mocha_1 = require("@testdeck/mocha");
20
- const path = require("path");
21
- const index_1 = require("./index");
22
- const test_1 = require("./test");
23
- let ApplicationTest = class ApplicationTest extends test_1.WebdaTest {
24
- before() {
25
- const _super = Object.create(null, {
26
- before: { get: () => super.before }
27
- });
28
- return __awaiter(this, void 0, void 0, function* () {
29
- yield _super.before.call(this);
30
- this.sampleApp = new test_1.TestApplication(path.join(__dirname, "..", "..", "..", "sample-app"));
31
- yield this.sampleApp.load();
32
- });
7
+ import { suite, test } from "@testdeck/mocha";
8
+ import * as assert from "assert";
9
+ import * as path from "path";
10
+ import { Application, UnpackedApplication } from "./index.js";
11
+ import { TestApplication, WebdaTest } from "./test.js";
12
+ import { getCommonJS } from "./utils/esm.js";
13
+ const { __dirname } = getCommonJS(import.meta.url);
14
+ let ApplicationTest = class ApplicationTest extends WebdaTest {
15
+ async before() {
16
+ await super.before();
17
+ this.sampleApp = new TestApplication(path.join(__dirname, "..", "..", "..", "sample-app"));
18
+ await this.sampleApp.load();
33
19
  }
34
20
  testObjectParameter() {
35
21
  assert.deepStrictEqual(this.sampleApp.replaceVariables({
@@ -67,145 +53,140 @@ let ApplicationTest = class ApplicationTest extends test_1.WebdaTest {
67
53
  getConfiguration() {
68
54
  let config = this.sampleApp.getConfiguration();
69
55
  }
70
- cacheSchema() {
71
- return __awaiter(this, void 0, void 0, function* () {
72
- let app = new index_1.Application(__dirname + "/../test/config.json");
73
- yield app.load();
74
- // Should load from cache
75
- assert.notStrictEqual(app.getSchema("WebdaTest/Mailer"), undefined);
76
- assert.strictEqual(app.getSchema("Webda/Container"), undefined);
77
- // Check if cached just use cache
78
- // @ts-ignore
79
- app.baseConfiguration.cachedModules = {
80
- schemas: {
81
- // @ts-ignore
82
- fake: 666
83
- }
84
- };
85
- assert.strictEqual(app.getSchema("fake"), 666);
86
- });
56
+ async cacheSchema() {
57
+ let app = new Application(__dirname + "/../test/config.json");
58
+ await app.load();
59
+ // Should load from cache
60
+ assert.notStrictEqual(app.getSchema("WebdaTest/Mailer"), undefined);
61
+ assert.strictEqual(app.getSchema("Webda/Container"), undefined);
62
+ // Check if cached just use cache
63
+ // @ts-ignore
64
+ app.baseConfiguration.cachedModules = {
65
+ schemas: {
66
+ // @ts-ignore
67
+ fake: 666
68
+ }
69
+ };
70
+ assert.strictEqual(app.getSchema("fake"), 666);
87
71
  }
88
- cov() {
89
- return __awaiter(this, void 0, void 0, function* () {
90
- assert.throws(() => new index_1.Application("/notexisting"), /Not a webda application folder or webda.config.jsonc or webda.config.json file: unexisting.*/);
91
- yield assert.rejects(() => new index_1.Application(__dirname + "/../test/moddas").load(), /Not a webda application folder or webda.config.jsonc or webda.config.json file: .*/);
92
- yield assert.rejects(() => new index_1.Application(__dirname + "/../test/badapp").load(), /Cannot parse JSON of: .*/);
93
- // If allow module is enable the Application should let run anywhere
94
- new index_1.Application(__dirname + "/../test/moddas", undefined);
95
- let unpackedApp = new index_1.UnpackedApplication(__dirname + "/../test/badapp", undefined);
96
- unpackedApp.loadProjectInformation();
97
- // Read cached modules
98
- let app = new index_1.Application(__dirname + "/../test/cachedapp", undefined);
99
- yield app.load();
100
- app.getGitInformation();
101
- // No package.json should not fail although more than abnormal
102
- app = new test_1.TestApplication(__dirname + "/../test/config.json");
103
- yield app.load();
104
- assert.ok(!app.extends(null, String));
105
- app.getPackageWebda();
106
- assert.throws(() => app.getModda("Unknown"), /Undefined modda Unknown/);
107
- app.getDeployers();
108
- app.getModules();
109
- app.getBeans();
110
- // Alternative of files
111
- // @ts-ignore
112
- app.getPackageDescription.files = undefined;
113
- // Nothing can be really checked here
114
- app.addModel("WebdaTest/NotExisting", null);
115
- app.addDeployer("WebdaTest/NotExisting", null);
116
- delete app.getModels()["webdatest/notexisting"];
117
- assert.deepStrictEqual(app.getGitInformation(), {
118
- branch: "",
119
- commit: "",
120
- short: "",
121
- tag: "",
122
- tags: [],
123
- version: ""
124
- });
125
- assert.strictEqual(app.isCached(), true);
126
- assert.strictEqual(app.getCurrentDeployment(), "");
127
- assert.strictEqual(app.replaceVariables("hello", {}), "hello");
128
- assert.strictEqual(app.replaceVariables("hello ${test} ${test2}", {}), "hello undefined undefined");
129
- assert.throws(() => app.replaceVariables("hello ${now && process.exit(666)}", {}), /Variable cannot use every javascript features/);
130
- assert.throws(() => app.replaceVariables("hello ${test} ${{ test}", {}), /Variable cannot use every javascript features/);
131
- assert.throws(() => app.replaceVariables("hello " + "${test}".repeat(12), {}), /Too many variables/);
132
- unpackedApp = new index_1.UnpackedApplication(__dirname + "/../test/moddas", undefined);
133
- yield unpackedApp.load();
72
+ async cov() {
73
+ assert.throws(() => new Application("/notexisting"), /Not a webda application folder or webda.config.jsonc or webda.config.json file: unexisting.*/);
74
+ await assert.rejects(() => new Application(__dirname + "/../test/moddas").load(), /Not a webda application folder or webda.config.jsonc or webda.config.json file: .*/);
75
+ await assert.rejects(() => new Application(__dirname + "/../test/badapp").load(), /Cannot parse JSON of: .*/);
76
+ // If allow module is enable the Application should let run anywhere
77
+ new Application(__dirname + "/../test/moddas", undefined);
78
+ let unpackedApp = new UnpackedApplication(__dirname + "/../test/badapp", undefined);
79
+ unpackedApp.loadProjectInformation();
80
+ // Read cached modules
81
+ let app = new Application(__dirname + "/../test/cachedapp", undefined);
82
+ await app.load();
83
+ app.getGitInformation();
84
+ // No package.json should not fail although more than abnormal
85
+ app = new TestApplication(__dirname + "/../test/config.json");
86
+ await app.load();
87
+ assert.ok(!app.extends(null, String));
88
+ app.getPackageWebda();
89
+ assert.throws(() => app.getModda("Unknown"), /Undefined modda Unknown/);
90
+ app.getDeployers();
91
+ app.getModules();
92
+ app.getBeans();
93
+ // Alternative of files
94
+ // @ts-ignore
95
+ app.getPackageDescription.files = undefined;
96
+ // Nothing can be really checked here
97
+ app.addModel("WebdaTest/NotExisting", null);
98
+ app.addDeployer("WebdaTest/NotExisting", null);
99
+ delete app.getModels()["webdatest/notexisting"];
100
+ assert.deepStrictEqual(app.getGitInformation(), {
101
+ branch: "",
102
+ commit: "",
103
+ short: "",
104
+ tag: "",
105
+ tags: [],
106
+ version: ""
134
107
  });
108
+ assert.strictEqual(app.isCached(), true);
109
+ assert.strictEqual(app.getCurrentDeployment(), "");
110
+ assert.strictEqual(app.replaceVariables("hello", {}), "hello");
111
+ assert.strictEqual(app.replaceVariables("hello ${test} ${test2}", {}), "hello undefined undefined");
112
+ assert.throws(() => app.replaceVariables("hello ${now && process.exit(666)}", {}), /Variable cannot use every javascript features/);
113
+ assert.throws(() => app.replaceVariables("hello ${test} ${{ test}", {}), /Variable cannot use every javascript features/);
114
+ assert.throws(() => app.replaceVariables("hello " + "${test}".repeat(12), {}), /Too many variables/);
115
+ unpackedApp = new UnpackedApplication(__dirname + "/../test/moddas", undefined);
116
+ await unpackedApp.load();
117
+ // @ts-ignore
118
+ unpackedApp.baseConfiguration.cachedModules.project.webda = undefined;
119
+ assert.deepStrictEqual(unpackedApp.getPackageWebda(), { namespace: "Webda" });
135
120
  }
136
- getFullNameFromPrototype() {
137
- return __awaiter(this, void 0, void 0, function* () {
138
- let app = new test_1.TestApplication(__dirname + "/../test/config.json");
139
- yield app.load();
140
- let services = app.getModdas();
141
- let name = Object.keys(services).pop();
142
- let service = services[name].prototype;
143
- assert.strictEqual(app.getFullNameFromPrototype(service), name);
144
- // Cheat for deployer
145
- services = app.getModels();
146
- name = Object.keys(services).pop();
147
- service = services[name].prototype;
148
- app.addDeployer("Plop/Test", services[name]);
149
- assert.strictEqual(app.getFullNameFromPrototype(service), "plop/test");
150
- });
121
+ async getFullNameFromPrototype() {
122
+ let app = new TestApplication(__dirname + "/../test/config.json");
123
+ await app.load();
124
+ let services = app.getModdas();
125
+ let name = Object.keys(services).pop();
126
+ let service = services[name].prototype;
127
+ assert.strictEqual(app.getFullNameFromPrototype(service), name);
128
+ // Cheat for deployer
129
+ services = app.getModels();
130
+ name = Object.keys(services).pop();
131
+ service = services[name].prototype;
132
+ app.addDeployer("Plop/Test", services[name]);
133
+ assert.strictEqual(app.getFullNameFromPrototype(service), "plop/test");
151
134
  }
152
- loadModule() {
153
- return __awaiter(this, void 0, void 0, function* () {
154
- let app = new index_1.Application(__dirname + "/../test/config.json");
155
- yield app.loadModule({
156
- moddas: {
157
- Test: "moddas/fakeservice.js",
158
- ReTest: "./notFound.js"
159
- },
160
- models: {
161
- ReTest: "notFound.js"
162
- },
163
- deployers: {
164
- ReTest: "notFound.js"
165
- }
166
- }, "");
167
- yield app.loadModule({});
168
- yield app.importFile("./../test/moddas/fakeservice.js");
169
- let cwd = process.cwd();
170
- try {
171
- // Check loading of aws module
172
- process.chdir(path.join(__dirname, "..", "..", "aws"));
173
- yield app.loadLocalModule();
135
+ async loadModule() {
136
+ let app = new Application(__dirname + "/../test/config.json");
137
+ await app.loadModule({
138
+ moddas: {
139
+ Test: "moddas/fakeservice.js",
140
+ ReTest: "./notFound.js"
141
+ },
142
+ models: {
143
+ ReTest: "notFound.js"
144
+ },
145
+ deployers: {
146
+ ReTest: "notFound.js"
174
147
  }
175
- finally {
176
- process.chdir(cwd);
177
- }
178
- });
148
+ }, "");
149
+ await app.loadModule({});
150
+ await app.importFile("./../test/moddas/fakeservice.js");
151
+ let cwd = process.cwd();
152
+ try {
153
+ // Check loading of aws module
154
+ process.chdir(path.join(__dirname, "..", "..", "aws"));
155
+ await app.loadLocalModule();
156
+ }
157
+ finally {
158
+ process.chdir(cwd);
159
+ }
179
160
  }
180
161
  };
181
162
  __decorate([
182
- mocha_1.test
163
+ test
183
164
  ], ApplicationTest.prototype, "testObjectParameter", null);
184
165
  __decorate([
185
- mocha_1.test
166
+ test
186
167
  ], ApplicationTest.prototype, "configurationImports", null);
187
168
  __decorate([
188
- mocha_1.test
169
+ test
189
170
  ], ApplicationTest.prototype, "testStringParameter", null);
190
171
  __decorate([
191
- mocha_1.test
172
+ test
192
173
  ], ApplicationTest.prototype, "getAppPath", null);
193
174
  __decorate([
194
- mocha_1.test
175
+ test
195
176
  ], ApplicationTest.prototype, "getConfiguration", null);
196
177
  __decorate([
197
- mocha_1.test
178
+ test
198
179
  ], ApplicationTest.prototype, "cacheSchema", null);
199
180
  __decorate([
200
- mocha_1.test
181
+ test
201
182
  ], ApplicationTest.prototype, "cov", null);
202
183
  __decorate([
203
- mocha_1.test
184
+ test
204
185
  ], ApplicationTest.prototype, "getFullNameFromPrototype", null);
205
186
  __decorate([
206
- mocha_1.test
187
+ test
207
188
  ], ApplicationTest.prototype, "loadModule", null);
208
189
  ApplicationTest = __decorate([
209
- mocha_1.suite
190
+ suite
210
191
  ], ApplicationTest);
211
192
  //# sourceMappingURL=application.spec.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"application.spec.js","sourceRoot":"","sources":["../src/application.spec.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,iCAAiC;AAEjC,2CAA8C;AAC9C,6BAA6B;AAC7B,mCAA2D;AAC3D,iCAAoD;AAGpD,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,gBAAS;IAG/B,MAAM;;;;;YACV,MAAM,OAAM,MAAM,WAAE,CAAC;YACrB,IAAI,CAAC,SAAS,GAAG,IAAI,sBAAe,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EA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aAAa;aACtB;SACF,EACD,EAAE,CACH,CAAC;QACF,MAAM,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;QACzB,MAAM,GAAG,CAAC,UAAU,CAAC,iCAAiC,CAAC,CAAC;QACxD,IAAI,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;QACxB,IAAI;YACF,8BAA8B;YAC9B,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;YACvD,MAAM,GAAG,CAAC,eAAe,EAAE,CAAC;SAC7B;gBAAS;YACR,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;SACpB;IACH,CAAC;CACF,CAAA;AAxLC;IADC,IAAI;0DAuBJ;AAGD;IADC,IAAI;2DAKJ;AAGD;IADC,IAAI;0DAUJ;AAGD;IADC,IAAI;iDAIJ;AAGD;IADC,IAAI;uDAGJ;AAGD;IADC,IAAI;kDAgBJ;AAGD;IADC,IAAI;0CAiEJ;AAGD;IADC,IAAI;+DAcJ;AAGD;IADC,IAAI;iDA4BJ;AAjMG,eAAe;IADpB,KAAK;GACA,eAAe,CAkMpB"}
package/lib/core.d.ts CHANGED
@@ -1,13 +1,31 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  import { WorkerLogLevel, WorkerOutput } from "@webda/workout";
3
- import Ajv from "ajv";
4
+ import Ajv, { ErrorObject } from "ajv";
4
5
  import * as events from "events";
5
6
  import { OpenAPIV3 } from "openapi-types";
6
- import * as vm from "vm";
7
- import { Application, Configuration } from "./application";
8
- import { Context, HttpContext, Logger, Service } from "./index";
9
- import { CoreModel, CoreModelDefinition } from "./models/coremodel";
10
- import { OpenAPIWebdaDefinition, RouteInfo, Router } from "./router";
7
+ import { Writable } from "stream";
8
+ import { Application, Configuration } from "./application.js";
9
+ import { Context, HttpContext, Logger, Service, Store } from "./index.js";
10
+ import { Constructor, CoreModel, CoreModelDefinition } from "./models/coremodel.js";
11
+ import { RouteInfo, Router } from "./router.js";
12
+ import CryptoService from "./services/cryptoservice.js";
13
+ /**
14
+ * Copy from https://github.com/ajv-validator/ajv/blob/master/lib/runtime/validation_error.ts
15
+ * It is not exported by ajv
16
+ */
17
+ export declare class ValidationError extends Error {
18
+ readonly errors: Partial<ErrorObject>[];
19
+ readonly ajv: true;
20
+ readonly validation: true;
21
+ constructor(errors: Partial<ErrorObject>[]);
22
+ }
23
+ /**
24
+ *
25
+ */
26
+ export declare class RegistryEntry extends CoreModel {
27
+ [key: string]: any;
28
+ }
11
29
  /**
12
30
  * Error with a code
13
31
  */
@@ -67,7 +85,6 @@ export declare class WebsiteOriginFilter implements RequestFilter<Context> {
67
85
  checkRequest(context: Context): Promise<boolean>;
68
86
  }
69
87
  export declare function Bean(constructor: Function): void;
70
- export declare function Route(route: string, methods?: string | string[], allowPath?: boolean, openapi?: OpenAPIWebdaDefinition): (target: any, executor: string) => void;
71
88
  export declare type CoreEvents = {
72
89
  /**
73
90
  * Emitted when new result is sent
@@ -200,6 +217,14 @@ export declare class Core<E extends CoreEvents = CoreEvents> extends events.Even
200
217
  * Store the instance id
201
218
  */
202
219
  private instanceId;
220
+ /**
221
+ * Application registry
222
+ */
223
+ protected registry: Store<RegistryEntry>;
224
+ /**
225
+ * Manage encryption within the application
226
+ */
227
+ protected cryptoService: CryptoService;
203
228
  /**
204
229
  * @params {Object} config - The configuration Object, if undefined will load the configuration file
205
230
  */
@@ -224,10 +249,6 @@ export declare class Core<E extends CoreEvents = CoreEvents> extends events.Even
224
249
  * @returns
225
250
  */
226
251
  getAppPath(subpath?: string): string;
227
- /**
228
- * Reinit the @Route
229
- */
230
- reinitResolvedRoutes(): void;
231
252
  /**
232
253
  * Retrieve all detected modules definition
233
254
  */
@@ -271,12 +292,6 @@ export declare class Core<E extends CoreEvents = CoreEvents> extends events.Even
271
292
  * @param filter
272
293
  */
273
294
  registerCORSFilter(filter: RequestFilter<Context>): void;
274
- /**
275
- *
276
- * @param {Object} executor The executor to expose as executor
277
- * @param {String} code to execute
278
- */
279
- sandbox(code: any, context?: vm.Context): any;
280
295
  /**
281
296
  * Validate the object with schema
282
297
  *
@@ -360,29 +375,7 @@ export declare class Core<E extends CoreEvents = CoreEvents> extends events.Even
360
375
  *
361
376
  * @param {String} name The model name to retrieve
362
377
  */
363
- getModel(name: any): any;
364
- /**
365
- * This should return a "turning" secret with cache and a service to modify it every x mins
366
- * WARNING The security is lower without this "turning" secret, you can still set the global.secret parameter
367
- *
368
- * Dont rely on this method, it will probably disapear to avoid secret leak
369
- *
370
- * @deprecated
371
- * @returns {String} Current secret
372
- */
373
- getSecret(): string;
374
- /**
375
- * Retrieve a HMAC for a string
376
- * @param data
377
- * @returns
378
- */
379
- getHmac(data: string): Promise<string>;
380
- /**
381
- * Return a salt to use when doing digest
382
- *
383
- * @returns {String} Current salt
384
- */
385
- getSalt(): string;
378
+ getModel<T = any>(name: any): Constructor<T> | CoreModelDefinition;
386
379
  /**
387
380
  * Add to context information and executor based on the http context
388
381
  */
@@ -440,6 +433,16 @@ export declare class Core<E extends CoreEvents = CoreEvents> extends events.Even
440
433
  * @param obj service get setter from
441
434
  */
442
435
  protected _getSetters(obj: any): any[];
436
+ /**
437
+ * A registry is a predefined store
438
+ * @returns
439
+ */
440
+ getRegistry(): Store<RegistryEntry>;
441
+ /**
442
+ * Return the crypto service
443
+ * @returns
444
+ */
445
+ getCrypto(): CryptoService;
443
446
  /**
444
447
  * Auto connect services with setters
445
448
  */
@@ -449,10 +452,6 @@ export declare class Core<E extends CoreEvents = CoreEvents> extends events.Even
449
452
  * Init services and Beans along with Routes
450
453
  */
451
454
  initStatics(): void;
452
- /**
453
- * Init Routes declare by @Route annotation
454
- */
455
- initBeanRoutes(serviceBean: Service): void;
456
455
  /**
457
456
  * Create a new context for a request
458
457
  *
@@ -461,7 +460,7 @@ export declare class Core<E extends CoreEvents = CoreEvents> extends events.Even
461
460
  * @param stream - The request output stream if any
462
461
  * @return A new context object to pass along
463
462
  */
464
- newContext<T extends Context>(httpContext: HttpContext, stream?: any, noInit?: boolean): Promise<T>;
463
+ newContext<T extends Context>(httpContext: HttpContext, stream?: Writable, noInit?: boolean): Promise<T>;
465
464
  /**
466
465
  * Convert an object to JSON using the Webda json filter
467
466
  *