@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.
- package/lib/application.d.ts +317 -195
- package/lib/application.js +171 -674
- package/lib/application.js.map +1 -1
- package/lib/application.spec.js +97 -289
- package/lib/application.spec.js.map +1 -1
- package/lib/core.d.ts +102 -214
- package/lib/core.js +146 -70
- package/lib/core.js.map +1 -1
- package/lib/core.spec.js +80 -17
- package/lib/core.spec.js.map +1 -1
- package/lib/index.d.ts +14 -9
- package/lib/index.js +19 -10
- package/lib/index.js.map +1 -1
- package/lib/models/aclmodel.d.ts +29 -8
- package/lib/models/aclmodel.js +68 -18
- package/lib/models/aclmodel.js.map +1 -1
- package/lib/models/aclmodel.spec.js +56 -19
- package/lib/models/aclmodel.spec.js.map +1 -1
- package/lib/models/coremodel.d.ts +9 -17
- package/lib/models/coremodel.js +36 -36
- package/lib/models/coremodel.js.map +1 -1
- package/lib/models/ident.d.ts +8 -3
- package/lib/models/ident.js +8 -1
- package/lib/models/ident.js.map +1 -1
- package/lib/models/ident.spec.js +3 -0
- package/lib/models/ident.spec.js.map +1 -1
- package/lib/models/ownermodel.d.ts +8 -4
- package/lib/models/ownermodel.js +10 -6
- package/lib/models/ownermodel.js.map +1 -1
- package/lib/models/rolemodel.js.map +1 -1
- package/lib/models/rolemodel.spec.js +4 -1
- package/lib/models/rolemodel.spec.js.map +1 -1
- package/lib/models/user.d.ts +32 -3
- package/lib/models/user.js +31 -0
- package/lib/models/user.js.map +1 -1
- package/lib/models/user.spec.js +11 -0
- package/lib/models/user.spec.js.map +1 -1
- package/lib/queues/filequeue.d.ts +2 -7
- package/lib/queues/filequeue.js +2 -11
- package/lib/queues/filequeue.js.map +1 -1
- package/lib/queues/filequeue.spec.js +0 -1
- package/lib/queues/filequeue.spec.js.map +1 -1
- package/lib/queues/memoryqueue.d.ts +2 -7
- package/lib/queues/memoryqueue.js +1 -11
- package/lib/queues/memoryqueue.js.map +1 -1
- package/lib/queues/memoryqueue.spec.js +0 -1
- package/lib/queues/memoryqueue.spec.js.map +1 -1
- package/lib/queues/queue.spec.d.ts +1 -1
- package/lib/queues/queue.spec.js +11 -9
- package/lib/queues/queue.spec.js.map +1 -1
- package/lib/queues/queueservice.js +1 -1
- package/lib/queues/queueservice.js.map +1 -1
- package/lib/router.d.ts +46 -1
- package/lib/router.js +89 -51
- package/lib/router.js.map +1 -1
- package/lib/router.spec.js +19 -2
- package/lib/router.spec.js.map +1 -1
- package/lib/services/asyncevents.d.ts +1 -0
- package/lib/services/asyncevents.js +4 -3
- package/lib/services/asyncevents.js.map +1 -1
- package/lib/services/authentication.d.ts +47 -5
- package/lib/services/authentication.js +99 -40
- package/lib/services/authentication.js.map +1 -1
- package/lib/services/authentication.spec.js +10 -0
- package/lib/services/authentication.spec.js.map +1 -1
- package/lib/services/binary.d.ts +126 -64
- package/lib/services/binary.js +247 -96
- package/lib/services/binary.js.map +1 -1
- package/lib/services/binary.spec.d.ts +1 -0
- package/lib/services/binary.spec.js +96 -25
- package/lib/services/binary.spec.js.map +1 -1
- package/lib/services/cloudbinary.d.ts +67 -0
- package/lib/services/cloudbinary.js +178 -0
- package/lib/services/cloudbinary.js.map +1 -0
- package/lib/services/cloudbinary.spec.d.ts +13 -0
- package/lib/services/cloudbinary.spec.js +205 -0
- package/lib/services/cloudbinary.spec.js.map +1 -0
- package/lib/services/configuration.d.ts +7 -2
- package/lib/services/configuration.js +4 -3
- package/lib/services/configuration.js.map +1 -1
- package/lib/services/configuration.spec.js +1 -0
- package/lib/services/configuration.spec.js.map +1 -1
- package/lib/services/cron.d.ts +5 -6
- package/lib/services/cron.js +4 -11
- package/lib/services/cron.js.map +1 -1
- package/lib/services/cron.spec.js +2 -3
- package/lib/services/cron.spec.js.map +1 -1
- package/lib/services/debugmailer.d.ts +11 -6
- package/lib/services/debugmailer.js +20 -14
- package/lib/services/debugmailer.js.map +1 -1
- package/lib/services/debugmailer.spec.js +1 -0
- package/lib/services/debugmailer.spec.js.map +1 -1
- package/lib/services/echo.d.ts +2 -6
- package/lib/services/echo.js +1 -11
- package/lib/services/echo.js.map +1 -1
- package/lib/services/echo.spec.js +1 -0
- package/lib/services/echo.spec.js.map +1 -1
- package/lib/services/filebinary.d.ts +36 -12
- package/lib/services/filebinary.js +123 -38
- package/lib/services/filebinary.js.map +1 -1
- package/lib/services/filebinary.spec.d.ts +4 -2
- package/lib/services/filebinary.spec.js +48 -8
- package/lib/services/filebinary.spec.js.map +1 -1
- package/lib/services/fileconfiguration.d.ts +1 -5
- package/lib/services/fileconfiguration.js +1 -10
- package/lib/services/fileconfiguration.js.map +1 -1
- package/lib/services/invitationservice.d.ts +198 -0
- package/lib/services/invitationservice.js +443 -0
- package/lib/services/invitationservice.js.map +1 -0
- package/lib/services/invitationservice.spec.d.ts +1 -0
- package/lib/services/invitationservice.spec.js +517 -0
- package/lib/services/invitationservice.spec.js.map +1 -0
- package/lib/services/kubernetesconfiguration.d.ts +3 -5
- package/lib/services/kubernetesconfiguration.js +5 -12
- package/lib/services/kubernetesconfiguration.js.map +1 -1
- package/lib/services/kubernetesconfiguration.spec.js +1 -1
- package/lib/services/kubernetesconfiguration.spec.js.map +1 -1
- package/lib/services/mailer.d.ts +44 -7
- package/lib/services/mailer.js +34 -14
- package/lib/services/mailer.js.map +1 -1
- package/lib/services/mailer.spec.js +29 -0
- package/lib/services/mailer.spec.js.map +1 -1
- package/lib/services/notificationservice.d.ts +76 -0
- package/lib/services/notificationservice.js +91 -0
- package/lib/services/notificationservice.js.map +1 -0
- package/lib/services/notificationservice.spec.d.ts +1 -0
- package/lib/services/notificationservice.spec.js +104 -0
- package/lib/services/notificationservice.spec.js.map +1 -0
- package/lib/services/oauth.d.ts +6 -4
- package/lib/services/oauth.js +28 -11
- package/lib/services/oauth.js.map +1 -1
- package/lib/services/oauth.spec.js +7 -10
- package/lib/services/oauth.spec.js.map +1 -1
- package/lib/services/resource.d.ts +1 -5
- package/lib/services/resource.js +22 -17
- package/lib/services/resource.js.map +1 -1
- package/lib/services/resource.spec.js +0 -1
- package/lib/services/resource.spec.js.map +1 -1
- package/lib/services/service.d.ts +29 -26
- package/lib/services/service.js +16 -22
- package/lib/services/service.js.map +1 -1
- package/lib/services/service.spec.js +3 -0
- package/lib/services/service.spec.js.map +1 -1
- package/lib/services/version.d.ts +2 -5
- package/lib/services/version.js +1 -10
- package/lib/services/version.js.map +1 -1
- package/lib/stores/aggregator.d.ts +3 -5
- package/lib/stores/aggregator.js +3 -10
- package/lib/stores/aggregator.js.map +1 -1
- package/lib/stores/file.d.ts +7 -8
- package/lib/stores/file.js +18 -18
- package/lib/stores/file.js.map +1 -1
- package/lib/stores/file.spec.js +8 -6
- package/lib/stores/file.spec.js.map +1 -1
- package/lib/stores/mapper.d.ts +1 -5
- package/lib/stores/mapper.js +56 -39
- package/lib/stores/mapper.js.map +1 -1
- package/lib/stores/mapper.spec.js +120 -1
- package/lib/stores/mapper.spec.js.map +1 -1
- package/lib/stores/memory.d.ts +5 -9
- package/lib/stores/memory.js +5 -17
- package/lib/stores/memory.js.map +1 -1
- package/lib/stores/memory.spec.d.ts +1 -0
- package/lib/stores/memory.spec.js +32 -0
- package/lib/stores/memory.spec.js.map +1 -1
- package/lib/stores/store.d.ts +131 -26
- package/lib/stores/store.js +399 -80
- package/lib/stores/store.js.map +1 -1
- package/lib/stores/store.spec.d.ts +29 -2
- package/lib/stores/store.spec.js +204 -31
- package/lib/stores/store.spec.js.map +1 -1
- package/lib/stores/webdaql/WebdaQLLexer.d.ts +53 -0
- package/lib/stores/webdaql/WebdaQLLexer.js +290 -0
- package/lib/stores/webdaql/WebdaQLLexer.js.map +1 -0
- package/lib/stores/webdaql/WebdaQLParserLexer.d.ts +53 -0
- package/lib/stores/webdaql/WebdaQLParserLexer.js +290 -0
- package/lib/stores/webdaql/WebdaQLParserLexer.js.map +1 -0
- package/lib/stores/webdaql/WebdaQLParserListener.d.ts +308 -0
- package/lib/stores/webdaql/WebdaQLParserListener.js +4 -0
- package/lib/stores/webdaql/WebdaQLParserListener.js.map +1 -0
- package/lib/stores/webdaql/WebdaQLParserParser.d.ts +301 -0
- package/lib/stores/webdaql/WebdaQLParserParser.js +1781 -0
- package/lib/stores/webdaql/WebdaQLParserParser.js.map +1 -0
- package/lib/stores/webdaql/WebdaQLParserVisitor.d.ts +198 -0
- package/lib/stores/webdaql/WebdaQLParserVisitor.js +4 -0
- package/lib/stores/webdaql/WebdaQLParserVisitor.js.map +1 -0
- package/lib/stores/webdaql/query.d.ts +300 -0
- package/lib/stores/webdaql/query.js +471 -0
- package/lib/stores/webdaql/query.js.map +1 -0
- package/lib/stores/webdaql/query.spec.d.ts +1 -0
- package/lib/stores/webdaql/query.spec.js +136 -0
- package/lib/stores/webdaql/query.spec.js.map +1 -0
- package/lib/test.d.ts +50 -2
- package/lib/test.js +161 -16
- package/lib/test.js.map +1 -1
- package/lib/unpackedapplication.d.ts +66 -0
- package/lib/unpackedapplication.js +202 -0
- package/lib/unpackedapplication.js.map +1 -0
- package/lib/utils/context.d.ts +14 -12
- package/lib/utils/context.js +14 -9
- package/lib/utils/context.js.map +1 -1
- package/lib/utils/context.spec.js +1 -1
- package/lib/utils/context.spec.js.map +1 -1
- package/lib/utils/cookie.d.ts +6 -3
- package/lib/utils/cookie.js +22 -20
- package/lib/utils/cookie.js.map +1 -1
- package/lib/utils/cookie.spec.js +0 -1
- package/lib/utils/cookie.spec.js.map +1 -1
- package/lib/utils/logger.d.ts +16 -3
- package/lib/utils/logger.js +16 -3
- package/lib/utils/logger.js.map +1 -1
- package/lib/utils/logger.spec.js.map +1 -1
- package/lib/utils/serializers.js +5 -1
- package/lib/utils/serializers.js.map +1 -1
- package/lib/utils/waiter.d.ts +1 -1
- package/lib/utils/waiter.js.map +1 -1
- package/package.json +25 -18
- package/test/config-file-no-reload.json +2 -1
- package/test/config-file-reload.json +2 -1
- package/test/config-invitation.json +63 -0
- package/test/config-kube-reload.json +2 -1
- package/test/config-reload.json +1 -1
- package/test/config.json +6 -10
- package/test/config.old.json +1 -1
- package/test/moddas/annotatedservice.js +1 -3
- package/test/moddas/debugmailer.js +2 -7
- package/test/moddas/fakeservice.js +1 -1
- package/test/moddas/voidstore.js +2 -4
- package/test/models/ident.js +1 -1
- package/test/models/task.js +1 -5
- package/webda.module.json +1124 -0
- package/test/config.old-default.json +0 -151
package/lib/test.d.ts
CHANGED
|
@@ -1,10 +1,46 @@
|
|
|
1
|
+
import { WorkerLogLevel } from "@webda/workout";
|
|
1
2
|
import { Context, Core, HttpMethodType, Service } from "./index";
|
|
3
|
+
import { CachedModule } from "./application";
|
|
4
|
+
import { UnpackedApplication } from "./unpackedapplication";
|
|
2
5
|
export declare class Executor {
|
|
3
6
|
/**
|
|
4
7
|
* Main method called by the webda framework if the route don't specify a _method
|
|
5
8
|
*/
|
|
6
9
|
execute(ctx: Context): Promise<any>;
|
|
7
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* TestApplication ensure we load the typescript sources instead of compiled version
|
|
13
|
+
*
|
|
14
|
+
* Test use ts-node so to share same prototypes we need to load from the sources
|
|
15
|
+
*/
|
|
16
|
+
export declare class TestApplication extends UnpackedApplication {
|
|
17
|
+
/**
|
|
18
|
+
* Set the status of the compilation
|
|
19
|
+
*
|
|
20
|
+
* @param compile true will avoid trigger new compilation
|
|
21
|
+
*/
|
|
22
|
+
preventCompilation(compile: boolean): void;
|
|
23
|
+
/**
|
|
24
|
+
* Flag if application has been compiled already
|
|
25
|
+
*/
|
|
26
|
+
protected compiled: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Compile the application
|
|
29
|
+
*/
|
|
30
|
+
compile(): void;
|
|
31
|
+
/**
|
|
32
|
+
* Only allow local and core module and sample-app
|
|
33
|
+
*/
|
|
34
|
+
filterModule(filename: string): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Load a webda.module.json file
|
|
37
|
+
* Resolve the linked file to current application
|
|
38
|
+
*
|
|
39
|
+
* @param moduleFile to load
|
|
40
|
+
* @returns
|
|
41
|
+
*/
|
|
42
|
+
loadWebdaModule(moduleFile: string): CachedModule;
|
|
43
|
+
}
|
|
8
44
|
/**
|
|
9
45
|
* Utility class for UnitTest
|
|
10
46
|
*
|
|
@@ -19,18 +55,29 @@ declare class WebdaTest {
|
|
|
19
55
|
* @returns absolute path to configuration file
|
|
20
56
|
*/
|
|
21
57
|
getTestConfiguration(): string;
|
|
58
|
+
/**
|
|
59
|
+
* Allow test to add custom made service
|
|
60
|
+
* @param app
|
|
61
|
+
*/
|
|
62
|
+
tweakApp(app: TestApplication): Promise<void>;
|
|
22
63
|
/**
|
|
23
64
|
* Build the webda application
|
|
24
65
|
*
|
|
25
66
|
* Add a ConsoleLogger if addConsoleLogger is true
|
|
26
67
|
*/
|
|
27
|
-
protected buildWebda(): void
|
|
68
|
+
protected buildWebda(): Promise<void>;
|
|
28
69
|
/**
|
|
29
70
|
* Rebuild Webda application before each test
|
|
30
71
|
*
|
|
31
72
|
* @param init wait for the full init
|
|
32
73
|
*/
|
|
33
74
|
before(init?: boolean): Promise<void>;
|
|
75
|
+
/**
|
|
76
|
+
*
|
|
77
|
+
* @param level
|
|
78
|
+
* @param args
|
|
79
|
+
*/
|
|
80
|
+
log(level: WorkerLogLevel, ...args: any[]): void;
|
|
34
81
|
/**
|
|
35
82
|
* Create a new Context object
|
|
36
83
|
*
|
|
@@ -52,6 +99,7 @@ declare class WebdaTest {
|
|
|
52
99
|
* @returns
|
|
53
100
|
*/
|
|
54
101
|
getExecutor(ctx?: Context, host?: string, method?: HttpMethodType, url?: string, body?: any, headers?: object): Executor;
|
|
102
|
+
execute(ctx?: Context, host?: string, method?: HttpMethodType, url?: string, body?: any, headers?: object): Promise<any>;
|
|
55
103
|
/**
|
|
56
104
|
* Pause for time ms
|
|
57
105
|
*
|
|
@@ -76,6 +124,6 @@ declare class WebdaTest {
|
|
|
76
124
|
* @param name of the service to add
|
|
77
125
|
* @param service to add
|
|
78
126
|
*/
|
|
79
|
-
registerService(
|
|
127
|
+
registerService(service: Service, name?: string): void;
|
|
80
128
|
}
|
|
81
129
|
export { WebdaTest };
|
package/lib/test.js
CHANGED
|
@@ -9,9 +9,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.WebdaTest = exports.Executor = void 0;
|
|
12
|
+
exports.WebdaTest = exports.TestApplication = exports.Executor = void 0;
|
|
13
13
|
const index_1 = require("./index");
|
|
14
14
|
const logger_1 = require("./utils/logger");
|
|
15
|
+
const path = require("path");
|
|
16
|
+
const child_process_1 = require("child_process");
|
|
17
|
+
const application_1 = require("./application");
|
|
18
|
+
const serializers_1 = require("./utils/serializers");
|
|
19
|
+
const unpackedapplication_1 = require("./unpackedapplication");
|
|
15
20
|
class Executor {
|
|
16
21
|
/**
|
|
17
22
|
* Main method called by the webda framework if the route don't specify a _method
|
|
@@ -24,6 +29,84 @@ class Executor {
|
|
|
24
29
|
}
|
|
25
30
|
}
|
|
26
31
|
exports.Executor = Executor;
|
|
32
|
+
/**
|
|
33
|
+
* TestApplication ensure we load the typescript sources instead of compiled version
|
|
34
|
+
*
|
|
35
|
+
* Test use ts-node so to share same prototypes we need to load from the sources
|
|
36
|
+
*/
|
|
37
|
+
class TestApplication extends unpackedapplication_1.UnpackedApplication {
|
|
38
|
+
constructor() {
|
|
39
|
+
super(...arguments);
|
|
40
|
+
/**
|
|
41
|
+
* Flag if application has been compiled already
|
|
42
|
+
*/
|
|
43
|
+
this.compiled = false;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Set the status of the compilation
|
|
47
|
+
*
|
|
48
|
+
* @param compile true will avoid trigger new compilation
|
|
49
|
+
*/
|
|
50
|
+
preventCompilation(compile) {
|
|
51
|
+
this.compiled = compile;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Compile the application
|
|
55
|
+
*/
|
|
56
|
+
compile() {
|
|
57
|
+
if (this.compiled) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
// exec typescript
|
|
61
|
+
this.log("DEBUG", "Compiling application");
|
|
62
|
+
try {
|
|
63
|
+
(0, child_process_1.execSync)(`tsc -p ${this.appPath}`);
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
(err.stdout.toString() + err.stderr.toString())
|
|
67
|
+
.split("\n")
|
|
68
|
+
.filter(l => l !== "")
|
|
69
|
+
.forEach(l => {
|
|
70
|
+
this.log("ERROR", "tsc:", l);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
this.compiled = true;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Only allow local and core module and sample-app
|
|
77
|
+
*/
|
|
78
|
+
filterModule(filename) {
|
|
79
|
+
// Just for cov
|
|
80
|
+
const relativePath = path.relative(process.cwd(), filename);
|
|
81
|
+
return (super.filterModule(filename) &&
|
|
82
|
+
(!relativePath.includes("..") ||
|
|
83
|
+
relativePath.startsWith("../core") ||
|
|
84
|
+
relativePath.startsWith("../../sample-app/")));
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Load a webda.module.json file
|
|
88
|
+
* Resolve the linked file to current application
|
|
89
|
+
*
|
|
90
|
+
* @param moduleFile to load
|
|
91
|
+
* @returns
|
|
92
|
+
*/
|
|
93
|
+
loadWebdaModule(moduleFile) {
|
|
94
|
+
// Test are using ts-node so local source should be loaded from .ts with ts-node aswell
|
|
95
|
+
if (process.cwd() === path.dirname(moduleFile)) {
|
|
96
|
+
let module = serializers_1.FileUtils.load(moduleFile);
|
|
97
|
+
Object.keys(application_1.SectionEnum)
|
|
98
|
+
.filter(k => Number.isNaN(+k))
|
|
99
|
+
.forEach(p => {
|
|
100
|
+
for (let key in module[application_1.SectionEnum[p]]) {
|
|
101
|
+
module[application_1.SectionEnum[p]][key] = path.join(path.relative(this.getAppPath(), path.dirname(moduleFile)), module[application_1.SectionEnum[p]][key].replace(/^lib\//, "src/"));
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
return module;
|
|
105
|
+
}
|
|
106
|
+
return super.loadWebdaModule(moduleFile);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
exports.TestApplication = TestApplication;
|
|
27
110
|
/**
|
|
28
111
|
* Utility class for UnitTest
|
|
29
112
|
*
|
|
@@ -41,19 +124,40 @@ class WebdaTest {
|
|
|
41
124
|
getTestConfiguration() {
|
|
42
125
|
return process.cwd() + "/test/config.json";
|
|
43
126
|
}
|
|
127
|
+
/**
|
|
128
|
+
* Allow test to add custom made service
|
|
129
|
+
* @param app
|
|
130
|
+
*/
|
|
131
|
+
tweakApp(app) {
|
|
132
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
133
|
+
app.addService("webdatest/voidstore", yield Promise.resolve().then(() => require("../test/moddas/voidstore")));
|
|
134
|
+
app.addService("webdatest/fakeservice", yield Promise.resolve().then(() => require("../test/moddas/fakeservice")));
|
|
135
|
+
app.addService("webdatest/mailer", yield Promise.resolve().then(() => require("../test/moddas/debugmailer")));
|
|
136
|
+
app.addModel("webdatest/task", yield Promise.resolve().then(() => require("../test/models/task")));
|
|
137
|
+
app.addModel("webdatest/ident", yield Promise.resolve().then(() => require("../test/models/ident")));
|
|
138
|
+
});
|
|
139
|
+
}
|
|
44
140
|
/**
|
|
45
141
|
* Build the webda application
|
|
46
142
|
*
|
|
47
143
|
* Add a ConsoleLogger if addConsoleLogger is true
|
|
48
144
|
*/
|
|
49
145
|
buildWebda() {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
this
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
146
|
+
var _a;
|
|
147
|
+
var _b;
|
|
148
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
149
|
+
let app = new TestApplication(this.getTestConfiguration());
|
|
150
|
+
yield app.load();
|
|
151
|
+
if (app.getConfiguration() && app.getConfiguration().parameters) {
|
|
152
|
+
(_a = (_b = app.getConfiguration().parameters).sessionSecret) !== null && _a !== void 0 ? _a : (_b.sessionSecret = "1234567890ABCDEF".repeat(16));
|
|
153
|
+
}
|
|
154
|
+
yield this.tweakApp(app);
|
|
155
|
+
this.webda = new index_1.Core(app);
|
|
156
|
+
if (this.addConsoleLogger) {
|
|
157
|
+
// @ts-ignore - Hack a ConsoleLogger in
|
|
158
|
+
this.webda.services["ConsoleLogger"] = new logger_1.ConsoleLoggerService(this.webda, "ConsoleLogger", {});
|
|
159
|
+
}
|
|
160
|
+
});
|
|
57
161
|
}
|
|
58
162
|
/**
|
|
59
163
|
* Rebuild Webda application before each test
|
|
@@ -62,12 +166,25 @@ class WebdaTest {
|
|
|
62
166
|
*/
|
|
63
167
|
before(init = true) {
|
|
64
168
|
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
-
this.buildWebda();
|
|
169
|
+
yield this.buildWebda();
|
|
66
170
|
if (init) {
|
|
67
171
|
yield this.webda.init();
|
|
68
172
|
}
|
|
69
173
|
});
|
|
70
174
|
}
|
|
175
|
+
/**
|
|
176
|
+
*
|
|
177
|
+
* @param level
|
|
178
|
+
* @param args
|
|
179
|
+
*/
|
|
180
|
+
log(level, ...args) {
|
|
181
|
+
if (this.webda) {
|
|
182
|
+
this.webda.log(level, "TEST", ...args);
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
console.log(level, "WEBDA NOT INITATED TEST", ...args);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
71
188
|
/**
|
|
72
189
|
* Create a new Context object
|
|
73
190
|
*
|
|
@@ -103,7 +220,7 @@ class WebdaTest {
|
|
|
103
220
|
}
|
|
104
221
|
if (this.webda.updateContextWithRoute(ctx)) {
|
|
105
222
|
return {
|
|
106
|
-
execute: (argCtx) => __awaiter(this, void 0, void 0, function* () {
|
|
223
|
+
execute: (argCtx = ctx) => __awaiter(this, void 0, void 0, function* () {
|
|
107
224
|
if (typeof argCtx._route._method === "function") {
|
|
108
225
|
return Promise.resolve(argCtx.getExecutor()[argCtx._route._method.name](argCtx));
|
|
109
226
|
}
|
|
@@ -111,6 +228,32 @@ class WebdaTest {
|
|
|
111
228
|
};
|
|
112
229
|
}
|
|
113
230
|
}
|
|
231
|
+
execute(ctx = undefined, host = "test.webda.io", method = "GET", url = "/", body = {}, headers = {}) {
|
|
232
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
233
|
+
const exec = this.getExecutor(ctx, host, method, url, body, headers);
|
|
234
|
+
if (!exec) {
|
|
235
|
+
throw new Error(`${method} ${url} route not found`);
|
|
236
|
+
}
|
|
237
|
+
try {
|
|
238
|
+
yield exec.execute(ctx);
|
|
239
|
+
}
|
|
240
|
+
catch (err) {
|
|
241
|
+
if (err instanceof Error) {
|
|
242
|
+
throw 500;
|
|
243
|
+
}
|
|
244
|
+
throw err;
|
|
245
|
+
}
|
|
246
|
+
let res = ctx.getResponseBody();
|
|
247
|
+
if (res) {
|
|
248
|
+
try {
|
|
249
|
+
return JSON.parse(res);
|
|
250
|
+
}
|
|
251
|
+
catch (err) {
|
|
252
|
+
return res;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
}
|
|
114
257
|
/**
|
|
115
258
|
* Pause for time ms
|
|
116
259
|
*
|
|
@@ -137,12 +280,14 @@ class WebdaTest {
|
|
|
137
280
|
* @deprecated ?
|
|
138
281
|
*/
|
|
139
282
|
consumeAllModdas() {
|
|
140
|
-
let services = this.webda.getApplication().
|
|
283
|
+
let services = this.webda.getApplication().getModdas();
|
|
284
|
+
/*
|
|
141
285
|
for (let i in services) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
286
|
+
if (services[i].getModda) {
|
|
287
|
+
services[i].getModda();
|
|
288
|
+
}
|
|
145
289
|
}
|
|
290
|
+
*/
|
|
146
291
|
}
|
|
147
292
|
/**
|
|
148
293
|
* Dynamic add a service to webda
|
|
@@ -150,10 +295,10 @@ class WebdaTest {
|
|
|
150
295
|
* @param name of the service to add
|
|
151
296
|
* @param service to add
|
|
152
297
|
*/
|
|
153
|
-
registerService(
|
|
298
|
+
registerService(service, name = service.getName()) {
|
|
154
299
|
// Have to override protected
|
|
155
300
|
// @ts-ignore
|
|
156
|
-
this.webda.services[name] = service;
|
|
301
|
+
this.webda.services[name.toLowerCase()] = service;
|
|
157
302
|
}
|
|
158
303
|
}
|
|
159
304
|
exports.WebdaTest = WebdaTest;
|
package/lib/test.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test.js","sourceRoot":"","sources":["../src/test.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,
|
|
1
|
+
{"version":3,"file":"test.js","sourceRoot":"","sources":["../src/test.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,mCAA8E;AAC9E,2CAAsD;AACtD,6BAA6B;AAC7B,iDAAyC;AACzC,+CAA0D;AAC1D,qDAAgD;AAChD,+DAA4D;AAE5D,MAAa,QAAQ;IACnB;;OAEG;IACH,OAAO,CAAC,GAAY;QAClB,IAAI,OAAO,GAAG,CAAC,MAAM,CAAC,OAAO,KAAK,UAAU,EAAE;YAC5C,OAAO,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;SACzE;QACD,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAClD,CAAC;CACF;AAVD,4BAUC;AAED;;;;GAIG;AACH,MAAa,eAAgB,SAAQ,yCAAmB;IAAxD;;QASE;;WAEG;QACO,aAAQ,GAAY,KAAK,CAAC;IA+DtC,CAAC;IA1EC;;;;OAIG;IACH,kBAAkB,CAAC,OAAgB;QACjC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAKD;;OAEG;IACH,OAAO;QACL,IAAI,IAAI,CAAC,Q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OAKG;IACH,eAAe,CAAC,OAAgB,EAAE,OAAe,OAAO,CAAC,OAAO,EAAE;QAChE,6BAA6B;QAC7B,aAAa;QACb,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,GAAG,OAAO,CAAC;IACpD,CAAC;CACF;AAEQ,8BAAS"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { WorkerOutput } from "@webda/workout";
|
|
2
|
+
import { Application, CachedModule, Configuration, GitInformation, ProjectInformation } from "./application";
|
|
3
|
+
/**
|
|
4
|
+
* Empty git information
|
|
5
|
+
*/
|
|
6
|
+
export declare const EmptyGitInformation: GitInformation;
|
|
7
|
+
/**
|
|
8
|
+
* An unpacked application load dynamically all webda.module.json
|
|
9
|
+
* And load also all the package description
|
|
10
|
+
*
|
|
11
|
+
* The normal Application is designed to load all this information from
|
|
12
|
+
* the cachedModule to avoid any unecessary action within a production environment
|
|
13
|
+
*/
|
|
14
|
+
export declare class UnpackedApplication extends Application {
|
|
15
|
+
constructor(file: string, logger?: WorkerOutput);
|
|
16
|
+
/**
|
|
17
|
+
* Load full configuration
|
|
18
|
+
*
|
|
19
|
+
* webda.config.json and complete the cachedModule
|
|
20
|
+
*
|
|
21
|
+
* @param file
|
|
22
|
+
* @returns
|
|
23
|
+
*/
|
|
24
|
+
loadConfiguration(file: string): void;
|
|
25
|
+
/**
|
|
26
|
+
* Add Moddas, Models and Deployers definitions
|
|
27
|
+
* It also add the project metadata
|
|
28
|
+
*
|
|
29
|
+
* @param configuration
|
|
30
|
+
* @returns
|
|
31
|
+
*/
|
|
32
|
+
completeConfiguration(configuration: Configuration): Configuration;
|
|
33
|
+
/**
|
|
34
|
+
* @returns empty git information
|
|
35
|
+
*/
|
|
36
|
+
getGitInformation(_name?: string, _version?: string): GitInformation;
|
|
37
|
+
/**
|
|
38
|
+
* Check package.json
|
|
39
|
+
*/
|
|
40
|
+
loadProjectInformation(): ProjectInformation;
|
|
41
|
+
/**
|
|
42
|
+
* Load all imported modules and current module
|
|
43
|
+
* It will compile module
|
|
44
|
+
* Generate the current module file
|
|
45
|
+
* Load any imported webda.module.json
|
|
46
|
+
*/
|
|
47
|
+
findModules(module: CachedModule): string[];
|
|
48
|
+
/**
|
|
49
|
+
* Only allow local and core module and sample-app
|
|
50
|
+
*/
|
|
51
|
+
filterModule(_filename: string): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Load a webda.module.json file
|
|
54
|
+
* Resolve the linked file to current application
|
|
55
|
+
*
|
|
56
|
+
* @param moduleFile to load
|
|
57
|
+
* @returns
|
|
58
|
+
*/
|
|
59
|
+
loadWebdaModule(moduleFile: string): CachedModule;
|
|
60
|
+
/**
|
|
61
|
+
* Merge all modules into one cached module
|
|
62
|
+
*
|
|
63
|
+
* @param module
|
|
64
|
+
*/
|
|
65
|
+
mergeModules(configuration: Configuration): void;
|
|
66
|
+
}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UnpackedApplication = exports.EmptyGitInformation = void 0;
|
|
4
|
+
const application_1 = require("./application");
|
|
5
|
+
const fs = require("fs");
|
|
6
|
+
const path = require("path");
|
|
7
|
+
const serializers_1 = require("./utils/serializers");
|
|
8
|
+
const deepmerge_ts_1 = require("deepmerge-ts");
|
|
9
|
+
/**
|
|
10
|
+
* Empty git information
|
|
11
|
+
*/
|
|
12
|
+
exports.EmptyGitInformation = {
|
|
13
|
+
branch: "",
|
|
14
|
+
commit: "",
|
|
15
|
+
short: "",
|
|
16
|
+
tag: "",
|
|
17
|
+
tags: [],
|
|
18
|
+
version: ""
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* An unpacked application load dynamically all webda.module.json
|
|
22
|
+
* And load also all the package description
|
|
23
|
+
*
|
|
24
|
+
* The normal Application is designed to load all this information from
|
|
25
|
+
* the cachedModule to avoid any unecessary action within a production environment
|
|
26
|
+
*/
|
|
27
|
+
class UnpackedApplication extends application_1.Application {
|
|
28
|
+
constructor(file, logger) {
|
|
29
|
+
super(file, logger);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Load full configuration
|
|
33
|
+
*
|
|
34
|
+
* webda.config.json and complete the cachedModule
|
|
35
|
+
*
|
|
36
|
+
* @param file
|
|
37
|
+
* @returns
|
|
38
|
+
*/
|
|
39
|
+
loadConfiguration(file) {
|
|
40
|
+
if (!fs.existsSync(file)) {
|
|
41
|
+
this.baseConfiguration = this.completeConfiguration({ version: 3 });
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
this.baseConfiguration = this.completeConfiguration(serializers_1.FileUtils.load(file));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Add Moddas, Models and Deployers definitions
|
|
49
|
+
* It also add the project metadata
|
|
50
|
+
*
|
|
51
|
+
* @param configuration
|
|
52
|
+
* @returns
|
|
53
|
+
*/
|
|
54
|
+
completeConfiguration(configuration) {
|
|
55
|
+
configuration.cachedModules = {
|
|
56
|
+
project: this.loadProjectInformation(),
|
|
57
|
+
beans: {},
|
|
58
|
+
deployers: {},
|
|
59
|
+
models: {},
|
|
60
|
+
schemas: {},
|
|
61
|
+
moddas: {}
|
|
62
|
+
};
|
|
63
|
+
this.mergeModules(configuration);
|
|
64
|
+
return configuration;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* @returns empty git information
|
|
68
|
+
*/
|
|
69
|
+
getGitInformation(_name, _version) {
|
|
70
|
+
return {
|
|
71
|
+
branch: "",
|
|
72
|
+
commit: "",
|
|
73
|
+
short: "",
|
|
74
|
+
tag: "",
|
|
75
|
+
tags: [],
|
|
76
|
+
version: ""
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Check package.json
|
|
81
|
+
*/
|
|
82
|
+
loadProjectInformation() {
|
|
83
|
+
var _a, _b;
|
|
84
|
+
const info = {
|
|
85
|
+
deployment: {
|
|
86
|
+
name: ""
|
|
87
|
+
},
|
|
88
|
+
package: {
|
|
89
|
+
name: "",
|
|
90
|
+
version: ""
|
|
91
|
+
},
|
|
92
|
+
git: exports.EmptyGitInformation,
|
|
93
|
+
webda: {}
|
|
94
|
+
};
|
|
95
|
+
let packageJson = path.join(this.appPath, "package.json");
|
|
96
|
+
if (fs.existsSync(packageJson)) {
|
|
97
|
+
info.package = JSON.parse(fs.readFileSync(packageJson).toString());
|
|
98
|
+
}
|
|
99
|
+
info.git = this.getGitInformation((_a = info.package) === null || _a === void 0 ? void 0 : _a.name, (_b = info.package) === null || _b === void 0 ? void 0 : _b.version);
|
|
100
|
+
info.webda = info.package.webda || {};
|
|
101
|
+
let parent = path.join(this.appPath, "..");
|
|
102
|
+
do {
|
|
103
|
+
packageJson = path.join(parent, "package.json");
|
|
104
|
+
if (fs.existsSync(packageJson)) {
|
|
105
|
+
let currentInfo = JSON.parse(fs.readFileSync(packageJson).toString());
|
|
106
|
+
if (currentInfo.workspaces) {
|
|
107
|
+
this.log("DEBUG", "Application is running within a workspace");
|
|
108
|
+
// Replace any relative path by absolute one
|
|
109
|
+
for (let i in currentInfo.webda) {
|
|
110
|
+
if (currentInfo.webda[i].startsWith("./")) {
|
|
111
|
+
currentInfo.webda[i] = path.resolve(parent) + "/" + currentInfo.webda[i].substr(2);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
info.webda = (0, deepmerge_ts_1.deepmerge)(currentInfo.webda || {}, info.webda);
|
|
115
|
+
info.webda.workspaces = {
|
|
116
|
+
packages: currentInfo.workspaces,
|
|
117
|
+
parent: currentInfo,
|
|
118
|
+
path: path.resolve(parent)
|
|
119
|
+
};
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
parent = path.join(parent, "..");
|
|
124
|
+
} while (path.resolve(parent) !== "/");
|
|
125
|
+
// Check modules
|
|
126
|
+
return info;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Load all imported modules and current module
|
|
130
|
+
* It will compile module
|
|
131
|
+
* Generate the current module file
|
|
132
|
+
* Load any imported webda.module.json
|
|
133
|
+
*/
|
|
134
|
+
findModules(module) {
|
|
135
|
+
const Finder = require("fs-finder");
|
|
136
|
+
// Modules should be cached on deploy
|
|
137
|
+
var files = [];
|
|
138
|
+
let nodeModules = this.getAppPath("node_modules");
|
|
139
|
+
if (fs.existsSync(nodeModules)) {
|
|
140
|
+
files = Finder.from(nodeModules).findFiles("webda.module.json");
|
|
141
|
+
}
|
|
142
|
+
// Search workspace for webda.module.json
|
|
143
|
+
if (module.project.webda.workspaces && module.project.webda.workspaces.path !== "") {
|
|
144
|
+
nodeModules = path.join(module.project.webda.workspaces.path, "node_modules");
|
|
145
|
+
if (fs.existsSync(nodeModules)) {
|
|
146
|
+
files.push(...Finder.from(nodeModules).findFiles("webda.module.json"));
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
let currentModule = this.getAppPath("webda.module.json");
|
|
150
|
+
if (fs.existsSync(currentModule)) {
|
|
151
|
+
files.push(currentModule);
|
|
152
|
+
}
|
|
153
|
+
// Ensure we are not adding many times the same modules
|
|
154
|
+
return Array.from(new Set(files.map(n => fs.realpathSync(n)))).filter(f => this.filterModule(f));
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Only allow local and core module and sample-app
|
|
158
|
+
*/
|
|
159
|
+
filterModule(_filename) {
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Load a webda.module.json file
|
|
164
|
+
* Resolve the linked file to current application
|
|
165
|
+
*
|
|
166
|
+
* @param moduleFile to load
|
|
167
|
+
* @returns
|
|
168
|
+
*/
|
|
169
|
+
loadWebdaModule(moduleFile) {
|
|
170
|
+
let module = serializers_1.FileUtils.load(moduleFile);
|
|
171
|
+
Object.keys(application_1.SectionEnum)
|
|
172
|
+
.filter(k => Number.isNaN(+k))
|
|
173
|
+
.forEach(p => {
|
|
174
|
+
for (let key in module[application_1.SectionEnum[p]]) {
|
|
175
|
+
module[application_1.SectionEnum[p]][key] = path.join(path.relative(this.getAppPath(), path.dirname(moduleFile)), module[application_1.SectionEnum[p]][key]);
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
return module;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Merge all modules into one cached module
|
|
182
|
+
*
|
|
183
|
+
* @param module
|
|
184
|
+
*/
|
|
185
|
+
mergeModules(configuration) {
|
|
186
|
+
const module = configuration.cachedModules;
|
|
187
|
+
let files = new Set(this.findModules(module).map(f => fs.realpathSync(f)));
|
|
188
|
+
let value = Array.from(files)
|
|
189
|
+
.map(f => this.loadWebdaModule(f))
|
|
190
|
+
.reduce((prev, val) => {
|
|
191
|
+
return (0, deepmerge_ts_1.deepmerge)(prev, val);
|
|
192
|
+
}, module);
|
|
193
|
+
Object.keys(application_1.SectionEnum)
|
|
194
|
+
.filter(k => Number.isNaN(+k))
|
|
195
|
+
.forEach(p => {
|
|
196
|
+
module[application_1.SectionEnum[p]] = value[application_1.SectionEnum[p]];
|
|
197
|
+
});
|
|
198
|
+
module.schemas = value.schemas;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
exports.UnpackedApplication = UnpackedApplication;
|
|
202
|
+
//# sourceMappingURL=unpackedapplication.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unpackedapplication.js","sourceRoot":"","sources":["../src/unpackedapplication.ts"],"names":[],"mappings":";;;AACA,+CAOuB;AACvB,yBAAyB;AACzB,6BAA6B;AAC7B,qDAAgD;AAChD,+CAAyC;AAEzC;;GAEG;AACU,QAAA,mBAAmB,GAAmB;IACjD,MAAM,EAAE,EAAE;IACV,MAAM,EAAE,EAAE;IACV,KAAK,EAAE,EAAE;IACT,GAAG,EAAE,EAAE;IACP,IAAI,EAAE,EAAE;IACR,OAAO,EAAE,EAAE;CACZ,CAAC;AAEF;;;;;;GAMG;AACH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