@bringg/dashboard-sdk 0.5.7 → 0.5.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bringg/dashboard-sdk",
3
- "version": "0.5.7",
3
+ "version": "0.5.8",
4
4
  "description": "Bringg dashboard SDK",
5
5
  "main": "dist/bringg-dashboard-sdk.js",
6
6
  "typings": "dist/index.d.ts",
@@ -1,19 +0,0 @@
1
- export declare const processorsMetadataKey: unique symbol;
2
- export declare class ArgValidator {
3
- validator: (any: any) => void;
4
- constructor(argProcessor: (any: any) => void);
5
- process(argument: any): any;
6
- }
7
- export declare class ArgModifier {
8
- modifier: (object: any) => {};
9
- constructor(modifier: (object: any) => {});
10
- process(argument: any): {};
11
- }
12
- export declare function processArguments(target: any, functionName: string, descriptor: TypedPropertyDescriptor<Function>): void;
13
- export declare const createArgProcessingDecorator: (argProcessor: ArgValidator | ArgModifier) => (target: any, functionName: string, parameterIndex: number) => void;
14
- export declare const getValidationFunctionFromKeys: (allowedKeys: string[]) => (arg: {}) => void;
15
- export declare const getRequiredValidationFunctionFromKeys: (requiredKeys: string[]) => (arg: {}) => void;
16
- export declare const allowedKeys: (keys: string[]) => (target: any, functionName: string, parameterIndex: number) => void;
17
- export declare const requiredKeys: (keys: string[]) => (target: any, functionName: string, parameterIndex: number) => void;
18
- export declare const getArgSanitizeFromKeys: (keys: string[]) => (arg: {}) => Partial<{}>;
19
- export declare const sanitize: (keys: string[]) => (target: any, functionName: string, parameterIndex: number) => void;
@@ -1,114 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sanitize = exports.getArgSanitizeFromKeys = exports.requiredKeys = exports.allowedKeys = exports.getRequiredValidationFunctionFromKeys = exports.getValidationFunctionFromKeys = exports.createArgProcessingDecorator = exports.processArguments = exports.ArgModifier = exports.ArgValidator = exports.processorsMetadataKey = void 0;
4
- var BringgException_1 = require("./BringgException");
5
- var ExceptionReason_1 = require("./ExceptionReason");
6
- var lodash_1 = require("lodash");
7
- exports.processorsMetadataKey = Symbol('validations');
8
- var ArgValidator = /** @class */ (function () {
9
- function ArgValidator(argProcessor) {
10
- this.validator = argProcessor;
11
- }
12
- ArgValidator.prototype.process = function (argument) {
13
- var clone = lodash_1.cloneDeep(argument);
14
- this.validator(clone);
15
- return argument;
16
- };
17
- return ArgValidator;
18
- }());
19
- exports.ArgValidator = ArgValidator;
20
- var ArgModifier = /** @class */ (function () {
21
- function ArgModifier(modifier) {
22
- this.modifier = modifier;
23
- }
24
- ArgModifier.prototype.process = function (argument) {
25
- return this.modifier(argument);
26
- };
27
- return ArgModifier;
28
- }());
29
- exports.ArgModifier = ArgModifier;
30
- var ensureMetadataSlotExists = function (target, functionName) {
31
- if (!target[exports.processorsMetadataKey]) {
32
- target[exports.processorsMetadataKey] = {};
33
- }
34
- if (!target[exports.processorsMetadataKey][functionName]) {
35
- target[exports.processorsMetadataKey][functionName] = [];
36
- }
37
- };
38
- var ensureProcessorsWereRegistered = function (target, functionName) {
39
- ensureMetadataSlotExists(target, functionName);
40
- if (target[exports.processorsMetadataKey][functionName].length === 0) {
41
- throw new BringgException_1.BringgException(ExceptionReason_1.ExceptionReason.ILLEGAL_STATE, function () { return "No validators were used on " + functionName + " arguments"; });
42
- }
43
- };
44
- function processArguments(target, functionName, descriptor) {
45
- ensureProcessorsWereRegistered(target, functionName);
46
- var originalMethod = target[functionName];
47
- descriptor.value = function () {
48
- var args = [];
49
- for (var _i = 0; _i < arguments.length; _i++) {
50
- args[_i] = arguments[_i];
51
- }
52
- target[exports.processorsMetadataKey][functionName].forEach(function (_a) {
53
- var parameterIndex = _a.parameterIndex, argProcessor = _a.argProcessor;
54
- args[parameterIndex] = argProcessor.process(args[parameterIndex]);
55
- });
56
- return originalMethod.apply(this, args);
57
- };
58
- }
59
- exports.processArguments = processArguments;
60
- var createArgProcessingDecorator = function (argProcessor) {
61
- return function (target, functionName, parameterIndex) {
62
- ensureMetadataSlotExists(target, functionName);
63
- target[exports.processorsMetadataKey][functionName].push({ parameterIndex: parameterIndex, argProcessor: argProcessor });
64
- };
65
- };
66
- exports.createArgProcessingDecorator = createArgProcessingDecorator;
67
- // Validators
68
- var getValidationFunctionFromKeys = function (allowedKeys) {
69
- var setKeys = new Set(allowedKeys);
70
- return function (arg) {
71
- var nonValidKeys = [];
72
- Object.keys(arg).forEach(function (key) {
73
- if (!setKeys.has(key)) {
74
- nonValidKeys.push(key);
75
- }
76
- });
77
- if (nonValidKeys.length > 0) {
78
- throw new BringgException_1.BringgException(ExceptionReason_1.ExceptionReason.INVALID_ARGUMENTS, function () { return "Not allowed parameters: " + nonValidKeys.toString(); });
79
- }
80
- };
81
- };
82
- exports.getValidationFunctionFromKeys = getValidationFunctionFromKeys;
83
- var getRequiredValidationFunctionFromKeys = function (requiredKeys) {
84
- return function (arg) {
85
- var missingKeys = [];
86
- requiredKeys.forEach(function (key) {
87
- if (!lodash_1.has(arg, key)) {
88
- missingKeys.push(key);
89
- }
90
- });
91
- if (missingKeys.length > 0) {
92
- throw new BringgException_1.BringgException(ExceptionReason_1.ExceptionReason.INVALID_ARGUMENTS, function () { return "Missing keys: " + missingKeys.toString(); });
93
- }
94
- };
95
- };
96
- exports.getRequiredValidationFunctionFromKeys = getRequiredValidationFunctionFromKeys;
97
- var allowedKeys = function (keys) {
98
- return exports.createArgProcessingDecorator(new ArgValidator(exports.getValidationFunctionFromKeys(keys)));
99
- };
100
- exports.allowedKeys = allowedKeys;
101
- var requiredKeys = function (keys) {
102
- return exports.createArgProcessingDecorator(new ArgValidator(exports.getRequiredValidationFunctionFromKeys(keys)));
103
- };
104
- exports.requiredKeys = requiredKeys;
105
- // Modifiers
106
- var getArgSanitizeFromKeys = function (keys) {
107
- return function (arg) {
108
- return lodash_1.pick(arg, keys);
109
- };
110
- };
111
- exports.getArgSanitizeFromKeys = getArgSanitizeFromKeys;
112
- var sanitize = function (keys) { return exports.createArgProcessingDecorator(new ArgModifier(exports.getArgSanitizeFromKeys(keys))); };
113
- exports.sanitize = sanitize;
114
- //# sourceMappingURL=MethodsArgsDecorators.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MethodsArgsDecorators.js","sourceRoot":"","sources":["../../src/Core/MethodsArgsDecorators.ts"],"names":[],"mappings":";;;AAAA,qDAAoD;AACpD,qDAAoD;AACpD,iCAA8C;AAEjC,QAAA,qBAAqB,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC;AAE3D;IAEC,sBAAY,YAA2B;QACtC,IAAI,CAAC,SAAS,GAAG,YAAY,CAAC;IAC/B,CAAC;IAEM,8BAAO,GAAd,UAAe,QAAQ;QACtB,IAAM,KAAK,GAAG,kBAAS,CAAC,QAAQ,CAAC,CAAC;QAClC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACtB,OAAO,QAAQ,CAAC;IACjB,CAAC;IACF,mBAAC;AAAD,CAAC,AAXD,IAWC;AAXY,oCAAY;AAazB;IAEC,qBAAY,QAAwB;QACnC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC1B,CAAC;IACM,6BAAO,GAAd,UAAe,QAAQ;QACtB,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAChC,CAAC;IACF,kBAAC;AAAD,CAAC,AARD,IAQC;AARY,kCAAW;AAUxB,IAAM,wBAAwB,GAAG,UAAC,MAAU,EAAE,YAAoB;IACjE,IAAI,CAAC,MAAM,CAAC,6BAAqB,CAAC,EAAE;QACnC,MAAM,CAAC,6BAAqB,CAAC,GAAG,EAAE,CAAC;KACnC;IACD,IAAI,CAAC,MAAM,CAAC,6BAAqB,CAAC,CAAC,YAAY,CAAC,EAAE;QACjD,MAAM,CAAC,6BAAqB,CAAC,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC;KACjD;AACF,CAAC,CAAC;AAEF,IAAM,8BAA8B,GAAG,UAAC,MAAU,EAAE,YAA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