@mavenmachines/event-handler-lib 1.5.0-rc.2 → 1.5.0-rc.4
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/package.json +2 -1
- package/dist/src/clients/openSearch/mappings.d.ts +4 -2
- package/dist/src/clients/openSearch/mappings.js +8 -1
- package/dist/src/clients/openSearch/mappings.js.map +1 -1
- package/dist/src/clients/openSearch/openSearchClient.d.ts +6 -6
- package/dist/src/clients/openSearch/openSearchClient.js +56 -71
- package/dist/src/clients/openSearch/openSearchClient.js.map +1 -1
- package/dist/src/configs/inversifyConfig.js +3 -2
- package/dist/src/configs/inversifyConfig.js.map +1 -1
- package/dist/src/handlers/crud/baseHandlers.d.ts +1 -10
- package/dist/src/handlers/crud/baseHandlers.js +1 -12
- package/dist/src/handlers/crud/baseHandlers.js.map +1 -1
- package/dist/src/handlers/crud/createProjectionHandler.d.ts +1 -1
- package/dist/src/handlers/crud/createProjectionHandler.js +2 -1
- package/dist/src/handlers/crud/createProjectionHandler.js.map +1 -1
- package/dist/src/handlers/crud/createUpdateProjectionHandler.d.ts +1 -1
- package/dist/src/handlers/crud/createUpdateProjectionHandler.js +2 -1
- package/dist/src/handlers/crud/createUpdateProjectionHandler.js.map +1 -1
- package/dist/src/handlers/crud/decorators.d.ts +3 -2
- package/dist/src/handlers/crud/decorators.js +2 -2
- package/dist/src/handlers/crud/decorators.js.map +1 -1
- package/dist/src/handlers/crud/deleteProjectionHandler.d.ts +1 -1
- package/dist/src/handlers/crud/deleteProjectionHandler.js.map +1 -1
- package/dist/src/handlers/crud/getProjectionHandler.d.ts +1 -1
- package/dist/src/handlers/crud/getProjectionHandler.js +2 -1
- package/dist/src/handlers/crud/getProjectionHandler.js.map +1 -1
- package/dist/src/handlers/crud/getProjectionsHandler.d.ts +1 -1
- package/dist/src/handlers/crud/getProjectionsHandler.js +2 -1
- package/dist/src/handlers/crud/getProjectionsHandler.js.map +1 -1
- package/dist/src/handlers/crud/helpers.d.ts +13 -0
- package/dist/src/handlers/crud/helpers.js +124 -16
- package/dist/src/handlers/crud/helpers.js.map +1 -1
- package/dist/src/handlers/crud/index.d.ts +3 -3
- package/dist/src/handlers/crud/index.js +2 -4
- package/dist/src/handlers/crud/index.js.map +1 -1
- package/dist/src/handlers/crud/searchProjectionsHandler.d.ts +1 -13
- package/dist/src/handlers/crud/searchProjectionsHandler.js +25 -11
- package/dist/src/handlers/crud/searchProjectionsHandler.js.map +1 -1
- package/dist/src/handlers/crud/types.d.ts +46 -0
- package/dist/src/handlers/crud/types.js +42 -0
- package/dist/src/handlers/crud/types.js.map +1 -0
- package/dist/src/helpers/dataStructure.helpers.d.ts +1 -0
- package/dist/src/helpers/dataStructure.helpers.js +17 -0
- package/dist/src/helpers/dataStructure.helpers.js.map +1 -1
- package/dist/src/helpers/string.helpers.d.ts +2 -0
- package/dist/src/helpers/string.helpers.js +17 -0
- package/dist/src/helpers/string.helpers.js.map +1 -1
- package/dist/src/helpers/typeManipulation/classValidation.d.ts +1 -0
- package/dist/src/helpers/typeManipulation/classValidation.js.map +1 -1
- package/dist/src/helpers/typeManipulation/decorators.d.ts +7 -2
- package/dist/src/helpers/typeManipulation/decorators.js.map +1 -1
- package/dist/src/testUtils/mocks/openSearch.client.mock.d.ts +102 -0
- package/dist/src/testUtils/mocks/openSearch.client.mock.js +405 -0
- package/dist/src/testUtils/mocks/openSearch.client.mock.js.map +1 -0
- package/dist/test/testImplementations/testCrud.d.ts +3 -0
- package/dist/test/testImplementations/testCrud.js +14 -0
- package/dist/test/testImplementations/testCrud.js.map +1 -1
- package/dist/test/tests/clients/opensearch.client.spec.js +1 -72
- package/dist/test/tests/clients/opensearch.client.spec.js.map +1 -1
- package/dist/test/tests/eventHandlers/crudHandlers.spec.js +63 -2
- package/dist/test/tests/eventHandlers/crudHandlers.spec.js.map +1 -1
- package/dist/test/tests/helpers/decorators.spec.d.ts +1 -0
- package/dist/test/tests/helpers/decorators.spec.js +109 -0
- package/dist/test/tests/helpers/decorators.spec.js.map +1 -0
- package/dist/test/tests/helpers/syncOpensearch.spec.js +0 -43
- package/dist/test/tests/helpers/syncOpensearch.spec.js.map +1 -1
- package/package.json +3 -2
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const
|
|
1
|
+
import { FieldTypeNames } from "../../clients/openSearch/mappings";
|
|
2
|
+
export declare const IsEditable: () => import("../../helpers/typeManipulation/decorators").Decorator, getIsEditable: import("../../helpers/typeManipulation/decorators").MetadataGetter<boolean>, getEditable: ((target: any, value?: false | undefined) => readonly string[]) | ((target: any, value?: true | undefined) => readonly string[]);
|
|
3
|
+
export declare const IsSearchable: (value?: FieldTypeNames | undefined) => import("../../helpers/typeManipulation/decorators").Decorator, getIsSearchable: import("../../helpers/typeManipulation/decorators").MetadataGetter<FieldTypeNames | undefined>, getSearchable: ((target: any) => readonly string[]) | ((target: any, value?: "string" | undefined) => readonly string[]) | ((target: any, value?: "number" | undefined) => readonly string[]) | ((target: any, value?: "boolean" | undefined) => readonly string[]) | ((target: any, value?: "id" | undefined) => readonly string[]) | ((target: any, value?: "geopoint" | undefined) => readonly string[]);
|
|
3
4
|
export declare const ProjectionType: (value: string) => import("../../helpers/typeManipulation/decorators").Decorator, getProjectionType: import("../../helpers/typeManipulation/decorators").MetadataGetter<string>;
|
|
@@ -3,7 +3,7 @@ var _a, _b, _c;
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.getProjectionType = exports.ProjectionType = exports.getSearchable = exports.getIsSearchable = exports.IsSearchable = exports.getEditable = exports.getIsEditable = exports.IsEditable = void 0;
|
|
5
5
|
const decorators_1 = require("../../helpers/typeManipulation/decorators");
|
|
6
|
-
_a = (0, decorators_1.createMetadataDecorator)("editable"
|
|
7
|
-
_b = (0, decorators_1.createMetadataDecorator)("searchable"
|
|
6
|
+
_a = (0, decorators_1.createMetadataDecorator)("editable"), exports.IsEditable = _a[0], exports.getIsEditable = _a[1], exports.getEditable = _a[2];
|
|
7
|
+
_b = (0, decorators_1.createMetadataDecorator)("searchable"), exports.IsSearchable = _b[0], exports.getIsSearchable = _b[1], exports.getSearchable = _b[2];
|
|
8
8
|
_c = (0, decorators_1.createMetadataDecorator)("projectionType"), exports.ProjectionType = _c[0], exports.getProjectionType = _c[1];
|
|
9
9
|
//# sourceMappingURL=decorators.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../../../src/handlers/crud/decorators.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../../../src/handlers/crud/decorators.ts"],"names":[],"mappings":";;;;AACA,0EAAoF;AAEvE,KACX,IAAA,oCAAuB,EAAU,UAAU,CAAC,EADhC,kBAAU,UAAE,qBAAa,UAAE,mBAAW,SACL;AAElC,KACX,IAAA,oCAAuB,EAA6B,YAAY,CAAC,EADrD,oBAAY,UAAE,uBAAe,UAAE,qBAAa,SACU;AAEvD,KACX,IAAA,oCAAuB,EAAS,gBAAgB,CAAC,EADrC,sBAAc,UAAE,yBAAiB,SACK"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deleteProjectionHandler.js","sourceRoot":"","sources":["../../../../src/handlers/crud/deleteProjectionHandler.ts"],"names":[],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"deleteProjectionHandler.js","sourceRoot":"","sources":["../../../../src/handlers/crud/deleteProjectionHandler.ts"],"names":[],"mappings":";;;;;;;;;;;;AAiBA,sEA2BC;AA5CD,qDAAkD;AAClD,iDAAwD;AAExD,6CAAiD;AAIjD,MAAa,uBAAuB;CAMnC;AAND,0DAMC;AAJC;IADC,IAAA,uBAAK,GAAE;;0DACW;AAGnB;IADC,IAAA,0BAAQ,GAAE;;mDACC;AAGd,MAAa,wBAAwB;CAAG;AAAxC,4DAAwC;AAExC,SAAgB,6BAA6B,CAC3C,eAAoC;IAEpC,OAAO,qCAAsB,CAAC,MAAM,CAClC,QAAQ,EACR,eAAe,EACf,uBAAuB,EACvB,KAAK,WAKH,OAAuD;QAEvD,MAAM,EACJ,SAAS,EACT,OAAO,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,GAC1B,GAAG,OAAO,CAAC;QACZ,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAC;YACxD,SAAS;YACT,cAAc,EAAE,IAAA,8BAAiB,EAAC,eAAe,CAAC;YAClD,QAAQ;SACT,CAAC,CAAC;QACH,MAAM,OAAO,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QAC5D,OAAO,EAAE,CAAC;IACZ,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ClassConstructor } from "class-transformer";
|
|
2
|
-
import { CompanyIdRequest, Projection, ProjectionId } from "./baseHandlers";
|
|
3
2
|
import { RpcHandler } from "../../rpc/abstractRpcHandler";
|
|
3
|
+
import { CompanyIdRequest, Projection, ProjectionId } from "./types";
|
|
4
4
|
declare const GetProjectionRequest_base: ClassConstructor<CompanyIdRequest & ProjectionId>;
|
|
5
5
|
export declare class GetProjectionRequest extends GetProjectionRequest_base {
|
|
6
6
|
}
|
|
@@ -6,7 +6,8 @@ const class_transformer_1 = require("class-transformer");
|
|
|
6
6
|
const dynamicClasses_1 = require("../../helpers/typeManipulation/dynamicClasses");
|
|
7
7
|
const baseHandlers_1 = require("./baseHandlers");
|
|
8
8
|
const decorators_1 = require("./decorators");
|
|
9
|
-
|
|
9
|
+
const types_1 = require("./types");
|
|
10
|
+
class GetProjectionRequest extends (0, dynamicClasses_1.combine)(types_1.CompanyIdRequest, types_1.ProjectionId) {
|
|
10
11
|
}
|
|
11
12
|
exports.GetProjectionRequest = GetProjectionRequest;
|
|
12
13
|
class GetProjectionResponse {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getProjectionHandler.js","sourceRoot":"","sources":["../../../../src/handlers/crud/getProjectionHandler.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"getProjectionHandler.js","sourceRoot":"","sources":["../../../../src/handlers/crud/getProjectionHandler.ts"],"names":[],"mappings":";;;AAeA,gEA6BC;AA5CD,yDAAsE;AACtE,kFAAwE;AACxE,iDAAsD;AAEtD,6CAAiD;AACjD,mCAAqE;AAErE,MAAa,oBAAqB,SAAQ,IAAA,wBAAO,EAC/C,wBAAgB,EAChB,oBAAY,CACb;CAAG;AAHJ,oDAGI;AACJ,MAAa,qBAAqB;CAEjC;AAFD,sDAEC;AAED,SAAgB,0BAA0B,CACxC,eAAoC;IAIpC,MAAM,cAAc,GAAG,IAAA,8BAAiB,EAAC,eAAe,CAAC,CAAC;IAC1D,OAAO,mCAAoB,CAAC,MAAM,CAChC,KAAK,EACL,eAAe,EACf,oBAAoB,EACpB,CAAA,qBAAwB,CAAA,EACxB,KAAK,WAKH,OAA6B;QAE7B,MAAM,EAAE,SAAS,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC;QAClC,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,aAAa,CAAI;YAClE,SAAS;YACT,cAAc;YACd,QAAQ,EAAE,EAAE;SACb,CAAC,CAAC;QACH,OAAO,IAAA,mCAAe,EAAC,CAAA,qBAAwB,CAAA,EAAE;YAC/C,UAAU,EAAE,UAAU,EAAE,OAAO;SAChC,CAAC,CAAC;IACL,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -18,7 +18,8 @@ const class_validator_1 = require("class-validator");
|
|
|
18
18
|
const baseHandlers_1 = require("./baseHandlers");
|
|
19
19
|
const bluebird_1 = __importDefault(require("bluebird"));
|
|
20
20
|
const decorators_1 = require("./decorators");
|
|
21
|
-
|
|
21
|
+
const types_1 = require("./types");
|
|
22
|
+
class GetProjectionsRequest extends types_1.CompanyIdRequest {
|
|
22
23
|
}
|
|
23
24
|
exports.GetProjectionsRequest = GetProjectionsRequest;
|
|
24
25
|
__decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getProjectionsHandler.js","sourceRoot":"","sources":["../../../../src/handlers/crud/getProjectionsHandler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"getProjectionsHandler.js","sourceRoot":"","sources":["../../../../src/handlers/crud/getProjectionsHandler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAmBA,kEA0CC;AA7DD,qDAAoD;AACpD,iDAAsD;AAEtD,wDAAgC;AAChC,6CAAiD;AAEjD,mCAAuD;AAEvD,MAAa,qBAAsB,SAAQ,wBAAgB;CAI1D;AAJD,sDAIC;AADC;IAFC,IAAA,yBAAO,GAAE;IACT,IAAA,0BAAQ,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;;kDACV;AAGjB,MAAa,sBAAsB;CAGlC;AAHD,wDAGC;AAED,SAAgB,2BAA2B,CACzC,eAAoC;IAEpC,MAAM,cAAc,GAAG,IAAA,8BAAiB,EAAC,eAAe,CAAC,CAAC;IAC1D,OAAO,mCAAoB,CAAC,MAAM,CAChC,KAAK,EACL,eAAe,EACf,qBAAqB,EACrB,CAAA,sBAAyB,CAAA,EACzB,KAAK,WAKH,OAA8B;QAE9B,MAAM,EAAE,SAAS,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;QACnC,MAAM,OAAO,GAAG,MAAM,kBAAQ,CAAC,GAAG,CAChC,GAAG,EACH,KAAK,EAAE,QAAQ,EAAE,EAAE,CACjB;YACE,QAAQ;YACR,MAAM,IAAI,CAAC,oBAAoB,CAAC,aAAa,CAAI;gBAC/C,SAAS;gBACT,cAAc;gBACd,QAAQ;aACT,CAAC;SACoC,CAC3C,CAAC;QACF,MAAM,WAAW,GAAG,OAAO;aACxB,MAAM,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,EAAE,EAAE,CAAC,UAAU,KAAK,SAAS,CAAC;aACpD,GAAG,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAC/C,MAAM,OAAO,GAAG,OAAO;aACpB,MAAM,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,EAAE,EAAE,CAAC,UAAU,KAAK,SAAS,CAAC;aACpD,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC;QACjC,OAAO;YACL,WAAW;YACX,OAAO;SACR,CAAC;IACJ,CAAC,EACD,IAAI,CACL,CAAC;AACJ,CAAC"}
|
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
import { ClassConstructor } from "class-transformer";
|
|
2
2
|
import { DeepPartial } from "../../helpers/dataStructure.helpers";
|
|
3
|
+
import { DistanceUnits } from "./types";
|
|
3
4
|
export declare function describe<T extends Record<string, any>>(projectionClass: ClassConstructor<T>): {
|
|
4
5
|
editable: readonly (keyof T)[];
|
|
5
6
|
searchable: readonly (keyof T)[];
|
|
6
7
|
};
|
|
7
8
|
export declare function deepApply<T extends Record<string, any>>(target: T, updates: DeepPartial<T>): T;
|
|
9
|
+
export declare class GeopointQueryObject {
|
|
10
|
+
lat?: number;
|
|
11
|
+
lon?: number;
|
|
12
|
+
distance?: number;
|
|
13
|
+
units?: DistanceUnits;
|
|
14
|
+
top?: number;
|
|
15
|
+
left?: number;
|
|
16
|
+
bottom?: number;
|
|
17
|
+
right?: number;
|
|
18
|
+
}
|
|
19
|
+
export declare function allSearchable<T extends object>(cls: ClassConstructor<T>): ClassConstructor<Partial<T>>;
|
|
20
|
+
export declare function deepSearchable<T extends object>(cls: ClassConstructor<T>): ClassConstructor<Partial<T>>;
|
|
8
21
|
export declare function deepOptional<T extends object>(cls: ClassConstructor<T>): ClassConstructor<Partial<T>>;
|
|
9
22
|
export declare function deepEditable<T extends object>(cls: ClassConstructor<T>): ClassConstructor<Partial<Pick<T, keyof T>>>;
|
|
@@ -1,12 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.GeopointQueryObject = void 0;
|
|
3
13
|
exports.describe = describe;
|
|
4
14
|
exports.deepApply = deepApply;
|
|
15
|
+
exports.allSearchable = allSearchable;
|
|
16
|
+
exports.deepSearchable = deepSearchable;
|
|
5
17
|
exports.deepOptional = deepOptional;
|
|
6
18
|
exports.deepEditable = deepEditable;
|
|
7
19
|
const decorators_1 = require("./decorators");
|
|
8
20
|
const dynamicClasses_1 = require("../../helpers/typeManipulation/dynamicClasses");
|
|
9
21
|
const classValidation_1 = require("../../helpers/typeManipulation/classValidation");
|
|
22
|
+
const class_validator_1 = require("class-validator");
|
|
23
|
+
const types_1 = require("./types");
|
|
10
24
|
function describe(projectionClass) {
|
|
11
25
|
return {
|
|
12
26
|
editable: (0, decorators_1.getEditable)(projectionClass),
|
|
@@ -43,29 +57,123 @@ function deepApply(target, updates) {
|
|
|
43
57
|
});
|
|
44
58
|
return target;
|
|
45
59
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
60
|
+
const modifiedClasses = new Map();
|
|
61
|
+
function deepModify(cls, modify, name) {
|
|
62
|
+
if (!modifiedClasses.has(name)) {
|
|
63
|
+
modifiedClasses.set(name, new Map());
|
|
64
|
+
}
|
|
65
|
+
if (modifiedClasses.get(name).has(cls)) {
|
|
66
|
+
return modifiedClasses.get(name).get(cls);
|
|
67
|
+
}
|
|
68
|
+
const Child = modify(cls);
|
|
69
|
+
modifyChildren(Child, (x) => deepModify(x, modify, name));
|
|
70
|
+
const Renamed = (0, dynamicClasses_1.renameClass)(Child, `${name}${cls.name}`);
|
|
71
|
+
modifiedClasses.get(name).set(cls, Renamed);
|
|
72
|
+
return Renamed;
|
|
73
|
+
}
|
|
74
|
+
function modifyChildren(cls, modify) {
|
|
75
|
+
for (const rule of (0, classValidation_1.getClassTransformerRules)(cls)) {
|
|
49
76
|
if (rule.typeFunction) {
|
|
50
77
|
const currentType = rule.typeFunction();
|
|
51
|
-
const
|
|
52
|
-
rule.typeFunction = () =>
|
|
78
|
+
const modifiedType = modify(currentType, rule.propertyName);
|
|
79
|
+
rule.typeFunction = () => modifiedType;
|
|
53
80
|
}
|
|
54
81
|
}
|
|
55
|
-
|
|
56
|
-
return Child;
|
|
82
|
+
return cls;
|
|
57
83
|
}
|
|
58
|
-
function
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
|
|
84
|
+
function mutuallyExclusive(...groups) {
|
|
85
|
+
for (let i = 0; i < groups.length; i++) {
|
|
86
|
+
for (let j = 0; j < groups.length; j++) {
|
|
87
|
+
if (i === j) {
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
for (const member of groups[i]) {
|
|
91
|
+
if (groups[j].includes(member)) {
|
|
92
|
+
throw new Error(`${member} found in ${groups[i].join(", ")} and ${groups[j].join(", ")}`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
66
95
|
}
|
|
67
96
|
}
|
|
68
|
-
(
|
|
97
|
+
return function (target, propertyKey, propertyDescriptor) {
|
|
98
|
+
let i;
|
|
99
|
+
for (i = 0; i < groups.length; i++) {
|
|
100
|
+
if (groups[i].includes(propertyKey)) {
|
|
101
|
+
for (const member of groups[i]) {
|
|
102
|
+
(0, class_validator_1.ValidateIf)((o) => o[member] !== undefined)(target, propertyKey);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
for (const member of groups[i]) {
|
|
107
|
+
(0, class_validator_1.ValidateIf)((o) => o[member] === undefined)(target, propertyKey);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
const ValidateGeopoint = mutuallyExclusive(["lat", "lon", "distance", "units"], ["top", "left", "bottom", "right"]);
|
|
114
|
+
class GeopointQueryObject {
|
|
115
|
+
}
|
|
116
|
+
exports.GeopointQueryObject = GeopointQueryObject;
|
|
117
|
+
__decorate([
|
|
118
|
+
ValidateGeopoint,
|
|
119
|
+
(0, class_validator_1.IsNumber)(),
|
|
120
|
+
__metadata("design:type", Number)
|
|
121
|
+
], GeopointQueryObject.prototype, "lat", void 0);
|
|
122
|
+
__decorate([
|
|
123
|
+
ValidateGeopoint,
|
|
124
|
+
(0, class_validator_1.IsNumber)(),
|
|
125
|
+
__metadata("design:type", Number)
|
|
126
|
+
], GeopointQueryObject.prototype, "lon", void 0);
|
|
127
|
+
__decorate([
|
|
128
|
+
ValidateGeopoint,
|
|
129
|
+
(0, class_validator_1.IsNumber)(),
|
|
130
|
+
__metadata("design:type", Number)
|
|
131
|
+
], GeopointQueryObject.prototype, "distance", void 0);
|
|
132
|
+
__decorate([
|
|
133
|
+
ValidateGeopoint,
|
|
134
|
+
(0, class_validator_1.IsIn)(types_1.DISTANCE_UNITS),
|
|
135
|
+
__metadata("design:type", String)
|
|
136
|
+
], GeopointQueryObject.prototype, "units", void 0);
|
|
137
|
+
__decorate([
|
|
138
|
+
ValidateGeopoint,
|
|
139
|
+
(0, class_validator_1.IsNumber)(),
|
|
140
|
+
__metadata("design:type", Number)
|
|
141
|
+
], GeopointQueryObject.prototype, "top", void 0);
|
|
142
|
+
__decorate([
|
|
143
|
+
ValidateGeopoint,
|
|
144
|
+
(0, class_validator_1.IsNumber)(),
|
|
145
|
+
__metadata("design:type", Number)
|
|
146
|
+
], GeopointQueryObject.prototype, "left", void 0);
|
|
147
|
+
__decorate([
|
|
148
|
+
ValidateGeopoint,
|
|
149
|
+
(0, class_validator_1.IsNumber)(),
|
|
150
|
+
__metadata("design:type", Number)
|
|
151
|
+
], GeopointQueryObject.prototype, "bottom", void 0);
|
|
152
|
+
__decorate([
|
|
153
|
+
ValidateGeopoint,
|
|
154
|
+
(0, class_validator_1.IsNumber)(),
|
|
155
|
+
__metadata("design:type", Number)
|
|
156
|
+
], GeopointQueryObject.prototype, "right", void 0);
|
|
157
|
+
function allSearchable(cls) {
|
|
158
|
+
const Child = (0, dynamicClasses_1.allOptional)(cls);
|
|
159
|
+
modifyChildren(Child, (x, name) => {
|
|
160
|
+
if (name === "latLon" || (0, decorators_1.getIsSearchable)(cls, name) === "geopoint") {
|
|
161
|
+
return GeopointQueryObject;
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
return x;
|
|
165
|
+
}
|
|
166
|
+
});
|
|
69
167
|
return Child;
|
|
70
168
|
}
|
|
169
|
+
function deepSearchable(cls) {
|
|
170
|
+
return deepModify(cls, (x) => allSearchable(x), "Searchable");
|
|
171
|
+
}
|
|
172
|
+
function deepOptional(cls) {
|
|
173
|
+
return deepModify(cls, (x) => (0, dynamicClasses_1.allOptional)(x), "Optional");
|
|
174
|
+
}
|
|
175
|
+
function deepEditable(cls) {
|
|
176
|
+
const { editable } = describe(cls);
|
|
177
|
+
return deepModify(cls, (x) => (0, dynamicClasses_1.allOptional)((0, dynamicClasses_1.pickFields)(cls, ...editable)), "Editable");
|
|
178
|
+
}
|
|
71
179
|
//# sourceMappingURL=helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../src/handlers/crud/helpers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../src/handlers/crud/helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;AAYA,4BAUC;AAED,8BAgCC;AA0HD,sCAUC;AAED,wCAEC;AAED,oCAEC;AAED,oCAOC;AA3MD,6CAA2E;AAC3E,kFAIuD;AACvD,oFAA0F;AAC1F,qDAA6D;AAC7D,mCAAwD;AAExD,SAAgB,QAAQ,CACtB,eAAoC;IAKpC,OAAO;QACL,QAAQ,EAAE,IAAA,wBAAW,EAAC,eAAe,CAAgB;QACrD,UAAU,EAAE,IAAA,0BAAa,EAAC,eAAe,CAAgB;KAC1D,CAAC;AACJ,CAAC;AAED,SAAgB,SAAS,CACvB,MAAS,EACT,OAAuB;IAEvB,IAAI,QAAQ,GAAG,CAAC,GAAY,EAAE,EAAE,CAAC,SAAS,CAAC;IAC3C,IAAI,MAAM,CAAC,WAAW,IAAI,MAAM,CAAC,WAAW,KAAK,MAAM,EAAE,CAAC;QACxD,MAAM,EAAE,QAAQ,EAAE,GAAG,QAAQ,CAAC,MAAM,CAAC,WAAkC,CAAC,CAAC;QACzE,QAAQ,GAAG,CAAC,GAAY,EAAE,EAAE;YAC1B,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAa,CAAC,EAAE,CAAC;gBACtC,MAAM,IAAI,KAAK,CACb,iBAAiB,MAAM,CAAC,WAAW,CAAC,IAAI,IAAI,GAAa,EAAE,CAC5D,CAAC;YACJ,CAAC;QACH,CAAC,CAAC;IACJ,CAAC;IACD,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAiB,EAAE,EAAE;QAC/D,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,OAAO;QACT,CAAC;QACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9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BAAgB;IAChB,IAAA,0BAAQ,GAAE;;mDACK;AAIhB;IAFC,gBAAgB;IAChB,IAAA,0BAAQ,GAAE;;kDACI;AAKjB,SAAgB,aAAa,CAAmB,GAAwB;IACtE,MAAM,KAAK,GAAG,IAAA,4BAAW,EAAC,GAAG,CAAC,CAAC;IAC/B,cAAc,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE;QAChC,IAAI,IAAI,KAAK,QAAQ,IAAI,IAAA,4BAAe,EAAC,GAAG,EAAE,IAAI,CAAC,KAAK,UAAU,EAAE,CAAC;YACnE,OAAO,mBAAmB,CAAC;QAC7B,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,CAAC;QACX,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAgB,cAAc,CAAmB,GAAwB;IACvE,OAAO,UAAU,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;AAChE,CAAC;AAED,SAAgB,YAAY,CAAmB,GAAwB;IACrE,OAAO,UAAU,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,4BAAW,EAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;AAC5D,CAAC;AAED,SAAgB,YAAY,CAAmB,GAAwB;IACrE,MAAM,EAAE,QAAQ,EAAE,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;IACnC,OAAO,UAAU,CACf,GAAG,EACH,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,4BAAW,EAAC,IAAA,2BAAU,EAAC,GAAG,EAAE,GAAG,QAAQ,CAAC,CAAC,EAChD,UAAU,CACX,CAAC;AACJ,CAAC"}
|
|
@@ -4,17 +4,17 @@ import { createGetProjectionsHandler } from "./getProjectionsHandler";
|
|
|
4
4
|
import { createUpdateProjectionHandler, createUpdateRequest } from "./createUpdateProjectionHandler";
|
|
5
5
|
import { createDeleteProjectionHandler } from "./deleteProjectionHandler";
|
|
6
6
|
import { createSearchProjectionsHandler, createSearchRequest } from "./searchProjectionsHandler";
|
|
7
|
-
import { CrudAction, Projection } from "./baseHandlers";
|
|
8
7
|
import { ClassConstructor } from "class-transformer";
|
|
9
8
|
import { Container } from "inversify";
|
|
10
|
-
|
|
9
|
+
import { CrudAction, Projection } from "./types";
|
|
11
10
|
export { CreateRequest, CreatedResponse } from "./createProjectionHandler";
|
|
12
11
|
export { UpdateRequest, ModifiedResponse, } from "./createUpdateProjectionHandler";
|
|
13
12
|
export { DeleteProjectionRequest, DeleteProjectionResponse, } from "./deleteProjectionHandler";
|
|
14
13
|
export { GetProjectionRequest, GetProjectionResponse, } from "./getProjectionHandler";
|
|
15
14
|
export { GetProjectionsRequest, GetProjectionsResponse, } from "./getProjectionsHandler";
|
|
16
|
-
export {
|
|
15
|
+
export { SearchResults } from "./searchProjectionsHandler";
|
|
17
16
|
export * from "./decorators";
|
|
17
|
+
export * from "./types";
|
|
18
18
|
export declare const CrudHandlerFactory: {
|
|
19
19
|
getHandler: typeof createGetProjectionHandler;
|
|
20
20
|
multiGetHandler: typeof createGetProjectionsHandler;
|
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.CrudCommandFactory = exports.CrudHandlerFactory = exports.SearchResults = exports.GetProjectionsResponse = exports.GetProjectionsRequest = exports.GetProjectionResponse = exports.GetProjectionRequest = exports.DeleteProjectionResponse = exports.DeleteProjectionRequest = exports.ModifiedResponse = exports.CreatedResponse =
|
|
17
|
+
exports.CrudCommandFactory = exports.CrudHandlerFactory = exports.SearchResults = exports.GetProjectionsResponse = exports.GetProjectionsRequest = exports.GetProjectionResponse = exports.GetProjectionRequest = exports.DeleteProjectionResponse = exports.DeleteProjectionRequest = exports.ModifiedResponse = exports.CreatedResponse = void 0;
|
|
18
18
|
const createProjectionHandler_1 = require("./createProjectionHandler");
|
|
19
19
|
const getProjectionHandler_1 = require("./getProjectionHandler");
|
|
20
20
|
const getProjectionsHandler_1 = require("./getProjectionsHandler");
|
|
@@ -22,9 +22,6 @@ const createUpdateProjectionHandler_1 = require("./createUpdateProjectionHandler
|
|
|
22
22
|
const deleteProjectionHandler_1 = require("./deleteProjectionHandler");
|
|
23
23
|
const searchProjectionsHandler_1 = require("./searchProjectionsHandler");
|
|
24
24
|
const dependencyTypes_1 = require("../../dependencies/dependencyTypes");
|
|
25
|
-
var baseHandlers_1 = require("./baseHandlers");
|
|
26
|
-
Object.defineProperty(exports, "ProjectionId", { enumerable: true, get: function () { return baseHandlers_1.ProjectionId; } });
|
|
27
|
-
Object.defineProperty(exports, "CompanyIdRequest", { enumerable: true, get: function () { return baseHandlers_1.CompanyIdRequest; } });
|
|
28
25
|
var createProjectionHandler_2 = require("./createProjectionHandler");
|
|
29
26
|
Object.defineProperty(exports, "CreatedResponse", { enumerable: true, get: function () { return createProjectionHandler_2.CreatedResponse; } });
|
|
30
27
|
var createUpdateProjectionHandler_2 = require("./createUpdateProjectionHandler");
|
|
@@ -41,6 +38,7 @@ Object.defineProperty(exports, "GetProjectionsResponse", { enumerable: true, get
|
|
|
41
38
|
var searchProjectionsHandler_2 = require("./searchProjectionsHandler");
|
|
42
39
|
Object.defineProperty(exports, "SearchResults", { enumerable: true, get: function () { return searchProjectionsHandler_2.SearchResults; } });
|
|
43
40
|
__exportStar(require("./decorators"), exports);
|
|
41
|
+
__exportStar(require("./types"), exports);
|
|
44
42
|
exports.CrudHandlerFactory = {
|
|
45
43
|
getHandler: getProjectionHandler_1.createGetProjectionHandler,
|
|
46
44
|
multiGetHandler: getProjectionsHandler_1.createGetProjectionsHandler,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/handlers/crud/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,uEAGmC;AACnC,iEAAoE;AACpE,mEAAsE;AACtE,mFAGyC;AACzC,uEAA0E;AAC1E,yEAGoC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/handlers/crud/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,uEAGmC;AACnC,iEAAoE;AACpE,mEAAsE;AACtE,mFAGyC;AACzC,uEAA0E;AAC1E,yEAGoC;AAGpC,wEAA2D;AAG3D,qEAA2E;AAAnD,0HAAA,eAAe,OAAA;AACvC,iFAGyC;AADvC,iIAAA,gBAAgB,OAAA;AAElB,qEAGmC;AAFjC,kIAAA,uBAAuB,OAAA;AACvB,mIAAA,wBAAwB,OAAA;AAE1B,+DAGgC;AAF9B,4HAAA,oBAAoB,OAAA;AACpB,6HAAA,qBAAqB,OAAA;AAEvB,iEAGiC;AAF/B,8HAAA,qBAAqB,OAAA;AACrB,+HAAA,sBAAsB,OAAA;AAExB,uEAA2D;AAAlD,yHAAA,aAAa,OAAA;AACtB,+CAA6B;AAC7B,0CAAwB;AAEX,QAAA,kBAAkB,GAAG;IAChC,UAAU,EAAE,iDAA0B;IACtC,eAAe,EAAE,mDAA2B;IAC5C,aAAa,EAAE,6DAA6B;IAC5C,aAAa,EAAE,uDAA6B;IAC5C,aAAa,EAAE,uDAA6B;IAC5C,aAAa,EAAE,yDAA8B;IAC7C,IAAI,EAAE,CACJ,SAAoB,EACpB,eAA6C,EAC7C,UAAwB,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,CAAC,EACvE,QAAiB,IAAI,EACrB,EAAE;QACF,IAAI,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YAC5B,SAAS;iBACN,IAAI,CAAC,uBAAK,CAAC,UAAU,CAAC;iBACtB,EAAE,CAAC,IAAA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 -1,17 +1,5 @@
|
|
|
1
1
|
import { ClassConstructor } from "class-transformer";
|
|
2
|
-
import {
|
|
3
|
-
import { DeepPartial } from "../../helpers/dataStructure.helpers";
|
|
4
|
-
export type SortParameters<T extends object> = {
|
|
5
|
-
[P in keyof T]?: T[P] extends object ? SortParameters<T[P]> : "asc" | "desc";
|
|
6
|
-
};
|
|
7
|
-
export type SearchRequest<T extends Projection> = CompanyIdRequest & {
|
|
8
|
-
query: DeepPartial<T>;
|
|
9
|
-
limit?: number;
|
|
10
|
-
continuationToken?: string;
|
|
11
|
-
page?: number;
|
|
12
|
-
sort?: SortParameters<T>;
|
|
13
|
-
pointInTime?: boolean;
|
|
14
|
-
};
|
|
2
|
+
import { Projection, SearchRequest } from "./types";
|
|
15
3
|
export declare class SearchResults<T> {
|
|
16
4
|
results: T[];
|
|
17
5
|
continuationToken?: string;
|
|
@@ -23,15 +23,16 @@ const classValidation_1 = require("../../helpers/typeManipulation/classValidatio
|
|
|
23
23
|
const abstractRpcHandler_1 = require("../../rpc/abstractRpcHandler");
|
|
24
24
|
const rpc_error_keys_enum_1 = require("../../types/enums/rpc-error-keys.enum");
|
|
25
25
|
const errors_1 = require("../../clients/openSearch/errors");
|
|
26
|
+
const types_1 = require("./types");
|
|
26
27
|
class SearchResults {
|
|
27
28
|
}
|
|
28
29
|
exports.SearchResults = SearchResults;
|
|
29
30
|
function createSearchRequest(projectionClass) {
|
|
30
|
-
class Request extends
|
|
31
|
+
class Request extends types_1.CompanyIdRequest {
|
|
31
32
|
}
|
|
32
33
|
__decorate([
|
|
33
34
|
(0, class_validator_1.ValidateNested)(),
|
|
34
|
-
(0, class_transformer_1.Type)(() => (0, helpers_1.
|
|
35
|
+
(0, class_transformer_1.Type)(() => (0, helpers_1.deepSearchable)(projectionClass)),
|
|
35
36
|
__metadata("design:type", Object)
|
|
36
37
|
], Request.prototype, "query", void 0);
|
|
37
38
|
__decorate([
|
|
@@ -69,6 +70,9 @@ function convertSortFields(sort, mappings) {
|
|
|
69
70
|
if (fieldSort === undefined) {
|
|
70
71
|
throw new abstractRpcHandler_1.RpcHandlerError(rpc_error_keys_enum_1.RpcErrorKey.ERROR_INVALID_FORMAT, `Unknown field ${key}`);
|
|
71
72
|
}
|
|
73
|
+
else if (fieldSort === "geopoint") {
|
|
74
|
+
return [key];
|
|
75
|
+
}
|
|
72
76
|
else if (fieldSort === "string") {
|
|
73
77
|
return [`${key}.keyword`, value];
|
|
74
78
|
}
|
|
@@ -80,7 +84,25 @@ function convertSortFields(sort, mappings) {
|
|
|
80
84
|
function* getTypes(cls) {
|
|
81
85
|
const { searchable } = (0, helpers_1.describe)(cls);
|
|
82
86
|
for (const metadata of (0, classValidation_1.getClassValidatorRules)(cls)) {
|
|
83
|
-
if (metadata.
|
|
87
|
+
if (searchable.includes(metadata.propertyName)) {
|
|
88
|
+
const searchableType = (0, decorators_1.getIsSearchable)(cls, metadata.propertyName);
|
|
89
|
+
if (searchableType) {
|
|
90
|
+
yield [metadata.propertyName, searchableType];
|
|
91
|
+
}
|
|
92
|
+
else if (metadata.name === "isNumber") {
|
|
93
|
+
yield [metadata.propertyName, "number"];
|
|
94
|
+
}
|
|
95
|
+
else if (metadata.name === "isString") {
|
|
96
|
+
yield [metadata.propertyName, "string"];
|
|
97
|
+
}
|
|
98
|
+
else if (metadata.name === "isBoolean") {
|
|
99
|
+
yield [metadata.propertyName, "boolean"];
|
|
100
|
+
}
|
|
101
|
+
else if (metadata.name === "isLatLon") {
|
|
102
|
+
yield [metadata.propertyName, "geopoint"];
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
else if (metadata.type === "nestedValidation") {
|
|
84
106
|
for (const transform of (0, classValidation_1.getClassTransformerRules)(cls)) {
|
|
85
107
|
if (transform.typeFunction) {
|
|
86
108
|
const t = transform.typeFunction();
|
|
@@ -90,14 +112,6 @@ function* getTypes(cls) {
|
|
|
90
112
|
}
|
|
91
113
|
}
|
|
92
114
|
}
|
|
93
|
-
else if (searchable.includes(metadata.propertyName)) {
|
|
94
|
-
if (metadata.name === "isNumber") {
|
|
95
|
-
yield [metadata.propertyName, "number"];
|
|
96
|
-
}
|
|
97
|
-
else if (metadata.name === "isString") {
|
|
98
|
-
yield [metadata.propertyName, "string"];
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
115
|
}
|
|
102
116
|
}
|
|
103
117
|
function createSearchProjectionsHandler(projectionClass) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"searchProjectionsHandler.js","sourceRoot":"","sources":["../../../../src/handlers/crud/searchProjectionsHandler.ts"],"names":[],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"searchProjectionsHandler.js","sourceRoot":"","sources":["../../../../src/handlers/crud/searchProjectionsHandler.ts"],"names":[],"mappings":";;;;;;;;;;;;AAmCA,kDA8BC;AA6DD,wEAkFC;AAhND,yDAA2D;AAC3D,iDAAsD;AACtD,+EAA8D;AAC9D,qDAOyB;AACzB,kFAA4E;AAC5E,6CAAkE;AAClE,uCAAqD;AACrD,oFAGwD;AACxD,qEAA+D;AAC/D,+EAAoE;AACpE,4DAAqE;AAErE,mCAMiB;AAEjB,MAAa,aAAa;CAGzB;AAHD,sCAGC;AAED,SAAgB,mBAAmB,CACjC,eAAoC;IAEpC,MAAM,OAAQ,SAAQ,wBAAgB;KAwBrC;IArBC;QAFC,IAAA,gCAAc,GAAE;QAChB,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,IAAA,wBAAc,EAAC,eAAe,CAAC,CAAC;;0CAClB;IAI1B;QAFC,IAAA,uBAAK,GAAE;QACP,IAAA,4BAAU,GAAE;;0CACE;IAKf;QAHC,IAAA,uBAAK,GAAE;QACP,IAAA,qBAAG,EAAC,CAAC,EAAE,EAAE,OAAO,EAAE,4BAA4B,EAAE,CAAC;QACjD,IAAA,4BAAU,GAAE;;yCACC;IAId;QAFC,IAAA,4BAAU,GAAE;QACZ,IAAA,0BAAQ,GAAE;;sDACgB;IAG3B;QADC,IAAA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BAC7D,CAAC;gBACH,CAAC;qBAAM,CAAC;oBACN,MAAM,GAAG,CAAC;gBACZ,CAAC;YACH,CAAC;QACH,CAAC,CAAC;QACF,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,MAAM,mBAAmB,EAAE,CAAC;QAC9D,OAAO;YACL,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC;YAChD,iBAAiB,EAAE,YAAY;SAChC,CAAC;IACJ,CAAC,EACD,IAAI,EACJ,KAAK;QAGH,kBAAkB,GAAG,MAAM,CAAC,WAAW,CACrC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC;YAC1D,WAAW,IAAI,EAAE;YACjB,IAAI;SACL,CAAC,CACH,CAAC;QACF,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,cAAc,EAAE,CAAC,CAAC;QACtD,MAAM,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,cAAc,EAAE;YACnD,EAAE,EAAE,IAAI;YACR,GAAG,kBAAkB;SACtB,CAAC,CAAC;IACL,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export type CrudAction = "create" | "get" | "update" | "delete" | "search";
|
|
2
|
+
export type Projection = {
|
|
3
|
+
id: string;
|
|
4
|
+
};
|
|
5
|
+
export declare class ProjectionId {
|
|
6
|
+
id: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class CompanyIdRequest {
|
|
9
|
+
companyId: number;
|
|
10
|
+
}
|
|
11
|
+
export type SortParameters<T extends object> = {
|
|
12
|
+
[P in keyof T]?: T[P] extends object ? SortParameters<T[P]> : "asc" | "desc";
|
|
13
|
+
};
|
|
14
|
+
export type DistanceUnits = "miles" | "yards" | "feet" | "kilometers" | "meters";
|
|
15
|
+
export declare const DISTANCE_UNITS: DistanceUnits[];
|
|
16
|
+
export type Geopoint = {
|
|
17
|
+
lat: number;
|
|
18
|
+
lon: number;
|
|
19
|
+
};
|
|
20
|
+
export type GeopointQuery = {
|
|
21
|
+
distance: number;
|
|
22
|
+
units: DistanceUnits;
|
|
23
|
+
lat: number;
|
|
24
|
+
lon: number;
|
|
25
|
+
} | {
|
|
26
|
+
top: number;
|
|
27
|
+
left: number;
|
|
28
|
+
bottom: number;
|
|
29
|
+
right: number;
|
|
30
|
+
};
|
|
31
|
+
export type LegalGeopointNames = "latLon" | "latLong";
|
|
32
|
+
export type SearchRequest<T extends Projection> = CompanyIdRequest & {
|
|
33
|
+
query: DeepSearchable<T>;
|
|
34
|
+
limit?: number;
|
|
35
|
+
continuationToken?: string;
|
|
36
|
+
page?: number;
|
|
37
|
+
sort?: SortParameters<T>;
|
|
38
|
+
pointInTime?: boolean;
|
|
39
|
+
};
|
|
40
|
+
export type DeepSearchable<T extends object> = {
|
|
41
|
+
[P in keyof T]?: Geopoint extends T[P] ? GeopointQuery : T[P] extends LegalGeopointNames ? GeopointQuery : T[P] extends object ? DeepSearchable<T[P]> : T[P];
|
|
42
|
+
};
|
|
43
|
+
export declare class LatLon {
|
|
44
|
+
lat: number;
|
|
45
|
+
lon: number;
|
|
46
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.LatLon = exports.DISTANCE_UNITS = exports.CompanyIdRequest = exports.ProjectionId = void 0;
|
|
13
|
+
const class_validator_1 = require("class-validator");
|
|
14
|
+
class ProjectionId {
|
|
15
|
+
}
|
|
16
|
+
exports.ProjectionId = ProjectionId;
|
|
17
|
+
class CompanyIdRequest {
|
|
18
|
+
}
|
|
19
|
+
exports.CompanyIdRequest = CompanyIdRequest;
|
|
20
|
+
__decorate([
|
|
21
|
+
(0, class_validator_1.IsNumber)(),
|
|
22
|
+
__metadata("design:type", Number)
|
|
23
|
+
], CompanyIdRequest.prototype, "companyId", void 0);
|
|
24
|
+
exports.DISTANCE_UNITS = [
|
|
25
|
+
"miles",
|
|
26
|
+
"yards",
|
|
27
|
+
"feet",
|
|
28
|
+
"meters",
|
|
29
|
+
"kilometers",
|
|
30
|
+
];
|
|
31
|
+
class LatLon {
|
|
32
|
+
}
|
|
33
|
+
exports.LatLon = LatLon;
|
|
34
|
+
__decorate([
|
|
35
|
+
(0, class_validator_1.IsNumber)(),
|
|
36
|
+
__metadata("design:type", Number)
|
|
37
|
+
], LatLon.prototype, "lat", void 0);
|
|
38
|
+
__decorate([
|
|
39
|
+
(0, class_validator_1.IsNumber)(),
|
|
40
|
+
__metadata("design:type", Number)
|
|
41
|
+
], LatLon.prototype, "lon", void 0);
|
|
42
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/handlers/crud/types.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAA2C;AAQ3C,MAAa,YAAY;CAExB;AAFD,oCAEC;AAED,MAAa,gBAAgB;CAG5B;AAHD,4CAGC;AADC;IADC,IAAA,0BAAQ,GAAE;;mDACQ;AAcR,QAAA,cAAc,GAAoB;IAC7C,OAAO;IACP,OAAO;IACP,MAAM;IACN,QAAQ;IACR,YAAY;CACb,CAAC;AAyCF,MAAa,MAAM;CAMlB;AAND,wBAMC;AAJC;IADC,IAAA,0BAAQ,GAAE;;mCACE;AAGb;IADC,IAAA,0BAAQ,GAAE;;mCACE"}
|
|
@@ -25,3 +25,4 @@ export declare function findLast<T extends Record<string, any>>(item: T, fieldPa
|
|
|
25
25
|
export declare function removeField<T extends Record<string, any>>(item: T, fieldPath: string): T;
|
|
26
26
|
export declare function deepApply<T extends Record<string, any>, U extends Record<string, any>>(item: T, fields: U): T & U;
|
|
27
27
|
export declare function flatten<T>(items: Record<string, any>): Record<string, T>;
|
|
28
|
+
export declare function findDeep<T>(items: Record<string, any>, path: string): T | undefined;
|
|
@@ -7,6 +7,7 @@ exports.findLast = findLast;
|
|
|
7
7
|
exports.removeField = removeField;
|
|
8
8
|
exports.deepApply = deepApply;
|
|
9
9
|
exports.flatten = flatten;
|
|
10
|
+
exports.findDeep = findDeep;
|
|
10
11
|
const lodash_1 = require("lodash");
|
|
11
12
|
function deepDiff(a, b, on, path) {
|
|
12
13
|
const aKeys = Object.keys(a).filter((key) => typeof key === "string");
|
|
@@ -151,4 +152,20 @@ function* generateFlat(items) {
|
|
|
151
152
|
function flatten(items) {
|
|
152
153
|
return Object.fromEntries(generateFlat(items));
|
|
153
154
|
}
|
|
155
|
+
function findDeep(items, path) {
|
|
156
|
+
if (path.length === 0) {
|
|
157
|
+
return items;
|
|
158
|
+
}
|
|
159
|
+
if (items === undefined) {
|
|
160
|
+
console.log("no value to recurse");
|
|
161
|
+
return items;
|
|
162
|
+
}
|
|
163
|
+
const seperatorIndex = path.indexOf(".");
|
|
164
|
+
if (seperatorIndex === -1) {
|
|
165
|
+
return items[path];
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
return findDeep(items[path.slice(0, seperatorIndex)], path.slice(seperatorIndex + 1));
|
|
169
|
+
}
|
|
170
|
+
}
|
|
154
171
|
//# sourceMappingURL=dataStructure.helpers.js.map
|