Skip to content

Commit

Permalink
fix: search params generation
Browse files Browse the repository at this point in the history
  • Loading branch information
GenaRazmakhnin committed May 10, 2024
1 parent ec488a5 commit 38ebacc
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/generator/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
(let [dirs (file-seq (io/file path))]
(doseq [dir dirs]
(when (and (.isDirectory dir) (not= "types" (.getName dir)))
(when (re-matches #"^hl7-fhir-r.+-core$" (.getName dir))
#_(when (re-matches #"^hl7-fhir-r.+-core$" (.getName dir))
(.write r (format "import { ResourceType } from './%s'\n" (.getName dir))))
(if (.exists (io/file dir "indexPackage.ts"))
(.write r (format "export * from './%s/indexPackage'\n" (.getName dir)))
Expand Down Expand Up @@ -186,6 +186,8 @@
(.write r "/** GENERATED BY zen-cli\nDON'T MODIFY MANUALLY */\n\n")
(mapv #(when-not (contains? #{"string" "boolean"} %) (.write r (format "import { %s } from './%s'\n" % %)))
(keys (get @r/schema package)))
(mapv #(when-not (contains? #{"string" "boolean"} %) (.write r (format "export { %s } from './%s'\n" % %)))
(keys (get @r/schema package)))
(.write r "export interface SubsSubscription {\nid?:string;\nresourceType: 'SubsSubscription';\nstatus: 'active' | 'off';trigger: Partial<Record<ResourceType, { event: Array<'all' | 'create' | 'update' | 'delete'>; filter?: unknown }>>; channel: {\ntype: 'rest-hook';\nendpoint: string;\npayload?: { content: string; contentType: string; context: unknown };headers?: Record<string, string>;\ntimeout?: number;\n};\n}")
(.write r "export type ResourceTypeMap = {\n SubsSubscription: SubsSubscription;\n User: Record<string,any>;\n")
(mapv #(when-not (contains? #{"string" "boolean"} %) (.write r (format " %s: %s;\n" % %)))
Expand Down Expand Up @@ -228,7 +230,9 @@
flatten)
searches (search-params-generator ztx definitions)]
(doseq [package (keys searches)]
(with-open [r (io/writer (io/file path package "index.ts") :append true)]
(println path)
(with-open [r (io/writer (io/file path package "indexPackage.ts") :append true)]
(.write r "\ntype composite = any\n")
(.write r "export interface SearchParams extends Record<ResourceType, unknown> {\n")
(reduce-kv (fn [acc k v]
(.write r (format "'%s': {\n" (name k)))
Expand All @@ -240,12 +244,12 @@

(defn gen-types [ztx zen-path output-folder]
(when (find-and-read-entrypoint ztx zen-path)
(read-ftr ztx zen-path)
(read-ftr ztx zen-path)
(gen-task-types ztx (io/file zen-path output-folder))
(gen-workflow-types ztx (io/file zen-path output-folder))
(gen-package-types ztx (io/file zen-path output-folder))
(gen-searches ztx (io/file zen-path output-folder))
(gen-main-file (io/file zen-path output-folder))
(gen-searches ztx (io/file zen-path output-folder))
true))


Expand Down

0 comments on commit 38ebacc

Please sign in to comment.