@strapi/types 5.0.0-beta.3 → 5.0.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/dist/data/component.d.ts +9 -0
  2. package/dist/data/component.d.ts.map +1 -1
  3. package/dist/data/constants.d.ts +3 -0
  4. package/dist/data/constants.d.ts.map +1 -1
  5. package/dist/data/content-type.d.ts +9 -0
  6. package/dist/data/content-type.d.ts.map +1 -1
  7. package/dist/data/entity.d.ts +6 -0
  8. package/dist/data/entity.d.ts.map +1 -1
  9. package/dist/modules/documents/component-extension.d.ts +22 -0
  10. package/dist/modules/documents/component-extension.d.ts.map +1 -0
  11. package/dist/modules/documents/document-engine.d.ts +0 -1
  12. package/dist/modules/documents/index.d.ts +2 -1
  13. package/dist/modules/documents/index.d.ts.map +1 -1
  14. package/dist/modules/documents/middleware.d.ts +1 -1
  15. package/dist/modules/documents/middleware.d.ts.map +1 -1
  16. package/dist/modules/documents/service-instance.d.ts +1 -19
  17. package/dist/modules/documents/service-instance.d.ts.map +1 -1
  18. package/dist/modules/features.d.ts +0 -1
  19. package/dist/modules/features.d.ts.map +1 -1
  20. package/dist/public/registries.d.ts +38 -0
  21. package/dist/public/registries.d.ts.map +1 -1
  22. package/dist/public/shared.d.ts +53 -0
  23. package/dist/public/shared.d.ts.map +1 -1
  24. package/dist/schema/attribute/base.d.ts +43 -4
  25. package/dist/schema/attribute/base.d.ts.map +1 -1
  26. package/dist/schema/attribute/common.d.ts +9 -0
  27. package/dist/schema/attribute/common.d.ts.map +1 -1
  28. package/dist/schema/attribute/definitions/biginteger.d.ts +3 -0
  29. package/dist/schema/attribute/definitions/biginteger.d.ts.map +1 -1
  30. package/dist/schema/attribute/definitions/blocks.d.ts +3 -0
  31. package/dist/schema/attribute/definitions/blocks.d.ts.map +1 -1
  32. package/dist/schema/attribute/definitions/boolean.d.ts +3 -0
  33. package/dist/schema/attribute/definitions/boolean.d.ts.map +1 -1
  34. package/dist/schema/attribute/definitions/component.d.ts +3 -0
  35. package/dist/schema/attribute/definitions/component.d.ts.map +1 -1
  36. package/dist/schema/attribute/definitions/date-time.d.ts +3 -0
  37. package/dist/schema/attribute/definitions/date-time.d.ts.map +1 -1
  38. package/dist/schema/attribute/definitions/date.d.ts +3 -0
  39. package/dist/schema/attribute/definitions/date.d.ts.map +1 -1
  40. package/dist/schema/attribute/definitions/decimal.d.ts +3 -0
  41. package/dist/schema/attribute/definitions/decimal.d.ts.map +1 -1
  42. package/dist/schema/attribute/definitions/dynamic-zone.d.ts +3 -0
  43. package/dist/schema/attribute/definitions/dynamic-zone.d.ts.map +1 -1
  44. package/dist/schema/attribute/definitions/email.d.ts +3 -0
  45. package/dist/schema/attribute/definitions/email.d.ts.map +1 -1
  46. package/dist/schema/attribute/definitions/enumeration.d.ts +3 -0
  47. package/dist/schema/attribute/definitions/enumeration.d.ts.map +1 -1
  48. package/dist/schema/attribute/definitions/float.d.ts +3 -0
  49. package/dist/schema/attribute/definitions/float.d.ts.map +1 -1
  50. package/dist/schema/attribute/definitions/integer.d.ts +3 -0
  51. package/dist/schema/attribute/definitions/integer.d.ts.map +1 -1
  52. package/dist/schema/attribute/definitions/json.d.ts +3 -0
  53. package/dist/schema/attribute/definitions/json.d.ts.map +1 -1
  54. package/dist/schema/attribute/definitions/media.d.ts +3 -0
  55. package/dist/schema/attribute/definitions/media.d.ts.map +1 -1
  56. package/dist/schema/attribute/definitions/password.d.ts +3 -0
  57. package/dist/schema/attribute/definitions/password.d.ts.map +1 -1
  58. package/dist/schema/attribute/definitions/relation.d.ts +3 -0
  59. package/dist/schema/attribute/definitions/relation.d.ts.map +1 -1
  60. package/dist/schema/attribute/definitions/richtext.d.ts +3 -0
  61. package/dist/schema/attribute/definitions/richtext.d.ts.map +1 -1
  62. package/dist/schema/attribute/definitions/string.d.ts +6 -0
  63. package/dist/schema/attribute/definitions/string.d.ts.map +1 -1
  64. package/dist/schema/attribute/definitions/text.d.ts +3 -0
  65. package/dist/schema/attribute/definitions/text.d.ts.map +1 -1
  66. package/dist/schema/attribute/definitions/time.d.ts +3 -0
  67. package/dist/schema/attribute/definitions/time.d.ts.map +1 -1
  68. package/dist/schema/attribute/definitions/timestamp.d.ts +3 -0
  69. package/dist/schema/attribute/definitions/timestamp.d.ts.map +1 -1
  70. package/dist/schema/attribute/definitions/uid.d.ts +3 -0
  71. package/dist/schema/attribute/definitions/uid.d.ts.map +1 -1
  72. package/dist/schema/attribute/options.d.ts +140 -0
  73. package/dist/schema/attribute/options.d.ts.map +1 -1
  74. package/dist/schema/attribute/utils.d.ts +41 -0
  75. package/dist/schema/attribute/utils.d.ts.map +1 -1
  76. package/dist/schema/index.d.ts +75 -2
  77. package/dist/schema/index.d.ts.map +1 -1
  78. package/dist/struct/schema.d.ts +135 -31
  79. package/dist/struct/schema.d.ts.map +1 -1
  80. package/dist/uid/index.d.ts +134 -9
  81. package/dist/uid/index.d.ts.map +1 -1
  82. package/package.json +9 -9
