@supacloud/compiler 0.55.1 → 0.57.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/DELIVERY.md +26 -0
- package/README.md +22 -14
- package/dist/api-source.d.ts +6 -5
- package/dist/cli.js +3767 -3214
- package/dist/command-boundary.d.ts +9 -0
- package/dist/database-contracts.d.ts +2 -2
- package/dist/delivery-bundle-worker.js +118 -78
- package/dist/delivery-imports.d.ts +1 -1
- package/dist/delivery-render.d.ts +1 -0
- package/dist/di-resolution.d.ts +39 -0
- package/dist/diagnostics.js +62 -22
- package/dist/execution-manifest.d.ts +8 -0
- package/dist/generate.d.ts +3 -2
- package/dist/graphql-runtime.d.ts +1 -1
- package/dist/http-provider-migration.d.ts +3 -3
- package/dist/incremental.d.ts +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3658 -3104
- package/dist/inspect.d.ts +1 -1
- package/dist/migration-app-version.d.ts +1 -1
- package/dist/migration-elysia-version.d.ts +1 -1
- package/dist/migrations.d.ts +2 -2
- package/dist/program.d.ts +7 -19
- package/dist/reactive-analysis.d.ts +2 -2
- package/dist/source-semantics.d.ts +2 -2
- package/dist/sql-safety.d.ts +3 -3
- package/dist/static-di.d.ts +2 -2
- package/dist/traits.d.ts +1 -1
- package/dist/type-safety.d.ts +2 -2
- package/dist/types.d.ts +156 -3
- package/dist/typescript.d.ts +1 -0
- package/package.json +12 -10
package/DELIVERY.md
CHANGED
|
@@ -552,3 +552,29 @@ it cannot bypass platform SQL policy or grant database privileges. Platform
|
|
|
552
552
|
runtime prerequisites are separately managed, not implicitly bundled.
|
|
553
553
|
Building an archive is not evidence of backward compatibility, applied migrations,
|
|
554
554
|
successful activation, application rollback or recovered data.
|
|
555
|
+
|
|
556
|
+
## Compiled execution contract migration
|
|
557
|
+
|
|
558
|
+
Delivery builds now validate `app.manifest.json.executionPlan` against explicit
|
|
559
|
+
`commandCapabilities` before emitting a bundle. Applications with commands must
|
|
560
|
+
declare the capabilities of the adapters actually wired by their host; omitted
|
|
561
|
+
capabilities are unavailable at this boundary. For a named database adapter:
|
|
562
|
+
|
|
563
|
+
```ts
|
|
564
|
+
commandCapabilities: {
|
|
565
|
+
requirePersistentAdapters: true,
|
|
566
|
+
permission: true,
|
|
567
|
+
rpc: {
|
|
568
|
+
orders: { boundary: "database", audit: true, idempotency: true, transaction: true },
|
|
569
|
+
},
|
|
570
|
+
}
|
|
571
|
+
```
|
|
572
|
+
|
|
573
|
+
Declare every RPC branch. External adapters need reconciliation and must not
|
|
574
|
+
claim a database transaction around a remote effect. These declarations are
|
|
575
|
+
checked structurally; deployment still needs runtime adapter verification.
|
|
576
|
+
|
|
577
|
+
Upgrade compiler and Elysia adapter together, regenerate artifacts, and rebuild
|
|
578
|
+
the bundle. HTTP modules require the generated `registerRoutes` callback; old
|
|
579
|
+
route-array fallback has been removed. See the [adapter migration](../elysia/README.md#static-route-registration-migration)
|
|
580
|
+
and [command boundary migration](../app/EXECUTION.md#command-boundary-migration-sc4029).
|
package/README.md
CHANGED
|
@@ -63,7 +63,7 @@ Remote database changes alone do not trigger watch; the next compile checks them
|
|
|
63
63
|
This gate enforces the adopted database-source contract and declared object
|
|
64
64
|
checks, not complete database coverage, ORM usage, runtime authorization, or SQL
|
|
65
65
|
test behavior. Passing it is not deployment acceptance. Keep one existing
|
|
66
|
-
append-only migration ledger, maintain
|
|
66
|
+
append-only migration ledger, maintain ZModel structure and SQL sources
|
|
67
67
|
separately, and explicitly generate/review RPC contracts before compiling.
|
|
68
68
|
See `docs/database-governance.md` and `docs/database-source-contracts.md` for
|
|
69
69
|
the database checks and their limitations.
|
|
@@ -86,19 +86,19 @@ attempts. The default policy requires `requireRouteEffects`,
|
|
|
86
86
|
## Unified Database Contracts
|
|
87
87
|
|
|
88
88
|
Database contracts are protocol-aware: configure only the database sources the
|
|
89
|
-
application uses (`postgrestTypes`, `
|
|
89
|
+
application uses (`postgrestTypes`, `modelSchema`, or `graphql`). The generated
|
|
90
90
|
`database.manifest.json` is a TypeBox-validated, fingerprinted build boundary;
|
|
91
91
|
consumers must reject it when its schema or migration fingerprint is stale.
|
|
92
92
|
|
|
93
93
|
`supacloud-compiler database-contracts database-contracts.json` generates a shared
|
|
94
|
-
type entry point while preserving PostgREST,
|
|
94
|
+
type entry point while preserving PostgREST, ZModel and GraphQL native types:
|
|
95
95
|
|
|
96
96
|
```json
|
|
97
97
|
{
|
|
98
98
|
"rootDir": ".",
|
|
99
99
|
"outDir": "generated",
|
|
100
100
|
"postgrestTypes": "database.types.ts",
|
|
101
|
-
"
|
|
101
|
+
"modelSchema": "zenstack/generated/schema.ts",
|
|
102
102
|
"role": "authenticated",
|
|
103
103
|
"graphql": {
|
|
104
104
|
"schema": "graphql/schema.graphql",
|
|
@@ -111,18 +111,21 @@ type entry point while preserving PostgREST, Drizzle and GraphQL native types:
|
|
|
111
111
|
Configuration paths are relative to the configuration directory; GraphQL document
|
|
112
112
|
patterns are resolved under `rootDir`. Supply the official PostgREST `Database`
|
|
113
113
|
snapshot and a role-scoped `pg_graphql` schema snapshot. The generated barrel
|
|
114
|
-
exports `Database`, `QueryData`,
|
|
115
|
-
Consumers need `@supabase/supabase-js` and their
|
|
114
|
+
exports `Database`, `QueryData`, ZModel schema types and GraphQL contracts.
|
|
115
|
+
Consumers need `@supabase/supabase-js` and their ZenStack dependencies.
|
|
116
116
|
|
|
117
|
-
`--check` detects drift in supplied snapshots, local
|
|
117
|
+
`--check` detects drift in supplied snapshots, local ZModel imports, migration
|
|
118
118
|
content/order and generated artifacts without writing. This is an offline check,
|
|
119
119
|
not proof of live database parity or authorization. Refresh snapshots from the
|
|
120
120
|
intended database and role before running it. Keep runtime decoders at untrusted
|
|
121
121
|
boundaries; protocol result shapes are not interchangeable.
|
|
122
122
|
|
|
123
|
-
|
|
123
|
+
Architecture references: Micronaut for compile-time AOP, NestJS for feature modules,
|
|
124
|
+
and Angular for DI semantics. Compiled DI requires constructor injection and generated scope factories.
|
|
125
|
+
Validation, generation and manifests share a static resolver; see the supported
|
|
126
|
+
[DI profile and migration](../../docs/architecture/static-aop.md#已实施的静态服务端-di-语义).
|
|
124
127
|
Property `inject()` and runtime injection-context APIs fail with `SC2012`.
|
|
125
|
-
Production SQL scanning reports non-`unknown`
|
|
128
|
+
Production SQL scanning reports non-`unknown` Kysely `sql<T>` as `SC6007` and
|
|
126
129
|
dynamic `sql.raw` as `SC6008`. Prefer parameters and explicit result decoders.
|
|
127
130
|
These rules do not replace PostgreSQL constraints, RLS or migration review.
|
|
128
131
|
|
|
@@ -208,7 +211,7 @@ SupaCloud 应用静态编译器:读取 `@supacloud/app` 装饰器元数据的
|
|
|
208
211
|
|
|
209
212
|
## Recommended GraphQL Query Contracts
|
|
210
213
|
|
|
211
|
-
**Database First is the only server-schema model.**
|
|
214
|
+
**Database First is the only server-schema model.** ZModel and SQL declarations
|
|
212
215
|
are migrated to PostgreSQL; `pg_graphql` reflects the actual database, and
|
|
213
216
|
`graphql-schema` exports the intended role's snapshot. Author queries/fragments,
|
|
214
217
|
not GraphQL resolver classes or a separate server SDL. `graphql.schema` accepts
|
|
@@ -562,13 +565,14 @@ IDE 和 AI agent 做状态机漂移检查。
|
|
|
562
565
|
`<outDir>/application.ts`(头注释 `// GENERATED BY @supacloud/compiler — do not edit`):
|
|
563
566
|
|
|
564
567
|
- 文件顶部本地声明 `CompiledRoute` / `CompiledController` / `CompiledModule` 接口,不 import 任何外部包。
|
|
565
|
-
- `createCompiledModules()` 按 imports
|
|
568
|
+
- `createCompiledModules()` 按 imports 与隐式 root 依赖拓扑序返回模块描述:`{ name, createServices, createRequestScope?, createJobScope?, controllers, commands }`。平台依赖统一由 `createApplication({ deps })` 传入生成工厂。
|
|
566
569
|
- `makeEnvironmentProviders`、`provideToken`、`provideAppInitializer`、`provideEnvironmentInitializer`、`provideRouter` 和 `provideHttpClient` 的可静态展开部分会在 AST 分析阶段展开为普通 provider;不支持静态安全展开的动态参数会产生诊断,不会被静默丢弃。
|
|
567
|
-
- 每个模块一个 `create<Name>Services(deps, imported)`:实例化 application 级 provider;dep 解析顺序为本模块
|
|
568
|
-
- 含 request 级 provider/controller 的模块额外生成 `create<Name>RequestScope(services, ctx)`:依赖 `REQUEST_CONTEXT`(或 token name `supacloud.request-context`)的参数传 `ctx
|
|
570
|
+
- 每个模块一个 `create<Name>Services(deps, imported)`:实例化 application 级 provider;dep 解析顺序为本模块 > imports 公开导出/重导出的原始 provider > root 默认 provider > 平台自有属性。歧义与非法生命周期在编译时拒绝。
|
|
571
|
+
- 含 request 级 provider/controller 的模块额外生成 `create<Name>RequestScope(services, ctx)`:依赖 `REQUEST_CONTEXT`(或 token name `supacloud.request-context`)的参数传 `ctx`,其余根据静态计划从本 scope、`services`、`imported` 或私有保留的平台绑定读取;job 级同理生成 `create<Name>JobScope`。
|
|
569
572
|
- 含 request/job 级 provider 或 controller 的模块同时生成异步静态 `create<Name>RequestScope` / `create<Name>JobScope` 与 `destroy<Name>RequestScope(scope)` / `destroy<Name>JobScope(scope)`;factory 在构造中途失败时按编译期确定的逆创建顺序回滚已知 `onDestroy` 方法,不会运行时扫描或解析 Token。
|
|
570
573
|
- `@Host()` 在 EnvironmentInjector 作用域中保留元数据但不改变解析,因为 SupaCloud 没有 Angular 元素注入器树;`@Self()` / `@SkipSelf()` 由静态 factory 按当前 scope 与模块可见性执行。
|
|
571
574
|
- AOP 只支持静态边界:`ModuleOptions.aspects`、`RouteOptions.aspects`、`CommandOptions.aspects` 和 `JobOptions.aspects` 必须是显式数组字面量,元素必须是可解析的函数标识符。生成器会直接 import aspect 并生成固定顺序的 onion chain,不使用 Proxy、Reflect 扫描、动态 pointcut 或运行时注册。
|
|
575
|
+
- typed aspect 可使用真实 `@supacloud/app`、`/core`、`/execution` 的 `defineOperationAspect` 初始化 `const` 命名变量;`kind`、`name` 必须为静态字面量且与绑定操作一致,契约不接受 spread。输入/结果校验器与 capability 选择器提供类型缩窄。生成的 Command 管线要求成功返回来自一次 next,拒绝结果替换及吞掉下游失败,并递归冻结普通数据结果。详见 [静态 AOP 约束](../../docs/architecture/static-aop.md)。
|
|
572
576
|
- 执行顺序为 `commandGovernance -> module -> route -> command -> handler`,授权拒绝不会运行业务切面;Job 使用 `module -> job -> executor -> run/execute`,并在 finally 中销毁 job scope。
|
|
573
577
|
- services 对象的 key 为 token 名的 camelCase:`CaseService → caseService`、`CASE_REPOSITORY → caseRepository`、`LOGGER → logger`。
|
|
574
578
|
- controller 描述静态给出:`{ path, serviceKey, scope, routes: [{ method, path, handler, body?, params?, query?, headers?, cookie?, response?, responses? }] }`,schema 直接引用 import 进来的对象。
|
|
@@ -739,7 +743,11 @@ export default defineSupacloudConfig({
|
|
|
739
743
|
supacloud-compiler check --root ./app --out ./app/generated --strict
|
|
740
744
|
```
|
|
741
745
|
|
|
742
|
-
|
|
746
|
+
程序化调用需 `await scanGeneratedArtifacts()` 和 `await scanProductionSource()` 获取结构化诊断。
|
|
747
|
+
|
|
748
|
+
编译工具链固定为官方 TypeScript `7.1.0-beta`,内部使用 `typescript/async`,可直接运行于 Bun 1.4.4。源码解析、类型查询和迁移不再依赖 TypeScript 6 或 Node 同步 API。Svelte 的 `svelte-check` 是唯一例外:暂留 TS 6,并通过 `@typescript/native` 使用同一 TS 7.1 beta。
|
|
749
|
+
|
|
750
|
+
`IncrementalProgramSession.update()`、`getDiagnostics()`、`emit()`、`reset()` 现在返回 Promise。会话支持 `await using`,更新后不要继续使用上一快照的 checker/type/symbol;自主管理缓存的调用方需 `await session.reset()` 释放原生进程。`IncrementalCompiler.reset()` 同样需要等待,watch 关闭会自动清理。内置源码迁移返回 Promise,自定义迁移仍可同步返回结果。
|
|
743
751
|
|
|
744
752
|
## 开发模式
|
|
745
753
|
|
package/dist/api-source.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import * as ts from "@typescript
|
|
1
|
+
import * as ts from "@supacloud/db/typescript";
|
|
2
2
|
export interface ApiOrigin {
|
|
3
3
|
module: string;
|
|
4
4
|
name: string;
|
|
5
5
|
}
|
|
6
6
|
/** Bind one source for lexical identity only. Never load dependencies or execute application code. */
|
|
7
|
-
export declare function bindApiSource(source: ts.SourceFile): {
|
|
7
|
+
export declare function bindApiSource(source: ts.SourceFile): Promise<{
|
|
8
8
|
source: ts.SourceFile;
|
|
9
|
-
checker: ts.
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
checker: ts.Checker;
|
|
10
|
+
[Symbol.asyncDispose]: () => Promise<void>;
|
|
11
|
+
}>;
|
|
12
|
+
export declare function apiOrigin(expression: ts.Expression, checker: ts.TypeChecker, seen?: Set<ts.Node>): Promise<ApiOrigin | undefined>;
|