diff --git a/augen/.gitignore b/augen/.gitignore index aa18dd9cac..24b279c5b3 100644 --- a/augen/.gitignore +++ b/augen/.gitignore @@ -1,4 +1,5 @@ -test/checkers +test/checkers*/* +test/checkers-raw/*.ts test/types/*.js public/docs/* public/server-api.json diff --git a/augen/src/augen.js b/augen/src/augen.js index 79617d0975..62ecba17a1 100644 --- a/augen/src/augen.js +++ b/augen/src/augen.js @@ -49,14 +49,17 @@ export function typeCheckers(fileRoutes, fromPath) { } const importLines = [`import { createValidate } from 'typia'`] const createLines = [] + const dedupedTypeIds = new Set() for (const file in typeIdsByFile) { if (file.endsWith('.js')) continue - const typeIds = Array.from(typeIdsByFile[file]).filter(t => t !== 'any') + const typeIds = Array.from(typeIdsByFile[file]).filter(t => t !== 'any' && !dedupedTypeIds.has(t)) if (!typeIds.length) continue - importLines.push(`import { ${typeIds.join(', ')} } from '${fromPath}/${file}'`) + const filename = file.split('.').slice(0, -1).join('.') + importLines.push(`import type { ${typeIds.join(', ')} } from '${fromPath}/${filename}.js'`) for (const typeId of typeIds) { createLines.push(`export const valid${typeId} = createValidate<${typeId}>()`) } + for (const t of typeIds) dedupedTypeIds.add(t) } const content = importLines.join('\n') + '\n\n' + createLines.join('\n') return content diff --git a/augen/src/extractTypesFromHtml.js b/augen/src/extractTypesFromHtml.js index 53cc10e467..beddd2c15d 100755 --- a/augen/src/extractTypesFromHtml.js +++ b/augen/src/extractTypesFromHtml.js @@ -21,7 +21,7 @@ for (const t of ['types', 'interfaces']) { if (fname.startsWith('_internal_.')) { const linkName = join(dir, `${name}.html`) if (!fs.existsSync(linkName)) { - fs.symlink(htmlFilePath, linkName, err => { + fs.symlink(join('.', fname), linkName, err => { if (err) throw err }) } diff --git a/augen/src/tester.ts b/augen/src/tester.ts index 09688d6a6d..bc5d8ed74c 100644 --- a/augen/src/tester.ts +++ b/augen/src/tester.ts @@ -37,7 +37,7 @@ function getApp({ api }, getHandlerInitArg = null) { ***************/ // f: a filename under the server/routes dir -export async function testApi(route, f, checkers) { +export function testApi(route, f, checkers) { const { api } = route tape('\n', function (test) { @@ -52,7 +52,7 @@ export async function testApi(route, f, checkers) { if (!m.examples) m.examples = [{ request: {}, response: {} }] for (const x of m.examples) { - tape(`${api.endpoint} ${METHOD}`, async test => { + tape(`${api.endpoint} ${METHOD}`, test => { if (m.alternativeFor) { console.log(`${METHOD} method tested previously as '${m.alternativeFor.toUpperCase()}'`) test.end() @@ -87,7 +87,7 @@ export async function testApi(route, f, checkers) { } const route = app.routes[api.endpoint] test.equal(typeof route?.get, 'function', 'should exist as a route') - await route.get(req, res) + route.get(req, res) test.end() }) } diff --git a/augen/test/checkers-raw/index.ts b/augen/test/checkers-raw/index.ts deleted file mode 100644 index 6de7f7202a..0000000000 --- a/augen/test/checkers-raw/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { createValidate } from 'typia' -import { AbcRequest, AbcResponse } from '../types/abc.ts' - -export const validAbcRequest = createValidate() -export const validAbcResponse = createValidate() diff --git a/augen/test/unit.spec.js b/augen/test/unit.spec.js index bcc238f599..5ce1d652dc 100644 --- a/augen/test/unit.spec.js +++ b/augen/test/unit.spec.js @@ -10,9 +10,9 @@ runTests() async function runTests() { const files = readdirSync(join(__dirname, './routes')) - const endpoints = files.filter(f => f.endsWith('.ts') || f.endsWith('.js')) + const endpoints = files.filter(f => f.endsWith('.ts')) for (const f of endpoints) { const route = await import(`./routes/${f}`) - await testApi(route, f, checkers) + testApi(route, f, checkers) } } diff --git a/client/plots/wsiviewer/WSIViewer.ts b/client/plots/wsiviewer/WSIViewer.ts index 2dc9c42c76..16d616fca8 100644 --- a/client/plots/wsiviewer/WSIViewer.ts +++ b/client/plots/wsiviewer/WSIViewer.ts @@ -12,7 +12,7 @@ import TileSource from 'ol/source/Tile' import { WSIViewerInteractions } from '#plots/wsiviewer/interactions/WSIViewerInteractions.ts' import Settings from '#plots/wsiviewer/Settings.ts' import wsiViewerDefaults from '#plots/wsiviewer/defaults.ts' -import { GetWSImagesRequest, GetWSImagesResponse } from '#routes/wsimages.ts' +import { WSImagesRequest, WSImagesResponse } from '#routes/wsimages.ts' import wsiViewerImageFiles from './wsimagesloaded.ts' import { WSImage } from '#routes/samplewsimages.ts' import { table2col } from '#dom/table2col' @@ -169,14 +169,14 @@ export default class WSIViewer { const layers: Array> = [] for (let i = 0; i < wsimages.length; i++) { - const body: GetWSImagesRequest = { + const body: WSImagesRequest = { genome: state.genome || state.vocab.genome, dslabel: state.dslabel || state.vocab.dslabel, sampleId: state.sample_id, wsimage: wsimages[i].filename } - const data: GetWSImagesResponse = await dofetch3('wsimages', { body }) + const data: WSImagesResponse = await dofetch3('wsimages', { body }) if (data.status === 'error') { return [] diff --git a/package.json b/package.json index de178f8c81..7c3c7f9db9 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "sethooks": "./utils/hooks/init.sh", "getconf": "node -p 'JSON.stringify(require(\"./server/src/serverconfig.js\"),null,\" \")'", "clean": "git add -A; git stash --staged", - "doc": "npm run doc --workspace=server" + "doc": "npm run doc --workspace=shared/types" }, "author": "", "license": "SEE LICENSE IN ./LICENSE", diff --git a/public/server.html b/public/server.html index d2459a59af..ea48b38456 100644 --- a/public/server.html +++ b/public/server.html @@ -4,7 +4,7 @@ - +