Skip to content

Commit 59af63f

Browse files
committed
workflow: stub workflow/api package so it can be referenced in a workflow context
what's not allowed is to call these functions, so let's stub them and make them fail in runtime. i guess that eventually we will actually implement some of them (start or resumeHook or whatever) in a durable way. Signed-off-by: Gal Schlezinger <gal@spitfire.co.il>
1 parent 6373ab5 commit 59af63f

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

packages/workflow/package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@
2828
"require": "./dist/typescript-plugin.cjs",
2929
"default": "./dist/index.js"
3030
},
31-
"./api": "./dist/api.js",
31+
"./api": {
32+
"types": "./dist/api.d.ts",
33+
"workflow": "./dist/api-workflow.js",
34+
"default": "./dist/api.js"
35+
},
3236
"./internal/errors": "./dist/internal/errors.js",
3337
"./internal/serialization": "./dist/internal/serialization.js",
3438
"./internal/builtins": "./dist/internal/builtins.js",
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
export type {
2+
Event,
3+
StartOptions,
4+
WorkflowReadableStreamOptions,
5+
WorkflowRun,
6+
} from '@workflow/core/runtime';
7+
8+
const workflowStub = (item: string) => {
9+
throw new Error(
10+
`The workflow environment doesn't allow this runtime usage of ${item}.`
11+
);
12+
};
13+
14+
export function Run() {
15+
workflowStub('Run');
16+
}
17+
export const getRun = () => workflowStub('getRun');
18+
export const getHookByToken = () => workflowStub('getHookByToken');
19+
export const resumeHook = () => workflowStub('resumeHook');
20+
export const resumeWebhook = () => workflowStub('resumeWebhook');
21+
export const runStep = () => workflowStub('runStep');
22+
export const start = () => workflowStub('start');

0 commit comments

Comments
 (0)