@payloadcms/figma 0.0.1-alpha.38-2 → 0.0.1-alpha.4

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 (264) hide show
  1. package/dist/api/control-plane.d.ts +1 -22
  2. package/dist/api/control-plane.d.ts.map +1 -1
  3. package/dist/api/control-plane.js +22 -55
  4. package/dist/api/control-plane.js.map +1 -1
  5. package/dist/api/figma-api.d.ts.map +1 -1
  6. package/dist/api/figma-api.js +26 -45
  7. package/dist/api/figma-api.js.map +1 -1
  8. package/dist/auth/callback-server.d.ts.map +1 -1
  9. package/dist/auth/callback-server.js +1 -2
  10. package/dist/auth/callback-server.js.map +1 -1
  11. package/dist/auth/crypto-utils.d.ts.map +1 -1
  12. package/dist/auth/crypto-utils.js +5 -5
  13. package/dist/auth/crypto-utils.js.map +1 -1
  14. package/dist/auth/jwt-validator.d.ts +1 -2
  15. package/dist/auth/jwt-validator.d.ts.map +1 -1
  16. package/dist/auth/jwt-validator.js +2 -2
  17. package/dist/auth/jwt-validator.js.map +1 -1
  18. package/dist/auth/oauth-flow.d.ts +1 -1
  19. package/dist/auth/oauth-flow.d.ts.map +1 -1
  20. package/dist/auth/oauth-flow.js +8 -9
  21. package/dist/auth/oauth-flow.js.map +1 -1
  22. package/dist/auth/project-token.d.ts.map +1 -1
  23. package/dist/auth/project-token.js +4 -9
  24. package/dist/auth/project-token.js.map +1 -1
  25. package/dist/auth/refresh.d.ts.map +1 -1
  26. package/dist/auth/refresh.js +9 -14
  27. package/dist/auth/refresh.js.map +1 -1
  28. package/dist/auth/token-store.d.ts +0 -10
  29. package/dist/auth/token-store.d.ts.map +1 -1
  30. package/dist/auth/token-store.js +0 -20
  31. package/dist/auth/token-store.js.map +1 -1
  32. package/dist/cli.d.ts.map +1 -1
  33. package/dist/cli.js +0 -22
  34. package/dist/cli.js.map +1 -1
  35. package/dist/commands/deploy.d.ts +0 -4
  36. package/dist/commands/deploy.d.ts.map +1 -1
  37. package/dist/commands/deploy.js +129 -71
  38. package/dist/commands/deploy.js.map +1 -1
  39. package/dist/commands/init.d.ts +5 -1
  40. package/dist/commands/init.d.ts.map +1 -1
  41. package/dist/commands/init.js +85 -90
  42. package/dist/commands/init.js.map +1 -1
  43. package/dist/commands/list-tokens.d.ts.map +1 -1
  44. package/dist/commands/list-tokens.js +3 -6
  45. package/dist/commands/list-tokens.js.map +1 -1
  46. package/dist/commands/login.d.ts +1 -8
  47. package/dist/commands/login.d.ts.map +1 -1
  48. package/dist/commands/login.js +11 -21
  49. package/dist/commands/login.js.map +1 -1
  50. package/dist/commands/logout.js +2 -2
  51. package/dist/commands/logout.js.map +1 -1
  52. package/dist/config/oauth.d.ts +14 -4
  53. package/dist/config/oauth.d.ts.map +1 -1
  54. package/dist/config/oauth.js +40 -19
  55. package/dist/config/oauth.js.map +1 -1
  56. package/dist/constants.d.ts +18 -26
  57. package/dist/constants.d.ts.map +1 -1
  58. package/dist/constants.js +20 -34
  59. package/dist/constants.js.map +1 -1
  60. package/dist/index.d.ts +1 -2
  61. package/dist/index.d.ts.map +1 -1
  62. package/dist/index.js +1 -3
  63. package/dist/index.js.map +1 -1
  64. package/dist/oauth/components/LoginButton/index.d.ts.map +1 -1
  65. package/dist/oauth/components/LoginButton/index.js +6 -50
  66. package/dist/oauth/components/LoginButton/index.js.map +1 -1
  67. package/dist/oauth/components/LoginButton/index.scss +3 -50
  68. package/dist/oauth/components/LogoutButton/index.d.ts.map +1 -1
  69. package/dist/oauth/components/LogoutButton/index.js +1 -0
  70. package/dist/oauth/components/LogoutButton/index.js.map +1 -1
  71. package/dist/oauth/defaults.d.ts.map +1 -1
  72. package/dist/oauth/defaults.js +5 -29
  73. package/dist/oauth/defaults.js.map +1 -1
  74. package/dist/oauth/endpoints/getLoginEndpoint.d.ts.map +1 -1
  75. package/dist/oauth/endpoints/getLoginEndpoint.js +4 -4
  76. package/dist/oauth/endpoints/getLoginEndpoint.js.map +1 -1
  77. package/dist/oauth/index.d.ts.map +1 -1
  78. package/dist/oauth/index.js +7 -42
  79. package/dist/oauth/index.js.map +1 -1
  80. package/dist/oauth/strategy/index.d.ts +2 -0
  81. package/dist/oauth/strategy/index.d.ts.map +1 -1
  82. package/dist/oauth/strategy/index.js +15 -38
  83. package/dist/oauth/strategy/index.js.map +1 -1
  84. package/dist/oauth/types.d.ts +6 -6
  85. package/dist/oauth/types.d.ts.map +1 -1
  86. package/dist/oauth/types.js.map +1 -1
  87. package/dist/oauth/utilities/createCookieOptions.d.ts.map +1 -1
  88. package/dist/oauth/utilities/createCookieOptions.js.map +1 -1
  89. package/dist/oauth/utilities/refreshTokens.d.ts.map +1 -1
  90. package/dist/oauth/utilities/refreshTokens.js +1 -1
  91. package/dist/oauth/utilities/refreshTokens.js.map +1 -1
  92. package/dist/plugin/build-config.d.ts +4 -21
  93. package/dist/plugin/build-config.d.ts.map +1 -1
  94. package/dist/plugin/build-config.js +8 -114
  95. package/dist/plugin/build-config.js.map +1 -1
  96. package/dist/types.d.ts +0 -1
  97. package/dist/types.d.ts.map +1 -1
  98. package/dist/types.js.map +1 -1
  99. package/dist/utils/asset-collection.d.ts +6 -3
  100. package/dist/utils/asset-collection.d.ts.map +1 -1
  101. package/dist/utils/asset-collection.js +34 -10
  102. package/dist/utils/asset-collection.js.map +1 -1
  103. package/dist/utils/config.js +1 -1
  104. package/dist/utils/config.js.map +1 -1
  105. package/dist/utils/env-management.d.ts +8 -9
  106. package/dist/utils/env-management.d.ts.map +1 -1
  107. package/dist/utils/env-management.js +74 -73
  108. package/dist/utils/env-management.js.map +1 -1
  109. package/dist/utils/formatter.d.ts.map +1 -1
  110. package/dist/utils/formatter.js +5 -3
  111. package/dist/utils/formatter.js.map +1 -1
  112. package/dist/utils/lambda-config.d.ts +1 -3
  113. package/dist/utils/lambda-config.d.ts.map +1 -1
  114. package/dist/utils/lambda-config.js +21 -13
  115. package/dist/utils/lambda-config.js.map +1 -1
  116. package/dist/utils/messages.js +7 -7
  117. package/dist/utils/messages.js.map +1 -1
  118. package/dist/utils/payload-config-ast.d.ts +3 -22
  119. package/dist/utils/payload-config-ast.d.ts.map +1 -1
  120. package/dist/utils/payload-config-ast.js +31 -89
  121. package/dist/utils/payload-config-ast.js.map +1 -1
  122. package/dist/utils/payload-config-finder.d.ts +2 -2
  123. package/dist/utils/payload-config-finder.d.ts.map +1 -1
  124. package/dist/utils/payload-config-finder.js +9 -48
  125. package/dist/utils/payload-config-finder.js.map +1 -1
  126. package/dist/utils/payload-config-modifier.d.ts.map +1 -1
  127. package/dist/utils/payload-config-modifier.js +6 -54
  128. package/dist/utils/payload-config-modifier.js.map +1 -1
  129. package/dist/utils/payload-package-check.d.ts +1 -12
  130. package/dist/utils/payload-package-check.d.ts.map +1 -1
  131. package/dist/utils/payload-package-check.js +5 -63
  132. package/dist/utils/payload-package-check.js.map +1 -1
  133. package/dist/utils/project.d.ts.map +1 -1
  134. package/dist/utils/project.js +5 -8
  135. package/dist/utils/project.js.map +1 -1
  136. package/dist/utils/s3-upload.d.ts +1 -0
  137. package/dist/utils/s3-upload.d.ts.map +1 -1
  138. package/dist/utils/s3-upload.js +3 -10
  139. package/dist/utils/s3-upload.js.map +1 -1
  140. package/dist/utils/token-display.d.ts.map +1 -1
  141. package/dist/utils/token-display.js +5 -11
  142. package/dist/utils/token-display.js.map +1 -1
  143. package/dist/utils/typescript-validator.d.ts.map +1 -1
  144. package/dist/utils/typescript-validator.js +6 -4
  145. package/dist/utils/typescript-validator.js.map +1 -1
  146. package/package.json +7 -31
  147. package/dist/commands/build-lambda-zip.d.ts +0 -5
  148. package/dist/commands/build-lambda-zip.d.ts.map +0 -1
  149. package/dist/commands/build-lambda-zip.js +0 -19
  150. package/dist/commands/build-lambda-zip.js.map +0 -1
  151. package/dist/db-content-api/README.md +0 -98
  152. package/dist/db-content-api/generated/content-api-types.d.ts +0 -3848
  153. package/dist/db-content-api/generated/content-api-types.d.ts.map +0 -1
  154. package/dist/db-content-api/generated/content-api-types.js +0 -7
  155. package/dist/db-content-api/generated/content-api-types.js.map +0 -1
  156. package/dist/db-content-api/index.d.ts +0 -18
  157. package/dist/db-content-api/index.d.ts.map +0 -1
  158. package/dist/db-content-api/index.js +0 -571
  159. package/dist/db-content-api/index.js.map +0 -1
  160. package/dist/db-content-api/temp-utilities/pagination.d.ts +0 -13
  161. package/dist/db-content-api/temp-utilities/pagination.d.ts.map +0 -1
  162. package/dist/db-content-api/temp-utilities/pagination.js +0 -45
  163. package/dist/db-content-api/temp-utilities/pagination.js.map +0 -1
  164. package/dist/db-content-api/temp-utilities/slug.d.ts +0 -2
  165. package/dist/db-content-api/temp-utilities/slug.d.ts.map +0 -1
  166. package/dist/db-content-api/temp-utilities/slug.js +0 -3
  167. package/dist/db-content-api/temp-utilities/slug.js.map +0 -1
  168. package/dist/db-content-api/temp-utilities/sorting.d.ts +0 -3
  169. package/dist/db-content-api/temp-utilities/sorting.d.ts.map +0 -1
  170. package/dist/db-content-api/temp-utilities/sorting.js +0 -32
  171. package/dist/db-content-api/temp-utilities/sorting.js.map +0 -1
  172. package/dist/db-content-api/temp-utilities/unwrapDocument.d.ts +0 -4
  173. package/dist/db-content-api/temp-utilities/unwrapDocument.d.ts.map +0 -1
  174. package/dist/db-content-api/temp-utilities/unwrapDocument.js +0 -53
  175. package/dist/db-content-api/temp-utilities/unwrapDocument.js.map +0 -1
  176. package/dist/db-content-api/utilities/auth.d.ts +0 -30
  177. package/dist/db-content-api/utilities/auth.d.ts.map +0 -1
  178. package/dist/db-content-api/utilities/auth.js +0 -81
  179. package/dist/db-content-api/utilities/auth.js.map +0 -1
  180. package/dist/db-content-api/utilities/data/applyDefaults.d.ts +0 -7
  181. package/dist/db-content-api/utilities/data/applyDefaults.d.ts.map +0 -1
  182. package/dist/db-content-api/utilities/data/applyDefaults.js +0 -59
  183. package/dist/db-content-api/utilities/data/applyDefaults.js.map +0 -1
  184. package/dist/db-content-api/utilities/data/castFieldValue.d.ts +0 -11
  185. package/dist/db-content-api/utilities/data/castFieldValue.d.ts.map +0 -1
  186. package/dist/db-content-api/utilities/data/castFieldValue.js +0 -66
  187. package/dist/db-content-api/utilities/data/castFieldValue.js.map +0 -1
  188. package/dist/db-content-api/utilities/data/index.d.ts +0 -30
  189. package/dist/db-content-api/utilities/data/index.d.ts.map +0 -1
  190. package/dist/db-content-api/utilities/data/index.js +0 -173
  191. package/dist/db-content-api/utilities/data/index.js.map +0 -1
  192. package/dist/db-content-api/utilities/data/removeVirtualFields.d.ts +0 -12
  193. package/dist/db-content-api/utilities/data/removeVirtualFields.d.ts.map +0 -1
  194. package/dist/db-content-api/utilities/data/removeVirtualFields.js +0 -54
  195. package/dist/db-content-api/utilities/data/removeVirtualFields.js.map +0 -1
  196. package/dist/db-content-api/utilities/data/stripFields.d.ts +0 -48
  197. package/dist/db-content-api/utilities/data/stripFields.d.ts.map +0 -1
  198. package/dist/db-content-api/utilities/data/stripFields.js +0 -195
  199. package/dist/db-content-api/utilities/data/stripFields.js.map +0 -1
  200. package/dist/db-content-api/utilities/joins.d.ts +0 -55
  201. package/dist/db-content-api/utilities/joins.d.ts.map +0 -1
  202. package/dist/db-content-api/utilities/joins.js +0 -136
  203. package/dist/db-content-api/utilities/joins.js.map +0 -1
  204. package/dist/db-content-api/utilities/where.d.ts +0 -12
  205. package/dist/db-content-api/utilities/where.d.ts.map +0 -1
  206. package/dist/db-content-api/utilities/where.js +0 -107
  207. package/dist/db-content-api/utilities/where.js.map +0 -1
  208. package/dist/endpoints/health.d.ts +0 -3
  209. package/dist/endpoints/health.d.ts.map +0 -1
  210. package/dist/endpoints/health.js +0 -11
  211. package/dist/endpoints/health.js.map +0 -1
  212. package/dist/exports/client.d.ts +0 -4
  213. package/dist/exports/client.d.ts.map +0 -1
  214. package/dist/exports/client.js +0 -5
  215. package/dist/exports/client.js.map +0 -1
  216. package/dist/oauth/utilities/isDuplicateKeyError.d.ts +0 -7
  217. package/dist/oauth/utilities/isDuplicateKeyError.d.ts.map +0 -1
  218. package/dist/oauth/utilities/isDuplicateKeyError.js +0 -14
  219. package/dist/oauth/utilities/isDuplicateKeyError.js.map +0 -1
  220. package/dist/storage-content-api/api-types.d.ts +0 -161
  221. package/dist/storage-content-api/api-types.d.ts.map +0 -1
  222. package/dist/storage-content-api/api-types.js +0 -6
  223. package/dist/storage-content-api/api-types.js.map +0 -1
  224. package/dist/storage-content-api/client-uploads/ClientUploadHandler.d.ts +0 -9
  225. package/dist/storage-content-api/client-uploads/ClientUploadHandler.d.ts.map +0 -1
  226. package/dist/storage-content-api/client-uploads/ClientUploadHandler.js +0 -42
  227. package/dist/storage-content-api/client-uploads/ClientUploadHandler.js.map +0 -1
  228. package/dist/storage-content-api/client-uploads/generateSignedURL.d.ts +0 -13
  229. package/dist/storage-content-api/client-uploads/generateSignedURL.d.ts.map +0 -1
  230. package/dist/storage-content-api/client-uploads/generateSignedURL.js +0 -31
  231. package/dist/storage-content-api/client-uploads/generateSignedURL.js.map +0 -1
  232. package/dist/storage-content-api/client.d.ts +0 -6
  233. package/dist/storage-content-api/client.d.ts.map +0 -1
  234. package/dist/storage-content-api/client.js +0 -36
  235. package/dist/storage-content-api/client.js.map +0 -1
  236. package/dist/storage-content-api/generateURL.d.ts +0 -7
  237. package/dist/storage-content-api/generateURL.d.ts.map +0 -1
  238. package/dist/storage-content-api/generateURL.js +0 -7
  239. package/dist/storage-content-api/generateURL.js.map +0 -1
  240. package/dist/storage-content-api/handleDelete.d.ts +0 -8
  241. package/dist/storage-content-api/handleDelete.d.ts.map +0 -1
  242. package/dist/storage-content-api/handleDelete.js +0 -15
  243. package/dist/storage-content-api/handleDelete.js.map +0 -1
  244. package/dist/storage-content-api/handleUpload.d.ts +0 -11
  245. package/dist/storage-content-api/handleUpload.d.ts.map +0 -1
  246. package/dist/storage-content-api/handleUpload.js +0 -136
  247. package/dist/storage-content-api/handleUpload.js.map +0 -1
  248. package/dist/storage-content-api/index.d.ts +0 -5
  249. package/dist/storage-content-api/index.d.ts.map +0 -1
  250. package/dist/storage-content-api/index.js +0 -31
  251. package/dist/storage-content-api/index.js.map +0 -1
  252. package/dist/storage-content-api/staticHandler.d.ts +0 -10
  253. package/dist/storage-content-api/staticHandler.d.ts.map +0 -1
  254. package/dist/storage-content-api/staticHandler.js +0 -55
  255. package/dist/storage-content-api/staticHandler.js.map +0 -1
  256. package/dist/storage-content-api/types.d.ts +0 -10
  257. package/dist/storage-content-api/types.d.ts.map +0 -1
  258. package/dist/storage-content-api/types.js +0 -3
  259. package/dist/storage-content-api/types.js.map +0 -1
  260. package/dist/templates/README.md +0 -19
  261. package/dist/utils/build-lambda-zip.d.ts +0 -14
  262. package/dist/utils/build-lambda-zip.d.ts.map +0 -1
  263. package/dist/utils/build-lambda-zip.js +0 -81
  264. package/dist/utils/build-lambda-zip.js.map +0 -1
