@webda/core 1.6.0-beta.3 → 2.0.0-beta.2

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 (253) hide show
  1. package/lib/application.d.ts +355 -195
  2. package/lib/application.js +188 -682
  3. package/lib/application.js.map +1 -1
  4. package/lib/application.spec.js +109 -289
  5. package/lib/application.spec.js.map +1 -1
  6. package/lib/core.d.ts +150 -215
  7. package/lib/core.js +188 -71
  8. package/lib/core.js.map +1 -1
  9. package/lib/core.spec.js +103 -42
  10. package/lib/core.spec.js.map +1 -1
  11. package/lib/index.d.ts +4 -0
  12. package/lib/index.js +9 -1
  13. package/lib/index.js.map +1 -1
  14. package/lib/models/aclmodel.d.ts +3 -1
  15. package/lib/models/aclmodel.js +6 -3
  16. package/lib/models/aclmodel.js.map +1 -1
  17. package/lib/models/aclmodel.spec.js +10 -5
  18. package/lib/models/aclmodel.spec.js.map +1 -1
  19. package/lib/models/coremodel.d.ts +86 -24
  20. package/lib/models/coremodel.js +85 -36
  21. package/lib/models/coremodel.js.map +1 -1
  22. package/lib/models/coremodel.spec.js +21 -2
  23. package/lib/models/coremodel.spec.js.map +1 -1
  24. package/lib/models/ident.d.ts +7 -5
  25. package/lib/models/ident.js +2 -1
  26. package/lib/models/ident.js.map +1 -1
  27. package/lib/models/ident.spec.js +1 -1
  28. package/lib/models/ident.spec.js.map +1 -1
  29. package/lib/models/ownermodel.d.ts +18 -4
  30. package/lib/models/ownermodel.js +24 -4
  31. package/lib/models/ownermodel.js.map +1 -1
  32. package/lib/models/ownermodel.spec.js +18 -1
  33. package/lib/models/ownermodel.spec.js.map +1 -1
  34. package/lib/models/rolemodel.js.map +1 -1
  35. package/lib/models/rolemodel.spec.js +5 -2
  36. package/lib/models/rolemodel.spec.js.map +1 -1
  37. package/lib/models/user.d.ts +7 -6
  38. package/lib/models/user.js +2 -1
  39. package/lib/models/user.js.map +1 -1
  40. package/lib/models/user.spec.js +1 -1
  41. package/lib/models/user.spec.js.map +1 -1
  42. package/lib/queues/filequeue.d.ts +2 -7
  43. package/lib/queues/filequeue.js +4 -13
  44. package/lib/queues/filequeue.js.map +1 -1
  45. package/lib/queues/filequeue.spec.js +2 -3
  46. package/lib/queues/filequeue.spec.js.map +1 -1
  47. package/lib/queues/memoryqueue.d.ts +2 -7
  48. package/lib/queues/memoryqueue.js +1 -11
  49. package/lib/queues/memoryqueue.js.map +1 -1
  50. package/lib/queues/memoryqueue.spec.js +1 -1
  51. package/lib/queues/memoryqueue.spec.js.map +1 -1
  52. package/lib/queues/queue.spec.d.ts +1 -1
  53. package/lib/queues/queue.spec.js +12 -10
  54. package/lib/queues/queue.spec.js.map +1 -1
  55. package/lib/queues/queueservice.d.ts +1 -1
  56. package/lib/queues/queueservice.js +1 -1
  57. package/lib/queues/queueservice.js.map +1 -1
  58. package/lib/router.d.ts +52 -2
  59. package/lib/router.js +80 -51
  60. package/lib/router.js.map +1 -1
  61. package/lib/router.spec.js +23 -6
  62. package/lib/router.spec.js.map +1 -1
  63. package/lib/services/asyncevents.d.ts +1 -0
  64. package/lib/services/asyncevents.js +4 -3
  65. package/lib/services/asyncevents.js.map +1 -1
  66. package/lib/services/asyncevents.spec.js +2 -2
  67. package/lib/services/asyncevents.spec.js.map +1 -1
  68. package/lib/services/authentication.d.ts +39 -11
  69. package/lib/services/authentication.js +60 -55
  70. package/lib/services/authentication.js.map +1 -1
  71. package/lib/services/authentication.spec.js +2 -1
  72. package/lib/services/authentication.spec.js.map +1 -1
  73. package/lib/services/binary.d.ts +127 -65
  74. package/lib/services/binary.js +255 -98
  75. package/lib/services/binary.js.map +1 -1
  76. package/lib/services/binary.spec.d.ts +2 -1
  77. package/lib/services/binary.spec.js +101 -30
  78. package/lib/services/binary.spec.js.map +1 -1
  79. package/lib/services/cloudbinary.d.ts +67 -0
  80. package/lib/services/cloudbinary.js +178 -0
  81. package/lib/services/cloudbinary.js.map +1 -0
  82. package/lib/services/cloudbinary.spec.d.ts +13 -0
  83. package/lib/services/cloudbinary.spec.js +212 -0
  84. package/lib/services/cloudbinary.spec.js.map +1 -0
  85. package/lib/services/configuration.d.ts +7 -2
  86. package/lib/services/configuration.js +6 -5
  87. package/lib/services/configuration.js.map +1 -1
  88. package/lib/services/configuration.spec.js +3 -2
  89. package/lib/services/configuration.spec.js.map +1 -1
  90. package/lib/services/cron.d.ts +5 -6
  91. package/lib/services/cron.js +5 -12
  92. package/lib/services/cron.js.map +1 -1
  93. package/lib/services/cron.spec.js +3 -4
  94. package/lib/services/cron.spec.js.map +1 -1
  95. package/lib/services/debugmailer.d.ts +3 -5
  96. package/lib/services/debugmailer.js +3 -11
  97. package/lib/services/debugmailer.js.map +1 -1
  98. package/lib/services/debugmailer.spec.js +1 -1
  99. package/lib/services/debugmailer.spec.js.map +1 -1
  100. package/lib/services/echo.d.ts +3 -7
  101. package/lib/services/echo.js +1 -11
  102. package/lib/services/echo.js.map +1 -1
  103. package/lib/services/echo.spec.js +4 -3
  104. package/lib/services/echo.spec.js.map +1 -1
  105. package/lib/services/filebinary.d.ts +45 -16
  106. package/lib/services/filebinary.js +147 -50
  107. package/lib/services/filebinary.js.map +1 -1
  108. package/lib/services/filebinary.spec.d.ts +4 -2
  109. package/lib/services/filebinary.spec.js +50 -12
  110. package/lib/services/filebinary.spec.js.map +1 -1
  111. package/lib/services/fileconfiguration.d.ts +1 -5
  112. package/lib/services/fileconfiguration.js +3 -12
  113. package/lib/services/fileconfiguration.js.map +1 -1
  114. package/lib/services/fileconfiguration.spec.js +2 -2
  115. package/lib/services/fileconfiguration.spec.js.map +1 -1
  116. package/lib/services/invitationservice.d.ts +28 -4
  117. package/lib/services/invitationservice.js +9 -6
  118. package/lib/services/invitationservice.js.map +1 -1
  119. package/lib/services/invitationservice.spec.js +4 -3
  120. package/lib/services/invitationservice.spec.js.map +1 -1
  121. package/lib/services/kubernetesconfiguration.d.ts +3 -5
  122. package/lib/services/kubernetesconfiguration.js +7 -14
  123. package/lib/services/kubernetesconfiguration.js.map +1 -1
  124. package/lib/services/kubernetesconfiguration.spec.js +5 -5
  125. package/lib/services/kubernetesconfiguration.spec.js.map +1 -1
  126. package/lib/services/mailer.d.ts +1 -5
  127. package/lib/services/mailer.js +1 -10
  128. package/lib/services/mailer.js.map +1 -1
  129. package/lib/services/mailer.spec.js +3 -3
  130. package/lib/services/mailer.spec.js.map +1 -1
  131. package/lib/services/notificationservice.d.ts +2 -0
  132. package/lib/services/notificationservice.js +2 -0
  133. package/lib/services/notificationservice.js.map +1 -1
  134. package/lib/services/notificationservice.spec.js +2 -2
  135. package/lib/services/notificationservice.spec.js.map +1 -1
  136. package/lib/services/oauth.d.ts +8 -6
  137. package/lib/services/oauth.js +30 -14
  138. package/lib/services/oauth.js.map +1 -1
  139. package/lib/services/oauth.spec.js +11 -10
  140. package/lib/services/oauth.spec.js.map +1 -1
  141. package/lib/services/resource.d.ts +18 -5
  142. package/lib/services/resource.js +42 -23
  143. package/lib/services/resource.js.map +1 -1
  144. package/lib/services/resource.spec.js +4 -4
  145. package/lib/services/resource.spec.js.map +1 -1
  146. package/lib/services/service.d.ts +25 -25
  147. package/lib/services/service.js +21 -25
  148. package/lib/services/service.js.map +1 -1
  149. package/lib/services/service.spec.js +2 -2
  150. package/lib/services/service.spec.js.map +1 -1
  151. package/lib/services/version.d.ts +2 -5
  152. package/lib/services/version.js +1 -10
  153. package/lib/services/version.js.map +1 -1
  154. package/lib/services/version.spec.js +1 -1
  155. package/lib/services/version.spec.js.map +1 -1
  156. package/lib/stores/aggregator.d.ts +3 -5
  157. package/lib/stores/aggregator.js +3 -10
  158. package/lib/stores/aggregator.js.map +1 -1
  159. package/lib/stores/file.d.ts +15 -8
  160. package/lib/stores/file.js +21 -18
  161. package/lib/stores/file.js.map +1 -1
  162. package/lib/stores/file.spec.d.ts +3 -1
  163. package/lib/stores/file.spec.js +32 -8
  164. package/lib/stores/file.spec.js.map +1 -1
  165. package/lib/stores/mapper.d.ts +1 -5
  166. package/lib/stores/mapper.js +5 -13
  167. package/lib/stores/mapper.js.map +1 -1
  168. package/lib/stores/mapper.spec.js +2 -2
  169. package/lib/stores/mapper.spec.js.map +1 -1
  170. package/lib/stores/memory.d.ts +5 -9
  171. package/lib/stores/memory.js +5 -17
  172. package/lib/stores/memory.js.map +1 -1
  173. package/lib/stores/memory.spec.d.ts +2 -1
  174. package/lib/stores/memory.spec.js +36 -4
  175. package/lib/stores/memory.spec.js.map +1 -1
  176. package/lib/stores/store.d.ts +142 -29
  177. package/lib/stores/store.js +451 -82
  178. package/lib/stores/store.js.map +1 -1
  179. package/lib/stores/store.spec.d.ts +31 -4
  180. package/lib/stores/store.spec.js +206 -35
  181. package/lib/stores/store.spec.js.map +1 -1
  182. package/lib/stores/webdaql/WebdaQLLexer.d.ts +53 -0
  183. package/lib/stores/webdaql/WebdaQLLexer.js +290 -0
  184. package/lib/stores/webdaql/WebdaQLLexer.js.map +1 -0
  185. package/lib/stores/webdaql/WebdaQLParserLexer.d.ts +53 -0
  186. package/lib/stores/webdaql/WebdaQLParserLexer.js +290 -0
  187. package/lib/stores/webdaql/WebdaQLParserLexer.js.map +1 -0
  188. package/lib/stores/webdaql/WebdaQLParserListener.d.ts +284 -0
  189. package/lib/stores/webdaql/WebdaQLParserListener.js +4 -0
  190. package/lib/stores/webdaql/WebdaQLParserListener.js.map +1 -0
  191. package/lib/stores/webdaql/WebdaQLParserParser.d.ts +301 -0
  192. package/lib/stores/webdaql/WebdaQLParserParser.js +1781 -0
  193. package/lib/stores/webdaql/WebdaQLParserParser.js.map +1 -0
  194. package/lib/stores/webdaql/WebdaQLParserVisitor.d.ts +174 -0
  195. package/lib/stores/webdaql/WebdaQLParserVisitor.js +4 -0
  196. package/lib/stores/webdaql/WebdaQLParserVisitor.js.map +1 -0
  197. package/lib/stores/webdaql/query.d.ts +300 -0
  198. package/lib/stores/webdaql/query.js +471 -0
  199. package/lib/stores/webdaql/query.js.map +1 -0
  200. package/lib/stores/webdaql/query.spec.d.ts +1 -0
  201. package/lib/stores/webdaql/query.spec.js +136 -0
  202. package/lib/stores/webdaql/query.spec.js.map +1 -0
  203. package/lib/test.d.ts +54 -9
  204. package/lib/test.js +139 -25
  205. package/lib/test.js.map +1 -1
  206. package/lib/unpackedapplication.d.ts +66 -0
  207. package/lib/unpackedapplication.js +219 -0
  208. package/lib/unpackedapplication.js.map +1 -0
  209. package/lib/utils/abstractdeployer.spec.js +1 -1
  210. package/lib/utils/abstractdeployer.spec.js.map +1 -1
  211. package/lib/utils/context.d.ts +17 -58
  212. package/lib/utils/context.js +33 -124
  213. package/lib/utils/context.js.map +1 -1
  214. package/lib/utils/context.spec.js +52 -28
  215. package/lib/utils/context.spec.js.map +1 -1
  216. package/lib/utils/cookie.d.ts +6 -3
  217. package/lib/utils/cookie.js +9 -5
  218. package/lib/utils/cookie.js.map +1 -1
  219. package/lib/utils/cookie.spec.js +5 -5
  220. package/lib/utils/cookie.spec.js.map +1 -1
  221. package/lib/utils/httpcontext.d.ts +182 -0
  222. package/lib/utils/httpcontext.js +325 -0
  223. package/lib/utils/httpcontext.js.map +1 -0
  224. package/lib/utils/httpcontext.spec.d.ts +5 -0
  225. package/lib/utils/httpcontext.spec.js +90 -0
  226. package/lib/utils/httpcontext.spec.js.map +1 -0
  227. package/lib/utils/logger.d.ts +18 -5
  228. package/lib/utils/logger.js +17 -4
  229. package/lib/utils/logger.js.map +1 -1
  230. package/lib/utils/logger.spec.js.map +1 -1
  231. package/lib/utils/serializers.js +5 -1
  232. package/lib/utils/serializers.js.map +1 -1
  233. package/lib/utils/serializers.spec.js +3 -3
  234. package/lib/utils/serializers.spec.js.map +1 -1
  235. package/lib/utils/waiter.d.ts +1 -1
  236. package/lib/utils/waiter.js.map +1 -1
  237. package/lib/utils/waiter.spec.js +2 -2
  238. package/lib/utils/waiter.spec.js.map +1 -1
  239. package/package.json +25 -18
  240. package/test/config-file-no-reload.json +2 -1
  241. package/test/config-file-reload.json +2 -1
  242. package/test/config-kube-reload.json +2 -1
  243. package/test/config-reload.json +1 -1
  244. package/test/config.json +8 -11
  245. package/test/config.old.json +1 -1
  246. package/test/moddas/annotatedservice.js +1 -3
  247. package/test/moddas/debugmailer.js +2 -7
  248. package/test/moddas/fakeservice.js +1 -1
  249. package/test/moddas/voidstore.js +2 -4
  250. package/test/models/ident.js +1 -1
  251. package/test/models/task.js +1 -6
  252. package/webda.module.json +1124 -0
  253. package/test/config.old-default.json +0 -151
