Skip to content

Commit

Permalink
fix: resolve issue with typing of the readonly fields
Browse files Browse the repository at this point in the history
  • Loading branch information
pdfowler committed Aug 17, 2023
1 parent 9cec716 commit 1ca8f77
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export const ${camelName}ExternalResolver = resolve<${singluarUpperName}, HookCo
)}
})
const ${camelName}ReadonlyFields: (keyof ${singluarUpperName})[] = [...defaultReadonlyFields]
/**
* @title: ${camelName}DataSchema
* @description Schema for creating new entries
Expand All @@ -55,7 +57,7 @@ export const ${camelName}DataSchema = ${isEntityService ? `Type.Pick` : `Type.O
${
isEntityService
? authStrategies.map((name) => (name === 'local' ? `'email', 'password'` : `'${name}Id'`)).join(', ')
: `...(defaultReadonlyFields as (keyof ${singluarUpperName})[]),`
: `...(${camelName}ReadonlyFields),`
}
], {
$id: '${upperName}Data'
Expand All @@ -72,7 +74,7 @@ export const ${camelName}DataResolver = resolve<${singluarUpperName}, HookContex
*/
export const ${camelName}PatchSchema = Type.Partial(
Type.Omit(${camelName}Schema, [
...(defaultReadonlyFields as (keyof ${singluarUpperName})[]),
${camelName}ReadonlyFields,
]), {
$id: '${upperName}Patch'
})
Expand Down

0 comments on commit 1ca8f77

Please sign in to comment.