Skip to content

Commit 0594701

Browse files
authored
chore: add JSDoc for globals Local API operations (#11313)
Continuation of #11265 for globals. Documents all the possible properties of globals Local API operations with JSDoc.
1 parent 845c647 commit 0594701

File tree

6 files changed

+275
-1
lines changed

6 files changed

+275
-1
lines changed

packages/payload/src/globals/operations/local/countGlobalVersions.ts

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,46 @@ import { countGlobalVersionsOperation } from '../countGlobalVersions.js'
88

99
export type CountGlobalVersionsOptions<TSlug extends GlobalSlug> = {
1010
/**
11-
* context, which will then be passed to req.context, which can be read by hooks
11+
* [Context](https://payloadcms.com/docs/hooks/context), which will then be passed to `context` and `req.context`,
12+
* which can be read by hooks. Useful if you want to pass additional information to the hooks which
13+
* shouldn't be necessarily part of the document, for example a `triggerBeforeChange` option which can be read by the BeforeChange hook
14+
* to determine if it should run or not.
1215
*/
1316
context?: RequestContext
17+
/**
18+
* [Control auto-population](https://payloadcms.com/docs/queries/depth) of nested relationship and upload fields.
19+
*/
1420
depth?: number
21+
/**
22+
* When set to `true`, errors will not be thrown.
23+
*/
1524
disableErrors?: boolean
25+
/**
26+
* the Global slug to operate against.
27+
*/
1628
global: TSlug
29+
/**
30+
* Specify [locale](https://payloadcms.com/docs/configuration/localization) for any returned documents.
31+
*/
1732
locale?: TypedLocale
33+
/**
34+
* Skip access control.
35+
* Set to `false` if you want to respect Access Control for the operation, for example when fetching data for the fron-end.
36+
* @default true
37+
*/
1838
overrideAccess?: boolean
39+
/**
40+
* The `PayloadRequest` object. You can pass it to thread the current [transaction](https://payloadcms.com/docs/database/transactions), user and locale to the operation.
41+
* Recommended to pass when using the Local API from hooks, as usually you want to execute the operation within the current transaction.
42+
*/
1943
req?: Partial<PayloadRequest>
44+
/**
45+
* If you set `overrideAccess` to `false`, you can pass a user to use against the access control checks.
46+
*/
2047
user?: Document
48+
/**
49+
* A filter [query](https://payloadcms.com/docs/queries/overview)
50+
*/
2151
where?: Where
2252
}
2353

packages/payload/src/globals/operations/local/findOne.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,64 @@ import { createLocalReq } from '../../../utilities/createLocalReq.js'
1414
import { findOneOperation } from '../findOne.js'
1515

1616
export type Options<TSlug extends GlobalSlug, TSelect extends SelectType> = {
17+
/**
18+
* [Context](https://payloadcms.com/docs/hooks/context), which will then be passed to `context` and `req.context`,
19+
* which can be read by hooks. Useful if you want to pass additional information to the hooks which
20+
* shouldn't be necessarily part of the document, for example a `triggerBeforeChange` option which can be read by the BeforeChange hook
21+
* to determine if it should run or not.
22+
*/
1723
context?: RequestContext
24+
/**
25+
* [Control auto-population](https://payloadcms.com/docs/queries/depth) of nested relationship and upload fields.
26+
*/
1827
depth?: number
28+
/**
29+
* Whether the document should be queried from the versions table/collection or not. [More](https://payloadcms.com/docs/versions/drafts#draft-api)
30+
*/
1931
draft?: boolean
32+
/**
33+
* Specify a [fallback locale](https://payloadcms.com/docs/configuration/localization) to use for any returned documents.
34+
*/
2035
fallbackLocale?: false | TypedLocale
36+
/**
37+
* Include info about the lock status to the result with fields: `_isLocked` and `_userEditing`
38+
*/
2139
includeLockStatus?: boolean
40+
/**
41+
* Specify [locale](https://payloadcms.com/docs/configuration/localization) for any returned documents.
42+
*/
2243
locale?: 'all' | TypedLocale
44+
/**
45+
* Skip access control.
46+
* Set to `false` if you want to respect Access Control for the operation, for example when fetching data for the fron-end.
47+
* @default true
48+
*/
2349
overrideAccess?: boolean
50+
/**
51+
* Specify [populate](https://payloadcms.com/docs/queries/select#populate) to control which fields to include to the result from populated documents.
52+
*/
2453
populate?: PopulateType
54+
/**
55+
* The `PayloadRequest` object. You can pass it to thread the current [transaction](https://payloadcms.com/docs/database/transactions), user and locale to the operation.
56+
* Recommended to pass when using the Local API from hooks, as usually you want to execute the operation within the current transaction.
57+
*/
2558
req?: Partial<PayloadRequest>
59+
/**
60+
* Specify [select](https://payloadcms.com/docs/queries/select) to control which fields to include to the result.
61+
*/
2662
select?: TSelect
63+
/**
64+
* Opt-in to receiving hidden fields. By default, they are hidden from returned documents in accordance to your config.
65+
* @default false
66+
*/
2767
showHiddenFields?: boolean
68+
/**
69+
* the Global slug to operate against.
70+
*/
2871
slug: TSlug
72+
/**
73+
* If you set `overrideAccess` to `false`, you can pass a user to use against the access control checks.
74+
*/
2975
user?: Document
3076
}
3177

packages/payload/src/globals/operations/local/findVersionByID.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,65 @@ import { createLocalReq } from '../../../utilities/createLocalReq.js'
99
import { findVersionByIDOperation } from '../findVersionByID.js'
1010

1111
export type Options<TSlug extends GlobalSlug> = {
12+
/**
13+
* [Context](https://payloadcms.com/docs/hooks/context), which will then be passed to `context` and `req.context`,
14+
* which can be read by hooks. Useful if you want to pass additional information to the hooks which
15+
* shouldn't be necessarily part of the document, for example a `triggerBeforeChange` option which can be read by the BeforeChange hook
16+
* to determine if it should run or not.
17+
*/
1218
context?: RequestContext
19+
/**
20+
* [Control auto-population](https://payloadcms.com/docs/queries/depth) of nested relationship and upload fields.
21+
*/
1322
depth?: number
23+
/**
24+
* When set to `true`, errors will not be thrown.
25+
* `null` will be returned instead, if the document on this ID was not found.
26+
*/
1427
disableErrors?: boolean
28+
/**
29+
* Specify a [fallback locale](https://payloadcms.com/docs/configuration/localization) to use for any returned documents.
30+
*/
1531
fallbackLocale?: false | TypedLocale
32+
/**
33+
* The ID of the version to find.
34+
*/
1635
id: string
36+
/**
37+
* Specify [locale](https://payloadcms.com/docs/configuration/localization) for any returned documents.
38+
*/
1739
locale?: 'all' | TypedLocale
40+
/**
41+
* Skip access control.
42+
* Set to `false` if you want to respect Access Control for the operation, for example when fetching data for the fron-end.
43+
* @default true
44+
*/
1845
overrideAccess?: boolean
46+
/**
47+
* Specify [populate](https://payloadcms.com/docs/queries/select#populate) to control which fields to include to the result from populated documents.
48+
*/
1949
populate?: PopulateType
50+
/**
51+
* The `PayloadRequest` object. You can pass it to thread the current [transaction](https://payloadcms.com/docs/database/transactions), user and locale to the operation.
52+
* Recommended to pass when using the Local API from hooks, as usually you want to execute the operation within the current transaction.
53+
*/
2054
req?: Partial<PayloadRequest>
55+
/**
56+
* Specify [select](https://payloadcms.com/docs/queries/select) to control which fields to include to the result.
57+
*/
2158
select?: SelectType
59+
/**
60+
* Opt-in to receiving hidden fields. By default, they are hidden from returned documents in accordance to your config.
61+
* @default false
62+
*/
2263
showHiddenFields?: boolean
64+
/**
65+
* the Global slug to operate against.
66+
*/
2367
slug: TSlug
68+
/**
69+
* If you set `overrideAccess` to `false`, you can pass a user to use against the access control checks.
70+
*/
2471
user?: Document
2572
}
2673

packages/payload/src/globals/operations/local/findVersions.ts

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,77 @@ import { createLocalReq } from '../../../utilities/createLocalReq.js'
1818
import { findVersionsOperation } from '../findVersions.js'
1919

2020
export type Options<TSlug extends GlobalSlug> = {
21+
/**
22+
* [Context](https://payloadcms.com/docs/hooks/context), which will then be passed to `context` and `req.context`,
23+
* which can be read by hooks. Useful if you want to pass additional information to the hooks which
24+
* shouldn't be necessarily part of the document, for example a `triggerBeforeChange` option which can be read by the BeforeChange hook
25+
* to determine if it should run or not.
26+
*/
2127
context?: RequestContext
28+
/**
29+
* [Control auto-population](https://payloadcms.com/docs/queries/depth) of nested relationship and upload fields.
30+
*/
2231
depth?: number
32+
/**
33+
* Specify a [fallback locale](https://payloadcms.com/docs/configuration/localization) to use for any returned documents.
34+
*/
2335
fallbackLocale?: false | TypedLocale
36+
/**
37+
* The maximum related documents to be returned.
38+
* Defaults unless `defaultLimit` is specified for the collection config
39+
* @default 10
40+
*/
2441
limit?: number
42+
/**
43+
* Specify [locale](https://payloadcms.com/docs/configuration/localization) for any returned documents.
44+
*/
2545
locale?: 'all' | TypedLocale
46+
/**
47+
* Skip access control.
48+
* Set to `false` if you want to respect Access Control for the operation, for example when fetching data for the fron-end.
49+
* @default true
50+
*/
2651
overrideAccess?: boolean
52+
/**
53+
* Get a specific page number
54+
* @default 1
55+
*/
2756
page?: number
57+
/**
58+
* Specify [populate](https://payloadcms.com/docs/queries/select#populate) to control which fields to include to the result from populated documents.
59+
*/
2860
populate?: PopulateType
61+
/**
62+
* The `PayloadRequest` object. You can pass it to thread the current [transaction](https://payloadcms.com/docs/database/transactions), user and locale to the operation.
63+
* Recommended to pass when using the Local API from hooks, as usually you want to execute the operation within the current transaction.
64+
*/
2965
req?: Partial<PayloadRequest>
66+
/**
67+
* Specify [select](https://payloadcms.com/docs/queries/select) to control which fields to include to the result.
68+
*/
3069
select?: SelectType
70+
/**
71+
* Opt-in to receiving hidden fields. By default, they are hidden from returned documents in accordance to your config.
72+
* @default false
73+
*/
3174
showHiddenFields?: boolean
75+
/**
76+
* the Global slug to operate against.
77+
*/
3278
slug: TSlug
79+
/**
80+
* Sort the documents, can be a string or an array of strings
81+
* @example '-version.createdAt' // Sort DESC by createdAt
82+
* @example ['version.group', '-version.createdAt'] // sort by 2 fields, ASC group and DESC createdAt
83+
*/
3384
sort?: Sort
85+
/**
86+
* If you set `overrideAccess` to `false`, you can pass a user to use against the access control checks.
87+
*/
3488
user?: Document
89+
/**
90+
* A filter [query](https://payloadcms.com/docs/queries/overview)
91+
*/
3592
where?: Where
3693
}
3794

packages/payload/src/globals/operations/local/restoreVersion.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,56 @@ import { createLocalReq } from '../../../utilities/createLocalReq.js'
99
import { restoreVersionOperation } from '../restoreVersion.js'
1010

1111
export type Options<TSlug extends GlobalSlug> = {
12+
/**
13+
* [Context](https://payloadcms.com/docs/hooks/context), which will then be passed to `context` and `req.context`,
14+
* which can be read by hooks. Useful if you want to pass additional information to the hooks which
15+
* shouldn't be necessarily part of the document, for example a `triggerBeforeChange` option which can be read by the BeforeChange hook
16+
* to determine if it should run or not.
17+
*/
1218
context?: RequestContext
19+
/**
20+
* [Control auto-population](https://payloadcms.com/docs/queries/depth) of nested relationship and upload fields.
21+
*/
1322
depth?: number
23+
/**
24+
* Specify a [fallback locale](https://payloadcms.com/docs/configuration/localization) to use for any returned documents.
25+
*/
1426
fallbackLocale?: false | TypedLocale
27+
/**
28+
* The ID of the version to restore.
29+
*/
1530
id: string
31+
/**
32+
* Specify [locale](https://payloadcms.com/docs/configuration/localization) for any returned documents.
33+
*/
1634
locale?: TypedLocale
35+
/**
36+
* Skip access control.
37+
* Set to `false` if you want to respect Access Control for the operation, for example when fetching data for the fron-end.
38+
* @default true
39+
*/
1740
overrideAccess?: boolean
41+
/**
42+
* Specify [populate](https://payloadcms.com/docs/queries/select#populate) to control which fields to include to the result from populated documents.
43+
*/
1844
populate?: PopulateType
45+
/**
46+
* The `PayloadRequest` object. You can pass it to thread the current [transaction](https://payloadcms.com/docs/database/transactions), user and locale to the operation.
47+
* Recommended to pass when using the Local API from hooks, as usually you want to execute the operation within the current transaction.
48+
*/
1949
req?: Partial<PayloadRequest>
50+
/**
51+
* Opt-in to receiving hidden fields. By default, they are hidden from returned documents in accordance to your config.
52+
* @default false
53+
*/
2054
showHiddenFields?: boolean
55+
/**
56+
* the Global slug to operate against.
57+
*/
2158
slug: TSlug
59+
/**
60+
* If you set `overrideAccess` to `false`, you can pass a user to use against the access control checks.
61+
*/
2262
user?: Document
2363
}
2464

packages/payload/src/globals/operations/local/update.ts

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,74 @@ import { createLocalReq } from '../../../utilities/createLocalReq.js'
2222
import { updateOperation } from '../update.js'
2323

2424
export type Options<TSlug extends GlobalSlug, TSelect extends SelectType> = {
25+
/**
26+
* [Context](https://payloadcms.com/docs/hooks/context), which will then be passed to `context` and `req.context`,
27+
* which can be read by hooks. Useful if you want to pass additional information to the hooks which
28+
* shouldn't be necessarily part of the document, for example a `triggerBeforeChange` option which can be read by the BeforeChange hook
29+
* to determine if it should run or not.
30+
*/
2531
context?: RequestContext
32+
/**
33+
* The global data to update.
34+
*/
2635
data: DeepPartial<Omit<DataFromGlobalSlug<TSlug>, 'id'>>
36+
/**
37+
* [Control auto-population](https://payloadcms.com/docs/queries/depth) of nested relationship and upload fields.
38+
*/
2739
depth?: number
40+
/**
41+
* Update documents to a draft.
42+
*/
2843
draft?: boolean
44+
/**
45+
* Specify a [fallback locale](https://payloadcms.com/docs/configuration/localization) to use for any returned documents.
46+
*/
2947
fallbackLocale?: false | TypedLocale
48+
/**
49+
* Specify [locale](https://payloadcms.com/docs/configuration/localization) for any returned documents.
50+
*/
3051
locale?: 'all' | TypedLocale
52+
/**
53+
* Skip access control.
54+
* Set to `false` if you want to respect Access Control for the operation, for example when fetching data for the fron-end.
55+
* @default true
56+
*/
3157
overrideAccess?: boolean
58+
/**
59+
* If you are uploading a file and would like to replace
60+
* the existing file instead of generating a new filename,
61+
* you can set the following property to `true`
62+
*/
3263
overrideLock?: boolean
64+
/**
65+
* Specify [populate](https://payloadcms.com/docs/queries/select#populate) to control which fields to include to the result from populated documents.
66+
*/
3367
populate?: PopulateType
68+
/**
69+
* Publish the document / documents with a specific locale.
70+
*/
3471
publishSpecificLocale?: TypedLocale
72+
/**
73+
* The `PayloadRequest` object. You can pass it to thread the current [transaction](https://payloadcms.com/docs/database/transactions), user and locale to the operation.
74+
* Recommended to pass when using the Local API from hooks, as usually you want to execute the operation within the current transaction.
75+
*/
3576
req?: Partial<PayloadRequest>
77+
/**
78+
* Specify [select](https://payloadcms.com/docs/queries/select) to control which fields to include to the result.
79+
*/
3680
select?: TSelect
81+
/**
82+
* Opt-in to receiving hidden fields. By default, they are hidden from returned documents in accordance to your config.
83+
* @default false
84+
*/
3785
showHiddenFields?: boolean
86+
/**
87+
* the Global slug to operate against.
88+
*/
3889
slug: TSlug
90+
/**
91+
* If you set `overrideAccess` to `false`, you can pass a user to use against the access control checks.
92+
*/
3993
user?: Document
4094
}
4195

0 commit comments

Comments
 (0)