@raytio/core 11.5.0 → 11.7.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 (133) hide show
  1. package/README.md +1708 -217
  2. package/dist/accessApplication/api/legacy/convertRelationships.d.ts +3 -5
  3. package/dist/accessApplication/api/legacy/convertRelationships.js +3 -3
  4. package/dist/crypto/cognitoAttributes.d.ts +3 -0
  5. package/dist/crypto/cognitoAttributes.js +15 -4
  6. package/dist/crypto/getAADecryptor.d.ts +1 -1
  7. package/dist/crypto/getAADecryptor.js +1 -3
  8. package/dist/crypto/index.d.ts +3 -0
  9. package/dist/crypto/index.js +6 -0
  10. package/dist/crypto/kdf/argon2.d.ts +67 -0
  11. package/dist/crypto/kdf/argon2.js +99 -0
  12. package/dist/crypto/kdf/index.d.ts +43 -0
  13. package/dist/crypto/kdf/index.js +106 -0
  14. package/dist/crypto/kdf/pbkdf2.d.ts +16 -0
  15. package/dist/crypto/kdf/pbkdf2.js +45 -0
  16. package/dist/crypto/kdf/twoSecretKdf.d.ts +37 -0
  17. package/dist/crypto/kdf/twoSecretKdf.js +66 -0
  18. package/dist/crypto/kdf/types.d.ts +65 -0
  19. package/dist/crypto/kdf/types.js +50 -0
  20. package/dist/crypto/kdf/utils.d.ts +59 -0
  21. package/dist/crypto/kdf/utils.js +110 -0
  22. package/dist/crypto/localSecret/format.d.ts +48 -0
  23. package/dist/crypto/localSecret/format.js +157 -0
  24. package/dist/crypto/localSecret/generator.d.ts +23 -0
  25. package/dist/crypto/localSecret/generator.js +53 -0
  26. package/dist/crypto/localSecret/index.d.ts +12 -0
  27. package/dist/crypto/localSecret/index.js +46 -0
  28. package/dist/crypto/localSecret/storage.d.ts +53 -0
  29. package/dist/crypto/localSecret/storage.js +207 -0
  30. package/dist/crypto/localSecret/types.d.ts +68 -0
  31. package/dist/crypto/localSecret/types.js +31 -0
  32. package/dist/crypto/pgpKey/encryption.d.ts +49 -0
  33. package/dist/crypto/pgpKey/encryption.js +104 -0
  34. package/dist/crypto/pgpKey/export.d.ts +59 -0
  35. package/dist/crypto/pgpKey/export.js +322 -0
  36. package/dist/crypto/pgpKey/format.d.ts +61 -0
  37. package/dist/crypto/pgpKey/format.js +143 -0
  38. package/dist/crypto/pgpKey/generator.d.ts +20 -0
  39. package/dist/crypto/pgpKey/generator.js +76 -0
  40. package/dist/crypto/pgpKey/import.d.ts +69 -0
  41. package/dist/crypto/pgpKey/import.js +239 -0
  42. package/dist/crypto/pgpKey/index.d.ts +19 -0
  43. package/dist/crypto/pgpKey/index.js +67 -0
  44. package/dist/crypto/pgpKey/signing.d.ts +44 -0
  45. package/dist/crypto/pgpKey/signing.js +71 -0
  46. package/dist/crypto/pgpKey/storage.d.ts +43 -0
  47. package/dist/crypto/pgpKey/storage.js +141 -0
  48. package/dist/crypto/pgpKey/types.d.ts +86 -0
  49. package/dist/crypto/pgpKey/types.js +25 -0
  50. package/dist/index.d.ts +1 -0
  51. package/dist/index.js +1 -0
  52. package/dist/rules/calculateScore.d.ts +1 -1
  53. package/dist/rules/convertInstanceToRuleInput.js +99 -97
  54. package/dist/rules/evaluateBadge.d.ts +36 -0
  55. package/dist/rules/evaluateBadge.js +36 -0
  56. package/dist/rules/index.d.ts +1 -0
  57. package/dist/rules/index.js +1 -0
  58. package/dist/rules/types/config.d.ts +1 -1
  59. package/dist/rules/types/dataValueTypes.d.ts +4 -4
  60. package/dist/schema/expandSchema/constants.js +1 -1
  61. package/dist/schema/expandSchema/expandSchema.d.ts +3 -3
  62. package/dist/schema/expandSchema/expandSchema.js +4 -4
  63. package/dist/schema/expandSchema/i18n.d.ts +6 -1
  64. package/dist/schema/expandSchema/i18n.js +32 -4
  65. package/dist/schema/expandSchema/maybeUseI18n.d.ts +2 -2
  66. package/dist/schema/expandSchema/maybeUseI18n.js +68 -11
  67. package/dist/schema/expandSchema/processSchema.js +14 -5
  68. package/dist/schema/expandSchema/removePrivateFields.d.ts +75 -22
  69. package/dist/schema/expandSchema/sortSchemaProperties.d.ts +4 -1
  70. package/dist/schema/expandSchema/sortSchemaProperties.js +24 -1
  71. package/dist/schema/labels.js +1 -2
  72. package/dist/util/canonicalJsonify.d.ts +7 -1
  73. package/dist/util/canonicalJsonify.js +3 -2
  74. package/dist/verifications/safeHarbour.js +5 -0
  75. package/dist/verifications/verifyCheck/getOwnRealVerifications.js +2 -0
  76. package/package.json +6 -4
  77. package/dist/__tests__/docs.test.d.ts +0 -1
  78. package/dist/__tests__/docs.test.js +0 -24
  79. package/dist/accessApplication/api/__tests__/fetchKeysForSubmission.test.d.ts +0 -1
  80. package/dist/accessApplication/api/__tests__/fetchKeysForSubmission.test.js +0 -28
  81. package/dist/accessApplication/api/__tests__/fetchPOsOrAOsForSubmission.test.d.ts +0 -1
  82. package/dist/accessApplication/api/__tests__/fetchPOsOrAOsForSubmission.test.js +0 -23
  83. package/dist/accessApplication/api/__tests__/fetchRelationshipsForSubmission.test.d.ts +0 -1
  84. package/dist/accessApplication/api/__tests__/fetchRelationshipsForSubmission.test.js +0 -27
  85. package/dist/accessApplication/api/__tests__/getMissingDataForInstance.test.d.ts +0 -1
  86. package/dist/accessApplication/api/__tests__/getMissingDataForInstance.test.js +0 -30
  87. package/dist/accessApplication/api/legacy/__tests__/convertRelationships.test.d.ts +0 -1
  88. package/dist/accessApplication/api/legacy/__tests__/convertRelationships.test.js +0 -37
  89. package/dist/rules/helpers/__tests__/addInfiniteThresholdBoundaries.test.d.ts +0 -1
  90. package/dist/rules/helpers/__tests__/addInfiniteThresholdBoundaries.test.js +0 -27
  91. package/dist/rules/helpers/__tests__/checkTypeofValue.test.d.ts +0 -1
  92. package/dist/rules/helpers/__tests__/checkTypeofValue.test.js +0 -49
  93. package/dist/rules/helpers/__tests__/getValuesFromPath.test.d.ts +0 -1
  94. package/dist/rules/helpers/__tests__/getValuesFromPath.test.js +0 -67
  95. package/dist/rules/helpers/__tests__/thresholds.test.d.ts +0 -1
  96. package/dist/rules/helpers/__tests__/thresholds.test.js +0 -32
  97. package/dist/rules/operators/__tests__/bool.test.d.ts +0 -1
  98. package/dist/rules/operators/__tests__/bool.test.js +0 -21
  99. package/dist/rules/operators/__tests__/date.test.d.ts +0 -1
  100. package/dist/rules/operators/__tests__/date.test.js +0 -81
  101. package/dist/rules/operators/__tests__/hfield.test.d.ts +0 -1
  102. package/dist/rules/operators/__tests__/hfield.test.js +0 -38
  103. package/dist/rules/operators/__tests__/hschema.test.d.ts +0 -1
  104. package/dist/rules/operators/__tests__/hschema.test.js +0 -24
  105. package/dist/rules/operators/__tests__/number.test.d.ts +0 -1
  106. package/dist/rules/operators/__tests__/number.test.js +0 -53
  107. package/dist/rules/operators/__tests__/string.test.d.ts +0 -1
  108. package/dist/rules/operators/__tests__/string.test.js +0 -74
  109. package/dist/schema/expandSchema/__tests__/addLoadingTimes.test.d.ts +0 -1
  110. package/dist/schema/expandSchema/__tests__/addLoadingTimes.test.js +0 -24
  111. package/dist/schema/expandSchema/__tests__/expandSchema.test.d.ts +0 -1
  112. package/dist/schema/expandSchema/__tests__/expandSchema.test.js +0 -96
  113. package/dist/schema/expandSchema/__tests__/i18n.test.d.ts +0 -1
  114. package/dist/schema/expandSchema/__tests__/i18n.test.js +0 -32
  115. package/dist/schema/expandSchema/__tests__/maybeUseI18n.test.d.ts +0 -1
  116. package/dist/schema/expandSchema/__tests__/maybeUseI18n.test.js +0 -98
  117. package/dist/schema/expandSchema/__tests__/processSchema.test.d.ts +0 -1
  118. package/dist/schema/expandSchema/__tests__/processSchema.test.js +0 -326
  119. package/dist/schema/expandSchema/__tests__/sortSchemaProperties.test.d.ts +0 -1
  120. package/dist/schema/expandSchema/__tests__/sortSchemaProperties.test.js +0 -182
  121. package/dist/schema/expandSchema/__tests__/util.test.d.ts +0 -1
  122. package/dist/schema/expandSchema/__tests__/util.test.js +0 -19
  123. package/dist/verifications/cleanInstance.d.ts +0 -9
  124. package/dist/verifications/cleanInstance.js +0 -15
  125. package/dist/verifications/verifyCheck/__tests__/getOwnRealVerifications.test.d.ts +0 -1
  126. package/dist/verifications/verifyCheck/__tests__/getOwnRealVerifications.test.js +0 -221
  127. package/dist/verifications/verifyCheck/__tests__/getSomeoneElsesRealVerifications.test.d.ts +0 -1
  128. package/dist/verifications/verifyCheck/__tests__/getSomeoneElsesRealVerifications.test.js +0 -206
  129. package/dist/verifications/verifyCheck/operations/__tests__/checkOwnVerification.test.d.ts +0 -1
  130. package/dist/verifications/verifyCheck/operations/__tests__/checkOwnVerification.test.js +0 -138
  131. package/dist/verifications/verifyCheck/operations/__tests__/checkSomeoneElsesVerifications.test.d.ts +0 -1
  132. package/dist/verifications/verifyCheck/operations/__tests__/checkSomeoneElsesVerifications.test.js +0 -49
  133. package/dist/verifications/verifyCheck/operations/__tests__/sampleBundle.json +0 -44
