sanity 4.22.0 → 4.22.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/lib/_chunks-es/package.js +1 -1
- package/lib/_chunks-es/version.js +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.js +14 -7
- package/lib/index.js.map +1 -1
- package/package.json +16 -16
|
@@ -7,7 +7,7 @@ try {
|
|
|
7
7
|
try {
|
|
8
8
|
buildVersion = buildVersion || // This is replaced by `@sanity/pkg-utils` at build time
|
|
9
9
|
// and must always be references by its full static name, e.g. no optional chaining, no `if (process && process.env)` etc.
|
|
10
|
-
"4.22.
|
|
10
|
+
"4.22.1";
|
|
11
11
|
} catch {
|
|
12
12
|
}
|
|
13
13
|
const SANITY_VERSION = buildVersion || `${version}-dev`;
|
package/lib/index.d.ts
CHANGED
|
@@ -5573,6 +5573,7 @@ export declare function emitOperation(
|
|
|
5573
5573
|
idPair: IdPair,
|
|
5574
5574
|
typeName: string,
|
|
5575
5575
|
extraArgs: any[],
|
|
5576
|
+
storeKey?: string,
|
|
5576
5577
|
): void
|
|
5577
5578
|
|
|
5578
5579
|
/** @internal */
|
|
@@ -5726,6 +5727,7 @@ declare interface ExecuteArgs {
|
|
|
5726
5727
|
operationName: keyof OperationsAPI
|
|
5727
5728
|
idPair: IdPair
|
|
5728
5729
|
typeName: string
|
|
5730
|
+
storeKey?: string
|
|
5729
5731
|
extraArgs: any[]
|
|
5730
5732
|
}
|
|
5731
5733
|
|
package/lib/index.js
CHANGED
|
@@ -5475,7 +5475,12 @@ const snapshotPair = memoize((client, idPair, typeName, serverActionsEnabled, pa
|
|
|
5475
5475
|
}, (ctx, idPair, typeName) => memoizeKeyGen(ctx.client, idPair, typeName)), consistencyStatus = memoize((client, idPair, typeName, serverActionsEnabled, extraOptions) => memoizedPair(client, idPair, typeName, serverActionsEnabled, extraOptions).pipe(switchMap(({
|
|
5476
5476
|
draft,
|
|
5477
5477
|
published
|
|
5478
|
-
}) => combineLatest([draft.consistency$, published.consistency$])), map(([draftIsConsistent, publishedIsConsistent]) => draftIsConsistent && publishedIsConsistent), distinctUntilChanged(), publishReplay(1), refCount()), memoizeKeyGen)
|
|
5478
|
+
}) => combineLatest([draft.consistency$, published.consistency$])), map(([draftIsConsistent, publishedIsConsistent]) => draftIsConsistent && publishedIsConsistent), distinctUntilChanged(), publishReplay(1), refCount()), memoizeKeyGen);
|
|
5479
|
+
function getOperationStoreKey(client) {
|
|
5480
|
+
const config = client.config();
|
|
5481
|
+
return `${config.projectId ?? ""}-${config.dataset ?? ""}`;
|
|
5482
|
+
}
|
|
5483
|
+
const operationArgs = memoize((ctx, idPair, typeName) => snapshotPair(ctx.client, idPair, typeName, ctx.serverActionsEnabled, ctx.pairListenerOptions).pipe(switchMap((versions) => combineLatest([versions.draft.snapshots$, versions.published.snapshots$, ctx.serverActionsEnabled, ...typeof versions.version > "u" ? [] : [versions.version.snapshots$]]).pipe(map(([draft, published, canUseServerActions, version2]) => ({
|
|
5479
5484
|
...ctx,
|
|
5480
5485
|
serverActionsEnabled: canUseServerActions,
|
|
5481
5486
|
idPair,
|
|
@@ -5859,16 +5864,17 @@ const operationImpls = {
|
|
|
5859
5864
|
const operation = serverActionsEnabled ? serverOperationImpls[operationName] : operationImpls[operationName];
|
|
5860
5865
|
return defer(() => merge(of(null), maybeObservable(operation.execute(operationArguments, ...extraArgs)))).pipe(last());
|
|
5861
5866
|
}, operationCalls$ = new Subject();
|
|
5862
|
-
function emitOperation(operationName, idPair, typeName, extraArgs) {
|
|
5867
|
+
function emitOperation(operationName, idPair, typeName, extraArgs, storeKey) {
|
|
5863
5868
|
operationCalls$.next({
|
|
5864
5869
|
operationName,
|
|
5865
5870
|
idPair,
|
|
5866
5871
|
typeName,
|
|
5872
|
+
storeKey,
|
|
5867
5873
|
extraArgs
|
|
5868
5874
|
});
|
|
5869
5875
|
}
|
|
5870
5876
|
const REQUIRES_CONSISTENCY = ["publish", "unpublish", "discardChanges", "delete"], operationEvents = memoize((ctx) => {
|
|
5871
|
-
const result$ = operationCalls$.pipe(groupBy$1((op) => op.idPair.publishedId), mergeMap((groups$) => groups$.pipe(
|
|
5877
|
+
const storeKey = getOperationStoreKey(ctx.client), result$ = operationCalls$.pipe(filter((op) => op.storeKey === storeKey || !op.storeKey), groupBy$1((op) => op.idPair.publishedId), mergeMap((groups$) => groups$.pipe(
|
|
5872
5878
|
// although it might look like a bug, dropping pending async operations here is actually a feature
|
|
5873
5879
|
// E.g. if the user types `publish` which is async and then starts patching (sync) then the publish
|
|
5874
5880
|
// should be cancelled
|
|
@@ -5889,7 +5895,7 @@ const REQUIRES_CONSISTENCY = ["publish", "unpublish", "discardChanges", "delete"
|
|
|
5889
5895
|
leading: !0,
|
|
5890
5896
|
trailing: !0
|
|
5891
5897
|
}), concatMap$1((result) => window.SLOW ? timer(1e4).pipe(map(() => result)) : of(result)), tap((result) => {
|
|
5892
|
-
emitOperation("commit", result.args.idPair, result.args.typeName, []);
|
|
5898
|
+
emitOperation("commit", result.args.idPair, result.args.typeName, [], result.args.storeKey);
|
|
5893
5899
|
}));
|
|
5894
5900
|
return merge(result$, autoCommit$.pipe(mergeMapTo(EMPTY$5)));
|
|
5895
5901
|
}, (ctx) => {
|
|
@@ -7011,11 +7017,12 @@ const GUARDED = {
|
|
|
7011
7017
|
unpublish: createOperationGuard("unpublish"),
|
|
7012
7018
|
duplicate: createOperationGuard("duplicate"),
|
|
7013
7019
|
restore: createOperationGuard("restore")
|
|
7014
|
-
}, createEmitter = (operationName, idPair, typeName) => (...executeArgs) => emitOperation(operationName, idPair, typeName, executeArgs);
|
|
7020
|
+
}, createEmitter = (operationName, idPair, typeName, storeKey) => (...executeArgs) => emitOperation(operationName, idPair, typeName, executeArgs, storeKey);
|
|
7015
7021
|
function wrap(opName, op, operationArgs2) {
|
|
7022
|
+
const disabled = op.disabled(operationArgs2), storeKey = getOperationStoreKey(operationArgs2.client);
|
|
7016
7023
|
return {
|
|
7017
|
-
disabled
|
|
7018
|
-
execute: createEmitter(opName, operationArgs2.idPair, operationArgs2.typeName)
|
|
7024
|
+
disabled,
|
|
7025
|
+
execute: createEmitter(opName, operationArgs2.idPair, operationArgs2.typeName, storeKey)
|
|
7019
7026
|
};
|
|
7020
7027
|
}
|
|
7021
7028
|
function createOperationsAPI(args) {
|