@strapi/core 5.23.2 → 5.23.4

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.
Files changed (35) hide show
  1. package/dist/core-api/routes/validation/mappers.d.ts.map +1 -1
  2. package/dist/core-api/routes/validation/mappers.js +35 -0
  3. package/dist/core-api/routes/validation/mappers.js.map +1 -1
  4. package/dist/core-api/routes/validation/mappers.mjs +35 -0
  5. package/dist/core-api/routes/validation/mappers.mjs.map +1 -1
  6. package/dist/loaders/plugins/index.js +1 -1
  7. package/dist/loaders/plugins/index.js.map +1 -1
  8. package/dist/loaders/plugins/index.mjs +1 -1
  9. package/dist/loaders/plugins/index.mjs.map +1 -1
  10. package/dist/package.json.js +11 -11
  11. package/dist/package.json.mjs +11 -11
  12. package/dist/services/content-source-maps.d.ts +2 -1
  13. package/dist/services/content-source-maps.d.ts.map +1 -1
  14. package/dist/services/content-source-maps.js +29 -7
  15. package/dist/services/content-source-maps.js.map +1 -1
  16. package/dist/services/content-source-maps.mjs +29 -7
  17. package/dist/services/content-source-maps.mjs.map +1 -1
  18. package/dist/services/document-service/components.d.ts +6 -1
  19. package/dist/services/document-service/components.d.ts.map +1 -1
  20. package/dist/services/document-service/components.js +97 -0
  21. package/dist/services/document-service/components.js.map +1 -1
  22. package/dist/services/document-service/components.mjs +97 -1
  23. package/dist/services/document-service/components.mjs.map +1 -1
  24. package/dist/services/document-service/repository.d.ts.map +1 -1
  25. package/dist/services/document-service/repository.js +4 -0
  26. package/dist/services/document-service/repository.js.map +1 -1
  27. package/dist/services/document-service/repository.mjs +5 -1
  28. package/dist/services/document-service/repository.mjs.map +1 -1
  29. package/dist/services/document-service/utils/unidirectional-relations.d.ts +19 -2
  30. package/dist/services/document-service/utils/unidirectional-relations.d.ts.map +1 -1
  31. package/dist/services/document-service/utils/unidirectional-relations.js +21 -6
  32. package/dist/services/document-service/utils/unidirectional-relations.js.map +1 -1
  33. package/dist/services/document-service/utils/unidirectional-relations.mjs +21 -6
  34. package/dist/services/document-service/utils/unidirectional-relations.mjs.map +1 -1
  35. package/package.json +11 -11
