@antglobal/copilot-cards-core 1.0.4 → 1.0.6
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 +57 -0
- package/dist/index.cjs +350 -129
- package/dist/index.d.ts +33 -7
- package/dist/index.js +350 -130
- package/dist/validation-text.cjs +1298 -0
- package/dist/validation-text.d.ts +215 -0
- package/dist/validation-text.js +1293 -0
- package/package.json +7 -1
package/README.md
CHANGED
|
@@ -48,6 +48,63 @@ const greeting = resolveExpression("Hello, ${user.name}!", schema.variables);
|
|
|
48
48
|
console.log(tree, greeting);
|
|
49
49
|
```
|
|
50
50
|
|
|
51
|
+
## Structured and source-located validation
|
|
52
|
+
|
|
53
|
+
Core exposes two structured validators for different input stages:
|
|
54
|
+
|
|
55
|
+
| Input | API | Import path | Result |
|
|
56
|
+
| --- | --- | --- | --- |
|
|
57
|
+
| An already parsed Schema object | `validateSchemaDetailed` | `@antglobal/copilot-cards-core` | `SchemaValidationIssue[]` |
|
|
58
|
+
| Raw JSON source text | `validateSchemaText` | `@antglobal/copilot-cards-core/validation-text` | `SchemaTextValidationResult` |
|
|
59
|
+
|
|
60
|
+
`validation-text` is an optional package subpath, not a function name. There is
|
|
61
|
+
no `validateText` export. Keeping this API in a separate entry point prevents
|
|
62
|
+
render-only Core consumers from bundling `jsonc-parser`.
|
|
63
|
+
|
|
64
|
+
`validateSchema(schema)` remains the compatible `string[]` API. Use
|
|
65
|
+
`validateSchemaDetailed(schema)` when an integration needs stable error codes,
|
|
66
|
+
RFC 6901 JSON Pointer paths, and localization parameters:
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
import {
|
|
70
|
+
validateSchemaDetailed,
|
|
71
|
+
type SchemaValidationIssue,
|
|
72
|
+
} from "@antglobal/copilot-cards-core";
|
|
73
|
+
|
|
74
|
+
const issues: SchemaValidationIssue[] = validateSchemaDetailed(schema);
|
|
75
|
+
// [{ code, path, anchorPath?, message, params? }]
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
JSON editors can opt into strict parsing and source ranges through a separate
|
|
79
|
+
entry point, keeping parser code out of render-only Core bundles:
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
import {
|
|
83
|
+
validateSchemaText,
|
|
84
|
+
type SchemaTextValidationResult,
|
|
85
|
+
} from "@antglobal/copilot-cards-core/validation-text";
|
|
86
|
+
|
|
87
|
+
const result: SchemaTextValidationResult = validateSchemaText(jsonText);
|
|
88
|
+
if (!result.valid) {
|
|
89
|
+
for (const issue of result.errors) {
|
|
90
|
+
console.log(issue.code, issue.path, issue.range);
|
|
91
|
+
}
|
|
92
|
+
} else {
|
|
93
|
+
// The successful result already contains the parsed Schema.
|
|
94
|
+
render(result.schema);
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Lines and columns are 1-based; offsets are 0-based JavaScript UTF-16 offsets.
|
|
99
|
+
The text API rejects comments, trailing commas, duplicate properties, inputs
|
|
100
|
+
over 1,000,000 characters, and nesting deeper than 128 levels. It returns at
|
|
101
|
+
most 50 diagnostics and sets `truncated: true` when more exist.
|
|
102
|
+
|
|
103
|
+
Core validates only shared SDK protocol such as roots, slots, references and
|
|
104
|
+
Repeat bindings. It deliberately does not validate component registration,
|
|
105
|
+
custom component props, host actions/events, injected variables, or expression
|
|
106
|
+
result types, so custom component JSON is not rejected for business-owned data.
|
|
107
|
+
|
|
51
108
|
## Capabilities
|
|
52
109
|
|
|
53
110
|
| Module | Purpose |
|