@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.
- package/README.md +107 -2
- package/bin/pxbaas.js +13 -0
- package/dist/app/preflight.d.ts +38 -0
- package/dist/app/preflight.d.ts.map +1 -0
- package/dist/app/preflight.js +79 -0
- package/dist/app/preflight.js.map +1 -0
- package/dist/app/spec-lint.d.ts +45 -0
- package/dist/app/spec-lint.d.ts.map +1 -0
- package/dist/app/spec-lint.js +407 -0
- package/dist/app/spec-lint.js.map +1 -0
- package/dist/app/templates.d.ts +143 -0
- package/dist/app/templates.d.ts.map +1 -0
- package/dist/app/templates.js +151 -0
- package/dist/app/templates.js.map +1 -0
- package/dist/cli/root.d.ts +3 -0
- package/dist/cli/root.d.ts.map +1 -0
- package/dist/cli/root.js +69 -0
- package/dist/cli/root.js.map +1 -0
- package/dist/commands/app/index.d.ts +8 -0
- package/dist/commands/app/index.d.ts.map +1 -0
- package/dist/commands/app/index.js +1476 -0
- package/dist/commands/app/index.js.map +1 -0
- package/dist/commands/auth/index.d.ts +3 -0
- package/dist/commands/auth/index.d.ts.map +1 -0
- package/dist/commands/auth/index.js +198 -0
- package/dist/commands/auth/index.js.map +1 -0
- package/dist/commands/completion/index.d.ts +3 -0
- package/dist/commands/completion/index.d.ts.map +1 -0
- package/dist/commands/completion/index.js +10 -0
- package/dist/commands/completion/index.js.map +1 -0
- package/dist/commands/data/index.d.ts +3 -0
- package/dist/commands/data/index.d.ts.map +1 -0
- package/dist/commands/data/index.js +245 -0
- package/dist/commands/data/index.js.map +1 -0
- package/dist/commands/db/index.d.ts +15 -0
- package/dist/commands/db/index.d.ts.map +1 -0
- package/dist/commands/db/index.js +389 -0
- package/dist/commands/db/index.js.map +1 -0
- package/dist/commands/doctor/index.d.ts +3 -0
- package/dist/commands/doctor/index.d.ts.map +1 -0
- package/dist/commands/doctor/index.js +305 -0
- package/dist/commands/doctor/index.js.map +1 -0
- package/dist/commands/functions/delete.d.ts +3 -0
- package/dist/commands/functions/delete.d.ts.map +1 -0
- package/dist/commands/functions/delete.js +55 -0
- package/dist/commands/functions/delete.js.map +1 -0
- package/dist/commands/functions/deploy.d.ts +3 -0
- package/dist/commands/functions/deploy.d.ts.map +1 -0
- package/dist/commands/functions/deploy.js +118 -0
- package/dist/commands/functions/deploy.js.map +1 -0
- package/dist/commands/functions/index.d.ts +3 -0
- package/dist/commands/functions/index.d.ts.map +1 -0
- package/dist/commands/functions/index.js +15 -0
- package/dist/commands/functions/index.js.map +1 -0
- package/dist/commands/functions/list.d.ts +6 -0
- package/dist/commands/functions/list.d.ts.map +1 -0
- package/dist/commands/functions/list.js +63 -0
- package/dist/commands/functions/list.js.map +1 -0
- package/dist/commands/functions/new.d.ts +3 -0
- package/dist/commands/functions/new.d.ts.map +1 -0
- package/dist/commands/functions/new.js +57 -0
- package/dist/commands/functions/new.js.map +1 -0
- package/dist/commands/gen/index.d.ts +3 -0
- package/dist/commands/gen/index.d.ts.map +1 -0
- package/dist/commands/gen/index.js +320 -0
- package/dist/commands/gen/index.js.map +1 -0
- package/dist/commands/instance/index.d.ts +8 -0
- package/dist/commands/instance/index.d.ts.map +1 -0
- package/dist/commands/instance/index.js +361 -0
- package/dist/commands/instance/index.js.map +1 -0
- package/dist/commands/login/index.d.ts +3 -0
- package/dist/commands/login/index.d.ts.map +1 -0
- package/dist/commands/login/index.js +160 -0
- package/dist/commands/login/index.js.map +1 -0
- package/dist/commands/login/login.d.ts +3 -0
- package/dist/commands/login/login.d.ts.map +1 -0
- package/dist/commands/login/login.js +185 -0
- package/dist/commands/login/login.js.map +1 -0
- package/dist/commands/logout/index.d.ts +3 -0
- package/dist/commands/logout/index.d.ts.map +1 -0
- package/dist/commands/logout/index.js +41 -0
- package/dist/commands/logout/index.js.map +1 -0
- package/dist/commands/profile/import-env.d.ts +13 -0
- package/dist/commands/profile/import-env.d.ts.map +1 -0
- package/dist/commands/profile/import-env.js +81 -0
- package/dist/commands/profile/import-env.js.map +1 -0
- package/dist/commands/profile/index.d.ts +3 -0
- package/dist/commands/profile/index.d.ts.map +1 -0
- package/dist/commands/profile/index.js +112 -0
- package/dist/commands/profile/index.js.map +1 -0
- package/dist/commands/rest/index.d.ts +3 -0
- package/dist/commands/rest/index.d.ts.map +1 -0
- package/dist/commands/rest/index.js +102 -0
- package/dist/commands/rest/index.js.map +1 -0
- package/dist/commands/skill/index.d.ts +11 -0
- package/dist/commands/skill/index.d.ts.map +1 -0
- package/dist/commands/skill/index.js +153 -0
- package/dist/commands/skill/index.js.map +1 -0
- package/dist/commands/status/index.d.ts +3 -0
- package/dist/commands/status/index.d.ts.map +1 -0
- package/dist/commands/status/index.js +59 -0
- package/dist/commands/status/index.js.map +1 -0
- package/dist/commands/storage/index.d.ts +3 -0
- package/dist/commands/storage/index.d.ts.map +1 -0
- package/dist/commands/storage/index.js +198 -0
- package/dist/commands/storage/index.js.map +1 -0
- package/dist/commands/whoami/index.d.ts +3 -0
- package/dist/commands/whoami/index.d.ts.map +1 -0
- package/dist/commands/whoami/index.js +82 -0
- package/dist/commands/whoami/index.js.map +1 -0
- package/dist/credentials/commit.d.ts +38 -0
- package/dist/credentials/commit.d.ts.map +1 -0
- package/dist/credentials/commit.js +57 -0
- package/dist/credentials/commit.js.map +1 -0
- package/dist/credentials/credential-store.d.ts +57 -0
- package/dist/credentials/credential-store.d.ts.map +1 -0
- package/dist/credentials/credential-store.js +180 -0
- package/dist/credentials/credential-store.js.map +1 -0
- package/dist/credentials/env-file.d.ts +44 -0
- package/dist/credentials/env-file.d.ts.map +1 -0
- package/dist/credentials/env-file.js +118 -0
- package/dist/credentials/env-file.js.map +1 -0
- package/dist/credentials/formatter.d.ts +39 -0
- package/dist/credentials/formatter.d.ts.map +1 -0
- package/dist/credentials/formatter.js +79 -0
- package/dist/credentials/formatter.js.map +1 -0
- package/dist/credentials/index.d.ts +13 -0
- package/dist/credentials/index.d.ts.map +1 -0
- package/dist/credentials/index.js +13 -0
- package/dist/credentials/index.js.map +1 -0
- package/dist/credentials/jwt-introspect.d.ts +32 -0
- package/dist/credentials/jwt-introspect.d.ts.map +1 -0
- package/dist/credentials/jwt-introspect.js +64 -0
- package/dist/credentials/jwt-introspect.js.map +1 -0
- package/dist/credentials/masker.d.ts +20 -0
- package/dist/credentials/masker.d.ts.map +1 -0
- package/dist/credentials/masker.js +37 -0
- package/dist/credentials/masker.js.map +1 -0
- package/dist/credentials/profile.d.ts +83 -0
- package/dist/credentials/profile.d.ts.map +1 -0
- package/dist/credentials/profile.js +184 -0
- package/dist/credentials/profile.js.map +1 -0
- package/dist/credentials/tenant-guard.d.ts +16 -0
- package/dist/credentials/tenant-guard.d.ts.map +1 -0
- package/dist/credentials/tenant-guard.js +53 -0
- package/dist/credentials/tenant-guard.js.map +1 -0
- package/dist/credentials/tty-guard.d.ts +19 -0
- package/dist/credentials/tty-guard.d.ts.map +1 -0
- package/dist/credentials/tty-guard.js +47 -0
- package/dist/credentials/tty-guard.js.map +1 -0
- package/dist/db/apply-schema.d.ts +144 -0
- package/dist/db/apply-schema.d.ts.map +1 -0
- package/dist/db/apply-schema.js +359 -0
- package/dist/db/apply-schema.js.map +1 -0
- package/dist/db/sql-file.d.ts +104 -0
- package/dist/db/sql-file.d.ts.map +1 -0
- package/dist/db/sql-file.js +584 -0
- package/dist/db/sql-file.js.map +1 -0
- package/dist/instance/provision.d.ts +89 -0
- package/dist/instance/provision.d.ts.map +1 -0
- package/dist/instance/provision.js +139 -0
- package/dist/instance/provision.js.map +1 -0
- package/dist/instance/zero-store.d.ts +47 -0
- package/dist/instance/zero-store.d.ts.map +1 -0
- package/dist/instance/zero-store.js +91 -0
- package/dist/instance/zero-store.js.map +1 -0
- package/dist/main.d.ts +3 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +46 -0
- package/dist/main.js.map +1 -0
- package/dist/skill/assets.d.ts +38 -0
- package/dist/skill/assets.d.ts.map +1 -0
- package/dist/skill/assets.js +111 -0
- package/dist/skill/assets.js.map +1 -0
- package/dist/skill/hint.d.ts +39 -0
- package/dist/skill/hint.d.ts.map +1 -0
- package/dist/skill/hint.js +109 -0
- package/dist/skill/hint.js.map +1 -0
- package/dist/skill/hosts.d.ts +21 -0
- package/dist/skill/hosts.d.ts.map +1 -0
- package/dist/skill/hosts.js +38 -0
- package/dist/skill/hosts.js.map +1 -0
- package/dist/skill/installer.d.ts +88 -0
- package/dist/skill/installer.d.ts.map +1 -0
- package/dist/skill/installer.js +203 -0
- package/dist/skill/installer.js.map +1 -0
- package/dist/skill/ownership.d.ts +35 -0
- package/dist/skill/ownership.d.ts.map +1 -0
- package/dist/skill/ownership.js +52 -0
- package/dist/skill/ownership.js.map +1 -0
- package/package.json +63 -3
- package/skills/pxbaas-app-spec/SKILL.md +163 -0
- package/skills/pxbaas-app-spec/references/deploy-options.md +157 -0
- package/skills/pxbaas-app-spec/references/guardrails-pitfalls.md +89 -0
- package/skills/pxbaas-app-spec/references/runtime-contract.md +151 -0
- package/skills/pxbaas-app-spec/references/ssr-session.md +121 -0
- package/skills/pxbaas-app-spec/references/templates-examples.md +311 -0
- package/skills/pxbaas-cli/SKILL.md +171 -0
- package/skills/pxbaas-cli/references/api-reference.md +68 -0
- package/skills/pxbaas-cli/references/app-deploy.md +170 -0
- package/skills/pxbaas-cli/references/auth-and-credentials.md +100 -0
- package/skills/pxbaas-cli/references/data-postgrest.md +85 -0
- package/skills/pxbaas-cli/references/db-and-meta.md +97 -0
- package/skills/pxbaas-cli/references/edge-functions.md +71 -0
- package/skills/pxbaas-cli/references/multi-tenant-apps.md +138 -0
- package/skills/pxbaas-cli/references/provision.md +86 -0
- package/skills/pxbaas-cli/references/safety-and-two-phase.md +49 -0
- package/skills/pxbaas-cli/references/storage.md +61 -0
- package/skills/pxbaas-cli/references/troubleshooting.md +73 -0
- package/templates/webapp/api/index.ts +55 -0
- package/templates/webapp/csr-bff/README.md +81 -0
- package/templates/webapp/csr-bff/backend/index.ts +168 -0
- package/templates/webapp/csr-bff/db/rls.json +13 -0
- package/templates/webapp/csr-bff/db/schema.sql +49 -0
- package/templates/webapp/csr-bff/frontend/dist/admin.html +101 -0
- package/templates/webapp/csr-bff/frontend/dist/article.html +44 -0
- package/templates/webapp/csr-bff/frontend/dist/blog.js +206 -0
- package/templates/webapp/csr-bff/frontend/dist/blogger.html +53 -0
- package/templates/webapp/csr-bff/frontend/dist/index.html +70 -0
- package/templates/webapp/csr-bff/frontend/dist/login.html +56 -0
- package/templates/webapp/csr-bff/frontend/dist/profile.html +59 -0
- package/templates/webapp/csr-bff/frontend/dist/signup.html +78 -0
- package/templates/webapp/csr-bff/frontend/dist/style.css +27 -0
- package/templates/webapp/manifest.json +299 -0
- package/templates/webapp/mpa/about.html +29 -0
- package/templates/webapp/mpa/app.js +42 -0
- package/templates/webapp/mpa/index.html +42 -0
- package/templates/webapp/mpa/index.ts +60 -0
- package/templates/webapp/mpa/style.css +42 -0
- package/templates/webapp/react-vite/frontend/index.html +12 -0
- package/templates/webapp/react-vite/frontend/package-lock.json +1826 -0
- package/templates/webapp/react-vite/frontend/package.json +23 -0
- package/templates/webapp/react-vite/frontend/src/App.tsx +34 -0
- package/templates/webapp/react-vite/frontend/src/main.tsx +13 -0
- package/templates/webapp/react-vite/frontend/src/style.css +46 -0
- package/templates/webapp/react-vite/frontend/tsconfig.json +20 -0
- package/templates/webapp/react-vite/frontend/vite.config.ts +10 -0
- package/templates/webapp/react-vite-hono/backend/index.ts +21 -0
- package/templates/webapp/react-vite-hono/frontend/index.html +12 -0
- package/templates/webapp/react-vite-hono/frontend/package-lock.json +1826 -0
- package/templates/webapp/react-vite-hono/frontend/package.json +23 -0
- package/templates/webapp/react-vite-hono/frontend/src/App.tsx +47 -0
- package/templates/webapp/react-vite-hono/frontend/src/main.tsx +13 -0
- package/templates/webapp/react-vite-hono/frontend/src/style.css +66 -0
- package/templates/webapp/react-vite-hono/frontend/tsconfig.json +20 -0
- package/templates/webapp/react-vite-hono/frontend/vite.config.ts +10 -0
- package/templates/webapp/spa/index.ts +119 -0
- package/templates/webapp/ssr-auth/backend/index.ts +133 -0
- package/templates/webapp/ssr-auth/frontend/dist/index.html +15 -0
- package/templates/webapp/ssr-blog/README.md +111 -0
- package/templates/webapp/ssr-blog/backend/index.ts +764 -0
- package/templates/webapp/ssr-blog/db/rls.json +13 -0
- package/templates/webapp/ssr-blog/db/schema.sql +51 -0
- package/templates/webapp/ssr-blog/frontend/dist/index.html +39 -0
- package/templates/webapp/ssr-frameworks/README.md +64 -0
- package/templates/webapp/ssr-frameworks/backend/index.ts +241 -0
- package/templates/webapp/ssr-frameworks/frontend/dist/index.html +31 -0
- package/templates/webapp/ssr-hono/backend/index.ts +92 -0
- package/templates/webapp/ssr-hono/frontend/dist/index.html +12 -0
- package/templates/webapp/ssr-shop/README.md +80 -0
- package/templates/webapp/ssr-shop/backend/index.ts +491 -0
- package/templates/webapp/ssr-shop/db/rls.json +16 -0
- package/templates/webapp/ssr-shop/db/schema.sql +90 -0
- package/templates/webapp/ssr-shop/frontend/dist/index.html +12 -0
- package/templates/webapp/vanilla-static/frontend/app.js +6 -0
- package/templates/webapp/vanilla-static/frontend/index.html +19 -0
- package/templates/webapp/vanilla-static/frontend/style.css +43 -0
package/README.md
CHANGED
|
@@ -1,3 +1,108 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @polardbx/pxbaas
|
|
2
2
|
|
|
3
|
-
|
|
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"}
|