@gadicc/loom 1.20.0 → 1.21.1
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/db/databaseUrl.d.ts +26 -0
- package/db/databaseUrl.js +27 -0
- package/db/databaseUrl.test.ts +72 -0
- package/db/neonFull.js +4 -7
- package/esm/src/cli/mod.d.ts.map +1 -1
- package/esm/src/cli/mod.js +210 -6
- package/esm/src/next/jobs/run.d.ts +7 -0
- package/esm/src/next/jobs/run.d.ts.map +1 -1
- package/esm/src/next/jobs/run.js +48 -29
- package/esm/src/next/jobs/runRequest.d.ts +19 -0
- package/esm/src/next/jobs/runRequest.d.ts.map +1 -0
- package/esm/src/next/jobs/runRequest.js +76 -0
- package/package.json +8 -2
- package/script/src/cli/mod.d.ts.map +1 -1
- package/script/src/cli/mod.js +209 -5
- package/script/src/next/jobs/run.d.ts +7 -0
- package/script/src/next/jobs/run.d.ts.map +1 -1
- package/script/src/next/jobs/run.js +51 -29
- package/script/src/next/jobs/runRequest.d.ts +19 -0
- package/script/src/next/jobs/runRequest.d.ts.map +1 -0
- package/script/src/next/jobs/runRequest.js +81 -0
- package/skills/loom-jobs/SKILL.md +28 -3
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
const MAX_JOBS_RUN_ERROR_BODY_LENGTH = 1_000;
|
|
2
|
+
/** The compatibility transport used when a run panel does not choose one. */
|
|
3
|
+
export const DEFAULT_JOBS_RUN_REQUEST_METHOD = "GET";
|
|
4
|
+
/**
|
|
5
|
+
* Preserves compatibility query values while overlaying declared form fields.
|
|
6
|
+
* Empty non-boolean fields remove an existing value instead of sending it.
|
|
7
|
+
*/
|
|
8
|
+
export function buildJobsRunSearchParams(queryString, definitions, formValues) {
|
|
9
|
+
const searchParams = new URLSearchParams(queryString ?? "");
|
|
10
|
+
if (!definitions)
|
|
11
|
+
return searchParams;
|
|
12
|
+
for (const [key, definition] of Object.entries(definitions)) {
|
|
13
|
+
const value = formValues[key] ?? "";
|
|
14
|
+
if (definition.type === "boolean") {
|
|
15
|
+
searchParams.set(key, value === "true" ? "true" : "false");
|
|
16
|
+
}
|
|
17
|
+
else if (value !== "") {
|
|
18
|
+
searchParams.set(key, value);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
searchParams.delete(key);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return searchParams;
|
|
25
|
+
}
|
|
26
|
+
function safeJsonStringify(value) {
|
|
27
|
+
try {
|
|
28
|
+
return JSON.stringify(value);
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return String(value);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function boundJobsRunErrorBody(value) {
|
|
35
|
+
const normalized = value.trim();
|
|
36
|
+
if (normalized.length <= MAX_JOBS_RUN_ERROR_BODY_LENGTH) {
|
|
37
|
+
return normalized;
|
|
38
|
+
}
|
|
39
|
+
return `${normalized.slice(0, MAX_JOBS_RUN_ERROR_BODY_LENGTH - 3)}...`;
|
|
40
|
+
}
|
|
41
|
+
function getJsonErrorBody(body) {
|
|
42
|
+
try {
|
|
43
|
+
const parsed = JSON.parse(body);
|
|
44
|
+
if (typeof parsed !== "object" ||
|
|
45
|
+
parsed === null ||
|
|
46
|
+
!("error" in parsed)) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
const error = parsed.error;
|
|
50
|
+
return typeof error === "string" ? error : safeJsonStringify(error);
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Builds a bounded plain-text message for a failed jobs runner response.
|
|
58
|
+
* Response content is returned only as text so React escapes it when rendered.
|
|
59
|
+
*/
|
|
60
|
+
export async function getJobsRunResponseErrorMessage(response) {
|
|
61
|
+
const fallback = `Request failed with status ${response.status}`;
|
|
62
|
+
try {
|
|
63
|
+
const body = await response.text();
|
|
64
|
+
if (!body.trim())
|
|
65
|
+
return fallback;
|
|
66
|
+
const contentType = response.headers.get("content-type")?.toLowerCase();
|
|
67
|
+
const detail = contentType?.includes("application/json")
|
|
68
|
+
? getJsonErrorBody(body) ?? body
|
|
69
|
+
: body;
|
|
70
|
+
const boundedDetail = boundJobsRunErrorBody(detail);
|
|
71
|
+
return boundedDetail ? `${fallback}: ${boundedDetail}` : fallback;
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
return fallback;
|
|
75
|
+
}
|
|
76
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gadicc/loom",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.21.1",
|
|
4
4
|
"description": "Deno-first shared helpers for extracting common Next.js app code.",
|
|
5
5
|
"homepage": "https://github.com/gadicc/loom#readme",
|
|
6
6
|
"repository": {
|
|
@@ -77,6 +77,12 @@
|
|
|
77
77
|
"require": "./db/drizzle-config.js",
|
|
78
78
|
"default": "./db/drizzle-config.js"
|
|
79
79
|
},
|
|
80
|
+
"./db/database-url": {
|
|
81
|
+
"types": "./db/databaseUrl.d.ts",
|
|
82
|
+
"import": "./db/databaseUrl.js",
|
|
83
|
+
"require": "./db/databaseUrl.js",
|
|
84
|
+
"default": "./db/databaseUrl.js"
|
|
85
|
+
},
|
|
80
86
|
"./db/fixtures": {
|
|
81
87
|
"types": "./db/fixtures.d.ts",
|
|
82
88
|
"import": "./db/fixtures.js",
|
|
@@ -225,7 +231,7 @@
|
|
|
225
231
|
},
|
|
226
232
|
"scripts": {},
|
|
227
233
|
"loom": {
|
|
228
|
-
"gitCommit": "
|
|
234
|
+
"gitCommit": "5e5f4af45c0081d4010f2b033cf71b45f818005e"
|
|
229
235
|
},
|
|
230
236
|
"bin": {
|
|
231
237
|
"loom": "script/bin/loom.js"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/src/cli/mod.ts"],"names":[],"m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E,MAAM,EACrB,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,EACrD,OAAO,GAAE;IACP,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAChC,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CAClB;;;GAqBP;AAED,wBAAsB,YAAY,CAChC,GAAG,EAAE,MAAM,EACX,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,EACrD,OAAO,GAAE,mBAAwB;;;;GAgLlC;AAED,wBAAsB,mBAAmB,CACvC,GAAG,EAAE,MAAM,EACX,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,EACrD,OAAO,GAAE,mBAAwB;;;eAMxB,MAAM;gBACL,sBAAsB;;;;GA2GjC;AAuFD,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,uBAAuB,EAC9B,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAO,YAoClD;AAu/BD,wBAAsB,aAAa,CACjC,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,IAAI,EAAE,MAAM,EAAE,EACd,EAAE,EAAE,SAAS,EACb,OAAO,GAAE;IACP,aAAa,CAAC,EAAE,aAAa,CAAC;CAC1B,mBAiBP;AA6lBD,wBAAsB,MAAM,CAC1B,IAAI,MAAwB,EAC5B,EAAE,GAAE,SAGH,mBAqKF"}
|
package/script/src/cli/mod.js
CHANGED
|
@@ -994,6 +994,7 @@ function getJobsConfig(framework) {
|
|
|
994
994
|
ui: {
|
|
995
995
|
enabled: true,
|
|
996
996
|
listPage: `${appRoot}/admin/jobs/page.tsx`,
|
|
997
|
+
requestMethod: "GET",
|
|
997
998
|
routeHandler: `${appRoot}/admin/jobs/[id]/route.ts`,
|
|
998
999
|
runPage: `${appRoot}/admin/jobs/run/[id]/page.tsx`,
|
|
999
1000
|
},
|
|
@@ -3671,6 +3672,168 @@ function matchesImportSource(text, expectedSources) {
|
|
|
3671
3672
|
].map((match) => match[1]);
|
|
3672
3673
|
return expectedSources.some((source) => importSources.includes(source));
|
|
3673
3674
|
}
|
|
3675
|
+
const JOBS_RUN_SOURCE_EXTENSIONS = [
|
|
3676
|
+
".ts",
|
|
3677
|
+
".tsx",
|
|
3678
|
+
".mts",
|
|
3679
|
+
".cts",
|
|
3680
|
+
".js",
|
|
3681
|
+
".jsx",
|
|
3682
|
+
".mjs",
|
|
3683
|
+
".cjs",
|
|
3684
|
+
];
|
|
3685
|
+
const MAX_JOBS_RUN_GRAPH_MODULES = 250;
|
|
3686
|
+
function getModuleBoundaryDirective(text) {
|
|
3687
|
+
let remaining = normalizeText(text).trimStart();
|
|
3688
|
+
while (remaining.startsWith("//") || remaining.startsWith("/*")) {
|
|
3689
|
+
if (remaining.startsWith("//")) {
|
|
3690
|
+
const newline = remaining.indexOf("\n");
|
|
3691
|
+
remaining = newline < 0 ? "" : remaining.slice(newline + 1).trimStart();
|
|
3692
|
+
continue;
|
|
3693
|
+
}
|
|
3694
|
+
const end = remaining.indexOf("*/", 2);
|
|
3695
|
+
if (end < 0)
|
|
3696
|
+
return null;
|
|
3697
|
+
remaining = remaining.slice(end + 2).trimStart();
|
|
3698
|
+
}
|
|
3699
|
+
const match = remaining.match(/^(?:"use (client|server)"|'use (client|server)')\s*;?/);
|
|
3700
|
+
return (match?.[1] ?? match?.[2] ?? null);
|
|
3701
|
+
}
|
|
3702
|
+
function getStaticModuleSpecifiers(text) {
|
|
3703
|
+
const specifiers = new Set();
|
|
3704
|
+
for (const match of normalizeText(text).matchAll(/(?:^|[;\n])\s*(?:import|export)\s+(?:type\s+)?(?:[^"'`;]*?\s+from\s+)?["']([^"']+)["']/gm)) {
|
|
3705
|
+
specifiers.add(match[1]);
|
|
3706
|
+
}
|
|
3707
|
+
for (const match of normalizeText(text).matchAll(/\bimport\s*\(\s*["']([^"']+)["']\s*\)/g)) {
|
|
3708
|
+
specifiers.add(match[1]);
|
|
3709
|
+
}
|
|
3710
|
+
return [...specifiers];
|
|
3711
|
+
}
|
|
3712
|
+
function getJobsRunHelperImports(text) {
|
|
3713
|
+
const helpers = new Set();
|
|
3714
|
+
for (const match of normalizeText(text).matchAll(/import\s+(?:type\s+)?\{([^}]+)\}\s+from\s+["']@gadicc\/loom\/next\/jobs(?:\/run)?["']/g)) {
|
|
3715
|
+
for (const rawSpecifier of match[1].split(",")) {
|
|
3716
|
+
const importedName = rawSpecifier.trim().replace(/^type\s+/, "")
|
|
3717
|
+
.split(/\s+as\s+/)[0];
|
|
3718
|
+
if (importedName === "createJobsRunPage" || importedName === "JobsRunPanel") {
|
|
3719
|
+
helpers.add(importedName);
|
|
3720
|
+
}
|
|
3721
|
+
}
|
|
3722
|
+
}
|
|
3723
|
+
return helpers;
|
|
3724
|
+
}
|
|
3725
|
+
function getJobsRunRequestMethods(text) {
|
|
3726
|
+
return [
|
|
3727
|
+
...normalizeText(text).matchAll(/\brequestMethod\s*(?::|=)\s*["'](GET|POST)["']/g),
|
|
3728
|
+
].map((match) => match[1]);
|
|
3729
|
+
}
|
|
3730
|
+
async function resolveLocalSourceImport(cwd, framework, importerPath, specifier) {
|
|
3731
|
+
let basePath;
|
|
3732
|
+
if (specifier.startsWith("./") || specifier.startsWith("../")) {
|
|
3733
|
+
basePath = (0, node_path_1.resolve)((0, node_path_1.dirname)(importerPath), specifier);
|
|
3734
|
+
}
|
|
3735
|
+
else if (specifier.startsWith("@/")) {
|
|
3736
|
+
basePath = (0, node_path_1.resolve)(cwd, framework.srcDir ? "src" : "", specifier.slice(2));
|
|
3737
|
+
}
|
|
3738
|
+
else {
|
|
3739
|
+
return null;
|
|
3740
|
+
}
|
|
3741
|
+
const relativeBasePath = (0, node_path_1.relative)(cwd, basePath);
|
|
3742
|
+
if (relativeBasePath === ".." ||
|
|
3743
|
+
relativeBasePath.startsWith(`..${node_path_1.sep}`) ||
|
|
3744
|
+
(0, node_path_1.resolve)(cwd, relativeBasePath) !== basePath) {
|
|
3745
|
+
return null;
|
|
3746
|
+
}
|
|
3747
|
+
const hasSourceExtension = JOBS_RUN_SOURCE_EXTENSIONS.some((extension) => basePath.endsWith(extension));
|
|
3748
|
+
const candidates = hasSourceExtension ? [basePath] : [
|
|
3749
|
+
...JOBS_RUN_SOURCE_EXTENSIONS.map((extension) => `${basePath}${extension}`),
|
|
3750
|
+
...JOBS_RUN_SOURCE_EXTENSIONS.map((extension) => (0, node_path_1.join)(basePath, `index${extension}`)),
|
|
3751
|
+
];
|
|
3752
|
+
for (const candidate of candidates) {
|
|
3753
|
+
if (await exists(candidate))
|
|
3754
|
+
return candidate;
|
|
3755
|
+
}
|
|
3756
|
+
return null;
|
|
3757
|
+
}
|
|
3758
|
+
async function inspectJobsRunModuleGraph(cwd, framework, rootRelativePath) {
|
|
3759
|
+
const clientFormatImports = [];
|
|
3760
|
+
const clientNodeImports = [];
|
|
3761
|
+
const helperPaths = new Set();
|
|
3762
|
+
const requestMethods = new Set();
|
|
3763
|
+
const sourceCache = new Map();
|
|
3764
|
+
const visitedStates = new Set();
|
|
3765
|
+
const rootPath = (0, node_path_1.resolve)(cwd, rootRelativePath);
|
|
3766
|
+
const queue = [{
|
|
3767
|
+
chain: [rootRelativePath],
|
|
3768
|
+
inheritedClientBoundary: false,
|
|
3769
|
+
path: rootPath,
|
|
3770
|
+
}];
|
|
3771
|
+
let truncated = false;
|
|
3772
|
+
while (queue.length > 0) {
|
|
3773
|
+
const current = queue.shift();
|
|
3774
|
+
let text = sourceCache.get(current.path);
|
|
3775
|
+
if (text === undefined) {
|
|
3776
|
+
if (sourceCache.size >= MAX_JOBS_RUN_GRAPH_MODULES) {
|
|
3777
|
+
truncated = true;
|
|
3778
|
+
break;
|
|
3779
|
+
}
|
|
3780
|
+
const source = await readTextIfExists(current.path);
|
|
3781
|
+
if (source === null)
|
|
3782
|
+
continue;
|
|
3783
|
+
text = source;
|
|
3784
|
+
sourceCache.set(current.path, text);
|
|
3785
|
+
}
|
|
3786
|
+
const moduleDirective = getModuleBoundaryDirective(text);
|
|
3787
|
+
const isClient = moduleDirective === "client" ||
|
|
3788
|
+
(moduleDirective !== "server" && current.inheritedClientBoundary);
|
|
3789
|
+
const stateKey = `${current.path}\0${isClient ? "client" : "server"}`;
|
|
3790
|
+
if (visitedStates.has(stateKey))
|
|
3791
|
+
continue;
|
|
3792
|
+
visitedStates.add(stateKey);
|
|
3793
|
+
const currentRelativePath = (0, node_path_1.relative)(cwd, current.path).replaceAll("\\", "/");
|
|
3794
|
+
const helpers = getJobsRunHelperImports(text);
|
|
3795
|
+
if (helpers.size > 0) {
|
|
3796
|
+
helperPaths.add(currentRelativePath);
|
|
3797
|
+
for (const method of getJobsRunRequestMethods(text)) {
|
|
3798
|
+
requestMethods.add(method);
|
|
3799
|
+
}
|
|
3800
|
+
}
|
|
3801
|
+
const specifiers = getStaticModuleSpecifiers(text);
|
|
3802
|
+
if (isClient) {
|
|
3803
|
+
for (const specifier of specifiers) {
|
|
3804
|
+
const finding = {
|
|
3805
|
+
chain: current.chain,
|
|
3806
|
+
path: currentRelativePath,
|
|
3807
|
+
specifier,
|
|
3808
|
+
};
|
|
3809
|
+
if (specifier === "@gadicc/loom/jobs/format") {
|
|
3810
|
+
clientFormatImports.push(finding);
|
|
3811
|
+
}
|
|
3812
|
+
else if (specifier.startsWith("node:")) {
|
|
3813
|
+
clientNodeImports.push(finding);
|
|
3814
|
+
}
|
|
3815
|
+
}
|
|
3816
|
+
}
|
|
3817
|
+
for (const specifier of specifiers) {
|
|
3818
|
+
const importedPath = await resolveLocalSourceImport(cwd, framework, current.path, specifier);
|
|
3819
|
+
if (!importedPath)
|
|
3820
|
+
continue;
|
|
3821
|
+
const importedRelativePath = (0, node_path_1.relative)(cwd, importedPath).replaceAll("\\", "/");
|
|
3822
|
+
queue.push({
|
|
3823
|
+
chain: [...current.chain, importedRelativePath],
|
|
3824
|
+
inheritedClientBoundary: isClient,
|
|
3825
|
+
path: importedPath,
|
|
3826
|
+
});
|
|
3827
|
+
}
|
|
3828
|
+
}
|
|
3829
|
+
return {
|
|
3830
|
+
clientFormatImports,
|
|
3831
|
+
clientNodeImports,
|
|
3832
|
+
helperPaths: [...helperPaths],
|
|
3833
|
+
requestMethods,
|
|
3834
|
+
truncated,
|
|
3835
|
+
};
|
|
3836
|
+
}
|
|
3674
3837
|
function detectBetterAuthExportName(text) {
|
|
3675
3838
|
const match = normalizeText(text).match(/export\s+const\s+([A-Za-z_$][\w$]*)\s*=\s*betterAuth\s*\(/);
|
|
3676
3839
|
return match?.[1] ?? null;
|
|
@@ -3756,6 +3919,7 @@ import * as jobs from "${config.metaCatalogModule}";
|
|
|
3756
3919
|
|
|
3757
3920
|
const JobsRunPage = createJobsRunPage({
|
|
3758
3921
|
metas: jobs,
|
|
3922
|
+
requestMethod: "${config.ui.requestMethod}",
|
|
3759
3923
|
});
|
|
3760
3924
|
|
|
3761
3925
|
export default JobsRunPage;
|
|
@@ -7323,6 +7487,11 @@ async function applyJobsFeature(cwd, framework, manifest, activate) {
|
|
|
7323
7487
|
? structuredClone(currentFeature)
|
|
7324
7488
|
: { status: "planned" };
|
|
7325
7489
|
const config = mergeJobsConfig(framework, feature.config);
|
|
7490
|
+
if (currentFeature?.status !== "active" &&
|
|
7491
|
+
!feature.config?.ui
|
|
7492
|
+
?.requestMethod) {
|
|
7493
|
+
config.ui.requestMethod = "POST";
|
|
7494
|
+
}
|
|
7326
7495
|
const tooling = await getProjectTooling(cwd, manifest);
|
|
7327
7496
|
const dependencyUpdate = await (0, projectTooling_js_1.mutateProjectDependencies)(cwd, tooling.dependencies, {
|
|
7328
7497
|
dependencies: JOBS_DEFAULT_DEPENDENCIES,
|
|
@@ -8224,11 +8393,6 @@ async function checkJobsFeature(cwd, framework, manifest) {
|
|
|
8224
8393
|
config.metaCatalogModule,
|
|
8225
8394
|
"Jobs list-page module does not import the configured meta catalog module",
|
|
8226
8395
|
],
|
|
8227
|
-
[
|
|
8228
|
-
config.modules.runPageModule,
|
|
8229
|
-
"createJobsRunPage",
|
|
8230
|
-
"Jobs run-page module is not wired to the shared jobs run helper",
|
|
8231
|
-
],
|
|
8232
8396
|
[
|
|
8233
8397
|
config.modules.routeModule,
|
|
8234
8398
|
"createJobsRouteHandler",
|
|
@@ -8249,6 +8413,46 @@ async function checkJobsFeature(cwd, framework, manifest) {
|
|
|
8249
8413
|
suggestions.add("Update the jobs module wiring to match loom.json, or rerun `loom add jobs` and reapply any app-local customizations.");
|
|
8250
8414
|
}
|
|
8251
8415
|
}
|
|
8416
|
+
const runModuleGraph = await inspectJobsRunModuleGraph(cwd, framework, config.modules.runPageModule);
|
|
8417
|
+
if (runModuleGraph.helperPaths.length === 0) {
|
|
8418
|
+
issues.push(`Jobs run-page module is not wired to createJobsRunPage or JobsRunPanel through its local import graph: ${config.modules.runPageModule}`);
|
|
8419
|
+
suggestions.add("Use createJobsRunPage directly, or keep a server wrapper that passes serializable metadata to a local client island using JobsRunPanel.");
|
|
8420
|
+
}
|
|
8421
|
+
if (runModuleGraph.truncated) {
|
|
8422
|
+
issues.push(`Jobs run-page local import graph exceeds ${MAX_JOBS_RUN_GRAPH_MODULES} modules: ${config.modules.runPageModule}`);
|
|
8423
|
+
suggestions.add("Keep the jobs metadata catalog dependency-free and the run-page server-wrapper/client-island graph focused.");
|
|
8424
|
+
}
|
|
8425
|
+
const seenClientImports = new Set();
|
|
8426
|
+
for (const finding of runModuleGraph.clientFormatImports) {
|
|
8427
|
+
const key = `${finding.path}\0${finding.specifier}`;
|
|
8428
|
+
if (seenClientImports.has(key))
|
|
8429
|
+
continue;
|
|
8430
|
+
seenClientImports.add(key);
|
|
8431
|
+
issues.push(`Jobs client graph imports @gadicc/loom/jobs/format, which is not browser-safe: ${finding.path} (via ${finding.chain.join(" -> ")}). formatJobLogTime is available from @gadicc/loom/jobs/log; use JobsRunPanel, renderLogValue, or another explicitly browser-safe helper for structured browser output.`);
|
|
8432
|
+
}
|
|
8433
|
+
for (const finding of runModuleGraph.clientNodeImports) {
|
|
8434
|
+
const key = `${finding.path}\0${finding.specifier}`;
|
|
8435
|
+
if (seenClientImports.has(key))
|
|
8436
|
+
continue;
|
|
8437
|
+
seenClientImports.add(key);
|
|
8438
|
+
issues.push(`Jobs client graph imports Node builtin ${finding.specifier}: ${finding.path} (via ${finding.chain.join(" -> ")}). Move the Node-only module above the client boundary or replace it with a browser-safe helper.`);
|
|
8439
|
+
}
|
|
8440
|
+
if (runModuleGraph.clientFormatImports.length > 0 ||
|
|
8441
|
+
runModuleGraph.clientNodeImports.length > 0) {
|
|
8442
|
+
suggestions.add("Keep executable catalogs and server-only formatters outside the jobs run-page client graph.");
|
|
8443
|
+
}
|
|
8444
|
+
const requestMethods = runModuleGraph.requestMethods;
|
|
8445
|
+
const requestMethodMatches = config.ui.requestMethod === "GET"
|
|
8446
|
+
? requestMethods.size === 0 ||
|
|
8447
|
+
(requestMethods.size === 1 && requestMethods.has("GET"))
|
|
8448
|
+
: requestMethods.size === 1 && requestMethods.has("POST");
|
|
8449
|
+
if (runModuleGraph.helperPaths.length > 0 && !requestMethodMatches) {
|
|
8450
|
+
const actual = requestMethods.size > 0
|
|
8451
|
+
? [...requestMethods].join(" and ")
|
|
8452
|
+
: "the GET runtime default";
|
|
8453
|
+
issues.push(`Jobs run-page request method does not match loom.json: expected ${config.ui.requestMethod}, found ${actual} in ${runModuleGraph.helperPaths.join(", ")}`);
|
|
8454
|
+
suggestions.add(`Pass requestMethod: "${config.ui.requestMethod}" to createJobsRunPage or requestMethod="${config.ui.requestMethod}" to JobsRunPanel, and keep features.jobs.config.ui.requestMethod aligned.`);
|
|
8455
|
+
}
|
|
8252
8456
|
const jobsRoot = framework.srcDir ? "src/jobs" : "jobs";
|
|
8253
8457
|
const catalogFiles = [
|
|
8254
8458
|
`${jobsRoot}/index.ts`,
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { type NextPageSearchParams } from "./paths.js";
|
|
3
|
+
import { buildJobsRunSearchParams, DEFAULT_JOBS_RUN_REQUEST_METHOD, getJobsRunResponseErrorMessage, type JobsRunRequestMethod } from "./runRequest.js";
|
|
4
|
+
export { buildJobsRunSearchParams, DEFAULT_JOBS_RUN_REQUEST_METHOD, getJobsRunResponseErrorMessage, type JobsRunRequestMethod, };
|
|
3
5
|
export type JobRunStatus = "idle" | "starting" | "running" | "done" | "error" | "stopped";
|
|
4
6
|
export interface JobsRunPageProps {
|
|
5
7
|
params: Promise<{
|
|
@@ -37,6 +39,11 @@ export interface JobsRunPanelProps {
|
|
|
37
39
|
id: string;
|
|
38
40
|
queryString?: string;
|
|
39
41
|
metas?: Record<string, unknown> | Iterable<unknown>;
|
|
42
|
+
/**
|
|
43
|
+
* HTTP method used to start the job. Parameters remain in the query string.
|
|
44
|
+
* Defaults to GET for compatibility with existing consumers.
|
|
45
|
+
*/
|
|
46
|
+
requestMethod?: JobsRunRequestMethod;
|
|
40
47
|
renderLogValue?: RenderJobLogValue;
|
|
41
48
|
renderPage?: (props: RenderJobsRunPageProps) => React.ReactNode;
|
|
42
49
|
renderPanel?: (props: RenderJobsRunPanelProps) => React.ReactNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../../src/src/next/jobs/run.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAS1B,OAAO,EAEL,KAAK,oBAAoB,EAE1B,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../../src/src/next/jobs/run.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAS1B,OAAO,EAEL,KAAK,oBAAoB,EAE1B,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,wBAAwB,EACxB,+BAA+B,EAC/B,8BAA8B,EAC9B,KAA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O,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;IACpD;;;OAGG;IACH,aAAa,CAAC,EAAE,oBAAoB,CAAC;IACrC,cAAc,CAAC,EAAE,iBAAiB,CAAC;IACnC,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,KAAK,CAAC,SAAS,CAAC;IAChE,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,uBAAuB,KAAK,KAAK,CAAC,SAAS,CAAC;IAClE,iBAAiB,CAAC,EAAE,CAClB,KAAK,EAAE,wBAAwB,KAC5B,KAAK,CAAC,SAAS,CAAC;IACrB,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,uBAAuB,KAAK,KAAK,CAAC,SAAS,CAAC;CACnE;AAED,MAAM,WAAW,wBACf,SAAQ,IAAI,CAAC,iBAAiB,EAAE,IAAI,GAAG,aAAa,CAAC;IACrD,oBAAoB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC1C;AAoMD,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,OAmjBpD;AAED,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,wBAA6B,IAC1C,OAAO,gBAAgB,SAYpD"}
|
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
5
|
};
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.getJobsRunResponseErrorMessage = exports.DEFAULT_JOBS_RUN_REQUEST_METHOD = exports.buildJobsRunSearchParams = void 0;
|
|
7
8
|
exports.JobsRunPanel = JobsRunPanel;
|
|
8
9
|
exports.createJobsRunPage = createJobsRunPage;
|
|
9
10
|
const react_1 = __importDefault(require("react"));
|
|
@@ -12,6 +13,10 @@ const controller_js_1 = require("../../jobs/controller.js");
|
|
|
12
13
|
const events_js_1 = require("../../jobs/events.js");
|
|
13
14
|
const log_js_1 = require("../../jobs/log.js");
|
|
14
15
|
const paths_js_1 = require("./paths.js");
|
|
16
|
+
const runRequest_js_1 = require("./runRequest.js");
|
|
17
|
+
Object.defineProperty(exports, "buildJobsRunSearchParams", { enumerable: true, get: function () { return runRequest_js_1.buildJobsRunSearchParams; } });
|
|
18
|
+
Object.defineProperty(exports, "DEFAULT_JOBS_RUN_REQUEST_METHOD", { enumerable: true, get: function () { return runRequest_js_1.DEFAULT_JOBS_RUN_REQUEST_METHOD; } });
|
|
19
|
+
Object.defineProperty(exports, "getJobsRunResponseErrorMessage", { enumerable: true, get: function () { return runRequest_js_1.getJobsRunResponseErrorMessage; } });
|
|
15
20
|
const stream_js_1 = require("./stream.js");
|
|
16
21
|
const JOB_LOG_LEVEL_COLORS = [
|
|
17
22
|
"#b91c1c",
|
|
@@ -170,6 +175,7 @@ function JobsRunPanel(props) {
|
|
|
170
175
|
const scrolling = react_1.default.useRef(false);
|
|
171
176
|
const scrollTimeout = react_1.default.useRef(null);
|
|
172
177
|
const lineHeight = react_1.default.useRef(12);
|
|
178
|
+
const abortController = react_1.default.useRef(null);
|
|
173
179
|
const activeMeta = react_1.default.useMemo(() => {
|
|
174
180
|
if (!props.metas)
|
|
175
181
|
return undefined;
|
|
@@ -223,6 +229,9 @@ function JobsRunPanel(props) {
|
|
|
223
229
|
lineHeight.current =
|
|
224
230
|
Number.parseFloat(getComputedStyle(panelRef.current).fontSize) || 12;
|
|
225
231
|
}, []);
|
|
232
|
+
react_1.default.useEffect(() => {
|
|
233
|
+
return () => abortController.current?.abort();
|
|
234
|
+
}, []);
|
|
226
235
|
react_1.default.useEffect(() => {
|
|
227
236
|
const element = panelRef.current;
|
|
228
237
|
if (!element) {
|
|
@@ -249,8 +258,14 @@ function JobsRunPanel(props) {
|
|
|
249
258
|
};
|
|
250
259
|
}, []);
|
|
251
260
|
react_1.default.useEffect(() => {
|
|
252
|
-
|
|
253
|
-
|
|
261
|
+
const element = panelRef.current;
|
|
262
|
+
if (!element || !autoscroll.current || scrolling.current)
|
|
263
|
+
return;
|
|
264
|
+
if (typeof element.scrollTo === "function") {
|
|
265
|
+
element.scrollTo(0, element.scrollHeight);
|
|
266
|
+
}
|
|
267
|
+
else {
|
|
268
|
+
element.scrollTop = element.scrollHeight;
|
|
254
269
|
}
|
|
255
270
|
}, [entries]);
|
|
256
271
|
const runJob = react_1.default.useCallback(async () => {
|
|
@@ -259,24 +274,7 @@ function JobsRunPanel(props) {
|
|
|
259
274
|
}
|
|
260
275
|
isRunning.current = true;
|
|
261
276
|
const paths = (0, paths_js_1.createJobsAdminPaths)(props.basePath);
|
|
262
|
-
const searchParams =
|
|
263
|
-
if (activeMeta?.params) {
|
|
264
|
-
for (const [key, val] of Object.entries(formValues)) {
|
|
265
|
-
const def = activeMeta.params[key];
|
|
266
|
-
if (def?.type === "boolean") {
|
|
267
|
-
searchParams.set(key, val === "true" ? "true" : "false");
|
|
268
|
-
}
|
|
269
|
-
else if (val !== "") {
|
|
270
|
-
searchParams.set(key, val);
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
else {
|
|
275
|
-
const p = new URLSearchParams(props.queryString || "");
|
|
276
|
-
for (const [key, val] of p.entries()) {
|
|
277
|
-
searchParams.set(key, val);
|
|
278
|
-
}
|
|
279
|
-
}
|
|
277
|
+
const searchParams = (0, runRequest_js_1.buildJobsRunSearchParams)(props.queryString, activeMeta?.params, formValues);
|
|
280
278
|
const qString = searchParams.toString();
|
|
281
279
|
if (typeof globalThis.window !== "undefined") {
|
|
282
280
|
const newUrl = `${globalThis.location.pathname}${qString ? `?${qString}` : ""}`;
|
|
@@ -286,12 +284,16 @@ function JobsRunPanel(props) {
|
|
|
286
284
|
setStatus("starting");
|
|
287
285
|
setEntries([]);
|
|
288
286
|
nextEntryId.current = 0;
|
|
287
|
+
const controller = new AbortController();
|
|
288
|
+
abortController.current = controller;
|
|
289
289
|
try {
|
|
290
|
-
const response = await fetch(requestPath
|
|
290
|
+
const response = await fetch(requestPath, {
|
|
291
|
+
method: props.requestMethod ?? runRequest_js_1.DEFAULT_JOBS_RUN_REQUEST_METHOD,
|
|
292
|
+
signal: controller.signal,
|
|
293
|
+
});
|
|
291
294
|
if (!response.ok) {
|
|
292
295
|
setStatus("error");
|
|
293
|
-
appendEntry(toJobErrorEvent(
|
|
294
|
-
`Request failed with status ${response.status}`));
|
|
296
|
+
appendEntry(toJobErrorEvent(await (0, runRequest_js_1.getJobsRunResponseErrorMessage)(response)));
|
|
295
297
|
return;
|
|
296
298
|
}
|
|
297
299
|
if (!response.body) {
|
|
@@ -315,16 +317,36 @@ function JobsRunPanel(props) {
|
|
|
315
317
|
}
|
|
316
318
|
}
|
|
317
319
|
catch (error) {
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
320
|
+
if (controller.signal.aborted) {
|
|
321
|
+
setStatus("stopped");
|
|
322
|
+
}
|
|
323
|
+
else {
|
|
324
|
+
setStatus("error");
|
|
325
|
+
appendEntry(toJobErrorEvent(error instanceof Error
|
|
326
|
+
? error.stack ?? error.message
|
|
327
|
+
: safeJsonStringify(error)));
|
|
328
|
+
}
|
|
322
329
|
}
|
|
323
330
|
finally {
|
|
331
|
+
if (abortController.current === controller) {
|
|
332
|
+
abortController.current = null;
|
|
333
|
+
}
|
|
324
334
|
isRunning.current = false;
|
|
325
335
|
}
|
|
326
|
-
}, [
|
|
327
|
-
|
|
336
|
+
}, [
|
|
337
|
+
props.basePath,
|
|
338
|
+
props.id,
|
|
339
|
+
props.queryString,
|
|
340
|
+
props.requestMethod,
|
|
341
|
+
formValues,
|
|
342
|
+
activeMeta,
|
|
343
|
+
]);
|
|
344
|
+
const runKey = react_1.default.useMemo(() => [
|
|
345
|
+
props.basePath ?? "",
|
|
346
|
+
props.id,
|
|
347
|
+
props.queryString ?? "",
|
|
348
|
+
props.requestMethod ?? runRequest_js_1.DEFAULT_JOBS_RUN_REQUEST_METHOD,
|
|
349
|
+
].join("\0"), [props.basePath, props.id, props.queryString, props.requestMethod]);
|
|
328
350
|
react_1.default.useEffect(() => {
|
|
329
351
|
if (props.autoStart !== true) {
|
|
330
352
|
setStatus("idle");
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Supported transports for starting a job from the shared browser runner. */
|
|
2
|
+
export type JobsRunRequestMethod = "GET" | "POST";
|
|
3
|
+
/** The compatibility transport used when a run panel does not choose one. */
|
|
4
|
+
export declare const DEFAULT_JOBS_RUN_REQUEST_METHOD: JobsRunRequestMethod;
|
|
5
|
+
interface JobsRunParamDefinition {
|
|
6
|
+
type: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Preserves compatibility query values while overlaying declared form fields.
|
|
10
|
+
* Empty non-boolean fields remove an existing value instead of sending it.
|
|
11
|
+
*/
|
|
12
|
+
export declare function buildJobsRunSearchParams(queryString: string | undefined, definitions: Record<string, JobsRunParamDefinition> | undefined, formValues: Record<string, string>): any;
|
|
13
|
+
/**
|
|
14
|
+
* Builds a bounded plain-text message for a failed jobs runner response.
|
|
15
|
+
* Response content is returned only as text so React escapes it when rendered.
|
|
16
|
+
*/
|
|
17
|
+
export declare function getJobsRunResponseErrorMessage(response: Response): Promise<string>;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=runRequest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runRequest.d.ts","sourceRoot":"","sources":["../../../../src/src/next/jobs/runRequest.ts"],"names":[],"mappings":"AAEA,8EAA8E;AAC9E,MAAM,MAAM,oBAAoB,GAAG,KAAK,GAAG,MAAM,CAAC;AAElD,6EAA6E;AAC7E,eAAO,MAAM,+BAA+B,EAAE,oBAA4B,CAAC;AAE3E,UAAU,sBAAsB;IAC9B,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,GAAG,SAAS,EAC/D,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,OAiBnC;AAqCD;;;GAGG;AACH,wBAAsB,8BAA8B,CAClD,QAAQ,EAAE,QAAQ,GACjB,OAAO,CAAC,MAAM,CAAC,CAgBjB"}
|