@raytio/core 11.2.0 → 11.3.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 +4 -0
- package/README.md +119 -30
- package/dist/accessApplication/api/__tests__/fetchKeysForSubmission.test.d.ts +1 -0
- package/dist/accessApplication/api/__tests__/fetchKeysForSubmission.test.js +28 -0
- package/dist/accessApplication/api/__tests__/fetchPOsOrAOsForSubmission.test.d.ts +1 -0
- package/dist/accessApplication/api/__tests__/fetchPOsOrAOsForSubmission.test.js +23 -0
- package/dist/accessApplication/api/__tests__/fetchRelationshipsForSubmission.test.d.ts +1 -0
- package/dist/accessApplication/api/__tests__/fetchRelationshipsForSubmission.test.js +27 -0
- package/dist/accessApplication/api/__tests__/getMissingDataForInstance.test.d.ts +1 -0
- package/dist/accessApplication/api/__tests__/getMissingDataForInstance.test.js +30 -0
- package/dist/accessApplication/api/fetchKeysForSubmission.d.ts +12 -0
- package/dist/accessApplication/api/fetchKeysForSubmission.js +16 -0
- package/dist/accessApplication/api/fetchPOsOrAOsForSubmission.d.ts +6 -0
- package/dist/accessApplication/api/fetchPOsOrAOsForSubmission.js +25 -0
- package/dist/accessApplication/api/fetchRelationshipsForSubmission.d.ts +6 -0
- package/dist/accessApplication/api/fetchRelationshipsForSubmission.js +10 -0
- package/dist/accessApplication/api/getMissingDataForInstance.d.ts +10 -0
- package/dist/accessApplication/api/getMissingDataForInstance.js +28 -0
- package/dist/accessApplication/api/index.d.ts +2 -0
- package/dist/accessApplication/api/index.js +18 -0
- package/dist/accessApplication/api/legacy/__tests__/convertRelationships.test.d.ts +1 -0
- package/dist/accessApplication/api/legacy/__tests__/convertRelationships.test.js +37 -0
- package/dist/accessApplication/api/legacy/convertRelationships.d.ts +16 -0
- package/dist/accessApplication/api/legacy/convertRelationships.js +21 -0
- package/dist/accessApplication/api/legacy/index.d.ts +1 -0
- package/dist/accessApplication/api/legacy/index.js +17 -0
- package/dist/accessApplication/createAA.js +6 -5
- package/dist/accessApplication/index.d.ts +1 -0
- package/dist/accessApplication/index.js +1 -0
- package/dist/crypto/cognitoAttributes.d.ts +1 -1
- package/dist/crypto/decryptSharedData.d.ts +2 -2
- package/dist/crypto/decryptSharedData.js +2 -5
- package/dist/crypto/getAADecryptor.d.ts +18 -3
- package/dist/crypto/getAADecryptor.js +10 -10
- package/dist/crypto/helpers.d.ts +2 -2
- package/dist/general/types.d.ts +9 -0
- package/dist/general/types.js +10 -1
- package/dist/rules/calculateScore.d.ts +1 -1
- package/dist/rules/convertInstanceToRuleInput.d.ts +3 -3
- package/dist/rules/convertInstanceToRuleInput.js +5 -2
- package/dist/rules/evaluateScoreCondition.d.ts +1 -1
- package/dist/rules/helpers/__tests__/getValuesFromPath.test.js +1 -1
- package/dist/rules/helpers/addInfiniteThresholdBoundaries.d.ts +1 -1
- package/dist/rules/helpers/checkTypeofValue.d.ts +1 -1
- package/dist/rules/helpers/getValuesFromPath.d.ts +1 -1
- package/dist/rules/helpers/thresholds.d.ts +1 -1
- package/dist/rules/operators/bool.d.ts +1 -1
- package/dist/rules/operators/date.d.ts +1 -1
- package/dist/rules/operators/hfield.d.ts +1 -1
- package/dist/rules/operators/hschema.d.ts +1 -1
- package/dist/rules/operators/index.d.ts +1 -1
- package/dist/rules/operators/number.d.ts +1 -1
- package/dist/rules/operators/string.d.ts +1 -1
- package/dist/rules/types/config.d.ts +4 -3
- package/dist/rules/types/dataValueTypes.d.ts +2 -3
- package/dist/rules/types/internal.d.ts +4 -3
- package/dist/rules/validate.d.ts +2 -2
- package/dist/schema/expandSchema/__tests__/expandSchema.test.js +2 -2
- package/dist/schema/expandSchema/__tests__/i18n.test.js +1 -1
- package/dist/schema/expandSchema/__tests__/maybeUseI18n.test.js +2 -2
- package/dist/schema/expandSchema/__tests__/processSchema.test.js +2 -2
- package/dist/schema/expandSchema/addLoadingTimes.d.ts +1 -1
- package/dist/schema/expandSchema/constants.d.ts +1 -1
- package/dist/schema/expandSchema/expandSchema.d.ts +1 -1
- package/dist/schema/expandSchema/maybeUseI18n.d.ts +1 -1
- package/dist/schema/expandSchema/processSchema.d.ts +1 -1
- package/dist/schema/expandSchema/removePrivateFields.d.ts +5 -5
- package/dist/schema/expandSchema/sortSchemaProperties.d.ts +3 -3
- package/dist/schema/expandSchema/unwrapSchema.d.ts +2 -6
- package/dist/schema/labels.d.ts +2 -1
- package/dist/testHelpers.d.ts +2 -2
- package/dist/verifications/cleanInstance.d.ts +1 -1
- package/dist/verifications/getPOVerification.d.ts +1 -1
- package/dist/verifications/index.d.ts +0 -1
- package/dist/verifications/index.js +0 -1
- package/dist/verifications/safeHarbour.d.ts +2 -2
- package/dist/verifications/verifyCheck/__tests__/getOwnRealVerifications.test.js +3 -3
- package/dist/verifications/verifyCheck/__tests__/getSomeoneElsesRealVerifications.test.js +2 -2
- package/dist/verifications/verifyCheck/getOwnRealVerifications.d.ts +1 -1
- package/dist/verifications/verifyCheck/getSomeoneElsesRealVerifications.d.ts +1 -1
- package/dist/verifications/verifyCheck/getSomeoneElsesRealVerifications.js +1 -1
- package/dist/verifications/verifyCheck/operations/__tests__/checkOwnVerification.test.js +1 -1
- package/dist/verifications/verifyCheck/operations/__tests__/checkSomeoneElsesVerifications.test.js +2 -2
- package/dist/verifications/verifyCheck/operations/checkOwnVerification.d.ts +1 -1
- package/dist/verifications/verifyCheck/operations/checkOwnVerification.js +2 -0
- package/package.json +6 -42
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./convertRelationships"), exports);
|
|
@@ -15,12 +15,13 @@ const createApplicationPublicKey = async ({ apiUrl, apiToken, aId, publicKey, })
|
|
|
15
15
|
body: JSON.stringify({ a_id: aId, key: publicKey }),
|
|
16
16
|
headers: { Authorization: `Bearer ${apiToken}` },
|
|
17
17
|
}).then(util_1.handleResponse);
|
|
18
|
-
|
|
18
|
+
// temporary typecast until this API is updated
|
|
19
|
+
return { publicKeyId: PO.n_id };
|
|
19
20
|
};
|
|
20
21
|
/** @internal */
|
|
21
|
-
const createApplicationEncryptedPrivateKey = ({ apiUrl, apiToken,
|
|
22
|
+
const createApplicationEncryptedPrivateKey = ({ apiUrl, apiToken, publicKeyId, encryptedPrivateKey, }) => fetch(`${apiUrl}/share/v2/access_application/public_key/${publicKeyId}/private_key`, {
|
|
22
23
|
method: "POST",
|
|
23
|
-
body: JSON.stringify({ n_id:
|
|
24
|
+
body: JSON.stringify({ n_id: publicKeyId, key: encryptedPrivateKey }),
|
|
24
25
|
headers: { Authorization: `Bearer ${apiToken}` },
|
|
25
26
|
}).then(util_1.handleResponse);
|
|
26
27
|
/** @internal */
|
|
@@ -54,7 +55,7 @@ async function createAA({ apiUrl, apiToken, userDoc, maxcryptor, application, })
|
|
|
54
55
|
application,
|
|
55
56
|
});
|
|
56
57
|
const { publicKey, encryptedPrivateKey } = await createApplicationEncryptor(userDoc, maxcryptor);
|
|
57
|
-
const {
|
|
58
|
+
const { publicKeyId } = await createApplicationPublicKey({
|
|
58
59
|
apiUrl,
|
|
59
60
|
apiToken,
|
|
60
61
|
aId: newApp.a_id,
|
|
@@ -63,7 +64,7 @@ async function createAA({ apiUrl, apiToken, userDoc, maxcryptor, application, })
|
|
|
63
64
|
await createApplicationEncryptedPrivateKey({
|
|
64
65
|
apiUrl,
|
|
65
66
|
apiToken,
|
|
66
|
-
|
|
67
|
+
publicKeyId,
|
|
67
68
|
encryptedPrivateKey,
|
|
68
69
|
});
|
|
69
70
|
return newApp;
|
|
@@ -14,4 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./api"), exports);
|
|
17
18
|
__exportStar(require("./createAA"), exports);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Encrypted, Instance } from "@raytio/types";
|
|
1
|
+
import type { ApplicationEncryptor, Maxcryptor } from "@raytio/maxcryptor";
|
|
2
|
+
import type { Encrypted, Instance } from "@raytio/types";
|
|
3
3
|
/**
|
|
4
4
|
* Decrypts any encrypted properties included in the supplied `instanceData`.
|
|
5
5
|
* If nothing is encrypted the supplied `instanceData` is returned.
|
|
@@ -15,16 +15,13 @@ const decryptKeys_1 = require("./decryptKeys");
|
|
|
15
15
|
*/
|
|
16
16
|
const decryptSharedData = async ({ instanceData, maxcryptor, apiUrl, apiToken, onCorruptedData, }) => {
|
|
17
17
|
const { decryptor: applicationDecryptor } = await (0, getAADecryptor_1.getAADecryptor)({
|
|
18
|
-
aId: instanceData.
|
|
18
|
+
aId: instanceData.aa_id,
|
|
19
19
|
maxcryptor,
|
|
20
20
|
apiUrl,
|
|
21
21
|
apiToken,
|
|
22
22
|
});
|
|
23
23
|
const instance = Object.assign(Object.assign({}, instanceData), { profile_objects: await Promise.all(instanceData.profile_objects.map(async (PO) => {
|
|
24
|
-
const
|
|
25
|
-
? PO.n_id.split("::")[1]
|
|
26
|
-
: PO.n_id;
|
|
27
|
-
const keys = instanceData.keys[realNId];
|
|
24
|
+
const keys = instanceData.keys[PO.id];
|
|
28
25
|
const decryptedProperties = await (0, decryptKeys_1.decryptKeys)({
|
|
29
26
|
applicationDecryptor,
|
|
30
27
|
keys,
|
|
@@ -1,5 +1,19 @@
|
|
|
1
|
-
import { ApplicationEncryptor, Maxcryptor } from "@raytio/maxcryptor";
|
|
2
|
-
import {
|
|
1
|
+
import type { ApplicationEncryptor, Maxcryptor } from "@raytio/maxcryptor";
|
|
2
|
+
import type { AId, CommonFields as CommonNodeFields, KId } from "@raytio/types";
|
|
3
|
+
type PublicKeyNode = CommonNodeFields<KId> & {
|
|
4
|
+
public_key_name: string;
|
|
5
|
+
public_key_description: string;
|
|
6
|
+
public_key: JsonWebKey;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Fetches the Public Key Information for an Access Application
|
|
10
|
+
* @returns the id and Key information of the Applications Public Key
|
|
11
|
+
*/
|
|
12
|
+
export declare function getAAPublicKey({ apiUrl, apiToken, aId, }: {
|
|
13
|
+
apiUrl: string;
|
|
14
|
+
apiToken: string;
|
|
15
|
+
aId: AId;
|
|
16
|
+
}): Promise<PublicKeyNode>;
|
|
3
17
|
/**
|
|
4
18
|
* Fetchs the public and private keys for an Access Application, then initializes
|
|
5
19
|
* the {@link https://npm.im/@raytio/maxcryptor|Maxcryptor}'s `ApplicationEncryptor`.
|
|
@@ -12,5 +26,6 @@ export declare function getAADecryptor({ aId, apiUrl, maxcryptor, apiToken, }: {
|
|
|
12
26
|
apiToken: string;
|
|
13
27
|
}): Promise<{
|
|
14
28
|
decryptor: ApplicationEncryptor;
|
|
15
|
-
|
|
29
|
+
publicKeyId: KId;
|
|
16
30
|
}>;
|
|
31
|
+
export {};
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAADecryptor = void 0;
|
|
3
|
+
exports.getAADecryptor = exports.getAAPublicKey = void 0;
|
|
4
4
|
const util_1 = require("../util");
|
|
5
5
|
/**
|
|
6
6
|
* Fetches the Public Key Information for an Access Application
|
|
7
7
|
* @returns the id and Key information of the Applications Public Key
|
|
8
8
|
*/
|
|
9
|
-
async function
|
|
9
|
+
async function getAAPublicKey({ apiUrl, apiToken, aId, }) {
|
|
10
10
|
const [publicKey] = await fetch(`${apiUrl}/db/v1/dsm_access_application_public_keys?aa_id=eq.${aId}`, {
|
|
11
11
|
headers: { Authorization: `Bearer ${apiToken}` },
|
|
12
12
|
}).then(util_1.handleResponse);
|
|
13
13
|
if (!publicKey) {
|
|
14
14
|
throw new Error("Could not Find Encryption Key");
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
return { n_id: id, properties: public_key };
|
|
16
|
+
return publicKey;
|
|
18
17
|
}
|
|
18
|
+
exports.getAAPublicKey = getAAPublicKey;
|
|
19
19
|
/**
|
|
20
20
|
* Fetches the Private Key Information from a Public Key
|
|
21
21
|
* @returns An encrypted Private Key
|
|
22
22
|
*/
|
|
23
|
-
async function fetchPrivateKey({ apiUrl, apiToken,
|
|
24
|
-
const [privateKey] = await fetch(`${apiUrl}/db/v1/dsm_access_application_private_keys?aack_id=eq.${
|
|
23
|
+
async function fetchPrivateKey({ apiUrl, apiToken, publicKeyId, }) {
|
|
24
|
+
const [privateKey] = await fetch(`${apiUrl}/db/v1/dsm_access_application_private_keys?aack_id=eq.${publicKeyId}`, { headers: { Authorization: `Bearer ${apiToken}` } }).then(util_1.handleResponse);
|
|
25
25
|
return privateKey.encrypted_private_key;
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
@@ -30,19 +30,19 @@ async function fetchPrivateKey({ apiUrl, apiToken, publicKeyNId, }) {
|
|
|
30
30
|
* @returns an `ApplicationEncryptor` and the public key of the Access Application
|
|
31
31
|
*/
|
|
32
32
|
async function getAADecryptor({ aId, apiUrl, maxcryptor, apiToken, }) {
|
|
33
|
-
const {
|
|
33
|
+
const { id: publicKeyId, public_key: publicKey } = await getAAPublicKey({
|
|
34
34
|
apiUrl,
|
|
35
35
|
apiToken,
|
|
36
36
|
aId,
|
|
37
|
-
})
|
|
37
|
+
});
|
|
38
38
|
const privateKey = await fetchPrivateKey({
|
|
39
39
|
apiUrl,
|
|
40
40
|
apiToken,
|
|
41
|
-
|
|
41
|
+
publicKeyId,
|
|
42
42
|
});
|
|
43
43
|
return {
|
|
44
44
|
decryptor: await maxcryptor.loadApplicationEncryptorForDecryption(publicKey, privateKey),
|
|
45
|
-
|
|
45
|
+
publicKeyId,
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
48
|
exports.getAADecryptor = getAADecryptor;
|
package/dist/crypto/helpers.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Encrypted } from "@raytio/types";
|
|
1
|
+
import type { Encrypted } from "@raytio/types";
|
|
2
2
|
/**
|
|
3
3
|
* Determines where the input is an encrypted Raytio object
|
|
4
4
|
* @param value anything
|
|
@@ -15,4 +15,4 @@ export declare const isEncryptedFile: (value: unknown) => value is Encrypted;
|
|
|
15
15
|
* Given a profile object's properties, returns the number
|
|
16
16
|
* of properties that are encryted.
|
|
17
17
|
*/
|
|
18
|
-
export declare const someEncrypted: <T extends object
|
|
18
|
+
export declare const someEncrypted: <T extends object>(obj: T) => number;
|
package/dist/general/types.d.ts
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
|
+
import type { AId, NId } from "@raytio/types";
|
|
1
2
|
/**
|
|
2
3
|
* to prevent a key from the JS object prototype (e.g. `__proto__`) from
|
|
3
4
|
* returning an unexpected value (see #1162)
|
|
4
5
|
* @ignore
|
|
5
6
|
*/
|
|
6
7
|
export declare function assertSafeProperty(key: string): asserts key is string;
|
|
8
|
+
/**
|
|
9
|
+
* the API returns hashed {@link NId}s in a separate field,
|
|
10
|
+
* which breaks the whole app. So, we move the hashed ID into
|
|
11
|
+
* the normal `n_id` field, and use a different format.
|
|
12
|
+
*
|
|
13
|
+
* This was first introduced in #1048
|
|
14
|
+
*/
|
|
15
|
+
export declare const createHashedNId: (nId: NId, aId: AId) => NId;
|
package/dist/general/types.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.assertSafeProperty = void 0;
|
|
3
|
+
exports.createHashedNId = exports.assertSafeProperty = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* to prevent a key from the JS object prototype (e.g. `__proto__`) from
|
|
6
6
|
* returning an unexpected value (see #1162)
|
|
@@ -11,3 +11,12 @@ function assertSafeProperty(key) {
|
|
|
11
11
|
throw new Error("Unacceptable object property");
|
|
12
12
|
}
|
|
13
13
|
exports.assertSafeProperty = assertSafeProperty;
|
|
14
|
+
/**
|
|
15
|
+
* the API returns hashed {@link NId}s in a separate field,
|
|
16
|
+
* which breaks the whole app. So, we move the hashed ID into
|
|
17
|
+
* the normal `n_id` field, and use a different format.
|
|
18
|
+
*
|
|
19
|
+
* This was first introduced in #1048
|
|
20
|
+
*/
|
|
21
|
+
const createHashedNId = (nId, aId) => `HASHED::${nId}::${aId}`;
|
|
22
|
+
exports.createHashedNId = createHashedNId;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RuleData, ScoreConfig, ScoreRule } from "./types";
|
|
1
|
+
import type { RuleData, ScoreConfig, ScoreRule } from "./types";
|
|
2
2
|
/** evaluates an individual rule, normally you should use {@link calculateScore} */
|
|
3
3
|
export declare function evaluateRule(rule: ScoreRule, data: RuleData): {
|
|
4
4
|
passed: boolean;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ProfileObject, RealVer, Schema } from "@raytio/types";
|
|
2
|
-
import { RuleData } from "./types";
|
|
3
|
-
export declare const convertInstanceToRuleInput: (POs: ProfileObject[], realVers: RealVer[], getSchema: (schemaName:
|
|
1
|
+
import type { ProfileObject, RealVer, Schema, SchemaName } from "@raytio/types";
|
|
2
|
+
import type { RuleData } from "./types";
|
|
3
|
+
export declare const convertInstanceToRuleInput: (POs: ProfileObject[], realVers: RealVer[], getSchema: (schemaName: SchemaName) => Promise<Schema>) => Promise<RuleData>;
|
|
@@ -60,8 +60,11 @@ const convertInstanceToRuleInput = async (POs, realVers, getSchema) => {
|
|
|
60
60
|
});
|
|
61
61
|
const dateFieldByCategorys = (0, ramda_1.groupBy)(([fieldName]) => schema.properties[fieldName].tags.find(tag => tag.startsWith("group:date_picker")), validFields.filter(isDateField(schema)));
|
|
62
62
|
// the three date fields become one pseudo field for the score system
|
|
63
|
-
const pseudoDateFields = Object.entries(dateFieldByCategorys).map(([groupTag,
|
|
63
|
+
const pseudoDateFields = Object.entries(dateFieldByCategorys).map(([groupTag, _members]) => {
|
|
64
64
|
var _a;
|
|
65
|
+
// obviously this won't be undefined since we're
|
|
66
|
+
// looping through the object.
|
|
67
|
+
const members = _members;
|
|
65
68
|
const groupName = groupTag.split(":")[2] || "NO_NAME";
|
|
66
69
|
const memberFieldNames = members.map(x => x[0]);
|
|
67
70
|
const worstVer = (0, ramda_1.sort)((a, b) => b - a, // find the highest enum value (that's the worst)
|
|
@@ -108,7 +111,7 @@ const convertInstanceToRuleInput = async (POs, realVers, getSchema) => {
|
|
|
108
111
|
return subFields.map(subFieldName => {
|
|
109
112
|
const value = fieldValue[subFieldName];
|
|
110
113
|
const hsubfield = {
|
|
111
|
-
hField: null,
|
|
114
|
+
hField: null, // you can't access metadata on a subfield
|
|
112
115
|
type: getTypeofFieldValue(value),
|
|
113
116
|
value,
|
|
114
117
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ASTScoreConditionNode, RuleData } from "./types";
|
|
1
|
+
import type { ASTScoreConditionNode, RuleData } from "./types";
|
|
2
2
|
export declare function evaluateScoreCondition(node: ASTScoreConditionNode, data: RuleData): boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GetTSType, ValueType } from "../types";
|
|
1
|
+
import { type GetTSType, type ValueType } from "../types";
|
|
2
2
|
/** asserts that the provided `value` meets the constaints of `type` */
|
|
3
3
|
export declare function checkTypeofValue<T extends ValueType>(type: T, value: unknown): value is GetTSType<T>;
|
|
4
4
|
/**
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { RuleData, ValuePath } from "../types";
|
|
1
|
+
import type { RuleData, ValuePath } from "../types";
|
|
2
2
|
/** this returns an array because there might be multiple of the same schema shared */
|
|
3
3
|
export declare function getValuesFromPath(path: ValuePath, data: RuleData): unknown[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { OperatorDef, OperatorID } from "../types";
|
|
2
2
|
export declare const boolOperators: Partial<Record<OperatorID, OperatorDef>>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { OperatorDef, OperatorID } from "../types";
|
|
2
2
|
export declare const dateOperators: Partial<Record<OperatorID, OperatorDef>>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { OperatorDef, OperatorID } from "../types";
|
|
2
2
|
export declare const fieldOperators: Partial<Record<OperatorID, OperatorDef>>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { OperatorDef, OperatorID } from "../types";
|
|
2
2
|
export declare const schemaOperators: Partial<Record<OperatorID, OperatorDef>>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { OperatorDef, OperatorID } from "../types";
|
|
2
2
|
export declare const numberOperators: Partial<Record<OperatorID, OperatorDef>>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { OperatorDef, OperatorID } from "../types";
|
|
2
2
|
export declare const stringOperators: Partial<Record<OperatorID, OperatorDef>>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { SchemaName } from "@raytio/types";
|
|
2
|
+
import type { GetTSType } from "./dataValueTypes";
|
|
2
3
|
/**
|
|
3
4
|
* @ignore
|
|
4
5
|
* these are just IDs, the string is never parsed by anything.
|
|
@@ -11,9 +12,9 @@ export type OperatorID = "bool_eq" | "bool_neq" | "num_eq" | "num_neq" | "num_lt
|
|
|
11
12
|
/** @ignore */
|
|
12
13
|
export type ValuePathFieldProp = "meta" | "value" | "valueLength" | `subField|${string}`;
|
|
13
14
|
/** @ignore */
|
|
14
|
-
export type ValuePath = [type: "schema", schemaName:
|
|
15
|
+
export type ValuePath = [type: "schema", schemaName: SchemaName, prop: "meta"] | [
|
|
15
16
|
type: "field",
|
|
16
|
-
schemaName:
|
|
17
|
+
schemaName: SchemaName,
|
|
17
18
|
fieldName: string,
|
|
18
19
|
prop: ValuePathFieldProp
|
|
19
20
|
];
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { FieldVerification, NId, POVerification } from "@raytio/types";
|
|
1
|
+
import type { FieldVerification, NId, POVerification, SchemaName } from "@raytio/types";
|
|
2
2
|
import type { HFieldSymbol, HSchemaSymbol } from "../helpers";
|
|
3
3
|
/** undefined if not shared */
|
|
4
4
|
export type HField = {
|
|
5
5
|
__typeof__: typeof HFieldSymbol;
|
|
6
6
|
verification: FieldVerification;
|
|
7
7
|
verifiedBy: readonly NId[];
|
|
8
|
-
|
|
9
|
-
cameFromSchema: string;
|
|
8
|
+
cameFromSchema: SchemaName;
|
|
10
9
|
};
|
|
11
10
|
/** undefined if not shared */
|
|
12
11
|
export type HSchema = {
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { SchemaName } from "@raytio/types";
|
|
2
|
+
import type { GetTSType, HField, HSchema } from "./dataValueTypes";
|
|
3
|
+
import type { FieldValueTypes, ValueType } from "./config";
|
|
3
4
|
export type RuleDataProperty<T extends FieldValueTypes> = {
|
|
4
5
|
type: T;
|
|
5
6
|
value: GetTSType<T>;
|
|
6
7
|
hField: HField;
|
|
7
8
|
};
|
|
8
9
|
export type RuleData = {
|
|
9
|
-
[schemaName:
|
|
10
|
+
[schemaName: SchemaName]: {
|
|
10
11
|
hSchema: HSchema;
|
|
11
12
|
properties: {
|
|
12
13
|
[fieldName: string]: RuleDataProperty<FieldValueTypes>;
|
package/dist/rules/validate.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ScoreResult } from "./calculateScore";
|
|
2
|
-
import { ScoreConfig } from "./types";
|
|
1
|
+
import type { ScoreResult } from "./calculateScore";
|
|
2
|
+
import type { ScoreConfig } from "./types";
|
|
3
3
|
/** determines whether a `ScoreResult` object is valid */
|
|
4
4
|
export declare const isScoreResultValid: (x: unknown) => x is ScoreResult;
|
|
5
5
|
/** determines whether a `ScoreConfig` object is valid */
|
|
@@ -62,14 +62,14 @@ describe("expandSchema", () => {
|
|
|
62
62
|
end_date: "2222-12-31T23:59:59+00:00",
|
|
63
63
|
version: "0.0.7",
|
|
64
64
|
schema_type: "ps",
|
|
65
|
-
i18n: fromAPI[0].schema.i18n,
|
|
65
|
+
i18n: fromAPI[0].schema.i18n, // unchanged
|
|
66
66
|
isProfileSchema: true,
|
|
67
67
|
isSpSchema: false,
|
|
68
68
|
properties: {
|
|
69
69
|
manufacture_year: {
|
|
70
70
|
// $id was removed
|
|
71
71
|
$prop: "manufacture_year",
|
|
72
|
-
$ref: "ss_birth_year_integer",
|
|
72
|
+
$ref: "ss_birth_year_integer", // it added a $ref tag
|
|
73
73
|
maximum: 2022,
|
|
74
74
|
minimum: 1900,
|
|
75
75
|
title: "Year of birth",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const i18n_1 = require("../i18n");
|
|
4
|
-
const DEFAULT_LOCALES = ["de-DE"]; // match what the client does in
|
|
4
|
+
const DEFAULT_LOCALES = ["de-DE"]; // match what the client does in vi.setup.ts
|
|
5
5
|
describe("getAllLocales", () => {
|
|
6
6
|
it("correctly expands languages with a country-componentand lowercases them", () => {
|
|
7
7
|
const expanded = (0, i18n_1.getAllLocales)([
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const maybeUseI18n_1 = require("../maybeUseI18n");
|
|
4
|
-
const DEFAULT_LOCALES = ["de-DE"]; // match what the client does in
|
|
4
|
+
const DEFAULT_LOCALES = ["de-DE"]; // match what the client does in vi.setup.ts
|
|
5
5
|
describe("maybeUseI18n", () => {
|
|
6
6
|
it("correctly applies schema-wise overrides", () => {
|
|
7
7
|
const originalSchema = {
|
|
@@ -82,7 +82,7 @@ describe("maybeUseI18n", () => {
|
|
|
82
82
|
};
|
|
83
83
|
const translatedSchema = (0, maybeUseI18n_1.maybeUseI18n)(originalSchema, DEFAULT_LOCALES);
|
|
84
84
|
expect(translatedSchema).toStrictEqual({
|
|
85
|
-
clientLocale: "de",
|
|
85
|
+
clientLocale: "de", // note how this is 'de', not 'de-de' because the schema defined 'de'
|
|
86
86
|
groupNames: {},
|
|
87
87
|
group_title: undefined,
|
|
88
88
|
properties: {
|
|
@@ -53,7 +53,7 @@ describe("processSchema", () => {
|
|
|
53
53
|
});
|
|
54
54
|
});
|
|
55
55
|
it("should not expand normal properties", async () => {
|
|
56
|
-
const getIdentityToken =
|
|
56
|
+
const getIdentityToken = vi.fn(async () => { });
|
|
57
57
|
const properties = {
|
|
58
58
|
first_name: {
|
|
59
59
|
priority: 10,
|
|
@@ -119,7 +119,7 @@ describe("processSchema", () => {
|
|
|
119
119
|
verified_fields: undefined,
|
|
120
120
|
isProfileSchema: false,
|
|
121
121
|
isSpSchema: false,
|
|
122
|
-
allOf: mock.schema.allOf,
|
|
122
|
+
allOf: mock.schema.allOf, // removed later
|
|
123
123
|
definitions: mock.schema.definitions, // removed later
|
|
124
124
|
});
|
|
125
125
|
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Schema } from "@raytio/types";
|
|
1
|
+
import type { Schema } from "@raytio/types";
|
|
2
2
|
export declare const addLoadingTimes: (schema: Schema) => Schema;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { SchemaTag } from "@raytio/types";
|
|
1
|
+
import type { SchemaTag } from "@raytio/types";
|
|
2
2
|
export declare const TAG_DENYLIST: SchemaTag[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Schema } from "@raytio/types";
|
|
1
|
+
import type { Schema } from "@raytio/types";
|
|
2
2
|
export declare const maybeUseI18n: (schema: Schema, userLocales: readonly string[]) => Schema;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Schema, WrappedSchema } from "@raytio/types";
|
|
1
|
+
import type { Schema, WrappedSchema } from "@raytio/types";
|
|
2
2
|
import type { unwrapSchema } from "./unwrapSchema";
|
|
3
3
|
export declare const processSchema: (schema: ReturnType<typeof unwrapSchema>, allUnexpandedSchemas: WrappedSchema[]) => Schema;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Schema } from "@raytio/types";
|
|
1
|
+
import type { Schema } from "@raytio/types";
|
|
2
2
|
export declare const removePrivateFields: (schema: Schema) => {
|
|
3
3
|
properties: Record<string, Omit<import("@raytio/types").SchemaField, "$id" | "allOf" | "$schema" | "definitions">>;
|
|
4
4
|
title: string;
|
|
@@ -59,8 +59,8 @@ export declare const removePrivateFields: (schema: Schema) => {
|
|
|
59
59
|
direction: "from";
|
|
60
60
|
type: string;
|
|
61
61
|
required_relationship?: boolean | undefined;
|
|
62
|
-
oneOf?:
|
|
63
|
-
anyOf?:
|
|
62
|
+
oneOf?: (import("@raytio/types").SchemaName | "instance")[] | undefined;
|
|
63
|
+
anyOf?: import("@raytio/types").SchemaName[] | undefined;
|
|
64
64
|
multiple?: boolean | undefined;
|
|
65
65
|
properties?: {
|
|
66
66
|
[fieldName: string]: import("@raytio/types").SchemaField;
|
|
@@ -83,7 +83,7 @@ export declare const removePrivateFields: (schema: Schema) => {
|
|
|
83
83
|
} | undefined;
|
|
84
84
|
onboard_properties?: {
|
|
85
85
|
profile_objects?: {
|
|
86
|
-
schema_name:
|
|
86
|
+
schema_name: import("@raytio/types").SchemaName;
|
|
87
87
|
properties: Record<string, unknown>;
|
|
88
88
|
}[] | undefined;
|
|
89
89
|
relationships?: {
|
|
@@ -104,7 +104,7 @@ export declare const removePrivateFields: (schema: Schema) => {
|
|
|
104
104
|
}[] | undefined;
|
|
105
105
|
return_to?: string | undefined;
|
|
106
106
|
} | undefined;
|
|
107
|
-
name:
|
|
107
|
+
name: import("@raytio/types").SchemaName;
|
|
108
108
|
type?: import("@raytio/types").DataTypes | undefined;
|
|
109
109
|
group_title?: string | undefined;
|
|
110
110
|
verified_fields?: (string | import("@raytio/types").ConditionallyRequired)[] | undefined;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { NId, SchemaField, Urn } from "@raytio/types";
|
|
1
|
+
import type { NId, SchemaField, Urn } from "@raytio/types";
|
|
2
2
|
/** two overloads - if you provide undefined, you might get undefined back */
|
|
3
3
|
export declare const getNidFromUrn: {
|
|
4
|
-
(urn: Urn):
|
|
5
|
-
(urn: Urn | undefined):
|
|
4
|
+
<IDType = NId>(urn: Urn): IDType;
|
|
5
|
+
<IDType_1 = NId>(urn: Urn | undefined): IDType_1 | undefined;
|
|
6
6
|
};
|
|
7
7
|
type Key = string;
|
|
8
8
|
type Tag = string;
|
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
import { WrappedSchema } from "@raytio/types";
|
|
2
|
-
export
|
|
3
|
-
version: string;
|
|
4
|
-
name: string;
|
|
5
|
-
};
|
|
6
|
-
export declare function unwrapSchema(wrapped: WrappedSchema): WrappedSchema["schema"] & Pick<WrappedSchema, "start_date" | "end_date" | "schema_type"> & ClientFields;
|
|
1
|
+
import type { Schema, WrappedSchema } from "@raytio/types";
|
|
2
|
+
export declare function unwrapSchema(wrapped: WrappedSchema): WrappedSchema["schema"] & Pick<WrappedSchema, "start_date" | "end_date" | "schema_type"> & Pick<Schema, "name" | "version">;
|
package/dist/schema/labels.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
+
import type { SchemaName } from "@raytio/types";
|
|
1
2
|
/** Finds the label (on a profile object) which is the schema name */
|
|
2
|
-
export declare const findSchemaLabel: (labels: string[] | undefined) =>
|
|
3
|
+
export declare const findSchemaLabel: (labels: string[] | undefined) => SchemaName | undefined;
|
package/dist/testHelpers.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Mock } from "vitest";
|
|
2
2
|
/** like {@link Partial} but applies to all deep properties */
|
|
3
3
|
export type DeepPartial<T> = T | (T extends object ? {
|
|
4
4
|
[K in keyof T]?: DeepPartial<T[K]>;
|
|
5
5
|
} : T extends (infer U)[] ? DeepPartial<U>[] : T);
|
|
6
6
|
/** tells typescript that this function is mocked */
|
|
7
|
-
export declare const m: (func: unknown) =>
|
|
7
|
+
export declare const m: (func: unknown) => Mock<any, any>;
|
|
8
8
|
/** helper to let us define type-safe partial mocks */
|
|
9
9
|
export declare const deepPartial: <T>(partial: DeepPartial<T>) => T;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FieldVerification,
|
|
1
|
+
import { FieldVerification, type NId, POVerification, type ProfileObject, type ProfileObjectForUpload, type RealVer, type Schema, type VerificationProvider } from "@raytio/types";
|
|
2
2
|
export type VerDetails = {
|
|
3
3
|
sourceNId?: NId;
|
|
4
4
|
verifiers: VerificationProvider[];
|