@@ -4,12 +4,24 @@ import type { If, Object, Guard } from '../utils';
4
4
  import type * as Attribute from './attribute';
5
5
  export { Attribute };
6
6
  /**
7
- * The Schemas type represents a combination of both content type and component schemas
7
+ * Combines both content type and component schemas, effectively serving as a consolidated registry of all schemas.
8
8
  *
9
- * Both are fetched from the public registries.
9
+ * Enables mapping between a unique identifier and its corresponding schema.
10
+ *
11
+ @remark Schema definitions are pulled from the public registries
10
12
  */
11
13
  export type Schemas = Public.ContentTypeSchemas & Public.ComponentSchemas;
14
+ /**
15
+ * Content-type schema definitions.
16
+ *
17
+ * @remark Schema definitions are pulled from the public content-type registries
18
+ */
12
19
  export type ContentTypes = Public.ContentTypeSchemas;
20
+ /**
21
+ * Component schema definitions.
22
+ *
23
+ * @remark Schema definitions are pulled from the public component registries
24
+ */
13
25
  export type Components = Public.ComponentSchemas;
14
26
  export type ContentType<TContentTypeUID extends UID.ContentType = UID.ContentType> = ContentTypes[TContentTypeUID];
15
27
  export type Component<TComponentUID extends UID.Component = UID.Component> = Components[TComponentUID];
@@ -17,18 +29,24 @@ export type Component<TComponentUID extends UID.Component = UID.Component> = Com
17
29
  * Returns the Schema data structure associated with the given UID
18
30
  *
19
31
  * @template TSchemaUID - The unique identifier for the schema.
32
+ *
33
+ * @see Schemas
20
34
  */
21
35
  export type Schema<TSchemaUID extends UID.Schema = UID.Schema> = Schemas[TSchemaUID];
22
36
  /**
23
37
  * Returns the `info` property for a given schema.
24
38
  *
25
39
  * @template TSchemaUID - The targeted schema UID.
40
+ *
41
+ * @see Schema
26
42
  */
27
43
  export type Info<TSchemaUID extends UID.Schema> = Schema<TSchemaUID>['info'];
28
44
  /**
29
45
  * Returns the `modelType` property for a given schema.
30
46
  *
31
47
  * @template TSchemaUID - The targeted schema UID.
48
+ *
49
+ * @see Schema
32
50
  */
33
51
  export type ModelType<TSchemaUID extends UID.Schema> = Schema<TSchemaUID>['modelType'];
34
52
  /**
@@ -59,13 +77,68 @@ export type Attributes<TSchemaUID extends UID.Schema = UID.Schema> = {
59
77
  * @template TSchemaUID - The Schema's UID used to get the attributes names.
60
78
  */
61
79
  export type AttributeNames<TSchemaUID extends UID.Schema> = Extract<keyof Attributes<TSchemaUID>, string>;
