Skip to content

Commit

Permalink
Add task and workflow utility types (#34)
Browse files Browse the repository at this point in the history
feat(typescript): add task and workflow utility types
  • Loading branch information
krvital authored Oct 21, 2024
1 parent e933369 commit b1f750b
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 7 deletions.
13 changes: 13 additions & 0 deletions resources/sdk/typescript/types/task/SystemSendMessage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export type SystemSendMessageParams = {
phone: string;
message: string;
};

export type SystemSendMessageResult = {
status: string;
};

export type SystemSendMessage = {
params?: SystemSendMessageParams;
result?: SystemSendMessageResult;
};
28 changes: 28 additions & 0 deletions resources/sdk/typescript/types/task/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { SystemSendMessage } from "./SystemSendMessage";

type WaitTaskDuration = {
duration: {
hours: number;
minutes: number;
seconds: number;
};
until?: never;
};

type WaitTaskUntil = {
duration?: never;
until: string;
};

export type TaskDefinitionsMap = {
"awf.task/wait": {
params: WaitTaskDuration | WaitTaskUntil;
result: Record<string, unknown>;
};
"system/SendMessage": SystemSendMessage;
};

export declare const TaskDefinitionsNameMap: Record<
keyof TaskDefinitionsMap,
string
>;
17 changes: 17 additions & 0 deletions resources/sdk/typescript/types/workflow/SystemCheckOutWorkflow.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export type SystemCheckOutWorkflowParams = {
clientId: string;
};

export type SystemCheckOutWorkflowResult = {
messageId?: string;
};

export type SystemCheckOutWorkflowError = {
message?: string;
};

export type SystemCheckOutWorkflow = {
params?: SystemCheckOutWorkflowParams;
result?: SystemCheckOutWorkflowResult;
error?: SystemCheckOutWorkflowError;
};
10 changes: 10 additions & 0 deletions resources/sdk/typescript/types/workflow/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { SystemCheckOutWorkflow } from "./SystemCheckOutWorkflow";

export type WorkflowDefinitionsMap = {
"system/CheckOutWorkflow": SystemCheckOutWorkflow;
};

export declare const WorkflowDefinitionsNameMap: Record<
keyof WorkflowDefinitionsMap,
string
>;
14 changes: 7 additions & 7 deletions src/aidbox_sdk/generator/typescript.clj
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,13 @@
[x]
(str/replace x #"[\.#]" "-"))

(defn datatypes-file-path []
(io/file "datatypes.ts"))

(defn resource-file-path [ir-schema]
(io/file (package->directory (:package ir-schema))
(io/file "types"
(package->directory (:package ir-schema))
(str (->pascal-case (:resource-name ir-schema)) ".ts")))

(defn search-param-filepath [ir-schema]
(io/file "search" (str (:name ir-schema) "SearchParameters.ts")))
(io/file "types" "search" (str (:name ir-schema) "SearchParameters.ts")))

(defn ->lang-type [fhir-type]
(case fhir-type
Expand Down Expand Up @@ -250,12 +248,14 @@
(generator/prepare-sdk-files
:typescript
["index.ts" "eslint.config.mjs" "http-client.ts" "package.json"
"package-lock.json" "tsconfig.json" "types/index.ts"]))
"package-lock.json" "tsconfig.json" "types/index.ts"
"types/workflow/SystemCheckOutWorkflow.ts" "types/workflow/index.ts"
"types/task/SystemSendMessage.ts" "types/task/index.ts"]))

(generate-valuesets [_ vs-schemas]
(->> vs-schemas
(map (fn [[fhir-version schemas]]
{:path (io/file (package->directory fhir-version) "valuesets.ts")
{:path (io/file "types" (package->directory fhir-version) "valuesets.ts")
:content
(->> schemas
(mapv (fn [vs]
Expand Down

0 comments on commit b1f750b

Please sign in to comment.