@restorecommerce/resource-base-interface 0.1.1 → 0.2.3
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/CHANGELOG.md +22 -0
- package/lib/core/GraphResourcesServiceBase.js +121 -101
- package/lib/core/GraphResourcesServiceBase.js.map +1 -1
- package/lib/core/ResourcesAPI.d.ts +3 -2
- package/lib/core/ResourcesAPI.js +279 -228
- package/lib/core/ResourcesAPI.js.map +1 -1
- package/lib/core/ServiceBase.d.ts +2 -0
- package/lib/core/ServiceBase.js +345 -165
- package/lib/core/ServiceBase.js.map +1 -1
- package/lib/core/interfaces.d.ts +66 -1
- package/lib/core/interfaces.js +36 -0
- package/lib/core/interfaces.js.map +1 -1
- package/lib/index.d.ts +9 -2
- package/lib/index.js +187 -64
- package/lib/index.js.map +1 -1
- package/package.json +21 -20
- package/tsconfig.json +12 -4
package/lib/core/interfaces.d.ts
CHANGED
|
@@ -1,8 +1,42 @@
|
|
|
1
|
+
import { Vertices, Collection } from '@restorecommerce/chassis-srv';
|
|
1
2
|
export declare type TRequest = CreateRequest | DeleteRequest | UpdateRequest | UpsertRequest | ReadRequest;
|
|
2
3
|
export interface ServiceCall<TRequest> {
|
|
3
4
|
request: TRequest;
|
|
4
5
|
}
|
|
5
6
|
export declare type SortType = 'ASCENDING' | 'DESCENDING' | 'UNSORTED' | 2 | 1 | 0;
|
|
7
|
+
export declare enum FilterOperation {
|
|
8
|
+
eq = 0,
|
|
9
|
+
lt = 1,
|
|
10
|
+
lte = 2,
|
|
11
|
+
gt = 3,
|
|
12
|
+
gte = 4,
|
|
13
|
+
isEmpty = 5,
|
|
14
|
+
iLike = 6,
|
|
15
|
+
in = 7,
|
|
16
|
+
neq = 8
|
|
17
|
+
}
|
|
18
|
+
export declare enum FilterValueType {
|
|
19
|
+
STRING = 0,
|
|
20
|
+
NUMBER = 1,
|
|
21
|
+
BOOLEAN = 2,
|
|
22
|
+
DATE = 3,
|
|
23
|
+
ARRAY = 4
|
|
24
|
+
}
|
|
25
|
+
export declare enum OperatorType {
|
|
26
|
+
and = 0,
|
|
27
|
+
or = 1
|
|
28
|
+
}
|
|
29
|
+
export interface Filter {
|
|
30
|
+
field: string;
|
|
31
|
+
operation: FilterOperation;
|
|
32
|
+
value: string;
|
|
33
|
+
type?: FilterValueType;
|
|
34
|
+
filters?: FilterOp[];
|
|
35
|
+
}
|
|
36
|
+
export interface FilterOp {
|
|
37
|
+
filter?: Filter[];
|
|
38
|
+
operator?: OperatorType;
|
|
39
|
+
}
|
|
6
40
|
export interface ReadRequest {
|
|
7
41
|
search?: string;
|
|
8
42
|
sort?: {
|
|
@@ -15,7 +49,7 @@ export interface ReadRequest {
|
|
|
15
49
|
name: string;
|
|
16
50
|
include: boolean;
|
|
17
51
|
}[];
|
|
18
|
-
|
|
52
|
+
filters?: FilterOp[];
|
|
19
53
|
custom_queries?: string[];
|
|
20
54
|
custom_arguments?: any;
|
|
21
55
|
}
|
|
@@ -45,3 +79,34 @@ export interface UpsertRequest extends UpdateRequest {
|
|
|
45
79
|
export interface CreateRequest {
|
|
46
80
|
items: BaseDocument[];
|
|
47
81
|
}
|
|
82
|
+
export declare enum Direction {
|
|
83
|
+
OUTBOUND = "OUTBOUND",
|
|
84
|
+
INBOUND = "INBOUND"
|
|
85
|
+
}
|
|
86
|
+
export interface TraversalOptions {
|
|
87
|
+
include_vertex?: string[];
|
|
88
|
+
exclude_vertex?: string[];
|
|
89
|
+
include_edge?: string[];
|
|
90
|
+
exclude_edge?: string[];
|
|
91
|
+
direction?: Direction;
|
|
92
|
+
}
|
|
93
|
+
export interface GraphFilter {
|
|
94
|
+
field: string;
|
|
95
|
+
operation: FilterOperation;
|
|
96
|
+
value: string;
|
|
97
|
+
type?: FilterValueType;
|
|
98
|
+
filters?: GraphFilters[];
|
|
99
|
+
}
|
|
100
|
+
export interface GraphFilters {
|
|
101
|
+
entity?: string;
|
|
102
|
+
edge?: string;
|
|
103
|
+
filter?: GraphFilter[];
|
|
104
|
+
operator?: OperatorType;
|
|
105
|
+
}
|
|
106
|
+
export interface TraversalRequest {
|
|
107
|
+
vertices?: Vertices;
|
|
108
|
+
collection?: Collection;
|
|
109
|
+
opts?: TraversalOptions;
|
|
110
|
+
path?: boolean;
|
|
111
|
+
filters?: GraphFilters[];
|
|
112
|
+
}
|
package/lib/core/interfaces.js
CHANGED
|
@@ -1,3 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Direction = exports.OperatorType = exports.FilterValueType = exports.FilterOperation = void 0;
|
|
4
|
+
var FilterOperation;
|
|
5
|
+
(function (FilterOperation) {
|
|
6
|
+
FilterOperation[FilterOperation["eq"] = 0] = "eq";
|
|
7
|
+
FilterOperation[FilterOperation["lt"] = 1] = "lt";
|
|
8
|
+
FilterOperation[FilterOperation["lte"] = 2] = "lte";
|
|
9
|
+
FilterOperation[FilterOperation["gt"] = 3] = "gt";
|
|
10
|
+
FilterOperation[FilterOperation["gte"] = 4] = "gte";
|
|
11
|
+
FilterOperation[FilterOperation["isEmpty"] = 5] = "isEmpty";
|
|
12
|
+
FilterOperation[FilterOperation["iLike"] = 6] = "iLike";
|
|
13
|
+
FilterOperation[FilterOperation["in"] = 7] = "in";
|
|
14
|
+
FilterOperation[FilterOperation["neq"] = 8] = "neq";
|
|
15
|
+
})(FilterOperation = exports.FilterOperation || (exports.FilterOperation = {}));
|
|
16
|
+
;
|
|
17
|
+
var FilterValueType;
|
|
18
|
+
(function (FilterValueType) {
|
|
19
|
+
FilterValueType[FilterValueType["STRING"] = 0] = "STRING";
|
|
20
|
+
FilterValueType[FilterValueType["NUMBER"] = 1] = "NUMBER";
|
|
21
|
+
FilterValueType[FilterValueType["BOOLEAN"] = 2] = "BOOLEAN";
|
|
22
|
+
FilterValueType[FilterValueType["DATE"] = 3] = "DATE";
|
|
23
|
+
FilterValueType[FilterValueType["ARRAY"] = 4] = "ARRAY";
|
|
24
|
+
})(FilterValueType = exports.FilterValueType || (exports.FilterValueType = {}));
|
|
25
|
+
;
|
|
26
|
+
var OperatorType;
|
|
27
|
+
(function (OperatorType) {
|
|
28
|
+
OperatorType[OperatorType["and"] = 0] = "and";
|
|
29
|
+
OperatorType[OperatorType["or"] = 1] = "or";
|
|
30
|
+
})(OperatorType = exports.OperatorType || (exports.OperatorType = {}));
|
|
31
|
+
;
|
|
32
|
+
var Direction;
|
|
33
|
+
(function (Direction) {
|
|
34
|
+
Direction["OUTBOUND"] = "OUTBOUND";
|
|
35
|
+
Direction["INBOUND"] = "INBOUND";
|
|
36
|
+
})(Direction = exports.Direction || (exports.Direction = {}));
|
|
37
|
+
;
|
|
38
|
+
;
|
|
3
39
|
//# sourceMappingURL=interfaces.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/core/interfaces.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/core/interfaces.ts"],"names":[],"mappings":";;;AASA,IAAY,eAUX;AAVD,WAAY,eAAe;IACzB,iDAAM,CAAA;IACN,iDAAM,CAAA;IACN,mDAAO,CAAA;IACP,iDAAM,CAAA;IACN,mDAAO,CAAA;IACP,2DAAW,CAAA;IACX,uDAAS,CAAA;IACT,iDAAM,CAAA;IACN,mDAAO,CAAA;AACT,CAAC,EAVW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAU1B;AAAA,CAAC;AAEF,IAAY,eAMX;AAND,WAAY,eAAe;IACzB,yDAAU,CAAA;IACV,yDAAU,CAAA;IACV,2DAAW,CAAA;IACX,qDAAQ,CAAA;IACR,uDAAS,CAAA;AACX,CAAC,EANW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAM1B;AAAA,CAAC;AAEF,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,6CAAO,CAAA;IACP,2CAAM,CAAA;AACR,CAAC,EAHW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAGvB;AAAA,CAAC;AAsDF,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,kCAAqB,CAAA;IACrB,gCAAmB,CAAA;AACrB,CAAC,EAHW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAGpB;AAAA,CAAC;AAQD,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* toObject takes input contained in the proto structure defined in resource_base proto
|
|
3
|
+
* and converts it into Object understandable by the underlying DB implementation in chassis-srv
|
|
4
|
+
* @param {*} input Original filter input object
|
|
5
|
+
* @param {*} obj converted filter objected passed recursively
|
|
6
|
+
* @param {*} operatorList operatorlist updated and passed recursively
|
|
7
|
+
*/
|
|
8
|
+
export declare const toObject: (input: any, obj?: any, operatorList?: string[]) => any;
|
|
3
9
|
import { ResourcesAPIBase } from './core/ResourcesAPI';
|
|
4
10
|
export { ResourcesAPIBase };
|
|
5
11
|
import { ServiceBase } from './core/ServiceBase';
|
|
6
12
|
export { ServiceBase };
|
|
7
13
|
import { GraphResourcesServiceBase } from './core/GraphResourcesServiceBase';
|
|
8
14
|
export { GraphResourcesServiceBase };
|
|
15
|
+
export { Filter, FilterOp, FilterOperation, FilterValueType, OperatorType, TraversalOptions, GraphFilters, GraphFilter } from './core/interfaces';
|
package/lib/index.js
CHANGED
|
@@ -1,83 +1,202 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
2
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const _ = require("lodash");
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
22
|
+
exports.OperatorType = exports.FilterValueType = exports.FilterOperation = exports.GraphResourcesServiceBase = exports.ServiceBase = exports.ResourcesAPIBase = exports.toObject = void 0;
|
|
23
|
+
const _ = __importStar(require("lodash"));
|
|
24
|
+
const filterOperationMap = new Map([
|
|
25
|
+
[0, 'eq'],
|
|
26
|
+
[1, 'lt'],
|
|
27
|
+
[2, 'lte'],
|
|
28
|
+
[3, 'gt'],
|
|
29
|
+
[4, 'gte'],
|
|
30
|
+
[5, 'isEmpty'],
|
|
31
|
+
[6, 'iLike'],
|
|
32
|
+
[7, 'in'],
|
|
33
|
+
[8, 'neq']
|
|
34
|
+
]);
|
|
35
|
+
const filterOperatorMap = new Map([
|
|
36
|
+
[0, 'and'],
|
|
37
|
+
[1, 'or']
|
|
38
|
+
]);
|
|
39
|
+
/**
|
|
40
|
+
* Takes filter object containing field, operation and value and inserts it
|
|
41
|
+
* to the obj using the operatorList for finding the last operator position and updates obj
|
|
42
|
+
* @param {filter} filter object containing field, operation, value and type
|
|
43
|
+
* @param {obj} obj converted filter object
|
|
44
|
+
* @param {operatorList} operatorList list of operators from original filter object
|
|
45
|
+
*/
|
|
46
|
+
const convertFilterToObject = (filter, obj, operatorList) => {
|
|
47
|
+
let temp = _.clone(obj);
|
|
48
|
+
let value;
|
|
49
|
+
if (!filter.type || filter.type === 'STRING' || filter.type === 0) {
|
|
50
|
+
value = filter.value;
|
|
51
|
+
}
|
|
52
|
+
else if ((filter.type === 'NUMBER' || filter.type === 1) && !isNaN(filter.value)) {
|
|
53
|
+
value = Number(filter.value);
|
|
54
|
+
}
|
|
55
|
+
else if (filter.type === 'BOOLEAN' || filter.type === 2) {
|
|
56
|
+
if (filter.value === 'true') {
|
|
57
|
+
value = true;
|
|
13
58
|
}
|
|
14
|
-
else if (
|
|
15
|
-
|
|
59
|
+
else if (filter.value === 'false') {
|
|
60
|
+
value = false;
|
|
16
61
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return exports.toStruct(v, true);
|
|
22
|
-
})
|
|
23
|
-
}
|
|
24
|
-
};
|
|
62
|
+
}
|
|
63
|
+
else if (filter.type === 'ARRAY' || filter.type === 4) {
|
|
64
|
+
try {
|
|
65
|
+
value = JSON.parse(filter.value);
|
|
25
66
|
}
|
|
26
|
-
|
|
27
|
-
|
|
67
|
+
catch (err) {
|
|
68
|
+
// to handle JSON string parse error
|
|
69
|
+
if (err.message.indexOf('Unexpected token') > -1) {
|
|
70
|
+
value = JSON.parse(JSON.stringify(filter.value));
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
throw err;
|
|
74
|
+
}
|
|
28
75
|
}
|
|
29
|
-
return decodedVal;
|
|
30
|
-
};
|
|
31
|
-
let struct;
|
|
32
|
-
// fromArray flag is true when iterating
|
|
33
|
-
// objects inside a JSON array
|
|
34
|
-
if (!fromArray) {
|
|
35
|
-
struct = {
|
|
36
|
-
fields: {},
|
|
37
|
-
};
|
|
38
|
-
_.forEach(obj, (value, key) => {
|
|
39
|
-
struct.fields[key] = decode(value);
|
|
40
|
-
});
|
|
41
76
|
}
|
|
42
|
-
else {
|
|
43
|
-
|
|
77
|
+
else if (filter.type === 'DATE' || filter.type === 3) {
|
|
78
|
+
value = (new Date(filter.value)).getTime();
|
|
44
79
|
}
|
|
45
|
-
|
|
80
|
+
for (let i = 0; i < operatorList.length; i++) {
|
|
81
|
+
if (_.isArray(temp)) {
|
|
82
|
+
temp = _.find(temp, operatorList[i]);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
temp = temp[operatorList[i]];
|
|
86
|
+
}
|
|
87
|
+
if (i === (operatorList.length - 1)) {
|
|
88
|
+
// push for final element in the operatorList array
|
|
89
|
+
if (filter.operation === 'eq' || filter.operation === 0) {
|
|
90
|
+
if (_.isArray(temp)) {
|
|
91
|
+
temp.push({ [filter.field]: value });
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
temp[operatorList[i]].push({ [filter.field]: value });
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
else if (filter.operation === 'neq' || filter.operation === 8) {
|
|
98
|
+
if (_.isArray(temp)) {
|
|
99
|
+
temp.push({ [filter.field]: { $not: { $eq: value } } });
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
temp[operatorList[i]].push({ [filter.field]: { $not: { $eq: value } } });
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
let op, opValue;
|
|
107
|
+
if (typeof filter.operation === 'string' || filter.operation instanceof String) {
|
|
108
|
+
opValue = filter.operation;
|
|
109
|
+
}
|
|
110
|
+
else if (Number.isInteger(filter.operation)) {
|
|
111
|
+
opValue = filterOperationMap.get(filter.operation);
|
|
112
|
+
}
|
|
113
|
+
op = `$${opValue}`;
|
|
114
|
+
if (_.isArray(temp)) {
|
|
115
|
+
temp.push({ [filter.field]: { [op]: value } });
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
temp[operatorList[i]].push({ [filter.field]: { [op]: value } });
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return obj;
|
|
46
124
|
};
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
125
|
+
/**
|
|
126
|
+
* Inserts the new operator into obj iterating throught the operator list and updates obj
|
|
127
|
+
* @param {obj} obj Converted filter object
|
|
128
|
+
* @param {operatorList} operatorList operator list
|
|
129
|
+
* @param {operatorNew} operatorNew new operator
|
|
130
|
+
*/
|
|
131
|
+
const insertNewOpAndUpdateObj = (obj, operatorList, operatorNew) => {
|
|
132
|
+
let pos = _.clone(obj);
|
|
133
|
+
for (let i = 0; i < operatorList.length; i++) {
|
|
134
|
+
if (_.isArray(pos)) {
|
|
135
|
+
pos = _.find(pos, operatorList[i]);
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
pos = pos[operatorList[i]];
|
|
139
|
+
}
|
|
140
|
+
// push new operator after iterating to the last element in operatorList
|
|
141
|
+
if (i === (operatorList.length - 1)) {
|
|
142
|
+
pos.push({ [operatorNew]: [] });
|
|
143
|
+
}
|
|
52
144
|
}
|
|
53
|
-
|
|
54
|
-
|
|
145
|
+
return obj;
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* toObject takes input contained in the proto structure defined in resource_base proto
|
|
149
|
+
* and converts it into Object understandable by the underlying DB implementation in chassis-srv
|
|
150
|
+
* @param {*} input Original filter input object
|
|
151
|
+
* @param {*} obj converted filter objected passed recursively
|
|
152
|
+
* @param {*} operatorList operatorlist updated and passed recursively
|
|
153
|
+
*/
|
|
154
|
+
const toObject = (input, obj, operatorList) => {
|
|
155
|
+
// since toObject method is called recursively we are not adding the typing to input parameter
|
|
156
|
+
let filters;
|
|
157
|
+
if (input && !_.isEmpty(input.filters)) {
|
|
158
|
+
filters = input.filters;
|
|
55
159
|
}
|
|
56
|
-
else
|
|
57
|
-
|
|
160
|
+
else {
|
|
161
|
+
filters = input;
|
|
58
162
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
163
|
+
// const filters = _.cloneDeep( (input.filters && input.filters.length > 0) ? input.filters : input);
|
|
164
|
+
// by default use 'and' operator if no operator is specified
|
|
165
|
+
if (filters && _.isArray(filters.filter) && !filters.operator) {
|
|
166
|
+
filters.operator = 'and';
|
|
63
167
|
}
|
|
64
|
-
|
|
65
|
-
|
|
168
|
+
if (!obj) {
|
|
169
|
+
obj = {};
|
|
66
170
|
}
|
|
67
|
-
|
|
68
|
-
|
|
171
|
+
if (_.isArray(filters.filter)) {
|
|
172
|
+
let operatorValue;
|
|
173
|
+
if (typeof filters.operator === 'string' || filters.operator instanceof String) {
|
|
174
|
+
operatorValue = filters.operator;
|
|
175
|
+
}
|
|
176
|
+
else if (Number.isInteger(filters.operator)) {
|
|
177
|
+
operatorValue = filterOperatorMap.get(filters.operator);
|
|
178
|
+
}
|
|
179
|
+
const newOperator = `$${operatorValue}`;
|
|
180
|
+
if (operatorList && newOperator) {
|
|
181
|
+
// insert obj with new operator
|
|
182
|
+
obj = insertNewOpAndUpdateObj(obj, operatorList, newOperator);
|
|
183
|
+
operatorList.push(newOperator);
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
operatorList = [newOperator];
|
|
187
|
+
obj[newOperator] = [];
|
|
188
|
+
}
|
|
189
|
+
// pass operatorList and obj recursively
|
|
190
|
+
(0, exports.toObject)(filters.filter, obj, operatorList);
|
|
69
191
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (!fromArray) {
|
|
75
|
-
_.forEach(struct.fields, (value, key) => {
|
|
76
|
-
obj[key] = decodeValue(value);
|
|
77
|
-
});
|
|
192
|
+
else if (_.isArray(filters)) {
|
|
193
|
+
for (let filterObj of filters) {
|
|
194
|
+
(0, exports.toObject)(filterObj, obj, operatorList);
|
|
195
|
+
}
|
|
78
196
|
}
|
|
79
|
-
else {
|
|
80
|
-
obj
|
|
197
|
+
else if (filters.field && (filters.operation || filters.operation === 0) && filters.value) {
|
|
198
|
+
// object contains field, operation and value, update it on obj using convertFilterToObject()
|
|
199
|
+
obj = convertFilterToObject(filters, obj, operatorList);
|
|
81
200
|
}
|
|
82
201
|
return obj;
|
|
83
202
|
};
|
|
@@ -88,4 +207,8 @@ const ServiceBase_1 = require("./core/ServiceBase");
|
|
|
88
207
|
Object.defineProperty(exports, "ServiceBase", { enumerable: true, get: function () { return ServiceBase_1.ServiceBase; } });
|
|
89
208
|
const GraphResourcesServiceBase_1 = require("./core/GraphResourcesServiceBase");
|
|
90
209
|
Object.defineProperty(exports, "GraphResourcesServiceBase", { enumerable: true, get: function () { return GraphResourcesServiceBase_1.GraphResourcesServiceBase; } });
|
|
210
|
+
var interfaces_1 = require("./core/interfaces");
|
|
211
|
+
Object.defineProperty(exports, "FilterOperation", { enumerable: true, get: function () { return interfaces_1.FilterOperation; } });
|
|
212
|
+
Object.defineProperty(exports, "FilterValueType", { enumerable: true, get: function () { return interfaces_1.FilterValueType; } });
|
|
213
|
+
Object.defineProperty(exports, "OperatorType", { enumerable: true, get: function () { return interfaces_1.OperatorType; } });
|
|
91
214
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,0CAA4B;AAE5B,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC;IACjC,CAAC,CAAC,EAAE,IAAI,CAAC;IACT,CAAC,CAAC,EAAE,IAAI,CAAC;IACT,CAAC,CAAC,EAAE,KAAK,CAAC;IACV,CAAC,CAAC,EAAE,IAAI,CAAC;IACT,CAAC,CAAC,EAAE,KAAK,CAAC;IACV,CAAC,CAAC,EAAE,SAAS,CAAC;IACd,CAAC,CAAC,EAAE,OAAO,CAAC;IACZ,CAAC,C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K,EAAE;QAC3F,6FAA6F;QAC7F,GAAG,GAAG,qBAAqB,CAAC,OAAO,EAAE,GAAG,EAAE,YAAY,CAAC,CAAC;KACzD;IACD,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AA3CW,QAAA,QAAQ,YA2CnB;AAEF,sDAAuD;AAC9C,iGADA,+BAAgB,OACA;AACzB,oDAAiD;AACxC,4FADA,yBAAW,OACA;AACpB,gFAA6E;AACpE,0GADA,qDAAyB,OACA;AAClC,gDAAkJ;AAAvH,6GAAA,eAAe,OAAA;AAAE,6GAAA,eAAe,OAAA;AAAE,0GAAA,YAAY,OAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@restorecommerce/resource-base-interface",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Restorecommerce Resource Base Interface",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"author": "n-fuse GmbH",
|
|
@@ -17,42 +17,43 @@
|
|
|
17
17
|
"interface"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@restorecommerce/chassis-srv": "^0.
|
|
21
|
-
"@restorecommerce/grpc-client": "0.
|
|
22
|
-
"@restorecommerce/kafka-client": "^0.2.
|
|
23
|
-
"@restorecommerce/protos": "^0.0
|
|
24
|
-
"@restorecommerce/service-config": "^0.4.
|
|
20
|
+
"@restorecommerce/chassis-srv": "^0.3.6",
|
|
21
|
+
"@restorecommerce/grpc-client": "^0.2.14",
|
|
22
|
+
"@restorecommerce/kafka-client": "^0.2.29",
|
|
23
|
+
"@restorecommerce/protos": "^0.5.0",
|
|
24
|
+
"@restorecommerce/service-config": "^0.4.23",
|
|
25
25
|
"bluebird": "^3.7.2",
|
|
26
26
|
"lodash": "^4.17.21",
|
|
27
27
|
"redis": "^3.1.2"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@types/bluebird": "^3.5.
|
|
31
|
-
"@types/lodash": "^4.14.
|
|
32
|
-
"@types/mocha": "^
|
|
33
|
-
"@types/redis": "^2.8.
|
|
34
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
35
|
-
"@typescript-eslint/eslint-plugin-tslint": "^
|
|
36
|
-
"@typescript-eslint/parser": "^
|
|
30
|
+
"@types/bluebird": "^3.5.36",
|
|
31
|
+
"@types/lodash": "^4.14.178",
|
|
32
|
+
"@types/mocha": "^9.1.0",
|
|
33
|
+
"@types/redis": "^2.8.31",
|
|
34
|
+
"@typescript-eslint/eslint-plugin": "^5.10.1",
|
|
35
|
+
"@typescript-eslint/eslint-plugin-tslint": "^5.10.1",
|
|
36
|
+
"@typescript-eslint/parser": "^5.10.1",
|
|
37
37
|
"cross-env": "^7.0.3",
|
|
38
|
-
"eslint": "^7.
|
|
39
|
-
"eslint-plugin-prefer-arrow-functions": "^3.
|
|
40
|
-
"mocha": "^
|
|
38
|
+
"eslint": "^8.7.0",
|
|
39
|
+
"eslint-plugin-prefer-arrow-functions": "^3.1.4",
|
|
40
|
+
"mocha": "^9.2.0",
|
|
41
41
|
"npm-run-all": "^4.1.5",
|
|
42
42
|
"nyc": "^15.1.0",
|
|
43
43
|
"rimraf": "^3.0.2",
|
|
44
44
|
"should": "^13.2.3",
|
|
45
|
+
"ts-node": "^10.4.0",
|
|
45
46
|
"tslint": "^6.1.3",
|
|
46
|
-
"typescript": "^4.
|
|
47
|
+
"typescript": "^4.5.5"
|
|
47
48
|
},
|
|
48
49
|
"scripts": {
|
|
49
50
|
"test": "npm run lint && nyc npm run mocha",
|
|
50
|
-
"pretest": "npm run build
|
|
51
|
+
"pretest": "npm run build",
|
|
51
52
|
"tsctests": "tsc -d -p tsconfig.test.json",
|
|
52
53
|
"lint": "eslint 'src/**/*.ts' ",
|
|
53
|
-
"mocha": "cross-env NODE_ENV=test; mocha -
|
|
54
|
+
"mocha": "cross-env NODE_ENV=test; mocha --full-trace --exit --trace-warnings;",
|
|
54
55
|
"test-debug": "npm run lint && npm run mocha-debug",
|
|
55
|
-
"mocha-debug": "cross-env NODE_ENV=test; mocha
|
|
56
|
+
"mocha-debug": "cross-env NODE_ENV=test; mocha --full-trace --inspect-brk",
|
|
56
57
|
"lcov-report": "nyc report --reporter=lcov",
|
|
57
58
|
"build:tsc": "tsc -d",
|
|
58
59
|
"build:clean": "rimraf lib",
|
package/tsconfig.json
CHANGED
|
@@ -1,24 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"target": "
|
|
3
|
+
"target": "ES2021",
|
|
4
4
|
"module": "commonjs",
|
|
5
5
|
"moduleResolution": "node",
|
|
6
|
+
"declaration": true,
|
|
7
|
+
// "strict": true,
|
|
6
8
|
"emitDecoratorMetadata": true,
|
|
7
9
|
"experimentalDecorators": true,
|
|
8
10
|
"allowSyntheticDefaultImports": true,
|
|
11
|
+
"noUnusedLocals": false,
|
|
9
12
|
"skipLibCheck": true,
|
|
13
|
+
"esModuleInterop": true,
|
|
14
|
+
"sourceMap": true,
|
|
10
15
|
"outDir": "lib",
|
|
11
16
|
"typeRoots": [
|
|
12
17
|
"node_modules/@types"
|
|
13
18
|
],
|
|
14
|
-
"
|
|
19
|
+
"lib": [
|
|
20
|
+
"es2020.promise",
|
|
21
|
+
"dom"
|
|
22
|
+
]
|
|
15
23
|
},
|
|
16
24
|
"include": [
|
|
17
25
|
"./src/**/*.ts"
|
|
18
26
|
],
|
|
19
27
|
"exclude": [
|
|
20
|
-
"
|
|
28
|
+
"node_modules",
|
|
21
29
|
"lib",
|
|
22
|
-
"
|
|
30
|
+
"doc"
|
|
23
31
|
]
|
|
24
32
|
}
|