@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.
- package/ADVANCED.md +283 -0
- package/CONTRIBUTING.md +109 -0
- package/LICENSE +21 -0
- package/MIGRATION.md +364 -0
- package/README.md +36 -0
- package/TYPESCRIPT.md +329 -0
- package/changes.json +30 -0
- package/dist/contentful.browser.js +10886 -0
- package/dist/contentful.browser.min.js +1 -0
- package/dist/contentful.cjs +23983 -0
- package/dist/esm/contentful.js +60 -0
- package/dist/esm/create-contentful-api.js +463 -0
- package/dist/esm/create-global-options.js +21 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/make-client.js +52 -0
- package/dist/esm/mixins/stringify-safe.js +23 -0
- package/dist/esm/paged-sync.js +118 -0
- package/dist/esm/utils/normalize-cursor-pagination-parameters.js +9 -0
- package/dist/esm/utils/normalize-cursor-pagination-response.js +23 -0
- package/dist/esm/utils/normalize-search-parameters.js +18 -0
- package/dist/esm/utils/normalize-select.js +25 -0
- package/dist/esm/utils/query-selection-set.js +14 -0
- package/dist/esm/utils/resolve-circular.js +15 -0
- package/dist/esm/utils/timeline-preview-helpers.js +33 -0
- package/dist/esm/utils/validate-params.js +65 -0
- package/dist/esm/utils/validate-search-parameters.js +11 -0
- package/dist/esm/utils/validate-timestamp.js +16 -0
- package/dist/esm/utils/validation-error.js +8 -0
- package/dist/stats-browser-min.html +4949 -0
- package/dist/types/contentful.d.ts +150 -0
- package/dist/types/create-contentful-api.d.ts +13 -0
- package/dist/types/create-global-options.d.ts +19 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/make-client.d.ts +3 -0
- package/dist/types/mixins/stringify-safe.d.ts +1 -0
- package/dist/types/paged-sync.d.ts +7 -0
- package/dist/types/types/asset-key.d.ts +7 -0
- package/dist/types/types/asset.d.ts +79 -0
- package/dist/types/types/client.d.ts +477 -0
- package/dist/types/types/collection.d.ts +42 -0
- package/dist/types/types/concept-scheme.d.ts +26 -0
- package/dist/types/types/concept.d.ts +51 -0
- package/dist/types/types/content-type.d.ts +105 -0
- package/dist/types/types/entry.d.ts +246 -0
- package/dist/types/types/index.d.ts +17 -0
- package/dist/types/types/link.d.ts +61 -0
- package/dist/types/types/locale.d.ts +30 -0
- package/dist/types/types/metadata.d.ts +13 -0
- package/dist/types/types/query/equality.d.ts +29 -0
- package/dist/types/types/query/existence.d.ts +15 -0
- package/dist/types/types/query/index.d.ts +12 -0
- package/dist/types/types/query/location.d.ts +29 -0
- package/dist/types/types/query/order.d.ts +44 -0
- package/dist/types/types/query/query.d.ts +155 -0
- package/dist/types/types/query/range.d.ts +18 -0
- package/dist/types/types/query/reference.d.ts +12 -0
- package/dist/types/types/query/search.d.ts +17 -0
- package/dist/types/types/query/select.d.ts +29 -0
- package/dist/types/types/query/set.d.ts +10 -0
- package/dist/types/types/query/subset.d.ts +20 -0
- package/dist/types/types/query/util.d.ts +32 -0
- package/dist/types/types/resource-link.d.ts +9 -0
- package/dist/types/types/space.d.ts +20 -0
- package/dist/types/types/sync.d.ts +84 -0
- package/dist/types/types/sys.d.ts +30 -0
- package/dist/types/types/tag.d.ts +32 -0
- package/dist/types/types/timeline-preview.d.ts +16 -0
- package/dist/types/utils/client-helpers.d.ts +9 -0
- package/dist/types/utils/normalize-cursor-pagination-parameters.d.ts +5 -0
- package/dist/types/utils/normalize-cursor-pagination-response.d.ts +2 -0
- package/dist/types/utils/normalize-search-parameters.d.ts +1 -0
- package/dist/types/utils/normalize-select.d.ts +1 -0
- package/dist/types/utils/query-selection-set.d.ts +1 -0
- package/dist/types/utils/resolve-circular.d.ts +4 -0
- package/dist/types/utils/timeline-preview-helpers.d.ts +7 -0
- package/dist/types/utils/validate-params.d.ts +6 -0
- package/dist/types/utils/validate-search-parameters.d.ts +1 -0
- package/dist/types/utils/validate-timestamp.d.ts +6 -0
- package/dist/types/utils/validation-error.d.ts +3 -0
- package/images/contentful-icon.png +0 -0
- package/images/dynamic-query-keys.png +0 -0
- package/images/static-query-keys.png +0 -0
- package/package.json +221 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contentful Delivery API SDK. Allows you to create instances of a client
|
|
3
|
+
* with access to the Contentful Content Delivery API.
|
|
4
|
+
*/
|
|
5
|
+
import type { AxiosAdapter, AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
6
|
+
import type { ContentfulClientApi } from './types/client.js';
|
|
7
|
+
import type { TimelinePreview } from './types/timeline-preview.js';
|
|
8
|
+
/**
|
|
9
|
+
* @category Client
|
|
10
|
+
*/
|
|
11
|
+
export type ClientLogLevel = 'error' | 'warning' | 'info' | string;
|
|
12
|
+
/**
|
|
13
|
+
* Client initialization parameters
|
|
14
|
+
* @category Client
|
|
15
|
+
*/
|
|
16
|
+
export interface CreateClientParams {
|
|
17
|
+
/**
|
|
18
|
+
* Space ID
|
|
19
|
+
*/
|
|
20
|
+
space: string;
|
|
21
|
+
/**
|
|
22
|
+
* Contentful CDA Access Token
|
|
23
|
+
*/
|
|
24
|
+
accessToken: string;
|
|
25
|
+
/**
|
|
26
|
+
* Contentful Environment ID
|
|
27
|
+
* @defaultValue "master"
|
|
28
|
+
*/
|
|
29
|
+
environment?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Requests will be made over http instead of the default https
|
|
32
|
+
* @defaultValue true
|
|
33
|
+
*/
|
|
34
|
+
insecure?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* API host. Also usable with preview.contentful.com.
|
|
37
|
+
* @defaultValue "cdn.contentful.com"
|
|
38
|
+
*/
|
|
39
|
+
host?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Path appended to the host to support gateways/proxies with custom urls
|
|
42
|
+
*/
|
|
43
|
+
basePath?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Optional Node.js HTTP agent for proxying
|
|
46
|
+
* (see <a href="https://nodejs.org/api/http.html#http_class_http_agent">Node.js docs</a>
|
|
47
|
+
* and <a href="https://www.npmjs.com/package/https-proxy-agent">https-proxy-agent</a>)
|
|
48
|
+
*/
|
|
49
|
+
httpAgent?: AxiosRequestConfig['httpAgent'];
|
|
50
|
+
/**
|
|
51
|
+
* Optional Node.js HTTP agent for proxying
|
|
52
|
+
* (see <a href="https://nodejs.org/api/http.html#http_class_http_agent">Node.js docs</a>
|
|
53
|
+
* and <a href="https://www.npmjs.com/package/https-proxy-agent">https-proxy-agent</a>)
|
|
54
|
+
*/
|
|
55
|
+
httpsAgent?: AxiosRequestConfig['httpsAgent'];
|
|
56
|
+
/**
|
|
57
|
+
* Optional Axios proxy (see <a href="https://github.com/mzabriskie/axios#request-config"> axios docs </a>)
|
|
58
|
+
*/
|
|
59
|
+
proxy?: AxiosRequestConfig['proxy'];
|
|
60
|
+
/**
|
|
61
|
+
* Optional additional headers
|
|
62
|
+
*/
|
|
63
|
+
headers?: Record<string, string>;
|
|
64
|
+
/**
|
|
65
|
+
* Optional axios request adapter (see <a href="https://github.com/mzabriskie/axios#request-config"> axios docs </a>)
|
|
66
|
+
*/
|
|
67
|
+
adapter?: AxiosAdapter;
|
|
68
|
+
/**
|
|
69
|
+
* Application name and version e.g myApp/version
|
|
70
|
+
*/
|
|
71
|
+
application?: string;
|
|
72
|
+
/**
|
|
73
|
+
* Integration name and version e.g react/version
|
|
74
|
+
*/
|
|
75
|
+
integration?: string;
|
|
76
|
+
/**
|
|
77
|
+
* If we should retry on errors and 429 rate limit exceptions
|
|
78
|
+
* @defaultValue true
|
|
79
|
+
*/
|
|
80
|
+
retryOnError?: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* A log handler function to process given log messages and errors.
|
|
83
|
+
* (The default can be found at: https://github.com/contentful/contentful-sdk-core/blob/master/src/create-http-client.ts)
|
|
84
|
+
* @param level - Log level, e.g. error, warning, or info
|
|
85
|
+
* @param data - Log data
|
|
86
|
+
*/
|
|
87
|
+
logHandler?: (level: ClientLogLevel, data?: Record<string, any> | string) => void;
|
|
88
|
+
/**
|
|
89
|
+
* connection timeout in milliseconds (default:30000)
|
|
90
|
+
*/
|
|
91
|
+
timeout?: number;
|
|
92
|
+
/**
|
|
93
|
+
* Optional number of retries before failure.
|
|
94
|
+
* @defaultValue 5
|
|
95
|
+
*/
|
|
96
|
+
retryLimit?: number;
|
|
97
|
+
/**
|
|
98
|
+
* Interceptor called on every request. Takes Axios request config as an arg.
|
|
99
|
+
*/
|
|
100
|
+
requestLogger?: (request: AxiosRequestConfig | Error) => unknown;
|
|
101
|
+
/**
|
|
102
|
+
* Interceptor called on every response. Takes Axios response object as an arg.
|
|
103
|
+
*/
|
|
104
|
+
responseLogger?: (response: AxiosResponse<any> | Error) => unknown;
|
|
105
|
+
/**
|
|
106
|
+
* Enable Content Source Maps.
|
|
107
|
+
* @remarks
|
|
108
|
+
* This feature is only available when using the Content Preview API.
|
|
109
|
+
*/
|
|
110
|
+
includeContentSourceMaps?: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* Enable Timeline Preview.
|
|
113
|
+
*
|
|
114
|
+
* @remarks
|
|
115
|
+
* This feature is only available when using the Content Preview API.
|
|
116
|
+
*/
|
|
117
|
+
timelinePreview?: TimelinePreview;
|
|
118
|
+
/**
|
|
119
|
+
* Enable alpha features.
|
|
120
|
+
*/
|
|
121
|
+
alphaFeatures?: {
|
|
122
|
+
/**
|
|
123
|
+
* @deprecated Use the `includeContentSourceMaps` option directly instead.
|
|
124
|
+
*/
|
|
125
|
+
includeContentSourceMaps?: boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Enable Timeline Preview.
|
|
128
|
+
*
|
|
129
|
+
* @remarks
|
|
130
|
+
* This feature is only available when using the Content Preview API.
|
|
131
|
+
*
|
|
132
|
+
* @deprecated Use the `timelinePreview` option directly instead.
|
|
133
|
+
*/
|
|
134
|
+
timelinePreview?: TimelinePreview;
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Create a client instance
|
|
139
|
+
* @param params - Client initialization parameters
|
|
140
|
+
* @category Client
|
|
141
|
+
* @example
|
|
142
|
+
* ```typescript
|
|
143
|
+
* const contentful = require('contentful')
|
|
144
|
+
* const client = contentful.createClient({
|
|
145
|
+
* accessToken: 'myAccessToken',
|
|
146
|
+
* space: 'mySpaceId'
|
|
147
|
+
* })
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
150
|
+
export declare function createClient(params: CreateClientParams): ContentfulClientApi<undefined>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contentful Delivery API Client. Contains methods which allow access to the
|
|
3
|
+
* different kinds of entities present in Contentful (Entries, Assets, etc).
|
|
4
|
+
*/
|
|
5
|
+
import type { AxiosInstance } from 'contentful-sdk-core';
|
|
6
|
+
import type { GetGlobalOptions } from './create-global-options.js';
|
|
7
|
+
import type { ContentfulClientApi } from './types/index.js';
|
|
8
|
+
import type { ChainOptions } from './utils/client-helpers.js';
|
|
9
|
+
export interface CreateContentfulApiParams {
|
|
10
|
+
http: AxiosInstance;
|
|
11
|
+
getGlobalOptions: GetGlobalOptions;
|
|
12
|
+
}
|
|
13
|
+
export default function createContentfulApi<OptionType extends ChainOptions>({ http, getGlobalOptions }: CreateContentfulApiParams, options?: OptionType): ContentfulClientApi<undefined>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @category Client
|
|
3
|
+
*/
|
|
4
|
+
export interface GlobalOptionsParams {
|
|
5
|
+
environment?: string;
|
|
6
|
+
space?: string;
|
|
7
|
+
spaceBaseUrl?: string;
|
|
8
|
+
environmentBaseUrl?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* @category Client
|
|
12
|
+
*/
|
|
13
|
+
export type GetGlobalOptions = (globalOptions?: GlobalOptionsParams) => Required<GlobalOptionsParams>;
|
|
14
|
+
/**
|
|
15
|
+
* @param globalSettings - Global library settings
|
|
16
|
+
* @returns getGlobalSettings - Method returning client settings
|
|
17
|
+
* @category Client
|
|
18
|
+
*/
|
|
19
|
+
export declare function createGlobalOptions(globalSettings: Required<GlobalOptionsParams>): GetGlobalOptions;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function mixinStringifySafe(data: any): any;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AxiosInstance } from 'contentful-sdk-core';
|
|
2
|
+
import type { SyncCollection, SyncOptions, SyncQuery, LocaleCode, EntrySkeletonType } from './types/index.js';
|
|
3
|
+
import type { ChainOptions, ModifiersFromOptions } from './utils/client-helpers.js';
|
|
4
|
+
/**
|
|
5
|
+
* Retrieves all the available pages for a sync operation
|
|
6
|
+
*/
|
|
7
|
+
export default function pagedSync<EntrySkeleton extends EntrySkeletonType, Locales extends LocaleCode, Options extends ChainOptions>(http: AxiosInstance, query: SyncQuery, options?: SyncOptions | ChainOptions): Promise<SyncCollection<EntrySkeleton, ModifiersFromOptions<Options>, Locales>>;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { ContentfulCollection, CursorPaginatedCollection } from './collection.js';
|
|
2
|
+
import type { LocaleCode } from './locale.js';
|
|
3
|
+
import type { Metadata } from './metadata.js';
|
|
4
|
+
import type { EntitySys } from './sys.js';
|
|
5
|
+
import type { ChainModifiers } from './client.js';
|
|
6
|
+
/**
|
|
7
|
+
* @category Asset
|
|
8
|
+
*/
|
|
9
|
+
export interface AssetDetails {
|
|
10
|
+
size: number;
|
|
11
|
+
image?: {
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* @category Asset
|
|
18
|
+
*/
|
|
19
|
+
export interface AssetFile {
|
|
20
|
+
url: string;
|
|
21
|
+
details: AssetDetails;
|
|
22
|
+
fileName: string;
|
|
23
|
+
contentType: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* @category Asset
|
|
27
|
+
*/
|
|
28
|
+
export interface AssetFields {
|
|
29
|
+
title?: string;
|
|
30
|
+
description?: string;
|
|
31
|
+
file?: AssetFile;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Assets are binary files in a Contentful space
|
|
35
|
+
* @category Asset
|
|
36
|
+
* @typeParam Modifiers - The chain modifiers used to configure the client. They’re set automatically when using the client chain modifiers.
|
|
37
|
+
* @typeParam Locales - If provided for a client using `allLocales` modifier, response type defines locale keys for asset field values.
|
|
38
|
+
* @see {@link https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/assets | Documentation}
|
|
39
|
+
*/
|
|
40
|
+
export interface Asset<Modifiers extends ChainModifiers = ChainModifiers, Locales extends LocaleCode = LocaleCode> {
|
|
41
|
+
sys: AssetSys;
|
|
42
|
+
fields: ChainModifiers extends Modifiers ? {
|
|
43
|
+
[FieldName in keyof AssetFields]: {
|
|
44
|
+
[LocaleName in Locales]?: AssetFields[FieldName];
|
|
45
|
+
};
|
|
46
|
+
} | AssetFields : 'WITH_ALL_LOCALES' extends Modifiers ? {
|
|
47
|
+
[FieldName in keyof AssetFields]: {
|
|
48
|
+
[LocaleName in Locales]?: AssetFields[FieldName];
|
|
49
|
+
};
|
|
50
|
+
} : AssetFields;
|
|
51
|
+
metadata: Metadata;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* @category Asset
|
|
55
|
+
*/
|
|
56
|
+
export type AssetMimeType = 'attachment' | 'plaintext' | 'image' | 'audio' | 'video' | 'richtext' | 'presentation' | 'spreadsheet' | 'pdfdocument' | 'archive' | 'code' | 'markup';
|
|
57
|
+
/**
|
|
58
|
+
* A collection of assets
|
|
59
|
+
* @category Asset
|
|
60
|
+
* @typeParam Modifiers - The chain modifiers used to configure the client. They’re set automatically when using the client chain modifiers.
|
|
61
|
+
* @typeParam Locales - If provided for a client using `allLocales` modifier, response type defines locale keys for asset field values.
|
|
62
|
+
* @see {@link https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/assets | Documentation}
|
|
63
|
+
*/
|
|
64
|
+
export type AssetCollection<Modifiers extends ChainModifiers = ChainModifiers, Locales extends LocaleCode = LocaleCode> = ContentfulCollection<Asset<Modifiers, Locales>>;
|
|
65
|
+
/**
|
|
66
|
+
* A cursor paginated collection of assets
|
|
67
|
+
* @category Asset
|
|
68
|
+
* @typeParam Modifiers - The chain modifiers used to configure the client. They’re set automatically when using the client chain modifiers.
|
|
69
|
+
* @typeParam Locales - If provided for a client using `allLocales` modifier, response type defines locale keys for asset field values.
|
|
70
|
+
* @see {@link https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/assets | Documentation}
|
|
71
|
+
*/
|
|
72
|
+
export type AssetCursorPaginatedCollection<Modifiers extends ChainModifiers = ChainModifiers, Locales extends LocaleCode = LocaleCode> = CursorPaginatedCollection<Asset<Modifiers, Locales>>;
|
|
73
|
+
/**
|
|
74
|
+
* System managed metadata for assets
|
|
75
|
+
* @category Asset
|
|
76
|
+
*/
|
|
77
|
+
export type AssetSys = EntitySys & {
|
|
78
|
+
type: 'Asset';
|
|
79
|
+
};
|