@webda/core 1.6.0-beta.2 → 2.0.0-beta.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 (253) hide show
  1. package/lib/application.d.ts +351 -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 +108 -214
  7. package/lib/core.js +169 -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 +11 -18
  20. package/lib/models/coremodel.js +36 -36
  21. package/lib/models/coremodel.js.map +1 -1
  22. package/lib/models/coremodel.spec.js +2 -2
  23. package/lib/models/coremodel.spec.js.map +1 -1
  24. package/lib/models/ident.d.ts +3 -3
  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 +8 -4
  30. package/lib/models/ownermodel.js +9 -4
  31. package/lib/models/ownermodel.js.map +1 -1
  32. package/lib/models/ownermodel.spec.js +1 -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 +4 -3
  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 +48 -2
  59. package/lib/router.js +78 -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 +40 -16
  106. package/lib/services/filebinary.js +142 -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 +10 -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 +22 -25
  147. package/lib/services/service.js +16 -22
  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 +4 -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 +137 -26
  177. package/lib/stores/store.js +431 -75
  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 +49 -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 +157 -0
  222. package/lib/utils/httpcontext.js +279 -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 +82 -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 Ajv from "ajv";
2
3
  import * as events from "events";
3
- import { JSONSchema6 } from "json-schema";
4
4
  import { OpenAPIV3 } from "openapi-types";
5
5
  import * as vm from "vm";
6
- import { Application } from "./application";
6
+ import { Application, Configuration } from "./application";
7
7
  import { Context, HttpContext, Logger, Service } from "./index";
8
8
  import { CoreModel, CoreModelDefinition } from "./models/coremodel";
9
- import { RouteInfo, Router } from "./router";
9
+ import { OpenAPIWebdaDefinition, RouteInfo, Router } from "./router";
10
10
  import { WorkerOutput, WorkerLogLevel } from "@webda/workout";
11
- import { AbstractDeployer } from "./utils/abstractdeployer";
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,39 @@ 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
+ "Webda.Init.Services": {
85
+ [key: string]: Service;
86
+ };
87
+ "Webda.Create.Services": {
88
+ [key: string]: Service;
89
+ };
90
+ "Webda.Init": Configuration;
91
+ "Webda.NewContext": Context;
92
+ [key: string]: unknown;
93
+ };
94
+ declare type NoSchemaResult = null;
95
+ declare type SchemaValidResult = true;
256
96
  /**
257
97
  * This is the main class of the framework, it handles the routing, the services initialization and resolution
258
98
  *
259
99
  * @class Core
260
100
  * @category CoreFeatures
261
101
  */