80
+ /**
81
+ * Create an attribute record whose types matches the given ones.
82
+ *
83
+ * @template TSchemaUID - The Schema's UID used to get the attribute names.
84
+ * @template TKind - The kind of attribute we are searching for.
85
+ * @template TCondition - Optional. An additional condition to match additional attributes properties.
86
+ */
62
87
  export type AttributesByType<TSchemaUID extends UID.Schema, TKind extends Attribute.Kind, TCondition = never> = Object.PickBy<Attributes<TSchemaUID>, Attribute.OfType<TKind> & Guard.Never<TCondition>>;
88
+ /**
89
+ * Returns a union of attribute names whose type matches the given ones.
90
+ *
91
+ * @template TSchemaUID - The Schema's UID used to get the attribute names.
92
+ * @template TKind - The kind of attribute we are searching for.
93
+ * @template TCondition - Optional. An additional condition to match additional attributes properties.
94
+ */
63
95
  export type AttributeNamesByType<TSchemaUID extends UID.Schema, TKind extends Attribute.Kind, TCondition = never> = Object.KeysBy<Attributes<TSchemaUID>, Attribute.OfType<TKind> & Guard.Never<TCondition, unknown>, AttributeNames<TSchemaUID>>;
96
+ /**
97
+ * Provides the names of non-populatable attributes of a Schema.
98
+ *
99
+ * Non-populatable attributes are those which do not need to be populated to get their final value.
100
+ *
101
+ * @template TSchemaUID - The unique identifier of the schema.
102
+ */
64
103
  export type NonPopulatableAttributeNames<TSchemaUID extends UID.Schema> = AttributeNamesByType<TSchemaUID, Attribute.NonPopulatableKind>;
104
+ /**
105
+ * Provides the names of populatable attributes of a Schema.
106
+ *
107
+ * Populatable attributes are those which need to be populated to get their final value, such as {@link Attribute.Relation}, {@link Attribute.DynamicZone}, {@link Attribute.Component} or {@link Attribute.Media}.
108
+ *
109
+ * @template TSchemaUID - The unique identifier of the schema.
110
+ */
65
111
  export type PopulatableAttributeNames<TSchemaUID extends UID.Schema> = AttributeNamesByType<TSchemaUID, Attribute.PopulatableKind>;
112
+ /**
113
+ * Returns a list of attribute names which have associated targets.
114
+ *
115
+ * @remark `
116
+ AttributeNamesWithTarget` maps over the list of attribute for a given schema and filters those
117
+ * with targets (in other words, attribute names that have associated {@link Attribute.HasTarget} true).
118
+ *
119
+ * @returns a union of each attribute's name matching the condition.
120
+ *
121
+ * @template TSchemaUID - The unique identifier of the schema.
122
+ */
66
123
  export type AttributeNamesWithTarget<TSchemaUID extends UID.Schema> = Extract<Object.Values<{
67
124
  [TKey in AttributeNames<TSchemaUID>]: If<Attribute.HasTarget<AttributeByName<TSchemaUID, TKey>>, TKey>;
68
125
  }>, AttributeNames<TSchemaUID>>;
126
+ /**
127
+ * Extracts the names of all required attributes from a given schema.
128
+ *
129
+ * @remark `RequiredAttributeNames` screens attributes based on the {@link Attribute.Required} property,
130
+ * determining mandatory attributes from the given schema.
131
+ *
132
+ * @template TSchemaUID - The identifier of the schema.
133
+ */
69
134
  export type RequiredAttributeNames<TSchemaUID extends UID.Schema> = Object.KeysBy<Attributes<TSchemaUID>, Attribute.Required, AttributeNames<TSchemaUID>>;
135
+ /**
136
+ * Returns a union of every optional attribute name by excluding required attribute keys from the given Schema UID.
137
+ *
138
+ * @remark The `
139
+ OptionalAttributeNames` type utilises the {@link Object.KeysExcept} utility that takes a Schema's attributes and excludes the keys of required attributes.
140
+ *
141
+ * @template TSchemaUID - The unique identifier for the schema.
142
+ */
70
143
  export type OptionalAttributeNames<TSchemaUID extends UID.Schema> = Object.KeysExcept<Attributes<TSchemaUID>, Attribute.Required, AttributeNames<TSchemaUID>>;
