@middag-io/react 0.48.0 → 0.50.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.
Files changed (31) hide show
  1. package/dist-lib/base/shell/BasicShell.d.ts.map +1 -1
  2. package/dist-lib/base/shell/BasicShell.js +21 -9
  3. package/dist-lib/contracts/block-data/form.d.ts +13 -18
  4. package/dist-lib/contracts/block-data/form.d.ts.map +1 -1
  5. package/dist-lib/contracts/generated/index.d.ts +2 -2
  6. package/dist-lib/contracts/generated/schemas.d.ts +94 -51
  7. package/dist-lib/contracts/generated/schemas.d.ts.map +1 -1
  8. package/dist-lib/contracts/generated/types.d.ts +25 -24
  9. package/dist-lib/contracts/generated/types.d.ts.map +1 -1
  10. package/dist-lib/contracts/page-contract.d.ts +2 -5
  11. package/dist-lib/contracts/page-contract.d.ts.map +1 -1
  12. package/dist-lib/index.d.ts +2 -3
  13. package/dist-lib/index.d.ts.map +1 -1
  14. package/dist-lib/middag-react.js +4931 -4920
  15. package/docs/public/schemas/ai-contract-manifest.json +0 -7
  16. package/docs/public/schemas/fragment.json +53 -60
  17. package/docs/public/schemas/manifest.json +0 -8
  18. package/docs/public/schemas/page-contract.json +53 -60
  19. package/docs/public/schemas/shared-props.json +53 -60
  20. package/package.json +5 -2
  21. package/src/base/blocks/FormPanelBlock.tsx +3 -3
  22. package/src/base/shell/BasicShell.tsx +15 -1
  23. package/src/contracts/block-data/form.ts +22 -18
  24. package/src/contracts/generated/index.ts +2 -2
  25. package/src/contracts/generated/schemas.ts +13 -22
  26. package/src/contracts/generated/types.ts +25 -24
  27. package/src/contracts/page-contract.ts +1 -6
  28. package/dist-lib/contracts/connectors.d.ts +0 -50
  29. package/dist-lib/contracts/connectors.d.ts.map +0 -1
  30. package/docs/public/schemas/connectors.json +0 -97
  31. package/src/contracts/connectors.ts +0 -60
@@ -7,9 +7,9 @@
7
7
  * Regenerate: npm run gen:contracts
8
8
  * Drift gate: npm run gen:contracts:check
9
9
  *
10
- * @source middag-io/middag-php-ui@v1.13.0 schema/{page-contract.json,fragment.json,shared-props.json}
10
+ * @source middag-io/middag-php-ui@v1.14.0 schema/{page-contract.json,fragment.json,shared-props.json}
11
11
  * @contract-version 2
12
- * @hash a11a97d1f5ad9c63
12
+ * @hash ed3b25557c7c82c7
13
13
  */
14
14
  export * from "./types.js";
15
15
  export { pageContractSchemaCore, fragmentSchemaCore, sharedPropsSchemaCore } from "./schemas.js";
@@ -7,9 +7,9 @@
7
7
  * Regenerate: npm run gen:contracts
8
8
  * Drift gate: npm run gen:contracts:check
9
9
  *
10
- * @source middag-io/middag-php-ui@v1.13.0 schema/{page-contract.json,fragment.json,shared-props.json}
10
+ * @source middag-io/middag-php-ui@v1.14.0 schema/{page-contract.json,fragment.json,shared-props.json}
11
11
  * @contract-version 2
12
- * @hash a11a97d1f5ad9c63
12
+ * @hash ed3b25557c7c82c7
13
13
  */
14
14
  import { z } from "zod";
15
15
  import type { NavigationNode, FormSectionNode, FormGroupNode, FormSchemaNode } from "./types.js";
@@ -103,17 +103,6 @@ export const LayoutDescriptorSchema = z.object({
103
103
  "meta": z.record(z.string(), z.unknown()).optional(),
104
104
  });
105
105
 
106
- export const BrandingSchema = z.object({
107
- "appName": z.string(),
108
- "logoUrl": z.string().optional(),
109
- "logoCompactUrl": z.string().optional(),
110
- });
111
-
112
- export const PageResourcesSchema = z.object({
113
- "featureFlags": z.record(z.string(), z.boolean()),
114
- "branding": BrandingSchema.optional(),
115
- });
116
-
117
106
  export const NotificationLevelSchema = z.union([z.enum(["success", "info", "warning", "error"]), z.string()]);
