diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ef7f248a..770acb62f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ Readme · Setup · Migration · - Changelog · + Changelog · Contributing

diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e07a6e2ad..9184c6948 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -14,7 +14,7 @@ Readme · Setup · Migration · - Changelog · + Changelog · Contributing

diff --git a/README.md b/README.md index 82ad51ffe..d1fd25593 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@

Readme · Setup · - Changelog · + Changelog · Contributing

@@ -44,34 +44,22 @@ - [Getting started](#getting-started) - [Installation](#installation) - - [Node:](#node) - - [Browser:](#browser) + - [Node](#node) + - [Browser](#browser) - [Typings](#typings) - [Authentication](#authentication) - - [Using ES6 import](#using-es6-import) - - [Your first request](#your-first-request) - - [Legacy Client Interface](#legacy-client-interface) + - [Importing the library](#importing-the-library) + - [Using the Plain Client](#using-the-plain-client) + - [With scoped space and environment](#with-scoped-space-and-environment) + - [Using the Legacy Client](#using-the-legacy-client) - [App Framework](#app-framework) - [Troubleshooting](#troubleshooting) - [Documentation/References](#documentationreferences) - - [Configuration](#configuration) - - [accessToken (required, when `apiAdapter` is not set)](#accesstoken-required-when-apiadapter-is-not-set) - - [host (default: `'api.contentful.com'`)](#host-default-apicontentfulcom) - - [hostUpload (default: `'upload.contentful.com'`)](#hostupload-default-uploadcontentfulcom) - - [basePath (default: \`\`)](#basepath-default-) - - [httpAgent (default: `undefined`)](#httpagent-default-undefined) - - [httpsAgent (default: `undefined`)](#httpsagent-default-undefined) - - [headers (default: `{}`)](#headers-default-) - - [proxy (default: `undefined`)](#proxy-default-undefined) - - [retryOnError (default: `true`)](#retryonerror-default-true) - - [logHandler (default: `function (level, data) {}`)](#loghandler-default-function-level-data-) - - [requestLogger (default: `function (config) {}`)](#requestlogger-default-function-config-) - - [responseLogger (default: `function (response) {}`)](#responselogger-default-function-response-) - - [apiAdapter (default: `new RestAdapter(configuration)`)](#apiadapter-default-new-restadapterconfiguration) - - [throttle (default: `0`)](#throttle-default-0) + - [REST API reference with examples](#rest-api-reference-with-examples) - [Reference documentation](#reference-documentation) - - [Contentful JavaScript resources](#contentful-javascript-resources) - - [REST API reference](#rest-api-reference) + - [Configuration](#configuration) + - [Request configuration options](#request-configuration-options) + - [Tutorials \& other resources](#tutorials--other-resources) - [Versioning](#versioning) - [Reach out to us](#reach-out-to-us) - [You have questions about how to use this library?](#you-have-questions-about-how-to-use-this-library) @@ -89,6 +77,9 @@ - Content management and retrieval through Contentful's [Content Management API](https://www.contentful.com/developers/docs/references/content-management-api/). - Built in rate limiting with recovery procedures - Asset processing helpers +- Two different types of clients: + - [Plain Client](#using-the-plain-client) + - [Legacy Chainable Client ](#using-the-legacy-client) ## Supported environments @@ -108,14 +99,14 @@ To get started with the Contentful Management JS library you'll need to install - [Installation](#installation) - [Authentication](#authentication) -- [Using ES6 import](#using-es6-import) +- [Importing the library](#importing-the-library) - [Your first request](#your-first-request) - [Troubleshooting](#troubleshooting) - [Documentation/References](#documentationreferences) ## Installation -### Node: +### Node Using [npm](http://npmjs.org): @@ -129,7 +120,7 @@ Using [yarn](https://yarnpkg.com/lang/en/): yarn add contentful-management ``` -### Browser: +### Browser For browsers, we recommend to download the library via npm or yarn to ensure 100% availability. @@ -154,7 +145,7 @@ Check the [releases](https://github.com/contentful/contentful-management.js/rele ## Typings -This library also comes with typings to use with typescript. +This library includes TypeScript typings out of the box. ## Authentication @@ -164,29 +155,24 @@ If you want to use this library for a simple tool or a local app that you won't If you'd like to create an app which would make use of this library but that would be available for other users, where they could authenticate with their own Contentful credentials, make sure to also check out the section about [Creating an OAuth Application](https://www.contentful.com/developers/docs/references/authentication/#creating-an-oauth-20-application) -## Using ES6 import +## Importing the library -You can use the es6 import with the library as follows +You can import the library using either modern ES6 modules or CommonJS syntax: ```js -// import createClient directly +// Using ES6 modules import contentful from 'contentful-management' -const client = contentful.createClient( - { - // This is the access token for this space. Normally you get the token in the Contentful web app - accessToken: 'YOUR_ACCESS_TOKEN', - }, - { type: 'plain' } -) -//.... + +// Using CommonJS +const contentful = require('contentful-management') ``` -## Your first request +## Using the Plain Client Beginning with `contentful-management@7` this library provides a client which exposes all CMA endpoints in a simple flat API surface, as opposed to the waterfall structure exposed by legacy versions of the SDK. ```javascript -const contentful = require('contentful-management') +import contentful from 'contentful-management' const plainClient = contentful.createClient( { accessToken: 'YOUR_ACCESS_TOKEN', @@ -207,8 +193,11 @@ const entries = await plainClient.entry.getMany({ limit: 100, }, }) +``` -// With scoped space and environment +### With scoped space and environment + +```javascript const scopedPlainClient = contentful.createClient( { accessToken: 'YOUR_ACCESS_TOKEN', @@ -231,8 +220,6 @@ const entries = await scopedPlainClient.entry.getMany({ }) ``` -You can try and change the above example on [Runkit](https://npm.runkit.com/contentful-management). - The benefits of using the "plain" version of the client, over the legacy version, are: - The ability to reach any possible CMA endpoint without the necessity to call any async functions beforehand. @@ -241,12 +228,12 @@ The benefits of using the "plain" version of the client, over the legacy version - The ability to scope CMA client instance to a specific `spaceId`, `environmentId`, and `organizationId` when initializing the client. - You can pass a concrete values to `defaults` and omit specifying these params in actual CMA methods calls. -## Legacy Client Interface +## Using the Legacy Client The following code snippet is an example of the legacy client interface, which reads and writes data as a sequence of nested requests: ```js -const contentful = require('contentful-management') +import contentful from 'contentful-management' const client = contentful.createClient({ accessToken: 'YOUR_ACCESS_TOKEN', }) @@ -281,10 +268,10 @@ grants your apps access to the supported space-environment scoped entities witho need to expose a management token, and without coding any additional backend middleware. ```javascript -const contentfulApp = require('@contentful/app-sdk') -const contentful = require('contentful-management') +import { init as initContentfulApp } from '@contentful/app-sdk' +import contentful from 'contentful-management' -contentfulApp.init((sdk) => { +initContentfulApp((sdk) => { const cma = contentful.createClient( { apiAdapter: sdk.cmaAdapter }, { @@ -316,112 +303,86 @@ contentfulApp.init((sdk) => { ## Documentation/References -To help you get the most out of this library, we've prepared reference documentation, tutorials and other examples that will help you learn and understand how to use this library. - -## Configuration - -The `createClient` method supports several options you may set to achieve the expected behavior: - -```js -contentful.createClient({ - ... your config here ... -}) -``` - -#### accessToken (required, when `apiAdapter` is not set) - -Your CMA access token. - -#### host (default: `'api.contentful.com'`) - -Set the host used to build the request URI's. - -#### hostUpload (default: `'upload.contentful.com'`) - -Set the host used to build the upload related request uri's. - -#### basePath (default: ``) - -This path gets appended to the host to allow request urls like `https://gateway.example.com/contentful/` for custom gateways/proxies. +To help you get the most out of this library, we've prepared full client configuration options, reference documentation, tutorials, and other examples to help you learn and understand how to use this library effectively. -#### httpAgent (default: `undefined`) +- [REST API reference with examples](#rest-api-reference-with-examples) +- [Configuration](#configuration) +- [Reference documentation](#reference-documentation) +- [Tutorials & other resources](#tutorials--other-resources) -Custom agent to perform HTTP requests. Find further information in the [axios request config documentation](https://github.com/mzabriskie/axios#request-config). +### REST API reference with examples -#### httpsAgent (default: `undefined`) +This library is a wrapper around the [Contentful Management REST API](https://www.contentful.com/developers/docs/references/content-management-api/). -Custom agent to perform HTTPS requests. Find further information in the [axios request config documentation](https://github.com/mzabriskie/axios#request-config). +You can use the API reference to find full, copy-paste-ready examples for both the **plain** and **legacy** clients of this library. +[For example, here’s how to create, update, publish, or fetch an entry](https://www.contentful.com/developers/docs/references/content-management-api/#/reference/entries/entry). -#### headers (default: `{}`) +It’s your go-to resource for: -Additional headers to attach to the requests. We add/overwrite the following headers: - -- Content-Type: `application/vnd.contentful.management.v1+json` -- X-Contentful-User-Agent: `sdk contentful-management.js/1.2.3; platform node.js/1.2.3; os macOS/1.2.3` - (Automatically generated) - -#### proxy (default: `undefined`) - -Axios proxy configuration. See the [axios request config documentation](https://github.com/mzabriskie/axios#request-config) for further information about the supported values. - -#### retryOnError (default: `true`) - -By default, this library is retrying requests which resulted in a 500 server error and 429 rate limit response. Set this to `false` to disable this behavior. - -#### logHandler (default: `function (level, data) {}`) - -Errors and warnings will be logged by default to the node or browser console. Pass your own log handler to intercept here and handle errors, warnings and info on your own. - -#### requestLogger (default: `function (config) {}`) - -Interceptor called on every request. Takes Axios request config as an arg. Default does nothing. Pass your own function to log any desired data. - -#### responseLogger (default: `function (response) {}`) - -Interceptor called on every response. Takes Axios response object as an arg. Default does nothing. Pass your own function to log any desired data. - -#### apiAdapter (default: `new RestAdapter(configuration)`) - -An [`Adapter`](https://github.com/contentful/contentful-management.js/blob/2350b47053459694b21b19c71025632fe57815cc/lib/common-types.ts#L493-L495) -that can be utilized to issue requests. It defaults to a [`RestAdapter`](https://github.com/contentful/contentful-management.js/blob/b50534c629a8ddc81637170a07bc63477d136cec/lib/adapters/REST/rest-adapter.ts) -initialized with provided configuration. - -> **Please Note** -> -> The Adapter will take precedence over the other options. Therefore, ensure you're providing the Adapter all the -> information it needs to issue the request (e.g., host or auth headers) - -#### throttle (default: `0`) - -Maximum number of requests per second. - -- `1`-`30` (fixed number of limit), -- `'auto'` (calculated limit based on your plan), -- `'0%'` - `'100%'` (calculated % limit based on your plan) +- Quickly grabbing example snippets for specific operations in the Contentful Management API +- Complete and detailed endpoint descriptions +- Previewing request and response payloads +- Understanding query filters and pagination ### Reference documentation -The [Contentful's JS library reference](https://contentful.github.io/contentful-management.js) documents what objects and methods are exposed by this library, what arguments they expect and what kind of data is returned. - -Most methods also have examples which show you how to use them. +The [Contentful JS SDK TypeDoc reference](https://contentful.github.io/contentful-management.js) documents all exported objects, types, functions, and instance methods. -You can start by looking at the top level `contentfulManagement` namespace. +> You can access version-specific docs at +> `https://contentful.github.io/contentful-management.js/contentful-management/` -The `ContentfulClientAPI` namespace defines the methods at the Client level which allow you to create and get spaces. +--- -The `ContentfulSpaceAPI` namespace defines the methods at the Space level which allow you to create and get entries, assets, content types and other possible entities. +### Configuration -The `Entry`, `Asset` and `ContentType` namespaces show you the instance methods you can use on each of these entities, once you retrieve them from the server. +The `createClient` method accepts several options to configure the client behavior: -> From version 1.0.0 onwards, you can access documentation for a specific version by visiting `https://contentful.github.io/contentful-management.js/contentful-management/` - -### Contentful JavaScript resources - -Read the [Contentful for JavaScript](https://www.contentful.com/developers/docs/javascript/) page for Tutorials, Demo Apps, and more information on other ways of using JavaScript with Contentful +```js +contentful.createClient({ + ...your config here... +}) +``` -### REST API reference +```js +// The plain client accepts the same configuration options +contentful.createClient( + { + ...your config here... + }, + { type: 'plain' } +) +``` -This library is a wrapper around our Contentful Management REST API. Some more specific details such as search parameters and pagination are better explained on the [REST API reference](https://www.contentful.com/developers/docs/references/content-management-api/), and you can also get a better understanding of how the requests look under the hood. +#### Request configuration options + +| Name | Default | Description | +| ---------------- | -------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `accessToken` | | **Required** (unless using `apiAdapter`). Your CMA access token. | +| `host` | `'api.contentful.com'` | The base host used for API requests. | +| `hostUpload` | `'upload.contentful.com'` | The host used for upload-related API requests. | +| `basePath` | `''` | Appended to the host. Useful for custom gateways/proxies like `https://gateway.example.com/contentful/`. | +| `httpAgent` | `undefined` | Custom HTTP agent. See [Axios request config](https://github.com/axios/axios#request-config). | +| `httpsAgent` | `undefined` | Custom HTTPS agent. See [Axios request config](https://github.com/axios/axios#request-config). | +| `headers` | `{}` | Additional headers for all requests. The SDK automatically sets:
• `Content-Type: application/vnd.contentful.management.v1+json`
• `X-Contentful-User-Agent: sdk contentful-management.js/x.y.z; platform ...; os ...` | +| `proxy` | `undefined` | Axios proxy configuration. See [Axios request config](https://github.com/axios/axios#request-config). | +| `retryOnError` | `true` | Retries requests on `500` or `429` responses. Set to `false` to disable retry behavior. | +| `throttle` | `0` | Max requests per second:
• Fixed: `1`–`30`
• `'auto'`: based on your plan
• `'0%'`–`'100%'`: percentage-based rate based on plan limit | +| `application` | `undefined` | Custom application identifier, e.g. `'myApp/version'`. Added to the `X-Contentful-User-Agent` header. | +| `integration` | `undefined` | Custom integration identifier, e.g. `'react/version'`. Added to the `X-Contentful-User-Agent` header. | +| `timeout` | `30000` | Timeout in milliseconds for requests. | +| `retryLimit` | `5` | Maximum number of retry attempts for recoverable errors. | +| `logHandler` | `function (level, data) {}` | Custom log handler for SDK logs (errors, warnings, info). Defaults to console logging. | +| `requestLogger` | `function (config) {}` | Called before each request. Receives the Axios request config. No-op by default. | +| `responseLogger` | `function (response) {}` | Called after each response. Receives the Axios response object. No-op by default. | +| `apiAdapter` | `new RestAdapter(configuration)` | Custom adapter that overrides request handling.
👉 [View adapter source](https://github.com/contentful/contentful-management.js/blob/b50534c629a8ddc81637170a07bc63477d136cec/lib/adapters/REST/rest-adapter.ts)

**Note**: Takes full control of requests. Must handle headers, host, and auth internally. | + +### Tutorials & other resources + +Check out the [Contentful for JavaScript](https://www.contentful.com/developers/docs/javascript/) page for: + +- Hands-on tutorials +- Example applications +- Integration guides for frameworks and tools ## Versioning diff --git a/SETUP.md b/SETUP.md index 16a0da6e7..e830b98c0 100644 --- a/SETUP.md +++ b/SETUP.md @@ -14,7 +14,7 @@ Readme · Setup · Migration · - Changelog · + Changelog · Contributing

diff --git a/lib/adapters/REST/make-request.ts b/lib/adapters/REST/make-request.ts index cd44cbd50..ea83c2feb 100644 --- a/lib/adapters/REST/make-request.ts +++ b/lib/adapters/REST/make-request.ts @@ -2,7 +2,7 @@ import type { AxiosInstance } from 'contentful-sdk-core' import type { MakeRequestOptions, MakeRequestPayload } from '../../common-types' import type { OpPatch } from 'json-patch' import type { RawAxiosRequestHeaders } from 'axios' -import endpoints from './endpoints' +import endpoints from './endpoints/index' type makeAxiosRequest = MakeRequestOptions & { axiosInstance: AxiosInstance diff --git a/lib/common-utils.ts b/lib/common-utils.ts index 0da3ea5f8..cec3d74d7 100644 --- a/lib/common-utils.ts +++ b/lib/common-utils.ts @@ -1,5 +1,3 @@ -/* eslint-disable @typescript-eslint/ban-ts-comment */ - import { toPlainObject } from 'contentful-sdk-core' import copy from 'fast-copy' import type { @@ -17,10 +15,11 @@ export const wrapCollection = (fn: (makeRequest: MakeRequest, entity: T, ...rest: Rest) => R) => (makeRequest: MakeRequest, data: CollectionProp, ...rest: Rest): Collection => { const collectionData = toPlainObject(copy(data)) - // @ts-expect-error - collectionData.items = collectionData.items.map((entity) => fn(makeRequest, entity, ...rest)) - // @ts-expect-error - return collectionData + + return { + ...collectionData, + items: collectionData.items.map((entity) => fn(makeRequest, entity, ...rest)), + } } export const wrapCursorPaginatedCollection = @@ -31,10 +30,10 @@ export const wrapCursorPaginatedCollection = ...rest: Rest ): CursorPaginatedCollection => { const collectionData = toPlainObject(copy(data)) - // @ts-expect-error - collectionData.items = collectionData.items.map((entity) => fn(makeRequest, entity, ...rest)) - // @ts-expect-error - return collectionData + return { + ...collectionData, + items: collectionData.items.map((entity) => fn(makeRequest, entity, ...rest)), + } } export function isSuccessful(statusCode: number) { return statusCode < 300 diff --git a/lib/contentful-management.ts b/lib/contentful-management.ts index d8863b199..d29d3bdd4 100644 --- a/lib/contentful-management.ts +++ b/lib/contentful-management.ts @@ -4,109 +4,18 @@ * @packageDocumentation */ -import { getUserAgentHeader } from 'contentful-sdk-core' -import type { RestAdapterParams } from './adapters/REST/rest-adapter' -import type { MakeRequest, XOR } from './common-types' -import type { AdapterParams } from './create-adapter' -import { createAdapter } from './create-adapter' -import type { ClientAPI } from './create-contentful-api' -import createContentfulApi from './create-contentful-api' -import type { PlainClientAPI } from './plain/common-types' -import type { DefaultParams } from './plain/plain-client' -import { createPlainClient } from './plain/plain-client' -import * as editorInterfaceDefaults from './constants/editor-interface-defaults' +export type { PlainClientDefaultParams } from './plain/plain-client' export type { ClientAPI } from './create-contentful-api' +export type { PlainClientAPI } from './plain/plain-client-types' +export type { RestAdapterParams } from './adapters/REST/rest-adapter' +export type * from './export-types' + export { asIterator } from './plain/as-iterator' export { fetchAll } from './plain/pagination-helper' export { isDraft, isPublished, isUpdated } from './plain/checks' -export type { PlainClientAPI } from './plain/common-types' -export { createClient } -export { RestAdapter } from './adapters/REST/rest-adapter' -export type { RestAdapterParams } from './adapters/REST/rest-adapter' export { makeRequest } from './adapters/REST/make-request' -export { editorInterfaceDefaults } -export type PlainClientDefaultParams = DefaultParams -export * from './export-types' - -interface UserAgentParams { - /** - * Application name and version e.g myApp/version - */ - application?: string - /** - * Integration name and version e.g react/version - */ - integration?: string - - feature?: string -} - -/** - * @deprecated - */ -export type ClientParams = RestAdapterParams & UserAgentParams - -export type ClientOptions = UserAgentParams & XOR - -/** - * Create a client instance - * @param params - Client initialization parameters - * - * ```javascript - * const client = contentfulManagement.createClient({ - * accessToken: 'myAccessToken' - * }) - * ``` - */ -function createClient(params: ClientOptions): ClientAPI -function createClient( - params: ClientOptions, - opts: { - type: 'plain' - defaults?: DefaultParams - } -): PlainClientAPI -// Usually, overloads with more specific signatures should come first but some IDEs are often not able to handle overloads with separate TSDocs correctly -/** - * @deprecated The `alphaFeatures` option is no longer supported. Please use the function without this option. - */ -function createClient( - params: ClientOptions, - opts: { - type?: 'plain' - alphaFeatures: string[] - defaults?: DefaultParams - } -): ClientAPI | PlainClientAPI -function createClient( - params: ClientOptions, - opts: { - type?: 'plain' - defaults?: DefaultParams - } = {} -): ClientAPI | PlainClientAPI { - const sdkMain = - opts.type === 'plain' ? 'contentful-management-plain.js' : 'contentful-management.js' - const userAgent = getUserAgentHeader( - // @ts-expect-error - `${sdkMain}/${__VERSION__}`, - params.application, - params.integration, - params.feature - ) - - const adapter = createAdapter({ ...params, userAgent }) - - // Parameters and ReturnType only return the types of the last overload - // https://github.com/microsoft/TypeScript/issues/26591 - // @ts-expect-error - const makeRequest: MakeRequest = (options: Parameters[0]): ReturnType => - adapter.makeRequest({ ...options, userAgent }) +export { RestAdapter } from './adapters/REST/rest-adapter' +export * as editorInterfaceDefaults from './constants/editor-interface-defaults/index' - if (opts.type === 'plain') { - return createPlainClient(makeRequest, opts.defaults) - } else { - return createContentfulApi(makeRequest) as ClientAPI - } -} +export * from './create-client' diff --git a/lib/create-app-definition-api.ts b/lib/create-app-definition-api.ts index ad8be2d98..59459e5ed 100644 --- a/lib/create-app-definition-api.ts +++ b/lib/create-app-definition-api.ts @@ -1,5 +1,6 @@ import type { MakeRequest, QueryOptions, SpaceQueryOptions } from './common-types' -import entities from './entities' +import { wrapAppBundle, wrapAppBundleCollection } from './entities/app-bundle' +import { wrapResourceProvider } from './entities/resource-provider' import type { CreateAppBundleProps } from './entities/app-bundle' import type { AppDefinitionProps } from './entities/app-definition' import { wrapAppDefinition } from './entities/app-definition' @@ -14,9 +15,6 @@ export type ContentfulAppDefinitionAPI = ReturnType ({ appDefinitionId: data.sys.id, organizationId: data.sys.organization.sys.id, diff --git a/lib/create-client.ts b/lib/create-client.ts new file mode 100644 index 000000000..c2c2e20a9 --- /dev/null +++ b/lib/create-client.ts @@ -0,0 +1,119 @@ +/** + * Navigate below to the `createClient` function to get started with using this library. + * @module + * @category Core + */ +import type { AdapterParams } from './create-adapter' +import type { ClientAPI } from './create-contentful-api' +import type { PlainClientDefaultParams } from './plain/plain-client' +import type { MakeRequest, XOR } from './common-types' +import type { PlainClientAPI } from './plain/plain-client-types' +import type { RestAdapterParams } from './adapters/REST/rest-adapter' + +import { createAdapter } from './create-adapter' +import { createPlainClient } from './plain/plain-client' +import { getUserAgentHeader } from 'contentful-sdk-core' +import { createClientApi } from './create-contentful-api' + +interface UserAgentParams { + /** + * Application name and version e.g myApp/version + */ + application?: string + /** + * Integration name and version e.g react/version + */ + integration?: string + + feature?: string +} + +export type ClientOptions = UserAgentParams & XOR + +declare global { + const __VERSION__: string +} + +/** + * Create a plain client instance + * + * @param clientOptions + * @param opts + * + * @example Plain Client + * ```javascript + * const client = contentfulManagement.createClient({ + * accessToken: 'myAccessToken', + * opts: { + * type: 'plain' + * } + * }) + * ``` + * @example Plain Client with defaults + * ```javascript + * const client = contentfulManagement.createClient({ + * accessToken: 'myAccessToken', + * opts: { + * type: 'plain', + * defaults: { + * ... + * } + * } + * }) + * ``` + */ +export function createClient( + clientOptions: ClientOptions, + opts: { + type: 'plain' + defaults?: PlainClientDefaultParams + } +): PlainClientAPI +/** + * Create a legacy, chainable client instance + * @param clientOptions + * + * @example Legacy Chainable Client + * ```javascript + * const client = contentfulManagement.createClient({ + * accessToken: 'myAccessToken' + * }) + * ``` + */ +export function createClient(clientOptions: ClientOptions): ClientAPI +/** + * Create a legacy or plain client instance + * + * Please check the corresponding section below: + * + * * [Plain Client](#createclient) + * * [Legacy Chainable Client](#createclient-1) + */ +export function createClient( + clientOptions: ClientOptions, + opts?: { + type?: string + defaults?: PlainClientDefaultParams + } +): ClientAPI | PlainClientAPI { + const sdkMain = + opts && opts.type === 'plain' ? 'contentful-management-plain.js' : 'contentful-management.js' + const userAgent = getUserAgentHeader( + `${sdkMain}/${__VERSION__}`, + clientOptions.application, + clientOptions.integration, + clientOptions.feature + ) + + const adapter = createAdapter({ ...clientOptions, userAgent }) + + // @ts-expect-error Parameters and ReturnType only return the types of the last overload (https://github.com/microsoft/TypeScript/issues/26591) + const makeRequest: MakeRequest = (options: Parameters[0]): ReturnType => + adapter.makeRequest({ ...options, userAgent }) + + if (opts && opts.type === 'plain') { + return createPlainClient(makeRequest, opts.defaults) + } else { + return createClientApi(makeRequest) as ClientAPI + } +} diff --git a/lib/create-contentful-api.ts b/lib/create-contentful-api.ts index e4b27743e..87b0c1c06 100644 --- a/lib/create-contentful-api.ts +++ b/lib/create-contentful-api.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Legacy Client + */ import { createRequestConfig } from 'contentful-sdk-core' import type { Collection, @@ -12,7 +16,27 @@ import type { GetOAuthApplicationParams, GetUserParams, } from './common-types' -import entities from './entities' +import { wrapSpace, wrapSpaceCollection } from './entities/space' +import { wrapUser } from './entities/user' +import { + wrapPersonalAccessToken, + wrapPersonalAccessTokenCollection, +} from './entities/personal-access-token' +import { wrapAccessToken, wrapAccessTokenCollection } from './entities/access-token' +import { wrapOrganization, wrapOrganizationCollection } from './entities/organization' +import { wrapUsageCollection } from './entities/usage' +import { wrapAppDefinition } from './entities/app-definition' +import { + wrapEnvironmentTemplate, + wrapEnvironmentTemplateCollection, +} from './entities/environment-template' +import type { + CreateOAuthApplicationProps, + OAuthApplication, + OAuthApplicationProps, +} from './entities/oauth-application' +import { wrapOAuthApplication, wrapOAuthApplicationCollection } from './entities/oauth-application' + import type { Organization, OrganizationProps } from './entities/organization' import type { CreatePersonalAccessTokenProps } from './entities/personal-access-token' import type { Space, SpaceProps } from './entities/space' @@ -25,11 +49,6 @@ import type { EnvironmentTemplateProps, } from './entities/environment-template' import type { RawAxiosRequestConfig } from 'axios' -import type { - CreateOAuthApplicationProps, - OAuthApplication, - OAuthApplicationProps, -} from './export-types' export type ClientAPI = ReturnType type CreateSpaceProps = Omit & { defaultLocale?: string } @@ -37,19 +56,7 @@ type CreateSpaceProps = Omit & { defaultLocale?: string } /** * @private */ -export default function createClientApi(makeRequest: MakeRequest) { - const { wrapSpace, wrapSpaceCollection } = entities.space - const { wrapUser } = entities.user - const { wrapPersonalAccessToken, wrapPersonalAccessTokenCollection } = - entities.personalAccessToken - const { wrapAccessToken, wrapAccessTokenCollection } = entities.accessToken - const { wrapOrganization, wrapOrganizationCollection } = entities.organization - const { wrapUsageCollection } = entities.usage - const { wrapAppDefinition } = entities.appDefinition - const { wrapEnvironmentTemplate, wrapEnvironmentTemplateCollection } = - entities.environmentTemplate - const { wrapOAuthApplication, wrapOAuthApplicationCollection } = entities.oauthApplication - +export function createClientApi(makeRequest: MakeRequest) { return { /** * Gets all environment templates for a given organization with the lasted version diff --git a/lib/create-entry-api.ts b/lib/create-entry-api.ts index 6118c7030..8bbc0c7bc 100644 --- a/lib/create-entry-api.ts +++ b/lib/create-entry-api.ts @@ -4,7 +4,11 @@ import type { CreateCommentParams, CreateCommentProps } from './entities/comment import type { Entry, EntryProps, EntryReferenceOptionsProps } from './entities/entry' import type { CreateTaskProps } from './entities/task' import * as checks from './plain/checks' -import entities from './entities' + +import { wrapEntry, wrapEntryCollection } from './entities/entry' +import { wrapSnapshot, wrapSnapshotCollection } from './entities/snapshot' +import { wrapTask, wrapTaskCollection } from './entities/task' +import { wrapComment, wrapCommentCollection } from './entities/comment' /** * @private @@ -15,11 +19,6 @@ export type ContentfulEntryApi = ReturnType * @private */ export default function createEntryApi(makeRequest: MakeRequest) { - const { wrapEntry, wrapEntryCollection } = entities.entry - const { wrapSnapshot, wrapSnapshotCollection } = entities.snapshot - const { wrapTask, wrapTaskCollection } = entities.task - const { wrapComment, wrapCommentCollection } = entities.comment - const getParams = (self: Entry) => { const entry = self.toPlainObject() as EntryProps diff --git a/lib/create-environment-api.ts b/lib/create-environment-api.ts index 586bfe3e2..7cc5065b6 100644 --- a/lib/create-environment-api.ts +++ b/lib/create-environment-api.ts @@ -8,7 +8,6 @@ import type { QueryOptions, } from './common-types' import type { BasicQueryOptions, MakeRequest } from './common-types' -import entities from './entities' import type { CreateAppInstallationProps } from './entities/app-installation' import type { CreateAppSignedRequestProps } from './entities/app-signed-request' import type { CreateAppActionCallProps } from './entities/app-action-call' @@ -54,6 +53,23 @@ import { wrapUserUIConfig } from './entities/user-ui-config' import { wrapEnvironmentTemplateInstallationCollection } from './entities/environment-template-installation' import { wrapFunctionCollection } from './entities/function' import { wrapFunctionLog, wrapFunctionLogCollection } from './entities/function-log' +import { wrapEnvironment } from './entities/environment' +import { wrapContentType, wrapContentTypeCollection } from './entities/content-type' +import { wrapEntry, wrapEntryCollection } from './entities/entry' +import { wrapAsset, wrapAssetCollection } from './entities/asset' +import { wrapAssetKey } from './entities/asset-key' +import { wrapLocale, wrapLocaleCollection } from './entities/locale' +import { wrapSnapshotCollection } from './entities/snapshot' +import { wrapEditorInterface, wrapEditorInterfaceCollection } from './entities/editor-interface' +import { wrapUpload } from './entities/upload' +import { wrapExtension, wrapExtensionCollection } from './entities/extension' +import { wrapAppInstallation, wrapAppInstallationCollection } from './entities/app-installation' +import { wrapAppSignedRequest } from './entities/app-signed-request' +import { wrapAppActionCall } from './entities/app-action-call' +import { wrapBulkAction } from './entities/bulk-action' +import { wrapAppAccessToken } from './entities/app-access-token' +import { wrapResourceTypesForEnvironmentCollection } from './entities/resource-type' +import { wrapResourceCollection } from './entities/resource' import type { CreateAppAccessTokenProps } from './entities/app-access-token' import type { ResourceQueryOptions } from './entities/resource' import type { AiActionInvocationType } from './entities/ai-action-invocation' @@ -71,24 +87,6 @@ export type ContentfulEnvironmentAPI = ReturnType * @private */ export default function createEnvironmentApi(makeRequest: MakeRequest) { - const { wrapEnvironment } = entities.environment - const { wrapContentType, wrapContentTypeCollection } = entities.contentType - const { wrapEntry, wrapEntryCollection } = entities.entry - const { wrapAsset, wrapAssetCollection } = entities.asset - const { wrapAssetKey } = entities.assetKey - const { wrapLocale, wrapLocaleCollection } = entities.locale - const { wrapSnapshotCollection } = entities.snapshot - const { wrapEditorInterface, wrapEditorInterfaceCollection } = entities.editorInterface - const { wrapUpload } = entities.upload - const { wrapExtension, wrapExtensionCollection } = entities.extension - const { wrapAppInstallation, wrapAppInstallationCollection } = entities.appInstallation - const { wrapAppSignedRequest } = entities.appSignedRequest - const { wrapAppActionCall } = entities.appActionCall - const { wrapBulkAction } = entities.bulkAction - const { wrapAppAccessToken } = entities.appAccessToken - const { wrapResourceTypesForEnvironmentCollection } = entities.resourceType - const { wrapResourceCollection } = entities.resource - return { /** * Deletes the environment diff --git a/lib/create-environment-template-api.ts b/lib/create-environment-template-api.ts index 4ac9eccf2..8a0636200 100644 --- a/lib/create-environment-template-api.ts +++ b/lib/create-environment-template-api.ts @@ -1,6 +1,5 @@ import { createRequestConfig } from 'contentful-sdk-core' import type { BasicCursorPaginationOptions, MakeRequest } from './common-types' -import entities from './entities' import type { EnvironmentTemplateProps } from './entities/environment-template' import type { CreateEnvironmentTemplateInstallationProps, @@ -9,12 +8,13 @@ import type { export type ContentfulEnvironmentTemplateApi = ReturnType -export function createEnvironmentTemplateApi(makeRequest: MakeRequest, organizationId: string) { - const { wrapEnvironmentTemplate, wrapEnvironmentTemplateCollection } = - entities.environmentTemplate - - const { wrapEnvironmentTemplateInstallationCollection } = entities.environmentTemplateInstallation +import { + wrapEnvironmentTemplate, + wrapEnvironmentTemplateCollection, +} from './entities/environment-template' +import { wrapEnvironmentTemplateInstallationCollection } from './entities/environment-template-installation' +export function createEnvironmentTemplateApi(makeRequest: MakeRequest, organizationId: string) { return { /** * Updates a environment template diff --git a/lib/create-organization-api.ts b/lib/create-organization-api.ts index 1c610b563..090a0c2e0 100644 --- a/lib/create-organization-api.ts +++ b/lib/create-organization-api.ts @@ -1,12 +1,10 @@ import { createRequestConfig } from 'contentful-sdk-core' -import entities from './entities' import type { Stream } from 'stream' import type { CreateTeamMembershipProps } from './entities/team-membership' import type { CreateTeamProps } from './entities/team' import type { CreateOrganizationInvitationProps } from './entities/organization-invitation' import type { AcceptsQueryOptions, - AcceptsQueryParams, BasicQueryOptions, MakeRequest, QueryOptions, @@ -20,6 +18,30 @@ import type { CreateAppKeyProps } from './entities/app-key' import type { CreateAppDetailsProps } from './entities/app-details' import type { OrganizationProps } from './entities/organization' +import { wrapAppDefinition, wrapAppDefinitionCollection } from './entities/app-definition' +import { wrapUser, wrapUserCollection } from './entities/user' +import { + wrapOrganizationMembership, + wrapOrganizationMembershipCollection, +} from './entities/organization-membership' +import { wrapTeamMembership, wrapTeamMembershipCollection } from './entities/team-membership' +import { + wrapTeamSpaceMembership, + wrapTeamSpaceMembershipCollection, +} from './entities/team-space-membership' +import { wrapTeam, wrapTeamCollection } from './entities/team' +import { wrapSpaceMembership, wrapSpaceMembershipCollection } from './entities/space-membership' +import { wrapOrganizationInvitation } from './entities/organization-invitation' +import { wrapAppUpload } from './entities/app-upload' +import { wrapAppSigningSecret } from './entities/app-signing-secret' +import { wrapAppEventSubscription } from './entities/app-event-subscription' +import { wrapAppKey, wrapAppKeyCollection } from './entities/app-key' +import { wrapAppDetails } from './entities/app-details' +import { wrapAppAction, wrapAppActionCollection } from './entities/app-action' +import { wrapFunction, wrapFunctionCollection } from './entities/function' +import { wrapRoleCollection } from './entities/role' +import { wrapSpaceCollection } from './entities/space' + /** * @private */ @@ -32,26 +54,6 @@ export type ContentfulOrganizationAPI = ReturnType * @private */ export default function createOrganizationApi(makeRequest: MakeRequest) { - const { wrapAppDefinition, wrapAppDefinitionCollection } = entities.appDefinition - const { wrapUser, wrapUserCollection } = entities.user - const { wrapOrganizationMembership, wrapOrganizationMembershipCollection } = - entities.organizationMembership - const { wrapTeamMembership, wrapTeamMembershipCollection } = entities.teamMembership - const { wrapTeamSpaceMembership, wrapTeamSpaceMembershipCollection } = - entities.teamSpaceMembership - const { wrapTeam, wrapTeamCollection } = entities.team - const { wrapSpaceMembership, wrapSpaceMembershipCollection } = entities.spaceMembership - const { wrapOrganizationInvitation } = entities.organizationInvitation - const { wrapAppUpload } = entities.appUpload - const { wrapAppSigningSecret } = entities.appSigningSecret - const { wrapAppEventSubscription } = entities.appEventSubscription - const { wrapAppKey, wrapAppKeyCollection } = entities.appKey - const { wrapAppDetails } = entities.appDetails - const { wrapAppAction, wrapAppActionCollection } = entities.appAction - const { wrapFunction, wrapFunctionCollection } = entities.func - const { wrapRoleCollection } = entities.role - const { wrapSpaceCollection } = entities.space - return { /** * Gets a collection of spaces in the organization diff --git a/lib/create-space-api.ts b/lib/create-space-api.ts index de997a677..29f3491bd 100644 --- a/lib/create-space-api.ts +++ b/lib/create-space-api.ts @@ -5,7 +5,6 @@ import { createRequestConfig } from 'contentful-sdk-core' import type { MakeRequest, PaginationQueryOptions, QueryOptions } from './common-types' -import entities from './entities' import type { CreateApiKeyProps } from './entities/api-key' import type { CreateEnvironmentProps } from './entities/environment' import type { CreateEnvironmentAliasProps } from './entities/environment-alias' @@ -21,6 +20,24 @@ import type { } from './entities/webhook' import type { AiActionProps, AiActionQueryOptions, CreateAiActionProps } from './entities/ai-action' +import { wrapSpace } from './entities/space' +import { wrapEnvironment, wrapEnvironmentCollection } from './entities/environment' +import { wrapWebhook, wrapWebhookCollection } from './entities/webhook' +import { wrapRole, wrapRoleCollection } from './entities/role' +import { wrapUser, wrapUserCollection } from './entities/user' +import { wrapSpaceMember, wrapSpaceMemberCollection } from './entities/space-member' +import { wrapSpaceMembership, wrapSpaceMembershipCollection } from './entities/space-membership' +import { + wrapTeamSpaceMembership, + wrapTeamSpaceMembershipCollection, +} from './entities/team-space-membership' +import { wrapTeamCollection } from './entities/team' +import { wrapApiKey, wrapApiKeyCollection } from './entities/api-key' +import { wrapEnvironmentAlias, wrapEnvironmentAliasCollection } from './entities/environment-alias' +import { wrapPreviewApiKey, wrapPreviewApiKeyCollection } from './entities/preview-api-key' +import { wrapScheduledAction, wrapScheduledActionCollection } from './entities/scheduled-action' +import { wrapAiAction, wrapAiActionCollection } from './entities/ai-action' + /** * @private */ @@ -33,23 +50,6 @@ export type ContentfulSpaceAPI = ReturnType * @private */ export default function createSpaceApi(makeRequest: MakeRequest) { - const { wrapSpace } = entities.space - const { wrapEnvironment, wrapEnvironmentCollection } = entities.environment - const { wrapWebhook, wrapWebhookCollection } = entities.webhook - const { wrapRole, wrapRoleCollection } = entities.role - const { wrapUser, wrapUserCollection } = entities.user - const { wrapSpaceMember, wrapSpaceMemberCollection } = entities.spaceMember - const { wrapSpaceMembership, wrapSpaceMembershipCollection } = entities.spaceMembership - const { wrapTeamSpaceMembership, wrapTeamSpaceMembershipCollection } = - entities.teamSpaceMembership - const { wrapTeamCollection } = entities.team - const { wrapApiKey, wrapApiKeyCollection } = entities.apiKey - const { wrapEnvironmentAlias, wrapEnvironmentAliasCollection } = entities.environmentAlias - const { wrapPreviewApiKey, wrapPreviewApiKeyCollection } = entities.previewApiKey - const { wrapScheduledAction, wrapScheduledActionCollection } = entities.scheduledAction - const { wrapAiAction, wrapAiActionCollection } = entities.aiAction - const { wrapAiActionInvocation, wrapAiActionInvocationCollection } = entities.aiActionInvocation - return { /** * Deletes the space diff --git a/lib/create-ui-config-api.ts b/lib/create-ui-config-api.ts index c012a8660..b762317fb 100644 --- a/lib/create-ui-config-api.ts +++ b/lib/create-ui-config-api.ts @@ -1,7 +1,8 @@ import type { MakeRequest } from './common-types' -import entities from './entities' import type { UIConfig } from './entities/ui-config' +import { wrapUIConfig } from './entities/ui-config' + /** * @private */ @@ -11,8 +12,6 @@ export type ContentfulUIConfigApi = ReturnType * @private */ export default function createUIConfigApi(makeRequest: MakeRequest) { - const { wrapUIConfig } = entities.uiConfig - const getParams = (self: UIConfig) => { const uiConfig = self.toPlainObject() diff --git a/lib/create-user-ui-config-api.ts b/lib/create-user-ui-config-api.ts index 0ae28af78..e6ee62654 100644 --- a/lib/create-user-ui-config-api.ts +++ b/lib/create-user-ui-config-api.ts @@ -1,7 +1,8 @@ import type { MakeRequest } from './common-types' -import entities from './entities' import type { UserUIConfig } from './entities/user-ui-config' +import { wrapUserUIConfig } from './entities/user-ui-config' + /** * @private */ @@ -11,8 +12,6 @@ export type ContentfulUIConfigApi = ReturnType * @private */ export default function createUserUIConfigApi(makeRequest: MakeRequest) { - const { wrapUserUIConfig } = entities.userUIConfig - const getParams = (self: UserUIConfig) => { const userUIConfig = self.toPlainObject() diff --git a/lib/entities/access-token.ts b/lib/entities/access-token.ts index 15714b2c6..b9f55d797 100644 --- a/lib/entities/access-token.ts +++ b/lib/entities/access-token.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import copy from 'fast-copy' import { freezeSys, toPlainObject } from 'contentful-sdk-core' import enhanceWithMethods from '../enhance-with-methods' diff --git a/lib/entities/api-key.ts b/lib/entities/api-key.ts index 7c7745808..9c3904c0e 100644 --- a/lib/entities/api-key.ts +++ b/lib/entities/api-key.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import { freezeSys, toPlainObject } from 'contentful-sdk-core' import copy from 'fast-copy' import type { DefaultElements, MakeRequest, MetaLinkProps, MetaSysProps } from '../common-types' diff --git a/lib/entities/app-access-token.ts b/lib/entities/app-access-token.ts index 72435c5d7..24df9c350 100644 --- a/lib/entities/app-access-token.ts +++ b/lib/entities/app-access-token.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import copy from 'fast-copy' import { freezeSys, toPlainObject } from 'contentful-sdk-core' import type { Except } from 'type-fest' diff --git a/lib/entities/app-action-call.ts b/lib/entities/app-action-call.ts index a5c2df73a..d4dae2ffa 100644 --- a/lib/entities/app-action-call.ts +++ b/lib/entities/app-action-call.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import copy from 'fast-copy' import { toPlainObject } from 'contentful-sdk-core' import type { Except } from 'type-fest' diff --git a/lib/entities/app-action.ts b/lib/entities/app-action.ts index 4606f1f73..5380992bf 100644 --- a/lib/entities/app-action.ts +++ b/lib/entities/app-action.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import { freezeSys, toPlainObject } from 'contentful-sdk-core' import copy from 'fast-copy' import type { Except } from 'type-fest' diff --git a/lib/entities/app-bundle.ts b/lib/entities/app-bundle.ts index 62e76a2a6..80046c4ea 100644 --- a/lib/entities/app-bundle.ts +++ b/lib/entities/app-bundle.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import { freezeSys, toPlainObject } from 'contentful-sdk-core' import copy from 'fast-copy' import type { Except } from 'type-fest' diff --git a/lib/entities/app-definition.ts b/lib/entities/app-definition.ts index c6933d997..24e24c2b5 100644 --- a/lib/entities/app-definition.ts +++ b/lib/entities/app-definition.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import copy from 'fast-copy' import { freezeSys, toPlainObject } from 'contentful-sdk-core' import type { diff --git a/lib/entities/app-details.ts b/lib/entities/app-details.ts index 5819b1cee..17cc2eafc 100644 --- a/lib/entities/app-details.ts +++ b/lib/entities/app-details.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import copy from 'fast-copy' import { toPlainObject } from 'contentful-sdk-core' import type { Except } from 'type-fest' diff --git a/lib/entities/app-event-subscription.ts b/lib/entities/app-event-subscription.ts index 6d5ec7b4e..cea22c9e6 100644 --- a/lib/entities/app-event-subscription.ts +++ b/lib/entities/app-event-subscription.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import copy from 'fast-copy' import { toPlainObject } from 'contentful-sdk-core' import type { Except } from 'type-fest' diff --git a/lib/entities/app-installation.ts b/lib/entities/app-installation.ts index 34ed0df82..e5548fb37 100644 --- a/lib/entities/app-installation.ts +++ b/lib/entities/app-installation.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import { toPlainObject, freezeSys } from 'contentful-sdk-core' import copy from 'fast-copy' import enhanceWithMethods from '../enhance-with-methods' diff --git a/lib/entities/app-key.ts b/lib/entities/app-key.ts index 773248c90..771d7c32c 100644 --- a/lib/entities/app-key.ts +++ b/lib/entities/app-key.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import copy from 'fast-copy' import { toPlainObject } from 'contentful-sdk-core' import type { Except } from 'type-fest' diff --git a/lib/entities/app-signed-request.ts b/lib/entities/app-signed-request.ts index 9afa925cf..70f807d1f 100644 --- a/lib/entities/app-signed-request.ts +++ b/lib/entities/app-signed-request.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import copy from 'fast-copy' import { toPlainObject } from 'contentful-sdk-core' import type { Except } from 'type-fest' diff --git a/lib/entities/app-signing-secret.ts b/lib/entities/app-signing-secret.ts index e0ab6bb2b..aa7257190 100644 --- a/lib/entities/app-signing-secret.ts +++ b/lib/entities/app-signing-secret.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import copy from 'fast-copy' import { toPlainObject } from 'contentful-sdk-core' import type { Except } from 'type-fest' diff --git a/lib/entities/app-upload.ts b/lib/entities/app-upload.ts index 9245ee376..ca2d36f97 100644 --- a/lib/entities/app-upload.ts +++ b/lib/entities/app-upload.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import { freezeSys, toPlainObject } from 'contentful-sdk-core' import copy from 'fast-copy' import type { Except } from 'type-fest' diff --git a/lib/entities/asset-key.ts b/lib/entities/asset-key.ts index 6713e5d00..bf15bcecb 100644 --- a/lib/entities/asset-key.ts +++ b/lib/entities/asset-key.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import copy from 'fast-copy' import { toPlainObject } from 'contentful-sdk-core' import type { DefaultElements, MakeRequest } from '../common-types' diff --git a/lib/entities/asset.ts b/lib/entities/asset.ts index 0f8f268b7..b3b95ded7 100644 --- a/lib/entities/asset.ts +++ b/lib/entities/asset.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import copy from 'fast-copy' import { freezeSys, toPlainObject } from 'contentful-sdk-core' import type { Stream } from 'stream' diff --git a/lib/entities/bulk-action.ts b/lib/entities/bulk-action.ts index 4c86037d5..a948a40dc 100644 --- a/lib/entities/bulk-action.ts +++ b/lib/entities/bulk-action.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ /* eslint-disable @typescript-eslint/no-explicit-any */ import { freezeSys, toPlainObject } from 'contentful-sdk-core' import copy from 'fast-copy' diff --git a/lib/entities/comment.ts b/lib/entities/comment.ts index 159d6b5ea..ea79c5f67 100644 --- a/lib/entities/comment.ts +++ b/lib/entities/comment.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import { freezeSys, toPlainObject } from 'contentful-sdk-core' import type { Node, Text } from '@contentful/rich-text-types' import copy from 'fast-copy' diff --git a/lib/entities/concept-scheme.ts b/lib/entities/concept-scheme.ts index c2a8cdea5..3a12771f1 100644 --- a/lib/entities/concept-scheme.ts +++ b/lib/entities/concept-scheme.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import type { Link } from '../common-types' import type { TaxonomyConceptLink } from './concept' import type { LocalizedEntity } from './utils' diff --git a/lib/entities/concept.ts b/lib/entities/concept.ts index 093e41da1..e540a5aa5 100644 --- a/lib/entities/concept.ts +++ b/lib/entities/concept.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import type { Link } from '../common-types' import type { LocalizedEntity } from './utils' diff --git a/lib/entities/content-type-fields.ts b/lib/entities/content-type-fields.ts index c4c05fae7..6e511cb3d 100644 --- a/lib/entities/content-type-fields.ts +++ b/lib/entities/content-type-fields.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import type { KeyValueMap } from '../common-types' import type { INLINES, BLOCKS } from '@contentful/rich-text-types' diff --git a/lib/entities/content-type.ts b/lib/entities/content-type.ts index fb5cd73a4..7b1593ebc 100644 --- a/lib/entities/content-type.ts +++ b/lib/entities/content-type.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import { freezeSys, toPlainObject } from 'contentful-sdk-core' import copy from 'fast-copy' import type { Except, RequireAtLeastOne, SetOptional } from 'type-fest' diff --git a/lib/entities/editor-interface.ts b/lib/entities/editor-interface.ts index c7d94e9bf..dfe0d3360 100644 --- a/lib/entities/editor-interface.ts +++ b/lib/entities/editor-interface.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import copy from 'fast-copy' import { freezeSys, toPlainObject } from 'contentful-sdk-core' import enhanceWithMethods from '../enhance-with-methods' diff --git a/lib/entities/entry.ts b/lib/entities/entry.ts index 6b0c77287..cc0a1fff0 100644 --- a/lib/entities/entry.ts +++ b/lib/entities/entry.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import { freezeSys, toPlainObject } from 'contentful-sdk-core' import copy from 'fast-copy' import type { diff --git a/lib/entities/environment-alias.ts b/lib/entities/environment-alias.ts index d80aae3e0..dec61202c 100644 --- a/lib/entities/environment-alias.ts +++ b/lib/entities/environment-alias.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import copy from 'fast-copy' import { freezeSys, toPlainObject } from 'contentful-sdk-core' import enhanceWithMethods from '../enhance-with-methods' diff --git a/lib/entities/environment-template-installation.ts b/lib/entities/environment-template-installation.ts index 8d2969716..bb60caea0 100644 --- a/lib/entities/environment-template-installation.ts +++ b/lib/entities/environment-template-installation.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import { freezeSys, toPlainObject } from 'contentful-sdk-core' import copy from 'fast-copy' import type { diff --git a/lib/entities/environment-template.ts b/lib/entities/environment-template.ts index c203159f3..4fb8f839b 100644 --- a/lib/entities/environment-template.ts +++ b/lib/entities/environment-template.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import { freezeSys, toPlainObject } from 'contentful-sdk-core' import copy from 'fast-copy' import type { BasicMetaSysProps, Link, MakeRequest, DefaultElements } from '../common-types' diff --git a/lib/entities/environment.ts b/lib/entities/environment.ts index 96d89aec6..c3af2d84e 100644 --- a/lib/entities/environment.ts +++ b/lib/entities/environment.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import copy from 'fast-copy' import { freezeSys, toPlainObject } from 'contentful-sdk-core' import enhanceWithMethods from '../enhance-with-methods' diff --git a/lib/entities/extension.ts b/lib/entities/extension.ts index 7a92a5c0c..82c34c6da 100644 --- a/lib/entities/extension.ts +++ b/lib/entities/extension.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import copy from 'fast-copy' import { freezeSys, toPlainObject } from 'contentful-sdk-core' import enhanceWithMethods from '../enhance-with-methods' diff --git a/lib/entities/field-type.ts b/lib/entities/field-type.ts index 341bfa3d4..f06f60505 100644 --- a/lib/entities/field-type.ts +++ b/lib/entities/field-type.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ export type FieldType = | { type: 'Symbol' } | { type: 'Text' } diff --git a/lib/entities/function-log.ts b/lib/entities/function-log.ts index 6f8a0b632..5f8d3f083 100644 --- a/lib/entities/function-log.ts +++ b/lib/entities/function-log.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import type { Link, DefaultElements } from '../common-types' import { freezeSys, toPlainObject } from 'contentful-sdk-core' import copy from 'fast-copy' diff --git a/lib/entities/function.ts b/lib/entities/function.ts index 2e8cc02a4..d171eaf4a 100644 --- a/lib/entities/function.ts +++ b/lib/entities/function.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import type { Link, DefaultElements } from '../common-types' import { freezeSys, toPlainObject } from 'contentful-sdk-core' import copy from 'fast-copy' diff --git a/lib/entities/index.ts b/lib/entities/index.ts deleted file mode 100644 index d63243839..000000000 --- a/lib/entities/index.ts +++ /dev/null @@ -1,127 +0,0 @@ -import * as aiAction from './ai-action' -import * as aiActionInvocation from './ai-action-invocation' -import * as apiKey from './api-key' -import * as appAction from './app-action' -import * as appActionCall from './app-action-call' -import * as appBundle from './app-bundle' -import * as appDefinition from './app-definition' -import * as appDetails from './app-details' -import * as appInstallation from './app-installation' -import * as appSignedRequest from './app-signed-request' -import * as appSigningSecret from './app-signing-secret' -import * as appEventSubscription from './app-event-subscription' -import * as appKey from './app-key' -import * as appAccessToken from './app-access-token' -import * as appUpload from './app-upload' -import * as asset from './asset' -import * as assetKey from './asset-key' -import * as bulkAction from './bulk-action' -import * as comment from './comment' -import * as contentType from './content-type' -import * as editorInterface from './editor-interface' -import * as entry from './entry' -import * as environment from './environment' -import * as environmentAlias from './environment-alias' -import * as environmentTemplate from './environment-template' -import * as environmentTemplateInstallation from './environment-template-installation' -import * as extension from './extension' -import * as func from './function' -import * as functionLog from './function-log' -import * as locale from './locale' -import * as oauthApplication from './oauth-application' -import * as organization from './organization' -import * as organizationInvitation from './organization-invitation' -import * as organizationMembership from './organization-membership' -import * as personalAccessToken from './personal-access-token' -import * as accessToken from './access-token' -import * as previewApiKey from './preview-api-key' -import * as release from './release' -import * as releaseAction from './release-action' -import * as role from './role' -import * as scheduledAction from './scheduled-action' -import * as snapshot from './snapshot' -import * as space from './space' -import * as spaceMember from './space-member' -import * as spaceMembership from './space-membership' -import * as tag from './tag' -import * as task from './task' -import * as team from './team' -import * as teamMembership from './team-membership' -import * as teamSpaceMembership from './team-space-membership' -import * as uiConfig from './ui-config' -import * as upload from './upload' -import * as usage from './usage' -import * as user from './user' -import * as userUIConfig from './user-ui-config' -import * as webhook from './webhook' -import * as workflowDefinition from './workflow-definition' -import * as concept from './concept' -import * as conceptScheme from './concept-scheme' -import * as resourceProvider from './resource-provider' -import * as resourceType from './resource-type' -import * as resource from './resource' - -export default { - aiAction, - aiActionInvocation, - accessToken, - appAction, - appActionCall, - appBundle, - apiKey, - appDefinition, - appInstallation, - appUpload, - appDetails, - appSignedRequest, - appSigningSecret, - appEventSubscription, - appKey, - appAccessToken, - asset, - assetKey, - bulkAction, - comment, - concept, - conceptScheme, - contentType, - editorInterface, - entry, - environment, - environmentAlias, - environmentTemplate, - environmentTemplateInstallation, - extension, - func, - functionLog, - locale, - oauthApplication, - organization, - organizationInvitation, - organizationMembership, - personalAccessToken, - previewApiKey, - release, - releaseAction, - resourceProvider, - resourceType, - resource, - role, - scheduledAction, - snapshot, - space, - spaceMember, - spaceMembership, - tag, - task, - team, - teamMembership, - teamSpaceMembership, - uiConfig, - upload, - usage, - user, - userUIConfig, - webhook, - workflowDefinition, -} diff --git a/lib/entities/locale.ts b/lib/entities/locale.ts index 5aa4b630b..15f6bab77 100644 --- a/lib/entities/locale.ts +++ b/lib/entities/locale.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import copy from 'fast-copy' import { freezeSys, toPlainObject } from 'contentful-sdk-core' import type { Except, SetOptional } from 'type-fest' diff --git a/lib/entities/oauth-application.ts b/lib/entities/oauth-application.ts index b46b5d30d..f022d027e 100644 --- a/lib/entities/oauth-application.ts +++ b/lib/entities/oauth-application.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import { freezeSys, toPlainObject } from 'contentful-sdk-core' import type { BasicMetaSysProps, DefaultElements, MakeRequest } from '../common-types' import enhanceWithMethods from '../enhance-with-methods' diff --git a/lib/entities/organization-invitation.ts b/lib/entities/organization-invitation.ts index ff1b60489..5da0ded0d 100644 --- a/lib/entities/organization-invitation.ts +++ b/lib/entities/organization-invitation.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import { freezeSys, toPlainObject } from 'contentful-sdk-core' import copy from 'fast-copy' import type { DefaultElements, MakeRequest, MetaLinkProps, MetaSysProps } from '../common-types' diff --git a/lib/entities/organization-membership.ts b/lib/entities/organization-membership.ts index 4f8c97422..9ba4c898d 100644 --- a/lib/entities/organization-membership.ts +++ b/lib/entities/organization-membership.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import copy from 'fast-copy' import { freezeSys, toPlainObject } from 'contentful-sdk-core' import enhanceWithMethods from '../enhance-with-methods' diff --git a/lib/entities/organization.ts b/lib/entities/organization.ts index 2d0558740..8d595ba4b 100644 --- a/lib/entities/organization.ts +++ b/lib/entities/organization.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import copy from 'fast-copy' import { freezeSys, toPlainObject } from 'contentful-sdk-core' import enhanceWithMethods from '../enhance-with-methods' diff --git a/lib/entities/personal-access-token.ts b/lib/entities/personal-access-token.ts index 5d6105a5c..57b5334c1 100644 --- a/lib/entities/personal-access-token.ts +++ b/lib/entities/personal-access-token.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import copy from 'fast-copy' import { freezeSys, toPlainObject } from 'contentful-sdk-core' import enhanceWithMethods from '../enhance-with-methods' diff --git a/lib/entities/preview-api-key.ts b/lib/entities/preview-api-key.ts index c49f63c5c..cd1dc4ec3 100644 --- a/lib/entities/preview-api-key.ts +++ b/lib/entities/preview-api-key.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import { freezeSys, toPlainObject } from 'contentful-sdk-core' import copy from 'fast-copy' import type { DefaultElements, MakeRequest, MetaSysProps } from '../common-types' diff --git a/lib/entities/release-action.ts b/lib/entities/release-action.ts index 440e2a538..975e63da6 100644 --- a/lib/entities/release-action.ts +++ b/lib/entities/release-action.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ /* eslint-disable @typescript-eslint/no-explicit-any */ import { freezeSys, toPlainObject } from 'contentful-sdk-core' import copy from 'fast-copy' diff --git a/lib/entities/release.ts b/lib/entities/release.ts index 3791a3ecb..48f01b905 100644 --- a/lib/entities/release.ts +++ b/lib/entities/release.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ /* eslint-disable @typescript-eslint/no-explicit-any */ import { freezeSys, toPlainObject } from 'contentful-sdk-core' import copy from 'fast-copy' diff --git a/lib/entities/resource-provider.ts b/lib/entities/resource-provider.ts index 4614c7933..4c84ef419 100644 --- a/lib/entities/resource-provider.ts +++ b/lib/entities/resource-provider.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import type { BasicMetaSysProps, CollectionProp, @@ -9,7 +13,8 @@ import { toPlainObject, freezeSys } from 'contentful-sdk-core' import copy from 'fast-copy' import enhanceWithMethods from '../enhance-with-methods' import type { ResourceType, UpsertResourceTypeProps } from './resource-type' -import entities from '.' + +import { wrapResourceType } from './resource-type' export type ResourceProviderProps = { /** @@ -47,8 +52,6 @@ export interface ResourceProvider * @private */ function createResourceProviderApi(makeRequest: MakeRequest) { - const { wrapResourceType } = entities.resourceType - return { /** * Sends an update to the server with any changes made to the object's properties diff --git a/lib/entities/resource-type.ts b/lib/entities/resource-type.ts index 3aa576e85..38dbd21bd 100644 --- a/lib/entities/resource-type.ts +++ b/lib/entities/resource-type.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import type { BasicMetaSysProps, CursorPaginatedCollectionProp, diff --git a/lib/entities/resource.ts b/lib/entities/resource.ts index eb95ed1ed..bca412a47 100644 --- a/lib/entities/resource.ts +++ b/lib/entities/resource.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import type { BasicCursorPaginationOptions, CursorPaginatedCollectionProp, diff --git a/lib/entities/role.ts b/lib/entities/role.ts index fa5dbc897..6e5f5b282 100644 --- a/lib/entities/role.ts +++ b/lib/entities/role.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import copy from 'fast-copy' import { freezeSys, toPlainObject } from 'contentful-sdk-core' import enhanceWithMethods from '../enhance-with-methods' diff --git a/lib/entities/scheduled-action.ts b/lib/entities/scheduled-action.ts index 0273c4a8c..b27e9487d 100644 --- a/lib/entities/scheduled-action.ts +++ b/lib/entities/scheduled-action.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import { freezeSys, toPlainObject } from 'contentful-sdk-core' import copy from 'fast-copy' import type { diff --git a/lib/entities/snapshot.ts b/lib/entities/snapshot.ts index 119f4bbc7..071d997c4 100644 --- a/lib/entities/snapshot.ts +++ b/lib/entities/snapshot.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import copy from 'fast-copy' import { freezeSys, toPlainObject } from 'contentful-sdk-core' import enhanceWithMethods from '../enhance-with-methods' diff --git a/lib/entities/space-member.ts b/lib/entities/space-member.ts index 24ac0ccc1..df541abfa 100644 --- a/lib/entities/space-member.ts +++ b/lib/entities/space-member.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import { freezeSys, toPlainObject } from 'contentful-sdk-core' import copy from 'fast-copy' import type { DefaultElements, MakeRequest, MetaLinkProps, MetaSysProps } from '../common-types' diff --git a/lib/entities/space-membership.ts b/lib/entities/space-membership.ts index 6d1dc8ae6..4bf0c9f4d 100644 --- a/lib/entities/space-membership.ts +++ b/lib/entities/space-membership.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import copy from 'fast-copy' import { freezeSys, toPlainObject } from 'contentful-sdk-core' import enhanceWithMethods from '../enhance-with-methods' diff --git a/lib/entities/space.ts b/lib/entities/space.ts index b926ecf9e..ef4bf37c1 100644 --- a/lib/entities/space.ts +++ b/lib/entities/space.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import { freezeSys, toPlainObject } from 'contentful-sdk-core' import copy from 'fast-copy' import type { BasicMetaSysProps, DefaultElements, MakeRequest } from '../common-types' diff --git a/lib/entities/tag.ts b/lib/entities/tag.ts index 98bc4c88d..819cd049f 100644 --- a/lib/entities/tag.ts +++ b/lib/entities/tag.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import { freezeSys, toPlainObject } from 'contentful-sdk-core' import copy from 'fast-copy' import type { diff --git a/lib/entities/task.ts b/lib/entities/task.ts index 30ab37f35..ad37cd7ee 100644 --- a/lib/entities/task.ts +++ b/lib/entities/task.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import { freezeSys, toPlainObject } from 'contentful-sdk-core' import copy from 'fast-copy' import type { diff --git a/lib/entities/team-membership.ts b/lib/entities/team-membership.ts index ffd84d19a..f7f4d6639 100644 --- a/lib/entities/team-membership.ts +++ b/lib/entities/team-membership.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import copy from 'fast-copy' import { freezeSys, toPlainObject } from 'contentful-sdk-core' import enhanceWithMethods from '../enhance-with-methods' diff --git a/lib/entities/team-space-membership.ts b/lib/entities/team-space-membership.ts index c61578a16..b1fe9035d 100644 --- a/lib/entities/team-space-membership.ts +++ b/lib/entities/team-space-membership.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import copy from 'fast-copy' import { freezeSys, toPlainObject } from 'contentful-sdk-core' import enhanceWithMethods from '../enhance-with-methods' diff --git a/lib/entities/team.ts b/lib/entities/team.ts index 8fc87e805..57383003d 100644 --- a/lib/entities/team.ts +++ b/lib/entities/team.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import copy from 'fast-copy' import { freezeSys, toPlainObject } from 'contentful-sdk-core' import enhanceWithMethods from '../enhance-with-methods' diff --git a/lib/entities/ui-config.ts b/lib/entities/ui-config.ts index f7110b6db..39c980b32 100644 --- a/lib/entities/ui-config.ts +++ b/lib/entities/ui-config.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import { freezeSys, toPlainObject } from 'contentful-sdk-core' import copy from 'fast-copy' import type { BasicMetaSysProps, DefaultElements, MakeRequest, SysLink } from '../common-types' diff --git a/lib/entities/upload-credential.ts b/lib/entities/upload-credential.ts index 8c11ccfa4..6201c6cee 100644 --- a/lib/entities/upload-credential.ts +++ b/lib/entities/upload-credential.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import { freezeSys, toPlainObject } from 'contentful-sdk-core' import copy from 'fast-copy' import type { DefaultElements, MakeRequest, MetaSysProps, SysLink } from '../common-types' diff --git a/lib/entities/upload.ts b/lib/entities/upload.ts index 33015d828..e0ca33977 100644 --- a/lib/entities/upload.ts +++ b/lib/entities/upload.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import copy from 'fast-copy' import { freezeSys, toPlainObject } from 'contentful-sdk-core' import enhanceWithMethods from '../enhance-with-methods' diff --git a/lib/entities/usage.ts b/lib/entities/usage.ts index fd0f7088e..ff6436f09 100644 --- a/lib/entities/usage.ts +++ b/lib/entities/usage.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import { freezeSys, toPlainObject } from 'contentful-sdk-core' import copy from 'fast-copy' import type { diff --git a/lib/entities/user-ui-config.ts b/lib/entities/user-ui-config.ts index 1d2f72f13..324d7fc39 100644 --- a/lib/entities/user-ui-config.ts +++ b/lib/entities/user-ui-config.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import { freezeSys, toPlainObject } from 'contentful-sdk-core' import copy from 'fast-copy' import type { BasicMetaSysProps, DefaultElements, MakeRequest, SysLink } from '../common-types' diff --git a/lib/entities/user.ts b/lib/entities/user.ts index de88211e9..ce710cb5c 100644 --- a/lib/entities/user.ts +++ b/lib/entities/user.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import { freezeSys, toPlainObject } from 'contentful-sdk-core' import copy from 'fast-copy' import enhanceWithMethods from '../enhance-with-methods' diff --git a/lib/entities/utils.ts b/lib/entities/utils.ts index d1cd11d95..4d7fd6618 100644 --- a/lib/entities/utils.ts +++ b/lib/entities/utils.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ export type LocalizedEntity< Entity, LocalizedFields extends keyof Entity, diff --git a/lib/entities/webhook.ts b/lib/entities/webhook.ts index 3a9433d08..014869f32 100644 --- a/lib/entities/webhook.ts +++ b/lib/entities/webhook.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import { freezeSys, toPlainObject } from 'contentful-sdk-core' import copy from 'fast-copy' import type { Except, JsonValue, SetOptional } from 'type-fest' diff --git a/lib/entities/widget-parameters.ts b/lib/entities/widget-parameters.ts index 1913b57d3..ac9262680 100644 --- a/lib/entities/widget-parameters.ts +++ b/lib/entities/widget-parameters.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ export type ParameterType = 'Boolean' | 'Symbol' | 'Number' | 'Enum' export type InstallationParameterType = ParameterType | 'Secret' export type ParameterOption = string | { [key: string]: string } diff --git a/lib/entities/workflow-definition.ts b/lib/entities/workflow-definition.ts index 49d5a04c5..935a33fe8 100644 --- a/lib/entities/workflow-definition.ts +++ b/lib/entities/workflow-definition.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import { freezeSys, toPlainObject } from 'contentful-sdk-core' import copy from 'fast-copy' import type { diff --git a/lib/entities/workflow.ts b/lib/entities/workflow.ts index 186b8fe06..901a25280 100644 --- a/lib/entities/workflow.ts +++ b/lib/entities/workflow.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import { freezeSys, toPlainObject } from 'contentful-sdk-core' import copy from 'fast-copy' import type { diff --git a/lib/entities/workflows-changelog-entry.ts b/lib/entities/workflows-changelog-entry.ts index d524a9d41..71db75394 100644 --- a/lib/entities/workflows-changelog-entry.ts +++ b/lib/entities/workflows-changelog-entry.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Entities + */ import { freezeSys, toPlainObject } from 'contentful-sdk-core' import copy from 'fast-copy' import type { diff --git a/lib/export-types.ts b/lib/export-types.ts index f88cca269..bbeef3dbb 100644 --- a/lib/export-types.ts +++ b/lib/export-types.ts @@ -260,7 +260,7 @@ export type { WorkflowStepProps, WorkflowStepTaskAction, } from './entities/workflow-definition' -export * from './plain/common-types' +export * from './plain/plain-client-types' export { WorkflowStepPermissionAction, diff --git a/lib/methods/bulk-action.ts b/lib/methods/bulk-action.ts index 0ea7056d4..18d7830e9 100644 --- a/lib/methods/bulk-action.ts +++ b/lib/methods/bulk-action.ts @@ -1,5 +1,5 @@ import type { BulkActionPayload, BulkActionProps } from '../entities/bulk-action' -import type { PlainClientAPI } from '../plain/common-types' +import type { PlainClientAPI } from '../plain/plain-client-types' import type { AsyncActionProcessingOptions } from './action' import { pollAsyncActionStatus } from './action' diff --git a/lib/methods/release-action.ts b/lib/methods/release-action.ts index fc53b0361..df1928e6f 100644 --- a/lib/methods/release-action.ts +++ b/lib/methods/release-action.ts @@ -1,5 +1,5 @@ import type { ReleaseActionProps, ReleaseActionTypes } from '../entities/release-action' -import type { PlainClientAPI } from '../plain/common-types' +import type { PlainClientAPI } from '../plain/plain-client-types' import type { AsyncActionProcessingOptions } from './action' import { pollAsyncActionStatus } from './action' diff --git a/lib/plain/as-iterator.ts b/lib/plain/as-iterator.ts index f2583d2d9..4db6087e3 100644 --- a/lib/plain/as-iterator.ts +++ b/lib/plain/as-iterator.ts @@ -1,3 +1,7 @@ +/** + * @module + * @category Plain Client + */ import copy from 'fast-copy' import type { CollectionProp, QueryParams } from '../common-types' diff --git a/lib/plain/checks.ts b/lib/plain/checks.ts index 161157861..7245f1af8 100644 --- a/lib/plain/checks.ts +++ b/lib/plain/checks.ts @@ -1,13 +1,29 @@ +/** + * @module + * @category Plain Client + */ import type { MetaSysProps } from '../common-types' +/** + * Returns true when an entity is published + */ export const isPublished = (data: { sys: MetaSysProps }) => !!data.sys.publishedVersion +/** + * Returns true when an entity has unpublished changes + */ export const isUpdated = (data: { sys: MetaSysProps }) => { // The act of publishing an entity increases its version by 1, so any entry which has // 2 versions higher or more than the publishedVersion has unpublished changes. return !!(data.sys.publishedVersion && data.sys.version > data.sys.publishedVersion + 1) } +/** + * Returns true when an entity has no published version + */ export const isDraft = (data: { sys: MetaSysProps }) => !data.sys.publishedVersion +/** + * Returns true when an entity is archived (and unpublished) + */ export const isArchived = (data: { sys: MetaSysProps }) => !!data.sys.archivedVersion diff --git a/lib/plain/entities/resource-type.ts b/lib/plain/entities/resource-type.ts index 912ed0aab..0f52244f1 100644 --- a/lib/plain/entities/resource-type.ts +++ b/lib/plain/entities/resource-type.ts @@ -8,8 +8,11 @@ import type { GetResourceTypeParams, GetSpaceEnvironmentParams, } from '../../common-types' -import type { ResourceTypeProps, UpsertResourceTypeProps } from '../../export-types' -import type { SpaceEnvResourceTypeProps } from '../../entities/resource-type' +import type { + SpaceEnvResourceTypeProps, + ResourceTypeProps, + UpsertResourceTypeProps, +} from '../../entities/resource-type' export type ResourceTypePlainClientAPI = { /* diff --git a/lib/plain/entities/tag.ts b/lib/plain/entities/tag.ts index e74336699..da6640c58 100644 --- a/lib/plain/entities/tag.ts +++ b/lib/plain/entities/tag.ts @@ -5,8 +5,7 @@ import type { QueryParams, CollectionProp, } from '../../common-types' -import type { UpdateTagProps, DeleteTagParams } from '../../entities/tag' -import type { TagProps, CreateTagProps } from '../../export-types' +import type { TagProps, CreateTagProps, UpdateTagProps, DeleteTagParams } from '../../entities/tag' import type { OptionalDefaults } from '../wrappers/wrap' export type TagPlainClientAPI = { diff --git a/lib/plain/entities/team-membership.ts b/lib/plain/entities/team-membership.ts index d7f5bba71..ae9e8a3d9 100644 --- a/lib/plain/entities/team-membership.ts +++ b/lib/plain/entities/team-membership.ts @@ -6,7 +6,7 @@ import type { CollectionProp, GetTeamParams, } from '../../common-types' -import type { TeamMembershipProps, CreateTeamMembershipProps } from '../../export-types' +import type { TeamMembershipProps, CreateTeamMembershipProps } from '../../entities/team-membership' import type { OptionalDefaults } from '../wrappers/wrap' export type TeamMembershipPlainClientAPI = { diff --git a/lib/plain/entities/team-space-membership.ts b/lib/plain/entities/team-space-membership.ts index c6f89c32d..39a729cbc 100644 --- a/lib/plain/entities/team-space-membership.ts +++ b/lib/plain/entities/team-space-membership.ts @@ -6,7 +6,10 @@ import type { CollectionProp, GetOrganizationParams, } from '../../common-types' -import type { TeamSpaceMembershipProps, CreateTeamSpaceMembershipProps } from '../../export-types' +import type { + TeamSpaceMembershipProps, + CreateTeamSpaceMembershipProps, +} from '../../entities/team-space-membership' import type { OptionalDefaults } from '../wrappers/wrap' export type TeamSpaceMembershipPlainClientAPI = { diff --git a/lib/plain/entities/team.ts b/lib/plain/entities/team.ts index 5115095b8..8401c54e7 100644 --- a/lib/plain/entities/team.ts +++ b/lib/plain/entities/team.ts @@ -6,7 +6,7 @@ import type { CollectionProp, GetSpaceParams, } from '../../common-types' -import type { TeamProps, CreateTeamProps } from '../../export-types' +import type { TeamProps, CreateTeamProps } from '../../entities/team' import type { OptionalDefaults } from '../wrappers/wrap' export type TeamPlainClientAPI = { diff --git a/lib/plain/entities/usage.ts b/lib/plain/entities/usage.ts index 647d24b88..0baba1454 100644 --- a/lib/plain/entities/usage.ts +++ b/lib/plain/entities/usage.ts @@ -1,5 +1,5 @@ import type { CollectionProp, QueryParams } from '../../common-types' -import type { UsageProps } from '../../export-types' +import type { UsageProps } from '../../entities/usage' import type { OptionalDefaults } from '../wrappers/wrap' export type UsagePlainClientAPI = { diff --git a/lib/plain/entities/user.ts b/lib/plain/entities/user.ts index 6a2792131..adcae098f 100644 --- a/lib/plain/entities/user.ts +++ b/lib/plain/entities/user.ts @@ -4,7 +4,7 @@ import type { GetSpaceParams, QueryParams, } from '../../common-types' -import type { UserProps } from '../../export-types' +import type { UserProps } from '../../entities/user' import type { OptionalDefaults } from '../wrappers/wrap' export type UserPlainClientAPI = { diff --git a/lib/plain/common-types.ts b/lib/plain/plain-client-types.ts similarity index 99% rename from lib/plain/common-types.ts rename to lib/plain/plain-client-types.ts index 05680cb4c..bfdee12b3 100644 --- a/lib/plain/common-types.ts +++ b/lib/plain/plain-client-types.ts @@ -1,3 +1,8 @@ +/** + * @module + * @category Plain Client + */ + import type { RawAxiosRequestConfig, RawAxiosRequestHeaders } from 'axios' import type { OpPatch } from 'json-patch' import type { @@ -115,7 +120,7 @@ import type { WebhookPlainClientAPI } from './entities/webhook' import type { WorkflowPlainClientAPI } from './entities/workflow' import type { WorkflowDefinitionPlainClientAPI } from './entities/workflow-definition' import type { WorkflowsChangelogPlainClientAPI } from './entities/workflows-changelog' -import type { DefaultParams, OptionalDefaults } from './wrappers/wrap' +import type { PlainClientDefaultParams, OptionalDefaults } from './wrappers/wrap' import type { OAuthApplicationPlainClientAPI } from './entities/oauth-application' import type { FunctionLogPlainClientAPI } from './entities/function-log' import type { AiActionPlainClientAPI } from './entities/ai-action' @@ -123,7 +128,7 @@ import type { AiActionInvocationPlainClientAPI } from './entities/ai-action-invo export type PlainClientAPI = { raw: { - getDefaultParams(): DefaultParams | undefined + getDefaultParams(): PlainClientDefaultParams | undefined get(url: string, config?: RawAxiosRequestConfig): Promise post(url: string, payload?: any, config?: RawAxiosRequestConfig): Promise patch(url: string, payload?: any, config?: RawAxiosRequestConfig): Promise diff --git a/lib/plain/plain-client.ts b/lib/plain/plain-client.ts index 7f510acf4..41ae12ff0 100644 --- a/lib/plain/plain-client.ts +++ b/lib/plain/plain-client.ts @@ -1,17 +1,22 @@ +/** + * @module + * @category Plain Client + */ + import type { GetContentTypeParams, GetSpaceEnvironmentParams, MakeRequest } from '../common-types' import { omitAndDeleteField } from '../methods/content-type' -import type { PlainClientAPI } from './common-types' -import type { DefaultParams } from './wrappers/wrap' +import type { PlainClientAPI } from './plain-client-types' +import type { PlainClientDefaultParams } from './wrappers/wrap' import { wrap } from './wrappers/wrap' -export type { DefaultParams } from './wrappers/wrap' +export type { PlainClientDefaultParams } from './wrappers/wrap' /** * @private */ export const createPlainClient = ( makeRequest: MakeRequest, - defaults: DefaultParams | undefined + defaults: PlainClientDefaultParams | undefined ): PlainClientAPI => { const wrapParams = { makeRequest, defaults } diff --git a/lib/plain/wrappers/wrap.ts b/lib/plain/wrappers/wrap.ts index d979b38cb..97057fef6 100644 --- a/lib/plain/wrappers/wrap.ts +++ b/lib/plain/wrappers/wrap.ts @@ -1,6 +1,6 @@ import type { MakeRequest, MRActions, MRReturn } from '../../common-types' -export type DefaultParams = { +export type PlainClientDefaultParams = { spaceId?: string environmentId?: string organizationId?: string @@ -13,15 +13,15 @@ type UnionOmit = T extends unknown ? Omit : neve /** * @private */ -export type OptionalDefaults = UnionOmit & - Partial>> +export type OptionalDefaults = UnionOmit & + Partial>> /** * @private */ export type WrapParams = { makeRequest: MakeRequest - defaults?: DefaultParams + defaults?: PlainClientDefaultParams } /** @@ -66,21 +66,15 @@ export const wrap = => - // @ts-expect-error + // @ts-expect-error see above makeRequest({ - // @ts-expect-error entityType, - // @ts-expect-error action, - // @ts-expect-error params: { ...defaults, ...params }, payload, // Required after adding optional headers to a delete method for the first time - // @ts-expect-error headers, - }) + } as unknown) } diff --git a/package-lock.json b/package-lock.json index 0cac9d156..5ea35c18b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,10 +13,7 @@ "axios": "^1.8.4", "contentful-sdk-core": "^9.0.1", "fast-copy": "^3.0.0", - "globals": "^15.15.0", - "typedoc-github-theme": "^0.2.1", - "typedoc-plugin-markdown": "^4.4.2", - "typedoc-plugin-missing-exports": "^3.1.0" + "globals": "^15.15.0" }, "devDependencies": { "@babel/cli": "^7.24.6", @@ -60,6 +57,8 @@ "size-limit": "^11.1.6", "type-fest": "^4.18.3", "typedoc": "^0.27.9", + "typedoc-github-theme": "^0.2.1", + "typedoc-plugin-missing-exports": "^3.1.0", "typescript": "^5.6.3", "typescript-eslint": "^8.16.0", "vitest": "^2.1.5", @@ -2669,6 +2668,7 @@ "version": "1.27.2", "resolved": "https://registry.npmjs.org/@gerrit0/mini-shiki/-/mini-shiki-1.27.2.tgz", "integrity": "sha512-GeWyHz8ao2gBiUW4OJnQDxXQnFgZQwwQk05t/CVVgNBN7/rK8XZ7xY6YhLVv9tH3VppWWmr9DCl3MwemB/i+Og==", + "dev": true, "license": "MIT", "dependencies": { "@shikijs/engine-oniguruma": "^1.27.2", @@ -3943,6 +3943,7 @@ "version": "1.29.2", "resolved": "https://registry.npmjs.org/@shikijs/engine-oniguruma/-/engine-oniguruma-1.29.2.tgz", "integrity": "sha512-7iiOx3SG8+g1MnlzZVDYiaeHe7Ez2Kf2HrJzdmGwkRisT7r4rak0e655AcM/tF9JG/kg5fMNYlLLKglbN7gBqA==", + "dev": true, "license": "MIT", "dependencies": { "@shikijs/types": "1.29.2", @@ -3953,6 +3954,7 @@ "version": "1.29.2", "resolved": "https://registry.npmjs.org/@shikijs/types/-/types-1.29.2.tgz", "integrity": "sha512-VJjK0eIijTZf0QSTODEXCqinjBn0joAHQ+aPSBzrv4O2d/QSbsMw+ZeSRx03kV34Hy7NzUvV/7NqfYGRLrASmw==", + "dev": true, "license": "MIT", "dependencies": { "@shikijs/vscode-textmate": "^10.0.1", @@ -3963,6 +3965,7 @@ "version": "10.0.2", "resolved": "https://registry.npmjs.org/@shikijs/vscode-textmate/-/vscode-textmate-10.0.2.tgz", "integrity": "sha512-83yeghZ2xxin3Nj8z1NMd/NCuca+gsYXswywDy5bHvwlWL8tpTQmzGeUuHd9FC3E/SBEMvzJRwWEOz5gGes9Qg==", + "dev": true, "license": "MIT" }, "node_modules/@sindresorhus/is": { @@ -4096,6 +4099,7 @@ "version": "3.0.4", "resolved": "https://registry.npmjs.org/@types/hast/-/hast-3.0.4.tgz", "integrity": "sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ==", + "dev": true, "license": "MIT", "dependencies": { "@types/unist": "*" @@ -4157,6 +4161,7 @@ "version": "3.0.3", "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz", "integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==", + "dev": true, "license": "MIT" }, "node_modules/@typescript-eslint/eslint-plugin": { @@ -4985,6 +4990,7 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true, "license": "Python-2.0" }, "node_modules/argv-formatter": { @@ -5338,6 +5344,7 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true, "license": "MIT" }, "node_modules/base64-js": { @@ -6956,6 +6963,7 @@ "version": "4.5.0", "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", + "dev": true, "license": "BSD-2-Clause", "engines": { "node": ">=0.12" @@ -10040,6 +10048,7 @@ "version": "5.0.0", "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-5.0.0.tgz", "integrity": "sha512-5aHCbzQRADcdP+ATqnDuhhJ/MRIqDkZX5pyjFHRRysS8vZ5AbqGEoFIb6pYHPZ+L/OC2Lc+xT8uHVVR5CAK/wQ==", + "dev": true, "license": "MIT", "dependencies": { "uc.micro": "^2.0.0" @@ -10674,6 +10683,7 @@ "version": "2.3.9", "resolved": "https://registry.npmjs.org/lunr/-/lunr-2.3.9.tgz", "integrity": "sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow==", + "dev": true, "license": "MIT" }, "node_modules/lz-string": { @@ -10736,6 +10746,7 @@ "version": "14.1.0", "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-14.1.0.tgz", "integrity": "sha512-a54IwgWPaeBCAAsv13YgmALOF1elABB08FxO9i+r4VFk5Vl4pKokRPeX8u5TCgSsPi6ec1otfLjdOpVcgbpshg==", + "dev": true, "license": "MIT", "dependencies": { "argparse": "^2.0.1", @@ -10822,6 +10833,7 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-2.0.0.tgz", "integrity": "sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w==", + "dev": true, "license": "MIT" }, "node_modules/media-typer": { @@ -15003,6 +15015,7 @@ "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode.js/-/punycode.js-2.3.1.tgz", "integrity": "sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA==", + "dev": true, "license": "MIT", "engines": { "node": ">=6" @@ -17587,6 +17600,7 @@ "version": "0.27.9", "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.27.9.tgz", "integrity": "sha512-/z585740YHURLl9DN2jCWe6OW7zKYm6VoQ93H0sxZ1cwHQEQrUn5BJrEnkWhfzUdyO+BLGjnKUZ9iz9hKloFDw==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@gerrit0/mini-shiki": "^1.24.0", @@ -17609,6 +17623,7 @@ "version": "0.2.1", "resolved": "https://registry.npmjs.org/typedoc-github-theme/-/typedoc-github-theme-0.2.1.tgz", "integrity": "sha512-pOgsS9CVAOO3JxQ1V0ocDkrPCULpoWg1OzRmn/mOlyG+vEYwUAp5DAoKrGECdNIomycxcisc8ovcMX0nHDgWTA==", + "dev": true, "license": "MIT", "engines": { "node": ">=18.0.0" @@ -17617,22 +17632,11 @@ "typedoc": "^0.27.6" } }, - "node_modules/typedoc-plugin-markdown": { - "version": "4.4.2", - "resolved": "https://registry.npmjs.org/typedoc-plugin-markdown/-/typedoc-plugin-markdown-4.4.2.tgz", - "integrity": "sha512-kJVkU2Wd+AXQpyL6DlYXXRrfNrHrEIUgiABWH8Z+2Lz5Sq6an4dQ/hfvP75bbokjNDUskOdFlEEm/0fSVyC7eg==", - "license": "MIT", - "engines": { - "node": ">= 18" - }, - "peerDependencies": { - "typedoc": "0.27.x" - } - }, "node_modules/typedoc-plugin-missing-exports": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/typedoc-plugin-missing-exports/-/typedoc-plugin-missing-exports-3.1.0.tgz", "integrity": "sha512-Sogbaj+qDa21NjB3SlIw4JXSwmcl/WOjwiPNaVEcPhpNG/MiRTtpwV81cT7h1cbu9StpONFPbddYWR0KV/fTWA==", + "dev": true, "license": "MIT", "peerDependencies": { "typedoc": "0.26.x || 0.27.x" @@ -17642,6 +17646,7 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, "license": "MIT", "dependencies": { "balanced-match": "^1.0.0" @@ -17651,6 +17656,7 @@ "version": "9.0.5", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, "license": "ISC", "dependencies": { "brace-expansion": "^2.0.1" @@ -17666,6 +17672,7 @@ "version": "5.6.3", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.3.tgz", "integrity": "sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw==", + "dev": true, "license": "Apache-2.0", "bin": { "tsc": "bin/tsc", @@ -17702,6 +17709,7 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-2.1.0.tgz", "integrity": "sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==", + "dev": true, "license": "MIT" }, "node_modules/uglify-js": { @@ -18668,6 +18676,7 @@ "version": "2.7.0", "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.7.0.tgz", "integrity": "sha512-+hSoy/QHluxmC9kCIJyL/uyFmLmc+e5CFR5Wa+bpIhIj85LVb9ZH2nVnqrHoSvKogwODv0ClqZkmiSSaIH5LTA==", + "dev": true, "license": "ISC", "bin": { "yaml": "bin.mjs" diff --git a/package.json b/package.json index e45709036..3be841acb 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,8 @@ "axios": "^1.8.4", "contentful-sdk-core": "^9.0.1", "fast-copy": "^3.0.0", - "globals": "^15.15.0" + "globals": "^15.15.0", + "type-fest": "^4.18.3" }, "devDependencies": { "@babel/cli": "^7.24.6", @@ -111,8 +112,7 @@ "rimraf": "^5.0.0", "semantic-release": "^22.0.12", "size-limit": "^11.1.6", - "type-fest": "^4.18.3", - "typedoc": "^0.28.1", + "typedoc": "^0.27.9", "typedoc-github-theme": "^0.2.1", "typedoc-plugin-missing-exports": "^3.1.0", "typescript": "^5.6.3", diff --git a/typedoc.json b/typedoc.json index 200dd2105..a867b397e 100644 --- a/typedoc.json +++ b/typedoc.json @@ -1,23 +1,91 @@ { "name": "contentful-management.js", "entryPoints": [ - "lib/contentful-management.ts", - // "lib/plain/plain-client.ts", + "lib/create-contentful-api.ts", + "lib/create-client.ts", + "lib/plain/plain-client.ts", + "lib/plain/plain-client-types.ts", + "lib/plain/checks.ts", // "lib/plain/wrappers/wrap.ts", // "lib/contentful-management.ts", // "lib/create-adapter.ts", - // "lib/create-contentful-api.ts", // "lib/entities/app-action.ts", - // "lib/entities/environment-template-installation.ts" + // "lib/entities/environment-template-installation.ts", + "lib/contentful-management.ts", + "lib/entities/access-token.ts", + "lib/entities/api-key.ts", + "lib/entities/app-access-token.ts", + "lib/entities/app-action-call.ts", + "lib/entities/app-action.ts", + "lib/entities/app-bundle.ts", + "lib/entities/app-definition.ts", + "lib/entities/app-details.ts", + "lib/entities/app-event-subscription.ts", + "lib/entities/app-installation.ts", + "lib/entities/app-key.ts", + "lib/entities/app-signed-request.ts", + "lib/entities/app-signing-secret.ts", + "lib/entities/app-upload.ts", + "lib/entities/asset-key.ts", + "lib/entities/asset.ts", + "lib/entities/bulk-action.ts", + "lib/entities/comment.ts", + "lib/entities/concept-scheme.ts", + "lib/entities/concept.ts", + "lib/entities/content-type-fields.ts", + "lib/entities/content-type.ts", + "lib/entities/editor-interface.ts", + "lib/entities/entry.ts", + "lib/entities/environment-alias.ts", + "lib/entities/environment-template-installation.ts", + "lib/entities/environment-template.ts", + "lib/entities/environment.ts", + "lib/entities/extension.ts", + "lib/entities/field-type.ts", + "lib/entities/function-log.ts", + "lib/entities/function.ts", + "lib/entities/locale.ts", + "lib/entities/oauth-application.ts", + "lib/entities/organization-invitation.ts", + "lib/entities/organization-membership.ts", + "lib/entities/organization.ts", + "lib/entities/personal-access-token.ts", + "lib/entities/preview-api-key.ts", + "lib/entities/release-action.ts", + "lib/entities/release.ts", + "lib/entities/resource-provider.ts", + "lib/entities/resource-type.ts", + "lib/entities/resource.ts", + "lib/entities/role.ts", + "lib/entities/scheduled-action.ts", + "lib/entities/snapshot.ts", + "lib/entities/space-member.ts", + "lib/entities/space-membership.ts", + "lib/entities/space.ts", + "lib/entities/tag.ts", + "lib/entities/task.ts", + "lib/entities/team-membership.ts", + "lib/entities/team-space-membership.ts", + "lib/entities/team.ts", + "lib/entities/ui-config.ts", + "lib/entities/upload-credential.ts", + "lib/entities/upload.ts", + "lib/entities/usage.ts", + "lib/entities/user-ui-config.ts", + "lib/entities/user.ts", + "lib/entities/utils.ts", + "lib/entities/webhook.ts", + "lib/entities/widget-parameters.ts", + "lib/entities/workflow-definition.ts", + "lib/entities/workflow.ts", + "lib/entities/workflows-changelog-entry.ts" ], "out": "out", "includeVersion": true, - // "categorizeByGroup": true, - // "categoryOrder": ["Core", "Clients", "Entities", "Utilities", "*"], - "categoryOrder": ["createClient", "ClientParams", "ContentType", "Entry", "*"], - // "groupOrder": ["Variables", "Functions", "*"], + "categorizeByGroup": false, + "categoryOrder": ["Core", "Plain Client", "Legacy Client", "Entities", "*"], + "defaultCategory": "Other", "kindSortOrder": [ - "Reference", "Project", "Module", "Namespace", @@ -30,6 +98,7 @@ "Interface", "TypeAlias", "Variable", + "Reference", "Accessor", "Method", "Parameter", @@ -41,6 +110,7 @@ "GetSignature", "SetSignature" ], + "groupOrder": ["Functions", "Interfaces", "Modules", "*"], "sortEntryPoints": false, "readme": "README.md", "excludePrivate": false, @@ -48,9 +118,12 @@ "excludeProtected": false, "treatWarningsAsErrors": false, "sort": ["source-order"], - "plugin": [ - "typedoc-plugin-missing-exports", - "typedoc-github-theme" - ], + "plugin": ["typedoc-plugin-missing-exports", "typedoc-github-theme"], "hideGenerator": true, -} \ No newline at end of file + "includeHierarchySummary": true, + "navigation": { + "includeGroups": false, + "includeCategories": true, + "includeFolders": false + } +}