payload 3.0.0-beta.100 → 3.0.0-beta.102

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.
Files changed (124) hide show
  1. package/dist/admin/RichText.d.ts +2 -2
  2. package/dist/admin/RichText.d.ts.map +1 -1
  3. package/dist/admin/RichText.js.map +1 -1
  4. package/dist/admin/fields/Array.d.ts +8 -3
  5. package/dist/admin/fields/Array.d.ts.map +1 -1
  6. package/dist/admin/fields/Array.js.map +1 -1
  7. package/dist/admin/fields/Blocks.d.ts +8 -3
  8. package/dist/admin/fields/Blocks.d.ts.map +1 -1
  9. package/dist/admin/fields/Blocks.js.map +1 -1
  10. package/dist/admin/fields/Checkbox.d.ts +8 -3
  11. package/dist/admin/fields/Checkbox.d.ts.map +1 -1
  12. package/dist/admin/fields/Checkbox.js.map +1 -1
  13. package/dist/admin/fields/Code.d.ts +9 -4
  14. package/dist/admin/fields/Code.d.ts.map +1 -1
  15. package/dist/admin/fields/Code.js.map +1 -1
  16. package/dist/admin/fields/Collapsible.d.ts +6 -2
  17. package/dist/admin/fields/Collapsible.d.ts.map +1 -1
  18. package/dist/admin/fields/Collapsible.js.map +1 -1
  19. package/dist/admin/fields/Date.d.ts +8 -3
  20. package/dist/admin/fields/Date.d.ts.map +1 -1
  21. package/dist/admin/fields/Date.js.map +1 -1
  22. package/dist/admin/fields/Email.d.ts +8 -3
  23. package/dist/admin/fields/Email.d.ts.map +1 -1
  24. package/dist/admin/fields/Email.js.map +1 -1
  25. package/dist/admin/fields/Group.d.ts +6 -2
  26. package/dist/admin/fields/Group.d.ts.map +1 -1
  27. package/dist/admin/fields/Group.js.map +1 -1
  28. package/dist/admin/fields/JSON.d.ts +8 -3
  29. package/dist/admin/fields/JSON.d.ts.map +1 -1
  30. package/dist/admin/fields/JSON.js.map +1 -1
  31. package/dist/admin/fields/Number.d.ts +8 -3
  32. package/dist/admin/fields/Number.d.ts.map +1 -1
  33. package/dist/admin/fields/Number.js.map +1 -1
  34. package/dist/admin/fields/Point.d.ts +8 -3
  35. package/dist/admin/fields/Point.d.ts.map +1 -1
  36. package/dist/admin/fields/Point.js.map +1 -1
  37. package/dist/admin/fields/Radio.d.ts +8 -3
  38. package/dist/admin/fields/Radio.d.ts.map +1 -1
  39. package/dist/admin/fields/Radio.js.map +1 -1
  40. package/dist/admin/fields/Relationship.d.ts +8 -3
  41. package/dist/admin/fields/Relationship.d.ts.map +1 -1
  42. package/dist/admin/fields/Relationship.js.map +1 -1
  43. package/dist/admin/fields/RichText.d.ts +8 -3
  44. package/dist/admin/fields/RichText.d.ts.map +1 -1
  45. package/dist/admin/fields/RichText.js.map +1 -1
  46. package/dist/admin/fields/Row.d.ts +8 -3
  47. package/dist/admin/fields/Row.d.ts.map +1 -1
  48. package/dist/admin/fields/Row.js.map +1 -1
  49. package/dist/admin/fields/Select.d.ts +8 -3
  50. package/dist/admin/fields/Select.d.ts.map +1 -1
  51. package/dist/admin/fields/Select.js.map +1 -1
  52. package/dist/admin/fields/Tabs.d.ts +8 -3
  53. package/dist/admin/fields/Tabs.d.ts.map +1 -1
  54. package/dist/admin/fields/Tabs.js.map +1 -1
  55. package/dist/admin/fields/Text.d.ts +8 -3
  56. package/dist/admin/fields/Text.d.ts.map +1 -1
  57. package/dist/admin/fields/Text.js.map +1 -1
  58. package/dist/admin/fields/Textarea.d.ts +8 -3
  59. package/dist/admin/fields/Textarea.d.ts.map +1 -1
  60. package/dist/admin/fields/Textarea.js.map +1 -1
  61. package/dist/admin/fields/Upload.d.ts +8 -3
  62. package/dist/admin/fields/Upload.d.ts.map +1 -1
  63. package/dist/admin/fields/Upload.js.map +1 -1
  64. package/dist/admin/forms/Description.d.ts +2 -4
  65. package/dist/admin/forms/Description.d.ts.map +1 -1
  66. package/dist/admin/forms/Description.js.map +1 -1
  67. package/dist/admin/forms/Error.d.ts +2 -4
  68. package/dist/admin/forms/Error.d.ts.map +1 -1
  69. package/dist/admin/forms/Error.js.map +1 -1
  70. package/dist/admin/forms/Field.d.ts +18 -7
  71. package/dist/admin/forms/Field.d.ts.map +1 -1
  72. package/dist/admin/forms/Field.js.map +1 -1
  73. package/dist/admin/forms/Label.d.ts +1 -3
  74. package/dist/admin/forms/Label.d.ts.map +1 -1
  75. package/dist/admin/forms/Label.js.map +1 -1
  76. package/dist/admin/types.d.ts +20 -20
  77. package/dist/admin/types.d.ts.map +1 -1
  78. package/dist/admin/types.js.map +1 -1
  79. package/dist/auth/operations/auth.d.ts.map +1 -1
  80. package/dist/auth/operations/auth.js +0 -6
  81. package/dist/auth/operations/auth.js.map +1 -1
  82. package/dist/auth/operations/login.d.ts.map +1 -1
  83. package/dist/auth/operations/login.js +0 -9
  84. package/dist/auth/operations/login.js.map +1 -1
  85. package/dist/collections/config/sanitize.d.ts.map +1 -1
  86. package/dist/collections/config/sanitize.js +2 -0
  87. package/dist/collections/config/sanitize.js.map +1 -1
  88. package/dist/collections/config/useAsTitle.d.ts +6 -0
  89. package/dist/collections/config/useAsTitle.d.ts.map +1 -0
  90. package/dist/collections/config/useAsTitle.js +33 -0
  91. package/dist/collections/config/useAsTitle.js.map +1 -0
  92. package/dist/collections/config/useAsTitle.spec.js +186 -0
  93. package/dist/collections/config/useAsTitle.spec.js.map +1 -0
  94. package/dist/collections/dataloader.js +2 -2
  95. package/dist/collections/dataloader.js.map +1 -1
  96. package/dist/fields/baseFields/baseBeforeDuplicateArrays.d.ts +6 -0
  97. package/dist/fields/baseFields/baseBeforeDuplicateArrays.d.ts.map +1 -0
  98. package/dist/fields/baseFields/baseBeforeDuplicateArrays.js +15 -0
  99. package/dist/fields/baseFields/baseBeforeDuplicateArrays.js.map +1 -0
  100. package/dist/fields/config/sanitize.d.ts.map +1 -1
  101. package/dist/fields/config/sanitize.js +19 -0
  102. package/dist/fields/config/sanitize.js.map +1 -1
  103. package/dist/fields/config/types.d.ts +2 -2
  104. package/dist/fields/config/types.d.ts.map +1 -1
  105. package/dist/fields/config/types.js.map +1 -1
  106. package/dist/preferences/operations/delete.d.ts +1 -2
  107. package/dist/preferences/operations/delete.d.ts.map +1 -1
  108. package/dist/preferences/operations/delete.js +2 -10
  109. package/dist/preferences/operations/delete.js.map +1 -1
  110. package/dist/preferences/operations/findOne.d.ts +1 -2
  111. package/dist/preferences/operations/findOne.d.ts.map +1 -1
  112. package/dist/preferences/operations/findOne.js +6 -3
  113. package/dist/preferences/operations/findOne.js.map +1 -1
  114. package/dist/preferences/operations/update.d.ts +1 -9
  115. package/dist/preferences/operations/update.d.ts.map +1 -1
  116. package/dist/preferences/operations/update.js +25 -24
  117. package/dist/preferences/operations/update.js.map +1 -1
  118. package/dist/preferences/requestHandlers/delete.js +1 -1
  119. package/dist/preferences/requestHandlers/delete.js.map +1 -1
  120. package/dist/preferences/requestHandlers/findOne.js +1 -1
  121. package/dist/preferences/requestHandlers/findOne.js.map +1 -1
  122. package/dist/preferences/requestHandlers/update.js +1 -1
  123. package/dist/preferences/requestHandlers/update.js.map +1 -1
  124. package/package.json +2 -2
