create-disposabl-app 0.4.2 → 0.6.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 +18 -0
- package/dist/disposabl.js +541 -0
- package/dist/index.js +154 -61
- package/dist/templates/default/.github/scripts/android-build.sh +18 -0
- package/dist/templates/default/.github/scripts/disposabl.mjs +95 -0
- package/dist/templates/default/.github/scripts/expo-channel.sh +10 -0
- package/dist/templates/default/.github/scripts/expo-env.sh +17 -0
- package/dist/templates/default/.github/scripts/expo-fingerprint.sh +19 -0
- package/dist/templates/default/.github/scripts/expo-update.sh +11 -0
- package/dist/templates/default/.github/scripts/package-release.sh +23 -0
- package/dist/templates/default/.github/scripts/platforms.sh +37 -0
- package/dist/templates/default/.github/scripts/release-publish.sh +28 -0
- package/dist/templates/default/.github/scripts/release-source.sh +14 -0
- package/dist/templates/default/.github/scripts/verify-artifacts.sh +13 -0
- package/dist/templates/default/.github/scripts/web-deploy.sh +10 -0
- package/dist/templates/default/.github/workflows/pipeline.yml +299 -0
- package/dist/templates/default/apps/docs/README.md +37 -0
- package/dist/templates/default/apps/docs/content/guides/writing.mdx +15 -0
- package/dist/templates/default/apps/docs/content/index.mdx +10 -0
- package/dist/templates/default/apps/docs/package.json +29 -1
- package/dist/templates/default/apps/docs/press.config.ts +20 -0
- package/dist/templates/default/apps/docs/src/app.css +4 -0
- package/dist/templates/default/apps/docs/tsconfig.json +14 -0
- package/dist/templates/default/apps/docs/vite.config.ts +8 -0
- package/dist/templates/default/apps/mobile/.env.example +2 -0
- package/dist/templates/default/apps/mobile/AGENTS.md +2 -2
- package/dist/templates/default/apps/mobile/README.md +64 -4
- package/dist/templates/default/apps/mobile/app.json +5 -4
- package/dist/templates/default/apps/mobile/assets/images/android-icon-foreground.png +0 -0
- package/dist/templates/default/apps/mobile/assets/images/android-icon-monochrome.png +0 -0
- package/dist/templates/default/apps/mobile/assets/images/icon.png +0 -0
- package/dist/templates/default/apps/mobile/assets/images/splash-icon.png +0 -0
- package/dist/templates/default/apps/mobile/eas.json +5 -0
- package/dist/templates/default/apps/mobile/package.json +18 -4
- package/dist/templates/default/apps/mobile/src/app/(auth)/_layout.tsx +1 -0
- package/dist/templates/default/apps/mobile/src/app/(auth)/login.tsx +1 -0
- package/dist/templates/default/apps/mobile/src/app/(auth)/signup.tsx +1 -0
- package/dist/templates/default/apps/mobile/src/app/(authenticated)/_layout.tsx +1 -0
- package/dist/templates/default/apps/mobile/src/app/(authenticated)/account.tsx +1 -0
- package/dist/templates/default/apps/mobile/src/app/_layout.tsx +1 -5
- package/dist/templates/default/apps/mobile/src/app/index.tsx +1 -17
- package/dist/templates/default/apps/mobile/tsconfig.json +8 -1
- package/dist/templates/default/apps/web/package.json +3 -2
- package/dist/templates/default/apps/web/src/routeTree.gen.ts +0 -44
- package/dist/templates/default/apps/web/src/router/__root.tsx +1 -1
- package/dist/templates/default/apps/web/src/router/_authenticated/dashboard.api-keys.tsx +1 -1
- package/dist/templates/default/apps/web/src/router/_authenticated/dashboard.tsx +2 -1
- package/dist/templates/default/apps/web/src/router/index.tsx +11 -3
- package/dist/templates/default/apps/web/tests/auth-branches.test.tsx +44 -0
- package/dist/templates/default/apps/web/vite.config.ts +15 -0
- package/dist/templates/default/bun.lock +583 -23
- package/dist/templates/default/bunfig.toml +0 -2
- package/dist/templates/default/disposabl.json +2 -13
- package/dist/templates/default/package.json +3 -3
- package/dist/templates/default/packages/backend/AGENTS.md +15 -13
- package/dist/templates/default/packages/backend/README.md +6 -28
- package/dist/templates/default/packages/backend/convex/_generated/ai/ai-files.state.json +1 -1
- package/dist/templates/default/packages/backend/convex/_generated/api.d.ts +32 -6
- package/dist/templates/default/packages/backend/convex/_generated/server.d.ts +8 -0
- package/dist/templates/default/packages/backend/convex/apps/actions/create.ts +19 -0
- package/dist/templates/default/packages/backend/convex/apps/internal.ts +197 -0
- package/dist/templates/default/packages/backend/convex/auth.ts +1 -1
- package/dist/templates/default/packages/backend/convex/convex.config.ts +8 -0
- package/dist/templates/default/packages/backend/convex/github/actions/http.ts +40 -0
- package/dist/templates/default/packages/backend/convex/github/actions/internal.ts +189 -0
- package/dist/templates/default/packages/backend/convex/github/actions/oidc.ts +75 -0
- package/dist/templates/default/packages/backend/convex/github/actions/provision.ts +80 -0
- package/dist/templates/default/packages/backend/convex/github/actions/tokens.ts +66 -0
- package/dist/templates/default/packages/backend/convex/github/internal.ts +34 -0
- package/dist/templates/default/packages/backend/convex/http.ts +3 -0
- package/dist/templates/default/packages/backend/convex/previews/internal.ts +270 -0
- package/dist/templates/default/packages/backend/convex/previews/token/actions/create.ts +69 -0
- package/dist/templates/default/packages/backend/convex/previews/token/actions/management.ts +133 -0
- package/dist/templates/default/packages/backend/convex/previews/token/internal.ts +1 -0
- package/dist/templates/default/packages/backend/convex/releases/internal.ts +28 -0
- package/dist/templates/default/packages/backend/convex/schema.ts +34 -4
- package/dist/templates/default/packages/backend/convex/users/index.ts +21 -0
- package/dist/templates/default/packages/backend/convex/users/internal.ts +44 -0
- package/dist/templates/default/packages/backend/convex/validator.ts +87 -0
- package/dist/templates/default/packages/backend/generate.ts +6 -1
- package/dist/templates/default/packages/backend/generated/openapi.json +961 -43
- package/dist/templates/default/packages/backend/generated/pages.json +0 -8
- package/dist/templates/default/packages/backend/generated/platforms.ts +14 -2
- package/dist/templates/default/packages/backend/package.json +1 -1
- package/dist/templates/default/packages/cli/README.md +15 -9
- package/dist/templates/default/packages/cli/auth.ts +11 -3
- package/dist/templates/default/packages/cli/commands.ts +236 -0
- package/dist/templates/default/packages/cli/index.ts +2 -142
- package/dist/templates/default/packages/cli/preview.ts +157 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/log-out.tsx +16 -0
- package/dist/templates/default/packages/disposabl-kit/client/lib/prerender.ts +6 -3
- package/dist/templates/default/packages/disposabl-kit/client/routes/_auth-pages/login.tsx +1 -1
- package/dist/templates/default/packages/disposabl-kit/client/routes/_auth-pages/signUp.tsx +1 -1
- package/dist/templates/default/packages/disposabl-kit/client/routes/_authenticated/route.tsx +25 -16
- package/dist/templates/default/packages/disposabl-kit/client/routes/consent.tsx +3 -2
- package/dist/templates/default/packages/disposabl-kit/client/routes/route.tsx +57 -2
- package/dist/templates/default/packages/disposabl-kit/client/vite.config.ts +20 -9
- package/dist/templates/default/packages/disposabl-kit/eslint.config.js +1 -1
- package/dist/templates/default/packages/disposabl-kit/features.ts +4 -0
- package/dist/templates/default/packages/disposabl-kit/mobile/components/auth-form.tsx +125 -0
- package/dist/templates/default/packages/disposabl-kit/mobile/components/auth-ui.tsx +107 -0
- package/dist/templates/default/packages/disposabl-kit/mobile/expo-plugin.cjs +26 -0
- package/dist/templates/default/packages/disposabl-kit/mobile/index.ts +10 -0
- package/dist/templates/default/packages/disposabl-kit/mobile/layout.tsx +101 -0
- package/dist/templates/default/packages/disposabl-kit/mobile/lib/auth-errors.ts +40 -0
- package/dist/templates/default/packages/disposabl-kit/mobile/lib/auth-storage.ts +9 -0
- package/dist/templates/default/packages/disposabl-kit/mobile/lib/convex.ts +1 -0
- package/dist/templates/default/packages/disposabl-kit/mobile/lib/logo.png +0 -0
- package/dist/templates/default/packages/disposabl-kit/mobile/screens/account.tsx +67 -0
- package/dist/templates/default/packages/disposabl-kit/mobile/screens/home.tsx +65 -0
- package/dist/templates/default/packages/disposabl-kit/mobile/screens/login.tsx +5 -0
- package/dist/templates/default/packages/disposabl-kit/mobile/screens/signup.tsx +5 -0
- package/dist/templates/default/packages/disposabl-kit/package.json +24 -1
- package/dist/templates/default/packages/disposabl-kit/platforms.ts +1 -27
- package/dist/templates/default/packages/disposabl-kit/server/http.ts +6 -0
- package/dist/templates/default/packages/disposabl-kit/server/lib/docs.test.ts +111 -0
- package/dist/templates/default/packages/disposabl-kit/server/lib/docs.ts +62 -0
- package/dist/templates/default/packages/disposabl-kit/tsconfig.json +1 -1
- package/dist/templates/default/packages/sdk/README.md +8 -4
- package/dist/templates/default/packages/sdk/src/config.ts +14 -7
- package/dist/templates/default/packages/sdk/src/generated/index.ts +48 -13
- package/dist/templates/default/packages/sdk/src/generated/sdk.gen.ts +139 -27
- package/dist/templates/default/packages/sdk/src/generated/types.gen.ts +440 -37
- package/dist/templates/default/turbo.json +7 -0
- package/package.json +6 -3
- package/dist/templates/default/.github/README.md +0 -99
- package/dist/templates/default/.github/actionlint.yaml +0 -6
- package/dist/templates/default/.github/workflows/pipeline.yml.example +0 -546
- package/dist/templates/default/apps/blog/package.json +0 -1
- package/dist/templates/default/apps/changelog/package.json +0 -1
- package/dist/templates/default/apps/desktop/.oxfmtrc.json +0 -5
- package/dist/templates/default/apps/desktop/.oxlintrc.json +0 -6
- package/dist/templates/default/apps/desktop/README.md +0 -88
- package/dist/templates/default/apps/desktop/build-ci.mjs +0 -56
- package/dist/templates/default/apps/desktop/forge.config.mts +0 -109
- package/dist/templates/default/apps/desktop/index.html +0 -12
- package/dist/templates/default/apps/desktop/package.json +0 -55
- package/dist/templates/default/apps/desktop/src/declarations.d.ts +0 -2
- package/dist/templates/default/apps/desktop/src/index.css +0 -8
- package/dist/templates/default/apps/desktop/src/main.ts +0 -58
- package/dist/templates/default/apps/desktop/src/preload.ts +0 -3
- package/dist/templates/default/apps/desktop/src/renderer.ts +0 -19
- package/dist/templates/default/apps/desktop/tsconfig.json +0 -14
- package/dist/templates/default/apps/desktop/vite.main.config.mts +0 -4
- package/dist/templates/default/apps/desktop/vite.preload.config.mts +0 -4
- package/dist/templates/default/apps/desktop/vite.renderer.config.mts +0 -4
- package/dist/templates/default/apps/web/src/router/_authenticated/todos/$id.tsx +0 -27
- package/dist/templates/default/apps/web/src/router/_authenticated/todos/index.tsx +0 -33
- package/dist/templates/default/packages/backend/convex/todos/index.ts +0 -26
- package/dist/templates/default/packages/backend/convex/todos/internal.ts +0 -43
- package/dist/templates/default/packages/backend/convex/users.ts +0 -20
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { api } from "../../../backend/convex/_generated/api";
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { useAuthActions } from "@convex-dev/auth/react";
|
|
2
|
+
import { useQuery } from "convex/react";
|
|
3
|
+
import { Link, router } from "expo-router";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
import { Text, View } from "react-native";
|
|
6
|
+
import { AuthButton, AuthScreen, styles } from "../components/auth-ui";
|
|
7
|
+
import { api } from "../lib/convex";
|
|
8
|
+
|
|
9
|
+
export function AccountScreen() {
|
|
10
|
+
const user = useQuery(api.users.index.current);
|
|
11
|
+
const { signOut } = useAuthActions();
|
|
12
|
+
const [pending, setPending] = useState(false);
|
|
13
|
+
const [error, setError] = useState<string | null>(null);
|
|
14
|
+
|
|
15
|
+
async function logOut() {
|
|
16
|
+
if (pending) return;
|
|
17
|
+
setPending(true);
|
|
18
|
+
setError(null);
|
|
19
|
+
try {
|
|
20
|
+
await signOut();
|
|
21
|
+
router.replace("/");
|
|
22
|
+
} catch {
|
|
23
|
+
setError("Couldn't clear your session. Please try logging out again.");
|
|
24
|
+
} finally {
|
|
25
|
+
setPending(false);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<AuthScreen>
|
|
31
|
+
<Text style={styles.title}>
|
|
32
|
+
{user?.username ? `Hi, ${user.username}` : "Your account"}
|
|
33
|
+
</Text>
|
|
34
|
+
{user === undefined ? (
|
|
35
|
+
<Text style={styles.body}>Loading your account...</Text>
|
|
36
|
+
) : user === null ? (
|
|
37
|
+
<Text style={styles.error}>Your account could not be found.</Text>
|
|
38
|
+
) : (
|
|
39
|
+
<View style={styles.card}>
|
|
40
|
+
<Text style={styles.label}>You are logged in</Text>
|
|
41
|
+
<Text style={styles.body}>
|
|
42
|
+
Username: {user.username ?? "Not set"}
|
|
43
|
+
</Text>
|
|
44
|
+
<Text style={styles.body} selectable>
|
|
45
|
+
User ID: {user.id}
|
|
46
|
+
</Text>
|
|
47
|
+
<Text style={styles.body}>
|
|
48
|
+
Your account was verified by the server.
|
|
49
|
+
</Text>
|
|
50
|
+
</View>
|
|
51
|
+
)}
|
|
52
|
+
<AuthButton
|
|
53
|
+
title={pending ? "Logging out..." : "Log out"}
|
|
54
|
+
pending={pending}
|
|
55
|
+
onPress={() => void logOut()}
|
|
56
|
+
/>
|
|
57
|
+
{error && (
|
|
58
|
+
<Text accessibilityRole="alert" style={styles.error}>
|
|
59
|
+
{error}
|
|
60
|
+
</Text>
|
|
61
|
+
)}
|
|
62
|
+
<Link href="/" style={styles.link}>
|
|
63
|
+
Back to home
|
|
64
|
+
</Link>
|
|
65
|
+
</AuthScreen>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { useConvexAuth } from "convex/react";
|
|
2
|
+
import { router, Stack } from "expo-router";
|
|
3
|
+
import { Image, Text } from "react-native";
|
|
4
|
+
import { AuthButton, AuthScreen, styles } from "../components/auth-ui";
|
|
5
|
+
|
|
6
|
+
export function HomeScreen() {
|
|
7
|
+
return (
|
|
8
|
+
<AuthScreen>
|
|
9
|
+
<HomeIntro />
|
|
10
|
+
<AccountLinks />
|
|
11
|
+
</AuthScreen>
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function AccountLinks() {
|
|
16
|
+
const { isAuthenticated, isLoading } = useConvexAuth();
|
|
17
|
+
if (isLoading)
|
|
18
|
+
return <Text style={styles.body}>Restoring your session...</Text>;
|
|
19
|
+
if (isAuthenticated) {
|
|
20
|
+
return (
|
|
21
|
+
<AuthButton
|
|
22
|
+
title="Your account"
|
|
23
|
+
onPress={() => router.push("/(authenticated)/account")}
|
|
24
|
+
/>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
return (
|
|
28
|
+
<>
|
|
29
|
+
<Text style={styles.body}>
|
|
30
|
+
Log in to see your account, or create one to get started.
|
|
31
|
+
</Text>
|
|
32
|
+
<AuthButton title="Log in" onPress={() => router.push("/(auth)/login")} />
|
|
33
|
+
<AuthButton
|
|
34
|
+
title="Create account"
|
|
35
|
+
onPress={() => router.push("/(auth)/signup")}
|
|
36
|
+
/>
|
|
37
|
+
</>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function PublicHomeScreen() {
|
|
42
|
+
return (
|
|
43
|
+
<AuthScreen>
|
|
44
|
+
<Stack.Screen options={{ title: "Disposabl" }} />
|
|
45
|
+
<HomeIntro />
|
|
46
|
+
</AuthScreen>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function HomeIntro() {
|
|
51
|
+
return (
|
|
52
|
+
<>
|
|
53
|
+
<Image
|
|
54
|
+
source={require("../lib/logo.png")}
|
|
55
|
+
style={{ width: 96, height: 96 }}
|
|
56
|
+
accessibilityLabel="Disposabl logo"
|
|
57
|
+
/>
|
|
58
|
+
<Text style={styles.title}>Welcome to Disposabl</Text>
|
|
59
|
+
<Text style={styles.body}>
|
|
60
|
+
Your app starts here. Make this space your own and build something
|
|
61
|
+
useful.
|
|
62
|
+
</Text>
|
|
63
|
+
</>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
@@ -57,6 +57,29 @@
|
|
|
57
57
|
"./server/http": "./server/http.ts",
|
|
58
58
|
"./server/lib/functions": "./server/lib/functions.ts",
|
|
59
59
|
"./client/vite.config": "./client/vite.config.ts",
|
|
60
|
-
"./platforms": "./platforms.ts"
|
|
60
|
+
"./platforms": "./platforms.ts",
|
|
61
|
+
"./mobile": "./mobile/index.ts",
|
|
62
|
+
"./features": "./features.ts",
|
|
63
|
+
"./mobile/expo-plugin": "./mobile/expo-plugin.cjs"
|
|
64
|
+
},
|
|
65
|
+
"peerDependencies": {
|
|
66
|
+
"expo": "~58.0.19",
|
|
67
|
+
"expo-router": "~58.0.26",
|
|
68
|
+
"expo-secure-store": "~58.0.2",
|
|
69
|
+
"react-native": "0.88.0"
|
|
70
|
+
},
|
|
71
|
+
"peerDependenciesMeta": {
|
|
72
|
+
"expo": {
|
|
73
|
+
"optional": true
|
|
74
|
+
},
|
|
75
|
+
"expo-router": {
|
|
76
|
+
"optional": true
|
|
77
|
+
},
|
|
78
|
+
"expo-secure-store": {
|
|
79
|
+
"optional": true
|
|
80
|
+
},
|
|
81
|
+
"react-native": {
|
|
82
|
+
"optional": true
|
|
83
|
+
}
|
|
61
84
|
}
|
|
62
85
|
}
|
|
@@ -2,38 +2,15 @@ export const platforms = [
|
|
|
2
2
|
{ id: "web", label: "Web", group: "Required", status: "required" },
|
|
3
3
|
{ id: "android", label: "Android", group: "Mobile", status: "available" },
|
|
4
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
5
|
{
|
|
9
6
|
id: "mcp",
|
|
10
7
|
label: "MCP",
|
|
11
|
-
group: "
|
|
8
|
+
group: "Developer tools",
|
|
12
9
|
status: "available",
|
|
13
10
|
description: "Tools for AI assistants",
|
|
14
11
|
},
|
|
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
12
|
{ id: "api", label: "API", group: "Developer tools", status: "available" },
|
|
30
13
|
{ id: "cli", label: "CLI", group: "Developer tools", status: "available" },
|
|
31
|
-
{
|
|
32
|
-
id: "python-sdk",
|
|
33
|
-
label: "Python SDK",
|
|
34
|
-
group: "Coming soon",
|
|
35
|
-
status: "disabled",
|
|
36
|
-
},
|
|
37
14
|
{
|
|
38
15
|
id: "typescript-sdk",
|
|
39
16
|
label: "TypeScript SDK",
|
|
@@ -48,10 +25,7 @@ export const requiredPlatform: Platform = "web";
|
|
|
48
25
|
export const platformDependencies: Partial<
|
|
49
26
|
Record<Platform, readonly Platform[]>
|
|
50
27
|
> = {
|
|
51
|
-
"openai-plugin": ["mcp"],
|
|
52
|
-
"claude-code-plugin": ["mcp"],
|
|
53
28
|
cli: ["api"],
|
|
54
|
-
"python-sdk": ["api"],
|
|
55
29
|
"typescript-sdk": ["api"],
|
|
56
30
|
};
|
|
57
31
|
|
|
@@ -7,6 +7,9 @@ import modules from "../../backend/generated/platforms";
|
|
|
7
7
|
import openapi from "../../backend/generated/openapi.json";
|
|
8
8
|
import config from "../../../disposabl.json";
|
|
9
9
|
import { validatePlatforms } from "../platforms";
|
|
10
|
+
// docs:start
|
|
11
|
+
import { registerDocsRoutes } from "./lib/docs";
|
|
12
|
+
// docs:end
|
|
10
13
|
import { createOpenApi, createPlatforms } from "./lib/platform-spec";
|
|
11
14
|
import { registerPageRoutes } from "./lib/static";
|
|
12
15
|
|
|
@@ -93,6 +96,9 @@ export default function createHttpRouter() {
|
|
|
93
96
|
}),
|
|
94
97
|
});
|
|
95
98
|
}
|
|
99
|
+
// docs:start
|
|
100
|
+
registerDocsRoutes(http);
|
|
101
|
+
// docs:end
|
|
96
102
|
registerPageRoutes(http);
|
|
97
103
|
return http;
|
|
98
104
|
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { test } from "node:test";
|
|
3
|
+
import {
|
|
4
|
+
httpRouter,
|
|
5
|
+
type GenericActionCtx,
|
|
6
|
+
type GenericDataModel,
|
|
7
|
+
} from "convex/server";
|
|
8
|
+
import { registerDocsRoutes } from "./docs";
|
|
9
|
+
|
|
10
|
+
function setup() {
|
|
11
|
+
const router = httpRouter();
|
|
12
|
+
registerDocsRoutes(router);
|
|
13
|
+
const paths: string[] = [];
|
|
14
|
+
const assets = new Map([
|
|
15
|
+
[
|
|
16
|
+
"/docs/index.html",
|
|
17
|
+
{ contentType: "text/html", storageUrl: "data:text/html,Docs" },
|
|
18
|
+
],
|
|
19
|
+
[
|
|
20
|
+
"/docs/guides/writing/index.html",
|
|
21
|
+
{ contentType: "text/html", storageUrl: "data:text/html,Writing" },
|
|
22
|
+
],
|
|
23
|
+
[
|
|
24
|
+
"/docs/404.html",
|
|
25
|
+
{ contentType: "text/html", storageUrl: "data:text/html,Missing" },
|
|
26
|
+
],
|
|
27
|
+
[
|
|
28
|
+
"/docs/RSC/R/guides/writing.txt",
|
|
29
|
+
{ contentType: "text/plain", storageUrl: "data:text/plain,RSC" },
|
|
30
|
+
],
|
|
31
|
+
]);
|
|
32
|
+
const ctx = {
|
|
33
|
+
runQuery: (
|
|
34
|
+
_query: unknown,
|
|
35
|
+
args: { path: string; spaFallback: boolean },
|
|
36
|
+
) => {
|
|
37
|
+
assert.equal(args.spaFallback, false);
|
|
38
|
+
paths.push(args.path);
|
|
39
|
+
return Promise.resolve(assets.get(args.path) ?? null);
|
|
40
|
+
},
|
|
41
|
+
} as unknown as GenericActionCtx<GenericDataModel>;
|
|
42
|
+
async function get(path: string, accept = "text/html") {
|
|
43
|
+
const request = new Request(`https://example.convex.site${path}`, {
|
|
44
|
+
headers: { Accept: accept },
|
|
45
|
+
});
|
|
46
|
+
const match = router.lookup(new URL(request.url).pathname, "GET");
|
|
47
|
+
assert.ok(match);
|
|
48
|
+
const action = match[0] as unknown as {
|
|
49
|
+
_handler: (context: typeof ctx, request: Request) => Promise<Response>;
|
|
50
|
+
};
|
|
51
|
+
return action._handler(ctx, request);
|
|
52
|
+
}
|
|
53
|
+
return { router, paths, get };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
test("docs root redirects to the Waku base path and preserves query parameters", async () => {
|
|
57
|
+
const { get, paths } = setup();
|
|
58
|
+
const response = await get("/docs?q=writing");
|
|
59
|
+
assert.equal(response.status, 308);
|
|
60
|
+
assert.equal(
|
|
61
|
+
response.headers.get("Location"),
|
|
62
|
+
"https://example.convex.site/docs/?q=writing",
|
|
63
|
+
);
|
|
64
|
+
assert.deepEqual(paths, []);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
test("root and nested clean URLs resolve their directory indexes", async () => {
|
|
68
|
+
const { get } = setup();
|
|
69
|
+
assert.equal(await (await get("/docs/")).text(), "Docs");
|
|
70
|
+
for (const path of ["/docs/guides/writing", "/docs/guides/writing/"]) {
|
|
71
|
+
const response = await get(path);
|
|
72
|
+
assert.equal(response.status, 200);
|
|
73
|
+
assert.equal(response.headers.get("Content-Type"), "text/html");
|
|
74
|
+
assert.equal(await response.text(), "Writing");
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test("RSC files are served at their exact path with their content type", async () => {
|
|
79
|
+
const { get, paths } = setup();
|
|
80
|
+
const response = await get("/docs/RSC/R/guides/writing.txt", "*/*");
|
|
81
|
+
assert.equal(response.status, 200);
|
|
82
|
+
assert.equal(response.headers.get("Content-Type"), "text/plain");
|
|
83
|
+
assert.equal(await response.text(), "RSC");
|
|
84
|
+
assert.deepEqual(paths, ["/docs/RSC/R/guides/writing.txt"]);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
test("missing pages retain HTTP 404 and never use the app homepage", async () => {
|
|
88
|
+
const { get, paths } = setup();
|
|
89
|
+
const response = await get("/docs/missing");
|
|
90
|
+
assert.equal(response.status, 404);
|
|
91
|
+
assert.equal(await response.text(), "Missing");
|
|
92
|
+
assert.ok(!paths.includes("/index.html"));
|
|
93
|
+
const asset = await get("/docs/assets/missing.js", "*/*");
|
|
94
|
+
assert.equal(asset.status, 404);
|
|
95
|
+
assert.equal(await asset.text(), "Not Found");
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
test("malformed paths are rejected and other routes remain outside the docs handler", async () => {
|
|
99
|
+
const { get, paths, router } = setup();
|
|
100
|
+
for (const path of [
|
|
101
|
+
"/docs/%",
|
|
102
|
+
"/docs/%2e%2e%2fprivate",
|
|
103
|
+
"/docs/%5cprivate",
|
|
104
|
+
"/docs/%00",
|
|
105
|
+
]) {
|
|
106
|
+
assert.equal((await get(path)).status, 400);
|
|
107
|
+
}
|
|
108
|
+
assert.deepEqual(paths, []);
|
|
109
|
+
assert.equal(router.lookup("/dashboard", "GET"), null);
|
|
110
|
+
assert.equal(router.lookup("/docs-other", "GET"), null);
|
|
111
|
+
});
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { httpActionGeneric, type HttpRouter } from "convex/server";
|
|
2
|
+
import type { GenericId } from "convex/values";
|
|
3
|
+
import { components } from "../../../backend/convex/_generated/api";
|
|
4
|
+
|
|
5
|
+
/** Fumapress emits directory indexes; the static component resolves exact paths. */
|
|
6
|
+
export function registerDocsRoutes(http: HttpRouter) {
|
|
7
|
+
const handler = httpActionGeneric(async (ctx, request) => {
|
|
8
|
+
const url = new URL(request.url);
|
|
9
|
+
if (url.pathname === "/docs") {
|
|
10
|
+
url.pathname = "/docs/";
|
|
11
|
+
return Response.redirect(url, 308);
|
|
12
|
+
}
|
|
13
|
+
let path: string;
|
|
14
|
+
try {
|
|
15
|
+
path = decodeURIComponent(url.pathname);
|
|
16
|
+
} catch {
|
|
17
|
+
return new Response("Bad Request", { status: 400 });
|
|
18
|
+
}
|
|
19
|
+
if (
|
|
20
|
+
!path.startsWith("/docs/") ||
|
|
21
|
+
path.includes("\\") ||
|
|
22
|
+
path.includes("\0") ||
|
|
23
|
+
path.split("/").some((part) => part === "." || part === "..")
|
|
24
|
+
) {
|
|
25
|
+
return new Response("Bad Request", { status: 400 });
|
|
26
|
+
}
|
|
27
|
+
const resolve = (assetPath: string) =>
|
|
28
|
+
ctx.runQuery(components.staticHosting.lib.resolveAssetForHttp, {
|
|
29
|
+
path: assetPath,
|
|
30
|
+
spaFallback: false,
|
|
31
|
+
});
|
|
32
|
+
let asset = await resolve(path);
|
|
33
|
+
asset ??= await resolve(`${path.replace(/\/$/, "")}/index.html`);
|
|
34
|
+
const status = asset ? 200 : 404;
|
|
35
|
+
if (!asset && request.headers.get("Accept")?.includes("text/html"))
|
|
36
|
+
asset = await resolve("/docs/404.html");
|
|
37
|
+
if (!asset) return new Response("Not Found", { status: 404 });
|
|
38
|
+
if (asset.blobId && !asset.contentType.startsWith("text/html"))
|
|
39
|
+
return Response.redirect(
|
|
40
|
+
new URL(`/fs/blobs/${encodeURIComponent(asset.blobId)}`, url),
|
|
41
|
+
302,
|
|
42
|
+
);
|
|
43
|
+
const body = asset.appStorageId
|
|
44
|
+
? await ctx.storage.get(asset.appStorageId as GenericId<"_storage">)
|
|
45
|
+
: asset.storageUrl
|
|
46
|
+
? await fetch(asset.storageUrl).then((response) =>
|
|
47
|
+
response.ok ? response.body : null,
|
|
48
|
+
)
|
|
49
|
+
: null;
|
|
50
|
+
if (!body) return new Response("Asset not available", { status: 502 });
|
|
51
|
+
return new Response(body, {
|
|
52
|
+
status,
|
|
53
|
+
headers: {
|
|
54
|
+
"Content-Type": asset.contentType,
|
|
55
|
+
"Cache-Control": "no-cache",
|
|
56
|
+
"X-Content-Type-Options": "nosniff",
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
http.route({ path: "/docs", method: "GET", handler });
|
|
61
|
+
http.route({ pathPrefix: "/docs/", method: "GET", handler });
|
|
62
|
+
}
|
|
@@ -3,16 +3,20 @@
|
|
|
3
3
|
Generated with the pinned Hey API generator from `packages/backend/generated/openapi.json`.
|
|
4
4
|
|
|
5
5
|
```ts
|
|
6
|
-
import { client,
|
|
6
|
+
import { client, appsCreate, appsList, appsGet } from "@disposabl/sdk";
|
|
7
7
|
|
|
8
8
|
client.setConfig({
|
|
9
9
|
baseUrl: "https://your-deployment.convex.site",
|
|
10
10
|
auth: process.env.DISPOSABL_API_KEY,
|
|
11
11
|
throwOnError: true,
|
|
12
12
|
});
|
|
13
|
-
const { data:
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
const { data: created } = await appsCreate({
|
|
14
|
+
body: { name: "My app", platforms: ["web", "api"] },
|
|
15
|
+
});
|
|
16
|
+
const { data: page } = await appsList({
|
|
17
|
+
query: { paginationOpts: { numItems: 20, cursor: null } },
|
|
18
|
+
});
|
|
19
|
+
const { data: app } = await appsGet({ query: { appId: created!.appId } });
|
|
16
20
|
```
|
|
17
21
|
|
|
18
22
|
Create API keys at `/dashboard/api-keys`. Keep server integration keys on the server. The API also accepts OAuth tokens issued through its MCP authorization server.
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import type { CreateClientConfig } from "./generated/client.gen.js";
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
const serializeQuery = (query: Record<string, unknown>) =>
|
|
4
|
+
new URLSearchParams(
|
|
5
|
+
Object.entries(query)
|
|
6
|
+
.filter(([, value]) => value !== undefined)
|
|
7
|
+
.map(([name, value]) => [name, JSON.stringify(value)]),
|
|
8
|
+
).toString();
|
|
9
|
+
|
|
3
10
|
export const createClientConfig: CreateClientConfig = (config) => ({
|
|
4
11
|
...config,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
12
|
+
// Generated object parameters otherwise override the client's JSON serializer.
|
|
13
|
+
requestValidator: async (options) => {
|
|
14
|
+
(options as { querySerializer: typeof serializeQuery }).querySerializer =
|
|
15
|
+
serializeQuery;
|
|
16
|
+
return options;
|
|
17
|
+
},
|
|
11
18
|
});
|
|
@@ -1,18 +1,53 @@
|
|
|
1
1
|
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
2
|
|
|
3
|
-
export {
|
|
3
|
+
export {
|
|
4
|
+
appsCreate,
|
|
5
|
+
appsDelete,
|
|
6
|
+
appsGet,
|
|
7
|
+
appsList,
|
|
8
|
+
type Options,
|
|
9
|
+
previewsGet,
|
|
10
|
+
previewsList,
|
|
11
|
+
previewsTokenCreate,
|
|
12
|
+
releasesGet,
|
|
13
|
+
usersCurrent,
|
|
14
|
+
} from "./sdk.gen.js";
|
|
4
15
|
export type {
|
|
16
|
+
AppsCreateData,
|
|
17
|
+
AppsCreateErrors,
|
|
18
|
+
AppsCreateResponse,
|
|
19
|
+
AppsCreateResponses,
|
|
20
|
+
AppsDeleteData,
|
|
21
|
+
AppsDeleteErrors,
|
|
22
|
+
AppsDeleteResponse,
|
|
23
|
+
AppsDeleteResponses,
|
|
24
|
+
AppsGetData,
|
|
25
|
+
AppsGetErrors,
|
|
26
|
+
AppsGetResponse,
|
|
27
|
+
AppsGetResponses,
|
|
28
|
+
AppsListData,
|
|
29
|
+
AppsListErrors,
|
|
30
|
+
AppsListResponse,
|
|
31
|
+
AppsListResponses,
|
|
5
32
|
ClientOptions,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
33
|
+
PreviewsGetData,
|
|
34
|
+
PreviewsGetErrors,
|
|
35
|
+
PreviewsGetResponse,
|
|
36
|
+
PreviewsGetResponses,
|
|
37
|
+
PreviewsListData,
|
|
38
|
+
PreviewsListErrors,
|
|
39
|
+
PreviewsListResponse,
|
|
40
|
+
PreviewsListResponses,
|
|
41
|
+
PreviewsTokenCreateData,
|
|
42
|
+
PreviewsTokenCreateErrors,
|
|
43
|
+
PreviewsTokenCreateResponse,
|
|
44
|
+
PreviewsTokenCreateResponses,
|
|
45
|
+
ReleasesGetData,
|
|
46
|
+
ReleasesGetErrors,
|
|
47
|
+
ReleasesGetResponse,
|
|
48
|
+
ReleasesGetResponses,
|
|
49
|
+
UsersCurrentData,
|
|
50
|
+
UsersCurrentErrors,
|
|
51
|
+
UsersCurrentResponse,
|
|
52
|
+
UsersCurrentResponses,
|
|
18
53
|
} from "./types.gen.js";
|