payload 3.0.0-beta.122 → 3.0.0-beta.123
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/collections/operations/find.d.ts.map +1 -1
- package/dist/collections/operations/find.js +1 -0
- 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 +1 -0
- package/dist/collections/operations/findByID.js.map +1 -1
- package/dist/globals/operations/findOne.d.ts.map +1 -1
- package/dist/globals/operations/findOne.js +18 -4
- package/dist/globals/operations/findOne.js.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.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,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC/D,OAAO,KAAK,EACV,cAAc,EACd,UAAU,EACV,IAAI,EACJ,6BAA6B,EAC7B,KAAK,EACN,MAAM,sBAAsB,CAAA;AAC7B,OAAO,KAAK,EACV,UAAU,EAEV,wBAAwB,EACzB,MAAM,oBAAoB,CAAA;AAa3B,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,IAA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AO,CAAA;IACpB,GAAG,CAAC,EAAE,cAAc,CAAA;IACpB,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,KAAK,CAAC,EAAE,KAAK,CAAA;CACd,CAAA;AAED,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,CAsStE,CAAA"}
|
|
@@ -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, JoinQuery } from '../../index.js'\nimport type {\n PayloadRequest,\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 { afterRead } from '../../fields/hooks/afterRead/index.js'\nimport { killTransaction } from '../../utilities/killTransaction.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 './utils.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 req?: PayloadRequest\n select?: SelectType\n showHiddenFields?: boolean\n sort?: Sort\n where?: Where\n}\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 await args.collection.config.hooks.beforeOperation.reduce(async (priorHook, hook) => {\n await priorHook\n\n args =\n (await hook({\n args,\n collection: args.collection.config,\n context: args.req.context,\n operation: 'read',\n req: args.req,\n })) || args\n }, Promise.resolve())\n\n const {\n collection: { config: collectionConfig },\n collection,\n currentDepth,\n depth,\n disableErrors,\n draft: draftsEnabled,\n includeLockStatus,\n joins,\n limit,\n overrideAccess,\n page,\n pagination = true,\n req: { fallbackLocale, locale, payload },\n req,\n select,\n showHiddenFields,\n sort,\n where,\n } = args\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,\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\n if (collectionConfig.versions?.drafts && draftsEnabled) {\n fullWhere = appendVersionToQueryKey(fullWhere)\n\n await validateQueryPaths({\n collectionConfig: collection.config,\n overrideAccess,\n req,\n versionFields: buildVersionCollectionFields(payload.config, collection.config),\n where: fullWhere,\n })\n\n result = await payload.db.queryDrafts<DataFromCollectionSlug<TSlug>>({\n collection: collectionConfig.slug,\n joins: req.payloadAPI === 'GraphQL' ? false : joins,\n limit: sanitizedLimit,\n locale,\n page: sanitizedPage,\n pagination: usePagination,\n req,\n select: getQueryDraftsSelect({ select }),\n sort: getQueryDraftsSort({ collectionConfig, sort }),\n where: fullWhere,\n })\n } else {\n await validateQueryPaths({\n collectionConfig,\n overrideAccess,\n req,\n where,\n })\n\n result = await payload.db.find<DataFromCollectionSlug<TSlug>>({\n collection: collectionConfig.slug,\n joins: req.payloadAPI === 'GraphQL' ? false : joins,\n limit: sanitizedLimit,\n 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 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 lockedDocuments = await payload.find({\n collection: 'payload-locked-documents',\n depth: 1,\n limit: sanitizedLimit,\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(new Date().getTime() - lockDurationInMilliseconds),\n },\n },\n ],\n },\n })\n\n const now = new Date().getTime()\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 result.docs = result.docs.map((doc) => {\n const lockedDoc = validLockedDocs.find((lock) => lock?.document?.value === doc.id)\n return {\n ...doc,\n _isLocked: !!lockedDoc,\n _userEditing: lockedDoc ? lockedDoc?.user?.value : null,\n }\n })\n } catch (error) {\n result.docs = result.docs.map((doc) => ({\n ...doc,\n _isLocked: false,\n _userEditing: null,\n }))\n }\n }\n\n // /////////////////////////////////////\n // beforeRead - Collection\n // /////////////////////////////////////\n\n result = {\n ...result,\n docs: await Promise.all(\n result.docs.map(async (doc) => {\n let docRef = doc\n\n await collectionConfig.hooks.beforeRead.reduce(async (priorHook, hook) => {\n await priorHook\n\n docRef =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n doc: docRef,\n query: fullWhere,\n req,\n })) || docRef\n }, Promise.resolve())\n\n return docRef\n }),\n ),\n }\n\n // /////////////////////////////////////\n // afterRead - Fields\n // /////////////////////////////////////\n\n result = {\n ...result,\n 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,\n doc,\n draft: draftsEnabled,\n fallbackLocale,\n findMany: true,\n global: null,\n locale,\n overrideAccess,\n req,\n select,\n showHiddenFields,\n }),\n ),\n ),\n }\n\n // /////////////////////////////////////\n // afterRead - Collection\n // /////////////////////////////////////\n\n result = {\n ...result,\n docs: await Promise.all(\n result.docs.map(async (doc) => {\n let docRef = doc\n\n await collectionConfig.hooks.afterRead.reduce(async (priorHook, hook) => {\n await priorHook\n\n docRef =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n doc: docRef,\n findMany: true,\n query: fullWhere,\n req,\n })) || doc\n }, Promise.resolve())\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 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","afterRead","killTransaction","buildVersionCollectionFields","appendVersionToQueryKey","getQueryDraftsSelect","getQueryDraftsSort","buildAfterOperation","findOperation","incomingArgs","args","collection","config","hooks","beforeOperation","reduce","priorHook","hook","context","req","operation","Promise","resolve","collectionConfig","currentDepth","depth","disableErrors","draft","draftsEnabled","includeLockStatus","joins","limit","overrideAccess","page","pagination","fallbackLocale","locale","payload","select","showHiddenFields","sort","where","accessResult","access","read","docs","hasNextPage","hasPrevPage","nextPage","pagingCounter","prevPage","totalDocs","totalPages","usePagination","sanitizedLimit","sanitizedPage","result","fullWhere","versions","drafts","versionFields","db","queryDrafts","slug","payloadAPI","find","lockDocumentsProp","lockDocuments","lockDurationDefault","lockDuration","duration","lockDurationInMilliseconds","lockedDocuments","and","equals","in","map","doc","id","updatedAt","greater_than","Date","getTime","now","lockedDocs","Array","isArray","validLockedDocs","filter","lock","lastEditedAt","lockedDoc","document","value","_isLocked","_userEditing","user","error","all","docRef","beforeRead","query","findMany","global"],"mappings":"AAgBA,OAAOA,mBAAmB,8BAA6B;AACvD,SAASC,cAAc,QAAQ,mCAAkC;AACjE,SAASC,kBAAkB,QAAQ,uDAAsD;AACzF,SAASC,SAAS,QAAQ,wCAAuC;AACjE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,4BAA4B,QAAQ,0CAAyC;AACtF,SAASC,uBAAuB,QAAQ,mDAAkD;AAC1F,SAASC,oBAAoB,QAAQ,gDAA+C;AACpF,SAASC,kBAAkB,QAAQ,8CAA6C;AAChF,SAASC,mBAAmB,QAAQ,aAAY;AAqBhD,OAAO,MAAMC,gBAAgB,OAI3BC;IAEA,IAAIC,OAAOD;IAEX,IAAI;QACF,wCAAwC;QACxC,+BAA+B;QAC/B,wCAAwC;QAExC,MAAMC,KAAKC,UAAU,CAACC,MAAM,CAACC,KAAK,CAACC,eAAe,CAACC,MAAM,CAAC,OAAOC,WAAWC;YAC1E,MAAMD;YAENN,OACE,AAAC,MAAMO,KAAK;gBACVP;gB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M8E;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, JoinQuery } from '../../index.js'\nimport type {\n PayloadRequest,\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 { afterRead } from '../../fields/hooks/afterRead/index.js'\nimport { killTransaction } from '../../utilities/killTransaction.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 './utils.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 req?: PayloadRequest\n select?: SelectType\n showHiddenFields?: boolean\n sort?: Sort\n where?: Where\n}\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 await args.collection.config.hooks.beforeOperation.reduce(async (priorHook, hook) => {\n await priorHook\n\n args =\n (await hook({\n args,\n collection: args.collection.config,\n context: args.req.context,\n operation: 'read',\n req: args.req,\n })) || args\n }, Promise.resolve())\n\n const {\n collection: { config: collectionConfig },\n collection,\n currentDepth,\n depth,\n disableErrors,\n draft: draftsEnabled,\n includeLockStatus,\n joins,\n limit,\n overrideAccess,\n page,\n pagination = true,\n req: { fallbackLocale, locale, payload },\n req,\n select,\n showHiddenFields,\n sort,\n where,\n } = args\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,\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\n if (collectionConfig.versions?.drafts && draftsEnabled) {\n fullWhere = appendVersionToQueryKey(fullWhere)\n\n await validateQueryPaths({\n collectionConfig: collection.config,\n overrideAccess,\n req,\n versionFields: buildVersionCollectionFields(payload.config, collection.config),\n where: fullWhere,\n })\n\n result = await payload.db.queryDrafts<DataFromCollectionSlug<TSlug>>({\n collection: collectionConfig.slug,\n joins: req.payloadAPI === 'GraphQL' ? false : joins,\n limit: sanitizedLimit,\n locale,\n page: sanitizedPage,\n pagination: usePagination,\n req,\n select: getQueryDraftsSelect({ select }),\n sort: getQueryDraftsSort({ collectionConfig, sort }),\n where: fullWhere,\n })\n } else {\n await validateQueryPaths({\n collectionConfig,\n overrideAccess,\n req,\n where,\n })\n\n result = await payload.db.find<DataFromCollectionSlug<TSlug>>({\n collection: collectionConfig.slug,\n joins: req.payloadAPI === 'GraphQL' ? false : joins,\n limit: sanitizedLimit,\n 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 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 lockedDocuments = await payload.find({\n collection: 'payload-locked-documents',\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(new Date().getTime() - lockDurationInMilliseconds),\n },\n },\n ],\n },\n })\n\n const now = new Date().getTime()\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 result.docs = result.docs.map((doc) => {\n const lockedDoc = validLockedDocs.find((lock) => lock?.document?.value === doc.id)\n return {\n ...doc,\n _isLocked: !!lockedDoc,\n _userEditing: lockedDoc ? lockedDoc?.user?.value : null,\n }\n })\n } catch (error) {\n result.docs = result.docs.map((doc) => ({\n ...doc,\n _isLocked: false,\n _userEditing: null,\n }))\n }\n }\n\n // /////////////////////////////////////\n // beforeRead - Collection\n // /////////////////////////////////////\n\n result = {\n ...result,\n docs: await Promise.all(\n result.docs.map(async (doc) => {\n let docRef = doc\n\n await collectionConfig.hooks.beforeRead.reduce(async (priorHook, hook) => {\n await priorHook\n\n docRef =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n doc: docRef,\n query: fullWhere,\n req,\n })) || docRef\n }, Promise.resolve())\n\n return docRef\n }),\n ),\n }\n\n // /////////////////////////////////////\n // afterRead - Fields\n // /////////////////////////////////////\n\n result = {\n ...result,\n 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,\n doc,\n draft: draftsEnabled,\n fallbackLocale,\n findMany: true,\n global: null,\n locale,\n overrideAccess,\n req,\n select,\n showHiddenFields,\n }),\n ),\n ),\n }\n\n // /////////////////////////////////////\n // afterRead - Collection\n // /////////////////////////////////////\n\n result = {\n ...result,\n docs: await Promise.all(\n result.docs.map(async (doc) => {\n let docRef = doc\n\n await collectionConfig.hooks.afterRead.reduce(async (priorHook, hook) => {\n await priorHook\n\n docRef =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n doc: docRef,\n findMany: true,\n query: fullWhere,\n req,\n })) || doc\n }, Promise.resolve())\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 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","afterRead","killTransaction","buildVersionCollectionFields","appendVersionToQueryKey","getQueryDraftsSelect","getQueryDraftsSort","buildAfterOperation","findOperation","incomingArgs","args","collection","config","hooks","beforeOperation","reduce","priorHook","hook","context","req","operation","Promise","resolve","collectionConfig","currentDepth","depth","disableErrors","draft","draftsEnabled","includeLockStatus","joins","limit","overrideAccess","page","pagination","fallbackLocale","locale","payload","select","showHiddenFields","sort","where","accessResult","access","read","docs","hasNextPage","hasPrevPage","nextPage","pagingCounter","prevPage","totalDocs","totalPages","usePagination","sanitizedLimit","sanitizedPage","result","fullWhere","versions","drafts","versionFields","db","queryDrafts","slug","payloadAPI","find","lockDocumentsProp","lockDocuments","lockDurationDefault","lockDuration","duration","lockDurationInMilliseconds","lockedDocuments","and","equals","in","map","doc","id","updatedAt","greater_than","Date","getTime","now","lockedDocs","Array","isArray","validLockedDocs","filter","lock","lastEditedAt","lockedDoc","document","value","_isLocked","_userEditing","user","error","all","docRef","beforeRead","query","findMany","global"],"mappings":"AAgBA,OAAOA,mBAAmB,8BAA6B;AACvD,SAASC,cAAc,QAAQ,mCAAkC;AACjE,SAASC,kBAAkB,QAAQ,uDAAsD;AACzF,SAASC,SAAS,QAAQ,wCAAuC;AACjE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,4BAA4B,QAAQ,0CAAyC;AACtF,SAASC,uBAAuB,QAAQ,mDAAkD;AAC1F,SAASC,oBAAoB,QAAQ,gDAA+C;AACpF,SAASC,kBAAkB,QAAQ,8CAA6C;AAChF,SAASC,mBAAmB,QAAQ,aAAY;AAqBhD,OAAO,MAAMC,gBAAgB,OAI3BC;IAEA,IAAIC,OAAOD;IAEX,IAAI;QACF,wCAAwC;QACxC,+BAA+B;QAC/B,wCAAwC;QAExC,MAAMC,KAAKC,UAAU,CAACC,MAAM,CAACC,KAAK,CAACC,eAAe,CAACC,MAAM,CAAC,OAAOC,WAAWC;YAC1E,MAAMD;YAENN,OACE,AAAC,MAAMO,KAAK;gBACVP;gBACAC,YAAYD,KAAKC,UAAU,CAACC,MAAM;gBAClCM,SAASR,KAAKS,GAAG,CAACD,OAAO;gBACzBE,WAAW;gBACXD,KAAKT,KAAKS,GAAG;YACf,MAAOT;QACX,GAAGW,QAAQC,OAAO;QAElB,MAAM,EACJX,YAAY,EAAEC,QAAQW,gBAAgB,EAAE,EACxCZ,UAAU,EACVa,YAAY,EACZC,KAAK,EACLC,aAAa,EACbC,OAAOC,aAAa,EACpBC,iBAAiB,EACjBC,KAAK,EACLC,KAAK,EACLC,cAAc,EACdC,IAAI,EACJC,aAAa,IAAI,EACjBf,KAAK,EAAEgB,cA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,OAAO;oBACpBM;oBACAC;oBACAoD;oBACAlD,OAAOC;oBACPO;oBACAmE,UAAU;oBACVC,QAAQ;oBACRnE;oBACAJ;oBACAb;oBACAmB;oBACAC;gBACF;QAGN;QAEA,wCAAwC;QACxC,yBAAyB;QACzB,wCAAwC;QAExCiB,SAAS;YACP,GAAGA,MAAM;YACTX,MAAM,MAAMxB,QAAQ6E,GAAG,CACrB1C,OAAOX,IAAI,CAAC+B,GAAG,CAAC,OAAOC;gBACrB,IAAIsB,SAAStB;gBAEb,MAAMtD,iBAAiBV,KAAK,CAACZ,SAAS,CAACc,MAAM,CAAC,OAAOC,WAAWC;oBAC9D,MAAMD;oBAENmF,SACE,AAAC,MAAMlF,KAAK;wBACVN,YAAYY;wBACZL,SAASC,IAAID,OAAO;wBACpB2D,KAAKsB;wBACLG,UAAU;wBACVD,OAAO5C;wBACPtC;oBACF,MAAO0D;gBACX,GAAGxD,QAAQC,OAAO;gBAElB,OAAO6E;YACT;QAEJ;QAEA,wCAAwC;QACxC,8BAA8B;QAC9B,wCAAwC;QAExC3C,SAAS,MAAMjD,oBAAoB;YACjCG;YACAC,YAAYY;YACZH,WAAW;YACXoC;QACF;QAEA,wCAAwC;QACxC,iBAAiB;QACjB,wCAAwC;QAExC,OAAOA;IACT,EAAE,OAAOyC,OAAgB;QACvB,MAAM/F,gBAAgBQ,KAAKS,GAAG;QAC9B,MAAM8E;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,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC/D,OAAO,KAAK,EACV,kBAAkB,EAClB,cAAc,EACd,UAAU,EACV,6BAA6B,EAC9B,MAAM,sBAAsB,CAAA;AAC7B,OAAO,KAAK,EACV,UAAU,EAEV,wBAAwB,EACzB,MAAM,oBAAoB,CAAA;AAU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E,EAAE,MAAM,GAAG,MAAM,CAAA;IACnB,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,GAAG,EAAE,cAAc,CAAA;IACnB,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAC3B,CAAA;AAED,eAAO,MAAM,iBAAiB,GAC5B,KAAK,SAAS,cAAc,EAC5B,cAAc,SAAS,OAAO,EAC9B,OAAO,SAAS,wBAAwB,CAAC,KAAK,CAAC,gBAEjC,SAAS,KACtB,OAAO,CAAC,kBAAkB,CAAC,6BAA6B,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,cAAc,CAAC,CAmO3F,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/collections/operations/findByID.ts"],"sourcesContent":["import type { FindOneArgs } from '../../database/types.js'\nimport type { CollectionSlug, JoinQuery } from '../../index.js'\nimport type {\n ApplyDisableErrors,\n PayloadRequest,\n SelectType,\n TransformCollectionWithSelect,\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 { NotFound } from '../../errors/index.js'\nimport { afterRead } from '../../fields/hooks/afterRead/index.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport replaceWithDraftIfAvailable from '../../versions/drafts/replaceWithDraftIfAvailable.js'\nimport { buildAfterOperation } from './utils.js'\n\nexport type Arguments = {\n collection: Collection\n currentDepth?: number\n depth?: number\n disableErrors?: boolean\n draft?: boolean\n id: number | string\n includeLockStatus?: boolean\n joins?: JoinQuery\n overrideAccess?: boolean\n req: PayloadRequest\n select?: SelectType\n showHiddenFields?: boolean\n}\n\nexport const findByIDOperation = async <\n TSlug extends CollectionSlug,\n TDisableErrors extends boolean,\n TSelect extends SelectFromCollectionSlug<TSlug>,\n>(\n incomingArgs: Arguments,\n): Promise<ApplyDisableErrors<TransformCollectionWithSelect<TSlug, TSelect>, TDisableErrors>> => {\n let args = incomingArgs\n\n try {\n // /////////////////////////////////////\n // beforeOperation - Collection\n // /////////////////////////////////////\n\n await args.collection.config.hooks.beforeOperation.reduce(async (priorHook, hook) => {\n await priorHook\n\n args =\n (await hook({\n args,\n collection: args.collection.config,\n context: args.req.context,\n operation: 'read',\n req: args.req,\n })) || args\n }, Promise.resolve())\n\n const {\n id,\n collection: { config: collectionConfig },\n currentDepth,\n depth,\n disableErrors,\n draft: draftEnabled = false,\n includeLockStatus,\n joins,\n overrideAccess = false,\n req: { fallbackLocale, locale, t },\n req,\n select,\n showHiddenFields,\n } = args\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 findOneArgs: FindOneArgs = {\n collection: collectionConfig.slug,\n joins: req.payloadAPI === 'GraphQL' ? false : joins,\n locale,\n req: {\n transactionID: req.transactionID,\n } as PayloadRequest,\n select,\n where: combineQueries({ id: { equals: id } }, accessResult),\n }\n\n // /////////////////////////////////////\n // Find by ID\n // /////////////////////////////////////\n\n if (!findOneArgs.where.and[0].id) {\n throw new NotFound(t)\n }\n\n let result: DataFromCollectionSlug<TSlug> = await req.payload.db.findOne(findOneArgs)\n\n if (!result) {\n if (!disableErrors) {\n throw new NotFound(req.t)\n }\n\n return null\n }\n\n // /////////////////////////////////////\n // Include Lock Status if required\n // /////////////////////////////////////\n\n if (includeLockStatus && id) {\n let lockStatus = 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: 'payload-locked-documents',\n depth: 1,\n limit: 1,\n pagination: false,\n req,\n where: {\n and: [\n {\n 'document.relationTo': {\n equals: collectionConfig.slug,\n },\n },\n {\n 'document.value': {\n equals: id,\n },\n },\n // Query where the lock is newer than the current time minus lock time\n {\n updatedAt: {\n greater_than: new Date(new Date().getTime() - lockDurationInMilliseconds),\n },\n },\n ],\n },\n })\n\n if (lockedDocument && lockedDocument.docs.length > 0) {\n lockStatus = lockedDocument.docs[0]\n }\n } catch {\n // swallow error\n }\n\n result._isLocked = !!lockStatus\n result._userEditing = lockStatus?.user?.value ?? null\n }\n\n // /////////////////////////////////////\n // Replace document with draft if available\n // /////////////////////////////////////\n\n if (collectionConfig.versions?.drafts && draftEnabled) {\n result = await replaceWithDraftIfAvailable({\n accessResult,\n doc: result,\n entity: collectionConfig,\n entityType: 'collection',\n overrideAccess,\n req,\n select,\n })\n }\n\n // /////////////////////////////////////\n // beforeRead - Collection\n // /////////////////////////////////////\n\n await collectionConfig.hooks.beforeRead.reduce(async (priorHook, hook) => {\n await priorHook\n\n result =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n doc: result,\n query: findOneArgs.where,\n req,\n })) || result\n }, Promise.resolve())\n\n // /////////////////////////////////////\n // afterRead - Fields\n // /////////////////////////////////////\n\n result = await afterRead({\n collection: collectionConfig,\n context: req.context,\n currentDepth,\n depth,\n doc: result,\n draft: draftEnabled,\n fallbackLocale,\n global: null,\n locale,\n overrideAccess,\n req,\n select,\n showHiddenFields,\n })\n\n // /////////////////////////////////////\n // afterRead - Collection\n // /////////////////////////////////////\n\n await collectionConfig.hooks.afterRead.reduce(async (priorHook, hook) => {\n await priorHook\n\n result =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n doc: result,\n query: findOneArgs.where,\n req,\n })) || result\n }, Promise.resolve())\n\n // /////////////////////////////////////\n // afterOperation - Collection\n // /////////////////////////////////////\n\n result = await buildAfterOperation({\n args,\n collection: collectionConfig,\n operation: 'findByID',\n result,\n })\n\n // /////////////////////////////////////\n // Return results\n // /////////////////////////////////////\n\n return result as ApplyDisableErrors<\n TransformCollectionWithSelect<TSlug, TSelect>,\n TDisableErrors\n >\n } catch (error: unknown) {\n await killTransaction(args.req)\n throw error\n }\n}\n"],"names":["executeAccess","combineQueries","NotFound","afterRead","killTransaction","replaceWithDraftIfAvailable","buildAfterOperation","findByIDOperation","incomingArgs","args","collection","config","hooks","beforeOperation","reduce","priorHook","hook","context","req","operation","Promise","resolve","id","collectionConfig","currentDepth","depth","disableErrors","draft","draftEnabled","includeLockStatus","joins","overrideAccess","fallbackLocale","locale","t","select","showHiddenFields","accessResult","access","read","findOneArgs","slug","payloadAPI","transactionID","where","equals","and","result","payload","db","findOne","lockStatus","lockDocumentsProp","lockDocuments","lockDurationDefault","lockDuration","duration","lockDurationInMilliseconds","lockedDocument","find","limit","pagination","updatedAt","greater_than","Date","getTime","docs","length","_isLocked","_userEditing","user","value","versions","drafts","doc","entity","entityType","beforeRead","query","global","error"],"mappings":"AAcA,OAAOA,mBAAmB,8BAA6B;AACvD,SAASC,cAAc,QAAQ,mCAAkC;AACjE,SAASC,QAAQ,QAAQ,wBAAuB;AAChD,SAASC,SAAS,QAAQ,wCAAuC;AACjE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,OAAOC,iCAAiC,uDAAsD;AAC9F,SAASC,mBAAmB,QAAQ,aAAY;AAiBhD,OAAO,MAAMC,oBAAoB,OAK/BC;IAEA,IAAIC,OAAOD;IAEX,IAAI;QACF,wCAAwC;QACxC,+BAA+B;QAC/B,wCAAwC;QAExC,MAAMC,KAAKC,UAAU,CAACC,MAAM,CAACC,KAAK,CAACC,eAAe,CAACC,MAAM,CAAC,OAAOC,WAAWC;YAC1E,MAAMD;YAENN,OACE,AAAC,MAAMO,KAAK;gBACVP;gBACAC,YAAYD,KAAKC,UAAU,CAACC,MAAM;gBAClCM,SAASR,KAAKS,GAAG,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C;YAC/D,MAAMD;YAENgC,SACE,AAAC,MAAM/B,KAAK;gBACVN,YAAYa;gBACZN,SAASC,IAAID,OAAO;gBACpByD,KAAK3B;gBACL+B,OAAOtC,YAAYI,KAAK;gBACxB1B;YACF,MAAO6B;QACX,GAAG3B,QAAQC,OAAO;QAElB,wCAAwC;QACxC,qBAAqB;QACrB,wCAAwC;QAExC0B,SAAS,MAAM5C,UAAU;YACvBO,YAAYa;YACZN,SAASC,IAAID,OAAO;YACpBO;YACAC;YACAiD,KAAK3B;YACLpB,OAAOC;YACPI;YACA+C,QAAQ;YACR9C;YACAF;YACAb;YACAiB;YACAC;QACF;QAEA,wCAAwC;QACxC,yBAAyB;QACzB,wCAAwC;QAExC,MAAMb,iBAAiBX,KAAK,CAACT,SAAS,CAACW,MAAM,CAAC,OAAOC,WAAWC;YAC9D,MAAMD;YAENgC,SACE,AAAC,MAAM/B,KAAK;gBACVN,YAAYa;gBACZN,SAASC,IAAID,OAAO;gBACpByD,KAAK3B;gBACL+B,OAAOtC,YAAYI,KAAK;gBACxB1B;YACF,MAAO6B;QACX,GAAG3B,QAAQC,OAAO;QAElB,wCAAwC;QACxC,8BAA8B;QAC9B,wCAAwC;QAExC0B,SAAS,MAAMzC,oBAAoB;YACjCG;YACAC,YAAYa;YACZJ,WAAW;YACX4B;QACF;QAEA,wCAAwC;QACxC,iBAAiB;QACjB,wCAAwC;QAExC,OAAOA;IAIT,EAAE,OAAOiC,OAAgB;QACvB,MAAM5E,gBAAgBK,KAAKS,GAAG;QAC9B,MAAM8D;IACR;AACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/collections/operations/findByID.ts"],"sourcesContent":["import type { FindOneArgs } from '../../database/types.js'\nimport type { CollectionSlug, JoinQuery } from '../../index.js'\nimport type {\n ApplyDisableErrors,\n PayloadRequest,\n SelectType,\n TransformCollectionWithSelect,\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 { NotFound } from '../../errors/index.js'\nimport { afterRead } from '../../fields/hooks/afterRead/index.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport replaceWithDraftIfAvailable from '../../versions/drafts/replaceWithDraftIfAvailable.js'\nimport { buildAfterOperation } from './utils.js'\n\nexport type Arguments = {\n collection: Collection\n currentDepth?: number\n depth?: number\n disableErrors?: boolean\n draft?: boolean\n id: number | string\n includeLockStatus?: boolean\n joins?: JoinQuery\n overrideAccess?: boolean\n req: PayloadRequest\n select?: SelectType\n showHiddenFields?: boolean\n}\n\nexport const findByIDOperation = async <\n TSlug extends CollectionSlug,\n TDisableErrors extends boolean,\n TSelect extends SelectFromCollectionSlug<TSlug>,\n>(\n incomingArgs: Arguments,\n): Promise<ApplyDisableErrors<TransformCollectionWithSelect<TSlug, TSelect>, TDisableErrors>> => {\n let args = incomingArgs\n\n try {\n // /////////////////////////////////////\n // beforeOperation - Collection\n // /////////////////////////////////////\n\n await args.collection.config.hooks.beforeOperation.reduce(async (priorHook, hook) => {\n await priorHook\n\n args =\n (await hook({\n args,\n collection: args.collection.config,\n context: args.req.context,\n operation: 'read',\n req: args.req,\n })) || args\n }, Promise.resolve())\n\n const {\n id,\n collection: { config: collectionConfig },\n currentDepth,\n depth,\n disableErrors,\n draft: draftEnabled = false,\n includeLockStatus,\n joins,\n overrideAccess = false,\n req: { fallbackLocale, locale, t },\n req,\n select,\n showHiddenFields,\n } = args\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 findOneArgs: FindOneArgs = {\n collection: collectionConfig.slug,\n joins: req.payloadAPI === 'GraphQL' ? false : joins,\n locale,\n req: {\n transactionID: req.transactionID,\n } as PayloadRequest,\n select,\n where: combineQueries({ id: { equals: id } }, accessResult),\n }\n\n // /////////////////////////////////////\n // Find by ID\n // /////////////////////////////////////\n\n if (!findOneArgs.where.and[0].id) {\n throw new NotFound(t)\n }\n\n let result: DataFromCollectionSlug<TSlug> = await req.payload.db.findOne(findOneArgs)\n\n if (!result) {\n if (!disableErrors) {\n throw new NotFound(req.t)\n }\n\n return null\n }\n\n // /////////////////////////////////////\n // Include Lock Status if required\n // /////////////////////////////////////\n\n if (includeLockStatus && id) {\n let lockStatus = 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: 'payload-locked-documents',\n depth: 1,\n limit: 1,\n overrideAccess: false,\n pagination: false,\n req,\n where: {\n and: [\n {\n 'document.relationTo': {\n equals: collectionConfig.slug,\n },\n },\n {\n 'document.value': {\n equals: id,\n },\n },\n // Query where the lock is newer than the current time minus lock time\n {\n updatedAt: {\n greater_than: new Date(new Date().getTime() - lockDurationInMilliseconds),\n },\n },\n ],\n },\n })\n\n if (lockedDocument && lockedDocument.docs.length > 0) {\n lockStatus = lockedDocument.docs[0]\n }\n } catch {\n // swallow error\n }\n\n result._isLocked = !!lockStatus\n result._userEditing = lockStatus?.user?.value ?? null\n }\n\n // /////////////////////////////////////\n // Replace document with draft if available\n // /////////////////////////////////////\n\n if (collectionConfig.versions?.drafts && draftEnabled) {\n result = await replaceWithDraftIfAvailable({\n accessResult,\n doc: result,\n entity: collectionConfig,\n entityType: 'collection',\n overrideAccess,\n req,\n select,\n })\n }\n\n // /////////////////////////////////////\n // beforeRead - Collection\n // /////////////////////////////////////\n\n await collectionConfig.hooks.beforeRead.reduce(async (priorHook, hook) => {\n await priorHook\n\n result =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n doc: result,\n query: findOneArgs.where,\n req,\n })) || result\n }, Promise.resolve())\n\n // /////////////////////////////////////\n // afterRead - Fields\n // /////////////////////////////////////\n\n result = await afterRead({\n collection: collectionConfig,\n context: req.context,\n currentDepth,\n depth,\n doc: result,\n draft: draftEnabled,\n fallbackLocale,\n global: null,\n locale,\n overrideAccess,\n req,\n select,\n showHiddenFields,\n })\n\n // /////////////////////////////////////\n // afterRead - Collection\n // /////////////////////////////////////\n\n await collectionConfig.hooks.afterRead.reduce(async (priorHook, hook) => {\n await priorHook\n\n result =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n doc: result,\n query: findOneArgs.where,\n req,\n })) || result\n }, Promise.resolve())\n\n // /////////////////////////////////////\n // afterOperation - Collection\n // /////////////////////////////////////\n\n result = await buildAfterOperation({\n args,\n collection: collectionConfig,\n operation: 'findByID',\n result,\n })\n\n // /////////////////////////////////////\n // Return results\n // /////////////////////////////////////\n\n return result as ApplyDisableErrors<\n TransformCollectionWithSelect<TSlug, TSelect>,\n TDisableErrors\n >\n } catch (error: unknown) {\n await killTransaction(args.req)\n throw error\n }\n}\n"],"names":["executeAccess","combineQueries","NotFound","afterRead","killTransaction","replaceWithDraftIfAvailable","buildAfterOperation","findByIDOperation","incomingArgs","args","collection","config","hooks","beforeOperation","reduce","priorHook","hook","context","req","operation","Promise","resolve","id","collectionConfig","currentDepth","depth","disableErrors","draft","draftEnabled","includeLockStatus","joins","overrideAccess","fallbackLocale","locale","t","select","showHiddenFields","accessResult","access","read","findOneArgs","slug","payloadAPI","transactionID","where","equals","and","result","payload","db","findOne","lockStatus","lockDocumentsProp","lockDocuments","lockDurationDefault","lockDuration","duration","lockDurationInMilliseconds","lockedDocument","find","limit","pagination","updatedAt","greater_than","Date","getTime","docs","length","_isLocked","_userEditing","user","value","versions","drafts","doc","entity","entityType","beforeRead","query","global","error"],"mappings":"AAcA,OAAOA,mBAAmB,8BAA6B;AACvD,SAASC,cAAc,QAAQ,mCAAkC;AACjE,SAASC,QAAQ,QAAQ,wBAAuB;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AS,MAAMzC,oBAAoB;YACjCG;YACAC,YAAYa;YACZJ,WAAW;YACX4B;QACF;QAEA,wCAAwC;QACxC,iBAAiB;QACjB,wCAAwC;QAExC,OAAOA;IAIT,EAAE,OAAOiC,OAAgB;QACvB,MAAM5E,gBAAgBK,KAAKS,GAAG;QAC9B,MAAM8D;IACR;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findOne.d.ts","sourceRoot":"","sources":["../../../src/globals/operations/findOne.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAS,MAAM,sBAAsB,CAAA;AAC7E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAQ/D,KAAK,IAAI,GAAG;IACV,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,YAAY,EAAE,qBAAqB,CAAA;IACnC,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,GAAG,EAAE,cAAc,CAAA;IACnB,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAU,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,QAChE,IAAI,KACT,OAAO,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"findOne.d.ts","sourceRoot":"","sources":["../../../src/globals/operations/findOne.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAS,MAAM,sBAAsB,CAAA;AAC7E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAQ/D,KAAK,IAAI,GAAG;IACV,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,YAAY,EAAE,qBAAqB,CAAA;IACnC,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,GAAG,EAAE,cAAc,CAAA;IACnB,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAU,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,QAChE,IAAI,KACT,OAAO,CAAC,CAAC,CAiLX,CAAA"}
|
|
@@ -34,16 +34,31 @@ export const findOneOperation = async (args)=>{
|
|
|
34
34
|
if (includeLockStatus && slug) {
|
|
35
35
|
let lockStatus = null;
|
|
36
36
|
try {
|
|
37
|
+
const lockDocumentsProp = globalConfig?.lockDocuments;
|
|
38
|
+
const lockDurationDefault = 300 // Default 5 minutes in seconds
|
|
39
|
+
;
|
|
40
|
+
const lockDuration = typeof lockDocumentsProp === 'object' ? lockDocumentsProp.duration : lockDurationDefault;
|
|
41
|
+
const lockDurationInMilliseconds = lockDuration * 1000;
|
|
37
42
|
const lockedDocument = await req.payload.find({
|
|
38
43
|
collection: 'payload-locked-documents',
|
|
39
44
|
depth: 1,
|
|
40
45
|
limit: 1,
|
|
46
|
+
overrideAccess: false,
|
|
41
47
|
pagination: false,
|
|
42
48
|
req,
|
|
43
49
|
where: {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
50
|
+
and: [
|
|
51
|
+
{
|
|
52
|
+
globalSlug: {
|
|
53
|
+
equals: slug
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
updatedAt: {
|
|
58
|
+
greater_than: new Date(new Date().getTime() - lockDurationInMilliseconds)
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
]
|
|
47
62
|
}
|
|
48
63
|
});
|
|
49
64
|
if (lockedDocument && lockedDocument.docs.length > 0) {
|
|
@@ -53,7 +68,6 @@ export const findOneOperation = async (args)=>{
|
|
|
53
68
|
// swallow error
|
|
54
69
|
}
|
|
55
70
|
doc._isLocked = !!lockStatus;
|
|
56
|
-
doc._lastEditedAt = lockStatus?.updatedAt ?? null;
|
|
57
71
|
doc._userEditing = lockStatus?.user?.value ?? null;
|
|
58
72
|
}
|
|
59
73
|
// /////////////////////////////////////
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/globals/operations/findOne.ts"],"sourcesContent":["import type { AccessResult } from '../../config/types.js'\nimport type { PayloadRequest, SelectType, Where } from '../../types/index.js'\nimport type { SanitizedGlobalConfig } from '../config/types.js'\n\nimport executeAccess from '../../auth/executeAccess.js'\nimport { afterRead } from '../../fields/hooks/afterRead/index.js'\nimport { getSelectMode } from '../../utilities/getSelectMode.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport replaceWithDraftIfAvailable from '../../versions/drafts/replaceWithDraftIfAvailable.js'\n\ntype Args = {\n depth?: number\n draft?: boolean\n globalConfig: SanitizedGlobalConfig\n includeLockStatus?: boolean\n overrideAccess?: boolean\n req: PayloadRequest\n select?: SelectType\n showHiddenFields?: boolean\n slug: string\n}\n\nexport const findOneOperation = async <T extends Record<string, unknown>>(\n args: Args,\n): Promise<T> => {\n const {\n slug,\n depth,\n draft: draftEnabled = false,\n globalConfig,\n includeLockStatus,\n overrideAccess = false,\n req: { fallbackLocale, locale },\n req,\n select,\n showHiddenFields,\n } = args\n\n try {\n // /////////////////////////////////////\n // Retrieve and execute access\n // /////////////////////////////////////\n\n let accessResult: AccessResult\n\n if (!overrideAccess) {\n accessResult = await executeAccess({ req }, globalConfig.access.read)\n }\n\n // /////////////////////////////////////\n // Perform database operation\n // /////////////////////////////////////\n\n let doc = await req.payload.db.findGlobal({\n slug,\n locale,\n req,\n select,\n where: overrideAccess ? undefined : (accessResult as Where),\n })\n if (!doc) {\n doc = {}\n }\n\n // /////////////////////////////////////\n // Include Lock Status if required\n // /////////////////////////////////////\n
|
|
1
|
+
{"version":3,"sources":["../../../src/globals/operations/findOne.ts"],"sourcesContent":["import type { AccessResult } from '../../config/types.js'\nimport type { PayloadRequest, SelectType, Where } from '../../types/index.js'\nimport type { SanitizedGlobalConfig } from '../config/types.js'\n\nimport executeAccess from '../../auth/executeAccess.js'\nimport { afterRead } from '../../fields/hooks/afterRead/index.js'\nimport { getSelectMode } from '../../utilities/getSelectMode.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport replaceWithDraftIfAvailable from '../../versions/drafts/replaceWithDraftIfAvailable.js'\n\ntype Args = {\n depth?: number\n draft?: boolean\n globalConfig: SanitizedGlobalConfig\n includeLockStatus?: boolean\n overrideAccess?: boolean\n req: PayloadRequest\n select?: SelectType\n showHiddenFields?: boolean\n slug: string\n}\n\nexport const findOneOperation = async <T extends Record<string, unknown>>(\n args: Args,\n): Promise<T> => {\n const {\n slug,\n depth,\n draft: draftEnabled = false,\n globalConfig,\n includeLockStatus,\n overrideAccess = false,\n req: { fallbackLocale, locale },\n req,\n select,\n showHiddenFields,\n } = args\n\n try {\n // /////////////////////////////////////\n // Retrieve and execute access\n // /////////////////////////////////////\n\n let accessResult: AccessResult\n\n if (!overrideAccess) {\n accessResult = await executeAccess({ req }, globalConfig.access.read)\n }\n\n // /////////////////////////////////////\n // Perform database operation\n // /////////////////////////////////////\n\n let doc = await req.payload.db.findGlobal({\n slug,\n locale,\n req,\n select,\n where: overrideAccess ? undefined : (accessResult as Where),\n })\n if (!doc) {\n doc = {}\n }\n\n // /////////////////////////////////////\n // Include Lock Status if required\n // /////////////////////////////////////\n if (includeLockStatus && slug) {\n let lockStatus = null\n\n try {\n const lockDocumentsProp = globalConfig?.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: 'payload-locked-documents',\n depth: 1,\n limit: 1,\n overrideAccess: false,\n pagination: false,\n req,\n where: {\n and: [\n {\n globalSlug: {\n equals: slug,\n },\n },\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 doc._isLocked = !!lockStatus\n doc._userEditing = lockStatus?.user?.value ?? null\n }\n\n // /////////////////////////////////////\n // Replace document with draft if available\n // /////////////////////////////////////\n\n if (globalConfig.versions?.drafts && draftEnabled) {\n doc = await replaceWithDraftIfAvailable({\n accessResult,\n doc,\n entity: globalConfig,\n entityType: 'global',\n overrideAccess,\n req,\n select,\n })\n }\n\n // /////////////////////////////////////\n // Execute before global hook\n // /////////////////////////////////////\n\n await globalConfig.hooks.beforeRead.reduce(async (priorHook, hook) => {\n await priorHook\n\n doc =\n (await hook({\n context: req.context,\n doc,\n global: globalConfig,\n req,\n })) || doc\n }, Promise.resolve())\n\n // /////////////////////////////////////\n // Execute globalType field if not selected\n // /////////////////////////////////////\n if (select && doc.globalType) {\n const selectMode = getSelectMode(select)\n if (\n (selectMode === 'include' && !select['globalType']) ||\n (selectMode === 'exclude' && select['globalType'] === false)\n ) {\n delete doc['globalType']\n }\n }\n\n // /////////////////////////////////////\n // Execute field-level hooks and access\n // /////////////////////////////////////\n\n doc = await afterRead({\n collection: null,\n context: req.context,\n depth,\n doc,\n draft: draftEnabled,\n fallbackLocale,\n global: globalConfig,\n locale,\n overrideAccess,\n req,\n select,\n showHiddenFields,\n })\n\n // /////////////////////////////////////\n // Execute after global hook\n // /////////////////////////////////////\n\n await globalConfig.hooks.afterRead.reduce(async (priorHook, hook) => {\n await priorHook\n\n doc =\n (await hook({\n context: req.context,\n doc,\n global: globalConfig,\n req,\n })) || doc\n }, Promise.resolve())\n\n // /////////////////////////////////////\n // Return results\n // /////////////////////////////////////\n\n return doc\n } catch (error: unknown) {\n await killTransaction(req)\n throw error\n }\n}\n"],"names":["executeAccess","afterRead","getSelectMode","killTransaction","replaceWithDraftIfAvailable","findOneOperation","args","slug","depth","draft","draftEnabled","globalConfig","includeLockStatus","overrideAccess","req","fallbackLocale","locale","select","showHiddenFields","accessResult","access","read","doc","payload","db","findGlobal","where","undefined","lockStatus","lockDocumentsProp","lockDocuments","lockDurationDefault","lockDuration","duration","lockDurationInMilliseconds","lockedDocument","find","collection","limit","pagination","and","globalSlug","equals","updatedAt","greater_than","Date","getTime","docs","length","_isLocked","_userEditing","user","value","versions","drafts","entity","entityType","hooks","beforeRead","reduce","priorHook","hook","context","global","Promise","resolve","globalType","selectMode","error"],"mappings":"AAIA,OAAOA,mBAAmB,8BAA6B;AACvD,SAASC,SAAS,QAAQ,wCAAuC;AACjE,SAASC,aAAa,QAAQ,mCAAkC;AAChE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,OAAOC,iCAAiC,uDAAsD;AAc9F,OAAO,MAAMC,mBAAmB,OAC9BC;IAEA,MAAM,EACJC,IAAI,EACJC,KAAK,EACLC,OAAOC,eAAe,KAAK,EAC3BC,YAAY,EACZC,iBAAiB,EACjBC,iBAAiB,KAAK,EACtBC,KAAK,EAAEC,cAAc,EAAEC,MAAM,EAAE,EAC/BF,GAAG,EACHG,MAAM,EACNC,gBAAgB,EACjB,GAAGZ;IAEJ,IAAI;QACF,wCAAwC;QACxC,8BAA8B;QAC9B,wCAAwC;QAExC,IAAIa;QAEJ,IAAI,CAACN,gBAAgB;YACnBM,eAAe,MAAMnB,cAAc;gBAAEc;YAAI,GAAGH,aAAaS,MAAM,CAACC,IAAI;QACtE;QAEA,wCAAwC;QACxC,6BAA6B;QAC7B,wCAAwC;QAExC,IAAIC,MAAM,MAAMR,IAAIS,OAAO,CAACC,EAAE,CAACC,UAAU,CAAC;YACxClB;YACAS;YACAF;YACAG;YACAS,OAAOb,iBAAiBc,YAAaR;QACvC;QACA,IAAI,CAACG,KAAK;Y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MAAMuC,KAAK;gBACVC,SAAShD,IAAIgD,OAAO;gBACpBxC;gBACAyC,QAAQpD;gBACRG;YACF,MAAOQ;QACX,GAAG0C,QAAQC,OAAO;QAElB,wCAAwC;QACxC,2CAA2C;QAC3C,wCAAwC;QACxC,IAAIhD,UAAUK,IAAI4C,UAAU,EAAE;YAC5B,MAAMC,aAAajE,cAAce;YACjC,IACE,AAACkD,eAAe,aAAa,CAAClD,MAAM,CAAC,aAAa,IACjDkD,eAAe,aAAalD,MAAM,CAAC,aAAa,KAAK,OACtD;gBACA,OAAOK,GAAG,CAAC,aAAa;YAC1B;QACF;QAEA,wCAAwC;QACxC,uCAAuC;QACvC,wCAAwC;QAExCA,MAAM,MAAMrB,UAAU;YACpBoC,YAAY;YACZyB,SAAShD,IAAIgD,OAAO;YACpBtD;YACAc;YACAb,OAAOC;YACPK;YACAgD,QAAQpD;YACRK;YACAH;YACAC;YACAG;YACAC;QACF;QAEA,wCAAwC;QACxC,4BAA4B;QAC5B,wCAAwC;QAExC,MAAMP,aAAa8C,KAAK,CAACxD,SAAS,CAAC0D,MAAM,CAAC,OAAOC,WAAWC;YAC1D,MAAMD;YAENtC,MACE,AAAC,MAAMuC,KAAK;gBACVC,SAAShD,IAAIgD,OAAO;gBACpBxC;gBACAyC,QAAQpD;gBACRG;YACF,MAAOQ;QACX,GAAG0C,QAAQC,OAAO;QAElB,wCAAwC;QACxC,iBAAiB;QACjB,wCAAwC;QAExC,OAAO3C;IACT,EAAE,OAAO8C,OAAgB;QACvB,MAAMjE,gBAAgBW;QACtB,MAAMsD;IACR;AACF,EAAC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -120,7 +120,7 @@ export type SelectExcludeType = {
|
|
|
120
120
|
};
|
|
121
121
|
export type SelectMode = 'exclude' | 'include';
|
|
122
122
|
export type SelectType = SelectExcludeType | SelectIncludeType;
|
|
123
|
-
export type ApplyDisableErrors<T, DisableErrors
|
|
123
|
+
export type ApplyDisableErrors<T, DisableErrors = false> = false extends DisableErrors ? T : null | T;
|
|
124
124
|
export type TransformDataWithSelect<Data extends Record<string, any>, Select extends SelectType> = Select extends never ? Data : string extends keyof Select ? Data : string extends keyof Omit<Data, 'id'> ? Select extends SelectIncludeType ? {
|
|
125
125
|
[K in Data extends TypeWithID ? 'id' | keyof Select : keyof Select]: K extends 'id' ? number | string : unknown;
|
|
126
126
|
} : Data : Select extends SelectIncludeType ? {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AAC/D,OAAO,KAAK,UAAU,MAAM,YAAY,CAAA;AACxC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAE9B,OAAO,KAAK,EACV,sBAAsB,EACtB,UAAU,EACV,kBAAkB,EACnB,MAAM,gCAAgC,CAAA;AACvC,OAAO,KAAK,OAAO,MAAM,aAAa,CAAA;AACtC,OAAO,KAAK,EACV,cAAc,EACd,kBAAkB,EAClB,UAAU,EACV,WAAW,EACX,SAAS,EACV,MAAM,aAAa,CAAA;AACpB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACpD,YAAY,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,aAAa,CAAA;AAErD,MAAM,MAAM,8BAA8B,GAAG;IAC3C,OAAO,EAAE,cAAc,CAAA;IACvB,mGAAmG;IACnG,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,IAAI,EAAE,IAAI,CAAA;IACV;;;OAGG;IACH,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB;;OAEG;IACH,OAAO,EAAE,OAAO,OAAO,CAAA;IACvB;;OAEG;IACH,UAAU,EAAE,SAAS,GAAG,OAAO,GAAG,MAAM,CAAA;IACxC,gCAAgC;IAChC,iBAAiB,CAAC,EAAE,UAAU,CAAC,MAAM,EAAE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AU,IACxB,OAAO,SAAS,UAAU,GAC1B,uBAAuB,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,GAC3D,kBAAkB,CAAC,KAAK,CAAC,CAAA"}
|
package/dist/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/index.ts"],"sourcesContent":["import type { I18n, TFunction } from '@payloadcms/translations'\nimport type DataLoader from 'dataloader'\nimport type { URL } from 'url'\n\nimport type {\n DataFromCollectionSlug,\n TypeWithID,\n TypeWithTimestamps,\n} from '../collections/config/types.js'\nimport type payload from '../index.js'\nimport type {\n CollectionSlug,\n DataFromGlobalSlug,\n GlobalSlug,\n TypedLocale,\n TypedUser,\n} from '../index.js'\nimport type { validOperators } from './constants.js'\nexport type { Payload as Payload } from '../index.js'\n\nexport type CustomPayloadRequestProperties = {\n context: RequestContext\n /** The locale that should be used for a field when it is not translated to the requested locale */\n fallbackLocale?: string\n i18n: I18n\n /**\n * The requested locale if specified\n * Only available for localized collections\n */\n locale?: TypedLocale\n /**\n * The payload object\n */\n payload: typeof payload\n /**\n * The context in which the request is being made\n */\n payloadAPI: 'GraphQL' | 'local' | 'REST'\n /** Optimized document loader */\n payloadDataLoader?: DataLoader<string, TypeWithID>\n /** Resized versions of the image that was uploaded during this request */\n payloadUploadSizes?: Record<string, Buffer>\n /** Query params on the request */\n query: Record<string, unknown>\n /** Any response headers that are required to be set when a response is sent */\n responseHeaders?: Headers\n /** The route parameters\n * @example\n * /:collection/:id -> /posts/123\n * { collection: 'posts', id: '123' }\n */\n routeParams?: Record<string, unknown>\n /** Translate function - duplicate of i18n.t */\n t: TFunction\n /**\n * Identifier for the database transaction for interactions in a single, all-or-nothing operation.\n * Can also be used to ensure consistency when multiple operations try to create a transaction concurrently on the same request.\n */\n transactionID?: number | Promise<number | string> | string\n /**\n * Used to ensure consistency when multiple operations try to create a transaction concurrently on the same request\n */\n transactionIDPromise?: Promise<void>\n /** The signed-in user */\n user: null | TypedUser\n} & Pick<\n URL,\n 'hash' | 'host' | 'href' | 'origin' | 'pathname' | 'port' | 'protocol' | 'search' | 'searchParams'\n>\ntype PayloadRequestData = {\n /**\n * Data from the request body\n *\n * Within Payload operations, i.e. hooks, data will be there\n * BUT in custom endpoints it will not be, you will need to\n * use either:\n * 1. `const data = await req.json()`\n *\n * 2. import { addDataAndFileToRequest } from '@payloadcms/next/utilities'\n * `await addDataAndFileToRequest(req)`\n * */\n data?: JsonObject\n /** The file on the request, same rules apply as the `data` property */\n file?: {\n data: Buffer\n mimetype: string\n name: string\n size: number\n tempFilePath?: string\n }\n}\nexport type PayloadRequest = CustomPayloadRequestProperties &\n Partial<Request> &\n PayloadRequestData &\n Required<Pick<Request, 'headers'>>\n\nexport interface RequestContext {\n [key: string]: unknown\n}\n\nexport type Operator = (typeof validOperators)[number]\n\n// Makes it so things like passing new Date() will error\nexport type JsonValue = JsonArray | JsonObject | unknown //Date | JsonArray | JsonObject | boolean | null | number | string // TODO: Evaluate proper, strong type for this\n\nexport type JsonArray = Array<JsonValue>\n\nexport interface JsonObject {\n [key: string]: any\n}\n\nexport type WhereField = {\n // any json-serializable value\n [key in Operator]?: JsonValue\n}\n\nexport type Where = {\n [key: string]: Where[] | WhereField\n and?: Where[]\n or?: Where[]\n}\n\nexport type Sort = Array<string> | string\n\n/**\n * Applies pagination for join fields for including collection relationships\n */\nexport type JoinQuery =\n | {\n [schemaPath: string]: {\n limit?: number\n sort?: string\n where?: Where\n }\n }\n | false\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type Document = any\n\nexport type Operation = 'create' | 'delete' | 'read' | 'update'\nexport type VersionOperations = 'readVersions'\nexport type AuthOperations = 'unlock'\nexport type AllOperations = AuthOperations | Operation | VersionOperations\n\nexport function docHasTimestamps(doc: any): doc is TypeWithTimestamps {\n return doc?.createdAt && doc?.updatedAt\n}\n\nexport type IfAny<T, Y, N> = 0 extends 1 & T ? Y : N // This is a commonly used trick to detect 'any'\nexport type IsAny<T> = IfAny<T, true, false>\nexport type ReplaceAny<T, DefaultType> = IsAny<T> extends true ? DefaultType : T\n\nexport type SelectIncludeType = {\n [k: string]: SelectIncludeType | true\n}\n\nexport type SelectExcludeType = {\n [k: string]: false | SelectExcludeType\n}\n\nexport type SelectMode = 'exclude' | 'include'\n\nexport type SelectType = SelectExcludeType | SelectIncludeType\n\nexport type ApplyDisableErrors<T, DisableErrors
|
|
1
|
+
{"version":3,"sources":["../../src/types/index.ts"],"sourcesContent":["import type { I18n, TFunction } from '@payloadcms/translations'\nimport type DataLoader from 'dataloader'\nimport type { URL } from 'url'\n\nimport type {\n DataFromCollectionSlug,\n TypeWithID,\n TypeWithTimestamps,\n} from '../collections/config/types.js'\nimport type payload from '../index.js'\nimport type {\n CollectionSlug,\n DataFromGlobalSlug,\n GlobalSlug,\n TypedLocale,\n TypedUser,\n} from '../index.js'\nimport type { validOperators } from './constants.js'\nexport type { Payload as Payload } from '../index.js'\n\nexport type CustomPayloadRequestProperties = {\n context: RequestContext\n /** The locale that should be used for a field when it is not translated to the requested locale */\n fallbackLocale?: string\n i18n: I18n\n /**\n * The requested locale if specified\n * Only available for localized collections\n */\n locale?: TypedLocale\n /**\n * The payload object\n */\n payload: typeof payload\n /**\n * The context in which the request is being made\n */\n payloadAPI: 'GraphQL' | 'local' | 'REST'\n /** Optimized document loader */\n payloadDataLoader?: DataLoader<string, TypeWithID>\n /** Resized versions of the image that was uploaded during this request */\n payloadUploadSizes?: Record<string, Buffer>\n /** Query params on the request */\n query: Record<string, unknown>\n /** Any response headers that are required to be set when a response is sent */\n responseHeaders?: Headers\n /** The route parameters\n * @example\n * /:collection/:id -> /posts/123\n * { collection: 'posts', id: '123' }\n */\n routeParams?: Record<string, unknown>\n /** Translate function - duplicate of i18n.t */\n t: TFunction\n /**\n * Identifier for the database transaction for interactions in a single, all-or-nothing operation.\n * Can also be used to ensure consistency when multiple operations try to create a transaction concurrently on the same request.\n */\n transactionID?: number | Promise<number | string> | string\n /**\n * Used to ensure consistency when multiple operations try to create a transaction concurrently on the same request\n */\n transactionIDPromise?: Promise<void>\n /** The signed-in user */\n user: null | TypedUser\n} & Pick<\n URL,\n 'hash' | 'host' | 'href' | 'origin' | 'pathname' | 'port' | 'protocol' | 'search' | 'searchParams'\n>\ntype PayloadRequestData = {\n /**\n * Data from the request body\n *\n * Within Payload operations, i.e. hooks, data will be there\n * BUT in custom endpoints it will not be, you will need to\n * use either:\n * 1. `const data = await req.json()`\n *\n * 2. import { addDataAndFileToRequest } from '@payloadcms/next/utilities'\n * `await addDataAndFileToRequest(req)`\n * */\n data?: JsonObject\n /** The file on the request, same rules apply as the `data` property */\n file?: {\n data: Buffer\n mimetype: string\n name: string\n size: number\n tempFilePath?: string\n }\n}\nexport type PayloadRequest = CustomPayloadRequestProperties &\n Partial<Request> &\n PayloadRequestData &\n Required<Pick<Request, 'headers'>>\n\nexport interface RequestContext {\n [key: string]: unknown\n}\n\nexport type Operator = (typeof validOperators)[number]\n\n// Makes it so things like passing new Date() will error\nexport type JsonValue = JsonArray | JsonObject | unknown //Date | JsonArray | JsonObject | boolean | null | number | string // TODO: Evaluate proper, strong type for this\n\nexport type JsonArray = Array<JsonValue>\n\nexport interface JsonObject {\n [key: string]: any\n}\n\nexport type WhereField = {\n // any json-serializable value\n [key in Operator]?: JsonValue\n}\n\nexport type Where = {\n [key: string]: Where[] | WhereField\n and?: Where[]\n or?: Where[]\n}\n\nexport type Sort = Array<string> | string\n\n/**\n * Applies pagination for join fields for including collection relationships\n */\nexport type JoinQuery =\n | {\n [schemaPath: string]: {\n limit?: number\n sort?: string\n where?: Where\n }\n }\n | false\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type Document = any\n\nexport type Operation = 'create' | 'delete' | 'read' | 'update'\nexport type VersionOperations = 'readVersions'\nexport type AuthOperations = 'unlock'\nexport type AllOperations = AuthOperations | Operation | VersionOperations\n\nexport function docHasTimestamps(doc: any): doc is TypeWithTimestamps {\n return doc?.createdAt && doc?.updatedAt\n}\n\nexport type IfAny<T, Y, N> = 0 extends 1 & T ? Y : N // This is a commonly used trick to detect 'any'\nexport type IsAny<T> = IfAny<T, true, false>\nexport type ReplaceAny<T, DefaultType> = IsAny<T> extends true ? DefaultType : T\n\nexport type SelectIncludeType = {\n [k: string]: SelectIncludeType | true\n}\n\nexport type SelectExcludeType = {\n [k: string]: false | SelectExcludeType\n}\n\nexport type SelectMode = 'exclude' | 'include'\n\nexport type SelectType = SelectExcludeType | SelectIncludeType\n\nexport type ApplyDisableErrors<T, DisableErrors = false> = false extends DisableErrors\n ? T\n : null | T\n\nexport type TransformDataWithSelect<\n Data extends Record<string, any>,\n Select extends SelectType,\n> = Select extends never\n ? Data\n : string extends keyof Select\n ? Data\n : // START Handle types when they aren't generated\n // For example in any package in this repository outside of tests / plugins\n // This stil gives us autocomplete when using include select mode, i.e select: {title :true} returns type {title: any, id: string | number}\n string extends keyof Omit<Data, 'id'>\n ? Select extends SelectIncludeType\n ? {\n [K in Data extends TypeWithID ? 'id' | keyof Select : keyof Select]: K extends 'id'\n ? number | string\n : unknown\n }\n : Data\n : // END Handle types when they aren't generated\n // Handle include mode\n Select extends SelectIncludeType\n ? {\n [K in keyof Data as K extends keyof Select\n ? Select[K] extends object | true\n ? K\n : never\n : // select 'id' always\n K extends 'id'\n ? K\n : never]: Data[K]\n }\n : // Handle exclude mode\n {\n [K in keyof Data as K extends keyof Select\n ? Select[K] extends object | undefined\n ? K\n : never\n : K]: Data[K]\n }\n\nexport type TransformCollectionWithSelect<\n TSlug extends CollectionSlug,\n TSelect extends SelectType,\n> = TSelect extends SelectType\n ? TransformDataWithSelect<DataFromCollectionSlug<TSlug>, TSelect>\n : DataFromCollectionSlug<TSlug>\n\nexport type TransformGlobalWithSelect<\n TSlug extends GlobalSlug,\n TSelect extends SelectType,\n> = TSelect extends SelectType\n ? TransformDataWithSelect<DataFromGlobalSlug<TSlug>, TSelect>\n : DataFromGlobalSlug<TSlug>\n"],"names":["docHasTimestamps","doc","createdAt","updatedAt"],"mappings":"AAiJA,OAAO,SAASA,iBAAiBC,GAAQ;IACvC,OAAOA,KAAKC,aAAaD,KAAKE;AAChC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "payload",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.123",
|
|
4
4
|
"description": "Node, React, Headless CMS and Application Framework built on Next.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"admin panel",
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
"ts-essentials": "10.0.2",
|
|
97
97
|
"tsx": "4.19.1",
|
|
98
98
|
"uuid": "10.0.0",
|
|
99
|
-
"@payloadcms/translations": "3.0.0-beta.
|
|
99
|
+
"@payloadcms/translations": "3.0.0-beta.123"
|
|
100
100
|
},
|
|
101
101
|
"devDependencies": {
|
|
102
102
|
"@hyrious/esbuild-plugin-commonjs": "^0.2.4",
|