payload 3.55.0-internal.d44d1d3 → 3.55.0-internal.df60e35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/dist/admin/fields/Row.d.ts +4 -2
  2. package/dist/admin/fields/Row.d.ts.map +1 -1
  3. package/dist/admin/fields/Row.js.map +1 -1
  4. package/dist/admin/forms/Field.d.ts +0 -7
  5. package/dist/admin/forms/Field.d.ts.map +1 -1
  6. package/dist/admin/forms/Field.js.map +1 -1
  7. package/dist/admin/functions/index.d.ts +0 -25
  8. package/dist/admin/functions/index.d.ts.map +1 -1
  9. package/dist/admin/functions/index.js.map +1 -1
  10. package/dist/auth/operations/resetPassword.d.ts.map +1 -1
  11. package/dist/auth/operations/resetPassword.js +12 -1
  12. package/dist/auth/operations/resetPassword.js.map +1 -1
  13. package/dist/collections/endpoints/findByID.d.ts.map +1 -1
  14. package/dist/collections/endpoints/findByID.js +5 -4
  15. package/dist/collections/endpoints/findByID.js.map +1 -1
  16. package/dist/collections/operations/create.d.ts.map +1 -1
  17. package/dist/collections/operations/create.js +1 -0
  18. package/dist/collections/operations/create.js.map +1 -1
  19. package/dist/collections/operations/findByID.d.ts +5 -0
  20. package/dist/collections/operations/findByID.d.ts.map +1 -1
  21. package/dist/collections/operations/findByID.js +1 -1
  22. package/dist/collections/operations/findByID.js.map +1 -1
  23. package/dist/collections/operations/local/findByID.d.ts +5 -0
  24. package/dist/collections/operations/local/findByID.d.ts.map +1 -1
  25. package/dist/collections/operations/local/findByID.js +2 -1
  26. package/dist/collections/operations/local/findByID.js.map +1 -1
  27. package/dist/collections/operations/utilities/update.d.ts.map +1 -1
  28. package/dist/collections/operations/utilities/update.js +1 -0
  29. package/dist/collections/operations/utilities/update.js.map +1 -1
  30. package/dist/config/client.d.ts.map +1 -1
  31. package/dist/config/client.js +8 -0
  32. package/dist/config/client.js.map +1 -1
  33. package/dist/config/defaults.d.ts.map +1 -1
  34. package/dist/config/defaults.js +2 -0
  35. package/dist/config/defaults.js.map +1 -1
  36. package/dist/config/types.d.ts +14 -0
  37. package/dist/config/types.d.ts.map +1 -1
  38. package/dist/config/types.js.map +1 -1
  39. package/dist/database/types.d.ts +2 -0
  40. package/dist/database/types.d.ts.map +1 -1
  41. package/dist/database/types.js.map +1 -1
  42. package/dist/exports/shared.d.ts +0 -1
  43. package/dist/exports/shared.d.ts.map +1 -1
  44. package/dist/exports/shared.js +0 -1
  45. package/dist/exports/shared.js.map +1 -1
  46. package/dist/folders/types.d.ts +2 -2
  47. package/dist/folders/types.d.ts.map +1 -1
  48. package/dist/folders/types.js.map +1 -1
  49. package/dist/globals/operations/update.d.ts.map +1 -1
  50. package/dist/globals/operations/update.js +1 -0
  51. package/dist/globals/operations/update.js.map +1 -1
  52. package/dist/index.d.ts +0 -1
  53. package/dist/index.d.ts.map +1 -1
  54. package/dist/index.js.map +1 -1
  55. package/dist/utilities/handleEndpoints.d.ts.map +1 -1
  56. package/dist/utilities/handleEndpoints.js +30 -10
  57. package/dist/utilities/handleEndpoints.js.map +1 -1
  58. package/dist/versions/baseFields.d.ts +2 -0
  59. package/dist/versions/baseFields.d.ts.map +1 -1
  60. package/dist/versions/baseFields.js +23 -0
  61. package/dist/versions/baseFields.js.map +1 -1
  62. package/dist/versions/buildCollectionFields.d.ts.map +1 -1
  63. package/dist/versions/buildCollectionFields.js +16 -1
  64. package/dist/versions/buildCollectionFields.js.map +1 -1
  65. package/dist/versions/buildGlobalFields.d.ts.map +1 -1
  66. package/dist/versions/buildGlobalFields.js +16 -1
  67. package/dist/versions/buildGlobalFields.js.map +1 -1
  68. package/dist/versions/drafts/replaceWithDraftIfAvailable.d.ts.map +1 -1
  69. package/dist/versions/drafts/replaceWithDraftIfAvailable.js +6 -0
  70. package/dist/versions/drafts/replaceWithDraftIfAvailable.js.map +1 -1
  71. package/dist/versions/saveVersion.d.ts +2 -1
  72. package/dist/versions/saveVersion.d.ts.map +1 -1
  73. package/dist/versions/saveVersion.js +64 -31
  74. package/dist/versions/saveVersion.js.map +1 -1
  75. package/dist/versions/types.d.ts +1 -0
  76. package/dist/versions/types.d.ts.map +1 -1
  77. package/dist/versions/types.js.map +1 -1
  78. package/package.json +2 -2
  79. package/dist/utilities/fieldSchemaToJSON.d.ts +0 -14
  80. package/dist/utilities/fieldSchemaToJSON.d.ts.map +0 -1
  81. package/dist/utilities/fieldSchemaToJSON.js +0 -91
  82. package/dist/utilities/fieldSchemaToJSON.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/collections/operations/findByID.ts"],"sourcesContent":["import type { FindOneArgs } from '../../database/types.js'\nimport type { CollectionSlug, JoinQuery } from '../../index.js'\nimport type {\n ApplyDisableErrors,\n JsonObject,\n PayloadRequest,\n PopulateType,\n SelectType,\n TransformCollectionWithSelect,\n} from '../../types/index.js'\nimport type {\n Collection,\n DataFromCollectionSlug,\n SelectFromCollectionSlug,\n TypeWithID,\n} from '../config/types.js'\n\nimport { executeAccess } from '../../auth/executeAccess.js'\nimport { combineQueries } from '../../database/combineQueries.js'\nimport { sanitizeJoinQuery } from '../../database/sanitizeJoinQuery.js'\nimport { sanitizeWhereQuery } from '../../database/sanitizeWhereQuery.js'\nimport { NotFound } from '../../errors/index.js'\nimport { afterRead } from '../../fields/hooks/afterRead/index.js'\nimport { validateQueryPaths } from '../../index.js'\nimport { lockedDocumentsCollectionSlug } from '../../locked-documents/config.js'\nimport { appendNonTrashedFilter } from '../../utilities/appendNonTrashedFilter.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport { sanitizeSelect } from '../../utilities/sanitizeSelect.js'\nimport { replaceWithDraftIfAvailable } from '../../versions/drafts/replaceWithDraftIfAvailable.js'\nimport { buildAfterOperation } from './utils.js'\n\nexport type Arguments = {\n collection: Collection\n currentDepth?: number\n depth?: number\n disableErrors?: boolean\n draft?: boolean\n id: number | string\n includeLockStatus?: boolean\n joins?: JoinQuery\n overrideAccess?: boolean\n populate?: PopulateType\n req: PayloadRequest\n select?: SelectType\n showHiddenFields?: boolean\n trash?: boolean\n}\n\nexport const findByIDOperation = async <\n TSlug extends CollectionSlug,\n TDisableErrors extends boolean,\n TSelect extends SelectFromCollectionSlug<TSlug>,\n>(\n incomingArgs: Arguments,\n): Promise<ApplyDisableErrors<TransformCollectionWithSelect<TSlug, TSelect>, TDisableErrors>> => {\n let args = incomingArgs\n\n try {\n // /////////////////////////////////////\n // beforeOperation - Collection\n // /////////////////////////////////////\n\n if (args.collection.config.hooks?.beforeOperation?.length) {\n for (const hook of args.collection.config.hooks.beforeOperation) {\n args =\n (await hook({\n args,\n collection: args.collection.config,\n context: args.req.context,\n operation: 'read',\n req: args.req,\n })) || args\n }\n }\n\n const {\n id,\n collection: { config: collectionConfig },\n currentDepth,\n depth,\n disableErrors,\n draft: draftEnabled = false,\n includeLockStatus,\n joins,\n overrideAccess = false,\n populate,\n req: { fallbackLocale, locale, t },\n req,\n select: incomingSelect,\n showHiddenFields,\n trash = false,\n } = args\n\n const select = sanitizeSelect({\n fields: collectionConfig.flattenedFields,\n forceSelect: collectionConfig.forceSelect,\n select: incomingSelect,\n })\n\n // /////////////////////////////////////\n // Access\n // /////////////////////////////////////\n\n const accessResult = !overrideAccess\n ? await executeAccess({ id, disableErrors, req }, collectionConfig.access.read)\n : true\n\n // If errors are disabled, and access returns false, return null\n if (accessResult === false) {\n return null!\n }\n\n const where = { id: { equals: id } }\n\n let fullWhere = combineQueries(where, accessResult)\n\n // Exclude trashed documents when trash: false\n fullWhere = appendNonTrashedFilter({\n enableTrash: collectionConfig.trash,\n trash,\n where: fullWhere,\n })\n\n sanitizeWhereQuery({\n fields: collectionConfig.flattenedFields,\n payload: args.req.payload,\n where: fullWhere,\n })\n\n const sanitizedJoins = await sanitizeJoinQuery({\n collectionConfig,\n joins,\n overrideAccess,\n req,\n })\n\n const findOneArgs: FindOneArgs = {\n collection: collectionConfig.slug,\n draftsEnabled: draftEnabled,\n joins: req.payloadAPI === 'GraphQL' ? false : sanitizedJoins,\n locale: locale!,\n req: {\n transactionID: req.transactionID,\n } as PayloadRequest,\n select,\n where: fullWhere,\n }\n\n // execute only if there's a custom ID and potentially overwriten access on id\n if (req.payload.collections[collectionConfig.slug]!.customIDType) {\n await validateQueryPaths({\n collectionConfig,\n overrideAccess,\n req,\n where,\n })\n }\n // /////////////////////////////////////\n // Find by ID\n // /////////////////////////////////////\n\n if (!findOneArgs.where?.and?.[0]?.id) {\n throw new NotFound(t)\n }\n\n let result: DataFromCollectionSlug<TSlug> = (await req.payload.db.findOne(findOneArgs))!\n\n if (!result) {\n if (!disableErrors) {\n throw new NotFound(req.t)\n }\n\n return null!\n }\n\n // /////////////////////////////////////\n // Include Lock Status if required\n // /////////////////////////////////////\n\n if (includeLockStatus && id) {\n let lockStatus: (JsonObject & TypeWithID) | null = null\n\n try {\n const lockDocumentsProp = collectionConfig?.lockDocuments\n\n const lockDurationDefault = 300 // Default 5 minutes in seconds\n const lockDuration =\n typeof lockDocumentsProp === 'object' ? lockDocumentsProp.duration : lockDurationDefault\n const lockDurationInMilliseconds = lockDuration * 1000\n\n const lockedDocument = await req.payload.find({\n collection: lockedDocumentsCollectionSlug,\n depth: 1,\n limit: 1,\n overrideAccess: false,\n pagination: false,\n req,\n where: {\n and: [\n {\n 'document.relationTo': {\n equals: collectionConfig.slug,\n },\n },\n {\n 'document.value': {\n equals: id,\n },\n },\n // Query where the lock is newer than the current time minus lock time\n {\n updatedAt: {\n greater_than: new Date(new Date().getTime() - lockDurationInMilliseconds),\n },\n },\n ],\n },\n })\n\n if (lockedDocument && lockedDocument.docs.length > 0) {\n lockStatus = lockedDocument.docs[0]!\n }\n } catch {\n // swallow error\n }\n\n result._isLocked = !!lockStatus\n result._userEditing = lockStatus?.user?.value ?? null\n }\n\n // /////////////////////////////////////\n // Replace document with draft if available\n // /////////////////////////////////////\n\n if (collectionConfig.versions?.drafts && draftEnabled) {\n result = await replaceWithDraftIfAvailable({\n accessResult,\n doc: result,\n entity: collectionConfig,\n entityType: 'collection',\n overrideAccess,\n req,\n select,\n })\n }\n\n // /////////////////////////////////////\n // beforeRead - Collection\n // /////////////////////////////////////\n\n if (collectionConfig.hooks?.beforeRead?.length) {\n for (const hook of collectionConfig.hooks.beforeRead) {\n result =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n doc: result,\n query: findOneArgs.where,\n req,\n })) || result\n }\n }\n\n // /////////////////////////////////////\n // afterRead - Fields\n // /////////////////////////////////////\n\n result = await afterRead({\n collection: collectionConfig,\n context: req.context,\n currentDepth,\n depth: depth!,\n doc: result,\n draft: draftEnabled,\n fallbackLocale: fallbackLocale!,\n global: null,\n locale: locale!,\n overrideAccess,\n populate,\n req,\n select,\n showHiddenFields: showHiddenFields!,\n })\n\n // /////////////////////////////////////\n // afterRead - Collection\n // /////////////////////////////////////\n\n if (collectionConfig.hooks?.afterRead?.length) {\n for (const hook of collectionConfig.hooks.afterRead) {\n result =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n doc: result,\n query: findOneArgs.where,\n req,\n })) || result\n }\n }\n\n // /////////////////////////////////////\n // afterOperation - Collection\n // /////////////////////////////////////\n\n result = await buildAfterOperation({\n args,\n collection: collectionConfig,\n operation: 'findByID',\n result,\n })\n\n // /////////////////////////////////////\n // Return results\n // /////////////////////////////////////\n\n return result as ApplyDisableErrors<\n TransformCollectionWithSelect<TSlug, TSelect>,\n TDisableErrors\n >\n } catch (error: unknown) {\n await killTransaction(args.req)\n throw error\n }\n}\n"],"names":["executeAccess","combineQueries","sanitizeJoinQuery","sanitizeWhereQuery","NotFound","afterRead","validateQueryPaths","lockedDocumentsCollectionSlug","appendNonTrashedFilter","killTransaction","sanitizeSelect","replaceWithDraftIfAvailable","buildAfterOperation","findByIDOperation","incomingArgs","args","collection","config","hooks","beforeOperation","length","hook","context","req","operation","id","collectionConfig","currentDepth","depth","disableErrors","draft","draftEnabled","includeLockStatus","joins","overrideAccess","populate","fallbackLocale","locale","t","select","incomingSelect","showHiddenFields","trash","fields","flattenedFields","forceSelect","accessResult","access","read","where","equals","fullWhere","enableTrash","payload","sanitizedJoins","findOneArgs","slug","draftsEnabled","payloadAPI","transactionID","collections","customIDType","and","result","db","findOne","lockStatus","lockDocumentsProp","lockDocuments","lockDurationDefault","lockDuration","duration","lockDurationInMilliseconds","lockedDocument","find","limit","pagination","updatedAt","greater_than","Date","getTime","docs","_isLocked","_userEditing","user","value","versions","drafts","doc","entity","entityType","beforeRead","query","global","error"],"mappings":"AAiBA,SAASA,aAAa,QAAQ,8BAA6B;AAC3D,SAASC,cAAc,QAAQ,mCAAkC;AACjE,SAASC,iBAAiB,QAAQ,sCAAqC;AACvE,SAASC,kBAAkB,QAAQ,uCAAsC;AACzE,SAASC,QAAQ,QAAQ,wBAAuB;AAChD,SAASC,SAAS,QAAQ,wCAAuC;AACjE,SAASC,kBAAkB,QAAQ,iBAAgB;AACnD,SAASC,6BAA6B,QAAQ,mCAAkC;AAChF,SAASC,sBAAsB,QAAQ,4CAA2C;AAClF,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,cAAc,QAAQ,oCAAmC;AAClE,SAASC,2BAA2B,QAAQ,uDAAsD;AAClG,SAASC,mBAAmB,QAAQ,aAAY;AAmBhD,OAAO,MAAMC,oBAAoB,OAK/BC;IAEA,IAAIC,OAAOD;IAEX,IAAI;QACF,wCAAwC;QACxC,+BAA+B;QAC/B,wCAAwC;QAExC,IAAIC,KAAKC,UAAU,CAACC,MAAM,CAACC,KAAK,EAAEC,iBAAiBC,QAAQ;YACzD,KAAK,MAAMC,QAAQN,KAAKC,UAAU,CAACC,MAAM,CAACC,KAAK,CAACC,eAAe,CAAE;gBAC/DJ,OACE,AAAC,MAAMM,KAAK;oBACVN;oBACAC,YAAYD,KAAKC,UAAU,CAACC,MAAM;oBAClCK,SAASP,KAAKQ,GAAG,CAACD,OAAO;oBACzBE,WAAW;oBACXD,KAAKR,KAAKQ,GAAG;gBACf,MAAOR;YACX;QACF;QAEA,MAAM,EACJU,EAAE,EACFT,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ACZJ,SAASC,IAAID,OAAO;oBACpBkE,KAAKzB;oBACL6B,OAAOrC,YAAYN,KAAK;oBACxB1B;gBACF,MAAOwC;YACX;QACF;QAEA,wCAAwC;QACxC,8BAA8B;QAC9B,wCAAwC;QAExCA,SAAS,MAAMnD,oBAAoB;YACjCG;YACAC,YAAYU;YACZF,WAAW;YACXuC;QACF;QAEA,wCAAwC;QACxC,iBAAiB;QACjB,wCAAwC;QAExC,OAAOA;IAIT,EAAE,OAAO+B,OAAgB;QACvB,MAAMrF,gBAAgBM,KAAKQ,GAAG;QAC9B,MAAMuE;IACR;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/collections/operations/findByID.ts"],"sourcesContent":["import type { FindOneArgs } from '../../database/types.js'\nimport type { CollectionSlug, JoinQuery } from '../../index.js'\nimport type {\n ApplyDisableErrors,\n JsonObject,\n PayloadRequest,\n PopulateType,\n SelectType,\n TransformCollectionWithSelect,\n} from '../../types/index.js'\nimport type {\n Collection,\n DataFromCollectionSlug,\n SelectFromCollectionSlug,\n TypeWithID,\n} from '../config/types.js'\n\nimport { executeAccess } from '../../auth/executeAccess.js'\nimport { combineQueries } from '../../database/combineQueries.js'\nimport { sanitizeJoinQuery } from '../../database/sanitizeJoinQuery.js'\nimport { sanitizeWhereQuery } from '../../database/sanitizeWhereQuery.js'\nimport { NotFound } from '../../errors/index.js'\nimport { afterRead } from '../../fields/hooks/afterRead/index.js'\nimport { validateQueryPaths } from '../../index.js'\nimport { lockedDocumentsCollectionSlug } from '../../locked-documents/config.js'\nimport { appendNonTrashedFilter } from '../../utilities/appendNonTrashedFilter.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport { sanitizeSelect } from '../../utilities/sanitizeSelect.js'\nimport { replaceWithDraftIfAvailable } from '../../versions/drafts/replaceWithDraftIfAvailable.js'\nimport { buildAfterOperation } from './utils.js'\n\nexport type Arguments = {\n collection: Collection\n currentDepth?: number\n /**\n * You may pass the document data directly which will skip the `db.findOne` database query.\n * This is useful if you want to use this endpoint solely for running hooks and populating data.\n */\n data?: Record<string, unknown>\n depth?: number\n disableErrors?: boolean\n draft?: boolean\n id: number | string\n includeLockStatus?: boolean\n joins?: JoinQuery\n overrideAccess?: boolean\n populate?: PopulateType\n req: PayloadRequest\n select?: SelectType\n showHiddenFields?: boolean\n trash?: boolean\n}\n\nexport const findByIDOperation = async <\n TSlug extends CollectionSlug,\n TDisableErrors extends boolean,\n TSelect extends SelectFromCollectionSlug<TSlug>,\n>(\n incomingArgs: Arguments,\n): Promise<ApplyDisableErrors<TransformCollectionWithSelect<TSlug, TSelect>, TDisableErrors>> => {\n let args = incomingArgs\n\n try {\n // /////////////////////////////////////\n // beforeOperation - Collection\n // /////////////////////////////////////\n\n if (args.collection.config.hooks?.beforeOperation?.length) {\n for (const hook of args.collection.config.hooks.beforeOperation) {\n args =\n (await hook({\n args,\n collection: args.collection.config,\n context: args.req.context,\n operation: 'read',\n req: args.req,\n })) || args\n }\n }\n\n const {\n id,\n collection: { config: collectionConfig },\n currentDepth,\n depth,\n disableErrors,\n draft: draftEnabled = false,\n includeLockStatus,\n joins,\n overrideAccess = false,\n populate,\n req: { fallbackLocale, locale, t },\n req,\n select: incomingSelect,\n showHiddenFields,\n trash = false,\n } = args\n\n const select = sanitizeSelect({\n fields: collectionConfig.flattenedFields,\n forceSelect: collectionConfig.forceSelect,\n select: incomingSelect,\n })\n\n // /////////////////////////////////////\n // Access\n // /////////////////////////////////////\n\n const accessResult = !overrideAccess\n ? await executeAccess({ id, disableErrors, req }, collectionConfig.access.read)\n : true\n\n // If errors are disabled, and access returns false, return null\n if (accessResult === false) {\n return null!\n }\n\n const where = { id: { equals: id } }\n\n let fullWhere = combineQueries(where, accessResult)\n\n // Exclude trashed documents when trash: false\n fullWhere = appendNonTrashedFilter({\n enableTrash: collectionConfig.trash,\n trash,\n where: fullWhere,\n })\n\n sanitizeWhereQuery({\n fields: collectionConfig.flattenedFields,\n payload: args.req.payload,\n where: fullWhere,\n })\n\n const sanitizedJoins = await sanitizeJoinQuery({\n collectionConfig,\n joins,\n overrideAccess,\n req,\n })\n\n const findOneArgs: FindOneArgs = {\n collection: collectionConfig.slug,\n draftsEnabled: draftEnabled,\n joins: req.payloadAPI === 'GraphQL' ? false : sanitizedJoins,\n locale: locale!,\n req: {\n transactionID: req.transactionID,\n } as PayloadRequest,\n select,\n where: fullWhere,\n }\n\n // execute only if there's a custom ID and potentially overwriten access on id\n if (req.payload.collections[collectionConfig.slug]!.customIDType) {\n await validateQueryPaths({\n collectionConfig,\n overrideAccess,\n req,\n where,\n })\n }\n // /////////////////////////////////////\n // Find by ID\n // /////////////////////////////////////\n\n if (!findOneArgs.where?.and?.[0]?.id) {\n throw new NotFound(t)\n }\n\n let result: DataFromCollectionSlug<TSlug> =\n (args.data as DataFromCollectionSlug<TSlug>) ?? (await req.payload.db.findOne(findOneArgs))!\n\n if (!result) {\n if (!disableErrors) {\n throw new NotFound(req.t)\n }\n\n return null!\n }\n\n // /////////////////////////////////////\n // Include Lock Status if required\n // /////////////////////////////////////\n\n if (includeLockStatus && id) {\n let lockStatus: (JsonObject & TypeWithID) | null = null\n\n try {\n const lockDocumentsProp = collectionConfig?.lockDocuments\n\n const lockDurationDefault = 300 // Default 5 minutes in seconds\n const lockDuration =\n typeof lockDocumentsProp === 'object' ? lockDocumentsProp.duration : lockDurationDefault\n const lockDurationInMilliseconds = lockDuration * 1000\n\n const lockedDocument = await req.payload.find({\n collection: lockedDocumentsCollectionSlug,\n depth: 1,\n limit: 1,\n overrideAccess: false,\n pagination: false,\n req,\n where: {\n and: [\n {\n 'document.relationTo': {\n equals: collectionConfig.slug,\n },\n },\n {\n 'document.value': {\n equals: id,\n },\n },\n // Query where the lock is newer than the current time minus lock time\n {\n updatedAt: {\n greater_than: new Date(new Date().getTime() - lockDurationInMilliseconds),\n },\n },\n ],\n },\n })\n\n if (lockedDocument && lockedDocument.docs.length > 0) {\n lockStatus = lockedDocument.docs[0]!\n }\n } catch {\n // swallow error\n }\n\n result._isLocked = !!lockStatus\n result._userEditing = lockStatus?.user?.value ?? null\n }\n\n // /////////////////////////////////////\n // Replace document with draft if available\n // /////////////////////////////////////\n\n if (collectionConfig.versions?.drafts && draftEnabled) {\n result = await replaceWithDraftIfAvailable({\n accessResult,\n doc: result,\n entity: collectionConfig,\n entityType: 'collection',\n overrideAccess,\n req,\n select,\n })\n }\n\n // /////////////////////////////////////\n // beforeRead - Collection\n // /////////////////////////////////////\n\n if (collectionConfig.hooks?.beforeRead?.length) {\n for (const hook of collectionConfig.hooks.beforeRead) {\n result =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n doc: result,\n query: findOneArgs.where,\n req,\n })) || result\n }\n }\n\n // /////////////////////////////////////\n // afterRead - Fields\n // /////////////////////////////////////\n\n result = await afterRead({\n collection: collectionConfig,\n context: req.context,\n currentDepth,\n depth: depth!,\n doc: result,\n draft: draftEnabled,\n fallbackLocale: fallbackLocale!,\n global: null,\n locale: locale!,\n overrideAccess,\n populate,\n req,\n select,\n showHiddenFields: showHiddenFields!,\n })\n\n // /////////////////////////////////////\n // afterRead - Collection\n // /////////////////////////////////////\n\n if (collectionConfig.hooks?.afterRead?.length) {\n for (const hook of collectionConfig.hooks.afterRead) {\n result =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n doc: result,\n query: findOneArgs.where,\n req,\n })) || result\n }\n }\n\n // /////////////////////////////////////\n // afterOperation - Collection\n // /////////////////////////////////////\n\n result = await buildAfterOperation({\n args,\n collection: collectionConfig,\n operation: 'findByID',\n result,\n })\n\n // /////////////////////////////////////\n // Return results\n // /////////////////////////////////////\n\n return result as ApplyDisableErrors<\n TransformCollectionWithSelect<TSlug, TSelect>,\n TDisableErrors\n >\n } catch (error: unknown) {\n await killTransaction(args.req)\n throw error\n }\n}\n"],"names":["executeAccess","combineQueries","sanitizeJoinQuery","sanitizeWhereQuery","NotFound","afterRead","validateQueryPaths","lockedDocumentsCollectionSlug","appendNonTrashedFilter","killTransaction","sanitizeSelect","replaceWithDraftIfAvailable","buildAfterOperation","findByIDOperation","incomingArgs","args","collection","config","hooks","beforeOperation","length","hook","context","req","operation","id","collectionConfig","currentDepth","depth","disableErrors","draft","draftEnabled","includeLockStatus","joins","overrideAccess","populate","fallbackLocale","locale","t","select","incomingSelect","showHiddenFields","trash","fields","flattenedFields","forceSelect","accessResult","access","read","where","equals","fullWhere","enableTrash","payload","sanitizedJoins","findOneArgs","slug","draftsEnabled","payloadAPI","transactionID","collections","customIDType","and","result","data","db","findOne","lockStatus","lockDocumentsProp","lockDocuments","lockDurationDefault","lockDuration","duration","lockDurationInMilliseconds","lockedDocument","find","limit","pagination","updatedAt","greater_than","Date","getTime","docs","_isLocked","_userEditing","user","value","versions","drafts","doc","entity","entityType","beforeRead","query","global","error"],"mappings":"AAiBA,SAASA,aAAa,QAAQ,8BAA6B;AAC3D,SAASC,cAAc,QAAQ,mCAAkC;AACjE,SAASC,iBAAiB,QAAQ,sCAAqC;AACvE,SAASC,kBAAkB,QAAQ,uCAAsC;AACzE,SAASC,QAAQ,QAAQ,wBAAuB;AAChD,SAASC,SAAS,QAAQ,wCAAuC;AACjE,SAASC,kBAAkB,QAAQ,iBAAgB;AACnD,SAASC,6BAA6B,QAAQ,mCAAkC;AAChF,SAASC,sBAAsB,QAAQ,4CAA2C;AAClF,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,cAAc,QAAQ,oCAAmC;AAClE,SAASC,2BAA2B,QAAQ,uDAAsD;AAClG,SAASC,mBAAmB,QAAQ,aAAY;AAwBhD,OAAO,MAAMC,oBAAoB,OAK/BC;IAEA,IAAIC,OAAOD;IAEX,IAAI;QACF,wCAAwC;QACxC,+BAA+B;QAC/B,wCAAwC;QAExC,IAAIC,KAAKC,UAAU,CAACC,MAAM,CAACC,KAAK,EAAEC,iBAAiBC,QAAQ;YACzD,KAAK,MAAMC,QAAQN,KAAKC,UAAU,CAACC,MAAM,CAACC,KAAK,CAACC,eAAe,CAAE;gBAC/DJ,OACE,AAAC,MAAMM,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AkBA;QACpB;QAEA,wCAAwC;QACxC,yBAAyB;QACzB,wCAAwC;QAExC,IAAIf,iBAAiBR,KAAK,EAAEb,WAAWe,QAAQ;YAC7C,KAAK,MAAMC,QAAQK,iBAAiBR,KAAK,CAACb,SAAS,CAAE;gBACnD0D,SACE,AAAC,MAAM1C,KAAK;oBACVL,YAAYU;oBACZJ,SAASC,IAAID,OAAO;oBACpBmE,KAAK1B;oBACL8B,OAAOtC,YAAYN,KAAK;oBACxB1B;gBACF,MAAOwC;YACX;QACF;QAEA,wCAAwC;QACxC,8BAA8B;QAC9B,wCAAwC;QAExCA,SAAS,MAAMnD,oBAAoB;YACjCG;YACAC,YAAYU;YACZF,WAAW;YACXuC;QACF;QAEA,wCAAwC;QACxC,iBAAiB;QACjB,wCAAwC;QAExC,OAAOA;IAIT,EAAE,OAAOgC,OAAgB;QACvB,MAAMtF,gBAAgBM,KAAKQ,GAAG;QAC9B,MAAMwE;IACR;AACF,EAAC"}
@@ -18,6 +18,11 @@ export type Options<TSlug extends CollectionSlug, TDisableErrors extends boolean
18
18
  * @internal
19
19
  */
20
20
  currentDepth?: number;
21
+ /**
22
+ * You may pass the document data directly which will skip the `db.findOne` database query.
23
+ * This is useful if you want to use this endpoint solely for running hooks and populating data.
24
+ */
25
+ data?: Record<string, unknown>;
21
26
  /**
22
27
  * [Control auto-population](https://payloadcms.com/docs/queries/depth) of nested relationship and upload fields.
23
28
  */
@@ -1 +1 @@
1
- {"version":3,"file":"findByID.d.ts","sourceRoot":"","sources":["../../../../src/collections/operations/local/findByID.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,SAAS,EACT,OAAO,EACP,cAAc,EACd,UAAU,EACV,WAAW,EACZ,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EACV,kBAAkB,EAClB,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,6BAA6B,EAC9B,MAAM,yBAAyB,CAAA;AAEhC,OAAO,KAAK,EAAE,wBAAwB,E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AO,EAChB,OAAO,EAAE,OAAO,CAAC,KAAK,EAAE,cAAc,EAAE,OAAO,CAAC,GAC/C,OAAO,CAAC,kBAAkB,CAAC,6BAA6B,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,cAAc,CAAC,CAAC,CAyC5F"}
1
+ {"version":3,"file":"findByID.d.ts","sourceRoot":"","sources":["../../../../src/collections/operations/local/findByID.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,SAAS,EACT,OAAO,EACP,cAAc,EACd,UAAU,EACV,WAAW,EACZ,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EACV,kBAAkB,EAClB,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,6BAA6B,EAC9B,MAAM,yBAAyB,CAAA;AAEhC,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AAMrE,MAAM,MAAM,OAAO,CACjB,KAAK,SAAS,cAAc,EAC5B,cAAc,SAAS,OAAO,EAC9B,OAAO,SAAS,UAAU,IACxB;IACF;;OAEG;IACH,UAAU,EAAE,KAAK,CAAA;IACjB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9B;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,aAAa,CAAC,EAAE,cAAc,CAAA;IAC9B;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAA;IACf;;OAEG;IACH,cAAc,CAAC,EAAE,KAAK,GAAG,WAAW,CAAA;IACpC;;OAEG;IACH,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;IACnB;;OAEG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B;;;OAGG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC,KAAK,CAAC,CAAA;IACxB;;OAEG;IACH,MAAM,CAAC,EAAE,KAAK,GAAG,WAAW,CAAA;IAC5B;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;OAEG;IACH,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB;;;OAGG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAA;IAC7B;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B;;;;;;;OAOG;IACH,KAAK,CAAC,EAAE,OAAO,CAAA;IACf;;OAEG;IACH,IAAI,CAAC,EAAE,QAAQ,CAAA;CAChB,CAAA;AAED,wBAAsB,aAAa,CACjC,KAAK,SAAS,cAAc,EAC5B,cAAc,SAAS,OAAO,EAC9B,OAAO,SAAS,wBAAwB,CAAC,KAAK,CAAC,EAE/C,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,CAAC,KAAK,EAAE,cAAc,EAAE,OAAO,CAAC,GAC/C,OAAO,CAAC,kBAAkB,CAAC,6BAA6B,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,cAAc,CAAC,CAAC,CA2C5F"}
@@ -2,7 +2,7 @@ import { APIError } from '../../../errors/index.js';
2
2
  import { createLocalReq } from '../../../utilities/createLocalReq.js';
3
3
  import { findByIDOperation } from '../findByID.js';
4
4
  export async function findByIDLocal(payload, options) {
5
- const { id, collection: collectionSlug, currentDepth, depth, disableErrors = false, draft = false, includeLockStatus, joins, overrideAccess = true, populate, select, showHiddenFields, trash = false } = options;
5
+ const { id, collection: collectionSlug, currentDepth, data, depth, disableErrors = false, draft = false, includeLockStatus, joins, overrideAccess = true, populate, select, showHiddenFields, trash = false } = options;
6
6
  const collection = payload.collections[collectionSlug];
7
7
  if (!collection) {
8
8
  throw new APIError(`The collection with slug ${String(collectionSlug)} can't be found. Find By ID Operation.`);
@@ -11,6 +11,7 @@ export async function findByIDLocal(payload, options) {
11
11
  id,
12
12
  collection,
13
13
  currentDepth,
14
+ data,
14
15
  depth,
15
16
  disableErrors,
16
17
  draft,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/collections/operations/local/findByID.ts"],"sourcesContent":["import type {\n CollectionSlug,\n JoinQuery,\n Payload,\n RequestContext,\n SelectType,\n TypedLocale,\n} from '../../../index.js'\nimport type {\n ApplyDisableErrors,\n Document,\n PayloadRequest,\n PopulateType,\n TransformCollectionWithSelect,\n} from '../../../types/index.js'\nimport type { CreateLocalReqOptions } from '../../../utilities/createLocalReq.js'\nimport type { SelectFromCollectionSlug } from '../../config/types.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { findByIDOperation } from '../findByID.js'\n\nexport type Options<\n TSlug extends CollectionSlug,\n TDisableErrors extends boolean,\n TSelect extends SelectType,\n> = {\n /**\n * the Collection slug to operate against.\n */\n collection: TSlug\n /**\n * [Context](https://payloadcms.com/docs/hooks/context), which will then be passed to `context` and `req.context`,\n * which can be read by hooks. Useful if you want to pass additional information to the hooks which\n * shouldn't be necessarily part of the document, for example a `triggerBeforeChange` option which can be read by the BeforeChange hook\n * to determine if it should run or not.\n */\n context?: RequestContext\n /**\n * The current population depth, used internally for relationships population.\n * @internal\n */\n currentDepth?: number\n /**\n * [Control auto-population](https://payloadcms.com/docs/queries/depth) of nested relationship and upload fields.\n */\n depth?: number\n /**\n * When set to `true`, errors will not be thrown.\n * `null` will be returned instead, if the document on this ID was not found.\n */\n disableErrors?: TDisableErrors\n /**\n * Whether the document should be queried from the versions table/collection or not. [More](https://payloadcms.com/docs/versions/drafts#draft-api)\n */\n draft?: boolean\n /**\n * Specify a [fallback locale](https://payloadcms.com/docs/configuration/localization) to use for any returned documents.\n */\n fallbackLocale?: false | TypedLocale\n /**\n * The ID of the document to find.\n */\n id: number | string\n /**\n * Include info about the lock status to the result with fields: `_isLocked` and `_userEditing`\n */\n includeLockStatus?: boolean\n /**\n * The [Join Field Query](https://payloadcms.com/docs/fields/join#query-options).\n * Pass `false` to disable all join fields from the result.\n */\n joins?: JoinQuery<TSlug>\n /**\n * Specify [locale](https://payloadcms.com/docs/configuration/localization) for any returned documents.\n */\n locale?: 'all' | TypedLocale\n /**\n * Skip access control.\n * Set to `false` if you want to respect Access Control for the operation, for example when fetching data for the front-end.\n * @default true\n */\n overrideAccess?: boolean\n /**\n * Specify [populate](https://payloadcms.com/docs/queries/select#populate) to control which fields to include to the result from populated documents.\n */\n populate?: PopulateType\n /**\n * The `PayloadRequest` object. You can pass it to thread the current [transaction](https://payloadcms.com/docs/database/transactions), user and locale to the operation.\n * Recommended to pass when using the Local API from hooks, as usually you want to execute the operation within the current transaction.\n */\n req?: Partial<PayloadRequest>\n /**\n * Specify [select](https://payloadcms.com/docs/queries/select) to control which fields to include to the result.\n */\n select?: TSelect\n /**\n * Opt-in to receiving hidden fields. By default, they are hidden from returned documents in accordance to your config.\n * @default false\n */\n showHiddenFields?: boolean\n /**\n * When set to `true`, the operation will return a document by ID, even if it is trashed (soft-deleted).\n * By default (`false`), the operation will exclude trashed documents.\n * To fetch a trashed document, set `trash: true`.\n *\n * This argument has no effect unless `trash` is enabled on the collection.\n * @default false\n */\n trash?: boolean\n /**\n * If you set `overrideAccess` to `false`, you can pass a user to use against the access control checks.\n */\n user?: Document\n}\n\nexport async function findByIDLocal<\n TSlug extends CollectionSlug,\n TDisableErrors extends boolean,\n TSelect extends SelectFromCollectionSlug<TSlug>,\n>(\n payload: Payload,\n options: Options<TSlug, TDisableErrors, TSelect>,\n): Promise<ApplyDisableErrors<TransformCollectionWithSelect<TSlug, TSelect>, TDisableErrors>> {\n const {\n id,\n collection: collectionSlug,\n currentDepth,\n depth,\n disableErrors = false,\n draft = false,\n includeLockStatus,\n joins,\n overrideAccess = true,\n populate,\n select,\n showHiddenFields,\n trash = false,\n } = options\n\n const collection = payload.collections[collectionSlug]\n\n if (!collection) {\n throw new APIError(\n `The collection with slug ${String(collectionSlug)} can't be found. Find By ID Operation.`,\n )\n }\n\n return findByIDOperation<TSlug, TDisableErrors, TSelect>({\n id,\n collection,\n currentDepth,\n depth,\n disableErrors,\n draft,\n includeLockStatus,\n joins,\n overrideAccess,\n populate,\n req: await createLocalReq(options as CreateLocalReqOptions, payload),\n select,\n showHiddenFields,\n trash,\n })\n}\n"],"names":["APIError","createLocalReq","findByIDOperation","findByIDLocal","payload","options","id","collection","collectionSlug","currentDepth","depth","disableErrors","draft","includeLockStatus","joins","overrideAccess","populate","select","showHiddenFields","trash","collections","String","req"],"mappings":"AAkBA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,iBAAiB,QAAQ,iBAAgB;AAgGlD,OAAO,eAAeC,cAKpBC,OAAgB,EAChBC,OAAgD;IAEhD,MAAM,EACJC,EAAE,EACFC,YAAYC,cAAc,EAC1BC,YAAY,EACZC,KAAK,EACLC,gBAAgB,KAAK,EACrBC,QAAQ,KAAK,EACbC,iBAAiB,EACjBC,KAAK,EACLC,iBAAiB,IAAI,EACrBC,QAAQ,EACRC,MAAM,EACNC,gBAAgB,EAChBC,QAAQ,KAAK,EACd,GAAGd;IAEJ,MAAME,aAAaH,QAAQgB,WAAW,CAACZ,eAAe;IAEtD,IAAI,CAACD,YAAY;QACf,MAAM,IAAIP,SACR,CAAC,yBAAyB,EAAEqB,OAAOb,gBAAgB,sCAAsC,CAAC;IAE9F;IAEA,OAAON,kBAAkD;QACvDI;QACAC;QACAE;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAM,KAAK,MAAMrB,eAAeI,SAAkCD;QAC5Da;QACAC;QACAC;IACF;AACF"}
1
+ {"version":3,"sources":["../../../../src/collections/operations/local/findByID.ts"],"sourcesContent":["import type {\n CollectionSlug,\n JoinQuery,\n Payload,\n RequestContext,\n SelectType,\n TypedLocale,\n} from '../../../index.js'\nimport type {\n ApplyDisableErrors,\n Document,\n PayloadRequest,\n PopulateType,\n TransformCollectionWithSelect,\n} from '../../../types/index.js'\nimport type { CreateLocalReqOptions } from '../../../utilities/createLocalReq.js'\nimport type { SelectFromCollectionSlug } from '../../config/types.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { findByIDOperation } from '../findByID.js'\n\nexport type Options<\n TSlug extends CollectionSlug,\n TDisableErrors extends boolean,\n TSelect extends SelectType,\n> = {\n /**\n * the Collection slug to operate against.\n */\n collection: TSlug\n /**\n * [Context](https://payloadcms.com/docs/hooks/context), which will then be passed to `context` and `req.context`,\n * which can be read by hooks. Useful if you want to pass additional information to the hooks which\n * shouldn't be necessarily part of the document, for example a `triggerBeforeChange` option which can be read by the BeforeChange hook\n * to determine if it should run or not.\n */\n context?: RequestContext\n /**\n * The current population depth, used internally for relationships population.\n * @internal\n */\n currentDepth?: number\n /**\n * You may pass the document data directly which will skip the `db.findOne` database query.\n * This is useful if you want to use this endpoint solely for running hooks and populating data.\n */\n data?: Record<string, unknown>\n /**\n * [Control auto-population](https://payloadcms.com/docs/queries/depth) of nested relationship and upload fields.\n */\n depth?: number\n /**\n * When set to `true`, errors will not be thrown.\n * `null` will be returned instead, if the document on this ID was not found.\n */\n disableErrors?: TDisableErrors\n /**\n * Whether the document should be queried from the versions table/collection or not. [More](https://payloadcms.com/docs/versions/drafts#draft-api)\n */\n draft?: boolean\n /**\n * Specify a [fallback locale](https://payloadcms.com/docs/configuration/localization) to use for any returned documents.\n */\n fallbackLocale?: false | TypedLocale\n /**\n * The ID of the document to find.\n */\n id: number | string\n /**\n * Include info about the lock status to the result with fields: `_isLocked` and `_userEditing`\n */\n includeLockStatus?: boolean\n /**\n * The [Join Field Query](https://payloadcms.com/docs/fields/join#query-options).\n * Pass `false` to disable all join fields from the result.\n */\n joins?: JoinQuery<TSlug>\n /**\n * Specify [locale](https://payloadcms.com/docs/configuration/localization) for any returned documents.\n */\n locale?: 'all' | TypedLocale\n /**\n * Skip access control.\n * Set to `false` if you want to respect Access Control for the operation, for example when fetching data for the front-end.\n * @default true\n */\n overrideAccess?: boolean\n /**\n * Specify [populate](https://payloadcms.com/docs/queries/select#populate) to control which fields to include to the result from populated documents.\n */\n populate?: PopulateType\n /**\n * The `PayloadRequest` object. You can pass it to thread the current [transaction](https://payloadcms.com/docs/database/transactions), user and locale to the operation.\n * Recommended to pass when using the Local API from hooks, as usually you want to execute the operation within the current transaction.\n */\n req?: Partial<PayloadRequest>\n /**\n * Specify [select](https://payloadcms.com/docs/queries/select) to control which fields to include to the result.\n */\n select?: TSelect\n /**\n * Opt-in to receiving hidden fields. By default, they are hidden from returned documents in accordance to your config.\n * @default false\n */\n showHiddenFields?: boolean\n /**\n * When set to `true`, the operation will return a document by ID, even if it is trashed (soft-deleted).\n * By default (`false`), the operation will exclude trashed documents.\n * To fetch a trashed document, set `trash: true`.\n *\n * This argument has no effect unless `trash` is enabled on the collection.\n * @default false\n */\n trash?: boolean\n /**\n * If you set `overrideAccess` to `false`, you can pass a user to use against the access control checks.\n */\n user?: Document\n}\n\nexport async function findByIDLocal<\n TSlug extends CollectionSlug,\n TDisableErrors extends boolean,\n TSelect extends SelectFromCollectionSlug<TSlug>,\n>(\n payload: Payload,\n options: Options<TSlug, TDisableErrors, TSelect>,\n): Promise<ApplyDisableErrors<TransformCollectionWithSelect<TSlug, TSelect>, TDisableErrors>> {\n const {\n id,\n collection: collectionSlug,\n currentDepth,\n data,\n depth,\n disableErrors = false,\n draft = false,\n includeLockStatus,\n joins,\n overrideAccess = true,\n populate,\n select,\n showHiddenFields,\n trash = false,\n } = options\n\n const collection = payload.collections[collectionSlug]\n\n if (!collection) {\n throw new APIError(\n `The collection with slug ${String(collectionSlug)} can't be found. Find By ID Operation.`,\n )\n }\n\n return findByIDOperation<TSlug, TDisableErrors, TSelect>({\n id,\n collection,\n currentDepth,\n data,\n depth,\n disableErrors,\n draft,\n includeLockStatus,\n joins,\n overrideAccess,\n populate,\n req: await createLocalReq(options as CreateLocalReqOptions, payload),\n select,\n showHiddenFields,\n trash,\n })\n}\n"],"names":["APIError","createLocalReq","findByIDOperation","findByIDLocal","payload","options","id","collection","collectionSlug","currentDepth","data","depth","disableErrors","draft","includeLockStatus","joins","overrideAccess","populate","select","showHiddenFields","trash","collections","String","req"],"mappings":"AAkBA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,iBAAiB,QAAQ,iBAAgB;AAqGlD,OAAO,eAAeC,cAKpBC,OAAgB,EAChBC,OAAgD;IAEhD,MAAM,EACJC,EAAE,EACFC,YAAYC,cAAc,EAC1BC,YAAY,EACZC,IAAI,EACJC,KAAK,EACLC,gBAAgB,KAAK,EACrBC,QAAQ,KAAK,EACbC,iBAAiB,EACjBC,KAAK,EACLC,iBAAiB,IAAI,EACrBC,QAAQ,EACRC,MAAM,EACNC,gBAAgB,EAChBC,QAAQ,KAAK,EACd,GAAGf;IAEJ,MAAME,aAAaH,QAAQiB,WAAW,CAACb,eAAe;IAEtD,IAAI,CAACD,YAAY;QACf,MAAM,IAAIP,SACR,CAAC,yBAAyB,EAAEsB,OAAOd,gBAAgB,sCAAsC,CAAC;IAE9F;IAEA,OAAON,kBAAkD;QACvDI;QACAC;QACAE;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAM,KAAK,MAAMtB,eAAeI,SAAkCD;QAC5Dc;QACAC;QACAC;IACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../src/collections/operations/utilities/update.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAGhD,OAAO,KAAK,EACV,OAAO,EACP,cAAc,EACd,YAAY,EACZ,UAAU,EACV,6BAA6B,EAC9B,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EACV,sBAAsB,EACtB,yBAAyB,EACzB,wBAAwB,EACzB,MAAM,uBAAuB,CAAA;AAS9B,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,cAAc,EAEnB,KAAK,UAAU,EACf,KAAK,eAAe,EACrB,MAAM,mBAAmB,CAAA;AAO1B,MAAM,MAAM,wBAAwB,CAAC,KAAK,SAAS,cAAc,IAAI;IACnE,aAAa,EAAE,YAAY,CAAA;IAC3B,QAAQ,EAAE,OAAO,CAAA;IACjB,gBAAgB,EAAE,yBAAyB,CAAA;IAC3C,MAAM,EAAE,eAAe,CAAA;IACvB,IAAI,EAAE,WAAW,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC,CAAA;IAChD,KAAK,EAAE,MAAM,CAAA;IACb,cAAc,EAAE,GAAG,CAAA;IACnB,QAAQ,EAAE,OAAO,CAAA;IACjB,cAAc,EAAE,MAAM,CAAA;IACtB,aAAa,EAAE,UAAU,EAAE,CAAA;IAC3B,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;IACnB,MAAM,EAAE,MAAM,CAAA;IACd,cAAc,EAAE,OAAO,CAAA;IACvB,YAAY,EAAE,OAAO,CAAA;IACrB,OAAO,EAAE,OAAO,CAAA;IAChB,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,GAAG,EAAE,cAAc,CAAA;IACnB,MAAM,EAAE,UAAU,CAAA;IAClB,gBAAgB,EAAE,OAAO,CAAA;CAC1B,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,cAAc,GACzB,KAAK,SAAS,cAAc,EAC5B,OAAO,SAAS,wBAAwB,CAAC,KAAK,CAAC,gQAsB9C,wBAAwB,CAAC,KAAK,CAAC,KAAG,OAAO,CAAC,6BAA6B,CAAC,KAAK,EAAE,OAAO,CAAC,CA8SzF,CAAA"}
1
+ {"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../src/collections/operations/utilities/update.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,M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G,OAAO,CAAC,6BAA6B,CAAC,KAAK,EAAE,OAAO,CAAC,CA+SzF,CAAA"}
@@ -213,6 +213,7 @@ import { saveVersion } from '../../../versions/saveVersion.js';
213
213
  collection: collectionConfig,
214
214
  docWithLocales: result,
215
215
  draft: shouldSaveDraft,
216
+ locale,
216
217
  operation: 'update',
217
218
  payload,
218
219
  publishSpecificLocale,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/collections/operations/utilities/update.ts"],"sourcesContent":["import type { DeepPartial } from 'ts-essentials'\n\nimport type { Args } from '../../../fields/hooks/beforeChange/index.js'\nimport type {\n Payload,\n PayloadRequest,\n PopulateType,\n SelectType,\n TransformCollectionWithSelect,\n} from '../../../types/index.js'\nimport type {\n DataFromCollectionSlug,\n SanitizedCollectionConfig,\n SelectFromCollectionSlug,\n} from '../../config/types.js'\n\nimport { ensureUsernameOrEmail } from '../../../auth/ensureUsernameOrEmail.js'\nimport { generatePasswordSaltHash } from '../../../auth/strategies/local/generatePasswordSaltHash.js'\nimport { combineQueries } from '../../../database/combineQueries.js'\nimport { afterChange } from '../../../fields/hooks/afterChange/index.js'\nimport { afterRead } from '../../../fields/hooks/afterRead/index.js'\nimport { beforeChange } from '../../../fields/hooks/beforeChange/index.js'\nimport { beforeValidate } from '../../../fields/hooks/beforeValidate/index.js'\nimport {\n type AccessResult,\n type CollectionSlug,\n deepCopyObjectSimple,\n type FileToSave,\n type SanitizedConfig,\n} from '../../../index.js'\nimport { deleteAssociatedFiles } from '../../../uploads/deleteAssociatedFiles.js'\nimport { uploadFiles } from '../../../uploads/uploadFiles.js'\nimport { checkDocumentLockStatus } from '../../../utilities/checkDocumentLockStatus.js'\nimport { getLatestCollectionVersion } from '../../../versions/getLatestCollectionVersion.js'\nimport { saveVersion } from '../../../versions/saveVersion.js'\n\nexport type SharedUpdateDocumentArgs<TSlug extends CollectionSlug> = {\n accessResults: AccessResult\n autosave: boolean\n collectionConfig: SanitizedCollectionConfig\n config: SanitizedConfig\n data: DeepPartial<DataFromCollectionSlug<TSlug>>\n depth: number\n docWithLocales: any\n draftArg: boolean\n fallbackLocale: string\n filesToUpload: FileToSave[]\n id: number | string\n locale: string\n overrideAccess: boolean\n overrideLock: boolean\n payload: Payload\n populate?: PopulateType\n publishSpecificLocale?: string\n req: PayloadRequest\n select: SelectType\n showHiddenFields: boolean\n}\n\n/**\n * This function is used to update a document in the DB and return the result.\n *\n * It runs the following hooks in order:\n * - beforeValidate - Fields\n * - beforeValidate - Collection\n * - beforeChange - Collection\n * - beforeChange - Fields\n * - afterRead - Fields\n * - afterRead - Collection\n * - afterChange - Fields\n * - afterChange - Collection\n */\nexport const updateDocument = async <\n TSlug extends CollectionSlug,\n TSelect extends SelectFromCollectionSlug<TSlug> = SelectType,\n>({\n id,\n accessResults,\n autosave,\n collectionConfig,\n config,\n data,\n depth,\n docWithLocales,\n draftArg,\n fallbackLocale,\n filesToUpload,\n locale,\n overrideAccess,\n overrideLock,\n payload,\n populate,\n publishSpecificLocale,\n req,\n select,\n showHiddenFields,\n}: SharedUpdateDocumentArgs<TSlug>): Promise<TransformCollectionWithSelect<TSlug, TSelect>> => {\n const password = data?.password\n const shouldSaveDraft =\n Boolean(draftArg && collectionConfig.versions.drafts) && data._status !== 'published'\n const shouldSavePassword = Boolean(\n password &&\n collectionConfig.auth &&\n (!collectionConfig.auth.disableLocalStrategy ||\n (typeof collectionConfig.auth.disableLocalStrategy === 'object' &&\n collectionConfig.auth.disableLocalStrategy.enableFields)) &&\n !shouldSaveDraft,\n )\n\n // /////////////////////////////////////\n // Handle potentially locked documents\n // /////////////////////////////////////\n\n await checkDocumentLockStatus({\n id,\n collectionSlug: collectionConfig.slug,\n lockErrorMessage: `Document with ID ${id} is currently locked by another user and cannot be updated.`,\n overrideLock,\n req,\n })\n\n const originalDoc = await afterRead({\n collection: collectionConfig,\n context: req.context,\n depth: 0,\n doc: deepCopyObjectSimple(docWithLocales),\n draft: draftArg,\n fallbackLocale: id ? null : fallbackLocale,\n global: null,\n locale,\n overrideAccess: true,\n req,\n showHiddenFields: true,\n })\n\n if (collectionConfig.auth) {\n ensureUsernameOrEmail<TSlug>({\n authOptions: collectionConfig.auth,\n collectionSlug: collectionConfig.slug,\n data,\n operation: 'update',\n originalDoc,\n req,\n })\n }\n\n // /////////////////////////////////////\n // Delete any associated files\n // /////////////////////////////////////\n\n await deleteAssociatedFiles({\n collectionConfig,\n config,\n doc: docWithLocales,\n files: filesToUpload,\n overrideDelete: false,\n req,\n })\n\n // /////////////////////////////////////\n // beforeValidate - Fields\n // /////////////////////////////////////\n\n data = await beforeValidate<DeepPartial<DataFromCollectionSlug<TSlug>>>({\n id,\n collection: collectionConfig,\n context: req.context,\n data,\n doc: originalDoc,\n global: null,\n operation: 'update',\n overrideAccess,\n req,\n })\n\n // /////////////////////////////////////\n // beforeValidate - Collection\n // /////////////////////////////////////\n\n if (collectionConfig.hooks?.beforeValidate?.length) {\n for (const hook of collectionConfig.hooks.beforeValidate) {\n data =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n data,\n operation: 'update',\n originalDoc,\n req,\n })) || data\n }\n }\n\n // /////////////////////////////////////\n // Write files to local storage\n // /////////////////////////////////////\n\n if (!collectionConfig.upload.disableLocalStorage) {\n await uploadFiles(payload, filesToUpload, req)\n }\n\n // /////////////////////////////////////\n // beforeChange - Collection\n // /////////////////////////////////////\n\n if (collectionConfig.hooks?.beforeChange?.length) {\n for (const hook of collectionConfig.hooks.beforeChange) {\n data =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n data,\n operation: 'update',\n originalDoc,\n req,\n })) || data\n }\n }\n\n // /////////////////////////////////////\n // beforeChange - Fields\n // /////////////////////////////////////\n\n let publishedDocWithLocales = docWithLocales\n let versionSnapshotResult\n\n const beforeChangeArgs: Args<DataFromCollectionSlug<TSlug>> = {\n id,\n collection: collectionConfig,\n context: req.context,\n data: { ...data, id },\n doc: originalDoc,\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n docWithLocales: undefined,\n global: null,\n operation: 'update',\n overrideAccess,\n req,\n skipValidation:\n shouldSaveDraft &&\n collectionConfig.versions.drafts &&\n !collectionConfig.versions.drafts.validate,\n }\n\n if (publishSpecificLocale) {\n versionSnapshotResult = await beforeChange({\n ...beforeChangeArgs,\n docWithLocales,\n })\n\n const lastPublished = await getLatestCollectionVersion({\n id,\n config: collectionConfig,\n payload,\n published: true,\n query: {\n collection: collectionConfig.slug,\n locale,\n req,\n where: combineQueries({ id: { equals: id } }, accessResults),\n },\n req,\n })\n\n publishedDocWithLocales = lastPublished ? lastPublished : {}\n }\n\n let result = await beforeChange({\n ...beforeChangeArgs,\n docWithLocales: publishedDocWithLocales,\n })\n\n // /////////////////////////////////////\n // Handle potential password update\n // /////////////////////////////////////\n\n const dataToUpdate: Record<string, unknown> = { ...result }\n\n if (shouldSavePassword && typeof password === 'string') {\n const { hash, salt } = await generatePasswordSaltHash({\n collection: collectionConfig,\n password,\n req,\n })\n dataToUpdate.salt = salt\n dataToUpdate.hash = hash\n delete dataToUpdate.password\n delete data.password\n }\n\n // /////////////////////////////////////\n // Update\n // /////////////////////////////////////\n\n if (!shouldSaveDraft) {\n // Ensure updatedAt date is always updated\n dataToUpdate.updatedAt = new Date().toISOString()\n result = await req.payload.db.updateOne({\n id,\n collection: collectionConfig.slug,\n data: dataToUpdate,\n locale,\n req,\n select,\n })\n }\n\n // /////////////////////////////////////\n // Create version\n // /////////////////////////////////////\n\n if (collectionConfig.versions) {\n result = await saveVersion({\n id,\n autosave,\n collection: collectionConfig,\n docWithLocales: result,\n draft: shouldSaveDraft,\n operation: 'update',\n payload,\n publishSpecificLocale,\n req,\n select,\n snapshot: versionSnapshotResult,\n })\n }\n\n // /////////////////////////////////////\n // afterRead - Fields\n // /////////////////////////////////////\n\n result = await afterRead({\n collection: collectionConfig,\n context: req.context,\n depth,\n doc: result,\n draft: draftArg,\n fallbackLocale,\n global: null,\n locale,\n overrideAccess,\n populate,\n req,\n select,\n showHiddenFields,\n })\n\n // /////////////////////////////////////\n // afterRead - Collection\n // /////////////////////////////////////\n\n if (collectionConfig.hooks?.afterRead?.length) {\n for (const hook of collectionConfig.hooks.afterRead) {\n result =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n doc: result,\n req,\n })) || result\n }\n }\n\n // /////////////////////////////////////\n // afterChange - Fields\n // /////////////////////////////////////\n\n result = await afterChange({\n collection: collectionConfig,\n context: req.context,\n data,\n doc: result,\n global: null,\n operation: 'update',\n previousDoc: originalDoc,\n req,\n })\n\n // /////////////////////////////////////\n // afterChange - Collection\n // /////////////////////////////////////\n\n if (collectionConfig.hooks?.afterChange?.length) {\n for (const hook of collectionConfig.hooks.afterChange) {\n result =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n data,\n doc: result,\n operation: 'update',\n previousDoc: originalDoc,\n req,\n })) || result\n }\n }\n\n return result as TransformCollectionWithSelect<TSlug, TSelect>\n}\n"],"names":["ensureUsernameOrEmail","generatePasswordSaltHash","combineQueries","afterChange","afterRead","beforeChange","beforeValidate","deepCopyObjectSimple","deleteAssociatedFiles","uploadFiles","checkDocumentLockStatus","getLatestCollectionVersion","saveVersion","updateDocument","id","accessResults","autosave","collectionConfig","config","data","depth","docWithLocales","draftArg","fallbackLocale","filesToUpload","locale","overrideAccess","overrideLock","payload","populate","publishSpecificLocale","req","select","showHiddenFields","password","shouldSaveDraft","Boolean","versions","drafts","_status","shouldSavePassword","auth","disableLocalStrategy","enableFields","collectionSlug","slug","lockErrorMessage","originalDoc","collection","context","doc","draft","global","authOptions","operation","files","overrideDelete","hooks","length","hook","upload","disableLocalStorage","publishedDocWithLocales","versionSnapshotResult","beforeChangeArgs","undefined","skipValidation","validate","lastPublished","published","query","where","equals","result","dataToUpdate","hash","salt","updatedAt","Date","toISOString","db","updateOne","snapshot","previousDoc"],"mappings":"AAgBA,SAASA,qBAAqB,QAAQ,yCAAwC;AAC9E,SAASC,wBAAwB,QAAQ,6DAA4D;AACrG,SAASC,cAAc,QAAQ,sCAAqC;AACpE,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F,MAAO0C;QACX;IACF;IAEA,wCAAwC;IACxC,uBAAuB;IACvB,wCAAwC;IAExCA,SAAS,MAAMtE,YAAY;QACzB6C,YAAY/B;QACZgC,SAASlB,IAAIkB,OAAO;QACpB9B;QACA+B,KAAKuB;QACLrB,QAAQ;QACRE,WAAW;QACX6B,aAAapC;QACbhB;IACF;IAEA,wCAAwC;IACxC,2BAA2B;IAC3B,wCAAwC;IAExC,IAAId,iBAAiBwC,KAAK,EAAEtD,aAAauD,QAAQ;QAC/C,KAAK,MAAMC,QAAQ1C,iBAAiBwC,KAAK,CAACtD,WAAW,CAAE;YACrDsE,SACE,AAAC,MAAMd,KAAK;gBACVX,YAAY/B;gBACZgC,SAASlB,IAAIkB,OAAO;gBACpB9B;gBACA+B,KAAKuB;gBACLnB,WAAW;gBACX6B,aAAapC;gBACbhB;YACF,MAAO0C;QACX;IACF;IAEA,OAAOA;AACT,EAAC"}
1
+ {"version":3,"sources":["../../../../src/collections/operations/utilities/update.ts"],"sourcesContent":["import type { DeepPartial } from 'ts-essentials'\n\nimport type { Args } from '../../../fields/hooks/beforeChange/index.js'\nimport type {\n Payload,\n PayloadRequest,\n PopulateType,\n SelectType,\n TransformCollectionWithSelect,\n} from '../../../types/index.js'\nimport type {\n DataFromCollectionSlug,\n SanitizedCollectionConfig,\n SelectFromCollectionSlug,\n} from '../../config/types.js'\n\nimport { ensureUsernameOrEmail } from '../../../auth/ensureUsernameOrEmail.js'\nimport { generatePasswordSaltHash } from '../../../auth/strategies/local/generatePasswordSaltHash.js'\nimport { combineQueries } from '../../../database/combineQueries.js'\nimport { afterChange } from '../../../fields/hooks/afterChange/index.js'\nimport { afterRead } from '../../../fields/hooks/afterRead/index.js'\nimport { beforeChange } from '../../../fields/hooks/beforeChange/index.js'\nimport { beforeValidate } from '../../../fields/hooks/beforeValidate/index.js'\nimport {\n type AccessResult,\n type CollectionSlug,\n deepCopyObjectSimple,\n type FileToSave,\n type SanitizedConfig,\n} from '../../../index.js'\nimport { deleteAssociatedFiles } from '../../../uploads/deleteAssociatedFiles.js'\nimport { uploadFiles } from '../../../uploads/uploadFiles.js'\nimport { checkDocumentLockStatus } from '../../../utilities/checkDocumentLockStatus.js'\nimport { getLatestCollectionVersion } from '../../../versions/getLatestCollectionVersion.js'\nimport { saveVersion } from '../../../versions/saveVersion.js'\n\nexport type SharedUpdateDocumentArgs<TSlug extends CollectionSlug> = {\n accessResults: AccessResult\n autosave: boolean\n collectionConfig: SanitizedCollectionConfig\n config: SanitizedConfig\n data: DeepPartial<DataFromCollectionSlug<TSlug>>\n depth: number\n docWithLocales: any\n draftArg: boolean\n fallbackLocale: string\n filesToUpload: FileToSave[]\n id: number | string\n locale: string\n overrideAccess: boolean\n overrideLock: boolean\n payload: Payload\n populate?: PopulateType\n publishSpecificLocale?: string\n req: PayloadRequest\n select: SelectType\n showHiddenFields: boolean\n}\n\n/**\n * This function is used to update a document in the DB and return the result.\n *\n * It runs the following hooks in order:\n * - beforeValidate - Fields\n * - beforeValidate - Collection\n * - beforeChange - Collection\n * - beforeChange - Fields\n * - afterRead - Fields\n * - afterRead - Collection\n * - afterChange - Fields\n * - afterChange - Collection\n */\nexport const updateDocument = async <\n TSlug extends CollectionSlug,\n TSelect extends SelectFromCollectionSlug<TSlug> = SelectType,\n>({\n id,\n accessResults,\n autosave,\n collectionConfig,\n config,\n data,\n depth,\n docWithLocales,\n draftArg,\n fallbackLocale,\n filesToUpload,\n locale,\n overrideAccess,\n overrideLock,\n payload,\n populate,\n publishSpecificLocale,\n req,\n select,\n showHiddenFields,\n}: SharedUpdateDocumentArgs<TSlug>): Promise<TransformCollectionWithSelect<TSlug, TSelect>> => {\n const password = data?.password\n const shouldSaveDraft =\n Boolean(draftArg && collectionConfig.versions.drafts) && data._status !== 'published'\n const shouldSavePassword = Boolean(\n password &&\n collectionConfig.auth &&\n (!collectionConfig.auth.disableLocalStrategy ||\n (typeof collectionConfig.auth.disableLocalStrategy === 'object' &&\n collectionConfig.auth.disableLocalStrategy.enableFields)) &&\n !shouldSaveDraft,\n )\n\n // /////////////////////////////////////\n // Handle potentially locked documents\n // /////////////////////////////////////\n\n await checkDocumentLockStatus({\n id,\n collectionSlug: collectionConfig.slug,\n lockErrorMessage: `Document with ID ${id} is currently locked by another user and cannot be updated.`,\n overrideLock,\n req,\n })\n\n const originalDoc = await afterRead({\n collection: collectionConfig,\n context: req.context,\n depth: 0,\n doc: deepCopyObjectSimple(docWithLocales),\n draft: draftArg,\n fallbackLocale: id ? null : fallbackLocale,\n global: null,\n locale,\n overrideAccess: true,\n req,\n showHiddenFields: true,\n })\n\n if (collectionConfig.auth) {\n ensureUsernameOrEmail<TSlug>({\n authOptions: collectionConfig.auth,\n collectionSlug: collectionConfig.slug,\n data,\n operation: 'update',\n originalDoc,\n req,\n })\n }\n\n // /////////////////////////////////////\n // Delete any associated files\n // /////////////////////////////////////\n\n await deleteAssociatedFiles({\n collectionConfig,\n config,\n doc: docWithLocales,\n files: filesToUpload,\n overrideDelete: false,\n req,\n })\n\n // /////////////////////////////////////\n // beforeValidate - Fields\n // /////////////////////////////////////\n\n data = await beforeValidate<DeepPartial<DataFromCollectionSlug<TSlug>>>({\n id,\n collection: collectionConfig,\n context: req.context,\n data,\n doc: originalDoc,\n global: null,\n operation: 'update',\n overrideAccess,\n req,\n })\n\n // /////////////////////////////////////\n // beforeValidate - Collection\n // /////////////////////////////////////\n\n if (collectionConfig.hooks?.beforeValidate?.length) {\n for (const hook of collectionConfig.hooks.beforeValidate) {\n data =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n data,\n operation: 'update',\n originalDoc,\n req,\n })) || data\n }\n }\n\n // /////////////////////////////////////\n // Write files to local storage\n // /////////////////////////////////////\n\n if (!collectionConfig.upload.disableLocalStorage) {\n await uploadFiles(payload, filesToUpload, req)\n }\n\n // /////////////////////////////////////\n // beforeChange - Collection\n // /////////////////////////////////////\n\n if (collectionConfig.hooks?.beforeChange?.length) {\n for (const hook of collectionConfig.hooks.beforeChange) {\n data =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n data,\n operation: 'update',\n originalDoc,\n req,\n })) || data\n }\n }\n\n // /////////////////////////////////////\n // beforeChange - Fields\n // /////////////////////////////////////\n\n let publishedDocWithLocales = docWithLocales\n let versionSnapshotResult\n\n const beforeChangeArgs: Args<DataFromCollectionSlug<TSlug>> = {\n id,\n collection: collectionConfig,\n context: req.context,\n data: { ...data, id },\n doc: originalDoc,\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n docWithLocales: undefined,\n global: null,\n operation: 'update',\n overrideAccess,\n req,\n skipValidation:\n shouldSaveDraft &&\n collectionConfig.versions.drafts &&\n !collectionConfig.versions.drafts.validate,\n }\n\n if (publishSpecificLocale) {\n versionSnapshotResult = await beforeChange({\n ...beforeChangeArgs,\n docWithLocales,\n })\n\n const lastPublished = await getLatestCollectionVersion({\n id,\n config: collectionConfig,\n payload,\n published: true,\n query: {\n collection: collectionConfig.slug,\n locale,\n req,\n where: combineQueries({ id: { equals: id } }, accessResults),\n },\n req,\n })\n\n publishedDocWithLocales = lastPublished ? lastPublished : {}\n }\n\n let result = await beforeChange({\n ...beforeChangeArgs,\n docWithLocales: publishedDocWithLocales,\n })\n\n // /////////////////////////////////////\n // Handle potential password update\n // /////////////////////////////////////\n\n const dataToUpdate: Record<string, unknown> = { ...result }\n\n if (shouldSavePassword && typeof password === 'string') {\n const { hash, salt } = await generatePasswordSaltHash({\n collection: collectionConfig,\n password,\n req,\n })\n dataToUpdate.salt = salt\n dataToUpdate.hash = hash\n delete dataToUpdate.password\n delete data.password\n }\n\n // /////////////////////////////////////\n // Update\n // /////////////////////////////////////\n\n if (!shouldSaveDraft) {\n // Ensure updatedAt date is always updated\n dataToUpdate.updatedAt = new Date().toISOString()\n result = await req.payload.db.updateOne({\n id,\n collection: collectionConfig.slug,\n data: dataToUpdate,\n locale,\n req,\n select,\n })\n }\n\n // /////////////////////////////////////\n // Create version\n // /////////////////////////////////////\n\n if (collectionConfig.versions) {\n result = await saveVersion({\n id,\n autosave,\n collection: collectionConfig,\n docWithLocales: result,\n draft: shouldSaveDraft,\n locale,\n operation: 'update',\n payload,\n publishSpecificLocale,\n req,\n select,\n snapshot: versionSnapshotResult,\n })\n }\n\n // /////////////////////////////////////\n // afterRead - Fields\n // /////////////////////////////////////\n\n result = await afterRead({\n collection: collectionConfig,\n context: req.context,\n depth,\n doc: result,\n draft: draftArg,\n fallbackLocale,\n global: null,\n locale,\n overrideAccess,\n populate,\n req,\n select,\n showHiddenFields,\n })\n\n // /////////////////////////////////////\n // afterRead - Collection\n // /////////////////////////////////////\n\n if (collectionConfig.hooks?.afterRead?.length) {\n for (const hook of collectionConfig.hooks.afterRead) {\n result =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n doc: result,\n req,\n })) || result\n }\n }\n\n // /////////////////////////////////////\n // afterChange - Fields\n // /////////////////////////////////////\n\n result = await afterChange({\n collection: collectionConfig,\n context: req.context,\n data,\n doc: result,\n global: null,\n operation: 'update',\n previousDoc: originalDoc,\n req,\n })\n\n // /////////////////////////////////////\n // afterChange - Collection\n // /////////////////////////////////////\n\n if (collectionConfig.hooks?.afterChange?.length) {\n for (const hook of collectionConfig.hooks.afterChange) {\n result =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n data,\n doc: result,\n operation: 'update',\n previousDoc: originalDoc,\n req,\n })) || result\n }\n }\n\n return result as TransformCollectionWithSelect<TSlug, TSelect>\n}\n"],"names":["ensureUsernameOrEmail","generatePasswordSaltHash","combineQueries","afterChange","afterRead","beforeChange","beforeValidate","deepCopyObjectSimple","deleteAssociatedFiles","uploadFiles","checkDocumentLockStatus","getLatestCollectionVersion","saveVersion","updateDocument","id","accessResults","autosave","collectionConfig","config","data","depth","docWithLocales","draftArg","fallbackLocale","filesToUpload","locale","overrideAccess","overrideLock","payload","populate","publishSpecificLocale","req","select","showHiddenFields","password","shouldSaveDraft","Boolean","versions","drafts","_status","shouldSavePassword","auth","disableLocalStrategy","enableFields","collectionSlug","slug","lockErrorMessage","originalDoc","collection","context","doc","draft","global","authOptions","operation","files","overrideDelete","hooks","length","hook","upload","disableLocalStorage","publishedDocWithLocales","versionSnapshotResult","beforeChangeArgs","undefined","skipValidation","validate","lastPublished","published","query","where","equals","result","dataToUpdate","hash","salt","updatedAt","Date","toISOString","db","updateOne","snapshot","previousDoc"],"mappings":"AAgBA,SAASA,qBAAqB,QAAQ,yCAAwC;AAC9E,SAASC,wBAAwB,QAAQ,6DAA4D;AACrG,SAASC,cAAc,QAAQ,sCAAqC;AACpE,SAASC,WAAW,QAAQ,6CAA4C;AACxE,SAASC,SAAS,QAAQ,2CAA0C;AACpE,SAASC,YAAY,QAAQ,8CAA6C;AAC1E,SAASC,cAAc,QAAQ,gDAA+C;AAC9E,SAGEC,oBAAoB,QAGf,oBAAmB;AAC1B,SAASC,qBAAqB,QAAQ,4CAA2C;AACjF,SAASC,WAAW,QAAQ,kCAAiC;AAC7D,SAASC,uBAAuB,QAAQ,gDAA+C;AACvF,SAASC,0BAA0B,QAAQ,kDAAiD;AAC5F,SAASC,WAAW,QAAQ,mCAAkC;AAyB9D;;;;;;;;;;;;CAYC,GACD,OAAO,MAAMC,iBAAiB,OAG5B,EACAC,EAAE,EACFC,aAAa,EACbC,QAAQ,EACRC,gBAAgB,EAChBC,MAAM,EACNC,IAAI,EACJC,KAAK,EACLC,cAAc,EACdC,QAAQ,EACRC,cAAc,EACdC,aAAa,EACbC,MAAM,EACNC,cAAc,EACdC,YAAY,EACZC,OAAO,EACPC,QAAQ,EACRC,qBAAqB,EACrBC,GAAG,EACHC,MAAM,EACNC,gBAAgB,EACgB;IAChC,MAAMC,WAAWf,MAAMe;IACvB,MAAMC,kBACJC,QAAQd,YAAYL,iBAAiBoB,QAAQ,CAACC,MAAM,KAAKnB,KAAKoB,OAAO,KAAK;IAC5E,MAAMC,qBAAqBJ,QACzBF,YACEjB,iBAAiBwB,IAAI,IACpB,CAAA,CAACxB,iBAAiBwB,IAAI,CAACC,oBAAoB,IACzC,OA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;QACPC;QACA6B,QAAQ;QACR3B;QACAC;QACAG;QACAE;QACAC;QACAC;IACF;IAEA,wCAAwC;IACxC,yBAAyB;IACzB,wCAAwC;IAExC,IAAIhB,iBAAiBwC,KAAK,EAAErD,WAAWsD,QAAQ;QAC7C,KAAK,MAAMC,QAAQ1C,iBAAiBwC,KAAK,CAACrD,SAAS,CAAE;YACnDqE,SACE,AAAC,MAAMd,KAAK;gBACVX,YAAY/B;gBACZgC,SAASlB,IAAIkB,OAAO;gBACpBC,KAAKuB;gBACL1C;YACF,MAAO0C;QACX;IACF;IAEA,wCAAwC;IACxC,uBAAuB;IACvB,wCAAwC;IAExCA,SAAS,MAAMtE,YAAY;QACzB6C,YAAY/B;QACZgC,SAASlB,IAAIkB,OAAO;QACpB9B;QACA+B,KAAKuB;QACLrB,QAAQ;QACRE,WAAW;QACX6B,aAAapC;QACbhB;IACF;IAEA,wCAAwC;IACxC,2BAA2B;IAC3B,wCAAwC;IAExC,IAAId,iBAAiBwC,KAAK,EAAEtD,aAAauD,QAAQ;QAC/C,KAAK,MAAMC,QAAQ1C,iBAAiBwC,KAAK,CAACtD,WAAW,CAAE;YACrDsE,SACE,AAAC,MAAMd,KAAK;gBACVX,YAAY/B;gBACZgC,SAASlB,IAAIkB,OAAO;gBACpB9B;gBACA+B,KAAKuB;gBACLnB,WAAW;gBACX6B,aAAapC;gBACbhB;YACF,MAAO0C;QACX;IACF;IAEA,OAAOA;AACT,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/config/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAG1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAA;AAClE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,KAAK,EAC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M,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC5B,OAAO,EAAE,kBAAkB,EAAE,CAAA;CAC9B,GAAG,IAAI,CAAC,eAAe,EAAE,OAAO,GAAG,aAAa,GAAG,SAAS,GAAG,MAAM,GAAG,wBAAwB,CAAC,CAAA;AAElG,eAAO,MAAM,+BAA+B,EAAE,SAAS,OAAO,CAAC,6BAA6B,CAAC,EAAO,CAAA;AAEpG,eAAO,MAAM,0BAA0B,EAAE,SAAS,OAAO,CAAC,wBAAwB,CAAC,EAqBlF,CAAA;AAED,eAAO,MAAM,kBAAkB,iCAI5B;IACD,MAAM,EAAE,eAAe,CAAA;IACvB,IAAI,EAAE,UAAU,CAAA;IAChB,SAAS,EAAE,SAAS,CAAA;CACrB,KAAG,YAyJH,CAAA"}
@@ -77,6 +77,14 @@ export const createClientConfig = ({ config, i18n, importMap })=>{
77
77
  importMap
78
78
  });
79
79
  break;
80
+ case 'experimental':
81
+ if (config.experimental) {
82
+ clientConfig.experimental = {};
83
+ if (config.experimental?.localizeStatus) {
84
+ clientConfig.experimental.localizeStatus = config.experimental.localizeStatus;
85
+ }
86
+ }
87
+ break;
80
88
  case 'folders':
81
89
  if (config.folders) {
82
90
  clientConfig.folders = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/config/client.ts"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type { DeepPartial } from 'ts-essentials'\n\nimport type { ImportMap } from '../bin/generateImportMap/index.js'\nimport type { ClientBlock } from '../fields/config/types.js'\nimport type { BlockSlug } from '../index.js'\nimport type {\n RootLivePreviewConfig,\n SanitizedConfig,\n ServerOnlyLivePreviewProperties,\n} from './types.js'\n\nimport {\n type ClientCollectionConfig,\n createClientCollectionConfigs,\n} from '../collections/config/client.js'\nimport { createClientBlocks } from '../fields/config/client.js'\nimport { type ClientGlobalConfig, createClientGlobalConfigs } from '../globals/config/client.js'\n\nexport type ServerOnlyRootProperties = keyof Pick<\n SanitizedConfig,\n | 'bin'\n | 'cors'\n | 'csrf'\n | 'custom'\n | 'db'\n | 'editor'\n | 'email'\n | 'endpoints'\n | 'graphQL'\n | 'hooks'\n | 'i18n'\n | 'jobs'\n | 'logger'\n | 'onInit'\n | 'plugins'\n | 'queryPresets'\n | 'secret'\n | 'sharp'\n | 'typescript'\n>\n\nexport type ServerOnlyRootAdminProperties = keyof Pick<SanitizedConfig['admin'], 'components'>\n\nexport type UnsanitizedClientConfig = {\n admin: {\n livePreview?: Omit<RootLivePreviewConfig, ServerOnlyLivePreviewProperties>\n } & Omit<SanitizedConfig['admin'], 'components' | 'dependencies' | 'livePreview'>\n blocks: ClientBlock[]\n collections: ClientCollectionConfig[]\n custom?: Record<string, any>\n globals: ClientGlobalConfig[]\n} & Omit<SanitizedConfig, 'admin' | 'collections' | 'globals' | 'i18n' | ServerOnlyRootProperties>\n\nexport type ClientConfig = {\n admin: {\n livePreview?: Omit<RootLivePreviewConfig, ServerOnlyLivePreviewProperties>\n } & Omit<SanitizedConfig['admin'], 'components' | 'dependencies' | 'livePreview'>\n blocks: ClientBlock[]\n blocksMap: Record<BlockSlug, ClientBlock>\n collections: ClientCollectionConfig[]\n custom?: Record<string, any>\n globals: ClientGlobalConfig[]\n} & Omit<SanitizedConfig, 'admin' | 'collections' | 'globals' | 'i18n' | ServerOnlyRootProperties>\n\nexport const serverOnlyAdminConfigProperties: readonly Partial<ServerOnlyRootAdminProperties>[] = []\n\nexport const serverOnlyConfigProperties: readonly Partial<ServerOnlyRootProperties>[] = [\n 'endpoints',\n 'db',\n 'editor',\n 'plugins',\n 'sharp',\n 'onInit',\n 'secret',\n 'hooks',\n 'bin',\n 'i18n',\n 'typescript',\n 'cors',\n 'csrf',\n 'email',\n 'custom',\n 'graphQL',\n 'jobs',\n 'logger',\n 'queryPresets',\n // `admin`, `onInit`, `localization`, `collections`, and `globals` are all handled separately\n]\n\nexport const createClientConfig = ({\n config,\n i18n,\n importMap,\n}: {\n config: SanitizedConfig\n i18n: I18nClient\n importMap: ImportMap\n}): ClientConfig => {\n const clientConfig = {} as DeepPartial<ClientConfig>\n\n for (const key in config) {\n if (serverOnlyConfigProperties.includes(key as any)) {\n continue\n }\n\n switch (key) {\n case 'admin':\n clientConfig.admin = {\n autoLogin: config.admin.autoLogin,\n avatar: config.admin.avatar,\n custom: config.admin.custom,\n dateFormat: config.admin.dateFormat,\n importMap: config.admin.importMap,\n meta: config.admin.meta,\n routes: config.admin.routes,\n theme: config.admin.theme,\n timezones: config.admin.timezones,\n toast: config.admin.toast,\n user: config.admin.user,\n }\n\n if (config.admin.livePreview) {\n clientConfig.admin.livePreview = {}\n\n if (config.admin.livePreview.breakpoints) {\n clientConfig.admin.livePreview.breakpoints = config.admin.livePreview.breakpoints\n }\n\n if (config.admin.livePreview.collections) {\n clientConfig.admin.livePreview.collections = config.admin.livePreview.collections\n }\n\n if (config.admin.livePreview.globals) {\n clientConfig.admin.livePreview.globals = config.admin.livePreview.globals\n }\n }\n\n break\n\n case 'blocks': {\n ;(clientConfig.blocks as ClientBlock[]) = createClientBlocks({\n blocks: config.blocks!,\n defaultIDType: config.db.defaultIDType,\n i18n,\n importMap,\n }).filter((block) => typeof block !== 'string') as ClientBlock[]\n\n break\n }\n\n case 'collections':\n ;(clientConfig.collections as ClientCollectionConfig[]) = createClientCollectionConfigs({\n collections: config.collections,\n defaultIDType: config.db.defaultIDType,\n i18n,\n importMap,\n })\n\n break\n\n case 'folders':\n if (config.folders) {\n clientConfig.folders = {\n slug: config.folders.slug,\n browseByFolder: config.folders.browseByFolder,\n debug: config.folders.debug,\n fieldName: config.folders.fieldName,\n }\n }\n\n break\n\n case 'globals':\n ;(clientConfig.globals as ClientGlobalConfig[]) = createClientGlobalConfigs({\n defaultIDType: config.db.defaultIDType,\n globals: config.globals,\n i18n,\n importMap,\n })\n\n break\n\n case 'localization':\n if (typeof config.localization === 'object' && config.localization) {\n clientConfig.localization = {}\n\n if (config.localization.defaultLocale) {\n clientConfig.localization.defaultLocale = config.localization.defaultLocale\n }\n\n if (config.localization.defaultLocalePublishOption) {\n clientConfig.localization.defaultLocalePublishOption =\n config.localization.defaultLocalePublishOption\n }\n\n if (config.localization.fallback) {\n clientConfig.localization.fallback = config.localization.fallback\n }\n\n if (config.localization.localeCodes) {\n clientConfig.localization.localeCodes = config.localization.localeCodes\n }\n\n if (config.localization.locales) {\n clientConfig.localization.locales = []\n\n for (const locale of config.localization.locales) {\n if (locale) {\n const clientLocale: Partial<(typeof config.localization.locales)[0]> = {}\n\n if (locale.code) {\n clientLocale.code = locale.code\n }\n\n if (locale.fallbackLocale) {\n clientLocale.fallbackLocale = locale.fallbackLocale\n }\n\n if (locale.label) {\n clientLocale.label = locale.label\n }\n\n if (locale.rtl) {\n clientLocale.rtl = locale.rtl\n }\n\n clientConfig.localization.locales.push(clientLocale)\n }\n }\n }\n }\n\n break\n\n default:\n ;(clientConfig as any)[key] = config[key as keyof SanitizedConfig]\n }\n }\n\n return clientConfig as ClientConfig\n}\n"],"names":["createClientCollectionConfigs","createClientBlocks","createClientGlobalConfigs","serverOnlyAdminConfigProperties","serverOnlyConfigProperties","createClientConfig","config","i18n","importMap","clientConfig","key","includes","admin","autoLogin","avatar","custom","dateFormat","meta","routes","theme","timezones","toast","user","livePreview","breakpoints","collections","globals","blocks","defaultIDType","db","filter","block","folders","slug","browseByFolder","debug","fieldName","localization","defaultLocale","defaultLocalePublishOption","fallback","localeCodes","locales","locale","clientLocale","code","fallbackLocale","label","rtl","push"],"mappings":"AAYA,SAEEA,6BAA6B,QACxB,kCAAiC;AACxC,SAASC,kBAAkB,QAAQ,6BAA4B;AAC/D,SAAkCC,yBAAyB,QAAQ,8BAA6B;AAgDhG,OAAO,MAAMC,kCAAqF,EAAE,CAAA;AAEpG,OAAO,MAAMC,6BAA2E;IACtF;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CAED,CAAA;AAED,OAAO,MAAMC,qBAAqB,CAAC,EACjC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AY,CAACG,QAAQ,EAAE;wBAChC/B,aAAa4B,YAAY,CAACG,QAAQ,GAAGlC,OAAO+B,YAAY,CAACG,QAAQ;oBACnE;oBAEA,IAAIlC,OAAO+B,YAAY,CAACI,WAAW,EAAE;wBACnChC,aAAa4B,YAAY,CAACI,WAAW,GAAGnC,OAAO+B,YAAY,CAACI,WAAW;oBACzE;oBAEA,IAAInC,OAAO+B,YAAY,CAACK,OAAO,EAAE;wBAC/BjC,aAAa4B,YAAY,CAACK,OAAO,GAAG,EAAE;wBAEtC,KAAK,MAAMC,UAAUrC,OAAO+B,YAAY,CAACK,OAAO,CAAE;4BAChD,IAAIC,QAAQ;gCACV,MAAMC,eAAiE,CAAC;gCAExE,IAAID,OAAOE,IAAI,EAAE;oCACfD,aAAaC,IAAI,GAAGF,OAAOE,IAAI;gCACjC;gCAEA,IAAIF,OAAOG,cAAc,EAAE;oCACzBF,aAAaE,cAAc,GAAGH,OAAOG,cAAc;gCACrD;gCAEA,IAAIH,OAAOI,KAAK,EAAE;oCAChBH,aAAaG,KAAK,GAAGJ,OAAOI,KAAK;gCACnC;gCAEA,IAAIJ,OAAOK,GAAG,EAAE;oCACdJ,aAAaI,GAAG,GAAGL,OAAOK,GAAG;gCAC/B;gCAEAvC,aAAa4B,YAAY,CAACK,OAAO,CAACO,IAAI,CAACL;4BACzC;wBACF;oBACF;gBACF;gBAEA;YAEF;;gBACInC,YAAoB,CAACC,IAAI,GAAGJ,MAAM,CAACI,IAA6B;QACtE;IACF;IAEA,OAAOD;AACT,EAAC"}
1
+ {"version":3,"sources":["../../src/config/client.ts"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type { DeepPartial } from 'ts-essentials'\n\nimport type { ImportMap } from '../bin/generateImportMap/index.js'\nimport type { ClientBlock } from '../fields/config/types.js'\nimport type { BlockSlug } from '../index.js'\nimport type {\n RootLivePreviewConfig,\n SanitizedConfig,\n ServerOnlyLivePreviewProperties,\n} from './types.js'\n\nimport {\n type ClientCollectionConfig,\n createClientCollectionConfigs,\n} from '../collections/config/client.js'\nimport { createClientBlocks } from '../fields/config/client.js'\nimport { type ClientGlobalConfig, createClientGlobalConfigs } from '../globals/config/client.js'\n\nexport type ServerOnlyRootProperties = keyof Pick<\n SanitizedConfig,\n | 'bin'\n | 'cors'\n | 'csrf'\n | 'custom'\n | 'db'\n | 'editor'\n | 'email'\n | 'endpoints'\n | 'graphQL'\n | 'hooks'\n | 'i18n'\n | 'jobs'\n | 'logger'\n | 'onInit'\n | 'plugins'\n | 'queryPresets'\n | 'secret'\n | 'sharp'\n | 'typescript'\n>\n\nexport type ServerOnlyRootAdminProperties = keyof Pick<SanitizedConfig['admin'], 'components'>\n\nexport type UnsanitizedClientConfig = {\n admin: {\n livePreview?: Omit<RootLivePreviewConfig, ServerOnlyLivePreviewProperties>\n } & Omit<SanitizedConfig['admin'], 'components' | 'dependencies' | 'livePreview'>\n blocks: ClientBlock[]\n collections: ClientCollectionConfig[]\n custom?: Record<string, any>\n globals: ClientGlobalConfig[]\n} & Omit<SanitizedConfig, 'admin' | 'collections' | 'globals' | 'i18n' | ServerOnlyRootProperties>\n\nexport type ClientConfig = {\n admin: {\n livePreview?: Omit<RootLivePreviewConfig, ServerOnlyLivePreviewProperties>\n } & Omit<SanitizedConfig['admin'], 'components' | 'dependencies' | 'livePreview'>\n blocks: ClientBlock[]\n blocksMap: Record<BlockSlug, ClientBlock>\n collections: ClientCollectionConfig[]\n custom?: Record<string, any>\n globals: ClientGlobalConfig[]\n} & Omit<SanitizedConfig, 'admin' | 'collections' | 'globals' | 'i18n' | ServerOnlyRootProperties>\n\nexport const serverOnlyAdminConfigProperties: readonly Partial<ServerOnlyRootAdminProperties>[] = []\n\nexport const serverOnlyConfigProperties: readonly Partial<ServerOnlyRootProperties>[] = [\n 'endpoints',\n 'db',\n 'editor',\n 'plugins',\n 'sharp',\n 'onInit',\n 'secret',\n 'hooks',\n 'bin',\n 'i18n',\n 'typescript',\n 'cors',\n 'csrf',\n 'email',\n 'custom',\n 'graphQL',\n 'jobs',\n 'logger',\n 'queryPresets',\n // `admin`, `onInit`, `localization`, `collections`, and `globals` are all handled separately\n]\n\nexport const createClientConfig = ({\n config,\n i18n,\n importMap,\n}: {\n config: SanitizedConfig\n i18n: I18nClient\n importMap: ImportMap\n}): ClientConfig => {\n const clientConfig = {} as DeepPartial<ClientConfig>\n\n for (const key in config) {\n if (serverOnlyConfigProperties.includes(key as any)) {\n continue\n }\n\n switch (key) {\n case 'admin':\n clientConfig.admin = {\n autoLogin: config.admin.autoLogin,\n avatar: config.admin.avatar,\n custom: config.admin.custom,\n dateFormat: config.admin.dateFormat,\n importMap: config.admin.importMap,\n meta: config.admin.meta,\n routes: config.admin.routes,\n theme: config.admin.theme,\n timezones: config.admin.timezones,\n toast: config.admin.toast,\n user: config.admin.user,\n }\n\n if (config.admin.livePreview) {\n clientConfig.admin.livePreview = {}\n\n if (config.admin.livePreview.breakpoints) {\n clientConfig.admin.livePreview.breakpoints = config.admin.livePreview.breakpoints\n }\n\n if (config.admin.livePreview.collections) {\n clientConfig.admin.livePreview.collections = config.admin.livePreview.collections\n }\n\n if (config.admin.livePreview.globals) {\n clientConfig.admin.livePreview.globals = config.admin.livePreview.globals\n }\n }\n\n break\n\n case 'blocks': {\n ;(clientConfig.blocks as ClientBlock[]) = createClientBlocks({\n blocks: config.blocks!,\n defaultIDType: config.db.defaultIDType,\n i18n,\n importMap,\n }).filter((block) => typeof block !== 'string') as ClientBlock[]\n\n break\n }\n\n case 'collections':\n ;(clientConfig.collections as ClientCollectionConfig[]) = createClientCollectionConfigs({\n collections: config.collections,\n defaultIDType: config.db.defaultIDType,\n i18n,\n importMap,\n })\n\n break\n\n case 'experimental':\n if (config.experimental) {\n clientConfig.experimental = {}\n if (config.experimental?.localizeStatus) {\n clientConfig.experimental.localizeStatus = config.experimental.localizeStatus\n }\n }\n\n break\n\n case 'folders':\n if (config.folders) {\n clientConfig.folders = {\n slug: config.folders.slug,\n browseByFolder: config.folders.browseByFolder,\n debug: config.folders.debug,\n fieldName: config.folders.fieldName,\n }\n }\n\n break\n\n case 'globals':\n ;(clientConfig.globals as ClientGlobalConfig[]) = createClientGlobalConfigs({\n defaultIDType: config.db.defaultIDType,\n globals: config.globals,\n i18n,\n importMap,\n })\n\n break\n\n case 'localization':\n if (typeof config.localization === 'object' && config.localization) {\n clientConfig.localization = {}\n\n if (config.localization.defaultLocale) {\n clientConfig.localization.defaultLocale = config.localization.defaultLocale\n }\n\n if (config.localization.defaultLocalePublishOption) {\n clientConfig.localization.defaultLocalePublishOption =\n config.localization.defaultLocalePublishOption\n }\n\n if (config.localization.fallback) {\n clientConfig.localization.fallback = config.localization.fallback\n }\n\n if (config.localization.localeCodes) {\n clientConfig.localization.localeCodes = config.localization.localeCodes\n }\n\n if (config.localization.locales) {\n clientConfig.localization.locales = []\n\n for (const locale of config.localization.locales) {\n if (locale) {\n const clientLocale: Partial<(typeof config.localization.locales)[0]> = {}\n\n if (locale.code) {\n clientLocale.code = locale.code\n }\n\n if (locale.fallbackLocale) {\n clientLocale.fallbackLocale = locale.fallbackLocale\n }\n\n if (locale.label) {\n clientLocale.label = locale.label\n }\n\n if (locale.rtl) {\n clientLocale.rtl = locale.rtl\n }\n\n clientConfig.localization.locales.push(clientLocale)\n }\n }\n }\n }\n\n break\n\n default:\n ;(clientConfig as any)[key] = config[key as keyof SanitizedConfig]\n }\n }\n\n return clientConfig as ClientConfig\n}\n"],"names":["createClientCollectionConfigs","createClientBlocks","createClientGlobalConfigs","serverOnlyAdminConfigProperties","serverOnlyConfigProperties","createClientConfig","config","i18n","importMap","clientConfig","key","includes","admin","autoLogin","avatar","custom","dateFormat","meta","routes","theme","timezones","toast","user","livePreview","breakpoints","collections","globals","blocks","defaultIDType","db","filter","block","experimental","localizeStatus","folders","slug","browseByFolder","debug","fieldName","localization","defaultLocale","defaultLocalePublishOption","fallback","localeCodes","locales","locale","clientLocale","code","fallbackLocale","label","rtl","push"],"mappings":"AAYA,SAEEA,6BAA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GAAG,EAAE;oCACdJ,aAAaI,GAAG,GAAGL,OAAOK,GAAG;gCAC/B;gCAEAzC,aAAa8B,YAAY,CAACK,OAAO,CAACO,IAAI,CAACL;4BACzC;wBACF;oBACF;gBACF;gBAEA;YAEF;;gBACIrC,YAAoB,CAACC,IAAI,GAAGJ,MAAM,CAACI,IAA6B;QACtE;IACF;IAEA,OAAOD;AACT,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/config/defaults.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAKxC;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,GAAG,QAAQ,GAAG,QAAQ,CAsE7D,CAAA;AAED,eAAO,MAAM,mBAAmB,WAAY,MAAM,KAAG,MAqGpD,CAAA"}
1
+ {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/config/defaults.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAKxC;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,GAAG,QAAQ,GAAG,QAAQ,CAuE7D,CAAA;AAED,eAAO,MAAM,mBAAmB,WAAY,MAAM,KAAG,MAsGpD,CAAA"}
@@ -46,6 +46,7 @@ import { foldersSlug, parentFolderFieldName } from '../folders/constants.js';
46
46
  defaultDepth: 2,
47
47
  defaultMaxTextLength: 40000,
48
48
  endpoints: [],
49
+ experimental: {},
49
50
  globals: [],
50
51
  graphQL: {
51
52
  disablePlaygroundInProduction: true,
@@ -118,6 +119,7 @@ export const addDefaultsToConfig = (config)=>{
118
119
  config.defaultDepth = config.defaultDepth ?? 2;
119
120
  config.defaultMaxTextLength = config.defaultMaxTextLength ?? 40000;
120
121
  config.endpoints = config.endpoints ?? [];
122
+ config.experimental = config.experimental ?? {};
121
123
  config.globals = config.globals ?? [];
122
124
  config.graphQL = {
123
125
  disableIntrospectionInProduction: true,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/config/defaults.ts"],"sourcesContent":["import type { JobsConfig } from '../queues/config/types/index.js'\nimport type { Config } from './types.js'\n\nimport { defaultAccess } from '../auth/defaultAccess.js'\nimport { foldersSlug, parentFolderFieldName } from '../folders/constants.js'\n\n/**\n * @deprecated - remove in 4.0. This is error-prone, as mutating this object will affect any objects that use the defaults as a base.\n */\nexport const defaults: Omit<Config, 'db' | 'editor' | 'secret'> = {\n admin: {\n avatar: 'gravatar',\n components: {},\n custom: {},\n dateFormat: 'MMMM do yyyy, h:mm a',\n dependencies: {},\n importMap: {\n baseDir: `${typeof process?.cwd === 'function' ? process.cwd() : ''}`,\n },\n meta: {\n defaultOGImageType: 'dynamic',\n robots: 'noindex, nofollow',\n titleSuffix: '- Payload',\n },\n routes: {\n account: '/account',\n browseByFolder: '/browse-by-folder',\n createFirstUser: '/create-first-user',\n forgot: '/forgot',\n inactivity: '/logout-inactivity',\n login: '/login',\n logout: '/logout',\n reset: '/reset',\n unauthorized: '/unauthorized',\n },\n theme: 'all',\n },\n auth: {\n jwtOrder: ['JWT', 'Bearer', 'cookie'],\n },\n bin: [],\n collections: [],\n cookiePrefix: 'payload',\n cors: [],\n csrf: [],\n custom: {},\n defaultDepth: 2,\n defaultMaxTextLength: 40000,\n endpoints: [],\n globals: [],\n graphQL: {\n disablePlaygroundInProduction: true,\n maxComplexity: 1000,\n schemaOutputFile: `${typeof process?.cwd === 'function' ? process.cwd() : ''}/schema.graphql`,\n },\n hooks: {},\n i18n: {},\n jobs: {\n access: {\n run: defaultAccess,\n },\n deleteJobOnComplete: true,\n depth: 0,\n } as JobsConfig,\n localization: false,\n maxDepth: 10,\n routes: {\n admin: '/admin',\n api: '/api',\n graphQL: '/graphql',\n graphQLPlayground: '/graphql-playground',\n },\n serverURL: '',\n telemetry: true,\n typescript: {\n autoGenerate: true,\n outputFile: `${typeof process?.cwd === 'function' ? process.cwd() : ''}/payload-types.ts`,\n },\n upload: {},\n}\n\nexport const addDefaultsToConfig = (config: Config): Config => {\n config.admin = {\n avatar: 'gravatar',\n components: {},\n custom: {},\n dateFormat: 'MMMM do yyyy, h:mm a',\n dependencies: {},\n theme: 'all',\n ...(config.admin || {}),\n importMap: {\n baseDir: `${typeof process?.cwd === 'function' ? process.cwd() : ''}`,\n ...(config?.admin?.importMap || {}),\n },\n meta: {\n defaultOGImageType: 'dynamic',\n robots: 'noindex, nofollow',\n titleSuffix: '- Payload',\n ...(config?.admin?.meta || {}),\n },\n routes: {\n account: '/account',\n browseByFolder: '/browse-by-folder',\n createFirstUser: '/create-first-user',\n forgot: '/forgot',\n inactivity: '/logout-inactivity',\n login: '/login',\n logout: '/logout',\n reset: '/reset',\n unauthorized: '/unauthorized',\n ...(config?.admin?.routes || {}),\n },\n }\n\n config.bin = config.bin ?? []\n config.collections = config.collections ?? []\n config.cookiePrefix = config.cookiePrefix ?? 'payload'\n config.cors = config.cors ?? []\n config.csrf = config.csrf ?? []\n config.custom = config.custom ?? {}\n config.defaultDepth = config.defaultDepth ?? 2\n config.defaultMaxTextLength = config.defaultMaxTextLength ?? 40000\n config.endpoints = config.endpoints ?? []\n config.globals = config.globals ?? []\n config.graphQL = {\n disableIntrospectionInProduction: true,\n disablePlaygroundInProduction: true,\n maxComplexity: 1000,\n schemaOutputFile: `${typeof process?.cwd === 'function' ? process.cwd() : ''}/schema.graphql`,\n ...(config.graphQL || {}),\n }\n config.hooks = config.hooks ?? {}\n config.i18n = config.i18n ?? {}\n config.jobs = {\n deleteJobOnComplete: true,\n depth: 0,\n ...(config.jobs || {}),\n access: {\n run: defaultAccess,\n ...(config.jobs?.access || {}),\n },\n } as JobsConfig\n config.localization = config.localization ?? false\n config.maxDepth = config.maxDepth ?? 10\n config.routes = {\n admin: '/admin',\n api: (process.env.NEXT_BASE_PATH ?? '') + '/api',\n graphQL: '/graphql',\n graphQLPlayground: '/graphql-playground',\n ...(config.routes || {}),\n }\n config.serverURL = config.serverURL ?? ''\n config.telemetry = config.telemetry ?? true\n config.typescript = {\n autoGenerate: true,\n outputFile: `${typeof process?.cwd === 'function' ? process.cwd() : ''}/payload-types.ts`,\n ...(config.typescript || {}),\n }\n config.upload = config.upload ?? {}\n\n config.auth = {\n jwtOrder: ['JWT', 'Bearer', 'cookie'],\n ...(config.auth || {}),\n }\n\n if (\n config.folders !== false &&\n config.collections.some((collection) => Boolean(collection.folders))\n ) {\n config.folders = {\n slug: config.folders?.slug ?? foldersSlug,\n browseByFolder: config.folders?.browseByFolder ?? true,\n collectionOverrides: config.folders?.collectionOverrides || undefined,\n collectionSpecific: config.folders?.collectionSpecific ?? true,\n debug: config.folders?.debug ?? false,\n fieldName: config.folders?.fieldName ?? parentFolderFieldName,\n }\n } else {\n config.folders = false\n }\n\n return config\n}\n"],"names":["defaultAccess","foldersSlug","parentFolderFieldName","defaults","admin","avatar","components","custom","dateFormat","dependencies","importMap","baseDir","process","cwd","meta","defaultOGImageType","robots","titleSuffix","routes","account","browseByFolder","createFirstUser","forgot","inactivity","login","logout","reset","unauthorized","theme","auth","jwtOrder","bin","collections","cookiePrefix","cors","csrf","defaultDepth","defaultMaxTextLength","endpoints","globals","graphQL","disablePlaygroundInProduction","maxComplexity","schemaOutputFile","hooks","i18n","jobs","access","run","deleteJobOnComplete","depth","localization","maxDepth","api","graphQLPlayground","serverURL","telemetry","typescript","autoGenerate","outputFile","upload","addDefaultsToConfig","config","disableIntrospectionInProduction","env","NEXT_BASE_PATH","folders","some","collection","Boolean","slug","collectionOverrides","undefined","collectionSpecific","debug","fieldName"],"mappings":"AAGA,SAASA,aAAa,QAAQ,2BAA0B;AACxD,SAASC,WAAW,EAAEC,qBAAqB,QAAQ,0BAAyB;AAE5E;;CAEC,GACD,OAAO,MAAMC,WAAqD;IAChEC,OAAO;QACLC,QAAQ;QACRC,YAAY,CAAC;QACbC,QAAQ,CAAC;QACTC,YAAY;QACZC,cAAc,C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QrE;YAC9BmB,gBAAgB0C,OAAOI,OAAO,EAAE9C,kBAAkB;YAClDmD,qBAAqBT,OAAOI,OAAO,EAAEK,uBAAuBC;YAC5DC,oBAAoBX,OAAOI,OAAO,EAAEO,sBAAsB;YAC1DC,OAAOZ,OAAOI,OAAO,EAAEQ,SAAS;YAChCC,WAAWb,OAAOI,OAAO,EAAES,aAAazE;QAC1C;IACF,OAAO;QACL4D,OAAOI,OAAO,GAAG;IACnB;IAEA,OAAOJ;AACT,EAAC"}
1
+ {"version":3,"sources":["../../src/config/defaults.ts"],"sourcesContent":["import type { JobsConfig } from '../queues/config/types/index.js'\nimport type { Config } from './types.js'\n\nimport { defaultAccess } from '../auth/defaultAccess.js'\nimport { foldersSlug, parentFolderFieldName } from '../folders/constants.js'\n\n/**\n * @deprecated - remove in 4.0. This is error-prone, as mutating this object will affect any objects that use the defaults as a base.\n */\nexport const defaults: Omit<Config, 'db' | 'editor' | 'secret'> = {\n admin: {\n avatar: 'gravatar',\n components: {},\n custom: {},\n dateFormat: 'MMMM do yyyy, h:mm a',\n dependencies: {},\n importMap: {\n baseDir: `${typeof process?.cwd === 'function' ? process.cwd() : ''}`,\n },\n meta: {\n defaultOGImageType: 'dynamic',\n robots: 'noindex, nofollow',\n titleSuffix: '- Payload',\n },\n routes: {\n account: '/account',\n browseByFolder: '/browse-by-folder',\n createFirstUser: '/create-first-user',\n forgot: '/forgot',\n inactivity: '/logout-inactivity',\n login: '/login',\n logout: '/logout',\n reset: '/reset',\n unauthorized: '/unauthorized',\n },\n theme: 'all',\n },\n auth: {\n jwtOrder: ['JWT', 'Bearer', 'cookie'],\n },\n bin: [],\n collections: [],\n cookiePrefix: 'payload',\n cors: [],\n csrf: [],\n custom: {},\n defaultDepth: 2,\n defaultMaxTextLength: 40000,\n endpoints: [],\n experimental: {},\n globals: [],\n graphQL: {\n disablePlaygroundInProduction: true,\n maxComplexity: 1000,\n schemaOutputFile: `${typeof process?.cwd === 'function' ? process.cwd() : ''}/schema.graphql`,\n },\n hooks: {},\n i18n: {},\n jobs: {\n access: {\n run: defaultAccess,\n },\n deleteJobOnComplete: true,\n depth: 0,\n } as JobsConfig,\n localization: false,\n maxDepth: 10,\n routes: {\n admin: '/admin',\n api: '/api',\n graphQL: '/graphql',\n graphQLPlayground: '/graphql-playground',\n },\n serverURL: '',\n telemetry: true,\n typescript: {\n autoGenerate: true,\n outputFile: `${typeof process?.cwd === 'function' ? process.cwd() : ''}/payload-types.ts`,\n },\n upload: {},\n}\n\nexport const addDefaultsToConfig = (config: Config): Config => {\n config.admin = {\n avatar: 'gravatar',\n components: {},\n custom: {},\n dateFormat: 'MMMM do yyyy, h:mm a',\n dependencies: {},\n theme: 'all',\n ...(config.admin || {}),\n importMap: {\n baseDir: `${typeof process?.cwd === 'function' ? process.cwd() : ''}`,\n ...(config?.admin?.importMap || {}),\n },\n meta: {\n defaultOGImageType: 'dynamic',\n robots: 'noindex, nofollow',\n titleSuffix: '- Payload',\n ...(config?.admin?.meta || {}),\n },\n routes: {\n account: '/account',\n browseByFolder: '/browse-by-folder',\n createFirstUser: '/create-first-user',\n forgot: '/forgot',\n inactivity: '/logout-inactivity',\n login: '/login',\n logout: '/logout',\n reset: '/reset',\n unauthorized: '/unauthorized',\n ...(config?.admin?.routes || {}),\n },\n }\n\n config.bin = config.bin ?? []\n config.collections = config.collections ?? []\n config.cookiePrefix = config.cookiePrefix ?? 'payload'\n config.cors = config.cors ?? []\n config.csrf = config.csrf ?? []\n config.custom = config.custom ?? {}\n config.defaultDepth = config.defaultDepth ?? 2\n config.defaultMaxTextLength = config.defaultMaxTextLength ?? 40000\n config.endpoints = config.endpoints ?? []\n config.experimental = config.experimental ?? {}\n config.globals = config.globals ?? []\n config.graphQL = {\n disableIntrospectionInProduction: true,\n disablePlaygroundInProduction: true,\n maxComplexity: 1000,\n schemaOutputFile: `${typeof process?.cwd === 'function' ? process.cwd() : ''}/schema.graphql`,\n ...(config.graphQL || {}),\n }\n config.hooks = config.hooks ?? {}\n config.i18n = config.i18n ?? {}\n config.jobs = {\n deleteJobOnComplete: true,\n depth: 0,\n ...(config.jobs || {}),\n access: {\n run: defaultAccess,\n ...(config.jobs?.access || {}),\n },\n } as JobsConfig\n config.localization = config.localization ?? false\n config.maxDepth = config.maxDepth ?? 10\n config.routes = {\n admin: '/admin',\n api: (process.env.NEXT_BASE_PATH ?? '') + '/api',\n graphQL: '/graphql',\n graphQLPlayground: '/graphql-playground',\n ...(config.routes || {}),\n }\n config.serverURL = config.serverURL ?? ''\n config.telemetry = config.telemetry ?? true\n config.typescript = {\n autoGenerate: true,\n outputFile: `${typeof process?.cwd === 'function' ? process.cwd() : ''}/payload-types.ts`,\n ...(config.typescript || {}),\n }\n config.upload = config.upload ?? {}\n\n config.auth = {\n jwtOrder: ['JWT', 'Bearer', 'cookie'],\n ...(config.auth || {}),\n }\n\n if (\n config.folders !== false &&\n config.collections.some((collection) => Boolean(collection.folders))\n ) {\n config.folders = {\n slug: config.folders?.slug ?? foldersSlug,\n browseByFolder: config.folders?.browseByFolder ?? true,\n collectionOverrides: config.folders?.collectionOverrides || undefined,\n collectionSpecific: config.folders?.collectionSpecific ?? true,\n debug: config.folders?.debug ?? false,\n fieldName: config.folders?.fieldName ?? parentFolderFieldName,\n }\n } else {\n config.folders = false\n }\n\n return config\n}\n"],"names":["defaultAccess","foldersSlug","parentFolderFieldName","defaults","admin","avatar","components","custom","dateFormat","dependencies","importMap","baseDir","process","cwd","meta","defaultOGImageType","robots","titleSuffix","routes","account","browseByFolder","createFirstUser","forgot","inactivity","login","logout","reset","unauthorized","theme","auth","jwtOrder","bin","collections","cookiePrefix","cors","csrf","defaultDepth","defaultMaxTextLength","endpoints","experimental","globals","graphQL","disablePlaygroundInProduction","maxComplexity","schemaOutputFile","hooks","i18n","jobs","access","run","deleteJobOnComplete","depth","localization","maxDepth","api","graphQLPlayground","serverURL","telemetry","typescript","autoGenerate","outputFile","upload","addDefaultsToConfig","config","disableIntrospectionInProduction","env","NEXT_BASE_PATH","folders","some","collection","Boolean","slug","collectionOverrides","undefined","collectionSpecific","debug","fieldName"],"mappings":"AAGA,SAASA,aAAa,QAAQ,2BAA0B;AACxD,SAASC,WAAW,EAAEC,qBAAqB,QAAQ,0BAAyB;AAE5E;;CAEC,GACD,OAAO,MAAMC,WAAqD;IAChEC,OAAO;QACLC,QAAQ;QACRC,YAAY,CAAC;QACbC,QAAQ,CAAC;QACTC,YAAY;QACZC,cAAc,CAAC;QACfC,WAAW;YACTC,SAAS,GAAG,OAAOC,SAASC,QAAQ,aAAaD,QAAQC,GAAG,KAAK,IAAI;QACvE;QACAC,MAAM;YACJC,oBAAoB;YACpBC,QAAQ;YACRC,aAAa;QACf;QACAC,QAAQ;YACNC,SAAS;YACTC,gBAAgB;YAChBC,iBAAiB;YACjBC,QAAQ;YACRC,YAAY;YACZC,OAAO;YACPC,QAAQ;YACRC,OAAO;YACPC,cAAc;QAChB;QACAC,OAAO;IACT;IACAC,MAAM;QACJC,UAAU;YAAC;YAAO;YAAU;SAAS;IACvC;IACAC,KAAK,EAAE;IACPC,aAAa,EAAE;IACfC,cAAc;IACdC,MAAM,EAAE;IACRC,MAAM,EAAE;IACR5B,QAAQ,CAAC;IACT6B,cAAc;IACdC,sBAAsB;IACtBC,WAAW,EAAE;IACbC,cAAc,CAAC;IACfC,SAAS,EAAE;IACXC,SAAS;QACPC,+BAA+B;QAC/BC,eAAe;QACfC,kBAAkB,GAAG,OAAOhC,SAASC,QAAQ,aAAaD,QAAQC,GAAG,KAAK,GAAG,eAAe,CAAC;IAC/F;IACAgC,OAAO,CAAC;IACRC,MAAM,CAAC;IACPC,MAAM;QACJC,QAAQ;YACNC,KAAKjD;QACP;QACAkD,qBAAqB;QACrBC,OAAO;IACT;IACAC,cAAc;IACdC,UAAU;IACVnC,QAAQ;QACNd,OAAO;QACPkD,KAAK;QACLb,SAAS;QACTc,mBAAmB;IACrB;IACAC,WAAW;IACXC,WAAW;IACXC,YAAY;QACVC,cAAc;QACdC,YAAY,GA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IAC7B;IACAK,OAAOF,MAAM,GAAGE,OAAOF,MAAM,IAAI,CAAC;IAElCE,OAAOlC,IAAI,GAAG;QACZC,UAAU;YAAC;YAAO;YAAU;SAAS;QACrC,GAAIiC,OAAOlC,IAAI,IAAI,CAAC,CAAC;IACvB;IAEA,IACEkC,OAAOI,OAAO,KAAK,SACnBJ,OAAO/B,WAAW,CAACoC,IAAI,CAAC,CAACC,aAAeC,QAAQD,WAAWF,OAAO,IAClE;QACAJ,OAAOI,OAAO,GAAG;YACfI,MAAMR,OAAOI,OAAO,EAAEI,QAAQtE;YAC9BmB,gBAAgB2C,OAAOI,OAAO,EAAE/C,kBAAkB;YAClDoD,qBAAqBT,OAAOI,OAAO,EAAEK,uBAAuBC;YAC5DC,oBAAoBX,OAAOI,OAAO,EAAEO,sBAAsB;YAC1DC,OAAOZ,OAAOI,OAAO,EAAEQ,SAAS;YAChCC,WAAWb,OAAOI,OAAO,EAAES,aAAa1E;QAC1C;IACF,OAAO;QACL6D,OAAOI,OAAO,GAAG;IACnB;IAEA,OAAOJ;AACT,EAAC"}
@@ -549,6 +549,13 @@ export type ImportMapGenerators = Array<(props: {
549
549
  importMap: InternalImportMap;
550
550
  imports: Imports;
551
551
  }) => void>;
552
+ /**
553
+ * Experimental features.
554
+ * These may be unstable and may change or be removed in future releases.
555
+ */
556
+ export type ExperimentalConfig = {
557
+ localizeStatus?: boolean;
558
+ };
552
559
  export type AfterErrorHook = (args: AfterErrorHookArgs) => AfterErrorResult | Promise<AfterErrorResult>;
553
560
  /**
554
561
  * This is the central configuration
@@ -860,6 +867,12 @@ export type Config = {
860
867
  email?: EmailAdapter | Promise<EmailAdapter>;
861
868
  /** Custom REST endpoints */
862
869
  endpoints?: Endpoint[];
870
+ /**
871
+ * Configure experimental features for Payload.
872
+ *
873
+ * These features may be unstable and may change or be removed in future releases.
874
+ */
875
+ experimental?: ExperimentalConfig;
863
876
  /**
864
877
  * Options for folder view within the admin panel
865
878
  * @experimental this feature may change in minor versions until it is fully stable
@@ -1119,6 +1132,7 @@ export type SanitizedConfig = {
1119
1132
  /** Default richtext editor to use for richText fields */
1120
1133
  editor?: RichTextAdapter<any, any, any>;
1121
1134
  endpoints: Endpoint[];
1135
+ experimental?: ExperimentalConfig;
1122
1136
  globals: SanitizedGlobalConfig[];
1123
1137
  i18n: Required<I18nOptions>;
1124
1138
  jobs: SanitizedJobsConfig;