@sanity/client 6.16.0 → 6.17.1-canary.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/dist/index.browser.cjs +53 -2
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +33 -0
- package/dist/index.browser.d.ts +33 -0
- package/dist/index.browser.js +53 -2
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +54 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +33 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +54 -3
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/SanityClient.ts +4 -0
- package/src/data/syncTags.ts +88 -0
- package/src/types.ts +22 -0
- package/umd/sanityClient.js +53 -2
- package/umd/sanityClient.min.js +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1123,6 +1123,7 @@ export declare class ObservableSanityClient {
|
|
|
1123
1123
|
* Instance properties
|
|
1124
1124
|
*/
|
|
1125
1125
|
listen: typeof _listen
|
|
1126
|
+
syncTags: typeof _syncTags
|
|
1126
1127
|
constructor(httpRequest: HttpRequest, config?: ClientConfig)
|
|
1127
1128
|
/**
|
|
1128
1129
|
* Clone the client - returns a new instance
|
|
@@ -1831,6 +1832,7 @@ export declare interface RawQueryResponse<R> {
|
|
|
1831
1832
|
ms: number
|
|
1832
1833
|
result: R
|
|
1833
1834
|
resultSourceMap?: ContentSourceMap
|
|
1835
|
+
syncTags?: `s1:${string}`[]
|
|
1834
1836
|
}
|
|
1835
1837
|
|
|
1836
1838
|
/** @internal */
|
|
@@ -1943,6 +1945,7 @@ export declare class SanityClient {
|
|
|
1943
1945
|
* Instance properties
|
|
1944
1946
|
*/
|
|
1945
1947
|
listen: typeof _listen
|
|
1948
|
+
syncTags: typeof _syncTags
|
|
1946
1949
|
constructor(httpRequest: HttpRequest, config?: ClientConfig)
|
|
1947
1950
|
/**
|
|
1948
1951
|
* Clone the client - returns a new instance
|
|
@@ -2504,6 +2507,7 @@ export declare interface SanityProject {
|
|
|
2504
2507
|
maxRetentionDays?: number
|
|
2505
2508
|
members: SanityProjectMember[]
|
|
2506
2509
|
metadata: {
|
|
2510
|
+
cliInitializedAt?: string
|
|
2507
2511
|
color?: string
|
|
2508
2512
|
externalStudioHost?: string
|
|
2509
2513
|
}
|
|
@@ -2594,6 +2598,35 @@ export {StudioBaseUrl}
|
|
|
2594
2598
|
|
|
2595
2599
|
export {StudioUrl}
|
|
2596
2600
|
|
|
2601
|
+
/** @public */
|
|
2602
|
+
export declare function _syncTags(
|
|
2603
|
+
this: SanityClient | ObservableSanityClient,
|
|
2604
|
+
opts?: SyncTagsOptions,
|
|
2605
|
+
): Observable<SyncTagsChangeEvent | SyncTagsErrorEvent | SyncTagsRestartEvent>
|
|
2606
|
+
|
|
2607
|
+
/** @public */
|
|
2608
|
+
export declare interface SyncTagsChangeEvent {
|
|
2609
|
+
tags: `s1:${string}`[]
|
|
2610
|
+
pos: string
|
|
2611
|
+
}
|
|
2612
|
+
|
|
2613
|
+
/** @public */
|
|
2614
|
+
export declare interface SyncTagsErrorEvent {
|
|
2615
|
+
type: 'error'
|
|
2616
|
+
status: number
|
|
2617
|
+
message: string
|
|
2618
|
+
}
|
|
2619
|
+
|
|
2620
|
+
/** @public */
|
|
2621
|
+
export declare interface SyncTagsOptions {
|
|
2622
|
+
pos?: string
|
|
2623
|
+
}
|
|
2624
|
+
|
|
2625
|
+
/** @public */
|
|
2626
|
+
export declare interface SyncTagsRestartEvent {
|
|
2627
|
+
type: 'restart'
|
|
2628
|
+
}
|
|
2629
|
+
|
|
2597
2630
|
/** @public */
|
|
2598
2631
|
export declare class Transaction extends BaseTransaction {
|
|
2599
2632
|
#private
|
package/dist/index.d.ts
CHANGED
|
@@ -1123,6 +1123,7 @@ export declare class ObservableSanityClient {
|
|
|
1123
1123
|
* Instance properties
|
|
1124
1124
|
*/
|
|
1125
1125
|
listen: typeof _listen
|
|
1126
|
+
syncTags: typeof _syncTags
|
|
1126
1127
|
constructor(httpRequest: HttpRequest, config?: ClientConfig)
|
|
1127
1128
|
/**
|
|
1128
1129
|
* Clone the client - returns a new instance
|
|
@@ -1831,6 +1832,7 @@ export declare interface RawQueryResponse<R> {
|
|
|
1831
1832
|
ms: number
|
|
1832
1833
|
result: R
|
|
1833
1834
|
resultSourceMap?: ContentSourceMap
|
|
1835
|
+
syncTags?: `s1:${string}`[]
|
|
1834
1836
|
}
|
|
1835
1837
|
|
|
1836
1838
|
/** @internal */
|
|
@@ -1943,6 +1945,7 @@ export declare class SanityClient {
|
|
|
1943
1945
|
* Instance properties
|
|
1944
1946
|
*/
|
|
1945
1947
|
listen: typeof _listen
|
|
1948
|
+
syncTags: typeof _syncTags
|
|
1946
1949
|
constructor(httpRequest: HttpRequest, config?: ClientConfig)
|
|
1947
1950
|
/**
|
|
1948
1951
|
* Clone the client - returns a new instance
|
|
@@ -2504,6 +2507,7 @@ export declare interface SanityProject {
|
|
|
2504
2507
|
maxRetentionDays?: number
|
|
2505
2508
|
members: SanityProjectMember[]
|
|
2506
2509
|
metadata: {
|
|
2510
|
+
cliInitializedAt?: string
|
|
2507
2511
|
color?: string
|
|
2508
2512
|
externalStudioHost?: string
|
|
2509
2513
|
}
|
|
@@ -2594,6 +2598,35 @@ export {StudioBaseUrl}
|
|
|
2594
2598
|
|
|
2595
2599
|
export {StudioUrl}
|
|
2596
2600
|
|
|
2601
|
+
/** @public */
|
|
2602
|
+
export declare function _syncTags(
|
|
2603
|
+
this: SanityClient | ObservableSanityClient,
|
|
2604
|
+
opts?: SyncTagsOptions,
|
|
2605
|
+
): Observable<SyncTagsChangeEvent | SyncTagsErrorEvent | SyncTagsRestartEvent>
|
|
2606
|
+
|
|
2607
|
+
/** @public */
|
|
2608
|
+
export declare interface SyncTagsChangeEvent {
|
|
2609
|
+
tags: `s1:${string}`[]
|
|
2610
|
+
pos: string
|
|
2611
|
+
}
|
|
2612
|
+
|
|
2613
|
+
/** @public */
|
|
2614
|
+
export declare interface SyncTagsErrorEvent {
|
|
2615
|
+
type: 'error'
|
|
2616
|
+
status: number
|
|
2617
|
+
message: string
|
|
2618
|
+
}
|
|
2619
|
+
|
|
2620
|
+
/** @public */
|
|
2621
|
+
export declare interface SyncTagsOptions {
|
|
2622
|
+
pos?: string
|
|
2623
|
+
}
|
|
2624
|
+
|
|
2625
|
+
/** @public */
|
|
2626
|
+
export declare interface SyncTagsRestartEvent {
|
|
2627
|
+
type: 'restart'
|
|
2628
|
+
}
|
|
2629
|
+
|
|
2597
2630
|
/** @public */
|
|
2598
2631
|
export declare class Transaction extends BaseTransaction {
|
|
2599
2632
|
#private
|
package/dist/index.js
CHANGED
|
@@ -916,6 +916,57 @@ function cooerceError(err) {
|
|
|
916
916
|
function extractErrorMessage(err) {
|
|
917
917
|
return err.error ? err.error.description ? err.error.description : typeof err.error == "string" ? err.error : JSON.stringify(err.error, null, 2) : err.message || "Unknown listener error";
|
|
918
918
|
}
|
|
919
|
+
function _syncTags(opts = {}) {
|
|
920
|
+
const path = _getDataUrl(this, "sync-tags"), url = new URL(this.getUrl(path, !0));
|
|
921
|
+
return opts.pos && url.searchParams.append("start", opts.pos), new Observable((observer) => {
|
|
922
|
+
const controller = new AbortController(), { signal } = controller;
|
|
923
|
+
return fetch(url, { signal }).then(async (res) => {
|
|
924
|
+
if (!res.body)
|
|
925
|
+
throw new TypeError("Response body is not readable");
|
|
926
|
+
const reader = res.body.pipeThrough(new TextDecoderStream()).pipeThrough(splitStream(`
|
|
927
|
+
`)).pipeThrough(parseJSON()).getReader(), results = {
|
|
928
|
+
[Symbol.asyncIterator]() {
|
|
929
|
+
return {
|
|
930
|
+
next: () => reader.read()
|
|
931
|
+
};
|
|
932
|
+
}
|
|
933
|
+
};
|
|
934
|
+
for await (const chunk of results) {
|
|
935
|
+
if (signal.aborted)
|
|
936
|
+
break;
|
|
937
|
+
if (chunk.type === "error") {
|
|
938
|
+
observer.error(chunk);
|
|
939
|
+
break;
|
|
940
|
+
}
|
|
941
|
+
observer.next(chunk);
|
|
942
|
+
}
|
|
943
|
+
}).catch((err) => {
|
|
944
|
+
(err == null ? void 0 : err.name) !== "TimeoutError" && (err == null ? void 0 : err.name) !== "AbortError" && observer.error(err);
|
|
945
|
+
}), () => {
|
|
946
|
+
controller.abort();
|
|
947
|
+
};
|
|
948
|
+
});
|
|
949
|
+
}
|
|
950
|
+
function splitStream(splitOn) {
|
|
951
|
+
let buffer = "";
|
|
952
|
+
return new TransformStream({
|
|
953
|
+
transform(chunk, controller) {
|
|
954
|
+
buffer += chunk;
|
|
955
|
+
const parts = buffer.split(splitOn);
|
|
956
|
+
parts.slice(0, -1).forEach((part) => controller.enqueue(part)), buffer = parts[parts.length - 1];
|
|
957
|
+
},
|
|
958
|
+
flush(controller) {
|
|
959
|
+
buffer && controller.enqueue(buffer);
|
|
960
|
+
}
|
|
961
|
+
});
|
|
962
|
+
}
|
|
963
|
+
function parseJSON() {
|
|
964
|
+
return new TransformStream({
|
|
965
|
+
transform(chunk, controller) {
|
|
966
|
+
chunk && controller.enqueue(JSON.parse(chunk));
|
|
967
|
+
}
|
|
968
|
+
});
|
|
969
|
+
}
|
|
919
970
|
var __accessCheck$3 = (obj, member, msg) => {
|
|
920
971
|
if (!member.has(obj))
|
|
921
972
|
throw TypeError("Cannot " + msg);
|
|
@@ -1120,7 +1171,7 @@ var __defProp = Object.defineProperty, __defNormalProp = (obj, key, value) => ke
|
|
|
1120
1171
|
}, __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value), _clientConfig, _httpRequest;
|
|
1121
1172
|
const _ObservableSanityClient = class _ObservableSanityClient2 {
|
|
1122
1173
|
constructor(httpRequest, config = defaultConfig) {
|
|
1123
|
-
__publicField(this, "assets"), __publicField(this, "datasets"), __publicField(this, "projects"), __publicField(this, "users"), __privateAdd(this, _clientConfig, void 0), __privateAdd(this, _httpRequest, void 0), __publicField(this, "listen", _listen), this.config(config), __privateSet(this, _httpRequest, httpRequest), this.assets = new ObservableAssetsClient(this, __privateGet(this, _httpRequest)), this.datasets = new ObservableDatasetsClient(this, __privateGet(this, _httpRequest)), this.projects = new ObservableProjectsClient(this, __privateGet(this, _httpRequest)), this.users = new ObservableUsersClient(this, __privateGet(this, _httpRequest));
|
|
1174
|
+
__publicField(this, "assets"), __publicField(this, "datasets"), __publicField(this, "projects"), __publicField(this, "users"), __privateAdd(this, _clientConfig, void 0), __privateAdd(this, _httpRequest, void 0), __publicField(this, "listen", _listen), __publicField(this, "syncTags", _syncTags), this.config(config), __privateSet(this, _httpRequest, httpRequest), this.assets = new ObservableAssetsClient(this, __privateGet(this, _httpRequest)), this.datasets = new ObservableDatasetsClient(this, __privateGet(this, _httpRequest)), this.projects = new ObservableProjectsClient(this, __privateGet(this, _httpRequest)), this.users = new ObservableUsersClient(this, __privateGet(this, _httpRequest));
|
|
1124
1175
|
}
|
|
1125
1176
|
/**
|
|
1126
1177
|
* Clone the client - returns a new instance
|
|
@@ -1249,7 +1300,7 @@ let ObservableSanityClient = _ObservableSanityClient;
|
|
|
1249
1300
|
var _clientConfig2, _httpRequest2;
|
|
1250
1301
|
const _SanityClient = class _SanityClient2 {
|
|
1251
1302
|
constructor(httpRequest, config = defaultConfig) {
|
|
1252
|
-
__publicField(this, "assets"), __publicField(this, "datasets"), __publicField(this, "projects"), __publicField(this, "users"), __publicField(this, "observable"), __privateAdd(this, _clientConfig2, void 0), __privateAdd(this, _httpRequest2, void 0), __publicField(this, "listen", _listen), this.config(config), __privateSet(this, _httpRequest2, httpRequest), this.assets = new AssetsClient(this, __privateGet(this, _httpRequest2)), this.datasets = new DatasetsClient(this, __privateGet(this, _httpRequest2)), this.projects = new ProjectsClient(this, __privateGet(this, _httpRequest2)), this.users = new UsersClient(this, __privateGet(this, _httpRequest2)), this.observable = new ObservableSanityClient(httpRequest, config);
|
|
1303
|
+
__publicField(this, "assets"), __publicField(this, "datasets"), __publicField(this, "projects"), __publicField(this, "users"), __publicField(this, "observable"), __privateAdd(this, _clientConfig2, void 0), __privateAdd(this, _httpRequest2, void 0), __publicField(this, "listen", _listen), __publicField(this, "syncTags", _syncTags), this.config(config), __privateSet(this, _httpRequest2, httpRequest), this.assets = new AssetsClient(this, __privateGet(this, _httpRequest2)), this.datasets = new DatasetsClient(this, __privateGet(this, _httpRequest2)), this.projects = new ProjectsClient(this, __privateGet(this, _httpRequest2)), this.users = new UsersClient(this, __privateGet(this, _httpRequest2)), this.observable = new ObservableSanityClient(httpRequest, config);
|
|
1253
1304
|
}
|
|
1254
1305
|
/**
|
|
1255
1306
|
* Clone the client - returns a new instance
|
|
@@ -1415,7 +1466,7 @@ function defineDeprecatedCreateClient(createClient2) {
|
|
|
1415
1466
|
return printNoDefaultExport(), createClient2(config);
|
|
1416
1467
|
};
|
|
1417
1468
|
}
|
|
1418
|
-
var name = "@sanity/client", version = "6.
|
|
1469
|
+
var name = "@sanity/client", version = "6.17.1-canary.0";
|
|
1419
1470
|
const middleware = [
|
|
1420
1471
|
debug({ verbose: !0, namespace: "sanity:client" }),
|
|
1421
1472
|
headers({ "User-Agent": `${name} ${version}` }),
|