@appport/generators 1.0.0
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 +34 -0
- package/dist/client.d.ts +23 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +83 -0
- package/dist/client.js.map +1 -0
- package/dist/desktop.d.ts +60 -0
- package/dist/desktop.d.ts.map +1 -0
- package/dist/desktop.js +97 -0
- package/dist/desktop.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/json-schema-to-ts.d.ts +14 -0
- package/dist/json-schema-to-ts.d.ts.map +1 -0
- package/dist/json-schema-to-ts.js +103 -0
- package/dist/json-schema-to-ts.js.map +1 -0
- package/package.json +29 -0
package/README.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# @appport/generators
|
|
2
|
+
|
|
3
|
+
Manifest-driven code generation.
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
manifest -> generator -> typed client
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { generateClient } from "@appport/generators";
|
|
11
|
+
|
|
12
|
+
const source = generateClient(manifest);
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
or, from the CLI:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
appport generate
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
The generated module contains input and output types per capability version,
|
|
22
|
+
event payload types, a contract interface, the capability versions to send, the
|
|
23
|
+
list of stream capabilities, and a typed client factory:
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { createDocumentsClient } from "./appport/generated/client.ts";
|
|
27
|
+
|
|
28
|
+
const client = createDocumentsClient({ transport });
|
|
29
|
+
const { version } = await client.capabilities.documents.save({ documentId, content });
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Types are derived from the published JSON Schema rather than from the server's
|
|
33
|
+
TypeScript, so the same generator works against any conformant implementation —
|
|
34
|
+
including one written in another language.
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { AppPortManifest } from "@appport/protocol";
|
|
2
|
+
/**
|
|
3
|
+
* Client generation (specification §33).
|
|
4
|
+
*
|
|
5
|
+
* manifest → generator → typed client. The developer never builds a protocol
|
|
6
|
+
* envelope by hand, and the types come from the published JSON Schema rather
|
|
7
|
+
* than from the server's source, so the same generator works against any
|
|
8
|
+
* conformant implementation.
|
|
9
|
+
*/
|
|
10
|
+
export interface GenerateClientOptions {
|
|
11
|
+
/** Exported contract type name. Defaults to a name derived from the app id. */
|
|
12
|
+
contractName?: string;
|
|
13
|
+
/** Exported factory name. Defaults to `create<App>Client`. */
|
|
14
|
+
factoryName?: string;
|
|
15
|
+
/** Emit the manifest as a constant so the client can resolve versions offline. */
|
|
16
|
+
embedManifest?: boolean;
|
|
17
|
+
/** Module specifier for the client package. */
|
|
18
|
+
clientModule?: string;
|
|
19
|
+
}
|
|
20
|
+
export declare function generateClient(manifest: AppPortManifest, options?: GenerateClientOptions): string;
|
|
21
|
+
/** Emits the manifest as a standalone JSON document. */
|
|
22
|
+
export declare function generateManifestJson(manifest: AppPortManifest): string;
|
|
23
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGzD;;;;;;;GAOG;AACH,MAAM,WAAW,qBAAqB;IACpC,+EAA+E;IAC/E,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,8DAA8D;IAC9D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kFAAkF;IAClF,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,+CAA+C;IAC/C,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,eAAe,EAAE,OAAO,GAAE,qBAA0B,GAAG,MAAM,CA6FrG;AAED,wDAAwD;AACxD,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,eAAe,GAAG,MAAM,CAEtE"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { jsonSchemaToTypeScript, pascalCase } from "./json-schema-to-ts.js";
|
|
2
|
+
export function generateClient(manifest, options = {}) {
|
|
3
|
+
const appName = pascalCase(manifest.application.id.split(".").slice(-1)[0] ?? "app");
|
|
4
|
+
const contractName = options.contractName ?? `${appName}Contract`;
|
|
5
|
+
const factoryName = options.factoryName ?? `create${appName}Client`;
|
|
6
|
+
const clientModule = options.clientModule ?? "@appport/sdk";
|
|
7
|
+
const embedManifest = options.embedManifest ?? true;
|
|
8
|
+
const lines = [];
|
|
9
|
+
lines.push("/**");
|
|
10
|
+
lines.push(` * Generated from the AppPort manifest for ${manifest.application.id}`);
|
|
11
|
+
lines.push(` * (application version ${manifest.application.version}, protocol ${manifest.protocol}).`);
|
|
12
|
+
lines.push(" *");
|
|
13
|
+
lines.push(" * Do not edit by hand: run `appport generate` to refresh it.");
|
|
14
|
+
lines.push(" */");
|
|
15
|
+
lines.push(`import { createClient, type AppContract, type AppPortClient, type ClientOptions } from ${JSON.stringify(clientModule)};`);
|
|
16
|
+
lines.push("");
|
|
17
|
+
for (const capability of manifest.capabilities) {
|
|
18
|
+
for (const definition of capability.definitions) {
|
|
19
|
+
const base = `${pascalCase(capability.name)}V${definition.version}`;
|
|
20
|
+
if (definition.description)
|
|
21
|
+
lines.push(`/** ${definition.description} */`);
|
|
22
|
+
lines.push(`export type ${base}Input = ${jsonSchemaToTypeScript(definition.inputSchema)};`);
|
|
23
|
+
lines.push(`export type ${base}Output = ${jsonSchemaToTypeScript(definition.outputSchema)};`);
|
|
24
|
+
lines.push("");
|
|
25
|
+
}
|
|
26
|
+
const latest = `${pascalCase(capability.name)}V${capability.latestVersion}`;
|
|
27
|
+
lines.push(`export type ${pascalCase(capability.name)}Input = ${latest}Input;`);
|
|
28
|
+
lines.push(`export type ${pascalCase(capability.name)}Output = ${latest}Output;`);
|
|
29
|
+
lines.push("");
|
|
30
|
+
}
|
|
31
|
+
for (const event of manifest.events) {
|
|
32
|
+
if (event.description)
|
|
33
|
+
lines.push(`/** ${event.description} */`);
|
|
34
|
+
lines.push(`export type ${pascalCase(event.name)}Payload = ${jsonSchemaToTypeScript(event.payloadSchema)};`);
|
|
35
|
+
lines.push("");
|
|
36
|
+
}
|
|
37
|
+
lines.push(`/** The capability contract published by ${manifest.application.id}. */`);
|
|
38
|
+
lines.push(`export interface ${contractName} extends AppContract {`);
|
|
39
|
+
lines.push(" capabilities: {");
|
|
40
|
+
for (const capability of manifest.capabilities) {
|
|
41
|
+
const name = pascalCase(capability.name);
|
|
42
|
+
lines.push(` ${JSON.stringify(capability.name)}: { input: ${name}Input; output: ${name}Output; kind: ${JSON.stringify(capability.kind)}; version: ${capability.latestVersion} };`);
|
|
43
|
+
}
|
|
44
|
+
lines.push(" };");
|
|
45
|
+
lines.push(" events: {");
|
|
46
|
+
for (const event of manifest.events) {
|
|
47
|
+
lines.push(` ${JSON.stringify(event.name)}: ${pascalCase(event.name)}Payload;`);
|
|
48
|
+
}
|
|
49
|
+
lines.push(" };");
|
|
50
|
+
lines.push("}");
|
|
51
|
+
lines.push("");
|
|
52
|
+
lines.push("/** Capability versions this client sends by default (§42). */");
|
|
53
|
+
lines.push("export const capabilityVersions: Record<string, number> = {");
|
|
54
|
+
for (const capability of manifest.capabilities) {
|
|
55
|
+
lines.push(` ${JSON.stringify(capability.name)}: ${capability.latestVersion},`);
|
|
56
|
+
}
|
|
57
|
+
lines.push("};");
|
|
58
|
+
lines.push("");
|
|
59
|
+
const streams = manifest.capabilities.filter((entry) => entry.kind === "stream").map((entry) => entry.name);
|
|
60
|
+
lines.push("/** Capabilities that answer with a stream (§20). */");
|
|
61
|
+
lines.push(`export const streamCapabilities: string[] = ${JSON.stringify(streams)};`);
|
|
62
|
+
lines.push("");
|
|
63
|
+
if (embedManifest) {
|
|
64
|
+
lines.push("/** The manifest this client was generated from. */");
|
|
65
|
+
lines.push(`export const manifest = ${JSON.stringify(manifest, null, 2)} as const;`);
|
|
66
|
+
lines.push("");
|
|
67
|
+
}
|
|
68
|
+
lines.push(`/** Creates a typed client for ${manifest.application.name}. */`);
|
|
69
|
+
lines.push(`export function ${factoryName}(options: ClientOptions): AppPortClient<${contractName}> {`);
|
|
70
|
+
lines.push(` return createClient<${contractName}>({`);
|
|
71
|
+
lines.push(" versions: capabilityVersions,");
|
|
72
|
+
lines.push(" streamCapabilities,");
|
|
73
|
+
lines.push(" ...options");
|
|
74
|
+
lines.push(" });");
|
|
75
|
+
lines.push("}");
|
|
76
|
+
lines.push("");
|
|
77
|
+
return lines.join("\n");
|
|
78
|
+
}
|
|
79
|
+
/** Emits the manifest as a standalone JSON document. */
|
|
80
|
+
export function generateManifestJson(manifest) {
|
|
81
|
+
return `${JSON.stringify(manifest, null, 2)}\n`;
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAqB5E,MAAM,UAAU,cAAc,CAAC,QAAyB,EAAE,UAAiC,EAAE;IAC3F,MAAM,OAAO,GAAG,UAAU,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC;IACrF,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,IAAI,GAAG,OAAO,UAAU,CAAC;IAClE,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,IAA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protocol";
|
|
2
|
+
export type DesktopRuntime = "tauri" | "electron";
|
|
3
|
+
export type DesktopPlatform = "macos" | "windows" | "linux";
|
|
4
|
+
export type DesktopTransport = "ipc" | "http" | "websocket";
|
|
5
|
+
export interface DesktopRuntimeConfig {
|
|
6
|
+
runtime: DesktopRuntime;
|
|
7
|
+
applicationId: string;
|
|
8
|
+
name: string;
|
|
9
|
+
version: string;
|
|
10
|
+
entry: {
|
|
11
|
+
development?: string;
|
|
12
|
+
production: string;
|
|
13
|
+
};
|
|
14
|
+
platforms: DesktopPlatform[];
|
|
15
|
+
appport: {
|
|
16
|
+
transport: DesktopTransport;
|
|
17
|
+
};
|
|
18
|
+
host?: {
|
|
19
|
+
enabled: boolean;
|
|
20
|
+
transport: "http" | "websocket" | "both";
|
|
21
|
+
host: string;
|
|
22
|
+
port: number;
|
|
23
|
+
cors: {
|
|
24
|
+
origins: string[];
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
authorization?: {
|
|
28
|
+
web: {
|
|
29
|
+
allow: string[];
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export interface ProjectContext {
|
|
34
|
+
root: string;
|
|
35
|
+
manifest: AppPortManifest;
|
|
36
|
+
manifestPath: string;
|
|
37
|
+
packageManager?: "pnpm" | "npm" | "yarn" | "bun";
|
|
38
|
+
framework?: "vite" | "react" | "next";
|
|
39
|
+
developmentCommand?: string;
|
|
40
|
+
developmentUrl?: string;
|
|
41
|
+
buildCommand?: string;
|
|
42
|
+
applicationEntry?: string;
|
|
43
|
+
}
|
|
44
|
+
export interface DetectionResult {
|
|
45
|
+
detected: boolean;
|
|
46
|
+
reason?: string;
|
|
47
|
+
}
|
|
48
|
+
export interface GenerationResult {
|
|
49
|
+
files: string[];
|
|
50
|
+
unchanged: boolean;
|
|
51
|
+
}
|
|
52
|
+
export interface DesktopGenerator {
|
|
53
|
+
runtime: DesktopRuntime;
|
|
54
|
+
detect(project: ProjectContext): Promise<DetectionResult>;
|
|
55
|
+
generate(project: ProjectContext, config: DesktopRuntimeConfig, options?: {
|
|
56
|
+
force?: boolean;
|
|
57
|
+
}): Promise<GenerationResult>;
|
|
58
|
+
}
|
|
59
|
+
export declare const desktopGenerators: Record<DesktopRuntime, DesktopGenerator>;
|
|
60
|
+
//# sourceMappingURL=desktop.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"desktop.d.ts","sourceRoot":"","sources":["../src/desktop.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,UAAU,CAAC;AAClD,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,SAAS,GAAG,OAAO,CAAC;AAC5D,MAAM,MAAM,gBAAgB,GAAG,KAAK,GAAG,MAAM,GAAG,WAAW,CAAC;AAE5D,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,cAAc,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE;QAAE,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC;IACpD,SAAS,EAAE,eAAe,EAAE,CAAC;IAC7B,OAAO,EAAE;QAAE,SAAS,EAAE,gBAAgB,CAAA;KAAE,CAAC;IACzC,IAAI,CAAC,EAAE;QACL,OAAO,EAAE,OAAO,CAAC;QACjB,SAAS,EAAE,MAAM,GAAG,WAAW,GAAG,MAAM,CAAC;QACzC,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE;YAAE,OAAO,EAAE,MAAM,EAAE,CAAA;SAAE,CAAC;KAC7B,CAAC;IACF,aAAa,CAAC,EAAE;QAAE,GAAG,EAAE;YAAE,KAAK,EAAE,MAAM,EAAE,CAAA;SAAE,CAAA;KAAE,CAAC;CAC9C;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,eAAe,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,CAAC;IACjD,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;IACtC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,eAAe;IAAG,QAAQ,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE;AACvE,MAAM,WAAW,gBAAgB;IAAG,KAAK,EAAE,MAAM,EAAE,CAAC;IAAC,SAAS,EAAE,OAAO,CAAA;CAAE;AACzE,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,cAAc,CAAC;IACxB,MAAM,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAC1D,QAAQ,CAAC,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,oBAAoB,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;CAC3H;AAuFD,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,cAAc,EAAE,gBAAgB,CAA0E,CAAC"}
|
package/dist/desktop.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { access, mkdir, readFile, writeFile } from "node:fs/promises";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
const marker = ".appport-generated.json";
|
|
5
|
+
const hash = (value) => createHash("sha256").update(value).digest("hex");
|
|
6
|
+
const json = (value) => `${JSON.stringify(value, null, 2)}\n`;
|
|
7
|
+
function commonFiles(config, manifestPath, applicationEntry = "./appport/server.ts") {
|
|
8
|
+
const transport = config.runtime === "tauri"
|
|
9
|
+
? `import { invoke } from "@tauri-apps/api/core";\nimport { listen } from "@tauri-apps/api/event";\nimport { createTauriTransport } from "@appport/sdk";\n\nconst transport = createTauriTransport({ invoke, listen });`
|
|
10
|
+
: `import { createElectronTransport } from "@appport/sdk";\n\nconst transport = createElectronTransport();`;
|
|
11
|
+
return {
|
|
12
|
+
"appport.desktop.json": json(config),
|
|
13
|
+
"desktop/src/appport.ts": `// Generated transport edge. Application capability code imports the same client module.\nimport { createClient } from "@appport/sdk";\n${transport}\n\nexport const app = createClient({ transport });\nawait app.connect();\nawait app.load();\n`,
|
|
14
|
+
"desktop/appport.manifest.json": json({
|
|
15
|
+
source: manifestPath,
|
|
16
|
+
protocol: "appport/1",
|
|
17
|
+
application: config.applicationId,
|
|
18
|
+
runtime: config.runtime,
|
|
19
|
+
transport: config.appport.transport
|
|
20
|
+
}),
|
|
21
|
+
"desktop/host.mjs": `import { serveDesktopHost } from "@appport/server/node";\nimport server from ${JSON.stringify(`../${applicationEntry.replace(/^\.\//, "")}`)};\nimport config from "../appport.desktop.json" with { type: "json" };\n\nif (!config.host?.enabled) throw new Error("Desktop host mode is not enabled");\nexport const host = await serveDesktopHost({\n server,\n host: config.host.host ?? "127.0.0.1",\n port: config.host.port ?? 0,\n transport: config.host.transport ?? "both",\n allowedOrigins: config.host.cors?.origins ?? ["http://localhost:*", "http://127.0.0.1:*"],\n allowedCapabilities: config.authorization?.web?.allow ?? []\n});\nconsole.log(\`AppPort desktop host listening at \${host.url}\`);\n`
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function electronFiles(config) {
|
|
25
|
+
const dev = JSON.stringify(config.entry.development ?? "");
|
|
26
|
+
return {
|
|
27
|
+
"desktop/electron/main.mjs": `import { app, BrowserWindow, ipcMain } from "electron";\nimport { fileURLToPath } from "node:url";\nimport { serveElectronIpc } from "@appport/transport-electron";\nimport server from "../../appport/server.ts";\n\nconst developmentUrl = ${dev};\nserveElectronIpc({\n server, ipcMain,\n validateSender(event) {\n const url = event.senderFrame?.url ?? "";\n return url.startsWith("file://") || (developmentUrl.length > 0 && new URL(url).origin === new URL(developmentUrl).origin);\n },\n identify: () => ({ session: { id: "ses_desktop", applicationId: server.application.descriptor.id, createdAt: new Date().toISOString(), principal: { id: "local-user", type: "user" }, permissions: ${JSON.stringify(["documents.read", "documents.write", "build.execute"])} } })\n});\nserver.application.advertiseTransport({ kind: "ipc", channel: "appport:message" });\n\napp.whenReady().then(async () => {\n const window = new BrowserWindow({ webPreferences: { preload: fileURLToPath(new URL("./preload.cjs", import.meta.url)), contextIsolation: true, nodeIntegration: false, sandbox: true } });\n if (!app.isPackaged && developmentUrl) await window.loadURL(developmentUrl);\n else await window.loadFile(fileURLToPath(new URL(${JSON.stringify(`../${config.entry.production}/index.html`)}, import.meta.url)));\n});\n`,
|
|
28
|
+
"desktop/electron/preload.cjs": `const { contextBridge, ipcRenderer } = require("electron");\nconst CHANNEL = "appport:message";\ncontextBridge.exposeInMainWorld("appport", Object.freeze({\n send: (envelope) => ipcRenderer.send(CHANNEL, envelope),\n receive(listener) {\n const handler = (_event, envelope) => listener(envelope);\n ipcRenderer.on(CHANNEL, handler);\n return () => ipcRenderer.removeListener(CHANNEL, handler);\n }\n}));\n`,
|
|
29
|
+
"desktop/electron/package.json": json({ private: true, main: "main.mjs", scripts: { dev: "electron .", build: "electron-builder" }, devDependencies: { electron: "^35.0.0", "electron-builder": "^26.0.0" }, build: { appId: config.applicationId, productName: config.name, files: ["**/*"] } })
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function tauriFiles(config) {
|
|
33
|
+
return {
|
|
34
|
+
"desktop/src/main.ts": `import "./appport.js";\n`,
|
|
35
|
+
"desktop/src-tauri/Cargo.toml": `[package]\nname = "appport_desktop"\nversion = ${JSON.stringify(config.version)}\nedition = "2021"\n\n[lib]\ncrate-type = ["staticlib", "cdylib", "rlib"]\n\n[dependencies]\ntauri = { version = "2", features = [] }\nserde_json = "1"\n`,
|
|
36
|
+
"desktop/src-tauri/tauri.conf.json": json({ $schema: "https://schema.tauri.app/config/2", productName: config.name, version: config.version, identifier: config.applicationId, build: { devUrl: config.entry.development, frontendDist: `../${config.entry.production}` }, app: { security: { csp: "default-src 'self'; connect-src ipc: http://ipc.localhost" }, windows: [{ title: config.name, width: 1024, height: 720 }] } }),
|
|
37
|
+
"desktop/src-tauri/capabilities/default.json": json({ identifier: "appport-default", description: "Only the generated AppPort window; no shell or filesystem permissions.", windows: ["main"], permissions: ["core:default"] }),
|
|
38
|
+
"desktop/src-tauri/src/lib.rs": `use serde_json::Value;\n\n// A single canonical envelope boundary. Dispatch must validate and authorize through AppPort.\n#[tauri::command]\nasync fn appport_request(envelope: Value) -> Result<Value, String> {\n crate::runtime::dispatch(envelope).await.map_err(|_| "AppPort request failed".into())\n}\n\nmod runtime;\n#[cfg_attr(mobile, tauri::mobile_entry_point)]\npub fn run() { tauri::Builder::default().invoke_handler(tauri::generate_handler![appport_request]).run(tauri::generate_context!()).expect("tauri runtime"); }\n`,
|
|
39
|
+
"desktop/src-tauri/src/runtime.rs": `use serde_json::Value;\n\n// Bind this narrow adapter to the application's existing AppPort server.\npub async fn dispatch(_envelope: Value) -> Result<Value, ()> { Err(()) }\n`,
|
|
40
|
+
"desktop/tauri/src-tauri/src/appport.rs": `// Compatibility entry for projects created by AppPort 1.0.\n// The production command is registered in desktop/src-tauri/src/lib.rs.\npub const COMMAND: &str = "appport_request";\n`
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
async function exists(path) { try {
|
|
44
|
+
await access(path);
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return false;
|
|
49
|
+
} }
|
|
50
|
+
class Generator {
|
|
51
|
+
runtime;
|
|
52
|
+
constructor(runtime) {
|
|
53
|
+
this.runtime = runtime;
|
|
54
|
+
}
|
|
55
|
+
async detect(project) {
|
|
56
|
+
return project.manifest.protocol === "appport/1" && project.manifest.application?.id
|
|
57
|
+
? { detected: true }
|
|
58
|
+
: { detected: false, reason: "The manifest must use appport/1 and declare an application identity." };
|
|
59
|
+
}
|
|
60
|
+
async generate(project, config, options = {}) {
|
|
61
|
+
const generated = { ...commonFiles(config, project.manifestPath, project.applicationEntry), ...(this.runtime === "electron" ? electronFiles(config) : tauriFiles(config)) };
|
|
62
|
+
const files = Object.fromEntries(Object.entries(generated).map(([name, contents]) => [name, contents
|
|
63
|
+
.replaceAll("@appport/server/node", "@appport/sdk/node")
|
|
64
|
+
.replaceAll("@appport/transport-electron", "@appport/sdk")
|
|
65
|
+
.replaceAll("@appport/transport-tauri", "@appport/sdk")
|
|
66
|
+
.replaceAll("@appport/client", "@appport/sdk")
|
|
67
|
+
]));
|
|
68
|
+
const markerPath = join(project.root, "desktop", marker);
|
|
69
|
+
let old = {};
|
|
70
|
+
if (await exists(markerPath))
|
|
71
|
+
old = JSON.parse(await readFile(markerPath, "utf8"));
|
|
72
|
+
for (const [name, expected] of Object.entries(old)) {
|
|
73
|
+
const path = join(project.root, name);
|
|
74
|
+
if (await exists(path)) {
|
|
75
|
+
const actual = await readFile(path, "utf8");
|
|
76
|
+
if (hash(actual) !== expected && !options.force)
|
|
77
|
+
throw new Error(`Generated file has been modified: ${name}. Use --force to replace generated files.`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const names = Object.keys(files);
|
|
81
|
+
const allSame = await Promise.all(Object.entries(files).map(async ([name, value]) => (await exists(join(project.root, name))) && hash(await readFile(join(project.root, name), "utf8")) === hash(value)));
|
|
82
|
+
if (allSame.every(Boolean))
|
|
83
|
+
return { files: names, unchanged: true };
|
|
84
|
+
for (const [name, value] of Object.entries(files)) {
|
|
85
|
+
const path = join(project.root, name);
|
|
86
|
+
if ((await exists(path)) && !old[name] && !options.force)
|
|
87
|
+
throw new Error(`Refusing to overwrite developer-owned file: ${name}. Use --force to replace it explicitly.`);
|
|
88
|
+
await mkdir(dirname(path), { recursive: true });
|
|
89
|
+
await writeFile(path, value, "utf8");
|
|
90
|
+
}
|
|
91
|
+
await mkdir(dirname(markerPath), { recursive: true });
|
|
92
|
+
await writeFile(markerPath, json(Object.fromEntries(Object.entries(files).map(([name, value]) => [name, hash(value)]))), "utf8");
|
|
93
|
+
return { files: names, unchanged: false };
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
export const desktopGenerators = { tauri: new Generator("tauri"), electron: new Generator("electron") };
|
|
97
|
+
//# sourceMappingURL=desktop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"desktop.js","sourceRoot":"","sources":["../src/desktop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AA6C1C,MAAM,MAAM,GAAG,yBAAyB,CAAC;AACzC,MAAM,IAAI,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACjF,MAAM,IAAI,GAAG,CAAC,KAAc,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC;AAEvE,SAAS,WAAW,CAAC,MAA4B,EAAE,YAAoB,EAAE,gBAAgB,GAAG,qBAAqB;IAC/G,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,KAAK,OAAO;QAC1C,CAAC,CAAC,sNAAsN;QACxN,CAAC,CAAC,yGAAyG,CAAC;IAC9G,O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,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { JSONSchema } from "@appport/protocol";
|
|
2
|
+
/**
|
|
3
|
+
* Renders a JSON Schema as a TypeScript type expression.
|
|
4
|
+
*
|
|
5
|
+
* The manifest is the source of truth (§32, §33), so generated clients are
|
|
6
|
+
* derived from the published schema rather than from the server's TypeScript.
|
|
7
|
+
* That is what lets a third-party implementation generate the same client.
|
|
8
|
+
*/
|
|
9
|
+
export declare function jsonSchemaToTypeScript(schema: JSONSchema, root?: JSONSchema, indent?: number): string;
|
|
10
|
+
/** `documents.save` → `DocumentsSave`. */
|
|
11
|
+
export declare function pascalCase(name: string): string;
|
|
12
|
+
/** `documents.save` → `documentsSave`. */
|
|
13
|
+
export declare function camelCase(name: string): string;
|
|
14
|
+
//# sourceMappingURL=json-schema-to-ts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-schema-to-ts.d.ts","sourceRoot":"","sources":["../src/json-schema-to-ts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,GAAE,UAAmB,EAAE,MAAM,SAAI,GAAG,MAAM,CAkCxG;AAmDD,0CAA0C;AAC1C,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAM/C;AAED,0CAA0C;AAC1C,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAG9C"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Renders a JSON Schema as a TypeScript type expression.
|
|
3
|
+
*
|
|
4
|
+
* The manifest is the source of truth (§32, §33), so generated clients are
|
|
5
|
+
* derived from the published schema rather than from the server's TypeScript.
|
|
6
|
+
* That is what lets a third-party implementation generate the same client.
|
|
7
|
+
*/
|
|
8
|
+
export function jsonSchemaToTypeScript(schema, root = schema, indent = 0) {
|
|
9
|
+
const resolved = resolveRef(schema, root);
|
|
10
|
+
if (resolved.const !== undefined)
|
|
11
|
+
return JSON.stringify(resolved.const);
|
|
12
|
+
if (resolved.enum)
|
|
13
|
+
return resolved.enum.map((value) => JSON.stringify(value)).join(" | ");
|
|
14
|
+
if (resolved.anyOf)
|
|
15
|
+
return unionOf(resolved.anyOf, root, indent);
|
|
16
|
+
if (resolved.oneOf)
|
|
17
|
+
return unionOf(resolved.oneOf, root, indent);
|
|
18
|
+
if (resolved.allOf) {
|
|
19
|
+
return resolved.allOf.map((member) => jsonSchemaToTypeScript(member, root, indent)).join(" & ");
|
|
20
|
+
}
|
|
21
|
+
const types = resolved.type === undefined ? [] : Array.isArray(resolved.type) ? resolved.type : [resolved.type];
|
|
22
|
+
if (types.length === 0)
|
|
23
|
+
return "unknown";
|
|
24
|
+
if (types.length > 1) {
|
|
25
|
+
return types.map((type) => jsonSchemaToTypeScript({ ...resolved, type }, root, indent)).join(" | ");
|
|
26
|
+
}
|
|
27
|
+
switch (types[0]) {
|
|
28
|
+
case "string":
|
|
29
|
+
return "string";
|
|
30
|
+
case "number":
|
|
31
|
+
case "integer":
|
|
32
|
+
return "number";
|
|
33
|
+
case "boolean":
|
|
34
|
+
return "boolean";
|
|
35
|
+
case "null":
|
|
36
|
+
return "null";
|
|
37
|
+
case "array":
|
|
38
|
+
return `Array<${resolved.items ? jsonSchemaToTypeScript(resolved.items, root, indent) : "unknown"}>`;
|
|
39
|
+
case "object":
|
|
40
|
+
return objectType(resolved, root, indent);
|
|
41
|
+
default:
|
|
42
|
+
return "unknown";
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function unionOf(members, root, indent) {
|
|
46
|
+
const rendered = members.map((member) => jsonSchemaToTypeScript(member, root, indent));
|
|
47
|
+
return [...new Set(rendered)].join(" | ");
|
|
48
|
+
}
|
|
49
|
+
function objectType(schema, root, indent) {
|
|
50
|
+
const properties = schema.properties ?? {};
|
|
51
|
+
const keys = Object.keys(properties);
|
|
52
|
+
if (keys.length === 0) {
|
|
53
|
+
if (typeof schema.additionalProperties === "object") {
|
|
54
|
+
return `Record<string, ${jsonSchemaToTypeScript(schema.additionalProperties, root, indent)}>`;
|
|
55
|
+
}
|
|
56
|
+
return schema.additionalProperties === false ? "Record<string, never>" : "Record<string, unknown>";
|
|
57
|
+
}
|
|
58
|
+
const required = new Set(schema.required ?? []);
|
|
59
|
+
const pad = " ".repeat(indent + 1);
|
|
60
|
+
const closePad = " ".repeat(indent);
|
|
61
|
+
const lines = keys.map((key) => {
|
|
62
|
+
const property = properties[key];
|
|
63
|
+
const optional = required.has(key) ? "" : "?";
|
|
64
|
+
const doc = property.description ? `${pad}/** ${property.description} */\n` : "";
|
|
65
|
+
return `${doc}${pad}${propertyKey(key)}${optional}: ${jsonSchemaToTypeScript(property, root, indent + 1)};`;
|
|
66
|
+
});
|
|
67
|
+
if (typeof schema.additionalProperties === "object") {
|
|
68
|
+
lines.push(`${pad}[key: string]: ${jsonSchemaToTypeScript(schema.additionalProperties, root, indent + 1)};`);
|
|
69
|
+
}
|
|
70
|
+
return `{\n${lines.join("\n")}\n${closePad}}`;
|
|
71
|
+
}
|
|
72
|
+
const IDENTIFIER = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
|
|
73
|
+
function propertyKey(key) {
|
|
74
|
+
return IDENTIFIER.test(key) ? key : JSON.stringify(key);
|
|
75
|
+
}
|
|
76
|
+
function resolveRef(schema, root) {
|
|
77
|
+
let current = schema;
|
|
78
|
+
let guard = 0;
|
|
79
|
+
while (current.$ref && guard < 16) {
|
|
80
|
+
guard += 1;
|
|
81
|
+
if (!current.$ref.startsWith("#/$defs/"))
|
|
82
|
+
break;
|
|
83
|
+
const target = root.$defs?.[current.$ref.slice("#/$defs/".length)];
|
|
84
|
+
if (!target)
|
|
85
|
+
break;
|
|
86
|
+
current = target;
|
|
87
|
+
}
|
|
88
|
+
return current;
|
|
89
|
+
}
|
|
90
|
+
/** `documents.save` → `DocumentsSave`. */
|
|
91
|
+
export function pascalCase(name) {
|
|
92
|
+
return name
|
|
93
|
+
.split(/[.\-_]/)
|
|
94
|
+
.filter(Boolean)
|
|
95
|
+
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
|
|
96
|
+
.join("");
|
|
97
|
+
}
|
|
98
|
+
/** `documents.save` → `documentsSave`. */
|
|
99
|
+
export function camelCase(name) {
|
|
100
|
+
const pascal = pascalCase(name);
|
|
101
|
+
return pascal.charAt(0).toLowerCase() + pascal.slice(1);
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=json-schema-to-ts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-schema-to-ts.js","sourceRoot":"","sources":["../src/json-schema-to-ts.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAAkB,EAAE,OAAmB,MAAM,EAAE,MAAM,GAAG,CAAC;IAC9F,MAAM,QAAQ,GAAG,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAE1C,IAAI,QAAQ,CAAC,KAAK,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACxE,IAAI,QAAQ,CAAC,IAAI;QAAE,OAAO,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC1F,IAAI,QAAQ,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AAC;AAED,SAAS,UAAU,CAAC,MAAkB,EAAE,IAAgB;IACtD,IAAI,OAAO,GAAG,MAAM,CAAC;IACrB,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,OAAO,OAAO,CAAC,IAAI,IAAI,KAAK,GAAG,EAAE,EAAE,CAAC;QAClC,KAAK,IAAI,CAAC,CAAC;QACX,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC;YAAE,MAAM;QAChD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;QACnE,IAAI,CAAC,MAAM;YAAE,MAAM;QACnB,OAAO,GAAG,MAAM,CAAC;IACnB,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,0CAA0C;AAC1C,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,OAAO,IAAI;SACR,KAAK,CAAC,QAAQ,CAAC;SACf,MAAM,CAAC,OAAO,CAAC;SACf,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;SAC3D,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,CAAC;AAED,0CAA0C;AAC1C,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,MAAM,MAAM,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;IAChC,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAC1D,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@appport/generators",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Manifest-driven client and type generation for AppPort.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"repository": { "type": "git", "url": "git+https://github.com/rkendel1/appport.git", "directory": "packages/generators" },
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"README.md"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsc -b",
|
|
22
|
+
"clean": "tsc -b --clean"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@appport/protocol": "1.0.0",
|
|
26
|
+
"@appport/schema": "1.0.0"
|
|
27
|
+
},
|
|
28
|
+
"publishConfig": { "access": "public" }
|
|
29
|
+
}
|