@common-stack/core 0.5.1-alpha.4 → 0.6.1-alpha.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/connectors/common-feature.d.ts +22 -0
- package/lib/connectors/common-feature.js +23 -0
- package/lib/connectors/common-feature.js.map +1 -0
- package/lib/connectors/feature.d.ts +8 -0
- package/lib/connectors/feature.js +29 -0
- package/lib/connectors/feature.js.map +1 -0
- package/lib/connectors/index.d.ts +2 -0
- package/lib/connectors/index.js +19 -0
- package/lib/connectors/index.js.map +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/interfaces/common-feature.d.ts +59 -0
- package/lib/interfaces/common-feature.js +3 -0
- package/lib/interfaces/common-feature.js.map +1 -0
- package/lib/interfaces/feature.d.ts +23 -0
- package/lib/interfaces/feature.js +3 -0
- package/lib/interfaces/feature.js.map +1 -0
- package/lib/interfaces/index.d.ts +2 -0
- package/lib/interfaces/index.js +2 -0
- package/lib/interfaces/index.js.map +1 -1
- package/package.json +5 -2
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { interfaces, Container } from 'inversify';
|
|
2
|
+
import { Feature2 } from './feature';
|
|
3
|
+
import { ICommonFeature, ICommonFeatureShape, ILocalization, ContainerFunc } from '../interfaces';
|
|
4
|
+
declare class CommonFeature<S = unknown> extends Feature2 implements ICommonFeature<S> {
|
|
5
|
+
readonly localizationIn?: ILocalization[];
|
|
6
|
+
readonly appContextIn?: {
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
};
|
|
9
|
+
readonly createContainerFuncIn?: ContainerFunc[];
|
|
10
|
+
readonly createServiceFuncIn?: Function[];
|
|
11
|
+
protected _container: interfaces.Container;
|
|
12
|
+
protected _services: {
|
|
13
|
+
[key: string]: S;
|
|
14
|
+
};
|
|
15
|
+
constructor(...modules: ICommonFeatureShape[]);
|
|
16
|
+
get localizations(): ILocalization[];
|
|
17
|
+
get container(): interfaces.Container | Container;
|
|
18
|
+
get services(): {
|
|
19
|
+
[key: string]: S;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export { CommonFeature };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CommonFeature = void 0;
|
|
4
|
+
const fractal_objects_1 = require("fractal-objects");
|
|
5
|
+
const inversify_1 = require("inversify");
|
|
6
|
+
const feature_1 = require("./feature");
|
|
7
|
+
class CommonFeature extends feature_1.Feature2 {
|
|
8
|
+
constructor(...modules) {
|
|
9
|
+
super(...modules);
|
|
10
|
+
(0, fractal_objects_1.foldTo)(this, modules);
|
|
11
|
+
}
|
|
12
|
+
get localizations() {
|
|
13
|
+
return this.localizationIn || [];
|
|
14
|
+
}
|
|
15
|
+
get container() {
|
|
16
|
+
return this._container || new inversify_1.Container();
|
|
17
|
+
}
|
|
18
|
+
get services() {
|
|
19
|
+
return this._services;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.CommonFeature = CommonFeature;
|
|
23
|
+
//# sourceMappingURL=common-feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common-feature.js","sourceRoot":"","sources":["../../src/connectors/common-feature.ts"],"names":[],"mappings":";;;AAAA,qDAAyC;AACzC,yCAAkD;AAClD,uCAAqC;AAGrC,MAAM,aAAyB,SAAQ,kBAAQ;IAQ3C,YAAY,GAAG,OAA8B;QACzC,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC;QAClB,IAAA,wBAAM,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC1B,CAAC;IAED,IAAI,aAAa;QACb,OAAO,IAAI,CAAC,cAAc,IAAI,EAAE,CAAC;IACrC,CAAC;IAED,IAAI,SAAS;QACT,OAAO,IAAI,CAAC,UAAU,IAAI,IAAI,qBAAS,EAAE,CAAC;IAC9C,CAAC;IAED,IAAI,QAAQ;QACR,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;CACJ;AACQ,sCAAa"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="@types/node" />
|
|
2
|
+
import { IFeature2, IFeature2Shape } from '../interfaces';
|
|
3
|
+
declare class Feature2 implements IFeature2 {
|
|
4
|
+
readonly onAppCreate?: Array<(modules: IFeature2, entryModule: NodeModule) => Promise<any>>;
|
|
5
|
+
constructor(...modules: IFeature2Shape[]);
|
|
6
|
+
createApp(entryModule: NodeModule): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export { Feature2 };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Feature2 = void 0;
|
|
13
|
+
const fractal_objects_1 = require("fractal-objects");
|
|
14
|
+
class Feature2 {
|
|
15
|
+
constructor(...modules) {
|
|
16
|
+
(0, fractal_objects_1.foldTo)(this, modules);
|
|
17
|
+
}
|
|
18
|
+
createApp(entryModule) {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
if (this.onAppCreate) {
|
|
21
|
+
for (const callback of this.onAppCreate) {
|
|
22
|
+
yield callback(this, entryModule);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.Feature2 = Feature2;
|
|
29
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feature.js","sourceRoot":"","sources":["../../src/connectors/feature.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAyC;AAGzC,MAAM,QAAQ;IAIV,YAAY,GAAG,OAAyB;QACpC,IAAA,wBAAM,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC1B,CAAC;IAEY,SAAS,CAAC,WAAuB;;YAC1C,IAAI,IAAI,CAAC,WAAW,EAAE;gBAClB,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,WAAW,EAAE;oBACrC,MAAM,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;iBACrC;aACJ;QACL,CAAC;KAAA;CACJ;AAEQ,4BAAQ"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./feature"), exports);
|
|
18
|
+
__exportStar(require("./common-feature"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/connectors/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,mDAAiC"}
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -17,4 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./field-error"), exports);
|
|
18
18
|
__exportStar(require("./interfaces"), exports);
|
|
19
19
|
__exportStar(require("./constants"), exports);
|
|
20
|
+
__exportStar(require("./connectors"), exports);
|
|
20
21
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,+CAA6B;AAC7B,8CAA4B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,+CAA6B;AAC7B,8CAA4B;AAC5B,+CAA6B"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Resource } from 'i18next';
|
|
2
|
+
import { interfaces } from 'inversify';
|
|
3
|
+
import { IFeature2Shape } from './feature';
|
|
4
|
+
export declare type ILocalization = {
|
|
5
|
+
ns: string;
|
|
6
|
+
resources: Resource;
|
|
7
|
+
};
|
|
8
|
+
export declare type ContainerFunc = (options?: any) => interfaces.ContainerModule;
|
|
9
|
+
/**
|
|
10
|
+
* Common Feature Shape
|
|
11
|
+
*/
|
|
12
|
+
export interface ICommonFeatureShape extends IFeature2Shape {
|
|
13
|
+
/**
|
|
14
|
+
* localizations for `i18next` library
|
|
15
|
+
*/
|
|
16
|
+
localizationIn?: ILocalization[];
|
|
17
|
+
/**
|
|
18
|
+
* Feature modules shared context
|
|
19
|
+
*/
|
|
20
|
+
appContextIn?: {
|
|
21
|
+
[key: string]: any;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* @param createContainerFunc Synchronous Container Modules of inversify.
|
|
25
|
+
* @inheritdoc https://github.com/inversify/InversifyJS/blob/master/wiki/container_modules.md
|
|
26
|
+
*/
|
|
27
|
+
createContainerFuncIn?: ContainerFunc[];
|
|
28
|
+
/**
|
|
29
|
+
* @param createServiceFunc Services
|
|
30
|
+
*/
|
|
31
|
+
createServiceFuncIn?: Function[];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Common ancestor for server and client feature modules interfaces.
|
|
35
|
+
* param S Services type
|
|
36
|
+
*/
|
|
37
|
+
export interface ICommonFeature<S = unknown> extends IFeature2Shape {
|
|
38
|
+
readonly localizationIn?: ILocalization[];
|
|
39
|
+
readonly appContextIn?: {
|
|
40
|
+
[key: string]: any;
|
|
41
|
+
};
|
|
42
|
+
readonly createContainerFuncIn?: ContainerFunc[];
|
|
43
|
+
readonly createServiceFuncIn?: Function[];
|
|
44
|
+
/**
|
|
45
|
+
* @returns localization for i18next library
|
|
46
|
+
*/
|
|
47
|
+
readonly localizations?: ILocalization[];
|
|
48
|
+
/**
|
|
49
|
+
* @param args Options to pass to each Container Module
|
|
50
|
+
* @returns create container loaded with all container modules.
|
|
51
|
+
*/
|
|
52
|
+
readonly container?: interfaces.Container;
|
|
53
|
+
/**
|
|
54
|
+
* @return Created services
|
|
55
|
+
*/
|
|
56
|
+
readonly services: {
|
|
57
|
+
[key: string]: S;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common-feature.js","sourceRoot":"","sources":["../../src/interfaces/common-feature.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/// <reference types="@types/node" />
|
|
2
|
+
/**
|
|
3
|
+
* @param Feature2Shape
|
|
4
|
+
* @description Shape of the Feature2
|
|
5
|
+
*/
|
|
6
|
+
export interface IFeature2Shape {
|
|
7
|
+
/**
|
|
8
|
+
* A hook called on the very start of the application right after all the feature modules are imported.
|
|
9
|
+
* @param modules Feature modules
|
|
10
|
+
* @param entryModule
|
|
11
|
+
*/
|
|
12
|
+
onAppCreate?: Array<(modules: IFeature2, entryModule: NodeModule) => Promise<any>>;
|
|
13
|
+
}
|
|
14
|
+
export interface IFeature2 extends IFeature2Shape {
|
|
15
|
+
readonly onAppCreate?: Array<(modules: IFeature2, entryModule: NodeModule) => Promise<any>>;
|
|
16
|
+
/**
|
|
17
|
+
* Calls each feature module `onAppCreate` hook, with `module` object as a first argument and the list of all feature modules as a second argument, extending this `Feature2Share` interface.
|
|
18
|
+
*
|
|
19
|
+
* In `onAppCreate` hook each module can initialize itself. Usually, the `core` feature module in `onAppCreate` hook initializes used framework adn registers callbacks exported by other feature mdoules. And then the framework calls these callbacks.
|
|
20
|
+
* @param entryModule Feature Module
|
|
21
|
+
*/
|
|
22
|
+
createApp(entryModule: IFeature2 | NodeModule): any;
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feature.js","sourceRoot":"","sources":["../../src/interfaces/feature.ts"],"names":[],"mappings":""}
|
package/lib/interfaces/index.js
CHANGED
|
@@ -15,4 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./common-settings"), exports);
|
|
18
|
+
__exportStar(require("./feature"), exports);
|
|
19
|
+
__exportStar(require("./common-feature"), exports);
|
|
18
20
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,4CAA0B;AAC1B,mDAAiC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@common-stack/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1-alpha.0",
|
|
4
4
|
"description": "Common core for higher packages to depend on",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "CDMBase LLC",
|
|
@@ -18,11 +18,14 @@
|
|
|
18
18
|
"test:watch": "npm test -- --watch",
|
|
19
19
|
"watch": "yarn build:lib:watch"
|
|
20
20
|
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"fractal-objects": "^0.10.4"
|
|
23
|
+
},
|
|
21
24
|
"publishConfig": {
|
|
22
25
|
"access": "public"
|
|
23
26
|
},
|
|
24
27
|
"typescript": {
|
|
25
28
|
"definition": "lib/index.d.ts"
|
|
26
29
|
},
|
|
27
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "32445493b66c73ec547b5fd27acfa84ae4718897"
|
|
28
31
|
}
|