@payloadcms/figma 0.1.0-alpha.1 → 0.1.0-alpha.10

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 (297) hide show
  1. package/LICENSE.md +1 -1
  2. package/dist/{utils → adapters}/asset-collection.d.ts +17 -3
  3. package/dist/adapters/asset-collection.js +242 -0
  4. package/dist/{utils → adapters}/build-lambda-zip.d.ts +8 -7
  5. package/dist/adapters/build-lambda-zip.js +111 -0
  6. package/dist/adapters/configureNextjsCache.d.ts +8 -0
  7. package/dist/adapters/configureNextjsCache.js +55 -0
  8. package/dist/adapters/deploy-output/inspectNextjsOutput/getNextRelativeAppDir.d.ts +1 -0
  9. package/dist/adapters/deploy-output/inspectNextjsOutput/getNextRelativeAppDir.js +15 -0
  10. package/dist/adapters/deploy-output/inspectNextjsOutput.d.ts +12 -0
  11. package/dist/adapters/deploy-output/inspectNextjsOutput.js +28 -0
  12. package/dist/adapters/deploy-output/inspectNitroOutput.d.ts +9 -0
  13. package/dist/adapters/deploy-output/inspectNitroOutput.js +13 -0
  14. package/dist/adapters/deploy-output/isFile.d.ts +1 -0
  15. package/dist/adapters/deploy-output/isFile.js +4 -0
  16. package/dist/adapters/deploy-output/readJson.d.ts +1 -0
  17. package/dist/adapters/deploy-output/readJson.js +9 -0
  18. package/dist/adapters/deploy-output/resolveNitroOutputLayout.d.ts +8 -0
  19. package/dist/adapters/deploy-output/resolveNitroOutputLayout.js +16 -0
  20. package/dist/adapters/deploy-output/resolveOutputPath.d.ts +2 -0
  21. package/dist/adapters/deploy-output/resolveOutputPath.js +9 -0
  22. package/dist/adapters/deploy-output/resolveWithin.d.ts +1 -0
  23. package/dist/adapters/deploy-output/resolveWithin.js +12 -0
  24. package/dist/adapters/fs-utils.d.ts +39 -0
  25. package/dist/adapters/fs-utils.js +135 -0
  26. package/dist/adapters/index.d.ts +4 -0
  27. package/dist/adapters/index.js +3 -0
  28. package/dist/adapters/lambda-runtime/nextjs-cache.d.ts +40 -0
  29. package/dist/adapters/lambda-runtime/nextjs-cache.js +174 -0
  30. package/dist/adapters/nextjs.d.ts +12 -0
  31. package/dist/adapters/nextjs.js +67 -0
  32. package/dist/adapters/nitro.d.ts +8 -0
  33. package/dist/adapters/nitro.js +193 -0
  34. package/dist/adapters/secret-files.d.ts +25 -0
  35. package/dist/adapters/secret-files.js +50 -0
  36. package/dist/adapters/types.d.ts +42 -0
  37. package/dist/adapters/types.js +1 -0
  38. package/dist/{utils/adapters → adapters}/vite.d.ts +2 -2
  39. package/dist/adapters/vite.js +33 -0
  40. package/dist/api/check-project-subdomain-availability.d.ts +12 -0
  41. package/dist/api/check-project-subdomain-availability.js +32 -0
  42. package/dist/api/control-plane-error.d.ts +6 -0
  43. package/dist/api/control-plane-error.js +8 -0
  44. package/dist/api/control-plane-fetch.d.ts +7 -0
  45. package/dist/api/control-plane-fetch.js +37 -0
  46. package/dist/api/control-plane.d.ts +1 -9
  47. package/dist/api/control-plane.js +2 -48
  48. package/dist/api/create-project.d.ts +18 -0
  49. package/dist/api/create-project.js +37 -0
  50. package/dist/api/list-project-workspaces.d.ts +8 -0
  51. package/dist/api/list-project-workspaces.js +28 -0
  52. package/dist/api/project-resource-type.d.ts +1 -0
  53. package/dist/api/project-resource-type.js +1 -0
  54. package/dist/auth/headless-oauth-flow.d.ts +23 -0
  55. package/dist/auth/headless-oauth-flow.js +69 -0
  56. package/dist/auth/oauth-flow.d.ts +2 -0
  57. package/dist/auth/oauth-flow.js +13 -8
  58. package/dist/auth/token-store.d.ts +4 -1
  59. package/dist/auth/token-store.js +14 -0
  60. package/dist/auth/types.d.ts +12 -0
  61. package/dist/cli.d.ts +39 -0
  62. package/dist/cli.js +71 -36
  63. package/dist/commands/bootstrap.js +2 -1
  64. package/dist/commands/build-lambda-zip.js +1 -1
  65. package/dist/commands/deploy.d.ts +12 -0
  66. package/dist/commands/deploy.js +63 -25
  67. package/dist/commands/detect-project-resource-type.d.ts +3 -0
  68. package/dist/commands/detect-project-resource-type.js +28 -0
  69. package/dist/commands/init.d.ts +2 -2
  70. package/dist/commands/init.js +164 -79
  71. package/dist/commands/login.d.ts +11 -1
  72. package/dist/commands/login.js +66 -4
  73. package/dist/commands/prompt-to-create-project/format-project-subdomain.d.ts +1 -0
  74. package/dist/commands/prompt-to-create-project/format-project-subdomain.js +3 -0
  75. package/dist/commands/prompt-to-create-project/format-unavailable-subdomain-reason.d.ts +1 -0
  76. package/dist/commands/prompt-to-create-project/format-unavailable-subdomain-reason.js +7 -0
  77. package/dist/commands/prompt-to-create-project/get-default-project-name.d.ts +1 -0
  78. package/dist/commands/prompt-to-create-project/get-default-project-name.js +13 -0
  79. package/dist/commands/prompt-to-create-project/prompt-for-available-subdomain.d.ts +7 -0
  80. package/dist/commands/prompt-to-create-project/prompt-for-available-subdomain.js +32 -0
  81. package/dist/commands/prompt-to-create-project/resolve-project-region.d.ts +8 -0
  82. package/dist/commands/prompt-to-create-project/resolve-project-region.js +27 -0
  83. package/dist/commands/prompt-to-create-project/resolve-project-subdomain.d.ts +9 -0
  84. package/dist/commands/prompt-to-create-project/resolve-project-subdomain.js +54 -0
  85. package/dist/commands/prompt-to-create-project/resolve-text-input.d.ts +9 -0
  86. package/dist/commands/prompt-to-create-project/resolve-text-input.js +23 -0
  87. package/dist/commands/prompt-to-create-project/resolve-workspace-plan-key.d.ts +12 -0
  88. package/dist/commands/prompt-to-create-project/resolve-workspace-plan-key.js +36 -0
  89. package/dist/commands/prompt-to-create-project/validate-subdomain.d.ts +1 -0
  90. package/dist/commands/prompt-to-create-project/validate-subdomain.js +9 -0
  91. package/dist/commands/prompt-to-create-project.d.ts +24 -0
  92. package/dist/commands/prompt-to-create-project.js +69 -0
  93. package/dist/commands/setup-agent.d.ts +12 -0
  94. package/dist/commands/setup-agent.js +123 -0
  95. package/dist/commands/write-project-configuration.d.ts +12 -0
  96. package/dist/commands/write-project-configuration.js +16 -0
  97. package/dist/db-content-api/generated/content-api-types.d.ts +6 -2
  98. package/dist/db-content-api/index.d.ts +1 -1
  99. package/dist/db-content-api/index.js +121 -72
  100. package/dist/db-content-api/utilities/data/index.js +2 -2
  101. package/dist/db-content-api/utilities/data/injectGlobalType.d.ts +6 -0
  102. package/dist/db-content-api/utilities/data/injectGlobalType.js +11 -0
  103. package/dist/db-content-api/utilities/data/removeVirtualFields.d.ts +3 -11
  104. package/dist/db-content-api/utilities/data/removeVirtualFields.js +12 -50
  105. package/dist/db-content-api/utilities/isRecord.d.ts +9 -0
  106. package/dist/db-content-api/utilities/isRecord.js +19 -0
  107. package/dist/db-content-api/utilities/joins.js +5 -1
  108. package/dist/db-content-api/utilities/meta/resolvesToRelationshipValue.d.ts +10 -0
  109. package/dist/db-content-api/utilities/meta/resolvesToRelationshipValue.js +95 -0
  110. package/dist/db-content-api/utilities/meta/stringifyIdsInWhere.d.ts +9 -0
  111. package/dist/db-content-api/utilities/meta/stringifyIdsInWhere.js +112 -0
  112. package/dist/db-content-api/utilities/schema/getDocumentSchema.d.ts +3 -0
  113. package/dist/db-content-api/utilities/schema/getDocumentSchema.js +24 -0
  114. package/dist/db-content-api/utilities/where.d.ts +2 -6
  115. package/dist/db-content-api/utilities/where.js +20 -9
  116. package/dist/exports/client.d.ts +2 -0
  117. package/dist/exports/client.js +2 -0
  118. package/dist/exports/views.d.ts +1 -0
  119. package/dist/exports/views.js +1 -0
  120. package/dist/imageSizeOptions.d.ts +23 -0
  121. package/dist/imageSizeOptions.js +26 -0
  122. package/dist/index.d.ts +2 -0
  123. package/dist/index.js +2 -0
  124. package/dist/lib/write-agent-config.d.ts +12 -0
  125. package/dist/lib/write-agent-config.js +52 -0
  126. package/dist/next/image-loader.d.ts +6 -0
  127. package/dist/next/image-loader.js +14 -0
  128. package/dist/oauth/components/LoginButton/index.js +66 -19
  129. package/dist/oauth/components/LoginButton/index.scss +121 -15
  130. package/dist/oauth/defaults.js +4 -1
  131. package/dist/oauth/endpoints/getLoginEndpoint.js +5 -2
  132. package/dist/oauth/index.js +8 -7
  133. package/dist/oauth/utilities/getAdminCollectionSlug.d.ts +1 -1
  134. package/dist/oauth/utilities/getAuthorizeURL.d.ts +1 -0
  135. package/dist/oauth/utilities/getAuthorizeURL.js +5 -1
  136. package/dist/plugin/build-config.d.ts +4 -2
  137. package/dist/plugin/build-config.js +95 -31
  138. package/dist/plugin/cache-revalidation-hooks.d.ts +6 -0
  139. package/dist/plugin/cache-revalidation-hooks.js +69 -0
  140. package/dist/plugin/cloud-limits/CloudLimitModal/index.d.ts +8 -0
  141. package/dist/plugin/cloud-limits/CloudLimitModal/index.js +66 -0
  142. package/dist/plugin/cloud-limits/CloudLimitModal/index.scss +56 -0
  143. package/dist/plugin/cloud-limits/CloudLimitProvider/index.d.ts +4 -0
  144. package/dist/plugin/cloud-limits/CloudLimitProvider/index.js +110 -0
  145. package/dist/plugin/cloud-limits/LimitReachedView/index.css +14 -0
  146. package/dist/plugin/cloud-limits/LimitReachedView/index.d.ts +4 -0
  147. package/dist/plugin/cloud-limits/LimitReachedView/index.js +52 -0
  148. package/dist/plugin/cloud-limits/SlugRegistryContext/index.d.ts +7 -0
  149. package/dist/plugin/cloud-limits/SlugRegistryContext/index.js +3 -0
  150. package/dist/plugin/cloud-limits/SlugTracker/index.d.ts +1 -0
  151. package/dist/plugin/cloud-limits/SlugTracker/index.js +27 -0
  152. package/dist/plugin/cloud-limits/icons/ExternalLinkIcon.d.ts +2 -0
  153. package/dist/plugin/cloud-limits/icons/ExternalLinkIcon.js +30 -0
  154. package/dist/plugin/cloud-limits/routes.d.ts +2 -0
  155. package/dist/plugin/cloud-limits/routes.js +4 -0
  156. package/dist/plugin/cloud-limits/server/redirectInitialAutosaveCreate.d.ts +9 -0
  157. package/dist/plugin/cloud-limits/server/redirectInitialAutosaveCreate.js +28 -0
  158. package/dist/plugin/cloud-limits/shared.d.ts +10 -0
  159. package/dist/plugin/cloud-limits/shared.js +52 -0
  160. package/dist/plugin/cloud-limits/utilities/cloudLimitInterceptor.d.ts +2 -0
  161. package/dist/plugin/cloud-limits/utilities/cloudLimitInterceptor.js +134 -0
  162. package/dist/plugin/cloud-limits/utilities/toasts.d.ts +4 -0
  163. package/dist/plugin/cloud-limits/utilities/toasts.js +19 -0
  164. package/dist/plugin/make-permission-access/make-permission-access.d.ts +8 -0
  165. package/dist/plugin/make-permission-access/make-permission-access.js +24 -0
  166. package/dist/plugin/sandbox-upload-fetch.d.ts +32 -0
  167. package/dist/plugin/sandbox-upload-fetch.js +53 -0
  168. package/dist/skills/deploy-to-figma/SKILL.md +234 -0
  169. package/dist/skills/deploy-to-figma/references/cli-reference.md +146 -0
  170. package/dist/storage-content-api/client-uploads/generate.js +2 -1
  171. package/dist/storage-content-api/getDownloadResponseHeaderPolicy.d.ts +11 -0
  172. package/dist/storage-content-api/getDownloadResponseHeaderPolicy.js +27 -0
  173. package/dist/storage-content-api/index.js +1 -0
  174. package/dist/storage-content-api/resolveDownloadResponseHeaders.d.ts +5 -0
  175. package/dist/storage-content-api/resolveDownloadResponseHeaders.js +13 -0
  176. package/dist/storage-content-api/staticHandler.js +2 -1
  177. package/dist/storage-content-api/types.d.ts +4 -1
  178. package/dist/translations/ar.d.ts +12 -0
  179. package/dist/translations/ar.js +12 -0
  180. package/dist/translations/az.d.ts +12 -0
  181. package/dist/translations/az.js +12 -0
  182. package/dist/translations/bg.d.ts +12 -0
  183. package/dist/translations/bg.js +12 -0
  184. package/dist/translations/bnBd.d.ts +12 -0
  185. package/dist/translations/bnBd.js +12 -0
  186. package/dist/translations/bnIn.d.ts +12 -0
  187. package/dist/translations/bnIn.js +12 -0
  188. package/dist/translations/ca.d.ts +12 -0
  189. package/dist/translations/ca.js +12 -0
  190. package/dist/translations/cs.d.ts +12 -0
  191. package/dist/translations/cs.js +12 -0
  192. package/dist/translations/da.d.ts +12 -0
  193. package/dist/translations/da.js +12 -0
  194. package/dist/translations/de.d.ts +12 -0
  195. package/dist/translations/de.js +12 -0
  196. package/dist/translations/en.d.ts +12 -0
  197. package/dist/translations/en.js +12 -0
  198. package/dist/translations/es.d.ts +12 -0
  199. package/dist/translations/es.js +12 -0
  200. package/dist/translations/et.d.ts +12 -0
  201. package/dist/translations/et.js +12 -0
  202. package/dist/translations/fa.d.ts +12 -0
  203. package/dist/translations/fa.js +12 -0
  204. package/dist/translations/fr.d.ts +12 -0
  205. package/dist/translations/fr.js +12 -0
  206. package/dist/translations/he.d.ts +12 -0
  207. package/dist/translations/he.js +12 -0
  208. package/dist/translations/hr.d.ts +12 -0
  209. package/dist/translations/hr.js +12 -0
  210. package/dist/translations/hu.d.ts +12 -0
  211. package/dist/translations/hu.js +12 -0
  212. package/dist/translations/hy.d.ts +12 -0
  213. package/dist/translations/hy.js +12 -0
  214. package/dist/translations/id.d.ts +12 -0
  215. package/dist/translations/id.js +12 -0
  216. package/dist/translations/index.d.ts +533 -0
  217. package/dist/translations/index.js +90 -0
  218. package/dist/translations/is.d.ts +12 -0
  219. package/dist/translations/is.js +12 -0
  220. package/dist/translations/it.d.ts +12 -0
  221. package/dist/translations/it.js +12 -0
  222. package/dist/translations/ja.d.ts +12 -0
  223. package/dist/translations/ja.js +12 -0
  224. package/dist/translations/ko.d.ts +12 -0
  225. package/dist/translations/ko.js +12 -0
  226. package/dist/translations/lt.d.ts +12 -0
  227. package/dist/translations/lt.js +12 -0
  228. package/dist/translations/lv.d.ts +12 -0
  229. package/dist/translations/lv.js +12 -0
  230. package/dist/translations/my.d.ts +12 -0
  231. package/dist/translations/my.js +12 -0
  232. package/dist/translations/nb.d.ts +12 -0
  233. package/dist/translations/nb.js +12 -0
  234. package/dist/translations/nl.d.ts +12 -0
  235. package/dist/translations/nl.js +12 -0
  236. package/dist/translations/pl.d.ts +12 -0
  237. package/dist/translations/pl.js +12 -0
  238. package/dist/translations/pt.d.ts +12 -0
  239. package/dist/translations/pt.js +12 -0
  240. package/dist/translations/ro.d.ts +12 -0
  241. package/dist/translations/ro.js +12 -0
  242. package/dist/translations/rs.d.ts +12 -0
  243. package/dist/translations/rs.js +12 -0
  244. package/dist/translations/rsLatin.d.ts +12 -0
  245. package/dist/translations/rsLatin.js +12 -0
  246. package/dist/translations/ru.d.ts +12 -0
  247. package/dist/translations/ru.js +12 -0
  248. package/dist/translations/sk.d.ts +12 -0
  249. package/dist/translations/sk.js +12 -0
  250. package/dist/translations/sl.d.ts +12 -0
  251. package/dist/translations/sl.js +12 -0
  252. package/dist/translations/sv.d.ts +12 -0
  253. package/dist/translations/sv.js +12 -0
  254. package/dist/translations/ta.d.ts +12 -0
  255. package/dist/translations/ta.js +12 -0
  256. package/dist/translations/th.d.ts +12 -0
  257. package/dist/translations/th.js +12 -0
  258. package/dist/translations/tr.d.ts +12 -0
  259. package/dist/translations/tr.js +12 -0
  260. package/dist/translations/uk.d.ts +12 -0
  261. package/dist/translations/uk.js +12 -0
  262. package/dist/translations/vi.d.ts +12 -0
  263. package/dist/translations/vi.js +12 -0
  264. package/dist/translations/zh.d.ts +12 -0
  265. package/dist/translations/zh.js +12 -0
  266. package/dist/translations/zhTw.d.ts +12 -0
  267. package/dist/translations/zhTw.js +12 -0
  268. package/dist/types.d.ts +11 -0
  269. package/dist/utils/assert-never.d.ts +1 -0
  270. package/dist/utils/assert-never.js +3 -0
  271. package/dist/utils/build-detection.d.ts +6 -1
  272. package/dist/utils/build-detection.js +68 -89
  273. package/dist/utils/deploy-adapter.d.ts +3 -35
  274. package/dist/utils/deploy-adapter.js +25 -14
  275. package/dist/utils/lambda-config.js +18 -23
  276. package/dist/utils/messages.js +24 -3
  277. package/dist/utils/next-image-loader-config.d.ts +2 -0
  278. package/dist/utils/next-image-loader-config.js +63 -0
  279. package/dist/utils/next-image-loader-file.d.ts +2 -0
  280. package/dist/utils/next-image-loader-file.js +11 -0
  281. package/dist/utils/payload-generate.d.ts +10 -0
  282. package/dist/utils/payload-generate.js +59 -0
  283. package/dist/utils/pnpm-builds.d.ts +14 -0
  284. package/dist/utils/pnpm-builds.js +125 -0
  285. package/dist/utils/s3-upload.js +4 -1
  286. package/package.json +31 -7
  287. package/dist/lib/download-skill.d.ts +0 -12
  288. package/dist/lib/download-skill.js +0 -77
  289. package/dist/utils/adapters/nextjs.d.ts +0 -8
  290. package/dist/utils/adapters/nextjs.js +0 -61
  291. package/dist/utils/adapters/nitro.d.ts +0 -8
  292. package/dist/utils/adapters/nitro.js +0 -172
  293. package/dist/utils/adapters/vite.js +0 -31
  294. package/dist/utils/asset-collection.js +0 -144
  295. package/dist/utils/build-lambda-zip.js +0 -90
  296. package/dist/utils/fs-utils.d.ts +0 -12
  297. package/dist/utils/fs-utils.js +0 -55
@@ -1,19 +1,21 @@
1
1
  import createClient from 'openapi-fetch';
2
- import { APIError, createDatabaseAdapter } from 'payload';
2
+ import { APIError, createDatabaseAdapter, ValidationError } from 'payload';
3
3
  import { v4 as uuid } from 'uuid';
4
4
  import { FigmaApiError } from '../api/figma-api.js';
5
5
  import { CONTENT_SYSTEM_NOT_FOUND_MESSAGE } from '../constants.js';
6
+ import { redirectInitialAutosaveCreate } from '../plugin/cloud-limits/server/redirectInitialAutosaveCreate.js';
6
7
  import { getGlobalSlug } from './temp-utilities/slug.js';
7
8
  import { addFallbackSort } from './temp-utilities/sorting.js';
8
9
  import { unwrapDocument, unwrapFindResponse } from './temp-utilities/unwrapDocument.js';
9
10
  import { createAuthMiddleware, createErrorMiddleware } from './utilities/auth.js';
10
11
  import { getClientVersionHeaders } from './utilities/clientVersionHeaders.js';
11
12
  import { dataToContentAPI, resolveVersionContent } from './utilities/data/index.js';
13
+ import { injectGlobalType } from './utilities/data/injectGlobalType.js';
12
14
  import { validateRelationshipIds } from './utilities/data/validateRelationships.js';