71
144
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schema/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,KAAK,GAAG,MAAM,QAAQ,CAAC;AACnC,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAElD,OAAO,KAAK,KAAK,SAAS,MAAM,aAAa,CAAC;AAE9C,OAAO,EAAE,SAAS,EAAE,CAAC;AAErB;;;;GAIG;AACH,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC,kBAAkB,GAAG,MAAM,CAAC,gBAAgB,CAAC;AAE1E,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,kBAAkB,CAAC;AAErD,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,gBAAgB,CAAC;AAEjD,MAAM,MAAM,WAAW,CAAC,eAAe,SAAS,GAAG,CAAC,WAAW,GAAG,GAAG,CAAC,WAAW,IAC/E,YAAY,CAAC,eAAe,CAAC,CAAC;AAEhC,MAAM,MAAM,SAAS,CAAC,aAAa,SAAS,GAAG,CAAC,SAAS,GAAG,GAAG,CAAC,SAAS,IACvE,UAAU,CAAC,aAAa,CAAC,CAAC;AAE5B;;;;GAIG;AACH,MAAM,MAAM,MAAM,CAAC,UAAU,SAAS,GAAG,CAAC,MAAM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UAAU,CAAC,CAC3B,CAAC"}
@@ -4,141 +4,245 @@ export type ContentTypeKind = 'collectionType' | 'singleType';
4
4
  export type ModelType = 'contentType' | 'component';
5
5
  export type Schema = ContentTypeSchema | ComponentSchema;
6
6
  /**
7
- * Represents a Strapi Schema once loaded by the server
7
+ * A loaded instance of a Strapi Schema accessible to the server.
8
8
  */
9
9
  export interface BaseSchema {
10
10
  /**
11
- * The unique identifier of the Schema
11
+ * The unique identifier of the Schema. This identifier is a combined type encompassing both ContentType and Component UID types.
12
+ *
13
+ * It is mainly used when dealing with either content types or components in a situation where the context is not specific.
12
14
  */
13
15
  uid: UID.Schema;
14
16
  /**
15
- * The type of the model. Useful to discriminate content-types from component
17
+ * This is an identifier type that helps differentiate between a 'contentType' and 'component'.
18
+ * This distinction aids in communication where the ModelType needs to be specified explicitly.
16
19
  */
17
20
  modelType: ModelType;
18
21
  /**
19
- * Unique identifier of the schema
22
+ * Serves as the public name of the schema. Often utilized in referencing a specific schema (e.g. in the database).
20
23
  */
21
24
  modelName: string;
22
25
  /**
23
- * Unique identifier of the schema
26
+ * This global identifier acts as a unique reference to the schema across varying scopes and contexts.
24
27
  */
25
28
  globalId: string;
26
29
  /**
27
- * Options declared and read by the plugins
30
+ * Contains options specific to plugins. It is an optional property and stores configurations that are read by the plugins associated with this Schema.
28
31
  */
29
32
  pluginOptions?: SchemaPluginOptions;
30
33
  /**
31
- * Options object dedicated to Strapi core features
34
+ * Encapsulates all core options related to Strapi features for a given Schema.
32
35
  */
33
36
  options?: SchemaOptions;
34
37
  /**
35
- * Custom table name for the schema
38
+ * Optional property. Specifies the custom table name for the Schema if any.
36
39
  */
37
40
  collectionName?: string;
38
41
  /**
39
- * Information about schema naming and display
42
+ * Contains information related to naming and display characteristics of the Schema.
40
43
  */
41
44
  info: SchemaInfo;
42
45
  /**
43
- * A collection of attributes for a given Schema.
44
- *
45
- * It is stored as a record, where each attribute is associated with a unique string key.
46
+ * Houses a comprehensive collection of attributes for this Schema.
46
47
  *
47
- * The values should be instances of {@link Attribute.AnyAttribute}.
48
+ * Each attribute has a unique string key and corresponding value should be any Attribute type instance.
48
49
  */
49
50
  attributes: SchemaAttributes;
50
51
  }
51
52
  /**
52
- * Data structure containing naming and display information for a Schema
53
+ * Comprises naming and display parameters to customize a Schema's representation.
53
54
  */
54
55
  export interface SchemaInfo {
55
56
  /**
56
- * Default name to use in the admin panel
57
+ * Sets the default nomenclature for the Admin Panel. Acts as the label while identifying
58
+ * the schema or interacting with it within the admin panel. For example, used as a label
59
+ * for fields, table columns, and menu items.
57
60
  */
58
61
  displayName: string;
59
62
  /**
60
- * Description of the model
63
+ * Delineates the purpose of the model, clarifying its intended usage or its function. This
64
+ * property is optional and is primarily meant for further documentation to provide better
65
+ * context and understanding of the schema.
61
66
  */
62
67
  description?: string;
63
68
  /**
64
- * @strapi/icon name to use for the component's icon in the admin panel
69
+ * Specifies the visual identifier - an icon, for the schema inside the admin panel. It eases
70
+ * recognition and improves navigation. The value should be any valid @strapi/icon name. This
71
+ * property is optional, and if omitted, a default icon might be used by the interface.
65
72
  */
66
73
  icon?: string;
67
74
  }
