@supacloud/compiler 0.21.1 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,5 +1,43 @@
1
1
  # @supacloud/compiler
2
2
 
3
+ ## Unified Database Contracts
4
+
5
+ `supacloud-compiler database-contracts database-contracts.json` generates a shared
6
+ type entry point while preserving PostgREST, Drizzle and GraphQL native types:
7
+
8
+ ```json
9
+ {
10
+ "rootDir": ".",
11
+ "outDir": "generated",
12
+ "postgrestTypes": "database.types.ts",
13
+ "drizzleSchema": "db/schema.ts",
14
+ "role": "authenticated",
15
+ "graphql": {
16
+ "schema": "graphql/schema.graphql",
17
+ "documents": ["src/**/*.graphql"]
18
+ },
19
+ "migrations": ["migrations/001.sql"]
20
+ }
21
+ ```
22
+
23
+ Configuration paths are relative to the configuration directory; GraphQL document
24
+ patterns are resolved under `rootDir`. Supply the official PostgREST `Database`
25
+ snapshot and a role-scoped `pg_graphql` schema snapshot. The generated barrel
26
+ exports `Database`, `QueryData`, Drizzle schema types and GraphQL contracts.
27
+ Consumers need `@supabase/supabase-js` and their Drizzle dependencies.
28
+
29
+ `--check` detects drift in supplied snapshots, local Drizzle imports, migration
30
+ content/order and generated artifacts without writing. This is an offline check,
31
+ not proof of live database parity or authorization. Refresh snapshots from the
32
+ intended database and role before running it. Keep runtime decoders at untrusted
33
+ boundaries; protocol result shapes are not interchangeable.
34
+
35
+ Compiled DI requires constructor injection and generated scope factories.
36
+ Property `inject()` and runtime injection-context APIs fail with `SC2012`.
37
+ Production SQL scanning reports non-`unknown` Drizzle `sql<T>` as `SC6007` and
38
+ dynamic `sql.raw` as `SC6008`. Prefer parameters and explicit result decoders.
39
+ These rules do not replace PostgreSQL constraints, RLS or migration review.
40
+
3
41
  ## Local Delivery
4
42
 
5
43
  `supacloud-compiler plan --json` previews workload targets, dependency closures,
@@ -407,7 +445,7 @@ IDE 和 AI agent 做状态机漂移检查。
407
445
  - 含 request/job 级 provider 或 controller 的模块同时生成异步静态 `create<Name>RequestScope` / `create<Name>JobScope` 与 `destroy<Name>RequestScope(scope)` / `destroy<Name>JobScope(scope)`;factory 在构造中途失败时按编译期确定的逆创建顺序回滚已知 `onDestroy` 方法,不会运行时扫描或解析 Token。
408
446
  - `@Host()` 在 EnvironmentInjector 作用域中保留元数据但不改变解析,因为 SupaCloud 没有 Angular 元素注入器树;`@Self()` / `@SkipSelf()` 由静态 factory 按当前 scope 与模块可见性执行。
409
447
  - AOP 只支持静态边界:`ModuleOptions.aspects`、`RouteOptions.aspects`、`CommandOptions.aspects` 和 `JobOptions.aspects` 必须是显式数组字面量,元素必须是可解析的函数标识符。生成器会直接 import aspect 并生成固定顺序的 onion chain,不使用 Proxy、Reflect 扫描、动态 pointcut 或运行时注册。
410
- - 执行顺序为 `module -> route -> command -> commandGovernance -> handler`;Job 使用 `module -> job -> executor -> run/execute`,并在 finally 中销毁 job scope。
448
+ - 执行顺序为 `commandGovernance -> module -> route -> command -> handler`,授权拒绝不会运行业务切面;Job 使用 `module -> job -> executor -> run/execute`,并在 finally 中销毁 job scope。
411
449
  - services 对象的 key 为 token 名的 camelCase:`CaseService → caseService`、`CASE_REPOSITORY → caseRepository`、`LOGGER → logger`。
412
450
  - controller 描述静态给出:`{ path, serviceKey, scope, routes: [{ method, path, handler, body?, params?, query?, headers?, cookie?, response?, responses? }] }`,schema 直接引用 import 进来的对象。
413
451
  - `client.ts` 在启用 `generateClient` 时生成:包含 `API_ROUTES`、`API_SCHEMAS`、类型化请求选项和显式响应 decoder 入口。