@strapi/core 5.48.0 → 5.48.1

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.
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var name = "@strapi/core";
6
- var version = "5.48.0";
6
+ var version = "5.48.1";
7
7
  var description = "Core of Strapi";
8
8
  var homepage = "https://strapi.io";
9
9
  var bugs = {
@@ -64,15 +64,15 @@ var dependencies = {
64
64
  "@koa/router": "12.0.2",
65
65
  "@modelcontextprotocol/sdk": "1.29.0",
66
66
  "@paralleldrive/cuid2": "2.2.2",
67
- "@strapi/admin": "5.48.0",
68
- "@strapi/database": "5.48.0",
69
- "@strapi/generators": "5.48.0",
70
- "@strapi/logger": "5.48.0",
71
- "@strapi/openapi": "5.48.0",
72
- "@strapi/permissions": "5.48.0",
73
- "@strapi/types": "5.48.0",
74
- "@strapi/typescript-utils": "5.48.0",
75
- "@strapi/utils": "5.48.0",
67
+ "@strapi/admin": "5.48.1",
68
+ "@strapi/database": "5.48.1",
69
+ "@strapi/generators": "5.48.1",
70
+ "@strapi/logger": "5.48.1",
71
+ "@strapi/openapi": "5.48.1",
72
+ "@strapi/permissions": "5.48.1",
73
+ "@strapi/types": "5.48.1",
74
+ "@strapi/typescript-utils": "5.48.1",
75
+ "@strapi/utils": "5.48.1",
76
76
  "@vercel/stega": "0.1.2",
77
77
  bcryptjs: "2.4.3",
78
78
  boxen: "5.1.2",
@@ -88,6 +88,7 @@ var dependencies = {
88
88
  "fs-extra": "11.3.4",
89
89
  glob: "13.0.6",
90
90
  "global-agent": "4.1.3",
91
+ helmet: "6.2.0",
91
92
  "http-errors": "2.0.0",
92
93
  inquirer: "9.3.8",
93
94
  "is-docker": "2.2.1",
@@ -98,14 +99,14 @@ var dependencies = {
98
99
  "koa-compose": "4.1.0",
99
100
  "koa-compress": "5.1.1",
100
101
  "koa-favicon": "2.1.0",
101
- "koa-helmet": "7.0.2",
102
+ "koa-helmet": "7.1.0",
102
103
  "koa-ip": "^2.1.3",
103
104
  "koa-session": "7.0.2",
104
105
  "koa-static": "5.0.0",
105
106
  lodash: "4.18.1",
106
107
  "mime-types": "2.1.35",
107
108
  "node-schedule": "2.1.1",
108
- open: "8.4.0",
109
+ open: "8.4.2",
109
110
  ora: "5.4.1",
110
111
  "package-json": "7.0.0",
111
112
  "pkg-up": "3.1.0",
@@ -138,14 +139,14 @@ var devDependencies = {
138
139
  "@types/node": "24.10.0",
139
140
  "@types/node-schedule": "2.1.7",
140
141
  "@types/statuses": "2.0.1",
141
- "eslint-config-custom": "5.48.0",
142
+ "eslint-config-custom": "5.48.1",
142
143
  supertest: "7.2.2",
143
- tsconfig: "5.48.0",
144
+ tsconfig: "5.48.1",
144
145
  vitest: "catalog:",
145
- "vitest-config": "5.48.0"
146
+ "vitest-config": "5.48.1"
146
147
  };
147
148
  var engines = {
148
- node: ">=20.0.0 <=24.x.x",
149
+ node: ">=20.0.0 <=26.x.x",
149
150
  npm: ">=6.0.0"
150
151
  };
151
152
  var pkg = {
@@ -1 +1 @@
1
- {"version":3,"file":"package.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"package.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,5 +1,5 @@
1
1
  var name = "@strapi/core";
2
- var version = "5.48.0";
2
+ var version = "5.48.1";
3
3
  var description = "Core of Strapi";
4
4
  var homepage = "https://strapi.io";
5
5
  var bugs = {
@@ -60,15 +60,15 @@ var dependencies = {
60
60
  "@koa/router": "12.0.2",
61
61
  "@modelcontextprotocol/sdk": "1.29.0",
62
62
  "@paralleldrive/cuid2": "2.2.2",
63
- "@strapi/admin": "5.48.0",
64
- "@strapi/database": "5.48.0",
65
- "@strapi/generators": "5.48.0",
66
- "@strapi/logger": "5.48.0",
67
- "@strapi/openapi": "5.48.0",
68
- "@strapi/permissions": "5.48.0",
69
- "@strapi/types": "5.48.0",
70
- "@strapi/typescript-utils": "5.48.0",
71
- "@strapi/utils": "5.48.0",
63
+ "@strapi/admin": "5.48.1",
64
+ "@strapi/database": "5.48.1",
65
+ "@strapi/generators": "5.48.1",
66
+ "@strapi/logger": "5.48.1",
67
+ "@strapi/openapi": "5.48.1",
68
+ "@strapi/permissions": "5.48.1",
69
+ "@strapi/types": "5.48.1",
70
+ "@strapi/typescript-utils": "5.48.1",
71
+ "@strapi/utils": "5.48.1",
72
72
  "@vercel/stega": "0.1.2",
73
73
  bcryptjs: "2.4.3",
74
74
  boxen: "5.1.2",
@@ -84,6 +84,7 @@ var dependencies = {
84
84
  "fs-extra": "11.3.4",
85
85
  glob: "13.0.6",
86
86
  "global-agent": "4.1.3",
87
+ helmet: "6.2.0",
87
88
  "http-errors": "2.0.0",
88
89
  inquirer: "9.3.8",
89
90
  "is-docker": "2.2.1",
@@ -94,14 +95,14 @@ var dependencies = {
94
95
  "koa-compose": "4.1.0",
95
96
  "koa-compress": "5.1.1",
96
97
  "koa-favicon": "2.1.0",
97
- "koa-helmet": "7.0.2",
98
+ "koa-helmet": "7.1.0",
98
99
  "koa-ip": "^2.1.3",
99
100
  "koa-session": "7.0.2",
100
101
  "koa-static": "5.0.0",
101
102
  lodash: "4.18.1",
102
103
  "mime-types": "2.1.35",
103
104
  "node-schedule": "2.1.1",
104
- open: "8.4.0",
105
+ open: "8.4.2",
105
106
  ora: "5.4.1",
106
107
  "package-json": "7.0.0",
107
108
  "pkg-up": "3.1.0",
@@ -134,14 +135,14 @@ var devDependencies = {
134
135
  "@types/node": "24.10.0",
135
136
  "@types/node-schedule": "2.1.7",
136
137
  "@types/statuses": "2.0.1",
137
- "eslint-config-custom": "5.48.0",
138
+ "eslint-config-custom": "5.48.1",
138
139
  supertest: "7.2.2",
139
- tsconfig: "5.48.0",
140
+ tsconfig: "5.48.1",
140
141
  vitest: "catalog:",
141
- "vitest-config": "5.48.0"
142
+ "vitest-config": "5.48.1"
142
143
  };
143
144
  var engines = {
144
- node: ">=20.0.0 <=24.x.x",
145
+ node: ">=20.0.0 <=26.x.x",
145
146
  npm: ">=6.0.0"
146
147
  };
147
148
  var pkg = {
@@ -1 +1 @@
1
- {"version":3,"file":"package.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"package.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"transform-content-types-to-models.d.ts","sourceRoot":"","sources":["../../src/utils/transform-content-types-to-models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+FzB,CAAC;AAEF,eAAO,MAAM,mBAAmB,gBACjB,sBAAsB,eACtB,WAAW,OAazB,CAAC;AAEF,eAAO,MAAM,iBAAiB,gBACf,sBAAsB;UACc,aAAa,GAAG,WAAW;CAI7E,CAAC;AAEF,eAAO,MAAM,gBAAgB,iBAAW,CAAC;AAgFzC,eAAO,MAAM,6BAA6B,iBAC1B,sBAAsB,EAAE,eACzB,WAAW,KACvB,KAAK,EAkEP,CAAC"}
1
+ {"version":3,"file":"transform-content-types-to-models.d.ts","sourceRoot":"","sources":["../../src/utils/transform-content-types-to-models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAE,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAIhD;;;;;;;;;;;GAWG;AAEH,eAAO,MAAM,yBAAyB,mBAAoB,MAAM,eAAe,WAAW,WAKzF,CAAC;AAEF,eAAO,MAAM,kBAAkB,mBAAoB,MAAM,eAAe,WAAW,WAKlF,CAAC;AAEF,eAAO,MAAM,gCAAgC,gBAAiB,WAAW,WAKxE,CAAC;AAEF,eAAO,MAAM,iCAAiC,gBAAiB,WAAW,WAKzE,CAAC;AAEF,eAAO,MAAM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AazB,CAAC;AAEF,eAAO,MAAM,iBAAiB,gBACf,sBAAsB;UACc,aAAa,GAAG,WAAW;CAI7E,CAAC;AAEF,eAAO,MAAM,gBAAgB,iBAAW,CAAC;AAgFzC,eAAO,MAAM,6BAA6B,iBAC1B,sBAAsB,EAAE,eACzB,WAAW,KACvB,KAAK,EAsEP,CAAC"}
@@ -340,7 +340,11 @@ const transformContentTypesToModels = (contentTypes, identifiers)=>{
340
340
  foreignKeys: contentType.foreignKeys,
341
341
  lifecycles: contentType?.lifecycles ?? {}
342
342
  };
343
- // Add indexes to model
343
+ // Document lookups: secondary btree index declared here so syncSchema owns it
344
+ // (instead of DDL in internal migration `5.0.0-06-add-document-id-indexes`, now a no-op).
345
+ // Keep the exact same name/columns schema sync already produced so existing databases
346
+ // see no index diff on upgrade (a rename would orphan the old index, since the schema
347
+ // builder's dropIndex is a silent no-op unless forceMigration is enabled).
344
348
  if (contentType.modelType === 'contentType') {
345
349
  model.indexes = [
346
350
  ...model.indexes || [],
@@ -1 +1 @@
1
- {"version":3,"file":"transform-content-types-to-models.js","sources":["../../src/utils/transform-content-types-to-models.ts"],"sourcesContent":["import { type Model, type Identifiers } from '@strapi/database';\nimport type { Struct, Schema } from '@strapi/types';\nimport { createId } from '@paralleldrive/cuid2';\nimport assert from 'node:assert';\nimport _ from 'lodash/fp';\n\n/**\n * Because strapi/database models don't know about things like components or dynamic zones, we use this file to convert them\n * to a relations format that it recognizes\n *\n * Therefore we have to keep an additional set of helpers/extensions to the database naming methods\n *\n * IMPORTANT!\n * If we use short versions of anything, we MUST call getNameFromTokens directly; attempting to shorten them ourselves\n * prevents the unshortened name map from being filled properly, so for example it will think that the short name\n * 'collection4f3a_cmps' maps to the unshortened 'collectionname_cmps' rather than 'collectionname_components'\n * Therefore, we only use the identifiers helpers in cases where we do not do any of our own shortening\n */\n\nexport const getComponentJoinTableName = (collectionName: string, identifiers: Identifiers) => {\n return identifiers.getNameFromTokens([\n { name: collectionName, compressible: true },\n { name: 'components', shortName: 'cmps', compressible: false },\n ]);\n};\n\nexport const getDzJoinTableName = (collectionName: string, identifiers: Identifiers) => {\n return identifiers.getNameFromTokens([\n { name: collectionName, compressible: true },\n { name: 'components', shortName: 'cmps', compressible: false },\n ]);\n};\n\nexport const getComponentJoinColumnEntityName = (identifiers: Identifiers) => {\n return identifiers.getNameFromTokens([\n { name: 'entity', compressible: false },\n { name: 'id', compressible: false },\n ]);\n};\n\nexport const getComponentJoinColumnInverseName = (identifiers: Identifiers) => {\n return identifiers.getNameFromTokens([\n { name: 'component', shortName: 'cmp', compressible: false },\n { name: 'id', compressible: false },\n ]);\n};\n\nexport const getComponentTypeColumn = (identifiers: Identifiers) => {\n return identifiers.getNameFromTokens([{ name: 'component_type', compressible: false }]);\n};\n\nexport const getComponentFkIndexName = (contentType: string, identifiers: Identifiers) => {\n return identifiers.getNameFromTokens([\n { name: contentType, compressible: true },\n { name: 'entity', compressible: false },\n { name: 'fk', compressible: false },\n ]);\n};\n\n// const { ID_COLUMN: id, FIELD_COLUMN: field, ORDER_COLUMN: order } = identifiers;\n\nexport type LoadedContentTypeModel = Struct.ContentTypeSchema &\n Required<Pick<Struct.ContentTypeSchema, 'collectionName' | 'uid' | 'modelName'>> &\n Pick<Model, 'lifecycles'>;\n\n// Transforms an attribute (particularly for relation types) into the format that strapi/database accepts\nexport const transformAttribute = (\n name: string,\n attribute: Schema.Attribute.AnyAttribute,\n contentType: LoadedContentTypeModel,\n identifiers: Identifiers\n) => {\n switch (attribute.type) {\n case 'media': {\n return {\n type: 'relation',\n relation: attribute.multiple === true ? 'morphMany' : 'morphOne',\n target: 'plugin::upload.file',\n morphBy: 'related',\n };\n }\n case 'component': {\n const joinTableName = getComponentJoinTableName(contentType.collectionName, identifiers);\n const joinColumnEntityName = getComponentJoinColumnEntityName(identifiers);\n const joinColumnInverseName = getComponentJoinColumnInverseName(identifiers);\n const compTypeColumn = getComponentTypeColumn(identifiers);\n return {\n type: 'relation',\n relation: attribute.repeatable === true ? 'oneToMany' : 'oneToOne',\n target: attribute.component,\n\n // We need the join table name to be deterministic,\n // We need to allow passing the join table name as an option\n joinTable: {\n name: joinTableName,\n joinColumn: {\n name: joinColumnEntityName,\n referencedColumn: identifiers.ID_COLUMN,\n },\n inverseJoinColumn: {\n name: joinColumnInverseName,\n referencedColumn: identifiers.ID_COLUMN,\n },\n on: {\n field: name,\n },\n orderColumnName: identifiers.ORDER_COLUMN,\n orderBy: {\n order: 'asc',\n },\n pivotColumns: [\n joinColumnEntityName,\n joinColumnInverseName,\n identifiers.FIELD_COLUMN,\n compTypeColumn,\n ],\n },\n };\n }\n case 'dynamiczone': {\n const joinTableName = getDzJoinTableName(contentType.collectionName, identifiers);\n const joinColumnEntityName = getComponentJoinColumnEntityName(identifiers);\n const joinColumnInverseName = getComponentJoinColumnInverseName(identifiers);\n const compTypeColumn = getComponentTypeColumn(identifiers);\n\n return {\n type: 'relation',\n relation: 'morphToMany',\n // TODO: handle restrictions at some point\n // target: attribute.components,\n joinTable: {\n name: joinTableName,\n joinColumn: {\n name: joinColumnEntityName,\n referencedColumn: identifiers.ID_COLUMN,\n },\n morphColumn: {\n idColumn: {\n name: joinColumnInverseName,\n referencedColumn: identifiers.ID_COLUMN,\n },\n typeColumn: {\n name: compTypeColumn,\n },\n typeField: '__component',\n },\n on: {\n field: name,\n },\n orderBy: {\n order: 'asc',\n },\n pivotColumns: [\n joinColumnEntityName,\n joinColumnInverseName,\n identifiers.FIELD_COLUMN,\n compTypeColumn,\n ],\n },\n };\n }\n default: {\n return attribute;\n }\n }\n};\n\nexport const transformAttributes = (\n contentType: LoadedContentTypeModel,\n identifiers: Identifiers\n) => {\n return Object.keys(contentType.attributes! || {}).reduce((attrs, attrName) => {\n return {\n ...attrs,\n [attrName]: transformAttribute(\n attrName,\n contentType.attributes[attrName]!,\n contentType,\n identifiers\n ),\n };\n }, {});\n};\n\nexport const hasComponentsOrDz = (\n contentType: LoadedContentTypeModel\n): contentType is LoadedContentTypeModel & { type: 'dynamiczone' | 'component' } => {\n return Object.values(contentType.attributes || {}).some(\n (({ type }: { type: string }) => type === 'dynamiczone' || type === 'component') as any\n );\n};\n\nexport const createDocumentId = createId;\n\nconst createCompoLinkModel = (\n contentType: LoadedContentTypeModel,\n identifiers: Identifiers\n): Model => {\n const name = getComponentJoinTableName(contentType.collectionName, identifiers);\n\n const entityId = getComponentJoinColumnEntityName(identifiers);\n const componentId = getComponentJoinColumnInverseName(identifiers);\n const compTypeColumn = getComponentTypeColumn(identifiers);\n const fkIndex = getComponentFkIndexName(contentType.collectionName, identifiers);\n\n return {\n // TODO: make sure there can't be any conflicts with a prefix\n singularName: name,\n uid: name,\n tableName: name,\n attributes: {\n [identifiers.ID_COLUMN]: {\n type: 'increments',\n },\n [entityId]: {\n type: 'integer',\n column: {\n unsigned: true,\n },\n },\n [componentId]: {\n type: 'integer',\n column: {\n unsigned: true,\n },\n },\n [compTypeColumn]: {\n type: 'string',\n },\n [identifiers.FIELD_COLUMN]: {\n type: 'string',\n },\n [identifiers.ORDER_COLUMN]: {\n type: 'float',\n column: {\n unsigned: true,\n defaultTo: null,\n },\n },\n },\n indexes: [\n {\n name: identifiers.getIndexName([contentType.collectionName, identifiers.FIELD_COLUMN]),\n columns: [identifiers.FIELD_COLUMN],\n },\n {\n name: identifiers.getIndexName([contentType.collectionName, compTypeColumn]),\n columns: [compTypeColumn],\n },\n {\n name: fkIndex,\n columns: [entityId],\n },\n {\n // NOTE: since we don't include attribute names, we need to be careful not to create another unique index\n name: identifiers.getUniqueIndexName([contentType.collectionName]),\n columns: [entityId, componentId, identifiers.FIELD_COLUMN, compTypeColumn],\n type: 'unique',\n },\n ],\n foreignKeys: [\n {\n name: fkIndex,\n columns: [entityId],\n referencedColumns: [identifiers.ID_COLUMN],\n referencedTable: identifiers.getTableName(contentType.collectionName),\n onDelete: 'CASCADE',\n },\n ],\n };\n};\n\nexport const transformContentTypesToModels = (\n contentTypes: LoadedContentTypeModel[],\n identifiers: Identifiers\n): Model[] => {\n const models: Model[] = [];\n\n contentTypes.forEach((contentType) => {\n assert(contentType.collectionName, 'Content type \"collectionName\" is required');\n assert(contentType.modelName, 'Content type \"modelName\" is required');\n assert(contentType.uid, 'Content type \"uid\" is required');\n\n // Add document id to content types\n // as it is not documented\n const documentIdAttribute: Record<string, Schema.Attribute.AnyAttribute> =\n contentType.modelType === 'contentType'\n ? { documentId: { type: 'string', default: createDocumentId } }\n : {};\n\n // TODO: this needs to be combined with getReservedNames, we should not be maintaining two lists\n // Prevent user from creating a documentId attribute\n const reservedAttributeNames = ['document_id', identifiers.ID_COLUMN];\n Object.keys(contentType.attributes || {}).forEach((attributeName) => {\n const snakeCasedAttributeName = _.snakeCase(attributeName);\n if (reservedAttributeNames.includes(snakeCasedAttributeName)) {\n throw new Error(\n `The attribute \"${attributeName}\" is reserved and cannot be used in a model. Please rename \"${contentType.modelName}\" attribute \"${attributeName}\" to something else.`\n );\n }\n });\n\n if (hasComponentsOrDz(contentType)) {\n const compoLinkModel = createCompoLinkModel(contentType, identifiers);\n models.push(compoLinkModel);\n }\n\n const model: Model = {\n uid: contentType.uid,\n singularName: contentType.modelName,\n tableName: contentType.collectionName, // This gets shortened in metadata.loadModels(), so we don't shorten here or it will happen twice\n attributes: {\n [identifiers.ID_COLUMN]: {\n type: 'increments',\n },\n ...documentIdAttribute,\n ...transformAttributes(contentType, identifiers),\n },\n indexes: contentType.indexes as Model['indexes'],\n foreignKeys: contentType.foreignKeys as Model['foreignKeys'],\n lifecycles: contentType?.lifecycles ?? {},\n };\n\n // Add indexes to model\n if (contentType.modelType === 'contentType') {\n model.indexes = [\n ...(model.indexes || []),\n {\n name: identifiers.getIndexName([contentType.collectionName, 'documents']),\n // Filter attributes that are not in the schema\n columns: ['documentId', 'locale', 'publishedAt']\n .filter((n) => model.attributes[n])\n .map((name) => identifiers.getColumnName(_.snakeCase(name))),\n },\n ];\n }\n\n models.push(model);\n });\n\n return models;\n};\n"],"names":["getComponentJoinTableName","collectionName","identifiers","getNameFromTokens","name","compressible","shortName","getDzJoinTableName","getComponentJoinColumnEntityName","getComponentJoinColumnInverseName","getComponentTypeColumn","getComponentFkIndexName","contentType","transformAttribute","attribute","type","relation","multiple","target","morphBy","joinTableName","joinColumnEntityName","joinColumnInverseName","compTypeColumn","repeatable","component","joinTable","joinColumn","referencedColumn","ID_COLUMN","inverseJoinColumn","on","field","orderColumnName","ORDER_COLUMN","orderBy","order","pivotColumns","FIELD_COLUMN","morphColumn","idColumn","typeColumn","typeField","transformAttributes","Object","keys","attributes","reduce","attrs","attrName","hasComponentsOrDz","values","some","createDocumentId","createId","createCompoLinkModel","entityId","componentId","fkIndex","singularName","uid","tableName","column","unsigned","defaultTo","indexes","getIndexName","columns","getUniqueIndexName","foreignKeys","referencedColumns","referencedTable","getTableName","onDelete","transformContentTypesToModels","contentTypes","models","forEach","assert","modelName","documentIdAttribute","modelType","documentId","default","reservedAttributeNames","attributeName","snakeCasedAttributeName","_","snakeCase","includes","Error","compoLinkModel","push","model","lifecycles","filter","n","map","getColumnName"],"mappings":";;;;;;AAMA;;;;;;;;;;;AAWC,IAEM,MAAMA,yBAAAA,GAA4B,CAACC,cAAAA,EAAwBC,WAAAA,GAAAA;IAChE,OAAOA,WAAAA,CAAYC,iBAAiB,CAAC;AACnC,QAAA;YAAEC,IAAAA,EAAMH,cAAAA;YAAgBI,YAAAA,EAAc;AAAK,SAAA;AAC3C,QAAA;YAAED,IAAAA,EAAM,YAAA;YAAcE,SAAAA,EAAW,MAAA;YAAQD,YAAAA,EAAc;AAAM;AAC9D,KAAA,CAAA;AACH;AAEO,MAAME,kBAAAA,GAAqB,CAACN,cAAAA,EAAwBC,WAAAA,GAAAA;IACzD,OAAOA,WAAAA,CAAYC,iBAAiB,CAAC;AACnC,QAAA;YAAEC,IAAAA,EAAMH,cAAAA;YAAgBI,YAAAA,EAAc;AAAK,SAAA;AAC3C,QAAA;YAAED,IAAAA,EAAM,YAAA;YAAcE,SAAAA,EAAW,MAAA;YAAQD,YAAAA,E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BAAA,QAAA;AAAU,wBAAA;AAAc,qBAAA,CAC7C4B,MAAM,CAAC,CAACC,IAAMH,KAAAA,CAAM/C,UAAU,CAACkD,CAAAA,CAAE,CAAA,CACjCC,GAAG,CAAC,CAAC7F,IAAAA,GAASF,WAAAA,CAAYgG,aAAa,CAACX,EAAAA,CAAEC,SAAS,CAACpF,IAAAA,CAAAA,CAAAA;AACzD;AACD,aAAA;AACH,QAAA;AAEAwE,QAAAA,MAAAA,CAAOgB,IAAI,CAACC,KAAAA,CAAAA;AACd,IAAA,CAAA,CAAA;IAEA,OAAOjB,MAAAA;AACT;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"transform-content-types-to-models.js","sources":["../../src/utils/transform-content-types-to-models.ts"],"sourcesContent":["import { type Model, type Identifiers } from '@strapi/database';\nimport type { Struct, Schema } from '@strapi/types';\nimport { createId } from '@paralleldrive/cuid2';\nimport assert from 'node:assert';\nimport _ from 'lodash/fp';\n\n/**\n * Because strapi/database models don't know about things like components or dynamic zones, we use this file to convert them\n * to a relations format that it recognizes\n *\n * Therefore we have to keep an additional set of helpers/extensions to the database naming methods\n *\n * IMPORTANT!\n * If we use short versions of anything, we MUST call getNameFromTokens directly; attempting to shorten them ourselves\n * prevents the unshortened name map from being filled properly, so for example it will think that the short name\n * 'collection4f3a_cmps' maps to the unshortened 'collectionname_cmps' rather than 'collectionname_components'\n * Therefore, we only use the identifiers helpers in cases where we do not do any of our own shortening\n */\n\nexport const getComponentJoinTableName = (collectionName: string, identifiers: Identifiers) => {\n return identifiers.getNameFromTokens([\n { name: collectionName, compressible: true },\n { name: 'components', shortName: 'cmps', compressible: false },\n ]);\n};\n\nexport const getDzJoinTableName = (collectionName: string, identifiers: Identifiers) => {\n return identifiers.getNameFromTokens([\n { name: collectionName, compressible: true },\n { name: 'components', shortName: 'cmps', compressible: false },\n ]);\n};\n\nexport const getComponentJoinColumnEntityName = (identifiers: Identifiers) => {\n return identifiers.getNameFromTokens([\n { name: 'entity', compressible: false },\n { name: 'id', compressible: false },\n ]);\n};\n\nexport const getComponentJoinColumnInverseName = (identifiers: Identifiers) => {\n return identifiers.getNameFromTokens([\n { name: 'component', shortName: 'cmp', compressible: false },\n { name: 'id', compressible: false },\n ]);\n};\n\nexport const getComponentTypeColumn = (identifiers: Identifiers) => {\n return identifiers.getNameFromTokens([{ name: 'component_type', compressible: false }]);\n};\n\nexport const getComponentFkIndexName = (contentType: string, identifiers: Identifiers) => {\n return identifiers.getNameFromTokens([\n { name: contentType, compressible: true },\n { name: 'entity', compressible: false },\n { name: 'fk', compressible: false },\n ]);\n};\n\n// const { ID_COLUMN: id, FIELD_COLUMN: field, ORDER_COLUMN: order } = identifiers;\n\nexport type LoadedContentTypeModel = Struct.ContentTypeSchema &\n Required<Pick<Struct.ContentTypeSchema, 'collectionName' | 'uid' | 'modelName'>> &\n Pick<Model, 'lifecycles'>;\n\n// Transforms an attribute (particularly for relation types) into the format that strapi/database accepts\nexport const transformAttribute = (\n name: string,\n attribute: Schema.Attribute.AnyAttribute,\n contentType: LoadedContentTypeModel,\n identifiers: Identifiers\n) => {\n switch (attribute.type) {\n case 'media': {\n return {\n type: 'relation',\n relation: attribute.multiple === true ? 'morphMany' : 'morphOne',\n target: 'plugin::upload.file',\n morphBy: 'related',\n };\n }\n case 'component': {\n const joinTableName = getComponentJoinTableName(contentType.collectionName, identifiers);\n const joinColumnEntityName = getComponentJoinColumnEntityName(identifiers);\n const joinColumnInverseName = getComponentJoinColumnInverseName(identifiers);\n const compTypeColumn = getComponentTypeColumn(identifiers);\n return {\n type: 'relation',\n relation: attribute.repeatable === true ? 'oneToMany' : 'oneToOne',\n target: attribute.component,\n\n // We need the join table name to be deterministic,\n // We need to allow passing the join table name as an option\n joinTable: {\n name: joinTableName,\n joinColumn: {\n name: joinColumnEntityName,\n referencedColumn: identifiers.ID_COLUMN,\n },\n inverseJoinColumn: {\n name: joinColumnInverseName,\n referencedColumn: identifiers.ID_COLUMN,\n },\n on: {\n field: name,\n },\n orderColumnName: identifiers.ORDER_COLUMN,\n orderBy: {\n order: 'asc',\n },\n pivotColumns: [\n joinColumnEntityName,\n joinColumnInverseName,\n identifiers.FIELD_COLUMN,\n compTypeColumn,\n ],\n },\n };\n }\n case 'dynamiczone': {\n const joinTableName = getDzJoinTableName(contentType.collectionName, identifiers);\n const joinColumnEntityName = getComponentJoinColumnEntityName(identifiers);\n const joinColumnInverseName = getComponentJoinColumnInverseName(identifiers);\n const compTypeColumn = getComponentTypeColumn(identifiers);\n\n return {\n type: 'relation',\n relation: 'morphToMany',\n // TODO: handle restrictions at some point\n // target: attribute.components,\n joinTable: {\n name: joinTableName,\n joinColumn: {\n name: joinColumnEntityName,\n referencedColumn: identifiers.ID_COLUMN,\n },\n morphColumn: {\n idColumn: {\n name: joinColumnInverseName,\n referencedColumn: identifiers.ID_COLUMN,\n },\n typeColumn: {\n name: compTypeColumn,\n },\n typeField: '__component',\n },\n on: {\n field: name,\n },\n orderBy: {\n order: 'asc',\n },\n pivotColumns: [\n joinColumnEntityName,\n joinColumnInverseName,\n identifiers.FIELD_COLUMN,\n compTypeColumn,\n ],\n },\n };\n }\n default: {\n return attribute;\n }\n }\n};\n\nexport const transformAttributes = (\n contentType: LoadedContentTypeModel,\n identifiers: Identifiers\n) => {\n return Object.keys(contentType.attributes! || {}).reduce((attrs, attrName) => {\n return {\n ...attrs,\n [attrName]: transformAttribute(\n attrName,\n contentType.attributes[attrName]!,\n contentType,\n identifiers\n ),\n };\n }, {});\n};\n\nexport const hasComponentsOrDz = (\n contentType: LoadedContentTypeModel\n): contentType is LoadedContentTypeModel & { type: 'dynamiczone' | 'component' } => {\n return Object.values(contentType.attributes || {}).some(\n (({ type }: { type: string }) => type === 'dynamiczone' || type === 'component') as any\n );\n};\n\nexport const createDocumentId = createId;\n\nconst createCompoLinkModel = (\n contentType: LoadedContentTypeModel,\n identifiers: Identifiers\n): Model => {\n const name = getComponentJoinTableName(contentType.collectionName, identifiers);\n\n const entityId = getComponentJoinColumnEntityName(identifiers);\n const componentId = getComponentJoinColumnInverseName(identifiers);\n const compTypeColumn = getComponentTypeColumn(identifiers);\n const fkIndex = getComponentFkIndexName(contentType.collectionName, identifiers);\n\n return {\n // TODO: make sure there can't be any conflicts with a prefix\n singularName: name,\n uid: name,\n tableName: name,\n attributes: {\n [identifiers.ID_COLUMN]: {\n type: 'increments',\n },\n [entityId]: {\n type: 'integer',\n column: {\n unsigned: true,\n },\n },\n [componentId]: {\n type: 'integer',\n column: {\n unsigned: true,\n },\n },\n [compTypeColumn]: {\n type: 'string',\n },\n [identifiers.FIELD_COLUMN]: {\n type: 'string',\n },\n [identifiers.ORDER_COLUMN]: {\n type: 'float',\n column: {\n unsigned: true,\n defaultTo: null,\n },\n },\n },\n indexes: [\n {\n name: identifiers.getIndexName([contentType.collectionName, identifiers.FIELD_COLUMN]),\n columns: [identifiers.FIELD_COLUMN],\n },\n {\n name: identifiers.getIndexName([contentType.collectionName, compTypeColumn]),\n columns: [compTypeColumn],\n },\n {\n name: fkIndex,\n columns: [entityId],\n },\n {\n // NOTE: since we don't include attribute names, we need to be careful not to create another unique index\n name: identifiers.getUniqueIndexName([contentType.collectionName]),\n columns: [entityId, componentId, identifiers.FIELD_COLUMN, compTypeColumn],\n type: 'unique',\n },\n ],\n foreignKeys: [\n {\n name: fkIndex,\n columns: [entityId],\n referencedColumns: [identifiers.ID_COLUMN],\n referencedTable: identifiers.getTableName(contentType.collectionName),\n onDelete: 'CASCADE',\n },\n ],\n };\n};\n\nexport const transformContentTypesToModels = (\n contentTypes: LoadedContentTypeModel[],\n identifiers: Identifiers\n): Model[] => {\n const models: Model[] = [];\n\n contentTypes.forEach((contentType) => {\n assert(contentType.collectionName, 'Content type \"collectionName\" is required');\n assert(contentType.modelName, 'Content type \"modelName\" is required');\n assert(contentType.uid, 'Content type \"uid\" is required');\n\n // Add document id to content types\n // as it is not documented\n const documentIdAttribute: Record<string, Schema.Attribute.AnyAttribute> =\n contentType.modelType === 'contentType'\n ? { documentId: { type: 'string', default: createDocumentId } }\n : {};\n\n // TODO: this needs to be combined with getReservedNames, we should not be maintaining two lists\n // Prevent user from creating a documentId attribute\n const reservedAttributeNames = ['document_id', identifiers.ID_COLUMN];\n Object.keys(contentType.attributes || {}).forEach((attributeName) => {\n const snakeCasedAttributeName = _.snakeCase(attributeName);\n if (reservedAttributeNames.includes(snakeCasedAttributeName)) {\n throw new Error(\n `The attribute \"${attributeName}\" is reserved and cannot be used in a model. Please rename \"${contentType.modelName}\" attribute \"${attributeName}\" to something else.`\n );\n }\n });\n\n if (hasComponentsOrDz(contentType)) {\n const compoLinkModel = createCompoLinkModel(contentType, identifiers);\n models.push(compoLinkModel);\n }\n\n const model: Model = {\n uid: contentType.uid,\n singularName: contentType.modelName,\n tableName: contentType.collectionName, // This gets shortened in metadata.loadModels(), so we don't shorten here or it will happen twice\n attributes: {\n [identifiers.ID_COLUMN]: {\n type: 'increments',\n },\n ...documentIdAttribute,\n ...transformAttributes(contentType, identifiers),\n },\n indexes: contentType.indexes as Model['indexes'],\n foreignKeys: contentType.foreignKeys as Model['foreignKeys'],\n lifecycles: contentType?.lifecycles ?? {},\n };\n\n // Document lookups: secondary btree index declared here so syncSchema owns it\n // (instead of DDL in internal migration `5.0.0-06-add-document-id-indexes`, now a no-op).\n // Keep the exact same name/columns schema sync already produced so existing databases\n // see no index diff on upgrade (a rename would orphan the old index, since the schema\n // builder's dropIndex is a silent no-op unless forceMigration is enabled).\n if (contentType.modelType === 'contentType') {\n model.indexes = [\n ...(model.indexes || []),\n {\n name: identifiers.getIndexName([contentType.collectionName, 'documents']),\n // Filter attributes that are not in the schema\n columns: ['documentId', 'locale', 'publishedAt']\n .filter((n) => model.attributes[n])\n .map((name) => identifiers.getColumnName(_.snakeCase(name))),\n },\n ];\n }\n\n models.push(model);\n });\n\n return models;\n};\n"],"names":["getComponentJoinTableName","collectionName","identifiers","getNameFromTokens","name","compressible","shortName","getDzJoinTableName","getComponentJoinColumnEntityName","getComponentJoinColumnInverseName","getComponentTypeColumn","getComponentFkIndexName","contentType","transformAttribute","attribute","type","relation","multiple","target","morphBy","joinTableName","joinColumnEntityName","joinColumnInverseName","compTypeColumn","repeatable","component","joinTable","joinColumn","referencedColumn","ID_COLUMN","inverseJoinColumn","on","field","orderColumnName","ORDER_COLUMN","orderBy","order","pivotColumns","FIELD_COLUMN","morphColumn","idColumn","typeColumn","typeField","transformAttributes","Object","keys","attributes","reduce","attrs","attrName","hasComponentsOrDz","values","some","createDocumentId","createId","createCompoLinkModel","entityId","componentId","fkIndex","singularName","uid","tableName","column","unsigned","defaultTo","indexes","getIndexName","columns","getUniqueIndexName","foreignKeys","referencedColumns","referencedTable","getTableName","onDelete","transformContentTypesToModels","contentTypes","models","forEach","assert","modelName","documentIdAttribute","modelType","documentId","default","reservedAttributeNames","attributeName","snakeCasedAttributeName","_","snakeCase","includes","Error","compoLinkModel","push","model","lifecycles","filter","n","map","getColumnName"],"mappings":";;;;;;AAMA;;;;;;;;;;;AAWC,IAEM,MAAMA,yBAAAA,GAA4B,CAACC,cAAAA,EAAwBC,WAAAA,GAAAA;IAChE,OAAOA,WAAAA,CAAYC,iBAAiB,CAAC;AACnC,QAAA;YAAEC,IAAAA,EAAMH,cAAAA;YAAgBI,YAAAA,EAAc;AAAK,SAAA;AAC3C,QAAA;YAAED,IAAAA,EAAM,YAAA;YAAcE,SAAAA,EAAW,MAAA;YAAQD,YAAAA,EAAc;AAAM;AAC9D,KAAA,CAAA;AACH;AAEO,MAAME,kBAAAA,GAAqB,CAACN,cAAAA,EAAwBC,WAAAA,GAAAA;IACzD,OAAOA,WAAAA,CAAYC,iBAAiB,CAAC;AACnC,QAAA;YAAEC,IAAAA,EAAMH,cAAAA;YAAgBI,YAAAA,EAAc;AAAK,SAAA;AAC3C,QAAA;YAAED,IAAAA,EAAM,YAAA;YAAcE,SAAAA,EAAW,MAAA;YAAQD,YAAAA,EAAc;AAAM;AAC9D,KAAA,CAAA;AACH;AAEO,MAAMG,mCAAmC,CAACN,WAAAA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C,IAAMH,KAAAA,CAAM/C,UAAU,CAACkD,CAAAA,CAAE,CAAA,CACjCC,GAAG,CAAC,CAAC7F,IAAAA,GAASF,WAAAA,CAAYgG,aAAa,CAACX,EAAAA,CAAEC,SAAS,CAACpF,IAAAA,CAAAA,CAAAA;AACzD;AACD,aAAA;AACH,QAAA;AAEAwE,QAAAA,MAAAA,CAAOgB,IAAI,CAACC,KAAAA,CAAAA;AACd,IAAA,CAAA,CAAA;IAEA,OAAOjB,MAAAA;AACT;;;;;;;;;;;;;;"}
@@ -338,7 +338,11 @@ const transformContentTypesToModels = (contentTypes, identifiers)=>{
338
338
  foreignKeys: contentType.foreignKeys,
339
339
  lifecycles: contentType?.lifecycles ?? {}
340
340
  };
341
- // Add indexes to model
341
+ // Document lookups: secondary btree index declared here so syncSchema owns it
342
+ // (instead of DDL in internal migration `5.0.0-06-add-document-id-indexes`, now a no-op).
343
+ // Keep the exact same name/columns schema sync already produced so existing databases
344
+ // see no index diff on upgrade (a rename would orphan the old index, since the schema
345
+ // builder's dropIndex is a silent no-op unless forceMigration is enabled).
342
346
  if (contentType.modelType === 'contentType') {
343
347
  model.indexes = [
344
348
  ...model.indexes || [],
@@ -1 +1 @@
1
- {"version":3,"file":"transform-content-types-to-models.mjs","sources":["../../src/utils/transform-content-types-to-models.ts"],"sourcesContent":["import { type Model, type Identifiers } from '@strapi/database';\nimport type { Struct, Schema } from '@strapi/types';\nimport { createId } from '@paralleldrive/cuid2';\nimport assert from 'node:assert';\nimport _ from 'lodash/fp';\n\n/**\n * Because strapi/database models don't know about things like components or dynamic zones, we use this file to convert them\n * to a relations format that it recognizes\n *\n * Therefore we have to keep an additional set of helpers/extensions to the database naming methods\n *\n * IMPORTANT!\n * If we use short versions of anything, we MUST call getNameFromTokens directly; attempting to shorten them ourselves\n * prevents the unshortened name map from being filled properly, so for example it will think that the short name\n * 'collection4f3a_cmps' maps to the unshortened 'collectionname_cmps' rather than 'collectionname_components'\n * Therefore, we only use the identifiers helpers in cases where we do not do any of our own shortening\n */\n\nexport const getComponentJoinTableName = (collectionName: string, identifiers: Identifiers) => {\n return identifiers.getNameFromTokens([\n { name: collectionName, compressible: true },\n { name: 'components', shortName: 'cmps', compressible: false },\n ]);\n};\n\nexport const getDzJoinTableName = (collectionName: string, identifiers: Identifiers) => {\n return identifiers.getNameFromTokens([\n { name: collectionName, compressible: true },\n { name: 'components', shortName: 'cmps', compressible: false },\n ]);\n};\n\nexport const getComponentJoinColumnEntityName = (identifiers: Identifiers) => {\n return identifiers.getNameFromTokens([\n { name: 'entity', compressible: false },\n { name: 'id', compressible: false },\n ]);\n};\n\nexport const getComponentJoinColumnInverseName = (identifiers: Identifiers) => {\n return identifiers.getNameFromTokens([\n { name: 'component', shortName: 'cmp', compressible: false },\n { name: 'id', compressible: false },\n ]);\n};\n\nexport const getComponentTypeColumn = (identifiers: Identifiers) => {\n return identifiers.getNameFromTokens([{ name: 'component_type', compressible: false }]);\n};\n\nexport const getComponentFkIndexName = (contentType: string, identifiers: Identifiers) => {\n return identifiers.getNameFromTokens([\n { name: contentType, compressible: true },\n { name: 'entity', compressible: false },\n { name: 'fk', compressible: false },\n ]);\n};\n\n// const { ID_COLUMN: id, FIELD_COLUMN: field, ORDER_COLUMN: order } = identifiers;\n\nexport type LoadedContentTypeModel = Struct.ContentTypeSchema &\n Required<Pick<Struct.ContentTypeSchema, 'collectionName' | 'uid' | 'modelName'>> &\n Pick<Model, 'lifecycles'>;\n\n// Transforms an attribute (particularly for relation types) into the format that strapi/database accepts\nexport const transformAttribute = (\n name: string,\n attribute: Schema.Attribute.AnyAttribute,\n contentType: LoadedContentTypeModel,\n identifiers: Identifiers\n) => {\n switch (attribute.type) {\n case 'media': {\n return {\n type: 'relation',\n relation: attribute.multiple === true ? 'morphMany' : 'morphOne',\n target: 'plugin::upload.file',\n morphBy: 'related',\n };\n }\n case 'component': {\n const joinTableName = getComponentJoinTableName(contentType.collectionName, identifiers);\n const joinColumnEntityName = getComponentJoinColumnEntityName(identifiers);\n const joinColumnInverseName = getComponentJoinColumnInverseName(identifiers);\n const compTypeColumn = getComponentTypeColumn(identifiers);\n return {\n type: 'relation',\n relation: attribute.repeatable === true ? 'oneToMany' : 'oneToOne',\n target: attribute.component,\n\n // We need the join table name to be deterministic,\n // We need to allow passing the join table name as an option\n joinTable: {\n name: joinTableName,\n joinColumn: {\n name: joinColumnEntityName,\n referencedColumn: identifiers.ID_COLUMN,\n },\n inverseJoinColumn: {\n name: joinColumnInverseName,\n referencedColumn: identifiers.ID_COLUMN,\n },\n on: {\n field: name,\n },\n orderColumnName: identifiers.ORDER_COLUMN,\n orderBy: {\n order: 'asc',\n },\n pivotColumns: [\n joinColumnEntityName,\n joinColumnInverseName,\n identifiers.FIELD_COLUMN,\n compTypeColumn,\n ],\n },\n };\n }\n case 'dynamiczone': {\n const joinTableName = getDzJoinTableName(contentType.collectionName, identifiers);\n const joinColumnEntityName = getComponentJoinColumnEntityName(identifiers);\n const joinColumnInverseName = getComponentJoinColumnInverseName(identifiers);\n const compTypeColumn = getComponentTypeColumn(identifiers);\n\n return {\n type: 'relation',\n relation: 'morphToMany',\n // TODO: handle restrictions at some point\n // target: attribute.components,\n joinTable: {\n name: joinTableName,\n joinColumn: {\n name: joinColumnEntityName,\n referencedColumn: identifiers.ID_COLUMN,\n },\n morphColumn: {\n idColumn: {\n name: joinColumnInverseName,\n referencedColumn: identifiers.ID_COLUMN,\n },\n typeColumn: {\n name: compTypeColumn,\n },\n typeField: '__component',\n },\n on: {\n field: name,\n },\n orderBy: {\n order: 'asc',\n },\n pivotColumns: [\n joinColumnEntityName,\n joinColumnInverseName,\n identifiers.FIELD_COLUMN,\n compTypeColumn,\n ],\n },\n };\n }\n default: {\n return attribute;\n }\n }\n};\n\nexport const transformAttributes = (\n contentType: LoadedContentTypeModel,\n identifiers: Identifiers\n) => {\n return Object.keys(contentType.attributes! || {}).reduce((attrs, attrName) => {\n return {\n ...attrs,\n [attrName]: transformAttribute(\n attrName,\n contentType.attributes[attrName]!,\n contentType,\n identifiers\n ),\n };\n }, {});\n};\n\nexport const hasComponentsOrDz = (\n contentType: LoadedContentTypeModel\n): contentType is LoadedContentTypeModel & { type: 'dynamiczone' | 'component' } => {\n return Object.values(contentType.attributes || {}).some(\n (({ type }: { type: string }) => type === 'dynamiczone' || type === 'component') as any\n );\n};\n\nexport const createDocumentId = createId;\n\nconst createCompoLinkModel = (\n contentType: LoadedContentTypeModel,\n identifiers: Identifiers\n): Model => {\n const name = getComponentJoinTableName(contentType.collectionName, identifiers);\n\n const entityId = getComponentJoinColumnEntityName(identifiers);\n const componentId = getComponentJoinColumnInverseName(identifiers);\n const compTypeColumn = getComponentTypeColumn(identifiers);\n const fkIndex = getComponentFkIndexName(contentType.collectionName, identifiers);\n\n return {\n // TODO: make sure there can't be any conflicts with a prefix\n singularName: name,\n uid: name,\n tableName: name,\n attributes: {\n [identifiers.ID_COLUMN]: {\n type: 'increments',\n },\n [entityId]: {\n type: 'integer',\n column: {\n unsigned: true,\n },\n },\n [componentId]: {\n type: 'integer',\n column: {\n unsigned: true,\n },\n },\n [compTypeColumn]: {\n type: 'string',\n },\n [identifiers.FIELD_COLUMN]: {\n type: 'string',\n },\n [identifiers.ORDER_COLUMN]: {\n type: 'float',\n column: {\n unsigned: true,\n defaultTo: null,\n },\n },\n },\n indexes: [\n {\n name: identifiers.getIndexName([contentType.collectionName, identifiers.FIELD_COLUMN]),\n columns: [identifiers.FIELD_COLUMN],\n },\n {\n name: identifiers.getIndexName([contentType.collectionName, compTypeColumn]),\n columns: [compTypeColumn],\n },\n {\n name: fkIndex,\n columns: [entityId],\n },\n {\n // NOTE: since we don't include attribute names, we need to be careful not to create another unique index\n name: identifiers.getUniqueIndexName([contentType.collectionName]),\n columns: [entityId, componentId, identifiers.FIELD_COLUMN, compTypeColumn],\n type: 'unique',\n },\n ],\n foreignKeys: [\n {\n name: fkIndex,\n columns: [entityId],\n referencedColumns: [identifiers.ID_COLUMN],\n referencedTable: identifiers.getTableName(contentType.collectionName),\n onDelete: 'CASCADE',\n },\n ],\n };\n};\n\nexport const transformContentTypesToModels = (\n contentTypes: LoadedContentTypeModel[],\n identifiers: Identifiers\n): Model[] => {\n const models: Model[] = [];\n\n contentTypes.forEach((contentType) => {\n assert(contentType.collectionName, 'Content type \"collectionName\" is required');\n assert(contentType.modelName, 'Content type \"modelName\" is required');\n assert(contentType.uid, 'Content type \"uid\" is required');\n\n // Add document id to content types\n // as it is not documented\n const documentIdAttribute: Record<string, Schema.Attribute.AnyAttribute> =\n contentType.modelType === 'contentType'\n ? { documentId: { type: 'string', default: createDocumentId } }\n : {};\n\n // TODO: this needs to be combined with getReservedNames, we should not be maintaining two lists\n // Prevent user from creating a documentId attribute\n const reservedAttributeNames = ['document_id', identifiers.ID_COLUMN];\n Object.keys(contentType.attributes || {}).forEach((attributeName) => {\n const snakeCasedAttributeName = _.snakeCase(attributeName);\n if (reservedAttributeNames.includes(snakeCasedAttributeName)) {\n throw new Error(\n `The attribute \"${attributeName}\" is reserved and cannot be used in a model. Please rename \"${contentType.modelName}\" attribute \"${attributeName}\" to something else.`\n );\n }\n });\n\n if (hasComponentsOrDz(contentType)) {\n const compoLinkModel = createCompoLinkModel(contentType, identifiers);\n models.push(compoLinkModel);\n }\n\n const model: Model = {\n uid: contentType.uid,\n singularName: contentType.modelName,\n tableName: contentType.collectionName, // This gets shortened in metadata.loadModels(), so we don't shorten here or it will happen twice\n attributes: {\n [identifiers.ID_COLUMN]: {\n type: 'increments',\n },\n ...documentIdAttribute,\n ...transformAttributes(contentType, identifiers),\n },\n indexes: contentType.indexes as Model['indexes'],\n foreignKeys: contentType.foreignKeys as Model['foreignKeys'],\n lifecycles: contentType?.lifecycles ?? {},\n };\n\n // Add indexes to model\n if (contentType.modelType === 'contentType') {\n model.indexes = [\n ...(model.indexes || []),\n {\n name: identifiers.getIndexName([contentType.collectionName, 'documents']),\n // Filter attributes that are not in the schema\n columns: ['documentId', 'locale', 'publishedAt']\n .filter((n) => model.attributes[n])\n .map((name) => identifiers.getColumnName(_.snakeCase(name))),\n },\n ];\n }\n\n models.push(model);\n });\n\n return models;\n};\n"],"names":["getComponentJoinTableName","collectionName","identifiers","getNameFromTokens","name","compressible","shortName","getDzJoinTableName","getComponentJoinColumnEntityName","getComponentJoinColumnInverseName","getComponentTypeColumn","getComponentFkIndexName","contentType","transformAttribute","attribute","type","relation","multiple","target","morphBy","joinTableName","joinColumnEntityName","joinColumnInverseName","compTypeColumn","repeatable","component","joinTable","joinColumn","referencedColumn","ID_COLUMN","inverseJoinColumn","on","field","orderColumnName","ORDER_COLUMN","orderBy","order","pivotColumns","FIELD_COLUMN","morphColumn","idColumn","typeColumn","typeField","transformAttributes","Object","keys","attributes","reduce","attrs","attrName","hasComponentsOrDz","values","some","createDocumentId","createId","createCompoLinkModel","entityId","componentId","fkIndex","singularName","uid","tableName","column","unsigned","defaultTo","indexes","getIndexName","columns","getUniqueIndexName","foreignKeys","referencedColumns","referencedTable","getTableName","onDelete","transformContentTypesToModels","contentTypes","models","forEach","assert","modelName","documentIdAttribute","modelType","documentId","default","reservedAttributeNames","attributeName","snakeCasedAttributeName","_","snakeCase","includes","Error","compoLinkModel","push","model","lifecycles","filter","n","map","getColumnName"],"mappings":";;;;AAMA;;;;;;;;;;;AAWC,IAEM,MAAMA,yBAAAA,GAA4B,CAACC,cAAAA,EAAwBC,WAAAA,GAAAA;IAChE,OAAOA,WAAAA,CAAYC,iBAAiB,CAAC;AACnC,QAAA;YAAEC,IAAAA,EAAMH,cAAAA;YAAgBI,YAAAA,EAAc;AAAK,SAAA;AAC3C,QAAA;YAAED,IAAAA,EAAM,YAAA;YAAcE,SAAAA,EAAW,MAAA;YAAQD,YAAAA,EAAc;AAAM;AAC9D,KAAA,CAAA;AACH;AAEO,MAAME,kBAAAA,GAAqB,CAACN,cAAAA,EAAwBC,WAAAA,GAAAA;IACzD,OAAOA,WAAAA,CAAYC,iBAAiB,CAAC;AACnC,QAAA;YAAEC,IAAAA,EAAMH,cAAAA;YAA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BAAAA,WAAAA,CAAYX,cAAc;AAAE,wBAAA;AAAY,qBAAA,CAAA;;oBAExEkE,OAAAA,EAAS;AAAC,wBAAA,YAAA;AAAc,wBAAA,QAAA;AAAU,wBAAA;AAAc,qBAAA,CAC7C4B,MAAM,CAAC,CAACC,IAAMH,KAAAA,CAAM/C,UAAU,CAACkD,CAAAA,CAAE,CAAA,CACjCC,GAAG,CAAC,CAAC7F,IAAAA,GAASF,WAAAA,CAAYgG,aAAa,CAACX,EAAAA,CAAEC,SAAS,CAACpF,IAAAA,CAAAA,CAAAA;AACzD;AACD,aAAA;AACH,QAAA;AAEAwE,QAAAA,MAAAA,CAAOgB,IAAI,CAACC,KAAAA,CAAAA;AACd,IAAA,CAAA,CAAA;IAEA,OAAOjB,MAAAA;AACT;;;;"}
1
+ {"version":3,"file":"transform-content-types-to-models.mjs","sources":["../../src/utils/transform-content-types-to-models.ts"],"sourcesContent":["import { type Model, type Identifiers } from '@strapi/database';\nimport type { Struct, Schema } from '@strapi/types';\nimport { createId } from '@paralleldrive/cuid2';\nimport assert from 'node:assert';\nimport _ from 'lodash/fp';\n\n/**\n * Because strapi/database models don't know about things like components or dynamic zones, we use this file to convert them\n * to a relations format that it recognizes\n *\n * Therefore we have to keep an additional set of helpers/extensions to the database naming methods\n *\n * IMPORTANT!\n * If we use short versions of anything, we MUST call getNameFromTokens directly; attempting to shorten them ourselves\n * prevents the unshortened name map from being filled properly, so for example it will think that the short name\n * 'collection4f3a_cmps' maps to the unshortened 'collectionname_cmps' rather than 'collectionname_components'\n * Therefore, we only use the identifiers helpers in cases where we do not do any of our own shortening\n */\n\nexport const getComponentJoinTableName = (collectionName: string, identifiers: Identifiers) => {\n return identifiers.getNameFromTokens([\n { name: collectionName, compressible: true },\n { name: 'components', shortName: 'cmps', compressible: false },\n ]);\n};\n\nexport const getDzJoinTableName = (collectionName: string, identifiers: Identifiers) => {\n return identifiers.getNameFromTokens([\n { name: collectionName, compressible: true },\n { name: 'components', shortName: 'cmps', compressible: false },\n ]);\n};\n\nexport const getComponentJoinColumnEntityName = (identifiers: Identifiers) => {\n return identifiers.getNameFromTokens([\n { name: 'entity', compressible: false },\n { name: 'id', compressible: false },\n ]);\n};\n\nexport const getComponentJoinColumnInverseName = (identifiers: Identifiers) => {\n return identifiers.getNameFromTokens([\n { name: 'component', shortName: 'cmp', compressible: false },\n { name: 'id', compressible: false },\n ]);\n};\n\nexport const getComponentTypeColumn = (identifiers: Identifiers) => {\n return identifiers.getNameFromTokens([{ name: 'component_type', compressible: false }]);\n};\n\nexport const getComponentFkIndexName = (contentType: string, identifiers: Identifiers) => {\n return identifiers.getNameFromTokens([\n { name: contentType, compressible: true },\n { name: 'entity', compressible: false },\n { name: 'fk', compressible: false },\n ]);\n};\n\n// const { ID_COLUMN: id, FIELD_COLUMN: field, ORDER_COLUMN: order } = identifiers;\n\nexport type LoadedContentTypeModel = Struct.ContentTypeSchema &\n Required<Pick<Struct.ContentTypeSchema, 'collectionName' | 'uid' | 'modelName'>> &\n Pick<Model, 'lifecycles'>;\n\n// Transforms an attribute (particularly for relation types) into the format that strapi/database accepts\nexport const transformAttribute = (\n name: string,\n attribute: Schema.Attribute.AnyAttribute,\n contentType: LoadedContentTypeModel,\n identifiers: Identifiers\n) => {\n switch (attribute.type) {\n case 'media': {\n return {\n type: 'relation',\n relation: attribute.multiple === true ? 'morphMany' : 'morphOne',\n target: 'plugin::upload.file',\n morphBy: 'related',\n };\n }\n case 'component': {\n const joinTableName = getComponentJoinTableName(contentType.collectionName, identifiers);\n const joinColumnEntityName = getComponentJoinColumnEntityName(identifiers);\n const joinColumnInverseName = getComponentJoinColumnInverseName(identifiers);\n const compTypeColumn = getComponentTypeColumn(identifiers);\n return {\n type: 'relation',\n relation: attribute.repeatable === true ? 'oneToMany' : 'oneToOne',\n target: attribute.component,\n\n // We need the join table name to be deterministic,\n // We need to allow passing the join table name as an option\n joinTable: {\n name: joinTableName,\n joinColumn: {\n name: joinColumnEntityName,\n referencedColumn: identifiers.ID_COLUMN,\n },\n inverseJoinColumn: {\n name: joinColumnInverseName,\n referencedColumn: identifiers.ID_COLUMN,\n },\n on: {\n field: name,\n },\n orderColumnName: identifiers.ORDER_COLUMN,\n orderBy: {\n order: 'asc',\n },\n pivotColumns: [\n joinColumnEntityName,\n joinColumnInverseName,\n identifiers.FIELD_COLUMN,\n compTypeColumn,\n ],\n },\n };\n }\n case 'dynamiczone': {\n const joinTableName = getDzJoinTableName(contentType.collectionName, identifiers);\n const joinColumnEntityName = getComponentJoinColumnEntityName(identifiers);\n const joinColumnInverseName = getComponentJoinColumnInverseName(identifiers);\n const compTypeColumn = getComponentTypeColumn(identifiers);\n\n return {\n type: 'relation',\n relation: 'morphToMany',\n // TODO: handle restrictions at some point\n // target: attribute.components,\n joinTable: {\n name: joinTableName,\n joinColumn: {\n name: joinColumnEntityName,\n referencedColumn: identifiers.ID_COLUMN,\n },\n morphColumn: {\n idColumn: {\n name: joinColumnInverseName,\n referencedColumn: identifiers.ID_COLUMN,\n },\n typeColumn: {\n name: compTypeColumn,\n },\n typeField: '__component',\n },\n on: {\n field: name,\n },\n orderBy: {\n order: 'asc',\n },\n pivotColumns: [\n joinColumnEntityName,\n joinColumnInverseName,\n identifiers.FIELD_COLUMN,\n compTypeColumn,\n ],\n },\n };\n }\n default: {\n return attribute;\n }\n }\n};\n\nexport const transformAttributes = (\n contentType: LoadedContentTypeModel,\n identifiers: Identifiers\n) => {\n return Object.keys(contentType.attributes! || {}).reduce((attrs, attrName) => {\n return {\n ...attrs,\n [attrName]: transformAttribute(\n attrName,\n contentType.attributes[attrName]!,\n contentType,\n identifiers\n ),\n };\n }, {});\n};\n\nexport const hasComponentsOrDz = (\n contentType: LoadedContentTypeModel\n): contentType is LoadedContentTypeModel & { type: 'dynamiczone' | 'component' } => {\n return Object.values(contentType.attributes || {}).some(\n (({ type }: { type: string }) => type === 'dynamiczone' || type === 'component') as any\n );\n};\n\nexport const createDocumentId = createId;\n\nconst createCompoLinkModel = (\n contentType: LoadedContentTypeModel,\n identifiers: Identifiers\n): Model => {\n const name = getComponentJoinTableName(contentType.collectionName, identifiers);\n\n const entityId = getComponentJoinColumnEntityName(identifiers);\n const componentId = getComponentJoinColumnInverseName(identifiers);\n const compTypeColumn = getComponentTypeColumn(identifiers);\n const fkIndex = getComponentFkIndexName(contentType.collectionName, identifiers);\n\n return {\n // TODO: make sure there can't be any conflicts with a prefix\n singularName: name,\n uid: name,\n tableName: name,\n attributes: {\n [identifiers.ID_COLUMN]: {\n type: 'increments',\n },\n [entityId]: {\n type: 'integer',\n column: {\n unsigned: true,\n },\n },\n [componentId]: {\n type: 'integer',\n column: {\n unsigned: true,\n },\n },\n [compTypeColumn]: {\n type: 'string',\n },\n [identifiers.FIELD_COLUMN]: {\n type: 'string',\n },\n [identifiers.ORDER_COLUMN]: {\n type: 'float',\n column: {\n unsigned: true,\n defaultTo: null,\n },\n },\n },\n indexes: [\n {\n name: identifiers.getIndexName([contentType.collectionName, identifiers.FIELD_COLUMN]),\n columns: [identifiers.FIELD_COLUMN],\n },\n {\n name: identifiers.getIndexName([contentType.collectionName, compTypeColumn]),\n columns: [compTypeColumn],\n },\n {\n name: fkIndex,\n columns: [entityId],\n },\n {\n // NOTE: since we don't include attribute names, we need to be careful not to create another unique index\n name: identifiers.getUniqueIndexName([contentType.collectionName]),\n columns: [entityId, componentId, identifiers.FIELD_COLUMN, compTypeColumn],\n type: 'unique',\n },\n ],\n foreignKeys: [\n {\n name: fkIndex,\n columns: [entityId],\n referencedColumns: [identifiers.ID_COLUMN],\n referencedTable: identifiers.getTableName(contentType.collectionName),\n onDelete: 'CASCADE',\n },\n ],\n };\n};\n\nexport const transformContentTypesToModels = (\n contentTypes: LoadedContentTypeModel[],\n identifiers: Identifiers\n): Model[] => {\n const models: Model[] = [];\n\n contentTypes.forEach((contentType) => {\n assert(contentType.collectionName, 'Content type \"collectionName\" is required');\n assert(contentType.modelName, 'Content type \"modelName\" is required');\n assert(contentType.uid, 'Content type \"uid\" is required');\n\n // Add document id to content types\n // as it is not documented\n const documentIdAttribute: Record<string, Schema.Attribute.AnyAttribute> =\n contentType.modelType === 'contentType'\n ? { documentId: { type: 'string', default: createDocumentId } }\n : {};\n\n // TODO: this needs to be combined with getReservedNames, we should not be maintaining two lists\n // Prevent user from creating a documentId attribute\n const reservedAttributeNames = ['document_id', identifiers.ID_COLUMN];\n Object.keys(contentType.attributes || {}).forEach((attributeName) => {\n const snakeCasedAttributeName = _.snakeCase(attributeName);\n if (reservedAttributeNames.includes(snakeCasedAttributeName)) {\n throw new Error(\n `The attribute \"${attributeName}\" is reserved and cannot be used in a model. Please rename \"${contentType.modelName}\" attribute \"${attributeName}\" to something else.`\n );\n }\n });\n\n if (hasComponentsOrDz(contentType)) {\n const compoLinkModel = createCompoLinkModel(contentType, identifiers);\n models.push(compoLinkModel);\n }\n\n const model: Model = {\n uid: contentType.uid,\n singularName: contentType.modelName,\n tableName: contentType.collectionName, // This gets shortened in metadata.loadModels(), so we don't shorten here or it will happen twice\n attributes: {\n [identifiers.ID_COLUMN]: {\n type: 'increments',\n },\n ...documentIdAttribute,\n ...transformAttributes(contentType, identifiers),\n },\n indexes: contentType.indexes as Model['indexes'],\n foreignKeys: contentType.foreignKeys as Model['foreignKeys'],\n lifecycles: contentType?.lifecycles ?? {},\n };\n\n // Document lookups: secondary btree index declared here so syncSchema owns it\n // (instead of DDL in internal migration `5.0.0-06-add-document-id-indexes`, now a no-op).\n // Keep the exact same name/columns schema sync already produced so existing databases\n // see no index diff on upgrade (a rename would orphan the old index, since the schema\n // builder's dropIndex is a silent no-op unless forceMigration is enabled).\n if (contentType.modelType === 'contentType') {\n model.indexes = [\n ...(model.indexes || []),\n {\n name: identifiers.getIndexName([contentType.collectionName, 'documents']),\n // Filter attributes that are not in the schema\n columns: ['documentId', 'locale', 'publishedAt']\n .filter((n) => model.attributes[n])\n .map((name) => identifiers.getColumnName(_.snakeCase(name))),\n },\n ];\n }\n\n models.push(model);\n });\n\n return models;\n};\n"],"names":["getComponentJoinTableName","collectionName","identifiers","getNameFromTokens","name","compressible","shortName","getDzJoinTableName","getComponentJoinColumnEntityName","getComponentJoinColumnInverseName","getComponentTypeColumn","getComponentFkIndexName","contentType","transformAttribute","attribute","type","relation","multiple","target","morphBy","joinTableName","joinColumnEntityName","joinColumnInverseName","compTypeColumn","repeatable","component","joinTable","joinColumn","referencedColumn","ID_COLUMN","inverseJoinColumn","on","field","orderColumnName","ORDER_COLUMN","orderBy","order","pivotColumns","FIELD_COLUMN","morphColumn","idColumn","typeColumn","typeField","transformAttributes","Object","keys","attributes","reduce","attrs","attrName","hasComponentsOrDz","values","some","createDocumentId","createId","createCompoLinkModel","entityId","componentId","fkIndex","singularName","uid","tableName","column","unsigned","defaultTo","indexes","getIndexName","columns","getUniqueIndexName","foreignKeys","referencedColumns","referencedTable","getTableName","onDelete","transformContentTypesToModels","contentTypes","models","forEach","assert","modelName","documentIdAttribute","modelType","documentId","default","reservedAttributeNames","attributeName","snakeCasedAttributeName","_","snakeCase","includes","Error","compoLinkModel","push","model","lifecycles","filter","n","map","getColumnName"],"mappings":";;;;AAMA;;;;;;;;;;;AAWC,IAEM,MAAMA,yBAAAA,GAA4B,CAACC,cAAAA,EAAwBC,WAAAA,GAAAA;IAChE,OAAOA,WAAAA,CAAYC,iBAAiB,CAAC;AACnC,QAAA;YAAEC,IAAAA,EAAMH,cAAAA;YAAgBI,YAAAA,EAAc;AAAK,SAAA;AAC3C,QAAA;YAAED,IAAAA,EAAM,YAAA;YAAcE,SAAAA,EAAW,MAAA;YAAQD,YAAAA,EAAc;AAAM;AAC9D,KAAA,CAAA;AACH;AAEO,MAAME,kBAAAA,GAAqB,CAACN,cAAAA,EAAwBC,WAAAA,GAAAA;IACzD,OAAOA,WAAAA,CAAYC,iBAAiB,CAAC;AACnC,QAAA;YAAEC,IAAAA,EAAMH,cAAAA;YAAgBI,YAAAA,EAAc;AAAK,SAAA;AAC3C,QAAA;YAAED,IAAAA,EAAM,YAAA;YAAcE,SAAA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A,EAAS;AAAC,wBAAA,YAAA;AAAc,wBAAA,QAAA;AAAU,wBAAA;AAAc,qBAAA,CAC7C4B,MAAM,CAAC,CAACC,IAAMH,KAAAA,CAAM/C,UAAU,CAACkD,CAAAA,CAAE,CAAA,CACjCC,GAAG,CAAC,CAAC7F,IAAAA,GAASF,WAAAA,CAAYgG,aAAa,CAACX,EAAAA,CAAEC,SAAS,CAACpF,IAAAA,CAAAA,CAAAA;AACzD;AACD,aAAA;AACH,QAAA;AAEAwE,QAAAA,MAAAA,CAAOgB,IAAI,CAACC,KAAAA,CAAAA;AACd,IAAA,CAAA,CAAA;IAEA,OAAOjB,MAAAA;AACT;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/core",
3
- "version": "5.48.0",
3
+ "version": "5.48.1",
4
4
  "description": "Core of Strapi",
5
5
  "homepage": "https://strapi.io",
6
6
  "bugs": {
@@ -61,15 +61,15 @@
61
61
  "@koa/router": "12.0.2",
62
62
  "@modelcontextprotocol/sdk": "1.29.0",
63
63
  "@paralleldrive/cuid2": "2.2.2",
64
- "@strapi/admin": "5.48.0",
65
- "@strapi/database": "5.48.0",
66
- "@strapi/generators": "5.48.0",
67
- "@strapi/logger": "5.48.0",
68
- "@strapi/openapi": "5.48.0",
69
- "@strapi/permissions": "5.48.0",
70
- "@strapi/types": "5.48.0",
71
- "@strapi/typescript-utils": "5.48.0",
72
- "@strapi/utils": "5.48.0",
64
+ "@strapi/admin": "5.48.1",
65
+ "@strapi/database": "5.48.1",
66
+ "@strapi/generators": "5.48.1",
67
+ "@strapi/logger": "5.48.1",
68
+ "@strapi/openapi": "5.48.1",
69
+ "@strapi/permissions": "5.48.1",
70
+ "@strapi/types": "5.48.1",
71
+ "@strapi/typescript-utils": "5.48.1",
72
+ "@strapi/utils": "5.48.1",
73
73
  "@vercel/stega": "0.1.2",
74
74
  "bcryptjs": "2.4.3",
75
75
  "boxen": "5.1.2",
@@ -85,6 +85,7 @@
85
85
  "fs-extra": "11.3.4",
86
86
  "glob": "13.0.6",
87
87
  "global-agent": "4.1.3",
88
+ "helmet": "6.2.0",
88
89
  "http-errors": "2.0.0",
89
90
  "inquirer": "9.3.8",
90
91
  "is-docker": "2.2.1",
@@ -95,14 +96,14 @@
95
96
  "koa-compose": "4.1.0",
96
97
  "koa-compress": "5.1.1",
97
98
  "koa-favicon": "2.1.0",
98
- "koa-helmet": "7.0.2",
99
+ "koa-helmet": "7.1.0",
99
100
  "koa-ip": "^2.1.3",
100
101
  "koa-session": "7.0.2",
101
102
  "koa-static": "5.0.0",
102
103
  "lodash": "4.18.1",
103
104
  "mime-types": "2.1.35",
104
105
  "node-schedule": "2.1.1",
105
- "open": "8.4.0",
106
+ "open": "8.4.2",
106
107
  "ora": "5.4.1",
107
108
  "package-json": "7.0.0",
108
109
  "pkg-up": "3.1.0",
@@ -135,14 +136,14 @@
135
136
  "@types/node": "24.10.0",
136
137
  "@types/node-schedule": "2.1.7",
137
138
  "@types/statuses": "2.0.1",
138
- "eslint-config-custom": "5.48.0",
139
+ "eslint-config-custom": "5.48.1",
139
140
  "supertest": "7.2.2",
140
- "tsconfig": "5.48.0",
141
+ "tsconfig": "5.48.1",
141
142
  "vitest": "catalog:",
142
- "vitest-config": "5.48.0"
143
+ "vitest-config": "5.48.1"
143
144
  },
144
145
  "engines": {
145
- "node": ">=20.0.0 <=24.x.x",
146
+ "node": ">=20.0.0 <=26.x.x",
146
147
  "npm": ">=6.0.0"
147
148
  }
148
149
  }