@polardbx/pxbaas 0.0.0-stage → 0.1.0-beta.2

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 (267) hide show
  1. package/README.md +107 -2
  2. package/bin/pxbaas.js +13 -0
  3. package/dist/app/preflight.d.ts +38 -0
  4. package/dist/app/preflight.d.ts.map +1 -0
  5. package/dist/app/preflight.js +79 -0
  6. package/dist/app/preflight.js.map +1 -0
  7. package/dist/app/spec-lint.d.ts +45 -0
  8. package/dist/app/spec-lint.d.ts.map +1 -0
  9. package/dist/app/spec-lint.js +407 -0
  10. package/dist/app/spec-lint.js.map +1 -0
  11. package/dist/app/templates.d.ts +143 -0
  12. package/dist/app/templates.d.ts.map +1 -0
  13. package/dist/app/templates.js +151 -0
  14. package/dist/app/templates.js.map +1 -0
  15. package/dist/cli/root.d.ts +3 -0
  16. package/dist/cli/root.d.ts.map +1 -0
  17. package/dist/cli/root.js +69 -0
  18. package/dist/cli/root.js.map +1 -0
  19. package/dist/commands/app/index.d.ts +8 -0
  20. package/dist/commands/app/index.d.ts.map +1 -0
  21. package/dist/commands/app/index.js +1476 -0
  22. package/dist/commands/app/index.js.map +1 -0
  23. package/dist/commands/auth/index.d.ts +3 -0
  24. package/dist/commands/auth/index.d.ts.map +1 -0
  25. package/dist/commands/auth/index.js +198 -0
  26. package/dist/commands/auth/index.js.map +1 -0
  27. package/dist/commands/completion/index.d.ts +3 -0
  28. package/dist/commands/completion/index.d.ts.map +1 -0
  29. package/dist/commands/completion/index.js +10 -0
  30. package/dist/commands/completion/index.js.map +1 -0
  31. package/dist/commands/data/index.d.ts +3 -0
  32. package/dist/commands/data/index.d.ts.map +1 -0
  33. package/dist/commands/data/index.js +245 -0
  34. package/dist/commands/data/index.js.map +1 -0
  35. package/dist/commands/db/index.d.ts +15 -0
  36. package/dist/commands/db/index.d.ts.map +1 -0
  37. package/dist/commands/db/index.js +389 -0
  38. package/dist/commands/db/index.js.map +1 -0
  39. package/dist/commands/doctor/index.d.ts +3 -0
  40. package/dist/commands/doctor/index.d.ts.map +1 -0
  41. package/dist/commands/doctor/index.js +305 -0
  42. package/dist/commands/doctor/index.js.map +1 -0
  43. package/dist/commands/functions/delete.d.ts +3 -0
  44. package/dist/commands/functions/delete.d.ts.map +1 -0
  45. package/dist/commands/functions/delete.js +55 -0
  46. package/dist/commands/functions/delete.js.map +1 -0
  47. package/dist/commands/functions/deploy.d.ts +3 -0
  48. package/dist/commands/functions/deploy.d.ts.map +1 -0
  49. package/dist/commands/functions/deploy.js +118 -0
  50. package/dist/commands/functions/deploy.js.map +1 -0
  51. package/dist/commands/functions/index.d.ts +3 -0
  52. package/dist/commands/functions/index.d.ts.map +1 -0
  53. package/dist/commands/functions/index.js +15 -0
  54. package/dist/commands/functions/index.js.map +1 -0
  55. package/dist/commands/functions/list.d.ts +6 -0
  56. package/dist/commands/functions/list.d.ts.map +1 -0
  57. package/dist/commands/functions/list.js +63 -0
  58. package/dist/commands/functions/list.js.map +1 -0
  59. package/dist/commands/functions/new.d.ts +3 -0
  60. package/dist/commands/functions/new.d.ts.map +1 -0
  61. package/dist/commands/functions/new.js +57 -0
  62. package/dist/commands/functions/new.js.map +1 -0
  63. package/dist/commands/gen/index.d.ts +3 -0
  64. package/dist/commands/gen/index.d.ts.map +1 -0
  65. package/dist/commands/gen/index.js +320 -0
  66. package/dist/commands/gen/index.js.map +1 -0
  67. package/dist/commands/instance/index.d.ts +8 -0
  68. package/dist/commands/instance/index.d.ts.map +1 -0
  69. package/dist/commands/instance/index.js +361 -0
  70. package/dist/commands/instance/index.js.map +1 -0
  71. package/dist/commands/login/index.d.ts +3 -0
  72. package/dist/commands/login/index.d.ts.map +1 -0
  73. package/dist/commands/login/index.js +160 -0
  74. package/dist/commands/login/index.js.map +1 -0
  75. package/dist/commands/login/login.d.ts +3 -0
  76. package/dist/commands/login/login.d.ts.map +1 -0
  77. package/dist/commands/login/login.js +185 -0
  78. package/dist/commands/login/login.js.map +1 -0
  79. package/dist/commands/logout/index.d.ts +3 -0
  80. package/dist/commands/logout/index.d.ts.map +1 -0
  81. package/dist/commands/logout/index.js +41 -0
  82. package/dist/commands/logout/index.js.map +1 -0
  83. package/dist/commands/profile/import-env.d.ts +13 -0
  84. package/dist/commands/profile/import-env.d.ts.map +1 -0
  85. package/dist/commands/profile/import-env.js +81 -0
  86. package/dist/commands/profile/import-env.js.map +1 -0
  87. package/dist/commands/profile/index.d.ts +3 -0
  88. package/dist/commands/profile/index.d.ts.map +1 -0
  89. package/dist/commands/profile/index.js +112 -0
  90. package/dist/commands/profile/index.js.map +1 -0
  91. package/dist/commands/rest/index.d.ts +3 -0
  92. package/dist/commands/rest/index.d.ts.map +1 -0
  93. package/dist/commands/rest/index.js +102 -0
  94. package/dist/commands/rest/index.js.map +1 -0
  95. package/dist/commands/skill/index.d.ts +11 -0
  96. package/dist/commands/skill/index.d.ts.map +1 -0
  97. package/dist/commands/skill/index.js +153 -0
  98. package/dist/commands/skill/index.js.map +1 -0
  99. package/dist/commands/status/index.d.ts +3 -0
  100. package/dist/commands/status/index.d.ts.map +1 -0
  101. package/dist/commands/status/index.js +59 -0
  102. package/dist/commands/status/index.js.map +1 -0
  103. package/dist/commands/storage/index.d.ts +3 -0
  104. package/dist/commands/storage/index.d.ts.map +1 -0
  105. package/dist/commands/storage/index.js +198 -0
  106. package/dist/commands/storage/index.js.map +1 -0
  107. package/dist/commands/whoami/index.d.ts +3 -0
  108. package/dist/commands/whoami/index.d.ts.map +1 -0
  109. package/dist/commands/whoami/index.js +82 -0
  110. package/dist/commands/whoami/index.js.map +1 -0
  111. package/dist/credentials/commit.d.ts +38 -0
  112. package/dist/credentials/commit.d.ts.map +1 -0
  113. package/dist/credentials/commit.js +57 -0
  114. package/dist/credentials/commit.js.map +1 -0
  115. package/dist/credentials/credential-store.d.ts +57 -0
  116. package/dist/credentials/credential-store.d.ts.map +1 -0
  117. package/dist/credentials/credential-store.js +180 -0
  118. package/dist/credentials/credential-store.js.map +1 -0
  119. package/dist/credentials/env-file.d.ts +44 -0
  120. package/dist/credentials/env-file.d.ts.map +1 -0
  121. package/dist/credentials/env-file.js +118 -0
  122. package/dist/credentials/env-file.js.map +1 -0
  123. package/dist/credentials/formatter.d.ts +39 -0
  124. package/dist/credentials/formatter.d.ts.map +1 -0
  125. package/dist/credentials/formatter.js +79 -0
  126. package/dist/credentials/formatter.js.map +1 -0
  127. package/dist/credentials/index.d.ts +13 -0
  128. package/dist/credentials/index.d.ts.map +1 -0
  129. package/dist/credentials/index.js +13 -0
  130. package/dist/credentials/index.js.map +1 -0
  131. package/dist/credentials/jwt-introspect.d.ts +32 -0
  132. package/dist/credentials/jwt-introspect.d.ts.map +1 -0
  133. package/dist/credentials/jwt-introspect.js +64 -0
  134. package/dist/credentials/jwt-introspect.js.map +1 -0
  135. package/dist/credentials/masker.d.ts +20 -0
  136. package/dist/credentials/masker.d.ts.map +1 -0
  137. package/dist/credentials/masker.js +37 -0
  138. package/dist/credentials/masker.js.map +1 -0
  139. package/dist/credentials/profile.d.ts +83 -0
  140. package/dist/credentials/profile.d.ts.map +1 -0
  141. package/dist/credentials/profile.js +184 -0
  142. package/dist/credentials/profile.js.map +1 -0
  143. package/dist/credentials/tenant-guard.d.ts +16 -0
  144. package/dist/credentials/tenant-guard.d.ts.map +1 -0
  145. package/dist/credentials/tenant-guard.js +53 -0
  146. package/dist/credentials/tenant-guard.js.map +1 -0
  147. package/dist/credentials/tty-guard.d.ts +19 -0
  148. package/dist/credentials/tty-guard.d.ts.map +1 -0
  149. package/dist/credentials/tty-guard.js +47 -0
  150. package/dist/credentials/tty-guard.js.map +1 -0
  151. package/dist/db/apply-schema.d.ts +144 -0
  152. package/dist/db/apply-schema.d.ts.map +1 -0
  153. package/dist/db/apply-schema.js +359 -0
  154. package/dist/db/apply-schema.js.map +1 -0
  155. package/dist/db/sql-file.d.ts +104 -0
  156. package/dist/db/sql-file.d.ts.map +1 -0
  157. package/dist/db/sql-file.js +584 -0
  158. package/dist/db/sql-file.js.map +1 -0
  159. package/dist/instance/provision.d.ts +89 -0
  160. package/dist/instance/provision.d.ts.map +1 -0
  161. package/dist/instance/provision.js +139 -0
  162. package/dist/instance/provision.js.map +1 -0
  163. package/dist/instance/zero-store.d.ts +47 -0
  164. package/dist/instance/zero-store.d.ts.map +1 -0
  165. package/dist/instance/zero-store.js +91 -0
  166. package/dist/instance/zero-store.js.map +1 -0
  167. package/dist/main.d.ts +3 -0
  168. package/dist/main.d.ts.map +1 -0
  169. package/dist/main.js +46 -0
  170. package/dist/main.js.map +1 -0
  171. package/dist/skill/assets.d.ts +38 -0
  172. package/dist/skill/assets.d.ts.map +1 -0
  173. package/dist/skill/assets.js +111 -0
  174. package/dist/skill/assets.js.map +1 -0
  175. package/dist/skill/hint.d.ts +39 -0
  176. package/dist/skill/hint.d.ts.map +1 -0
  177. package/dist/skill/hint.js +109 -0
  178. package/dist/skill/hint.js.map +1 -0
  179. package/dist/skill/hosts.d.ts +21 -0
  180. package/dist/skill/hosts.d.ts.map +1 -0
  181. package/dist/skill/hosts.js +38 -0
  182. package/dist/skill/hosts.js.map +1 -0
  183. package/dist/skill/installer.d.ts +88 -0
  184. package/dist/skill/installer.d.ts.map +1 -0
  185. package/dist/skill/installer.js +203 -0
  186. package/dist/skill/installer.js.map +1 -0
  187. package/dist/skill/ownership.d.ts +35 -0
  188. package/dist/skill/ownership.d.ts.map +1 -0
  189. package/dist/skill/ownership.js +52 -0
  190. package/dist/skill/ownership.js.map +1 -0
  191. package/package.json +63 -3
  192. package/skills/pxbaas-app-spec/SKILL.md +163 -0
  193. package/skills/pxbaas-app-spec/references/deploy-options.md +157 -0
  194. package/skills/pxbaas-app-spec/references/guardrails-pitfalls.md +89 -0
  195. package/skills/pxbaas-app-spec/references/runtime-contract.md +151 -0
  196. package/skills/pxbaas-app-spec/references/ssr-session.md +121 -0
  197. package/skills/pxbaas-app-spec/references/templates-examples.md +311 -0
  198. package/skills/pxbaas-cli/SKILL.md +171 -0
  199. package/skills/pxbaas-cli/references/api-reference.md +68 -0
  200. package/skills/pxbaas-cli/references/app-deploy.md +170 -0
  201. package/skills/pxbaas-cli/references/auth-and-credentials.md +100 -0
  202. package/skills/pxbaas-cli/references/data-postgrest.md +85 -0
  203. package/skills/pxbaas-cli/references/db-and-meta.md +97 -0
  204. package/skills/pxbaas-cli/references/edge-functions.md +71 -0
  205. package/skills/pxbaas-cli/references/multi-tenant-apps.md +138 -0
  206. package/skills/pxbaas-cli/references/provision.md +86 -0
  207. package/skills/pxbaas-cli/references/safety-and-two-phase.md +49 -0
  208. package/skills/pxbaas-cli/references/storage.md +61 -0
  209. package/skills/pxbaas-cli/references/troubleshooting.md +73 -0
  210. package/templates/webapp/api/index.ts +55 -0
  211. package/templates/webapp/csr-bff/README.md +81 -0
  212. package/templates/webapp/csr-bff/backend/index.ts +168 -0
  213. package/templates/webapp/csr-bff/db/rls.json +13 -0
  214. package/templates/webapp/csr-bff/db/schema.sql +49 -0
  215. package/templates/webapp/csr-bff/frontend/dist/admin.html +101 -0
  216. package/templates/webapp/csr-bff/frontend/dist/article.html +44 -0
  217. package/templates/webapp/csr-bff/frontend/dist/blog.js +206 -0
  218. package/templates/webapp/csr-bff/frontend/dist/blogger.html +53 -0
  219. package/templates/webapp/csr-bff/frontend/dist/index.html +70 -0
  220. package/templates/webapp/csr-bff/frontend/dist/login.html +56 -0
  221. package/templates/webapp/csr-bff/frontend/dist/profile.html +59 -0
  222. package/templates/webapp/csr-bff/frontend/dist/signup.html +78 -0
  223. package/templates/webapp/csr-bff/frontend/dist/style.css +27 -0
  224. package/templates/webapp/manifest.json +299 -0
  225. package/templates/webapp/mpa/about.html +29 -0
  226. package/templates/webapp/mpa/app.js +42 -0
  227. package/templates/webapp/mpa/index.html +42 -0
  228. package/templates/webapp/mpa/index.ts +60 -0
  229. package/templates/webapp/mpa/style.css +42 -0
  230. package/templates/webapp/react-vite/frontend/index.html +12 -0
  231. package/templates/webapp/react-vite/frontend/package-lock.json +1826 -0
  232. package/templates/webapp/react-vite/frontend/package.json +23 -0
  233. package/templates/webapp/react-vite/frontend/src/App.tsx +34 -0
  234. package/templates/webapp/react-vite/frontend/src/main.tsx +13 -0
  235. package/templates/webapp/react-vite/frontend/src/style.css +46 -0
  236. package/templates/webapp/react-vite/frontend/tsconfig.json +20 -0
  237. package/templates/webapp/react-vite/frontend/vite.config.ts +10 -0
  238. package/templates/webapp/react-vite-hono/backend/index.ts +21 -0
  239. package/templates/webapp/react-vite-hono/frontend/index.html +12 -0
  240. package/templates/webapp/react-vite-hono/frontend/package-lock.json +1826 -0
  241. package/templates/webapp/react-vite-hono/frontend/package.json +23 -0
  242. package/templates/webapp/react-vite-hono/frontend/src/App.tsx +47 -0
  243. package/templates/webapp/react-vite-hono/frontend/src/main.tsx +13 -0
  244. package/templates/webapp/react-vite-hono/frontend/src/style.css +66 -0
  245. package/templates/webapp/react-vite-hono/frontend/tsconfig.json +20 -0
  246. package/templates/webapp/react-vite-hono/frontend/vite.config.ts +10 -0
  247. package/templates/webapp/spa/index.ts +119 -0
  248. package/templates/webapp/ssr-auth/backend/index.ts +133 -0
  249. package/templates/webapp/ssr-auth/frontend/dist/index.html +15 -0
  250. package/templates/webapp/ssr-blog/README.md +111 -0
  251. package/templates/webapp/ssr-blog/backend/index.ts +764 -0
  252. package/templates/webapp/ssr-blog/db/rls.json +13 -0
  253. package/templates/webapp/ssr-blog/db/schema.sql +51 -0
  254. package/templates/webapp/ssr-blog/frontend/dist/index.html +39 -0
  255. package/templates/webapp/ssr-frameworks/README.md +64 -0
  256. package/templates/webapp/ssr-frameworks/backend/index.ts +241 -0
  257. package/templates/webapp/ssr-frameworks/frontend/dist/index.html +31 -0
  258. package/templates/webapp/ssr-hono/backend/index.ts +92 -0
  259. package/templates/webapp/ssr-hono/frontend/dist/index.html +12 -0
  260. package/templates/webapp/ssr-shop/README.md +80 -0
  261. package/templates/webapp/ssr-shop/backend/index.ts +491 -0
  262. package/templates/webapp/ssr-shop/db/rls.json +16 -0
  263. package/templates/webapp/ssr-shop/db/schema.sql +90 -0
  264. package/templates/webapp/ssr-shop/frontend/dist/index.html +12 -0
  265. package/templates/webapp/vanilla-static/frontend/app.js +6 -0
  266. package/templates/webapp/vanilla-static/frontend/index.html +19 -0
  267. package/templates/webapp/vanilla-static/frontend/style.css +43 -0
