@primeuicom/mcp 0.1.8 → 0.1.10
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/README.md +56 -21
- package/dist/service.js +723 -17
- package/dist/service.js.map +1 -1
- package/package.json +5 -2
- package/dist/instructions.d.ts +0 -173
- package/dist/instructions.js +0 -252
- package/dist/instructions.js.map +0 -1
- package/dist/lib/fs.d.ts +0 -4
- package/dist/lib/fs.js +0 -25
- package/dist/lib/fs.js.map +0 -1
- package/dist/server.d.ts +0 -3
- package/dist/server.js +0 -70
- package/dist/server.js.map +0 -1
- package/dist/service.d.ts +0 -2
- package/dist/services/project-sync-service.d.ts +0 -22
- package/dist/services/project-sync-service.js +0 -60
- package/dist/services/project-sync-service.js.map +0 -1
- package/dist/sources/api-provider.d.ts +0 -25
- package/dist/sources/api-provider.js +0 -238
- package/dist/sources/api-provider.js.map +0 -1
- package/dist/sources/project-data-provider.d.ts +0 -7
- package/dist/sources/project-data-provider.js +0 -2
- package/dist/sources/project-data-provider.js.map +0 -1
- package/dist/sources/project-sync-source.d.ts +0 -8
- package/dist/sources/project-sync-source.js +0 -2
- package/dist/sources/project-sync-source.js.map +0 -1
- package/dist/types.d.ts +0 -33
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
package/dist/server.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
-
import { initialInstructions, toolClearTemp, toolCreateExport, toolDownloadExport, toolGetProjectInfo, toolListExports, } from "./instructions.js";
|
|
3
|
-
function okResult(title, data) {
|
|
4
|
-
return {
|
|
5
|
-
content: [{ type: "text", text: `${title} completed` }],
|
|
6
|
-
structuredContent: data,
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
|
-
function errorResult(error) {
|
|
10
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
11
|
-
return {
|
|
12
|
-
isError: true,
|
|
13
|
-
content: [{ type: "text", text: `primeui mcp error: ${message}` }],
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
export function createPrimeUiMcpServer(source) {
|
|
17
|
-
const server = new McpServer({
|
|
18
|
-
name: "primeui-mcp-server",
|
|
19
|
-
version: "0.1.0",
|
|
20
|
-
}, {
|
|
21
|
-
instructions: initialInstructions,
|
|
22
|
-
});
|
|
23
|
-
server.registerTool("primeui_get_project_info", toolGetProjectInfo, async () => {
|
|
24
|
-
try {
|
|
25
|
-
const info = await source.getProjectInfo();
|
|
26
|
-
return okResult("primeui_get_project_info", info);
|
|
27
|
-
}
|
|
28
|
-
catch (error) {
|
|
29
|
-
return errorResult(error);
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
server.registerTool("primeui_list_exports", toolListExports, async () => {
|
|
33
|
-
try {
|
|
34
|
-
const exportsList = await source.listExports();
|
|
35
|
-
return okResult("primeui_list_exports", { exports: exportsList });
|
|
36
|
-
}
|
|
37
|
-
catch (error) {
|
|
38
|
-
return errorResult(error);
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
server.registerTool("primeui_create_export", toolCreateExport, async () => {
|
|
42
|
-
try {
|
|
43
|
-
const result = await source.createExport();
|
|
44
|
-
return okResult("primeui_create_export", result);
|
|
45
|
-
}
|
|
46
|
-
catch (error) {
|
|
47
|
-
return errorResult(error);
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
server.registerTool("primeui_download_export", toolDownloadExport, async ({ id }) => {
|
|
51
|
-
try {
|
|
52
|
-
const result = await source.downloadExportById(id);
|
|
53
|
-
return okResult("primeui_download_export", result);
|
|
54
|
-
}
|
|
55
|
-
catch (error) {
|
|
56
|
-
return errorResult(error);
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
server.registerTool("primeui_clear_temp", toolClearTemp, async () => {
|
|
60
|
-
try {
|
|
61
|
-
await source.clearTemp();
|
|
62
|
-
return okResult("primeui_clear_temp", { success: true });
|
|
63
|
-
}
|
|
64
|
-
catch (error) {
|
|
65
|
-
return errorResult(error);
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
return server;
|
|
69
|
-
}
|
|
70
|
-
//# sourceMappingURL=server.js.map
|
package/dist/server.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AAGnE,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,GAChB,MAAM,mBAAmB,CAAA;AAI1B,SAAS,QAAQ,CAAI,KAAa,EAAE,IAAO;IACzC,OAAO;QACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,YAAY,EAAE,CAAC;QACvD,iBAAiB,EAAE,IAA+B;KACnD,CAAA;AACH,CAAC;AAED,SAAS,WAAW,CAAC,KAAc;IACjC,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IACtE,OAAO;QACL,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,sBAAsB,OAAO,EAAE,EAAE,CAAC;KACnE,CAAA;AACH,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,MAAyB;IAC9D,MAAM,MAAM,GAAG,IAAI,SAAS,CAC1B;QACE,IAAI,EAAE,oBAAoB;QAC1B,OAAO,EAAE,OAAO;KACjB,EACD;QACE,YAAY,EAAE,mBAAmB;KAClC,CACF,CAAA;IAED,MAAM,CAAC,YAAY,CACjB,0BAA0B,EAC1B,kBAAkB,EAClB,KAAK,IAA6B,EAAE;QAClC,IAAI,CAAC;YACH,MAAM,IAAI,GAAuB,M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C3B,CAAC;IACH,CAAC,CACF,CAAA;IAED,MAAM,CAAC,YAAY,CACjB,oBAAoB,EACpB,aAAa,EACb,KAAK,IAA6B,EAAE;QAClC,IAAI,CAAC;YACH,MAAM,MAAM,CAAC,SAAS,EAAE,CAAA;YACxB,OAAO,QAAQ,CAAC,oBAAoB,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAA;QAC1D,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,WAAW,CAAC,KAAK,CAAC,CAAA;QAC3B,CAAC;IACH,CAAC,CACF,CAAA;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
|
package/dist/service.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { ProjectDataProvider } from "../sources/project-data-provider.js";
|
|
2
|
-
import type { ProjectSyncSource } from "../sources/project-sync-source.js";
|
|
3
|
-
import type { PrimeUiCreateExportResult, PrimeUiDownloadResult, PrimeUiExport, PrimeUiProjectInfo } from "../types.js";
|
|
4
|
-
type ProjectSyncServiceOptions = {
|
|
5
|
-
projectRoot: string;
|
|
6
|
-
provider: ProjectDataProvider;
|
|
7
|
-
};
|
|
8
|
-
export declare class ProjectSyncService implements ProjectSyncSource {
|
|
9
|
-
private readonly provider;
|
|
10
|
-
private readonly projectRoot;
|
|
11
|
-
private readonly primeUiRoot;
|
|
12
|
-
private readonly tempRoot;
|
|
13
|
-
private readonly exportsRoot;
|
|
14
|
-
constructor(options: ProjectSyncServiceOptions);
|
|
15
|
-
getProjectInfo(): Promise<PrimeUiProjectInfo>;
|
|
16
|
-
listExports(): Promise<PrimeUiExport[]>;
|
|
17
|
-
createExport(): Promise<PrimeUiCreateExportResult>;
|
|
18
|
-
downloadExportById(id: string): Promise<PrimeUiDownloadResult>;
|
|
19
|
-
clearTemp(): Promise<void>;
|
|
20
|
-
private ensureTempLayout;
|
|
21
|
-
}
|
|
22
|
-
export {};
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { ensureDir, extractZip, resetDir, writeUtf8 } from "../lib/fs.js";
|
|
3
|
-
export class ProjectSyncService {
|
|
4
|
-
provider;
|
|
5
|
-
projectRoot;
|
|
6
|
-
primeUiRoot;
|
|
7
|
-
tempRoot;
|
|
8
|
-
exportsRoot;
|
|
9
|
-
constructor(options) {
|
|
10
|
-
this.projectRoot = options.projectRoot;
|
|
11
|
-
this.provider = options.provider;
|
|
12
|
-
this.primeUiRoot = path.join(this.projectRoot, ".primeui");
|
|
13
|
-
this.tempRoot = path.join(this.primeUiRoot, "temp");
|
|
14
|
-
this.exportsRoot = path.join(this.tempRoot, "exports");
|
|
15
|
-
}
|
|
16
|
-
async getProjectInfo() {
|
|
17
|
-
await this.ensureTempLayout();
|
|
18
|
-
return this.provider.getProjectInfo();
|
|
19
|
-
}
|
|
20
|
-
async listExports() {
|
|
21
|
-
await this.ensureTempLayout();
|
|
22
|
-
return this.provider.listExports();
|
|
23
|
-
}
|
|
24
|
-
async createExport() {
|
|
25
|
-
await this.ensureTempLayout();
|
|
26
|
-
return this.provider.createExport();
|
|
27
|
-
}
|
|
28
|
-
async downloadExportById(id) {
|
|
29
|
-
await this.ensureTempLayout();
|
|
30
|
-
const exportsList = await this.provider.listExports();
|
|
31
|
-
const selected = exportsList.find((item) => item.id === id);
|
|
32
|
-
if (!selected) {
|
|
33
|
-
throw new Error(`Export not found: ${id}`);
|
|
34
|
-
}
|
|
35
|
-
const targetZipPath = path.join(this.exportsRoot, `${id}.zip`);
|
|
36
|
-
const targetProjectPath = path.join(this.exportsRoot, id);
|
|
37
|
-
await ensureDir(this.exportsRoot);
|
|
38
|
-
await this.provider.downloadExportArchive(id, targetZipPath);
|
|
39
|
-
await resetDir(targetProjectPath);
|
|
40
|
-
await extractZip(targetZipPath, targetProjectPath);
|
|
41
|
-
const { pages } = await this.provider.getProjectInfo();
|
|
42
|
-
return {
|
|
43
|
-
exportId: id,
|
|
44
|
-
projectPath: targetProjectPath,
|
|
45
|
-
pages,
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
async clearTemp() {
|
|
49
|
-
await resetDir(this.tempRoot);
|
|
50
|
-
await writeUtf8(path.join(this.tempRoot, ".gitkeep"), "");
|
|
51
|
-
await ensureDir(this.exportsRoot);
|
|
52
|
-
}
|
|
53
|
-
async ensureTempLayout() {
|
|
54
|
-
await ensureDir(this.primeUiRoot);
|
|
55
|
-
await ensureDir(this.tempRoot);
|
|
56
|
-
await ensureDir(this.exportsRoot);
|
|
57
|
-
await writeUtf8(path.join(this.tempRoot, ".gitkeep"), "");
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
//# sourceMappingURL=project-sync-service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"project-sync-service.js","sourceRoot":"","sources":["../../src/services/project-sync-service.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAUzE,MAAM,OAAO,kBAAkB;IACZ,QAAQ,CAAqB;IAC7B,WAAW,CAAQ;IACnB,WAAW,CAAQ;IACnB,QAAQ,CAAQ;IAChB,WAAW,CAAQ;IAEpC,YAAY,OAAkC;QAC5C,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAA;QACtC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAA;QAChC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,CAAA;QAC1D,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,CAAA;QACnD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAA;IACxD,CAAC;I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QAClD,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,cAAc,EAAE,CAAA;QAEtD,OAAO;YACL,QAAQ,EAAE,EAAE;YACZ,WAAW,EAAE,iBAAiB;YAC9B,KAAK;SACN,CAAA;IACH,CAAC;IAED,KAAK,CAAC,SAAS;QACb,MAAM,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QAC7B,MAAM,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,EAAE,EAAE,CAAC,CAAA;QACzD,MAAM,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;IACnC,CAAC;IAEO,KAAK,CAAC,gBAAgB;QAC5B,MAAM,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;QACjC,MAAM,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QAC9B,MAAM,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;QACjC,MAAM,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,EAAE,EAAE,CAAC,CAAA;IAC3D,CAAC;CACF"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { PrimeUiCreateExportResult, PrimeUiExport, PrimeUiProjectInfo } from "../types.js";
|
|
2
|
-
import type { ProjectDataProvider } from "./project-data-provider.js";
|
|
3
|
-
type ApiProjectDataProviderOptions = {
|
|
4
|
-
apiKey?: string;
|
|
5
|
-
baseUrl?: string;
|
|
6
|
-
};
|
|
7
|
-
export declare class ApiProjectDataProvider implements ProjectDataProvider {
|
|
8
|
-
private readonly apiKey?;
|
|
9
|
-
private readonly apiRoot;
|
|
10
|
-
constructor(options: ApiProjectDataProviderOptions);
|
|
11
|
-
getProjectInfo(): Promise<PrimeUiProjectInfo>;
|
|
12
|
-
listExports(): Promise<PrimeUiExport[]>;
|
|
13
|
-
createExport(): Promise<PrimeUiCreateExportResult>;
|
|
14
|
-
/**
|
|
15
|
-
* Consumer-side runtime contract for GET /api/v1/project/exports/:exportId/download.
|
|
16
|
-
* Producer source of truth: apps/studio/src/app/api/v1/project/exports/[exportId]/download/route.ts
|
|
17
|
-
* Keep content-type and archive format checks synchronized with the producer response.
|
|
18
|
-
*/
|
|
19
|
-
downloadExportArchive(exportId: string, destinationPath: string): Promise<void>;
|
|
20
|
-
private buildUrl;
|
|
21
|
-
private requestJson;
|
|
22
|
-
private readError;
|
|
23
|
-
private requireApiKey;
|
|
24
|
-
}
|
|
25
|
-
export {};
|
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
import { createWriteStream } from "node:fs";
|
|
2
|
-
import { unlink } from "node:fs/promises";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import { Readable, Transform } from "node:stream";
|
|
5
|
-
import { pipeline } from "node:stream/promises";
|
|
6
|
-
import { z } from "zod";
|
|
7
|
-
import { ensureDir } from "../lib/fs.js";
|
|
8
|
-
const DEFAULT_API_BASE_URL = "https://app.primeui.com/";
|
|
9
|
-
const ZIP_CONTENT_TYPES = ["application/zip", "application/octet-stream", "application/x-zip-compressed"];
|
|
10
|
-
const exportStatusSchema = z.enum(["in_progress", "completed", "failed"]);
|
|
11
|
-
const projectPageSchema = z.object({
|
|
12
|
-
id: z.string(),
|
|
13
|
-
title: z.string(),
|
|
14
|
-
slug: z.string(),
|
|
15
|
-
pageType: z.string(),
|
|
16
|
-
isReadyToExport: z.boolean(),
|
|
17
|
-
pagePath: z.string(),
|
|
18
|
-
componentsPath: z.string(),
|
|
19
|
-
});
|
|
20
|
-
/**
|
|
21
|
-
* Consumer-side runtime contract for GET /api/v1/project.
|
|
22
|
-
* Producer source of truth: apps/studio/src/app/api/v1/project/route.ts
|
|
23
|
-
* Keep this schema synchronized with the producer payload.
|
|
24
|
-
*/
|
|
25
|
-
const projectInfoSchema = z.object({
|
|
26
|
-
projectId: z.string(),
|
|
27
|
-
projectName: z.string(),
|
|
28
|
-
metadata: z.record(z.unknown()),
|
|
29
|
-
pages: z.array(projectPageSchema),
|
|
30
|
-
});
|
|
31
|
-
/**
|
|
32
|
-
* Consumer-side runtime contract for GET /api/v1/project/exports.
|
|
33
|
-
* Producer source of truth: apps/studio/src/app/api/v1/project/exports/route.ts
|
|
34
|
-
* Keep this schema synchronized with the producer payload.
|
|
35
|
-
*/
|
|
36
|
-
const exportsResponseSchema = z.object({
|
|
37
|
-
exports: z.array(z.object({
|
|
38
|
-
id: z.string(),
|
|
39
|
-
status: exportStatusSchema,
|
|
40
|
-
createdAt: z.string().datetime({ offset: true }),
|
|
41
|
-
})),
|
|
42
|
-
});
|
|
43
|
-
/**
|
|
44
|
-
* Consumer-side runtime contract for POST /api/v1/project/exports.
|
|
45
|
-
* Producer source of truth: apps/studio/src/app/api/v1/project/exports/route.ts
|
|
46
|
-
* Keep this schema synchronized with the producer payload.
|
|
47
|
-
*/
|
|
48
|
-
const createExportResponseSchema = z.object({
|
|
49
|
-
export: z.object({
|
|
50
|
-
id: z.string(),
|
|
51
|
-
status: exportStatusSchema,
|
|
52
|
-
}),
|
|
53
|
-
pages: z.array(projectPageSchema),
|
|
54
|
-
});
|
|
55
|
-
class PrimeUiApiContractError extends Error {
|
|
56
|
-
constructor(endpoint, details) {
|
|
57
|
-
super(`PrimeUI API contract mismatch for "${endpoint}": ${details}`);
|
|
58
|
-
this.name = "PrimeUiApiContractError";
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
const normalizeApiRoot = (rawBaseUrl) => {
|
|
62
|
-
const normalizedBase = rawBaseUrl.trim() || DEFAULT_API_BASE_URL;
|
|
63
|
-
const parsed = new URL(normalizedBase);
|
|
64
|
-
const normalizedPath = parsed.pathname.replace(/\/+$/, "");
|
|
65
|
-
if (normalizedPath.endsWith("/api/v1")) {
|
|
66
|
-
parsed.pathname = `${normalizedPath}/`;
|
|
67
|
-
return parsed.toString();
|
|
68
|
-
}
|
|
69
|
-
parsed.pathname = `${normalizedPath}/api/v1/`.replace("//api/v1/", "/api/v1/");
|
|
70
|
-
return parsed.toString();
|
|
71
|
-
};
|
|
72
|
-
const isJsonContentType = (contentType) => contentType.includes("application/json") || contentType.includes("+json");
|
|
73
|
-
const isZipContentType = (contentType) => ZIP_CONTENT_TYPES.some((allowedType) => contentType.includes(allowedType));
|
|
74
|
-
const looksLikeZipArchive = (buffer) => {
|
|
75
|
-
if (buffer.length < 4) {
|
|
76
|
-
return false;
|
|
77
|
-
}
|
|
78
|
-
if (buffer[0] !== 0x50 || buffer[1] !== 0x4b) {
|
|
79
|
-
return false;
|
|
80
|
-
}
|
|
81
|
-
const signature = `${buffer[2]}:${buffer[3]}`;
|
|
82
|
-
return signature === "3:4" || signature === "5:6" || signature === "7:8";
|
|
83
|
-
};
|
|
84
|
-
const createZipSignatureGuard = (endpoint) => {
|
|
85
|
-
let signature = Buffer.alloc(0);
|
|
86
|
-
let validated = false;
|
|
87
|
-
return new Transform({
|
|
88
|
-
transform(chunk, _encoding, callback) {
|
|
89
|
-
const chunkBuffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
90
|
-
if (!validated) {
|
|
91
|
-
const requiredBytes = Math.max(0, 4 - signature.length);
|
|
92
|
-
if (requiredBytes > 0) {
|
|
93
|
-
signature = Buffer.concat([signature, chunkBuffer.subarray(0, requiredBytes)]);
|
|
94
|
-
}
|
|
95
|
-
if (signature.length >= 4) {
|
|
96
|
-
if (!looksLikeZipArchive(signature)) {
|
|
97
|
-
callback(new PrimeUiApiContractError(endpoint, "response body is not a valid zip archive"));
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
validated = true;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
callback(null, chunkBuffer);
|
|
104
|
-
},
|
|
105
|
-
flush(callback) {
|
|
106
|
-
if (!validated) {
|
|
107
|
-
callback(new PrimeUiApiContractError(endpoint, "response body is not a valid zip archive"));
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
callback();
|
|
111
|
-
},
|
|
112
|
-
});
|
|
113
|
-
};
|
|
114
|
-
export class ApiProjectDataProvider {
|
|
115
|
-
apiKey;
|
|
116
|
-
apiRoot;
|
|
117
|
-
constructor(options) {
|
|
118
|
-
this.apiKey = options.apiKey;
|
|
119
|
-
this.apiRoot = normalizeApiRoot(options.baseUrl ?? DEFAULT_API_BASE_URL);
|
|
120
|
-
}
|
|
121
|
-
async getProjectInfo() {
|
|
122
|
-
return this.requestJson("project", projectInfoSchema);
|
|
123
|
-
}
|
|
124
|
-
async listExports() {
|
|
125
|
-
const response = await this.requestJson("project/exports", exportsResponseSchema);
|
|
126
|
-
return response.exports;
|
|
127
|
-
}
|
|
128
|
-
async createExport() {
|
|
129
|
-
return this.requestJson("project/exports", createExportResponseSchema, { method: "POST" });
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Consumer-side runtime contract for GET /api/v1/project/exports/:exportId/download.
|
|
133
|
-
* Producer source of truth: apps/studio/src/app/api/v1/project/exports/[exportId]/download/route.ts
|
|
134
|
-
* Keep content-type and archive format checks synchronized with the producer response.
|
|
135
|
-
*/
|
|
136
|
-
async downloadExportArchive(exportId, destinationPath) {
|
|
137
|
-
const endpoint = `project/exports/${encodeURIComponent(exportId)}/download`;
|
|
138
|
-
const apiKey = this.requireApiKey();
|
|
139
|
-
const response = await fetch(this.buildUrl(endpoint), {
|
|
140
|
-
method: "GET",
|
|
141
|
-
headers: {
|
|
142
|
-
Authorization: `Bearer ${apiKey}`,
|
|
143
|
-
},
|
|
144
|
-
});
|
|
145
|
-
if (!response.ok) {
|
|
146
|
-
const details = await this.readError(response);
|
|
147
|
-
throw new Error(`PrimeUI API request failed (${response.status}) while downloading export "${exportId}": ${details}`);
|
|
148
|
-
}
|
|
149
|
-
const contentType = response.headers.get("content-type") ?? "";
|
|
150
|
-
if (!isZipContentType(contentType)) {
|
|
151
|
-
throw new PrimeUiApiContractError(endpoint, `expected zip content-type but got "${contentType || "unknown"}"`);
|
|
152
|
-
}
|
|
153
|
-
if (!response.body) {
|
|
154
|
-
throw new PrimeUiApiContractError(endpoint, "response body is empty");
|
|
155
|
-
}
|
|
156
|
-
await ensureDir(path.dirname(destinationPath));
|
|
157
|
-
const zipStream = Readable.fromWeb(response.body);
|
|
158
|
-
const signatureGuard = createZipSignatureGuard(endpoint);
|
|
159
|
-
const fileStream = createWriteStream(destinationPath);
|
|
160
|
-
try {
|
|
161
|
-
await pipeline(zipStream, signatureGuard, fileStream);
|
|
162
|
-
}
|
|
163
|
-
catch (error) {
|
|
164
|
-
await unlink(destinationPath).catch(() => undefined);
|
|
165
|
-
throw error;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
buildUrl(endpoint) {
|
|
169
|
-
return new URL(endpoint, this.apiRoot).toString();
|
|
170
|
-
}
|
|
171
|
-
async requestJson(endpoint, schema, requestInit = {}) {
|
|
172
|
-
const apiKey = this.requireApiKey();
|
|
173
|
-
const method = requestInit.method ?? "GET";
|
|
174
|
-
const response = await fetch(this.buildUrl(endpoint), {
|
|
175
|
-
...requestInit,
|
|
176
|
-
method,
|
|
177
|
-
headers: {
|
|
178
|
-
...(requestInit.headers ?? {}),
|
|
179
|
-
Authorization: `Bearer ${apiKey}`,
|
|
180
|
-
},
|
|
181
|
-
});
|
|
182
|
-
if (!response.ok) {
|
|
183
|
-
const details = await this.readError(response);
|
|
184
|
-
throw new Error(`PrimeUI API request failed (${response.status}) for "${endpoint}": ${details}`);
|
|
185
|
-
}
|
|
186
|
-
const contentType = response.headers.get("content-type") ?? "";
|
|
187
|
-
if (!isJsonContentType(contentType)) {
|
|
188
|
-
throw new PrimeUiApiContractError(endpoint, `expected JSON content-type but got "${contentType || "unknown"}"`);
|
|
189
|
-
}
|
|
190
|
-
let payload;
|
|
191
|
-
try {
|
|
192
|
-
payload = await response.json();
|
|
193
|
-
}
|
|
194
|
-
catch {
|
|
195
|
-
throw new PrimeUiApiContractError(endpoint, "response body is not valid JSON");
|
|
196
|
-
}
|
|
197
|
-
const parsed = schema.safeParse(payload);
|
|
198
|
-
if (!parsed.success) {
|
|
199
|
-
const details = parsed.error.issues
|
|
200
|
-
.map((issue) => `${issue.path.join(".") || "<root>"}: ${issue.message}`)
|
|
201
|
-
.join("; ");
|
|
202
|
-
throw new PrimeUiApiContractError(endpoint, details);
|
|
203
|
-
}
|
|
204
|
-
return parsed.data;
|
|
205
|
-
}
|
|
206
|
-
async readError(response) {
|
|
207
|
-
const contentType = response.headers.get("content-type") ?? "";
|
|
208
|
-
try {
|
|
209
|
-
if (contentType.includes("application/json")) {
|
|
210
|
-
const body = (await response.json());
|
|
211
|
-
if (body?.message && body?.code) {
|
|
212
|
-
return `${body.code}: ${body.message}`;
|
|
213
|
-
}
|
|
214
|
-
if (body?.message) {
|
|
215
|
-
return body.message;
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
else {
|
|
219
|
-
const bodyText = await response.text();
|
|
220
|
-
if (bodyText.trim()) {
|
|
221
|
-
return bodyText.trim();
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
catch {
|
|
226
|
-
// No-op: fall through to generic status text.
|
|
227
|
-
}
|
|
228
|
-
return response.statusText || "Unknown error";
|
|
229
|
-
}
|
|
230
|
-
requireApiKey() {
|
|
231
|
-
const apiKey = this.apiKey?.trim();
|
|
232
|
-
if (!apiKey) {
|
|
233
|
-
throw new Error("PRIMEUI_API_KEY is required to call PrimeUI API tools.");
|
|
234
|
-
}
|
|
235
|
-
return apiKey;
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
//# sourceMappingURL=api-provider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"api-provider.js","sourceRoot":"","sources":["../../src/sources/api-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,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AE9D,IAAI,CAAC;YACH,IAAI,WAAW,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC;gBAC7C,MAAM,IAAI,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAwC,CAAA;gBAC3E,IAAI,IAAI,EAAE,OAAO,IAAI,IAAI,EAAE,IAAI,EAAE,CAAC;oBAChC,OAAO,GAAG,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,OAAO,EAAE,CAAA;gBACxC,CAAC;gBACD,IAAI,IAAI,EAAE,OAAO,EAAE,CAAC;oBAClB,OAAO,IAAI,CAAC,OAAO,CAAA;gBACrB,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;gBACtC,IAAI,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC;oBACpB,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAA;gBACxB,CAAC;YACH,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,8CAA8C;QAChD,CAAC;QAED,OAAO,QAAQ,CAAC,UAAU,IAAI,eAAe,CAAA;IAC/C,CAAC;IAEO,aAAa;QACnB,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,CAAA;QAClC,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAA;QAC3E,CAAC;QAED,OAAO,MAAM,CAAA;IACf,CAAC;CACF"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { PrimeUiCreateExportResult, PrimeUiExport, PrimeUiProjectInfo } from "../types.js";
|
|
2
|
-
export interface ProjectDataProvider {
|
|
3
|
-
getProjectInfo(): Promise<PrimeUiProjectInfo>;
|
|
4
|
-
listExports(): Promise<PrimeUiExport[]>;
|
|
5
|
-
createExport(): Promise<PrimeUiCreateExportResult>;
|
|
6
|
-
downloadExportArchive(exportId: string, destinationPath: string): Promise<void>;
|
|
7
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"project-data-provider.js","sourceRoot":"","sources":["../../src/sources/project-data-provider.ts"],"names":[],"mappings":""}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { PrimeUiCreateExportResult, PrimeUiDownloadResult, PrimeUiExport, PrimeUiProjectInfo } from "../types.js";
|
|
2
|
-
export interface ProjectSyncSource {
|
|
3
|
-
getProjectInfo(): Promise<PrimeUiProjectInfo>;
|
|
4
|
-
listExports(): Promise<PrimeUiExport[]>;
|
|
5
|
-
createExport(): Promise<PrimeUiCreateExportResult>;
|
|
6
|
-
downloadExportById(id: string): Promise<PrimeUiDownloadResult>;
|
|
7
|
-
clearTemp(): Promise<void>;
|
|
8
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"project-sync-source.js","sourceRoot":"","sources":["../../src/sources/project-sync-source.ts"],"names":[],"mappings":""}
|
package/dist/types.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
export type PrimeUiExportStatus = "in_progress" | "completed" | "failed";
|
|
2
|
-
export interface PrimeUiProjectPage {
|
|
3
|
-
id: string;
|
|
4
|
-
title: string;
|
|
5
|
-
slug: string;
|
|
6
|
-
pageType: string;
|
|
7
|
-
isReadyToExport: boolean;
|
|
8
|
-
pagePath: string;
|
|
9
|
-
componentsPath: string;
|
|
10
|
-
}
|
|
11
|
-
export interface PrimeUiProjectInfo {
|
|
12
|
-
projectId: string;
|
|
13
|
-
projectName: string;
|
|
14
|
-
metadata: Record<string, unknown>;
|
|
15
|
-
pages: PrimeUiProjectPage[];
|
|
16
|
-
}
|
|
17
|
-
export interface PrimeUiExport {
|
|
18
|
-
id: string;
|
|
19
|
-
status: PrimeUiExportStatus;
|
|
20
|
-
createdAt: string;
|
|
21
|
-
}
|
|
22
|
-
export interface PrimeUiCreateExportResult {
|
|
23
|
-
export: {
|
|
24
|
-
id: string;
|
|
25
|
-
status: PrimeUiExportStatus;
|
|
26
|
-
};
|
|
27
|
-
pages: PrimeUiProjectPage[];
|
|
28
|
-
}
|
|
29
|
-
export interface PrimeUiDownloadResult {
|
|
30
|
-
exportId: string;
|
|
31
|
-
projectPath: string;
|
|
32
|
-
pages: PrimeUiProjectPage[];
|
|
33
|
-
}
|
package/dist/types.js
DELETED
package/dist/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|