@depup/contentful 11.10.7-depup.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/ADVANCED.md +283 -0
  2. package/CONTRIBUTING.md +109 -0
  3. package/LICENSE +21 -0
  4. package/MIGRATION.md +364 -0
  5. package/README.md +36 -0
  6. package/TYPESCRIPT.md +329 -0
  7. package/changes.json +30 -0
  8. package/dist/contentful.browser.js +10886 -0
  9. package/dist/contentful.browser.min.js +1 -0
  10. package/dist/contentful.cjs +23983 -0
  11. package/dist/esm/contentful.js +60 -0
  12. package/dist/esm/create-contentful-api.js +463 -0
  13. package/dist/esm/create-global-options.js +21 -0
  14. package/dist/esm/index.js +4 -0
  15. package/dist/esm/make-client.js +52 -0
  16. package/dist/esm/mixins/stringify-safe.js +23 -0
  17. package/dist/esm/paged-sync.js +118 -0
  18. package/dist/esm/utils/normalize-cursor-pagination-parameters.js +9 -0
  19. package/dist/esm/utils/normalize-cursor-pagination-response.js +23 -0
  20. package/dist/esm/utils/normalize-search-parameters.js +18 -0
  21. package/dist/esm/utils/normalize-select.js +25 -0
  22. package/dist/esm/utils/query-selection-set.js +14 -0
  23. package/dist/esm/utils/resolve-circular.js +15 -0
  24. package/dist/esm/utils/timeline-preview-helpers.js +33 -0
  25. package/dist/esm/utils/validate-params.js +65 -0
  26. package/dist/esm/utils/validate-search-parameters.js +11 -0
  27. package/dist/esm/utils/validate-timestamp.js +16 -0
  28. package/dist/esm/utils/validation-error.js +8 -0
  29. package/dist/stats-browser-min.html +4949 -0
  30. package/dist/types/contentful.d.ts +150 -0
  31. package/dist/types/create-contentful-api.d.ts +13 -0
  32. package/dist/types/create-global-options.d.ts +19 -0
  33. package/dist/types/index.d.ts +6 -0
  34. package/dist/types/make-client.d.ts +3 -0
  35. package/dist/types/mixins/stringify-safe.d.ts +1 -0
  36. package/dist/types/paged-sync.d.ts +7 -0
  37. package/dist/types/types/asset-key.d.ts +7 -0
  38. package/dist/types/types/asset.d.ts +79 -0
  39. package/dist/types/types/client.d.ts +477 -0
  40. package/dist/types/types/collection.d.ts +42 -0
  41. package/dist/types/types/concept-scheme.d.ts +26 -0
  42. package/dist/types/types/concept.d.ts +51 -0
  43. package/dist/types/types/content-type.d.ts +105 -0
  44. package/dist/types/types/entry.d.ts +246 -0
  45. package/dist/types/types/index.d.ts +17 -0
  46. package/dist/types/types/link.d.ts +61 -0
  47. package/dist/types/types/locale.d.ts +30 -0
  48. package/dist/types/types/metadata.d.ts +13 -0
  49. package/dist/types/types/query/equality.d.ts +29 -0
  50. package/dist/types/types/query/existence.d.ts +15 -0
  51. package/dist/types/types/query/index.d.ts +12 -0
  52. package/dist/types/types/query/location.d.ts +29 -0
  53. package/dist/types/types/query/order.d.ts +44 -0
  54. package/dist/types/types/query/query.d.ts +155 -0
  55. package/dist/types/types/query/range.d.ts +18 -0
  56. package/dist/types/types/query/reference.d.ts +12 -0
  57. package/dist/types/types/query/search.d.ts +17 -0
  58. package/dist/types/types/query/select.d.ts +29 -0
  59. package/dist/types/types/query/set.d.ts +10 -0
  60. package/dist/types/types/query/subset.d.ts +20 -0
  61. package/dist/types/types/query/util.d.ts +32 -0
  62. package/dist/types/types/resource-link.d.ts +9 -0
  63. package/dist/types/types/space.d.ts +20 -0
  64. package/dist/types/types/sync.d.ts +84 -0
  65. package/dist/types/types/sys.d.ts +30 -0
  66. package/dist/types/types/tag.d.ts +32 -0
  67. package/dist/types/types/timeline-preview.d.ts +16 -0
  68. package/dist/types/utils/client-helpers.d.ts +9 -0
  69. package/dist/types/utils/normalize-cursor-pagination-parameters.d.ts +5 -0
  70. package/dist/types/utils/normalize-cursor-pagination-response.d.ts +2 -0
  71. package/dist/types/utils/normalize-search-parameters.d.ts +1 -0
  72. package/dist/types/utils/normalize-select.d.ts +1 -0
  73. package/dist/types/utils/query-selection-set.d.ts +1 -0
  74. package/dist/types/utils/resolve-circular.d.ts +4 -0
  75. package/dist/types/utils/timeline-preview-helpers.d.ts +7 -0
  76. package/dist/types/utils/validate-params.d.ts +6 -0
  77. package/dist/types/utils/validate-search-parameters.d.ts +1 -0
  78. package/dist/types/utils/validate-timestamp.d.ts +6 -0
  79. package/dist/types/utils/validation-error.d.ts +3 -0
  80. package/images/contentful-icon.png +0 -0
  81. package/images/dynamic-query-keys.png +0 -0
  82. package/images/static-query-keys.png +0 -0
  83. package/package.json +221 -0
