@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.
Files changed (241) hide show
  1. package/README.md +12 -0
  2. package/dist/_exports/_internal.d.ts +163 -0
  3. package/dist/_exports/_internal.d.ts.map +1 -0
  4. package/dist/_exports/_internal.js +332 -0
  5. package/dist/_exports/_internal.js.map +1 -0
  6. package/dist/_exports/agent.d.ts +65 -0
  7. package/dist/_exports/agent.d.ts.map +1 -0
  8. package/dist/_exports/agent.js +71 -0
  9. package/dist/_exports/agent.js.map +1 -0
  10. package/dist/_exports/comlink.d.ts +118 -0
  11. package/dist/_exports/comlink.d.ts.map +1 -0
  12. package/dist/_exports/comlink.js +69 -0
  13. package/dist/_exports/comlink.js.map +1 -0
  14. package/dist/authStore-CtE9bLHW.js +754 -0
  15. package/dist/authStore-CtE9bLHW.js.map +1 -0
  16. package/dist/authStore-DKFX8fn7.d.ts +3179 -0
  17. package/dist/authStore-DKFX8fn7.d.ts.map +1 -0
  18. package/dist/clientStore-BtE2-q2i.js +90 -0
  19. package/dist/clientStore-BtE2-q2i.js.map +1 -0
  20. package/dist/createSanityInstance-DUI1bGIg.d.ts +278 -0
  21. package/dist/createSanityInstance-DUI1bGIg.d.ts.map +1 -0
  22. package/dist/createStateSourceAction-BOKtqFNm.js +300 -0
  23. package/dist/createStateSourceAction-BOKtqFNm.js.map +1 -0
  24. package/dist/getEnv-D5RGkQLu.js +8 -0
  25. package/dist/getEnv-D5RGkQLu.js.map +1 -0
  26. package/dist/getNodeState-CR3__B2D.js +67 -0
  27. package/dist/getNodeState-CR3__B2D.js.map +1 -0
  28. package/dist/index.d.ts +3 -2332
  29. package/dist/index.js +4171 -4332
  30. package/dist/index.js.map +1 -1
  31. package/dist/logger-DAtJb5RQ.js +173 -0
  32. package/dist/logger-DAtJb5RQ.js.map +1 -0
  33. package/dist/object-CxXlSVg7.js +83 -0
  34. package/dist/object-CxXlSVg7.js.map +1 -0
  35. package/dist/queryStore-DPf9sN3V.js +1346 -0
  36. package/dist/queryStore-DPf9sN3V.js.map +1 -0
  37. package/dist/rolldown-runtime-vyAXikos.js +9 -0
  38. package/dist/setCleanupTimeout-BiM6q1KF.js +31 -0
  39. package/dist/setCleanupTimeout-BiM6q1KF.js.map +1 -0
  40. package/dist/telemetryManager-Dq_qCkeI.js +127 -0
  41. package/dist/telemetryManager-Dq_qCkeI.js.map +1 -0
  42. package/dist/version-BChjsi4u.js +9 -0
  43. package/dist/version-BChjsi4u.js.map +1 -0
  44. package/package.json +47 -52
  45. package/src/_exports/_internal.ts +27 -0
  46. package/src/_exports/agent.ts +19 -0
  47. package/src/_exports/comlink.ts +16 -0
  48. package/src/_exports/index.ts +125 -64
  49. package/src/access/checkPermissions.test.ts +55 -0
  50. package/src/access/checkPermissions.ts +54 -0
  51. package/src/agent/agentActions.test.ts +16 -60
  52. package/src/agent/agentActions.ts +25 -38
  53. package/src/applications/applications.test-d.ts +88 -0
  54. package/src/applications/applications.test.ts +130 -0
  55. package/src/applications/applications.ts +367 -0
  56. package/src/auth/authLogger.ts +30 -0
  57. package/src/auth/authStore.test.ts +194 -13
  58. package/src/auth/authStore.ts +58 -26
  59. package/src/auth/getOrganizationVerificationState.test.ts +18 -17
  60. package/src/auth/getOrganizationVerificationState.ts +4 -4
  61. package/src/auth/handleAuthCallback.test.ts +35 -1
  62. package/src/auth/handleAuthCallback.ts +25 -6
  63. package/src/auth/logout.test.ts +75 -2
  64. package/src/auth/logout.ts +23 -4
  65. package/src/auth/refreshStampedToken.test.ts +219 -469
  66. package/src/auth/refreshStampedToken.ts +79 -195
  67. package/src/auth/studioAuth.ts +1 -1
  68. package/src/auth/studioModeAuth.ts +2 -1
  69. package/src/auth/subscribeToStateAndFetchCurrentUser.test.ts +146 -13
  70. package/src/auth/subscribeToStateAndFetchCurrentUser.ts +37 -6
  71. package/src/auth/subscribeToStorageEventsAndSetToken.test.ts +2 -0
  72. package/src/client/clientStore.test.ts +62 -37
  73. package/src/client/clientStore.ts +45 -75
  74. package/src/client/liveEvents.test.ts +151 -0
  75. package/src/client/liveEvents.ts +107 -0
  76. package/src/comlink/controller/actions/destroyController.test.ts +4 -1
  77. package/src/comlink/controller/actions/getOrCreateChannel.test.ts +4 -1
  78. package/src/comlink/controller/actions/getOrCreateChannel.ts +2 -2
  79. package/src/comlink/controller/actions/getOrCreateController.test.ts +4 -1
  80. package/src/comlink/controller/actions/releaseChannel.test.ts +1 -1
  81. package/src/comlink/controller/comlinkControllerStore.test.ts +4 -1
  82. package/src/comlink/node/actions/getOrCreateNode.test.ts +9 -3
  83. package/src/comlink/node/actions/getOrCreateNode.ts +2 -2
  84. package/src/comlink/node/actions/releaseNode.test.ts +7 -4
  85. package/src/comlink/node/comlinkNodeStore.test.ts +2 -2
  86. package/src/comlink/node/getNodeState.test.ts +1 -1
  87. package/src/comlink/node/getNodeState.ts +2 -1
  88. package/src/comments/addonDatasetStore.test.ts +215 -0
  89. package/src/comments/addonDatasetStore.ts +249 -0
  90. package/src/comments/buildCommentThreads.test.ts +83 -0
  91. package/src/comments/buildCommentThreads.ts +54 -0
  92. package/src/comments/commentActions.test.ts +540 -0
  93. package/src/comments/commentActions.ts +555 -0
  94. package/src/comments/commentFieldPath.test.ts +40 -0
  95. package/src/comments/commentFieldPath.ts +44 -0
  96. package/src/comments/commentsConstants.ts +80 -0
  97. package/src/comments/commentsStore.test.ts +419 -0
  98. package/src/comments/commentsStore.ts +483 -0
  99. package/src/comments/normalizeComment.test.ts +116 -0
  100. package/src/comments/normalizeComment.ts +45 -0
  101. package/src/comments/observeComments.test.ts +193 -0
  102. package/src/comments/observeComments.ts +113 -0
  103. package/src/comments/reducers.test.ts +277 -0
  104. package/src/comments/reducers.ts +316 -0
  105. package/src/comments/types.ts +249 -0
  106. package/src/comments/weakenReferences.test.ts +47 -0
  107. package/src/comments/weakenReferences.ts +29 -0
  108. package/src/config/__tests__/handles.test.ts +18 -12
  109. package/src/config/handles.ts +25 -7
  110. package/src/config/sanityConfig.ts +40 -82
  111. package/src/datasets/datasets.test.ts +2 -2
  112. package/src/datasets/datasets.ts +10 -4
  113. package/src/document/actions.test.ts +115 -33
  114. package/src/document/actions.ts +212 -15
  115. package/src/document/applyDocumentActions.test.ts +35 -13
  116. package/src/document/applyDocumentActions.ts +30 -9
  117. package/src/document/documentConstants.ts +15 -0
  118. package/src/document/documentStore.concurrency.test.ts +1306 -0
  119. package/src/document/documentStore.test.ts +753 -273
  120. package/src/document/documentStore.ts +197 -75
  121. package/src/document/events.test.ts +57 -2
  122. package/src/document/events.ts +82 -26
  123. package/src/document/listen.test.ts +56 -0
  124. package/src/document/listen.ts +74 -21
  125. package/src/document/listenerEventOperators.test.ts +311 -0
  126. package/src/document/listenerEventOperators.ts +217 -0
  127. package/src/document/patchOperations.test.ts +76 -2
  128. package/src/document/patchOperations.ts +60 -1
  129. package/src/document/permissions.test.ts +107 -60
  130. package/src/document/permissions.ts +44 -19
  131. package/src/document/processActions/create.ts +138 -0
  132. package/src/document/processActions/delete.ts +100 -0
  133. package/src/document/processActions/discard.ts +63 -0
  134. package/src/document/processActions/edit.ts +154 -0
  135. package/src/document/processActions/processActions.ts +218 -0
  136. package/src/document/processActions/publish.ts +120 -0
  137. package/src/document/processActions/releaseArchive.ts +77 -0
  138. package/src/document/processActions/releaseCreate.ts +59 -0
  139. package/src/document/processActions/releaseDelete.ts +65 -0
  140. package/src/document/processActions/releaseEdit.ts +37 -0
  141. package/src/document/processActions/releasePublish.ts +45 -0
  142. package/src/document/processActions/releaseSchedule.ts +87 -0
  143. package/src/document/processActions/releaseUtil.ts +31 -0
  144. package/src/document/processActions/shared.ts +308 -0
  145. package/src/document/processActions/unpublish.ts +85 -0
  146. package/src/document/processActions.test.ts +1129 -121
  147. package/src/document/reducers.test.ts +772 -64
  148. package/src/document/reducers.ts +205 -51
  149. package/src/document/resourceRules.test.ts +178 -0
  150. package/src/document/resourceRules.ts +117 -0
  151. package/src/document/sharedListener.test.ts +16 -14
  152. package/src/document/sharedListener.ts +24 -8
  153. package/src/document/util.test.ts +46 -0
  154. package/src/document/util.ts +50 -0
  155. package/src/favorites/favorites.test.ts +5 -6
  156. package/src/installations/installations.test-d.ts +73 -0
  157. package/src/installations/installations.test.ts +62 -0
  158. package/src/installations/installations.ts +206 -0
  159. package/src/organization/organization.test-d.ts +36 -0
  160. package/src/organization/organization.test.ts +138 -0
  161. package/src/organization/organization.ts +138 -0
  162. package/src/organizations/organizations.test-d.ts +56 -0
  163. package/src/organizations/organizations.test.ts +150 -0
  164. package/src/organizations/organizations.ts +107 -0
  165. package/src/presence/bifurTransport.test.ts +201 -9
  166. package/src/presence/bifurTransport.ts +98 -14
  167. package/src/presence/paths.test.ts +70 -0
  168. package/src/presence/paths.ts +41 -0
  169. package/src/presence/presenceStore.test.ts +915 -24
  170. package/src/presence/presenceStore.ts +576 -104
  171. package/src/presence/types.ts +175 -3
  172. package/src/preview/previewProjectionUtils.test.ts +9 -22
  173. package/src/preview/previewProjectionUtils.ts +7 -3
  174. package/src/preview/types.ts +0 -15
  175. package/src/project/project.test-d.ts +37 -0
  176. package/src/project/project.test.ts +157 -12
  177. package/src/project/project.ts +138 -25
  178. package/src/projection/getProjectionState.test.ts +18 -20
  179. package/src/projection/getProjectionState.ts +23 -3
  180. package/src/projection/projectionQuery.ts +5 -5
  181. package/src/projection/projectionStore.test.ts +1 -9
  182. package/src/projection/resolveProjection.test.ts +1 -2
  183. package/src/projection/resolveProjection.ts +16 -0
  184. package/src/projection/subscribeToStateAndFetchBatches.test.ts +1 -1
  185. package/src/projection/subscribeToStateAndFetchBatches.ts +32 -23
  186. package/src/projects/projects.test-d.ts +32 -0
  187. package/src/projects/projects.test.ts +108 -42
  188. package/src/projects/projects.ts +63 -27
  189. package/src/query/queryStore.test.ts +259 -123
  190. package/src/query/queryStore.ts +85 -69
  191. package/src/query/reducers.test.ts +0 -42
  192. package/src/query/reducers.ts +2 -18
  193. package/src/releases/getPerspectiveState.test.ts +17 -23
  194. package/src/releases/getPerspectiveState.ts +8 -20
  195. package/src/releases/observeReleases.test.ts +127 -0
  196. package/src/releases/observeReleases.ts +102 -0
  197. package/src/releases/releasesStore.test.ts +100 -53
  198. package/src/releases/releasesStore.ts +69 -44
  199. package/src/releases/utils/sortReleases.test.ts +38 -2
  200. package/src/releases/utils/sortReleases.ts +15 -10
  201. package/src/store/createActionBinder.test.ts +109 -90
  202. package/src/store/createActionBinder.ts +36 -28
  203. package/src/store/createSanityInstance.test.ts +15 -13
  204. package/src/store/createSanityInstance.ts +14 -2
  205. package/src/store/createStateSourceAction.test.ts +64 -2
  206. package/src/store/createStateSourceAction.ts +38 -43
  207. package/src/store/createStoreInstance.test.ts +4 -2
  208. package/src/store/fetcherStore.test-d.ts +121 -0
  209. package/src/store/fetcherStore.test.ts +299 -0
  210. package/src/store/fetcherStore.ts +801 -0
  211. package/src/telemetry/environment.test.ts +119 -0
  212. package/src/telemetry/environment.ts +92 -0
  213. package/src/telemetry/events.ts +42 -0
  214. package/src/telemetry/initTelemetry.test.ts +432 -0
  215. package/src/telemetry/initTelemetry.ts +218 -0
  216. package/src/telemetry/telemetryManager.test.ts +327 -0
  217. package/src/telemetry/telemetryManager.ts +199 -0
  218. package/src/users/reducers.test.ts +3 -1
  219. package/src/users/reducers.ts +5 -6
  220. package/src/users/types.ts +4 -4
  221. package/src/users/usersStore.test.ts +16 -12
  222. package/src/users/usersStore.ts +5 -1
  223. package/src/utils/buildQuery.test.ts +14 -0
  224. package/src/utils/buildQuery.ts +17 -0
  225. package/src/utils/createFetcherStore.test.ts +7 -5
  226. package/src/utils/createFetcherStore.ts +8 -5
  227. package/src/utils/getStagingApiHost.test.ts +21 -0
  228. package/src/utils/getStagingApiHost.ts +14 -0
  229. package/src/utils/ids.test.ts +1 -29
  230. package/src/utils/ids.ts +0 -10
  231. package/src/utils/includeShape.ts +36 -0
  232. package/src/utils/isImportError.test.ts +72 -0
  233. package/src/utils/isImportError.ts +34 -0
  234. package/src/utils/logger.test.ts +12 -0
  235. package/src/utils/logger.ts +8 -3
  236. package/src/utils/object.test.ts +95 -0
  237. package/src/utils/object.ts +142 -0
  238. package/src/utils/setCleanupTimeout.ts +37 -0
  239. package/src/document/processActions.ts +0 -707
  240. package/src/utils/defineIntent.test.ts +0 -477
  241. 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.0",
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
- "content"
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
- "browserslist": "extends @sanity/browserslist-config",
44
- "prettier": "@sanity/prettier-config",
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.4.1",
47
- "@sanity/client": "^7.14.1",
48
- "@sanity/comlink": "^3.0.4",
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.0.3",
52
+ "@sanity/image-url": "^2.1.1",
53
53
  "@sanity/json-match": "^1.0.5",
