@sanity/assist 1.2.12 → 1.2.14

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
@@ -179,7 +179,7 @@ function isUnsupportedType(type) {
179
179
  }
180
180
  const inlineTypes = ["document", "object", "image", "file"];
181
181
  function serializeSchema(schema, options) {
182
- const list = schema.getTypeNames().filter(t => !(hiddenTypes.includes(t) || t.startsWith("sanity."))).map(t => schema.get(t)).filter(t => !!t).filter(t => isAssistSupported(t)).filter(t => !t.hidden && !t.readOnly).map(t => getSchemaStub(t, schema, options)).filter(t => {
182
+ const list = schema.getTypeNames().filter(t => !(hiddenTypes.includes(t) || t.startsWith("sanity."))).map(t => schema.get(t)).filter(t => !!t).filter(t => !t.hidden && !t.readOnly).map(t => getSchemaStub(t, schema, options)).filter(t => {
183
183
  if ("to" in t && t.to && !t.to.length) {
184
184
  return false;
185
185
  }
@@ -4229,7 +4229,40 @@ const documentInstructionStatus = sanity.defineType({
4229
4229
  }]
4230
4230
  })]
4231
4231
  });
4232
- const schemaTypes = [fieldInstructions, assistDocumentSchema, prompt, fieldReference, instruction, documentInstructionStatus, instructionTask, contextDocumentSchema, userInput, promptContext];
4232
+ function excludeComments(type) {
4233
+ var _a, _b, _c;
4234
+ const existingRender = (_a = type == null ? void 0 : type.components) == null ? void 0 : _a.field;
4235
+ return {
4236
+ ...type,
4237
+ ...("components" in type ? {
4238
+ components: {
4239
+ ...type.components,
4240
+ field: props => {
4241
+ const newProps = {
4242
+ ...props,
4243
+ ...{
4244
+ __internal_comments: void 0
4245
+ }
4246
+ };
4247
+ if (typeof existingRender === "function") {
4248
+ return existingRender(newProps);
4249
+ }
4250
+ return props.renderDefault(newProps);
4251
+ }
4252
+ }
4253
+ } : {}),
4254
+ ...("fields" in type ? {
4255
+ // recursively disable comments in fields
4256
+ fields: (_b = type.fields) == null ? void 0 : _b.map(field => excludeComments(field))
4257
+ } : {}),
4258
+ ...("of" in type ? {
4259
+ // recursively disable comments in array items
4260
+ of: (_c = type.of) == null ? void 0 : _c.map(arrayItemType => excludeComments(arrayItemType))
4261
+ } : {})
4262
+ };
4263
+ }
4264
+ const instructionForm = [fieldInstructions, instruction, fieldReference, prompt, userInput, promptContext].map(excludeComments);
4265
+ const schemaTypes = [...instructionForm, assistDocumentSchema, documentInstructionStatus, instructionTask, contextDocumentSchema];
4233
4266
  function useAssistSupported(path, schemaType) {
4234
4267
  return react.useMemo(() => isAssistSupported(schemaType), [schemaType]);
4235
4268
  }
@@ -4724,15 +4757,23 @@ const assist = sanity.definePlugin(config => {
4724
4757
  }
4725
4758
  return prev;
4726
4759
  },
4727
- unstable_fieldActions: prev => {
4728
- return [...prev, assistFieldActions];
4760
+ unstable_fieldActions: (prev, _ref17) => {
4761
+ let {
4762
+ documentType,
4763
+ schema
4764
+ } = _ref17;
4765
+ const docSchema = schema.get(documentType);
4766
+ if (docSchema && isSchemaAssistEnabled(docSchema)) {
4767
+ return [...prev, assistFieldActions];
4768
+ }
4769
+ return prev;
4729
4770
  },
4730
- unstable_languageFilter: (prev, _ref17) => {
4771
+ unstable_languageFilter: (prev, _ref18) => {
4731
4772
  let {
4732
4773
  documentId,
4733
4774
  schema,
4734
4775
  schemaType
4735
- } = _ref17;
4776
+ } = _ref18;
4736
4777
  const docSchema = schema.get(schemaType);
4737
4778
  if (docSchema && sanity.isObjectSchemaType(docSchema) && isSchemaAssistEnabled(docSchema)) {
4738
4779
  return [...prev, createAssistDocumentPresence(documentId, docSchema)];