@ai-matrx/content-ir 0.6.0 → 0.7.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/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.7.0 — 2026-08-29
4
+
5
+ - **`kindSchemaFromJsonSchema` — the registry-facing door for deriving a
6
+ kind's fields from its schema.** One schema in; the kind's `KindSchema` out,
7
+ plus every child kind the schema declared inline or through `$defs`, plus
8
+ the conversion problems. Pure and synchronous, so a host can call it from a
9
+ warm load, a cold fetch, a reducer, or a test. Accepts a bare JSON Schema
10
+ and the provider `{name, schema, strict}` envelope alike.
11
+
12
+ This is what makes a stored second copy of a kind's fields unnecessary. It
13
+ never returns a partial guess: an inexpressible field widens to `json`, and
14
+ only a structurally unusable root yields null.
15
+
3
16
  ## 0.6.0 — 2026-08-29
4
17
 
5
18
  - **`$ref` / `$defs` resolution — a kind's child kinds are no longer invisible
package/dist/index.cjs CHANGED
@@ -4295,6 +4295,41 @@ function kindSchemaToJsonSchema(kind, resolve, options = {}) {
4295
4295
  return { name: kind, schema: { ...rootNode, $defs: defs }, strict, unresolved };
4296
4296
  }
4297
4297
 
4298
+ // convert/json-schema-to-kind.ts
4299
+ function kindSchemaFromJsonSchema(kind, jsonSchema) {
4300
+ if (jsonSchema === null || jsonSchema === void 0) {
4301
+ return { schema: null, children: {}, problems: [] };
4302
+ }
4303
+ const normalized = normalizeAiSchemaInput(jsonSchema);
4304
+ const rootSchema = normalized.rootSchema ?? (typeof jsonSchema === "object" && !Array.isArray(jsonSchema) ? jsonSchema : null);
4305
+ if (!rootSchema) {
4306
+ return {
4307
+ schema: null,
4308
+ children: {},
4309
+ problems: [
4310
+ {
4311
+ severity: "error",
4312
+ path: "",
4313
+ message: `Kind "${kind}": emitted_json_schema is not a JSON object.`
4314
+ }
4315
+ ]
4316
+ };
4317
+ }
4318
+ const converted = convertAiSchemaToBlockFields(kind, rootSchema, false);
4319
+ let schema = null;
4320
+ const children = {};
4321
+ for (const draft of converted.blockSchemas) {
4322
+ const asKindSchema = {
4323
+ kind: draft.slug,
4324
+ fields: draft.fields,
4325
+ ...draft.root ? { root: draft.root } : {}
4326
+ };
4327
+ if (draft.slug === kind) schema = asKindSchema;
4328
+ else children[draft.slug] = asKindSchema;
4329
+ }
4330
+ return { schema, children, problems: converted.problems };
4331
+ }
4332
+
4298
4333
  // wire/partial-kind.ts
4299
4334
  var IR_PARTIAL_KEY = "__ir_partial";
4300
4335
  var PARTIAL_STATES = [
@@ -4626,6 +4661,7 @@ exports.isJsonAnyField = isJsonAnyField;
4626
4661
  exports.isProvisionalKind = isProvisionalKind;
4627
4662
  exports.isScalarArrayType = isScalarArrayType;
4628
4663
  exports.isTerminalKindEvent = isTerminalKindEvent;
4664
+ exports.kindSchemaFromJsonSchema = kindSchemaFromJsonSchema;
4629
4665
  exports.kindSchemaToJsonSchema = kindSchemaToJsonSchema;
4630
4666
  exports.kindSchemaToStorage = kindSchemaToStorage;
4631
4667
  exports.kindVerdictOf = kindVerdictOf;