@adaas/a-server 0.0.5 → 0.0.6
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/src/entities/A_EntityList/A_EntityList.entity.d.ts +8 -12
- 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/package.json +1 -1
- package/src/entities/A_EntityList/A_EntityList.entity.ts +12 -11
- package/src/entities/A_EntityList/A_EntityList.entity.types.ts +2 -2
|
@@ -1,26 +1,22 @@
|
|
|
1
|
-
import { A_Entity
|
|
1
|
+
import { A_Entity } from "@adaas/a-concept";
|
|
2
2
|
import { A_SERVER_TYPES__A_EntityListConstructor, A_SERVER_TYPES__A_EntityListPagination, A_SERVER_TYPES__A_EntityListSerialized } from "./A_EntityList.entity.types";
|
|
3
3
|
/**
|
|
4
4
|
* A-EntityList
|
|
5
5
|
*
|
|
6
6
|
* Entity that represents a list of entities with pagination of particular type
|
|
7
7
|
*/
|
|
8
|
-
export declare class A_EntityList<
|
|
9
|
-
protected _entityConstructor:
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
protected _items: Array<A_Entity>;
|
|
8
|
+
export declare class A_EntityList<EntityType extends A_Entity = A_Entity> extends A_Entity<A_SERVER_TYPES__A_EntityListConstructor, A_SERVER_TYPES__A_EntityListSerialized> {
|
|
9
|
+
protected _entityConstructor: new (...args: any[]) => EntityType;
|
|
10
|
+
protected _items: Array<EntityType>;
|
|
13
11
|
protected _pagination: A_SERVER_TYPES__A_EntityListPagination;
|
|
14
12
|
/**
|
|
15
13
|
* Returns the entity constructor used for the list
|
|
16
14
|
*/
|
|
17
|
-
get entityConstructor():
|
|
18
|
-
new (...args: any[]): A_Entity<any, SerializedEntityType>;
|
|
19
|
-
};
|
|
15
|
+
get entityConstructor(): new (...args: any[]) => EntityType;
|
|
20
16
|
/**
|
|
21
17
|
* Returns the list of items contained in the entity list
|
|
22
18
|
*/
|
|
23
|
-
get items(): Array<
|
|
19
|
+
get items(): Array<EntityType>;
|
|
24
20
|
/**
|
|
25
21
|
* Returns pagination information about the entity list
|
|
26
22
|
*/
|
|
@@ -39,11 +35,11 @@ export declare class A_EntityList<SerializedEntityType extends A_TYPES__Entity_J
|
|
|
39
35
|
* @param items
|
|
40
36
|
* @param pagination
|
|
41
37
|
*/
|
|
42
|
-
fromList(items: Array<
|
|
38
|
+
fromList(items: Array<EntityType> | Array<ReturnType<EntityType['toJSON']>>, pagination?: A_SERVER_TYPES__A_EntityListPagination): void;
|
|
43
39
|
/**
|
|
44
40
|
* Serializes the EntityList to a JSON object
|
|
45
41
|
*
|
|
46
42
|
* @returns
|
|
47
43
|
*/
|
|
48
|
-
toJSON(): A_SERVER_TYPES__A_EntityListSerialized
|
|
44
|
+
toJSON(): A_SERVER_TYPES__A_EntityListSerialized<EntityType>;
|
|
49
45
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"A_EntityList.entity.js","sourceRoot":"","sources":["../../../../src/entities/A_EntityList/A_EntityList.entity.ts"],"names":[],"mappings":";;;AAAA,gDAG0B;AAM1B,4CAAuC;AAIvC;;;;GAIG;AACH,MAAa,
|
|
1
|
+
{"version":3,"file":"A_EntityList.entity.js","sourceRoot":"","sources":["../../../../src/entities/A_EntityList/A_EntityList.entity.ts"],"names":[],"mappings":";;;AAAA,gDAG0B;AAM1B,4CAAuC;AAIvC;;;;GAIG;AACH,MAAa,YAEX,SAAQ,oBAGT;IALD;;QAOc,WAAM,GAAsB,EAAE,CAAC;QAC/B,gBAAW,GAA2C;YAC5D,KAAK,EAAE,CAAC;YACR,IAAI,EAAE,CAAC;YACP,QAAQ,EAAE,EAAE;SACf,CAAC;IAyFN,CAAC;IAtFG;;OAEG;IACH,IAAI,iBAAiB;QACjB,OAAO,IAAI,CAAC,kBAAkB,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,IAAI,KAAK;QACL,OAAO,IAAI,CAA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AAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,CAAuC,EAC7E,UAAU,EAAE,IAAI,CAAC,WAAW,IAC/B;IACL,CAAC;CACJ;AArGD,oCAqGC"}
|
|
@@ -9,8 +9,8 @@ export type A_SERVER_TYPES__A_EntityListConstructor = {
|
|
|
9
9
|
export declare enum A_SERVER_TYPES__A_EntityListEvent {
|
|
10
10
|
Load = "load"
|
|
11
11
|
}
|
|
12
|
-
export type A_SERVER_TYPES__A_EntityListSerialized = {
|
|
13
|
-
items:
|
|
12
|
+
export type A_SERVER_TYPES__A_EntityListSerialized<EntityTypes extends A_Entity = A_Entity> = {
|
|
13
|
+
items: Array<ReturnType<EntityTypes['toJSON']>>;
|
|
14
14
|
type: string;
|
|
15
15
|
pagination: A_SERVER_TYPES__A_EntityListPagination;
|
|
16
16
|
} & A_TYPES__Entity_JSON;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adaas/a-server",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "SDK to create a server with ease. Build your backend server with modular structure and use it within or outside the ADAAS ecosystem.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -16,13 +16,14 @@ import { ASEID } from "@adaas/a-utils";
|
|
|
16
16
|
*
|
|
17
17
|
* Entity that represents a list of entities with pagination of particular type
|
|
18
18
|
*/
|
|
19
|
-
export class A_EntityList<
|
|
19
|
+
export class A_EntityList<
|
|
20
|
+
EntityType extends A_Entity = A_Entity,
|
|
21
|
+
> extends A_Entity<
|
|
20
22
|
A_SERVER_TYPES__A_EntityListConstructor,
|
|
21
23
|
A_SERVER_TYPES__A_EntityListSerialized
|
|
22
24
|
> {
|
|
23
|
-
|
|
24
|
-
protected
|
|
25
|
-
protected _items: Array<A_Entity> = [];
|
|
25
|
+
protected _entityConstructor!: new (...args: any[]) => EntityType;
|
|
26
|
+
protected _items: Array<EntityType> = [];
|
|
26
27
|
protected _pagination: A_SERVER_TYPES__A_EntityListPagination = {
|
|
27
28
|
total: 0,
|
|
28
29
|
page: 1,
|
|
@@ -33,14 +34,14 @@ export class A_EntityList<SerializedEntityType extends A_TYPES__Entity_JSON = A_
|
|
|
33
34
|
/**
|
|
34
35
|
* Returns the entity constructor used for the list
|
|
35
36
|
*/
|
|
36
|
-
get entityConstructor():
|
|
37
|
+
get entityConstructor(): new (...args: any[]) => EntityType {
|
|
37
38
|
return this._entityConstructor;
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
/**
|
|
41
42
|
* Returns the list of items contained in the entity list
|
|
42
43
|
*/
|
|
43
|
-
get items(): Array<
|
|
44
|
+
get items(): Array<EntityType> {
|
|
44
45
|
return this._items;
|
|
45
46
|
}
|
|
46
47
|
|
|
@@ -67,7 +68,7 @@ export class A_EntityList<SerializedEntityType extends A_TYPES__Entity_JSON = A_
|
|
|
67
68
|
id: (new Date()).getTime().toString(),
|
|
68
69
|
});
|
|
69
70
|
|
|
70
|
-
this._entityConstructor = newEntity.constructor as
|
|
71
|
+
this._entityConstructor = newEntity.constructor as new (...args: any[]) => EntityType;
|
|
71
72
|
}
|
|
72
73
|
|
|
73
74
|
|
|
@@ -81,12 +82,12 @@ export class A_EntityList<SerializedEntityType extends A_TYPES__Entity_JSON = A_
|
|
|
81
82
|
* @param pagination
|
|
82
83
|
*/
|
|
83
84
|
fromList(
|
|
84
|
-
items: Array<
|
|
85
|
+
items: Array<EntityType> | Array<ReturnType<EntityType['toJSON']>>,
|
|
85
86
|
pagination?: A_SERVER_TYPES__A_EntityListPagination
|
|
86
87
|
) {
|
|
87
88
|
this._items = items.map(item => {
|
|
88
89
|
if (item instanceof A_Entity) {
|
|
89
|
-
return item;
|
|
90
|
+
return item as EntityType;
|
|
90
91
|
} else {
|
|
91
92
|
const entity = new this._entityConstructor(item);
|
|
92
93
|
return entity;
|
|
@@ -109,10 +110,10 @@ export class A_EntityList<SerializedEntityType extends A_TYPES__Entity_JSON = A_
|
|
|
109
110
|
*
|
|
110
111
|
* @returns
|
|
111
112
|
*/
|
|
112
|
-
toJSON(): A_SERVER_TYPES__A_EntityListSerialized {
|
|
113
|
+
toJSON(): A_SERVER_TYPES__A_EntityListSerialized<EntityType> {
|
|
113
114
|
return {
|
|
114
115
|
...super.toJSON(),
|
|
115
|
-
items: this._items.map(i => i.toJSON()),
|
|
116
|
+
items: this._items.map(i => i.toJSON()) as ReturnType<EntityType['toJSON']>[],
|
|
116
117
|
pagination: this._pagination
|
|
117
118
|
}
|
|
118
119
|
}
|
|
@@ -11,8 +11,8 @@ export enum A_SERVER_TYPES__A_EntityListEvent {
|
|
|
11
11
|
Load = 'load',
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export type A_SERVER_TYPES__A_EntityListSerialized = {
|
|
15
|
-
items:
|
|
14
|
+
export type A_SERVER_TYPES__A_EntityListSerialized<EntityTypes extends A_Entity = A_Entity> = {
|
|
15
|
+
items: Array<ReturnType<EntityTypes['toJSON']>>,
|
|
16
16
|
type: string,
|
|
17
17
|
pagination: A_SERVER_TYPES__A_EntityListPagination
|
|
18
18
|
} & A_TYPES__Entity_JSON;
|