@strapi/core 0.0.0-experimental.25f7de53c1fc990bbb86d4aa43c379acfa838064 → 0.0.0-experimental.281d87ac79eeddcaa1823767b9a4c9dbd5d6192d

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.

Potentially problematic release.


This version of @strapi/core might be problematic. Click here for more details.

Files changed (112) hide show
  1. package/dist/Strapi.d.ts.map +1 -1
  2. package/dist/Strapi.js +2 -0
  3. package/dist/Strapi.js.map +1 -1
  4. package/dist/Strapi.mjs +2 -0
  5. package/dist/Strapi.mjs.map +1 -1
  6. package/dist/core-api/routes/index.d.ts +22 -4
  7. package/dist/core-api/routes/index.d.ts.map +1 -1
  8. package/dist/core-api/routes/index.js +8 -118
  9. package/dist/core-api/routes/index.js.map +1 -1
  10. package/dist/core-api/routes/index.mjs +8 -118
  11. package/dist/core-api/routes/index.mjs.map +1 -1
  12. package/dist/domain/module/index.d.ts.map +1 -1
  13. package/dist/domain/module/index.js +0 -3
  14. package/dist/domain/module/index.js.map +1 -1
  15. package/dist/domain/module/index.mjs +0 -3
  16. package/dist/domain/module/index.mjs.map +1 -1
  17. package/dist/ee/index.d.ts +6 -0
  18. package/dist/ee/index.d.ts.map +1 -1
  19. package/dist/ee/index.js +29 -3
  20. package/dist/ee/index.js.map +1 -1
  21. package/dist/ee/index.mjs +30 -4
  22. package/dist/ee/index.mjs.map +1 -1
  23. package/dist/ee/license.d.ts +3 -1
  24. package/dist/ee/license.d.ts.map +1 -1
  25. package/dist/ee/license.js +6 -1
  26. package/dist/ee/license.js.map +1 -1
  27. package/dist/ee/license.mjs +6 -2
  28. package/dist/ee/license.mjs.map +1 -1
  29. package/dist/factories.d.ts +1 -3
  30. package/dist/factories.d.ts.map +1 -1
  31. package/dist/factories.js +2 -10
  32. package/dist/factories.js.map +1 -1
  33. package/dist/factories.mjs +3 -10
  34. package/dist/factories.mjs.map +1 -1
  35. package/dist/index.js +1 -1
  36. package/dist/index.mjs +1 -1
  37. package/dist/package.json.js +21 -15
  38. package/dist/package.json.js.map +1 -1
  39. package/dist/package.json.mjs +21 -16
  40. package/dist/package.json.mjs.map +1 -1
  41. package/dist/services/core-store.d.ts +2 -2
  42. package/dist/services/core-store.d.ts.map +1 -1
  43. package/dist/services/core-store.js.map +1 -1
  44. package/dist/services/core-store.mjs.map +1 -1
  45. package/dist/services/document-service/entries.d.ts.map +1 -1
  46. package/dist/services/document-service/entries.js +42 -0
  47. package/dist/services/document-service/entries.js.map +1 -1
  48. package/dist/services/document-service/entries.mjs +43 -1
  49. package/dist/services/document-service/entries.mjs.map +1 -1
  50. package/dist/services/document-service/internationalization.d.ts +6 -1
  51. package/dist/services/document-service/internationalization.d.ts.map +1 -1
  52. package/dist/services/document-service/internationalization.js +32 -0
  53. package/dist/services/document-service/internationalization.js.map +1 -1
  54. package/dist/services/document-service/internationalization.mjs +32 -1
  55. package/dist/services/document-service/internationalization.mjs.map +1 -1
  56. package/dist/services/document-service/repository.d.ts.map +1 -1
  57. package/dist/services/document-service/repository.js +5 -4
  58. package/dist/services/document-service/repository.js.map +1 -1
  59. package/dist/services/document-service/repository.mjs +6 -5
  60. package/dist/services/document-service/repository.mjs.map +1 -1
  61. package/dist/services/entity-validator/index.d.ts.map +1 -1
  62. package/dist/services/entity-validator/index.js +9 -0
  63. package/dist/services/entity-validator/index.js.map +1 -1
  64. package/dist/services/entity-validator/index.mjs +9 -0
  65. package/dist/services/entity-validator/index.mjs.map +1 -1
  66. package/dist/services/entity-validator/validators.d.ts +1 -0
  67. package/dist/services/entity-validator/validators.d.ts.map +1 -1
  68. package/dist/services/entity-validator/validators.js +3 -0
  69. package/dist/services/entity-validator/validators.js.map +1 -1
  70. package/dist/services/entity-validator/validators.mjs +3 -0
  71. package/dist/services/entity-validator/validators.mjs.map +1 -1
  72. package/dist/services/server/register-routes.js +2 -22
  73. package/dist/services/server/register-routes.js.map +1 -1
  74. package/dist/services/server/register-routes.mjs +2 -22
  75. package/dist/services/server/register-routes.mjs.map +1 -1
  76. package/dist/services/server/routing.d.ts +0 -10
  77. package/dist/services/server/routing.d.ts.map +1 -1
  78. package/dist/services/server/routing.js +1 -7
  79. package/dist/services/server/routing.js.map +1 -1
  80. package/dist/services/server/routing.mjs +1 -7
  81. package/dist/services/server/routing.mjs.map +1 -1
  82. package/dist/services/utils/conditional-fields.d.ts +3 -0
  83. package/dist/services/utils/conditional-fields.d.ts.map +1 -0
  84. package/dist/services/utils/conditional-fields.js +22 -0
  85. package/dist/services/utils/conditional-fields.js.map +1 -0
  86. package/dist/services/utils/conditional-fields.mjs +20 -0
  87. package/dist/services/utils/conditional-fields.mjs.map +1 -0
  88. package/dist/utils/fetch.d.ts +5 -1
  89. package/dist/utils/fetch.d.ts.map +1 -1
  90. package/dist/utils/fetch.js +8 -4
  91. package/dist/utils/fetch.js.map +1 -1
  92. package/dist/utils/fetch.mjs +8 -4
  93. package/dist/utils/fetch.mjs.map +1 -1
  94. package/dist/utils/transform-content-types-to-models.d.ts +197 -0
  95. package/dist/utils/transform-content-types-to-models.d.ts.map +1 -1
  96. package/package.json +19 -15
  97. package/dist/core-api/routes/validation/common.d.ts +0 -135
  98. package/dist/core-api/routes/validation/common.d.ts.map +0 -1
  99. package/dist/core-api/routes/validation/common.js +0 -201
  100. package/dist/core-api/routes/validation/common.js.map +0 -1
  101. package/dist/core-api/routes/validation/common.mjs +0 -198
  102. package/dist/core-api/routes/validation/common.mjs.map +0 -1
  103. package/dist/core-api/routes/validation/component.d.ts +0 -42
  104. package/dist/core-api/routes/validation/component.d.ts.map +0 -1
  105. package/dist/core-api/routes/validation/content-type.d.ts +0 -139
  106. package/dist/core-api/routes/validation/content-type.d.ts.map +0 -1
  107. package/dist/core-api/routes/validation/content-type.js +0 -176
  108. package/dist/core-api/routes/validation/content-type.js.map +0 -1
  109. package/dist/core-api/routes/validation/content-type.mjs +0 -174
  110. package/dist/core-api/routes/validation/content-type.mjs.map +0 -1
  111. package/dist/core-api/routes/validation/index.d.ts +0 -4
  112. package/dist/core-api/routes/validation/index.d.ts.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"common.mjs","sources":["../../../../src/core-api/routes/validation/common.ts"],"sourcesContent":["import { type Core, Schema, type UID } from '@strapi/types';\nimport { contentTypes, relations } from '@strapi/utils';\nimport { z } from 'zod';\n\n/**\n * AbstractCoreRouteValidator provides the foundation for validating and managing core routes within a Strapi context for a specific model.\n *\n * This abstract class facilitates validation logic for scalar and populatable fields defined in a model schema.\n *\n * It uses runtime information about Strapi models to derive and expose schema validations.\n *\n * @template {UID.Schema} T Representing the schema identifier to be validated.\n */\nexport abstract class AbstractCoreRouteValidator<T extends UID.Schema> {\n /**\n * The `_strapi` variable serves as a reference to the core Strapi instance.\n * It is used for interacting with the loaded model.\n */\n protected readonly _strapi: Core.Strapi;\n\n /**\n * A unique identifier used to represent a model within Strapi.\n *\n * The type of the identifier is generic to allow flexibility and ensure type safety\n * when working with either content-types or components.\n */\n protected readonly _uid: T;\n\n /**\n * Protected constructor for initializing the class with the provided Strapi instance and unique identifier (UID).\n *\n * @param strapi The Strapi instance to be used.\n * @param uid The unique identifier for the instance.\n */\n protected constructor(strapi: Core.Strapi, uid: T) {\n this._strapi = strapi;\n this._uid = uid;\n }\n\n /**\n * Retrieves an enum schema constructed from the keys of the scalar fields.\n *\n * @return A Zod enum containing the keys from the scalar fields.\n */\n public get scalarFieldsEnum() {\n return z.enum(Object.keys(this._scalarFields) as [string]);\n }\n\n /**\n * Retrieves an enum schema constructed from the keys of fields that can be populated (relations, components, files, etc.)\n *\n * @return A ZodEnum object containing the list of populatable field keys.\n */\n public get populatableFieldsEnum() {\n return z.enum(Object.keys(this._populatableFields) as [string]);\n }\n\n /**\n * Retrieves an array representation of the scalar fields.\n *\n * @return An array containing the scalar fields as defined by {@link scalarFieldsEnum}.\n */\n public get scalarFieldsArray() {\n return z.array(this.scalarFieldsEnum);\n }\n\n /**\n * Retrieves an array of populatable fields.\n *\n * @return A Zod array schema representing the available populatable fields as defined by {@link populatableFieldsEnum}.\n */\n public get populatableFieldsArray() {\n return z.array(this.populatableFieldsEnum);\n }\n\n /**\n * Retrieves the schema associated with the current model.\n *\n * The schema represents the structural definition of the model,\n * as retrieved from the Strapi model associated with the given UID.\n *\n * @return The schema of the model retrieved from Strapi.\n */\n protected get _schema() {\n return this._strapi.getModel(this._uid);\n }\n\n /**\n * Retrieves scalar fields from the object's schema attributes.\n *\n * Filters the schema attributes to include only those that are scalar and not private.\n *\n * @return An object composed of scalar fields from the schema attributes.\n */\n protected get _scalarFields() {\n const attributes = Object.entries(this._schema.attributes);\n\n const scalarEntries = attributes\n .filter(([, attribute]) => contentTypes.isScalarAttribute(attribute))\n .filter(([attributeName]) => !contentTypes.isPrivateAttribute(this._schema, attributeName));\n\n return Object.fromEntries(scalarEntries);\n }\n\n /**\n * Retrieves the populatable fields from the schema attributes.\n *\n * Filters the schema attributes to include only those that are populatable and not private.\n *\n * @return An object containing the populatable fields derived from the schema attributes.\n */\n protected get _populatableFields() {\n const attributes = Object.entries(this._schema.attributes);\n\n const populatableEntries = attributes\n .filter(([, attribute]) => !contentTypes.isScalarAttribute(attribute))\n .filter(([attributeName]) => !contentTypes.isPrivateAttribute(this._schema, attributeName));\n\n return Object.fromEntries(populatableEntries);\n }\n\n /**\n * Creates a Zod schema as a record with scalar fields as keys and the specified type as values.\n *\n * @param type - The Zod type to use for the record's values.\n * @return A Zod record schema with scalar fields as keys and the specified type as values.\n */\n public fieldRecord(type: z.ZodTypeAny) {\n return z.record(this.scalarFieldsEnum, type);\n }\n}\n\n/**\n * Maps a Strapi attribute definition to a corresponding Zod validation schema.\n * This function handles various 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 = mapAttributeToSchema(stringAttribute);\n *\n * // Enumeration attribute\n * const enumAttribute = {\n * type: 'enumeration',\n * enum: ['draft', 'published', 'archived']\n * };\n * const enumSchema = mapAttributeToSchema(enumAttribute);\n *\n * // Media attribute with multiple files\n * const mediaAttribute = {\n * type: 'media',\n * multiple: true\n * };\n * const mediaSchema = mapAttributeToSchema(mediaAttribute);\n * ```\n *\n * @throws {Error} Throws an error if an unsupported attribute type is provided\n *\n * @remarks\n * - Complex types (component, relation, dynamic zone) use placeholder schemas\n */\nexport const mapAttributeToSchema = (attribute: Schema.Attribute.AnyAttribute): z.Schema => {\n switch (attribute.type) {\n case 'string':\n case 'text':\n case 'richtext': {\n const { minLength, maxLength, required, default: def } = attribute;\n\n return [z.string()]\n .map((schema) => (minLength !== undefined ? schema.min(minLength) : schema))\n .map((schema) => (maxLength !== undefined ? schema.max(maxLength) : schema))\n .map((schema) => (required ? schema : schema.optional()))\n .map((schema) => {\n if (typeof def === 'undefined') {\n return schema;\n }\n\n // Needed to infer the type and target the correct schema.default() version\n return typeof def === 'function' ? schema.default(def) : schema.default(def);\n })[0];\n }\n case 'blocks':\n return z.string();\n case 'float':\n return z.number().describe(`A float field`);\n case 'decimal':\n return z.number().describe(`A decimal field`);\n case 'biginteger':\n return z.number().describe(`A biginteger field`);\n case 'integer':\n return z.number().int().describe(`An integer field`);\n case 'boolean':\n return z.boolean().describe(`A boolean field`);\n case 'date':\n case 'datetime':\n case 'timestamp':\n case 'time':\n return z.string().datetime().describe(`A date field`);\n case 'email':\n return z.string().email().describe(`An email field`);\n case 'enumeration':\n return z\n .enum(attribute.enum as [string])\n .describe(`An enumeration field with possible values: ${attribute.enum.join(', ')}`);\n case 'component': {\n const schema = z.any().describe('imagine this is a component');\n\n return attribute.repeatable ? z.array(schema) : schema.nullable();\n }\n case 'relation': {\n const schema = z.any().describe(`A related document`);\n\n return relations.isAnyToMany(attribute) ? z.array(schema) : schema.nullable();\n }\n case 'dynamiczone':\n return z.array(z.any()).describe('Imagine this is a dynamic zone').nullable();\n case 'json':\n return z.any().describe(`A JSON field`);\n case 'uid':\n return z.string().describe(`A unique identifier (UID) field`);\n case 'password':\n return z.string().describe(`A password field`);\n case 'media': {\n const schema = z.any().describe(`A media field`);\n\n return attribute.multiple ? z.array(schema) : schema.nullable();\n }\n default:\n throw new Error(`Unsupported attribute type: ${attribute['type']}`);\n }\n};\n"],"names":["AbstractCoreRouteValidator","scalarFieldsEnum","z","enum","Object","keys","_scalarFields","populatableFieldsEnum","_populatableFields","scalarFieldsArray","array","populatableFieldsArray","_schema","_strapi","getModel","_uid","attributes","entries","scalarEntries","filter","attribute","contentTypes","isScalarAttribute","attributeName","isPrivateAttribute","fromEntries","populatableEntries","fieldRecord","type","record","strapi","uid","mapAttributeToSchema","minLength","maxLength","required","default","def","string","map","schema","undefined","min","max","optional","number","describe","int","boolean","datetime","email","join","any","repeatable","nullable","relations","isAnyToMany","multiple","Error"],"mappings":";;;AAIA;;;;;;;;AAQC,IACM,MAAeA,0BAAAA,CAAAA;AA0BpB;;;;AAIC,MACD,IAAWC,gBAAmB,GAAA;QAC5B,OAAOC,CAAAA,CAAEC,IAAI,CAACC,MAAAA,CAAOC,IAAI,CAAC,IAAI,CAACC,aAAa,CAAA,CAAA;AAC9C;AAEA;;;;AAIC,MACD,IAAWC,qBAAwB,GAAA;QACjC,OAAOL,CAAAA,CAAEC,IAAI,CAACC,MAAAA,CAAOC,IAAI,CAAC,IAAI,CAACG,kBAAkB,CAAA,CAAA;AACnD;AAEA;;;;AAIC,MACD,IAAWC,iBAAoB,GAAA;AAC7B,QAAA,OAAOP,CAAEQ,CAAAA,KAAK,CAAC,IAAI,CAACT,gBAAgB,CAAA;AACtC;AAEA;;;;AAIC,MACD,IAAWU,sBAAyB,GAAA;AAClC,QAAA,OAAOT,CAAEQ,CAAAA,KAAK,CAAC,IAAI,CAACH,qBAAqB,CAAA;AAC3C;AAEA;;;;;;;AAOC,MACD,IAAc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A,GAAStC,EAAEkD,GAAG,EAAA,CAAGN,QAAQ,CAAC,CAAC,kBAAkB,CAAC,CAAA;gBAEpD,OAAOS,SAAAA,CAAUC,WAAW,CAACpC,SAAAA,CAAAA,GAAalB,EAAEQ,KAAK,CAAC8B,MAAUA,CAAAA,GAAAA,MAAAA,CAAOc,QAAQ,EAAA;AAC7E;QACA,KAAK,aAAA;YACH,OAAOpD,CAAAA,CAAEQ,KAAK,CAACR,CAAAA,CAAEkD,GAAG,EAAIN,CAAAA,CAAAA,QAAQ,CAAC,gCAAA,CAAA,CAAkCQ,QAAQ,EAAA;QAC7E,KAAK,MAAA;AACH,YAAA,OAAOpD,EAAEkD,GAAG,EAAA,CAAGN,QAAQ,CAAC,CAAC,YAAY,CAAC,CAAA;QACxC,KAAK,KAAA;AACH,YAAA,OAAO5C,EAAEoC,MAAM,EAAA,CAAGQ,QAAQ,CAAC,CAAC,+BAA+B,CAAC,CAAA;QAC9D,KAAK,UAAA;AACH,YAAA,OAAO5C,EAAEoC,MAAM,EAAA,CAAGQ,QAAQ,CAAC,CAAC,gBAAgB,CAAC,CAAA;QAC/C,KAAK,OAAA;AAAS,YAAA;gBACZ,MAAMN,MAAAA,GAAStC,EAAEkD,GAAG,EAAA,CAAGN,QAAQ,CAAC,CAAC,aAAa,CAAC,CAAA;gBAE/C,OAAO1B,SAAAA,CAAUqC,QAAQ,GAAGvD,CAAAA,CAAEQ,KAAK,CAAC8B,MAAAA,CAAAA,GAAUA,OAAOc,QAAQ,EAAA;AAC/D;AACA,QAAA;YACE,MAAM,IAAII,MAAM,CAAC,4BAA4B,EAAEtC,SAAS,CAAC,MAAO,CAAA,CAAC,CAAC,CAAA;AACtE;AACF;;;;"}
