@sanity-labs/client-fake-for-test 0.19.0 → 0.21.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 +7 -5
- package/dist/index.cjs +212 -50
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +40 -4
- package/dist/index.d.ts +40 -4
- package/dist/index.js +212 -50
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -209,6 +209,22 @@ export declare interface CreateTestClientOptions {
|
|
|
209
209
|
* mints siblings on the other host.
|
|
210
210
|
*/
|
|
211
211
|
useProjectHostname?: boolean;
|
|
212
|
+
/**
|
|
213
|
+
* The API host, as the real `createClient` config names it (default
|
|
214
|
+
* `https://api.sanity.io`). With {@link apiVersion}, `useCdn` and the
|
|
215
|
+
* host flag it decides the URL a platform error carries as
|
|
216
|
+
* `response.url`: the URL `@sanity/client` would have requested, e.g.
|
|
217
|
+
* `https://p1.api.sanity.io/v2025-02-19/data/doc/production/x?tag=t`.
|
|
218
|
+
*/
|
|
219
|
+
apiHost?: string;
|
|
220
|
+
/** The API version (default `"1"`, as in `@sanity/client`): `"YYYY-MM-DD"`, `"X"` or `"1"`, `v` prefix optional. */
|
|
221
|
+
apiVersion?: string;
|
|
222
|
+
/**
|
|
223
|
+
* Whether GET reads of the data API (queries, documents, history) go to
|
|
224
|
+
* the API CDN, as in `@sanity/client` (default `true`). Only the URL a
|
|
225
|
+
* platform error names depends on it; the fake serves the same data.
|
|
226
|
+
*/
|
|
227
|
+
useCdn?: boolean;
|
|
212
228
|
}
|
|
213
229
|
|
|
214
230
|
/**
|
|
@@ -726,16 +742,24 @@ export declare class PlatformHttpError extends ClientError {
|
|
|
726
742
|
constructor(args: PlatformResponseArgs);
|
|
727
743
|
}
|
|
728
744
|
|
|
729
|
-
/** A request the platform answers.
|
|
745
|
+
/** A request the platform answers. */
|
|
730
746
|
declare interface PlatformRequest {
|
|
731
747
|
method: "GET" | "POST";
|
|
748
|
+
/** The API path the platform routes on, without host, API version or query string. */
|
|
732
749
|
path: string;
|
|
750
|
+
/**
|
|
751
|
+
* The full URL `@sanity/client` requests, host, `/v<apiVersion>` and query
|
|
752
|
+
* string included, which its errors carry as `response.url` (see
|
|
753
|
+
* `./request-url.ts`).
|
|
754
|
+
*/
|
|
755
|
+
url: string;
|
|
733
756
|
}
|
|
734
757
|
|
|
735
758
|
/** What the platform answered, and to which request. */
|
|
736
759
|
declare interface PlatformResponseArgs {
|
|
737
760
|
method: string;
|
|
738
|
-
|
|
761
|
+
/** The URL `@sanity/client` requested; see {@link PlatformRequest.url}. */
|
|
762
|
+
url: string;
|
|
739
763
|
statusCode: number;
|
|
740
764
|
statusMessage: string;
|
|
741
765
|
body: unknown;
|
|
@@ -1087,6 +1111,12 @@ export declare interface TestClient {
|
|
|
1087
1111
|
requestTagPrefix?: string;
|
|
1088
1112
|
token?: string;
|
|
1089
1113
|
useProjectHostname: boolean;
|
|
1114
|
+
/** The API host, `https://api.sanity.io` unless configured. */
|
|
1115
|
+
apiHost: string;
|
|
1116
|
+
/** The API version, without a leading `v`; `"1"` unless configured, as in `@sanity/client`. */
|
|
1117
|
+
apiVersion: string;
|
|
1118
|
+
/** Whether GET reads of the data API go to the API CDN; `true` unless configured `false`. */
|
|
1119
|
+
useCdn: boolean;
|
|
1090
1120
|
};
|
|
1091
1121
|
/**
|
|
1092
1122
|
* Return a new client handle pointing at a different `(projectId, dataset)`
|
|
@@ -1106,8 +1136,8 @@ export declare interface TestClient {
|
|
|
1106
1136
|
*/
|
|
1107
1137
|
resource: TestClientResource | undefined;
|
|
1108
1138
|
perspective: Perspective;
|
|
1109
|
-
/** Prefix composed with request tags and used alone for untagged requests. */
|
|
1110
|
-
requestTagPrefix: string;
|
|
1139
|
+
/** Prefix composed with request tags and used alone for untagged requests; `undefined` unsets it. */
|
|
1140
|
+
requestTagPrefix: string | undefined;
|
|
1111
1141
|
/**
|
|
1112
1142
|
* Model the global API host (`false`) instead of the project host
|
|
1113
1143
|
* (default `true`). A global-hosted sibling's `/users/me` serves the
|
|
@@ -1116,6 +1146,12 @@ export declare interface TestClient {
|
|
|
1116
1146
|
* config routes requests to `api.sanity.io`.
|
|
1117
1147
|
*/
|
|
1118
1148
|
useProjectHostname: boolean;
|
|
1149
|
+
/** See {@link CreateTestClientOptions.apiHost}. */
|
|
1150
|
+
apiHost: string;
|
|
1151
|
+
/** See {@link CreateTestClientOptions.apiVersion}. */
|
|
1152
|
+
apiVersion: string;
|
|
1153
|
+
/** See {@link CreateTestClientOptions.useCdn}. */
|
|
1154
|
+
useCdn: boolean;
|
|
1119
1155
|
/**
|
|
1120
1156
|
* Rebind the acting identity (and its grants) on a sibling that shares
|
|
1121
1157
|
* the same store — the test analogue of a token-scoped client. Lets two
|
package/dist/index.d.ts
CHANGED
|
@@ -209,6 +209,22 @@ export declare interface CreateTestClientOptions {
|
|
|
209
209
|
* mints siblings on the other host.
|
|
210
210
|
*/
|
|
211
211
|
useProjectHostname?: boolean;
|
|
212
|
+
/**
|
|
213
|
+
* The API host, as the real `createClient` config names it (default
|
|
214
|
+
* `https://api.sanity.io`). With {@link apiVersion}, `useCdn` and the
|
|
215
|
+
* host flag it decides the URL a platform error carries as
|
|
216
|
+
* `response.url`: the URL `@sanity/client` would have requested, e.g.
|
|
217
|
+
* `https://p1.api.sanity.io/v2025-02-19/data/doc/production/x?tag=t`.
|
|
218
|
+
*/
|
|
219
|
+
apiHost?: string;
|
|
220
|
+
/** The API version (default `"1"`, as in `@sanity/client`): `"YYYY-MM-DD"`, `"X"` or `"1"`, `v` prefix optional. */
|
|
221
|
+
apiVersion?: string;
|
|
222
|
+
/**
|
|
223
|
+
* Whether GET reads of the data API (queries, documents, history) go to
|
|
224
|
+
* the API CDN, as in `@sanity/client` (default `true`). Only the URL a
|
|
225
|
+
* platform error names depends on it; the fake serves the same data.
|
|
226
|
+
*/
|
|
227
|
+
useCdn?: boolean;
|
|
212
228
|
}
|
|
213
229
|
|
|
214
230
|
/**
|
|
@@ -726,16 +742,24 @@ export declare class PlatformHttpError extends ClientError {
|
|
|
726
742
|
constructor(args: PlatformResponseArgs);
|
|
727
743
|
}
|
|
728
744
|
|
|
729
|
-
/** A request the platform answers.
|
|
745
|
+
/** A request the platform answers. */
|
|
730
746
|
declare interface PlatformRequest {
|
|
731
747
|
method: "GET" | "POST";
|
|
748
|
+
/** The API path the platform routes on, without host, API version or query string. */
|
|
732
749
|
path: string;
|
|
750
|
+
/**
|
|
751
|
+
* The full URL `@sanity/client` requests, host, `/v<apiVersion>` and query
|
|
752
|
+
* string included, which its errors carry as `response.url` (see
|
|
753
|
+
* `./request-url.ts`).
|
|
754
|
+
*/
|
|
755
|
+
url: string;
|
|
733
756
|
}
|
|
734
757
|
|
|
735
758
|
/** What the platform answered, and to which request. */
|
|
736
759
|
declare interface PlatformResponseArgs {
|
|
737
760
|
method: string;
|
|
738
|
-
|
|
761
|
+
/** The URL `@sanity/client` requested; see {@link PlatformRequest.url}. */
|
|
762
|
+
url: string;
|
|
739
763
|
statusCode: number;
|
|
740
764
|
statusMessage: string;
|
|
741
765
|
body: unknown;
|
|
@@ -1087,6 +1111,12 @@ export declare interface TestClient {
|
|
|
1087
1111
|
requestTagPrefix?: string;
|
|
1088
1112
|
token?: string;
|
|
1089
1113
|
useProjectHostname: boolean;
|
|
1114
|
+
/** The API host, `https://api.sanity.io` unless configured. */
|
|
1115
|
+
apiHost: string;
|
|
1116
|
+
/** The API version, without a leading `v`; `"1"` unless configured, as in `@sanity/client`. */
|
|
1117
|
+
apiVersion: string;
|
|
1118
|
+
/** Whether GET reads of the data API go to the API CDN; `true` unless configured `false`. */
|
|
1119
|
+
useCdn: boolean;
|
|
1090
1120
|
};
|
|
1091
1121
|
/**
|
|
1092
1122
|
* Return a new client handle pointing at a different `(projectId, dataset)`
|
|
@@ -1106,8 +1136,8 @@ export declare interface TestClient {
|
|
|
1106
1136
|
*/
|
|
1107
1137
|
resource: TestClientResource | undefined;
|
|
1108
1138
|
perspective: Perspective;
|
|
1109
|
-
/** Prefix composed with request tags and used alone for untagged requests. */
|
|
1110
|
-
requestTagPrefix: string;
|
|
1139
|
+
/** Prefix composed with request tags and used alone for untagged requests; `undefined` unsets it. */
|
|
1140
|
+
requestTagPrefix: string | undefined;
|
|
1111
1141
|
/**
|
|
1112
1142
|
* Model the global API host (`false`) instead of the project host
|
|
1113
1143
|
* (default `true`). A global-hosted sibling's `/users/me` serves the
|
|
@@ -1116,6 +1146,12 @@ export declare interface TestClient {
|
|
|
1116
1146
|
* config routes requests to `api.sanity.io`.
|
|
1117
1147
|
*/
|
|
1118
1148
|
useProjectHostname: boolean;
|
|
1149
|
+
/** See {@link CreateTestClientOptions.apiHost}. */
|
|
1150
|
+
apiHost: string;
|
|
1151
|
+
/** See {@link CreateTestClientOptions.apiVersion}. */
|
|
1152
|
+
apiVersion: string;
|
|
1153
|
+
/** See {@link CreateTestClientOptions.useCdn}. */
|
|
1154
|
+
useCdn: boolean;
|
|
1119
1155
|
/**
|
|
1120
1156
|
* Rebind the acting identity (and its grants) on a sibling that shares
|
|
1121
1157
|
* the same store — the test analogue of a token-scoped client. Lets two
|