@supacloud/compiler 0.34.0 → 0.35.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/cli.js +10 -7
- package/dist/index.js +10 -7
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -2509,7 +2509,7 @@ function renderClient(graph, options) {
|
|
|
2509
2509
|
" readonly path: string;",
|
|
2510
2510
|
" readonly status: number;",
|
|
2511
2511
|
" readonly requestId: string | undefined;",
|
|
2512
|
-
" /**
|
|
2512
|
+
" /** HTTP response for inspection; successful response bodies may already be consumed. */",
|
|
2513
2513
|
" readonly response: Response | undefined;",
|
|
2514
2514
|
" constructor(message: string, details: ApiClientErrorDetails) {",
|
|
2515
2515
|
" super(message);",
|
|
@@ -2856,25 +2856,27 @@ function renderClient(graph, options) {
|
|
|
2856
2856
|
" const declaredSchema = responseSchemas ? selectResponseSchema(response.status, responseSchemas) : undefined;",
|
|
2857
2857
|
" const failure = (code: ApiClientErrorCode, message: string) => new ApiClientError(message, {",
|
|
2858
2858
|
' code, method, path, status: response.status, requestId: response.headers.get("x-request-id"),',
|
|
2859
|
-
|
|
2859
|
+
" response,",
|
|
2860
2860
|
" });",
|
|
2861
2861
|
" if (!response.ok && declaredSchema === undefined) {",
|
|
2862
2862
|
' throw failure("API_HTTP_ERROR", `API request failed: ${method} ${path} -> ${response.status}`);',
|
|
2863
2863
|
" }",
|
|
2864
|
+
" // Preserve the original HTTP error response if a declared error body fails validation.",
|
|
2865
|
+
" const bodyResponse = response.ok ? response : response.clone();",
|
|
2864
2866
|
' const contentType = response.headers?.get("content-type") ?? "";',
|
|
2865
2867
|
" let value: unknown;",
|
|
2866
2868
|
" if ([204, 205, 304].includes(response.status)) {",
|
|
2867
2869
|
" value = undefined;",
|
|
2868
2870
|
' } else if (contentType.includes("application/json") || contentType.includes("+json")) {',
|
|
2869
|
-
" const responseText = await
|
|
2871
|
+
" const responseText = await bodyResponse.text();",
|
|
2870
2872
|
" try { value = JSON.parse(responseText); }",
|
|
2871
2873
|
' catch { throw failure("API_RESPONSE_INVALID", "Response is not valid JSON"); }',
|
|
2872
2874
|
' } else if (responseKind === "binary" || contentType.includes("application/octet-stream")) {',
|
|
2873
|
-
" value = await
|
|
2875
|
+
" value = await bodyResponse.arrayBuffer();",
|
|
2874
2876
|
' } else if (responseKind === "stream") {',
|
|
2875
|
-
" value =
|
|
2877
|
+
" value = bodyResponse.body;",
|
|
2876
2878
|
" } else {",
|
|
2877
|
-
" value = await
|
|
2879
|
+
" value = await bodyResponse.text();",
|
|
2878
2880
|
" }",
|
|
2879
2881
|
" if (!responseSchemas) return decode ? decode(value) : value;",
|
|
2880
2882
|
" if (declaredSchema === undefined) {",
|
|
@@ -2901,9 +2903,10 @@ function renderClient(graph, options) {
|
|
|
2901
2903
|
" ): ClientRequestOptions {",
|
|
2902
2904
|
" const headers = { ...(options.headers as Record<string, string> | undefined) };",
|
|
2903
2905
|
" if (execution?.idempotencyKey !== undefined) {",
|
|
2904
|
-
|
|
2906
|
+
' if (typeof execution.idempotencyKey !== "string" || !/^[A-Za-z0-9._:-]{1,512}$/.test(execution.idempotencyKey)) {',
|
|
2905
2907
|
' throw new TypeError("idempotencyKey must contain only safe header characters and be at most 512 characters");',
|
|
2906
2908
|
" }",
|
|
2909
|
+
' for (const key of Object.keys(headers)) if (key.toLowerCase() === "idempotency-key") delete headers[key];',
|
|
2907
2910
|
' headers["idempotency-key"] = execution.idempotencyKey;',
|
|
2908
2911
|
" }",
|
|
2909
2912
|
' if (idempotency === "required" && !hasHeader(headers, "idempotency-key")) {',
|
package/dist/index.js
CHANGED
|
@@ -2508,7 +2508,7 @@ function renderClient(graph, options) {
|
|
|
2508
2508
|
" readonly path: string;",
|
|
2509
2509
|
" readonly status: number;",
|
|
2510
2510
|
" readonly requestId: string | undefined;",
|
|
2511
|
-
" /**
|
|
2511
|
+
" /** HTTP response for inspection; successful response bodies may already be consumed. */",
|
|
2512
2512
|
" readonly response: Response | undefined;",
|
|
2513
2513
|
" constructor(message: string, details: ApiClientErrorDetails) {",
|
|
2514
2514
|
" super(message);",
|
|
@@ -2855,25 +2855,27 @@ function renderClient(graph, options) {
|
|
|
2855
2855
|
" const declaredSchema = responseSchemas ? selectResponseSchema(response.status, responseSchemas) : undefined;",
|
|
2856
2856
|
" const failure = (code: ApiClientErrorCode, message: string) => new ApiClientError(message, {",
|
|
2857
2857
|
' code, method, path, status: response.status, requestId: response.headers.get("x-request-id"),',
|
|
2858
|
-
|
|
2858
|
+
" response,",
|
|
2859
2859
|
" });",
|
|
2860
2860
|
" if (!response.ok && declaredSchema === undefined) {",
|
|
2861
2861
|
' throw failure("API_HTTP_ERROR", `API request failed: ${method} ${path} -> ${response.status}`);',
|
|
2862
2862
|
" }",
|
|
2863
|
+
" // Preserve the original HTTP error response if a declared error body fails validation.",
|
|
2864
|
+
" const bodyResponse = response.ok ? response : response.clone();",
|
|
2863
2865
|
' const contentType = response.headers?.get("content-type") ?? "";',
|
|
2864
2866
|
" let value: unknown;",
|
|
2865
2867
|
" if ([204, 205, 304].includes(response.status)) {",
|
|
2866
2868
|
" value = undefined;",
|
|
2867
2869
|
' } else if (contentType.includes("application/json") || contentType.includes("+json")) {',
|
|
2868
|
-
" const responseText = await
|
|
2870
|
+
" const responseText = await bodyResponse.text();",
|
|
2869
2871
|
" try { value = JSON.parse(responseText); }",
|
|
2870
2872
|
' catch { throw failure("API_RESPONSE_INVALID", "Response is not valid JSON"); }',
|
|
2871
2873
|
' } else if (responseKind === "binary" || contentType.includes("application/octet-stream")) {',
|
|
2872
|
-
" value = await
|
|
2874
|
+
" value = await bodyResponse.arrayBuffer();",
|
|
2873
2875
|
' } else if (responseKind === "stream") {',
|
|
2874
|
-
" value =
|
|
2876
|
+
" value = bodyResponse.body;",
|
|
2875
2877
|
" } else {",
|
|
2876
|
-
" value = await
|
|
2878
|
+
" value = await bodyResponse.text();",
|
|
2877
2879
|
" }",
|
|
2878
2880
|
" if (!responseSchemas) return decode ? decode(value) : value;",
|
|
2879
2881
|
" if (declaredSchema === undefined) {",
|
|
@@ -2900,9 +2902,10 @@ function renderClient(graph, options) {
|
|
|
2900
2902
|
" ): ClientRequestOptions {",
|
|
2901
2903
|
" const headers = { ...(options.headers as Record<string, string> | undefined) };",
|
|
2902
2904
|
" if (execution?.idempotencyKey !== undefined) {",
|
|
2903
|
-
|
|
2905
|
+
' if (typeof execution.idempotencyKey !== "string" || !/^[A-Za-z0-9._:-]{1,512}$/.test(execution.idempotencyKey)) {',
|
|
2904
2906
|
' throw new TypeError("idempotencyKey must contain only safe header characters and be at most 512 characters");',
|
|
2905
2907
|
" }",
|
|
2908
|
+
' for (const key of Object.keys(headers)) if (key.toLowerCase() === "idempotency-key") delete headers[key];',
|
|
2906
2909
|
' headers["idempotency-key"] = execution.idempotencyKey;',
|
|
2907
2910
|
" }",
|
|
2908
2911
|
' if (idempotency === "required" && !hasHeader(headers, "idempotency-key")) {',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@supacloud/compiler",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.35.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",
|