@sanity-labs/client-fake-for-test 0.15.0 → 0.17.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 +41 -4
- package/dist/index.cjs +274 -94
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +55 -12
- package/dist/index.d.ts +55 -12
- package/dist/index.js +274 -94
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -128,11 +128,18 @@ export declare interface CreateTestClientOptions {
|
|
|
128
128
|
* `/projects/<projectId>` answer as `organizationId`.
|
|
129
129
|
*/
|
|
130
130
|
organizationId?: string;
|
|
131
|
+
/**
|
|
132
|
+
* The features each project has, keyed by projectId: what
|
|
133
|
+
* `GET /projects/<projectId>/features` answers, sorted. A project
|
|
134
|
+
* without an entry has none and answers `[]`.
|
|
135
|
+
*/
|
|
136
|
+
projectFeatures?: Record<string, string[]>;
|
|
131
137
|
/**
|
|
132
138
|
* Opt-in access-control simulation. When set, the client exposes
|
|
133
139
|
* `request({ url })` that serves `/users/me` (host-aware), the
|
|
134
|
-
* configured ACL path, `/projects/<projectId>` (members),
|
|
135
|
-
* `/projects/<projectId>/users/<ids>`,
|
|
140
|
+
* configured ACL path, `/projects/<projectId>` (members),
|
|
141
|
+
* `/projects/<projectId>/users/<ids>`, `/projects/<projectId>/roles`,
|
|
142
|
+
* `/projects/<projectId>/features` and the other platform routes,
|
|
136
143
|
* AND every mutation is gated through the supplied `grants`
|
|
137
144
|
* — writes that the grants don't permit throw a `WriteAccessDeniedError`
|
|
138
145
|
* shaped like Sanity's 403. Lets tests demonstrate the full
|
|
@@ -401,10 +408,25 @@ export declare interface FetchOptions {
|
|
|
401
408
|
signal?: AbortSignal;
|
|
402
409
|
}
|
|
403
410
|
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
}
|
|
411
|
+
/**
|
|
412
|
+
* One grant: `permissions` on the documents a GROQ `filter` matches, as an
|
|
413
|
+
* ACL serves them, or on the ids a `path()` glob matches, as a token
|
|
414
|
+
* carries them (the token's `{ s, p }`). The Content Lake holds a grant as
|
|
415
|
+
* one or the other and evaluates a path grant as `_id in path("<path>")`
|
|
416
|
+
* (gradient `pkg/security/models.go` `Grant`, `FilterExpression`). A token
|
|
417
|
+
* grant's permissions are whatever the token names; the Content Lake
|
|
418
|
+
* refuses the token when one is not a permission it knows, or when the
|
|
419
|
+
* path does not parse (see `./token-grants.ts`).
|
|
420
|
+
*/
|
|
421
|
+
export declare type Grant =
|
|
422
|
+
| {
|
|
423
|
+
filter: string;
|
|
424
|
+
permissions: DocumentValuePermission[];
|
|
425
|
+
}
|
|
426
|
+
| {
|
|
427
|
+
path: string;
|
|
428
|
+
permissions: string[];
|
|
429
|
+
};
|
|
408
430
|
|
|
409
431
|
export declare interface GuardConfig {
|
|
410
432
|
/**
|
|
@@ -1004,12 +1026,25 @@ export declare interface TestClient {
|
|
|
1004
1026
|
) => Promise<ActionResult>;
|
|
1005
1027
|
/** Helpers mirroring `@sanity/client`'s `client.releases.*` surface. */
|
|
1006
1028
|
releases: ReleasesHandle;
|
|
1007
|
-
/**
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1029
|
+
/**
|
|
1030
|
+
* Helper for `sanity.action.document.version.create`: writes `document`, or,
|
|
1031
|
+
* given `baseId` (as `@sanity/client` takes it), copies that document into
|
|
1032
|
+
* `versions.<releaseId>.<publishedId>`.
|
|
1033
|
+
*/
|
|
1034
|
+
createVersion: (
|
|
1035
|
+
params:
|
|
1036
|
+
| {
|
|
1037
|
+
releaseId: string;
|
|
1038
|
+
publishedId: string;
|
|
1039
|
+
document: DocumentBody;
|
|
1040
|
+
}
|
|
1041
|
+
| {
|
|
1042
|
+
releaseId: string;
|
|
1043
|
+
publishedId: string;
|
|
1044
|
+
baseId: string;
|
|
1045
|
+
ifBaseRevisionId?: string;
|
|
1046
|
+
},
|
|
1047
|
+
) => Promise<ActionResult>;
|
|
1013
1048
|
/** Helper for `sanity.action.document.version.unpublish`. */
|
|
1014
1049
|
unpublishVersion: (params: {
|
|
1015
1050
|
releaseId: string;
|
|
@@ -1401,6 +1436,14 @@ export declare type VersionAction =
|
|
|
1401
1436
|
document: DocumentBody;
|
|
1402
1437
|
releaseId?: string;
|
|
1403
1438
|
}
|
|
1439
|
+
| {
|
|
1440
|
+
/** Copy the document at `baseId` into `versionId`, as `@sanity/client` sends `createVersion({ baseId })`. */
|
|
1441
|
+
actionType: "sanity.action.document.version.create";
|
|
1442
|
+
publishedId: string;
|
|
1443
|
+
baseId: string;
|
|
1444
|
+
versionId: string;
|
|
1445
|
+
ifBaseRevisionId?: string;
|
|
1446
|
+
}
|
|
1404
1447
|
| {
|
|
1405
1448
|
actionType: "sanity.action.document.version.replace";
|
|
1406
1449
|
document: SanityDocumentLike;
|
package/dist/index.d.ts
CHANGED
|
@@ -128,11 +128,18 @@ export declare interface CreateTestClientOptions {
|
|
|
128
128
|
* `/projects/<projectId>` answer as `organizationId`.
|
|
129
129
|
*/
|
|
130
130
|
organizationId?: string;
|
|
131
|
+
/**
|
|
132
|
+
* The features each project has, keyed by projectId: what
|
|
133
|
+
* `GET /projects/<projectId>/features` answers, sorted. A project
|
|
134
|
+
* without an entry has none and answers `[]`.
|
|
135
|
+
*/
|
|
136
|
+
projectFeatures?: Record<string, string[]>;
|
|
131
137
|
/**
|
|
132
138
|
* Opt-in access-control simulation. When set, the client exposes
|
|
133
139
|
* `request({ url })` that serves `/users/me` (host-aware), the
|
|
134
|
-
* configured ACL path, `/projects/<projectId>` (members),
|
|
135
|
-
* `/projects/<projectId>/users/<ids>`,
|
|
140
|
+
* configured ACL path, `/projects/<projectId>` (members),
|
|
141
|
+
* `/projects/<projectId>/users/<ids>`, `/projects/<projectId>/roles`,
|
|
142
|
+
* `/projects/<projectId>/features` and the other platform routes,
|
|
136
143
|
* AND every mutation is gated through the supplied `grants`
|
|
137
144
|
* — writes that the grants don't permit throw a `WriteAccessDeniedError`
|
|
138
145
|
* shaped like Sanity's 403. Lets tests demonstrate the full
|
|
@@ -401,10 +408,25 @@ export declare interface FetchOptions {
|
|
|
401
408
|
signal?: AbortSignal;
|
|
402
409
|
}
|
|
403
410
|
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
}
|
|
411
|
+
/**
|
|
412
|
+
* One grant: `permissions` on the documents a GROQ `filter` matches, as an
|
|
413
|
+
* ACL serves them, or on the ids a `path()` glob matches, as a token
|
|
414
|
+
* carries them (the token's `{ s, p }`). The Content Lake holds a grant as
|
|
415
|
+
* one or the other and evaluates a path grant as `_id in path("<path>")`
|
|
416
|
+
* (gradient `pkg/security/models.go` `Grant`, `FilterExpression`). A token
|
|
417
|
+
* grant's permissions are whatever the token names; the Content Lake
|
|
418
|
+
* refuses the token when one is not a permission it knows, or when the
|
|
419
|
+
* path does not parse (see `./token-grants.ts`).
|
|
420
|
+
*/
|
|
421
|
+
export declare type Grant =
|
|
422
|
+
| {
|
|
423
|
+
filter: string;
|
|
424
|
+
permissions: DocumentValuePermission[];
|
|
425
|
+
}
|
|
426
|
+
| {
|
|
427
|
+
path: string;
|
|
428
|
+
permissions: string[];
|
|
429
|
+
};
|
|
408
430
|
|
|
409
431
|
export declare interface GuardConfig {
|
|
410
432
|
/**
|
|
@@ -1004,12 +1026,25 @@ export declare interface TestClient {
|
|
|
1004
1026
|
) => Promise<ActionResult>;
|
|
1005
1027
|
/** Helpers mirroring `@sanity/client`'s `client.releases.*` surface. */
|
|
1006
1028
|
releases: ReleasesHandle;
|
|
1007
|
-
/**
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1029
|
+
/**
|
|
1030
|
+
* Helper for `sanity.action.document.version.create`: writes `document`, or,
|
|
1031
|
+
* given `baseId` (as `@sanity/client` takes it), copies that document into
|
|
1032
|
+
* `versions.<releaseId>.<publishedId>`.
|
|
1033
|
+
*/
|
|
1034
|
+
createVersion: (
|
|
1035
|
+
params:
|
|
1036
|
+
| {
|
|
1037
|
+
releaseId: string;
|
|
1038
|
+
publishedId: string;
|
|
1039
|
+
document: DocumentBody;
|
|
1040
|
+
}
|
|
1041
|
+
| {
|
|
1042
|
+
releaseId: string;
|
|
1043
|
+
publishedId: string;
|
|
1044
|
+
baseId: string;
|
|
1045
|
+
ifBaseRevisionId?: string;
|
|
1046
|
+
},
|
|
1047
|
+
) => Promise<ActionResult>;
|
|
1013
1048
|
/** Helper for `sanity.action.document.version.unpublish`. */
|
|
1014
1049
|
unpublishVersion: (params: {
|
|
1015
1050
|
releaseId: string;
|
|
@@ -1401,6 +1436,14 @@ export declare type VersionAction =
|
|
|
1401
1436
|
document: DocumentBody;
|
|
1402
1437
|
releaseId?: string;
|
|
1403
1438
|
}
|
|
1439
|
+
| {
|
|
1440
|
+
/** Copy the document at `baseId` into `versionId`, as `@sanity/client` sends `createVersion({ baseId })`. */
|
|
1441
|
+
actionType: "sanity.action.document.version.create";
|
|
1442
|
+
publishedId: string;
|
|
1443
|
+
baseId: string;
|
|
1444
|
+
versionId: string;
|
|
1445
|
+
ifBaseRevisionId?: string;
|
|
1446
|
+
}
|
|
1404
1447
|
| {
|
|
1405
1448
|
actionType: "sanity.action.document.version.replace";
|
|
1406
1449
|
document: SanityDocumentLike;
|