@balena/abstract-sql-to-typescript
Advanced tools
Comparing version 4.0.3 to 4.0.4-build-no-writable-fields-573c4da6d9e4521f700e7f38a033640ef8afe533-1
@@ -7,4 +7,8 @@ # Change Log | ||
## 4.0.3 - 2024-09-06 | ||
## 4.0.4 - 2024-09-12 | ||
* Correctly use `Record<string, never>` when there are no writable fields [Pagan Gazzard] | ||
## 4.0.3 - 2024-09-08 | ||
* Fix accidentally omitting `Read` types for computed fields [Pagan Gazzard] | ||
@@ -11,0 +15,0 @@ |
@@ -119,7 +119,10 @@ "use strict"; | ||
const tableToInterface = (m, table) => { | ||
const writeType = table.definition != null | ||
const writableFields = table.definition != null | ||
? [] | ||
: fieldsToInterfaceProps(m, table.fields, 'Write'); | ||
const writeType = writableFields.length === 0 | ||
? | ||
'Record<string, never>' | ||
: `{ | ||
${[...fieldsToInterfaceProps(m, table.fields, 'Write')].join('\n\t\t')} | ||
${writableFields.join('\n\t\t')} | ||
}`; | ||
@@ -126,0 +129,0 @@ return trimNL ` |
{ | ||
"name": "@balena/abstract-sql-to-typescript", | ||
"version": "4.0.3", | ||
"version": "4.0.4-build-no-writable-fields-573c4da6d9e4521f700e7f38a033640ef8afe533-1", | ||
"description": "A translator for abstract sql into typescript types.", | ||
@@ -56,4 +56,4 @@ "main": "out/index.js", | ||
"versionist": { | ||
"publishedAt": "2024-09-06T15:36:03.898Z" | ||
"publishedAt": "2024-09-12T16:01:33.498Z" | ||
} | ||
} |
@@ -213,8 +213,12 @@ import type { | ||
const tableToInterface = (m: RequiredModelSubset, table: AbstractSqlTable) => { | ||
const writableFields = | ||
table.definition != null | ||
? [] | ||
: fieldsToInterfaceProps(m, table.fields, 'Write'); | ||
const writeType = | ||
table.definition != null | ||
writableFields.length === 0 | ||
? // If there's a table definition then we cannot write anything | ||
'Record<string, never>' | ||
: `{ | ||
${[...fieldsToInterfaceProps(m, table.fields, 'Write')].join('\n\t\t')} | ||
${writableFields.join('\n\t\t')} | ||
}`; | ||
@@ -221,0 +225,0 @@ return trimNL` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
255333
870
2