@frontegg/entitlements-javascript-commons 1.0.0-alpha.1 → 1.0.0-alpha.10
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/.github/workflows/publish.yaml +1 -1
- package/.releaserc.yaml +2 -2
- package/dist/conditions/condition.evaluator.d.ts +6 -0
- package/dist/conditions/condition.evaluator.js +27 -0
- package/dist/conditions/condition.evaluator.js.map +1 -0
- package/dist/conditions/index.d.ts +2 -0
- package/dist/conditions/index.js +19 -0
- package/dist/conditions/index.js.map +1 -0
- package/dist/conditions/types.d.ts +7 -0
- package/dist/conditions/types.js +3 -0
- package/dist/conditions/types.js.map +1 -0
- package/dist/feature-flags/feature-flag.evaluator.d.ts +2 -0
- package/dist/feature-flags/feature-flag.evaluator.js +24 -0
- package/dist/feature-flags/feature-flag.evaluator.js.map +1 -0
- package/dist/feature-flags/index.d.ts +2 -0
- package/dist/feature-flags/index.js +18 -0
- package/dist/feature-flags/index.js.map +1 -0
- package/dist/feature-flags/types.d.ts +10 -0
- package/dist/feature-flags/types.js +3 -0
- package/dist/feature-flags/types.js.map +1 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.js +11 -5
- package/dist/index.js.map +1 -1
- package/dist/operations/boolean/index.d.ts +4 -0
- package/dist/operations/boolean/index.js +25 -0
- package/dist/operations/boolean/index.js.map +1 -0
- package/dist/operations/boolean/operations.d.ts +3 -0
- package/dist/operations/boolean/operations.js +8 -0
- package/dist/operations/boolean/operations.js.map +1 -0
- package/dist/operations/boolean/sanitizers.d.ts +4 -0
- package/dist/operations/boolean/sanitizers.js +17 -0
- package/dist/operations/boolean/sanitizers.js.map +1 -0
- package/dist/operations/boolean/types.d.ts +3 -0
- package/dist/operations/boolean/types.js +3 -0
- package/dist/operations/boolean/types.js.map +1 -0
- package/dist/operations/components/operation.resolver.d.ts +2 -0
- package/dist/operations/components/operation.resolver.js +19 -0
- package/dist/operations/components/operation.resolver.js.map +1 -0
- package/dist/operations/components/sanitizers.resolver.d.ts +2 -0
- package/dist/operations/components/sanitizers.resolver.js +18 -0
- package/dist/operations/components/sanitizers.resolver.js.map +1 -0
- package/dist/operations/date/index.d.ts +4 -0
- package/dist/operations/date/index.js +28 -0
- package/dist/operations/date/index.js.map +1 -0
- package/dist/operations/date/operations.d.ts +6 -0
- package/dist/operations/date/operations.js +22 -0
- package/dist/operations/date/operations.js.map +1 -0
- package/dist/operations/date/sanitizers.d.ts +5 -0
- package/dist/operations/date/sanitizers.js +27 -0
- package/dist/operations/date/sanitizers.js.map +1 -0
- package/dist/operations/date/types.d.ts +8 -0
- package/dist/operations/date/types.js +3 -0
- package/dist/operations/date/types.js.map +1 -0
- package/dist/operations/numeric/index.d.ts +5 -0
- package/dist/operations/numeric/index.js +31 -0
- package/dist/operations/numeric/index.js.map +1 -0
- package/dist/operations/numeric/operations.d.ts +8 -0
- package/dist/operations/numeric/operations.js +28 -0
- package/dist/operations/numeric/operations.js.map +1 -0
- package/dist/operations/numeric/sanitizers.d.ts +5 -0
- package/dist/operations/numeric/sanitizers.js +32 -0
- package/dist/operations/numeric/sanitizers.js.map +1 -0
- package/dist/operations/numeric/types.d.ts +8 -0
- package/dist/operations/numeric/types.js +3 -0
- package/dist/operations/numeric/types.js.map +1 -0
- package/dist/operations/string/index.d.ts +4 -0
- package/dist/operations/string/index.js +29 -0
- package/dist/operations/string/index.js.map +1 -0
- package/dist/operations/string/operations.d.ts +7 -0
- package/dist/operations/string/operations.js +33 -0
- package/dist/operations/string/operations.js.map +1 -0
- package/dist/operations/string/sanitizers.d.ts +5 -0
- package/dist/operations/string/sanitizers.js +31 -0
- package/dist/operations/string/sanitizers.js.map +1 -0
- package/dist/operations/string/types.d.ts +7 -0
- package/dist/operations/string/types.js +3 -0
- package/dist/operations/string/types.js.map +1 -0
- package/dist/operations/types/index.d.ts +24 -0
- package/dist/operations/types/index.js +18 -0
- package/dist/operations/types/index.js.map +1 -0
- package/dist/operations/types/operation.enum.d.ts +18 -0
- package/dist/operations/types/operation.enum.js +27 -0
- package/dist/operations/types/operation.enum.js.map +1 -0
- package/dist/rules/index.d.ts +2 -0
- package/dist/rules/index.js +19 -0
- package/dist/rules/index.js.map +1 -0
- package/dist/rules/rule.evaluator.d.ts +2 -0
- package/dist/rules/rule.evaluator.js +16 -0
- package/dist/rules/rule.evaluator.js.map +1 -0
- package/dist/rules/types.d.ts +21 -0
- package/dist/rules/types.js +18 -0
- package/dist/rules/types.js.map +1 -0
- package/dist/user-entitlements/index.d.ts +2 -0
- package/dist/user-entitlements/index.js +19 -0
- package/dist/user-entitlements/index.js.map +1 -0
- package/dist/user-entitlements/is-entitled.evaluator.d.ts +11 -0
- package/dist/user-entitlements/is-entitled.evaluator.js +75 -0
- package/dist/user-entitlements/is-entitled.evaluator.js.map +1 -0
- package/dist/user-entitlements/types.d.ts +31 -0
- package/dist/user-entitlements/types.js +11 -0
- package/dist/user-entitlements/types.js.map +1 -0
- package/docs/CHANGELOG.md +68 -0
- package/jest.config.js +26 -0
- package/package.json +2 -2
- package/src/conditions/condition.evaluator.ts +35 -0
- package/src/conditions/index.ts +2 -0
- package/src/conditions/tests/condition.evaluator.spec.ts +52 -0
- package/src/conditions/types.ts +8 -0
- package/src/feature-flags/feature-flag.evaluator.ts +27 -0
- package/src/feature-flags/index.ts +2 -0
- package/src/feature-flags/tests/feature-flag.evaluator.spec.ts +176 -0
- package/src/feature-flags/types.ts +12 -0
- package/src/index.ts +14 -3
- package/src/operations/boolean/index.ts +10 -0
- package/src/operations/boolean/operations.ts +6 -0
- package/src/operations/boolean/sanitizers.ts +18 -0
- package/src/operations/boolean/tests/operations.spec.ts +13 -0
- package/src/operations/boolean/tests/sanitizers.spec.ts +22 -0
- package/src/operations/boolean/types.ts +3 -0
- package/src/operations/components/operation.resolver.ts +18 -0
- package/src/operations/components/sanitizers.resolver.ts +16 -0
- package/src/operations/components/tests/operation.resolver.spec.ts +8 -0
- package/src/operations/components/tests/sanitizers.resolver.spec.ts +14 -0
- package/src/operations/date/index.ts +18 -0
- package/src/operations/date/operations.ts +20 -0
- package/src/operations/date/sanitizers.ts +27 -0
- package/src/operations/date/tests/operations.spec.ts +45 -0
- package/src/operations/date/tests/sanitizers.spec.ts +43 -0
- package/src/operations/date/types.ts +10 -0
- package/src/operations/numeric/index.ts +23 -0
- package/src/operations/numeric/operations.ts +26 -0
- package/src/operations/numeric/sanitizers.ts +34 -0
- package/src/operations/numeric/tests/operations.spec.ts +64 -0
- package/src/operations/numeric/tests/sanitizers.spec.ts +44 -0
- package/src/operations/numeric/types.ts +10 -0
- package/src/operations/string/index.ts +20 -0
- package/src/operations/string/operations.ts +32 -0
- package/src/operations/string/sanitizers.ts +33 -0
- package/src/operations/string/tests/operations.spec.ts +38 -0
- package/src/operations/string/tests/sanitizers.spec.ts +45 -0
- package/src/operations/string/types.ts +9 -0
- package/src/operations/types/index.ts +30 -0
- package/src/operations/types/operation.enum.ts +25 -0
- package/src/rules/index.ts +2 -0
- package/src/rules/rule.evaluator.ts +14 -0
- package/src/rules/tests/rule.evaluator.spec.ts +135 -0
- package/src/rules/types.ts +27 -0
- package/src/user-entitlements/index.ts +2 -0
- package/src/user-entitlements/is-entitled.evaluator.ts +99 -0
- package/src/user-entitlements/tests/is-entitled.evaluator.spec.ts +315 -0
- package/src/user-entitlements/types.ts +37 -0
- package/src/index.spec.ts +0 -5
package/.releaserc.yaml
CHANGED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Condition } from './types';
|
|
2
|
+
export interface CreateConditionEvaluatorPayload {
|
|
3
|
+
condition: Condition;
|
|
4
|
+
}
|
|
5
|
+
export type ConditionEvaluator = (attributes: Record<string, unknown>) => boolean;
|
|
6
|
+
export declare function createConditionEvaluator(payload: CreateConditionEvaluatorPayload): ConditionEvaluator;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createConditionEvaluator = void 0;
|
|
4
|
+
const operation_resolver_1 = require("../operations/components/operation.resolver");
|
|
5
|
+
const sanitizers_resolver_1 = require("../operations/components/sanitizers.resolver");
|
|
6
|
+
function failingConditionEvaluator() {
|
|
7
|
+
return () => false;
|
|
8
|
+
}
|
|
9
|
+
function createConditionEvaluator(payload) {
|
|
10
|
+
const sanitizer = (0, sanitizers_resolver_1.useSanitizer)(payload.condition.op);
|
|
11
|
+
if (!sanitizer) {
|
|
12
|
+
return failingConditionEvaluator();
|
|
13
|
+
}
|
|
14
|
+
const { isSanitized, sanitizedValue } = sanitizer(payload.condition.value);
|
|
15
|
+
if (!isSanitized || sanitizedValue === undefined) {
|
|
16
|
+
return failingConditionEvaluator();
|
|
17
|
+
}
|
|
18
|
+
const operation = (0, operation_resolver_1.useOperation)(payload.condition.op, sanitizedValue);
|
|
19
|
+
return (attributes) => {
|
|
20
|
+
const attributeKey = payload.condition.attribute;
|
|
21
|
+
const value = attributes[attributeKey];
|
|
22
|
+
const { isValid: result } = value !== undefined && operation ? operation(value) : { isValid: false };
|
|
23
|
+
return payload.condition.negate ? !result : result;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
exports.createConditionEvaluator = createConditionEvaluator;
|
|
27
|
+
//# sourceMappingURL=condition.evaluator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"condition.evaluator.js","sourceRoot":"","sources":["../../src/conditions/condition.evaluator.ts"],"names":[],"mappings":";;;AACA,oFAA2E;AAC3E,sFAA4E;AAQ5E,SAAS,yBAAyB;IAChC,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC;AACrB,CAAC;AAED,SAAgB,wBAAwB,CAAC,OAAwC;IAC/E,MAAM,SAAS,GAAG,IAAA,kCAAY,EAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;IACrD,IAAI,CAAC,SAAS,EAAE;QACd,OAAO,yBAAyB,EAAE,CAAC;KACpC;IAED,MAAM,EAAE,WAAW,EAAE,cAAc,EAAE,GAAG,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC3E,IAAI,CAAC,WAAW,IAAI,cAAc,KAAK,SAAS,EAAE;QAChD,OAAO,yBAAyB,EAAE,CAAC;KACpC;IAED,MAAM,SAAS,GAAG,IAAA,iCAAY,EAAC,OAAO,CAAC,SAAS,CAAC,EAAE,EAAE,cAAc,CAAC,CAAC;IAErE,OAAO,CAAC,UAAmC,EAAE,EAAE;QAC7C,MAAM,YAAY,GAAG,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC;QACjD,MAAM,KAAK,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC;QACvC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,KAAK,KAAK,SAAS,IAAI,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;QAErG,OAAO,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;IACrD,CAAC,CAAC;AACJ,CAAC;AApBD,4DAoBC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./condition.evaluator"), exports);
|
|
18
|
+
__exportStar(require("./types"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/conditions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,0CAAwB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/conditions/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.evaluateFeatureFlag = void 0;
|
|
4
|
+
const rules_1 = require("../rules");
|
|
5
|
+
function evaluateFeatureFlag(featureFlag, attributes) {
|
|
6
|
+
if (!featureFlag.on) {
|
|
7
|
+
return { treatment: featureFlag.offTreatment };
|
|
8
|
+
}
|
|
9
|
+
const treatableRule = findTreatableRule(featureFlag, attributes);
|
|
10
|
+
if (treatableRule) {
|
|
11
|
+
return { treatment: treatableRule.treatment };
|
|
12
|
+
}
|
|
13
|
+
return { treatment: featureFlag.defaultTreatment };
|
|
14
|
+
}
|
|
15
|
+
exports.evaluateFeatureFlag = evaluateFeatureFlag;
|
|
16
|
+
function findTreatableRule(featureFlag, attributes) {
|
|
17
|
+
var _a;
|
|
18
|
+
return (_a = featureFlag.rules) === null || _a === void 0 ? void 0 : _a.find((rule) => {
|
|
19
|
+
const evaluator = (0, rules_1.createRuleEvaluator)({ rule });
|
|
20
|
+
const result = evaluator(attributes);
|
|
21
|
+
return result === rules_1.RuleEvaluationResultEnum.Treatable;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=feature-flag.evaluator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feature-flag.evaluator.js","sourceRoot":"","sources":["../../src/feature-flags/feature-flag.evaluator.ts"],"names":[],"mappings":";;;AACA,oCAA+E;AAE/E,SAAgB,mBAAmB,CACjC,WAAwB,EACxB,UAAmC;IAEnC,IAAI,CAAC,WAAW,CAAC,EAAE,EAAE;QACnB,OAAO,EAAE,SAAS,EAAE,WAAW,CAAC,YAAY,EAAE,CAAC;KAChD;IAED,MAAM,aAAa,GAAG,iBAAiB,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;IACjE,IAAI,aAAa,EAAE;QACjB,OAAO,EAAE,SAAS,EAAE,aAAa,CAAC,SAAS,EAAE,CAAC;KAC/C;IAED,OAAO,EAAE,SAAS,EAAE,WAAW,CAAC,gBAAgB,EAAE,CAAC;AACrD,CAAC;AAdD,kDAcC;AAED,SAAS,iBAAiB,CAAC,WAAwB,EAAE,UAAmC;;IACtF,OAAO,MAAA,WAAW,CAAC,KAAK,0CAAE,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;QACtC,MAAM,SAAS,GAAG,IAAA,2BAAmB,EAAC,EAAE,IAAI,EAAE,CAAC,CAAC;QAChD,MAAM,MAAM,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC;QAErC,OAAO,MAAM,KAAK,gCAAwB,CAAC,SAAS,CAAC;IACvD,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./feature-flag.evaluator"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/feature-flags/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2DAAyC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Rule, TreatmentEnum } from '../rules';
|
|
2
|
+
export interface FeatureFlag {
|
|
3
|
+
on: boolean;
|
|
4
|
+
offTreatment: TreatmentEnum;
|
|
5
|
+
defaultTreatment: TreatmentEnum;
|
|
6
|
+
rules?: Rule[];
|
|
7
|
+
}
|
|
8
|
+
export interface FeatureFlagEvaluationResult {
|
|
9
|
+
treatment: TreatmentEnum;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/feature-flags/types.ts"],"names":[],"mappings":""}
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1,5 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { FeatureFlagEvaluationResult, FeatureFlag, evaluateFeatureFlag } from './feature-flags';
|
|
2
|
+
export { TreatmentEnum, Rule } from './rules';
|
|
3
|
+
export { Condition } from './conditions';
|
|
4
|
+
export { OperationEnum, ConditionValue } from './operations/types';
|
|
5
|
+
export { evaluateIsEntitledToFeature, evaluateIsEntitledToPermissions, CustomAttributes, FronteggAttributes, NotEntitledJustification, UserEntitlementsContext, EntitlementResult, Attributes, } from './user-entitlements';
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.evaluateFeatureFlag = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
exports.
|
|
3
|
+
exports.NotEntitledJustification = exports.evaluateIsEntitledToPermissions = exports.evaluateIsEntitledToFeature = exports.OperationEnum = exports.TreatmentEnum = exports.evaluateFeatureFlag = void 0;
|
|
4
|
+
var feature_flags_1 = require("./feature-flags");
|
|
5
|
+
Object.defineProperty(exports, "evaluateFeatureFlag", { enumerable: true, get: function () { return feature_flags_1.evaluateFeatureFlag; } });
|
|
6
|
+
var rules_1 = require("./rules");
|
|
7
|
+
Object.defineProperty(exports, "TreatmentEnum", { enumerable: true, get: function () { return rules_1.TreatmentEnum; } });
|
|
8
|
+
var types_1 = require("./operations/types");
|
|
9
|
+
Object.defineProperty(exports, "OperationEnum", { enumerable: true, get: function () { return types_1.OperationEnum; } });
|
|
10
|
+
var user_entitlements_1 = require("./user-entitlements");
|
|
11
|
+
Object.defineProperty(exports, "evaluateIsEntitledToFeature", { enumerable: true, get: function () { return user_entitlements_1.evaluateIsEntitledToFeature; } });
|
|
12
|
+
Object.defineProperty(exports, "evaluateIsEntitledToPermissions", { enumerable: true, get: function () { return user_entitlements_1.evaluateIsEntitledToPermissions; } });
|
|
13
|
+
Object.defineProperty(exports, "NotEntitledJustification", { enumerable: true, get: function () { return user_entitlements_1.NotEntitledJustification; } });
|
|
8
14
|
//# sourceMappingURL=index.js.map
|
package/dist/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,iDAAgG;AAA7C,oHAAA,mBAAmB,OAAA;AACtE,iCAA8C;AAArC,sGAAA,aAAa,OAAA;AAEtB,4CAAmE;AAA1D,sGAAA,aAAa,OAAA;AACtB,yDAS6B;AAR3B,gIAAA,2BAA2B,OAAA;AAC3B,oIAAA,+BAA+B,OAAA;AAG/B,6HAAA,wBAAwB,OAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.BooleanOperationsMapper = void 0;
|
|
18
|
+
const types_1 = require("../types");
|
|
19
|
+
const operations_1 = require("./operations");
|
|
20
|
+
__exportStar(require("./operations"), exports);
|
|
21
|
+
__exportStar(require("./sanitizers"), exports);
|
|
22
|
+
exports.BooleanOperationsMapper = {
|
|
23
|
+
[types_1.OperationEnum.Is]: (value) => (0, operations_1.useIsOperation)(value),
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/operations/boolean/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,oCAA2D;AAC3D,6CAA8C;AAG9C,+CAA6B;AAC7B,+CAA6B;AAEhB,QAAA,uBAAuB,GAAqB;IACvD,CAAC,qBAAa,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,2BAAc,EAAC,KAAgC,CAAC;CAChF,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useIsOperation = void 0;
|
|
4
|
+
function useIsOperation(payload) {
|
|
5
|
+
return (attribute) => ({ isValid: attribute === payload.boolean });
|
|
6
|
+
}
|
|
7
|
+
exports.useIsOperation = useIsOperation;
|
|
8
|
+
//# sourceMappingURL=operations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations.js","sourceRoot":"","sources":["../../../src/operations/boolean/operations.ts"],"names":[],"mappings":";;;AAGA,SAAgB,cAAc,CAAC,OAAgC;IAC7D,OAAO,CAAC,SAAkB,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,SAAS,KAAK,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;AAC9E,CAAC;AAFD,wCAEC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Sanitizer, SanitizersMapper } from '../types';
|
|
2
|
+
import { BooleanOperationPayload } from './types';
|
|
3
|
+
export declare const singleBooleanSanitizer: Sanitizer<BooleanOperationPayload>;
|
|
4
|
+
export declare const BooleanSanitizersMapper: SanitizersMapper<BooleanOperationPayload>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BooleanSanitizersMapper = exports.singleBooleanSanitizer = void 0;
|
|
4
|
+
const types_1 = require("../types");
|
|
5
|
+
const isBoolean = (value) => typeof value === 'boolean';
|
|
6
|
+
const singleBooleanSanitizer = (value) => {
|
|
7
|
+
const sanitizedValue = value.boolean !== undefined && isBoolean(value.boolean) ? { boolean: value.boolean } : undefined;
|
|
8
|
+
return {
|
|
9
|
+
isSanitized: !!sanitizedValue,
|
|
10
|
+
sanitizedValue,
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
exports.singleBooleanSanitizer = singleBooleanSanitizer;
|
|
14
|
+
exports.BooleanSanitizersMapper = {
|
|
15
|
+
[types_1.OperationEnum.Is]: exports.singleBooleanSanitizer,
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=sanitizers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sanitizers.js","sourceRoot":"","sources":["../../../src/operations/boolean/sanitizers.ts"],"names":[],"mappings":";;;AAAA,oCAAyF;AAGzF,MAAM,SAAS,GAAG,CAAC,KAAc,EAAoB,EAAE,CAAC,OAAO,KAAK,KAAK,SAAS,CAAC;AAE5E,MAAM,sBAAsB,GAAuC,CAAC,KAAwB,EAAE,EAAE;IACrG,MAAM,cAAc,GAClB,KAAK,CAAC,OAAO,KAAK,SAAS,IAAI,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IAEnG,OAAO;QACL,WAAW,EAAE,CAAC,CAAC,cAAc;QAC7B,cAAc;KACf,CAAC;AACJ,CAAC,CAAC;AARW,QAAA,sBAAsB,0BAQjC;AAEW,QAAA,uBAAuB,GAA8C;IAChF,CAAC,qBAAa,CAAC,EAAE,CAAC,EAAE,8BAAsB;CAC3C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/operations/boolean/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useOperation = void 0;
|
|
4
|
+
const string_1 = require("../string");
|
|
5
|
+
const numeric_1 = require("../numeric");
|
|
6
|
+
const date_1 = require("../date");
|
|
7
|
+
const boolean_1 = require("../boolean");
|
|
8
|
+
const operationEnrichersMapper = {
|
|
9
|
+
...string_1.StringOperationsMapper,
|
|
10
|
+
...numeric_1.NumericOperationsMapper,
|
|
11
|
+
...date_1.DateOperationsMapper,
|
|
12
|
+
...boolean_1.BooleanOperationsMapper,
|
|
13
|
+
};
|
|
14
|
+
function useOperation(operation, value) {
|
|
15
|
+
const operationContextEnricher = operationEnrichersMapper[operation];
|
|
16
|
+
return operationContextEnricher ? operationContextEnricher(value) : undefined;
|
|
17
|
+
}
|
|
18
|
+
exports.useOperation = useOperation;
|
|
19
|
+
//# sourceMappingURL=operation.resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operation.resolver.js","sourceRoot":"","sources":["../../../src/operations/components/operation.resolver.ts"],"names":[],"mappings":";;;AACA,sCAAmD;AACnD,wCAAqD;AACrD,kCAA+C;AAC/C,wCAAqD;AAErD,MAAM,wBAAwB,GAAqB;IACjD,GAAG,+BAAsB;IACzB,GAAG,iCAAuB;IAC1B,GAAG,2BAAoB;IACvB,GAAG,iCAAuB;CAC3B,CAAC;AAEF,SAAgB,YAAY,CAAC,SAAwB,EAAE,KAAqB;IAC1E,MAAM,wBAAwB,GAAG,wBAAwB,CAAC,SAAS,CAAC,CAAC;IAErE,OAAO,wBAAwB,CAAC,CAAC,CAAC,wBAAwB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAChF,CAAC;AAJD,oCAIC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useSanitizer = void 0;
|
|
4
|
+
const boolean_1 = require("../boolean");
|
|
5
|
+
const sanitizers_1 = require("../string/sanitizers");
|
|
6
|
+
const sanitizers_2 = require("../date/sanitizers");
|
|
7
|
+
const numeric_1 = require("../numeric");
|
|
8
|
+
const SanitizersMapper = {
|
|
9
|
+
...sanitizers_1.StringSanitizersMapper,
|
|
10
|
+
...numeric_1.NumericSanitizersMapper,
|
|
11
|
+
...sanitizers_2.DateSanitizersMapper,
|
|
12
|
+
...boolean_1.BooleanSanitizersMapper,
|
|
13
|
+
};
|
|
14
|
+
function useSanitizer(operation) {
|
|
15
|
+
return SanitizersMapper[operation];
|
|
16
|
+
}
|
|
17
|
+
exports.useSanitizer = useSanitizer;
|
|
18
|
+
//# sourceMappingURL=sanitizers.resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sanitizers.resolver.js","sourceRoot":"","sources":["../../../src/operations/components/sanitizers.resolver.ts"],"names":[],"mappings":";;;AACA,wCAAqD;AACrD,qDAA8D;AAC9D,mDAA0D;AAC1D,wCAAqD;AAErD,MAAM,gBAAgB,GAAqC;IACzD,GAAG,mCAAsB;IACzB,GAAG,iCAAuB;IAC1B,GAAG,iCAAoB;IACvB,GAAG,iCAAuB;CAC3B,CAAC;AAEF,SAAgB,YAAY,CAAC,SAAwB;IACnD,OAAO,gBAAgB,CAAC,SAAS,CAAC,CAAC;AACrC,CAAC;AAFD,oCAEC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.DateOperationsMapper = void 0;
|
|
18
|
+
const types_1 = require("../types");
|
|
19
|
+
const operations_1 = require("./operations");
|
|
20
|
+
__exportStar(require("./operations"), exports);
|
|
21
|
+
__exportStar(require("./types"), exports);
|
|
22
|
+
exports.DateOperationsMapper = {
|
|
23
|
+
[types_1.OperationEnum.On]: (value) => (0, operations_1.useDateOnOperation)(value),
|
|
24
|
+
[types_1.OperationEnum.OnOrAfter]: (value) => (0, operations_1.useDateOnOrAfterOperation)(value),
|
|
25
|
+
[types_1.OperationEnum.OnOrBefore]: (value) => (0, operations_1.useDateOnOrBeforeOperation)(value),
|
|
26
|
+
[types_1.OperationEnum.BetweenDate]: (value) => (0, operations_1.useDateBetweenOperation)(value),
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/operations/date/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,oCAA2D;AAC3D,6CAKsB;AAGtB,+CAA6B;AAC7B,0CAAwB;AAEX,QAAA,oBAAoB,GAAqB;IACpD,CAAC,qBAAa,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,+BAAkB,EAAC,KAAmC,CAAC;IACtF,CAAC,qBAAa,CAAC,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,sCAAyB,EAAC,KAAmC,CAAC;IACpG,CAAC,qBAAa,CAAC,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,uCAA0B,EAAC,KAAmC,CAAC;IACtG,CAAC,qBAAa,CAAC,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,oCAAuB,EAAC,KAAoC,CAAC;CACtG,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { OperationHandler } from '../types';
|
|
2
|
+
import { BetweenDateOperationPayload, SingleDateOperationPayload } from './types';
|
|
3
|
+
export declare function useDateOnOperation(payload: SingleDateOperationPayload): OperationHandler;
|
|
4
|
+
export declare function useDateOnOrAfterOperation(payload: SingleDateOperationPayload): OperationHandler;
|
|
5
|
+
export declare function useDateOnOrBeforeOperation(payload: SingleDateOperationPayload): OperationHandler;
|
|
6
|
+
export declare function useDateBetweenOperation(payload: BetweenDateOperationPayload): OperationHandler;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useDateBetweenOperation = exports.useDateOnOrBeforeOperation = exports.useDateOnOrAfterOperation = exports.useDateOnOperation = void 0;
|
|
4
|
+
function useDateOnOperation(payload) {
|
|
5
|
+
return (attribute) => ({ isValid: attribute.getTime() === payload.date.getTime() });
|
|
6
|
+
}
|
|
7
|
+
exports.useDateOnOperation = useDateOnOperation;
|
|
8
|
+
function useDateOnOrAfterOperation(payload) {
|
|
9
|
+
return (attribute) => ({ isValid: attribute.getTime() >= payload.date.getTime() });
|
|
10
|
+
}
|
|
11
|
+
exports.useDateOnOrAfterOperation = useDateOnOrAfterOperation;
|
|
12
|
+
function useDateOnOrBeforeOperation(payload) {
|
|
13
|
+
return (attribute) => ({ isValid: attribute.getTime() <= payload.date.getTime() });
|
|
14
|
+
}
|
|
15
|
+
exports.useDateOnOrBeforeOperation = useDateOnOrBeforeOperation;
|
|
16
|
+
function useDateBetweenOperation(payload) {
|
|
17
|
+
return (attribute) => ({
|
|
18
|
+
isValid: attribute.getTime() >= payload.start.getTime() && attribute.getTime() <= payload.end.getTime(),
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
exports.useDateBetweenOperation = useDateBetweenOperation;
|
|
22
|
+
//# sourceMappingURL=operations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations.js","sourceRoot":"","sources":["../../../src/operations/date/operations.ts"],"names":[],"mappings":";;;AAGA,SAAgB,kBAAkB,CAAC,OAAmC;IACpE,OAAO,CAAC,SAAe,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,SAAS,CAAC,OAAO,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;AAC5F,CAAC;AAFD,gDAEC;AAED,SAAgB,yBAAyB,CAAC,OAAmC;IAC3E,OAAO,CAAC,SAAe,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,SAAS,CAAC,OAAO,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;AAC3F,CAAC;AAFD,8DAEC;AAED,SAAgB,0BAA0B,CAAC,OAAmC;IAC5E,OAAO,CAAC,SAAe,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,SAAS,CAAC,OAAO,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;AAC3F,CAAC;AAFD,gEAEC;AAED,SAAgB,uBAAuB,CAAC,OAAoC;IAC1E,OAAO,CAAC,SAAe,EAAE,EAAE,CAAC,CAAC;QAC3B,OAAO,EAAE,SAAS,CAAC,OAAO,EAAE,IAAI,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,SAAS,CAAC,OAAO,EAAE,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE;KACxG,CAAC,CAAC;AACL,CAAC;AAJD,0DAIC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Sanitizer, SanitizersMapper } from '../types';
|
|
2
|
+
import { BetweenDateOperationPayload, DateOperationPayload, SingleDateOperationPayload } from './types';
|
|
3
|
+
export declare const sanitizeSingleDate: Sanitizer<SingleDateOperationPayload>;
|
|
4
|
+
export declare const sanitizeDateRange: Sanitizer<BetweenDateOperationPayload>;
|
|
5
|
+
export declare const DateSanitizersMapper: SanitizersMapper<DateOperationPayload>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DateSanitizersMapper = exports.sanitizeDateRange = exports.sanitizeSingleDate = void 0;
|
|
4
|
+
const types_1 = require("../types");
|
|
5
|
+
const sanitizeSingleDate = (value) => {
|
|
6
|
+
const sanitizedValue = value.date ? { date: value.date } : undefined;
|
|
7
|
+
return {
|
|
8
|
+
isSanitized: !!sanitizedValue,
|
|
9
|
+
sanitizedValue,
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
exports.sanitizeSingleDate = sanitizeSingleDate;
|
|
13
|
+
const sanitizeDateRange = (value) => {
|
|
14
|
+
const sanitizedValue = value.start && value.end ? { start: value.start, end: value.end } : undefined;
|
|
15
|
+
return {
|
|
16
|
+
isSanitized: !!sanitizedValue,
|
|
17
|
+
sanitizedValue,
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
exports.sanitizeDateRange = sanitizeDateRange;
|
|
21
|
+
exports.DateSanitizersMapper = {
|
|
22
|
+
[types_1.OperationEnum.On]: exports.sanitizeSingleDate,
|
|
23
|
+
[types_1.OperationEnum.OnOrAfter]: exports.sanitizeDateRange,
|
|
24
|
+
[types_1.OperationEnum.OnOrBefore]: exports.sanitizeSingleDate,
|
|
25
|
+
[types_1.OperationEnum.BetweenDate]: exports.sanitizeSingleDate,
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=sanitizers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sanitizers.js","sourceRoot":"","sources":["../../../src/operations/date/sanitizers.ts"],"names":[],"mappings":";;;AAAA,oCAAsE;AAG/D,MAAM,kBAAkB,GAA0C,CAAC,KAAK,EAAE,EAAE;IACjF,MAAM,cAAc,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAY,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IAE7E,OAAO;QACL,WAAW,EAAE,CAAC,CAAC,cAAc;QAC7B,cAAc;KACf,CAAC;AACJ,CAAC,CAAC;AAPW,QAAA,kBAAkB,sBAO7B;AAEK,MAAM,iBAAiB,GAA2C,CAAC,KAAK,EAAE,EAAE;IACjF,MAAM,cAAc,GAAG,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAa,EAAE,GAAG,EAAE,KAAK,CAAC,GAAW,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IAErH,OAAO;QACL,WAAW,EAAE,CAAC,CAAC,cAAc;QAC7B,cAAc;KACf,CAAC;AACJ,CAAC,CAAC;AAPW,QAAA,iBAAiB,qBAO5B;AAEW,QAAA,oBAAoB,GAA2C;IAC1E,CAAC,qBAAa,CAAC,EAAE,CAAC,EAAE,0BAAkB;IACtC,CAAC,qBAAa,CAAC,SAAS,CAAC,EAAE,yBAAiB;IAC5C,CAAC,qBAAa,CAAC,UAAU,CAAC,EAAE,0BAAkB;IAC9C,CAAC,qBAAa,CAAC,WAAW,CAAC,EAAE,0BAAkB;CAChD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/operations/date/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.NumericOperationsMapper = void 0;
|
|
18
|
+
const types_1 = require("../types");
|
|
19
|
+
const operations_1 = require("./operations");
|
|
20
|
+
exports.NumericOperationsMapper = {
|
|
21
|
+
[types_1.OperationEnum.Equal]: (value) => (0, operations_1.useEqualsOperation)(value),
|
|
22
|
+
[types_1.OperationEnum.GreaterThan]: (value) => (0, operations_1.useGreaterThanOperation)(value),
|
|
23
|
+
[types_1.OperationEnum.GreaterThanEqual]: (value) => (0, operations_1.useGreaterThanEqualOperation)(value),
|
|
24
|
+
[types_1.OperationEnum.LesserThan]: (value) => (0, operations_1.useLesserThanOperation)(value),
|
|
25
|
+
[types_1.OperationEnum.LesserThanEqual]: (value) => (0, operations_1.useLesserThanEqualOperation)(value),
|
|
26
|
+
[types_1.OperationEnum.BetweenNumeric]: (value) => (0, operations_1.useBetweenNumericOperation)(value),
|
|
27
|
+
};
|
|
28
|
+
__exportStar(require("./operations"), exports);
|
|
29
|
+
__exportStar(require("./sanitizers"), exports);
|
|
30
|
+
__exportStar(require("./types"), exports);
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/operations/numeric/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,oCAA2D;AAC3D,6CAOsB;AAGT,QAAA,uBAAuB,GAAqB;IACvD,CAAC,qBAAa,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,+BAAkB,EAAC,KAAsC,CAAC;IAC5F,CAAC,qBAAa,CAAC,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,oCAAuB,EAAC,KAAsC,CAAC;IACvG,CAAC,qBAAa,CAAC,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,yCAA4B,EAAC,KAAsC,CAAC;IACjH,CAAC,qBAAa,CAAC,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,mCAAsB,EAAC,KAAsC,CAAC;IACrG,CAAC,qBAAa,CAAC,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,wCAA2B,EAAC,KAAsC,CAAC;IAC/G,CAAC,qBAAa,CAAC,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,uCAA0B,EAAC,KAAuC,CAAC;CAC/G,CAAC;AAEF,+CAA6B;AAC7B,+CAA6B;AAC7B,0CAAwB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { OperationHandler } from '../types';
|
|
2
|
+
import { BetweenNumericOperationPayload, SingleNumericOperationPayload } from './types';
|
|
3
|
+
export declare function useEqualsOperation(payload: SingleNumericOperationPayload): OperationHandler;
|
|
4
|
+
export declare function useGreaterThanOperation(payload: SingleNumericOperationPayload): OperationHandler;
|
|
5
|
+
export declare function useGreaterThanEqualOperation(payload: SingleNumericOperationPayload): OperationHandler;
|
|
6
|
+
export declare function useLesserThanOperation(payload: SingleNumericOperationPayload): OperationHandler;
|
|
7
|
+
export declare function useLesserThanEqualOperation(payload: SingleNumericOperationPayload): OperationHandler;
|
|
8
|
+
export declare function useBetweenNumericOperation(payload: BetweenNumericOperationPayload): OperationHandler;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useBetweenNumericOperation = exports.useLesserThanEqualOperation = exports.useLesserThanOperation = exports.useGreaterThanEqualOperation = exports.useGreaterThanOperation = exports.useEqualsOperation = void 0;
|
|
4
|
+
function useEqualsOperation(payload) {
|
|
5
|
+
return (attribute) => ({ isValid: attribute === payload.number });
|
|
6
|
+
}
|
|
7
|
+
exports.useEqualsOperation = useEqualsOperation;
|
|
8
|
+
function useGreaterThanOperation(payload) {
|
|
9
|
+
return (attribute) => ({ isValid: attribute > payload.number });
|
|
10
|
+
}
|
|
11
|
+
exports.useGreaterThanOperation = useGreaterThanOperation;
|
|
12
|
+
function useGreaterThanEqualOperation(payload) {
|
|
13
|
+
return (attribute) => ({ isValid: attribute >= payload.number });
|
|
14
|
+
}
|
|
15
|
+
exports.useGreaterThanEqualOperation = useGreaterThanEqualOperation;
|
|
16
|
+
function useLesserThanOperation(payload) {
|
|
17
|
+
return (attribute) => ({ isValid: attribute < payload.number });
|
|
18
|
+
}
|
|
19
|
+
exports.useLesserThanOperation = useLesserThanOperation;
|
|
20
|
+
function useLesserThanEqualOperation(payload) {
|
|
21
|
+
return (attribute) => ({ isValid: attribute <= payload.number });
|
|
22
|
+
}
|
|
23
|
+
exports.useLesserThanEqualOperation = useLesserThanEqualOperation;
|
|
24
|
+
function useBetweenNumericOperation(payload) {
|
|
25
|
+
return (attribute) => ({ isValid: attribute >= payload.start && attribute <= payload.end });
|
|
26
|
+
}
|
|
27
|
+
exports.useBetweenNumericOperation = useBetweenNumericOperation;
|
|
28
|
+
//# sourceMappingURL=operations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations.js","sourceRoot":"","sources":["../../../src/operations/numeric/operations.ts"],"names":[],"mappings":";;;AAGA,SAAgB,kBAAkB,CAAC,OAAsC;IACvE,OAAO,CAAC,SAAiB,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,SAAS,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;AAC5E,CAAC;AAFD,gDAEC;AAED,SAAgB,uBAAuB,CAAC,OAAsC;IAC5E,OAAO,CAAC,SAAiB,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;AAC1E,CAAC;AAFD,0DAEC;AAED,SAAgB,4BAA4B,CAAC,OAAsC;IACjF,OAAO,CAAC,SAAiB,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,SAAS,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;AAC3E,CAAC;AAFD,oEAEC;AAED,SAAgB,sBAAsB,CAAC,OAAsC;IAC3E,OAAO,CAAC,SAAiB,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;AAC1E,CAAC;AAFD,wDAEC;AAED,SAAgB,2BAA2B,CAAC,OAAsC;IAChF,OAAO,CAAC,SAAiB,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,SAAS,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;AAC3E,CAAC;AAFD,kEAEC;AAED,SAAgB,0BAA0B,CAAC,OAAuC;IAChF,OAAO,CAAC,SAAiB,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,SAAS,IAAI,OAAO,CAAC,KAAK,IAAI,SAAS,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;AACtG,CAAC;AAFD,gEAEC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Sanitizer, SanitizersMapper } from '../types';
|
|
2
|
+
import { BetweenNumericOperationPayload, NumericOperationPayload, SingleNumericOperationPayload } from './types';
|
|
3
|
+
export declare const sanitizeSingleNumber: Sanitizer<SingleNumericOperationPayload>;
|
|
4
|
+
export declare const sanitizeNumericRange: Sanitizer<BetweenNumericOperationPayload>;
|
|
5
|
+
export declare const NumericSanitizersMapper: SanitizersMapper<NumericOperationPayload>;
|