@strapi/core 5.55.1 → 5.56.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/package.json.js +15 -15
- package/dist/package.json.mjs +15 -15
- package/dist/services/content-structure/index.js +1 -1
- package/dist/services/content-structure/index.js.map +1 -1
- package/dist/services/content-structure/index.mjs +1 -1
- package/dist/services/content-structure/index.mjs.map +1 -1
- package/package.json +15 -15
package/dist/package.json.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var name = "@strapi/core";
|
|
6
|
-
var version = "5.
|
|
6
|
+
var version = "5.56.0";
|
|
7
7
|
var description = "Core of Strapi";
|
|
8
8
|
var homepage = "https://strapi.io";
|
|
9
9
|
var bugs = {
|
|
@@ -66,15 +66,15 @@ var dependencies = {
|
|
|
66
66
|
"@modelcontextprotocol/node": "2.0.0",
|
|
67
67
|
"@modelcontextprotocol/server": "2.0.0",
|
|
68
68
|
"@paralleldrive/cuid2": "2.2.2",
|
|
69
|
-
"@strapi/admin": "5.
|
|
70
|
-
"@strapi/database": "5.
|
|
71
|
-
"@strapi/generators": "5.
|
|
72
|
-
"@strapi/logger": "5.
|
|
73
|
-
"@strapi/openapi": "5.
|
|
74
|
-
"@strapi/permissions": "5.
|
|
75
|
-
"@strapi/types": "5.
|
|
76
|
-
"@strapi/typescript-utils": "5.
|
|
77
|
-
"@strapi/utils": "5.
|
|
69
|
+
"@strapi/admin": "5.56.0",
|
|
70
|
+
"@strapi/database": "5.56.0",
|
|
71
|
+
"@strapi/generators": "5.56.0",
|
|
72
|
+
"@strapi/logger": "5.56.0",
|
|
73
|
+
"@strapi/openapi": "5.56.0",
|
|
74
|
+
"@strapi/permissions": "5.56.0",
|
|
75
|
+
"@strapi/types": "5.56.0",
|
|
76
|
+
"@strapi/typescript-utils": "5.56.0",
|
|
77
|
+
"@strapi/utils": "5.56.0",
|
|
78
78
|
"@vercel/stega": "0.1.2",
|
|
79
79
|
bcryptjs: "2.4.3",
|
|
80
80
|
boxen: "5.1.2",
|
|
@@ -112,11 +112,11 @@ var dependencies = {
|
|
|
112
112
|
ora: "5.4.1",
|
|
113
113
|
"package-json": "10.0.1",
|
|
114
114
|
"pkg-up": "3.1.0",
|
|
115
|
-
qs: "6.
|
|
115
|
+
qs: "6.16.0",
|
|
116
116
|
"resolve.exports": "2.0.2",
|
|
117
117
|
semver: "7.7.4",
|
|
118
118
|
typescript: "5.9.3",
|
|
119
|
-
undici: "6.
|
|
119
|
+
undici: "6.29.0",
|
|
120
120
|
yup: "0.32.9",
|
|
121
121
|
zod: "4.4.3"
|
|
122
122
|
};
|
|
@@ -140,12 +140,12 @@ var devDependencies = {
|
|
|
140
140
|
"@types/node": "20.19.41",
|
|
141
141
|
ajv: "8.20.0",
|
|
142
142
|
"ajv-formats": "3.0.1",
|
|
143
|
-
"eslint-config-custom": "5.
|
|
143
|
+
"eslint-config-custom": "5.56.0",
|
|
144
144
|
jest: "29.6.0",
|
|
145
145
|
supertest: "7.2.2",
|
|
146
|
-
tsconfig: "5.
|
|
146
|
+
tsconfig: "5.56.0",
|
|
147
147
|
vitest: "catalog:",
|
|
148
|
-
"vitest-config": "5.
|
|
148
|
+
"vitest-config": "5.56.0"
|
|
149
149
|
};
|
|
150
150
|
var engines = {
|
|
151
151
|
node: ">=20.0.0 <=26.x.x",
|
package/dist/package.json.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var name = "@strapi/core";
|
|
2
|
-
var version = "5.
|
|
2
|
+
var version = "5.56.0";
|
|
3
3
|
var description = "Core of Strapi";
|
|
4
4
|
var homepage = "https://strapi.io";
|
|
5
5
|
var bugs = {
|
|
@@ -62,15 +62,15 @@ var dependencies = {
|
|
|
62
62
|
"@modelcontextprotocol/node": "2.0.0",
|
|
63
63
|
"@modelcontextprotocol/server": "2.0.0",
|
|
64
64
|
"@paralleldrive/cuid2": "2.2.2",
|
|
65
|
-
"@strapi/admin": "5.
|
|
66
|
-
"@strapi/database": "5.
|
|
67
|
-
"@strapi/generators": "5.
|
|
68
|
-
"@strapi/logger": "5.
|
|
69
|
-
"@strapi/openapi": "5.
|
|
70
|
-
"@strapi/permissions": "5.
|
|
71
|
-
"@strapi/types": "5.
|
|
72
|
-
"@strapi/typescript-utils": "5.
|
|
73
|
-
"@strapi/utils": "5.
|
|
65
|
+
"@strapi/admin": "5.56.0",
|
|
66
|
+
"@strapi/database": "5.56.0",
|
|
67
|
+
"@strapi/generators": "5.56.0",
|
|
68
|
+
"@strapi/logger": "5.56.0",
|
|
69
|
+
"@strapi/openapi": "5.56.0",
|
|
70
|
+
"@strapi/permissions": "5.56.0",
|
|
71
|
+
"@strapi/types": "5.56.0",
|
|
72
|
+
"@strapi/typescript-utils": "5.56.0",
|
|
73
|
+
"@strapi/utils": "5.56.0",
|
|
74
74
|
"@vercel/stega": "0.1.2",
|
|
75
75
|
bcryptjs: "2.4.3",
|
|
76
76
|
boxen: "5.1.2",
|
|
@@ -108,11 +108,11 @@ var dependencies = {
|
|
|
108
108
|
ora: "5.4.1",
|
|
109
109
|
"package-json": "10.0.1",
|
|
110
110
|
"pkg-up": "3.1.0",
|
|
111
|
-
qs: "6.
|
|
111
|
+
qs: "6.16.0",
|
|
112
112
|
"resolve.exports": "2.0.2",
|
|
113
113
|
semver: "7.7.4",
|
|
114
114
|
typescript: "5.9.3",
|
|
115
|
-
undici: "6.
|
|
115
|
+
undici: "6.29.0",
|
|
116
116
|
yup: "0.32.9",
|
|
117
117
|
zod: "4.4.3"
|
|
118
118
|
};
|
|
@@ -136,12 +136,12 @@ var devDependencies = {
|
|
|
136
136
|
"@types/node": "20.19.41",
|
|
137
137
|
ajv: "8.20.0",
|
|
138
138
|
"ajv-formats": "3.0.1",
|
|
139
|
-
"eslint-config-custom": "5.
|
|
139
|
+
"eslint-config-custom": "5.56.0",
|
|
140
140
|
jest: "29.6.0",
|
|
141
141
|
supertest: "7.2.2",
|
|
142
|
-
tsconfig: "5.
|
|
142
|
+
tsconfig: "5.56.0",
|
|
143
143
|
vitest: "catalog:",
|
|
144
|
-
"vitest-config": "5.
|
|
144
|
+
"vitest-config": "5.56.0"
|
|
145
145
|
};
|
|
146
146
|
var engines = {
|
|
147
147
|
node: ">=20.0.0 <=26.x.x",
|
|
@@ -16,7 +16,7 @@ const isRecord = (value)=>{
|
|
|
16
16
|
};
|
|
17
17
|
function createContentStructureService(strapi) {
|
|
18
18
|
/**
|
|
19
|
-
* This cache exists to ensure all consumers
|
|
19
|
+
* This cache exists to ensure all consumers receive the same cleaned+resolved data, regardless of call order / invocation relative to the strapi reload.
|
|
20
20
|
*/ let cache;
|
|
21
21
|
const warn = (message)=>{
|
|
22
22
|
strapi.log.warn(`[content-structure] ${message}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/services/content-structure/index.ts"],"sourcesContent":["import { join } from 'path';\nimport fse from 'fs-extra';\n\nimport type { Core, Modules, UID } from '@strapi/types';\nimport { isGroupExpressionValid } from './utils/isGroupExpressionValid';\nimport { contentStructureFileSchema } from './validation';\n\nexport const CONTENT_STRUCTURE_FILE_NAME = 'groups.json';\n\nexport const MAX_FOLDER_DEPTH = 3;\n\nexport interface ContentStructureService {\n /**\n * Reads the contents of groups.json directly with minimal sanitization.\n */\n read(): Promise<Modules.ContentStructure.ContentStructureFile | null>;\n\n /**\n * Yields an extremely tolerant version of the groups configuration file. Invalid references are repaired or ignored. Warnings fire for each repair/omission.\n */\n getCleanedFile(): Promise<Modules.ContentStructure.ContentStructureFile | null>;\n\n /**\n * Returns the groups configuration transformed into nested trees.\n */\n resolve(): Promise<Modules.ContentStructure.ResolvedContentStructure>;\n\n /**\n * Writes a new config and invalidates the cache. Does NOT perform validation - this is\n * left to the caller. The Save that triggers the write restarts the server via the\n * standard update-schema flow, which reloads the file; this method only persists it.\n */\n write(structure: Modules.ContentStructure.ContentStructureFile): Promise<void>;\n\n /**\n * Strictly validates an unknown value against the canonical groups.json schema; throws if invalid.\n */\n validate(value: unknown): Modules.ContentStructure.ContentStructureFile;\n\n /**\n * Invalidates the cached parsed groups.json file.\n */\n invalidate(): void;\n\n /**\n * Total number of groups across both sections of the cleaned file.\n */\n countGroups(): Promise<number>;\n}\n\nconst isRecord = (value: unknown): value is Record<string, unknown> => {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n};\n\ntype ContentStructureCache = Promise<{\n cleaned: Modules.ContentStructure.ContentStructureFile | null;\n resolved: Modules.ContentStructure.ResolvedContentStructure;\n}>;\n\nexport function createContentStructureService(strapi: Core.Strapi): ContentStructureService {\n /**\n * This cache exists to ensure all consumers recieve the same cleaned+resolved data, regardless of call order / invocation relative to the strapi reload.\n */\n let cache: ContentStructureCache | undefined;\n\n const warn = (message: string) => {\n strapi.log.warn(`[content-structure] ${message}`);\n };\n\n const cleanSection = (\n rawSection: unknown,\n sectionKey: Modules.ContentStructure.ContentStructureSectionKey\n ): Modules.ContentStructure.ContentStructureSection => {\n const rawGroups = (() => {\n if (rawSection === undefined || rawSection === null) {\n return [];\n }\n\n if (!isRecord(rawSection) || !Array.isArray(rawSection.groups)) {\n warn(`Section \"${sectionKey}\" is malformed; ignoring it`);\n return [];\n }\n\n return rawSection.groups;\n })();\n\n const seenGroupIds = new Map<string, Modules.ContentStructure.ContentStructureGroup>();\n const groups: Modules.ContentStructure.ContentStructureGroup[] = [];\n\n for (const raw of rawGroups) {\n if (!isGroupExpressionValid(raw)) {\n warn(`Dropping a malformed group entry in section \"${sectionKey}\"`);\n continue;\n }\n\n if (raw.name.trim() === '') {\n warn(`Dropping group \"${raw.id}\" in section \"${sectionKey}\": empty name`);\n continue;\n }\n\n if (seenGroupIds.has(raw.id)) {\n warn(`Dropping duplicate group id \"${raw.id}\" in section \"${sectionKey}\"`);\n continue;\n }\n\n const group: Modules.ContentStructure.ContentStructureGroup = {\n children: raw.children as Modules.ContentStructure.ContentStructureChild[],\n parent: raw.parent,\n name: raw.name,\n id: raw.id,\n };\n\n seenGroupIds.set(group.id, group);\n groups.push(group);\n }\n\n const reparentToRoot = (\n group: Modules.ContentStructure.ContentStructureGroup,\n reason: string\n ) => {\n group.parent = null;\n\n groups.splice(groups.indexOf(group), 1);\n groups.push(group);\n\n warn(`Reparenting group \"${group.id}\" in section \"${sectionKey}\" to root: ${reason}`);\n };\n\n // oxlint-disable-next-line - Duplicating is necessary because the original array is mutated inside the iterator.\n for (const group of [...groups]) {\n if (group.parent !== null && !seenGroupIds.has(group.parent)) {\n reparentToRoot(group, `parent \"${group.parent}\" does not exist`);\n }\n }\n\n // oxlint-disable-next-line - Duplicating is necessary because the original array is mutated inside the iterator.\n for (const group of [...groups]) {\n const chain = new Set([group.id]);\n let current = group;\n\n while (current.parent !== null) {\n if (chain.has(current.parent)) {\n reparentToRoot(group, 'its parent chain contains a cycle');\n break;\n }\n\n chain.add(current.parent);\n current = seenGroupIds.get(current.parent)!;\n }\n }\n\n // oxlint-disable-next-line - Duplicating is necessary because the original array is mutated inside the iterator.\n for (const group of [...groups]) {\n let current = group;\n let depth = 1;\n\n while (current.parent !== null) {\n current = seenGroupIds.get(current.parent)!;\n depth += 1;\n }\n\n if (depth > MAX_FOLDER_DEPTH) {\n reparentToRoot(group, `it exceeds the maximum nesting depth of ${MAX_FOLDER_DEPTH}`);\n }\n }\n\n const expectedKind = sectionKey === 'collectionTypes' ? 'collectionType' : 'singleType';\n const seenGroupChildren = new Set<string>();\n const seenUids = new Set<string>();\n\n for (const group of groups) {\n const cleanedChildren: Modules.ContentStructure.ContentStructureChild[] = [];\n\n for (const entry of group.children) {\n if (!isRecord(entry)) {\n warn(`Dropping a malformed child entry of group \"${group.id}\"`);\n continue;\n }\n\n if (entry.type === 'contentType') {\n const { uid } = entry;\n\n if (typeof uid !== 'string') {\n warn(`Dropping a contentType child of group \"${group.id}\": invalid uid`);\n continue;\n }\n\n const schema: { kind?: string } | undefined = strapi.contentTypes[uid as UID.ContentType];\n\n if (!schema) {\n warn(`Dropping unknown content type \"${uid}\" from group \"${group.id}\"`);\n continue;\n }\n\n // kind is optional on schemas; absent means collectionType.\n const kind = schema.kind ?? 'collectionType';\n\n if (kind !== expectedKind) {\n warn(\n `Dropping content type \"${uid}\" from group \"${group.id}\": its kind \"${kind}\" does not belong in section \"${sectionKey}\"`\n );\n continue;\n }\n\n if (seenUids.has(uid)) {\n warn(`Dropping duplicate reference to content type \"${uid}\" from group \"${group.id}\"`);\n continue;\n }\n\n cleanedChildren.push({ type: 'contentType', uid: uid as UID.ContentType });\n seenUids.add(uid);\n continue;\n }\n\n if (entry.type === 'group') {\n const { id } = entry;\n\n if (typeof id !== 'string') {\n warn(`Dropping a group child of group \"${group.id}\": invalid id`);\n continue;\n }\n\n const target = seenGroupIds.get(id);\n\n if (!target || target.parent !== group.id) {\n warn(`Dropping group child \"${id}\" from group \"${group.id}\": inconsistent reference`);\n continue;\n }\n\n if (seenGroupChildren.has(id)) {\n warn(`Dropping duplicate group child \"${id}\" from group \"${group.id}\"`);\n continue;\n }\n\n cleanedChildren.push({ type: 'group', id });\n seenGroupChildren.add(id);\n continue;\n }\n\n warn(`Dropping a child entry of group \"${group.id}\" with an unknown type`);\n }\n\n group.children = cleanedChildren;\n }\n\n for (const group of groups) {\n if (group.parent !== null && !seenGroupChildren.has(group.id)) {\n const parent = seenGroupIds.get(group.parent)!;\n\n parent.children.push({ type: 'group', id: group.id });\n seenGroupChildren.add(group.id);\n\n warn(\n `Group \"${group.id}\" was missing from the children of its parent \"${parent.id}\"; appended it`\n );\n }\n }\n\n return { groups };\n };\n\n const resolveSection = (\n section: Modules.ContentStructure.ContentStructureSection\n ): Modules.ContentStructure.ResolvedGroupNode[] => {\n const byId = new Map(section.groups.map((group) => [group.id, group]));\n\n const toNode = (\n group: Modules.ContentStructure.ContentStructureGroup\n ): Modules.ContentStructure.ResolvedGroupNode => {\n const cleanedChildren = group.children.map(\n (entry): Modules.ContentStructure.ResolvedStructureChild => {\n if (entry.type === 'contentType') {\n return { type: 'contentType', uid: entry.uid };\n }\n\n return toNode(byId.get(entry.id)!);\n }\n );\n\n return {\n children: cleanedChildren,\n name: group.name,\n type: 'group',\n id: group.id,\n };\n };\n\n return section.groups.filter((group) => group.parent === null).map(toNode);\n };\n\n async function read(): Promise<Modules.ContentStructure.ContentStructureFile | null> {\n const filePath = join(strapi.dirs.dist.contentStructure, CONTENT_STRUCTURE_FILE_NAME);\n\n if (!(await fse.pathExists(filePath))) {\n return null;\n }\n\n let parsed: unknown;\n try {\n parsed = await fse.readJSON(filePath);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n\n strapi.log.error(\n `[content-structure] Could not parse ${filePath} (${message}); continuing without content-type folders`\n );\n\n return null;\n }\n\n if (!isRecord(parsed) || !isRecord(parsed.sections)) {\n strapi.log.error(\n `[content-structure] ${filePath} is not an object with a \"sections\" property; continuing without content-type folders`\n );\n return null;\n }\n\n if (parsed.version !== 1) {\n strapi.log.error(\n `[content-structure] Unknown version \"${parsed.version}\" in ${filePath} (expected 1); continuing without content-type folders`\n );\n return null;\n }\n\n return parsed as unknown as Modules.ContentStructure.ContentStructureFile;\n }\n\n const load = () => {\n if (!cache) {\n cache = (async () => {\n const file = await read();\n\n if (!file) {\n return { cleaned: null, resolved: { collectionTypes: [], singleTypes: [] } };\n }\n\n const cleaned: Modules.ContentStructure.ContentStructureFile = {\n version: 1,\n sections: {\n collectionTypes: cleanSection(file.sections.collectionTypes, 'collectionTypes'),\n singleTypes: cleanSection(file.sections.singleTypes, 'singleTypes'),\n },\n };\n\n return {\n cleaned,\n resolved: {\n collectionTypes: resolveSection(cleaned.sections.collectionTypes),\n singleTypes: resolveSection(cleaned.sections.singleTypes),\n },\n };\n })();\n }\n\n return cache;\n };\n\n function invalidate() {\n cache = undefined;\n }\n\n async function getCleanedFile() {\n return (await load()).cleaned;\n }\n\n async function resolve() {\n return (await load()).resolved;\n }\n\n async function write(structure: Modules.ContentStructure.ContentStructureFile) {\n const dir = strapi.dirs.app.contentStructure;\n\n await fse.ensureDir(dir);\n await fse.writeJSON(join(dir, CONTENT_STRUCTURE_FILE_NAME), structure, { spaces: 2 });\n\n invalidate();\n }\n\n function validate(value: unknown): Modules.ContentStructure.ContentStructureFile {\n return contentStructureFileSchema.parse(value) as Modules.ContentStructure.ContentStructureFile;\n }\n\n async function countGroups() {\n const { cleaned } = await load();\n\n if (!cleaned) {\n return 0;\n }\n\n const collectionTypesCount = cleaned.sections.collectionTypes.groups.length;\n const singleTypesCount = cleaned.sections.singleTypes.groups.length;\n\n return collectionTypesCount + singleTypesCount;\n }\n\n return {\n getCleanedFile,\n countGroups,\n invalidate,\n validate,\n resolve,\n write,\n read,\n };\n}\n"],"names":["CONTENT_STRUCTURE_FILE_NAME","MAX_FOLDER_DEPTH","isRecord","value","Array","isArray","createContentStructureService","strapi","cache","warn","message","log","cleanSection","rawSection","sectionKey","rawGroups","undefined","groups","seenGroupIds","Map","raw","isGroupExpressionValid","name","trim","id","has","group","children","parent","set","push","reparentToRoot","reason","splice","indexOf","chain","Set","current","add","get","depth","expectedKind","seenGroupChildren","seenUids","cleanedChildren","entry","type","uid","schema","contentTypes","kind","target","resolveSection","section","byId","map","toNode","filter","read","filePath","join","dirs","dist","contentStructure","fse","pathExists","parsed","readJSON","error","Error","String","sections","version","load","file","cleaned","resolved","collectionTypes","singleTypes","invalidate","getCleanedFile","resolve","write","structure","dir","app","ensureDir","writeJSON","spaces","validate","contentStructureFileSchema","parse","countGroups","collectionTypesCount","length","singleTypesCount"],"mappings":";;;;;;;;;;;AAOO,MAAMA,8BAA8B;AAEpC,MAAMC,mBAAmB;AAyChC,MAAMC,WAAW,CAACC,KAAAA,GAAAA;IAChB,OAAO,OAAOA,UAAU,QAAA,IAAYA,KAAAA,KAAU,QAAQ,CAACC,KAAAA,CAAMC,OAAO,CAACF,KAAAA,CAAAA;AACvE,CAAA;AAOO,SAASG,8BAA8BC,MAAmB,EAAA;AAC/D;;AAEC,MACD,IAAIC,KA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YACZ,OAAO,CAAA;AACT,QAAA;QAEA,MAAMkB,oBAAAA,GAAuBlB,QAAQJ,QAAQ,CAACM,eAAe,CAAC5D,MAAM,CAAC6E,MAAM;QAC3E,MAAMC,gBAAAA,GAAmBpB,QAAQJ,QAAQ,CAACO,WAAW,CAAC7D,MAAM,CAAC6E,MAAM;AAEnE,QAAA,OAAOD,oBAAAA,GAAuBE,gBAAAA;AAChC,IAAA;IAEA,OAAO;AACLf,QAAAA,cAAAA;AACAY,QAAAA,WAAAA;AACAb,QAAAA,UAAAA;AACAU,QAAAA,QAAAA;AACAR,QAAAA,OAAAA;AACAC,QAAAA,KAAAA;AACAxB,QAAAA;AACF,KAAA;AACF;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/services/content-structure/index.ts"],"sourcesContent":["import { join } from 'path';\nimport fse from 'fs-extra';\n\nimport type { Core, Modules, UID } from '@strapi/types';\nimport { isGroupExpressionValid } from './utils/isGroupExpressionValid';\nimport { contentStructureFileSchema } from './validation';\n\nexport const CONTENT_STRUCTURE_FILE_NAME = 'groups.json';\n\nexport const MAX_FOLDER_DEPTH = 3;\n\nexport interface ContentStructureService {\n /**\n * Reads the contents of groups.json directly with minimal sanitization.\n */\n read(): Promise<Modules.ContentStructure.ContentStructureFile | null>;\n\n /**\n * Yields an extremely tolerant version of the groups configuration file. Invalid references are repaired or ignored. Warnings fire for each repair/omission.\n */\n getCleanedFile(): Promise<Modules.ContentStructure.ContentStructureFile | null>;\n\n /**\n * Returns the groups configuration transformed into nested trees.\n */\n resolve(): Promise<Modules.ContentStructure.ResolvedContentStructure>;\n\n /**\n * Writes a new config and invalidates the cache. Does NOT perform validation - this is\n * left to the caller. The Save that triggers the write restarts the server via the\n * standard update-schema flow, which reloads the file; this method only persists it.\n */\n write(structure: Modules.ContentStructure.ContentStructureFile): Promise<void>;\n\n /**\n * Strictly validates an unknown value against the canonical groups.json schema; throws if invalid.\n */\n validate(value: unknown): Modules.ContentStructure.ContentStructureFile;\n\n /**\n * Invalidates the cached parsed groups.json file.\n */\n invalidate(): void;\n\n /**\n * Total number of groups across both sections of the cleaned file.\n */\n countGroups(): Promise<number>;\n}\n\nconst isRecord = (value: unknown): value is Record<string, unknown> => {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n};\n\ntype ContentStructureCache = Promise<{\n cleaned: Modules.ContentStructure.ContentStructureFile | null;\n resolved: Modules.ContentStructure.ResolvedContentStructure;\n}>;\n\nexport function createContentStructureService(strapi: Core.Strapi): ContentStructureService {\n /**\n * This cache exists to ensure all consumers receive the same cleaned+resolved data, regardless of call order / invocation relative to the strapi reload.\n */\n let cache: ContentStructureCache | undefined;\n\n const warn = (message: string) => {\n strapi.log.warn(`[content-structure] ${message}`);\n };\n\n const cleanSection = (\n rawSection: unknown,\n sectionKey: Modules.ContentStructure.ContentStructureSectionKey\n ): Modules.ContentStructure.ContentStructureSection => {\n const rawGroups = (() => {\n if (rawSection === undefined || rawSection === null) {\n return [];\n }\n\n if (!isRecord(rawSection) || !Array.isArray(rawSection.groups)) {\n warn(`Section \"${sectionKey}\" is malformed; ignoring it`);\n return [];\n }\n\n return rawSection.groups;\n })();\n\n const seenGroupIds = new Map<string, Modules.ContentStructure.ContentStructureGroup>();\n const groups: Modules.ContentStructure.ContentStructureGroup[] = [];\n\n for (const raw of rawGroups) {\n if (!isGroupExpressionValid(raw)) {\n warn(`Dropping a malformed group entry in section \"${sectionKey}\"`);\n continue;\n }\n\n if (raw.name.trim() === '') {\n warn(`Dropping group \"${raw.id}\" in section \"${sectionKey}\": empty name`);\n continue;\n }\n\n if (seenGroupIds.has(raw.id)) {\n warn(`Dropping duplicate group id \"${raw.id}\" in section \"${sectionKey}\"`);\n continue;\n }\n\n const group: Modules.ContentStructure.ContentStructureGroup = {\n children: raw.children as Modules.ContentStructure.ContentStructureChild[],\n parent: raw.parent,\n name: raw.name,\n id: raw.id,\n };\n\n seenGroupIds.set(group.id, group);\n groups.push(group);\n }\n\n const reparentToRoot = (\n group: Modules.ContentStructure.ContentStructureGroup,\n reason: string\n ) => {\n group.parent = null;\n\n groups.splice(groups.indexOf(group), 1);\n groups.push(group);\n\n warn(`Reparenting group \"${group.id}\" in section \"${sectionKey}\" to root: ${reason}`);\n };\n\n // oxlint-disable-next-line - Duplicating is necessary because the original array is mutated inside the iterator.\n for (const group of [...groups]) {\n if (group.parent !== null && !seenGroupIds.has(group.parent)) {\n reparentToRoot(group, `parent \"${group.parent}\" does not exist`);\n }\n }\n\n // oxlint-disable-next-line - Duplicating is necessary because the original array is mutated inside the iterator.\n for (const group of [...groups]) {\n const chain = new Set([group.id]);\n let current = group;\n\n while (current.parent !== null) {\n if (chain.has(current.parent)) {\n reparentToRoot(group, 'its parent chain contains a cycle');\n break;\n }\n\n chain.add(current.parent);\n current = seenGroupIds.get(current.parent)!;\n }\n }\n\n // oxlint-disable-next-line - Duplicating is necessary because the original array is mutated inside the iterator.\n for (const group of [...groups]) {\n let current = group;\n let depth = 1;\n\n while (current.parent !== null) {\n current = seenGroupIds.get(current.parent)!;\n depth += 1;\n }\n\n if (depth > MAX_FOLDER_DEPTH) {\n reparentToRoot(group, `it exceeds the maximum nesting depth of ${MAX_FOLDER_DEPTH}`);\n }\n }\n\n const expectedKind = sectionKey === 'collectionTypes' ? 'collectionType' : 'singleType';\n const seenGroupChildren = new Set<string>();\n const seenUids = new Set<string>();\n\n for (const group of groups) {\n const cleanedChildren: Modules.ContentStructure.ContentStructureChild[] = [];\n\n for (const entry of group.children) {\n if (!isRecord(entry)) {\n warn(`Dropping a malformed child entry of group \"${group.id}\"`);\n continue;\n }\n\n if (entry.type === 'contentType') {\n const { uid } = entry;\n\n if (typeof uid !== 'string') {\n warn(`Dropping a contentType child of group \"${group.id}\": invalid uid`);\n continue;\n }\n\n const schema: { kind?: string } | undefined = strapi.contentTypes[uid as UID.ContentType];\n\n if (!schema) {\n warn(`Dropping unknown content type \"${uid}\" from group \"${group.id}\"`);\n continue;\n }\n\n // kind is optional on schemas; absent means collectionType.\n const kind = schema.kind ?? 'collectionType';\n\n if (kind !== expectedKind) {\n warn(\n `Dropping content type \"${uid}\" from group \"${group.id}\": its kind \"${kind}\" does not belong in section \"${sectionKey}\"`\n );\n continue;\n }\n\n if (seenUids.has(uid)) {\n warn(`Dropping duplicate reference to content type \"${uid}\" from group \"${group.id}\"`);\n continue;\n }\n\n cleanedChildren.push({ type: 'contentType', uid: uid as UID.ContentType });\n seenUids.add(uid);\n continue;\n }\n\n if (entry.type === 'group') {\n const { id } = entry;\n\n if (typeof id !== 'string') {\n warn(`Dropping a group child of group \"${group.id}\": invalid id`);\n continue;\n }\n\n const target = seenGroupIds.get(id);\n\n if (!target || target.parent !== group.id) {\n warn(`Dropping group child \"${id}\" from group \"${group.id}\": inconsistent reference`);\n continue;\n }\n\n if (seenGroupChildren.has(id)) {\n warn(`Dropping duplicate group child \"${id}\" from group \"${group.id}\"`);\n continue;\n }\n\n cleanedChildren.push({ type: 'group', id });\n seenGroupChildren.add(id);\n continue;\n }\n\n warn(`Dropping a child entry of group \"${group.id}\" with an unknown type`);\n }\n\n group.children = cleanedChildren;\n }\n\n for (const group of groups) {\n if (group.parent !== null && !seenGroupChildren.has(group.id)) {\n const parent = seenGroupIds.get(group.parent)!;\n\n parent.children.push({ type: 'group', id: group.id });\n seenGroupChildren.add(group.id);\n\n warn(\n `Group \"${group.id}\" was missing from the children of its parent \"${parent.id}\"; appended it`\n );\n }\n }\n\n return { groups };\n };\n\n const resolveSection = (\n section: Modules.ContentStructure.ContentStructureSection\n ): Modules.ContentStructure.ResolvedGroupNode[] => {\n const byId = new Map(section.groups.map((group) => [group.id, group]));\n\n const toNode = (\n group: Modules.ContentStructure.ContentStructureGroup\n ): Modules.ContentStructure.ResolvedGroupNode => {\n const cleanedChildren = group.children.map(\n (entry): Modules.ContentStructure.ResolvedStructureChild => {\n if (entry.type === 'contentType') {\n return { type: 'contentType', uid: entry.uid };\n }\n\n return toNode(byId.get(entry.id)!);\n }\n );\n\n return {\n children: cleanedChildren,\n name: group.name,\n type: 'group',\n id: group.id,\n };\n };\n\n return section.groups.filter((group) => group.parent === null).map(toNode);\n };\n\n async function read(): Promise<Modules.ContentStructure.ContentStructureFile | null> {\n const filePath = join(strapi.dirs.dist.contentStructure, CONTENT_STRUCTURE_FILE_NAME);\n\n if (!(await fse.pathExists(filePath))) {\n return null;\n }\n\n let parsed: unknown;\n try {\n parsed = await fse.readJSON(filePath);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n\n strapi.log.error(\n `[content-structure] Could not parse ${filePath} (${message}); continuing without content-type folders`\n );\n\n return null;\n }\n\n if (!isRecord(parsed) || !isRecord(parsed.sections)) {\n strapi.log.error(\n `[content-structure] ${filePath} is not an object with a \"sections\" property; continuing without content-type folders`\n );\n return null;\n }\n\n if (parsed.version !== 1) {\n strapi.log.error(\n `[content-structure] Unknown version \"${parsed.version}\" in ${filePath} (expected 1); continuing without content-type folders`\n );\n return null;\n }\n\n return parsed as unknown as Modules.ContentStructure.ContentStructureFile;\n }\n\n const load = () => {\n if (!cache) {\n cache = (async () => {\n const file = await read();\n\n if (!file) {\n return { cleaned: null, resolved: { collectionTypes: [], singleTypes: [] } };\n }\n\n const cleaned: Modules.ContentStructure.ContentStructureFile = {\n version: 1,\n sections: {\n collectionTypes: cleanSection(file.sections.collectionTypes, 'collectionTypes'),\n singleTypes: cleanSection(file.sections.singleTypes, 'singleTypes'),\n },\n };\n\n return {\n cleaned,\n resolved: {\n collectionTypes: resolveSection(cleaned.sections.collectionTypes),\n singleTypes: resolveSection(cleaned.sections.singleTypes),\n },\n };\n })();\n }\n\n return cache;\n };\n\n function invalidate() {\n cache = undefined;\n }\n\n async function getCleanedFile() {\n return (await load()).cleaned;\n }\n\n async function resolve() {\n return (await load()).resolved;\n }\n\n async function write(structure: Modules.ContentStructure.ContentStructureFile) {\n const dir = strapi.dirs.app.contentStructure;\n\n await fse.ensureDir(dir);\n await fse.writeJSON(join(dir, CONTENT_STRUCTURE_FILE_NAME), structure, { spaces: 2 });\n\n invalidate();\n }\n\n function validate(value: unknown): Modules.ContentStructure.ContentStructureFile {\n return contentStructureFileSchema.parse(value) as Modules.ContentStructure.ContentStructureFile;\n }\n\n async function countGroups() {\n const { cleaned } = await load();\n\n if (!cleaned) {\n return 0;\n }\n\n const collectionTypesCount = cleaned.sections.collectionTypes.groups.length;\n const singleTypesCount = cleaned.sections.singleTypes.groups.length;\n\n return collectionTypesCount + singleTypesCount;\n }\n\n return {\n getCleanedFile,\n countGroups,\n invalidate,\n validate,\n resolve,\n write,\n read,\n };\n}\n"],"names":["CONTENT_STRUCTURE_FILE_NAME","MAX_FOLDER_DEPTH","isRecord","value","Array","isArray","createContentStructureService","strapi","cache","warn","message","log","cleanSection","rawSection","sectionKey","rawGroups","undefined","groups","seenGroupIds","Map","raw","isGroupExpressionValid","name","trim","id","has","group","children","parent","set","push","reparentToRoot","reason","splice","indexOf","chain","Set","current","add","get","depth","expectedKind","seenGroupChildren","seenUids","cleanedChildren","entry","type","uid","schema","contentTypes","kind","target","resolveSection","section","byId","map","toNode","filter","read","filePath","join","dirs","dist","contentStructure","fse","pathExists","parsed","readJSON","error","Error","String","sections","version","load","file","cleaned","resolved","collectionTypes","singleTypes","invalidate","getCleanedFile","resolve","write","structure","dir","app","ensureDir","writeJSON","spaces","validate","contentStructureFileSchema","parse","countGroups","collectionTypesCount","length","singleTypesCount"],"mappings":";;;;;;;;;;;AAOO,MAAMA,8BAA8B;AAEpC,MAAMC,mBAAmB;AAyChC,MAAMC,WAAW,CAACC,KAAAA,GAAAA;IAChB,OAAO,OAAOA,UAAU,QAAA,IAAYA,KAAAA,KAAU,QAAQ,CAACC,KAAAA,CAAMC,OAAO,CAACF,KAAAA,CAAAA;AACvE,CAAA;AAOO,SAASG,8BAA8BC,MAAmB,EAAA;AAC/D;;AAEC,MACD,IAAIC,KAAAA;AAEJ,IAAA,MAAMC,OAAO,CAACC,OAAAA,GAAAA;AACZH,QAAAA,MAAAA,CAAOI,GAAG,CAACF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AAC5D,MAAM,CAAC6E,MAAM;QAC3E,MAAMC,gBAAAA,GAAmBpB,QAAQJ,QAAQ,CAACO,WAAW,CAAC7D,MAAM,CAAC6E,MAAM;AAEnE,QAAA,OAAOD,oBAAAA,GAAuBE,gBAAAA;AAChC,IAAA;IAEA,OAAO;AACLf,QAAAA,cAAAA;AACAY,QAAAA,WAAAA;AACAb,QAAAA,UAAAA;AACAU,QAAAA,QAAAA;AACAR,QAAAA,OAAAA;AACAC,QAAAA,KAAAA;AACAxB,QAAAA;AACF,KAAA;AACF;;;;;;"}
|
|
@@ -10,7 +10,7 @@ const isRecord = (value)=>{
|
|
|
10
10
|
};
|
|
11
11
|
function createContentStructureService(strapi) {
|
|
12
12
|
/**
|
|
13
|
-
* This cache exists to ensure all consumers
|
|
13
|
+
* This cache exists to ensure all consumers receive the same cleaned+resolved data, regardless of call order / invocation relative to the strapi reload.
|
|
14
14
|
*/ let cache;
|
|
15
15
|
const warn = (message)=>{
|
|
16
16
|
strapi.log.warn(`[content-structure] ${message}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../../src/services/content-structure/index.ts"],"sourcesContent":["import { join } from 'path';\nimport fse from 'fs-extra';\n\nimport type { Core, Modules, UID } from '@strapi/types';\nimport { isGroupExpressionValid } from './utils/isGroupExpressionValid';\nimport { contentStructureFileSchema } from './validation';\n\nexport const CONTENT_STRUCTURE_FILE_NAME = 'groups.json';\n\nexport const MAX_FOLDER_DEPTH = 3;\n\nexport interface ContentStructureService {\n /**\n * Reads the contents of groups.json directly with minimal sanitization.\n */\n read(): Promise<Modules.ContentStructure.ContentStructureFile | null>;\n\n /**\n * Yields an extremely tolerant version of the groups configuration file. Invalid references are repaired or ignored. Warnings fire for each repair/omission.\n */\n getCleanedFile(): Promise<Modules.ContentStructure.ContentStructureFile | null>;\n\n /**\n * Returns the groups configuration transformed into nested trees.\n */\n resolve(): Promise<Modules.ContentStructure.ResolvedContentStructure>;\n\n /**\n * Writes a new config and invalidates the cache. Does NOT perform validation - this is\n * left to the caller. The Save that triggers the write restarts the server via the\n * standard update-schema flow, which reloads the file; this method only persists it.\n */\n write(structure: Modules.ContentStructure.ContentStructureFile): Promise<void>;\n\n /**\n * Strictly validates an unknown value against the canonical groups.json schema; throws if invalid.\n */\n validate(value: unknown): Modules.ContentStructure.ContentStructureFile;\n\n /**\n * Invalidates the cached parsed groups.json file.\n */\n invalidate(): void;\n\n /**\n * Total number of groups across both sections of the cleaned file.\n */\n countGroups(): Promise<number>;\n}\n\nconst isRecord = (value: unknown): value is Record<string, unknown> => {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n};\n\ntype ContentStructureCache = Promise<{\n cleaned: Modules.ContentStructure.ContentStructureFile | null;\n resolved: Modules.ContentStructure.ResolvedContentStructure;\n}>;\n\nexport function createContentStructureService(strapi: Core.Strapi): ContentStructureService {\n /**\n * This cache exists to ensure all consumers recieve the same cleaned+resolved data, regardless of call order / invocation relative to the strapi reload.\n */\n let cache: ContentStructureCache | undefined;\n\n const warn = (message: string) => {\n strapi.log.warn(`[content-structure] ${message}`);\n };\n\n const cleanSection = (\n rawSection: unknown,\n sectionKey: Modules.ContentStructure.ContentStructureSectionKey\n ): Modules.ContentStructure.ContentStructureSection => {\n const rawGroups = (() => {\n if (rawSection === undefined || rawSection === null) {\n return [];\n }\n\n if (!isRecord(rawSection) || !Array.isArray(rawSection.groups)) {\n warn(`Section \"${sectionKey}\" is malformed; ignoring it`);\n return [];\n }\n\n return rawSection.groups;\n })();\n\n const seenGroupIds = new Map<string, Modules.ContentStructure.ContentStructureGroup>();\n const groups: Modules.ContentStructure.ContentStructureGroup[] = [];\n\n for (const raw of rawGroups) {\n if (!isGroupExpressionValid(raw)) {\n warn(`Dropping a malformed group entry in section \"${sectionKey}\"`);\n continue;\n }\n\n if (raw.name.trim() === '') {\n warn(`Dropping group \"${raw.id}\" in section \"${sectionKey}\": empty name`);\n continue;\n }\n\n if (seenGroupIds.has(raw.id)) {\n warn(`Dropping duplicate group id \"${raw.id}\" in section \"${sectionKey}\"`);\n continue;\n }\n\n const group: Modules.ContentStructure.ContentStructureGroup = {\n children: raw.children as Modules.ContentStructure.ContentStructureChild[],\n parent: raw.parent,\n name: raw.name,\n id: raw.id,\n };\n\n seenGroupIds.set(group.id, group);\n groups.push(group);\n }\n\n const reparentToRoot = (\n group: Modules.ContentStructure.ContentStructureGroup,\n reason: string\n ) => {\n group.parent = null;\n\n groups.splice(groups.indexOf(group), 1);\n groups.push(group);\n\n warn(`Reparenting group \"${group.id}\" in section \"${sectionKey}\" to root: ${reason}`);\n };\n\n // oxlint-disable-next-line - Duplicating is necessary because the original array is mutated inside the iterator.\n for (const group of [...groups]) {\n if (group.parent !== null && !seenGroupIds.has(group.parent)) {\n reparentToRoot(group, `parent \"${group.parent}\" does not exist`);\n }\n }\n\n // oxlint-disable-next-line - Duplicating is necessary because the original array is mutated inside the iterator.\n for (const group of [...groups]) {\n const chain = new Set([group.id]);\n let current = group;\n\n while (current.parent !== null) {\n if (chain.has(current.parent)) {\n reparentToRoot(group, 'its parent chain contains a cycle');\n break;\n }\n\n chain.add(current.parent);\n current = seenGroupIds.get(current.parent)!;\n }\n }\n\n // oxlint-disable-next-line - Duplicating is necessary because the original array is mutated inside the iterator.\n for (const group of [...groups]) {\n let current = group;\n let depth = 1;\n\n while (current.parent !== null) {\n current = seenGroupIds.get(current.parent)!;\n depth += 1;\n }\n\n if (depth > MAX_FOLDER_DEPTH) {\n reparentToRoot(group, `it exceeds the maximum nesting depth of ${MAX_FOLDER_DEPTH}`);\n }\n }\n\n const expectedKind = sectionKey === 'collectionTypes' ? 'collectionType' : 'singleType';\n const seenGroupChildren = new Set<string>();\n const seenUids = new Set<string>();\n\n for (const group of groups) {\n const cleanedChildren: Modules.ContentStructure.ContentStructureChild[] = [];\n\n for (const entry of group.children) {\n if (!isRecord(entry)) {\n warn(`Dropping a malformed child entry of group \"${group.id}\"`);\n continue;\n }\n\n if (entry.type === 'contentType') {\n const { uid } = entry;\n\n if (typeof uid !== 'string') {\n warn(`Dropping a contentType child of group \"${group.id}\": invalid uid`);\n continue;\n }\n\n const schema: { kind?: string } | undefined = strapi.contentTypes[uid as UID.ContentType];\n\n if (!schema) {\n warn(`Dropping unknown content type \"${uid}\" from group \"${group.id}\"`);\n continue;\n }\n\n // kind is optional on schemas; absent means collectionType.\n const kind = schema.kind ?? 'collectionType';\n\n if (kind !== expectedKind) {\n warn(\n `Dropping content type \"${uid}\" from group \"${group.id}\": its kind \"${kind}\" does not belong in section \"${sectionKey}\"`\n );\n continue;\n }\n\n if (seenUids.has(uid)) {\n warn(`Dropping duplicate reference to content type \"${uid}\" from group \"${group.id}\"`);\n continue;\n }\n\n cleanedChildren.push({ type: 'contentType', uid: uid as UID.ContentType });\n seenUids.add(uid);\n continue;\n }\n\n if (entry.type === 'group') {\n const { id } = entry;\n\n if (typeof id !== 'string') {\n warn(`Dropping a group child of group \"${group.id}\": invalid id`);\n continue;\n }\n\n const target = seenGroupIds.get(id);\n\n if (!target || target.parent !== group.id) {\n warn(`Dropping group child \"${id}\" from group \"${group.id}\": inconsistent reference`);\n continue;\n }\n\n if (seenGroupChildren.has(id)) {\n warn(`Dropping duplicate group child \"${id}\" from group \"${group.id}\"`);\n continue;\n }\n\n cleanedChildren.push({ type: 'group', id });\n seenGroupChildren.add(id);\n continue;\n }\n\n warn(`Dropping a child entry of group \"${group.id}\" with an unknown type`);\n }\n\n group.children = cleanedChildren;\n }\n\n for (const group of groups) {\n if (group.parent !== null && !seenGroupChildren.has(group.id)) {\n const parent = seenGroupIds.get(group.parent)!;\n\n parent.children.push({ type: 'group', id: group.id });\n seenGroupChildren.add(group.id);\n\n warn(\n `Group \"${group.id}\" was missing from the children of its parent \"${parent.id}\"; appended it`\n );\n }\n }\n\n return { groups };\n };\n\n const resolveSection = (\n section: Modules.ContentStructure.ContentStructureSection\n ): Modules.ContentStructure.ResolvedGroupNode[] => {\n const byId = new Map(section.groups.map((group) => [group.id, group]));\n\n const toNode = (\n group: Modules.ContentStructure.ContentStructureGroup\n ): Modules.ContentStructure.ResolvedGroupNode => {\n const cleanedChildren = group.children.map(\n (entry): Modules.ContentStructure.ResolvedStructureChild => {\n if (entry.type === 'contentType') {\n return { type: 'contentType', uid: entry.uid };\n }\n\n return toNode(byId.get(entry.id)!);\n }\n );\n\n return {\n children: cleanedChildren,\n name: group.name,\n type: 'group',\n id: group.id,\n };\n };\n\n return section.groups.filter((group) => group.parent === null).map(toNode);\n };\n\n async function read(): Promise<Modules.ContentStructure.ContentStructureFile | null> {\n const filePath = join(strapi.dirs.dist.contentStructure, CONTENT_STRUCTURE_FILE_NAME);\n\n if (!(await fse.pathExists(filePath))) {\n return null;\n }\n\n let parsed: unknown;\n try {\n parsed = await fse.readJSON(filePath);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n\n strapi.log.error(\n `[content-structure] Could not parse ${filePath} (${message}); continuing without content-type folders`\n );\n\n return null;\n }\n\n if (!isRecord(parsed) || !isRecord(parsed.sections)) {\n strapi.log.error(\n `[content-structure] ${filePath} is not an object with a \"sections\" property; continuing without content-type folders`\n );\n return null;\n }\n\n if (parsed.version !== 1) {\n strapi.log.error(\n `[content-structure] Unknown version \"${parsed.version}\" in ${filePath} (expected 1); continuing without content-type folders`\n );\n return null;\n }\n\n return parsed as unknown as Modules.ContentStructure.ContentStructureFile;\n }\n\n const load = () => {\n if (!cache) {\n cache = (async () => {\n const file = await read();\n\n if (!file) {\n return { cleaned: null, resolved: { collectionTypes: [], singleTypes: [] } };\n }\n\n const cleaned: Modules.ContentStructure.ContentStructureFile = {\n version: 1,\n sections: {\n collectionTypes: cleanSection(file.sections.collectionTypes, 'collectionTypes'),\n singleTypes: cleanSection(file.sections.singleTypes, 'singleTypes'),\n },\n };\n\n return {\n cleaned,\n resolved: {\n collectionTypes: resolveSection(cleaned.sections.collectionTypes),\n singleTypes: resolveSection(cleaned.sections.singleTypes),\n },\n };\n })();\n }\n\n return cache;\n };\n\n function invalidate() {\n cache = undefined;\n }\n\n async function getCleanedFile() {\n return (await load()).cleaned;\n }\n\n async function resolve() {\n return (await load()).resolved;\n }\n\n async function write(structure: Modules.ContentStructure.ContentStructureFile) {\n const dir = strapi.dirs.app.contentStructure;\n\n await fse.ensureDir(dir);\n await fse.writeJSON(join(dir, CONTENT_STRUCTURE_FILE_NAME), structure, { spaces: 2 });\n\n invalidate();\n }\n\n function validate(value: unknown): Modules.ContentStructure.ContentStructureFile {\n return contentStructureFileSchema.parse(value) as Modules.ContentStructure.ContentStructureFile;\n }\n\n async function countGroups() {\n const { cleaned } = await load();\n\n if (!cleaned) {\n return 0;\n }\n\n const collectionTypesCount = cleaned.sections.collectionTypes.groups.length;\n const singleTypesCount = cleaned.sections.singleTypes.groups.length;\n\n return collectionTypesCount + singleTypesCount;\n }\n\n return {\n getCleanedFile,\n countGroups,\n invalidate,\n validate,\n resolve,\n write,\n read,\n };\n}\n"],"names":["CONTENT_STRUCTURE_FILE_NAME","MAX_FOLDER_DEPTH","isRecord","value","Array","isArray","createContentStructureService","strapi","cache","warn","message","log","cleanSection","rawSection","sectionKey","rawGroups","undefined","groups","seenGroupIds","Map","raw","isGroupExpressionValid","name","trim","id","has","group","children","parent","set","push","reparentToRoot","reason","splice","indexOf","chain","Set","current","add","get","depth","expectedKind","seenGroupChildren","seenUids","cleanedChildren","entry","type","uid","schema","contentTypes","kind","target","resolveSection","section","byId","map","toNode","filter","read","filePath","join","dirs","dist","contentStructure","fse","pathExists","parsed","readJSON","error","Error","String","sections","version","load","file","cleaned","resolved","collectionTypes","singleTypes","invalidate","getCleanedFile","resolve","write","structure","dir","app","ensureDir","writeJSON","spaces","validate","contentStructureFileSchema","parse","countGroups","collectionTypesCount","length","singleTypesCount"],"mappings":";;;;;AAOO,MAAMA,8BAA8B;AAEpC,MAAMC,mBAAmB;AAyChC,MAAMC,WAAW,CAACC,KAAAA,GAAAA;IAChB,OAAO,OAAOA,UAAU,QAAA,IAAYA,KAAAA,KAAU,QA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eyF,WAAAA,GAAAA;AACb,QAAA,MAAM,EAAEjB,OAAO,EAAE,GAAG,MAAMF,IAAAA,EAAAA;AAE1B,QAAA,IAAI,CAACE,OAAAA,EAAS;YACZ,OAAO,CAAA;AACT,QAAA;QAEA,MAAMkB,oBAAAA,GAAuBlB,QAAQJ,QAAQ,CAACM,eAAe,CAAC5D,MAAM,CAAC6E,MAAM;QAC3E,MAAMC,gBAAAA,GAAmBpB,QAAQJ,QAAQ,CAACO,WAAW,CAAC7D,MAAM,CAAC6E,MAAM;AAEnE,QAAA,OAAOD,oBAAAA,GAAuBE,gBAAAA;AAChC,IAAA;IAEA,OAAO;AACLf,QAAAA,cAAAA;AACAY,QAAAA,WAAAA;AACAb,QAAAA,UAAAA;AACAU,QAAAA,QAAAA;AACAR,QAAAA,OAAAA;AACAC,QAAAA,KAAAA;AACAxB,QAAAA;AACF,KAAA;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../src/services/content-structure/index.ts"],"sourcesContent":["import { join } from 'path';\nimport fse from 'fs-extra';\n\nimport type { Core, Modules, UID } from '@strapi/types';\nimport { isGroupExpressionValid } from './utils/isGroupExpressionValid';\nimport { contentStructureFileSchema } from './validation';\n\nexport const CONTENT_STRUCTURE_FILE_NAME = 'groups.json';\n\nexport const MAX_FOLDER_DEPTH = 3;\n\nexport interface ContentStructureService {\n /**\n * Reads the contents of groups.json directly with minimal sanitization.\n */\n read(): Promise<Modules.ContentStructure.ContentStructureFile | null>;\n\n /**\n * Yields an extremely tolerant version of the groups configuration file. Invalid references are repaired or ignored. Warnings fire for each repair/omission.\n */\n getCleanedFile(): Promise<Modules.ContentStructure.ContentStructureFile | null>;\n\n /**\n * Returns the groups configuration transformed into nested trees.\n */\n resolve(): Promise<Modules.ContentStructure.ResolvedContentStructure>;\n\n /**\n * Writes a new config and invalidates the cache. Does NOT perform validation - this is\n * left to the caller. The Save that triggers the write restarts the server via the\n * standard update-schema flow, which reloads the file; this method only persists it.\n */\n write(structure: Modules.ContentStructure.ContentStructureFile): Promise<void>;\n\n /**\n * Strictly validates an unknown value against the canonical groups.json schema; throws if invalid.\n */\n validate(value: unknown): Modules.ContentStructure.ContentStructureFile;\n\n /**\n * Invalidates the cached parsed groups.json file.\n */\n invalidate(): void;\n\n /**\n * Total number of groups across both sections of the cleaned file.\n */\n countGroups(): Promise<number>;\n}\n\nconst isRecord = (value: unknown): value is Record<string, unknown> => {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n};\n\ntype ContentStructureCache = Promise<{\n cleaned: Modules.ContentStructure.ContentStructureFile | null;\n resolved: Modules.ContentStructure.ResolvedContentStructure;\n}>;\n\nexport function createContentStructureService(strapi: Core.Strapi): ContentStructureService {\n /**\n * This cache exists to ensure all consumers receive the same cleaned+resolved data, regardless of call order / invocation relative to the strapi reload.\n */\n let cache: ContentStructureCache | undefined;\n\n const warn = (message: string) => {\n strapi.log.warn(`[content-structure] ${message}`);\n };\n\n const cleanSection = (\n rawSection: unknown,\n sectionKey: Modules.ContentStructure.ContentStructureSectionKey\n ): Modules.ContentStructure.ContentStructureSection => {\n const rawGroups = (() => {\n if (rawSection === undefined || rawSection === null) {\n return [];\n }\n\n if (!isRecord(rawSection) || !Array.isArray(rawSection.groups)) {\n warn(`Section \"${sectionKey}\" is malformed; ignoring it`);\n return [];\n }\n\n return rawSection.groups;\n })();\n\n const seenGroupIds = new Map<string, Modules.ContentStructure.ContentStructureGroup>();\n const groups: Modules.ContentStructure.ContentStructureGroup[] = [];\n\n for (const raw of rawGroups) {\n if (!isGroupExpressionValid(raw)) {\n warn(`Dropping a malformed group entry in section \"${sectionKey}\"`);\n continue;\n }\n\n if (raw.name.trim() === '') {\n warn(`Dropping group \"${raw.id}\" in section \"${sectionKey}\": empty name`);\n continue;\n }\n\n if (seenGroupIds.has(raw.id)) {\n warn(`Dropping duplicate group id \"${raw.id}\" in section \"${sectionKey}\"`);\n continue;\n }\n\n const group: Modules.ContentStructure.ContentStructureGroup = {\n children: raw.children as Modules.ContentStructure.ContentStructureChild[],\n parent: raw.parent,\n name: raw.name,\n id: raw.id,\n };\n\n seenGroupIds.set(group.id, group);\n groups.push(group);\n }\n\n const reparentToRoot = (\n group: Modules.ContentStructure.ContentStructureGroup,\n reason: string\n ) => {\n group.parent = null;\n\n groups.splice(groups.indexOf(group), 1);\n groups.push(group);\n\n warn(`Reparenting group \"${group.id}\" in section \"${sectionKey}\" to root: ${reason}`);\n };\n\n // oxlint-disable-next-line - Duplicating is necessary because the original array is mutated inside the iterator.\n for (const group of [...groups]) {\n if (group.parent !== null && !seenGroupIds.has(group.parent)) {\n reparentToRoot(group, `parent \"${group.parent}\" does not exist`);\n }\n }\n\n // oxlint-disable-next-line - Duplicating is necessary because the original array is mutated inside the iterator.\n for (const group of [...groups]) {\n const chain = new Set([group.id]);\n let current = group;\n\n while (current.parent !== null) {\n if (chain.has(current.parent)) {\n reparentToRoot(group, 'its parent chain contains a cycle');\n break;\n }\n\n chain.add(current.parent);\n current = seenGroupIds.get(current.parent)!;\n }\n }\n\n // oxlint-disable-next-line - Duplicating is necessary because the original array is mutated inside the iterator.\n for (const group of [...groups]) {\n let current = group;\n let depth = 1;\n\n while (current.parent !== null) {\n current = seenGroupIds.get(current.parent)!;\n depth += 1;\n }\n\n if (depth > MAX_FOLDER_DEPTH) {\n reparentToRoot(group, `it exceeds the maximum nesting depth of ${MAX_FOLDER_DEPTH}`);\n }\n }\n\n const expectedKind = sectionKey === 'collectionTypes' ? 'collectionType' : 'singleType';\n const seenGroupChildren = new Set<string>();\n const seenUids = new Set<string>();\n\n for (const group of groups) {\n const cleanedChildren: Modules.ContentStructure.ContentStructureChild[] = [];\n\n for (const entry of group.children) {\n if (!isRecord(entry)) {\n warn(`Dropping a malformed child entry of group \"${group.id}\"`);\n continue;\n }\n\n if (entry.type === 'contentType') {\n const { uid } = entry;\n\n if (typeof uid !== 'string') {\n warn(`Dropping a contentType child of group \"${group.id}\": invalid uid`);\n continue;\n }\n\n const schema: { kind?: string } | undefined = strapi.contentTypes[uid as UID.ContentType];\n\n if (!schema) {\n warn(`Dropping unknown content type \"${uid}\" from group \"${group.id}\"`);\n continue;\n }\n\n // kind is optional on schemas; absent means collectionType.\n const kind = schema.kind ?? 'collectionType';\n\n if (kind !== expectedKind) {\n warn(\n `Dropping content type \"${uid}\" from group \"${group.id}\": its kind \"${kind}\" does not belong in section \"${sectionKey}\"`\n );\n continue;\n }\n\n if (seenUids.has(uid)) {\n warn(`Dropping duplicate reference to content type \"${uid}\" from group \"${group.id}\"`);\n continue;\n }\n\n cleanedChildren.push({ type: 'contentType', uid: uid as UID.ContentType });\n seenUids.add(uid);\n continue;\n }\n\n if (entry.type === 'group') {\n const { id } = entry;\n\n if (typeof id !== 'string') {\n warn(`Dropping a group child of group \"${group.id}\": invalid id`);\n continue;\n }\n\n const target = seenGroupIds.get(id);\n\n if (!target || target.parent !== group.id) {\n warn(`Dropping group child \"${id}\" from group \"${group.id}\": inconsistent reference`);\n continue;\n }\n\n if (seenGroupChildren.has(id)) {\n warn(`Dropping duplicate group child \"${id}\" from group \"${group.id}\"`);\n continue;\n }\n\n cleanedChildren.push({ type: 'group', id });\n seenGroupChildren.add(id);\n continue;\n }\n\n warn(`Dropping a child entry of group \"${group.id}\" with an unknown type`);\n }\n\n group.children = cleanedChildren;\n }\n\n for (const group of groups) {\n if (group.parent !== null && !seenGroupChildren.has(group.id)) {\n const parent = seenGroupIds.get(group.parent)!;\n\n parent.children.push({ type: 'group', id: group.id });\n seenGroupChildren.add(group.id);\n\n warn(\n `Group \"${group.id}\" was missing from the children of its parent \"${parent.id}\"; appended it`\n );\n }\n }\n\n return { groups };\n };\n\n const resolveSection = (\n section: Modules.ContentStructure.ContentStructureSection\n ): Modules.ContentStructure.ResolvedGroupNode[] => {\n const byId = new Map(section.groups.map((group) => [group.id, group]));\n\n const toNode = (\n group: Modules.ContentStructure.ContentStructureGroup\n ): Modules.ContentStructure.ResolvedGroupNode => {\n const cleanedChildren = group.children.map(\n (entry): Modules.ContentStructure.ResolvedStructureChild => {\n if (entry.type === 'contentType') {\n return { type: 'contentType', uid: entry.uid };\n }\n\n return toNode(byId.get(entry.id)!);\n }\n );\n\n return {\n children: cleanedChildren,\n name: group.name,\n type: 'group',\n id: group.id,\n };\n };\n\n return section.groups.filter((group) => group.parent === null).map(toNode);\n };\n\n async function read(): Promise<Modules.ContentStructure.ContentStructureFile | null> {\n const filePath = join(strapi.dirs.dist.contentStructure, CONTENT_STRUCTURE_FILE_NAME);\n\n if (!(await fse.pathExists(filePath))) {\n return null;\n }\n\n let parsed: unknown;\n try {\n parsed = await fse.readJSON(filePath);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n\n strapi.log.error(\n `[content-structure] Could not parse ${filePath} (${message}); continuing without content-type folders`\n );\n\n return null;\n }\n\n if (!isRecord(parsed) || !isRecord(parsed.sections)) {\n strapi.log.error(\n `[content-structure] ${filePath} is not an object with a \"sections\" property; continuing without content-type folders`\n );\n return null;\n }\n\n if (parsed.version !== 1) {\n strapi.log.error(\n `[content-structure] Unknown version \"${parsed.version}\" in ${filePath} (expected 1); continuing without content-type folders`\n );\n return null;\n }\n\n return parsed as unknown as Modules.ContentStructure.ContentStructureFile;\n }\n\n const load = () => {\n if (!cache) {\n cache = (async () => {\n const file = await read();\n\n if (!file) {\n return { cleaned: null, resolved: { collectionTypes: [], singleTypes: [] } };\n }\n\n const cleaned: Modules.ContentStructure.ContentStructureFile = {\n version: 1,\n sections: {\n collectionTypes: cleanSection(file.sections.collectionTypes, 'collectionTypes'),\n singleTypes: cleanSection(file.sections.singleTypes, 'singleTypes'),\n },\n };\n\n return {\n cleaned,\n resolved: {\n collectionTypes: resolveSection(cleaned.sections.collectionTypes),\n singleTypes: resolveSection(cleaned.sections.singleTypes),\n },\n };\n })();\n }\n\n return cache;\n };\n\n function invalidate() {\n cache = undefined;\n }\n\n async function getCleanedFile() {\n return (await load()).cleaned;\n }\n\n async function resolve() {\n return (await load()).resolved;\n }\n\n async function write(structure: Modules.ContentStructure.ContentStructureFile) {\n const dir = strapi.dirs.app.contentStructure;\n\n await fse.ensureDir(dir);\n await fse.writeJSON(join(dir, CONTENT_STRUCTURE_FILE_NAME), structure, { spaces: 2 });\n\n invalidate();\n }\n\n function validate(value: unknown): Modules.ContentStructure.ContentStructureFile {\n return contentStructureFileSchema.parse(value) as Modules.ContentStructure.ContentStructureFile;\n }\n\n async function countGroups() {\n const { cleaned } = await load();\n\n if (!cleaned) {\n return 0;\n }\n\n const collectionTypesCount = cleaned.sections.collectionTypes.groups.length;\n const singleTypesCount = cleaned.sections.singleTypes.groups.length;\n\n return collectionTypesCount + singleTypesCount;\n }\n\n return {\n getCleanedFile,\n countGroups,\n invalidate,\n validate,\n resolve,\n write,\n read,\n };\n}\n"],"names":["CONTENT_STRUCTURE_FILE_NAME","MAX_FOLDER_DEPTH","isRecord","value","Array","isArray","createContentStructureService","strapi","cache","warn","message","log","cleanSection","rawSection","sectionKey","rawGroups","undefined","groups","seenGroupIds","Map","raw","isGroupExpressionValid","name","trim","id","has","group","children","parent","set","push","reparentToRoot","reason","splice","indexOf","chain","Set","current","add","get","depth","expectedKind","seenGroupChildren","seenUids","cleanedChildren","entry","type","uid","schema","contentTypes","kind","target","resolveSection","section","byId","map","toNode","filter","read","filePath","join","dirs","dist","contentStructure","fse","pathExists","parsed","readJSON","error","Error","String","sections","version","load","file","cleaned","resolved","collectionTypes","singleTypes","invalidate","getCleanedFile","resolve","write","structure","dir","app","ensureDir","writeJSON","spaces","validate","contentStructureFileSchema","parse","countGroups","collectionTypesCount","length","singleTypesCount"],"mappings":";;;;;AAOO,MAAMA,8BAA8B;AAEpC,MAAMC,mBAAmB;AAyChC,MAAMC,WAAW,CAACC,KAAAA,GAAAA;IAChB,OAAO,OAAOA,UAAU,QAAA,IAAYA,KAAAA,KAAU,QAAQ,CAACC,KAAAA,CAAMC,OAAO,CAACF,KAAAA,CAAAA;AACvE,CAAA;AAOO,SAASG,8BAA8BC,MAAmB,EAAA;AAC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,CAACE,OAAAA,EAAS;YACZ,OAAO,CAAA;AACT,QAAA;QAEA,MAAMkB,oBAAAA,GAAuBlB,QAAQJ,QAAQ,CAACM,eAAe,CAAC5D,MAAM,CAAC6E,MAAM;QAC3E,MAAMC,gBAAAA,GAAmBpB,QAAQJ,QAAQ,CAACO,WAAW,CAAC7D,MAAM,CAAC6E,MAAM;AAEnE,QAAA,OAAOD,oBAAAA,GAAuBE,gBAAAA;AAChC,IAAA;IAEA,OAAO;AACLf,QAAAA,cAAAA;AACAY,QAAAA,WAAAA;AACAb,QAAAA,UAAAA;AACAU,QAAAA,QAAAA;AACAR,QAAAA,OAAAA;AACAC,QAAAA,KAAAA;AACAxB,QAAAA;AACF,KAAA;AACF;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/core",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.56.0",
|
|
4
4
|
"description": "Core of Strapi",
|
|
5
5
|
"homepage": "https://strapi.io",
|
|
6
6
|
"bugs": {
|
|
@@ -63,15 +63,15 @@
|
|
|
63
63
|
"@modelcontextprotocol/node": "2.0.0",
|
|
64
64
|
"@modelcontextprotocol/server": "2.0.0",
|
|
65
65
|
"@paralleldrive/cuid2": "2.2.2",
|
|
66
|
-
"@strapi/admin": "5.
|
|
67
|
-
"@strapi/database": "5.
|
|
68
|
-
"@strapi/generators": "5.
|
|
69
|
-
"@strapi/logger": "5.
|
|
70
|
-
"@strapi/openapi": "5.
|
|
71
|
-
"@strapi/permissions": "5.
|
|
72
|
-
"@strapi/types": "5.
|
|
73
|
-
"@strapi/typescript-utils": "5.
|
|
74
|
-
"@strapi/utils": "5.
|
|
66
|
+
"@strapi/admin": "5.56.0",
|
|
67
|
+
"@strapi/database": "5.56.0",
|
|
68
|
+
"@strapi/generators": "5.56.0",
|
|
69
|
+
"@strapi/logger": "5.56.0",
|
|
70
|
+
"@strapi/openapi": "5.56.0",
|
|
71
|
+
"@strapi/permissions": "5.56.0",
|
|
72
|
+
"@strapi/types": "5.56.0",
|
|
73
|
+
"@strapi/typescript-utils": "5.56.0",
|
|
74
|
+
"@strapi/utils": "5.56.0",
|
|
75
75
|
"@vercel/stega": "0.1.2",
|
|
76
76
|
"bcryptjs": "2.4.3",
|
|
77
77
|
"boxen": "5.1.2",
|
|
@@ -109,11 +109,11 @@
|
|
|
109
109
|
"ora": "5.4.1",
|
|
110
110
|
"package-json": "10.0.1",
|
|
111
111
|
"pkg-up": "3.1.0",
|
|
112
|
-
"qs": "6.
|
|
112
|
+
"qs": "6.16.0",
|
|
113
113
|
"resolve.exports": "2.0.2",
|
|
114
114
|
"semver": "7.7.4",
|
|
115
115
|
"typescript": "5.9.3",
|
|
116
|
-
"undici": "6.
|
|
116
|
+
"undici": "6.29.0",
|
|
117
117
|
"yup": "0.32.9",
|
|
118
118
|
"zod": "4.4.3"
|
|
119
119
|
},
|
|
@@ -137,12 +137,12 @@
|
|
|
137
137
|
"@types/node": "20.19.41",
|
|
138
138
|
"ajv": "8.20.0",
|
|
139
139
|
"ajv-formats": "3.0.1",
|
|
140
|
-
"eslint-config-custom": "5.
|
|
140
|
+
"eslint-config-custom": "5.56.0",
|
|
141
141
|
"jest": "29.6.0",
|
|
142
142
|
"supertest": "7.2.2",
|
|
143
|
-
"tsconfig": "5.
|
|
143
|
+
"tsconfig": "5.56.0",
|
|
144
144
|
"vitest": "catalog:",
|
|
145
|
-
"vitest-config": "5.
|
|
145
|
+
"vitest-config": "5.56.0"
|
|
146
146
|
},
|
|
147
147
|
"engines": {
|
|
148
148
|
"node": ">=20.0.0 <=26.x.x",
|