@supacloud/compiler 0.12.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/README.md +82 -1
- package/dist/cli.js +3896 -3317
- package/dist/config.d.ts +4 -1
- package/dist/generate.d.ts +1 -0
- package/dist/graphql-client.d.ts +2 -0
- package/dist/graphql-inputs.d.ts +3 -0
- package/dist/graphql-options.d.ts +7 -0
- package/dist/graphql-schema.d.ts +17 -0
- package/dist/graphql.d.ts +8 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +4043 -3527
- package/dist/inspect.d.ts +1 -0
- package/dist/types.d.ts +28 -0
- package/package.json +9 -3
package/dist/config.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import type { CommandExecutionCapabilities, CompileOptions, ModuleBoundaryPresetName } from "./types";
|
|
1
|
+
import type { CommandExecutionCapabilities, CompileOptions, GraphqlOptions, ModuleBoundaryPresetName } from "./types";
|
|
2
2
|
export interface SupaCloudConfig {
|
|
3
|
+
/** Opt-in outside app init. Schema is configuration-relative; documents are root-relative. */
|
|
4
|
+
graphql?: GraphqlOptions | false;
|
|
3
5
|
root?: string;
|
|
4
6
|
outDir?: string;
|
|
5
7
|
include?: string[];
|
|
@@ -27,6 +29,7 @@ export declare function resolveSupacloudConfig(config?: SupaCloudConfig, cwd?: s
|
|
|
27
29
|
moduleBoundaryPreset: ModuleBoundaryPresetName;
|
|
28
30
|
commandCapabilities?: CommandExecutionCapabilities;
|
|
29
31
|
treeShakeUnusedProviders: boolean;
|
|
32
|
+
graphql?: GraphqlOptions;
|
|
30
33
|
};
|
|
31
34
|
export declare function loadSupacloudConfig(cwd?: string): Promise<SupaCloudConfig>;
|
|
32
35
|
export declare function compileOptionsFromConfig(config: SupaCloudConfig, cwd?: string): CompileOptions;
|
package/dist/generate.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export declare function renderApplication(graph: ApplicationGraph, options: Gene
|
|
|
22
22
|
* Generated code imports only application classes and schemas, with no runtime reflection or container lookup.
|
|
23
23
|
*/
|
|
24
24
|
export declare function generateApplication(graph: ApplicationGraph, options: GenerateOptions): Promise<string[]>;
|
|
25
|
+
export declare function writeFileIfChanged(path: string, content: string, hashes?: Map<string, string>): Promise<boolean>;
|
|
25
26
|
/**
|
|
26
27
|
* Generates typed API client in client.ts from discovered Controllers and Routes.
|
|
27
28
|
* Modeled after Angular HttpClient and typed contract clients.
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/** Appended to the generated SDK; browser consumers need only the platform fetch API. */
|
|
2
|
+
export declare const GRAPHQL_CLIENT_SOURCE = "\nexport interface GraphqlClientOptions {\n /** Project base URL, not the management API URL. HTTPS is required outside loopback. */\n url: string;\n /** Public project key only. Never put a service-role or management key in a browser. */\n publishableKey?: string;\n /** Resolved on every request so session refresh and logout are observed. */\n getAccessToken?: () => string | null | undefined | Promise<string | null | undefined>;\n fetch?: (url: string, init: RequestInit) => Promise<Response>;\n}\n\nexport interface GraphqlRequestOptions {\n signal?: AbortSignal;\n}\n\nexport class GraphqlRequestError extends Error {\n constructor(\n public readonly code: \"http\" | \"graphql\" | \"invalid-response\",\n message: string,\n public readonly status?: number,\n public readonly errors?: readonly unknown[],\n ) {\n super(message);\n this.name = \"GraphqlRequestError\";\n }\n}\n\nexport function createGraphqlClient(options: GraphqlClientOptions) {\n const endpoint = new URL(options.url);\n const loopback = [\"localhost\", \"127.0.0.1\", \"[::1]\"].includes(endpoint.hostname);\n if (endpoint.protocol !== \"https:\" && !(endpoint.protocol === \"http:\" && loopback)) {\n throw new Error(\"GraphQL requires HTTPS outside loopback development.\");\n }\n if (endpoint.username || endpoint.password || endpoint.search || endpoint.hash) {\n throw new Error(\"GraphQL project URLs must not contain credentials, query parameters or fragments.\");\n }\n endpoint.pathname = endpoint.pathname.replace(/\\/$/, \"\") + \"/graphql/v1\";\n const fetcher = options.fetch ?? globalThis.fetch.bind(globalThis);\n return getSdk<GraphqlRequestOptions>(async <R, V>(\n query: string,\n variables?: V,\n request?: GraphqlRequestOptions,\n ): Promise<R> => {\n const headers = new Headers({ \"Content-Type\": \"application/json\", Accept: \"application/json\" });\n if (options.publishableKey) headers.set(\"apikey\", options.publishableKey);\n const token = await options.getAccessToken?.();\n if (token) headers.set(\"Authorization\", \"Bearer \" + token);\n const response = await fetcher(endpoint.toString(), {\n method: \"POST\",\n headers,\n body: JSON.stringify({ query, variables }),\n signal: request?.signal,\n redirect: \"error\",\n });\n if (!response.ok) {\n throw new GraphqlRequestError(\"http\", \"GraphQL HTTP request failed (\" + response.status + \").\", response.status);\n }\n let envelope: unknown;\n try {\n envelope = await response.json();\n } catch {\n throw new GraphqlRequestError(\"invalid-response\", \"GraphQL returned invalid JSON.\", response.status);\n }\n if (!envelope || typeof envelope !== \"object\" || Array.isArray(envelope)) {\n throw new GraphqlRequestError(\"invalid-response\", \"GraphQL returned an invalid envelope.\", response.status);\n }\n if (\"errors\" in envelope) {\n if (!Array.isArray(envelope.errors)) {\n throw new GraphqlRequestError(\"invalid-response\", \"GraphQL returned invalid errors.\", response.status);\n }\n if (envelope.errors.length > 0) {\n throw new GraphqlRequestError(\"graphql\", \"GraphQL query failed.\", response.status, envelope.errors);\n }\n }\n if (!(\"data\" in envelope) || !envelope.data || typeof envelope.data !== \"object\" || Array.isArray(envelope.data)) {\n throw new GraphqlRequestError(\"invalid-response\", \"GraphQL returned no result object.\", response.status);\n }\n // Operation types describe the schema snapshot, not runtime response validation.\n return envelope.data as R;\n });\n}\n";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { GraphqlOptions } from "./types";
|
|
2
|
+
export declare class GraphqlConfigurationError extends Error {
|
|
3
|
+
readonly code = "graphql-config-invalid";
|
|
4
|
+
constructor(detail: string);
|
|
5
|
+
}
|
|
6
|
+
/** Validate before resolving paths so URLs cannot turn into apparently local filenames. */
|
|
7
|
+
export declare function assertGraphqlOptions(value: unknown): asserts value is GraphqlOptions;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface PullGraphqlSchemaOptions {
|
|
2
|
+
/** Explicit project URL. This operation never discovers or changes a deployment. */
|
|
3
|
+
url: string;
|
|
4
|
+
output: string;
|
|
5
|
+
publishableKey?: string;
|
|
6
|
+
accessToken?: string;
|
|
7
|
+
/** Compare the deployed role schema with the snapshot without writing. Useful after migrations. */
|
|
8
|
+
check?: boolean;
|
|
9
|
+
fetch?: (url: string, init: RequestInit) => Promise<Response>;
|
|
10
|
+
}
|
|
11
|
+
/** Explicit authenticated snapshot export, separate from the offline compile/check pipeline. */
|
|
12
|
+
export declare function pullGraphqlSchema(options: PullGraphqlSchemaOptions): Promise<{
|
|
13
|
+
path: string;
|
|
14
|
+
schemaHash: string;
|
|
15
|
+
upToDate: boolean;
|
|
16
|
+
written: boolean;
|
|
17
|
+
}>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CompileOptions, Diagnostic, GraphqlContractSummary } from "./types";
|
|
2
|
+
export interface GraphqlArtifacts {
|
|
3
|
+
diagnostics: Diagnostic[];
|
|
4
|
+
files: Record<string, string>;
|
|
5
|
+
contract?: GraphqlContractSummary;
|
|
6
|
+
}
|
|
7
|
+
/** Offline only: schema authority and role selection belong to the explicit snapshot workflow. */
|
|
8
|
+
export declare function renderGraphql(options: CompileOptions): Promise<GraphqlArtifacts>;
|
package/dist/index.d.ts
CHANGED
|
@@ -23,5 +23,7 @@ export { DEFAULT_SUPACLOUD_CONFIG, compileOptionsFromConfig, defineSupacloudConf
|
|
|
23
23
|
export type { SupaCloudConfig } from "./config";
|
|
24
24
|
export { camelName } from "./util";
|
|
25
25
|
export { ANGULAR_ENTERPRISE_RULES, CLEAN_ARCHITECTURE_RULES, MODULAR_MONOLITH_RULES, MODULE_BOUNDARY_PROFILES, getModuleBoundaryPreset, getModuleBoundaryProfile, resolveModuleBoundaries, } from "./profiles";
|
|
26
|
-
export type { ApplicationGraph, AspectRefNode, CachedModuleEntry, CheckProjectResult, CommandExecutionCapabilities, CommandNode, CompileOptions, CompileResult, CompileStats, ControllerNode, DependencyGraphCache, DependencyGraphIndex, Diagnostic, DiagnosticFix, ModuleBoundaryPresetName, ModuleBoundaryProfile, ModuleBoundaryRule, ModuleNode, JobNode, ProviderKind, ProviderNode, QueryNode, RouteNode, Scope, TokenKind, TypeSafetyOptions, ValidateOptions, WatchEvent, WatchHandle, WatchOptions, FeatureSpecNode, FeatureTransitionNode, } from "./types";
|
|
26
|
+
export type { ApplicationGraph, AspectRefNode, CachedModuleEntry, CheckProjectResult, CommandExecutionCapabilities, CommandNode, CompileOptions, CompileResult, CompileStats, ControllerNode, DependencyGraphCache, DependencyGraphIndex, Diagnostic, DiagnosticFix, ModuleBoundaryPresetName, ModuleBoundaryProfile, ModuleBoundaryRule, ModuleNode, JobNode, ProviderKind, ProviderNode, QueryNode, RouteNode, Scope, TokenKind, TypeSafetyOptions, ValidateOptions, WatchEvent, WatchHandle, WatchOptions, FeatureSpecNode, FeatureTransitionNode, GraphqlOptions, GraphqlContractSummary, } from "./types";
|
|
27
27
|
export { inspectRouteContracts, validateRouteContracts } from "./route-contracts";
|
|
28
|
+
export { pullGraphqlSchema } from "./graphql-schema";
|
|
29
|
+
export type { PullGraphqlSchemaOptions } from "./graphql-schema";
|