@sanity/sdk 0.0.2 → 1.0.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/sdk",
3
- "version": "0.0.2",
3
+ "version": "1.0.0",
4
4
  "private": false,
5
5
  "description": "Sanity SDK",
6
6
  "keywords": [
@@ -49,7 +49,7 @@
49
49
  "@sanity/mutate": "^0.12.4",
50
50
  "@sanity/types": "^3.83.0",
51
51
  "@types/lodash-es": "^4.17.12",
52
- "groq": "3.86.2-experimental.0",
52
+ "groq": "3.88.1-typegen-experimental.0",
53
53
  "lodash-es": "^4.17.21",
54
54
  "reselect": "^5.1.1",
55
55
  "rxjs": "^7.8.2",
@@ -68,9 +68,9 @@
68
68
  "vite": "^6.3.4",
69
69
  "vitest": "^3.1.2",
70
70
  "@repo/config-eslint": "0.0.0",
71
- "@repo/config-test": "0.0.1",
72
71
  "@repo/package.bundle": "3.82.0",
73
72
  "@repo/package.config": "0.0.1",
73
+ "@repo/config-test": "0.0.1",
74
74
  "@repo/tsconfig": "0.0.1"
75
75
  },
76
76
  "engines": {
@@ -1,5 +1,5 @@
1
1
  import {type SanityClient} from '@sanity/client'
2
- import {type SanityDocumentResult} from 'groq'
2
+ import {type SanityDocument} from 'groq'
3
3
  import {distinctUntilChanged, filter, first, firstValueFrom, map, race} from 'rxjs'
4
4
 
5
5
  import {bindActionByDataset} from '../store/createActionBinder'
@@ -11,7 +11,7 @@ import {type DocumentSet} from './processMutations'
11
11
  import {type AppliedTransaction, type QueuedTransaction, queueTransaction} from './reducers'
12
12
 
13
13
  /** @beta */
14
- export interface ActionsResult<TDocument extends SanityDocumentResult = SanityDocumentResult> {
14
+ export interface ActionsResult<TDocument extends SanityDocument = SanityDocument> {
15
15
  transactionId: string
16
16
  documents: DocumentSet<TDocument>
17
17
  previous: DocumentSet<TDocument>
@@ -45,7 +45,7 @@ export function applyDocumentActions<
45
45
  | DocumentAction<TDocumentType, TDataset, TProjectId>
46
46
  | DocumentAction<TDocumentType, TDataset, TProjectId>[],
47
47
  options?: ApplyDocumentActionsOptions,
48
- ): Promise<ActionsResult<SanityDocumentResult<TDocumentType, TDataset, TProjectId>>>
48
+ ): Promise<ActionsResult<SanityDocument<TDocumentType, `${TProjectId}.${TDataset}`>>>
49
49
  /** @beta */
50
50
  export function applyDocumentActions(
51
51
  instance: SanityInstance,
@@ -57,7 +57,7 @@ type AllTestSchemaTypes = TestDocument
57
57
  // Augment the 'groq' module
58
58
  declare module 'groq' {
59
59
  interface SanitySchemas {
60
- 'default:default': AllTestSchemaTypes
60
+ default: AllTestSchemaTypes
61
61
  }
62
62
  }
63
63
 
@@ -1,7 +1,6 @@
1
1
  import {type Action} from '@sanity/client'
2
2
  import {getPublishedId} from '@sanity/client/csm'
3
- import {type SanityDocument} from '@sanity/types'
4
- import {type SanityDocumentResult} from 'groq'
3
+ import {type SanityDocument} from 'groq'
5
4
  import {type ExprNode} from 'groq-js'
6
5
  import {
7
6
  catchError,
@@ -151,7 +150,7 @@ export function getDocumentState<
151
150
  >(
152
151
  instance: SanityInstance,
153
152
  options: DocumentOptions<undefined, TDocumentType, TDataset, TProjectId>,
154
- ): StateSource<SanityDocumentResult<TDocumentType, TDataset, TProjectId> | undefined | null>
153
+ ): StateSource<SanityDocument<TDocumentType, `${TProjectId}.${TDataset}`> | undefined | null>
155
154
 
156
155
  /** @beta */
157
156
  export function getDocumentState<
@@ -163,7 +162,7 @@ export function getDocumentState<
163
162
  instance: SanityInstance,
164
163
  options: DocumentOptions<TPath, TDocumentType, TDataset, TProjectId>,
165
164
  ): StateSource<
166
- JsonMatch<SanityDocumentResult<TDocumentType, TDataset, TProjectId>, TPath> | undefined
165
+ JsonMatch<SanityDocument<TDocumentType, `${TProjectId}.${TDataset}`>, TPath> | undefined
167
166
  >
168
167
 
169
168
  /** @beta */
@@ -208,7 +207,7 @@ export function resolveDocument<
208
207
  >(
209
208
  instance: SanityInstance,
210
209
  docHandle: DocumentHandle<TDocumentType, TDataset, TProjectId>,
211
- ): Promise<SanityDocumentResult<TDocumentType, TDataset, TProjectId> | null>
210
+ ): Promise<SanityDocument<TDocumentType, `${TProjectId}.${TDataset}`> | null>
212
211
  /** @beta */
