@adaas/a-server 0.0.29 → 0.0.31
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/browser/index.d.mts +123 -69
- package/dist/browser/index.mjs +211 -69
- package/dist/browser/index.mjs.map +1 -1
- package/dist/node/controllers/A-EntityController/A-EntityController.component.d.mts +2 -5
- package/dist/node/controllers/A-EntityController/A-EntityController.component.d.ts +2 -5
- package/dist/node/controllers/A-EntityController/A-EntityController.component.js +66 -88
- package/dist/node/controllers/A-EntityController/A-EntityController.component.js.map +1 -1
- package/dist/node/controllers/A-EntityController/A-EntityController.component.mjs +67 -89
- package/dist/node/controllers/A-EntityController/A-EntityController.component.mjs.map +1 -1
- package/dist/node/controllers/A-ListingController/A-ListingController.component.js +20 -18
- package/dist/node/controllers/A-ListingController/A-ListingController.component.js.map +1 -1
- package/dist/node/controllers/A-ListingController/A-ListingController.component.mjs +20 -18
- package/dist/node/controllers/A-ListingController/A-ListingController.component.mjs.map +1 -1
- package/dist/node/controllers/A-ServerHealthMonitor/A-ServerHealthMonitor.component.d.mts +0 -2
- package/dist/node/controllers/A-ServerHealthMonitor/A-ServerHealthMonitor.component.d.ts +0 -2
- package/dist/node/controllers/A-ServerHealthMonitor/A-ServerHealthMonitor.component.js +10 -1
- package/dist/node/controllers/A-ServerHealthMonitor/A-ServerHealthMonitor.component.js.map +1 -1
- package/dist/node/controllers/A-ServerHealthMonitor/A-ServerHealthMonitor.component.mjs +10 -1
- package/dist/node/controllers/A-ServerHealthMonitor/A-ServerHealthMonitor.component.mjs.map +1 -1
- package/dist/node/index.d.mts +3 -1
- package/dist/node/index.d.ts +3 -1
- package/dist/node/index.js +14 -0
- package/dist/node/index.mjs +2 -0
- package/dist/node/lib/A-Server/A-HttpServer.container.d.mts +4 -6
- package/dist/node/lib/A-Server/A-HttpServer.container.d.ts +4 -6
- package/dist/node/lib/A-ServerController/A-ServerController.component.js +17 -4
- package/dist/node/lib/A-ServerController/A-ServerController.component.js.map +1 -1
- package/dist/node/lib/A-ServerController/A-ServerController.component.mjs +17 -4
- package/dist/node/lib/A-ServerController/A-ServerController.component.mjs.map +1 -1
- package/dist/node/lib/A-ServerEntityList/A-EntityList.entity.d.mts +52 -28
- package/dist/node/lib/A-ServerEntityList/A-EntityList.entity.d.ts +52 -28
- package/dist/node/lib/A-ServerEntityList/A-EntityList.entity.js +117 -44
- package/dist/node/lib/A-ServerEntityList/A-EntityList.entity.js.map +1 -1
- package/dist/node/lib/A-ServerEntityList/A-EntityList.entity.mjs +118 -45
- package/dist/node/lib/A-ServerEntityList/A-EntityList.entity.mjs.map +1 -1
- package/dist/node/lib/A-ServerEntityList/A-EntityList.types.d.mts +14 -6
- package/dist/node/lib/A-ServerEntityList/A-EntityList.types.d.ts +14 -6
- package/dist/node/lib/A-ServerEntityList/A-EntityList.types.js.map +1 -1
- package/dist/node/lib/A-ServerEntityList/A-EntityList.types.mjs.map +1 -1
- package/dist/node/lib/A-ServerEntityList/A-EntityListCacheState.context.d.mts +12 -0
- package/dist/node/lib/A-ServerEntityList/A-EntityListCacheState.context.d.ts +12 -0
- package/dist/node/lib/A-ServerEntityList/A-EntityListCacheState.context.js +25 -0
- package/dist/node/lib/A-ServerEntityList/A-EntityListCacheState.context.js.map +1 -0
- package/dist/node/lib/A-ServerEntityList/A-EntityListCacheState.context.mjs +24 -0
- package/dist/node/lib/A-ServerEntityList/A-EntityListCacheState.context.mjs.map +1 -0
- package/dist/node/lib/A-ServerEntityList/A-EntityListPagination.context.d.mts +18 -0
- package/dist/node/lib/A-ServerEntityList/A-EntityListPagination.context.d.ts +18 -0
- package/dist/node/lib/A-ServerEntityList/A-EntityListPagination.context.js +48 -0
- package/dist/node/lib/A-ServerEntityList/A-EntityListPagination.context.js.map +1 -0
- package/dist/node/lib/A-ServerEntityList/A-EntityListPagination.context.mjs +47 -0
- package/dist/node/lib/A-ServerEntityList/A-EntityListPagination.context.mjs.map +1 -0
- package/dist/node/lib/A-ServerLogger/A-ServerLogger.component.d.mts +6 -8
- package/dist/node/lib/A-ServerLogger/A-ServerLogger.component.d.ts +6 -8
- package/dist/node/lib/A-ServerLogger/A-ServerLogger.component.js +3 -4
- package/dist/node/lib/A-ServerLogger/A-ServerLogger.component.js.map +1 -1
- package/dist/node/lib/A-ServerLogger/A-ServerLogger.component.mjs +4 -5
- package/dist/node/lib/A-ServerLogger/A-ServerLogger.component.mjs.map +1 -1
- package/dist/node/lib/A-ServerRouter/A-ServerRouter.component.d.mts +0 -2
- package/dist/node/lib/A-ServerRouter/A-ServerRouter.component.d.ts +0 -2
- package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.component.js +1 -1
- package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.component.js.map +1 -1
- package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.component.mjs +1 -1
- package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.component.mjs.map +1 -1
- package/dist/node/repositories/A-EntityRepository/A-EntityRepository.component.d.mts +1 -0
- package/dist/node/repositories/A-EntityRepository/A-EntityRepository.component.d.ts +1 -0
- package/examples/simple-server/components/Users.repository.ts +2 -2
- package/jest.config.ts +1 -0
- package/package.json +5 -5
- package/src/controllers/A-EntityController/A-EntityController.component.ts +69 -109
- package/src/controllers/A-ListingController/A-ListingController.component.ts +22 -20
- package/src/controllers/A-ServerHealthMonitor/A-ServerHealthMonitor.component.ts +11 -1
- package/src/index.ts +2 -0
- package/src/lib/A-ServerController/A-ServerController.component.ts +17 -8
- package/src/lib/A-ServerEntityList/A-EntityList.entity.ts +159 -55
- package/src/lib/A-ServerEntityList/A-EntityList.types.ts +17 -7
- package/src/lib/A-ServerEntityList/A-EntityListCacheState.context.ts +27 -0
- package/src/lib/A-ServerEntityList/A-EntityListPagination.context.ts +48 -0
- package/src/lib/A-ServerLogger/A-ServerLogger.component.ts +3 -4
- package/src/middlewares/A-ServerCORS/A_ServerCORS.component.ts +1 -1
- package/tests/A-Server-CORS.test.ts +542 -0
- package/tests/A-Server-Entity.test.ts +205 -0
- package/tests/A-Server-Health.test.ts +89 -0
- package/tests/A-Server-Routes.test.ts +113 -0
- package/tests/A-ServerEntityList.test.ts +416 -0
|
@@ -7,6 +7,7 @@ var AResponse_entity = require('@adaas/a-server/response/A-Response.entity');
|
|
|
7
7
|
var AServerRouter_component = require('@adaas/a-server/router/A-ServerRouter.component');
|
|
8
8
|
var AEntityList_entity = require('@adaas/a-server/entity-list/A-EntityList.entity');
|
|
9
9
|
var AServerListQueryFilter_context = require('@adaas/a-server/list-query/A-ServerListQueryFilter.context');
|
|
10
|
+
var AHttpServer_error = require('../../lib/A-Server/A-HttpServer.error');
|
|
10
11
|
|
|
11
12
|
var __defProp = Object.defineProperty;
|
|
12
13
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -21,25 +22,26 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
21
22
|
var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index);
|
|
22
23
|
class A_ListingController extends aConcept.A_Component {
|
|
23
24
|
async list(request, response, scope, config) {
|
|
24
|
-
const
|
|
25
|
-
if (
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
constructor
|
|
25
|
+
const ctor = scope.resolveConstructor(request.params.type);
|
|
26
|
+
if (!ctor)
|
|
27
|
+
throw new AHttpServer_error.A_HttpServerError({
|
|
28
|
+
status: 404,
|
|
29
|
+
description: `Entity type "${request.params.type}" not registered`
|
|
30
30
|
});
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
31
|
+
const entityList = new AEntityList_entity.A_ServerEntityList({
|
|
32
|
+
entity: ctor
|
|
33
|
+
});
|
|
34
|
+
scope.register(entityList);
|
|
35
|
+
const queryFilter = new AServerListQueryFilter_context.A_ServerListQueryFilter(request.query, {
|
|
36
|
+
itemsPerPage: String(config.get("A_LIST_ITEMS_PER_PAGE") || "10"),
|
|
37
|
+
page: String(config.get("A_LIST_PAGE") || "1")
|
|
38
|
+
});
|
|
39
|
+
const queryScope = new aConcept.A_Scope({
|
|
40
|
+
fragments: [queryFilter]
|
|
41
|
+
}).inherit(scope);
|
|
42
|
+
await entityList.load(queryScope);
|
|
43
|
+
response.add("items", entityList.items);
|
|
44
|
+
response.add("pagination", entityList.pagination);
|
|
43
45
|
}
|
|
44
46
|
}
|
|
45
47
|
__decorateClass([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/controllers/A-ListingController/A-ListingController.component.ts"],"names":["A_Component","A_ServerEntityList","A_ServerListQueryFilter","A_Scope","A_ServerRouter","A_Request","A_Response","A_Config"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/controllers/A-ListingController/A-ListingController.component.ts"],"names":["A_Component","A_HttpServerError","A_ServerEntityList","A_ServerListQueryFilter","A_Scope","A_ServerRouter","A_Request","A_Response","A_Config"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAWO,MAAM,4BAA4BA,oBAAA,CAAY;AAAA,EAWjD,MAAM,IAAA,CACmB,OAAA,EACC,QAAA,EACH,OACC,MAAA,EACtB;AAEE,IAAA,MAAM,IAAA,GAAO,KAAA,CAAM,kBAAA,CAAmB,OAAA,CAAQ,OAAO,IAAI,CAAA;AAEzD,IAAA,IAAI,CAAC,IAAA;AACD,MAAA,MAAM,IAAIC,mCAAA,CAAkB;AAAA,QACxB,MAAA,EAAQ,GAAA;AAAA,QACR,WAAA,EAAa,CAAA,aAAA,EAAgB,OAAA,CAAQ,MAAA,CAAO,IAAI,CAAA,gBAAA;AAAA,OACnD,CAAA;AAEL,IAAA,MAAM,UAAA,GAAa,IAAIC,qCAAA,CAAmB;AAAA,MACtC,MAAA,EAAQ;AAAA,KACX,CAAA;AAED,IAAA,KAAA,CAAM,SAAS,UAAU,CAAA;AAEzB,IAAA,MAAM,WAAA,GAAc,IAAIC,sDAAA,CAAwB,OAAA,CAAQ,KAAA,EAAO;AAAA,MAC3D,cAAc,MAAA,CAAO,MAAA,CAAO,GAAA,CAAI,uBAAuB,KAAK,IAAI,CAAA;AAAA,MAChE,MAAM,MAAA,CAAO,MAAA,CAAO,GAAA,CAAI,aAAa,KAAK,GAAG;AAAA,KAChD,CAAA;AAED,IAAA,MAAM,UAAA,GAAa,IAAIC,gBAAA,CAAQ;AAAA,MAC3B,SAAA,EAAW,CAAC,WAAW;AAAA,KAC1B,CAAA,CAAE,OAAA,CAAQ,KAAK,CAAA;AAEhB,IAAA,MAAM,UAAA,CAAW,KAAK,UAAU,CAAA;AAEhC,IAAA,QAAA,CAAS,GAAA,CAAI,OAAA,EAAS,UAAA,CAAW,KAAK,CAAA;AACtC,IAAA,QAAA,CAAS,GAAA,CAAI,YAAA,EAAc,UAAA,CAAW,UAAU,CAAA;AAAA,EACpD;AACJ;AAnCU,eAAA,CAAA;AAAA,EALLC,uCAAe,GAAA,CAAI;AAAA,IAChB,IAAA,EAAM,QAAA;AAAA,IACN,OAAA,EAAS,IAAA;AAAA,IACT,MAAA,EAAQ;AAAA,GACX,CAAA;AAAA,EAEI,qCAASC,yBAAS,CAAA,CAAA;AAAA,EAClB,qCAASC,2BAAU,CAAA,CAAA;AAAA,EACnB,qCAASH,gBAAO,CAAA,CAAA;AAAA,EAChB,qCAASI,gBAAQ,CAAA;AAAA,CAAA,EAfb,mBAAA,CAWH,SAAA,EAAA,MAAA,CAAA","file":"A-ListingController.component.js","sourcesContent":["import { A_Component, A_Feature, A_Inject, A_Scope } from \"@adaas/a-concept\"\nimport { A_Config } from \"@adaas/a-utils/a-config\";\nimport { A_Request } from \"@adaas/a-server/request/A-Request.entity\";\nimport { A_Response } from \"@adaas/a-server/response/A-Response.entity\";\nimport { A_ServerRouter } from \"@adaas/a-server/router/A-ServerRouter.component\";\nimport { A_ServerEntityList } from \"@adaas/a-server/entity-list/A-EntityList.entity\";\nimport { A_ServerListQueryFilter } from \"@adaas/a-server/list-query/A-ServerListQueryFilter.context\";\nimport { A_HttpServerError } from \"../../lib/A-Server/A-HttpServer.error\";\n\n\n\nexport class A_ListingController extends A_Component {\n\n // @A_Feature.Define({\n // name: 'listEntities',\n // invoke: false\n // })\n @A_ServerRouter.Get({\n path: '/:type',\n version: 'v1',\n prefix: 'a-list'\n })\n async list(\n @A_Inject(A_Request) request: A_Request<any, any, { type: string }>,\n @A_Inject(A_Response) response: A_Response,\n @A_Inject(A_Scope) scope: A_Scope,\n @A_Inject(A_Config) config: A_Config<['A_LIST_ITEMS_PER_PAGE', 'A_LIST_PAGE']>\n ) {\n\n const ctor = scope.resolveConstructor(request.params.type);\n\n if (!ctor)\n throw new A_HttpServerError({\n status: 404,\n description: `Entity type \"${request.params.type}\" not registered`,\n });\n\n const entityList = new A_ServerEntityList({\n entity: ctor,\n });\n\n scope.register(entityList);\n\n const queryFilter = new A_ServerListQueryFilter(request.query, {\n itemsPerPage: String(config.get('A_LIST_ITEMS_PER_PAGE') || '10'),\n page: String(config.get('A_LIST_PAGE') || '1'),\n });\n\n const queryScope = new A_Scope({\n fragments: [queryFilter],\n }).inherit(scope);\n\n await entityList.load(queryScope);\n\n response.add('items', entityList.items);\n response.add('pagination', entityList.pagination);\n }\n}"]}
|
|
@@ -6,28 +6,30 @@ import { A_Response } from '@adaas/a-server/response/A-Response.entity';
|
|
|
6
6
|
import { A_ServerRouter } from '@adaas/a-server/router/A-ServerRouter.component';
|
|
7
7
|
import { A_ServerEntityList } from '@adaas/a-server/entity-list/A-EntityList.entity';
|
|
8
8
|
import { A_ServerListQueryFilter } from '@adaas/a-server/list-query/A-ServerListQueryFilter.context';
|
|
9
|
+
import { A_HttpServerError } from '../../lib/A-Server/A-HttpServer.error';
|
|
9
10
|
|
|
10
11
|
class A_ListingController extends A_Component {
|
|
11
12
|
async list(request, response, scope, config) {
|
|
12
|
-
const
|
|
13
|
-
if (
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
constructor
|
|
13
|
+
const ctor = scope.resolveConstructor(request.params.type);
|
|
14
|
+
if (!ctor)
|
|
15
|
+
throw new A_HttpServerError({
|
|
16
|
+
status: 404,
|
|
17
|
+
description: `Entity type "${request.params.type}" not registered`
|
|
18
18
|
});
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
19
|
+
const entityList = new A_ServerEntityList({
|
|
20
|
+
entity: ctor
|
|
21
|
+
});
|
|
22
|
+
scope.register(entityList);
|
|
23
|
+
const queryFilter = new A_ServerListQueryFilter(request.query, {
|
|
24
|
+
itemsPerPage: String(config.get("A_LIST_ITEMS_PER_PAGE") || "10"),
|
|
25
|
+
page: String(config.get("A_LIST_PAGE") || "1")
|
|
26
|
+
});
|
|
27
|
+
const queryScope = new A_Scope({
|
|
28
|
+
fragments: [queryFilter]
|
|
29
|
+
}).inherit(scope);
|
|
30
|
+
await entityList.load(queryScope);
|
|
31
|
+
response.add("items", entityList.items);
|
|
32
|
+
response.add("pagination", entityList.pagination);
|
|
31
33
|
}
|
|
32
34
|
}
|
|
33
35
|
__decorateClass([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/controllers/A-ListingController/A-ListingController.component.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/controllers/A-ListingController/A-ListingController.component.ts"],"names":[],"mappings":";;;;;;;;;;AAWO,MAAM,4BAA4B,WAAA,CAAY;AAAA,EAWjD,MAAM,IAAA,CACmB,OAAA,EACC,QAAA,EACH,OACC,MAAA,EACtB;AAEE,IAAA,MAAM,IAAA,GAAO,KAAA,CAAM,kBAAA,CAAmB,OAAA,CAAQ,OAAO,IAAI,CAAA;AAEzD,IAAA,IAAI,CAAC,IAAA;AACD,MAAA,MAAM,IAAI,iBAAA,CAAkB;AAAA,QACxB,MAAA,EAAQ,GAAA;AAAA,QACR,WAAA,EAAa,CAAA,aAAA,EAAgB,OAAA,CAAQ,MAAA,CAAO,IAAI,CAAA,gBAAA;AAAA,OACnD,CAAA;AAEL,IAAA,MAAM,UAAA,GAAa,IAAI,kBAAA,CAAmB;AAAA,MACtC,MAAA,EAAQ;AAAA,KACX,CAAA;AAED,IAAA,KAAA,CAAM,SAAS,UAAU,CAAA;AAEzB,IAAA,MAAM,WAAA,GAAc,IAAI,uBAAA,CAAwB,OAAA,CAAQ,KAAA,EAAO;AAAA,MAC3D,cAAc,MAAA,CAAO,MAAA,CAAO,GAAA,CAAI,uBAAuB,KAAK,IAAI,CAAA;AAAA,MAChE,MAAM,MAAA,CAAO,MAAA,CAAO,GAAA,CAAI,aAAa,KAAK,GAAG;AAAA,KAChD,CAAA;AAED,IAAA,MAAM,UAAA,GAAa,IAAI,OAAA,CAAQ;AAAA,MAC3B,SAAA,EAAW,CAAC,WAAW;AAAA,KAC1B,CAAA,CAAE,OAAA,CAAQ,KAAK,CAAA;AAEhB,IAAA,MAAM,UAAA,CAAW,KAAK,UAAU,CAAA;AAEhC,IAAA,QAAA,CAAS,GAAA,CAAI,OAAA,EAAS,UAAA,CAAW,KAAK,CAAA;AACtC,IAAA,QAAA,CAAS,GAAA,CAAI,YAAA,EAAc,UAAA,CAAW,UAAU,CAAA;AAAA,EACpD;AACJ;AAnCU,eAAA,CAAA;AAAA,EALL,eAAe,GAAA,CAAI;AAAA,IAChB,IAAA,EAAM,QAAA;AAAA,IACN,OAAA,EAAS,IAAA;AAAA,IACT,MAAA,EAAQ;AAAA,GACX,CAAA;AAAA,EAEI,4BAAS,SAAS,CAAA,CAAA;AAAA,EAClB,4BAAS,UAAU,CAAA,CAAA;AAAA,EACnB,4BAAS,OAAO,CAAA,CAAA;AAAA,EAChB,4BAAS,QAAQ,CAAA;AAAA,CAAA,EAfb,mBAAA,CAWH,SAAA,EAAA,MAAA,EAAA,CAAA,CAAA","file":"A-ListingController.component.mjs","sourcesContent":["import { A_Component, A_Feature, A_Inject, A_Scope } from \"@adaas/a-concept\"\nimport { A_Config } from \"@adaas/a-utils/a-config\";\nimport { A_Request } from \"@adaas/a-server/request/A-Request.entity\";\nimport { A_Response } from \"@adaas/a-server/response/A-Response.entity\";\nimport { A_ServerRouter } from \"@adaas/a-server/router/A-ServerRouter.component\";\nimport { A_ServerEntityList } from \"@adaas/a-server/entity-list/A-EntityList.entity\";\nimport { A_ServerListQueryFilter } from \"@adaas/a-server/list-query/A-ServerListQueryFilter.context\";\nimport { A_HttpServerError } from \"../../lib/A-Server/A-HttpServer.error\";\n\n\n\nexport class A_ListingController extends A_Component {\n\n // @A_Feature.Define({\n // name: 'listEntities',\n // invoke: false\n // })\n @A_ServerRouter.Get({\n path: '/:type',\n version: 'v1',\n prefix: 'a-list'\n })\n async list(\n @A_Inject(A_Request) request: A_Request<any, any, { type: string }>,\n @A_Inject(A_Response) response: A_Response,\n @A_Inject(A_Scope) scope: A_Scope,\n @A_Inject(A_Config) config: A_Config<['A_LIST_ITEMS_PER_PAGE', 'A_LIST_PAGE']>\n ) {\n\n const ctor = scope.resolveConstructor(request.params.type);\n\n if (!ctor)\n throw new A_HttpServerError({\n status: 404,\n description: `Entity type \"${request.params.type}\" not registered`,\n });\n\n const entityList = new A_ServerEntityList({\n entity: ctor,\n });\n\n scope.register(entityList);\n\n const queryFilter = new A_ServerListQueryFilter(request.query, {\n itemsPerPage: String(config.get('A_LIST_ITEMS_PER_PAGE') || '10'),\n page: String(config.get('A_LIST_PAGE') || '1'),\n });\n\n const queryScope = new A_Scope({\n fragments: [queryFilter],\n }).inherit(scope);\n\n await entityList.load(queryScope);\n\n response.add('items', entityList.items);\n response.add('pagination', entityList.pagination);\n }\n}"]}
|
|
@@ -19,8 +19,6 @@ import '../../lib/A-ServerRoute/A-ServerRoute.types.mjs';
|
|
|
19
19
|
import '../../lib/A-ServerRoute/A-ServerRoute.constants.mjs';
|
|
20
20
|
import 'stream';
|
|
21
21
|
import '../../lib/A-Response/A-Response.constants.mjs';
|
|
22
|
-
import '../../lib/A-Server/A-Server.context.mjs';
|
|
23
|
-
import '../../lib/A-Server/A-Server.types.mjs';
|
|
24
22
|
import '@adaas/a-utils/a-logger';
|
|
25
23
|
|
|
26
24
|
declare class A_ServerHealthMonitor extends A_Component {
|
|
@@ -19,8 +19,6 @@ import '../../lib/A-ServerRoute/A-ServerRoute.types.js';
|
|
|
19
19
|
import '../../lib/A-ServerRoute/A-ServerRoute.constants.js';
|
|
20
20
|
import 'stream';
|
|
21
21
|
import '../../lib/A-Response/A-Response.constants.js';
|
|
22
|
-
import '../../lib/A-Server/A-Server.context.js';
|
|
23
|
-
import '../../lib/A-Server/A-Server.types.js';
|
|
24
22
|
import '@adaas/a-utils/a-logger';
|
|
25
23
|
|
|
26
24
|
declare class A_ServerHealthMonitor extends A_Component {
|
|
@@ -6,6 +6,7 @@ var ARequest_entity = require('@adaas/a-server/request/A-Request.entity');
|
|
|
6
6
|
var AResponse_entity = require('@adaas/a-server/response/A-Response.entity');
|
|
7
7
|
var aConfig = require('@adaas/a-utils/a-config');
|
|
8
8
|
var AServerLogger_component = require('@adaas/a-server/logger/A-ServerLogger.component');
|
|
9
|
+
var AHttpServer_error = require('../../lib/A-Server/A-HttpServer.error');
|
|
9
10
|
var fs = require('fs');
|
|
10
11
|
var path = require('path');
|
|
11
12
|
|
|
@@ -29,7 +30,15 @@ class A_ServerHealthMonitor extends aConcept.A_Component {
|
|
|
29
30
|
async get(config, request, response, logger) {
|
|
30
31
|
const rootFolder = config.get("A_CONCEPT_ROOT_FOLDER") || aConcept.A_CONCEPT_ENV.A_CONCEPT_ROOT_FOLDER || process.cwd();
|
|
31
32
|
const pkgPath = path__default.default.join(rootFolder, "package.json");
|
|
32
|
-
|
|
33
|
+
let packageJSON;
|
|
34
|
+
try {
|
|
35
|
+
packageJSON = JSON.parse(fs__default.default.readFileSync(pkgPath, "utf-8"));
|
|
36
|
+
} catch {
|
|
37
|
+
throw new AHttpServer_error.A_HttpServerError({
|
|
38
|
+
status: 500,
|
|
39
|
+
description: `Could not read package.json at "${pkgPath}"`
|
|
40
|
+
});
|
|
41
|
+
}
|
|
33
42
|
const exposedProperties = config.get("EXPOSED_PROPERTIES")?.split(",") || [
|
|
34
43
|
"name",
|
|
35
44
|
"version",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/controllers/A-ServerHealthMonitor/A-ServerHealthMonitor.component.ts"],"names":["A_Component","A_CONCEPT_ENV","path","fs","A_ServerRouter","A_Config","A_Request","A_Response","A_ServerLogger"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/controllers/A-ServerHealthMonitor/A-ServerHealthMonitor.component.ts"],"names":["A_Component","A_CONCEPT_ENV","path","fs","A_HttpServerError","A_ServerRouter","A_Config","A_Request","A_Response","A_ServerLogger"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYO,MAAM,8BAA8BA,oBAAA,CAAY;AAAA,EAYnD,MAAM,GAAA,CACkB,MAAA,EACC,OAAA,EACC,UACI,MAAA,EACd;AACZ,IAAA,MAAM,UAAA,GAAa,OAAO,GAAA,CAAI,uBAAuB,KAAKC,sBAAA,CAAc,qBAAA,IAAyB,QAAQ,GAAA,EAAI;AAC7G,IAAA,MAAM,OAAA,GAAUC,qBAAA,CAAK,IAAA,CAAK,UAAA,EAAY,cAAc,CAAA;AAEpD,IAAA,IAAI,WAAA;AAEJ,IAAA,IAAI;AACA,MAAA,WAAA,GAAc,KAAK,KAAA,CAAMC,mBAAA,CAAG,YAAA,CAAa,OAAA,EAAS,OAAO,CAAC,CAAA;AAAA,IAC9D,CAAA,CAAA,MAAQ;AACJ,MAAA,MAAM,IAAIC,mCAAA,CAAkB;AAAA,QACxB,MAAA,EAAQ,GAAA;AAAA,QACR,WAAA,EAAa,mCAAmC,OAAO,CAAA,CAAA;AAAA,OAC1D,CAAA;AAAA,IACL;AAEA,IAAA,MAAM,oBAAmC,MAAA,CAAO,GAAA,CAAI,oBAAoB,CAAA,EAAG,KAAA,CAAM,GAAG,CAAA,IAAK;AAAA,MACrF,MAAA;AAAA,MACA,SAAA;AAAA,MACA;AAAA,KACJ;AAEA,IAAA,iBAAA,CAAkB,OAAA,CAAQ,UAAQ,QAAA,CAAS,GAAA,CAAI,MAAM,WAAA,CAAY,IAAI,CAAC,CAAC,CAAA;AAAA,EAC3E;AACJ;AA5BU,eAAA,CAAA;AAAA,EALLC,uCAAe,GAAA,CAAI;AAAA,IAChB,IAAA,EAAM,GAAA;AAAA,IACN,MAAA,EAAQ,QAAA;AAAA,IACR,OAAA,EAAS;AAAA,GACZ,CAAA;AAAA,EAEI,qCAASC,gBAAQ,CAAA,CAAA;AAAA,EACjB,qCAASC,yBAAS,CAAA,CAAA;AAAA,EAClB,qCAASC,2BAAU,CAAA,CAAA;AAAA,EACnB,qCAASC,sCAAc,CAAA;AAAA,CAAA,EAhBnB,qBAAA,CAYH,SAAA,EAAA,KAAA,CAAA","file":"A-ServerHealthMonitor.component.js","sourcesContent":["import { A_Component, A_CONCEPT_ENV, A_Inject } from \"@adaas/a-concept\";\nimport { A_ServerRouter } from \"@adaas/a-server/router/A-ServerRouter.component\";\nimport { A_Request } from \"@adaas/a-server/request/A-Request.entity\";\nimport { A_Response } from \"@adaas/a-server/response/A-Response.entity\";\nimport { A_Config } from \"@adaas/a-utils/a-config\";\nimport { A_ServerLogger } from \"@adaas/a-server/logger/A-ServerLogger.component\";\nimport { A_HttpServerError } from \"../../lib/A-Server/A-HttpServer.error\";\nimport fs from \"fs\";\nimport path from \"path\";\n\n\n\nexport class A_ServerHealthMonitor extends A_Component {\n\n\n // =======================================================\n // ================ Method Definition=====================\n // =======================================================\n\n @A_ServerRouter.Get({\n path: '/',\n prefix: 'health',\n version: 'v1',\n })\n async get(\n @A_Inject(A_Config) config: A_Config<['VERSION_PATH', 'EXPOSED_PROPERTIES']>,\n @A_Inject(A_Request) request: A_Request,\n @A_Inject(A_Response) response: A_Response,\n @A_Inject(A_ServerLogger) logger: A_ServerLogger\n ): Promise<any> {\n const rootFolder = config.get('A_CONCEPT_ROOT_FOLDER') || A_CONCEPT_ENV.A_CONCEPT_ROOT_FOLDER || process.cwd();\n const pkgPath = path.join(rootFolder, 'package.json');\n\n let packageJSON: Record<string, unknown>;\n\n try {\n packageJSON = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));\n } catch {\n throw new A_HttpServerError({\n status: 500,\n description: `Could not read package.json at \"${pkgPath}\"`,\n });\n }\n\n const exposedProperties: Array<string> = config.get('EXPOSED_PROPERTIES')?.split(',') || [\n 'name',\n 'version',\n 'description',\n ];\n\n exposedProperties.forEach(prop => response.add(prop, packageJSON[prop]));\n }\n}"]}
|
|
@@ -5,6 +5,7 @@ import { A_Request } from '@adaas/a-server/request/A-Request.entity';
|
|
|
5
5
|
import { A_Response } from '@adaas/a-server/response/A-Response.entity';
|
|
6
6
|
import { A_Config } from '@adaas/a-utils/a-config';
|
|
7
7
|
import { A_ServerLogger } from '@adaas/a-server/logger/A-ServerLogger.component';
|
|
8
|
+
import { A_HttpServerError } from '../../lib/A-Server/A-HttpServer.error';
|
|
8
9
|
import fs from 'fs';
|
|
9
10
|
import path from 'path';
|
|
10
11
|
|
|
@@ -12,7 +13,15 @@ class A_ServerHealthMonitor extends A_Component {
|
|
|
12
13
|
async get(config, request, response, logger) {
|
|
13
14
|
const rootFolder = config.get("A_CONCEPT_ROOT_FOLDER") || A_CONCEPT_ENV.A_CONCEPT_ROOT_FOLDER || process.cwd();
|
|
14
15
|
const pkgPath = path.join(rootFolder, "package.json");
|
|
15
|
-
|
|
16
|
+
let packageJSON;
|
|
17
|
+
try {
|
|
18
|
+
packageJSON = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
|
|
19
|
+
} catch {
|
|
20
|
+
throw new A_HttpServerError({
|
|
21
|
+
status: 500,
|
|
22
|
+
description: `Could not read package.json at "${pkgPath}"`
|
|
23
|
+
});
|
|
24
|
+
}
|
|
16
25
|
const exposedProperties = config.get("EXPOSED_PROPERTIES")?.split(",") || [
|
|
17
26
|
"name",
|
|
18
27
|
"version",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/controllers/A-ServerHealthMonitor/A-ServerHealthMonitor.component.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/controllers/A-ServerHealthMonitor/A-ServerHealthMonitor.component.ts"],"names":[],"mappings":";;;;;;;;;;;AAYO,MAAM,8BAA8B,WAAA,CAAY;AAAA,EAYnD,MAAM,GAAA,CACkB,MAAA,EACC,OAAA,EACC,UACI,MAAA,EACd;AACZ,IAAA,MAAM,UAAA,GAAa,OAAO,GAAA,CAAI,uBAAuB,KAAK,aAAA,CAAc,qBAAA,IAAyB,QAAQ,GAAA,EAAI;AAC7G,IAAA,MAAM,OAAA,GAAU,IAAA,CAAK,IAAA,CAAK,UAAA,EAAY,cAAc,CAAA;AAEpD,IAAA,IAAI,WAAA;AAEJ,IAAA,IAAI;AACA,MAAA,WAAA,GAAc,KAAK,KAAA,CAAM,EAAA,CAAG,YAAA,CAAa,OAAA,EAAS,OAAO,CAAC,CAAA;AAAA,IAC9D,CAAA,CAAA,MAAQ;AACJ,MAAA,MAAM,IAAI,iBAAA,CAAkB;AAAA,QACxB,MAAA,EAAQ,GAAA;AAAA,QACR,WAAA,EAAa,mCAAmC,OAAO,CAAA,CAAA;AAAA,OAC1D,CAAA;AAAA,IACL;AAEA,IAAA,MAAM,oBAAmC,MAAA,CAAO,GAAA,CAAI,oBAAoB,CAAA,EAAG,KAAA,CAAM,GAAG,CAAA,IAAK;AAAA,MACrF,MAAA;AAAA,MACA,SAAA;AAAA,MACA;AAAA,KACJ;AAEA,IAAA,iBAAA,CAAkB,OAAA,CAAQ,UAAQ,QAAA,CAAS,GAAA,CAAI,MAAM,WAAA,CAAY,IAAI,CAAC,CAAC,CAAA;AAAA,EAC3E;AACJ;AA5BU,eAAA,CAAA;AAAA,EALL,eAAe,GAAA,CAAI;AAAA,IAChB,IAAA,EAAM,GAAA;AAAA,IACN,MAAA,EAAQ,QAAA;AAAA,IACR,OAAA,EAAS;AAAA,GACZ,CAAA;AAAA,EAEI,4BAAS,QAAQ,CAAA,CAAA;AAAA,EACjB,4BAAS,SAAS,CAAA,CAAA;AAAA,EAClB,4BAAS,UAAU,CAAA,CAAA;AAAA,EACnB,4BAAS,cAAc,CAAA;AAAA,CAAA,EAhBnB,qBAAA,CAYH,SAAA,EAAA,KAAA,EAAA,CAAA,CAAA","file":"A-ServerHealthMonitor.component.mjs","sourcesContent":["import { A_Component, A_CONCEPT_ENV, A_Inject } from \"@adaas/a-concept\";\nimport { A_ServerRouter } from \"@adaas/a-server/router/A-ServerRouter.component\";\nimport { A_Request } from \"@adaas/a-server/request/A-Request.entity\";\nimport { A_Response } from \"@adaas/a-server/response/A-Response.entity\";\nimport { A_Config } from \"@adaas/a-utils/a-config\";\nimport { A_ServerLogger } from \"@adaas/a-server/logger/A-ServerLogger.component\";\nimport { A_HttpServerError } from \"../../lib/A-Server/A-HttpServer.error\";\nimport fs from \"fs\";\nimport path from \"path\";\n\n\n\nexport class A_ServerHealthMonitor extends A_Component {\n\n\n // =======================================================\n // ================ Method Definition=====================\n // =======================================================\n\n @A_ServerRouter.Get({\n path: '/',\n prefix: 'health',\n version: 'v1',\n })\n async get(\n @A_Inject(A_Config) config: A_Config<['VERSION_PATH', 'EXPOSED_PROPERTIES']>,\n @A_Inject(A_Request) request: A_Request,\n @A_Inject(A_Response) response: A_Response,\n @A_Inject(A_ServerLogger) logger: A_ServerLogger\n ): Promise<any> {\n const rootFolder = config.get('A_CONCEPT_ROOT_FOLDER') || A_CONCEPT_ENV.A_CONCEPT_ROOT_FOLDER || process.cwd();\n const pkgPath = path.join(rootFolder, 'package.json');\n\n let packageJSON: Record<string, unknown>;\n\n try {\n packageJSON = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));\n } catch {\n throw new A_HttpServerError({\n status: 500,\n description: `Could not read package.json at \"${pkgPath}\"`,\n });\n }\n\n const exposedProperties: Array<string> = config.get('EXPOSED_PROPERTIES')?.split(',') || [\n 'name',\n 'version',\n 'description',\n ];\n\n exposedProperties.forEach(prop => response.add(prop, packageJSON[prop]));\n }\n}"]}
|
package/dist/node/index.d.mts
CHANGED
|
@@ -17,7 +17,9 @@ export { A_ServerError } from './lib/A-Server/A-Server.error.mjs';
|
|
|
17
17
|
export { A_SERVER_TYPES__ServerConstructor, A_SERVER_TYPES__ServerError_Init, A_SERVER_TYPES__ServerError_Serialized } from './lib/A-Server/A-Server.types.mjs';
|
|
18
18
|
export { A_ServerController } from './lib/A-ServerController/A-ServerController.component.mjs';
|
|
19
19
|
export { A_ServerEntityList } from './lib/A-ServerEntityList/A-EntityList.entity.mjs';
|
|
20
|
-
export { A_SERVER_TYPES__A_EntityListConstructor, A_SERVER_TYPES__A_EntityListEvent, A_SERVER_TYPES__A_EntityListPagination, A_SERVER_TYPES__A_EntityListSerialized } from './lib/A-ServerEntityList/A-EntityList.types.mjs';
|
|
20
|
+
export { A_SERVER_TYPES__A_EntityListCacheEntry, A_SERVER_TYPES__A_EntityListConstructor, A_SERVER_TYPES__A_EntityListEvent, A_SERVER_TYPES__A_EntityListPagination, A_SERVER_TYPES__A_EntityListSerialized } from './lib/A-ServerEntityList/A-EntityList.types.mjs';
|
|
21
|
+
export { A_SERVER_TYPES__A_EntityListPaginationSerialized, A_ServerEntityListPagination } from './lib/A-ServerEntityList/A-EntityListPagination.context.mjs';
|
|
22
|
+
export { A_ServerEntityListCacheState } from './lib/A-ServerEntityList/A-EntityListCacheState.context.mjs';
|
|
21
23
|
export { A_ServerListQueryFilter } from './lib/A-ServerListQuery/A-ServerListQueryFilter.context.mjs';
|
|
22
24
|
export { A_SERVER__A_SERVER_LOGGER_ENV_VARIABLES } from './lib/A-ServerLogger/A-ServerLogger.constants.mjs';
|
|
23
25
|
export { A_ServerLogger } from './lib/A-ServerLogger/A-ServerLogger.component.mjs';
|
package/dist/node/index.d.ts
CHANGED
|
@@ -17,7 +17,9 @@ export { A_ServerError } from './lib/A-Server/A-Server.error.js';
|
|
|
17
17
|
export { A_SERVER_TYPES__ServerConstructor, A_SERVER_TYPES__ServerError_Init, A_SERVER_TYPES__ServerError_Serialized } from './lib/A-Server/A-Server.types.js';
|
|
18
18
|
export { A_ServerController } from './lib/A-ServerController/A-ServerController.component.js';
|
|
19
19
|
export { A_ServerEntityList } from './lib/A-ServerEntityList/A-EntityList.entity.js';
|
|
20
|
-
export { A_SERVER_TYPES__A_EntityListConstructor, A_SERVER_TYPES__A_EntityListEvent, A_SERVER_TYPES__A_EntityListPagination, A_SERVER_TYPES__A_EntityListSerialized } from './lib/A-ServerEntityList/A-EntityList.types.js';
|
|
20
|
+
export { A_SERVER_TYPES__A_EntityListCacheEntry, A_SERVER_TYPES__A_EntityListConstructor, A_SERVER_TYPES__A_EntityListEvent, A_SERVER_TYPES__A_EntityListPagination, A_SERVER_TYPES__A_EntityListSerialized } from './lib/A-ServerEntityList/A-EntityList.types.js';
|
|
21
|
+
export { A_SERVER_TYPES__A_EntityListPaginationSerialized, A_ServerEntityListPagination } from './lib/A-ServerEntityList/A-EntityListPagination.context.js';
|
|
22
|
+
export { A_ServerEntityListCacheState } from './lib/A-ServerEntityList/A-EntityListCacheState.context.js';
|
|
21
23
|
export { A_ServerListQueryFilter } from './lib/A-ServerListQuery/A-ServerListQueryFilter.context.js';
|
|
22
24
|
export { A_SERVER__A_SERVER_LOGGER_ENV_VARIABLES } from './lib/A-ServerLogger/A-ServerLogger.constants.js';
|
|
23
25
|
export { A_ServerLogger } from './lib/A-ServerLogger/A-ServerLogger.component.js';
|
package/dist/node/index.js
CHANGED
|
@@ -24,6 +24,8 @@ var AServerController_component = require('./lib/A-ServerController/A-ServerCont
|
|
|
24
24
|
var AServerController_types = require('./lib/A-ServerController/A-ServerController.types');
|
|
25
25
|
var AEntityList_entity = require('./lib/A-ServerEntityList/A-EntityList.entity');
|
|
26
26
|
var AEntityList_types = require('./lib/A-ServerEntityList/A-EntityList.types');
|
|
27
|
+
var AEntityListPagination_context = require('./lib/A-ServerEntityList/A-EntityListPagination.context');
|
|
28
|
+
var AEntityListCacheState_context = require('./lib/A-ServerEntityList/A-EntityListCacheState.context');
|
|
27
29
|
var AServerListQueryFilter_context = require('./lib/A-ServerListQuery/A-ServerListQueryFilter.context');
|
|
28
30
|
var AServerLogger_constants = require('./lib/A-ServerLogger/A-ServerLogger.constants');
|
|
29
31
|
var AServerLogger_component = require('./lib/A-ServerLogger/A-ServerLogger.component');
|
|
@@ -196,6 +198,18 @@ Object.keys(AEntityList_types).forEach(function (k) {
|
|
|
196
198
|
get: function () { return AEntityList_types[k]; }
|
|
197
199
|
});
|
|
198
200
|
});
|
|
201
|
+
Object.keys(AEntityListPagination_context).forEach(function (k) {
|
|
202
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
203
|
+
enumerable: true,
|
|
204
|
+
get: function () { return AEntityListPagination_context[k]; }
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
Object.keys(AEntityListCacheState_context).forEach(function (k) {
|
|
208
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
209
|
+
enumerable: true,
|
|
210
|
+
get: function () { return AEntityListCacheState_context[k]; }
|
|
211
|
+
});
|
|
212
|
+
});
|
|
199
213
|
Object.keys(AServerListQueryFilter_context).forEach(function (k) {
|
|
200
214
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
201
215
|
enumerable: true,
|
package/dist/node/index.mjs
CHANGED
|
@@ -23,6 +23,8 @@ export * from './lib/A-ServerController/A-ServerController.component';
|
|
|
23
23
|
export * from './lib/A-ServerController/A-ServerController.types';
|
|
24
24
|
export * from './lib/A-ServerEntityList/A-EntityList.entity';
|
|
25
25
|
export * from './lib/A-ServerEntityList/A-EntityList.types';
|
|
26
|
+
export * from './lib/A-ServerEntityList/A-EntityListPagination.context';
|
|
27
|
+
export * from './lib/A-ServerEntityList/A-EntityListCacheState.context';
|
|
26
28
|
export * from './lib/A-ServerListQuery/A-ServerListQueryFilter.context';
|
|
27
29
|
export * from './lib/A-ServerLogger/A-ServerLogger.constants';
|
|
28
30
|
export * from './lib/A-ServerLogger/A-ServerLogger.component';
|
|
@@ -6,12 +6,6 @@ import { A_Service, A_ServiceFeatures } from '@adaas/a-utils/a-service';
|
|
|
6
6
|
import { A_Polyfill } from '@adaas/a-utils/a-polyfill';
|
|
7
7
|
import { A_Config } from '@adaas/a-utils/a-config';
|
|
8
8
|
import '@adaas/a-concept';
|
|
9
|
-
import './A-Server.context.mjs';
|
|
10
|
-
import './A-Server.types.mjs';
|
|
11
|
-
import '../A-ServerRoute/A-ServerRoute.entity.mjs';
|
|
12
|
-
import '@adaas/a-utils/a-route';
|
|
13
|
-
import '../A-ServerRoute/A-ServerRoute.types.mjs';
|
|
14
|
-
import '../A-ServerRoute/A-ServerRoute.constants.mjs';
|
|
15
9
|
import '../../A-Request.entity-r905O60G.mjs';
|
|
16
10
|
import './A-HttpServer.error.mjs';
|
|
17
11
|
import './A-HttpServer.types.mjs';
|
|
@@ -21,6 +15,10 @@ import '../A-Request/A-HttpServerRequest.context.mjs';
|
|
|
21
15
|
import '@adaas/a-utils/a-operation';
|
|
22
16
|
import '../A-Request/A-HttpRequestData.context.mjs';
|
|
23
17
|
import '@adaas/a-utils/a-execution';
|
|
18
|
+
import '../A-ServerRoute/A-ServerRoute.entity.mjs';
|
|
19
|
+
import '@adaas/a-utils/a-route';
|
|
20
|
+
import '../A-ServerRoute/A-ServerRoute.types.mjs';
|
|
21
|
+
import '../A-ServerRoute/A-ServerRoute.constants.mjs';
|
|
24
22
|
import '../../A-Response.entity-6qhiV7BE.mjs';
|
|
25
23
|
import 'stream';
|
|
26
24
|
import '../A-Response/A-Response.constants.mjs';
|
|
@@ -6,12 +6,6 @@ import { A_Service, A_ServiceFeatures } from '@adaas/a-utils/a-service';
|
|
|
6
6
|
import { A_Polyfill } from '@adaas/a-utils/a-polyfill';
|
|
7
7
|
import { A_Config } from '@adaas/a-utils/a-config';
|
|
8
8
|
import '@adaas/a-concept';
|
|
9
|
-
import './A-Server.context.js';
|
|
10
|
-
import './A-Server.types.js';
|
|
11
|
-
import '../A-ServerRoute/A-ServerRoute.entity.js';
|
|
12
|
-
import '@adaas/a-utils/a-route';
|
|
13
|
-
import '../A-ServerRoute/A-ServerRoute.types.js';
|
|
14
|
-
import '../A-ServerRoute/A-ServerRoute.constants.js';
|
|
15
9
|
import '../../A-Request.entity-8_9MCXT2.js';
|
|
16
10
|
import './A-HttpServer.error.js';
|
|
17
11
|
import './A-HttpServer.types.js';
|
|
@@ -21,6 +15,10 @@ import '../A-Request/A-HttpServerRequest.context.js';
|
|
|
21
15
|
import '@adaas/a-utils/a-operation';
|
|
22
16
|
import '../A-Request/A-HttpRequestData.context.js';
|
|
23
17
|
import '@adaas/a-utils/a-execution';
|
|
18
|
+
import '../A-ServerRoute/A-ServerRoute.entity.js';
|
|
19
|
+
import '@adaas/a-utils/a-route';
|
|
20
|
+
import '../A-ServerRoute/A-ServerRoute.types.js';
|
|
21
|
+
import '../A-ServerRoute/A-ServerRoute.constants.js';
|
|
24
22
|
import '../../A-Response.entity-bjh6bofZ.js';
|
|
25
23
|
import 'stream';
|
|
26
24
|
import '../A-Response/A-Response.constants.js';
|
|
@@ -4,6 +4,7 @@ var aConcept = require('@adaas/a-concept');
|
|
|
4
4
|
var AServerRouter_component = require('@adaas/a-server/router/A-ServerRouter.component');
|
|
5
5
|
var AResponse_entity = require('@adaas/a-server/response/A-Response.entity');
|
|
6
6
|
var ARequest_entity = require('@adaas/a-server/request/A-Request.entity');
|
|
7
|
+
var AHttpServer_error = require('../A-Server/A-HttpServer.error');
|
|
7
8
|
|
|
8
9
|
var __defProp = Object.defineProperty;
|
|
9
10
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -19,17 +20,29 @@ var __decorateParam = (index, decorator) => (target, key) => decorator(target, k
|
|
|
19
20
|
class A_ServerController extends aConcept.A_Component {
|
|
20
21
|
async callEntityMethod(request, response, scope) {
|
|
21
22
|
if (!scope.has(request.params.component))
|
|
22
|
-
|
|
23
|
+
throw new AHttpServer_error.A_HttpServerError({
|
|
24
|
+
status: 404,
|
|
25
|
+
description: `Component "${request.params.component}" not found`
|
|
26
|
+
});
|
|
23
27
|
if (!request.params.operation || typeof request.params.operation !== "string")
|
|
24
|
-
|
|
28
|
+
throw new AHttpServer_error.A_HttpServerError({
|
|
29
|
+
status: 400,
|
|
30
|
+
description: 'Missing or invalid "operation" parameter'
|
|
31
|
+
});
|
|
25
32
|
const possibleComponent = scope.resolve(request.params.component);
|
|
26
33
|
if (!possibleComponent || ![aConcept.A_Component, aConcept.A_Container].some((c) => possibleComponent instanceof c))
|
|
27
|
-
|
|
34
|
+
throw new AHttpServer_error.A_HttpServerError({
|
|
35
|
+
status: 404,
|
|
36
|
+
description: `"${request.params.component}" is not a valid component`
|
|
37
|
+
});
|
|
28
38
|
const component = possibleComponent;
|
|
29
39
|
const meta = aConcept.A_Context.meta(component);
|
|
30
40
|
const targetFeature = meta.features().find((f) => f.name === `${component.constructor.name}.${request.params.operation}`);
|
|
31
41
|
if (!targetFeature)
|
|
32
|
-
|
|
42
|
+
throw new AHttpServer_error.A_HttpServerError({
|
|
43
|
+
status: 404,
|
|
44
|
+
description: `Operation "${request.params.operation}" not found on component "${request.params.component}"`
|
|
45
|
+
});
|
|
33
46
|
await component.call(request.params.operation, scope);
|
|
34
47
|
}
|
|
35
48
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/A-ServerController/A-ServerController.component.ts"],"names":["A_Component","A_Container","A_Context","A_ServerRouter","A_Request","A_Response","A_Scope"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/A-ServerController/A-ServerController.component.ts"],"names":["A_Component","A_HttpServerError","A_Container","A_Context","A_ServerRouter","A_Request","A_Response","A_Scope"],"mappings":";;;;;;;;;;;;;;;;;;;AAQO,MAAM,2BAA2BA,oBAAA,CAAY;AAAA,EAQhD,MAAM,gBAAA,CACmB,OAAA,EAIC,QAAA,EACH,KAAA,EACrB;AAEE,IAAA,IAAI,CAAC,KAAA,CAAM,GAAA,CAAI,OAAA,CAAQ,OAAO,SAAS,CAAA;AACnC,MAAA,MAAM,IAAIC,mCAAA,CAAkB;AAAA,QACxB,MAAA,EAAQ,GAAA;AAAA,QACR,WAAA,EAAa,CAAA,WAAA,EAAc,OAAA,CAAQ,MAAA,CAAO,SAAS,CAAA,WAAA;AAAA,OACtD,CAAA;AAEL,IAAA,IAAI,CAAC,OAAA,CAAQ,MAAA,CAAO,aAAa,OAAO,OAAA,CAAQ,OAAO,SAAA,KAAc,QAAA;AACjE,MAAA,MAAM,IAAIA,mCAAA,CAAkB;AAAA,QACxB,MAAA,EAAQ,GAAA;AAAA,QACR,WAAA,EAAa;AAAA,OAChB,CAAA;AAEL,IAAA,MAAM,iBAAA,GAAoB,KAAA,CAAM,OAAA,CAAQ,OAAA,CAAQ,OAAO,SAAS,CAAA;AAEhE,IAAA,IACI,CAAC,iBAAA,IAED,CAAC,CAACD,oBAAA,EAAaE,oBAAW,CAAA,CACrB,IAAA,CAAK,CAAA,CAAA,KAAK,iBAAA,YAA6B,CAAC,CAAA;AAE7C,MAAA,MAAM,IAAID,mCAAA,CAAkB;AAAA,QACxB,MAAA,EAAQ,GAAA;AAAA,QACR,WAAA,EAAa,CAAA,CAAA,EAAI,OAAA,CAAQ,MAAA,CAAO,SAAS,CAAA,0BAAA;AAAA,OAC5C,CAAA;AAEL,IAAA,MAAM,SAAA,GAAY,iBAAA;AAElB,IAAA,MAAM,IAAA,GAAOE,kBAAA,CAAU,IAAA,CAAK,SAAS,CAAA;AAErC,IAAA,MAAM,gBAAgB,IAAA,CAAK,QAAA,EAAS,CAAE,IAAA,CAAK,OAAK,CAAA,CAAE,IAAA,KAAS,CAAA,EAAG,SAAA,CAAU,YAAY,IAAI,CAAA,CAAA,EAAI,OAAA,CAAQ,MAAA,CAAO,SAAS,CAAA,CAAE,CAAA;AAEtH,IAAA,IAAI,CAAC,aAAA;AACD,MAAA,MAAM,IAAIF,mCAAA,CAAkB;AAAA,QACxB,MAAA,EAAQ,GAAA;AAAA,QACR,WAAA,EAAa,cAAc,OAAA,CAAQ,MAAA,CAAO,SAAS,CAAA,0BAAA,EAA6B,OAAA,CAAQ,OAAO,SAAS,CAAA,CAAA;AAAA,OAC3G,CAAA;AAEL,IAAA,MAAM,SAAA,CAAU,IAAA,CAAK,OAAA,CAAQ,MAAA,CAAO,WAAW,KAAK,CAAA;AAAA,EACxD;AACJ;AAhDU,eAAA,CAAA;AAAA,EALLG,uCAAe,IAAA,CAAK;AAAA,IACjB,IAAA,EAAM,wBAAA;AAAA,IACN,OAAA,EAAS,IAAA;AAAA,IACT,MAAA,EAAQ;AAAA,GACX,CAAA;AAAA,EAEI,qCAASC,yBAAS,CAAA,CAAA;AAAA,EAIlB,qCAASC,2BAAU,CAAA,CAAA;AAAA,EACnB,qCAASC,gBAAO,CAAA;AAAA,CAAA,EAdZ,kBAAA,CAQH,SAAA,EAAA,kBAAA,CAAA","file":"A-ServerController.component.js","sourcesContent":["import { A_Component, A_Container, A_Context, A_Feature, A_Inject, A_Scope } from \"@adaas/a-concept\";\nimport { A_ServerRouter } from \"@adaas/a-server/router/A-ServerRouter.component\";\nimport { A_Response } from \"@adaas/a-server/response/A-Response.entity\";\nimport { A_Request } from \"@adaas/a-server/request/A-Request.entity\";\nimport { A_HttpServerError } from \"../A-Server/A-HttpServer.error\";\n\n\n\nexport class A_ServerController extends A_Component {\n\n\n @A_ServerRouter.Post({\n path: '/:component/:operation',\n version: 'v1',\n prefix: 'a-component'\n })\n async callEntityMethod(\n @A_Inject(A_Request) request: A_Request<any, any, {\n component: string,\n operation: string\n }>,\n @A_Inject(A_Response) response: A_Response,\n @A_Inject(A_Scope) scope: A_Scope\n ) {\n\n if (!scope.has(request.params.component))\n throw new A_HttpServerError({\n status: 404,\n description: `Component \"${request.params.component}\" not found`,\n });\n\n if (!request.params.operation || typeof request.params.operation !== 'string')\n throw new A_HttpServerError({\n status: 400,\n description: 'Missing or invalid \"operation\" parameter',\n });\n\n const possibleComponent = scope.resolve(request.params.component);\n\n if (\n !possibleComponent\n ||\n ![A_Component, A_Container]\n .some(c => possibleComponent instanceof c)\n )\n throw new A_HttpServerError({\n status: 404,\n description: `\"${request.params.component}\" is not a valid component`,\n });\n\n const component = possibleComponent as A_Component | A_Container;\n\n const meta = A_Context.meta(component);\n\n const targetFeature = meta.features().find(f => f.name === `${component.constructor.name}.${request.params.operation}`);\n\n if (!targetFeature)\n throw new A_HttpServerError({\n status: 404,\n description: `Operation \"${request.params.operation}\" not found on component \"${request.params.component}\"`,\n });\n\n await component.call(request.params.operation, scope);\n }\n}"]}
|
|
@@ -3,21 +3,34 @@ import { A_Inject, A_Scope, A_Component, A_Container, A_Context } from '@adaas/a
|
|
|
3
3
|
import { A_ServerRouter } from '@adaas/a-server/router/A-ServerRouter.component';
|
|
4
4
|
import { A_Response } from '@adaas/a-server/response/A-Response.entity';
|
|
5
5
|
import { A_Request } from '@adaas/a-server/request/A-Request.entity';
|
|
6
|
+
import { A_HttpServerError } from '../A-Server/A-HttpServer.error';
|
|
6
7
|
|
|
7
8
|
class A_ServerController extends A_Component {
|
|
8
9
|
async callEntityMethod(request, response, scope) {
|
|
9
10
|
if (!scope.has(request.params.component))
|
|
10
|
-
|
|
11
|
+
throw new A_HttpServerError({
|
|
12
|
+
status: 404,
|
|
13
|
+
description: `Component "${request.params.component}" not found`
|
|
14
|
+
});
|
|
11
15
|
if (!request.params.operation || typeof request.params.operation !== "string")
|
|
12
|
-
|
|
16
|
+
throw new A_HttpServerError({
|
|
17
|
+
status: 400,
|
|
18
|
+
description: 'Missing or invalid "operation" parameter'
|
|
19
|
+
});
|
|
13
20
|
const possibleComponent = scope.resolve(request.params.component);
|
|
14
21
|
if (!possibleComponent || ![A_Component, A_Container].some((c) => possibleComponent instanceof c))
|
|
15
|
-
|
|
22
|
+
throw new A_HttpServerError({
|
|
23
|
+
status: 404,
|
|
24
|
+
description: `"${request.params.component}" is not a valid component`
|
|
25
|
+
});
|
|
16
26
|
const component = possibleComponent;
|
|
17
27
|
const meta = A_Context.meta(component);
|
|
18
28
|
const targetFeature = meta.features().find((f) => f.name === `${component.constructor.name}.${request.params.operation}`);
|
|
19
29
|
if (!targetFeature)
|
|
20
|
-
|
|
30
|
+
throw new A_HttpServerError({
|
|
31
|
+
status: 404,
|
|
32
|
+
description: `Operation "${request.params.operation}" not found on component "${request.params.component}"`
|
|
33
|
+
});
|
|
21
34
|
await component.call(request.params.operation, scope);
|
|
22
35
|
}
|
|
23
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/A-ServerController/A-ServerController.component.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/A-ServerController/A-ServerController.component.ts"],"names":[],"mappings":";;;;;;;AAQO,MAAM,2BAA2B,WAAA,CAAY;AAAA,EAQhD,MAAM,gBAAA,CACmB,OAAA,EAIC,QAAA,EACH,KAAA,EACrB;AAEE,IAAA,IAAI,CAAC,KAAA,CAAM,GAAA,CAAI,OAAA,CAAQ,OAAO,SAAS,CAAA;AACnC,MAAA,MAAM,IAAI,iBAAA,CAAkB;AAAA,QACxB,MAAA,EAAQ,GAAA;AAAA,QACR,WAAA,EAAa,CAAA,WAAA,EAAc,OAAA,CAAQ,MAAA,CAAO,SAAS,CAAA,WAAA;AAAA,OACtD,CAAA;AAEL,IAAA,IAAI,CAAC,OAAA,CAAQ,MAAA,CAAO,aAAa,OAAO,OAAA,CAAQ,OAAO,SAAA,KAAc,QAAA;AACjE,MAAA,MAAM,IAAI,iBAAA,CAAkB;AAAA,QACxB,MAAA,EAAQ,GAAA;AAAA,QACR,WAAA,EAAa;AAAA,OAChB,CAAA;AAEL,IAAA,MAAM,iBAAA,GAAoB,KAAA,CAAM,OAAA,CAAQ,OAAA,CAAQ,OAAO,SAAS,CAAA;AAEhE,IAAA,IACI,CAAC,iBAAA,IAED,CAAC,CAAC,WAAA,EAAa,WAAW,CAAA,CACrB,IAAA,CAAK,CAAA,CAAA,KAAK,iBAAA,YAA6B,CAAC,CAAA;AAE7C,MAAA,MAAM,IAAI,iBAAA,CAAkB;AAAA,QACxB,MAAA,EAAQ,GAAA;AAAA,QACR,WAAA,EAAa,CAAA,CAAA,EAAI,OAAA,CAAQ,MAAA,CAAO,SAAS,CAAA,0BAAA;AAAA,OAC5C,CAAA;AAEL,IAAA,MAAM,SAAA,GAAY,iBAAA;AAElB,IAAA,MAAM,IAAA,GAAO,SAAA,CAAU,IAAA,CAAK,SAAS,CAAA;AAErC,IAAA,MAAM,gBAAgB,IAAA,CAAK,QAAA,EAAS,CAAE,IAAA,CAAK,OAAK,CAAA,CAAE,IAAA,KAAS,CAAA,EAAG,SAAA,CAAU,YAAY,IAAI,CAAA,CAAA,EAAI,OAAA,CAAQ,MAAA,CAAO,SAAS,CAAA,CAAE,CAAA;AAEtH,IAAA,IAAI,CAAC,aAAA;AACD,MAAA,MAAM,IAAI,iBAAA,CAAkB;AAAA,QACxB,MAAA,EAAQ,GAAA;AAAA,QACR,WAAA,EAAa,cAAc,OAAA,CAAQ,MAAA,CAAO,SAAS,CAAA,0BAAA,EAA6B,OAAA,CAAQ,OAAO,SAAS,CAAA,CAAA;AAAA,OAC3G,CAAA;AAEL,IAAA,MAAM,SAAA,CAAU,IAAA,CAAK,OAAA,CAAQ,MAAA,CAAO,WAAW,KAAK,CAAA;AAAA,EACxD;AACJ;AAhDU,eAAA,CAAA;AAAA,EALL,eAAe,IAAA,CAAK;AAAA,IACjB,IAAA,EAAM,wBAAA;AAAA,IACN,OAAA,EAAS,IAAA;AAAA,IACT,MAAA,EAAQ;AAAA,GACX,CAAA;AAAA,EAEI,4BAAS,SAAS,CAAA,CAAA;AAAA,EAIlB,4BAAS,UAAU,CAAA,CAAA;AAAA,EACnB,4BAAS,OAAO,CAAA;AAAA,CAAA,EAdZ,kBAAA,CAQH,SAAA,EAAA,kBAAA,EAAA,CAAA,CAAA","file":"A-ServerController.component.mjs","sourcesContent":["import { A_Component, A_Container, A_Context, A_Feature, A_Inject, A_Scope } from \"@adaas/a-concept\";\nimport { A_ServerRouter } from \"@adaas/a-server/router/A-ServerRouter.component\";\nimport { A_Response } from \"@adaas/a-server/response/A-Response.entity\";\nimport { A_Request } from \"@adaas/a-server/request/A-Request.entity\";\nimport { A_HttpServerError } from \"../A-Server/A-HttpServer.error\";\n\n\n\nexport class A_ServerController extends A_Component {\n\n\n @A_ServerRouter.Post({\n path: '/:component/:operation',\n version: 'v1',\n prefix: 'a-component'\n })\n async callEntityMethod(\n @A_Inject(A_Request) request: A_Request<any, any, {\n component: string,\n operation: string\n }>,\n @A_Inject(A_Response) response: A_Response,\n @A_Inject(A_Scope) scope: A_Scope\n ) {\n\n if (!scope.has(request.params.component))\n throw new A_HttpServerError({\n status: 404,\n description: `Component \"${request.params.component}\" not found`,\n });\n\n if (!request.params.operation || typeof request.params.operation !== 'string')\n throw new A_HttpServerError({\n status: 400,\n description: 'Missing or invalid \"operation\" parameter',\n });\n\n const possibleComponent = scope.resolve(request.params.component);\n\n if (\n !possibleComponent\n ||\n ![A_Component, A_Container]\n .some(c => possibleComponent instanceof c)\n )\n throw new A_HttpServerError({\n status: 404,\n description: `\"${request.params.component}\" is not a valid component`,\n });\n\n const component = possibleComponent as A_Component | A_Container;\n\n const meta = A_Context.meta(component);\n\n const targetFeature = meta.features().find(f => f.name === `${component.constructor.name}.${request.params.operation}`);\n\n if (!targetFeature)\n throw new A_HttpServerError({\n status: 404,\n description: `Operation \"${request.params.operation}\" not found on component \"${request.params.component}\"`,\n });\n\n await component.call(request.params.operation, scope);\n }\n}"]}
|
|
@@ -1,48 +1,72 @@
|
|
|
1
|
-
import { A_Entity } from '@adaas/a-concept';
|
|
1
|
+
import { A_Entity, A_TYPES__Entity_Constructor, A_Scope } from '@adaas/a-concept';
|
|
2
2
|
import { A_SERVER_TYPES__A_EntityListConstructor, A_SERVER_TYPES__A_EntityListSerialized, A_SERVER_TYPES__A_EntityListPagination } from './A-EntityList.types.mjs';
|
|
3
|
+
import { A_ServerEntityListPagination } from './A-EntityListPagination.context.mjs';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* A-EntityList
|
|
6
7
|
*
|
|
7
|
-
*
|
|
8
|
+
* Typed, paginated list of A-Concept entities.
|
|
9
|
+
*
|
|
10
|
+
* Construction (user-facing):
|
|
11
|
+
* new A_ServerEntityList<User>({ entity: User, pagination: { page: 1, pageSize: 20 } })
|
|
12
|
+
*
|
|
13
|
+
* Construction (controller-internal, backward-compat):
|
|
14
|
+
* new A_ServerEntityList({ name: 'user', scope: 'my-scope', constructor: User })
|
|
8
15
|
*/
|
|
9
|
-
declare class A_ServerEntityList<EntityType extends A_Entity = A_Entity> extends A_Entity<A_SERVER_TYPES__A_EntityListConstructor
|
|
16
|
+
declare class A_ServerEntityList<EntityType extends A_Entity = A_Entity> extends A_Entity<A_SERVER_TYPES__A_EntityListConstructor<EntityType>, A_SERVER_TYPES__A_EntityListSerialized<EntityType>> {
|
|
10
17
|
static get scope(): string;
|
|
11
|
-
protected _entityConstructor:
|
|
12
|
-
protected _items: Array<EntityType>;
|
|
13
|
-
protected _pagination: A_SERVER_TYPES__A_EntityListPagination;
|
|
18
|
+
protected _entityConstructor: A_TYPES__Entity_Constructor<EntityType>;
|
|
14
19
|
/**
|
|
15
|
-
*
|
|
20
|
+
* Ordered item references for O(1) positional access.
|
|
21
|
+
* The list's own scope is the authoritative store (enables @A_Inject and
|
|
22
|
+
* feature chains on items); this array mirrors the same items in order.
|
|
16
23
|
*/
|
|
17
|
-
|
|
24
|
+
protected _items: Array<EntityType>;
|
|
25
|
+
/** Lazily allocated private scope — pagination and cache state live here. */
|
|
26
|
+
private _ownScope?;
|
|
18
27
|
/**
|
|
19
|
-
*
|
|
28
|
+
* The list's own scope, created on first access and bound to this entity
|
|
29
|
+
* via A_Context.allocate. Items, pagination and cache state are registered
|
|
30
|
+
* here so they participate in feature chains and @A_Inject resolution.
|
|
20
31
|
*/
|
|
32
|
+
get ownScope(): A_Scope;
|
|
33
|
+
get entityConstructor(): A_TYPES__Entity_Constructor<EntityType>;
|
|
21
34
|
get items(): Array<EntityType>;
|
|
35
|
+
/** Pagination state — lives as a Fragment in the list's own scope. */
|
|
36
|
+
get pagination(): A_ServerEntityListPagination;
|
|
37
|
+
private get cacheState();
|
|
38
|
+
/** Total number of items currently held in memory. */
|
|
39
|
+
get length(): number;
|
|
40
|
+
fromNew(newEntity: A_SERVER_TYPES__A_EntityListConstructor<EntityType>): void;
|
|
22
41
|
/**
|
|
23
|
-
*
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Creates a new instance of A_EntityList
|
|
28
|
-
*
|
|
29
|
-
* @param newEntity
|
|
30
|
-
*/
|
|
31
|
-
fromNew(newEntity: A_SERVER_TYPES__A_EntityListConstructor): void;
|
|
32
|
-
/**
|
|
33
|
-
* Allows to convert Repository Response data to EntityList instance
|
|
34
|
-
*
|
|
35
|
-
* [!] This method does not load the data from the repository, it only converts the data to the EntityList instance
|
|
36
|
-
*
|
|
37
|
-
* @param items
|
|
38
|
-
* @param pagination
|
|
42
|
+
* Populate the list from raw repository data.
|
|
43
|
+
* Items are registered in the list's own scope so they participate in
|
|
44
|
+
* feature chains and @A_Inject resolution.
|
|
39
45
|
*/
|
|
40
46
|
fromList(items: Array<EntityType> | Array<ReturnType<EntityType['toJSON']>>, pagination?: A_SERVER_TYPES__A_EntityListPagination): void;
|
|
47
|
+
/** Return the item at `index`, or `undefined` if out of range. */
|
|
48
|
+
at(index: number): EntityType | undefined;
|
|
49
|
+
/** Replace the item at `index` in place. Accepts a live entity or a plain serialised object. */
|
|
50
|
+
replace(index: number, item: EntityType | ReturnType<EntityType['toJSON']>): this;
|
|
51
|
+
/** Append an item to the end of the list. */
|
|
52
|
+
push(item: EntityType | ReturnType<EntityType['toJSON']>): this;
|
|
53
|
+
/** Prepend an item to the beginning of the list. */
|
|
54
|
+
unshift(item: EntityType | ReturnType<EntityType['toJSON']>): this;
|
|
55
|
+
/** Remove the item at `index` from the list. */
|
|
56
|
+
remove(index: number): this;
|
|
57
|
+
/** Return the first item that satisfies `predicate`, or `undefined`. */
|
|
58
|
+
find(predicate: (item: EntityType, index: number) => boolean): EntityType | undefined;
|
|
59
|
+
/** Return all items that satisfy `predicate` without mutating the list. */
|
|
60
|
+
filter(predicate: (item: EntityType, index: number) => boolean): EntityType[];
|
|
41
61
|
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* @returns
|
|
62
|
+
* Mark this list as cached for `ttlMs` milliseconds from now.
|
|
63
|
+
* Callers can check `isCached()` to decide whether to skip `load()`.
|
|
45
64
|
*/
|
|
65
|
+
setCache(ttlMs: number): this;
|
|
66
|
+
/** Returns `true` if the cache is still valid. */
|
|
67
|
+
isCached(): boolean;
|
|
68
|
+
/** Invalidate the cache so the next `load()` call fetches fresh data. */
|
|
69
|
+
invalidateCache(): this;
|
|
46
70
|
toJSON(): A_SERVER_TYPES__A_EntityListSerialized<EntityType>;
|
|
47
71
|
}
|
|
48
72
|
|