@webda/core 1.6.0-beta.1 → 2.0.0-beta.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 (232) hide show
  1. package/lib/application.d.ts +317 -195
  2. package/lib/application.js +171 -674
  3. package/lib/application.js.map +1 -1
  4. package/lib/application.spec.js +97 -289
  5. package/lib/application.spec.js.map +1 -1
  6. package/lib/core.d.ts +102 -214
  7. package/lib/core.js +146 -70
  8. package/lib/core.js.map +1 -1
  9. package/lib/core.spec.js +80 -17
  10. package/lib/core.spec.js.map +1 -1
  11. package/lib/index.d.ts +14 -9
  12. package/lib/index.js +19 -10
  13. package/lib/index.js.map +1 -1
  14. package/lib/models/aclmodel.d.ts +29 -8
  15. package/lib/models/aclmodel.js +68 -18
  16. package/lib/models/aclmodel.js.map +1 -1
  17. package/lib/models/aclmodel.spec.js +56 -19
  18. package/lib/models/aclmodel.spec.js.map +1 -1
  19. package/lib/models/coremodel.d.ts +9 -17
  20. package/lib/models/coremodel.js +36 -36
  21. package/lib/models/coremodel.js.map +1 -1
  22. package/lib/models/ident.d.ts +8 -3
  23. package/lib/models/ident.js +8 -1
  24. package/lib/models/ident.js.map +1 -1
  25. package/lib/models/ident.spec.js +3 -0
  26. package/lib/models/ident.spec.js.map +1 -1
  27. package/lib/models/ownermodel.d.ts +8 -4
  28. package/lib/models/ownermodel.js +10 -6
  29. package/lib/models/ownermodel.js.map +1 -1
  30. package/lib/models/rolemodel.js.map +1 -1
  31. package/lib/models/rolemodel.spec.js +4 -1
  32. package/lib/models/rolemodel.spec.js.map +1 -1
  33. package/lib/models/user.d.ts +32 -3
  34. package/lib/models/user.js +31 -0
  35. package/lib/models/user.js.map +1 -1
  36. package/lib/models/user.spec.js +11 -0
  37. package/lib/models/user.spec.js.map +1 -1
  38. package/lib/queues/filequeue.d.ts +2 -7
  39. package/lib/queues/filequeue.js +2 -11
  40. package/lib/queues/filequeue.js.map +1 -1
  41. package/lib/queues/filequeue.spec.js +0 -1
  42. package/lib/queues/filequeue.spec.js.map +1 -1
  43. package/lib/queues/memoryqueue.d.ts +2 -7
  44. package/lib/queues/memoryqueue.js +1 -11
  45. package/lib/queues/memoryqueue.js.map +1 -1
  46. package/lib/queues/memoryqueue.spec.js +0 -1
  47. package/lib/queues/memoryqueue.spec.js.map +1 -1
  48. package/lib/queues/queue.spec.d.ts +1 -1
  49. package/lib/queues/queue.spec.js +11 -9
  50. package/lib/queues/queue.spec.js.map +1 -1
  51. package/lib/queues/queueservice.js +1 -1
  52. package/lib/queues/queueservice.js.map +1 -1
  53. package/lib/router.d.ts +46 -1
  54. package/lib/router.js +89 -51
  55. package/lib/router.js.map +1 -1
  56. package/lib/router.spec.js +19 -2
  57. package/lib/router.spec.js.map +1 -1
  58. package/lib/services/asyncevents.d.ts +1 -0
  59. package/lib/services/asyncevents.js +4 -3
  60. package/lib/services/asyncevents.js.map +1 -1
  61. package/lib/services/authentication.d.ts +47 -5
  62. package/lib/services/authentication.js +99 -40
  63. package/lib/services/authentication.js.map +1 -1
  64. package/lib/services/authentication.spec.js +10 -0
  65. package/lib/services/authentication.spec.js.map +1 -1
  66. package/lib/services/binary.d.ts +126 -64
  67. package/lib/services/binary.js +247 -96
  68. package/lib/services/binary.js.map +1 -1
  69. package/lib/services/binary.spec.d.ts +1 -0
  70. package/lib/services/binary.spec.js +96 -25
  71. package/lib/services/binary.spec.js.map +1 -1
  72. package/lib/services/cloudbinary.d.ts +67 -0
  73. package/lib/services/cloudbinary.js +178 -0
  74. package/lib/services/cloudbinary.js.map +1 -0
  75. package/lib/services/cloudbinary.spec.d.ts +13 -0
  76. package/lib/services/cloudbinary.spec.js +205 -0
  77. package/lib/services/cloudbinary.spec.js.map +1 -0
  78. package/lib/services/configuration.d.ts +7 -2
  79. package/lib/services/configuration.js +4 -3
  80. package/lib/services/configuration.js.map +1 -1
  81. package/lib/services/configuration.spec.js +1 -0
  82. package/lib/services/configuration.spec.js.map +1 -1
  83. package/lib/services/cron.d.ts +5 -6
  84. package/lib/services/cron.js +4 -11
  85. package/lib/services/cron.js.map +1 -1
  86. package/lib/services/cron.spec.js +2 -3
  87. package/lib/services/cron.spec.js.map +1 -1
  88. package/lib/services/debugmailer.d.ts +11 -6
  89. package/lib/services/debugmailer.js +20 -14
  90. package/lib/services/debugmailer.js.map +1 -1
  91. package/lib/services/debugmailer.spec.js +1 -0
  92. package/lib/services/debugmailer.spec.js.map +1 -1
  93. package/lib/services/echo.d.ts +2 -6
  94. package/lib/services/echo.js +1 -11
  95. package/lib/services/echo.js.map +1 -1
  96. package/lib/services/echo.spec.js +1 -0
  97. package/lib/services/echo.spec.js.map +1 -1
  98. package/lib/services/filebinary.d.ts +36 -12
  99. package/lib/services/filebinary.js +123 -38
  100. package/lib/services/filebinary.js.map +1 -1
  101. package/lib/services/filebinary.spec.d.ts +4 -2
  102. package/lib/services/filebinary.spec.js +48 -8
  103. package/lib/services/filebinary.spec.js.map +1 -1
  104. package/lib/services/fileconfiguration.d.ts +1 -5
  105. package/lib/services/fileconfiguration.js +1 -10
  106. package/lib/services/fileconfiguration.js.map +1 -1
  107. package/lib/services/invitationservice.d.ts +198 -0
  108. package/lib/services/invitationservice.js +443 -0
  109. package/lib/services/invitationservice.js.map +1 -0
  110. package/lib/services/invitationservice.spec.d.ts +1 -0
  111. package/lib/services/invitationservice.spec.js +517 -0
  112. package/lib/services/invitationservice.spec.js.map +1 -0
  113. package/lib/services/kubernetesconfiguration.d.ts +3 -5
  114. package/lib/services/kubernetesconfiguration.js +5 -12
  115. package/lib/services/kubernetesconfiguration.js.map +1 -1
  116. package/lib/services/kubernetesconfiguration.spec.js +1 -1
  117. package/lib/services/kubernetesconfiguration.spec.js.map +1 -1
  118. package/lib/services/mailer.d.ts +44 -7
  119. package/lib/services/mailer.js +34 -14
  120. package/lib/services/mailer.js.map +1 -1
  121. package/lib/services/mailer.spec.js +29 -0
  122. package/lib/services/mailer.spec.js.map +1 -1
  123. package/lib/services/notificationservice.d.ts +76 -0
  124. package/lib/services/notificationservice.js +91 -0
  125. package/lib/services/notificationservice.js.map +1 -0
  126. package/lib/services/notificationservice.spec.d.ts +1 -0
  127. package/lib/services/notificationservice.spec.js +104 -0
  128. package/lib/services/notificationservice.spec.js.map +1 -0
  129. package/lib/services/oauth.d.ts +6 -4
  130. package/lib/services/oauth.js +28 -11
  131. package/lib/services/oauth.js.map +1 -1
  132. package/lib/services/oauth.spec.js +7 -10
  133. package/lib/services/oauth.spec.js.map +1 -1
  134. package/lib/services/resource.d.ts +1 -5
  135. package/lib/services/resource.js +22 -17
  136. package/lib/services/resource.js.map +1 -1
  137. package/lib/services/resource.spec.js +0 -1
  138. package/lib/services/resource.spec.js.map +1 -1
  139. package/lib/services/service.d.ts +29 -26
  140. package/lib/services/service.js +16 -22
  141. package/lib/services/service.js.map +1 -1
  142. package/lib/services/service.spec.js +3 -0
  143. package/lib/services/service.spec.js.map +1 -1
  144. package/lib/services/version.d.ts +2 -5
  145. package/lib/services/version.js +1 -10
  146. package/lib/services/version.js.map +1 -1
  147. package/lib/stores/aggregator.d.ts +3 -5
  148. package/lib/stores/aggregator.js +3 -10
  149. package/lib/stores/aggregator.js.map +1 -1
  150. package/lib/stores/file.d.ts +7 -8
  151. package/lib/stores/file.js +18 -18
  152. package/lib/stores/file.js.map +1 -1
  153. package/lib/stores/file.spec.js +8 -6
  154. package/lib/stores/file.spec.js.map +1 -1
  155. package/lib/stores/mapper.d.ts +1 -5
  156. package/lib/stores/mapper.js +56 -39
  157. package/lib/stores/mapper.js.map +1 -1
  158. package/lib/stores/mapper.spec.js +120 -1
  159. package/lib/stores/mapper.spec.js.map +1 -1
  160. package/lib/stores/memory.d.ts +5 -9
  161. package/lib/stores/memory.js +5 -17
  162. package/lib/stores/memory.js.map +1 -1
  163. package/lib/stores/memory.spec.d.ts +1 -0
  164. package/lib/stores/memory.spec.js +32 -0
  165. package/lib/stores/memory.spec.js.map +1 -1
  166. package/lib/stores/store.d.ts +131 -26
  167. package/lib/stores/store.js +399 -80
  168. package/lib/stores/store.js.map +1 -1
  169. package/lib/stores/store.spec.d.ts +29 -2
  170. package/lib/stores/store.spec.js +204 -31
  171. package/lib/stores/store.spec.js.map +1 -1
  172. package/lib/stores/webdaql/WebdaQLLexer.d.ts +53 -0
  173. package/lib/stores/webdaql/WebdaQLLexer.js +290 -0
  174. package/lib/stores/webdaql/WebdaQLLexer.js.map +1 -0
  175. package/lib/stores/webdaql/WebdaQLParserLexer.d.ts +53 -0
  176. package/lib/stores/webdaql/WebdaQLParserLexer.js +290 -0
  177. package/lib/stores/webdaql/WebdaQLParserLexer.js.map +1 -0
  178. package/lib/stores/webdaql/WebdaQLParserListener.d.ts +308 -0
  179. package/lib/stores/webdaql/WebdaQLParserListener.js +4 -0
  180. package/lib/stores/webdaql/WebdaQLParserListener.js.map +1 -0
  181. package/lib/stores/webdaql/WebdaQLParserParser.d.ts +301 -0
  182. package/lib/stores/webdaql/WebdaQLParserParser.js +1781 -0
  183. package/lib/stores/webdaql/WebdaQLParserParser.js.map +1 -0
  184. package/lib/stores/webdaql/WebdaQLParserVisitor.d.ts +198 -0
  185. package/lib/stores/webdaql/WebdaQLParserVisitor.js +4 -0
  186. package/lib/stores/webdaql/WebdaQLParserVisitor.js.map +1 -0
  187. package/lib/stores/webdaql/query.d.ts +300 -0
  188. package/lib/stores/webdaql/query.js +471 -0
  189. package/lib/stores/webdaql/query.js.map +1 -0
  190. package/lib/stores/webdaql/query.spec.d.ts +1 -0
  191. package/lib/stores/webdaql/query.spec.js +136 -0
  192. package/lib/stores/webdaql/query.spec.js.map +1 -0
  193. package/lib/test.d.ts +50 -2
  194. package/lib/test.js +161 -16
  195. package/lib/test.js.map +1 -1
  196. package/lib/unpackedapplication.d.ts +66 -0
  197. package/lib/unpackedapplication.js +202 -0
  198. package/lib/unpackedapplication.js.map +1 -0
  199. package/lib/utils/context.d.ts +14 -12
  200. package/lib/utils/context.js +14 -9
  201. package/lib/utils/context.js.map +1 -1
  202. package/lib/utils/context.spec.js +1 -1
  203. package/lib/utils/context.spec.js.map +1 -1
  204. package/lib/utils/cookie.d.ts +6 -3
  205. package/lib/utils/cookie.js +22 -20
  206. package/lib/utils/cookie.js.map +1 -1
  207. package/lib/utils/cookie.spec.js +0 -1
  208. package/lib/utils/cookie.spec.js.map +1 -1
  209. package/lib/utils/logger.d.ts +16 -3
  210. package/lib/utils/logger.js +16 -3
  211. package/lib/utils/logger.js.map +1 -1
  212. package/lib/utils/logger.spec.js.map +1 -1
  213. package/lib/utils/serializers.js +5 -1
  214. package/lib/utils/serializers.js.map +1 -1
  215. package/lib/utils/waiter.d.ts +1 -1
  216. package/lib/utils/waiter.js.map +1 -1
  217. package/package.json +25 -18
  218. package/test/config-file-no-reload.json +2 -1
  219. package/test/config-file-reload.json +2 -1
  220. package/test/config-invitation.json +63 -0
  221. package/test/config-kube-reload.json +2 -1
  222. package/test/config-reload.json +1 -1
  223. package/test/config.json +6 -10
  224. package/test/config.old.json +1 -1
  225. package/test/moddas/annotatedservice.js +1 -3
  226. package/test/moddas/debugmailer.js +2 -7
  227. package/test/moddas/fakeservice.js +1 -1
  228. package/test/moddas/voidstore.js +2 -4
  229. package/test/models/ident.js +1 -1
  230. package/test/models/task.js +1 -5
  231. package/webda.module.json +1124 -0
  232. package/test/config.old-default.json +0 -151
