@webtypen/webframez-core 0.3.69 → 0.3.71

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 CHANGED
@@ -370,6 +370,11 @@ Example: `GET /api/backoffice/current-user`.
370
370
 
371
371
  The scope middleware runs before the function. Its return value is passed to the function as `apiRequest.context`. Calling `abort(message, status)` stops execution and returns an error response with that status.
372
372
 
373
+ For HTTP middleware that must also run on automatic `OPTIONS` responses, set
374
+ `routeMiddleware = ["cors"]` on the scope. These names refer to middleware in the
375
+ application kernel. They run before the route handler; scope `middleware()` still
376
+ runs for function calls and provides their authorization/context (including MCP).
377
+
373
378
  ### Group ApiScopes
374
379
 
375
380
  Use `ApiScopesGroup` to share middleware across multiple scopes:
@@ -570,6 +575,25 @@ builder.registerType({
570
575
  });
571
576
  ```
572
577
 
578
+ Forms may group their complete layout in tabs. Tab fields still address the same
579
+ root data object; tabs only change presentation. `appearance: "plain"` avoids an
580
+ additional card around a full-form tab layout.
581
+
582
+ ```ts
583
+ forms: {
584
+ main: {
585
+ fields: [{
586
+ type: "tabs",
587
+ appearance: "plain",
588
+ tabs: [
589
+ { key: "general", title: "General", icon: "settings", fields: [{ field: "email" }] },
590
+ { key: "defaults", title: "Defaults", icon: "database", fields: [{ field: "default_values" }] }
591
+ ]
592
+ }]
593
+ }
594
+ }
595
+ ```
596
+
573
597
  `option` fields can use static `options: [{ value, label }]` or a client-side
574
598
  `optionsMapping`. The mapping can be a single object or an array of objects with
575
599
  `{ from: string; value: string; label: string; valuePrefix?: string; labelPrefix?: string }`. Multiple
@@ -5,6 +5,8 @@ export declare class ApiScope {
5
5
  key: string;
6
6
  apiBasePath: string | null;
7
7
  mcpEndpoint: string | null;
8
+ /** Kernel middleware for HTTP routes, including automatic OPTIONS responses. */
9
+ routeMiddleware: string[];
8
10
  functions: Array<ApiFunctionClass> | (() => Array<ApiFunctionClass>);
9
11
  middleware(_req: Request, _res: Response, _abort: ApiScopeMiddlewareAbort): Promise<{
10
12
  [key: string]: any;
@@ -15,6 +15,8 @@ class ApiScope {
15
15
  this.key = "unique_scope_key";
16
16
  this.apiBasePath = "/api";
17
17
  this.mcpEndpoint = null;
18
+ /** Kernel middleware for HTTP routes, including automatic OPTIONS responses. */
19
+ this.routeMiddleware = [];
18
20
  this.functions = [];
19
21
  }
20
22
  middleware(_req, _res, _abort) {
@@ -71,10 +71,10 @@ class ApiScopeRegistryFacade {
71
71
  const handler = (req, res) => __awaiter(this, void 0, void 0, function* () {
72
72
  return yield this.handleHttpFunction(registration, FunctionClass, req, res);
73
73
  });
74
- this.registerRouteMethod(func.requestMethod, path, handler);
74
+ this.registerRouteMethod(func.requestMethod, path, handler, scope.routeMiddleware);
75
75
  }
76
76
  }
77
- registerRouteMethod(method, path, handler) {
77
+ registerRouteMethod(method, path, handler, middleware) {
78
78
  if (!method) {
79
79
  return;
80
80
  }
@@ -83,7 +83,7 @@ class ApiScopeRegistryFacade {
83
83
  if (!routeMethod || typeof routeMethod !== "function") {
84
84
  throw new Error(`ApiFunction request method "${method}" is not supported by Route`);
85
85
  }
86
- routeMethod.bind(Route_1.Route)(path, handler);
86
+ routeMethod.bind(Route_1.Route)(path, handler, { middleware });
87
87
  }
88
88
  handleHttpFunction(registration, FunctionClass, req, res) {
89
89
  return __awaiter(this, void 0, void 0, function* () {
@@ -29,14 +29,52 @@ export type DataBuilderOptionMapping = {
29
29
  labelPrefix?: string;
30
30
  };
31
31
  export type DataBuilderOptionsMapping = DataBuilderOptionMapping | DataBuilderOptionMapping[];
32
+ export type DataBuilderFormFieldDefinition = {
33
+ field: string;
34
+ width?: string | number;
35
+ placement?: "content" | "actions";
36
+ hidden?: string | boolean;
37
+ disabled?: string | boolean;
38
+ fields?: DataBuilderFormDefinition[];
39
+ [key: string]: any;
40
+ };
41
+ export type DataBuilderFormTabDefinition = {
42
+ key: string;
43
+ title: string;
44
+ icon?: string;
45
+ disabled?: boolean;
46
+ fields: DataBuilderFormDefinition[];
47
+ };
48
+ export type DataBuilderFormTabsDefinition = {
49
+ type: "tabs";
50
+ label?: string;
51
+ width?: string | number;
52
+ appearance?: "card" | "plain";
53
+ tabs: DataBuilderFormTabDefinition[];
54
+ };
55
+ export type DataBuilderFormLayoutDefinition = {
56
+ type: string;
57
+ width?: string | number;
58
+ children?: DataBuilderFormDefinition[];
59
+ [key: string]: any;
60
+ };
61
+ export type DataBuilderFormDefinition = DataBuilderFormFieldDefinition | DataBuilderFormTabsDefinition | DataBuilderFormLayoutDefinition;
62
+ export type DataBuilderForm = {
63
+ fields: DataBuilderFormDefinition[] | ((req: Request) => DataBuilderFormDefinition[] | Promise<DataBuilderFormDefinition[]>);
64
+ [key: string]: any;
65
+ };
32
66
  export type DataBuilderType = {
33
67
  key: string;
34
68
  singular: string;
35
69
  plural: string;
36
70
  schema: DataBuilderSchema;
37
71
  forms?: {
38
- [key: string]: any;
39
- };
72
+ [key: string]: DataBuilderForm;
73
+ } | ((req: Request) => {
74
+ [key: string]: DataBuilderForm;
75
+ } | Promise<{
76
+ [key: string]: DataBuilderForm;
77
+ }>);
40
78
  unmapped?: boolean;
41
79
  };
42
80
  export type DataBuilderFieldType = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webtypen/webframez-core",
3
- "version": "0.3.69",
3
+ "version": "0.3.71",
4
4
  "description": "The core package of the typescript based webframez (web-framework) by webtypen.de",
5
5
  "homepage": "https://webtypen.de/",
6
6
  "license": "MIT",
@@ -31,7 +31,8 @@
31
31
  "scripts": {
32
32
  "build": "tsc",
33
33
  "build:check": "tsc --noEmit",
34
- "dev": "PORT=3210 ts-node ./dev/app.ts"
34
+ "dev": "PORT=3210 ts-node ./dev/app.ts",
35
+ "test": "node --test tests/*.test.cjs"
35
36
  },
36
37
  "devDependencies": {
37
38
  "@types/busboy": "^1.5.4",