devpush 0.0.0-stage → 1.0.0-beta.4

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.
Files changed (456) hide show
  1. package/README.md +22 -2
  2. package/agent-release.json +37 -0
  3. package/dist/package/LICENSE.md +21 -0
  4. package/dist/package/migrate.mjs +182 -0
  5. package/dist/package/plugins.mjs +125 -0
  6. package/dist/package/vite.mjs +439 -0
  7. package/package.json +168 -3
  8. package/public/apple-touch-icon.png +0 -0
  9. package/public/favicon.svg +1 -0
  10. package/public/logo-email.png +0 -0
  11. package/public/robots.txt +3 -0
  12. package/public/social.png +0 -0
  13. package/src/cloudflare-runtime.d.ts +78 -0
  14. package/src/components/about-dialog.tsx +70 -0
  15. package/src/components/copy-button.tsx +74 -0
  16. package/src/components/logo-mark.tsx +20 -0
  17. package/src/components/pending-collection.tsx +103 -0
  18. package/src/components/resource-avatar.tsx +65 -0
  19. package/src/components/route-error-state.tsx +95 -0
  20. package/src/components/section-navigation.tsx +39 -0
  21. package/src/components/settings-layout.tsx +111 -0
  22. package/src/components/storage-capabilities.tsx +11 -0
  23. package/src/components/table-pager.tsx +101 -0
  24. package/src/components/ui/alert-dialog.tsx +180 -0
  25. package/src/components/ui/alert.tsx +78 -0
  26. package/src/components/ui/avatar.tsx +58 -0
  27. package/src/components/ui/badge.tsx +49 -0
  28. package/src/components/ui/button-group.tsx +38 -0
  29. package/src/components/ui/button.tsx +67 -0
  30. package/src/components/ui/card.tsx +82 -0
  31. package/src/components/ui/chart.tsx +307 -0
  32. package/src/components/ui/checkbox.tsx +30 -0
  33. package/src/components/ui/combobox.tsx +256 -0
  34. package/src/components/ui/dialog.tsx +163 -0
  35. package/src/components/ui/dropdown-menu.tsx +110 -0
  36. package/src/components/ui/empty.tsx +65 -0
  37. package/src/components/ui/field.tsx +192 -0
  38. package/src/components/ui/input-group.tsx +118 -0
  39. package/src/components/ui/input-otp.tsx +70 -0
  40. package/src/components/ui/input.tsx +19 -0
  41. package/src/components/ui/label.tsx +24 -0
  42. package/src/components/ui/pagination.tsx +34 -0
  43. package/src/components/ui/popover.tsx +86 -0
  44. package/src/components/ui/select.tsx +145 -0
  45. package/src/components/ui/skeleton.tsx +19 -0
  46. package/src/components/ui/sonner.tsx +47 -0
  47. package/src/components/ui/switch.tsx +31 -0
  48. package/src/components/ui/table.tsx +81 -0
  49. package/src/components/ui/textarea.tsx +18 -0
  50. package/src/components/ui/tooltip.tsx +55 -0
  51. package/src/features/admin/admin-settings.tsx +1048 -0
  52. package/src/features/auth/current-user-context-query.ts +11 -0
  53. package/src/features/auth/login-form.tsx +442 -0
  54. package/src/features/auth/sign-out-menu-item.tsx +42 -0
  55. package/src/features/deployments/deployment-actions.tsx +336 -0
  56. package/src/features/deployments/deployment-alias-badge.tsx +35 -0
  57. package/src/features/deployments/deployment-detail.tsx +596 -0
  58. package/src/features/deployments/deployment-filters.ts +66 -0
  59. package/src/features/deployments/deployment-list.tsx +465 -0
  60. package/src/features/deployments/deployment-visit-links.tsx +104 -0
  61. package/src/features/deployments/deployments-page.tsx +376 -0
  62. package/src/features/logs/log-scroll-area.tsx +69 -0
  63. package/src/features/notifications/email-preferences.tsx +232 -0
  64. package/src/features/onboarding/profile-onboarding.tsx +162 -0
  65. package/src/features/plugins/contributions.tsx +118 -0
  66. package/src/features/projects/backup-job-logs.tsx +143 -0
  67. package/src/features/projects/backup-policy-delete-dialog.tsx +82 -0
  68. package/src/features/projects/backup-restore-actions.tsx +573 -0
  69. package/src/features/projects/backup-status-icon.tsx +33 -0
  70. package/src/features/projects/backup-target-list.tsx +222 -0
  71. package/src/features/projects/backup-timestamp.tsx +32 -0
  72. package/src/features/projects/backup-volume-picker.tsx +158 -0
  73. package/src/features/projects/compose-service-input.tsx +64 -0
  74. package/src/features/projects/deploy-readiness.ts +28 -0
  75. package/src/features/projects/environment-dot.tsx +91 -0
  76. package/src/features/projects/log-keyword-filter.tsx +48 -0
  77. package/src/features/projects/manual-deploy-dialog.tsx +563 -0
  78. package/src/features/projects/pending-section.ts +26 -0
  79. package/src/features/projects/project-backup-details-pending.tsx +305 -0
  80. package/src/features/projects/project-backup-details.tsx +936 -0
  81. package/src/features/projects/project-backup-policy.tsx +644 -0
  82. package/src/features/projects/project-backup-utils.ts +190 -0
  83. package/src/features/projects/project-backups-pending.tsx +136 -0
  84. package/src/features/projects/project-backups.tsx +876 -0
  85. package/src/features/projects/project-environment-settings.tsx +1128 -0
  86. package/src/features/projects/project-heading.tsx +68 -0
  87. package/src/features/projects/project-layout.tsx +188 -0
  88. package/src/features/projects/project-logs.tsx +461 -0
  89. package/src/features/projects/project-overview.tsx +280 -0
  90. package/src/features/projects/project-route-pending.tsx +1064 -0
  91. package/src/features/projects/project-routing-settings.tsx +663 -0
  92. package/src/features/projects/project-settings-section.tsx +64 -0
  93. package/src/features/projects/project-settings-utils.ts +101 -0
  94. package/src/features/projects/project-settings.tsx +1472 -0
  95. package/src/features/projects/repository-picker-dialog.tsx +404 -0
  96. package/src/features/repositories/new-project-dialog-launcher.tsx +44 -0
  97. package/src/features/repositories/new-project-dialog.tsx +1204 -0
  98. package/src/features/repositories/new-project-pending.tsx +28 -0
  99. package/src/features/repositories/repository-list-pending.tsx +59 -0
  100. package/src/features/servers/server-availability-alert.tsx +44 -0
  101. package/src/features/servers/server-availability.ts +29 -0
  102. package/src/features/servers/server-avatar.tsx +52 -0
  103. package/src/features/servers/server-detail-pending.tsx +315 -0
  104. package/src/features/servers/server-detail.tsx +855 -0
  105. package/src/features/servers/server-metric-chart-pending.tsx +38 -0
  106. package/src/features/servers/server-metric-chart.tsx +182 -0
  107. package/src/features/servers/server-metric-format.ts +50 -0
  108. package/src/features/servers/server-metrics-pending.tsx +75 -0
  109. package/src/features/servers/server-metrics.tsx +136 -0
  110. package/src/features/servers/team-servers.tsx +432 -0
  111. package/src/features/settings/settings-route-pending.tsx +406 -0
  112. package/src/features/teams/backup-storage-settings.tsx +483 -0
  113. package/src/features/teams/navigation.ts +51 -0
  114. package/src/features/teams/new-team-dialog.tsx +132 -0
  115. package/src/features/teams/pending-section.ts +19 -0
  116. package/src/features/teams/team-header.tsx +1286 -0
  117. package/src/features/teams/team-heading.tsx +57 -0
  118. package/src/features/teams/team-home.tsx +391 -0
  119. package/src/features/teams/team-invite.tsx +155 -0
  120. package/src/features/teams/team-route-pending.tsx +505 -0
  121. package/src/features/teams/team-settings.tsx +1555 -0
  122. package/src/features/teams/use-workspace-updates.ts +126 -0
  123. package/src/features/users/api-keys-settings.tsx +544 -0
  124. package/src/features/users/api-scope-selection.tsx +269 -0
  125. package/src/features/users/connected-apps-settings.tsx +449 -0
  126. package/src/features/users/mcp-consent.tsx +220 -0
  127. package/src/features/users/profile-picture.tsx +171 -0
  128. package/src/features/users/user-settings.tsx +1064 -0
  129. package/src/lib/account-settings-schema.ts +78 -0
  130. package/src/lib/action-feedback.ts +81 -0
  131. package/src/lib/admin-search-schema.ts +8 -0
  132. package/src/lib/agent-release.d.mts +21 -0
  133. package/src/lib/agent-release.mjs +90 -0
  134. package/src/lib/allowlist-schema.ts +79 -0
  135. package/src/lib/api-key-schema.ts +176 -0
  136. package/src/lib/auth/client.ts +20 -0
  137. package/src/lib/avatar-schema.ts +11 -0
  138. package/src/lib/backup-cron.ts +118 -0
  139. package/src/lib/backup-database.ts +41 -0
  140. package/src/lib/backup-feature.ts +2 -0
  141. package/src/lib/backup-paths.ts +7 -0
  142. package/src/lib/backup-policy-schema.ts +85 -0
  143. package/src/lib/backup-resource-schema.ts +12 -0
  144. package/src/lib/backup-restore-schema.ts +15 -0
  145. package/src/lib/backup-storage-schema.ts +55 -0
  146. package/src/lib/deferred-module.ts +38 -0
  147. package/src/lib/deployment-logs-query.ts +63 -0
  148. package/src/lib/display-name.ts +7 -0
  149. package/src/lib/error-message.ts +119 -0
  150. package/src/lib/form-errors.ts +10 -0
  151. package/src/lib/internal-redirect.ts +25 -0
  152. package/src/lib/manual-deploy-options-query.ts +21 -0
  153. package/src/lib/notification-preferences.ts +43 -0
  154. package/src/lib/onboarding.ts +11 -0
  155. package/src/lib/operation-logs-query.ts +51 -0
  156. package/src/lib/page-head.ts +14 -0
  157. package/src/lib/project-context-query.ts +257 -0
  158. package/src/lib/project-creation-schema.ts +64 -0
  159. package/src/lib/project-env-schema.ts +23 -0
  160. package/src/lib/project-environments-schema.ts +56 -0
  161. package/src/lib/project-routing-schema.ts +94 -0
  162. package/src/lib/project-runtime-config.ts +131 -0
  163. package/src/lib/project-settings-schema.ts +75 -0
  164. package/src/lib/public-api-schema.ts +128 -0
  165. package/src/lib/public-error.ts +337 -0
  166. package/src/lib/query.ts +13 -0
  167. package/src/lib/repository-selection-query.ts +11 -0
  168. package/src/lib/resource-cache.ts +30 -0
  169. package/src/lib/runtime-id.ts +19 -0
  170. package/src/lib/search.ts +14 -0
  171. package/src/lib/server-context-query.ts +43 -0
  172. package/src/lib/server-name-schema.ts +11 -0
  173. package/src/lib/settings-conflict.ts +45 -0
  174. package/src/lib/settings-version.ts +7 -0
  175. package/src/lib/team-context-query.ts +126 -0
  176. package/src/lib/team-context-schema.ts +8 -0
  177. package/src/lib/team-forms-schema.ts +45 -0
  178. package/src/lib/team-role.ts +13 -0
  179. package/src/lib/team-settings-schema.ts +48 -0
  180. package/src/lib/urls.ts +3 -0
  181. package/src/lib/use-avatar-input.ts +61 -0
  182. package/src/lib/use-refresh-error.ts +18 -0
  183. package/src/lib/use-settings-version.ts +23 -0
  184. package/src/lib/utils.ts +6 -0
  185. package/src/lib/validation.ts +5 -0
  186. package/src/lib/workspace-updates.ts +53 -0
  187. package/src/package/config.ts +10 -0
  188. package/src/package/env.mjs +54 -0
  189. package/src/package/migrate-api.d.ts +5 -0
  190. package/src/package/migrate.ts +56 -0
  191. package/src/package/plugins.ts +141 -0
  192. package/src/package/sqlite.mjs +2 -0
  193. package/src/package/vite-api.d.ts +5 -0
  194. package/src/package/vite.ts +324 -0
  195. package/src/package/watch-guard.cjs +26 -0
  196. package/src/plugins/client.ts +57 -0
  197. package/src/plugins/contract.ts +188 -0
  198. package/src/plugins/default.server.ts +4 -0
  199. package/src/plugins/default.ui.ts +4 -0
  200. package/src/plugins/operations.ts +45 -0
  201. package/src/plugins/server.ts +197 -0
  202. package/src/plugins/version.ts +1 -0
  203. package/src/routeTree.gen.ts +1275 -0
  204. package/src/router.tsx +46 -0
  205. package/src/routes/$teamSlug.index.tsx +53 -0
  206. package/src/routes/$teamSlug.new-project.tsx +13 -0
  207. package/src/routes/$teamSlug.projects.$projectName.backups.$backupId.tsx +40 -0
  208. package/src/routes/$teamSlug.projects.$projectName.backups.tsx +82 -0
  209. package/src/routes/$teamSlug.projects.$projectName.deployments.$deploymentId.tsx +52 -0
  210. package/src/routes/$teamSlug.projects.$projectName.deployments.tsx +86 -0
  211. package/src/routes/$teamSlug.projects.$projectName.logs.tsx +55 -0
  212. package/src/routes/$teamSlug.projects.$projectName.settings.tsx +51 -0
  213. package/src/routes/$teamSlug.projects.$projectName.tsx +106 -0
  214. package/src/routes/$teamSlug.projects.tsx +40 -0
  215. package/src/routes/$teamSlug.servers.$serverId.tsx +31 -0
  216. package/src/routes/$teamSlug.servers.index.tsx +59 -0
  217. package/src/routes/$teamSlug.servers.tsx +7 -0
  218. package/src/routes/$teamSlug.settings.tsx +56 -0
  219. package/src/routes/$teamSlug.tsx +86 -0
  220. package/src/routes/[.]well-known.oauth-authorization-server.api.auth.ts +13 -0
  221. package/src/routes/[.]well-known.oauth-protected-resource.mcp.ts +6 -0
  222. package/src/routes/__root.tsx +155 -0
  223. package/src/routes/admin.tsx +55 -0
  224. package/src/routes/api/agents/certificates.ts +21 -0
  225. package/src/routes/api/agents/credentials/rotate.ts +22 -0
  226. package/src/routes/api/agents/heartbeat.ts +42 -0
  227. package/src/routes/api/agents/job-logs.ts +22 -0
  228. package/src/routes/api/agents/jobs/complete.ts +22 -0
  229. package/src/routes/api/agents/jobs/next.ts +29 -0
  230. package/src/routes/api/agents/jobs/progress.ts +32 -0
  231. package/src/routes/api/agents/jobs/status.ts +22 -0
  232. package/src/routes/api/agents/register.ts +45 -0
  233. package/src/routes/api/agents/runtime-logs.ts +22 -0
  234. package/src/routes/api/agents/switch.ts +25 -0
  235. package/src/routes/api/auth/$.ts +38 -0
  236. package/src/routes/api/cron/backups.ts +33 -0
  237. package/src/routes/api/cron/maintenance.ts +30 -0
  238. package/src/routes/api/github/install.callback.ts +51 -0
  239. package/src/routes/api/github/install.ts +41 -0
  240. package/src/routes/api/github/webhook.ts +11 -0
  241. package/src/routes/api/health.ts +19 -0
  242. package/src/routes/api/install/agent.$token.ts +50 -0
  243. package/src/routes/api/install/agent.binary.ts +83 -0
  244. package/src/routes/api/install/agent.checksum.ts +45 -0
  245. package/src/routes/api/install/agent.ts +26 -0
  246. package/src/routes/api/plugins/$.ts +11 -0
  247. package/src/routes/api/v1/$.ts +15 -0
  248. package/src/routes/api/workspaces/updates.ts +8 -0
  249. package/src/routes/auth.login.tsx +50 -0
  250. package/src/routes/deployments.$deploymentId.unavailable.tsx +21 -0
  251. package/src/routes/index.tsx +23 -0
  252. package/src/routes/invites.$token.tsx +35 -0
  253. package/src/routes/mcp.ts +13 -0
  254. package/src/routes/oauth.consent.tsx +54 -0
  255. package/src/routes/onboarding.tsx +37 -0
  256. package/src/routes/onboarding.workspace.tsx +44 -0
  257. package/src/routes/settings.tsx +30 -0
  258. package/src/routes/uploads/avatars/$fileName.ts +44 -0
  259. package/src/server/admin/access.ts +67 -0
  260. package/src/server/admin/functions.ts +122 -0
  261. package/src/server/admin/service.ts +260 -0
  262. package/src/server/agents/backup-state.ts +210 -0
  263. package/src/server/agents/certificates.ts +96 -0
  264. package/src/server/agents/claims.ts +116 -0
  265. package/src/server/agents/cleanup.ts +52 -0
  266. package/src/server/agents/compatibility.ts +116 -0
  267. package/src/server/agents/completion.ts +83 -0
  268. package/src/server/agents/container-cleanup-state.ts +51 -0
  269. package/src/server/agents/deployment-state.ts +111 -0
  270. package/src/server/agents/job-payloads.ts +159 -0
  271. package/src/server/agents/jobs.ts +1293 -0
  272. package/src/server/agents/protocol.ts +400 -0
  273. package/src/server/agents/reconciliation.ts +43 -0
  274. package/src/server/agents/runtime-logs.ts +337 -0
  275. package/src/server/agents/runtime-state.ts +125 -0
  276. package/src/server/api/admission.ts +12 -0
  277. package/src/server/api/authorization.ts +115 -0
  278. package/src/server/api/credentials.ts +569 -0
  279. package/src/server/api/cursors.ts +72 -0
  280. package/src/server/api/errors.ts +24 -0
  281. package/src/server/api/functions.ts +60 -0
  282. package/src/server/api/handler.ts +274 -0
  283. package/src/server/api/mutation-operations.ts +913 -0
  284. package/src/server/api/operation-context.ts +139 -0
  285. package/src/server/api/operation-contract.ts +1099 -0
  286. package/src/server/api/operations.ts +64 -0
  287. package/src/server/api/read-operations.ts +891 -0
  288. package/src/server/api/retention.ts +33 -0
  289. package/src/server/auth/access.ts +109 -0
  290. package/src/server/auth/auth-methods.ts +28 -0
  291. package/src/server/auth/better-auth.ts +518 -0
  292. package/src/server/auth/context.ts +28 -0
  293. package/src/server/auth/email-change.ts +47 -0
  294. package/src/server/auth/email-delivery.ts +51 -0
  295. package/src/server/auth/provider-identity.ts +19 -0
  296. package/src/server/auth/provider-tokens.ts +27 -0
  297. package/src/server/auth/session.server.ts +19 -0
  298. package/src/server/backups/database-commands.ts +40 -0
  299. package/src/server/backups/destination.ts +12 -0
  300. package/src/server/backups/feature.ts +6 -0
  301. package/src/server/backups/policy-validation.ts +51 -0
  302. package/src/server/backups/queue-state.ts +137 -0
  303. package/src/server/backups/service.ts +918 -0
  304. package/src/server/backups/storage-functions.ts +42 -0
  305. package/src/server/backups/storage-state.ts +67 -0
  306. package/src/server/backups/storage.ts +237 -0
  307. package/src/server/config.ts +274 -0
  308. package/src/server/db/atomic.ts +16 -0
  309. package/src/server/db/d1-connection.ts +83 -0
  310. package/src/server/db/errors.ts +17 -0
  311. package/src/server/db/index.cloudflare.ts +15 -0
  312. package/src/server/db/index.ts +35 -0
  313. package/src/server/db/libsql-connection.ts +72 -0
  314. package/src/server/db/log-schema.ts +102 -0
  315. package/src/server/db/migrate-libsql.ts +29 -0
  316. package/src/server/db/migrate-sqlite.ts +47 -0
  317. package/src/server/db/migration-history.ts +12 -0
  318. package/src/server/db/migrations-logs/0000_initial.sql +48 -0
  319. package/src/server/db/migrations-logs/0001_runtime_log_order.sql +2 -0
  320. package/src/server/db/migrations-logs/meta/0000_snapshot.json +327 -0
  321. package/src/server/db/migrations-logs/meta/0001_snapshot.json +329 -0
  322. package/src/server/db/migrations-logs/meta/_journal.json +20 -0
  323. package/src/server/db/migrations-sqlite/0000_initial.sql +894 -0
  324. package/src/server/db/migrations-sqlite/0001_agent_indexes.sql +5 -0
  325. package/src/server/db/migrations-sqlite/meta/0000_snapshot.json +5816 -0
  326. package/src/server/db/migrations-sqlite/meta/0001_snapshot.json +5841 -0
  327. package/src/server/db/migrations-sqlite/meta/_journal.json +20 -0
  328. package/src/server/db/oauth-schema.ts +216 -0
  329. package/src/server/db/remote-config.ts +47 -0
  330. package/src/server/db/schema.ts +1218 -0
  331. package/src/server/db/sqlite-connection.ts +94 -0
  332. package/src/server/db/sqlite-files.ts +27 -0
  333. package/src/server/db/sqlite-params.ts +19 -0
  334. package/src/server/db/worker-connection.ts +47 -0
  335. package/src/server/deleted-resources.ts +133 -0
  336. package/src/server/deletion-recovery.ts +272 -0
  337. package/src/server/email/layout.tsx +85 -0
  338. package/src/server/email/notification-template.tsx +62 -0
  339. package/src/server/email/otp-template.tsx +48 -0
  340. package/src/server/email/service.ts +251 -0
  341. package/src/server/email/team-invite-template.tsx +59 -0
  342. package/src/server/email/theme.ts +10 -0
  343. package/src/server/github/http.ts +14 -0
  344. package/src/server/github/install-state.ts +48 -0
  345. package/src/server/github/service.ts +831 -0
  346. package/src/server/github/webhook-handler.ts +198 -0
  347. package/src/server/github/webhooks.ts +205 -0
  348. package/src/server/http/auth.ts +11 -0
  349. package/src/server/http/error-diagnostics.ts +66 -0
  350. package/src/server/http/plugin-request.ts +15 -0
  351. package/src/server/http/proxy-request.ts +53 -0
  352. package/src/server/http/public-errors.ts +48 -0
  353. package/src/server/http/rate-limit.ts +59 -0
  354. package/src/server/http/request-body.ts +54 -0
  355. package/src/server/http/request-ip.ts +54 -0
  356. package/src/server/http/security-headers.ts +36 -0
  357. package/src/server/install/agent-binary.ts +230 -0
  358. package/src/server/install/agent-script.ts +565 -0
  359. package/src/server/install/release-binary.ts +65 -0
  360. package/src/server/logs/budget.ts +72 -0
  361. package/src/server/logs/cleanup.ts +64 -0
  362. package/src/server/logs/deployments.ts +98 -0
  363. package/src/server/logs/operations.ts +145 -0
  364. package/src/server/logs/retention.ts +39 -0
  365. package/src/server/maintenance.ts +61 -0
  366. package/src/server/mcp/connections.ts +358 -0
  367. package/src/server/mcp/functions.ts +63 -0
  368. package/src/server/mcp/handler.ts +295 -0
  369. package/src/server/mcp/oauth-discovery.cloudflare.ts +6 -0
  370. package/src/server/mcp/oauth-discovery.ts +8 -0
  371. package/src/server/mcp/oauth-provider.ts +220 -0
  372. package/src/server/mcp/urls.ts +20 -0
  373. package/src/server/notifications/functions.ts +51 -0
  374. package/src/server/notifications/observe.ts +303 -0
  375. package/src/server/notifications/outbox.ts +335 -0
  376. package/src/server/notifications/preferences.ts +131 -0
  377. package/src/server/notifications/query.ts +16 -0
  378. package/src/server/plugins/scope.ts +17 -0
  379. package/src/server/plugins/server-context.ts +157 -0
  380. package/src/server/plugins/services.server.ts +10 -0
  381. package/src/server/plugins/workspace-access.ts +74 -0
  382. package/src/server/projects/backup-policy-state.ts +68 -0
  383. package/src/server/projects/backups.ts +219 -0
  384. package/src/server/projects/compose-metadata.ts +174 -0
  385. package/src/server/projects/configuration-state.ts +90 -0
  386. package/src/server/projects/context.ts +909 -0
  387. package/src/server/projects/creation-state.ts +46 -0
  388. package/src/server/projects/deletion-state.ts +69 -0
  389. package/src/server/projects/deployment-config.ts +139 -0
  390. package/src/server/projects/deployment-logs.ts +97 -0
  391. package/src/server/projects/deployments.ts +1123 -0
  392. package/src/server/projects/domain-state.ts +71 -0
  393. package/src/server/projects/environment-branches.ts +75 -0
  394. package/src/server/projects/environment-state.ts +158 -0
  395. package/src/server/projects/environments.ts +424 -0
  396. package/src/server/projects/functions.ts +748 -0
  397. package/src/server/projects/generated-hostname.ts +77 -0
  398. package/src/server/projects/hostnames.ts +244 -0
  399. package/src/server/projects/mappers.ts +457 -0
  400. package/src/server/projects/names.ts +41 -0
  401. package/src/server/projects/project-env-vars.ts +28 -0
  402. package/src/server/projects/queue-state.ts +118 -0
  403. package/src/server/projects/repository.ts +368 -0
  404. package/src/server/projects/route-state.ts +37 -0
  405. package/src/server/projects/runtime-logs.ts +97 -0
  406. package/src/server/projects/settings-context.ts +58 -0
  407. package/src/server/projects/settings.ts +738 -0
  408. package/src/server/projects/types.ts +355 -0
  409. package/src/server/realtime/agent-events.ts +32 -0
  410. package/src/server/realtime/node-broadcaster.ts +71 -0
  411. package/src/server/realtime/node-handler.ts +55 -0
  412. package/src/server/realtime/service.ts +125 -0
  413. package/src/server/realtime/workspace-object.cloudflare.ts +62 -0
  414. package/src/server/realtime/workspace-object.ts +3 -0
  415. package/src/server/resources/color.ts +13 -0
  416. package/src/server/runtime/background.ts +21 -0
  417. package/src/server/runtime/node-asset-cache-plugin.ts +12 -0
  418. package/src/server/runtime/node-scheduler-plugin.ts +17 -0
  419. package/src/server/runtime/node-scheduler.ts +51 -0
  420. package/src/server/runtime/platform-env.cloudflare.ts +17 -0
  421. package/src/server/runtime/platform-env.ts +19 -0
  422. package/src/server/runtime/scheduled-task-error.ts +9 -0
  423. package/src/server/scheduled-tasks.ts +28 -0
  424. package/src/server/secrets/crypto.ts +56 -0
  425. package/src/server/servers/functions.ts +233 -0
  426. package/src/server/servers/lifecycle.ts +122 -0
  427. package/src/server/servers/metric-history-schema.ts +24 -0
  428. package/src/server/servers/metric-history.ts +55 -0
  429. package/src/server/servers/monitoring.ts +592 -0
  430. package/src/server/servers/service.ts +1211 -0
  431. package/src/server/servers/status.ts +32 -0
  432. package/src/server/servers/switch.ts +96 -0
  433. package/src/server/settings-version.ts +43 -0
  434. package/src/server/storage/capabilities.ts +6 -0
  435. package/src/server/storage/local-object-store.cloudflare.ts +7 -0
  436. package/src/server/storage/local-object-store.ts +50 -0
  437. package/src/server/storage/object-store.ts +160 -0
  438. package/src/server/teams/creation.ts +51 -0
  439. package/src/server/teams/delete-policy.ts +13 -0
  440. package/src/server/teams/deletion-state.ts +80 -0
  441. package/src/server/teams/functions.ts +324 -0
  442. package/src/server/teams/invitations.ts +38 -0
  443. package/src/server/teams/membership.ts +86 -0
  444. package/src/server/teams/queries.ts +261 -0
  445. package/src/server/teams/service.ts +1127 -0
  446. package/src/server/teams/types.ts +101 -0
  447. package/src/server/uploads/avatar.ts +133 -0
  448. package/src/server/users/deletion-state.ts +93 -0
  449. package/src/server/users/functions.ts +160 -0
  450. package/src/server/users/onboarding.ts +17 -0
  451. package/src/server/users/service.ts +644 -0
  452. package/src/server.ts +55 -0
  453. package/src/styles/shadcn.css +653 -0
  454. package/src/styles/theme.css +76 -0
  455. package/src/styles.css +177 -0
  456. package/wrangler.template.jsonc +37 -0