75
+ /**
76
+ * `SchemaAttributes` is a mapping of attribute keys to their corresponding values.
77
+ *
78
+ * These keys and values define the structure and characteristics of a Strapi schema.
79
+ */
68
80
  export type SchemaAttributes = Record<string, Attribute.AnyAttribute>;
69
81
  /**
70
- * Structure containing every core schema options and their associated value
82
+ * Contains various options employed during runtime to tweak certain aspects of Strapi features.
83
+ *
84
+ * Each property under this interface can enable, disable or modify a specific feature or functionality associated with a schema.
71
85
  */
72
86
  export interface SchemaOptions {
73
87
  /**
74
- * EE only.
88
+ * Toggles the review workflow feature on or off.
89
+ *
90
+ * A review workflow is a process that describes the stages a document must go through from creation to publication.
91
+ *
92
+ * @remark This option is Enterprise Edition Exclusive.
75
93
  */
76
94
  reviewWorkflows?: boolean;
95
+ /**
96
+ * Determines if creator fields can be populated.
97
+ *
98
+ * When enabled, this feature will allow populating data about the admin user who created a specific document entry.
99
+ */
77
100
  populateCreatorFields?: boolean;
101
+ /**
102
+ * May be used for providing specific notes or annotations of the schema.
103
+ */
78
104
  comment?: string;
105
+ /**
106
+ * Can be utilized for setting a particular version of schema related to the review-workflow feature.
107
+ *
108
+ * @deprecated As of v5, this is deprecated and will likely be removed soon.
109
+ */
79
110
  version?: string;
111
+ /**
112
+ * Used to enable or disable the draft and publish feature.
113
+ * This would decide whether the changes made to a document are published immediately or saved as a draft for later.
114
+ */
80
115
  draftAndPublish?: boolean;
81
116
  }
82
117
  /**
83
- * Plugins' options for a Schema
118
+ * Provides a flexible configuration method for Strapi plugins.
119
+ *
120
+ * In Strapi, plugins extend the core functionality and enhance features of the application. Each plugin may require
121
+ * prerequisite settings or configurations for successful functioning. `SchemaPluginOptions` facilitates this by storing these configurations
122
+ * as key-value pairs where the key corresponds to the name of the plugin, and the value defines the respective settings of that plugin.
123
+ *
124
+ * @remark The keys/values of configurations are not explicitly defined and are manually defined in each schema definition.
125
+ *
126
+ * @example
127
+ * Using `SchemaPluginOptions` in the schema definition:
128
+ *
129
+ * ```typescript
130
+ * import type { Struct } from '@strapi/types';
131
+ *
132
+ * const strapiPluginOptions: Struct.SchemaPluginOptions = {
133
+ * 'plugin-foo': {
134
+ * prop1: string;
135
+ * prop2: boolean;
136
+ * },
137
+ * 'plugin-bar': {
138
+ * prop1: string;
139
+ * prop2: boolean;
140
+ * },
141
+ * };
142
+ *
143
+ * const articleSchema: Struct.BaseSchema = {
144
+ * uid: 'article',
145
+ * modelType: 'contentType',
146
+ * modelName: 'Article',
147
+ * globalId: 'Article',
148
+ * pluginOptions: strapiPluginOptions,
149
+ * // Other schema properties...
150
+ * };
151
+ * ```
152
+ *
84
153
  */
85
154
  export interface SchemaPluginOptions {
86
155
  [key: string]: unknown;
87
156
  }
88
157
  /**
89
- * Schema for a content type
158
+ * Serves as a layout for a content type.
159
+ *
160
+ * Inherits and enhances various properties from the `BaseSchema`, the `ContentTypeSchema` is a unique derivative of the base schema that distinguishes itself with additional properties.
90
161
  */
