create-disposabl-app 0.3.1 → 0.3.3
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/index.js +36 -8
- package/dist/templates/default/.github/README.md +99 -57
- package/dist/templates/default/.github/actionlint.yaml +6 -0
- package/dist/templates/default/.github/workflows/pipeline.yml.example +492 -0
- package/dist/templates/default/apps/desktop/README.md +44 -14
- package/dist/templates/default/apps/desktop/build-ci.mjs +56 -0
- package/dist/templates/default/apps/desktop/forge.config.mts +36 -17
- package/dist/templates/default/apps/desktop/package.json +5 -5
- package/dist/templates/default/apps/mobile/README.md +127 -0
- package/dist/templates/default/apps/mobile/app.config.js +78 -0
- package/dist/templates/default/apps/mobile/assets/expo.icon/icon.json +21 -26
- package/dist/templates/default/apps/mobile/eas.json +22 -0
- package/dist/templates/default/apps/mobile/eslint.config.js +3 -3
- package/dist/templates/default/apps/mobile/package.json +5 -3
- package/dist/templates/default/apps/mobile/plugins/with-android-signing.js +29 -0
- package/dist/templates/default/apps/mobile/scripts/android-config.test.mjs +128 -0
- package/dist/templates/default/apps/mobile/tsconfig.json +3 -12
- package/dist/templates/default/apps/web/src/index.css +124 -73
- package/dist/templates/default/apps/web/src/routeTree.gen.ts +0 -9
- package/dist/templates/default/bun.lock +121 -11
- package/dist/templates/default/bunfig.toml +8 -1
- package/dist/templates/default/disposabl.json +9 -4
- package/dist/templates/default/gitignore +2 -0
- package/dist/templates/default/package.json +1 -0
- package/dist/templates/default/packages/backend/convex/todos/internal.ts +3 -3
- package/dist/templates/default/packages/backend/generate.ts +114 -0
- package/dist/templates/default/packages/backend/generated/openapi.json +190 -0
- package/dist/templates/default/packages/backend/generated/platforms.ts +3 -0
- package/dist/templates/default/packages/backend/package.json +4 -3
- package/dist/templates/default/packages/disposabl-kit/client/styles/globals.css +43 -43
- package/dist/templates/default/packages/disposabl-kit/eslint.config.js +2 -2
- package/dist/templates/default/packages/disposabl-kit/package.json +2 -1
- package/dist/templates/default/packages/disposabl-kit/platforms.ts +87 -0
- package/dist/templates/default/packages/disposabl-kit/server/http.ts +37 -7
- package/dist/templates/default/packages/disposabl-kit/server/lib/functions.ts +1 -10
- package/dist/templates/default/packages/disposabl-kit/server/lib/platform-spec.ts +226 -0
- package/dist/templates/default/turbo.json +25 -5
- package/package.json +1 -1
- package/dist/templates/default/.github/workflows/pipeline.yml +0 -141
- package/dist/templates/default/packages/disposabl-kit/server/dev-setup.mjs +0 -39
- package/dist/templates/default/packages/disposabl-kit/server/lib/mcp-tools.ts +0 -47
- package/dist/templates/default/packages/disposabl-kit/server/lib/platforms.ts +0 -20
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { watch } from "node:fs";
|
|
2
|
+
import { readdir, readFile, mkdir, writeFile } from "node:fs/promises";
|
|
3
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { spawnSync } from "node:child_process";
|
|
6
|
+
import {
|
|
7
|
+
createOpenApi,
|
|
8
|
+
createPlatforms,
|
|
9
|
+
} from "../disposabl-kit/server/lib/platform-spec";
|
|
10
|
+
|
|
11
|
+
const root = fileURLToPath(new URL(".", import.meta.url));
|
|
12
|
+
const convex = join(root, "convex");
|
|
13
|
+
const output = join(root, "generated");
|
|
14
|
+
const canonical = (value: unknown): string =>
|
|
15
|
+
JSON.stringify(value, (_, item) =>
|
|
16
|
+
item && typeof item === "object" && !Array.isArray(item)
|
|
17
|
+
? Object.fromEntries(
|
|
18
|
+
Object.entries(item).sort(([a], [b]) => a.localeCompare(b)),
|
|
19
|
+
)
|
|
20
|
+
: item,
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
async function writeChanged(path: string, text: string) {
|
|
24
|
+
if ((await readFile(path, "utf8").catch(() => "")) !== text)
|
|
25
|
+
await writeFile(path, text);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Discover opt-in modules, validate the contract, then update both transports together. */
|
|
29
|
+
export async function generate(acceptBreaking = false) {
|
|
30
|
+
const files = await readdir(convex, { recursive: true });
|
|
31
|
+
const modules: Record<string, Record<string, unknown>> = {};
|
|
32
|
+
for (const file of files.sort()) {
|
|
33
|
+
if (
|
|
34
|
+
file.startsWith("_generated/") ||
|
|
35
|
+
!file.endsWith(".ts") ||
|
|
36
|
+
file.endsWith(".d.ts")
|
|
37
|
+
)
|
|
38
|
+
continue;
|
|
39
|
+
const source = await readFile(join(convex, file), "utf8");
|
|
40
|
+
if (!/\bplatforms\s*:\s*true\b/.test(source)) continue;
|
|
41
|
+
if (/^[\s;]*["']use node["']/.test(source))
|
|
42
|
+
throw new Error(
|
|
43
|
+
`${file}: platform validators must be in a default-runtime module; delegate Node work through an internal action.`,
|
|
44
|
+
);
|
|
45
|
+
modules[file.slice(0, -3)] = await import(
|
|
46
|
+
pathToFileURL(join(convex, file)).href
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
const next = createOpenApi(createPlatforms(modules).spec);
|
|
50
|
+
const previous = await readFile(join(output, "openapi.json"), "utf8")
|
|
51
|
+
.then(JSON.parse)
|
|
52
|
+
.catch((error) => {
|
|
53
|
+
if (error.code !== "ENOENT") throw error;
|
|
54
|
+
return null;
|
|
55
|
+
});
|
|
56
|
+
const changes = previous
|
|
57
|
+
? Object.keys(previous.paths).filter(
|
|
58
|
+
(path) =>
|
|
59
|
+
canonical(previous.paths[path]) !== canonical(next.paths[path]),
|
|
60
|
+
)
|
|
61
|
+
: [];
|
|
62
|
+
if (changes.length && !acceptBreaking)
|
|
63
|
+
throw new Error(
|
|
64
|
+
`Contract changed or removed: ${changes.join(", ")}. Review the changes, then run bun run generate --accept-breaking to accept a major version.`,
|
|
65
|
+
);
|
|
66
|
+
if (previous) {
|
|
67
|
+
const [major, minor, patch] = previous.info.version.split(".").map(Number);
|
|
68
|
+
next.info.version = changes.length
|
|
69
|
+
? `${major + 1}.0.0`
|
|
70
|
+
: canonical(previous.paths) !== canonical(next.paths)
|
|
71
|
+
? `${major}.${minor + 1}.0`
|
|
72
|
+
: `${major}.${minor}.${patch}`;
|
|
73
|
+
}
|
|
74
|
+
const paths = Object.keys(modules);
|
|
75
|
+
const registry =
|
|
76
|
+
"// Generated by bun run generate. Do not edit.\n" +
|
|
77
|
+
paths
|
|
78
|
+
.map(
|
|
79
|
+
(path, index) =>
|
|
80
|
+
`import * as m${index} from ${JSON.stringify(`../convex/${path}`)};`,
|
|
81
|
+
)
|
|
82
|
+
.join("\n") +
|
|
83
|
+
`\nexport default {${paths.map((path, index) => `${JSON.stringify(path)}: m${index}`).join(",")}};\n`;
|
|
84
|
+
await mkdir(output, { recursive: true });
|
|
85
|
+
await writeChanged(
|
|
86
|
+
join(output, "openapi.json"),
|
|
87
|
+
JSON.stringify(next, null, 2) + "\n",
|
|
88
|
+
);
|
|
89
|
+
await writeChanged(join(output, "platforms.ts"), registry);
|
|
90
|
+
const formatted = spawnSync(process.execPath, ["fmt", output], {
|
|
91
|
+
stdio: "pipe",
|
|
92
|
+
});
|
|
93
|
+
if (formatted.status !== 0)
|
|
94
|
+
throw new Error("Could not format generated contract");
|
|
95
|
+
console.log(
|
|
96
|
+
`Generated ${Object.keys(next.paths).length} operations, contract ${next.info.version}.`,
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (import.meta.main) {
|
|
101
|
+
if (process.argv.includes("--watch")) {
|
|
102
|
+
const run = () =>
|
|
103
|
+
spawnSync(process.execPath, [fileURLToPath(import.meta.url)], {
|
|
104
|
+
stdio: "inherit",
|
|
105
|
+
});
|
|
106
|
+
run();
|
|
107
|
+
let timer: ReturnType<typeof setTimeout>;
|
|
108
|
+
watch(convex, { recursive: true }, (_, file) => {
|
|
109
|
+
if (!file?.endsWith(".ts")) return;
|
|
110
|
+
clearTimeout(timer);
|
|
111
|
+
timer = setTimeout(run, 200);
|
|
112
|
+
});
|
|
113
|
+
} else await generate(process.argv.includes("--accept-breaking"));
|
|
114
|
+
}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
{
|
|
2
|
+
"openapi": "3.1.0",
|
|
3
|
+
"info": {
|
|
4
|
+
"title": "Application API",
|
|
5
|
+
"version": "0.1.0"
|
|
6
|
+
},
|
|
7
|
+
"security": [
|
|
8
|
+
{
|
|
9
|
+
"bearerAuth": []
|
|
10
|
+
}
|
|
11
|
+
],
|
|
12
|
+
"components": {
|
|
13
|
+
"securitySchemes": {
|
|
14
|
+
"bearerAuth": {
|
|
15
|
+
"type": "http",
|
|
16
|
+
"scheme": "bearer"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"paths": {
|
|
21
|
+
"/api/todos/create": {
|
|
22
|
+
"post": {
|
|
23
|
+
"operationId": "todosCreate",
|
|
24
|
+
"x-convex-function": "todos/internal:create",
|
|
25
|
+
"requestBody": {
|
|
26
|
+
"required": true,
|
|
27
|
+
"content": {
|
|
28
|
+
"application/json": {
|
|
29
|
+
"schema": {
|
|
30
|
+
"type": "object",
|
|
31
|
+
"properties": {
|
|
32
|
+
"title": {
|
|
33
|
+
"type": "string"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"required": ["title"],
|
|
37
|
+
"additionalProperties": false
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"responses": {
|
|
43
|
+
"200": {
|
|
44
|
+
"description": "Success",
|
|
45
|
+
"content": {
|
|
46
|
+
"application/json": {
|
|
47
|
+
"schema": {
|
|
48
|
+
"type": "string",
|
|
49
|
+
"description": "ID of a document in \"todos\""
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"400": {
|
|
55
|
+
"description": "Invalid arguments"
|
|
56
|
+
},
|
|
57
|
+
"401": {
|
|
58
|
+
"description": "Authentication required"
|
|
59
|
+
},
|
|
60
|
+
"403": {
|
|
61
|
+
"description": "Insufficient scope"
|
|
62
|
+
},
|
|
63
|
+
"500": {
|
|
64
|
+
"description": "Internal error"
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
"/api/todos/get": {
|
|
70
|
+
"get": {
|
|
71
|
+
"operationId": "todosGet",
|
|
72
|
+
"x-convex-function": "todos/internal:get",
|
|
73
|
+
"parameters": [
|
|
74
|
+
{
|
|
75
|
+
"name": "id",
|
|
76
|
+
"in": "query",
|
|
77
|
+
"required": true,
|
|
78
|
+
"content": {
|
|
79
|
+
"application/json": {
|
|
80
|
+
"schema": {
|
|
81
|
+
"type": "string",
|
|
82
|
+
"description": "ID of a document in \"todos\""
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
],
|
|
88
|
+
"responses": {
|
|
89
|
+
"200": {
|
|
90
|
+
"description": "Success",
|
|
91
|
+
"content": {
|
|
92
|
+
"application/json": {
|
|
93
|
+
"schema": {
|
|
94
|
+
"anyOf": [
|
|
95
|
+
{
|
|
96
|
+
"type": "object",
|
|
97
|
+
"properties": {
|
|
98
|
+
"userId": {
|
|
99
|
+
"type": "string"
|
|
100
|
+
},
|
|
101
|
+
"title": {
|
|
102
|
+
"type": "string"
|
|
103
|
+
},
|
|
104
|
+
"_id": {
|
|
105
|
+
"type": "string",
|
|
106
|
+
"description": "ID of a document in \"todos\""
|
|
107
|
+
},
|
|
108
|
+
"_creationTime": {
|
|
109
|
+
"type": "number"
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
"required": ["userId", "title", "_id", "_creationTime"],
|
|
113
|
+
"additionalProperties": false
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"type": "null"
|
|
117
|
+
}
|
|
118
|
+
]
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
"400": {
|
|
124
|
+
"description": "Invalid arguments"
|
|
125
|
+
},
|
|
126
|
+
"401": {
|
|
127
|
+
"description": "Authentication required"
|
|
128
|
+
},
|
|
129
|
+
"403": {
|
|
130
|
+
"description": "Insufficient scope"
|
|
131
|
+
},
|
|
132
|
+
"500": {
|
|
133
|
+
"description": "Internal error"
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
"/api/todos/list": {
|
|
139
|
+
"get": {
|
|
140
|
+
"operationId": "todosList",
|
|
141
|
+
"x-convex-function": "todos/internal:list",
|
|
142
|
+
"parameters": [],
|
|
143
|
+
"responses": {
|
|
144
|
+
"200": {
|
|
145
|
+
"description": "Success",
|
|
146
|
+
"content": {
|
|
147
|
+
"application/json": {
|
|
148
|
+
"schema": {
|
|
149
|
+
"type": "array",
|
|
150
|
+
"items": {
|
|
151
|
+
"type": "object",
|
|
152
|
+
"properties": {
|
|
153
|
+
"userId": {
|
|
154
|
+
"type": "string"
|
|
155
|
+
},
|
|
156
|
+
"title": {
|
|
157
|
+
"type": "string"
|
|
158
|
+
},
|
|
159
|
+
"_id": {
|
|
160
|
+
"type": "string",
|
|
161
|
+
"description": "ID of a document in \"todos\""
|
|
162
|
+
},
|
|
163
|
+
"_creationTime": {
|
|
164
|
+
"type": "number"
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
"required": ["userId", "title", "_id", "_creationTime"],
|
|
168
|
+
"additionalProperties": false
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
"400": {
|
|
175
|
+
"description": "Invalid arguments"
|
|
176
|
+
},
|
|
177
|
+
"401": {
|
|
178
|
+
"description": "Authentication required"
|
|
179
|
+
},
|
|
180
|
+
"403": {
|
|
181
|
+
"description": "Insufficient scope"
|
|
182
|
+
},
|
|
183
|
+
"500": {
|
|
184
|
+
"description": "Internal error"
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
@@ -3,15 +3,16 @@
|
|
|
3
3
|
"private": true,
|
|
4
4
|
"version": "0.0.0",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"
|
|
6
|
+
"generate": "bun generate.ts",
|
|
7
|
+
"generate:watch": "bun generate.ts --watch",
|
|
8
|
+
"predev": "bun run generate && bun x --no-install --package @convex-dev/auth auth --keys-only",
|
|
7
9
|
"dev": "convex dev",
|
|
8
10
|
"logs": "convex logs",
|
|
9
11
|
"typecheck": "tsc -p convex",
|
|
10
|
-
"lint": "
|
|
12
|
+
"lint": "eslint . --report-unused-disable-directives --max-warnings 0",
|
|
11
13
|
"format": "prettier --write 'convex/**/*.ts'"
|
|
12
14
|
},
|
|
13
15
|
"dependencies": {
|
|
14
|
-
"@boatdev/convex": "^0.1.0",
|
|
15
16
|
"@convex-dev/auth": "catalog:",
|
|
16
17
|
"@convex-dev/mcp": "catalog:",
|
|
17
18
|
"@convex-dev/static-hosting": "catalog:",
|
|
@@ -8,53 +8,53 @@
|
|
|
8
8
|
@source "../**/*.{ts,tsx}";
|
|
9
9
|
|
|
10
10
|
@theme inline {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
11
|
+
--font-heading: var(--font-sans);
|
|
12
|
+
--color-sidebar-ring: var(--sidebar-ring);
|
|
13
|
+
--color-sidebar-border: var(--sidebar-border);
|
|
14
|
+
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
|
|
15
|
+
--color-sidebar-accent: var(--sidebar-accent);
|
|
16
|
+
--color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
|
|
17
|
+
--color-sidebar-primary: var(--sidebar-primary);
|
|
18
|
+
--color-sidebar-foreground: var(--sidebar-foreground);
|
|
19
|
+
--color-sidebar: var(--sidebar);
|
|
20
|
+
--color-chart-5: var(--chart-5);
|
|
21
|
+
--color-chart-4: var(--chart-4);
|
|
22
|
+
--color-chart-3: var(--chart-3);
|
|
23
|
+
--color-chart-2: var(--chart-2);
|
|
24
|
+
--color-chart-1: var(--chart-1);
|
|
25
|
+
--color-ring: var(--ring);
|
|
26
|
+
--color-input: var(--input);
|
|
27
|
+
--color-border: var(--border);
|
|
28
|
+
--color-destructive: var(--destructive);
|
|
29
|
+
--color-accent-foreground: var(--accent-foreground);
|
|
30
|
+
--color-accent: var(--accent);
|
|
31
|
+
--color-muted-foreground: var(--muted-foreground);
|
|
32
|
+
--color-muted: var(--muted);
|
|
33
|
+
--color-secondary-foreground: var(--secondary-foreground);
|
|
34
|
+
--color-secondary: var(--secondary);
|
|
35
|
+
--color-primary-foreground: var(--primary-foreground);
|
|
36
|
+
--color-primary: var(--primary);
|
|
37
|
+
--color-popover-foreground: var(--popover-foreground);
|
|
38
|
+
--color-popover: var(--popover);
|
|
39
|
+
--color-card-foreground: var(--card-foreground);
|
|
40
|
+
--color-card: var(--card);
|
|
41
|
+
--color-foreground: var(--foreground);
|
|
42
|
+
--color-background: var(--background);
|
|
43
|
+
--radius-sm: calc(var(--radius) * 0.6);
|
|
44
|
+
--radius-md: calc(var(--radius) * 0.8);
|
|
45
|
+
--radius-lg: var(--radius);
|
|
46
|
+
--radius-xl: calc(var(--radius) * 1.4);
|
|
47
|
+
--radius-2xl: calc(var(--radius) * 1.8);
|
|
48
|
+
--radius-3xl: calc(var(--radius) * 2.2);
|
|
49
|
+
--radius-4xl: calc(var(--radius) * 2.6);
|
|
50
|
+
--font-sans: 'Inter Variable', sans-serif;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
@layer base {
|
|
54
54
|
* {
|
|
55
55
|
@apply border-border outline-ring/50;
|
|
56
|
-
|
|
56
|
+
}
|
|
57
57
|
body {
|
|
58
58
|
@apply bg-background text-foreground;
|
|
59
|
-
|
|
60
|
-
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
|
|
3
|
-
import { tanstackConfig } from "@tanstack/eslint-config"
|
|
3
|
+
import { tanstackConfig } from "@tanstack/eslint-config";
|
|
4
4
|
|
|
5
5
|
export default [
|
|
6
6
|
...tanstackConfig,
|
|
@@ -18,4 +18,4 @@ export default [
|
|
|
18
18
|
{
|
|
19
19
|
ignores: ["eslint.config.js", ".prettierrc"],
|
|
20
20
|
},
|
|
21
|
-
]
|
|
21
|
+
];
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
"./client/hooks/*": "./client/hooks/*.ts",
|
|
55
55
|
"./server/http": "./server/http.ts",
|
|
56
56
|
"./server/lib/functions": "./server/lib/functions.ts",
|
|
57
|
-
"./client/vite.config": "./client/vite.config.ts"
|
|
57
|
+
"./client/vite.config": "./client/vite.config.ts",
|
|
58
|
+
"./platforms": "./platforms.ts"
|
|
58
59
|
}
|
|
59
60
|
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
export const platforms = [
|
|
2
|
+
{ id: "web", label: "Web", group: "Required", status: "required" },
|
|
3
|
+
{ id: "android", label: "Android", group: "Mobile", status: "available" },
|
|
4
|
+
{ id: "ios", label: "iOS", group: "Mobile", status: "available" },
|
|
5
|
+
{ id: "windows", label: "Windows", group: "Desktop", status: "available" },
|
|
6
|
+
{ id: "linux", label: "Linux", group: "Desktop", status: "available" },
|
|
7
|
+
{ id: "macos", label: "macOS", group: "Desktop", status: "available" },
|
|
8
|
+
{
|
|
9
|
+
id: "mcp",
|
|
10
|
+
label: "MCP",
|
|
11
|
+
group: "MCP & plugins",
|
|
12
|
+
status: "available",
|
|
13
|
+
description: "Tools for AI assistants",
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
id: "openai-plugin",
|
|
17
|
+
label: "OpenAI Plugin",
|
|
18
|
+
description: "Tools and skills for OpenAI",
|
|
19
|
+
group: "MCP & plugins",
|
|
20
|
+
status: "available",
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
id: "claude-code-plugin",
|
|
24
|
+
label: "Claude Code Plugin",
|
|
25
|
+
description: "Tools and skills for Claude Code",
|
|
26
|
+
group: "MCP & plugins",
|
|
27
|
+
status: "available",
|
|
28
|
+
},
|
|
29
|
+
{ id: "api", label: "API", group: "Coming soon", status: "disabled" },
|
|
30
|
+
{ id: "cli", label: "CLI", group: "Coming soon", status: "disabled" },
|
|
31
|
+
{
|
|
32
|
+
id: "python-sdk",
|
|
33
|
+
label: "Python SDK",
|
|
34
|
+
group: "Coming soon",
|
|
35
|
+
status: "disabled",
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
id: "typescript-sdk",
|
|
39
|
+
label: "TypeScript SDK",
|
|
40
|
+
group: "Coming soon",
|
|
41
|
+
status: "disabled",
|
|
42
|
+
},
|
|
43
|
+
] as const;
|
|
44
|
+
|
|
45
|
+
export type Platform = (typeof platforms)[number]["id"];
|
|
46
|
+
export const platformIds = platforms.map(({ id }) => id);
|
|
47
|
+
export const requiredPlatform: Platform = "web";
|
|
48
|
+
export const platformDependencies: Partial<
|
|
49
|
+
Record<Platform, readonly Platform[]>
|
|
50
|
+
> = {
|
|
51
|
+
"openai-plugin": ["mcp"],
|
|
52
|
+
"claude-code-plugin": ["mcp"],
|
|
53
|
+
cli: ["api"],
|
|
54
|
+
"python-sdk": ["api"],
|
|
55
|
+
"typescript-sdk": ["api"],
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export function isPlatform(value: unknown): value is Platform {
|
|
59
|
+
return typeof value === "string" && platformIds.includes(value as Platform);
|
|
60
|
+
}
|
|
61
|
+
export function parsePlatform(value: unknown): Platform {
|
|
62
|
+
if (isPlatform(value)) return value;
|
|
63
|
+
throw new Error(`Unknown platform ${JSON.stringify(value)}`);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Validate persisted selections without silently dropping or adding platforms. */
|
|
67
|
+
export function validatePlatforms(values: readonly unknown[]): Platform[] {
|
|
68
|
+
const selected = new Set(values.map(parsePlatform));
|
|
69
|
+
if (!selected.has(requiredPlatform)) throw new Error("Web is required");
|
|
70
|
+
for (const id of selected) {
|
|
71
|
+
for (const dependency of platformDependencies[id] ?? []) {
|
|
72
|
+
if (!selected.has(dependency))
|
|
73
|
+
throw new Error(`${id} requires ${dependency}`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return platformIds.filter((id) => selected.has(id));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** UI selection adds the required Web platform and dependent transports. */
|
|
80
|
+
export function resolvePlatforms(values: readonly unknown[]): Platform[] {
|
|
81
|
+
const selected = new Set(values.map(parsePlatform));
|
|
82
|
+
selected.add(requiredPlatform);
|
|
83
|
+
for (const id of selected)
|
|
84
|
+
for (const dependency of platformDependencies[id] ?? [])
|
|
85
|
+
selected.add(dependency);
|
|
86
|
+
return platformIds.filter((id) => selected.has(id));
|
|
87
|
+
}
|
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
import { getAuthUserId } from "@convex-dev/auth/server";
|
|
2
2
|
import { McpServer } from "@convex-dev/mcp";
|
|
3
3
|
import { registerStaticRoutes } from "@convex-dev/static-hosting";
|
|
4
|
-
import { httpRouter } from "convex/server";
|
|
4
|
+
import { httpActionGeneric, httpRouter } from "convex/server";
|
|
5
5
|
import { components } from "../../backend/convex/_generated/api";
|
|
6
6
|
import { env } from "../../backend/convex/_generated/server";
|
|
7
|
-
import
|
|
8
|
-
import
|
|
7
|
+
import modules from "../../backend/generated/platforms";
|
|
8
|
+
import openapi from "../../backend/generated/openapi.json";
|
|
9
|
+
import config from "../../../disposabl.json";
|
|
10
|
+
import { validatePlatforms } from "../platforms";
|
|
11
|
+
import { createPlatforms } from "./lib/platform-spec";
|
|
9
12
|
|
|
10
13
|
export { tool } from "@convex-dev/mcp";
|
|
11
14
|
export type { McpServerOptions, McpUser, ToolCtx } from "@convex-dev/mcp";
|
|
12
15
|
|
|
13
|
-
const
|
|
16
|
+
const platforms = createPlatforms(modules);
|
|
17
|
+
export const platformSpec = platforms.spec;
|
|
18
|
+
|
|
19
|
+
const enabled = validatePlatforms(config.platforms);
|
|
20
|
+
const mcp = enabled.some((platform) => platform === "mcp" || platform === "api")
|
|
14
21
|
? new McpServer(components.mcp, {
|
|
15
22
|
name: "disposabl",
|
|
16
23
|
title: "Disposabl",
|
|
@@ -18,8 +25,7 @@ const mcp = getPlatforms().isMcpEnabled
|
|
|
18
25
|
siteUrl: env.CONVEX_SITE_URL,
|
|
19
26
|
consentUrl: `${env.CONVEX_SITE_URL}/consent`,
|
|
20
27
|
scopes: {},
|
|
21
|
-
|
|
22
|
-
tools: createMcpTools({}),
|
|
28
|
+
tools: platforms.tools,
|
|
23
29
|
})
|
|
24
30
|
: undefined;
|
|
25
31
|
|
|
@@ -36,7 +42,31 @@ export const {
|
|
|
36
42
|
|
|
37
43
|
export default function createHttpRouter() {
|
|
38
44
|
const http = httpRouter();
|
|
39
|
-
mcp
|
|
45
|
+
if (mcp) {
|
|
46
|
+
const authRoutes = httpRouter();
|
|
47
|
+
mcp.registerRoutes(authRoutes);
|
|
48
|
+
for (const [path, method, handler] of authRoutes.getRoutes()) {
|
|
49
|
+
if (path !== "/mcp" || enabled.includes("mcp"))
|
|
50
|
+
http.route({ path, method, handler });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (mcp && enabled.includes("api")) {
|
|
54
|
+
http.route({
|
|
55
|
+
path: "/openapi.json",
|
|
56
|
+
method: "GET",
|
|
57
|
+
handler: httpActionGeneric(async () =>
|
|
58
|
+
Response.json({ ...openapi, servers: [{ url: env.CONVEX_SITE_URL }] }),
|
|
59
|
+
),
|
|
60
|
+
});
|
|
61
|
+
for (const method of ["GET", "POST"] as const)
|
|
62
|
+
http.route({
|
|
63
|
+
pathPrefix: "/api/",
|
|
64
|
+
method,
|
|
65
|
+
handler: httpActionGeneric((ctx, request) =>
|
|
66
|
+
platforms.handleApi(ctx, request, mcp.authenticate.bind(mcp)),
|
|
67
|
+
),
|
|
68
|
+
});
|
|
69
|
+
}
|
|
40
70
|
registerStaticRoutes(http, components.staticHosting);
|
|
41
71
|
return http;
|
|
42
72
|
}
|
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
internalMutation as nativeMutation,
|
|
9
9
|
internalQuery as nativeQuery,
|
|
10
10
|
} from "../../../backend/convex/_generated/server";
|
|
11
|
-
import type { Platforms } from "./platforms";
|
|
12
11
|
|
|
13
12
|
// Trusted server entrypoints must supply the user ID after authentication.
|
|
14
13
|
export const identityFields = {
|
|
@@ -22,19 +21,11 @@ const withPlatforms = <TDefinition, TResult extends object>(
|
|
|
22
21
|
definition: TDefinition & {
|
|
23
22
|
args: PropertyValidators;
|
|
24
23
|
returns: GenericValidator;
|
|
25
|
-
platforms?:
|
|
26
|
-
mcp?: boolean;
|
|
24
|
+
platforms?: true;
|
|
27
25
|
},
|
|
28
26
|
): TResult => {
|
|
29
|
-
const mcpEnabled =
|
|
30
|
-
definition.platforms === undefined
|
|
31
|
-
? definition.mcp === true
|
|
32
|
-
: definition.platforms === true ||
|
|
33
|
-
(typeof definition.platforms === "object" &&
|
|
34
|
-
definition.platforms.mcp === true);
|
|
35
27
|
return Object.assign(builder(definition), {
|
|
36
28
|
platforms: definition.platforms,
|
|
37
|
-
mcp: mcpEnabled ? (definition.mcp ?? true) : false,
|
|
38
29
|
args: definition.args,
|
|
39
30
|
returns: definition.returns,
|
|
40
31
|
});
|