@@ -0,0 +1,1099 @@
1
+ import type { WorkspaceOperation } from '#devpush/plugins/operations'
2
+ import { settingsVersionSchema } from '#devpush/lib/settings-version'
3
+ import { projectEnvironmentsSchema } from '#devpush/lib/project-environments-schema'
4
+ import { backupDatabaseSchema } from '#devpush/lib/backup-database'
5
+ import { z } from 'zod'
6
+ import type { TeamRole } from '#devpush/lib/team-role'
7
+ import {
8
+ publicBackupAcceptedSchema,
9
+ publicBackupInputSchema,
10
+ publicBackupRunSchema,
11
+ publicDeploymentAcceptedSchema,
12
+ publicDeploymentInputSchema,
13
+ publicDeploymentSchema,
14
+ publicEnvironmentSchema,
15
+ publicErrorResponseSchema,
16
+ publicIdSchema,
17
+ publicLogPageSchema,
18
+ publicPageInputSchema,
19
+ publicPageSchema,
20
+ publicProjectInputSchema,
21
+ publicProjectSchema,
22
+ publicRestoreAcceptedSchema,
23
+ publicServerInputSchema,
24
+ publicServerSchema,
25
+ publicTimestampSchema,
26
+ } from '#devpush/lib/public-api-schema'
27
+ import { backupRestoreArtifactSchema } from '#devpush/lib/backup-restore-schema'
28
+ import { projectRoutesSchema } from '#devpush/lib/project-routing-schema'
29
+ import { createProjectSchema } from '#devpush/lib/project-creation-schema'
30
+ import { backupConfigSchema } from '#devpush/lib/backup-policy-schema'
31
+ import { backupStorageSchema } from '#devpush/lib/backup-storage-schema'
32
+ import { projectMachineNameSchema } from '#devpush/lib/project-settings-schema'
33
+ import { serverNameSchema } from '#devpush/lib/server-name-schema'
34
+ import { projectRuntimeConfigSchema } from '#devpush/lib/project-runtime-config'
35
+
36
+ export type PublicApiOperation = {
37
+ id: string
38
+ description: string
39
+ method: 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE'
40
+ path: string
41
+ scope: string
42
+ input: z.ZodObject
43
+ output: z.ZodType
44
+ status: number
45
+ mcp: boolean
46
+ destructive: boolean
47
+ workspacePolicy: {
48
+ operation: WorkspaceOperation
49
+ boundary: 'domain' | 'dispatcher'
50
+ } | null
51
+ readOnly: boolean
52
+ requiresWholeTeam: boolean
53
+ minimumRole: TeamRole
54
+ }
55
+ function operation(
56
+ input: Omit<
57
+ PublicApiOperation,
58
+ | 'status'
59
+ | 'mcp'
60
+ | 'destructive'
61
+ | 'readOnly'
62
+ | 'requiresWholeTeam'
63
+ | 'minimumRole'
64
+ | 'workspacePolicy'
65
+ | 'method'
66
+ > &
67
+ (
68
+ | { method: 'GET'; workspacePolicy?: never }
69
+ | {
70
+ method: Exclude<PublicApiOperation['method'], 'GET'>
71
+ workspacePolicy: NonNullable<PublicApiOperation['workspacePolicy']>
72
+ }
73
+ ) &
74
+ Partial<
75
+ Pick<
76
+ PublicApiOperation,
77
+ 'status' | 'mcp' | 'destructive' | 'requiresWholeTeam' | 'minimumRole'
78
+ >
79
+ >,
80
+ ) {
81
+ return {
82
+ workspacePolicy: null,
83
+ status: 200,
84
+ mcp: true,
85
+ destructive: false,
86
+ requiresWholeTeam: [
87
+ 'list_servers',
88
+ 'get_server',
89
+ 'read_server_metrics',
90
+ 'list_backup_storage',
91
+ 'create_project',
92
+ 'rename_server',
93
+ 'create_server',
94
+ 'enable_server',
95
+ 'disable_server',
96
+ 'delete_server',
97
+ 'get_server_delete_diagnostic',
98
+ 'create_backup_storage',
99
+ 'update_backup_storage',
100
+ 'delete_backup_storage',
101
+ ].includes(input.id),
102
+ minimumRole:
103
+ input.id === 'delete_project' ? ('admin' as const) : ('member' as const),
104
+ ...input,
105
+ readOnly: input.method === 'GET',
106
+ }
107
+ }
108
+ const projectPage = publicProjectInputSchema.extend(publicPageInputSchema.shape)
109
+ const deploymentPage = projectPage.extend({
110
+ environmentId: publicIdSchema.optional(),
111
+ })
112
+ const logPage = publicPageInputSchema.extend({
113
+ stream: z.literal('build').default('build'),
114
+ })
115
+ const runtimeLogInput = projectPage.extend({
116
+ environmentId: publicIdSchema.optional(),
117
+ service: z.string().min(1).max(128).optional(),
118
+ keyword: z.string().min(1).max(200).optional(),
119
+ since: publicTimestampSchema.optional(),
120
+ })
121
+ export const publicApiOperations: PublicApiOperation[] = [
122
+ operation({
123
+ id: 'list_github_installations',
124
+ description:
125
+ 'List one provider page of linked GitHub installations available when creating projects. Requires unrestricted team management access.',
126
+ method: 'GET',
127
+ path: '/github/installations',
128
+ scope: 'projects:write',
129
+ requiresWholeTeam: true,
130
+ mcp: false,
131
+ input: publicPageInputSchema,
132
+ output: publicPageSchema(
133
+ z.strictObject({
134
+ id: z.number().int(),
135
+ accountLogin: z.string(),
136
+ accountType: z.string(),
137
+ repositorySelection: z.string(),
138
+ }),
139
+ ),
140
+ }),
141
+ operation({
142
+ id: 'list_github_repositories',
143
+ description:
144
+ 'List one provider page of repositories with push access in a linked installation. Continue with nextCursor even when a filtered page is empty.',
145
+ method: 'GET',
146
+ path: '/github/repositories',
147
+ scope: 'projects:write',
148
+ requiresWholeTeam: true,
149
+ mcp: false,
150
+ input: publicPageInputSchema.extend({
151
+ installationId: z.coerce.number().int().positive(),
152
+ }),
153
+ output: publicPageSchema(
154
+ z.strictObject({
155
+ id: z.number().int(),
156
+ installationId: z.number().int(),
157
+ fullName: z.string(),
158
+ defaultBranch: z.string(),
159
+ private: z.boolean(),
160
+ }),
161
+ ),
162
+ }),
163
+ operation({
164
+ id: 'get_backup_policy',
165
+ description:
166
+ 'Read a backup policy without commands or storage credentials.',
167
+ method: 'GET',
168
+ path: '/projects/{projectId}/backup-policies/{policyId}',
169
+ scope: 'backups:read',
170
+ input: publicProjectInputSchema.extend({ policyId: publicIdSchema }),
171
+ output: backupConfigSchema
172
+ .extend({
173
+ id: publicIdSchema,
174
+ projectId: publicIdSchema,
175
+ settingsVersion: settingsVersionSchema,
176
+ databaseDumps: z.array(backupDatabaseSchema).max(100),
177
+ })
178
+ .strict(),
179
+ }),
180
+ operation({
181
+ id: 'get_identity',
182
+ description:
183
+ 'Read the authenticated user, selected team, and effective credential scopes.',
184
+ method: 'GET',
185
+ path: '/identity',
186
+ scope: 'projects:read',
187
+ input: z.strictObject({}),
188
+ output: z.strictObject({
189
+ user: z.strictObject({
190
+ id: publicIdSchema,
191
+ name: z.string(),
192
+ username: z.string(),
193
+ }),
194
+ team: z.strictObject({
195
+ id: publicIdSchema,
196
+ name: z.string(),
197
+ slug: z.string(),
198
+ }),
199
+ scopes: z.array(z.string()),
200
+ projectIds: z.array(publicIdSchema).nullable(),
201
+ }),
202
+ }),
203
+ operation({
204
+ id: 'list_projects',
205
+ description: 'List authorized active projects using a bounded cursor.',
206
+ method: 'GET',
207
+ path: '/projects',
208
+ scope: 'projects:read',
209
+ input: publicPageInputSchema,
210
+ output: publicPageSchema(publicProjectSchema),
211
+ }),
212
+ operation({
213
+ id: 'get_project',
214
+ description:
215
+ 'Read public project metadata. Secret values and private configuration snapshots are excluded.',
216
+ method: 'GET',
217
+ path: '/projects/{projectId}',
218
+ scope: 'projects:read',
219
+ input: publicProjectInputSchema,
220
+ output: publicProjectSchema,
221
+ }),
222
+ operation({
223
+ id: 'list_environments',
224
+ description: 'List the active environments for a project.',
225
+ method: 'GET',
226
+ path: '/projects/{projectId}/environments',
227
+ scope: 'projects:read',
228
+ input: projectPage,
229
+ output: publicPageSchema(publicEnvironmentSchema),
230
+ }),
231
+ operation({
232
+ id: 'get_project_configuration',
233
+ description: 'Read the supported Compose runtime configuration and routes.',
234
+ method: 'GET',
235
+ path: '/projects/{projectId}/configuration',
236
+ scope: 'projects:read',
237
+ input: publicProjectInputSchema,
238
+ output: z.strictObject({
239
+ settingsVersion: settingsVersionSchema,
240
+ runtimeConfig: projectRuntimeConfigSchema,
241
+ routes: projectRoutesSchema.shape.routes,
242
+ }),
243
+ }),
244
+ operation({
245
+ id: 'list_variables',
246
+ description:
247
+ 'List variable names and environment scopes. Values are never returned.',
248
+ method: 'GET',
249
+ path: '/projects/{projectId}/variables',
250
+ scope: 'projects:read',
251
+ input: projectPage,
252
+ output: publicPageSchema(
253
+ z.strictObject({
254
+ key: z.string(),
255
+ environmentId: publicIdSchema.nullable(),
256
+ }),
257
+ ).extend({ settingsVersion: settingsVersionSchema }),
258
+ }),
259
+ operation({
260
+ id: 'list_domains',
261
+ description: 'List custom domains and their verification status.',
262
+ method: 'GET',
263
+ path: '/projects/{projectId}/domains',
264
+ scope: 'projects:read',
265
+ input: projectPage,
266
+ output: publicPageSchema(
267
+ z.strictObject({
268
+ id: publicIdSchema,
269
+ environmentId: publicIdSchema,
270
+ hostname: z.string().nullable(),
271
+ basePath: z.string().nullable(),
272
+ https: z.boolean(),
273
+ status: z.string(),
274
+ createdAt: publicTimestampSchema,
275
+ }),
276
+ ),
277
+ }),
278
+ operation({
279
+ id: 'list_aliases',
280
+ description: 'List generated deployment, branch, and environment aliases.',
281
+ method: 'GET',
282
+ path: '/projects/{projectId}/aliases',
283
+ scope: 'projects:read',
284
+ input: projectPage,
285
+ output: publicPageSchema(
286
+ z.strictObject({
287
+ id: publicIdSchema,
288
+ environmentId: publicIdSchema,
289
+ deploymentId: publicIdSchema.nullable(),
290
+ hostname: z.string().nullable(),
291
+ type: z.enum(['deployment', 'environment', 'branch']),
292
+ branch: z.string().nullable(),
293
+ https: z.boolean(),
294
+ createdAt: publicTimestampSchema,
295
+ }),
296
+ ),
297
+ }),
298
+ operation({
299
+ id: 'list_deployments',
300
+ description:
301
+ 'List deployment metadata. Build snapshots and variable values are excluded.',
302
+ method: 'GET',
303
+ path: '/projects/{projectId}/deployments',
304
+ scope: 'deployments:read',
305
+ input: deploymentPage,
306
+ output: publicPageSchema(publicDeploymentSchema),
307
+ }),
308
+ operation({
309
+ id: 'get_deployment',
310
+ description: 'Read deployment status by immutable deployment ID.',
311
+ method: 'GET',
312
+ path: '/deployments/{deploymentId}',
313
+ scope: 'deployments:read',
314
+ input: publicDeploymentInputSchema,
315
+ output: publicDeploymentSchema,
316
+ }),
317
+ operation({
318
+ id: 'read_deployment_logs',
319
+ description:
320
+ 'Read bounded build or control log entries. Application output may contain secrets.',
321
+ method: 'GET',
322
+ path: '/deployments/{deploymentId}/logs',
323
+ scope: 'logs:read',
324
+ input: publicDeploymentInputSchema.extend(logPage.shape),
325
+ output: publicLogPageSchema,
326
+ }),
327
+ operation({
328
+ id: 'read_runtime_logs',
329
+ description:
330
+ 'Read bounded runtime output from current environment server assignments. Application output may contain secrets.',
331
+ method: 'GET',
332
+ path: '/projects/{projectId}/runtime-logs',
333
+ scope: 'logs:read',
334
+ input: runtimeLogInput,
335
+ output: publicPageSchema(
336
+ z.strictObject({
337
+ id: publicIdSchema,
338
+ environmentId: publicIdSchema,
339
+ service: z.string(),
340
+ content: z.string().max(64 * 1024),
341
+ observedAt: publicTimestampSchema,
342
+ truncated: z.boolean(),
343
+ }),
344
+ ).extend({ retentionMayHaveRemovedEarlierEntries: z.literal(true) }),
345
+ }),
346
+ operation({
347
+ id: 'list_servers',
348
+ description:
349
+ 'List team server metadata. Unavailable to project-restricted credentials.',
350
+ method: 'GET',
351
+ path: '/servers',
352
+ scope: 'servers:read',
353
+ input: publicPageInputSchema,
354
+ output: publicPageSchema(publicServerSchema),
355
+ }),
356
+ operation({
357
+ id: 'get_server',
358
+ description:
359
+ 'Read server metadata. Enrollment and agent credentials are excluded.',
360
+ method: 'GET',
361
+ path: '/servers/{serverId}',
362
+ scope: 'servers:read',
363
+ input: publicServerInputSchema,
364
+ output: publicServerSchema,
365
+ }),
366
+ operation({
367
+ id: 'read_server_metrics',
368
+ description: 'Read bounded host metric samples.',
369
+ method: 'GET',
370
+ path: '/servers/{serverId}/metrics',
371
+ scope: 'servers:read',
372
+ input: publicServerInputSchema
373
+ .extend(publicPageInputSchema.shape)
374
+ .extend({ since: publicTimestampSchema.optional() }),
375
+ output: publicPageSchema(
376
+ z.strictObject({
377
+ id: publicIdSchema,
378
+ observedAt: publicTimestampSchema,
379
+ cpuPercent: z.number().nullable(),
380
+ memoryUsedBytes: z.number().nullable(),
381
+ memoryTotalBytes: z.number().nullable(),
382
+ diskUsedBytes: z.number().nullable(),
383
+ diskTotalBytes: z.number().nullable(),
384
+ networkReceiveBytesPerSecond: z.number().nullable(),
385
+ networkTransmitBytesPerSecond: z.number().nullable(),
386
+ }),
387
+ ),
388
+ }),
389
+ operation({
390
+ id: 'list_backups',
391
+ description:
392
+ 'List backup status metadata. Storage credentials and internal manifests are excluded.',
393
+ method: 'GET',
394
+ path: '/projects/{projectId}/backups',
395
+ scope: 'backups:read',
396
+ input: deploymentPage,
397
+ output: publicPageSchema(publicBackupRunSchema),
398
+ }),
399
+ operation({
400
+ id: 'get_backup',
401
+ description: 'Read backup status by immutable backup run ID.',
402
+ method: 'GET',
403
+ path: '/backups/{backupRunId}',
404
+ scope: 'backups:read',
405
+ input: publicBackupInputSchema,
406
+ output: publicBackupRunSchema,
407
+ }),
408
+ operation({
409
+ id: 'list_backup_artifacts',
410
+ description:
411
+ 'List restore artifact identifiers, types, sizes, and checksums. Object keys and credentials are excluded.',
412
+ method: 'GET',
413
+ path: '/backups/{backupRunId}/artifacts',
414
+ scope: 'backups:read',
415
+ input: publicBackupInputSchema.extend(publicPageInputSchema.shape),
416
+ output: publicPageSchema(
417
+ z.strictObject({
418
+ id: publicIdSchema,
419
+ type: z.enum(['manifest', 'volume', 'database']),
420
+ storage: z.enum(['local', 'remote']),
421
+ sizeBytes: z.number().nonnegative(),
422
+ checksumSha256: z.string(),
423
+ createdAt: publicTimestampSchema,
424
+ }),
425
+ ),
426
+ }),
427
+ operation({
428
+ id: 'list_backup_policies',
429
+ description:
430
+ 'List policy identifiers and enabled state. Database connection secrets are excluded.',
431
+ method: 'GET',
432
+ path: '/projects/{projectId}/backup-policies',
433
+ scope: 'backups:read',
434
+ input: projectPage,
435
+ output: publicPageSchema(
436
+ z.strictObject({
437
+ id: publicIdSchema,
438
+ name: z.string(),
439
+ environmentId: publicIdSchema,
440
+ enabled: z.boolean(),
441
+ createdAt: publicTimestampSchema,
442
+ }),
443
+ ),
444
+ }),
445
+ operation({
446
+ id: 'list_backup_storage',
447
+ description:
448
+ 'List team storage destination metadata without access keys. Unavailable to project-restricted credentials.',
449
+ method: 'GET',
450
+ path: '/backup-storage',
451
+ scope: 'backups:read',
452
+ input: publicPageInputSchema,
453
+ output: publicPageSchema(
454
+ z.strictObject({
455
+ id: publicIdSchema,
456
+ settingsVersion: settingsVersionSchema,
457
+ name: z.string(),
458
+ bucket: z.string(),
459
+ region: z.string(),
460
+ endpoint: z.string().nullable(),
461
+ createdAt: publicTimestampSchema,
462
+ }),
463
+ ),
464
+ }),
465
+ operation({
466
+ id: 'get_job',
467
+ description:
468
+ 'Read an asynchronous backup or restore job status without its credential-bearing payload.',
469
+ method: 'GET',
470
+ path: '/jobs/{jobId}',
471
+ scope: 'backups:read',
472
+ input: z.strictObject({ jobId: publicIdSchema }),
473
+ output: z.strictObject({
474
+ id: publicIdSchema,
475
+ projectId: publicIdSchema,
476
+ type: z.string(),
477
+ status: z.string(),
478
+ createdAt: publicTimestampSchema,
479
+ finishedAt: publicTimestampSchema.nullable(),
480
+ }),
481
+ }),
482
+ operation({
483
+ id: 'read_job_logs',
484
+ description:
485
+ 'Read bounded backup or restore output. Logs may contain application secrets.',
486
+ method: 'GET',
487
+ path: '/jobs/{jobId}/logs',
488
+ scope: 'logs:read',
489
+ input: z
490
+ .strictObject({ jobId: publicIdSchema })
491
+ .extend(publicPageInputSchema.shape),
492
+ output: publicLogPageSchema,
493
+ }),
494
+ operation({
495
+ id: 'deploy',
496
+ workspacePolicy: { operation: 'deployment.create', boundary: 'domain' },
497
+ description:
498
+ 'Queue a deployment from a matching GitHub branch. Requires a unique idempotencyKey; returns acceptance, not execution success.',
499
+ method: 'POST',
500
+ path: '/projects/{projectId}/deployments',
501
+ scope: 'deployments:write',
502
+ status: 202,
503
+ input: publicProjectInputSchema.extend({
504
+ environmentId: publicIdSchema,
505
+ branch: z.string().min(1).max(255),
506
+ sha: z
507
+ .string()
508
+ .regex(/^[a-f0-9]{40}$/i)
509
+ .optional(),
510
+ idempotencyKey: z.string().min(1).max(128),
511
+ }),
512
+ output: publicDeploymentAcceptedSchema,
513
+ }),
514
+ operation({
515
+ id: 'redeploy',
516
+ workspacePolicy: { operation: 'deployment.create', boundary: 'domain' },
517
+ description:
518
+ 'Queue the recorded commit and runtime settings with current routing.',
519
+ method: 'POST',
520
+ path: '/deployments/{deploymentId}/redeploy',
521
+ scope: 'deployments:write',
522
+ status: 202,
523
+ input: publicDeploymentInputSchema.extend({
524
+ idempotencyKey: z.string().min(1).max(128),
525
+ }),
526
+ output: publicDeploymentAcceptedSchema,
527
+ }),
528
+ operation({
529
+ id: 'rollback',
530
+ workspacePolicy: { operation: 'deployment.create', boundary: 'domain' },
531
+ description:
532
+ 'Queue a successful recorded commit and runtime settings with current routing.',
533
+ method: 'POST',
534
+ path: '/deployments/{deploymentId}/rollback',
535
+ scope: 'deployments:write',
536
+ status: 202,
537
+ destructive: true,
538
+ input: publicDeploymentInputSchema.extend({
539
+ confirmation: z.literal('rollback'),
540
+ idempotencyKey: z.string().min(1).max(128),
541
+ }),
542
+ output: publicDeploymentAcceptedSchema,
543
+ }),
544
+ operation({
545
+ id: 'run_backup',
546
+ workspacePolicy: { operation: 'backup.run', boundary: 'domain' },
547
+ description: 'Queue a manual run of an enabled backup policy.',
548
+ method: 'POST',
549
+ path: '/projects/{projectId}/backups',
550
+ scope: 'backups:write',
551
+ status: 202,
552
+ input: publicProjectInputSchema.extend({
553
+ environmentId: publicIdSchema,
554
+ policyId: publicIdSchema
555
+ .optional()
556
+ .describe(
557
+ 'Required when the environment has multiple enabled policies.',
558
+ ),
559
+ idempotencyKey: z.string().min(1).max(128),
560
+ }),
561
+ output: publicBackupAcceptedSchema,
562
+ }),
563
+ operation({
564
+ id: 'restore_backup',
565
+ workspacePolicy: { operation: 'backup.restore', boundary: 'domain' },
566
+ description:
567
+ 'Queue a destructive restore into the current environment. Requires administrator role and explicit confirmation.',
568
+ method: 'POST',
569
+ path: '/backups/{backupRunId}/restore',
570
+ scope: 'backups:restore',
571
+ status: 202,
572
+ destructive: true,
573
+ input: publicBackupInputSchema.extend({
574
+ confirmation: z.literal('restore'),
575
+ artifacts: z.array(backupRestoreArtifactSchema).min(1).max(100),
576
+ idempotencyKey: z.string().min(1).max(128),
577
+ }),
578
+ output: publicRestoreAcceptedSchema,
579
+ }),
580
+ operation({
581
+ id: 'rename_project',
582
+ workspacePolicy: { operation: 'project.update', boundary: 'dispatcher' },
583
+ description:
584
+ 'Rename a project using its current settings version. Resource IDs stay unchanged.',
585
+ method: 'PATCH',
586
+ path: '/projects/{projectId}',
587
+ scope: 'projects:write',
588
+ input: publicProjectInputSchema.extend({
589
+ name: projectMachineNameSchema,
590
+ settingsVersion: settingsVersionSchema,
591
+ idempotencyKey: z.string().min(1).max(128),
592
+ }),
593
+ output: publicProjectSchema,
594
+ }),
595
+ operation({
596
+ id: 'update_variables',
597
+ workspacePolicy: { operation: 'variable.update', boundary: 'dispatcher' },
598
+ description:
599
+ 'Patch write-only variables. Omitted values are preserved; deleted names are removed only in their chosen environment scope.',
600
+ method: 'PATCH',
601
+ path: '/projects/{projectId}/variables',
602
+ scope: 'secrets:write',
603
+ input: publicProjectInputSchema.extend({
604
+ settingsVersion: settingsVersionSchema,
605
+ changes: z
606
+ .array(
607
+ z.strictObject({
608
+ key: z
609
+ .string()
610
+ .regex(/^[A-Za-z_][A-Za-z0-9_]*$/)
611
+ .max(255),
612
+ environmentId: publicIdSchema.nullable(),
613
+ value: z
614
+ .string()
615
+ .max(64 * 1024)
616
+ .nullable(),
617
+ }),
618
+ )
619
+ .min(1)
620
+ .max(100),
621
+ idempotencyKey: z.string().min(1).max(128),
622
+ }),
623
+ output: z.strictObject({
624
+ projectId: publicIdSchema,
625
+ settingsVersion: settingsVersionSchema,
626
+ }),
627
+ }),
628
+ operation({
629
+ id: 'rename_server',
630
+ workspacePolicy: { operation: 'server.update', boundary: 'dispatcher' },
631
+ description: 'Rename a server. Requires current team administrator role.',
632
+ method: 'PATCH',
633
+ path: '/servers/{serverId}',
634
+ scope: 'servers:write',
635
+ mcp: false,
636
+ input: publicServerInputSchema.extend({
637
+ settingsVersion: settingsVersionSchema,
638
+ name: serverNameSchema,
639
+ idempotencyKey: z.string().min(1).max(128),
640
+ }),
641
+ output: publicServerSchema,
642
+ }),
643
+ operation({
644
+ id: 'create_server',
645
+ workspacePolicy: { operation: 'server.create', boundary: 'domain' },
646
+ description:
647
+ 'Create a pending server. Enrollment credentials are generated separately in the browser.',
648
+ method: 'POST',
649
+ path: '/servers',
650
+ scope: 'servers:write',
651
+ mcp: false,
652
+ status: 201,
653
+ input: z.strictObject({
654
+ name: serverNameSchema,
655
+ idempotencyKey: z.string().min(1).max(128),
656
+ }),
657
+ output: publicServerSchema,
658
+ }),
659
+ operation({
660
+ id: 'update_project_configuration',
661
+ workspacePolicy: { operation: 'project.update', boundary: 'dispatcher' },
662
+ description:
663
+ 'Replace Compose runtime configuration and routes with settings version protection. Host lifecycle command changes require their separate administrator scope.',
664
+ method: 'PUT',
665
+ path: '/projects/{projectId}/configuration',
666
+ scope: 'projects:write',
667
+ input: publicProjectInputSchema.extend({
668
+ settingsVersion: settingsVersionSchema,
669
+ runtimeConfig: projectRuntimeConfigSchema,
670
+ routes: projectRoutesSchema.shape.routes.max(100),
671
+ idempotencyKey: z.string().min(1).max(128),
672
+ }),
673
+ output: z.strictObject({
674
+ projectId: publicIdSchema,
675
+ settingsVersion: settingsVersionSchema,
676
+ }),
677
+ }),
678
+ operation({
679
+ id: 'delete_project',
680
+ workspacePolicy: { operation: 'project.delete', boundary: 'dispatcher' },
681
+ description:
682
+ 'Delete a project and optionally queue deployed runtime removal. Requires current administrator role and the project name as confirmation.',
683
+ method: 'DELETE',
684
+ path: '/projects/{projectId}',
685
+ scope: 'projects:write',
686
+ destructive: true,
687
+ input: publicProjectInputSchema.extend({
688
+ confirmationName: z.string().min(1).max(100),
689
+ removeDeployments: z.boolean().default(true),
690
+ idempotencyKey: z.string().min(1).max(128),
691
+ }),
692
+ output: z.strictObject({
693
+ projectId: publicIdSchema,
694
+ status: z.literal('deleted'),
695
+ }),
696
+ }),
697
+ operation({
698
+ id: 'enable_server',
699
+ workspacePolicy: { operation: 'server.enable', boundary: 'dispatcher' },
700
+ description:
701
+ 'Enable a disabled server. Requires current administrator role.',
702
+ method: 'POST',
703
+ path: '/servers/{serverId}/enable',
704
+ scope: 'servers:write',
705
+ mcp: false,
706
+ input: publicServerInputSchema.extend({
707
+ idempotencyKey: z.string().min(1).max(128),
708
+ }),
709
+ output: z.strictObject({
710
+ serverId: publicIdSchema,
711
+ enabled: z.literal(true),
712
+ }),
713
+ }),
714
+ operation({
715
+ id: 'disable_server',
716
+ workspacePolicy: { operation: 'server.disable', boundary: 'dispatcher' },
717
+ description:
718
+ 'Disable a server using its name as confirmation. Requires current administrator role.',
719
+ method: 'POST',
720
+ path: '/servers/{serverId}/disable',
721
+ scope: 'servers:write',
722
+ mcp: false,
723
+ destructive: true,
724
+ input: publicServerInputSchema.extend({
725
+ confirmationName: z.string().min(1).max(100),
726
+ idempotencyKey: z.string().min(1).max(128),
727
+ }),
728
+ output: z.strictObject({
729
+ serverId: publicIdSchema,
730
+ enabled: z.literal(false),
731
+ }),
732
+ }),
733
+ operation({
734
+ id: 'delete_server',
735
+ workspacePolicy: { operation: 'server.delete', boundary: 'domain' },
736
+ description:
737
+ 'Delete a server using its name as confirmation. Existing deployment cancellation is an explicit option.',
738
+ method: 'DELETE',
739
+ path: '/servers/{serverId}',
740
+ scope: 'servers:write',
741
+ mcp: false,
742
+ destructive: true,
743
+ input: publicServerInputSchema.extend({
744
+ confirmationName: z.string().min(1).max(100),
745
+ cancelOngoingDeployments: z.boolean().default(true),
746
+ idempotencyKey: z.string().min(1).max(128),
747
+ }),
748
+ output: z.strictObject({
749
+ serverId: publicIdSchema,
750
+ status: z.literal('deleted'),
751
+ }),
752
+ }),
753
+ operation({
754
+ id: 'get_server_delete_diagnostic',
755
+ description:
756
+ 'Read counts of active project and environment assignments affected by server deletion.',
757
+ method: 'GET',
758
+ path: '/servers/{serverId}/delete-diagnostic',
759
+ scope: 'servers:write',
760
+ mcp: false,
761
+ input: publicServerInputSchema,
762
+ output: z.strictObject({
763
+ serverId: publicIdSchema,
764
+ projectCount: z.number().int().nonnegative(),
765
+ environmentCount: z.number().int().nonnegative(),
766
+ }),
767
+ }),
768
+ operation({
769
+ id: 'create_project',
770
+ workspacePolicy: { operation: 'project.create', boundary: 'domain' },
771
+ description:
772
+ 'Create a Compose project from a repository accessible to the owner’s linked GitHub account. Browser GitHub connection and installation consent must already be complete.',
773
+ method: 'POST',
774
+ path: '/projects',
775
+ scope: 'projects:write',
776
+ status: 201,
777
+ input: createProjectSchema
778
+ .omit({ teamSlug: true })
779
+ .extend({
780
+ envVars: createProjectSchema.shape.envVars.unwrap().max(100).optional(),
781
+ idempotencyKey: z.string().min(1).max(128),
782
+ })
783
+ .strict(),
784
+ output: z.strictObject({
785
+ projectId: publicIdSchema,
786
+ statusUrl: z.string(),
787
+ }),
788
+ }),
789
+ operation({
790
+ id: 'get_deployment_options',
791
+ description:
792
+ 'List one provider page of matching branches and recent commits only for the selected branch. Continue with nextCursor to reach later matching branches, including after empty filtered pages.',
793
+ method: 'GET',
794
+ path: '/projects/{projectId}/deploy-options',
795
+ scope: 'deployments:read',
796
+ input: projectPage.extend({
797
+ environmentId: publicIdSchema,
798
+ branch: z.string().min(1).max(255).optional(),
799
+ }),
800
+ output: z.strictObject({
801
+ branches: z.array(z.string()).max(100),
802
+ nextCursor: z.string().nullable(),
803
+ selectedBranch: z.string().nullable(),
804
+ commits: z
805
+ .array(
806
+ z.strictObject({
807
+ sha: z.string(),
808
+ message: z.string().nullable(),
809
+ url: z.string().nullable(),
810
+ authorName: z.string().nullable(),
811
+ authoredAt: publicTimestampSchema.nullable(),
812
+ }),
813
+ )
814
+ .max(5),
815
+ }),
816
+ }),
817
+ operation({
818
+ id: 'create_backup_policy',
819
+ workspacePolicy: {
820
+ operation: 'backup.policy.save',
821
+ boundary: 'dispatcher',
822
+ },
823
+ description: 'Create a backup policy. Requires current administrator role.',
824
+ method: 'POST',
825
+ path: '/projects/{projectId}/backup-policies',
826
+ scope: 'backups:write',
827
+ status: 201,
828
+ input: publicProjectInputSchema
829
+ .extend(backupConfigSchema.omit({ id: true }).shape)
830
+ .extend({
831
+ idempotencyKey: z.string().min(1).max(128),
832
+ }),
833
+ output: z.strictObject({
834
+ policyId: publicIdSchema,
835
+ projectId: publicIdSchema,
836
+ settingsVersion: settingsVersionSchema,
837
+ }),
838
+ }),
839
+ operation({
840
+ id: 'update_backup_policy',
841
+ workspacePolicy: {
842
+ operation: 'backup.policy.save',
843
+ boundary: 'dispatcher',
844
+ },
845
+ description:
846
+ 'Replace a backup policy using its current settings version. Requires current administrator role.',
847
+ method: 'PUT',
848
+ path: '/projects/{projectId}/backup-policies/{policyId}',
849
+ scope: 'backups:write',
850
+ input: publicProjectInputSchema
851
+ .extend(backupConfigSchema.omit({ id: true }).shape)
852
+ .extend({
853
+ policyId: publicIdSchema,
854
+ settingsVersion: settingsVersionSchema,
855
+ idempotencyKey: z.string().min(1).max(128),
856
+ }),
857
+ output: z.strictObject({
858
+ policyId: publicIdSchema,
859
+ projectId: publicIdSchema,
860
+ settingsVersion: settingsVersionSchema,
861
+ }),
862
+ }),
863
+ operation({
864
+ id: 'delete_backup_policy',
865
+ workspacePolicy: {
866
+ operation: 'backup.policy.delete',
867
+ boundary: 'dispatcher',
868
+ },
869
+ description:
870
+ 'Remove a backup policy without deleting retained backup runs. Requires current administrator role.',
871
+ method: 'DELETE',
872
+ path: '/projects/{projectId}/backup-policies/{policyId}',
873
+ scope: 'backups:write',
874
+ destructive: true,
875
+ input: publicProjectInputSchema.extend({
876
+ policyId: publicIdSchema,
877
+ confirmation: z.literal('delete-policy'),
878
+ settingsVersion: settingsVersionSchema,
879
+ idempotencyKey: z.string().min(1).max(128),
880
+ }),
881
+ output: z.strictObject({
882
+ policyId: publicIdSchema,
883
+ projectId: publicIdSchema,
884
+ settingsVersion: settingsVersionSchema,
885
+ }),
886
+ }),
887
+ operation({
888
+ id: 'create_backup_storage',
889
+ workspacePolicy: {
890
+ operation: 'backup.storage.save',
891
+ boundary: 'dispatcher',
892
+ },
893
+ description:
894
+ 'Create a team backup destination. Secret access keys are write-only. Requires current administrator role.',
895
+ method: 'POST',
896
+ path: '/backup-storage',
897
+ scope: 'backups:write',
898
+ mcp: false,
899
+ status: 201,
900
+ input: backupStorageSchema
901
+ .omit({ id: true })
902
+ .extend({ idempotencyKey: z.string().min(1).max(128) })
903
+ .strict(),
904
+ output: z.strictObject({
905
+ storageId: publicIdSchema,
906
+ settingsVersion: settingsVersionSchema,
907
+ }),
908
+ }),
909
+ operation({
910
+ id: 'update_backup_storage',
911
+ workspacePolicy: {
912
+ operation: 'backup.storage.save',
913
+ boundary: 'dispatcher',
914
+ },
915
+ description:
916
+ 'Rename or rotate credentials of a team backup destination. Bucket, region, and endpoint are immutable.',
917
+ method: 'PUT',
918
+ path: '/backup-storage/{storageId}',
919
+ scope: 'backups:write',
920
+ mcp: false,
921
+ input: backupStorageSchema
922
+ .omit({ id: true })
923
+ .extend({
924
+ storageId: publicIdSchema,
925
+ settingsVersion: settingsVersionSchema,
926
+ idempotencyKey: z.string().min(1).max(128),
927
+ })
928
+ .strict(),
929
+ output: z.strictObject({
930
+ storageId: publicIdSchema,
931
+ settingsVersion: settingsVersionSchema,
932
+ }),
933
+ }),
934
+ operation({
935
+ id: 'delete_backup_storage',
936
+ workspacePolicy: {
937
+ operation: 'backup.storage.delete',
938
+ boundary: 'dispatcher',
939
+ },
940
+ description:
941
+ 'Delete an unreferenced backup destination. Policies, active backups, and retained remote artifacts prevent deletion.',
942
+ method: 'DELETE',
943
+ path: '/backup-storage/{storageId}',
944
+ scope: 'backups:write',
945
+ mcp: false,
946
+ destructive: true,
947
+ input: z.strictObject({
948
+ storageId: publicIdSchema,
949
+ settingsVersion: settingsVersionSchema,
950
+ confirmation: z.literal('delete-storage'),
951
+ idempotencyKey: z.string().min(1).max(128),
952
+ }),
953
+ output: z.strictObject({
954
+ storageId: publicIdSchema,
955
+ settingsVersion: settingsVersionSchema,
956
+ }),
957
+ }),
958
+ operation({
959
+ id: 'update_environments',
960
+ workspacePolicy: { operation: 'environment.update', boundary: 'domain' },
961
+ description:
962
+ 'Replace environment definitions with project settings version protection. Omitted server assignments are preserved. Production is required.',
963
+ method: 'PUT',
964
+ path: '/projects/{projectId}/environments',
965
+ scope: 'projects:write',
966
+ destructive: true,
967
+ input: publicProjectInputSchema.extend({
968
+ environments: projectEnvironmentsSchema.shape.environments.max(100),
969
+ settingsVersion: settingsVersionSchema,
970
+ idempotencyKey: z.string().min(1).max(128),
971
+ }),
972
+ output: z.strictObject({
973
+ projectId: publicIdSchema,
974
+ settingsVersion: settingsVersionSchema,
975
+ }),
976
+ }),
977
+ operation({
978
+ id: 'update_environment_servers',
979
+ workspacePolicy: { operation: 'environment.update', boundary: 'domain' },
980
+ description:
981
+ 'Update default and per-environment server assignments, regenerating environment aliases. Unspecified environment assignments are preserved.',
982
+ method: 'PUT',
983
+ path: '/projects/{projectId}/environment-servers',
984
+ scope: 'projects:write',
985
+ input: publicProjectInputSchema.extend({
986
+ defaultServerId: publicIdSchema.nullable(),
987
+ environmentServers: z
988
+ .array(
989
+ z.strictObject({
990
+ environmentId: publicIdSchema,
991
+ serverId: publicIdSchema.nullable(),
992
+ }),
993
+ )
994
+ .max(100),
995
+ settingsVersion: settingsVersionSchema,
996
+ idempotencyKey: z.string().min(1).max(128),
997
+ }),
998
+ output: z.strictObject({
999
+ projectId: publicIdSchema,
1000
+ settingsVersion: settingsVersionSchema,
1001
+ }),
1002
+ }),
1003
+ ]
1004
+
1005
+ export function findPublicApiOperation(id: string) {
1006
+ return publicApiOperations.find((entry) => entry.id === id)
1007
+ }
1008
+
1009
+ // Generated from the very schemas used before execution and before responding.
1010
+ // Unknown input properties are rejected; output schemas reject private fields.
1011
+ export function createPublicOpenApiDocument() {
1012
+ const paths: Record<string, Record<string, unknown>> = {}
1013
+ for (const entry of publicApiOperations) {
1014
+ const parameters = Object.entries(entry.input.shape).flatMap(
1015
+ ([name, schema]) => {
1016
+ const path = entry.path.includes(`{${name}}`)
1017
+ if (!path && entry.method !== 'GET') return []
1018
+ return [
1019
+ {
1020
+ name,
1021
+ in: path ? 'path' : 'query',
1022
+ required: path || !schema.isOptional(),
1023
+ schema: z.toJSONSchema(schema, { io: 'input' }),
1024
+ },
1025
+ ]
1026
+ },
1027
+ )
1028
+ const bodyShape = Object.fromEntries(
1029
+ Object.entries(entry.input.shape).filter(
1030
+ ([name]) =>
1031
+ !entry.path.includes(`{${name}}`) && name !== 'idempotencyKey',
1032
+ ),
1033
+ )
1034
+ const pathItem = (paths[`/api/v1${entry.path}`] ??= {})
1035
+ pathItem[entry.method.toLowerCase()] = {
1036
+ operationId: entry.id,
1037
+ description: entry.description,
1038
+ security: [{ apiKey: [] }],
1039
+ parameters: entry.readOnly
1040
+ ? parameters
1041
+ : [
1042
+ ...parameters,
1043
+ {
1044
+ name: 'Idempotency-Key',
1045
+ in: 'header',
1046
+ required: true,
1047
+ schema: { type: 'string', minLength: 1, maxLength: 128 },
1048
+ },
1049
+ ],
1050
+ ...(entry.readOnly || Object.keys(bodyShape).length === 0
1051
+ ? {}
1052
+ : {
1053
+ requestBody: {
1054
+ required: true,
1055
+ content: {
1056
+ 'application/json': {
1057
+ schema: z.toJSONSchema(z.strictObject(bodyShape), {
1058
+ io: 'input',
1059
+ }),
1060
+ },
1061
+ },
1062
+ },
1063
+ }),
1064
+ responses: Object.fromEntries(
1065
+ [entry.status, 400, 401, 403, 404, 409, 422, 429, 500].map((status) => [
1066
+ status,
1067
+ {
1068
+ description: status === entry.status ? 'Success' : 'Public error',
1069
+ content: {
1070
+ 'application/json': {
1071
+ schema: z.toJSONSchema(
1072
+ status === entry.status
1073
+ ? entry.output
1074
+ : publicErrorResponseSchema,
1075
+ { io: 'output' },
1076
+ ),
1077
+ },
1078
+ },
1079
+ },
1080
+ ]),
1081
+ ),
1082
+ 'x-devpush-scope': entry.scope,
1083
+ }
1084
+ }
1085
+ return {
1086
+ openapi: '3.1.0',
1087
+ info: { title: 'devpush management API', version: '1.0.0' },
1088
+ paths,
1089
+ components: {
1090
+ securitySchemes: {
1091
+ apiKey: {
1092
+ type: 'http',
1093
+ scheme: 'bearer',
1094
+ description: 'A scoped devpush API key created in Account settings.',
1095
+ },
1096
+ },
1097
+ },
1098
+ }
1099
+ }