From 005b2d2cd7472c76a8b0fc24690e2d12f50dfe82 Mon Sep 17 00:00:00 2001 From: Vitaly Kravtsov Date: Thu, 24 Oct 2024 16:47:46 +0600 Subject: [PATCH] fix(typescript): add typings index --- src/aidbox_sdk/generator/typescript.clj | 30 ++++++++++++++++--------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/aidbox_sdk/generator/typescript.clj b/src/aidbox_sdk/generator/typescript.clj index d4cd480..3deea03 100644 --- a/src/aidbox_sdk/generator/typescript.clj +++ b/src/aidbox_sdk/generator/typescript.clj @@ -230,6 +230,12 @@ "};" "export type ResourceType = keyof ResourceTypeMap;"])) +(defn generate-types-index [packages] + (into ["export * from './workflow';" + "export * from './task';"] + (for [pkg packages] + (format "export * from './%s';" (package->directory pkg))))) + (defrecord TypeScriptCodeGenerator [] CodeGenerator (generate-datatypes [_ ir-schemas] @@ -274,20 +280,24 @@ (let [packages (group-by :package ir-schemas) package-indexes (for [[package schemas] packages] - {:path (io/file "types" - (package->directory package) - "index.ts") + {:path (io/file "types" (package->directory package) "index.ts") :content (str/join "\n" (into (index-exports schemas) (resource-type-map schemas)))}) - + types-index [{:path (io/file "types" "index.ts") + :content (str/join "\n" (generate-types-index (keys packages)))}] common-sdk-files (generator/prepare-sdk-files :typescript - ["index.ts" "eslint.config.mjs" "http-client.ts" "package.json" - "package-lock.json" "tsconfig.json" "types/index.ts" - "types/workflow/SystemCheckOutWorkflow.ts" "types/workflow/index.ts" - "types/task/SystemSendMessage.ts" "types/task/index.ts"])] - - (into common-sdk-files package-indexes))) + ["index.ts" + "eslint.config.mjs" + "http-client.ts" + "package.json" + "package-lock.json" + "tsconfig.json" + "types/workflow/SystemCheckOutWorkflow.ts" + "types/workflow/index.ts" + "types/task/SystemSendMessage.ts" + "types/task/index.ts"])] + (into (into common-sdk-files package-indexes) types-index))) (generate-valuesets [_ vs-schemas] (->> vs-schemas