@alterior/runtime 3.13.3 → 3.13.4
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/dist/app-options.d.ts +65 -65
- package/dist/app-options.js +26 -26
- package/dist/app-options.js.map +1 -1
- package/dist/application.d.ts +52 -52
- package/dist/application.js +172 -171
- package/dist/application.js.map +1 -1
- package/dist/args.d.ts +7 -7
- package/dist/args.js +13 -13
- package/dist/expose.d.ts +12 -12
- package/dist/expose.d.ts.map +1 -1
- package/dist/expose.js +36 -36
- package/dist/expose.js.map +1 -1
- package/dist/index.d.ts +9 -9
- package/dist/index.js +12 -12
- package/dist/lifecycle.d.ts +24 -24
- package/dist/lifecycle.js +2 -2
- package/dist/module.test.d.ts +1 -1
- package/dist/modules.d.ts +120 -120
- package/dist/modules.js +282 -282
- package/dist/modules.js.map +1 -1
- package/dist/reflector.d.ts +123 -123
- package/dist/reflector.js +306 -306
- package/dist/reflector.js.map +1 -1
- package/dist/roles.service.d.ts +79 -79
- package/dist/roles.service.js +124 -124
- package/dist/roles.service.js.map +1 -1
- package/dist/service.d.ts +24 -24
- package/dist/service.js +19 -19
- package/dist/service.js.map +1 -1
- package/dist/test.d.ts +1 -1
- package/dist.esm/app-options.d.ts +65 -65
- package/dist.esm/app-options.js +23 -23
- package/dist.esm/app-options.js.map +1 -1
- package/dist.esm/application.d.ts +52 -52
- package/dist.esm/application.js +167 -166
- package/dist.esm/application.js.map +1 -1
- package/dist.esm/args.d.ts +7 -7
- package/dist.esm/args.js +9 -9
- package/dist.esm/expose.d.ts +12 -12
- package/dist.esm/expose.d.ts.map +1 -1
- package/dist.esm/expose.js +31 -31
- package/dist.esm/expose.js.map +1 -1
- package/dist.esm/index.d.ts +9 -9
- package/dist.esm/index.js +9 -9
- package/dist.esm/lifecycle.d.ts +24 -24
- package/dist.esm/lifecycle.js +1 -1
- package/dist.esm/module.test.d.ts +1 -1
- package/dist.esm/modules.d.ts +120 -120
- package/dist.esm/modules.js +276 -276
- package/dist.esm/modules.js.map +1 -1
- package/dist.esm/reflector.d.ts +123 -123
- package/dist.esm/reflector.js +296 -296
- package/dist.esm/reflector.js.map +1 -1
- package/dist.esm/roles.service.d.ts +79 -79
- package/dist.esm/roles.service.js +121 -121
- package/dist.esm/roles.service.js.map +1 -1
- package/dist.esm/service.d.ts +24 -24
- package/dist.esm/service.js +15 -15
- package/dist.esm/service.js.map +1 -1
- package/dist.esm/test.d.ts +1 -1
- package/package.json +9 -9
- package/src/application.ts +1 -1
- package/tsconfig.esm.tsbuildinfo +1 -0
- package/tsconfig.json +0 -2
- package/tsconfig.tsbuildinfo +1 -5546
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
import { Annotation } from '@alterior/annotations';
|
|
2
|
-
import { Injector, Provider } from '@alterior/di';
|
|
3
|
-
export interface ApplicationOptions {
|
|
4
|
-
/**
|
|
5
|
-
* Specify a human readable name for your application.
|
|
6
|
-
*/
|
|
7
|
-
name?: string;
|
|
8
|
-
/**
|
|
9
|
-
* Version of the service
|
|
10
|
-
*/
|
|
11
|
-
version?: string;
|
|
12
|
-
/**
|
|
13
|
-
* The computer-readable name for your application. Should match your NPM package name.
|
|
14
|
-
*/
|
|
15
|
-
packageName?: string;
|
|
16
|
-
/**
|
|
17
|
-
* A long-form description for your application, when necessary. If you implement only one,
|
|
18
|
-
* implement summary instead.
|
|
19
|
-
*/
|
|
20
|
-
description?: string;
|
|
21
|
-
/**
|
|
22
|
-
* A shorter-form description for your application, when necessary. If you implement only one,
|
|
23
|
-
* implement this instead of description.
|
|
24
|
-
*/
|
|
25
|
-
summary?: string;
|
|
26
|
-
/**
|
|
27
|
-
* A set of string tags related to your application.
|
|
28
|
-
*/
|
|
29
|
-
tags?: string[];
|
|
30
|
-
group?: string;
|
|
31
|
-
/**
|
|
32
|
-
* Enable verbose console logging for Alterior
|
|
33
|
-
*/
|
|
34
|
-
verbose?: boolean;
|
|
35
|
-
/**
|
|
36
|
-
* Whether to start the service immediately on startup.
|
|
37
|
-
* Defaults to true.
|
|
38
|
-
*/
|
|
39
|
-
autostart?: boolean;
|
|
40
|
-
/**
|
|
41
|
-
* Turn off all console output
|
|
42
|
-
*/
|
|
43
|
-
silent?: boolean;
|
|
44
|
-
/**
|
|
45
|
-
* Additional dependency injection providers to include in the application's injector.
|
|
46
|
-
*/
|
|
47
|
-
providers?: Provider[];
|
|
48
|
-
/**
|
|
49
|
-
* An injector to use as the parent of the application injector. Optional, useful when doing more complex
|
|
50
|
-
* application bootstrapping.
|
|
51
|
-
*/
|
|
52
|
-
parentInjector?: Injector;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Used to attach an ApplicationOptions object onto a class definition.
|
|
56
|
-
*/
|
|
57
|
-
export declare class AppOptionsAnnotation extends Annotation {
|
|
58
|
-
readonly options?: ApplicationOptions;
|
|
59
|
-
constructor(options?: ApplicationOptions);
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Use this decorator to define the options for your application,
|
|
63
|
-
* either on the entry module, or service class when using `@alterior/web-server`.
|
|
64
|
-
*/
|
|
65
|
-
export declare const AppOptions: (options?: ApplicationOptions) => ClassDecorator;
|
|
1
|
+
import { Annotation } from '@alterior/annotations';
|
|
2
|
+
import { Injector, Provider } from '@alterior/di';
|
|
3
|
+
export interface ApplicationOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Specify a human readable name for your application.
|
|
6
|
+
*/
|
|
7
|
+
name?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Version of the service
|
|
10
|
+
*/
|
|
11
|
+
version?: string;
|
|
12
|
+
/**
|
|
13
|
+
* The computer-readable name for your application. Should match your NPM package name.
|
|
14
|
+
*/
|
|
15
|
+
packageName?: string;
|
|
16
|
+
/**
|
|
17
|
+
* A long-form description for your application, when necessary. If you implement only one,
|
|
18
|
+
* implement summary instead.
|
|
19
|
+
*/
|
|
20
|
+
description?: string;
|
|
21
|
+
/**
|
|
22
|
+
* A shorter-form description for your application, when necessary. If you implement only one,
|
|
23
|
+
* implement this instead of description.
|
|
24
|
+
*/
|
|
25
|
+
summary?: string;
|
|
26
|
+
/**
|
|
27
|
+
* A set of string tags related to your application.
|
|
28
|
+
*/
|
|
29
|
+
tags?: string[];
|
|
30
|
+
group?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Enable verbose console logging for Alterior
|
|
33
|
+
*/
|
|
34
|
+
verbose?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Whether to start the service immediately on startup.
|
|
37
|
+
* Defaults to true.
|
|
38
|
+
*/
|
|
39
|
+
autostart?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Turn off all console output
|
|
42
|
+
*/
|
|
43
|
+
silent?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Additional dependency injection providers to include in the application's injector.
|
|
46
|
+
*/
|
|
47
|
+
providers?: Provider[];
|
|
48
|
+
/**
|
|
49
|
+
* An injector to use as the parent of the application injector. Optional, useful when doing more complex
|
|
50
|
+
* application bootstrapping.
|
|
51
|
+
*/
|
|
52
|
+
parentInjector?: Injector;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Used to attach an ApplicationOptions object onto a class definition.
|
|
56
|
+
*/
|
|
57
|
+
export declare class AppOptionsAnnotation extends Annotation {
|
|
58
|
+
readonly options?: ApplicationOptions;
|
|
59
|
+
constructor(options?: ApplicationOptions);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Use this decorator to define the options for your application,
|
|
63
|
+
* either on the entry module, or service class when using `@alterior/web-server`.
|
|
64
|
+
*/
|
|
65
|
+
export declare const AppOptions: (options?: ApplicationOptions) => ClassDecorator;
|
|
66
66
|
//# sourceMappingURL=app-options.d.ts.map
|
package/dist.esm/app-options.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { __decorate, __metadata } from "tslib";
|
|
2
|
-
import { Annotation, MetadataName } from '@alterior/annotations';
|
|
3
|
-
/**
|
|
4
|
-
* Used to attach an ApplicationOptions object onto a class definition.
|
|
5
|
-
*/
|
|
6
|
-
let AppOptionsAnnotation = class AppOptionsAnnotation extends Annotation {
|
|
7
|
-
constructor(options) {
|
|
8
|
-
super();
|
|
9
|
-
this.options = options;
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
AppOptionsAnnotation = __decorate([
|
|
13
|
-
MetadataName('@alterior/di:Application'),
|
|
14
|
-
__metadata("design:paramtypes", [Object])
|
|
15
|
-
], AppOptionsAnnotation);
|
|
16
|
-
export { AppOptionsAnnotation };
|
|
17
|
-
/**
|
|
18
|
-
* Use this decorator to define the options for your application,
|
|
19
|
-
* either on the entry module, or service class when using `@alterior/web-server`.
|
|
20
|
-
*/
|
|
21
|
-
export const AppOptions = AppOptionsAnnotation.decorator({
|
|
22
|
-
validTargets: ['class']
|
|
23
|
-
});
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { Annotation, MetadataName } from '@alterior/annotations';
|
|
3
|
+
/**
|
|
4
|
+
* Used to attach an ApplicationOptions object onto a class definition.
|
|
5
|
+
*/
|
|
6
|
+
let AppOptionsAnnotation = class AppOptionsAnnotation extends Annotation {
|
|
7
|
+
constructor(options) {
|
|
8
|
+
super();
|
|
9
|
+
this.options = options;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
AppOptionsAnnotation = __decorate([
|
|
13
|
+
MetadataName('@alterior/di:Application'),
|
|
14
|
+
__metadata("design:paramtypes", [Object])
|
|
15
|
+
], AppOptionsAnnotation);
|
|
16
|
+
export { AppOptionsAnnotation };
|
|
17
|
+
/**
|
|
18
|
+
* Use this decorator to define the options for your application,
|
|
19
|
+
* either on the entry module, or service class when using `@alterior/web-server`.
|
|
20
|
+
*/
|
|
21
|
+
export const AppOptions = AppOptionsAnnotation.decorator({
|
|
22
|
+
validTargets: ['class']
|
|
23
|
+
});
|
|
24
24
|
//# sourceMappingURL=app-options.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-options.js","sourceRoot":"","sources":["../src/app-options.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAuB,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAmEtF;;GAEG;AAEI,IAAM,oBAAoB,GAA1B,MAAM,oBAAqB,SAAQ,UAAU;IACnD,YAAqB,OAA4B;QAChD,KAAK,EAAE,CAAC;QADY,YAAO,GAAP,OAAO,CAAqB;IAEjD,CAAC;CACD,CAAA;AAJY,oBAAoB;IADhC,YAAY,CAAC,0BAA0B,CAAC;;GAC5B,oBAAoB,CAIhC
|
|
1
|
+
{"version":3,"file":"app-options.js","sourceRoot":"","sources":["../src/app-options.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAuB,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAmEtF;;GAEG;AAEI,IAAM,oBAAoB,GAA1B,MAAM,oBAAqB,SAAQ,UAAU;IACnD,YAAqB,OAA4B;QAChD,KAAK,EAAE,CAAC;QADY,YAAO,GAAP,OAAO,CAAqB;IAEjD,CAAC;CACD,CAAA;AAJY,oBAAoB;IADhC,YAAY,CAAC,0BAA0B,CAAC;;GAC5B,oBAAoB,CAIhC;;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,oBAAoB,CAAC,SAAS,CAAC;IACxD,YAAY,EAAE,CAAC,OAAO,CAAC;CACvB,CAAC,CAAC"}
|
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
import 'reflect-metadata';
|
|
2
|
-
import { ApplicationOptions } from './app-options';
|
|
3
|
-
import { Runtime } from './modules';
|
|
4
|
-
export declare class ApplicationOptionsRef {
|
|
5
|
-
constructor(options: ApplicationOptions);
|
|
6
|
-
readonly options: ApplicationOptions;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Represents the current runtime execution context.
|
|
10
|
-
* This is exposed via a zone-local variable, and the Runtime
|
|
11
|
-
* populates it with useful information as it becomes available.
|
|
12
|
-
*/
|
|
13
|
-
export declare class ExecutionContext {
|
|
14
|
-
/**
|
|
15
|
-
* Retrieve the Alterior application which is currently being executed.
|
|
16
|
-
* If an application has not been bootstrapped yet, the value is null.
|
|
17
|
-
*/
|
|
18
|
-
application: Application;
|
|
19
|
-
static readonly ZONE_LOCAL_NAME = "@alterior/runtime:ExecutionContext";
|
|
20
|
-
/**
|
|
21
|
-
* Get the current execution context, if any.
|
|
22
|
-
*/
|
|
23
|
-
static get current(): ExecutionContext;
|
|
24
|
-
/**
|
|
25
|
-
* Execute the given function in a new zone which has
|
|
26
|
-
* this ExecutionContext instance as the current execution context.
|
|
27
|
-
*/
|
|
28
|
-
run<T>(callback: () => Promise<T>): Promise<T>;
|
|
29
|
-
runSync<T>(callback: () => T): T;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Handles bootstrapping the application.
|
|
33
|
-
*/
|
|
34
|
-
export declare class Application {
|
|
35
|
-
readonly runtime: Runtime;
|
|
36
|
-
private _optionsRef;
|
|
37
|
-
private _args;
|
|
38
|
-
start(): void;
|
|
39
|
-
stop(): void;
|
|
40
|
-
get injector(): import("@alterior/di").Injector;
|
|
41
|
-
inject<T>(ctor: {
|
|
42
|
-
new (...args: any[]): T;
|
|
43
|
-
}, notFoundValue?: T): T;
|
|
44
|
-
get args(): string[];
|
|
45
|
-
get options(): ApplicationOptions;
|
|
46
|
-
private static loadOptions;
|
|
47
|
-
private static validateEntryModule;
|
|
48
|
-
/**
|
|
49
|
-
* Bootstrap an Alterior application.
|
|
50
|
-
*/
|
|
51
|
-
static bootstrap(entryModule: Function, options?: ApplicationOptions): Application;
|
|
52
|
-
}
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { ApplicationOptions } from './app-options';
|
|
3
|
+
import { Runtime } from './modules';
|
|
4
|
+
export declare class ApplicationOptionsRef {
|
|
5
|
+
constructor(options: ApplicationOptions);
|
|
6
|
+
readonly options: ApplicationOptions;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Represents the current runtime execution context.
|
|
10
|
+
* This is exposed via a zone-local variable, and the Runtime
|
|
11
|
+
* populates it with useful information as it becomes available.
|
|
12
|
+
*/
|
|
13
|
+
export declare class ExecutionContext {
|
|
14
|
+
/**
|
|
15
|
+
* Retrieve the Alterior application which is currently being executed.
|
|
16
|
+
* If an application has not been bootstrapped yet, the value is null.
|
|
17
|
+
*/
|
|
18
|
+
application: Application;
|
|
19
|
+
static readonly ZONE_LOCAL_NAME = "@alterior/runtime:ExecutionContext";
|
|
20
|
+
/**
|
|
21
|
+
* Get the current execution context, if any.
|
|
22
|
+
*/
|
|
23
|
+
static get current(): ExecutionContext;
|
|
24
|
+
/**
|
|
25
|
+
* Execute the given function in a new zone which has
|
|
26
|
+
* this ExecutionContext instance as the current execution context.
|
|
27
|
+
*/
|
|
28
|
+
run<T>(callback: () => Promise<T>): Promise<T>;
|
|
29
|
+
runSync<T>(callback: () => T): T;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Handles bootstrapping the application.
|
|
33
|
+
*/
|
|
34
|
+
export declare class Application {
|
|
35
|
+
readonly runtime: Runtime;
|
|
36
|
+
private _optionsRef;
|
|
37
|
+
private _args;
|
|
38
|
+
start(): void;
|
|
39
|
+
stop(): void;
|
|
40
|
+
get injector(): import("@alterior/di").Injector;
|
|
41
|
+
inject<T>(ctor: {
|
|
42
|
+
new (...args: any[]): T;
|
|
43
|
+
}, notFoundValue?: T): T;
|
|
44
|
+
get args(): string[];
|
|
45
|
+
get options(): ApplicationOptions;
|
|
46
|
+
private static loadOptions;
|
|
47
|
+
private static validateEntryModule;
|
|
48
|
+
/**
|
|
49
|
+
* Bootstrap an Alterior application.
|
|
50
|
+
*/
|
|
51
|
+
static bootstrap(entryModule: Function, options?: ApplicationOptions): Application;
|
|
52
|
+
}
|
|
53
53
|
//# sourceMappingURL=application.d.ts.map
|
package/dist.esm/application.js
CHANGED
|
@@ -1,167 +1,168 @@
|
|
|
1
|
-
var Application_1;
|
|
2
|
-
import { __awaiter, __decorate } from "tslib";
|
|
3
|
-
import 'reflect-metadata';
|
|
4
|
-
import { Environment, Time } from '@alterior/common';
|
|
5
|
-
import { inject, Injectable, ModuleAnnotation, ReflectiveInjector } from '@alterior/di';
|
|
6
|
-
import { AppOptionsAnnotation } from './app-options';
|
|
7
|
-
import { ApplicationArgs } from './args';
|
|
8
|
-
import { Runtime } from './modules';
|
|
9
|
-
import { RolesService } from './roles.service';
|
|
10
|
-
export class ApplicationOptionsRef {
|
|
11
|
-
constructor(options) {
|
|
12
|
-
this.options = Object.assign({}, options);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Represents the current runtime execution context.
|
|
17
|
-
* This is exposed via a zone-local variable, and the Runtime
|
|
18
|
-
* populates it with useful information as it becomes available.
|
|
19
|
-
*/
|
|
20
|
-
export class ExecutionContext {
|
|
21
|
-
constructor() {
|
|
22
|
-
/**
|
|
23
|
-
* Retrieve the Alterior application which is currently being executed.
|
|
24
|
-
* If an application has not been bootstrapped yet, the value is null.
|
|
25
|
-
*/
|
|
26
|
-
this.application = null;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Get the current execution context, if any.
|
|
30
|
-
*/
|
|
31
|
-
static get current() {
|
|
32
|
-
return Zone.current.get(ExecutionContext.ZONE_LOCAL_NAME);
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Execute the given function in a new zone which has
|
|
36
|
-
* this ExecutionContext instance as the current execution context.
|
|
37
|
-
*/
|
|
38
|
-
run(callback) {
|
|
39
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
-
let zone = Zone.current.fork({
|
|
41
|
-
name: `AlteriorExecutionContext`,
|
|
42
|
-
properties: {
|
|
43
|
-
[ExecutionContext.ZONE_LOCAL_NAME]: this
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
return yield zone.run(() => callback());
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
runSync(callback) {
|
|
50
|
-
let zone = Zone.current.fork({
|
|
51
|
-
name: `AlteriorExecutionContext`,
|
|
52
|
-
properties: {
|
|
53
|
-
[ExecutionContext.ZONE_LOCAL_NAME]: this
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
return zone.run(() => callback());
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
ExecutionContext.ZONE_LOCAL_NAME = '@alterior/runtime:ExecutionContext';
|
|
60
|
-
/**
|
|
61
|
-
* Handles bootstrapping the application.
|
|
62
|
-
*/
|
|
63
|
-
let Application = Application_1 = class Application {
|
|
64
|
-
constructor() {
|
|
65
|
-
this.runtime = inject(Runtime);
|
|
66
|
-
this._optionsRef = inject(ApplicationOptionsRef);
|
|
67
|
-
this._args = inject(ApplicationArgs);
|
|
68
|
-
}
|
|
69
|
-
start() {
|
|
70
|
-
this.runtime.start();
|
|
71
|
-
}
|
|
72
|
-
stop() {
|
|
73
|
-
this.runtime.stop();
|
|
74
|
-
}
|
|
75
|
-
get injector() {
|
|
76
|
-
return this.runtime.injector;
|
|
77
|
-
}
|
|
78
|
-
inject(ctor, notFoundValue) {
|
|
79
|
-
return this.injector.get(ctor, notFoundValue);
|
|
80
|
-
}
|
|
81
|
-
get args() {
|
|
82
|
-
return this._args.get();
|
|
83
|
-
}
|
|
84
|
-
get options() {
|
|
85
|
-
return this._optionsRef.options;
|
|
86
|
-
}
|
|
87
|
-
static loadOptions(entryModule, bootstrapOptions) {
|
|
88
|
-
// Read an @AppOptions() decorator if any, and merge providers from it
|
|
89
|
-
// into the bootstrapped providers
|
|
90
|
-
|
|
91
|
-
let
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
+
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
let
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
providers.push(
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
console.error(
|
|
141
|
-
console.error(
|
|
142
|
-
console.
|
|
143
|
-
console.
|
|
144
|
-
console.
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
runtime.
|
|
151
|
-
runtime.
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
1
|
+
var Application_1;
|
|
2
|
+
import { __awaiter, __decorate } from "tslib";
|
|
3
|
+
import 'reflect-metadata';
|
|
4
|
+
import { Environment, Time } from '@alterior/common';
|
|
5
|
+
import { inject, Injectable, ModuleAnnotation, ReflectiveInjector } from '@alterior/di';
|
|
6
|
+
import { AppOptionsAnnotation } from './app-options';
|
|
7
|
+
import { ApplicationArgs } from './args';
|
|
8
|
+
import { Runtime } from './modules';
|
|
9
|
+
import { RolesService } from './roles.service';
|
|
10
|
+
export class ApplicationOptionsRef {
|
|
11
|
+
constructor(options) {
|
|
12
|
+
this.options = Object.assign({}, options);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Represents the current runtime execution context.
|
|
17
|
+
* This is exposed via a zone-local variable, and the Runtime
|
|
18
|
+
* populates it with useful information as it becomes available.
|
|
19
|
+
*/
|
|
20
|
+
export class ExecutionContext {
|
|
21
|
+
constructor() {
|
|
22
|
+
/**
|
|
23
|
+
* Retrieve the Alterior application which is currently being executed.
|
|
24
|
+
* If an application has not been bootstrapped yet, the value is null.
|
|
25
|
+
*/
|
|
26
|
+
this.application = null;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Get the current execution context, if any.
|
|
30
|
+
*/
|
|
31
|
+
static get current() {
|
|
32
|
+
return Zone.current.get(ExecutionContext.ZONE_LOCAL_NAME);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Execute the given function in a new zone which has
|
|
36
|
+
* this ExecutionContext instance as the current execution context.
|
|
37
|
+
*/
|
|
38
|
+
run(callback) {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
let zone = Zone.current.fork({
|
|
41
|
+
name: `AlteriorExecutionContext`,
|
|
42
|
+
properties: {
|
|
43
|
+
[ExecutionContext.ZONE_LOCAL_NAME]: this
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
return yield zone.run(() => callback());
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
runSync(callback) {
|
|
50
|
+
let zone = Zone.current.fork({
|
|
51
|
+
name: `AlteriorExecutionContext`,
|
|
52
|
+
properties: {
|
|
53
|
+
[ExecutionContext.ZONE_LOCAL_NAME]: this
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
return zone.run(() => callback());
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
ExecutionContext.ZONE_LOCAL_NAME = '@alterior/runtime:ExecutionContext';
|
|
60
|
+
/**
|
|
61
|
+
* Handles bootstrapping the application.
|
|
62
|
+
*/
|
|
63
|
+
let Application = Application_1 = class Application {
|
|
64
|
+
constructor() {
|
|
65
|
+
this.runtime = inject(Runtime);
|
|
66
|
+
this._optionsRef = inject(ApplicationOptionsRef);
|
|
67
|
+
this._args = inject(ApplicationArgs);
|
|
68
|
+
}
|
|
69
|
+
start() {
|
|
70
|
+
this.runtime.start();
|
|
71
|
+
}
|
|
72
|
+
stop() {
|
|
73
|
+
this.runtime.stop();
|
|
74
|
+
}
|
|
75
|
+
get injector() {
|
|
76
|
+
return this.runtime.injector;
|
|
77
|
+
}
|
|
78
|
+
inject(ctor, notFoundValue) {
|
|
79
|
+
return this.injector.get(ctor, notFoundValue);
|
|
80
|
+
}
|
|
81
|
+
get args() {
|
|
82
|
+
return this._args.get();
|
|
83
|
+
}
|
|
84
|
+
get options() {
|
|
85
|
+
return this._optionsRef.options;
|
|
86
|
+
}
|
|
87
|
+
static loadOptions(entryModule, bootstrapOptions) {
|
|
88
|
+
// Read an @AppOptions() decorator if any, and merge providers from it
|
|
89
|
+
// into the bootstrapped providers
|
|
90
|
+
var _a;
|
|
91
|
+
let appOptionsAnnotation = AppOptionsAnnotation.getForClass(entryModule);
|
|
92
|
+
let appProvidedOptions = (_a = appOptionsAnnotation === null || appOptionsAnnotation === void 0 ? void 0 : appOptionsAnnotation.options) !== null && _a !== void 0 ? _a : {};
|
|
93
|
+
return Object.assign({
|
|
94
|
+
version: '0.0.0',
|
|
95
|
+
verbose: false,
|
|
96
|
+
silent: false,
|
|
97
|
+
autostart: true,
|
|
98
|
+
providers: []
|
|
99
|
+
}, appProvidedOptions, bootstrapOptions);
|
|
100
|
+
}
|
|
101
|
+
static validateEntryModule(module) {
|
|
102
|
+
if (typeof module !== 'function') {
|
|
103
|
+
throw new Error(`You must pass a Module class as the first parameter `
|
|
104
|
+
+ `to bootstrap(). You provided: `
|
|
105
|
+
+ `${typeof module} with value '${module}'`);
|
|
106
|
+
}
|
|
107
|
+
let moduleMetadata = ModuleAnnotation.getForClass(module);
|
|
108
|
+
if (!moduleMetadata)
|
|
109
|
+
throw new Error(`You must pass a module class decorated by @Module()`);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Bootstrap an Alterior application.
|
|
113
|
+
*/
|
|
114
|
+
static bootstrap(entryModule, options) {
|
|
115
|
+
let executionContext = new ExecutionContext();
|
|
116
|
+
return executionContext.runSync(() => {
|
|
117
|
+
var _a;
|
|
118
|
+
this.validateEntryModule(entryModule);
|
|
119
|
+
options = this.loadOptions(entryModule, options);
|
|
120
|
+
let runtime = new Runtime(entryModule);
|
|
121
|
+
let providers = [
|
|
122
|
+
ApplicationArgs,
|
|
123
|
+
RolesService,
|
|
124
|
+
Environment,
|
|
125
|
+
Time
|
|
126
|
+
];
|
|
127
|
+
runtime.contributeProviders(providers);
|
|
128
|
+
providers.push({
|
|
129
|
+
provide: ApplicationOptionsRef,
|
|
130
|
+
useValue: new ApplicationOptionsRef(options)
|
|
131
|
+
});
|
|
132
|
+
providers.push(Application_1);
|
|
133
|
+
providers.push((_a = options.providers) !== null && _a !== void 0 ? _a : []);
|
|
134
|
+
runtime.providers = providers;
|
|
135
|
+
let injector;
|
|
136
|
+
try {
|
|
137
|
+
injector = ReflectiveInjector.resolveAndCreate(providers, options.parentInjector);
|
|
138
|
+
}
|
|
139
|
+
catch (e) {
|
|
140
|
+
console.error(`Failed to resolve injector:`);
|
|
141
|
+
console.error(e);
|
|
142
|
+
console.error(`Providers:`);
|
|
143
|
+
console.dir(providers);
|
|
144
|
+
console.error(`Modules:`);
|
|
145
|
+
console.dir(runtime.definitions);
|
|
146
|
+
throw e;
|
|
147
|
+
}
|
|
148
|
+
injector.get(RolesService).silent = options.silent;
|
|
149
|
+
runtime.load(injector);
|
|
150
|
+
executionContext.application = runtime.getService(Application_1);
|
|
151
|
+
runtime.fireEvent('OnInit');
|
|
152
|
+
runtime.configure();
|
|
153
|
+
if (runtime.selfTest) {
|
|
154
|
+
console.log(`[Self Test] ✔ Looks good!`);
|
|
155
|
+
process.exit(0);
|
|
156
|
+
}
|
|
157
|
+
if (options.autostart)
|
|
158
|
+
runtime.start();
|
|
159
|
+
runtime.fireEvent('AfterStart');
|
|
160
|
+
return executionContext.application;
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
Application = Application_1 = __decorate([
|
|
165
|
+
Injectable()
|
|
166
|
+
], Application);
|
|
167
|
+
export { Application };
|
|
167
168
|
//# sourceMappingURL=application.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application.js","sourceRoot":"","sources":["../src/application.ts"],"names":[],"mappings":";;AAAA,OAAO,kBAAkB,CAAC;AAE1B,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EACN,MAAM,EACN,UAAU,EACV,gBAAgB,EAEhB,kBAAkB,EAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAsB,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,MAAM,OAAO,qBAAqB;IACjC,YACC,OAA2B;QAE3B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;IAC3C,CAAC;CAGD;AAED;;;;GAIG;AACH,MAAM,OAAO,gBAAgB;IAA7B;QACC;;;WAGG;QACI,gBAAW,GAAgB,IAAI,CAAC;IAoCxC,CAAC;IAhCA;;OAEG;IACI,MAAM,KAAK,OAAO;QACxB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,eAAe,CAAC,CAAC;IAC3D,CAAC;IAED;;;OAGG;IACU,GAAG,CAAI,QAA0B;;YAC7C,IAAI,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;gBAC5B,IAAI,EAAE,0BAA0B;gBAChC,UAAU,EAAE;oBACX,CAAC,gBAAgB,CAAC,eAAe,CAAC,EAAE,IAAI;iBACxC;aACD,CAAC,CAAC;YAEH,OAAO,MAAM,IAAI,CAAC,GAAG,CA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