@sanity/assist 3.0.6 → 3.0.8
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 +3 -1
- 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.js
CHANGED
|
@@ -28,7 +28,7 @@ function isWelcomeEvent(event) {
|
|
|
28
28
|
return event.type === "welcome";
|
|
29
29
|
}
|
|
30
30
|
const listenQuery = (client, query, params = {}, options2 = {}) => {
|
|
31
|
-
const fetchQuery =
|
|
31
|
+
const fetchQuery = query, listenerQuery = query, fetchOnce$ = fetch(client, fetchQuery, params, options2), events$ = listen(client, listenerQuery, params, options2).pipe(
|
|
32
32
|
operators.mergeMap((ev, i) => i === 0 && !isWelcomeEvent(ev) ? rxjs.throwError(
|
|
33
33
|
new Error(
|
|
34
34
|
ev.type === "reconnect" ? "Could not establish EventSource connection" : `Received unexpected type of first event "${ev.type}"`
|
|
@@ -46,12 +46,12 @@ const listenQuery = (client, query, params = {}, options2 = {}) => {
|
|
|
46
46
|
}, DEFAULT_PARAMS = {}, DEFAULT_OPTIONS = { apiVersion: "v2022-05-09" };
|
|
47
47
|
function useListeningQuery(query, params = DEFAULT_PARAMS, options2 = DEFAULT_OPTIONS) {
|
|
48
48
|
const [loading, setLoading] = react.useState(!0), [error, setError] = react.useState(!1), [data, setData] = react.useState(null), subscription = react.useRef(null), client = sanity.useClient({ apiVersion: "v2022-05-09" });
|
|
49
|
-
return react.useEffect(() => (
|
|
49
|
+
return react.useEffect(() => (subscription.current = listenQuery(client, query, params, options2).pipe(
|
|
50
50
|
operators.distinctUntilChanged(isEqual__default.default),
|
|
51
51
|
operators.catchError((err) => (console.error(err), setError(err), setLoading(!1), setData(null), err))
|
|
52
52
|
).subscribe((documents) => {
|
|
53
53
|
setData((current) => isEqual__default.default(current, documents) ? current : documents), setLoading(!1), setError(!1);
|
|
54
|
-
})
|
|
54
|
+
}), () => subscription.current ? subscription.current.unsubscribe() : void 0), [query, params, options2, client]), { loading, error, data };
|
|
55
55
|
}
|
|
56
56
|
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>";
|
|
57
57
|
function isPortableTextArray(type) {
|
|
@@ -935,7 +935,7 @@ function getConditionalMembers(docState) {
|
|
|
935
935
|
path: "",
|
|
936
936
|
hidden: !1,
|
|
937
937
|
readOnly: !!docState.readOnly,
|
|
938
|
-
conditional:
|
|
938
|
+
conditional: isConditional(docState.schemaType)
|
|
939
939
|
}, ...extractConditionalPaths(docState, MAX_DEPTH)].filter((v) => v.conditional).map(({ conditional, ...state }) => ({ ...state }));
|
|
940
940
|
}
|
|
941
941
|
function isConditional(schemaType) {
|