@@ -1 +1 @@
1
- {"version":3,"file":"mappers.d.ts","sourceRoot":"","sources":["../../../../src/core-api/routes/validation/mappers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAK5B;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,sBAAsB,eACrB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,SAAS,CAAC,YAAY,CAAC,EAAE,mCASvE,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,2BAA2B,eAC1B,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,SAAS,CAAC,YAAY,CAAC,EAAE,mCASvE,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,oBAAoB,cAAe,OAAO,SAAS,CAAC,YAAY,KAAG,EAAE,UAiDjF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,eAAO,MAAM,yBAAyB,cACzB,OAAO,SAAS,CAAC,YAAY,KACvC,EAAE,UAiDJ,CAAC"}
1
+ {"version":3,"file":"mappers.d.ts","sourceRoot":"","sources":["../../../../src/core-api/routes/validation/mappers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAgB5B;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,sBAAsB,eACrB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,SAAS,CAAC,YAAY,CAAC,EAAE,mCASvE,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,2BAA2B,eAC1B,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,SAAS,CAAC,YAAY,CAAC,EAAE,mCASvE,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,oBAAoB,cAAe,OAAO,SAAS,CAAC,YAAY,KAAG,EAAE,UAiEjF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,eAAO,MAAM,yBAAyB,cACzB,OAAO,SAAS,CAAC,YAAY,KACvC,EAAE,UAiEJ,CAAC"}
@@ -22,6 +22,9 @@ function _interopNamespaceDefault(e) {
22
22
 
23
23
  var z__namespace = /*#__PURE__*/_interopNamespaceDefault(z);
24
24
 
25
+ const isCustomFieldAttribute = (attribute)=>{
26
+ return !!attribute && typeof attribute === 'object' && attribute.type === 'customField' && typeof attribute.customField === 'string';
27
+ };
25
28
  /**
26
29
  * Creates a Zod schema for a collection of Strapi attributes.
27
30
  *
@@ -136,6 +139,22 @@ var z__namespace = /*#__PURE__*/_interopNamespaceDefault(z);
136
139
  return attributes.uidToSchema(attribute);
137
140
  default:
138
141
  {
142
+ if (isCustomFieldAttribute(attribute)) {
143
+ const attrCF = attribute;
144
+ const strapiInstance = global.strapi;
145
+ if (!strapiInstance) {
146
+ throw new Error('Strapi instance not available for custom field conversion');
147
+ }
148
+ const customField = strapiInstance.get('custom-fields').get(attrCF.customField);
149
+ if (!customField) {
150
+ throw new Error(`Custom field '${attrCF.customField}' not found`);
151
+ }
152
+ // Re-dispatch with the resolved underlying Strapi kind
153
+ return mapAttributeToSchema({
154
+ ...attrCF,
155
+ type: customField.type
156
+ });
157
+ }
139
158
  const { type } = attribute;
140
159
  throw new Error(`Unsupported attribute type: ${type}`);
141
160
  }
@@ -225,6 +244,22 @@ var z__namespace = /*#__PURE__*/_interopNamespaceDefault(z);
225
244
  return attributes.uidToInputSchema(attribute);
226
245
  default:
227
246
  {
247
+ if (isCustomFieldAttribute(attribute)) {
248
+ const attrCF = attribute;
249
+ const strapiInstance = global.strapi;
250
+ if (!strapiInstance) {
251
+ throw new Error('Strapi instance not available for custom field conversion');
252
+ }
253
+ const customField = strapiInstance.get('custom-fields').get(attrCF.customField);
254
+ if (!customField) {
255
+ throw new Error(`Custom field '${attrCF.customField}' not found`);
256
+ }
257
+ // Re-dispatch with the resolved underlying Strapi kind
258
+ return mapAttributeToInputSchema({
259
+ ...attrCF,
260
+ type: customField.type
261
+ });
262
+ }
228
263
  const { type } = attribute;
229
264
  throw new Error(`Unsupported attribute type: ${type}`);
230
265
  }
@@ -1 +1 @@
1
- {"version":3,"file":"mappers.js","sources":["../../../../src/core-api/routes/validation/mappers.ts"],"sourcesContent":["/**\n * @fileoverview\n * This file contains functions responsible for mapping Strapi attribute definitions to Zod schemas.\n */\n\nimport type { Schema } from '@strapi/types';\nimport * as z from 'zod/v4';\n\n// eslint-disable-next-line import/no-cycle\nimport * as attributes from './attributes';\n\n/**\n * Creates a Zod schema for a collection of Strapi attributes.\n *\n * @param attributes - An array of tuples, where each tuple contains the attribute name and its schema definition.\n * @returns A Zod object schema representing the combined attributes.\n *\n * @example\n * ```typescript\n * const myAttributes = [\n * ['title', { type: 'string', required: true }],\n * ['description', { type: 'text' }],\n * ];\n * const schema = createAttributesSchema(myAttributes);\n * // schema will be a Zod object with 'title' and 'description' fields,\n * // each mapped to their respective Zod schemas based on their Strapi attribute types.\n * ```\n */\nexport const createAttributesSchema = (\n attributes: [name: string, attribute: Schema.Attribute.AnyAttribute][]\n) => {\n return attributes.reduce((acc, [name, attribute]) => {\n return acc.extend({\n get [name]() {\n return mapAttributeToSchema(attribute);\n },\n });\n }, z.object({}));\n};\n\n/**\n * Creates a Zod input schema for a collection of Strapi attributes.\n * This is typically used for validating incoming data (e.g., from API requests).\n *\n * @param attributes - An array of tuples, where each tuple contains the attribute name and its schema definition.\n * @returns A Zod object schema representing the combined input attributes.\n *\n * @example\n * ```typescript\n * const myInputAttributes = [\n * ['email', { type: 'email', required: true }],\n * ['description', { type: 'text', minLength: 8 }],\n * ];\n * const inputSchema = createAttributesInputSchema(myInputAttributes);\n * // inputSchema will be a Zod object with 'email' and 'description' fields,\n * // mapped to Zod schemas suitable for input validation.\n * ```\n */\nexport const createAttributesInputSchema = (\n attributes: [name: string, attribute: Schema.Attribute.AnyAttribute][]\n) => {\n return attributes.reduce((acc, [name, attribute]) => {\n return acc.extend({\n get [name]() {\n return mapAttributeToInputSchema(attribute);\n },\n });\n }, z.object({}));\n};\n\n/**\n * Maps a Strapi attribute definition to a corresponding Zod validation schema.\n *\n * This function handles every Strapi attribute types and converts them into\n * appropriate Zod validation schemas.\n *\n * @param attribute - The Strapi attribute configuration object.\n * @returns A Zod schema that corresponds to the input attribute's type.\n * @throws {Error} Throws an error if an unsupported attribute type is provided.\n *\n * @example\n * ```typescript\n * const stringAttribute = { type: 'string', minLength: 3 };\n * const stringSchema = mapAttributeToSchema(stringAttribute); // Returns a Zod string schema with minLength.\n *\n * const booleanAttribute = { type: 'boolean', default: false };\n * const booleanSchema = mapAttributeToSchema(booleanAttribute); // Returns a Zod boolean schema with a default.\n * ```\n */\nexport const mapAttributeToSchema = (attribute: Schema.Attribute.AnyAttribute): z.ZodTypeAny => {\n switch (attribute.type) {\n case 'biginteger':\n return attributes.bigIntegerToSchema(attribute);\n case 'blocks':\n return attributes.blocksToSchema();\n case 'boolean':\n return attributes.booleanToSchema(attribute);\n case 'component':\n return attributes.componentToSchema(attribute);\n case 'date':\n return attributes.dateToSchema(attribute);\n case 'datetime':\n return attributes.datetimeToSchema(attribute);\n case 'decimal':\n return attributes.decimalToSchema(attribute);\n case 'dynamiczone':\n return attributes.dynamicZoneToSchema(attribute);\n case 'email':\n return attributes.emailToSchema(attribute);\n case 'enumeration':\n return attributes.enumToSchema(attribute);\n case 'float':\n return attributes.floatToSchema(attribute);\n case 'integer':\n return attributes.integerToSchema(attribute);\n case 'json':\n return attributes.jsonToSchema(attribute);\n case 'media':\n return attributes.mediaToSchema(attribute);\n case 'relation':\n return attributes.relationToSchema(attribute);\n case 'password':\n case 'text':\n case 'richtext':\n case 'string':\n return attributes.stringToSchema(attribute);\n case 'time':\n return attributes.timeToSchema(attribute);\n case 'timestamp':\n return attributes.timestampToSchema(attribute);\n case 'uid':\n return attributes.uidToSchema(attribute);\n default: {\n const { type } = attribute as Schema.Attribute.AnyAttribute;\n\n throw new Error(`Unsupported attribute type: ${type}`);\n }\n }\n};\n\n/**\n * Maps a Strapi attribute definition to a corresponding Zod input validation schema.\n *\n * This function handles every Strapi attribute types and converts them into\n * appropriate Zod validation schemas with their respective constraints.\n *\n * @param attribute - The Strapi attribute configuration object. Contains type information\n * and validation rules for the attribute.\n *\n * @returns A Zod schema that corresponds to the input attribute's type and validation rules\n *\n * @example\n * ```typescript\n * // String attribute with constraints\n * const stringAttribute = {\n * type: 'string',\n * minLength: 3,\n * maxLength: 50,\n * required: true\n * };\n * const stringSchema = mapAttributeToInputSchema(stringAttribute);\n *\n * // Enumeration attribute\n * const enumAttribute = {\n * type: 'enumeration',\n * enum: ['draft', 'published', 'archived']\n * };\n * const enumSchema = mapAttributeToInputSchema(enumAttribute);\n *\n * // Media attribute with multiple files\n * const mediaAttribute = {\n * type: 'media',\n * multiple: true\n * };\n * const mediaSchema = mapAttributeToInputSchema(mediaAttribute);\n * ```\n *\n * @throws {Error} Throws an error if an unsupported attribute type is provided\n *\n */\nexport const mapAttributeToInputSchema = (\n attribute: Schema.Attribute.AnyAttribute\n): z.ZodTypeAny => {\n switch (attribute.type) {\n case 'biginteger':\n return attributes.bigIntegerToInputSchema(attribute);\n case 'blocks':\n return attributes.blocksToInputSchema();\n case 'boolean':\n return attributes.booleanToInputSchema(attribute);\n case 'component':\n return attributes.componentToInputSchema(attribute);\n case 'date':\n return attributes.dateToInputSchema(attribute);\n case 'datetime':\n return attributes.datetimeToInputSchema(attribute);\n case 'decimal':\n return attributes.decimalToInputSchema(attribute);\n case 'dynamiczone':\n return attributes.dynamicZoneToInputSchema(attribute);\n case 'email':\n return attributes.emailToInputSchema(attribute);\n case 'enumeration':\n return attributes.enumerationToInputSchema(attribute);\n case 'float':\n return attributes.floatToInputSchema(attribute);\n case 'integer':\n return attributes.integerToInputSchema(attribute);\n case 'json':\n return attributes.jsonToInputSchema(attribute);\n case 'media':\n return attributes.mediaToInputSchema(attribute);\n case 'relation':\n return attributes.relationToInputSchema(attribute);\n case 'password':\n case 'text':\n case 'richtext':\n case 'string':\n return attributes.textToInputSchema(attribute);\n case 'time':\n return attributes.timeToInputSchema(attribute);\n case 'timestamp':\n return attributes.timestampToInputSchema(attribute);\n case 'uid':\n return attributes.uidToInputSchema(attribute);\n default: {\n const { type } = attribute as Schema.Attribute.AnyAttribute;\n\n throw new Error(`Unsupported attribute type: ${type}`);\n }\n }\n};\n"],"names":["createAttributesSchema","attributes","reduce","acc","name","attribute","extend","mapAttributeToSchema","z","object","createAttributesInputSchema","mapAttributeToInputSchema","type","Error"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAWA;;;;;;;;;;;;;;;;IAiBaA,MAAAA,sBAAAA,GAAyB,CACpCC,UAAAA,GAAAA;AAEA,IAAA,OAAOA,WAAWC,MAAM,CAAC,CAACC,GAAK,EAAA,CAACC,MAAMC,SAAU,CAAA,GAAA;QAC9C,OAAOF,GAAAA,CAAIG,MAAM,CAAC;YAChB,KAAKF,MAAQ,GAAA;AACX,gBAAA,OAAOG,oBAAqBF,CAAAA,SAAAA,CAAAA;AAC9B;AACF,SAAA,CAAA;KACCG,EAAAA,YAAAA,CAAEC,MAAM,CAAC,EAAC,CAAA,CAAA;AACf;AAEA;;;;;;;;;;;;;;;;;IAkBaC,MAAAA,2BAAAA,GAA8B,CACzCT,UAAAA,GAAAA;AAEA,IAAA,OAAOA,WAAWC,MAAM,CAAC,CAACC,GAAK,EAAA,CAACC,MAAMC,SAAU,CAAA,GAAA;QAC9C,OAAOF,GAAAA,CAAIG,MAAM,CAAC;YAChB,KA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A;QACzC,KAAK,MAAA;YACH,OAAOJ,4BAA4B,CAACI,SAAAA,CAAAA;QACtC,KAAK,OAAA;YACH,OAAOJ,6BAA6B,CAACI,SAAAA,CAAAA;QACvC,KAAK,UAAA;YACH,OAAOJ,gCAAgC,CAACI,SAAAA,CAAAA;QAC1C,KAAK,UAAA;QACL,KAAK,MAAA;QACL,KAAK,UAAA;QACL,KAAK,QAAA;YACH,OAAOJ,4BAA4B,CAACI,SAAAA,CAAAA;QACtC,KAAK,MAAA;YACH,OAAOJ,4BAA4B,CAACI,SAAAA,CAAAA;QACtC,KAAK,WAAA;YACH,OAAOJ,iCAAiC,CAACI,SAAAA,CAAAA;QAC3C,KAAK,KAAA;YACH,OAAOJ,2BAA2B,CAACI,SAAAA,CAAAA;AACrC,QAAA;AAAS,YAAA;gBACP,MAAM,EAAEO,IAAI,EAAE,GAAGP,SAAAA;AAEjB,gBAAA,MAAM,IAAIQ,KAAM,CAAA,CAAC,4BAA4B,EAAED,KAAK,CAAC,CAAA;AACvD;AACF;AACF;;;;;;;"}
1
+ {"version":3,"file":"mappers.js","sources":["../../../../src/core-api/routes/validation/mappers.ts"],"sourcesContent":["/**\n * @fileoverview\n * This file contains functions responsible for mapping Strapi attribute definitions to Zod schemas.\n */\n\nimport type { Schema } from '@strapi/types';\nimport * as z from 'zod/v4';\n\n// eslint-disable-next-line import/no-cycle\nimport * as attributes from './attributes';\n\nconst isCustomFieldAttribute = (\n attribute: unknown\n): attribute is { type: 'customField'; customField: string } => {\n return (\n !!attribute &&\n typeof attribute === 'object' &&\n (attribute as any).type === 'customField' &&\n typeof (attribute as any).customField === 'string'\n );\n};\n\n/**\n * Creates a Zod schema for a collection of Strapi attributes.\n *\n * @param attributes - An array of tuples, where each tuple contains the attribute name and its schema definition.\n * @returns A Zod object schema representing the combined attributes.\n *\n * @example\n * ```typescript\n * const myAttributes = [\n * ['title', { type: 'string', required: true }],\n * ['description', { type: 'text' }],\n * ];\n * const schema = createAttributesSchema(myAttributes);\n * // schema will be a Zod object with 'title' and 'description' fields,\n * // each mapped to their respective Zod schemas based on their Strapi attribute types.\n * ```\n */\nexport const createAttributesSchema = (\n attributes: [name: string, attribute: Schema.Attribute.AnyAttribute][]\n) => {\n return attributes.reduce((acc, [name, attribute]) => {\n return acc.extend({\n get [name]() {\n return mapAttributeToSchema(attribute);\n },\n });\n }, z.object({}));\n};\n\n/**\n * Creates a Zod input schema for a collection of Strapi attributes.\n * This is typically used for validating incoming data (e.g., from API requests).\n *\n * @param attributes - An array of tuples, where each tuple contains the attribute name and its schema definition.\n * @returns A Zod object schema representing the combined input attributes.\n *\n * @example\n * ```typescript\n * const myInputAttributes = [\n * ['email', { type: 'email', required: true }],\n * ['description', { type: 'text', minLength: 8 }],\n * ];\n * const inputSchema = createAttributesInputSchema(myInputAttributes);\n * // inputSchema will be a Zod object with 'email' and 'description' fields,\n * // mapped to Zod schemas suitable for input validation.\n * ```\n */\nexport const createAttributesInputSchema = (\n attributes: [name: string, attribute: Schema.Attribute.AnyAttribute][]\n) => {\n return attributes.reduce((acc, [name, attribute]) => {\n return acc.extend({\n get [name]() {\n return mapAttributeToInputSchema(attribute);\n },\n });\n }, z.object({}));\n};\n\n/**\n * Maps a Strapi attribute definition to a corresponding Zod validation schema.\n *\n * This function handles every Strapi attribute types and converts them into\n * appropriate Zod validation schemas.\n *\n * @param attribute - The Strapi attribute configuration object.\n * @returns A Zod schema that corresponds to the input attribute's type.\n * @throws {Error} Throws an error if an unsupported attribute type is provided.\n *\n * @example\n * ```typescript\n * const stringAttribute = { type: 'string', minLength: 3 };\n * const stringSchema = mapAttributeToSchema(stringAttribute); // Returns a Zod string schema with minLength.\n *\n * const booleanAttribute = { type: 'boolean', default: false };\n * const booleanSchema = mapAttributeToSchema(booleanAttribute); // Returns a Zod boolean schema with a default.\n * ```\n */\nexport const mapAttributeToSchema = (attribute: Schema.Attribute.AnyAttribute): z.ZodTypeAny => {\n switch (attribute.type) {\n case 'biginteger':\n return attributes.bigIntegerToSchema(attribute);\n case 'blocks':\n return attributes.blocksToSchema();\n case 'boolean':\n return attributes.booleanToSchema(attribute);\n case 'component':\n return attributes.componentToSchema(attribute);\n case 'date':\n return attributes.dateToSchema(attribute);\n case 'datetime':\n return attributes.datetimeToSchema(attribute);\n case 'decimal':\n return attributes.decimalToSchema(attribute);\n case 'dynamiczone':\n return attributes.dynamicZoneToSchema(attribute);\n case 'email':\n return attributes.emailToSchema(attribute);\n case 'enumeration':\n return attributes.enumToSchema(attribute);\n case 'float':\n return attributes.floatToSchema(attribute);\n case 'integer':\n return attributes.integerToSchema(attribute);\n case 'json':\n return attributes.jsonToSchema(attribute);\n case 'media':\n return attributes.mediaToSchema(attribute);\n case 'relation':\n return attributes.relationToSchema(attribute);\n case 'password':\n case 'text':\n case 'richtext':\n case 'string':\n return attributes.stringToSchema(attribute);\n case 'time':\n return attributes.timeToSchema(attribute);\n case 'timestamp':\n return attributes.timestampToSchema(attribute);\n case 'uid':\n return attributes.uidToSchema(attribute);\n default: {\n if (isCustomFieldAttribute(attribute)) {\n const attrCF = attribute as { type: 'customField'; customField: string };\n const strapiInstance = global.strapi;\n if (!strapiInstance) {\n throw new Error('Strapi instance not available for custom field conversion');\n }\n\n const customField = strapiInstance.get('custom-fields').get(attrCF.customField);\n if (!customField) {\n throw new Error(`Custom field '${attrCF.customField}' not found`);\n }\n\n // Re-dispatch with the resolved underlying Strapi kind\n return mapAttributeToSchema({ ...attrCF, type: customField.type });\n }\n\n const { type } = attribute as Schema.Attribute.AnyAttribute;\n\n throw new Error(`Unsupported attribute type: ${type}`);\n }\n }\n};\n\n/**\n * Maps a Strapi attribute definition to a corresponding Zod input validation schema.\n *\n * This function handles every Strapi attribute types and converts them into\n * appropriate Zod validation schemas with their respective constraints.\n *\n * @param attribute - The Strapi attribute configuration object. Contains type information\n * and validation rules for the attribute.\n *\n * @returns A Zod schema that corresponds to the input attribute's type and validation rules\n *\n * @example\n * ```typescript\n * // String attribute with constraints\n * const stringAttribute = {\n * type: 'string',\n * minLength: 3,\n * maxLength: 50,\n * required: true\n * };\n * const stringSchema = mapAttributeToInputSchema(stringAttribute);\n *\n * // Enumeration attribute\n * const enumAttribute = {\n * type: 'enumeration',\n * enum: ['draft', 'published', 'archived']\n * };\n * const enumSchema = mapAttributeToInputSchema(enumAttribute);\n *\n * // Media attribute with multiple files\n * const mediaAttribute = {\n * type: 'media',\n * multiple: true\n * };\n * const mediaSchema = mapAttributeToInputSchema(mediaAttribute);\n * ```\n *\n * @throws {Error} Throws an error if an unsupported attribute type is provided\n *\n */\nexport const mapAttributeToInputSchema = (\n attribute: Schema.Attribute.AnyAttribute\n): z.ZodTypeAny => {\n switch (attribute.type) {\n case 'biginteger':\n return attributes.bigIntegerToInputSchema(attribute);\n case 'blocks':\n return attributes.blocksToInputSchema();\n case 'boolean':\n return attributes.booleanToInputSchema(attribute);\n case 'component':\n return attributes.componentToInputSchema(attribute);\n case 'date':\n return attributes.dateToInputSchema(attribute);\n case 'datetime':\n return attributes.datetimeToInputSchema(attribute);\n case 'decimal':\n return attributes.decimalToInputSchema(attribute);\n case 'dynamiczone':\n return attributes.dynamicZoneToInputSchema(attribute);\n case 'email':\n return attributes.emailToInputSchema(attribute);\n case 'enumeration':\n return attributes.enumerationToInputSchema(attribute);\n case 'float':\n return attributes.floatToInputSchema(attribute);\n case 'integer':\n return attributes.integerToInputSchema(attribute);\n case 'json':\n return attributes.jsonToInputSchema(attribute);\n case 'media':\n return attributes.mediaToInputSchema(attribute);\n case 'relation':\n return attributes.relationToInputSchema(attribute);\n case 'password':\n case 'text':\n case 'richtext':\n case 'string':\n return attributes.textToInputSchema(attribute);\n case 'time':\n return attributes.timeToInputSchema(attribute);\n case 'timestamp':\n return attributes.timestampToInputSchema(attribute);\n case 'uid':\n return attributes.uidToInputSchema(attribute);\n default: {\n if (isCustomFieldAttribute(attribute)) {\n const attrCF = attribute as { type: 'customField'; customField: string };\n const strapiInstance = global.strapi;\n if (!strapiInstance) {\n throw new Error('Strapi instance not available for custom field conversion');\n }\n\n const customField = strapiInstance.get('custom-fields').get(attrCF.customField);\n if (!customField) {\n throw new Error(`Custom field '${attrCF.customField}' not found`);\n }\n\n // Re-dispatch with the resolved underlying Strapi kind\n return mapAttributeToInputSchema({ ...attrCF, type: customField.type });\n }\n\n const { type } = attribute as Schema.Attribute.AnyAttribute;\n\n throw new Error(`Unsupported attribute type: ${type}`);\n }\n }\n};\n"],"names":["isCustomFieldAttribute","attribute","type","customField","createAttributesSchema","attributes","reduce","acc","name","extend","mapAttributeToSchema","z","object","createAttributesInputSchema","mapAttributeToInputSchema","attrCF","strapiInstance","global","strapi","Error","get"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAWA,MAAMA,yBAAyB,CAC7BC,SAAAA,GAAAA;AAEA,IAAA,OACE,CAAC,CAACA,SACF,IAAA,OAAOA,cAAc,QACrB,IAACA,SAAkBC,CAAAA,IAAI,KAAK,aAC5B,IAAA,OAAO,SAACD,CAAkBE,WAAW,KAAK,QAAA;AAE9C,CAAA;AAEA;;;;;;;;;;;;;;;;IAiBaC,MAAAA,sBAAAA,GAAyB,CACpCC,UAAAA,GAAAA;AAEA,IAAA,OAAOA,WAAWC,MAAM,CAAC,CAACC,GAAK,EAAA,CAACC,MAAMP,SAAU,CAAA,GAAA;QAC9C,OAAOM,GAAAA,CAAIE,MAAM,CAAC;YAChB,KAAKD,MAAQ,GAAA;AACX,gBAAA,OAAOE,oBAAqBT,CAAAA,SAAAA,CAAAA;AAC9B;AACF,SAAA,CAAA;KACCU,EAAAA,YAAAA,CAAEC,MAAM,CAAC,EAAC,CAAA,CAAA;AACf;AAEA;;;;;;;;;;;;;;;;;IAkBaC,MAAAA,2BAAAA,GAA8B,CACzCR,UAAAA,GAAAA;AAEA,IAAA,OAAOA,WAAWC,MAAM,CAAC,CAACC,GAAK,EAAA,CAACC,MAAMP,SAAU,CAAA,GAAA;QAC9C,OAAOM,GAAAA,CAAIE,MAAM,CAAC;YAChB,KAAKD,MAAQ,GAAA;A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A;AACnB,wBAAA,MAAM,IAAIG,KAAM,CAAA,2DAAA,CAAA;AAClB;oBAEA,MAAMhB,WAAAA,GAAca,eAAeI,GAAG,CAAC,iBAAiBA,GAAG,CAACL,OAAOZ,WAAW,CAAA;AAC9E,oBAAA,IAAI,CAACA,WAAa,EAAA;wBAChB,MAAM,IAAIgB,MAAM,CAAC,cAAc,EAAEJ,MAAOZ,CAAAA,WAAW,CAAC,WAAW,CAAC,CAAA;AAClE;;AAGA,oBAAA,OAAOW,yBAA0B,CAAA;AAAE,wBAAA,GAAGC,MAAM;AAAEb,wBAAAA,IAAAA,EAAMC,YAAYD;AAAK,qBAAA,CAAA;AACvE;gBAEA,MAAM,EAAEA,IAAI,EAAE,GAAGD,SAAAA;AAEjB,gBAAA,MAAM,IAAIkB,KAAM,CAAA,CAAC,4BAA4B,EAAEjB,KAAK,CAAC,CAAA;AACvD;AACF;AACF;;;;;;;"}
@@ -1,6 +1,9 @@
1
1
  import * as z from 'zod/v4';
2
2
  import { uidToSchema, timestampToSchema, timeToSchema, stringToSchema, relationToSchema, mediaToSchema, jsonToSchema, integerToSchema, floatToSchema, enumToSchema, emailToSchema, dynamicZoneToSchema, decimalToSchema, datetimeToSchema, dateToSchema, componentToSchema, booleanToSchema, blocksToSchema, bigIntegerToSchema, uidToInputSchema, timestampToInputSchema, timeToInputSchema, textToInputSchema, relationToInputSchema, mediaToInputSchema, jsonToInputSchema, integerToInputSchema, floatToInputSchema, enumerationToInputSchema, emailToInputSchema, dynamicZoneToInputSchema, decimalToInputSchema, datetimeToInputSchema, dateToInputSchema, componentToInputSchema, booleanToInputSchema, blocksToInputSchema, bigIntegerToInputSchema } from './attributes.mjs';
3
3
 
4
+ const isCustomFieldAttribute = (attribute)=>{
5
+ return !!attribute && typeof attribute === 'object' && attribute.type === 'customField' && typeof attribute.customField === 'string';
6
+ };
4
7
  /**
5
8
  * Creates a Zod schema for a collection of Strapi attributes.
6
9
  *
@@ -115,6 +118,22 @@ import { uidToSchema, timestampToSchema, timeToSchema, stringToSchema, relationT
115
118
  return uidToSchema(attribute);
116
119
  default:
117
120
  {
121
+ if (isCustomFieldAttribute(attribute)) {
122
+ const attrCF = attribute;
123
+ const strapiInstance = global.strapi;
124
+ if (!strapiInstance) {
125
+ throw new Error('Strapi instance not available for custom field conversion');
126
+ }
127
+ const customField = strapiInstance.get('custom-fields').get(attrCF.customField);
128
+ if (!customField) {
129
+ throw new Error(`Custom field '${attrCF.customField}' not found`);
130
+ }
131
+ // Re-dispatch with the resolved underlying Strapi kind
132
+ return mapAttributeToSchema({
133
+ ...attrCF,
134
+ type: customField.type
135
+ });
136
+ }
118
137
  const { type } = attribute;
119
138
  throw new Error(`Unsupported attribute type: ${type}`);
120
139
  }
@@ -204,6 +223,22 @@ import { uidToSchema, timestampToSchema, timeToSchema, stringToSchema, relationT
204
223
  return uidToInputSchema(attribute);
205
224
  default:
206
225
  {
226
+ if (isCustomFieldAttribute(attribute)) {
227
+ const attrCF = attribute;
228
+ const strapiInstance = global.strapi;
229
+ if (!strapiInstance) {
230
+ throw new Error('Strapi instance not available for custom field conversion');
231
+ }
232
+ const customField = strapiInstance.get('custom-fields').get(attrCF.customField);
233
+ if (!customField) {
234
+ throw new Error(`Custom field '${attrCF.customField}' not found`);
235
+ }
236
+ // Re-dispatch with the resolved underlying Strapi kind
237
+ return mapAttributeToInputSchema({
238
+ ...attrCF,
239
+ type: customField.type
240
+ });
241
+ }
207
242
  const { type } = attribute;
208
243
  throw new Error(`Unsupported attribute type: ${type}`);
209
244
  }
@@ -1 +1 @@
1
- {"version":3,"file":"mappers.mjs","sources":["../../../../src/core-api/routes/validation/mappers.ts"],"sourcesContent":["/**\n * @fileoverview\n * This file contains functions responsible for mapping Strapi attribute definitions to Zod schemas.\n */\n\nimport type { Schema } from '@strapi/types';\nimport * as z from 'zod/v4';\n\n// eslint-disable-next-line import/no-cycle\nimport * as attributes from './attributes';\n\n/**\n * Creates a Zod schema for a collection of Strapi attributes.\n *\n * @param attributes - An array of tuples, where each tuple contains the attribute name and its schema definition.\n * @returns A Zod object schema representing the combined attributes.\n *\n * @example\n * ```typescript\n * const myAttributes = [\n * ['title', { type: 'string', required: true }],\n * ['description', { type: 'text' }],\n * ];\n * const schema = createAttributesSchema(myAttributes);\n * // schema will be a Zod object with 'title' and 'description' fields,\n * // each mapped to their respective Zod schemas based on their Strapi attribute types.\n * ```\n */\nexport const createAttributesSchema = (\n attributes: [name: string, attribute: Schema.Attribute.AnyAttribute][]\n) => {\n return attributes.reduce((acc, [name, attribute]) => {\n return acc.extend({\n get [name]() {\n return mapAttributeToSchema(attribute);\n },\n });\n }, z.object({}));\n};\n\n/**\n * Creates a Zod input schema for a collection of Strapi attributes.\n * This is typically used for validating incoming data (e.g., from API requests).\n *\n * @param attributes - An array of tuples, where each tuple contains the attribute name and its schema definition.\n * @returns A Zod object schema representing the combined input attributes.\n *\n * @example\n * ```typescript\n * const myInputAttributes = [\n * ['email', { type: 'email', required: true }],\n * ['description', { type: 'text', minLength: 8 }],\n * ];\n * const inputSchema = createAttributesInputSchema(myInputAttributes);\n * // inputSchema will be a Zod object with 'email' and 'description' fields,\n * // mapped to Zod schemas suitable for input validation.\n * ```\n */\nexport const createAttributesInputSchema = (\n attributes: [name: string, attribute: Schema.Attribute.AnyAttribute][]\n) => {\n return attributes.reduce((acc, [name, attribute]) => {\n return acc.extend({\n get [name]() {\n return mapAttributeToInputSchema(attribute);\n },\n });\n }, z.object({}));\n};\n\n/**\n * Maps a Strapi attribute definition to a corresponding Zod validation schema.\n *\n * This function handles every Strapi attribute types and converts them into\n * appropriate Zod validation schemas.\n *\n * @param attribute - The Strapi attribute configuration object.\n * @returns A Zod schema that corresponds to the input attribute's type.\n * @throws {Error} Throws an error if an unsupported attribute type is provided.\n *\n * @example\n * ```typescript\n * const stringAttribute = { type: 'string', minLength: 3 };\n * const stringSchema = mapAttributeToSchema(stringAttribute); // Returns a Zod string schema with minLength.\n *\n * const booleanAttribute = { type: 'boolean', default: false };\n * const booleanSchema = mapAttributeToSchema(booleanAttribute); // Returns a Zod boolean schema with a default.\n * ```\n */\nexport const mapAttributeToSchema = (attribute: Schema.Attribute.AnyAttribute): z.ZodTypeAny => {\n switch (attribute.type) {\n case 'biginteger':\n return attributes.bigIntegerToSchema(attribute);\n case 'blocks':\n return attributes.blocksToSchema();\n case 'boolean':\n return attributes.booleanToSchema(attribute);\n case 'component':\n return attributes.componentToSchema(attribute);\n case 'date':\n return attributes.dateToSchema(attribute);\n case 'datetime':\n return attributes.datetimeToSchema(attribute);\n case 'decimal':\n return attributes.decimalToSchema(attribute);\n case 'dynamiczone':\n return attributes.dynamicZoneToSchema(attribute);\n case 'email':\n return attributes.emailToSchema(attribute);\n case 'enumeration':\n return attributes.enumToSchema(attribute);\n case 'float':\n return attributes.floatToSchema(attribute);\n case 'integer':\n return attributes.integerToSchema(attribute);\n case 'json':\n return attributes.jsonToSchema(attribute);\n case 'media':\n return attributes.mediaToSchema(attribute);\n case 'relation':\n return attributes.relationToSchema(attribute);\n case 'password':\n case 'text':\n case 'richtext':\n case 'string':\n return attributes.stringToSchema(attribute);\n case 'time':\n return attributes.timeToSchema(attribute);\n case 'timestamp':\n return attributes.timestampToSchema(attribute);\n case 'uid':\n return attributes.uidToSchema(attribute);\n default: {\n const { type } = attribute as Schema.Attribute.AnyAttribute;\n\n throw new Error(`Unsupported attribute type: ${type}`);\n }\n }\n};\n\n/**\n * Maps a Strapi attribute definition to a corresponding Zod input validation schema.\n *\n * This function handles every Strapi attribute types and converts them into\n * appropriate Zod validation schemas with their respective constraints.\n *\n * @param attribute - The Strapi attribute configuration object. Contains type information\n * and validation rules for the attribute.\n *\n * @returns A Zod schema that corresponds to the input attribute's type and validation rules\n *\n * @example\n * ```typescript\n * // String attribute with constraints\n * const stringAttribute = {\n * type: 'string',\n * minLength: 3,\n * maxLength: 50,\n * required: true\n * };\n * const stringSchema = mapAttributeToInputSchema(stringAttribute);\n *\n * // Enumeration attribute\n * const enumAttribute = {\n * type: 'enumeration',\n * enum: ['draft', 'published', 'archived']\n * };\n * const enumSchema = mapAttributeToInputSchema(enumAttribute);\n *\n * // Media attribute with multiple files\n * const mediaAttribute = {\n * type: 'media',\n * multiple: true\n * };\n * const mediaSchema = mapAttributeToInputSchema(mediaAttribute);\n * ```\n *\n * @throws {Error} Throws an error if an unsupported attribute type is provided\n *\n */\nexport const mapAttributeToInputSchema = (\n attribute: Schema.Attribute.AnyAttribute\n): z.ZodTypeAny => {\n switch (attribute.type) {\n case 'biginteger':\n return attributes.bigIntegerToInputSchema(attribute);\n case 'blocks':\n return attributes.blocksToInputSchema();\n case 'boolean':\n return attributes.booleanToInputSchema(attribute);\n case 'component':\n return attributes.componentToInputSchema(attribute);\n case 'date':\n return attributes.dateToInputSchema(attribute);\n case 'datetime':\n return attributes.datetimeToInputSchema(attribute);\n case 'decimal':\n return attributes.decimalToInputSchema(attribute);\n case 'dynamiczone':\n return attributes.dynamicZoneToInputSchema(attribute);\n case 'email':\n return attributes.emailToInputSchema(attribute);\n case 'enumeration':\n return attributes.enumerationToInputSchema(attribute);\n case 'float':\n return attributes.floatToInputSchema(attribute);\n case 'integer':\n return attributes.integerToInputSchema(attribute);\n case 'json':\n return attributes.jsonToInputSchema(attribute);\n case 'media':\n return attributes.mediaToInputSchema(attribute);\n case 'relation':\n return attributes.relationToInputSchema(attribute);\n case 'password':\n case 'text':\n case 'richtext':\n case 'string':\n return attributes.textToInputSchema(attribute);\n case 'time':\n return attributes.timeToInputSchema(attribute);\n case 'timestamp':\n return attributes.timestampToInputSchema(attribute);\n case 'uid':\n return attributes.uidToInputSchema(attribute);\n default: {\n const { type } = attribute as Schema.Attribute.AnyAttribute;\n\n throw new Error(`Unsupported attribute type: ${type}`);\n }\n }\n};\n"],"names":["createAttributesSchema","attributes","reduce","acc","name","attribute","extend","mapAttributeToSchema","z","object","createAttributesInputSchema","mapAttributeToInputSchema","type","Error"],"mappings":";;;AAWA;;;;;;;;;;;;;;;;IAiBaA,MAAAA,sBAAAA,GA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esContent":["/**\n * @fileoverview\n * This file contains functions responsible for mapping Strapi attribute definitions to Zod schemas.\n */\n\nimport type { Schema } from '@strapi/types';\nimport * as z from 'zod/v4';\n\n// eslint-disable-next-line import/no-cycle\nimport * as attributes from './attributes';\n\nconst isCustomFieldAttribute = (\n attribute: unknown\n): attribute is { type: 'customField'; customField: string } => {\n return (\n !!attribute &&\n typeof attribute === 'object' &&\n (attribute as any).type === 'customField' &&\n typeof (attribute as any).customField === 'string'\n );\n};\n\n/**\n * Creates a Zod schema for a collection of Strapi attributes.\n *\n * @param attributes - An array of tuples, where each tuple contains the attribute name and its schema definition.\n * @returns A Zod object schema representing the combined attributes.\n *\n * @example\n * ```typescript\n * const myAttributes = [\n * ['title', { type: 'string', required: true }],\n * ['description', { type: 'text' }],\n * ];\n * const schema = createAttributesSchema(myAttributes);\n * // schema will be a Zod object with 'title' and 'description' fields,\n * // each mapped to their respective Zod schemas based on their Strapi attribute types.\n * ```\n */\nexport const createAttributesSchema = (\n attributes: [name: string, attribute: Schema.Attribute.AnyAttribute][]\n) => {\n return attributes.reduce((acc, [name, attribute]) => {\n return acc.extend({\n get [name]() {\n return mapAttributeToSchema(attribute);\n },\n });\n }, z.object({}));\n};\n\n/**\n * Creates a Zod input schema for a collection of Strapi attributes.\n * This is typically used for validating incoming data (e.g., from API requests).\n *\n * @param attributes - An array of tuples, where each tuple contains the attribute name and its schema definition.\n * @returns A Zod object schema representing the combined input attributes.\n *\n * @example\n * ```typescript\n * const myInputAttributes = [\n * ['email', { type: 'email', required: true }],\n * ['description', { type: 'text', minLength: 8 }],\n * ];\n * const inputSchema = createAttributesInputSchema(myInputAttributes);\n * // inputSchema will be a Zod object with 'email' and 'description' fields,\n * // mapped to Zod schemas suitable for input validation.\n * ```\n */\nexport const createAttributesInputSchema = (\n attributes: [name: string, attribute: Schema.Attribute.AnyAttribute][]\n) => {\n return attributes.reduce((acc, [name, attribute]) => {\n return acc.extend({\n get [name]() {\n return mapAttributeToInputSchema(attribute);\n },\n });\n }, z.object({}));\n};\n\n/**\n * Maps a Strapi attribute definition to a corresponding Zod validation schema.\n *\n * This function handles every Strapi attribute types and converts them into\n * appropriate Zod validation schemas.\n *\n * @param attribute - The Strapi attribute configuration object.\n * @returns A Zod schema that corresponds to the input attribute's type.\n * @throws {Error} Throws an error if an unsupported attribute type is provided.\n *\n * @example\n * ```typescript\n * const stringAttribute = { type: 'string', minLength: 3 };\n * const stringSchema = mapAttributeToSchema(stringAttribute); // Returns a Zod string schema with minLength.\n *\n * const booleanAttribute = { type: 'boolean', default: false };\n * const booleanSchema = mapAttributeToSchema(booleanAttribute); // Returns a Zod boolean schema with a default.\n * ```\n */\nexport const mapAttributeToSchema = (attribute: Schema.Attribute.AnyAttribute): z.ZodTypeAny => {\n switch (attribute.type) {\n case 'biginteger':\n return attributes.bigIntegerToSchema(attribute);\n case 'blocks':\n return attributes.blocksToSchema();\n case 'boolean':\n return attributes.booleanToSchema(attribute);\n case 'component':\n return attributes.componentToSchema(attribute);\n case 'date':\n return attributes.dateToSchema(attribute);\n case 'datetime':\n return attributes.datetimeToSchema(attribute);\n case 'decimal':\n return attributes.decimalToSchema(attribute);\n case 'dynamiczone':\n return attributes.dynamicZoneToSchema(attribute);\n case 'email':\n return attributes.emailToSchema(attribute);\n case 'enumeration':\n return attributes.enumToSchema(attribute);\n case 'float':\n return attributes.floatToSchema(attribute);\n case 'integer':\n return attributes.integerToSchema(attribute);\n case 'json':\n return attributes.jsonToSchema(attribute);\n case 'media':\n return attributes.mediaToSchema(attribute);\n case 'relation':\n return attributes.relationToSchema(attribute);\n case 'password':\n case 'text':\n case 'richtext':\n case 'string':\n return attributes.stringToSchema(attribute);\n case 'time':\n return attributes.timeToSchema(attribute);\n case 'timestamp':\n return attributes.timestampToSchema(attribute);\n case 'uid':\n return attributes.uidToSchema(attribute);\n default: {\n if (isCustomFieldAttribute(attribute)) {\n const attrCF = attribute as { type: 'customField'; customField: string };\n const strapiInstance = global.strapi;\n if (!strapiInstance) {\n throw new Error('Strapi instance not available for custom field conversion');\n }\n\n const customField = strapiInstance.get('custom-fields').get(attrCF.customField);\n if (!customField) {\n throw new Error(`Custom field '${attrCF.customField}' not found`);\n }\n\n // Re-dispatch with the resolved underlying Strapi kind\n return mapAttributeToSchema({ ...attrCF, type: customField.type });\n }\n\n const { type } = attribute as Schema.Attribute.AnyAttribute;\n\n throw new Error(`Unsupported attribute type: ${type}`);\n }\n }\n};\n\n/**\n * Maps a Strapi attribute definition to a corresponding Zod input validation schema.\n *\n * This function handles every Strapi attribute types and converts them into\n * appropriate Zod validation schemas with their respective constraints.\n *\n * @param attribute - The Strapi attribute configuration object. Contains type information\n * and validation rules for the attribute.\n *\n * @returns A Zod schema that corresponds to the input attribute's type and validation rules\n *\n * @example\n * ```typescript\n * // String attribute with constraints\n * const stringAttribute = {\n * type: 'string',\n * minLength: 3,\n * maxLength: 50,\n * required: true\n * };\n * const stringSchema = mapAttributeToInputSchema(stringAttribute);\n *\n * // Enumeration attribute\n * const enumAttribute = {\n * type: 'enumeration',\n * enum: ['draft', 'published', 'archived']\n * };\n * const enumSchema = mapAttributeToInputSchema(enumAttribute);\n *\n * // Media attribute with multiple files\n * const mediaAttribute = {\n * type: 'media',\n * multiple: true\n * };\n * const mediaSchema = mapAttributeToInputSchema(mediaAttribute);\n * ```\n *\n * @throws {Error} Throws an error if an unsupported attribute type is provided\n *\n */\nexport const mapAttributeToInputSchema = (\n attribute: Schema.Attribute.AnyAttribute\n): z.ZodTypeAny => {\n switch (attribute.type) {\n case 'biginteger':\n return attributes.bigIntegerToInputSchema(attribute);\n case 'blocks':\n return attributes.blocksToInputSchema();\n case 'boolean':\n return attributes.booleanToInputSchema(attribute);\n case 'component':\n return attributes.componentToInputSchema(attribute);\n case 'date':\n return attributes.dateToInputSchema(attribute);\n case 'datetime':\n return attributes.datetimeToInputSchema(attribute);\n case 'decimal':\n return attributes.decimalToInputSchema(attribute);\n case 'dynamiczone':\n return attributes.dynamicZoneToInputSchema(attribute);\n case 'email':\n return attributes.emailToInputSchema(attribute);\n case 'enumeration':\n return attributes.enumerationToInputSchema(attribute);\n case 'float':\n return attributes.floatToInputSchema(attribute);\n case 'integer':\n return attributes.integerToInputSchema(attribute);\n case 'json':\n return attributes.jsonToInputSchema(attribute);\n case 'media':\n return attributes.mediaToInputSchema(attribute);\n case 'relation':\n return attributes.relationToInputSchema(attribute);\n case 'password':\n case 'text':\n case 'richtext':\n case 'string':\n return attributes.textToInputSchema(attribute);\n case 'time':\n return attributes.timeToInputSchema(attribute);\n case 'timestamp':\n return attributes.timestampToInputSchema(attribute);\n case 'uid':\n return attributes.uidToInputSchema(attribute);\n default: {\n if (isCustomFieldAttribute(attribute)) {\n const attrCF = attribute as { type: 'customField'; customField: string };\n const strapiInstance = global.strapi;\n if (!strapiInstance) {\n throw new Error('Strapi instance not available for custom field conversion');\n }\n\n const customField = strapiInstance.get('custom-fields').get(attrCF.customField);\n if (!customField) {\n throw new Error(`Custom field '${attrCF.customField}' not found`);\n }\n\n // Re-dispatch with the resolved underlying Strapi kind\n return mapAttributeToInputSchema({ ...attrCF, type: customField.type });\n }\n\n const { type } = attribute as Schema.Attribute.AnyAttribute;\n\n throw new Error(`Unsupported attribute type: ${type}`);\n }\n }\n};\n"],"names":["isCustomFieldAttribute","attribute","type","customField","createAttributesSchema","attributes","reduce","acc","name","extend","mapAttributeToSchema","z","object","createAttributesInputSchema","mapAttributeToInputSchema","attrCF","strapiInstance","global","strapi","Error","get"],"mappings":";;;AAWA,MAAMA,yBAAyB,CAC7BC,SAAAA,GAAAA;AAEA,IAAA,OACE,CAAC,CAACA,SACF,IAAA,OAAOA,cAAc,QACrB,IAACA,SAAkBC,CAAAA,IAAI,KAAK,aAC5B,IAAA,OAAO,SAACD,CAAkBE,WAAW,KAAK,QAAA;AAE9C,CAAA;AAEA;;;;;;;;;;;;;;;;IAiBaC,MAAAA,sBAAAA,GAAyB,CACpCC,UAAAA,GAAAA;AAEA,IAAA,OAAOA,WAAWC,MAAM,CA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,KAAK,UAAA;QACL,KAAK,MAAA;QACL,KAAK,UAAA;QACL,KAAK,QAAA;YACH,OAAOI,iBAA4B,CAACJ,SAAAA,CAAAA;QACtC,KAAK,MAAA;YACH,OAAOI,iBAA4B,CAACJ,SAAAA,CAAAA;QACtC,KAAK,WAAA;YACH,OAAOI,sBAAiC,CAACJ,SAAAA,CAAAA;QAC3C,KAAK,KAAA;YACH,OAAOI,gBAA2B,CAACJ,SAAAA,CAAAA;AACrC,QAAA;AAAS,YAAA;AACP,gBAAA,IAAID,uBAAuBC,SAAY,CAAA,EAAA;AACrC,oBAAA,MAAMc,MAASd,GAAAA,SAAAA;oBACf,MAAMe,cAAAA,GAAiBC,OAAOC,MAAM;AACpC,oBAAA,IAAI,CAACF,cAAgB,EAAA;AACnB,wBAAA,MAAM,IAAIG,KAAM,CAAA,2DAAA,CAAA;AAClB;oBAEA,MAAMhB,WAAAA,GAAca,eAAeI,GAAG,CAAC,iBAAiBA,GAAG,CAACL,OAAOZ,WAAW,CAAA;AAC9E,oBAAA,IAAI,CAACA,WAAa,EAAA;wBAChB,MAAM,IAAIgB,MAAM,CAAC,cAAc,EAAEJ,MAAOZ,CAAAA,WAAW,CAAC,WAAW,CAAC,CAAA;AAClE;;AAGA,oBAAA,OAAOW,yBAA0B,CAAA;AAAE,wBAAA,GAAGC,MAAM;AAAEb,wBAAAA,IAAAA,EAAMC,YAAYD;AAAK,qBAAA,CAAA;AACvE;gBAEA,MAAM,EAAEA,IAAI,EAAE,GAAGD,SAAAA;AAEjB,gBAAA,MAAM,IAAIkB,KAAM,CAAA,CAAC,4BAA4B,EAAEjB,KAAK,CAAC,CAAA;AACvD;AACF;AACF;;;;"}
@@ -117,7 +117,7 @@ async function loadPlugins(strapi1) {
117
117
  try {
118
118
  serverEntrypointPath = path.join(enabledPlugin.pathToPlugin, resolvedExport);
119
119
  } catch (e) {
120
- throw new Error(`Error loading the plugin ${pluginName} because ${pluginName} is not installed. Please either install the plugin or remove it's configuration.`);
120
+ throw new Error(`Error loading the plugin ${pluginName} because ${pluginName} is not installed. Please either install the plugin or remove its configuration.`);
121
121
  }
122
122
  // only load plugins with a server entrypoint
123
123
  if (!await fse.pathExists(serverEntrypointPath)) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/loaders/plugins/index.ts"],"sourcesContent":["import { join } from 'path';\nimport fse from 'fs-extra';\nimport { defaultsDeep, defaults, getOr, get } from 'lodash/fp';\nimport * as resolve from 'resolve.exports';\n\nimport { env } from '@strapi/utils';\nimport type { Core, Plugin, Struct } from '@strapi/types';\nimport { loadConfigFile } from '../../utils/load-config-file';\nimport { loadFiles } from '../../utils/load-files';\nimport { getEnabledPlugins } from './get-enabled-plugins';\nimport { getUserPluginsConfig } from './get-user-plugins-config';\nimport { getGlobalId } from '../../domain/content-type';\n\ninterface Plugins {\n [key: string]: Plugin.LoadedPlugin;\n}\n\nconst defaultPlugin = {\n bootstrap() {},\n destroy() {},\n register() {},\n config: {\n default: {},\n validator() {},\n },\n routes: [],\n controllers: {},\n services: {},\n policies: {},\n middlewares: {},\n contentTypes: {},\n};\n\nconst applyUserExtension = async (plugins: Plugins) => {\n const extensionsDir = strapi.dirs.dist.extensions;\n if (!(await fse.pathExists(extensionsDir))) {\n return;\n }\n\n const extendedSchemas = await loadFiles(extensionsDir, '**/content-types/**/schema.json');\n const strapiServers = await loadFiles(extensionsDir, '**/strapi-server.js');\n\n for (const pluginName of Object.keys(plugins)) {\n const plugin = plugins[pluginName];\n // first: load json schema\n for (const ctName of Object.keys(plugin.contentTypes)) {\n const extendedSchema = get([pluginName, 'content-types', ctName, 'schema'], extendedSchemas);\n if (extendedSchema) {\n plugin.contentTypes[ctName].schema = {\n ...plugin.contentTypes[ctName].schema,\n ...extendedSchema,\n };\n }\n }\n // second: execute strapi-server extension\n const strapiServer = get([pluginName, 'strapi-server'], strapiServers);\n if (strapiServer) {\n plugins[pluginName] = await strapiServer(plugin);\n }\n }\n};\n\nconst applyUserConfig = async (plugins: Plugins) => {\n const userPluginsConfig = await getUserPluginsConfig();\n\n for (const pluginName of Object.keys(plugins)) {\n const plugin = plugins[pluginName];\n const userPluginConfig = getOr({}, `${pluginName}.config`, userPluginsConfig);\n const defaultConfig =\n typeof plugin.config.default === 'function'\n ? plugin.config.default({ env })\n : plugin.config.default;\n\n const config = defaultsDeep(defaultConfig, userPluginConfig);\n try {\n plugin.config.validator(config);\n } catch (e) {\n if (e instanceof Error) {\n throw new Error(`Error regarding ${pluginName} config: ${e.message}`);\n }\n\n throw e;\n }\n plugin.config = config;\n }\n};\n\nexport default async function loadPlugins(strapi: Core.Strapi) {\n const plugins: Plugins = {};\n\n const enabledPlugins = await getEnabledPlugins(strapi);\n\n strapi.config.set('enabledPlugins', enabledPlugins);\n\n for (const pluginName of Object.keys(enabledPlugins)) {\n const enabledPlugin = enabledPlugins[pluginName];\n\n let serverEntrypointPath;\n let resolvedExport = './strapi-server.js';\n\n try {\n resolvedExport = (\n resolve.exports(enabledPlugin.packageInfo, 'strapi-server', {\n require: true,\n }) ?? './strapi-server.js'\n ).toString();\n } catch (e) {\n // no export map or missing strapi-server export => fallback to default\n }\n\n try {\n serverEntrypointPath = join(enabledPlugin.pathToPlugin, resolvedExport);\n } catch (e) {\n throw new Error(\n `Error loading the plugin ${pluginName} because ${pluginName} is not installed. Please either install the plugin or remove it's configuration.`\n );\n }\n\n // only load plugins with a server entrypoint\n if (!(await fse.pathExists(serverEntrypointPath))) {\n continue;\n }\n\n const pluginServer = loadConfigFile(serverEntrypointPath);\n plugins[pluginName] = {\n ...defaultPlugin,\n ...pluginServer,\n contentTypes: formatContentTypes(pluginName, pluginServer.contentTypes ?? {}),\n config: defaults(defaultPlugin.config, pluginServer.config),\n routes: pluginServer.routes ?? defaultPlugin.routes,\n };\n }\n\n // TODO: validate plugin format\n await applyUserConfig(plugins);\n await applyUserExtension(plugins);\n\n for (const pluginName of Object.keys(plugins)) {\n strapi.get('plugins').add(pluginName, plugins[pluginName]);\n }\n}\n\nconst formatContentTypes = (\n pluginName: string,\n contentTypes: Record<string, { schema: Struct.ContentTypeSchema }>\n) => {\n Object.values(contentTypes).forEach((definition) => {\n const { schema } = definition;\n\n Object.assign(schema, {\n plugin: pluginName,\n collectionName:\n schema.collectionName || `${pluginName}_${schema.info.singularName}`.toLowerCase(),\n globalId: getGlobalId(schema, pluginName),\n });\n });\n\n return contentTypes;\n};\n"],"names":["defaultPlugin","bootstrap","destroy","register","config","default","validator","routes","controllers","services","policies","middlewares","contentTypes","applyUserExtension","plugins","extensionsDir","strapi","dirs","dist","extensions","fse","pathExists","extendedSchemas","loadFiles","strapiServers","pluginName","Object","keys","plugin","ctName","extendedSchema","get","schema","strapiServer","applyUserConfig","userPluginsConfig","getUserPluginsConfig","userPluginConfig","getOr","defaultConfig","env","defaultsDeep","e","Error","message","loadPlugins","enabledPlugins","getEnabledPlugins","set","enabledPlugin","serverEntrypointPath","resolvedExport","resolve","exports","packageInfo","require","toString","join","pathToPlugin","pluginServer","loadConfigFile","formatContentTypes","defaults","add","values","forEach","definition","assign","collectionName","info","singularName","toLowerCase","globalId","getGlobalId"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,MAAMA,aAAgB,GAAA;IACpBC,SAAa,CAAA,GAAA,EAAA;IACbC,OAAW,CAAA,GAAA,EAAA;IACXC,QAAY,CAAA,GAAA,EAAA;IACZC,MAAQ,EAAA;AACNC,QAAAA,OAAAA,EAAS,EAAC;QACVC,SAAa,CAAA,GAAA;AACf,KAAA;AACAC,IAAAA,MAAAA,EAAQ,EAAE;AACVC,IAAAA,WAAAA,EAAa,EAAC;AACdC,IAAAA,QAAAA,EAAU,EAAC;AACXC,IAAAA,QAAAA,EAAU,EAAC;AACXC,IAAAA,WAAAA,EAAa,EAAC;AACdC,IAAAA,YAAAA,EAAc;AAChB,CAAA;AAEA,MAAMC,qBAAqB,OAAOC,OAAAA,GAAAA;AAChC,IAAA,MAAMC,gBAAgBC,MAAOC,CAAAA,IAAI,C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AAI,CAACb,OAAU,CAAA,CAAA;QAC7CE,OAAOe,CAAAA,GAAG,CAAC,SAAWgC,CAAAA,CAAAA,GAAG,CAACtC,UAAYX,EAAAA,OAAO,CAACW,UAAW,CAAA,CAAA;AAC3D;AACF;AAEA,MAAMoC,kBAAAA,GAAqB,CACzBpC,UACAb,EAAAA,YAAAA,GAAAA;AAEAc,IAAAA,MAAAA,CAAOsC,MAAM,CAACpD,YAAcqD,CAAAA,CAAAA,OAAO,CAAC,CAACC,UAAAA,GAAAA;QACnC,MAAM,EAAElC,MAAM,EAAE,GAAGkC,UAAAA;QAEnBxC,MAAOyC,CAAAA,MAAM,CAACnC,MAAQ,EAAA;YACpBJ,MAAQH,EAAAA,UAAAA;AACR2C,YAAAA,cAAAA,EACEpC,MAAOoC,CAAAA,cAAc,IAAI,CAAC,EAAE3C,UAAW,CAAA,CAAC,EAAEO,MAAAA,CAAOqC,IAAI,CAACC,YAAY,CAAC,CAAC,CAACC,WAAW,EAAA;AAClFC,YAAAA,QAAAA,EAAUC,kBAAYzC,MAAQP,EAAAA,UAAAA;AAChC,SAAA,CAAA;AACF,KAAA,CAAA;IAEA,OAAOb,YAAAA;AACT,CAAA;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/loaders/plugins/index.ts"],"sourcesContent":["import { join } from 'path';\nimport fse from 'fs-extra';\nimport { defaultsDeep, defaults, getOr, get } from 'lodash/fp';\nimport * as resolve from 'resolve.exports';\n\nimport { env } from '@strapi/utils';\nimport type { Core, Plugin, Struct } from '@strapi/types';\nimport { loadConfigFile } from '../../utils/load-config-file';\nimport { loadFiles } from '../../utils/load-files';\nimport { getEnabledPlugins } from './get-enabled-plugins';\nimport { getUserPluginsConfig } from './get-user-plugins-config';\nimport { getGlobalId } from '../../domain/content-type';\n\ninterface Plugins {\n [key: string]: Plugin.LoadedPlugin;\n}\n\nconst defaultPlugin = {\n bootstrap() {},\n destroy() {},\n register() {},\n config: {\n default: {},\n validator() {},\n },\n routes: [],\n controllers: {},\n services: {},\n policies: {},\n middlewares: {},\n contentTypes: {},\n};\n\nconst applyUserExtension = async (plugins: Plugins) => {\n const extensionsDir = strapi.dirs.dist.extensions;\n if (!(await fse.pathExists(extensionsDir))) {\n return;\n }\n\n const extendedSchemas = await loadFiles(extensionsDir, '**/content-types/**/schema.json');\n const strapiServers = await loadFiles(extensionsDir, '**/strapi-server.js');\n\n for (const pluginName of Object.keys(plugins)) {\n const plugin = plugins[pluginName];\n // first: load json schema\n for (const ctName of Object.keys(plugin.contentTypes)) {\n const extendedSchema = get([pluginName, 'content-types', ctName, 'schema'], extendedSchemas);\n if (extendedSchema) {\n plugin.contentTypes[ctName].schema = {\n ...plugin.contentTypes[ctName].schema,\n ...extendedSchema,\n };\n }\n }\n // second: execute strapi-server extension\n const strapiServer = get([pluginName, 'strapi-server'], strapiServers);\n if (strapiServer) {\n plugins[pluginName] = await strapiServer(plugin);\n }\n }\n};\n\nconst applyUserConfig = async (plugins: Plugins) => {\n const userPluginsConfig = await getUserPluginsConfig();\n\n for (const pluginName of Object.keys(plugins)) {\n const plugin = plugins[pluginName];\n const userPluginConfig = getOr({}, `${pluginName}.config`, userPluginsConfig);\n const defaultConfig =\n typeof plugin.config.default === 'function'\n ? plugin.config.default({ env })\n : plugin.config.default;\n\n const config = defaultsDeep(defaultConfig, userPluginConfig);\n try {\n plugin.config.validator(config);\n } catch (e) {\n if (e instanceof Error) {\n throw new Error(`Error regarding ${pluginName} config: ${e.message}`);\n }\n\n throw e;\n }\n plugin.config = config;\n }\n};\n\nexport default async function loadPlugins(strapi: Core.Strapi) {\n const plugins: Plugins = {};\n\n const enabledPlugins = await getEnabledPlugins(strapi);\n\n strapi.config.set('enabledPlugins', enabledPlugins);\n\n for (const pluginName of Object.keys(enabledPlugins)) {\n const enabledPlugin = enabledPlugins[pluginName];\n\n let serverEntrypointPath;\n let resolvedExport = './strapi-server.js';\n\n try {\n resolvedExport = (\n resolve.exports(enabledPlugin.packageInfo, 'strapi-server', {\n require: true,\n }) ?? './strapi-server.js'\n ).toString();\n } catch (e) {\n // no export map or missing strapi-server export => fallback to default\n }\n\n try {\n serverEntrypointPath = join(enabledPlugin.pathToPlugin, resolvedExport);\n } catch (e) {\n throw new Error(\n `Error loading the plugin ${pluginName} because ${pluginName} is not installed. Please either install the plugin or remove its configuration.`\n );\n }\n\n // only load plugins with a server entrypoint\n if (!(await fse.pathExists(serverEntrypointPath))) {\n continue;\n }\n\n const pluginServer = loadConfigFile(serverEntrypointPath);\n plugins[pluginName] = {\n ...defaultPlugin,\n ...pluginServer,\n contentTypes: formatContentTypes(pluginName, pluginServer.contentTypes ?? {}),\n config: defaults(defaultPlugin.config, pluginServer.config),\n routes: pluginServer.routes ?? defaultPlugin.routes,\n };\n }\n\n // TODO: validate plugin format\n await applyUserConfig(plugins);\n await applyUserExtension(plugins);\n\n for (const pluginName of Object.keys(plugins)) {\n strapi.get('plugins').add(pluginName, plugins[pluginName]);\n }\n}\n\nconst formatContentTypes = (\n pluginName: string,\n contentTypes: Record<string, { schema: Struct.ContentTypeSchema }>\n) => {\n Object.values(contentTypes).forEach((definition) => {\n const { schema } = definition;\n\n Object.assign(schema, {\n plugin: pluginName,\n collectionName:\n schema.collectionName || `${pluginName}_${schema.info.singularName}`.toLowerCase(),\n globalId: getGlobalId(schema, pluginName),\n });\n });\n\n return contentTypes;\n};\n"],"names":["defaultPlugin","bootstrap","destroy","register","config","default","validator","routes","controllers","services","policies","middlewares","contentTypes","applyUserExtension","plugins","extensionsDir","strapi","dirs","dist","extensions","fse","pathExists","extendedSchemas","loadFiles","strapiServers","pluginName","Object","keys","plugin","ctName","extendedSchema","get","schema","strapiServer","applyUserConfig","userPluginsConfig","getUserPluginsConfig","userPluginConfig","getOr","defaultConfig","env","defaultsDeep","e","Error","message","loadPlugins","enabledPlugins","getEnabledPlugins","set","enabledPlugin","serverEntrypointPath","resolvedExport","resolve","exports","packageInfo","require","toString","join","pathToPlugin","pluginServer","loadConfigFile","formatContentTypes","defaults","add","values","forEach","definition","assign","collectionName","info","singularName","toLowerCase","globalId","getGlobalId"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,MAAMA,aAAgB,GAAA;IACpBC,SAAa,CAAA,GAAA,EAAA;IACbC,OAAW,CAAA,GAAA,EAAA;IACXC,QAAY,CAAA,GAAA,EAAA;IACZC,MAAQ,EAAA;AACNC,QAAAA,OAAAA,EAAS,EAAC;QACVC,SAAa,CAAA,GAAA;AACf,KAAA;AACAC,IAAAA,MAAAA,EAAQ,EAAE;AACVC,IAAAA,WAAAA,EAAa,EAAC;AACdC,IAAAA,QAAAA,EAAU,EAAC;AACXC,IAAAA,QAAAA,EAAU,EAAC;AACXC,IAAAA,WAAAA,EAAa,EAAC;AACdC,IAAAA,YAAAA,EAAc;AAChB,CAAA;AAEA,MAAMC,qBAAqB,OAAOC,OAAAA,GAAAA;AAChC,IAAA,MAAMC,gBAAgBC,MAAOC,CAAAA,IAAI,CAACC,IAAI,CAACC,UAAU;AACjD,IAAA,IAAI,CAAE,MAAMC,GAAIC,CAAAA,UAAU,CAACN,aAAiB,CAAA,EAAA;AAC1C,QAAA;AACF;IAEA,MAAMO,eAAAA,GAAkB,MAAMC,mBAAAA,CAAUR,aAAe,EAAA,iCAAA,CAAA;IACvD,MAAMS,aAAAA,GAAgB,MAAMD,mBAAAA,CAAUR,aAAe,EAAA,qBAAA,CAAA;AAErD,IAAA,KAAK,MAAMU,UAAAA,IAAcC,MAAOC,CAAAA,IAAI,CAACb,OAAU,CAAA,CAAA;QAC7C,MAAMc,MAAAA,GAASd,OAAO,CAACW,UAAW,CAAA;;AAElC,QAAA,KAAK,MAAMI,MAAUH,IAAAA,MAAAA,CAAOC,IAAI,CAACC,MAAAA,CAAOhB,YAAY,CAAG,CAAA;AACrD,YAAA,MAAMkB,iBAAiBC,MAAI,CAAA;AAACN,gBAAAA,UAAAA;AAAY,gBAAA,eAAA;AAAiBI,gBAAAA,MAAAA;AAAQ,gBAAA;aAAS,EA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,kBAAYzC,MAAQP,EAAAA,UAAAA;AAChC,SAAA,CAAA;AACF,KAAA,CAAA;IAEA,OAAOb,YAAAA;AACT,CAAA;;;;"}
@@ -96,7 +96,7 @@ async function loadPlugins(strapi1) {
96
96
  try {
97
97
  serverEntrypointPath = join(enabledPlugin.pathToPlugin, resolvedExport);
98
98
  } catch (e) {
99
- throw new Error(`Error loading the plugin ${pluginName} because ${pluginName} is not installed. Please either install the plugin or remove it's configuration.`);
99
+ throw new Error(`Error loading the plugin ${pluginName} because ${pluginName} is not installed. Please either install the plugin or remove its configuration.`);
100
100
  }
101
101
  // only load plugins with a server entrypoint
102
102
  if (!await fse.pathExists(serverEntrypointPath)) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../../src/loaders/plugins/index.ts"],"sourcesContent":["import { join } from 'path';\nimport fse from 'fs-extra';\nimport { defaultsDeep, defaults, getOr, get } from 'lodash/fp';\nimport * as resolve from 'resolve.exports';\n\nimport { env } from '@strapi/utils';\nimport type { Core, Plugin, Struct } from '@strapi/types';\nimport { loadConfigFile } from '../../utils/load-config-file';\nimport { loadFiles } from '../../utils/load-files';\nimport { getEnabledPlugins } from './get-enabled-plugins';\nimport { getUserPluginsConfig } from './get-user-plugins-config';\nimport { getGlobalId } from '../../domain/content-type';\n\ninterface Plugins {\n [key: string]: Plugin.LoadedPlugin;\n}\n\nconst defaultPlugin = {\n bootstrap() {},\n destroy() {},\n register() {},\n config: {\n default: {},\n validator() {},\n },\n routes: [],\n controllers: {},\n services: {},\n policies: {},\n middlewares: {},\n contentTypes: {},\n};\n\nconst applyUserExtension = async (plugins: Plugins) => {\n const extensionsDir = strapi.dirs.dist.extensions;\n if (!(await fse.pathExists(extensionsDir))) {\n return;\n }\n\n const extendedSchemas = await loadFiles(extensionsDir, '**/content-types/**/schema.json');\n const strapiServers = await loadFiles(extensionsDir, '**/strapi-server.js');\n\n for (const pluginName of Object.keys(plugins)) {\n const plugin = plugins[pluginName];\n // first: load json schema\n for (const ctName of Object.keys(plugin.contentTypes)) {\n const extendedSchema = get([pluginName, 'content-types', ctName, 'schema'], extendedSchemas);\n if (extendedSchema) {\n plugin.contentTypes[ctName].schema = {\n ...plugin.contentTypes[ctName].schema,\n ...extendedSchema,\n };\n }\n }\n // second: execute strapi-server extension\n const strapiServer = get([pluginName, 'strapi-server'], strapiServers);\n if (strapiServer) {\n plugins[pluginName] = await strapiServer(plugin);\n }\n }\n};\n\nconst applyUserConfig = async (plugins: Plugins) => {\n const userPluginsConfig = await getUserPluginsConfig();\n\n for (const pluginName of Object.keys(plugins)) {\n const plugin = plugins[pluginName];\n const userPluginConfig = getOr({}, `${pluginName}.config`, userPluginsConfig);\n const defaultConfig =\n typeof plugin.config.default === 'function'\n ? plugin.config.default({ env })\n : plugin.config.default;\n\n const config = defaultsDeep(defaultConfig, userPluginConfig);\n try {\n plugin.config.validator(config);\n } catch (e) {\n if (e instanceof Error) {\n throw new Error(`Error regarding ${pluginName} config: ${e.message}`);\n }\n\n throw e;\n }\n plugin.config = config;\n }\n};\n\nexport default async function loadPlugins(strapi: Core.Strapi) {\n const plugins: Plugins = {};\n\n const enabledPlugins = await getEnabledPlugins(strapi);\n\n strapi.config.set('enabledPlugins', enabledPlugins);\n\n for (const pluginName of Object.keys(enabledPlugins)) {\n const enabledPlugin = enabledPlugins[pluginName];\n\n let serverEntrypointPath;\n let resolvedExport = './strapi-server.js';\n\n try {\n resolvedExport = (\n resolve.exports(enabledPlugin.packageInfo, 'strapi-server', {\n require: true,\n }) ?? './strapi-server.js'\n ).toString();\n } catch (e) {\n // no export map or missing strapi-server export => fallback to default\n }\n\n try {\n serverEntrypointPath = join(enabledPlugin.pathToPlugin, resolvedExport);\n } catch (e) {\n throw new Error(\n `Error loading the plugin ${pluginName} because ${pluginName} is not installed. Please either install the plugin or remove it's configuration.`\n );\n }\n\n // only load plugins with a server entrypoint\n if (!(await fse.pathExists(serverEntrypointPath))) {\n continue;\n }\n\n const pluginServer = loadConfigFile(serverEntrypointPath);\n plugins[pluginName] = {\n ...defaultPlugin,\n ...pluginServer,\n contentTypes: formatContentTypes(pluginName, pluginServer.contentTypes ?? {}),\n config: defaults(defaultPlugin.config, pluginServer.config),\n routes: pluginServer.routes ?? defaultPlugin.routes,\n };\n }\n\n // TODO: validate plugin format\n await applyUserConfig(plugins);\n await applyUserExtension(plugins);\n\n for (const pluginName of Object.keys(plugins)) {\n strapi.get('plugins').add(pluginName, plugins[pluginName]);\n }\n}\n\nconst formatContentTypes = (\n pluginName: string,\n contentTypes: Record<string, { schema: Struct.ContentTypeSchema }>\n) => {\n Object.values(contentTypes).forEach((definition) => {\n const { schema } = definition;\n\n Object.assign(schema, {\n plugin: pluginName,\n collectionName:\n schema.collectionName || `${pluginName}_${schema.info.singularName}`.toLowerCase(),\n globalId: getGlobalId(schema, pluginName),\n });\n });\n\n return contentTypes;\n};\n"],"names":["defaultPlugin","bootstrap","destroy","register","config","default","validator","routes","controllers","services","policies","middlewares","contentTypes","applyUserExtension","plugins","extensionsDir","strapi","dirs","dist","extensions","fse","pathExists","extendedSchemas","loadFiles","strapiServers","pluginName","Object","keys","plugin","ctName","extendedSchema","get","schema","strapiServer","applyUserConfig","userPluginsConfig","getUserPluginsConfig","userPluginConfig","getOr","defaultConfig","env","defaultsDeep","e","Error","message","loadPlugins","enabledPlugins","getEnabledPlugins","set","enabledPlugin","serverEntrypointPath","resolvedExport","resolve","exports","packageInfo","require","toString","join","pathToPlugin","pluginServer","loadConfigFile","formatContentTypes","defaults","add","values","forEach","definition","assign","collectionName","info","singularName","toLowerCase","globalId","getGlobalId"],"mappings":";;;;;;;;;;;AAiBA,MAAMA,aAAgB,GAAA;IACpBC,SAAa,CAAA,GAAA,EAAA;IACbC,OAAW,CAAA,GAAA,EAAA;IACXC,QAAY,CAAA,GAAA,EAAA;IACZC,MAAQ,EAAA;AACNC,QAAAA,OAAAA,EAAS,EAAC;QACVC,SAAa,CAAA,GAAA;AACf,KAAA;AACAC,IAAAA,MAAAA,EAAQ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MAAM,CAAA;AAC1DG,YAAAA,MAAAA,EAAQoD,YAAapD,CAAAA,MAAM,IAAIP,aAAAA,CAAcO;AAC/C,SAAA;AACF;;AAGA,IAAA,MAAM2B,eAAgBpB,CAAAA,OAAAA,CAAAA;AACtB,IAAA,MAAMD,kBAAmBC,CAAAA,OAAAA,CAAAA;AAEzB,IAAA,KAAK,MAAMW,UAAAA,IAAcC,MAAOC,CAAAA,IAAI,CAACb,OAAU,CAAA,CAAA;QAC7CE,OAAOe,CAAAA,GAAG,CAAC,SAAWgC,CAAAA,CAAAA,GAAG,CAACtC,UAAYX,EAAAA,OAAO,CAACW,UAAW,CAAA,CAAA;AAC3D;AACF;AAEA,MAAMoC,kBAAAA,GAAqB,CACzBpC,UACAb,EAAAA,YAAAA,GAAAA;AAEAc,IAAAA,MAAAA,CAAOsC,MAAM,CAACpD,YAAcqD,CAAAA,CAAAA,OAAO,CAAC,CAACC,UAAAA,GAAAA;QACnC,MAAM,EAAElC,MAAM,EAAE,GAAGkC,UAAAA;QAEnBxC,MAAOyC,CAAAA,MAAM,CAACnC,MAAQ,EAAA;YACpBJ,MAAQH,EAAAA,UAAAA;AACR2C,YAAAA,cAAAA,EACEpC,MAAOoC,CAAAA,cAAc,IAAI,CAAC,EAAE3C,UAAW,CAAA,CAAC,EAAEO,MAAAA,CAAOqC,IAAI,CAACC,YAAY,CAAC,CAAC,CAACC,WAAW,EAAA;AAClFC,YAAAA,QAAAA,EAAUC,YAAYzC,MAAQP,EAAAA,UAAAA;AAChC,SAAA,CAAA;AACF,KAAA,CAAA;IAEA,OAAOb,YAAAA;AACT,CAAA;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":["../../../src/loaders/plugins/index.ts"],"sourcesContent":["import { join } from 'path';\nimport fse from 'fs-extra';\nimport { defaultsDeep, defaults, getOr, get } from 'lodash/fp';\nimport * as resolve from 'resolve.exports';\n\nimport { env } from '@strapi/utils';\nimport type { Core, Plugin, Struct } from '@strapi/types';\nimport { loadConfigFile } from '../../utils/load-config-file';\nimport { loadFiles } from '../../utils/load-files';\nimport { getEnabledPlugins } from './get-enabled-plugins';\nimport { getUserPluginsConfig } from './get-user-plugins-config';\nimport { getGlobalId } from '../../domain/content-type';\n\ninterface Plugins {\n [key: string]: Plugin.LoadedPlugin;\n}\n\nconst defaultPlugin = {\n bootstrap() {},\n destroy() {},\n register() {},\n config: {\n default: {},\n validator() {},\n },\n routes: [],\n controllers: {},\n services: {},\n policies: {},\n middlewares: {},\n contentTypes: {},\n};\n\nconst applyUserExtension = async (plugins: Plugins) => {\n const extensionsDir = strapi.dirs.dist.extensions;\n if (!(await fse.pathExists(extensionsDir))) {\n return;\n }\n\n const extendedSchemas = await loadFiles(extensionsDir, '**/content-types/**/schema.json');\n const strapiServers = await loadFiles(extensionsDir, '**/strapi-server.js');\n\n for (const pluginName of Object.keys(plugins)) {\n const plugin = plugins[pluginName];\n // first: load json schema\n for (const ctName of Object.keys(plugin.contentTypes)) {\n const extendedSchema = get([pluginName, 'content-types', ctName, 'schema'], extendedSchemas);\n if (extendedSchema) {\n plugin.contentTypes[ctName].schema = {\n ...plugin.contentTypes[ctName].schema,\n ...extendedSchema,\n };\n }\n }\n // second: execute strapi-server extension\n const strapiServer = get([pluginName, 'strapi-server'], strapiServers);\n if (strapiServer) {\n plugins[pluginName] = await strapiServer(plugin);\n }\n }\n};\n\nconst applyUserConfig = async (plugins: Plugins) => {\n const userPluginsConfig = await getUserPluginsConfig();\n\n for (const pluginName of Object.keys(plugins)) {\n const plugin = plugins[pluginName];\n const userPluginConfig = getOr({}, `${pluginName}.config`, userPluginsConfig);\n const defaultConfig =\n typeof plugin.config.default === 'function'\n ? plugin.config.default({ env })\n : plugin.config.default;\n\n const config = defaultsDeep(defaultConfig, userPluginConfig);\n try {\n plugin.config.validator(config);\n } catch (e) {\n if (e instanceof Error) {\n throw new Error(`Error regarding ${pluginName} config: ${e.message}`);\n }\n\n throw e;\n }\n plugin.config = config;\n }\n};\n\nexport default async function loadPlugins(strapi: Core.Strapi) {\n const plugins: Plugins = {};\n\n const enabledPlugins = await getEnabledPlugins(strapi);\n\n strapi.config.set('enabledPlugins', enabledPlugins);\n\n for (const pluginName of Object.keys(enabledPlugins)) {\n const enabledPlugin = enabledPlugins[pluginName];\n\n let serverEntrypointPath;\n let resolvedExport = './strapi-server.js';\n\n try {\n resolvedExport = (\n resolve.exports(enabledPlugin.packageInfo, 'strapi-server', {\n require: true,\n }) ?? './strapi-server.js'\n ).toString();\n } catch (e) {\n // no export map or missing strapi-server export => fallback to default\n }\n\n try {\n serverEntrypointPath = join(enabledPlugin.pathToPlugin, resolvedExport);\n } catch (e) {\n throw new Error(\n `Error loading the plugin ${pluginName} because ${pluginName} is not installed. Please either install the plugin or remove its configuration.`\n );\n }\n\n // only load plugins with a server entrypoint\n if (!(await fse.pathExists(serverEntrypointPath))) {\n continue;\n }\n\n const pluginServer = loadConfigFile(serverEntrypointPath);\n plugins[pluginName] = {\n ...defaultPlugin,\n ...pluginServer,\n contentTypes: formatContentTypes(pluginName, pluginServer.contentTypes ?? {}),\n config: defaults(defaultPlugin.config, pluginServer.config),\n routes: pluginServer.routes ?? defaultPlugin.routes,\n };\n }\n\n // TODO: validate plugin format\n await applyUserConfig(plugins);\n await applyUserExtension(plugins);\n\n for (const pluginName of Object.keys(plugins)) {\n strapi.get('plugins').add(pluginName, plugins[pluginName]);\n }\n}\n\nconst formatContentTypes = (\n pluginName: string,\n contentTypes: Record<string, { schema: Struct.ContentTypeSchema }>\n) => {\n Object.values(contentTypes).forEach((definition) => {\n const { schema } = definition;\n\n Object.assign(schema, {\n plugin: pluginName,\n collectionName:\n schema.collectionName || `${pluginName}_${schema.info.singularName}`.toLowerCase(),\n globalId: getGlobalId(schema, pluginName),\n });\n });\n\n return contentTypes;\n};\n"],"names":["defaultPlugin","bootstrap","destroy","register","config","default","validator","routes","controllers","services","policies","middlewares","contentTypes","applyUserExtension","plugins","extensionsDir","strapi","dirs","dist","extensions","fse","pathExists","extendedSchemas","loadFiles","strapiServers","pluginName","Object","keys","plugin","ctName","extendedSchema","get","schema","strapiServer","applyUserConfig","userPluginsConfig","getUserPluginsConfig","userPluginConfig","getOr","defaultConfig","env","defaultsDeep","e","Error","message","loadPlugins","enabledPlugins","getEnabledPlugins","set","enabledPlugin","serverEntrypointPath","resolvedExport","resolve","exports","packageInfo","require","toString","join","pathToPlugin","pluginServer","loadConfigFile","formatContentTypes","defaults","add","values","forEach","definition","assign","collectionName","info","singularName","toLowerCase","globalId","getGlobalId"],"mappings":";;;;;;;;;;;AAiBA,MAAMA,aAAgB,GAAA;IACpBC,SAAa,CAAA,GAAA,EAAA;IACbC,OAAW,CAAA,GAAA,EAAA;IACXC,QAAY,CAAA,GAAA,EAAA;IACZC,MAAQ,EAAA;AACNC,QAAAA,OAAAA,EAAS,EAAC;QACVC,SAAa,CAAA,GAAA;AACf,KAAA;AACAC,IAAAA,MAAAA,EAAQ,EAAE;AACVC,IAAAA,WAAAA,EAAa,EAAC;AACdC,IAAAA,QAAAA,EAAU,EAAC;AACXC,IAAAA,QAAAA,EAAU,EAAC;AACXC,IAAAA,WAAAA,EAAa,EAAC;AACdC,IAAAA,YAAAA,EAAc;AAChB,CAAA;AAEA,MAAMC,qBAAqB,OAAOC,OAAAA,GAAAA;AAChC,IAAA,MAAMC,gBAAgBC,MAAOC,CAAAA,IAAI,CAACC,IAAI,CAACC,UAAU;AACjD,IAAA,IAAI,CAAE,MAAMC,GAAIC,CAAAA,UAAU,CAACN,aAAiB,CAAA,EAAA;AAC1C,QAAA;AACF;IAEA,MAAMO,eAAAA,GAAkB,MAAMC,SAAAA,CAAUR,aAAe,EAAA,iCAAA,CAAA;IACvD,MAAMS,aAAAA,GAAgB,MAAMD,SAAAA,CAAUR,aAAe,EAAA,qBAAA,CAAA;AAErD,IAAA,KAAK,MAAMU,UAAAA,IAAcC,MAAOC,CAAAA,IAAI,CAACb,OAAU,CAAA,CAAA;QAC7C,MAAMc,MAAAA,GAASd,OAAO,CAACW,UAAW,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,MAAQ,EAAA;YACpBJ,MAAQH,EAAAA,UAAAA;AACR2C,YAAAA,cAAAA,EACEpC,MAAOoC,CAAAA,cAAc,IAAI,CAAC,EAAE3C,UAAW,CAAA,CAAC,EAAEO,MAAAA,CAAOqC,IAAI,CAACC,YAAY,CAAC,CAAC,CAACC,WAAW,EAAA;AAClFC,YAAAA,QAAAA,EAAUC,YAAYzC,MAAQP,EAAAA,UAAAA;AAChC,SAAA,CAAA;AACF,KAAA,CAAA;IAEA,OAAOb,YAAAA;AACT,CAAA;;;;"}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var name = "@strapi/core";
6
- var version = "5.23.2";
6
+ var version = "5.23.4";
7
7
  var description = "Core of Strapi";
8
8
  var homepage = "https://strapi.io";
9
9
  var bugs = {
@@ -59,14 +59,14 @@ var dependencies = {
59
59
  "@koa/cors": "5.0.0",
60
60
  "@koa/router": "12.0.2",
61
61
  "@paralleldrive/cuid2": "2.2.2",
62
- "@strapi/admin": "5.23.2",
63
- "@strapi/database": "5.23.2",
64
- "@strapi/generators": "5.23.2",
65
- "@strapi/logger": "5.23.2",
66
- "@strapi/permissions": "5.23.2",
67
- "@strapi/types": "5.23.2",
68
- "@strapi/typescript-utils": "5.23.2",
69
- "@strapi/utils": "5.23.2",
62
+ "@strapi/admin": "5.23.4",
63
+ "@strapi/database": "5.23.4",
64
+ "@strapi/generators": "5.23.4",
65
+ "@strapi/logger": "5.23.4",
66
+ "@strapi/permissions": "5.23.4",
67
+ "@strapi/types": "5.23.4",
68
+ "@strapi/typescript-utils": "5.23.4",
69
+ "@strapi/utils": "5.23.4",
70
70
  "@vercel/stega": "0.1.2",
71
71
  bcryptjs: "2.4.3",
72
72
  boxen: "5.1.2",
@@ -133,9 +133,9 @@ var devDependencies = {
133
133
  "@types/node": "18.19.24",
134
134
  "@types/node-schedule": "2.1.7",
135
135
  "@types/statuses": "2.0.1",
136
- "eslint-config-custom": "5.23.2",
136
+ "eslint-config-custom": "5.23.4",
137
137
  supertest: "6.3.3",
138
- tsconfig: "5.23.2"
138
+ tsconfig: "5.23.4"
139
139
  };
140
140
  var engines = {
141
141
  node: ">=18.0.0 <=22.x.x",
@@ -1,5 +1,5 @@
1
1
  var name = "@strapi/core";
2
- var version = "5.23.2";
2
+ var version = "5.23.4";
3
3
  var description = "Core of Strapi";
4
4
  var homepage = "https://strapi.io";
5
5
  var bugs = {
@@ -55,14 +55,14 @@ var dependencies = {
55
55
  "@koa/cors": "5.0.0",
56
56
  "@koa/router": "12.0.2",
57
57
  "@paralleldrive/cuid2": "2.2.2",
58
- "@strapi/admin": "5.23.2",
59
- "@strapi/database": "5.23.2",
60
- "@strapi/generators": "5.23.2",
61
- "@strapi/logger": "5.23.2",
62
- "@strapi/permissions": "5.23.2",
63
- "@strapi/types": "5.23.2",
64
- "@strapi/typescript-utils": "5.23.2",
65
- "@strapi/utils": "5.23.2",
58
+ "@strapi/admin": "5.23.4",
59
+ "@strapi/database": "5.23.4",
60
+ "@strapi/generators": "5.23.4",
61
+ "@strapi/logger": "5.23.4",
62
+ "@strapi/permissions": "5.23.4",
63
+ "@strapi/types": "5.23.4",
64
+ "@strapi/typescript-utils": "5.23.4",
65
+ "@strapi/utils": "5.23.4",
66
66
  "@vercel/stega": "0.1.2",
67
67
  bcryptjs: "2.4.3",
68
68
  boxen: "5.1.2",
@@ -129,9 +129,9 @@ var devDependencies = {
129
129
  "@types/node": "18.19.24",
130
130
  "@types/node-schedule": "2.1.7",
131
131
  "@types/statuses": "2.0.1",
132
- "eslint-config-custom": "5.23.2",
132
+ "eslint-config-custom": "5.23.4",
133
133
  supertest: "6.3.3",
134
- tsconfig: "5.23.2"
134
+ tsconfig: "5.23.4"
135
135
  };
136
136
  var engines = {
137
137
  node: ">=18.0.0 <=22.x.x",
@@ -1,10 +1,11 @@
1
1
  import type { Core, Struct } from '@strapi/types';
2
+ import type { FieldContentSourceMap } from '@strapi/admin/strapi-admin';
2
3
  interface EncodingInfo {
3
4
  data: any;
4
5
  schema: Struct.Schema;
5
6
  }
6
7
  declare const createContentSourceMapsService: (strapi: Core.Strapi) => {
7
- encodeField(text: string, key: string): string;
8
+ encodeField(text: string, { kind, model, documentId, type, path, locale }: FieldContentSourceMap): string;
8
9
  encodeEntry({ data, schema }: EncodingInfo): Promise<any>;
9
10
  encodeSourceMaps({ data, schema }: EncodingInfo): Promise<any>;
10
11
  };
@@ -1 +1 @@
1
- {"version":3,"file":"content-source-maps.d.ts","sourceRoot":"","sources":["../../src/services/content-source-maps.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,EAAO,MAAM,eAAe,CAAC;AAyCvD,UAAU,YAAY;IACpB,IAAI,EAAE,GAAG,CAAC;IACV,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC;CACvB;AAMD,QAAA,MAAM,8BAA8B,WAAY,KAAK,MAAM;sBAErC,MAAM,OAAO,MAAM,GAAG,MAAM;kCAQV,YAAY,GAAG,QAAQ,GAAG,CAAC;uCAuBtB,YAAY,GAAG,QAAQ,GAAG,CAAC;CAmBvE,CAAC;AAEF,OAAO,EAAE,8BAA8B,EAAE,CAAC"}
1
+ {"version":3,"file":"content-source-maps.d.ts","sourceRoot":"","sources":["../../src/services/content-source-maps.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,EAAO,MAAM,eAAe,CAAC;AAEvD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAwCxE,UAAU,YAAY;IACpB,IAAI,EAAE,GAAG,CAAC;IACV,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC;CACvB;AAMD,QAAA,MAAM,8BAA8B,WAAY,KAAK,MAAM;sBAG/C,MAAM,mDACqC,qBAAqB;kCAyBpC,YAAY,GAAG,QAAQ,GAAG,CAAC;uCAiCtB,YAAY,GAAG,QAAQ,GAAG,CAAC;CAmBvE,CAAC;AAEF,OAAO,EAAE,8BAA8B,EAAE,CAAC"}
@@ -36,23 +36,45 @@ const isObject = (value)=>{
36
36
  };
37
37
  const createContentSourceMapsService = (strapi)=>{
38
38
  return {
39
- encodeField (text, key) {
40
- const res = stega.vercelStegaCombine(text, {
41
- // TODO: smarter metadata than just the key
42
- key
39
+ encodeField (text, { kind, model, documentId, type, path, locale }) {
40
+ /**
41
+ * Combine all metadata into into a one string so we only have to deal with one data-atribute
42
+ * on the frontend. Make it human readable because that data-attribute may be set manually by
43
+ * users for fields that don't support sourcemap encoding.
44
+ */ const strapiSource = new URLSearchParams();
45
+ strapiSource.set('documentId', documentId);
46
+ strapiSource.set('type', type);
47
+ strapiSource.set('path', path);
48
+ if (model) {
49
+ strapiSource.set('model', model);
50
+ }
51
+ if (kind) {
52
+ strapiSource.set('kind', kind);
53
+ }
54
+ if (locale) {
55
+ strapiSource.set('locale', locale);
56
+ }
57
+ return stega.vercelStegaCombine(text, {
58
+ strapiSource: strapiSource.toString()
43
59
  });
44
- return res;
45
60
  },
46
61
  async encodeEntry ({ data, schema }) {
47
62
  if (!isObject(data) || data === undefined) {
48
63
  return data;
49
64
  }
50
- return strapiUtils.traverseEntity(({ key, value, attribute }, { set })=>{
65
+ return strapiUtils.traverseEntity(({ key, value, attribute, schema, path }, { set })=>{
51
66
  if (!attribute || EXCLUDED_FIELDS.includes(key)) {
52
67
  return;
53
68
  }
54
69
  if (ENCODABLE_TYPES.includes(attribute.type) && typeof value === 'string') {
55
- set(key, this.encodeField(value, key));
70
+ set(key, this.encodeField(value, {
71
+ path: path.rawWithIndices,
72
+ type: attribute.type,
73
+ kind: schema.kind,
74
+ model: schema.uid,
75
+ locale: data.locale,
76
+ documentId: data.documentId
77
+ }));
56
78
  }
57
79
  }, {
58
80
  schema,
@@ -1 +1 @@
1
- {"version":3,"file":"content-source-maps.js","sources":["../../src/services/content-source-maps.ts"],"sourcesContent":["import { vercelStegaCombine } from '@vercel/stega';\nimport type { Core, Struct, UID } from '@strapi/types';\nimport { traverseEntity } from '@strapi/utils';\n\nconst ENCODABLE_TYPES = [\n 'string',\n 'text',\n 'richtext',\n 'biginteger',\n 'date',\n 'time',\n 'datetime',\n 'timestamp',\n 'boolean',\n 'enumeration',\n 'json',\n 'media',\n 'email',\n 'password',\n /**\n * We cannot modify the response shape, so types that aren't based on string cannot be encoded:\n * - json: object\n * - blocks: object, will require a custom implementation in a dedicated PR\n * - integer, float and decimal: number\n * - boolean: boolean (believe it or not)\n * - uid: can be stringified but would mess up URLs\n */\n];\n\n// TODO: use a centralized store for these fields that would be shared with the CM and CTB\nconst EXCLUDED_FIELDS = [\n 'id',\n 'documentId',\n 'locale',\n 'localizations',\n 'created_by',\n 'updated_by',\n 'created_at',\n 'updated_at',\n 'publishedAt',\n];\n\ninterface EncodingInfo {\n data: any;\n schema: Struct.Schema;\n}\n\nconst isObject = (value: unknown): value is Record<string, any> => {\n return typeof value === 'object' && value !== null;\n};\n\nconst createContentSourceMapsService = (strapi: Core.Strapi) => {\n return {\n encodeField(text: string, key: string): string {\n const res = vercelStegaCombine(text, {\n // TODO: smarter metadata than just the key\n key,\n });\n return res;\n },\n\n async encodeEntry({ data, schema }: EncodingInfo): Promise<any> {\n if (!isObject(data) || data === undefined) {\n return data;\n }\n\n return traverseEntity(\n ({ key, value, attribute }, { set }) => {\n if (!attribute || EXCLUDED_FIELDS.includes(key)) {\n return;\n }\n\n if (ENCODABLE_TYPES.includes(attribute.type) && typeof value === 'string') {\n set(key, this.encodeField(value, key) as any);\n }\n },\n {\n schema,\n getModel: (uid) => strapi.getModel(uid as UID.Schema),\n },\n data\n );\n },\n\n async encodeSourceMaps({ data, schema }: EncodingInfo): Promise<any> {\n try {\n if (Array.isArray(data)) {\n return await Promise.all(\n data.map((item) => this.encodeSourceMaps({ data: item, schema }))\n );\n }\n\n if (!isObject(data)) {\n return data;\n }\n\n return await this.encodeEntry({ data, schema });\n } catch (error) {\n strapi.log.error('Error encoding source maps:', error);\n return data;\n }\n },\n };\n};\n\nexport { createContentSourceMapsService };\n"],"names":["ENCODABLE_TYPES","EXCLUDED_FIELDS","isObject","value","createContentSourceMapsService","strapi","encodeField","text","key","res","vercelStegaCombine","encodeEntry","data","schema","undefined","traverseEntity","attribute","set","includes","type","getModel","uid","encodeSourceMaps","Array","isArray","Promise","all","map","item","error","log"],"mappings":";;;;;AAIA,MAAMA,eAAkB,GAAA;AACtB,IAAA,QAAA;AACA,IAAA,MAAA;AACA,IAAA,UAAA;AACA,IAAA,YAAA;AACA,IAAA,MAAA;AACA,IAAA,MAAA;AACA,IAAA,UAAA;AACA,IAAA,WAAA;AACA,IAAA,SAAA;AACA,IAAA,aAAA;AACA,IAAA,MAAA;AACA,IAAA,OAAA;AACA,IAAA,OAAA;AACA,IAAA;AASD,CAAA;AAED;AACA,MAAMC,eAAkB,GAAA;AACtB,IAAA,IAAA;AACA,IAAA,YAAA;AACA,IAAA,QAAA;AACA,IAAA,eAAA;AACA,IAAA,YAAA;AACA,IAAA,YAAA;AACA,IAAA,YAAA;AACA,IAAA,YAAA;AACA,IAAA;AACD,CAAA;AAOD,MAAMC,WAAW,CAACC,KAAAA,GAAAA;IAChB,OAAO,OAAOA,KAAU,KAAA,QAAA,IAAYA,KAAU,KAAA,IAAA;AAChD,CAAA;AAEA,MAAMC,iCAAiC,CAACC,MAAAA,GAAAA;IACtC,OAAO;QACLC,WAAYC,CAAAA,CAAAA,IAAY,EAAEC,GAAW,EAAA;YACnC,MAAMC,GAAAA,GAAMC,yBAAmBH,IAAM,EAAA;;AAEnCC,gBAAAA;AACF,aAAA,CAAA;YACA,OAAOC,GAAAA;AACT,SAAA;AAEA,QAAA,MAAME,WAAY,CAAA,CAAA,EAAEC,IAAI,EAAEC,MAAM,EAAgB,EAAA;AAC9C,YAAA,IAAI,CAACX,QAAAA,CAASU,IAASA,CAAAA,IAAAA,IAAAA,KAASE,SAAW,EAAA;gBACzC,OAAOF,IAAAA;AACT;AAEA,YAAA,OAAOG,0BACL,CAAA,CAAC,EAAEP,GAAG,EAAEL,K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F,KAAA;AACF;;;;"}
1
+ {"version":3,"file":"content-source-maps.js","sources":["../../src/services/content-source-maps.ts"],"sourcesContent":["import { vercelStegaCombine } from '@vercel/stega';\nimport type { Core, Struct, UID } from '@strapi/types';\nimport { traverseEntity } from '@strapi/utils';\nimport type { FieldContentSourceMap } from '@strapi/admin/strapi-admin';\n\nconst ENCODABLE_TYPES = [\n 'string',\n 'text',\n 'richtext',\n 'biginteger',\n 'date',\n 'time',\n 'datetime',\n 'timestamp',\n 'boolean',\n 'enumeration',\n 'json',\n 'media',\n 'email',\n 'password',\n /**\n * We cannot modify the response shape, so types that aren't based on string cannot be encoded:\n * - json: object\n * - blocks: object, will require a custom implementation in a dedicated PR\n * - integer, float and decimal: number\n * - boolean: boolean (believe it or not)\n * - uid: can be stringified but would mess up URLs\n */\n];\n\n// TODO: use a centralized store for these fields that would be shared with the CM and CTB\nconst EXCLUDED_FIELDS = [\n 'id',\n 'documentId',\n 'locale',\n 'localizations',\n 'created_by',\n 'updated_by',\n 'created_at',\n 'updated_at',\n 'publishedAt',\n];\n\ninterface EncodingInfo {\n data: any;\n schema: Struct.Schema;\n}\n\nconst isObject = (value: unknown): value is Record<string, any> => {\n return typeof value === 'object' && value !== null;\n};\n\nconst createContentSourceMapsService = (strapi: Core.Strapi) => {\n return {\n encodeField(\n text: string,\n { kind, model, documentId, type, path, locale }: FieldContentSourceMap\n ) {\n /**\n * Combine all metadata into into a one string so we only have to deal with one data-atribute\n * on the frontend. Make it human readable because that data-attribute may be set manually by\n * users for fields that don't support sourcemap encoding.\n */\n const strapiSource = new URLSearchParams();\n strapiSource.set('documentId', documentId);\n strapiSource.set('type', type);\n strapiSource.set('path', path);\n\n if (model) {\n strapiSource.set('model', model);\n }\n if (kind) {\n strapiSource.set('kind', kind);\n }\n if (locale) {\n strapiSource.set('locale', locale);\n }\n\n return vercelStegaCombine(text, { strapiSource: strapiSource.toString() });\n },\n\n async encodeEntry({ data, schema }: EncodingInfo): Promise<any> {\n if (!isObject(data) || data === undefined) {\n return data;\n }\n\n return traverseEntity(\n ({ key, value, attribute, schema, path }, { set }) => {\n if (!attribute || EXCLUDED_FIELDS.includes(key)) {\n return;\n }\n\n if (ENCODABLE_TYPES.includes(attribute.type) && typeof value === 'string') {\n set(\n key,\n this.encodeField(value, {\n path: path.rawWithIndices!,\n type: attribute.type,\n kind: schema.kind,\n model: schema.uid as UID.Schema,\n locale: data.locale,\n documentId: data.documentId,\n }) as any\n );\n }\n },\n {\n schema,\n getModel: (uid) => strapi.getModel(uid as UID.Schema),\n },\n data\n );\n },\n\n async encodeSourceMaps({ data, schema }: EncodingInfo): Promise<any> {\n try {\n if (Array.isArray(data)) {\n return await Promise.all(\n data.map((item) => this.encodeSourceMaps({ data: item, schema }))\n );\n }\n\n if (!isObject(data)) {\n return data;\n }\n\n return await this.encodeEntry({ data, schema });\n } catch (error) {\n strapi.log.error('Error encoding source maps:', error);\n return data;\n }\n },\n };\n};\n\nexport { createContentSourceMapsService };\n"],"names":["ENCODABLE_TYPES","EXCLUDED_FIELDS","isObject","value","createContentSourceMapsService","strapi","encodeField","text","kind","model","documentId","type","path","locale","strapiSource","URLSearchParams","set","vercelStegaCombine","toString","encodeEntry","data","schema","undefined","traverseEntity","key","attribute","includes","rawWithIndices","uid","getModel","encodeSourceMaps","Array","isArray","Promise","all","map","item","error","log"],"mappings":";;;;;AAKA,MAAMA,eAAkB,GAAA;AACtB,IAAA,QAAA;AACA,IAAA,MAAA;AACA,IAAA,UAAA;AACA,IAAA,YAAA;AACA,IAAA,MAAA;AACA,IAAA,MAAA;AACA,IAAA,UAAA;AACA,IAAA,WAAA;AACA,IAAA,SAAA;AACA,IAAA,aAAA;AACA,IAAA,MAAA;AACA,IAAA,OAAA;AACA,IAAA,OAAA;AACA,IAAA;AASD,CAAA;AAED;AACA,MAAMC,eAAkB,GAAA;AACtB,IAAA,IAAA;AACA,IAAA,YAAA;AACA,IAAA,QAAA;AACA,IAAA,eAAA;AACA,IAAA,YAAA;AACA,IAA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