@detiq/crawler 1.1.17 → 1.1.19
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 +44 -12
- package/dist/job-queue.js.map +2 -2
- package/package.json +1 -1
- package/src/job-queue.ts +61 -14
package/dist/job-queue.js
CHANGED
|
@@ -820,17 +820,23 @@ async function processFigmaImportJob(jobId, config) {
|
|
|
820
820
|
(tx) => tx.platformJob.update({ where: { id: jobId }, data: { status: "RUNNING", startedAt: /* @__PURE__ */ new Date() } })
|
|
821
821
|
);
|
|
822
822
|
try {
|
|
823
|
-
const
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
);
|
|
827
|
-
if (!connector) throw new Error("Figma connector not configured. Add your Figma token in Project Settings \u2192 Integrations.");
|
|
828
|
-
const cfg = connector.config;
|
|
829
|
-
const accessToken = cfg.accessToken_enc ? decrypt(cfg.accessToken_enc) : "";
|
|
830
|
-
if (!accessToken) throw new Error("Figma access token missing. Edit the Figma connector and add your Personal Access Token.");
|
|
831
|
-
const resolvedFileKey = fileKey ?? cfg.fileKey ?? "";
|
|
823
|
+
const oauthConn = await AppBrain.getOAuthConnection(tenantId, projectId, "FIGMA");
|
|
824
|
+
let creds;
|
|
825
|
+
const resolvedFileKey = fileKey ?? "";
|
|
832
826
|
if (!resolvedFileKey) throw new Error("No Figma file key. Paste the full Figma file URL as the App URL.");
|
|
833
|
-
|
|
827
|
+
if (oauthConn?.accessToken && oauthConn.status === "CONNECTED") {
|
|
828
|
+
creds = { accessToken: "", oauthToken: oauthConn.accessToken, fileKey: resolvedFileKey };
|
|
829
|
+
} else {
|
|
830
|
+
const connector = await withTenant(
|
|
831
|
+
tenantId,
|
|
832
|
+
(tx) => tx.connector.findFirst({ where: { projectId, kind: "FIGMA", tenantId } })
|
|
833
|
+
);
|
|
834
|
+
if (!connector) throw new Error("Figma connector not configured. Add your Figma token in Project Settings \u2192 Integrations.");
|
|
835
|
+
const cfg = connector.config;
|
|
836
|
+
const pat = cfg.accessToken_enc ? decrypt(cfg.accessToken_enc) : "";
|
|
837
|
+
if (!pat) throw new Error("Figma access token missing. Edit the Figma connector and add your Personal Access Token.");
|
|
838
|
+
creds = { accessToken: pat, fileKey: resolvedFileKey };
|
|
839
|
+
}
|
|
834
840
|
await updateJobProgress(tenantId, jobId, 5, "Listing frames from Figma file\u2026");
|
|
835
841
|
const frames = await figma.listScreens(creds, resolvedFileKey);
|
|
836
842
|
if (frames.length === 0) {
|
|
@@ -869,7 +875,9 @@ async function processFigmaImportJob(jobId, config) {
|
|
|
869
875
|
console.warn("[figma-import] cloud upload failed:", e);
|
|
870
876
|
}
|
|
871
877
|
}
|
|
872
|
-
|
|
878
|
+
const w = frame.boundingBox?.width ?? 1440;
|
|
879
|
+
const viewport = w <= 480 ? "MOBILE_PORTRAIT" : w <= 1024 ? "TABLET" : "DESKTOP";
|
|
880
|
+
await AppBrain.saveScreenshot(tenantId, projectId, screen.id, storagePath, 1, viewport, cloudUrl);
|
|
873
881
|
}
|
|
874
882
|
}
|
|
875
883
|
if (frame.node) {
|
|
@@ -2068,7 +2076,7 @@ jobDispatchTable = {
|
|
|
2068
2076
|
BATCH_GENERATE_ALIGNED: processBatchGenerateAlignedJob,
|
|
2069
2077
|
CREATE_PR: processCreatePRJob,
|
|
2070
2078
|
NEW_PAGES_PIPELINE: processNewPagesPipelineJob,
|
|
2071
|
-
//
|
|
2079
|
+
// The following job types are processed in-process by the API (never QUEUED).
|
|
2072
2080
|
// If the worker claims one, the API crashed after creating it — mark failed so it's visible.
|
|
2073
2081
|
GENERATE_TESTS: async (jobId, _config) => {
|
|
2074
2082
|
logger.error({ jobId }, "[job-worker] GENERATE_TESTS claimed by worker \u2014 API did not process it in-process");
|
|
@@ -2077,6 +2085,30 @@ jobDispatchTable = {
|
|
|
2077
2085
|
data: { status: "FAILED", error: "Test generation was not completed by the API \u2014 please retry from the UI.", finishedAt: /* @__PURE__ */ new Date() }
|
|
2078
2086
|
}).catch(() => {
|
|
2079
2087
|
});
|
|
2088
|
+
},
|
|
2089
|
+
GENERATE_DATA: async (jobId, _config) => {
|
|
2090
|
+
logger.error({ jobId }, "[job-worker] GENERATE_DATA claimed by worker \u2014 API did not process it in-process");
|
|
2091
|
+
await prismaAdmin.platformJob.update({
|
|
2092
|
+
where: { id: jobId },
|
|
2093
|
+
data: { status: "FAILED", error: "Data generation was not completed by the API \u2014 please retry from the UI.", finishedAt: /* @__PURE__ */ new Date() }
|
|
2094
|
+
}).catch(() => {
|
|
2095
|
+
});
|
|
2096
|
+
},
|
|
2097
|
+
GENERATE_SCRIPT: async (jobId, _config) => {
|
|
2098
|
+
logger.error({ jobId }, "[job-worker] GENERATE_SCRIPT claimed by worker \u2014 API did not process it in-process");
|
|
2099
|
+
await prismaAdmin.platformJob.update({
|
|
2100
|
+
where: { id: jobId },
|
|
2101
|
+
data: { status: "FAILED", error: "Script generation was not completed by the API \u2014 please retry from the UI.", finishedAt: /* @__PURE__ */ new Date() }
|
|
2102
|
+
}).catch(() => {
|
|
2103
|
+
});
|
|
2104
|
+
},
|
|
2105
|
+
GENERATE_TEST_PLAN: async (jobId, _config) => {
|
|
2106
|
+
logger.error({ jobId }, "[job-worker] GENERATE_TEST_PLAN claimed by worker \u2014 API did not process it in-process");
|
|
2107
|
+
await prismaAdmin.platformJob.update({
|
|
2108
|
+
where: { id: jobId },
|
|
2109
|
+
data: { status: "FAILED", error: "Test plan generation was not completed by the API \u2014 please retry from the UI.", finishedAt: /* @__PURE__ */ new Date() }
|
|
2110
|
+
}).catch(() => {
|
|
2111
|
+
});
|
|
2080
2112
|
}
|
|
2081
2113
|
};
|
|
2082
2114
|
async function processRepoScanJob(jobId, config) {
|