@@ -0,0 +1,105 @@
1
+ import type { ContentfulCollection } from './collection.js';
2
+ import type { EntryFields } from './entry.js';
3
+ import type { SpaceLink, EnvironmentLink } from './link.js';
4
+ import type { BaseSys } from './sys.js';
5
+ import type { BLOCKS, INLINES } from '@contentful/rich-text-types';
6
+ /**
7
+ * System managed metadata for content type
8
+ * @category ContentType
9
+ * @see {@link https://www.contentful.com/developers/docs/references/content-delivery-api/#/introduction/common-resource-attributes | CDA documentation on common attributes}
10
+ */
11
+ export interface ContentTypeSys extends BaseSys {
12
+ createdAt: EntryFields.Date;
13
+ updatedAt: EntryFields.Date;
14
+ revision: number;
15
+ space: {
16
+ sys: SpaceLink;
17
+ };
18
+ environment: {
19
+ sys: EnvironmentLink;
20
+ };
21
+ }
22
+ /**
23
+ * Definition of a content type field
24
+ * @category ContentType
25
+ * @see {@link https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/content-types/content-type | Documentation}
26
+ */
27
+ export interface ContentTypeField {
28
+ disabled: boolean;
29
+ id: string;
30
+ linkType?: string;
31
+ localized: boolean;
32
+ name: string;
33
+ omitted: boolean;
34
+ required: boolean;
35
+ type: ContentTypeFieldType;
36
+ validations: ContentTypeFieldValidation[];
37
+ items?: FieldItem;
38
+ allowedResources?: ContentTypeAllowedResources[];
39
+ }
40
+ export interface ContentTypeAllowedResources {
41
+ type: string;
42
+ source: string;
43
+ contentTypes: string[];
44
+ }
45
+ /**
46
+ * @category ContentType
47
+ */
48
+ export type ContentTypeFieldType = 'Symbol' | 'Text' | 'Integer' | 'Number' | 'Date' | 'Boolean' | 'Location' | 'Link' | 'Array' | 'Object' | 'RichText' | 'ResourceLink';
49
+ /**
50
+ * Definition of a single validation rule applied
51
+ * to the related content type field
52
+ * @category ContentType
53
+ */
54
+ export interface ContentTypeFieldValidation {
55
+ unique?: boolean;
56
+ size?: {
57
+ min?: number;
58
+ max?: number;
59
+ };
60
+ regexp?: {
61
+ pattern: string;
62
+ };
63
+ linkMimetypeGroup?: string[];
64
+ in?: string[];
65
+ linkContentType?: string[];
66
+ message?: string | null;
67
+ nodes?: {
68
+ [BLOCKS.EMBEDDED_ENTRY]?: Pick<ContentTypeFieldValidation, 'size' | 'linkContentType' | 'message'>[];
69
+ [INLINES.EMBEDDED_ENTRY]?: Pick<ContentTypeFieldValidation, 'size' | 'linkContentType' | 'message'>[];
70
+ [INLINES.ENTRY_HYPERLINK]?: Pick<ContentTypeFieldValidation, 'size' | 'linkContentType' | 'message'>[];
71
+ [BLOCKS.EMBEDDED_ASSET]?: Pick<ContentTypeFieldValidation, 'size' | 'message'>[];
72
+ [INLINES.ASSET_HYPERLINK]?: Pick<ContentTypeFieldValidation, 'size' | 'message'>[];
73
+ [BLOCKS.EMBEDDED_RESOURCE]?: {
74
+ validations: Pick<ContentTypeFieldValidation, 'size' | 'message'>[];
75
+ allowedResources: ContentTypeAllowedResources[];
76
+ };
77
+ };
78
+ enabledNodeTypes?: (`${BLOCKS}` | `${INLINES}`)[];
79
+ }
80
+ /**
81
+ * Definition of an item belonging to the content type field
82
+ * @category ContentType
83
+ */
84
+ export interface FieldItem {
85
+ type: 'Link' | 'Symbol' | 'ResourceLink';
86
+ validations: ContentTypeFieldValidation[];
87
+ linkType?: 'Entry' | 'Asset';
88
+ }
89
+ /**
90
+ * Definition of a content type
91
+ * @category ContentType
92
+ * @see {@link https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/content-types | Documentation}
93
+ */
94
+ export interface ContentType {
95
+ sys: ContentTypeSys;
96
+ name: string;
97
+ description: string;
98
+ displayField: string;
99
+ fields: Array<ContentTypeField>;
100
+ }
101
+ /**
102
+ * Collection of content types
103
+ * @category ContentType
104
+ */
105
+ export type ContentTypeCollection = ContentfulCollection<ContentType>;
@@ -0,0 +1,246 @@
1
+ import type { Document as RichTextDocument } from '@contentful/rich-text-types';
2
+ import type { Asset } from './asset.js';
3
+ import type { ContentfulCollection, CursorPaginatedCollection } from './collection.js';
4
+ import type { ContentTypeLink, UnresolvedLink } from './link.js';
5
+ import type { LocaleCode } from './locale.js';
6
+ import type { Metadata } from './metadata.js';
7
+ import type { EntrySkeletonType } from './query/index.js';
8
+ import type { EntitySys } from './sys.js';
9
+ import type { JsonArray, JsonObject } from 'type-fest';
10
+ import type { ResourceLink } from './resource-link.js';
11
+ import type { ChainModifiers } from './client.js';
12
+ /**
13
+ * System managed metadata for entries
14
+ * @category Entry
15
+ */
16
+ export interface EntrySys extends EntitySys {
17
+ contentType: {
18
+ sys: ContentTypeLink;
19
+ };
20
+ type: 'Entry';
21
+ }
22
+ /**
23
+ * Definition of abstract entry field types with additional type properties
24
+ * Introduced to properly distinguish all fields to create consistent query types
25
+ * @category Entry
26
+ */
27
+ export declare namespace EntryFieldTypes {
28
+ type Symbol<Values extends string = string> = {
29
+ type: 'Symbol';
30
+ values: Values;
31
+ };
32
+ type Text<Values extends string = string> = {
33
+ type: 'Text';
34
+ values: Values;
35
+ };
36
+ type Integer<Values extends number = number> = {
37
+ type: 'Integer';
38
+ values: Values;
39
+ };
40
+ type Number<Values extends number = number> = {
41
+ type: 'Number';
42
+ values: Values;
43
+ };
44
+ type Date = {
45
+ type: 'Date';
46
+ };
47
+ type Boolean = {
48
+ type: 'Boolean';
49
+ };
50
+ type Location = {
51
+ type: 'Location';
52
+ };
53
+ type RichText = {
54
+ type: 'RichText';
55
+ };
56
+ type EntryLink<EntrySkeleton extends EntrySkeletonType> = {
57
+ type: 'EntryLink';
58
+ entry: EntrySkeleton;
59
+ };
60
+ type EntryResourceLink<EntrySkeleton extends EntrySkeletonType> = {
61
+ type: 'EntryResourceLink';
62
+ entry: EntrySkeleton;
63
+ };
64
+ type ExternalResourceLink = {
65
+ type: 'ExternalResourceLink';
66
+ };
67
+ type AssetLink = {
68
+ type: 'AssetLink';
69
+ };
70
+ type Array<Item extends EntryFieldTypes.Symbol | EntryFieldTypes.AssetLink | EntryFieldTypes.EntryLink<EntrySkeletonType> | EntryFieldTypes.EntryResourceLink<EntrySkeletonType> | EntryFieldTypes.ExternalResourceLink> = {
71
+ type: 'Array';
72
+ item: Item;
73
+ };
74
+ type Object<Data extends JsonObject | JsonArray | null = JsonObject | JsonArray | null> = {
75
+ type: 'Object';
76
+ data: Data;
77
+ };
78
+ }
79
+ /**
80
+ * Definition of entry fields
81
+ * @category Entry
82
+ */
83
+ export declare namespace EntryFields {
84
+ type Symbol<Values extends string = string> = Values;
85
+ type Text<Values extends string = string> = Values;
86
+ type Integer<Values extends number = number> = Values;
87
+ type Number<Values extends number = number> = Values;
88
+ type Date = `${number}-${number}-${number}T${number}:${number}:${number}Z`;
89
+ type Boolean = boolean;
90
+ type Location = {
91
+ lat: number;
92
+ lon: number;
93
+ };
94
+ type EntryLink<EntrySkeleton extends EntrySkeletonType> = Entry<EntrySkeleton>;
95
+ type AssetLink = Asset;
96
+ type Link<EntrySkeleton extends EntrySkeletonType> = AssetLink | EntryLink<EntrySkeleton>;
97
+ type Array<Item extends EntryFields.Symbol | AssetLink | EntryLink<EntrySkeletonType>> = Item[];
98
+ type Object<Data extends JsonObject | JsonArray | null = JsonObject | JsonArray | null> = Data;
99
+ type RichText = RichTextDocument;
100
+ }
101
+ /**
102
+ * All possible values for entry field types with additional type properties
103
+ * @category Entry
104
+ */
105
+ export type EntryFieldType<EntrySkeleton extends EntrySkeletonType> = EntryFieldTypes.Symbol | EntryFieldTypes.Text | EntryFieldTypes.Integer | EntryFieldTypes.Number | EntryFieldTypes.Date | EntryFieldTypes.Boolean | EntryFieldTypes.Location | EntryFieldTypes.RichText | EntryFieldTypes.Object | EntryFieldTypes.EntryLink<EntrySkeleton> | EntryFieldTypes.EntryResourceLink<EntrySkeleton> | EntryFieldTypes.ExternalResourceLink | EntryFieldTypes.AssetLink | EntryFieldTypes.Array<EntryFieldTypes.Symbol> | EntryFieldTypes.Array<EntryFieldTypes.AssetLink> | EntryFieldTypes.Array<EntryFieldTypes.EntryLink<EntrySkeleton>> | EntryFieldTypes.Array<EntryFieldTypes.EntryResourceLink<EntrySkeleton> | EntryFieldTypes.ExternalResourceLink>;
106
+ /**
107
+ * All possible values for entry field types
108
+ * @category Entry
109
+ */
110
+ export type EntryField<EntrySkeleton extends EntrySkeletonType> = EntryFields.Symbol | EntryFields.Text | EntryFields.Integer | EntryFields.Number | EntryFields.Date | EntryFields.Boolean | EntryFields.Location | EntryFields.RichText | EntryFields.Object | EntryFields.EntryLink<EntrySkeleton> | EntryFields.AssetLink | EntryFields.Array<EntryFields.Symbol> | EntryFields.Array<EntryFields.AssetLink> | EntryFields.Array<EntryFields.EntryLink<EntrySkeleton>>;
111
+ /**
112
+ * @category Entry
113
+ */
114
+ export type BaseEntry = {
115
+ sys: EntrySys;
116
+ metadata: Metadata;
117
+ };
118
+ /**
119
+ * Mapping between abstract entry field types with additional type information
120
+ * and entry field types
121
+ * @category Entry
122
+ */
123
+ export type BaseFieldMap<Field extends EntryFieldType<EntrySkeletonType>> = Field extends EntryFieldTypes.Symbol<infer Values> ? EntryFields.Symbol<Values> : Field extends EntryFieldTypes.Text<infer Values> ? EntryFields.Text<Values> : Field extends EntryFieldTypes.Integer<infer Values> ? EntryFields.Integer<Values> : Field extends EntryFieldTypes.Number<infer Values> ? EntryFields.Number<Values> : Field extends EntryFieldTypes.Date ? EntryFields.Date : Field extends EntryFieldTypes.Boolean ? EntryFields.Boolean : Field extends EntryFieldTypes.Location ? EntryFields.Location : Field extends EntryFieldTypes.RichText ? EntryFields.RichText : Field extends EntryFieldTypes.Object<infer Data> ? EntryFields.Object<Data> : never;
124
+ /**
125
+ * A single resolved link to another entry in the same space
126
+ * If the current client configuration includes `withoutLinkResolution` chain option,
127
+ * the returned type will not resolve linked entities, but keep them as objects
128
+ * If the current client configuration includes `withoutUnresolvableLinks` chain option,
129
+ * the returned type will not include non-resolvable linked entities
130
+ * @category Entry
131
+ * @typeParam Modifiers - The chain modifiers used to configure the client. They’re set automatically when using the client chain modifiers.
132
+ * @typeParam Locales - If provided for a client using `allLocales` modifier, response type defines locale keys for entry field values.
133
+ * @typeParam LinkedEntry - Shape of the linked entry used to calculate dynamic keys
134
+ * @internal
135
+ */
136
+ export type ResolvedEntryLink<Modifiers extends ChainModifiers, Locales extends LocaleCode, LinkedEntry extends EntrySkeletonType> = ChainModifiers extends Modifiers ? Entry<LinkedEntry, Modifiers, Locales> | UnresolvedLink<'Entry'> | undefined : 'WITHOUT_LINK_RESOLUTION' extends Modifiers ? UnresolvedLink<'Entry'> : 'WITHOUT_UNRESOLVABLE_LINKS' extends Modifiers ? Entry<LinkedEntry, Modifiers, Locales> | undefined : Entry<LinkedEntry, Modifiers, Locales> | UnresolvedLink<'Entry'>;
137
+ /**
138
+ * A single resolved reference link to another entry in a different space
139
+ * If the current client configuration includes `withoutLinkResolution` chain option,
140
+ * the returned type will not resolve linked entities, but keep them as objects
141
+ * If the current client configuration includes `withoutUnresolvableLinks` chain option,
142
+ * the returned type will not include non-resolvable linked entities
143
+ * @category Entry
144
+ * @typeParam Modifiers - The chain modifiers used to configure the client. They’re set automatically when using the client chain modifiers.
145
+ * @typeParam Locales - If provided for a client using `allLocales` modifier, response type defines locale keys for entry field values.
146
+ * @typeParam LinkedEntry - Shape of the linked entry used to calculate dynamic keys
147
+ * @internal
148
+ */
149
+ export type ResolvedEntryResourceLink<Modifiers extends ChainModifiers, Locales extends LocaleCode, LinkedEntry extends EntrySkeletonType> = ChainModifiers extends Modifiers ? Entry<LinkedEntry, Modifiers, Locales> | {
150
+ sys: ResourceLink;
151
+ } | undefined : 'WITHOUT_LINK_RESOLUTION' extends Modifiers ? {
152
+ sys: ResourceLink;
153
+ } : 'WITHOUT_UNRESOLVABLE_LINKS' extends Modifiers ? Entry<LinkedEntry, Modifiers, Locales> | undefined : Entry<LinkedEntry, Modifiers, Locales> | {
154
+ sys: ResourceLink;
155
+ };
156
+ /**
157
+ * A single resolved link to another asset
158
+ * If the current client configuration includes `withoutLinkResolution` chain option,
159
+ * the returned type will not resolve linked entities, but keep them as objects
160
+ * If the current client configuration includes `withoutUnresolvableLinks` chain option,
161
+ * the returned type will not include non-resolvable linked entities
162
+ * @category Entry
163
+ * @typeParam Modifiers - The chain modifiers used to configure the client. They’re set automatically when using the client chain modifiers.
164
+ * @internal
165
+ */
166
+ export type ResolvedAssetLink<Modifiers extends ChainModifiers, Locales extends LocaleCode> = ChainModifiers extends Modifiers ? Asset<Modifiers, Locales> | UnresolvedLink<'Asset'> | undefined : 'WITHOUT_LINK_RESOLUTION' extends Modifiers ? UnresolvedLink<'Asset'> : 'WITHOUT_UNRESOLVABLE_LINKS' extends Modifiers ? Asset<Modifiers, Locales> | undefined : Asset<Modifiers, Locales> | UnresolvedLink<'Asset'>;
167
+ /**
168
+ * A single resolved link to another resource
169
+ * @category Entry
170
+ * @typeParam Field - Shape of an entry used to calculate dynamic keys
171
+ * @typeParam Modifiers - The chain modifiers used to configure the client. They’re set automatically when using the client chain modifiers.
172
+ * @typeParam Locales - If provided for a client using `allLocales` modifier, response type defines locale keys for entry field values.
173
+ * @internal
174
+ */
175
+ export type ResolvedLink<Field extends EntryFieldType<EntrySkeletonType>, Modifiers extends ChainModifiers = ChainModifiers, Locales extends LocaleCode = LocaleCode> = Field extends EntryFieldTypes.EntryLink<infer LinkedEntry> ? ResolvedEntryLink<Modifiers, Locales, LinkedEntry> : Field extends EntryFieldTypes.EntryResourceLink<infer LinkedEntry> ? ResolvedEntryResourceLink<Modifiers, Locales, LinkedEntry> : Field extends EntryFieldTypes.ExternalResourceLink ? {
176
+ sys: ResourceLink<string>;
177
+ } : Field extends EntryFieldTypes.AssetLink ? ResolvedAssetLink<Modifiers, Locales> : BaseFieldMap<Field>;
178
+ /**
179
+ * A collection or single resolved link to another resource
180
+ * @category Entry
181
+ * @typeParam Field - Shape of an entry used to calculate dynamic keys
182
+ * @typeParam Modifiers - The chain modifiers used to configure the client. They’re set automatically when using the client chain modifiers.
183
+ * @typeParam Locales - If provided for a client using `allLocales` modifier, response type defines locale keys for entry field values.
184
+ * @see {@link https://www.contentful.com/developers/docs/concepts/links/ | Documentation}
185
+ */
186
+ export type ResolvedField<Field extends EntryFieldType<EntrySkeletonType>, Modifiers extends ChainModifiers, Locales extends LocaleCode = LocaleCode> = Field extends EntryFieldTypes.Array<infer Item> ? Array<ResolvedLink<Item, Modifiers, Locales>> : ResolvedLink<Field, Modifiers, Locales>;
187
+ /**
188
+ * Entry represents anything defined as a Content Type in a space
189
+ * @category Entry
190
+ * @typeParam EntrySkeleton - Shape of entry fields used to calculate dynamic keys
191
+ * @typeParam Modifiers - The chain modifiers used to configure the client. They’re set automatically when using the client chain modifiers.
192
+ * @typeParam Locales - If provided for a client using `allLocales` modifier, response type defines locale keys for entry field values.
193
+ * @see {@link https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/entries | Documentation}
194
+ */
195
+ export type Entry<EntrySkeleton extends EntrySkeletonType = EntrySkeletonType, Modifiers extends ChainModifiers = ChainModifiers, Locales extends LocaleCode = LocaleCode> = BaseEntry & {
196
+ sys: {
197
+ contentType: {
198
+ sys: {
199
+ id: EntrySkeleton['contentTypeId'];
200
+ };
201
+ };
202
+ };
203
+ fields: ChainModifiers extends Modifiers ? {
204
+ [FieldName in keyof EntrySkeleton['fields']]: {
205
+ [LocaleName in Locales]?: ResolvedField<EntrySkeleton['fields'][FieldName], Modifiers, Locales>;
206
+ };
207
+ } | {
208
+ [FieldName in keyof EntrySkeleton['fields']]: ResolvedField<EntrySkeleton['fields'][FieldName], Modifiers, Locales>;
209
+ } : 'WITH_ALL_LOCALES' extends Modifiers ? {
210
+ [FieldName in keyof EntrySkeleton['fields']]: {
211
+ [LocaleName in Locales]?: ResolvedField<EntrySkeleton['fields'][FieldName], Modifiers, Locales>;
212
+ };
213
+ } : {
214
+ [FieldName in keyof EntrySkeleton['fields']]: ResolvedField<EntrySkeleton['fields'][FieldName], Modifiers, Locales>;
215
+ };
216
+ };
217
+ /**
218
+ * A collection of entries
219
+ * @category Entry
220
+ * @typeParam EntrySkeleton - Shape of entry fields used to calculate dynamic keys
221
+ * @typeParam Modifiers - The chain modifiers used to configure the client. They’re set automatically when using the client chain modifiers.
222
+ * @typeParam Locales - If provided for a client using `allLocales` modifier, response type defines locale keys for entry field values.
223
+ * @see {@link https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/entries | Documentation}
224
+ */
225
+ export type EntryCollection<EntrySkeleton extends EntrySkeletonType, Modifiers extends ChainModifiers = ChainModifiers, Locales extends LocaleCode = LocaleCode> = ContentfulCollection<Entry<EntrySkeleton, Modifiers, Locales>> & {
226
+ errors?: Array<any>;
227
+ includes?: {
228
+ Entry?: Entry<EntrySkeletonType, Modifiers, Locales>[];
229
+ Asset?: Asset<Modifiers, Locales>[];
230
+ };
231
+ };
232
+ /**
233
+ * A cursor paginated collection of entries
234
+ * @category Entry
235
+ * @typeParam EntrySkeleton - Shape of entry fields used to calculate dynamic keys
236
+ * @typeParam Modifiers - The chain modifiers used to configure the client. They’re set automatically when using the client chain modifiers.
237
+ * @typeParam Locales - If provided for a client using `allLocales` modifier, response type defines locale keys for entry field values.
238
+ * @see {@link https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/entries | Documentation}
239
+ */
240
+ export type EntryCursorPaginatedCollection<EntrySkeleton extends EntrySkeletonType, Modifiers extends ChainModifiers = ChainModifiers, Locales extends LocaleCode = LocaleCode> = CursorPaginatedCollection<Entry<EntrySkeleton, Modifiers, Locales>> & {
241
+ errors?: Array<any>;
242
+ includes?: {
243
+ Entry?: Entry<EntrySkeletonType, Modifiers, Locales>[];
244
+ Asset?: Asset<Modifiers, Locales>[];
245
+ };
246
+ };
@@ -0,0 +1,17 @@
1
+ export * from './asset.js';
2
+ export * from './asset-key.js';
3
+ export { AddChainModifier, ChainModifiers, ContentfulClientApi } from './client.js';
4
+ export * from './collection.js';
5
+ export * from './concept-scheme.js';
6
+ export * from './concept.js';
7
+ export * from './content-type.js';
8
+ export * from './entry.js';
9
+ export * from './link.js';
10
+ export * from './locale.js';
11
+ export * from './metadata.js';
12
+ export * from './query/index.js';
13
+ export * from './resource-link.js';
14
+ export * from './space.js';
15
+ export * from './sync.js';
16
+ export * from './sys.js';
17
+ export * from './tag.js';
@@ -0,0 +1,61 @@
1
+ import type { ResourceLink } from './resource-link.js';
2
+ /**
3
+ * @category Link
4
+ */
5
+ export type LinkType = 'Space' | 'ContentType' | 'Environment' | 'Entry' | 'Tag' | 'User' | 'Asset' | 'TaxonomyConcept' | 'TaxonomyConceptScheme';
6
+ /**
7
+ * Link definition of a specific link type
8
+ * @category Link
9
+ */
10
+ export interface Link<T extends LinkType> {
11
+ type: 'Link';
12
+ linkType: T;
13
+ id: string;
14
+ }
15
+ /**
16
+ * Unresolved link field of a specific link type
17
+ * @category Link
18
+ */
19
+ export type UnresolvedLink<T extends LinkType> = {
20
+ sys: Link<T>;
21
+ };
22
+ /**
23
+ * Space link type
24
+ * @category Entity
25
+ */
26
+ export type SpaceLink = Link<'Space'>;
27
+ /**
28
+ * Content type link type
29
+ * @category ContentType
30
+ */
31
+ export type ContentTypeLink = Link<'ContentType'>;
32
+ /**
33
+ * Environment link type
34
+ * @category Entity
35
+ */
36
+ export type EnvironmentLink = Link<'Environment'>;
37
+ /**
38
+ * Asset link type
39
+ * @category Asset
40
+ */
41
+ export type AssetLink = Link<'Asset'>;
42
+ /**
43
+ * Entry link type
44
+ * @category Entry
45
+ */
46
+ export type EntryLink = Link<'Entry'> | ResourceLink;
47
+ /**
48
+ * Tag link type
49
+ * @category Tag
50
+ */
51
+ export type TagLink = Link<'Tag'>;
52
+ /**
53
+ * User link type
54
+ * @category Entity
55
+ */
56
+ export type UserLink = Link<'User'>;
57
+ /**
58
+ * Taxonomy Concept link type
59
+ * @category Entity
60
+ */
61
+ export type TaxonomyConceptLink = Link<'TaxonomyConcept'>;
@@ -0,0 +1,30 @@
1
+ import type { ContentfulCollection } from './collection.js';
2
+ import type { BaseSys } from './sys.js';
3
+ /**
4
+ * @category Entity
5
+ */
6
+ export type LocaleCode = string;
7
+ /**
8
+ * System managed metadata for locale
9
+ * @category Entity
10
+ */
11
+ export interface LocaleSys extends BaseSys {
12
+ type: 'Locale';
13
+ version: number;
14
+ }
15
+ /**
16
+ * Properties of a single locale definition
17
+ * @category Entity
18
+ */
19
+ export interface Locale {
20
+ code: string;
21
+ name: string;
22
+ default: boolean;
23
+ fallbackCode: string | null;
24
+ sys: LocaleSys;
25
+ }
26
+ /**
27
+ * Collection of locales
28
+ * @category Entity
29
+ */
30
+ export type LocaleCollection = ContentfulCollection<Locale>;
@@ -0,0 +1,13 @@
1
+ import type { TagLink, TaxonomyConceptLink } from './link.js';
2
+ /**
3
+ * User-controlled metadata
4
+ * @category Entity
5
+ */
6
+ export type Metadata = {
7
+ tags: {
8
+ sys: TagLink;
9
+ }[];
10
+ concepts?: {
11
+ sys: TaxonomyConceptLink;
12
+ }[];
13
+ };
@@ -0,0 +1,29 @@
1
+ import type { EntryFields, EntryFieldType, EntryFieldTypes } from '../entry.js';
2
+ import type { ConditionalQueries, EntryFieldsConditionalQueries, EntrySkeletonType } from './util.js';
3
+ type SupportedTypes = EntryFields.Symbol | EntryFields.Symbol[] | EntryFields.Text | EntryFields.Integer | EntryFields.Number | EntryFields.Date | EntryFields.Boolean | undefined;
4
+ type SupportedEntryFieldTypes = EntryFieldTypes.Symbol | EntryFieldTypes.Array<EntryFieldTypes.Symbol> | EntryFieldTypes.Text | EntryFieldTypes.Integer | EntryFieldTypes.Number | EntryFieldTypes.Date | EntryFieldTypes.Boolean | undefined;
5
+ /**
6
+ * Equality filters in provided fields - search for exact matches
7
+ * @see {@link https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters/equality-operator | Documentation}
8
+ * @internal
9
+ */
10
+ export type EqualityFilter<Fields, Prefix extends string> = ConditionalQueries<Fields, SupportedTypes, Prefix, ''>;
11
+ /**
12
+ * Equality filters in provided fields of an entry - search for exact matches
13
+ * @see {@link https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters/equality-operator | Documentation}
14
+ * @internal
15
+ */
16
+ export type EntryFieldsEqualityFilter<Fields extends Record<string, EntryFieldType<EntrySkeletonType>>, Prefix extends string> = EntryFieldsConditionalQueries<Fields, SupportedEntryFieldTypes, Prefix, ''>;
17
+ /**
18
+ * Inequality filters in provided fields - exclude matching items
19
+ * @see {@link https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters/inequality-operator | Documentation}
20
+ * @internal
21
+ */
22
+ export type InequalityFilter<Fields, Prefix extends string> = ConditionalQueries<Fields, SupportedTypes, Prefix, '[ne]'>;
23
+ /**
24
+ * Inequality filters in provided fields of an entry - exclude matching items
25
+ * @see {@link https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters/inequality-operator | Documentation}
26
+ * @internal
27
+ */
28
+ export type EntryFieldsInequalityFilter<Fields extends Record<string, EntryFieldType<EntrySkeletonType>>, Prefix extends string> = EntryFieldsConditionalQueries<Fields, SupportedEntryFieldTypes, Prefix, '[ne]'>;
29
+ export {};
@@ -0,0 +1,15 @@
1
+ import type { EntryField, EntryFieldType } from '../entry.js';
2
+ import type { ConditionalFixedQueries, FieldsType, EntrySkeletonType } from './util.js';
3
+ import type { AssetDetails, AssetFile } from '../asset.js';
4
+ /**
5
+ * Check for existence of provided fields
6
+ * @see {@link https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters/existence | Documentation}
7
+ * @internal
8
+ */
9
+ export type ExistenceFilter<Fields extends FieldsType, Prefix extends string> = ConditionalFixedQueries<Fields, EntryField<EntrySkeletonType<Fields>> | AssetFile | AssetDetails | undefined, boolean, Prefix, '[exists]'>;
10
+ /**
11
+ * Check for existence of provided fields in an entry
12
+ * @see {@link https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters/existence | Documentation}
13
+ * @internal
14
+ */
15
+ export type EntryFieldsExistenceFilter<Fields extends FieldsType, Prefix extends string> = ConditionalFixedQueries<Fields, EntryFieldType<EntrySkeletonType> | undefined, boolean, Prefix, '[exists]'>;
@@ -0,0 +1,12 @@
1
+ export { type FieldsType, EntrySkeletonType, type ConditionalFixedQueries, type ConditionalListQueries, } from './util.js';
2
+ export * from './equality.js';
3
+ export * from './existence.js';
4
+ export * from './location.js';
5
+ export * from './order.js';
6
+ export * from './query.js';
7
+ export * from './range.js';
8
+ export * from './reference.js';
9
+ export * from './search.js';
10
+ export * from './select.js';
11
+ export * from './set.js';
12
+ export * from './subset.js';
@@ -0,0 +1,29 @@
1
+ import type { ConditionalPick } from 'type-fest';
2
+ import type { EntryFieldTypes } from '../entry.js';
3
+ type Types = EntryFieldTypes.Location | undefined;
4
+ export type ProximitySearchFilterInput = [number, number];
5
+ export type BoundingBoxSearchFilterInput = [number, number, number, number];
6
+ export type BoundingCircleSearchFilterInput = [number, number, number];
7
+ type BaseLocationFilter<Fields, SupportedTypes, ValueType, Prefix extends string, QueryFilter extends string = ''> = NonNullable<{
8
+ [FieldName in keyof ConditionalPick<Fields, SupportedTypes> as `${Prefix}.${string & FieldName}[${QueryFilter}]`]?: ValueType;
9
+ }>;
10
+ /**
11
+ * near - location proximity search in provided fields
12
+ * @see {@link https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters/location-proximity-search | Documentation}
13
+ * @internal
14
+ */
15
+ export type ProximitySearchFilter<Fields, Prefix extends string> = BaseLocationFilter<Fields, Types, ProximitySearchFilterInput, Prefix, 'near'>;
16
+ /**
17
+ * within - location in a bounding object in provided fields
18
+ * @see {@link https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters/locations-in-a-bounding-object | Documentation}
19
+ * @internal
20
+ */
21
+ export type BoundingObjectSearchFilter<Fields, Prefix extends string> = BaseLocationFilter<Fields, Types, BoundingCircleSearchFilterInput | BoundingBoxSearchFilterInput, Prefix, 'within'>;
22
+ /**
23
+ * Location search
24
+ * @see {@link ProximitySearchFilter}
25
+ * @see {@link BoundingObjectSearchFilter}
26
+ * @internal
27
+ */
28
+ export type LocationSearchFilters<Fields, Prefix extends string> = ProximitySearchFilter<Fields, Prefix> & BoundingObjectSearchFilter<Fields, Prefix>;
29
+ export {};
@@ -0,0 +1,44 @@
1
+ import type { EntrySkeletonType, FieldsType } from './util.js';
2
+ import type { EntryFields, EntryFieldType, EntryFieldTypes, EntrySys } from '../entry.js';
3
+ import type { AssetSys } from '../asset.js';
4
+ import type { ConditionalPick } from 'type-fest';
5
+ import type { TagSys } from '../tag.js';
6
+ export type SupportedTypes = EntryFields.Symbol | EntryFields.Integer | EntryFields.Number | EntryFields.Date | EntryFields.Boolean | EntryFields.Location | undefined;
7
+ export type SupportedEntryFieldTypes = EntryFieldTypes.Symbol | EntryFieldTypes.Integer | EntryFieldTypes.Number | EntryFieldTypes.Date | EntryFieldTypes.Boolean | EntryFieldTypes.Location | undefined;
8
+ export type SupportedLinkTypes = EntryFieldTypes.AssetLink | EntryFieldTypes.EntryLink<any> | undefined;
9
+ export type OrderFilterPaths<Fields extends FieldsType, Prefix extends string> = `${Prefix}.${keyof ConditionalPick<Fields, SupportedTypes> & string}` | `-${Prefix}.${keyof ConditionalPick<Fields, SupportedTypes> & string}`;
10
+ /**
11
+ * Order for provided fields in an entry
12
+ * @see {@link https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters/order | Documentation}
13
+ * @internal
14
+ */
15
+ export type EntryOrderFilterWithFields<Fields extends Record<string, EntryFieldType<EntrySkeletonType>>> = {
16
+ order?: (`fields.${keyof ConditionalPick<Fields, SupportedEntryFieldTypes> & string}` | `-fields.${keyof ConditionalPick<Fields, SupportedEntryFieldTypes> & string}` | `fields.${keyof ConditionalPick<Fields, SupportedLinkTypes> & string}.sys.id` | `-fields.${keyof ConditionalPick<Fields, SupportedLinkTypes> & string}.sys.id` | OrderFilterPaths<EntrySys, 'sys'> | 'sys.contentType.sys.id' | '-sys.contentType.sys.id')[];
17
+ };
18
+ /**
19
+ * Order in an entry
20
+ * @see {@link https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters/order | Documentation}
21
+ * @internal
22
+ */
23
+ export type EntryOrderFilter = {
24
+ order?: (OrderFilterPaths<EntrySys, 'sys'> | 'sys.contentType.sys.id' | '-sys.contentType.sys.id')[];
25
+ };
26
+ /**
27
+ * Order in an asset
28
+ * @see {@link https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters/order | Documentation}
29
+ * @internal
30
+ */
31
+ export type AssetOrderFilter = {
32
+ order?: (OrderFilterPaths<AssetSys, 'sys'> | 'fields.file.contentType' | '-fields.file.contentType' | 'fields.file.fileName' | '-fields.file.fileName' | 'fields.file.url' | '-fields.file.url' | 'fields.file.details.size' | '-fields.file.details.size')[];
33
+ };
34
+ /**
35
+ * Order in a tag
36
+ * @see {@link https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters/order | Documentation}
37
+ * @internal
38
+ */
39
+ export type TagOrderFilter = {
40
+ order?: (OrderFilterPaths<TagSys, 'sys'> | 'name' | '-name')[];
41
+ };
42
+ export type TaxonomyOrderFilter = {
43
+ order?: ('sys.createdAt' | 'sys.updatedAt' | 'prefLabel')[];
44
+ };