@sanity-labs/client-fake-for-test 0.30.0 → 0.32.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 +204 -129
- package/dist/index.cjs +443 -33
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +56 -0
- package/dist/index.d.ts +56 -0
- package/dist/index.js +443 -33
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -557,6 +557,18 @@ export declare interface GuardDeniedResponse {
|
|
|
557
557
|
statusMessage: "Forbidden";
|
|
558
558
|
}
|
|
559
559
|
|
|
560
|
+
/** What `@sanity/client` hands a `requestHandler`, as far as the fake reads it. */
|
|
561
|
+
declare interface HandledRequestOptions {
|
|
562
|
+
url?: string | undefined;
|
|
563
|
+
method?: string | undefined;
|
|
564
|
+
headers?: [string, string][] | Record<string, string> | Headers | undefined;
|
|
565
|
+
body?: unknown;
|
|
566
|
+
query?:
|
|
567
|
+
| URLSearchParams
|
|
568
|
+
| Record<string, string | number | boolean | undefined>
|
|
569
|
+
| undefined;
|
|
570
|
+
}
|
|
571
|
+
|
|
560
572
|
/** An event as `GET <data base>/history/events/documents/<ids>` serves it. */
|
|
561
573
|
export declare interface HistoryEvent {
|
|
562
574
|
type: "createLiveDocument" | "updateLiveDocument";
|
|
@@ -654,6 +666,15 @@ export declare interface MutationLogEntry {
|
|
|
654
666
|
dataset: string;
|
|
655
667
|
/** The resource the transaction targeted, on a `resource`-configured handle. */
|
|
656
668
|
resource?: TestClientResource;
|
|
669
|
+
/**
|
|
670
|
+
* The organization store the transaction targeted, for a write over the
|
|
671
|
+
* Workflows store routes; `projectId` and `dataset` are then the calling
|
|
672
|
+
* handle's, not where the write landed.
|
|
673
|
+
*/
|
|
674
|
+
organizationStore?: {
|
|
675
|
+
id: string;
|
|
676
|
+
organizationId: string;
|
|
677
|
+
};
|
|
657
678
|
mutations: TxnMutation[];
|
|
658
679
|
/** Request tag the commit carried, when one was passed (`null` = explicit suppression). */
|
|
659
680
|
tag?: string | null;
|
|
@@ -693,6 +714,14 @@ export declare interface MutationOptions {
|
|
|
693
714
|
tag?: string | null;
|
|
694
715
|
}
|
|
695
716
|
|
|
717
|
+
/**
|
|
718
|
+
* A store id in populus's format, `os` and ten characters
|
|
719
|
+
* (`organizationStoreService.ts:47-51`), without a segment populus disallows
|
|
720
|
+
* (`src/util/createUniqueId.js:39-41`). Derived from the organization so a
|
|
721
|
+
* test can name it before the lookup.
|
|
722
|
+
*/
|
|
723
|
+
export declare function organizationStoreId(organizationId: string): string;
|
|
724
|
+
|
|
696
725
|
/** The statuses populus serves a store in. */
|
|
697
726
|
declare type OrganizationStoreStatus = "provisioning" | "active";
|
|
698
727
|
|
|
@@ -1326,6 +1355,25 @@ export declare interface TestClient {
|
|
|
1326
1355
|
* store whose provisioning never completes stays `provisioning`.
|
|
1327
1356
|
*/
|
|
1328
1357
|
completeOrganizationStoreProvisioning: (organizationId: string) => void;
|
|
1358
|
+
/**
|
|
1359
|
+
* The documents of the organization's store, the Workflows store, which
|
|
1360
|
+
* the Workflows store routes of {@link TestClient.request} read and write:
|
|
1361
|
+
* seed it, or read what a test wrote. Throws unless the organization has a
|
|
1362
|
+
* store (seed `organizationStores`, or look it up first). Seeding does not
|
|
1363
|
+
* change the store's status; the routes serve it once it is `active`.
|
|
1364
|
+
*/
|
|
1365
|
+
organizationStore: (organizationId: string) => TestStore;
|
|
1366
|
+
/**
|
|
1367
|
+
* A `requestHandler` for a real `@sanity/client`, so code that builds its
|
|
1368
|
+
* own client runs against this fake: `createClient({ ...config,
|
|
1369
|
+
* requestHandler: fake.requestHandler() })`. Each request is answered as
|
|
1370
|
+
* {@link TestClient.request} answers it on a sibling bound to the
|
|
1371
|
+
* request's bearer token, API host and API version, and resolves to the
|
|
1372
|
+
* response body. Requests the fake's `request()` does not serve throw its
|
|
1373
|
+
* fake error, as `request()` does; route data API calls through the fake's
|
|
1374
|
+
* own methods instead.
|
|
1375
|
+
*/
|
|
1376
|
+
requestHandler: () => (options: HandledRequestOptions) => Promise<unknown>;
|
|
1329
1377
|
/**
|
|
1330
1378
|
* Deploy a function, or replace the one with its id, for every handle of
|
|
1331
1379
|
* the family. Throws for an id shorter than 10 characters, an unknown
|
|
@@ -1483,6 +1531,14 @@ export declare interface TestClientIdentity {
|
|
|
1483
1531
|
* `…/robots/<id>` instead of `…/users`, and it is never a user row.
|
|
1484
1532
|
*/
|
|
1485
1533
|
robot?: true;
|
|
1534
|
+
/**
|
|
1535
|
+
* The organization an organization-scoped token is limited to. The
|
|
1536
|
+
* Content Lake refuses it on another organization's store with 403
|
|
1537
|
+
* `permissionDeniedError`, `Unauthorized organization access` (gradient
|
|
1538
|
+
* `pkg/system/session.go:71-94`). Omit for a token with no organization
|
|
1539
|
+
* scope.
|
|
1540
|
+
*/
|
|
1541
|
+
organizationScope?: string;
|
|
1486
1542
|
}
|
|
1487
1543
|
|
|
1488
1544
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -557,6 +557,18 @@ export declare interface GuardDeniedResponse {
|
|
|
557
557
|
statusMessage: "Forbidden";
|
|
558
558
|
}
|
|
559
559
|
|
|
560
|
+
/** What `@sanity/client` hands a `requestHandler`, as far as the fake reads it. */
|
|
561
|
+
declare interface HandledRequestOptions {
|
|
562
|
+
url?: string | undefined;
|
|
563
|
+
method?: string | undefined;
|
|
564
|
+
headers?: [string, string][] | Record<string, string> | Headers | undefined;
|
|
565
|
+
body?: unknown;
|
|
566
|
+
query?:
|
|
567
|
+
| URLSearchParams
|
|
568
|
+
| Record<string, string | number | boolean | undefined>
|
|
569
|
+
| undefined;
|
|
570
|
+
}
|
|
571
|
+
|
|
560
572
|
/** An event as `GET <data base>/history/events/documents/<ids>` serves it. */
|
|
561
573
|
export declare interface HistoryEvent {
|
|
562
574
|
type: "createLiveDocument" | "updateLiveDocument";
|
|
@@ -654,6 +666,15 @@ export declare interface MutationLogEntry {
|
|
|
654
666
|
dataset: string;
|
|
655
667
|
/** The resource the transaction targeted, on a `resource`-configured handle. */
|
|
656
668
|
resource?: TestClientResource;
|
|
669
|
+
/**
|
|
670
|
+
* The organization store the transaction targeted, for a write over the
|
|
671
|
+
* Workflows store routes; `projectId` and `dataset` are then the calling
|
|
672
|
+
* handle's, not where the write landed.
|
|
673
|
+
*/
|
|
674
|
+
organizationStore?: {
|
|
675
|
+
id: string;
|
|
676
|
+
organizationId: string;
|
|
677
|
+
};
|
|
657
678
|
mutations: TxnMutation[];
|
|
658
679
|
/** Request tag the commit carried, when one was passed (`null` = explicit suppression). */
|
|
659
680
|
tag?: string | null;
|
|
@@ -693,6 +714,14 @@ export declare interface MutationOptions {
|
|
|
693
714
|
tag?: string | null;
|
|
694
715
|
}
|
|
695
716
|
|
|
717
|
+
/**
|
|
718
|
+
* A store id in populus's format, `os` and ten characters
|
|
719
|
+
* (`organizationStoreService.ts:47-51`), without a segment populus disallows
|
|
720
|
+
* (`src/util/createUniqueId.js:39-41`). Derived from the organization so a
|
|
721
|
+
* test can name it before the lookup.
|
|
722
|
+
*/
|
|
723
|
+
export declare function organizationStoreId(organizationId: string): string;
|
|
724
|
+
|
|
696
725
|
/** The statuses populus serves a store in. */
|
|
697
726
|
declare type OrganizationStoreStatus = "provisioning" | "active";
|
|
698
727
|
|
|
@@ -1326,6 +1355,25 @@ export declare interface TestClient {
|
|
|
1326
1355
|
* store whose provisioning never completes stays `provisioning`.
|
|
1327
1356
|
*/
|
|
1328
1357
|
completeOrganizationStoreProvisioning: (organizationId: string) => void;
|
|
1358
|
+
/**
|
|
1359
|
+
* The documents of the organization's store, the Workflows store, which
|
|
1360
|
+
* the Workflows store routes of {@link TestClient.request} read and write:
|
|
1361
|
+
* seed it, or read what a test wrote. Throws unless the organization has a
|
|
1362
|
+
* store (seed `organizationStores`, or look it up first). Seeding does not
|
|
1363
|
+
* change the store's status; the routes serve it once it is `active`.
|
|
1364
|
+
*/
|
|
1365
|
+
organizationStore: (organizationId: string) => TestStore;
|
|
1366
|
+
/**
|
|
1367
|
+
* A `requestHandler` for a real `@sanity/client`, so code that builds its
|
|
1368
|
+
* own client runs against this fake: `createClient({ ...config,
|
|
1369
|
+
* requestHandler: fake.requestHandler() })`. Each request is answered as
|
|
1370
|
+
* {@link TestClient.request} answers it on a sibling bound to the
|
|
1371
|
+
* request's bearer token, API host and API version, and resolves to the
|
|
1372
|
+
* response body. Requests the fake's `request()` does not serve throw its
|
|
1373
|
+
* fake error, as `request()` does; route data API calls through the fake's
|
|
1374
|
+
* own methods instead.
|
|
1375
|
+
*/
|
|
1376
|
+
requestHandler: () => (options: HandledRequestOptions) => Promise<unknown>;
|
|
1329
1377
|
/**
|
|
1330
1378
|
* Deploy a function, or replace the one with its id, for every handle of
|
|
1331
1379
|
* the family. Throws for an id shorter than 10 characters, an unknown
|
|
@@ -1483,6 +1531,14 @@ export declare interface TestClientIdentity {
|
|
|
1483
1531
|
* `…/robots/<id>` instead of `…/users`, and it is never a user row.
|
|
1484
1532
|
*/
|
|
1485
1533
|
robot?: true;
|
|
1534
|
+
/**
|
|
1535
|
+
* The organization an organization-scoped token is limited to. The
|
|
1536
|
+
* Content Lake refuses it on another organization's store with 403
|
|
1537
|
+
* `permissionDeniedError`, `Unauthorized organization access` (gradient
|
|
1538
|
+
* `pkg/system/session.go:71-94`). Omit for a token with no organization
|
|
1539
|
+
* scope.
|
|
1540
|
+
*/
|
|
1541
|
+
organizationScope?: string;
|
|
1486
1542
|
}
|
|
1487
1543
|
|
|
1488
1544
|
/**
|