91
162
  export interface ContentTypeSchema extends BaseSchema {
163
+ /**
164
+ * Forces the `modelType` to be a `contentType`.
165
+ *
166
+ * @remark Helpful to distinguish a {@link ContentTypeSchema} from a {@link ComponentSchema}
167
+ */
92
168
  modelType: 'contentType';
93
169
  /**
94
- * Unique identifier of the schema
170
+ * Unique identifier associated with the content type. It acts as a reference to work with data structures that are specifically identified by the content type's UID.
95
171
  */
96
172
  uid: UID.ContentType;
97
173
  /**
98
- * Determine the type of the content type (single-type or collection-type)
174
+ * Classifies the content type as 'collection-type' or 'single-type'.
99
175
  */
100
176
  kind: ContentTypeKind;
101
177
  /**
102
- * Information about schema naming and display
178
+ * Brings together attributes related to naming and display characteristics like singular name and plural name of the content type. These names are typically used in user interfaces where these entries are displayed.
103
179
  */
104
180
  info: ContentTypeSchemaInfo;
105
181
  /**
106
- * Indexes to be created on the database
182
+ * Optional attribute to indicate the indexes to be created on the database for this content type.
183
+ *
107
184
  * @internal
108
185
  */
109
186
  indexes?: unknown[];
110
187
  }
111
188
  /**
112
- * Represents information about a content type schema.
189
+ * Contains naming properties specific to a specific content type.
113
190
  */
114
191
  export interface ContentTypeSchemaInfo extends SchemaInfo {
115
192
  /**
116
- * Singular form of the content type name
193
+ * Indicates how a single instance of the content type should be labeled.
117
194
  */
118
195
  singularName: string;
119
196
  /**
120
- * Plural form of the collection type name
197
+ * Provides a human-friendly label for referring to multiple instances of the content type.
121
198
  */
122
199
  pluralName: string;
123
200
  }
124
201
  /**
125
- * Schema for a collection type
202
+ * Schema that represents a collection of content types' entry in the system.
126
203
  */
127
204
  export interface CollectionTypeSchema extends ContentTypeSchema {
205
+ /**
206
+ * Explicitly sets the kind of content type schema to 'collectionType'.
207
+ *
208
+ * This signifies that the content type is organized in a collection, handling multiple entries.
209
+ */
128
210
  kind: 'collectionType';
129
211
  }
130
212
  /**
131
- * Schema for a single type
213
+ * Schema that represents a single of content type's entry in the system.
132
214
  */
133
215
  export interface SingleTypeSchema extends ContentTypeSchema {
216
+ /**
217
+ * Explicitly sets the kind of content type schema to 'singleType'.
218
+ *
219
+ * This signifies that the content type has a single entry.
220
+ */
134
221
  kind: 'singleType';
135
222
  }
136
223
  /**
137
- * Schema for a component
224
+ * Serves as a layout for a component type.
225
+ *
226
+ * Inherits and enhances various properties from the `BaseSchema`, the `ComponentSchema` is a unique derivative of the base schema that distinguishes itself with additional properties.
138
227
  */
139
228
  export interface ComponentSchema extends BaseSchema {
229
+ /**
230
+ * Forces the `modelType` to be a `component`.
231
+ *
232
+ * @remark Helpful to distinguish a {@link ComponentSchema} from a {@link ContentTypeSchema}
233
+ */
140
234
  modelType: 'component';
235
+ /**
236
+ * A unique identifier for the component.
237
+ *
238
+ * It uses `UID.Component` type which encapsulates unique identifiers for any component defined in the public component registry.
239
+ */
141
240
  uid: UID.Component;
241
+ /**
242
+ * A classification field for the component.
243
+ *
244
+ * This string type field is utilized to categorize components into different categories based on their function or feature.
245
+ */
142
246
  category: string;
143
247
  }
144
248
  //# sourceMappingURL=schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/struct/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,KAAK,KAAK,GAAG,MAAM,QAAQ,CAAC;AAEnC,MAAM,MAAM,eAAe,GAAG,gBAAgB,GAAG,YAAY,CAAC;AAE9D,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG,WAAW,CAAC;AAEpD,MAAM,MAAM,MAAM,GAAG,iBAAiB,GAAG,eAAe,CAAC;AAEzD;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC;IAEhB;;OAEG;IACH,SAAS,EAAE,SAAS,CAAC;IAErB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;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CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAiB,SAAQ,iBAAiB;IACzD;;;;OAIG;IACH,IAAI,EAAE,YAAY,CAAC;CACpB;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAgB,SAAQ,UAAU;IACjD;;;;OAIG;IACH,SAAS,EAAE,WAAW,CAAC;IAEvB;;;;OAIG;IACH,GAAG,EAAE,GAAG,CAAC,SAAS,CAAC;IAEnB;;;;OAIG;IACH,QAAQ,EAAE,MAAM,CAAC;CAClB"}
@@ -3,41 +3,166 @@ import type * as Struct from '../struct';
3
3
  import type { Constants, Guard, Object, Extends, Or } from '../utils';
