@raytio/core 11.4.1 → 11.6.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.
- package/CHANGELOG.md +6 -0
- package/README.md +1714 -213
- package/dist/accessApplication/api/legacy/convertRelationships.d.ts +3 -5
- package/dist/accessApplication/api/legacy/convertRelationships.js +3 -3
- package/dist/crypto/cognitoAttributes.d.ts +3 -0
- package/dist/crypto/cognitoAttributes.js +15 -4
- package/dist/crypto/getAADecryptor.d.ts +1 -1
- package/dist/crypto/getAADecryptor.js +1 -3
- package/dist/crypto/index.d.ts +3 -0
- package/dist/crypto/index.js +6 -0
- package/dist/crypto/kdf/argon2.d.ts +67 -0
- package/dist/crypto/kdf/argon2.js +99 -0
- package/dist/crypto/kdf/index.d.ts +43 -0
- package/dist/crypto/kdf/index.js +106 -0
- package/dist/crypto/kdf/pbkdf2.d.ts +16 -0
- package/dist/crypto/kdf/pbkdf2.js +45 -0
- package/dist/crypto/kdf/twoSecretKdf.d.ts +37 -0
- package/dist/crypto/kdf/twoSecretKdf.js +66 -0
- package/dist/crypto/kdf/types.d.ts +65 -0
- package/dist/crypto/kdf/types.js +50 -0
- package/dist/crypto/kdf/utils.d.ts +59 -0
- package/dist/crypto/kdf/utils.js +110 -0
- package/dist/crypto/localSecret/format.d.ts +48 -0
- package/dist/crypto/localSecret/format.js +157 -0
- package/dist/crypto/localSecret/generator.d.ts +23 -0
- package/dist/crypto/localSecret/generator.js +53 -0
- package/dist/crypto/localSecret/index.d.ts +12 -0
- package/dist/crypto/localSecret/index.js +46 -0
- package/dist/crypto/localSecret/storage.d.ts +53 -0
- package/dist/crypto/localSecret/storage.js +207 -0
- package/dist/crypto/localSecret/types.d.ts +68 -0
- package/dist/crypto/localSecret/types.js +31 -0
- package/dist/crypto/pgpKey/encryption.d.ts +49 -0
- package/dist/crypto/pgpKey/encryption.js +104 -0
- package/dist/crypto/pgpKey/export.d.ts +59 -0
- package/dist/crypto/pgpKey/export.js +322 -0
- package/dist/crypto/pgpKey/format.d.ts +61 -0
- package/dist/crypto/pgpKey/format.js +143 -0
- package/dist/crypto/pgpKey/generator.d.ts +20 -0
- package/dist/crypto/pgpKey/generator.js +76 -0
- package/dist/crypto/pgpKey/import.d.ts +69 -0
- package/dist/crypto/pgpKey/import.js +239 -0
- package/dist/crypto/pgpKey/index.d.ts +19 -0
- package/dist/crypto/pgpKey/index.js +67 -0
- package/dist/crypto/pgpKey/signing.d.ts +44 -0
- package/dist/crypto/pgpKey/signing.js +71 -0
- package/dist/crypto/pgpKey/storage.d.ts +43 -0
- package/dist/crypto/pgpKey/storage.js +141 -0
- package/dist/crypto/pgpKey/types.d.ts +86 -0
- package/dist/crypto/pgpKey/types.js +25 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/rules/calculateScore.d.ts +1 -1
- package/dist/rules/convertInstanceToRuleInput.js +99 -97
- package/dist/rules/evaluateBadge.d.ts +36 -0
- package/dist/rules/evaluateBadge.js +36 -0
- package/dist/rules/index.d.ts +1 -0
- package/dist/rules/index.js +1 -0
- package/dist/rules/types/config.d.ts +1 -1
- package/dist/rules/types/dataValueTypes.d.ts +4 -4
- package/dist/schema/expandSchema/constants.js +1 -1
- package/dist/schema/expandSchema/expandSchema.d.ts +3 -3
- package/dist/schema/expandSchema/expandSchema.js +4 -4
- package/dist/schema/expandSchema/i18n.d.ts +6 -1
- package/dist/schema/expandSchema/i18n.js +32 -4
- package/dist/schema/expandSchema/index.d.ts +1 -0
- package/dist/schema/expandSchema/index.js +1 -0
- package/dist/schema/expandSchema/maybeUseI18n.d.ts +2 -2
- package/dist/schema/expandSchema/maybeUseI18n.js +68 -11
- package/dist/schema/expandSchema/processSchema.js +14 -5
- package/dist/schema/expandSchema/removePrivateFields.d.ts +75 -22
- package/dist/schema/expandSchema/sortSchemaProperties.d.ts +4 -1
- package/dist/schema/expandSchema/sortSchemaProperties.js +24 -1
- package/dist/schema/labels.js +1 -2
- package/dist/util/canonicalJsonify.d.ts +7 -1
- package/dist/util/canonicalJsonify.js +11 -10
- package/dist/verifications/safeHarbour.js +5 -0
- package/dist/verifications/verifyCheck/getOwnRealVerifications.js +3 -0
- package/dist/verifications/verifyCheck/getSomeoneElsesRealVerifications.js +1 -0
- package/package.json +6 -4
- package/dist/__tests__/docs.test.d.ts +0 -1
- package/dist/__tests__/docs.test.js +0 -24
- package/dist/accessApplication/api/__tests__/fetchKeysForSubmission.test.d.ts +0 -1
- package/dist/accessApplication/api/__tests__/fetchKeysForSubmission.test.js +0 -28
- package/dist/accessApplication/api/__tests__/fetchPOsOrAOsForSubmission.test.d.ts +0 -1
- package/dist/accessApplication/api/__tests__/fetchPOsOrAOsForSubmission.test.js +0 -23
- package/dist/accessApplication/api/__tests__/fetchRelationshipsForSubmission.test.d.ts +0 -1
- package/dist/accessApplication/api/__tests__/fetchRelationshipsForSubmission.test.js +0 -27
- package/dist/accessApplication/api/__tests__/getMissingDataForInstance.test.d.ts +0 -1
- package/dist/accessApplication/api/__tests__/getMissingDataForInstance.test.js +0 -30
- package/dist/accessApplication/api/legacy/__tests__/convertRelationships.test.d.ts +0 -1
- package/dist/accessApplication/api/legacy/__tests__/convertRelationships.test.js +0 -37
- package/dist/rules/helpers/__tests__/addInfiniteThresholdBoundaries.test.d.ts +0 -1
- package/dist/rules/helpers/__tests__/addInfiniteThresholdBoundaries.test.js +0 -27
- package/dist/rules/helpers/__tests__/checkTypeofValue.test.d.ts +0 -1
- package/dist/rules/helpers/__tests__/checkTypeofValue.test.js +0 -49
- package/dist/rules/helpers/__tests__/getValuesFromPath.test.d.ts +0 -1
- package/dist/rules/helpers/__tests__/getValuesFromPath.test.js +0 -67
- package/dist/rules/helpers/__tests__/thresholds.test.d.ts +0 -1
- package/dist/rules/helpers/__tests__/thresholds.test.js +0 -32
- package/dist/rules/operators/__tests__/bool.test.d.ts +0 -1
- package/dist/rules/operators/__tests__/bool.test.js +0 -21
- package/dist/rules/operators/__tests__/date.test.d.ts +0 -1
- package/dist/rules/operators/__tests__/date.test.js +0 -81
- package/dist/rules/operators/__tests__/hfield.test.d.ts +0 -1
- package/dist/rules/operators/__tests__/hfield.test.js +0 -38
- package/dist/rules/operators/__tests__/hschema.test.d.ts +0 -1
- package/dist/rules/operators/__tests__/hschema.test.js +0 -24
- package/dist/rules/operators/__tests__/number.test.d.ts +0 -1
- package/dist/rules/operators/__tests__/number.test.js +0 -53
- package/dist/rules/operators/__tests__/string.test.d.ts +0 -1
- package/dist/rules/operators/__tests__/string.test.js +0 -74
- package/dist/schema/expandSchema/__tests__/addLoadingTimes.test.d.ts +0 -1
- package/dist/schema/expandSchema/__tests__/addLoadingTimes.test.js +0 -24
- package/dist/schema/expandSchema/__tests__/expandSchema.test.d.ts +0 -1
- package/dist/schema/expandSchema/__tests__/expandSchema.test.js +0 -96
- package/dist/schema/expandSchema/__tests__/i18n.test.d.ts +0 -1
- package/dist/schema/expandSchema/__tests__/i18n.test.js +0 -32
- package/dist/schema/expandSchema/__tests__/maybeUseI18n.test.d.ts +0 -1
- package/dist/schema/expandSchema/__tests__/maybeUseI18n.test.js +0 -98
- package/dist/schema/expandSchema/__tests__/processSchema.test.d.ts +0 -1
- package/dist/schema/expandSchema/__tests__/processSchema.test.js +0 -326
- package/dist/schema/expandSchema/__tests__/sortSchemaProperties.test.d.ts +0 -1
- package/dist/schema/expandSchema/__tests__/sortSchemaProperties.test.js +0 -182
- package/dist/schema/expandSchema/__tests__/util.test.d.ts +0 -1
- package/dist/schema/expandSchema/__tests__/util.test.js +0 -19
- package/dist/verifications/cleanInstance.d.ts +0 -9
- package/dist/verifications/cleanInstance.js +0 -15
- package/dist/verifications/verifyCheck/__tests__/getOwnRealVerifications.test.d.ts +0 -1
- package/dist/verifications/verifyCheck/__tests__/getOwnRealVerifications.test.js +0 -217
- package/dist/verifications/verifyCheck/__tests__/getSomeoneElsesRealVerifications.test.d.ts +0 -1
- package/dist/verifications/verifyCheck/__tests__/getSomeoneElsesRealVerifications.test.js +0 -205
- package/dist/verifications/verifyCheck/operations/__tests__/checkOwnVerification.test.d.ts +0 -1
- package/dist/verifications/verifyCheck/operations/__tests__/checkOwnVerification.test.js +0 -131
- package/dist/verifications/verifyCheck/operations/__tests__/checkSomeoneElsesVerifications.test.d.ts +0 -1
- package/dist/verifications/verifyCheck/operations/__tests__/checkSomeoneElsesVerifications.test.js +0 -49
- package/dist/verifications/verifyCheck/operations/__tests__/sampleBundle.json +0 -44
|
@@ -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
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const maybeUseI18n_1 = require("../maybeUseI18n");
|
|
4
|
-
const DEFAULT_LOCALES = ["de-DE"]; // match what the client does in vi.setup.ts
|
|
5
|
-
describe("maybeUseI18n", () => {
|
|
6
|
-
it("correctly applies schema-wise overrides", () => {
|
|
7
|
-
const originalSchema = {
|
|
8
|
-
schema_group: "old_schemas",
|
|
9
|
-
title: "Default title",
|
|
10
|
-
description: "default desc",
|
|
11
|
-
i18n: {
|
|
12
|
-
"de-de": {
|
|
13
|
-
$schema: {
|
|
14
|
-
title: "der Name dieses Schema",
|
|
15
|
-
description: "eine Beschreibung in Deutsch",
|
|
16
|
-
},
|
|
17
|
-
old_schemas: {
|
|
18
|
-
title_plural: "All the old sChema",
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
const translatedSchema = (0, maybeUseI18n_1.maybeUseI18n)(originalSchema, DEFAULT_LOCALES);
|
|
24
|
-
expect(translatedSchema).toStrictEqual({
|
|
25
|
-
schema_group: "old_schemas",
|
|
26
|
-
group_title: "All the old sChema",
|
|
27
|
-
title: "der Name dieses Schema",
|
|
28
|
-
description: "eine Beschreibung in Deutsch",
|
|
29
|
-
clientLocale: "de-de",
|
|
30
|
-
groupNames: {},
|
|
31
|
-
properties: {},
|
|
32
|
-
i18n: originalSchema.i18n,
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
it("corretly creates a groupNames property with the correct locale", () => {
|
|
36
|
-
const originalSchema = {
|
|
37
|
-
i18n: {
|
|
38
|
-
"en-nz": {
|
|
39
|
-
"group:DoB": { title: "Your date of birth" },
|
|
40
|
-
},
|
|
41
|
-
"fr-fr": {
|
|
42
|
-
"group:DoB": { title: "anniversaire" },
|
|
43
|
-
},
|
|
44
|
-
"de-de": {
|
|
45
|
-
"group:DoB": { title: "dein Geburtstag" },
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
properties: {
|
|
49
|
-
year_of_birth: {
|
|
50
|
-
tags: ["group:DoB"],
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
};
|
|
54
|
-
const translatedSchema = (0, maybeUseI18n_1.maybeUseI18n)(originalSchema, DEFAULT_LOCALES);
|
|
55
|
-
expect(translatedSchema).toStrictEqual({
|
|
56
|
-
clientLocale: "de-de",
|
|
57
|
-
groupNames: {
|
|
58
|
-
DoB: "dein Geburtstag",
|
|
59
|
-
},
|
|
60
|
-
group_title: undefined,
|
|
61
|
-
properties: originalSchema.properties,
|
|
62
|
-
i18n: originalSchema.i18n,
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
it("correctly applies overrides to certain schema fields", () => {
|
|
66
|
-
const originalSchema = {
|
|
67
|
-
i18n: {
|
|
68
|
-
"en-029": {
|
|
69
|
-
year_of_birth: { title: "Your year of birth" },
|
|
70
|
-
},
|
|
71
|
-
de: {
|
|
72
|
-
// also testing whether it utilizes "de" even tho locale is "de-DE"
|
|
73
|
-
year_of_birth: { title: "dein Geburtsjahr", randomProp: 1 },
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
properties: {
|
|
77
|
-
year_of_birth: {
|
|
78
|
-
title: "Default field title",
|
|
79
|
-
tags: ["group:DoB"],
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
};
|
|
83
|
-
const translatedSchema = (0, maybeUseI18n_1.maybeUseI18n)(originalSchema, DEFAULT_LOCALES);
|
|
84
|
-
expect(translatedSchema).toStrictEqual({
|
|
85
|
-
clientLocale: "de", // note how this is 'de', not 'de-de' because the schema defined 'de'
|
|
86
|
-
groupNames: {},
|
|
87
|
-
group_title: undefined,
|
|
88
|
-
properties: {
|
|
89
|
-
year_of_birth: {
|
|
90
|
-
title: "dein Geburtsjahr",
|
|
91
|
-
randomProp: 1,
|
|
92
|
-
tags: ["group:DoB"],
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
i18n: originalSchema.i18n,
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,326 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const processSchema_1 = require("../processSchema");
|
|
4
|
-
describe("processSchema", () => {
|
|
5
|
-
it("should correctly merge properties with a reference", async () => {
|
|
6
|
-
const mock = {
|
|
7
|
-
schema: {
|
|
8
|
-
definitions: {
|
|
9
|
-
firstname: { $ref: "urn:schema:ss_first_name_01" },
|
|
10
|
-
},
|
|
11
|
-
properties: {
|
|
12
|
-
first_name: {
|
|
13
|
-
allOf: [
|
|
14
|
-
{ $ref: "#/definitions/firstname" },
|
|
15
|
-
{
|
|
16
|
-
priority: 10,
|
|
17
|
-
duplicateStringField: "from main schema",
|
|
18
|
-
tags: ["customTag"],
|
|
19
|
-
},
|
|
20
|
-
],
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
-
const allUnexpandedSchema = [
|
|
26
|
-
mock,
|
|
27
|
-
{
|
|
28
|
-
schema_name: "ss_first_name_01",
|
|
29
|
-
schema: {
|
|
30
|
-
properties: {},
|
|
31
|
-
tags: ["a tag from the child"],
|
|
32
|
-
duplicateStringField: "from sub schema",
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
];
|
|
36
|
-
const expected = {
|
|
37
|
-
first_name: {
|
|
38
|
-
$prop: "first_name",
|
|
39
|
-
$ref: "ss_first_name_01",
|
|
40
|
-
priority: 10,
|
|
41
|
-
duplicateStringField: "from main schema",
|
|
42
|
-
tags: ["customTag", "a tag from the child"],
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
expect((0, processSchema_1.processSchema)(mock.schema, allUnexpandedSchema)).toStrictEqual({
|
|
46
|
-
properties: expected,
|
|
47
|
-
required: [],
|
|
48
|
-
tags: [],
|
|
49
|
-
verified_fields: undefined,
|
|
50
|
-
isProfileSchema: false,
|
|
51
|
-
isSpSchema: false,
|
|
52
|
-
definitions: mock.schema.definitions, // removed at a later stage
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
it("should not expand normal properties", async () => {
|
|
56
|
-
const getIdentityToken = vi.fn(async () => { });
|
|
57
|
-
const properties = {
|
|
58
|
-
first_name: {
|
|
59
|
-
priority: 10,
|
|
60
|
-
tags: ["customTag"],
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
const actual = (0, processSchema_1.processSchema)({ properties }, []);
|
|
64
|
-
expect(getIdentityToken).not.toHaveBeenCalled();
|
|
65
|
-
expect(actual).toStrictEqual({
|
|
66
|
-
properties: {
|
|
67
|
-
first_name: {
|
|
68
|
-
$prop: "first_name",
|
|
69
|
-
priority: 10,
|
|
70
|
-
tags: ["customTag"],
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
required: [],
|
|
74
|
-
tags: [],
|
|
75
|
-
verified_fields: undefined,
|
|
76
|
-
isProfileSchema: false,
|
|
77
|
-
isSpSchema: false,
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
it("should correctly expand refs from a schema-wide allOf filter", async () => {
|
|
81
|
-
const mock = {
|
|
82
|
-
schema: {
|
|
83
|
-
required: ["a", "b"],
|
|
84
|
-
definitions: {
|
|
85
|
-
firstname: { $ref: "urn:schema:ss_first_name_01" },
|
|
86
|
-
lastname: { $ref: "urn:schema:ss_last_name_01" },
|
|
87
|
-
},
|
|
88
|
-
allOf: [
|
|
89
|
-
{ $ref: "#/definitions/firstname" },
|
|
90
|
-
{ $ref: "#/definitions/lastname" },
|
|
91
|
-
],
|
|
92
|
-
// note how there are no properties on the schema. this is possible if there is an allOf
|
|
93
|
-
},
|
|
94
|
-
};
|
|
95
|
-
const allUnexpandedSchema = [
|
|
96
|
-
mock,
|
|
97
|
-
{
|
|
98
|
-
schema_name: "ss_first_name_01",
|
|
99
|
-
schema: {
|
|
100
|
-
required: ["c", "d"],
|
|
101
|
-
properties: { first_name: { type: "string" } },
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
schema_name: "ss_last_name_01",
|
|
106
|
-
schema: {
|
|
107
|
-
required: ["e", "f"],
|
|
108
|
-
properties: { last_name: { type: "string" } },
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
|
-
];
|
|
112
|
-
expect((0, processSchema_1.processSchema)(mock.schema, allUnexpandedSchema)).toStrictEqual({
|
|
113
|
-
required: ["a", "b", "c", "d", "e", "f"],
|
|
114
|
-
properties: {
|
|
115
|
-
first_name: { type: "string", $prop: "first_name" },
|
|
116
|
-
last_name: { type: "string", $prop: "last_name" },
|
|
117
|
-
},
|
|
118
|
-
tags: [],
|
|
119
|
-
verified_fields: undefined,
|
|
120
|
-
isProfileSchema: false,
|
|
121
|
-
isSpSchema: false,
|
|
122
|
-
allOf: mock.schema.allOf, // removed later
|
|
123
|
-
definitions: mock.schema.definitions, // removed later
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
it("handles fields that conditionally show", async () => {
|
|
127
|
-
const schema = {
|
|
128
|
-
properties: {},
|
|
129
|
-
allOf: [
|
|
130
|
-
{
|
|
131
|
-
if: { properties: { country: { enum: ["AU"] } } },
|
|
132
|
-
then: {
|
|
133
|
-
required: ["sublocality"],
|
|
134
|
-
properties: { sublocality: { lookup: "AUSTRALIA" } },
|
|
135
|
-
},
|
|
136
|
-
},
|
|
137
|
-
{
|
|
138
|
-
if: { properties: { country: { enum: ["NZ"] } } },
|
|
139
|
-
then: {
|
|
140
|
-
properties: { sublocality: { lookup: "NEW ZEALAND" } },
|
|
141
|
-
},
|
|
142
|
-
},
|
|
143
|
-
],
|
|
144
|
-
};
|
|
145
|
-
expect((0, processSchema_1.processSchema)(schema, [])).toStrictEqual({
|
|
146
|
-
properties: {
|
|
147
|
-
// by default it's not shown
|
|
148
|
-
// it converted the one field into two conditionally shown fields
|
|
149
|
-
"sublocality <=> country=AU": {
|
|
150
|
-
$prop: "sublocality",
|
|
151
|
-
if: { country: ["AU"] },
|
|
152
|
-
lookup: "AUSTRALIA",
|
|
153
|
-
},
|
|
154
|
-
"sublocality <=> country=NZ": {
|
|
155
|
-
$prop: "sublocality",
|
|
156
|
-
if: { country: ["NZ"] },
|
|
157
|
-
lookup: "NEW ZEALAND",
|
|
158
|
-
},
|
|
159
|
-
},
|
|
160
|
-
required: [
|
|
161
|
-
{
|
|
162
|
-
field: "sublocality",
|
|
163
|
-
if: {
|
|
164
|
-
country: ["AU"],
|
|
165
|
-
},
|
|
166
|
-
},
|
|
167
|
-
],
|
|
168
|
-
tags: [],
|
|
169
|
-
verified_fields: undefined,
|
|
170
|
-
isProfileSchema: false,
|
|
171
|
-
isSpSchema: false,
|
|
172
|
-
allOf: schema.allOf,
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
|
-
it("handles fields that conditionally change properties", async () => {
|
|
176
|
-
const schema = {
|
|
177
|
-
properties: { sublocality: { lookup: "NONE" } },
|
|
178
|
-
allOf: [
|
|
179
|
-
{
|
|
180
|
-
if: { properties: { country: { enum: ["AU", "US"] } } },
|
|
181
|
-
then: {
|
|
182
|
-
required: ["sublocality"],
|
|
183
|
-
properties: { sublocality: { lookup: "AUSTRALIA OR US" } },
|
|
184
|
-
},
|
|
185
|
-
},
|
|
186
|
-
{
|
|
187
|
-
if: {
|
|
188
|
-
properties: {
|
|
189
|
-
country: { enum: ["NZ"] },
|
|
190
|
-
island: { enum: ["SouthIsland"] },
|
|
191
|
-
},
|
|
192
|
-
},
|
|
193
|
-
then: {
|
|
194
|
-
properties: {
|
|
195
|
-
sublocality: { lookup: "NEW ZEALAND AND south island" },
|
|
196
|
-
},
|
|
197
|
-
},
|
|
198
|
-
},
|
|
199
|
-
],
|
|
200
|
-
};
|
|
201
|
-
expect((0, processSchema_1.processSchema)(schema, [])).toStrictEqual({
|
|
202
|
-
properties: {
|
|
203
|
-
// it kept the original field but added two conditionally shown fields
|
|
204
|
-
sublocality: {
|
|
205
|
-
$prop: "sublocality",
|
|
206
|
-
lookup: "NONE",
|
|
207
|
-
},
|
|
208
|
-
"sublocality <=> country=AU|US": {
|
|
209
|
-
$prop: "sublocality",
|
|
210
|
-
if: { country: ["AU", "US"] },
|
|
211
|
-
lookup: "AUSTRALIA OR US",
|
|
212
|
-
},
|
|
213
|
-
"sublocality <=> country=NZ & island=SouthIsland": {
|
|
214
|
-
$prop: "sublocality",
|
|
215
|
-
if: { country: ["NZ"], island: ["SouthIsland"] },
|
|
216
|
-
lookup: "NEW ZEALAND AND south island",
|
|
217
|
-
},
|
|
218
|
-
},
|
|
219
|
-
required: [
|
|
220
|
-
{
|
|
221
|
-
field: "sublocality",
|
|
222
|
-
if: { country: ["AU", "US"] },
|
|
223
|
-
},
|
|
224
|
-
],
|
|
225
|
-
tags: [],
|
|
226
|
-
verified_fields: undefined,
|
|
227
|
-
isProfileSchema: false,
|
|
228
|
-
isSpSchema: false,
|
|
229
|
-
allOf: schema.allOf,
|
|
230
|
-
});
|
|
231
|
-
});
|
|
232
|
-
it("handles fields that are conditionally verifiable", async () => {
|
|
233
|
-
const schema = {
|
|
234
|
-
properties: {},
|
|
235
|
-
allOf: [
|
|
236
|
-
{
|
|
237
|
-
if: { properties: { birth_year: { enum: [17, 18] } } },
|
|
238
|
-
then: {
|
|
239
|
-
verified_fields: ["first_name"],
|
|
240
|
-
},
|
|
241
|
-
},
|
|
242
|
-
],
|
|
243
|
-
};
|
|
244
|
-
expect((0, processSchema_1.processSchema)(schema, [])).toStrictEqual({
|
|
245
|
-
properties: {},
|
|
246
|
-
required: [],
|
|
247
|
-
tags: [],
|
|
248
|
-
verified_fields: [{ field: "first_name", if: { birth_year: [17, 18] } }],
|
|
249
|
-
isProfileSchema: false,
|
|
250
|
-
isSpSchema: false,
|
|
251
|
-
allOf: schema.allOf,
|
|
252
|
-
});
|
|
253
|
-
});
|
|
254
|
-
it("makes the whole schema verifiable if there are any conditionally verifiable fields", async () => {
|
|
255
|
-
const schema = {
|
|
256
|
-
properties: {},
|
|
257
|
-
tags: ["abc"],
|
|
258
|
-
allOf: [
|
|
259
|
-
{
|
|
260
|
-
if: { properties: { birth_year: { enum: [17, 18] } } },
|
|
261
|
-
then: {
|
|
262
|
-
tags: ["action:verify", "xyz"],
|
|
263
|
-
},
|
|
264
|
-
},
|
|
265
|
-
],
|
|
266
|
-
};
|
|
267
|
-
expect((0, processSchema_1.processSchema)(schema, [])).toStrictEqual({
|
|
268
|
-
properties: {},
|
|
269
|
-
required: [],
|
|
270
|
-
tags: ["abc", "action:verify"],
|
|
271
|
-
verified_fields: undefined,
|
|
272
|
-
isProfileSchema: false,
|
|
273
|
-
isSpSchema: false,
|
|
274
|
-
allOf: schema.allOf,
|
|
275
|
-
});
|
|
276
|
-
});
|
|
277
|
-
it("handles nested allOfs", async () => {
|
|
278
|
-
const schema = {
|
|
279
|
-
definitions: {
|
|
280
|
-
ref_to_MOE_ID: { $ref: "urn:schema:ss_MOE_ID" },
|
|
281
|
-
},
|
|
282
|
-
properties: {},
|
|
283
|
-
allOf: [
|
|
284
|
-
{
|
|
285
|
-
if: { properties: { country: { enum: ["NZ"] } } },
|
|
286
|
-
then: {
|
|
287
|
-
properties: {
|
|
288
|
-
MOE_ID: {
|
|
289
|
-
allOf: [
|
|
290
|
-
{ $ref: "#/definitions/ref_to_MOE_ID" },
|
|
291
|
-
{ title: "MinEdu ID" },
|
|
292
|
-
],
|
|
293
|
-
},
|
|
294
|
-
},
|
|
295
|
-
},
|
|
296
|
-
},
|
|
297
|
-
],
|
|
298
|
-
};
|
|
299
|
-
const moeSubSchema = {
|
|
300
|
-
schema_name: "ss_MOE_ID",
|
|
301
|
-
schema: {
|
|
302
|
-
type: "number",
|
|
303
|
-
properties: {},
|
|
304
|
-
},
|
|
305
|
-
};
|
|
306
|
-
expect((0, processSchema_1.processSchema)(schema, [schema, moeSubSchema])).toStrictEqual({
|
|
307
|
-
allOf: schema.allOf,
|
|
308
|
-
definitions: schema.definitions,
|
|
309
|
-
isProfileSchema: false,
|
|
310
|
-
isSpSchema: false,
|
|
311
|
-
properties: {
|
|
312
|
-
"MOE_ID <=> country=NZ": {
|
|
313
|
-
$prop: "MOE_ID",
|
|
314
|
-
$ref: "ss_MOE_ID",
|
|
315
|
-
if: { country: ["NZ"] },
|
|
316
|
-
// it merged in props from 3 different places
|
|
317
|
-
title: "MinEdu ID",
|
|
318
|
-
type: "number",
|
|
319
|
-
},
|
|
320
|
-
},
|
|
321
|
-
required: [],
|
|
322
|
-
tags: [],
|
|
323
|
-
verified_fields: undefined,
|
|
324
|
-
});
|
|
325
|
-
});
|
|
326
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|