@sanity/sdk 3.0.0-rc.1 → 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 (120) hide show
  1. package/README.md +12 -0
  2. package/dist/_exports/_internal.d.ts +71 -3
  3. package/dist/_exports/_internal.d.ts.map +1 -1
  4. package/dist/_exports/_internal.js +332 -24
  5. package/dist/_exports/_internal.js.map +1 -1
  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 -2335
  29. package/dist/index.js +4048 -3874
  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 +13 -19
  45. package/src/_exports/_internal.ts +1 -0
  46. package/src/_exports/agent.ts +19 -0
  47. package/src/_exports/comlink.ts +16 -0
  48. package/src/_exports/index.ts +38 -86
  49. package/src/applications/applications.test-d.ts +5 -0
  50. package/src/applications/applications.ts +5 -2
  51. package/src/auth/authMode.test.ts +0 -25
  52. package/src/auth/authMode.ts +3 -6
  53. package/src/auth/authStore.test.ts +1 -1
  54. package/src/auth/authStore.ts +0 -1
  55. package/src/comments/addonDatasetStore.test.ts +215 -0
  56. package/src/comments/addonDatasetStore.ts +249 -0
  57. package/src/comments/buildCommentThreads.test.ts +83 -0
  58. package/src/comments/buildCommentThreads.ts +54 -0
  59. package/src/comments/commentActions.test.ts +540 -0
  60. package/src/comments/commentActions.ts +555 -0
  61. package/src/comments/commentFieldPath.test.ts +40 -0
  62. package/src/comments/commentFieldPath.ts +44 -0
  63. package/src/comments/commentsConstants.ts +80 -0
  64. package/src/comments/commentsStore.test.ts +419 -0
  65. package/src/comments/commentsStore.ts +483 -0
  66. package/src/comments/normalizeComment.test.ts +116 -0
  67. package/src/comments/normalizeComment.ts +45 -0
  68. package/src/comments/observeComments.test.ts +193 -0
  69. package/src/comments/observeComments.ts +113 -0
  70. package/src/comments/reducers.test.ts +277 -0
  71. package/src/comments/reducers.ts +316 -0
  72. package/src/comments/types.ts +249 -0
  73. package/src/comments/weakenReferences.test.ts +47 -0
  74. package/src/comments/weakenReferences.ts +29 -0
  75. package/src/config/sanityConfig.ts +3 -75
  76. package/src/document/applyDocumentActions.test.ts +8 -12
  77. package/src/document/documentConstants.ts +8 -0
  78. package/src/document/documentStore.test.ts +104 -19
  79. package/src/document/documentStore.ts +36 -5
  80. package/src/document/patchOperations.test.ts +27 -0
  81. package/src/document/patchOperations.ts +10 -1
  82. package/src/document/permissions.test.ts +3 -1
  83. package/src/document/reducers.test.ts +133 -0
  84. package/src/document/reducers.ts +18 -3
  85. package/src/document/util.test.ts +46 -0
  86. package/src/document/util.ts +37 -1
  87. package/src/installations/installations.test-d.ts +5 -0
  88. package/src/installations/installations.ts +4 -0
  89. package/src/presence/bifurTransport.test.ts +155 -3
  90. package/src/presence/bifurTransport.ts +79 -12
  91. package/src/presence/paths.test.ts +70 -0
  92. package/src/presence/paths.ts +41 -0
  93. package/src/presence/presenceStore.test.ts +822 -2
  94. package/src/presence/presenceStore.ts +518 -102
  95. package/src/presence/types.ts +175 -3
  96. package/src/preview/types.ts +0 -25
  97. package/src/projection/projectionStore.test.ts +0 -8
  98. package/src/projection/types.ts +0 -8
  99. package/src/query/queryStore.ts +7 -6
  100. package/src/store/createActionBinder.test.ts +51 -29
  101. package/src/store/createActionBinder.ts +16 -62
  102. package/src/store/createSanityInstance.test.ts +0 -68
  103. package/src/store/createSanityInstance.ts +0 -63
  104. package/src/store/createStateSourceAction.ts +1 -1
  105. package/src/users/reducers.test.ts +0 -3
  106. package/dist/_chunks-dts/createGroqSearchFilter.d.ts +0 -1147
  107. package/dist/_chunks-dts/createGroqSearchFilter.d.ts.map +0 -1
  108. package/dist/_chunks-es/_internal.js +0 -134
  109. package/dist/_chunks-es/_internal.js.map +0 -1
  110. package/dist/_chunks-es/createGroqSearchFilter.js +0 -1864
  111. package/dist/_chunks-es/createGroqSearchFilter.js.map +0 -1
  112. package/dist/_chunks-es/telemetryManager.js +0 -93
  113. package/dist/_chunks-es/telemetryManager.js.map +0 -1
  114. package/dist/index.d.ts.map +0 -1
  115. package/src/applications/userApplications.test.ts +0 -126
  116. package/src/applications/userApplications.ts +0 -261
  117. package/src/preview/getPreviewState.test.ts +0 -137
  118. package/src/preview/getPreviewState.ts +0 -69
  119. package/src/preview/resolvePreview.test.ts +0 -64
  120. package/src/preview/resolvePreview.ts +0 -43