4
4
  import type * as Public from '../public';
5
5
  /**
6
- * Schemas' UIDs based on the public schema registries.
6
+ * Combines ContentType and Component UID types in a single union type.
7
7
  *
8
- * It includes both ContentTypeSchemas and ComponentSchemas
8
+ * `UID.Schema` provides the ability to deal with both content types and components through one streamlined type.
9
+ *
10
+ * It hinges on underlying schema registries, which aggregates and maps unique identifiers to their respective schemas.
11
+ *
12
+ * This type would typically be used where the context is not particular about dealing with content types or components exclusively but rather any kind of schema.
13
+ *
14
+ * @example
15
+ * Let's assume we need a function that processes schema irrespective of whether it's ContenType or Component.
16
+ *
17
+ * ```typescript
18
+ * import type { UID } from '@strapi/types';
19
+ *
20
+ * function processSchema(schemaID: UID.Schema) {
21
+ * // Implementation goes here...
22
+ * }
23
+ *
24
+ * // Now, calling processSchema() with uid of content type
25
+ * processSchema('api::foo.foo');
26
+ *
27
+ * // And calling processSchema() with uid of component
28
+ * processSchema('default.foo');
29
+ * ```
30
+ *
31
+ * @see {@link ContentType} Identifier for content types based on the public registry.
32
+ * @see {@link Component} Identifier for components based on the public registry.
9
33
  */
10
34
  export type Schema = ContentType | Component;
11
35
  /**
12
- * Content-Types' UIDs based on the public content-type registry.
36
+ * Unique identifiers for any content-type defined in the public content-type registry.
37
+ *
38
+ * Useful when it's required to work with data structures that can only be identified by the underlying content-type UID.
39
+ *
40
+ * When no content-types are declared in the registry, it uses the generic {@link Internal.UID.ContentType} instead.
41
+ *
42
+ * @example
43
+ * Here's an example of how to use the `UID.ContentType` type:
44
+ *
45
+ * ```typescript
46
+ * import type { UID } from '@strapi/types';
47
+ *
48
+ * // Assume we have a function that requires a ContentType UID
49
+ * function fetchSchema(uid: UID.ContentType) {
50
+ * // Implementation goes here...
51
+ * }
52
+ *
53
+ * // Now you can pass the unique identifier for a content type to fetch its schema
54
+ * fetchSchema('api::foo.foo');
55
+ * ```
56
+ * @see {@link Public.ContentTypeSchemas} Content-type public registry.
57
+ * @see {@link UID.ContentType} ContentType UID format definition.
13
58
  */
14
59
  export type ContentType = Internal.Registry.Keys<Public.ContentTypeSchemas, Internal.UID.ContentType>;
15
60
  /**
16
- * Components' UIDs based on the public component registry.
61
+ * Unique identifiers for any component defined in the public component registry.
62
+ *
63
+ * Useful when it's required to work with data structures that can only be identified by the underlying component UID.
64
+ *
65
+ * When no component are declared in the registry, it uses the generic {@link Internal.UID.Component} instead.
66
+ *
67
+ * @example
68
+ * Here's an example of how to use the `UID.Component` type:
69
+ *
70
+ * ```typescript
71
+ * import type { UID } from '@strapi/types';
72
+ *
73
+ * // Assume we have a function that requires a Component UID
74
+ * function fetchSchema(uid: UID.Component) {
75
+ * // Implementation goes here...
76
+ * }
77
+ *
78
+ * // Now you can pass the unique identifier for a component to fetch its schema
79
+ * fetchSchema('default.foo');
80
+ * ```
81
+ * @see {@link Public.ComponentSchemas} Component public registry.
82
+ * @see {@link UID.Component} Component UID format definition.
17
83
  */
18
84
  export type Component = Internal.Registry.Keys<Public.ComponentSchemas, Internal.UID.Component>;
19
85
  /**
20
- * Union of every components' category, based on the public component registry
86
+ * Obtains a union of every component's category from the public component registry.
87
+ *
88
+ * It utilizes [conditional types inference](https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#inferring-within-conditional-types) to extract the category name from the components' UID.
89
+ *
90
+ * The component UID format is a string that follows a specific pattern defined by {@link Internal.UID.Component}.
91
+ * If a type extends `Internal.UID.Component`, it implies that it has a structure with `TCategory` string as the category name of the component.
92
+ *
93
+ * @see {@link Internal.UID.Component} for more details on how the component's unique identifier is structured.
21
94
  */
