diff --git a/lib/JSONBValidation/validation.ts b/lib/JSONBValidation/validation.ts index c327148d..5d5d72e7 100644 --- a/lib/JSONBValidation/validation.ts +++ b/lib/JSONBValidation/validation.ts @@ -92,9 +92,10 @@ export function getJSONBSchemaTSTypes(schema: JSONB.JSONBSchema, colOpts: ColOpt return `${fieldType.nullable ? `null | ` : ""} ( ${getFieldType(arrayOf, true, undefined, depth + 1)} )[]`; } else if (fieldType?.record) { - const { keysEnum, values } = fieldType.record; + const { keysEnum, values, partial } = fieldType.record; // TODO: ensure props with undefined values are not allowed in the TS type - return `${fieldType.nullable ? `null |` : ""} Partial asValue(v)).join(" | ") ?? "string"}, ${!values? "any" : getFieldType(values, true, undefined, depth + 1)}>>` + const getRecord = (v: string) => partial? `Partial>` : `Record<${v}>`; + return `${fieldType.nullable ? `null |` : ""} ${getRecord(`${keysEnum?.map(v => asValue(v)).join(" | ") ?? "string"}, ${!values? "any" : getFieldType(values, true, undefined, depth + 1)}`)}>>` } else if(fieldType?.lookup){ diff --git a/package-lock.json b/package-lock.json index 96d98692..4a7d8d1b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "prostgles-server", - "version": "4.1.83", + "version": "4.1.84", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "prostgles-server", - "version": "4.1.83", + "version": "4.1.84", "license": "MIT", "dependencies": { "@types/express": "^4.17.13", @@ -15,7 +15,7 @@ "check-disk-space": "^3.3.1", "file-type": "^17.1.4", "pg-promise": "^11.3.0", - "prostgles-types": "^4.0.41" + "prostgles-types": "^4.0.42" }, "devDependencies": { "@types/bluebird": "^3.5.36", @@ -1654,9 +1654,9 @@ } }, "node_modules/prostgles-types": { - "version": "4.0.41", - "resolved": "https://registry.npmjs.org/prostgles-types/-/prostgles-types-4.0.41.tgz", - "integrity": "sha512-DiSFE524LjCw5mc/2zDm9mnzirFCAPqutAJl/JD37t83uqXlOQjFb2cNvP4ACD444eJ0DXNhwm8Ko1gy7MsR6w==", + "version": "4.0.42", + "resolved": "https://registry.npmjs.org/prostgles-types/-/prostgles-types-4.0.42.tgz", + "integrity": "sha512-ZyU8x+Sn1I6XZ82vLcuJMYsHIC0dgAqiMQDmcC9mTOkeIWundhMLVG75ZEcu6QVbaCTzZDLq+aj0z3XKCxoT6A==", "dependencies": { "json-schema": "^0.4.0" } @@ -3271,9 +3271,9 @@ "dev": true }, "prostgles-types": { - "version": "4.0.41", - "resolved": "https://registry.npmjs.org/prostgles-types/-/prostgles-types-4.0.41.tgz", - "integrity": "sha512-DiSFE524LjCw5mc/2zDm9mnzirFCAPqutAJl/JD37t83uqXlOQjFb2cNvP4ACD444eJ0DXNhwm8Ko1gy7MsR6w==", + "version": "4.0.42", + "resolved": "https://registry.npmjs.org/prostgles-types/-/prostgles-types-4.0.42.tgz", + "integrity": "sha512-ZyU8x+Sn1I6XZ82vLcuJMYsHIC0dgAqiMQDmcC9mTOkeIWundhMLVG75ZEcu6QVbaCTzZDLq+aj0z3XKCxoT6A==", "requires": { "json-schema": "^0.4.0" } diff --git a/package.json b/package.json index f6211882..f9311412 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "prostgles-server", - "version": "4.1.83", + "version": "4.1.84", "description": "", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -41,7 +41,7 @@ "check-disk-space": "^3.3.1", "file-type": "^17.1.4", "pg-promise": "^11.3.0", - "prostgles-types": "^4.0.41" + "prostgles-types": "^4.0.42" }, "devDependencies": { "@types/bluebird": "^3.5.36", diff --git a/tests/client/PID.txt b/tests/client/PID.txt index d702bc21..1c34f73a 100644 --- a/tests/client/PID.txt +++ b/tests/client/PID.txt @@ -1 +1 @@ -1733501 +1745085 diff --git a/tests/client/package-lock.json b/tests/client/package-lock.json index 248a12db..0171b72e 100644 --- a/tests/client/package-lock.json +++ b/tests/client/package-lock.json @@ -10,7 +10,7 @@ "license": "ISC", "dependencies": { "@types/node": "^14.14.16", - "prostgles-client": "^4.0.25", + "prostgles-client": "^4.0.26", "socket.io-client": "^4.7.1" }, "devDependencies": { @@ -74,11 +74,11 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, "node_modules/prostgles-client": { - "version": "4.0.25", - "resolved": "https://registry.npmjs.org/prostgles-client/-/prostgles-client-4.0.25.tgz", - "integrity": "sha512-wXLrZB65uqF+lop8AV7AuiA01P2sIDZgj+VjH+/SMTlTv5LhpubORIXofDzlZfAwk2eUs53u6o707RtQ4qHt4w==", + "version": "4.0.26", + "resolved": "https://registry.npmjs.org/prostgles-client/-/prostgles-client-4.0.26.tgz", + "integrity": "sha512-Mmcv+z7ktaEdP2E+G8WWboiqZvmtkRZxT+SyRJimpFeJY3o+Xh2smzbTeg+KojsFP4SCWYtPQhgtPCNyQCVvUw==", "dependencies": { - "prostgles-types": "^4.0.41" + "prostgles-types": "^4.0.42" }, "peerDependencies": { "react": "^16.8.0 || ^17.0.0 || ^18.0.0" @@ -90,9 +90,9 @@ } }, "node_modules/prostgles-types": { - "version": "4.0.41", - "resolved": "https://registry.npmjs.org/prostgles-types/-/prostgles-types-4.0.41.tgz", - "integrity": "sha512-DiSFE524LjCw5mc/2zDm9mnzirFCAPqutAJl/JD37t83uqXlOQjFb2cNvP4ACD444eJ0DXNhwm8Ko1gy7MsR6w==", + "version": "4.0.42", + "resolved": "https://registry.npmjs.org/prostgles-types/-/prostgles-types-4.0.42.tgz", + "integrity": "sha512-ZyU8x+Sn1I6XZ82vLcuJMYsHIC0dgAqiMQDmcC9mTOkeIWundhMLVG75ZEcu6QVbaCTzZDLq+aj0z3XKCxoT6A==", "dependencies": { "json-schema": "^0.4.0" } @@ -212,17 +212,17 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, "prostgles-client": { - "version": "4.0.25", - "resolved": "https://registry.npmjs.org/prostgles-client/-/prostgles-client-4.0.25.tgz", - "integrity": "sha512-wXLrZB65uqF+lop8AV7AuiA01P2sIDZgj+VjH+/SMTlTv5LhpubORIXofDzlZfAwk2eUs53u6o707RtQ4qHt4w==", + "version": "4.0.26", + "resolved": "https://registry.npmjs.org/prostgles-client/-/prostgles-client-4.0.26.tgz", + "integrity": "sha512-Mmcv+z7ktaEdP2E+G8WWboiqZvmtkRZxT+SyRJimpFeJY3o+Xh2smzbTeg+KojsFP4SCWYtPQhgtPCNyQCVvUw==", "requires": { - "prostgles-types": "^4.0.41" + "prostgles-types": "^4.0.42" } }, "prostgles-types": { - "version": "4.0.41", - "resolved": "https://registry.npmjs.org/prostgles-types/-/prostgles-types-4.0.41.tgz", - "integrity": "sha512-DiSFE524LjCw5mc/2zDm9mnzirFCAPqutAJl/JD37t83uqXlOQjFb2cNvP4ACD444eJ0DXNhwm8Ko1gy7MsR6w==", + "version": "4.0.42", + "resolved": "https://registry.npmjs.org/prostgles-types/-/prostgles-types-4.0.42.tgz", + "integrity": "sha512-ZyU8x+Sn1I6XZ82vLcuJMYsHIC0dgAqiMQDmcC9mTOkeIWundhMLVG75ZEcu6QVbaCTzZDLq+aj0z3XKCxoT6A==", "requires": { "json-schema": "^0.4.0" } diff --git a/tests/client/package.json b/tests/client/package.json index 5d9d2795..7633921e 100644 --- a/tests/client/package.json +++ b/tests/client/package.json @@ -13,7 +13,7 @@ "license": "ISC", "dependencies": { "@types/node": "^14.14.16", - "prostgles-client": "^4.0.25", + "prostgles-client": "^4.0.26", "socket.io-client": "^4.7.1" }, "devDependencies": { diff --git a/tests/server/DBoGenerated.d.ts b/tests/server/DBoGenerated.d.ts index 42a6426f..d9b7724a 100644 --- a/tests/server/DBoGenerated.d.ts +++ b/tests/server/DBoGenerated.d.ts @@ -485,7 +485,7 @@ export type DBSchemaGenerated = { | { ok: string; } | { err: string; } | { loading: { loaded: number; total: number; }; } - table_config?: null | { referencedTables?: ( { name: string; minFiles: number; } )[]; recType?: null | Partial>; }; + table_config?: null | { referencedTables?: ( { name: string; minFiles: number; } )[]; recType?: null | Record<'a' | 'b', { bools: boolean[]; }>>>; }; }; }; tr1: { diff --git a/tests/server/package-lock.json b/tests/server/package-lock.json index dc6bf33e..361c1af8 100644 --- a/tests/server/package-lock.json +++ b/tests/server/package-lock.json @@ -21,7 +21,7 @@ }, "../..": { "name": "prostgles-server", - "version": "4.1.83", + "version": "4.1.84", "license": "MIT", "dependencies": { "@types/express": "^4.17.13", @@ -30,7 +30,7 @@ "check-disk-space": "^3.3.1", "file-type": "^17.1.4", "pg-promise": "^11.3.0", - "prostgles-types": "^4.0.41" + "prostgles-types": "^4.0.42" }, "devDependencies": { "@types/bluebird": "^3.5.36", @@ -1521,7 +1521,7 @@ "eslint": "^8.44.0", "file-type": "^17.1.4", "pg-promise": "^11.3.0", - "prostgles-types": "^4.0.41", + "prostgles-types": "^4.0.42", "typescript": "^5.0.3" } },