@@ -1,69 +0,0 @@
1
- import {map} from 'rxjs'
2
-
3
- import {type DocumentHandle} from '../config/sanityConfig'
4
- import {getProjectionState} from '../projection/getProjectionState'
5
- import {type SanityInstance} from '../store/createSanityInstance'
6
- import {type StateSource} from '../store/createStateSourceAction'
7
- import {PREVIEW_PROJECTION} from './previewConstants'
8
- import {transformProjectionToPreview} from './previewProjectionUtils'
9
- import {type PreviewQueryResult, type PreviewValue, type ValuePending} from './types'
10
-
11
- /**
12
- * @beta
13
- * @deprecated This type is deprecated and will be removed in a future release.
14
- */
15
- export type GetPreviewStateOptions = DocumentHandle
16
-
17
- /**
18
- * @beta
19
- * @deprecated This function is deprecated and will be removed in a future release.
20
- */
21
- export function getPreviewState<TResult extends object>(
22
- instance: SanityInstance,
23
- options: GetPreviewStateOptions,
24
- ): StateSource<ValuePending<TResult>>
25
- /**
26
- * @beta
27
- * @deprecated This function is deprecated and will be removed in a future release.
28
- */
29
- export function getPreviewState(
30
- instance: SanityInstance,
31
- options: GetPreviewStateOptions,
32
- ): StateSource<ValuePending<PreviewValue>>
33
- /**
34
- * @beta
35
- * @deprecated This function is deprecated and will be removed in a future release.
36
- */
37
- export function getPreviewState(
38
- instance: SanityInstance,
39
- options: GetPreviewStateOptions,
40
- ): StateSource<ValuePending<PreviewValue>> {
41
- // Get the projection state
42
- const projectionState = getProjectionState<PreviewQueryResult>(instance, {
43
- ...options,
44
- projection: PREVIEW_PROJECTION,
45
- })
46
-
47
- // Transform helper to convert projection result to preview format
48
- const transformResult = (
49
- current: ReturnType<typeof projectionState.getCurrent>,
50
- ): ValuePending<PreviewValue> => {
51
- if (!current || current.data === null) {
52
- return {data: null, isPending: current?.isPending ?? false}
53
- }
54
-
55
- const previewValue = transformProjectionToPreview(instance, current.data, options.resource)
56
-
57
- return {
58
- data: previewValue,
59
- isPending: current.isPending,
60
- }
61
- }
62
-
63
- // Wrap the state source to transform projection results to preview format
64
- return {
65
- getCurrent: () => transformResult(projectionState.getCurrent()),
66
- subscribe: (callback) => projectionState.subscribe(callback),
67
- observable: projectionState.observable.pipe(map(transformResult)),
68
- }
69
- }
@@ -1,64 +0,0 @@
1
- import {beforeEach, describe, expect, it, vi} from 'vitest'
2
-
3
- import {resolveProjection} from '../projection/resolveProjection'
4
- import {type ProjectionValuePending} from '../projection/types'
5
- import {createSanityInstance, type SanityInstance} from '../store/createSanityInstance'
6
- import {resolvePreview} from './resolvePreview'
7
- import {type PreviewQueryResult} from './types'
8
-
9
- vi.mock('../projection/resolveProjection')
10
-
11
- describe('resolvePreview', () => {
12
- let instance: SanityInstance
13
- beforeEach(() => {
14
- vi.clearAllMocks()
15
- instance = createSanityInstance({projectId: 'p', dataset: 'd'})
16
- })
17
-
18
- afterEach(() => {
19
- instance.dispose()
20
- })
21
-
22
- it('resolves and transforms projection result to preview format', async () => {
23
- const mockProjectionResult: PreviewQueryResult = {
24
- _id: 'doc1',
25
- _type: 'article',
26
- _updatedAt: '2024-01-01',
27
- titleCandidates: {title: 'Resolved Title'},
28
- subtitleCandidates: {description: 'Resolved Description'},
29
- media: null,
30
- }
31
-
32
- vi.mocked(resolveProjection).mockResolvedValue({
33
- data: mockProjectionResult,
34
- isPending: false,
35
- } as ProjectionValuePending<PreviewQueryResult>)
36
-
37
- const result = await resolvePreview(instance, {
38
- documentId: 'doc1',
39
- documentType: 'article',
40
- })
41
-
42
- expect(result.data).toEqual({
43
- title: 'Resolved Title',
44
- subtitle: 'Resolved Description',
45
- media: null,
46
- })
47
- expect(result.isPending).toBe(false)
48
- })
49
-
50
- it('returns null data when projection resolves with null', async () => {
51
- vi.mocked(resolveProjection).mockResolvedValue({
52
- data: null,
53
- isPending: false,
54
- })
55
-
56
- const result = await resolvePreview(instance, {
57
- documentId: 'doc1',
58
- documentType: 'article',
59
- })
60
-
61
- expect(result.data).toBeNull()
62
- expect(result.isPending).toBe(false)
63
- })
64
- })
@@ -1,43 +0,0 @@
1
- import {type DocumentHandle} from '../config/sanityConfig'
2
- import {resolveProjection} from '../projection/resolveProjection'
3
- import {type SanityInstance} from '../store/createSanityInstance'
4
- import {PREVIEW_PROJECTION} from './previewConstants'
5
- import {transformProjectionToPreview} from './previewProjectionUtils'
6
- import {type PreviewQueryResult, type PreviewValue, type ValuePending} from './types'
7
-
8
- /**
9
- * @beta
10
- * @deprecated This type is deprecated and will be removed in a future release.
11
- */
12
- export type ResolvePreviewOptions = DocumentHandle
13
-
14
- /**
15
- * @beta
16
- * @deprecated This function is deprecated and will be removed in a future release.
17
- */
18
- export async function resolvePreview(
19
- instance: SanityInstance,
20
- options: ResolvePreviewOptions,
21
- ): Promise<ValuePending<PreviewValue>> {
22
- // Resolve the projection
23
- const projectionResult = await resolveProjection<PreviewQueryResult>(instance, {
24
- ...options,
25
- projection: PREVIEW_PROJECTION,
26
- })
27
-
28
- if (!projectionResult.data) {
29
- return {data: null, isPending: projectionResult.isPending}
30
- }
31
-
32
- // Transform to preview format
33
- const previewValue = transformProjectionToPreview(
34
- instance,
35
- projectionResult.data,
36
- options.resource,
37
- )
38
-
39
- return {
40
- data: previewValue,
41
- isPending: projectionResult.isPending,
42
- }
43
- }