payload 3.74.0-internal.b78b222 → 3.74.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin/functions/index.d.ts +5 -12
- package/dist/admin/functions/index.d.ts.map +1 -1
- package/dist/admin/functions/index.js.map +1 -1
- package/dist/admin/types.d.ts +1 -1
- package/dist/admin/types.d.ts.map +1 -1
- package/dist/admin/types.js.map +1 -1
- package/dist/admin/views/dashboard.d.ts +3 -2
- package/dist/admin/views/dashboard.d.ts.map +1 -1
- package/dist/admin/views/dashboard.js.map +1 -1
- package/dist/auth/operations/forgotPassword.d.ts +3 -3
- package/dist/auth/operations/forgotPassword.d.ts.map +1 -1
- package/dist/auth/operations/forgotPassword.js.map +1 -1
- package/dist/auth/operations/local/forgotPassword.d.ts +4 -4
- package/dist/auth/operations/local/forgotPassword.d.ts.map +1 -1
- package/dist/auth/operations/local/forgotPassword.js.map +1 -1
- package/dist/auth/operations/local/login.d.ts +6 -4
- package/dist/auth/operations/local/login.d.ts.map +1 -1
- package/dist/auth/operations/local/login.js.map +1 -1
- package/dist/auth/operations/local/resetPassword.d.ts +4 -4
- package/dist/auth/operations/local/resetPassword.d.ts.map +1 -1
- package/dist/auth/operations/local/resetPassword.js.map +1 -1
- package/dist/auth/operations/local/unlock.d.ts +3 -3
- package/dist/auth/operations/local/unlock.d.ts.map +1 -1
- package/dist/auth/operations/local/unlock.js.map +1 -1
- package/dist/auth/operations/local/verifyEmail.d.ts +4 -4
- package/dist/auth/operations/local/verifyEmail.d.ts.map +1 -1
- package/dist/auth/operations/local/verifyEmail.js.map +1 -1
- package/dist/auth/operations/login.d.ts +10 -8
- package/dist/auth/operations/login.d.ts.map +1 -1
- package/dist/auth/operations/login.js.map +1 -1
- package/dist/auth/operations/registerFirstUser.d.ts +3 -3
- package/dist/auth/operations/registerFirstUser.d.ts.map +1 -1
- package/dist/auth/operations/registerFirstUser.js.map +1 -1
- package/dist/auth/operations/resetPassword.d.ts +2 -2
- package/dist/auth/operations/resetPassword.d.ts.map +1 -1
- package/dist/auth/operations/resetPassword.js.map +1 -1
- package/dist/auth/operations/unlock.d.ts +3 -3
- package/dist/auth/operations/unlock.d.ts.map +1 -1
- package/dist/auth/operations/unlock.js.map +1 -1
- package/dist/collections/config/types.d.ts +2 -2
- package/dist/collections/config/types.d.ts.map +1 -1
- package/dist/collections/config/types.js.map +1 -1
- package/dist/collections/operations/create.d.ts.map +1 -1
- package/dist/collections/operations/create.js +0 -9
- package/dist/collections/operations/create.js.map +1 -1
- package/dist/collections/operations/delete.d.ts.map +1 -1
- package/dist/collections/operations/delete.js +0 -9
- package/dist/collections/operations/delete.js.map +1 -1
- package/dist/collections/operations/deleteByID.d.ts.map +1 -1
- package/dist/collections/operations/deleteByID.js +0 -9
- package/dist/collections/operations/deleteByID.js.map +1 -1
- package/dist/collections/operations/find.d.ts.map +1 -1
- package/dist/collections/operations/find.js +0 -9
- package/dist/collections/operations/find.js.map +1 -1
- package/dist/collections/operations/findByID.d.ts.map +1 -1
- package/dist/collections/operations/findByID.js +0 -9
- package/dist/collections/operations/findByID.js.map +1 -1
- package/dist/collections/operations/local/count.d.ts.map +1 -1
- package/dist/collections/operations/local/count.js.map +1 -1
- package/dist/collections/operations/local/countVersions.d.ts.map +1 -1
- package/dist/collections/operations/local/countVersions.js.map +1 -1
- package/dist/collections/operations/local/create.d.ts.map +1 -1
- package/dist/collections/operations/local/create.js.map +1 -1
- package/dist/collections/operations/local/delete.d.ts.map +1 -1
- package/dist/collections/operations/local/delete.js.map +1 -1
- package/dist/collections/operations/local/duplicate.d.ts.map +1 -1
- package/dist/collections/operations/local/duplicate.js.map +1 -1
- package/dist/collections/operations/local/find.d.ts.map +1 -1
- package/dist/collections/operations/local/find.js.map +1 -1
- package/dist/collections/operations/local/findByID.d.ts.map +1 -1
- package/dist/collections/operations/local/findByID.js.map +1 -1
- package/dist/collections/operations/local/findDistinct.d.ts.map +1 -1
- package/dist/collections/operations/local/findDistinct.js.map +1 -1
- package/dist/collections/operations/local/findVersionByID.d.ts.map +1 -1
- package/dist/collections/operations/local/findVersionByID.js.map +1 -1
- package/dist/collections/operations/local/findVersions.d.ts.map +1 -1
- package/dist/collections/operations/local/findVersions.js.map +1 -1
- package/dist/collections/operations/local/restoreVersion.d.ts.map +1 -1
- package/dist/collections/operations/local/restoreVersion.js.map +1 -1
- package/dist/collections/operations/local/update.d.ts.map +1 -1
- package/dist/collections/operations/local/update.js.map +1 -1
- package/dist/collections/operations/update.d.ts.map +1 -1
- package/dist/collections/operations/update.js +1 -10
- package/dist/collections/operations/update.js.map +1 -1
- package/dist/collections/operations/updateByID.d.ts.map +1 -1
- package/dist/collections/operations/updateByID.js +0 -9
- package/dist/collections/operations/updateByID.js.map +1 -1
- package/dist/globals/operations/local/countVersions.d.ts.map +1 -1
- package/dist/globals/operations/local/countVersions.js.map +1 -1
- package/dist/globals/operations/local/findOne.d.ts.map +1 -1
- package/dist/globals/operations/local/findOne.js.map +1 -1
- package/dist/globals/operations/local/findVersionByID.d.ts.map +1 -1
- package/dist/globals/operations/local/findVersionByID.js.map +1 -1
- package/dist/globals/operations/local/findVersions.d.ts.map +1 -1
- package/dist/globals/operations/local/findVersions.js.map +1 -1
- package/dist/globals/operations/local/restoreVersion.d.ts.map +1 -1
- package/dist/globals/operations/local/restoreVersion.js.map +1 -1
- package/dist/globals/operations/local/update.d.ts.map +1 -1
- package/dist/globals/operations/local/update.js.map +1 -1
- package/dist/index.bundled.d.ts +41 -46
- package/dist/index.d.ts +6 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/preferences/config.d.ts.map +1 -1
- package/dist/preferences/config.js +13 -2
- package/dist/preferences/config.js.map +1 -1
- package/dist/utilities/addSelectGenericsToGeneratedTypes.spec.js +6 -4
- package/dist/utilities/addSelectGenericsToGeneratedTypes.spec.js.map +1 -1
- package/dist/utilities/configToJSONSchema.d.ts.map +1 -1
- package/dist/utilities/configToJSONSchema.js +21 -20
- package/dist/utilities/configToJSONSchema.js.map +1 -1
- package/dist/utilities/createLocalReq.d.ts.map +1 -1
- package/dist/utilities/createLocalReq.js +0 -8
- package/dist/utilities/createLocalReq.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../src/collections/operations/find.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC5E,OAAO,KAAK,EACV,cAAc,EACd,YAAY,EACZ,UAAU,EACV,IAAI,EACJ,6BAA6B,EAC7B,KAAK,EACN,MAAM,sBAAsB,CAAA;AAC7B,OAAO,KAAK,EACV,UAAU,EAEV,wBAAwB,EACzB,MAAM,oBAAoB,CAAA;AAqB3B,MAAM,MAAM,SAAS,GAAG;IACtB,UAAU,EAAE,UAAU,CAAA;IACtB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,GAAG,CAAC,EAAE,cAAc,CAAA;IACpB,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,KAAK,CAAC,EAAE,KAAK,CAA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AAE,IAAI,CAAA;IACX,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,KAAK,CAAC,EAAE,KAAK,CAAA;CACd,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,UAAU,CAAC,EAAE,QAAQ,CAAC,CAAA;AAInD,eAAO,MAAM,aAAa,GACxB,KAAK,SAAS,cAAc,EAC5B,OAAO,SAAS,wBAAwB,CAAC,KAAK,CAAC,gBAEjC,SAAS,KACtB,OAAO,CAAC,aAAa,CAAC,6BAA6B,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CA4TtE,CAAA"}
|
|
@@ -140,15 +140,6 @@ export const findOperation = async (incomingArgs)=>{
|
|
|
140
140
|
where: fullWhere
|
|
141
141
|
});
|
|
142
142
|
}
|
|
143
|
-
// /////////////////////////////////////
|
|
144
|
-
// Add collection property for auth collections
|
|
145
|
-
// /////////////////////////////////////
|
|
146
|
-
if (collectionConfig.auth) {
|
|
147
|
-
result.docs = result.docs.map((doc)=>({
|
|
148
|
-
...doc,
|
|
149
|
-
collection: collectionConfig.slug
|
|
150
|
-
}));
|
|
151
|
-
}
|
|
152
143
|
if (includeLockStatus) {
|
|
153
144
|
try {
|
|
154
145
|
const lockDocumentsProp = collectionConfig?.lockDocuments;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/collections/operations/find.ts"],"sourcesContent":["import type { AccessResult } from '../../config/types.js'\nimport type { PaginatedDocs } from '../../database/types.js'\nimport type { CollectionSlug, FindOptions, JoinQuery } from '../../index.js'\nimport type {\n PayloadRequest,\n PopulateType,\n SelectType,\n Sort,\n TransformCollectionWithSelect,\n Where,\n} from '../../types/index.js'\nimport type {\n Collection,\n DataFromCollectionSlug,\n SelectFromCollectionSlug,\n} from '../config/types.js'\n\nimport { executeAccess } from '../../auth/executeAccess.js'\nimport { combineQueries } from '../../database/combineQueries.js'\nimport { validateQueryPaths } from '../../database/queryValidation/validateQueryPaths.js'\nimport { sanitizeJoinQuery } from '../../database/sanitizeJoinQuery.js'\nimport { sanitizeWhereQuery } from '../../database/sanitizeWhereQuery.js'\nimport { afterRead } from '../../fields/hooks/afterRead/index.js'\nimport { lockedDocumentsCollectionSlug } from '../../locked-documents/config.js'\nimport { appendNonTrashedFilter } from '../../utilities/appendNonTrashedFilter.js'\nimport { hasDraftsEnabled } from '../../utilities/getVersionsConfig.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport { sanitizeSelect } from '../../utilities/sanitizeSelect.js'\nimport { buildVersionCollectionFields } from '../../versions/buildCollectionFields.js'\nimport { appendVersionToQueryKey } from '../../versions/drafts/appendVersionToQueryKey.js'\nimport { getQueryDraftsSelect } from '../../versions/drafts/getQueryDraftsSelect.js'\nimport { getQueryDraftsSort } from '../../versions/drafts/getQueryDraftsSort.js'\nimport { buildAfterOperation } from './utilities/buildAfterOperation.js'\nimport { buildBeforeOperation } from './utilities/buildBeforeOperation.js'\nimport { sanitizeSortQuery } from './utilities/sanitizeSortQuery.js'\n\nexport type Arguments = {\n collection: Collection\n currentDepth?: number\n depth?: number\n disableErrors?: boolean\n draft?: boolean\n includeLockStatus?: boolean\n joins?: JoinQuery\n limit?: number\n overrideAccess?: boolean\n page?: number\n pagination?: boolean\n populate?: PopulateType\n req?: PayloadRequest\n showHiddenFields?: boolean\n sort?: Sort\n trash?: boolean\n where?: Where\n} & Pick<FindOptions<string, SelectType>, 'select'>\n\nconst lockDurationDefault = 300 // Default 5 minutes in seconds\n\nexport const findOperation = async <\n TSlug extends CollectionSlug,\n TSelect extends SelectFromCollectionSlug<TSlug>,\n>(\n incomingArgs: Arguments,\n): Promise<PaginatedDocs<TransformCollectionWithSelect<TSlug, TSelect>>> => {\n let args = incomingArgs\n\n try {\n // /////////////////////////////////////\n // beforeOperation - Collection\n // /////////////////////////////////////\n\n args = await buildBeforeOperation({\n args,\n collection: args.collection.config,\n operation: 'read',\n overrideAccess: args.overrideAccess!,\n })\n\n const {\n collection: { config: collectionConfig },\n collection,\n currentDepth,\n depth,\n disableErrors,\n draft: draftsEnabled,\n includeLockStatus: includeLockStatusFromArgs,\n joins,\n limit,\n overrideAccess,\n page,\n pagination = true,\n populate,\n select: incomingSelect,\n showHiddenFields,\n sort: incomingSort,\n trash = false,\n where,\n } = args\n\n const req = args.req!\n\n const includeLockStatus =\n includeLockStatusFromArgs && req.payload.collections?.[lockedDocumentsCollectionSlug]\n\n const { fallbackLocale, locale, payload } = req\n\n const select = sanitizeSelect({\n fields: collectionConfig.flattenedFields,\n forceSelect: collectionConfig.forceSelect,\n select: incomingSelect,\n })\n\n // /////////////////////////////////////\n // Access\n // /////////////////////////////////////\n\n let accessResult: AccessResult\n\n if (!overrideAccess) {\n accessResult = await executeAccess({ disableErrors, req }, collectionConfig.access.read)\n\n // If errors are disabled, and access returns false, return empty results\n if (accessResult === false) {\n return {\n docs: [],\n hasNextPage: false,\n hasPrevPage: false,\n limit: limit!,\n nextPage: null,\n page: 1,\n pagingCounter: 1,\n prevPage: null,\n totalDocs: 0,\n totalPages: 1,\n }\n }\n }\n\n // /////////////////////////////////////\n // Find\n // /////////////////////////////////////\n\n const usePagination = pagination && limit !== 0\n const sanitizedLimit = limit ?? (usePagination ? 10 : 0)\n const sanitizedPage = page || 1\n\n let result: PaginatedDocs<DataFromCollectionSlug<TSlug>>\n\n let fullWhere = combineQueries(where!, accessResult!)\n sanitizeWhereQuery({ fields: collectionConfig.flattenedFields, payload, where: fullWhere })\n\n // Exclude trashed documents when trash: false\n fullWhere = appendNonTrashedFilter({\n enableTrash: collectionConfig.trash,\n trash,\n where: fullWhere,\n })\n\n const sort = sanitizeSortQuery({\n fields: collection.config.flattenedFields,\n sort: incomingSort,\n })\n\n const sanitizedJoins = await sanitizeJoinQuery({\n collectionConfig,\n joins,\n overrideAccess: overrideAccess!,\n req,\n })\n\n if (hasDraftsEnabled(collectionConfig) && draftsEnabled) {\n fullWhere = appendVersionToQueryKey(fullWhere)\n\n await validateQueryPaths({\n collectionConfig: collection.config,\n overrideAccess: overrideAccess!,\n req,\n versionFields: buildVersionCollectionFields(payload.config, collection.config, true),\n where: appendVersionToQueryKey(where),\n })\n\n result = await payload.db.queryDrafts<DataFromCollectionSlug<TSlug>>({\n collection: collectionConfig.slug,\n joins: req.payloadAPI === 'GraphQL' ? false : sanitizedJoins,\n limit: sanitizedLimit,\n locale: locale!,\n page: sanitizedPage,\n pagination: usePagination,\n req,\n select: getQueryDraftsSelect({ select }),\n sort: getQueryDraftsSort({\n collectionConfig,\n sort,\n }),\n where: fullWhere,\n })\n } else {\n await validateQueryPaths({\n collectionConfig,\n overrideAccess: overrideAccess!,\n req,\n where: where!,\n })\n\n result = await payload.db.find<DataFromCollectionSlug<TSlug>>({\n collection: collectionConfig.slug,\n draftsEnabled,\n joins: req.payloadAPI === 'GraphQL' ? false : sanitizedJoins,\n limit: sanitizedLimit,\n locale: locale!,\n page: sanitizedPage,\n pagination,\n req,\n select,\n sort,\n where: fullWhere,\n })\n }\n\n // /////////////////////////////////////\n // Add collection property for auth collections\n // /////////////////////////////////////\n\n if (collectionConfig.auth) {\n result.docs = result.docs.map((doc) => ({ ...doc, collection: collectionConfig.slug }))\n }\n\n if (includeLockStatus) {\n try {\n const lockDocumentsProp = collectionConfig?.lockDocuments\n\n const lockDuration =\n typeof lockDocumentsProp === 'object' ? lockDocumentsProp.duration : lockDurationDefault\n const lockDurationInMilliseconds = lockDuration * 1000\n\n const now = new Date().getTime()\n\n const lockedDocuments = await payload.find({\n collection: lockedDocumentsCollectionSlug,\n depth: 1,\n limit: sanitizedLimit,\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 in: result.docs.map((doc) => doc.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(now - lockDurationInMilliseconds),\n },\n },\n ],\n },\n })\n\n const lockedDocs = Array.isArray(lockedDocuments?.docs) ? lockedDocuments.docs : []\n\n // Filter out stale locks\n const validLockedDocs = lockedDocs.filter((lock) => {\n const lastEditedAt = new Date(lock?.updatedAt).getTime()\n return lastEditedAt + lockDurationInMilliseconds > now\n })\n\n for (const doc of result.docs) {\n const lockedDoc = validLockedDocs.find((lock) => lock?.document?.value === doc.id)\n doc._isLocked = !!lockedDoc\n doc._userEditing = lockedDoc ? lockedDoc?.user?.value : null\n }\n } catch (_err) {\n for (const doc of result.docs) {\n doc._isLocked = false\n doc._userEditing = null\n }\n }\n }\n\n // /////////////////////////////////////\n // beforeRead - Collection\n // /////////////////////////////////////\n\n if (collectionConfig?.hooks?.beforeRead?.length) {\n result.docs = await Promise.all(\n result.docs.map(async (doc) => {\n let docRef = doc\n\n for (const hook of collectionConfig.hooks.beforeRead) {\n docRef =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n doc: docRef,\n overrideAccess: overrideAccess!,\n query: fullWhere,\n req,\n })) || docRef\n }\n\n return docRef\n }),\n )\n }\n\n // /////////////////////////////////////\n // afterRead - Fields\n // /////////////////////////////////////\n\n result.docs = await Promise.all(\n result.docs.map(async (doc) =>\n afterRead<DataFromCollectionSlug<TSlug>>({\n collection: collectionConfig,\n context: req.context,\n currentDepth,\n depth: depth!,\n doc,\n draft: draftsEnabled!,\n fallbackLocale: fallbackLocale!,\n findMany: true,\n global: null,\n locale: locale!,\n overrideAccess: overrideAccess!,\n populate,\n req,\n select,\n showHiddenFields: showHiddenFields!,\n }),\n ),\n )\n\n // /////////////////////////////////////\n // afterRead - Collection\n // /////////////////////////////////////\n\n if (collectionConfig?.hooks?.afterRead?.length) {\n result.docs = await Promise.all(\n result.docs.map(async (doc) => {\n let docRef = doc\n\n for (const hook of collectionConfig.hooks.afterRead) {\n docRef =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n doc: docRef,\n findMany: true,\n overrideAccess: overrideAccess!,\n query: fullWhere,\n req,\n })) || docRef\n }\n\n return docRef\n }),\n )\n }\n\n // /////////////////////////////////////\n // afterOperation - Collection\n // /////////////////////////////////////\n\n result = await buildAfterOperation({\n args,\n collection: collectionConfig,\n operation: 'find',\n overrideAccess: overrideAccess!,\n result,\n })\n\n // /////////////////////////////////////\n // Return results\n // /////////////////////////////////////\n\n return result as PaginatedDocs<TransformCollectionWithSelect<TSlug, TSelect>>\n } catch (error: unknown) {\n await killTransaction(args.req!)\n throw error\n }\n}\n"],"names":["executeAccess","combineQueries","validateQueryPaths","sanitizeJoinQuery","sanitizeWhereQuery","afterRead","lockedDocumentsCollectionSlug","appendNonTrashedFilter","hasDraftsEnabled","killTransaction","sanitizeSelect","buildVersionCollectionFields","appendVersionToQueryKey","getQueryDraftsSelect","getQueryDraftsSort","buildAfterOperation","buildBeforeOperation","sanitizeSortQuery","lockDurationDefault","findOperation","incomingArgs","args","collection","config","operation","overrideAccess","collectionConfig","currentDepth","depth","disableErrors","draft","draftsEnabled","includeLockStatus","includeLockStatusFromArgs","joins","limit","page","pagination","populate","select","incomingSelect","showHiddenFields","sort","incomingSort","trash","where","req","payload","collections","fallbackLocale","locale","fields","flattenedFields","forceSelect","accessResult","access","read","docs","hasNextPage","hasPrevPage","nextPage","pagingCounter","prevPage","totalDocs","totalPages","usePagination","sanitizedLimit","sanitizedPage","result","fullWhere","enableTrash","sanitizedJoins","versionFields","db","queryDrafts","slug","payloadAPI","find","auth","map","doc","lockDocumentsProp","lockDocuments","lockDuration","duration","lockDurationInMilliseconds","now","Date","getTime","lockedDocuments","and","equals","in","id","updatedAt","greater_than","lockedDocs","Array","isArray","validLockedDocs","filter","lock","lastEditedAt","lockedDoc","document","value","_isLocked","_userEditing","user","_err","hooks","beforeRead","length","Promise","all","docRef","hook","context","query","findMany","global","error"],"mappings":"AAiBA,SAASA,aAAa,QAAQ,8BAA6B;AAC3D,SAASC,cAAc,QAAQ,mCAAkC;AACjE,SAASC,kBAAkB,QAAQ,uDAAsD;AACzF,SAASC,iBAAiB,QAAQ,sCAAqC;AACvE,SAASC,kBAAkB,QAAQ,uCAAsC;AACzE,SAASC,SAAS,QAA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QACxC,8BAA8B;QAC9B,wCAAwC;QAExC/C,SAAS,MAAMrD,oBAAoB;YACjCM;YACAC,YAAYI;YACZF,WAAW;YACXC,gBAAgBA;YAChB2C;QACF;QAEA,wCAAwC;QACxC,iBAAiB;QACjB,wCAAwC;QAExC,OAAOA;IACT,EAAE,OAAOqD,OAAgB;QACvB,MAAMhH,gBAAgBY,KAAKyB,GAAG;QAC9B,MAAM2E;IACR;AACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/collections/operations/find.ts"],"sourcesContent":["import type { AccessResult } from '../../config/types.js'\nimport type { PaginatedDocs } from '../../database/types.js'\nimport type { CollectionSlug, FindOptions, JoinQuery } from '../../index.js'\nimport type {\n PayloadRequest,\n PopulateType,\n SelectType,\n Sort,\n TransformCollectionWithSelect,\n Where,\n} from '../../types/index.js'\nimport type {\n Collection,\n DataFromCollectionSlug,\n SelectFromCollectionSlug,\n} from '../config/types.js'\n\nimport { executeAccess } from '../../auth/executeAccess.js'\nimport { combineQueries } from '../../database/combineQueries.js'\nimport { validateQueryPaths } from '../../database/queryValidation/validateQueryPaths.js'\nimport { sanitizeJoinQuery } from '../../database/sanitizeJoinQuery.js'\nimport { sanitizeWhereQuery } from '../../database/sanitizeWhereQuery.js'\nimport { afterRead } from '../../fields/hooks/afterRead/index.js'\nimport { lockedDocumentsCollectionSlug } from '../../locked-documents/config.js'\nimport { appendNonTrashedFilter } from '../../utilities/appendNonTrashedFilter.js'\nimport { hasDraftsEnabled } from '../../utilities/getVersionsConfig.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport { sanitizeSelect } from '../../utilities/sanitizeSelect.js'\nimport { buildVersionCollectionFields } from '../../versions/buildCollectionFields.js'\nimport { appendVersionToQueryKey } from '../../versions/drafts/appendVersionToQueryKey.js'\nimport { getQueryDraftsSelect } from '../../versions/drafts/getQueryDraftsSelect.js'\nimport { getQueryDraftsSort } from '../../versions/drafts/getQueryDraftsSort.js'\nimport { buildAfterOperation } from './utilities/buildAfterOperation.js'\nimport { buildBeforeOperation } from './utilities/buildBeforeOperation.js'\nimport { sanitizeSortQuery } from './utilities/sanitizeSortQuery.js'\n\nexport type Arguments = {\n collection: Collection\n currentDepth?: number\n depth?: number\n disableErrors?: boolean\n draft?: boolean\n includeLockStatus?: boolean\n joins?: JoinQuery\n limit?: number\n overrideAccess?: boolean\n page?: number\n pagination?: boolean\n populate?: PopulateType\n req?: PayloadRequest\n showHiddenFields?: boolean\n sort?: Sort\n trash?: boolean\n where?: Where\n} & Pick<FindOptions<string, SelectType>, 'select'>\n\nconst lockDurationDefault = 300 // Default 5 minutes in seconds\n\nexport const findOperation = async <\n TSlug extends CollectionSlug,\n TSelect extends SelectFromCollectionSlug<TSlug>,\n>(\n incomingArgs: Arguments,\n): Promise<PaginatedDocs<TransformCollectionWithSelect<TSlug, TSelect>>> => {\n let args = incomingArgs\n\n try {\n // /////////////////////////////////////\n // beforeOperation - Collection\n // /////////////////////////////////////\n\n args = await buildBeforeOperation({\n args,\n collection: args.collection.config,\n operation: 'read',\n overrideAccess: args.overrideAccess!,\n })\n\n const {\n collection: { config: collectionConfig },\n collection,\n currentDepth,\n depth,\n disableErrors,\n draft: draftsEnabled,\n includeLockStatus: includeLockStatusFromArgs,\n joins,\n limit,\n overrideAccess,\n page,\n pagination = true,\n populate,\n select: incomingSelect,\n showHiddenFields,\n sort: incomingSort,\n trash = false,\n where,\n } = args\n\n const req = args.req!\n\n const includeLockStatus =\n includeLockStatusFromArgs && req.payload.collections?.[lockedDocumentsCollectionSlug]\n\n const { fallbackLocale, locale, payload } = req\n\n const select = sanitizeSelect({\n fields: collectionConfig.flattenedFields,\n forceSelect: collectionConfig.forceSelect,\n select: incomingSelect,\n })\n\n // /////////////////////////////////////\n // Access\n // /////////////////////////////////////\n\n let accessResult: AccessResult\n\n if (!overrideAccess) {\n accessResult = await executeAccess({ disableErrors, req }, collectionConfig.access.read)\n\n // If errors are disabled, and access returns false, return empty results\n if (accessResult === false) {\n return {\n docs: [],\n hasNextPage: false,\n hasPrevPage: false,\n limit: limit!,\n nextPage: null,\n page: 1,\n pagingCounter: 1,\n prevPage: null,\n totalDocs: 0,\n totalPages: 1,\n }\n }\n }\n\n // /////////////////////////////////////\n // Find\n // /////////////////////////////////////\n\n const usePagination = pagination && limit !== 0\n const sanitizedLimit = limit ?? (usePagination ? 10 : 0)\n const sanitizedPage = page || 1\n\n let result: PaginatedDocs<DataFromCollectionSlug<TSlug>>\n\n let fullWhere = combineQueries(where!, accessResult!)\n sanitizeWhereQuery({ fields: collectionConfig.flattenedFields, payload, where: fullWhere })\n\n // Exclude trashed documents when trash: false\n fullWhere = appendNonTrashedFilter({\n enableTrash: collectionConfig.trash,\n trash,\n where: fullWhere,\n })\n\n const sort = sanitizeSortQuery({\n fields: collection.config.flattenedFields,\n sort: incomingSort,\n })\n\n const sanitizedJoins = await sanitizeJoinQuery({\n collectionConfig,\n joins,\n overrideAccess: overrideAccess!,\n req,\n })\n\n if (hasDraftsEnabled(collectionConfig) && draftsEnabled) {\n fullWhere = appendVersionToQueryKey(fullWhere)\n\n await validateQueryPaths({\n collectionConfig: collection.config,\n overrideAccess: overrideAccess!,\n req,\n versionFields: buildVersionCollectionFields(payload.config, collection.config, true),\n where: appendVersionToQueryKey(where),\n })\n\n result = await payload.db.queryDrafts<DataFromCollectionSlug<TSlug>>({\n collection: collectionConfig.slug,\n joins: req.payloadAPI === 'GraphQL' ? false : sanitizedJoins,\n limit: sanitizedLimit,\n locale: locale!,\n page: sanitizedPage,\n pagination: usePagination,\n req,\n select: getQueryDraftsSelect({ select }),\n sort: getQueryDraftsSort({\n collectionConfig,\n sort,\n }),\n where: fullWhere,\n })\n } else {\n await validateQueryPaths({\n collectionConfig,\n overrideAccess: overrideAccess!,\n req,\n where: where!,\n })\n\n result = await payload.db.find<DataFromCollectionSlug<TSlug>>({\n collection: collectionConfig.slug,\n draftsEnabled,\n joins: req.payloadAPI === 'GraphQL' ? false : sanitizedJoins,\n limit: sanitizedLimit,\n locale: locale!,\n page: sanitizedPage,\n pagination,\n req,\n select,\n sort,\n where: fullWhere,\n })\n }\n\n if (includeLockStatus) {\n try {\n const lockDocumentsProp = collectionConfig?.lockDocuments\n\n const lockDuration =\n typeof lockDocumentsProp === 'object' ? lockDocumentsProp.duration : lockDurationDefault\n const lockDurationInMilliseconds = lockDuration * 1000\n\n const now = new Date().getTime()\n\n const lockedDocuments = await payload.find({\n collection: lockedDocumentsCollectionSlug,\n depth: 1,\n limit: sanitizedLimit,\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 in: result.docs.map((doc) => doc.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(now - lockDurationInMilliseconds),\n },\n },\n ],\n },\n })\n\n const lockedDocs = Array.isArray(lockedDocuments?.docs) ? lockedDocuments.docs : []\n\n // Filter out stale locks\n const validLockedDocs = lockedDocs.filter((lock) => {\n const lastEditedAt = new Date(lock?.updatedAt).getTime()\n return lastEditedAt + lockDurationInMilliseconds > now\n })\n\n for (const doc of result.docs) {\n const lockedDoc = validLockedDocs.find((lock) => lock?.document?.value === doc.id)\n doc._isLocked = !!lockedDoc\n doc._userEditing = lockedDoc ? lockedDoc?.user?.value : null\n }\n } catch (_err) {\n for (const doc of result.docs) {\n doc._isLocked = false\n doc._userEditing = null\n }\n }\n }\n\n // /////////////////////////////////////\n // beforeRead - Collection\n // /////////////////////////////////////\n\n if (collectionConfig?.hooks?.beforeRead?.length) {\n result.docs = await Promise.all(\n result.docs.map(async (doc) => {\n let docRef = doc\n\n for (const hook of collectionConfig.hooks.beforeRead) {\n docRef =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n doc: docRef,\n overrideAccess: overrideAccess!,\n query: fullWhere,\n req,\n })) || docRef\n }\n\n return docRef\n }),\n )\n }\n\n // /////////////////////////////////////\n // afterRead - Fields\n // /////////////////////////////////////\n\n result.docs = await Promise.all(\n result.docs.map(async (doc) =>\n afterRead<DataFromCollectionSlug<TSlug>>({\n collection: collectionConfig,\n context: req.context,\n currentDepth,\n depth: depth!,\n doc,\n draft: draftsEnabled!,\n fallbackLocale: fallbackLocale!,\n findMany: true,\n global: null,\n locale: locale!,\n overrideAccess: overrideAccess!,\n populate,\n req,\n select,\n showHiddenFields: showHiddenFields!,\n }),\n ),\n )\n\n // /////////////////////////////////////\n // afterRead - Collection\n // /////////////////////////////////////\n\n if (collectionConfig?.hooks?.afterRead?.length) {\n result.docs = await Promise.all(\n result.docs.map(async (doc) => {\n let docRef = doc\n\n for (const hook of collectionConfig.hooks.afterRead) {\n docRef =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n doc: docRef,\n findMany: true,\n overrideAccess: overrideAccess!,\n query: fullWhere,\n req,\n })) || docRef\n }\n\n return docRef\n }),\n )\n }\n\n // /////////////////////////////////////\n // afterOperation - Collection\n // /////////////////////////////////////\n\n result = await buildAfterOperation({\n args,\n collection: collectionConfig,\n operation: 'find',\n overrideAccess: overrideAccess!,\n result,\n })\n\n // /////////////////////////////////////\n // Return results\n // /////////////////////////////////////\n\n return result as PaginatedDocs<TransformCollectionWithSelect<TSlug, TSelect>>\n } catch (error: unknown) {\n await killTransaction(args.req!)\n throw error\n }\n}\n"],"names":["executeAccess","combineQueries","validateQueryPaths","sanitizeJoinQuery","sanitizeWhereQuery","afterRead","lockedDocumentsCollectionSlug","appendNonTrashedFilter","hasDraftsEnabled","killTransaction","sanitizeSelect","buildVersionCollectionFields","appendVersionToQueryKey","getQueryDraftsSelect","getQueryDraftsSort","buildAfterOperation","buildBeforeOperation","sanitizeSortQuery","lockDurationDefault","findOperation","incomingArgs","args","collection","config","operation","overrideAccess","collectionConfig","currentDepth","depth","disableErrors","draft","draftsEnabled","includeLockStatus","includeLockStatusFromArgs","joins","limit","page","pagination","populate","select","incomingSelect","showHiddenFields","sort","incomingSort","trash","where","req","payload","collections","fallbackLocale","locale","fields","flattenedFields","forceSelect","accessResult","access","read","docs","hasNextPage","hasPrevPage","nextPage","pagingCounter","prevPage","totalDocs","totalPages","usePagination","sanitizedLimit","sanitizedPage","result","fullWhere","enableTrash","sanitizedJoins","versionFields","db","queryDrafts","slug","payloadAPI","find","lockDocumentsProp","lockDocuments","lockDuration","duration","lockDurationInMilliseconds","now","Date","getTime","lockedDocuments","and","equals","in","map","doc","id","updatedAt","greater_than","lockedDocs","Array","isArray","validLockedDocs","filter","lock","lastEditedAt","lockedDoc","document","value","_isLocked","_userEditing","user","_err","hooks","beforeRead","length","Promise","all","docRef","hook","context","query","findMany","global","error"],"mappings":"AAiBA,SAASA,aAAa,QAAQ,8BAA6B;AAC3D,SAASC,cAAc,QAAQ,mCAAkC;AACjE,SAASC,kBAAkB,QAAQ,uDAAsD;AACzF,SAASC,iBAAiB,QAAQ,sCAAqC;AACvE,SAASC,kBAAkB,QAAQ,uCAAsC;AACzE,SAASC,SAAS,QAAQ,wCAAuC;AACjE,SAASC,6BAA6B,QAAQ,mCAAkC;AAChF,SAASC,sBAAsB,QAAQ,4CAA2C;AAClF,SAASC,gBAAgB,QAAQ,uCAAsC;AACvE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,cAAc,QAAQ,oCAAmC;AAClE,SAASC,4BAA4B,QAAQ,0CAAyC;AACtF,SAASC,uBAAuB,QAAQ,mDAAkD;AAC1F,SAASC,oBAAoB,QAAQ,gDAA+C;AACpF,SAASC,kBAAkB,QAAQ,8CAA6C;AAChF,SAASC,mBAAmB,QAAQ,qCAAoC;AACxE,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,iBAAiB,QAAQ,mCAAkC;AAsBpE,MAAMC,sBAAsB,IAAI,+BAA+B;;AAE/D,OAAO,MAAMC,gBAAgB,OAI3BC;IAEA,IAAIC,OAAOD;IAEX,IAAI;QACF,wCAAwC;QACxC,+BAA+B;QAC/B,wCAAwC;QAExCC,OAAO,MAAML,qBAAqB;YAChCK;YACAC,YAAYD,KA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7C,OAAOX,IAAI,CAACiC,GAAG,CAAC,OAAOC;gBACrB,IAAIuB,SAASvB;gBAEb,KAAK,MAAMwB,QAAQzF,iBAAiBmF,KAAK,CAACxG,SAAS,CAAE;oBACnD6G,SACE,AAAC,MAAMC,KAAK;wBACV7F,YAAYI;wBACZ0F,SAAStE,IAAIsE,OAAO;wBACpBzB,KAAKuB;wBACLI,UAAU;wBACV7F,gBAAgBA;wBAChB4F,OAAOhD;wBACPvB;oBACF,MAAOoE;gBACX;gBAEA,OAAOA;YACT;QAEJ;QAEA,wCAAwC;QACxC,8BAA8B;QAC9B,wCAAwC;QAExC9C,SAAS,MAAMrD,oBAAoB;YACjCM;YACAC,YAAYI;YACZF,WAAW;YACXC,gBAAgBA;YAChB2C;QACF;QAEA,wCAAwC;QACxC,iBAAiB;QACjB,wCAAwC;QAExC,OAAOA;IACT,EAAE,OAAOoD,OAAgB;QACvB,MAAM/G,gBAAgBY,KAAKyB,GAAG;QAC9B,MAAM0E;IACR;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findByID.d.ts","sourceRoot":"","sources":["../../../src/collections/operations/findByID.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC5E,OAAO,KAAK,EACV,kBAAkB,EAClB,UAAU,EACV,cAAc,EACd,YAAY,EACZ,UAAU,EACV,6BAA6B,EAC9B,MAAM,sBAAsB,CAAA;AAC7B,OAAO,KAAK,EACV,UAAU,EAEV,wBAAwB,EAEzB,MAAM,oBAAoB,CAAA;AAO3B,OAAO,EAAa,KAAK,aAAa,EAAE,MAAM,uCAAuC,CAAA;AAYrF,MAAM,MAAM,YAAY,GAAG;IACzB,UAAU,EAAE,UAAU,CAAA;IACtB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CA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AAG;IACzB,UAAU,EAAE,UAAU,CAAA;IACtB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;IACnB,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,GAAG,EAAE,cAAc,CAAA;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,EAAE,gBAAgB,CAAC,GACnD,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,UAAU,CAAC,EAAE,QAAQ,CAAC,CAAA;AAEjD,eAAO,MAAM,iBAAiB,GAC5B,KAAK,SAAS,cAAc,EAC5B,cAAc,SAAS,OAAO,EAC9B,OAAO,SAAS,wBAAwB,CAAC,KAAK,CAAC,gBAEjC,YAAY,KACzB,OAAO,CAAC,kBAAkB,CAAC,6BAA6B,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,cAAc,CAAC,CA8R3F,CAAA"}
|
|
@@ -111,15 +111,6 @@ export const findByIDOperation = async (incomingArgs)=>{
|
|
|
111
111
|
}
|
|
112
112
|
let result = args.data ?? docFromDB;
|
|
113
113
|
// /////////////////////////////////////
|
|
114
|
-
// Add collection property for auth collections
|
|
115
|
-
// /////////////////////////////////////
|
|
116
|
-
if (collectionConfig.auth) {
|
|
117
|
-
result = {
|
|
118
|
-
...result,
|
|
119
|
-
collection: collectionConfig.slug
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
// /////////////////////////////////////
|
|
123
114
|
// Include Lock Status if required
|
|
124
115
|
// /////////////////////////////////////
|
|
125
116
|
if (includeLockStatus && id) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/collections/operations/findByID.ts"],"sourcesContent":["import type { FindOneArgs } from '../../database/types.js'\nimport type { CollectionSlug, FindOptions, 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, type AfterReadArgs } 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 { getSelectMode } from '../../utilities/getSelectMode.js'\nimport { hasDraftsEnabled } from '../../utilities/getVersionsConfig.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport { sanitizeSelect } from '../../utilities/sanitizeSelect.js'\nimport { replaceWithDraftIfAvailable } from '../../versions/drafts/replaceWithDraftIfAvailable.js'\nimport { buildAfterOperation } from './utilities/buildAfterOperation.js'\nimport { buildBeforeOperation } from './utilities/buildBeforeOperation.js'\n\nexport type FindByIDArgs = {\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 showHiddenFields?: boolean\n trash?: boolean\n} & Pick<AfterReadArgs<JsonObject>, 'flattenLocales'> &\n Pick<FindOptions<string, SelectType>, 'select'>\n\nexport const findByIDOperation = async <\n TSlug extends CollectionSlug,\n TDisableErrors extends boolean,\n TSelect extends SelectFromCollectionSlug<TSlug>,\n>(\n incomingArgs: FindByIDArgs,\n): Promise<ApplyDisableErrors<TransformCollectionWithSelect<TSlug, TSelect>, TDisableErrors>> => {\n let args = incomingArgs\n\n try {\n // /////////////////////////////////////\n // beforeOperation - Collection\n // /////////////////////////////////////\n\n args = await buildBeforeOperation({\n args,\n collection: args.collection.config,\n operation: 'read',\n overrideAccess: args.overrideAccess!,\n })\n\n const {\n id,\n collection: { config: collectionConfig },\n currentDepth,\n depth,\n disableErrors,\n draft: replaceWithVersion = false,\n flattenLocales,\n includeLockStatus: includeLockStatusFromArgs,\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 includeLockStatus =\n includeLockStatusFromArgs && req.payload.collections?.[lockedDocumentsCollectionSlug]\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 // 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 // /////////////////////////////////////\n // Find by ID\n // /////////////////////////////////////\n\n let dbSelect = select\n\n if (\n collectionConfig.versions?.drafts &&\n replaceWithVersion &&\n select &&\n getSelectMode(select) === 'include'\n ) {\n dbSelect = { ...select, createdAt: true, updatedAt: true }\n }\n\n const findOneArgs: FindOneArgs = {\n collection: collectionConfig.slug,\n draftsEnabled: replaceWithVersion,\n joins: req.payloadAPI === 'GraphQL' ? false : sanitizedJoins,\n locale: locale!,\n req: {\n transactionID: req.transactionID,\n } as PayloadRequest,\n select: dbSelect,\n where: fullWhere,\n }\n\n if (!findOneArgs.where?.and?.[0]?.id) {\n throw new NotFound(t)\n }\n\n const docFromDB = await req.payload.db.findOne(findOneArgs)\n\n if (!docFromDB && !args.data) {\n if (!disableErrors) {\n throw new NotFound(req.t)\n }\n return null!\n }\n\n let result: DataFromCollectionSlug<TSlug> =\n (args.data as DataFromCollectionSlug<TSlug>) ?? docFromDB!\n\n // /////////////////////////////////////\n // Add collection property for auth collections\n // /////////////////////////////////////\n\n if (collectionConfig.auth) {\n result = { ...result, collection: collectionConfig.slug }\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 (replaceWithVersion && hasDraftsEnabled(collectionConfig)) {\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 overrideAccess,\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: replaceWithVersion,\n fallbackLocale: fallbackLocale!,\n flattenLocales,\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 overrideAccess,\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 overrideAccess,\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","getSelectMode","hasDraftsEnabled","killTransaction","sanitizeSelect","replaceWithDraftIfAvailable","buildAfterOperation","buildBeforeOperation","findByIDOperation","incomingArgs","args","collection","config","operation","overrideAccess","id","collectionConfig","currentDepth","depth","disableErrors","draft","replaceWithVersion","flattenLocales","includeLockStatus","includeLockStatusFromArgs","joins","populate","req","fallbackLocale","locale","t","select","incomingSelect","showHiddenFields","trash","payload","collections","fields","flattenedFields","forceSelect","accessResult","access","read","where","equals","fullWhere","enableTrash","sanitizedJoins","slug","customIDType","dbSelect","versions","drafts","createdAt","updatedAt","findOneArgs","draftsEnabled","payloadAPI","transactionID","and","docFromDB","db","findOne","data","result","auth","lockStatus","lockDocumentsProp","lockDocuments","lockDurationDefault","lockDuration","duration","lockDurationInMilliseconds","lockedDocument","find","limit","pagination","greater_than","Date","getTime","docs","length","_isLocked","_userEditing","user","value","doc","entity","entityType","hooks","beforeRead","hook","context","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,QAA4B,wCAAuC;AACrF,SAASC,kBAAkB,QAAQ,iBAAgB;AACnD,SAASC,6BAA6B,QAAQ,mCAAkC;AAChF,SAASC,sBAAsB,QAAQ,4CAA2C;AAClF,SAASC,aAAa,QAAQ,mCAAkC;AA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;YACjCI;YACAC,YAAYK;YACZH,WAAW;YACXC;YACAkD;QACF;QAEA,wCAAwC;QACxC,iBAAiB;QACjB,wCAAwC;QAExC,OAAOA;IAIT,EAAE,OAAO+B,OAAgB;QACvB,MAAM5F,gBAAgBO,KAAKiB,GAAG;QAC9B,MAAMoE;IACR;AACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/collections/operations/findByID.ts"],"sourcesContent":["import type { FindOneArgs } from '../../database/types.js'\nimport type { CollectionSlug, FindOptions, 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, type AfterReadArgs } 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 { getSelectMode } from '../../utilities/getSelectMode.js'\nimport { hasDraftsEnabled } from '../../utilities/getVersionsConfig.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport { sanitizeSelect } from '../../utilities/sanitizeSelect.js'\nimport { replaceWithDraftIfAvailable } from '../../versions/drafts/replaceWithDraftIfAvailable.js'\nimport { buildAfterOperation } from './utilities/buildAfterOperation.js'\nimport { buildBeforeOperation } from './utilities/buildBeforeOperation.js'\n\nexport type FindByIDArgs = {\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 showHiddenFields?: boolean\n trash?: boolean\n} & Pick<AfterReadArgs<JsonObject>, 'flattenLocales'> &\n Pick<FindOptions<string, SelectType>, 'select'>\n\nexport const findByIDOperation = async <\n TSlug extends CollectionSlug,\n TDisableErrors extends boolean,\n TSelect extends SelectFromCollectionSlug<TSlug>,\n>(\n incomingArgs: FindByIDArgs,\n): Promise<ApplyDisableErrors<TransformCollectionWithSelect<TSlug, TSelect>, TDisableErrors>> => {\n let args = incomingArgs\n\n try {\n // /////////////////////////////////////\n // beforeOperation - Collection\n // /////////////////////////////////////\n\n args = await buildBeforeOperation({\n args,\n collection: args.collection.config,\n operation: 'read',\n overrideAccess: args.overrideAccess!,\n })\n\n const {\n id,\n collection: { config: collectionConfig },\n currentDepth,\n depth,\n disableErrors,\n draft: replaceWithVersion = false,\n flattenLocales,\n includeLockStatus: includeLockStatusFromArgs,\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 includeLockStatus =\n includeLockStatusFromArgs && req.payload.collections?.[lockedDocumentsCollectionSlug]\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 // 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 // /////////////////////////////////////\n // Find by ID\n // /////////////////////////////////////\n\n let dbSelect = select\n\n if (\n collectionConfig.versions?.drafts &&\n replaceWithVersion &&\n select &&\n getSelectMode(select) === 'include'\n ) {\n dbSelect = { ...select, createdAt: true, updatedAt: true }\n }\n\n const findOneArgs: FindOneArgs = {\n collection: collectionConfig.slug,\n draftsEnabled: replaceWithVersion,\n joins: req.payloadAPI === 'GraphQL' ? false : sanitizedJoins,\n locale: locale!,\n req: {\n transactionID: req.transactionID,\n } as PayloadRequest,\n select: dbSelect,\n where: fullWhere,\n }\n\n if (!findOneArgs.where?.and?.[0]?.id) {\n throw new NotFound(t)\n }\n\n const docFromDB = await req.payload.db.findOne(findOneArgs)\n\n if (!docFromDB && !args.data) {\n if (!disableErrors) {\n throw new NotFound(req.t)\n }\n return null!\n }\n\n let result: DataFromCollectionSlug<TSlug> =\n (args.data as DataFromCollectionSlug<TSlug>) ?? docFromDB!\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 (replaceWithVersion && hasDraftsEnabled(collectionConfig)) {\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 overrideAccess,\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: replaceWithVersion,\n fallbackLocale: fallbackLocale!,\n flattenLocales,\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 overrideAccess,\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 overrideAccess,\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","getSelectMode","hasDraftsEnabled","killTransaction","sanitizeSelect","replaceWithDraftIfAvailable","buildAfterOperation","buildBeforeOperation","findByIDOperation","incomingArgs","args","collection","config","operation","overrideAccess","id","collectionConfig","currentDepth","depth","disableErrors","draft","replaceWithVersion","flattenLocales","includeLockStatus","includeLockStatusFromArgs","joins","populate","req","fallbackLocale","locale","t","select","incomingSelect","showHiddenFields","trash","payload","collections","fields","flattenedFields","forceSelect","accessResult","access","read","where","equals","fullWhere","enableTrash","sanitizedJoins","slug","customIDType","dbSelect","versions","drafts","createdAt","updatedAt","findOneArgs","draftsEnabled","payloadAPI","transactionID","and","docFromDB","db","findOne","data","result","lockStatus","lockDocumentsProp","lockDocuments","lockDurationDefault","lockDuration","duration","lockDurationInMilliseconds","lockedDocument","find","limit","pagination","greater_than","Date","getTime","docs","length","_isLocked","_userEditing","user","value","doc","entity","entityType","hooks","beforeRead","hook","context","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,QAA4B,wCAAuC;AACrF,SAASC,kBAAkB,QAAQ,iBAAgB;AACnD,SAASC,6BAA6B,QAAQ,mCAAkC;AAChF,SAASC,sBAAsB,QAAQ,4CAA2C;AAClF,SAASC,aAAa,QAAQ,mCAAkC;AAChE,SAASC,gBAAgB,QAAQ,uCAAsC;AACv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AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"count.d.ts","sourceRoot":"","sources":["../../../../src/collections/operations/local/count.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC7F,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAO9E,MAAM,MAAM,YAAY,CAAC,KAAK,SAAS,cAAc,IAAI;IACvD;;OAEG;IACH,UAAU,EAAE,KAAK,CAAA;IACjB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB;;OAEG;IACH,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;;OAGG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAA;IAC7B;;;;;;;OAOG;IACH,KAAK,CAAC,EAAE,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"count.d.ts","sourceRoot":"","sources":["../../../../src/collections/operations/local/count.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC7F,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAO9E,MAAM,MAAM,YAAY,CAAC,KAAK,SAAS,cAAc,IAAI;IACvD;;OAEG;IACH,UAAU,EAAE,KAAK,CAAA;IACjB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB;;OAEG;IACH,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;;OAGG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAA;IAC7B;;;;;;;OAOG;IACH,KAAK,CAAC,EAAE,OAAO,CAAA;IACf;;OAEG;IACH,IAAI,CAAC,EAAE,QAAQ,CAAA;IACf;;OAEG;IACH,KAAK,CAAC,EAAE,KAAK,CAAA;CACd,CAAA;AAED,wBAAsB,UAAU,CAAC,KAAK,SAAS,cAAc,EAC3D,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,YAAY,CAAC,KAAK,CAAC,GAC3B,OAAO,CAAC;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CAyBhC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/collections/operations/local/count.ts"],"sourcesContent":["import type { CollectionSlug, Payload, RequestContext, TypedLocale } from '../../../index.js'\nimport type { Document, PayloadRequest, Where } from '../../../types/index.js'\nimport type { CreateLocalReqOptions } from '../../../utilities/createLocalReq.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { countOperation } from '../count.js'\n\nexport type CountOptions<TSlug extends CollectionSlug> = {\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 * When set to `true`, errors will not be thrown.\n */\n disableErrors?: boolean\n /**\n * Specify [locale](https://payloadcms.com/docs/configuration/localization) for any returned documents.\n */\n locale?: 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 * 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 * When set to `true`, the query will include both normal and trashed documents.\n * To query only trashed documents, pass `trash: true` and combine with a `where` clause filtering by `deletedAt`.\n * By default (`false`), the query will only include normal documents and exclude those with a `deletedAt` field.\n *\n * This argument has no effect unless `trash` is enabled on the collection.\n * @default false\n */\n trash?: boolean\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/collections/operations/local/count.ts"],"sourcesContent":["import type { CollectionSlug, Payload, RequestContext, TypedLocale } from '../../../index.js'\nimport type { Document, PayloadRequest, Where } from '../../../types/index.js'\nimport type { CreateLocalReqOptions } from '../../../utilities/createLocalReq.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { countOperation } from '../count.js'\n\nexport type CountOptions<TSlug extends CollectionSlug> = {\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 * When set to `true`, errors will not be thrown.\n */\n disableErrors?: boolean\n /**\n * Specify [locale](https://payloadcms.com/docs/configuration/localization) for any returned documents.\n */\n locale?: 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 * 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 * When set to `true`, the query will include both normal and trashed documents.\n * To query only trashed documents, pass `trash: true` and combine with a `where` clause filtering by `deletedAt`.\n * By default (`false`), the query will only include normal documents and exclude those with a `deletedAt` field.\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 * A filter [query](https://payloadcms.com/docs/queries/overview)\n */\n where?: Where\n}\n\nexport async function countLocal<TSlug extends CollectionSlug>(\n payload: Payload,\n options: CountOptions<TSlug>,\n): Promise<{ totalDocs: number }> {\n const {\n collection: collectionSlug,\n disableErrors,\n overrideAccess = true,\n trash = false,\n where,\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. Count Operation.`,\n )\n }\n\n return countOperation<TSlug>({\n collection,\n disableErrors,\n overrideAccess,\n req: await createLocalReq(options as CreateLocalReqOptions, payload),\n trash,\n where,\n })\n}\n"],"names":["APIError","createLocalReq","countOperation","countLocal","payload","options","collection","collectionSlug","disableErrors","overrideAccess","trash","where","collections","String","req"],"mappings":"AAIA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,cAAc,QAAQ,cAAa;AAoD5C,OAAO,eAAeC,WACpBC,OAAgB,EAChBC,OAA4B;IAE5B,MAAM,EACJC,YAAYC,cAAc,EAC1BC,aAAa,EACbC,iBAAiB,IAAI,EACrBC,QAAQ,KAAK,EACbC,KAAK,EACN,GAAGN;IAEJ,MAAMC,aAAaF,QAAQQ,WAAW,CAACL,eAAe;IAEtD,IAAI,CAACD,YAAY;QACf,MAAM,IAAIN,SACR,CAAC,yBAAyB,EAAEa,OAAON,gBAAgB,iCAAiC,CAAC;IAEzF;IAEA,OAAOL,eAAsB;QAC3BI;QACAE;QACAC;QACAK,KAAK,MAAMb,eAAeI,SAAkCD;QAC5DM;QACAC;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"countVersions.d.ts","sourceRoot":"","sources":["../../../../src/collections/operations/local/countVersions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC7F,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAO9E,MAAM,MAAM,oBAAoB,CAAC,KAAK,SAAS,cAAc,IAAI;IAC/D;;OAEG;IACH,UAAU,EAAE,KAAK,CAAA;IACjB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB;;OAEG;IACH,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;;OAGG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"countVersions.d.ts","sourceRoot":"","sources":["../../../../src/collections/operations/local/countVersions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC7F,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAO9E,MAAM,MAAM,oBAAoB,CAAC,KAAK,SAAS,cAAc,IAAI;IAC/D;;OAEG;IACH,UAAU,EAAE,KAAK,CAAA;IACjB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB;;OAEG;IACH,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;;OAGG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAA;IAC7B;;OAEG;IACH,IAAI,CAAC,EAAE,QAAQ,CAAA;IACf;;OAEG;IACH,KAAK,CAAC,EAAE,KAAK,CAAA;CACd,CAAA;AAED,wBAAsB,kBAAkB,CAAC,KAAK,SAAS,cAAc,EACnE,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,oBAAoB,CAAC,KAAK,CAAC,GACnC,OAAO,CAAC;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CAkBhC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/collections/operations/local/countVersions.ts"],"sourcesContent":["import type { CollectionSlug, Payload, RequestContext, TypedLocale } from '../../../index.js'\nimport type { Document, PayloadRequest, Where } from '../../../types/index.js'\nimport type { CreateLocalReqOptions } from '../../../utilities/createLocalReq.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { countVersionsOperation } from '../countVersions.js'\n\nexport type CountVersionsOptions<TSlug extends CollectionSlug> = {\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 * When set to `true`, errors will not be thrown.\n */\n disableErrors?: boolean\n /**\n * Specify [locale](https://payloadcms.com/docs/configuration/localization) for any returned documents.\n */\n locale?: 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 * 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
|
|
1
|
+
{"version":3,"sources":["../../../../src/collections/operations/local/countVersions.ts"],"sourcesContent":["import type { CollectionSlug, Payload, RequestContext, TypedLocale } from '../../../index.js'\nimport type { Document, PayloadRequest, Where } from '../../../types/index.js'\nimport type { CreateLocalReqOptions } from '../../../utilities/createLocalReq.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { countVersionsOperation } from '../countVersions.js'\n\nexport type CountVersionsOptions<TSlug extends CollectionSlug> = {\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 * When set to `true`, errors will not be thrown.\n */\n disableErrors?: boolean\n /**\n * Specify [locale](https://payloadcms.com/docs/configuration/localization) for any returned documents.\n */\n locale?: 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 * 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 * If you set `overrideAccess` to `false`, you can pass a user to use against the access control checks.\n */\n user?: Document\n /**\n * A filter [query](https://payloadcms.com/docs/queries/overview)\n */\n where?: Where\n}\n\nexport async function countVersionsLocal<TSlug extends CollectionSlug>(\n payload: Payload,\n options: CountVersionsOptions<TSlug>,\n): Promise<{ totalDocs: number }> {\n const { collection: collectionSlug, disableErrors, overrideAccess = true, where } = 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. Count Versions Operation.`,\n )\n }\n\n return countVersionsOperation<TSlug>({\n collection,\n disableErrors,\n overrideAccess,\n req: await createLocalReq(options as CreateLocalReqOptions, payload),\n where,\n })\n}\n"],"names":["APIError","createLocalReq","countVersionsOperation","countVersionsLocal","payload","options","collection","collectionSlug","disableErrors","overrideAccess","where","collections","String","req"],"mappings":"AAIA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,sBAAsB,QAAQ,sBAAqB;AA2C5D,OAAO,eAAeC,mBACpBC,OAAgB,EAChBC,OAAoC;IAEpC,MAAM,EAAEC,YAAYC,cAAc,EAAEC,aAAa,EAAEC,iBAAiB,IAAI,EAAEC,KAAK,EAAE,GAAGL;IAEpF,MAAMC,aAAaF,QAAQO,WAAW,CAACJ,eAAe;IAEtD,IAAI,CAACD,YAAY;QACf,MAAM,IAAIN,SACR,CAAC,yBAAyB,EAAEY,OAAOL,gBAAgB,0CAA0C,CAAC;IAElG;IAEA,OAAOL,uBAA8B;QACnCI;QACAE;QACAC;QACAI,KAAK,MAAMZ,eAAeI,SAAkCD;QAC5DM;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../../src/collections/operations/local/create.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,UAAU,EACV,6BAA6B,EAC9B,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,2BAA2B,CAAA;AAErD,OAAO,KAAK,EACV,wBAAwB,EACxB,sBAAsB,EACtB,2BAA2B,EAC3B,8BAA8B,EAC9B,wBAAwB,EACzB,MAAM,uBAAuB,CAAA;AAG9B,OAAO,EACL,KAAK,cAAc,EAEnB,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,WAAW,EACjB,MAAM,mBAAmB,CAAA;AAK1B,KAAK,WAAW,CAAC,KAAK,SAAS,cAAc,EAAE,OAAO,SAAS,UAAU,IAAI;IAC3E;;OAEG;IACH,UAAU,EAAE,KAAK,CAAA;IACjB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B;;;OAGG;IACH,wBAAwB,CAAC,EAAE,OAAO,CAAA;IAClC;;OAEG;IACH,eAAe,CAAC,EAAE,sBAAsB,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAA;IACrD;;OAEG;IACH,cAAc,CAAC,EAAE,KAAK,GAAG,WAAW,CAAA;IACpC;;OAEG;IACH,IAAI,CAAC,EAAE,IAAI,CAAA;IACX;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;OAEG;IACH,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;;;OAIG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAA;IAChC;;OAEG;IACH,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB;;OAEG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B;;;OAGG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAA;IAC7B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../../src/collections/operations/local/create.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,UAAU,EACV,6BAA6B,EAC9B,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,2BAA2B,CAAA;AAErD,OAAO,KAAK,EACV,wBAAwB,EACxB,sBAAsB,EACtB,2BAA2B,EAC3B,8BAA8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AAO,SAAS,wBAAwB,CAAC,KAAK,CAAC,EAE/C,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,GAC/B,OAAO,CAAC,6BAA6B,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CA+CxD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/collections/operations/local/create.ts"],"sourcesContent":["import type {\n Document,\n PayloadRequest,\n PopulateType,\n SelectType,\n TransformCollectionWithSelect,\n} from '../../../types/index.js'\nimport type { File } from '../../../uploads/types.js'\nimport type { CreateLocalReqOptions } from '../../../utilities/createLocalReq.js'\nimport type {\n CollectionsWithoutDrafts,\n DataFromCollectionSlug,\n DraftDataFromCollectionSlug,\n RequiredDataFromCollectionSlug,\n SelectFromCollectionSlug,\n} from '../../config/types.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport {\n type CollectionSlug,\n deepCopyObjectSimple,\n type FindOptions,\n type GeneratedTypes,\n type Payload,\n type RequestContext,\n type TypedLocale,\n} from '../../../index.js'\nimport { getFileByPath } from '../../../uploads/getFileByPath.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { createOperation } from '../create.js'\n\ntype BaseOptions<TSlug extends CollectionSlug, TSelect extends SelectType> = {\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 * [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`, a [database transactions](https://payloadcms.com/docs/database/transactions) will not be initialized.\n * @default false\n */\n disableTransaction?: boolean\n /**\n * If creating verification-enabled auth doc,\n * you can disable the email that is auto-sent\n */\n disableVerificationEmail?: boolean\n /**\n * If you want to create a document that is a duplicate of another document\n */\n duplicateFromID?: DataFromCollectionSlug<TSlug>['id']\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 * A `File` object when creating a collection with `upload: true`.\n */\n file?: File\n /**\n * A file path when creating a collection with `upload: true`.\n */\n filePath?: string\n /**\n * Specify [locale](https://payloadcms.com/docs/configuration/localization) for any returned documents.\n */\n locale?: 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 * If you are uploading a file and would like to replace\n * the existing file instead of generating a new filename,\n * you can set the following property to `true`\n */\n overwriteExistingFiles?: 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 * Publish to all locales\n */\n publishAllLocales?: boolean\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 * 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
|
|
1
|
+
{"version":3,"sources":["../../../../src/collections/operations/local/create.ts"],"sourcesContent":["import type {\n Document,\n PayloadRequest,\n PopulateType,\n SelectType,\n TransformCollectionWithSelect,\n} from '../../../types/index.js'\nimport type { File } from '../../../uploads/types.js'\nimport type { CreateLocalReqOptions } from '../../../utilities/createLocalReq.js'\nimport type {\n CollectionsWithoutDrafts,\n DataFromCollectionSlug,\n DraftDataFromCollectionSlug,\n RequiredDataFromCollectionSlug,\n SelectFromCollectionSlug,\n} from '../../config/types.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport {\n type CollectionSlug,\n deepCopyObjectSimple,\n type FindOptions,\n type GeneratedTypes,\n type Payload,\n type RequestContext,\n type TypedLocale,\n} from '../../../index.js'\nimport { getFileByPath } from '../../../uploads/getFileByPath.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { createOperation } from '../create.js'\n\ntype BaseOptions<TSlug extends CollectionSlug, TSelect extends SelectType> = {\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 * [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`, a [database transactions](https://payloadcms.com/docs/database/transactions) will not be initialized.\n * @default false\n */\n disableTransaction?: boolean\n /**\n * If creating verification-enabled auth doc,\n * you can disable the email that is auto-sent\n */\n disableVerificationEmail?: boolean\n /**\n * If you want to create a document that is a duplicate of another document\n */\n duplicateFromID?: DataFromCollectionSlug<TSlug>['id']\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 * A `File` object when creating a collection with `upload: true`.\n */\n file?: File\n /**\n * A file path when creating a collection with `upload: true`.\n */\n filePath?: string\n /**\n * Specify [locale](https://payloadcms.com/docs/configuration/localization) for any returned documents.\n */\n locale?: 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 * If you are uploading a file and would like to replace\n * the existing file instead of generating a new filename,\n * you can set the following property to `true`\n */\n overwriteExistingFiles?: 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 * Publish to all locales\n */\n publishAllLocales?: boolean\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 * 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 * If you set `overrideAccess` to `false`, you can pass a user to use against the access control checks.\n */\n user?: Document\n} & Pick<FindOptions<TSlug, TSelect>, 'select'>\n\nexport type Options<\n TSlug extends CollectionSlug,\n TSelect extends SelectType,\n> = GeneratedTypes extends { strictDraftTypes: true }\n ? CollectionsWithoutDrafts extends TSlug\n ? {\n /**\n * The data for the document to create.\n */\n data: DataFromCollectionSlug<TSlug>\n /**\n * Create a **draft** document. [More](https://payloadcms.com/docs/versions/drafts#draft-api)\n */\n draft?: boolean\n } & BaseOptions<TSlug, TSelect>\n : TSlug extends CollectionsWithoutDrafts\n ? {\n data: RequiredDataFromCollectionSlug<TSlug>\n /**\n * The `draft` property is not allowed because this collection does not have `versions.drafts` enabled.\n */\n draft?: never\n } & BaseOptions<TSlug, TSelect>\n : (\n | {\n /**\n * The data for the document to create.\n */\n data: RequiredDataFromCollectionSlug<TSlug>\n /**\n * Create a **draft** document. [More](https://payloadcms.com/docs/versions/drafts#draft-api)\n * Omit this property or set to `false` to create a published document.\n */\n draft?: false\n }\n | {\n /**\n * The data for the document to create.\n * When creating a draft, required fields are optional as validation is skipped by default.\n */\n data: DraftDataFromCollectionSlug<TSlug>\n /**\n * Create a **draft** document. [More](https://payloadcms.com/docs/versions/drafts#draft-api)\n */\n draft: true\n }\n ) &\n BaseOptions<TSlug, TSelect>\n :\n | ({\n /**\n * The data for the document to create.\n */\n data: RequiredDataFromCollectionSlug<TSlug>\n /**\n * Create a **draft** document. [More](https://payloadcms.com/docs/versions/drafts#draft-api)\n */\n draft?: false\n } & BaseOptions<TSlug, TSelect>)\n | ({\n /**\n * The data for the document to create.\n * When creating a draft, required fields are optional as validation is skipped by default.\n */\n data: DraftDataFromCollectionSlug<TSlug>\n /**\n * Create a **draft** document. [More](https://payloadcms.com/docs/versions/drafts#draft-api)\n */\n draft: true\n } & BaseOptions<TSlug, TSelect>)\n\nexport async function createLocal<\n TSlug extends CollectionSlug,\n TSelect extends SelectFromCollectionSlug<TSlug>,\n>(\n payload: Payload,\n options: Options<TSlug, TSelect>,\n): Promise<TransformCollectionWithSelect<TSlug, TSelect>> {\n const {\n collection: collectionSlug,\n data,\n depth,\n disableTransaction,\n disableVerificationEmail,\n draft,\n duplicateFromID,\n file,\n filePath,\n overrideAccess = true,\n overwriteExistingFiles = false,\n populate,\n publishAllLocales,\n select,\n showHiddenFields,\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. Create Operation.`,\n )\n }\n\n const req = await createLocalReq(options as CreateLocalReqOptions, payload)\n\n req.file = file ?? (await getFileByPath(filePath!))\n\n return createOperation<TSlug, TSelect>({\n collection,\n data: deepCopyObjectSimple(data), // Ensure mutation of data in create operation hooks doesn't affect the original data\n depth,\n disableTransaction,\n disableVerificationEmail,\n draft,\n duplicateFromID,\n overrideAccess,\n overwriteExistingFiles,\n populate,\n publishAllLocales,\n req,\n select,\n showHiddenFields,\n })\n}\n"],"names":["APIError","deepCopyObjectSimple","getFileByPath","createLocalReq","createOperation","createLocal","payload","options","collection","collectionSlug","data","depth","disableTransaction","disableVerificationEmail","draft","duplicateFromID","file","filePath","overrideAccess","overwriteExistingFiles","populate","publishAllLocales","select","showHiddenFields","collections","String","req"],"mappings":"AAiBA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAEEC,oBAAoB,QAMf,oBAAmB;AAC1B,SAASC,aAAa,QAAQ,oCAAmC;AACjE,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,eAAe,QAAQ,eAAc;AA2J9C,OAAO,eAAeC,YAIpBC,OAAgB,EAChBC,OAAgC;IAEhC,MAAM,EACJC,YAAYC,cAAc,EAC1BC,IAAI,EACJC,KAAK,EACLC,kBAAkB,EAClBC,wBAAwB,EACxBC,KAAK,EACLC,eAAe,EACfC,IAAI,EACJC,QAAQ,EACRC,iBAAiB,IAAI,EACrBC,yBAAyB,KAAK,EAC9BC,QAAQ,EACRC,iBAAiB,EACjBC,MAAM,EACNC,gBAAgB,EACjB,GAAGhB;IAEJ,MAAMC,aAAaF,QAAQkB,WAAW,CAACf,eAAe;IAEtD,IAAI,CAACD,YAAY;QACf,MAAM,IAAIR,SACR,CAAC,yBAAyB,EAAEyB,OAAOhB,gBAAgB,kCAAkC,CAAC;IAE1F;IAEA,MAAMiB,MAAM,MAAMvB,eAAeI,SAAkCD;IAEnEoB,IAAIV,IAAI,GAAGA,QAAS,MAAMd,cAAce;IAExC,OAAOb,gBAAgC;QACrCI;QACAE,MAAMT,qBAAqBS;QAC3BC;QACAC;QACAC;QACAC;QACAC;QACAG;QACAC;QACAC;QACAC;QACAK;QACAJ;QACAC;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../../src/collections/operations/local/delete.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,WAAW,EACX,OAAO,EACP,cAAc,EACd,WAAW,EACZ,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EACV,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,UAAU,EACV,6BAA6B,EAC7B,KAAK,EACN,MAAM,yBAAyB,CAAA;AAEhC,OAAO,KAAK,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AAO1F,MAAM,MAAM,WAAW,CAAC,KAAK,SAAS,cAAc,EAAE,OAAO,SAAS,UAAU,IAAI;IAClF;;OAEG;IACH,UAAU,EAAE,KAAK,CAAA;IACjB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B;;OAEG;IACH,cAAc,CAAC,EAAE,KAAK,GAAG,WAAW,CAAA;IACpC;;OAEG;IACH,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB;;OAEG;IACH,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB;;;OAGG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAA;IAC7B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../../src/collections/operations/local/delete.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,WAAW,EACX,OAAO,EACP,cAAc,EACd,WAAW,EACZ,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EACV,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,UAAU,EACV,6BAA6B,EAC7B,KAAK,EACN,MAAM,yBAAyB,CAAA;AAEhC,OAAO,KAAK,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AAO1F,MAAM,MAAM,WAAW,CAAC,KAAK,SAAS,cAAc,EAAE,OAAO,SAAS,UAAU,IAAI;IAClF;;OAEG;IACH,UAAU,EAAE,KAAK,CAAA;IACjB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B;;OAEG;IACH,cAAc,CAAC,EAAE,KAAK,GAAG,WAAW,CAAA;IACpC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AC5B,OAAO,SAAS,wBAAwB,CAAC,KAAK,CAAC,EAE/C,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,WAAW,CAAC,KAAK,EAAE,OAAO,CAAC,GACnC,OAAO,CAAC,6BAA6B,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAA;AACzD,iBAAe,WAAW,CACxB,KAAK,SAAS,cAAc,EAC5B,OAAO,SAAS,wBAAwB,CAAC,KAAK,CAAC,EAE/C,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,WAAW,CAAC,KAAK,EAAE,OAAO,CAAC,GACnC,OAAO,CAAC,mBAAmB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAA;AAC/C,iBAAe,WAAW,CACxB,KAAK,SAAS,cAAc,EAC5B,OAAO,SAAS,wBAAwB,CAAC,KAAK,CAAC,EAE/C,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,GAC/B,OAAO,CAAC,mBAAmB,CAAC,KAAK,EAAE,OAAO,CAAC,GAAG,6BAA6B,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAA;AAqD/F,OAAO,EAAE,WAAW,EAAE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/collections/operations/local/delete.ts"],"sourcesContent":["import type {\n CollectionSlug,\n FindOptions,\n Payload,\n RequestContext,\n TypedLocale,\n} from '../../../index.js'\nimport type {\n Document,\n PayloadRequest,\n PopulateType,\n SelectType,\n TransformCollectionWithSelect,\n Where,\n} from '../../../types/index.js'\nimport type { CreateLocalReqOptions } from '../../../utilities/createLocalReq.js'\nimport type { BulkOperationResult, SelectFromCollectionSlug } from '../../config/types.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { deleteOperation } from '../delete.js'\nimport { deleteByIDOperation } from '../deleteByID.js'\n\nexport type BaseOptions<TSlug extends CollectionSlug, TSelect extends SelectType> = {\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 * [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`, a [database transactions](https://payloadcms.com/docs/database/transactions) will not be initialized.\n * @default false\n */\n disableTransaction?: 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 * Specify [locale](https://payloadcms.com/docs/configuration/localization) for any returned documents.\n */\n locale?: 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 * By default, document locks are ignored (`true`). Set to `false` to enforce locks and prevent operations when a document is locked by another user. [More details](https://payloadcms.com/docs/admin/locked-documents).\n * @default true\n */\n overrideLock?: 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 * 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 permanently delete both normal and trashed documents.\n * By default (`false`), only normal (non-trashed) documents will be permanently deleted.\n *\n * This argument has no effect unless `trash` is enabled on the collection.\n * @default false\n */\n trash?: boolean\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/collections/operations/local/delete.ts"],"sourcesContent":["import type {\n CollectionSlug,\n FindOptions,\n Payload,\n RequestContext,\n TypedLocale,\n} from '../../../index.js'\nimport type {\n Document,\n PayloadRequest,\n PopulateType,\n SelectType,\n TransformCollectionWithSelect,\n Where,\n} from '../../../types/index.js'\nimport type { CreateLocalReqOptions } from '../../../utilities/createLocalReq.js'\nimport type { BulkOperationResult, SelectFromCollectionSlug } from '../../config/types.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { deleteOperation } from '../delete.js'\nimport { deleteByIDOperation } from '../deleteByID.js'\n\nexport type BaseOptions<TSlug extends CollectionSlug, TSelect extends SelectType> = {\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 * [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`, a [database transactions](https://payloadcms.com/docs/database/transactions) will not be initialized.\n * @default false\n */\n disableTransaction?: 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 * Specify [locale](https://payloadcms.com/docs/configuration/localization) for any returned documents.\n */\n locale?: 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 * By default, document locks are ignored (`true`). Set to `false` to enforce locks and prevent operations when a document is locked by another user. [More details](https://payloadcms.com/docs/admin/locked-documents).\n * @default true\n */\n overrideLock?: 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 * 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 permanently delete both normal and trashed documents.\n * By default (`false`), only normal (non-trashed) documents will be permanently deleted.\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} & Pick<FindOptions<TSlug, TSelect>, 'select'>\n\nexport type ByIDOptions<\n TSlug extends CollectionSlug,\n TSelect extends SelectFromCollectionSlug<TSlug>,\n> = {\n /**\n * The ID of the document to delete.\n */\n id: number | string\n /**\n * A filter [query](https://payloadcms.com/docs/queries/overview)\n */\n where?: never\n} & BaseOptions<TSlug, TSelect>\n\nexport type ManyOptions<\n TSlug extends CollectionSlug,\n TSelect extends SelectFromCollectionSlug<TSlug>,\n> = {\n /**\n * The ID of the document to delete.\n */\n id?: never\n /**\n * A filter [query](https://payloadcms.com/docs/queries/overview)\n */\n where: Where\n} & BaseOptions<TSlug, TSelect>\n\nexport type Options<\n TSlug extends CollectionSlug,\n TSelect extends SelectFromCollectionSlug<TSlug>,\n> = ByIDOptions<TSlug, TSelect> | ManyOptions<TSlug, TSelect>\n\nasync function deleteLocal<\n TSlug extends CollectionSlug,\n TSelect extends SelectFromCollectionSlug<TSlug>,\n>(\n payload: Payload,\n options: ByIDOptions<TSlug, TSelect>,\n): Promise<TransformCollectionWithSelect<TSlug, TSelect>>\nasync function deleteLocal<\n TSlug extends CollectionSlug,\n TSelect extends SelectFromCollectionSlug<TSlug>,\n>(\n payload: Payload,\n options: ManyOptions<TSlug, TSelect>,\n): Promise<BulkOperationResult<TSlug, TSelect>>\nasync function deleteLocal<\n TSlug extends CollectionSlug,\n TSelect extends SelectFromCollectionSlug<TSlug>,\n>(\n payload: Payload,\n options: Options<TSlug, TSelect>,\n): Promise<BulkOperationResult<TSlug, TSelect> | TransformCollectionWithSelect<TSlug, TSelect>>\nasync function deleteLocal<\n TSlug extends CollectionSlug,\n TSelect extends SelectFromCollectionSlug<TSlug>,\n>(\n payload: Payload,\n options: Options<TSlug, TSelect>,\n): Promise<BulkOperationResult<TSlug, TSelect> | TransformCollectionWithSelect<TSlug, TSelect>> {\n const {\n id,\n collection: collectionSlug,\n depth,\n disableTransaction,\n overrideAccess = true,\n overrideLock,\n populate,\n select,\n showHiddenFields,\n trash = false,\n where,\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. Delete Operation.`,\n )\n }\n\n const args = {\n id,\n collection,\n depth,\n disableTransaction,\n overrideAccess,\n overrideLock,\n populate,\n req: await createLocalReq(options as CreateLocalReqOptions, payload),\n select,\n showHiddenFields,\n trash,\n where,\n }\n\n if (options.id) {\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n return deleteByIDOperation<TSlug, TSelect>(args)\n }\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n return deleteOperation<TSlug, TSelect>(args)\n}\n\nexport { deleteLocal }\n"],"names":["APIError","createLocalReq","deleteOperation","deleteByIDOperation","deleteLocal","payload","options","id","collection","collectionSlug","depth","disableTransaction","overrideAccess","overrideLock","populate","select","showHiddenFields","trash","where","collections","String","args","req"],"mappings":"AAkBA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,eAAe,QAAQ,eAAc;AAC9C,SAASC,mBAAmB,QAAQ,mBAAkB;AA4HtD,eAAeC,YAIbC,OAAgB,EAChBC,OAAgC;IAEhC,MAAM,EACJC,EAAE,EACFC,YAAYC,cAAc,EAC1BC,KAAK,EACLC,kBAAkB,EAClBC,iBAAiB,IAAI,EACrBC,YAAY,EACZC,QAAQ,EACRC,MAAM,EACNC,gBAAgB,EAChBC,QAAQ,KAAK,EACbC,KAAK,EACN,GAAGZ;IAEJ,MAAME,aAAaH,QAAQc,WAAW,CAACV,eAAe;IAEtD,IAAI,CAACD,YAAY;QACf,MAAM,IAAIR,SACR,CAAC,yBAAyB,EAAEoB,OAAOX,gBAAgB,kCAAkC,CAAC;IAE1F;IAEA,MAAMY,OAAO;QACXd;QACAC;QACAE;QACAC;QACAC;QACAC;QACAC;QACAQ,KAAK,MAAMrB,eAAeK,SAAkCD;QAC5DU;QACAC;QACAC;QACAC;IACF;IAEA,IAAIZ,QAAQC,EAAE,EAAE;QACd,oFAAoF;QACpF,OAAOJ,oBAAoCkB;IAC7C;IACA,oFAAoF;IACpF,OAAOnB,gBAAgCmB;AACzC;AAEA,SAASjB,WAAW,GAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"duplicate.d.ts","sourceRoot":"","sources":["../../../../src/collections/operations/local/duplicate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAEhD,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AACrE,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAC7E,OAAO,KAAK,EACV,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,UAAU,EACV,6BAA6B,EAC9B,MAAM,yBAAyB,CAAA;AAEhC,OAAO,KAAK,EACV,2BAA2B,EAC3B,8BAA8B,EAC9B,wBAAwB,EACzB,MAAM,uBAAuB,CAAA;AAM9B,KAAK,WAAW,CAAC,KAAK,SAAS,cAAc,EAAE,OAAO,SAAS,UAAU,IAAI;IAC3E;;OAEG;IACH,UAAU,EAAE,KAAK,CAAA;IACjB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB;;OAEG;IACH,IAAI,CAAC,EAAE,WAAW,CAAC,8BAA8B,CAAC,KAAK,CAAC,CAAC,CAAA;IACzD;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B;;OAEG;IACH,cAAc,CAAC,EAAE,KAAK,GAAG,WAAW,CAAA;IACpC;;OAEG;IACH,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;IACnB;;OAEG;IACH,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB;;;;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;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,EAAE,CAAA;IAC1B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"duplicate.d.ts","sourceRoot":"","sources":["../../../../src/collections/operations/local/duplicate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAEhD,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AACrE,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAC7E,OAAO,KAAK,EACV,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,UAAU,EACV,6BAA6B,EAC9B,MAAM,yBAAyB,CAAA;AAEhC,OAAO,KAAK,EACV,2BAA2B,EAC3B,8BAA8B,EAC9B,wBAAwB,EACzB,MAAM,uBAAuB,CAAA;AAM9B,KAAK,WAAW,CAAC,KAAK,SAAS,cAAc,EAAE,OAAO,SAAS,UAAU,IAAI;IAC3E;;OAEG;IACH,UAAU,EAAE,KAAK,CAAA;IACjB;;;;;OA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
{"version":3,"sources":["../../../../src/collections/operations/local/duplicate.ts"],"sourcesContent":["import type { DeepPartial } from 'ts-essentials'\n\nimport type { CollectionSlug, TypedLocale } from '../../..//index.js'\nimport type { FindOptions, Payload, RequestContext } from '../../../index.js'\nimport type {\n Document,\n PayloadRequest,\n PopulateType,\n SelectType,\n TransformCollectionWithSelect,\n} from '../../../types/index.js'\nimport type { CreateLocalReqOptions } from '../../../utilities/createLocalReq.js'\nimport type {\n DraftFlagFromCollectionSlug,\n RequiredDataFromCollectionSlug,\n SelectFromCollectionSlug,\n} from '../../config/types.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { duplicateOperation } from '../duplicate.js'\n\ntype BaseOptions<TSlug extends CollectionSlug, TSelect extends SelectType> = {\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 * Override the data for the document to duplicate.\n */\n data?: DeepPartial<RequiredDataFromCollectionSlug<TSlug>>\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`, a [database transactions](https://payloadcms.com/docs/database/transactions) will not be initialized.\n * @default false\n */\n disableTransaction?: 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 duplicate from.\n */\n id: number | string\n /**\n * Specify [locale](https://payloadcms.com/docs/configuration/localization) for any returned documents.\n */\n locale?: 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 * Specifies which locales to include when duplicating localized fields. Non-localized data is always duplicated.\n * By default, all locales are duplicated.\n */\n selectedLocales?: string[]\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
|
|
1
|
+
{"version":3,"sources":["../../../../src/collections/operations/local/duplicate.ts"],"sourcesContent":["import type { DeepPartial } from 'ts-essentials'\n\nimport type { CollectionSlug, TypedLocale } from '../../..//index.js'\nimport type { FindOptions, Payload, RequestContext } from '../../../index.js'\nimport type {\n Document,\n PayloadRequest,\n PopulateType,\n SelectType,\n TransformCollectionWithSelect,\n} from '../../../types/index.js'\nimport type { CreateLocalReqOptions } from '../../../utilities/createLocalReq.js'\nimport type {\n DraftFlagFromCollectionSlug,\n RequiredDataFromCollectionSlug,\n SelectFromCollectionSlug,\n} from '../../config/types.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { duplicateOperation } from '../duplicate.js'\n\ntype BaseOptions<TSlug extends CollectionSlug, TSelect extends SelectType> = {\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 * Override the data for the document to duplicate.\n */\n data?: DeepPartial<RequiredDataFromCollectionSlug<TSlug>>\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`, a [database transactions](https://payloadcms.com/docs/database/transactions) will not be initialized.\n * @default false\n */\n disableTransaction?: 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 duplicate from.\n */\n id: number | string\n /**\n * Specify [locale](https://payloadcms.com/docs/configuration/localization) for any returned documents.\n */\n locale?: 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 * Specifies which locales to include when duplicating localized fields. Non-localized data is always duplicated.\n * By default, all locales are duplicated.\n */\n selectedLocales?: string[]\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 * If you set `overrideAccess` to `false`, you can pass a user to use against the access control checks.\n */\n user?: Document\n} & Pick<FindOptions<TSlug, TSelect>, 'select'>\n\nexport type Options<TSlug extends CollectionSlug, TSelect extends SelectType> =\n BaseOptions<TSlug, TSelect> & DraftFlagFromCollectionSlug<TSlug>\n\nexport async function duplicateLocal<\n TSlug extends CollectionSlug,\n TSelect extends SelectFromCollectionSlug<TSlug>,\n>(\n payload: Payload,\n options: Options<TSlug, TSelect>,\n): Promise<TransformCollectionWithSelect<TSlug, TSelect>> {\n const {\n id,\n collection: collectionSlug,\n data,\n depth,\n disableTransaction,\n draft,\n overrideAccess = true,\n populate,\n select,\n selectedLocales,\n showHiddenFields,\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. Duplicate Operation.`,\n )\n }\n\n if (collection.config.disableDuplicate === true) {\n throw new APIError(\n `The collection with slug ${String(collectionSlug)} cannot be duplicated.`,\n 400,\n )\n }\n\n const req = await createLocalReq(options as CreateLocalReqOptions, payload)\n\n return duplicateOperation<TSlug, TSelect>({\n id,\n collection,\n data,\n depth,\n disableTransaction,\n draft,\n overrideAccess,\n populate,\n req,\n select,\n selectedLocales,\n showHiddenFields,\n })\n}\n"],"names":["APIError","createLocalReq","duplicateOperation","duplicateLocal","payload","options","id","collection","collectionSlug","data","depth","disableTransaction","draft","overrideAccess","populate","select","selectedLocales","showHiddenFields","collections","String","config","disableDuplicate","req"],"mappings":"AAkBA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,kBAAkB,QAAQ,kBAAiB;AAyEpD,OAAO,eAAeC,eAIpBC,OAAgB,EAChBC,OAAgC;IAEhC,MAAM,EACJC,EAAE,EACFC,YAAYC,cAAc,EAC1BC,IAAI,EACJC,KAAK,EACLC,kBAAkB,EAClBC,KAAK,EACLC,iBAAiB,IAAI,EACrBC,QAAQ,EACRC,MAAM,EACNC,eAAe,EACfC,gBAAgB,EACjB,GAAGZ;IAEJ,MAAME,aAAaH,QAAQc,WAAW,CAACV,eAAe;IAEtD,IAAI,CAACD,YAAY;QACf,MAAM,IAAIP,SACR,CAAC,yBAAyB,EAAEmB,OAAOX,gBAAgB,qCAAqC,CAAC;IAE7F;IAEA,IAAID,WAAWa,MAAM,CAACC,gBAAgB,KAAK,MAAM;QAC/C,MAAM,IAAIrB,SACR,CAAC,yBAAyB,EAAEmB,OAAOX,gBAAgB,sBAAsB,CAAC,EAC1E;IAEJ;IAEA,MAAMc,MAAM,MAAMrB,eAAeI,SAAkCD;IAEnE,OAAOF,mBAAmC;QACxCI;QACAC;QACAE;QACAC;QACAC;QACAC;QACAC;QACAC;QACAQ;QACAP;QACAC;QACAC;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../../src/collections/operations/local/find.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC/D,OAAO,KAAK,EACV,cAAc,EAEd,SAAS,EACT,OAAO,EACP,YAAY,EACZ,cAAc,EACd,mBAAmB,EACnB,WAAW,EACZ,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EACV,QAAQ,EACR,kCAAkC,EAClC,cAAc,EACd,YAAY,EACZ,UAAU,EACV,IAAI,EACJ,6BAA6B,EAC7B,KAAK,EACN,MAAM,yBAAyB,CAAA;AAEhC,OAAO,KAAK,EACV,2BAA2B,EAC3B,wBAAwB,EACzB,MAAM,uBAAuB,CAAA;AAM9B,KAAK,eAAe,CAAC,KAAK,SAAS,cAAc,EAAE,OAAO,SAAS,UAAU,IAAI;IAC/E;;OAEG;IACH,UAAU,EAAE,KAAK,CAAA;IACjB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB;;OAEG;IACH,cAAc,CAAC,EAAE,mBAAmB,CAAA;IACpC;;OAEG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B;;;OAGG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC,KAAK,CAAC,CAAA;IACxB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,MAAM,CAAC,EAAE,KAAK,GAAG,WAAW,CAAA;IAC5B;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB;;OAEG;IACH,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB;;;OAGG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAA;IAC7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6CG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B;;;;OAIG;IACH,IAAI,CAAC,EAAE,IAAI,CAAA;IACX;;;;;;;OAOG;IACH,KAAK,CAAC,EAAE,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../../src/collections/operations/local/find.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC/D,OAAO,KAAK,EACV,cAAc,EAEd,SAAS,EACT,OAAO,EACP,YAAY,EACZ,cAAc,EACd,mBAAmB,EACnB,WAAW,EACZ,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EACV,QAAQ,EACR,kCAAkC,EAClC,cAAc,EACd,YAAY,EACZ,UAAU,EACV,IAAI,EACJ,6BAA6B,EAC7B,KAAK,EACN,MAAM,yBAAyB,CAAA;AAEhC,OAAO,KAAK,EACV,2BAA2B,EAC3B,wBAAwB,EACzB,MAAM,uBAAuB,CAAA;AAM9B,KAAK,eAAe,CAAC,KAAK,SAAS,cAAc,EAAE,OAAO,SAAS,UAAU,IAAI;IAC/E;;OAEG;IACH,UAAU,EAAE,KAAK,CAAA;IACjB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB;;OAEG;IACH,cAAc,CAAC,E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