Skip to content

Commit

Permalink
Fix schema record type alias in the definitions parser (#98)
Browse files Browse the repository at this point in the history
* Improve exported schema types

* Fix schema record type alias in the definitions parser
  • Loading branch information
deebov authored Jul 12, 2024
1 parent 302d0be commit 26d1433
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/bin/utils/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ export async function parseSchemaDefinitionFile(
const missingSchemas: { name: string; parent: string; source: string }[] = [];
const unknownFields: { parent: string; name: string; type: string; source: string }[] = [];

let schemaRecordAlias = 'SchemaRecord';
let schemaRecordsAlias = 'SchemaRecords';
let schemaRecordAlias = 'Record';
let schemaRecordsAlias = 'Records';

function getFieldType(type: string): string {
const originalType = typeMapping[type] || type;
Expand Down Expand Up @@ -376,7 +376,8 @@ export async function parseSchemaDefinitionFile(
onError(
`The schema \`${typeName}\` does not have a plural slug and name defined.\n\n` +
`Please define them in your schema definition file and include them in the \`Schemas\` interface:\n\n` +
`type ${pluralTypeName} = ${schemaRecordsAlias}<${typeName}>;\n\n` +
`import type * as Schema from 'ronin/schema';\n\n` +
`type ${pluralTypeName} = Schema.${schemaRecordsAlias}<${typeName}>;\n\n` +
`interface Schemas {\n ${propertyName}: ${typeName};\n ${pluralize(result.slug as string)}: ${pluralTypeName};\n}`,
);
}
Expand Down

0 comments on commit 26d1433

Please sign in to comment.