@detiq/crawler 1.1.22 → 1.1.23

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/dist/job-queue.js CHANGED
@@ -212,10 +212,15 @@ function startJobWorkerLoop(opts) {
212
212
  logger.error({ err: String(err) }, "[job-worker] stale-job sweep failed");
213
213
  }
214
214
  try {
215
- for (let i = 0; i < concurrency; i++) {
216
- const job = await claimNextQueuedJob();
217
- if (!job) break;
218
- void dispatchClaimedJob(job);
215
+ const pauseRow = await prismaAdmin.systemConfig.findUnique({ where: { key: "queue.paused" } });
216
+ if (pauseRow?.value === "true") {
217
+ logger.info("[job-worker] queue is paused \u2014 skipping claim");
218
+ } else {
219
+ for (let i = 0; i < concurrency; i++) {
220
+ const job = await claimNextQueuedJob();
221
+ if (!job) break;
222
+ void dispatchClaimedJob(job);
223
+ }
219
224
  }
220
225
  } catch (err) {
221
226
  logger.error({ err: String(err) }, "[job-worker] claim loop failed");
@@ -1947,9 +1952,20 @@ async function processCaptureStepsJob(jobId, config) {
1947
1952
  ]);
1948
1953
  if (!tc) throw new Error("Test case not found");
1949
1954
  const rawSteps = Array.isArray(tc.steps) ? tc.steps : [];
1950
- const stepTexts = rawSteps.map(captureStepText).filter(Boolean);
1955
+ if (rawSteps.length === 0) throw new Error("Test case has no steps to capture");
1956
+ const _tdi = tc.testDataInline ?? {};
1957
+ const _tdiStartUrl = typeof _tdi["startUrl"] === "string" && _tdi["startUrl"].startsWith("http") ? _tdi["startUrl"] : "";
1958
+ const _recordedUrls = Array.isArray(_tdi["recordedUrls"]) ? _tdi["recordedUrls"].map(String) : [];
1959
+ const _recordedStartUrl = _recordedUrls.find((u) => u.startsWith("http")) ?? "";
1960
+ const baseUrl = config.baseUrl || _tdiStartUrl || _recordedStartUrl || tc?.screen?.project?.appUrl || crawlCfg?.appUrl || "";
1961
+ const _envTokenMap = {};
1962
+ for (const [k, v] of Object.entries(_tdi)) {
1963
+ if (typeof v === "string" && v.startsWith("http")) _envTokenMap[k] = v;
1964
+ }
1965
+ if (_recordedStartUrl && !_envTokenMap["startUrl"]) _envTokenMap["startUrl"] = _recordedStartUrl;
1966
+ const resolveStepText = (text) => text.replace(/\{\{\s*fze\.env\.([A-Za-z_][A-Za-z0-9_]*)\s*\}\}/g, (_m, k) => _envTokenMap[k] ?? `[${k}]`).replace(/\[env:([A-Za-z_][A-Za-z0-9_]*)\]/g, (_m, k) => _envTokenMap[k] ?? `[${k}]`);
1967
+ const stepTexts = rawSteps.map(captureStepText).filter(Boolean).map(resolveStepText);
1951
1968
  if (stepTexts.length === 0) throw new Error("Test case has no steps to capture");
1952
- const baseUrl = config.baseUrl || tc?.screen?.project?.appUrl || crawlCfg?.appUrl || "";
1953
1969
  let plan = await generateExecutionPlan(tenantId, { ...tc, steps: stepTexts }, baseUrl).catch(() => []);
1954
1970
  plan = Array.isArray(plan) ? plan.filter(Boolean).map((step, idx) => ({ ...step, stepNumber: idx + 1 })) : [];
1955
1971
  if (plan.length === 0) plan = fallbackExecutionPlan(rawSteps);