package/README.md CHANGED
@@ -1,3 +1,108 @@
1
- # Temporary Holding Version
1
+ # @polardbx/pxbaas
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Command-line interface for [PolarDB-X BaaS](https://github.com/polardbx/mysql-supabase) (MySQL-Supabase, Backend as a Service). Run SQL, inspect tables and schemas, query and edit table data over the PostgREST-style REST API, deploy Edge Functions and webapp demos, manage storage objects and auth users, generate TypeScript types — and claim a free disposable BaaS instance — all from your terminal.
4
+
5
+ ## Requirements
6
+
7
+ - Node.js >= 20
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ # Public npm (prerelease line publishes under the `beta` dist-tag)
13
+ npm install -g @polardbx/pxbaas@beta
14
+
15
+ # From a repository clone (installer checks Node >= 20, never uses sudo,
16
+ # and verifies the binary with --version + --help after install)
17
+ git clone https://github.com/polardbx/mysql-supabase.git
18
+ cd mysql-supabase/cli
19
+ bash install.sh --yes
20
+
21
+ # Air-gapped environments: build an offline bundle (tarballs + optional Node runtime)
22
+ bash scripts/pack-offline.sh
23
+ ```
24
+
25
+ `@polardbx/pxbaas` depends on `@polardbx/pxbaas-client`; both are published to npm in lockstep, so a plain global install resolves everything. If the OS keychain is unavailable, credentials fall back to an encrypted `~/.baas/credentials.json` (mode 0600).
26
+
27
+ ## Quick Start
28
+
29
+ ```bash
30
+ # No instance yet? Claim a free disposable PolarDB-X Zero BaaS instance.
31
+ # Agent-safe: keys arrive over TLS and only fingerprints are printed.
32
+ pxbaas provision --json
33
+
34
+ # Already have an endpoint + keys? Interactive login (human-only, requires a TTY).
35
+ pxbaas login
36
+
37
+ pxbaas whoami # current profile + key fingerprints (never plaintext keys)
38
+ pxbaas doctor # connectivity / configuration diagnostics
39
+ pxbaas status # instance reachability summary
40
+ ```
41
+
42
+ Every command accepts `--json` for machine-readable output, and `--profile <name>` to select a profile per invocation (`pxbaas profile list / use / import` manage them).
43
+
44
+ ## Command Reference
45
+
46
+ | Group | Commands |
47
+ | --- | --- |
48
+ | Onboarding & diagnostics | `login`, `logout`, `whoami`, `status`, `doctor`, `profile` |
49
+ | Disposable instances (Zero) | `provision` (alias `instance claim`), `instance list / current / credentials / release` |
50
+ | Database | `db query <sql>`, `db tables`, `db schema <table>`, `db push <file>`, `db create-table`, `db add-column` |
51
+ | Data (REST) | `data select / insert / update / delete <table>`, `rest <method> <path>` |
52
+ | Edge Functions | `functions new / deploy / list / delete` |
53
+ | Webapp demos | `app new / deploy / verify / url / list / remove / destroy / templates / db-init / capabilities`, `app share ...` |
54
+ | Storage | `storage ls / cp / mv / rm` |
55
+ | Auth admin | `auth users list / create / invite` |
56
+ | Codegen | `gen types` (TypeScript types from the live schema) |
57
+ | Tooling | `skill install / list / remove`, `completion <shell>` |
58
+
59
+ ### Provisioning (PolarDB-X Zero)
60
+
61
+ ```bash
62
+ pxbaas provision --json # claim a free 15-day Zero BaaS instance -> binds a profile
63
+ pxbaas instance list --json # Zero instances bound locally
64
+ pxbaas instance release <id> --confirm # release (two-phase; destroys cloud resources)
65
+ ```
66
+
67
+ Keys come from Zero over TLS and are stored in the keyring; output shows only fingerprints. Unlike `pxbaas login`, `pxbaas provision` is safe for agents to run. One instance = one profile (`source: zero`); select with `pxbaas profile use` or `--profile`.
68
+
69
+ ### Webapp demos (edge-function sandbox)
70
+
71
+ ```bash
72
+ pxbaas app new shop --template spa --json # scaffold a self-contained single-file webapp
73
+ pxbaas app deploy shop --dry-run --json # preflight (quota / root-abs refs / public reachability)
74
+ pxbaas app deploy shop --json # deploy -> share URL
75
+ pxbaas app verify shop --json # cold-start retry + content-type + API ping
76
+ pxbaas app url shop --json # {endpoint}/functions/v1/{slug}
77
+ pxbaas app destroy shop --confirm --json # delete edge funcs + mount record (DB tables kept)
78
+ ```
79
+
80
+ `pxbaas app` is a higher-level convenience over `pxbaas functions` for lightweight demos. Templates ship under `templates/` (npm/source install only); `pxbaas app templates` is the authoritative list. The CLI scaffolds but does not generate demo code — fill the scaffold yourself or let your coding agent do it.
81
+
82
+ ### Agent Skill
83
+
84
+ ```bash
85
+ pxbaas skill install --host qoder --json # install the bundled pxbaas-cli Agent Skill
86
+ pxbaas skill install --all --dry-run # preview for every detected host
87
+ pxbaas skill list # show install state per host
88
+ pxbaas skill remove --host qoder --confirm # remove (only baas-managed dirs)
89
+ ```
90
+
91
+ Installs into supported Agent hosts (`~/.qoder`, `~/.claude`, `~/.cursor`, `~/.qwen`, `~/.hermes`); fail-closed on foreign directories. When an Agent host is detected but the skill is missing, any `pxbaas` command prints a one-time hint on stderr (skipped under `--json`, silenced with `BAAS_NO_SKILL_HINT=1`). The CLI never writes into agent directories on npm install.
92
+
93
+ ## Security Principles
94
+
95
+ 1. **Human-only login**: `pxbaas login` requires an interactive TTY; agents cannot execute it.
96
+ 2. **Agent commands never accept key parameters**: post-login commands read credentials from the keyring.
97
+ 3. **Output masking**: commands show only key fingerprints (sha256 prefix 8 + suffix 4), never plaintext.
98
+ 4. **Two-phase operations**: destructive writes support `--plan` / `--confirm`.
99
+ 5. **Tenant isolation**: commands validate that the key's tenant matches the profile's tenant before executing.
100
+
101
+ ## Documentation
102
+
103
+ - Repository & monorepo docs: <https://github.com/polardbx/mysql-supabase> (`cli/` directory)
104
+ - Design documents: `mysql_supbase_design/supabase_cli/spcli/` in the repository (capability scope, engineering organization, test design, delivery plan)
105
+
106
+ ## License
107
+
108
+ MIT
package/bin/pxbaas.js ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { fileURLToPath } from 'node:url';
4
+ import { dirname, join } from 'node:path';
5
+
6
+ const __filename = fileURLToPath(import.meta.url);
7
+ const __dirname = dirname(__filename);
8
+
9
+ // Import and run the CLI
10
+ import(join(__dirname, '..', 'dist', 'main.js')).catch((err) => {
11
+ console.error('Failed to start CLI:', err);
12
+ process.exit(1);
13
+ });
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Preflight guardrails for `pxbaas app deploy`.
3
+ *
4
+ * These checks encode the edge-function sandbox constraints (see doc 02 and the
5
+ * sandbox webapp evaluation): 5-function quota, no root-absolute asset refs
6
+ * (they escape the /functions/v1/ prefix onto Studio), and cross-machine sharing
7
+ * requires a public endpoint (sandbox URLs are internal).
8
+ */
9
+ export interface QuotaCheck {
10
+ used: number;
11
+ limit: number;
12
+ ok: boolean;
13
+ near: boolean;
14
+ }
15
+ export interface PreflightInput {
16
+ source: string;
17
+ endpoint: string;
18
+ functionsCount: number;
19
+ quotaLimit?: number;
20
+ verifyJwt: boolean;
21
+ entrypointExists: boolean;
22
+ sourceBytes?: number;
23
+ }
24
+ export interface PreflightResult {
25
+ quota: QuotaCheck;
26
+ rootAbsoluteRefs: string[];
27
+ publicReachable: boolean;
28
+ warnings: string[];
29
+ blockers: string[];
30
+ }
31
+ /** Detect root-absolute references that would escape the /functions/v1/ prefix. */
32
+ export declare function scanRootAbsoluteRefs(source: string): string[];
33
+ /** True when the endpoint host is publicly reachable (not loopback / RFC1918). */
34
+ export declare function isPublicEndpoint(endpoint: string): boolean;
35
+ export declare function checkQuota(used: number, limit?: number): QuotaCheck;
36
+ /** Run all preflight checks and collect warnings/blockers. */
37
+ export declare function runPreflight(input: PreflightInput): PreflightResult;
38
+ //# sourceMappingURL=preflight.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preflight.d.ts","sourceRoot":"","sources":["../../src/app/preflight.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,OAAO,CAAC;IACZ,IAAI,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,UAAU,CAAC;IAClB,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,eAAe,EAAE,OAAO,CAAC;IACzB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,mFAAmF;AACnF,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAY7D;AAED,kFAAkF;AAClF,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAY1D;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,SAAI,GAAG,UAAU,CAE9D;AAED,8DAA8D;AAC9D,wBAAgB,YAAY,CAAC,KAAK,EAAE,cAAc,GAAG,eAAe,CAiDnE"}
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Preflight guardrails for `pxbaas app deploy`.
3
+ *
4
+ * These checks encode the edge-function sandbox constraints (see doc 02 and the
5
+ * sandbox webapp evaluation): 5-function quota, no root-absolute asset refs
6
+ * (they escape the /functions/v1/ prefix onto Studio), and cross-machine sharing
7
+ * requires a public endpoint (sandbox URLs are internal).
8
+ */
9
+ /** Detect root-absolute references that would escape the /functions/v1/ prefix. */
10
+ export function scanRootAbsoluteRefs(source) {
11
+ const patterns = [
12
+ /(href|src|action)\s*=\s*["']\/(?!\/)[^"']*["']/gi,
13
+ /fetch\(\s*["'`]\/(?!\/)[^"'`]*["'`]/gi,
14
+ /url\(\s*\/(?!\/)[^)]*\)/gi,
15
+ ];
16
+ const hits = [];
17
+ for (const re of patterns) {
18
+ const m = source.match(re);
19
+ if (m)
20
+ hits.push(...m);
21
+ }
22
+ return hits;
23
+ }
24
+ /** True when the endpoint host is publicly reachable (not loopback / RFC1918). */
25
+ export function isPublicEndpoint(endpoint) {
26
+ const host = endpoint
27
+ .replace(/^https?:\/\//, "")
28
+ .split("/")[0]
29
+ .split(":")[0]
30
+ .toLowerCase();
31
+ if (!host)
32
+ return false;
33
+ if (["localhost", "127.0.0.1", "::1", "0.0.0.0"].includes(host))
34
+ return false;
35
+ if (/^10\./.test(host))
36
+ return false;
37
+ if (/^192\.168\./.test(host))
38
+ return false;
39
+ if (/^172\.(1[6-9]|2\d|3[01])\./.test(host))
40
+ return false;
41
+ return true;
42
+ }
43
+ export function checkQuota(used, limit = 5) {
44
+ return { used, limit, ok: used < limit, near: used === limit - 1 };
45
+ }
46
+ /** Run all preflight checks and collect warnings/blockers. */
47
+ export function runPreflight(input) {
48
+ const quota = checkQuota(input.functionsCount, input.quotaLimit ?? 5);
49
+ const rootAbsoluteRefs = scanRootAbsoluteRefs(input.source);
50
+ const publicReachable = isPublicEndpoint(input.endpoint);
51
+ const warnings = [];
52
+ const blockers = [];
53
+ if (!input.entrypointExists) {
54
+ blockers.push("Entrypoint file not found. Run `pxbaas app new <name>` first.");
55
+ }
56
+ if (!quota.ok) {
57
+ blockers.push(`Edge Function quota reached (${quota.used}/${quota.limit}). Remove an existing function (\`pxbaas app remove\` / \`pxbaas functions delete\`) or request a higher quota.`);
58
+ }
59
+ else if (quota.near) {
60
+ warnings.push(`Approaching the Edge Function quota (${quota.used}/${quota.limit}).`);
61
+ }
62
+ if (rootAbsoluteRefs.length > 0) {
63
+ // Root-absolute refs are a hard spec violation and are reported as a BLOCKER
64
+ // by spec-lint (pxbaas-app-spec). We still surface the raw list here for data,
65
+ // but do not double-report it as a preflight warning.
66
+ }
67
+ if (!publicReachable) {
68
+ warnings.push(`Endpoint ${input.endpoint} is not publicly reachable (loopback/private). The share URL will NOT work cross-machine.`);
69
+ }
70
+ if (!input.verifyJwt) {
71
+ warnings.push("verify_jwt=false: the share URL is public and the slug is enumerable. Do not co-locate secrets or sensitive logic in this function.");
72
+ }
73
+ const bytes = input.sourceBytes ?? Buffer.byteLength(input.source, "utf8");
74
+ if (bytes > 1_000_000) {
75
+ warnings.push(`Single-file bundle is large (${Math.round(bytes / 1024)}KB). Worker memory is limited (~150MB); consider hosting static assets via Storage/CDN instead.`);
76
+ }
77
+ return { quota, rootAbsoluteRefs, publicReachable, warnings, blockers };
78
+ }
79
+ //# sourceMappingURL=preflight.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preflight.js","sourceRoot":"","sources":["../../src/app/preflight.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,45 @@
1
+ /** Static compliance checks for legacy edge-function apps and manifest-v2 webapps. */
2
+ import type { BackendFramework } from "./templates.js";
3
+ export type Severity = "blocker" | "warning";
4
+ export interface Finding {
5
+ rule: string;
6
+ severity: Severity;
7
+ message: string;
8
+ specRef: string;
9
+ }
10
+ export interface SpecLintResult {
11
+ passed: boolean;
12
+ blockers: Finding[];
13
+ warnings: Finding[];
14
+ }
15
+ export interface ArtifactSource {
16
+ path: string;
17
+ source: string;
18
+ }
19
+ export interface SpecLintOptions {
20
+ verifyJwt?: boolean;
21
+ mode?: string;
22
+ declaredFiles?: string[];
23
+ existingFiles?: string[];
24
+ auxiliarySources?: string[];
25
+ frontendFiles?: string[];
26
+ frontendSources?: ArtifactSource[];
27
+ frontendConfigSource?: string;
28
+ frontendProjectSources?: string[];
29
+ requireHashRouter?: boolean;
30
+ backendSource?: string;
31
+ backendFramework?: BackendFramework;
32
+ honoVersion?: string | null;
33
+ /** Capability ssrLibs: curated SSR renderer allow-list (name@version) (W9/D7). */
34
+ ssrLibs?: string[];
35
+ secrets?: string[];
36
+ egressPolicy?: string;
37
+ ssrFallback?: boolean;
38
+ ssrProbePath?: string;
39
+ backendSession?: string;
40
+ sessionMode?: string;
41
+ sessionHeaders?: string[];
42
+ }
43
+ /** Lint source and artifact metadata while preserving legacy spa/api/mpa behavior. */
44
+ export declare function lintAppSource(source: string, options?: SpecLintOptions): SpecLintResult;
45
+ //# sourceMappingURL=spec-lint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spec-lint.d.ts","sourceRoot":"","sources":["../../src/app/spec-lint.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAGtF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,MAAM,MAAM,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAC;AAE7C,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,QAAQ,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,QAAQ,EAAE,OAAO,EAAE,CAAC;CACrB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,eAAe;IAC9B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,eAAe,CAAC,EAAE,cAAc,EAAE,CAAC;IACnC,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,sBAAsB,CAAC,EAAE,MAAM,EAAE,CAAC;IAClC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,kFAAkF;IAClF,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AAmaD,sFAAsF;AACtF,wBAAgB,aAAa,CAC3B,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,eAAoB,GAC5B,cAAc,CA6GhB"}