@supacloud/compiler 0.11.0 → 0.13.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/dist/inspect.d.ts CHANGED
@@ -1,14 +1,27 @@
1
1
  import type { ApplicationGraph, Diagnostic, ModuleNode } from "./types";
2
+ import { inspectRouteContracts } from "./route-contracts";
3
+ export interface ExecutionPlan {
4
+ module: string;
5
+ kind: "route" | "command" | "job";
6
+ name: string;
7
+ command?: string;
8
+ /** Standard governance contract. Audit success follows the handler; custom executors may short-circuit. */
9
+ stages: string[];
10
+ }
2
11
  export interface ContextPack {
3
12
  version: 1;
4
13
  subject: string;
5
14
  modules: ModuleNode[];
6
15
  files: string[];
7
16
  externalTokens: string[];
17
+ executionPlans: ExecutionPlan[];
18
+ routeContracts: ReturnType<typeof inspectRouteContracts>;
19
+ diagnostics: Diagnostic[];
8
20
  relatedModules: {
9
21
  importedBy: string[];
10
22
  imports: string[];
11
23
  };
24
+ graphql?: ApplicationGraph["graphql"];
12
25
  }
13
26
  export interface DoctorResult {
14
27
  checks: Array<{
@@ -26,6 +39,8 @@ export declare function explainGraph(graph: ApplicationGraph, subject: string):
26
39
  * editing one feature: the subject module, its imports, and its dependents.
27
40
  */
28
41
  export declare function createContextPack(graph: ApplicationGraph, subject: string): ContextPack;
42
+ /** Static plan, not runtime discovery; custom executors remain explicit boundaries. */
43
+ export declare function createExecutionPlans(graph: ApplicationGraph): ExecutionPlan[];
29
44
  export declare function doctorProject(rootDir: string, outDir: string, graph: ApplicationGraph, upToDate: boolean, diagnostics?: Diagnostic[]): DoctorResult;
30
45
  /**
31
46
  * Exports the application module architecture as a Mermaid graph diagram.
@@ -8,5 +8,13 @@ export declare function inspectRouteContracts(graph: ApplicationGraph): {
8
8
  path: string;
9
9
  file: string;
10
10
  missing: ("query" | "body" | "params" | "response")[];
11
+ validation: {
12
+ body: string;
13
+ response: string;
14
+ schemas: Partial<Record<"query" | "body" | "params" | "response", "opaque" | "declared">>;
15
+ evidence: string | null;
16
+ verified: false;
17
+ obligations: string[];
18
+ };
11
19
  }[];
12
20
  export declare function validateRouteContracts(graph: ApplicationGraph): Diagnostic[];
package/dist/types.d.ts CHANGED
@@ -21,6 +21,8 @@ export interface FunctionalInjectNode {
21
21
  host?: boolean;
22
22
  }
23
23
  export interface AspectRefNode {
24
+ /** Exact project-local source path for context packs. */
25
+ file?: string;
24
26
  /** Exported symbol name used in the generated static import. */
25
27
  name: string;
26
28
  /** Source expression retained for diagnostics and manifest inspection. */
@@ -50,6 +52,14 @@ export interface Diagnostic {
50
52
  * than raw text offsets so fixes remain valid after unrelated edits.
51
53
  */
52
54
  export type DiagnosticFix = {
55
+ type: "set_command_mode";
56
+ targetFile: string;
57
+ command: string;
58
+ property: "transaction" | "idempotency";
59
+ expectedExpression: string;
60
+ /** Must be selected by the caller; never infer weaker governance. */
61
+ value?: "required" | "none";
62
+ } | {
53
63
  type: "add_module_import";
54
64
  targetFile: string;
55
65
  module: string;
@@ -136,6 +146,13 @@ export interface HandlerParamNode {
136
146
  default?: unknown;
137
147
  }
138
148
  export interface RouteNode {
149
+ contract?: {
150
+ body?: "framework" | "domain";
151
+ response?: "framework" | "native-json" | "binary" | "stream";
152
+ evidence?: string;
153
+ };
154
+ schemaKinds?: Partial<Record<"body" | "params" | "query" | "response", "opaque" | "declared">>;
155
+ nativeResponse?: boolean;
139
156
  method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS";
140
157
  path: string;
141
158
  handler: string;
@@ -206,6 +223,7 @@ export interface ControllerNode {
206
223
  schemaImports?: Record<string, string>;
207
224
  }
208
225
  export interface CommandNode {
226
+ rpc?: string;
209
227
  className: string;
210
228
  name: string;
211
229
  permission?: string;
@@ -269,6 +287,8 @@ export interface ModuleNode {
269
287
  featureSpec?: FeatureSpecNode;
270
288
  }
271
289
  export interface ApplicationGraph {
290
+ /** Offline query inventory for AI context. Kept in graphql.manifest.json, not app.manifest.json. */
291
+ graphql?: GraphqlContractSummary;
272
292
  modules: ModuleNode[];
273
293
  /** Depended token names provided by platform injection rather than any module. */
274
294
  externalTokens: string[];
@@ -290,6 +310,8 @@ export interface ApplicationGraph {
290
310
  };
291
311
  }
292
312
  export interface CompileOptions {
313
+ /** Opt-in, offline GraphQL query contracts backed by a role-scoped schema snapshot. */
314
+ graphql?: GraphqlOptions;
293
315
  /** Require schemas for bound route inputs and responses. Does not prove runtime validation. */
294
316
  requireRouteContracts?: boolean;
295
317
  /** Project root directory (containing tsconfig). */
@@ -312,7 +334,7 @@ export interface CompileOptions {
312
334
  disallowControllerDirectDb?: boolean;
313
335
  /** Detect modules declared in the project that are unreachable from any root module. */
314
336
  detectOrphanModules?: boolean;
315
- /** Write generated artifacts even when error-level diagnostics exist (default: true). */
337
+ /** Explicit unsafe opt-in to emit artifacts with errors (default: false). */
316
338
  writeOnError?: boolean;
317
339
  /** Generate typed API client in client.ts (default: false). */
318
340
  generateClient?: boolean;
@@ -330,6 +352,30 @@ export interface CompileOptions {
330
352
  /** Type-safety gates for generated artifacts and production source. */
331
353
  typeSafety?: TypeSafetyOptions;
332
354
  }
355
+ export interface GraphqlOptions {
356
+ /** Additionally emit standard TypedDocumentNode artifacts for GraphQL ecosystem clients. */
357
+ typedDocuments?: boolean;
358
+ /** Exported role-scoped database snapshot (.graphql/.gql/.json), never authored SDL or executable code.
359
+ * Relative to rootDir for the programmatic API. Offline compilation does not attest its origin. */
360
+ schema: string;
361
+ /** Query/fragment globs relative to rootDir. Defaults to all .graphql and .gql files. */
362
+ documents?: string[];
363
+ /** Explicit wire types for custom scalars. Unmapped scalars remain unknown. */
364
+ scalars?: Record<string, string | {
365
+ input: string;
366
+ output: string;
367
+ }>;
368
+ }
369
+ export interface GraphqlContractSummary {
370
+ schema: string;
371
+ schemaHash?: string;
372
+ documents: string[];
373
+ operations: Array<{
374
+ name: string;
375
+ file: string;
376
+ line: number;
377
+ }>;
378
+ }
333
379
  export interface TypeSafetyOptions {
334
380
  /** Reject the `any` keyword in generated TypeScript artifacts. */
335
381
  noAnyInGenerated?: boolean;
@@ -368,6 +414,12 @@ export interface ValidateOptions {
368
414
  }
369
415
  /** Runtime capabilities declared by the Command executor. */
370
416
  export interface CommandExecutionCapabilities {
417
+ /** Explicit named adapters; declarations must also be tested against the database. */
418
+ rpc?: Record<string, {
419
+ audit?: boolean;
420
+ idempotency?: boolean;
421
+ transaction?: boolean;
422
+ }>;
371
423
  /** Whether runtime permission checks are supported. */
372
424
  permission?: boolean;
373
425
  /** Whether runtime audit persistence is supported. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supacloud/compiler",
3
- "version": "0.11.0",
3
+ "version": "0.13.0",
4
4
  "description": "Static compiler for @supacloud/app metadata: builds the application graph from AST, validates it, and generates reflection-free factory code",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -22,7 +22,7 @@
22
22
  ],
23
23
  "scripts": {
24
24
  "build": "bun run clean && bun run build:js && bun run build:types",
25
- "build:js": "bun build src/index.ts src/cli.ts --outdir dist --target node --external @typescript/typescript6",
25
+ "build:js": "bun build src/index.ts src/cli.ts --outdir dist --target node --external @typescript/typescript6 --external graphql --external '@graphql-codegen/*'",
26
26
  "build:types": "tsc -p tsconfig.json --emitDeclarationOnly",
27
27
  "clean": "rm -rf dist",
28
28
  "prepublishOnly": "bun run build",
@@ -45,7 +45,13 @@
45
45
  "directory": "packages/compiler"
46
46
  },
47
47
  "dependencies": {
48
- "@typescript/typescript6": "^6.0.2"
48
+ "@graphql-codegen/core": "^6.2.0",
49
+ "@graphql-codegen/typed-document-node": "^7.1.0",
50
+ "@graphql-codegen/typescript": "^6.1.0",
51
+ "@graphql-codegen/typescript-operations": "^6.1.6",
52
+ "@graphql-typed-document-node/core": "^3.2.0",
53
+ "@typescript/typescript6": "^6.0.2",
54
+ "graphql": "^16"
49
55
  },
50
56
  "devDependencies": {
51
57
  "@types/bun": "^1.4.0",