@@ -1,42 +0,0 @@
1
- import type { Core, UID } from '@strapi/types';
2
- import { z } from 'zod';
3
- import { AbstractCoreRouteValidator } from './common';
4
- /**
5
- * A component validator for core content-type routes.
6
- *
7
- * Provides validation schemas and utilities for handling component-specific validation in content-type routes.
8
- *
9
- * @example
10
- * ```ts
11
- * const strapi = // ... strapi instance
12
- * const uid = 'api::article.article'
13
- * const validator = new CoreComponentRouteValidator(strapi, uid);
14
- *
15
- * // Get validation schema for a component entry
16
- * const componentSchema = validator.component;
17
- * ```
18
- */
19
- export declare class CoreComponentRouteValidator extends AbstractCoreRouteValidator<UID.Component> {
20
- /**
21
- * Creates a new instance of CoreComponentRouteValidator
22
- *
23
- * @param strapi - The Strapi instance
24
- * @param uid - The component's unique identifier
25
- */
26
- constructor(strapi: Core.Strapi, uid: UID.Component);
27
- /**
28
- * Generates a comprehensive validation schema for a single component entry.
29
- *
30
- * Combines scalar fields and populatable fields into a single schema.
31
- *
32
- * @returns A schema for validating complete entries
33
- *
34
- * @example
35
- * ```ts
36
- * const validator = new CoreComponentRouteValidator(strapi, uid);
37
- * const entrySchema = validator.entry;
38
- * ```
39
- */
40
- get entry(): z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
41
- }
42
- //# sourceMappingURL=component.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../../src/core-api/routes/validation/component.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,0BAA0B,EAAwB,MAAM,UAAU,CAAC;AAE5E;;;;;;;;;;;;;;GAcG;AACH,qBAAa,2BAA4B,SAAQ,0BAA0B,CAAC,GAAG,CAAC,SAAS,CAAC;IACxF;;;;;OAKG;gBACS,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,SAAS;IAInD;;;;;;;;;;;;OAYG;IACH,IAAI,KAAK,mDAQR;CACF"}
@@ -1,139 +0,0 @@
1
- import type { Core, UID } from '@strapi/types';
2
- import { z } from 'zod';
3
- import { AbstractCoreRouteValidator } from './common';
4
- type QueryParam = 'fields' | 'populate' | 'sort';
5
- /**
6
- * A validator for core content-type routes.
7
- *
8
- * Provides validation schemas and utilities for handling content-type-specific route validation.
9
- *
10
- * @example
11
- * ```ts
12
- * const strapi = // ... strapi instance
13
- * const uid = 'api::article.article'
14
- * const validator = new CoreContentTypeRouteValidator(strapi, uid);
15
- *
16
- * // Get validation schema for document
17
- * const documentSchema = validator.document;
18
- *
19
- * // Validate query parameters
20
- * const querySchema = validator.query(['fields', 'populate', 'sort']);
21
- * ```
22
- */
23
- export declare class CoreContentTypeRouteValidator extends AbstractCoreRouteValidator<UID.ContentType> {
24
- /**
25
- * Creates a new instance of CoreContentTypeRouteValidator
26
- *
27
- * @param strapi - The Strapi instance
28
- * @param uid - The content-type's unique identifier
29
- */
30
- constructor(strapi: Core.Strapi, uid: UID.ContentType);
31
- /**
32
- * Generates a validation schema for document IDs
33
- *
34
- * @returns A schema that validates UUIDs
35
- *
36
- * @example
37
- * ```ts
38
- * const validator = new CoreContentTypeRouteValidator(strapi, uid);
39
- * const idSchema = validator.documentID;
40
- * ```
41
- */
42
- get documentID(): z.ZodString;
43
- /**
44
- * Generates a comprehensive validation schema for a single document.
45
- *
46
- * Combines scalar fields and populatable fields into a single schema.
47
- *
48
- * @returns A schema for validating complete documents
49
- *
50
- * @example
51
- * ```ts
52
- * const validator = new CoreContentTypeRouteValidator(strapi, uid);
53
- * const docSchema = validator.document;
54
- * ```
55
- */
56
- get document(): z.ZodObject<{
57
- documentId: z.ZodString;
58
- }, "strip", z.ZodTypeAny, {
59
- documentId: string;
60
- }, {
61
- documentId: string;
62
- }>;
63
- /**
64
- * Generates a validation schema for an array of documents
65
- *
66
- * @returns A schema for validating arrays of documents
67
- *
68
- * @example
69
- * ```ts
70
- * const validator = new CoreContentTypeRouteValidator(strapi, uid);
71
- * const docsSchema = validator.documents;
72
- * ```
73
- */
74
- get documents(): z.ZodArray<z.ZodObject<{
75
- documentId: z.ZodString;
76
- }, "strip", z.ZodTypeAny, {
77
- documentId: string;
78
- }, {
79
- documentId: string;
80
- }>, "many">;
81
- /**
82
- * Creates validation schemas for query parameters
83
- *
84
- * @param params - Array of query parameters to validate ('fields', 'populate', 'sort', ...)
85
- * @returns Object containing validation schemas for requested parameters
86
- *
87
- * @example
88
- * ```ts
89
- * const validator = new CoreContentTypeRouteValidator(strapi, uid);
90
- * const querySchemas = validator.query(['fields', 'populate']);
91
- * ```
92
- */
93
- query(params: QueryParam[]): Partial<Record<QueryParam, z.Schema>>;
94
- /**
95
- * Generates a validation schema for field selection in queries
96
- *
97
- * @returns A schema for validating field selection
98
- *
99
- * @example
100
- * ```ts
101
- * const validator = new CoreContentTypeRouteValidator(strapi, uid);
102
- * const fieldsSchema = validator.queryFields;
103
- * ```
104
- */
105
- get queryFields(): z.ZodReadonly<z.ZodArray<z.ZodEnum<[string]>, "many">>;
106
- /**
107
- * Generates a validation schema for populate operations.
108
- *
109
- * Allows wildcard (*), single field, and multiple field population.
110
- *
111
- * @returns A schema for validating populate parameters
112
- *
113
- * @example
114
- * ```ts
115
- * const validator = new CoreContentTypeRouteValidator(strapi, uid);
116
- * const populateSchema = validator.queryPopulate;
117
- * ```
118
- */
119
- get queryPopulate(): z.ZodUnion<[z.ZodReadonly<z.ZodLiteral<"*">>, z.ZodReadonly<z.ZodEnum<[string]>>, z.ZodArray<z.ZodEnum<[string]>, "many">]>;
120
- /**
121
- * Generates a validation schema for sorting parameters.
122
- *
123
- * Allows various sorting formats including single field, multiple fields, and direction specifications
124
- *
125
- * @returns A schema for validating sort parameters
126
- *
127
- * @example
128
- * ```ts
129
- * const validator = new CoreContentTypeRouteValidator(strapi, uid);
130
- * const sortSchema = validator.querySort;
131
- * ```
132
- *
133
- * @remarks
134
- * - Nested sorts are currently not supported
135
- */
136
- get querySort(): z.ZodOptional<z.ZodUnion<[z.ZodEnum<[string]>, z.ZodArray<z.ZodEnum<[string]>, "many">, z.ZodRecord<z.ZodEnum<[string]>, z.ZodTypeAny>, z.ZodArray<z.ZodRecord<z.ZodEnum<[string]>, z.ZodTypeAny>, "many">]>>;
137
- }
138
- export {};
139
- //# sourceMappingURL=content-type.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"content-type.d.ts","sourceRoot":"","sources":["../../../../src/core-api/routes/validation/content-type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,0BAA0B,EAAwB,MAAM,UAAU,CAAC;AAE5E,KAAK,UAAU,GAAG,QAAQ,GAAG,UAAU,GAAG,MAAM,CAAC;AAEjD;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,6BAA8B,SAAQ,0BAA0B,CAAC,GAAG,CAAC,WAAW,CAAC;IAC5F;;;;;OAKG;gBACS,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,WAAW;IAIrD;;;;;;;;;;OAUG;IACH,IAAI,UAAU,gBAEb;IAED;;;;;;;;;;;;OAYG;IACH,IAAI,QAAQ;;;;;;OAYX;IAED;;;;;;;;;;OAUG;IACH,IAAI,SAAS;;;;;;gBAEZ;IAED;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;IAalE;;;;;;;;;;OAUG;IACH,IAAI,WAAW,2DAMd;IAED;;;;;;;;;;;;OAYG;IACH,IAAI,aAAa,gIAiBhB;IAED;;;;;;;;;;;;;;;OAeG;IACH,IAAI,SAAS,kNAgBZ;CACF"}
@@ -1,176 +0,0 @@
1
- 'use strict';
2
-
3
- var zod = require('zod');
4
- var common = require('./common.js');
5
-
6
- /**
7
- * A validator for core content-type routes.
8
- *
9
- * Provides validation schemas and utilities for handling content-type-specific route validation.
10
- *
11
- * @example
12
- * ```ts
13
- * const strapi = // ... strapi instance
14
- * const uid = 'api::article.article'
15
- * const validator = new CoreContentTypeRouteValidator(strapi, uid);
16
- *
17
- * // Get validation schema for document
18
- * const documentSchema = validator.document;
19
- *
20
- * // Validate query parameters
21
- * const querySchema = validator.query(['fields', 'populate', 'sort']);
22
- * ```
23
- */ class CoreContentTypeRouteValidator extends common.AbstractCoreRouteValidator {
24
- /**
25
- * Generates a validation schema for document IDs
26
- *
27
- * @returns A schema that validates UUIDs
28
- *
29
- * @example
30
- * ```ts
31
- * const validator = new CoreContentTypeRouteValidator(strapi, uid);
32
- * const idSchema = validator.documentID;
33
- * ```
34
- */ get documentID() {
35
- return zod.z.string().uuid().describe('The document ID, represented by a UUID');
36
- }
37
- /**
38
- * Generates a comprehensive validation schema for a single document.
39
- *
40
- * Combines scalar fields and populatable fields into a single schema.
41
- *
42
- * @returns A schema for validating complete documents
43
- *
44
- * @example
45
- * ```ts
46
- * const validator = new CoreContentTypeRouteValidator(strapi, uid);
47
- * const docSchema = validator.document;
48
- * ```
49
- */ get document() {
50
- const { _scalarFields, _populatableFields } = this;
51
- const entries = Object.entries({
52
- ..._scalarFields,
53
- ..._populatableFields
54
- });
55
- const attributesSchema = entries.reduce((acc, [attributeName, attribute])=>{
56
- return acc.merge(zod.z.object({
57
- [attributeName]: common.mapAttributeToSchema(attribute)
58
- }));
59
- }, zod.z.object({}));
60
- const defaultSchema = zod.z.object({
61
- documentId: this.documentID
62
- });
63
- return defaultSchema.merge(attributesSchema);
64
- }
65
- /**
66
- * Generates a validation schema for an array of documents
67
- *
68
- * @returns A schema for validating arrays of documents
69
- *
70
- * @example
71
- * ```ts
72
- * const validator = new CoreContentTypeRouteValidator(strapi, uid);
73
- * const docsSchema = validator.documents;
74
- * ```
75
- */ get documents() {
76
- return zod.z.array(this.document);
77
- }
78
- /**
79
- * Creates validation schemas for query parameters
80
- *
81
- * @param params - Array of query parameters to validate ('fields', 'populate', 'sort', ...)
82
- * @returns Object containing validation schemas for requested parameters
83
- *
84
- * @example
85
- * ```ts
86
- * const validator = new CoreContentTypeRouteValidator(strapi, uid);
87
- * const querySchemas = validator.query(['fields', 'populate']);
88
- * ```
89
- */ query(params) {
90
- const map = {
91
- fields: ()=>this.queryFields,
92
- populate: ()=>this.queryPopulate,
93
- sort: ()=>this.querySort
94
- };
95
- return params.reduce((acc, param)=>({
96
- ...acc,
97
- [param]: map[param]()
98
- }), {});
99
- }
100
- /**
101
- * Generates a validation schema for field selection in queries
102
- *
103
- * @returns A schema for validating field selection
104
- *
105
- * @example
106
- * ```ts
107
- * const validator = new CoreContentTypeRouteValidator(strapi, uid);
108
- * const fieldsSchema = validator.queryFields;
109
- * ```
110
- */ get queryFields() {
111
- return this.scalarFieldsArray.readonly().describe(`The fields to return, this doesn't include populatable fields like relations, components, files, or dynamic zones`);
112
- }
113
- /**
114
- * Generates a validation schema for populate operations.
115
- *
116
- * Allows wildcard (*), single field, and multiple field population.
117
- *
118
- * @returns A schema for validating populate parameters
119
- *
120
- * @example
121
- * ```ts
122
- * const validator = new CoreContentTypeRouteValidator(strapi, uid);
123
- * const populateSchema = validator.queryPopulate;
124
- * ```
125
- */ get queryPopulate() {
126
- const wildcardPopulate = zod.z.literal('*').readonly().describe('Populate all the first level relations, components, files, and dynamic zones for the entry');
127
- const singleFieldPopulate = this.populatableFieldsEnum.readonly().describe('Populate a single relation, component, file, or dynamic zone');
128
- const multiPopulate = this.populatableFieldsArray.describe('Populate a selection of multiple relations, components, files, or dynamic zones');
129
- return zod.z.union([
130
- wildcardPopulate,
131
- singleFieldPopulate,
132
- multiPopulate
133
- ]);
134
- }
135
- /**
136
- * Generates a validation schema for sorting parameters.
137
- *
138
- * Allows various sorting formats including single field, multiple fields, and direction specifications
139
- *
140
- * @returns A schema for validating sort parameters
141
- *
142
- * @example
143
- * ```ts
144
- * const validator = new CoreContentTypeRouteValidator(strapi, uid);
145
- * const sortSchema = validator.querySort;
146
- * ```
147
- *
148
- * @remarks
149
- * - Nested sorts are currently not supported
150
- */ get querySort() {
151
- const orderDirection = zod.z.enum([
152
- 'asc',
153
- 'desc'
154
- ]);
155
- // TODO: Handle nested sorts but very low priority, very little usage
156
- return zod.z.union([
157
- this.scalarFieldsEnum,
158
- this.scalarFieldsArray,
159
- this.fieldRecord(orderDirection),
160
- zod.z.array(this.fieldRecord(orderDirection))
161
- ], {
162
- description: 'Sort Union'
163
- }).optional().describe('Sort the result');
164
- }
165
- /**
166
- * Creates a new instance of CoreContentTypeRouteValidator
167
- *
168
- * @param strapi - The Strapi instance
169
- * @param uid - The content-type's unique identifier
170
- */ constructor(strapi, uid){
171
- super(strapi, uid);
172
- }
173
- }
174
-
175
- exports.CoreContentTypeRouteValidator = CoreContentTypeRouteValidator;
176
- //# sourceMappingURL=content-type.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"content-type.js","sources":["../../../../src/core-api/routes/validation/content-type.ts"],"sourcesContent":["import type { Core, UID } from '@strapi/types';\nimport { z } from 'zod';\n\nimport { AbstractCoreRouteValidator, mapAttributeToSchema } from './common';\n\ntype QueryParam = 'fields' | 'populate' | 'sort';\n\n/**\n * A validator for core content-type routes.\n *\n * Provides validation schemas and utilities for handling content-type-specific route validation.\n *\n * @example\n * ```ts\n * const strapi = // ... strapi instance\n * const uid = 'api::article.article'\n * const validator = new CoreContentTypeRouteValidator(strapi, uid);\n *\n * // Get validation schema for document\n * const documentSchema = validator.document;\n *\n * // Validate query parameters\n * const querySchema = validator.query(['fields', 'populate', 'sort']);\n * ```\n */\nexport class CoreContentTypeRouteValidator extends AbstractCoreRouteValidator<UID.ContentType> {\n /**\n * Creates a new instance of CoreContentTypeRouteValidator\n *\n * @param strapi - The Strapi instance\n * @param uid - The content-type's unique identifier\n */\n constructor(strapi: Core.Strapi, uid: UID.ContentType) {\n super(strapi, uid);\n }\n\n /**\n * Generates a validation schema for document IDs\n *\n * @returns A schema that validates UUIDs\n *\n * @example\n * ```ts\n * const validator = new CoreContentTypeRouteValidator(strapi, uid);\n * const idSchema = validator.documentID;\n * ```\n */\n get documentID() {\n return z.string().uuid().describe('The document ID, represented by a UUID');\n }\n\n /**\n * Generates a comprehensive validation schema for a single document.\n *\n * Combines scalar fields and populatable fields into a single schema.\n *\n * @returns A schema for validating complete documents\n *\n * @example\n * ```ts\n * const validator = new CoreContentTypeRouteValidator(strapi, uid);\n * const docSchema = validator.document;\n * ```\n */\n get document() {\n const { _scalarFields, _populatableFields } = this;\n\n const entries = Object.entries({ ..._scalarFields, ..._populatableFields });\n\n const attributesSchema = entries.reduce((acc, [attributeName, attribute]) => {\n return acc.merge(z.object({ [attributeName]: mapAttributeToSchema(attribute) }));\n }, z.object({}));\n\n const defaultSchema = z.object({ documentId: this.documentID });\n\n return defaultSchema.merge(attributesSchema);\n }\n\n /**\n * Generates a validation schema for an array of documents\n *\n * @returns A schema for validating arrays of documents\n *\n * @example\n * ```ts\n * const validator = new CoreContentTypeRouteValidator(strapi, uid);\n * const docsSchema = validator.documents;\n * ```\n */\n get documents() {\n return z.array(this.document);\n }\n\n /**\n * Creates validation schemas for query parameters\n *\n * @param params - Array of query parameters to validate ('fields', 'populate', 'sort', ...)\n * @returns Object containing validation schemas for requested parameters\n *\n * @example\n * ```ts\n * const validator = new CoreContentTypeRouteValidator(strapi, uid);\n * const querySchemas = validator.query(['fields', 'populate']);\n * ```\n */\n query(params: QueryParam[]): Partial<Record<QueryParam, z.Schema>> {\n const map = {\n fields: () => this.queryFields,\n populate: () => this.queryPopulate,\n sort: () => this.querySort,\n };\n\n return params.reduce(\n (acc, param) => ({ ...acc, [param]: map[param]() }),\n {} as Partial<Record<QueryParam, z.Schema>>\n );\n }\n\n /**\n * Generates a validation schema for field selection in queries\n *\n * @returns A schema for validating field selection\n *\n * @example\n * ```ts\n * const validator = new CoreContentTypeRouteValidator(strapi, uid);\n * const fieldsSchema = validator.queryFields;\n * ```\n */\n get queryFields() {\n return this.scalarFieldsArray\n .readonly()\n .describe(\n `The fields to return, this doesn't include populatable fields like relations, components, files, or dynamic zones`\n );\n }\n\n /**\n * Generates a validation schema for populate operations.\n *\n * Allows wildcard (*), single field, and multiple field population.\n *\n * @returns A schema for validating populate parameters\n *\n * @example\n * ```ts\n * const validator = new CoreContentTypeRouteValidator(strapi, uid);\n * const populateSchema = validator.queryPopulate;\n * ```\n */\n get queryPopulate() {\n const wildcardPopulate = z\n .literal('*')\n .readonly()\n .describe(\n 'Populate all the first level relations, components, files, and dynamic zones for the entry'\n );\n\n const singleFieldPopulate = this.populatableFieldsEnum\n .readonly()\n .describe('Populate a single relation, component, file, or dynamic zone');\n\n const multiPopulate = this.populatableFieldsArray.describe(\n 'Populate a selection of multiple relations, components, files, or dynamic zones'\n );\n\n return z.union([wildcardPopulate, singleFieldPopulate, multiPopulate]);\n }\n\n /**\n * Generates a validation schema for sorting parameters.\n *\n * Allows various sorting formats including single field, multiple fields, and direction specifications\n *\n * @returns A schema for validating sort parameters\n *\n * @example\n * ```ts\n * const validator = new CoreContentTypeRouteValidator(strapi, uid);\n * const sortSchema = validator.querySort;\n * ```\n *\n * @remarks\n * - Nested sorts are currently not supported\n */\n get querySort() {\n const orderDirection = z.enum(['asc', 'desc']);\n\n // TODO: Handle nested sorts but very low priority, very little usage\n return z\n .union(\n [\n this.scalarFieldsEnum, // 'name' | 'title'\n this.scalarFieldsArray, // ['name', 'title']\n this.fieldRecord(orderDirection), // { name: 'desc' } | { title: 'asc' }\n z.array(this.fieldRecord(orderDirection)), // [{ name: 'desc'}, { title: 'asc' }]\n ],\n { description: 'Sort Union' }\n )\n .optional()\n .describe('Sort the result');\n }\n}\n"],"names":["CoreContentTypeRouteValidator","AbstractCoreRouteValidator","documentID","z","string","uuid","describe","document","_scalarFields","_populatableFields","entries","Object","attributesSchema","reduce","acc","attributeName","attribute","merge","object","mapAttributeToSchema","defaultSchema","documentId","documents","array","query","params","map","fields","queryFields","populate","queryPopulate","sort","querySort","param","scalarFieldsArray","readonly","wildcardPopulate","literal","singleFieldPopulate","populatableFieldsEnum","multiPopulate","populatableFieldsArray","union","orderDirection","enum","scalarField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AAA,CAAEoB,KAAK,CAAC,IAAI,CAACuB,WAAW,CAACH,cAAAA,CAAAA;SAC1B,EACD;YAAEI,WAAa,EAAA;SAEhBC,CAAAA,CAAAA,QAAQ,EACR1C,CAAAA,QAAQ,CAAC,iBAAA,CAAA;AACd;AA/KA;;;;;AAKC,MACD2C,WAAYC,CAAAA,MAAmB,EAAEC,GAAoB,CAAE;AACrD,QAAA,KAAK,CAACD,MAAQC,EAAAA,GAAAA,CAAAA;AAChB;AAwKF;;;;"}
@@ -1,174 +0,0 @@
1
- import { z } from 'zod';
2
- import { AbstractCoreRouteValidator, mapAttributeToSchema } from './common.mjs';
3
-
4
- /**
5
- * A validator for core content-type routes.
6
- *
7
- * Provides validation schemas and utilities for handling content-type-specific route validation.
8
- *
9
- * @example
10
- * ```ts
11
- * const strapi = // ... strapi instance
12
- * const uid = 'api::article.article'
13
- * const validator = new CoreContentTypeRouteValidator(strapi, uid);
14
- *
15
- * // Get validation schema for document
16
- * const documentSchema = validator.document;
17
- *
18
- * // Validate query parameters
19
- * const querySchema = validator.query(['fields', 'populate', 'sort']);
20
- * ```
21
- */ class CoreContentTypeRouteValidator extends AbstractCoreRouteValidator {
22
- /**
23
- * Generates a validation schema for document IDs
24
- *
25
- * @returns A schema that validates UUIDs
26
- *
27
- * @example
28
- * ```ts
29
- * const validator = new CoreContentTypeRouteValidator(strapi, uid);
30
- * const idSchema = validator.documentID;
31
- * ```
32
- */ get documentID() {
33
- return z.string().uuid().describe('The document ID, represented by a UUID');
34
- }
35
- /**
36
- * Generates a comprehensive validation schema for a single document.
37
- *
38
- * Combines scalar fields and populatable fields into a single schema.
39
- *
40
- * @returns A schema for validating complete documents
41
- *
42
- * @example
43
- * ```ts
44
- * const validator = new CoreContentTypeRouteValidator(strapi, uid);
45
- * const docSchema = validator.document;
46
- * ```
47
- */ get document() {
48
- const { _scalarFields, _populatableFields } = this;
49
- const entries = Object.entries({
50
- ..._scalarFields,
51
- ..._populatableFields
52
- });
53
- const attributesSchema = entries.reduce((acc, [attributeName, attribute])=>{
54
- return acc.merge(z.object({
55
- [attributeName]: mapAttributeToSchema(attribute)
56
- }));
57
- }, z.object({}));
58
- const defaultSchema = z.object({
59
- documentId: this.documentID
60
- });
61
- return defaultSchema.merge(attributesSchema);
62
- }
63
- /**
64
- * Generates a validation schema for an array of documents
65
- *
66
- * @returns A schema for validating arrays of documents
67
- *
68
- * @example
69
- * ```ts
70
- * const validator = new CoreContentTypeRouteValidator(strapi, uid);
71
- * const docsSchema = validator.documents;
72
- * ```
73
- */ get documents() {
74
- return z.array(this.document);
75
- }
76
- /**
77
- * Creates validation schemas for query parameters
78
- *
79
- * @param params - Array of query parameters to validate ('fields', 'populate', 'sort', ...)
80
- * @returns Object containing validation schemas for requested parameters
81
- *
82
- * @example
83
- * ```ts
84
- * const validator = new CoreContentTypeRouteValidator(strapi, uid);
85
- * const querySchemas = validator.query(['fields', 'populate']);
86
- * ```
87
- */ query(params) {
88
- const map = {
89
- fields: ()=>this.queryFields,
90
- populate: ()=>this.queryPopulate,
91
- sort: ()=>this.querySort
92
- };
93
- return params.reduce((acc, param)=>({
94
- ...acc,
95
- [param]: map[param]()
96
- }), {});
97
- }
98
- /**
99
- * Generates a validation schema for field selection in queries
100
- *
101
- * @returns A schema for validating field selection
102
- *
103
- * @example
104
- * ```ts
105
- * const validator = new CoreContentTypeRouteValidator(strapi, uid);
106
- * const fieldsSchema = validator.queryFields;
107
- * ```
108
- */ get queryFields() {
109
- return this.scalarFieldsArray.readonly().describe(`The fields to return, this doesn't include populatable fields like relations, components, files, or dynamic zones`);
110
- }
111
- /**
112
- * Generates a validation schema for populate operations.
113
- *
114
- * Allows wildcard (*), single field, and multiple field population.
115
- *
116
- * @returns A schema for validating populate parameters
117
- *
118
- * @example
119
- * ```ts
120
- * const validator = new CoreContentTypeRouteValidator(strapi, uid);
121
- * const populateSchema = validator.queryPopulate;
122
- * ```
123
- */ get queryPopulate() {
124
- const wildcardPopulate = z.literal('*').readonly().describe('Populate all the first level relations, components, files, and dynamic zones for the entry');
125
- const singleFieldPopulate = this.populatableFieldsEnum.readonly().describe('Populate a single relation, component, file, or dynamic zone');
126
- const multiPopulate = this.populatableFieldsArray.describe('Populate a selection of multiple relations, components, files, or dynamic zones');
127
- return z.union([
128
- wildcardPopulate,
129
- singleFieldPopulate,
130
- multiPopulate
131
- ]);
132
- }
133
- /**
134
- * Generates a validation schema for sorting parameters.
135
- *
136
- * Allows various sorting formats including single field, multiple fields, and direction specifications
137
- *
138
- * @returns A schema for validating sort parameters
139
- *
140
- * @example
141
- * ```ts
142
- * const validator = new CoreContentTypeRouteValidator(strapi, uid);
143
- * const sortSchema = validator.querySort;
144
- * ```
145
- *
146
- * @remarks
147
- * - Nested sorts are currently not supported
148
- */ get querySort() {
149
- const orderDirection = z.enum([
150
- 'asc',
151
- 'desc'
152
- ]);
153
- // TODO: Handle nested sorts but very low priority, very little usage
154
- return z.union([
155
- this.scalarFieldsEnum,
156
- this.scalarFieldsArray,
157
- this.fieldRecord(orderDirection),
158
- z.array(this.fieldRecord(orderDirection))
159
- ], {
160
- description: 'Sort Union'
161
- }).optional().describe('Sort the result');
162
- }
163
- /**
164
- * Creates a new instance of CoreContentTypeRouteValidator
165
- *
166
- * @param strapi - The Strapi instance
167
- * @param uid - The content-type's unique identifier
168
- */ constructor(strapi, uid){
169
- super(strapi, uid);
170
- }
171
- }
172
-
173
- export { CoreContentTypeRouteValidator };
174
- //# sourceMappingURL=content-type.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"content-type.mjs","sources":["../../../../src/core-api/routes/validation/content-type.ts"],"sourcesContent":["import type { Core, UID } from '@strapi/types';\nimport { z } from 'zod';\n\nimport { AbstractCoreRouteValidator, mapAttributeToSchema } from './common';\n\ntype QueryParam = 'fields' | 'populate' | 'sort';\n\n/**\n * A validator for core content-type routes.\n *\n * Provides validation schemas and utilities for handling content-type-specific route validation.\n *\n * @example\n * ```ts\n * const strapi = // ... strapi instance\n * const uid = 'api::article.article'\n * const validator = new CoreContentTypeRouteValidator(strapi, uid);\n *\n * // Get validation schema for document\n * const documentSchema = validator.document;\n *\n * // Validate query parameters\n * const querySchema = validator.query(['fields', 'populate', 'sort']);\n * ```\n */\nexport class CoreContentTypeRouteValidator extends AbstractCoreRouteValidator<UID.ContentType> {\n /**\n * Creates a new instance of CoreContentTypeRouteValidator\n *\n * @param strapi - The Strapi instance\n * @param uid - The content-type's unique identifier\n */\n constructor(strapi: Core.Strapi, uid: UID.ContentType) {\n super(strapi, uid);\n }\n\n /**\n * Generates a validation schema for document IDs\n *\n * @returns A schema that validates UUIDs\n *\n * @example\n * ```ts\n * const validator = new CoreContentTypeRouteValidator(strapi, uid);\n * const idSchema = validator.documentID;\n * ```\n */\n get documentID() {\n return z.string().uuid().describe('The document ID, represented by a UUID');\n }\n\n /**\n * Generates a comprehensive validation schema for a single document.\n *\n * Combines scalar fields and populatable fields into a single schema.\n *\n * @returns A schema for validating complete documents\n *\n * @example\n * ```ts\n * const validator = new CoreContentTypeRouteValidator(strapi, uid);\n * const docSchema = validator.document;\n * ```\n */\n get document() {\n const { _scalarFields, _populatableFields } = this;\n\n const entries = Object.entries({ ..._scalarFields, ..._populatableFields });\n\n const attributesSchema = entries.reduce((acc, [attributeName, attribute]) => {\n return acc.merge(z.object({ [attributeName]: mapAttributeToSchema(attribute) }));\n }, z.object({}));\n\n const defaultSchema = z.object({ documentId: this.documentID });\n\n return defaultSchema.merge(attributesSchema);\n }\n\n /**\n * Generates a validation schema for an array of documents\n *\n * @returns A schema for validating arrays of documents\n *\n * @example\n * ```ts\n * const validator = new CoreContentTypeRouteValidator(strapi, uid);\n * const docsSchema = validator.documents;\n * ```\n */\n get documents() {\n return z.array(this.document);\n }\n\n /**\n * Creates validation schemas for query parameters\n *\n * @param params - Array of query parameters to validate ('fields', 'populate', 'sort', ...)\n * @returns Object containing validation schemas for requested parameters\n *\n * @example\n * ```ts\n * const validator = new CoreContentTypeRouteValidator(strapi, uid);\n * const querySchemas = validator.query(['fields', 'populate']);\n * ```\n */\n query(params: QueryParam[]): Partial<Record<QueryParam, z.Schema>> {\n const map = {\n fields: () => this.queryFields,\n populate: () => this.queryPopulate,\n sort: () => this.querySort,\n };\n\n return params.reduce(\n (acc, param) => ({ ...acc, [param]: map[param]() }),\n {} as Partial<Record<QueryParam, z.Schema>>\n );\n }\n\n /**\n * Generates a validation schema for field selection in queries\n *\n * @returns A schema for validating field selection\n *\n * @example\n * ```ts\n * const validator = new CoreContentTypeRouteValidator(strapi, uid);\n * const fieldsSchema = validator.queryFields;\n * ```\n */\n get queryFields() {\n return this.scalarFieldsArray\n .readonly()\n .describe(\n `The fields to return, this doesn't include populatable fields like relations, components, files, or dynamic zones`\n );\n }\n\n /**\n * Generates a validation schema for populate operations.\n *\n * Allows wildcard (*), single field, and multiple field population.\n *\n * @returns A schema for validating populate parameters\n *\n * @example\n * ```ts\n * const validator = new CoreContentTypeRouteValidator(strapi, uid);\n * const populateSchema = validator.queryPopulate;\n * ```\n */\n get queryPopulate() {\n const wildcardPopulate = z\n .literal('*')\n .readonly()\n .describe(\n 'Populate all the first level relations, components, files, and dynamic zones for the entry'\n );\n\n const singleFieldPopulate = this.populatableFieldsEnum\n .readonly()\n .describe('Populate a single relation, component, file, or dynamic zone');\n\n const multiPopulate = this.populatableFieldsArray.describe(\n 'Populate a selection of multiple relations, components, files, or dynamic zones'\n );\n\n return z.union([wildcardPopulate, singleFieldPopulate, multiPopulate]);\n }\n\n /**\n * Generates a validation schema for sorting parameters.\n *\n * Allows various sorting formats including single field, multiple fields, and direction specifications\n *\n * @returns A schema for validating sort parameters\n *\n * @example\n * ```ts\n * const validator = new CoreContentTypeRouteValidator(strapi, uid);\n * const sortSchema = validator.querySort;\n * ```\n *\n * @remarks\n * - Nested sorts are currently not supported\n */\n get querySort() {\n const orderDirection = z.enum(['asc', 'desc']);\n\n // TODO: Handle nested sorts but very low priority, very little usage\n return z\n .union(\n [\n this.scalarFieldsEnum, // 'name' | 'title'\n this.scalarFieldsArray, // ['name', 'title']\n this.fieldRecord(orderDirection), // { name: 'desc' } | { title: 'asc' }\n z.array(this.fieldRecord(orderDirection)), // [{ name: 'desc'}, { title: 'asc' }]\n ],\n { description: 'Sort Union' }\n )\n .optional()\n .describe('Sort the result');\n }\n}\n"],"names":["CoreContentTypeRouteValidator","AbstractCoreRouteValidator","documentID","z","string","uuid","describe","document","_scalarFields","_populatableFields","entries","Object","attributesSchema","reduce","acc","attributeName","attribute","merge","object","mapAttributeToSchema","defaultSchema","documentId","documents","array","query","params","map","fields","queryFields","populate","queryPopulate","sort","querySort","param","scalarFieldsArray","readonly","wildcardPopulate","literal","singleFieldPopulate","populatableFieldsEnum","multiPopulate","populatableFieldsArray","union","orderDirection","enum","scalarFieldsEnum","fieldRecord","description","optional","constructor","strapi","uid"],"mappings":";;;AAOA;;;;;;;;;;;;;;;;;IAkBO,MAAMA,6BAAsCC,SAAAA,0BAAAA,CAAAA;AAWjD;;;;;;;;;;AAUC,MACD,IAAIC,UAAa,GAAA;AACf,QAAA,OAAOC,EAAEC,MAAM,EAAA,CAAGC,IAAI,EAAA,CAAGC,QAAQ,CAAC,wCAAA,CAAA;AACpC;AAEA;;;;;;;;;;;;AAYC,MACD,IAAIC,QAAW,GAAA;AACb,QAAA,MAAM,EAAEC,aAAa,EAAEC,kBAAkB,EAAE,GAAG,IAAI;QAElD,MAAMC,OAAAA,GAAUC,MAAOD,CAAAA,OAAO,CAAC;AAAE,YAAA,GAAGF,aAAa;AAAE,YAAA,GAAGC;AAAmB,SAAA,CAAA;QAEzE,MAAMG,gBAAAA,GAAmBF,QAAQG,MAAM,CAAC,CAACC,GAAK,EAAA,CAACC,eAAeC,SAAU,CAAA,GAAA;AACtE,YAAA,OAAOF,GAAIG,CAAAA,KAAK,CAACd,CAAAA,CAAEe,MAAM,CAAC;gBAAE,CAACH,aAAAA,GAAgBI,oBAAqBH,CAAAA,SAAAA;AAAW,aAAA,CAAA,CAAA;SAC5Eb,EAAAA,CAAAA,CAAE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CAAA;QAGF,OAAOH,CAAAA,CAAEuC,KAAK,CAAC;AAACN,YAAAA,gBAAAA;AAAkBE,YAAAA,mBAAAA;AAAqBE,YAAAA;AAAc,SAAA,CAAA;AACvE;AAEA;;;;;;;;;;;;;;;AAeC,MACD,IAAIR,SAAY,GAAA;QACd,MAAMW,cAAAA,GAAiBxC,CAAEyC,CAAAA,IAAI,CAAC;AAAC,YAAA,KAAA;AAAO,YAAA;AAAO,SAAA,CAAA;;QAG7C,OAAOzC,CAAAA,CACJuC,KAAK,CACJ;AACE,YAAA,IAAI,CAACG,gBAAgB;AACrB,YAAA,IAAI,CAACX,iBAAiB;YACtB,IAAI,CAACY,WAAW,CAACH,cAAAA,CAAAA;AACjBxC,YAAAA,CAAAA,CAAEoB,KAAK,CAAC,IAAI,CAACuB,WAAW,CAACH,cAAAA,CAAAA;SAC1B,EACD;YAAEI,WAAa,EAAA;SAEhBC,CAAAA,CAAAA,QAAQ,EACR1C,CAAAA,QAAQ,CAAC,iBAAA,CAAA;AACd;AA/KA;;;;;AAKC,MACD2C,WAAYC,CAAAA,MAAmB,EAAEC,GAAoB,CAAE;AACrD,QAAA,KAAK,CAACD,MAAQC,EAAAA,GAAAA,CAAAA;AAChB;AAwKF;;;;"}
@@ -1,4 +0,0 @@
1
- export { AbstractCoreRouteValidator, mapAttributeToSchema } from './common';
2
- export { CoreContentTypeRouteValidator } from './content-type';
3
- export { CoreComponentRouteValidator } from './component';
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core-api/routes/validation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAC5E,OAAO,EAAE,6BAA6B,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC"}