262
- export declare class Core extends events.EventEmitter {
102
+ export declare class Core<E extends CoreEvents = CoreEvents> extends events.EventEmitter {
263
103
  /**
264
104
  * Webda Services
265
105
  * @hidden
@@ -286,11 +126,14 @@ export declare class Core extends events.EventEmitter {
286
126
  /**
287
127
  * JSON Schema validator instance
288
128
  */
289
- protected _ajv: any;
129
+ protected _ajv: Ajv;
290
130
  /**
291
131
  * JSON Schema registry
132
+ * Save if a schema was added to Ajv already
292
133
  */
293
- protected _ajvSchemas: any;
134
+ protected _ajvSchemas: {
135
+ [key: string]: true;
136
+ };
294
137
  /**
295
138
  * Current executor
296
139
  */
@@ -304,17 +147,34 @@ export declare class Core extends events.EventEmitter {
304
147
  */
305
148
  protected logger: Logger;
306
149
  /**
307
- * CORS Filter registry
150
+ * Request Filter registry
308
151
  *
309
152
  * Added via [[Webda.registerRequestFilter]]
310
153
  * See [[CorsFilter]]
311
154
  */
312
155
  protected _requestFilters: RequestFilter<Context>[];
156
+ /**
157
+ * CORS Filter registry
158
+ *
159
+ * Added via [[Webda.registerCORSRequestFilter]]
160
+ * See [[CorsFilter]]
161
+ */
162
+ protected _requestCORSFilters: RequestFilter<Context>[];
313
163
  private workerOutput;
164
+ /**
165
+ * Store the instance id
166
+ */
167
+ private instanceId;
314
168
  /**
315
169
  * @params {Object} config - The configuration Object, if undefined will load the configuration file
316
170
  */
317
171
  constructor(application: Application);
172
+ /**
173
+ * Return Core instance id
174
+ *
175
+ * It is a random generated string
176
+ */
177
+ getInstanceId(): string;
318
178
  /**
319
179
  * Get absolute url with subpath
320
180
  * @param subpath
@@ -336,13 +196,7 @@ export declare class Core extends events.EventEmitter {
336
196
  /**
337
197
  * Retrieve all detected modules definition
338
198
  */
339
- getModules(): CachedModule;
340
- /**
341
- * Retrieve all deployers
342
- */
343
- getDeployers(): {
344
- [key: string]: import("./application").ServiceConstructor<Service<import("./index").ServiceParameters>>;
345
- };
199
+ getModules(): import("./application").CachedModule;
346
200
  /**
347
201
  * Return application definition
348
202
  */
@@ -362,7 +216,20 @@ export declare class Core extends events.EventEmitter {
362
216
  * It will resolve Services init method and autolink
363
217
  */
364
218
  init(): Promise<void>;
219
+ /**
220
+ * Register a request filtering
221
+ *
222
+ * Will apply to all requests regardless of the devMode
223
+ * @param filter
224
+ */
365
225
  registerRequestFilter(filter: RequestFilter<Context>): void;
226
+ /**
227
+ * Register a CORS request filtering
228
+ *
229
+ * Does not apply in devMode
230
+ * @param filter
231
+ */
232
+ registerCORSFilter(filter: RequestFilter<Context>): void;
366
233
  /**
367
234
  *
368
235
  * @param {Object} executor The executor to expose as executor
@@ -375,11 +242,7 @@ export declare class Core extends events.EventEmitter {
375
242
  * @param schema path to use
376
243
  * @param object to validate
377
244
  */
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;
245
+ validateSchema(webdaObject: CoreModel | string, object: any): NoSchemaResult | SchemaValidResult;
383
246
  /**
384
247
  * Return webda current version
385
248
  *
@@ -433,7 +296,7 @@ export declare class Core extends events.EventEmitter {
433
296
  * @param type The type of implementation
434
297
  * @returns {{}}
435
298
  */
436
- getServicesImplementations(type?: any): {
299
+ getServicesOfType(type?: any): {
437
300
  [key: string]: Service;
438
301
  };
439
302
  getConfiguration(): Configuration;
@@ -451,10 +314,6 @@ export declare class Core extends events.EventEmitter {
451
314
  getModels(): {
452
315
  [key: string]: CoreModelDefinition;
453
316
  };
454
- /**
455
- * Register model
456
- */
457
- registerModel(name: string, clazz: any): void;
458
317
  /**
459
318
  * Check for a model name and return the wanted class or throw exception if none found
460
319
  *
@@ -471,6 +330,12 @@ export declare class Core extends events.EventEmitter {
471
330
  * @returns {String} Current secret
472
331
  */
473
332
  getSecret(): string;
333
+ /**
334
+ * Retrieve a HMAC for a string
335
+ * @param data
336
+ * @returns
337
+ */
338
+ getHmac(data: string): Promise<string>;
474
339
  /**
475
340
  * Return a salt to use when doing digest
476
341
  *
@@ -488,11 +353,11 @@ export declare class Core extends events.EventEmitter {
488
353
  *
489
354
  * @abstract
490
355
  */
491
- flushHeaders(context: Context): void;
356
+ flushHeaders(_context: Context): void;
492
357
  /**
493
358
  * Flush the entire response to the client
494
359
  */
495
- flush(context: Context): void;
360
+ flush(_context: Context): void;
496
361
  /**
497
362
  * Return if Webda is in debug mode
498
363
  */
@@ -539,6 +404,9 @@ export declare class Core extends events.EventEmitter {
539
404
  */
540
405
  protected autoConnectServices(): void;
541
406
  protected jsonFilter(key: string, value: any): any;
407
+ /**
408
+ * Init services and Beans along with Routes
409
+ */
542
410
  initStatics(): void;
543
411
  /**
544
412
  * Init Routes declare by @Route annotation
@@ -561,10 +429,29 @@ export declare class Core extends events.EventEmitter {
561
429
  * @return {String} The export of the strip object ( removed all attribute with _ )
562
430
  */
563
431
  toPublicJSON(object: any): string;
432
+ /**
433
+ * Return a UUID
434
+ *
435
+ * @param format to return different type of format
436
+ * Plan to implement base64 and maybe base85
437
+ */
438
+ getUuid(format?: "ascii" | "base64" | "hex" | "binary" | "uuid"): string;
439
+ /**
440
+ * @override
441
+ */
442
+ emit<K extends keyof E>(eventType: K | symbol | string, event?: E[K], ...data: any[]): boolean;
564
443
  /**
565
444
  * Emit the event with data and wait for Promise to finish if listener returned a Promise
566
445
  */
567
- emitSync<T = any>(eventType: string, event?: T, ...data: any[]): Promise<any[]>;
446
+ emitSync<K extends keyof E>(eventType: K | symbol, event?: E[K], ...data: any[]): Promise<any[]>;
447
+ /**
448
+ * Type the listener part
449
+ * @param event
450
+ * @param listener
451
+ * @param queue
452
+ * @returns
453
+ */
454
+ on<Key extends keyof E>(event: Key | symbol, listener: (evt: E[Key]) => void): this;
568
455
  /**
569
456
  * Logs
570
457
  * @param level
@@ -576,10 +463,17 @@ export declare class Core extends events.EventEmitter {
576
463
  */
577
464
  parameter(name: string): any;
578
465
  /**
579
- * Verify if an origin is allowed to do request on the API
466
+ * Verify if a request can be done
580
467
  *
581
468
  * @param context Context of the request
582
469
  */
583
470
  protected checkRequest(ctx: Context): Promise<boolean>;
471
+ /**
472
+ * Verify if an origin is allowed to do request on the API
473
+ *
474
+ * @param context Context of the request
475
+ */
476
+ protected checkCORSRequest(ctx: Context): Promise<boolean>;
584
477
  exportOpenAPI(skipHidden?: boolean): OpenAPIV3.Document;
585
478
  }
479
+ export {};