package/lib/core.d.ts CHANGED
@@ -1,14 +1,13 @@
1
1
  /// <reference types="node" />
2
+ import { WorkerLogLevel, WorkerOutput } from "@webda/workout";
3
+ import Ajv from "ajv";
2
4
  import * as events from "events";
3
- import { JSONSchema6 } from "json-schema";
4
5
  import { OpenAPIV3 } from "openapi-types";
5
6
  import * as vm from "vm";
6
- import { Application } from "./application";
7
+ import { Application, Configuration } from "./application";
7
8
  import { Context, HttpContext, Logger, Service } from "./index";
8
9
  import { CoreModel, CoreModelDefinition } from "./models/coremodel";
9
- import { RouteInfo, Router } from "./router";
10
- import { WorkerOutput, WorkerLogLevel } from "@webda/workout";
11
- import { AbstractDeployer } from "./utils/abstractdeployer";
10
+ import { OpenAPIWebdaDefinition, RouteInfo, Router } from "./router";
12
11
  /**
13
12
  * Error with a code
14
13
  */
@@ -31,190 +30,6 @@ export declare class WebdaError extends Error {
31
30
  export interface EventWithContext {
32
31
  context: Context;
33
32
  }
34
- /**
35
- * Emitted when new request comes in
36
- */
37
- export interface EventWebdaRequest extends EventWithContext {
38
- }
39
- /**
40
- * Emitted when new result is sent
41
- */
42
- export interface EventWebdaResult extends EventWithContext {
43
- }
44
- /**
45
- * Emitted when a request does not match any route
46
- */
47
- export interface EventWebda404 extends EventWithContext {
48
- }
49
- /**
50
- * Define a reusable service
51
- *
52
- * A Modda is a class that can be reused
53
- * For example:
54
- * - MongoDB Store implementation
55
- * - SQS Service implementation
56
- * - etc
57
- */
58
- export interface ModdaDefinition {
59
- uuid: string;
60
- /**
61
- * Label of the service
62
- */
63
- label: string;
64
- /**
65
- * Description of your service
66
- */
67
- description: string;
68
- /**
69
- * Documentation page must be available online
70
- */
71
- documentation?: string;
72
- /**
73
- * Type of services
74
- */
75
- category?: "services" | "models" | "deployers";
76
- /**
77
- * URL of the logo to display
78
- */
79
- logo?: string;
80
- }
81
- /**
82
- * A Webda module is a NPM package
83
- *
84
- * It contains one or more Modda to provide features
85
- */
86
- export interface Module {
87
- /**
88
- * Services provided by the module
89
- */
90
- services?: {
91
- [key: string]: string;
92
- };
93
- /**
94
- * Models provided by the module
95
- */
96
- models?: {
97
- [key: string]: string;
98
- };
99
- /**
100
- * Deployers provided by the module
101
- *
102
- * @link Deployer
103
- */
104
- deployers?: {
105
- [key: string]: string;
106
- };
107
- /**
108
- * Schemas for services, deployers and coremodel
109
- */
110
- schemas?: {
111
- [key: string]: JSONSchema6;
112
- };
113
- }
114
- /**
115
- * Cached module is all modules discover plus local package including the sources list
116
- */
117
- export interface CachedModule extends Module {
118
- /**
119
- * Source files to import
120
- */
121
- sources?: string[];
122
- }
123
- /**
124
- * Configuration from Webda 1.0 > version > 0.5
125
- */
126
- export interface ConfigurationV1 {
127
- /**
128
- * Configuration version
129
- */
130
- version: number;
131
- /**
132
- * Cached modules to avoid scanning node_modules
133
- * This is used by packagers
134
- */
135
- cachedModules?: CachedModule;
136
- /**
137
- * Models
138
- */
139
- models?: any;
140
- /**
141
- * Services configuration
142
- */
143
- services?: any;
144
- [key: string]: any;
145
- }
146
- /**
147
- * Configuration from Webda version >= 1.0
148
- */
149
- export interface Configuration {
150
- /**
151
- * @minimum 2
152
- */
153
- version: number;
154
- /**
155
- * Cached modules to avoid scanning node_modules
156
- * This is used by packagers
157
- */
158
- cachedModules?: CachedModule;
159
- /**
160
- * Module definition
161
- */
162
- module: Module;
163
- /**
164
- * Services configuration
165
- */
166
- services?: any;
167
- /**
168
- * Global parameters
169
- */
170
- parameters?: {
171
- /**
172
- * Allowed origin for referer that match
173
- * any of this regexp
174
- *
175
- * {@link OriginFilter}
176
- */
177
- csrfOrigins?: string[];
178
- /**
179
- * Allow you to authorize one or several websites
180
- * If you use "*" then the API is open to direct call and any origins
181
- *
182
- * {@link WebsiteOriginFilter}
183
- */
184
- website?: string | string[] | {
185
- url: string;
186
- };
187
- /**
188
- * Cookie configuration for session
189
- */
190
- cookie?: {
191
- sameSite: "None" | "Strict" | "Lax";
192
- domain: string;
193
- /**
194
- * @minimum 1
195
- */
196
- maxAge: number;
197
- path: string;
198
- };
199
- /**
200
- * Read from the configuration service before init
201
- */
202
- configurationService?: string;
203
- /**
204
- * Application salt
205
- */
206
- salt?: string;
207
- /**
208
- * Define the api url
209
- */
210
- apiUrl?: string;
211
- [key: string]: any;
212
- };
213
- /**
214
- * OpenAPI override
215
- */
216
- openapi?: any;
217
- }
218
33
  /**
219
34
  * RequestFilter allow a service which implement it to control incoming request
220
35
  *
@@ -252,14 +67,51 @@ export declare class WebsiteOriginFilter implements RequestFilter<Context> {
252
67
  checkRequest(context: Context): Promise<boolean>;
253
68
  }
254
69
  export declare function Bean(constructor: Function): void;
255
- export declare function Route(route: string, methods?: string | string[], allowPath?: boolean, openapi?: any): (target: any, executor: string, descriptor: PropertyDescriptor) => void;
70
+ export declare function Route(route: string, methods?: string | string[], allowPath?: boolean, openapi?: OpenAPIWebdaDefinition): (target: any, executor: string) => void;
71
+ export declare type CoreEvents = {
72
+ /**
73
+ * Emitted when new result is sent
74
+ */
75
+ "Webda.Result": EventWithContext;
76
+ /**
77
+ * Emitted when new request comes in
78
+ */
79
+ "Webda.Request": EventWithContext;
80
+ /**
81
+ * Emitted when a request does not match any route
82
+ */
83
+ "Webda.404": EventWithContext;
84
+ /**
85
+ * Emitted when Services have been initialized
86
+ */
87
+ "Webda.Init.Services": {
88
+ [key: string]: Service;
89
+ };
90
+ /**
91
+ * Emitted when Services have been created
92
+ */
93
+ "Webda.Create.Services": {
94
+ [key: string]: Service;
95
+ };
96
+ /**
97
+ * Emitted when Core is initialized
98
+ */
99
+ "Webda.Init": Configuration;
100
+ /**
101
+ * Emitted whenever a new Context is created
102
+ */
103
+ "Webda.NewContext": Context;
104
+ [key: string]: unknown;
105
+ };
106
+ declare type NoSchemaResult = null;
107
+ declare type SchemaValidResult = true;
256
108
  /**
257
109
  * This is the main class of the framework, it handles the routing, the services initialization and resolution
258
110
  *
259
111
  * @class Core
260
112
  * @category CoreFeatures
261
113
  */
