@sanity/sdk 3.0.0-rc.0 → 3.0.0-rc.2
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 +12 -0
- package/dist/_exports/_internal.d.ts +163 -0
- package/dist/_exports/_internal.d.ts.map +1 -0
- package/dist/_exports/_internal.js +332 -0
- package/dist/_exports/_internal.js.map +1 -0
- package/dist/_exports/agent.d.ts +65 -0
- package/dist/_exports/agent.d.ts.map +1 -0
- package/dist/_exports/agent.js +71 -0
- package/dist/_exports/agent.js.map +1 -0
- package/dist/_exports/comlink.d.ts +118 -0
- package/dist/_exports/comlink.d.ts.map +1 -0
- package/dist/_exports/comlink.js +69 -0
- package/dist/_exports/comlink.js.map +1 -0
- package/dist/authStore-CtE9bLHW.js +754 -0
- package/dist/authStore-CtE9bLHW.js.map +1 -0
- package/dist/authStore-DKFX8fn7.d.ts +3179 -0
- package/dist/authStore-DKFX8fn7.d.ts.map +1 -0
- package/dist/clientStore-BtE2-q2i.js +90 -0
- package/dist/clientStore-BtE2-q2i.js.map +1 -0
- package/dist/createSanityInstance-DUI1bGIg.d.ts +278 -0
- package/dist/createSanityInstance-DUI1bGIg.d.ts.map +1 -0
- package/dist/createStateSourceAction-BOKtqFNm.js +300 -0
- package/dist/createStateSourceAction-BOKtqFNm.js.map +1 -0
- package/dist/getEnv-D5RGkQLu.js +8 -0
- package/dist/getEnv-D5RGkQLu.js.map +1 -0
- package/dist/getNodeState-CR3__B2D.js +67 -0
- package/dist/getNodeState-CR3__B2D.js.map +1 -0
- package/dist/index.d.ts +3 -2332
- package/dist/index.js +4171 -4332
- package/dist/index.js.map +1 -1
- package/dist/logger-DAtJb5RQ.js +173 -0
- package/dist/logger-DAtJb5RQ.js.map +1 -0
- package/dist/object-CxXlSVg7.js +83 -0
- package/dist/object-CxXlSVg7.js.map +1 -0
- package/dist/queryStore-DPf9sN3V.js +1346 -0
- package/dist/queryStore-DPf9sN3V.js.map +1 -0
- package/dist/rolldown-runtime-vyAXikos.js +9 -0
- package/dist/setCleanupTimeout-BiM6q1KF.js +31 -0
- package/dist/setCleanupTimeout-BiM6q1KF.js.map +1 -0
- package/dist/telemetryManager-Dq_qCkeI.js +127 -0
- package/dist/telemetryManager-Dq_qCkeI.js.map +1 -0
- package/dist/version-BChjsi4u.js +9 -0
- package/dist/version-BChjsi4u.js.map +1 -0
- package/package.json +47 -52
- package/src/_exports/_internal.ts +27 -0
- package/src/_exports/agent.ts +19 -0
- package/src/_exports/comlink.ts +16 -0
- package/src/_exports/index.ts +125 -64
- package/src/access/checkPermissions.test.ts +55 -0
- package/src/access/checkPermissions.ts +54 -0
- package/src/agent/agentActions.test.ts +16 -60
- package/src/agent/agentActions.ts +25 -38
- package/src/applications/applications.test-d.ts +88 -0
- package/src/applications/applications.test.ts +130 -0
- package/src/applications/applications.ts +367 -0
- package/src/auth/authLogger.ts +30 -0
- package/src/auth/authStore.test.ts +194 -13
- package/src/auth/authStore.ts +58 -26
- package/src/auth/getOrganizationVerificationState.test.ts +18 -17
- package/src/auth/getOrganizationVerificationState.ts +4 -4
- package/src/auth/handleAuthCallback.test.ts +35 -1
- package/src/auth/handleAuthCallback.ts +25 -6
- package/src/auth/logout.test.ts +75 -2
- package/src/auth/logout.ts +23 -4
- package/src/auth/refreshStampedToken.test.ts +219 -469
- package/src/auth/refreshStampedToken.ts +79 -195
- package/src/auth/studioAuth.ts +1 -1
- package/src/auth/studioModeAuth.ts +2 -1
- package/src/auth/subscribeToStateAndFetchCurrentUser.test.ts +146 -13
- package/src/auth/subscribeToStateAndFetchCurrentUser.ts +37 -6
- package/src/auth/subscribeToStorageEventsAndSetToken.test.ts +2 -0
- package/src/client/clientStore.test.ts +62 -37
- package/src/client/clientStore.ts +45 -75
- package/src/client/liveEvents.test.ts +151 -0
- package/src/client/liveEvents.ts +107 -0
- package/src/comlink/controller/actions/destroyController.test.ts +4 -1
- package/src/comlink/controller/actions/getOrCreateChannel.test.ts +4 -1
- package/src/comlink/controller/actions/getOrCreateChannel.ts +2 -2
- package/src/comlink/controller/actions/getOrCreateController.test.ts +4 -1
- package/src/comlink/controller/actions/releaseChannel.test.ts +1 -1
- package/src/comlink/controller/comlinkControllerStore.test.ts +4 -1
- package/src/comlink/node/actions/getOrCreateNode.test.ts +9 -3
- package/src/comlink/node/actions/getOrCreateNode.ts +2 -2
- package/src/comlink/node/actions/releaseNode.test.ts +7 -4
- package/src/comlink/node/comlinkNodeStore.test.ts +2 -2
- package/src/comlink/node/getNodeState.test.ts +1 -1
- package/src/comlink/node/getNodeState.ts +2 -1
- package/src/comments/addonDatasetStore.test.ts +215 -0
- package/src/comments/addonDatasetStore.ts +249 -0
- package/src/comments/buildCommentThreads.test.ts +83 -0
- package/src/comments/buildCommentThreads.ts +54 -0
- package/src/comments/commentActions.test.ts +540 -0
- package/src/comments/commentActions.ts +555 -0
- package/src/comments/commentFieldPath.test.ts +40 -0
- package/src/comments/commentFieldPath.ts +44 -0
- package/src/comments/commentsConstants.ts +80 -0
- package/src/comments/commentsStore.test.ts +419 -0
- package/src/comments/commentsStore.ts +483 -0
- package/src/comments/normalizeComment.test.ts +116 -0
- package/src/comments/normalizeComment.ts +45 -0
- package/src/comments/observeComments.test.ts +193 -0
- package/src/comments/observeComments.ts +113 -0
- package/src/comments/reducers.test.ts +277 -0
- package/src/comments/reducers.ts +316 -0
- package/src/comments/types.ts +249 -0
- package/src/comments/weakenReferences.test.ts +47 -0
- package/src/comments/weakenReferences.ts +29 -0
- package/src/config/__tests__/handles.test.ts +18 -12
- package/src/config/handles.ts +25 -7
- package/src/config/sanityConfig.ts +40 -82
- package/src/datasets/datasets.test.ts +2 -2
- package/src/datasets/datasets.ts +10 -4
- package/src/document/actions.test.ts +115 -33
- package/src/document/actions.ts +212 -15
- package/src/document/applyDocumentActions.test.ts +35 -13
- package/src/document/applyDocumentActions.ts +30 -9
- package/src/document/documentConstants.ts +15 -0
- package/src/document/documentStore.concurrency.test.ts +1306 -0
- package/src/document/documentStore.test.ts +753 -273
- package/src/document/documentStore.ts +197 -75
- package/src/document/events.test.ts +57 -2
- package/src/document/events.ts +82 -26
- package/src/document/listen.test.ts +56 -0
- package/src/document/listen.ts +74 -21
- package/src/document/listenerEventOperators.test.ts +311 -0
- package/src/document/listenerEventOperators.ts +217 -0
- package/src/document/patchOperations.test.ts +76 -2
- package/src/document/patchOperations.ts +60 -1
- package/src/document/permissions.test.ts +107 -60
- package/src/document/permissions.ts +44 -19
- package/src/document/processActions/create.ts +138 -0
- package/src/document/processActions/delete.ts +100 -0
- package/src/document/processActions/discard.ts +63 -0
- package/src/document/processActions/edit.ts +154 -0
- package/src/document/processActions/processActions.ts +218 -0
- package/src/document/processActions/publish.ts +120 -0
- package/src/document/processActions/releaseArchive.ts +77 -0
- package/src/document/processActions/releaseCreate.ts +59 -0
- package/src/document/processActions/releaseDelete.ts +65 -0
- package/src/document/processActions/releaseEdit.ts +37 -0
- package/src/document/processActions/releasePublish.ts +45 -0
- package/src/document/processActions/releaseSchedule.ts +87 -0
- package/src/document/processActions/releaseUtil.ts +31 -0
- package/src/document/processActions/shared.ts +308 -0
- package/src/document/processActions/unpublish.ts +85 -0
- package/src/document/processActions.test.ts +1129 -121
- package/src/document/reducers.test.ts +772 -64
- package/src/document/reducers.ts +205 -51
- package/src/document/resourceRules.test.ts +178 -0
- package/src/document/resourceRules.ts +117 -0
- package/src/document/sharedListener.test.ts +16 -14
- package/src/document/sharedListener.ts +24 -8
- package/src/document/util.test.ts +46 -0
- package/src/document/util.ts +50 -0
- package/src/favorites/favorites.test.ts +5 -6
- package/src/installations/installations.test-d.ts +73 -0
- package/src/installations/installations.test.ts +62 -0
- package/src/installations/installations.ts +206 -0
- package/src/organization/organization.test-d.ts +36 -0
- package/src/organization/organization.test.ts +138 -0
- package/src/organization/organization.ts +138 -0
- package/src/organizations/organizations.test-d.ts +56 -0
- package/src/organizations/organizations.test.ts +150 -0
- package/src/organizations/organizations.ts +107 -0
- package/src/presence/bifurTransport.test.ts +201 -9
- package/src/presence/bifurTransport.ts +98 -14
- package/src/presence/paths.test.ts +70 -0
- package/src/presence/paths.ts +41 -0
- package/src/presence/presenceStore.test.ts +915 -24
- package/src/presence/presenceStore.ts +576 -104
- package/src/presence/types.ts +175 -3
- package/src/preview/previewProjectionUtils.test.ts +9 -22
- package/src/preview/previewProjectionUtils.ts +7 -3
- package/src/preview/types.ts +0 -15
- package/src/project/project.test-d.ts +37 -0
- package/src/project/project.test.ts +157 -12
- package/src/project/project.ts +138 -25
- package/src/projection/getProjectionState.test.ts +18 -20
- package/src/projection/getProjectionState.ts +23 -3
- package/src/projection/projectionQuery.ts +5 -5
- package/src/projection/projectionStore.test.ts +1 -9
- package/src/projection/resolveProjection.test.ts +1 -2
- package/src/projection/resolveProjection.ts +16 -0
- package/src/projection/subscribeToStateAndFetchBatches.test.ts +1 -1
- package/src/projection/subscribeToStateAndFetchBatches.ts +32 -23
- package/src/projects/projects.test-d.ts +32 -0
- package/src/projects/projects.test.ts +108 -42
- package/src/projects/projects.ts +63 -27
- package/src/query/queryStore.test.ts +259 -123
- package/src/query/queryStore.ts +85 -69
- package/src/query/reducers.test.ts +0 -42
- package/src/query/reducers.ts +2 -18
- package/src/releases/getPerspectiveState.test.ts +17 -23
- package/src/releases/getPerspectiveState.ts +8 -20
- package/src/releases/observeReleases.test.ts +127 -0
- package/src/releases/observeReleases.ts +102 -0
- package/src/releases/releasesStore.test.ts +100 -53
- package/src/releases/releasesStore.ts +69 -44
- package/src/releases/utils/sortReleases.test.ts +38 -2
- package/src/releases/utils/sortReleases.ts +15 -10
- package/src/store/createActionBinder.test.ts +109 -90
- package/src/store/createActionBinder.ts +36 -28
- package/src/store/createSanityInstance.test.ts +15 -13
- package/src/store/createSanityInstance.ts +14 -2
- package/src/store/createStateSourceAction.test.ts +64 -2
- package/src/store/createStateSourceAction.ts +38 -43
- package/src/store/createStoreInstance.test.ts +4 -2
- package/src/store/fetcherStore.test-d.ts +121 -0
- package/src/store/fetcherStore.test.ts +299 -0
- package/src/store/fetcherStore.ts +801 -0
- package/src/telemetry/environment.test.ts +119 -0
- package/src/telemetry/environment.ts +92 -0
- package/src/telemetry/events.ts +42 -0
- package/src/telemetry/initTelemetry.test.ts +432 -0
- package/src/telemetry/initTelemetry.ts +218 -0
- package/src/telemetry/telemetryManager.test.ts +327 -0
- package/src/telemetry/telemetryManager.ts +199 -0
- package/src/users/reducers.test.ts +3 -1
- package/src/users/reducers.ts +5 -6
- package/src/users/types.ts +4 -4
- package/src/users/usersStore.test.ts +16 -12
- package/src/users/usersStore.ts +5 -1
- package/src/utils/buildQuery.test.ts +14 -0
- package/src/utils/buildQuery.ts +17 -0
- package/src/utils/createFetcherStore.test.ts +7 -5
- package/src/utils/createFetcherStore.ts +8 -5
- package/src/utils/getStagingApiHost.test.ts +21 -0
- package/src/utils/getStagingApiHost.ts +14 -0
- package/src/utils/ids.test.ts +1 -29
- package/src/utils/ids.ts +0 -10
- package/src/utils/includeShape.ts +36 -0
- package/src/utils/isImportError.test.ts +72 -0
- package/src/utils/isImportError.ts +34 -0
- package/src/utils/logger.test.ts +12 -0
- package/src/utils/logger.ts +8 -3
- package/src/utils/object.test.ts +95 -0
- package/src/utils/object.ts +142 -0
- package/src/utils/setCleanupTimeout.ts +37 -0
- package/src/document/processActions.ts +0 -707
- package/src/utils/defineIntent.test.ts +0 -477
- package/src/utils/defineIntent.ts +0 -244
package/package.json
CHANGED
|
@@ -1,96 +1,91 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/sdk",
|
|
3
|
-
"version": "3.0.0-rc.
|
|
3
|
+
"version": "3.0.0-rc.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Sanity SDK",
|
|
6
6
|
"keywords": [
|
|
7
|
-
"sanity",
|
|
8
|
-
"sdk",
|
|
9
|
-
"content operating system",
|
|
10
7
|
"cms",
|
|
8
|
+
"content",
|
|
9
|
+
"content operating system",
|
|
11
10
|
"headless",
|
|
12
11
|
"realtime",
|
|
13
|
-
"
|
|
12
|
+
"sanity",
|
|
13
|
+
"sdk"
|
|
14
14
|
],
|
|
15
15
|
"homepage": "https://github.com/sanity-io/sdk/tree/main/packages/core/README.md",
|
|
16
16
|
"bugs": {
|
|
17
17
|
"url": "https://github.com/sanity-io/sdk/issues"
|
|
18
18
|
},
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"author": "Sanity <developers@sanity.io>",
|
|
19
21
|
"repository": {
|
|
20
22
|
"type": "git",
|
|
21
23
|
"url": "git+https://github.com/sanity-io/sdk.git",
|
|
22
24
|
"directory": "packages/core"
|
|
23
25
|
},
|
|
24
|
-
"license": "MIT",
|
|
25
|
-
"author": "Sanity <developers@sanity.io>",
|
|
26
|
-
"sideEffects": false,
|
|
27
|
-
"type": "module",
|
|
28
|
-
"exports": {
|
|
29
|
-
".": {
|
|
30
|
-
"source": "./src/_exports/index.ts",
|
|
31
|
-
"import": "./dist/index.js",
|
|
32
|
-
"default": "./dist/index.js"
|
|
33
|
-
},
|
|
34
|
-
"./package.json": "./package.json"
|
|
35
|
-
},
|
|
36
|
-
"main": "./dist/index.js",
|
|
37
|
-
"module": "./dist/index.js",
|
|
38
|
-
"types": "./dist/index.d.ts",
|
|
39
26
|
"files": [
|
|
40
27
|
"dist",
|
|
41
28
|
"src"
|
|
42
29
|
],
|
|
43
|
-
"
|
|
44
|
-
"
|
|
30
|
+
"type": "module",
|
|
31
|
+
"sideEffects": false,
|
|
32
|
+
"main": "./dist/index.js",
|
|
33
|
+
"module": "./dist/index.js",
|
|
34
|
+
"types": "./dist/index.d.ts",
|
|
35
|
+
"exports": {
|
|
36
|
+
".": "./dist/index.js",
|
|
37
|
+
"./package.json": "./package.json",
|
|
38
|
+
"./_internal": "./dist/_exports/_internal.js",
|
|
39
|
+
"./agent": "./dist/_exports/agent.js",
|
|
40
|
+
"./comlink": "./dist/_exports/comlink.js"
|
|
41
|
+
},
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public"
|
|
44
|
+
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@sanity/bifur-client": "^0.
|
|
47
|
-
"@sanity/client": "^7.
|
|
48
|
-
"@sanity/comlink": "^
|
|
46
|
+
"@sanity/bifur-client": "^1.0.0",
|
|
47
|
+
"@sanity/client": "^7.26.2",
|
|
48
|
+
"@sanity/comlink": "^4.0.3",
|
|
49
49
|
"@sanity/diff-match-patch": "^3.2.0",
|
|
50
50
|
"@sanity/diff-patch": "^6.0.0",
|
|
51
51
|
"@sanity/id-utils": "^1.0.0",
|
|
52
|
-
"@sanity/image-url": "^2.
|
|
52
|
+
"@sanity/image-url": "^2.1.1",
|
|
53
53
|
"@sanity/json-match": "^1.0.5",
|
|
54
|
-
"@sanity/message-protocol": "^0.
|
|
55
|
-
"@sanity/mutate": "^0.
|
|
56
|
-
"@sanity/
|
|
57
|
-
"
|
|
58
|
-
"
|
|
54
|
+
"@sanity/message-protocol": "^0.24.0",
|
|
55
|
+
"@sanity/mutate": "^0.18.1",
|
|
56
|
+
"@sanity/telemetry": "^1.1.0",
|
|
57
|
+
"@sanity/types": "^6.9.1",
|
|
58
|
+
"groq": "3.88.1-typegen-experimental.0",
|
|
59
|
+
"groq-js": "^2.0.0",
|
|
59
60
|
"reselect": "^5.1.1",
|
|
60
61
|
"rxjs": "^7.8.2",
|
|
61
|
-
"zustand": "^5.0.
|
|
62
|
+
"zustand": "^5.0.13"
|
|
62
63
|
},
|
|
63
64
|
"devDependencies": {
|
|
64
65
|
"@sanity/browserslist-config": "^1.0.5",
|
|
65
|
-
"@sanity/pkg-utils": "^
|
|
66
|
-
"@
|
|
67
|
-
"@
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"vitest": "^3.2.4",
|
|
66
|
+
"@sanity/pkg-utils": "^12.1.0",
|
|
67
|
+
"@types/node": "^24.13.3",
|
|
68
|
+
"@vitest/coverage-v8": "^4.1.10",
|
|
69
|
+
"eslint": "^10.6.0",
|
|
70
|
+
"oxfmt": "^0.58.0",
|
|
71
|
+
"rolldown": "^1.2.3",
|
|
72
|
+
"typescript": "^6.0.3",
|
|
73
|
+
"vite": "^8.1.5",
|
|
74
|
+
"vitest": "^4.1.10",
|
|
75
75
|
"@repo/config-eslint": "0.0.0",
|
|
76
|
-
"@repo/config-test": "0.0.1",
|
|
77
76
|
"@repo/package.bundle": "3.82.0",
|
|
78
|
-
"@repo/
|
|
79
|
-
"@repo/package.config": "0.0.1"
|
|
80
|
-
|
|
81
|
-
"engines": {
|
|
82
|
-
"node": ">=20.19"
|
|
83
|
-
},
|
|
84
|
-
"publishConfig": {
|
|
85
|
-
"access": "public"
|
|
77
|
+
"@repo/config-test": "0.0.1",
|
|
78
|
+
"@repo/package.config": "0.0.1",
|
|
79
|
+
"@repo/tsconfig": "0.0.1"
|
|
86
80
|
},
|
|
81
|
+
"browserslist": "extends @sanity/browserslist-config",
|
|
87
82
|
"scripts": {
|
|
88
83
|
"build": "pkg build --strict --clean --check",
|
|
89
84
|
"build:bundle": "vite build --configLoader runner --config package.bundle.ts",
|
|
90
85
|
"clean": "rimraf dist",
|
|
91
86
|
"dev": "pkg watch",
|
|
92
87
|
"docs": "typedoc --json docs/typedoc.json --tsconfig ./tsconfig.dist.json",
|
|
93
|
-
"format": "
|
|
88
|
+
"format": "oxfmt",
|
|
94
89
|
"lint": "eslint .",
|
|
95
90
|
"test": "vitest run",
|
|
96
91
|
"test:coverage": "vitest run --coverage",
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export {isStudioConfig} from '../auth/authMode'
|
|
2
|
+
export {
|
|
3
|
+
type ApiErrorBody,
|
|
4
|
+
getClientErrorApiBody,
|
|
5
|
+
getClientErrorApiDescription,
|
|
6
|
+
getClientErrorApiType,
|
|
7
|
+
isProjectUserNotFoundClientError,
|
|
8
|
+
} from '../auth/utils'
|
|
9
|
+
export {getCommentsOptionsKey, parseCommentsOptionsKey} from '../comments/commentsStore' // only used for memoizing in React, not needed for actual functionality
|
|
10
|
+
export {PREVIEW_PROJECTION} from '../preview/previewConstants'
|
|
11
|
+
export {transformProjectionToPreview} from '../preview/previewProjectionUtils'
|
|
12
|
+
export {getQueryKey, parseQueryKey} from '../query/queryStore' // only used for memoizing in React, not needed for actual functionality
|
|
13
|
+
export {
|
|
14
|
+
type CacheTag,
|
|
15
|
+
type CacheWriter,
|
|
16
|
+
defineFetcher,
|
|
17
|
+
defineMutation,
|
|
18
|
+
type Fetcher,
|
|
19
|
+
type FetcherDefinition,
|
|
20
|
+
type FetcherSnapshot,
|
|
21
|
+
type MutationDefinition,
|
|
22
|
+
type MutationResult,
|
|
23
|
+
} from '../store/fetcherStore'
|
|
24
|
+
export {getTelemetryManager, initTelemetry, trackHookMounted} from '../telemetry/initTelemetry'
|
|
25
|
+
export {getUsersKey, parseUsersKey} from '../users/reducers' // only used for memoizing in React, not needed for actual functionality
|
|
26
|
+
export {createGroqSearchFilter} from '../utils/createGroqSearchFilter'
|
|
27
|
+
export {isDeepEqual, pickProperties} from '../utils/object'
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type {
|
|
2
|
+
AgentGenerateOptions,
|
|
3
|
+
AgentGenerateResult,
|
|
4
|
+
AgentPatchOptions,
|
|
5
|
+
AgentPatchResult,
|
|
6
|
+
AgentPromptOptions,
|
|
7
|
+
AgentPromptResult,
|
|
8
|
+
AgentTransformOptions,
|
|
9
|
+
AgentTransformResult,
|
|
10
|
+
AgentTranslateOptions,
|
|
11
|
+
AgentTranslateResult,
|
|
12
|
+
} from '../agent/agentActions'
|
|
13
|
+
export {
|
|
14
|
+
agentGenerate,
|
|
15
|
+
agentPatch,
|
|
16
|
+
agentPrompt,
|
|
17
|
+
agentTransform,
|
|
18
|
+
agentTranslate,
|
|
19
|
+
} from '../agent/agentActions'
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export {
|
|
2
|
+
type ComlinkControllerState,
|
|
3
|
+
destroyController,
|
|
4
|
+
getOrCreateChannel,
|
|
5
|
+
getOrCreateController,
|
|
6
|
+
releaseChannel,
|
|
7
|
+
} from '../comlink/controller/comlinkControllerStore'
|
|
8
|
+
export type {ComlinkNodeState} from '../comlink/node/comlinkNodeStore'
|
|
9
|
+
export {getOrCreateNode, releaseNode} from '../comlink/node/comlinkNodeStore'
|
|
10
|
+
export {getNodeState, type NodeState} from '../comlink/node/getNodeState'
|
|
11
|
+
export {
|
|
12
|
+
type FrameMessage,
|
|
13
|
+
type NewTokenResponseMessage,
|
|
14
|
+
type RequestNewTokenMessage,
|
|
15
|
+
type WindowMessage,
|
|
16
|
+
} from '../comlink/types'
|
package/src/_exports/index.ts
CHANGED
|
@@ -5,27 +5,30 @@ import {type SanityProject as _SanityProject} from '@sanity/client'
|
|
|
5
5
|
*/
|
|
6
6
|
export type SanityProject = _SanityProject
|
|
7
7
|
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
8
|
+
export {checkPermissions} from '../access/checkPermissions'
|
|
9
|
+
export {type AccessResourceType} from '../access/checkPermissions'
|
|
10
|
+
export {
|
|
11
|
+
application,
|
|
12
|
+
applications,
|
|
13
|
+
deleteApplication,
|
|
14
|
+
updateApplication,
|
|
15
|
+
} from '../applications/applications'
|
|
16
|
+
export {
|
|
17
|
+
type Application,
|
|
18
|
+
type ApplicationAccess,
|
|
19
|
+
type ApplicationBase,
|
|
20
|
+
type ApplicationDeployment,
|
|
21
|
+
type ApplicationInclude,
|
|
22
|
+
type ApplicationInterface,
|
|
23
|
+
type ApplicationsOptions,
|
|
24
|
+
type ApplicationsResponse,
|
|
25
|
+
type ApplicationStudioConfig,
|
|
26
|
+
type ApplicationVisibility,
|
|
27
|
+
type ApplicationWorkspace,
|
|
28
|
+
type DeleteApplicationInput,
|
|
29
|
+
type DeletedResult,
|
|
30
|
+
type UpdateApplicationInput,
|
|
31
|
+
} from '../applications/applications'
|
|
29
32
|
export {AuthStateType} from '../auth/authStateType'
|
|
30
33
|
export {
|
|
31
34
|
type AuthState,
|
|
@@ -45,36 +48,44 @@ export {
|
|
|
45
48
|
export {observeOrganizationVerificationState} from '../auth/getOrganizationVerificationState'
|
|
46
49
|
export {handleAuthCallback} from '../auth/handleAuthCallback'
|
|
47
50
|
export {logout} from '../auth/logout'
|
|
48
|
-
export {
|
|
49
|
-
type ApiErrorBody,
|
|
50
|
-
getClientErrorApiBody,
|
|
51
|
-
getClientErrorApiDescription,
|
|
52
|
-
getClientErrorApiType,
|
|
53
|
-
isProjectUserNotFoundClientError,
|
|
54
|
-
} from '../auth/utils'
|
|
55
51
|
export type {ClientStoreState as ClientState} from '../client/clientStore'
|
|
56
52
|
export {type ClientOptions, getClient, getClientState} from '../client/clientStore'
|
|
57
53
|
export {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
type
|
|
71
|
-
|
|
72
|
-
|
|
54
|
+
createComment,
|
|
55
|
+
type CreateCommentOptions,
|
|
56
|
+
removeComment,
|
|
57
|
+
type RemoveCommentOptions,
|
|
58
|
+
replyToComment,
|
|
59
|
+
type ReplyToCommentOptions,
|
|
60
|
+
setCommentStatus,
|
|
61
|
+
type SetCommentStatusOptions,
|
|
62
|
+
updateComment,
|
|
63
|
+
type UpdateCommentOptions,
|
|
64
|
+
} from '../comments/commentActions'
|
|
65
|
+
export {
|
|
66
|
+
type CommentsOptions,
|
|
67
|
+
getCommentsState,
|
|
68
|
+
getCommentThreadsState,
|
|
69
|
+
resolveComments,
|
|
70
|
+
type ResolveCommentsOptions,
|
|
71
|
+
resolveCommentThreads,
|
|
72
|
+
} from '../comments/commentsStore'
|
|
73
|
+
export {
|
|
74
|
+
type Comment,
|
|
75
|
+
type CommentLocalState,
|
|
76
|
+
type CommentMessage,
|
|
77
|
+
type CommentReaction,
|
|
78
|
+
type CommentStatus,
|
|
79
|
+
type CommentTextSelection,
|
|
80
|
+
type CommentTextSelectionItem,
|
|
81
|
+
type CommentThread,
|
|
82
|
+
} from '../comments/types'
|
|
73
83
|
export {type AuthConfig, type AuthProvider} from '../config/authConfig'
|
|
74
84
|
export {
|
|
85
|
+
createDatasetHandle,
|
|
75
86
|
createDocumentHandle,
|
|
76
87
|
createDocumentTypeHandle,
|
|
77
|
-
|
|
88
|
+
createProjectHandle,
|
|
78
89
|
} from '../config/handles'
|
|
79
90
|
export {
|
|
80
91
|
configureLogging,
|
|
@@ -87,8 +98,8 @@ export {
|
|
|
87
98
|
} from '../config/loggingConfig'
|
|
88
99
|
export {
|
|
89
100
|
type CanvasResource,
|
|
101
|
+
type DatasetHandle,
|
|
90
102
|
type DatasetResource,
|
|
91
|
-
DEFAULT_RESOURCE_NAME,
|
|
92
103
|
type DocumentHandle,
|
|
93
104
|
type DocumentResource,
|
|
94
105
|
type DocumentTypeHandle,
|
|
@@ -97,27 +108,47 @@ export {
|
|
|
97
108
|
isMediaLibraryResource,
|
|
98
109
|
type MediaLibraryResource,
|
|
99
110
|
type PerspectiveHandle,
|
|
111
|
+
type ProjectHandle,
|
|
112
|
+
type ReleaseHandle,
|
|
100
113
|
type ReleasePerspective,
|
|
101
|
-
type ResourceHandle,
|
|
102
114
|
type SanityConfig,
|
|
103
115
|
type StudioConfig,
|
|
104
116
|
type TokenSource,
|
|
105
117
|
} from '../config/sanityConfig'
|
|
106
118
|
export {getDatasetsState, resolveDatasets} from '../datasets/datasets'
|
|
107
119
|
export {
|
|
120
|
+
type Action,
|
|
121
|
+
archiveRelease,
|
|
122
|
+
type ArchiveReleaseAction,
|
|
108
123
|
createDocument,
|
|
109
124
|
type CreateDocumentAction,
|
|
125
|
+
createRelease,
|
|
126
|
+
type CreateReleaseAction,
|
|
110
127
|
deleteDocument,
|
|
111
128
|
type DeleteDocumentAction,
|
|
129
|
+
deleteRelease,
|
|
130
|
+
type DeleteReleaseAction,
|
|
112
131
|
discardDocument,
|
|
113
132
|
type DiscardDocumentAction,
|
|
114
133
|
type DocumentAction,
|
|
115
134
|
editDocument,
|
|
116
135
|
type EditDocumentAction,
|
|
136
|
+
type EditDocumentOptions,
|
|
137
|
+
editRelease,
|
|
138
|
+
type EditReleaseAction,
|
|
117
139
|
publishDocument,
|
|
118
140
|
type PublishDocumentAction,
|
|
141
|
+
publishRelease,
|
|
142
|
+
type PublishReleaseAction,
|
|
143
|
+
type ReleaseAction,
|
|
144
|
+
scheduleRelease,
|
|
145
|
+
type ScheduleReleaseAction,
|
|
146
|
+
unarchiveRelease,
|
|
147
|
+
type UnarchiveReleaseAction,
|
|
119
148
|
unpublishDocument,
|
|
120
149
|
type UnpublishDocumentAction,
|
|
150
|
+
unscheduleRelease,
|
|
151
|
+
type UnscheduleReleaseAction,
|
|
121
152
|
} from '../document/actions'
|
|
122
153
|
export {
|
|
123
154
|
type ActionsResult,
|
|
@@ -141,44 +172,74 @@ export {
|
|
|
141
172
|
type DocumentEditedEvent,
|
|
142
173
|
type DocumentEvent,
|
|
143
174
|
type DocumentPublishedEvent,
|
|
175
|
+
type DocumentRemotePatchesEvent,
|
|
176
|
+
type DocumentTransactionSubmissionResult,
|
|
144
177
|
type DocumentUnpublishedEvent,
|
|
145
178
|
type TransactionAcceptedEvent,
|
|
146
179
|
type TransactionRevertedEvent,
|
|
147
180
|
} from '../document/events'
|
|
181
|
+
export {type JsonMatch} from '../document/patchOperations'
|
|
148
182
|
export {type DocumentPermissionsResult, type PermissionDeniedReason} from '../document/permissions'
|
|
183
|
+
export {getReleaseDocumentId} from '../document/processActions/releaseUtil'
|
|
149
184
|
export type {FavoriteStatusResponse} from '../favorites/favorites'
|
|
150
185
|
export {getFavoritesState, resolveFavoritesState} from '../favorites/favorites'
|
|
151
|
-
export {
|
|
186
|
+
export {installation, installations} from '../installations/installations'
|
|
187
|
+
export {
|
|
188
|
+
type Installation,
|
|
189
|
+
type InstallationAccess,
|
|
190
|
+
type InstallationActiveConfig,
|
|
191
|
+
type InstallationBase,
|
|
192
|
+
type InstallationInclude,
|
|
193
|
+
type InstallationInterface,
|
|
194
|
+
type InstallationsOptions,
|
|
195
|
+
type InstallationsResponse,
|
|
196
|
+
} from '../installations/installations'
|
|
197
|
+
export {organization} from '../organization/organization'
|
|
198
|
+
export {
|
|
199
|
+
type Organization,
|
|
200
|
+
type OrganizationBase,
|
|
201
|
+
type OrganizationMember,
|
|
202
|
+
type OrganizationOptions,
|
|
203
|
+
} from '../organization/organization'
|
|
204
|
+
export {organizations} from '../organizations/organizations'
|
|
205
|
+
export {type Organizations, type OrganizationsOptions} from '../organizations/organizations'
|
|
206
|
+
export {getDocumentPresence, getPresence, reportPresence} from '../presence/presenceStore'
|
|
152
207
|
export type {
|
|
153
208
|
DisconnectEvent,
|
|
209
|
+
DocumentPresence,
|
|
210
|
+
DocumentPresenceOptions,
|
|
154
211
|
PresenceLocation,
|
|
212
|
+
PresencePerspectiveOptions,
|
|
213
|
+
PresenceSelection,
|
|
214
|
+
PresenceSelectionPoint,
|
|
215
|
+
ReportPresenceOptions,
|
|
155
216
|
RollCallEvent,
|
|
156
217
|
StateEvent,
|
|
157
218
|
TransportEvent,
|
|
158
219
|
UserPresence,
|
|
159
220
|
} from '../presence/types'
|
|
160
|
-
export {
|
|
161
|
-
export {transformProjectionToPreview} from '../preview/previewProjectionUtils'
|
|
162
|
-
export type {PreviewMedia, PreviewQueryResult, PreviewValue, ValuePending} from '../preview/types'
|
|
221
|
+
export type {PreviewMedia, PreviewQueryResult, PreviewValue} from '../preview/types'
|
|
163
222
|
export {type OrgVerificationResult} from '../project/organizationVerification'
|
|
164
|
-
export {
|
|
223
|
+
export {project} from '../project/project'
|
|
224
|
+
export {
|
|
225
|
+
type Project,
|
|
226
|
+
type ProjectBase,
|
|
227
|
+
type ProjectMember,
|
|
228
|
+
type ProjectMemberRole,
|
|
229
|
+
type ProjectMetadata,
|
|
230
|
+
type ProjectOptions,
|
|
231
|
+
} from '../project/project'
|
|
165
232
|
export {getProjectionState} from '../projection/getProjectionState'
|
|
166
233
|
export {resolveProjection} from '../projection/resolveProjection'
|
|
167
234
|
export {type ProjectionValuePending} from '../projection/types'
|
|
168
|
-
export {
|
|
169
|
-
export {
|
|
170
|
-
|
|
171
|
-
getQueryState,
|
|
172
|
-
parseQueryKey,
|
|
173
|
-
type QueryOptions,
|
|
174
|
-
resolveQuery,
|
|
175
|
-
} from '../query/queryStore'
|
|
235
|
+
export {projects} from '../projects/projects'
|
|
236
|
+
export {type ProjectsOptions} from '../projects/projects'
|
|
237
|
+
export {getQueryState, type QueryOptions, resolveQuery} from '../query/queryStore'
|
|
176
238
|
export {getPerspectiveState} from '../releases/getPerspectiveState'
|
|
177
|
-
export type {
|
|
178
|
-
export {getActiveReleasesState} from '../releases/releasesStore'
|
|
239
|
+
export type {ReleaseState} from '../releases/releasesStore'
|
|
240
|
+
export {getActiveReleasesState, getAllReleasesState} from '../releases/releasesStore'
|
|
179
241
|
export {createSanityInstance, type SanityInstance} from '../store/createSanityInstance'
|
|
180
242
|
export {type Selector, type StateSource} from '../store/createStateSourceAction'
|
|
181
|
-
export {getUsersKey, parseUsersKey} from '../users/reducers'
|
|
182
243
|
export {
|
|
183
244
|
type GetUserOptions,
|
|
184
245
|
type GetUsersOptions,
|
|
@@ -199,10 +260,10 @@ export {
|
|
|
199
260
|
resolveUsers,
|
|
200
261
|
} from '../users/usersStore'
|
|
201
262
|
export {type FetcherStore, type FetcherStoreState} from '../utils/createFetcherStore'
|
|
202
|
-
export {createGroqSearchFilter} from '../utils/createGroqSearchFilter'
|
|
203
|
-
export {defineIntent, type Intent, type IntentFilter} from '../utils/defineIntent'
|
|
204
263
|
export {getCorsErrorProjectId} from '../utils/getCorsErrorProjectId'
|
|
264
|
+
export {isImportError} from '../utils/isImportError'
|
|
205
265
|
export {CORE_SDK_VERSION} from '../version'
|
|
266
|
+
export type {ReleaseDocument} from '@sanity/client'
|
|
206
267
|
export {
|
|
207
268
|
getIndexForKey,
|
|
208
269
|
getPathDepth,
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import {type SanityClient} from '@sanity/client'
|
|
2
|
+
import {of} from 'rxjs'
|
|
3
|
+
import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest'
|
|
4
|
+
|
|
5
|
+
import {getClientState} from '../client/clientStore'
|
|
6
|
+
import {createSanityInstance, type SanityInstance} from '../store/createSanityInstance'
|
|
7
|
+
import {type StateSource} from '../store/createStateSourceAction'
|
|
8
|
+
import {checkPermissions} from './checkPermissions'
|
|
9
|
+
|
|
10
|
+
vi.mock('../client/clientStore')
|
|
11
|
+
|
|
12
|
+
describe('checkPermissions', () => {
|
|
13
|
+
let instance: SanityInstance
|
|
14
|
+
const request = vi.fn()
|
|
15
|
+
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
instance = createSanityInstance({projectId: 'p', dataset: 'd'})
|
|
18
|
+
request.mockReset()
|
|
19
|
+
vi.mocked(getClientState).mockReturnValue({
|
|
20
|
+
observable: of({observable: {request}} as unknown as SanityClient),
|
|
21
|
+
} as StateSource<SanityClient>)
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
afterEach(() => {
|
|
25
|
+
instance.dispose()
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
it('checks permissions on the global client and unwraps the data envelope', async () => {
|
|
29
|
+
request.mockReturnValue(of({data: {'sanity.project.read': true}}))
|
|
30
|
+
|
|
31
|
+
const result = await checkPermissions.resolveState(instance, 'project', 'p1', [
|
|
32
|
+
'sanity.project.read',
|
|
33
|
+
])
|
|
34
|
+
|
|
35
|
+
expect(result).toEqual({'sanity.project.read': true})
|
|
36
|
+
expect(getClientState).toHaveBeenCalledWith(instance, {
|
|
37
|
+
apiVersion: 'v2025-07-11',
|
|
38
|
+
scope: 'global',
|
|
39
|
+
})
|
|
40
|
+
expect(request).toHaveBeenCalledWith({
|
|
41
|
+
uri: '/access/project/p1/user-permissions/me/check',
|
|
42
|
+
query: {permissions: ['sanity.project.read']},
|
|
43
|
+
tag: 'access.check',
|
|
44
|
+
})
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
it('does not create distinct cache entries for different permission orderings', async () => {
|
|
48
|
+
request.mockReturnValue(of({data: {a: true, b: false}}))
|
|
49
|
+
|
|
50
|
+
await checkPermissions.resolveState(instance, 'organization', 'org1', ['b', 'a'])
|
|
51
|
+
await checkPermissions.resolveState(instance, 'organization', 'org1', ['a', 'b'])
|
|
52
|
+
|
|
53
|
+
expect(request).toHaveBeenCalledTimes(1)
|
|
54
|
+
})
|
|
55
|
+
})
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import {map, switchMap} from 'rxjs'
|
|
2
|
+
|
|
3
|
+
import {getClientState} from '../client/clientStore'
|
|
4
|
+
import {defineFetcher} from '../store/fetcherStore'
|
|
5
|
+
|
|
6
|
+
const API_VERSION = 'v2025-07-11'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The resource types the Access API can scope a permission check to.
|
|
10
|
+
*
|
|
11
|
+
* @see https://www.sanity.io/docs/http-reference/access-api
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
export type AccessResourceType =
|
|
15
|
+
| 'organization'
|
|
16
|
+
| 'project'
|
|
17
|
+
| 'media-library'
|
|
18
|
+
| 'canvas'
|
|
19
|
+
| 'dashboard'
|
|
20
|
+
| 'view'
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Fetcher checking whether the current user holds the given permissions on a
|
|
24
|
+
* resource (`GET /access/:resourceType/:resourceId/user-permissions/me/check`),
|
|
25
|
+
* on the shared fetcher cache. Resolves to a map of each requested permission
|
|
26
|
+
* to whether the user has it. The key sorts the permission list, so permission
|
|
27
|
+
* order doesn't create distinct cache entries.
|
|
28
|
+
*
|
|
29
|
+
* @see https://www.sanity.io/docs/http-reference/access-api
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
export const checkPermissions = defineFetcher<
|
|
33
|
+
[resourceType: AccessResourceType, resourceId: string, permissions: string[]],
|
|
34
|
+
Record<string, boolean>
|
|
35
|
+
>({
|
|
36
|
+
name: 'checkPermissions',
|
|
37
|
+
getKey: (_instance, resourceType, resourceId, permissions) =>
|
|
38
|
+
`${resourceType}:${resourceId}:${[...permissions].sort().join(',')}`,
|
|
39
|
+
fetch: (instance) => (resourceType, resourceId, permissions) =>
|
|
40
|
+
getClientState(instance, {apiVersion: API_VERSION, scope: 'global'}).observable.pipe(
|
|
41
|
+
switchMap((client) =>
|
|
42
|
+
client.observable
|
|
43
|
+
.request<{data: Record<string, boolean>}>({
|
|
44
|
+
uri: `/access/${resourceType}/${resourceId}/user-permissions/me/check`,
|
|
45
|
+
query: {permissions},
|
|
46
|
+
tag: 'access.check',
|
|
47
|
+
})
|
|
48
|
+
.pipe(map((response) => response.data)),
|
|
49
|
+
),
|
|
50
|
+
),
|
|
51
|
+
tags: (_data, resourceType, resourceId) => [
|
|
52
|
+
{type: 'access', id: `${resourceType}:${resourceId}`},
|
|
53
|
+
],
|
|
54
|
+
})
|