@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.
- package/README.md +12 -0
- package/dist/_exports/_internal.d.ts +71 -3
- package/dist/_exports/_internal.d.ts.map +1 -1
- package/dist/_exports/_internal.js +332 -24
- package/dist/_exports/_internal.js.map +1 -1
- 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 -2335
- package/dist/index.js +4048 -3874
- 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 +13 -19
- package/src/_exports/_internal.ts +1 -0
- package/src/_exports/agent.ts +19 -0
- package/src/_exports/comlink.ts +16 -0
- package/src/_exports/index.ts +38 -86
- package/src/applications/applications.test-d.ts +5 -0
- package/src/applications/applications.ts +5 -2
- package/src/auth/authMode.test.ts +0 -25
- package/src/auth/authMode.ts +3 -6
- package/src/auth/authStore.test.ts +1 -1
- package/src/auth/authStore.ts +0 -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/sanityConfig.ts +3 -75
- package/src/document/applyDocumentActions.test.ts +8 -12
- package/src/document/documentConstants.ts +8 -0
- package/src/document/documentStore.test.ts +104 -19
- package/src/document/documentStore.ts +36 -5
- package/src/document/patchOperations.test.ts +27 -0
- package/src/document/patchOperations.ts +10 -1
- package/src/document/permissions.test.ts +3 -1
- package/src/document/reducers.test.ts +133 -0
- package/src/document/reducers.ts +18 -3
- package/src/document/util.test.ts +46 -0
- package/src/document/util.ts +37 -1
- package/src/installations/installations.test-d.ts +5 -0
- package/src/installations/installations.ts +4 -0
- package/src/presence/bifurTransport.test.ts +155 -3
- package/src/presence/bifurTransport.ts +79 -12
- package/src/presence/paths.test.ts +70 -0
- package/src/presence/paths.ts +41 -0
- package/src/presence/presenceStore.test.ts +822 -2
- package/src/presence/presenceStore.ts +518 -102
- package/src/presence/types.ts +175 -3
- package/src/preview/types.ts +0 -25
- package/src/projection/projectionStore.test.ts +0 -8
- package/src/projection/types.ts +0 -8
- package/src/query/queryStore.ts +7 -6
- package/src/store/createActionBinder.test.ts +51 -29
- package/src/store/createActionBinder.ts +16 -62
- package/src/store/createSanityInstance.test.ts +0 -68
- package/src/store/createSanityInstance.ts +0 -63
- package/src/store/createStateSourceAction.ts +1 -1
- package/src/users/reducers.test.ts +0 -3
- package/dist/_chunks-dts/createGroqSearchFilter.d.ts +0 -1147
- package/dist/_chunks-dts/createGroqSearchFilter.d.ts.map +0 -1
- package/dist/_chunks-es/_internal.js +0 -134
- package/dist/_chunks-es/_internal.js.map +0 -1
- package/dist/_chunks-es/createGroqSearchFilter.js +0 -1864
- package/dist/_chunks-es/createGroqSearchFilter.js.map +0 -1
- package/dist/_chunks-es/telemetryManager.js +0 -93
- package/dist/_chunks-es/telemetryManager.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/src/applications/userApplications.test.ts +0 -126
- package/src/applications/userApplications.ts +0 -261
- package/src/preview/getPreviewState.test.ts +0 -137
- package/src/preview/getPreviewState.ts +0 -69
- package/src/preview/resolvePreview.test.ts +0 -64
- 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
|
-
}
|