213
212
  export function resolveDocument<TData extends SanityDocument>(
214
213
  instance: SanityInstance,
@@ -2,7 +2,7 @@ import {getEnv} from '../utils/getEnv'
2
2
  import {type PreviewValue, type ValuePending} from './previewStore'
3
3
 
4
4
  export const PREVIEW_TAG = 'preview'
5
- export const PREVIEW_PERSPECTIVE = 'drafts'
5
+ export const PREVIEW_PERSPECTIVE = 'raw'
6
6
  export const STABLE_EMPTY_PREVIEW: ValuePending<PreviewValue> = {data: null, isPending: false}
7
7
  export const STABLE_ERROR_PREVIEW: ValuePending<PreviewValue> = {
8
8
  data: {
@@ -36,7 +36,9 @@ export function getProjectionState<
36
36
  instance: SanityInstance,
37
37
  options: ProjectionOptions<TProjection, TDocumentType, TDataset, TProjectId>,
38
38
  ): StateSource<
39
- | ProjectionValuePending<SanityProjectionResult<TProjection, TDocumentType, TDataset, TProjectId>>
39
+ | ProjectionValuePending<
40
+ SanityProjectionResult<TProjection, TDocumentType, `${TProjectId}.${TDataset}`>
41
+ >
40
42
  | undefined
41
43
  >
42
44
 
@@ -17,7 +17,9 @@ export function resolveProjection<
17
17
  instance: SanityInstance,
18
18
  options: ProjectionOptions<TProjection, TDocumentType, TDataset, TProjectId>,
19
19
  ): Promise<
20
- ProjectionValuePending<SanityProjectionResult<TProjection, TDocumentType, TDataset, TProjectId>>
20
+ ProjectionValuePending<
21
+ SanityProjectionResult<TProjection, TDocumentType, `${TProjectId}.${TDataset}`>
22
+ >
21
23
  >
22
24
 
23
25
  /** @beta */
@@ -1,7 +1,7 @@
1
1
  import {type ValidProjection} from './types'
2
2
 
3
3
  export const PROJECTION_TAG = 'sdk.projection'
4
- export const PROJECTION_PERSPECTIVE = 'drafts'
4
+ export const PROJECTION_PERSPECTIVE = 'raw'
5
5
  export const PROJECTION_STATE_CLEAR_DELAY = 1000
6
6
 
7
7
  export const STABLE_EMPTY_PROJECTION = {
@@ -232,7 +232,7 @@ export function getQueryState<
232
232
  >(
233
233
  instance: SanityInstance,
234
234
  queryOptions: QueryOptions<TQuery, TDataset, TProjectId>,
235
- ): StateSource<SanityQueryResult<TQuery, TDataset, TProjectId> | undefined>
235
+ ): StateSource<SanityQueryResult<TQuery, `${TProjectId}.${TDataset}`> | undefined>
236
236
 
237
237
  /** @beta */
238
238
  export function getQueryState<TData>(
@@ -300,7 +300,7 @@ export function resolveQuery<
300
300
  >(
301
301
  instance: SanityInstance,
302
302
  queryOptions: ResolveQueryOptions<TQuery, TDataset, TProjectId>,
303
- ): Promise<SanityQueryResult<TQuery, TDataset, TProjectId>>
303
+ ): Promise<SanityQueryResult<TQuery, `${TProjectId}.${TDataset}`>>
304
304
 
305
305
  /** @beta */
306
306
  export function resolveQuery<TData>(