@adaas/a-server 0.0.15 → 0.0.17
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/README.md +504 -18
- package/dist/index.d.ts +16 -5
- package/dist/index.js +47 -17
- package/dist/index.js.map +1 -1
- package/dist/src/channels/A-Http/A-Http.channel.constants.d.ts +5 -0
- package/dist/src/channels/A-Http/A-Http.channel.constants.js +10 -0
- package/dist/src/channels/A-Http/A-Http.channel.constants.js.map +1 -0
- package/dist/src/channels/A-Http/A-Http.channel.d.ts +28 -0
- package/dist/src/channels/A-Http/A-Http.channel.error.d.ts +4 -0
- package/dist/src/channels/A-Http/A-Http.channel.error.js +9 -0
- package/dist/src/channels/A-Http/A-Http.channel.error.js.map +1 -0
- package/dist/src/channels/A-Http/A-Http.channel.js +148 -0
- package/dist/src/channels/A-Http/A-Http.channel.js.map +1 -0
- package/dist/src/channels/A-Http/A-Http.channel.types.d.ts +59 -0
- package/dist/src/channels/A-Http/A-Http.channel.types.js +3 -0
- package/dist/src/channels/A-Http/A-Http.channel.types.js.map +1 -0
- package/dist/src/components/A-CommandController/A-CommandController.component.d.ts +2 -2
- package/dist/src/components/A-CommandController/A-CommandController.component.js +5 -2
- package/dist/src/components/A-CommandController/A-CommandController.component.js.map +1 -1
- package/dist/src/components/A-Controller/A-Controller.component.js +0 -4
- package/dist/src/components/A-Controller/A-Controller.component.js.map +1 -1
- package/dist/src/components/A-EntityController/A-EntityController.component.d.ts +1 -1
- package/dist/src/components/A-EntityController/A-EntityController.component.js +26 -15
- package/dist/src/components/A-EntityController/A-EntityController.component.js.map +1 -1
- package/dist/src/components/A-EntityRepository/A-EntityRepository.component.d.ts +7 -0
- package/dist/src/components/A-EntityRepository/A-EntityRepository.component.js +96 -0
- package/dist/src/components/A-EntityRepository/A-EntityRepository.component.js.map +1 -0
- package/dist/src/components/A-EntityRepository/A-EntityRepository.error.js +2 -0
- package/dist/src/components/A-EntityRepository/A-EntityRepository.error.js.map +1 -0
- package/dist/src/components/A-EntityRepository/A-EntityRepository.types.js +2 -0
- package/dist/src/components/A-EntityRepository/A-EntityRepository.types.js.map +1 -0
- package/dist/src/components/A-ListingController/A-ListingController.component.d.ts +2 -1
- package/dist/src/components/A-ListingController/A-ListingController.component.js +7 -6
- package/dist/src/components/A-ListingController/A-ListingController.component.js.map +1 -1
- package/dist/src/components/A-Router/A-Router.component.d.ts +3 -2
- package/dist/src/components/A-Router/A-Router.component.js +17 -10
- package/dist/src/components/A-Router/A-Router.component.js.map +1 -1
- package/dist/src/components/A-ServerCORS/A_ServerCORS.component.d.ts +2 -1
- package/dist/src/components/A-ServerCORS/A_ServerCORS.component.js +2 -1
- package/dist/src/components/A-ServerCORS/A_ServerCORS.component.js.map +1 -1
- package/dist/src/components/A-ServerError/A-ServerError.class.d.ts +7 -0
- package/dist/src/components/A-ServerError/A-ServerError.class.js +88 -0
- package/dist/src/components/A-ServerError/A-ServerError.class.js.map +1 -0
- package/dist/src/components/A-ServerError/A-ServerError.constants.d.ts +0 -0
- package/dist/src/components/A-ServerError/A-ServerError.constants.js +2 -0
- package/dist/src/components/A-ServerError/A-ServerError.constants.js.map +1 -0
- package/dist/src/components/A-ServerError/A-ServerError.types.d.ts +13 -0
- package/dist/src/components/A-ServerError/A-ServerError.types.js +3 -0
- package/dist/src/components/A-ServerError/A-ServerError.types.js.map +1 -0
- package/dist/src/components/A-ServerHealthMonitor/A-ServerHealthMonitor.component.d.ts +2 -1
- package/dist/src/components/A-ServerHealthMonitor/A-ServerHealthMonitor.component.js +7 -3
- package/dist/src/components/A-ServerHealthMonitor/A-ServerHealthMonitor.component.js.map +1 -1
- package/dist/src/components/A-ServerLogger/A_ServerLogger.component.d.ts +3 -2
- package/dist/src/components/A-ServerLogger/A_ServerLogger.component.js +6 -7
- package/dist/src/components/A-ServerLogger/A_ServerLogger.component.js.map +1 -1
- package/dist/src/components/A-ServerLogger/A_ServerLogger.component.types.d.ts +2 -1
- package/dist/src/components/A-ServerProxy/A-ServerProxy.component.d.ts +3 -2
- package/dist/src/components/A-ServerProxy/A-ServerProxy.component.js +4 -3
- package/dist/src/components/A-ServerProxy/A-ServerProxy.component.js.map +1 -1
- package/dist/src/components/A-StaticLoader/A-StaticLoader.component.d.ts +2 -1
- package/dist/src/components/A-StaticLoader/A-StaticLoader.component.js +3 -2
- package/dist/src/components/A-StaticLoader/A-StaticLoader.component.js.map +1 -1
- package/dist/src/components/A-StaticLoader/A-StaticLoader.component.types.d.ts +2 -1
- package/dist/src/components/A-StaticLoader/A-StaticLoader.component.types.js +2 -1
- package/dist/src/components/A-StaticLoader/A-StaticLoader.component.types.js.map +1 -1
- package/dist/src/containers/A-Service/A-Service.container.d.ts +4 -2
- package/dist/src/containers/A-Service/A-Service.container.js +41 -35
- package/dist/src/containers/A-Service/A-Service.container.js.map +1 -1
- package/dist/src/context/A-EntityFactory/A-EntityFactory.context.d.ts +1 -2
- package/dist/src/context/A-EntityFactory/A-EntityFactory.context.js +6 -7
- package/dist/src/context/A-EntityFactory/A-EntityFactory.context.js.map +1 -1
- package/dist/src/context/A-HttpChannel/A-HttpChannel.context.d.ts +12 -0
- package/dist/src/context/A-HttpChannel/A-HttpChannel.context.js +16 -0
- package/dist/src/context/A-HttpChannel/A-HttpChannel.context.js.map +1 -0
- package/dist/src/context/{A_ListQueryFilter → A-ListQueryFilter}/A_ListQueryFilter.context.js.map +1 -1
- package/dist/src/context/{A_ProxyConfig → A-ProxyConfig}/A_ProxyConfig.constants.js.map +1 -1
- package/dist/src/context/{A_ProxyConfig → A-ProxyConfig}/A_ProxyConfig.context.js.map +1 -1
- package/dist/src/context/A-ProxyConfig/A_ProxyConfig.types.js.map +1 -0
- package/dist/src/context/A-Server/A_Server.context.d.ts +1 -1
- package/dist/src/context/A-Server/A_Server.context.js.map +1 -1
- package/dist/src/entities/A-Request/A-Request.entity.d.ts +3 -2
- package/dist/src/entities/A-Request/A-Request.entity.js +12 -19
- package/dist/src/entities/A-Request/A-Request.entity.js.map +1 -1
- package/dist/src/entities/A-Request/A-Request.entity.types.d.ts +2 -2
- package/dist/src/entities/A-Response/A-Response.entity.d.ts +3 -3
- package/dist/src/entities/A-Response/A-Response.entity.js +12 -11
- package/dist/src/entities/A-Response/A-Response.entity.js.map +1 -1
- package/dist/src/entities/A-Response/A-Response.entity.types.d.ts +2 -2
- package/dist/src/entities/A-Route/A-Route.entity.js +3 -1
- package/dist/src/entities/A-Route/A-Route.entity.js.map +1 -1
- package/dist/src/entities/A_EntityList/A_EntityList.entity.js +2 -3
- package/dist/src/entities/A_EntityList/A_EntityList.entity.js.map +1 -1
- package/dist/src/entities/A_EntityList/A_EntityList.entity.types.d.ts +2 -2
- package/examples/simple-server/commands/SignIn.command.ts +2 -2
- package/examples/simple-server/components/Test.controller.ts +19 -5
- package/examples/simple-server/components/Users.repository.ts +10 -7
- package/examples/simple-server/concept.ts +19 -20
- package/examples/simple-server/entities/User/User.entity.ts +10 -7
- package/examples/simple-server/entities/User/User.entity.types.ts +2 -2
- package/index.ts +49 -19
- package/jest.config.ts +1 -0
- package/package.json +4 -4
- package/src/channels/A-Http/A-Http.channel.constants.ts +8 -0
- package/src/channels/A-Http/A-Http.channel.error.ts +8 -0
- package/src/channels/A-Http/A-Http.channel.ts +188 -0
- package/src/channels/A-Http/A-Http.channel.types.ts +66 -0
- package/src/components/A-CommandController/A-CommandController.component.ts +7 -2
- package/src/components/A-Controller/A-Controller.component.ts +0 -4
- package/src/components/A-EntityController/A-EntityController.component.ts +27 -10
- package/src/components/A-EntityRepository/A-EntityRepository.component.ts +88 -0
- package/src/components/A-EntityRepository/A-EntityRepository.error.ts +0 -0
- package/src/components/A-EntityRepository/A-EntityRepository.types.ts +0 -0
- package/src/components/A-ListingController/A-ListingController.component.ts +7 -6
- package/src/components/A-Router/A-Router.component.ts +25 -14
- package/src/components/A-Router/A-Router.component.types.ts +1 -1
- package/src/components/A-ServerCORS/A_ServerCORS.component.ts +2 -1
- package/src/components/A-ServerError/A-ServerError.class.ts +98 -0
- package/src/components/A-ServerError/A-ServerError.constants.ts +0 -0
- package/src/components/A-ServerError/A-ServerError.types.ts +22 -0
- package/src/components/A-ServerHealthMonitor/A-ServerHealthMonitor.component.ts +8 -3
- package/src/components/A-ServerLogger/A_ServerLogger.component.ts +6 -9
- package/src/components/A-ServerLogger/A_ServerLogger.component.types.ts +2 -9
- package/src/components/A-ServerProxy/A-ServerProxy.component.ts +3 -2
- package/src/components/A-StaticLoader/A-StaticLoader.component.ts +2 -1
- package/src/components/A-StaticLoader/A-StaticLoader.component.types.ts +2 -3
- package/src/containers/A-Service/A-Service.container.ts +37 -35
- package/src/context/A-EntityFactory/A-EntityFactory.context.ts +1 -2
- package/src/context/A-HttpChannel/A-HttpChannel.context.ts +36 -0
- package/src/context/A-Server/A_Server.context.ts +2 -3
- package/src/entities/A-Request/A-Request.entity.ts +16 -17
- package/src/entities/A-Request/A-Request.entity.types.ts +3 -3
- package/src/entities/A-Response/A-Response.entity.ts +14 -12
- package/src/entities/A-Response/A-Response.entity.types.ts +2 -2
- package/src/entities/A-Route/A-Route.entity.ts +4 -4
- package/src/entities/A_EntityList/A_EntityList.entity.ts +2 -3
- package/src/entities/A_EntityList/A_EntityList.entity.types.ts +5 -5
- package/tests/A-HttpChannel.test.ts +204 -0
- package/tests/A-Service.test.ts +1 -3
- package/tsconfig.build.json +1 -0
- package/tsconfig.json +2 -0
- package/dist/src/context/A_ProxyConfig/A_ProxyConfig.types.js.map +0 -1
- package/dist/src/context/Server.context.types.js +0 -2
- package/dist/src/context/Server.context.types.js.map +0 -1
- /package/dist/src/{context/Server.context.types.d.ts → components/A-EntityRepository/A-EntityRepository.error.d.ts} +0 -0
- /package/{src/context/Server.context.types.ts → dist/src/components/A-EntityRepository/A-EntityRepository.types.d.ts} +0 -0
- /package/dist/src/context/{A_ListQueryFilter → A-ListQueryFilter}/A_ListQueryFilter.context.d.ts +0 -0
- /package/dist/src/context/{A_ListQueryFilter → A-ListQueryFilter}/A_ListQueryFilter.context.js +0 -0
- /package/dist/src/context/{A_ProxyConfig → A-ProxyConfig}/A_ProxyConfig.constants.d.ts +0 -0
- /package/dist/src/context/{A_ProxyConfig → A-ProxyConfig}/A_ProxyConfig.constants.js +0 -0
- /package/dist/src/context/{A_ProxyConfig → A-ProxyConfig}/A_ProxyConfig.context.d.ts +0 -0
- /package/dist/src/context/{A_ProxyConfig → A-ProxyConfig}/A_ProxyConfig.context.js +0 -0
- /package/dist/src/context/{A_ProxyConfig → A-ProxyConfig}/A_ProxyConfig.types.d.ts +0 -0
- /package/dist/src/context/{A_ProxyConfig → A-ProxyConfig}/A_ProxyConfig.types.js +0 -0
- /package/src/context/{A_ListQueryFilter → A-ListQueryFilter}/A_ListQueryFilter.context.ts +0 -0
- /package/src/context/{A_ProxyConfig → A-ProxyConfig}/A_ProxyConfig.constants.ts +0 -0
- /package/src/context/{A_ProxyConfig → A-ProxyConfig}/A_ProxyConfig.context.ts +0 -0
- /package/src/context/{A_ProxyConfig → A-ProxyConfig}/A_ProxyConfig.types.ts +0 -0
|
@@ -8,16 +8,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
12
|
exports.A_Request = void 0;
|
|
16
|
-
const crypto_1 = __importDefault(require("crypto"));
|
|
17
13
|
const a_concept_1 = require("@adaas/a-concept");
|
|
18
|
-
const a_utils_1 = require("@adaas/a-utils");
|
|
19
14
|
const A_Request_entity_types_1 = require("./A-Request.entity.types");
|
|
20
15
|
const A_Route_entity_1 = require("../A-Route/A-Route.entity");
|
|
16
|
+
const A_ServerError_class_1 = require("../../components/A-ServerError/A-ServerError.class");
|
|
21
17
|
class A_Request extends a_concept_1.A_Entity {
|
|
22
18
|
constructor() {
|
|
23
19
|
super(...arguments);
|
|
@@ -29,24 +25,21 @@ class A_Request extends a_concept_1.A_Entity {
|
|
|
29
25
|
*/
|
|
30
26
|
this.duration = 0;
|
|
31
27
|
}
|
|
28
|
+
static get namespace() {
|
|
29
|
+
return 'a-server';
|
|
30
|
+
}
|
|
32
31
|
fromNew(newEntity) {
|
|
33
32
|
this.req = newEntity.request;
|
|
34
|
-
this.aseid = new
|
|
35
|
-
|
|
36
|
-
scope: newEntity.scope
|
|
37
|
-
entity:
|
|
33
|
+
this.aseid = new a_concept_1.ASEID({
|
|
34
|
+
concept: a_concept_1.A_Context.root.name,
|
|
35
|
+
scope: newEntity.scope,
|
|
36
|
+
entity: this.constructor.entity,
|
|
38
37
|
id: newEntity.id
|
|
39
38
|
});
|
|
40
39
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const time = Date.now();
|
|
45
|
-
const method = this.method;
|
|
46
|
-
const url = this.url;
|
|
47
|
-
const randomValue = Math.random().toString(); // Adds extra randomness
|
|
48
|
-
hash.update(`${time}-${method}-${url}-${randomValue}`);
|
|
49
|
-
return hash.digest('hex');
|
|
40
|
+
get startedAt() {
|
|
41
|
+
const timeId = a_concept_1.A_IdentityHelper.parseTimeId(this.aseid.id.split('-')[0]);
|
|
42
|
+
return timeId ? new Date(timeId.timestamp) : undefined;
|
|
50
43
|
}
|
|
51
44
|
// Getter for request URL
|
|
52
45
|
get url() {
|
|
@@ -68,7 +61,7 @@ class A_Request extends a_concept_1.A_Entity {
|
|
|
68
61
|
init() {
|
|
69
62
|
return __awaiter(this, void 0, void 0, function* () {
|
|
70
63
|
this.req.on('error', (err) => __awaiter(this, void 0, void 0, function* () {
|
|
71
|
-
this.error = new
|
|
64
|
+
this.error = new A_ServerError_class_1.A_ServerError(err);
|
|
72
65
|
yield this.call(A_Request_entity_types_1.A_SERVER_TYPES__RequestEvent.Error);
|
|
73
66
|
}));
|
|
74
67
|
this.params = this.extractParams(this.url);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"A-Request.entity.js","sourceRoot":"","sources":["../../../../src/entities/A-Request/A-Request.entity.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"A-Request.entity.js","sourceRoot":"","sources":["../../../../src/entities/A-Request/A-Request.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,gDAAiF;AACjF,qEAKkC;AAClC,8DAAoD;AACpD,sGAA6F;AAG7F,MAAa,SAMT,SAAQ,oBAGP;IATL;;QAiBI,SAAI,GAAiB,EAAkB,CAAC;QACxC,WAAM,GAAgB,EAAiB,CAAC;QACxC,UAAK,GAAe,EAAgB,CAAC;QAKrC;;WAEG;QACH,aAAQ,GAAW,CAAC,CAAC;IA2HzB,CAAC;IA3IG,MAAM,KAAK,SAAS;QAChB,OAAO,UAAU,CAAC;IACtB,CAAC;IAgBD,OAAO,CAAC,SAA6C;QACjD,IAAI,CAAC,GAAG,GAAG,SAAS,CAAC,OAAO,CAAC;QAE7B,IAAI,CAAC,KAAK,GAAG,IAAI,iBAAK,CAAC;YACnB,OAAO,EAAE,qBAAS,CAAC,IAAI,CAAC,IAAI;YAC5B,KAAK,EAAE,SAAS,CAAC,KAAK;YACtB,MAAM,EAAG,IAAI,CAAC,WAAgC,CAAC,MAAM;YACrD,EAAE,EAAE,SAAS,CAAC,EAAE;SACnB,CAAC,CAAC;IACP,CAAC;IAED,IAAI,SAAS;QACT,MAAM,MAAM,GAAG,4BAAgB,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAEzE,OAAO,MAAM,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC3D,CAAC;IAID,yBAAyB;IACzB,IAAW,GAAG;QACV,OAAO,IAAI,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AG,CAAC,CAAC,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;QAC/D,CAAC;QAED,OAAO,KAAK,CAAC;IACjB,CAAC;IAID,SAAS;QACL,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACnC,IAAI,IAAI,GAAG,EAAE,CAAC;YACd,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,IAAI,IAAI,KAAK,CAAC,CAAC;YAC5C,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE;gBACpB,IAAI,CAAC;oBACD,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;gBAC9B,CAAC;gBAAC,OAAO,GAAG,EAAE,CAAC;oBACX,MAAM,CAAC,GAAG,CAAC,CAAC;gBAChB,CAAC;YACL,CAAC,CAAC,CAAC;YACH,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;IACP,CAAC;CAEJ;AAtJD,8BAsJC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IncomingMessage } from "http";
|
|
2
2
|
import { A_Request } from "./A-Request.entity";
|
|
3
|
-
import {
|
|
3
|
+
import { A_TYPES__Entity_Serialized } from "@adaas/a-concept";
|
|
4
4
|
export type A_SERVER_TYPES__RequestConstructor = {
|
|
5
5
|
/**
|
|
6
6
|
* Should correspond to Response id
|
|
@@ -9,7 +9,7 @@ export type A_SERVER_TYPES__RequestConstructor = {
|
|
|
9
9
|
request: IncomingMessage;
|
|
10
10
|
scope: string;
|
|
11
11
|
};
|
|
12
|
-
export type A_SERVER_TYPES__RequestSerialized = {} &
|
|
12
|
+
export type A_SERVER_TYPES__RequestSerialized = {} & A_TYPES__Entity_Serialized;
|
|
13
13
|
export type A_SERVER_TYPES__RequestMethods = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'OPTIONS' | 'HEAD' | 'CONNECT' | 'TRACE' | 'DEFAULT';
|
|
14
14
|
export declare enum A_SERVER_TYPES__RequestEvent {
|
|
15
15
|
Error = "error",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { A_Entity, A_Scope } from "@adaas/a-concept";
|
|
1
|
+
import { A_Entity, A_Error, A_Scope } from "@adaas/a-concept";
|
|
2
2
|
import { IncomingHttpHeaders, ServerResponse } from "http";
|
|
3
3
|
import { A_SERVER_TYPES__ResponseConstructor, A_SERVER_TYPES__ResponseSerialized, A_SERVER_TYPES__SendResponseObject } from "./A-Response.entity.types";
|
|
4
|
-
import {
|
|
4
|
+
import { A_ServerError } from "../../components/A-ServerError/A-ServerError.class";
|
|
5
5
|
export declare class A_Response<_ResponseType = any> extends A_Entity<A_SERVER_TYPES__ResponseConstructor, A_SERVER_TYPES__ResponseSerialized> {
|
|
6
6
|
/**
|
|
7
7
|
* Duration of the request in milliseconds
|
|
@@ -15,7 +15,7 @@ export declare class A_Response<_ResponseType = any> extends A_Entity<A_SERVER_T
|
|
|
15
15
|
get original(): ServerResponse<import("http").IncomingMessage>;
|
|
16
16
|
get statusCode(): number;
|
|
17
17
|
init(): Promise<void>;
|
|
18
|
-
failed(error: A_ServerError | A_Error | Error |
|
|
18
|
+
failed(error: A_ServerError | A_Error | Error | any): void;
|
|
19
19
|
send(data?: string | object): void;
|
|
20
20
|
destroy(error: Error | unknown, scope?: A_Scope): Promise<any>;
|
|
21
21
|
json(data?: object): void;
|
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.A_Response = void 0;
|
|
13
13
|
const a_concept_1 = require("@adaas/a-concept");
|
|
14
14
|
const A_Response_entity_types_1 = require("./A-Response.entity.types");
|
|
15
|
+
const A_ServerError_class_1 = require("../../components/A-ServerError/A-ServerError.class");
|
|
15
16
|
const a_utils_1 = require("@adaas/a-utils");
|
|
16
17
|
class A_Response extends a_concept_1.A_Entity {
|
|
17
18
|
constructor() {
|
|
@@ -24,10 +25,10 @@ class A_Response extends a_concept_1.A_Entity {
|
|
|
24
25
|
}
|
|
25
26
|
fromNew(newEntity) {
|
|
26
27
|
this.res = newEntity.response;
|
|
27
|
-
this.aseid = new
|
|
28
|
-
|
|
29
|
-
scope: newEntity.scope
|
|
30
|
-
entity:
|
|
28
|
+
this.aseid = new a_concept_1.ASEID({
|
|
29
|
+
concept: a_concept_1.A_Context.root.name,
|
|
30
|
+
scope: newEntity.scope,
|
|
31
|
+
entity: this.constructor.entity,
|
|
31
32
|
id: newEntity.id
|
|
32
33
|
});
|
|
33
34
|
}
|
|
@@ -56,21 +57,21 @@ class A_Response extends a_concept_1.A_Entity {
|
|
|
56
57
|
}
|
|
57
58
|
failed(error) {
|
|
58
59
|
switch (true) {
|
|
59
|
-
case error instanceof
|
|
60
|
+
case error instanceof A_ServerError_class_1.A_ServerError:
|
|
60
61
|
this.error = error;
|
|
61
62
|
break;
|
|
62
|
-
case error instanceof
|
|
63
|
-
this.error = new
|
|
63
|
+
case error instanceof a_concept_1.A_Error:
|
|
64
|
+
this.error = new A_ServerError_class_1.A_ServerError(error);
|
|
64
65
|
break;
|
|
65
66
|
default:
|
|
66
|
-
this.error = new
|
|
67
|
+
this.error = new A_ServerError_class_1.A_ServerError(error);
|
|
67
68
|
break;
|
|
68
69
|
}
|
|
69
|
-
return this.status(this.error.
|
|
70
|
+
return this.status(this.error.status).json(this.error);
|
|
70
71
|
}
|
|
71
72
|
// Send a plain text or JSON response
|
|
72
73
|
send(data = this.toResponse()) {
|
|
73
|
-
const logger = a_concept_1.A_Context.scope(this).resolve(
|
|
74
|
+
const logger = a_concept_1.A_Context.scope(this).resolve(a_utils_1.A_Logger);
|
|
74
75
|
if (this.headersSent) {
|
|
75
76
|
logger.warning('Response headers already sent, cannot send response again.');
|
|
76
77
|
return;
|
|
@@ -100,7 +101,7 @@ class A_Response extends a_concept_1.A_Entity {
|
|
|
100
101
|
}
|
|
101
102
|
// Explicit JSON response
|
|
102
103
|
json(data = this.toResponse()) {
|
|
103
|
-
const logger = a_concept_1.A_Context.scope(this).resolve(
|
|
104
|
+
const logger = a_concept_1.A_Context.scope(this).resolve(a_utils_1.A_Logger);
|
|
104
105
|
if (this.headersSent) {
|
|
105
106
|
logger.warning('Response headers already sent, cannot send response again.');
|
|
106
107
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"A-Response.entity.js","sourceRoot":"","sources":["../../../../src/entities/A-Response/A-Response.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"A-Response.entity.js","sourceRoot":"","sources":["../../../../src/entities/A-Response/A-Response.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,gDAM0B;AAK1B,uEAKmC;AACnC,sGAA6F;AAC7F,4CAA0C;AAK1C,MAAa,UAEX,SAAQ,oBAGT;IALD;;QASI;;WAEG;QACH,aAAQ,GAAW,CAAC,CAAC;QAGb,SAAI,GAA+B,IAAI,GAAG,EAAE,CAAC;IA2JzD,CAAC;IAvJG,OAAO,CAAC,SAA8C;QAClD,IAAI,CAAC,GAAG,GAAG,SAAS,CAAC,QAAQ,CAAC;QAE9B,IAAI,CAAC,KAAK,GAAG,IAAI,iBAAK,CAAC;YACnB,OAAO,EAAE,qBAAS,CAAC,IAAI,CAAC,IAAI;YAC5B,KAAK,EAAE,SAAS,CAAC,KAAK;YACtB,MAAM,EAAG,IAAI,CAAC,WAAiC,CAAC,MAAM;YACtD,EAAE,EAAE,SAAS,CAAC,EAAE;SACnB,CAAC,CAAC;IACP,CAAC;IAED,IAAI,WAAW;QACX,OAAO,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC;IAChC,CAAC;IAED,IAAI,QAAQ;QACR,OAAO,IAAI,CAAC,GAAG,CAAC;IACpB,CAAC;IAED,IAAI,UAAU;QACV,OAAO,IAAI,CAAC,GAAG,CAAC,UAAU,CA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,CAAC,MAAM,EAAE,CAAC;;gBAG1B,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;YACrB,OAAO,GAAG,CAAC;QACf,CAAC,EAAE,EAAE,CAAC,CAAC;IACX,CAAC;CACJ;AA1KD,gCA0KC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A_TYPES__Entity_Serialized } from "@adaas/a-concept";
|
|
2
2
|
import { ServerResponse } from "http";
|
|
3
3
|
export type A_SERVER_TYPES__ResponseConstructor = {
|
|
4
4
|
/**
|
|
@@ -15,5 +15,5 @@ export declare enum A_SERVER_TYPES__ResponseEvent {
|
|
|
15
15
|
End = "end",
|
|
16
16
|
Close = "close"
|
|
17
17
|
}
|
|
18
|
-
export type A_SERVER_TYPES__ResponseSerialized =
|
|
18
|
+
export type A_SERVER_TYPES__ResponseSerialized = A_TYPES__Entity_Serialized;
|
|
19
19
|
export type A_SERVER_TYPES__SendResponseObject<_ResponseType = any> = Record<string, _ResponseType>;
|
|
@@ -10,7 +10,9 @@ class A_Route {
|
|
|
10
10
|
* returns path only without query and hash
|
|
11
11
|
*/
|
|
12
12
|
get path() {
|
|
13
|
-
|
|
13
|
+
const p = this.url.split('?')[0].split('#')[0];
|
|
14
|
+
// ensure that last char is not /
|
|
15
|
+
return p.endsWith('/') ? p.slice(0, -1) : p;
|
|
14
16
|
}
|
|
15
17
|
get params() {
|
|
16
18
|
var _a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"A-Route.entity.js","sourceRoot":"","sources":["../../../../src/entities/A-Route/A-Route.entity.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"A-Route.entity.js","sourceRoot":"","sources":["../../../../src/entities/A-Route/A-Route.entity.ts"],"names":[],"mappings":";;;AAIA,MAAa,OAAO;IAahB,YACI,MAAuB,EACvB,MAAuC;QAGvC,IAAI,CAAC,GAAG,GAAG,MAAM,YAAY,MAAM,CAAC,CAAC,CAAC,MA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M,CAAC,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC;IAC5F,CAAC;IAED,mBAAmB,CAAC,iBAAgC,EAAE;QAClD,OAAO,IAAI,MAAM,CAAC,IAAI,cAAc,CAAC,MAAM;YACvC,CAAC,CAAC,IAAI,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG;YACjC,CAAC,CAAC,IACF,MAAM,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC;IAChF,CAAC;CACJ;AA/GD,0BA+GC"}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.A_EntityList = void 0;
|
|
4
4
|
const a_concept_1 = require("@adaas/a-concept");
|
|
5
|
-
const a_utils_1 = require("@adaas/a-utils");
|
|
6
5
|
/**
|
|
7
6
|
* A-EntityList
|
|
8
7
|
*
|
|
@@ -45,8 +44,8 @@ class A_EntityList extends a_concept_1.A_Entity {
|
|
|
45
44
|
* @param newEntity
|
|
46
45
|
*/
|
|
47
46
|
fromNew(newEntity) {
|
|
48
|
-
this.aseid = new
|
|
49
|
-
|
|
47
|
+
this.aseid = new a_concept_1.ASEID({
|
|
48
|
+
concept: a_concept_1.A_Context.root.name,
|
|
50
49
|
scope: 'default',
|
|
51
50
|
entity: 'a-list' + (newEntity.name ? `.${newEntity.name}` : ''),
|
|
52
51
|
id: (new Date()).getTime().toString(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"A_EntityList.entity.js","sourceRoot":"","sources":["../../../../src/entities/A_EntityList/A_EntityList.entity.ts"],"names":[],"mappings":";;;AAAA,gDAG0B;
|
|
1
|
+
{"version":3,"file":"A_EntityList.entity.js","sourceRoot":"","sources":["../../../../src/entities/A_EntityList/A_Entity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BAAM,CAAC;gBACJ,MAAM,MAAM,GAAG,IAAI,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;gBACjD,OAAO,MAAM,CAAC;YAClB,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,IAAI,UAAU,EAAE,CAAC;YACb,IAAI,CAAC,WAAW,GAAG;gBACf,KAAK,EAAE,UAAU,CAAC,KAAK;gBACvB,IAAI,EAAE,UAAU,CAAC,IAAI;gBACrB,QAAQ,EAAE,UAAU,CAAC,QAAQ;aAChC,CAAA;QACL,CAAC;IACL,CAAC;IAID;;;;OAIG;IACH,MAAM;QACF,uCACO,KAAK,CAAC,MAAM,EAAE,KACjB,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,CAAuC,EAC7E,UAAU,EAAE,IAAI,CAAC,WAAW,IAC/B;IACL,CAAC;CACJ;AA1GD,oCA0GC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A_Entity,
|
|
1
|
+
import { A_Entity, A_TYPES__Entity_Serialized } from "@adaas/a-concept";
|
|
2
2
|
export type A_SERVER_TYPES__A_EntityListConstructor = {
|
|
3
3
|
name: string;
|
|
4
4
|
scope: string;
|
|
@@ -13,7 +13,7 @@ export type A_SERVER_TYPES__A_EntityListSerialized<EntityTypes extends A_Entity
|
|
|
13
13
|
items: Array<ReturnType<EntityTypes['toJSON']>>;
|
|
14
14
|
type: string;
|
|
15
15
|
pagination: A_SERVER_TYPES__A_EntityListPagination;
|
|
16
|
-
} &
|
|
16
|
+
} & A_TYPES__Entity_Serialized;
|
|
17
17
|
export type A_SERVER_TYPES__A_EntityListPagination = {
|
|
18
18
|
total: number;
|
|
19
19
|
page: number;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { A_Command } from "@adaas/a-
|
|
1
|
+
import { A_Command } from "@adaas/a-utils";
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
export class SignInCommand extends A_Command<{ email: string, password: string }, { token: string }> {
|
|
6
6
|
|
|
7
|
-
static get
|
|
7
|
+
static get entity(): string {
|
|
8
8
|
return 'sign-in';
|
|
9
9
|
}
|
|
10
10
|
}
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import { A_Component, A_Feature, A_Inject
|
|
1
|
+
import { A_Component, A_Feature, A_Inject } from "@adaas/a-concept";
|
|
2
2
|
import { A_Router } from "@adaas/a-server/components/A-Router/A-Router.component";
|
|
3
3
|
import { A_Request } from "@adaas/a-server/entities/A-Request/A-Request.entity";
|
|
4
4
|
import { A_Response } from "@adaas/a-server/entities/A-Response/A-Response.entity";
|
|
5
|
+
import { A_CONSTANTS_A_Command_Features, A_Logger } from "@adaas/a-utils";
|
|
6
|
+
import { SignInCommand } from "../commands/SignIn.command";
|
|
5
7
|
|
|
6
8
|
|
|
7
9
|
export class TestController extends A_Component {
|
|
8
10
|
|
|
9
11
|
|
|
10
12
|
|
|
11
|
-
@A_Feature.Define({
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
})
|
|
13
|
+
// @A_Feature.Define({
|
|
14
|
+
// name: 'test',
|
|
15
|
+
// invoke: false,
|
|
16
|
+
// })
|
|
15
17
|
@A_Router.Get({
|
|
16
18
|
path: '/test',
|
|
17
19
|
version: 'v1',
|
|
@@ -43,4 +45,16 @@ export class TestController extends A_Component {
|
|
|
43
45
|
|
|
44
46
|
response.add('test', 'test');
|
|
45
47
|
}
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
@A_Feature.Extend({
|
|
53
|
+
name: A_CONSTANTS_A_Command_Features.EXECUTE,
|
|
54
|
+
scope: [SignInCommand]
|
|
55
|
+
})
|
|
56
|
+
signIn() {
|
|
57
|
+
console.log('!!!!!!!!!!!!!!!!!!!!!!Sign-in feature extended in TestController');
|
|
58
|
+
|
|
59
|
+
}
|
|
46
60
|
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { A_Component, A_Entity, A_Feature, A_Inject,
|
|
1
|
+
import { A_Component, A_Entity, A_Feature, A_Inject, A_Scope, } from "@adaas/a-concept";
|
|
2
2
|
import { User } from "../entities/User/User.entity";
|
|
3
3
|
import { UserJSON } from "../entities/User/User.entity.types";
|
|
4
4
|
import { A_EntityList } from "@adaas/a-server/entities/A_EntityList/A_EntityList.entity";
|
|
5
|
-
import { A_ListQueryFilter } from "@adaas/a-server/context/
|
|
5
|
+
import { A_ListQueryFilter } from "@adaas/a-server/context/A-ListQueryFilter/A_ListQueryFilter.context";
|
|
6
|
+
import { A_Command, A_Logger } from "@adaas/a-utils";
|
|
7
|
+
import { A_TYPES__EntityFeatures } from "@adaas/a-concept/dist/src/global/A-Entity/A-Entity.constants";
|
|
8
|
+
import { SignInCommand } from "../commands/SignIn.command";
|
|
6
9
|
|
|
7
10
|
|
|
8
11
|
export class UsersRepository extends A_Component {
|
|
@@ -22,9 +25,9 @@ export class UsersRepository extends A_Component {
|
|
|
22
25
|
|
|
23
26
|
|
|
24
27
|
@A_Feature.Extend({
|
|
25
|
-
name:
|
|
28
|
+
name: 'load',
|
|
26
29
|
scope: {
|
|
27
|
-
exclude: [A_EntityList]
|
|
30
|
+
exclude: [A_EntityList, A_Command, SignInCommand]
|
|
28
31
|
}
|
|
29
32
|
})
|
|
30
33
|
load(
|
|
@@ -44,7 +47,7 @@ export class UsersRepository extends A_Component {
|
|
|
44
47
|
|
|
45
48
|
|
|
46
49
|
@A_Feature.Extend({
|
|
47
|
-
name:
|
|
50
|
+
name: A_TYPES__EntityFeatures.LOAD,
|
|
48
51
|
scope: [A_EntityList]
|
|
49
52
|
})
|
|
50
53
|
list(
|
|
@@ -76,7 +79,7 @@ export class UsersRepository extends A_Component {
|
|
|
76
79
|
|
|
77
80
|
|
|
78
81
|
@A_Feature.Extend({
|
|
79
|
-
name:
|
|
82
|
+
name: A_TYPES__EntityFeatures.SAVE
|
|
80
83
|
})
|
|
81
84
|
create(
|
|
82
85
|
@A_Inject(User) user: User
|
|
@@ -87,7 +90,7 @@ export class UsersRepository extends A_Component {
|
|
|
87
90
|
|
|
88
91
|
|
|
89
92
|
@A_Feature.Extend({
|
|
90
|
-
name:
|
|
93
|
+
name: A_TYPES__EntityFeatures.DESTROY
|
|
91
94
|
})
|
|
92
95
|
delete(
|
|
93
96
|
@A_Inject(User) user: User
|
|
@@ -1,22 +1,17 @@
|
|
|
1
1
|
import { A_EntityController } from "@adaas/a-server/components/A-EntityController/A-EntityController.component"
|
|
2
2
|
import { A_Router } from "@adaas/a-server/components/A-Router/A-Router.component"
|
|
3
3
|
import { A_Service } from "@adaas/a-server/containers/A-Service/A-Service.container"
|
|
4
|
-
import { A_EntityFactory } from "@adaas/a-server/context/A-EntityFactory/A-EntityFactory.context"
|
|
5
4
|
import { User } from "./entities/User/User.entity"
|
|
6
5
|
import { A_ServerLogger } from "@adaas/a-server/components/A-ServerLogger/A_ServerLogger.component"
|
|
7
6
|
import {
|
|
8
7
|
A_Concept,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
A_ErrorsManager,
|
|
12
|
-
ConfigReader,
|
|
13
|
-
ENVConfigReader,
|
|
14
|
-
FileConfigReader
|
|
8
|
+
A_CONSTANTS__DEFAULT_ENV_VARIABLES,
|
|
9
|
+
A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY,
|
|
15
10
|
} from "@adaas/a-concept"
|
|
16
11
|
import { UsersRepository } from "./components/Users.repository"
|
|
17
12
|
import { TestController } from "./components/Test.controller"
|
|
18
13
|
import { A_ServerHealthMonitor } from "@adaas/a-server/components/A-ServerHealthMonitor/A-ServerHealthMonitor.component"
|
|
19
|
-
import { A_ProxyConfig } from "@adaas/a-server/context/
|
|
14
|
+
import { A_ProxyConfig } from "@adaas/a-server/context/A-ProxyConfig/A_ProxyConfig.context"
|
|
20
15
|
import { A_ServerProxy } from "@adaas/a-server/components/A-ServerProxy/A-ServerProxy.component"
|
|
21
16
|
import { A_ServerCORS } from "@adaas/a-server/components/A-ServerCORS/A_ServerCORS.component"
|
|
22
17
|
import { A_StaticLoader } from "@adaas/a-server/components/A-StaticLoader/A-StaticLoader.component"
|
|
@@ -26,14 +21,18 @@ import { A_Controller } from "@adaas/a-server/components/A-Controller/A-Controll
|
|
|
26
21
|
import { A_ListingController } from "@adaas/a-server/components/A-ListingController/A-ListingController.component"
|
|
27
22
|
import { A_CommandController } from "@adaas/a-server/components/A-CommandController/A-CommandController.component"
|
|
28
23
|
import { SignInCommand } from "./commands/SignIn.command"
|
|
24
|
+
import { A_Config, A_ConfigLoader, A_Polyfill, ConfigReader, ENVConfigReader, FileConfigReader } from "@adaas/a-utils"
|
|
29
25
|
|
|
30
26
|
|
|
31
27
|
|
|
32
28
|
(async () => {
|
|
33
29
|
const config = new A_Config({
|
|
34
|
-
variables: [
|
|
30
|
+
variables: [
|
|
31
|
+
...A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY,
|
|
32
|
+
'A_SERVER_PORT', 'A_ROUTER__PARSE_PARAMS_AUTOMATICALLY', 'CONFIG_VERBOSE', 'DEV_MODE'
|
|
33
|
+
] as const,
|
|
35
34
|
defaults: {
|
|
36
|
-
|
|
35
|
+
A_SERVER_PORT: 3000,
|
|
37
36
|
A_ROUTER__PARSE_PARAMS_AUTOMATICALLY: true,
|
|
38
37
|
CONFIG_VERBOSE: true,
|
|
39
38
|
DEV_MODE: true
|
|
@@ -42,8 +41,6 @@ import { SignInCommand } from "./commands/SignIn.command"
|
|
|
42
41
|
|
|
43
42
|
const SharedConfig = new A_ConfigLoader({
|
|
44
43
|
components: [
|
|
45
|
-
ConfigReader,
|
|
46
|
-
FileConfigReader,
|
|
47
44
|
ENVConfigReader
|
|
48
45
|
],
|
|
49
46
|
fragments: [config]
|
|
@@ -52,7 +49,7 @@ import { SignInCommand } from "./commands/SignIn.command"
|
|
|
52
49
|
|
|
53
50
|
const Server = new A_Service({
|
|
54
51
|
components: [
|
|
55
|
-
|
|
52
|
+
A_Polyfill,
|
|
56
53
|
A_ServerLogger,
|
|
57
54
|
A_Router,
|
|
58
55
|
A_EntityController,
|
|
@@ -65,16 +62,16 @@ import { SignInCommand } from "./commands/SignIn.command"
|
|
|
65
62
|
A_Controller,
|
|
66
63
|
A_ServerCORS,
|
|
67
64
|
A_ListingController,
|
|
68
|
-
A_CommandController
|
|
65
|
+
A_CommandController,
|
|
66
|
+
|
|
69
67
|
],
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
entities: [
|
|
69
|
+
// commands
|
|
70
|
+
SignInCommand,
|
|
71
|
+
User
|
|
72
72
|
],
|
|
73
73
|
fragments: [
|
|
74
|
-
config
|
|
75
|
-
new A_EntityFactory({
|
|
76
|
-
'user': User
|
|
77
|
-
})
|
|
74
|
+
config
|
|
78
75
|
]
|
|
79
76
|
});
|
|
80
77
|
|
|
@@ -95,6 +92,7 @@ import { SignInCommand } from "./commands/SignIn.command"
|
|
|
95
92
|
const concept = new A_Concept({
|
|
96
93
|
name: 'simple-server-concept',
|
|
97
94
|
containers: [SharedConfig, Server],
|
|
95
|
+
components: [A_Polyfill],
|
|
98
96
|
fragments: [
|
|
99
97
|
config,
|
|
100
98
|
new A_ProxyConfig({
|
|
@@ -108,6 +106,7 @@ import { SignInCommand } from "./commands/SignIn.command"
|
|
|
108
106
|
});
|
|
109
107
|
|
|
110
108
|
|
|
109
|
+
|
|
111
110
|
await concept.load();
|
|
112
111
|
await concept.start();
|
|
113
112
|
})()
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import { A_Entity, A_Feature, A_Scope,
|
|
1
|
+
import { A_Entity, A_Feature, A_Scope, ASEID, } from "@adaas/a-concept";
|
|
2
2
|
import { NewUser, UserJSON } from "./User.entity.types";
|
|
3
|
-
import { ASEID } from "@adaas/a-utils";
|
|
4
3
|
import { UserDoing } from "examples/simple-server/context/UserDoing.context";
|
|
5
4
|
|
|
6
5
|
|
|
7
6
|
export class User extends A_Entity<NewUser, UserJSON> {
|
|
8
7
|
|
|
8
|
+
static get entity(): string {
|
|
9
|
+
return 'user';
|
|
10
|
+
}
|
|
11
|
+
|
|
9
12
|
email!: string;
|
|
10
13
|
name!: string;
|
|
11
14
|
|
|
@@ -23,10 +26,10 @@ export class User extends A_Entity<NewUser, UserJSON> {
|
|
|
23
26
|
}
|
|
24
27
|
|
|
25
28
|
|
|
26
|
-
@A_Feature.Define({
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
})
|
|
29
|
+
// @A_Feature.Define({
|
|
30
|
+
// name: 'do',
|
|
31
|
+
// invoke: false
|
|
32
|
+
// })
|
|
30
33
|
async do(scope: A_Scope) {
|
|
31
34
|
console.log('Doing something with user:', this.name);
|
|
32
35
|
|
|
@@ -41,7 +44,7 @@ export class User extends A_Entity<NewUser, UserJSON> {
|
|
|
41
44
|
fromNew(newEntity: NewUser): void {
|
|
42
45
|
this.aseid = new ASEID({
|
|
43
46
|
id: newEntity.id,
|
|
44
|
-
|
|
47
|
+
concept: 'users1',
|
|
45
48
|
scope: 'users2',
|
|
46
49
|
entity: 'user3'
|
|
47
50
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A_TYPES__Entity_Serialized } from "@adaas/a-concept"
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
export type NewUser = {
|
|
@@ -8,4 +8,4 @@ export type NewUser = {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
export type UserJSON = NewUser &
|
|
11
|
+
export type UserJSON = NewUser & A_TYPES__Entity_Serialized
|