@@ -1,60 +1,27 @@
1
1
  "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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
- return c > 3 && r && Object.defineProperty(target, key, r), r;
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
+ });
7
10
  };
8
11
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.Application = exports.DefaultSchemaResolver = void 0;
10
- const child_process_1 = require("child_process");
12
+ exports.Application = exports.SectionEnum = void 0;
11
13
  const fs = require("fs");
12
- const glob = require("glob");
13
- const merge = require("merge");
14
14
  const path = require("path");
15
15
  const index_1 = require("./index");
16
16
  const workout_1 = require("@webda/workout");
17
- const abstractdeployer_1 = require("./utils/abstractdeployer");
18
- const deepmerge = require("deepmerge");
19
- const semver = require("semver");
20
- const dateFormat = require("dateformat");
21
17
  const serializers_1 = require("./utils/serializers");
22
- const echo_1 = require("./services/echo");
23
- const cron_1 = require("./services/cron");
24
- /**
25
- * Implement the default way of retrieving schema
26
- */
27
- class DefaultSchemaResolver {
28
- constructor(app) {
29
- this.app = app;
30
- }
31
- fromServiceType(type = "") {
32
- if (this.app.isCached()) {
33
- return this.app.getConfiguration().cachedModules.schemas[type];
34
- }
35
- type = type.toLowerCase();
36
- let proto = this.app.getDeployers()[type];
37
- if (proto) {
38
- return this.fromPrototype(proto);
39
- }
40
- proto = this.app.getServices()[type];
41
- if (proto) {
42
- return this.fromPrototype(proto);
43
- }
44
- proto = this.app.getModels()[type];
45
- if (proto) {
46
- return this.fromPrototype(proto);
47
- }
48
- return undefined;
49
- }
50
- fromPrototype(type) {
51
- if (type && typeof type.getSchema === "function") {
52
- return type.getSchema();
53
- }
54
- return undefined;
55
- }
56
- }
57
- exports.DefaultSchemaResolver = DefaultSchemaResolver;
18
+ var SectionEnum;
19
+ (function (SectionEnum) {
20
+ SectionEnum["Moddas"] = "moddas";
21
+ SectionEnum["Deployers"] = "deployers";
22
+ SectionEnum["Models"] = "models";
23
+ SectionEnum["Beans"] = "beans";
24
+ })(SectionEnum = exports.SectionEnum || (exports.SectionEnum = {}));
58
25
  /**
59
26
  * Map a Webda Application
60
27
  *
@@ -74,21 +41,12 @@ class Application {
74
41
  * @param {string} fileOrFolder to load Webda Application from
75
42
  * @param {Logger} logger
76
43
  */