118
107
 
119
108
  export const NotificationSchema = z.object({
@@ -130,23 +119,17 @@ export const PageContractSchema = z.object({
130
119
  "shell": z.string(),
131
120
  "page": PageMetaSchema,
132
121
  "layout": LayoutDescriptorSchema,
133
- "resources": PageResourcesSchema.optional(),
134
122
  "notifications": z.array(NotificationSchema).optional(),
135
123
  "entities": z.record(z.string(), z.string()).optional(),
136
124
  });
137
125
 
138
126
  export const FragmentKindSchema = z.enum(["block", "region", "table", "form", "detail", "inspector", "notifications", "custom"]);
139
127
 
140
- export const ResourcePatchSchema = z.object({
141
- "featureFlags": z.record(z.string(), z.boolean()).optional(),
142
- });
143
-
144
128
  export const FragmentSchema = z.object({
145
129
  "version": z.literal("2"),
146
130
  "kind": FragmentKindSchema,
147
131
  "payload": z.record(z.string(), z.unknown()).optional(),
148
132
  "notifications": z.array(NotificationSchema).optional(),
149
- "resources": ResourcePatchSchema.optional(),
150
133
  "customType": z.string().optional(),
151
134
  });
152
135
 
@@ -218,15 +201,24 @@ export const FlashMessagesSchema = z.object({
218
201
  "warning": z.string().optional(),
219
202
  });
220
203
 
221
- export const FieldErrorSchema = z.union([z.string(), z.array(z.string())]);
204
+ export const FieldMessageSchema = z.object({
205
+ "message": z.string(),
206
+ "key": z.string(),
207
+ "domain": z.string(),
208
+ "params": z.record(z.string(), z.unknown()).optional(),
209
+ });
210
+
211
+ export const FieldErrorSchema = z.union([z.string(), z.array(z.union([z.string(), FieldMessageSchema])), FieldMessageSchema]);
222
212
 
223
213
  export const FormErrorsSchema = z.record(z.string(), FieldErrorSchema);
224
214
 
215
+ export const FormErrorBagsSchema = z.record(z.string(), FormErrorsSchema);
216
+
225
217
  export const SharedPropsSchema = z.object({
226
218
  "auth": SharedAuthSchema.optional(),
227
219
  "theme": SharedThemeSchema.optional(),
228
220
  "flash": FlashMessagesSchema.optional(),
229
- "errors": FormErrorsSchema.optional(),
221
+ "errors": z.union([FormErrorsSchema, FormErrorBagsSchema]).optional(),
230
222
  "csrf_token": z.string().optional(),
231
223
  "locale": z.string().optional(),
232
224
  "scope": z.record(z.string(), z.unknown()).optional(),
@@ -576,7 +568,6 @@ export const ActionResultSchema = z.object({
576
568
  "refreshBlocks": z.array(z.string()).optional(),
577
569
  "errors": FormErrorsSchema.optional(),
578
570
  "fragments": z.array(FragmentSchema).optional(),
579
- "resources": ResourcePatchSchema.optional(),
580
571
  });
581
572
 
582
573
  export const ActionTargetKindSchema = z.enum(["link", "route", "request", "panel"]);
@@ -7,9 +7,9 @@
7
7
  * Regenerate: npm run gen:contracts
8
8
  * Drift gate: npm run gen:contracts:check
9
9
  *
10
- * @source middag-io/middag-php-ui@v1.13.0 schema/{page-contract.json,fragment.json,shared-props.json}
10
+ * @source middag-io/middag-php-ui@v1.14.0 schema/{page-contract.json,fragment.json,shared-props.json}
11
11
  * @contract-version 2
12
- * @hash a11a97d1f5ad9c63
12
+ * @hash ed3b25557c7c82c7
13
13
  */
14
14
  export type Label = string | Translatable;
15
15
  export type ActionTarget =
@@ -55,7 +55,7 @@ export type FragmentKind =
55
55
  | "notifications"
56
56
  | "custom";
57
57
  export type ThemeMode = "light" | "dark" | "system" | (string & {});
58
- export type FieldError = string | string[];
58
+ export type FieldError = string | (string | FieldMessage)[] | FieldMessage;
59
59
  export type ValueFormat =
60
60
  | "text"
61
61
  | "date"
@@ -404,7 +404,6 @@ export interface PageContract {
404
404
  shell: string;
405
405
  page: PageMeta;
406
406
  layout: LayoutDescriptor;
407
- resources?: PageResources;
408
407
  notifications?: Notification[];
409
408
  entities?: {
410
409
  [k: string]: string;
@@ -483,17 +482,6 @@ export interface PollConfig {
483
482
  pauseWhenHidden: boolean;
484
483
  stopAfterMs?: number;
485
484
  }
486
- export interface PageResources {
487
- featureFlags: {
488
- [k: string]: boolean;
489
- };
490
- branding?: Branding;
491
- }
492
- export interface Branding {
493
- appName: string;
494
- logoUrl?: string;
495
- logoCompactUrl?: string;
496
- }
497
485
  export interface Notification {
498
486
  level: NotificationLevel;
499
487
  message: Label;
@@ -509,14 +497,8 @@ export interface Fragment {
509
497
  [k: string]: unknown;
510
498
  };
511
499
  notifications?: Notification[];
512
- resources?: ResourcePatch;
513
500
  customType?: string;
514
501
  }
515
- export interface ResourcePatch {
516
- featureFlags?: {
517
- [k: string]: boolean;
518
- };
519
- }
520
502
  export interface InspectorDescriptor {
521
503
  endpoint: string;
522
504
  width: number;
@@ -560,7 +542,10 @@ export interface SharedProps {
560
542
  auth?: SharedAuth;
561
543
  theme?: SharedTheme;
562
544
  flash?: FlashMessages;
563
- errors?: FormErrors;
545
+ /**
546
+ * Validation errors of the current request: a FormErrors map or, when the request carried the X-Inertia-Error-Bag header, a FormErrorBags map of bag name to FormErrors. The wire is not self-describing: the reader that sent the header reads errors[bag]; any other reader treats the map as flat.
547
+ */
548
+ errors?: FormErrors | FormErrorBags;
564
549
  csrf_token?: string;
565
550
  locale?: string;
566
551
  scope?: {
@@ -591,11 +576,28 @@ export interface FlashMessages {
591
576
  warning?: string;
592
577
  }
593
578
  /**
594
- * Validation errors keyed by field name. The reserved key "_" carries form-level errors; dotted keys target nested fields.
579
+ * Validation errors keyed by field name. Each value is a message, a structured message (FieldMessage) or a list of either. The reserved key "_" carries form-level errors; dotted keys target nested fields.
595
580
  */
596
581
  export interface FormErrors {
597
582
  [k: string]: FieldError;
598
583
  }
584
+ /**
585
+ * A structured validation message: the server-resolved message plus the translation key, domain and optional params.
586
+ */
587
+ export interface FieldMessage {
588
+ message: string;
589
+ key: string;
590
+ domain: string;
591
+ params?: {
592
+ [k: string]: unknown;
593
+ };
594
+ }
595
+ /**
596
+ * Validation errors scoped to error bags: bag name to FormErrors.
597
+ */
598
+ export interface FormErrorBags {
599
+ [k: string]: FormErrors;
600
+ }
599
601
  export interface TableConfig {
600
602
  columns: Column[];
601
603
  filters?: FilterDefinition[];
@@ -717,6 +719,5 @@ export interface ActionResult {
717
719
  refreshBlocks?: string[];
718
720
  errors?: FormErrors;
719
721
  fragments?: Fragment[];
720
- resources?: ResourcePatch;
721
722
  }
722
723
 
@@ -18,7 +18,6 @@ import type {
18
18
  LayoutDescriptor as WireLayoutDescriptor,
19
19
  PageContract as WirePageContract,
20
20
  PageMeta as WirePageMeta,
21
- PageResources as WirePageResources,
22
21
  } from "@/contracts/generated";
23
22
 
24
23
  // ── Composed wire types ──────────────────────────────────────────────────────
@@ -45,13 +44,9 @@ export type LayoutDescriptor = Omit<WireLayoutDescriptor, "regions"> & {
45
44
  regions: Record<string, BlockDescriptor[]>;
46
45
  };
47
46
 
48
- /** Page resources — canonical php-ui shape. */
49
- export type PageResources = WirePageResources;
50
-
51
- export type PageContract = Omit<WirePageContract, "page" | "layout" | "resources"> & {
47
+ export type PageContract = Omit<WirePageContract, "page" | "layout"> & {
52
48
  page: PageMeta;
53
49
  layout: LayoutDescriptor;
54
- resources?: PageResources;
55
50
  // `entities` (entity type → route pattern) now rides on the generated
56
51
  // WirePageContract — sourced from the middag-php-ui PageContract VO.
57
52
  };
@@ -1,50 +0,0 @@
1
- /**
2
- * Connectors VOs — TypeScript mirror of PHP VOs in
3
- * `classes/extensions/core/connectors/connector/*`.
4
- */
5
- export type ConnectorStatus = "unconfigured" | "configured" | "connected" | "degraded" | "disconnected";
6
- export interface CredentialField {
7
- key: string;
8
- label: string;
9
- type: "text" | "password" | "url" | "select";
10
- required?: boolean;
11
- placeholder?: string | null;
12
- }
13
- export interface HealthCheckResult {
14
- success: boolean;
15
- latency_ms: number | null;
16
- error_message: string | null;
17
- resulting_status: string;
18
- checked_at: number;
19
- }
20
- export interface ConnectorListItem {
21
- id: number;
22
- fullname: string;
23
- connector_type: string;
24
- extension: string;
25
- status: ConnectorStatus;
26
- enabled: boolean;
27
- last_check_at: number | null;
28
- latency_ms: number | null;
29
- }
30
- export interface ConnectorDetail {
31
- id: number;
32
- fullname: string;
33
- description: string | null;
34
- connector_type: string;
35
- endpoint: string | null;
36
- extension: string;
37
- status: ConnectorStatus;
38
- enabled: boolean;
39
- created_at: number;
40
- modified_at: number;
41
- credential_fields: CredentialField[];
42
- health_history: HealthCheckResult[];
43
- }
44
- export interface ConnectorTypeInfo {
45
- type: string;
46
- name: string;
47
- extension: string;
48
- credential_fields: CredentialField[];
49
- }
50
- //# sourceMappingURL=connectors.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"connectors.d.ts","sourceRoot":"","sources":["../../src/contracts/connectors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,M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AAc,EAAE,iBAAiB,EAAE,CAAC;CACrC;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,EAAE,eAAe,EAAE,CAAC;CACtC"}
@@ -1,97 +0,0 @@
1
- {
2
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "$id": "https://ui-docs.middag.io/schemas/connectors.json",
4
- "title": "MIDDAG Connectors Contract",
5
- "description": "TypeScript contract types for the connector management subsystem. Mirrors PHP VOs in classes/extensions/core/connectors/connector/*. Used for connector list pages, detail views, health checks, and type catalogs.",
6
-
7
- "types": {
8
- "ConnectorStatus": {
9
- "type": "string",
10
- "enum": ["unconfigured", "configured", "connected", "degraded", "disconnected"],
11
- "description": "Lifecycle state of a connector instance.",
12
- "x-ai-purpose": "Use to display status badges in connector lists and details. Maps to semantic colors: connected→success, degraded→warning, disconnected→destructive, configured→info, unconfigured→neutral."
13
- },
14
- "CredentialField": {
15
- "type": "object",
16
- "description": "Schema for a single credential input in the connector configuration form.",
17
- "properties": {
18
- "key": { "type": "string", "description": "Field identifier." },
19
- "label": { "type": "string", "description": "Display label." },
20
- "type": { "type": "string", "enum": ["text", "password", "url", "select"], "description": "Input component type." },
21
- "required": { "type": "boolean", "description": "Whether the field is required." },
22
- "placeholder": { "type": ["string", "null"], "description": "Placeholder text." }
23
- },
24
- "required": ["key", "label", "type"]
25
- },
26
- "HealthCheckResult": {
27
- "type": "object",
28
- "description": "Result of a single health check probe against a connector.",
29
- "properties": {
30
- "success": { "type": "boolean", "description": "Whether the health check passed." },
31
- "latency_ms": { "type": ["number", "null"], "description": "Response time in milliseconds." },
32
- "error_message": { "type": ["string", "null"], "description": "Error details when check fails." },
33
- "resulting_status": { "type": "string", "description": "ConnectorStatus after this check." },
34
- "checked_at": { "type": "number", "description": "Unix timestamp of the check." }
35
- },
36
- "required": ["success", "latency_ms", "error_message", "resulting_status", "checked_at"]
37
- },
38
- "ConnectorListItem": {
39
- "type": "object",
40
- "description": "Summary connector data for list/table views.",
41
- "properties": {
42
- "id": { "type": "number" },
43
- "fullname": { "type": "string" },
44
- "connector_type": { "type": "string" },
45
- "extension": { "type": "string", "description": "Owning extension (e.g. 'local_middag')." },
46
- "status": { "$ref": "#/types/ConnectorStatus" },
47
- "enabled": { "type": "boolean" },
48
- "last_check_at": { "type": ["number", "null"], "description": "Unix timestamp of last health check." },
49
- "latency_ms": { "type": ["number", "null"] }
50
- },
51
- "required": ["id", "fullname", "connector_type", "extension", "status", "enabled"]
52
- },
53
- "ConnectorDetail": {
54
- "type": "object",
55
- "description": "Full connector data for detail/edit views.",
56
- "properties": {
57
- "id": { "type": "number" },
58
- "fullname": { "type": "string" },
59
- "description": { "type": ["string", "null"] },
60
- "connector_type": { "type": "string" },
61
- "endpoint": { "type": ["string", "null"], "description": "API endpoint URL." },
62
- "extension": { "type": "string" },
63
- "status": { "$ref": "#/types/ConnectorStatus" },
64
- "enabled": { "type": "boolean" },
65
- "created_at": { "type": "number" },
66
- "modified_at": { "type": "number" },
67
- "credential_fields": {
68
- "type": "array",
69
- "items": { "$ref": "#/types/CredentialField" },
70
- "description": "Schema for the connector's credential form."
71
- },
72
- "health_history": {
73
- "type": "array",
74
- "items": { "$ref": "#/types/HealthCheckResult" },
75
- "description": "Recent health check history (most recent first)."
76
- }
77
- },
78
- "required": ["id", "fullname", "connector_type", "extension", "status", "enabled", "created_at", "modified_at", "credential_fields", "health_history"]
79
- },
80
- "ConnectorTypeInfo": {
81
- "type": "object",
82
- "description": "Catalog entry for a connector type (not an instance).",
83
- "properties": {
84
- "type": { "type": "string", "description": "Unique type identifier." },
85
- "name": { "type": "string", "description": "Display name." },
86
- "extension": { "type": "string" },
87
- "credential_fields": {
88
- "type": "array",
89
- "items": { "$ref": "#/types/CredentialField" }
90
- }
91
- },
92
- "required": ["type", "name", "extension", "credential_fields"]
93
- }
94
- },
95
-
96
- "x-ai-purpose": "These types are used when building connector management pages (list, detail, configuration). They are NOT part of the PageContract block system — connectors are a separate subsystem with its own pages that happen to use the same block types (dense_table for lists, detail_panel for details, form_panel for configuration)."
97
- }
@@ -1,60 +0,0 @@
1
- /**
2
- * Connectors VOs — TypeScript mirror of PHP VOs in
3
- * `classes/extensions/core/connectors/connector/*`.
4
- */
5
-
6
- export type ConnectorStatus =
7
- | "unconfigured"
8
- | "configured"
9
- | "connected"
10
- | "degraded"
11
- | "disconnected";
12
-
13
- export interface CredentialField {
14
- key: string;
15
- label: string;
16
- type: "text" | "password" | "url" | "select";
17
- required?: boolean;
18
- placeholder?: string | null;
19
- }
20
-
21
- export interface HealthCheckResult {
22
- success: boolean;
23
- latency_ms: number | null;
24
- error_message: string | null;
25
- resulting_status: string;
26
- checked_at: number;
27
- }
28
-
29
- export interface ConnectorListItem {
30
- id: number;
31
- fullname: string;
32
- connector_type: string;
33
- extension: string;
34
- status: ConnectorStatus;
35
- enabled: boolean;
36
- last_check_at: number | null;
37
- latency_ms: number | null;
38
- }
39
-
40
- export interface ConnectorDetail {
41
- id: number;
42
- fullname: string;
43
- description: string | null;
44
- connector_type: string;
45
- endpoint: string | null;
46
- extension: string;
47
- status: ConnectorStatus;
48
- enabled: boolean;
49
- created_at: number;
50
- modified_at: number;
51
- credential_fields: CredentialField[];
52
- health_history: HealthCheckResult[];
53
- }
54
-
55
- export interface ConnectorTypeInfo {
56
- type: string;
57
- name: string;
58
- extension: string;
59
- credential_fields: CredentialField[];
60
- }