@workflow/world-local 4.0.1-beta.2 → 4.0.1-beta.20
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/config.d.ts +14 -4
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +29 -10
- package/dist/config.js.map +1 -1
- package/dist/fs.d.ts +13 -0
- package/dist/fs.d.ts.map +1 -1
- package/dist/fs.js +53 -11
- package/dist/fs.js.map +1 -1
- package/dist/index.d.ts +7 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -9
- package/dist/index.js.map +1 -1
- package/dist/queue.d.ts +2 -1
- package/dist/queue.d.ts.map +1 -1
- package/dist/queue.js +92 -40
- package/dist/queue.js.map +1 -1
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +147 -90
- package/dist/storage.js.map +1 -1
- package/dist/streamer.d.ts +1 -1
- package/dist/streamer.d.ts.map +1 -1
- package/dist/streamer.js +81 -20
- package/dist/streamer.js.map +1 -1
- package/package.json +12 -9
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/config.d.ts
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
export declare const DEFAULT_RESOLVE_DATA_OPTION = "all";
|
|
2
|
+
export type Config = {
|
|
3
|
+
dataDir: string;
|
|
4
|
+
port?: number;
|
|
5
|
+
baseUrl?: string;
|
|
6
|
+
};
|
|
2
7
|
export declare const config: {
|
|
3
|
-
readonly value:
|
|
4
|
-
dataDir: string;
|
|
5
|
-
port: number;
|
|
6
|
-
};
|
|
8
|
+
readonly value: Config;
|
|
7
9
|
};
|
|
10
|
+
/**
|
|
11
|
+
* Resolves the base URL for queue requests following the priority order:
|
|
12
|
+
* 1. config.baseUrl (highest priority - full override from args or WORKFLOW_LOCAL_BASE_URL env var)
|
|
13
|
+
* 2. config.port (explicit port override from args)
|
|
14
|
+
* 3. PORT env var (explicit configuration)
|
|
15
|
+
* 4. Auto-detected port via getPort (detect actual listening port)
|
|
16
|
+
*/
|
|
17
|
+
export declare function resolveBaseUrl(config: Partial<Config>): Promise<string>;
|
|
8
18
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,2BAA2B,QAAQ,CAAC;AAMjD,MAAM,MAAM,MAAM,GAAG;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,MAAM;;CAKjB,CAAC;AAEH;;;;;;GAMG;AACH,wBAAsB,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAmB7E"}
|
package/dist/config.js
CHANGED
|
@@ -1,19 +1,38 @@
|
|
|
1
|
+
import { getWorkflowPort } from '@workflow/utils/get-port';
|
|
1
2
|
import { once } from './util.js';
|
|
2
3
|
const getDataDirFromEnv = () => {
|
|
3
|
-
return process.env.
|
|
4
|
+
return process.env.WORKFLOW_LOCAL_DATA_DIR || '.workflow-data';
|
|
4
5
|
};
|
|
5
6
|
export const DEFAULT_RESOLVE_DATA_OPTION = 'all';
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
if (port) {
|
|
9
|
-
return Number(port);
|
|
10
|
-
}
|
|
11
|
-
//
|
|
12
|
-
return 3000;
|
|
7
|
+
const getBaseUrlFromEnv = () => {
|
|
8
|
+
return process.env.WORKFLOW_LOCAL_BASE_URL;
|
|
13
9
|
};
|
|
14
10
|
export const config = once(() => {
|
|
15
11
|
const dataDir = getDataDirFromEnv();
|
|
16
|
-
const
|
|
17
|
-
return { dataDir,
|
|
12
|
+
const baseUrl = getBaseUrlFromEnv();
|
|
13
|
+
return { dataDir, baseUrl };
|
|
18
14
|
});
|
|
15
|
+
/**
|
|
16
|
+
* Resolves the base URL for queue requests following the priority order:
|
|
17
|
+
* 1. config.baseUrl (highest priority - full override from args or WORKFLOW_LOCAL_BASE_URL env var)
|
|
18
|
+
* 2. config.port (explicit port override from args)
|
|
19
|
+
* 3. PORT env var (explicit configuration)
|
|
20
|
+
* 4. Auto-detected port via getPort (detect actual listening port)
|
|
21
|
+
*/
|
|
22
|
+
export async function resolveBaseUrl(config) {
|
|
23
|
+
if (config.baseUrl) {
|
|
24
|
+
return config.baseUrl;
|
|
25
|
+
}
|
|
26
|
+
if (typeof config.port === 'number') {
|
|
27
|
+
return `http://localhost:${config.port}`;
|
|
28
|
+
}
|
|
29
|
+
if (process.env.PORT) {
|
|
30
|
+
return `http://localhost:${process.env.PORT}`;
|
|
31
|
+
}
|
|
32
|
+
const detectedPort = await getWorkflowPort();
|
|
33
|
+
if (detectedPort) {
|
|
34
|
+
return `http://localhost:${detectedPort}`;
|
|
35
|
+
}
|
|
36
|
+
throw new Error('Unable to resolve base URL for workflow queue.');
|
|
37
|
+
}
|
|
19
38
|
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,iBAAiB,GAAG,GAAG,EAAE;IAC7B,OAAO,OAAO,CAAC,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,iBAAiB,GAAG,GAAG,EAAE;IAC7B,OAAO,OAAO,CAAC,GAAG,CAAC,uBAAuB,IAAI,gBAAgB,CAAC;AACjE,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,2BAA2B,GAAG,KAAK,CAAC;AAEjD,MAAM,iBAAiB,GAAG,GAAG,EAAE;IAC7B,OAAO,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC;AAC7C,CAAC,CAAC;AAQF,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,CAAS,GAAG,EAAE;IACtC,MAAM,OAAO,GAAG,iBAAiB,EAAE,CAAC;IACpC,MAAM,OAAO,GAAG,iBAAiB,EAAE,CAAC;IAEpC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AAC9B,CAAC,CAAC,CAAC;AAEH;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,MAAuB;IAC1D,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,OAAO,MAAM,CAAC,OAAO,CAAC;IACxB,CAAC;IAED,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QACpC,OAAO,oBAAoB,MAAM,CAAC,IAAI,EAAE,CAAC;IAC3C,CAAC;IAED,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;QACrB,OAAO,oBAAoB,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;IAChD,CAAC;IAED,MAAM,YAAY,GAAG,MAAM,eAAe,EAAE,CAAC;IAC7C,IAAI,YAAY,EAAE,CAAC;QACjB,OAAO,oBAAoB,YAAY,EAAE,CAAC;IAC5C,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;AACpE,CAAC"}
|
package/dist/fs.d.ts
CHANGED
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
import type { PaginatedResponse } from '@workflow/world';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
+
/**
|
|
4
|
+
* Clear the created files cache. Useful for testing or when files are deleted externally.
|
|
5
|
+
*/
|
|
6
|
+
export declare function clearCreatedFilesCache(): void;
|
|
3
7
|
export declare function ulidToDate(maybeUlid: string): Date | null;
|
|
4
8
|
export declare function ensureDir(dirPath: string): Promise<void>;
|
|
5
9
|
interface WriteOptions {
|
|
6
10
|
overwrite?: boolean;
|
|
7
11
|
}
|
|
8
12
|
export declare function writeJSON(filePath: string, data: any, opts?: WriteOptions): Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Writes data to a file using atomic write-rename pattern.
|
|
15
|
+
*
|
|
16
|
+
* Note: While this function uses temp files to avoid partial writes,
|
|
17
|
+
* it does not provide protection against concurrent writes from multiple
|
|
18
|
+
* processes. In a multi-writer scenario, the last writer wins.
|
|
19
|
+
* For production use with multiple writers, consider using a proper
|
|
20
|
+
* database or locking mechanism.
|
|
21
|
+
*/
|
|
9
22
|
export declare function write(filePath: string, data: string | Buffer, opts?: WriteOptions): Promise<void>;
|
|
10
23
|
export declare function readJSON<T>(filePath: string, decoder: z.ZodType<T>): Promise<T | null>;
|
|
11
24
|
export declare function readBuffer(filePath: string): Promise<Buffer>;
|
package/dist/fs.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../src/fs.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../src/fs.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAUxB;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,IAAI,CAE7C;AAED,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAOzD;AAED,wBAAsB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAM9D;AAED,UAAU,YAAY;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,wBAAsB,SAAS,CAC7B,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,GAAG,EACT,IAAI,CAAC,EAAE,YAAY,GAClB,OAAO,CAAC,IAAI,CAAC,CAEf;AAED;;;;;;;;GAQG;AACH,wBAAsB,KAAK,CACzB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,GAAG,MAAM,EACrB,IAAI,CAAC,EAAE,YAAY,GAClB,OAAO,CAAC,IAAI,CAAC,CA4Cf;AAED,wBAAsB,QAAQ,CAAC,CAAC,EAC9B,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GACpB,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAQnB;AAED,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAGlE;AAED,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAMhE;AAED,wBAAsB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAUtE;AAED,UAAU,8BAA8B,CAAC,CAAC;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC;IAC9B,SAAS,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC;IAC5C,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,MAAM,CAAC;CACzB;AAqBD,wBAAsB,wBAAwB,CAAC,CAAC,SAAS;IAAE,SAAS,EAAE,IAAI,CAAA;CAAE,EAC1E,MAAM,EAAE,8BAA8B,CAAC,CAAC,CAAC,GACxC,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CA+I/B"}
|
package/dist/fs.js
CHANGED
|
@@ -5,6 +5,15 @@ import { decodeTime, monotonicFactory } from 'ulid';
|
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
const ulid = monotonicFactory(() => Math.random());
|
|
7
7
|
const Ulid = z.string().ulid();
|
|
8
|
+
// In-memory cache of created files to avoid expensive fs.access() calls
|
|
9
|
+
// This is safe because we only write once per file path (no overwrites without explicit flag)
|
|
10
|
+
const createdFilesCache = new Set();
|
|
11
|
+
/**
|
|
12
|
+
* Clear the created files cache. Useful for testing or when files are deleted externally.
|
|
13
|
+
*/
|
|
14
|
+
export function clearCreatedFilesCache() {
|
|
15
|
+
createdFilesCache.clear();
|
|
16
|
+
}
|
|
8
17
|
export function ulidToDate(maybeUlid) {
|
|
9
18
|
const ulid = Ulid.safeParse(maybeUlid);
|
|
10
19
|
if (!ulid.success) {
|
|
@@ -23,10 +32,27 @@ export async function ensureDir(dirPath) {
|
|
|
23
32
|
export async function writeJSON(filePath, data, opts) {
|
|
24
33
|
return write(filePath, JSON.stringify(data, null, 2), opts);
|
|
25
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Writes data to a file using atomic write-rename pattern.
|
|
37
|
+
*
|
|
38
|
+
* Note: While this function uses temp files to avoid partial writes,
|
|
39
|
+
* it does not provide protection against concurrent writes from multiple
|
|
40
|
+
* processes. In a multi-writer scenario, the last writer wins.
|
|
41
|
+
* For production use with multiple writers, consider using a proper
|
|
42
|
+
* database or locking mechanism.
|
|
43
|
+
*/
|
|
26
44
|
export async function write(filePath, data, opts) {
|
|
27
45
|
if (!opts?.overwrite) {
|
|
46
|
+
// Fast path: check in-memory cache first to avoid expensive fs.access() calls
|
|
47
|
+
// This provides significant performance improvement when creating many files
|
|
48
|
+
if (createdFilesCache.has(filePath)) {
|
|
49
|
+
throw new WorkflowAPIError(`File ${filePath} already exists and 'overwrite' is false`, { status: 409 });
|
|
50
|
+
}
|
|
51
|
+
// Slow path: check filesystem for files created before this process started
|
|
28
52
|
try {
|
|
29
53
|
await fs.access(filePath);
|
|
54
|
+
// File exists on disk, add to cache for future checks
|
|
55
|
+
createdFilesCache.add(filePath);
|
|
30
56
|
throw new WorkflowAPIError(`File ${filePath} already exists and 'overwrite' is false`, { status: 409 });
|
|
31
57
|
}
|
|
32
58
|
catch (error) {
|
|
@@ -37,13 +63,20 @@ export async function write(filePath, data, opts) {
|
|
|
37
63
|
}
|
|
38
64
|
}
|
|
39
65
|
const tempPath = `${filePath}.tmp.${ulid()}`;
|
|
66
|
+
let tempFileCreated = false;
|
|
40
67
|
try {
|
|
41
68
|
await ensureDir(path.dirname(filePath));
|
|
42
69
|
await fs.writeFile(tempPath, data);
|
|
70
|
+
tempFileCreated = true;
|
|
43
71
|
await fs.rename(tempPath, filePath);
|
|
72
|
+
// Track this file in cache so future writes know it exists
|
|
73
|
+
createdFilesCache.add(filePath);
|
|
44
74
|
}
|
|
45
75
|
catch (error) {
|
|
46
|
-
|
|
76
|
+
// Only try to clean up temp file if it was actually created
|
|
77
|
+
if (tempFileCreated) {
|
|
78
|
+
await fs.unlink(tempPath).catch(() => { });
|
|
79
|
+
}
|
|
47
80
|
throw error;
|
|
48
81
|
}
|
|
49
82
|
}
|
|
@@ -130,21 +163,30 @@ export async function paginatedFileSystemQuery(config) {
|
|
|
130
163
|
: fileTime > cursorTime;
|
|
131
164
|
}
|
|
132
165
|
}
|
|
133
|
-
//
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
// Even without cursor, skip files where getCreatedAt returns null for consistency
|
|
139
|
-
candidateFileIds = relevantFileIds.filter((fileId) => {
|
|
140
|
-
return getCreatedAt(`${fileId}.json`) !== null;
|
|
166
|
+
// Can't extract timestamp from filename (e.g., steps use sequential IDs).
|
|
167
|
+
// Include the file and defer to JSON-based filtering below.
|
|
168
|
+
return true;
|
|
141
169
|
});
|
|
142
170
|
}
|
|
143
171
|
// 4. Load files individually and collect valid items
|
|
144
172
|
const validItems = [];
|
|
145
173
|
for (const fileId of candidateFileIds) {
|
|
146
174
|
const filePath = path.join(directory, `${fileId}.json`);
|
|
147
|
-
|
|
175
|
+
let item = null;
|
|
176
|
+
try {
|
|
177
|
+
item = await readJSON(filePath, schema);
|
|
178
|
+
}
|
|
179
|
+
catch (error) {
|
|
180
|
+
// We don't expect zod errors to happen, but if the JSON does get malformed,
|
|
181
|
+
// we skip the item. Preferably, we'd have a way to mark items as malformed,
|
|
182
|
+
// so that the UI can display them as such, with richer messaging. In the meantime,
|
|
183
|
+
// we just log a warning and skip the item.
|
|
184
|
+
if (error instanceof z.ZodError) {
|
|
185
|
+
console.warn(`Skipping item ${fileId} due to malformed JSON: ${error.message}`);
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
188
|
+
throw error;
|
|
189
|
+
}
|
|
148
190
|
if (item) {
|
|
149
191
|
// Apply custom filter early if provided
|
|
150
192
|
if (filter && !filter(item))
|
|
@@ -198,7 +240,7 @@ export async function paginatedFileSystemQuery(config) {
|
|
|
198
240
|
// 6. Apply pagination
|
|
199
241
|
const hasMore = validItems.length > limit;
|
|
200
242
|
const items = hasMore ? validItems.slice(0, limit) : validItems;
|
|
201
|
-
const nextCursor =
|
|
243
|
+
const nextCursor = items.length > 0
|
|
202
244
|
? createCursor(items[items.length - 1].createdAt, getId?.(items[items.length - 1]))
|
|
203
245
|
: null;
|
|
204
246
|
return {
|
package/dist/fs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fs.js","sourceRoot":"","sources":["../src/fs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,MAAM,CAAC;AACpD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,IAAI,GAAG,gBAAgB,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;AAEnD,MAAM,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC;AAE/B,MAAM,UAAU,UAAU,CAAC,SAAiB;IAC1C,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IACvC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QAClB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,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AU,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;IAChE,MAAM,UAAU,GACd,KAAK,CAAC,MAAM,GAAG,CAAC;QACd,CAAC,CAAC,YAAY,CACV,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,SAAS,EACjC,KAAK,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CACjC;QACH,CAAC,CAAC,IAAI,CAAC;IAEX,OAAO;QACL,IAAI,EAAE,KAAK;QACX,MAAM,EAAE,UAAU;QAClB,OAAO;KACR,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { World } from '@workflow/world';
|
|
2
|
+
import type { Config } from './config.js';
|
|
2
3
|
/**
|
|
3
|
-
* Creates
|
|
4
|
+
* Creates a local world instance that combines queue, storage, and streamer functionalities.
|
|
4
5
|
*
|
|
5
|
-
* @param
|
|
6
|
-
* @param
|
|
6
|
+
* @param args - Optional configuration object
|
|
7
|
+
* @param args.dataDir - Directory for storing workflow data (default: `.workflow-data/`)
|
|
8
|
+
* @param args.port - Port override for queue transport (default: auto-detected)
|
|
9
|
+
* @param args.baseUrl - Full base URL override for queue transport (default: `http://localhost:{port}`)
|
|
7
10
|
*/
|
|
8
|
-
export declare function
|
|
9
|
-
dataDir?: string;
|
|
10
|
-
port?: number;
|
|
11
|
-
}): World;
|
|
11
|
+
export declare function createLocalWorld(args?: Partial<Config>): World;
|
|
12
12
|
//# 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,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAM1C;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,KAAK,CAY9D"}
|
package/dist/index.js
CHANGED
|
@@ -3,18 +3,22 @@ import { createQueue } from './queue.js';
|
|
|
3
3
|
import { createStorage } from './storage.js';
|
|
4
4
|
import { createStreamer } from './streamer.js';
|
|
5
5
|
/**
|
|
6
|
-
* Creates
|
|
6
|
+
* Creates a local world instance that combines queue, storage, and streamer functionalities.
|
|
7
7
|
*
|
|
8
|
-
* @param
|
|
9
|
-
* @param
|
|
8
|
+
* @param args - Optional configuration object
|
|
9
|
+
* @param args.dataDir - Directory for storing workflow data (default: `.workflow-data/`)
|
|
10
|
+
* @param args.port - Port override for queue transport (default: auto-detected)
|
|
11
|
+
* @param args.baseUrl - Full base URL override for queue transport (default: `http://localhost:{port}`)
|
|
10
12
|
*/
|
|
11
|
-
export function
|
|
12
|
-
const
|
|
13
|
-
|
|
13
|
+
export function createLocalWorld(args) {
|
|
14
|
+
const definedArgs = args
|
|
15
|
+
? Object.fromEntries(Object.entries(args).filter(([, value]) => value !== undefined))
|
|
16
|
+
: {};
|
|
17
|
+
const mergedConfig = { ...config.value, ...definedArgs };
|
|
14
18
|
return {
|
|
15
|
-
...createQueue(
|
|
16
|
-
...createStorage(
|
|
17
|
-
...createStreamer(
|
|
19
|
+
...createQueue(mergedConfig),
|
|
20
|
+
...createStorage(mergedConfig.dataDir),
|
|
21
|
+
...createStreamer(mergedConfig.dataDir),
|
|
18
22
|
};
|
|
19
23
|
}
|
|
20
24
|
//# 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":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAsB;IACrD,MAAM,WAAW,GAAG,IAAI;QACtB,CAAC,CAAC,MAAM,CAAC,WAAW,CAChB,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,CAChE;QACH,CAAC,CAAC,EAAE,CAAC;IACP,MAAM,YAAY,GAAG,EAAE,GAAG,MAAM,CAAC,KAAK,EAAE,GAAG,WAAW,EAAE,CAAC;IACzD,OAAO;QACL,GAAG,WAAW,CAAC,YAAY,CAAC;QAC5B,GAAG,aAAa,CAAC,YAAY,CAAC,OAAO,CAAC;QACtC,GAAG,cAAc,CAAC,YAAY,CAAC,OAAO,CAAC;KACxC,CAAC;AACJ,CAAC"}
|
package/dist/queue.d.ts
CHANGED
package/dist/queue.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../src/queue.ts"],"names":[],"mappings":"AAEA,OAAO,EAAa,KAAK,KAAK,EAAkB,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../src/queue.ts"],"names":[],"mappings":"AAEA,OAAO,EAAa,KAAK,KAAK,EAAkB,MAAM,iBAAiB,CAAC;AAKxE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AA2B1C,wBAAgB,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,KAAK,CAgL1D"}
|