@strapi/core 5.47.1 → 5.48.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/configuration/index.d.ts +24 -0
- package/dist/configuration/index.d.ts.map +1 -1
- package/dist/configuration/index.js +47 -22
- package/dist/configuration/index.js.map +1 -1
- package/dist/configuration/index.mjs +47 -22
- package/dist/configuration/index.mjs.map +1 -1
- package/dist/package.json.js +14 -13
- package/dist/package.json.js.map +1 -1
- package/dist/package.json.mjs +14 -13
- package/dist/package.json.mjs.map +1 -1
- package/dist/services/document-service/draft-and-publish.d.ts +4 -4
- package/dist/services/document-service/internationalization.d.ts +4 -4
- package/dist/services/document-service/utils/unidirectional-relations.d.ts.map +1 -1
- package/dist/services/document-service/utils/unidirectional-relations.js +17 -4
- package/dist/services/document-service/utils/unidirectional-relations.js.map +1 -1
- package/dist/services/document-service/utils/unidirectional-relations.mjs +17 -4
- package/dist/services/document-service/utils/unidirectional-relations.mjs.map +1 -1
- package/dist/services/entity-validator/validators.d.ts.map +1 -1
- package/dist/services/entity-validator/validators.js +51 -2
- package/dist/services/entity-validator/validators.js.map +1 -1
- package/dist/services/entity-validator/validators.mjs +51 -2
- package/dist/services/entity-validator/validators.mjs.map +1 -1
- package/dist/services/server/openapi.d.ts +3 -0
- package/dist/services/server/openapi.d.ts.map +1 -0
- package/dist/services/server/openapi.js +209 -0
- package/dist/services/server/openapi.js.map +1 -0
- package/dist/services/server/openapi.mjs +188 -0
- package/dist/services/server/openapi.mjs.map +1 -0
- package/dist/services/server/register-routes.d.ts.map +1 -1
- package/dist/services/server/register-routes.js +2 -0
- package/dist/services/server/register-routes.js.map +1 -1
- package/dist/services/server/register-routes.mjs +2 -0
- package/dist/services/server/register-routes.mjs.map +1 -1
- package/dist/utils/startup-logger.d.ts.map +1 -1
- package/dist/utils/startup-logger.js +18 -6
- package/dist/utils/startup-logger.js.map +1 -1
- package/dist/utils/startup-logger.mjs +18 -6
- package/dist/utils/startup-logger.mjs.map +1 -1
- package/package.json +14 -13
|
@@ -38,6 +38,30 @@ export declare const loadConfiguration: (opts: StrapiOptions) => {
|
|
|
38
38
|
enabled: true;
|
|
39
39
|
};
|
|
40
40
|
};
|
|
41
|
+
openapi: {
|
|
42
|
+
'content-api': {
|
|
43
|
+
access: "disabled";
|
|
44
|
+
route: {
|
|
45
|
+
path: string;
|
|
46
|
+
};
|
|
47
|
+
cache: {
|
|
48
|
+
enabled: true;
|
|
49
|
+
maxAgeMs: number;
|
|
50
|
+
filePath: string;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
admin: {
|
|
54
|
+
access: "disabled";
|
|
55
|
+
route: {
|
|
56
|
+
path: string;
|
|
57
|
+
};
|
|
58
|
+
cache: {
|
|
59
|
+
enabled: true;
|
|
60
|
+
maxAgeMs: number;
|
|
61
|
+
filePath: string;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
};
|
|
41
65
|
};
|
|
42
66
|
admin: {};
|
|
43
67
|
api: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/configuration/index.ts"],"names":[],"mappings":"AAGA,OAAO,CAAC,MAAM,QAAQ,CAAC;AAUvB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/configuration/index.ts"],"names":[],"mappings":"AAGA,OAAO,CAAC,MAAM,QAAQ,CAAC;AAUvB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AA+D/C,eAAO,MAAM,iBAAiB,SAAU,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wEAkDpD,CAAC"}
|
|
@@ -15,34 +15,59 @@ dotenv.config({
|
|
|
15
15
|
path: process.env.ENV_PATH
|
|
16
16
|
});
|
|
17
17
|
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
18
|
+
const defaultServerConfig = {
|
|
19
|
+
host: process.env.HOST || os.hostname() || 'localhost',
|
|
20
|
+
port: Number(process.env.PORT) || 1337,
|
|
21
|
+
proxy: false,
|
|
22
|
+
cron: {
|
|
23
|
+
enabled: false
|
|
24
|
+
},
|
|
25
|
+
admin: {
|
|
26
|
+
autoOpen: false
|
|
27
|
+
},
|
|
28
|
+
dirs: {
|
|
29
|
+
public: './public'
|
|
30
|
+
},
|
|
31
|
+
transfer: {
|
|
32
|
+
remote: {
|
|
33
|
+
enabled: true
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
logger: {
|
|
37
|
+
updates: {
|
|
38
|
+
enabled: true
|
|
31
39
|
},
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
40
|
+
startup: {
|
|
41
|
+
enabled: true
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
openapi: {
|
|
45
|
+
'content-api': {
|
|
46
|
+
access: 'disabled',
|
|
47
|
+
route: {
|
|
48
|
+
path: '/openapi.json'
|
|
49
|
+
},
|
|
50
|
+
cache: {
|
|
51
|
+
enabled: true,
|
|
52
|
+
maxAgeMs: 60000,
|
|
53
|
+
filePath: '.strapi/openapi/content-api.json'
|
|
35
54
|
}
|
|
36
55
|
},
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
56
|
+
admin: {
|
|
57
|
+
access: 'disabled',
|
|
58
|
+
route: {
|
|
59
|
+
path: '/openapi.json'
|
|
40
60
|
},
|
|
41
|
-
|
|
42
|
-
enabled: true
|
|
61
|
+
cache: {
|
|
62
|
+
enabled: true,
|
|
63
|
+
maxAgeMs: 60000,
|
|
64
|
+
filePath: '.strapi/openapi/admin.json'
|
|
43
65
|
}
|
|
44
66
|
}
|
|
45
|
-
}
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
const defaultConfig = {
|
|
70
|
+
server: defaultServerConfig,
|
|
46
71
|
admin: {},
|
|
47
72
|
api: {
|
|
48
73
|
rest: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/configuration/index.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-var-requires */\nimport os from 'os';\nimport path from 'path';\nimport _ from 'lodash';\nimport { omit } from 'lodash/fp';\nimport dotenv from 'dotenv';\nimport type { Core } from '@strapi/types';\nimport { strings } from '@strapi/utils';\n\nimport { getConfigUrls, getAbsoluteAdminUrl, getAbsoluteServerUrl } from './urls';\nimport loadConfigDir from './config-loader';\nimport { getDirs } from './get-dirs';\n\nimport type { StrapiOptions } from '../Strapi';\nimport { version as strapiVersion } from '../../package.json';\n\ndotenv.config({ path: process.env.ENV_PATH });\n\nprocess.env.NODE_ENV = process.env.NODE_ENV || 'development';\n\nconst
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/configuration/index.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-var-requires */\nimport os from 'os';\nimport path from 'path';\nimport _ from 'lodash';\nimport { omit } from 'lodash/fp';\nimport dotenv from 'dotenv';\nimport type { Core } from '@strapi/types';\nimport { strings } from '@strapi/utils';\n\nimport { getConfigUrls, getAbsoluteAdminUrl, getAbsoluteServerUrl } from './urls';\nimport loadConfigDir from './config-loader';\nimport { getDirs } from './get-dirs';\n\nimport type { StrapiOptions } from '../Strapi';\nimport { version as strapiVersion } from '../../package.json';\n\ndotenv.config({ path: process.env.ENV_PATH });\n\nprocess.env.NODE_ENV = process.env.NODE_ENV || 'development';\n\nconst defaultServerConfig = {\n host: process.env.HOST || os.hostname() || 'localhost',\n port: Number(process.env.PORT) || 1337,\n proxy: false,\n cron: { enabled: false },\n admin: { autoOpen: false },\n dirs: { public: './public' },\n transfer: {\n remote: {\n enabled: true,\n },\n },\n logger: {\n updates: {\n enabled: true,\n },\n startup: {\n enabled: true,\n },\n },\n openapi: {\n 'content-api': {\n access: 'disabled',\n route: {\n path: '/openapi.json',\n },\n cache: {\n enabled: true,\n maxAgeMs: 60_000,\n filePath: '.strapi/openapi/content-api.json',\n },\n },\n admin: {\n access: 'disabled',\n route: {\n path: '/openapi.json',\n },\n cache: {\n enabled: true,\n maxAgeMs: 60_000,\n filePath: '.strapi/openapi/admin.json',\n },\n },\n },\n} satisfies Partial<Core.Config.Server>;\n\nconst defaultConfig = {\n server: defaultServerConfig,\n admin: {} satisfies Partial<Core.Config.Admin>,\n api: {\n rest: {\n prefix: '/api',\n },\n } satisfies Partial<Core.Config.Api>,\n};\n\nexport const loadConfiguration = (opts: StrapiOptions) => {\n const { appDir, distDir, autoReload = false, serveAdminPanel = true } = opts;\n\n const pkgJSON = require(path.resolve(appDir, 'package.json'));\n\n const configDir = path.resolve(distDir || process.cwd(), 'config');\n\n const rootConfig = {\n launchedAt: Date.now(),\n autoReload,\n environment: process.env.NODE_ENV,\n uuid: _.get(pkgJSON, 'strapi.uuid'),\n installId: _.get(pkgJSON, 'strapi.installId'),\n packageJsonStrapi: _.omit(_.get(pkgJSON, 'strapi', {}), 'uuid'),\n info: {\n ...pkgJSON,\n strapi: strapiVersion,\n },\n admin: {\n serveAdminPanel,\n },\n };\n\n // See packages/core/core/src/domain/module/index.ts for plugin config loading\n const baseConfig = omit('plugins', loadConfigDir(configDir)); // plugin config will be loaded later\n\n const envDir = path.resolve(configDir, 'env', process.env.NODE_ENV as string);\n const envConfig = loadConfigDir(envDir);\n\n const config = _.merge(rootConfig, defaultConfig, baseConfig, envConfig);\n\n const { serverUrl, adminUrl } = getConfigUrls(config);\n\n const serverAbsoluteUrl = getAbsoluteServerUrl(config);\n const adminAbsoluteUrl = getAbsoluteAdminUrl(config);\n\n const sameOrigin = new URL(adminAbsoluteUrl).origin === new URL(serverAbsoluteUrl).origin;\n\n const adminPath = sameOrigin\n ? adminUrl.replace(strings.getCommonPath(serverUrl, adminUrl), '')\n : new URL(adminUrl).pathname;\n\n _.set(config, 'server.url', serverUrl);\n _.set(config, 'server.absoluteUrl', serverAbsoluteUrl);\n _.set(config, 'admin.url', adminUrl);\n _.set(config, 'admin.path', adminPath);\n _.set(config, 'admin.absoluteUrl', adminAbsoluteUrl);\n _.set(config, 'dirs', getDirs(opts, config));\n\n return config;\n};\n"],"names":["dotenv","config","path","process","env","ENV_PATH","NODE_ENV","defaultServerConfig","host","HOST","os","hostname","port","Number","PORT","proxy","cron","enabled","admin","autoOpen","dirs","public","transfer","remote","logger","updates","startup","openapi","access","route","cache","maxAgeMs","filePath","defaultConfig","server","api","rest","prefix","loadConfiguration","opts","appDir","distDir","autoReload","serveAdminPanel","pkgJSON","require","resolve","configDir","cwd","rootConfig","launchedAt","Date","now","environment","uuid","_","get","installId","packageJsonStrapi","omit","info","strapi","strapiVersion","baseConfig","loadConfigDir","envDir","envConfig","merge","serverUrl","adminUrl","getConfigUrls","serverAbsoluteUrl","getAbsoluteServerUrl","adminAbsoluteUrl","getAbsoluteAdminUrl","sameOrigin","URL","origin","adminPath","replace","strings","getCommonPath","pathname","set","getDirs"],"mappings":";;;;;;;;;;;;;AAgBAA,MAAAA,CAAOC,MAAM,CAAC;IAAEC,IAAAA,EAAMC,OAAAA,CAAQC,GAAG,CAACC;AAAS,CAAA,CAAA;AAE3CF,OAAAA,CAAQC,GAAG,CAACE,QAAQ,GAAGH,QAAQC,GAAG,CAACE,QAAQ,IAAI,aAAA;AAE/C,MAAMC,mBAAAA,GAAsB;AAC1BC,IAAAA,IAAAA,EAAML,QAAQC,GAAG,CAACK,IAAI,IAAIC,EAAAA,CAAGC,QAAQ,EAAA,IAAM,WAAA;AAC3CC,IAAAA,IAAAA,EAAMC,MAAAA,CAAOV,OAAAA,CAAQC,GAAG,CAACU,IAAI,CAAA,IAAK,IAAA;IAClCC,KAAAA,EAAO,KAAA;IACP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
16
|
+
const defaultServerConfig = {
|
|
17
|
+
host: process.env.HOST || os.hostname() || 'localhost',
|
|
18
|
+
port: Number(process.env.PORT) || 1337,
|
|
19
|
+
proxy: false,
|
|
20
|
+
cron: {
|
|
21
|
+
enabled: false
|
|
22
|
+
},
|
|
23
|
+
admin: {
|
|
24
|
+
autoOpen: false
|
|
25
|
+
},
|
|
26
|
+
dirs: {
|
|
27
|
+
public: './public'
|
|
28
|
+
},
|
|
29
|
+
transfer: {
|
|
30
|
+
remote: {
|
|
31
|
+
enabled: true
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
logger: {
|
|
35
|
+
updates: {
|
|
36
|
+
enabled: true
|
|
29
37
|
},
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
38
|
+
startup: {
|
|
39
|
+
enabled: true
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
openapi: {
|
|
43
|
+
'content-api': {
|
|
44
|
+
access: 'disabled',
|
|
45
|
+
route: {
|
|
46
|
+
path: '/openapi.json'
|
|
47
|
+
},
|
|
48
|
+
cache: {
|
|
49
|
+
enabled: true,
|
|
50
|
+
maxAgeMs: 60000,
|
|
51
|
+
filePath: '.strapi/openapi/content-api.json'
|
|
33
52
|
}
|
|
34
53
|
},
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
54
|
+
admin: {
|
|
55
|
+
access: 'disabled',
|
|
56
|
+
route: {
|
|
57
|
+
path: '/openapi.json'
|
|
38
58
|
},
|
|
39
|
-
|
|
40
|
-
enabled: true
|
|
59
|
+
cache: {
|
|
60
|
+
enabled: true,
|
|
61
|
+
maxAgeMs: 60000,
|
|
62
|
+
filePath: '.strapi/openapi/admin.json'
|
|
41
63
|
}
|
|
42
64
|
}
|
|
43
|
-
}
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
const defaultConfig = {
|
|
68
|
+
server: defaultServerConfig,
|
|
44
69
|
admin: {},
|
|
45
70
|
api: {
|
|
46
71
|
rest: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../src/configuration/index.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-var-requires */\nimport os from 'os';\nimport path from 'path';\nimport _ from 'lodash';\nimport { omit } from 'lodash/fp';\nimport dotenv from 'dotenv';\nimport type { Core } from '@strapi/types';\nimport { strings } from '@strapi/utils';\n\nimport { getConfigUrls, getAbsoluteAdminUrl, getAbsoluteServerUrl } from './urls';\nimport loadConfigDir from './config-loader';\nimport { getDirs } from './get-dirs';\n\nimport type { StrapiOptions } from '../Strapi';\nimport { version as strapiVersion } from '../../package.json';\n\ndotenv.config({ path: process.env.ENV_PATH });\n\nprocess.env.NODE_ENV = process.env.NODE_ENV || 'development';\n\nconst
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/configuration/index.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-var-requires */\nimport os from 'os';\nimport path from 'path';\nimport _ from 'lodash';\nimport { omit } from 'lodash/fp';\nimport dotenv from 'dotenv';\nimport type { Core } from '@strapi/types';\nimport { strings } from '@strapi/utils';\n\nimport { getConfigUrls, getAbsoluteAdminUrl, getAbsoluteServerUrl } from './urls';\nimport loadConfigDir from './config-loader';\nimport { getDirs } from './get-dirs';\n\nimport type { StrapiOptions } from '../Strapi';\nimport { version as strapiVersion } from '../../package.json';\n\ndotenv.config({ path: process.env.ENV_PATH });\n\nprocess.env.NODE_ENV = process.env.NODE_ENV || 'development';\n\nconst defaultServerConfig = {\n host: process.env.HOST || os.hostname() || 'localhost',\n port: Number(process.env.PORT) || 1337,\n proxy: false,\n cron: { enabled: false },\n admin: { autoOpen: false },\n dirs: { public: './public' },\n transfer: {\n remote: {\n enabled: true,\n },\n },\n logger: {\n updates: {\n enabled: true,\n },\n startup: {\n enabled: true,\n },\n },\n openapi: {\n 'content-api': {\n access: 'disabled',\n route: {\n path: '/openapi.json',\n },\n cache: {\n enabled: true,\n maxAgeMs: 60_000,\n filePath: '.strapi/openapi/content-api.json',\n },\n },\n admin: {\n access: 'disabled',\n route: {\n path: '/openapi.json',\n },\n cache: {\n enabled: true,\n maxAgeMs: 60_000,\n filePath: '.strapi/openapi/admin.json',\n },\n },\n },\n} satisfies Partial<Core.Config.Server>;\n\nconst defaultConfig = {\n server: defaultServerConfig,\n admin: {} satisfies Partial<Core.Config.Admin>,\n api: {\n rest: {\n prefix: '/api',\n },\n } satisfies Partial<Core.Config.Api>,\n};\n\nexport const loadConfiguration = (opts: StrapiOptions) => {\n const { appDir, distDir, autoReload = false, serveAdminPanel = true } = opts;\n\n const pkgJSON = require(path.resolve(appDir, 'package.json'));\n\n const configDir = path.resolve(distDir || process.cwd(), 'config');\n\n const rootConfig = {\n launchedAt: Date.now(),\n autoReload,\n environment: process.env.NODE_ENV,\n uuid: _.get(pkgJSON, 'strapi.uuid'),\n installId: _.get(pkgJSON, 'strapi.installId'),\n packageJsonStrapi: _.omit(_.get(pkgJSON, 'strapi', {}), 'uuid'),\n info: {\n ...pkgJSON,\n strapi: strapiVersion,\n },\n admin: {\n serveAdminPanel,\n },\n };\n\n // See packages/core/core/src/domain/module/index.ts for plugin config loading\n const baseConfig = omit('plugins', loadConfigDir(configDir)); // plugin config will be loaded later\n\n const envDir = path.resolve(configDir, 'env', process.env.NODE_ENV as string);\n const envConfig = loadConfigDir(envDir);\n\n const config = _.merge(rootConfig, defaultConfig, baseConfig, envConfig);\n\n const { serverUrl, adminUrl } = getConfigUrls(config);\n\n const serverAbsoluteUrl = getAbsoluteServerUrl(config);\n const adminAbsoluteUrl = getAbsoluteAdminUrl(config);\n\n const sameOrigin = new URL(adminAbsoluteUrl).origin === new URL(serverAbsoluteUrl).origin;\n\n const adminPath = sameOrigin\n ? adminUrl.replace(strings.getCommonPath(serverUrl, adminUrl), '')\n : new URL(adminUrl).pathname;\n\n _.set(config, 'server.url', serverUrl);\n _.set(config, 'server.absoluteUrl', serverAbsoluteUrl);\n _.set(config, 'admin.url', adminUrl);\n _.set(config, 'admin.path', adminPath);\n _.set(config, 'admin.absoluteUrl', adminAbsoluteUrl);\n _.set(config, 'dirs', getDirs(opts, config));\n\n return config;\n};\n"],"names":["dotenv","config","path","process","env","ENV_PATH","NODE_ENV","defaultServerConfig","host","HOST","os","hostname","port","Number","PORT","proxy","cron","enabled","admin","autoOpen","dirs","public","transfer","remote","logger","updates","startup","openapi","access","route","cache","maxAgeMs","filePath","defaultConfig","server","api","rest","prefix","loadConfiguration","opts","appDir","distDir","autoReload","serveAdminPanel","pkgJSON","require","resolve","configDir","cwd","rootConfig","launchedAt","Date","now","environment","uuid","_","get","installId","packageJsonStrapi","omit","info","strapi","strapiVersion","baseConfig","loadConfigDir","envDir","envConfig","merge","serverUrl","adminUrl","getConfigUrls","serverAbsoluteUrl","getAbsoluteServerUrl","adminAbsoluteUrl","getAbsoluteAdminUrl","sameOrigin","URL","origin","adminPath","replace","strings","getCommonPath","pathname","set","getDirs"],"mappings":";;;;;;;;;;;AAgBAA,MAAAA,CAAOC,MAAM,CAAC;IAAEC,IAAAA,EAAMC,OAAAA,CAAQC,GAAG,CAACC;AAAS,CAAA,CAAA;AAE3CF,OAAAA,CAAQC,GAAG,CAACE,QAAQ,GAAGH,QAAQC,GAAG,CAACE,QAAQ,IAAI,aAAA;AAE/C,MAAMC,mBAAAA,GAAsB;AAC1BC,IAAAA,IAAAA,EAAML,QAAQC,GAAG,CAACK,IAAI,IAAIC,EAAAA,CAAGC,QAAQ,EAAA,IAAM,WAAA;AAC3CC,IAAAA,IAAAA,EAAMC,MAAAA,CAAOV,OAAAA,CAAQC,GAAG,CAACU,IAAI,CAAA,IAAK,IAAA;IAClCC,KAAAA,EAAO,KAAA;IACPC,IAAAA,EAAM;QAAEC,OAAAA,EAAS;AAAM,KAAA;IACvBC,KAAAA,EAAO;QAAEC,QAAAA,EAAU;AAAM,KAAA;IACzBC,IAAAA,EAAM;QAAEC,MAAAA,EAAQ;AAAW,KAAA;IAC3BC,QAAAA,EAAU;QACRC,MAAAA,EA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AA,MAAMC,SAAAA,GAAYH,UAAAA,GACdN,QAAAA,CAASU,OAAO,CAACC,OAAAA,CAAQC,aAAa,CAACb,SAAAA,EAAWC,QAAAA,CAAAA,EAAW,EAAA,CAAA,GAC7D,IAAIO,GAAAA,CAAIP,UAAUa,QAAQ;IAE9B3B,CAAAA,CAAE4B,GAAG,CAAClF,MAAAA,EAAQ,YAAA,EAAcmE,SAAAA,CAAAA;IAC5Bb,CAAAA,CAAE4B,GAAG,CAAClF,MAAAA,EAAQ,oBAAA,EAAsBsE,iBAAAA,CAAAA;IACpChB,CAAAA,CAAE4B,GAAG,CAAClF,MAAAA,EAAQ,WAAA,EAAaoE,QAAAA,CAAAA;IAC3Bd,CAAAA,CAAE4B,GAAG,CAAClF,MAAAA,EAAQ,YAAA,EAAc6E,SAAAA,CAAAA;IAC5BvB,CAAAA,CAAE4B,GAAG,CAAClF,MAAAA,EAAQ,mBAAA,EAAqBwE,gBAAAA,CAAAA;AACnClB,IAAAA,CAAAA,CAAE4B,GAAG,CAAClF,MAAAA,EAAQ,MAAA,EAAQmF,QAAQ7C,IAAAA,EAAMtC,MAAAA,CAAAA,CAAAA;IAEpC,OAAOA,MAAAA;AACT;;;;"}
|
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.48.0";
|
|
7
7
|
var description = "Core of Strapi";
|
|
8
8
|
var homepage = "https://strapi.io";
|
|
9
9
|
var bugs = {
|
|
@@ -64,14 +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.
|
|
68
|
-
"@strapi/database": "5.
|
|
69
|
-
"@strapi/generators": "5.
|
|
70
|
-
"@strapi/logger": "5.
|
|
71
|
-
"@strapi/
|
|
72
|
-
"@strapi/
|
|
73
|
-
"@strapi/
|
|
74
|
-
"@strapi/utils": "5.
|
|
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",
|
|
75
76
|
"@vercel/stega": "0.1.2",
|
|
76
77
|
bcryptjs: "2.4.3",
|
|
77
78
|
boxen: "5.1.2",
|
|
@@ -122,7 +123,7 @@ var devDependencies = {
|
|
|
122
123
|
"@swc/core": "1.13.5",
|
|
123
124
|
"@types/bcryptjs": "2.4.3",
|
|
124
125
|
"@types/configstore": "5.0.1",
|
|
125
|
-
"@types/delegates": "1.0.
|
|
126
|
+
"@types/delegates": "1.0.3",
|
|
126
127
|
"@types/fs-extra": "11.0.4",
|
|
127
128
|
"@types/global-agent": "3.0.0",
|
|
128
129
|
"@types/http-errors": "2.0.4",
|
|
@@ -137,11 +138,11 @@ var devDependencies = {
|
|
|
137
138
|
"@types/node": "24.10.0",
|
|
138
139
|
"@types/node-schedule": "2.1.7",
|
|
139
140
|
"@types/statuses": "2.0.1",
|
|
140
|
-
"eslint-config-custom": "5.
|
|
141
|
+
"eslint-config-custom": "5.48.0",
|
|
141
142
|
supertest: "7.2.2",
|
|
142
|
-
tsconfig: "5.
|
|
143
|
+
tsconfig: "5.48.0",
|
|
143
144
|
vitest: "catalog:",
|
|
144
|
-
"vitest-config": "5.
|
|
145
|
+
"vitest-config": "5.48.0"
|
|
145
146
|
};
|
|
146
147
|
var engines = {
|
|
147
148
|
node: ">=20.0.0 <=24.x.x",
|
package/dist/package.json.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"package.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/package.json.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var name = "@strapi/core";
|
|
2
|
-
var version = "5.
|
|
2
|
+
var version = "5.48.0";
|
|
3
3
|
var description = "Core of Strapi";
|
|
4
4
|
var homepage = "https://strapi.io";
|
|
5
5
|
var bugs = {
|
|
@@ -60,14 +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.
|
|
64
|
-
"@strapi/database": "5.
|
|
65
|
-
"@strapi/generators": "5.
|
|
66
|
-
"@strapi/logger": "5.
|
|
67
|
-
"@strapi/
|
|
68
|
-
"@strapi/
|
|
69
|
-
"@strapi/
|
|
70
|
-
"@strapi/utils": "5.
|
|
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",
|
|
71
72
|
"@vercel/stega": "0.1.2",
|
|
72
73
|
bcryptjs: "2.4.3",
|
|
73
74
|
boxen: "5.1.2",
|
|
@@ -118,7 +119,7 @@ var devDependencies = {
|
|
|
118
119
|
"@swc/core": "1.13.5",
|
|
119
120
|
"@types/bcryptjs": "2.4.3",
|
|
120
121
|
"@types/configstore": "5.0.1",
|
|
121
|
-
"@types/delegates": "1.0.
|
|
122
|
+
"@types/delegates": "1.0.3",
|
|
122
123
|
"@types/fs-extra": "11.0.4",
|
|
123
124
|
"@types/global-agent": "3.0.0",
|
|
124
125
|
"@types/http-errors": "2.0.4",
|
|
@@ -133,11 +134,11 @@ var devDependencies = {
|
|
|
133
134
|
"@types/node": "24.10.0",
|
|
134
135
|
"@types/node-schedule": "2.1.7",
|
|
135
136
|
"@types/statuses": "2.0.1",
|
|
136
|
-
"eslint-config-custom": "5.
|
|
137
|
+
"eslint-config-custom": "5.48.0",
|
|
137
138
|
supertest: "7.2.2",
|
|
138
|
-
tsconfig: "5.
|
|
139
|
+
tsconfig: "5.48.0",
|
|
139
140
|
vitest: "catalog:",
|
|
140
|
-
"vitest-config": "5.
|
|
141
|
+
"vitest-config": "5.48.0"
|
|
141
142
|
};
|
|
142
143
|
var engines = {
|
|
143
144
|
node: ">=20.0.0 <=24.x.x",
|
|
@@ -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,10 +1,10 @@
|
|
|
1
1
|
/// <reference types="lodash" />
|
|
2
2
|
import type { Modules, Struct } from '@strapi/types';
|
|
3
|
-
declare const setStatusToDraftCurry: import("lodash").CurriedFunction2<Struct.
|
|
3
|
+
declare const setStatusToDraftCurry: import("lodash").CurriedFunction2<Struct.CollectionTypeSchema | Struct.SingleTypeSchema, Modules.Documents.Params.All, Modules.Documents.Params.All>;
|
|
4
4
|
declare const defaultToDraftCurry: import("lodash").CurriedFunction1<Modules.Documents.Params.All, Modules.Documents.Params.All>;
|
|
5
|
-
declare const defaultStatusCurry: import("lodash").CurriedFunction2<Struct.
|
|
5
|
+
declare const defaultStatusCurry: import("lodash").CurriedFunction2<Struct.CollectionTypeSchema | Struct.SingleTypeSchema, Modules.Documents.Params.All, Modules.Documents.Params.All>;
|
|
6
6
|
declare const filterDataPublishedAtCurry: import("lodash").CurriedFunction1<Modules.Documents.Params.All, Modules.Documents.Params.All>;
|
|
7
|
-
declare const statusToLookupCurry: import("lodash").CurriedFunction2<Struct.
|
|
8
|
-
declare const statusToDataCurry: import("lodash").CurriedFunction2<Struct.
|
|
7
|
+
declare const statusToLookupCurry: import("lodash").CurriedFunction2<Struct.CollectionTypeSchema | Struct.SingleTypeSchema, Modules.Documents.Params.All, Modules.Documents.Params.All>;
|
|
8
|
+
declare const statusToDataCurry: import("lodash").CurriedFunction2<Struct.CollectionTypeSchema | Struct.SingleTypeSchema, Modules.Documents.Params.All, Modules.Documents.Params.All>;
|
|
9
9
|
export { setStatusToDraftCurry as setStatusToDraft, defaultToDraftCurry as defaultToDraft, defaultStatusCurry as defaultStatus, filterDataPublishedAtCurry as filterDataPublishedAt, statusToLookupCurry as statusToLookup, statusToDataCurry as statusToData, };
|
|
10
10
|
//# sourceMappingURL=draft-and-publish.d.ts.map
|
|
@@ -5,9 +5,9 @@ import type { Struct, Modules } from '@strapi/types';
|
|
|
5
5
|
* for a different locale of the same document. Returns a new object with the merged data.
|
|
6
6
|
*/
|
|
7
7
|
declare const copyNonLocalizedFields: (contentType: Struct.SingleTypeSchema | Struct.CollectionTypeSchema, documentId: string, dataToCreate: Record<string, any>) => Promise<Record<string, any>>;
|
|
8
|
-
declare const defaultLocaleCurry: import("lodash").CurriedFunction2<Struct.
|
|
9
|
-
declare const localeToLookupCurry: import("lodash").CurriedFunction2<Struct.
|
|
10
|
-
declare const multiLocaleToLookupCurry: import("lodash").CurriedFunction2<Struct.
|
|
11
|
-
declare const localeToDataCurry: import("lodash").CurriedFunction2<Struct.
|
|
8
|
+
declare const defaultLocaleCurry: import("lodash").CurriedFunction2<Struct.CollectionTypeSchema | Struct.SingleTypeSchema, Modules.Documents.Params.All, Promise<Modules.Documents.Params.All>>;
|
|
9
|
+
declare const localeToLookupCurry: import("lodash").CurriedFunction2<Struct.CollectionTypeSchema | Struct.SingleTypeSchema, Modules.Documents.Params.All, Modules.Documents.Params.All>;
|
|
10
|
+
declare const multiLocaleToLookupCurry: import("lodash").CurriedFunction2<Struct.CollectionTypeSchema | Struct.SingleTypeSchema, Modules.Documents.Params.All, Modules.Documents.Params.All>;
|
|
11
|
+
declare const localeToDataCurry: import("lodash").CurriedFunction2<Struct.CollectionTypeSchema | Struct.SingleTypeSchema, Modules.Documents.Params.All, Modules.Documents.Params.All>;
|
|
12
12
|
export { defaultLocaleCurry as defaultLocale, localeToLookupCurry as localeToLookup, localeToDataCurry as localeToData, multiLocaleToLookupCurry as multiLocaleToLookup, copyNonLocalizedFields, };
|
|
13
13
|
//# sourceMappingURL=internationalization.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unidirectional-relations.d.ts","sourceRoot":"","sources":["../../../../src/services/document-service/utils/unidirectional-relations.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAElD,UAAU,WAAW;IACnB,WAAW,EAAE;QAAE,EAAE,EAAE,IAAI,CAAC,EAAE,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC/C,WAAW,EAAE;QAAE,EAAE,EAAE,IAAI,CAAC,EAAE,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAChD;AAED,UAAU,cAAc;IACtB,SAAS,EAAE,SAAS,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;CAClC;AAED,UAAU,qBAAqB;IAC7B;;;OAGG;IACH,uBAAuB,CAAC,EAAE,CACxB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC7B,KAAK,EAAE,MAAM,CAAC,SAAS,GAAG,MAAM,CAAC,WAAW,EAC5C,GAAG,EAAE,GAAG,KACL,OAAO,CAAC,OAAO,CAAC,CAAC;CACvB;AAED;;;;GAIG;AACH,QAAA,MAAM,IAAI,QACH,IAAI,WAAW,gCACU,WAAW,YAChC,qBAAqB,KAC7B,QAAQ,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"unidirectional-relations.d.ts","sourceRoot":"","sources":["../../../../src/services/document-service/utils/unidirectional-relations.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAElD,UAAU,WAAW;IACnB,WAAW,EAAE;QAAE,EAAE,EAAE,IAAI,CAAC,EAAE,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC/C,WAAW,EAAE;QAAE,EAAE,EAAE,IAAI,CAAC,EAAE,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAChD;AAED,UAAU,cAAc;IACtB,SAAS,EAAE,SAAS,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;CAClC;AAED,UAAU,qBAAqB;IAC7B;;;OAGG;IACH,uBAAuB,CAAC,EAAE,CACxB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC7B,KAAK,EAAE,MAAM,CAAC,SAAS,GAAG,MAAM,CAAC,WAAW,EAC5C,GAAG,EAAE,GAAG,KACL,OAAO,CAAC,OAAO,CAAC,CAAC;CACvB;AAED;;;;GAIG;AACH,QAAA,MAAM,IAAI,QACH,IAAI,WAAW,gCACU,WAAW,YAChC,qBAAqB,KAC7B,QAAQ,cAAc,EAAE,CA0H1B,CAAC;AAEF;;;;;;;;;;GAUG;AACH,QAAA,MAAM,IAAI,eACI;IAAE,EAAE,EAAE,KAAK,EAAE,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAAE,cACjC;IAAE,EAAE,EAAE,KAAK,EAAE,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAAE,gBAC/B;IAAE,SAAS,EAAE,GAAG,CAAC;IAAC,SAAS,EAAE,GAAG,EAAE,CAAA;CAAE,EAAE,kBAiCrD,CAAC;AAEF,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AACtB,YAAY,EAAE,qBAAqB,EAAE,CAAC"}
|
|
@@ -20,9 +20,13 @@ var fp = require('lodash/fp');
|
|
|
20
20
|
for (const attribute of Object.values(dbModel.attributes)){
|
|
21
21
|
/**
|
|
22
22
|
* Only consider unidirectional relations.
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
|
|
23
|
+
* Bidirectional relations (inversedBy/mappedBy) are handled by bidirectionalRelations.
|
|
24
|
+
* Self-referential relations (model.uid === uid) are included here, but rows where
|
|
25
|
+
* the source entry is also being republished in this same operation are excluded —
|
|
26
|
+
* those are handled by selfReferentialRelations, which remaps both sides simultaneously.
|
|
27
|
+
* Without this guard, we would insert rows pointing to a source entry that is about
|
|
28
|
+
* to be deleted, creating stale foreign-key values.
|
|
29
|
+
*/ if (attribute.type !== 'relation' || attribute.target !== uid || attribute.inversedBy || attribute.mappedBy) {
|
|
26
30
|
continue;
|
|
27
31
|
}
|
|
28
32
|
// TODO: joinColumn relations
|
|
@@ -36,7 +40,16 @@ var fp = require('lodash/fp');
|
|
|
36
40
|
* Load all relations that need to be updated
|
|
37
41
|
*/ // NOTE: when the model has draft and publish, we can assume relation are only draft to draft & published to published
|
|
38
42
|
const ids = oldVersions.map((entry)=>entry.id);
|
|
39
|
-
|
|
43
|
+
let oldVersionsQuery = strapi.db.getConnection().select('*').from(joinTable.name).whereIn(targetColumnName, ids);
|
|
44
|
+
/**
|
|
45
|
+
* For self-referential relations, exclude join rows where the source entry is also
|
|
46
|
+
* being republished. When both sides are in the same publish batch, selfReferentialRelations
|
|
47
|
+
* already handles remapping them. Including them here too would insert a row whose
|
|
48
|
+
* source FK points at an entry that is about to be deleted.
|
|
49
|
+
*/ if (model.uid === uid && ids.length > 0) {
|
|
50
|
+
oldVersionsQuery = oldVersionsQuery.whereNotIn(sourceColumnName, ids);
|
|
51
|
+
}
|
|
52
|
+
const oldVersionsRelations = await oldVersionsQuery.transacting(trx);
|
|
40
53
|
if (oldVersionsRelations.length > 0) {
|
|
41
54
|
updates.push({
|
|
42
55
|
joinTable,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unidirectional-relations.js","sources":["../../../../src/services/document-service/utils/unidirectional-relations.ts"],"sourcesContent":["/* eslint-disable no-continue */\nimport { keyBy, omit } from 'lodash/fp';\n\nimport type { Data, UID, Schema } from '@strapi/types';\n\nimport type { JoinTable } from '@strapi/database';\n\ninterface LoadContext {\n oldVersions: { id: Data.ID; locale: string }[];\n newVersions: { id: Data.ID; locale: string }[];\n}\n\ninterface RelationUpdate {\n joinTable: JoinTable;\n relations: Record<string, any>[];\n}\n\ninterface RelationFilterOptions {\n /**\n * Function to determine if a relation should be propagated to new document versions\n * This replaces the hardcoded component-specific logic\n */\n shouldPropagateRelation?: (\n relation: Record<string, any>,\n model: Schema.Component | Schema.ContentType,\n trx: any\n ) => Promise<boolean>;\n}\n\n/**\n * Loads lingering relations that need to be updated when overriding a published or draft entry.\n * This is necessary because the relations are uni-directional and the target entry is not aware of the source entry.\n * This is not the case for bi-directional relations, where the target entry is also linked to the source entry.\n */\nconst load = async (\n uid: UID.ContentType,\n { oldVersions, newVersions }: LoadContext,\n options: RelationFilterOptions = {}\n): Promise<RelationUpdate[]> => {\n const updates: RelationUpdate[] = [];\n\n // Iterate all components and content types to find relations that need to be updated\n await strapi.db.transaction(async ({ trx }) => {\n const contentTypes = Object.values(strapi.contentTypes) as Schema.ContentType[];\n const components = Object.values(strapi.components) as Schema.Component[];\n\n for (const model of [...contentTypes, ...components]) {\n const dbModel = strapi.db.metadata.get(model.uid);\n\n for (const attribute of Object.values(dbModel.attributes) as any) {\n /**\n * Only consider unidirectional relations.\n * Self-referential relations (model.uid === uid) are handled by selfReferentialRelations;\n * processing them here would re-insert stale source FK values pointing to deleted entries.\n */\n if (\n attribute.type !== 'relation' ||\n attribute.target !== uid ||\n attribute.inversedBy ||\n attribute.mappedBy ||\n model.uid === uid\n ) {\n continue;\n }\n\n // TODO: joinColumn relations\n const joinTable = attribute.joinTable;\n if (!joinTable) {\n continue;\n }\n\n const { name: sourceColumnName } = joinTable.joinColumn;\n const { name: targetColumnName } = joinTable.inverseJoinColumn;\n\n /**\n * Load all relations that need to be updated\n */\n // NOTE: when the model has draft and publish, we can assume relation are only draft to draft & published to published\n const ids = oldVersions.map((entry) => entry.id);\n\n const oldVersionsRelations = await strapi.db\n .getConnection()\n .select('*')\n .from(joinTable.name)\n .whereIn(targetColumnName, ids)\n .transacting(trx);\n\n if (oldVersionsRelations.length > 0) {\n updates.push({ joinTable, relations: oldVersionsRelations });\n }\n\n /**\n * if publishing\n * if published version exists\n * updated published versions links\n * else\n * create link to newly published version\n *\n * if discarding\n * if published version link exists & not draft version link\n * create link to new draft version\n */\n if (!model.options?.draftAndPublish) {\n const ids = newVersions.map((entry) => entry.id);\n\n // This is the step were we query the join table based on the id of the document\n const newVersionsRelations = await strapi.db\n .getConnection()\n .select('*')\n .from(joinTable.name)\n .whereIn(targetColumnName, ids)\n .transacting(trx);\n\n let versionRelations = newVersionsRelations;\n if (options.shouldPropagateRelation) {\n const relationsToPropagate = [];\n for (const relation of newVersionsRelations) {\n if (await options.shouldPropagateRelation(relation, model, trx)) {\n relationsToPropagate.push(relation);\n }\n }\n versionRelations = relationsToPropagate;\n }\n\n if (versionRelations.length > 0) {\n // when publishing a draft that doesn't have a published version yet,\n // copy the links to the draft over to the published version\n // when discarding a published version, if no drafts exists\n const discardToAdd = versionRelations\n .filter((relation) => {\n const matchingOldVersion = oldVersionsRelations.find((oldRelation) => {\n return oldRelation[sourceColumnName] === relation[sourceColumnName];\n });\n\n return !matchingOldVersion;\n })\n .map(omit(strapi.db.metadata.identifiers.ID_COLUMN));\n\n updates.push({ joinTable, relations: discardToAdd });\n }\n }\n }\n }\n });\n\n return updates;\n};\n\n/**\n * Updates uni directional relations to target the right entries when overriding published or draft entries.\n *\n * This function:\n * 1. Creates new relations pointing to the new entry versions\n * 2. Precisely deletes only the old relations being replaced to prevent orphaned links\n *\n * @param oldEntries The old entries that are being overridden\n * @param newEntries The new entries that are overriding the old ones\n * @param oldRelations The relations that were previously loaded with `load` @see load\n */\nconst sync = async (\n oldEntries: { id: Data.ID; locale: string }[],\n newEntries: { id: Data.ID; locale: string }[],\n oldRelations: { joinTable: any; relations: any[] }[]\n) => {\n /**\n * Create a map of old entry ids to new entry ids\n *\n * Will be used to update the relation target ids\n */\n const newEntryByLocale = keyBy('locale', newEntries);\n const oldEntriesMap = oldEntries.reduce(\n (acc, entry) => {\n const newEntry = newEntryByLocale[entry.locale];\n if (!newEntry) return acc;\n acc[String(entry.id)] = newEntry.id;\n return acc;\n },\n {} as Record<string, Data.ID>\n );\n\n await strapi.db.transaction(async ({ trx }) => {\n // Iterate old relations that are deleted and insert the new ones\n for (const { joinTable, relations } of oldRelations) {\n // Update old ids with the new ones\n const column = joinTable.inverseJoinColumn.name;\n\n const newRelations = relations.map((relation) => {\n const newId = oldEntriesMap[relation[column]];\n return { ...relation, [column]: newId };\n });\n\n const batchSize = strapi.db.dialect.getBatchInsertSize();\n await trx.batchInsert(joinTable.name, newRelations, batchSize);\n }\n });\n};\n\nexport { load, sync };\nexport type { RelationFilterOptions };\n"],"names":["load","uid","oldVersions","newVersions","options","updates","strapi","db","transaction","trx","contentTypes","Object","values","components","model","dbModel","metadata","get","attribute","attributes","type","target","inversedBy","mappedBy","joinTable","name","sourceColumnName","joinColumn","targetColumnName","inverseJoinColumn","ids","map","entry","id","oldVersionsRelations","getConnection","select","from","whereIn","transacting","length","push","relations","draftAndPublish","newVersionsRelations","versionRelations","shouldPropagateRelation","relationsToPropagate","relation","discardToAdd","filter","matchingOldVersion","find","oldRelation","omit","identifiers","ID_COLUMN","sync","oldEntries","newEntries","oldRelations","newEntryByLocale","keyBy","oldEntriesMap","reduce","acc","newEntry","locale","String","column","newRelations","newId","batchSize","dialect","getBatchInsertSize","batchInsert"],"mappings":";;;;AA6BA;;;;AAIC,IACD,MAAMA,IAAAA,GAAO,OACXC,GAAAA,EACA,EAAEC,WAAW,EAAEC,WAAW,EAAe,EACzCC,OAAAA,GAAiC,EAAE,GAAA;AAEnC,IAAA,MAAMC,UAA4B,EAAE;;IAGpC,MAAMC,MAAAA,CAAOC,EAAE,CAACC,WAAW,CAAC,OAAO,EAAEC,GAAG,EAAE,GAAA;AACxC,QAAA,MAAMC,YAAAA,GAAeC,MAAAA,CAAOC,MAAM,CAACN,OAAOI,YAAY,CAAA;AACtD,QAAA,MAAMG,UAAAA,GAAaF,MAAAA,CAAOC,MAAM,CAACN,OAAOO,UAAU,CAAA;AAElD,QAAA,KAAK,MAAMC,KAAAA,IAAS;AAAIJ,YAAAA,GAAAA,YAAAA;AAAiBG,YAAAA,GAAAA;SAAW,CAAE;YACpD,MAAME,OAAAA,GAAUT,OAAOC,EAAE,CAACS,QAAQ,CAACC,GAAG,CAACH,KAAAA,CAAMb,G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ASE;AAAM,iBAAA;AACxC,YAAA,CAAA,CAAA;AAEA,YAAA,MAAMC,YAAYlE,MAAAA,CAAOC,EAAE,CAACkE,OAAO,CAACC,kBAAkB,EAAA;AACtD,YAAA,MAAMjE,IAAIkE,WAAW,CAACnD,SAAAA,CAAUC,IAAI,EAAE6C,YAAAA,EAAcE,SAAAA,CAAAA;AACtD,QAAA;AACF,IAAA,CAAA,CAAA;AACF;;;;;"}
|
|
1
|
+
{"version":3,"file":"unidirectional-relations.js","sources":["../../../../src/services/document-service/utils/unidirectional-relations.ts"],"sourcesContent":["/* eslint-disable no-continue */\nimport { keyBy, omit } from 'lodash/fp';\n\nimport type { Data, UID, Schema } from '@strapi/types';\n\nimport type { JoinTable } from '@strapi/database';\n\ninterface LoadContext {\n oldVersions: { id: Data.ID; locale: string }[];\n newVersions: { id: Data.ID; locale: string }[];\n}\n\ninterface RelationUpdate {\n joinTable: JoinTable;\n relations: Record<string, any>[];\n}\n\ninterface RelationFilterOptions {\n /**\n * Function to determine if a relation should be propagated to new document versions\n * This replaces the hardcoded component-specific logic\n */\n shouldPropagateRelation?: (\n relation: Record<string, any>,\n model: Schema.Component | Schema.ContentType,\n trx: any\n ) => Promise<boolean>;\n}\n\n/**\n * Loads lingering relations that need to be updated when overriding a published or draft entry.\n * This is necessary because the relations are uni-directional and the target entry is not aware of the source entry.\n * This is not the case for bi-directional relations, where the target entry is also linked to the source entry.\n */\nconst load = async (\n uid: UID.ContentType,\n { oldVersions, newVersions }: LoadContext,\n options: RelationFilterOptions = {}\n): Promise<RelationUpdate[]> => {\n const updates: RelationUpdate[] = [];\n\n // Iterate all components and content types to find relations that need to be updated\n await strapi.db.transaction(async ({ trx }) => {\n const contentTypes = Object.values(strapi.contentTypes) as Schema.ContentType[];\n const components = Object.values(strapi.components) as Schema.Component[];\n\n for (const model of [...contentTypes, ...components]) {\n const dbModel = strapi.db.metadata.get(model.uid);\n\n for (const attribute of Object.values(dbModel.attributes) as any) {\n /**\n * Only consider unidirectional relations.\n * Bidirectional relations (inversedBy/mappedBy) are handled by bidirectionalRelations.\n * Self-referential relations (model.uid === uid) are included here, but rows where\n * the source entry is also being republished in this same operation are excluded —\n * those are handled by selfReferentialRelations, which remaps both sides simultaneously.\n * Without this guard, we would insert rows pointing to a source entry that is about\n * to be deleted, creating stale foreign-key values.\n */\n if (\n attribute.type !== 'relation' ||\n attribute.target !== uid ||\n attribute.inversedBy ||\n attribute.mappedBy\n ) {\n continue;\n }\n\n // TODO: joinColumn relations\n const joinTable = attribute.joinTable;\n if (!joinTable) {\n continue;\n }\n\n const { name: sourceColumnName } = joinTable.joinColumn;\n const { name: targetColumnName } = joinTable.inverseJoinColumn;\n\n /**\n * Load all relations that need to be updated\n */\n // NOTE: when the model has draft and publish, we can assume relation are only draft to draft & published to published\n const ids = oldVersions.map((entry) => entry.id);\n\n let oldVersionsQuery = strapi.db\n .getConnection()\n .select('*')\n .from(joinTable.name)\n .whereIn(targetColumnName, ids);\n\n /**\n * For self-referential relations, exclude join rows where the source entry is also\n * being republished. When both sides are in the same publish batch, selfReferentialRelations\n * already handles remapping them. Including them here too would insert a row whose\n * source FK points at an entry that is about to be deleted.\n */\n if (model.uid === uid && ids.length > 0) {\n oldVersionsQuery = oldVersionsQuery.whereNotIn(sourceColumnName, ids);\n }\n\n const oldVersionsRelations = await oldVersionsQuery.transacting(trx);\n\n if (oldVersionsRelations.length > 0) {\n updates.push({ joinTable, relations: oldVersionsRelations });\n }\n\n /**\n * if publishing\n * if published version exists\n * updated published versions links\n * else\n * create link to newly published version\n *\n * if discarding\n * if published version link exists & not draft version link\n * create link to new draft version\n */\n if (!model.options?.draftAndPublish) {\n const ids = newVersions.map((entry) => entry.id);\n\n // This is the step were we query the join table based on the id of the document\n const newVersionsRelations = await strapi.db\n .getConnection()\n .select('*')\n .from(joinTable.name)\n .whereIn(targetColumnName, ids)\n .transacting(trx);\n\n let versionRelations = newVersionsRelations;\n if (options.shouldPropagateRelation) {\n const relationsToPropagate = [];\n for (const relation of newVersionsRelations) {\n if (await options.shouldPropagateRelation(relation, model, trx)) {\n relationsToPropagate.push(relation);\n }\n }\n versionRelations = relationsToPropagate;\n }\n\n if (versionRelations.length > 0) {\n // when publishing a draft that doesn't have a published version yet,\n // copy the links to the draft over to the published version\n // when discarding a published version, if no drafts exists\n const discardToAdd = versionRelations\n .filter((relation) => {\n const matchingOldVersion = oldVersionsRelations.find((oldRelation) => {\n return oldRelation[sourceColumnName] === relation[sourceColumnName];\n });\n\n return !matchingOldVersion;\n })\n .map(omit(strapi.db.metadata.identifiers.ID_COLUMN));\n\n updates.push({ joinTable, relations: discardToAdd });\n }\n }\n }\n }\n });\n\n return updates;\n};\n\n/**\n * Updates uni directional relations to target the right entries when overriding published or draft entries.\n *\n * This function:\n * 1. Creates new relations pointing to the new entry versions\n * 2. Precisely deletes only the old relations being replaced to prevent orphaned links\n *\n * @param oldEntries The old entries that are being overridden\n * @param newEntries The new entries that are overriding the old ones\n * @param oldRelations The relations that were previously loaded with `load` @see load\n */\nconst sync = async (\n oldEntries: { id: Data.ID; locale: string }[],\n newEntries: { id: Data.ID; locale: string }[],\n oldRelations: { joinTable: any; relations: any[] }[]\n) => {\n /**\n * Create a map of old entry ids to new entry ids\n *\n * Will be used to update the relation target ids\n */\n const newEntryByLocale = keyBy('locale', newEntries);\n const oldEntriesMap = oldEntries.reduce(\n (acc, entry) => {\n const newEntry = newEntryByLocale[entry.locale];\n if (!newEntry) return acc;\n acc[String(entry.id)] = newEntry.id;\n return acc;\n },\n {} as Record<string, Data.ID>\n );\n\n await strapi.db.transaction(async ({ trx }) => {\n // Iterate old relations that are deleted and insert the new ones\n for (const { joinTable, relations } of oldRelations) {\n // Update old ids with the new ones\n const column = joinTable.inverseJoinColumn.name;\n\n const newRelations = relations.map((relation) => {\n const newId = oldEntriesMap[relation[column]];\n return { ...relation, [column]: newId };\n });\n\n const batchSize = strapi.db.dialect.getBatchInsertSize();\n await trx.batchInsert(joinTable.name, newRelations, batchSize);\n }\n });\n};\n\nexport { load, sync };\nexport type { RelationFilterOptions };\n"],"names":["load","uid","oldVersions","newVersions","options","updates","strapi","db","transaction","trx","contentTypes","Object","values","components","model","dbModel","metadata","get","attribute","attributes","type","target","inversedBy","mappedBy","joinTable","name","sourceColumnName","joinColumn","targetColumnName","inverseJoinColumn","ids","map","entry","id","oldVersionsQuery","getConnection","select","from","whereIn","length","whereNotIn","oldVersionsRelations","transacting","push","relations","draftAndPublish","newVersionsRelations","versionRelations","shouldPropagateRelation","relationsToPropagate","relation","discardToAdd","filter","matchingOldVersion","find","oldRelation","omit","identifiers","ID_COLUMN","sync","oldEntries","newEntries","oldRelations","newEntryByLocale","keyBy","oldEntriesMap","reduce","acc","newEntry","locale","String","column","newRelations","newId","batchSize","dialect","getBatchInsertSize","batchInsert"],"mappings":";;;;AA6BA;;;;AAIC,IACD,MAAMA,IAAAA,GAAO,OACXC,GAAAA,EACA,EAAEC,WAAW,EAAEC,WAAW,EAAe,EACzCC,OAAAA,GAAiC,EAAE,GAAA;AAEnC,IAAA,MAAMC,UAA4B,EAAE;;IAGpC,MAAMC,MAAAA,CAAOC,EAAE,CAACC,WAAW,CAAC,OAAO,EAAEC,GAAG,EAAE,GAAA;AACxC,QAAA,MAAMC,YAAAA,GAAeC,MAAAA,CAAOC,MAAM,CAACN,OAAOI,YAAY,CAAA;AACtD,QAAA,MAAMG,UAAAA,GAAaF,MAAAA,CAAOC,MAAM,CAACN,OAAOO,UAAU,CAAA;AAElD,QAAA,KAAK,MAAMC,KAAAA,IAAS;AAAIJ,YAAAA,GAAAA,YAAAA;AAAiBG,YAAAA,GAAAA;SAAW,CAAE;YACpD,MAAME,OAAAA,GAAUT,OAAOC,EAAE,CAACS,QAAQ,CAACC,GAAG,CAACH,KAAAA,CAAMb,GAAG,CAAA;AAEhD,YAAA,KAAK,MAAMiB,SAAAA,IAAaP,MAAAA,CAAOC,MAAM,CAACG,OAAAA,CAAQI,UAAU,CAAA,CAAU;AAChE;;;;;;;;AAQC,YACD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;AAAE,oBAAA,GAAGrB,QAAQ;AAAE,oBAAA,CAACqB,SAASE;AAAM,iBAAA;AACxC,YAAA,CAAA,CAAA;AAEA,YAAA,MAAMC,YAAYpE,MAAAA,CAAOC,EAAE,CAACoE,OAAO,CAACC,kBAAkB,EAAA;AACtD,YAAA,MAAMnE,IAAIoE,WAAW,CAACrD,SAAAA,CAAUC,IAAI,EAAE+C,YAAAA,EAAcE,SAAAA,CAAAA;AACtD,QAAA;AACF,IAAA,CAAA,CAAA;AACF;;;;;"}
|
|
@@ -18,9 +18,13 @@ import { omit, keyBy } from 'lodash/fp';
|
|
|
18
18
|
for (const attribute of Object.values(dbModel.attributes)){
|
|
19
19
|
/**
|
|
20
20
|
* Only consider unidirectional relations.
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
|
|
21
|
+
* Bidirectional relations (inversedBy/mappedBy) are handled by bidirectionalRelations.
|
|
22
|
+
* Self-referential relations (model.uid === uid) are included here, but rows where
|
|
23
|
+
* the source entry is also being republished in this same operation are excluded —
|
|
24
|
+
* those are handled by selfReferentialRelations, which remaps both sides simultaneously.
|
|
25
|
+
* Without this guard, we would insert rows pointing to a source entry that is about
|
|
26
|
+
* to be deleted, creating stale foreign-key values.
|
|
27
|
+
*/ if (attribute.type !== 'relation' || attribute.target !== uid || attribute.inversedBy || attribute.mappedBy) {
|
|
24
28
|
continue;
|
|
25
29
|
}
|
|
26
30
|
// TODO: joinColumn relations
|
|
@@ -34,7 +38,16 @@ import { omit, keyBy } from 'lodash/fp';
|
|
|
34
38
|
* Load all relations that need to be updated
|
|
35
39
|
*/ // NOTE: when the model has draft and publish, we can assume relation are only draft to draft & published to published
|
|
36
40
|
const ids = oldVersions.map((entry)=>entry.id);
|
|
37
|
-
|
|
41
|
+
let oldVersionsQuery = strapi.db.getConnection().select('*').from(joinTable.name).whereIn(targetColumnName, ids);
|
|
42
|
+
/**
|
|
43
|
+
* For self-referential relations, exclude join rows where the source entry is also
|
|
44
|
+
* being republished. When both sides are in the same publish batch, selfReferentialRelations
|
|
45
|
+
* already handles remapping them. Including them here too would insert a row whose
|
|
46
|
+
* source FK points at an entry that is about to be deleted.
|
|
47
|
+
*/ if (model.uid === uid && ids.length > 0) {
|
|
48
|
+
oldVersionsQuery = oldVersionsQuery.whereNotIn(sourceColumnName, ids);
|
|
49
|
+
}
|
|
50
|
+
const oldVersionsRelations = await oldVersionsQuery.transacting(trx);
|
|
38
51
|
if (oldVersionsRelations.length > 0) {
|
|
39
52
|
updates.push({
|
|
40
53
|
joinTable,
|