@@ -1,49 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const types_1 = require("@raytio/types");
4
- const checkTypeofValue_1 = require("../checkTypeofValue");
5
- const symbols_1 = require("../symbols");
6
- const hField = { __typeof__: symbols_1.HFieldSymbol };
7
- const hSchema = { __typeof__: symbols_1.HSchemaSymbol };
8
- describe("checkTypeofValue", () => {
9
- it.each `
10
- val | type | isValid
11
- ${[]} | ${"Array"} | ${true}
12
- ${[]} | ${"Number"} | ${false}
13
- ${false} | ${"Bool"} | ${true}
14
- ${undefined} | ${"Bool"} | ${false}
15
- ${new Date()} | ${"Date"} | ${true}
16
- ${2020} | ${"Date"} | ${false}
17
- ${"Y"} | ${"DateUnit"} | ${true}
18
- ${"y"} | ${"DateUnit"} | ${false}
19
- ${types_1.FieldVerification.Expired} | ${"FieldVerification"} | ${true}
20
- ${12345} | ${"FieldVerification"} | ${false}
21
- ${hField} | ${"HField"} | ${true}
22
- ${{}} | ${"HField"} | ${false}
23
- ${hSchema} | ${"HSchema"} | ${true}
24
- ${{}} | ${"HSchema"} | ${false}
25
- ${123} | ${"Number"} | ${true}
26
- ${types_1.FieldVerification.Expired} | ${"Number"} | ${true}
27
- ${"123"} | ${"Number"} | ${false}
28
- ${types_1.POVerification.Expired} | ${"POVerification"} | ${true}
29
- ${12345} | ${"POVerification"} | ${false}
30
- ${/a/} | ${"RegEx"} | ${true}
31
- ${"/a/"} | ${"RegEx"} | ${false}
32
- ${""} | ${"String"} | ${true}
33
- ${1} | ${"String"} | ${false}
34
- ${""} | ${"Verifier"} | ${true}
35
- ${1} | ${"Verifier"} | ${false}
36
- ${0} | ${"invalidddd"} | ${false}
37
- `("asserts that $val is/isNot $type ($isValid)", ({ val, type, isValid }) => {
38
- expect((0, checkTypeofValue_1.checkTypeofValue)(type, val)).toBe(isValid);
39
- });
40
- });
41
- describe("simplifyValueType", () => {
42
- it.each `
43
- input | output
44
- ${"Verifier"} | ${"String"}
45
- ${"some other value"} | ${"some other value"}
46
- `("can simplify functionally equivalent types ($input -> $output)", ({ input, output }) => {
47
- expect((0, checkTypeofValue_1.simplifyValueType)(input)).toStrictEqual(output);
48
- });
49
- });
@@ -1,67 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const types_1 = require("@raytio/types");
4
- const getValuesFromPath_1 = require("../getValuesFromPath");
5
- const symbols_1 = require("../symbols");
6
- const hSchema = {
7
- __typeof__: symbols_1.HSchemaSymbol,
8
- verification: types_1.POVerification.PartiallyVerified,
9
- verifiedBy: ["Waka Kotahi"],
10
- };
11
- const hField = {
12
- __typeof__: symbols_1.HFieldSymbol,
13
- cameFromSchema: "ss_NZ_DL",
14
- verification: types_1.FieldVerification.Verified,
15
- verifiedBy: ["Waka Kotahi"],
16
- };
17
- const data = {
18
- ["ss_NZ_DL"]: [
19
- {
20
- hSchema,
21
- properties: {
22
- fName: { type: "String", value: "Wolfgang", hField },
23
- age: { type: "Number", value: 19.25, hField },
24
- "address|housenumber": {
25
- type: "Number",
26
- value: 31,
27
- hField: null,
28
- },
29
- "address|street": {
30
- type: "String",
31
- value: "Circular Quay",
32
- hField: null,
33
- },
34
- },
35
- },
36
- ],
37
- };
38
- describe("getValuesFromPath", () => {
39
- it.each `
40
- path | out
41
- ${["field", "ss_NZ_DL", "fName", "value"]} | ${["Wolfgang"]}
42
- ${["field", "ss_NZ_DL", "fName", "valueLength"]} | ${[8]}
43
- ${["field", "ss_NZ_DL", "fName", "meta"]} | ${[hField]}
44
- ${["schema", "ss_NZ_DL", "meta"]} | ${[hSchema]}
45
- ${["field", "ss_NZ_DL", "fakeeee", "value"]} | ${[undefined]}
46
- ${["schema", "fakeeee", "meta"]} | ${[]}
47
- ${["field", "ss_NZ_DL", "address", "subField|street"]} | ${["Circular Quay"]}
48
- ${["field", "ss_NZ_DL", "address", "subField|fakeee"]} | ${[undefined]}
49
- ${["field", "ss_NZ_DL", "address", "subField|"]} | ${[undefined]}
50
- `("can get a value from a valid path ($path)", ({ path, out }) => {
51
- expect((0, getValuesFromPath_1.getValuesFromPath)(path, data)).toStrictEqual(out);
52
- });
53
- it.each `
54
- path | error
55
- ${["jkhsfjkdf"]} | ${"Invalid ValuePath[0] (jkhsfjkdf)"}
56
- ${["schema", "constructor", "meta"]} | ${"Unacceptable object property"}
57
- ${["schema", "ss_NZ_DL", "fakeeee"]} | ${"Invalid ValuePath[2] for schema (fakeeee)"}
58
- ${["schema", "ss_NZ_DL", "constructor", "meta"]} | ${"Unacceptable object property"}
59
- ${["field", "ss_NZ_DL", "fName", "fakeeee"]} | ${"Invalid ValuePath[3] for field (fakeeee)"}
60
- ${["field"]} | ${"Invalid ValuePath[3] for field (undefined)"}
61
- ${["schema"]} | ${"Invalid ValuePath[2] for schema (undefined)"}
62
- ${""} | ${"Invalid ValuePath[0] (undefined)"}
63
- ${["field", "ss_NZ_DL", "age", "valueLength"]} | ${"valueLength may only be used on arrays and strings"}
64
- `("throws an error for invalid paths ($path)", ({ path, error }) => {
65
- expect(() => (0, getValuesFromPath_1.getValuesFromPath)(path, data)).toThrow(new Error(error));
66
- });
67
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const thresholds_1 = require("../thresholds");
4
- describe("getThresholdBoundary", () => {
5
- it("gets the min and max for plus", () => {
6
- expect((0, thresholds_1.getThresholdBoundary)("+", [
7
- { trueWeight: 3, falseWeight: 5 },
8
- { trueWeight: -20, falseWeight: -10 },
9
- ])).toStrictEqual([-17, -5]);
10
- expect((0, thresholds_1.getThresholdBoundary)("+", [
11
- { trueWeight: -7, falseWeight: -8 },
12
- ])).toStrictEqual([-8, -7]);
13
- });
14
- it("gets the min and max for multiply", () => {
15
- expect((0, thresholds_1.getThresholdBoundary)("*", [
16
- { trueWeight: 7, falseWeight: -2 },
17
- { trueWeight: -1, falseWeight: 2 },
18
- { trueWeight: -5, falseWeight: 4 },
19
- ])).toStrictEqual([-70, 56]);
20
- expect((0, thresholds_1.getThresholdBoundary)("*", [
21
- { trueWeight: 7, falseWeight: -2 },
22
- ])).toStrictEqual([-2, 7]);
23
- });
24
- it("works for empty arrays", () => {
25
- expect((0, thresholds_1.getThresholdBoundary)("+", [])).toStrictEqual([0, 0]);
26
- expect((0, thresholds_1.getThresholdBoundary)("*", [])).toStrictEqual([Infinity, -Infinity]);
27
- });
28
- it("throws an error for invalid combinators", () => {
29
- // @ts-expect-error testing invalid input
30
- expect(() => (0, thresholds_1.getThresholdBoundary)("^", [])).toThrow(new Error("Invalid combinator"));
31
- });
32
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const bool_1 = require("../bool");
4
- describe("boolOperators", () => {
5
- it.each `
6
- a | b | result
7
- ${true} | ${true} | ${true}
8
- ${false} | ${true} | ${false}
9
- ${false} | ${false} | ${true}
10
- `("bool_eq $a, $b", ({ a, b, result }) => {
11
- expect(bool_1.boolOperators.bool_eq.implementation(a, b)).toBe(result);
12
- });
13
- it.each `
14
- a | b | result
15
- ${true} | ${true} | ${false}
16
- ${false} | ${true} | ${true}
17
- ${false} | ${false} | ${false}
18
- `("bool_neq $a, $b", ({ a, b, result }) => {
19
- expect(bool_1.boolOperators.bool_neq.implementation(a, b)).toBe(result);
20
- });
21
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,81 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const date_1 = require("../date");
4
- describe("dateOperators", () => {
5
- it.each `
6
- a | b | result
7
- ${new Date("2001-06-06T01:00:00Z")} | ${new Date("2001-06-06T23:59:59Z")} | ${true}
8
- ${new Date("2001-02-02")} | ${new Date("2001-02-03")} | ${false}
9
- `("date_eq $a, $b", ({ a, b, result }) => {
10
- expect(date_1.dateOperators.date_eq.implementation(a, b)).toBe(result);
11
- });
12
- it.each `
13
- a | b | result
14
- ${new Date("2001-06-06T01:00:00Z")} | ${new Date("2001-06-06T23:59:59Z")} | ${false}
15
- ${new Date("2001-02-02")} | ${new Date("2001-02-03")} | ${true}
16
- `("date_neq $a, $b", ({ a, b, result }) => {
17
- expect(date_1.dateOperators.date_neq.implementation(a, b)).toBe(result);
18
- });
19
- it.each `
20
- a | result
21
- ${new Date("2001-01-01")} | ${true}
22
- ${new Date("bobs ur uncle")} | ${false}
23
- `("date_valid $a", ({ a, result }) => {
24
- expect(date_1.dateOperators.date_valid.implementation(a)).toBe(result);
25
- });
26
- it.each `
27
- a | result
28
- ${new Date("2001-01-01")} | ${false}
29
- ${new Date("bobs ur uncle")} | ${true}
30
- `("date_invalid $a", ({ a, result }) => {
31
- expect(date_1.dateOperators.date_invalid.implementation(a)).toBe(result);
32
- });
33
- it.each `
34
- a | b | result
35
- ${new Date("2001-02-02")} | ${new Date("2001-02-03")} | ${true}
36
- ${new Date("2001-01-01")} | ${new Date("1999-01-01")} | ${false}
37
- `("date_before $a, $b", ({ a, b, result }) => {
38
- expect(date_1.dateOperators.date_before.implementation(a, b)).toBe(result);
39
- });
40
- it.each `
41
- a | b | result
42
- ${new Date("2001-02-02")} | ${new Date("2001-02-03")} | ${false}
43
- ${new Date("2001-01-01")} | ${new Date("1999-01-01")} | ${true}
44
- `("date_after $a, $b", ({ a, b, result }) => {
45
- expect(date_1.dateOperators.date_after.implementation(a, b)).toBe(result);
46
- });
47
- it.each `
48
- a | b | c | result
49
- ${new Date("2001")} | ${new Date("2000")} | ${new Date("2002")} | ${true}
50
- ${new Date("2001")} | ${new Date("2005")} | ${new Date("2000")} | ${false}
51
- ${new Date("1900")} | ${new Date("1900")} | ${new Date("1900")} | ${true}
52
- `("date_between $a, $b, $c", ({ a, b, c, result }) => {
53
- expect(date_1.dateOperators.date_between.implementation(a, b, c)).toBe(result);
54
- });
55
- it.each `
56
- date | num | units | result
57
- ${new Date("2010")} | ${10} | ${"Y"} | ${true}
58
- ${new Date("2010")} | ${20} | ${"Y"} | ${false}
59
- ${new Date("2030")} | ${1} | ${"Y"} | ${false}
60
- ${new Date()} | ${1} | ${"ms"} | ${true /* reminaing tests are just for 100% coverage */}
61
- ${new Date()} | ${1} | ${"s"} | ${false}
62
- ${new Date()} | ${1} | ${"m"} | ${false}
63
- ${new Date()} | ${1} | ${"h"} | ${false}
64
- ${new Date()} | ${1} | ${"D"} | ${false}
65
- ${new Date()} | ${1} | ${"W"} | ${false}
66
- ${new Date()} | ${1} | ${"M"} | ${false}
67
- `("date_older_than $date, $num, $units", ({ date, num, units, result }) => {
68
- expect(date_1.dateOperators.date_older_than.implementation(date, num, units)).toBe(result);
69
- });
70
- it("date_older_than (throws an error for an invalid DateUnit)", () => {
71
- expect(() => date_1.dateOperators.date_older_than.implementation(new Date(), 6, "Quaters")).toThrow(new Error("Invalid date unit: Quaters"));
72
- });
73
- it.each `
74
- date | num | units | result
75
- ${new Date("2030")} | ${1} | ${"Y"} | ${true}
76
- ${new Date("2030")} | ${10} | ${"Y"} | ${false}
77
- ${new Date()} | ${1} | ${"h"} | ${false}
78
- `("date_newer_than $date, $num, $units", ({ date, num, units, result }) => {
79
- expect(date_1.dateOperators.date_newer_than.implementation(date, num, units)).toBe(result);
80
- });
81
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,38 +0,0 @@
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
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,24 +0,0 @@
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
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,53 +0,0 @@
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
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,74 +0,0 @@
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,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const addLoadingTimes_1 = require("../addLoadingTimes");
4
- describe("addLoadingTimes", () => {
5
- it("parses loading times from the schema tags", () => {
6
- const schema = {
7
- name: "hi",
8
- tags: [
9
- "a:b",
10
- "c",
11
- "time:action1:20",
12
- "time:action2:5",
13
- "time:action3:0",
14
- "time:action4:not a number",
15
- ],
16
- };
17
- expect((0, addLoadingTimes_1.addLoadingTimes)(schema)).toStrictEqual(Object.assign(Object.assign({}, schema), { timing: {
18
- action1: 20,
19
- action2: 5,
20
- action3: 0,
21
- action4: NaN,
22
- } }));
23
- });
24
- });
@@ -1,96 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const expandSchema_1 = require("../expandSchema");
4
- const fromAPI = [
5
- {
6
- schema_name: "ps_Vessel",
7
- start_date: "1970-01-01T00:00:00+00:00",
8
- end_date: "2222-12-31T23:59:59+00:00",
9
- active: true,
10
- version_current: true,
11
- schema_version: "0.0.7",
12
- schema_type: "ps",
13
- schema: {
14
- $id: "https://api.rayt.io/graph/v1/schema/ps/ps_Vessel",
15
- $schema: "http://json-schema.org/draft-07/schema#",
16
- title: "Vessel/Boat",
17
- description: "A schema that describes a maritime vessel",
18
- i18n: {
19
- "mi-NZ": {
20
- $schema: { title: "Waka" },
21
- vesselName: { title: "nga waka ingoa" },
22
- },
23
- },
24
- tags: ["time:action1:20"],
25
- required: ["vesselName"],
26
- properties: {
27
- manufacture_year: {
28
- allOf: [
29
- { $ref: "#/definitions/ss_birth_year_integer" },
30
- { tags: ["aaa"], priority: 700 },
31
- ],
32
- },
33
- vesselName: { type: "string", title: "Vessel Name", priority: 1000 },
34
- },
35
- definitions: {
36
- ss_birth_year_integer: { $ref: "urn:schema:ss_birth_year_integer" },
37
- },
38
- },
39
- },
40
- {
41
- schema_name: "ss_birth_year_integer",
42
- schema_version: "0.0.1",
43
- schema: {
44
- $id: "this field often has typos. in this case its blatantly wrong",
45
- $schema: "https://whatever",
46
- maximum: 2022,
47
- minimum: 1900,
48
- tags: ["type:globally_unique_field"],
49
- title: "Year of birth",
50
- },
51
- },
52
- ];
53
- describe("expandSchema", () => {
54
- it("can do the entire expansion process", () => {
55
- expect((0, expandSchema_1.expandSchema)(fromAPI[0], fromAPI, ["lb-LU"])).toStrictEqual({
56
- wasExpandedByClient: true,
57
- // $schema was removed
58
- name: "ps_Vessel",
59
- title: "Vessel/Boat",
60
- description: "A schema that describes a maritime vessel",
61
- start_date: "1970-01-01T00:00:00+00:00",
62
- end_date: "2222-12-31T23:59:59+00:00",
63
- version: "0.0.7",
64
- schema_type: "ps",
65
- i18n: fromAPI[0].schema.i18n, // unchanged
66
- isProfileSchema: true,
67
- isSpSchema: false,
68
- properties: {
69
- manufacture_year: {
70
- // $id was removed
71
- $prop: "manufacture_year",
72
- $ref: "ss_birth_year_integer", // it added a $ref tag
73
- maximum: 2022,
74
- minimum: 1900,
75
- title: "Year of birth",
76
- // it merged the allOf into a single object
77
- priority: 700,
78
- tags: ["aaa", "type:globally_unique_field"],
79
- },
80
- vesselName: {
81
- $prop: "vesselName",
82
- // no $ref attribute
83
- priority: 1000,
84
- title: "Vessel Name",
85
- type: "string",
86
- },
87
- },
88
- required: ["vesselName"],
89
- tags: ["time:action1:20"],
90
- timing: {
91
- action1: 20,
92
- },
93
- verified_fields: undefined,
94
- });
95
- });
96
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const i18n_1 = require("../i18n");
4
- const DEFAULT_LOCALES = ["de-DE"]; // match what the client does in vi.setup.ts
5
- describe("getAllLocales", () => {
6
- it("correctly expands languages with a country-componentand lowercases them", () => {
7
- const expanded = (0, i18n_1.getAllLocales)([
8
- "en-NZ",
9
- "de-CH",
10
- "be",
11
- "ar-001",
12
- "az-Cyrl-AZ",
13
- ]);
14
- expect(expanded).toStrictEqual([
15
- "en-nz",
16
- "en",
17
- "de-ch",
18
- "de",
19
- "be",
20
- "ar-001",
21
- "ar",
22
- "az-cyrl-az",
23
- "az",
24
- ]);
25
- });
26
- });
27
- describe("findSuitableLocale", () => {
28
- it("picks the most appropriate option", () => {
29
- // the users's locale is `de-DE`, so it picked the most appropriate one from the options: `de-AT`
30
- expect((0, i18n_1.findSuitableLocale)(["en-029", "de-AT", "fr-FR"], DEFAULT_LOCALES)).toBe("de-AT");
31
- });
32
- });