@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,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,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,182 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const sortSchemaProperties_1 = require("../sortSchemaProperties");
4
- describe("sortSchemaProperties tests", () => {
5
- it("correctly sorts the fields by priority and groups", () => {
6
- const actual = (0, sortSchemaProperties_1.sortSchemaProperties)({
7
- first_name: {
8
- tags: ["group:name"],
9
- priority: 10,
10
- n_id: "first_name",
11
- $prop: "first_name",
12
- },
13
- last_name: {
14
- tags: ["group:name"],
15
- priority: 20,
16
- n_id: "last_name",
17
- $prop: "last_name",
18
- },
19
- gender: {
20
- tags: ["globally_unique_field", "group:gender"],
21
- priority: 5,
22
- n_id: "gender",
23
- $prop: "gender",
24
- },
25
- oof: { priority: 30, n_id: "abc123", $prop: "oof" },
26
- another_field_without_tags_and_no_nid: {
27
- priority: 50,
28
- $prop: "another_field_without_tags_and_no_nid",
29
- },
30
- another_field_without_tags: {
31
- priority: 40,
32
- n_id: "xyz789",
33
- $prop: "another_field_without_tags",
34
- },
35
- middle_name: {
36
- tags: ["group:name"],
37
- priority: 15,
38
- n_id: "middle_name",
39
- $prop: "middle_name",
40
- },
41
- });
42
- const expected = [
43
- {
44
- title: "gender",
45
- items: [
46
- {
47
- $prop: "gender",
48
- priority: 5,
49
- tags: ["globally_unique_field", "group:gender"],
50
- n_id: "gender",
51
- },
52
- ],
53
- },
54
- {
55
- title: "name",
56
- items: [
57
- {
58
- priority: 10,
59
- tags: ["group:name"],
60
- n_id: "first_name",
61
- $prop: "first_name",
62
- },
63
- {
64
- priority: 15,
65
- tags: ["group:name"],
66
- n_id: "middle_name",
67
- $prop: "middle_name",
68
- },
69
- {
70
- priority: 20,
71
- tags: ["group:name"],
72
- n_id: "last_name",
73
- $prop: "last_name",
74
- },
75
- ],
76
- },
77
- {
78
- title: "-notag-common",
79
- items: [
80
- { priority: 30, n_id: "abc123", $prop: "oof" },
81
- { priority: 40, n_id: "xyz789", $prop: "another_field_without_tags" },
82
- { priority: 50, $prop: "another_field_without_tags_and_no_nid" },
83
- ],
84
- },
85
- ];
86
- expect(actual).toStrictEqual(expected);
87
- });
88
- it("Deals with nested data", () => {
89
- const result = (0, sortSchemaProperties_1.sortSchemaProperties)({
90
- id: {
91
- priority: 100,
92
- tags: ["group:provider_product"],
93
- type: "string",
94
- description: "The unique id of the product",
95
- title: "Product ID",
96
- $prop: "id",
97
- },
98
- metadata: {
99
- $prop: "metadata",
100
- properties: {},
101
- items: {
102
- id: {
103
- priority: 100,
104
- tags: ["group:provider_product"],
105
- type: "string",
106
- description: "The unique id of the product",
107
- title: "Product ID",
108
- },
109
- },
110
- type: "object",
111
- title: "Product details",
112
- priority: 300,
113
- tags: ["group:provider_product"],
114
- description: "Additional information about the product",
115
- },
116
- });
117
- expect(result).toStrictEqual([
118
- {
119
- items: [
120
- {
121
- $prop: "id",
122
- description: "The unique id of the product",
123
- priority: 100,
124
- tags: ["group:provider_product"],
125
- title: "Product ID",
126
- type: "string",
127
- },
128
- {
129
- $prop: "metadata",
130
- description: "Additional information about the product",
131
- items: {
132
- id: {
133
- description: "The unique id of the product",
134
- priority: 100,
135
- tags: ["group:provider_product"],
136
- title: "Product ID",
137
- type: "string",
138
- },
139
- },
140
- priority: 300,
141
- properties: {},
142
- tags: ["group:provider_product"],
143
- title: "Product details",
144
- type: "object",
145
- },
146
- ],
147
- title: "provider_product",
148
- },
149
- ]);
150
- });
151
- it("makes use of sub groups within the same group", () => {
152
- const actual = (0, sortSchemaProperties_1.sortSchemaProperties)({
153
- date_of_birth: { $prop: "date_of_birth", tags: ["group:date:birth"] },
154
- month_of_birth: { $prop: "month_of_birth", tags: ["group:date:birth"] },
155
- year_of_birth: { $prop: "year_of_birth", tags: ["group:date:birth"] },
156
- date_of_expiry: { $prop: "date_of_expiry", tags: ["group:date:expiry"] },
157
- month_of_expiry: {
158
- $prop: "month_of_expiry",
159
- tags: ["group:date:expiry"],
160
- },
161
- year_of_expiry: { $prop: "year_of_expiry", tags: ["group:date:expiry"] },
162
- });
163
- expect(actual).toStrictEqual([
164
- {
165
- title: "date:birth",
166
- items: [
167
- { $prop: "date_of_birth", tags: ["group:date:birth"] },
168
- { $prop: "month_of_birth", tags: ["group:date:birth"] },
169
- { $prop: "year_of_birth", tags: ["group:date:birth"] },
170
- ],
171
- },
172
- {
173
- title: "date:expiry",
174
- items: [
175
- { $prop: "date_of_expiry", tags: ["group:date:expiry"] },
176
- { $prop: "month_of_expiry", tags: ["group:date:expiry"] },
177
- { $prop: "year_of_expiry", tags: ["group:date:expiry"] },
178
- ],
179
- },
180
- ]);
181
- });
182
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const util_1 = require("../util");
4
- describe("getConditionId", () => {
5
- it.each `
6
- iff | id
7
- ${{ country: ["NZ"] }} | ${"country=NZ"}
8
- ${{ country: ["NZ", "AU"] }} | ${"country=AU|NZ"}
9
- ${{ country: ["AU", "NZ"] }} | ${"country=AU|NZ"}
10
- ${{ country: ["NZ"], age: [17] }} | ${"age=17 & country=NZ"}
11
- ${{ country: ["NZ"], age: [17, 18] }} | ${"age=17|18 & country=NZ"}
12
- ${{ country: ["NZ", "AU"], age: [17, 18] }} | ${"age=17|18 & country=AU|NZ"}
13
- ${{}} | ${""}
14
- ${{ country: [] }} | ${"country="}
15
- ${{ country: [], age: [] }} | ${"age= & country="}
16
- `("generates IDs ($id)", ({ iff, id }) => {
17
- expect((0, util_1.getConditionId)(iff)).toBe(id);
18
- });
19
- });
@@ -1,9 +0,0 @@
1
- import { Instance } from "@raytio/types";
2
- /**
3
- * The API response from share/v2/access_application/instance/:iId
4
- * returns a complicated hashed_n_id format, so you need to clean up
5
- * the API response using this function as soon as possible.
6
- *
7
- * We relace `hashed_n_id`s with a string `HASHED::{NId}::{AId}`
8
- */
9
- export declare function cleanInstance(instance: Instance): Instance;
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.cleanInstance = void 0;
4
- const ramda_1 = require("ramda");
5
- /**
6
- * The API response from share/v2/access_application/instance/:iId
7
- * returns a complicated hashed_n_id format, so you need to clean up
8
- * the API response using this function as soon as possible.
9
- *
10
- * We relace `hashed_n_id`s with a string `HASHED::{NId}::{AId}`
11
- */
12
- function cleanInstance(instance) {
13
- return Object.assign(Object.assign({}, instance), { profile_objects: instance.profile_objects.map((PO) => (Object.assign(Object.assign({}, (0, ramda_1.omit)(["hashed_n_id"], PO)), { n_id: PO.n_id || `HASHED::${PO.hashed_n_id}::${instance.a_id}` }))) });
14
- }
15
- exports.cleanInstance = cleanInstance;