@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.esm.js +47 -6
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +47 -6
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
- package/src/plugin.tsx +6 -2
- package/src/schemas/index.ts +45 -6
- package/src/schemas/serialize/serializeSchema.test.ts +15 -2
- package/src/schemas/serialize/serializeSchema.ts +2 -1
package/dist/index.esm.js
CHANGED
|
@@ -166,7 +166,7 @@ function isUnsupportedType(type) {
|
|
|
166
166
|
}
|
|
167
167
|
const inlineTypes = ["document", "object", "image", "file"];
|
|
168
168
|
function serializeSchema(schema, options) {
|
|
169
|
-
const list = schema.getTypeNames().filter(t => !(hiddenTypes.includes(t) || t.startsWith("sanity."))).map(t => schema.get(t)).filter(t => !!t).filter(t =>
|
|
169
|
+
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 => {
|
|
170
170
|
if ("to" in t && t.to && !t.to.length) {
|
|
171
171
|
return false;
|
|
172
172
|
}
|
|
@@ -4216,7 +4216,40 @@ const documentInstructionStatus = defineType({
|
|
|
4216
4216
|
}]
|
|
4217
4217
|
})]
|
|
4218
4218
|
});
|
|
4219
|
-
|
|
4219
|
+
function excludeComments(type) {
|
|
4220
|
+
var _a, _b, _c;
|
|
4221
|
+
const existingRender = (_a = type == null ? void 0 : type.components) == null ? void 0 : _a.field;
|
|
4222
|
+
return {
|
|
4223
|
+
...type,
|
|
4224
|
+
...("components" in type ? {
|
|
4225
|
+
components: {
|
|
4226
|
+
...type.components,
|
|
4227
|
+
field: props => {
|
|
4228
|
+
const newProps = {
|
|
4229
|
+
...props,
|
|
4230
|
+
...{
|
|
4231
|
+
__internal_comments: void 0
|
|
4232
|
+
}
|
|
4233
|
+
};
|
|
4234
|
+
if (typeof existingRender === "function") {
|
|
4235
|
+
return existingRender(newProps);
|
|
4236
|
+
}
|
|
4237
|
+
return props.renderDefault(newProps);
|
|
4238
|
+
}
|
|
4239
|
+
}
|
|
4240
|
+
} : {}),
|
|
4241
|
+
...("fields" in type ? {
|
|
4242
|
+
// recursively disable comments in fields
|
|
4243
|
+
fields: (_b = type.fields) == null ? void 0 : _b.map(field => excludeComments(field))
|
|
4244
|
+
} : {}),
|
|
4245
|
+
...("of" in type ? {
|
|
4246
|
+
// recursively disable comments in array items
|
|
4247
|
+
of: (_c = type.of) == null ? void 0 : _c.map(arrayItemType => excludeComments(arrayItemType))
|
|
4248
|
+
} : {})
|
|
4249
|
+
};
|
|
4250
|
+
}
|
|
4251
|
+
const instructionForm = [fieldInstructions, instruction, fieldReference, prompt, userInput, promptContext].map(excludeComments);
|
|
4252
|
+
const schemaTypes = [...instructionForm, assistDocumentSchema, documentInstructionStatus, instructionTask, contextDocumentSchema];
|
|
4220
4253
|
function useAssistSupported(path, schemaType) {
|
|
4221
4254
|
return useMemo(() => isAssistSupported(schemaType), [schemaType]);
|
|
4222
4255
|
}
|
|
@@ -4711,15 +4744,23 @@ const assist = definePlugin(config => {
|
|
|
4711
4744
|
}
|
|
4712
4745
|
return prev;
|
|
4713
4746
|
},
|
|
4714
|
-
unstable_fieldActions: prev => {
|
|
4715
|
-
|
|
4747
|
+
unstable_fieldActions: (prev, _ref17) => {
|
|
4748
|
+
let {
|
|
4749
|
+
documentType,
|
|
4750
|
+
schema
|
|
4751
|
+
} = _ref17;
|
|
4752
|
+
const docSchema = schema.get(documentType);
|
|
4753
|
+
if (docSchema && isSchemaAssistEnabled(docSchema)) {
|
|
4754
|
+
return [...prev, assistFieldActions];
|
|
4755
|
+
}
|
|
4756
|
+
return prev;
|
|
4716
4757
|
},
|
|
4717
|
-
unstable_languageFilter: (prev,
|
|
4758
|
+
unstable_languageFilter: (prev, _ref18) => {
|
|
4718
4759
|
let {
|
|
4719
4760
|
documentId,
|
|
4720
4761
|
schema,
|
|
4721
4762
|
schemaType
|
|
4722
|
-
} =
|
|
4763
|
+
} = _ref18;
|
|
4723
4764
|
const docSchema = schema.get(schemaType);
|
|
4724
4765
|
if (docSchema && isObjectSchemaType(docSchema) && isSchemaAssistEnabled(docSchema)) {
|
|
4725
4766
|
return [...prev, createAssistDocumentPresence(documentId, docSchema)];
|