@strapi/content-manager 5.46.0 → 5.47.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.
Files changed (197) hide show
  1. package/dist/admin/constants/hooks.js +5 -0
  2. package/dist/admin/constants/hooks.js.map +1 -1
  3. package/dist/admin/constants/hooks.mjs +5 -0
  4. package/dist/admin/constants/hooks.mjs.map +1 -1
  5. package/dist/admin/history/components/VersionInputRenderer.js +64 -26
  6. package/dist/admin/history/components/VersionInputRenderer.js.map +1 -1
  7. package/dist/admin/history/components/VersionInputRenderer.mjs +63 -27
  8. package/dist/admin/history/components/VersionInputRenderer.mjs.map +1 -1
  9. package/dist/admin/pages/ComponentConfigurationPage.js +2 -45
  10. package/dist/admin/pages/ComponentConfigurationPage.js.map +1 -1
  11. package/dist/admin/pages/ComponentConfigurationPage.mjs +3 -46
  12. package/dist/admin/pages/ComponentConfigurationPage.mjs.map +1 -1
  13. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js +4 -4
  14. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js.map +1 -1
  15. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs +4 -4
  16. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs.map +1 -1
  17. package/dist/admin/pages/ListConfiguration/ListConfigurationPage.js +11 -3
  18. package/dist/admin/pages/ListConfiguration/ListConfigurationPage.js.map +1 -1
  19. package/dist/admin/pages/ListConfiguration/ListConfigurationPage.mjs +11 -3
  20. package/dist/admin/pages/ListConfiguration/ListConfigurationPage.mjs.map +1 -1
  21. package/dist/admin/pages/ListView/ListViewPage.js +1 -0
  22. package/dist/admin/pages/ListView/ListViewPage.js.map +1 -1
  23. package/dist/admin/pages/ListView/ListViewPage.mjs +1 -0
  24. package/dist/admin/pages/ListView/ListViewPage.mjs.map +1 -1
  25. package/dist/admin/pages/ListView/components/Filters.js +38 -4
  26. package/dist/admin/pages/ListView/components/Filters.js.map +1 -1
  27. package/dist/admin/pages/ListView/components/Filters.mjs +39 -5
  28. package/dist/admin/pages/ListView/components/Filters.mjs.map +1 -1
  29. package/dist/admin/pages/formatComponentConfigurationEditLayout.js +58 -0
  30. package/dist/admin/pages/formatComponentConfigurationEditLayout.js.map +1 -0
  31. package/dist/admin/pages/formatComponentConfigurationEditLayout.mjs +56 -0
  32. package/dist/admin/pages/formatComponentConfigurationEditLayout.mjs.map +1 -0
  33. package/dist/admin/src/constants/hooks.d.ts +23 -0
  34. package/dist/admin/src/exports.d.ts +1 -0
  35. package/dist/admin/src/history/components/VersionInputRenderer.d.ts +27 -1
  36. package/dist/admin/src/pages/EditView/components/FormInputs/Relations/Relations.d.ts +9 -5
  37. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/EditorLayout.d.ts +4 -2
  38. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygStyles.d.ts +38 -6
  39. package/dist/admin/src/pages/EditView/components/FormLayout.d.ts +27 -5
  40. package/dist/admin/src/pages/ListView/components/Filters.d.ts +3 -4
  41. package/dist/admin/src/pages/formatComponentConfigurationEditLayout.d.ts +15 -0
  42. package/dist/admin/translations/cs.json.js +0 -1
  43. package/dist/admin/translations/cs.json.js.map +1 -1
  44. package/dist/admin/translations/cs.json.mjs +0 -1
  45. package/dist/admin/translations/cs.json.mjs.map +1 -1
  46. package/dist/admin/translations/de.json.js +0 -1
  47. package/dist/admin/translations/de.json.js.map +1 -1
  48. package/dist/admin/translations/de.json.mjs +0 -1
  49. package/dist/admin/translations/de.json.mjs.map +1 -1
  50. package/dist/admin/translations/en.json.js +0 -1
  51. package/dist/admin/translations/en.json.js.map +1 -1
  52. package/dist/admin/translations/en.json.mjs +0 -1
  53. package/dist/admin/translations/en.json.mjs.map +1 -1
  54. package/dist/admin/translations/es.json.js +0 -1
  55. package/dist/admin/translations/es.json.js.map +1 -1
  56. package/dist/admin/translations/es.json.mjs +0 -1
  57. package/dist/admin/translations/es.json.mjs.map +1 -1
  58. package/dist/admin/translations/fr.json.js +0 -1
  59. package/dist/admin/translations/fr.json.js.map +1 -1
  60. package/dist/admin/translations/fr.json.mjs +0 -1
  61. package/dist/admin/translations/fr.json.mjs.map +1 -1
  62. package/dist/admin/translations/nl.json.js +0 -1
  63. package/dist/admin/translations/nl.json.js.map +1 -1
  64. package/dist/admin/translations/nl.json.mjs +0 -1
  65. package/dist/admin/translations/nl.json.mjs.map +1 -1
  66. package/dist/admin/translations/pl.json.js +0 -1
  67. package/dist/admin/translations/pl.json.js.map +1 -1
  68. package/dist/admin/translations/pl.json.mjs +0 -1
  69. package/dist/admin/translations/pl.json.mjs.map +1 -1
  70. package/dist/admin/translations/ru.json.js +0 -1
  71. package/dist/admin/translations/ru.json.js.map +1 -1
  72. package/dist/admin/translations/ru.json.mjs +0 -1
  73. package/dist/admin/translations/ru.json.mjs.map +1 -1
  74. package/dist/admin/translations/sk.json.js +175 -9
  75. package/dist/admin/translations/sk.json.js.map +1 -1
  76. package/dist/admin/translations/sk.json.mjs +175 -9
  77. package/dist/admin/translations/sk.json.mjs.map +1 -1
  78. package/dist/admin/translations/uk.json.js +0 -1
  79. package/dist/admin/translations/uk.json.js.map +1 -1
  80. package/dist/admin/translations/uk.json.mjs +0 -1
  81. package/dist/admin/translations/uk.json.mjs.map +1 -1
  82. package/dist/admin/translations/zh-Hans.json.js +0 -1
  83. package/dist/admin/translations/zh-Hans.json.js.map +1 -1
  84. package/dist/admin/translations/zh-Hans.json.mjs +0 -1
  85. package/dist/admin/translations/zh-Hans.json.mjs.map +1 -1
  86. package/dist/server/bootstrap.js +4 -0
  87. package/dist/server/bootstrap.js.map +1 -1
  88. package/dist/server/bootstrap.mjs +4 -0
  89. package/dist/server/bootstrap.mjs.map +1 -1
  90. package/dist/server/controllers/collection-types.js +9 -5
  91. package/dist/server/controllers/collection-types.js.map +1 -1
  92. package/dist/server/controllers/collection-types.mjs +10 -6
  93. package/dist/server/controllers/collection-types.mjs.map +1 -1
  94. package/dist/server/mcp/derive-content-type-mcp-tools.js +524 -0
  95. package/dist/server/mcp/derive-content-type-mcp-tools.js.map +1 -0
  96. package/dist/server/mcp/derive-content-type-mcp-tools.mjs +518 -0
  97. package/dist/server/mcp/derive-content-type-mcp-tools.mjs.map +1 -0
  98. package/dist/server/mcp/handlers/collection-handlers.js +404 -0
  99. package/dist/server/mcp/handlers/collection-handlers.js.map +1 -0
  100. package/dist/server/mcp/handlers/collection-handlers.mjs +395 -0
  101. package/dist/server/mcp/handlers/collection-handlers.mjs.map +1 -0
  102. package/dist/server/mcp/handlers/constants.js +10 -0
  103. package/dist/server/mcp/handlers/constants.js.map +1 -0
  104. package/dist/server/mcp/handlers/constants.mjs +6 -0
  105. package/dist/server/mcp/handlers/constants.mjs.map +1 -0
  106. package/dist/server/mcp/handlers/single-type-handlers.js +344 -0
  107. package/dist/server/mcp/handlers/single-type-handlers.js.map +1 -0
  108. package/dist/server/mcp/handlers/single-type-handlers.mjs +336 -0
  109. package/dist/server/mcp/handlers/single-type-handlers.mjs.map +1 -0
  110. package/dist/server/mcp/permissions.js +138 -0
  111. package/dist/server/mcp/permissions.js.map +1 -0
  112. package/dist/server/mcp/permissions.mjs +131 -0
  113. package/dist/server/mcp/permissions.mjs.map +1 -0
  114. package/dist/server/mcp/register-content-manager-mcp-tools.js +30 -0
  115. package/dist/server/mcp/register-content-manager-mcp-tools.js.map +1 -0
  116. package/dist/server/mcp/register-content-manager-mcp-tools.mjs +28 -0
  117. package/dist/server/mcp/register-content-manager-mcp-tools.mjs.map +1 -0
  118. package/dist/server/mcp/schemas/blocks-schema.js +124 -0
  119. package/dist/server/mcp/schemas/blocks-schema.js.map +1 -0
  120. package/dist/server/mcp/schemas/blocks-schema.mjs +122 -0
  121. package/dist/server/mcp/schemas/blocks-schema.mjs.map +1 -0
  122. package/dist/server/mcp/schemas/data-schema.js +252 -0
  123. package/dist/server/mcp/schemas/data-schema.js.map +1 -0
  124. package/dist/server/mcp/schemas/data-schema.mjs +248 -0
  125. package/dist/server/mcp/schemas/data-schema.mjs.map +1 -0
  126. package/dist/server/mcp/schemas/filters-schema.js +111 -0
  127. package/dist/server/mcp/schemas/filters-schema.js.map +1 -0
  128. package/dist/server/mcp/schemas/filters-schema.mjs +107 -0
  129. package/dist/server/mcp/schemas/filters-schema.mjs.map +1 -0
  130. package/dist/server/mcp/schemas/input-schemas.js +18 -0
  131. package/dist/server/mcp/schemas/input-schemas.js.map +1 -0
  132. package/dist/server/mcp/schemas/input-schemas.mjs +13 -0
  133. package/dist/server/mcp/schemas/input-schemas.mjs.map +1 -0
  134. package/dist/server/mcp/schemas/output-schemas.js +48 -0
  135. package/dist/server/mcp/schemas/output-schemas.js.map +1 -0
  136. package/dist/server/mcp/schemas/output-schemas.mjs +44 -0
  137. package/dist/server/mcp/schemas/output-schemas.mjs.map +1 -0
  138. package/dist/server/mcp/schemas/sort-schema.js +80 -0
  139. package/dist/server/mcp/schemas/sort-schema.js.map +1 -0
  140. package/dist/server/mcp/schemas/sort-schema.mjs +76 -0
  141. package/dist/server/mcp/schemas/sort-schema.mjs.map +1 -0
  142. package/dist/server/mcp/utils.js +43 -0
  143. package/dist/server/mcp/utils.js.map +1 -0
  144. package/dist/server/mcp/utils.mjs +39 -0
  145. package/dist/server/mcp/utils.mjs.map +1 -0
  146. package/dist/server/services/index.js +1 -1
  147. package/dist/server/services/index.js.map +1 -1
  148. package/dist/server/services/permission-checker.js +4 -1
  149. package/dist/server/services/permission-checker.js.map +1 -1
  150. package/dist/server/services/permission-checker.mjs +1 -1
  151. package/dist/server/services/permission-checker.mjs.map +1 -1
  152. package/dist/server/services/utils/populate.js +3 -3
  153. package/dist/server/services/utils/populate.js.map +1 -1
  154. package/dist/server/services/utils/populate.mjs +3 -3
  155. package/dist/server/services/utils/populate.mjs.map +1 -1
  156. package/dist/server/src/bootstrap.d.ts.map +1 -1
  157. package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
  158. package/dist/server/src/index.d.ts +3 -3
  159. package/dist/server/src/mcp/derive-content-type-mcp-tools.d.ts +12 -0
  160. package/dist/server/src/mcp/derive-content-type-mcp-tools.d.ts.map +1 -0
  161. package/dist/server/src/mcp/handlers/collection-handlers.d.ts +69 -0
  162. package/dist/server/src/mcp/handlers/collection-handlers.d.ts.map +1 -0
  163. package/dist/server/src/mcp/handlers/constants.d.ts +4 -0
  164. package/dist/server/src/mcp/handlers/constants.d.ts.map +1 -0
  165. package/dist/server/src/mcp/handlers/index.d.ts +3 -0
  166. package/dist/server/src/mcp/handlers/index.d.ts.map +1 -0
  167. package/dist/server/src/mcp/handlers/single-type-handlers.d.ts +66 -0
  168. package/dist/server/src/mcp/handlers/single-type-handlers.d.ts.map +1 -0
  169. package/dist/server/src/mcp/permissions.d.ts +49 -0
  170. package/dist/server/src/mcp/permissions.d.ts.map +1 -0
  171. package/dist/server/src/mcp/register-content-manager-mcp-tools.d.ts +8 -0
  172. package/dist/server/src/mcp/register-content-manager-mcp-tools.d.ts.map +1 -0
  173. package/dist/server/src/mcp/schemas/blocks-schema.d.ts +8 -0
  174. package/dist/server/src/mcp/schemas/blocks-schema.d.ts.map +1 -0
  175. package/dist/server/src/mcp/schemas/data-schema.d.ts +36 -0
  176. package/dist/server/src/mcp/schemas/data-schema.d.ts.map +1 -0
  177. package/dist/server/src/mcp/schemas/filters-schema.d.ts +22 -0
  178. package/dist/server/src/mcp/schemas/filters-schema.d.ts.map +1 -0
  179. package/dist/server/src/mcp/schemas/index.d.ts +7 -0
  180. package/dist/server/src/mcp/schemas/index.d.ts.map +1 -0
  181. package/dist/server/src/mcp/schemas/input-schemas.d.ts +10 -0
  182. package/dist/server/src/mcp/schemas/input-schemas.d.ts.map +1 -0
  183. package/dist/server/src/mcp/schemas/output-schemas.d.ts +18 -0
  184. package/dist/server/src/mcp/schemas/output-schemas.d.ts.map +1 -0
  185. package/dist/server/src/mcp/schemas/sort-schema.d.ts +24 -0
  186. package/dist/server/src/mcp/schemas/sort-schema.d.ts.map +1 -0
  187. package/dist/server/src/mcp/types.d.ts +31 -0
  188. package/dist/server/src/mcp/types.d.ts.map +1 -0
  189. package/dist/server/src/mcp/utils.d.ts +21 -0
  190. package/dist/server/src/mcp/utils.d.ts.map +1 -0
  191. package/dist/server/src/services/index.d.ts +3 -3
  192. package/dist/server/src/services/permission-checker.d.ts +13 -3
  193. package/dist/server/src/services/permission-checker.d.ts.map +1 -1
  194. package/dist/server/src/services/utils/configuration/index.d.ts +2 -2
  195. package/dist/server/src/services/utils/configuration/layouts.d.ts +2 -2
  196. package/dist/server/src/services/utils/populate.d.ts.map +1 -1
  197. package/package.json +10 -8
