Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add task and workflow utility types #34

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading