@payloadcms/figma 0.0.1-alpha.42 → 0.0.1-alpha.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constants.d.ts +1 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +19 -4
- package/dist/constants.js.map +1 -1
- package/dist/db-content-api/generated/content-api-types.d.ts +3 -174
- package/dist/db-content-api/generated/content-api-types.d.ts.map +1 -1
- package/dist/db-content-api/generated/content-api-types.js.map +1 -1
- package/dist/db-content-api/index.d.ts.map +1 -1
- package/dist/db-content-api/index.js +56 -12
- package/dist/db-content-api/index.js.map +1 -1
- package/dist/db-content-api/utilities/data/castFieldValue.d.ts.map +1 -1
- package/dist/db-content-api/utilities/data/castFieldValue.js +4 -1
- package/dist/db-content-api/utilities/data/castFieldValue.js.map +1 -1
- package/dist/db-content-api/utilities/data/index.d.ts.map +1 -1
- package/dist/db-content-api/utilities/data/index.js +15 -2
- package/dist/db-content-api/utilities/data/index.js.map +1 -1
- package/dist/db-content-api/utilities/meta/buildLocalizedPaths.d.ts +11 -0
- package/dist/db-content-api/utilities/meta/buildLocalizedPaths.d.ts.map +1 -0
- package/dist/db-content-api/utilities/meta/buildLocalizedPaths.js +55 -0
- package/dist/db-content-api/utilities/meta/buildLocalizedPaths.js.map +1 -0
- package/dist/db-content-api/utilities/meta/buildMeta.d.ts +22 -0
- package/dist/db-content-api/utilities/meta/buildMeta.d.ts.map +1 -0
- package/dist/db-content-api/utilities/meta/buildMeta.js +30 -0
- package/dist/db-content-api/utilities/meta/buildMeta.js.map +1 -0
- package/dist/db-content-api/utilities/meta/buildPathTypes.d.ts +7 -0
- package/dist/db-content-api/utilities/meta/buildPathTypes.d.ts.map +1 -0
- package/dist/db-content-api/utilities/{buildPathTypes.js → meta/buildPathTypes.js} +3 -9
- package/dist/db-content-api/utilities/meta/buildPathTypes.js.map +1 -0
- package/dist/db-content-api/utilities/meta/index.d.ts +5 -0
- package/dist/db-content-api/utilities/meta/index.d.ts.map +1 -0
- package/dist/db-content-api/utilities/meta/index.js +5 -0
- package/dist/db-content-api/utilities/meta/index.js.map +1 -0
- package/dist/storage-content-api/client-uploads/ClientUploadHandler.d.ts.map +1 -1
- package/dist/storage-content-api/client-uploads/ClientUploadHandler.js +3 -3
- package/dist/storage-content-api/client-uploads/ClientUploadHandler.js.map +1 -1
- package/dist/storage-content-api/client-uploads/generateSignedURL.d.ts.map +1 -1
- package/dist/storage-content-api/client-uploads/generateSignedURL.js +8 -1
- package/dist/storage-content-api/client-uploads/generateSignedURL.js.map +1 -1
- package/dist/storage-content-api/utilities/getSafeFilename.d.ts +12 -0
- package/dist/storage-content-api/utilities/getSafeFilename.d.ts.map +1 -0
- package/dist/storage-content-api/utilities/getSafeFilename.js +61 -0
- package/dist/storage-content-api/utilities/getSafeFilename.js.map +1 -0
- package/dist/storage-content-api/utilities/index.d.ts +2 -0
- package/dist/storage-content-api/utilities/index.d.ts.map +1 -0
- package/dist/storage-content-api/utilities/index.js +3 -0
- package/dist/storage-content-api/utilities/index.js.map +1 -0
- package/dist/templates/.env.example +11 -0
- package/dist/utils/env-management.d.ts +9 -1
- package/dist/utils/env-management.d.ts.map +1 -1
- package/dist/utils/env-management.js +39 -17
- package/dist/utils/env-management.js.map +1 -1
- package/dist/utils/project.d.ts.map +1 -1
- package/dist/utils/project.js +3 -0
- package/dist/utils/project.js.map +1 -1
- package/package.json +2 -2
- package/dist/db-content-api/utilities/buildPathTypes.d.ts +0 -12
- package/dist/db-content-api/utilities/buildPathTypes.d.ts.map +0 -1
- package/dist/db-content-api/utilities/buildPathTypes.js.map +0 -1
|
@@ -5,9 +5,9 @@ import { getGlobalSlug } from './temp-utilities/slug.js';
|
|
|
5
5
|
import { addFallbackSort } from './temp-utilities/sorting.js';
|
|
6
6
|
import { unwrapDocument, unwrapFindResponse } from './temp-utilities/unwrapDocument.js';
|
|
7
7
|
import { createAuthMiddleware, createErrorMiddleware } from './utilities/auth.js';
|
|
8
|
-
import { buildPathTypes } from './utilities/buildPathTypes.js';
|
|
9
8
|
import { dataToContentAPI } from './utilities/data/index.js';
|
|
10
9
|
import { convertPayloadJoinsToContentAPI } from './utilities/joins.js';
|
|
10
|
+
import { buildMeta } from './utilities/meta/index.js';
|
|
11
11
|
import { convertPayloadWhereToContentAPI } from './utilities/where.js';
|
|
12
12
|
async function init() {
|
|
13
13
|
if (this.auth.mode === 'apiKey') {
|
|
@@ -90,17 +90,26 @@ async function createCollection(collectionId) {
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
|
-
async function findMany({ collection, joins, limit, page, pagination, sort, where }) {
|
|
93
|
+
async function findMany({ collection, joins, limit, locale, page, pagination, sort, where }) {
|
|
94
|
+
// Use provided locale or fall back to default locale from config
|
|
95
|
+
// 'all' is a special Payload value meaning "return all locales" - don't send to Content API
|
|
96
|
+
const localization = this.payload.config.localization;
|
|
97
|
+
const effectiveLocale = locale && locale !== 'all' ? locale : localization ? localization.defaultLocale : undefined;
|
|
94
98
|
const { data: response, error } = await this.client.POST('/api/v0/documents:find', {
|
|
95
99
|
body: {
|
|
96
100
|
collection,
|
|
97
101
|
contentSystemId: this.contentSystemId,
|
|
98
102
|
join: convertPayloadJoinsToContentAPI(this.payload, collection, joins),
|
|
99
103
|
limit,
|
|
104
|
+
locale: effectiveLocale && locale !== 'all' ? effectiveLocale : undefined,
|
|
100
105
|
page: page ?? 1,
|
|
101
106
|
sort: addFallbackSort(sort, this.payload, collection),
|
|
102
107
|
where: convertPayloadWhereToContentAPI(where ?? {}),
|
|
103
|
-
...
|
|
108
|
+
...buildMeta(this.payload, {
|
|
109
|
+
collection,
|
|
110
|
+
locale: effectiveLocale,
|
|
111
|
+
where
|
|
112
|
+
})
|
|
104
113
|
}
|
|
105
114
|
});
|
|
106
115
|
if (error) {
|
|
@@ -119,6 +128,7 @@ async function find(args) {
|
|
|
119
128
|
// TODO: FindArgs.limit should be 'number' not 'number | undefined'
|
|
120
129
|
// is sanitized by Payload Core before calling the adapter (defaults to 10 or 0 based on pagination)
|
|
121
130
|
limit: args.limit,
|
|
131
|
+
locale: args.locale,
|
|
122
132
|
page: args.page ?? 1,
|
|
123
133
|
pagination: args.pagination,
|
|
124
134
|
sort: args.sort || collectionConfig?.defaultSort,
|
|
@@ -131,6 +141,10 @@ async function findVersions(args) {
|
|
|
131
141
|
const whereClause = convertPayloadWhereToContentAPI(args.where ?? {}, {
|
|
132
142
|
parentToDocumentId: true
|
|
133
143
|
});
|
|
144
|
+
// Use provided locale or fall back to default locale from config
|
|
145
|
+
// 'all' is a special Payload value meaning "return all locales" - don't send to Content API
|
|
146
|
+
const localization = this.payload.config.localization;
|
|
147
|
+
const effectiveLocale = args.locale && args.locale !== 'all' ? args.locale : localization ? localization.defaultLocale : undefined;
|
|
134
148
|
const { data: response, error } = await this.client.POST('/api/v0/document_versions:find', {
|
|
135
149
|
body: {
|
|
136
150
|
collection: args.collection,
|
|
@@ -138,10 +152,15 @@ async function findVersions(args) {
|
|
|
138
152
|
// TODO: FindVersionsArgs.limit should be 'number' not 'number | undefined'
|
|
139
153
|
// is sanitized by Payload Core before calling the adapter (defaults to 10 or 0 based on pagination)
|
|
140
154
|
limit: args.limit,
|
|
155
|
+
locale: effectiveLocale && args.locale !== 'all' ? effectiveLocale : undefined,
|
|
141
156
|
page: args.page ?? 1,
|
|
142
157
|
sort: sortWithFallback,
|
|
143
158
|
where: whereClause,
|
|
144
|
-
...
|
|
159
|
+
...buildMeta(this.payload, {
|
|
160
|
+
collection: args.collection,
|
|
161
|
+
locale: effectiveLocale,
|
|
162
|
+
where: args.where
|
|
163
|
+
})
|
|
145
164
|
}
|
|
146
165
|
});
|
|
147
166
|
if (error) {
|
|
@@ -219,7 +238,10 @@ async function updateVersion(args) {
|
|
|
219
238
|
version: dataToContentAPI(this.payload, args.collection, args.versionData)
|
|
220
239
|
},
|
|
221
240
|
where: convertPayloadWhereToContentAPI(where),
|
|
222
|
-
...
|
|
241
|
+
...buildMeta(this.payload, {
|
|
242
|
+
collection: args.collection,
|
|
243
|
+
where
|
|
244
|
+
})
|
|
223
245
|
}
|
|
224
246
|
});
|
|
225
247
|
if (error) {
|
|
@@ -243,7 +265,10 @@ async function deleteVersions(args) {
|
|
|
243
265
|
collection: args.collection,
|
|
244
266
|
contentSystemId: this.contentSystemId,
|
|
245
267
|
where: convertPayloadWhereToContentAPI(args.where),
|
|
246
|
-
...
|
|
268
|
+
...buildMeta(this.payload, {
|
|
269
|
+
collection: args.collection,
|
|
270
|
+
where: args.where
|
|
271
|
+
})
|
|
247
272
|
}
|
|
248
273
|
});
|
|
249
274
|
if (error) {
|
|
@@ -255,6 +280,7 @@ async function findOne(args) {
|
|
|
255
280
|
collection: args.collection,
|
|
256
281
|
joins: args.joins,
|
|
257
282
|
limit: 1,
|
|
283
|
+
locale: args.locale,
|
|
258
284
|
pagination: false,
|
|
259
285
|
where: args.where
|
|
260
286
|
});
|
|
@@ -272,7 +298,10 @@ async function updateMany(args) {
|
|
|
272
298
|
returning: {},
|
|
273
299
|
sort: sortWithFallback,
|
|
274
300
|
where: convertPayloadWhereToContentAPI(args.where),
|
|
275
|
-
...
|
|
301
|
+
...buildMeta(this.payload, {
|
|
302
|
+
collection: args.collection,
|
|
303
|
+
where: args.where
|
|
304
|
+
})
|
|
276
305
|
}
|
|
277
306
|
});
|
|
278
307
|
if (error) {
|
|
@@ -300,7 +329,10 @@ async function updateOne(args) {
|
|
|
300
329
|
doc: dataToContentAPI(this.payload, args.collection, args.data),
|
|
301
330
|
returning: {},
|
|
302
331
|
where: convertPayloadWhereToContentAPI(where),
|
|
303
|
-
...
|
|
332
|
+
...buildMeta(this.payload, {
|
|
333
|
+
collection: args.collection,
|
|
334
|
+
where
|
|
335
|
+
})
|
|
304
336
|
}
|
|
305
337
|
});
|
|
306
338
|
if (error) {
|
|
@@ -324,7 +356,10 @@ async function deleteMany(args) {
|
|
|
324
356
|
collection: args.collection,
|
|
325
357
|
contentSystemId: this.contentSystemId,
|
|
326
358
|
where: convertPayloadWhereToContentAPI(args.where),
|
|
327
|
-
...
|
|
359
|
+
...buildMeta(this.payload, {
|
|
360
|
+
collection: args.collection,
|
|
361
|
+
where: args.where
|
|
362
|
+
})
|
|
328
363
|
}
|
|
329
364
|
});
|
|
330
365
|
if (error) {
|
|
@@ -338,7 +373,10 @@ async function deleteOne(args) {
|
|
|
338
373
|
contentSystemId: this.contentSystemId,
|
|
339
374
|
returning: {},
|
|
340
375
|
where: convertPayloadWhereToContentAPI(args.where),
|
|
341
|
-
...
|
|
376
|
+
...buildMeta(this.payload, {
|
|
377
|
+
collection: args.collection,
|
|
378
|
+
where: args.where
|
|
379
|
+
})
|
|
342
380
|
}
|
|
343
381
|
});
|
|
344
382
|
if (error) {
|
|
@@ -382,7 +420,10 @@ async function count(args) {
|
|
|
382
420
|
collection: args.collection,
|
|
383
421
|
contentSystemId: this.contentSystemId,
|
|
384
422
|
where: convertPayloadWhereToContentAPI(args.where),
|
|
385
|
-
...
|
|
423
|
+
...buildMeta(this.payload, {
|
|
424
|
+
collection: args.collection,
|
|
425
|
+
where: args.where
|
|
426
|
+
})
|
|
386
427
|
}
|
|
387
428
|
});
|
|
388
429
|
if (error) {
|
|
@@ -401,7 +442,10 @@ async function countVersions(args) {
|
|
|
401
442
|
collection: args.collection,
|
|
402
443
|
contentSystemId: this.contentSystemId,
|
|
403
444
|
where: convertPayloadWhereToContentAPI(args.where),
|
|
404
|
-
...
|
|
445
|
+
...buildMeta(this.payload, {
|
|
446
|
+
collection: args.collection,
|
|
447
|
+
where: args.where
|
|
448
|
+
})
|
|
405
449
|
}
|
|
406
450
|
});
|
|
407
451
|
if (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/db-content-api/index.ts"],"sourcesContent":["import type {\n BaseDatabaseAdapter,\n Count,\n CountArgs,\n CountGlobalVersionArgs,\n CountGlobalVersions,\n CountVersions,\n Create,\n CreateArgs,\n CreateGlobal,\n CreateGlobalArgs,\n CreateGlobalVersion,\n CreateGlobalVersionArgs,\n CreateVersion,\n CreateVersionArgs,\n DatabaseAdapterObj,\n DeleteMany,\n DeleteManyArgs,\n DeleteOne,\n DeleteOneArgs,\n DeleteVersions,\n DeleteVersionsArgs,\n Find,\n FindArgs,\n FindGlobal,\n FindGlobalArgs,\n FindGlobalVersions,\n FindGlobalVersionsArgs,\n FindOne,\n FindOneArgs,\n FindVersions,\n FindVersionsArgs,\n QueryDrafts,\n QueryDraftsArgs,\n UpdateGlobal,\n UpdateGlobalArgs,\n UpdateGlobalVersion,\n UpdateGlobalVersionArgs,\n UpdateMany,\n UpdateManyArgs,\n UpdateOne,\n UpdateOneArgs,\n UpdateVersion,\n UpdateVersionArgs,\n Upsert,\n UpsertArgs,\n} from 'payload'\n\nimport createClient from 'openapi-fetch'\nimport { createDatabaseAdapter } from 'payload'\nimport { v4 as uuid } from 'uuid'\n\nimport type { paths } from './generated/content-api-types.js'\n\nimport { getGlobalSlug } from './temp-utilities/slug.js'\nimport { addFallbackSort } from './temp-utilities/sorting.js'\nimport { unwrapDocument, unwrapFindResponse } from './temp-utilities/unwrapDocument.js'\nimport { type AuthMode, createAuthMiddleware, createErrorMiddleware } from './utilities/auth.js'\nimport { buildPathTypes } from './utilities/buildPathTypes.js'\nimport { dataToContentAPI } from './utilities/data/index.js'\nimport { convertPayloadJoinsToContentAPI } from './utilities/joins.js'\nimport { convertPayloadWhereToContentAPI } from './utilities/where.js'\n\ntype ContentAPIOptions = {\n auth: AuthMode\n contentSystemId: string\n url: string\n}\n\nexport type ContentAPIAdapter = {\n auth: AuthMode\n client: ReturnType<typeof createClient<paths>>\n contentSystemId: string\n url: string\n} & BaseDatabaseAdapter\n\nasync function init(this: ContentAPIAdapter) {\n if (this.auth.mode === 'apiKey') {\n this.payload.logger.info('Using API Key authentication')\n } else if (this.auth.mode === 'tokenStore') {\n this.payload.logger.info('Using TokenStore authentication (local dev)')\n } else {\n this.payload.logger.info('Using Dev JWT authentication (testing)')\n }\n\n if (process.env.PAYLOAD_DROP_DATABASE === 'true') {\n this.payload.logger.info(`---- DROPPING CONTENT API SYSTEM (${this.contentSystemId}) ----`)\n try {\n await fetch(`${this.url}/dev/clear-db`, {\n body: JSON.stringify({ contentSystemId: this.contentSystemId }),\n headers: { 'Content-Type': 'application/json' },\n method: 'POST',\n })\n this.payload.logger.info('---- DROPPED CONTENT API SYSTEM ----')\n } catch (error) {\n this.payload.logger.warn(`Failed to drop content system: ${(error as Error).message}`)\n }\n }\n\n let existingIds: Set<string>\n try {\n const { data: response, error } = await this.client.GET(\n '/api/v0/content_systems/{contentSystemId}/collections',\n {\n params: { path: { contentSystemId: this.contentSystemId } },\n },\n )\n\n if (error) {\n throw new Error(JSON.stringify(error))\n }\n if (!response) {\n throw new Error('No response from collections endpoint')\n }\n\n existingIds = new Set(response.data.map((c) => c.id))\n this.payload.logger.info(`Found ${existingIds.size} existing collections`)\n } catch (error) {\n this.payload.logger.warn(\n `Failed to fetch collections, will attempt to create all: ${(error as Error).message}`,\n )\n existingIds = new Set()\n }\n\n for (const collection of this.payload.config.collections) {\n if (!existingIds.has(collection.slug)) {\n await createCollection.call(this, collection.slug)\n }\n }\n\n for (const global of this.payload.config.globals || []) {\n const globalId = `_global-${global.slug}`\n if (!existingIds.has(globalId)) {\n await createCollection.call(this, globalId)\n }\n }\n}\n\nasync function createCollection(this: ContentAPIAdapter, collectionId: string) {\n try {\n const { error } = await this.client.POST(\n '/api/v0/content_systems/{contentSystemId}/collections',\n {\n body: { id: collectionId },\n params: { path: { contentSystemId: this.contentSystemId } },\n },\n )\n\n if (error) {\n throw new Error(JSON.stringify(error))\n }\n this.payload.logger.info(`Created collection: ${collectionId}`)\n } catch (error) {\n const errorMessage = (error as Error).message\n if (!errorMessage.includes('already exists') && !errorMessage.includes('409')) {\n this.payload.logger.warn(`Failed to create collection ${collectionId}: ${errorMessage}`)\n }\n }\n}\n\nasync function findMany(\n this: ContentAPIAdapter,\n {\n collection,\n joins,\n limit,\n page,\n pagination,\n sort,\n where,\n // Not yet passed to Content API:\n // - select: supported by Content API, pass-through possible\n // Not supported by Content API:\n // - draftsEnabled, locale, versions, projection\n }: Pick<FindArgs, 'joins' | 'pagination' | 'sort' | 'where'> &\n Required<Pick<FindArgs, 'collection' | 'limit' | 'page'>>,\n) {\n const { data: response, error } = await this.client.POST('/api/v0/documents:find', {\n body: {\n collection,\n contentSystemId: this.contentSystemId,\n join: convertPayloadJoinsToContentAPI(this.payload, collection, joins),\n limit,\n page: page ?? 1,\n sort: addFallbackSort(sort, this.payload, collection),\n where: convertPayloadWhereToContentAPI(where ?? {}),\n ...buildPathTypes(this.payload, collection, where),\n },\n })\n\n if (error) {\n throw new Error(`Content API findMany error: ${JSON.stringify(error)}`)\n }\n if (!response) {\n throw new Error('No response from findMany')\n }\n\n return unwrapFindResponse(this.payload, response.result, collection)\n}\n\nasync function find(this: ContentAPIAdapter, args: FindArgs) {\n const collectionConfig = this.payload.config.collections.find((c) => c.slug === args.collection)\n return findMany.call(this, {\n collection: args.collection,\n joins: args.joins,\n // TODO: FindArgs.limit should be 'number' not 'number | undefined'\n // is sanitized by Payload Core before calling the adapter (defaults to 10 or 0 based on pagination)\n limit: args.limit!,\n page: args.page ?? 1,\n pagination: args.pagination,\n sort: args.sort || collectionConfig?.defaultSort,\n where: args.where,\n })\n}\n\n// TODO: remove Omit when this PR is released: https://github.com/payloadcms/payload/pull/15183\nasync function findVersions(this: ContentAPIAdapter, args: Omit<FindVersionsArgs, 'skip'>) {\n const sortWithFallback = addFallbackSort(args.sort || '-updatedAt', this.payload, args.collection)\n\n const whereClause = convertPayloadWhereToContentAPI(args.where ?? {}, {\n parentToDocumentId: true,\n })\n\n const { data: response, error } = await this.client.POST('/api/v0/document_versions:find', {\n body: {\n collection: args.collection,\n contentSystemId: this.contentSystemId,\n // TODO: FindVersionsArgs.limit should be 'number' not 'number | undefined'\n // is sanitized by Payload Core before calling the adapter (defaults to 10 or 0 based on pagination)\n limit: args.limit!,\n page: args.page ?? 1,\n sort: sortWithFallback,\n where: whereClause,\n ...buildPathTypes(this.payload, args.collection, args.where),\n },\n })\n\n if (error) {\n throw new Error(`Content API findVersions error: ${JSON.stringify(error)}`)\n }\n if (!response) {\n throw new Error('No response from findVersions')\n }\n\n return unwrapFindResponse(this.payload, response.result, args.collection)\n}\n\nasync function queryDrafts(this: ContentAPIAdapter, args: QueryDraftsArgs) {\n const versionsResult = await this.findVersions({\n collection: args.collection,\n limit: args.limit,\n page: args.page,\n pagination: args.pagination,\n sort: args.sort,\n where: { ...args.where, latest: { equals: true } },\n })\n\n // queryDrafts should return documents with fields at root level, not nested in 'version'\n // So we need to unwrap the version structure and merge version fields to root\n const docs = versionsResult.docs.map((versionDoc) => {\n const { version, ...versionMeta } = versionDoc\n return {\n ...versionMeta,\n ...version,\n // Keep version metadata like parent, but document fields take precedence\n id: version.id, // Document ID, not version ID\n }\n })\n\n return {\n ...versionsResult,\n docs,\n }\n}\n\nasync function createVersion(this: ContentAPIAdapter, args: CreateVersionArgs) {\n const { data: response, error } = await this.client.POST('/api/v0/document_versions:create', {\n body: {\n collection: args.collectionSlug,\n contentSystemId: this.contentSystemId,\n versionDoc: {\n latest: !args.autosave,\n parent: String(args.parent),\n version: dataToContentAPI(this.payload, args.collectionSlug, args.versionData, {\n applyDefaults: true,\n }),\n },\n },\n })\n\n if (error) {\n throw new Error(`Content API createVersion error: ${JSON.stringify(error)}`)\n }\n if (!response) {\n throw new Error('No response from createVersion')\n }\n return unwrapDocument(this.payload, response.result, args.collectionSlug)\n}\n\nasync function updateVersion(this: ContentAPIAdapter, args: UpdateVersionArgs) {\n const where = args.where ?? { id: { equals: args.id } }\n\n const { data: response, error } = await this.client.POST('/api/v0/document_versions:update', {\n body: {\n collection: args.collection,\n contentSystemId: this.contentSystemId,\n createOnMissing: false,\n versionDoc: {\n version: dataToContentAPI(this.payload, args.collection, args.versionData),\n },\n where: convertPayloadWhereToContentAPI(where),\n ...buildPathTypes(this.payload, args.collection, where),\n },\n })\n\n if (error) {\n throw new Error(`Content API updateVersion error: ${JSON.stringify(error)}`)\n }\n if (!response?.result || !('data' in response.result)) {\n throw new Error('No document data in updateVersion response')\n }\n\n const doc = response.result.data[0]\n if (!doc) {\n return null\n }\n\n return unwrapDocument(this.payload, doc, args.collection)\n}\n\nasync function deleteVersions(this: ContentAPIAdapter, args: DeleteVersionsArgs) {\n if (!args.collection) {\n throw new Error('deleteVersions requires a collection')\n }\n\n const { error } = await this.client.POST('/api/v0/document_versions:delete', {\n body: {\n collection: args.collection,\n contentSystemId: this.contentSystemId,\n where: convertPayloadWhereToContentAPI(args.where),\n ...buildPathTypes(this.payload, args.collection, args.where),\n },\n })\n\n if (error) {\n throw new Error(`Content API deleteVersions error: ${JSON.stringify(error)}`)\n }\n}\n\nasync function findOne(this: ContentAPIAdapter, args: FindOneArgs) {\n const { docs } = await this.find({\n collection: args.collection,\n joins: args.joins,\n limit: 1,\n pagination: false,\n where: args.where,\n })\n return docs[0] ?? null\n}\n\nasync function updateMany(this: ContentAPIAdapter, args: UpdateManyArgs) {\n const sortWithFallback = addFallbackSort(args.sort || '-updatedAt', this.payload, args.collection)\n\n const { data: response, error } = await this.client.POST('/api/v0/documents:update', {\n body: {\n collection: args.collection,\n contentSystemId: this.contentSystemId,\n createOnMissing: false,\n doc: dataToContentAPI(this.payload, args.collection, args.data),\n limit: args.limit,\n returning: {},\n sort: sortWithFallback,\n where: convertPayloadWhereToContentAPI(args.where),\n ...buildPathTypes(this.payload, args.collection, args.where),\n },\n })\n\n if (error) {\n throw new Error(`Content API updateMany error: ${JSON.stringify(error)}`)\n }\n if (!response) {\n throw new Error('No response from updateMany')\n }\n\n if (response.result && 'data' in response.result) {\n return response.result.data.map((doc) => unwrapDocument(this.payload, doc, args.collection))\n }\n return null\n}\n\nasync function updateOne(this: ContentAPIAdapter, args: UpdateOneArgs) {\n const where = args.where ?? { id: { equals: args.id } }\n\n const { data: response, error } = await this.client.POST('/api/v0/documents:update', {\n body: {\n collection: args.collection,\n contentSystemId: this.contentSystemId,\n createOnMissing: false,\n doc: dataToContentAPI(this.payload, args.collection, args.data),\n returning: {},\n where: convertPayloadWhereToContentAPI(where),\n ...buildPathTypes(this.payload, args.collection, where),\n },\n })\n\n if (error) {\n throw new Error(`Content API updateOne error: ${JSON.stringify(error)}`)\n }\n if (!response) {\n throw new Error('No response from updateOne')\n }\n if (!response.result || !('data' in response.result)) {\n throw new Error('Unexpected response format from updateOne')\n }\n\n const doc = response.result.data[0]\n if (!doc) {\n return null\n }\n\n return unwrapDocument(this.payload, doc, args.collection)\n}\n\nasync function deleteMany(this: ContentAPIAdapter, args: DeleteManyArgs) {\n const { error } = await this.client.POST('/api/v0/documents:delete', {\n body: {\n collection: args.collection,\n contentSystemId: this.contentSystemId,\n where: convertPayloadWhereToContentAPI(args.where),\n ...buildPathTypes(this.payload, args.collection, args.where),\n },\n })\n\n if (error) {\n throw new Error(`Content API deleteMany error: ${JSON.stringify(error)}`)\n }\n}\n\nasync function deleteOne(this: ContentAPIAdapter, args: DeleteOneArgs) {\n const { data: response, error } = await this.client.POST('/api/v0/documents:delete', {\n body: {\n collection: args.collection,\n contentSystemId: this.contentSystemId,\n returning: {}, // Request deleted document back\n where: convertPayloadWhereToContentAPI(args.where),\n ...buildPathTypes(this.payload, args.collection, args.where),\n },\n })\n\n if (error) {\n throw new Error(`Content API deleteOne error: ${JSON.stringify(error)}`)\n }\n if (!response?.result || !('data' in response.result)) {\n throw new Error('No document data in deleteOne response')\n }\n\n const doc = response.result.data[0]\n if (!doc) {\n return null\n }\n\n return unwrapDocument(this.payload, doc, args.collection)\n}\n\nasync function create(this: ContentAPIAdapter, args: CreateArgs) {\n const id = (args.data.id as string | undefined) || uuid()\n\n const { data: response, error } = await this.client.POST('/api/v0/documents:create', {\n body: {\n collection: args.collection,\n contentSystemId: this.contentSystemId,\n doc: {\n id: String(id),\n ...dataToContentAPI(this.payload, args.collection, args.data, {\n applyDefaults: true,\n createdAt: true,\n }),\n },\n },\n })\n\n if (error) {\n throw new Error(`Content API create error: ${JSON.stringify(error)}`)\n }\n if (!response) {\n throw new Error('No response from create')\n }\n return unwrapDocument(this.payload, response.result, args.collection)\n}\n\nasync function count(this: ContentAPIAdapter, args: CountArgs) {\n const { data: response, error } = await this.client.POST('/api/v0/documents:count', {\n body: {\n collection: args.collection,\n contentSystemId: this.contentSystemId,\n where: convertPayloadWhereToContentAPI(args.where),\n ...buildPathTypes(this.payload, args.collection, args.where),\n },\n })\n\n if (error) {\n throw new Error(`Content API count error: ${JSON.stringify(error)}`)\n }\n if (!response) {\n throw new Error('No response from count')\n }\n\n return { totalDocs: response.result.count }\n}\n\nasync function countVersions(this: ContentAPIAdapter, args: CountArgs) {\n const { data: response, error } = await this.client.POST('/api/v0/document_versions:count', {\n body: {\n collection: args.collection,\n contentSystemId: this.contentSystemId,\n where: convertPayloadWhereToContentAPI(args.where),\n ...buildPathTypes(this.payload, args.collection, args.where),\n },\n })\n\n if (error) {\n throw new Error(`Content API countVersions error: ${JSON.stringify(error)}`)\n }\n if (!response) {\n throw new Error('No response from countVersions')\n }\n\n return { totalDocs: response.result.count }\n}\n\nasync function upsert(this: ContentAPIAdapter, args: UpsertArgs) {\n let documentId = args.data.id as string | undefined\n if (!documentId && args.where && 'id' in args.where) {\n const idClause = (args.where as Record<string, unknown>).id as Record<string, unknown>\n if (idClause && 'equals' in idClause) {\n documentId = idClause.equals as string\n }\n }\n if (!documentId) {\n documentId = uuid()\n }\n\n const { data: response, error } = await this.client.POST('/api/v0/documents:update', {\n body: {\n collection: args.collection,\n contentSystemId: this.contentSystemId,\n createOnMissing: { id: documentId },\n doc: dataToContentAPI(this.payload, args.collection, args.data, {\n applyDefaults: true,\n createdAt: true,\n }),\n where: convertPayloadWhereToContentAPI(args.where),\n },\n })\n\n if (error) {\n throw new Error(`Content API upsert error: ${JSON.stringify(error)}`)\n }\n if (!response) {\n throw new Error('No response from upsert')\n }\n if (!response.result || !('data' in response.result)) {\n throw new Error('Unexpected response format from upsert')\n }\n\n const doc = response.result.data[0]\n if (!doc) {\n throw new Error('No document data in upsert response')\n }\n\n return unwrapDocument(this.payload, doc, args.collection)\n}\n\nfunction createGlobal(this: ContentAPIAdapter, args: CreateGlobalArgs) {\n return this.create({\n collection: getGlobalSlug(args.slug),\n data: { ...args.data, id: args.slug, globalType: args.slug },\n })\n}\n\nfunction findGlobal(this: ContentAPIAdapter, args: FindGlobalArgs) {\n return this.findOne({ collection: getGlobalSlug(args.slug), where: args.where ?? {} })\n}\n\nasync function updateGlobal(this: ContentAPIAdapter, args: UpdateGlobalArgs) {\n // Use upsert to ensure the global exists\n // Use slug as the consistent document ID for globals\n return this.upsert({\n collection: getGlobalSlug(args.slug),\n data: args.data,\n where: { id: { equals: args.slug } },\n })\n}\n\n// TODO: remove Omit when this PR is released: https://github.com/payloadcms/payload/pull/15183\nfunction findGlobalVersions(this: ContentAPIAdapter, args: Omit<FindGlobalVersionsArgs, 'skip'>) {\n return this.findVersions({\n collection: getGlobalSlug(args.global),\n limit: args.limit,\n page: args.page,\n pagination: args.pagination,\n sort: args.sort,\n where: args.where,\n })\n}\n\nfunction createGlobalVersion(this: ContentAPIAdapter, args: CreateGlobalVersionArgs) {\n // For globals, use the globalSlug as the consistent document ID\n // This matches what we do in updateGlobal\n return this.createVersion({\n autosave: args.autosave,\n collectionSlug: getGlobalSlug(args.globalSlug),\n createdAt: args.createdAt,\n parent: args.globalSlug,\n updatedAt: args.updatedAt,\n versionData: args.versionData,\n })\n}\n\nfunction updateGlobalVersion(this: ContentAPIAdapter, args: UpdateGlobalVersionArgs) {\n // UpdateVersion requires either id OR where, not both\n if (args.id !== undefined) {\n return this.updateVersion({\n id: args.id,\n collection: getGlobalSlug(args.global),\n versionData: args.versionData,\n })\n }\n // args.where is guaranteed by Payload when args.id is undefined\n return this.updateVersion({\n collection: getGlobalSlug(args.global),\n versionData: args.versionData,\n where: args.where,\n })\n}\n\nfunction countGlobalVersions(this: ContentAPIAdapter, args: CountGlobalVersionArgs) {\n return this.countVersions({ collection: getGlobalSlug(args.global), where: args.where })\n}\n\nexport const contentAPIAdapter = (opts: ContentAPIOptions): DatabaseAdapterObj => ({\n name: 'content-api',\n defaultIDType: 'text',\n init: ({ payload }) => {\n const client = createClient<paths>({ baseUrl: opts.url })\n\n const middlewareOpts = {\n auth: opts.auth,\n contentSystemId: opts.contentSystemId,\n logger: payload.logger,\n url: opts.url,\n }\n\n client.use(createAuthMiddleware(middlewareOpts))\n client.use(createErrorMiddleware(middlewareOpts))\n\n return createDatabaseAdapter<ContentAPIAdapter>({\n name: 'content-api',\n auth: opts.auth,\n beginTransaction: () => Promise.resolve(null),\n client,\n commitTransaction: async () => {},\n contentSystemId: opts.contentSystemId,\n count: count as Count,\n countGlobalVersions: countGlobalVersions as CountGlobalVersions,\n countVersions: countVersions as CountVersions,\n create: create as Create,\n createGlobal: createGlobal as CreateGlobal,\n createGlobalVersion: createGlobalVersion as CreateGlobalVersion,\n createVersion: createVersion as CreateVersion,\n defaultIDType: 'text',\n deleteMany: deleteMany as DeleteMany,\n deleteOne: deleteOne as DeleteOne,\n deleteVersions: deleteVersions as DeleteVersions,\n find: find as Find,\n findDistinct: () =>\n Promise.reject(new Error('findDistinct is not yet implemented for Content API adapter')),\n findGlobal: findGlobal as FindGlobal,\n findGlobalVersions: findGlobalVersions as FindGlobalVersions,\n findOne: findOne as FindOne,\n findVersions: findVersions as FindVersions,\n init,\n packageName: '@payloadcms/db-content-api',\n payload,\n queryDrafts: queryDrafts as QueryDrafts,\n rollbackTransaction: async () => {},\n updateGlobal: updateGlobal as UpdateGlobal,\n updateGlobalVersion: updateGlobalVersion as UpdateGlobalVersion,\n updateMany: updateMany as UpdateMany,\n updateOne: updateOne as UpdateOne,\n updateVersion: updateVersion as UpdateVersion,\n upsert: upsert as Upsert,\n url: opts.url,\n })\n },\n})\n"],"names":["createClient","createDatabaseAdapter","v4","uuid","getGlobalSlug","addFallbackSort","unwrapDocument","unwrapFindResponse","createAuthMiddleware","createErrorMiddleware","buildPathTypes","dataToContentAPI","convertPayloadJoinsToContentAPI","convertPayloadWhereToContentAPI","init","auth","mode","payload","logger","info","process","env","PAYLOAD_DROP_DATABASE","contentSystemId","fetch","url","body","JSON","stringify","headers","method","error","warn","message","existingIds","data","response","client","GET","params","path","Error","Set","map","c","id","size","collection","config","collections","has","slug","createCollection","call","global","globals","globalId","collectionId","POST","errorMessage","includes","findMany","joins","limit","page","pagination","sort","where","join","result","find","args","collectionConfig","defaultSort","findVersions","sortWithFallback","whereClause","parentToDocumentId","queryDrafts","versionsResult","latest","equals","docs","versionDoc","version","versionMeta","createVersion","collectionSlug","autosave","parent","String","versionData","applyDefaults","updateVersion","createOnMissing","doc","deleteVersions","findOne","updateMany","returning","updateOne","deleteMany","deleteOne","create","createdAt","count","totalDocs","countVersions","upsert","documentId","idClause","createGlobal","globalType","findGlobal","updateGlobal","findGlobalVersions","createGlobalVersion","globalSlug","updatedAt","updateGlobalVersion","undefined","countGlobalVersions","contentAPIAdapter","opts","name","defaultIDType","baseUrl","middlewareOpts","use","beginTransaction","Promise","resolve","commitTransaction","findDistinct","reject","packageName","rollbackTransaction"],"mappings":"AAgDA,OAAOA,kBAAkB,gBAAe;AACxC,SAASC,qBAAqB,QAAQ,UAAS;AAC/C,SAASC,MAAMC,IAAI,QAAQ,OAAM;AAIjC,SAASC,aAAa,QAAQ,2BAA0B;AACxD,SAASC,eAAe,QAAQ,8BAA6B;AAC7D,SAASC,cAAc,EAAEC,kBAAkB,QAAQ,qCAAoC;AACvF,SAAwBC,oBAAoB,EAAEC,qBAAqB,QAAQ,sBAAqB;AAChG,SAASC,cAAc,QAAQ,gCAA+B;AAC9D,SAASC,gBAAgB,QAAQ,4BAA2B;AAC5D,SAASC,+BAA+B,QAAQ,uBAAsB;AACtE,SAASC,+BAA+B,QAAQ,uBAAsB;AAetE,eAAeC;IACb,IAAI,IAAI,CAACC,IAAI,CAACC,IAAI,KAAK,UAAU;QAC/B,IAAI,CAACC,OAAO,CAAC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;YAChB,MAAMoB,SAASrC,aAAoB;gBAAE8H,SAASH,KAAKlG,GAAG;YAAC;YAEvD,MAAMsG,iBAAiB;gBACrBhH,MAAM4G,KAAK5G,IAAI;gBACfQ,iBAAiBoG,KAAKpG,eAAe;gBACrCL,QAAQD,QAAQC,MAAM;gBACtBO,KAAKkG,KAAKlG,GAAG;YACf;YAEAY,OAAO2F,GAAG,CAACxH,qBAAqBuH;YAChC1F,OAAO2F,GAAG,CAACvH,sBAAsBsH;YAEjC,OAAO9H,sBAAyC;gBAC9C2H,MAAM;gBACN7G,MAAM4G,KAAK5G,IAAI;gBACfkH,kBAAkB,IAAMC,QAAQC,OAAO,CAAC;gBACxC9F;gBACA+F,mBAAmB,WAAa;gBAChC7G,iBAAiBoG,KAAKpG,eAAe;gBACrCkF,OAAOA;gBACPgB,qBAAqBA;gBACrBd,eAAeA;gBACfJ,QAAQA;gBACRQ,cAAcA;gBACdK,qBAAqBA;gBACrB9B,eAAeA;gBACfuC,eAAe;gBACfxB,YAAYA;gBACZC,WAAWA;gBACXN,gBAAgBA;gBAChB1B,MAAMA;gBACN+D,cAAc,IACZH,QAAQI,MAAM,CAAC,IAAI7F,MAAM;gBAC3BwE,YAAYA;gBACZE,oBAAoBA;gBACpBlB,SAASA;gBACTvB,cAAcA;gBACd5D;gBACAyH,aAAa;gBACbtH;gBACA6D,aAAaA;gBACb0D,qBAAqB,WAAa;gBAClCtB,cAAcA;gBACdK,qBAAqBA;gBACrBrB,YAAYA;gBACZE,WAAWA;gBACXP,eAAeA;gBACfe,QAAQA;gBACRnF,KAAKkG,KAAKlG,GAAG;YACf;QACF;IACF,CAAA,EAAE"}
|
|
1
|
+
{"version":3,"sources":["../../src/db-content-api/index.ts"],"sourcesContent":["import type {\n BaseDatabaseAdapter,\n Count,\n CountArgs,\n CountGlobalVersionArgs,\n CountGlobalVersions,\n CountVersions,\n Create,\n CreateArgs,\n CreateGlobal,\n CreateGlobalArgs,\n CreateGlobalVersion,\n CreateGlobalVersionArgs,\n CreateVersion,\n CreateVersionArgs,\n DatabaseAdapterObj,\n DeleteMany,\n DeleteManyArgs,\n DeleteOne,\n DeleteOneArgs,\n DeleteVersions,\n DeleteVersionsArgs,\n Find,\n FindArgs,\n FindGlobal,\n FindGlobalArgs,\n FindGlobalVersions,\n FindGlobalVersionsArgs,\n FindOne,\n FindOneArgs,\n FindVersions,\n FindVersionsArgs,\n QueryDrafts,\n QueryDraftsArgs,\n UpdateGlobal,\n UpdateGlobalArgs,\n UpdateGlobalVersion,\n UpdateGlobalVersionArgs,\n UpdateMany,\n UpdateManyArgs,\n UpdateOne,\n UpdateOneArgs,\n UpdateVersion,\n UpdateVersionArgs,\n Upsert,\n UpsertArgs,\n} from 'payload'\n\nimport createClient from 'openapi-fetch'\nimport { createDatabaseAdapter } from 'payload'\nimport { v4 as uuid } from 'uuid'\n\nimport type { paths } from './generated/content-api-types.js'\n\nimport { getGlobalSlug } from './temp-utilities/slug.js'\nimport { addFallbackSort } from './temp-utilities/sorting.js'\nimport { unwrapDocument, unwrapFindResponse } from './temp-utilities/unwrapDocument.js'\nimport { type AuthMode, createAuthMiddleware, createErrorMiddleware } from './utilities/auth.js'\nimport { dataToContentAPI } from './utilities/data/index.js'\nimport { convertPayloadJoinsToContentAPI } from './utilities/joins.js'\nimport { buildMeta } from './utilities/meta/index.js'\nimport { convertPayloadWhereToContentAPI } from './utilities/where.js'\n\ntype ContentAPIOptions = {\n auth: AuthMode\n contentSystemId: string\n url: string\n}\n\nexport type ContentAPIAdapter = {\n auth: AuthMode\n client: ReturnType<typeof createClient<paths>>\n contentSystemId: string\n url: string\n} & BaseDatabaseAdapter\n\nasync function init(this: ContentAPIAdapter) {\n if (this.auth.mode === 'apiKey') {\n this.payload.logger.info('Using API Key authentication')\n } else if (this.auth.mode === 'tokenStore') {\n this.payload.logger.info('Using TokenStore authentication (local dev)')\n } else {\n this.payload.logger.info('Using Dev JWT authentication (testing)')\n }\n\n if (process.env.PAYLOAD_DROP_DATABASE === 'true') {\n this.payload.logger.info(`---- DROPPING CONTENT API SYSTEM (${this.contentSystemId}) ----`)\n try {\n await fetch(`${this.url}/dev/clear-db`, {\n body: JSON.stringify({ contentSystemId: this.contentSystemId }),\n headers: { 'Content-Type': 'application/json' },\n method: 'POST',\n })\n this.payload.logger.info('---- DROPPED CONTENT API SYSTEM ----')\n } catch (error) {\n this.payload.logger.warn(`Failed to drop content system: ${(error as Error).message}`)\n }\n }\n\n let existingIds: Set<string>\n try {\n const { data: response, error } = await this.client.GET(\n '/api/v0/content_systems/{contentSystemId}/collections',\n {\n params: { path: { contentSystemId: this.contentSystemId } },\n },\n )\n\n if (error) {\n throw new Error(JSON.stringify(error))\n }\n if (!response) {\n throw new Error('No response from collections endpoint')\n }\n\n existingIds = new Set(response.data.map((c) => c.id))\n this.payload.logger.info(`Found ${existingIds.size} existing collections`)\n } catch (error) {\n this.payload.logger.warn(\n `Failed to fetch collections, will attempt to create all: ${(error as Error).message}`,\n )\n existingIds = new Set()\n }\n\n for (const collection of this.payload.config.collections) {\n if (!existingIds.has(collection.slug)) {\n await createCollection.call(this, collection.slug)\n }\n }\n\n for (const global of this.payload.config.globals || []) {\n const globalId = `_global-${global.slug}`\n if (!existingIds.has(globalId)) {\n await createCollection.call(this, globalId)\n }\n }\n}\n\nasync function createCollection(this: ContentAPIAdapter, collectionId: string) {\n try {\n const { error } = await this.client.POST(\n '/api/v0/content_systems/{contentSystemId}/collections',\n {\n body: { id: collectionId },\n params: { path: { contentSystemId: this.contentSystemId } },\n },\n )\n\n if (error) {\n throw new Error(JSON.stringify(error))\n }\n this.payload.logger.info(`Created collection: ${collectionId}`)\n } catch (error) {\n const errorMessage = (error as Error).message\n if (!errorMessage.includes('already exists') && !errorMessage.includes('409')) {\n this.payload.logger.warn(`Failed to create collection ${collectionId}: ${errorMessage}`)\n }\n }\n}\n\nasync function findMany(\n this: ContentAPIAdapter,\n {\n collection,\n joins,\n limit,\n locale,\n page,\n pagination,\n sort,\n where,\n // Not yet passed to Content API:\n // - select: supported by Content API, pass-through possible\n // Not supported by Content API:\n // - draftsEnabled, versions, projection\n }: Pick<FindArgs, 'joins' | 'locale' | 'pagination' | 'sort' | 'where'> &\n Required<Pick<FindArgs, 'collection' | 'limit' | 'page'>>,\n) {\n // Use provided locale or fall back to default locale from config\n // 'all' is a special Payload value meaning \"return all locales\" - don't send to Content API\n const localization = this.payload.config.localization\n const effectiveLocale =\n locale && locale !== 'all' ? locale : localization ? localization.defaultLocale : undefined\n\n const { data: response, error } = await this.client.POST('/api/v0/documents:find', {\n body: {\n collection,\n contentSystemId: this.contentSystemId,\n join: convertPayloadJoinsToContentAPI(this.payload, collection, joins),\n limit,\n locale: effectiveLocale && locale !== 'all' ? effectiveLocale : undefined,\n page: page ?? 1,\n sort: addFallbackSort(sort, this.payload, collection),\n where: convertPayloadWhereToContentAPI(where ?? {}),\n ...buildMeta(this.payload, { collection, locale: effectiveLocale, where }),\n },\n })\n\n if (error) {\n throw new Error(`Content API findMany error: ${JSON.stringify(error)}`)\n }\n if (!response) {\n throw new Error('No response from findMany')\n }\n\n return unwrapFindResponse(this.payload, response.result, collection)\n}\n\nasync function find(this: ContentAPIAdapter, args: FindArgs) {\n const collectionConfig = this.payload.config.collections.find((c) => c.slug === args.collection)\n return findMany.call(this, {\n collection: args.collection,\n joins: args.joins,\n // TODO: FindArgs.limit should be 'number' not 'number | undefined'\n // is sanitized by Payload Core before calling the adapter (defaults to 10 or 0 based on pagination)\n limit: args.limit!,\n locale: args.locale,\n page: args.page ?? 1,\n pagination: args.pagination,\n sort: args.sort || collectionConfig?.defaultSort,\n where: args.where,\n })\n}\n\n// TODO: remove Omit when this PR is released: https://github.com/payloadcms/payload/pull/15183\nasync function findVersions(this: ContentAPIAdapter, args: Omit<FindVersionsArgs, 'skip'>) {\n const sortWithFallback = addFallbackSort(args.sort || '-updatedAt', this.payload, args.collection)\n\n const whereClause = convertPayloadWhereToContentAPI(args.where ?? {}, {\n parentToDocumentId: true,\n })\n\n // Use provided locale or fall back to default locale from config\n // 'all' is a special Payload value meaning \"return all locales\" - don't send to Content API\n const localization = this.payload.config.localization\n const effectiveLocale =\n args.locale && args.locale !== 'all'\n ? args.locale\n : localization\n ? localization.defaultLocale\n : undefined\n\n const { data: response, error } = await this.client.POST('/api/v0/document_versions:find', {\n body: {\n collection: args.collection,\n contentSystemId: this.contentSystemId,\n // TODO: FindVersionsArgs.limit should be 'number' not 'number | undefined'\n // is sanitized by Payload Core before calling the adapter (defaults to 10 or 0 based on pagination)\n limit: args.limit!,\n locale: effectiveLocale && args.locale !== 'all' ? effectiveLocale : undefined,\n page: args.page ?? 1,\n sort: sortWithFallback,\n where: whereClause,\n ...buildMeta(this.payload, {\n collection: args.collection,\n locale: effectiveLocale,\n where: args.where,\n }),\n },\n })\n\n if (error) {\n throw new Error(`Content API findVersions error: ${JSON.stringify(error)}`)\n }\n if (!response) {\n throw new Error('No response from findVersions')\n }\n\n return unwrapFindResponse(this.payload, response.result, args.collection)\n}\n\nasync function queryDrafts(this: ContentAPIAdapter, args: QueryDraftsArgs) {\n const versionsResult = await this.findVersions({\n collection: args.collection,\n limit: args.limit,\n page: args.page,\n pagination: args.pagination,\n sort: args.sort,\n where: { ...args.where, latest: { equals: true } },\n })\n\n // queryDrafts should return documents with fields at root level, not nested in 'version'\n // So we need to unwrap the version structure and merge version fields to root\n const docs = versionsResult.docs.map((versionDoc) => {\n const { version, ...versionMeta } = versionDoc\n return {\n ...versionMeta,\n ...version,\n // Keep version metadata like parent, but document fields take precedence\n id: version.id, // Document ID, not version ID\n }\n })\n\n return {\n ...versionsResult,\n docs,\n }\n}\n\nasync function createVersion(this: ContentAPIAdapter, args: CreateVersionArgs) {\n const { data: response, error } = await this.client.POST('/api/v0/document_versions:create', {\n body: {\n collection: args.collectionSlug,\n contentSystemId: this.contentSystemId,\n versionDoc: {\n latest: !args.autosave,\n parent: String(args.parent),\n version: dataToContentAPI(this.payload, args.collectionSlug, args.versionData, {\n applyDefaults: true,\n }),\n },\n },\n })\n\n if (error) {\n throw new Error(`Content API createVersion error: ${JSON.stringify(error)}`)\n }\n if (!response) {\n throw new Error('No response from createVersion')\n }\n return unwrapDocument(this.payload, response.result, args.collectionSlug)\n}\n\nasync function updateVersion(this: ContentAPIAdapter, args: UpdateVersionArgs) {\n const where = args.where ?? { id: { equals: args.id } }\n\n const { data: response, error } = await this.client.POST('/api/v0/document_versions:update', {\n body: {\n collection: args.collection,\n contentSystemId: this.contentSystemId,\n createOnMissing: false,\n versionDoc: {\n version: dataToContentAPI(this.payload, args.collection, args.versionData),\n },\n where: convertPayloadWhereToContentAPI(where),\n ...buildMeta(this.payload, { collection: args.collection, where }),\n },\n })\n\n if (error) {\n throw new Error(`Content API updateVersion error: ${JSON.stringify(error)}`)\n }\n if (!response?.result || !('data' in response.result)) {\n throw new Error('No document data in updateVersion response')\n }\n\n const doc = response.result.data[0]\n if (!doc) {\n return null\n }\n\n return unwrapDocument(this.payload, doc, args.collection)\n}\n\nasync function deleteVersions(this: ContentAPIAdapter, args: DeleteVersionsArgs) {\n if (!args.collection) {\n throw new Error('deleteVersions requires a collection')\n }\n\n const { error } = await this.client.POST('/api/v0/document_versions:delete', {\n body: {\n collection: args.collection,\n contentSystemId: this.contentSystemId,\n where: convertPayloadWhereToContentAPI(args.where),\n ...buildMeta(this.payload, { collection: args.collection, where: args.where }),\n },\n })\n\n if (error) {\n throw new Error(`Content API deleteVersions error: ${JSON.stringify(error)}`)\n }\n}\n\nasync function findOne(this: ContentAPIAdapter, args: FindOneArgs) {\n const { docs } = await this.find({\n collection: args.collection,\n joins: args.joins,\n limit: 1,\n locale: args.locale,\n pagination: false,\n where: args.where,\n })\n return docs[0] ?? null\n}\n\nasync function updateMany(this: ContentAPIAdapter, args: UpdateManyArgs) {\n const sortWithFallback = addFallbackSort(args.sort || '-updatedAt', this.payload, args.collection)\n\n const { data: response, error } = await this.client.POST('/api/v0/documents:update', {\n body: {\n collection: args.collection,\n contentSystemId: this.contentSystemId,\n createOnMissing: false,\n doc: dataToContentAPI(this.payload, args.collection, args.data),\n limit: args.limit,\n returning: {},\n sort: sortWithFallback,\n where: convertPayloadWhereToContentAPI(args.where),\n ...buildMeta(this.payload, { collection: args.collection, where: args.where }),\n },\n })\n\n if (error) {\n throw new Error(`Content API updateMany error: ${JSON.stringify(error)}`)\n }\n if (!response) {\n throw new Error('No response from updateMany')\n }\n\n if (response.result && 'data' in response.result) {\n return response.result.data.map((doc) => unwrapDocument(this.payload, doc, args.collection))\n }\n return null\n}\n\nasync function updateOne(this: ContentAPIAdapter, args: UpdateOneArgs) {\n const where = args.where ?? { id: { equals: args.id } }\n\n const { data: response, error } = await this.client.POST('/api/v0/documents:update', {\n body: {\n collection: args.collection,\n contentSystemId: this.contentSystemId,\n createOnMissing: false,\n doc: dataToContentAPI(this.payload, args.collection, args.data),\n returning: {},\n where: convertPayloadWhereToContentAPI(where),\n ...buildMeta(this.payload, { collection: args.collection, where }),\n },\n })\n\n if (error) {\n throw new Error(`Content API updateOne error: ${JSON.stringify(error)}`)\n }\n if (!response) {\n throw new Error('No response from updateOne')\n }\n if (!response.result || !('data' in response.result)) {\n throw new Error('Unexpected response format from updateOne')\n }\n\n const doc = response.result.data[0]\n if (!doc) {\n return null\n }\n\n return unwrapDocument(this.payload, doc, args.collection)\n}\n\nasync function deleteMany(this: ContentAPIAdapter, args: DeleteManyArgs) {\n const { error } = await this.client.POST('/api/v0/documents:delete', {\n body: {\n collection: args.collection,\n contentSystemId: this.contentSystemId,\n where: convertPayloadWhereToContentAPI(args.where),\n ...buildMeta(this.payload, { collection: args.collection, where: args.where }),\n },\n })\n\n if (error) {\n throw new Error(`Content API deleteMany error: ${JSON.stringify(error)}`)\n }\n}\n\nasync function deleteOne(this: ContentAPIAdapter, args: DeleteOneArgs) {\n const { data: response, error } = await this.client.POST('/api/v0/documents:delete', {\n body: {\n collection: args.collection,\n contentSystemId: this.contentSystemId,\n returning: {}, // Request deleted document back\n where: convertPayloadWhereToContentAPI(args.where),\n ...buildMeta(this.payload, { collection: args.collection, where: args.where }),\n },\n })\n\n if (error) {\n throw new Error(`Content API deleteOne error: ${JSON.stringify(error)}`)\n }\n if (!response?.result || !('data' in response.result)) {\n throw new Error('No document data in deleteOne response')\n }\n\n const doc = response.result.data[0]\n if (!doc) {\n return null\n }\n\n return unwrapDocument(this.payload, doc, args.collection)\n}\n\nasync function create(this: ContentAPIAdapter, args: CreateArgs) {\n const id = (args.data.id as string | undefined) || uuid()\n\n const { data: response, error } = await this.client.POST('/api/v0/documents:create', {\n body: {\n collection: args.collection,\n contentSystemId: this.contentSystemId,\n doc: {\n id: String(id),\n ...dataToContentAPI(this.payload, args.collection, args.data, {\n applyDefaults: true,\n createdAt: true,\n }),\n },\n },\n })\n\n if (error) {\n throw new Error(`Content API create error: ${JSON.stringify(error)}`)\n }\n if (!response) {\n throw new Error('No response from create')\n }\n return unwrapDocument(this.payload, response.result, args.collection)\n}\n\nasync function count(this: ContentAPIAdapter, args: CountArgs) {\n const { data: response, error } = await this.client.POST('/api/v0/documents:count', {\n body: {\n collection: args.collection,\n contentSystemId: this.contentSystemId,\n where: convertPayloadWhereToContentAPI(args.where),\n ...buildMeta(this.payload, { collection: args.collection, where: args.where }),\n },\n })\n\n if (error) {\n throw new Error(`Content API count error: ${JSON.stringify(error)}`)\n }\n if (!response) {\n throw new Error('No response from count')\n }\n\n return { totalDocs: response.result.count }\n}\n\nasync function countVersions(this: ContentAPIAdapter, args: CountArgs) {\n const { data: response, error } = await this.client.POST('/api/v0/document_versions:count', {\n body: {\n collection: args.collection,\n contentSystemId: this.contentSystemId,\n where: convertPayloadWhereToContentAPI(args.where),\n ...buildMeta(this.payload, { collection: args.collection, where: args.where }),\n },\n })\n\n if (error) {\n throw new Error(`Content API countVersions error: ${JSON.stringify(error)}`)\n }\n if (!response) {\n throw new Error('No response from countVersions')\n }\n\n return { totalDocs: response.result.count }\n}\n\nasync function upsert(this: ContentAPIAdapter, args: UpsertArgs) {\n let documentId = args.data.id as string | undefined\n if (!documentId && args.where && 'id' in args.where) {\n const idClause = (args.where as Record<string, unknown>).id as Record<string, unknown>\n if (idClause && 'equals' in idClause) {\n documentId = idClause.equals as string\n }\n }\n if (!documentId) {\n documentId = uuid()\n }\n\n const { data: response, error } = await this.client.POST('/api/v0/documents:update', {\n body: {\n collection: args.collection,\n contentSystemId: this.contentSystemId,\n createOnMissing: { id: documentId },\n doc: dataToContentAPI(this.payload, args.collection, args.data, {\n applyDefaults: true,\n createdAt: true,\n }),\n where: convertPayloadWhereToContentAPI(args.where),\n },\n })\n\n if (error) {\n throw new Error(`Content API upsert error: ${JSON.stringify(error)}`)\n }\n if (!response) {\n throw new Error('No response from upsert')\n }\n if (!response.result || !('data' in response.result)) {\n throw new Error('Unexpected response format from upsert')\n }\n\n const doc = response.result.data[0]\n if (!doc) {\n throw new Error('No document data in upsert response')\n }\n\n return unwrapDocument(this.payload, doc, args.collection)\n}\n\nfunction createGlobal(this: ContentAPIAdapter, args: CreateGlobalArgs) {\n return this.create({\n collection: getGlobalSlug(args.slug),\n data: { ...args.data, id: args.slug, globalType: args.slug },\n })\n}\n\nfunction findGlobal(this: ContentAPIAdapter, args: FindGlobalArgs) {\n return this.findOne({ collection: getGlobalSlug(args.slug), where: args.where ?? {} })\n}\n\nasync function updateGlobal(this: ContentAPIAdapter, args: UpdateGlobalArgs) {\n // Use upsert to ensure the global exists\n // Use slug as the consistent document ID for globals\n return this.upsert({\n collection: getGlobalSlug(args.slug),\n data: args.data,\n where: { id: { equals: args.slug } },\n })\n}\n\n// TODO: remove Omit when this PR is released: https://github.com/payloadcms/payload/pull/15183\nfunction findGlobalVersions(this: ContentAPIAdapter, args: Omit<FindGlobalVersionsArgs, 'skip'>) {\n return this.findVersions({\n collection: getGlobalSlug(args.global),\n limit: args.limit,\n page: args.page,\n pagination: args.pagination,\n sort: args.sort,\n where: args.where,\n })\n}\n\nfunction createGlobalVersion(this: ContentAPIAdapter, args: CreateGlobalVersionArgs) {\n // For globals, use the globalSlug as the consistent document ID\n // This matches what we do in updateGlobal\n return this.createVersion({\n autosave: args.autosave,\n collectionSlug: getGlobalSlug(args.globalSlug),\n createdAt: args.createdAt,\n parent: args.globalSlug,\n updatedAt: args.updatedAt,\n versionData: args.versionData,\n })\n}\n\nfunction updateGlobalVersion(this: ContentAPIAdapter, args: UpdateGlobalVersionArgs) {\n // UpdateVersion requires either id OR where, not both\n if (args.id !== undefined) {\n return this.updateVersion({\n id: args.id,\n collection: getGlobalSlug(args.global),\n versionData: args.versionData,\n })\n }\n // args.where is guaranteed by Payload when args.id is undefined\n return this.updateVersion({\n collection: getGlobalSlug(args.global),\n versionData: args.versionData,\n where: args.where,\n })\n}\n\nfunction countGlobalVersions(this: ContentAPIAdapter, args: CountGlobalVersionArgs) {\n return this.countVersions({ collection: getGlobalSlug(args.global), where: args.where })\n}\n\nexport const contentAPIAdapter = (opts: ContentAPIOptions): DatabaseAdapterObj => ({\n name: 'content-api',\n defaultIDType: 'text',\n init: ({ payload }) => {\n const client = createClient<paths>({ baseUrl: opts.url })\n\n const middlewareOpts = {\n auth: opts.auth,\n contentSystemId: opts.contentSystemId,\n logger: payload.logger,\n url: opts.url,\n }\n\n client.use(createAuthMiddleware(middlewareOpts))\n client.use(createErrorMiddleware(middlewareOpts))\n\n return createDatabaseAdapter<ContentAPIAdapter>({\n name: 'content-api',\n auth: opts.auth,\n beginTransaction: () => Promise.resolve(null),\n client,\n commitTransaction: async () => {},\n contentSystemId: opts.contentSystemId,\n count: count as Count,\n countGlobalVersions: countGlobalVersions as CountGlobalVersions,\n countVersions: countVersions as CountVersions,\n create: create as Create,\n createGlobal: createGlobal as CreateGlobal,\n createGlobalVersion: createGlobalVersion as CreateGlobalVersion,\n createVersion: createVersion as CreateVersion,\n defaultIDType: 'text',\n deleteMany: deleteMany as DeleteMany,\n deleteOne: deleteOne as DeleteOne,\n deleteVersions: deleteVersions as DeleteVersions,\n find: find as Find,\n findDistinct: () =>\n Promise.reject(new Error('findDistinct is not yet implemented for Content API adapter')),\n findGlobal: findGlobal as FindGlobal,\n findGlobalVersions: findGlobalVersions as FindGlobalVersions,\n findOne: findOne as FindOne,\n findVersions: findVersions as FindVersions,\n init,\n packageName: '@payloadcms/db-content-api',\n payload,\n queryDrafts: queryDrafts as QueryDrafts,\n rollbackTransaction: async () => {},\n updateGlobal: updateGlobal as UpdateGlobal,\n updateGlobalVersion: updateGlobalVersion as UpdateGlobalVersion,\n updateMany: updateMany as UpdateMany,\n updateOne: updateOne as UpdateOne,\n updateVersion: updateVersion as UpdateVersion,\n upsert: upsert as Upsert,\n url: opts.url,\n })\n },\n})\n"],"names":["createClient","createDatabaseAdapter","v4","uuid","getGlobalSlug","addFallbackSort","unwrapDocument","unwrapFindResponse","createAuthMiddleware","createErrorMiddleware","dataToContentAPI","convertPayloadJoinsToContentAPI","buildMeta","convertPayloadWhereToContentAPI","init","auth","mode","payload","logger","info","process","env","PAYLOAD_DROP_DATABASE","contentSystemId","fetch","url","body","JSON","stringify","headers","method","error","warn","message","existingIds","data","response","client","GET","params","path","Error","Set","map","c","id","size","collection","config","collections","has","slug","createCollection","call","global","globals","globalId","collectionId","POST","errorMessage","includes","findMany","joins","limit","locale","page","pagination","sort","where","localization","effectiveLocale","defaultLocale","undefined","join","result","find","args","collectionConfig","defaultSort","findVersions","sortWithFallback","whereClause","parentToDocumentId","queryDrafts","versionsResult","latest","equals","docs","versionDoc","version","versionMeta","createVersion","collectionSlug","autosave","parent","String","versionData","applyDefaults","updateVersion","createOnMissing","doc","deleteVersions","findOne","updateMany","returning","updateOne","deleteMany","deleteOne","create","createdAt","count","totalDocs","countVersions","upsert","documentId","idClause","createGlobal","globalType","findGlobal","updateGlobal","findGlobalVersions","createGlobalVersion","globalSlug","updatedAt","updateGlobalVersion","countGlobalVersions","contentAPIAdapter","opts","name","defaultIDType","baseUrl","middlewareOpts","use","beginTransaction","Promise","resolve","commitTransaction","findDistinct","reject","packageName","rollbackTransaction"],"mappings":"AAgDA,OAAOA,kBAAkB,gBAAe;AACx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,MAAM0D,oBAAoB,CAACC,OAAiD,CAAA;QACjFC,MAAM;QACNC,eAAe;QACfnH,MAAM,CAAC,EAAEG,OAAO,EAAE;YAChB,MAAMoB,SAASrC,aAAoB;gBAAEkI,SAASH,KAAKtG,GAAG;YAAC;YAEvD,MAAM0G,iBAAiB;gBACrBpH,MAAMgH,KAAKhH,IAAI;gBACfQ,iBAAiBwG,KAAKxG,eAAe;gBACrCL,QAAQD,QAAQC,MAAM;gBACtBO,KAAKsG,KAAKtG,GAAG;YACf;YAEAY,OAAO+F,GAAG,CAAC5H,qBAAqB2H;YAChC9F,OAAO+F,GAAG,CAAC3H,sBAAsB0H;YAEjC,OAAOlI,sBAAyC;gBAC9C+H,MAAM;gBACNjH,MAAMgH,KAAKhH,IAAI;gBACfsH,kBAAkB,IAAMC,QAAQC,OAAO,CAAC;gBACxClG;gBACAmG,mBAAmB,WAAa;gBAChCjH,iBAAiBwG,KAAKxG,eAAe;gBACrCuF,OAAOA;gBACPe,qBAAqBA;gBACrBb,eAAeA;gBACfJ,QAAQA;gBACRQ,cAAcA;gBACdK,qBAAqBA;gBACrB9B,eAAeA;gBACfsC,eAAe;gBACfvB,YAAYA;gBACZC,WAAWA;gBACXN,gBAAgBA;gBAChB1B,MAAMA;gBACN8D,cAAc,IACZH,QAAQI,MAAM,CAAC,IAAIjG,MAAM;gBAC3B6E,YAAYA;gBACZE,oBAAoBA;gBACpBlB,SAASA;gBACTvB,cAAcA;gBACdjE;gBACA6H,aAAa;gBACb1H;gBACAkE,aAAaA;gBACbyD,qBAAqB,WAAa;gBAClCrB,cAAcA;gBACdK,qBAAqBA;gBACrBrB,YAAYA;gBACZE,WAAWA;gBACXP,eAAeA;gBACfe,QAAQA;gBACRxF,KAAKsG,KAAKtG,GAAG;YACf;QACF;IACF,CAAA,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"castFieldValue.d.ts","sourceRoot":"","sources":["../../../../src/db-content-api/utilities/data/castFieldValue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEhD;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,UAAU,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"castFieldValue.d.ts","sourceRoot":"","sources":["../../../../src/db-content-api/utilities/data/castFieldValue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEhD;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,UAAU,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAwEjF"}
|
|
@@ -56,7 +56,10 @@
|
|
|
56
56
|
}
|
|
57
57
|
// Text-like fields: convert non-strings to JSON strings
|
|
58
58
|
// This handles text, textarea, email, and code fields
|
|
59
|
-
|
|
59
|
+
// EXCEPTIONS:
|
|
60
|
+
// - Localized fields are stored as objects like {"en": "value", "es": "valor"}
|
|
61
|
+
// - hasMany fields are stored as arrays like ["value1", "value2"]
|
|
62
|
+
if ((field.type === 'text' || field.type === 'textarea' || field.type === 'email' || field.type === 'code') && typeof value !== 'string' && !('localized' in field && field.localized) && !('hasMany' in field && field.hasMany && Array.isArray(value))) {
|
|
60
63
|
return JSON.stringify(value);
|
|
61
64
|
}
|
|
62
65
|
// No casting needed for other types or already correct types
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/db-content-api/utilities/data/castFieldValue.ts"],"sourcesContent":["import type { Field, TabAsField } from 'payload'\n\n/**\n * Cast field values to the appropriate type for Content API storage.\n *\n * This function implements type coercion similar to Mongoose (used by MongoDB adapter)\n * to ensure data consistency. When users ignore TypeScript types and pass incorrect types,\n * we automatically convert them to the expected type.\n *\n */\nexport function castFieldValue(field: Field | TabAsField, value: unknown): unknown {\n if (value === null || value === undefined) {\n return value\n }\n\n if (field.type === 'number') {\n // Handle hasMany: true - array of numbers\n if ('hasMany' in field && field.hasMany && Array.isArray(value)) {\n return value.map((item) => {\n if (typeof item === 'number') {\n return item\n }\n if (typeof item === 'string' || typeof item === 'boolean') {\n return Number(item)\n }\n return item // Pass through other types (will likely fail validation)\n })\n }\n\n // Handle single number\n if (typeof value !== 'number') {\n if (typeof value === 'string' || typeof value === 'boolean') {\n return Number(value)\n }\n // For objects/arrays (when not hasMany), return as-is (will likely fail validation later)\n return value\n }\n }\n\n if (field.type === 'checkbox' && typeof value !== 'boolean') {\n if (typeof value === 'string') {\n if (value.toLowerCase() === 'true' || value === '1') {\n return true\n }\n if (value.toLowerCase() === 'false' || value === '0' || value === '') {\n return false\n }\n }\n return Boolean(value)\n }\n\n // Matches Mongoose behavior: stores dates as ISO strings\n if (field.type === 'date' && typeof value !== 'string') {\n if (value instanceof Date) {\n return value.toISOString()\n }\n if (typeof value === 'number') {\n return new Date(value).toISOString()\n }\n // For other types, return as-is (will likely fail validation)\n return value\n }\n\n // Text-like fields: convert non-strings to JSON strings\n // This handles text, textarea, email, and code fields\n if (\n (field.type === 'text' ||\n field.type === 'textarea' ||\n field.type === 'email' ||\n field.type === 'code') &&\n typeof value !== 'string'\n ) {\n return JSON.stringify(value)\n }\n\n // No casting needed for other types or already correct types\n return value\n}\n"],"names":["castFieldValue","field","value","undefined","type","hasMany","Array","isArray","map","item","Number","toLowerCase","Boolean","Date","toISOString","JSON","stringify"],"mappings":"AAEA;;;;;;;CAOC,GACD,OAAO,SAASA,eAAeC,KAAyB,EAAEC,KAAc;IACtE,IAAIA,UAAU,QAAQA,UAAUC,WAAW;QACzC,OAAOD;IACT;IAEA,IAAID,MAAMG,IAAI,KAAK,UAAU;QAC3B,0CAA0C;QAC1C,IAAI,aAAaH,SAASA,MAAMI,OAAO,IAAIC,MAAMC,OAAO,CAACL,QAAQ;YAC/D,OAAOA,MAAMM,GAAG,CAAC,CAACC;gBAChB,IAAI,OAAOA,SAAS,UAAU;oBAC5B,OAAOA;gBACT;gBACA,IAAI,OAAOA,SAAS,YAAY,OAAOA,SAAS,WAAW;oBACzD,OAAOC,OAAOD;gBAChB;gBACA,OAAOA,KAAK,yDAAyD;;YACvE;QACF;QAEA,uBAAuB;QACvB,IAAI,OAAOP,UAAU,UAAU;YAC7B,IAAI,OAAOA,UAAU,YAAY,OAAOA,UAAU,WAAW;gBAC3D,OAAOQ,OAAOR;YAChB;YACA,0FAA0F;YAC1F,OAAOA;QACT;IACF;IAEA,IAAID,MAAMG,IAAI,KAAK,cAAc,OAAOF,UAAU,WAAW;QAC3D,IAAI,OAAOA,UAAU,UAAU;YAC7B,IAAIA,MAAMS,WAAW,OAAO,UAAUT,UAAU,KAAK;gBACnD,OAAO;YACT;YACA,IAAIA,MAAMS,WAAW,OAAO,WAAWT,UAAU,OAAOA,UAAU,IAAI;gBACpE,OAAO;YACT;QACF;QACA,OAAOU,QAAQV;IACjB;IAEA,yDAAyD;IACzD,IAAID,MAAMG,IAAI,KAAK,UAAU,OAAOF,UAAU,UAAU;QACtD,IAAIA,iBAAiBW,MAAM;YACzB,OAAOX,MAAMY,WAAW;QAC1B;QACA,IAAI,OAAOZ,UAAU,UAAU;YAC7B,OAAO,IAAIW,KAAKX,OAAOY,WAAW;QACpC;QACA,8DAA8D;QAC9D,OAAOZ;IACT;IAEA,wDAAwD;IACxD,sDAAsD;IACtD,IACE,AAACD,CAAAA,MAAMG,IAAI,KAAK,UACdH,MAAMG,IAAI,KAAK,cACfH,MAAMG,IAAI,KAAK,WACfH,MAAMG,IAAI,KAAK,MAAK,KACtB,OAAOF,UAAU,
|
|
1
|
+
{"version":3,"sources":["../../../../src/db-content-api/utilities/data/castFieldValue.ts"],"sourcesContent":["import type { Field, TabAsField } from 'payload'\n\n/**\n * Cast field values to the appropriate type for Content API storage.\n *\n * This function implements type coercion similar to Mongoose (used by MongoDB adapter)\n * to ensure data consistency. When users ignore TypeScript types and pass incorrect types,\n * we automatically convert them to the expected type.\n *\n */\nexport function castFieldValue(field: Field | TabAsField, value: unknown): unknown {\n if (value === null || value === undefined) {\n return value\n }\n\n if (field.type === 'number') {\n // Handle hasMany: true - array of numbers\n if ('hasMany' in field && field.hasMany && Array.isArray(value)) {\n return value.map((item) => {\n if (typeof item === 'number') {\n return item\n }\n if (typeof item === 'string' || typeof item === 'boolean') {\n return Number(item)\n }\n return item // Pass through other types (will likely fail validation)\n })\n }\n\n // Handle single number\n if (typeof value !== 'number') {\n if (typeof value === 'string' || typeof value === 'boolean') {\n return Number(value)\n }\n // For objects/arrays (when not hasMany), return as-is (will likely fail validation later)\n return value\n }\n }\n\n if (field.type === 'checkbox' && typeof value !== 'boolean') {\n if (typeof value === 'string') {\n if (value.toLowerCase() === 'true' || value === '1') {\n return true\n }\n if (value.toLowerCase() === 'false' || value === '0' || value === '') {\n return false\n }\n }\n return Boolean(value)\n }\n\n // Matches Mongoose behavior: stores dates as ISO strings\n if (field.type === 'date' && typeof value !== 'string') {\n if (value instanceof Date) {\n return value.toISOString()\n }\n if (typeof value === 'number') {\n return new Date(value).toISOString()\n }\n // For other types, return as-is (will likely fail validation)\n return value\n }\n\n // Text-like fields: convert non-strings to JSON strings\n // This handles text, textarea, email, and code fields\n // EXCEPTIONS:\n // - Localized fields are stored as objects like {\"en\": \"value\", \"es\": \"valor\"}\n // - hasMany fields are stored as arrays like [\"value1\", \"value2\"]\n if (\n (field.type === 'text' ||\n field.type === 'textarea' ||\n field.type === 'email' ||\n field.type === 'code') &&\n typeof value !== 'string' &&\n !('localized' in field && field.localized) &&\n !('hasMany' in field && field.hasMany && Array.isArray(value))\n ) {\n return JSON.stringify(value)\n }\n\n // No casting needed for other types or already correct types\n return value\n}\n"],"names":["castFieldValue","field","value","undefined","type","hasMany","Array","isArray","map","item","Number","toLowerCase","Boolean","Date","toISOString","localized","JSON","stringify"],"mappings":"AAEA;;;;;;;CAOC,GACD,OAAO,SAASA,eAAeC,KAAyB,EAAEC,KAAc;IACtE,IAA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,WACfH,MAAMG,IAAI,KAAK,MAAK,KACtB,OAAOF,UAAU,YACjB,CAAE,CAAA,eAAeD,SAASA,MAAMc,SAAS,AAAD,KACxC,CAAE,CAAA,aAAad,SAASA,MAAMI,OAAO,IAAIC,MAAMC,OAAO,CAACL,MAAK,GAC5D;QACA,OAAOc,KAAKC,SAAS,CAACf;IACxB;IAEA,6DAA6D;IAC7D,OAAOA;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/db-content-api/utilities/data/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkC,OAAO,EAA0B,MAAM,SAAS,CAAA;AAI9F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAA;AAOtE,KAAK,kBAAkB,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,oBAAoB,CAAC,CAAA;AAErE;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,MAAM,EACtB,IAAI,EAAE,OAAO,EACb,OAAO,CAAC,EAAE;IAAE,aAAa,CAAC,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,GACzD,kBAAkB,CA8EpB;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,MAAM,EACtB,IAAI,EAAE,OAAO,GACZ,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/db-content-api/utilities/data/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkC,OAAO,EAA0B,MAAM,SAAS,CAAA;AAI9F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAA;AAOtE,KAAK,kBAAkB,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,oBAAoB,CAAC,CAAA;AAErE;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,MAAM,EACtB,IAAI,EAAE,OAAO,EACb,OAAO,CAAC,EAAE;IAAE,aAAa,CAAC,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,GACzD,kBAAkB,CA8EpB;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,MAAM,EACtB,IAAI,EAAE,OAAO,GACZ,OAAO,CAyGT"}
|
|
@@ -130,8 +130,21 @@ import { stripFields } from './stripFields.js';
|
|
|
130
130
|
return;
|
|
131
131
|
}
|
|
132
132
|
if (value !== null) {
|
|
133
|
-
//
|
|
134
|
-
|
|
133
|
+
// Localized fields: JSON string -> parsed object
|
|
134
|
+
// Content API may store localized fields as JSON strings like "{\"en\":\"value\"}"
|
|
135
|
+
// so we need to parse them back to objects.
|
|
136
|
+
// Note: We return the full locale object - Payload Core handles flattening to requested locale.
|
|
137
|
+
if ('localized' in field && field.localized && typeof value === 'string') {
|
|
138
|
+
try {
|
|
139
|
+
current[field.name] = JSON.parse(value);
|
|
140
|
+
} catch (error) {
|
|
141
|
+
const fieldPath = parentPath ? `${parentPath}.${field.name}` : field.name;
|
|
142
|
+
payload.logger.warn({
|
|
143
|
+
err: error instanceof Error ? error : new Error(String(error)),
|
|
144
|
+
msg: `Failed to parse localized field '${fieldPath}' in collection '${collectionSlug}'`
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
} else if (field.type === 'richText' && typeof value === 'string') {
|
|
135
148
|
try {
|
|
136
149
|
current[field.name] = JSON.parse(value);
|
|
137
150
|
} catch (error) {
|
|
@@ -1 +1 @@
|
|
|
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 * - Timestamps: Add updatedAt (always), and createdAt (when createdAt=true)\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; createdAt?: 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 // Add timestamps (Content API no longer auto-sets these in DB)\n // updatedAt is always set, createdAt only on create operations\n const now = new Date().toISOString()\n transformed.updatedAt = now\n if (options?.createdAt) {\n transformed.createdAt = now\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 // Normalize undefined → null for optional fields\n // Content API may omit fields (undefined) but Payload expects null for optional fields\n if (value === undefined) {\n const isRequired = 'required' in field && field.required\n if (!isRequired) {\n current[field.name] = null\n }\n return\n }\n\n if (value !== null) {\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","now","Date","toISOString","updatedAt","createdAt","dataFromContentAPI","parentPath","isRequired","required","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;;;;;;;;;;;CAWC,GACD,OAAO,SAASC,iBACdC,OAAgB,EAChBC,cAAsB,EACtBC,IAAa,EACbC,OAA0D;IAE1D,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,UAAU;YACnC;QACF;QAEA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AKJ,iBAAiBK,QAAQL,QAAQ,IAAIK,MAAMf,OAAOU;wBACvDM,KAAK,CAAC,gCAAgC,EAAEL,UAAU,iBAAiB,EAAE5C,eAAe,CAAC,CAAC;oBACxF;gBACF;YACF;QACA,0EAA0E;QAC5E;IACF;IAEAP,eAAe;QAAE2B;QAAUD,QAAQR,iBAAiBQ,MAAM;QAAEG,KAAKnB;IAAY;IAE7E,mEAAmE;IACnE,MAAM4B,eAAehC,QAAQkB,WAAW,EAAE,CAACjB,eAAe,EAAE+B;IAC5D,IAAIA,iBAAiB,UAAU;QAC7B5B,YAAY6B,EAAE,GAAGkB,OAAO/C,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,iBAAiBwC,IAAI,EAAE;QACvD,MAAMC,aAAa;YAAC;YAA2B;SAAY;QAC3D,KAAK,MAAMC,aAAaD,WAAY;YAClC,IAAI,CAAEC,CAAAA,aAAalD,WAAU,GAAI;gBAC/BA,WAAW,CAACkD,UAAU,GAAG;YAC3B;QACF;IACF;IAEA,OAAOlD;AACT"}
|
|
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 * - Timestamps: Add updatedAt (always), and createdAt (when createdAt=true)\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; createdAt?: 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 // Add timestamps (Content API no longer auto-sets these in DB)\n // updatedAt is always set, createdAt only on create operations\n const now = new Date().toISOString()\n transformed.updatedAt = now\n if (options?.createdAt) {\n transformed.createdAt = now\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 // Normalize undefined → null for optional fields\n // Content API may omit fields (undefined) but Payload expects null for optional fields\n if (value === undefined) {\n const isRequired = 'required' in field && field.required\n if (!isRequired) {\n current[field.name] = null\n }\n return\n }\n\n if (value !== null) {\n // Localized fields: JSON string -> parsed object\n // Content API may store localized fields as JSON strings like \"{\\\"en\\\":\\\"value\\\"}\"\n // so we need to parse them back to objects.\n // Note: We return the full locale object - Payload Core handles flattening to requested locale.\n if ('localized' in field && field.localized && 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 localized field '${fieldPath}' in collection '${collectionSlug}'`,\n })\n }\n }\n // RichText: JSON string -> object\n else 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","now","Date","toISOString","updatedAt","createdAt","dataFromContentAPI","parentPath","isRequired","required","localized","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;;;;;;;;;;;CAWC,GACD,OAAO,SAASC,iBACdC,OAAgB,EAChBC,cAAsB,EACtBC,IAAa,EACbC,OAA0D;IAE1D,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;IAC9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AiBQ,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,iBAAiByC,IAAI,EAAE;QACvD,MAAMC,aAAa;YAAC;YAA2B;SAAY;QAC3D,KAAK,MAAMC,aAAaD,WAAY;YAClC,IAAI,CAAEC,CAAAA,aAAanD,WAAU,GAAI;gBAC/BA,WAAW,CAACmD,UAAU,GAAG;YAC3B;QACF;IACF;IAEA,OAAOnD;AACT"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Payload } from 'payload';
|
|
2
|
+
/**
|
|
3
|
+
* Extracts all localized field paths from a collection's field configuration.
|
|
4
|
+
* Recursively traverses nested structures (groups, arrays, blocks, tabs) to find fields marked as localized.
|
|
5
|
+
*
|
|
6
|
+
* @param payload - The Payload instance containing collection configurations
|
|
7
|
+
* @param collectionSlug - The slug of the collection to extract localized paths from
|
|
8
|
+
* @returns Array of dot-notation paths to localized fields (e.g., ['title', 'metadata.description'])
|
|
9
|
+
*/
|
|
10
|
+
export declare function buildLocalizedPaths(payload: Payload, collectionSlug: string): string[];
|
|
11
|
+
//# sourceMappingURL=buildLocalizedPaths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildLocalizedPaths.d.ts","sourceRoot":"","sources":["../../../../src/db-content-api/utilities/meta/buildLocalizedPaths.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,OAAO,EAAE,MAAM,SAAS,CAAA;AAE7C;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,GAAG,MAAM,EAAE,CAStF"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extracts all localized field paths from a collection's field configuration.
|
|
3
|
+
* Recursively traverses nested structures (groups, arrays, blocks, tabs) to find fields marked as localized.
|
|
4
|
+
*
|
|
5
|
+
* @param payload - The Payload instance containing collection configurations
|
|
6
|
+
* @param collectionSlug - The slug of the collection to extract localized paths from
|
|
7
|
+
* @returns Array of dot-notation paths to localized fields (e.g., ['title', 'metadata.description'])
|
|
8
|
+
*/ export function buildLocalizedPaths(payload, collectionSlug) {
|
|
9
|
+
const collectionConfig = payload.config.collections.find((c)=>c.slug === collectionSlug);
|
|
10
|
+
if (!collectionConfig) {
|
|
11
|
+
return [];
|
|
12
|
+
}
|
|
13
|
+
const localizedPaths = [];
|
|
14
|
+
traverseFields(collectionConfig.fields, localizedPaths);
|
|
15
|
+
return localizedPaths;
|
|
16
|
+
}
|
|
17
|
+
/** Recursively traverses fields to find and collect localized paths */ function traverseFields(fields, localizedPaths, parentPath = '', parentIsLocalized = false) {
|
|
18
|
+
for (const field of fields){
|
|
19
|
+
// Only field types that have names can support localization
|
|
20
|
+
// See: https://payloadcms.com/docs/configuration/localization
|
|
21
|
+
//
|
|
22
|
+
// This will skip presentational fields like ui, collapsible, row, tabs (if unnamed), groups (if unnamed)
|
|
23
|
+
// which do not store data in the database and thus are not relevant for querying localized paths
|
|
24
|
+
// See: https://payloadcms.com/docs/fields/overview#presentational-fields
|
|
25
|
+
if (!('name' in field)) {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
const fieldPath = buildPath(parentPath, field.name);
|
|
29
|
+
const isLocalized = 'localized' in field && field.localized === true;
|
|
30
|
+
const includeNestedPaths = isLocalized || parentIsLocalized;
|
|
31
|
+
// Add field to results if localized or parent is localized
|
|
32
|
+
if (includeNestedPaths) {
|
|
33
|
+
localizedPaths.push(fieldPath);
|
|
34
|
+
}
|
|
35
|
+
// Handle blocks field - has a special 'blocks' array structure and each block has its own nested fields
|
|
36
|
+
if (field.type === 'blocks' && 'blocks' in field) {
|
|
37
|
+
for (const block of field.blocks){
|
|
38
|
+
if ('fields' in block) {
|
|
39
|
+
traverseFields(block.fields, localizedPaths, fieldPath, includeNestedPaths);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
// Handle field type that support nested fields
|
|
45
|
+
// Recursively handle nested structures (groups, arrays, tab, etc)
|
|
46
|
+
if ('fields' in field) {
|
|
47
|
+
traverseFields(field.fields, localizedPaths, fieldPath, includeNestedPaths);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/** Builds a dot-notation path from parent path and field name */ function buildPath(parentPath, fieldName) {
|
|
52
|
+
return parentPath ? `${parentPath}.${fieldName}` : fieldName;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
//# sourceMappingURL=buildLocalizedPaths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/db-content-api/utilities/meta/buildLocalizedPaths.ts"],"sourcesContent":["import type { Field, Payload } from 'payload'\n\n/**\n * Extracts all localized field paths from a collection's field configuration.\n * Recursively traverses nested structures (groups, arrays, blocks, tabs) to find fields marked as localized.\n *\n * @param payload - The Payload instance containing collection configurations\n * @param collectionSlug - The slug of the collection to extract localized paths from\n * @returns Array of dot-notation paths to localized fields (e.g., ['title', 'metadata.description'])\n */\nexport function buildLocalizedPaths(payload: Payload, collectionSlug: string): string[] {\n const collectionConfig = payload.config.collections.find((c) => c.slug === collectionSlug)\n if (!collectionConfig) {\n return []\n }\n\n const localizedPaths: string[] = []\n traverseFields(collectionConfig.fields, localizedPaths)\n return localizedPaths\n}\n\n/** Recursively traverses fields to find and collect localized paths */\nfunction traverseFields(\n fields: Field[],\n localizedPaths: string[],\n parentPath = '',\n parentIsLocalized = false,\n): void {\n for (const field of fields) {\n // Only field types that have names can support localization\n // See: https://payloadcms.com/docs/configuration/localization\n //\n // This will skip presentational fields like ui, collapsible, row, tabs (if unnamed), groups (if unnamed)\n // which do not store data in the database and thus are not relevant for querying localized paths\n // See: https://payloadcms.com/docs/fields/overview#presentational-fields\n if (!('name' in field)) {\n continue\n }\n\n const fieldPath = buildPath(parentPath, field.name)\n const isLocalized = 'localized' in field && field.localized === true\n const includeNestedPaths = isLocalized || parentIsLocalized\n\n // Add field to results if localized or parent is localized\n if (includeNestedPaths) {\n localizedPaths.push(fieldPath)\n }\n\n // Handle blocks field - has a special 'blocks' array structure and each block has its own nested fields\n if (field.type === 'blocks' && 'blocks' in field) {\n for (const block of field.blocks) {\n if ('fields' in block) {\n traverseFields(block.fields, localizedPaths, fieldPath, includeNestedPaths)\n }\n }\n continue\n }\n\n // Handle field type that support nested fields\n // Recursively handle nested structures (groups, arrays, tab, etc)\n if ('fields' in field) {\n traverseFields(field.fields, localizedPaths, fieldPath, includeNestedPaths)\n }\n }\n}\n\n/** Builds a dot-notation path from parent path and field name */\nfunction buildPath(parentPath: string, fieldName: string): string {\n return parentPath ? `${parentPath}.${fieldName}` : fieldName\n}\n"],"names":["buildLocalizedPaths","payload","collectionSlug","collectionConfig","config","collections","find","c","slug","localizedPaths","traverseFields","fields","parentPath","parentIsLocalized","field","fieldPath","buildPath","name","isLocalized","localized","includeNestedPaths","push","type","block","blocks","fieldName"],"mappings":"AAEA;;;;;;;CAOC,GACD,OAAO,SAASA,oBAAoBC,OAAgB,EAAEC,cAAsB;IAC1E,MAAMC,mBAAmBF,QAAQG,MAAM,CAACC,WAAW,CAACC,IAAI,CAAC,CAACC,IAAMA,EAAEC,IAAI,KAAKN;IAC3E,IAAI,CAACC,kBAAkB;QACrB,OAAO,EAAE;IACX;IAEA,MAAMM,iBAA2B,EAAE;IACnCC,eAAeP,iBAAiBQ,MAAM,EAAEF;IACxC,OAAOA;AACT;AAEA,qEAAqE,GACrE,SAASC,eACPC,MAAe,EACfF,cAAwB,EACxBG,aAAa,EAAE,EACfC,oBAAoB,KAAK;IAEzB,KAAK,MAAMC,SAASH,OAAQ;QAC1B,4DAA4D;QAC5D,8DAA8D;QAC9D,EAAE;QACF,yGAA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