payload 3.0.0-beta.125 → 3.0.0-beta.127
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/RichText.d.ts +3 -1
- package/dist/admin/RichText.d.ts.map +1 -1
- package/dist/admin/RichText.js.map +1 -1
- package/dist/bin/index.js +1 -1
- package/dist/bin/index.js.map +1 -1
- package/dist/collections/operations/create.d.ts +2 -1
- package/dist/collections/operations/create.d.ts.map +1 -1
- package/dist/collections/operations/create.js +2 -10
- package/dist/collections/operations/create.js.map +1 -1
- package/dist/collections/operations/delete.d.ts +2 -1
- package/dist/collections/operations/delete.d.ts.map +1 -1
- package/dist/collections/operations/delete.js +2 -1
- package/dist/collections/operations/delete.js.map +1 -1
- package/dist/collections/operations/deleteByID.d.ts +2 -1
- package/dist/collections/operations/deleteByID.d.ts.map +1 -1
- package/dist/collections/operations/deleteByID.js +2 -1
- package/dist/collections/operations/deleteByID.js.map +1 -1
- package/dist/collections/operations/duplicate.d.ts +2 -1
- package/dist/collections/operations/duplicate.d.ts.map +1 -1
- package/dist/collections/operations/duplicate.js +2 -1
- package/dist/collections/operations/duplicate.js.map +1 -1
- package/dist/collections/operations/find.d.ts +2 -1
- package/dist/collections/operations/find.d.ts.map +1 -1
- package/dist/collections/operations/find.js +2 -1
- package/dist/collections/operations/find.js.map +1 -1
- package/dist/collections/operations/findByID.d.ts +2 -1
- package/dist/collections/operations/findByID.d.ts.map +1 -1
- package/dist/collections/operations/findByID.js +2 -1
- package/dist/collections/operations/findByID.js.map +1 -1
- package/dist/collections/operations/findVersionByID.d.ts +2 -1
- package/dist/collections/operations/findVersionByID.d.ts.map +1 -1
- package/dist/collections/operations/findVersionByID.js +2 -1
- package/dist/collections/operations/findVersionByID.js.map +1 -1
- package/dist/collections/operations/findVersions.d.ts +2 -1
- package/dist/collections/operations/findVersions.d.ts.map +1 -1
- package/dist/collections/operations/findVersions.js +2 -1
- package/dist/collections/operations/findVersions.js.map +1 -1
- package/dist/collections/operations/local/create.d.ts +2 -1
- package/dist/collections/operations/local/create.d.ts.map +1 -1
- package/dist/collections/operations/local/create.js +2 -1
- package/dist/collections/operations/local/create.js.map +1 -1
- package/dist/collections/operations/local/delete.d.ts +2 -1
- package/dist/collections/operations/local/delete.d.ts.map +1 -1
- package/dist/collections/operations/local/delete.js +2 -1
- package/dist/collections/operations/local/delete.js.map +1 -1
- package/dist/collections/operations/local/duplicate.d.ts +2 -1
- package/dist/collections/operations/local/duplicate.d.ts.map +1 -1
- package/dist/collections/operations/local/duplicate.js +2 -1
- package/dist/collections/operations/local/duplicate.js.map +1 -1
- package/dist/collections/operations/local/find.d.ts +3 -2
- package/dist/collections/operations/local/find.d.ts.map +1 -1
- package/dist/collections/operations/local/find.js +2 -2
- package/dist/collections/operations/local/find.js.map +1 -1
- package/dist/collections/operations/local/findByID.d.ts +3 -2
- package/dist/collections/operations/local/findByID.d.ts.map +1 -1
- package/dist/collections/operations/local/findByID.js +2 -1
- package/dist/collections/operations/local/findByID.js.map +1 -1
- package/dist/collections/operations/local/findVersionByID.d.ts +2 -1
- package/dist/collections/operations/local/findVersionByID.d.ts.map +1 -1
- package/dist/collections/operations/local/findVersionByID.js +2 -1
- package/dist/collections/operations/local/findVersionByID.js.map +1 -1
- package/dist/collections/operations/local/findVersions.d.ts +2 -1
- package/dist/collections/operations/local/findVersions.d.ts.map +1 -1
- package/dist/collections/operations/local/findVersions.js +2 -1
- package/dist/collections/operations/local/findVersions.js.map +1 -1
- package/dist/collections/operations/local/restoreVersion.d.ts +2 -1
- package/dist/collections/operations/local/restoreVersion.d.ts.map +1 -1
- package/dist/collections/operations/local/restoreVersion.js +2 -1
- package/dist/collections/operations/local/restoreVersion.js.map +1 -1
- package/dist/collections/operations/local/update.d.ts +2 -1
- package/dist/collections/operations/local/update.d.ts.map +1 -1
- package/dist/collections/operations/local/update.js +2 -1
- package/dist/collections/operations/local/update.js.map +1 -1
- package/dist/collections/operations/restoreVersion.d.ts +2 -1
- package/dist/collections/operations/restoreVersion.d.ts.map +1 -1
- package/dist/collections/operations/restoreVersion.js +2 -1
- package/dist/collections/operations/restoreVersion.js.map +1 -1
- package/dist/collections/operations/update.d.ts +2 -1
- package/dist/collections/operations/update.d.ts.map +1 -1
- package/dist/collections/operations/update.js +2 -1
- package/dist/collections/operations/update.js.map +1 -1
- package/dist/collections/operations/updateByID.d.ts +2 -1
- package/dist/collections/operations/updateByID.d.ts.map +1 -1
- package/dist/collections/operations/updateByID.js +8 -6
- package/dist/collections/operations/updateByID.js.map +1 -1
- package/dist/database/migrations/migrateRefresh.d.ts.map +1 -1
- package/dist/database/migrations/migrateRefresh.js +47 -47
- package/dist/database/migrations/migrateRefresh.js.map +1 -1
- package/dist/database/sanitizeJoinQuery.d.ts +3 -3
- package/dist/database/sanitizeJoinQuery.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/index.d.ts +2 -1
- package/dist/fields/hooks/afterRead/index.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/index.js +2 -1
- package/dist/fields/hooks/afterRead/index.js.map +1 -1
- package/dist/fields/hooks/afterRead/promise.d.ts +3 -2
- package/dist/fields/hooks/afterRead/promise.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/promise.js +12 -1
- package/dist/fields/hooks/afterRead/promise.js.map +1 -1
- package/dist/fields/hooks/afterRead/relationshipPopulationPromise.d.ts +3 -2
- package/dist/fields/hooks/afterRead/relationshipPopulationPromise.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/relationshipPopulationPromise.js +7 -3
- package/dist/fields/hooks/afterRead/relationshipPopulationPromise.js.map +1 -1
- package/dist/fields/hooks/afterRead/traverseFields.d.ts +3 -2
- package/dist/fields/hooks/afterRead/traverseFields.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/traverseFields.js +2 -1
- package/dist/fields/hooks/afterRead/traverseFields.js.map +1 -1
- package/dist/globals/operations/findOne.d.ts +2 -1
- package/dist/globals/operations/findOne.d.ts.map +1 -1
- package/dist/globals/operations/findOne.js +2 -1
- package/dist/globals/operations/findOne.js.map +1 -1
- package/dist/globals/operations/findVersionByID.d.ts +2 -1
- package/dist/globals/operations/findVersionByID.d.ts.map +1 -1
- package/dist/globals/operations/findVersionByID.js +2 -1
- package/dist/globals/operations/findVersionByID.js.map +1 -1
- package/dist/globals/operations/findVersions.d.ts +2 -1
- package/dist/globals/operations/findVersions.d.ts.map +1 -1
- package/dist/globals/operations/findVersions.js +2 -1
- package/dist/globals/operations/findVersions.js.map +1 -1
- package/dist/globals/operations/local/findOne.d.ts +2 -1
- package/dist/globals/operations/local/findOne.d.ts.map +1 -1
- package/dist/globals/operations/local/findOne.js +2 -1
- package/dist/globals/operations/local/findOne.js.map +1 -1
- package/dist/globals/operations/local/findVersionByID.d.ts +2 -1
- package/dist/globals/operations/local/findVersionByID.d.ts.map +1 -1
- package/dist/globals/operations/local/findVersionByID.js +2 -1
- package/dist/globals/operations/local/findVersionByID.js.map +1 -1
- package/dist/globals/operations/local/findVersions.d.ts +2 -1
- package/dist/globals/operations/local/findVersions.d.ts.map +1 -1
- package/dist/globals/operations/local/findVersions.js +2 -1
- package/dist/globals/operations/local/findVersions.js.map +1 -1
- package/dist/globals/operations/local/restoreVersion.d.ts +2 -1
- package/dist/globals/operations/local/restoreVersion.d.ts.map +1 -1
- package/dist/globals/operations/local/restoreVersion.js +2 -1
- package/dist/globals/operations/local/restoreVersion.js.map +1 -1
- package/dist/globals/operations/local/update.d.ts +2 -1
- package/dist/globals/operations/local/update.d.ts.map +1 -1
- package/dist/globals/operations/local/update.js +2 -1
- package/dist/globals/operations/local/update.js.map +1 -1
- package/dist/globals/operations/restoreVersion.d.ts +2 -1
- package/dist/globals/operations/restoreVersion.d.ts.map +1 -1
- package/dist/globals/operations/restoreVersion.js +2 -1
- package/dist/globals/operations/restoreVersion.js.map +1 -1
- package/dist/globals/operations/update.d.ts +2 -1
- package/dist/globals/operations/update.d.ts.map +1 -1
- package/dist/globals/operations/update.js +2 -1
- package/dist/globals/operations/update.js.map +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/queues/config/jobsCollection.d.ts.map +1 -1
- package/dist/queues/config/jobsCollection.js +15 -13
- package/dist/queues/config/jobsCollection.js.map +1 -1
- package/dist/queues/config/types/index.d.ts +1 -1
- package/dist/queues/config/types/index.d.ts.map +1 -1
- package/dist/queues/config/types/index.js.map +1 -1
- package/dist/queues/operations/runJobs/index.js +1 -1
- package/dist/queues/operations/runJobs/index.js.map +1 -1
- package/dist/types/index.d.ts +5 -4
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/utilities/configToJSONSchema.d.ts.map +1 -1
- package/dist/utilities/configToJSONSchema.js +35 -0
- package/dist/utilities/configToJSONSchema.js.map +1 -1
- package/package.json +10 -10
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PaginatedDocs } from '../../database/types.js';
|
|
2
|
-
import type { PayloadRequest, SelectType, Sort, Where } from '../../types/index.js';
|
|
2
|
+
import type { PayloadRequest, PopulateType, SelectType, Sort, Where } from '../../types/index.js';
|
|
3
3
|
import type { TypeWithVersion } from '../../versions/types.js';
|
|
4
4
|
import type { SanitizedGlobalConfig } from '../config/types.js';
|
|
5
5
|
export type Arguments = {
|
|
@@ -9,6 +9,7 @@ export type Arguments = {
|
|
|
9
9
|
overrideAccess?: boolean;
|
|
10
10
|
page?: number;
|
|
11
11
|
pagination?: boolean;
|
|
12
|
+
populate?: PopulateType;
|
|
12
13
|
req?: PayloadRequest;
|
|
13
14
|
select?: SelectType;
|
|
14
15
|
showHiddenFields?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findVersions.d.ts","sourceRoot":"","sources":["../../../src/globals/operations/findVersions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"findVersions.d.ts","sourceRoot":"","sources":["../../../src/globals/operations/findVersions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AACjG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAU/D,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,YAAY,EAAE,qBAAqB,CAAA;IACnC,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,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,qBAAqB,GAAU,CAAC,SAAS,eAAe,CAAC,CAAC,CAAC,QAChE,SAAS,KACd,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAoI1B,CAAA"}
|
|
@@ -6,7 +6,7 @@ import { killTransaction } from '../../utilities/killTransaction.js';
|
|
|
6
6
|
import sanitizeInternalFields from '../../utilities/sanitizeInternalFields.js';
|
|
7
7
|
import { buildVersionGlobalFields } from '../../versions/buildGlobalFields.js';
|
|
8
8
|
export const findVersionsOperation = async (args)=>{
|
|
9
|
-
const { depth, globalConfig, limit, overrideAccess, page, pagination = true, req: { fallbackLocale, locale, payload }, req, select, showHiddenFields, sort, where } = args;
|
|
9
|
+
const { depth, globalConfig, limit, overrideAccess, page, pagination = true, populate, req: { fallbackLocale, locale, payload }, req, select, showHiddenFields, sort, where } = args;
|
|
10
10
|
const versionFields = buildVersionGlobalFields(payload.config, globalConfig);
|
|
11
11
|
try {
|
|
12
12
|
// /////////////////////////////////////
|
|
@@ -60,6 +60,7 @@ export const findVersionsOperation = async (args)=>{
|
|
|
60
60
|
global: globalConfig,
|
|
61
61
|
locale,
|
|
62
62
|
overrideAccess,
|
|
63
|
+
populate,
|
|
63
64
|
req,
|
|
64
65
|
select,
|
|
65
66
|
showHiddenFields
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/globals/operations/findVersions.ts"],"sourcesContent":["import type { PaginatedDocs } from '../../database/types.js'\nimport type { PayloadRequest, SelectType, Sort, Where } from '../../types/index.js'\nimport type { TypeWithVersion } from '../../versions/types.js'\nimport type { SanitizedGlobalConfig } 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 sanitizeInternalFields from '../../utilities/sanitizeInternalFields.js'\nimport { buildVersionGlobalFields } from '../../versions/buildGlobalFields.js'\n\nexport type Arguments = {\n depth?: number\n globalConfig: SanitizedGlobalConfig\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 findVersionsOperation = async <T extends TypeWithVersion<T>>(\n args: Arguments,\n): Promise<PaginatedDocs<T>> => {\n const {\n depth,\n globalConfig,\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 const versionFields = buildVersionGlobalFields(payload.config, globalConfig)\n\n try {\n // /////////////////////////////////////\n // Access\n // /////////////////////////////////////\n\n const accessResults = !overrideAccess\n ? await executeAccess({ req }, globalConfig.access.readVersions)\n : true\n\n await validateQueryPaths({\n globalConfig,\n overrideAccess,\n req,\n versionFields,\n where,\n })\n\n const fullWhere = combineQueries(where, accessResults)\n\n // /////////////////////////////////////\n // Find\n // /////////////////////////////////////\n\n const paginatedDocs = await payload.db.findGlobalVersions<T>({\n global: globalConfig.slug,\n limit: limit ?? 10,\n locale,\n page: page || 1,\n pagination,\n req,\n select,\n sort,\n where: fullWhere,\n })\n\n // /////////////////////////////////////\n // afterRead - Fields\n // /////////////////////////////////////\n\n let result = {\n ...paginatedDocs,\n docs: await Promise.all(\n paginatedDocs.docs.map(async (data) => {\n return {\n ...data,\n version: await afterRead<T>({\n collection: null,\n context: req.context,\n depth,\n doc: {\n ...data.version,\n // Patch globalType onto version doc\n globalType: globalConfig.slug,\n },\n draft: undefined,\n fallbackLocale,\n findMany: true,\n global: globalConfig,\n locale,\n overrideAccess,\n req,\n select,\n showHiddenFields,\n }),\n }\n }),\n ),\n } as PaginatedDocs<T>\n\n // /////////////////////////////////////\n // afterRead - Global\n // /////////////////////////////////////\n\n result = {\n ...result,\n docs: await Promise.all(\n result.docs.map(async (doc) => {\n const docRef = doc\n\n await globalConfig.hooks.afterRead.reduce(async (priorHook, hook) => {\n await priorHook\n\n docRef.version =\n (await hook({\n context: req.context,\n doc: doc.version,\n findMany: true,\n global: globalConfig,\n query: fullWhere,\n req,\n })) || doc.version\n }, Promise.resolve())\n\n return docRef\n }),\n ),\n }\n\n // /////////////////////////////////////\n // Return results\n // /////////////////////////////////////\n\n result = {\n ...result,\n docs: result.docs.map((doc) => sanitizeInternalFields<T>(doc)),\n }\n\n return result\n } catch (error: unknown) {\n await killTransaction(req)\n throw error\n }\n}\n"],"names":["executeAccess","combineQueries","validateQueryPaths","afterRead","killTransaction","sanitizeInternalFields","buildVersionGlobalFields","findVersionsOperation","args","depth","globalConfig","limit","overrideAccess","page","pagination","req","fallbackLocale","locale","payload","select","showHiddenFields","sort","where","versionFields","config","accessResults","access","readVersions","fullWhere","paginatedDocs","db","findGlobalVersions","global","slug","result","docs","Promise","all","map","data","version","collection","context","doc","globalType","draft","undefined","findMany","docRef","hooks","reduce","priorHook","hook","query","resolve","error"],"mappings":"AAKA,OAAOA,mBAAmB,8BAA6B;AACvD,SAASC,cAAc,QAAQ,mCAAkC;AACjE,SAASC,kBAAkB,QAAQ,uDAAsD;AACzF,SAASC,SAAS,QAAQ,wCAAuC;AACjE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,OAAOC,4BAA4B,4CAA2C;AAC9E,SAASC,wBAAwB,QAAQ,sCAAqC;
|
|
1
|
+
{"version":3,"sources":["../../../src/globals/operations/findVersions.ts"],"sourcesContent":["import type { PaginatedDocs } from '../../database/types.js'\nimport type { PayloadRequest, PopulateType, SelectType, Sort, Where } from '../../types/index.js'\nimport type { TypeWithVersion } from '../../versions/types.js'\nimport type { SanitizedGlobalConfig } 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 sanitizeInternalFields from '../../utilities/sanitizeInternalFields.js'\nimport { buildVersionGlobalFields } from '../../versions/buildGlobalFields.js'\n\nexport type Arguments = {\n depth?: number\n globalConfig: SanitizedGlobalConfig\n limit?: number\n overrideAccess?: boolean\n page?: number\n pagination?: boolean\n populate?: PopulateType\n req?: PayloadRequest\n select?: SelectType\n showHiddenFields?: boolean\n sort?: Sort\n where?: Where\n}\n\nexport const findVersionsOperation = async <T extends TypeWithVersion<T>>(\n args: Arguments,\n): Promise<PaginatedDocs<T>> => {\n const {\n depth,\n globalConfig,\n limit,\n overrideAccess,\n page,\n pagination = true,\n populate,\n req: { fallbackLocale, locale, payload },\n req,\n select,\n showHiddenFields,\n sort,\n where,\n } = args\n\n const versionFields = buildVersionGlobalFields(payload.config, globalConfig)\n\n try {\n // /////////////////////////////////////\n // Access\n // /////////////////////////////////////\n\n const accessResults = !overrideAccess\n ? await executeAccess({ req }, globalConfig.access.readVersions)\n : true\n\n await validateQueryPaths({\n globalConfig,\n overrideAccess,\n req,\n versionFields,\n where,\n })\n\n const fullWhere = combineQueries(where, accessResults)\n\n // /////////////////////////////////////\n // Find\n // /////////////////////////////////////\n\n const paginatedDocs = await payload.db.findGlobalVersions<T>({\n global: globalConfig.slug,\n limit: limit ?? 10,\n locale,\n page: page || 1,\n pagination,\n req,\n select,\n sort,\n where: fullWhere,\n })\n\n // /////////////////////////////////////\n // afterRead - Fields\n // /////////////////////////////////////\n\n let result = {\n ...paginatedDocs,\n docs: await Promise.all(\n paginatedDocs.docs.map(async (data) => {\n return {\n ...data,\n version: await afterRead<T>({\n collection: null,\n context: req.context,\n depth,\n doc: {\n ...data.version,\n // Patch globalType onto version doc\n globalType: globalConfig.slug,\n },\n draft: undefined,\n fallbackLocale,\n findMany: true,\n global: globalConfig,\n locale,\n overrideAccess,\n populate,\n req,\n select,\n showHiddenFields,\n }),\n }\n }),\n ),\n } as PaginatedDocs<T>\n\n // /////////////////////////////////////\n // afterRead - Global\n // /////////////////////////////////////\n\n result = {\n ...result,\n docs: await Promise.all(\n result.docs.map(async (doc) => {\n const docRef = doc\n\n await globalConfig.hooks.afterRead.reduce(async (priorHook, hook) => {\n await priorHook\n\n docRef.version =\n (await hook({\n context: req.context,\n doc: doc.version,\n findMany: true,\n global: globalConfig,\n query: fullWhere,\n req,\n })) || doc.version\n }, Promise.resolve())\n\n return docRef\n }),\n ),\n }\n\n // /////////////////////////////////////\n // Return results\n // /////////////////////////////////////\n\n result = {\n ...result,\n docs: result.docs.map((doc) => sanitizeInternalFields<T>(doc)),\n }\n\n return result\n } catch (error: unknown) {\n await killTransaction(req)\n throw error\n }\n}\n"],"names":["executeAccess","combineQueries","validateQueryPaths","afterRead","killTransaction","sanitizeInternalFields","buildVersionGlobalFields","findVersionsOperation","args","depth","globalConfig","limit","overrideAccess","page","pagination","populate","req","fallbackLocale","locale","payload","select","showHiddenFields","sort","where","versionFields","config","accessResults","access","readVersions","fullWhere","paginatedDocs","db","findGlobalVersions","global","slug","result","docs","Promise","all","map","data","version","collection","context","doc","globalType","draft","undefined","findMany","docRef","hooks","reduce","priorHook","hook","query","resolve","error"],"mappings":"AAKA,OAAOA,mBAAmB,8BAA6B;AACvD,SAASC,cAAc,QAAQ,mCAAkC;AACjE,SAASC,kBAAkB,QAAQ,uDAAsD;AACzF,SAASC,SAAS,QAAQ,wCAAuC;AACjE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,OAAOC,4BAA4B,4CAA2C;AAC9E,SAASC,wBAAwB,QAAQ,sCAAqC;AAiB9E,OAAO,MAAMC,wBAAwB,OACnCC;IAEA,MAAM,EACJC,KAAK,EACLC,YAAY,EACZC,KAAK,EACLC,cAAc,EACdC,IAAI,EACJC,aAAa,IAAI,EACjBC,QAAQ,EACRC,KAAK,EAAEC,cAAc,EAAEC,MAAM,EAAEC,OAAO,EAAE,EACxCH,GAAG,EACHI,MAAM,EACNC,gBAAgB,EAChBC,IAAI,EACJC,KAAK,EACN,GAAGf;IAEJ,MAAMgB,gBAAgBlB,yBAAyBa,QAAQM,MAAM,EAAEf;IAE/D,IAAI;QACF,wCAAwC;QACxC,SAAS;QACT,wCAAwC;QAExC,MAAMgB,gBAAgB,CAACd,iBACnB,MAAMZ,cAAc;YAAEgB;QAAI,GAAGN,aAAaiB,MAAM,CAACC,YAAY,IAC7D;QAEJ,MAAM1B,mBAAmB;YACvBQ;YACAE;YACAI;YACAQ;YACAD;QACF;QAEA,MAAMM,YAAY5B,eAAesB,OAAOG;QAExC,wCAAwC;QACxC,OAAO;QAC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wCAAwC;QAExCd,SAAS;YACP,GAAGA,MAAM;YACTC,MAAMD,OAAOC,IAAI,CAACG,GAAG,CAAC,CAACK,MAAQvC,uBAA0BuC;QAC3D;QAEA,OAAOT;IACT,EAAE,OAAOqB,OAAgB;QACvB,MAAMpD,gBAAgBY;QACtB,MAAMwC;IACR;AACF,EAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { GlobalSlug, Payload, RequestContext, TypedLocale } from '../../../index.js';
|
|
2
|
-
import type { Document, PayloadRequest, SelectType, TransformGlobalWithSelect } from '../../../types/index.js';
|
|
2
|
+
import type { Document, PayloadRequest, PopulateType, SelectType, TransformGlobalWithSelect } from '../../../types/index.js';
|
|
3
3
|
import type { SelectFromGlobalSlug } from '../../config/types.js';
|
|
4
4
|
export type Options<TSlug extends GlobalSlug, TSelect extends SelectType> = {
|
|
5
5
|
context?: RequestContext;
|
|
@@ -9,6 +9,7 @@ export type Options<TSlug extends GlobalSlug, TSelect extends SelectType> = {
|
|
|
9
9
|
includeLockStatus?: boolean;
|
|
10
10
|
locale?: 'all' | TypedLocale;
|
|
11
11
|
overrideAccess?: boolean;
|
|
12
|
+
populate?: PopulateType;
|
|
12
13
|
req?: PayloadRequest;
|
|
13
14
|
select?: TSelect;
|
|
14
15
|
showHiddenFields?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findOne.d.ts","sourceRoot":"","sources":["../../../../src/globals/operations/local/findOne.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACzF,OAAO,KAAK,EACV,QAAQ,EACR,cAAc,EACd,UAAU,EACV,yBAAyB,EAC1B,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAMjE,MAAM,MAAM,OAAO,CAAC,KAAK,SAAS,UAAU,EAAE,OAAO,S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AAO,CAAA;IACf,cAAc,CAAC,EAAE,WAAW,CAAA;IAC5B,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,MAAM,CAAC,EAAE,KAAK,GAAG,WAAW,CAAA;IAC5B,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,GAAG,CAAC,EAAE,cAAc,CAAA;IACpB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,IAAI,EAAE,KAAK,CAAA;IACX,IAAI,CAAC,EAAE,QAAQ,CAAA;CAChB,CAAA;AAED,wBAA8B,YAAY,CACxC,KAAK,SAAS,UAAU,EACxB,OAAO,SAAS,oBAAoB,CAAC,KAAK,CAAC,EAE3C,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,GAC/B,OAAO,CAAC,yBAAyB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CA8BpD"}
|
|
@@ -2,7 +2,7 @@ import { APIError } from '../../../errors/index.js';
|
|
|
2
2
|
import { createLocalReq } from '../../../utilities/createLocalReq.js';
|
|
3
3
|
import { findOneOperation } from '../findOne.js';
|
|
4
4
|
export default async function findOneLocal(payload, options) {
|
|
5
|
-
const { slug: globalSlug, depth, draft = false, includeLockStatus, overrideAccess = true, select, showHiddenFields } = options;
|
|
5
|
+
const { slug: globalSlug, depth, draft = false, includeLockStatus, overrideAccess = true, populate, select, showHiddenFields } = options;
|
|
6
6
|
const globalConfig = payload.globals.config.find((config)=>config.slug === globalSlug);
|
|
7
7
|
if (!globalConfig) {
|
|
8
8
|
throw new APIError(`The global with slug ${String(globalSlug)} can't be found.`);
|
|
@@ -14,6 +14,7 @@ export default async function findOneLocal(payload, options) {
|
|
|
14
14
|
globalConfig,
|
|
15
15
|
includeLockStatus,
|
|
16
16
|
overrideAccess,
|
|
17
|
+
populate,
|
|
17
18
|
req: await createLocalReq(options, payload),
|
|
18
19
|
select,
|
|
19
20
|
showHiddenFields
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/globals/operations/local/findOne.ts"],"sourcesContent":["import type { GlobalSlug, Payload, RequestContext, TypedLocale } from '../../../index.js'\nimport type {\n Document,\n PayloadRequest,\n SelectType,\n TransformGlobalWithSelect,\n} from '../../../types/index.js'\nimport type { SelectFromGlobalSlug } from '../../config/types.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { findOneOperation } from '../findOne.js'\n\nexport type Options<TSlug extends GlobalSlug, TSelect extends SelectType> = {\n context?: RequestContext\n depth?: number\n draft?: boolean\n fallbackLocale?: TypedLocale\n includeLockStatus?: boolean\n locale?: 'all' | TypedLocale\n overrideAccess?: boolean\n req?: PayloadRequest\n select?: TSelect\n showHiddenFields?: boolean\n slug: TSlug\n user?: Document\n}\n\nexport default async function findOneLocal<\n TSlug extends GlobalSlug,\n TSelect extends SelectFromGlobalSlug<TSlug>,\n>(\n payload: Payload,\n options: Options<TSlug, TSelect>,\n): Promise<TransformGlobalWithSelect<TSlug, TSelect>> {\n const {\n slug: globalSlug,\n depth,\n draft = false,\n includeLockStatus,\n overrideAccess = true,\n select,\n showHiddenFields,\n } = options\n\n const globalConfig = payload.globals.config.find((config) => config.slug === globalSlug)\n\n if (!globalConfig) {\n throw new APIError(`The global with slug ${String(globalSlug)} can't be found.`)\n }\n\n return findOneOperation({\n slug: globalSlug as string,\n depth,\n draft,\n globalConfig,\n includeLockStatus,\n overrideAccess,\n req: await createLocalReq(options, payload),\n select,\n showHiddenFields,\n })\n}\n"],"names":["APIError","createLocalReq","findOneOperation","findOneLocal","payload","options","slug","globalSlug","depth","draft","includeLockStatus","overrideAccess","select","showHiddenFields","globalConfig","globals","config","find","String","req"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/globals/operations/local/findOne.ts"],"sourcesContent":["import type { GlobalSlug, Payload, RequestContext, TypedLocale } from '../../../index.js'\nimport type {\n Document,\n PayloadRequest,\n PopulateType,\n SelectType,\n TransformGlobalWithSelect,\n} from '../../../types/index.js'\nimport type { SelectFromGlobalSlug } from '../../config/types.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { findOneOperation } from '../findOne.js'\n\nexport type Options<TSlug extends GlobalSlug, TSelect extends SelectType> = {\n context?: RequestContext\n depth?: number\n draft?: boolean\n fallbackLocale?: TypedLocale\n includeLockStatus?: boolean\n locale?: 'all' | TypedLocale\n overrideAccess?: boolean\n populate?: PopulateType\n req?: PayloadRequest\n select?: TSelect\n showHiddenFields?: boolean\n slug: TSlug\n user?: Document\n}\n\nexport default async function findOneLocal<\n TSlug extends GlobalSlug,\n TSelect extends SelectFromGlobalSlug<TSlug>,\n>(\n payload: Payload,\n options: Options<TSlug, TSelect>,\n): Promise<TransformGlobalWithSelect<TSlug, TSelect>> {\n const {\n slug: globalSlug,\n depth,\n draft = false,\n includeLockStatus,\n overrideAccess = true,\n populate,\n select,\n showHiddenFields,\n } = options\n\n const globalConfig = payload.globals.config.find((config) => config.slug === globalSlug)\n\n if (!globalConfig) {\n throw new APIError(`The global with slug ${String(globalSlug)} can't be found.`)\n }\n\n return findOneOperation({\n slug: globalSlug as string,\n depth,\n draft,\n globalConfig,\n includeLockStatus,\n overrideAccess,\n populate,\n req: await createLocalReq(options, payload),\n select,\n showHiddenFields,\n })\n}\n"],"names":["APIError","createLocalReq","findOneOperation","findOneLocal","payload","options","slug","globalSlug","depth","draft","includeLockStatus","overrideAccess","populate","select","showHiddenFields","globalConfig","globals","config","find","String","req"],"mappings":"AAUA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,gBAAgB,QAAQ,gBAAe;AAkBhD,eAAe,eAAeC,aAI5BC,OAAgB,EAChBC,OAAgC;IAEhC,MAAM,EACJC,MAAMC,UAAU,EAChBC,KAAK,EACLC,QAAQ,KAAK,EACbC,iBAAiB,EACjBC,iBAAiB,IAAI,EACrBC,QAAQ,EACRC,MAAM,EACNC,gBAAgB,EACjB,GAAGT;IAEJ,MAAMU,eAAeX,QAAQY,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC,CAACD,SAAWA,OAAOX,IAAI,KAAKC;IAE7E,IAAI,CAACQ,cAAc;QACjB,MAAM,IAAIf,SAAS,CAAC,qBAAqB,EAAEmB,OAAOZ,YAAY,gBAAgB,CAAC;IACjF;IAEA,OAAOL,iBAAiB;QACtBI,MAAMC;QACNC;QACAC;QACAM;QACAL;QACAC;QACAC;QACAQ,KAAK,MAAMnB,eAAeI,SAASD;QACnCS;QACAC;IACF;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { GlobalSlug, Payload, RequestContext, TypedLocale } from '../../../index.js';
|
|
2
|
-
import type { Document, PayloadRequest, SelectType } from '../../../types/index.js';
|
|
2
|
+
import type { Document, PayloadRequest, PopulateType, SelectType } from '../../../types/index.js';
|
|
3
3
|
import type { TypeWithVersion } from '../../../versions/types.js';
|
|
4
4
|
import type { DataFromGlobalSlug } from '../../config/types.js';
|
|
5
5
|
export type Options<TSlug extends GlobalSlug> = {
|
|
@@ -10,6 +10,7 @@ export type Options<TSlug extends GlobalSlug> = {
|
|
|
10
10
|
id: string;
|
|
11
11
|
locale?: 'all' | TypedLocale;
|
|
12
12
|
overrideAccess?: boolean;
|
|
13
|
+
populate?: PopulateType;
|
|
13
14
|
req?: PayloadRequest;
|
|
14
15
|
select?: SelectType;
|
|
15
16
|
showHiddenFields?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findVersionByID.d.ts","sourceRoot":"","sources":["../../../../src/globals/operations/local/findVersionByID.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACzF,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@@ import { createLocalReq } from '../../../utilities/createLocalReq.js';
|
|
|
3
3
|
import { findVersionByIDOperation } from '../findVersionByID.js';
|
|
4
4
|
// eslint-disable-next-line no-restricted-exports
|
|
5
5
|
export default async function findVersionByIDLocal(payload, options) {
|
|
6
|
-
const { id, slug: globalSlug, depth, disableErrors = false, overrideAccess = true, select, showHiddenFields } = options;
|
|
6
|
+
const { id, slug: globalSlug, depth, disableErrors = false, overrideAccess = true, populate, select, showHiddenFields } = options;
|
|
7
7
|
const globalConfig = payload.globals.config.find((config)=>config.slug === globalSlug);
|
|
8
8
|
if (!globalConfig) {
|
|
9
9
|
throw new APIError(`The global with slug ${String(globalSlug)} can't be found.`);
|
|
@@ -14,6 +14,7 @@ export default async function findVersionByIDLocal(payload, options) {
|
|
|
14
14
|
disableErrors,
|
|
15
15
|
globalConfig,
|
|
16
16
|
overrideAccess,
|
|
17
|
+
populate,
|
|
17
18
|
req: await createLocalReq(options, payload),
|
|
18
19
|
select,
|
|
19
20
|
showHiddenFields
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/globals/operations/local/findVersionByID.ts"],"sourcesContent":["import type { GlobalSlug, Payload, RequestContext, TypedLocale } from '../../../index.js'\nimport type { Document, PayloadRequest, SelectType } from '../../../types/index.js'\nimport type { TypeWithVersion } from '../../../versions/types.js'\nimport type { DataFromGlobalSlug } from '../../config/types.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { findVersionByIDOperation } from '../findVersionByID.js'\n\nexport type Options<TSlug extends GlobalSlug> = {\n context?: RequestContext\n depth?: number\n disableErrors?: boolean\n fallbackLocale?: TypedLocale\n id: string\n locale?: 'all' | TypedLocale\n overrideAccess?: boolean\n req?: PayloadRequest\n select?: SelectType\n showHiddenFields?: boolean\n slug: TSlug\n user?: Document\n}\n\n// eslint-disable-next-line no-restricted-exports\nexport default async function findVersionByIDLocal<TSlug extends GlobalSlug>(\n payload: Payload,\n options: Options<TSlug>,\n): Promise<TypeWithVersion<DataFromGlobalSlug<TSlug>>> {\n const {\n id,\n slug: globalSlug,\n depth,\n disableErrors = false,\n overrideAccess = true,\n select,\n showHiddenFields,\n } = options\n\n const globalConfig = payload.globals.config.find((config) => config.slug === globalSlug)\n\n if (!globalConfig) {\n throw new APIError(`The global with slug ${String(globalSlug)} can't be found.`)\n }\n\n return findVersionByIDOperation({\n id,\n depth,\n disableErrors,\n globalConfig,\n overrideAccess,\n req: await createLocalReq(options, payload),\n select,\n showHiddenFields,\n })\n}\n"],"names":["APIError","createLocalReq","findVersionByIDOperation","findVersionByIDLocal","payload","options","id","slug","globalSlug","depth","disableErrors","overrideAccess","select","showHiddenFields","globalConfig","globals","config","find","String","req"],"mappings":"AAKA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,wBAAwB,QAAQ,wBAAuB;
|
|
1
|
+
{"version":3,"sources":["../../../../src/globals/operations/local/findVersionByID.ts"],"sourcesContent":["import type { GlobalSlug, Payload, RequestContext, TypedLocale } from '../../../index.js'\nimport type { Document, PayloadRequest, PopulateType, SelectType } from '../../../types/index.js'\nimport type { TypeWithVersion } from '../../../versions/types.js'\nimport type { DataFromGlobalSlug } from '../../config/types.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { findVersionByIDOperation } from '../findVersionByID.js'\n\nexport type Options<TSlug extends GlobalSlug> = {\n context?: RequestContext\n depth?: number\n disableErrors?: boolean\n fallbackLocale?: TypedLocale\n id: string\n locale?: 'all' | TypedLocale\n overrideAccess?: boolean\n populate?: PopulateType\n req?: PayloadRequest\n select?: SelectType\n showHiddenFields?: boolean\n slug: TSlug\n user?: Document\n}\n\n// eslint-disable-next-line no-restricted-exports\nexport default async function findVersionByIDLocal<TSlug extends GlobalSlug>(\n payload: Payload,\n options: Options<TSlug>,\n): Promise<TypeWithVersion<DataFromGlobalSlug<TSlug>>> {\n const {\n id,\n slug: globalSlug,\n depth,\n disableErrors = false,\n overrideAccess = true,\n populate,\n select,\n showHiddenFields,\n } = options\n\n const globalConfig = payload.globals.config.find((config) => config.slug === globalSlug)\n\n if (!globalConfig) {\n throw new APIError(`The global with slug ${String(globalSlug)} can't be found.`)\n }\n\n return findVersionByIDOperation({\n id,\n depth,\n disableErrors,\n globalConfig,\n overrideAccess,\n populate,\n req: await createLocalReq(options, payload),\n select,\n showHiddenFields,\n })\n}\n"],"names":["APIError","createLocalReq","findVersionByIDOperation","findVersionByIDLocal","payload","options","id","slug","globalSlug","depth","disableErrors","overrideAccess","populate","select","showHiddenFields","globalConfig","globals","config","find","String","req"],"mappings":"AAKA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,wBAAwB,QAAQ,wBAAuB;AAkBhE,iDAAiD;AACjD,eAAe,eAAeC,qBAC5BC,OAAgB,EAChBC,OAAuB;IAEvB,MAAM,EACJC,EAAE,EACFC,MAAMC,UAAU,EAChBC,KAAK,EACLC,gBAAgB,KAAK,EACrBC,iBAAiB,IAAI,EACrBC,QAAQ,EACRC,MAAM,EACNC,gBAAgB,EACjB,GAAGT;IAEJ,MAAMU,eAAeX,QAAQY,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC,CAACD,SAAWA,OAAOV,IAAI,KAAKC;IAE7E,IAAI,CAACO,cAAc;QACjB,MAAM,IAAIf,SAAS,CAAC,qBAAqB,EAAEmB,OAAOX,YAAY,gBAAgB,CAAC;IACjF;IAEA,OAAON,yBAAyB;QAC9BI;QACAG;QACAC;QACAK;QACAJ;QACAC;QACAQ,KAAK,MAAMnB,eAAeI,SAASD;QACnCS;QACAC;IACF;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PaginatedDocs } from '../../../database/types.js';
|
|
2
2
|
import type { GlobalSlug, Payload, RequestContext, TypedLocale } from '../../../index.js';
|
|
3
|
-
import type { Document, PayloadRequest, SelectType, Sort, Where } from '../../../types/index.js';
|
|
3
|
+
import type { Document, PayloadRequest, PopulateType, SelectType, Sort, Where } from '../../../types/index.js';
|
|
4
4
|
import type { TypeWithVersion } from '../../../versions/types.js';
|
|
5
5
|
import type { DataFromGlobalSlug } from '../../config/types.js';
|
|
6
6
|
export type Options<TSlug extends GlobalSlug> = {
|
|
@@ -11,6 +11,7 @@ export type Options<TSlug extends GlobalSlug> = {
|
|
|
11
11
|
locale?: 'all' | TypedLocale;
|
|
12
12
|
overrideAccess?: boolean;
|
|
13
13
|
page?: number;
|
|
14
|
+
populate?: PopulateType;
|
|
14
15
|
req?: PayloadRequest;
|
|
15
16
|
select?: SelectType;
|
|
16
17
|
showHiddenFields?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findVersions.d.ts","sourceRoot":"","sources":["../../../../src/globals/operations/local/findVersions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC/D,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACzF,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"findVersions.d.ts","sourceRoot":"","sources":["../../../../src/globals/operations/local/findVersions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC/D,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACzF,OAAO,KAAK,EACV,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,UAAU,EACV,IAAI,EACJ,KAAK,EACN,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AACjE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAM/D,MAAM,MAAM,OAAO,CAAC,KAAK,SAAS,UAAU,IAAI;IAC9C,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,cAAc,CAAC,EAAE,WAAW,CAAA;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,KAAK,GAAG,WAAW,CAAA;IAC5B,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,GAAG,CAAC,EAAE,cAAc,CAAA;IACpB,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,IAAI,EAAE,KAAK,CAAA;IACX,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,IAAI,CAAC,EAAE,QAAQ,CAAA;IACf,KAAK,CAAC,EAAE,KAAK,CAAA;CACd,CAAA;AAED,wBAA8B,iBAAiB,CAAC,KAAK,SAAS,UAAU,EACtE,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,GACtB,OAAO,CAAC,aAAa,CAAC,eAAe,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAiCpE"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { createLocalReq } from '../../../utilities/createLocalReq.js';
|
|
3
3
|
import { findVersionsOperation } from '../findVersions.js';
|
|
4
4
|
export default async function findVersionsLocal(payload, options) {
|
|
5
|
-
const { slug: globalSlug, depth, limit, overrideAccess = true, page, select, showHiddenFields, sort, where } = options;
|
|
5
|
+
const { slug: globalSlug, depth, limit, overrideAccess = true, page, populate, select, showHiddenFields, sort, where } = options;
|
|
6
6
|
const globalConfig = payload.globals.config.find((config)=>config.slug === globalSlug);
|
|
7
7
|
if (!globalConfig) {
|
|
8
8
|
throw new APIError(`The global with slug ${String(globalSlug)} can't be found.`);
|
|
@@ -13,6 +13,7 @@ export default async function findVersionsLocal(payload, options) {
|
|
|
13
13
|
limit,
|
|
14
14
|
overrideAccess,
|
|
15
15
|
page,
|
|
16
|
+
populate,
|
|
16
17
|
req: await createLocalReq(options, payload),
|
|
17
18
|
select,
|
|
18
19
|
showHiddenFields,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/globals/operations/local/findVersions.ts"],"sourcesContent":["/* eslint-disable no-restricted-exports */\nimport type { PaginatedDocs } from '../../../database/types.js'\nimport type { GlobalSlug, Payload, RequestContext, TypedLocale } from '../../../index.js'\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../../../src/globals/operations/local/findVersions.ts"],"sourcesContent":["/* eslint-disable no-restricted-exports */\nimport type { PaginatedDocs } from '../../../database/types.js'\nimport type { GlobalSlug, Payload, RequestContext, TypedLocale } from '../../../index.js'\nimport type {\n Document,\n PayloadRequest,\n PopulateType,\n SelectType,\n Sort,\n Where,\n} from '../../../types/index.js'\nimport type { TypeWithVersion } from '../../../versions/types.js'\nimport type { DataFromGlobalSlug } from '../../config/types.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { findVersionsOperation } from '../findVersions.js'\n\nexport type Options<TSlug extends GlobalSlug> = {\n context?: RequestContext\n depth?: number\n fallbackLocale?: TypedLocale\n limit?: number\n locale?: 'all' | TypedLocale\n overrideAccess?: boolean\n page?: number\n populate?: PopulateType\n req?: PayloadRequest\n select?: SelectType\n showHiddenFields?: boolean\n slug: TSlug\n sort?: Sort\n user?: Document\n where?: Where\n}\n\nexport default async function findVersionsLocal<TSlug extends GlobalSlug>(\n payload: Payload,\n options: Options<TSlug>,\n): Promise<PaginatedDocs<TypeWithVersion<DataFromGlobalSlug<TSlug>>>> {\n const {\n slug: globalSlug,\n depth,\n limit,\n overrideAccess = true,\n page,\n populate,\n select,\n showHiddenFields,\n sort,\n where,\n } = options\n\n const globalConfig = payload.globals.config.find((config) => config.slug === globalSlug)\n\n if (!globalConfig) {\n throw new APIError(`The global with slug ${String(globalSlug)} can't be found.`)\n }\n\n return findVersionsOperation({\n depth,\n globalConfig,\n limit,\n overrideAccess,\n page,\n populate,\n req: await createLocalReq(options, payload),\n select,\n showHiddenFields,\n sort,\n where,\n })\n}\n"],"names":["APIError","createLocalReq","findVersionsOperation","findVersionsLocal","payload","options","slug","globalSlug","depth","limit","overrideAccess","page","populate","select","showHiddenFields","sort","where","globalConfig","globals","config","find","String","req"],"mappings":"AAAA,wCAAwC,GAcxC,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,qBAAqB,QAAQ,qBAAoB;AAoB1D,eAAe,eAAeC,kBAC5BC,OAAgB,EAChBC,OAAuB;IAEvB,MAAM,EACJC,MAAMC,UAAU,EAChBC,KAAK,EACLC,KAAK,EACLC,iBAAiB,IAAI,EACrBC,IAAI,EACJC,QAAQ,EACRC,MAAM,EACNC,gBAAgB,EAChBC,IAAI,EACJC,KAAK,EACN,GAAGX;IAEJ,MAAMY,eAAeb,QAAQc,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC,CAACD,SAAWA,OAAOb,IAAI,KAAKC;IAE7E,IAAI,CAACU,cAAc;QACjB,MAAM,IAAIjB,SAAS,CAAC,qBAAqB,EAAEqB,OAAOd,YAAY,gBAAgB,CAAC;IACjF;IAEA,OAAOL,sBAAsB;QAC3BM;QACAS;QACAR;QACAC;QACAC;QACAC;QACAU,KAAK,MAAMrB,eAAeI,SAASD;QACnCS;QACAC;QACAC;QACAC;IACF;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { GlobalSlug, Payload, RequestContext, TypedLocale } from '../../../index.js';
|
|
2
|
-
import type { Document, PayloadRequest } from '../../../types/index.js';
|
|
2
|
+
import type { Document, PayloadRequest, PopulateType } from '../../../types/index.js';
|
|
3
3
|
import type { DataFromGlobalSlug } from '../../config/types.js';
|
|
4
4
|
export type Options<TSlug extends GlobalSlug> = {
|
|
5
5
|
context?: RequestContext;
|
|
@@ -8,6 +8,7 @@ export type Options<TSlug extends GlobalSlug> = {
|
|
|
8
8
|
id: string;
|
|
9
9
|
locale?: TypedLocale;
|
|
10
10
|
overrideAccess?: boolean;
|
|
11
|
+
populate?: PopulateType;
|
|
11
12
|
req?: PayloadRequest;
|
|
12
13
|
showHiddenFields?: boolean;
|
|
13
14
|
slug: TSlug;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"restoreVersion.d.ts","sourceRoot":"","sources":["../../../../src/globals/operations/local/restoreVersion.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACzF,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;
|
|
1
|
+
{"version":3,"file":"restoreVersion.d.ts","sourceRoot":"","sources":["../../../../src/globals/operations/local/restoreVersion.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACzF,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AACrF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAM/D,MAAM,MAAM,OAAO,CAAC,KAAK,SAAS,UAAU,IAAI;IAC9C,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,cAAc,CAAC,EAAE,WAAW,CAAA;IAC5B,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,GAAG,CAAC,EAAE,cAAc,CAAA;IACpB,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,IAAI,EAAE,KAAK,CAAA;IACX,IAAI,CAAC,EAAE,QAAQ,CAAA;CAChB,CAAA;AAED,wBAA8B,mBAAmB,CAAC,KAAK,SAAS,UAAU,EACxE,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,GACtB,OAAO,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAkBpC"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { createLocalReq } from '../../../utilities/createLocalReq.js';
|
|
3
3
|
import { restoreVersionOperation } from '../restoreVersion.js';
|
|
4
4
|
export default async function restoreVersionLocal(payload, options) {
|
|
5
|
-
const { id, slug: globalSlug, depth, overrideAccess = true, showHiddenFields } = options;
|
|
5
|
+
const { id, slug: globalSlug, depth, overrideAccess = true, populate, showHiddenFields } = options;
|
|
6
6
|
const globalConfig = payload.globals.config.find((config)=>config.slug === globalSlug);
|
|
7
7
|
if (!globalConfig) {
|
|
8
8
|
throw new APIError(`The global with slug ${String(globalSlug)} can't be found.`);
|
|
@@ -12,6 +12,7 @@ export default async function restoreVersionLocal(payload, options) {
|
|
|
12
12
|
depth,
|
|
13
13
|
globalConfig,
|
|
14
14
|
overrideAccess,
|
|
15
|
+
populate,
|
|
15
16
|
req: await createLocalReq(options, payload),
|
|
16
17
|
showHiddenFields
|
|
17
18
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/globals/operations/local/restoreVersion.ts"],"sourcesContent":["/* eslint-disable no-restricted-exports */\nimport type { GlobalSlug, Payload, RequestContext, TypedLocale } from '../../../index.js'\nimport type { Document, PayloadRequest } from '../../../types/index.js'\nimport type { DataFromGlobalSlug } from '../../config/types.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { restoreVersionOperation } from '../restoreVersion.js'\n\nexport type Options<TSlug extends GlobalSlug> = {\n context?: RequestContext\n depth?: number\n fallbackLocale?: TypedLocale\n id: string\n locale?: TypedLocale\n overrideAccess?: boolean\n req?: PayloadRequest\n showHiddenFields?: boolean\n slug: TSlug\n user?: Document\n}\n\nexport default async function restoreVersionLocal<TSlug extends GlobalSlug>(\n payload: Payload,\n options: Options<TSlug>,\n): Promise<DataFromGlobalSlug<TSlug>> {\n const { id, slug: globalSlug, depth, overrideAccess = true, showHiddenFields } = options\n\n const globalConfig = payload.globals.config.find((config) => config.slug === globalSlug)\n\n if (!globalConfig) {\n throw new APIError(`The global with slug ${String(globalSlug)} can't be found.`)\n }\n\n return restoreVersionOperation({\n id,\n depth,\n globalConfig,\n overrideAccess,\n req: await createLocalReq(options, payload),\n showHiddenFields,\n })\n}\n"],"names":["APIError","createLocalReq","restoreVersionOperation","restoreVersionLocal","payload","options","id","slug","globalSlug","depth","overrideAccess","showHiddenFields","globalConfig","globals","config","find","String","req"],"mappings":"AAAA,wCAAwC,GAKxC,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,uBAAuB,QAAQ,uBAAsB;
|
|
1
|
+
{"version":3,"sources":["../../../../src/globals/operations/local/restoreVersion.ts"],"sourcesContent":["/* eslint-disable no-restricted-exports */\nimport type { GlobalSlug, Payload, RequestContext, TypedLocale } from '../../../index.js'\nimport type { Document, PayloadRequest, PopulateType } from '../../../types/index.js'\nimport type { DataFromGlobalSlug } from '../../config/types.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { restoreVersionOperation } from '../restoreVersion.js'\n\nexport type Options<TSlug extends GlobalSlug> = {\n context?: RequestContext\n depth?: number\n fallbackLocale?: TypedLocale\n id: string\n locale?: TypedLocale\n overrideAccess?: boolean\n populate?: PopulateType\n req?: PayloadRequest\n showHiddenFields?: boolean\n slug: TSlug\n user?: Document\n}\n\nexport default async function restoreVersionLocal<TSlug extends GlobalSlug>(\n payload: Payload,\n options: Options<TSlug>,\n): Promise<DataFromGlobalSlug<TSlug>> {\n const { id, slug: globalSlug, depth, overrideAccess = true, populate, showHiddenFields } = options\n\n const globalConfig = payload.globals.config.find((config) => config.slug === globalSlug)\n\n if (!globalConfig) {\n throw new APIError(`The global with slug ${String(globalSlug)} can't be found.`)\n }\n\n return restoreVersionOperation({\n id,\n depth,\n globalConfig,\n overrideAccess,\n populate,\n req: await createLocalReq(options, payload),\n showHiddenFields,\n })\n}\n"],"names":["APIError","createLocalReq","restoreVersionOperation","restoreVersionLocal","payload","options","id","slug","globalSlug","depth","overrideAccess","populate","showHiddenFields","globalConfig","globals","config","find","String","req"],"mappings":"AAAA,wCAAwC,GAKxC,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,uBAAuB,QAAQ,uBAAsB;AAgB9D,eAAe,eAAeC,oBAC5BC,OAAgB,EAChBC,OAAuB;IAEvB,MAAM,EAAEC,EAAE,EAAEC,MAAMC,UAAU,EAAEC,KAAK,EAAEC,iBAAiB,IAAI,EAAEC,QAAQ,EAAEC,gBAAgB,EAAE,GAAGP;IAE3F,MAAMQ,eAAeT,QAAQU,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC,CAACD,SAAWA,OAAOR,IAAI,KAAKC;IAE7E,IAAI,CAACK,cAAc;QACjB,MAAM,IAAIb,SAAS,CAAC,qBAAqB,EAAEiB,OAAOT,YAAY,gBAAgB,CAAC;IACjF;IAEA,OAAON,wBAAwB;QAC7BI;QACAG;QACAI;QACAH;QACAC;QACAO,KAAK,MAAMjB,eAAeI,SAASD;QACnCQ;IACF;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { DeepPartial } from 'ts-essentials';
|
|
2
2
|
import type { GlobalSlug, Payload, RequestContext, TypedLocale } from '../../../index.js';
|
|
3
|
-
import type { Document, PayloadRequest, SelectType, TransformGlobalWithSelect } from '../../../types/index.js';
|
|
3
|
+
import type { Document, PayloadRequest, PopulateType, SelectType, TransformGlobalWithSelect } from '../../../types/index.js';
|
|
4
4
|
import type { DataFromGlobalSlug, SelectFromGlobalSlug } from '../../config/types.js';
|
|
5
5
|
export type Options<TSlug extends GlobalSlug, TSelect extends SelectType> = {
|
|
6
6
|
context?: RequestContext;
|
|
@@ -11,6 +11,7 @@ export type Options<TSlug extends GlobalSlug, TSelect extends SelectType> = {
|
|
|
11
11
|
locale?: TypedLocale;
|
|
12
12
|
overrideAccess?: boolean;
|
|
13
13
|
overrideLock?: boolean;
|
|
14
|
+
populate?: PopulateType;
|
|
14
15
|
publishSpecificLocale?: TypedLocale;
|
|
15
16
|
req?: PayloadRequest;
|
|
16
17
|
select?: TSelect;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../src/globals/operations/local/update.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAEhD,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACzF,OAAO,KAAK,EACV,QAAQ,EACR,cAAc,EACd,UAAU,EACV,yBAAyB,EAC1B,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAMrF,MAAM,MAAM,OAAO,CAAC,KAAK,SAAS,UAAU,EAAE,OAAO,SAAS,UAAU,IAAI;IAC1E,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,CAAC,CAAA;IACxD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,cAAc,CAAC,EAAE,WAAW,CAAA;IAC5B,MAAM,CAAC,EAAE,WAAW,CAAA;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ACf,cAAc,CAAC,EAAE,WAAW,CAAA;IAC5B,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,qBAAqB,CAAC,EAAE,WAAW,CAAA;IACnC,GAAG,CAAC,EAAE,cAAc,CAAA;IACpB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,IAAI,EAAE,KAAK,CAAA;IACX,IAAI,CAAC,EAAE,QAAQ,CAAA;CAChB,CAAA;AAED,wBAA8B,WAAW,CACvC,KAAK,SAAS,UAAU,EACxB,OAAO,SAAS,oBAAoB,CAAC,KAAK,CAAC,EAE3C,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,GAC/B,OAAO,CAAC,yBAAyB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAkCpD"}
|
|
@@ -2,7 +2,7 @@ import { APIError } from '../../../errors/index.js';
|
|
|
2
2
|
import { createLocalReq } from '../../../utilities/createLocalReq.js';
|
|
3
3
|
import { updateOperation } from '../update.js';
|
|
4
4
|
export default async function updateLocal(payload, options) {
|
|
5
|
-
const { slug: globalSlug, data, depth, draft, overrideAccess = true, overrideLock, publishSpecificLocale, select, showHiddenFields } = options;
|
|
5
|
+
const { slug: globalSlug, data, depth, draft, overrideAccess = true, overrideLock, populate, publishSpecificLocale, select, showHiddenFields } = options;
|
|
6
6
|
const globalConfig = payload.globals.config.find((config)=>config.slug === globalSlug);
|
|
7
7
|
if (!globalConfig) {
|
|
8
8
|
throw new APIError(`The global with slug ${String(globalSlug)} can't be found.`);
|
|
@@ -15,6 +15,7 @@ export default async function updateLocal(payload, options) {
|
|
|
15
15
|
globalConfig,
|
|
16
16
|
overrideAccess,
|
|
17
17
|
overrideLock,
|
|
18
|
+
populate,
|
|
18
19
|
publishSpecificLocale,
|
|
19
20
|
req: await createLocalReq(options, payload),
|
|
20
21
|
select,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/globals/operations/local/update.ts"],"sourcesContent":["import type { DeepPartial } from 'ts-essentials'\n\nimport type { GlobalSlug, Payload, RequestContext, TypedLocale } from '../../../index.js'\nimport type {\n Document,\n PayloadRequest,\n SelectType,\n TransformGlobalWithSelect,\n} from '../../../types/index.js'\nimport type { DataFromGlobalSlug, SelectFromGlobalSlug } from '../../config/types.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { updateOperation } from '../update.js'\n\nexport type Options<TSlug extends GlobalSlug, TSelect extends SelectType> = {\n context?: RequestContext\n data: DeepPartial<Omit<DataFromGlobalSlug<TSlug>, 'id'>>\n depth?: number\n draft?: boolean\n fallbackLocale?: TypedLocale\n locale?: TypedLocale\n overrideAccess?: boolean\n overrideLock?: boolean\n publishSpecificLocale?: TypedLocale\n req?: PayloadRequest\n select?: TSelect\n showHiddenFields?: boolean\n slug: TSlug\n user?: Document\n}\n\nexport default async function updateLocal<\n TSlug extends GlobalSlug,\n TSelect extends SelectFromGlobalSlug<TSlug>,\n>(\n payload: Payload,\n options: Options<TSlug, TSelect>,\n): Promise<TransformGlobalWithSelect<TSlug, TSelect>> {\n const {\n slug: globalSlug,\n data,\n depth,\n draft,\n overrideAccess = true,\n overrideLock,\n publishSpecificLocale,\n select,\n showHiddenFields,\n } = options\n\n const globalConfig = payload.globals.config.find((config) => config.slug === globalSlug)\n\n if (!globalConfig) {\n throw new APIError(`The global with slug ${String(globalSlug)} can't be found.`)\n }\n\n return updateOperation<TSlug, TSelect>({\n slug: globalSlug as string,\n data,\n depth,\n draft,\n globalConfig,\n overrideAccess,\n overrideLock,\n publishSpecificLocale,\n req: await createLocalReq(options, payload),\n select,\n showHiddenFields,\n })\n}\n"],"names":["APIError","createLocalReq","updateOperation","updateLocal","payload","options","slug","globalSlug","data","depth","draft","overrideAccess","overrideLock","publishSpecificLocale","select","showHiddenFields","globalConfig","globals","config","find","String","req"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/globals/operations/local/update.ts"],"sourcesContent":["import type { DeepPartial } from 'ts-essentials'\n\nimport type { GlobalSlug, Payload, RequestContext, TypedLocale } from '../../../index.js'\nimport type {\n Document,\n PayloadRequest,\n PopulateType,\n SelectType,\n TransformGlobalWithSelect,\n} from '../../../types/index.js'\nimport type { DataFromGlobalSlug, SelectFromGlobalSlug } from '../../config/types.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { updateOperation } from '../update.js'\n\nexport type Options<TSlug extends GlobalSlug, TSelect extends SelectType> = {\n context?: RequestContext\n data: DeepPartial<Omit<DataFromGlobalSlug<TSlug>, 'id'>>\n depth?: number\n draft?: boolean\n fallbackLocale?: TypedLocale\n locale?: TypedLocale\n overrideAccess?: boolean\n overrideLock?: boolean\n populate?: PopulateType\n publishSpecificLocale?: TypedLocale\n req?: PayloadRequest\n select?: TSelect\n showHiddenFields?: boolean\n slug: TSlug\n user?: Document\n}\n\nexport default async function updateLocal<\n TSlug extends GlobalSlug,\n TSelect extends SelectFromGlobalSlug<TSlug>,\n>(\n payload: Payload,\n options: Options<TSlug, TSelect>,\n): Promise<TransformGlobalWithSelect<TSlug, TSelect>> {\n const {\n slug: globalSlug,\n data,\n depth,\n draft,\n overrideAccess = true,\n overrideLock,\n populate,\n publishSpecificLocale,\n select,\n showHiddenFields,\n } = options\n\n const globalConfig = payload.globals.config.find((config) => config.slug === globalSlug)\n\n if (!globalConfig) {\n throw new APIError(`The global with slug ${String(globalSlug)} can't be found.`)\n }\n\n return updateOperation<TSlug, TSelect>({\n slug: globalSlug as string,\n data,\n depth,\n draft,\n globalConfig,\n overrideAccess,\n overrideLock,\n populate,\n publishSpecificLocale,\n req: await createLocalReq(options, payload),\n select,\n showHiddenFields,\n })\n}\n"],"names":["APIError","createLocalReq","updateOperation","updateLocal","payload","options","slug","globalSlug","data","depth","draft","overrideAccess","overrideLock","populate","publishSpecificLocale","select","showHiddenFields","globalConfig","globals","config","find","String","req"],"mappings":"AAYA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,eAAe,QAAQ,eAAc;AAoB9C,eAAe,eAAeC,YAI5BC,OAAgB,EAChBC,OAAgC;IAEhC,MAAM,EACJC,MAAMC,UAAU,EAChBC,IAAI,EACJC,KAAK,EACLC,KAAK,EACLC,iBAAiB,IAAI,EACrBC,YAAY,EACZC,QAAQ,EACRC,qBAAqB,EACrBC,MAAM,EACNC,gBAAgB,EACjB,GAAGX;IAEJ,MAAMY,eAAeb,QAAQc,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC,CAACD,SAAWA,OAAOb,IAAI,KAAKC;IAE7E,IAAI,CAACU,cAAc;QACjB,MAAM,IAAIjB,SAAS,CAAC,qBAAqB,EAAEqB,OAAOd,YAAY,gBAAgB,CAAC;IACjF;IAEA,OAAOL,gBAAgC;QACrCI,MAAMC;QACNC;QACAC;QACAC;QACAO;QACAN;QACAC;QACAC;QACAC;QACAQ,KAAK,MAAMrB,eAAeI,SAASD;QACnCW;QACAC;IACF;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PayloadRequest } from '../../types/index.js';
|
|
1
|
+
import type { PayloadRequest, PopulateType } from '../../types/index.js';
|
|
2
2
|
import type { TypeWithVersion } from '../../versions/types.js';
|
|
3
3
|
import type { SanitizedGlobalConfig } from '../config/types.js';
|
|
4
4
|
export type Arguments = {
|
|
@@ -7,6 +7,7 @@ export type Arguments = {
|
|
|
7
7
|
globalConfig: SanitizedGlobalConfig;
|
|
8
8
|
id: number | string;
|
|
9
9
|
overrideAccess?: boolean;
|
|
10
|
+
populate?: PopulateType;
|
|
10
11
|
req?: PayloadRequest;
|
|
11
12
|
showHiddenFields?: boolean;
|
|
12
13
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"restoreVersion.d.ts","sourceRoot":"","sources":["../../../src/globals/operations/restoreVersion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"restoreVersion.d.ts","sourceRoot":"","sources":["../../../src/globals/operations/restoreVersion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACxE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAU/D,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,YAAY,EAAE,qBAAqB,CAAA;IACnC,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;IACnB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,GAAG,CAAC,EAAE,cAAc,CAAA;IACpB,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAC3B,CAAA;AAED,eAAO,MAAM,uBAAuB,GAAU,CAAC,SAAS,eAAe,CAAC,CAAC,CAAC,cAClE,SAAS,KACd,OAAO,CAAC,CAAC,CA4KX,CAAA"}
|
|
@@ -6,7 +6,7 @@ import { commitTransaction } from '../../utilities/commitTransaction.js';
|
|
|
6
6
|
import { initTransaction } from '../../utilities/initTransaction.js';
|
|
7
7
|
import { killTransaction } from '../../utilities/killTransaction.js';
|
|
8
8
|
export const restoreVersionOperation = async (args)=>{
|
|
9
|
-
const { id, depth, draft, globalConfig, overrideAccess, req: { fallbackLocale, locale, payload }, req, showHiddenFields } = args;
|
|
9
|
+
const { id, depth, draft, globalConfig, overrideAccess, populate, req: { fallbackLocale, locale, payload }, req, showHiddenFields } = args;
|
|
10
10
|
try {
|
|
11
11
|
const shouldCommit = await initTransaction(req);
|
|
12
12
|
// /////////////////////////////////////
|
|
@@ -92,6 +92,7 @@ export const restoreVersionOperation = async (args)=>{
|
|
|
92
92
|
global: globalConfig,
|
|
93
93
|
locale,
|
|
94
94
|
overrideAccess,
|
|
95
|
+
populate,
|
|
95
96
|
req,
|
|
96
97
|
showHiddenFields
|
|
97
98
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/globals/operations/restoreVersion.ts"],"sourcesContent":["import type { PayloadRequest } from '../../types/index.js'\nimport type { TypeWithVersion } from '../../versions/types.js'\nimport type { SanitizedGlobalConfig } from '../config/types.js'\n\nimport executeAccess from '../../auth/executeAccess.js'\nimport { NotFound } from '../../errors/index.js'\nimport { afterChange } from '../../fields/hooks/afterChange/index.js'\nimport { afterRead } from '../../fields/hooks/afterRead/index.js'\nimport { commitTransaction } from '../../utilities/commitTransaction.js'\nimport { initTransaction } from '../../utilities/initTransaction.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\n\nexport type Arguments = {\n depth?: number\n draft?: boolean\n globalConfig: SanitizedGlobalConfig\n id: number | string\n overrideAccess?: boolean\n req?: PayloadRequest\n showHiddenFields?: boolean\n}\n\nexport const restoreVersionOperation = async <T extends TypeWithVersion<T> = any>(\n args: Arguments,\n): Promise<T> => {\n const {\n id,\n depth,\n draft,\n globalConfig,\n overrideAccess,\n req: { fallbackLocale, locale, payload },\n req,\n showHiddenFields,\n } = args\n\n try {\n const shouldCommit = await initTransaction(req)\n\n // /////////////////////////////////////\n // Access\n // /////////////////////////////////////\n\n if (!overrideAccess) {\n await executeAccess({ req }, globalConfig.access.update)\n }\n\n // /////////////////////////////////////\n // Retrieve original raw version\n // /////////////////////////////////////\n\n const { docs: versionDocs } = await payload.db.findGlobalVersions<any>({\n global: globalConfig.slug,\n limit: 1,\n req,\n where: { id: { equals: id } },\n })\n\n if (!versionDocs || versionDocs.length === 0) {\n throw new NotFound(req.t)\n }\n\n const rawVersion = versionDocs[0]\n\n // Patch globalType onto version doc\n rawVersion.version.globalType = globalConfig.slug\n\n // Overwrite draft status if draft is true\n\n if (draft) {\n rawVersion.version._status = 'draft'\n }\n // /////////////////////////////////////\n // fetch previousDoc\n // /////////////////////////////////////\n\n const previousDoc = await payload.findGlobal({\n slug: globalConfig.slug,\n depth,\n req,\n })\n\n // /////////////////////////////////////\n // Update global\n // /////////////////////////////////////\n\n const global = await payload.db.findGlobal({\n slug: globalConfig.slug,\n req,\n })\n\n let result = rawVersion.version\n\n if (global) {\n result = await payload.db.updateGlobal({\n slug: globalConfig.slug,\n data: result,\n req,\n })\n\n const now = new Date().toISOString()\n\n result = await payload.db.createGlobalVersion({\n autosave: false,\n createdAt: result.createdAt ? new Date(result.createdAt).toISOString() : now,\n globalSlug: globalConfig.slug,\n parent: id,\n req,\n updatedAt: draft ? now : new Date(result.updatedAt).toISOString(),\n versionData: result,\n })\n } else {\n result = await payload.db.createGlobal({\n slug: globalConfig.slug,\n data: result,\n req,\n })\n }\n\n // /////////////////////////////////////\n // afterRead - Fields\n // /////////////////////////////////////\n\n result = await afterRead({\n collection: null,\n context: req.context,\n depth,\n doc: result,\n draft: undefined,\n fallbackLocale,\n global: globalConfig,\n locale,\n overrideAccess,\n req,\n showHiddenFields,\n })\n\n // /////////////////////////////////////\n // afterRead - Global\n // /////////////////////////////////////\n\n await globalConfig.hooks.afterRead.reduce(async (priorHook, hook) => {\n await priorHook\n\n result =\n (await hook({\n context: req.context,\n doc: result,\n global: globalConfig,\n req,\n })) || result\n }, Promise.resolve())\n\n // /////////////////////////////////////\n // afterChange - Fields\n // /////////////////////////////////////\n\n result = await afterChange({\n collection: null,\n context: req.context,\n data: result,\n doc: result,\n global: globalConfig,\n operation: 'update',\n previousDoc,\n req,\n })\n\n // /////////////////////////////////////\n // afterChange - Global\n // /////////////////////////////////////\n\n await globalConfig.hooks.afterChange.reduce(async (priorHook, hook) => {\n await priorHook\n\n result =\n (await hook({\n context: req.context,\n doc: result,\n global: globalConfig,\n previousDoc,\n req,\n })) || result\n }, Promise.resolve())\n\n if (shouldCommit) {\n await commitTransaction(req)\n }\n\n return result\n } catch (error: unknown) {\n await killTransaction(req)\n throw error\n }\n}\n"],"names":["executeAccess","NotFound","afterChange","afterRead","commitTransaction","initTransaction","killTransaction","restoreVersionOperation","args","id","depth","draft","globalConfig","overrideAccess","req","fallbackLocale","locale","payload","showHiddenFields","shouldCommit","access","update","docs","versionDocs","db","findGlobalVersions","global","slug","limit","where","equals","length","t","rawVersion","version","globalType","_status","previousDoc","findGlobal","result","updateGlobal","data","now","Date","toISOString","createGlobalVersion","autosave","createdAt","globalSlug","parent","updatedAt","versionData","createGlobal","collection","context","doc","undefined","hooks","reduce","priorHook","hook","Promise","resolve","operation","error"],"mappings":"AAIA,OAAOA,mBAAmB,8BAA6B;AACvD,SAASC,QAAQ,QAAQ,wBAAuB;AAChD,SAASC,WAAW,QAAQ,0CAAyC;AACrE,SAASC,SAAS,QAAQ,wCAAuC;AACjE,SAASC,iBAAiB,QAAQ,uCAAsC;AACxE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,eAAe,QAAQ,qCAAoC;
|
|
1
|
+
{"version":3,"sources":["../../../src/globals/operations/restoreVersion.ts"],"sourcesContent":["import type { PayloadRequest, PopulateType } from '../../types/index.js'\nimport type { TypeWithVersion } from '../../versions/types.js'\nimport type { SanitizedGlobalConfig } from '../config/types.js'\n\nimport executeAccess from '../../auth/executeAccess.js'\nimport { NotFound } from '../../errors/index.js'\nimport { afterChange } from '../../fields/hooks/afterChange/index.js'\nimport { afterRead } from '../../fields/hooks/afterRead/index.js'\nimport { commitTransaction } from '../../utilities/commitTransaction.js'\nimport { initTransaction } from '../../utilities/initTransaction.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\n\nexport type Arguments = {\n depth?: number\n draft?: boolean\n globalConfig: SanitizedGlobalConfig\n id: number | string\n overrideAccess?: boolean\n populate?: PopulateType\n req?: PayloadRequest\n showHiddenFields?: boolean\n}\n\nexport const restoreVersionOperation = async <T extends TypeWithVersion<T> = any>(\n args: Arguments,\n): Promise<T> => {\n const {\n id,\n depth,\n draft,\n globalConfig,\n overrideAccess,\n populate,\n req: { fallbackLocale, locale, payload },\n req,\n showHiddenFields,\n } = args\n\n try {\n const shouldCommit = await initTransaction(req)\n\n // /////////////////////////////////////\n // Access\n // /////////////////////////////////////\n\n if (!overrideAccess) {\n await executeAccess({ req }, globalConfig.access.update)\n }\n\n // /////////////////////////////////////\n // Retrieve original raw version\n // /////////////////////////////////////\n\n const { docs: versionDocs } = await payload.db.findGlobalVersions<any>({\n global: globalConfig.slug,\n limit: 1,\n req,\n where: { id: { equals: id } },\n })\n\n if (!versionDocs || versionDocs.length === 0) {\n throw new NotFound(req.t)\n }\n\n const rawVersion = versionDocs[0]\n\n // Patch globalType onto version doc\n rawVersion.version.globalType = globalConfig.slug\n\n // Overwrite draft status if draft is true\n\n if (draft) {\n rawVersion.version._status = 'draft'\n }\n // /////////////////////////////////////\n // fetch previousDoc\n // /////////////////////////////////////\n\n const previousDoc = await payload.findGlobal({\n slug: globalConfig.slug,\n depth,\n req,\n })\n\n // /////////////////////////////////////\n // Update global\n // /////////////////////////////////////\n\n const global = await payload.db.findGlobal({\n slug: globalConfig.slug,\n req,\n })\n\n let result = rawVersion.version\n\n if (global) {\n result = await payload.db.updateGlobal({\n slug: globalConfig.slug,\n data: result,\n req,\n })\n\n const now = new Date().toISOString()\n\n result = await payload.db.createGlobalVersion({\n autosave: false,\n createdAt: result.createdAt ? new Date(result.createdAt).toISOString() : now,\n globalSlug: globalConfig.slug,\n parent: id,\n req,\n updatedAt: draft ? now : new Date(result.updatedAt).toISOString(),\n versionData: result,\n })\n } else {\n result = await payload.db.createGlobal({\n slug: globalConfig.slug,\n data: result,\n req,\n })\n }\n\n // /////////////////////////////////////\n // afterRead - Fields\n // /////////////////////////////////////\n\n result = await afterRead({\n collection: null,\n context: req.context,\n depth,\n doc: result,\n draft: undefined,\n fallbackLocale,\n global: globalConfig,\n locale,\n overrideAccess,\n populate,\n req,\n showHiddenFields,\n })\n\n // /////////////////////////////////////\n // afterRead - Global\n // /////////////////////////////////////\n\n await globalConfig.hooks.afterRead.reduce(async (priorHook, hook) => {\n await priorHook\n\n result =\n (await hook({\n context: req.context,\n doc: result,\n global: globalConfig,\n req,\n })) || result\n }, Promise.resolve())\n\n // /////////////////////////////////////\n // afterChange - Fields\n // /////////////////////////////////////\n\n result = await afterChange({\n collection: null,\n context: req.context,\n data: result,\n doc: result,\n global: globalConfig,\n operation: 'update',\n previousDoc,\n req,\n })\n\n // /////////////////////////////////////\n // afterChange - Global\n // /////////////////////////////////////\n\n await globalConfig.hooks.afterChange.reduce(async (priorHook, hook) => {\n await priorHook\n\n result =\n (await hook({\n context: req.context,\n doc: result,\n global: globalConfig,\n previousDoc,\n req,\n })) || result\n }, Promise.resolve())\n\n if (shouldCommit) {\n await commitTransaction(req)\n }\n\n return result\n } catch (error: unknown) {\n await killTransaction(req)\n throw error\n }\n}\n"],"names":["executeAccess","NotFound","afterChange","afterRead","commitTransaction","initTransaction","killTransaction","restoreVersionOperation","args","id","depth","draft","globalConfig","overrideAccess","populate","req","fallbackLocale","locale","payload","showHiddenFields","shouldCommit","access","update","docs","versionDocs","db","findGlobalVersions","global","slug","limit","where","equals","length","t","rawVersion","version","globalType","_status","previousDoc","findGlobal","result","updateGlobal","data","now","Date","toISOString","createGlobalVersion","autosave","createdAt","globalSlug","parent","updatedAt","versionData","createGlobal","collection","context","doc","undefined","hooks","reduce","priorHook","hook","Promise","resolve","operation","error"],"mappings":"AAIA,OAAOA,mBAAmB,8BAA6B;AACvD,SAASC,QAAQ,QAAQ,wBAAuB;AAChD,SAASC,WAAW,QAAQ,0CAAyC;AACrE,SAASC,SAAS,QAAQ,wCAAuC;AACjE,SAASC,iBAAiB,QAAQ,uCAAsC;AACxE,SAASC,eAAe,QAAQ,q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Y;YACzBoD,YAAY;YACZC,SAASxC,IAAIwC,OAAO;YACpBb,MAAMF;YACNgB,KAAKhB;YACLb,QAAQf;YACRoD,WAAW;YACX1B;YACAvB;QACF;QAEA,wCAAwC;QACxC,uBAAuB;QACvB,wCAAwC;QAExC,MAAMH,aAAa8C,KAAK,CAACxD,WAAW,CAACyD,MAAM,CAAC,OAAOC,WAAWC;YAC5D,MAAMD;YAENpB,SACE,AAAC,MAAMqB,KAAK;gBACVN,SAASxC,IAAIwC,OAAO;gBACpBC,KAAKhB;gBACLb,QAAQf;gBACR0B;gBACAvB;YACF,MAAOyB;QACX,GAAGsB,QAAQC,OAAO;QAElB,IAAI3C,cAAc;YAChB,MAAMhB,kBAAkBW;QAC1B;QAEA,OAAOyB;IACT,EAAE,OAAOyB,OAAgB;QACvB,MAAM3D,gBAAgBS;QACtB,MAAMkD;IACR;AACF,EAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { DeepPartial } from 'ts-essentials';
|
|
2
2
|
import type { GlobalSlug } from '../../index.js';
|
|
3
|
-
import type { PayloadRequest, SelectType, TransformGlobalWithSelect } from '../../types/index.js';
|
|
3
|
+
import type { PayloadRequest, PopulateType, SelectType, TransformGlobalWithSelect } from '../../types/index.js';
|
|
4
4
|
import type { DataFromGlobalSlug, SanitizedGlobalConfig, SelectFromGlobalSlug } from '../config/types.js';
|
|
5
5
|
type Args<TSlug extends GlobalSlug> = {
|
|
6
6
|
autosave?: boolean;
|
|
@@ -11,6 +11,7 @@ type Args<TSlug extends GlobalSlug> = {
|
|
|
11
11
|
globalConfig: SanitizedGlobalConfig;
|
|
12
12
|
overrideAccess?: boolean;
|
|
13
13
|
overrideLock?: boolean;
|
|
14
|
+
populate?: PopulateType;
|
|
14
15
|
publishSpecificLocale?: string;
|
|
15
16
|
req: PayloadRequest;
|
|
16
17
|
select?: SelectType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../src/globals/operations/update.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAEhD,OAAO,KAAK,EAAE,UAAU,EAAc,MAAM,gBAAgB,CAAA;AAC5D,OAAO,KAAK,EAEV,cAAc,EACd,UAAU,EACV,yBAAyB,EAE1B,MAAM,sBAAsB,CAAA;AAC7B,OAAO,KAAK,EACV,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACrB,MAAM,oBAAoB,CAAA;AAgB3B,KAAK,IAAI,CAAC,KAAK,SAAS,UAAU,IAAI;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,CAAC,CAAA;IACxD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,YAAY,EAAE,qBAAqB,CAAA;IACnC,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,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,eAAe,GAC1B,KAAK,SAAS,UAAU,EACxB,OAAO,SAAS,oBAAoB,CAAC,KAAK,CAAC,QAErC,IAAI,CAAC,KAAK,CAAC,KAChB,OAAO,CAAC,yBAAyB,CAAC,KAAK,EAAE,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../src/globals/operations/update.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAEhD,OAAO,KAAK,EAAE,UAAU,EAAc,MAAM,gBAAgB,CAAA;AAC5D,OAAO,KAAK,EAEV,cAAc,EACd,YAAY,EACZ,UAAU,EACV,yBAAyB,EAE1B,MAAM,sBAAsB,CAAA;AAC7B,OAAO,KAAK,EACV,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACrB,MAAM,oBAAoB,CAAA;AAgB3B,KAAK,IAAI,CAAC,KAAK,SAAS,UAAU,IAAI;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,CAAC,CAAA;IACxD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,YAAY,EAAE,qBAAqB,CAAA;IACnC,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,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,eAAe,GAC1B,KAAK,SAAS,UAAU,EACxB,OAAO,SAAS,oBAAoB,CAAC,KAAK,CAAC,QAErC,IAAI,CAAC,KAAK,CAAC,KAChB,OAAO,CAAC,yBAAyB,CAAC,KAAK,EAAE,OAAO,CAAC,CAsUnD,CAAA"}
|
|
@@ -15,7 +15,7 @@ export const updateOperation = async (args)=>{
|
|
|
15
15
|
if (args.publishSpecificLocale) {
|
|
16
16
|
args.req.locale = args.publishSpecificLocale;
|
|
17
17
|
}
|
|
18
|
-
const { slug, autosave, depth, disableTransaction, draft: draftArg, globalConfig, overrideAccess, overrideLock, publishSpecificLocale, req: { fallbackLocale, locale, payload }, req, select, showHiddenFields } = args;
|
|
18
|
+
const { slug, autosave, depth, disableTransaction, draft: draftArg, globalConfig, overrideAccess, overrideLock, populate, publishSpecificLocale, req: { fallbackLocale, locale, payload }, req, select, showHiddenFields } = args;
|
|
19
19
|
try {
|
|
20
20
|
const shouldCommit = !disableTransaction && await initTransaction(req);
|
|
21
21
|
let { data } = args;
|
|
@@ -208,6 +208,7 @@ export const updateOperation = async (args)=>{
|
|
|
208
208
|
global: globalConfig,
|
|
209
209
|
locale,
|
|
210
210
|
overrideAccess,
|
|
211
|
+
populate,
|
|
211
212
|
req,
|
|
212
213
|
select,
|
|
213
214
|
showHiddenFields
|