@@ -1,173 +0,0 @@
1
- import { flattenAllFields, traverseFields } from 'payload';
2
- import { applyDefaults } from './applyDefaults.js';
3
- import { castFieldValue } from './castFieldValue.js';
4
- import { removeVirtualFields } from './removeVirtualFields.js';
5
- import { stripFields } from './stripFields.js';
6
- /**
7
- * Transform data before sending to Content API (WRITE operations)
8
- *
9
- * Conversions applied:
10
- * - Default values: Apply static defaults for undefined fields (when applyDefaults=true)
11
- * - Type casting: Convert values to match field types (e.g., number -> string for text fields)
12
- * - RichText fields: Objects -> JSON strings
13
- * - Virtual fields: Remove fields with `virtual: true` (pure virtual fields should never be saved)
14
- *
15
- * Note: Date fields are automatically converted to ISO strings by JSON.stringify()
16
- */ export function dataToContentAPI(payload, collectionSlug, data, options) {
17
- if (!data || typeof data !== 'object') {
18
- return data;
19
- }
20
- // Deep clone to avoid mutating original data
21
- const transformed = JSON.parse(JSON.stringify(data));
22
- // Get collection config
23
- const isGlobal = collectionSlug.startsWith('_global-');
24
- const actualSlug = isGlobal ? collectionSlug.substring(8) : collectionSlug;
25
- const collectionConfig = isGlobal ? payload.config.globals?.find((g)=>g.slug === actualSlug) : payload.config.collections.find((c)=>c.slug === actualSlug);
26
- if (!collectionConfig?.fields) {
27
- return transformed;
28
- }
29
- // Apply static defaults recursively to handle nested structures (arrays, groups)
30
- // This must happen before traverseFields to ensure defaults are in place
31
- if (options?.applyDefaults) {
32
- applyDefaults(transformed, collectionConfig.fields);
33
- }
34
- // Use Payload's traverseFields to iterate over all fields for transformations
35
- const callback = ({ field, ref })=>{
36
- if (!('name' in field) || !field.name) {
37
- return;
38
- }
39
- if (!ref || typeof ref !== 'object') {
40
- return;
41
- }
42
- const current = ref;
43
- let value = current[field.name];
44
- // Transform existing values
45
- if (value !== null && value !== undefined) {
46
- // Step 1: Apply type casting (e.g., number -> string for text fields)
47
- value = castFieldValue(field, value);
48
- current[field.name] = value;
49
- // Step 2: Apply Content API specific transformations
50
- // RichText: object -> JSON string
51
- if (field.type === 'richText' && typeof value !== 'string') {
52
- current[field.name] = JSON.stringify(value);
53
- }
54
- // Date fields are already handled by JSON.stringify() which converts Date -> ISO string
55
- }
56
- };
57
- traverseFields({
58
- callback,
59
- fields: collectionConfig.fields,
60
- fillEmpty: false,
61
- ref: transformed
62
- });
63
- stripFields({
64
- config: payload.config,
65
- data: transformed,
66
- fields: flattenAllFields({
67
- cache: true,
68
- fields: collectionConfig.fields
69
- }),
70
- reservedKeys: [
71
- 'id',
72
- 'globalType'
73
- ]
74
- });
75
- removeVirtualFields(transformed, collectionConfig.fields);
76
- // Convert numeric ID to string for Content API
77
- const customIDType = payload.collections?.[collectionSlug]?.customIDType;
78
- if (customIDType === 'number') {
79
- transformed.id = String(transformed.id);
80
- }
81
- return transformed;
82
- }
83
- /**
84
- * Transform data received from Content API (READ operations)
85
- *
86
- * Conversions applied:
87
- * - RichText fields: JSON strings -> Objects
88
- * - Virtual fields: Remove fields with `virtual: true` (should not be in DB but Content API backend may add them)
89
- *
90
- * Note: Date fields come as ISO strings from Content API and stay as strings
91
- * (matching MongoDB and other adapters' behavior)
92
- */ export function dataFromContentAPI(payload, collectionSlug, data) {
93
- if (!data || typeof data !== 'object') {
94
- return data;
95
- }
96
- // Deep clone to avoid mutating original data
97
- const transformed = JSON.parse(JSON.stringify(data));
98
- // Get collection config
99
- const isGlobal = collectionSlug.startsWith('_global-');
100
- const actualSlug = isGlobal ? collectionSlug.substring(8) : collectionSlug;
101
- const collectionConfig = isGlobal ? payload.config.globals?.find((g)=>g.slug === actualSlug) : payload.config.collections.find((c)=>c.slug === actualSlug);
102
- if (!collectionConfig?.fields) {
103
- return transformed;
104
- }
105
- // Use Payload's traverseFields to iterate over all fields
106
- const callback = ({ field, parentPath, ref })=>{
107
- if (!('name' in field) || !field.name) {
108
- return;
109
- }
110
- if (!ref || typeof ref !== 'object') {
111
- return;
112
- }
113
- const current = ref;
114
- const value = current[field.name];
115
- if (value !== null && value !== undefined) {
116
- // RichText: JSON string -> object
117
- if (field.type === 'richText' && typeof value === 'string') {
118
- try {
119
- current[field.name] = JSON.parse(value);
120
- } catch (error) {
121
- const fieldPath = parentPath ? `${parentPath}.${field.name}` : field.name;
122
- payload.logger.warn({
123
- err: error instanceof Error ? error : new Error(String(error)),
124
- msg: `Failed to parse richtext field '${fieldPath}' in collection '${collectionSlug}'`
125
- });
126
- }
127
- }
128
- // Date fields: Already ISO strings from Content API, no conversion needed
129
- }
130
- };
131
- traverseFields({
132
- callback,
133
- fields: collectionConfig.fields,
134
- ref: transformed
135
- });
136
- // Convert string ID to number if collection uses numeric custom ID
137
- const customIDType = payload.collections?.[collectionSlug]?.customIDType;
138
- if (customIDType === 'number') {
139
- transformed.id = Number(transformed.id);
140
- }
141
- stripFields({
142
- config: payload.config,
143
- data: transformed,
144
- fields: flattenAllFields({
145
- cache: true,
146
- fields: collectionConfig.fields
147
- }),
148
- reservedKeys: [
149
- 'id',
150
- 'globalType'
151
- ]
152
- });
153
- // Remove virtual fields - must happen AFTER stripFields
154
- removeVirtualFields(transformed, collectionConfig.fields);
155
- // Handle auth-specific fields that aren't in the field schema
156
- // When these fields are null in DB, Content API omits them from response (undefined)
157
- // But Payload expects them to be null, not undefined
158
- // Only add them if the collection has auth enabled
159
- if ('auth' in collectionConfig && collectionConfig.auth) {
160
- const authFields = [
161
- 'resetPasswordExpiration',
162
- 'lockUntil'
163
- ];
164
- for (const fieldName of authFields){
165
- if (!(fieldName in transformed)) {
166
- transformed[fieldName] = null;
167
- }
168
- }
169
- }
170
- return transformed;
171
- }
172
-
173
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/db-content-api/utilities/data/index.ts"],"sourcesContent":["import type { CollectionConfig, GlobalConfig, Payload, TraverseFieldsCallback } from 'payload'\n\nimport { flattenAllFields, traverseFields } from 'payload'\n\nimport type { components } from '../../generated/content-api-types.js'\n\nimport { applyDefaults } from './applyDefaults.js'\nimport { castFieldValue } from './castFieldValue.js'\nimport { removeVirtualFields } from './removeVirtualFields.js'\nimport { stripFields } from './stripFields.js'\n\ntype DataWithOperations = components['schemas']['DataWithOperations']\n\n/**\n * Transform data before sending to Content API (WRITE operations)\n *\n * Conversions applied:\n * - Default values: Apply static defaults for undefined fields (when applyDefaults=true)\n * - Type casting: Convert values to match field types (e.g., number -> string for text fields)\n * - RichText fields: Objects -> JSON strings\n * - Virtual fields: Remove fields with `virtual: true` (pure virtual fields should never be saved)\n *\n * Note: Date fields are automatically converted to ISO strings by JSON.stringify()\n */\nexport function dataToContentAPI(\n payload: Payload,\n collectionSlug: string,\n data: unknown,\n options?: { applyDefaults?: boolean },\n): DataWithOperations {\n if (!data || typeof data !== 'object') {\n return data as DataWithOperations\n }\n\n // Deep clone to avoid mutating original data\n const transformed = JSON.parse(JSON.stringify(data))\n\n // Get collection config\n const isGlobal = collectionSlug.startsWith('_global-')\n const actualSlug = isGlobal ? collectionSlug.substring(8) : collectionSlug\n const collectionConfig: CollectionConfig | GlobalConfig | undefined = isGlobal\n ? payload.config.globals?.find((g) => g.slug === actualSlug)\n : payload.config.collections.find((c) => c.slug === actualSlug)\n\n if (!collectionConfig?.fields) {\n return transformed as DataWithOperations\n }\n\n // Apply static defaults recursively to handle nested structures (arrays, groups)\n // This must happen before traverseFields to ensure defaults are in place\n if (options?.applyDefaults) {\n applyDefaults(transformed, collectionConfig.fields)\n }\n\n // Use Payload's traverseFields to iterate over all fields for transformations\n const callback: TraverseFieldsCallback = ({ field, ref }) => {\n if (!('name' in field) || !field.name) {\n return\n }\n if (!ref || typeof ref !== 'object') {\n return\n }\n\n const current = ref as Record<string, unknown>\n let value = current[field.name]\n\n // Transform existing values\n if (value !== null && value !== undefined) {\n // Step 1: Apply type casting (e.g., number -> string for text fields)\n value = castFieldValue(field, value)\n current[field.name] = value\n\n // Step 2: Apply Content API specific transformations\n // RichText: object -> JSON string\n if (field.type === 'richText' && typeof value !== 'string') {\n current[field.name] = JSON.stringify(value)\n }\n // Date fields are already handled by JSON.stringify() which converts Date -> ISO string\n }\n }\n\n traverseFields({ callback, fields: collectionConfig.fields, fillEmpty: false, ref: transformed })\n\n stripFields({\n config: payload.config,\n data: transformed,\n fields: flattenAllFields({ cache: true, fields: collectionConfig.fields }),\n reservedKeys: ['id', 'globalType'],\n })\n\n removeVirtualFields(transformed, collectionConfig.fields)\n\n // Convert numeric ID to string for Content API\n const customIDType = payload.collections?.[collectionSlug]?.customIDType\n if (customIDType === 'number') {\n transformed.id = String(transformed.id)\n }\n\n return transformed as DataWithOperations\n}\n\n/**\n * Transform data received from Content API (READ operations)\n *\n * Conversions applied:\n * - RichText fields: JSON strings -> Objects\n * - Virtual fields: Remove fields with `virtual: true` (should not be in DB but Content API backend may add them)\n *\n * Note: Date fields come as ISO strings from Content API and stay as strings\n * (matching MongoDB and other adapters' behavior)\n */\nexport function dataFromContentAPI(\n payload: Payload,\n collectionSlug: string,\n data: unknown,\n): unknown {\n if (!data || typeof data !== 'object') {\n return data\n }\n\n // Deep clone to avoid mutating original data\n const transformed = JSON.parse(JSON.stringify(data))\n\n // Get collection config\n const isGlobal = collectionSlug.startsWith('_global-')\n const actualSlug = isGlobal ? collectionSlug.substring(8) : collectionSlug\n const collectionConfig: CollectionConfig | GlobalConfig | undefined = isGlobal\n ? payload.config.globals?.find((g) => g.slug === actualSlug)\n : payload.config.collections.find((c) => c.slug === actualSlug)\n\n if (!collectionConfig?.fields) {\n return transformed\n }\n\n // Use Payload's traverseFields to iterate over all fields\n const callback: TraverseFieldsCallback = ({ field, parentPath, ref }) => {\n if (!('name' in field) || !field.name) {\n return\n }\n if (!ref || typeof ref !== 'object') {\n return\n }\n\n const current = ref as Record<string, unknown>\n const value = current[field.name]\n\n if (value !== null && value !== undefined) {\n // RichText: JSON string -> object\n if (field.type === 'richText' && typeof value === 'string') {\n try {\n current[field.name] = JSON.parse(value)\n } catch (error) {\n const fieldPath = parentPath ? `${parentPath}.${field.name}` : field.name\n payload.logger.warn({\n err: error instanceof Error ? error : new Error(String(error)),\n msg: `Failed to parse richtext field '${fieldPath}' in collection '${collectionSlug}'`,\n })\n }\n }\n // Date fields: Already ISO strings from Content API, no conversion needed\n }\n }\n\n traverseFields({ callback, fields: collectionConfig.fields, ref: transformed })\n\n // Convert string ID to number if collection uses numeric custom ID\n const customIDType = payload.collections?.[collectionSlug]?.customIDType\n if (customIDType === 'number') {\n transformed.id = Number(transformed.id)\n }\n\n stripFields({\n config: payload.config,\n data: transformed,\n fields: flattenAllFields({ cache: true, fields: collectionConfig.fields }),\n reservedKeys: ['id', 'globalType'],\n })\n\n // Remove virtual fields - must happen AFTER stripFields\n removeVirtualFields(transformed, collectionConfig.fields)\n\n // Handle auth-specific fields that aren't in the field schema\n // When these fields are null in DB, Content API omits them from response (undefined)\n // But Payload expects them to be null, not undefined\n // Only add them if the collection has auth enabled\n if ('auth' in collectionConfig && collectionConfig.auth) {\n const authFields = ['resetPasswordExpiration', 'lockUntil']\n for (const fieldName of authFields) {\n if (!(fieldName in transformed)) {\n transformed[fieldName] = null\n }\n }\n }\n\n return transformed\n}\n"],"names":["flattenAllFields","traverseFields","applyDefaults","castFieldValue","removeVirtualFields","stripFields","dataToContentAPI","payload","collectionSlug","data","options","transformed","JSON","parse","stringify","isGlobal","startsWith","actualSlug","substring","collectionConfig","config","globals","find","g","slug","collections","c","fields","callback","field","ref","name","current","value","undefined","type","fillEmpty","cache","reservedKeys","customIDType","id","String","dataFromContentAPI","parentPath","error","fieldPath","logger","warn","err","Error","msg","Number","auth","authFields","fieldName"],"mappings":"AAEA,SAASA,gBAAgB,EAAEC,cAAc,QAAQ,UAAS;AAI1D,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,cAAc,QAAQ,sBAAqB;AACpD,SAASC,mBAAmB,QAAQ,2BAA0B;AAC9D,SAASC,WAAW,QAAQ,mBAAkB;AAI9C;;;;;;;;;;CAUC,GACD,OAAO,SAASC,iBACdC,OAAgB,EAChBC,cAAsB,EACtBC,IAAa,EACbC,OAAqC;IAErC,IAAI,CAACD,QAAQ,OAAOA,SAAS,UAAU;QACrC,OAAOA;IACT;IAEA,6CAA6C;IAC7C,MAAME,cAAcC,KAAKC,KAAK,CAACD,KAAKE,SAAS,CAACL;IAE9C,wBAAwB;IACxB,MAAMM,WAAWP,eAAeQ,UAAU,CAAC;IAC3C,MAAMC,aAAaF,WAAWP,eAAeU,SAAS,CAAC,KAAKV;IAC5D,MAAMW,mBAAgEJ,WAClER,QAAQa,MAAM,CAACC,OAAO,EAAEC,KAAK,CAACC,IAAMA,EAAEC,IAAI,KAAKP,cAC/CV,QAAQa,MAAM,CAACK,WAAW,CAACH,IAAI,CAAC,CAACI,IAAMA,EAAEF,IAAI,KAAKP;IAEtD,IAAI,CAACE,kBAAkBQ,QAAQ;QAC7B,OAAOhB;IACT;IAEA,iFAAiF;IACjF,yEAAyE;IACzE,IAAID,SAASR,eAAe;QAC1BA,cAAcS,aAAaQ,iBAAiBQ,MAAM;IACpD;IAEA,8EAA8E;IAC9E,MAAMC,WAAmC,CAAC,EAAEC,KAAK,EAAEC,GAAG,EAAE;QACtD,IAAI,CAAE,CAAA,UAAUD,KAAI,KAAM,CAACA,MAAME,IAAI,EAAE;YACrC;QACF;QACA,IAAI,CAACD,OAAO,OAAOA,QAAQ,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IAC5D,IAAIA,iBAAiB,UAAU;QAC7B5B,YAAY6B,EAAE,GAAGW,OAAOxC,YAAY6B,EAAE;IACxC;IAEAnC,YAAY;QACVe,QAAQb,QAAQa,MAAM;QACtBX,MAAME;QACNgB,QAAQ3B,iBAAiB;YAAEqC,OAAO;YAAMV,QAAQR,iBAAiBQ,MAAM;QAAC;QACxEW,cAAc;YAAC;YAAM;SAAa;IACpC;IAEA,wDAAwD;IACxDlC,oBAAoBO,aAAaQ,iBAAiBQ,MAAM;IAExD,8DAA8D;IAC9D,qFAAqF;IACrF,qDAAqD;IACrD,mDAAmD;IACnD,IAAI,UAAUR,oBAAoBA,iBAAiBiC,IAAI,EAAE;QACvD,MAAMC,aAAa;YAAC;YAA2B;SAAY;QAC3D,KAAK,MAAMC,aAAaD,WAAY;YAClC,IAAI,CAAEC,CAAAA,aAAa3C,WAAU,GAAI;gBAC/BA,WAAW,CAAC2C,UAAU,GAAG;YAC3B;QACF;IACF;IAEA,OAAO3C;AACT"}
@@ -1,12 +0,0 @@
1
- import type { CollectionConfig } from 'payload';
2
- /**
3
- * Removes virtual fields (fields with virtual: true) from data recursively.
4
- * Virtual fields should never be persisted in the database.
5
- *
6
- * @todo It might be a good idea to combine `stripFields` with `stripFields`
7
- * in a new utility that receives a callback with conditions. I didn't do
8
- * it now because `stripFields` was copied from db-mongo and I'd like to
9
- * find a way to unify everything.
10
- */
11
- export declare function removeVirtualFields(data: Record<string, unknown>, fieldConfigs: CollectionConfig['fields']): void;
12
- //# sourceMappingURL=removeVirtualFields.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"removeVirtualFields.d.ts","sourceRoot":"","sources":["../../../../src/db-content-api/utilities/data/removeVirtualFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAE/C;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,YAAY,EAAE,gBAAgB,CAAC,QAAQ,CAAC,GACvC,IAAI,CAgDN"}
@@ -1,54 +0,0 @@
1
- /**
2
- * Removes virtual fields (fields with virtual: true) from data recursively.
3
- * Virtual fields should never be persisted in the database.
4
- *
5
- * @todo It might be a good idea to combine `stripFields` with `stripFields`
6
- * in a new utility that receives a callback with conditions. I didn't do
7
- * it now because `stripFields` was copied from db-mongo and I'd like to
8
- * find a way to unify everything.
9
- */ export function removeVirtualFields(data, fieldConfigs) {
10
- for (const field of fieldConfigs){
11
- // Handle UI fields (row, collapsible, tabs) - they don't have names
12
- // but contain other fields that might be virtual
13
- if (field.type === 'row' || field.type === 'collapsible') {
14
- if ('fields' in field) {
15
- removeVirtualFields(data, field.fields);
16
- }
17
- continue;
18
- }
19
- if (field.type === 'tabs' && 'tabs' in field) {
20
- for (const tab of field.tabs){
21
- if ('fields' in tab) {
22
- removeVirtualFields(data, tab.fields);
23
- }
24
- }
25
- continue;
26
- }
27
- // Skip fields without names
28
- if (!('name' in field) || !field.name) {
29
- continue;
30
- }
31
- // Remove field if it has virtual: true
32
- if ('virtual' in field && field.virtual === true) {
33
- delete data[field.name];
34
- continue;
35
- }
36
- // Recursively handle nested structures (groups, arrays with items, etc.)
37
- if ('fields' in field && field.name in data) {
38
- const value = data[field.name];
39
- if (field.type === 'array' && Array.isArray(value)) {
40
- // Process each array item
41
- for (const item of value){
42
- if (item && typeof item === 'object') {
43
- removeVirtualFields(item, field.fields);
44
- }
45
- }
46
- } else if (field.type === 'group' && value && typeof value === 'object') {
47
- // Process group
48
- removeVirtualFields(value, field.fields);
49
- }
50
- }
51
- }
52
- }
53
-
54
- //# sourceMappingURL=removeVirtualFields.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/db-content-api/utilities/data/removeVirtualFields.ts"],"sourcesContent":["import type { CollectionConfig } from 'payload'\n\n/**\n * Removes virtual fields (fields with virtual: true) from data recursively.\n * Virtual fields should never be persisted in the database.\n *\n * @todo It might be a good idea to combine `stripFields` with `stripFields`\n * in a new utility that receives a callback with conditions. I didn't do\n * it now because `stripFields` was copied from db-mongo and I'd like to\n * find a way to unify everything.\n */\nexport function removeVirtualFields(\n data: Record<string, unknown>,\n fieldConfigs: CollectionConfig['fields'],\n): void {\n for (const field of fieldConfigs) {\n // Handle UI fields (row, collapsible, tabs) - they don't have names\n // but contain other fields that might be virtual\n if (field.type === 'row' || field.type === 'collapsible') {\n if ('fields' in field) {\n removeVirtualFields(data, field.fields)\n }\n continue\n }\n\n if (field.type === 'tabs' && 'tabs' in field) {\n for (const tab of field.tabs) {\n if ('fields' in tab) {\n removeVirtualFields(data, tab.fields)\n }\n }\n continue\n }\n\n // Skip fields without names\n if (!('name' in field) || !field.name) {\n continue\n }\n\n // Remove field if it has virtual: true\n if ('virtual' in field && field.virtual === true) {\n delete data[field.name]\n continue\n }\n\n // Recursively handle nested structures (groups, arrays with items, etc.)\n if ('fields' in field && field.name in data) {\n const value = data[field.name]\n\n if (field.type === 'array' && Array.isArray(value)) {\n // Process each array item\n for (const item of value) {\n if (item && typeof item === 'object') {\n removeVirtualFields(item as Record<string, unknown>, field.fields)\n }\n }\n } else if (field.type === 'group' && value && typeof value === 'object') {\n // Process group\n removeVirtualFields(value as Record<string, unknown>, field.fields)\n }\n }\n }\n}\n"],"names":["removeVirtualFields","data","fieldConfigs","field","type","fields","tab","tabs","name","virtual","value","Array","isArray","item"],"mappings":"AAEA;;;;;;;;CAQC,GACD,OAAO,SAASA,oBACdC,IAA6B,EAC7BC,YAAwC;IAExC,KAAK,MAAMC,SAASD,aAAc;QAChC,oEAAoE;QACpE,iDAAiD;QACjD,IAAIC,MAAMC,IAAI,KAAK,SAASD,MAAMC,IAAI,KAAK,eAAe;YACxD,IAAI,YAAYD,OAAO;gBACrBH,oBAAoBC,MAAME,MAAME,MAAM;YACxC;YACA;QACF;QAEA,IAAIF,MAAMC,IAAI,KAAK,UAAU,UAAUD,OAAO;YAC5C,KAAK,MAAMG,OAAOH,MAAMI,IAAI,CAAE;gBAC5B,IAAI,YAAYD,KAAK;oBACnBN,oBAAoBC,MAAMK,IAAID,MAAM;gBACtC;YACF;YACA;QACF;QAEA,4BAA4B;QAC5B,IAAI,CAAE,CAAA,UAAUF,KAAI,KAAM,CAACA,MAAMK,IAAI,EAAE;YACrC;QACF;QAEA,uCAAuC;QACvC,IAAI,aAAaL,SAASA,MAAMM,OAAO,KAAK,MAAM;YAChD,OAAOR,IAAI,CAACE,MAAMK,IAAI,CAAC;YACvB;QACF;QAEA,yEAAyE;QACzE,IAAI,YAAYL,SAASA,MAAMK,IAAI,IAAIP,MAAM;YAC3C,MAAMS,QAAQT,IAAI,CAACE,MAAMK,IAAI,CAAC;YAE9B,IAAIL,MAAMC,IAAI,KAAK,WAAWO,MAAMC,OAAO,CAACF,QAAQ;gBAClD,0BAA0B;gBAC1B,KAAK,MAAMG,QAAQH,MAAO;oBACxB,IAAIG,QAAQ,OAAOA,SAAS,UAAU;wBACpCb,oBAAoBa,MAAiCV,MAAME,MAAM;oBACnE;gBACF;YACF,OAAO,IAAIF,MAAMC,IAAI,KAAK,WAAWM,SAAS,OAAOA,UAAU,UAAU;gBACvE,gBAAgB;gBAChBV,oBAAoBU,OAAkCP,MAAME,MAAM;YACpE;QACF;IACF;AACF"}
@@ -1,48 +0,0 @@
1
- import type { FlattenedField, SanitizedConfig } from 'payload';
2
- /**
3
- * Strips fields from data that are not defined in the schema or are invalid.
4
- *
5
- * This function was copied from the MongoDB adapter's implementation:
6
- * @see packages/db-mongodb/src/utilities/transform.ts (stripFields function)
7
- *
8
- * @description
9
- * This utility performs deep sanitization of document data by:
10
- * 1. **Removing undefined fields**: Strips any field not present in the collection's schema
11
- * (e.g., sensitive fields like `password`, `apiKey`, or any extra fields not in config)
12
- * 2. **Removing invalid locales**: Deletes locale keys that don't exist in `config.localization.localeCodes`
13
- * (e.g., if data contains `{ "es-MX": "..." }` but only `"en"` is configured)
14
- * 3. **Removing invalid blocks**: Filters out blocks with unknown `blockType` values
15
- * (prevents data corruption from blocks that don't exist in the schema)
16
- * 4. **Recursive sanitization**: Processes nested structures (arrays, groups, blocks, localized fields)
17
- * to ensure deep data integrity
18
- *
19
- * @remarks
20
- * Unlike MongoDB's adapter which uses Mongoose schemas with `strict: true` (rejecting extra fields
21
- * on write), Content API uses flexible JSONB storage that accepts any fields. Therefore, this
22
- * function is called on **both read and write operations** to ensure data consistency.
23
- *
24
- * The MongoDB adapter also supports an `allowAdditionalKeys` option that allows reading/writing
25
- * fields not in the schema. For now, Content API does not support this feature - we always
26
- * sanitize data. If users request this functionality in the future, we can consider adding it.
27
- *
28
- * @todo
29
- * 1. Consider moving this utility to `payload/shared` so both MongoDB and Content API adapters
30
- * can use the same implementation, reducing code duplication and maintenance burden.
31
- *
32
- * 2. Performance optimization: This function iterates through all fields recursively.
33
- * The `dataToContentAPI` and `dataFromContentAPI` functions in
34
- * `packages/figma/src/db-content-api/utilities/data.ts` also iterate through fields
35
- * to transform richText (object ↔ JSON string), custom IDs (number ↔ string), and dates.
36
- * Consider combining both traversals into a single abstraction to avoid iterating twice.
37
- *
38
- * 3. Feature parity: MongoDB adapter has `allowAdditionalKeys` option. We currently always
39
- * strip additional keys, but could add this as a configurable option if users need it.
40
- */
41
- export declare const stripFields: ({ config, data, fields, parentIsLocalized, reservedKeys, }: {
42
- config: SanitizedConfig;
43
- data: any;
44
- fields: FlattenedField[];
45
- parentIsLocalized?: boolean;
46
- reservedKeys?: string[];
47
- }) => void;
48
- //# sourceMappingURL=stripFields.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stripFields.d.ts","sourceRoot":"","sources":["../../../../src/db-content-api/utilities/data/stripFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,cAAc,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAI9E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,eAAO,MAAM,WAAW,+DAMrB;IACD,MAAM,EAAE,eAAe,CAAA;IAEvB,IAAI,EAAE,GAAG,CAAA;IACT,MAAM,EAAE,cAAc,EAAE,CAAA;IACxB,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;CACxB,SAmLA,CAAA"}
@@ -1,195 +0,0 @@
1
- import { fieldShouldBeLocalized } from 'payload/shared';
2
- /**
3
- * Strips fields from data that are not defined in the schema or are invalid.
4
- *
5
- * This function was copied from the MongoDB adapter's implementation:
6
- * @see packages/db-mongodb/src/utilities/transform.ts (stripFields function)
7
- *
8
- * @description
9
- * This utility performs deep sanitization of document data by:
10
- * 1. **Removing undefined fields**: Strips any field not present in the collection's schema
11
- * (e.g., sensitive fields like `password`, `apiKey`, or any extra fields not in config)
12
- * 2. **Removing invalid locales**: Deletes locale keys that don't exist in `config.localization.localeCodes`
13
- * (e.g., if data contains `{ "es-MX": "..." }` but only `"en"` is configured)
14
- * 3. **Removing invalid blocks**: Filters out blocks with unknown `blockType` values
15
- * (prevents data corruption from blocks that don't exist in the schema)
16
- * 4. **Recursive sanitization**: Processes nested structures (arrays, groups, blocks, localized fields)
17
- * to ensure deep data integrity
18
- *
19
- * @remarks
20
- * Unlike MongoDB's adapter which uses Mongoose schemas with `strict: true` (rejecting extra fields
21
- * on write), Content API uses flexible JSONB storage that accepts any fields. Therefore, this
22
- * function is called on **both read and write operations** to ensure data consistency.
23
- *
24
- * The MongoDB adapter also supports an `allowAdditionalKeys` option that allows reading/writing
25
- * fields not in the schema. For now, Content API does not support this feature - we always
26
- * sanitize data. If users request this functionality in the future, we can consider adding it.
27
- *
28
- * @todo
29
- * 1. Consider moving this utility to `payload/shared` so both MongoDB and Content API adapters
30
- * can use the same implementation, reducing code duplication and maintenance burden.
31
- *
32
- * 2. Performance optimization: This function iterates through all fields recursively.
33
- * The `dataToContentAPI` and `dataFromContentAPI` functions in
34
- * `packages/figma/src/db-content-api/utilities/data.ts` also iterate through fields
35
- * to transform richText (object ↔ JSON string), custom IDs (number ↔ string), and dates.
36
- * Consider combining both traversals into a single abstraction to avoid iterating twice.
37
- *
38
- * 3. Feature parity: MongoDB adapter has `allowAdditionalKeys` option. We currently always
39
- * strip additional keys, but could add this as a configurable option if users need it.
40
- */ export const stripFields = ({ config, data, fields, parentIsLocalized = false, reservedKeys = [] })=>{
41
- for(const k in data){
42
- if (!fields.some((field)=>field.name === k) && !reservedKeys.includes(k)) {
43
- delete data[k];
44
- }
45
- }
46
- for (const field of fields){
47
- reservedKeys = [];
48
- const fieldData = data[field.name];
49
- if (!fieldData || typeof fieldData !== 'object') {
50
- continue;
51
- }
52
- const shouldLocalizeField = fieldShouldBeLocalized({
53
- field,
54
- parentIsLocalized
55
- });
56
- if (field.type === 'blocks') {
57
- reservedKeys.push('blockType');
58
- }
59
- if ('flattenedFields' in field || 'blocks' in field) {
60
- if (shouldLocalizeField && config.localization) {
61
- for(const localeKey in fieldData){
62
- if (!config.localization.localeCodes.some((code)=>code === localeKey)) {
63
- delete fieldData[localeKey];
64
- continue;
65
- }
66
- const localeData = fieldData[localeKey];
67
- if (!localeData || typeof localeData !== 'object') {
68
- continue;
69
- }
70
- if (field.type === 'array' || field.type === 'blocks') {
71
- if (!Array.isArray(localeData)) {
72
- continue;
73
- }
74
- let hasNull = false;
75
- for(let i = 0; i < localeData.length; i++){
76
- const data = localeData[i];
77
- let fields = null;
78
- if (field.type === 'array') {
79
- fields = field.flattenedFields;
80
- } else {
81
- let maybeBlock = undefined;
82
- if (field.blockReferences) {
83
- const maybeBlockReference = field.blockReferences.find((each)=>{
84
- const slug = typeof each === 'string' ? each : each.slug;
85
- return slug === data.blockType;
86
- });
87
- if (maybeBlockReference) {
88
- if (typeof maybeBlockReference === 'object') {
89
- maybeBlock = maybeBlockReference;
90
- } else {
91
- maybeBlock = config.blocks?.find((each)=>each.slug === maybeBlockReference);
92
- }
93
- }
94
- }
95
- if (!maybeBlock) {
96
- maybeBlock = field.blocks.find((each)=>each.slug === data.blockType);
97
- }
98
- if (maybeBlock) {
99
- fields = maybeBlock.flattenedFields;
100
- } else {
101
- localeData[i] = null;
102
- hasNull = true;
103
- }
104
- }
105
- if (!fields) {
106
- continue;
107
- }
108
- stripFields({
109
- config,
110
- data,
111
- fields,
112
- parentIsLocalized: parentIsLocalized || field.localized,
113
- reservedKeys
114
- });
115
- }
116
- if (hasNull) {
117
- fieldData[localeKey] = localeData.filter(Boolean);
118
- }
119
- continue;
120
- } else {
121
- stripFields({
122
- config,
123
- data: localeData,
124
- fields: field.flattenedFields,
125
- parentIsLocalized: parentIsLocalized || field.localized,
126
- reservedKeys
127
- });
128
- }
129
- }
130
- continue;
131
- }
132
- if (field.type === 'array' || field.type === 'blocks') {
133
- if (!Array.isArray(fieldData)) {
134
- continue;
135
- }
136
- let hasNull = false;
137
- for(let i = 0; i < fieldData.length; i++){
138
- const data = fieldData[i];
139
- let fields = null;
140
- if (field.type === 'array') {
141
- fields = field.flattenedFields;
142
- } else {
143
- let maybeBlock = undefined;
144
- if (field.blockReferences) {
145
- const maybeBlockReference = field.blockReferences.find((each)=>{
146
- const slug = typeof each === 'string' ? each : each.slug;
147
- return slug === data.blockType;
148
- });
149
- if (maybeBlockReference) {
150
- if (typeof maybeBlockReference === 'object') {
151
- maybeBlock = maybeBlockReference;
152
- } else {
153
- maybeBlock = config.blocks?.find((each)=>each.slug === maybeBlockReference);
154
- }
155
- }
156
- }
157
- if (!maybeBlock) {
158
- maybeBlock = field.blocks.find((each)=>each.slug === data.blockType);
159
- }
160
- if (maybeBlock) {
161
- fields = maybeBlock.flattenedFields;
162
- } else {
163
- fieldData[i] = null;
164
- hasNull = true;
165
- }
166
- }
167
- if (!fields) {
168
- continue;
169
- }
170
- stripFields({
171
- config,
172
- data,
173
- fields,
174
- parentIsLocalized: parentIsLocalized || field.localized,
175
- reservedKeys
176
- });
177
- }
178
- if (hasNull) {
179
- data[field.name] = fieldData.filter(Boolean);
180
- }
181
- continue;
182
- } else {
183
- stripFields({
184
- config,
185
- data: fieldData,
186
- fields: field.flattenedFields,
187
- parentIsLocalized: parentIsLocalized || field.localized,
188
- reservedKeys
189
- });
190
- }
191
- }
192
- }
193
- };
194
-
195
- //# sourceMappingURL=stripFields.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/db-content-api/utilities/data/stripFields.ts"],"sourcesContent":["import type { FlattenedBlock, FlattenedField, SanitizedConfig } from 'payload'\n\nimport { fieldShouldBeLocalized } from 'payload/shared'\n\n/**\n * Strips fields from data that are not defined in the schema or are invalid.\n *\n * This function was copied from the MongoDB adapter's implementation:\n * @see packages/db-mongodb/src/utilities/transform.ts (stripFields function)\n *\n * @description\n * This utility performs deep sanitization of document data by:\n * 1. **Removing undefined fields**: Strips any field not present in the collection's schema\n * (e.g., sensitive fields like `password`, `apiKey`, or any extra fields not in config)\n * 2. **Removing invalid locales**: Deletes locale keys that don't exist in `config.localization.localeCodes`\n * (e.g., if data contains `{ \"es-MX\": \"...\" }` but only `\"en\"` is configured)\n * 3. **Removing invalid blocks**: Filters out blocks with unknown `blockType` values\n * (prevents data corruption from blocks that don't exist in the schema)\n * 4. **Recursive sanitization**: Processes nested structures (arrays, groups, blocks, localized fields)\n * to ensure deep data integrity\n *\n * @remarks\n * Unlike MongoDB's adapter which uses Mongoose schemas with `strict: true` (rejecting extra fields\n * on write), Content API uses flexible JSONB storage that accepts any fields. Therefore, this\n * function is called on **both read and write operations** to ensure data consistency.\n *\n * The MongoDB adapter also supports an `allowAdditionalKeys` option that allows reading/writing\n * fields not in the schema. For now, Content API does not support this feature - we always\n * sanitize data. If users request this functionality in the future, we can consider adding it.\n *\n * @todo\n * 1. Consider moving this utility to `payload/shared` so both MongoDB and Content API adapters\n * can use the same implementation, reducing code duplication and maintenance burden.\n *\n * 2. Performance optimization: This function iterates through all fields recursively.\n * The `dataToContentAPI` and `dataFromContentAPI` functions in\n * `packages/figma/src/db-content-api/utilities/data.ts` also iterate through fields\n * to transform richText (object ↔ JSON string), custom IDs (number ↔ string), and dates.\n * Consider combining both traversals into a single abstraction to avoid iterating twice.\n *\n * 3. Feature parity: MongoDB adapter has `allowAdditionalKeys` option. We currently always\n * strip additional keys, but could add this as a configurable option if users need it.\n */\nexport const stripFields = ({\n config,\n data,\n fields,\n parentIsLocalized = false,\n reservedKeys = [],\n}: {\n config: SanitizedConfig\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data: any\n fields: FlattenedField[]\n parentIsLocalized?: boolean\n reservedKeys?: string[]\n}) => {\n for (const k in data) {\n if (!fields.some((field) => field.name === k) && !reservedKeys.includes(k)) {\n delete data[k]\n }\n }\n\n for (const field of fields) {\n reservedKeys = []\n const fieldData = data[field.name]\n if (!fieldData || typeof fieldData !== 'object') {\n continue\n }\n\n const shouldLocalizeField = fieldShouldBeLocalized({ field, parentIsLocalized })\n\n if (field.type === 'blocks') {\n reservedKeys.push('blockType')\n }\n\n if ('flattenedFields' in field || 'blocks' in field) {\n if (shouldLocalizeField && config.localization) {\n for (const localeKey in fieldData) {\n if (!config.localization.localeCodes.some((code) => code === localeKey)) {\n delete fieldData[localeKey]\n continue\n }\n\n const localeData = fieldData[localeKey]\n\n if (!localeData || typeof localeData !== 'object') {\n continue\n }\n\n if (field.type === 'array' || field.type === 'blocks') {\n if (!Array.isArray(localeData)) {\n continue\n }\n\n let hasNull = false\n for (let i = 0; i < localeData.length; i++) {\n const data = localeData[i]\n let fields: FlattenedField[] | null = null\n\n if (field.type === 'array') {\n fields = field.flattenedFields\n } else {\n let maybeBlock: FlattenedBlock | undefined = undefined\n\n if (field.blockReferences) {\n const maybeBlockReference = field.blockReferences.find((each) => {\n const slug = typeof each === 'string' ? each : each.slug\n return slug === data.blockType\n })\n\n if (maybeBlockReference) {\n if (typeof maybeBlockReference === 'object') {\n maybeBlock = maybeBlockReference\n } else {\n maybeBlock = config.blocks?.find((each) => each.slug === maybeBlockReference)\n }\n }\n }\n\n if (!maybeBlock) {\n maybeBlock = field.blocks.find((each) => each.slug === data.blockType)\n }\n\n if (maybeBlock) {\n fields = maybeBlock.flattenedFields\n } else {\n localeData[i] = null\n hasNull = true\n }\n }\n\n if (!fields) {\n continue\n }\n\n stripFields({\n config,\n data,\n fields,\n parentIsLocalized: parentIsLocalized || field.localized,\n reservedKeys,\n })\n }\n\n if (hasNull) {\n fieldData[localeKey] = localeData.filter(Boolean)\n }\n\n continue\n } else {\n stripFields({\n config,\n data: localeData,\n fields: field.flattenedFields,\n parentIsLocalized: parentIsLocalized || field.localized,\n reservedKeys,\n })\n }\n }\n continue\n }\n\n if (field.type === 'array' || field.type === 'blocks') {\n if (!Array.isArray(fieldData)) {\n continue\n }\n\n let hasNull = false\n\n for (let i = 0; i < fieldData.length; i++) {\n const data = fieldData[i]\n let fields: FlattenedField[] | null = null\n\n if (field.type === 'array') {\n fields = field.flattenedFields\n } else {\n let maybeBlock: FlattenedBlock | undefined = undefined\n\n if (field.blockReferences) {\n const maybeBlockReference = field.blockReferences.find((each) => {\n const slug = typeof each === 'string' ? each : each.slug\n return slug === data.blockType\n })\n\n if (maybeBlockReference) {\n if (typeof maybeBlockReference === 'object') {\n maybeBlock = maybeBlockReference\n } else {\n maybeBlock = config.blocks?.find((each) => each.slug === maybeBlockReference)\n }\n }\n }\n\n if (!maybeBlock) {\n maybeBlock = field.blocks.find((each) => each.slug === data.blockType)\n }\n\n if (maybeBlock) {\n fields = maybeBlock.flattenedFields\n } else {\n fieldData[i] = null\n hasNull = true\n }\n }\n\n if (!fields) {\n continue\n }\n\n stripFields({\n config,\n data,\n fields,\n parentIsLocalized: parentIsLocalized || field.localized,\n reservedKeys,\n })\n }\n\n if (hasNull) {\n data[field.name] = fieldData.filter(Boolean)\n }\n\n continue\n } else {\n stripFields({\n config,\n data: fieldData,\n fields: field.flattenedFields,\n parentIsLocalized: parentIsLocalized || field.localized,\n reservedKeys,\n })\n }\n }\n }\n}\n"],"names":["fieldShouldBeLocalized","stripFields","config","data","fields","parentIsLocalized","reservedKeys","k","some","field","name","includes","fieldData","shouldLocalizeField","type","push","localization","localeKey","localeCodes","code","localeData","Array","isArray","hasNull","i","length","flattenedFields","maybeBlock","undefined","blockReferences","maybeBlockReference","find","each","slug","blockType","blocks","localized","filter","Boolean"],"mappings":"AAEA,SAASA,sBAAsB,QAAQ,iBAAgB;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsCC,GACD,OAAO,MAAMC,cAAc,CAAC,EAC1BC,MAAM,EACNC,IAAI,EACJC,MAAM,EACNC,oBAAoB,KAAK,EACzBC,eAAe,EAAE,EAQlB;IACC,IAAK,MAAMC,KAAKJ,KAAM;QACpB,IAAI,CAACC,OAAOI,IAAI,CAAC,CAACC,QAAUA,MAAMC,IAAI,KAAKH,MAAM,CAACD,aAAaK,QAAQ,CAACJ,IAAI;YAC1E,OAAOJ,IAAI,CAACI,EAAE;QAChB;IACF;IAEA,KAAK,MAAME,SAASL,OAAQ;QAC1BE,eAAe,EAAE;QACjB,MAAMM,YAAYT,IAAI,CAACM,MAAMC,IAAI,CAAC;QAClC,IAAI,CAACE,aAAa,OAAOA,cAAc,UAAU;YAC/C;QACF;QAEA,MAAMC,sBAAsBb,uBAAuB;YAAES;YAAOJ;QAAkB;QAE9E,IAAII,MAAMK,IAAI,KAAK,UAAU;YAC3BR,aAAaS,IAAI,CAAC;QACpB;QAEA,IAAI,qBAAqBN,SAAS,YAAYA,OAAO;YACnD,IAAII,uBAAuBX,OAAOc,YAAY,EAAE;gBAC9C,IAAK,MAAMC,aAAaL,UAAW;oBACjC,IAAI,CAACV,OAAOc,YAAY,CAACE,WAAW,CAACV,IAAI,CAAC,CAACW,OAASA,SAASF,YAAY;wBACvE,OAAOL,SAAS,CAACK,UAAU;wBAC3B;oBACF;oBAEA,MAAMG,aAAaR,SAAS,CAACK,UAAU;oBAEvC,IAAI,CAACG,cAAc,OAAOA,eAAe,UAAU;wBACjD;oBACF;oBAEA,IAAIX,MAAMK,IAAI,KAAK,WAAWL,MAAMK,IAAI,KAAK,UAAU;wBACrD,IAAI,CA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,SAAS;wBACvD9B;oBACF;gBACF;gBAEA,IAAIiB,SAAS;oBACXpB,IAAI,CAACM,MAAMC,IAAI,CAAC,GAAGE,UAAUyB,MAAM,CAACC;gBACtC;gBAEA;YACF,OAAO;gBACLrC,YAAY;oBACVC;oBACAC,MAAMS;oBACNR,QAAQK,MAAMiB,eAAe;oBAC7BrB,mBAAmBA,qBAAqBI,MAAM2B,SAAS;oBACvD9B;gBACF;YACF;QACF;IACF;AACF,EAAC"}
@@ -1,55 +0,0 @@
1
- import type { JoinQuery, Payload } from 'payload';
2
- import type { components } from '../generated/content-api-types.js';
3
- type ContentAPIJoin = components['schemas']['JoinClause'][number];
4
- /**
5
- * Convert Payload's JoinQuery to Content API's join format.
6
- *
7
- * ## Content API Join Limitations
8
- *
9
- * The following Payload join features are NOT YET supported by Content API:
10
- *
11
- * 1. **hasMany relationships** - Content API's join uses `data#>'{path}'#>>'{}'` to extract
12
- * a single ID. HasMany relationships store arrays `["id1", "id2"]` which can't match.
13
- *
14
- * 2. **Array field relationships** - `on: 'array.category'` expects iteration over array
15
- * elements, but Content API treats the path as a single JSONB extraction.
16
- *
17
- * 3. **Polymorphic relationships** - Stored as `{ relationTo, value }` objects, but
18
- * Content API expects a simple ID string.
19
- *
20
- * 4. **Localized relationship fields** - Locale-aware joins not implemented.
21
- *
22
- * Note: "Where querying through joins" (e.g., `where: { 'relatedPosts.title': { equals: 'x' } }`)
23
- * is a separate Payload feature that filters documents based on joined data. This is NOT
24
- * a join feature but a where clause feature, and would need separate Content API support.
25
- *
26
- * Payload's JoinQuery format (at runtime):
27
- * {
28
- * 'group.relatedPosts': { // joinPath - where results go in the document
29
- * sort: '-title',
30
- * limit: 10,
31
- * page: 2, // page-based pagination
32
- * where: { ... }, // Payload where format
33
- * count: true
34
- * }
35
- * }
36
- *
37
- * Content API's join format:
38
- * [{
39
- * collectionId: 'posts', // collection to join FROM
40
- * on: 'group.category', // field in joined collection pointing to this doc
41
- * path: 'group.relatedPosts', // where to put results
42
- * count: false,
43
- * where: { ... }, // Content API where format
44
- * sort: '-title',
45
- * limit: 10,
46
- * offset: 10 // offset-based pagination
47
- * }]
48
- *
49
- * The mapping requires the collection config to resolve:
50
- * - Which collection each join field refers to
51
- * - What the 'on' field is for each join
52
- */
53
- export declare function convertPayloadJoinsToContentAPI(payload: Payload, collectionSlug: string, joins: false | JoinQuery | undefined): ContentAPIJoin[] | undefined;
54
- export {};
55
- //# sourceMappingURL=joins.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"joins.d.ts","sourceRoot":"","sources":["../../../src/db-content-api/utilities/joins.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAEjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAMnE,KAAK,cAAc,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,CAAA;AAEjE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,MAAM,EACtB,KAAK,EAAE,KAAK,GAAG,SAAS,GAAG,SAAS,GACnC,cAAc,EAAE,GAAG,SAAS,CAyF9B"}