13
15
  import { convertPayloadJoinsToContentAPI } from './utilities/joins.js';
14
16
  import { addFallbackLocale } from './utilities/locale/index.js';
15
17
  import { normalizeLocaleInWhere } from './utilities/meta/normalizeLocaleInWhere.js';
16
- import { buildDocumentSchema } from './utilities/schema/buildDocumentSchema.js';
18
+ import { getDocumentSchema } from './utilities/schema/getDocumentSchema.js';
17
19
  import { convertPayloadWhereToContentAPI } from './utilities/where.js';
18
20
  /**
19
21
  * Heads-up logged locally whenever a job is queued. Queued jobs are executed by Figma's deployed runner, so
@@ -109,7 +111,7 @@ async function createCollection(collectionId) {
109
111
  }
110
112
  });
111
113
  if (error) {
112
- throw createContentAPIError('createCollection', error, httpResponse.status);
114
+ throw createDocumentContentAPIError(this, 'createCollection', error, httpResponse.status, collectionId);
113
115
  }
114
116
  this.payload.logger.info(`Created collection: ${collectionId}`);
115
117
  } catch (error) {
@@ -121,7 +123,7 @@ async function createCollection(collectionId) {
121
123
  }
122
124
  async function findMany({ collection, joins, limit, locale: localeArg, page, pagination: _pagination, sort, where }) {
123
125
  const locale = addFallbackLocale(localeArg, this.payload);
124
- const normalizedWhere = normalizeLocaleInWhere(where, this.payload, collection, locale);
126
+ const localeNormalizedWhere = normalizeLocaleInWhere(where, this.payload, collection, locale);
125
127
  const joinClause = convertPayloadJoinsToContentAPI(this.payload, collection, joins);
126
128
  const { data: response, error, response: httpResponse } = await this.client.POST('/api/v1/documents:find', {
127
129
  body: {
@@ -131,13 +133,13 @@ async function findMany({ collection, joins, limit, locale: localeArg, page, pag
131
133
  limit,
132
134
  locale,
133
135
  page: page ?? 1,
134
- schema: this.documentSchema,
136
+ schema: this.documentSchema(),
135
137
  sort: addFallbackSort(sort, this.payload, collection),
136
- where: convertPayloadWhereToContentAPI(normalizedWhere ?? {})
138
+ where: convertPayloadWhereToContentAPI(localeNormalizedWhere, this.payload, collection, false)
137
139
  }
138
140
  });
139
141
  if (error) {
140
- throw createContentAPIError('findMany', error, httpResponse.status);
142
+ throw createDocumentContentAPIError(this, 'findMany', error, httpResponse.status, collection);
141
143
  }
142
144
  if (!response) {
143
145
  throw new Error('No response from findMany');
@@ -165,7 +167,7 @@ async function find(args) {
165
167
  // TODO: remove Omit when this PR is released: https://github.com/payloadcms/payload/pull/15183
166
168
  async function findVersions(args) {
167
169
  const sortWithFallback = addFallbackSort(args.sort || '-updatedAt', this.payload, args.collection);
168
- const whereClause = convertPayloadWhereToContentAPI(args.where ?? {});
170
+ const whereClause = convertPayloadWhereToContentAPI(args.where, this.payload, args.collection, true);
169
171
  const locale = addFallbackLocale(args.locale, this.payload);
170
172
  const { data: response, error, response: httpResponse } = await this.client.POST('/api/v1/document_versions:find', {
171
173
  body: {
@@ -176,13 +178,13 @@ async function findVersions(args) {
176
178
  limit: args.limit,
177
179
  locale,
178
180
  page: args.page ?? 1,
179
- schema: this.documentSchema,
181
+ schema: this.documentSchema(),
180
182
  sort: sortWithFallback,
181
183
  where: whereClause
182
184
  }
183
185
  });
184
186
  if (error) {
185
- throw createContentAPIError('findVersions', error, httpResponse.status);
187
+ throw createDocumentContentAPIError(this, 'findVersions', error, httpResponse.status, args.collection);
186
188
  }
187
189
  if (!response) {
188
190
  throw new Error('No response from findVersions');
@@ -230,7 +232,7 @@ async function createVersion(args) {
230
232
  body: {
231
233
  collection: args.collectionSlug,
232
234
  contentSystemId: this.contentSystemId,
233
- schema: this.documentSchema,
235
+ schema: this.documentSchema(),
234
236
  versionDoc: {
235
237
  createdAt: args.createdAt,
236
238
  latest: true,
@@ -241,7 +243,7 @@ async function createVersion(args) {
241
243
  }
242
244
  });
243
245
  if (error) {
244
- throw createContentAPIError('createVersion', error, httpResponse.status);
246
+ throw createDocumentContentAPIError(this, 'createVersion', error, httpResponse.status, args.collectionSlug);
245
247
  }
246
248
  if (!response) {
247
249
  throw new Error('No response from createVersion');
@@ -272,7 +274,7 @@ async function updateVersion(args) {
272
274
  contentSystemId: this.contentSystemId,
273
275
  createOnMissing: false,
274
276
  locale,
275
- schema: this.documentSchema,
277
+ schema: this.documentSchema(),
276
278
  versionDoc: {
277
279
  createdAt: versionMeta.createdAt,
278
280
  latest: versionMeta.latest,
@@ -280,11 +282,11 @@ async function updateVersion(args) {
280
282
  updatedAt: versionMeta.updatedAt,
281
283
  version: versionContent
282
284
  },
283
- where: convertPayloadWhereToContentAPI(where)
285
+ where: convertPayloadWhereToContentAPI(where, this.payload, args.collection, true)
284
286
  }
285
287
  });
286
288
  if (error) {
287
- throw createContentAPIError('updateVersion', error, httpResponse.status);
289
+ throw createDocumentContentAPIError(this, 'updateVersion', error, httpResponse.status, args.collection);
288
290
  }
289
291
  if (!response?.result || !('data' in response.result)) {
290
292
  throw new Error('No document data in updateVersion response');
@@ -301,21 +303,25 @@ async function updateVersion(args) {
301
303
  });
302
304
  }
303
305
  async function deleteVersions(args) {
304
- if (!args.collection) {
305
- throw new Error('deleteVersions requires a collection');
306
+ // Globals are addressed by `globalSlug` and map to the `_global-<slug>` collection.
307
+ // Only one of `collection`/`globalSlug` is set.
308
+ const globalSlug = args.globalSlug != null ? getGlobalSlug(args.globalSlug) : undefined;
309
+ const collection = args.collection ?? globalSlug;
310
+ if (collection == null) {
311
+ throw new Error('deleteVersions requires a collection or globalSlug');
306
312
  }
307
313
  const locale = addFallbackLocale(args.locale, this.payload);
308
314
  const { error, response: httpResponse } = await this.client.POST('/api/v1/document_versions:delete', {
309
315
  body: {
310
- collection: args.collection,
316
+ collection,
311
317
  contentSystemId: this.contentSystemId,
312
318
  locale,
313
- schema: this.documentSchema,
314
- where: convertPayloadWhereToContentAPI(args.where)
319
+ schema: this.documentSchema(),
320
+ where: convertPayloadWhereToContentAPI(args.where, this.payload, collection, true)
315
321
  }
316
322
  });
317
323
  if (error) {
318
- throw createContentAPIError('deleteVersions', error, httpResponse.status);
324
+ throw createDocumentContentAPIError(this, 'deleteVersions', error, httpResponse.status, collection);
319
325
  }
320
326
  }
321
327
  async function findOne(args) {
@@ -339,13 +345,13 @@ async function findDistinct(args) {
339
345
  limit: args.limit,
340
346
  locale,
341
347
  page: args.page ?? 1,
342
- schema: this.documentSchema,
348
+ schema: this.documentSchema(),
343
349
  sort: addFallbackSort(args.sort, this.payload, args.collection),
344
- where: convertPayloadWhereToContentAPI(args.where ?? {})
350
+ where: convertPayloadWhereToContentAPI(args.where, this.payload, args.collection, false)
345
351
  }
346
352
  });
347
353
  if (error) {
348
- throw createContentAPIError('findDistinct', error, httpResponse.status);
354
+ throw createDocumentContentAPIError(this, 'findDistinct', error, httpResponse.status, args.collection);
349
355
  }
350
356
  const { data, ...pagination } = response.result;
351
357
  return {
@@ -372,13 +378,13 @@ async function updateMany(args) {
372
378
  environmentName: this.environmentName,
373
379
  limit: args.limit,
374
380
  locale,
375
- schema: this.documentSchema,
381
+ schema: this.documentSchema(),
376
382
  sort: addFallbackSort(args.sort || '-updatedAt', this.payload, args.collection),
377
- where: convertPayloadWhereToContentAPI(args.where)
383
+ where: convertPayloadWhereToContentAPI(args.where, this.payload, args.collection, false)
378
384
  }
379
385
  });
380
386
  if (error) {
381
- throw createContentAPIError('updateMany', error, httpResponse.status);
387
+ throw createDocumentContentAPIError(this, 'updateMany', error, httpResponse.status, args.collection);
382
388
  }
383
389
  if (!contentAPIResponse) {
384
390
  throw new Error('No response from updateMany');
@@ -413,12 +419,12 @@ async function updateOne(args) {
413
419
  doc: dataToContentAPI(this.payload, args.collection, args.data),
414
420
  environmentName: this.environmentName,
415
421
  locale,
416
- schema: this.documentSchema,
417
- where: convertPayloadWhereToContentAPI(where)
422
+ schema: this.documentSchema(),
423
+ where: convertPayloadWhereToContentAPI(where, this.payload, args.collection, false)
418
424
  }
419
425
  });
420
426
  if (error) {
421
- throw createContentAPIError('updateOne', error, httpResponse.status);
427
+ throw createDocumentContentAPIError(this, 'updateOne', error, httpResponse.status, args.collection);
422
428
  }
423
429
  if (!contentAPIResponse) {
424
430
  throw new Error('No response from updateOne');
@@ -445,12 +451,12 @@ async function deleteMany(args) {
445
451
  contentSystemId: this.contentSystemId,
446
452
  environmentName: this.environmentName,
447
453
  locale,
448
- schema: this.documentSchema,
449
- where: convertPayloadWhereToContentAPI(args.where)
454
+ schema: this.documentSchema(),
455
+ where: convertPayloadWhereToContentAPI(args.where, this.payload, args.collection, false)
450
456
  }
451
457
  });
452
458
  if (error) {
453
- throw createContentAPIError('deleteMany', error, httpResponse.status);
459
+ throw createDocumentContentAPIError(this, 'deleteMany', error, httpResponse.status, args.collection);
454
460
  }
455
461
  }
456
462
  async function deleteOne(args) {
@@ -461,12 +467,12 @@ async function deleteOne(args) {
461
467
  contentSystemId: this.contentSystemId,
462
468
  environmentName: this.environmentName,
463
469
  locale,
464
- schema: this.documentSchema,
465
- where: convertPayloadWhereToContentAPI(args.where)
470
+ schema: this.documentSchema(),
471
+ where: convertPayloadWhereToContentAPI(args.where, this.payload, args.collection, false)
466
472
  }
467
473
  });
468
474
  if (error) {
469
- throw createContentAPIError('deleteOne', error, httpResponse.status);
475
+ throw createDocumentContentAPIError(this, 'deleteOne', error, httpResponse.status, args.collection);
470
476
  }
471
477
  if (!response?.result || !('data' in response.result)) {
472
478
  throw new Error('No document data in deleteOne response');
@@ -516,11 +522,17 @@ async function create(args) {
516
522
  },
517
523
  environmentName: this.environmentName,
518
524
  locale,
519
- schema: this.documentSchema
525
+ schema: this.documentSchema()
520
526
  }
521
527
  });
522
528
  if (error) {
523
- throw createContentAPIError('create', error, httpResponse.status);
529
+ redirectInitialAutosaveCreate({
530
+ collectionSlug: args.collection,
531
+ errorCode: error.code,
532
+ payload: this.payload,
533
+ req: args.req
534
+ });
535
+ throw createDocumentContentAPIError(this, 'create', error, httpResponse.status, args.collection);
524
536
  }
525
537
  if (!contentAPIResponse) {
526
538
  throw new Error('No response from create');
@@ -568,12 +580,12 @@ async function count(args) {
568
580
  collection: args.collection,
569
581
  contentSystemId: this.contentSystemId,
570
582
  locale,
571
- schema: this.documentSchema,
572
- where: convertPayloadWhereToContentAPI(args.where)
583
+ schema: this.documentSchema(),
584
+ where: convertPayloadWhereToContentAPI(args.where, this.payload, args.collection, false)
573
585
  }
574
586
  });
575
587
  if (error) {
576
- throw createContentAPIError('count', error, httpResponse.status);
588
+ throw createDocumentContentAPIError(this, 'count', error, httpResponse.status, args.collection);
577
589
  }
578
590
  if (!response) {
579
591
  throw new Error('No response from count');
@@ -589,12 +601,12 @@ async function countVersions(args) {
589
601
  collection: args.collection,
590
602
  contentSystemId: this.contentSystemId,
591
603
  locale,
592
- schema: this.documentSchema,
593
- where: convertPayloadWhereToContentAPI(args.where)
604
+ schema: this.documentSchema(),
605
+ where: convertPayloadWhereToContentAPI(args.where, this.payload, args.collection, true)
594
606
  }
595
607
  });
596
608
  if (error) {
597
- throw createContentAPIError('countVersions', error, httpResponse.status);
609
+ throw createDocumentContentAPIError(this, 'countVersions', error, httpResponse.status, args.collection);
598
610
  }
599
611
  if (!response) {
600
612
  throw new Error('No response from countVersions');
@@ -603,12 +615,19 @@ async function countVersions(args) {
603
615
  totalDocs: response.result.count
604
616
  };
605
617
  }
618
+ // Content API document ids are text. A document id is only ever a string or a number
619
+ // (a custom numeric id), so coerce those to a string and treat anything else as absent.
620
+ function toIdString(value) {
621
+ return typeof value === 'string' || typeof value === 'number' ? String(value) : undefined;
622
+ }
606
623
  async function upsert(args) {
607
- let documentId = args.data.id;
624
+ // The Content API stores every document id as text; a custom numeric id arrives as a
625
+ // number, so coerce it (matching `create`) before it becomes `createOnMissing.id`.
626
+ let documentId = toIdString(args.data.id);
608
627
  if (!documentId && args.where && 'id' in args.where) {
609
628
  const idClause = args.where.id;
610
- if (idClause && 'equals' in idClause) {
611
- documentId = idClause.equals;
629
+ if (idClause) {
630
+ documentId = toIdString(idClause.equals);
612
631
  }
613
632
  }
614
633
  if (!documentId) {
@@ -620,25 +639,31 @@ async function upsert(args) {
620
639
  data: args.data,
621
640
  payload: this.payload
622
641
  });
642
+ // `createdAt` is create-time metadata, so seed it on `createOnMissing` (used only when no
643
+ // document matches) rather than on `doc`. The server preserves an existing document's
644
+ // `createdAt` on update precisely because `doc` omits it; `updatedAt` is still refreshed on
645
+ // every write via `dataToContentAPI`. Sending `createdAt` on `doc` would overwrite it on
646
+ // every update (e.g. repeated `updateGlobal` calls).
647
+ const createdAt = new Date().toISOString();
623
648
  const { data: contentAPIResponse, error, response: httpResponse } = await this.client.POST('/api/v1/documents:update', {
624
649
  body: {
625
650
  collection: args.collection,
626
651
  contentSystemId: this.contentSystemId,
627
652
  createOnMissing: {
628
- id: documentId
653
+ id: documentId,
654
+ createdAt
629
655
  },
630
656
  doc: dataToContentAPI(this.payload, args.collection, args.data, {
631
- applyDefaults: true,
632
- createdAt: true
657
+ applyDefaults: true
633
658
  }),
634
659
  environmentName: this.environmentName,
635
660
  locale,
636
- schema: this.documentSchema,
637
- where: convertPayloadWhereToContentAPI(args.where)
661
+ schema: this.documentSchema(),
662
+ where: convertPayloadWhereToContentAPI(args.where, this.payload, args.collection, false)
638
663
  }
639
664
  });
640
665
  if (error) {
641
- throw createContentAPIError('upsert', error, httpResponse.status);
666
+ throw createDocumentContentAPIError(this, 'upsert', error, httpResponse.status, args.collection);
642
667
  }
643
668
  if (!contentAPIResponse) {
644
669
  throw new Error('No response from upsert');
@@ -658,6 +683,7 @@ async function upsert(args) {
658
683
  });
659
684
  }
660
685
  async function updateJobs(args) {
686
+ const collection = 'payload-jobs';
661
687
  const { id, limit, returning, sort, where } = args;
662
688
  if (id == null && where == null) {
663
689
  throw new Error('updateJobs requires either id or a where clause');
@@ -678,12 +704,12 @@ async function updateJobs(args) {
678
704
  equals: String(id)
679
705
  }
680
706
  } : where;
681
- const docData = dataToContentAPI(this.payload, 'payload-jobs', data);
682
- const sortClause = addFallbackSort(sort || '-updatedAt', this.payload, 'payload-jobs');
683
- const whereQuery = convertPayloadWhereToContentAPI(whereClause);
707
+ const docData = dataToContentAPI(this.payload, collection, data);
708
+ const sortClause = addFallbackSort(sort || '-updatedAt', this.payload, collection);
709
+ const whereQuery = convertPayloadWhereToContentAPI(whereClause, this.payload, collection, false);
684
710
  const { data: response, error, response: httpResponse } = await this.client.POST('/api/v1/documents:update', {
685
711
  body: {
686
- collection: 'payload-jobs',
712
+ collection,
687
713
  contentSystemId: this.contentSystemId,
688
714
  createOnMissing: false,
689
715
  doc: docData,
@@ -691,13 +717,13 @@ async function updateJobs(args) {
691
717
  ...limit != null && {
692
718
  limit
693
719
  },
694
- schema: this.documentSchema,
720
+ schema: this.documentSchema(),
695
721
  sort: sortClause,
696
722
  where: whereQuery
697
723
  }
698
724
  });
699
725
  if (error) {
700
- throw createContentAPIError('updateJobs', error, httpResponse.status);
726
+ throw createDocumentContentAPIError(this, 'updateJobs', error, httpResponse.status, collection);
701
727
  }
702
728
  if (!response) {
703
729
  throw new Error('No response from updateJobs');
@@ -709,18 +735,18 @@ async function updateJobs(args) {
709
735
  return [];
710
736
  }
711
737
  return response.result.data.map((doc)=>unwrapDocument({
712
- collectionSlug: 'payload-jobs',
738
+ collectionSlug: collection,
713
739
  doc,
714
740
  payload: this.payload
715
741
  }));
716
742
  }
717
- function createGlobal(args) {
743
+ async function createGlobal(args) {
718
744
  // Globals are singletons identified by their slug. Use upsert so concurrent calls
719
745
  // (e.g. handleSchedules processing multiple queueables with the same null jobStats)
720
746
  // don't fail with "A record with this field already exists". The deep-merge semantics
721
747
  // of the update path are safe here: callers that want a fresh create (first run) get
722
748
  // an effective create, and callers that race a prior create get a merge instead.
723
- return this.upsert({
749
+ const doc = await this.upsert({
724
750
  collection: getGlobalSlug(args.slug),
725
751
  data: {
726
752
  ...args.data,
@@ -732,6 +758,7 @@ function createGlobal(args) {
732
758
  }
733
759
  }
734
760
  });
761
+ return injectGlobalType(doc, args.slug);
735
762
  }
736
763
  async function findGlobal(args) {
737
764
  const doc = await this.findOne({
@@ -739,17 +766,10 @@ async function findGlobal(args) {
739
766
  locale: args.locale,
740
767
  where: args.where ?? {}
741
768
  });
742
- if (doc != null) {
743
- ;
744
- doc.globalType = args.slug;
745
- }
746
- return doc;
769
+ return injectGlobalType(doc, args.slug);
747
770
  }
748
771
  async function updateGlobal(args) {
749
- // TODO: upsert's `createOnMissing` path generates a new `createdAt` on every call,
750
- // which overwrites the original timestamp on updates. The fix belongs in the Content API:
751
- // `createOnMissing` should preserve `createdAt` on updates and only set it on creates.
752
- return this.upsert({
772
+ const doc = await this.upsert({
753
773
  collection: getGlobalSlug(args.slug),
754
774
  data: args.data,
755
775
  where: {
@@ -758,6 +778,7 @@ async function updateGlobal(args) {
758
778
  }
759
779
  }
760
780
  });
781
+ return injectGlobalType(doc, args.slug);
761
782
  }
762
783
  // TODO: remove Omit when this PR is released: https://github.com/payloadcms/payload/pull/15183
763
784
  function findGlobalVersions(args) {
@@ -809,6 +830,13 @@ function countGlobalVersions(args) {
809
830
  where: args.where
810
831
  });
811
832
  }
833
+ function createDocumentContentAPIError(adapter, operation, error, status, collectionSlug) {
834
+ const validationError = maybeCreateUniqueValidationError(error, collectionSlug, adapter);
835
+ if (validationError != null) {
836
+ return validationError;
837
+ }
838
+ return createContentAPIError(operation, error, status);
839
+ }
812
840
  function createContentAPIError(operation, error, status) {
813
841
  return new APIError(`Content API ${operation} error: ${error.message}`, status, {
814
842
  code: error.code,
@@ -816,6 +844,27 @@ function createContentAPIError(operation, error, status) {
816
844
  field: error.field
817
845
  });
818
846
  }
847
+ // A unique-constraint violation from the Content API is Payload's `ValidationError` contract:
848
+ // reconstruct it with the offending field path(s) so callers can map the error back to a field
849
+ // (matching what Payload's other database adapters throw). Falls back to a generic APIError when
850
+ // the collection or offending field is unknown.
851
+ function maybeCreateUniqueValidationError(error, collectionSlug, adapter) {
852
+ if (error.constraint !== 'unique_constraint') {
853
+ return null;
854
+ }
855
+ const paths = (error.field ?? '').split(',').map((path)=>path.trim()).filter((path)=>path.length > 0);
856
+ if (paths.length === 0) {
857
+ adapter.payload.logger.error(`Unique constraint violation but no offending field.`);
858
+ return null;
859
+ }
860
+ return new ValidationError({
861
+ collection: collectionSlug,
862
+ errors: paths.map((path)=>({
863
+ message: error.message,
864
+ path
865
+ }))
866
+ });
867
+ }
819
868
  export const contentAPIAdapter = (opts)=>({
820
869
  name: 'content-api',
821
870
  defaultIDType: 'text',
@@ -855,7 +904,7 @@ export const contentAPIAdapter = (opts)=>({
855
904
  deleteMany: deleteMany,
856
905
  deleteOne: deleteOne,
857
906
  deleteVersions: deleteVersions,
858
- documentSchema: buildDocumentSchema(payload.config),
907
+ documentSchema: ()=>getDocumentSchema(payload.config),
859
908
  environmentName: opts.environmentName,
860
909
  find: find,
861
910
  findDistinct: findDistinct,
@@ -112,7 +112,7 @@ import { transformToLocalizeStatus } from './transformPublishedLocale.js';
112
112
  'id'
113
113
  ]
114
114
  });
115
- removeVirtualFields(transformed, collectionConfig.fields);
115
+ removeVirtualFields(transformed, collectionConfig.fields, payload.config);
116
116
  // Convert numeric ID to string for Content API
117
117
  const customIDType = payload.collections?.[collectionSlug]?.customIDType;
118
118
  if (customIDType === 'number') {
@@ -295,7 +295,7 @@ export function dataFromContentAPI(payload, collectionSlug, data, locale) {
295
295
  ]
296
296
  });
297
297
  // Remove virtual fields - must happen AFTER stripFields
298
- removeVirtualFields(transformed, collectionConfig.fields);
298
+ removeVirtualFields(transformed, collectionConfig.fields, payload.config);
299
299
  // Handle auth-specific fields that aren't in the field schema
300
300
  // When these fields are null in DB, Content API omits them from response (undefined)
301
301
  // But Payload expects them to be null, not undefined
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Payload expects globals to carry a `globalType` (their slug) alongside the stored data.
3
+ * Globals are stored as `_global-<slug>` collections that have no such column, so the adapter
4
+ * attaches it to every global document it returns.
5
+ */
6
+ export declare function injectGlobalType<T>(doc: T, slug: string): T;
@@ -0,0 +1,11 @@
1
+ import { isRecord } from '../isRecord.js';
2
+ /**
3
+ * Payload expects globals to carry a `globalType` (their slug) alongside the stored data.
4
+ * Globals are stored as `_global-<slug>` collections that have no such column, so the adapter
5
+ * attaches it to every global document it returns.
6
+ */ export function injectGlobalType(doc, slug) {
7
+ return isRecord(doc) ? {
8
+ ...doc,
9
+ globalType: slug
10
+ } : doc;
11
+ }
@@ -1,11 +1,3 @@
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;
1
+ import type { Field, SanitizedConfig } from 'payload';
2
+ /** Remove pure virtual fields from document data at every schema depth. */
3
+ export declare function removeVirtualFields(data: Record<string, unknown>, fields: Field[], config: SanitizedConfig): void;
@@ -1,52 +1,14 @@
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);
1
+ import { traverseFields } from 'payload';
2
+ /** Remove pure virtual fields from document data at every schema depth. */ export function removeVirtualFields(data, fields, config) {
3
+ traverseFields({
4
+ callback: ({ field, ref })=>{
5
+ if ('name' in field && field.name && 'virtual' in field && field.virtual === true) {
6
+ delete ref[field.name];
16
7
  }
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
- }
8
+ },
9
+ config,
10
+ fields,
11
+ fillEmpty: false,
12
+ ref: data
13
+ });
52
14
  }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * A plain, string-keyed object — the shape that can safely be spread and have
3
+ * properties read off it without tripping over arrays, `null`, or exotic objects.
4
+ *
5
+ * Objects carrying symbol-keyed own properties are rejected: symbol keys are how
6
+ * libraries tag a value as something more than data, and a spread copies only the
7
+ * string keys, so treating such a value as a record silently strips the tag.
8
+ */
9
+ export declare function isRecord(value: unknown): value is Record<string, unknown>;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * A plain, string-keyed object — the shape that can safely be spread and have
3
+ * properties read off it without tripping over arrays, `null`, or exotic objects.
4
+ *
5
+ * Objects carrying symbol-keyed own properties are rejected: symbol keys are how
6
+ * libraries tag a value as something more than data, and a spread copies only the
7
+ * string keys, so treating such a value as a record silently strips the tag.
8
+ */ export function isRecord(value) {
9
+ if (value == null) {
10
+ return false;
11
+ }
12
+ if (typeof value !== 'object') {
13
+ return false;
14
+ }
15
+ if (Array.isArray(value)) {
16
+ return false;
17
+ }
18
+ return Object.getOwnPropertySymbols(value).length === 0;
19
+ }