@sanity/sdk 2.11.0 → 2.11.1
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/_chunks-es/createGroqSearchFilter.js +10 -5
- package/dist/_chunks-es/createGroqSearchFilter.js.map +1 -1
- package/dist/_chunks-es/version.js +1 -1
- package/dist/index.js +396 -371
- package/dist/index.js.map +1 -1
- package/package.json +12 -12
- package/src/auth/refreshStampedToken.test.ts +2 -2
- package/src/auth/subscribeToStateAndFetchCurrentUser.test.ts +116 -0
- package/src/auth/subscribeToStateAndFetchCurrentUser.ts +27 -9
- package/src/document/documentStore.ts +1 -1
- package/src/document/permissions.ts +1 -1
- package/src/document/processActions/create.ts +135 -0
- package/src/document/processActions/delete.ts +100 -0
- package/src/document/processActions/discard.ts +63 -0
- package/src/document/processActions/edit.ts +176 -0
- package/src/document/processActions/processActions.ts +168 -0
- package/src/document/processActions/publish.ts +120 -0
- package/src/document/processActions/shared.ts +47 -0
- package/src/document/processActions/unpublish.ts +85 -0
- package/src/document/processActions.test.ts +1 -1
- package/src/document/reducers.ts +1 -1
- package/src/document/processActions.ts +0 -735
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createClient, CorsOriginError } from "@sanity/client";
|
|
2
|
-
import { Observable, map, distinctUntilChanged, shareReplay, skip, defer, finalize, filter, exhaustMap, timer, switchMap, takeWhile, from, firstValueFrom, EMPTY, fromEvent,
|
|
2
|
+
import { Observable, map, distinctUntilChanged, shareReplay, skip, defer, finalize, filter, exhaustMap, timer, switchMap, takeWhile, from, firstValueFrom, catchError, EMPTY, fromEvent, NEVER, first, race, startWith, pairwise, mergeMap, groupBy, of, combineLatest, tap, share } from "rxjs";
|
|
3
3
|
import { createSelector } from "reselect";
|
|
4
4
|
import { createImageUrlBuilder } from "@sanity/image-url";
|
|
5
5
|
import { devtools } from "zustand/middleware";
|
|
@@ -547,16 +547,21 @@ const refreshStampedToken = ({ state }) => {
|
|
|
547
547
|
uri: "/users/me",
|
|
548
548
|
method: "GET",
|
|
549
549
|
tag: "users.get-current"
|
|
550
|
-
})
|
|
550
|
+
}).pipe(
|
|
551
|
+
/**
|
|
552
|
+
* Catch inside switchMap so the outer subscription survives.
|
|
553
|
+
* Without this, a 401 terminates the subscription permanently
|
|
554
|
+
* and subsequent token refreshes via comlink never re-fetch /users/me.
|
|
555
|
+
* @see SDK-1409
|
|
556
|
+
*/
|
|
557
|
+
catchError((error) => (state.set("setError", { authState: { type: AuthStateType.ERROR, error } }), EMPTY))
|
|
558
|
+
)
|
|
551
559
|
)
|
|
552
560
|
).subscribe({
|
|
553
561
|
next: (currentUser) => {
|
|
554
562
|
state.set("setCurrentUser", (prev) => ({
|
|
555
563
|
authState: prev.authState.type === AuthStateType.LOGGED_IN ? { ...prev.authState, currentUser } : prev.authState
|
|
556
564
|
}));
|
|
557
|
-
},
|
|
558
|
-
error: (error) => {
|
|
559
|
-
state.set("setError", { authState: { type: AuthStateType.ERROR, error } });
|
|
560
565
|
}
|
|
561
566
|
});
|
|
562
567
|
};
|