@detiq/crawler 1.1.17 → 1.1.18
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 +19 -11
- package/dist/job-queue.js.map +2 -2
- package/package.json +1 -1
- package/src/job-queue.ts +20 -12
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) {
|