bazis 0.96.3 → 0.96.4
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/core/http/README.md
CHANGED
|
@@ -52,7 +52,7 @@ Instead there are ASP.NET-style conventions that codegen infers from the signatu
|
|
|
52
52
|
|
|
53
53
|
| Method parameter | Binding |
|
|
54
54
|
|---|---|
|
|
55
|
-
| the name matches
|
|
55
|
+
| the name matches a route parameter: `:name` in the method or `@Controller` template, or a wildcard `*name` (a bare `*` is `rest`) | the route value (converted by the constraint/type) |
|
|
56
56
|
| a DTO class from the application sources | the request body + `@Validator` validation (errors -> 400) |
|
|
57
57
|
| `HttpContext` / `Request` / `ResponseBuilder` | context / raw request / response builder |
|
|
58
58
|
| a primitive (`string`/`number`/`boolean` or inferred from the default) | a query parameter; `?` and a default -> optional |
|
|
@@ -232,7 +232,7 @@ export class CodexAppServerClient implements CodexClient {
|
|
|
232
232
|
if (method === "account/updated") this.modelCache = undefined;
|
|
233
233
|
}, () => { this.clearLogin(); this.modelCache = undefined; });
|
|
234
234
|
const initialized = await client.request("initialize", {
|
|
235
|
-
clientInfo: { name: "bazis", title: "Bazis", version: "0.96.
|
|
235
|
+
clientInfo: { name: "bazis", title: "Bazis", version: "0.96.4" }, capabilities: { experimentalApi: true },
|
|
236
236
|
}, 15_000, signal);
|
|
237
237
|
if (resolve(text(initialized.codexHome, 4096)) !== this.paths.home) throw new CodexError("PROTOCOL_ERROR");
|
|
238
238
|
client.notify("initialized");
|
|
@@ -1009,22 +1009,31 @@ function hasDecorator(node: ts.HasDecorators, name: string): boolean {
|
|
|
1009
1009
|
}
|
|
1010
1010
|
|
|
1011
1011
|
/** Route parameter names from all route decorators of a method (":id(int)" -> "id"). */
|
|
1012
|
+
/**
|
|
1013
|
+
* Route parameter names of an action: the `@Controller` prefix and the method
|
|
1014
|
+
* template, parsed like `Routing/template.ts` (`:name`, `:name(int)`, `*name`,
|
|
1015
|
+
* and a bare `*` named `rest`).
|
|
1016
|
+
*/
|
|
1012
1017
|
function routeParamNames(method: ts.MethodDeclaration): Set<string> {
|
|
1013
1018
|
const names = new Set<string>();
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1019
|
+
const templates: string[] = [];
|
|
1020
|
+
const owner = method.parent;
|
|
1021
|
+
const sources: readonly [readonly ts.Decorator[], (name: string) => boolean][] = [
|
|
1022
|
+
[ts.isClassDeclaration(owner) ? ts.getDecorators(owner) ?? [] : [], (name) => name === "Controller"],
|
|
1023
|
+
[ts.getDecorators(method) ?? [], (name) => ROUTE_DECORATORS.has(name)],
|
|
1024
|
+
];
|
|
1025
|
+
for (const [decorators, accepts] of sources) {
|
|
1026
|
+
for (const decorator of decorators) {
|
|
1027
|
+
const info = decoratorCall(decorator);
|
|
1028
|
+
const firstArg = info?.call?.arguments[0];
|
|
1029
|
+
if (info && accepts(info.name) && firstArg && ts.isStringLiteralLike(firstArg)) templates.push(firstArg.text);
|
|
1022
1030
|
}
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1031
|
+
}
|
|
1032
|
+
for (const template of templates) {
|
|
1033
|
+
for (const segment of template.split("/")) {
|
|
1034
|
+
const param = /^:([A-Za-z_][A-Za-z0-9_]*)/.exec(segment);
|
|
1035
|
+
if (param) names.add(param[1] as string);
|
|
1036
|
+
else if (segment.startsWith("*")) names.add(segment.length > 1 ? segment.slice(1) : "rest");
|
|
1028
1037
|
}
|
|
1029
1038
|
}
|
|
1030
1039
|
return names;
|
package/package.json
CHANGED