@raytio/core 10.1.0 → 11.0.0

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.
Files changed (172) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +100 -59
  3. package/dist/{util/hash.d.ts → __tests__/docs.test.d.ts} +1 -1
  4. package/dist/__tests__/docs.test.js +24 -0
  5. package/dist/accessApplication/createAA.d.ts +17 -17
  6. package/dist/accessApplication/createAA.js +71 -71
  7. package/dist/accessApplication/index.d.ts +1 -1
  8. package/dist/accessApplication/index.js +17 -17
  9. package/dist/crypto/cognitoAttributes.d.ts +15 -15
  10. package/dist/crypto/cognitoAttributes.js +33 -33
  11. package/dist/crypto/decryptKeys.d.ts +1 -1
  12. package/dist/crypto/decryptKeys.js +33 -33
  13. package/dist/crypto/decryptSharedData.d.ts +26 -26
  14. package/dist/crypto/decryptSharedData.js +38 -38
  15. package/dist/crypto/getAADecryptor.d.ts +16 -16
  16. package/dist/crypto/getAADecryptor.js +20 -20
  17. package/dist/crypto/helpers.d.ts +18 -18
  18. package/dist/crypto/helpers.js +26 -26
  19. package/dist/crypto/index.d.ts +4 -4
  20. package/dist/crypto/index.js +21 -21
  21. package/dist/general/conditional.d.ts +17 -17
  22. package/dist/general/conditional.js +32 -32
  23. package/dist/general/date.d.ts +2 -2
  24. package/dist/general/date.js +18 -18
  25. package/dist/general/index.d.ts +4 -4
  26. package/dist/general/index.js +20 -20
  27. package/dist/general/password.d.ts +10 -10
  28. package/dist/general/password.js +31 -31
  29. package/dist/general/types.d.ts +6 -6
  30. package/dist/general/types.js +13 -13
  31. package/dist/index.d.ts +6 -6
  32. package/dist/index.js +22 -22
  33. package/dist/rules/calculateScore.d.ts +28 -23
  34. package/dist/rules/calculateScore.js +82 -76
  35. package/dist/rules/convertInstanceToRuleInput.d.ts +3 -3
  36. package/dist/rules/convertInstanceToRuleInput.js +138 -139
  37. package/dist/rules/evaluateScoreCondition.d.ts +2 -2
  38. package/dist/rules/evaluateScoreCondition.js +44 -45
  39. package/dist/{verifications/checkVerifications.d.ts → rules/helpers/__tests__/addInfiniteThresholdBoundaries.test.d.ts} +1 -1
  40. package/dist/rules/helpers/__tests__/addInfiniteThresholdBoundaries.test.js +27 -0
  41. package/dist/{verifications/checkVerificationsNew.d.ts → rules/helpers/__tests__/checkTypeofValue.test.d.ts} +1 -1
  42. package/dist/rules/helpers/__tests__/checkTypeofValue.test.js +49 -0
  43. package/dist/{verifications/verifyCheck/util/canonicalJsonify.d.ts → rules/helpers/__tests__/getValuesFromPath.test.d.ts} +1 -1
  44. package/dist/rules/helpers/__tests__/getValuesFromPath.test.js +67 -0
  45. package/dist/rules/helpers/__tests__/thresholds.test.d.ts +1 -0
  46. package/dist/rules/helpers/__tests__/thresholds.test.js +32 -0
  47. package/dist/rules/helpers/addInfiniteThresholdBoundaries.d.ts +8 -8
  48. package/dist/rules/helpers/addInfiniteThresholdBoundaries.js +11 -11
  49. package/dist/rules/helpers/checkTypeofValue.d.ts +9 -9
  50. package/dist/rules/helpers/checkTypeofValue.js +60 -55
  51. package/dist/rules/helpers/getValuesFromPath.d.ts +3 -3
  52. package/dist/rules/helpers/getValuesFromPath.js +50 -50
  53. package/dist/rules/helpers/index.d.ts +5 -5
  54. package/dist/rules/helpers/index.js +21 -21
  55. package/dist/rules/helpers/symbols.d.ts +2 -2
  56. package/dist/rules/helpers/symbols.js +5 -5
  57. package/dist/rules/helpers/thresholds.d.ts +5 -5
  58. package/dist/rules/helpers/thresholds.js +46 -47
  59. package/dist/rules/index.d.ts +7 -7
  60. package/dist/rules/index.js +25 -25
  61. package/dist/rules/operators/__tests__/bool.test.d.ts +1 -0
  62. package/dist/rules/operators/__tests__/bool.test.js +21 -0
  63. package/dist/rules/operators/__tests__/date.test.d.ts +1 -0
  64. package/dist/rules/operators/__tests__/date.test.js +81 -0
  65. package/dist/rules/operators/__tests__/hfield.test.d.ts +1 -0
  66. package/dist/rules/operators/__tests__/hfield.test.js +38 -0
  67. package/dist/rules/operators/__tests__/hschema.test.d.ts +1 -0
  68. package/dist/rules/operators/__tests__/hschema.test.js +24 -0
  69. package/dist/rules/operators/__tests__/number.test.d.ts +1 -0
  70. package/dist/rules/operators/__tests__/number.test.js +53 -0
  71. package/dist/rules/operators/__tests__/string.test.d.ts +1 -0
  72. package/dist/rules/operators/__tests__/string.test.js +74 -0
  73. package/dist/rules/operators/bool.d.ts +2 -2
  74. package/dist/rules/operators/bool.js +17 -17
  75. package/dist/rules/operators/date.d.ts +2 -2
  76. package/dist/rules/operators/date.js +91 -91
  77. package/dist/rules/operators/hfield.d.ts +2 -2
  78. package/dist/rules/operators/hfield.js +33 -33
  79. package/dist/rules/operators/hschema.d.ts +2 -2
  80. package/dist/rules/operators/hschema.js +21 -21
  81. package/dist/rules/operators/index.d.ts +3 -3
  82. package/dist/rules/operators/index.js +11 -11
  83. package/dist/rules/operators/number.d.ts +2 -2
  84. package/dist/rules/operators/number.js +41 -41
  85. package/dist/rules/operators/string.d.ts +2 -2
  86. package/dist/rules/operators/string.js +58 -58
  87. package/dist/rules/types/config.d.ts +95 -91
  88. package/dist/rules/types/config.js +2 -2
  89. package/dist/rules/types/dataValueTypes.d.ts +19 -19
  90. package/dist/rules/types/dataValueTypes.js +4 -4
  91. package/dist/rules/types/index.d.ts +3 -3
  92. package/dist/rules/types/index.js +19 -19
  93. package/dist/rules/types/internal.d.ts +20 -20
  94. package/dist/rules/types/internal.js +2 -2
  95. package/dist/rules/validate.d.ts +6 -6
  96. package/dist/rules/validate.js +14 -14
  97. package/dist/rules/version.d.ts +1 -1
  98. package/dist/rules/version.js +5 -5
  99. package/dist/schema/index.d.ts +1 -1
  100. package/dist/schema/index.js +17 -17
  101. package/dist/schema/labels.d.ts +2 -2
  102. package/dist/schema/labels.js +20 -20
  103. package/dist/util/canonicalJsonify.d.ts +1 -1
  104. package/dist/util/canonicalJsonify.js +50 -50
  105. package/dist/util/handleResponse.d.ts +1 -1
  106. package/dist/util/handleResponse.js +21 -21
  107. package/dist/util/index.d.ts +2 -2
  108. package/dist/util/index.js +18 -18
  109. package/dist/verifications/cleanInstance.d.ts +9 -9
  110. package/dist/verifications/cleanInstance.js +15 -15
  111. package/dist/verifications/getPOVerification.d.ts +19 -16
  112. package/dist/verifications/getPOVerification.js +105 -94
  113. package/dist/verifications/getVerifiedBy.d.ts +1 -1
  114. package/dist/verifications/getVerifiedBy.js +19 -19
  115. package/dist/verifications/index.d.ts +5 -5
  116. package/dist/verifications/index.js +21 -21
  117. package/dist/verifications/maybeRereference.d.ts +1 -1
  118. package/dist/verifications/maybeRereference.js +10 -10
  119. package/dist/verifications/safeHarbour.d.ts +20 -20
  120. package/dist/verifications/safeHarbour.js +74 -74
  121. package/dist/verifications/verifyCheck/__tests__/getOwnRealVerifications.test.d.ts +1 -0
  122. package/dist/verifications/verifyCheck/__tests__/getOwnRealVerifications.test.js +152 -0
  123. package/dist/verifications/verifyCheck/__tests__/getSomeoneElsesRealVerifications.test.d.ts +1 -0
  124. package/dist/verifications/verifyCheck/__tests__/getSomeoneElsesRealVerifications.test.js +205 -0
  125. package/dist/verifications/verifyCheck/getOwnRealVerifications.d.ts +13 -13
  126. package/dist/verifications/verifyCheck/getOwnRealVerifications.js +66 -64
  127. package/dist/verifications/verifyCheck/getSomeoneElsesRealVerifications.d.ts +19 -19
  128. package/dist/verifications/verifyCheck/getSomeoneElsesRealVerifications.js +72 -72
  129. package/dist/verifications/verifyCheck/index.d.ts +3 -3
  130. package/dist/verifications/verifyCheck/index.js +21 -21
  131. package/dist/verifications/verifyCheck/operations/__tests__/checkOwnVerification.test.d.ts +1 -0
  132. package/dist/verifications/verifyCheck/operations/__tests__/checkOwnVerification.test.js +91 -0
  133. package/dist/verifications/verifyCheck/operations/__tests__/checkSomeoneElsesVerifications.test.d.ts +1 -0
  134. package/dist/verifications/verifyCheck/operations/__tests__/checkSomeoneElsesVerifications.test.js +49 -0
  135. package/dist/verifications/verifyCheck/operations/__tests__/sampleBundle.json +43 -0
  136. package/dist/verifications/verifyCheck/operations/checkOwnVerification.d.ts +15 -15
  137. package/dist/verifications/verifyCheck/operations/checkOwnVerification.js +39 -39
  138. package/dist/verifications/verifyCheck/operations/checkSomeoneElsesVerifications.d.ts +1 -1
  139. package/dist/verifications/verifyCheck/operations/checkSomeoneElsesVerifications.js +16 -16
  140. package/dist/verifications/verifyCheck/operations/index.d.ts +2 -2
  141. package/dist/verifications/verifyCheck/operations/index.js +18 -18
  142. package/package.json +13 -10
  143. package/dist/rules/helpers/getLhsTypeofValue.d.ts +0 -0
  144. package/dist/rules/helpers/getLhsTypeofValue.js +0 -1
  145. package/dist/rules/helpers/getValueFromPath.d.ts +0 -2
  146. package/dist/rules/helpers/getValueFromPath.js +0 -35
  147. package/dist/rules/helpers/rebuildInfiniteValues.d.ts +0 -3
  148. package/dist/rules/helpers/rebuildInfiniteValues.js +0 -6
  149. package/dist/rules/isScoreResultValid.d.ts +0 -2
  150. package/dist/rules/isScoreResultValid.js +0 -9
  151. package/dist/rules/operators/array.d.ts +0 -2
  152. package/dist/rules/operators/array.js +0 -74
  153. package/dist/rules/types/operators.d.ts +0 -19
  154. package/dist/rules/types/operators.js +0 -2
  155. package/dist/rules/types/score.d.ts +0 -50
  156. package/dist/rules/types/score.js +0 -2
  157. package/dist/util/conditional.d.ts +0 -7
  158. package/dist/util/conditional.js +0 -15
  159. package/dist/util/hash.js +0 -11
  160. package/dist/verifications/checkSingleVerification.d.ts +0 -9
  161. package/dist/verifications/checkSingleVerification.js +0 -29
  162. package/dist/verifications/checkVerifications.js +0 -16
  163. package/dist/verifications/checkVerificationsNew.js +0 -16
  164. package/dist/verifications/getOwnRealVerifications.d.ts +0 -14
  165. package/dist/verifications/getOwnRealVerifications.js +0 -64
  166. package/dist/verifications/getRealVerifications.d.ts +0 -22
  167. package/dist/verifications/getRealVerifications.js +0 -71
  168. package/dist/verifications/verifyCheck/util/canonicalJsonify.js +0 -48
  169. package/dist/verifications/verifyCheck/util/getValuesForAField.d.ts +0 -2
  170. package/dist/verifications/verifyCheck/util/getValuesForAField.js +0 -9
  171. package/dist/verifications/verifyCheck/util/index.d.ts +0 -2
  172. package/dist/verifications/verifyCheck/util/index.js +0 -14
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const types_1 = require("@raytio/types");
4
+ const hfield_1 = require("../hfield");
5
+ describe("fieldOperators", () => {
6
+ it("field_shared", () => {
7
+ expect(hfield_1.fieldOperators.field_shared.implementation()).toBe(true);
8
+ });
9
+ it.each `
10
+ field | verifier | result
11
+ ${{ verifiedBy: ["MoH"] }} | ${"MoH"} | ${true}
12
+ ${{ verifiedBy: ["MinEdu"] }} | ${"Ministry of Health"} | ${false}
13
+ ${{ verifiedBy: [] }} | ${"Ministry of Health"} | ${false}
14
+ `("field_verifiedBy {...}, $verifier", ({ field, verifier, result }) => {
15
+ expect(hfield_1.fieldOperators.field_verifiedBy.implementation(field, verifier)).toBe(result);
16
+ });
17
+ it.each `
18
+ field | value | result
19
+ ${{ verification: types_1.FieldVerification.Verified }} | ${types_1.FieldVerification.Verified} | ${true}
20
+ ${{ verification: types_1.FieldVerification.NotVerified }} | ${types_1.FieldVerification.Verified} | ${false}
21
+ `("field_hasVerStatus {...}, $value", ({ field, value, result }) => {
22
+ expect(hfield_1.fieldOperators.field_hasVerStatus.implementation(field, value)).toBe(result);
23
+ });
24
+ it.each `
25
+ field | value | result
26
+ ${{ cameFromSchema: "ss_A" }} | ${"ss_A"} | ${true}
27
+ ${{ cameFromSchema: "ss_A" }} | ${"ss_B"} | ${false}
28
+ `("field_cameFromSchema {...}, $value", ({ field, value, result }) => {
29
+ expect(hfield_1.fieldOperators.field_cameFromSchema.implementation(field, value)).toBe(result);
30
+ });
31
+ it.each `
32
+ field | value | result
33
+ ${{ cameFromSchema: "ss_A" }} | ${"ss_A"} | ${false}
34
+ ${{ cameFromSchema: "ss_A" }} | ${"ss_B"} | ${true}
35
+ `("field_ncameFromSchema {...}, $value", ({ field, value, result }) => {
36
+ expect(hfield_1.fieldOperators.field_ncameFromSchema.implementation(field, value)).toBe(result);
37
+ });
38
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const types_1 = require("@raytio/types");
4
+ const hschema_1 = require("../hschema");
5
+ describe("schemaOperators", () => {
6
+ it("schema_shared", () => {
7
+ expect(hschema_1.schemaOperators.schema_shared.implementation()).toBe(true);
8
+ });
9
+ it.each `
10
+ field | verifier | result
11
+ ${{ verifiedBy: ["MoH"] }} | ${"MoH"} | ${true}
12
+ ${{ verifiedBy: ["MinEdu"] }} | ${"Ministry of Health"} | ${false}
13
+ ${{ verifiedBy: [] }} | ${"Ministry of Health"} | ${false}
14
+ `("schema_verifiedBy {...}, $verifier", ({ field, verifier, result }) => {
15
+ expect(hschema_1.schemaOperators.schema_verifiedBy.implementation(field, verifier)).toBe(result);
16
+ });
17
+ it.each `
18
+ field | value | result
19
+ ${{ verification: types_1.POVerification.FullyVerified }} | ${types_1.POVerification.FullyVerified} | ${true}
20
+ ${{ verification: types_1.POVerification.NotVerified }} | ${types_1.POVerification.FullyVerified} | ${false}
21
+ `("schema_hasVerStatus {...}, $value", ({ field, value, result }) => {
22
+ expect(hschema_1.schemaOperators.schema_hasVerStatus.implementation(field, value)).toBe(result);
23
+ });
24
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const number_1 = require("../number");
4
+ describe("numberOperators", () => {
5
+ it.each `
6
+ a | b | result
7
+ ${1} | ${1} | ${true}
8
+ ${1} | ${2} | ${false}
9
+ ${3.3333} | ${3.3333} | ${true}
10
+ `("num_eq $a, $b", ({ a, b, result }) => {
11
+ expect(number_1.numberOperators.num_eq.implementation(a, b)).toBe(result);
12
+ });
13
+ it.each `
14
+ a | b | result
15
+ ${1} | ${1} | ${false}
16
+ ${1} | ${2} | ${true}
17
+ ${3.3333} | ${3.3333} | ${false}
18
+ `("num_neq $a, $b", ({ a, b, result }) => {
19
+ expect(number_1.numberOperators.num_neq.implementation(a, b)).toBe(result);
20
+ });
21
+ it.each `
22
+ a | b | result
23
+ ${0} | ${1} | ${false}
24
+ ${1} | ${1} | ${true}
25
+ ${2} | ${1} | ${true}
26
+ `("num_gt_eq $a, $b", ({ a, b, result }) => {
27
+ expect(number_1.numberOperators.num_gt_eq.implementation(a, b)).toBe(result);
28
+ });
29
+ it.each `
30
+ a | b | result
31
+ ${0} | ${1} | ${false}
32
+ ${1} | ${1} | ${false}
33
+ ${2} | ${1} | ${true}
34
+ `("num_gt $a, $b", ({ a, b, result }) => {
35
+ expect(number_1.numberOperators.num_gt.implementation(a, b)).toBe(result);
36
+ });
37
+ it.each `
38
+ a | b | result
39
+ ${0} | ${1} | ${true}
40
+ ${1} | ${1} | ${true}
41
+ ${2} | ${1} | ${false}
42
+ `("num_lt_eq $a, $b", ({ a, b, result }) => {
43
+ expect(number_1.numberOperators.num_lt_eq.implementation(a, b)).toBe(result);
44
+ });
45
+ it.each `
46
+ a | b | result
47
+ ${0} | ${1} | ${true}
48
+ ${1} | ${1} | ${false}
49
+ ${2} | ${1} | ${false}
50
+ `("num_lt $a, $b", ({ a, b, result }) => {
51
+ expect(number_1.numberOperators.num_lt.implementation(a, b)).toBe(result);
52
+ });
53
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const string_1 = require("../string");
4
+ describe("stringOperators", () => {
5
+ it.each `
6
+ a | b | result
7
+ ${"AA"} | ${"aa"} | ${true}
8
+ ${"Aa"} | ${"Bb"} | ${false}
9
+ `("string_eq $a, $b", ({ a, b, result }) => {
10
+ expect(string_1.stringOperators.string_eq.implementation(a, b)).toBe(result);
11
+ });
12
+ it.each `
13
+ a | b | result
14
+ ${"AA"} | ${"aa"} | ${false}
15
+ ${"Aa"} | ${"Bb"} | ${true}
16
+ `("string_neq $a, $b", ({ a, b, result }) => {
17
+ expect(string_1.stringOperators.string_neq.implementation(a, b)).toBe(result);
18
+ });
19
+ it.each `
20
+ str | substr | result
21
+ ${"alOOf"} | ${"oo"} | ${true}
22
+ ${"Hello"} | ${""} | ${true}
23
+ ${"Hello"} | ${"X"} | ${false}
24
+ `("string_contains $str, $substr", ({ str, substr, result }) => {
25
+ expect(string_1.stringOperators.string_contains.implementation(str, substr)).toBe(result);
26
+ });
27
+ it.each `
28
+ str | substr | result
29
+ ${"alOOf"} | ${"oo"} | ${false}
30
+ ${"Hello"} | ${""} | ${false}
31
+ ${"Hello"} | ${"X"} | ${true}
32
+ `("string_ncontains $str, $substr", ({ str, substr, result }) => {
33
+ expect(string_1.stringOperators.string_ncontains.implementation(str, substr)).toBe(result);
34
+ });
35
+ it.each `
36
+ str | substr | result
37
+ ${"alOOf"} | ${"alo"} | ${true}
38
+ ${"Hello"} | ${""} | ${true}
39
+ ${"Hello"} | ${"X"} | ${false}
40
+ `("string_startsWith $str, $substr", ({ str, substr, result }) => {
41
+ expect(string_1.stringOperators.string_startsWith.implementation(str, substr)).toBe(result);
42
+ });
43
+ it.each `
44
+ str | substr | result
45
+ ${"alOOf"} | ${"alo"} | ${false}
46
+ ${"Hello"} | ${""} | ${false}
47
+ ${"Hello"} | ${"X"} | ${true}
48
+ `("string_nstartsWith $str, $substr", ({ str, substr, result }) => {
49
+ expect(string_1.stringOperators.string_nstartsWith.implementation(str, substr)).toBe(result);
50
+ });
51
+ it.each `
52
+ str | substr | result
53
+ ${"alOOf"} | ${"oof"} | ${true}
54
+ ${"Hello"} | ${""} | ${true}
55
+ ${"Hello"} | ${"X"} | ${false}
56
+ `("string_endsWith $str, $substr", ({ str, substr, result }) => {
57
+ expect(string_1.stringOperators.string_endsWith.implementation(str, substr)).toBe(result);
58
+ });
59
+ it.each `
60
+ str | substr | result
61
+ ${"alOOf"} | ${"oof"} | ${false}
62
+ ${"Hello"} | ${""} | ${false}
63
+ ${"Hello"} | ${"X"} | ${true}
64
+ `("string_nendsWith $str, $substr", ({ str, substr, result }) => {
65
+ expect(string_1.stringOperators.string_nendsWith.implementation(str, substr)).toBe(result);
66
+ });
67
+ it.each `
68
+ str | regex | result
69
+ ${"Hello"} | ${/[^A-za-z]/} | ${false}
70
+ ${"Hēllō"} | ${/[^A-za-z]/} | ${true}
71
+ `("string_regex $str, $regex", ({ str, regex, result }) => {
72
+ expect(string_1.stringOperators.string_regex.implementation(str, regex)).toBe(result);
73
+ });
74
+ });
@@ -1,2 +1,2 @@
1
- import { OperatorID, OperatorDef } from "../types";
2
- export declare const boolOperators: Partial<Record<OperatorID, OperatorDef>>;
1
+ import { OperatorID, OperatorDef } from "../types";
2
+ export declare const boolOperators: Partial<Record<OperatorID, OperatorDef>>;
@@ -1,17 +1,17 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.boolOperators = void 0;
4
- exports.boolOperators = {
5
- bool_eq: {
6
- operands: ["Bool", "Bool"],
7
- implementation(b1, b2) {
8
- return b1 === b2;
9
- },
10
- },
11
- bool_neq: {
12
- operands: ["Bool", "Bool"],
13
- implementation(b1, b2) {
14
- return b1 !== b2;
15
- },
16
- },
17
- };
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.boolOperators = void 0;
4
+ exports.boolOperators = {
5
+ bool_eq: {
6
+ operands: ["Bool", "Bool"],
7
+ implementation(b1, b2) {
8
+ return b1 === b2;
9
+ },
10
+ },
11
+ bool_neq: {
12
+ operands: ["Bool", "Bool"],
13
+ implementation(b1, b2) {
14
+ return b1 !== b2;
15
+ },
16
+ },
17
+ };
@@ -1,2 +1,2 @@
1
- import { OperatorID, OperatorDef } from "../types";
2
- export declare const dateOperators: Partial<Record<OperatorID, OperatorDef>>;
1
+ import { OperatorID, OperatorDef } from "../types";
2
+ export declare const dateOperators: Partial<Record<OperatorID, OperatorDef>>;
@@ -1,91 +1,91 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.dateOperators = void 0;
4
- function getDateInXUnits(offset, unit) {
5
- const d = new Date();
6
- switch (unit) {
7
- case "ms":
8
- d.setMilliseconds(d.getMilliseconds() + offset);
9
- break;
10
- case "s":
11
- d.setSeconds(d.getSeconds() + offset);
12
- break;
13
- case "m":
14
- d.setMinutes(d.getMinutes() + offset);
15
- break;
16
- case "h":
17
- d.setHours(d.getHours() + offset);
18
- break;
19
- case "D":
20
- d.setDate(d.getDate() + offset);
21
- break;
22
- case "M":
23
- d.setMonth(d.getMonth() + offset);
24
- break;
25
- case "W":
26
- d.setDate(d.getDate() + 7 * offset);
27
- break;
28
- case "Y":
29
- d.setFullYear(d.getFullYear() + offset);
30
- break;
31
- default:
32
- throw new Error(`Invalid date unit: ${unit}`);
33
- }
34
- return d;
35
- }
36
- exports.dateOperators = {
37
- date_eq: {
38
- operands: ["Date", "Date"],
39
- implementation(d1, d2) {
40
- // only comaparing dates (not times), and in the UTC timezone.
41
- const isoDate1 = d1.toISOString().split("T")[0];
42
- const isoDate2 = d2.toISOString().split("T")[0];
43
- return isoDate1 === isoDate2;
44
- },
45
- },
46
- date_neq: {
47
- operands: ["Date", "Date"],
48
- implementation(d1, d2) {
49
- // only comaparing dates (not times), and in the UTC timezone.
50
- const isoDate1 = d1.toISOString().split("T")[0];
51
- const isoDate2 = d2.toISOString().split("T")[0];
52
- return isoDate1 !== isoDate2;
53
- },
54
- },
55
- date_valid: {
56
- operands: ["Date"],
57
- implementation: (d) => !Number.isNaN(+d),
58
- },
59
- date_invalid: {
60
- operands: ["Date"],
61
- implementation: (d) => Number.isNaN(+d),
62
- },
63
- date_before: {
64
- operands: ["Date", "Date"],
65
- implementation: (d1, d2) => d1 < d2,
66
- },
67
- date_after: {
68
- operands: ["Date", "Date"],
69
- implementation: (d1, d2) => d1 > d2,
70
- },
71
- date_between: {
72
- operands: ["Date", "Date", "Date"],
73
- implementation(lhs, lower, upper) {
74
- return lhs >= lower && lhs <= upper;
75
- },
76
- },
77
- date_older_than: {
78
- operands: ["Date", "Number", "DateUnit"],
79
- implementation(date, num, unit) {
80
- const XUnitsAgo = getDateInXUnits(-num, unit);
81
- return date < XUnitsAgo;
82
- },
83
- },
84
- date_newer_than: {
85
- operands: ["Date", "Number", "DateUnit"],
86
- implementation(date, num, unit) {
87
- const inXUnits = getDateInXUnits(num, unit);
88
- return date > inXUnits;
89
- },
90
- },
91
- };
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dateOperators = void 0;
4
+ function getDateInXUnits(offset, unit) {
5
+ const d = new Date();
6
+ switch (unit) {
7
+ case "ms":
8
+ d.setMilliseconds(d.getMilliseconds() + offset);
9
+ break;
10
+ case "s":
11
+ d.setSeconds(d.getSeconds() + offset);
12
+ break;
13
+ case "m":
14
+ d.setMinutes(d.getMinutes() + offset);
15
+ break;
16
+ case "h":
17
+ d.setHours(d.getHours() + offset);
18
+ break;
19
+ case "D":
20
+ d.setDate(d.getDate() + offset);
21
+ break;
22
+ case "M":
23
+ d.setMonth(d.getMonth() + offset);
24
+ break;
25
+ case "W":
26
+ d.setDate(d.getDate() + 7 * offset);
27
+ break;
28
+ case "Y":
29
+ d.setFullYear(d.getFullYear() + offset);
30
+ break;
31
+ default:
32
+ throw new Error(`Invalid date unit: ${unit}`);
33
+ }
34
+ return d;
35
+ }
36
+ exports.dateOperators = {
37
+ date_eq: {
38
+ operands: ["Date", "Date"],
39
+ implementation(d1, d2) {
40
+ // only comaparing dates (not times), and in the UTC timezone.
41
+ const isoDate1 = d1.toISOString().split("T")[0];
42
+ const isoDate2 = d2.toISOString().split("T")[0];
43
+ return isoDate1 === isoDate2;
44
+ },
45
+ },
46
+ date_neq: {
47
+ operands: ["Date", "Date"],
48
+ implementation(d1, d2) {
49
+ // only comaparing dates (not times), and in the UTC timezone.
50
+ const isoDate1 = d1.toISOString().split("T")[0];
51
+ const isoDate2 = d2.toISOString().split("T")[0];
52
+ return isoDate1 !== isoDate2;
53
+ },
54
+ },
55
+ date_valid: {
56
+ operands: ["Date"],
57
+ implementation: (d) => !Number.isNaN(+d),
58
+ },
59
+ date_invalid: {
60
+ operands: ["Date"],
61
+ implementation: (d) => Number.isNaN(+d),
62
+ },
63
+ date_before: {
64
+ operands: ["Date", "Date"],
65
+ implementation: (d1, d2) => d1 < d2,
66
+ },
67
+ date_after: {
68
+ operands: ["Date", "Date"],
69
+ implementation: (d1, d2) => d1 > d2,
70
+ },
71
+ date_between: {
72
+ operands: ["Date", "Date", "Date"],
73
+ implementation(lhs, lower, upper) {
74
+ return lhs >= lower && lhs <= upper;
75
+ },
76
+ },
77
+ date_older_than: {
78
+ operands: ["Date", "Number", "DateUnit"],
79
+ implementation(date, num, unit) {
80
+ const XUnitsAgo = getDateInXUnits(-num, unit);
81
+ return date < XUnitsAgo;
82
+ },
83
+ },
84
+ date_newer_than: {
85
+ operands: ["Date", "Number", "DateUnit"],
86
+ implementation(date, num, unit) {
87
+ const inXUnits = getDateInXUnits(num, unit);
88
+ return date > inXUnits;
89
+ },
90
+ },
91
+ };
@@ -1,2 +1,2 @@
1
- import { OperatorID, OperatorDef } from "../types";
2
- export declare const fieldOperators: Partial<Record<OperatorID, OperatorDef>>;
1
+ import { OperatorID, OperatorDef } from "../types";
2
+ export declare const fieldOperators: Partial<Record<OperatorID, OperatorDef>>;
@@ -1,33 +1,33 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fieldOperators = void 0;
4
- exports.fieldOperators = {
5
- field_verifiedBy: {
6
- operands: ["HField", "Verifier"],
7
- implementation(field, verifiedBy) {
8
- return field.verifiedBy.includes(verifiedBy);
9
- },
10
- },
11
- field_shared: {
12
- operands: ["HField"],
13
- implementation: () => true, // we can return true, because if the field didn't exist, this would never be called
14
- },
15
- field_hasVerStatus: {
16
- operands: ["HField", "FieldVerification"],
17
- implementation(field, status) {
18
- return field.verification === status;
19
- },
20
- },
21
- field_cameFromSchema: {
22
- operands: ["HField", "String"],
23
- implementation(field, schemaName) {
24
- return field.cameFromSchema === schemaName;
25
- },
26
- },
27
- field_ncameFromSchema: {
28
- operands: ["HField", "String"],
29
- implementation(field, schemaName) {
30
- return field.cameFromSchema !== schemaName;
31
- },
32
- },
33
- };
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fieldOperators = void 0;
4
+ exports.fieldOperators = {
5
+ field_verifiedBy: {
6
+ operands: ["HField", "Verifier"],
7
+ implementation(field, verifiedBy) {
8
+ return field.verifiedBy.includes(verifiedBy);
9
+ },
10
+ },
11
+ field_shared: {
12
+ operands: ["HField"],
13
+ implementation: () => true, // we can return true, because if the field didn't exist, this would never be called
14
+ },
15
+ field_hasVerStatus: {
16
+ operands: ["HField", "FieldVerification"],
17
+ implementation(field, status) {
18
+ return field.verification === status;
19
+ },
20
+ },
21
+ field_cameFromSchema: {
22
+ operands: ["HField", "String"],
23
+ implementation(field, schemaName) {
24
+ return field.cameFromSchema === schemaName;
25
+ },
26
+ },
27
+ field_ncameFromSchema: {
28
+ operands: ["HField", "String"],
29
+ implementation(field, schemaName) {
30
+ return field.cameFromSchema !== schemaName;
31
+ },
32
+ },
33
+ };
@@ -1,2 +1,2 @@
1
- import { OperatorID, OperatorDef } from "../types";
2
- export declare const schemaOperators: Partial<Record<OperatorID, OperatorDef>>;
1
+ import { OperatorID, OperatorDef } from "../types";
2
+ export declare const schemaOperators: Partial<Record<OperatorID, OperatorDef>>;
@@ -1,21 +1,21 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.schemaOperators = void 0;
4
- exports.schemaOperators = {
5
- schema_verifiedBy: {
6
- operands: ["HSchema", "Verifier"],
7
- implementation(schema, verifiedBy) {
8
- return schema === null || schema === void 0 ? void 0 : schema.verifiedBy.includes(verifiedBy);
9
- },
10
- },
11
- schema_shared: {
12
- operands: ["HSchema"],
13
- implementation: () => true, // we can return true, because if the schema didn't exist, this would never be called
14
- },
15
- schema_hasVerStatus: {
16
- operands: ["HSchema", "POVerification"],
17
- implementation(schema, status) {
18
- return (schema === null || schema === void 0 ? void 0 : schema.verification) === status;
19
- },
20
- },
21
- };
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.schemaOperators = void 0;
4
+ exports.schemaOperators = {
5
+ schema_verifiedBy: {
6
+ operands: ["HSchema", "Verifier"],
7
+ implementation(schema, verifiedBy) {
8
+ return schema === null || schema === void 0 ? void 0 : schema.verifiedBy.includes(verifiedBy);
9
+ },
10
+ },
11
+ schema_shared: {
12
+ operands: ["HSchema"],
13
+ implementation: () => true, // we can return true, because if the schema didn't exist, this would never be called
14
+ },
15
+ schema_hasVerStatus: {
16
+ operands: ["HSchema", "POVerification"],
17
+ implementation(schema, status) {
18
+ return (schema === null || schema === void 0 ? void 0 : schema.verification) === status;
19
+ },
20
+ },
21
+ };
@@ -1,3 +1,3 @@
1
- import { OperatorID, OperatorDef } from "../types";
2
- /** @ignore */
3
- export declare const operators: Record<OperatorID, OperatorDef>;
1
+ import { OperatorID, OperatorDef } from "../types";
2
+ /** @ignore */
3
+ export declare const operators: Record<OperatorID, OperatorDef>;
@@ -1,11 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.operators = void 0;
4
- const bool_1 = require("./bool");
5
- const date_1 = require("./date");
6
- const hfield_1 = require("./hfield");
7
- const hschema_1 = require("./hschema");
8
- const number_1 = require("./number");
9
- const string_1 = require("./string");
10
- /** @ignore */
11
- exports.operators = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, bool_1.boolOperators), date_1.dateOperators), hfield_1.fieldOperators), hschema_1.schemaOperators), number_1.numberOperators), string_1.stringOperators);
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.operators = void 0;
4
+ const bool_1 = require("./bool");
5
+ const date_1 = require("./date");
6
+ const hfield_1 = require("./hfield");
7
+ const hschema_1 = require("./hschema");
8
+ const number_1 = require("./number");
9
+ const string_1 = require("./string");
10
+ /** @ignore */
11
+ exports.operators = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, bool_1.boolOperators), date_1.dateOperators), hfield_1.fieldOperators), hschema_1.schemaOperators), number_1.numberOperators), string_1.stringOperators);
@@ -1,2 +1,2 @@
1
- import { OperatorID, OperatorDef } from "../types";
2
- export declare const numberOperators: Partial<Record<OperatorID, OperatorDef>>;
1
+ import { OperatorID, OperatorDef } from "../types";
2
+ export declare const numberOperators: Partial<Record<OperatorID, OperatorDef>>;