Skip to content

Commit ba5a73e

Browse files
committed
feat(typescript): add task and workflow utility types
1 parent e933369 commit ba5a73e

File tree

5 files changed

+75
-7
lines changed

5 files changed

+75
-7
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export type SystemSendMessageParams = {
2+
phone: string;
3+
message: string;
4+
};
5+
6+
export type SystemSendMessageResult = {
7+
status: string;
8+
};
9+
10+
export type SystemSendMessage = {
11+
params?: SystemSendMessageParams;
12+
result?: SystemSendMessageResult;
13+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { SystemSendMessage } from "./SystemSendMessage";
2+
3+
type WaitTaskDuration = {
4+
duration: {
5+
hours: number;
6+
minutes: number;
7+
seconds: number;
8+
};
9+
until?: never;
10+
};
11+
12+
type WaitTaskUntil = {
13+
duration?: never;
14+
until: string;
15+
};
16+
17+
export type TaskDefinitionsMap = {
18+
"awf.task/wait": {
19+
params: WaitTaskDuration | WaitTaskUntil;
20+
result: Record<string, unknown>;
21+
};
22+
"system/SendMessage": SystemSendMessage;
23+
};
24+
25+
export declare const TaskDefinitionsNameMap: Record<
26+
keyof TaskDefinitionsMap,
27+
string
28+
>;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
export type SystemCheckOutWorkflowParams = {
2+
clientId: string;
3+
};
4+
5+
export type SystemCheckOutWorkflowResult = {
6+
messageId?: string;
7+
};
8+
9+
export type SystemCheckOutWorkflowError = {
10+
message?: string;
11+
};
12+
13+
export type SystemCheckOutWorkflow = {
14+
params?: SystemCheckOutWorkflowParams;
15+
result?: SystemCheckOutWorkflowResult;
16+
error?: SystemCheckOutWorkflowError;
17+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { SystemCheckOutWorkflow } from "./SystemCheckOutWorkflow";
2+
3+
export type WorkflowDefinitionsMap = {
4+
"system/CheckOutWorkflow": SystemCheckOutWorkflow;
5+
};
6+
7+
export declare const WorkflowDefinitionsNameMap: Record<
8+
keyof WorkflowDefinitionsMap,
9+
string
10+
>;

src/aidbox_sdk/generator/typescript.clj

+7-7
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,13 @@
2121
[x]
2222
(str/replace x #"[\.#]" "-"))
2323

24-
(defn datatypes-file-path []
25-
(io/file "datatypes.ts"))
26-
2724
(defn resource-file-path [ir-schema]
28-
(io/file (package->directory (:package ir-schema))
25+
(io/file "types"
26+
(package->directory (:package ir-schema))
2927
(str (->pascal-case (:resource-name ir-schema)) ".ts")))
3028

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

3432
(defn ->lang-type [fhir-type]
3533
(case fhir-type
@@ -250,12 +248,14 @@
250248
(generator/prepare-sdk-files
251249
:typescript
252250
["index.ts" "eslint.config.mjs" "http-client.ts" "package.json"
253-
"package-lock.json" "tsconfig.json" "types/index.ts"]))
251+
"package-lock.json" "tsconfig.json" "types/index.ts"
252+
"types/workflow/SystemCheckOutWorkflow.ts" "types/workflow/index.ts"
253+
"types/task/SystemSendMessage.ts" "types/task/index.ts"]))
254254

255255
(generate-valuesets [_ vs-schemas]
256256
(->> vs-schemas
257257
(map (fn [[fhir-version schemas]]
258-
{:path (io/file (package->directory fhir-version) "valuesets.ts")
258+
{:path (io/file "types" (package->directory fhir-version) "valuesets.ts")
259259
:content
260260
(->> schemas
261261
(mapv (fn [vs]

0 commit comments

Comments
 (0)