@sanity/assist 3.0.6 → 3.0.7
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 +4 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/helpers/conditionalMembers.test.ts +28 -0
- package/src/helpers/conditionalMembers.ts +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -35,7 +35,7 @@ function isWelcomeEvent(event) {
|
|
|
35
35
|
return event.type === "welcome";
|
|
36
36
|
}
|
|
37
37
|
const listenQuery = (client, query, params = {}, options2 = {}) => {
|
|
38
|
-
const fetchQuery =
|
|
38
|
+
const fetchQuery = query, listenerQuery = query, fetchOnce$ = fetch(client, fetchQuery, params, options2), events$ = listen(client, listenerQuery, params, options2).pipe(
|
|
39
39
|
mergeMap((ev, i) => i === 0 && !isWelcomeEvent(ev) ? throwError(
|
|
40
40
|
new Error(
|
|
41
41
|
ev.type === "reconnect" ? "Could not establish EventSource connection" : `Received unexpected type of first event "${ev.type}"`
|
|
@@ -53,12 +53,12 @@ const listenQuery = (client, query, params = {}, options2 = {}) => {
|
|
|
53
53
|
}, DEFAULT_PARAMS = {}, DEFAULT_OPTIONS = { apiVersion: "v2022-05-09" };
|
|
54
54
|
function useListeningQuery(query, params = DEFAULT_PARAMS, options2 = DEFAULT_OPTIONS) {
|
|
55
55
|
const [loading, setLoading] = useState(!0), [error, setError] = useState(!1), [data, setData] = useState(null), subscription = useRef(null), client = useClient({ apiVersion: "v2022-05-09" });
|
|
56
|
-
return useEffect(() => (
|
|
56
|
+
return useEffect(() => (subscription.current = listenQuery(client, query, params, options2).pipe(
|
|
57
57
|
distinctUntilChanged(isEqual),
|
|
58
58
|
catchError((err) => (console.error(err), setError(err), setLoading(!1), setData(null), err))
|
|
59
59
|
).subscribe((documents) => {
|
|
60
60
|
setData((current) => isEqual(current, documents) ? current : documents), setLoading(!1), setError(!1);
|
|
61
|
-
})
|
|
61
|
+
}), () => subscription.current ? subscription.current.unsubscribe() : void 0), [query, params, options2, client]), { loading, error, data };
|
|
62
62
|
}
|
|
63
63
|
const assistDocumentIdPrefix = "sanity.assist.schemaType.", assistDocumentStatusIdPrefix = "sanity.assist.status.", assistSchemaIdPrefix = "sanity.assist.schema.", assistDocumentTypeName = "sanity.assist.schemaType.annotations", assistFieldTypeName = "sanity.assist.schemaType.field", instructionTypeName = "sanity.assist.instruction", promptTypeName = "sanity.assist.instruction.prompt", userInputTypeName = "sanity.assist.instruction.userInput", instructionContextTypeName = "sanity.assist.instruction.context", fieldReferenceTypeName = "sanity.assist.instruction.fieldRef", contextDocumentTypeName = "assist.instruction.context", assistTasksStatusTypeName = "sanity.assist.task.status", instructionTaskTypeName = "sanity.assist.instructionTask", fieldPresenceTypeName = "sanity.assist.instructionTask.presence", assistSerializedTypeName = "sanity.assist.serialized.type", assistSerializedFieldTypeName = "sanity.assist.serialized.field", outputFieldTypeName = "sanity.assist.output.field", outputTypeTypeName = "sanity.assist.output.type", fieldPathParam = "pathKey", instructionParam = "instruction", documentRootKey = "<document>";
|
|
64
64
|
function isPortableTextArray(type) {
|
|
@@ -942,7 +942,7 @@ function getConditionalMembers(docState) {
|
|
|
942
942
|
path: "",
|
|
943
943
|
hidden: !1,
|
|
944
944
|
readOnly: !!docState.readOnly,
|
|
945
|
-
conditional:
|
|
945
|
+
conditional: isConditional(docState.schemaType)
|
|
946
946
|
}, ...extractConditionalPaths(docState, MAX_DEPTH)].filter((v) => v.conditional).map(({ conditional, ...state }) => ({ ...state }));
|
|
947
947
|
}
|
|
948
948
|
function isConditional(schemaType) {
|