@strapi/core 5.57.0 → 5.58.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/Strapi.d.ts +28 -0
- package/dist/Strapi.d.ts.map +1 -1
- package/dist/Strapi.js +4 -0
- package/dist/Strapi.js.map +1 -1
- package/dist/Strapi.mjs +4 -0
- package/dist/Strapi.mjs.map +1 -1
- package/dist/ee/entitlements.d.ts +44 -0
- package/dist/ee/entitlements.d.ts.map +1 -0
- package/dist/ee/entitlements.js +54 -0
- package/dist/ee/entitlements.js.map +1 -0
- package/dist/ee/entitlements.mjs +51 -0
- package/dist/ee/entitlements.mjs.map +1 -0
- package/dist/ee/index.d.ts +33 -0
- package/dist/ee/index.d.ts.map +1 -1
- package/dist/ee/index.js +70 -3
- package/dist/ee/index.js.map +1 -1
- package/dist/ee/index.mjs +71 -4
- package/dist/ee/index.mjs.map +1 -1
- package/dist/ee/license.d.ts +10 -0
- package/dist/ee/license.d.ts.map +1 -1
- package/dist/ee/license.js +25 -1
- package/dist/ee/license.js.map +1 -1
- package/dist/ee/license.mjs +25 -2
- package/dist/ee/license.mjs.map +1 -1
- package/dist/package.json.js +16 -16
- package/dist/package.json.mjs +16 -16
- package/dist/services/document-service/transform/fields.d.ts.map +1 -1
- package/dist/services/document-service/transform/fields.js +7 -1
- package/dist/services/document-service/transform/fields.js.map +1 -1
- package/dist/services/document-service/transform/fields.mjs +7 -1
- package/dist/services/document-service/transform/fields.mjs.map +1 -1
- package/dist/services/document-service/transform/populate.d.ts.map +1 -1
- package/dist/services/document-service/transform/populate.js +8 -1
- package/dist/services/document-service/transform/populate.js.map +1 -1
- package/dist/services/document-service/transform/populate.mjs +8 -1
- package/dist/services/document-service/transform/populate.mjs.map +1 -1
- package/dist/services/document-service/transform/relations/utils/map-relation.d.ts.map +1 -1
- package/dist/services/document-service/transform/relations/utils/map-relation.js +10 -4
- package/dist/services/document-service/transform/relations/utils/map-relation.js.map +1 -1
- package/dist/services/document-service/transform/relations/utils/map-relation.mjs +10 -4
- package/dist/services/document-service/transform/relations/utils/map-relation.mjs.map +1 -1
- package/dist/utils/detect-customizations.d.ts +31 -0
- package/dist/utils/detect-customizations.d.ts.map +1 -0
- package/dist/utils/detect-customizations.js +173 -0
- package/dist/utils/detect-customizations.js.map +1 -0
- package/dist/utils/detect-customizations.mjs +165 -0
- package/dist/utils/detect-customizations.mjs.map +1 -0
- package/package.json +16 -16
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map-relation.mjs","sources":["../../../../../../src/services/document-service/transform/relations/utils/map-relation.ts"],"sourcesContent":["/* eslint-disable node/no-callback-literal */\nimport { curry, isObject } from 'lodash';\n\nimport { traverseEntity, async } from '@strapi/utils';\n\nimport { Relation } from './types';\n\nconst isNumeric = (value: any): value is number => {\n if (
|
|
1
|
+
{"version":3,"file":"map-relation.mjs","sources":["../../../../../../src/services/document-service/transform/relations/utils/map-relation.ts"],"sourcesContent":["/* eslint-disable node/no-callback-literal */\nimport { curry, isObject } from 'lodash';\n\nimport { traverseEntity, async } from '@strapi/utils';\n\nimport { Relation } from './types';\n\n/**\n * Whether a shorthand relation value is a numeric entry id (as opposed to a documentId).\n *\n * A string only counts as numeric when it is made of digits *entirely*. `parseInt` must not be\n * used here: it stops at the first non-digit character, so a documentId that happens to start\n * with a digit (e.g. `'3d52c864df72fcc68ab62ebe'` -> `3`) would be misclassified as an id.\n */\nconst isNumeric = (value: any): value is number => {\n if (typeof value === 'number') return Number.isFinite(value);\n if (typeof value === 'string') return /^\\d+$/.test(value);\n return false; // Arrays (e.g. [1, 'docId']), objects, etc.\n};\n\nconst toArray = (value: any) => {\n // Keep value as it is if it's a nullish value\n if (value == null) return value;\n if (Array.isArray(value)) return value;\n\n return [value];\n};\n\n/**\n * There are multiple ways to create Strapi relations.\n * This is a utility to traverse and transform relation data\n *\n *\n * For consistency and ease of use, the response will always be an object with the following shape:\n * { set: [{...}], connect: [{...}], disconnect: [{...}] }\n *\n * @example\n * transformRelationData({\n * onLongHand: (relation) => {\n * // Change the id of the relation\n * return { id: 'other' };\n * },\n * }, relation)\n */\nconst mapRelation = async (\n callback: (relation: any) => any,\n rel: Relation,\n isRecursive = false\n): Promise<Relation> => {\n let relation: Relation = rel;\n\n const wrapInSet = (value: any) => {\n // Ignore wrapping if it's a recursive call\n if (isRecursive) {\n return value;\n }\n return { set: toArray(value) };\n };\n\n // undefined | null\n if (relation == null) {\n return callback(relation);\n }\n\n // LongHand[] | ShortHand[]\n if (Array.isArray(relation)) {\n return async\n .map(relation, (r: Relation) => mapRelation(callback, r, true))\n .then((result: any) => result.flat().filter(Boolean))\n .then(wrapInSet);\n }\n\n // LongHand\n if (isObject(relation)) {\n // { id: 1 } || { documentId: 1 }\n if ('id' in relation || 'documentId' in relation) {\n const result = await callback(relation);\n return wrapInSet(result);\n }\n\n // If not connecting anything, return default visitor\n if (!relation.set && !relation.disconnect && !relation.connect) {\n return callback(relation);\n }\n\n // { set }\n if (relation.set) {\n const set: any = await mapRelation(callback, relation.set, true);\n relation = { ...relation, set: toArray(set) };\n }\n\n // { disconnect}\n if (relation.disconnect) {\n const disconnect: any = await mapRelation(callback, relation.disconnect, true);\n relation = { ...relation, disconnect: toArray(disconnect) };\n }\n\n // { connect }\n if (relation.connect) {\n // Transform the relation to connect\n const connect: any = await mapRelation(callback, relation.connect, true);\n relation = { ...relation, connect: toArray(connect) };\n }\n\n return relation;\n }\n\n // ShortHand\n if (isNumeric(relation)) {\n const result = await callback({ id: relation });\n return wrapInSet(result);\n }\n\n if (typeof relation === 'string') {\n const result = await callback({ documentId: relation });\n return wrapInSet(result);\n }\n\n // Anything else\n return callback(relation);\n};\n\ntype TraverseEntity = Parameters<typeof traverseEntity>;\ntype TraverseEntityRelationsOptions = TraverseEntity[1] & { includeMedia?: boolean };\n\n/**\n * Utility function, same as `traverseEntity` but only for relations and, when requested, media.\n */\nconst traverseEntityRelations = async (\n visitor: TraverseEntity[0],\n options: TraverseEntityRelationsOptions,\n data: TraverseEntity[2]\n) => {\n const { includeMedia = false, ...traverseOptions } = options;\n\n return traverseEntity(\n async (options, utils) => {\n const { attribute } = options;\n\n if (!attribute) {\n return;\n }\n\n if (attribute.type !== 'relation' && !(includeMedia && attribute.type === 'media')) {\n return;\n }\n\n if (attribute.type === 'relation') {\n // TODO: Handle join columns\n if (attribute.useJoinTable === false) {\n return;\n }\n\n // morphToOne uses morphColumn (inline columns on the entity), handled directly in processData\n if (attribute.relation === 'morphToOne') {\n return;\n }\n }\n\n return visitor(options, utils);\n },\n traverseOptions,\n data\n );\n};\n\nconst mapRelationCurried = curry(mapRelation);\nconst traverseEntityRelationsCurried = curry(traverseEntityRelations);\n\nexport {\n mapRelationCurried as mapRelation,\n traverseEntityRelationsCurried as traverseEntityRelations,\n};\n"],"names":["isNumeric","value","Number","isFinite","test","toArray","Array","isArray","mapRelation","callback","rel","isRecursive","relation","wrapInSet","set","async","map","r","then","result","flat","filter","Boolean","isObject","disconnect","connect","id","documentId","traverseEntityRelations","visitor","options","data","includeMedia","traverseOptions","traverseEntity","utils","attribute","type","useJoinTable","mapRelationCurried","curry","traverseEntityRelationsCurried"],"mappings":";;;AAOA;;;;;;IAOA,MAAMA,YAAY,CAACC,KAAAA,GAAAA;AACjB,IAAA,IAAI,OAAOA,KAAAA,KAAU,QAAA,EAAU,OAAOC,MAAAA,CAAOC,QAAQ,CAACF,KAAAA,CAAAA;AACtD,IAAA,IAAI,OAAOA,KAAAA,KAAU,QAAA,EAAU,OAAO,OAAA,CAAQG,IAAI,CAACH,KAAAA,CAAAA;AACnD,IAAA,OAAO;AACT,CAAA;AAEA,MAAMI,UAAU,CAACJ,KAAAA,GAAAA;;IAEf,IAAIA,KAAAA,IAAS,MAAM,OAAOA,KAAAA;AAC1B,IAAA,IAAIK,KAAAA,CAAMC,OAAO,CAACN,KAAAA,CAAAA,EAAQ,OAAOA,KAAAA;IAEjC,OAAO;AAACA,QAAAA;AAAM,KAAA;AAChB,CAAA;AAEA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A;AAKA;;AAEC,IACD,MAAMgB,uBAAAA,GAA0B,OAC9BC,OAAAA,EACAC,OAAAA,EACAC,IAAAA,GAAAA;AAEA,IAAA,MAAM,EAAEC,YAAAA,GAAe,KAAK,EAAE,GAAGC,iBAAiB,GAAGH,OAAAA;IAErD,OAAOI,cAAAA,CACL,OAAOJ,OAAAA,EAASK,KAAAA,GAAAA;QACd,MAAM,EAAEC,SAAS,EAAE,GAAGN,OAAAA;AAEtB,QAAA,IAAI,CAACM,SAAAA,EAAW;AACd,YAAA;AACF,QAAA;QAEA,IAAIA,SAAAA,CAAUC,IAAI,KAAK,UAAA,IAAc,EAAEL,YAAAA,IAAgBI,SAAAA,CAAUC,IAAI,KAAK,OAAM,CAAA,EAAI;AAClF,YAAA;AACF,QAAA;QAEA,IAAID,SAAAA,CAAUC,IAAI,KAAK,UAAA,EAAY;;YAEjC,IAAID,SAAAA,CAAUE,YAAY,KAAK,KAAA,EAAO;AACpC,gBAAA;AACF,YAAA;;YAGA,IAAIF,SAAAA,CAAUxB,QAAQ,KAAK,YAAA,EAAc;AACvC,gBAAA;AACF,YAAA;AACF,QAAA;AAEA,QAAA,OAAOiB,QAAQC,OAAAA,EAASK,KAAAA,CAAAA;AAC1B,IAAA,CAAA,EACAF,eAAAA,EACAF,IAAAA,CAAAA;AAEJ,CAAA;AAEA,MAAMQ,qBAAqBC,KAAAA,CAAMhC,WAAAA;AACjC,MAAMiC,iCAAiCD,KAAAA,CAAMZ,uBAAAA;;;;"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Core } from '@strapi/types';
|
|
2
|
+
export declare const isLifecycleNonEmpty: (fn: unknown) => boolean;
|
|
3
|
+
export declare const detectCustomizations: (strapi: Core.Strapi) => {
|
|
4
|
+
apis: {
|
|
5
|
+
uid: string;
|
|
6
|
+
customController: boolean;
|
|
7
|
+
customService: boolean;
|
|
8
|
+
customRoutes: boolean;
|
|
9
|
+
}[];
|
|
10
|
+
controllers: {
|
|
11
|
+
uid: string;
|
|
12
|
+
custom: boolean;
|
|
13
|
+
}[];
|
|
14
|
+
extendedPlugins: string[];
|
|
15
|
+
counts: {
|
|
16
|
+
customControllers: number;
|
|
17
|
+
customServices: number;
|
|
18
|
+
customRoutes: number;
|
|
19
|
+
};
|
|
20
|
+
srcIndex: {
|
|
21
|
+
present: boolean;
|
|
22
|
+
registerDefined: boolean;
|
|
23
|
+
registerNonEmpty: boolean;
|
|
24
|
+
bootstrapDefined: boolean;
|
|
25
|
+
bootstrapNonEmpty: boolean;
|
|
26
|
+
destroyDefined: boolean;
|
|
27
|
+
destroyNonEmpty: boolean;
|
|
28
|
+
beyondTemplate: boolean;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=detect-customizations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect-customizations.d.ts","sourceRoot":"","sources":["../../src/utils/detect-customizations.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAgB1C,eAAO,MAAM,mBAAmB,GAAI,IAAI,OAAO,KAAG,OAsBjD,CAAC;AAgHF,eAAO,MAAM,oBAAoB,GAAI,QAAQ,IAAI,CAAC,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2DvD,CAAC"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var fs = require('fs');
|
|
4
|
+
var path = require('path');
|
|
5
|
+
var factories = require('../factories.js');
|
|
6
|
+
|
|
7
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
|
+
|
|
9
|
+
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
10
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
11
|
+
|
|
12
|
+
const APP_UID_PREFIX = 'api::';
|
|
13
|
+
/**
|
|
14
|
+
* True when a lifecycle function has a non-empty body. The compiled function
|
|
15
|
+
* source is inspected here only to derive a boolean; it is never returned.
|
|
16
|
+
*/ const stripComments = (body)=>body.replace(/\/\*[\s\S]*?\*\//g, '').replace(/\/\/[^\n]*/g, '').trim();
|
|
17
|
+
const isLifecycleNonEmpty = (fn)=>{
|
|
18
|
+
if (typeof fn !== 'function') {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
const source = Function.prototype.toString.call(fn);
|
|
22
|
+
// The body starts at the first `{` AFTER the parameter list closes, not the
|
|
23
|
+
// first `{` overall: a real lifecycle signature like `register({ strapi })`
|
|
24
|
+
// or the template's `register(/*{ strapi }*/)` puts a `{` in the params/comment.
|
|
25
|
+
const parenEnd = source.indexOf(')');
|
|
26
|
+
const bodyStart = source.indexOf('{', parenEnd === -1 ? 0 : parenEnd);
|
|
27
|
+
// No brace anywhere after the parameters means a concise arrow body
|
|
28
|
+
// (`register: ({ strapi }) => strapi.log.info('x')`), where everything after the
|
|
29
|
+
// arrow IS the body. Treating that as empty under-reported a real customization,
|
|
30
|
+
// telling Support an app was stock when it was not. The template only ever ships
|
|
31
|
+
// braced method shorthand, so this branch cannot misread a fresh app.
|
|
32
|
+
if (bodyStart === -1) {
|
|
33
|
+
const arrow = source.indexOf('=>');
|
|
34
|
+
return arrow === -1 ? false : stripComments(source.slice(arrow + 2)).length > 0;
|
|
35
|
+
}
|
|
36
|
+
return stripComments(source.slice(bodyStart + 1, source.lastIndexOf('}'))).length > 0;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* A default `createCoreService` result has its CRUD methods on its class
|
|
40
|
+
* prototype and only `contentType` as an own key; that own key is copied onto
|
|
41
|
+
* the direct prototype (the base service instance) too, so a default service
|
|
42
|
+
* never has an own key that its direct prototype doesn't also have. A custom
|
|
43
|
+
* service (built via a `cfg` object/callback) has extra own method keys that
|
|
44
|
+
* are absent from the prototype it was assigned. Comparing own keys against
|
|
45
|
+
* the DIRECT prototype's own keys (rather than guessing base method names)
|
|
46
|
+
* avoids flagging every real service as custom.
|
|
47
|
+
*/ const isCustomService = (service)=>{
|
|
48
|
+
if (service === null || typeof service !== 'object') {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
const proto = Object.getPrototypeOf(service);
|
|
52
|
+
const protoOwnKeys = proto ? Object.keys(proto) : [];
|
|
53
|
+
return Object.keys(service).some((key)=>!protoOwnKeys.includes(key));
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Custom routes in Strapi are added as separate files in an api's `routes/`
|
|
57
|
+
* directory (each exporting a plain `{ routes: [...] }` object), never by
|
|
58
|
+
* editing the factory-generated route file, because Koa needs explicit route
|
|
59
|
+
* ordering. The factory router exposes `routes` as a getter, so any route
|
|
60
|
+
* file exposing `routes` as a plain data property is a hand-written custom
|
|
61
|
+
* route file.
|
|
62
|
+
*/ const hasCustomRoutes = (strapi, apiName)=>{
|
|
63
|
+
const api = strapi.api(apiName);
|
|
64
|
+
const routeFiles = api?.routes ?? {};
|
|
65
|
+
return Object.values(routeFiles).some((router)=>{
|
|
66
|
+
if (router === null || typeof router !== 'object') {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
const descriptor = Object.getOwnPropertyDescriptor(router, 'routes');
|
|
70
|
+
// A factory router exposes `routes` as an accessor (getter); a hand-written
|
|
71
|
+
// custom routes file exports it as a plain data property.
|
|
72
|
+
return descriptor ? typeof descriptor.get !== 'function' : false;
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* `createCoreController` sets the controller's prototype to the factory's base controller, and
|
|
77
|
+
* marks it when the app passed its own config. Anything else was not minted by the factory: a
|
|
78
|
+
* plain action map (`module.exports = { async find() {} }`) is entirely hand-written, and a
|
|
79
|
+
* factory that returned a non-object is not stock either. Neither may throw out of the dump.
|
|
80
|
+
*/ const isCustomApiController = (controller)=>{
|
|
81
|
+
if (controller === null || typeof controller !== 'object') {
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
const prototype = Object.getPrototypeOf(controller);
|
|
85
|
+
if (prototype === Object.prototype || prototype === null) {
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
return factories.isCustomController(controller);
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Plugin and admin controllers are plain objects even when stock, so only the factory's
|
|
92
|
+
* custom-config mark can single one out here (the same test startup telemetry uses).
|
|
93
|
+
*/ const isCustomFactoryController = (controller)=>controller !== null && typeof controller === 'object' && factories.isCustomController(controller);
|
|
94
|
+
/**
|
|
95
|
+
* Plugins the app overrides through `src/extensions/<plugin>/`: a `strapi-server.js`, which can
|
|
96
|
+
* replace any controller, service or route, or content-type schema overrides. A plugin
|
|
97
|
+
* controller looks the same stock or overridden, so this folder is what tells Support a
|
|
98
|
+
* plugin was changed.
|
|
99
|
+
*/ // The loader applies content-type overrides from `content-types/<name>/schema.json` only
|
|
100
|
+
const hasSchemaOverride = (pluginDir)=>{
|
|
101
|
+
const contentTypesDir = path__default.default.join(pluginDir, 'content-types');
|
|
102
|
+
if (!fs__default.default.existsSync(contentTypesDir)) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
return fs__default.default.readdirSync(contentTypesDir, {
|
|
106
|
+
withFileTypes: true
|
|
107
|
+
}).some((entry)=>entry.isDirectory() && fs__default.default.existsSync(path__default.default.join(contentTypesDir, entry.name, 'schema.json')));
|
|
108
|
+
};
|
|
109
|
+
const listExtendedPlugins = (strapi)=>{
|
|
110
|
+
const extensionsDir = strapi.dirs?.dist?.extensions;
|
|
111
|
+
if (!extensionsDir || !fs__default.default.existsSync(extensionsDir)) {
|
|
112
|
+
return [];
|
|
113
|
+
}
|
|
114
|
+
return fs__default.default.readdirSync(extensionsDir, {
|
|
115
|
+
withFileTypes: true
|
|
116
|
+
}).filter((entry)=>entry.isDirectory()).map((entry)=>entry.name).filter((name)=>fs__default.default.existsSync(path__default.default.join(extensionsDir, name, 'strapi-server.js')) || hasSchemaOverride(path__default.default.join(extensionsDir, name))).sort();
|
|
117
|
+
};
|
|
118
|
+
// Return shape is mirrored in @strapi/types Core.Strapi['getCustomizations'];
|
|
119
|
+
// keep the two in sync.
|
|
120
|
+
const detectCustomizations = (strapi)=>{
|
|
121
|
+
const controllers = strapi.controllers ?? {};
|
|
122
|
+
const services = strapi.services ?? {};
|
|
123
|
+
const appControllerUids = Object.keys(controllers).filter((uid)=>uid.startsWith(APP_UID_PREFIX));
|
|
124
|
+
const apis = appControllerUids.map((uid)=>{
|
|
125
|
+
const controller = controllers[uid];
|
|
126
|
+
const service = services[uid];
|
|
127
|
+
// uid is `api::<name>.<name>`; map to the bare api name for route lookup.
|
|
128
|
+
const apiName = uid.slice(APP_UID_PREFIX.length).split('.')[0];
|
|
129
|
+
return {
|
|
130
|
+
uid,
|
|
131
|
+
customController: isCustomApiController(controller),
|
|
132
|
+
customService: isCustomService(service),
|
|
133
|
+
customRoutes: hasCustomRoutes(strapi, apiName)
|
|
134
|
+
};
|
|
135
|
+
});
|
|
136
|
+
// Every controller, not only the app's own: the dump is used to rebuild an app for debugging.
|
|
137
|
+
const allControllers = Object.keys(controllers).map((uid)=>({
|
|
138
|
+
uid,
|
|
139
|
+
custom: uid.startsWith(APP_UID_PREFIX) ? isCustomApiController(controllers[uid]) : isCustomFactoryController(controllers[uid])
|
|
140
|
+
}));
|
|
141
|
+
const app = strapi.app;
|
|
142
|
+
const registerDefined = typeof app?.register === 'function';
|
|
143
|
+
const bootstrapDefined = typeof app?.bootstrap === 'function';
|
|
144
|
+
const destroyDefined = typeof app?.destroy === 'function';
|
|
145
|
+
const registerNonEmpty = isLifecycleNonEmpty(app?.register);
|
|
146
|
+
const bootstrapNonEmpty = isLifecycleNonEmpty(app?.bootstrap);
|
|
147
|
+
const destroyNonEmpty = isLifecycleNonEmpty(app?.destroy);
|
|
148
|
+
return {
|
|
149
|
+
apis,
|
|
150
|
+
controllers: allControllers,
|
|
151
|
+
extendedPlugins: listExtendedPlugins(strapi),
|
|
152
|
+
counts: {
|
|
153
|
+
customControllers: allControllers.filter((c)=>c.custom).length,
|
|
154
|
+
customServices: apis.filter((a)=>a.customService).length,
|
|
155
|
+
customRoutes: apis.filter((a)=>a.customRoutes).length
|
|
156
|
+
},
|
|
157
|
+
srcIndex: {
|
|
158
|
+
present: app != null,
|
|
159
|
+
registerDefined,
|
|
160
|
+
registerNonEmpty,
|
|
161
|
+
bootstrapDefined,
|
|
162
|
+
bootstrapNonEmpty,
|
|
163
|
+
destroyDefined,
|
|
164
|
+
destroyNonEmpty,
|
|
165
|
+
// Template ships only empty register + bootstrap and no destroy.
|
|
166
|
+
beyondTemplate: destroyDefined || registerNonEmpty || bootstrapNonEmpty
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
exports.detectCustomizations = detectCustomizations;
|
|
172
|
+
exports.isLifecycleNonEmpty = isLifecycleNonEmpty;
|
|
173
|
+
//# sourceMappingURL=detect-customizations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect-customizations.js","sources":["../../src/utils/detect-customizations.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\nimport type { Core } from '@strapi/types';\n\nimport * as factories from '../factories';\n\nconst APP_UID_PREFIX = 'api::';\n\n/**\n * True when a lifecycle function has a non-empty body. The compiled function\n * source is inspected here only to derive a boolean; it is never returned.\n */\nconst stripComments = (body: string): string =>\n body\n .replace(/\\/\\*[\\s\\S]*?\\*\\//g, '')\n .replace(/\\/\\/[^\\n]*/g, '')\n .trim();\n\nexport const isLifecycleNonEmpty = (fn: unknown): boolean => {\n if (typeof fn !== 'function') {\n return false;\n }\n const source = Function.prototype.toString.call(fn);\n // The body starts at the first `{` AFTER the parameter list closes, not the\n // first `{` overall: a real lifecycle signature like `register({ strapi })`\n // or the template's `register(/*{ strapi }*/)` puts a `{` in the params/comment.\n const parenEnd = source.indexOf(')');\n const bodyStart = source.indexOf('{', parenEnd === -1 ? 0 : parenEnd);\n\n // No brace anywhere after the parameters means a concise arrow body\n // (`register: ({ strapi }) => strapi.log.info('x')`), where everything after the\n // arrow IS the body. Treating that as empty under-reported a real customization,\n // telling Support an app was stock when it was not. The template only ever ships\n // braced method shorthand, so this branch cannot misread a fresh app.\n if (bodyStart === -1) {\n const arrow = source.indexOf('=>');\n return arrow === -1 ? false : stripComments(source.slice(arrow + 2)).length > 0;\n }\n\n return stripComments(source.slice(bodyStart + 1, source.lastIndexOf('}'))).length > 0;\n};\n\n/**\n * A default `createCoreService` result has its CRUD methods on its class\n * prototype and only `contentType` as an own key; that own key is copied onto\n * the direct prototype (the base service instance) too, so a default service\n * never has an own key that its direct prototype doesn't also have. A custom\n * service (built via a `cfg` object/callback) has extra own method keys that\n * are absent from the prototype it was assigned. Comparing own keys against\n * the DIRECT prototype's own keys (rather than guessing base method names)\n * avoids flagging every real service as custom.\n */\nconst isCustomService = (service: unknown): boolean => {\n if (service === null || typeof service !== 'object') {\n return false;\n }\n const proto = Object.getPrototypeOf(service);\n const protoOwnKeys = proto ? Object.keys(proto) : [];\n return Object.keys(service).some((key) => !protoOwnKeys.includes(key));\n};\n\n/**\n * Custom routes in Strapi are added as separate files in an api's `routes/`\n * directory (each exporting a plain `{ routes: [...] }` object), never by\n * editing the factory-generated route file, because Koa needs explicit route\n * ordering. The factory router exposes `routes` as a getter, so any route\n * file exposing `routes` as a plain data property is a hand-written custom\n * route file.\n */\nconst hasCustomRoutes = (strapi: Core.Strapi, apiName: string): boolean => {\n const api = strapi.api(apiName);\n const routeFiles = api?.routes ?? {};\n return Object.values(routeFiles).some((router) => {\n if (router === null || typeof router !== 'object') {\n return false;\n }\n const descriptor = Object.getOwnPropertyDescriptor(router, 'routes');\n // A factory router exposes `routes` as an accessor (getter); a hand-written\n // custom routes file exports it as a plain data property.\n return descriptor ? typeof descriptor.get !== 'function' : false;\n });\n};\n\n/**\n * `createCoreController` sets the controller's prototype to the factory's base controller, and\n * marks it when the app passed its own config. Anything else was not minted by the factory: a\n * plain action map (`module.exports = { async find() {} }`) is entirely hand-written, and a\n * factory that returned a non-object is not stock either. Neither may throw out of the dump.\n */\nconst isCustomApiController = (controller: unknown): boolean => {\n if (controller === null || typeof controller !== 'object') {\n return true;\n }\n\n const prototype = Object.getPrototypeOf(controller);\n if (prototype === Object.prototype || prototype === null) {\n return true;\n }\n\n return factories.isCustomController(controller as Core.Controller);\n};\n\n/**\n * Plugin and admin controllers are plain objects even when stock, so only the factory's\n * custom-config mark can single one out here (the same test startup telemetry uses).\n */\nconst isCustomFactoryController = (controller: unknown): boolean =>\n controller !== null &&\n typeof controller === 'object' &&\n factories.isCustomController(controller as Core.Controller);\n\n/**\n * Plugins the app overrides through `src/extensions/<plugin>/`: a `strapi-server.js`, which can\n * replace any controller, service or route, or content-type schema overrides. A plugin\n * controller looks the same stock or overridden, so this folder is what tells Support a\n * plugin was changed.\n */\n// The loader applies content-type overrides from `content-types/<name>/schema.json` only\nconst hasSchemaOverride = (pluginDir: string): boolean => {\n const contentTypesDir = path.join(pluginDir, 'content-types');\n if (!fs.existsSync(contentTypesDir)) {\n return false;\n }\n\n return fs\n .readdirSync(contentTypesDir, { withFileTypes: true })\n .some(\n (entry) =>\n entry.isDirectory() && fs.existsSync(path.join(contentTypesDir, entry.name, 'schema.json'))\n );\n};\n\nconst listExtendedPlugins = (strapi: Core.Strapi): string[] => {\n const extensionsDir = strapi.dirs?.dist?.extensions;\n if (!extensionsDir || !fs.existsSync(extensionsDir)) {\n return [];\n }\n\n return fs\n .readdirSync(extensionsDir, { withFileTypes: true })\n .filter((entry) => entry.isDirectory())\n .map((entry) => entry.name)\n .filter(\n (name) =>\n fs.existsSync(path.join(extensionsDir, name, 'strapi-server.js')) ||\n hasSchemaOverride(path.join(extensionsDir, name))\n )\n .sort();\n};\n\n// Return shape is mirrored in @strapi/types Core.Strapi['getCustomizations'];\n// keep the two in sync.\nexport const detectCustomizations = (strapi: Core.Strapi) => {\n const controllers = strapi.controllers ?? {};\n const services = strapi.services ?? {};\n\n const appControllerUids = Object.keys(controllers).filter((uid) =>\n uid.startsWith(APP_UID_PREFIX)\n );\n\n const apis = appControllerUids.map((uid) => {\n const controller = controllers[uid];\n const service = services[uid];\n // uid is `api::<name>.<name>`; map to the bare api name for route lookup.\n const apiName = uid.slice(APP_UID_PREFIX.length).split('.')[0];\n\n return {\n uid,\n customController: isCustomApiController(controller),\n customService: isCustomService(service),\n customRoutes: hasCustomRoutes(strapi, apiName),\n };\n });\n\n // Every controller, not only the app's own: the dump is used to rebuild an app for debugging.\n const allControllers = Object.keys(controllers).map((uid) => ({\n uid,\n custom: uid.startsWith(APP_UID_PREFIX)\n ? isCustomApiController(controllers[uid])\n : isCustomFactoryController(controllers[uid]),\n }));\n\n const app = strapi.app;\n const registerDefined = typeof app?.register === 'function';\n const bootstrapDefined = typeof app?.bootstrap === 'function';\n const destroyDefined = typeof app?.destroy === 'function';\n const registerNonEmpty = isLifecycleNonEmpty(app?.register);\n const bootstrapNonEmpty = isLifecycleNonEmpty(app?.bootstrap);\n const destroyNonEmpty = isLifecycleNonEmpty(app?.destroy);\n\n return {\n apis,\n controllers: allControllers,\n extendedPlugins: listExtendedPlugins(strapi),\n counts: {\n customControllers: allControllers.filter((c) => c.custom).length,\n customServices: apis.filter((a) => a.customService).length,\n customRoutes: apis.filter((a) => a.customRoutes).length,\n },\n srcIndex: {\n present: app != null,\n registerDefined,\n registerNonEmpty,\n bootstrapDefined,\n bootstrapNonEmpty,\n destroyDefined,\n destroyNonEmpty,\n // Template ships only empty register + bootstrap and no destroy.\n beyondTemplate: destroyDefined || registerNonEmpty || bootstrapNonEmpty,\n },\n };\n};\n"],"names":["APP_UID_PREFIX","stripComments","body","replace","trim","isLifecycleNonEmpty","fn","source","Function","prototype","toString","call","parenEnd","indexOf","bodyStart","arrow","slice","length","lastIndexOf","isCustomService","service","proto","Object","getPrototypeOf","protoOwnKeys","keys","some","key","includes","hasCustomRoutes","strapi","apiName","api","routeFiles","routes","values","router","descriptor","getOwnPropertyDescriptor","get","isCustomApiController","controller","factories","isCustomFactoryController","hasSchemaOverride","pluginDir","contentTypesDir","path","join","fs","existsSync","readdirSync","withFileTypes","entry","isDirectory","name","listExtendedPlugins","extensionsDir","dirs","dist","extensions","filter","map","sort","detectCustomizations","controllers","services","appControllerUids","uid","startsWith","apis","split","customController","customService","customRoutes","allControllers","custom","app","registerDefined","register","bootstrapDefined","bootstrap","destroyDefined","destroy","registerNonEmpty","bootstrapNonEmpty","destroyNonEmpty","extendedPlugins","counts","customControllers","c","customServices","a","srcIndex","present","beyondTemplate"],"mappings":";;;;;;;;;;;AAOA,MAAMA,cAAAA,GAAiB,OAAA;AAEvB;;;AAGC,IACD,MAAMC,aAAAA,GAAgB,CAACC,IAAAA,GACrBA,IAAAA,CACGC,OAAO,CAAC,mBAAA,EAAqB,EAAA,CAAA,CAC7BA,OAAO,CAAC,aAAA,EAAe,IACvBC,IAAI,EAAA;AAEF,MAAMC,sBAAsB,CAACC,EAAAA,GAAAA;IAClC,IAAI,OAAOA,OAAO,UAAA,EAAY;QAC5B,OAAO,KAAA;AACT,IAAA;AACA,IAAA,MAAMC,SAASC,QAAAA,CAASC,SAAS,CAACC,QAAQ,CAACC,IAAI,CAACL,EAAAA,CAAAA;;;;IAIhD,MAAMM,QAAAA,GAAWL,MAAAA,CAAOM,OAAO,CAAC,GAAA,CAAA;IAChC,MAAMC,SAAAA,GAAYP,OAAOM,OAAO,CAAC,KAAKD,QAAAA,KAAa,KAAK,CAAA,GAAIA,QAAAA,CAAAA;;;;;;IAO5D,IAAIE,SAAAA,KAAc,EAAC,EAAG;QACpB,MAAMC,KAAAA,GAAQR,MAAAA,CAAOM,OAAO,CAAC,IAAA,CAAA;QAC7B,OAAOE,KAAAA,KAAU,EAAC,GAAI,KAAA,GAAQd,aAAAA,CAAcM,MAAAA,CAAOS,KAAK,CAACD,KAAAA,GAAQ,CAAA,CAAA,CAAA,CAAIE,MAAM,GAAG,CAAA;AAChF,IAAA;IAEA,OAAOhB,aAAAA,CAAcM,MAAAA,C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,CAAC6B,IAAMA,CAAAA,CAAEd,MAAM,EAAE3D,MAAM;YAChE0E,cAAAA,EAAgBrB,IAAAA,CAAKT,MAAM,CAAC,CAAC+B,IAAMA,CAAAA,CAAEnB,aAAa,EAAExD,MAAM;YAC1DyD,YAAAA,EAAcJ,IAAAA,CAAKT,MAAM,CAAC,CAAC+B,IAAMA,CAAAA,CAAElB,YAAY,EAAEzD;AACnD,SAAA;QACA4E,QAAAA,EAAU;AACRC,YAAAA,OAAAA,EAASjB,GAAAA,IAAO,IAAA;AAChBC,YAAAA,eAAAA;AACAM,YAAAA,gBAAAA;AACAJ,YAAAA,gBAAAA;AACAK,YAAAA,iBAAAA;AACAH,YAAAA,cAAAA;AACAI,YAAAA,eAAAA;;AAEAS,YAAAA,cAAAA,EAAgBb,kBAAkBE,gBAAAA,IAAoBC;AACxD;AACF,KAAA;AACF;;;;;"}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { isCustomController } from '../factories.mjs';
|
|
4
|
+
|
|
5
|
+
const APP_UID_PREFIX = 'api::';
|
|
6
|
+
/**
|
|
7
|
+
* True when a lifecycle function has a non-empty body. The compiled function
|
|
8
|
+
* source is inspected here only to derive a boolean; it is never returned.
|
|
9
|
+
*/ const stripComments = (body)=>body.replace(/\/\*[\s\S]*?\*\//g, '').replace(/\/\/[^\n]*/g, '').trim();
|
|
10
|
+
const isLifecycleNonEmpty = (fn)=>{
|
|
11
|
+
if (typeof fn !== 'function') {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
const source = Function.prototype.toString.call(fn);
|
|
15
|
+
// The body starts at the first `{` AFTER the parameter list closes, not the
|
|
16
|
+
// first `{` overall: a real lifecycle signature like `register({ strapi })`
|
|
17
|
+
// or the template's `register(/*{ strapi }*/)` puts a `{` in the params/comment.
|
|
18
|
+
const parenEnd = source.indexOf(')');
|
|
19
|
+
const bodyStart = source.indexOf('{', parenEnd === -1 ? 0 : parenEnd);
|
|
20
|
+
// No brace anywhere after the parameters means a concise arrow body
|
|
21
|
+
// (`register: ({ strapi }) => strapi.log.info('x')`), where everything after the
|
|
22
|
+
// arrow IS the body. Treating that as empty under-reported a real customization,
|
|
23
|
+
// telling Support an app was stock when it was not. The template only ever ships
|
|
24
|
+
// braced method shorthand, so this branch cannot misread a fresh app.
|
|
25
|
+
if (bodyStart === -1) {
|
|
26
|
+
const arrow = source.indexOf('=>');
|
|
27
|
+
return arrow === -1 ? false : stripComments(source.slice(arrow + 2)).length > 0;
|
|
28
|
+
}
|
|
29
|
+
return stripComments(source.slice(bodyStart + 1, source.lastIndexOf('}'))).length > 0;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* A default `createCoreService` result has its CRUD methods on its class
|
|
33
|
+
* prototype and only `contentType` as an own key; that own key is copied onto
|
|
34
|
+
* the direct prototype (the base service instance) too, so a default service
|
|
35
|
+
* never has an own key that its direct prototype doesn't also have. A custom
|
|
36
|
+
* service (built via a `cfg` object/callback) has extra own method keys that
|
|
37
|
+
* are absent from the prototype it was assigned. Comparing own keys against
|
|
38
|
+
* the DIRECT prototype's own keys (rather than guessing base method names)
|
|
39
|
+
* avoids flagging every real service as custom.
|
|
40
|
+
*/ const isCustomService = (service)=>{
|
|
41
|
+
if (service === null || typeof service !== 'object') {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
const proto = Object.getPrototypeOf(service);
|
|
45
|
+
const protoOwnKeys = proto ? Object.keys(proto) : [];
|
|
46
|
+
return Object.keys(service).some((key)=>!protoOwnKeys.includes(key));
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Custom routes in Strapi are added as separate files in an api's `routes/`
|
|
50
|
+
* directory (each exporting a plain `{ routes: [...] }` object), never by
|
|
51
|
+
* editing the factory-generated route file, because Koa needs explicit route
|
|
52
|
+
* ordering. The factory router exposes `routes` as a getter, so any route
|
|
53
|
+
* file exposing `routes` as a plain data property is a hand-written custom
|
|
54
|
+
* route file.
|
|
55
|
+
*/ const hasCustomRoutes = (strapi, apiName)=>{
|
|
56
|
+
const api = strapi.api(apiName);
|
|
57
|
+
const routeFiles = api?.routes ?? {};
|
|
58
|
+
return Object.values(routeFiles).some((router)=>{
|
|
59
|
+
if (router === null || typeof router !== 'object') {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
const descriptor = Object.getOwnPropertyDescriptor(router, 'routes');
|
|
63
|
+
// A factory router exposes `routes` as an accessor (getter); a hand-written
|
|
64
|
+
// custom routes file exports it as a plain data property.
|
|
65
|
+
return descriptor ? typeof descriptor.get !== 'function' : false;
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* `createCoreController` sets the controller's prototype to the factory's base controller, and
|
|
70
|
+
* marks it when the app passed its own config. Anything else was not minted by the factory: a
|
|
71
|
+
* plain action map (`module.exports = { async find() {} }`) is entirely hand-written, and a
|
|
72
|
+
* factory that returned a non-object is not stock either. Neither may throw out of the dump.
|
|
73
|
+
*/ const isCustomApiController = (controller)=>{
|
|
74
|
+
if (controller === null || typeof controller !== 'object') {
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
const prototype = Object.getPrototypeOf(controller);
|
|
78
|
+
if (prototype === Object.prototype || prototype === null) {
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
return isCustomController(controller);
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Plugin and admin controllers are plain objects even when stock, so only the factory's
|
|
85
|
+
* custom-config mark can single one out here (the same test startup telemetry uses).
|
|
86
|
+
*/ const isCustomFactoryController = (controller)=>controller !== null && typeof controller === 'object' && isCustomController(controller);
|
|
87
|
+
/**
|
|
88
|
+
* Plugins the app overrides through `src/extensions/<plugin>/`: a `strapi-server.js`, which can
|
|
89
|
+
* replace any controller, service or route, or content-type schema overrides. A plugin
|
|
90
|
+
* controller looks the same stock or overridden, so this folder is what tells Support a
|
|
91
|
+
* plugin was changed.
|
|
92
|
+
*/ // The loader applies content-type overrides from `content-types/<name>/schema.json` only
|
|
93
|
+
const hasSchemaOverride = (pluginDir)=>{
|
|
94
|
+
const contentTypesDir = path.join(pluginDir, 'content-types');
|
|
95
|
+
if (!fs.existsSync(contentTypesDir)) {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
return fs.readdirSync(contentTypesDir, {
|
|
99
|
+
withFileTypes: true
|
|
100
|
+
}).some((entry)=>entry.isDirectory() && fs.existsSync(path.join(contentTypesDir, entry.name, 'schema.json')));
|
|
101
|
+
};
|
|
102
|
+
const listExtendedPlugins = (strapi)=>{
|
|
103
|
+
const extensionsDir = strapi.dirs?.dist?.extensions;
|
|
104
|
+
if (!extensionsDir || !fs.existsSync(extensionsDir)) {
|
|
105
|
+
return [];
|
|
106
|
+
}
|
|
107
|
+
return fs.readdirSync(extensionsDir, {
|
|
108
|
+
withFileTypes: true
|
|
109
|
+
}).filter((entry)=>entry.isDirectory()).map((entry)=>entry.name).filter((name)=>fs.existsSync(path.join(extensionsDir, name, 'strapi-server.js')) || hasSchemaOverride(path.join(extensionsDir, name))).sort();
|
|
110
|
+
};
|
|
111
|
+
// Return shape is mirrored in @strapi/types Core.Strapi['getCustomizations'];
|
|
112
|
+
// keep the two in sync.
|
|
113
|
+
const detectCustomizations = (strapi)=>{
|
|
114
|
+
const controllers = strapi.controllers ?? {};
|
|
115
|
+
const services = strapi.services ?? {};
|
|
116
|
+
const appControllerUids = Object.keys(controllers).filter((uid)=>uid.startsWith(APP_UID_PREFIX));
|
|
117
|
+
const apis = appControllerUids.map((uid)=>{
|
|
118
|
+
const controller = controllers[uid];
|
|
119
|
+
const service = services[uid];
|
|
120
|
+
// uid is `api::<name>.<name>`; map to the bare api name for route lookup.
|
|
121
|
+
const apiName = uid.slice(APP_UID_PREFIX.length).split('.')[0];
|
|
122
|
+
return {
|
|
123
|
+
uid,
|
|
124
|
+
customController: isCustomApiController(controller),
|
|
125
|
+
customService: isCustomService(service),
|
|
126
|
+
customRoutes: hasCustomRoutes(strapi, apiName)
|
|
127
|
+
};
|
|
128
|
+
});
|
|
129
|
+
// Every controller, not only the app's own: the dump is used to rebuild an app for debugging.
|
|
130
|
+
const allControllers = Object.keys(controllers).map((uid)=>({
|
|
131
|
+
uid,
|
|
132
|
+
custom: uid.startsWith(APP_UID_PREFIX) ? isCustomApiController(controllers[uid]) : isCustomFactoryController(controllers[uid])
|
|
133
|
+
}));
|
|
134
|
+
const app = strapi.app;
|
|
135
|
+
const registerDefined = typeof app?.register === 'function';
|
|
136
|
+
const bootstrapDefined = typeof app?.bootstrap === 'function';
|
|
137
|
+
const destroyDefined = typeof app?.destroy === 'function';
|
|
138
|
+
const registerNonEmpty = isLifecycleNonEmpty(app?.register);
|
|
139
|
+
const bootstrapNonEmpty = isLifecycleNonEmpty(app?.bootstrap);
|
|
140
|
+
const destroyNonEmpty = isLifecycleNonEmpty(app?.destroy);
|
|
141
|
+
return {
|
|
142
|
+
apis,
|
|
143
|
+
controllers: allControllers,
|
|
144
|
+
extendedPlugins: listExtendedPlugins(strapi),
|
|
145
|
+
counts: {
|
|
146
|
+
customControllers: allControllers.filter((c)=>c.custom).length,
|
|
147
|
+
customServices: apis.filter((a)=>a.customService).length,
|
|
148
|
+
customRoutes: apis.filter((a)=>a.customRoutes).length
|
|
149
|
+
},
|
|
150
|
+
srcIndex: {
|
|
151
|
+
present: app != null,
|
|
152
|
+
registerDefined,
|
|
153
|
+
registerNonEmpty,
|
|
154
|
+
bootstrapDefined,
|
|
155
|
+
bootstrapNonEmpty,
|
|
156
|
+
destroyDefined,
|
|
157
|
+
destroyNonEmpty,
|
|
158
|
+
// Template ships only empty register + bootstrap and no destroy.
|
|
159
|
+
beyondTemplate: destroyDefined || registerNonEmpty || bootstrapNonEmpty
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
export { detectCustomizations, isLifecycleNonEmpty };
|
|
165
|
+
//# sourceMappingURL=detect-customizations.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect-customizations.mjs","sources":["../../src/utils/detect-customizations.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\nimport type { Core } from '@strapi/types';\n\nimport * as factories from '../factories';\n\nconst APP_UID_PREFIX = 'api::';\n\n/**\n * True when a lifecycle function has a non-empty body. The compiled function\n * source is inspected here only to derive a boolean; it is never returned.\n */\nconst stripComments = (body: string): string =>\n body\n .replace(/\\/\\*[\\s\\S]*?\\*\\//g, '')\n .replace(/\\/\\/[^\\n]*/g, '')\n .trim();\n\nexport const isLifecycleNonEmpty = (fn: unknown): boolean => {\n if (typeof fn !== 'function') {\n return false;\n }\n const source = Function.prototype.toString.call(fn);\n // The body starts at the first `{` AFTER the parameter list closes, not the\n // first `{` overall: a real lifecycle signature like `register({ strapi })`\n // or the template's `register(/*{ strapi }*/)` puts a `{` in the params/comment.\n const parenEnd = source.indexOf(')');\n const bodyStart = source.indexOf('{', parenEnd === -1 ? 0 : parenEnd);\n\n // No brace anywhere after the parameters means a concise arrow body\n // (`register: ({ strapi }) => strapi.log.info('x')`), where everything after the\n // arrow IS the body. Treating that as empty under-reported a real customization,\n // telling Support an app was stock when it was not. The template only ever ships\n // braced method shorthand, so this branch cannot misread a fresh app.\n if (bodyStart === -1) {\n const arrow = source.indexOf('=>');\n return arrow === -1 ? false : stripComments(source.slice(arrow + 2)).length > 0;\n }\n\n return stripComments(source.slice(bodyStart + 1, source.lastIndexOf('}'))).length > 0;\n};\n\n/**\n * A default `createCoreService` result has its CRUD methods on its class\n * prototype and only `contentType` as an own key; that own key is copied onto\n * the direct prototype (the base service instance) too, so a default service\n * never has an own key that its direct prototype doesn't also have. A custom\n * service (built via a `cfg` object/callback) has extra own method keys that\n * are absent from the prototype it was assigned. Comparing own keys against\n * the DIRECT prototype's own keys (rather than guessing base method names)\n * avoids flagging every real service as custom.\n */\nconst isCustomService = (service: unknown): boolean => {\n if (service === null || typeof service !== 'object') {\n return false;\n }\n const proto = Object.getPrototypeOf(service);\n const protoOwnKeys = proto ? Object.keys(proto) : [];\n return Object.keys(service).some((key) => !protoOwnKeys.includes(key));\n};\n\n/**\n * Custom routes in Strapi are added as separate files in an api's `routes/`\n * directory (each exporting a plain `{ routes: [...] }` object), never by\n * editing the factory-generated route file, because Koa needs explicit route\n * ordering. The factory router exposes `routes` as a getter, so any route\n * file exposing `routes` as a plain data property is a hand-written custom\n * route file.\n */\nconst hasCustomRoutes = (strapi: Core.Strapi, apiName: string): boolean => {\n const api = strapi.api(apiName);\n const routeFiles = api?.routes ?? {};\n return Object.values(routeFiles).some((router) => {\n if (router === null || typeof router !== 'object') {\n return false;\n }\n const descriptor = Object.getOwnPropertyDescriptor(router, 'routes');\n // A factory router exposes `routes` as an accessor (getter); a hand-written\n // custom routes file exports it as a plain data property.\n return descriptor ? typeof descriptor.get !== 'function' : false;\n });\n};\n\n/**\n * `createCoreController` sets the controller's prototype to the factory's base controller, and\n * marks it when the app passed its own config. Anything else was not minted by the factory: a\n * plain action map (`module.exports = { async find() {} }`) is entirely hand-written, and a\n * factory that returned a non-object is not stock either. Neither may throw out of the dump.\n */\nconst isCustomApiController = (controller: unknown): boolean => {\n if (controller === null || typeof controller !== 'object') {\n return true;\n }\n\n const prototype = Object.getPrototypeOf(controller);\n if (prototype === Object.prototype || prototype === null) {\n return true;\n }\n\n return factories.isCustomController(controller as Core.Controller);\n};\n\n/**\n * Plugin and admin controllers are plain objects even when stock, so only the factory's\n * custom-config mark can single one out here (the same test startup telemetry uses).\n */\nconst isCustomFactoryController = (controller: unknown): boolean =>\n controller !== null &&\n typeof controller === 'object' &&\n factories.isCustomController(controller as Core.Controller);\n\n/**\n * Plugins the app overrides through `src/extensions/<plugin>/`: a `strapi-server.js`, which can\n * replace any controller, service or route, or content-type schema overrides. A plugin\n * controller looks the same stock or overridden, so this folder is what tells Support a\n * plugin was changed.\n */\n// The loader applies content-type overrides from `content-types/<name>/schema.json` only\nconst hasSchemaOverride = (pluginDir: string): boolean => {\n const contentTypesDir = path.join(pluginDir, 'content-types');\n if (!fs.existsSync(contentTypesDir)) {\n return false;\n }\n\n return fs\n .readdirSync(contentTypesDir, { withFileTypes: true })\n .some(\n (entry) =>\n entry.isDirectory() && fs.existsSync(path.join(contentTypesDir, entry.name, 'schema.json'))\n );\n};\n\nconst listExtendedPlugins = (strapi: Core.Strapi): string[] => {\n const extensionsDir = strapi.dirs?.dist?.extensions;\n if (!extensionsDir || !fs.existsSync(extensionsDir)) {\n return [];\n }\n\n return fs\n .readdirSync(extensionsDir, { withFileTypes: true })\n .filter((entry) => entry.isDirectory())\n .map((entry) => entry.name)\n .filter(\n (name) =>\n fs.existsSync(path.join(extensionsDir, name, 'strapi-server.js')) ||\n hasSchemaOverride(path.join(extensionsDir, name))\n )\n .sort();\n};\n\n// Return shape is mirrored in @strapi/types Core.Strapi['getCustomizations'];\n// keep the two in sync.\nexport const detectCustomizations = (strapi: Core.Strapi) => {\n const controllers = strapi.controllers ?? {};\n const services = strapi.services ?? {};\n\n const appControllerUids = Object.keys(controllers).filter((uid) =>\n uid.startsWith(APP_UID_PREFIX)\n );\n\n const apis = appControllerUids.map((uid) => {\n const controller = controllers[uid];\n const service = services[uid];\n // uid is `api::<name>.<name>`; map to the bare api name for route lookup.\n const apiName = uid.slice(APP_UID_PREFIX.length).split('.')[0];\n\n return {\n uid,\n customController: isCustomApiController(controller),\n customService: isCustomService(service),\n customRoutes: hasCustomRoutes(strapi, apiName),\n };\n });\n\n // Every controller, not only the app's own: the dump is used to rebuild an app for debugging.\n const allControllers = Object.keys(controllers).map((uid) => ({\n uid,\n custom: uid.startsWith(APP_UID_PREFIX)\n ? isCustomApiController(controllers[uid])\n : isCustomFactoryController(controllers[uid]),\n }));\n\n const app = strapi.app;\n const registerDefined = typeof app?.register === 'function';\n const bootstrapDefined = typeof app?.bootstrap === 'function';\n const destroyDefined = typeof app?.destroy === 'function';\n const registerNonEmpty = isLifecycleNonEmpty(app?.register);\n const bootstrapNonEmpty = isLifecycleNonEmpty(app?.bootstrap);\n const destroyNonEmpty = isLifecycleNonEmpty(app?.destroy);\n\n return {\n apis,\n controllers: allControllers,\n extendedPlugins: listExtendedPlugins(strapi),\n counts: {\n customControllers: allControllers.filter((c) => c.custom).length,\n customServices: apis.filter((a) => a.customService).length,\n customRoutes: apis.filter((a) => a.customRoutes).length,\n },\n srcIndex: {\n present: app != null,\n registerDefined,\n registerNonEmpty,\n bootstrapDefined,\n bootstrapNonEmpty,\n destroyDefined,\n destroyNonEmpty,\n // Template ships only empty register + bootstrap and no destroy.\n beyondTemplate: destroyDefined || registerNonEmpty || bootstrapNonEmpty,\n },\n };\n};\n"],"names":["APP_UID_PREFIX","stripComments","body","replace","trim","isLifecycleNonEmpty","fn","source","Function","prototype","toString","call","parenEnd","indexOf","bodyStart","arrow","slice","length","lastIndexOf","isCustomService","service","proto","Object","getPrototypeOf","protoOwnKeys","keys","some","key","includes","hasCustomRoutes","strapi","apiName","api","routeFiles","routes","values","router","descriptor","getOwnPropertyDescriptor","get","isCustomApiController","controller","factories","isCustomFactoryController","hasSchemaOverride","pluginDir","contentTypesDir","path","join","fs","existsSync","readdirSync","withFileTypes","entry","isDirectory","name","listExtendedPlugins","extensionsDir","dirs","dist","extensions","filter","map","sort","detectCustomizations","controllers","services","appControllerUids","uid","startsWith","apis","split","customController","customService","customRoutes","allControllers","custom","app","registerDefined","register","bootstrapDefined","bootstrap","destroyDefined","destroy","registerNonEmpty","bootstrapNonEmpty","destroyNonEmpty","extendedPlugins","counts","customControllers","c","customServices","a","srcIndex","present","beyondTemplate"],"mappings":";;;;AAOA,MAAMA,cAAAA,GAAiB,OAAA;AAEvB;;;AAGC,IACD,MAAMC,aAAAA,GAAgB,CAACC,IAAAA,GACrBA,IAAAA,CACGC,OAAO,CAAC,mBAAA,EAAqB,EAAA,CAAA,CAC7BA,OAAO,CAAC,aAAA,EAAe,IACvBC,IAAI,EAAA;AAEF,MAAMC,sB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,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/core",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.58.0",
|
|
4
4
|
"description": "Core of Strapi",
|
|
5
5
|
"homepage": "https://strapi.io",
|
|
6
6
|
"bugs": {
|
|
@@ -60,18 +60,18 @@
|
|
|
60
60
|
"@casl/ability": "6.7.5",
|
|
61
61
|
"@koa/cors": "5.0.0",
|
|
62
62
|
"@koa/router": "12.0.2",
|
|
63
|
-
"@modelcontextprotocol/node": "2.
|
|
64
|
-
"@modelcontextprotocol/server": "2.
|
|
63
|
+
"@modelcontextprotocol/node": "2.1.1",
|
|
64
|
+
"@modelcontextprotocol/server": "2.3.1",
|
|
65
65
|
"@paralleldrive/cuid2": "2.2.2",
|
|
66
|
-
"@strapi/admin": "5.
|
|
67
|
-
"@strapi/database": "5.
|
|
68
|
-
"@strapi/generators": "5.
|
|
69
|
-
"@strapi/logger": "5.
|
|
70
|
-
"@strapi/openapi": "5.
|
|
71
|
-
"@strapi/permissions": "5.
|
|
72
|
-
"@strapi/types": "5.
|
|
73
|
-
"@strapi/typescript-utils": "5.
|
|
74
|
-
"@strapi/utils": "5.
|
|
66
|
+
"@strapi/admin": "5.58.0",
|
|
67
|
+
"@strapi/database": "5.58.0",
|
|
68
|
+
"@strapi/generators": "5.58.0",
|
|
69
|
+
"@strapi/logger": "5.58.0",
|
|
70
|
+
"@strapi/openapi": "5.58.0",
|
|
71
|
+
"@strapi/permissions": "5.58.0",
|
|
72
|
+
"@strapi/types": "5.58.0",
|
|
73
|
+
"@strapi/typescript-utils": "5.58.0",
|
|
74
|
+
"@strapi/utils": "5.58.0",
|
|
75
75
|
"@vercel/stega": "0.1.2",
|
|
76
76
|
"bcryptjs": "2.4.3",
|
|
77
77
|
"boxen": "5.1.2",
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
"zod": "4.4.3"
|
|
119
119
|
},
|
|
120
120
|
"devDependencies": {
|
|
121
|
-
"@modelcontextprotocol/client": "2.
|
|
121
|
+
"@modelcontextprotocol/client": "2.3.1",
|
|
122
122
|
"@swc/core": "1.13.5",
|
|
123
123
|
"@types/bcryptjs": "2.4.3",
|
|
124
124
|
"@types/configstore": "5.0.1",
|
|
@@ -137,12 +137,12 @@
|
|
|
137
137
|
"@types/node": "20.19.41",
|
|
138
138
|
"ajv": "8.20.0",
|
|
139
139
|
"ajv-formats": "3.0.1",
|
|
140
|
-
"eslint-config-custom": "5.
|
|
140
|
+
"eslint-config-custom": "5.58.0",
|
|
141
141
|
"jest": "29.6.0",
|
|
142
142
|
"supertest": "7.2.2",
|
|
143
|
-
"tsconfig": "5.
|
|
143
|
+
"tsconfig": "5.58.0",
|
|
144
144
|
"vitest": "catalog:",
|
|
145
|
-
"vitest-config": "5.
|
|
145
|
+
"vitest-config": "5.58.0"
|
|
146
146
|
},
|
|
147
147
|
"engines": {
|
|
148
148
|
"node": ">=20.0.0 <=26.x.x",
|