@payloadcms/sdk 3.71.0-internal.727c7a4 → 3.71.0-internal.e36f916
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/auth/forgotPassword.d.ts +5 -4
- package/dist/auth/forgotPassword.d.ts.map +1 -1
- package/dist/auth/forgotPassword.js.map +1 -1
- package/dist/auth/login.d.ts +9 -5
- package/dist/auth/login.d.ts.map +1 -1
- package/dist/auth/login.js.map +1 -1
- package/dist/auth/me.d.ts +5 -4
- package/dist/auth/me.d.ts.map +1 -1
- package/dist/auth/me.js.map +1 -1
- package/dist/auth/refreshToken.d.ts +5 -4
- package/dist/auth/refreshToken.d.ts.map +1 -1
- package/dist/auth/refreshToken.js.map +1 -1
- package/dist/auth/resetPassword.d.ts +5 -4
- package/dist/auth/resetPassword.d.ts.map +1 -1
- package/dist/auth/resetPassword.js.map +1 -1
- package/dist/auth/verifyEmail.d.ts +3 -3
- package/dist/auth/verifyEmail.d.ts.map +1 -1
- package/dist/auth/verifyEmail.js.map +1 -1
- package/dist/collections/count.d.ts +3 -4
- package/dist/collections/count.d.ts.map +1 -1
- package/dist/collections/count.js.map +1 -1
- package/dist/collections/create.d.ts +4 -4
- package/dist/collections/create.d.ts.map +1 -1
- package/dist/collections/create.js.map +1 -1
- package/dist/collections/delete.d.ts +7 -7
- package/dist/collections/delete.d.ts.map +1 -1
- package/dist/collections/delete.js.map +1 -1
- package/dist/collections/find.d.ts +4 -4
- package/dist/collections/find.d.ts.map +1 -1
- package/dist/collections/find.js.map +1 -1
- package/dist/collections/findByID.d.ts +4 -4
- package/dist/collections/findByID.d.ts.map +1 -1
- package/dist/collections/findByID.js +3 -7
- package/dist/collections/findByID.js.map +1 -1
- package/dist/collections/findVersionByID.d.ts +4 -4
- package/dist/collections/findVersionByID.d.ts.map +1 -1
- package/dist/collections/findVersionByID.js +3 -7
- package/dist/collections/findVersionByID.js.map +1 -1
- package/dist/collections/findVersions.d.ts +4 -4
- package/dist/collections/findVersions.d.ts.map +1 -1
- package/dist/collections/findVersions.js.map +1 -1
- package/dist/collections/restoreVersion.d.ts +4 -3
- package/dist/collections/restoreVersion.d.ts.map +1 -1
- package/dist/collections/restoreVersion.js.map +1 -1
- package/dist/collections/update.d.ts +7 -7
- package/dist/collections/update.d.ts.map +1 -1
- package/dist/collections/update.js.map +1 -1
- package/dist/errors/PayloadSDKError.d.ts +23 -0
- package/dist/errors/PayloadSDKError.d.ts.map +1 -0
- package/dist/errors/PayloadSDKError.js +20 -0
- package/dist/errors/PayloadSDKError.js.map +1 -0
- package/dist/globals/findOne.d.ts +4 -4
- package/dist/globals/findOne.d.ts.map +1 -1
- package/dist/globals/findOne.js.map +1 -1
- package/dist/globals/findVersionByID.d.ts +4 -4
- package/dist/globals/findVersionByID.d.ts.map +1 -1
- package/dist/globals/findVersionByID.js +3 -7
- package/dist/globals/findVersionByID.js.map +1 -1
- package/dist/globals/findVersions.d.ts +4 -4
- package/dist/globals/findVersions.d.ts.map +1 -1
- package/dist/globals/findVersions.js.map +1 -1
- package/dist/globals/restoreVersion.d.ts +4 -4
- package/dist/globals/restoreVersion.d.ts.map +1 -1
- package/dist/globals/restoreVersion.js.map +1 -1
- package/dist/globals/update.d.ts +4 -4
- package/dist/globals/update.d.ts.map +1 -1
- package/dist/globals/update.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +27 -72
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utilities/buildSearchParams.d.ts +4 -4
- package/dist/utilities/buildSearchParams.d.ts.map +1 -1
- package/dist/utilities/buildSearchParams.js.map +1 -1
- package/package.json +2 -2
|
@@ -6,17 +6,13 @@ export async function findVersionByID(sdk, options, init) {
|
|
|
6
6
|
method: 'GET',
|
|
7
7
|
path: `/${options.collection}/versions/${options.id}`
|
|
8
8
|
});
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
} else {
|
|
12
|
-
throw new Error();
|
|
13
|
-
}
|
|
14
|
-
} catch {
|
|
9
|
+
return response.json();
|
|
10
|
+
} catch (err) {
|
|
15
11
|
if (options.disableErrors) {
|
|
16
12
|
// @ts-expect-error generic nullable
|
|
17
13
|
return null;
|
|
18
14
|
}
|
|
19
|
-
throw
|
|
15
|
+
throw err;
|
|
20
16
|
}
|
|
21
17
|
}
|
|
22
18
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/collections/findVersionByID.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"sources":["../../src/collections/findVersionByID.ts"],"sourcesContent":["import type {\n ApplyDisableErrors,\n CollectionSlug,\n PayloadTypesShape,\n SelectType,\n TypedLocale,\n TypeWithVersion,\n} from 'payload'\n\nimport type { PayloadSDK } from '../index.js'\nimport type { DataFromCollectionSlug, PopulateType } from '../types.js'\n\nexport type FindVersionByIDOptions<\n T extends PayloadTypesShape,\n TSlug extends CollectionSlug<T>,\n TDisableErrors extends boolean,\n> = {\n /**\n * the Collection slug to operate against.\n */\n collection: TSlug\n /**\n * [Control auto-population](https://payloadcms.com/docs/queries/depth) of nested relationship and upload fields.\n */\n depth?: number\n /**\n * When set to `true`, errors will not be thrown.\n * `null` will be returned instead, if the document on this ID was not found.\n */\n disableErrors?: TDisableErrors\n /**\n * Whether the document should be queried from the versions table/collection or not. [More](https://payloadcms.com/docs/versions/drafts#draft-api)\n */\n draft?: boolean\n /**\n * Specify a [fallback locale](https://payloadcms.com/docs/configuration/localization) to use for any returned documents.\n */\n fallbackLocale?: false | TypedLocale<T>\n /**\n * The ID of the version to find.\n */\n id: number | string\n /**\n * Specify [locale](https://payloadcms.com/docs/configuration/localization) for any returned documents.\n */\n locale?: 'all' | TypedLocale<T>\n /**\n * Specify [populate](https://payloadcms.com/docs/queries/select#populate) to control which fields to include to the result from populated documents.\n */\n populate?: PopulateType<T>\n /**\n * Specify [select](https://payloadcms.com/docs/queries/select) to control which fields to include to the result.\n */\n select?: SelectType\n /**\n * When set to `true`, the operation will return a document by ID, even if it is trashed (soft-deleted).\n * By default (`false`), the operation will exclude trashed documents.\n * To fetch a trashed document, set `trash: true`.\n *\n * This argument has no effect unless `trash` is enabled on the collection.\n * @default false\n */\n trash?: boolean\n}\n\nexport async function findVersionByID<\n T extends PayloadTypesShape,\n TSlug extends CollectionSlug<T>,\n TDisableErrors extends boolean,\n>(\n sdk: PayloadSDK<T>,\n options: FindVersionByIDOptions<T, TSlug, TDisableErrors>,\n init?: RequestInit,\n): Promise<ApplyDisableErrors<TypeWithVersion<DataFromCollectionSlug<T, TSlug>>, TDisableErrors>> {\n try {\n const response = await sdk.request({\n args: options,\n init,\n method: 'GET',\n path: `/${options.collection}/versions/${options.id}`,\n })\n\n return response.json()\n } catch (err) {\n if (options.disableErrors) {\n // @ts-expect-error generic nullable\n return null\n }\n\n throw err\n }\n}\n"],"names":["findVersionByID","sdk","options","init","response","request","args","method","path","collection","id","json","err","disableErrors"],"mappings":"AAiEA,OAAO,eAAeA,gBAKpBC,GAAkB,EAClBC,OAAyD,EACzDC,IAAkB;IAElB,IAAI;QACF,MAAMC,WAAW,MAAMH,IAAII,OAAO,CAAC;YACjCC,MAAMJ;YACNC;YACAI,QAAQ;YACRC,MAAM,CAAC,CAAC,EAAEN,QAAQO,UAAU,CAAC,UAAU,EAAEP,QAAQQ,EAAE,EAAE;QACvD;QAEA,OAAON,SAASO,IAAI;IACtB,EAAE,OAAOC,KAAK;QACZ,IAAIV,QAAQW,aAAa,EAAE;YACzB,oCAAoC;YACpC,OAAO;QACT;QAEA,MAAMD;IACR;AACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { PaginatedDocs, SelectType, Sort, TypeWithVersion, Where } from 'payload';
|
|
1
|
+
import type { CollectionSlug, PaginatedDocs, PayloadTypesShape, SelectType, Sort, TypedLocale, TypeWithVersion, Where } from 'payload';
|
|
2
2
|
import type { PayloadSDK } from '../index.js';
|
|
3
|
-
import type {
|
|
4
|
-
export type FindVersionsOptions<T extends
|
|
3
|
+
import type { DataFromCollectionSlug, PopulateType } from '../types.js';
|
|
4
|
+
export type FindVersionsOptions<T extends PayloadTypesShape, TSlug extends CollectionSlug<T>> = {
|
|
5
5
|
/**
|
|
6
6
|
* the Collection slug to operate against.
|
|
7
7
|
*/
|
|
@@ -66,5 +66,5 @@ export type FindVersionsOptions<T extends PayloadGeneratedTypes, TSlug extends C
|
|
|
66
66
|
*/
|
|
67
67
|
where?: Where;
|
|
68
68
|
};
|
|
69
|
-
export declare function findVersions<T extends
|
|
69
|
+
export declare function findVersions<T extends PayloadTypesShape, TSlug extends CollectionSlug<T>>(sdk: PayloadSDK<T>, options: FindVersionsOptions<T, TSlug>, init?: RequestInit): Promise<PaginatedDocs<TypeWithVersion<DataFromCollectionSlug<T, TSlug>>>>;
|
|
70
70
|
//# sourceMappingURL=findVersions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findVersions.d.ts","sourceRoot":"","sources":["../../src/collections/findVersions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"findVersions.d.ts","sourceRoot":"","sources":["../../src/collections/findVersions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,UAAU,EACV,IAAI,EACJ,WAAW,EACX,eAAe,EACf,KAAK,EACN,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,KAAK,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAEvE,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,iBAAiB,EAAE,KAAK,SAAS,cAAc,CAAC,CAAC,CAAC,IAAI;IAC9F;;OAEG;IACH,UAAU,EAAE,KAAK,CAAA;IACjB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAA;IACf;;OAEG;IACH,cAAc,CAAC,EAAE,KAAK,GAAG,WAAW,CAAC,CAAC,CAAC,CAAA;IACvC;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,MAAM,CAAC,EAAE,KAAK,GAAG,WAAW,CAAC,CAAC,CAAC,CAAA;IAC/B;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB;;OAEG;IACH,QAAQ,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,CAAA;IAC1B;;OAEG;IACH,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB;;;;OAIG;IACH,IAAI,CAAC,EAAE,IAAI,CAAA;IACX;;;;;;;OAOG;IACH,KAAK,CAAC,EAAE,OAAO,CAAA;IACf;;OAEG;IACH,KAAK,CAAC,EAAE,KAAK,CAAA;CACd,CAAA;AAED,wBAAsB,YAAY,CAAC,CAAC,SAAS,iBAAiB,EAAE,KAAK,SAAS,cAAc,CAAC,CAAC,CAAC,EAC7F,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,EAClB,OAAO,EAAE,mBAAmB,CAAC,CAAC,EAAE,KAAK,CAAC,EACtC,IAAI,CAAC,EAAE,WAAW,GACjB,OAAO,CAAC,aAAa,CAAC,eAAe,CAAC,sBAAsB,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAS3E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/collections/findVersions.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"sources":["../../src/collections/findVersions.ts"],"sourcesContent":["import type {\n CollectionSlug,\n PaginatedDocs,\n PayloadTypesShape,\n SelectType,\n Sort,\n TypedLocale,\n TypeWithVersion,\n Where,\n} from 'payload'\n\nimport type { PayloadSDK } from '../index.js'\nimport type { DataFromCollectionSlug, PopulateType } from '../types.js'\n\nexport type FindVersionsOptions<T extends PayloadTypesShape, TSlug extends CollectionSlug<T>> = {\n /**\n * the Collection slug to operate against.\n */\n collection: TSlug\n /**\n * [Control auto-population](https://payloadcms.com/docs/queries/depth) of nested relationship and upload fields.\n */\n depth?: number\n /**\n * Whether the documents should be queried from the versions table/collection or not. [More](https://payloadcms.com/docs/versions/drafts#draft-api)\n */\n draft?: boolean\n /**\n * Specify a [fallback locale](https://payloadcms.com/docs/configuration/localization) to use for any returned documents.\n */\n fallbackLocale?: false | TypedLocale<T>\n /**\n * The maximum related documents to be returned.\n * Defaults unless `defaultLimit` is specified for the collection config\n * @default 10\n */\n limit?: number\n /**\n * Specify [locale](https://payloadcms.com/docs/configuration/localization) for any returned documents.\n */\n locale?: 'all' | TypedLocale<T>\n /**\n * Get a specific page number\n * @default 1\n */\n page?: number\n /**\n * Set to `false` to return all documents and avoid querying for document counts which introduces some overhead.\n * You can also combine that property with a specified `limit` to limit documents but avoid the count query.\n */\n pagination?: boolean\n /**\n * Specify [populate](https://payloadcms.com/docs/queries/select#populate) to control which fields to include to the result from populated documents.\n */\n populate?: PopulateType<T>\n /**\n * Specify [select](https://payloadcms.com/docs/queries/select) to control which fields to include to the result.\n */\n select?: SelectType\n /**\n * Sort the documents, can be a string or an array of strings\n * @example '-version.createdAt' // Sort DESC by createdAt\n * @example ['version.group', '-version.createdAt'] // sort by 2 fields, ASC group and DESC createdAt\n */\n sort?: Sort\n /**\n * When set to `true`, the query will include both normal and trashed (soft-deleted) documents.\n * To query only trashed documents, pass `trash: true` and combine with a `where` clause filtering by `deletedAt`.\n * By default (`false`), the query will only include normal documents and exclude those with a `deletedAt` field.\n *\n * This argument has no effect unless `trash` is enabled on the collection.\n * @default false\n */\n trash?: boolean\n /**\n * A filter [query](https://payloadcms.com/docs/queries/overview)\n */\n where?: Where\n}\n\nexport async function findVersions<T extends PayloadTypesShape, TSlug extends CollectionSlug<T>>(\n sdk: PayloadSDK<T>,\n options: FindVersionsOptions<T, TSlug>,\n init?: RequestInit,\n): Promise<PaginatedDocs<TypeWithVersion<DataFromCollectionSlug<T, TSlug>>>> {\n const response = await sdk.request({\n args: options,\n init,\n method: 'GET',\n path: `/${options.collection}/versions`,\n })\n\n return response.json()\n}\n"],"names":["findVersions","sdk","options","init","response","request","args","method","path","collection","json"],"mappings":"AAgFA,OAAO,eAAeA,aACpBC,GAAkB,EAClBC,OAAsC,EACtCC,IAAkB;IAElB,MAAMC,WAAW,MAAMH,IAAII,OAAO,CAAC;QACjCC,MAAMJ;QACNC;QACAI,QAAQ;QACRC,MAAM,CAAC,CAAC,EAAEN,QAAQO,UAAU,CAAC,SAAS,CAAC;IACzC;IAEA,OAAOL,SAASM,IAAI;AACtB"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type { CollectionSlug, PayloadTypesShape, TypedLocale } from 'payload';
|
|
1
2
|
import type { PayloadSDK } from '../index.js';
|
|
2
|
-
import type {
|
|
3
|
-
export type RestoreVersionByIDOptions<T extends
|
|
3
|
+
import type { DataFromCollectionSlug, PopulateType } from '../types.js';
|
|
4
|
+
export type RestoreVersionByIDOptions<T extends PayloadTypesShape, TSlug extends CollectionSlug<T>> = {
|
|
4
5
|
/**
|
|
5
6
|
* the Collection slug to operate against.
|
|
6
7
|
*/
|
|
@@ -30,5 +31,5 @@ export type RestoreVersionByIDOptions<T extends PayloadGeneratedTypes, TSlug ext
|
|
|
30
31
|
*/
|
|
31
32
|
populate?: PopulateType<T>;
|
|
32
33
|
};
|
|
33
|
-
export declare function restoreVersion<T extends
|
|
34
|
+
export declare function restoreVersion<T extends PayloadTypesShape, TSlug extends CollectionSlug<T>>(sdk: PayloadSDK<T>, options: RestoreVersionByIDOptions<T, TSlug>, init?: RequestInit): Promise<DataFromCollectionSlug<T, TSlug>>;
|
|
34
35
|
//# sourceMappingURL=restoreVersion.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"restoreVersion.d.ts","sourceRoot":"","sources":["../../src/collections/restoreVersion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"restoreVersion.d.ts","sourceRoot":"","sources":["../../src/collections/restoreVersion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE7E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,KAAK,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAEvE,MAAM,MAAM,yBAAyB,CACnC,CAAC,SAAS,iBAAiB,EAC3B,KAAK,SAAS,cAAc,CAAC,CAAC,CAAC,IAC7B;IACF;;OAEG;IACH,UAAU,EAAE,KAAK,CAAA;IACjB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAA;IACf;;OAEG;IACH,cAAc,CAAC,EAAE,KAAK,GAAG,WAAW,CAAC,CAAC,CAAC,CAAA;IACvC;;OAEG;IACH,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;IACnB;;OAEG;IACH,MAAM,CAAC,EAAE,KAAK,GAAG,WAAW,CAAC,CAAC,CAAC,CAAA;IAC/B;;OAEG;IACH,QAAQ,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,CAAA;CAC3B,CAAA;AAED,wBAAsB,cAAc,CAAC,CAAC,SAAS,iBAAiB,EAAE,KAAK,SAAS,cAAc,CAAC,CAAC,CAAC,EAC/F,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,EAClB,OAAO,EAAE,yBAAyB,CAAC,CAAC,EAAE,KAAK,CAAC,EAC5C,IAAI,CAAC,EAAE,WAAW,GACjB,OAAO,CAAC,sBAAsB,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAS3C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/collections/restoreVersion.ts"],"sourcesContent":["import type { PayloadSDK } from '../index.js'\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../src/collections/restoreVersion.ts"],"sourcesContent":["import type { CollectionSlug, PayloadTypesShape, TypedLocale } from 'payload'\n\nimport type { PayloadSDK } from '../index.js'\nimport type { DataFromCollectionSlug, PopulateType } from '../types.js'\n\nexport type RestoreVersionByIDOptions<\n T extends PayloadTypesShape,\n TSlug extends CollectionSlug<T>,\n> = {\n /**\n * the Collection slug to operate against.\n */\n collection: TSlug\n /**\n * [Control auto-population](https://payloadcms.com/docs/queries/depth) of nested relationship and upload fields.\n */\n depth?: number\n /**\n * Whether the document should be queried from the versions table/collection or not. [More](https://payloadcms.com/docs/versions/drafts#draft-api)\n */\n draft?: boolean\n /**\n * Specify a [fallback locale](https://payloadcms.com/docs/configuration/localization) to use for any returned documents.\n */\n fallbackLocale?: false | TypedLocale<T>\n /**\n * The ID of the version to restore.\n */\n id: number | string\n /**\n * Specify [locale](https://payloadcms.com/docs/configuration/localization) for any returned documents.\n */\n locale?: 'all' | TypedLocale<T>\n /**\n * Specify [populate](https://payloadcms.com/docs/queries/select#populate) to control which fields to include to the result from populated documents.\n */\n populate?: PopulateType<T>\n}\n\nexport async function restoreVersion<T extends PayloadTypesShape, TSlug extends CollectionSlug<T>>(\n sdk: PayloadSDK<T>,\n options: RestoreVersionByIDOptions<T, TSlug>,\n init?: RequestInit,\n): Promise<DataFromCollectionSlug<T, TSlug>> {\n const response = await sdk.request({\n args: options,\n init,\n method: 'POST',\n path: `/${options.collection}/versions/${options.id}`,\n })\n\n return response.json()\n}\n"],"names":["restoreVersion","sdk","options","init","response","request","args","method","path","collection","id","json"],"mappings":"AAuCA,OAAO,eAAeA,eACpBC,GAAkB,EAClBC,OAA4C,EAC5CC,IAAkB;IAElB,MAAMC,WAAW,MAAMH,IAAII,OAAO,CAAC;QACjCC,MAAMJ;QACNC;QACAI,QAAQ;QACRC,MAAM,CAAC,CAAC,EAAEN,QAAQO,UAAU,CAAC,UAAU,EAAEP,QAAQQ,EAAE,EAAE;IACvD;IAEA,OAAON,SAASO,IAAI;AACtB"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { SelectType, Where } from 'payload';
|
|
1
|
+
import type { CollectionSlug, PayloadTypesShape, SelectType, TypedLocale, UploadCollectionSlug, Where } from 'payload';
|
|
2
2
|
import type { DeepPartial } from 'ts-essentials';
|
|
3
3
|
import type { PayloadSDK } from '../index.js';
|
|
4
|
-
import type { BulkOperationResult,
|
|
5
|
-
export type UpdateBaseOptions<T extends
|
|
4
|
+
import type { BulkOperationResult, PopulateType, RequiredDataFromCollectionSlug, SelectFromCollectionSlug, TransformCollectionWithSelect } from '../types.js';
|
|
5
|
+
export type UpdateBaseOptions<T extends PayloadTypesShape, TSlug extends CollectionSlug<T>, TSelect extends SelectType> = {
|
|
6
6
|
/**
|
|
7
7
|
* Whether the current update should be marked as from autosave.
|
|
8
8
|
* `versions.drafts.autosave` should be specified.
|
|
@@ -47,16 +47,16 @@ export type UpdateBaseOptions<T extends PayloadGeneratedTypes, TSlug extends Col
|
|
|
47
47
|
*/
|
|
48
48
|
select?: TSelect;
|
|
49
49
|
};
|
|
50
|
-
export type UpdateByIDOptions<T extends
|
|
50
|
+
export type UpdateByIDOptions<T extends PayloadTypesShape, TSlug extends CollectionSlug<T>, TSelect extends SelectFromCollectionSlug<T, TSlug>> = {
|
|
51
51
|
id: number | string;
|
|
52
52
|
limit?: never;
|
|
53
53
|
where?: never;
|
|
54
54
|
} & UpdateBaseOptions<T, TSlug, TSelect>;
|
|
55
|
-
export type UpdateManyOptions<T extends
|
|
55
|
+
export type UpdateManyOptions<T extends PayloadTypesShape, TSlug extends CollectionSlug<T>, TSelect extends SelectFromCollectionSlug<T, TSlug>> = {
|
|
56
56
|
id?: never;
|
|
57
57
|
limit?: number;
|
|
58
58
|
where: Where;
|
|
59
59
|
} & UpdateBaseOptions<T, TSlug, TSelect>;
|
|
60
|
-
export type UpdateOptions<T extends
|
|
61
|
-
export declare function update<T extends
|
|
60
|
+
export type UpdateOptions<T extends PayloadTypesShape, TSlug extends CollectionSlug<T>, TSelect extends SelectFromCollectionSlug<T, TSlug>> = UpdateByIDOptions<T, TSlug, TSelect> | UpdateManyOptions<T, TSlug, TSelect>;
|
|
61
|
+
export declare function update<T extends PayloadTypesShape, TSlug extends CollectionSlug<T>, TSelect extends SelectFromCollectionSlug<T, TSlug>>(sdk: PayloadSDK<T>, options: UpdateOptions<T, TSlug, TSelect>, init?: RequestInit): Promise<BulkOperationResult<T, TSlug, TSelect> | TransformCollectionWithSelect<T, TSlug, TSelect>>;
|
|
62
62
|
//# sourceMappingURL=update.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../src/collections/update.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../src/collections/update.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,iBAAiB,EACjB,UAAU,EACV,WAAW,EACX,oBAAoB,EACpB,KAAK,EACN,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAEhD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,KAAK,EACV,mBAAmB,EACnB,YAAY,EACZ,8BAA8B,EAC9B,wBAAwB,EACxB,6BAA6B,EAC9B,MAAM,aAAa,CAAA;AAIpB,MAAM,MAAM,iBAAiB,CAC3B,CAAC,SAAS,iBAAiB,EAC3B,KAAK,SAAS,cAAc,CAAC,CAAC,CAAC,EAC/B,OAAO,SAAS,UAAU,IACxB;IACF;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;OAEG;IACH,UAAU,EAAE,KAAK,CAAA;IACjB;;OAEG;IACH,IAAI,EAAE,WAAW,CAAC,8BAA8B,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAA;IAC3D;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAA;IACf;;OAEG;IACH,cAAc,CAAC,EAAE,KAAK,GAAG,WAAW,CAAC,CAAC,CAAC,CAAA;IACvC,uEAAuE;IACvE,IAAI,CAAC,EAAE,KAAK,SAAS,oBAAoB,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,MAAM,GAAG,KAAK,CAAA;IACpE;;OAEG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAA;IACvB;;OAEG;IACH,QAAQ,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,CAAA;IAC1B;;OAEG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,iBAAiB,CAC3B,CAAC,SAAS,iBAAiB,EAC3B,KAAK,SAAS,cAAc,CAAC,CAAC,CAAC,EAC/B,OAAO,SAAS,wBAAwB,CAAC,CAAC,EAAE,KAAK,CAAC,IAChD;IACF,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;IACnB,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,KAAK,CAAC,EAAE,KAAK,CAAA;CACd,GAAG,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,CAAA;AAExC,MAAM,MAAM,iBAAiB,CAC3B,CAAC,SAAS,iBAAiB,EAC3B,KAAK,SAAS,cAAc,CAAC,CAAC,CAAC,EAC/B,OAAO,SAAS,wBAAwB,CAAC,CAAC,EAAE,KAAK,CAAC,IAChD;IACF,EAAE,CAAC,EAAE,KAAK,CAAA;IACV,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,KAAK,CAAA;CACb,GAAG,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,CAAA;AAExC,MAAM,MAAM,aAAa,CACvB,CAAC,SAAS,iBAAiB,EAC3B,KAAK,SAAS,cAAc,CAAC,CAAC,CAAC,EAC/B,OAAO,SAAS,wBAAwB,CAAC,CAAC,EAAE,KAAK,CAAC,IAChD,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,GAAG,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,CAAA;AAE/E,wBAAsB,MAAM,CAC1B,CAAC,SAAS,iBAAiB,EAC3B,KAAK,SAAS,cAAc,CAAC,CAAC,CAAC,EAC/B,OAAO,SAAS,wBAAwB,CAAC,CAAC,EAAE,KAAK,CAAC,EAElD,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,EAClB,OAAO,EAAE,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,EACzC,IAAI,CAAC,EAAE,WAAW,GACjB,OAAO,CACR,mBAAmB,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,GAAG,6BAA6B,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,CAC1F,CAuBA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/collections/update.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"sources":["../../src/collections/update.ts"],"sourcesContent":["import type {\n CollectionSlug,\n PayloadTypesShape,\n SelectType,\n TypedLocale,\n UploadCollectionSlug,\n Where,\n} from 'payload'\nimport type { DeepPartial } from 'ts-essentials'\n\nimport type { PayloadSDK } from '../index.js'\nimport type {\n BulkOperationResult,\n PopulateType,\n RequiredDataFromCollectionSlug,\n SelectFromCollectionSlug,\n TransformCollectionWithSelect,\n} from '../types.js'\n\nimport { resolveFileFromOptions } from '../utilities/resolveFileFromOptions.js'\n\nexport type UpdateBaseOptions<\n T extends PayloadTypesShape,\n TSlug extends CollectionSlug<T>,\n TSelect extends SelectType,\n> = {\n /**\n * Whether the current update should be marked as from autosave.\n * `versions.drafts.autosave` should be specified.\n */\n autosave?: boolean\n /**\n * the Collection slug to operate against.\n */\n collection: TSlug\n /**\n * The document / documents data to update.\n */\n data: DeepPartial<RequiredDataFromCollectionSlug<T, TSlug>>\n /**\n * [Control auto-population](https://payloadcms.com/docs/queries/depth) of nested relationship and upload fields.\n */\n depth?: number\n /**\n * Update documents to a draft.\n */\n draft?: boolean\n /**\n * Specify a [fallback locale](https://payloadcms.com/docs/configuration/localization) to use for any returned documents.\n */\n fallbackLocale?: false | TypedLocale<T>\n /** File Blob object or URL to the file. Only for upload collections */\n file?: TSlug extends UploadCollectionSlug<T> ? Blob | string : never\n /**\n * Specify [locale](https://payloadcms.com/docs/configuration/localization) for any returned documents.\n */\n locale?: TypedLocale<T>\n /**\n * Specify [populate](https://payloadcms.com/docs/queries/select#populate) to control which fields to include to the result from populated documents.\n */\n populate?: PopulateType<T>\n /**\n * Publish the document / documents with a specific locale.\n */\n publishSpecificLocale?: string\n /**\n * Specify [select](https://payloadcms.com/docs/queries/select) to control which fields to include to the result.\n */\n select?: TSelect\n}\n\nexport type UpdateByIDOptions<\n T extends PayloadTypesShape,\n TSlug extends CollectionSlug<T>,\n TSelect extends SelectFromCollectionSlug<T, TSlug>,\n> = {\n id: number | string\n limit?: never\n where?: never\n} & UpdateBaseOptions<T, TSlug, TSelect>\n\nexport type UpdateManyOptions<\n T extends PayloadTypesShape,\n TSlug extends CollectionSlug<T>,\n TSelect extends SelectFromCollectionSlug<T, TSlug>,\n> = {\n id?: never\n limit?: number\n where: Where\n} & UpdateBaseOptions<T, TSlug, TSelect>\n\nexport type UpdateOptions<\n T extends PayloadTypesShape,\n TSlug extends CollectionSlug<T>,\n TSelect extends SelectFromCollectionSlug<T, TSlug>,\n> = UpdateByIDOptions<T, TSlug, TSelect> | UpdateManyOptions<T, TSlug, TSelect>\n\nexport async function update<\n T extends PayloadTypesShape,\n TSlug extends CollectionSlug<T>,\n TSelect extends SelectFromCollectionSlug<T, TSlug>,\n>(\n sdk: PayloadSDK<T>,\n options: UpdateOptions<T, TSlug, TSelect>,\n init?: RequestInit,\n): Promise<\n BulkOperationResult<T, TSlug, TSelect> | TransformCollectionWithSelect<T, TSlug, TSelect>\n> {\n let file: Blob | undefined = undefined\n\n if (options.file) {\n file = await resolveFileFromOptions(options.file)\n }\n\n const response = await sdk.request({\n args: options,\n file,\n init,\n json: options.data,\n method: 'PATCH',\n path: `/${options.collection}${options.id ? `/${options.id}` : ''}`,\n })\n\n const json = await response.json()\n\n if (options.id) {\n return json.doc\n }\n\n return json\n}\n"],"names":["resolveFileFromOptions","update","sdk","options","init","file","undefined","response","request","args","json","data","method","path","collection","id","doc"],"mappings":"AAmBA,SAASA,sBAAsB,QAAQ,yCAAwC;AA8E/E,OAAO,eAAeC,OAKpBC,GAAkB,EAClBC,OAAyC,EACzCC,IAAkB;IAIlB,IAAIC,OAAyBC;IAE7B,IAAIH,QAAQE,IAAI,EAAE;QAChBA,OAAO,MAAML,uBAAuBG,QAAQE,IAAI;IAClD;IAEA,MAAME,WAAW,MAAML,IAAIM,OAAO,CAAC;QACjCC,MAAMN;QACNE;QACAD;QACAM,MAAMP,QAAQQ,IAAI;QAClBC,QAAQ;QACRC,MAAM,CAAC,CAAC,EAAEV,QAAQW,UAAU,GAAGX,QAAQY,EAAE,GAAG,CAAC,CAAC,EAAEZ,QAAQY,EAAE,EAAE,GAAG,IAAI;IACrE;IAEA,MAAML,OAAO,MAAMH,SAASG,IAAI;IAEhC,IAAIP,QAAQY,EAAE,EAAE;QACd,OAAOL,KAAKM,GAAG;IACjB;IAEA,OAAON;AACT"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ErrorResult } from 'payload';
|
|
2
|
+
/**
|
|
3
|
+
* Error class for SDK API errors.
|
|
4
|
+
* Contains the HTTP status code and error details from the API response.
|
|
5
|
+
*/
|
|
6
|
+
export declare class PayloadSDKError extends Error {
|
|
7
|
+
/**
|
|
8
|
+
* The error data from the API response.
|
|
9
|
+
* For ValidationError, this contains `collection`, `global`, and `errors` array.
|
|
10
|
+
*/
|
|
11
|
+
errors: ErrorResult['errors'];
|
|
12
|
+
/** The response object */
|
|
13
|
+
response: Response;
|
|
14
|
+
/** HTTP status code */
|
|
15
|
+
status: number;
|
|
16
|
+
constructor({ errors, message, response, status, }: {
|
|
17
|
+
errors: ErrorResult['errors'];
|
|
18
|
+
message: string;
|
|
19
|
+
response: Response;
|
|
20
|
+
status: number;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=PayloadSDKError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PayloadSDKError.d.ts","sourceRoot":"","sources":["../../src/errors/PayloadSDKError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE1C;;;GAGG;AACH,qBAAa,eAAgB,SAAQ,KAAK;IACxC;;;OAGG;IACH,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAA;IAE7B,0BAA0B;IAC1B,QAAQ,EAAE,QAAQ,CAAA;IAElB,uBAAuB;IACvB,MAAM,EAAE,MAAM,CAAA;gBAEF,EACV,MAAM,EACN,OAAO,EACP,QAAQ,EACR,MAAM,GACP,EAAE;QACD,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAA;QAC7B,OAAO,EAAE,MAAM,CAAA;QACf,QAAQ,EAAE,QAAQ,CAAA;QAClB,MAAM,EAAE,MAAM,CAAA;KACf;CAOF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error class for SDK API errors.
|
|
3
|
+
* Contains the HTTP status code and error details from the API response.
|
|
4
|
+
*/ export class PayloadSDKError extends Error {
|
|
5
|
+
/**
|
|
6
|
+
* The error data from the API response.
|
|
7
|
+
* For ValidationError, this contains `collection`, `global`, and `errors` array.
|
|
8
|
+
*/ errors;
|
|
9
|
+
/** The response object */ response;
|
|
10
|
+
/** HTTP status code */ status;
|
|
11
|
+
constructor({ errors, message, response, status }){
|
|
12
|
+
super(message);
|
|
13
|
+
this.name = 'PayloadSDKError';
|
|
14
|
+
this.status = status;
|
|
15
|
+
this.errors = errors;
|
|
16
|
+
this.response = response;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=PayloadSDKError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/errors/PayloadSDKError.ts"],"sourcesContent":["import type { ErrorResult } from 'payload'\n\n/**\n * Error class for SDK API errors.\n * Contains the HTTP status code and error details from the API response.\n */\nexport class PayloadSDKError extends Error {\n /**\n * The error data from the API response.\n * For ValidationError, this contains `collection`, `global`, and `errors` array.\n */\n errors: ErrorResult['errors']\n\n /** The response object */\n response: Response\n\n /** HTTP status code */\n status: number\n\n constructor({\n errors,\n message,\n response,\n status,\n }: {\n errors: ErrorResult['errors']\n message: string\n response: Response\n status: number\n }) {\n super(message)\n this.name = 'PayloadSDKError'\n this.status = status\n this.errors = errors\n this.response = response\n }\n}\n"],"names":["PayloadSDKError","Error","errors","response","status","message","name"],"mappings":"AAEA;;;CAGC,GACD,OAAO,MAAMA,wBAAwBC;IACnC;;;GAGC,GACDC,OAA6B;IAE7B,wBAAwB,GACxBC,SAAkB;IAElB,qBAAqB,GACrBC,OAAc;IAEd,YAAY,EACVF,MAAM,EACNG,OAAO,EACPF,QAAQ,EACRC,MAAM,EAMP,CAAE;QACD,KAAK,CAACC;QACN,IAAI,CAACC,IAAI,GAAG;QACZ,IAAI,CAACF,MAAM,GAAGA;QACd,IAAI,CAACF,MAAM,GAAGA;QACd,IAAI,CAACC,QAAQ,GAAGA;IAClB;AACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { SelectType } from 'payload';
|
|
1
|
+
import type { GlobalSlug, PayloadTypesShape, SelectType, TypedLocale } from 'payload';
|
|
2
2
|
import type { PayloadSDK } from '../index.js';
|
|
3
|
-
import type {
|
|
4
|
-
export type FindGlobalOptions<T extends
|
|
3
|
+
import type { PopulateType, SelectFromGlobalSlug, TransformGlobalWithSelect } from '../types.js';
|
|
4
|
+
export type FindGlobalOptions<T extends PayloadTypesShape, TSlug extends GlobalSlug<T>, TSelect extends SelectType> = {
|
|
5
5
|
/**
|
|
6
6
|
* [Control auto-population](https://payloadcms.com/docs/queries/depth) of nested relationship and upload fields.
|
|
7
7
|
*/
|
|
@@ -31,5 +31,5 @@ export type FindGlobalOptions<T extends PayloadGeneratedTypes, TSlug extends Glo
|
|
|
31
31
|
*/
|
|
32
32
|
slug: TSlug;
|
|
33
33
|
};
|
|
34
|
-
export declare function findGlobal<T extends
|
|
34
|
+
export declare function findGlobal<T extends PayloadTypesShape, TSlug extends GlobalSlug<T>, TSelect extends SelectFromGlobalSlug<T, TSlug>>(sdk: PayloadSDK<T>, options: FindGlobalOptions<T, TSlug, TSelect>, init?: RequestInit): Promise<TransformGlobalWithSelect<T, TSlug, TSelect>>;
|
|
35
35
|
//# sourceMappingURL=findOne.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findOne.d.ts","sourceRoot":"","sources":["../../src/globals/findOne.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"findOne.d.ts","sourceRoot":"","sources":["../../src/globals/findOne.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAErF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAA;AAEhG,MAAM,MAAM,iBAAiB,CAC3B,CAAC,SAAS,iBAAiB,EAC3B,KAAK,SAAS,UAAU,CAAC,CAAC,CAAC,EAC3B,OAAO,SAAS,UAAU,IACxB;IACF;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAA;IACf;;OAEG;IACH,cAAc,CAAC,EAAE,KAAK,GAAG,WAAW,CAAC,CAAC,CAAC,CAAA;IACvC;;OAEG;IACH,MAAM,CAAC,EAAE,KAAK,GAAG,WAAW,CAAC,CAAC,CAAC,CAAA;IAC/B;;OAEG;IACH,QAAQ,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,CAAA;IAC1B;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB;;OAEG;IACH,IAAI,EAAE,KAAK,CAAA;CACZ,CAAA;AAED,wBAAsB,UAAU,CAC9B,CAAC,SAAS,iBAAiB,EAC3B,KAAK,SAAS,UAAU,CAAC,CAAC,CAAC,EAC3B,OAAO,SAAS,oBAAoB,CAAC,CAAC,EAAE,KAAK,CAAC,EAE9C,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,EAClB,OAAO,EAAE,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,EAC7C,IAAI,CAAC,EAAE,WAAW,GACjB,OAAO,CAAC,yBAAyB,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CASvD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/globals/findOne.ts"],"sourcesContent":["import type { SelectType } from 'payload'\n\nimport type { PayloadSDK } from '../index.js'\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../src/globals/findOne.ts"],"sourcesContent":["import type { GlobalSlug, PayloadTypesShape, SelectType, TypedLocale } from 'payload'\n\nimport type { PayloadSDK } from '../index.js'\nimport type { PopulateType, SelectFromGlobalSlug, TransformGlobalWithSelect } from '../types.js'\n\nexport type FindGlobalOptions<\n T extends PayloadTypesShape,\n TSlug extends GlobalSlug<T>,\n TSelect extends SelectType,\n> = {\n /**\n * [Control auto-population](https://payloadcms.com/docs/queries/depth) of nested relationship and upload fields.\n */\n depth?: number\n /**\n * Whether the document should be queried from the versions table/collection or not. [More](https://payloadcms.com/docs/versions/drafts#draft-api)\n */\n draft?: boolean\n /**\n * Specify a [fallback locale](https://payloadcms.com/docs/configuration/localization) to use for any returned documents.\n */\n fallbackLocale?: false | TypedLocale<T>\n /**\n * Specify [locale](https://payloadcms.com/docs/configuration/localization) for any returned documents.\n */\n locale?: 'all' | TypedLocale<T>\n /**\n * Specify [populate](https://payloadcms.com/docs/queries/select#populate) to control which fields to include to the result from populated documents.\n */\n populate?: PopulateType<T>\n /**\n * Specify [select](https://payloadcms.com/docs/queries/select) to control which fields to include to the result.\n */\n select?: TSelect\n /**\n * the Global slug to operate against.\n */\n slug: TSlug\n}\n\nexport async function findGlobal<\n T extends PayloadTypesShape,\n TSlug extends GlobalSlug<T>,\n TSelect extends SelectFromGlobalSlug<T, TSlug>,\n>(\n sdk: PayloadSDK<T>,\n options: FindGlobalOptions<T, TSlug, TSelect>,\n init?: RequestInit,\n): Promise<TransformGlobalWithSelect<T, TSlug, TSelect>> {\n const response = await sdk.request({\n args: options,\n init,\n method: 'GET',\n path: `/globals/${options.slug}`,\n })\n\n return response.json()\n}\n"],"names":["findGlobal","sdk","options","init","response","request","args","method","path","slug","json"],"mappings":"AAwCA,OAAO,eAAeA,WAKpBC,GAAkB,EAClBC,OAA6C,EAC7CC,IAAkB;IAElB,MAAMC,WAAW,MAAMH,IAAII,OAAO,CAAC;QACjCC,MAAMJ;QACNC;QACAI,QAAQ;QACRC,MAAM,CAAC,SAAS,EAAEN,QAAQO,IAAI,EAAE;IAClC;IAEA,OAAOL,SAASM,IAAI;AACtB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { ApplyDisableErrors, SelectType, TypeWithVersion } from 'payload';
|
|
1
|
+
import type { ApplyDisableErrors, GlobalSlug, PayloadTypesShape, SelectType, TypedLocale, TypeWithVersion } from 'payload';
|
|
2
2
|
import type { PayloadSDK } from '../index.js';
|
|
3
|
-
import type { DataFromGlobalSlug,
|
|
4
|
-
export type FindGlobalVersionByIDOptions<T extends
|
|
3
|
+
import type { DataFromGlobalSlug, PopulateType } from '../types.js';
|
|
4
|
+
export type FindGlobalVersionByIDOptions<T extends PayloadTypesShape, TSlug extends GlobalSlug<T>, TDisableErrors extends boolean> = {
|
|
5
5
|
/**
|
|
6
6
|
* [Control auto-population](https://payloadcms.com/docs/queries/depth) of nested relationship and upload fields.
|
|
7
7
|
*/
|
|
@@ -37,5 +37,5 @@ export type FindGlobalVersionByIDOptions<T extends PayloadGeneratedTypes, TSlug
|
|
|
37
37
|
*/
|
|
38
38
|
slug: TSlug;
|
|
39
39
|
};
|
|
40
|
-
export declare function findGlobalVersionByID<T extends
|
|
40
|
+
export declare function findGlobalVersionByID<T extends PayloadTypesShape, TSlug extends GlobalSlug<T>, TDisableErrors extends boolean>(sdk: PayloadSDK<T>, options: FindGlobalVersionByIDOptions<T, TSlug, TDisableErrors>, init?: RequestInit): Promise<ApplyDisableErrors<TypeWithVersion<DataFromGlobalSlug<T, TSlug>>, TDisableErrors>>;
|
|
41
41
|
//# sourceMappingURL=findVersionByID.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findVersionByID.d.ts","sourceRoot":"","sources":["../../src/globals/findVersionByID.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"findVersionByID.d.ts","sourceRoot":"","sources":["../../src/globals/findVersionByID.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,UAAU,EACV,iBAAiB,EACjB,UAAU,EACV,WAAW,EACX,eAAe,EAChB,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,KAAK,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAEnE,MAAM,MAAM,4BAA4B,CACtC,CAAC,SAAS,iBAAiB,EAC3B,KAAK,SAAS,UAAU,CAAC,CAAC,CAAC,EAC3B,cAAc,SAAS,OAAO,IAC5B;IACF;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,aAAa,CAAC,EAAE,cAAc,CAAA;IAC9B,KAAK,CAAC,EAAE,OAAO,CAAA;IACf;;OAEG;IACH,cAAc,CAAC,EAAE,KAAK,GAAG,WAAW,CAAC,CAAC,CAAC,CAAA;IACvC;;OAEG;IACH,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;IACnB;;OAEG;IACH,MAAM,CAAC,EAAE,KAAK,GAAG,WAAW,CAAC,CAAC,CAAC,CAAA;IAC/B;;OAEG;IACH,QAAQ,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,CAAA;IAC1B;;OAEG;IACH,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB;;OAEG;IACH,IAAI,EAAE,KAAK,CAAA;CACZ,CAAA;AAED,wBAAsB,qBAAqB,CACzC,CAAC,SAAS,iBAAiB,EAC3B,KAAK,SAAS,UAAU,CAAC,CAAC,CAAC,EAC3B,cAAc,SAAS,OAAO,EAE9B,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,EAClB,OAAO,EAAE,4BAA4B,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,EAC/D,IAAI,CAAC,EAAE,WAAW,GACjB,OAAO,CAAC,kBAAkB,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC,CAkB5F"}
|
|
@@ -6,17 +6,13 @@ export async function findGlobalVersionByID(sdk, options, init) {
|
|
|
6
6
|
method: 'GET',
|
|
7
7
|
path: `/globals/${options.slug}/versions/${options.id}`
|
|
8
8
|
});
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
} else {
|
|
12
|
-
throw new Error();
|
|
13
|
-
}
|
|
14
|
-
} catch {
|
|
9
|
+
return response.json();
|
|
10
|
+
} catch (err) {
|
|
15
11
|
if (options.disableErrors) {
|
|
16
12
|
// @ts-expect-error generic nullable
|
|
17
13
|
return null;
|
|
18
14
|
}
|
|
19
|
-
throw
|
|
15
|
+
throw err;
|
|
20
16
|
}
|
|
21
17
|
}
|
|
22
18
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/globals/findVersionByID.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"sources":["../../src/globals/findVersionByID.ts"],"sourcesContent":["import type {\n ApplyDisableErrors,\n GlobalSlug,\n PayloadTypesShape,\n SelectType,\n TypedLocale,\n TypeWithVersion,\n} from 'payload'\n\nimport type { PayloadSDK } from '../index.js'\nimport type { DataFromGlobalSlug, PopulateType } from '../types.js'\n\nexport type FindGlobalVersionByIDOptions<\n T extends PayloadTypesShape,\n TSlug extends GlobalSlug<T>,\n TDisableErrors extends boolean,\n> = {\n /**\n * [Control auto-population](https://payloadcms.com/docs/queries/depth) of nested relationship and upload fields.\n */\n depth?: number\n /**\n * When set to `true`, errors will not be thrown.\n * `null` will be returned instead, if the document on this ID was not found.\n */\n disableErrors?: TDisableErrors\n draft?: boolean\n /**\n * Specify a [fallback locale](https://payloadcms.com/docs/configuration/localization) to use for any returned documents.\n */\n fallbackLocale?: false | TypedLocale<T>\n /**\n * The ID of the version to find.\n */\n id: number | string\n /**\n * Specify [locale](https://payloadcms.com/docs/configuration/localization) for any returned documents.\n */\n locale?: 'all' | TypedLocale<T>\n /**\n * Specify [populate](https://payloadcms.com/docs/queries/select#populate) to control which fields to include to the result from populated documents.\n */\n populate?: PopulateType<T>\n /**\n * Specify [select](https://payloadcms.com/docs/queries/select) to control which fields to include to the result.\n */\n select?: SelectType\n /**\n * the Global slug to operate against.\n */\n slug: TSlug\n}\n\nexport async function findGlobalVersionByID<\n T extends PayloadTypesShape,\n TSlug extends GlobalSlug<T>,\n TDisableErrors extends boolean,\n>(\n sdk: PayloadSDK<T>,\n options: FindGlobalVersionByIDOptions<T, TSlug, TDisableErrors>,\n init?: RequestInit,\n): Promise<ApplyDisableErrors<TypeWithVersion<DataFromGlobalSlug<T, TSlug>>, TDisableErrors>> {\n try {\n const response = await sdk.request({\n args: options,\n init,\n method: 'GET',\n path: `/globals/${options.slug}/versions/${options.id}`,\n })\n\n return response.json()\n } catch (err) {\n if (options.disableErrors) {\n // @ts-expect-error generic nullable\n return null\n }\n\n throw err\n }\n}\n"],"names":["findGlobalVersionByID","sdk","options","init","response","request","args","method","path","slug","id","json","err","disableErrors"],"mappings":"AAqDA,OAAO,eAAeA,sBAKpBC,GAAkB,EAClBC,OAA+D,EAC/DC,IAAkB;IAElB,IAAI;QACF,MAAMC,WAAW,MAAMH,IAAII,OAAO,CAAC;YACjCC,MAAMJ;YACNC;YACAI,QAAQ;YACRC,MAAM,CAAC,SAAS,EAAEN,QAAQO,IAAI,CAAC,UAAU,EAAEP,QAAQQ,EAAE,EAAE;QACzD;QAEA,OAAON,SAASO,IAAI;IACtB,EAAE,OAAOC,KAAK;QACZ,IAAIV,QAAQW,aAAa,EAAE;YACzB,oCAAoC;YACpC,OAAO;QACT;QAEA,MAAMD;IACR;AACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { PaginatedDocs, SelectType, Sort, TypeWithVersion, Where } from 'payload';
|
|
1
|
+
import type { GlobalSlug, PaginatedDocs, PayloadTypesShape, SelectType, Sort, TypedLocale, TypeWithVersion, Where } from 'payload';
|
|
2
2
|
import type { PayloadSDK } from '../index.js';
|
|
3
|
-
import type { DataFromGlobalSlug,
|
|
4
|
-
export type FindGlobalVersionsOptions<T extends
|
|
3
|
+
import type { DataFromGlobalSlug, PopulateType } from '../types.js';
|
|
4
|
+
export type FindGlobalVersionsOptions<T extends PayloadTypesShape, TSlug extends GlobalSlug<T>> = {
|
|
5
5
|
/**
|
|
6
6
|
* [Control auto-population](https://payloadcms.com/docs/queries/depth) of nested relationship and upload fields.
|
|
7
7
|
*/
|
|
@@ -54,5 +54,5 @@ export type FindGlobalVersionsOptions<T extends PayloadGeneratedTypes, TSlug ext
|
|
|
54
54
|
*/
|
|
55
55
|
where?: Where;
|
|
56
56
|
};
|
|
57
|
-
export declare function findGlobalVersions<T extends
|
|
57
|
+
export declare function findGlobalVersions<T extends PayloadTypesShape, TSlug extends GlobalSlug<T>>(sdk: PayloadSDK<T>, options: FindGlobalVersionsOptions<T, TSlug>, init?: RequestInit): Promise<PaginatedDocs<TypeWithVersion<DataFromGlobalSlug<T, TSlug>>>>;
|
|
58
58
|
//# sourceMappingURL=findVersions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findVersions.d.ts","sourceRoot":"","sources":["../../src/globals/findVersions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"findVersions.d.ts","sourceRoot":"","sources":["../../src/globals/findVersions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,aAAa,EACb,iBAAiB,EACjB,UAAU,EACV,IAAI,EACJ,WAAW,EACX,eAAe,EACf,KAAK,EACN,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,KAAK,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAEnE,MAAM,MAAM,yBAAyB,CAAC,CAAC,SAAS,iBAAiB,EAAE,KAAK,SAAS,UAAU,CAAC,CAAC,CAAC,IAAI;IAChG;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,OAAO,CAAA;IACf;;OAEG;IACH,cAAc,CAAC,EAAE,KAAK,GAAG,WAAW,CAAC,CAAC,CAAC,CAAA;IACvC;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,MAAM,CAAC,EAAE,KAAK,GAAG,WAAW,CAAC,CAAC,CAAC,CAAA;IAC/B;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB;;OAEG;IACH,QAAQ,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,CAAA;IAC1B;;OAEG;IACH,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB;;OAEG;IACH,IAAI,EAAE,KAAK,CAAA;IACX;;;;OAIG;IACH,IAAI,CAAC,EAAE,IAAI,CAAA;IACX;;OAEG;IACH,KAAK,CAAC,EAAE,KAAK,CAAA;CACd,CAAA;AAED,wBAAsB,kBAAkB,CAAC,CAAC,SAAS,iBAAiB,EAAE,KAAK,SAAS,UAAU,CAAC,CAAC,CAAC,EAC/F,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,EAClB,OAAO,EAAE,yBAAyB,CAAC,CAAC,EAAE,KAAK,CAAC,EAC5C,IAAI,CAAC,EAAE,WAAW,GACjB,OAAO,CAAC,aAAa,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CASvE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/globals/findVersions.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"sources":["../../src/globals/findVersions.ts"],"sourcesContent":["import type {\n GlobalSlug,\n PaginatedDocs,\n PayloadTypesShape,\n SelectType,\n Sort,\n TypedLocale,\n TypeWithVersion,\n Where,\n} from 'payload'\n\nimport type { PayloadSDK } from '../index.js'\nimport type { DataFromGlobalSlug, PopulateType } from '../types.js'\n\nexport type FindGlobalVersionsOptions<T extends PayloadTypesShape, TSlug extends GlobalSlug<T>> = {\n /**\n * [Control auto-population](https://payloadcms.com/docs/queries/depth) of nested relationship and upload fields.\n */\n depth?: number\n draft?: boolean\n /**\n * Specify a [fallback locale](https://payloadcms.com/docs/configuration/localization) to use for any returned documents.\n */\n fallbackLocale?: false | TypedLocale<T>\n /**\n * The maximum related documents to be returned.\n * Defaults unless `defaultLimit` is specified for the collection config\n * @default 10\n */\n limit?: number\n /**\n * Specify [locale](https://payloadcms.com/docs/configuration/localization) for any returned documents.\n */\n locale?: 'all' | TypedLocale<T>\n /**\n * Get a specific page number\n * @default 1\n */\n page?: number\n /**\n * Set to `false` to return all documents and avoid querying for document counts which introduces some overhead.\n * You can also combine that property with a specified `limit` to limit documents but avoid the count query.\n */\n pagination?: boolean\n /**\n * Specify [populate](https://payloadcms.com/docs/queries/select#populate) to control which fields to include to the result from populated documents.\n */\n populate?: PopulateType<T>\n /**\n * Specify [select](https://payloadcms.com/docs/queries/select) to control which fields to include to the result.\n */\n select?: SelectType\n /**\n * the Global slug to operate against.\n */\n slug: TSlug\n /**\n * Sort the documents, can be a string or an array of strings\n * @example '-version.createdAt' // Sort DESC by createdAt\n * @example ['version.group', '-version.createdAt'] // sort by 2 fields, ASC group and DESC createdAt\n */\n sort?: Sort\n /**\n * A filter [query](https://payloadcms.com/docs/queries/overview)\n */\n where?: Where\n}\n\nexport async function findGlobalVersions<T extends PayloadTypesShape, TSlug extends GlobalSlug<T>>(\n sdk: PayloadSDK<T>,\n options: FindGlobalVersionsOptions<T, TSlug>,\n init?: RequestInit,\n): Promise<PaginatedDocs<TypeWithVersion<DataFromGlobalSlug<T, TSlug>>>> {\n const response = await sdk.request({\n args: options,\n init,\n method: 'GET',\n path: `/globals/${options.slug}/versions`,\n })\n\n return response.json()\n}\n"],"names":["findGlobalVersions","sdk","options","init","response","request","args","method","path","slug","json"],"mappings":"AAoEA,OAAO,eAAeA,mBACpBC,GAAkB,EAClBC,OAA4C,EAC5CC,IAAkB;IAElB,MAAMC,WAAW,MAAMH,IAAII,OAAO,CAAC;QACjCC,MAAMJ;QACNC;QACAI,QAAQ;QACRC,MAAM,CAAC,SAAS,EAAEN,QAAQO,IAAI,CAAC,SAAS,CAAC;IAC3C;IAEA,OAAOL,SAASM,IAAI;AACtB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { TypeWithVersion } from 'payload';
|
|
1
|
+
import type { GlobalSlug, PayloadTypesShape, TypedLocale, TypeWithVersion } from 'payload';
|
|
2
2
|
import type { PayloadSDK } from '../index.js';
|
|
3
|
-
import type { DataFromGlobalSlug,
|
|
4
|
-
export type RestoreGlobalVersionByIDOptions<T extends
|
|
3
|
+
import type { DataFromGlobalSlug, PopulateType } from '../types.js';
|
|
4
|
+
export type RestoreGlobalVersionByIDOptions<T extends PayloadTypesShape, TSlug extends GlobalSlug<T>> = {
|
|
5
5
|
/**
|
|
6
6
|
* [Control auto-population](https://payloadcms.com/docs/queries/depth) of nested relationship and upload fields.
|
|
7
7
|
*/
|
|
@@ -28,5 +28,5 @@ export type RestoreGlobalVersionByIDOptions<T extends PayloadGeneratedTypes, TSl
|
|
|
28
28
|
*/
|
|
29
29
|
slug: TSlug;
|
|
30
30
|
};
|
|
31
|
-
export declare function restoreGlobalVersion<T extends
|
|
31
|
+
export declare function restoreGlobalVersion<T extends PayloadTypesShape, TSlug extends GlobalSlug<T>>(sdk: PayloadSDK<T>, options: RestoreGlobalVersionByIDOptions<T, TSlug>, init?: RequestInit): Promise<TypeWithVersion<DataFromGlobalSlug<T, TSlug>>>;
|
|
32
32
|
//# sourceMappingURL=restoreVersion.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"restoreVersion.d.ts","sourceRoot":"","sources":["../../src/globals/restoreVersion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"restoreVersion.d.ts","sourceRoot":"","sources":["../../src/globals/restoreVersion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAE1F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,KAAK,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAEnE,MAAM,MAAM,+BAA+B,CACzC,CAAC,SAAS,iBAAiB,EAC3B,KAAK,SAAS,UAAU,CAAC,CAAC,CAAC,IACzB;IACF;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,OAAO,CAAA;IACf;;OAEG;IACH,cAAc,CAAC,EAAE,KAAK,GAAG,WAAW,CAAC,CAAC,CAAC,CAAA;IACvC;;OAEG;IACH,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;IACnB;;OAEG;IACH,MAAM,CAAC,EAAE,KAAK,GAAG,WAAW,CAAC,CAAC,CAAC,CAAA;IAC/B;;OAEG;IACH,QAAQ,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,CAAA;IAC1B;;OAEG;IACH,IAAI,EAAE,KAAK,CAAA;CACZ,CAAA;AAED,wBAAsB,oBAAoB,CACxC,CAAC,SAAS,iBAAiB,EAC3B,KAAK,SAAS,UAAU,CAAC,CAAC,CAAC,EAE3B,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,EAClB,OAAO,EAAE,+BAA+B,CAAC,CAAC,EAAE,KAAK,CAAC,EAClD,IAAI,CAAC,EAAE,WAAW,GACjB,OAAO,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAWxD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/globals/restoreVersion.ts"],"sourcesContent":["import type { TypeWithVersion } from 'payload'\n\nimport type { PayloadSDK } from '../index.js'\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../src/globals/restoreVersion.ts"],"sourcesContent":["import type { GlobalSlug, PayloadTypesShape, TypedLocale, TypeWithVersion } from 'payload'\n\nimport type { PayloadSDK } from '../index.js'\nimport type { DataFromGlobalSlug, PopulateType } from '../types.js'\n\nexport type RestoreGlobalVersionByIDOptions<\n T extends PayloadTypesShape,\n TSlug extends GlobalSlug<T>,\n> = {\n /**\n * [Control auto-population](https://payloadcms.com/docs/queries/depth) of nested relationship and upload fields.\n */\n depth?: number\n draft?: boolean\n /**\n * Specify a [fallback locale](https://payloadcms.com/docs/configuration/localization) to use for any returned documents.\n */\n fallbackLocale?: false | TypedLocale<T>\n /**\n * The ID of the version to restore.\n */\n id: number | string\n /**\n * Specify [locale](https://payloadcms.com/docs/configuration/localization) for any returned documents.\n */\n locale?: 'all' | TypedLocale<T>\n /**\n * Specify [populate](https://payloadcms.com/docs/queries/select#populate) to control which fields to include to the result from populated documents.\n */\n populate?: PopulateType<T>\n /**\n * the Global slug to operate against.\n */\n slug: TSlug\n}\n\nexport async function restoreGlobalVersion<\n T extends PayloadTypesShape,\n TSlug extends GlobalSlug<T>,\n>(\n sdk: PayloadSDK<T>,\n options: RestoreGlobalVersionByIDOptions<T, TSlug>,\n init?: RequestInit,\n): Promise<TypeWithVersion<DataFromGlobalSlug<T, TSlug>>> {\n const response = await sdk.request({\n args: options,\n init,\n method: 'POST',\n path: `/globals/${options.slug}/versions/${options.id}`,\n })\n\n const { doc } = await response.json()\n\n return doc\n}\n"],"names":["restoreGlobalVersion","sdk","options","init","response","request","args","method","path","slug","id","doc","json"],"mappings":"AAoCA,OAAO,eAAeA,qBAIpBC,GAAkB,EAClBC,OAAkD,EAClDC,IAAkB;IAElB,MAAMC,WAAW,MAAMH,IAAII,OAAO,CAAC;QACjCC,MAAMJ;QACNC;QACAI,QAAQ;QACRC,MAAM,CAAC,SAAS,EAAEN,QAAQO,IAAI,CAAC,UAAU,EAAEP,QAAQQ,EAAE,EAAE;IACzD;IAEA,MAAM,EAAEC,GAAG,EAAE,GAAG,MAAMP,SAASQ,IAAI;IAEnC,OAAOD;AACT"}
|
package/dist/globals/update.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { SelectType } from 'payload';
|
|
1
|
+
import type { GlobalSlug, PayloadTypesShape, SelectType, TypedLocale } from 'payload';
|
|
2
2
|
import type { DeepPartial } from 'ts-essentials';
|
|
3
3
|
import type { PayloadSDK } from '../index.js';
|
|
4
|
-
import type { DataFromGlobalSlug,
|
|
5
|
-
export type UpdateGlobalOptions<T extends
|
|
4
|
+
import type { DataFromGlobalSlug, PopulateType, SelectFromGlobalSlug, TransformGlobalWithSelect } from '../types.js';
|
|
5
|
+
export type UpdateGlobalOptions<T extends PayloadTypesShape, TSlug extends GlobalSlug<T>, TSelect extends SelectType> = {
|
|
6
6
|
/**
|
|
7
7
|
* The global data to update.
|
|
8
8
|
*/
|
|
@@ -40,5 +40,5 @@ export type UpdateGlobalOptions<T extends PayloadGeneratedTypes, TSlug extends G
|
|
|
40
40
|
*/
|
|
41
41
|
slug: TSlug;
|
|
42
42
|
};
|
|
43
|
-
export declare function updateGlobal<T extends
|
|
43
|
+
export declare function updateGlobal<T extends PayloadTypesShape, TSlug extends GlobalSlug<T>, TSelect extends SelectFromGlobalSlug<T, TSlug>>(sdk: PayloadSDK<T>, options: UpdateGlobalOptions<T, TSlug, TSelect>, init?: RequestInit): Promise<TransformGlobalWithSelect<T, TSlug, TSelect>>;
|
|
44
44
|
//# sourceMappingURL=update.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../src/globals/update.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../src/globals/update.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AACrF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAEhD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,KAAK,EACV,kBAAkB,EAClB,YAAY,EACZ,oBAAoB,EACpB,yBAAyB,EAC1B,MAAM,aAAa,CAAA;AAEpB,MAAM,MAAM,mBAAmB,CAC7B,CAAC,SAAS,iBAAiB,EAC3B,KAAK,SAAS,UAAU,CAAC,CAAC,CAAC,EAC3B,OAAO,SAAS,UAAU,IACxB;IACF;;OAEG;IACH,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,IAAI,CAAC,CAAC,CAAA;IAC3D;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAA;IACf;;OAEG;IACH,cAAc,CAAC,EAAE,KAAK,GAAG,WAAW,CAAC,CAAC,CAAC,CAAA;IACvC;;OAEG;IACH,MAAM,CAAC,EAAE,KAAK,GAAG,WAAW,CAAC,CAAC,CAAC,CAAA;IAC/B;;OAEG;IACH,QAAQ,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,CAAA;IAC1B;;OAEG;IACH,qBAAqB,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAA;IACtC;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB;;OAEG;IACH,IAAI,EAAE,KAAK,CAAA;CACZ,CAAA;AAED,wBAAsB,YAAY,CAChC,CAAC,SAAS,iBAAiB,EAC3B,KAAK,SAAS,UAAU,CAAC,CAAC,CAAC,EAC3B,OAAO,SAAS,oBAAoB,CAAC,CAAC,EAAE,KAAK,CAAC,EAE9C,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,EAClB,OAAO,EAAE,mBAAmB,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,EAC/C,IAAI,CAAC,EAAE,WAAW,GACjB,OAAO,CAAC,yBAAyB,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAYvD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/globals/update.ts"],"sourcesContent":["import type { SelectType } from 'payload'\nimport type { DeepPartial } from 'ts-essentials'\n\nimport type { PayloadSDK } from '../index.js'\nimport type {\n DataFromGlobalSlug,\n
|
|
1
|
+
{"version":3,"sources":["../../src/globals/update.ts"],"sourcesContent":["import type { GlobalSlug, PayloadTypesShape, SelectType, TypedLocale } from 'payload'\nimport type { DeepPartial } from 'ts-essentials'\n\nimport type { PayloadSDK } from '../index.js'\nimport type {\n DataFromGlobalSlug,\n PopulateType,\n SelectFromGlobalSlug,\n TransformGlobalWithSelect,\n} from '../types.js'\n\nexport type UpdateGlobalOptions<\n T extends PayloadTypesShape,\n TSlug extends GlobalSlug<T>,\n TSelect extends SelectType,\n> = {\n /**\n * The global data to update.\n */\n data: DeepPartial<Omit<DataFromGlobalSlug<T, TSlug>, 'id'>>\n /**\n * [Control auto-population](https://payloadcms.com/docs/queries/depth) of nested relationship and upload fields.\n */\n depth?: number\n /**\n * Update documents to a draft.\n */\n draft?: boolean\n /**\n * Specify a [fallback locale](https://payloadcms.com/docs/configuration/localization) to use for any returned documents.\n */\n fallbackLocale?: false | TypedLocale<T>\n /**\n * Specify [locale](https://payloadcms.com/docs/configuration/localization) for any returned documents.\n */\n locale?: 'all' | TypedLocale<T>\n /**\n * Specify [populate](https://payloadcms.com/docs/queries/select#populate) to control which fields to include to the result from populated documents.\n */\n populate?: PopulateType<T>\n /**\n * Publish the document / documents with a specific locale.\n */\n publishSpecificLocale?: TypedLocale<T>\n /**\n * Specify [select](https://payloadcms.com/docs/queries/select) to control which fields to include to the result.\n */\n select?: TSelect\n /**\n * the Global slug to operate against.\n */\n slug: TSlug\n}\n\nexport async function updateGlobal<\n T extends PayloadTypesShape,\n TSlug extends GlobalSlug<T>,\n TSelect extends SelectFromGlobalSlug<T, TSlug>,\n>(\n sdk: PayloadSDK<T>,\n options: UpdateGlobalOptions<T, TSlug, TSelect>,\n init?: RequestInit,\n): Promise<TransformGlobalWithSelect<T, TSlug, TSelect>> {\n const response = await sdk.request({\n args: options,\n init,\n json: options.data,\n method: 'POST',\n path: `/globals/${options.slug}`,\n })\n\n const { result } = await response.json()\n\n return result\n}\n"],"names":["updateGlobal","sdk","options","init","response","request","args","json","data","method","path","slug","result"],"mappings":"AAsDA,OAAO,eAAeA,aAKpBC,GAAkB,EAClBC,OAA+C,EAC/CC,IAAkB;IAElB,MAAMC,WAAW,MAAMH,IAAII,OAAO,CAAC;QACjCC,MAAMJ;QACNC;QACAI,MAAML,QAAQM,IAAI;QAClBC,QAAQ;QACRC,MAAM,CAAC,SAAS,EAAER,QAAQS,IAAI,EAAE;IAClC;IAEA,MAAM,EAAEC,MAAM,EAAE,GAAG,MAAMR,SAASG,IAAI;IAEtC,OAAOK;AACT"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { ApplyDisableErrors, PaginatedDocs, SelectType, TypeWithVersion } from 'payload';
|
|
1
|
+
import type { ApplyDisableErrors, AuthCollectionSlug, CollectionSlug, GlobalSlug, PaginatedDocs, PayloadTypes, PayloadTypesShape, SelectType, TypeWithVersion } from 'payload';
|
|
2
|
+
export { PayloadSDKError } from './errors/PayloadSDKError.js';
|
|
2
3
|
import type { ForgotPasswordOptions } from './auth/forgotPassword.js';
|
|
3
4
|
import type { LoginOptions, LoginResult } from './auth/login.js';
|
|
4
5
|
import type { MeOptions, MeResult } from './auth/me.js';
|
|
@@ -15,7 +16,7 @@ import type { FindGlobalVersionByIDOptions } from './globals/findVersionByID.js'
|
|
|
15
16
|
import type { FindGlobalVersionsOptions } from './globals/findVersions.js';
|
|
16
17
|
import type { RestoreGlobalVersionByIDOptions } from './globals/restoreVersion.js';
|
|
17
18
|
import type { UpdateGlobalOptions } from './globals/update.js';
|
|
18
|
-
import type {
|
|
19
|
+
import type { BulkOperationResult, DataFromCollectionSlug, DataFromGlobalSlug, SelectFromCollectionSlug, SelectFromGlobalSlug, TransformCollectionWithSelect, TransformGlobalWithSelect } from './types.js';
|
|
19
20
|
import type { OperationArgs } from './utilities/buildSearchParams.js';
|
|
20
21
|
import { type RefreshOptions, type RefreshResult } from './auth/refreshToken.js';
|
|
21
22
|
import { type VerifyEmailOptions } from './auth/verifyEmail.js';
|
|
@@ -82,7 +83,7 @@ type Args = {
|
|
|
82
83
|
/**
|
|
83
84
|
* @experimental
|
|
84
85
|
*/
|
|
85
|
-
export declare class PayloadSDK<T extends
|
|
86
|
+
export declare class PayloadSDK<T extends PayloadTypesShape = PayloadTypes> {
|
|
86
87
|
baseInit: RequestInit;
|
|
87
88
|
baseURL: string;
|
|
88
89
|
fetch: typeof fetch;
|
|
@@ -144,5 +145,4 @@ export declare class PayloadSDK<T extends PayloadGeneratedTypes = PayloadGenerat
|
|
|
144
145
|
message: string;
|
|
145
146
|
}>;
|
|
146
147
|
}
|
|
147
|
-
export {};
|
|
148
148
|
//# sourceMappingURL=index.d.ts.map
|