payload 3.71.1 → 3.72.0-internal.3e70d4c
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/config/sanitize.d.ts.map +1 -1
- package/dist/collections/config/sanitize.js +19 -4
- package/dist/collections/config/sanitize.js.map +1 -1
- package/dist/collections/endpoints/create.d.ts.map +1 -1
- package/dist/collections/endpoints/create.js +2 -1
- package/dist/collections/endpoints/create.js.map +1 -1
- package/dist/collections/endpoints/update.d.ts.map +1 -1
- package/dist/collections/endpoints/update.js +3 -1
- package/dist/collections/endpoints/update.js.map +1 -1
- package/dist/collections/endpoints/updateByID.d.ts.map +1 -1
- package/dist/collections/endpoints/updateByID.js +4 -2
- package/dist/collections/endpoints/updateByID.js.map +1 -1
- package/dist/collections/operations/create.d.ts +1 -0
- package/dist/collections/operations/create.d.ts.map +1 -1
- package/dist/collections/operations/create.js +23 -3
- package/dist/collections/operations/create.js.map +1 -1
- package/dist/collections/operations/local/create.d.ts +4 -0
- 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/update.d.ts +12 -0
- package/dist/collections/operations/local/update.d.ts.map +1 -1
- package/dist/collections/operations/local/update.js +3 -1
- package/dist/collections/operations/local/update.js.map +1 -1
- package/dist/collections/operations/update.d.ts +2 -0
- package/dist/collections/operations/update.d.ts.map +1 -1
- package/dist/collections/operations/update.js +4 -3
- package/dist/collections/operations/update.js.map +1 -1
- package/dist/collections/operations/updateByID.d.ts +2 -0
- package/dist/collections/operations/updateByID.d.ts.map +1 -1
- package/dist/collections/operations/updateByID.js +4 -3
- package/dist/collections/operations/updateByID.js.map +1 -1
- package/dist/collections/operations/utilities/update.d.ts +4 -3
- package/dist/collections/operations/utilities/update.d.ts.map +1 -1
- package/dist/collections/operations/utilities/update.js +81 -31
- package/dist/collections/operations/utilities/update.js.map +1 -1
- package/dist/config/types.d.ts +16 -0
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/types.js.map +1 -1
- package/dist/database/migrations/templates/localizeStatus.d.ts +10 -0
- package/dist/database/migrations/templates/localizeStatus.d.ts.map +1 -0
- package/dist/database/migrations/templates/localizeStatus.js +54 -0
- package/dist/database/migrations/templates/localizeStatus.js.map +1 -0
- package/dist/exports/migrations.d.ts +19 -0
- package/dist/exports/migrations.d.ts.map +1 -0
- package/dist/exports/migrations.js +19 -0
- package/dist/exports/migrations.js.map +1 -0
- package/dist/exports/shared.d.ts +1 -1
- package/dist/exports/shared.d.ts.map +1 -1
- package/dist/exports/shared.js +1 -1
- package/dist/exports/shared.js.map +1 -1
- package/dist/globals/config/sanitize.d.ts.map +1 -1
- package/dist/globals/config/sanitize.js +11 -1
- package/dist/globals/config/sanitize.js.map +1 -1
- package/dist/globals/endpoints/update.d.ts.map +1 -1
- package/dist/globals/endpoints/update.js +5 -1
- package/dist/globals/endpoints/update.js.map +1 -1
- package/dist/globals/operations/local/update.d.ts +10 -0
- package/dist/globals/operations/local/update.d.ts.map +1 -1
- package/dist/globals/operations/local/update.js +4 -2
- package/dist/globals/operations/local/update.js.map +1 -1
- package/dist/globals/operations/update.d.ts +2 -0
- package/dist/globals/operations/update.d.ts.map +1 -1
- package/dist/globals/operations/update.js +63 -15
- package/dist/globals/operations/update.js.map +1 -1
- package/dist/index.bundled.d.ts +102 -3
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/utilities/getVersionsConfig.d.ts +4 -0
- package/dist/utilities/getVersionsConfig.d.ts.map +1 -1
- package/dist/utilities/getVersionsConfig.js +7 -2
- package/dist/utilities/getVersionsConfig.js.map +1 -1
- package/dist/utilities/mergeLocalizedData.d.ts +20 -0
- package/dist/utilities/mergeLocalizedData.d.ts.map +1 -0
- package/dist/utilities/mergeLocalizedData.js +277 -0
- package/dist/utilities/mergeLocalizedData.js.map +1 -0
- package/dist/utilities/mergeLocalizedData.spec.js +784 -0
- package/dist/utilities/mergeLocalizedData.spec.js.map +1 -0
- package/dist/utilities/miniChalk.d.ts +15 -0
- package/dist/utilities/miniChalk.d.ts.map +1 -0
- package/dist/utilities/miniChalk.js +34 -0
- package/dist/utilities/miniChalk.js.map +1 -0
- package/dist/utilities/parseParams/index.d.ts +24 -20
- package/dist/utilities/parseParams/index.d.ts.map +1 -1
- package/dist/utilities/parseParams/index.js.map +1 -1
- package/dist/utilities/traverseForLocalizedFields.d.ts +3 -0
- package/dist/utilities/traverseForLocalizedFields.d.ts.map +1 -0
- package/dist/utilities/traverseForLocalizedFields.js +41 -0
- package/dist/utilities/traverseForLocalizedFields.js.map +1 -0
- package/dist/versions/baseFields.d.ts +3 -1
- package/dist/versions/baseFields.d.ts.map +1 -1
- package/dist/versions/baseFields.js +16 -15
- package/dist/versions/baseFields.js.map +1 -1
- package/dist/versions/drafts/replaceWithDraftIfAvailable.d.ts.map +1 -1
- package/dist/versions/drafts/replaceWithDraftIfAvailable.js +28 -2
- package/dist/versions/drafts/replaceWithDraftIfAvailable.js.map +1 -1
- package/dist/versions/migrations/localizeStatus/index.d.ts +12 -0
- package/dist/versions/migrations/localizeStatus/index.d.ts.map +1 -0
- package/dist/versions/migrations/localizeStatus/index.js +33 -0
- package/dist/versions/migrations/localizeStatus/index.js.map +1 -0
- package/dist/versions/migrations/localizeStatus/mongo/down.d.ts +9 -0
- package/dist/versions/migrations/localizeStatus/mongo/down.d.ts.map +1 -0
- package/dist/versions/migrations/localizeStatus/mongo/down.js +112 -0
- package/dist/versions/migrations/localizeStatus/mongo/down.js.map +1 -0
- package/dist/versions/migrations/localizeStatus/mongo/index.d.ts +8 -0
- package/dist/versions/migrations/localizeStatus/mongo/index.d.ts.map +1 -0
- package/dist/versions/migrations/localizeStatus/mongo/index.js +8 -0
- package/dist/versions/migrations/localizeStatus/mongo/index.js.map +1 -0
- package/dist/versions/migrations/localizeStatus/mongo/up.d.ts +9 -0
- package/dist/versions/migrations/localizeStatus/mongo/up.d.ts.map +1 -0
- package/dist/versions/migrations/localizeStatus/mongo/up.js +220 -0
- package/dist/versions/migrations/localizeStatus/mongo/up.js.map +1 -0
- package/dist/versions/migrations/localizeStatus/shared.d.ts +59 -0
- package/dist/versions/migrations/localizeStatus/shared.d.ts.map +1 -0
- package/dist/versions/migrations/localizeStatus/shared.js +122 -0
- package/dist/versions/migrations/localizeStatus/shared.js.map +1 -0
- package/dist/versions/migrations/localizeStatus/sql/down.d.ts +11 -0
- package/dist/versions/migrations/localizeStatus/sql/down.d.ts.map +1 -0
- package/dist/versions/migrations/localizeStatus/sql/down.js +213 -0
- package/dist/versions/migrations/localizeStatus/sql/down.js.map +1 -0
- package/dist/versions/migrations/localizeStatus/sql/index.d.ts +8 -0
- package/dist/versions/migrations/localizeStatus/sql/index.d.ts.map +1 -0
- package/dist/versions/migrations/localizeStatus/sql/index.js +8 -0
- package/dist/versions/migrations/localizeStatus/sql/index.js.map +1 -0
- package/dist/versions/migrations/localizeStatus/sql/migrateMainCollection.d.ts +13 -0
- package/dist/versions/migrations/localizeStatus/sql/migrateMainCollection.d.ts.map +1 -0
- package/dist/versions/migrations/localizeStatus/sql/migrateMainCollection.js +51 -0
- package/dist/versions/migrations/localizeStatus/sql/migrateMainCollection.js.map +1 -0
- package/dist/versions/migrations/localizeStatus/sql/migrateMainGlobal.d.ts +13 -0
- package/dist/versions/migrations/localizeStatus/sql/migrateMainGlobal.d.ts.map +1 -0
- package/dist/versions/migrations/localizeStatus/sql/migrateMainGlobal.js +54 -0
- package/dist/versions/migrations/localizeStatus/sql/migrateMainGlobal.js.map +1 -0
- package/dist/versions/migrations/localizeStatus/sql/up.d.ts +11 -0
- package/dist/versions/migrations/localizeStatus/sql/up.d.ts.map +1 -0
- package/dist/versions/migrations/localizeStatus/sql/up.js +277 -0
- package/dist/versions/migrations/localizeStatus/sql/up.js.map +1 -0
- package/dist/versions/saveSnapshot.d.ts.map +1 -1
- package/dist/versions/saveSnapshot.js +0 -1
- package/dist/versions/saveSnapshot.js.map +1 -1
- package/dist/versions/saveVersion.js +0 -3
- package/dist/versions/saveVersion.js.map +1 -1
- package/dist/versions/types.d.ts +18 -0
- package/dist/versions/types.d.ts.map +1 -1
- package/dist/versions/types.js.map +1 -1
- package/package.json +7 -2
- package/dist/uploads/imageResizer.d.ts +0 -40
- package/dist/uploads/imageResizer.d.ts.map +0 -1
- package/dist/uploads/imageResizer.js +0 -356
- package/dist/uploads/imageResizer.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/globals/endpoints/update.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\n\nimport { getRequestGlobal } from '../../utilities/getRequestEntity.js'\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\nimport { isNumber } from '../../utilities/isNumber.js'\nimport { sanitizePopulateParam } from '../../utilities/sanitizePopulateParam.js'\nimport { sanitizeSelectParam } from '../../utilities/sanitizeSelectParam.js'\nimport { updateOperation } from '../operations/update.js'\n\nexport const updateHandler: PayloadHandler = async (req) => {\n const globalConfig = getRequestGlobal(req)\n const { searchParams } = req\n const depth = searchParams.get('depth')\n const draft = searchParams.get('draft') === 'true'\n const autosave = searchParams.get('autosave') === 'true'\n const publishSpecificLocale = req.query.publishSpecificLocale as string | undefined\n\n const result = await updateOperation({\n slug: globalConfig.slug,\n autosave,\n data: req.data!,\n depth: isNumber(depth) ? Number(depth) : undefined,\n draft,\n globalConfig,\n populate: sanitizePopulateParam(req.query.populate),\n publishSpecificLocale,\n req,\n select: sanitizeSelectParam(req.query.select),\n })\n\n let message = req.t('general:updatedSuccessfully')\n\n if (draft) {\n message = req.t('version:draftSavedSuccessfully')\n }\n if (autosave) {\n message = req.t('version:autosavedSuccessfully')\n }\n\n return Response.json(\n {\n message,\n result,\n },\n {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["status","httpStatus","getRequestGlobal","headersWithCors","isNumber","sanitizePopulateParam","sanitizeSelectParam","updateOperation","updateHandler","req","globalConfig","searchParams","depth","get","draft","autosave","publishSpecificLocale","query","result","slug","data","Number","undefined","populate","select","message","t","Response","json","headers","Headers","OK"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAIlD,SAASC,gBAAgB,QAAQ,sCAAqC;AACtE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,QAAQ,QAAQ,8BAA6B;AACtD,SAASC,qBAAqB,QAAQ,2CAA0C;AAChF,SAASC,mBAAmB,QAAQ,yCAAwC;AAC5E,SAASC,eAAe,QAAQ,0BAAyB;AAEzD,OAAO,MAAMC,gBAAgC,OAAOC;IAClD,MAAMC,eAAeR,iBAAiBO;IACtC,MAAM,EAAEE,YAAY,EAAE,GAAGF;IACzB,MAAMG,QAAQD,aAAaE,GAAG,CAAC;IAC/B,MAAMC,QAAQH,aAAaE,GAAG,CAAC,aAAa;IAC5C,MAAME,WAAWJ,aAAaE,GAAG,CAAC,gBAAgB;IAClD,MAAMG,wBAAwBP,IAAIQ,KAAK,CAACD,qBAAqB;
|
|
1
|
+
{"version":3,"sources":["../../../src/globals/endpoints/update.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\n\nimport { getRequestGlobal } from '../../utilities/getRequestEntity.js'\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\nimport { isNumber } from '../../utilities/isNumber.js'\nimport { sanitizePopulateParam } from '../../utilities/sanitizePopulateParam.js'\nimport { sanitizeSelectParam } from '../../utilities/sanitizeSelectParam.js'\nimport { updateOperation } from '../operations/update.js'\n\nexport const updateHandler: PayloadHandler = async (req) => {\n const globalConfig = getRequestGlobal(req)\n const { searchParams } = req\n const depth = searchParams.get('depth')\n const draft = searchParams.get('draft') === 'true'\n const autosave = searchParams.get('autosave') === 'true'\n const publishSpecificLocale = req.query.publishSpecificLocale as string | undefined\n const publishAllLocales = searchParams.get('publishAllLocales') === 'true'\n const unpublishAllLocales = searchParams.get('unpublishAllLocales') === 'true'\n\n const result = await updateOperation({\n slug: globalConfig.slug,\n autosave,\n data: req.data!,\n depth: isNumber(depth) ? Number(depth) : undefined,\n draft,\n globalConfig,\n populate: sanitizePopulateParam(req.query.populate),\n publishAllLocales,\n publishSpecificLocale,\n req,\n select: sanitizeSelectParam(req.query.select),\n unpublishAllLocales,\n })\n\n let message = req.t('general:updatedSuccessfully')\n\n if (draft) {\n message = req.t('version:draftSavedSuccessfully')\n }\n if (autosave) {\n message = req.t('version:autosavedSuccessfully')\n }\n\n return Response.json(\n {\n message,\n result,\n },\n {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["status","httpStatus","getRequestGlobal","headersWithCors","isNumber","sanitizePopulateParam","sanitizeSelectParam","updateOperation","updateHandler","req","globalConfig","searchParams","depth","get","draft","autosave","publishSpecificLocale","query","publishAllLocales","unpublishAllLocales","result","slug","data","Number","undefined","populate","select","message","t","Response","json","headers","Headers","OK"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAIlD,SAASC,gBAAgB,QAAQ,sCAAqC;AACtE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,QAAQ,QAAQ,8BAA6B;AACtD,SAASC,qBAAqB,QAAQ,2CAA0C;AAChF,SAASC,mBAAmB,QAAQ,yCAAwC;AAC5E,SAASC,eAAe,QAAQ,0BAAyB;AAEzD,OAAO,MAAMC,gBAAgC,OAAOC;IAClD,MAAMC,eAAeR,iBAAiBO;IACtC,MAAM,EAAEE,YAAY,EAAE,GAAGF;IACzB,MAAMG,QAAQD,aAAaE,GAAG,CAAC;IAC/B,MAAMC,QAAQH,aAAaE,GAAG,CAAC,aAAa;IAC5C,MAAME,WAAWJ,aAAaE,GAAG,CAAC,gBAAgB;IAClD,MAAMG,wBAAwBP,IAAIQ,KAAK,CAACD,qBAAqB;IAC7D,MAAME,oBAAoBP,aAAaE,GAAG,CAAC,yBAAyB;IACpE,MAAMM,sBAAsBR,aAAaE,GAAG,CAAC,2BAA2B;IAExE,MAAMO,SAAS,MAAMb,gBAAgB;QACnCc,MAAMX,aAAaW,IAAI;QACvBN;QACAO,MAAMb,IAAIa,IAAI;QACdV,OAAOR,SAASQ,SAASW,OAAOX,SAASY;QACzCV;QACAJ;QACAe,UAAUpB,sBAAsBI,IAAIQ,KAAK,CAACQ,QAAQ;QAClDP;QACAF;QACAP;QACAiB,QAAQpB,oBAAoBG,IAAIQ,KAAK,CAACS,MAAM;QAC5CP;IACF;IAEA,IAAIQ,UAAUlB,IAAImB,CAAC,CAAC;IAEpB,IAAId,OAAO;QACTa,UAAUlB,IAAImB,CAAC,CAAC;IAClB;IACA,IAAIb,UAAU;QACZY,UAAUlB,IAAImB,CAAC,CAAC;IAClB;IAEA,OAAOC,SAASC,IAAI,CAClB;QACEH;QACAP;IACF,GACA;QACEW,SAAS5B,gBAAgB;YACvB4B,SAAS,IAAIC;YACbvB;QACF;QACAT,QAAQC,WAAWgC,EAAE;IACvB;AAEJ,EAAC"}
|
|
@@ -46,6 +46,12 @@ export type Options<TSlug extends GlobalSlug, TSelect extends SelectType> = {
|
|
|
46
46
|
* Specify [populate](https://payloadcms.com/docs/queries/select#populate) to control which fields to include to the result from populated documents.
|
|
47
47
|
*/
|
|
48
48
|
populate?: PopulateType;
|
|
49
|
+
/**
|
|
50
|
+
* Publish the document / documents in all locales. Requires `versions.drafts.localizeStatus` to be enabled.
|
|
51
|
+
*
|
|
52
|
+
* @default undefined
|
|
53
|
+
*/
|
|
54
|
+
publishAllLocales?: boolean;
|
|
49
55
|
/**
|
|
50
56
|
* Publish the document / documents with a specific locale.
|
|
51
57
|
*/
|
|
@@ -68,6 +74,10 @@ export type Options<TSlug extends GlobalSlug, TSelect extends SelectType> = {
|
|
|
68
74
|
* the Global slug to operate against.
|
|
69
75
|
*/
|
|
70
76
|
slug: TSlug;
|
|
77
|
+
/**
|
|
78
|
+
* Unpublish the document / documents in all locales. Requires `versions.drafts.localizeStatus` to be enabled.
|
|
79
|
+
*/
|
|
80
|
+
unpublishAllLocales?: boolean;
|
|
71
81
|
/**
|
|
72
82
|
* If you set `overrideAccess` to `false`, you can pass a user to use against the access control checks.
|
|
73
83
|
*/
|
|
@@ -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,EACV,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,UAAU,EACV,yBAAyB,EAC1B,MAAM,yBAAyB,CAAA;AAEhC,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAGrF,OAAO,EAEL,KAAK,UAAU,EACf,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,WAAW,EACjB,MAAM,mBAAmB,CAAA;AAI1B,MAAM,MAAM,OAAO,CAAC,KAAK,SAAS,UAAU,EAAE,OAAO,SAAS,UAAU,IAAI;IAC1E;;;;;OAKG;IACH,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB;;OAEG;IACH,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,CAAC,CAAA;IACxD;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAA;IACf;;OAEG;IACH,cAAc,CAAC,EAAE,KAAK,GAAG,WAAW,CAAA;IACpC;;OAEG;IACH,MAAM,CAAC,EAAE,KAAK,GAAG,WAAW,CAAA;IAC5B;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;I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AAC,KAAK,CAAC,EAAE,IAAI,CAAC,CAAC,CAAA;IACxD;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAA;IACf;;OAEG;IACH,cAAc,CAAC,EAAE,KAAK,GAAG,WAAW,CAAA;IACpC;;OAEG;IACH,MAAM,CAAC,EAAE,KAAK,GAAG,WAAW,CAAA;IAC5B;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB;;OAEG;IACH,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B;;OAEG;IACH,qBAAqB,CAAC,EAAE,WAAW,CAAA;IACnC;;;OAGG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAA;IAC7B;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B;;OAEG;IACH,IAAI,EAAE,KAAK,CAAA;IACX;;OAEG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B;;OAEG;IACH,IAAI,CAAC,EAAE,QAAQ,CAAA;CAChB,CAAA;AAED,wBAAsB,iBAAiB,CACrC,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,CAsCpD"}
|
|
@@ -3,7 +3,7 @@ import { deepCopyObjectSimple } from '../../../index.js';
|
|
|
3
3
|
import { createLocalReq } from '../../../utilities/createLocalReq.js';
|
|
4
4
|
import { updateOperation } from '../update.js';
|
|
5
5
|
export async function updateGlobalLocal(payload, options) {
|
|
6
|
-
const { slug: globalSlug, data, depth, draft, overrideAccess = true, overrideLock, populate, publishSpecificLocale, select, showHiddenFields } = options;
|
|
6
|
+
const { slug: globalSlug, data, depth, draft, overrideAccess = true, overrideLock, populate, publishAllLocales, publishSpecificLocale, select, showHiddenFields, unpublishAllLocales } = 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.`);
|
|
@@ -17,10 +17,12 @@ export async function updateGlobalLocal(payload, options) {
|
|
|
17
17
|
overrideAccess,
|
|
18
18
|
overrideLock,
|
|
19
19
|
populate,
|
|
20
|
+
publishAllLocales,
|
|
20
21
|
publishSpecificLocale: publishSpecificLocale,
|
|
21
22
|
req: await createLocalReq(options, payload),
|
|
22
23
|
select,
|
|
23
|
-
showHiddenFields
|
|
24
|
+
showHiddenFields,
|
|
25
|
+
unpublishAllLocales
|
|
24
26
|
});
|
|
25
27
|
}
|
|
26
28
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/globals/operations/local/update.ts"],"sourcesContent":["import type { DeepPartial } from 'ts-essentials'\n\nimport type {\n Document,\n PayloadRequest,\n PopulateType,\n SelectType,\n TransformGlobalWithSelect,\n} from '../../../types/index.js'\nimport type { CreateLocalReqOptions } from '../../../utilities/createLocalReq.js'\nimport type { DataFromGlobalSlug, SelectFromGlobalSlug } from '../../config/types.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport {\n deepCopyObjectSimple,\n type GlobalSlug,\n type Payload,\n type RequestContext,\n type TypedLocale,\n} from '../../../index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { updateOperation } from '../update.js'\n\nexport type Options<TSlug extends GlobalSlug, TSelect extends SelectType> = {\n /**\n * [Context](https://payloadcms.com/docs/hooks/context), which will then be passed to `context` and `req.context`,\n * which can be read by hooks. Useful if you want to pass additional information to the hooks which\n * shouldn't be necessarily part of the document, for example a `triggerBeforeChange` option which can be read by the BeforeChange hook\n * to determine if it should run or not.\n */\n context?: RequestContext\n /**\n * The global data to update.\n */\n data: DeepPartial<Omit<DataFromGlobalSlug<TSlug>, 'id'>>\n /**\n * [Control auto-population](https://payloadcms.com/docs/queries/depth) of nested relationship and upload fields.\n */\n depth?: number\n /**\n * Update documents to a draft.\n */\n draft?: boolean\n /**\n * Specify a [fallback locale](https://payloadcms.com/docs/configuration/localization) to use for any returned documents.\n */\n fallbackLocale?: false | TypedLocale\n /**\n * Specify [locale](https://payloadcms.com/docs/configuration/localization) for any returned documents.\n */\n locale?: 'all' | TypedLocale\n /**\n * Skip access control.\n * Set to `false` if you want to respect Access Control for the operation, for example when fetching data for the front-end.\n * @default true\n */\n overrideAccess?: boolean\n /**\n * If you are uploading a file and would like to replace\n * the existing file instead of generating a new filename,\n * you can set the following property to `true`\n */\n overrideLock?: boolean\n /**\n * Specify [populate](https://payloadcms.com/docs/queries/select#populate) to control which fields to include to the result from populated documents.\n */\n populate?: PopulateType\n /**\n * Publish the document / documents with a specific locale.\n */\n publishSpecificLocale?: TypedLocale\n /**\n * The `PayloadRequest` object. You can pass it to thread the current [transaction](https://payloadcms.com/docs/database/transactions), user and locale to the operation.\n * Recommended to pass when using the Local API from hooks, as usually you want to execute the operation within the current transaction.\n */\n req?: Partial<PayloadRequest>\n /**\n * Specify [select](https://payloadcms.com/docs/queries/select) to control which fields to include to the result.\n */\n select?: TSelect\n /**\n * Opt-in to receiving hidden fields. By default, they are hidden from returned documents in accordance to your config.\n * @default false\n */\n showHiddenFields?: boolean\n /**\n * the Global slug to operate against.\n */\n slug: TSlug\n /**\n * If you set `overrideAccess` to `false`, you can pass a user to use against the access control checks.\n */\n user?: Document\n}\n\nexport async function updateGlobalLocal<\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: deepCopyObjectSimple(data), // Ensure mutation of data in create operation hooks doesn't affect the original data\n depth,\n draft,\n globalConfig,\n overrideAccess,\n overrideLock,\n populate,\n publishSpecificLocale: publishSpecificLocale!,\n req: await createLocalReq(options as CreateLocalReqOptions, payload),\n select,\n showHiddenFields,\n })\n}\n"],"names":["APIError","deepCopyObjectSimple","createLocalReq","updateOperation","updateGlobalLocal","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,SACEC,oBAAoB,QAKf,oBAAmB;AAC1B,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,eAAe,QAAQ,eAAc;
|
|
1
|
+
{"version":3,"sources":["../../../../src/globals/operations/local/update.ts"],"sourcesContent":["import type { DeepPartial } from 'ts-essentials'\n\nimport type {\n Document,\n PayloadRequest,\n PopulateType,\n SelectType,\n TransformGlobalWithSelect,\n} from '../../../types/index.js'\nimport type { CreateLocalReqOptions } from '../../../utilities/createLocalReq.js'\nimport type { DataFromGlobalSlug, SelectFromGlobalSlug } from '../../config/types.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport {\n deepCopyObjectSimple,\n type GlobalSlug,\n type Payload,\n type RequestContext,\n type TypedLocale,\n} from '../../../index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { updateOperation } from '../update.js'\n\nexport type Options<TSlug extends GlobalSlug, TSelect extends SelectType> = {\n /**\n * [Context](https://payloadcms.com/docs/hooks/context), which will then be passed to `context` and `req.context`,\n * which can be read by hooks. Useful if you want to pass additional information to the hooks which\n * shouldn't be necessarily part of the document, for example a `triggerBeforeChange` option which can be read by the BeforeChange hook\n * to determine if it should run or not.\n */\n context?: RequestContext\n /**\n * The global data to update.\n */\n data: DeepPartial<Omit<DataFromGlobalSlug<TSlug>, 'id'>>\n /**\n * [Control auto-population](https://payloadcms.com/docs/queries/depth) of nested relationship and upload fields.\n */\n depth?: number\n /**\n * Update documents to a draft.\n */\n draft?: boolean\n /**\n * Specify a [fallback locale](https://payloadcms.com/docs/configuration/localization) to use for any returned documents.\n */\n fallbackLocale?: false | TypedLocale\n /**\n * Specify [locale](https://payloadcms.com/docs/configuration/localization) for any returned documents.\n */\n locale?: 'all' | TypedLocale\n /**\n * Skip access control.\n * Set to `false` if you want to respect Access Control for the operation, for example when fetching data for the front-end.\n * @default true\n */\n overrideAccess?: boolean\n /**\n * If you are uploading a file and would like to replace\n * the existing file instead of generating a new filename,\n * you can set the following property to `true`\n */\n overrideLock?: boolean\n /**\n * Specify [populate](https://payloadcms.com/docs/queries/select#populate) to control which fields to include to the result from populated documents.\n */\n populate?: PopulateType\n /**\n * Publish the document / documents in all locales. Requires `versions.drafts.localizeStatus` to be enabled.\n *\n * @default undefined\n */\n publishAllLocales?: boolean\n /**\n * Publish the document / documents with a specific locale.\n */\n publishSpecificLocale?: TypedLocale\n /**\n * The `PayloadRequest` object. You can pass it to thread the current [transaction](https://payloadcms.com/docs/database/transactions), user and locale to the operation.\n * Recommended to pass when using the Local API from hooks, as usually you want to execute the operation within the current transaction.\n */\n req?: Partial<PayloadRequest>\n /**\n * Specify [select](https://payloadcms.com/docs/queries/select) to control which fields to include to the result.\n */\n select?: TSelect\n /**\n * Opt-in to receiving hidden fields. By default, they are hidden from returned documents in accordance to your config.\n * @default false\n */\n showHiddenFields?: boolean\n /**\n * the Global slug to operate against.\n */\n slug: TSlug\n /**\n * Unpublish the document / documents in all locales. Requires `versions.drafts.localizeStatus` to be enabled.\n */\n unpublishAllLocales?: boolean\n /**\n * If you set `overrideAccess` to `false`, you can pass a user to use against the access control checks.\n */\n user?: Document\n}\n\nexport async function updateGlobalLocal<\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 publishAllLocales,\n publishSpecificLocale,\n select,\n showHiddenFields,\n unpublishAllLocales,\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: deepCopyObjectSimple(data), // Ensure mutation of data in create operation hooks doesn't affect the original data\n depth,\n draft,\n globalConfig,\n overrideAccess,\n overrideLock,\n populate,\n publishAllLocales,\n publishSpecificLocale: publishSpecificLocale!,\n req: await createLocalReq(options as CreateLocalReqOptions, payload),\n select,\n showHiddenFields,\n unpublishAllLocales,\n })\n}\n"],"names":["APIError","deepCopyObjectSimple","createLocalReq","updateOperation","updateGlobalLocal","payload","options","slug","globalSlug","data","depth","draft","overrideAccess","overrideLock","populate","publishAllLocales","publishSpecificLocale","select","showHiddenFields","unpublishAllLocales","globalConfig","globals","config","find","String","req"],"mappings":"AAYA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SACEC,oBAAoB,QAKf,oBAAmB;AAC1B,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,eAAe,QAAQ,eAAc;AAoF9C,OAAO,eAAeC,kBAIpBC,OAAgB,EAChBC,OAAgC;IAEhC,MAAM,EACJC,MAAMC,UAAU,EAChBC,IAAI,EACJC,KAAK,EACLC,KAAK,EACLC,iBAAiB,IAAI,EACrBC,YAAY,EACZC,QAAQ,EACRC,iBAAiB,EACjBC,qBAAqB,EACrBC,MAAM,EACNC,gBAAgB,EAChBC,mBAAmB,EACpB,GAAGb;IAEJ,MAAMc,eAAef,QAAQgB,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC,CAACD,SAAWA,OAAOf,IAAI,KAAKC;IAE7E,IAAI,CAACY,cAAc;QACjB,MAAM,IAAIpB,SAAS,CAAC,qBAAqB,EAAEwB,OAAOhB,YAAY,gBAAgB,CAAC;IACjF;IAEA,OAAOL,gBAAgC;QACrCI,MAAMC;QACNC,MAAMR,qBAAqBQ;QAC3BC;QACAC;QACAS;QACAR;QACAC;QACAC;QACAC;QACAC,uBAAuBA;QACvBS,KAAK,MAAMvB,eAAeI,SAAkCD;QAC5DY;QACAC;QACAC;IACF;AACF"}
|
|
@@ -12,11 +12,13 @@ type Args<TSlug extends GlobalSlug> = {
|
|
|
12
12
|
overrideAccess?: boolean;
|
|
13
13
|
overrideLock?: boolean;
|
|
14
14
|
populate?: PopulateType;
|
|
15
|
+
publishAllLocales?: boolean;
|
|
15
16
|
publishSpecificLocale?: string;
|
|
16
17
|
req: PayloadRequest;
|
|
17
18
|
select?: SelectType;
|
|
18
19
|
showHiddenFields?: boolean;
|
|
19
20
|
slug: string;
|
|
21
|
+
unpublishAllLocales?: boolean;
|
|
20
22
|
};
|
|
21
23
|
export declare const updateOperation: <TSlug extends GlobalSlug, TSelect extends SelectFromGlobalSlug<TSlug>>(args: Args<TSlug>) => Promise<TransformGlobalWithSelect<TSlug, TSelect>>;
|
|
22
24
|
export {};
|
|
@@ -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,YAAY,EACZ,UAAU,EACV,y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1B,KAAK,SAAS,UAAU,EACxB,OAAO,SAAS,oBAAoB,CAAC,KAAK,CAAC,QAErC,IAAI,CAAC,KAAK,CAAC,KAChB,OAAO,CAAC,yBAAyB,CAAC,KAAK,EAAE,OAAO,CAAC,CAoanD,CAAA"}
|
|
@@ -7,9 +7,10 @@ import { deepCopyObjectSimple } from '../../index.js';
|
|
|
7
7
|
import { checkDocumentLockStatus } from '../../utilities/checkDocumentLockStatus.js';
|
|
8
8
|
import { commitTransaction } from '../../utilities/commitTransaction.js';
|
|
9
9
|
import { getSelectMode } from '../../utilities/getSelectMode.js';
|
|
10
|
-
import { hasDraftsEnabled, hasDraftValidationEnabled } from '../../utilities/getVersionsConfig.js';
|
|
10
|
+
import { hasDraftsEnabled, hasDraftValidationEnabled, hasLocalizeStatusEnabled } from '../../utilities/getVersionsConfig.js';
|
|
11
11
|
import { initTransaction } from '../../utilities/initTransaction.js';
|
|
12
12
|
import { killTransaction } from '../../utilities/killTransaction.js';
|
|
13
|
+
import { mergeLocalizedData } from '../../utilities/mergeLocalizedData.js';
|
|
13
14
|
import { sanitizeSelect } from '../../utilities/sanitizeSelect.js';
|
|
14
15
|
import { getLatestGlobalVersion } from '../../versions/getLatestGlobalVersion.js';
|
|
15
16
|
import { saveVersion } from '../../versions/saveVersion.js';
|
|
@@ -17,7 +18,7 @@ export const updateOperation = async (args)=>{
|
|
|
17
18
|
if (args.publishSpecificLocale) {
|
|
18
19
|
args.req.locale = args.publishSpecificLocale;
|
|
19
20
|
}
|
|
20
|
-
const { slug, autosave, depth, disableTransaction, draft: draftArg, globalConfig, overrideAccess, overrideLock, populate, publishSpecificLocale, req: { fallbackLocale, locale, payload }, req, select: incomingSelect, showHiddenFields } = args;
|
|
21
|
+
const { slug, autosave, depth, disableTransaction, draft: draftArg, globalConfig, overrideAccess, overrideLock, populate, publishAllLocales: publishAllLocalesArg, publishSpecificLocale, req: { fallbackLocale, locale, payload, payload: { config } = {} }, req, select: incomingSelect, showHiddenFields, unpublishAllLocales: unpublishAllLocalesArg } = args;
|
|
21
22
|
try {
|
|
22
23
|
const shouldCommit = !disableTransaction && await initTransaction(req);
|
|
23
24
|
// /////////////////////////////////////
|
|
@@ -35,7 +36,12 @@ export const updateOperation = async (args)=>{
|
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
38
|
let { data } = args;
|
|
38
|
-
const
|
|
39
|
+
const publishAllLocales = !draftArg && (publishAllLocalesArg ?? (hasLocalizeStatusEnabled(globalConfig) ? false : true));
|
|
40
|
+
const unpublishAllLocales = typeof unpublishAllLocalesArg === 'string' ? unpublishAllLocalesArg === 'true' : !!unpublishAllLocalesArg;
|
|
41
|
+
const isSavingDraft = Boolean(draftArg && hasDraftsEnabled(globalConfig)) && data._status !== 'published' && !publishAllLocales;
|
|
42
|
+
if (isSavingDraft) {
|
|
43
|
+
data._status = 'draft';
|
|
44
|
+
}
|
|
39
45
|
// /////////////////////////////////////
|
|
40
46
|
// 1. Retrieve and execute access
|
|
41
47
|
// /////////////////////////////////////
|
|
@@ -145,20 +151,62 @@ export const updateOperation = async (args)=>{
|
|
|
145
151
|
};
|
|
146
152
|
let result = await beforeChange(beforeChangeArgs);
|
|
147
153
|
let snapshotToSave;
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
154
|
+
// /////////////////////////////////////
|
|
155
|
+
// Handle Localized Data Merging
|
|
156
|
+
// /////////////////////////////////////
|
|
157
|
+
if (config && config.localization && globalConfig.versions) {
|
|
158
|
+
let currentGlobal = null;
|
|
159
|
+
let snapshotData;
|
|
160
|
+
if (globalConfig.versions.drafts && globalConfig.versions.drafts.localizeStatus) {
|
|
161
|
+
if (publishAllLocales || unpublishAllLocales) {
|
|
162
|
+
let accessibleLocaleCodes = config.localization.localeCodes;
|
|
163
|
+
if (config.localization.filterAvailableLocales) {
|
|
164
|
+
const filteredLocales = await config.localization.filterAvailableLocales({
|
|
165
|
+
locales: config.localization.locales,
|
|
166
|
+
req
|
|
167
|
+
});
|
|
168
|
+
accessibleLocaleCodes = filteredLocales.map((locale)=>typeof locale === 'string' ? locale : locale.code);
|
|
169
|
+
}
|
|
170
|
+
if (typeof result._status !== 'object' || result._status === null) {
|
|
171
|
+
result._status = {};
|
|
172
|
+
}
|
|
173
|
+
for (const localeCode of accessibleLocaleCodes){
|
|
174
|
+
result._status[localeCode] = unpublishAllLocales ? 'draft' : 'published';
|
|
175
|
+
}
|
|
176
|
+
} else if (!isSavingDraft) {
|
|
177
|
+
// publishing a single locale
|
|
178
|
+
currentGlobal = await payload.db.findGlobal({
|
|
179
|
+
slug: globalConfig.slug,
|
|
159
180
|
req,
|
|
160
181
|
where: query
|
|
161
|
-
})
|
|
182
|
+
});
|
|
183
|
+
snapshotData = result;
|
|
184
|
+
}
|
|
185
|
+
} else if (publishSpecificLocale) {
|
|
186
|
+
// previous way of publishing a single locale
|
|
187
|
+
currentGlobal = (await getLatestGlobalVersion({
|
|
188
|
+
slug,
|
|
189
|
+
config: globalConfig,
|
|
190
|
+
payload,
|
|
191
|
+
published: true,
|
|
192
|
+
req,
|
|
193
|
+
where: query
|
|
194
|
+
})).global;
|
|
195
|
+
snapshotData = {
|
|
196
|
+
...result,
|
|
197
|
+
_status: 'draft'
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
if (snapshotData) {
|
|
201
|
+
snapshotToSave = deepCopyObjectSimple(snapshotData);
|
|
202
|
+
result = mergeLocalizedData({
|
|
203
|
+
configBlockReferences: config.blocks,
|
|
204
|
+
dataWithLocales: result || {},
|
|
205
|
+
docWithLocales: currentGlobal || {},
|
|
206
|
+
fields: globalConfig.fields,
|
|
207
|
+
selectedLocales: [
|
|
208
|
+
locale
|
|
209
|
+
]
|
|
162
210
|
});
|
|
163
211
|
}
|
|
164
212
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/globals/operations/update.ts"],"sourcesContent":["import type { DeepPartial } from 'ts-essentials'\n\nimport type { GlobalSlug, JsonObject } from '../../index.js'\nimport type {\n Operation,\n PayloadRequest,\n PopulateType,\n SelectType,\n TransformGlobalWithSelect,\n Where,\n} from '../../types/index.js'\nimport type {\n DataFromGlobalSlug,\n SanitizedGlobalConfig,\n SelectFromGlobalSlug,\n} from '../config/types.js'\n\nimport { executeAccess } from '../../auth/executeAccess.js'\nimport { afterChange } from '../../fields/hooks/afterChange/index.js'\nimport { afterRead } from '../../fields/hooks/afterRead/index.js'\nimport { beforeChange } from '../../fields/hooks/beforeChange/index.js'\nimport { beforeValidate } from '../../fields/hooks/beforeValidate/index.js'\nimport { deepCopyObjectSimple } from '../../index.js'\nimport { checkDocumentLockStatus } from '../../utilities/checkDocumentLockStatus.js'\nimport { commitTransaction } from '../../utilities/commitTransaction.js'\nimport { getSelectMode } from '../../utilities/getSelectMode.js'\nimport { hasDraftsEnabled, hasDraftValidationEnabled } from '../../utilities/getVersionsConfig.js'\nimport { initTransaction } from '../../utilities/initTransaction.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport { sanitizeSelect } from '../../utilities/sanitizeSelect.js'\nimport { getLatestGlobalVersion } from '../../versions/getLatestGlobalVersion.js'\nimport { saveVersion } from '../../versions/saveVersion.js'\n\ntype Args<TSlug extends GlobalSlug> = {\n autosave?: boolean\n data: DeepPartial<Omit<DataFromGlobalSlug<TSlug>, 'id'>>\n depth?: number\n disableTransaction?: boolean\n draft?: boolean\n globalConfig: SanitizedGlobalConfig\n overrideAccess?: boolean\n overrideLock?: boolean\n populate?: PopulateType\n publishSpecificLocale?: string\n req: PayloadRequest\n select?: SelectType\n showHiddenFields?: boolean\n slug: string\n}\n\nexport const updateOperation = async <\n TSlug extends GlobalSlug,\n TSelect extends SelectFromGlobalSlug<TSlug>,\n>(\n args: Args<TSlug>,\n): Promise<TransformGlobalWithSelect<TSlug, TSelect>> => {\n if (args.publishSpecificLocale) {\n args.req.locale = args.publishSpecificLocale\n }\n\n const {\n slug,\n autosave,\n depth,\n disableTransaction,\n draft: draftArg,\n globalConfig,\n overrideAccess,\n overrideLock,\n populate,\n publishSpecificLocale,\n req: { fallbackLocale, locale, payload },\n req,\n select: incomingSelect,\n showHiddenFields,\n } = args\n\n try {\n const shouldCommit = !disableTransaction && (await initTransaction(req))\n\n // /////////////////////////////////////\n // beforeOperation - Global\n // /////////////////////////////////////\n\n if (globalConfig.hooks?.beforeOperation?.length) {\n for (const hook of globalConfig.hooks.beforeOperation) {\n args =\n (await hook({\n args,\n context: args.req.context,\n global: globalConfig,\n operation: 'update',\n req: args.req,\n })) || args\n }\n }\n\n let { data } = args\n\n const isSavingDraft =\n Boolean(draftArg && hasDraftsEnabled(globalConfig)) && data._status !== 'published'\n\n // /////////////////////////////////////\n // 1. Retrieve and execute access\n // /////////////////////////////////////\n\n const accessResults = !overrideAccess\n ? await executeAccess(\n {\n data,\n req,\n },\n globalConfig.access.update,\n )\n : true\n\n // /////////////////////////////////////\n // Retrieve document\n // /////////////////////////////////////\n\n const query: Where = overrideAccess ? undefined! : (accessResults as Where)\n\n // /////////////////////////////////////\n // 2. Retrieve document\n // /////////////////////////////////////\n const globalVersionResult = await getLatestGlobalVersion({\n slug,\n config: globalConfig,\n locale: locale!,\n payload,\n req,\n where: query,\n })\n const { global, globalExists } = globalVersionResult || {}\n\n let globalJSON: JsonObject = {}\n\n if (globalVersionResult && globalVersionResult.global) {\n globalJSON = deepCopyObjectSimple(global)\n\n if (globalJSON._id) {\n delete globalJSON._id\n }\n }\n\n const originalDoc = await afterRead({\n collection: null,\n context: req.context,\n depth: 0,\n doc: deepCopyObjectSimple(globalJSON),\n draft: draftArg!,\n fallbackLocale: fallbackLocale!,\n global: globalConfig,\n locale: locale!,\n overrideAccess: true,\n req,\n showHiddenFields: showHiddenFields!,\n })\n\n // ///////////////////////////////////////////\n // Handle potentially locked global documents\n // ///////////////////////////////////////////\n\n await checkDocumentLockStatus({\n globalSlug: slug,\n lockErrorMessage: `Global with slug \"${slug}\" is currently locked by another user and cannot be updated.`,\n overrideLock,\n req,\n })\n\n // /////////////////////////////////////\n // beforeValidate - Fields\n // /////////////////////////////////////\n\n data = await beforeValidate({\n collection: null,\n context: req.context,\n data,\n doc: originalDoc,\n global: globalConfig,\n operation: 'update',\n overrideAccess: overrideAccess!,\n req,\n })\n\n // /////////////////////////////////////\n // beforeValidate - Global\n // /////////////////////////////////////\n\n if (globalConfig.hooks?.beforeValidate?.length) {\n for (const hook of globalConfig.hooks.beforeValidate) {\n data =\n (await hook({\n context: req.context,\n data,\n global: globalConfig,\n originalDoc,\n req,\n })) || data\n }\n }\n\n // /////////////////////////////////////\n // beforeChange - Global\n // /////////////////////////////////////\n\n if (globalConfig.hooks?.beforeChange?.length) {\n for (const hook of globalConfig.hooks.beforeChange) {\n data =\n (await hook({\n context: req.context,\n data,\n global: globalConfig,\n originalDoc,\n req,\n })) || data\n }\n }\n\n // /////////////////////////////////////\n // beforeChange - Fields\n // /////////////////////////////////////\n\n const beforeChangeArgs = {\n collection: null,\n context: req.context,\n data,\n doc: originalDoc,\n docWithLocales: globalJSON,\n global: globalConfig,\n operation: 'update' as Operation,\n req,\n skipValidation: isSavingDraft && !hasDraftValidationEnabled(globalConfig),\n }\n\n let result: JsonObject = await beforeChange(beforeChangeArgs)\n let snapshotToSave: JsonObject | undefined\n\n if (payload.config.localization && globalConfig.versions) {\n if (publishSpecificLocale) {\n snapshotToSave = deepCopyObjectSimple(result)\n\n // the published data to save to the main document\n result = await beforeChange({\n ...beforeChangeArgs,\n docWithLocales:\n (\n await getLatestGlobalVersion({\n slug,\n config: globalConfig,\n payload,\n published: true,\n req,\n where: query,\n })\n )?.global || {},\n })\n }\n }\n\n // /////////////////////////////////////\n // Update\n // /////////////////////////////////////\n\n const select = sanitizeSelect({\n fields: globalConfig.flattenedFields,\n forceSelect: globalConfig.forceSelect,\n select: incomingSelect,\n })\n\n if (!isSavingDraft) {\n const now = new Date().toISOString()\n // Ensure global has createdAt\n if (!result.createdAt) {\n result.createdAt = now\n }\n\n // Ensure updatedAt date is always updated\n result.updatedAt = now\n\n if (globalExists) {\n result = await payload.db.updateGlobal({\n slug,\n data: result,\n req,\n select,\n })\n } else {\n result = await payload.db.createGlobal({\n slug,\n data: result,\n req,\n })\n }\n }\n\n // /////////////////////////////////////\n // Create version\n // /////////////////////////////////////\n if (globalConfig.versions) {\n const { globalType } = result\n result = await saveVersion({\n autosave,\n docWithLocales: result,\n draft: isSavingDraft,\n global: globalConfig,\n operation: 'update',\n payload,\n publishSpecificLocale,\n req,\n select,\n snapshot: snapshotToSave,\n })\n\n result = {\n ...result,\n globalType,\n }\n }\n\n // /////////////////////////////////////\n // Execute globalType field if not selected\n // /////////////////////////////////////\n if (select && result.globalType) {\n const selectMode = getSelectMode(select)\n if (\n (selectMode === 'include' && !select['globalType']) ||\n (selectMode === 'exclude' && select['globalType'] === false)\n ) {\n delete result['globalType']\n }\n }\n\n // /////////////////////////////////////\n // afterRead - Fields\n // /////////////////////////////////////\n\n result = await afterRead({\n collection: null,\n context: req.context,\n depth: depth!,\n doc: result,\n draft: draftArg!,\n fallbackLocale: null,\n global: globalConfig,\n locale: locale!,\n overrideAccess: overrideAccess!,\n populate,\n req,\n select,\n showHiddenFields: showHiddenFields!,\n })\n\n // /////////////////////////////////////\n // afterRead - Global\n // /////////////////////////////////////\n\n if (globalConfig.hooks?.afterRead?.length) {\n for (const hook of globalConfig.hooks.afterRead) {\n result =\n (await hook({\n context: req.context,\n doc: result,\n global: globalConfig,\n req,\n })) || result\n }\n }\n\n // /////////////////////////////////////\n // afterChange - Fields\n // /////////////////////////////////////\n\n result = await afterChange({\n collection: null,\n context: req.context,\n data,\n doc: result,\n global: globalConfig,\n operation: 'update',\n previousDoc: originalDoc,\n req,\n })\n\n // /////////////////////////////////////\n // afterChange - Global\n // /////////////////////////////////////\n\n if (globalConfig.hooks?.afterChange?.length) {\n for (const hook of globalConfig.hooks.afterChange) {\n result =\n (await hook({\n context: req.context,\n data,\n doc: result,\n global: globalConfig,\n previousDoc: originalDoc,\n req,\n })) || result\n }\n }\n\n // /////////////////////////////////////\n // Return results\n // /////////////////////////////////////\n\n if (shouldCommit) {\n await commitTransaction(req)\n }\n\n return result as TransformGlobalWithSelect<TSlug, TSelect>\n } catch (error: unknown) {\n await killTransaction(req)\n throw error\n }\n}\n"],"names":["executeAccess","afterChange","afterRead","beforeChange","beforeValidate","deepCopyObjectSimple","checkDocumentLockStatus","commitTransaction","getSelectMode","hasDraftsEnabled","hasDraftValidationEnabled","initTransaction","killTransaction","sanitizeSelect","getLatestGlobalVersion","saveVersion","updateOperation","args","publishSpecificLocale","req","locale","slug","autosave","depth","disableTransaction","draft","draftArg","globalConfig","overrideAccess","overrideLock","populate","fallbackLocale","payload","select","incomingSelect","showHiddenFields","shouldCommit","hooks","beforeOperation","length","hook","context","global","operation","data","isSavingDraft","Boolean","_status","accessResults","access","update","query","undefined","globalVersionResult","config","where","globalExists","globalJSON","_id","originalDoc","collection","doc","globalSlug","lockErrorMessage","beforeChangeArgs","docWithLocales","skipValidation","result","snapshotToSave","localization","versions","published","fields","flattenedFields","forceSelect","now","Date","toISOString","createdAt","updatedAt","db","updateGlobal","createGlobal","globalType","snapshot","selectMode","previousDoc","error"],"mappings":"AAiBA,SAASA,aAAa,QAAQ,8BAA6B;AAC3D,SAASC,WAAW,QAAQ,0CAAyC;AACrE,SAASC,SAAS,QAAQ,wCAAuC;AACjE,SAASC,YAAY,QAAQ,2CAA0C;AACvE,SAASC,cAAc,QAAQ,6CAA4C;AAC3E,SAASC,oBAAoB,QAAQ,iBAAgB;AACrD,SAASC,uBAAuB,QAAQ,6CAA4C;AACpF,SAASC,iBAAiB,QAAQ,uCAAsC;AACxE,SAASC,aAAa,QAAQ,mCAAkC;AAChE,SAASC,gBAAgB,EAAEC,yBAAyB,QAAQ,uCAAsC;AAClG,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,eAAe,QAAQ,qCAAoC;A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QAExC,IAAIR,aAAaU,KAAK,EAAEnC,WAAWqC,QAAQ;YACzC,KAAK,MAAMC,QAAQb,aAAaU,KAAK,CAACnC,SAAS,CAAE;gBAC/CiE,SACE,AAAC,MAAM3B,KAAK;oBACVC,SAAStB,IAAIsB,OAAO;oBACpBoB,KAAKM;oBACLzB,QAAQf;oBACRR;gBACF,MAAOgD;YACX;QACF;QAEA,wCAAwC;QACxC,uBAAuB;QACvB,wCAAwC;QAExCA,SAAS,MAAMlE,YAAY;YACzB2D,YAAY;YACZnB,SAAStB,IAAIsB,OAAO;YACpBG;YACAiB,KAAKM;YACLzB,QAAQf;YACRgB,WAAW;YACX2C,aAAa3B;YACbxC;QACF;QAEA,wCAAwC;QACxC,uBAAuB;QACvB,wCAAwC;QAExC,IAAIQ,aAAaU,KAAK,EAAEpC,aAAasC,QAAQ;YAC3C,KAAK,MAAMC,QAAQb,aAAaU,KAAK,CAACpC,WAAW,CAAE;gBACjDkE,SACE,AAAC,MAAM3B,KAAK;oBACVC,SAAStB,IAAIsB,OAAO;oBACpBG;oBACAiB,KAAKM;oBACLzB,QAAQf;oBACR2D,aAAa3B;oBACbxC;gBACF,MAAOgD;YACX;QACF;QAEA,wCAAwC;QACxC,iBAAiB;QACjB,wCAAwC;QAExC,IAAI/B,cAAc;YAChB,MAAM7B,kBAAkBY;QAC1B;QAEA,OAAOgD;IACT,EAAE,OAAOoB,OAAgB;QACvB,MAAM3E,gBAAgBO;QACtB,MAAMoE;IACR;AACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/globals/operations/update.ts"],"sourcesContent":["import type { DeepPartial } from 'ts-essentials'\n\nimport type { GlobalSlug, JsonObject } from '../../index.js'\nimport type {\n Operation,\n PayloadRequest,\n PopulateType,\n SelectType,\n TransformGlobalWithSelect,\n Where,\n} from '../../types/index.js'\nimport type {\n DataFromGlobalSlug,\n SanitizedGlobalConfig,\n SelectFromGlobalSlug,\n} from '../config/types.js'\n\nimport { executeAccess } from '../../auth/executeAccess.js'\nimport { afterChange } from '../../fields/hooks/afterChange/index.js'\nimport { afterRead } from '../../fields/hooks/afterRead/index.js'\nimport { beforeChange } from '../../fields/hooks/beforeChange/index.js'\nimport { beforeValidate } from '../../fields/hooks/beforeValidate/index.js'\nimport { deepCopyObjectSimple } from '../../index.js'\nimport { checkDocumentLockStatus } from '../../utilities/checkDocumentLockStatus.js'\nimport { commitTransaction } from '../../utilities/commitTransaction.js'\nimport { getSelectMode } from '../../utilities/getSelectMode.js'\nimport {\n hasDraftsEnabled,\n hasDraftValidationEnabled,\n hasLocalizeStatusEnabled,\n} from '../../utilities/getVersionsConfig.js'\nimport { initTransaction } from '../../utilities/initTransaction.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport { mergeLocalizedData } from '../../utilities/mergeLocalizedData.js'\nimport { sanitizeSelect } from '../../utilities/sanitizeSelect.js'\nimport { getLatestGlobalVersion } from '../../versions/getLatestGlobalVersion.js'\nimport { saveVersion } from '../../versions/saveVersion.js'\ntype Args<TSlug extends GlobalSlug> = {\n autosave?: boolean\n data: DeepPartial<Omit<DataFromGlobalSlug<TSlug>, 'id'>>\n depth?: number\n disableTransaction?: boolean\n draft?: boolean\n globalConfig: SanitizedGlobalConfig\n overrideAccess?: boolean\n overrideLock?: boolean\n populate?: PopulateType\n publishAllLocales?: boolean\n publishSpecificLocale?: string\n req: PayloadRequest\n select?: SelectType\n showHiddenFields?: boolean\n slug: string\n unpublishAllLocales?: boolean\n}\n\nexport const updateOperation = async <\n TSlug extends GlobalSlug,\n TSelect extends SelectFromGlobalSlug<TSlug>,\n>(\n args: Args<TSlug>,\n): Promise<TransformGlobalWithSelect<TSlug, TSelect>> => {\n if (args.publishSpecificLocale) {\n args.req.locale = args.publishSpecificLocale\n }\n\n const {\n slug,\n autosave,\n depth,\n disableTransaction,\n draft: draftArg,\n globalConfig,\n overrideAccess,\n overrideLock,\n populate,\n publishAllLocales: publishAllLocalesArg,\n publishSpecificLocale,\n req: { fallbackLocale, locale, payload, payload: { config } = {} },\n req,\n select: incomingSelect,\n showHiddenFields,\n unpublishAllLocales: unpublishAllLocalesArg,\n } = args\n\n try {\n const shouldCommit = !disableTransaction && (await initTransaction(req))\n\n // /////////////////////////////////////\n // beforeOperation - Global\n // /////////////////////////////////////\n\n if (globalConfig.hooks?.beforeOperation?.length) {\n for (const hook of globalConfig.hooks.beforeOperation) {\n args =\n (await hook({\n args,\n context: args.req.context,\n global: globalConfig,\n operation: 'update',\n req: args.req,\n })) || args\n }\n }\n\n let { data } = args\n\n const publishAllLocales =\n !draftArg && (publishAllLocalesArg ?? (hasLocalizeStatusEnabled(globalConfig) ? false : true))\n const unpublishAllLocales =\n typeof unpublishAllLocalesArg === 'string'\n ? unpublishAllLocalesArg === 'true'\n : !!unpublishAllLocalesArg\n const isSavingDraft =\n Boolean(draftArg && hasDraftsEnabled(globalConfig)) &&\n data._status !== 'published' &&\n !publishAllLocales\n\n if (isSavingDraft) {\n data._status = 'draft'\n }\n\n // /////////////////////////////////////\n // 1. Retrieve and execute access\n // /////////////////////////////////////\n\n const accessResults = !overrideAccess\n ? await executeAccess(\n {\n data,\n req,\n },\n globalConfig.access.update,\n )\n : true\n\n // /////////////////////////////////////\n // Retrieve document\n // /////////////////////////////////////\n\n const query: Where = overrideAccess ? undefined! : (accessResults as Where)\n\n // /////////////////////////////////////\n // 2. Retrieve document\n // /////////////////////////////////////\n const globalVersionResult = await getLatestGlobalVersion({\n slug,\n config: globalConfig,\n locale: locale!,\n payload,\n req,\n where: query,\n })\n const { global, globalExists } = globalVersionResult || {}\n\n let globalJSON: JsonObject = {}\n\n if (globalVersionResult && globalVersionResult.global) {\n globalJSON = deepCopyObjectSimple(global)\n\n if (globalJSON._id) {\n delete globalJSON._id\n }\n }\n\n const originalDoc = await afterRead({\n collection: null,\n context: req.context,\n depth: 0,\n doc: deepCopyObjectSimple(globalJSON),\n draft: draftArg!,\n fallbackLocale: fallbackLocale!,\n global: globalConfig,\n locale: locale!,\n overrideAccess: true,\n req,\n showHiddenFields: showHiddenFields!,\n })\n\n // ///////////////////////////////////////////\n // Handle potentially locked global documents\n // ///////////////////////////////////////////\n\n await checkDocumentLockStatus({\n globalSlug: slug,\n lockErrorMessage: `Global with slug \"${slug}\" is currently locked by another user and cannot be updated.`,\n overrideLock,\n req,\n })\n\n // /////////////////////////////////////\n // beforeValidate - Fields\n // /////////////////////////////////////\n\n data = await beforeValidate({\n collection: null,\n context: req.context,\n data,\n doc: originalDoc,\n global: globalConfig,\n operation: 'update',\n overrideAccess: overrideAccess!,\n req,\n })\n\n // /////////////////////////////////////\n // beforeValidate - Global\n // /////////////////////////////////////\n\n if (globalConfig.hooks?.beforeValidate?.length) {\n for (const hook of globalConfig.hooks.beforeValidate) {\n data =\n (await hook({\n context: req.context,\n data,\n global: globalConfig,\n originalDoc,\n req,\n })) || data\n }\n }\n\n // /////////////////////////////////////\n // beforeChange - Global\n // /////////////////////////////////////\n\n if (globalConfig.hooks?.beforeChange?.length) {\n for (const hook of globalConfig.hooks.beforeChange) {\n data =\n (await hook({\n context: req.context,\n data,\n global: globalConfig,\n originalDoc,\n req,\n })) || data\n }\n }\n\n // /////////////////////////////////////\n // beforeChange - Fields\n // /////////////////////////////////////\n\n const beforeChangeArgs = {\n collection: null,\n context: req.context,\n data,\n doc: originalDoc,\n docWithLocales: globalJSON,\n global: globalConfig,\n operation: 'update' as Operation,\n req,\n skipValidation: isSavingDraft && !hasDraftValidationEnabled(globalConfig),\n }\n\n let result: JsonObject = await beforeChange(beforeChangeArgs)\n let snapshotToSave: JsonObject | undefined\n\n // /////////////////////////////////////\n // Handle Localized Data Merging\n // /////////////////////////////////////\n\n if (config && config.localization && globalConfig.versions) {\n let currentGlobal: JsonObject | null = null\n let snapshotData: JsonObject | undefined\n\n if (globalConfig.versions.drafts && globalConfig.versions.drafts.localizeStatus) {\n if (publishAllLocales || unpublishAllLocales) {\n let accessibleLocaleCodes = config.localization.localeCodes\n\n if (config.localization.filterAvailableLocales) {\n const filteredLocales = await config.localization.filterAvailableLocales({\n locales: config.localization.locales,\n req,\n })\n accessibleLocaleCodes = filteredLocales.map((locale) =>\n typeof locale === 'string' ? locale : locale.code,\n )\n }\n\n if (typeof result._status !== 'object' || result._status === null) {\n result._status = {}\n }\n\n for (const localeCode of accessibleLocaleCodes) {\n result._status[localeCode] = unpublishAllLocales ? 'draft' : 'published'\n }\n } else if (!isSavingDraft) {\n // publishing a single locale\n currentGlobal = await payload.db.findGlobal({\n slug: globalConfig.slug,\n req,\n where: query,\n })\n snapshotData = result\n }\n } else if (publishSpecificLocale) {\n // previous way of publishing a single locale\n currentGlobal = (\n await getLatestGlobalVersion({\n slug,\n config: globalConfig,\n payload,\n published: true,\n req,\n where: query,\n })\n ).global\n snapshotData = {\n ...result,\n _status: 'draft',\n }\n }\n\n if (snapshotData) {\n snapshotToSave = deepCopyObjectSimple(snapshotData)\n\n result = mergeLocalizedData({\n configBlockReferences: config.blocks,\n dataWithLocales: result || {},\n docWithLocales: currentGlobal || {},\n fields: globalConfig.fields,\n selectedLocales: [locale!],\n })\n }\n }\n // /////////////////////////////////////\n // Update\n // /////////////////////////////////////\n\n const select = sanitizeSelect({\n fields: globalConfig.flattenedFields,\n forceSelect: globalConfig.forceSelect,\n select: incomingSelect,\n })\n\n if (!isSavingDraft) {\n const now = new Date().toISOString()\n // Ensure global has createdAt\n if (!result.createdAt) {\n result.createdAt = now\n }\n\n // Ensure updatedAt date is always updated\n result.updatedAt = now\n\n if (globalExists) {\n result = await payload.db.updateGlobal({\n slug,\n data: result,\n req,\n select,\n })\n } else {\n result = await payload.db.createGlobal({\n slug,\n data: result,\n req,\n })\n }\n }\n\n // /////////////////////////////////////\n // Create version\n // /////////////////////////////////////\n if (globalConfig.versions) {\n const { globalType } = result\n result = await saveVersion({\n autosave,\n docWithLocales: result,\n draft: isSavingDraft,\n global: globalConfig,\n operation: 'update',\n payload,\n publishSpecificLocale,\n req,\n select,\n snapshot: snapshotToSave,\n })\n\n result = {\n ...result,\n globalType,\n }\n }\n\n // /////////////////////////////////////\n // Execute globalType field if not selected\n // /////////////////////////////////////\n if (select && result.globalType) {\n const selectMode = getSelectMode(select)\n if (\n (selectMode === 'include' && !select['globalType']) ||\n (selectMode === 'exclude' && select['globalType'] === false)\n ) {\n delete result['globalType']\n }\n }\n\n // /////////////////////////////////////\n // afterRead - Fields\n // /////////////////////////////////////\n\n result = await afterRead({\n collection: null,\n context: req.context,\n depth: depth!,\n doc: result,\n draft: draftArg!,\n fallbackLocale: null,\n global: globalConfig,\n locale: locale!,\n overrideAccess: overrideAccess!,\n populate,\n req,\n select,\n showHiddenFields: showHiddenFields!,\n })\n\n // /////////////////////////////////////\n // afterRead - Global\n // /////////////////////////////////////\n\n if (globalConfig.hooks?.afterRead?.length) {\n for (const hook of globalConfig.hooks.afterRead) {\n result =\n (await hook({\n context: req.context,\n doc: result,\n global: globalConfig,\n req,\n })) || result\n }\n }\n\n // /////////////////////////////////////\n // afterChange - Fields\n // /////////////////////////////////////\n\n result = await afterChange({\n collection: null,\n context: req.context,\n data,\n doc: result,\n global: globalConfig,\n operation: 'update',\n previousDoc: originalDoc,\n req,\n })\n\n // /////////////////////////////////////\n // afterChange - Global\n // /////////////////////////////////////\n\n if (globalConfig.hooks?.afterChange?.length) {\n for (const hook of globalConfig.hooks.afterChange) {\n result =\n (await hook({\n context: req.context,\n data,\n doc: result,\n global: globalConfig,\n previousDoc: originalDoc,\n req,\n })) || result\n }\n }\n\n // /////////////////////////////////////\n // Return results\n // /////////////////////////////////////\n\n if (shouldCommit) {\n await commitTransaction(req)\n }\n\n return result as TransformGlobalWithSelect<TSlug, TSelect>\n } catch (error: unknown) {\n await killTransaction(req)\n throw error\n }\n}\n"],"names":["executeAccess","afterChange","afterRead","beforeChange","beforeValidate","deepCopyObjectSimple","checkDocumentLockStatus","commitTransaction","getSelectMode","hasDraftsEnabled","hasDraftValidationEnabled","hasLocalizeStatusEnabled","initTransaction","killTransaction","mergeLocalizedData","sanitizeSelect","getLatestGlobalVersion","saveVersion","updateOperation","args","publishSpecificLocale","req","locale","slug","autosave","depth","disableTransaction","draft","draftArg","globalConfig","overrideAccess","overrideLock","populate","publishAllLocales","publishAllLocalesArg","fallbackLocale","payload","config","select","incomingSelect","showHiddenFields","unpublishAllLocales","unpublishAllLocalesArg","shouldCommit","hooks","beforeOperation","length","hook","context","global","operation","data","isSavingDraft","Boolean","_status","accessResults","access","update","query","undefined","globalVersionResult","where","globalExists","globalJSON","_id","originalDoc","collection","doc","globalSlug","lockErrorMessage","beforeChangeArgs","docWithLocales","skipValidation","result","snapshotToSave","localization","versions","currentGlobal","snapshotData","drafts","localizeStatus","accessibleLocaleCodes","localeCodes","filterAvailableLocales","filteredLocales","locales","map","code","localeCode","db","findGlobal","published","configBlockReferences","blocks","dataWithLocales","fields","selectedLocales","flattenedFields","forceSelect","now","Date","toISOString","createdAt","updatedAt","updateGlobal","createGlobal","globalType","snapshot","selectMode","previousDoc","error"],"mappings":"AAiBA,SAASA,aAAa,QAAQ,8BAA6B;AAC3D,SAASC,WAAW,QAAQ,0CAAyC;AACrE,SAASC,SAAS,QAAQ,wCAAuC;AACjE,SAASC,YAAY,QAAQ,2CAA0C;AACvE,SAASC,cAAc,QAAQ,6CAA4C;AAC3E,SAASC,oBAAoB,QAAQ,iBAAgB;AACrD,SAASC,uBAAuB,QAAQ,6CAA4C;AACpF,SAASC,iBAAiB,QAAQ,uCAAsC;AACxE,SAASC,aAAa,QAAQ,mCAAkC;AAChE,SACEC,gBAAgB,EAChBC,yBAAyB,EACzBC,wBAAwB,QACnB,uCAAsC;AAC7C,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,kBAAkB,QAAQ,wCAAuC;AAC1E,SAASC,cAAc,QAAQ,oCAAmC;AAClE,SAASC,sBAAsB,QAAQ,2CAA0C;AACjF,SAASC,WAAW,QAAQ,gCAA+B;AAoB3D,OAAO,MAAMC,kBAAkB,OAI7BC;IAEA,IAAIA,KA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