feat: add Penpot exporter SVG connector (P3, UNVERIFIED pending service)
designops-gateway / build (push) Failing after 1m2s

This commit is contained in:
2026-09-27 22:45:12 +08:00
parent ccb8df4c1d
commit 737d5b8e7a
+50
View File
@@ -0,0 +1,50 @@
/**
* @module gateway-penpot-export
* @path gateway/src/connectors/penpot-export.ts
* @description Penpot exporter SVG export (POST /api/export :export-shapes)
* @zone action
* @tier Tier2-support
*
* @skill penpot-svg-export — export page/shape to SVG via exporter service
* @rule exporter-auth P1 — X-Shared-Key: exporter <key> + session cookie
* @state: UNVERIFIED — 依赖 Penpot exporter 服务,当前环境未启动,无法端到端验证
*/
export interface ExportShapeInput {
fileId: string;
pageId: string;
objectId?: string;
}
export class PenpotExporter {
constructor(
private base: string,
private sharedKey: string,
) {}
/** @skill: penpot-export-svg — call exporter :export-shapes, return SVG bytes */
async exportSvg(input: ExportShapeInput): Promise<Buffer> {
const res = await fetch(`${this.base}/api/export`, {
method: 'POST',
headers: {
'content-type': 'application/transit+json',
'x-shared-key': `exporter ${this.sharedKey}`,
},
body: JSON.stringify({
cmd: ':export-shapes',
exports: [
{
'file-id': input.fileId,
'page-id': input.pageId,
'object-id': input.objectId ?? input.pageId,
type: 'svg',
},
],
}),
});
if (!res.ok) {
throw new Error(`Penpot exporter HTTP ${res.status}: ${await res.text()}`);
}
return Buffer.from(await res.arrayBuffer());
}
}