@kosmojs/dev 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/package.json +57 -0
  2. package/pkg/base-plugin/routes.js +618 -0
  3. package/pkg/base-plugin/routes.js.map +7 -0
  4. package/pkg/base-plugin/worker.js +810 -0
  5. package/pkg/base-plugin/worker.js.map +7 -0
  6. package/pkg/index.js +1004 -0
  7. package/pkg/index.js.map +7 -0
  8. package/pkg/src/alias-plugin/index.d.ts +5 -0
  9. package/pkg/src/base-plugin/api-handler.d.ts +10 -0
  10. package/pkg/src/base-plugin/ast.d.ts +49 -0
  11. package/pkg/src/base-plugin/cache.d.ts +20 -0
  12. package/pkg/src/base-plugin/index.d.ts +4 -0
  13. package/pkg/src/base-plugin/routes.d.ts +13 -0
  14. package/pkg/src/base-plugin/spinner.d.ts +8 -0
  15. package/pkg/src/base-plugin/worker.d.ts +17 -0
  16. package/pkg/src/define-plugin/index.d.ts +9 -0
  17. package/pkg/src/index.d.ts +6 -0
  18. package/pkg/src/stub-generator/index.d.ts +8 -0
  19. package/pkg/stub-generator/index.js +51 -0
  20. package/pkg/stub-generator/index.js.map +7 -0
  21. package/pkg/test/@fixtures/app/@src/api/articles/[...path]/index.d.ts +0 -0
  22. package/pkg/test/@fixtures/app/@src/api/books/[category]/[[author]]/index.d.ts +0 -0
  23. package/pkg/test/@fixtures/app/@src/api/books/[category]/index.d.ts +0 -0
  24. package/pkg/test/@fixtures/app/@src/api/books/index.d.ts +0 -0
  25. package/pkg/test/@fixtures/app/@src/api/files/[[folder]]/[[id]].json/index.d.ts +0 -0
  26. package/pkg/test/@fixtures/app/@src/api/files/[[folder]]/index.d.ts +0 -0
  27. package/pkg/test/@fixtures/app/@src/api/index/index.d.ts +0 -0
  28. package/pkg/test/@fixtures/app/@src/api/pages/[...path].html/index.d.ts +0 -0
  29. package/pkg/test/@fixtures/app/@src/api/users/[id].json/index.d.ts +0 -0
  30. package/pkg/test/@fixtures/app/lib/@src/{api}/articles/[...path]/types.d.ts +3 -0
  31. package/pkg/test/@fixtures/app/lib/@src/{api}/books/[category]/[[author]]/types.d.ts +4 -0
  32. package/pkg/test/@fixtures/app/lib/@src/{api}/books/[category]/types.d.ts +3 -0
  33. package/pkg/test/@fixtures/app/lib/@src/{api}/books/types.d.ts +1 -0
  34. package/pkg/test/@fixtures/app/lib/@src/{api}/files/[[folder]]/[[id]].json/types.d.ts +4 -0
  35. package/pkg/test/@fixtures/app/lib/@src/{api}/files/[[folder]]/types.d.ts +3 -0
  36. package/pkg/test/@fixtures/app/lib/@src/{api}/index/types.d.ts +1 -0
  37. package/pkg/test/@fixtures/app/lib/@src/{api}/pages/[...path].html/types.d.ts +3 -0
  38. package/pkg/test/@fixtures/app/lib/@src/{api}/users/[id].json/types.d.ts +3 -0
  39. package/pkg/test/@fixtures/ast/extractTypeDeclarations/exports/with-referenced-files.d.ts +1 -0
  40. package/pkg/test/@fixtures/ast/extractTypeDeclarations/imports/with-referenced-files.d.ts +1 -0
  41. package/pkg/test/ast/extractParamsRefinements.test.d.ts +1 -0
  42. package/pkg/test/ast/extractRouteMethods.test.d.ts +1 -0
  43. package/pkg/test/ast/extractTypeDeclarations.test.d.ts +1 -0
  44. package/pkg/test/routes/resolver.test.d.ts +1 -0
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/base-plugin/routes.ts", "../../src/base-plugin/ast.ts", "../../src/base-plugin/cache.ts", "../../src/base-plugin/templates/resolved-types.hbs", "../../src/base-plugin/templates/types.hbs"],
4
+ "sourcesContent": ["import { dirname, join, resolve } from \"node:path\";\n\nimport crc from \"crc/crc32\";\nimport picomatch from \"picomatch\";\nimport { glob } from \"tinyglobby\";\n\nimport {\n type ApiRoute,\n defaults,\n type PageRoute,\n type PluginOptionsResolved,\n pathResolver,\n pathTokensFactory,\n type RouteEntry,\n type RouteResolver,\n render,\n renderToFile,\n} from \"@kosmojs/devlib\";\n\nimport { resolveRouteSignature, typeResolverFactory } from \"./ast\";\nimport { cacheFactory } from \"./cache\";\n\nimport resolvedTypesTpl from \"./templates/resolved-types.hbs\";\nimport typesFileTpl from \"./templates/types.hbs\";\n\nexport type Resolvers = Map<string, RouteResolver>;\n\nexport type ResolveRouteFile = (file: string) =>\n | [\n // Either `apiDir` or `pagesDir`\n folder: string,\n // Path to a file within the folder, nested at least one level deep\n file: string,\n ]\n | undefined;\n\nexport type ResolversFactory = (\n routeFiles: Array<string>,\n) => Map<string, RouteResolver>;\n\nexport default async (\n pluginOptions: PluginOptionsResolved,\n): Promise<{\n resolvers: Resolvers;\n resolversFactory: ResolversFactory;\n resolveRouteFile: ResolveRouteFile;\n}> => {\n const {\n appRoot,\n sourceFolder,\n generators = [],\n formatters = [],\n refineTypeName,\n } = pluginOptions;\n\n let resolveTypes = false;\n\n for (const { options } of generators) {\n if (options?.resolveTypes) {\n resolveTypes = true;\n }\n }\n\n const {\n //\n literalTypesResolver,\n getSourceFile,\n refreshSourceFile,\n } = typeResolverFactory(pluginOptions);\n\n const routeFilePatterns = [\n `${defaults.apiDir}/**/index.ts`,\n `${defaults.pagesDir}/**/index.{ts,tsx,vue,svelte}`,\n ];\n\n const resolveRouteFile: ResolveRouteFile = (file) => {\n const [_sourceFolder, folder, ...rest] = resolve(appRoot, file)\n .replace(`${appRoot}/`, \"\")\n .split(\"/\");\n\n /**\n * Ensure the file:\n * - is under the correct source root (`sourceFolder`)\n * - belongs to a known route folder (`apiDir` or `pagesDir`)\n * - is nested at least one level deep (not a direct child of the folder)\n */\n if (!folder || _sourceFolder !== sourceFolder || rest.length < 2) {\n return;\n }\n\n return picomatch.isMatch(join(folder, ...rest), routeFilePatterns)\n ? [folder, rest.join(\"/\")]\n : undefined;\n };\n\n const resolversFactory: ResolversFactory = (routeFiles) => {\n const resolvers = new Map<\n string, // fileFullpath\n RouteResolver\n >();\n\n const entries: Array<RouteEntry> = routeFiles.flatMap((_file) => {\n const resolvedPaths = resolveRouteFile(_file);\n\n if (!resolvedPaths) {\n return [];\n }\n\n const [folder, file] = resolvedPaths;\n\n const fileFullpath = join(appRoot, sourceFolder, folder, file);\n\n const pathTokens = pathTokensFactory(dirname(file));\n\n const name = pathTokens.map((e) => e.orig).join(\"/\");\n\n const importPath = dirname(file);\n\n const importName = [\n importPath\n .split(/\\[/)[0]\n .replace(/^\\W+|\\W+$/g, \"\")\n .replace(/\\W+/g, \"_\"),\n crc(importPath),\n ].join(\"_\");\n\n return [\n {\n name,\n folder,\n file,\n fileFullpath,\n pathTokens,\n importPath,\n importName,\n },\n ];\n });\n\n for (const entry of entries.filter((e) => e.folder === defaults.apiDir)) {\n const {\n name,\n file,\n folder,\n fileFullpath,\n pathTokens,\n importPath,\n importName,\n } = entry;\n\n const handler: RouteResolver[\"handler\"] = async (updatedFile) => {\n const paramsSchema = pathTokens.flatMap((e) => {\n return e.param ? [e.param] : [];\n });\n\n const optionalParams = paramsSchema.length\n ? !paramsSchema.some((e) => e.isRequired)\n : true;\n\n const { getCache, persistCache } = cacheFactory(\n { file, fileFullpath, importName, importPath },\n {\n appRoot,\n sourceFolder,\n extraContext: { resolveTypes },\n },\n );\n\n let cache = await getCache({ validate: true });\n\n if (!cache) {\n if (updatedFile === fileFullpath) {\n await refreshSourceFile(fileFullpath);\n }\n\n const {\n typeDeclarations,\n paramsRefinements,\n methods,\n payloadTypes,\n responseTypes,\n referencedFiles = [],\n } = await resolveRouteSignature(\n { importName, fileFullpath, optionalParams },\n {\n withReferencedFiles: true,\n sourceFile: getSourceFile(fileFullpath),\n relpathResolver(path) {\n return join(sourceFolder, defaults.apiDir, dirname(file), path);\n },\n },\n );\n\n const numericParams = paramsRefinements\n ? paramsRefinements.flatMap(({ text, index }) => {\n if (text === \"number\") {\n const param = paramsSchema.at(index);\n return param ? [param.name] : [];\n }\n return [];\n })\n : [];\n\n const typesFile = pathResolver({ appRoot, sourceFolder }).resolve(\n \"apiLibDir\",\n importPath,\n \"types.ts\",\n );\n\n const params: ApiRoute[\"params\"] = {\n id: [\"ParamsT\", crc(name)].join(\"\"),\n schema: paramsSchema,\n resolvedType: undefined,\n };\n\n const typesFileContent = render(typesFileTpl, {\n params,\n paramsSchema: paramsSchema.map((param, index) => {\n return {\n ...param,\n refinement: paramsRefinements?.at(index),\n };\n }),\n typeDeclarations,\n payloadTypes,\n responseTypes,\n });\n\n const resolvedTypes = resolveTypes\n ? literalTypesResolver(typesFileContent, {\n overrides: [...payloadTypes, ...responseTypes].reduce(\n (map: Record<string, string>, { id, skipValidation }) => {\n if (skipValidation) {\n map[id] = \"never\";\n }\n return map;\n },\n { [refineTypeName]: refineTypeName },\n ),\n withProperties: [params.id, ...payloadTypes.map((e) => e.id)],\n formatters,\n })\n : undefined;\n\n /**\n * Deploy types.ts file; required by core generators (like fetch).\n * If types resolved, write resolved types;\n * otherwise write original types extracted from API route.\n * */\n await renderToFile(\n typesFile,\n resolvedTypes ? resolvedTypesTpl : typesFileContent,\n { resolvedTypes },\n );\n\n params.resolvedType = resolvedTypes?.find(\n (e) => e.name === params.id,\n );\n\n cache = await persistCache({\n params,\n methods,\n typeDeclarations,\n numericParams,\n // text was needed at writing types.ts file, dropping from cache\n payloadTypes: payloadTypes.map(({ text, ...rest }) => {\n return {\n ...rest,\n resolvedType: resolvedTypes?.find((e) => e.name === rest.id),\n };\n }),\n responseTypes: responseTypes.map(({ text, ...rest }) => {\n return {\n ...rest,\n resolvedType: resolvedTypes?.find((e) => e.name === rest.id),\n };\n }),\n referencedFiles,\n });\n }\n\n const route: ApiRoute = {\n name,\n pathTokens,\n params: cache.params,\n numericParams: cache.numericParams,\n optionalParams,\n importName,\n importPath,\n folder,\n file,\n fileFullpath,\n methods: cache.methods,\n typeDeclarations: cache.typeDeclarations,\n payloadTypes: cache.payloadTypes,\n responseTypes: cache.responseTypes,\n referencedFiles: Object.keys(cache.referencedFiles).map(\n // expand referenced files path,\n // they are stored as relative in cache\n (e) => resolve(appRoot, e),\n ),\n };\n\n return {\n kind: \"api\",\n route,\n };\n };\n\n resolvers.set(fileFullpath, { name, handler });\n }\n\n for (const entry of entries.filter((e) => e.folder === defaults.pagesDir)) {\n const {\n //\n name,\n folder,\n file,\n fileFullpath,\n pathTokens,\n importPath,\n importName,\n } = entry;\n\n const handler: RouteResolver[\"handler\"] = async () => {\n const route: PageRoute = {\n name,\n pathTokens,\n params: {\n schema: pathTokens.flatMap((e) => (e.param ? [e.param] : [])),\n },\n folder,\n file,\n fileFullpath,\n importPath,\n importName,\n };\n\n return {\n kind: \"page\",\n route,\n };\n };\n\n resolvers.set(fileFullpath, { name, handler });\n }\n\n return resolvers;\n };\n\n const routeFiles = await glob(routeFilePatterns, {\n cwd: resolve(appRoot, sourceFolder),\n absolute: true,\n onlyFiles: true,\n ignore: [\n `${defaults.apiDir}/index.ts`,\n `${defaults.pagesDir}/index.ts{x,}`,\n ],\n });\n\n return {\n resolvers: resolversFactory(routeFiles),\n resolversFactory,\n resolveRouteFile,\n };\n};\n", "import { resolve } from \"node:path\";\n\nimport crc from \"crc/crc32\";\nimport { flattener } from \"tfusion\";\nimport {\n type CallExpression,\n type Identifier,\n type Node,\n Project,\n type ProjectOptions,\n type SourceFile,\n SyntaxKind,\n} from \"ts-morph\";\n\nimport { type HTTPMethod, HTTPMethods } from \"@kosmojs/api\";\nimport type {\n ApiRoute,\n PayloadType,\n PluginOptionsResolved,\n ResponseType,\n TypeDeclaration,\n} from \"@kosmojs/devlib\";\n\ntype PathResolver = (path: string) => string;\n\nexport const createProject = (opts?: ProjectOptions) => new Project(opts);\n\nexport const resolveRouteSignature = async (\n route: Pick<ApiRoute, \"importName\" | \"fileFullpath\" | \"optionalParams\">,\n opts?: {\n relpathResolver?: PathResolver;\n sourceFile?: SourceFile;\n withReferencedFiles?: boolean;\n },\n) => {\n const {\n sourceFile = createProject().addSourceFileAtPath(route.fileFullpath),\n } = { ...opts };\n\n const [typeDeclarations, referencedFiles] = extractTypeDeclarations(\n sourceFile,\n opts,\n );\n\n const defaultExport = extractDefaultExport(sourceFile);\n\n const paramsRefinements = defaultExport\n ? extractParamsRefinements(defaultExport)\n : undefined;\n\n const methods = defaultExport\n ? extractRouteMethods(defaultExport, route)\n : [];\n\n const payloadTypes = methods.flatMap((e) => {\n return e.payloadType ? [e.payloadType] : [];\n });\n\n const responseTypes = methods.flatMap((e) => {\n return e.responseType ? [e.responseType] : [];\n });\n\n return {\n typeDeclarations,\n paramsRefinements,\n methods: methods.map((e) => e.method),\n payloadTypes,\n responseTypes,\n referencedFiles,\n };\n};\n\nexport const extractDefaultExport = (\n sourceFile: SourceFile,\n): CallExpression | undefined => {\n const [defaultExport] = sourceFile\n .getExportAssignments()\n .flatMap((exportAssignment) => {\n if (exportAssignment.isExportEquals()) {\n return [];\n }\n const callExpression = exportAssignment.getExpression();\n return callExpression.isKind(SyntaxKind.CallExpression)\n ? [callExpression]\n : [];\n });\n return defaultExport;\n};\n\nexport const extractParamsRefinements = (\n callExpression: CallExpression,\n):\n | Array<{\n index: number;\n text: string;\n }>\n | undefined => {\n const [firstGeneric] = extractGenerics(callExpression);\n\n if (!firstGeneric?.node.isKind(SyntaxKind.TupleType)) {\n return;\n }\n\n const tupleElements = firstGeneric.node.getElements();\n\n if (!tupleElements?.length) {\n return;\n }\n\n return tupleElements.map((node, index) => {\n return {\n index,\n text: node.getText(),\n };\n });\n};\n\nexport const extractRouteMethods = (\n callExpression: CallExpression,\n route: Pick<ApiRoute, \"importName\" | \"optionalParams\">,\n): Array<{\n method: HTTPMethod;\n payloadType: (PayloadType & { text: string }) | undefined;\n responseType: (ResponseType & { text: string }) | undefined;\n}> => {\n const funcDeclaration =\n callExpression.getFirstChildByKind(SyntaxKind.ArrowFunction) ||\n callExpression.getFirstChildByKind(SyntaxKind.FunctionExpression);\n\n if (!funcDeclaration) {\n return [];\n }\n\n const arrayLiteralExpression = funcDeclaration.getFirstChildByKind(\n SyntaxKind.ArrayLiteralExpression,\n );\n\n if (!arrayLiteralExpression) {\n return [];\n }\n\n const callExpressions: Array<[CallExpression, HTTPMethod]> = [];\n\n for (const e of arrayLiteralExpression.getChildrenOfKind(\n SyntaxKind.CallExpression,\n )) {\n const name = e.getExpression().getText() as HTTPMethod;\n if (HTTPMethods[name]) {\n callExpressions.push([e, name]);\n }\n }\n\n const methods = [];\n\n const skipValidationFilter = (e: string) => /@skip-validation/.test(e);\n\n for (const [callExpression, method] of callExpressions) {\n const [payloadGeneric, responseGeneric] = extractGenerics(callExpression);\n\n const payloadText = payloadGeneric?.node\n ? payloadGeneric.node.getChildren().length === 0\n ? \"{}\"\n : payloadGeneric.node.getFullText()\n : undefined;\n\n const responseText = responseGeneric?.node.getText();\n\n const responseType = responseText\n ? {\n id: [\"ResponseT\", crc(route.importName + method)].join(\"\"),\n method,\n skipValidation: responseGeneric?.comments\n ? responseGeneric.comments.some(skipValidationFilter)\n : false,\n text: [\"never\", \"object\"].includes(responseText)\n ? \"{}\"\n : responseText,\n resolvedType: undefined,\n }\n : undefined;\n\n const payloadType = payloadText\n ? {\n id: [\"PayloadT\", crc(route.importName + method)].join(\"\"),\n responseTypeId: responseType?.id,\n method,\n skipValidation: payloadGeneric?.comments\n ? payloadGeneric.comments.some(skipValidationFilter)\n : false,\n isOptional: payloadText\n ? payloadText === \"{}\" || route.optionalParams\n : true,\n text: payloadText,\n resolvedType: undefined,\n }\n : undefined;\n\n methods.push({\n method,\n payloadType,\n responseType,\n });\n }\n\n return methods;\n};\n\nexport const extractTypeDeclarations = (\n sourceFile: SourceFile,\n opts?: {\n relpathResolver?: PathResolver;\n withReferencedFiles?: boolean;\n },\n): [d: Array<TypeDeclaration>, f?: Array<string>] => {\n const declarations: Array<TypeDeclaration> = [];\n\n const referencedFiles: Array<string> | undefined = opts?.withReferencedFiles\n ? []\n : undefined;\n\n for (const declaration of sourceFile.getImportDeclarations()) {\n const modulePath = declaration.getModuleSpecifierValue();\n\n const path = /^\\.\\.?\\/?/.test(modulePath)\n ? opts?.relpathResolver\n ? opts.relpathResolver(modulePath)\n : modulePath\n : modulePath;\n\n const typeOnlyDeclaration = declaration.isTypeOnly();\n\n const defaultImport = typeOnlyDeclaration\n ? declaration.getDefaultImport()\n : undefined;\n\n if (defaultImport) {\n const name = defaultImport.getText();\n const text = `import type ${name} from \"${path}\";`;\n declarations.push({\n importDeclaration: {\n name,\n path,\n },\n text,\n });\n if (referencedFiles) {\n referencedFiles.push(...getReferencedFiles(defaultImport));\n }\n }\n\n for (const namedImport of declaration.getNamedImports()) {\n if (namedImport.isTypeOnly() || typeOnlyDeclaration) {\n const nameNode = namedImport.getNameNode();\n const name = nameNode.getText();\n const alias = namedImport.getAliasNode()?.getText();\n const nameText = alias ? `${name} as ${alias}` : name;\n\n declarations.push({\n importDeclaration: {\n name,\n alias,\n path,\n },\n text: `import type { ${nameText} } from \"${path}\";`,\n });\n\n if (referencedFiles) {\n if (nameNode.isKind(SyntaxKind.Identifier)) {\n referencedFiles.push(...getReferencedFiles(nameNode));\n }\n }\n }\n }\n }\n\n for (const declaration of sourceFile.getTypeAliases()) {\n const name = declaration.getName();\n const text = declaration.getFullText().trim();\n declarations.push({\n typeAliasDeclaration: { name },\n text,\n });\n }\n\n for (const declaration of sourceFile.getInterfaces()) {\n const name = declaration.getName();\n const text = declaration.getFullText().trim();\n declarations.push({\n interfaceDeclaration: { name },\n text,\n });\n }\n\n for (const declaration of sourceFile.getEnums()) {\n const name = declaration.getName();\n const text = declaration.getFullText().trim();\n declarations.push({\n enumDeclaration: { name },\n text,\n });\n }\n\n for (const declaration of sourceFile.getExportDeclarations()) {\n const typeOnlyDeclaration = declaration.isTypeOnly();\n\n const modulePath = declaration.getModuleSpecifierValue();\n\n const path = modulePath\n ? /^\\.\\.?\\/?/.test(modulePath)\n ? opts?.relpathResolver\n ? opts.relpathResolver(modulePath)\n : modulePath\n : modulePath\n : undefined;\n\n for (const namedExport of declaration.getNamedExports()) {\n if (namedExport.isTypeOnly() || typeOnlyDeclaration) {\n const nameNode = namedExport.getNameNode();\n const name = nameNode.getText();\n const alias = namedExport.getAliasNode()?.getText();\n const nameText = alias ? `${name} as ${alias}` : name;\n\n declarations.push({\n exportDeclaration: {\n name,\n alias: alias ?? name,\n path,\n },\n text: path\n ? `export type { ${nameText} } from \"${path}\";`\n : `export type { ${nameText} };`,\n });\n\n if (referencedFiles) {\n if (nameNode.isKind(SyntaxKind.Identifier)) {\n referencedFiles.push(...getReferencedFiles(nameNode));\n }\n }\n }\n }\n }\n\n return referencedFiles\n ? [declarations, [...new Set<string>(referencedFiles)]]\n : [declarations];\n};\n\nconst getReferencedFiles = (importIdentifier: Identifier): Array<string> => {\n // ambient modules may have declarations in multiple files\n const declarations =\n importIdentifier //\n ?.getSymbol()\n ?.getAliasedSymbol()\n ?.getDeclarations() || [];\n\n return declarations.flatMap((e) => {\n const sourceFile = e.getSourceFile();\n return sourceFile //\n ? [sourceFile.getFilePath()]\n : [];\n });\n};\n\nconst extractGenerics = (\n callExpression: CallExpression,\n): Array<{ node: Node; comments: Array<string> }> => {\n return callExpression.getTypeArguments().map((node) => {\n return {\n node,\n comments: node\n .getLeadingCommentRanges()\n .map((range) => range.getText().trim()),\n };\n });\n};\n\nexport const typeResolverFactory = ({ appRoot }: PluginOptionsResolved) => {\n const project = createProject({\n tsConfigFilePath: resolve(appRoot, \"tsconfig.json\"),\n skipAddingFilesFromTsConfig: true,\n });\n\n const literalTypesResolver = (\n literalTypes: string,\n options: Parameters<typeof flattener>[2],\n ) => {\n const sourceFile = project.createSourceFile(\n `${crc(literalTypes)}-${Date.now()}.ts`,\n literalTypes,\n { overwrite: true },\n );\n\n const resolvedTypes = flattener(project, sourceFile, {\n ...options,\n stripComments: true,\n });\n\n project.removeSourceFile(sourceFile);\n\n return resolvedTypes;\n };\n\n return {\n getSourceFile: (fileFullpath: string) => {\n return (\n project.getSourceFile(fileFullpath) ||\n project.addSourceFileAtPath(fileFullpath)\n );\n },\n refreshSourceFile: async (fileFullpath: string) => {\n const sourceFile = project.getSourceFile(fileFullpath);\n if (sourceFile) {\n await sourceFile.refreshFromFileSystem();\n }\n },\n literalTypesResolver,\n };\n};\n", "import { resolve } from \"node:path\";\n\nimport crc from \"crc/crc32\";\nimport fsx from \"fs-extra\";\n\nimport pkg from \"@kosmojs/dev/package.json\" with { type: \"json\" };\nimport { type ApiRoute, pathResolver } from \"@kosmojs/devlib\";\n\nexport type Cache = {\n hash: number;\n referencedFiles: Record<string, number>;\n} & Pick<\n ApiRoute,\n | \"params\"\n | \"methods\"\n | \"typeDeclarations\"\n | \"numericParams\"\n | \"payloadTypes\"\n | \"responseTypes\"\n>;\n\ntype ExtraContext = Record<string | number, unknown>;\n\nexport const cacheFactory = (\n route: Pick<ApiRoute, \"file\" | \"fileFullpath\" | \"importName\" | \"importPath\">,\n {\n appRoot,\n sourceFolder,\n extraContext,\n }: {\n appRoot: string;\n sourceFolder: string;\n extraContext?: ExtraContext;\n },\n) => {\n const cacheFile = pathResolver({\n appRoot,\n sourceFolder,\n }).resolve(\"apiLibDir\", route.importPath, \"cache.json\");\n\n const getCache = async (opt?: {\n validate?: boolean;\n }): Promise<Cache | undefined> => {\n if (await fsx.exists(cacheFile)) {\n try {\n const cache = JSON.parse(await fsx.readFile(cacheFile, \"utf8\"));\n return opt?.validate //\n ? validateCache(cache)\n : cache;\n } catch (_e) {}\n }\n return undefined;\n };\n\n const persistCache = async ({\n referencedFiles: _referencedFiles,\n ...rest\n }: Omit<Cache, \"hash\" | \"referencedFiles\"> & {\n referencedFiles: Array<string>;\n }): Promise<Cache> => {\n const hash = await generateFileHash(route.fileFullpath, {\n ...extraContext,\n });\n\n const referencedFiles: Cache[\"referencedFiles\"] = {};\n\n for (const file of _referencedFiles) {\n referencedFiles[\n // Strip project root to ensure cached paths are relative\n // and portable across environments (CI, local, etc.)\n file.replace(`${appRoot}/`, \"\")\n ] = await generateFileHash(file);\n }\n\n const cache = { ...rest, hash, referencedFiles };\n\n await fsx.outputJson(cacheFile, cache, { spaces: 2 });\n\n return cache;\n };\n\n const validateCache = async (\n cache: Cache | undefined,\n ): Promise<Cache | undefined> => {\n if (!cache?.hash) {\n return;\n }\n\n if (!cache.typeDeclarations || !cache.referencedFiles) {\n // incomplete cache\n return;\n }\n\n const hash = await generateFileHash(route.fileFullpath, {\n ...extraContext,\n });\n\n if (!identicalHashSum(cache.hash, hash)) {\n // route itself updated\n return;\n }\n\n for (const [file, hash] of Object.entries(cache.referencedFiles)) {\n if (\n !identicalHashSum(hash, await generateFileHash(resolve(appRoot, file)))\n ) {\n // some referenced file updated\n return;\n }\n }\n\n return cache;\n };\n\n return {\n getCache,\n validateCache,\n persistCache,\n };\n};\n\nconst generateFileHash = async (\n file: string,\n extraContext?: ExtraContext,\n): Promise<number> => {\n let fileContent: string | undefined;\n try {\n fileContent = await fsx.readFile(file, \"utf8\");\n } catch (_e) {\n // file could be deleted since last build\n return 0;\n }\n return fileContent\n ? crc(\n JSON.stringify({\n ...extraContext,\n [pkg.cacheVersion]: fileContent,\n }),\n )\n : 0;\n};\n\n// return true if sums are identical\nconst identicalHashSum = (a: number, b: number) => {\n return a === b;\n};\n", "{{#each resolvedTypes}}\nexport type {{name}} = {{text}};\n{{/each}}\n", "{{#each typeDeclarations}}{{text}}\n{{/each}}\n\nexport type {{params.id}} = {\n {{#each paramsSchema}}\n \"{{name}}\"{{#unless isRequired}}?{{/unless}}:{{#if isRest}} Array<{{/if}}\n {{#if refinement}}{{refinement.text}}{{else}}string{{/if}}\n {{#if isRest}}>{{/if}}\n {{/each}}\n};\n\n{{#each payloadTypes}}\nexport type {{id}} = {{text}};\n{{/each}}\n\n{{#each responseTypes}}\nexport type {{id}} = {{text}};\n{{/each}}\n"],
5
+ "mappings": ";AAAA,SAAS,SAAS,MAAM,WAAAA,gBAAe;AAEvC,OAAOC,UAAS;AAChB,OAAO,eAAe;AACtB,SAAS,YAAY;AAErB;AAAA,EAEE;AAAA,EAGA,gBAAAC;AAAA,EACA;AAAA,EAGA;AAAA,EACA;AAAA,OACK;;;ACjBP,SAAS,eAAe;AAExB,OAAO,SAAS;AAChB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