54
- "@sanity/message-protocol": "^0.18.0",
55
- "@sanity/mutate": "^0.12.4",
56
- "@sanity/types": "^5.2.0",
57
- "groq-js": "^1.19.0",
58
- "lodash-es": "^4.17.21",
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.4"
62
+ "zustand": "^5.0.13"
62
63
  },
63
64
  "devDependencies": {
64
65
  "@sanity/browserslist-config": "^1.0.5",
65
- "@sanity/pkg-utils": "^8.1.29",
66
- "@sanity/prettier-config": "^1.0.6",
67
- "@types/lodash-es": "^4.17.12",
68
- "@vitest/coverage-v8": "3.2.4",
69
- "eslint": "^9.22.0",
70
- "prettier": "^3.7.3",
71
- "rollup-plugin-visualizer": "^5.14.0",
72
- "typescript": "^5.8.3",
73
- "vite": "^6.3.4",
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/tsconfig": "0.0.1",
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": "prettier --write --cache --ignore-unknown .",
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'
@@ -5,27 +5,30 @@ import {type SanityProject as _SanityProject} from '@sanity/client'
5
5
  */
6
6
  export type SanityProject = _SanityProject
7
7
 
8
- export type {
9
- AgentGenerateOptions,
10
- AgentGenerateResult,
11
- AgentPatchOptions,
12
- AgentPatchResult,
13
- AgentPromptOptions,
14
- AgentPromptResult,
15
- AgentResourceOptions,
16
- AgentTransformOptions,
17
- AgentTransformResult,
18
- AgentTranslateOptions,
19
- AgentTranslateResult,
20
- } from '../agent/agentActions'
21
- export {
22
- agentGenerate,
23
- agentPatch,
24
- agentPrompt,
25
- agentTransform,
26
- agentTranslate,
27
- } from '../agent/agentActions'
28
- export {isStudioConfig} from '../auth/authMode'
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
- type ComlinkControllerState,
59
- destroyController,
60
- getOrCreateChannel,
61
- getOrCreateController,
62
- releaseChannel,
63
- } from '../comlink/controller/comlinkControllerStore'
64
- export type {ComlinkNodeState} from '../comlink/node/comlinkNodeStore'
65
- export {getOrCreateNode, releaseNode} from '../comlink/node/comlinkNodeStore'
66
- export {getNodeState, type NodeState} from '../comlink/node/getNodeState'
67
- export {
68
- type FrameMessage,
69
- type NewTokenResponseMessage,
70
- type RequestNewTokenMessage,
71
- type WindowMessage,
72
- } from '../comlink/types'
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
- createResourceHandle,
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 {getPresence} from '../presence/presenceStore'
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 {PREVIEW_PROJECTION} from '../preview/previewConstants'
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 {getProjectState, type ProjectHandle, resolveProject} from '../project/project'
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 {getProjectsState, resolveProjects} from '../projects/projects'
169
- export {
170
- getQueryKey,
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 {ReleaseDocument} from '../releases/releasesStore'
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
+ })