@sanity/assist 6.1.10 → 6.1.11
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 +1 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -17
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -472,7 +472,8 @@ declare const assist: import("sanity").Plugin<void | AssistPluginConfig>;
|
|
|
472
472
|
declare function SchemaTypeTool(): import("react").JSX.Element;
|
|
473
473
|
interface AssistOptions {
|
|
474
474
|
aiAssist?: {
|
|
475
|
-
/** Set to true to disable assistance for this field or type */
|
|
475
|
+
/** Set to true to disable assistance for this field or type */
|
|
476
|
+
exclude?: boolean;
|
|
476
477
|
/**
|
|
477
478
|
* Set to true to add translation field-action to the field.
|
|
478
479
|
* Only has an effect in document types configured for document or field level translations.
|
|
@@ -573,7 +574,8 @@ declare module 'sanity' {
|
|
|
573
574
|
interface ObjectOptions extends AssistOptions {}
|
|
574
575
|
interface ReferenceBaseOptions {
|
|
575
576
|
aiAssist?: {
|
|
576
|
-
/** Set to true to disable assistance for this field or type */
|
|
577
|
+
/** Set to true to disable assistance for this field or type */
|
|
578
|
+
exclude?: boolean;
|
|
577
579
|
/**
|
|
578
580
|
* When set, the reference field will allow instructions to be added to it.
|
|
579
581
|
* Should be the name of the embeddings-index where assist will look for contextually relevant documents
|
|
@@ -586,7 +588,7 @@ declare module 'sanity' {
|
|
|
586
588
|
interface TextOptions extends AssistOptions {}
|
|
587
589
|
interface UrlOptions extends AssistOptions {}
|
|
588
590
|
interface EmailOptions extends AssistOptions {}
|
|
589
|
-
}
|
|
591
|
+
}
|
|
590
592
|
declare const defaultLanguageOutputs: TranslationOutputsFunction;
|
|
591
593
|
type GetUserInput = (args: {
|
|
592
594
|
/**
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/assistTypes.ts","../src/fieldActions/customFieldActions.tsx","../src/translate/types.ts","../src/types.ts","../src/plugin.tsx","../src/schemas/serialize/SchemTypeTool.tsx","../src/schemas/typeDefExtensions.ts","../src/translate/paths.ts","../src/fieldActions/useUserInput.ts","../src/helpers/typeUtils.ts"],"mappings":";;;;UAEiB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/assistTypes.ts","../src/fieldActions/customFieldActions.tsx","../src/translate/types.ts","../src/types.ts","../src/plugin.tsx","../src/schemas/serialize/SchemTypeTool.tsx","../src/schemas/typeDefExtensions.ts","../src/translate/paths.ts","../src/fieldActions/useUserInput.ts","../src/helpers/typeUtils.ts"],"mappings":";;;;UAEiB;;;;;;;;;;;;;;;;;;EAkBf,kBAAkB,SAAS,0BAA0B;;;;;;;;;;;;;;;;EAiBrD;;;;;;;;;;;;;EAcA;;UAGe;EACf,MAAM;EACN,iBAAiB;;UAGF;;;;;;;;;;EAUf;;;;;;;;;;;EAYA;;UCvDe;EACf,MAAM;EACN;EACA;;UAGe;;;;;EAKf;;;;;;;;;;;;;;;;;;EAkBA;;;;;EAMA,oBAAoB;;;;;;;EAQpB,wBAAwB;;;;;;EAOxB,2BAA2B;;;;;;;;;;;;;;;;;;;;;;EAuB3B;;;;;;;;;;;;;;;;;;;;;EAsBA,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;EA0BN,YAAY;;;;;;;;;EAUZ,mBAAmB;;KAGT,wBACR,wBACA,yBACA;KAEQ,wBAAwB,KAClC;EAGA,uBAAuB;;KAGb,yBAAyB,KACnC;;;;;EAOA,WAAW;;iBAKG,wBACd,QAAQ,KAAK,iCACZ;iBAOa,4BAA4B;iBAM5B,6BACd,OAAO,KAAK,kCACX;UCxMc;EACf;EACA;;UAGe;EACf,YAAY;EACZ,MAAM;EACN;EACA;EACA;;UAGe;;EAEf;EACA,YAAY;;KAGF,8BACV,gBAAgB,gBAChB,eAAe,YACf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;;;;;;;;;;;;;;;;;;MAgCA;QAGM;;;;;;;QAOA;;;;YAIA,sBAAsB;YACtB,sBAAsB;YACtB;IACR;;MAEE;;;;;MAMA;;;YAGM,oBAAoB;YACpB,sBAAsB;YACtB,oBAAoB;YACpB,mBAAmB;YACnB,qBAAqB;;cCUpB,wBAAwB;KCrIzB,gBAAgB;;;;EAI1B;;;;EAIA,QAAQ;MACJ,QAAQ;;;;UAKG;;;;EAIf;;;;EAIA;;;;EAIA;;KAGU;;;;EAIV,OAAO;;;;EAKP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA+Dc,gBAAgB;;;;;;;iBC3FhB,OAAO,YAAY,YAAY"}
|
package/dist/index.js
CHANGED
|
@@ -328,7 +328,7 @@ function isSchemaAssistEnabled(type) {
|
|
|
328
328
|
return !type.options?.aiAssist?.exclude;
|
|
329
329
|
}
|
|
330
330
|
function isAssistSupported(type) {
|
|
331
|
-
return !isSchemaAssistEnabled(type) || isDisabled(type) ? !1 : type.jsonType === "array" ? !type.of.every((t) => isDisabled(t)) : type.jsonType
|
|
331
|
+
return !isSchemaAssistEnabled(type) || isDisabled(type) ? !1 : type.jsonType === "array" ? !type.of.every((t) => isDisabled(t)) : type.jsonType !== "object" || !type.fields.every((field) => isDisabled(field.type)) || isType(type, "image");
|
|
332
332
|
}
|
|
333
333
|
function isDisabled(type) {
|
|
334
334
|
return !isSchemaAssistEnabled(type) || isUnsupportedType(type);
|
|
@@ -1180,16 +1180,16 @@ const Root = styled.span.withConfig({
|
|
|
1180
1180
|
componentId: "sc-6srsjv-2"
|
|
1181
1181
|
})`background:var(--ai-avatar-disc-color);color:white;width:21px;height:21px;display:flex;align-items:center;justify-content:center;border-radius:10.5px;position:absolute;top:2px;left:2px;`;
|
|
1182
1182
|
function AssistAvatar(props) {
|
|
1183
|
-
let { state = "present" } = props, scheme = useColorSchemeValue()
|
|
1183
|
+
let { state = "present" } = props, scheme = useColorSchemeValue(), style = useMemo(() => scheme === "dark" ? {
|
|
1184
|
+
"--ai-avatar-stroke-color": purple[400].hex,
|
|
1185
|
+
"--ai-avatar-disc-color": purple[600].hex
|
|
1186
|
+
} : {
|
|
1187
|
+
"--ai-avatar-stroke-color": purple[500].hex,
|
|
1188
|
+
"--ai-avatar-disc-color": purple[600].hex
|
|
1189
|
+
}, [scheme]);
|
|
1184
1190
|
return /* @__PURE__ */ jsxs(Root, {
|
|
1185
1191
|
"data-state": state,
|
|
1186
|
-
style
|
|
1187
|
-
"--ai-avatar-stroke-color": purple[400].hex,
|
|
1188
|
-
"--ai-avatar-disc-color": purple[600].hex
|
|
1189
|
-
} : {
|
|
1190
|
-
"--ai-avatar-stroke-color": purple[500].hex,
|
|
1191
|
-
"--ai-avatar-disc-color": purple[600].hex
|
|
1192
|
-
}, [scheme]),
|
|
1192
|
+
style,
|
|
1193
1193
|
children: [/* @__PURE__ */ jsx(Outline, {
|
|
1194
1194
|
width: "25",
|
|
1195
1195
|
height: "25",
|
|
@@ -1773,7 +1773,7 @@ function FieldAutocomplete(props) {
|
|
|
1773
1773
|
let currentField = t1, t2;
|
|
1774
1774
|
if ($[11] !== fieldRefs || $[12] !== filter) {
|
|
1775
1775
|
let t3;
|
|
1776
|
-
$[14] === filter ? t3 = $[15] : (t3 = (field) => filter
|
|
1776
|
+
$[14] === filter ? t3 = $[15] : (t3 = (field) => !filter || filter(field), $[14] = filter, $[15] = t3), t2 = fieldRefs.filter(t3).filter(_temp$8).map(_temp2$4), $[11] = fieldRefs, $[12] = filter, $[13] = t2;
|
|
1777
1777
|
} else t2 = $[13];
|
|
1778
1778
|
let autocompleteOptions = t2, renderOption = _temp3$2, renderValue = _temp4$1, filterOption = _temp5, t3 = currentField ? currentField.icon : SearchIcon, t4 = currentField?.key, t5;
|
|
1779
1779
|
return $[16] !== autocompleteOptions || $[17] !== id || $[18] !== onSelect || $[19] !== t3 || $[20] !== t4 ? (t5 = /* @__PURE__ */ jsx(Autocomplete, {
|
|
@@ -2615,7 +2615,7 @@ const getLanguageParams = (select, document) => {
|
|
|
2615
2615
|
let selection = select || {}, selectedValue = {};
|
|
2616
2616
|
for (let [key, path] of Object.entries(selection)) {
|
|
2617
2617
|
let value = get(document, path);
|
|
2618
|
-
Array.isArray(value) && (value = value.filter((item) => typeof item
|
|
2618
|
+
Array.isArray(value) && (value = value.filter((item) => typeof item != "object" || item?._type !== "reference" || "_ref" in item)), selectedValue[key] = value;
|
|
2619
2619
|
}
|
|
2620
2620
|
return selectedValue;
|
|
2621
2621
|
}, toFieldLanguagesKeyPrefix = "sanityStudio:assist:field-languages:from:";
|
|
@@ -2759,10 +2759,13 @@ function FieldTranslationProvider(props) {
|
|
|
2759
2759
|
setFieldLanguageMaps(void 0);
|
|
2760
2760
|
return;
|
|
2761
2761
|
}
|
|
2762
|
-
let preferred = getPreferredToFieldLanguages(from.id), allToLanguages = languages_0.filter((l) => l.id !== from?.id);
|
|
2763
|
-
setToLanguages(
|
|
2762
|
+
let preferred = getPreferredToFieldLanguages(from.id), allToLanguages = languages_0.filter((l) => l.id !== from?.id), filteredToLanguages = allToLanguages.filter((l_0) => !preferred.length || preferred.includes(l_0.id));
|
|
2763
|
+
setToLanguages(filteredToLanguages);
|
|
2764
2764
|
let fromId = from?.id, allToIds = allToLanguages?.map(_temp$4) ?? [], docMembers = getDocumentMembersFlat(document, documentSchema, config?.maxPathDepth);
|
|
2765
|
-
fromId && allToIds?.length
|
|
2765
|
+
if (fromId && allToIds?.length) {
|
|
2766
|
+
let transMap = getFieldLanguageMap(documentSchema, docMembers, fromId, allToIds.filter((toId) => fromId !== toId), config?.translationOutputs ?? defaultLanguageOutputs);
|
|
2767
|
+
setFieldLanguageMaps(transMap);
|
|
2768
|
+
} else setFieldLanguageMaps(void 0);
|
|
2766
2769
|
}, $[3] = config?.maxPathDepth, $[4] = config?.translationOutputs, $[5] = t3) : t3 = $[5];
|
|
2767
2770
|
let selectFromLanguage = t3, t4;
|
|
2768
2771
|
$[6] === fromLanguage ? t4 = $[7] : (t4 = (toggledLang, toLanguages_0, languages_1) => {
|
|
@@ -3082,7 +3085,9 @@ function AiAssistanceConfigProvider(props) {
|
|
|
3082
3085
|
$[5] !== getInstructStatus || $[6] !== initInstruct ? (t3 = async () => {
|
|
3083
3086
|
setError(void 0);
|
|
3084
3087
|
try {
|
|
3085
|
-
await initInstruct()
|
|
3088
|
+
await initInstruct();
|
|
3089
|
+
let status_0 = await getInstructStatus();
|
|
3090
|
+
setStatus(status_0);
|
|
3086
3091
|
} catch (t4) {
|
|
3087
3092
|
let e_0 = t4;
|
|
3088
3093
|
console.error("Failed to init ai assistance", e_0), setError(e_0);
|
|
@@ -3649,7 +3654,7 @@ const assistFieldActions = {
|
|
|
3649
3654
|
translateAction,
|
|
3650
3655
|
...customActions,
|
|
3651
3656
|
assistSupported && manageInstructionsItem
|
|
3652
|
-
].filter((c) => !!c).filter((c) => c.type
|
|
3657
|
+
].filter((c) => !!c).filter((c) => c.type !== "group" || c.children.length),
|
|
3653
3658
|
expanded: !1,
|
|
3654
3659
|
renderAsButton: !0,
|
|
3655
3660
|
hidden: !assistSupported && !imageCaptionAction && !translateAction && !imageGenAction
|
|
@@ -4986,7 +4991,7 @@ function isWelcomeEvent(event) {
|
|
|
4986
4991
|
/** @internal */
|
|
4987
4992
|
const listenQuery = (client, query, params = {}, options = {}) => {
|
|
4988
4993
|
let fetchQuery = typeof query == "string" ? query : query.fetch, listenerQuery = typeof query == "string" ? query : query.listen, fetchOnce$ = fetch(client, fetchQuery, params, options), [welcome$, mutationAndReconnect$] = partition(listen(client, listenerQuery, params, options).pipe(mergeMap((ev, i) => i === 0 && !isWelcomeEvent(ev) ? throwError(/* @__PURE__ */ Error(ev.type === "reconnect" ? "Could not establish EventSource connection" : `Received unexpected type of first event "${ev.type}"`)) : of(ev)), share()), isWelcomeEvent);
|
|
4989
|
-
return merge(welcome$.pipe(take(1)), mutationAndReconnect$.pipe(filter((event) => !options.transitions || event.type !== "mutation"
|
|
4994
|
+
return merge(welcome$.pipe(take(1)), mutationAndReconnect$.pipe(filter((event) => !options.transitions || event.type !== "mutation" || options.transitions.includes(event.transition)), switchMap((event) => merge(of(event), of(event).pipe(delay(options.throttleTime || 1e3)))))).pipe(exhaustMapToWithTrailing(fetchOnce$));
|
|
4990
4995
|
}, DEFAULT_PARAMS = {}, DEFAULT_OPTIONS = { apiVersion: "v2022-05-09" };
|
|
4991
4996
|
function useListeningQuery(query, t0, t1) {
|
|
4992
4997
|
let $ = c(11), params = t0 === void 0 ? DEFAULT_PARAMS : t0, options = t1 === void 0 ? DEFAULT_OPTIONS : t1, [loading, setLoading] = useState(!0), [error, setError] = useState(!1), [data, setData] = useState(null), subscription = useRef(null), t2;
|