@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/README.md CHANGED
@@ -2,16 +2,18 @@
2
2
  <a href="https://sanity.io">
3
3
  <img src="https://cdn.sanity.io/images/3do82whm/next/1dfce9dde7a62ccaa8e8377254a1e919f6c07ad3-128x128.svg" />
4
4
  </a>
5
- <h1 align="center">Sanity Core App SDK</h1>
5
+ <h1 align="center">Sanity App SDK (Core)</h1>
6
6
  </p>
7
7
 
8
- Core functionality powering the React SDK.
8
+ The App SDK Core is a pure TypeScript implementation of the App SDK’s business logic. It powers our React App SDK under the hood, and leaves the door open for future framework specific implementations, too.
9
9
 
10
- ## Documentation
10
+ We highly recommend that users default to using the hooks provided by the React SDK for building custom apps on the Sanity platform, unless you’re looking to create your own Sanity App SDK using this core layer.
11
11
 
12
- - Familiarize yourself with the App SDK via a conceptual overview, a quickstart guide, and a step by step walkthrough on **[the Sanity Docs site](https://sanity.io/docs/app-sdk)**
13
- - Go in depth with the **[App SDK reference docs](https://sdk-docs.sanity.dev)**
14
- - View example implementations on the **[SDK Explorer](https://sdk-examples.sanity.dev)**
12
+ **Looking for our React SDK?** You’ll find it on:
13
+
14
+ - [GitHub](https://github.com/sanity-io/sdk/tree/main/packages/react)
15
+ - [Sanity Docs](https://sanity.io/docs/app-sdk)
16
+ - [App SDK (React) reference docs](https://reference.sanity.io/_sanity/sdk-react)
15
17
 
16
18
  ## License
17
19
 
package/dist/index.d.ts CHANGED
@@ -27,9 +27,9 @@ import {ResponseQueryOptions} from '@sanity/client'
27
27
  import {Role} from '@sanity/types'
28
28
  import {SanityClient} from '@sanity/client'
29
29
  import {SanityDocument} from '@sanity/types'
30
- import {SanityDocument as SanityDocument_2} from '@sanity/client'
30
+ import {SanityDocument as SanityDocument_2} from 'groq'
31
+ import {SanityDocument as SanityDocument_3} from '@sanity/client'
31
32
  import {SanityDocumentLike} from '@sanity/types'
32
- import {SanityDocumentResult} from 'groq'
33
33
  import {SanityProject as SanityProject_2} from '@sanity/client'
34
34
  import {SanityProjectionResult} from 'groq'
35
35
  import {SanityQueryResult} from 'groq'
@@ -77,9 +77,7 @@ declare type ActionMap = {
77
77
  }
78
78
 
79
79
  /** @beta */
80
- export declare interface ActionsResult<
81
- TDocument extends SanityDocumentResult = SanityDocumentResult,
82
- > {
80
+ export declare interface ActionsResult<TDocument extends SanityDocument_2 = SanityDocument_2> {
83
81
  transactionId: string
84
82
  documents: DocumentSet<TDocument>
85
83
  previous: DocumentSet<TDocument>
@@ -186,7 +184,7 @@ export declare function applyDocumentActions<
186
184
  | DocumentAction<TDocumentType, TDataset, TProjectId>
187
185
  | DocumentAction<TDocumentType, TDataset, TProjectId>[],
188
186
  options?: ApplyDocumentActionsOptions,
189
- ): Promise<ActionsResult<SanityDocumentResult<TDocumentType, TDataset, TProjectId>>>
187
+ ): Promise<ActionsResult<SanityDocument_2<TDocumentType, `${TProjectId}.${TDataset}`>>>
190
188
 
191
189
  /** @beta */
192
190
  export declare function applyDocumentActions(
@@ -850,12 +848,12 @@ declare interface DocumentState {
850
848
  * the "remote" local copy that matches the server. represents the last known
851
849
  * server state. this gets updated every time we confirm remote patches
852
850
  */
853
- remote?: SanityDocument | null
851
+ remote?: SanityDocument_2 | null
854
852
  /**
855
853
  * the current ephemeral working copy that includes local optimistic changes
856
854
  * that have not yet been confirmed by the server
857
855
  */
858
- local?: SanityDocument | null
856
+ local?: SanityDocument_2 | null
859
857
  /**
860
858
  * the revision that our remote document is at
861
859
  */
@@ -891,7 +889,7 @@ declare interface DocumentStoreState {
891
889
  grants?: Record<Grant, ExprNode>
892
890
  error?: unknown
893
891
  sharedListener: SharedListener
894
- fetchDocument: (documentId: string) => Observable<SanityDocument | null>
892
+ fetchDocument: (documentId: string) => Observable<SanityDocument_2 | null>
895
893
  events: Subject<DocumentEvent>
896
894
  }
897
895
 
@@ -1168,7 +1166,7 @@ export declare function getDocumentState<
1168
1166
  >(
1169
1167
  instance: SanityInstance,
1170
1168
  options: DocumentOptions<undefined, TDocumentType, TDataset, TProjectId>,
1171
- ): StateSource<SanityDocumentResult<TDocumentType, TDataset, TProjectId> | undefined | null>
1169
+ ): StateSource<SanityDocument_2<TDocumentType, `${TProjectId}.${TDataset}`> | undefined | null>
1172
1170
 
1173
1171
  /** @beta */
1174
1172
  export declare function getDocumentState<
@@ -1180,7 +1178,7 @@ export declare function getDocumentState<
1180
1178
  instance: SanityInstance,
1181
1179
  options: DocumentOptions<TPath, TDocumentType, TDataset, TProjectId>,
1182
1180
  ): StateSource<
1183
- JsonMatch<SanityDocumentResult<TDocumentType, TDataset, TProjectId>, TPath> | undefined
1181
+ JsonMatch<SanityDocument_2<TDocumentType, `${TProjectId}.${TDataset}`>, TPath> | undefined
1184
1182
  >
1185
1183
 
1186
1184
  /** @beta */
@@ -1308,7 +1306,9 @@ export declare function getProjectionState<
1308
1306
  instance: SanityInstance,
1309
1307
  options: ProjectionOptions<TProjection, TDocumentType, TDataset, TProjectId>,
1310
1308
  ): StateSource<
1311
- | ProjectionValuePending<SanityProjectionResult<TProjection, TDocumentType, TDataset, TProjectId>>
1309
+ | ProjectionValuePending<
1310
+ SanityProjectionResult<TProjection, TDocumentType, `${TProjectId}.${TDataset}`>
1311
+ >
1312
1312
  | undefined
1313
1313
  >
1314
1314
 
@@ -1368,7 +1368,7 @@ export declare function getQueryState<
1368
1368
  >(
1369
1369
  instance: SanityInstance,
1370
1370
  queryOptions: QueryOptions<TQuery, TDataset, TProjectId>,
1371
- ): StateSource<SanityQueryResult<TQuery, TDataset, TProjectId> | undefined>
1371
+ ): StateSource<SanityQueryResult<TQuery, `${TProjectId}.${TDataset}`> | undefined>
1372
1372
 
1373
1373
  /** @beta */
1374
1374
  export declare function getQueryState<TData>(
@@ -2037,10 +2037,10 @@ export declare function resolveDocument<
2037
2037
  >(
2038
2038
  instance: SanityInstance,
2039
2039
  docHandle: DocumentHandle<TDocumentType, TDataset, TProjectId>,
2040
- ): Promise<SanityDocumentResult<TDocumentType, TDataset, TProjectId> | null>
2040
+ ): Promise<SanityDocument_2<TDocumentType, `${TProjectId}.${TDataset}`> | null>
2041
2041
 
2042
2042
  /** @beta */
2043
- export declare function resolveDocument<TData extends SanityDocument>(
2043
+ export declare function resolveDocument<TData extends SanityDocument_2>(
2044
2044
  instance: SanityInstance,
2045
2045
  docHandle: DocumentHandle<string, string, string>,
2046
2046
  ): Promise<TData | null>
@@ -2096,7 +2096,9 @@ export declare function resolveProjection<
2096
2096
  instance: SanityInstance,
2097
2097
  options: ProjectionOptions<TProjection, TDocumentType, TDataset, TProjectId>,
2098
2098
  ): Promise<
2099
- ProjectionValuePending<SanityProjectionResult<TProjection, TDocumentType, TDataset, TProjectId>>
2099
+ ProjectionValuePending<
2100
+ SanityProjectionResult<TProjection, TDocumentType, `${TProjectId}.${TDataset}`>
2101
+ >
2100
2102
  >
2101
2103
 
2102
2104
  /** @beta */
@@ -2133,7 +2135,7 @@ export declare function resolveQuery<
2133
2135
  >(
2134
2136
  instance: SanityInstance,
2135
2137
  queryOptions: ResolveQueryOptions<TQuery, TDataset, TProjectId>,
2136
- ): Promise<SanityQueryResult<TQuery, TDataset, TProjectId>>
2138
+ ): Promise<SanityQueryResult<TQuery, `${TProjectId}.${TDataset}`>>
2137
2139
 
2138
2140
  /** @beta */
2139
2141
  export declare function resolveQuery<TData>(
@@ -2350,7 +2352,7 @@ declare interface SelectorNode extends BaseNode {
2350
2352
  }
2351
2353
 
2352
2354
  declare interface SharedListener {
2353
- events: Observable<ListenEvent<SanityDocument_2>>
2355
+ events: Observable<ListenEvent<SanityDocument_3>>
2354
2356
  dispose: () => void
2355
2357
  }
2356
2358
 
package/dist/index.js CHANGED
@@ -4824,7 +4824,7 @@ const TITLE_CANDIDATES = ["title", "name", "label", "heading", "header", "captio
4824
4824
  _type,
4825
4825
  _id,
4826
4826
  _updatedAt
4827
- }`, PREVIEW_TAG = "preview", PREVIEW_PERSPECTIVE = "drafts", STABLE_EMPTY_PREVIEW = { data: null, isPending: !1 }, STABLE_ERROR_PREVIEW = {
4827
+ }`, PREVIEW_TAG = "preview", PREVIEW_PERSPECTIVE = "raw", STABLE_EMPTY_PREVIEW = { data: null, isPending: !1 }, STABLE_ERROR_PREVIEW = {
4828
4828
  data: {
4829
4829
  title: "Preview Error",
4830
4830
  ...!!getEnv("DEV") && { subtitle: "Check the console for more details" }
@@ -5049,7 +5049,7 @@ function processProjectionQuery({ ids, results }) {
5049
5049
  }
5050
5050
  return finalValues;
5051
5051
  }
5052
- const PROJECTION_TAG = "sdk.projection", PROJECTION_PERSPECTIVE = "drafts", PROJECTION_STATE_CLEAR_DELAY = 1e3, STABLE_EMPTY_PROJECTION = {
5052
+ const PROJECTION_TAG = "sdk.projection", PROJECTION_PERSPECTIVE = "raw", PROJECTION_STATE_CLEAR_DELAY = 1e3, STABLE_EMPTY_PROJECTION = {
5053
5053
  data: null,
5054
5054
  isPending: !1
5055
5055
  };
@@ -5405,7 +5405,7 @@ function createGroqSearchFilter(query) {
5405
5405
  `${finalIncrementalToken}${WILDCARD_TOKEN}`
5406
5406
  ), `[@] match text::query("${processedTokens.join(" ").replace(/"/g, '\\"')}")`;
5407
5407
  }
5408
- var version = "0.0.2";
5408
+ var version = "1.0.0";
5409
5409
  const CORE_SDK_VERSION = getEnv("PKG_VERSION") || `${version}-development`;
5410
5410
  export {
5411
5411
  AuthStateType,