@supacloud/compiler 0.55.0 → 0.55.1
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 +21 -5
- package/dist/index.js +21 -5
- package/dist/migration-app-version.d.ts +1 -1
- package/dist/migration-elysia-version.d.ts +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -2123,6 +2123,9 @@ class ModuleGenerator {
|
|
|
2123
2123
|
const idempotency = route.idempotency ?? command?.idempotency ?? featureTransition?.idempotency;
|
|
2124
2124
|
const responseEntries = normalizedResponseEntries(route.responses);
|
|
2125
2125
|
const hasResponseMap = responseEntries.length > 0;
|
|
2126
|
+
const handlerParams = route.handlerParams ?? [];
|
|
2127
|
+
const needsContext = handlerParams.some((parameter) => parameter.kind === "context");
|
|
2128
|
+
const direct = factoryOfScope(controller.scope) === "services" && route.command === undefined && route.effect === undefined && (this.module.aspects?.length ?? 0) === 0 && !handlerParams.some((parameter) => parameter.kind === "cookie") && (route.aspects?.length ?? 0) === 0 && !hasResponseMap && route.parse !== "none" && !needsContext && (route.guards?.length ?? 0) === 0 && (route.canMatch?.length ?? 0) === 0 && (route.canDeactivate?.length ?? 0) === 0 && (route.resolvers === undefined || Object.keys(route.resolvers).length === 0) && (route.paramTransforms === undefined || Object.keys(route.paramTransforms).length === 0) && (route.queryTransforms === undefined || Object.keys(route.queryTransforms).length === 0) && (route.paramDefaults === undefined || Object.keys(route.paramDefaults).length === 0) && (route.queryDefaults === undefined || Object.keys(route.queryDefaults).length === 0);
|
|
2126
2129
|
const fields = [
|
|
2127
2130
|
`method: ${JSON.stringify(route.method)}`,
|
|
2128
2131
|
`path: ${JSON.stringify(route.path)}`,
|
|
@@ -2192,7 +2195,7 @@ class ModuleGenerator {
|
|
|
2192
2195
|
fields.push(`aspects: ${this.renderAspects(route.aspects)}`);
|
|
2193
2196
|
fields.push(`aspectPipeline: ${this.renderAspectPipeline(route.aspects)}`);
|
|
2194
2197
|
}
|
|
2195
|
-
const invokerArgs =
|
|
2198
|
+
const invokerArgs = handlerParams.map((hp) => {
|
|
2196
2199
|
if (hp.kind === "param") {
|
|
2197
2200
|
const accessor = `req.params?.[${JSON.stringify(hp.bindingName ?? hp.name)}]`;
|
|
2198
2201
|
const fallback = hp.default !== undefined ? JSON.stringify(hp.default) : "undefined";
|
|
@@ -2232,7 +2235,17 @@ class ModuleGenerator {
|
|
|
2232
2235
|
return "undefined";
|
|
2233
2236
|
});
|
|
2234
2237
|
const callArgs = invokerArgs.length > 0 ? invokerArgs.join(", ") : "req";
|
|
2235
|
-
fields.push(`invoker:
|
|
2238
|
+
fields.push(`invoker: (ctrl: unknown, req: { params?: Record<string, unknown>; query?: Record<string, unknown>; body?: unknown; headers?: Record<string, unknown>; cookie?: Record<string, unknown>; context?: unknown }) => { ` + `if (!isRecord(ctrl)) throw new TypeError("Route controller is not an object"); ` + `const handler = ctrl[${JSON.stringify(route.handler)}]; ` + `if (!isFunction(handler)) throw new TypeError("Route handler ${route.handler} is not callable"); ` + `return handler.call(ctrl, ${callArgs}); }`);
|
|
2239
|
+
if (direct) {
|
|
2240
|
+
const directArgs = invokerArgs.map((argument) => argument.replaceAll("req.", "context.").replaceAll("req)", "context)"));
|
|
2241
|
+
const directCallArgs = directArgs.length > 0 ? directArgs.join(", ") : "";
|
|
2242
|
+
const directContext = directArgs.length > 0 ? "const context = ctx as { params?: Record<string, unknown>; query?: Record<string, unknown>; body?: unknown; headers?: Record<string, unknown>; cookie?: Record<string, unknown>; context?: unknown }; " : "";
|
|
2243
|
+
fields.push(`directInvoker: (ctrl: unknown, ctx: unknown) => { ` + `if (!isRecord(ctrl)) throw new TypeError("Route controller is not an object"); ` + `const handler = ctrl[${JSON.stringify(route.handler)}]; ` + `if (!isFunction(handler)) throw new TypeError("Route handler ${route.handler} is not callable"); ` + `${directContext}return handler.call(ctrl, ${directCallArgs}); }`);
|
|
2244
|
+
fields.push(`directInvokerFast: (ctrl: Record<string, unknown>, handler: (...args: unknown[]) => unknown, ctx: unknown) => { ` + `${directContext}return handler.call(ctrl, ${directCallArgs}); }`);
|
|
2245
|
+
fields.push('executionMode: "direct"');
|
|
2246
|
+
} else {
|
|
2247
|
+
fields.push('executionMode: "pipeline"');
|
|
2248
|
+
}
|
|
2236
2249
|
if (route.contract !== undefined) {
|
|
2237
2250
|
fields.push(`contract: ${JSON.stringify(route.contract)}`);
|
|
2238
2251
|
}
|
|
@@ -4068,7 +4081,7 @@ var HEADER = "// GENERATED BY @supacloud/compiler — do not edit", INTERFACES =
|
|
|
4068
4081
|
data?: Record<string, unknown>;
|
|
4069
4082
|
aspects?: CompiledAspect[];
|
|
4070
4083
|
aspectPipeline?: CompiledAspectPipeline;
|
|
4071
|
-
invoker
|
|
4084
|
+
invoker: (
|
|
4072
4085
|
controller: unknown,
|
|
4073
4086
|
request: {
|
|
4074
4087
|
params?: Record<string, unknown>;
|
|
@@ -4079,6 +4092,9 @@ var HEADER = "// GENERATED BY @supacloud/compiler — do not edit", INTERFACES =
|
|
|
4079
4092
|
context?: unknown;
|
|
4080
4093
|
},
|
|
4081
4094
|
) => Promise<unknown> | unknown;
|
|
4095
|
+
directInvoker?: (controller: unknown, context: unknown) => Promise<unknown> | unknown;
|
|
4096
|
+
directInvokerFast?: (controller: Record<string, unknown>, handler: (...args: unknown[]) => unknown, context: unknown) => Promise<unknown> | unknown;
|
|
4097
|
+
executionMode?: "direct" | "pipeline";
|
|
4082
4098
|
}
|
|
4083
4099
|
|
|
4084
4100
|
export interface CompiledCommand {
|
|
@@ -25868,10 +25884,10 @@ import { readFileSync as readFileSync4 } from "node:fs";
|
|
|
25868
25884
|
import { resolve as resolve19 } from "node:path";
|
|
25869
25885
|
|
|
25870
25886
|
// src/migration-app-version.ts
|
|
25871
|
-
var MIGRATION_APP_VERSION = "0.36.
|
|
25887
|
+
var MIGRATION_APP_VERSION = "0.36.1";
|
|
25872
25888
|
|
|
25873
25889
|
// src/migration-elysia-version.ts
|
|
25874
|
-
var MIGRATION_ELYSIA_VERSION = "0.38.
|
|
25890
|
+
var MIGRATION_ELYSIA_VERSION = "0.38.2";
|
|
25875
25891
|
|
|
25876
25892
|
// src/migration-policy.ts
|
|
25877
25893
|
var cachedCompilerVersion;
|
package/dist/index.js
CHANGED
|
@@ -2122,6 +2122,9 @@ class ModuleGenerator {
|
|
|
2122
2122
|
const idempotency = route.idempotency ?? command?.idempotency ?? featureTransition?.idempotency;
|
|
2123
2123
|
const responseEntries = normalizedResponseEntries(route.responses);
|
|
2124
2124
|
const hasResponseMap = responseEntries.length > 0;
|
|
2125
|
+
const handlerParams = route.handlerParams ?? [];
|
|
2126
|
+
const needsContext = handlerParams.some((parameter) => parameter.kind === "context");
|
|
2127
|
+
const direct = factoryOfScope(controller.scope) === "services" && route.command === undefined && route.effect === undefined && (this.module.aspects?.length ?? 0) === 0 && !handlerParams.some((parameter) => parameter.kind === "cookie") && (route.aspects?.length ?? 0) === 0 && !hasResponseMap && route.parse !== "none" && !needsContext && (route.guards?.length ?? 0) === 0 && (route.canMatch?.length ?? 0) === 0 && (route.canDeactivate?.length ?? 0) === 0 && (route.resolvers === undefined || Object.keys(route.resolvers).length === 0) && (route.paramTransforms === undefined || Object.keys(route.paramTransforms).length === 0) && (route.queryTransforms === undefined || Object.keys(route.queryTransforms).length === 0) && (route.paramDefaults === undefined || Object.keys(route.paramDefaults).length === 0) && (route.queryDefaults === undefined || Object.keys(route.queryDefaults).length === 0);
|
|
2125
2128
|
const fields = [
|
|
2126
2129
|
`method: ${JSON.stringify(route.method)}`,
|
|
2127
2130
|
`path: ${JSON.stringify(route.path)}`,
|
|
@@ -2191,7 +2194,7 @@ class ModuleGenerator {
|
|
|
2191
2194
|
fields.push(`aspects: ${this.renderAspects(route.aspects)}`);
|
|
2192
2195
|
fields.push(`aspectPipeline: ${this.renderAspectPipeline(route.aspects)}`);
|
|
2193
2196
|
}
|
|
2194
|
-
const invokerArgs =
|
|
2197
|
+
const invokerArgs = handlerParams.map((hp) => {
|
|
2195
2198
|
if (hp.kind === "param") {
|
|
2196
2199
|
const accessor = `req.params?.[${JSON.stringify(hp.bindingName ?? hp.name)}]`;
|
|
2197
2200
|
const fallback = hp.default !== undefined ? JSON.stringify(hp.default) : "undefined";
|
|
@@ -2231,7 +2234,17 @@ class ModuleGenerator {
|
|
|
2231
2234
|
return "undefined";
|
|
2232
2235
|
});
|
|
2233
2236
|
const callArgs = invokerArgs.length > 0 ? invokerArgs.join(", ") : "req";
|
|
2234
|
-
fields.push(`invoker:
|
|
2237
|
+
fields.push(`invoker: (ctrl: unknown, req: { params?: Record<string, unknown>; query?: Record<string, unknown>; body?: unknown; headers?: Record<string, unknown>; cookie?: Record<string, unknown>; context?: unknown }) => { ` + `if (!isRecord(ctrl)) throw new TypeError("Route controller is not an object"); ` + `const handler = ctrl[${JSON.stringify(route.handler)}]; ` + `if (!isFunction(handler)) throw new TypeError("Route handler ${route.handler} is not callable"); ` + `return handler.call(ctrl, ${callArgs}); }`);
|
|
2238
|
+
if (direct) {
|
|
2239
|
+
const directArgs = invokerArgs.map((argument) => argument.replaceAll("req.", "context.").replaceAll("req)", "context)"));
|
|
2240
|
+
const directCallArgs = directArgs.length > 0 ? directArgs.join(", ") : "";
|
|
2241
|
+
const directContext = directArgs.length > 0 ? "const context = ctx as { params?: Record<string, unknown>; query?: Record<string, unknown>; body?: unknown; headers?: Record<string, unknown>; cookie?: Record<string, unknown>; context?: unknown }; " : "";
|
|
2242
|
+
fields.push(`directInvoker: (ctrl: unknown, ctx: unknown) => { ` + `if (!isRecord(ctrl)) throw new TypeError("Route controller is not an object"); ` + `const handler = ctrl[${JSON.stringify(route.handler)}]; ` + `if (!isFunction(handler)) throw new TypeError("Route handler ${route.handler} is not callable"); ` + `${directContext}return handler.call(ctrl, ${directCallArgs}); }`);
|
|
2243
|
+
fields.push(`directInvokerFast: (ctrl: Record<string, unknown>, handler: (...args: unknown[]) => unknown, ctx: unknown) => { ` + `${directContext}return handler.call(ctrl, ${directCallArgs}); }`);
|
|
2244
|
+
fields.push('executionMode: "direct"');
|
|
2245
|
+
} else {
|
|
2246
|
+
fields.push('executionMode: "pipeline"');
|
|
2247
|
+
}
|
|
2235
2248
|
if (route.contract !== undefined) {
|
|
2236
2249
|
fields.push(`contract: ${JSON.stringify(route.contract)}`);
|
|
2237
2250
|
}
|
|
@@ -4067,7 +4080,7 @@ var HEADER = "// GENERATED BY @supacloud/compiler — do not edit", INTERFACES =
|
|
|
4067
4080
|
data?: Record<string, unknown>;
|
|
4068
4081
|
aspects?: CompiledAspect[];
|
|
4069
4082
|
aspectPipeline?: CompiledAspectPipeline;
|
|
4070
|
-
invoker
|
|
4083
|
+
invoker: (
|
|
4071
4084
|
controller: unknown,
|
|
4072
4085
|
request: {
|
|
4073
4086
|
params?: Record<string, unknown>;
|
|
@@ -4078,6 +4091,9 @@ var HEADER = "// GENERATED BY @supacloud/compiler — do not edit", INTERFACES =
|
|
|
4078
4091
|
context?: unknown;
|
|
4079
4092
|
},
|
|
4080
4093
|
) => Promise<unknown> | unknown;
|
|
4094
|
+
directInvoker?: (controller: unknown, context: unknown) => Promise<unknown> | unknown;
|
|
4095
|
+
directInvokerFast?: (controller: Record<string, unknown>, handler: (...args: unknown[]) => unknown, context: unknown) => Promise<unknown> | unknown;
|
|
4096
|
+
executionMode?: "direct" | "pipeline";
|
|
4081
4097
|
}
|
|
4082
4098
|
|
|
4083
4099
|
export interface CompiledCommand {
|
|
@@ -25120,10 +25136,10 @@ import { readFileSync as readFileSync4 } from "node:fs";
|
|
|
25120
25136
|
import { resolve as resolve17 } from "node:path";
|
|
25121
25137
|
|
|
25122
25138
|
// src/migration-app-version.ts
|
|
25123
|
-
var MIGRATION_APP_VERSION = "0.36.
|
|
25139
|
+
var MIGRATION_APP_VERSION = "0.36.1";
|
|
25124
25140
|
|
|
25125
25141
|
// src/migration-elysia-version.ts
|
|
25126
|
-
var MIGRATION_ELYSIA_VERSION = "0.38.
|
|
25142
|
+
var MIGRATION_ELYSIA_VERSION = "0.38.2";
|
|
25127
25143
|
|
|
25128
25144
|
// src/migration-policy.ts
|
|
25129
25145
|
var cachedCompilerVersion;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const MIGRATION_APP_VERSION = "0.36.
|
|
1
|
+
export declare const MIGRATION_APP_VERSION = "0.36.1";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const MIGRATION_ELYSIA_VERSION = "0.38.
|
|
1
|
+
export declare const MIGRATION_ELYSIA_VERSION = "0.38.2";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@supacloud/compiler",
|
|
3
|
-
"version": "0.55.
|
|
3
|
+
"version": "0.55.1",
|
|
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",
|