22
95
  export type ComponentCategory = Component extends Internal.UID.Component<infer TCategory> ? TCategory : never;
23
96
  /**
24
- * Collection-Types' UIDs based on the public content-type registry.
97
+ * Collection-Type UID based on the public content-type registry
25
98
  *
26
- * If no collection type is found, fallback to a generic content-type UID.
99
+ * If no collection type is found, it fallbacks to a generic content-type UID.
27
100
  */
28
101
  export type CollectionType = Guard.Never<Extract<Object.KeysBy<Public.ContentTypeSchemas, Struct.CollectionTypeSchema>, ContentType>, Internal.UID.ContentType>;
29
102
  /**
30
- * Single-Type's UIDs based on the public content-type registry
103
+ * Single-Type UID based on the public content-type registry
31
104
  *
32
- * If no collection type is found, fallback to a generic content-type UID.
105
+ * If no single type is found, it falls back to a generic content-type UID.
33
106
  */
34
107
  export type SingleType = Guard.Never<Extract<Object.KeysBy<Public.ContentTypeSchemas, Struct.SingleTypeSchema>, ContentType>, Internal.UID.ContentType>;
108
+ /**
109
+ * Service UID based on the public service registry
110
+ *
111
+ * @see {Public.Services}
112
+ */
35
113
  export type Service = Internal.Registry.Keys<Public.Services, Internal.UID.Service>;
114
+ /**
115
+ * Controller UID based on the public service registry
116
+ *
117
+ * @see {Public.Controllers}
118
+ */
36
119
  export type Controller = Internal.Registry.Keys<Public.Controllers, Internal.UID.Controller>;
120
+ /**
121
+ * Policy UID based on the public service registry
122
+ *
123
+ * @see {Public.Policies}
124
+ */
37
125
  export type Policy = Internal.Registry.Keys<Public.Policies, Internal.UID.Policy>;
126
+ /**
127
+ * Middleware UID based on the public service registry
128
+ *
129
+ * @see {Public.Middlewares}
130
+ */
38
131
  export type Middleware = Internal.Registry.Keys<Public.Middlewares, Internal.UID.Middleware>;
132
+ /**
133
+ * Verifies if a certain schema UIDs correspond to a collection type.
134
+ *
135
+ * Given a schema UID, it checks if it matches the {@link CollectionType} UID type. Since {@link CollectionType}
136
+ * can resolve to the more generic {@link ContentType} type, we also need to check that the associated
137
+ * schema extends the {@link Struct.CollectionTypeSchema} data structure.
138
+ *
139
+ * @template TSchemaUID - The UID of the schema
140
+ */
39
141
  export type IsCollectionType<TSchemaUID extends Schema> = TSchemaUID extends CollectionType ? Extends<Public.ContentTypeSchemas[TSchemaUID], Struct.CollectionTypeSchema> : Constants.False;
142
+ /**
143
+ * Verifies if a certain schema UIDs correspond to a single type.
144
+ *
145
+ * Given a schema UID, it checks if it matches the {@link SingleType} UID type. Since {@link SingleType}
146
+ * can resolve to the more generic {@link ContentType} type, we also need to check that the associated
147
+ * schema extends the {@link Struct.CollectionTypeSchema} data structure.
148
+ *
149
+ * @template TSchemaUID - The UID of the schema
150
+ */
40
151
  export type IsSingleType<TSchemaUID extends Schema> = TSchemaUID extends SingleType ? Extends<Public.ContentTypeSchemas[TSchemaUID], Struct.SingleTypeSchema> : Constants.False;
152
+ /**
153
+ * Verifies if a certain schema UIDs correspond to a component.
154
+ *
155
+ * Given a schema UID, it checks if it matches the {@link Component} UID type.
156
+ *
157
+ * @template TSchemaUID - The UID of the schema
158
+ */
41
159
  export type IsComponent<TSchemaUID extends Schema> = TSchemaUID extends Component ? Extends<Public.ComponentSchemas[TSchemaUID], Struct.ComponentSchema> : Constants.False;
160
+ /**
161
+ * Verifies if a certain schema UIDs correspond to a content-type.
162
+ *
163
+ * Given a schema UID, it checks if it matches the {@link ContentType} UID type.
164
+ *
165
+ * @template TSchemaUID - The UID of the schema
166
+ */
42
167
  export type IsContentType<TSchemaUID extends Schema> = TSchemaUID extends ContentType ? Or<IsCollectionType<TSchemaUID>, IsSingleType<TSchemaUID>> : Constants.False;
43
168
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/uid/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,QAAQ,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,KAAK,MAAM,MAAM,W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