@strapi/core 5.53.0 → 5.54.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/domain/content-type/index.d.ts.map +1 -1
- package/dist/domain/content-type/index.js +3 -1
- package/dist/domain/content-type/index.js.map +1 -1
- package/dist/domain/content-type/index.mjs +3 -1
- package/dist/domain/content-type/index.mjs.map +1 -1
- package/dist/package.json.js +14 -15
- package/dist/package.json.js.map +1 -1
- package/dist/package.json.mjs +14 -15
- package/dist/package.json.mjs.map +1 -1
- package/dist/services/content-source-maps.d.ts +14 -2
- package/dist/services/content-source-maps.d.ts.map +1 -1
- package/dist/services/content-source-maps.js +134 -1
- package/dist/services/content-source-maps.js.map +1 -1
- package/dist/services/content-source-maps.mjs +134 -2
- package/dist/services/content-source-maps.mjs.map +1 -1
- package/dist/services/cron.d.ts +3 -18
- package/dist/services/cron.d.ts.map +1 -1
- package/dist/services/cron.js +241 -33
- package/dist/services/cron.js.map +1 -1
- package/dist/services/cron.mjs +241 -33
- package/dist/services/cron.mjs.map +1 -1
- package/dist/services/document-service/transform/relations/extract/data-ids.d.ts +1 -1
- package/dist/services/document-service/transform/relations/extract/data-ids.d.ts.map +1 -1
- package/dist/services/document-service/transform/relations/extract/data-ids.js +12 -3
- package/dist/services/document-service/transform/relations/extract/data-ids.js.map +1 -1
- package/dist/services/document-service/transform/relations/extract/data-ids.mjs +12 -3
- package/dist/services/document-service/transform/relations/extract/data-ids.mjs.map +1 -1
- package/dist/services/document-service/transform/relations/transform/data-ids.d.ts +1 -1
- package/dist/services/document-service/transform/relations/transform/data-ids.d.ts.map +1 -1
- package/dist/services/document-service/transform/relations/transform/data-ids.js +12 -3
- package/dist/services/document-service/transform/relations/transform/data-ids.js.map +1 -1
- package/dist/services/document-service/transform/relations/transform/data-ids.mjs +12 -3
- package/dist/services/document-service/transform/relations/transform/data-ids.mjs.map +1 -1
- package/dist/services/document-service/transform/relations/utils/map-relation.d.ts +6 -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 +13 -10
- 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 +13 -10
- package/dist/services/document-service/transform/relations/utils/map-relation.mjs.map +1 -1
- package/dist/services/features.d.ts.map +1 -1
- package/dist/services/features.js +3 -0
- package/dist/services/features.js.map +1 -1
- package/dist/services/features.mjs +3 -0
- package/dist/services/features.mjs.map +1 -1
- package/package.json +14 -15
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-ids.js","sources":["../../../../../../src/services/document-service/transform/relations/transform/data-ids.ts"],"sourcesContent":["import { curry } from 'lodash/fp';\n\nimport type { UID } from '@strapi/types';\nimport { errors, relations } from '@strapi/utils';\n\nimport { ID, LongHandDocument } from '../utils/types';\nimport { IdMap } from '../../id-map';\nimport { getRelationTargetLocale } from '../utils/i18n';\nimport { getRelationTargetStatus } from '../utils/dp';\nimport { mapRelation, traverseEntityRelations } from '../utils/map-relation';\nimport { normalizeXToOneRelationValue } from '../utils/xto-one';\n\nconst { isPolymorphic } = relations;\n\ninterface Options {\n uid: UID.Schema;\n locale?: string | null;\n status?: 'draft' | 'published';\n allowMissingId?: boolean; // Whether to ignore missing ids and not throw any error\n}\n\n/**\n * Get the entry ids for a given documentId.\n */\nconst getRelationIds = curry(\n (idMap: IdMap, source: Options, targetUid: UID.Schema, relation: LongHandDocument) => {\n // locale to connect to\n const targetLocale = getRelationTargetLocale(relation, {\n targetUid,\n sourceUid: source.uid,\n sourceLocale: source.locale,\n });\n\n // status(es) to connect to\n const targetStatus = getRelationTargetStatus(relation, {\n targetUid,\n sourceUid: source.uid,\n sourceStatus: source.status,\n });\n\n const ids: ID[] = [];\n\n // Find mapping between documentID -> id(s).\n // There are scenarios where a single documentID can map to multiple ids.\n // e.g when connecting Non DP -> DP and connecting to both the draft and publish version at the same time\n for (const tStatus of targetStatus) {\n const entryId = idMap.get({\n uid: targetUid,\n documentId: relation.documentId,\n locale: targetLocale,\n status: tStatus,\n });\n\n if (entryId) ids.push(entryId);\n }\n\n if (!ids.length && !source.allowMissingId) {\n throw new errors.ValidationError(\n `Document with id \"${relation.documentId}\", locale \"${targetLocale}\" not found`\n );\n }\n\n return ids;\n }\n);\n\n/**\n * Iterate over all relations of a data object and transform
|
|
1
|
+
{"version":3,"file":"data-ids.js","sources":["../../../../../../src/services/document-service/transform/relations/transform/data-ids.ts"],"sourcesContent":["import { curry } from 'lodash/fp';\n\nimport type { UID } from '@strapi/types';\nimport { errors, relations } from '@strapi/utils';\n\nimport { ID, LongHandDocument } from '../utils/types';\nimport { IdMap } from '../../id-map';\nimport { getRelationTargetLocale } from '../utils/i18n';\nimport { getRelationTargetStatus } from '../utils/dp';\nimport { mapRelation, traverseEntityRelations } from '../utils/map-relation';\nimport { normalizeXToOneRelationValue } from '../utils/xto-one';\n\nconst { isPolymorphic } = relations;\nconst MEDIA_UID = 'plugin::upload.file' as UID.ContentType;\n\ninterface Options {\n uid: UID.Schema;\n locale?: string | null;\n status?: 'draft' | 'published';\n allowMissingId?: boolean; // Whether to ignore missing ids and not throw any error\n}\n\n/**\n * Get the entry ids for a given documentId.\n */\nconst getRelationIds = curry(\n (idMap: IdMap, source: Options, targetUid: UID.Schema, relation: LongHandDocument) => {\n // locale to connect to\n const targetLocale = getRelationTargetLocale(relation, {\n targetUid,\n sourceUid: source.uid,\n sourceLocale: source.locale,\n });\n\n // status(es) to connect to\n const targetStatus = getRelationTargetStatus(relation, {\n targetUid,\n sourceUid: source.uid,\n sourceStatus: source.status,\n });\n\n const ids: ID[] = [];\n\n // Find mapping between documentID -> id(s).\n // There are scenarios where a single documentID can map to multiple ids.\n // e.g when connecting Non DP -> DP and connecting to both the draft and publish version at the same time\n for (const tStatus of targetStatus) {\n const entryId = idMap.get({\n uid: targetUid,\n documentId: relation.documentId,\n locale: targetLocale,\n status: tStatus,\n });\n\n if (entryId) ids.push(entryId);\n }\n\n if (!ids.length && !source.allowMissingId) {\n throw new errors.ValidationError(\n `Document with id \"${relation.documentId}\", locale \"${targetLocale}\" not found`\n );\n }\n\n return ids;\n }\n);\n\n/**\n * Iterate over all relations and media of a data object and transform document ids to entity ids.\n */\nconst transformDataIdsVisitor = (idMap: IdMap, data: Record<string, any>, source: Options) => {\n return traverseEntityRelations(\n async ({ key, value, attribute }, { set }) => {\n if (!attribute) {\n return;\n }\n const isPolymorphicRelation = isPolymorphic(attribute);\n const getIds = getRelationIds(idMap, source);\n\n // Collapse a \"relates to one\" payload to a single entry first.\n const normalizedValue = normalizeXToOneRelationValue(attribute, value as any);\n\n // Transform the relation documentId to entity id\n const newRelation = await mapRelation((relation) => {\n if (!relation || !relation.documentId) {\n return relation;\n }\n\n // Find relational attributes, and return the document ids\n // if its a polymorphic relation we need to get it from the data itself\n let targetUid: UID.Schema;\n if (attribute.type === 'media') {\n targetUid = MEDIA_UID;\n } else if (isPolymorphicRelation) {\n targetUid = relation.__type;\n } else {\n targetUid = attribute.target;\n }\n const ids: ID[] = getIds(targetUid, relation);\n\n // Handle positional arguments\n const position = { ...relation.position };\n\n // The positional relation target uid can be different for polymorphic relations\n let positionTargetUid: UID.Schema = targetUid;\n if (isPolymorphicRelation && position?.__type) {\n positionTargetUid = position.__type;\n }\n\n if (position.before) {\n const beforeRelation = { ...relation, ...position, documentId: position.before };\n const beforeIds: ID[] = getIds(positionTargetUid, beforeRelation);\n position.before = beforeIds.at(0);\n }\n\n if (position.after) {\n const afterRelation = { ...relation, ...position, documentId: position.after };\n position.after = getIds(positionTargetUid, afterRelation).at(0);\n }\n\n // Transform all ids to new relations\n return ids?.map((id) => {\n const newRelation = { id } as typeof relation;\n\n if (relation.position) {\n newRelation.position = position;\n }\n\n // Insert type if its a polymorphic relation\n if (isPolymorphicRelation) {\n newRelation.__type = targetUid;\n }\n\n return newRelation;\n });\n }, normalizedValue as any);\n\n set(key, newRelation as any);\n },\n {\n schema: strapi.getModel(source.uid),\n getModel: strapi.getModel.bind(strapi),\n includeMedia: true,\n },\n data\n );\n};\n\nexport { transformDataIdsVisitor };\n"],"names":["isPolymorphic","relations","MEDIA_UID","getRelationIds","curry","idMap","source","targetUid","relation","targetLocale","getRelationTargetLocale","sourceUid","uid","sourceLocale","locale","targetStatus","getRelationTargetStatus","sourceStatus","status","ids","tStatus","entryId","get","documentId","push","length","allowMissingId","errors","ValidationError","transformDataIdsVisitor","data","traverseEntityRelations","key","value","attribute","set","isPolymorphicRelation","getIds","normalizedValue","normalizeXToOneRelationValue","newRelation","mapRelation","type","__type","target","position","positionTargetUid","before","beforeRelation","beforeIds","at","after","afterRelation","map","id","schema","strapi","getModel","bind","includeMedia"],"mappings":";;;;;;;;;AAYA,MAAM,EAAEA,aAAa,EAAE,GAAGC,qBAAAA;AAC1B,MAAMC,SAAAA,GAAY,qBAAA;AASlB;;AAEC,IACD,MAAMC,cAAAA,GAAiBC,QAAAA,CACrB,CAACC,KAAAA,EAAcC,QAAiBC,SAAAA,EAAuBC,QAAAA,GAAAA;;IAErD,MAAMC,YAAAA,GAAeC,6BAAwBF,QAAAA,EAAU;AACrDD,QAAAA,SAAAA;AACAI,QAAAA,SAAAA,EAAWL,OAAOM,GAAG;AACrBC,QAAAA,YAAAA,EAAcP,OAAOQ;AACvB,KAAA,CAAA;;IAGA,MAAMC,YAAAA,GAAeC,2BAAwBR,QAAAA,EAAU;AACrDD,QAAAA,SAAAA;AACAI,QAAAA,SAAAA,EAAWL,OAAOM,GAAG;AACrBK,QAAAA,YAAAA,EAAcX,OAAOY;AACvB,KAAA,CAAA;AAEA,IAAA,MAAMC,MAAY,EAAE;;;;IAKpB,KAAK,MAAMC,WAAWL,YAAAA,CAAc;QAClC,MAAMM,OAAAA,GAAUhB,KAAAA,CAAMiB,GAAG,CAAC;YACxBV,GAAAA,EAAKL,SAAAA;AACLgB,YAAAA,UAAAA,EAAYf,SAASe,UAAU;YAC/BT,MAAAA,EAAQL,YAAAA;YACRS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QAAQ,GAAGA,QAAAA;AACzB,gBAAA;;AAGA,gBAAA,IAAIT,qBAAAA,EAAuB;AACzBI,oBAAAA,WAAAA,CAAYG,MAAM,GAAGpC,SAAAA;AACvB,gBAAA;gBAEA,OAAOiC,WAAAA;AACT,YAAA,CAAA,CAAA;QACF,CAAA,EAAGF,eAAAA,CAAAA;AAEHH,QAAAA,GAAAA,CAAIH,GAAAA,EAAKQ,WAAAA,CAAAA;IACX,CAAA,EACA;AACEe,QAAAA,MAAAA,EAAQC,MAAAA,CAAOC,QAAQ,CAACnD,MAAAA,CAAOM,GAAG,CAAA;AAClC6C,QAAAA,QAAAA,EAAUD,MAAAA,CAAOC,QAAQ,CAACC,IAAI,CAACF,MAAAA,CAAAA;QAC/BG,YAAAA,EAAc;KAChB,EACA7B,IAAAA,CAAAA;AAEJ;;;;"}
|
|
@@ -6,6 +6,7 @@ import { traverseEntityRelations as traverseEntityRelationsCurried, mapRelation
|
|
|
6
6
|
import { normalizeXToOneRelationValue } from '../utils/xto-one.mjs';
|
|
7
7
|
|
|
8
8
|
const { isPolymorphic } = relations;
|
|
9
|
+
const MEDIA_UID = 'plugin::upload.file';
|
|
9
10
|
/**
|
|
10
11
|
* Get the entry ids for a given documentId.
|
|
11
12
|
*/ const getRelationIds = curry((idMap, source, targetUid, relation)=>{
|
|
@@ -40,7 +41,7 @@ const { isPolymorphic } = relations;
|
|
|
40
41
|
return ids;
|
|
41
42
|
});
|
|
42
43
|
/**
|
|
43
|
-
* Iterate over all relations of a data object and transform
|
|
44
|
+
* Iterate over all relations and media of a data object and transform document ids to entity ids.
|
|
44
45
|
*/ const transformDataIdsVisitor = (idMap, data, source)=>{
|
|
45
46
|
return traverseEntityRelationsCurried(async ({ key, value, attribute }, { set })=>{
|
|
46
47
|
if (!attribute) {
|
|
@@ -57,7 +58,14 @@ const { isPolymorphic } = relations;
|
|
|
57
58
|
}
|
|
58
59
|
// Find relational attributes, and return the document ids
|
|
59
60
|
// if its a polymorphic relation we need to get it from the data itself
|
|
60
|
-
|
|
61
|
+
let targetUid;
|
|
62
|
+
if (attribute.type === 'media') {
|
|
63
|
+
targetUid = MEDIA_UID;
|
|
64
|
+
} else if (isPolymorphicRelation) {
|
|
65
|
+
targetUid = relation.__type;
|
|
66
|
+
} else {
|
|
67
|
+
targetUid = attribute.target;
|
|
68
|
+
}
|
|
61
69
|
const ids = getIds(targetUid, relation);
|
|
62
70
|
// Handle positional arguments
|
|
63
71
|
const position = {
|
|
@@ -103,7 +111,8 @@ const { isPolymorphic } = relations;
|
|
|
103
111
|
set(key, newRelation);
|
|
104
112
|
}, {
|
|
105
113
|
schema: strapi.getModel(source.uid),
|
|
106
|
-
getModel: strapi.getModel.bind(strapi)
|
|
114
|
+
getModel: strapi.getModel.bind(strapi),
|
|
115
|
+
includeMedia: true
|
|
107
116
|
}, data);
|
|
108
117
|
};
|
|
109
118
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-ids.mjs","sources":["../../../../../../src/services/document-service/transform/relations/transform/data-ids.ts"],"sourcesContent":["import { curry } from 'lodash/fp';\n\nimport type { UID } from '@strapi/types';\nimport { errors, relations } from '@strapi/utils';\n\nimport { ID, LongHandDocument } from '../utils/types';\nimport { IdMap } from '../../id-map';\nimport { getRelationTargetLocale } from '../utils/i18n';\nimport { getRelationTargetStatus } from '../utils/dp';\nimport { mapRelation, traverseEntityRelations } from '../utils/map-relation';\nimport { normalizeXToOneRelationValue } from '../utils/xto-one';\n\nconst { isPolymorphic } = relations;\n\ninterface Options {\n uid: UID.Schema;\n locale?: string | null;\n status?: 'draft' | 'published';\n allowMissingId?: boolean; // Whether to ignore missing ids and not throw any error\n}\n\n/**\n * Get the entry ids for a given documentId.\n */\nconst getRelationIds = curry(\n (idMap: IdMap, source: Options, targetUid: UID.Schema, relation: LongHandDocument) => {\n // locale to connect to\n const targetLocale = getRelationTargetLocale(relation, {\n targetUid,\n sourceUid: source.uid,\n sourceLocale: source.locale,\n });\n\n // status(es) to connect to\n const targetStatus = getRelationTargetStatus(relation, {\n targetUid,\n sourceUid: source.uid,\n sourceStatus: source.status,\n });\n\n const ids: ID[] = [];\n\n // Find mapping between documentID -> id(s).\n // There are scenarios where a single documentID can map to multiple ids.\n // e.g when connecting Non DP -> DP and connecting to both the draft and publish version at the same time\n for (const tStatus of targetStatus) {\n const entryId = idMap.get({\n uid: targetUid,\n documentId: relation.documentId,\n locale: targetLocale,\n status: tStatus,\n });\n\n if (entryId) ids.push(entryId);\n }\n\n if (!ids.length && !source.allowMissingId) {\n throw new errors.ValidationError(\n `Document with id \"${relation.documentId}\", locale \"${targetLocale}\" not found`\n );\n }\n\n return ids;\n }\n);\n\n/**\n * Iterate over all relations of a data object and transform
|
|
1
|
+
{"version":3,"file":"data-ids.mjs","sources":["../../../../../../src/services/document-service/transform/relations/transform/data-ids.ts"],"sourcesContent":["import { curry } from 'lodash/fp';\n\nimport type { UID } from '@strapi/types';\nimport { errors, relations } from '@strapi/utils';\n\nimport { ID, LongHandDocument } from '../utils/types';\nimport { IdMap } from '../../id-map';\nimport { getRelationTargetLocale } from '../utils/i18n';\nimport { getRelationTargetStatus } from '../utils/dp';\nimport { mapRelation, traverseEntityRelations } from '../utils/map-relation';\nimport { normalizeXToOneRelationValue } from '../utils/xto-one';\n\nconst { isPolymorphic } = relations;\nconst MEDIA_UID = 'plugin::upload.file' as UID.ContentType;\n\ninterface Options {\n uid: UID.Schema;\n locale?: string | null;\n status?: 'draft' | 'published';\n allowMissingId?: boolean; // Whether to ignore missing ids and not throw any error\n}\n\n/**\n * Get the entry ids for a given documentId.\n */\nconst getRelationIds = curry(\n (idMap: IdMap, source: Options, targetUid: UID.Schema, relation: LongHandDocument) => {\n // locale to connect to\n const targetLocale = getRelationTargetLocale(relation, {\n targetUid,\n sourceUid: source.uid,\n sourceLocale: source.locale,\n });\n\n // status(es) to connect to\n const targetStatus = getRelationTargetStatus(relation, {\n targetUid,\n sourceUid: source.uid,\n sourceStatus: source.status,\n });\n\n const ids: ID[] = [];\n\n // Find mapping between documentID -> id(s).\n // There are scenarios where a single documentID can map to multiple ids.\n // e.g when connecting Non DP -> DP and connecting to both the draft and publish version at the same time\n for (const tStatus of targetStatus) {\n const entryId = idMap.get({\n uid: targetUid,\n documentId: relation.documentId,\n locale: targetLocale,\n status: tStatus,\n });\n\n if (entryId) ids.push(entryId);\n }\n\n if (!ids.length && !source.allowMissingId) {\n throw new errors.ValidationError(\n `Document with id \"${relation.documentId}\", locale \"${targetLocale}\" not found`\n );\n }\n\n return ids;\n }\n);\n\n/**\n * Iterate over all relations and media of a data object and transform document ids to entity ids.\n */\nconst transformDataIdsVisitor = (idMap: IdMap, data: Record<string, any>, source: Options) => {\n return traverseEntityRelations(\n async ({ key, value, attribute }, { set }) => {\n if (!attribute) {\n return;\n }\n const isPolymorphicRelation = isPolymorphic(attribute);\n const getIds = getRelationIds(idMap, source);\n\n // Collapse a \"relates to one\" payload to a single entry first.\n const normalizedValue = normalizeXToOneRelationValue(attribute, value as any);\n\n // Transform the relation documentId to entity id\n const newRelation = await mapRelation((relation) => {\n if (!relation || !relation.documentId) {\n return relation;\n }\n\n // Find relational attributes, and return the document ids\n // if its a polymorphic relation we need to get it from the data itself\n let targetUid: UID.Schema;\n if (attribute.type === 'media') {\n targetUid = MEDIA_UID;\n } else if (isPolymorphicRelation) {\n targetUid = relation.__type;\n } else {\n targetUid = attribute.target;\n }\n const ids: ID[] = getIds(targetUid, relation);\n\n // Handle positional arguments\n const position = { ...relation.position };\n\n // The positional relation target uid can be different for polymorphic relations\n let positionTargetUid: UID.Schema = targetUid;\n if (isPolymorphicRelation && position?.__type) {\n positionTargetUid = position.__type;\n }\n\n if (position.before) {\n const beforeRelation = { ...relation, ...position, documentId: position.before };\n const beforeIds: ID[] = getIds(positionTargetUid, beforeRelation);\n position.before = beforeIds.at(0);\n }\n\n if (position.after) {\n const afterRelation = { ...relation, ...position, documentId: position.after };\n position.after = getIds(positionTargetUid, afterRelation).at(0);\n }\n\n // Transform all ids to new relations\n return ids?.map((id) => {\n const newRelation = { id } as typeof relation;\n\n if (relation.position) {\n newRelation.position = position;\n }\n\n // Insert type if its a polymorphic relation\n if (isPolymorphicRelation) {\n newRelation.__type = targetUid;\n }\n\n return newRelation;\n });\n }, normalizedValue as any);\n\n set(key, newRelation as any);\n },\n {\n schema: strapi.getModel(source.uid),\n getModel: strapi.getModel.bind(strapi),\n includeMedia: true,\n },\n data\n );\n};\n\nexport { transformDataIdsVisitor };\n"],"names":["isPolymorphic","relations","MEDIA_UID","getRelationIds","curry","idMap","source","targetUid","relation","targetLocale","getRelationTargetLocale","sourceUid","uid","sourceLocale","locale","targetStatus","getRelationTargetStatus","sourceStatus","status","ids","tStatus","entryId","get","documentId","push","length","allowMissingId","errors","ValidationError","transformDataIdsVisitor","data","traverseEntityRelations","key","value","attribute","set","isPolymorphicRelation","getIds","normalizedValue","normalizeXToOneRelationValue","newRelation","mapRelation","type","__type","target","position","positionTargetUid","before","beforeRelation","beforeIds","at","after","afterRelation","map","id","schema","strapi","getModel","bind","includeMedia"],"mappings":";;;;;;;AAYA,MAAM,EAAEA,aAAa,EAAE,GAAGC,SAAAA;AAC1B,MAAMC,SAAAA,GAAY,qBAAA;AASlB;;AAEC,IACD,MAAMC,cAAAA,GAAiBC,KAAAA,CACrB,CAACC,KAAAA,EAAcC,QAAiBC,SAAAA,EAAuBC,QAAAA,GAAAA;;IAErD,MAAMC,YAAAA,GAAeC,wBAAwBF,QAAAA,EAAU;AACrDD,QAAAA,SAAAA;AACAI,QAAAA,SAAAA,EAAWL,OAAOM,GAAG;AACrBC,QAAAA,YAAAA,EAAcP,OAAOQ;AACvB,KAAA,CAAA;;IAGA,MAAMC,YAAAA,GAAeC,wBAAwBR,QAAAA,EAAU;AACrDD,QAAAA,SAAAA;AACAI,QAAAA,SAAAA,EAAWL,OAAOM,GAAG;AACrBK,QAAAA,YAAAA,EAAcX,OAAOY;AACvB,KAAA,CAAA;AAEA,IAAA,MAAMC,MAAY,EAAE;;;;I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YAAA;;YAGA,OAAO/B,GAAAA,EAAKkC,IAAI,CAACC,EAAAA,GAAAA;AACf,gBAAA,MAAMd,WAAAA,GAAc;AAAEc,oBAAAA;AAAG,iBAAA;gBAEzB,IAAI9C,QAAAA,CAASqC,QAAQ,EAAE;AACrBL,oBAAAA,WAAAA,CAAYK,QAAQ,GAAGA,QAAAA;AACzB,gBAAA;;AAGA,gBAAA,IAAIT,qBAAAA,EAAuB;AACzBI,oBAAAA,WAAAA,CAAYG,MAAM,GAAGpC,SAAAA;AACvB,gBAAA;gBAEA,OAAOiC,WAAAA;AACT,YAAA,CAAA,CAAA;QACF,CAAA,EAAGF,eAAAA,CAAAA;AAEHH,QAAAA,GAAAA,CAAIH,GAAAA,EAAKQ,WAAAA,CAAAA;IACX,CAAA,EACA;AACEe,QAAAA,MAAAA,EAAQC,MAAAA,CAAOC,QAAQ,CAACnD,MAAAA,CAAOM,GAAG,CAAA;AAClC6C,QAAAA,QAAAA,EAAUD,MAAAA,CAAOC,QAAQ,CAACC,IAAI,CAACF,MAAAA,CAAAA;QAC/BG,YAAAA,EAAc;KAChB,EACA7B,IAAAA,CAAAA;AAEJ;;;;"}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
import { traverseEntity } from '@strapi/utils';
|
|
1
2
|
import { Relation } from './types';
|
|
3
|
+
type TraverseEntity = Parameters<typeof traverseEntity>;
|
|
4
|
+
type TraverseEntityRelationsOptions = TraverseEntity[1] & {
|
|
5
|
+
includeMedia?: boolean;
|
|
6
|
+
};
|
|
2
7
|
declare const mapRelationCurried: import("lodash").CurriedFunction2<(relation: any) => any, Relation, Promise<Relation>>;
|
|
3
|
-
declare const traverseEntityRelationsCurried: import("lodash").CurriedFunction3<import("@strapi/utils/dist/traverse-entity").Visitor,
|
|
8
|
+
declare const traverseEntityRelationsCurried: import("lodash").CurriedFunction3<import("@strapi/utils/dist/traverse-entity").Visitor, TraverseEntityRelationsOptions, import("@strapi/utils/dist/types").Data, Promise<import("@strapi/utils/dist/types").Data>>;
|
|
4
9
|
export { mapRelationCurried as mapRelation, traverseEntityRelationsCurried as traverseEntityRelations, };
|
|
5
10
|
//# sourceMappingURL=map-relation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map-relation.d.ts","sourceRoot":"","sources":["../../../../../../src/services/document-service/transform/relations/utils/map-relation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"map-relation.d.ts","sourceRoot":"","sources":["../../../../../../src/services/document-service/transform/relations/utils/map-relation.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAS,MAAM,eAAe,CAAC;AAEtD,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AA8GnC,KAAK,cAAc,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AACxD,KAAK,8BAA8B,GAAG,cAAc,CAAC,CAAC,CAAC,GAAG;IAAE,YAAY,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AA2CrF,QAAA,MAAM,kBAAkB,+CAzHD,GAAG,KAAK,GAAG,8BAyHW,CAAC;AAC9C,QAAA,MAAM,8BAA8B,oNAAiC,CAAC;AAEtE,OAAO,EACL,kBAAkB,IAAI,WAAW,EACjC,8BAA8B,IAAI,uBAAuB,GAC1D,CAAC"}
|
|
@@ -105,26 +105,29 @@ const toArray = (value)=>{
|
|
|
105
105
|
return callback(relation);
|
|
106
106
|
};
|
|
107
107
|
/**
|
|
108
|
-
* Utility function, same as `traverseEntity` but only for relations.
|
|
108
|
+
* Utility function, same as `traverseEntity` but only for relations and, when requested, media.
|
|
109
109
|
*/ const traverseEntityRelations = async (visitor, options, data)=>{
|
|
110
|
+
const { includeMedia = false, ...traverseOptions } = options;
|
|
110
111
|
return strapiUtils.traverseEntity(async (options, utils)=>{
|
|
111
112
|
const { attribute } = options;
|
|
112
113
|
if (!attribute) {
|
|
113
114
|
return;
|
|
114
115
|
}
|
|
115
|
-
if (attribute.type !== 'relation') {
|
|
116
|
+
if (attribute.type !== 'relation' && !(includeMedia && attribute.type === 'media')) {
|
|
116
117
|
return;
|
|
117
118
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
119
|
+
if (attribute.type === 'relation') {
|
|
120
|
+
// TODO: Handle join columns
|
|
121
|
+
if (attribute.useJoinTable === false) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
// morphToOne uses morphColumn (inline columns on the entity), handled directly in processData
|
|
125
|
+
if (attribute.relation === 'morphToOne') {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
125
128
|
}
|
|
126
129
|
return visitor(options, utils);
|
|
127
|
-
},
|
|
130
|
+
}, traverseOptions, data);
|
|
128
131
|
};
|
|
129
132
|
const mapRelationCurried = fp.curry(mapRelation);
|
|
130
133
|
const traverseEntityRelationsCurried = fp.curry(traverseEntityRelations);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map-relation.js","sources":["../../../../../../src/services/document-service/transform/relations/utils/map-relation.ts"],"sourcesContent":["/* eslint-disable node/no-callback-literal */\nimport { isObject, curry, isNil } from 'lodash/fp';\n\nimport { traverseEntity, async } from '@strapi/utils';\n\nimport { Relation } from './types';\n\nconst isNumeric = (value: any): value is number => {\n if (Array.isArray(value)) return false; // Handle [1, 'docId'] case\n const parsed = parseInt(value, 10);\n return !Number.isNaN(parsed);\n};\n\nconst toArray = (value: any) => {\n // Keep value as it is if it's a nullish value\n if (isNil(value)) 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 (isNil(relation)) {\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>;\n\n/**\n * Utility function, same as `traverseEntity` but only for relations.\n */\nconst traverseEntityRelations = async (\n visitor: TraverseEntity[0],\n options:
|
|
1
|
+
{"version":3,"file":"map-relation.js","sources":["../../../../../../src/services/document-service/transform/relations/utils/map-relation.ts"],"sourcesContent":["/* eslint-disable node/no-callback-literal */\nimport { isObject, curry, isNil } from 'lodash/fp';\n\nimport { traverseEntity, async } from '@strapi/utils';\n\nimport { Relation } from './types';\n\nconst isNumeric = (value: any): value is number => {\n if (Array.isArray(value)) return false; // Handle [1, 'docId'] case\n const parsed = parseInt(value, 10);\n return !Number.isNaN(parsed);\n};\n\nconst toArray = (value: any) => {\n // Keep value as it is if it's a nullish value\n if (isNil(value)) 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 (isNil(relation)) {\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","Array","isArray","parsed","parseInt","Number","isNaN","toArray","isNil","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,MAAMA,YAAY,CAACC,KAAAA,GAAAA;AACjB,IAAA,IAAIC,MAAMC,OAAO,CAACF,KAAAA,CAAAA,EAAQ,OAAO;IACjC,MAAMG,MAAAA,GAASC,SAASJ,KAAAA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CAAMZ,uBAAAA;;;;;"}
|
|
@@ -103,26 +103,29 @@ const toArray = (value)=>{
|
|
|
103
103
|
return callback(relation);
|
|
104
104
|
};
|
|
105
105
|
/**
|
|
106
|
-
* Utility function, same as `traverseEntity` but only for relations.
|
|
106
|
+
* Utility function, same as `traverseEntity` but only for relations and, when requested, media.
|
|
107
107
|
*/ const traverseEntityRelations = async (visitor, options, data)=>{
|
|
108
|
+
const { includeMedia = false, ...traverseOptions } = options;
|
|
108
109
|
return traverseEntity(async (options, utils)=>{
|
|
109
110
|
const { attribute } = options;
|
|
110
111
|
if (!attribute) {
|
|
111
112
|
return;
|
|
112
113
|
}
|
|
113
|
-
if (attribute.type !== 'relation') {
|
|
114
|
+
if (attribute.type !== 'relation' && !(includeMedia && attribute.type === 'media')) {
|
|
114
115
|
return;
|
|
115
116
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
117
|
+
if (attribute.type === 'relation') {
|
|
118
|
+
// TODO: Handle join columns
|
|
119
|
+
if (attribute.useJoinTable === false) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
// morphToOne uses morphColumn (inline columns on the entity), handled directly in processData
|
|
123
|
+
if (attribute.relation === 'morphToOne') {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
123
126
|
}
|
|
124
127
|
return visitor(options, utils);
|
|
125
|
-
},
|
|
128
|
+
}, traverseOptions, data);
|
|
126
129
|
};
|
|
127
130
|
const mapRelationCurried = curry(mapRelation);
|
|
128
131
|
const traverseEntityRelationsCurried = curry(traverseEntityRelations);
|
|
@@ -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 { isObject, curry, isNil } from 'lodash/fp';\n\nimport { traverseEntity, async } from '@strapi/utils';\n\nimport { Relation } from './types';\n\nconst isNumeric = (value: any): value is number => {\n if (Array.isArray(value)) return false; // Handle [1, 'docId'] case\n const parsed = parseInt(value, 10);\n return !Number.isNaN(parsed);\n};\n\nconst toArray = (value: any) => {\n // Keep value as it is if it's a nullish value\n if (isNil(value)) 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 (isNil(relation)) {\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>;\n\n/**\n * Utility function, same as `traverseEntity` but only for relations.\n */\nconst traverseEntityRelations = async (\n visitor: TraverseEntity[0],\n options:
|
|
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 { isObject, curry, isNil } from 'lodash/fp';\n\nimport { traverseEntity, async } from '@strapi/utils';\n\nimport { Relation } from './types';\n\nconst isNumeric = (value: any): value is number => {\n if (Array.isArray(value)) return false; // Handle [1, 'docId'] case\n const parsed = parseInt(value, 10);\n return !Number.isNaN(parsed);\n};\n\nconst toArray = (value: any) => {\n // Keep value as it is if it's a nullish value\n if (isNil(value)) 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 (isNil(relation)) {\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","Array","isArray","parsed","parseInt","Number","isNaN","toArray","isNil","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,MAAMA,YAAY,CAACC,KAAAA,GAAAA;AACjB,IAAA,IAAIC,MAAMC,OAAO,CAACF,KAAAA,CAAAA,EAAQ,OAAO;IACjC,MAAMG,MAAAA,GAASC,SAASJ,KAAAA,EAAO,EAAA,CAAA;IAC/B,OAAO,CAACK,MAAAA,CAAOC,KAAK,CAACH,MAAAA,CAAAA;AACvB,CAAA;AAEA,MAAMI,UAAU,CAACP,KAAAA,GAAAA;;IAEf,IAAIQ,KAAAA,CAAMR,QAAQ,OAAOA,KAAAA;AACzB,IAAA,IAAIC,KAAAA,CAAMC,OAAO,CAACF,KAAAA,CAAAA,EAAQ,OAAOA,KAAAA;IAEjC,OAAO;AAACA,QAAAA;AAAM,KAAA;AAChB,CAAA;AAEA;;;;;;;;;;;;;;;AAeC,IACD,MAAMS,WAAAA,GAAc,OAClBC,QAAAA,EACAC,GAAAA,EACAC,cAAc,KAAK,GAAA;AAEnB,IAAA,IAAIC,QAAAA,GAAqBF,GAAAA;AAEzB,IAAA,MAAMG,YAAY,CAACd,KAAAA,GAAAA;;AAEjB,QAAA,IAAIY,WAAAA,EAAa;YACf,OAAOZ,KAAAA;AACT,QAAA;QACA,OAAO;AAAEe,YAAAA,GAAAA,EAAKR,OAAAA,CAAQP,KAAAA;AAAO,SAAA;AAC/B,IAAA,CAAA;;AAGA,IAAA,IAAIQ,MAAMK,QAAAA,CAAAA,EAAW;AACnB,QAAA,OAAOH,QAAAA,CAASG,QAAAA,CAAAA;AAClB,IAAA;;IAGA,IAAIZ,K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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;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features.d.ts","sourceRoot":"","sources":["../../src/services/features.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAInD,QAAA,MAAM,qBAAqB,GAAI,QAAQ,IAAI,CAAC,MAAM,KAAG,OAAO,CAAC,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"features.d.ts","sourceRoot":"","sources":["../../src/services/features.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAInD,QAAA,MAAM,qBAAqB,GAAI,QAAQ,IAAI,CAAC,MAAM,KAAG,OAAO,CAAC,QAAQ,CAAC,eAgBrE,CAAC;AAEF,OAAO,EAAE,qBAAqB,EAAE,CAAC;AACjC,MAAM,MAAM,eAAe,GAAG,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features.js","sources":["../../src/services/features.ts"],"sourcesContent":["/**\n * The features service is responsible for managing features within strapi,\n * including interacting with the feature configuration file to know\n * which are enabled and disabled.\n */\n\nimport type { Core, Modules } from '@strapi/types';\n\ntype FeatureName = keyof Modules.Features.FeaturesConfig['future'];\n\nconst createFeaturesService = (strapi: Core.Strapi): Modules.Features.FeaturesService => {\n const service: Modules.Features.FeaturesService = {\n get config() {\n return strapi.config.get<Modules.Features.FeaturesService['config']>('features');\n },\n future: {\n isEnabled(futureFlagName: string): boolean {\n return service.config?.future?.[futureFlagName as FeatureName] === true;\n },\n },\n };\n\n return service;\n};\n\nexport { createFeaturesService };\nexport type FeaturesService = Modules.Features.FeaturesService;\n"],"names":["createFeaturesService","strapi","service","config","get","future","isEnabled","futureFlagName"],"mappings":";;AAAA;;;;IAUA,MAAMA,wBAAwB,CAACC,MAAAA,GAAAA;AAC7B,IAAA,MAAMC,OAAAA,GAA4C;AAChD,QAAA,IAAIC,MAAAA,CAAAA,GAAS;AACX,YAAA,OAAOF,MAAAA,CAAOE,MAAM,CAACC,GAAG,CAA6C,UAAA,CAAA;AACvE,QAAA,CAAA;QACAC,MAAAA,EAAQ;AACNC,YAAAA,SAAAA,CAAAA,CAAUC,cAAsB,EAAA;AAC9B,gBAAA,OAAOL,QAAQC,MAAM,EAAEE,MAAAA,GAASE,eAA8B,KAAK,IAAA;AACrE,YAAA;AACF;AACF,KAAA;IAEA,
|
|
1
|
+
{"version":3,"file":"features.js","sources":["../../src/services/features.ts"],"sourcesContent":["/**\n * The features service is responsible for managing features within strapi,\n * including interacting with the feature configuration file to know\n * which are enabled and disabled.\n */\n\nimport type { Core, Modules } from '@strapi/types';\n\ntype FeatureName = keyof Modules.Features.FeaturesConfig['future'];\n\nconst createFeaturesService = (strapi: Core.Strapi): Modules.Features.FeaturesService => {\n const service: Modules.Features.FeaturesService = {\n get config() {\n return strapi.config.get<Modules.Features.FeaturesService['config']>('features');\n },\n future: {\n isEnabled(futureFlagName: string): boolean {\n return service.config?.future?.[futureFlagName as FeatureName] === true;\n },\n },\n isEnabled(flagName): boolean {\n return service.config?.[flagName] === true;\n },\n };\n\n return service;\n};\n\nexport { createFeaturesService };\nexport type FeaturesService = Modules.Features.FeaturesService;\n"],"names":["createFeaturesService","strapi","service","config","get","future","isEnabled","futureFlagName","flagName"],"mappings":";;AAAA;;;;IAUA,MAAMA,wBAAwB,CAACC,MAAAA,GAAAA;AAC7B,IAAA,MAAMC,OAAAA,GAA4C;AAChD,QAAA,IAAIC,MAAAA,CAAAA,GAAS;AACX,YAAA,OAAOF,MAAAA,CAAOE,MAAM,CAACC,GAAG,CAA6C,UAAA,CAAA;AACvE,QAAA,CAAA;QACAC,MAAAA,EAAQ;AACNC,YAAAA,SAAAA,CAAAA,CAAUC,cAAsB,EAAA;AAC9B,gBAAA,OAAOL,QAAQC,MAAM,EAAEE,MAAAA,GAASE,eAA8B,KAAK,IAAA;AACrE,YAAA;AACF,SAAA;AACAD,QAAAA,SAAAA,CAAAA,CAAUE,QAAQ,EAAA;AAChB,YAAA,OAAON,OAAAA,CAAQC,MAAM,GAAGK,SAAS,KAAK,IAAA;AACxC,QAAA;AACF,KAAA;IAEA,OAAON,OAAAA;AACT;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features.mjs","sources":["../../src/services/features.ts"],"sourcesContent":["/**\n * The features service is responsible for managing features within strapi,\n * including interacting with the feature configuration file to know\n * which are enabled and disabled.\n */\n\nimport type { Core, Modules } from '@strapi/types';\n\ntype FeatureName = keyof Modules.Features.FeaturesConfig['future'];\n\nconst createFeaturesService = (strapi: Core.Strapi): Modules.Features.FeaturesService => {\n const service: Modules.Features.FeaturesService = {\n get config() {\n return strapi.config.get<Modules.Features.FeaturesService['config']>('features');\n },\n future: {\n isEnabled(futureFlagName: string): boolean {\n return service.config?.future?.[futureFlagName as FeatureName] === true;\n },\n },\n };\n\n return service;\n};\n\nexport { createFeaturesService };\nexport type FeaturesService = Modules.Features.FeaturesService;\n"],"names":["createFeaturesService","strapi","service","config","get","future","isEnabled","futureFlagName"],"mappings":"AAAA;;;;IAUA,MAAMA,wBAAwB,CAACC,MAAAA,GAAAA;AAC7B,IAAA,MAAMC,OAAAA,GAA4C;AAChD,QAAA,IAAIC,MAAAA,CAAAA,GAAS;AACX,YAAA,OAAOF,MAAAA,CAAOE,MAAM,CAACC,GAAG,CAA6C,UAAA,CAAA;AACvE,QAAA,CAAA;QACAC,MAAAA,EAAQ;AACNC,YAAAA,SAAAA,CAAAA,CAAUC,cAAsB,EAAA;AAC9B,gBAAA,OAAOL,QAAQC,MAAM,EAAEE,MAAAA,GAASE,eAA8B,KAAK,IAAA;AACrE,YAAA;AACF;AACF,KAAA;IAEA,
|
|
1
|
+
{"version":3,"file":"features.mjs","sources":["../../src/services/features.ts"],"sourcesContent":["/**\n * The features service is responsible for managing features within strapi,\n * including interacting with the feature configuration file to know\n * which are enabled and disabled.\n */\n\nimport type { Core, Modules } from '@strapi/types';\n\ntype FeatureName = keyof Modules.Features.FeaturesConfig['future'];\n\nconst createFeaturesService = (strapi: Core.Strapi): Modules.Features.FeaturesService => {\n const service: Modules.Features.FeaturesService = {\n get config() {\n return strapi.config.get<Modules.Features.FeaturesService['config']>('features');\n },\n future: {\n isEnabled(futureFlagName: string): boolean {\n return service.config?.future?.[futureFlagName as FeatureName] === true;\n },\n },\n isEnabled(flagName): boolean {\n return service.config?.[flagName] === true;\n },\n };\n\n return service;\n};\n\nexport { createFeaturesService };\nexport type FeaturesService = Modules.Features.FeaturesService;\n"],"names":["createFeaturesService","strapi","service","config","get","future","isEnabled","futureFlagName","flagName"],"mappings":"AAAA;;;;IAUA,MAAMA,wBAAwB,CAACC,MAAAA,GAAAA;AAC7B,IAAA,MAAMC,OAAAA,GAA4C;AAChD,QAAA,IAAIC,MAAAA,CAAAA,GAAS;AACX,YAAA,OAAOF,MAAAA,CAAOE,MAAM,CAACC,GAAG,CAA6C,UAAA,CAAA;AACvE,QAAA,CAAA;QACAC,MAAAA,EAAQ;AACNC,YAAAA,SAAAA,CAAAA,CAAUC,cAAsB,EAAA;AAC9B,gBAAA,OAAOL,QAAQC,MAAM,EAAEE,MAAAA,GAASE,eAA8B,KAAK,IAAA;AACrE,YAAA;AACF,SAAA;AACAD,QAAAA,SAAAA,CAAAA,CAAUE,QAAQ,EAAA;AAChB,YAAA,OAAON,OAAAA,CAAQC,MAAM,GAAGK,SAAS,KAAK,IAAA;AACxC,QAAA;AACF,KAAA;IAEA,OAAON,OAAAA;AACT;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/core",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.54.0",
|
|
4
4
|
"description": "Core of Strapi",
|
|
5
5
|
"homepage": "https://strapi.io",
|
|
6
6
|
"bugs": {
|
|
@@ -63,15 +63,15 @@
|
|
|
63
63
|
"@modelcontextprotocol/node": "2.0.0",
|
|
64
64
|
"@modelcontextprotocol/server": "2.0.0",
|
|
65
65
|
"@paralleldrive/cuid2": "2.2.2",
|
|
66
|
-
"@strapi/admin": "5.
|
|
67
|
-
"@strapi/database": "5.
|
|
68
|
-
"@strapi/generators": "5.
|
|
69
|
-
"@strapi/logger": "5.
|
|
70
|
-
"@strapi/openapi": "5.
|
|
71
|
-
"@strapi/permissions": "5.
|
|
72
|
-
"@strapi/types": "5.
|
|
73
|
-
"@strapi/typescript-utils": "5.
|
|
74
|
-
"@strapi/utils": "5.
|
|
66
|
+
"@strapi/admin": "5.54.0",
|
|
67
|
+
"@strapi/database": "5.54.0",
|
|
68
|
+
"@strapi/generators": "5.54.0",
|
|
69
|
+
"@strapi/logger": "5.54.0",
|
|
70
|
+
"@strapi/openapi": "5.54.0",
|
|
71
|
+
"@strapi/permissions": "5.54.0",
|
|
72
|
+
"@strapi/types": "5.54.0",
|
|
73
|
+
"@strapi/typescript-utils": "5.54.0",
|
|
74
|
+
"@strapi/utils": "5.54.0",
|
|
75
75
|
"@vercel/stega": "0.1.2",
|
|
76
76
|
"bcryptjs": "2.4.3",
|
|
77
77
|
"boxen": "5.1.2",
|
|
@@ -80,6 +80,7 @@
|
|
|
80
80
|
"cli-table3": "0.6.5",
|
|
81
81
|
"commander": "8.3.0",
|
|
82
82
|
"configstore": "5.0.1",
|
|
83
|
+
"croner": "10.0.1",
|
|
83
84
|
"debug": "4.3.4",
|
|
84
85
|
"delegates": "1.0.0",
|
|
85
86
|
"dotenv": "16.6.1",
|
|
@@ -104,7 +105,6 @@
|
|
|
104
105
|
"koa-static": "5.0.0",
|
|
105
106
|
"lodash": "4.18.1",
|
|
106
107
|
"mime-types": "2.1.35",
|
|
107
|
-
"node-schedule": "2.1.1",
|
|
108
108
|
"open": "8.4.2",
|
|
109
109
|
"ora": "5.4.1",
|
|
110
110
|
"package-json": "10.0.1",
|
|
@@ -135,15 +135,14 @@
|
|
|
135
135
|
"@types/lodash": "^4.14.191",
|
|
136
136
|
"@types/mime-types": "2.1.1",
|
|
137
137
|
"@types/node": "20.19.41",
|
|
138
|
-
"@types/node-schedule": "2.1.7",
|
|
139
138
|
"ajv": "8.20.0",
|
|
140
139
|
"ajv-formats": "3.0.1",
|
|
141
|
-
"eslint-config-custom": "5.
|
|
140
|
+
"eslint-config-custom": "5.54.0",
|
|
142
141
|
"jest": "29.6.0",
|
|
143
142
|
"supertest": "7.2.2",
|
|
144
|
-
"tsconfig": "5.
|
|
143
|
+
"tsconfig": "5.54.0",
|
|
145
144
|
"vitest": "catalog:",
|
|
146
|
-
"vitest-config": "5.
|
|
145
|
+
"vitest-config": "5.54.0"
|
|
147
146
|
},
|
|
148
147
|
"engines": {
|
|
149
148
|
"node": ">=20.0.0 <=26.x.x",
|