@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/package.json
CHANGED
package/src/job-queue.ts
CHANGED
|
@@ -1064,19 +1064,25 @@ async function processFigmaImportJob(jobId: string, config: any) {
|
|
|
1064
1064
|
tx.platformJob.update({ where: { id: jobId }, data: { status: 'RUNNING', startedAt: new Date() } })
|
|
1065
1065
|
);
|
|
1066
1066
|
try {
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
const cfg = connector.config as Record<string, string>;
|
|
1073
|
-
const accessToken = cfg.accessToken_enc ? decrypt(cfg.accessToken_enc) : '';
|
|
1074
|
-
if (!accessToken) throw new Error('Figma access token missing. Edit the Figma connector and add your Personal Access Token.');
|
|
1075
|
-
|
|
1076
|
-
const resolvedFileKey = fileKey ?? cfg.fileKey ?? '';
|
|
1067
|
+
// Prefer OAuth token (connected via Figma OAuth flow), fall back to PAT connector.
|
|
1068
|
+
const oauthConn = await AppBrain.getOAuthConnection(tenantId, projectId, 'FIGMA');
|
|
1069
|
+
let creds: figma.FigmaCredentials;
|
|
1070
|
+
const resolvedFileKey = fileKey ?? '';
|
|
1077
1071
|
if (!resolvedFileKey) throw new Error('No Figma file key. Paste the full Figma file URL as the App URL.');
|
|
1078
1072
|
|
|
1079
|
-
|
|
1073
|
+
if (oauthConn?.accessToken && oauthConn.status === 'CONNECTED') {
|
|
1074
|
+
// OAuth token must use Authorization: Bearer header (oauthToken field), not X-Figma-Token
|
|
1075
|
+
creds = { accessToken: '', oauthToken: oauthConn.accessToken, fileKey: resolvedFileKey };
|
|
1076
|
+
} else {
|
|
1077
|
+
const connector = await withTenant(tenantId, (tx) =>
|
|
1078
|
+
(tx as any).connector.findFirst({ where: { projectId, kind: 'FIGMA', tenantId } })
|
|
1079
|
+
) as any;
|
|
1080
|
+
if (!connector) throw new Error('Figma connector not configured. Add your Figma token in Project Settings → Integrations.');
|
|
1081
|
+
const cfg = connector.config as Record<string, string>;
|
|
1082
|
+
const pat = cfg.accessToken_enc ? decrypt(cfg.accessToken_enc) : '';
|
|
1083
|
+
if (!pat) throw new Error('Figma access token missing. Edit the Figma connector and add your Personal Access Token.');
|
|
1084
|
+
creds = { accessToken: pat, fileKey: resolvedFileKey };
|
|
1085
|
+
}
|
|
1080
1086
|
|
|
1081
1087
|
await updateJobProgress(tenantId, jobId, 5, 'Listing frames from Figma file…');
|
|
1082
1088
|
const frames = await figma.listScreens(creds, resolvedFileKey);
|
|
@@ -1118,7 +1124,9 @@ async function processFigmaImportJob(jobId: string, config: any) {
|
|
|
1118
1124
|
console.warn('[figma-import] cloud upload failed:', e);
|
|
1119
1125
|
}
|
|
1120
1126
|
}
|
|
1121
|
-
|
|
1127
|
+
const w = (frame as any).boundingBox?.width ?? 1440;
|
|
1128
|
+
const viewport = w <= 480 ? 'MOBILE_PORTRAIT' : w <= 1024 ? 'TABLET' : 'DESKTOP';
|
|
1129
|
+
await AppBrain.saveScreenshot(tenantId, projectId, screen.id, storagePath, 1, viewport, cloudUrl);
|
|
1122
1130
|
}
|
|
1123
1131
|
}
|
|
1124
1132
|
|