@ai-matrx/content-ir 0.7.0 → 0.8.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/dist/index.js CHANGED
@@ -3207,14 +3207,13 @@ function registerDeclaredKindDraft(declaredKind, objectNode, path, ctx) {
3207
3207
  for (const [propName, propNode] of Object.entries(objectNode.properties)) {
3208
3208
  if (!isRecord4(propNode)) continue;
3209
3209
  if (propName === KIND_KEY) continue;
3210
- const converted = convertProperty(
3210
+ fields[propName] = convertFieldOrWiden(
3211
3211
  propName,
3212
3212
  propNode,
3213
3213
  memberRequired.has(propName),
3214
3214
  `${path}.${propName}`,
3215
3215
  ctx
3216
3216
  );
3217
- if (converted) fields[propName] = converted;
3218
3217
  }
3219
3218
  ctx.blockSchemas.push({
3220
3219
  slug: declaredKind,
@@ -3222,6 +3221,21 @@ function registerDeclaredKindDraft(declaredKind, objectNode, path, ctx) {
3222
3221
  fields
3223
3222
  });
3224
3223
  }
3224
+ function convertFieldOrWiden(fieldName, node, required, path, ctx) {
3225
+ const before = ctx.problems.length;
3226
+ const converted = convertProperty(fieldName, node, required, path, ctx);
3227
+ if (converted) return converted;
3228
+ for (let i = before; i < ctx.problems.length; i++) {
3229
+ const problem = ctx.problems[i];
3230
+ if (problem && problem.severity === "error") problem.severity = "warning";
3231
+ }
3232
+ ctx.problems.push({
3233
+ severity: "warning",
3234
+ path,
3235
+ message: `Field "${fieldName}" has no exact field type \u2014 carried as any JSON value (json) rather than dropped from the kind.`
3236
+ });
3237
+ return { ...requiredNullableFlags(required), type: "json" };
3238
+ }
3225
3239
  function convertProperty(fieldName, node, required, path, ctx) {
3226
3240
  const core = convertPropertyCore(fieldName, node, required, path, ctx);
3227
3241
  const field = core === null ? null : attachNodeMetadata(node, core);
@@ -3612,16 +3626,13 @@ function convertPropertyCore(fieldName, node, required, path, ctx) {
3612
3626
  for (const [propName, propNode] of Object.entries(itemNode.properties)) {
3613
3627
  if (!isRecord4(propNode)) continue;
3614
3628
  if (propName === KIND_KEY) continue;
3615
- const converted = convertProperty(
3629
+ itemFields[propName] = convertFieldOrWiden(
3616
3630
  propName,
3617
3631
  propNode,
3618
3632
  itemRequired.has(propName),
3619
3633
  `${path}[].${propName}`,
3620
3634
  ctx
3621
3635
  );
3622
- if (converted) {
3623
- itemFields[propName] = converted;
3624
- }
3625
3636
  }
3626
3637
  const alreadyHasBlockKind = propNameIsBlockKind(itemNode.properties) || itemRequired.has(KIND_KEY);
3627
3638
  ctx.arrayBindings.push({
@@ -3666,16 +3677,13 @@ function convertPropertyCore(fieldName, node, required, path, ctx) {
3666
3677
  for (const [propName, propNode] of Object.entries(node.properties)) {
3667
3678
  if (!isRecord4(propNode)) continue;
3668
3679
  if (propName === KIND_KEY) continue;
3669
- const converted = convertProperty(
3680
+ nestedFields[propName] = convertFieldOrWiden(
3670
3681
  propName,
3671
3682
  propNode,
3672
3683
  nestedRequired.has(propName),
3673
3684
  `${path}.${propName}`,
3674
3685
  ctx
3675
3686
  );
3676
- if (converted) {
3677
- nestedFields[propName] = converted;
3678
- }
3679
3687
  }
3680
3688
  const referencedKind = readBlockKindFromProperties(node.properties);
3681
3689
  if (referencedKind) {
@@ -3860,16 +3868,13 @@ function convertAiSchemaToBlockFields(schemaName, rootSchema, strict) {
3860
3868
  for (const [fieldName, fieldNode] of Object.entries(properties)) {
3861
3869
  if (!isRecord4(fieldNode)) continue;
3862
3870
  if (fieldName === KIND_KEY) continue;
3863
- const converted = convertProperty(
3871
+ convertedFields[fieldName] = convertFieldOrWiden(
3864
3872
  fieldName,
3865
3873
  fieldNode,
3866
3874
  required.has(fieldName),
3867
3875
  fieldName,
3868
3876
  ctx
3869
3877
  );
3870
- if (converted) {
3871
- convertedFields[fieldName] = converted;
3872
- }
3873
3878
  }
3874
3879
  const rootHasKind = propNameIsBlockKind(properties) || required.has(KIND_KEY);
3875
3880
  if (!rootHasKind) {