@workflow/core 4.0.1-beta.0 → 4.0.1-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +201 -21
- package/dist/define-hook.d.ts +16 -12
- package/dist/define-hook.d.ts.map +1 -1
- package/dist/define-hook.js +25 -14
- package/dist/define-hook.js.map +1 -1
- package/dist/global.d.ts +9 -1
- package/dist/global.d.ts.map +1 -1
- package/dist/global.js +13 -1
- package/dist/global.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/observability.d.ts.map +1 -1
- package/dist/observability.js +13 -6
- package/dist/observability.js.map +1 -1
- package/dist/runtime/start.d.ts +5 -1
- package/dist/runtime/start.d.ts.map +1 -1
- package/dist/runtime/start.js.map +1 -1
- package/dist/runtime/world.d.ts.map +1 -1
- package/dist/runtime/world.js +0 -1
- package/dist/runtime/world.js.map +1 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +90 -13
- package/dist/runtime.js.map +1 -1
- package/dist/schemas.d.ts +1 -1
- package/dist/schemas.d.ts.map +1 -1
- package/dist/serialization.d.ts +1 -0
- package/dist/serialization.d.ts.map +1 -1
- package/dist/serialization.js +4 -2
- package/dist/serialization.js.map +1 -1
- package/dist/sleep.d.ts +33 -0
- package/dist/sleep.d.ts.map +1 -0
- package/dist/sleep.js +10 -0
- package/dist/sleep.js.map +1 -0
- package/dist/step/context-storage.d.ts +1 -0
- package/dist/step/context-storage.d.ts.map +1 -1
- package/dist/step/context-storage.js.map +1 -1
- package/dist/step/writable-stream.d.ts +14 -0
- package/dist/step/writable-stream.d.ts.map +1 -0
- package/dist/step/writable-stream.js +29 -0
- package/dist/step/writable-stream.js.map +1 -0
- package/dist/step.d.ts.map +1 -1
- package/dist/step.js +21 -9
- package/dist/step.js.map +1 -1
- package/dist/symbols.d.ts +1 -0
- package/dist/symbols.d.ts.map +1 -1
- package/dist/symbols.js +1 -0
- package/dist/symbols.js.map +1 -1
- package/dist/telemetry.js +1 -1
- package/dist/telemetry.js.map +1 -1
- package/dist/types.d.ts +0 -7
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +0 -25
- package/dist/types.js.map +1 -1
- package/dist/util.d.ts +4 -27
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js +19 -41
- package/dist/util.js.map +1 -1
- package/dist/workflow/define-hook.d.ts +3 -3
- package/dist/workflow/define-hook.d.ts.map +1 -1
- package/dist/workflow/define-hook.js.map +1 -1
- package/dist/workflow/hook.d.ts.map +1 -1
- package/dist/workflow/hook.js +1 -1
- package/dist/workflow/hook.js.map +1 -1
- package/dist/workflow/index.d.ts +1 -0
- package/dist/workflow/index.d.ts.map +1 -1
- package/dist/workflow/index.js +1 -0
- package/dist/workflow/index.js.map +1 -1
- package/dist/workflow/sleep.d.ts +4 -0
- package/dist/workflow/sleep.d.ts.map +1 -0
- package/dist/workflow/sleep.js +55 -0
- package/dist/workflow/sleep.js.map +1 -0
- package/dist/workflow.d.ts.map +1 -1
- package/dist/workflow.js +13 -3
- package/dist/workflow.js.map +1 -1
- package/dist/writable-stream.d.ts +5 -4
- package/dist/writable-stream.d.ts.map +1 -1
- package/dist/writable-stream.js +6 -5
- package/dist/writable-stream.js.map +1 -1
- package/package.json +16 -8
package/LICENSE.md
CHANGED
|
@@ -1,21 +1,201 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
<http://www.apache.org/licenses/>
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2025 Vercel Inc.
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/dist/define-hook.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
1
2
|
import type { Hook as HookEntity } from '@workflow/world';
|
|
2
3
|
import type { Hook, HookOptions } from './create-hook.js';
|
|
3
4
|
/**
|
|
4
5
|
* Defines a typed hook for type-safe hook creation and resumption.
|
|
5
6
|
*
|
|
6
|
-
* This helper provides type safety by allowing you to define the
|
|
7
|
-
*
|
|
7
|
+
* This helper provides type safety by allowing you to define the input and output types
|
|
8
|
+
* for the hook's payload, with optional validation and transformation via a schema.
|
|
8
9
|
*
|
|
9
|
-
* @
|
|
10
|
+
* @param schema - Schema used to validate and transform the input payload before resuming
|
|
11
|
+
* @returns An object with `create` and `resume` functions pre-typed with the input and output types
|
|
10
12
|
*
|
|
11
13
|
* @example
|
|
12
14
|
*
|
|
@@ -19,35 +21,37 @@ import type { Hook, HookOptions } from './create-hook.js';
|
|
|
19
21
|
* "use workflow";
|
|
20
22
|
*
|
|
21
23
|
* const hook = approvalHook.create();
|
|
22
|
-
* const result = await hook; // Fully typed as { approved: boolean; comment: string }
|
|
24
|
+
* const result = await hook; // Fully typed as { approved: boolean; comment: string; }
|
|
23
25
|
* }
|
|
24
26
|
*
|
|
25
27
|
* // In an API route
|
|
26
28
|
* export async function POST(request: Request) {
|
|
27
29
|
* const { token, approved, comment } = await request.json();
|
|
28
|
-
* await approvalHook.resume(token, { approved, comment });
|
|
30
|
+
* await approvalHook.resume(token, { approved, comment }); // Input type
|
|
29
31
|
* return Response.json({ success: true });
|
|
30
32
|
* }
|
|
31
33
|
* ```
|
|
32
34
|
*/
|
|
33
|
-
export declare function defineHook<
|
|
35
|
+
export declare function defineHook<TInput, TOutput = TInput>({ schema, }?: {
|
|
36
|
+
schema?: StandardSchemaV1<TInput, TOutput>;
|
|
37
|
+
}): {
|
|
34
38
|
/**
|
|
35
|
-
* Creates a new hook with the defined
|
|
39
|
+
* Creates a new hook with the defined output type.
|
|
36
40
|
*
|
|
37
41
|
* Note: This method is not available in runtime bundles. Use it from workflow contexts only.
|
|
38
42
|
*
|
|
39
43
|
* @param _options - Optional hook configuration
|
|
40
|
-
* @returns A Hook that resolves to the defined
|
|
44
|
+
* @returns A Hook that resolves to the defined output type
|
|
41
45
|
*/
|
|
42
|
-
create(
|
|
46
|
+
create(_options?: HookOptions): Hook<TOutput>;
|
|
43
47
|
/**
|
|
44
|
-
* Resumes a hook by sending a payload with the defined type.
|
|
48
|
+
* Resumes a hook by sending a payload with the defined input type.
|
|
45
49
|
* This is a type-safe wrapper around the `resumeHook` runtime function.
|
|
46
50
|
*
|
|
47
51
|
* @param token - The unique token identifying the hook
|
|
48
|
-
* @param payload - The payload to send
|
|
52
|
+
* @param payload - The payload to send; if a `schema` is configured it is validated/transformed before resuming
|
|
49
53
|
* @returns Promise resolving to the hook entity, or null if the hook doesn't exist
|
|
50
54
|
*/
|
|
51
|
-
resume(token: string, payload:
|
|
55
|
+
resume(token: string, payload: TInput): Promise<HookEntity | null>;
|
|
52
56
|
};
|
|
53
57
|
//# sourceMappingURL=define-hook.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define-hook.d.ts","sourceRoot":"","sources":["../src/define-hook.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG1D
|
|
1
|
+
{"version":3,"file":"define-hook.d.ts","sourceRoot":"","sources":["../src/define-hook.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,EAAE,EACnD,MAAM,GACP,GAAE;IACD,MAAM,CAAC,EAAE,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACvC;IAEF;;;;;;;OAOG;sBACe,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC;IAM7C;;;;;;;OAOG;kBACiB,MAAM,WAAW,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;EAkB3E"}
|
package/dist/define-hook.js
CHANGED
|
@@ -2,10 +2,11 @@ import { resumeHook } from './runtime/resume-hook.js';
|
|
|
2
2
|
/**
|
|
3
3
|
* Defines a typed hook for type-safe hook creation and resumption.
|
|
4
4
|
*
|
|
5
|
-
* This helper provides type safety by allowing you to define the
|
|
6
|
-
*
|
|
5
|
+
* This helper provides type safety by allowing you to define the input and output types
|
|
6
|
+
* for the hook's payload, with optional validation and transformation via a schema.
|
|
7
7
|
*
|
|
8
|
-
* @
|
|
8
|
+
* @param schema - Schema used to validate and transform the input payload before resuming
|
|
9
|
+
* @returns An object with `create` and `resume` functions pre-typed with the input and output types
|
|
9
10
|
*
|
|
10
11
|
* @example
|
|
11
12
|
*
|
|
@@ -18,41 +19,51 @@ import { resumeHook } from './runtime/resume-hook.js';
|
|
|
18
19
|
* "use workflow";
|
|
19
20
|
*
|
|
20
21
|
* const hook = approvalHook.create();
|
|
21
|
-
* const result = await hook; // Fully typed as { approved: boolean; comment: string }
|
|
22
|
+
* const result = await hook; // Fully typed as { approved: boolean; comment: string; }
|
|
22
23
|
* }
|
|
23
24
|
*
|
|
24
25
|
* // In an API route
|
|
25
26
|
* export async function POST(request: Request) {
|
|
26
27
|
* const { token, approved, comment } = await request.json();
|
|
27
|
-
* await approvalHook.resume(token, { approved, comment });
|
|
28
|
+
* await approvalHook.resume(token, { approved, comment }); // Input type
|
|
28
29
|
* return Response.json({ success: true });
|
|
29
30
|
* }
|
|
30
31
|
* ```
|
|
31
32
|
*/
|
|
32
|
-
export function defineHook() {
|
|
33
|
+
export function defineHook({ schema, } = {}) {
|
|
33
34
|
return {
|
|
34
35
|
/**
|
|
35
|
-
* Creates a new hook with the defined
|
|
36
|
+
* Creates a new hook with the defined output type.
|
|
36
37
|
*
|
|
37
38
|
* Note: This method is not available in runtime bundles. Use it from workflow contexts only.
|
|
38
39
|
*
|
|
39
40
|
* @param _options - Optional hook configuration
|
|
40
|
-
* @returns A Hook that resolves to the defined
|
|
41
|
+
* @returns A Hook that resolves to the defined output type
|
|
41
42
|
*/
|
|
42
|
-
|
|
43
|
-
create(options) {
|
|
43
|
+
create(_options) {
|
|
44
44
|
throw new Error('`defineHook().create()` can only be called inside a workflow function.');
|
|
45
45
|
},
|
|
46
46
|
/**
|
|
47
|
-
* Resumes a hook by sending a payload with the defined type.
|
|
47
|
+
* Resumes a hook by sending a payload with the defined input type.
|
|
48
48
|
* This is a type-safe wrapper around the `resumeHook` runtime function.
|
|
49
49
|
*
|
|
50
50
|
* @param token - The unique token identifying the hook
|
|
51
|
-
* @param payload - The payload to send
|
|
51
|
+
* @param payload - The payload to send; if a `schema` is configured it is validated/transformed before resuming
|
|
52
52
|
* @returns Promise resolving to the hook entity, or null if the hook doesn't exist
|
|
53
53
|
*/
|
|
54
|
-
resume(token, payload) {
|
|
55
|
-
|
|
54
|
+
async resume(token, payload) {
|
|
55
|
+
if (!schema?.['~standard']) {
|
|
56
|
+
return await resumeHook(token, payload);
|
|
57
|
+
}
|
|
58
|
+
let result = schema['~standard'].validate(payload);
|
|
59
|
+
if (result instanceof Promise) {
|
|
60
|
+
result = await result;
|
|
61
|
+
}
|
|
62
|
+
// if the `issues` field exists, the validation failed
|
|
63
|
+
if (result.issues) {
|
|
64
|
+
throw new Error(JSON.stringify(result.issues, null, 2));
|
|
65
|
+
}
|
|
66
|
+
return await resumeHook(token, result.value);
|
|
56
67
|
},
|
|
57
68
|
};
|
|
58
69
|
}
|
package/dist/define-hook.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define-hook.js","sourceRoot":"","sources":["../src/define-hook.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"define-hook.js","sourceRoot":"","sources":["../src/define-hook.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,UAAU,UAAU,CAA2B,EACnD,MAAM,MAGJ,EAAE;IACJ,OAAO;QACL;;;;;;;WAOG;QACH,MAAM,CAAC,QAAsB;YAC3B,MAAM,IAAI,KAAK,CACb,wEAAwE,CACzE,CAAC;QACJ,CAAC;QAED;;;;;;;WAOG;QACH,KAAK,CAAC,MAAM,CAAC,KAAa,EAAE,OAAe;YACzC,IAAI,CAAC,MAAM,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC;gBAC3B,OAAO,MAAM,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;YAC1C,CAAC;YAED,IAAI,MAAM,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;YACnD,IAAI,MAAM,YAAY,OAAO,EAAE,CAAC;gBAC9B,MAAM,GAAG,MAAM,MAAM,CAAC;YACxB,CAAC;YAED,sDAAsD;YACtD,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;gBAClB,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;YAC1D,CAAC;YAED,OAAO,MAAM,UAAU,CAAU,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;QACxD,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/global.d.ts
CHANGED
|
@@ -11,7 +11,13 @@ export interface HookInvocationQueueItem {
|
|
|
11
11
|
token: string;
|
|
12
12
|
metadata?: Serializable;
|
|
13
13
|
}
|
|
14
|
-
export
|
|
14
|
+
export interface WaitInvocationQueueItem {
|
|
15
|
+
type: 'wait';
|
|
16
|
+
correlationId: string;
|
|
17
|
+
resumeAt: Date;
|
|
18
|
+
hasCreatedEvent?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export type QueueItem = StepInvocationQueueItem | HookInvocationQueueItem | WaitInvocationQueueItem;
|
|
15
21
|
/**
|
|
16
22
|
* An error that is thrown when one or more operations (steps/hooks/etc.) are called but do
|
|
17
23
|
* not yet have corresponding entries in the event log. The workflow
|
|
@@ -23,7 +29,9 @@ export declare class WorkflowSuspension extends Error {
|
|
|
23
29
|
globalThis: typeof globalThis;
|
|
24
30
|
stepCount: number;
|
|
25
31
|
hookCount: number;
|
|
32
|
+
waitCount: number;
|
|
26
33
|
constructor(steps: QueueItem[], global: typeof globalThis);
|
|
34
|
+
static is(value: unknown): value is WorkflowSuspension;
|
|
27
35
|
}
|
|
28
36
|
export declare function ENOTSUP(): never;
|
|
29
37
|
//# sourceMappingURL=global.d.ts.map
|
package/dist/global.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"global.d.ts","sourceRoot":"","sources":["../src/global.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,YAAY,EAAE,CAAC;CACtB;AAED,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,MA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
@@ -9,9 +9,11 @@ export class WorkflowSuspension extends Error {
|
|
|
9
9
|
globalThis;
|
|
10
10
|
stepCount;
|
|
11
11
|
hookCount;
|
|
12
|
+
waitCount;
|
|
12
13
|
constructor(steps, global) {
|
|
13
14
|
const stepCount = steps.filter((s) => s.type === 'step').length;
|
|
14
15
|
const hookCount = steps.filter((s) => s.type === 'hook').length;
|
|
16
|
+
const waitCount = steps.filter((s) => s.type === 'wait').length;
|
|
15
17
|
// Build description parts
|
|
16
18
|
const parts = [];
|
|
17
19
|
if (stepCount > 0) {
|
|
@@ -20,8 +22,11 @@ export class WorkflowSuspension extends Error {
|
|
|
20
22
|
if (hookCount > 0) {
|
|
21
23
|
parts.push(`${hookCount} ${hookCount === 1 ? 'hook' : 'hooks'}`);
|
|
22
24
|
}
|
|
25
|
+
if (waitCount > 0) {
|
|
26
|
+
parts.push(`${waitCount} ${waitCount === 1 ? 'wait' : 'waits'}`);
|
|
27
|
+
}
|
|
23
28
|
// Determine verb (has/have) and action (run/created/received)
|
|
24
|
-
const totalCount = stepCount + hookCount;
|
|
29
|
+
const totalCount = stepCount + hookCount + waitCount;
|
|
25
30
|
const hasOrHave = totalCount === 1 ? 'has' : 'have';
|
|
26
31
|
let action;
|
|
27
32
|
if (stepCount > 0) {
|
|
@@ -30,6 +35,9 @@ export class WorkflowSuspension extends Error {
|
|
|
30
35
|
else if (hookCount > 0) {
|
|
31
36
|
action = 'created';
|
|
32
37
|
}
|
|
38
|
+
else if (waitCount > 0) {
|
|
39
|
+
action = 'created';
|
|
40
|
+
}
|
|
33
41
|
else {
|
|
34
42
|
action = 'received';
|
|
35
43
|
}
|
|
@@ -42,6 +50,10 @@ export class WorkflowSuspension extends Error {
|
|
|
42
50
|
this.globalThis = global;
|
|
43
51
|
this.stepCount = stepCount;
|
|
44
52
|
this.hookCount = hookCount;
|
|
53
|
+
this.waitCount = waitCount;
|
|
54
|
+
}
|
|
55
|
+
static is(value) {
|
|
56
|
+
return value instanceof WorkflowSuspension;
|
|
45
57
|
}
|
|
46
58
|
}
|
|
47
59
|
export function ENOTSUP() {
|
package/dist/global.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"global.js","sourceRoot":"","sources":["../src/global.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"global.js","sourceRoot":"","sources":["../src/global.ts"],"names":[],"mappings":"AA4BA;;;;;GAKG;AACH,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC3C,KAAK,CAAc;IACnB,UAAU,CAAoB;IAC9B,SAAS,CAAS;IAClB,SAAS,CAAS;IAClB,SAAS,CAAS;IAElB,YAAY,KAAkB,EAAE,MAAyB;QACvD,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,MAAM,CAAC;QAChE,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,MAAM,CAAC;QAChE,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,MAAM,CAAC;QAEhE,0BAA0B;QAC1B,MAAM,KAAK,GAAa,EAAE,CAAC;QAC3B,IAAI,SAAS,GAAG,CAAC,EAAE,CAAC;YAClB,KAAK,CAAC,IAAI,CAAC,GAAG,SAAS,IAAI,SAAS,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;QACnE,CAAC;QACD,IAAI,SAAS,GAAG,CAAC,EAAE,CAAC;YAClB,KAAK,CAAC,IAAI,CAAC,GAAG,SAAS,IAAI,SAAS,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;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B,OAAO,KAAK,YAAY,kBAAkB,CAAC;IAC7C,CAAC;CACF;AAED,MAAM,UAAU,OAAO;IACrB,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;AACzD,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -14,5 +14,6 @@ export { createHook, createWebhook, type Hook, type HookOptions, type RequestWit
|
|
|
14
14
|
export { defineHook } from './define-hook.js';
|
|
15
15
|
export { getStepMetadata, type StepMetadata, } from './step/get-step-metadata.js';
|
|
16
16
|
export { getWorkflowMetadata, type WorkflowMetadata, } from './step/get-workflow-metadata.js';
|
|
17
|
-
export {
|
|
17
|
+
export { sleep } from './sleep.js';
|
|
18
|
+
export { getWritable, type WorkflowWritableStreamOptions, } from './step/writable-stream.js';
|
|
18
19
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACL,UAAU,EACV,cAAc,EACd,KAAK,qBAAqB,GAC3B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,UAAU,EACV,aAAa,EACb,KAAK,IAAI,EACT,KAAK,WAAW,EAChB,KAAK,mBAAmB,EACxB,KAAK,OAAO,EACZ,KAAK,cAAc,GACpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EACL,eAAe,EACf,KAAK,YAAY,GAClB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,mBAAmB,EACnB,KAAK,gBAAgB,GACtB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACL,UAAU,EACV,cAAc,EACd,KAAK,qBAAqB,GAC3B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,UAAU,EACV,aAAa,EACb,KAAK,IAAI,EACT,KAAK,WAAW,EAChB,KAAK,mBAAmB,EACxB,KAAK,OAAO,EACZ,KAAK,cAAc,GACpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EACL,eAAe,EACf,KAAK,YAAY,GAClB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,mBAAmB,EACnB,KAAK,gBAAgB,GACtB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EACL,WAAW,EACX,KAAK,6BAA6B,GACnC,MAAM,2BAA2B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -14,5 +14,6 @@ export { createHook, createWebhook, } from './create-hook.js';
|
|
|
14
14
|
export { defineHook } from './define-hook.js';
|
|
15
15
|
export { getStepMetadata, } from './step/get-step-metadata.js';
|
|
16
16
|
export { getWorkflowMetadata, } from './step/get-workflow-metadata.js';
|
|
17
|
-
export {
|
|
17
|
+
export { sleep } from './sleep.js';
|
|
18
|
+
export { getWritable, } from './step/writable-stream.js';
|
|
18
19
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACL,UAAU,EACV,cAAc,GAEf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,UAAU,EACV,aAAa,GAMd,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EACL,eAAe,GAEhB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,mBAAmB,GAEpB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACL,UAAU,EACV,cAAc,GAEf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,UAAU,EACV,aAAa,GAMd,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EACL,eAAe,GAEhB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,mBAAmB,GAEpB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EACL,WAAW,GAEZ,MAAM,2BAA2B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observability.d.ts","sourceRoot":"","sources":["../src/observability.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAcH,eAAO,MAAM,UAAU,GAAI,OAAO,OAAO,KAAG,OAE3C,CAAC;
|
|
1
|
+
{"version":3,"file":"observability.d.ts","sourceRoot":"","sources":["../src/observability.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAcH,eAAO,MAAM,UAAU,GAAI,OAAO,OAAO,KAAG,OAE3C,CAAC;AAmGF,eAAO,MAAM,iBAAiB,GAC5B,CAAC,SAAS;IACR,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,SAAS,CAAC,EAAE,GAAG,CAAC;IAChB,gBAAgB,CAAC,EAAE,GAAG,CAAC;CACxB,EAED,UAAU,CAAC,KACV,CAmBF,CAAC;AAEF;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,EAAE,CAmBvD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,SAAK,GAAG,MAAM,CAG7D"}
|
package/dist/observability.js
CHANGED
|
@@ -12,10 +12,11 @@ export const isStreamId = (value) => {
|
|
|
12
12
|
};
|
|
13
13
|
const streamToStreamId = (value) => {
|
|
14
14
|
if ('name' in value) {
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
const name = String(value.name);
|
|
16
|
+
if (!name.startsWith(STREAM_ID_PREFIX)) {
|
|
17
|
+
return `${STREAM_ID_PREFIX}${name}`;
|
|
17
18
|
}
|
|
18
|
-
return
|
|
19
|
+
return name;
|
|
19
20
|
}
|
|
20
21
|
return `${STREAM_ID_PREFIX}null`;
|
|
21
22
|
};
|
|
@@ -54,11 +55,17 @@ const hydrateWorkflowIO = (workflow) => {
|
|
|
54
55
|
};
|
|
55
56
|
};
|
|
56
57
|
const hydrateEventData = (event) => {
|
|
58
|
+
if (!event.eventData) {
|
|
59
|
+
return event;
|
|
60
|
+
}
|
|
57
61
|
return {
|
|
58
62
|
...event,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
63
|
+
// Events have various top-level non-devalued keys, so we need to
|
|
64
|
+
// hydrate each value individually.
|
|
65
|
+
eventData: Object.fromEntries(Object.entries(event.eventData).map(([key, value]) => [
|
|
66
|
+
key,
|
|
67
|
+
hydrateStepArguments(value, [], globalThis),
|
|
68
|
+
])),
|
|
62
69
|
};
|
|
63
70
|
};
|
|
64
71
|
const hydrateHookMetadata = (hook) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observability.js","sourceRoot":"","sources":["../src/observability.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,wBAAwB,EACxB,0BAA0B,GAC3B,MAAM,oBAAoB,CAAC;AAE5B,MAAM,gBAAgB,GAAG,OAAO,CA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M,UAAU,gBAAgB,CAAC,GAAY;IAC3C,MAAM,SAAS,GAAa,EAAE,CAAC;IAE/B,SAAS,QAAQ,CAAC,KAAc;QAC9B,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;YACtB,SAAS,CAAC,IAAI,CAAC,KAAe,CAAC,CAAC;QAClC,CAAC;aAAM,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YAChC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;gBACzB,QAAQ,CAAC,IAAI,CAAC,CAAC;YACjB,CAAC;QACH,CAAC;aAAM,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9C,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;gBACvC,QAAQ,CAAC,GAAG,CAAC,CAAC;YAChB,CAAC;QACH,CAAC;IACH,CAAC;IAED,QAAQ,CAAC,GAAG,CAAC,CAAC;IACd,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,oBAAoB;AAC7D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,EAAU,EAAE,SAAS,GAAG,EAAE;IACnD,IAAI,EAAE,CAAC,MAAM,IAAI,SAAS;QAAE,OAAO,EAAE,CAAC;IACtC,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,KAAK,CAAC;AACxC,CAAC"}
|
package/dist/runtime/start.d.ts
CHANGED
|
@@ -2,6 +2,10 @@ import { Run } from '../runtime.js';
|
|
|
2
2
|
export interface StartOptions {
|
|
3
3
|
/**
|
|
4
4
|
* The deployment ID to use for the workflow run.
|
|
5
|
+
*
|
|
6
|
+
* @deprecated This property should not be set in user code under normal circumstances.
|
|
7
|
+
* It is automatically inferred from environment variables when deploying to Vercel.
|
|
8
|
+
* Only set this if you are doing something advanced and know what you are doing.
|
|
5
9
|
*/
|
|
6
10
|
deploymentId?: string;
|
|
7
11
|
}
|
|
@@ -24,5 +28,5 @@ export type WorkflowMetadata = {
|
|
|
24
28
|
* @returns The unique run ID for the newly started workflow invocation.
|
|
25
29
|
*/
|
|
26
30
|
export declare function start<TArgs extends unknown[], TResult>(workflow: WorkflowFunction<TArgs, TResult> | WorkflowMetadata, args: TArgs, options?: StartOptions): Promise<Run<TResult>>;
|
|
27
|
-
export declare function start<
|
|
31
|
+
export declare function start<TResult>(workflow: WorkflowFunction<[], TResult> | WorkflowMetadata, options?: StartOptions): Promise<Run<TResult>>;
|
|
28
32
|
//# sourceMappingURL=start.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../src/runtime/start.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAOpC,MAAM,WAAW,YAAY;IAC3B
|
|
1
|
+
{"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../src/runtime/start.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAOpC,MAAM,WAAW,YAAY;IAC3B;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,MAAM,gBAAgB,CAAC,KAAK,SAAS,OAAO,EAAE,EAAE,OAAO,IAAI,CAC/D,GAAG,IAAI,EAAE,KAAK,KACX,OAAO,CAAC,OAAO,CAAC,CAAC;AAEtB;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtD;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,KAAK,SAAS,OAAO,EAAE,EAAE,OAAO,EACpD,QAAQ,EAAE,gBAAgB,CAAC,KAAK,EAAE,OAAO,CAAC,GAAG,gBAAgB,EAC7D,IAAI,EAAE,KAAK,EACX,OAAO,CAAC,EAAE,YAAY,GACrB,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;AAEzB,wBAAgB,KAAK,CAAC,OAAO,EAC3B,QAAQ,EAAE,gBAAgB,CAAC,EAAE,EAAE,OAAO,CAAC,GAAG,gBAAgB,EAC1D,OAAO,CAAC,EAAE,YAAY,GACrB,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start.js","sourceRoot":"","sources":["../../src/runtime/start.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpC,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,KAAK,SAAS,MAAM,sCAAsC,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"start.js","sourceRoot":"","sources":["../../src/runtime/start.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpC,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,KAAK,SAAS,MAAM,sCAAsC,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AA4CtC,MAAM,CAAC,KAAK,UAAU,KAAK,CACzB,QA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MAAM,CAAC;YAC1C,YAAY,EAAE,YAAY;YAC1B,YAAY,EAAE,YAAY;YAC1B,KAAK,EAAE,iBAAiB;YACxB,gBAAgB,EAAE,EAAE,YAAY,EAAE;SACnC,CAAC,CAAC;QACH,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QAE5B,IAAI,EAAE,aAAa,CAAC;YAClB,GAAG,SAAS,CAAC,aAAa,CAAC,WAAW,CAAC,KAAK,CAAC;YAC7C,GAAG,SAAS,CAAC,iBAAiB,CAAC,WAAW,CAAC,MAAM,CAAC;YAClD,GAAG,SAAS,CAAC,YAAY,CAAC,YAAY,CAAC;SACxC,CAAC,CAAC;QAEH,MAAM,KAAK,CAAC,KAAK,CACf,kBAAkB,YAAY,EAAE,EAChC;YACE,KAAK,EAAE,WAAW,CAAC,KAAK;YACxB,YAAY;SACmB,EACjC;YACE,YAAY;SACb,CACF,CAAC;QAEF,OAAO,IAAI,GAAG,CAAU,WAAW,CAAC,KAAK,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"world.d.ts","sourceRoot":"","sources":["../../src/runtime/world.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAiB7C;;;;GAIG;AACH,eAAO,MAAM,WAAW,QAAO,
|
|
1
|
+
{"version":3,"file":"world.d.ts","sourceRoot":"","sources":["../../src/runtime/world.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAiB7C;;;;GAIG;AACH,eAAO,MAAM,WAAW,QAAO,KAiC9B,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,QAAO,IAAI,CAAC,KAAK,EAAE,oBAAoB,CASnE,CAAC;AAEF,eAAO,MAAM,QAAQ,QAAO,KAM3B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,QAAQ,GAAI,OAAO,KAAK,GAAG,SAAS,KAAG,IAGnD,CAAC"}
|
package/dist/runtime/world.js
CHANGED
|
@@ -32,7 +32,6 @@ export const createWorld = () => {
|
|
|
32
32
|
if (targetWorld === 'embedded') {
|
|
33
33
|
return createEmbeddedWorld({
|
|
34
34
|
dataDir: process.env.WORKFLOW_EMBEDDED_DATA_DIR,
|
|
35
|
-
port: process.env.PORT ? Number(process.env.PORT) : undefined,
|
|
36
35
|
});
|
|
37
36
|
}
|
|
38
37
|
const mod = require(targetWorld);
|