@strapi/core 0.0.0-experimental.25f7de53c1fc990bbb86d4aa43c379acfa838064 → 0.0.0-experimental.267375bdc00aa57de5e78acd345a838d21a63676
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.
- package/dist/core-api/routes/index.d.ts +22 -4
- package/dist/core-api/routes/index.d.ts.map +1 -1
- package/dist/core-api/routes/index.js +8 -118
- package/dist/core-api/routes/index.js.map +1 -1
- package/dist/core-api/routes/index.mjs +8 -118
- package/dist/core-api/routes/index.mjs.map +1 -1
- package/dist/domain/module/index.d.ts.map +1 -1
- package/dist/domain/module/index.js +0 -3
- package/dist/domain/module/index.js.map +1 -1
- package/dist/domain/module/index.mjs +0 -3
- package/dist/domain/module/index.mjs.map +1 -1
- package/dist/ee/index.d.ts +6 -0
- package/dist/ee/index.d.ts.map +1 -1
- package/dist/ee/index.js +29 -3
- package/dist/ee/index.js.map +1 -1
- package/dist/ee/index.mjs +30 -4
- package/dist/ee/index.mjs.map +1 -1
- package/dist/ee/license.d.ts +3 -1
- package/dist/ee/license.d.ts.map +1 -1
- package/dist/ee/license.js +6 -1
- package/dist/ee/license.js.map +1 -1
- package/dist/ee/license.mjs +6 -2
- package/dist/ee/license.mjs.map +1 -1
- package/dist/factories.d.ts +1 -3
- package/dist/factories.d.ts.map +1 -1
- package/dist/factories.js +2 -10
- package/dist/factories.js.map +1 -1
- package/dist/factories.mjs +3 -10
- package/dist/factories.mjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/package.json.js +13 -14
- package/dist/package.json.js.map +1 -1
- package/dist/package.json.mjs +13 -14
- package/dist/package.json.mjs.map +1 -1
- package/dist/services/core-store.d.ts +2 -2
- package/dist/services/core-store.d.ts.map +1 -1
- package/dist/services/core-store.js.map +1 -1
- package/dist/services/core-store.mjs.map +1 -1
- package/dist/services/document-service/entries.d.ts.map +1 -1
- package/dist/services/document-service/entries.js +42 -0
- package/dist/services/document-service/entries.js.map +1 -1
- package/dist/services/document-service/entries.mjs +43 -1
- package/dist/services/document-service/entries.mjs.map +1 -1
- package/dist/services/server/register-routes.js +2 -22
- package/dist/services/server/register-routes.js.map +1 -1
- package/dist/services/server/register-routes.mjs +2 -22
- package/dist/services/server/register-routes.mjs.map +1 -1
- package/dist/services/server/routing.d.ts +0 -10
- package/dist/services/server/routing.d.ts.map +1 -1
- package/dist/services/server/routing.js +1 -7
- package/dist/services/server/routing.js.map +1 -1
- package/dist/services/server/routing.mjs +1 -7
- package/dist/services/server/routing.mjs.map +1 -1
- package/dist/utils/fetch.d.ts +5 -1
- package/dist/utils/fetch.d.ts.map +1 -1
- package/dist/utils/fetch.js +8 -4
- package/dist/utils/fetch.js.map +1 -1
- package/dist/utils/fetch.mjs +8 -4
- package/dist/utils/fetch.mjs.map +1 -1
- package/package.json +13 -14
- package/dist/core-api/routes/validation/common.d.ts +0 -135
- package/dist/core-api/routes/validation/common.d.ts.map +0 -1
- package/dist/core-api/routes/validation/common.js +0 -201
- package/dist/core-api/routes/validation/common.js.map +0 -1
- package/dist/core-api/routes/validation/common.mjs +0 -198
- package/dist/core-api/routes/validation/common.mjs.map +0 -1
- package/dist/core-api/routes/validation/component.d.ts +0 -42
- package/dist/core-api/routes/validation/component.d.ts.map +0 -1
- package/dist/core-api/routes/validation/content-type.d.ts +0 -139
- package/dist/core-api/routes/validation/content-type.d.ts.map +0 -1
- package/dist/core-api/routes/validation/content-type.js +0 -176
- package/dist/core-api/routes/validation/content-type.js.map +0 -1
- package/dist/core-api/routes/validation/content-type.mjs +0 -174
- package/dist/core-api/routes/validation/content-type.mjs.map +0 -1
- package/dist/core-api/routes/validation/index.d.ts +0 -4
- package/dist/core-api/routes/validation/index.d.ts.map +0 -1
|
@@ -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","scalarFieldsEnum","fieldRecord","description","optional","constructor","strapi","uid"],"mappings":";;;;;AAOA;;;;;;;;;;;;;;;;;IAkBO,MAAMA,6BAAsCC,SAAAA,iCAAAA,CAAAA;AAWjD;;;;;;;;;;AAUC,MACD,IAAIC,UAAa,GAAA;AACf,QAAA,OAAOC,MAAEC,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,KAAAA,CAAEe,MAAM,CAAC;gBAAE,CAACH,aAAAA,GAAgBI,2BAAqBH,CAAAA,SAAAA;AAAW,aAAA,CAAA,CAAA;SAC5Eb,EAAAA,KAAAA,CAAEe,MAAM,CAAC,EAAC,CAAA,CAAA;QAEb,MAAME,aAAAA,GAAgBjB,KAAEe,CAAAA,MAAM,CAAC;YAAEG,UAAY,EAAA,IAAI,CAACnB;AAAW,SAAA,CAAA;QAE7D,OAAOkB,aAAAA,CAAcH,KAAK,CAACL,gBAAAA,CAAAA;AAC7B;AAEA;;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xC,KAAEyC,CAAAA,IAAI,CAAC;AAAC,YAAA,KAAA;AAAO,YAAA;AAAO,SAAA,CAAA;;QAG7C,OAAOzC,KAAAA,CACJuC,KAAK,CACJ;AACE,YAAA,IAAI,CAACG,gBAAgB;AACrB,YAAA,IAAI,CAACX,iBAAiB;YACtB,IAAI,CAACY,WAAW,CAACH,cAAAA,CAAAA;AACjBxC,YAAAA,KAAAA,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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