@christianriedl/rest 1.0.60 → 1.0.62
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/crudRest.d.ts +5 -9
- package/dist/crudRest.js +8 -9
- package/dist/crudRest.js.map +1 -1
- package/dist/iRest.d.ts +3 -3
- package/package.json +2 -2
package/dist/crudRest.d.ts
CHANGED
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
import { IRest, IRestResult, ICrudRest, RepairFunction } from './iRest';
|
|
2
|
-
import { ILogger, IEntity } from '@christianriedl/utils';
|
|
3
|
-
|
|
4
|
-
[key: string]: T;
|
|
5
|
-
};
|
|
6
|
-
export default class CrudRest implements ICrudRest<IEntity> {
|
|
2
|
+
import { ILogger, IEntity, Dictionary } from '@christianriedl/utils';
|
|
3
|
+
export declare class CrudRest implements ICrudRest<IEntity> {
|
|
7
4
|
rest: IRest;
|
|
8
5
|
logger: ILogger;
|
|
9
6
|
repairFunctions: Dictionary<RepairFunction<IEntity>>;
|
|
10
7
|
constructor(rest: IRest, logger: ILogger);
|
|
11
8
|
getEntities(table: string, params?: Dictionary<any>): Promise<IRestResult<IEntity[]>>;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
deleteEntity(table: string, id:
|
|
9
|
+
addEntity(table: string, entity: IEntity): Promise<IRestResult<string>>;
|
|
10
|
+
updateEntity(table: string, entity: IEntity): Promise<IRestResult<boolean>>;
|
|
11
|
+
deleteEntity(table: string, id: string): Promise<IRestResult<boolean>>;
|
|
15
12
|
adjustResult(result: IRestResult<IEntity>): void;
|
|
16
13
|
addRepairFunction(table: string, func: RepairFunction<IEntity>): void;
|
|
17
14
|
}
|
|
18
|
-
export {};
|
package/dist/crudRest.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export class CrudRest {
|
|
2
2
|
rest;
|
|
3
3
|
logger;
|
|
4
4
|
repairFunctions = {};
|
|
@@ -26,22 +26,21 @@ export default class CrudRest {
|
|
|
26
26
|
}
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
|
-
async updateEntity(table, entity) {
|
|
30
|
-
const result = await this.rest.putData(`api/${table}/${entity.id}`, entity);
|
|
31
|
-
this.logger.trace(`updateEntity ${table}: ${JSON.stringify(entity)} : ${result}`);
|
|
32
|
-
this.adjustResult(result);
|
|
33
|
-
return result;
|
|
34
|
-
}
|
|
35
29
|
async addEntity(table, entity) {
|
|
36
30
|
const result = await this.rest.postDataEx(`api/${table}`, entity);
|
|
37
31
|
this.logger.trace(`addEntity ${table}: ${JSON.stringify(entity)} : ${JSON.stringify(result)}`);
|
|
38
|
-
|
|
32
|
+
if (result.ok)
|
|
33
|
+
entity.id = result.result;
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
async updateEntity(table, entity) {
|
|
37
|
+
const result = await this.rest.putData(`api/${table}/${entity.id}`, entity);
|
|
38
|
+
this.logger.trace(`updateEntity ${table}: ${JSON.stringify(entity)} : ${result}`);
|
|
39
39
|
return result;
|
|
40
40
|
}
|
|
41
41
|
async deleteEntity(table, id) {
|
|
42
42
|
const result = await this.rest.deleteData(`api/${table}/${id}`);
|
|
43
43
|
this.logger.trace(`deleteEntity ${table}: ${id} : ${JSON.stringify(result)}`);
|
|
44
|
-
this.adjustResult(result);
|
|
45
44
|
return result;
|
|
46
45
|
}
|
|
47
46
|
adjustResult(result) {
|
package/dist/crudRest.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crudRest.js","sourceRoot":"","sources":["../src/crudRest.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"crudRest.js","sourceRoot":"","sources":["../src/crudRest.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,QAAQ;IACjB,IAAI,CAAQ;IACZ,MAAM,CAAU;IAChB,eAAe,GAAwC,EAAE,CAAC;IAE1D,YAAY,IAAW,EAAE,MAAe;QACpC,IAAI,CAAC,MAAM,GAAG,MAAM,CAA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;gBACtD,MAAM,CAAC,UAAU,GAAG,GAAG,aAAa,CAAC,KAAK,IAAI,aAAa,CAAC,IAAI,MAAM,aAAa,CAAC,MAAM,EAAE,CAAC;YACjG,CAAC;QACL,CAAC;IACL,CAAC;IACD,iBAAiB,CAAC,KAAa,EAAE,IAA6B;QAC1D,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;IACvC,CAAC;CACJ"}
|
package/dist/iRest.d.ts
CHANGED
|
@@ -42,9 +42,9 @@ export declare enum ECrudAction {
|
|
|
42
42
|
Delete = 3
|
|
43
43
|
}
|
|
44
44
|
export interface ICrudRest<T> {
|
|
45
|
-
addEntity(table: string, entity: T): Promise<IRestResult<
|
|
46
|
-
updateEntity(table: string, entity: T): Promise<IRestResult<
|
|
47
|
-
deleteEntity(table: string, id:
|
|
45
|
+
addEntity(table: string, entity: T): Promise<IRestResult<string>>;
|
|
46
|
+
updateEntity(table: string, entity: T): Promise<IRestResult<boolean>>;
|
|
47
|
+
deleteEntity(table: string, id: string): Promise<IRestResult<boolean>>;
|
|
48
48
|
getEntities(table: string, search?: Dictionary<any>): Promise<IRestResult<T[]>>;
|
|
49
49
|
addRepairFunction(table: string, func: RepairFunction<T>): void;
|
|
50
50
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@christianriedl/rest",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.62",
|
|
4
4
|
"description": "REST and OAuth library based on fetch API",
|
|
5
5
|
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"author": "Christian Riedl",
|
|
18
18
|
"license": "ISC",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@christianriedl/utils": "^1.0.
|
|
20
|
+
"@christianriedl/utils": "^1.0.109"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@types/node": "^20.14.9",
|