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
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
pathIgnorePatterns = ["**/dist/**", "**/out/**", "**/.output/**"]
|
|
4
4
|
|
|
5
5
|
[fmt]
|
|
6
|
-
# Keep the compact workflow readable; actionlint validates its YAML.
|
|
7
6
|
ignorePatterns = [
|
|
8
|
-
".github/workflows/pipeline.yml",
|
|
9
7
|
"**/routeTree.gen.ts",
|
|
10
8
|
"**/convex/_generated/**",
|
|
11
9
|
"**/.agents/**",
|
|
@@ -1,16 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": "0.1.0",
|
|
3
|
-
"platforms": [
|
|
4
|
-
|
|
5
|
-
"android",
|
|
6
|
-
"ios",
|
|
7
|
-
"windows",
|
|
8
|
-
"macos",
|
|
9
|
-
"linux",
|
|
10
|
-
"api",
|
|
11
|
-
"mcp",
|
|
12
|
-
"cli",
|
|
13
|
-
"typescript-sdk"
|
|
14
|
-
],
|
|
15
|
-
"features": ["authentication"]
|
|
3
|
+
"platforms": ["web", "android", "ios", "api", "mcp", "cli", "typescript-sdk"],
|
|
4
|
+
"features": ["authentication", "docs"]
|
|
16
5
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "disposabl-dev",
|
|
3
3
|
"private": true,
|
|
4
4
|
"scripts": {
|
|
5
|
-
"check": "bun run generate && turbo run typecheck lint && bun fmt --check
|
|
5
|
+
"check": "bun run generate && turbo run typecheck lint && bun fmt --check",
|
|
6
6
|
"build": "turbo build",
|
|
7
7
|
"dev": "turbo dev",
|
|
8
8
|
"lint": "turbo lint",
|
|
@@ -27,11 +27,11 @@
|
|
|
27
27
|
],
|
|
28
28
|
"catalog": {
|
|
29
29
|
"@convex-dev/auth": "2.0.0-beta.0",
|
|
30
|
-
"convex": "^1.
|
|
30
|
+
"convex": "^1.49.0",
|
|
31
31
|
"lucide-react": "^1.61.0",
|
|
32
32
|
"react": "^19.3.1",
|
|
33
33
|
"react-dom": "^19.3.1",
|
|
34
|
-
"@convex-dev/mcp": "0.1.0-alpha.
|
|
34
|
+
"@convex-dev/mcp": "0.1.0-alpha.7",
|
|
35
35
|
"@convex-dev/static-hosting": "0.2.1"
|
|
36
36
|
},
|
|
37
37
|
"patchedDependencies": {
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
# Backend code
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
- Read `convex/_generated/ai/guidelines.md` before changing Convex code.
|
|
4
|
+
- `schema.ts` contains tables only. Put argument and return validators in `validator.ts`.
|
|
5
|
+
- Keep the schema small. Store each fact once; derive what you can.
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
`convex/_generated/ai/guidelines.md` first** for important guidelines on
|
|
7
|
-
how to correctly use Convex APIs and patterns. The file contains rules that
|
|
8
|
-
override what you may have learned about Convex from training data.
|
|
7
|
+
## Modules
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
`
|
|
9
|
+
- `index.ts`: web/mobile functions. Resolve `userId`, then call the internal function with the same name.
|
|
10
|
+
- `internal.ts`: shared queries and mutations. Use `platforms: true` to expose functions to enabled platforms in `disposabl.json`.
|
|
11
|
+
- `actions/`: all actions, including ordinary and `"use node"` actions. Never put queries or mutations in a Node action file.
|
|
12
|
+
- Re-export ordinary platform actions from `internal.ts`. Call Node actions through `ctx.runAction`; never import a Node file into the default runtime.
|
|
13
|
+
- Use the kit's `internalQuery`, `internalMutation`, and `internalAction` builders, not `_generated/server` builders.
|
|
14
|
+
- Helpers do one specific job. Share them when another caller needs that same logic.
|
|
12
15
|
|
|
13
|
-
|
|
16
|
+
## Keep it simple
|
|
14
17
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
-
|
|
18
|
-
- Do not import these builders directly from `_generated/server` in application code. The kit wrappers own that import. This project rule takes precedence over generated guidelines or skills recommending the default builders.
|
|
18
|
+
- Keep every source file at 300 lines or fewer; regenerate generated files instead of editing them.
|
|
19
|
+
- Prefer clear, concise code over extra layers, fields, or abstractions.
|
|
20
|
+
- With each change, review it from a fresh perspective: simplify related code, remove duplication, and address nearby debt without expanding scope.
|
|
@@ -1,33 +1,11 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Backend
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
and ESLint.
|
|
3
|
+
Run `bun run dev` at the workspace root, or `bun run dev` here for Convex alone.
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
dashboard or via the CLI:
|
|
5
|
+
`apps`, `previews`, `appReleases`, and `githubConnections` hold application data. `users` provides authentication identities. App IDs are UUID v4 values; preview references are branch/worktree names, including `main`. Deletion permanently removes app, preview, and release records.
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
npx convex run myFunctions:myQuery '{"first": 1, "second": "Hello"}'
|
|
11
|
-
```
|
|
7
|
+
`index.ts` resolves the authenticated user for web/mobile. `internal.ts` implements operations; `platforms: true` exposes them through enabled API, MCP, SDK, and CLI platforms. Actions live under `actions/`. Put argument/return validators in `validator.ts`, and table definitions in `schema.ts`.
|
|
12
8
|
|
|
13
|
-
|
|
9
|
+
Managed setup needs `CONVEX_TEAM_ID` and `CONVEX_TEAM_TOKEN` on the service backend. GitHub repository creation uses Vercel Connect installation tokens, with `VERCEL_TOKEN`, `VERCEL_PROJECT_ID`, `VERCEL_TEAM_ID`, and `GITHUB_CONNECTOR`. `GITHUB_OWNER` and `GITHUB_INSTALLATION_ID` provide the default organization when the user has no connection.
|
|
14
10
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
```
|
|
18
|
-
npm create convex@latest -t bare
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
# App drafts and sandbox setup
|
|
22
|
-
|
|
23
|
-
App drafts require `website`; `cli`, `typescript`, and `python` require `api`, and `openai` and `claude` require `mcp`. App lists currently return at most 100 records. Existing records without platforms read as `website`.
|
|
24
|
-
|
|
25
|
-
Boat requires `BOAT_API_KEY` in the Convex deployment. Set `SANDBOX_OPENAI_API_KEY` to a separately scoped, budget-limited OpenAI API key before sending a message; it is exposed to code inside the sandbox. Creation and resume use `noEnv: true`. Codex credentials are written to protected files in its sandbox home, and healthy running sandboxes are reused without stopping them. The user-scoped MCP key is revoked on completion or after one hour, so long-running prompts can lose MCP access. An uncertain prompt submission stays locked for review instead of being retried automatically. Live sandbox provisioning, Codex credential loading, and dispatch have not been verified.
|
|
26
|
-
|
|
27
|
-
# MCP tools
|
|
28
|
-
|
|
29
|
-
Run `bun run dev` at the workspace root to start Turbo, or in this directory to start only the backend with `convex dev`.
|
|
30
|
-
|
|
31
|
-
The function builders still accept `platforms: true`, per-platform flags, and the legacy `mcp` flag. MCP server creation is still controlled by `disposabl.json`.
|
|
32
|
-
|
|
33
|
-
Tool discovery and platform generation are removed for now. The MCP server receives `createMcpTools({})`, so its tool list stays empty even when MCP is enabled and internal functions have `platforms: true`. The tool adapter remains available for future use.
|
|
11
|
+
Preview token creation reuses a named development deployment and returns a fresh development key. Keys are never stored in application tables. GitHub Actions reports the latest build results through verified OIDC identity. Enabled platforms without a published artifact have no download link.
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
"guidelinesHash": "b6b776e9d4dacfe8da23a58c9d11ab9cc9c505891c8f6b9fa9cdc69e4266ac37",
|
|
3
3
|
"agentsMdSectionHash": "5934f676ea9a332e7cd4a4f64aa23b59d926e9faca026c758d4b1f87d2101cc3",
|
|
4
4
|
"claudeMdHash": "5934f676ea9a332e7cd4a4f64aa23b59d926e9faca026c758d4b1f87d2101cc3",
|
|
5
|
-
"agentSkillsSha": "
|
|
5
|
+
"agentSkillsSha": "f60629d7c6c1f27eb58a56260546d2445049274d"
|
|
6
6
|
}
|
|
@@ -8,12 +8,25 @@
|
|
|
8
8
|
* @module
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
+
import type * as apps_actions_create from "../apps/actions/create.js";
|
|
12
|
+
import type * as apps_internal from "../apps/internal.js";
|
|
11
13
|
import type * as auth from "../auth.js";
|
|
14
|
+
import type * as github_actions_http from "../github/actions/http.js";
|
|
15
|
+
import type * as github_actions_internal from "../github/actions/internal.js";
|
|
16
|
+
import type * as github_actions_oidc from "../github/actions/oidc.js";
|
|
17
|
+
import type * as github_actions_provision from "../github/actions/provision.js";
|
|
18
|
+
import type * as github_actions_tokens from "../github/actions/tokens.js";
|
|
19
|
+
import type * as github_internal from "../github/internal.js";
|
|
12
20
|
import type * as http from "../http.js";
|
|
13
21
|
import type * as mcp from "../mcp.js";
|
|
14
|
-
import type * as
|
|
15
|
-
import type * as
|
|
16
|
-
import type * as
|
|
22
|
+
import type * as previews_internal from "../previews/internal.js";
|
|
23
|
+
import type * as previews_token_actions_create from "../previews/token/actions/create.js";
|
|
24
|
+
import type * as previews_token_actions_management from "../previews/token/actions/management.js";
|
|
25
|
+
import type * as previews_token_internal from "../previews/token/internal.js";
|
|
26
|
+
import type * as releases_internal from "../releases/internal.js";
|
|
27
|
+
import type * as users_index from "../users/index.js";
|
|
28
|
+
import type * as users_internal from "../users/internal.js";
|
|
29
|
+
import type * as validator from "../validator.js";
|
|
17
30
|
|
|
18
31
|
import type {
|
|
19
32
|
ApiFromModules,
|
|
@@ -22,12 +35,25 @@ import type {
|
|
|
22
35
|
} from "convex/server";
|
|
23
36
|
|
|
24
37
|
declare const fullApi: ApiFromModules<{
|
|
38
|
+
"apps/actions/create": typeof apps_actions_create;
|
|
39
|
+
"apps/internal": typeof apps_internal;
|
|
25
40
|
auth: typeof auth;
|
|
41
|
+
"github/actions/http": typeof github_actions_http;
|
|
42
|
+
"github/actions/internal": typeof github_actions_internal;
|
|
43
|
+
"github/actions/oidc": typeof github_actions_oidc;
|
|
44
|
+
"github/actions/provision": typeof github_actions_provision;
|
|
45
|
+
"github/actions/tokens": typeof github_actions_tokens;
|
|
46
|
+
"github/internal": typeof github_internal;
|
|
26
47
|
http: typeof http;
|
|
27
48
|
mcp: typeof mcp;
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
|
|
49
|
+
"previews/internal": typeof previews_internal;
|
|
50
|
+
"previews/token/actions/create": typeof previews_token_actions_create;
|
|
51
|
+
"previews/token/actions/management": typeof previews_token_actions_management;
|
|
52
|
+
"previews/token/internal": typeof previews_token_internal;
|
|
53
|
+
"releases/internal": typeof releases_internal;
|
|
54
|
+
"users/index": typeof users_index;
|
|
55
|
+
"users/internal": typeof users_internal;
|
|
56
|
+
validator: typeof validator;
|
|
31
57
|
}>;
|
|
32
58
|
|
|
33
59
|
/**
|
|
@@ -32,6 +32,14 @@ type Env = {
|
|
|
32
32
|
readonly CONVEX_SITE_URL: string;
|
|
33
33
|
readonly AUTH_JWKS: string;
|
|
34
34
|
readonly AUTH_PRIVATE_KEY: string;
|
|
35
|
+
readonly CONVEX_TEAM_ID: string | undefined;
|
|
36
|
+
readonly CONVEX_TEAM_TOKEN: string | undefined;
|
|
37
|
+
readonly GITHUB_CONNECTOR: string | undefined;
|
|
38
|
+
readonly GITHUB_INSTALLATION_ID: string | undefined;
|
|
39
|
+
readonly GITHUB_OWNER: string | undefined;
|
|
40
|
+
readonly VERCEL_PROJECT_ID: string | undefined;
|
|
41
|
+
readonly VERCEL_TEAM_ID: string | undefined;
|
|
42
|
+
readonly VERCEL_TOKEN: string | undefined;
|
|
35
43
|
};
|
|
36
44
|
|
|
37
45
|
/**
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
identityFields,
|
|
3
|
+
internalAction,
|
|
4
|
+
} from "@disposabl/disposabl-kit/server/lib/functions";
|
|
5
|
+
import { internal } from "../../_generated/api";
|
|
6
|
+
import { appArgs, appResult } from "../../validator";
|
|
7
|
+
import type { Infer } from "convex/values";
|
|
8
|
+
type AppResult = Infer<typeof appResult>;
|
|
9
|
+
|
|
10
|
+
export const create = internalAction({
|
|
11
|
+
platforms: true,
|
|
12
|
+
args: { ...identityFields, ...appArgs },
|
|
13
|
+
returns: appResult,
|
|
14
|
+
handler: async (ctx, args): Promise<AppResult> =>
|
|
15
|
+
ctx.runMutation(internal.apps.internal.insert, {
|
|
16
|
+
...args,
|
|
17
|
+
appId: crypto.randomUUID(),
|
|
18
|
+
}),
|
|
19
|
+
});
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import {
|
|
2
|
+
identityFields,
|
|
3
|
+
internalMutation,
|
|
4
|
+
internalQuery,
|
|
5
|
+
} from "@disposabl/disposabl-kit/server/lib/functions";
|
|
6
|
+
import {
|
|
7
|
+
paginationOptsValidator,
|
|
8
|
+
paginationResultValidator,
|
|
9
|
+
} from "convex/server";
|
|
10
|
+
import { ConvexError, v, type Infer } from "convex/values";
|
|
11
|
+
import { appArgs, appResult } from "../validator";
|
|
12
|
+
import { githubConnection } from "../validator";
|
|
13
|
+
import { env } from "../_generated/server";
|
|
14
|
+
import type { Doc } from "../_generated/dataModel";
|
|
15
|
+
import type { QueryCtx } from "../_generated/server";
|
|
16
|
+
type AppResult = Infer<typeof appResult>;
|
|
17
|
+
|
|
18
|
+
export { create } from "./actions/create";
|
|
19
|
+
export const insert = internalMutation({
|
|
20
|
+
args: { ...identityFields, ...appArgs, appId: v.string() },
|
|
21
|
+
returns: appResult,
|
|
22
|
+
handler: async (ctx, args) => {
|
|
23
|
+
assertAppId(args.appId);
|
|
24
|
+
const name = args.name.trim();
|
|
25
|
+
if (!name || name.length > 214)
|
|
26
|
+
throw new ConvexError("App name must contain 1–214 characters.");
|
|
27
|
+
const platforms = [...new Set(args.platforms)];
|
|
28
|
+
const id = await ctx.db.insert("apps", {
|
|
29
|
+
userId: args.userId,
|
|
30
|
+
appId: args.appId,
|
|
31
|
+
name,
|
|
32
|
+
platforms,
|
|
33
|
+
});
|
|
34
|
+
return presentApp((await ctx.db.get("apps", id))!);
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
export const list = internalQuery({
|
|
38
|
+
platforms: true,
|
|
39
|
+
args: { ...identityFields, paginationOpts: paginationOptsValidator },
|
|
40
|
+
returns: paginationResultValidator(appResult),
|
|
41
|
+
handler: async (ctx, { userId, paginationOpts }) => {
|
|
42
|
+
if (
|
|
43
|
+
!Number.isInteger(paginationOpts.numItems) ||
|
|
44
|
+
paginationOpts.numItems < 1 ||
|
|
45
|
+
paginationOpts.numItems > 100
|
|
46
|
+
)
|
|
47
|
+
throw new ConvexError("Page size must be between 1 and 100.");
|
|
48
|
+
const result = await ctx.db
|
|
49
|
+
.query("apps")
|
|
50
|
+
.withIndex("by_userId", (q) => q.eq("userId", userId))
|
|
51
|
+
.order("desc")
|
|
52
|
+
.paginate(paginationOpts);
|
|
53
|
+
return { ...result, page: result.page.map(presentApp) };
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
export const get = internalQuery({
|
|
57
|
+
platforms: true,
|
|
58
|
+
args: { ...identityFields, appId: v.string() },
|
|
59
|
+
returns: appResult,
|
|
60
|
+
handler: async (ctx, { userId, appId }) =>
|
|
61
|
+
presentApp(await ownedApp(ctx, userId, appId)),
|
|
62
|
+
});
|
|
63
|
+
const remove = internalMutation({
|
|
64
|
+
platforms: true,
|
|
65
|
+
args: { ...identityFields, appId: v.string() },
|
|
66
|
+
returns: v.null(),
|
|
67
|
+
handler: async (ctx, { userId, appId }) => {
|
|
68
|
+
const app = await ownedApp(ctx, userId, appId);
|
|
69
|
+
for await (const preview of ctx.db
|
|
70
|
+
.query("previews")
|
|
71
|
+
.withIndex("by_appId_reference", (q) => q.eq("appId", appId))) {
|
|
72
|
+
await ctx.db.delete("previews", preview._id);
|
|
73
|
+
}
|
|
74
|
+
const production = await ctx.db
|
|
75
|
+
.query("appReleases")
|
|
76
|
+
.withIndex("by_appId", (q) => q.eq("appId", appId))
|
|
77
|
+
.unique();
|
|
78
|
+
if (production) await ctx.db.delete("appReleases", production._id);
|
|
79
|
+
await ctx.db.delete("apps", app._id);
|
|
80
|
+
return null;
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
export { remove as delete };
|
|
84
|
+
|
|
85
|
+
function assertAppId(appId: string) {
|
|
86
|
+
if (
|
|
87
|
+
!/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/.test(
|
|
88
|
+
appId,
|
|
89
|
+
)
|
|
90
|
+
)
|
|
91
|
+
throw new ConvexError("appId must be a lowercase UUID v4.");
|
|
92
|
+
}
|
|
93
|
+
export async function ownedApp(
|
|
94
|
+
ctx: Pick<QueryCtx, "db">,
|
|
95
|
+
userId: string,
|
|
96
|
+
appId: string,
|
|
97
|
+
) {
|
|
98
|
+
assertAppId(appId);
|
|
99
|
+
const app = await ctx.db
|
|
100
|
+
.query("apps")
|
|
101
|
+
.withIndex("by_appId", (q) => q.eq("appId", appId))
|
|
102
|
+
.unique();
|
|
103
|
+
if (!app || app.userId !== userId) throw new ConvexError("App not found.");
|
|
104
|
+
return app;
|
|
105
|
+
}
|
|
106
|
+
function presentApp(app: Doc<"apps">): AppResult {
|
|
107
|
+
return {
|
|
108
|
+
appId: app.appId,
|
|
109
|
+
name: app.name,
|
|
110
|
+
platforms: app.platforms,
|
|
111
|
+
...(app.githubOwner ? { githubOwner: app.githubOwner } : {}),
|
|
112
|
+
...(app.githubRepo ? { githubRepo: app.githubRepo } : {}),
|
|
113
|
+
createdAt: app._creationTime,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
export const githubApp = internalQuery({
|
|
117
|
+
args: { appId: v.string() },
|
|
118
|
+
returns: v.union(
|
|
119
|
+
v.null(),
|
|
120
|
+
v.object({
|
|
121
|
+
githubOwner: v.string(),
|
|
122
|
+
githubRepo: v.string(),
|
|
123
|
+
installationId: v.string(),
|
|
124
|
+
}),
|
|
125
|
+
),
|
|
126
|
+
handler: async (ctx, { appId }) => {
|
|
127
|
+
assertAppId(appId);
|
|
128
|
+
const app = await ctx.db
|
|
129
|
+
.query("apps")
|
|
130
|
+
.withIndex("by_appId", (q) => q.eq("appId", appId))
|
|
131
|
+
.unique();
|
|
132
|
+
if (!app?.githubOwner || !app.githubRepo) return null;
|
|
133
|
+
const connection = await ctx.db
|
|
134
|
+
.query("githubConnections")
|
|
135
|
+
.withIndex("by_userId_owner", (q) =>
|
|
136
|
+
q.eq("userId", app.userId).eq("owner", app.githubOwner!),
|
|
137
|
+
)
|
|
138
|
+
.unique();
|
|
139
|
+
const installationId =
|
|
140
|
+
connection?.installationId ??
|
|
141
|
+
(app.githubOwner === env.GITHUB_OWNER?.toLowerCase()
|
|
142
|
+
? env.GITHUB_INSTALLATION_ID
|
|
143
|
+
: undefined);
|
|
144
|
+
return installationId
|
|
145
|
+
? {
|
|
146
|
+
githubOwner: app.githubOwner,
|
|
147
|
+
githubRepo: app.githubRepo,
|
|
148
|
+
installationId,
|
|
149
|
+
}
|
|
150
|
+
: null;
|
|
151
|
+
},
|
|
152
|
+
});
|
|
153
|
+
/** Only trusted repository provisioning can link an app. */
|
|
154
|
+
export const connectGithub = internalMutation({
|
|
155
|
+
args: {
|
|
156
|
+
...identityFields,
|
|
157
|
+
appId: v.string(),
|
|
158
|
+
githubOwner: v.string(),
|
|
159
|
+
githubRepo: v.string(),
|
|
160
|
+
},
|
|
161
|
+
returns: v.null(),
|
|
162
|
+
handler: async (ctx, { userId, appId, githubOwner, githubRepo }) => {
|
|
163
|
+
const app = await ownedApp(ctx, userId, appId);
|
|
164
|
+
githubOwner = githubOwner.toLowerCase();
|
|
165
|
+
if (
|
|
166
|
+
app.githubOwner &&
|
|
167
|
+
(app.githubOwner !== githubOwner || app.githubRepo !== githubRepo)
|
|
168
|
+
)
|
|
169
|
+
throw new ConvexError("App is already linked to a different repository.");
|
|
170
|
+
await ctx.db.patch("apps", app._id, { githubOwner, githubRepo });
|
|
171
|
+
return null;
|
|
172
|
+
},
|
|
173
|
+
});
|
|
174
|
+
export const githubSetup = internalQuery({
|
|
175
|
+
args: { ...identityFields, appId: v.string() },
|
|
176
|
+
returns: v.object({
|
|
177
|
+
app: appResult,
|
|
178
|
+
connection: v.union(githubConnection, v.null()),
|
|
179
|
+
}),
|
|
180
|
+
handler: async (ctx, { userId, appId }) => {
|
|
181
|
+
const app = await ownedApp(ctx, userId, appId);
|
|
182
|
+
const connection = await ctx.db
|
|
183
|
+
.query("githubConnections")
|
|
184
|
+
.withIndex("by_userId", (q) => q.eq("userId", userId))
|
|
185
|
+
.order("desc")
|
|
186
|
+
.first();
|
|
187
|
+
return {
|
|
188
|
+
app: presentApp(app),
|
|
189
|
+
connection: connection
|
|
190
|
+
? {
|
|
191
|
+
owner: connection.owner,
|
|
192
|
+
installationId: connection.installationId,
|
|
193
|
+
}
|
|
194
|
+
: null,
|
|
195
|
+
};
|
|
196
|
+
},
|
|
197
|
+
});
|
|
@@ -12,4 +12,4 @@ export const {
|
|
|
12
12
|
} = setupUsernamePassword(auth, {
|
|
13
13
|
component: components.authPassword,
|
|
14
14
|
usernameComponent: components.authUsername,
|
|
15
|
-
}).attachUserCallbacks({ createUser: internal.users.createUser });
|
|
15
|
+
}).attachUserCallbacks({ createUser: internal.users.internal.createUser });
|
|
@@ -11,6 +11,14 @@ const app = defineApp({
|
|
|
11
11
|
env: {
|
|
12
12
|
AUTH_PRIVATE_KEY: v.string(),
|
|
13
13
|
AUTH_JWKS: v.string(),
|
|
14
|
+
CONVEX_TEAM_ID: v.optional(v.string()),
|
|
15
|
+
CONVEX_TEAM_TOKEN: v.optional(v.string()),
|
|
16
|
+
VERCEL_TOKEN: v.optional(v.string()),
|
|
17
|
+
VERCEL_PROJECT_ID: v.optional(v.string()),
|
|
18
|
+
VERCEL_TEAM_ID: v.optional(v.string()),
|
|
19
|
+
GITHUB_CONNECTOR: v.optional(v.string()),
|
|
20
|
+
GITHUB_OWNER: v.optional(v.string()),
|
|
21
|
+
GITHUB_INSTALLATION_ID: v.optional(v.string()),
|
|
14
22
|
},
|
|
15
23
|
});
|
|
16
24
|
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { httpAction } from "../../_generated/server";
|
|
2
|
+
import { internal } from "../../_generated/api";
|
|
3
|
+
|
|
4
|
+
export const token = httpAction(async (ctx, request) => {
|
|
5
|
+
try {
|
|
6
|
+
const body = await request.json();
|
|
7
|
+
const token = request.headers.get("Authorization")?.replace(/^Bearer /, "");
|
|
8
|
+
if (!token) return new Response("Unauthorized", { status: 401 });
|
|
9
|
+
const result = await ctx.runAction(internal.github.actions.internal.token, {
|
|
10
|
+
appId: body.appId,
|
|
11
|
+
token,
|
|
12
|
+
});
|
|
13
|
+
return Response.json(result, { headers: { "Cache-Control": "no-store" } });
|
|
14
|
+
} catch {
|
|
15
|
+
return Response.json(
|
|
16
|
+
{ error: "Actions identity or app binding rejected." },
|
|
17
|
+
{ status: 403 },
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
export const report = httpAction(async (ctx, request) => {
|
|
22
|
+
try {
|
|
23
|
+
const body = await request.json();
|
|
24
|
+
const token = request.headers.get("Authorization")?.replace(/^Bearer /, "");
|
|
25
|
+
if (!token) return new Response("Unauthorized", { status: 401 });
|
|
26
|
+
await ctx.runAction(internal.github.actions.internal.report, {
|
|
27
|
+
...body,
|
|
28
|
+
token,
|
|
29
|
+
});
|
|
30
|
+
return Response.json(
|
|
31
|
+
{ ok: true },
|
|
32
|
+
{ headers: { "Cache-Control": "no-store" } },
|
|
33
|
+
);
|
|
34
|
+
} catch {
|
|
35
|
+
return Response.json(
|
|
36
|
+
{ error: "Actions report rejected." },
|
|
37
|
+
{ status: 403 },
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
});
|