From 9532e47ba0e56bba05db09f07a5cf4e2599d5cb9 Mon Sep 17 00:00:00 2001 From: Olivier Huin Date: Thu, 9 Jan 2025 20:04:35 +0000 Subject: [PATCH] Adds more imports --- src/incy-wincy-model.ts | 75 +++++++++++++++++++++++++++-------------- 1 file changed, 50 insertions(+), 25 deletions(-) diff --git a/src/incy-wincy-model.ts b/src/incy-wincy-model.ts index d556386..07a1ceb 100644 --- a/src/incy-wincy-model.ts +++ b/src/incy-wincy-model.ts @@ -14,32 +14,8 @@ const programmingLanguage = z .enum(programmingLanguageKey) .describe(describeEnum('Programming Language:', programmingLanguageLabels)); -const blockKindKey = [ - 'class', - 'interface', - 'const', - 'function', - 'test', - 'other', - 'import', -] as const; - -const blockKindlabels = { - class: 'Class', - interface: 'Interface', - const: 'Constant', - function: 'Function', - test: 'Test', - other: 'Other', - import: 'Import', -}; - -const blockKind = z - .enum(blockKindKey) - .describe(describeEnum('Language block kind:', blockKindlabels)); - const codeSection = { - name: stringFields.string1To80.describe('Name of the class'), + name: stringFields.string1To80.describe('Name of the section'), body: stringFields.string1To1000.describe('The full code of the block'), uncommentedBody: stringFields.string1To1000.describe( 'The code of the block with comments removed' @@ -53,3 +29,52 @@ const classSection = z.object({ kind: z.literal('class').describe('Class'), ...codeSection, }); + +const interfaceSection = z.object({ + kind: z.literal('interface').describe('Interface'), + ...codeSection, +}); + +const enumSection = z.object({ + kind: z.literal('enum').describe('Enum'), + ...codeSection, +}); + +const constSection = z.object({ + kind: z.literal('const').describe('Const'), + ...codeSection, +}); + +const functionSection = z.object({ + kind: z.literal('function').describe('Function'), + ...codeSection, +}); + +const testSection = z.object({ + kind: z.literal('test').describe('Test'), + ...codeSection, +}); + +const otherSection = z.object({ + kind: z.literal('other').describe('Other'), + ...codeSection, +}); + +const ImportSchema = z.object({ + type: z.literal('default').or(z.literal('named')).or(z.literal('namespace')), + source: z.string().url().optional(), + defaultImport: z.string().optional(), + namedImports: z.array(z.string()).optional(), + namespace: z.string().optional(), +}); + +const importSection = { + kind: z.literal('import').describe('Import'), + body: stringFields.string1To1000.describe('The full code of the block'), + uncommentedBody: stringFields.string1To1000.describe( + 'The code of the block with comments removed' + ), + importPaths: z + .array(stringFields.string1To140) + .describe('Paths of the imports'), +};