@supacloud/cli 0.120.1 → 0.121.6
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 +10 -9
- package/dist/index.js +639 -141
- package/dist/shared/tools/app-database-check.d.ts +2 -0
- package/dist/shared/tools/app-starter-database.d.ts +2 -1
- package/dist/shared/tools/app-starter-templates.d.ts +20 -3
- package/dist/shared/tools/app-starter.d.ts +3 -2
- package/dist/shared/tools/app-tools.d.ts +1 -1
- package/dist/shared/tools/lite-cli-tools.d.ts +5 -0
- package/package.json +10 -10
- package/skills/supacloud/references/app-workflow.md +3 -0
|
@@ -2,6 +2,8 @@ export interface AppDatabaseCheck {
|
|
|
2
2
|
name: "database-source-contracts";
|
|
3
3
|
ok: boolean;
|
|
4
4
|
detail: string;
|
|
5
|
+
/** `source` when the checker reports; `runtime` when that checker cannot run. */
|
|
6
|
+
layer: "source" | "runtime";
|
|
5
7
|
}
|
|
6
8
|
/** Use the project's installed tool, not arbitrary package scripts or remote database access. */
|
|
7
9
|
export declare function checkAppDatabaseSources(projectRoot: string): AppDatabaseCheck | undefined;
|
|
@@ -9,10 +9,11 @@ export declare const STARTER_DATABASE_CONFIG: {
|
|
|
9
9
|
auditConsumers: never[];
|
|
10
10
|
trustedHosts: string[];
|
|
11
11
|
role: string;
|
|
12
|
+
policyRls: string;
|
|
12
13
|
};
|
|
13
14
|
export declare const STARTER_DATABASE_MODEL = "datasource db {\n provider = \"postgresql\"\n url = env(\"DATABASE_URL\")\n}\nplugin policy {\n provider = \"@zenstackhq/plugin-policy\"\n}\ntype Principal {\n id String\n canApprove Boolean\n @@auth()\n}\nmodel Application {\n singleton Boolean @id @default(true)\n projectId String @map(\"project_id\")\n tenantId String @map(\"tenant_id\")\n @@map(\"starter_application\")\n @@allow(\"read\", auth() != null)\n}\nmodel Review {\n id String @id\n ownerId String @map(\"owner_id\")\n state String\n version Int\n attachment Attachment?\n results AttachmentResult[]\n @@map(\"starter_reviews\")\n @@allow(\"read\", auth() != null && (ownerId == auth().id || auth().canApprove))\n}\nmodel Member {\n subject String @id\n enabled Boolean @default(true)\n canApprove Boolean @default(false) @map(\"can_approve\")\n storageSubject String? @unique @db.Uuid @map(\"storage_subject\")\n @@map(\"starter_members\")\n @@allow(\"read\", auth() != null && subject == auth().id)\n}\nmodel Attachment {\n reviewId String @id @map(\"review_id\")\n review Review @relation(fields: [reviewId], references: [id])\n artifactId String @unique @db.Uuid @map(\"artifact_id\")\n ownerId String @map(\"owner_id\")\n runId String @unique @db.Uuid @map(\"run_id\")\n objectPath String @unique @map(\"object_path\")\n retries AttachmentRetry[]\n @@map(\"starter_attachments\")\n @@allow(\"read\", auth() != null && ownerId == auth().id)\n}\nmodel AttachmentResult {\n reviewId String @map(\"review_id\")\n review Review @relation(fields: [reviewId], references: [id])\n version Int\n artifactId String @db.Uuid @map(\"artifact_id\")\n result Json\n @@id([reviewId, version, artifactId])\n @@map(\"starter_attachment_results\")\n @@allow(\"read\", auth() != null && review.ownerId == auth().id)\n}\nmodel AttachmentRetry {\n runId String @id @db.Uuid @map(\"run_id\")\n reviewId String @map(\"review_id\")\n attachment Attachment @relation(fields: [reviewId], references: [reviewId])\n previousRunId String @unique @db.Uuid @map(\"previous_run_id\")\n generation Int\n @@unique([reviewId, generation])\n @@map(\"starter_attachment_retries\")\n @@allow(\"read\", auth() != null && attachment.ownerId == auth().id)\n}\n";
|
|
14
15
|
export declare const STARTER_DATABASE_SCHEMA = "export type { Review as ReviewRow, Attachment as AttachmentRow, AttachmentRetry as AttachmentRetryRow } from \"../zenstack/generated/models\";\nimport type { Review } from \"../zenstack/generated/models\";\nexport type NewReview = Review;\n";
|
|
15
16
|
export declare const STARTER_DATABASE_MODULES = "import { defineDatabaseModule } from \"@supacloud/db\";\n\nconst backendPolicies = [\n [\"starter_backend_binding_read\", \"public.starter_application\", \"select\", [\"starter_review_http\", \"starter_review_worker\"]],\n [\"starter_backend_binding_lock\", \"public.starter_application\", \"update\", [\"starter_review_http\", \"starter_review_worker\"]],\n [\"starter_backend_binding_immutable\", \"public.starter_application\", \"update\", [\"starter_review_http\", \"starter_review_worker\"]],\n [\"starter_backend_member_read\", \"public.starter_members\", \"select\", [\"starter_review_http\", \"starter_review_worker\"]],\n [\"starter_backend_member_lock\", \"public.starter_members\", \"update\", [\"starter_review_http\", \"starter_review_worker\"]],\n [\"starter_backend_member_immutable\", \"public.starter_members\", \"update\", [\"starter_review_http\", \"starter_review_worker\"]],\n [\"starter_backend_review_read\", \"public.starter_reviews\", \"select\", [\"starter_review_http\", \"starter_review_worker\"]],\n [\"starter_backend_review_update\", \"public.starter_reviews\", \"update\", [\"starter_review_http\"]],\n [\"starter_worker_review_immutable\", \"public.starter_reviews\", \"update\", [\"starter_review_worker\"]],\n [\"starter_backend_attachment_read\", \"public.starter_attachments\", \"select\", [\"starter_review_http\", \"starter_review_worker\"]],\n [\"starter_backend_attachment_lock\", \"public.starter_attachments\", \"update\", [\"starter_review_http\", \"starter_review_worker\"]],\n [\"starter_backend_attachment_immutable\", \"public.starter_attachments\", \"update\", [\"starter_review_http\", \"starter_review_worker\"]],\n [\"starter_http_attachment_insert\", \"public.starter_attachments\", \"insert\", [\"starter_review_http\"]],\n [\"starter_worker_result_read\", \"public.starter_attachment_results\", \"select\", [\"starter_review_worker\"]],\n [\"starter_worker_result_insert\", \"public.starter_attachment_results\", \"insert\", [\"starter_review_worker\"]],\n] as const;\n\n// The module is the single live-Catalog ownership contract for starter tables.\nexport default defineDatabaseModule({\n name: \"starter\",\n tables: [\"public.starter_application\", \"public.starter_reviews\", \"public.starter_members\", \"public.starter_attachments\", \"public.starter_attachment_results\", \"public.starter_attachment_retries\"],\n policies: [\n ...([\n [\"starter_http_retry_read\", \"select\", \"starter_review_http\"],\n [\"starter_http_retry_insert\", \"insert\", \"starter_review_http\"],\n [\"starter_worker_retry_read\", \"select\", \"starter_review_worker\"],\n ] as const).map(([name, operation, role]) => ({\n name, table: \"public.starter_attachment_retries\", operation, roles: [role],\n source: \"migrations/005-review-task-recovery.sql\", tests: [\"tests/database-governance.sql\"],\n })),\n ...backendPolicies.map(([name, table, operation, roles]) => ({\n name, table, operation, roles: [...roles], source: \"migrations/004-review-runtime-roles.sql\",\n tests: [\"tests/database-governance.sql\"],\n })),\n {\n name: \"starter_member_read\", table: \"public.starter_members\", operation: \"select\",\n roles: [\"authenticated\"], source: \"migrations/003-review-uploads.sql\",\n tests: [\"tests/database-governance.sql\"],\n },\n {\n name: \"starter_review_read\", table: \"public.starter_reviews\", operation: \"select\",\n roles: [\"authenticated\"], source: \"migrations/003-review-uploads.sql\",\n tests: [\"tests/database-governance.sql\"],\n },\n ],\n});\n";
|
|
16
17
|
export declare const STARTER_DATABASE_TEST = "-- Read-only catalog assertions; behavioral authorization tests remain separate.\nBEGIN READ ONLY;\nDO $test$\nDECLARE\n owned text[] := ARRAY['starter_application','starter_reviews','starter_members',\n 'starter_attachments','starter_attachment_results','starter_attachment_retries'];\nBEGIN\n IF (SELECT count(*) FROM pg_class c JOIN pg_namespace n ON n.oid=c.relnamespace\n WHERE n.nspname='public' AND c.relname=ANY(owned) AND c.relrowsecurity) <> 6 THEN\n RAISE EXCEPTION 'All starter tables must exist with RLS enabled';\n END IF;\n IF (SELECT count(*) FROM pg_policy p JOIN pg_class c ON c.oid=p.polrelid\n JOIN pg_namespace n ON n.oid=c.relnamespace\n WHERE n.nspname='public' AND c.relname=ANY(owned)) <> 20 THEN\n RAISE EXCEPTION 'Starter policy inventory changed; reconcile db/modules.ts';\n END IF;\n IF EXISTS (SELECT 1 FROM pg_roles WHERE rolname IN ('starter_review_http','starter_review_worker')\n AND (rolsuper OR rolbypassrls)) THEN\n RAISE EXCEPTION 'Starter roles must not bypass row security';\n END IF;\n IF (SELECT count(*) FROM pg_roles WHERE rolname IN ('starter_review_http','starter_review_worker')) <> 2 THEN\n RAISE EXCEPTION 'Starter runtime roles are missing';\n END IF;\nEND\n$test$;\nROLLBACK;\n";
|
|
17
|
-
export declare const STARTER_DATABASE_GUIDE = "\n## Model and migration workflow\n\nMaintain zenstack/schema.zmodel. Run `bun run db:generate` to compile model and RPC\ncontracts; commit generated types with their sources. Do not introduce any/@ts-ignore\nto bypass model or contract diagnostics. `bun run db:check` compares\nfresh generation without writing files or opening a database.
|
|
18
|
+
export declare const STARTER_DATABASE_GUIDE = "\n## Model and migration workflow\n\nMaintain zenstack/schema.zmodel. Run `bun run db:generate` to compile model and RPC\ncontracts; commit generated types with their sources. Do not introduce any/@ts-ignore\nto bypass model or contract diagnostics. `bun run db:check` compares\nfresh generation without writing files or opening a database. This starter sets\n`policyRls` to `deferred` because relation predicates and storage fences are reviewed\nSQL, not the authenticated row-policy projection. Command writes still use the shared\ntransaction, receipt and audit boundary, not unrestricted CRUD. SQL constraints, RPCs\nand RLS remain explicit reviewed migrations when the model language cannot express them.\n\nUse `bun run db:diff -- --candidate output/database-audit/change.sql` with an\nexplicit read-only SUPACLOUD_MODEL_DATABASE_URL. Review the SQL, then promote a new\nforward migration through the existing SupaCloud plan/apply ledger. Never run\nzen migrate deploy or db push against a managed production database.\n`bun run db:pull -- --candidate output/database-audit/schema.zmodel` writes a\nreview candidate only; it never overwrites the maintained model. Add policies\nbefore adopting introspection output. Keep one migration history and preserve RLS.\n\nAdopting a database that has no model yet starts with the same command: pull\nintrospects through a temporary datasource-only model, so no hand-written ZModel\nis required. Review the candidate, add the policy plugin and @@allow rules, move\nit to zenstack/schema.zmodel, then run `bun run db:generate`. Until that file\nexists, `db:diff` and `db:generate` fail closed instead of building from an\nunreviewed introspection result. Keep the host wiring unchanged: one\ncreateZenStackDatabase composition root supplies read-only models and the\ntransactional command store.\n";
|
|
18
19
|
export declare function starterDatabaseFiles(): Record<string, string>;
|
|
@@ -1,8 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
/** Canonical init templates. Unknown values fail closed. */
|
|
2
|
+
export declare const STARTER_TEMPLATES: readonly ["minimal", "client", "command", "model-command"];
|
|
3
|
+
export type StarterTemplate = (typeof STARTER_TEMPLATES)[number];
|
|
4
|
+
/** Forced vibecoding default: compiler, Elysia, and @supacloud/app. */
|
|
5
|
+
export declare const DEFAULT_STARTER_TEMPLATE = "minimal";
|
|
6
|
+
/** Explicit data-plane-only scaffold. Never the default. */
|
|
7
|
+
export declare const CLIENT_STARTER_TEMPLATE = "client";
|
|
8
|
+
/**
|
|
9
|
+
* Accepted CLI aliases. `app` was the 2518 name for the compiler stack and
|
|
10
|
+
* resolves to `minimal` so packed smoke scripts keep working.
|
|
11
|
+
*/
|
|
12
|
+
export declare const STARTER_TEMPLATE_ALIASES: {
|
|
13
|
+
readonly app: "minimal";
|
|
14
|
+
};
|
|
15
|
+
export type StarterTemplateInput = StarterTemplate | keyof typeof STARTER_TEMPLATE_ALIASES;
|
|
2
16
|
export interface StarterSdkDependencies {
|
|
3
17
|
"@supacloud/js": string;
|
|
4
18
|
"@supabase/supabase-js": string;
|
|
5
19
|
}
|
|
20
|
+
export declare function isStarterTemplate(value: string): value is StarterTemplate;
|
|
21
|
+
/** Resolve CLI/API input to a canonical template. Undefined selects the forced default. */
|
|
22
|
+
export declare function resolveStarterTemplate(input: string | undefined): StarterTemplate;
|
|
6
23
|
export declare function baseTemplateFiles(name: string, sdkDependencies: StarterSdkDependencies): Record<string, string>;
|
|
7
|
-
/**
|
|
8
|
-
export declare function appTemplateFiles(name: string, template: "minimal", sdkDependencies: StarterSdkDependencies): Record<string, string>;
|
|
24
|
+
/** `minimal` is the forced compiler/Effect stack. `client` is supabase-js only. */
|
|
25
|
+
export declare function appTemplateFiles(name: string, template: "minimal" | "client", sdkDependencies: StarterSdkDependencies): Record<string, string>;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { type StarterTemplate } from "./app-starter-templates";
|
|
1
|
+
import { type StarterTemplate, type StarterTemplateInput } from "./app-starter-templates";
|
|
2
2
|
/** Embedded source strings are included in both the npm CLI and standalone binary. */
|
|
3
3
|
export declare function appStarterFiles(name: string): Record<string, string>;
|
|
4
4
|
export declare function initializeAppProject(options: {
|
|
5
5
|
root?: string;
|
|
6
6
|
name?: string;
|
|
7
|
-
template?:
|
|
7
|
+
template?: StarterTemplateInput;
|
|
8
8
|
}): Promise<{
|
|
9
9
|
root: string;
|
|
10
10
|
name: string;
|
|
11
11
|
files: string[];
|
|
12
|
+
template: StarterTemplate;
|
|
12
13
|
}>;
|
|
@@ -67,7 +67,7 @@ export interface AppToolArguments {
|
|
|
67
67
|
wait?: boolean;
|
|
68
68
|
timeout_seconds?: number;
|
|
69
69
|
kind?: "module" | "command" | "query" | "controller" | "job" | "contract" | "resource" | "feature";
|
|
70
|
-
template?: "minimal" | "command" | "model-command";
|
|
70
|
+
template?: "minimal" | "client" | "command" | "model-command" | "app";
|
|
71
71
|
name?: string;
|
|
72
72
|
module?: string;
|
|
73
73
|
permission?: string;
|
|
@@ -10,6 +10,11 @@ export interface LiteCliArgs {
|
|
|
10
10
|
storage_dir?: string;
|
|
11
11
|
storage_backend?: "fs" | "memory" | "s3";
|
|
12
12
|
s3_prefix?: string;
|
|
13
|
+
/** [start/doctor] expose the inbound S3-compatible endpoint at /storage/v1/s3 */
|
|
14
|
+
s3_endpoint?: boolean;
|
|
15
|
+
s3_endpoint_access_key_id?: string;
|
|
16
|
+
s3_endpoint_region?: string;
|
|
17
|
+
s3_endpoint_buckets?: string;
|
|
13
18
|
engine?: "pglite" | "native";
|
|
14
19
|
host?: string;
|
|
15
20
|
port?: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@supacloud/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.121.6",
|
|
4
4
|
"description": "Project-scoped CLI for SupaCloud users",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -52,26 +52,26 @@
|
|
|
52
52
|
"directory": "packages/cli"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@supacloud/compiler": "^0.62.
|
|
56
|
-
"@supacloud/delivery": "0.
|
|
57
|
-
"@supacloud/db": "0.24.
|
|
55
|
+
"@supacloud/compiler": "^0.62.5",
|
|
56
|
+
"@supacloud/delivery": "0.28.0",
|
|
57
|
+
"@supacloud/db": "0.24.2",
|
|
58
58
|
"typebox": "1.4.3"
|
|
59
59
|
},
|
|
60
60
|
"overrides": {
|
|
61
|
-
"@supacloud/contracts": "0.16.
|
|
62
|
-
"@supacloud/delivery": "0.
|
|
61
|
+
"@supacloud/contracts": "0.16.2",
|
|
62
|
+
"@supacloud/delivery": "0.28.0",
|
|
63
63
|
"@graphql-tools/utils": "^12.0.4",
|
|
64
|
-
"@supacloud/compiler": "^0.62.
|
|
65
|
-
"@supacloud/db": "0.24.
|
|
64
|
+
"@supacloud/compiler": "^0.62.5",
|
|
65
|
+
"@supacloud/db": "0.24.2",
|
|
66
66
|
"deepmerge-ts": "8.0.2",
|
|
67
67
|
"prisma": "6.19.3"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@supabase/supabase-js": "2.118.0",
|
|
71
|
-
"@supacloud/elysia": "0.42.
|
|
71
|
+
"@supacloud/elysia": "0.42.4",
|
|
72
72
|
"@types/bun": "^1.4.4",
|
|
73
73
|
"effect": "4.0.5",
|
|
74
|
-
"elysia": "2.0.0-rc.
|
|
74
|
+
"elysia": "2.0.0-rc.3",
|
|
75
75
|
"typescript": "7.1.0-beta"
|
|
76
76
|
}
|
|
77
77
|
}
|
|
@@ -50,3 +50,6 @@ git diff --check
|
|
|
50
50
|
database and project operations still require the selected project context.
|
|
51
51
|
- Do not weaken compiler governance to make a diagnostic disappear. Fix the
|
|
52
52
|
source or report the required explicit input.
|
|
53
|
+
- `app doctor` keeps the existing checks and adds `layer` on each one: `source`
|
|
54
|
+
(源码), `artifact` (产物), or `runtime` (运行时). A failure names which of those
|
|
55
|
+
the check observed. There is no second catalog of checks.
|