@sanity/sdk 0.0.0-alpha.19 → 0.0.0-alpha.20
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.d.ts +21 -21
- package/dist/index.js +7 -7
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/_exports/index.ts +7 -3
- package/src/auth/{handleCallback.test.ts → handleAuthCallback.test.ts} +7 -7
- package/src/auth/{handleCallback.ts → handleAuthCallback.ts} +1 -1
- package/src/document/{applyActions.test.ts → applyDocumentActions.test.ts} +20 -12
- package/src/document/{applyActions.ts → applyDocumentActions.ts} +11 -11
- package/src/document/documentStore.test.ts +61 -54
- package/src/document/permissions.ts +2 -2
- package/src/tsdoc.json +13 -1
package/dist/index.d.ts
CHANGED
|
@@ -146,21 +146,21 @@ declare interface AppliedTransaction extends QueuedTransaction {
|
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
/** @beta */
|
|
149
|
-
export declare function
|
|
149
|
+
export declare function applyDocumentActions<TDocument extends SanityDocument>(
|
|
150
150
|
instance: SanityInstance | ActionContext<DocumentStoreState>,
|
|
151
151
|
action: DocumentAction<TDocument> | DocumentAction<TDocument>[],
|
|
152
|
-
options?:
|
|
152
|
+
options?: ApplyDocumentActionsOptions,
|
|
153
153
|
): Promise<ActionsResult<TDocument>>
|
|
154
154
|
|
|
155
155
|
/** @beta */
|
|
156
|
-
export declare function
|
|
156
|
+
export declare function applyDocumentActions(
|
|
157
157
|
instance: SanityInstance | ActionContext<DocumentStoreState>,
|
|
158
158
|
action: DocumentAction | DocumentAction[],
|
|
159
|
-
options?:
|
|
159
|
+
options?: ApplyDocumentActionsOptions,
|
|
160
160
|
): Promise<ActionsResult>
|
|
161
161
|
|
|
162
162
|
/** @beta */
|
|
163
|
-
export declare interface
|
|
163
|
+
export declare interface ApplyDocumentActionsOptions {
|
|
164
164
|
/**
|
|
165
165
|
* Optionally provide an ID to be used as this transaction ID
|
|
166
166
|
*/
|
|
@@ -656,6 +656,19 @@ export declare interface DocumentHandle<TDocument extends SanityDocumentLike = S
|
|
|
656
656
|
resourceId?: DocumentResourceId
|
|
657
657
|
}
|
|
658
658
|
|
|
659
|
+
/** @beta */
|
|
660
|
+
export declare type DocumentPermissionsResult =
|
|
661
|
+
| {
|
|
662
|
+
allowed: false
|
|
663
|
+
message: string
|
|
664
|
+
reasons: PermissionDeniedReason[]
|
|
665
|
+
}
|
|
666
|
+
| {
|
|
667
|
+
allowed: true
|
|
668
|
+
message?: undefined
|
|
669
|
+
reasons?: undefined
|
|
670
|
+
}
|
|
671
|
+
|
|
659
672
|
/**
|
|
660
673
|
* @beta
|
|
661
674
|
* Event emitted when a document is published.
|
|
@@ -1039,7 +1052,7 @@ export declare const getOrCreateNode: ResourceAction<
|
|
|
1039
1052
|
export declare const getPermissionsState: ResourceAction<
|
|
1040
1053
|
DocumentStoreState,
|
|
1041
1054
|
[actions: DocumentAction | DocumentAction[]],
|
|
1042
|
-
StateSource<
|
|
1055
|
+
StateSource<DocumentPermissionsResult | undefined>
|
|
1043
1056
|
>
|
|
1044
1057
|
|
|
1045
1058
|
/**
|
|
@@ -1178,7 +1191,7 @@ declare interface GroupNode extends BaseNode {
|
|
|
1178
1191
|
/**
|
|
1179
1192
|
* @public
|
|
1180
1193
|
*/
|
|
1181
|
-
export declare const
|
|
1194
|
+
export declare const handleAuthCallback: ResourceAction<
|
|
1182
1195
|
AuthStoreState,
|
|
1183
1196
|
[locationHref?: string | undefined],
|
|
1184
1197
|
Promise<string | false>
|
|
@@ -1518,19 +1531,6 @@ export declare interface PermissionDeniedReason {
|
|
|
1518
1531
|
documentId?: string
|
|
1519
1532
|
}
|
|
1520
1533
|
|
|
1521
|
-
/** @beta */
|
|
1522
|
-
export declare type PermissionsResult =
|
|
1523
|
-
| {
|
|
1524
|
-
allowed: false
|
|
1525
|
-
message: string
|
|
1526
|
-
reasons: PermissionDeniedReason[]
|
|
1527
|
-
}
|
|
1528
|
-
| {
|
|
1529
|
-
allowed: true
|
|
1530
|
-
message?: undefined
|
|
1531
|
-
reasons?: undefined
|
|
1532
|
-
}
|
|
1533
|
-
|
|
1534
1534
|
declare interface PipeFuncCallNode extends BaseNode {
|
|
1535
1535
|
type: 'PipeFuncCall'
|
|
1536
1536
|
func: GroqPipeFunction
|
|
@@ -1728,7 +1728,7 @@ export declare function resolveDocument(
|
|
|
1728
1728
|
export declare const resolvePermissions: ResourceAction<
|
|
1729
1729
|
DocumentStoreState,
|
|
1730
1730
|
[actions: DocumentAction | DocumentAction[]],
|
|
1731
|
-
Promise<
|
|
1731
|
+
Promise<DocumentPermissionsResult>
|
|
1732
1732
|
>
|
|
1733
1733
|
|
|
1734
1734
|
/**
|
package/dist/index.js
CHANGED
|
@@ -325,7 +325,7 @@ const authStore = {
|
|
|
325
325
|
});
|
|
326
326
|
return state.set("fetchedLoginUrls", { providers: configuredProviders }), configuredProviders;
|
|
327
327
|
};
|
|
328
|
-
}),
|
|
328
|
+
}), handleAuthCallback = createAction(authStore, ({ state }) => {
|
|
329
329
|
const { providedToken, callbackUrl, clientFactory, apiHost, storageArea, storageKey } = state.get().options;
|
|
330
330
|
return async function(locationHref = getDefaultLocation()) {
|
|
331
331
|
if (providedToken) return !1;
|
|
@@ -4084,10 +4084,10 @@ const _resolveDocument = createAction(documentStore, () => function(doc) {
|
|
|
4084
4084
|
};
|
|
4085
4085
|
}
|
|
4086
4086
|
);
|
|
4087
|
-
function
|
|
4088
|
-
return
|
|
4087
|
+
function applyDocumentActions(...args) {
|
|
4088
|
+
return _applyDocumentActions(...args);
|
|
4089
4089
|
}
|
|
4090
|
-
const
|
|
4090
|
+
const _applyDocumentActions = createAction(documentStore, ({ state }) => {
|
|
4091
4091
|
const { events } = state.get();
|
|
4092
4092
|
return async function(action, { transactionId = crypto.randomUUID(), disableBatching } = {}) {
|
|
4093
4093
|
const actions = Array.isArray(action) ? action : [action], transaction = {
|
|
@@ -4847,12 +4847,12 @@ const API_VERSION = "vX", usersStore = {
|
|
|
4847
4847
|
resolveUsers,
|
|
4848
4848
|
setOptions
|
|
4849
4849
|
});
|
|
4850
|
-
var version = "0.0.0-alpha.
|
|
4850
|
+
var version = "0.0.0-alpha.20";
|
|
4851
4851
|
const CORE_SDK_VERSION = getEnv("PKG_VERSION") || `${version}-development`;
|
|
4852
4852
|
export {
|
|
4853
4853
|
AuthStateType,
|
|
4854
4854
|
CORE_SDK_VERSION,
|
|
4855
|
-
|
|
4855
|
+
applyDocumentActions,
|
|
4856
4856
|
createDocument,
|
|
4857
4857
|
createSanityInstance,
|
|
4858
4858
|
createUsersStore,
|
|
@@ -4882,7 +4882,7 @@ export {
|
|
|
4882
4882
|
getQueryState,
|
|
4883
4883
|
getResourceId,
|
|
4884
4884
|
getTokenState,
|
|
4885
|
-
|
|
4885
|
+
handleAuthCallback,
|
|
4886
4886
|
jsonMatch,
|
|
4887
4887
|
logout,
|
|
4888
4888
|
parseQueryKey,
|