@@ -0,0 +1,186 @@
1
+ import { InvalidConfiguration } from '../../errors/InvalidConfiguration.js';
2
+ import { sanitizeCollection } from './sanitize.js';
3
+ describe('sanitize - collections -', ()=>{
4
+ const config = {
5
+ collections: [],
6
+ globals: []
7
+ };
8
+ describe('validate useAsTitle -', ()=>{
9
+ const defaultCollection = {
10
+ slug: 'collection-with-defaults',
11
+ fields: [
12
+ {
13
+ name: 'title',
14
+ type: 'text'
15
+ }
16
+ ]
17
+ };
18
+ it('should throw on invalid field', async ()=>{
19
+ const collectionConfig = {
20
+ ...defaultCollection,
21
+ admin: {
22
+ useAsTitle: 'invalidField'
23
+ }
24
+ };
25
+ await expect(async ()=>{
26
+ await sanitizeCollection(// @ts-expect-error
27
+ {
28
+ ...config,
29
+ collections: [
30
+ collectionConfig
31
+ ]
32
+ }, collectionConfig);
33
+ }).rejects.toThrow(InvalidConfiguration);
34
+ });
35
+ it('should not throw on valid field', async ()=>{
36
+ const collectionConfig = {
37
+ ...defaultCollection,
38
+ admin: {
39
+ useAsTitle: 'title'
40
+ }
41
+ };
42
+ await expect(async ()=>{
43
+ await sanitizeCollection(// @ts-expect-error
44
+ {
45
+ ...config,
46
+ collections: [
47
+ collectionConfig
48
+ ]
49
+ }, collectionConfig);
50
+ }).not.toThrow();
51
+ });
52
+ it('should not throw on valid field inside tabs', async ()=>{
53
+ const collectionConfig = {
54
+ ...defaultCollection,
55
+ admin: {
56
+ useAsTitle: 'title'
57
+ },
58
+ fields: [
59
+ {
60
+ type: 'tabs',
61
+ tabs: [
62
+ {
63
+ label: 'General',
64
+ fields: [
65
+ {
66
+ name: 'title',
67
+ type: 'text'
68
+ }
69
+ ]
70
+ }
71
+ ]
72
+ }
73
+ ]
74
+ };
75
+ await expect(async ()=>{
76
+ await sanitizeCollection(// @ts-expect-error
77
+ {
78
+ ...config,
79
+ collections: [
80
+ collectionConfig
81
+ ]
82
+ }, collectionConfig);
83
+ }).not.toThrow();
84
+ });
85
+ it('should not throw on valid field inside collapsibles', async ()=>{
86
+ const collectionConfig = {
87
+ ...defaultCollection,
88
+ admin: {
89
+ useAsTitle: 'title'
90
+ },
91
+ fields: [
92
+ {
93
+ type: 'collapsible',
94
+ label: 'Collapsible',
95
+ fields: [
96
+ {
97
+ name: 'title',
98
+ type: 'text'
99
+ }
100
+ ]
101
+ }
102
+ ]
103
+ };
104
+ await expect(async ()=>{
105
+ await sanitizeCollection(// @ts-expect-error
106
+ {
107
+ ...config,
108
+ collections: [
109
+ collectionConfig
110
+ ]
111
+ }, collectionConfig);
112
+ }).not.toThrow();
113
+ });
114
+ it('should throw on nested useAsTitle', async ()=>{
115
+ const collectionConfig = {
116
+ ...defaultCollection,
117
+ admin: {
118
+ useAsTitle: 'content.title'
119
+ }
120
+ };
121
+ await expect(async ()=>{
122
+ await sanitizeCollection(// @ts-expect-error
123
+ {
124
+ ...config,
125
+ collections: [
126
+ collectionConfig
127
+ ]
128
+ }, collectionConfig);
129
+ }).rejects.toThrow(InvalidConfiguration);
130
+ });
131
+ it('should not throw on default field: id', async ()=>{
132
+ const collectionConfig = {
133
+ ...defaultCollection,
134
+ admin: {
135
+ useAsTitle: 'id'
136
+ }
137
+ };
138
+ await expect(async ()=>{
139
+ await sanitizeCollection(// @ts-expect-error
140
+ {
141
+ ...config,
142
+ collections: [
143
+ collectionConfig
144
+ ]
145
+ }, collectionConfig);
146
+ }).not.toThrow();
147
+ });
148
+ it('should not throw on default field: email if auth is enabled', async ()=>{
149
+ const collectionConfig = {
150
+ ...defaultCollection,
151
+ auth: true,
152
+ admin: {
153
+ useAsTitle: 'email'
154
+ }
155
+ };
156
+ await expect(async ()=>{
157
+ await sanitizeCollection(// @ts-expect-error
158
+ {
159
+ ...config,
160
+ collections: [
161
+ collectionConfig
162
+ ]
163
+ }, collectionConfig);
164
+ }).not.toThrow();
165
+ });
166
+ it('should throw on default field: email if auth is not enabled', async ()=>{
167
+ const collectionConfig = {
168
+ ...defaultCollection,
169
+ admin: {
170
+ useAsTitle: 'email'
171
+ }
172
+ };
173
+ await expect(async ()=>{
174
+ await sanitizeCollection(// @ts-expect-error
175
+ {
176
+ ...config,
177
+ collections: [
178
+ collectionConfig
179
+ ]
180
+ }, collectionConfig);
181
+ }).rejects.toThrow(InvalidConfiguration);
182
+ });
183
+ });
184
+ });
185
+
186
+ //# sourceMappingURL=useAsTitle.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/collections/config/useAsTitle.spec.ts"],"sourcesContent":["import type { Config } from '../../config/types.js'\nimport type { CollectionConfig } from '../../index.js'\n\nimport { InvalidConfiguration } from '../../errors/InvalidConfiguration.js'\nimport { sanitizeCollection } from './sanitize.js'\n\ndescribe('sanitize - collections -', () => {\n const config = {\n collections: [],\n globals: [],\n } as Partial<Config>\n\n describe('validate useAsTitle -', () => {\n const defaultCollection: CollectionConfig = {\n slug: 'collection-with-defaults',\n fields: [\n {\n name: 'title',\n type: 'text',\n },\n ],\n }\n\n it('should throw on invalid field', async () => {\n const collectionConfig: CollectionConfig = {\n ...defaultCollection,\n admin: {\n useAsTitle: 'invalidField',\n },\n }\n await expect(async () => {\n await sanitizeCollection(\n // @ts-expect-error\n {\n ...config,\n collections: [collectionConfig],\n },\n collectionConfig,\n )\n }).rejects.toThrow(InvalidConfiguration)\n })\n\n it('should not throw on valid field', async () => {\n const collectionConfig: CollectionConfig = {\n ...defaultCollection,\n admin: {\n useAsTitle: 'title',\n },\n }\n await expect(async () => {\n await sanitizeCollection(\n // @ts-expect-error\n {\n ...config,\n collections: [collectionConfig],\n },\n collectionConfig,\n )\n }).not.toThrow()\n })\n\n it('should not throw on valid field inside tabs', async () => {\n const collectionConfig: CollectionConfig = {\n ...defaultCollection,\n admin: {\n useAsTitle: 'title',\n },\n fields: [\n {\n type: 'tabs',\n tabs: [\n {\n label: 'General',\n fields: [\n {\n name: 'title',\n type: 'text',\n },\n ],\n },\n ],\n },\n ],\n }\n await expect(async () => {\n await sanitizeCollection(\n // @ts-expect-error\n {\n ...config,\n collections: [collectionConfig],\n },\n collectionConfig,\n )\n }).not.toThrow()\n })\n\n it('should not throw on valid field inside collapsibles', async () => {\n const collectionConfig: CollectionConfig = {\n ...defaultCollection,\n admin: {\n useAsTitle: 'title',\n },\n fields: [\n {\n type: 'collapsible',\n label: 'Collapsible',\n fields: [\n {\n name: 'title',\n type: 'text',\n },\n ],\n },\n ],\n }\n await expect(async () => {\n await sanitizeCollection(\n // @ts-expect-error\n {\n ...config,\n collections: [collectionConfig],\n },\n collectionConfig,\n )\n }).not.toThrow()\n })\n\n it('should throw on nested useAsTitle', async () => {\n const collectionConfig: CollectionConfig = {\n ...defaultCollection,\n admin: {\n useAsTitle: 'content.title',\n },\n }\n await expect(async () => {\n await sanitizeCollection(\n // @ts-expect-error\n {\n ...config,\n collections: [collectionConfig],\n },\n collectionConfig,\n )\n }).rejects.toThrow(InvalidConfiguration)\n })\n\n it('should not throw on default field: id', async () => {\n const collectionConfig: CollectionConfig = {\n ...defaultCollection,\n admin: {\n useAsTitle: 'id',\n },\n }\n await expect(async () => {\n await sanitizeCollection(\n // @ts-expect-error\n {\n ...config,\n collections: [collectionConfig],\n },\n collectionConfig,\n )\n }).not.toThrow()\n })\n\n it('should not throw on default field: email if auth is enabled', async () => {\n const collectionConfig: CollectionConfig = {\n ...defaultCollection,\n auth: true,\n admin: {\n useAsTitle: 'email',\n },\n }\n await expect(async () => {\n await sanitizeCollection(\n // @ts-expect-error\n {\n ...config,\n collections: [collectionConfig],\n },\n collectionConfig,\n )\n }).not.toThrow()\n })\n it('should throw on default field: email if auth is not enabled', async () => {\n const collectionConfig: CollectionConfig = {\n ...defaultCollection,\n admin: {\n useAsTitle: 'email',\n },\n }\n await expect(async () => {\n await sanitizeCollection(\n // @ts-expect-error\n {\n ...config,\n collections: [collectionConfig],\n },\n collectionConfig,\n )\n }).rejects.toThrow(InvalidConfiguration)\n })\n })\n})\n"],"names":["InvalidConfiguration","sanitizeCollection","describe","config","collections","globals","defaultCollection","slug","fields","name","type","it","collectionConfig","admin","useAsTitle","expect","rejects","toThrow","not","tabs","label","auth"],"mappings":"AAGA,SAASA,oBAAoB,QAAQ,uCAAsC;AAC3E,SAASC,kBAAkB,QAAQ,gBAAe;AAElDC,SAAS,4BAA4B;IACnC,MAAMC,SAAS;QACbC,aAAa,EAAE;QACfC,SAAS,EAAE;IACb;IAEAH,SAAS,yBAAyB;QAChC,MAAMI,oBAAsC;YAC1CC,MAAM;YACNC,QAAQ;gBACN;oBACEC,MAAM;oBACNC,MAAM;gBACR;aACD;QACH;QAEAC,GAAG,iCAAiC;YAClC,MAAMC,mBAAqC;gBACzC,GAAGN,iBAAiB;gBACpBO,OAAO;oBACLC,YAAY;gBACd;YACF;YACA,MAAMC,OAAO;gBACX,MAAMd,mBACJ,mBAAmB;gBACnB;oBACE,GAAGE,MAAM;oBACTC,aAAa;wBAACQ;qBAAiB;gBACjC,GACAA;YAEJ,GAAGI,OAAO,CAACC,OAAO,CAACjB;QACrB;QAEAW,GAAG,mCAAmC;YACpC,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BACjC,GACAA;YAEJ,GAAGI,OAAO,CAACC,OAAO,CAACjB;QACrB;QAEAW,GAAG,yCAAyC;YAC1C,MAAMC,mBAAqC;gBACzC,GAAGN,iBAAiB;gBACpBO,OAAO;oBACLC,YAAY;gBACd;YACF;YACA,MAAMC,OAAO;gBACX,MAAMd,mBACJ,mBAAmB;gBACnB;oBACE,GAAGE,MAAM;oBACTC,aAAa;wBAACQ;qBAAiB;gBACjC,GACAA;YAEJ,GAAGM,GAAG,CAACD,OAAO;QAChB;QAEAN,GAAG,+DAA+D;YAChE,MAAMC,mBAAqC;gBACzC,GAAGN,iBAAiB;gBACpBe,MAAM;gBACNR,OAAO;oBACLC,YAAY;gBACd;YACF;YACA,MAAMC,OAAO;gBACX,MAAMd,mBACJ,mBAAmB;gBACnB;oBACE,GAAGE,MAAM;oBACTC,aAAa;wBAACQ;qBAAiB;gBACjC,GACAA;YAEJ,GAAGM,GAAG,CAACD,OAAO;QAChB;QACAN,GAAG,+DAA+D;YAChE,MAAMC,mBAAqC;gBACzC,GAAGN,iBAAiB;gBACpBO,OAAO;oBACLC,YAAY;gBACd;YACF;YACA,MAAMC,OAAO;gBACX,MAAMd,mBACJ,mBAAmB;gBACnB;oBACE,GAAGE,MAAM;oBACTC,aAAa;wBAACQ;qBAAiB;gBACjC,GACAA;YAEJ,GAAGI,OAAO,CAACC,OAAO,CAACjB;QACrB;IACF;AACF"}
@@ -89,8 +89,8 @@ const batchAndLoadDocs = (req)=>async (keys)=>{
89
89
  depth,
90
90
  docID: doc.id,
91
91
  draft,
92
- fallbackLocale: req.fallbackLocale,
93
- locale: req.locale,
92
+ fallbackLocale,
93
+ locale,
94
94
  overrideAccess,
95
95
  showHiddenFields,
96
96
  transactionID: req.transactionID
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/collections/dataloader.ts"],"sourcesContent":["import type { BatchLoadFn } from 'dataloader'\n\nimport DataLoader from 'dataloader'\n\nimport type { PayloadRequest } from '../types/index.js'\nimport type { TypeWithID } from './config/types.js'\n\nimport { isValidID } from '../utilities/isValidID.js'\n\n// Payload uses `dataloader` to solve the classic GraphQL N+1 problem.\n\n// We keep a list of all documents requested to be populated for any given request\n// and then batch together documents within the same collection,\n// making only 1 find per each collection, rather than `findByID` per each requested doc.\n\n// This dramatically improves performance for REST and Local API `depth` populations,\n// and also ensures complex GraphQL queries perform lightning-fast.\n\nconst batchAndLoadDocs =\n (req: PayloadRequest): BatchLoadFn<string, TypeWithID> =>\n async (keys: string[]): Promise<TypeWithID[]> => {\n const { payload } = req\n\n // Create docs array of same length as keys, using null as value\n // We will replace nulls with injected docs as they are retrieved\n const docs: (null | TypeWithID)[] = keys.map(() => null)\n\n /**\n * Batch IDs by their `find` args\n * so we can make one find query per combination of collection, depth, locale, and fallbackLocale.\n *\n * Resulting shape will be as follows:\n {\n // key is stringified set of find args\n '[null,\"pages\",2,0,\"es\",\"en\",false,false]': [\n // value is array of IDs to find with these args\n 'q34tl23462346234524',\n '435523540194324280',\n '2346245j35l3j5234532li',\n ],\n // etc\n };\n *\n **/\n\n const batchByFindArgs = keys.reduce((batches, key) => {\n const [\n transactionID,\n collection,\n id,\n depth,\n currentDepth,\n locale,\n fallbackLocale,\n overrideAccess,\n showHiddenFields,\n draft,\n ] = JSON.parse(key)\n\n const batchKeyArray = [\n transactionID,\n collection,\n depth,\n currentDepth,\n locale,\n fallbackLocale,\n overrideAccess,\n showHiddenFields,\n draft,\n ]\n\n const batchKey = JSON.stringify(batchKeyArray)\n\n const idType = payload.collections?.[collection].customIDType || payload.db.defaultIDType\n\n let sanitizedID: number | string = id\n\n if (idType === 'number') {\n sanitizedID = parseFloat(id)\n }\n\n if (isValidID(sanitizedID, idType)) {\n return {\n ...batches,\n [batchKey]: [...(batches[batchKey] || []), sanitizedID],\n }\n }\n return batches\n }, {})\n\n // Run find requests one after another, so as to not hang transactions\n\n await Object.entries(batchByFindArgs).reduce(async (priorFind, [batchKey, ids]) => {\n await priorFind\n\n const [\n transactionID,\n collection,\n depth,\n currentDepth,\n locale,\n fallbackLocale,\n overrideAccess,\n showHiddenFields,\n draft,\n ] = JSON.parse(batchKey)\n\n req.transactionID = transactionID\n\n const result = await payload.find({\n collection,\n currentDepth,\n depth,\n disableErrors: true,\n draft,\n fallbackLocale,\n locale,\n overrideAccess: Boolean(overrideAccess),\n pagination: false,\n req,\n showHiddenFields: Boolean(showHiddenFields),\n where: {\n id: {\n in: ids,\n },\n },\n })\n\n // For each returned doc, find index in original keys\n // Inject doc within docs array if index exists\n\n result.docs.forEach((doc) => {\n const docKey = createDataloaderCacheKey({\n collectionSlug: collection,\n currentDepth,\n depth,\n docID: doc.id,\n draft,\n fallbackLocale: req.fallbackLocale,\n locale: req.locale,\n overrideAccess,\n showHiddenFields,\n transactionID: req.transactionID,\n })\n const docsIndex = keys.findIndex((key) => key === docKey)\n\n if (docsIndex > -1) {\n docs[docsIndex] = doc\n }\n })\n }, Promise.resolve())\n\n // Return docs array,\n // which has now been injected with all fetched docs\n // and should match the length of the incoming keys arg\n return docs\n }\n\nexport const getDataLoader = (req: PayloadRequest) => new DataLoader(batchAndLoadDocs(req))\n\ntype CreateCacheKeyArgs = {\n collectionSlug: string\n currentDepth: number\n depth: number\n docID: number | string\n draft: boolean\n fallbackLocale: string\n locale: string\n overrideAccess: boolean\n showHiddenFields: boolean\n transactionID: number | Promise<number | string> | string\n}\nexport const createDataloaderCacheKey = ({\n collectionSlug,\n currentDepth,\n depth,\n docID,\n draft,\n fallbackLocale,\n locale,\n overrideAccess,\n showHiddenFields,\n transactionID,\n}: CreateCacheKeyArgs): string =>\n JSON.stringify([\n transactionID,\n collectionSlug,\n docID,\n depth,\n currentDepth,\n locale,\n fallbackLocale,\n overrideAccess,\n showHiddenFields,\n draft,\n ])\n"],"names":["DataLoader","isValidID","batchAndLoadDocs","req","keys","payload","docs","map","batchByFindArgs","reduce","batches","key","transactionID","collection","id","depth","currentDepth","locale","fallbackLocale","overrideAccess","showHiddenFields","draft","JSON","parse","batchKeyArray","batchKey","stringify","idType","collections","customIDType","db","defaultIDType","sanitizedID","parseFloat","Object","entries","priorFind","ids","result","find","disableErrors","Boolean","pagination","where","in","forEach","doc","docKey","createDataloaderCacheKey","collectionSlug","docID","docsIndex","findIndex","Promise","resolve","getDataLoader"],"mappings":"AAEA,OAAOA,gBAAgB,aAAY;AAKnC,SAASC,SAAS,QAAQ,4BAA2B;AAErD,sEAAsE;AAEtE,kFAAkF;AAClF,gEAAgE;AAChE,yFAAyF;AAEzF,qFAAqF;AACrF,mEAAmE;AAEnE,MAAMC,mBACJ,CAACC,MACD,OAAOC;QACL,MAAM,EAAEC,OAAO,EAAE,GAAGF;QAEpB,gEAAgE;QAChE,iEAAiE;QACjE,MAAMG,OAA8BF,KAAKG,GAAG,CAAC,IAAM;QAEnD;;;;;;;;;;;;;;;;KAgBC,GAED,MAAMC,kBAAkBJ,KAAKK,MAAM,CAAC,CAACC,SAASC;YAC5C,MAAM,CACJC,eACAC,YACAC,IACAC,OACAC,cACAC,QACAC,gBACAC,gBACAC,kBACAC,MACD,GAAGC,KAAKC,KAAK,CAACZ;YAEf,MAAMa,gBAAgB;gBACpBZ;gBACAC;gBACAE;gBACAC;gBACAC;gBACAC;gBACAC;gBACAC;gBACAC;aACD;YAED,MAAMI,WAAWH,KAAKI,SAAS,CAACF;YAEhC,MAAMG,SAAStB,QAAQuB,WAAW,EAAE,CAACf,WAAW,CAACgB,gBAAgBxB,QAAQyB,EAAE,CAACC,aAAa;YAEzF,IAAIC,cAA+BlB;YAEnC,IAAIa,WAAW,UAAU;gBACvBK,cAAcC,WAAWnB;YAC3B;YAEA,IAAIb,UAAU+B,aAAaL,SAAS;gBAClC,OAAO;oBACL,GAAGjB,OAAO;oBACV,CAACe,SAAS,EAAE;2BAAKf,OAAO,CAACe,SAAS,IAAI,EAAE;wBAAGO;qBAAY;gBACzD;YACF;YACA,OAAOtB;QACT,GAAG,CAAC;QAEJ,sEAAsE;QAEtE,MAAMwB,OAAOC,OAAO,CAAC3B,iBAAiB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,CAAC;QACbd;QACAqC;QACAC;QACAnC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;KACD,EAAC"}
1
+ {"version":3,"sources":["../../src/collections/dataloader.ts"],"sourcesContent":["import type { BatchLoadFn } from 'dataloader'\n\nimport DataLoader from 'dataloader'\n\nimport type { PayloadRequest } from '../types/index.js'\nimport type { TypeWithID } from './config/types.js'\n\nimport { isValidID } from '../utilities/isValidID.js'\n\n// Payload uses `dataloader` to solve the classic GraphQL N+1 problem.\n\n// We keep a list of all documents requested to be populated for any given request\n// and then batch together documents within the same collection,\n// making only 1 find per each collection, rather than `findByID` per each requested doc.\n\n// This dramatically improves performance for REST and Local API `depth` populations,\n// and also ensures complex GraphQL queries perform lightning-fast.\n\nconst batchAndLoadDocs =\n (req: PayloadRequest): BatchLoadFn<string, TypeWithID> =>\n async (keys: string[]): Promise<TypeWithID[]> => {\n const { payload } = req\n\n // Create docs array of same length as keys, using null as value\n // We will replace nulls with injected docs as they are retrieved\n const docs: (null | TypeWithID)[] = keys.map(() => null)\n\n /**\n * Batch IDs by their `find` args\n * so we can make one find query per combination of collection, depth, locale, and fallbackLocale.\n *\n * Resulting shape will be as follows:\n {\n // key is stringified set of find args\n '[null,\"pages\",2,0,\"es\",\"en\",false,false]': [\n // value is array of IDs to find with these args\n 'q34tl23462346234524',\n '435523540194324280',\n '2346245j35l3j5234532li',\n ],\n // etc\n };\n *\n **/\n\n const batchByFindArgs = keys.reduce((batches, key) => {\n const [\n transactionID,\n collection,\n id,\n depth,\n currentDepth,\n locale,\n fallbackLocale,\n overrideAccess,\n showHiddenFields,\n draft,\n ] = JSON.parse(key)\n\n const batchKeyArray = [\n transactionID,\n collection,\n depth,\n currentDepth,\n locale,\n fallbackLocale,\n overrideAccess,\n showHiddenFields,\n draft,\n ]\n\n const batchKey = JSON.stringify(batchKeyArray)\n\n const idType = payload.collections?.[collection].customIDType || payload.db.defaultIDType\n\n let sanitizedID: number | string = id\n\n if (idType === 'number') {\n sanitizedID = parseFloat(id)\n }\n\n if (isValidID(sanitizedID, idType)) {\n return {\n ...batches,\n [batchKey]: [...(batches[batchKey] || []), sanitizedID],\n }\n }\n return batches\n }, {})\n\n // Run find requests one after another, so as to not hang transactions\n\n await Object.entries(batchByFindArgs).reduce(async (priorFind, [batchKey, ids]) => {\n await priorFind\n\n const [\n transactionID,\n collection,\n depth,\n currentDepth,\n locale,\n fallbackLocale,\n overrideAccess,\n showHiddenFields,\n draft,\n ] = JSON.parse(batchKey)\n\n req.transactionID = transactionID\n\n const result = await payload.find({\n collection,\n currentDepth,\n depth,\n disableErrors: true,\n draft,\n fallbackLocale,\n locale,\n overrideAccess: Boolean(overrideAccess),\n pagination: false,\n req,\n showHiddenFields: Boolean(showHiddenFields),\n where: {\n id: {\n in: ids,\n },\n },\n })\n\n // For each returned doc, find index in original keys\n // Inject doc within docs array if index exists\n\n result.docs.forEach((doc) => {\n const docKey = createDataloaderCacheKey({\n collectionSlug: collection,\n currentDepth,\n depth,\n docID: doc.id,\n draft,\n fallbackLocale,\n locale,\n overrideAccess,\n showHiddenFields,\n transactionID: req.transactionID,\n })\n const docsIndex = keys.findIndex((key) => key === docKey)\n\n if (docsIndex > -1) {\n docs[docsIndex] = doc\n }\n })\n }, Promise.resolve())\n\n // Return docs array,\n // which has now been injected with all fetched docs\n // and should match the length of the incoming keys arg\n return docs\n }\n\nexport const getDataLoader = (req: PayloadRequest) => new DataLoader(batchAndLoadDocs(req))\n\ntype CreateCacheKeyArgs = {\n collectionSlug: string\n currentDepth: number\n depth: number\n docID: number | string\n draft: boolean\n fallbackLocale: string\n locale: string\n overrideAccess: boolean\n showHiddenFields: boolean\n transactionID: number | Promise<number | string> | string\n}\nexport const createDataloaderCacheKey = ({\n collectionSlug,\n currentDepth,\n depth,\n docID,\n draft,\n fallbackLocale,\n locale,\n overrideAccess,\n showHiddenFields,\n transactionID,\n}: CreateCacheKeyArgs): string =>\n JSON.stringify([\n transactionID,\n collectionSlug,\n docID,\n depth,\n currentDepth,\n locale,\n fallbackLocale,\n overrideAccess,\n showHiddenFields,\n draft,\n ])\n"],"names":["DataLoader","isValidID","batchAndLoadDocs","req","keys","payload","docs","map","batchByFindArgs","reduce","batches","key","transactionID","collection","id","depth","currentDepth","locale","fallbackLocale","overrideAccess","showHiddenFields","draft","JSON","parse","batchKeyArray","batchKey","stringify","idType","collections","customIDType","db","defaultIDType","sanitizedID","parseFloat","Object","entries","priorFind","ids","result","find","disableErrors","Boolean","pagination","where","in","forEach","doc","docKey","createDataloaderCacheKey","collectionSlug","docID","docsIndex","findIndex","Promise","resolve","getDataLoader"],"mappings":"AAEA,OAAOA,gBAAgB,aAAY;AAKnC,SAASC,SAAS,QAAQ,4BAA2B;AAErD,sEAAsE;AAEtE,kFAAkF;AAClF,gEAAgE;AAChE,yFAAyF;AAEzF,qFAAqF;AACrF,mEAAmE;AAEnE,MAAMC,mBACJ,CAACC,MACD,OAAOC;QACL,MAAM,EAAEC,OAAO,EAAE,GAAGF;QAEpB,gEAAgE;QAChE,iEAAiE;QACjE,MAAMG,OAA8BF,KAAKG,GAAG,CAAC,IAAM;QAEnD;;;;;;;;;;;;;;;;KAgBC,GAED,MAAMC,kBAAkBJ,KAAKK,MAAM,CAAC,CAACC,SAASC;YAC5C,MAAM,CACJC,eACAC,YACAC,IACAC,OACAC,cACAC,QACAC,gBACAC,gBACAC,kBACAC,MACD,GAAGC,KAAKC,KAAK,CAACZ;YAEf,MAAMa,gBAAgB;gBACpBZ;gBACAC;gBACAE;gBACAC;gBACAC;gBACAC;gBACAC;gBACAC;gBACAC;aACD;YAED,MAAMI,WAAWH,KAAKI,SAAS,CAACF;YAEhC,MAAMG,SAAStB,QAAQuB,WAAW,EAAE,CAACf,WAAW,CAACgB,gBAAgBxB,QAAQyB,EAAE,CAACC,aAAa;YAEzF,IAAIC,cAA+BlB;YAEnC,IAAIa,WAAW,UAAU;gBACvBK,cAAcC,WAAWnB;YAC3B;YAEA,IAAIb,UAAU+B,aAAaL,SAAS;gBAClC,O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,CAAC,EACvCC,cAAc,EACdjC,YAAY,EACZD,KAAK,EACLmC,KAAK,EACL7B,KAAK,EACLH,cAAc,EACdD,MAAM,EACNE,cAAc,EACdC,gBAAgB,EAChBR,aAAa,EACM,GACnBU,KAAKI,SAAS,CAAC;QACbd;QACAqC;QACAC;QACAnC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;KACD,EAAC"}
@@ -0,0 +1,6 @@
1
+ import type { FieldHook } from '../config/types.js';
2
+ /**
3
+ * Arrays and Blocks need to clear ids beforeDuplicate
4
+ */
5
+ export declare const baseBeforeDuplicateArrays: FieldHook;
6
+ //# sourceMappingURL=baseBeforeDuplicateArrays.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"baseBeforeDuplicateArrays.d.ts","sourceRoot":"","sources":["../../../src/fields/baseFields/baseBeforeDuplicateArrays.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAInD;;GAEG;AACH,eAAO,MAAM,yBAAyB,EAAE,SAQvC,CAAA"}
@@ -0,0 +1,15 @@
1
+ import ObjectIdImport from 'bson-objectid';
2
+ const ObjectId = ObjectIdImport.default || ObjectIdImport;
3
+ /**
4
+ * Arrays and Blocks need to clear ids beforeDuplicate
5
+ */ export const baseBeforeDuplicateArrays = ({ value })=>{
6
+ if (value) {
7
+ value = value.map((item)=>{
8
+ item.id = new ObjectId().toHexString();
9
+ return item;
10
+ });
11
+ return value;
12
+ }
13
+ };
14
+
15
+ //# sourceMappingURL=baseBeforeDuplicateArrays.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/fields/baseFields/baseBeforeDuplicateArrays.ts"],"sourcesContent":["import ObjectIdImport from 'bson-objectid'\n\nimport type { FieldHook } from '../config/types.js'\n\nconst ObjectId = (ObjectIdImport.default ||\n ObjectIdImport) as unknown as typeof ObjectIdImport.default\n/**\n * Arrays and Blocks need to clear ids beforeDuplicate\n */\nexport const baseBeforeDuplicateArrays: FieldHook = ({ value }) => {\n if (value) {\n value = value.map((item) => {\n item.id = new ObjectId().toHexString()\n return item\n })\n return value\n }\n}\n"],"names":["ObjectIdImport","ObjectId","default","baseBeforeDuplicateArrays","value","map","item","id","toHexString"],"mappings":"AAAA,OAAOA,oBAAoB,gBAAe;AAI1C,MAAMC,WAAYD,eAAeE,OAAO,IACtCF;AACF;;CAEC,GACD,OAAO,MAAMG,4BAAuC,CAAC,EAAEC,KAAK,EAAE;IAC5D,IAAIA,OAAO;QACTA,QAAQA,MAAMC,GAAG,CAAC,CAACC;YACjBA,KAAKC,EAAE,GAAG,IAAIN,WAAWO,WAAW;YACpC,OAAOF;QACT;QACA,OAAOF;IACT;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../../src/fields/config/sanitize.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAA;AACzE,OAAO,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAgBvC,KAAK,IAAI,GAAG;IACV,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;IACnC,MAAM,EAAE,MAAM,CAAA;IACd,kBAAkB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAChC,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,iBAAiB,EAAE,OAAO,CAAA;IAC1B;;;;OAIG;IACH,+BAA+B,CAAC,EAAE,OAAO,CAAA;IAEzC;;;OAGG;IACH,4BAA4B,CAAC,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC,CAAA;IAChF;;;OAGG;IACH,kBAAkB,EAAE,IAAI,GAAG,MAAM,EAAE,CAAA;CACpC,CAAA;AAED,eAAO,MAAM,cAAc,oKASxB,IAAI,KAAG,OAAO,CAAC,KAAK,EAAE,CA0NxB,CAAA"}
1
+ {"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../../src/fields/config/sanitize.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAA;AACzE,OAAO,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAiBvC,KAAK,IAAI,GAAG;IACV,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;IACnC,MAAM,EAAE,MAAM,CAAA;IACd,kBAAkB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAChC,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,iBAAiB,EAAE,OAAO,CAAA;IAC1B;;;;OAIG;IACH,+BAA+B,CAAC,EAAE,OAAO,CAAA;IAEzC;;;OAGG;IACH,4BAA4B,CAAC,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC,CAAA;IAChF;;;OAGG;IACH,kBAAkB,EAAE,IAAI,GAAG,MAAM,EAAE,CAAA;CACpC,CAAA;AAED,eAAO,MAAM,cAAc,oKASxB,IAAI,KAAG,OAAO,CAAC,KAAK,EAAE,CA4OxB,CAAA"}
@@ -2,6 +2,7 @@ import { deepMergeSimple } from '@payloadcms/translations/utilities';
2
2
  import { DuplicateFieldName, InvalidFieldName, InvalidFieldRelationship, MissingFieldType } from '../../errors/index.js';
3
3
  import { MissingEditorProp } from '../../errors/MissingEditorProp.js';
4
4
  import { formatLabels, toWords } from '../../utilities/formatLabels.js';
5
+ import { baseBeforeDuplicateArrays } from '../baseFields/baseBeforeDuplicateArrays.js';
5
6
  import { baseBlockFields } from '../baseFields/baseBlockFields.js';
6
7
  import { baseIDField } from '../baseFields/baseIDField.js';
7
8
  import { setDefaultBeforeDuplicate } from '../setDefaultBeforeDuplicate.js';
@@ -60,6 +61,15 @@ export const sanitizeFields = async ({ collectionConfig, config, existingFieldNa
60
61
  }
61
62
  if (field.type === 'array' && field.fields) {
62
63
  field.fields.push(baseIDField);
64
+ if (field.localized) {
65
+ if (!field.hooks) {
66
+ field.hooks = {};
67
+ }
68
+ if (!field.hooks.beforeDuplicate) {
69
+ field.hooks.beforeDuplicate = [];
70
+ }
71
+ field.hooks.beforeDuplicate.push(baseBeforeDuplicateArrays);
72
+ }
63
73
  }
64
74
  if ((field.type === 'blocks' || field.type === 'array') && field.label) {
65
75
  field.labels = field.labels || formatLabels(field.name);
@@ -134,6 +144,15 @@ export const sanitizeFields = async ({ collectionConfig, config, existingFieldNa
134
144
  }
135
145
  }
136
146
  if (field.type === 'blocks' && field.blocks) {
147
+ if (field.localized) {
148
+ if (!field.hooks) {
149
+ field.hooks = {};
150
+ }
151
+ if (!field.hooks.beforeDuplicate) {
152
+ field.hooks.beforeDuplicate = [];
153
+ }
154
+ field.hooks.beforeDuplicate.push(baseBeforeDuplicateArrays);
155
+ }
137
156
  for (const block of field.blocks){
138
157
  if (block._sanitized === true) {
139
158
  continue;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/fields/config/sanitize.ts"],"sourcesContent":["import { deepMergeSimple } from '@payloadcms/translations/utilities'\n\nimport type { CollectionConfig } from '../../collections/config/types.js'\nimport type { Config, SanitizedConfig } from '../../config/types.js'\nimport type { Field } from './types.js'\n\nimport {\n DuplicateFieldName,\n InvalidFieldName,\n InvalidFieldRelationship,\n MissingFieldType,\n} from '../../errors/index.js'\nimport { MissingEditorProp } from '../../errors/MissingEditorProp.js'\nimport { formatLabels, toWords } from '../../utilities/formatLabels.js'\nimport { baseBlockFields } from '../baseFields/baseBlockFields.js'\nimport { baseIDField } from '../baseFields/baseIDField.js'\nimport { setDefaultBeforeDuplicate } from '../setDefaultBeforeDuplicate.js'\nimport validations from '../validations.js'\nimport { fieldAffectsData, tabHasName } from './types.js'\n\ntype Args = {\n collectionConfig?: CollectionConfig\n config: Config\n existingFieldNames?: Set<string>\n fields: Field[]\n parentIsLocalized: boolean\n /**\n * If true, a richText field will require an editor property to be set, as the sanitizeFields function will not add it from the payload config if not present.\n *\n * @default false\n */\n requireFieldLevelRichTextEditor?: boolean\n\n /**\n * If this property is set, RichText fields won't be sanitized immediately. Instead, they will be added to this array as promises\n * so that you can sanitize them together, after the config has been sanitized.\n */\n richTextSanitizationPromises?: Array<(config: SanitizedConfig) => Promise<void>>\n /**\n * If not null, will validate that upload and relationship fields do not relate to a collection that is not in this array.\n * This validation will be skipped if validRelationships is null.\n */\n validRelationships: null | string[]\n}\n\nexport const sanitizeFields = async ({\n collectionConfig,\n config,\n existingFieldNames = new Set(),\n fields,\n parentIsLocalized,\n requireFieldLevelRichTextEditor = false,\n richTextSanitizationPromises,\n validRelationships,\n}: Args): Promise<Field[]> => {\n if (!fields) {\n return []\n }\n\n for (let i = 0; i < fields.length; i++) {\n const field = fields[i]\n\n if ('_sanitized' in field && field._sanitized === true) {\n continue\n }\n\n if (!field.type) {\n throw new MissingFieldType(field)\n }\n\n // assert that field names do not contain forbidden characters\n if (fieldAffectsData(field) && field.name.includes('.')) {\n throw new InvalidFieldName(field, field.name)\n }\n\n // Auto-label\n if (\n 'name' in field &&\n field.name &&\n typeof field.label !== 'object' &&\n typeof field.label !== 'string' &&\n typeof field.label !== 'function' &&\n field.label !== false\n ) {\n field.label = toWords(field.name)\n }\n\n if (\n field.type === 'checkbox' &&\n typeof field.defaultValue === 'undefined' &&\n field.required === true\n ) {\n field.defaultValue = false\n }\n\n if (field.type === 'relationship' || field.type === 'upload') {\n if (validRelationships) {\n const relationships = Array.isArray(field.relationTo)\n ? field.relationTo\n : [field.relationTo]\n relationships.forEach((relationship: string) => {\n if (!validRelationships.includes(relationship)) {\n throw new InvalidFieldRelationship(field, relationship)\n }\n })\n }\n\n if (field.min && !field.minRows) {\n console.warn(\n `(payload): The \"min\" property is deprecated for the Relationship field \"${field.name}\" and will be removed in a future version. Please use \"minRows\" instead.`,\n )\n }\n if (field.max && !field.maxRows) {\n console.warn(\n `(payload): The \"max\" property is deprecated for the Relationship field \"${field.name}\" and will be removed in a future version. Please use \"maxRows\" instead.`,\n )\n }\n field.minRows = field.minRows || field.min\n field.maxRows = field.maxRows || field.max\n }\n\n if (field.type === 'upload') {\n if (!field.admin || !('isSortable' in field.admin)) {\n field.admin = {\n isSortable: true,\n ...field.admin,\n }\n }\n }\n\n if (field.type === 'array' && field.fields) {\n field.fields.push(baseIDField)\n }\n\n if ((field.type === 'blocks' || field.type === 'array') && field.label) {\n field.labels = field.labels || formatLabels(field.name)\n }\n\n if (fieldAffectsData(field)) {\n if (existingFieldNames.has(field.name)) {\n throw new DuplicateFieldName(field.name)\n } else if (!['blockName', 'id'].includes(field.name)) {\n existingFieldNames.add(field.name)\n }\n\n if (typeof field.localized !== 'undefined') {\n let shouldDisableLocalized = !config.localization\n\n if (!config.compatibility?.allowLocalizedWithinLocalized && parentIsLocalized) {\n shouldDisableLocalized = true\n }\n\n if (shouldDisableLocalized) {\n delete field.localized\n }\n }\n\n if (typeof field.validate === 'undefined') {\n const defaultValidate = validations[field.type]\n if (defaultValidate) {\n field.validate = (val, options) => defaultValidate(val, { ...field, ...options })\n } else {\n field.validate = () => true\n }\n }\n\n if (!field.hooks) {\n field.hooks = {}\n }\n if (!field.access) {\n field.access = {}\n }\n\n setDefaultBeforeDuplicate(field)\n }\n\n if (!field.admin) {\n field.admin = {}\n }\n\n // Make sure that the richText field has an editor\n if (field.type === 'richText') {\n const sanitizeRichText = async (_config: SanitizedConfig) => {\n if (!field.editor) {\n if (_config.editor && !requireFieldLevelRichTextEditor) {\n // config.editor should be sanitized at this point\n field.editor = _config.editor\n } else {\n throw new MissingEditorProp(field) // while we allow disabling editor functionality, you should not have any richText fields defined if you do not have an editor\n }\n }\n\n if (typeof field.editor === 'function') {\n field.editor = await field.editor({\n config: _config,\n isRoot: requireFieldLevelRichTextEditor,\n parentIsLocalized: parentIsLocalized || field.localized,\n })\n }\n\n if (field.editor.i18n && Object.keys(field.editor.i18n).length >= 0) {\n config.i18n.translations = deepMergeSimple(config.i18n.translations, field.editor.i18n)\n }\n }\n if (richTextSanitizationPromises) {\n richTextSanitizationPromises.push(sanitizeRichText)\n } else {\n await sanitizeRichText(config as unknown as SanitizedConfig)\n }\n }\n\n if (field.type === 'blocks' && field.blocks) {\n for (const block of field.blocks) {\n if (block._sanitized === true) {\n continue\n }\n block._sanitized = true\n block.fields = block.fields.concat(baseBlockFields)\n block.labels = !block.labels ? formatLabels(block.slug) : block.labels\n\n block.fields = await sanitizeFields({\n config,\n existingFieldNames: new Set(),\n fields: block.fields,\n parentIsLocalized: parentIsLocalized || field.localized,\n requireFieldLevelRichTextEditor,\n richTextSanitizationPromises,\n validRelationships,\n })\n }\n }\n\n if ('fields' in field && field.fields) {\n field.fields = await sanitizeFields({\n config,\n existingFieldNames: fieldAffectsData(field) ? new Set() : existingFieldNames,\n fields: field.fields,\n parentIsLocalized: parentIsLocalized || field.localized,\n requireFieldLevelRichTextEditor,\n richTextSanitizationPromises,\n validRelationships,\n })\n }\n\n if (field.type === 'tabs') {\n for (let j = 0; j < field.tabs.length; j++) {\n const tab = field.tabs[j]\n if (tabHasName(tab) && typeof tab.label === 'undefined') {\n tab.label = toWords(tab.name)\n }\n\n tab.fields = await sanitizeFields({\n config,\n existingFieldNames: tabHasName(tab) ? new Set() : existingFieldNames,\n fields: tab.fields,\n parentIsLocalized: parentIsLocalized || (tabHasName(tab) && tab.localized),\n requireFieldLevelRichTextEditor,\n richTextSanitizationPromises,\n validRelationships,\n })\n field.tabs[j] = tab\n }\n }\n\n if ('_sanitized' in field) {\n field._sanitized = true\n }\n\n fields[i] = field\n }\n\n return fields\n}\n"],"names":["deepMergeSimple","DuplicateFieldName","InvalidFieldName","InvalidFieldRelationship","MissingFieldType","MissingEditorProp","formatLabels","toWords","baseBlockFields","baseIDField","setDefaultBeforeDuplicate","validations","fieldAffectsData","tabHasName","sanitizeFields","collectionConfig","config","existingFieldNames","Set","fields","parentIsLocalized","requireFieldLevelRichTextEditor","richTextSanitizationPromises","validRelationships","i","length","field","_sanitized","type","name","includes","label","defaultValue","required","relationships","Array","isArray","relationTo","forEach","relationship","min","minRows","console","warn","max","maxRows","admin","isSortable","push","labels","has","add","localized","shouldDisableLocalized","localization","compatibility","allowLocalizedWithinLocalized","validate","defaultValidate","val","options","hooks","access","sanitizeRichText","_config","editor","isRoot","i18n","Object","keys","translations","blocks","block","concat","slug","j","tabs","tab"],"mappings":"AAAA,SAASA,eAAe,QAAQ,qCAAoC;AAMpE,SACEC,kBAAkB,EAClBC,gBAAgB,EAChBC,wBAAwB,EACxBC,gBAAgB,QACX,wBAAuB;AAC9B,SAASC,iBAAiB,QAAQ,oCAAmC;AACrE,SAASC,YAAY,EAAEC,OAAO,QAAQ,kCAAiC;AACvE,SAASC,eAAe,QAAQ,mCAAkC;AAClE,SAASC,WAAW,QAAQ,+BAA8B;AAC1D,SAASC,yBAAyB,QAAQ,kCAAiC;AAC3E,OAAOC,iBAAiB,oBAAmB;AAC3C,SAASC,gBAAgB,EAAEC,UAAU,QAAQ,aAAY;AA2BzD,OAAO,MAAMC,iBAAiB,OAAO,EACnCC,gBAAgB,EAChBC,MAAM,EACNC,qBAAqB,IAAIC,KAAK,EAC9BC,MAAM,EACNC,iBAAiB,EACjBC,kCAAkC,KAAK,EACvCC,4BAA4B,EAC5BC,kBAAkB,EACb;IACL,IAAI,CAACJ,QAAQ;QACX,OAAO,EAAE;IACX;IAEA,IAAK,IAAIK,IAAI,GAAGA,IAAIL,OAAOM,MAAM,EAAED,IAAK;QACtC,MAAME,QAAQP,MAAM,CAACK,EAAE;QAEvB,IAAI,gBAAgBE,SAASA,MAAMC,UAAU,KAAK,MAAM;YACtD;QACF;QAEA,IAAI,CAACD,MAAME,IAAI,EAAE;YACf,MAAM,IAAIxB,iBAAiBsB;QAC7B;QAEA,8DAA8D;QAC9D,IAAId,iBAAiBc,UAAUA,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BAAmBA,qBAAsBP,WAAWgE,QAAQA,IAAIzB,SAAS;oBACzE/B;oBACAC;oBACAC;gBACF;gBACAG,MAAMkD,IAAI,CAACD,EAAE,GAAGE;YAClB;QACF;QAEA,IAAI,gBAAgBnD,OAAO;YACzBA,MAAMC,UAAU,GAAG;QACrB;QAEAR,MAAM,CAACK,EAAE,GAAGE;IACd;IAEA,OAAOP;AACT,EAAC"}
1
+ {"version":3,"sources":["../../../src/fields/config/sanitize.ts"],"sourcesContent":["import { deepMergeSimple } from '@payloadcms/translations/utilities'\n\nimport type { CollectionConfig } from '../../collections/config/types.js'\nimport type { Config, SanitizedConfig } from '../../config/types.js'\nimport type { Field } from './types.js'\n\nimport {\n DuplicateFieldName,\n InvalidFieldName,\n InvalidFieldRelationship,\n MissingFieldType,\n} from '../../errors/index.js'\nimport { MissingEditorProp } from '../../errors/MissingEditorProp.js'\nimport { formatLabels, toWords } from '../../utilities/formatLabels.js'\nimport { baseBeforeDuplicateArrays } from '../baseFields/baseBeforeDuplicateArrays.js'\nimport { baseBlockFields } from '../baseFields/baseBlockFields.js'\nimport { baseIDField } from '../baseFields/baseIDField.js'\nimport { setDefaultBeforeDuplicate } from '../setDefaultBeforeDuplicate.js'\nimport validations from '../validations.js'\nimport { fieldAffectsData, tabHasName } from './types.js'\n\ntype Args = {\n collectionConfig?: CollectionConfig\n config: Config\n existingFieldNames?: Set<string>\n fields: Field[]\n parentIsLocalized: boolean\n /**\n * If true, a richText field will require an editor property to be set, as the sanitizeFields function will not add it from the payload config if not present.\n *\n * @default false\n */\n requireFieldLevelRichTextEditor?: boolean\n\n /**\n * If this property is set, RichText fields won't be sanitized immediately. Instead, they will be added to this array as promises\n * so that you can sanitize them together, after the config has been sanitized.\n */\n richTextSanitizationPromises?: Array<(config: SanitizedConfig) => Promise<void>>\n /**\n * If not null, will validate that upload and relationship fields do not relate to a collection that is not in this array.\n * This validation will be skipped if validRelationships is null.\n */\n validRelationships: null | string[]\n}\n\nexport const sanitizeFields = async ({\n collectionConfig,\n config,\n existingFieldNames = new Set(),\n fields,\n parentIsLocalized,\n requireFieldLevelRichTextEditor = false,\n richTextSanitizationPromises,\n validRelationships,\n}: Args): Promise<Field[]> => {\n if (!fields) {\n return []\n }\n\n for (let i = 0; i < fields.length; i++) {\n const field = fields[i]\n\n if ('_sanitized' in field && field._sanitized === true) {\n continue\n }\n\n if (!field.type) {\n throw new MissingFieldType(field)\n }\n\n // assert that field names do not contain forbidden characters\n if (fieldAffectsData(field) && field.name.includes('.')) {\n throw new InvalidFieldName(field, field.name)\n }\n\n // Auto-label\n if (\n 'name' in field &&\n field.name &&\n typeof field.label !== 'object' &&\n typeof field.label !== 'string' &&\n typeof field.label !== 'function' &&\n field.label !== false\n ) {\n field.label = toWords(field.name)\n }\n\n if (\n field.type === 'checkbox' &&\n typeof field.defaultValue === 'undefined' &&\n field.required === true\n ) {\n field.defaultValue = false\n }\n\n if (field.type === 'relationship' || field.type === 'upload') {\n if (validRelationships) {\n const relationships = Array.isArray(field.relationTo)\n ? field.relationTo\n : [field.relationTo]\n relationships.forEach((relationship: string) => {\n if (!validRelationships.includes(relationship)) {\n throw new InvalidFieldRelationship(field, relationship)\n }\n })\n }\n\n if (field.min && !field.minRows) {\n console.warn(\n `(payload): The \"min\" property is deprecated for the Relationship field \"${field.name}\" and will be removed in a future version. Please use \"minRows\" instead.`,\n )\n }\n if (field.max && !field.maxRows) {\n console.warn(\n `(payload): The \"max\" property is deprecated for the Relationship field \"${field.name}\" and will be removed in a future version. Please use \"maxRows\" instead.`,\n )\n }\n field.minRows = field.minRows || field.min\n field.maxRows = field.maxRows || field.max\n }\n\n if (field.type === 'upload') {\n if (!field.admin || !('isSortable' in field.admin)) {\n field.admin = {\n isSortable: true,\n ...field.admin,\n }\n }\n }\n\n if (field.type === 'array' && field.fields) {\n field.fields.push(baseIDField)\n if (field.localized) {\n if (!field.hooks) {\n field.hooks = {}\n }\n if (!field.hooks.beforeDuplicate) {\n field.hooks.beforeDuplicate = []\n }\n field.hooks.beforeDuplicate.push(baseBeforeDuplicateArrays)\n }\n }\n\n if ((field.type === 'blocks' || field.type === 'array') && field.label) {\n field.labels = field.labels || formatLabels(field.name)\n }\n\n if (fieldAffectsData(field)) {\n if (existingFieldNames.has(field.name)) {\n throw new DuplicateFieldName(field.name)\n } else if (!['blockName', 'id'].includes(field.name)) {\n existingFieldNames.add(field.name)\n }\n\n if (typeof field.localized !== 'undefined') {\n let shouldDisableLocalized = !config.localization\n\n if (!config.compatibility?.allowLocalizedWithinLocalized && parentIsLocalized) {\n shouldDisableLocalized = true\n }\n\n if (shouldDisableLocalized) {\n delete field.localized\n }\n }\n\n if (typeof field.validate === 'undefined') {\n const defaultValidate = validations[field.type]\n if (defaultValidate) {\n field.validate = (val, options) => defaultValidate(val, { ...field, ...options })\n } else {\n field.validate = () => true\n }\n }\n\n if (!field.hooks) {\n field.hooks = {}\n }\n if (!field.access) {\n field.access = {}\n }\n\n setDefaultBeforeDuplicate(field)\n }\n\n if (!field.admin) {\n field.admin = {}\n }\n\n // Make sure that the richText field has an editor\n if (field.type === 'richText') {\n const sanitizeRichText = async (_config: SanitizedConfig) => {\n if (!field.editor) {\n if (_config.editor && !requireFieldLevelRichTextEditor) {\n // config.editor should be sanitized at this point\n field.editor = _config.editor\n } else {\n throw new MissingEditorProp(field) // while we allow disabling editor functionality, you should not have any richText fields defined if you do not have an editor\n }\n }\n\n if (typeof field.editor === 'function') {\n field.editor = await field.editor({\n config: _config,\n isRoot: requireFieldLevelRichTextEditor,\n parentIsLocalized: parentIsLocalized || field.localized,\n })\n }\n\n if (field.editor.i18n && Object.keys(field.editor.i18n).length >= 0) {\n config.i18n.translations = deepMergeSimple(config.i18n.translations, field.editor.i18n)\n }\n }\n if (richTextSanitizationPromises) {\n richTextSanitizationPromises.push(sanitizeRichText)\n } else {\n await sanitizeRichText(config as unknown as SanitizedConfig)\n }\n }\n\n if (field.type === 'blocks' && field.blocks) {\n if (field.localized) {\n if (!field.hooks) {\n field.hooks = {}\n }\n if (!field.hooks.beforeDuplicate) {\n field.hooks.beforeDuplicate = []\n }\n field.hooks.beforeDuplicate.push(baseBeforeDuplicateArrays)\n }\n for (const block of field.blocks) {\n if (block._sanitized === true) {\n continue\n }\n block._sanitized = true\n block.fields = block.fields.concat(baseBlockFields)\n block.labels = !block.labels ? formatLabels(block.slug) : block.labels\n\n block.fields = await sanitizeFields({\n config,\n existingFieldNames: new Set(),\n fields: block.fields,\n parentIsLocalized: parentIsLocalized || field.localized,\n requireFieldLevelRichTextEditor,\n richTextSanitizationPromises,\n validRelationships,\n })\n }\n }\n\n if ('fields' in field && field.fields) {\n field.fields = await sanitizeFields({\n config,\n existingFieldNames: fieldAffectsData(field) ? new Set() : existingFieldNames,\n fields: field.fields,\n parentIsLocalized: parentIsLocalized || field.localized,\n requireFieldLevelRichTextEditor,\n richTextSanitizationPromises,\n validRelationships,\n })\n }\n\n if (field.type === 'tabs') {\n for (let j = 0; j < field.tabs.length; j++) {\n const tab = field.tabs[j]\n if (tabHasName(tab) && typeof tab.label === 'undefined') {\n tab.label = toWords(tab.name)\n }\n\n tab.fields = await sanitizeFields({\n config,\n existingFieldNames: tabHasName(tab) ? new Set() : existingFieldNames,\n fields: tab.fields,\n parentIsLocalized: parentIsLocalized || (tabHasName(tab) && tab.localized),\n requireFieldLevelRichTextEditor,\n richTextSanitizationPromises,\n validRelationships,\n })\n field.tabs[j] = tab\n }\n }\n\n if ('_sanitized' in field) {\n field._sanitized = true\n }\n\n fields[i] = field\n }\n\n return fields\n}\n"],"names":["deepMergeSimple","DuplicateFieldName","InvalidFieldName","InvalidFieldRelationship","MissingFieldType","MissingEditorProp","formatLabels","toWords","baseBeforeDuplicateArrays","baseBlockFields","baseIDField","setDefaultBeforeDuplicate","validations","fieldAffectsData","tabHasName","sanitizeFields","collectionConfig","config","existingFieldNames","Set","fields","parentIsLocalized","requireFieldLevelRichTextEditor","richTextSanitizationPromises","validRelationships","i","length","field","_sanitized","type","name","includes","label","defaultValue","required","relationships","Array","isArray","relationTo","forEach","relationship","min","minRows","console","warn","max","maxRows","admin","isSortable","push","localized","hooks","beforeDuplicate","labels","has","add","shouldDisableLocalized","localization","compatibility","allowLocalizedWithinLocalized","validate","defaultValidate","val","options","access","sanitizeRichText","_config","editor","isRoot","i18n","Object","keys","translations","blocks","block","concat","slug","j","tabs","tab"],"mappings":"AAAA,SAASA,eAAe,QAAQ,qCAAoC;AAMpE,SACEC,kBAAkB,EAClBC,gBAAgB,EAChBC,wBAAwB,EACxBC,gBAAgB,QACX,wBAAuB;AAC9B,SAASC,iBAAiB,QAAQ,oCAAmC;AACrE,SAASC,YAAY,EAAEC,OAAO,QAAQ,kCAAiC;AACvE,SAASC,yBAAyB,QAAQ,6CAA4C;AACtF,SAASC,eAAe,QAAQ,mCAAkC;AAClE,SAASC,WAAW,QAAQ,+BAA8B;AAC1D,SAASC,yBAAyB,QAAQ,kCAAiC;AAC3E,OAAOC,iBAAiB,oBAAmB;AAC3C,SAASC,gBAAgB,EAAEC,UAAU,QAAQ,aAAY;AA2BzD,OAAO,MAAMC,iBAAiB,OAAO,EACnCC,gBAAgB,EAChBC,MAAM,EACNC,qBAAqB,IAAIC,KAAK,EAC9BC,MAAM,EACNC,iBAAiB,EACjBC,kCAAkC,KAAK,EACvCC,4BAA4B,EAC5BC,kBAAkB,EACb;IACL,IAAI,CAACJ,QAAQ;QACX,OAAO,EAAE;IACX;IAEA,IAAK,IAAIK,IAAI,GAAGA,IAAIL,OAAOM,MAAM,EAAED,IAAK;QACtC,MAAME,QAAQP,MAAM,CAACK,EAAE;QAEvB,IAAI,gBAAgBE,SAASA,MAAMC,UAAU,KAAK,MAAM;YACtD;QACF;QAEA,IAAI,CAACD,MAAME,IAAI,EAAE;YACf,MAAM,IAAIzB,iBAAiBuB;QAC7B;QAEA,8DAA8D;QAC9D,IAAId,iBAAiBc,UAAUA,MAAMG,IAAI,CAACC,QAAQ,CAAC,MAAM;YACvD,MAAM,IAAI7B,iBAAiByB,OAAOA,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BAAqBM,MAAMuB,SAAS;gBACvD5B;gBACAC;gBACAC;YACF;QACF;QAEA,IAAIG,MAAME,IAAI,KAAK,QAAQ;YACzB,IAAK,IAAIgD,IAAI,GAAGA,IAAIlD,MAAMmD,IAAI,CAACpD,MAAM,EAAEmD,IAAK;gBAC1C,MAAME,MAAMpD,MAAMmD,IAAI,CAACD,EAAE;gBACzB,IAAI/D,WAAWiE,QAAQ,OAAOA,IAAI/C,KAAK,KAAK,aAAa;oBACvD+C,IAAI/C,KAAK,GAAGzB,QAAQwE,IAAIjD,IAAI;gBAC9B;gBAEAiD,IAAI3D,MAAM,GAAG,MAAML,eAAe;oBAChCE;oBACAC,oBAAoBJ,WAAWiE,OAAO,IAAI5D,QAAQD;oBAClDE,QAAQ2D,IAAI3D,MAAM;oBAClBC,mBAAmBA,qBAAsBP,WAAWiE,QAAQA,IAAI7B,SAAS;oBACzE5B;oBACAC;oBACAC;gBACF;gBACAG,MAAMmD,IAAI,CAACD,EAAE,GAAGE;YAClB;QACF;QAEA,IAAI,gBAAgBpD,OAAO;YACzBA,MAAMC,UAAU,GAAG;QACrB;QAEAR,MAAM,CAACK,EAAE,GAAGE;IACd;IAEA,OAAOP;AACT,EAAC"}
@@ -3,7 +3,7 @@ import type { JSONSchema4 } from 'json-schema';
3
3
  import type { CSSProperties } from 'react';
4
4
  import type { DeepUndefinable } from 'ts-essentials';
5
5
  import type { RichTextAdapter, RichTextAdapterProvider } from '../../admin/RichText.js';
6
- import type { ArrayFieldErrorClientComponent, ArrayFieldErrorServerComponent, ArrayFieldLabelClientComponent, ArrayFieldLabelServerComponent, ArrayFieldProps, BlockFieldErrorClientComponent, BlockFieldErrorServerComponent, BlockFieldProps, CheckboxFieldErrorClientComponent, CheckboxFieldErrorServerComponent, CheckboxFieldLabelClientComponent, CheckboxFieldLabelServerComponent, CheckboxFieldProps, ClientTab, CodeFieldErrorClientComponent, CodeFieldErrorServerComponent, CodeFieldLabelClientComponent, CodeFieldLabelServerComponent, CodeFieldProps, CollapsibleFieldLabelClientComponent, CollapsibleFieldLabelServerComponent, CollapsibleFieldProps, ConditionalDateProps, DateFieldErrorClientComponent, DateFieldErrorServerComponent, DateFieldLabelClientComponent, DateFieldLabelServerComponent, DateFieldProps, Description, EmailFieldErrorClientComponent, EmailFieldErrorServerComponent, EmailFieldLabelClientComponent, EmailFieldLabelServerComponent, EmailFieldProps, FieldDescriptionClientComponent, FieldDescriptionServerComponent, GroupFieldLabelClientComponent, GroupFieldLabelServerComponent, GroupFieldProps, HiddenFieldProps, JSONFieldErrorClientComponent, JSONFieldErrorServerComponent, JSONFieldLabelClientComponent, JSONFieldLabelServerComponent, JSONFieldProps, MappedComponent, NumberFieldErrorClientComponent, NumberFieldErrorServerComponent, NumberFieldLabelClientComponent, NumberFieldLabelServerComponent, NumberFieldProps, PointFieldErrorClientComponent, PointFieldErrorServerComponent, PointFieldLabelClientComponent, PointFieldLabelServerComponent, PointFieldProps, RadioFieldErrorClientComponent, RadioFieldErrorServerComponent, RadioFieldLabelClientComponent, RadioFieldLabelServerComponent, RadioFieldProps, RelationshipFieldErrorClientComponent, RelationshipFieldErrorServerComponent, RelationshipFieldLabelClientComponent, RelationshipFieldLabelServerComponent, RelationshipFieldProps, RichTextFieldProps, RowFieldProps, RowLabelComponent, SelectFieldErrorClientComponent, SelectFieldErrorServerComponent, SelectFieldLabelClientComponent, SelectFieldLabelServerComponent, SelectFieldProps, StaticDescription, TabsFieldProps, TextareaFieldErrorClientComponent, TextareaFieldErrorServerComponent, TextareaFieldLabelClientComponent, TextareaFieldLabelServerComponent, TextareaFieldProps, TextFieldErrorClientComponent, TextFieldErrorServerComponent, TextFieldLabelClientComponent, TextFieldLabelServerComponent, UploadFieldProps } from '../../admin/types.js';
6
+ import type { ArrayFieldClientProps, ArrayFieldErrorClientComponent, ArrayFieldErrorServerComponent, ArrayFieldLabelClientComponent, ArrayFieldLabelServerComponent, BlockFieldErrorClientComponent, BlockFieldErrorServerComponent, BlocksFieldClientProps, CheckboxFieldClientProps, CheckboxFieldErrorClientComponent, CheckboxFieldErrorServerComponent, CheckboxFieldLabelClientComponent, CheckboxFieldLabelServerComponent, ClientTab, CodeFieldClientProps, CodeFieldErrorClientComponent, CodeFieldErrorServerComponent, CodeFieldLabelClientComponent, CodeFieldLabelServerComponent, CollapsibleFieldClientProps, CollapsibleFieldLabelClientComponent, CollapsibleFieldLabelServerComponent, ConditionalDateProps, DateFieldClientProps, DateFieldErrorClientComponent, DateFieldErrorServerComponent, DateFieldLabelClientComponent, DateFieldLabelServerComponent, Description, EmailFieldClientProps, EmailFieldErrorClientComponent, EmailFieldErrorServerComponent, EmailFieldLabelClientComponent, EmailFieldLabelServerComponent, FieldDescriptionClientComponent, FieldDescriptionServerComponent, GroupFieldClientProps, GroupFieldLabelClientComponent, GroupFieldLabelServerComponent, HiddenFieldProps, JSONFieldClientProps, JSONFieldErrorClientComponent, JSONFieldErrorServerComponent, JSONFieldLabelClientComponent, JSONFieldLabelServerComponent, MappedComponent, NumberFieldClientProps, NumberFieldErrorClientComponent, NumberFieldErrorServerComponent, NumberFieldLabelClientComponent, NumberFieldLabelServerComponent, PointFieldClientProps, PointFieldErrorClientComponent, PointFieldErrorServerComponent, PointFieldLabelClientComponent, PointFieldLabelServerComponent, RadioFieldClientProps, RadioFieldErrorClientComponent, RadioFieldErrorServerComponent, RadioFieldLabelClientComponent, RadioFieldLabelServerComponent, RelationshipFieldClientProps, RelationshipFieldErrorClientComponent, RelationshipFieldErrorServerComponent, RelationshipFieldLabelClientComponent, RelationshipFieldLabelServerComponent, RichTextFieldClientProps, RowFieldClientProps, RowLabelComponent, SelectFieldClientProps, SelectFieldErrorClientComponent, SelectFieldErrorServerComponent, SelectFieldLabelClientComponent, SelectFieldLabelServerComponent, StaticDescription, TabsFieldClientProps, TextareaFieldClientProps, TextareaFieldErrorClientComponent, TextareaFieldErrorServerComponent, TextareaFieldLabelClientComponent, TextareaFieldLabelServerComponent, TextFieldErrorClientComponent, TextFieldErrorServerComponent, TextFieldLabelClientComponent, TextFieldLabelServerComponent, UploadFieldClientProps } from '../../admin/types.js';
7
7
  import type { SanitizedCollectionConfig, TypeWithID } from '../../collections/config/types.js';
8
8
  import type { CustomComponent, LabelFunction, PayloadComponent, StaticLabel } from '../../config/types.js';
9
9
  import type { DBIdentifierName } from '../../database/types.js';
@@ -1072,7 +1072,7 @@ export type PointFieldClient = {
1072
1072
  } & FieldBaseClient & Pick<PointField, 'type'>;
1073
1073
  export type Field = ArrayField | BlockField | CheckboxField | CodeField | CollapsibleField | DateField | EmailField | GroupField | JSONField | NumberField | PointField | RadioField | RelationshipField | RichTextField | RowField | SelectField | TabsField | TextareaField | TextField | UIField | UploadField;
1074
1074
  export type ClientField = ArrayFieldClient | BlockFieldClient | CheckboxFieldClient | CodeFieldClient | CollapsibleFieldClient | DateFieldClient | EmailFieldClient | GroupFieldClient | JSONFieldClient | NumberFieldClient | PointFieldClient | RadioFieldClient | RelationshipFieldClient | RichTextFieldClient | RowFieldClient | SelectFieldClient | TabsFieldClient | TextareaFieldClient | TextFieldClient | UIFieldClient | UploadFieldClient;
1075
- export type ClientFieldProps = ArrayFieldProps | BlockFieldProps | CheckboxFieldProps | CodeFieldProps | CollapsibleFieldProps | DateFieldProps | EmailFieldProps | GroupFieldProps | HiddenFieldProps | JSONFieldProps | NumberFieldProps | PointFieldProps | RadioFieldProps | RelationshipFieldProps | RichTextFieldProps | RowFieldProps | SelectFieldProps | TabsFieldProps | TextareaFieldProps | UploadFieldProps;
1075
+ export type ClientFieldProps = ArrayFieldClientProps | BlocksFieldClientProps | CheckboxFieldClientProps | CodeFieldClientProps | CollapsibleFieldClientProps | DateFieldClientProps | EmailFieldClientProps | GroupFieldClientProps | HiddenFieldProps | JSONFieldClientProps | NumberFieldClientProps | PointFieldClientProps | RadioFieldClientProps | RelationshipFieldClientProps | RichTextFieldClientProps | RowFieldClientProps | SelectFieldClientProps | TabsFieldClientProps | TextareaFieldClientProps | UploadFieldClientProps;
1076
1076
  type ExtractFieldTypes<T> = T extends {
1077
1077
  type: infer U;
1078
1078
  } ? U : never;