@brickkit/cli 0.8.2 → 0.9.0
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/README.md +10 -1
- package/dashboard-dist/{CollapsiblePanel-DM8J3g8m.js → CollapsiblePanel-a54TwMKb.js} +1 -1
- package/dashboard-dist/{PopoverPopup-B6eMOlOC.js → PopoverPopup-BLzjTqsi.js} +1 -1
- package/dashboard-dist/{api-reference-wTdT1AVt.js → api-reference-r893F8zi.js} +2 -2
- package/dashboard-dist/app.css +1 -1
- package/dashboard-dist/app.js +13 -13
- package/dashboard-dist/core-BWAwhSFf.js +1 -0
- package/dashboard-dist/{docs-DflzpIIh.js → docs-CkMy3Y5i.js} +1 -1
- package/dashboard-dist/{preload-helper-CVJ-D494.js → preload-helper-CjQDFR0M.js} +1 -1
- package/dist/app-entry2.js +8 -1
- package/dist/app-entry2.js.map +1 -1
- package/dist/bin.js +6 -2
- package/dist/bin.js.map +1 -1
- package/dist/build.js +18 -5
- package/dist/build.js.map +1 -1
- package/dist/dev-telemetry-store.js +148 -5
- package/dist/dev-telemetry-store.js.map +1 -1
- package/dist/dev-telemetry.js.map +1 -1
- package/dist/dev-worker.js +19 -2
- package/dist/dev-worker.js.map +1 -1
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/runner.js +69 -3
- package/dist/runner.js.map +1 -1
- package/dist/workflows.d.ts +61 -0
- package/dist/workflows.d.ts.map +1 -0
- package/dist/workflows.js +1 -0
- package/dist/workflows2.js +298 -0
- package/dist/workflows2.js.map +1 -0
- package/inspector-dist/LICENSE.md +201 -0
- package/inspector-dist/NOTICE +20 -0
- package/inspector-dist/client/assets/api.rpc-l0sNRNKZ.js +1 -0
- package/inspector-dist/client/assets/api.stream._streamId-l0sNRNKZ.js +1 -0
- package/inspector-dist/client/assets/app-CY7CQBRo.css +1 -0
- package/inspector-dist/client/assets/entry.client-BJ6G3n5t.js +11697 -0
- package/inspector-dist/client/assets/highlighted-body-B3W2YXNL-C-3wZnxf.js +19 -0
- package/inspector-dist/client/assets/home-CSKAS4P2.js +4979 -0
- package/inspector-dist/client/assets/index-DECCyMR0.js +4482 -0
- package/inspector-dist/client/assets/index-Dot7CgrA.js +9837 -0
- package/inspector-dist/client/assets/index-HqNj_XIX.js +200 -0
- package/inspector-dist/client/assets/manifest-4baa7c6f.js +1 -0
- package/inspector-dist/client/assets/mermaid-3ZIDBTTL-DC0K8uTy.js +58626 -0
- package/inspector-dist/client/assets/mermaid-3ZIDBTTL-F88p7PFX.css +1 -0
- package/inspector-dist/client/assets/root-Bmn5n3jF.js +305 -0
- package/inspector-dist/client/assets/root-CfCr265_.css +1 -0
- package/inspector-dist/client/assets/run-detail-CWoGxu_0.css +1 -0
- package/inspector-dist/client/assets/run-detail-Cc7tSGNq.js +6237 -0
- package/inspector-dist/client/assets/world-config-context-BAD1QCrR.js +26 -0
- package/inspector-dist/client/assets/zstd-B5R2yJjB.wasm +0 -0
- package/inspector-dist/client/assets/zstd-browser-decoder-BQoRpP7L.js +28 -0
- package/inspector-dist/server/assets/app-C-ZVJtic.js +174880 -0
- package/inspector-dist/server/assets/highlighted-body-B3W2YXNL-C8sq8F_D.js +71 -0
- package/inspector-dist/server/assets/index-BfLBLRRi.js +204 -0
- package/inspector-dist/server/assets/index-BzrGWk7J.js +1164 -0
- package/inspector-dist/server/assets/index-CWJr34WJ.js +1296 -0
- package/inspector-dist/server/assets/index-CYlmUaKx.js +191 -0
- package/inspector-dist/server/assets/mermaid-3ZIDBTTL-Dv5rjfMN.js +58 -0
- package/inspector-dist/server/assets/token-DnLp3wBO.js +95 -0
- package/inspector-dist/server/assets/token-util-Bpfp-B0w.js +33 -0
- package/inspector-dist/server/assets/wrapper-D5LIcZ_u.js +67 -0
- package/inspector-dist/server/assets/zstd-browser-decoder-BM8GpVB8.js +77 -0
- package/inspector-dist/server/index.js +58 -0
- package/package.json +11 -4
- package/dashboard-dist/core-CHWYtApw.js +0 -1
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import { resolveWorkflowPaths } from "@brickkit/core";
|
|
3
|
+
import { pathToFileURL } from "node:url";
|
|
4
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
5
|
+
import { readFile, rm, stat, writeFile } from "node:fs/promises";
|
|
6
|
+
import { dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
7
|
+
//#region src/workflows.ts
|
|
8
|
+
const DIRECTIVE = /["']use (?:step|workflow)["']/;
|
|
9
|
+
/**
|
|
10
|
+
* Every project source file. Not the generated bundle: it holds the directives as
|
|
11
|
+
* text inside the SDK's own code and is already built. Not `.cjs` and `.cts`
|
|
12
|
+
* either: Bun drops `module.exports` from a file a plugin loads.
|
|
13
|
+
*/
|
|
14
|
+
const TRANSFORMED = new RegExp(String.raw`^(?!.*(?:node_modules|\.well-known/workflow/)).*\.(?:m?[jt]s|[jt]sx)$`);
|
|
15
|
+
/** Bun's own loader for each extension: JSX is allowed in `.js` but not in `.mjs`. */
|
|
16
|
+
function loaderFor(path) {
|
|
17
|
+
if (path.endsWith(".tsx")) return "tsx";
|
|
18
|
+
if (/\.m?ts$/.test(path)) return "ts";
|
|
19
|
+
return path.endsWith(".mjs") ? "js" : "jsx";
|
|
20
|
+
}
|
|
21
|
+
async function loadBuilders(root) {
|
|
22
|
+
try {
|
|
23
|
+
const path = createRequire(join(root, "package.json")).resolve("@workflow/builders");
|
|
24
|
+
return {
|
|
25
|
+
builders: await import(pathToFileURL(path).href),
|
|
26
|
+
path
|
|
27
|
+
};
|
|
28
|
+
} catch {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The plugin that turns `"use workflow"` and `"use step"` files into workflows and
|
|
34
|
+
* steps. `registerWorkflowTransform` installs it for the running process;
|
|
35
|
+
* `brick build` hands it to `Bun.build`.
|
|
36
|
+
*
|
|
37
|
+
* @param root - The project root, where the SDK is installed. Default: the working directory.
|
|
38
|
+
* @returns The plugin, or `undefined` when the Workflow SDK and its builders are not
|
|
39
|
+
* installed in the project.
|
|
40
|
+
*/
|
|
41
|
+
async function workflowTransformPlugin(root = process.cwd()) {
|
|
42
|
+
const projectRoot = resolve(root);
|
|
43
|
+
const builders = (await loadBuilders(projectRoot))?.builders;
|
|
44
|
+
if (!builders) return void 0;
|
|
45
|
+
return {
|
|
46
|
+
name: "brick:workflows",
|
|
47
|
+
setup(build) {
|
|
48
|
+
build.onLoad({ filter: TRANSFORMED }, (args) => {
|
|
49
|
+
const source = readFileSync(args.path, "utf8");
|
|
50
|
+
if (!DIRECTIVE.test(source)) return {
|
|
51
|
+
contents: source,
|
|
52
|
+
loader: loaderFor(args.path)
|
|
53
|
+
};
|
|
54
|
+
return builders.applySwcTransform(relative(projectRoot, args.path).replaceAll("\\", "/"), source, "step", args.path, projectRoot, projectRoot).then(({ code }) => ({
|
|
55
|
+
contents: code,
|
|
56
|
+
loader: "jsx"
|
|
57
|
+
}));
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
let installed = false;
|
|
63
|
+
/**
|
|
64
|
+
* Make files marked `"use workflow"` or `"use step"` load as workflows and steps.
|
|
65
|
+
*
|
|
66
|
+
* A workflow function gets the `workflowId` that `defineListener({ workflow })`
|
|
67
|
+
* needs, and a step registers itself so the runtime can run it in this process.
|
|
68
|
+
* `brick dev`, `brick start` and `brick worker` call it before they load the app.
|
|
69
|
+
* Call it in a script or test before importing the files, with the project root.
|
|
70
|
+
*
|
|
71
|
+
* It does nothing, and returns `false`, when the Workflow SDK and its builders are
|
|
72
|
+
* not installed in the project. Bun allows plugins once per process, so a second
|
|
73
|
+
* call is ignored.
|
|
74
|
+
*
|
|
75
|
+
* @param root - The project root, where the SDK is installed. Default: the working directory.
|
|
76
|
+
* @returns Whether the transform is active.
|
|
77
|
+
*/
|
|
78
|
+
async function registerWorkflowTransform(root = process.cwd()) {
|
|
79
|
+
if (installed) return true;
|
|
80
|
+
const plugin = await workflowTransformPlugin(root);
|
|
81
|
+
if (!plugin) return false;
|
|
82
|
+
installed = true;
|
|
83
|
+
Bun.plugin(plugin);
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
/** The state of the last build, kept beside the bundle it describes. */
|
|
87
|
+
const STATE_FILE = ".brick-build.json";
|
|
88
|
+
/** Bump it when what the state records changes, so an older state is not trusted. */
|
|
89
|
+
const STATE_VERSION = 2;
|
|
90
|
+
/**
|
|
91
|
+
* esbuild starts each module of a bundle with a `// <path>` comment, whatever
|
|
92
|
+
* the file (`data.json` too). The other comments it keeps name no file.
|
|
93
|
+
*/
|
|
94
|
+
const MODULE_COMMENT = /^\/\/ (.+)$/gm;
|
|
95
|
+
const LOCKFILES = [
|
|
96
|
+
"bun.lock",
|
|
97
|
+
"bun.lockb",
|
|
98
|
+
"package-lock.json",
|
|
99
|
+
"pnpm-lock.yaml",
|
|
100
|
+
"yarn.lock"
|
|
101
|
+
];
|
|
102
|
+
async function stamps(paths) {
|
|
103
|
+
const list = [...paths];
|
|
104
|
+
const all = await Promise.all(list.map(async (path) => {
|
|
105
|
+
try {
|
|
106
|
+
const { mtimeMs, size } = await stat(path);
|
|
107
|
+
return `${mtimeMs}:${size}`;
|
|
108
|
+
} catch {
|
|
109
|
+
return "";
|
|
110
|
+
}
|
|
111
|
+
}));
|
|
112
|
+
return Object.fromEntries(list.map((path, index) => [path, all[index]]));
|
|
113
|
+
}
|
|
114
|
+
function lockfileOf(root) {
|
|
115
|
+
for (let dir = root;; dir = dirname(dir)) {
|
|
116
|
+
for (const name of LOCKFILES) if (existsSync(join(dir, name))) return join(dir, name);
|
|
117
|
+
if (dirname(dir) === dir) return void 0;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
async function tsconfigInputs(path) {
|
|
121
|
+
const files = /* @__PURE__ */ new Set();
|
|
122
|
+
async function visit(file) {
|
|
123
|
+
if (files.has(file)) return;
|
|
124
|
+
files.add(file);
|
|
125
|
+
let config;
|
|
126
|
+
try {
|
|
127
|
+
config = Bun.JSONC.parse(await readFile(file, "utf8"));
|
|
128
|
+
} catch {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
if (!config || typeof config !== "object" || !("extends" in config)) return;
|
|
132
|
+
const parents = Array.isArray(config.extends) ? config.extends : [config.extends];
|
|
133
|
+
const require = createRequire(file);
|
|
134
|
+
for (const parent of parents) {
|
|
135
|
+
if (typeof parent !== "string") continue;
|
|
136
|
+
const isPath = isAbsolute(parent) || parent.startsWith("./") || parent.startsWith("../");
|
|
137
|
+
const candidates = isPath ? [parent, `${parent}.json`] : [
|
|
138
|
+
`${parent}/tsconfig.json`,
|
|
139
|
+
`${parent}.json`,
|
|
140
|
+
parent
|
|
141
|
+
];
|
|
142
|
+
let found;
|
|
143
|
+
for (const specifier of candidates) {
|
|
144
|
+
try {
|
|
145
|
+
found = require.resolve(specifier);
|
|
146
|
+
} catch {
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
if (found.endsWith(".json")) break;
|
|
150
|
+
found = void 0;
|
|
151
|
+
}
|
|
152
|
+
found ??= isPath ? void 0 : require.resolve.paths(parent)?.map((dir) => join(dir, parent, "tsconfig.json")).find(existsSync);
|
|
153
|
+
if (found) await visit(found);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
if (path) await visit(path);
|
|
157
|
+
return [...files];
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Whether the bundle on disk still matches its sources: nothing it was built
|
|
161
|
+
* from has changed, and no other source has come to hold a workflow, a step or a
|
|
162
|
+
* serializable class that the bundle would need to know.
|
|
163
|
+
*/
|
|
164
|
+
async function isCurrent(statePath, key, sources, builders, outputs) {
|
|
165
|
+
let state;
|
|
166
|
+
try {
|
|
167
|
+
state = JSON.parse(await readFile(statePath, "utf8"));
|
|
168
|
+
} catch {
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
if (state.key !== key || !outputs.every((file) => existsSync(file))) return false;
|
|
172
|
+
if (sources.length !== Object.keys(state.sources).length || sources.some((path) => !(path in state.sources))) return false;
|
|
173
|
+
const inputs = await stamps(Object.keys(state.inputs));
|
|
174
|
+
if (Object.entries(state.inputs).some(([path, stamp]) => inputs[path] !== stamp)) return false;
|
|
175
|
+
const others = sources.filter((path) => !(path in state.inputs));
|
|
176
|
+
const now = await stamps(others);
|
|
177
|
+
const changed = others.filter((path) => now[path] !== state.sources[path]);
|
|
178
|
+
return !(await Promise.all(changed.map(async (path) => {
|
|
179
|
+
const found = builders.detectWorkflowPatterns(await readFile(path, "utf8"));
|
|
180
|
+
return found.hasDirective || found.hasSerde;
|
|
181
|
+
}))).some(Boolean);
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Write down what the bundle was built from: the files esbuild bundled (it names
|
|
185
|
+
* each one in a comment), every file with a directive or a serializable class, and
|
|
186
|
+
* the files that decide how imports resolve. Writes nothing when one of them
|
|
187
|
+
* changed while the build ran, because the bundle may then not match what was
|
|
188
|
+
* recorded.
|
|
189
|
+
*/
|
|
190
|
+
async function recordState(statePath, key, sources, builders, root, dir, bundles, extra, startedAt) {
|
|
191
|
+
const sourceStamps = await stamps(sources);
|
|
192
|
+
const found = new Set(extra.filter((path) => path !== void 0));
|
|
193
|
+
for (const bundle of bundles) {
|
|
194
|
+
const text = await readFile(bundle, "utf8");
|
|
195
|
+
for (const [, path] of text.matchAll(MODULE_COMMENT)) {
|
|
196
|
+
const file = resolve(root, path);
|
|
197
|
+
if (!file.startsWith(dir)) found.add(file);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
await Promise.all(sources.map(async (path) => {
|
|
201
|
+
const patterns = builders.detectWorkflowPatterns(await readFile(path, "utf8"));
|
|
202
|
+
if (patterns.hasDirective || patterns.hasSerde) found.add(path);
|
|
203
|
+
}));
|
|
204
|
+
const inputs = Object.fromEntries(Object.entries(await stamps(found)).filter(([, stamp]) => stamp));
|
|
205
|
+
if (Object.values(inputs).some((stamp) => Number.parseFloat(stamp) >= startedAt)) return;
|
|
206
|
+
await writeFile(statePath, JSON.stringify({
|
|
207
|
+
key,
|
|
208
|
+
sources: sourceStamps,
|
|
209
|
+
inputs
|
|
210
|
+
}));
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Build the bundle that runs an app's workflows: `flow.mjs` and `manifest.json`
|
|
214
|
+
* in `<root>/.well-known/workflow/v1`, from every file under `root` marked
|
|
215
|
+
* `"use workflow"` or `"use step"`.
|
|
216
|
+
*
|
|
217
|
+
* `brick dev` and `brick start` call it before events start. Call it in a script
|
|
218
|
+
* or test before starting events.
|
|
219
|
+
*
|
|
220
|
+
* @param options - `root`: the project root. Default: the working directory.
|
|
221
|
+
* `reuse`: keep the bundle of the last build when nothing it was built from has
|
|
222
|
+
* changed, which saves about a second on each reload of `brick dev`. Default:
|
|
223
|
+
* `false`, always build.
|
|
224
|
+
* @returns Whether it built the bundle; `false` when it kept the last one.
|
|
225
|
+
* @throws When `@workflow/builders` is not installed in the project.
|
|
226
|
+
*/
|
|
227
|
+
async function buildWorkflows(options = {}) {
|
|
228
|
+
const { root, dir } = resolveWorkflowPaths(options);
|
|
229
|
+
const loaded = await loadBuilders(root);
|
|
230
|
+
if (!loaded) throw new Error(`Cannot build workflows: @workflow/builders is not installed in ${root}. Add it with: bun add -d @workflow/builders`);
|
|
231
|
+
const { builders } = loaded;
|
|
232
|
+
const output = (name) => `./${relative(root, join(dir, name)).replaceAll("\\", "/")}`;
|
|
233
|
+
const builder = new builders.StandaloneBuilder({
|
|
234
|
+
buildTarget: "standalone",
|
|
235
|
+
dirs: ["."],
|
|
236
|
+
workingDir: root,
|
|
237
|
+
stepsBundlePath: output("__step_registrations.mjs"),
|
|
238
|
+
workflowsBundlePath: output("flow.mjs"),
|
|
239
|
+
webhookBundlePath: output("webhook.mjs"),
|
|
240
|
+
suppressCreateWorkflowsBundleLogs: true,
|
|
241
|
+
suppressCreateWebhookBundleLogs: true,
|
|
242
|
+
suppressCreateManifestLogs: true
|
|
243
|
+
});
|
|
244
|
+
const statePath = join(dir, STATE_FILE);
|
|
245
|
+
const bundles = ["flow.mjs", "__step_registrations.mjs"].map((name) => join(dir, name));
|
|
246
|
+
const outputs = [
|
|
247
|
+
...bundles,
|
|
248
|
+
join(dir, "manifest.json"),
|
|
249
|
+
join(dir, "webhook.mjs")
|
|
250
|
+
];
|
|
251
|
+
const configs = await tsconfigInputs(await builder.findTsConfigPath());
|
|
252
|
+
const key = JSON.stringify([
|
|
253
|
+
STATE_VERSION,
|
|
254
|
+
loaded.path,
|
|
255
|
+
await stamps(configs),
|
|
256
|
+
...[
|
|
257
|
+
"NODE_ENV",
|
|
258
|
+
"WORKFLOW_DISCOVER_NODE_MODULES",
|
|
259
|
+
"WORKFLOW_SOURCEMAP",
|
|
260
|
+
"WORKFLOW_EMIT_SOURCEMAPS_FOR_DEBUGGING",
|
|
261
|
+
"WORKFLOW_PUBLIC_MANIFEST"
|
|
262
|
+
].map((name) => process.env[name] ?? "")
|
|
263
|
+
]);
|
|
264
|
+
const sources = await builder.getInputFiles();
|
|
265
|
+
if (options.reuse && await isCurrent(statePath, key, sources, builders, outputs)) return false;
|
|
266
|
+
await rm(statePath, { force: true });
|
|
267
|
+
const startedAt = Date.now();
|
|
268
|
+
await builder.build();
|
|
269
|
+
try {
|
|
270
|
+
await recordState(statePath, key, sources, builders, root, dir, bundles, [
|
|
271
|
+
join(root, "package.json"),
|
|
272
|
+
lockfileOf(root),
|
|
273
|
+
...configs
|
|
274
|
+
], startedAt);
|
|
275
|
+
} catch {}
|
|
276
|
+
return true;
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Build the workflow bundle an app needs, if it has workflow listeners.
|
|
280
|
+
*
|
|
281
|
+
* @param app - The loaded app.
|
|
282
|
+
* @param options - `reuse`: keep the last bundle when its sources have not changed.
|
|
283
|
+
* @returns Whether the app has a bundle, built now or kept from the last build.
|
|
284
|
+
*/
|
|
285
|
+
async function buildAppWorkflows(app, options = {}) {
|
|
286
|
+
const target = app.events?.workflows;
|
|
287
|
+
if (!target) return false;
|
|
288
|
+
const started = performance.now();
|
|
289
|
+
if (await buildWorkflows({
|
|
290
|
+
root: target.root,
|
|
291
|
+
reuse: options.reuse
|
|
292
|
+
})) console.log(`[Brick-TS] Built workflows in ${Math.round(performance.now() - started)}ms`);
|
|
293
|
+
return true;
|
|
294
|
+
}
|
|
295
|
+
//#endregion
|
|
296
|
+
export { workflowTransformPlugin as i, buildWorkflows as n, registerWorkflowTransform as r, buildAppWorkflows as t };
|
|
297
|
+
|
|
298
|
+
//# sourceMappingURL=workflows2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflows2.js","names":[],"sources":["../src/workflows.ts"],"sourcesContent":["import { existsSync, readFileSync } from \"node:fs\";\nimport { readFile, rm, stat, writeFile } from \"node:fs/promises\";\nimport { createRequire } from \"node:module\";\nimport { dirname, isAbsolute, join, relative, resolve } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport { resolveWorkflowPaths, type BrickApp } from \"@brickkit/core\";\n\ninterface Builders {\n StandaloneBuilder: new (config: Record<string, unknown>) => {\n build(): Promise<void>;\n getInputFiles(): Promise<string[]>;\n findTsConfigPath(): Promise<string | undefined>;\n };\n detectWorkflowPatterns(source: string): {\n hasDirective: boolean;\n hasSerde: boolean;\n };\n applySwcTransform(\n filename: string,\n source: string,\n mode: \"step\" | \"workflow\" | \"detect\" | false,\n absolutePath: string,\n projectRoot: string,\n moduleSpecifierRoot?: string,\n ): Promise<{ code: string }>;\n}\n\ntype BunPlugin = Parameters<typeof Bun.plugin>[0];\n\nconst DIRECTIVE = /[\"']use (?:step|workflow)[\"']/;\n\n/**\n * Every project source file. Not the generated bundle: it holds the directives as\n * text inside the SDK's own code and is already built. Not `.cjs` and `.cts`\n * either: Bun drops `module.exports` from a file a plugin loads.\n */\nconst TRANSFORMED = new RegExp(\n String.raw`^(?!.*(?:node_modules|\\.well-known/workflow/)).*\\.(?:m?[jt]s|[jt]sx)$`,\n);\n\n/** Bun's own loader for each extension: JSX is allowed in `.js` but not in `.mjs`. */\nfunction loaderFor(path: string): \"ts\" | \"tsx\" | \"js\" | \"jsx\" {\n if (path.endsWith(\".tsx\")) return \"tsx\";\n if (/\\.m?ts$/.test(path)) return \"ts\";\n return path.endsWith(\".mjs\") ? \"js\" : \"jsx\";\n}\n\nasync function loadBuilders(\n root: string,\n): Promise<{ builders: Builders; path: string } | undefined> {\n try {\n const path = createRequire(join(root, \"package.json\")).resolve(\n \"@workflow/builders\",\n );\n return {\n builders: (await import(pathToFileURL(path).href)) as Builders,\n path,\n };\n } catch {\n return undefined;\n }\n}\n\n/**\n * The plugin that turns `\"use workflow\"` and `\"use step\"` files into workflows and\n * steps. `registerWorkflowTransform` installs it for the running process;\n * `brick build` hands it to `Bun.build`.\n *\n * @param root - The project root, where the SDK is installed. Default: the working directory.\n * @returns The plugin, or `undefined` when the Workflow SDK and its builders are not\n * installed in the project.\n */\nexport async function workflowTransformPlugin(\n root: string = process.cwd(),\n): Promise<BunPlugin | undefined> {\n const projectRoot = resolve(root);\n const builders = (await loadBuilders(projectRoot))?.builders;\n if (!builders) return undefined;\n return {\n name: \"brick:workflows\",\n setup(build) {\n // Not async: Bun treats a module whose load returns a promise as async, and\n // `require()` refuses it. Only a file with a directive waits for SWC.\n build.onLoad({ filter: TRANSFORMED }, (args) => {\n const source = readFileSync(args.path, \"utf8\");\n if (!DIRECTIVE.test(source))\n return { contents: source, loader: loaderFor(args.path) };\n // SWC strips the types but leaves JSX as it is.\n return builders\n .applySwcTransform(\n relative(projectRoot, args.path).replaceAll(\"\\\\\", \"/\"),\n source,\n \"step\",\n args.path,\n projectRoot,\n projectRoot,\n )\n .then(({ code }) => ({ contents: code, loader: \"jsx\" as const }));\n });\n },\n };\n}\n\nlet installed = false;\n\n/**\n * Make files marked `\"use workflow\"` or `\"use step\"` load as workflows and steps.\n *\n * A workflow function gets the `workflowId` that `defineListener({ workflow })`\n * needs, and a step registers itself so the runtime can run it in this process.\n * `brick dev`, `brick start` and `brick worker` call it before they load the app.\n * Call it in a script or test before importing the files, with the project root.\n *\n * It does nothing, and returns `false`, when the Workflow SDK and its builders are\n * not installed in the project. Bun allows plugins once per process, so a second\n * call is ignored.\n *\n * @param root - The project root, where the SDK is installed. Default: the working directory.\n * @returns Whether the transform is active.\n */\nexport async function registerWorkflowTransform(\n root: string = process.cwd(),\n): Promise<boolean> {\n if (installed) return true;\n const plugin = await workflowTransformPlugin(root);\n if (!plugin) return false;\n installed = true;\n Bun.plugin(plugin);\n return true;\n}\n\n/** The state of the last build, kept beside the bundle it describes. */\nconst STATE_FILE = \".brick-build.json\";\n/** Bump it when what the state records changes, so an older state is not trusted. */\nconst STATE_VERSION = 2;\n/**\n * esbuild starts each module of a bundle with a `// <path>` comment, whatever\n * the file (`data.json` too). The other comments it keeps name no file.\n */\nconst MODULE_COMMENT = /^\\/\\/ (.+)$/gm;\nconst LOCKFILES = [\n \"bun.lock\",\n \"bun.lockb\",\n \"package-lock.json\",\n \"pnpm-lock.yaml\",\n \"yarn.lock\",\n];\n\n/** A file's modification time and size, or an empty string when it is gone. */\ntype Stamps = Record<string, string>;\n\ninterface BuildState {\n key: string;\n /** Every source file the builder looks at. */\n sources: Stamps;\n /** The files the bundle holds or was built with; the bundle is stale when one changes. */\n inputs: Stamps;\n}\n\nasync function stamps(paths: Iterable<string>): Promise<Stamps> {\n const list = [...paths];\n const all = await Promise.all(\n list.map(async (path) => {\n try {\n const { mtimeMs, size } = await stat(path);\n return `${mtimeMs}:${size}`;\n } catch {\n return \"\";\n }\n }),\n );\n return Object.fromEntries(list.map((path, index) => [path, all[index]]));\n}\n\nfunction lockfileOf(root: string): string | undefined {\n for (let dir = root; ; dir = dirname(dir)) {\n for (const name of LOCKFILES)\n if (existsSync(join(dir, name))) return join(dir, name);\n if (dirname(dir) === dir) return undefined;\n }\n}\n\nasync function tsconfigInputs(path: string | undefined): Promise<string[]> {\n const files = new Set<string>();\n async function visit(file: string) {\n if (files.has(file)) return;\n files.add(file);\n let config: unknown;\n try {\n config = Bun.JSONC.parse(await readFile(file, \"utf8\"));\n } catch {\n return;\n }\n if (!config || typeof config !== \"object\" || !(\"extends\" in config)) return;\n const parents = Array.isArray(config.extends)\n ? config.extends\n : [config.extends];\n const require = createRequire(file);\n for (const parent of parents) {\n if (typeof parent !== \"string\") continue;\n // esbuild's order, which builds the bundle: a path as written, then with\n // .json; for a package, its tsconfig.json before `${parent}.json`, never `main`.\n const isPath =\n isAbsolute(parent) ||\n parent.startsWith(\"./\") ||\n parent.startsWith(\"../\");\n const candidates = isPath\n ? [parent, `${parent}.json`]\n : [`${parent}/tsconfig.json`, `${parent}.json`, parent];\n let found: string | undefined;\n for (const specifier of candidates) {\n try {\n found = require.resolve(specifier);\n } catch {\n continue;\n }\n if (found.endsWith(\".json\")) break;\n found = undefined;\n }\n // esbuild still reads the tsconfig.json of a package whose `exports` hides it.\n found ??= isPath\n ? undefined\n : require.resolve\n .paths(parent)\n ?.map((dir) => join(dir, parent, \"tsconfig.json\"))\n .find(existsSync);\n if (found) await visit(found);\n }\n }\n if (path) await visit(path);\n return [...files];\n}\n\n/**\n * Whether the bundle on disk still matches its sources: nothing it was built\n * from has changed, and no other source has come to hold a workflow, a step or a\n * serializable class that the bundle would need to know.\n */\nasync function isCurrent(\n statePath: string,\n key: string,\n sources: string[],\n builders: Builders,\n outputs: string[],\n): Promise<boolean> {\n let state: BuildState;\n try {\n state = JSON.parse(await readFile(statePath, \"utf8\")) as BuildState;\n } catch {\n return false;\n }\n if (state.key !== key || !outputs.every((file) => existsSync(file)))\n return false;\n // A file added or removed can change what an import resolves to.\n if (\n sources.length !== Object.keys(state.sources).length ||\n sources.some((path) => !(path in state.sources))\n )\n return false;\n const inputs = await stamps(Object.keys(state.inputs));\n if (\n Object.entries(state.inputs).some(([path, stamp]) => inputs[path] !== stamp)\n )\n return false;\n const others = sources.filter((path) => !(path in state.inputs));\n const now = await stamps(others);\n const changed = others.filter((path) => now[path] !== state.sources[path]);\n const holds = await Promise.all(\n changed.map(async (path) => {\n const found = builders.detectWorkflowPatterns(\n await readFile(path, \"utf8\"),\n );\n return found.hasDirective || found.hasSerde;\n }),\n );\n return !holds.some(Boolean);\n}\n\n/**\n * Write down what the bundle was built from: the files esbuild bundled (it names\n * each one in a comment), every file with a directive or a serializable class, and\n * the files that decide how imports resolve. Writes nothing when one of them\n * changed while the build ran, because the bundle may then not match what was\n * recorded.\n */\nasync function recordState(\n statePath: string,\n key: string,\n sources: string[],\n builders: Builders,\n root: string,\n dir: string,\n bundles: string[],\n extra: (string | undefined)[],\n startedAt: number,\n): Promise<void> {\n // Stamped before they are read, so an edit made in between shows on the next reload.\n const sourceStamps = await stamps(sources);\n const found = new Set(extra.filter((path) => path !== undefined));\n for (const bundle of bundles) {\n const text = await readFile(bundle, \"utf8\");\n for (const [, path] of text.matchAll(MODULE_COMMENT)) {\n // The flow bundle imports the steps bundle as a module; both are outputs.\n const file = resolve(root, path);\n if (!file.startsWith(dir)) found.add(file);\n }\n }\n await Promise.all(\n sources.map(async (path) => {\n const patterns = builders.detectWorkflowPatterns(\n await readFile(path, \"utf8\"),\n );\n if (patterns.hasDirective || patterns.hasSerde) found.add(path);\n }),\n );\n // A comment that names no file, such as `// see foo.ts`, stamps as empty.\n const inputs = Object.fromEntries(\n Object.entries(await stamps(found)).filter(([, stamp]) => stamp),\n );\n if (\n Object.values(inputs).some((stamp) => Number.parseFloat(stamp) >= startedAt)\n )\n return;\n const state: BuildState = { key, sources: sourceStamps, inputs };\n await writeFile(statePath, JSON.stringify(state));\n}\n\n/**\n * Build the bundle that runs an app's workflows: `flow.mjs` and `manifest.json`\n * in `<root>/.well-known/workflow/v1`, from every file under `root` marked\n * `\"use workflow\"` or `\"use step\"`.\n *\n * `brick dev` and `brick start` call it before events start. Call it in a script\n * or test before starting events.\n *\n * @param options - `root`: the project root. Default: the working directory.\n * `reuse`: keep the bundle of the last build when nothing it was built from has\n * changed, which saves about a second on each reload of `brick dev`. Default:\n * `false`, always build.\n * @returns Whether it built the bundle; `false` when it kept the last one.\n * @throws When `@workflow/builders` is not installed in the project.\n */\nexport async function buildWorkflows(\n options: { root?: string; reuse?: boolean } = {},\n): Promise<boolean> {\n const { root, dir } = resolveWorkflowPaths(options);\n const loaded = await loadBuilders(root);\n if (!loaded)\n throw new Error(\n `Cannot build workflows: @workflow/builders is not installed in ${root}. Add it with: bun add -d @workflow/builders`,\n );\n const { builders } = loaded;\n const output = (name: string) =>\n `./${relative(root, join(dir, name)).replaceAll(\"\\\\\", \"/\")}`;\n const builder = new builders.StandaloneBuilder({\n buildTarget: \"standalone\",\n dirs: [\".\"],\n workingDir: root,\n stepsBundlePath: output(\"__step_registrations.mjs\"),\n workflowsBundlePath: output(\"flow.mjs\"),\n webhookBundlePath: output(\"webhook.mjs\"),\n suppressCreateWorkflowsBundleLogs: true,\n suppressCreateWebhookBundleLogs: true,\n suppressCreateManifestLogs: true,\n });\n const statePath = join(dir, STATE_FILE);\n const bundles = [\"flow.mjs\", \"__step_registrations.mjs\"].map((name) =>\n join(dir, name),\n );\n const outputs = [\n ...bundles,\n join(dir, \"manifest.json\"),\n join(dir, \"webhook.mjs\"),\n ];\n const configs = await tsconfigInputs(await builder.findTsConfigPath());\n const key = JSON.stringify([\n STATE_VERSION,\n loaded.path,\n // Resolve again on reload so a formerly missing parent also invalidates reuse.\n await stamps(configs),\n // The builder reads these too, and writes a different bundle for each.\n ...[\n \"NODE_ENV\",\n \"WORKFLOW_DISCOVER_NODE_MODULES\",\n \"WORKFLOW_SOURCEMAP\",\n \"WORKFLOW_EMIT_SOURCEMAPS_FOR_DEBUGGING\",\n \"WORKFLOW_PUBLIC_MANIFEST\",\n ].map((name) => process.env[name] ?? \"\"),\n ]);\n const sources = await builder.getInputFiles();\n if (\n options.reuse &&\n (await isCurrent(statePath, key, sources, builders, outputs))\n )\n return false;\n // A build that fails halfway leaves outputs the old state no longer describes.\n await rm(statePath, { force: true });\n const startedAt = Date.now();\n await builder.build();\n try {\n await recordState(\n statePath,\n key,\n sources,\n builders,\n root,\n dir,\n bundles,\n [join(root, \"package.json\"), lockfileOf(root), ...configs],\n startedAt,\n );\n } catch {\n // Without a state the next reload builds again, which is only slower.\n }\n return true;\n}\n\n/**\n * Build the workflow bundle an app needs, if it has workflow listeners.\n *\n * @param app - The loaded app.\n * @param options - `reuse`: keep the last bundle when its sources have not changed.\n * @returns Whether the app has a bundle, built now or kept from the last build.\n */\nexport async function buildAppWorkflows(\n app: BrickApp,\n options: { reuse?: boolean } = {},\n): Promise<boolean> {\n const target = app.events?.workflows;\n if (!target) return false;\n const started = performance.now();\n const built = await buildWorkflows({\n root: target.root,\n reuse: options.reuse,\n });\n if (built)\n console.log(\n `[Brick-TS] Built workflows in ${Math.round(performance.now() - started)}ms`,\n );\n return true;\n}\n"],"mappings":";;;;;;;AA6BA,MAAM,YAAY;;;;;;AAOlB,MAAM,cAAc,IAAI,OACtB,OAAO,GAAG,uEACZ;;AAGA,SAAS,UAAU,MAA2C;CAC5D,IAAI,KAAK,SAAS,MAAM,GAAG,OAAO;CAClC,IAAI,UAAU,KAAK,IAAI,GAAG,OAAO;CACjC,OAAO,KAAK,SAAS,MAAM,IAAI,OAAO;AACxC;AAEA,eAAe,aACb,MAC2D;CAC3D,IAAI;EACF,MAAM,OAAO,cAAc,KAAK,MAAM,cAAc,CAAC,CAAC,CAAC,QACrD,oBACF;EACA,OAAO;GACL,UAAW,MAAM,OAAO,cAAc,IAAI,CAAC,CAAC;GAC5C;EACF;CACF,QAAQ;EACN;CACF;AACF;;;;;;;;;;AAWA,eAAsB,wBACpB,OAAe,QAAQ,IAAI,GACK;CAChC,MAAM,cAAc,QAAQ,IAAI;CAChC,MAAM,YAAY,MAAM,aAAa,WAAW,EAAA,EAAI;CACpD,IAAI,CAAC,UAAU,OAAO,KAAA;CACtB,OAAO;EACL,MAAM;EACN,MA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,KAAK,eAAe;EACzB,KAAK,KAAK,aAAa;CACzB;CACA,MAAM,UAAU,MAAM,eAAe,MAAM,QAAQ,iBAAiB,CAAC;CACrE,MAAM,MAAM,KAAK,UAAU;EACzB;EACA,OAAO;EAEP,MAAM,OAAO,OAAO;EAEpB,GAAG;GACD;GACA;GACA;GACA;GACA;EACF,CAAC,CAAC,KAAK,SAAS,QAAQ,IAAI,SAAS,EAAE;CACzC,CAAC;CACD,MAAM,UAAU,MAAM,QAAQ,cAAc;CAC5C,IACE,QAAQ,SACP,MAAM,UAAU,WAAW,KAAK,SAAS,UAAU,OAAO,GAE3D,OAAO;CAET,MAAM,GAAG,WAAW,EAAE,OAAO,KAAK,CAAC;CACnC,MAAM,YAAY,KAAK,IAAI;CAC3B,MAAM,QAAQ,MAAM;CACpB,IAAI;EACF,MAAM,YACJ,WACA,KACA,SACA,UACA,MACA,KACA,SACA;GAAC,KAAK,MAAM,cAAc;GAAG,WAAW,IAAI;GAAG,GAAG;EAAO,GACzD,SACF;CACF,QAAQ,CAER;CACA,OAAO;AACT;;;;;;;;AASA,eAAsB,kBACpB,KACA,UAA+B,CAAC,GACd;CAClB,MAAM,SAAS,IAAI,QAAQ;CAC3B,IAAI,CAAC,QAAQ,OAAO;CACpB,MAAM,UAAU,YAAY,IAAI;CAKhC,IAAI,MAJgB,eAAe;EACjC,MAAM,OAAO;EACb,OAAO,QAAQ;CACjB,CAAC,GAEC,QAAQ,IACN,iCAAiC,KAAK,MAAM,YAAY,IAAI,IAAI,OAAO,EAAE,GAC3E;CACF,OAAO;AACT"}
|
|
@@ -0,0 +1,201 @@
|
|
|
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.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
@brickkit/workflow-inspector
|
|
2
|
+
|
|
3
|
+
This package is derived from @workflow/web 5.0.5, the Workflow SDK's
|
|
4
|
+
observability UI (https://github.com/vercel/workflow, packages/web), copyright
|
|
5
|
+
Vercel, Inc. and its contributors, licensed under Apache-2.0. The UI components
|
|
6
|
+
it draws (traces, streams, events) come unchanged from @workflow/web-shared.
|
|
7
|
+
|
|
8
|
+
Changes: removed the header (logo, connection status, health check, theme
|
|
9
|
+
picker, docs link) and the pages and server settings that only matter when the
|
|
10
|
+
UI runs on its own; removed the Graph and Workflows views, which the app never
|
|
11
|
+
showed, with the workflow manifest they read; removed the health check call;
|
|
12
|
+
the page follows the light or dark theme of the document that frames it, and
|
|
13
|
+
takes its colors, type and radii from the Brick dev dashboard, whose fonts it
|
|
14
|
+
loads; the host process passes its own world to createFetchHandler() instead of
|
|
15
|
+
the UI building a world from WORKFLOW_* environment variables, so nothing from
|
|
16
|
+
the environment is read or sent to the browser; the standalone server, the
|
|
17
|
+
Vercel and self-host entry points, the registry file and the upstream tests
|
|
18
|
+
were dropped; the stylesheet imports @workflow/web-shared from npm; the client
|
|
19
|
+
is built for current browsers (es2022), and for the path the dashboard serves it
|
|
20
|
+
at (/workflows/), so that its file URLs need no rewriting at run time.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|