262
- export declare class Core extends events.EventEmitter {
114
+ export declare class Core<E extends CoreEvents = CoreEvents> extends events.EventEmitter {
263
115
  /**
264
116
  * Webda Services
265
117
  * @hidden
@@ -267,9 +119,21 @@ export declare class Core extends events.EventEmitter {
267
119
  protected services: {
268
120
  [key: string]: Service;
269
121
  };
122
+ /**
123
+ * Application that generates this Core
124
+ */
270
125
  protected application: Application;
126
+ /**
127
+ * Router that will route http request in
128
+ */
271
129
  protected router: Router;
130
+ /**
131
+ * If Core is already initiated
132
+ */
272
133
  protected _initiated: boolean;
134
+ /**
135
+ * Services who failed to create or initialize
136
+ */
273
137
  protected failedServices: {
274
138
  [key: string]: any;
275
139
  };
@@ -286,17 +150,26 @@ export declare class Core extends events.EventEmitter {
286
150
  /**
287
151
  * JSON Schema validator instance
288
152
  */
289
- protected _ajv: any;
153
+ protected _ajv: Ajv;
290
154
  /**
291
155
  * JSON Schema registry
156
+ * Save if a schema was added to Ajv already
292
157
  */
293
- protected _ajvSchemas: any;
158
+ protected _ajvSchemas: {
159
+ [key: string]: true;
160
+ };
294
161
  /**
295
162
  * Current executor
296
163
  */
297
164
  protected _currentExecutor: any;
298
165
  protected _configFile: string;
166
+ /**
167
+ * Contains the current initialization process
168
+ */
299
169
  protected _initPromise: Promise<void>;
170
+ /**
171
+ * When the Core was initialized
172
+ */
300
173
  protected _initTime: number;
301
174
  /**
302
175
  * Console logger
@@ -304,17 +177,39 @@ export declare class Core extends events.EventEmitter {
304
177
  */
305
178
  protected logger: Logger;
306
179
  /**
307
- * CORS Filter registry
180
+ * Request Filter registry
308
181
  *
309
182
  * Added via [[Webda.registerRequestFilter]]
310
183
  * See [[CorsFilter]]
311
184
  */
312
185
  protected _requestFilters: RequestFilter<Context>[];
186
+ /**
187
+ * CORS Filter registry
188
+ *
189
+ * Added via [[Webda.registerCORSRequestFilter]]
190
+ * See [[CorsFilter]]
191
+ */
192
+ protected _requestCORSFilters: RequestFilter<Context>[];
193
+ /**
194
+ * Worker output
195
+ *
196
+ * @see @webda/workout
197
+ */
313
198
  private workerOutput;
199
+ /**
200
+ * Store the instance id
201
+ */
202
+ private instanceId;
314
203
  /**
315
204
  * @params {Object} config - The configuration Object, if undefined will load the configuration file
316
205
  */
317
206
  constructor(application: Application);
207
+ /**
208
+ * Return Core instance id
209
+ *
210
+ * It is a random generated string
211
+ */
212
+ getInstanceId(): string;
318
213
  /**
319
214
  * Get absolute url with subpath
320
215
  * @param subpath
@@ -336,13 +231,7 @@ export declare class Core extends events.EventEmitter {
336
231
  /**
337
232
  * Retrieve all detected modules definition
338
233
  */
339
- getModules(): CachedModule;
340
- /**
341
- * Retrieve all deployers
342
- */
343
- getDeployers(): {
344
- [key: string]: import("./application").ServiceConstructor<Service<import("./index").ServiceParameters>>;
345
- };
234
+ getModules(): import("./application").CachedModule;
346
235
  /**
347
236
  * Return application definition
348
237
  */
@@ -356,13 +245,32 @@ export declare class Core extends events.EventEmitter {
356
245
  * @param service
357
246
  */
358
247
  protected initService(service: string): Promise<void>;
248
+ /**
249
+ * Get an object from the application based on its full uuid
250
+ * @param fullUuid
251
+ * @param partials
252
+ */
253
+ getModelObject<T extends CoreModel = CoreModel>(fullUuid: string, partials?: any): Promise<T>;
359
254
  /**
360
255
  * Init Webda
361
256
  *
362
257
  * It will resolve Services init method and autolink
363
258
  */
364
259
  init(): Promise<void>;
260
+ /**
261
+ * Register a request filtering
262
+ *
263
+ * Will apply to all requests regardless of the devMode
264
+ * @param filter
265
+ */
365
266
  registerRequestFilter(filter: RequestFilter<Context>): void;
267
+ /**
268
+ * Register a CORS request filtering
269
+ *
270
+ * Does not apply in devMode
271
+ * @param filter
272
+ */
273
+ registerCORSFilter(filter: RequestFilter<Context>): void;
366
274
  /**
367
275
  *
368
276
  * @param {Object} executor The executor to expose as executor
@@ -375,11 +283,7 @@ export declare class Core extends events.EventEmitter {
375
283
  * @param schema path to use
376
284
  * @param object to validate
377
285
  */
378
- validateSchema(webdaObject: CoreModel | Service | AbstractDeployer, object: any): any;
379
- /**
380
- * Get last errors from AJV schema validator ( called through validate method )
381
- */
382
- validationLastErrors(): any;
286
+ validateSchema(webdaObject: CoreModel | string, object: any): NoSchemaResult | SchemaValidResult;
383
287
  /**
384
288
  * Return webda current version
385
289
  *
@@ -433,7 +337,7 @@ export declare class Core extends events.EventEmitter {
433
337
  * @param type The type of implementation
434
338
  * @returns {{}}
435
339
  */
436
- getServicesImplementations(type?: any): {
340
+ getServicesOfType(type?: any): {
437
341
  [key: string]: Service;
438
342
  };
439
343
  getConfiguration(): Configuration;
@@ -451,10 +355,6 @@ export declare class Core extends events.EventEmitter {
451
355
  getModels(): {
452
356
  [key: string]: CoreModelDefinition;
453
357
  };
454
- /**
455
- * Register model
456
- */
457
- registerModel(name: string, clazz: any): void;
458
358
  /**
459
359
  * Check for a model name and return the wanted class or throw exception if none found
460
360
  *
@@ -471,6 +371,12 @@ export declare class Core extends events.EventEmitter {
471
371
  * @returns {String} Current secret
472
372
  */
473
373
  getSecret(): string;
374
+ /**
375
+ * Retrieve a HMAC for a string
376
+ * @param data
377
+ * @returns
378
+ */
379
+ getHmac(data: string): Promise<string>;
474
380
  /**
475
381
  * Return a salt to use when doing digest
476
382
  *
@@ -488,11 +394,11 @@ export declare class Core extends events.EventEmitter {
488
394
  *
489
395
  * @abstract
490
396
  */
491
- flushHeaders(context: Context): void;
397
+ flushHeaders(_context: Context): void;
492
398
  /**
493
399
  * Flush the entire response to the client
494
400
  */
495
- flush(context: Context): void;
401
+ flush(_context: Context): void;
496
402
  /**
497
403
  * Return if Webda is in debug mode
498
404
  */
@@ -539,6 +445,9 @@ export declare class Core extends events.EventEmitter {
539
445
  */
540
446
  protected autoConnectServices(): void;
541
447
  protected jsonFilter(key: string, value: any): any;
448
+ /**
449
+ * Init services and Beans along with Routes
450
+ */
542
451
  initStatics(): void;
543
452
  /**
544
453
  * Init Routes declare by @Route annotation
@@ -561,10 +470,29 @@ export declare class Core extends events.EventEmitter {
561
470
  * @return {String} The export of the strip object ( removed all attribute with _ )
562
471
  */
563
472
  toPublicJSON(object: any): string;
473
+ /**
474
+ * Return a UUID
475
+ *
476
+ * @param format to return different type of format
477
+ * Plan to implement base64 and maybe base85
478
+ */
479
+ getUuid(format?: "ascii" | "base64" | "hex" | "binary" | "uuid"): string;
480
+ /**
481
+ * @override
482
+ */
483
+ emit<K extends keyof E>(eventType: K | symbol | string, event?: E[K], ...data: any[]): boolean;
564
484
  /**
565
485
  * Emit the event with data and wait for Promise to finish if listener returned a Promise
566
486
  */
567
- emitSync<T = any>(eventType: string, event?: T, ...data: any[]): Promise<any[]>;
487
+ emitSync<K extends keyof E>(eventType: K | symbol, event?: E[K], ...data: any[]): Promise<any[]>;
488
+ /**
489
+ * Type the listener part
490
+ * @param event
491
+ * @param listener
492
+ * @param queue
493
+ * @returns
494
+ */
495
+ on<Key extends keyof E>(event: Key | symbol, listener: (evt: E[Key]) => void): this;
568
496
  /**
569
497
  * Logs
570
498
  * @param level
@@ -576,10 +504,17 @@ export declare class Core extends events.EventEmitter {
576
504
  */
577
505
  parameter(name: string): any;
578
506
  /**
579
- * Verify if an origin is allowed to do request on the API
507
+ * Verify if a request can be done
580
508
  *
581
509
  * @param context Context of the request
582
510
  */
583
511
  protected checkRequest(ctx: Context): Promise<boolean>;
512
+ /**
513
+ * Verify if an origin is allowed to do request on the API
514
+ *
515
+ * @param context Context of the request
516
+ */
517
+ protected checkCORSRequest(ctx: Context): Promise<boolean>;
584
518
  exportOpenAPI(skipHidden?: boolean): OpenAPIV3.Document;
585
519
  }
520
+ export {};