@zhama/a2ui-core 0.4.0 → 0.6.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/README.md +60 -141
- package/dist/builders/index.cjs +2 -2
- package/dist/builders/index.d.cts +16 -3
- package/dist/builders/index.d.ts +16 -3
- package/dist/builders/index.js +2 -2
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/{primitives-nmkVz-tB.d.cts → primitives-DLbBDhLq.d.cts} +1 -35
- package/dist/{primitives-nmkVz-tB.d.ts → primitives-DLbBDhLq.d.ts} +1 -35
- package/dist/surface/index.cjs +2 -2
- package/dist/surface/index.d.cts +1 -1
- package/dist/surface/index.d.ts +1 -1
- package/dist/surface/index.js +2 -2
- package/dist/types/index.cjs +2 -2
- package/dist/types/index.d.cts +67 -34
- package/dist/types/index.d.ts +67 -34
- package/dist/types/index.js +2 -2
- package/dist/utils/index.d.cts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/validators/index.cjs +1 -1
- package/dist/validators/index.d.cts +8 -12
- package/dist/validators/index.d.ts +8 -12
- package/dist/validators/index.js +1 -1
- package/package.json +1 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { ServerToClientMessageV09
|
|
2
|
-
import '../primitives-
|
|
1
|
+
import { ServerToClientMessageV09 } from '../types/index.cjs';
|
|
2
|
+
import '../primitives-DLbBDhLq.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* Message Validator
|
|
5
|
+
* Message Validator - v0.9
|
|
6
6
|
*
|
|
7
|
-
* 提供 A2UI 消息验证功能
|
|
7
|
+
* 提供 A2UI v0.9 消息验证功能
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -54,16 +54,12 @@ interface ValidationOptions {
|
|
|
54
54
|
*/
|
|
55
55
|
declare function validateV09Message(message: ServerToClientMessageV09, options?: ValidationOptions): ValidationResult;
|
|
56
56
|
/**
|
|
57
|
-
*
|
|
57
|
+
* 验证消息(v0.9)
|
|
58
58
|
*/
|
|
59
|
-
declare function
|
|
60
|
-
/**
|
|
61
|
-
* 验证消息(自动检测版本)
|
|
62
|
-
*/
|
|
63
|
-
declare function validateMessage(message: ServerToClientMessage, options?: ValidationOptions): ValidationResult;
|
|
59
|
+
declare function validateMessage(message: ServerToClientMessageV09, options?: ValidationOptions): ValidationResult;
|
|
64
60
|
/**
|
|
65
61
|
* 验证消息数组
|
|
66
62
|
*/
|
|
67
|
-
declare function validateMessages(messages:
|
|
63
|
+
declare function validateMessages(messages: ServerToClientMessageV09[], options?: ValidationOptions): ValidationResult;
|
|
68
64
|
|
|
69
|
-
export { type ValidationError, type ValidationOptions, type ValidationResult, type ValidationWarning, validateMessage, validateMessages,
|
|
65
|
+
export { type ValidationError, type ValidationOptions, type ValidationResult, type ValidationWarning, validateMessage, validateMessages, validateV09Message };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { ServerToClientMessageV09
|
|
2
|
-
import '../primitives-
|
|
1
|
+
import { ServerToClientMessageV09 } from '../types/index.js';
|
|
2
|
+
import '../primitives-DLbBDhLq.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* Message Validator
|
|
5
|
+
* Message Validator - v0.9
|
|
6
6
|
*
|
|
7
|
-
* 提供 A2UI 消息验证功能
|
|
7
|
+
* 提供 A2UI v0.9 消息验证功能
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -54,16 +54,12 @@ interface ValidationOptions {
|
|
|
54
54
|
*/
|
|
55
55
|
declare function validateV09Message(message: ServerToClientMessageV09, options?: ValidationOptions): ValidationResult;
|
|
56
56
|
/**
|
|
57
|
-
*
|
|
57
|
+
* 验证消息(v0.9)
|
|
58
58
|
*/
|
|
59
|
-
declare function
|
|
60
|
-
/**
|
|
61
|
-
* 验证消息(自动检测版本)
|
|
62
|
-
*/
|
|
63
|
-
declare function validateMessage(message: ServerToClientMessage, options?: ValidationOptions): ValidationResult;
|
|
59
|
+
declare function validateMessage(message: ServerToClientMessageV09, options?: ValidationOptions): ValidationResult;
|
|
64
60
|
/**
|
|
65
61
|
* 验证消息数组
|
|
66
62
|
*/
|
|
67
|
-
declare function validateMessages(messages:
|
|
63
|
+
declare function validateMessages(messages: ServerToClientMessageV09[], options?: ValidationOptions): ValidationResult;
|
|
68
64
|
|
|
69
|
-
export { type ValidationError, type ValidationOptions, type ValidationResult, type ValidationWarning, validateMessage, validateMessages,
|
|
65
|
+
export { type ValidationError, type ValidationOptions, type ValidationResult, type ValidationWarning, validateMessage, validateMessages, validateV09Message };
|
package/dist/validators/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var u=["Text","Image","Icon","Video","AudioPlayer","Row","Column","List","Card","Tabs","Divider","Modal","Button","CheckBox","TextField","DateTimeInput","ChoicePicker","Slider"];function p(t,i={}){let a=[],n=[];if("createSurface"in t){let{createSurface:e}=t;e.surfaceId||a.push({code:"MISSING_SURFACE_ID",message:"createSurface.surfaceId is required",path:"createSurface.surfaceId"}),e.catalogId||a.push({code:"MISSING_CATALOG_ID",message:"createSurface.catalogId is required",path:"createSurface.catalogId"});}else if("updateComponents"in t){let{updateComponents:e}=t;e.surfaceId||a.push({code:"MISSING_SURFACE_ID",message:"updateComponents.surfaceId is required",path:"updateComponents.surfaceId"}),!e.components||!Array.isArray(e.components)?a.push({code:"INVALID_COMPONENTS",message:"updateComponents.components must be an array",path:"updateComponents.components"}):f(e.components,a,n,i);}else if("updateDataModel"in t){let{updateDataModel:e}=t;e.surfaceId||a.push({code:"MISSING_SURFACE_ID",message:"updateDataModel.surfaceId is required",path:"updateDataModel.surfaceId"}),e.op&&!["add","replace","remove"].includes(e.op)&&a.push({code:"INVALID_OP",message:"updateDataModel.op must be one of: add, replace, remove",path:"updateDataModel.op"}),e.op==="remove"&&e.value!==void 0&&n.push({code:"UNNECESSARY_VALUE",message:"updateDataModel.value should not be provided for remove operation",path:"updateDataModel.value"}),e.op!=="remove"&&e.value===void 0&&e.op==="add"&&a.push({code:"MISSING_VALUE",message:"updateDataModel.value is required for add operation",path:"updateDataModel.value"});}else if("deleteSurface"in t){let{deleteSurface:e}=t;e.surfaceId||a.push({code:"MISSING_SURFACE_ID",message:"deleteSurface.surfaceId is required",path:"deleteSurface.surfaceId"});}else a.push({code:"INVALID_MESSAGE_TYPE",message:"Message must contain one of: createSurface, updateComponents, updateDataModel, deleteSurface"});return {valid:a.length===0,errors:a,warnings:n}}function c(t,i={}){return p(t,i)}function l(t,i={}){let a=[],n=[];for(let e=0;e<t.length;e++){let r=t[e];if(!r)continue;let s=c(r,i);for(let o of s.errors)a.push({...o,path:`messages[${e}].${o.path??""}`});for(let o of s.warnings)n.push({...o,path:`messages[${e}].${o.path??""}`});}return {valid:a.length===0,errors:a,warnings:n}}function f(t,i,a,n){let e=new Set,r=false;for(let s=0;s<t.length;s++){let o=t[s];if(!o)continue;let d=`updateComponents.components[${s}]`;o.id?(e.has(o.id)&&i.push({code:"DUPLICATE_COMPONENT_ID",message:`Duplicate component id: ${o.id}`,path:`${d}.id`}),e.add(o.id),o.id==="root"&&(r=true)):i.push({code:"MISSING_COMPONENT_ID",message:"Component id is required",path:`${d}.id`}),o.component?n.strict&&!u.includes(o.component)&&n.allowedComponents&&!n.allowedComponents.includes(o.component)&&a.push({code:"UNKNOWN_COMPONENT_TYPE",message:`Unknown component type: ${o.component}`,path:`${d}.component`}):i.push({code:"MISSING_COMPONENT_TYPE",message:"Component type is required",path:`${d}.component`});}!r&&n.strict&&a.push({code:"MISSING_ROOT_COMPONENT",message:'No component with id "root" found',path:"updateComponents.components"});}export{c as validateMessage,l as validateMessages,p as validateV09Message};
|
package/package.json
CHANGED