@supacloud/compiler 0.13.0 → 0.14.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
@@ -72,6 +72,41 @@ Consumers of that optional file must install `@graphql-typed-document-node/core`
72
72
  it provides `ResultOf` and `VariablesOf` for operation-level inference. The default
73
73
  fetch client still needs no GraphQL runtime dependency.
74
74
 
75
+ Both outputs use the operation plugin as the single owner of referenced enums
76
+ and input objects. Regenerate both files after upgrading the compiler; do not
77
+ deduplicate declarations by editing generated files. Scalar mappings are applied
78
+ directly to operation/input fields, and types unused by queries are not emitted.
79
+
80
+ Consumer acceptance tests cover both SDK and TypedDocumentNode output:
81
+
82
+ ```gherkin
83
+ Scenario: Shared enum types
84
+ Given multiple queries share an enum in variables and selected fields
85
+ When the compiler generates the client artifacts
86
+ Then each artifact declares the enum once and passes strict TypeScript checks
87
+
88
+ Scenario: Nested input objects
89
+ Given recursive input objects contain enum lists, defaults and custom scalars
90
+ When the compiler generates the client artifacts
91
+ Then input declarations are unique and valid variables retain their types
92
+
93
+ Scenario: Invalid consumer code
94
+ Given generated query contracts
95
+ When a consumer supplies invalid variables or reads an unselected field
96
+ Then TypeScript rejects the consumer code
97
+
98
+ Scenario: Release package acceptance
99
+ Given an installed compiler package
100
+ When its CLI runs the same consumer acceptance suite
101
+ Then both artifact formats pass without editing generated files
102
+ ```
103
+
104
+ Run `bun test src/graphql-package.test.ts` from this package. To test an installed
105
+ tarball or registry release with the same suite, set
106
+ `SUPACLOUD_COMPILER_TEST_CLI` to its absolute `dist/cli.js` path.
107
+ `bun run test:package` checks the built CLI and runs automatically after the build
108
+ in `prepublishOnly`, blocking publication when generated consumer types fail.
109
+
75
110
  ```ts
76
111
  import { createGraphqlClient } from "./generated/graphql";
77
112
  const queries = createGraphqlClient({
@@ -84,12 +119,49 @@ const result = await queries.ReviewList({ first: 20 });
84
119
 
85
120
  Method names and types come from named operations. The generated client is
86
121
  dependency-free and refreshes identity per request; `getSdk(requester)` integrates
87
- an existing transport. It rejects HTTP errors, GraphQL errors and malformed
88
- response envelopes, but does not runtime-decode selected field values.
122
+ an existing transport returning `Promise<unknown>`. It rejects HTTP errors,
123
+ GraphQL errors, malformed response envelopes and invalid selected field values.
124
+ Both clients run generated operation parsers before returning typed data. No
125
+ customer TypeScript-to-TypeBox postprocessor or extra runtime dependency is needed.
126
+ The same module exports `parseReviewListQuery(value: unknown)` and
127
+ `isReviewListQuery(value: unknown)` for other integration boundaries (names follow
128
+ your operations). Validation follows the generated selected JSON shape, including
129
+ aliases, fragments, enums, lists, nullability and optional conditional fields.
130
+ Unmapped scalars remain `unknown`; scalar domain formats and authorization still
131
+ need business validation. Non-JSON scalar mappings such as `Date` fail compilation;
132
+ map the wire value to `string` and convert it after validation instead.
133
+ Generic application adapters can use `GraphqlQueryResults[Name]`,
134
+ `parseGraphqlResult(name, value)` and `isGraphqlResult(name, value)` instead of
135
+ maintaining their own result-type registry. Registry keys are operation names
136
+ such as `"ReviewList"`, without the `Query` type suffix.
89
137
  `graphql.manifest.json` records query locations and the schema hash; context packs
90
138
  include colocated queries. RLS/grants, real database acceptance and query resource
91
139
  limits remain deployment responsibilities. Business writes stay in Commands.
92
140
 
141
+ Use project configuration instead of a custom compile wrapper for shared rules:
142
+
143
+ ```ts
144
+ export default defineSupacloudConfig({
145
+ root: "src",
146
+ graphql: { schema: "graphql/schema.graphql" },
147
+ moduleBoundaries: [{
148
+ sourceTag: "type:feature",
149
+ bannedDependenciesWithTags: ["type:feature"],
150
+ }],
151
+ typeSafety: { scanProductionSource: true, noAnyInGenerated: true },
152
+ allowRouteCommandBindings: false,
153
+ });
154
+ ```
155
+
156
+ `compile`, `check` and `dev` apply these options through the same compiler pipeline.
157
+ `check` also compares generated validators without temporary directories or writes.
158
+ `allowRouteCommandBindings: false` prevents duplicate governance when an application
159
+ executes Commands inside its own service boundary. `disallowControllerDirectDb`
160
+ and `detectOrphanModules` expose the existing optional architecture checks too.
161
+ Keep application-specific governance and business queries in the application.
162
+ See `docs/compiler-consumer-simplification.md` in the repository for the ownership
163
+ checklist and migration boundaries.
164
+
93
165
  ## 安装
94
166
 
95
167
  ```bash