77
- constructor(file, logger = undefined, allowModule = false) {
78
- /**
79
- * Contains all definitions from imported modules and current code
80
- */
81
- this.cachedModules = {
82
- services: {},
83
- models: {},
84
- deployers: {},
85
- sources: []
86
- };
44
+ constructor(file, logger = undefined) {
87
45
  /**
88
46
  * Contains definitions of current application
89
47
  */
90
48
  this.appModule = {
91
- services: {},
49
+ moddas: {},
92
50
  models: {},
93
51
  deployers: {}
94
52
  };
@@ -101,55 +59,13 @@ class Application {
101
59
  */
102
60
  this.deployers = {};
103
61
  /**
104
- * Services type registry
62
+ * Moddas registry
105
63
  */
106
- this.services = {
107
- // real service - modda
108
- "webda/authentication": index_1.Authentication,
109
- "webda/filestore": index_1.FileStore,
110
- "webda/memorystore": index_1.MemoryStore,
111
- "webda/filebinary": index_1.FileBinary,
112
- "webda/debugmailer": index_1.DebugMailer,
113
- "webda/mailer": index_1.Mailer,
114
- "webda/asyncevents": index_1.EventService,
115
- "webda/resourceservice": index_1.ResourceService,
116
- "webda/cronservice": cron_1.CronService,
117
- "webda/echoservice": echo_1.EchoService,
118
- "webda/versionservice": index_1.VersionService,
119
- "webda/memoryqueue": index_1.MemoryQueue,
120
- "webda/filequeue": index_1.FileQueue,
121
- "webda/configurationservice": index_1.ConfigurationService,
122
- "webda/fileconfigurationservice": index_1.FileConfigurationService,
123
- "webda/kubernetesconfigurationservice": index_1.KubernetesConfigurationService,
124
- "webda/consolelogger": index_1.ConsoleLoggerService,
125
- "webda/memorylogger": index_1.MemoryLoggerService,
126
- "webda/mapper": index_1.MapperService,
127
- "webda/aggregator": index_1.AggregatorService
128
- };
64
+ this.moddas = {};
129
65
  /**
130
66
  * Models type registry
131
67
  */
132
- this.models = {
133
- // Models
134
- "webda/coremodel": index_1.CoreModel,
135
- "webda/ident": index_1.Ident,
136
- "webda/user": index_1.User,
137
- "webdacore/context": index_1.Context,
138
- "webdacore/sessioncookie": index_1.SessionCookie,
139
- "webdacore/securecookie": index_1.SecureCookie
140
- };
141
- /**
142
- * Flag if application has been compiled already
143
- */
144
- this.compiled = false;
145
- /**
146
- * Contains package.json of application
147
- */
148
- this.packageDescription = {};
149
- /**
150
- * Contains webda section of package.json and workspaces if exist
151
- */
152
- this.packageWebda = {};
68
+ this.models = {};
153
69
  /**
154
70
  * Detect if running as workspace
155
71
  */
@@ -157,90 +73,70 @@ class Application {
157
73
  this.logger = logger || new workout_1.WorkerOutput();
158
74
  this.initTime = Date.now();
159
75
  if (!fs.existsSync(file)) {
160
- throw new index_1.WebdaError("NO_WEBDA_FOLDER", `Not a webda application folder or webda.config.json file: unexisting ${file}`);
76
+ throw new index_1.WebdaError("NO_WEBDA_FOLDER", `Not a webda application folder or webda.config.jsonc or webda.config.json file: unexisting ${file}`);
161
77
  }
162
78
  if (fs.lstatSync(file).isDirectory()) {
163
- file = path.join(file, "webda.config.json");
79
+ file = path.join(file, "webda.config.jsonc");
80
+ if (!fs.existsSync(file)) {
81
+ file = file.substring(0, file.length - 1);
82
+ }
164
83
  }
84
+ this.configurationFile = file;
85
+ this.appPath = path.dirname(file);
86
+ }
87
+ /**
88
+ * Import all required modules
89
+ */
90
+ load() {
91
+ return __awaiter(this, void 0, void 0, function* () {
92
+ this.loadConfiguration(this.configurationFile);
93
+ yield this.loadModule(this.baseConfiguration.cachedModules);
94
+ return this;
95
+ });
96
+ }
97
+ /**
98
+ * Allow subclass to implement migration
99
+ *
100
+ * @param file
101
+ * @returns
102
+ */
103
+ loadConfiguration(file) {
165
104
  // Check if file is a file or folder
166
- if (!fs.existsSync(file) && !allowModule) {
167
- throw new index_1.WebdaError("NO_WEBDA_FOLDER", `Not a webda application folder or webda.config.json file: ${file}`);
105
+ if (!fs.existsSync(file)) {
106
+ throw new index_1.WebdaError("NO_WEBDA_FOLDER", `Not a webda application folder or webda.config.jsonc or webda.config.json file: ${file}`);
168
107
  }
169
- this.appPath = path.dirname(file);
170
108
  try {
171
- this.baseConfiguration = JSON.parse(fs.readFileSync(file).toString());
172
- }
173
- catch (err) {
174
- this.log("WARN", err);
175
- if (allowModule) {
176
- this.baseConfiguration = { version: 2, module: {} };
177
- }
178
- else {
179
- throw new index_1.WebdaError("INVALID_WEBDA_CONFIG", `Cannot parse JSON of: ${file}`);
109
+ this.baseConfiguration = serializers_1.FileUtils.load(file);
110
+ if (this.baseConfiguration.version !== 3) {
111
+ this.log("ERROR", "Your configuration file should use version 3, see https://docs.webda.io/");
180
112
  }
181
113
  }
182
- // Load default schema resolver
183
- this.schemaResolver = new DefaultSchemaResolver(this);
184
- // Migrate if needed
185
- if (!this.baseConfiguration.version) {
186
- this.baseConfiguration = this.migrateV0Config(this.baseConfiguration);
187
- }
188
- if (this.baseConfiguration.version == 1) {
189
- this.baseConfiguration = this.migrateV1Config(this.baseConfiguration);
190
- }
191
- // Load if a module definition is included
192
- if (this.baseConfiguration.module) {
193
- this.loadModule(this.baseConfiguration.module, this.appPath);
194
- }
195
- // Load cached modules if there
196
- if (this.baseConfiguration.cachedModules) {
197
- this.loadModule(this.baseConfiguration.cachedModules, this.appPath);
198
- // Import all modules sources to include any annotation
199
- if (this.baseConfiguration.cachedModules.sources) {
200
- this.baseConfiguration.cachedModules.sources.forEach(src => {
201
- require(path.join(process.cwd(), src));
202
- });
203
- }
114
+ catch (err) {
115
+ throw new index_1.WebdaError("INVALID_WEBDA_CONFIG", `Cannot parse JSON of: ${file}`);
204
116
  }
205
- this.loadPackageInfos();
206
- this.namespace = this.packageDescription.webda
207
- ? this.packageDescription.webda.namespace
208
- : this.packageDescription.name | this.packageDescription.name;
209
117
  }
210
118
  /**
211
119
  *
212
120
  * @param proto Prototype to send
213
121
  */
214
122
  getFullNameFromPrototype(proto) {
215
- for (let i in this.services) {
216
- if (this.services[i].prototype === proto) {
217
- return i;
218
- }
219
- }
220
- for (let i in this.deployers) {
221
- if (this.deployers[i].prototype === proto) {
222
- return i;
223
- }
224
- }
225
- for (let i in this.models) {
226
- if (this.models[i].prototype === proto) {
227
- return i;
123
+ for (let section in SectionEnum) {
124
+ for (let i in this[SectionEnum[section]]) {
125
+ if (this[SectionEnum[section]][i] && this[SectionEnum[section]][i].prototype === proto) {
126
+ return i;
127
+ }
228
128
  }
229
129
  }
230
130
  }
231
131
  /**
232
- * Set the current schema resolver
132
+ * Get a schema from a type
233
133
  *
234
- * @param resolver
134
+ * Schema should be precomputed in the default app
135
+ * @param type
136
+ * @returns
235
137
  */
236
- setSchemaResolver(resolver) {
237
- this.schemaResolver = resolver;
238
- }
239
- /**
240
- * Get schema resolver
241
- */
242
- getSchemaResolver() {
243
- return this.schemaResolver;
138
+ getSchema(type) {
139
+ return this.baseConfiguration.cachedModules.schemas[type];
244
140
  }
245
141
  /**
246
142
  * Check if application has cached modules
@@ -250,46 +146,7 @@ class Application {
250
146
  * take the schema from the cached modules also
251
147
  */
252
148
  isCached() {
253
- return this.baseConfiguration.cachedModules !== undefined;
254
- }
255
- /**
256
- * Check package.json
257
- */
258
- loadPackageInfos() {
259
- let packageJson = path.join(this.appPath, "package.json");
260
- if (fs.existsSync(packageJson)) {
261
- this.packageDescription = JSON.parse(fs.readFileSync(packageJson).toString());
262
- }
263
- else {
264
- this.log("WARN", "Application does not have a package.json");
265
- return;
266
- }
267
- this.packageWebda = this.packageDescription.webda || {};
268
- let parent = path.join(this.appPath, "..");
269
- do {
270
- packageJson = path.join(parent, "package.json");
271
- if (fs.existsSync(packageJson)) {
272
- let info = JSON.parse(fs.readFileSync(packageJson).toString());
273
- if (info.workspaces) {
274
- this.log("DEBUG", "Application is running within a workspace");
275
- this.workspacesPath = path.resolve(parent);
276
- // Replace any relative path by absolute one
277
- for (let i in info.webda) {
278
- if (info.webda[i].startsWith("./")) {
279
- info.webda[i] = path.resolve(parent) + "/" + info.webda[i].substr(2);
280
- }
281
- }
282
- this.packageWebda = deepmerge(info.webda || {}, this.packageWebda);
283
- this.packageWebda.workspaces = {
284
- packages: info.workspaces,
285
- parent: info,
286
- path: path.resolve(parent)
287
- };
288
- return;
289
- }
290
- }
291
- parent = path.join(parent, "..");
292
- } while (path.resolve(parent) !== "/");
149
+ return true;
293
150
  }
294
151
  /**
295
152
  * Retrieve specific webda conf from package.json
@@ -297,82 +154,17 @@ class Application {
297
154
  * In case of workspaces the object is combined
298
155
  */
299
156
  getPackageWebda() {
300
- return this.packageWebda;
157
+ var _a;
158
+ return (((_a = this.baseConfiguration.cachedModules.project) === null || _a === void 0 ? void 0 : _a.webda) || {
159
+ namespace: "Webda"
160
+ });
301
161
  }
302
162
  /**
303
163
  * Retrieve content of package.json
304
164
  */
305
165
  getPackageDescription() {
306
- return this.packageDescription;
307
- }
308
- /**
309
- * Set the status of the compilation
310
- *
311
- * @param compile true will avoid trigger new compilation
312
- */
313
- preventCompilation(compile) {
314
- this.compiled = compile;
315
- }
316
- /**
317
- * Migrate from v0 to v1 configuration
318
- *
319
- * A V0 is a webda.config.json that does not contain any version tag
320
- *
321
- * @param config
322
- */
323
- migrateV0Config(config) {
324
- this.log("WARN", "Old V0 webda.config.json format, trying to migrate");
325
- let newConfig = {
326
- parameters: {},
327
- services: {},
328
- models: {},
329
- routes: {},
330
- version: 1
331
- };
332
- let domain;
333
- if (config["*"]) {
334
- domain = config[config["*"]];
335
- }
336
- else {
337
- domain = config[Object.keys(config)[0]] || { global: {} };
338
- }
339
- if (domain.global) {
340
- newConfig.parameters = domain.global.params || {};
341
- newConfig.services = domain.global.services || {};
342
- newConfig.models = domain.global.models || {};
343
- newConfig.parameters.locales = domain.global.locales;
344
- newConfig.moddas = domain.global.moddas || {};
345
- }
346
- for (let i in domain) {
347
- if (i === "global")
348
- continue;
349
- newConfig.routes[i] = domain[i];
350
- }
351
- return newConfig;
352
- }
353
- /**
354
- * Migrate from v1 to v2 configuration format
355
- *
356
- * @param config
357
- */
358
- migrateV1Config(config) {
359
- this.log("WARN", "Old V1 webda.config.json format, trying to migrate");
360
- let newConfig = {
361
- parameters: config.parameters,
362
- services: config.services,
363
- module: {
364
- services: {},
365
- models: Object.assign({}, config.models),
366
- deployers: {}
367
- },
368
- version: 2
369
- };
370
- if (config.moddas) {
371
- for (let i in config.moddas) {
372
- newConfig.module.services[i] = config.moddas[i].require;
373
- }
374
- }
375
- return newConfig;
166
+ var _a, _b;
167
+ return ((_b = (_a = this.baseConfiguration.cachedModules) === null || _a === void 0 ? void 0 : _a.project) === null || _b === void 0 ? void 0 : _b.package) || {};
376
168
  }
377
169
  /**
378
170
  * Log information
@@ -413,30 +205,45 @@ class Application {
413
205
  */
414
206
  addService(name, service) {
415
207
  this.log("TRACE", "Registering service", name);
416
- this.services[name.toLowerCase()] = service;
208
+ this.moddas[name.toLowerCase()] = service;
209
+ return this;
417
210
  }
418
211
  /**
419
- * Get a service based on name
420
212
  *
213
+ * @param section
421
214
  * @param name
215
+ * @returns
422
216
  */
423
- getService(name) {
424
- let serviceName = this.completeNamespace(name).toLowerCase();
425
- this.log("TRACE", "Search for service", serviceName);
426
- if (!this.services[serviceName]) {
427
- serviceName = `Webda/${name}`.toLowerCase();
428
- // Try Webda namespace
429
- if (!this.services[serviceName]) {
430
- throw Error("Undefined service " + name);
431
- }
217
+ getWebdaObject(section, name) {
218
+ let objectName = this.completeNamespace(name);
219
+ this.log("TRACE", `Search for ${section} ${objectName}`);
220
+ if (!this[section][objectName] && name.indexOf("/") === -1) {
221
+ objectName = `webda/${name}`.toLowerCase();
222
+ }
223
+ if (!this[section][objectName]) {
224
+ throw Error(`Undefined ${section.substring(0, section.length - 1)} ${name} or ${objectName} (${Object.keys(this[section]).join(", ")})`);
432
225
  }
433
- return this.services[serviceName];
226
+ return this[section][objectName];
227
+ }
228
+ /**
229
+ * Get a service based on name
230
+ *
231
+ * @param name
232
+ */
233
+ getModda(name) {
234
+ return this.getWebdaObject("moddas", name);
434
235
  }
435
236
  /**
436
237
  * Return all services of the application
437
238
  */
438
- getServices() {
439
- return this.services;
239
+ getModdas() {
240
+ return this.moddas;
241
+ }
242
+ /**
243
+ * Return all beans of the application
244
+ */
245
+ getBeans() {
246
+ return this.baseConfiguration.cachedModules.beans;
440
247
  }
441
248
  /**
442
249
  * Retrieve the model implementation
@@ -444,14 +251,7 @@ class Application {
444
251
  * @param name model to retrieve
445
252
  */
446
253
  getModel(name) {
447
- name = name.toLowerCase();
448
- if (name.indexOf("/") < 0) {
449
- name = `webda/${name}`;
450
- }
451
- if (!this.models[name.toLowerCase()]) {
452
- throw Error("Undefined model '" + name + "' known models are '" + Object.keys(this.models).join(",") + "'");
453
- }
454
- return this.models[name.toLowerCase()];
254
+ return this.getWebdaObject("models", name);
455
255
  }
456
256
  /**
457
257
  * Get all models definitions
@@ -474,6 +274,7 @@ class Application {
474
274
  addModel(name, model) {
475
275
  this.log("TRACE", "Registering model", name);
476
276
  this.models[name.toLowerCase()] = model;
277
+ return this;
477
278
  }
478
279
  /**
479
280
  * Add a new deployer
@@ -484,16 +285,7 @@ class Application {
484
285
  addDeployer(name, model) {
485
286
  this.log("TRACE", "Registering deployer", name);
486
287
  this.deployers[name.toLowerCase()] = model;
487
- }
488
- /**
489
- * Check if a deployment exists for this application
490
- * This method cannot be called for a packaged application
491
- * as we do not keep deployments files when deployed
492
- *
493
- * @param deploymentName
494
- */
495
- hasDeployment(deploymentName) {
496
- return fs.existsSync(path.join(this.appPath, "deployments", deploymentName + ".json"));
288
+ return this;
497
289
  }
498
290
  /**
499
291
  * Return webda current version
@@ -504,76 +296,15 @@ class Application {
504
296
  getWebdaVersion() {
505
297
  return JSON.parse(fs.readFileSync(__dirname + "/../package.json").toString()).version;
506
298
  }
507
- getDeployment(deploymentName = undefined) {
508
- if (!deploymentName) {
509
- deploymentName = this.currentDeployment;
510
- }
511
- let deploymentConfig = path.join(this.appPath, "deployments", deploymentName + ".json");
512
- // Load deployment
513
- if (!fs.existsSync(deploymentConfig)) {
514
- throw new index_1.WebdaError("UNKNOWN_DEPLOYMENT", "Unknown deployment");
515
- }
516
- let deploymentModel;
517
- try {
518
- deploymentModel = JSON.parse(fs.readFileSync(deploymentConfig).toString());
519
- deploymentModel.name = deploymentName;
520
- }
521
- catch (err) {
522
- throw new index_1.WebdaError("INVALID_DEPLOYMENT", `Invalid deployment configuration ${deploymentConfig}: ${err.toString()}`);
523
- }
524
- return deploymentModel;
525
- }
526
299
  /**
527
300
  * Retrieve Git Repository information
528
301
  *
529
302
  * {@link GitInformation} for more details on how the information is gathered
530
303
  * @return the git information
531
304
  */
532
- getGitInformation() {
533
- let options = {
534
- cwd: this.getAppPath()
535
- };
536
- let info = this.getPackageDescription();
537
- try {
538
- let tags = (0, child_process_1.execSync)(`git tag --points-at HEAD`, options)
539
- .toString()
540
- .trim()
541
- .split("\n")
542
- .filter(t => t !== "");
543
- let tag = "";
544
- let version = info.version;
545
- if (tags.includes(`${info.name}@${info.version}`)) {
546
- tag = `${info.name}@${info.version}`;
547
- }
548
- else if (tags.includes(`v${info.version}`)) {
549
- tag = `v${info.version}`;
550
- }
551
- else {
552
- version = semver.inc(info.version, "patch") + "+" + dateFormat(new Date(), "yyyymmddHHMMssl");
553
- }
554
- // Search for what would be the tag
555
- // packageName@version
556
- // or version if single repo
557
- // if not included create a nextVersion+SNAPSHOT.${commit}.${now}
558
- return {
559
- commit: (0, child_process_1.execSync)(`git rev-parse HEAD`, options).toString().trim(),
560
- branch: (0, child_process_1.execSync)("git symbolic-ref --short HEAD", options).toString().trim(),
561
- short: (0, child_process_1.execSync)(`git rev-parse --short HEAD`, options).toString().trim(),
562
- tag,
563
- tags,
564
- version
565
- };
566
- }
567
- catch (err) {
568
- return {
569
- commit: "unknown",
570
- branch: "unknown",
571
- tag: "",
572
- short: "00000000",
573
- tags: [],
574
- version: info.version
575
- };
576
- }
305
+ getGitInformation(_packageName, _version) {
306
+ var _a;
307
+ return (_a = this.baseConfiguration.cachedModules.project) === null || _a === void 0 ? void 0 : _a.git;
577
308
  }
578
309
  /**
579
310
  * Allow variable inside of string
@@ -586,7 +317,7 @@ class Application {
586
317
  if (templateString.indexOf("${") < 0) {
587
318
  return templateString;
588
319
  }
589
- return new Function("return `" + templateString.replace(/\$\{/g, "${this.") + "`;").call(Object.assign({ package: this.getPackageDescription(), git: this.getGitInformation(), deployment: this.getCurrentDeployment(), now: this.initTime }, replacements));
320
+ return new Function("return `" + templateString.replace(/\$\{/g, "${this.") + "`;").call(Object.assign(Object.assign(Object.assign({}, this.baseConfiguration.cachedModules.project), { now: this.initTime }), replacements));
590
321
  }
591
322
  /**
592
323
  * Allow variable inside object strings
@@ -637,75 +368,26 @@ class Application {
637
368
  }));
638
369
  }
639
370
  /**
640
- * Return the application Configuration for a deployment
641
- *
642
- * Given this inputs:
643
- *
644
- * webda.config.json
645
- * ```json
646
- * {
647
- * "parameters": {
648
- * "param3": "test"
649
- * },
650
- * "services": {
651
- * "MyService": {
652
- * "param1": {
653
- * "sub": "test"
654
- * },
655
- * "param2": "value"
656
- * }
657
- * }
658
- * }
659
- * ```
660
- *
661
- * deployment.json
662
- * ```json
663
- * {
664
- * "parameters": {
665
- * "param4": "deployment"
666
- * }
667
- * "services": {
668
- * "MyService": {
669
- * "param1": {
670
- * "sub2": "deploymentSub"
671
- * },
672
- * "param2": "${package.version}"
673
- * }
674
- * }
675
- * }
676
- * ```
677
- *
678
- * The result would be:
679
- * ```json
680
- * {
681
- * "parameters": {
682
- * "param3": "test",
683
- * "param4": "deployment"
684
- * },
685
- * "services": {
686
- * "MyService": {
687
- * "param1": {
688
- * "sub": "test",
689
- * "sub2": "deploymentSub"
690
- * },
691
- * "param2": "1.1.0"
692
- * }
693
- * }
694
- * }
695
- * ```
696
- * This map can also use parameters {@link replaceVariables}
371
+ * Get current deployment name
372
+ */
373
+ getCurrentDeployment() {
374
+ return this.baseConfiguration.cachedModules.project.deployment.name;
375
+ }
376
+ /**
377
+ * Return all application modules merged as one
697
378
  *
698
- * @param deploymentName to use for the Configuration
379
+ * Used when deployed
380
+ * @returns
699
381
  */
700
- getConfiguration(deploymentName = undefined) {
701
- if (!deploymentName) {
702
- return this.baseConfiguration;
703
- }
704
- let config = JSON.parse(JSON.stringify(this.baseConfiguration));
705
- let deploymentModel = this.getDeployment(deploymentName);
706
- config.parameters = this.replaceVariables(merge.recursive(config.parameters, deploymentModel.parameters));
707
- config.services = this.replaceVariables(merge.recursive(config.services, deploymentModel.services));
708
- return config;
382
+ getModules() {
383
+ return this.baseConfiguration.cachedModules;
384
+ }
385
+ /**
386
+ * Get application configuration
387
+ * @returns
388
+ */
389
+ getConfiguration(_deployment = undefined) {
390
+ return this.baseConfiguration;
709
391
  }
710
392
  /**
711
393
  * Return current Configuration of the Application
@@ -717,132 +399,7 @@ class Application {
717
399
  * ```
718
400
  */
719
401
  getCurrentConfiguration() {
720
- return this.getConfiguration(this.currentDeployment);
721
- }
722
- /**
723
- * Set the current deployment for the application
724
- * Call to getCurrentConfiguration will resolve to the computed configuration for the deployment
725
- * If needed, you can call the method with undefined to reset to default configuration
726
- *
727
- * @param deployment to set
728
- */
729
- setCurrentDeployment(deployment) {
730
- this.currentDeployment = deployment;
731
- }
732
- /**
733
- * Get current deployment name
734
- */
735
- getCurrentDeployment() {
736
- return this.currentDeployment;
737
- }
738
- /**
739
- * Compile the application if it is a Typescript application
740
- * Do nothing otherwise
741
- */
742
- compile() {
743
- if (this.compiled) {
744
- return;
745
- }
746
- // exec typescript
747
- this.log("DEBUG", "Compiling application");
748
- try {
749
- (0, child_process_1.execSync)(`tsc -p ${this.appPath}`);
750
- }
751
- catch (err) {
752
- (err.stdout.toString() + err.stderr.toString())
753
- .split("\n")
754
- .filter(l => l !== "")
755
- .forEach(l => {
756
- this.log("ERROR", "tsc:", l);
757
- });
758
- }
759
- this.compiled = true;
760
- }
761
- /**
762
- * Load all imported modules and current module
763
- * It will compile module
764
- * Generate the current module file
765
- * Load any imported webda.module.json
766
- */
767
- loadModules() {
768
- // Cached modules is defined on deploy
769
- if (this.baseConfiguration.cachedModules) {
770
- // We should not load any modules as we are in a deployed version
771
- return;
772
- }
773
- // Compile
774
- this.compile();
775
- const Finder = require("fs-finder");
776
- // Modules should be cached on deploy
777
- var files = [];
778
- let nodeModules = path.join(this.appPath, "node_modules");
779
- if (fs.existsSync(nodeModules)) {
780
- files = Finder.from(nodeModules).findFiles("webda.module.json");
781
- }
782
- // Search workspace for webda.module.json
783
- if (this.workspacesPath !== "") {
784
- nodeModules = path.join(this.workspacesPath, "node_modules");
785
- if (fs.existsSync(nodeModules)) {
786
- files.push(...Finder.from(nodeModules).findFiles("webda.module.json"));
787
- }
788
- }
789
- // Generate module
790
- this.generateModule();
791
- let currentModule = path.join(this.appPath, "webda.module.json");
792
- if (fs.existsSync(currentModule)) {
793
- files.push(currentModule);
794
- }
795
- if (files.length) {
796
- this.log("DEBUG", "Found modules", files);
797
- files.forEach(file => {
798
- let info = require(file);
799
- this.loadModule(info, path.dirname(file));
800
- });
801
- }
802
- }
803
- getModules() {
804
- return this.cachedModules;
805
- }
806
- /**
807
- * Generate the module for current application
808
- */
809
- generateModule() {
810
- // Compile
811
- this.compile();
812
- // Reinit the sources cache
813
- this.cachedModules.sources = [];
814
- this._loaded = [];
815
- // Read all files
816
- this.getPackagesLocations().forEach(p => {
817
- let absPath = path.resolve(path.join(this.appPath, p));
818
- if (this._loaded.indexOf(absPath) >= 0) {
819
- return;
820
- }
821
- this._loaded.push(absPath);
822
- if (fs.existsSync(absPath) && fs.lstatSync(absPath).isDirectory()) {
823
- absPath += "/**/*.js";
824
- }
825
- glob.sync(absPath).forEach(f => this.loadJavascriptFile(f));
826
- });
827
- let moduleFile = path.join(this.appPath, "webda.module.json");
828
- let current = "";
829
- if (fs.existsSync(moduleFile)) {
830
- current = fs.readFileSync(moduleFile).toString();
831
- }
832
- let module = Object.assign(Object.assign({}, this.appModule), { schemas: {} });
833
- for (let i in this.appModule.services) {
834
- module.schemas[i] = this.getSchemaResolver().fromPrototype(this.services[i.toLowerCase()]);
835
- }
836
- for (let i in this.appModule.deployers) {
837
- module.schemas[i] = this.getSchemaResolver().fromPrototype(this.deployers[i.toLowerCase()]);
838
- }
839
- for (let i in this.appModule.models) {
840
- module.schemas[i] = this.getSchemaResolver().fromPrototype(this.models[i.toLowerCase()]);
841
- }
842
- if (current !== serializers_1.JSONUtils.stringify(module, undefined, 2)) {
843
- // Write module
844
- serializers_1.FileUtils.save(module, moduleFile);
845
- }
402
+ return this.getConfiguration();
846
403
  }
847
404
  /**
848
405
  * Import a file
@@ -851,32 +408,35 @@ class Application {
851
408
  *
852
409
  * @param info
853
410
  */
854
- resolveRequire(info) {
855
- if (info.startsWith(".")) {
856
- info = this.appPath + "/" + info;
857
- }
858
- try {
859
- let serviceConstructor = require(info);
860
- if (serviceConstructor.default) {
861
- return serviceConstructor.default;
411
+ importFile(info) {
412
+ return __awaiter(this, void 0, void 0, function* () {
413
+ if (info.startsWith(".")) {
414
+ info = this.appPath + "/" + info;
862
415
  }
863
- else {
864
- return serviceConstructor;
416
+ try {
417
+ this.log("TRACE", "Load file", info);
418
+ const [importFilename, importName = "default"] = info.split(":");
419
+ const importObject = (yield Promise.resolve().then(() => require(importFilename)))[importName];
420
+ if (!importObject) {
421
+ this.log("WARN", `Module ${importFilename} does not have export named ${importName}`);
422
+ }
423
+ return importObject;
865
424
  }
866
- }
867
- catch (err) {
868
- this.log("WARN", "Cannot resolve require", info, err.message);
869
- return null;
870
- }
425
+ catch (err) {
426
+ this.log("WARN", "Cannot resolve require", info, err.message);
427
+ }
428
+ });
871
429
  }
872
430
  /**
873
431
  * Load local module
874
432
  */
875
433
  loadLocalModule() {
876
- let moduleFile = path.join(process.cwd(), "webda.module.json");
877
- if (fs.existsSync(moduleFile)) {
878
- this.loadModule(JSON.parse(fs.readFileSync(moduleFile).toString()), process.cwd());
879
- }
434
+ return __awaiter(this, void 0, void 0, function* () {
435
+ let moduleFile = path.join(process.cwd(), "webda.module.json");
436
+ if (fs.existsSync(moduleFile)) {
437
+ yield this.loadModule(JSON.parse(fs.readFileSync(moduleFile).toString()), process.cwd());
438
+ }
439
+ });
880
440
  }
881
441
  /**
882
442
  * Load the module,
@@ -884,40 +444,26 @@ class Application {
884
444
  * @protected
885
445
  * @ignore Useless for documentation
886
446
  */
887
- loadModule(info, parent = this.appPath) {
888
- info.services = info.services || {};
889
- info.models = info.models || {};
890
- info.deployers = info.deployers || {};
891
- // Load services definition
892
- for (let key in info.services) {
893
- let service = this.resolveRequire(path.join(parent, info.services[key]));
894
- if (!service) {
895
- continue;
896
- }
897
- this.addService(key, service);
898
- this.cachedModules.services[key] =
899
- "./" + path.relative(this.appPath, path.resolve(path.join(parent, info.services[key])));
900
- }
901
- // Load models definition
902
- for (let key in info.models) {
903
- let service = this.resolveRequire(path.join(parent, info.models[key]));
904
- if (!service) {
905
- continue;
906
- }
907
- this.addModel(key, service);
908
- this.cachedModules.models[key] =
909
- "./" + path.relative(this.appPath, path.resolve(path.join(parent, info.models[key])));
910
- }
911
- // Load deployers definition
912
- for (let key in info.deployers) {
913
- let service = this.resolveRequire(path.join(parent, info.deployers[key]));
914
- if (!service) {
915
- continue;
916
- }
917
- this.addDeployer(key, service);
918
- this.cachedModules.deployers[key] =
919
- "./" + path.relative(this.appPath, path.resolve(path.join(parent, info.deployers[key])));
920
- }
447
+ loadModule(module, parent = this.appPath) {
448
+ return __awaiter(this, void 0, void 0, function* () {
449
+ const info = Object.assign({ beans: {} }, module);
450
+ const sectionLoader = (section) => __awaiter(this, void 0, void 0, function* () {
451
+ var _a;
452
+ var _b, _c;
453
+ for (let key in info[section]) {
454
+ (_a = (_b = this[section])[_c = key.toLowerCase()]) !== null && _a !== void 0 ? _a : (_b[_c] = yield this.importFile(path.join(parent, info[section][key])));
455
+ }
456
+ });
457
+ yield Promise.all([
458
+ sectionLoader("moddas"),
459
+ sectionLoader("deployers"),
460
+ sectionLoader("models"),
461
+ ...Object.keys(info.beans).map(f => {
462
+ this.baseConfiguration.cachedModules.beans[f] = info.beans[f];
463
+ return Promise.resolve().then(() => require(path.join(parent, info.beans[f]))).catch(this.log.bind(this, "WARN"));
464
+ })
465
+ ]);
466
+ });
921
467
  }
922
468
  /**
923
469
  * Return the full name including namespace
@@ -929,11 +475,12 @@ class Application {
929
475
  * @param name
930
476
  */
931
477
  completeNamespace(name = "") {
478
+ var _a, _b;
932
479
  // Do not add a namespace if already present
933
480
  if (name.indexOf("/") >= 0) {
934
- return name;
481
+ return name.toLowerCase();
935
482
  }
936
- return `${this.namespace}/${name}`;
483
+ return `${((_b = (_a = this.baseConfiguration.cachedModules.project) === null || _a === void 0 ? void 0 : _a.webda) === null || _b === void 0 ? void 0 : _b.namespace) || "webda"}/${name}`.toLowerCase();
937
484
  }
938
485
  /**
939
486
  * Check if object extends a class
@@ -955,56 +502,6 @@ class Application {
955
502
  }
956
503
  return false;
957
504
  }
958
- /**
959
- * Load a javascript file and check for Modda
960
- * @param path to load
961
- */
962
- loadJavascriptFile(absolutePath) {
963
- let marker = path.resolve(absolutePath);
964
- if (this._loaded.indexOf(marker) >= 0) {
965
- return;
966
- }
967
- this._loaded.push(marker);
968
- let source = "./" + path.relative(this.appPath, absolutePath);
969
- if (this.cachedModules.sources.indexOf(source) < 0) {
970
- this.cachedModules.sources.push(source);
971
- }
972
- let mod = this.resolveRequire(absolutePath);
973
- let obj = mod;
974
- if (obj && obj.getModda) {
975
- let modda = mod.getModda();
976
- let name = mod.prototype.name;
977
- let category = "services";
978
- if (modda) {
979
- name = modda.uuid;
980
- if (modda.category) {
981
- category = modda.category;
982
- }
983
- }
984
- this.log("DEBUG", `Found new getModda implementation ${category} ${this.completeNamespace(name)}`);
985
- this.appModule[category][this.completeNamespace(name)] = path.relative(this.appPath, absolutePath);
986
- if (this.extends(obj, abstractdeployer_1.AbstractDeployer)) {
987
- this.addDeployer(this.completeNamespace(name), obj);
988
- }
989
- else {
990
- this.addService(this.completeNamespace(name), obj);
991
- }
992
- }
993
- else if (this.extends(obj, index_1.CoreModel) || this.extends(obj, index_1.Context)) {
994
- this.log("DEBUG", "Found new CoreModel implementation", this.completeNamespace(obj.name));
995
- this.appModule["models"][this.completeNamespace(obj.name)] = path.relative(this.appPath, absolutePath);
996
- this.addModel(this.completeNamespace(obj.name), obj);
997
- }
998
- }
999
- /**
1000
- * Get the application files
1001
- */
1002
- getPackagesLocations() {
1003
- return this.packageDescription.files || ["lib/**/*.js"];
1004
- }
1005
505
  }
1006
- __decorate([
1007
- (0, index_1.Cache)()
1008
- ], Application.prototype, "getGitInformation", null);
1009
506
  exports.Application = Application;
1010
507
  //# sourceMappingURL=application.js.map