payload 3.0.0-beta.75 → 3.0.0-beta.77
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getLocalizedPaths.d.ts","sourceRoot":"","sources":["../../src/database/getLocalizedPaths.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAA;AACtD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAK7D,wBAAsB,iBAAiB,CAAC,EACtC,cAAc,EACd,MAAM,EACN,UAAU,EACV,YAAY,EACZ,MAAM,EACN,cAAsB,EACtB,OAAO,GACR,EAAE;IACD,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,MAAM,CAAA;IACpB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,OAAO,EAAE,OAAO,CAAA;CACjB,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"getLocalizedPaths.d.ts","sourceRoot":"","sources":["../../src/database/getLocalizedPaths.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAA;AACtD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAK7D,wBAAsB,iBAAiB,CAAC,EACtC,cAAc,EACd,MAAM,EACN,UAAU,EACV,YAAY,EACZ,MAAM,EACN,cAAsB,EACtB,OAAO,GACR,EAAE;IACD,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,MAAM,CAAA;IACpB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,OAAO,EAAE,OAAO,CAAA;CACjB,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAiJzB"}
|
|
@@ -74,9 +74,9 @@ export async function getLocalizedPaths({ collectionSlug, fields, globalSlug, in
|
|
|
74
74
|
'relationTo',
|
|
75
75
|
'value'
|
|
76
76
|
].includes(pathSegments[pathSegments.length - 1]) || pathSegments.length === 1;
|
|
77
|
+
lastIncompletePath.path = pathSegments.join('.');
|
|
77
78
|
if (lastSegmentIsValid) {
|
|
78
79
|
lastIncompletePath.complete = true;
|
|
79
|
-
lastIncompletePath.path = pathSegments.join('.');
|
|
80
80
|
} else {
|
|
81
81
|
lastIncompletePath.invalid = true;
|
|
82
82
|
return paths;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/database/getLocalizedPaths.ts"],"sourcesContent":["import type { Field } from '../fields/config/types.js'\nimport type { Payload } from '../index.js'\nimport type { PathToQuery } from './queryValidation/types.js'\n\nimport { fieldAffectsData } from '../fields/config/types.js'\nimport flattenFields from '../utilities/flattenTopLevelFields.js'\n\nexport async function getLocalizedPaths({\n collectionSlug,\n fields,\n globalSlug,\n incomingPath,\n locale,\n overrideAccess = false,\n payload,\n}: {\n collectionSlug?: string\n fields: Field[]\n globalSlug?: string\n incomingPath: string\n locale?: string\n overrideAccess?: boolean\n payload: Payload\n}): Promise<PathToQuery[]> {\n const pathSegments = incomingPath.split('.')\n const localizationConfig = payload.config.localization\n\n let paths: PathToQuery[] = [\n {\n collectionSlug,\n complete: false,\n field: undefined,\n fields: flattenFields(fields, false),\n globalSlug,\n invalid: false,\n path: '',\n },\n ]\n\n for (let i = 0; i < pathSegments.length; i += 1) {\n const segment = pathSegments[i]\n\n const lastIncompletePath = paths.find(({ complete }) => !complete)\n\n if (lastIncompletePath) {\n const { path } = lastIncompletePath\n let currentPath = path ? `${path}.${segment}` : segment\n\n const matchedField = lastIncompletePath.fields.find(\n (field) => fieldAffectsData(field) && field.name === segment,\n )\n lastIncompletePath.field = matchedField\n\n if (currentPath === 'globalType' && globalSlug) {\n lastIncompletePath.path = currentPath\n lastIncompletePath.complete = true\n lastIncompletePath.field = {\n name: 'globalType',\n type: 'text',\n }\n\n return paths\n }\n\n if (!matchedField && currentPath === 'id' && i === pathSegments.length - 1) {\n lastIncompletePath.path = currentPath\n const idField: Field = {\n name: 'id',\n type: payload.db.defaultIDType as 'text',\n }\n lastIncompletePath.field = idField\n lastIncompletePath.complete = true\n return paths\n }\n\n if (matchedField) {\n if ('hidden' in matchedField && matchedField.hidden && !overrideAccess) {\n lastIncompletePath.invalid = true\n }\n\n const nextSegment = pathSegments[i + 1]\n const nextSegmentIsLocale =\n localizationConfig && localizationConfig.localeCodes.includes(nextSegment)\n\n if (nextSegmentIsLocale) {\n // Skip the next iteration, because it's a locale\n i += 1\n currentPath = `${currentPath}.${nextSegment}`\n } else if (localizationConfig && 'localized' in matchedField && matchedField.localized) {\n currentPath = `${currentPath}.${locale}`\n }\n\n switch (matchedField.type) {\n case 'blocks':\n case 'richText':\n case 'json': {\n const upcomingSegments = pathSegments.slice(i + 1).join('.')\n lastIncompletePath.complete = true\n lastIncompletePath.path = upcomingSegments\n ? `${currentPath}.${upcomingSegments}`\n : currentPath\n return paths\n }\n\n case 'relationship':\n case 'upload': {\n // If this is a polymorphic relation,\n // We only support querying directly (no nested querying)\n if (typeof matchedField.relationTo !== 'string') {\n const lastSegmentIsValid =\n ['relationTo', 'value'].includes(pathSegments[pathSegments.length - 1]) ||\n pathSegments.length === 1\n\n if (lastSegmentIsValid) {\n lastIncompletePath.complete = true\n
|
|
1
|
+
{"version":3,"sources":["../../src/database/getLocalizedPaths.ts"],"sourcesContent":["import type { Field } from '../fields/config/types.js'\nimport type { Payload } from '../index.js'\nimport type { PathToQuery } from './queryValidation/types.js'\n\nimport { fieldAffectsData } from '../fields/config/types.js'\nimport flattenFields from '../utilities/flattenTopLevelFields.js'\n\nexport async function getLocalizedPaths({\n collectionSlug,\n fields,\n globalSlug,\n incomingPath,\n locale,\n overrideAccess = false,\n payload,\n}: {\n collectionSlug?: string\n fields: Field[]\n globalSlug?: string\n incomingPath: string\n locale?: string\n overrideAccess?: boolean\n payload: Payload\n}): Promise<PathToQuery[]> {\n const pathSegments = incomingPath.split('.')\n const localizationConfig = payload.config.localization\n\n let paths: PathToQuery[] = [\n {\n collectionSlug,\n complete: false,\n field: undefined,\n fields: flattenFields(fields, false),\n globalSlug,\n invalid: false,\n path: '',\n },\n ]\n\n for (let i = 0; i < pathSegments.length; i += 1) {\n const segment = pathSegments[i]\n\n const lastIncompletePath = paths.find(({ complete }) => !complete)\n\n if (lastIncompletePath) {\n const { path } = lastIncompletePath\n let currentPath = path ? `${path}.${segment}` : segment\n\n const matchedField = lastIncompletePath.fields.find(\n (field) => fieldAffectsData(field) && field.name === segment,\n )\n lastIncompletePath.field = matchedField\n\n if (currentPath === 'globalType' && globalSlug) {\n lastIncompletePath.path = currentPath\n lastIncompletePath.complete = true\n lastIncompletePath.field = {\n name: 'globalType',\n type: 'text',\n }\n\n return paths\n }\n\n if (!matchedField && currentPath === 'id' && i === pathSegments.length - 1) {\n lastIncompletePath.path = currentPath\n const idField: Field = {\n name: 'id',\n type: payload.db.defaultIDType as 'text',\n }\n lastIncompletePath.field = idField\n lastIncompletePath.complete = true\n return paths\n }\n\n if (matchedField) {\n if ('hidden' in matchedField && matchedField.hidden && !overrideAccess) {\n lastIncompletePath.invalid = true\n }\n\n const nextSegment = pathSegments[i + 1]\n const nextSegmentIsLocale =\n localizationConfig && localizationConfig.localeCodes.includes(nextSegment)\n\n if (nextSegmentIsLocale) {\n // Skip the next iteration, because it's a locale\n i += 1\n currentPath = `${currentPath}.${nextSegment}`\n } else if (localizationConfig && 'localized' in matchedField && matchedField.localized) {\n currentPath = `${currentPath}.${locale}`\n }\n\n switch (matchedField.type) {\n case 'blocks':\n case 'richText':\n case 'json': {\n const upcomingSegments = pathSegments.slice(i + 1).join('.')\n lastIncompletePath.complete = true\n lastIncompletePath.path = upcomingSegments\n ? `${currentPath}.${upcomingSegments}`\n : currentPath\n return paths\n }\n\n case 'relationship':\n case 'upload': {\n // If this is a polymorphic relation,\n // We only support querying directly (no nested querying)\n if (typeof matchedField.relationTo !== 'string') {\n const lastSegmentIsValid =\n ['relationTo', 'value'].includes(pathSegments[pathSegments.length - 1]) ||\n pathSegments.length === 1\n\n lastIncompletePath.path = pathSegments.join('.')\n\n if (lastSegmentIsValid) {\n lastIncompletePath.complete = true\n } else {\n lastIncompletePath.invalid = true\n return paths\n }\n } else {\n lastIncompletePath.complete = true\n lastIncompletePath.path = currentPath\n\n const nestedPathToQuery = pathSegments\n .slice(nextSegmentIsLocale ? i + 2 : i + 1)\n .join('.')\n\n if (nestedPathToQuery) {\n const relatedCollection = payload.collections[matchedField.relationTo].config\n\n const remainingPaths = await getLocalizedPaths({\n collectionSlug: relatedCollection.slug,\n fields: relatedCollection.fields,\n globalSlug,\n incomingPath: nestedPathToQuery,\n locale,\n payload,\n })\n\n paths = [...paths, ...remainingPaths]\n }\n\n return paths\n }\n\n break\n }\n\n default: {\n if ('fields' in lastIncompletePath.field) {\n lastIncompletePath.fields = flattenFields(lastIncompletePath.field.fields, false)\n }\n\n if (i + 1 === pathSegments.length) lastIncompletePath.complete = true\n lastIncompletePath.path = currentPath\n }\n }\n } else {\n lastIncompletePath.invalid = true\n lastIncompletePath.path = currentPath\n return paths\n }\n }\n }\n\n return paths\n}\n"],"names":["fieldAffectsData","flattenFields","getLocalizedPaths","collectionSlug","fields","globalSlug","incomingPath","locale","overrideAccess","payload","pathSegments","split","localizationConfig","config","localization","paths","complete","field","undefined","invalid","path","i","length","segment","lastIncompletePath","find","currentPath","matchedField","name","type","idField","db","defaultIDType","hidden","nextSegment","nextSegmentIsLocale","localeCodes","includes","localized","upcomingSegments","slice","join","relationTo","lastSegmentIsValid","nestedPathToQuery","relatedCollection","collections","remainingPaths","slug"],"mappings":"AAIA,SAASA,gBAAgB,QAAQ,4BAA2B;AAC5D,OAAOC,mBAAmB,wCAAuC;AAEjE,OAAO,eAAeC,kBAAkB,EACtCC,cAAc,EACdC,MAAM,EACNC,UAAU,EACVC,YAAY,EACZC,MAAM,EACNC,iBAAiB,KAAK,EACtBC,OAAO,EASR;IACC,MAAMC,eAAeJ,aAAaK,KAAK,CAAC;IACxC,MAAMC,qBAAqBH,QAAQI,MAAM,CAACC,YAAY;IAEtD,IAAIC,QAAuB;QACzB;YACEZ;YACAa,UAAU;YACVC,OAAOC;YACPd,QAAQH,cAAcG,QAAQ;YAC9BC;YACAc,SAAS;YACTC,MAAM;QACR;KACD;IAED,IAAK,IAAIC,IAAI,GAAGA,IAAIX,aAAaY,MAAM,EAAED,KAAK,EAAG;QAC/C,MAAME,UAAUb,YAAY,CAACW,EAAE;QAE/B,MAAMG,qBAAqBT,MAAMU,IAAI,CAAC,CAAC,EAAET,QAAQ,EAAE,GAAK,CAACA;QAEzD,IAAIQ,oBAAoB;YACtB,MAAM,EAAEJ,IAAI,EAAE,GAAGI;YACjB,IAAIE,cAAcN,OAAO,CAAC,EAAEA,KAAK,CAAC,EAAEG,QAAQ,CAAC,GAAGA;YAEhD,MAAMI,eAAeH,mBAAmBpB,MAAM,CAACqB,IAAI,CACjD,CAACR,QAAUjB,iBAAiBiB,UAAUA,MAAMW,IAAI,KAAKL;YAEvDC,mBAAmBP,KAAK,GAAGU;YAE3B,IAAID,gBAAgB,gBAAgBrB,YAAY;gBAC9CmB,mBAAmBJ,IAAI,GAAGM;gBAC1BF,mBAAmBR,QAAQ,GAAG;gBAC9BQ,mBAAmBP,KAAK,GAAG;oBACzBW,MAAM;oBACNC,MAAM;gBACR;gBAEA,OAAOd;YACT;YAEA,IAAI,CAACY,gBAAgBD,gBAAgB,QAAQL,MAAM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.77",
|
|
4
4
|
"description": "Node, React, Headless CMS and Application Framework built on Next.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"admin panel",
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
"scmp": "2.1.0",
|
|
97
97
|
"ts-essentials": "7.0.3",
|
|
98
98
|
"uuid": "10.0.0",
|
|
99
|
-
"@payloadcms/translations": "3.0.0-beta.
|
|
99
|
+
"@payloadcms/translations": "3.0.0-beta.77"
|
|
100
100
|
},
|
|
101
101
|
"devDependencies": {
|
|
102
102
|
"@hyrious/esbuild-plugin-commonjs": "^0.2.4",
|