@@ -0,0 +1,111 @@
1
+ 'use strict';
2
+
3
+ var strapiUtils = require('@strapi/utils');
4
+ var sortSchema = require('./sort-schema.js');
5
+
6
+ /**
7
+ * Maps a scalar Strapi attribute type to the appropriate Zod leaf value schema
8
+ * used inside filter operator objects (e.g. { $eq: <value> }).
9
+ */ const attributeTypeToFilterValue = (attr)=>{
10
+ switch(attr.type){
11
+ case 'integer':
12
+ case 'biginteger':
13
+ case 'decimal':
14
+ case 'float':
15
+ return strapiUtils.z.union([
16
+ strapiUtils.z.number(),
17
+ strapiUtils.z.array(strapiUtils.z.number())
18
+ ]);
19
+ case 'boolean':
20
+ return strapiUtils.z.boolean();
21
+ case 'enumeration':
22
+ {
23
+ const enumAttr = attr;
24
+ if (Array.isArray(enumAttr.enum) && enumAttr.enum.length > 0) {
25
+ return strapiUtils.z.union([
26
+ strapiUtils.z.enum(enumAttr.enum),
27
+ strapiUtils.z.array(strapiUtils.z.enum(enumAttr.enum))
28
+ ]);
29
+ }
30
+ return strapiUtils.z.union([
31
+ strapiUtils.z.string(),
32
+ strapiUtils.z.array(strapiUtils.z.string())
33
+ ]);
34
+ }
35
+ default:
36
+ // string, text, richtext, email, password, uid, date, datetime, time, timestamp
37
+ return strapiUtils.z.union([
38
+ strapiUtils.z.string(),
39
+ strapiUtils.z.array(strapiUtils.z.string()),
40
+ strapiUtils.z.null()
41
+ ]);
42
+ }
43
+ };
44
+ /** All supported Strapi filter operators (excludes the experimental `$jsonSupersetOf`). */ const FILTER_OPERATORS = [
45
+ '$eq',
46
+ '$eqi',
47
+ '$ne',
48
+ '$nei',
49
+ '$in',
50
+ '$notIn',
51
+ '$lt',
52
+ '$lte',
53
+ '$gt',
54
+ '$gte',
55
+ '$between',
56
+ '$contains',
57
+ '$notContains',
58
+ '$containsi',
59
+ '$notContainsi',
60
+ '$startsWith',
61
+ '$startsWithi',
62
+ '$endsWith',
63
+ '$endsWithi',
64
+ '$null',
65
+ '$notNull'
66
+ ];
67
+ /**
68
+ * Builds a per-content-type recursive filters Zod schema.
69
+ *
70
+ * Shape:
71
+ * - Logical operators: $and, $or accept an array of filter objects.
72
+ * - Logical operator: $not accepts a single filter object.
73
+ * - Field keys (scalar attrs only): accept either a direct value (implicit $eq)
74
+ * or an operator object { $eq, $contains, $gt, … }.
75
+ *
76
+ * If the model has no scalar attributes, the schema is z.never() (filters not allowed).
77
+ */ const buildFiltersSchema = (attributes, permittedFields)=>{
78
+ const scalarKeys = sortSchema.getScalarAttributeKeys(attributes, permittedFields);
79
+ if (scalarKeys.length === 0) {
80
+ return strapiUtils.z.never();
81
+ }
82
+ // Lazy reference for recursion ($and / $or / $not)
83
+ const filtersSchema = strapiUtils.z.lazy(()=>{
84
+ const fieldShapes = {};
85
+ for (const key of scalarKeys){
86
+ const attr = attributes[key];
87
+ const valueSchema = attributeTypeToFilterValue(attr);
88
+ const operatorObject = strapiUtils.z.object(Object.fromEntries(FILTER_OPERATORS.map((op)=>[
89
+ op,
90
+ valueSchema.optional()
91
+ ])));
92
+ // Field accepts either a direct value (implicit $eq) or operator object
93
+ fieldShapes[key] = strapiUtils.z.union([
94
+ valueSchema,
95
+ operatorObject
96
+ ]).optional();
97
+ }
98
+ return strapiUtils.z.object({
99
+ $and: strapiUtils.z.array(filtersSchema).optional(),
100
+ $or: strapiUtils.z.array(filtersSchema).optional(),
101
+ $not: filtersSchema.optional(),
102
+ ...fieldShapes
103
+ }).strict();
104
+ });
105
+ return filtersSchema.optional().describe(`Filter object. Supports logical operators ($and, $or, $not) and field operators ` + `($eq, $ne, $in, $contains, $gt, $lt, etc.). Valid fields: ${scalarKeys.join(', ')}.`);
106
+ };
107
+
108
+ exports.FILTER_OPERATORS = FILTER_OPERATORS;
109
+ exports.attributeTypeToFilterValue = attributeTypeToFilterValue;
110
+ exports.buildFiltersSchema = buildFiltersSchema;
111
+ //# sourceMappingURL=filters-schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filters-schema.js","sources":["../../../../server/src/mcp/schemas/filters-schema.ts"],"sourcesContent":["import { z } from '@strapi/utils';\nimport type { Schema, Struct } from '@strapi/types';\nimport { getScalarAttributeKeys } from './sort-schema';\n\n/**\n * Maps a scalar Strapi attribute type to the appropriate Zod leaf value schema\n * used inside filter operator objects (e.g. { $eq: <value> }).\n */\nexport const attributeTypeToFilterValue = (attr: Schema.Attribute.AnyAttribute): z.ZodTypeAny => {\n switch (attr.type) {\n case 'integer':\n case 'biginteger':\n case 'decimal':\n case 'float':\n return z.union([z.number(), z.array(z.number())]);\n case 'boolean':\n return z.boolean();\n case 'enumeration': {\n const enumAttr = attr as Schema.Attribute.Enumeration<string[]>;\n if (Array.isArray(enumAttr.enum) && enumAttr.enum.length > 0) {\n return z.union([\n z.enum(enumAttr.enum as [string, ...string[]]),\n z.array(z.enum(enumAttr.enum as [string, ...string[]])),\n ]);\n }\n return z.union([z.string(), z.array(z.string())]);\n }\n default:\n // string, text, richtext, email, password, uid, date, datetime, time, timestamp\n return z.union([z.string(), z.array(z.string()), z.null()]);\n }\n};\n\n/** All supported Strapi filter operators (excludes the experimental `$jsonSupersetOf`). */\nexport const FILTER_OPERATORS = [\n '$eq',\n '$eqi',\n '$ne',\n '$nei',\n '$in',\n '$notIn',\n '$lt',\n '$lte',\n '$gt',\n '$gte',\n '$between',\n '$contains',\n '$notContains',\n '$containsi',\n '$notContainsi',\n '$startsWith',\n '$startsWithi',\n '$endsWith',\n '$endsWithi',\n '$null',\n '$notNull',\n] as const;\n\n/**\n * Builds a per-content-type recursive filters Zod schema.\n *\n * Shape:\n * - Logical operators: $and, $or accept an array of filter objects.\n * - Logical operator: $not accepts a single filter object.\n * - Field keys (scalar attrs only): accept either a direct value (implicit $eq)\n * or an operator object { $eq, $contains, $gt, … }.\n *\n * If the model has no scalar attributes, the schema is z.never() (filters not allowed).\n */\nexport const buildFiltersSchema = (\n attributes: Struct.SchemaAttributes,\n permittedFields?: Set<string> | null\n): z.ZodTypeAny => {\n const scalarKeys = getScalarAttributeKeys(attributes, permittedFields);\n\n if (scalarKeys.length === 0) {\n return z.never();\n }\n\n // Lazy reference for recursion ($and / $or / $not)\n const filtersSchema: z.ZodTypeAny = z.lazy(() => {\n const fieldShapes: Record<string, z.ZodTypeAny> = {};\n\n for (const key of scalarKeys) {\n const attr = attributes[key];\n const valueSchema = attributeTypeToFilterValue(attr);\n const operatorObject = z.object(\n Object.fromEntries(FILTER_OPERATORS.map((op) => [op, valueSchema.optional()]))\n );\n // Field accepts either a direct value (implicit $eq) or operator object\n fieldShapes[key] = z.union([valueSchema, operatorObject]).optional();\n }\n\n return z\n .object({\n $and: z.array(filtersSchema).optional(),\n $or: z.array(filtersSchema).optional(),\n $not: filtersSchema.optional(),\n ...fieldShapes,\n })\n .strict();\n });\n\n return filtersSchema\n .optional()\n .describe(\n `Filter object. Supports logical operators ($and, $or, $not) and field operators ` +\n `($eq, $ne, $in, $contains, $gt, $lt, etc.). Valid fields: ${scalarKeys.join(', ')}.`\n );\n};\n"],"names":["attributeTypeToFilterValue","attr","type","z","union","number","array","boolean","enumAttr","Array","isArray","enum","length","string","null","FILTER_OPERATORS","buildFiltersSchema","attributes","permittedFields","scalarKeys","getScalarAttributeKeys","never","filtersSchema","lazy","fieldShapes","key","valueSchema","operatorObject","object","Object","fromEntries","map","op","optional","$and","$or","$not","strict","describe","join"],"mappings":";;;;;AAIA;;;IAIO,MAAMA,0BAAAA,GAA6B,CAACC,IAAAA,GA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,CAAC;AACNM,YAAAA,IAAAA,EAAM/B,aAAAA,CAAEG,KAAK,CAACgB,aAAAA,CAAAA,CAAeW,QAAQ,EAAA;AACrCE,YAAAA,GAAAA,EAAKhC,aAAAA,CAAEG,KAAK,CAACgB,aAAAA,CAAAA,CAAeW,QAAQ,EAAA;AACpCG,YAAAA,IAAAA,EAAMd,cAAcW,QAAQ,EAAA;AAC5B,YAAA,GAAGT;AACL,SAAA,CAAA,CACCa,MAAM,EAAA;AACX,IAAA,CAAA,CAAA;AAEA,IAAA,OAAOf,cACJW,QAAQ,EAAA,CACRK,QAAQ,CACP,CAAC,gFAAgF,CAAC,GAChF,CAAC,0DAA0D,EAAEnB,UAAAA,CAAWoB,IAAI,CAAC,IAAA,CAAA,CAAM,CAAC,CAAC,CAAA;AAE7F;;;;;;"}
@@ -0,0 +1,107 @@
1
+ import { z } from '@strapi/utils';
2
+ import { getScalarAttributeKeys } from './sort-schema.mjs';
3
+
4
+ /**
5
+ * Maps a scalar Strapi attribute type to the appropriate Zod leaf value schema
6
+ * used inside filter operator objects (e.g. { $eq: <value> }).
7
+ */ const attributeTypeToFilterValue = (attr)=>{
8
+ switch(attr.type){
9
+ case 'integer':
10
+ case 'biginteger':
11
+ case 'decimal':
12
+ case 'float':
13
+ return z.union([
14
+ z.number(),
15
+ z.array(z.number())
16
+ ]);
17
+ case 'boolean':
18
+ return z.boolean();
19
+ case 'enumeration':
20
+ {
21
+ const enumAttr = attr;
22
+ if (Array.isArray(enumAttr.enum) && enumAttr.enum.length > 0) {
23
+ return z.union([
24
+ z.enum(enumAttr.enum),
25
+ z.array(z.enum(enumAttr.enum))
26
+ ]);
27
+ }
28
+ return z.union([
29
+ z.string(),
30
+ z.array(z.string())
31
+ ]);
32
+ }
33
+ default:
34
+ // string, text, richtext, email, password, uid, date, datetime, time, timestamp
35
+ return z.union([
36
+ z.string(),
37
+ z.array(z.string()),
38
+ z.null()
39
+ ]);
40
+ }
41
+ };
42
+ /** All supported Strapi filter operators (excludes the experimental `$jsonSupersetOf`). */ const FILTER_OPERATORS = [
43
+ '$eq',
44
+ '$eqi',
45
+ '$ne',
46
+ '$nei',
47
+ '$in',
48
+ '$notIn',
49
+ '$lt',
50
+ '$lte',
51
+ '$gt',
52
+ '$gte',
53
+ '$between',
54
+ '$contains',
55
+ '$notContains',
56
+ '$containsi',
57
+ '$notContainsi',
58
+ '$startsWith',
59
+ '$startsWithi',
60
+ '$endsWith',
61
+ '$endsWithi',
62
+ '$null',
63
+ '$notNull'
64
+ ];
65
+ /**
66
+ * Builds a per-content-type recursive filters Zod schema.
67
+ *
68
+ * Shape:
69
+ * - Logical operators: $and, $or accept an array of filter objects.
70
+ * - Logical operator: $not accepts a single filter object.
71
+ * - Field keys (scalar attrs only): accept either a direct value (implicit $eq)
72
+ * or an operator object { $eq, $contains, $gt, … }.
73
+ *
74
+ * If the model has no scalar attributes, the schema is z.never() (filters not allowed).
75
+ */ const buildFiltersSchema = (attributes, permittedFields)=>{
76
+ const scalarKeys = getScalarAttributeKeys(attributes, permittedFields);
77
+ if (scalarKeys.length === 0) {
78
+ return z.never();
79
+ }
80
+ // Lazy reference for recursion ($and / $or / $not)
81
+ const filtersSchema = z.lazy(()=>{
82
+ const fieldShapes = {};
83
+ for (const key of scalarKeys){
84
+ const attr = attributes[key];
85
+ const valueSchema = attributeTypeToFilterValue(attr);
86
+ const operatorObject = z.object(Object.fromEntries(FILTER_OPERATORS.map((op)=>[
87
+ op,
88
+ valueSchema.optional()
89
+ ])));
90
+ // Field accepts either a direct value (implicit $eq) or operator object
91
+ fieldShapes[key] = z.union([
92
+ valueSchema,
93
+ operatorObject
94
+ ]).optional();
95
+ }
96
+ return z.object({
97
+ $and: z.array(filtersSchema).optional(),
98
+ $or: z.array(filtersSchema).optional(),
99
+ $not: filtersSchema.optional(),
100
+ ...fieldShapes
101
+ }).strict();
102
+ });
103
+ return filtersSchema.optional().describe(`Filter object. Supports logical operators ($and, $or, $not) and field operators ` + `($eq, $ne, $in, $contains, $gt, $lt, etc.). Valid fields: ${scalarKeys.join(', ')}.`);
104
+ };
105
+
106
+ export { FILTER_OPERATORS, attributeTypeToFilterValue, buildFiltersSchema };
107
+ //# sourceMappingURL=filters-schema.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filters-schema.mjs","sources":["../../../../server/src/mcp/schemas/filters-schema.ts"],"sourcesContent":["import { z } from '@strapi/utils';\nimport type { Schema, Struct } from '@strapi/types';\nimport { getScalarAttributeKeys } from './sort-schema';\n\n/**\n * Maps a scalar Strapi attribute type to the appropriate Zod leaf value schema\n * used inside filter operator objects (e.g. { $eq: <value> }).\n */\nexport const attributeTypeToFilterValue = (attr: Schema.Attribute.AnyAttribute): z.ZodTypeAny => {\n switch (attr.type) {\n case 'integer':\n case 'biginteger':\n case 'decimal':\n case 'float':\n return z.union([z.number(), z.array(z.number())]);\n case 'boolean':\n return z.boolean();\n case 'enumeration': {\n const enumAttr = attr as Schema.Attribute.Enumeration<string[]>;\n if (Array.isArray(enumAttr.enum) && enumAttr.enum.length > 0) {\n return z.union([\n z.enum(enumAttr.enum as [string, ...string[]]),\n z.array(z.enum(enumAttr.enum as [string, ...string[]])),\n ]);\n }\n return z.union([z.string(), z.array(z.string())]);\n }\n default:\n // string, text, richtext, email, password, uid, date, datetime, time, timestamp\n return z.union([z.string(), z.array(z.string()), z.null()]);\n }\n};\n\n/** All supported Strapi filter operators (excludes the experimental `$jsonSupersetOf`). */\nexport const FILTER_OPERATORS = [\n '$eq',\n '$eqi',\n '$ne',\n '$nei',\n '$in',\n '$notIn',\n '$lt',\n '$lte',\n '$gt',\n '$gte',\n '$between',\n '$contains',\n '$notContains',\n '$containsi',\n '$notContainsi',\n '$startsWith',\n '$startsWithi',\n '$endsWith',\n '$endsWithi',\n '$null',\n '$notNull',\n] as const;\n\n/**\n * Builds a per-content-type recursive filters Zod schema.\n *\n * Shape:\n * - Logical operators: $and, $or accept an array of filter objects.\n * - Logical operator: $not accepts a single filter object.\n * - Field keys (scalar attrs only): accept either a direct value (implicit $eq)\n * or an operator object { $eq, $contains, $gt, … }.\n *\n * If the model has no scalar attributes, the schema is z.never() (filters not allowed).\n */\nexport const buildFiltersSchema = (\n attributes: Struct.SchemaAttributes,\n permittedFields?: Set<string> | null\n): z.ZodTypeAny => {\n const scalarKeys = getScalarAttributeKeys(attributes, permittedFields);\n\n if (scalarKeys.length === 0) {\n return z.never();\n }\n\n // Lazy reference for recursion ($and / $or / $not)\n const filtersSchema: z.ZodTypeAny = z.lazy(() => {\n const fieldShapes: Record<string, z.ZodTypeAny> = {};\n\n for (const key of scalarKeys) {\n const attr = attributes[key];\n const valueSchema = attributeTypeToFilterValue(attr);\n const operatorObject = z.object(\n Object.fromEntries(FILTER_OPERATORS.map((op) => [op, valueSchema.optional()]))\n );\n // Field accepts either a direct value (implicit $eq) or operator object\n fieldShapes[key] = z.union([valueSchema, operatorObject]).optional();\n }\n\n return z\n .object({\n $and: z.array(filtersSchema).optional(),\n $or: z.array(filtersSchema).optional(),\n $not: filtersSchema.optional(),\n ...fieldShapes,\n })\n .strict();\n });\n\n return filtersSchema\n .optional()\n .describe(\n `Filter object. Supports logical operators ($and, $or, $not) and field operators ` +\n `($eq, $ne, $in, $contains, $gt, $lt, etc.). Valid fields: ${scalarKeys.join(', ')}.`\n );\n};\n"],"names":["attributeTypeToFilterValue","attr","type","z","union","number","array","boolean","enumAttr","Array","isArray","enum","length","string","null","FILTER_OPERATORS","buildFiltersSchema","attributes","permittedFields","scalarKeys","getScalarAttributeKeys","never","filtersSchema","lazy","fieldShapes","key","valueSchema","operatorObject","object","Object","fromEntries","map","op","optional","$and","$or","$not","strict","describe","join"],"mappings":";;;AAIA;;;IAIO,MAAMA,0BAAAA,GAA6B,CAACC,IAAAA,GAAAA;AACzC,IAAA,OAAQA,KAAKC,IAAI;QACf,KAAK,SAAA;QACL,KAAK,YAAA;QACL,KAAK,SAAA;QACL,KAAK,OAAA;YACH,OAAOC,CAAAA,CAAEC,KAAK,CAAC;AAACD,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CAACgB,aAAAA,CAAAA,CAAeW,QAAQ,EAAA;AACpCG,YAAAA,IAAAA,EAAMd,cAAcW,QAAQ,EAAA;AAC5B,YAAA,GAAGT;AACL,SAAA,CAAA,CACCa,MAAM,EAAA;AACX,IAAA,CAAA,CAAA;AAEA,IAAA,OAAOf,cACJW,QAAQ,EAAA,CACRK,QAAQ,CACP,CAAC,gFAAgF,CAAC,GAChF,CAAC,0DAA0D,EAAEnB,UAAAA,CAAWoB,IAAI,CAAC,IAAA,CAAA,CAAM,CAAC,CAAC,CAAA;AAE7F;;;;"}
@@ -0,0 +1,18 @@
1
+ 'use strict';
2
+
3
+ var strapiUtils = require('@strapi/utils');
4
+
5
+ strapiUtils.z.string().optional().describe('Locale code (e.g. "en", "fr"). Defaults to the default locale.');
6
+ const statusSchema = strapiUtils.z.enum([
7
+ 'draft',
8
+ 'published'
9
+ ]).optional().describe('Document status. Defaults to "draft" when draftAndPublish is enabled.');
10
+ const documentIdSchema = strapiUtils.z.string().min(1).describe('Stable document ID (e.g. "z7v8zma53x01r6oceimv922b"). Use this as the canonical identifier across draft/published versions; numeric "id" can differ per version row.');
11
+ const pageSchema = strapiUtils.z.number().int().min(1).optional().describe('Page number (1-indexed, default: 1).');
12
+ const pageSizeSchema = strapiUtils.z.number().int().min(1).max(100).optional().describe('Items per page (default: 25, max: 100).');
13
+
14
+ exports.documentIdSchema = documentIdSchema;
15
+ exports.pageSchema = pageSchema;
16
+ exports.pageSizeSchema = pageSizeSchema;
17
+ exports.statusSchema = statusSchema;
18
+ //# sourceMappingURL=input-schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input-schemas.js","sources":["../../../../server/src/mcp/schemas/input-schemas.ts"],"sourcesContent":["import { z } from '@strapi/utils';\n\nexport const localeSchema = z\n .string()\n .optional()\n .describe('Locale code (e.g. \"en\", \"fr\"). Defaults to the default locale.');\n\nexport const statusSchema = z\n .enum(['draft', 'published'])\n .optional()\n .describe('Document status. Defaults to \"draft\" when draftAndPublish is enabled.');\n\nexport const documentIdSchema = z\n .string()\n .min(1)\n .describe(\n 'Stable document ID (e.g. \"z7v8zma53x01r6oceimv922b\"). Use this as the canonical identifier across draft/published versions; numeric \"id\" can differ per version row.'\n );\n\nexport const pageSchema = z\n .number()\n .int()\n .min(1)\n .optional()\n .describe('Page number (1-indexed, default: 1).');\n\nexport const pageSizeSchema = z\n .number()\n .int()\n .min(1)\n .max(100)\n .optional()\n .describe('Items per page (default: 25, max: 100).');\n"],"names":["z","string","optional","describe","statusSchema","enum","documentIdSchema","min","pageSchema","number","int","pageSizeSchema","max"],"mappings":";;;;AAE4BA,aAAAA,CACzBC,MAAM,GACNC,QAAQ,EAAA,CACRC,QAAQ,CAAC,gEAAA;AAEL,MAAMC,YAAAA,GAAeJ,aAAAA,CACzBK,IAAI,CAAC;AAAC,IAAA,OAAA;AAAS,IAAA;AAAY,CAAA,CAAA,CAC3BH,QAAQ,EAAA,CACRC,QAAQ,CAAC,uEAAA;AAEL,MAAMG,gBAAAA,GAAmBN,aAAAA,CAC7BC,MAAM,EAAA,CACNM,GAAG,CAAC,CAAA,CAAA,CACJJ,QAAQ,CACP,sKAAA;AAGG,MAAMK,UAAAA,GAAaR,aAAAA,CACvBS,MAAM,GACNC,GAAG,EAAA,CACHH,GAAG,CAAC,CAAA,CAAA,CACJL,QAAQ,EAAA,CACRC,QAAQ,CAAC,sCAAA;MAECQ,cAAAA,GAAiBX,aAAAA,CAC3BS,MAAM,EAAA,CACNC,GAAG,EAAA,CACHH,GAAG,CAAC,CAAA,CAAA,CACJK,GAAG,CAAC,GAAA,CAAA,CACJV,QAAQ,EAAA,CACRC,QAAQ,CAAC,yCAAA;;;;;;;"}
@@ -0,0 +1,13 @@
1
+ import { z } from '@strapi/utils';
2
+
3
+ z.string().optional().describe('Locale code (e.g. "en", "fr"). Defaults to the default locale.');
4
+ const statusSchema = z.enum([
5
+ 'draft',
6
+ 'published'
7
+ ]).optional().describe('Document status. Defaults to "draft" when draftAndPublish is enabled.');
8
+ const documentIdSchema = z.string().min(1).describe('Stable document ID (e.g. "z7v8zma53x01r6oceimv922b"). Use this as the canonical identifier across draft/published versions; numeric "id" can differ per version row.');
9
+ const pageSchema = z.number().int().min(1).optional().describe('Page number (1-indexed, default: 1).');
10
+ const pageSizeSchema = z.number().int().min(1).max(100).optional().describe('Items per page (default: 25, max: 100).');
11
+
12
+ export { documentIdSchema, pageSchema, pageSizeSchema, statusSchema };
13
+ //# sourceMappingURL=input-schemas.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input-schemas.mjs","sources":["../../../../server/src/mcp/schemas/input-schemas.ts"],"sourcesContent":["import { z } from '@strapi/utils';\n\nexport const localeSchema = z\n .string()\n .optional()\n .describe('Locale code (e.g. \"en\", \"fr\"). Defaults to the default locale.');\n\nexport const statusSchema = z\n .enum(['draft', 'published'])\n .optional()\n .describe('Document status. Defaults to \"draft\" when draftAndPublish is enabled.');\n\nexport const documentIdSchema = z\n .string()\n .min(1)\n .describe(\n 'Stable document ID (e.g. \"z7v8zma53x01r6oceimv922b\"). Use this as the canonical identifier across draft/published versions; numeric \"id\" can differ per version row.'\n );\n\nexport const pageSchema = z\n .number()\n .int()\n .min(1)\n .optional()\n .describe('Page number (1-indexed, default: 1).');\n\nexport const pageSizeSchema = z\n .number()\n .int()\n .min(1)\n .max(100)\n .optional()\n .describe('Items per page (default: 25, max: 100).');\n"],"names":["z","string","optional","describe","statusSchema","enum","documentIdSchema","min","pageSchema","number","int","pageSizeSchema","max"],"mappings":";;AAE4BA,CAAAA,CACzBC,MAAM,GACNC,QAAQ,EAAA,CACRC,QAAQ,CAAC,gEAAA;AAEL,MAAMC,YAAAA,GAAeJ,CAAAA,CACzBK,IAAI,CAAC;AAAC,IAAA,OAAA;AAAS,IAAA;AAAY,CAAA,CAAA,CAC3BH,QAAQ,EAAA,CACRC,QAAQ,CAAC,uEAAA;AAEL,MAAMG,gBAAAA,GAAmBN,CAAAA,CAC7BC,MAAM,EAAA,CACNM,GAAG,CAAC,CAAA,CAAA,CACJJ,QAAQ,CACP,sKAAA;AAGG,MAAMK,UAAAA,GAAaR,CAAAA,CACvBS,MAAM,GACNC,GAAG,EAAA,CACHH,GAAG,CAAC,CAAA,CAAA,CACJL,QAAQ,EAAA,CACRC,QAAQ,CAAC,sCAAA;MAECQ,cAAAA,GAAiBX,CAAAA,CAC3BS,MAAM,EAAA,CACNC,GAAG,EAAA,CACHH,GAAG,CAAC,CAAA,CAAA,CACJK,GAAG,CAAC,GAAA,CAAA,CACJV,QAAQ,EAAA,CACRC,QAAQ,CAAC,yCAAA;;;;"}
@@ -0,0 +1,48 @@
1
+ 'use strict';
2
+
3
+ var strapiUtils = require('@strapi/utils');
4
+
5
+ const buildOutputDataSchema = (attributes, permittedFields)=>{
6
+ const readableKeys = Object.keys(attributes).filter((key)=>permittedFields === null || permittedFields.has(key));
7
+ if (readableKeys.length === 0) {
8
+ return strapiUtils.z.record(strapiUtils.z.string(), strapiUtils.z.unknown());
9
+ }
10
+ const shape = Object.fromEntries(readableKeys.map((key)=>[
11
+ key,
12
+ strapiUtils.z.unknown().optional()
13
+ ]));
14
+ return strapiUtils.z.object(shape).loose();
15
+ };
16
+ /**
17
+ * Builds the MCP output schema for a single-document response (`{ data, meta }`).
18
+ * Field shape is constrained to `readFields` when non-null (RBAC field filtering).
19
+ */ const buildDocumentOutputSchema = (attributes, readFields)=>strapiUtils.z.object({
20
+ data: buildOutputDataSchema(attributes, readFields).nullable(),
21
+ meta: strapiUtils.z.object({
22
+ availableLocales: strapiUtils.z.array(strapiUtils.z.record(strapiUtils.z.string(), strapiUtils.z.unknown())).optional(),
23
+ availableStatus: strapiUtils.z.array(strapiUtils.z.record(strapiUtils.z.string(), strapiUtils.z.unknown())).optional()
24
+ }).optional()
25
+ }).loose();
26
+ /**
27
+ * Builds the MCP output schema for a paginated list response (`{ results, pagination }`).
28
+ * Field shape is constrained to `readFields` when non-null (RBAC field filtering).
29
+ */ const buildListOutputSchema = (attributes, readFields)=>strapiUtils.z.object({
30
+ results: strapiUtils.z.array(buildOutputDataSchema(attributes, readFields)),
31
+ pagination: strapiUtils.z.object({
32
+ page: strapiUtils.z.number(),
33
+ pageSize: strapiUtils.z.number(),
34
+ pageCount: strapiUtils.z.number(),
35
+ total: strapiUtils.z.number()
36
+ })
37
+ }).loose();
38
+ /**
39
+ * Builds the MCP output schema for a delete response (`{ data }`).
40
+ * Field shape is constrained to `readFields` when non-null (RBAC field filtering).
41
+ */ const buildDeleteOutputSchema = (attributes, readFields)=>strapiUtils.z.object({
42
+ data: buildOutputDataSchema(attributes, readFields).nullable()
43
+ }).loose();
44
+
45
+ exports.buildDeleteOutputSchema = buildDeleteOutputSchema;
46
+ exports.buildDocumentOutputSchema = buildDocumentOutputSchema;
47
+ exports.buildListOutputSchema = buildListOutputSchema;
48
+ //# sourceMappingURL=output-schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output-schemas.js","sources":["../../../../server/src/mcp/schemas/output-schemas.ts"],"sourcesContent":["import { z } from '@strapi/utils';\nimport type { Struct } from '@strapi/types';\n\nconst buildOutputDataSchema = (\n attributes: Struct.SchemaAttributes,\n permittedFields: Set<string> | null\n): z.ZodTypeAny => {\n const readableKeys = Object.keys(attributes).filter(\n (key) => permittedFields === null || permittedFields.has(key)\n );\n\n if (readableKeys.length === 0) {\n return z.record(z.string(), z.unknown());\n }\n\n const shape = Object.fromEntries(readableKeys.map((key) => [key, z.unknown().optional()]));\n\n return z.object(shape).loose();\n};\n\n/**\n * Builds the MCP output schema for a single-document response (`{ data, meta }`).\n * Field shape is constrained to `readFields` when non-null (RBAC field filtering).\n */\nexport const buildDocumentOutputSchema = (\n attributes: Struct.SchemaAttributes,\n readFields: Set<string> | null\n): z.ZodObject<z.ZodRawShape> =>\n z\n .object({\n data: buildOutputDataSchema(attributes, readFields).nullable(),\n meta: z\n .object({\n availableLocales: z.array(z.record(z.string(), z.unknown())).optional(),\n availableStatus: z.array(z.record(z.string(), z.unknown())).optional(),\n })\n .optional(),\n })\n .loose();\n\n/**\n * Builds the MCP output schema for a paginated list response (`{ results, pagination }`).\n * Field shape is constrained to `readFields` when non-null (RBAC field filtering).\n */\nexport const buildListOutputSchema = (\n attributes: Struct.SchemaAttributes,\n readFields: Set<string> | null\n): z.ZodObject<z.ZodRawShape> =>\n z\n .object({\n results: z.array(buildOutputDataSchema(attributes, readFields)),\n pagination: z.object({\n page: z.number(),\n pageSize: z.number(),\n pageCount: z.number(),\n total: z.number(),\n }),\n })\n .loose();\n\n/**\n * Builds the MCP output schema for a delete response (`{ data }`).\n * Field shape is constrained to `readFields` when non-null (RBAC field filtering).\n */\nexport const buildDeleteOutputSchema = (\n attributes: Struct.SchemaAttributes,\n readFields: Set<string> | null\n): z.ZodObject<z.ZodRawShape> =>\n z\n .object({\n data: buildOutputDataSchema(attributes, readFields).nullable(),\n })\n .loose();\n"],"names":["buildOutputDataSchema","attributes","permittedFields","readableKeys","Object","keys","filter","key","has","length","z","record","string","unknown","shape","fromEntries","map","optional","object","loose","buildDocumentOutputSchema","readFields","data","nullable","meta","availableLocales","array","availableStatus","buildListOutputSchema","results","pagination","page","number","pageSize","pageCount","total","buildDeleteOutputSchema"],"mappings":";;;;AAGA,MAAMA,qBAAAA,GAAwB,CAC5BC,UAAAA,EACAC,eAAAA,GAAAA;AAEA,IAAA,MAAMC,YAAAA,GAAeC,MAAAA,CAAOC,IAAI,CAACJ,UAAAA,CAAAA,CAAYK,MAAM,CACjD,CAACC,GAAAA,GAAQL,eAAAA,KAAoB,IAAA,IAAQA,eAAAA,CAAgBM,GAAG,CAACD,GAAAA,CAAAA,CAAAA;IAG3D,IAAIJ,YAAAA,CAAaM,MAAM,KAAK,CAAA,EAAG;AAC7B,QAAA,OAAOC,cAAEC,MAAM,CAACD,cAAEE,MAAM,EAAA,EAAIF,cAAEG,OAAO,EAAA,CAAA;AACvC,IAAA;IAEA,MAAMC,KAAAA,GAAQV,OAAOW,WAAW,CAACZ,aAAaa,GAAG,CAAC,CA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EAAA;AACnBG,YAAAA,KAAAA,EAAOzB,cAAEsB,MAAM;AACjB,SAAA;AACF,KAAA,CAAA,CACCb,KAAK;AAEV;;;UAIaiB,uBAAAA,GAA0B,CACrCnC,YACAoB,UAAAA,GAEAX,aAAAA,CACGQ,MAAM,CAAC;QACNI,IAAAA,EAAMtB,qBAAAA,CAAsBC,UAAAA,EAAYoB,UAAAA,CAAAA,CAAYE,QAAQ;AAC9D,KAAA,CAAA,CACCJ,KAAK;;;;;;"}
@@ -0,0 +1,44 @@
1
+ import { z } from '@strapi/utils';
2
+
3
+ const buildOutputDataSchema = (attributes, permittedFields)=>{
4
+ const readableKeys = Object.keys(attributes).filter((key)=>permittedFields === null || permittedFields.has(key));
5
+ if (readableKeys.length === 0) {
6
+ return z.record(z.string(), z.unknown());
7
+ }
8
+ const shape = Object.fromEntries(readableKeys.map((key)=>[
9
+ key,
10
+ z.unknown().optional()
11
+ ]));
12
+ return z.object(shape).loose();
13
+ };
14
+ /**
15
+ * Builds the MCP output schema for a single-document response (`{ data, meta }`).
16
+ * Field shape is constrained to `readFields` when non-null (RBAC field filtering).
17
+ */ const buildDocumentOutputSchema = (attributes, readFields)=>z.object({
18
+ data: buildOutputDataSchema(attributes, readFields).nullable(),
19
+ meta: z.object({
20
+ availableLocales: z.array(z.record(z.string(), z.unknown())).optional(),
21
+ availableStatus: z.array(z.record(z.string(), z.unknown())).optional()
22
+ }).optional()
23
+ }).loose();
24
+ /**
25
+ * Builds the MCP output schema for a paginated list response (`{ results, pagination }`).
26
+ * Field shape is constrained to `readFields` when non-null (RBAC field filtering).
27
+ */ const buildListOutputSchema = (attributes, readFields)=>z.object({
28
+ results: z.array(buildOutputDataSchema(attributes, readFields)),
29
+ pagination: z.object({
30
+ page: z.number(),
31
+ pageSize: z.number(),
32
+ pageCount: z.number(),
33
+ total: z.number()
34
+ })
35
+ }).loose();
36
+ /**
37
+ * Builds the MCP output schema for a delete response (`{ data }`).
38
+ * Field shape is constrained to `readFields` when non-null (RBAC field filtering).
39
+ */ const buildDeleteOutputSchema = (attributes, readFields)=>z.object({
40
+ data: buildOutputDataSchema(attributes, readFields).nullable()
41
+ }).loose();
42
+
43
+ export { buildDeleteOutputSchema, buildDocumentOutputSchema, buildListOutputSchema };
44
+ //# sourceMappingURL=output-schemas.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output-schemas.mjs","sources":["../../../../server/src/mcp/schemas/output-schemas.ts"],"sourcesContent":["import { z } from '@strapi/utils';\nimport type { Struct } from '@strapi/types';\n\nconst buildOutputDataSchema = (\n attributes: Struct.SchemaAttributes,\n permittedFields: Set<string> | null\n): z.ZodTypeAny => {\n const readableKeys = Object.keys(attributes).filter(\n (key) => permittedFields === null || permittedFields.has(key)\n );\n\n if (readableKeys.length === 0) {\n return z.record(z.string(), z.unknown());\n }\n\n const shape = Object.fromEntries(readableKeys.map((key) => [key, z.unknown().optional()]));\n\n return z.object(shape).loose();\n};\n\n/**\n * Builds the MCP output schema for a single-document response (`{ data, meta }`).\n * Field shape is constrained to `readFields` when non-null (RBAC field filtering).\n */\nexport const buildDocumentOutputSchema = (\n attributes: Struct.SchemaAttributes,\n readFields: Set<string> | null\n): z.ZodObject<z.ZodRawShape> =>\n z\n .object({\n data: buildOutputDataSchema(attributes, readFields).nullable(),\n meta: z\n .object({\n availableLocales: z.array(z.record(z.string(), z.unknown())).optional(),\n availableStatus: z.array(z.record(z.string(), z.unknown())).optional(),\n })\n .optional(),\n })\n .loose();\n\n/**\n * Builds the MCP output schema for a paginated list response (`{ results, pagination }`).\n * Field shape is constrained to `readFields` when non-null (RBAC field filtering).\n */\nexport const buildListOutputSchema = (\n attributes: Struct.SchemaAttributes,\n readFields: Set<string> | null\n): z.ZodObject<z.ZodRawShape> =>\n z\n .object({\n results: z.array(buildOutputDataSchema(attributes, readFields)),\n pagination: z.object({\n page: z.number(),\n pageSize: z.number(),\n pageCount: z.number(),\n total: z.number(),\n }),\n })\n .loose();\n\n/**\n * Builds the MCP output schema for a delete response (`{ data }`).\n * Field shape is constrained to `readFields` when non-null (RBAC field filtering).\n */\nexport const buildDeleteOutputSchema = (\n attributes: Struct.SchemaAttributes,\n readFields: Set<string> | null\n): z.ZodObject<z.ZodRawShape> =>\n z\n .object({\n data: buildOutputDataSchema(attributes, readFields).nullable(),\n })\n .loose();\n"],"names":["buildOutputDataSchema","attributes","permittedFields","readableKeys","Object","keys","filter","key","has","length","z","record","string","unknown","shape","fromEntries","map","optional","object","loose","buildDocumentOutputSchema","readFields","data","nullable","meta","availableLocales","array","availableStatus","buildListOutputSchema","results","pagination","page","number","pageSize","pageCount","total","buildDeleteOutputSchema"],"mappings":";;AAGA,MAAMA,qBAAAA,GAAwB,CAC5BC,UAAAA,EACAC,eAAAA,GAAAA;AAEA,IAAA,MAAMC,YAAAA,GAAeC,MAAAA,CAAOC,IAAI,CAACJ,UAAAA,CAAAA,CAAYK,MAAM,CACjD,CAACC,GAAAA,GAAQL,eAAAA,KAAoB,IAAA,IAAQA,eAAAA,CAAgBM,GAAG,CAACD,GAAAA,CAAAA,CAAAA;IAG3D,IAAIJ,YAAAA,CAAaM,MAAM,KAAK,CAAA,EAAG;AAC7B,QAAA,OAAOC,EAAEC,MAAM,CAACD,EAAEE,MAAM,EAAA,EAAIF,EAAEG,OAAO,EAAA,CAAA;AACvC,IAAA;IAEA,MAAMC,KAAAA,GAAQV,OAAOW,WAAW,CAACZ,aAAaa,GAAG,CAAC,CAACT,GAAAA,GAAQ;AAACA,YAAAA,GAAAA;YAAKG,CAAAA,CAAEG,OAAO,GAAGI,QAAQ;AAAG,SAAA,CAAA,CAAA;AAExF,IAAA,OAAOP,CAAAA,CAAEQ,MAAM,CAACJ,KAAAA,CAAAA,CAAOK,KAAK,EAAA;AAC9B,CAAA;AAEA;;;UAIaC,yBAAAA,GAA4B,CACvCnB,YACAoB,UAAAA,GAEAX,CAAAA,CACGQ,MAAM,CAAC;QACNI,IAAAA,EAAMtB,qBAAAA,CAAsBC,UAAAA,EAAYoB,UA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 var strapiUtils = require('@strapi/utils');
4
+
5
+ /** Attribute types considered scalar for sorting and filtering (excludes relations, components, media, json, blocks). */ const SCALAR_ATTRIBUTE_TYPES = new Set([
6
+ 'string',
7
+ 'text',
8
+ 'richtext',
9
+ 'email',
10
+ 'password',
11
+ 'uid',
12
+ 'integer',
13
+ 'biginteger',
14
+ 'decimal',
15
+ 'float',
16
+ 'boolean',
17
+ 'date',
18
+ 'datetime',
19
+ 'time',
20
+ 'timestamp',
21
+ 'enumeration'
22
+ ]);
23
+ /**
24
+ * Returns the list of scalar attribute keys from a content type's attributes.
25
+ * Relation, component, dynamiczone, media, json, and blocks are excluded because
26
+ * they cannot be meaningfully sorted or filtered via simple operators.
27
+ */ const getScalarAttributeKeys = (attributes, permittedFields)=>{
28
+ let keys = Object.entries(attributes).filter(([, attr])=>SCALAR_ATTRIBUTE_TYPES.has(attr.type) && attr.private !== true).map(([key])=>key);
29
+ if (permittedFields !== null && permittedFields !== undefined) {
30
+ keys = keys.filter((key)=>permittedFields.has(key));
31
+ }
32
+ return keys;
33
+ };
34
+ /**
35
+ * Builds a per-content-type sort Zod schema constrained to the model's scalar fields.
36
+ *
37
+ * Supports all four Strapi sort notations:
38
+ * - string: "title:asc"
39
+ * - string[]: ["title:asc", "createdAt:desc"]
40
+ * - object: { title: "asc" }
41
+ * - object[]: [{ title: "asc" }, { createdAt: "desc" }]
42
+ *
43
+ * Object forms have their keys constrained to known scalar attribute names.
44
+ * If the model has no scalar attributes, the schema is z.never() (sort not allowed).
45
+ */ const buildSortSchema = (attributes, permittedFields)=>{
46
+ const scalarKeys = getScalarAttributeKeys(attributes, permittedFields);
47
+ if (scalarKeys.length === 0) {
48
+ return strapiUtils.z.never();
49
+ }
50
+ const directionSchema = strapiUtils.z.enum([
51
+ 'asc',
52
+ 'desc'
53
+ ]);
54
+ const sortObjectSchema = strapiUtils.z.object(Object.fromEntries(scalarKeys.map((key)=>[
55
+ key,
56
+ directionSchema.optional()
57
+ ]))).strict();
58
+ const sortStringPattern = /^([^:]+):(asc|desc)$/;
59
+ const isPermittedSortString = (value)=>{
60
+ const match = sortStringPattern.exec(value);
61
+ if (match === null) {
62
+ return true;
63
+ }
64
+ return scalarKeys.includes(match[1]);
65
+ };
66
+ const stringSortSchema = strapiUtils.z.string().refine(isPermittedSortString, {
67
+ message: `Sort field must be one of: ${scalarKeys.join(', ')}`
68
+ });
69
+ return strapiUtils.z.union([
70
+ stringSortSchema,
71
+ strapiUtils.z.array(stringSortSchema),
72
+ sortObjectSchema,
73
+ strapiUtils.z.array(sortObjectSchema)
74
+ ]).optional().describe(`Sort expression. String: "field:asc". Array: ["field:asc"]. Object: { field: "asc" }. ` + `Valid fields: ${scalarKeys.join(', ')}.`);
75
+ };
76
+
77
+ exports.SCALAR_ATTRIBUTE_TYPES = SCALAR_ATTRIBUTE_TYPES;
78
+ exports.buildSortSchema = buildSortSchema;
79
+ exports.getScalarAttributeKeys = getScalarAttributeKeys;
80
+ //# sourceMappingURL=sort-schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sort-schema.js","sources":["../../../../server/src/mcp/schemas/sort-schema.ts"],"sourcesContent":["import { z } from '@strapi/utils';\nimport type { Struct } from '@strapi/types';\n\n/** Attribute types considered scalar for sorting and filtering (excludes relations, components, media, json, blocks). */\nexport const SCALAR_ATTRIBUTE_TYPES = new Set([\n 'string',\n 'text',\n 'richtext',\n 'email',\n 'password',\n 'uid',\n 'integer',\n 'biginteger',\n 'decimal',\n 'float',\n 'boolean',\n 'date',\n 'datetime',\n 'time',\n 'timestamp',\n 'enumeration',\n]);\n\n/**\n * Returns the list of scalar attribute keys from a content type's attributes.\n * Relation, component, dynamiczone, media, json, and blocks are excluded because\n * they cannot be meaningfully sorted or filtered via simple operators.\n */\nexport const getScalarAttributeKeys = (\n attributes: Struct.SchemaAttributes,\n permittedFields?: Set<string> | null\n): string[] => {\n let keys = Object.entries(attributes)\n .filter(\n ([, attr]) =>\n SCALAR_ATTRIBUTE_TYPES.has(attr.type) && (attr as { private?: boolean }).private !== true\n )\n .map(([key]) => key);\n\n if (permittedFields !== null && permittedFields !== undefined) {\n keys = keys.filter((key) => permittedFields.has(key));\n }\n\n return keys;\n};\n\n/**\n * Builds a per-content-type sort Zod schema constrained to the model's scalar fields.\n *\n * Supports all four Strapi sort notations:\n * - string: \"title:asc\"\n * - string[]: [\"title:asc\", \"createdAt:desc\"]\n * - object: { title: \"asc\" }\n * - object[]: [{ title: \"asc\" }, { createdAt: \"desc\" }]\n *\n * Object forms have their keys constrained to known scalar attribute names.\n * If the model has no scalar attributes, the schema is z.never() (sort not allowed).\n */\nexport const buildSortSchema = (\n attributes: Struct.SchemaAttributes,\n permittedFields?: Set<string> | null\n): z.ZodTypeAny => {\n const scalarKeys = getScalarAttributeKeys(attributes, permittedFields);\n\n if (scalarKeys.length === 0) {\n return z.never();\n }\n\n const directionSchema = z.enum(['asc', 'desc']);\n const sortObjectSchema = z\n .object(Object.fromEntries(scalarKeys.map((key) => [key, directionSchema.optional()])))\n .strict();\n\n const sortStringPattern = /^([^:]+):(asc|desc)$/;\n const isPermittedSortString = (value: string): boolean => {\n const match = sortStringPattern.exec(value);\n if (match === null) {\n return true;\n }\n return scalarKeys.includes(match[1]);\n };\n\n const stringSortSchema = z.string().refine(isPermittedSortString, {\n message: `Sort field must be one of: ${scalarKeys.join(', ')}`,\n });\n\n return z\n .union([\n stringSortSchema,\n z.array(stringSortSchema),\n sortObjectSchema,\n z.array(sortObjectSchema),\n ])\n .optional()\n .describe(\n `Sort expression. String: \"field:asc\". Array: [\"field:asc\"]. Object: { field: \"asc\" }. ` +\n `Valid fields: ${scalarKeys.join(', ')}.`\n );\n};\n"],"names":["SCALAR_ATTRIBUTE_TYPES","Set","getScalarAttributeKeys","attributes","permittedFields","keys","Object","entries","filter","attr","has","type","private","map","key","undefined","buildSortSchema","scalarKeys","length","z","never","directionSchema","enum","sortObjectSchema","object","fromEntries","optional","strict","sortStringPattern","isPermittedSortString","value","match","exec","includes","stringSortS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0,0 +1,76 @@
1
+ import { z } from '@strapi/utils';
2
+
3
+ /** Attribute types considered scalar for sorting and filtering (excludes relations, components, media, json, blocks). */ const SCALAR_ATTRIBUTE_TYPES = new Set([
4
+ 'string',
5
+ 'text',
6
+ 'richtext',
7
+ 'email',
8
+ 'password',
9
+ 'uid',
10
+ 'integer',
11
+ 'biginteger',
12
+ 'decimal',
13
+ 'float',
14
+ 'boolean',
15
+ 'date',
16
+ 'datetime',
17
+ 'time',
18
+ 'timestamp',
19
+ 'enumeration'
20
+ ]);
21
+ /**
22
+ * Returns the list of scalar attribute keys from a content type's attributes.
23
+ * Relation, component, dynamiczone, media, json, and blocks are excluded because
24
+ * they cannot be meaningfully sorted or filtered via simple operators.
25
+ */ const getScalarAttributeKeys = (attributes, permittedFields)=>{
26
+ let keys = Object.entries(attributes).filter(([, attr])=>SCALAR_ATTRIBUTE_TYPES.has(attr.type) && attr.private !== true).map(([key])=>key);
27
+ if (permittedFields !== null && permittedFields !== undefined) {
28
+ keys = keys.filter((key)=>permittedFields.has(key));
29
+ }
30
+ return keys;
31
+ };
32
+ /**
33
+ * Builds a per-content-type sort Zod schema constrained to the model's scalar fields.
34
+ *
35
+ * Supports all four Strapi sort notations:
36
+ * - string: "title:asc"
37
+ * - string[]: ["title:asc", "createdAt:desc"]
38
+ * - object: { title: "asc" }
39
+ * - object[]: [{ title: "asc" }, { createdAt: "desc" }]
40
+ *
41
+ * Object forms have their keys constrained to known scalar attribute names.
42
+ * If the model has no scalar attributes, the schema is z.never() (sort not allowed).
43
+ */ const buildSortSchema = (attributes, permittedFields)=>{
44
+ const scalarKeys = getScalarAttributeKeys(attributes, permittedFields);
45
+ if (scalarKeys.length === 0) {
46
+ return z.never();
47
+ }
48
+ const directionSchema = z.enum([
49
+ 'asc',
50
+ 'desc'
51
+ ]);
52
+ const sortObjectSchema = z.object(Object.fromEntries(scalarKeys.map((key)=>[
53
+ key,
54
+ directionSchema.optional()
55
+ ]))).strict();
56
+ const sortStringPattern = /^([^:]+):(asc|desc)$/;
57
+ const isPermittedSortString = (value)=>{
58
+ const match = sortStringPattern.exec(value);
59
+ if (match === null) {
60
+ return true;
61
+ }
62
+ return scalarKeys.includes(match[1]);
63
+ };
64
+ const stringSortSchema = z.string().refine(isPermittedSortString, {
65
+ message: `Sort field must be one of: ${scalarKeys.join(', ')}`
66
+ });
67
+ return z.union([
68
+ stringSortSchema,
69
+ z.array(stringSortSchema),
70
+ sortObjectSchema,
71
+ z.array(sortObjectSchema)
72
+ ]).optional().describe(`Sort expression. String: "field:asc". Array: ["field:asc"]. Object: { field: "asc" }. ` + `Valid fields: ${scalarKeys.join(', ')}.`);
73
+ };
74
+
75
+ export { SCALAR_ATTRIBUTE_TYPES, buildSortSchema, getScalarAttributeKeys };
76
+ //# sourceMappingURL=sort-schema.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sort-schema.mjs","sources":["../../../../server/src/mcp/schemas/sort-schema.ts"],"sourcesContent":["import { z } from '@strapi/utils';\nimport type { Struct } from '@strapi/types';\n\n/** Attribute types considered scalar for sorting and filtering (excludes relations, components, media, json, blocks). */\nexport const SCALAR_ATTRIBUTE_TYPES = new Set([\n 'string',\n 'text',\n 'richtext',\n 'email',\n 'password',\n 'uid',\n 'integer',\n 'biginteger',\n 'decimal',\n 'float',\n 'boolean',\n 'date',\n 'datetime',\n 'time',\n 'timestamp',\n 'enumeration',\n]);\n\n/**\n * Returns the list of scalar attribute keys from a content type's attributes.\n * Relation, component, dynamiczone, media, json, and blocks are excluded because\n * they cannot be meaningfully sorted or filtered via simple operators.\n */\nexport const getScalarAttributeKeys = (\n attributes: Struct.SchemaAttributes,\n permittedFields?: Set<string> | null\n): string[] => {\n let keys = Object.entries(attributes)\n .filter(\n ([, attr]) =>\n SCALAR_ATTRIBUTE_TYPES.has(attr.type) && (attr as { private?: boolean }).private !== true\n )\n .map(([key]) => key);\n\n if (permittedFields !== null && permittedFields !== undefined) {\n keys = keys.filter((key) => permittedFields.has(key));\n }\n\n return keys;\n};\n\n/**\n * Builds a per-content-type sort Zod schema constrained to the model's scalar fields.\n *\n * Supports all four Strapi sort notations:\n * - string: \"title:asc\"\n * - string[]: [\"title:asc\", \"createdAt:desc\"]\n * - object: { title: \"asc\" }\n * - object[]: [{ title: \"asc\" }, { createdAt: \"desc\" }]\n *\n * Object forms have their keys constrained to known scalar attribute names.\n * If the model has no scalar attributes, the schema is z.never() (sort not allowed).\n */\nexport const buildSortSchema = (\n attributes: Struct.SchemaAttributes,\n permittedFields?: Set<string> | null\n): z.ZodTypeAny => {\n const scalarKeys = getScalarAttributeKeys(attributes, permittedFields);\n\n if (scalarKeys.length === 0) {\n return z.never();\n }\n\n const directionSchema = z.enum(['asc', 'desc']);\n const sortObjectSchema = z\n .object(Object.fromEntries(scalarKeys.map((key) => [key, directionSchema.optional()])))\n .strict();\n\n const sortStringPattern = /^([^:]+):(asc|desc)$/;\n const isPermittedSortString = (value: string): boolean => {\n const match = sortStringPattern.exec(value);\n if (match === null) {\n return true;\n }\n return scalarKeys.includes(match[1]);\n };\n\n const stringSortSchema = z.string().refine(isPermittedSortString, {\n message: `Sort field must be one of: ${scalarKeys.join(', ')}`,\n });\n\n return z\n .union([\n stringSortSchema,\n z.array(stringSortSchema),\n sortObjectSchema,\n z.array(sortObjectSchema),\n ])\n .optional()\n .describe(\n `Sort expression. String: \"field:asc\". Array: [\"field:asc\"]. Object: { field: \"asc\" }. ` +\n `Valid fields: ${scalarKeys.join(', ')}.`\n );\n};\n"],"names":["SCALAR_ATTRIBUTE_TYPES","Set","getScalarAttributeKeys","attributes","permittedFields","keys","Object","entries","filter","attr","has","type","private","map","key","undefined","buildSortSchema","scalarKeys","length","z","never","directionSchema","enum","sortObjectSchema","object","fromEntries","optional","strict","sortStringPattern","isPermittedSortString","value","match","exec","includes","stringSortSchema","string","refine","message","join","union","array","describe"],"mappings":";;AAGA,0HACO,MAAMA,sBAAAA,GAAyB,IAAIC,GAAAA,CAAI;AAC5C,IAAA,QAAA;AACA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