= {}) => {
export const defaultClient = initClient({ ...params })
/**
- * @returns {import('../lib/contentful-management').PlainClientAPI}
+ * @returns {import('../lib/index').PlainClientAPI}
*/
export const initPlainClient = (defaults = {}) => {
return createClient(
diff --git a/test/integration/app-access-token-integration.test.ts b/test/integration/app-access-token-integration.test.ts
index 981b70930e..a6499ba67c 100644
--- a/test/integration/app-access-token-integration.test.ts
+++ b/test/integration/app-access-token-integration.test.ts
@@ -14,7 +14,7 @@ import type {
Environment,
PlainClientAPI,
AppKeyProps,
-} from '../../lib/contentful-management'
+} from '../../lib/index'
describe('AppAccessToken api', { sequential: true }, () => {
let organization: Organization
diff --git a/test/integration/app-action-call-structured-integration.test.ts b/test/integration/app-action-call-structured-integration.test.ts
index 3aef7d5b77..394998c140 100644
--- a/test/integration/app-action-call-structured-integration.test.ts
+++ b/test/integration/app-action-call-structured-integration.test.ts
@@ -1,9 +1,5 @@
import { expect, describe, test, beforeAll, afterAll } from 'vitest'
-import type {
- PlainClientAPI,
- AppActionCallProps,
- AppActionProps,
-} from '../../lib/contentful-management'
+import type { PlainClientAPI, AppActionCallProps, AppActionProps } from '../../lib/index'
import {
initPlainClient,
getTestOrganization,
diff --git a/test/integration/app-action-integration.test.ts b/test/integration/app-action-integration.test.ts
index b18591001f..68734d7e2a 100644
--- a/test/integration/app-action-integration.test.ts
+++ b/test/integration/app-action-integration.test.ts
@@ -1,5 +1,5 @@
import { expect, describe, test, beforeAll, afterAll } from 'vitest'
-import type { AppActionProps, PlainClientAPI } from '../../lib/contentful-management'
+import type { AppActionProps, PlainClientAPI } from '../../lib/index'
import {
initPlainClient,
getTestOrganization,
diff --git a/test/integration/app-bundle-integration.test.ts b/test/integration/app-bundle-integration.test.ts
index 492e3abd82..8418ead7d1 100644
--- a/test/integration/app-bundle-integration.test.ts
+++ b/test/integration/app-bundle-integration.test.ts
@@ -1,13 +1,7 @@
import { expect, describe, test, beforeAll, afterAll } from 'vitest'
import { readFileSync } from 'fs'
import { getTestOrganization, getDefaultSpace, timeoutToCalmRateLimiting } from '../helpers'
-import type {
- Organization,
- AppDefinition,
- AppUpload,
- Space,
- Environment,
-} from '../../lib/contentful-management'
+import type { Organization, AppDefinition, AppUpload, Space, Environment } from '../../lib/index'
describe('AppBundle api', { sequential: true }, () => {
let organization: Organization
diff --git a/test/integration/app-definition-integration.test.ts b/test/integration/app-definition-integration.test.ts
index c71042da31..c575c7d6ae 100644
--- a/test/integration/app-definition-integration.test.ts
+++ b/test/integration/app-definition-integration.test.ts
@@ -7,12 +7,7 @@ import {
getDefaultSpace,
timeoutToCalmRateLimiting,
} from '../helpers'
-import type {
- Organization,
- Space,
- Environment,
- AppInstallation,
-} from '../../lib/contentful-management'
+import type { Organization, Space, Environment, AppInstallation } from '../../lib/index'
describe('AppDefinition api', { sequential: true }, () => {
let organization: Organization
diff --git a/test/integration/app-details-integration.test.ts b/test/integration/app-details-integration.test.ts
index 445607385b..968bbe4a57 100644
--- a/test/integration/app-details-integration.test.ts
+++ b/test/integration/app-details-integration.test.ts
@@ -1,11 +1,6 @@
import { expect, describe, test, beforeAll, afterAll } from 'vitest'
import { initPlainClient, getTestOrganization, timeoutToCalmRateLimiting } from '../helpers'
-import type {
- AppIcon,
- PlainClientAPI,
- Organization,
- AppDefinition,
-} from '../../lib/contentful-management'
+import type { AppIcon, PlainClientAPI, Organization, AppDefinition } from '../../lib/index'
describe('AppDetails api', { sequential: true }, () => {
let appDefinition: AppDefinition
diff --git a/test/integration/app-event-subscription-integration.test.ts b/test/integration/app-event-subscription-integration.test.ts
index af18401b84..537c04cc0a 100644
--- a/test/integration/app-event-subscription-integration.test.ts
+++ b/test/integration/app-event-subscription-integration.test.ts
@@ -1,6 +1,6 @@
import { expect, describe, test, beforeAll, afterAll } from 'vitest'
import { initPlainClient, getTestOrganization, timeoutToCalmRateLimiting } from '../helpers'
-import type { PlainClientAPI, Organization, AppDefinition } from '../../lib/contentful-management'
+import type { PlainClientAPI, Organization, AppDefinition } from '../../lib/index'
describe('AppEventSubscription api', { sequential: true }, () => {
let appDefinition: AppDefinition
diff --git a/test/integration/app-key-integration.test.ts b/test/integration/app-key-integration.test.ts
index b604d64e72..2539403af6 100644
--- a/test/integration/app-key-integration.test.ts
+++ b/test/integration/app-key-integration.test.ts
@@ -1,6 +1,6 @@
import { expect, describe, test, beforeAll, afterAll } from 'vitest'
import { initPlainClient, getTestOrganization, timeoutToCalmRateLimiting } from '../helpers'
-import type { PlainClientAPI, Organization, AppDefinition } from '../../lib/contentful-management'
+import type { PlainClientAPI, Organization, AppDefinition } from '../../lib/index'
describe('AppKey api', { sequential: true }, () => {
let appDefinition: AppDefinition
diff --git a/test/integration/app-signed-request-integration.test.ts b/test/integration/app-signed-request-integration.test.ts
index b604d64e72..2539403af6 100644
--- a/test/integration/app-signed-request-integration.test.ts
+++ b/test/integration/app-signed-request-integration.test.ts
@@ -1,6 +1,6 @@
import { expect, describe, test, beforeAll, afterAll } from 'vitest'
import { initPlainClient, getTestOrganization, timeoutToCalmRateLimiting } from '../helpers'
-import type { PlainClientAPI, Organization, AppDefinition } from '../../lib/contentful-management'
+import type { PlainClientAPI, Organization, AppDefinition } from '../../lib/index'
describe('AppKey api', { sequential: true }, () => {
let appDefinition: AppDefinition
diff --git a/test/integration/app-signing-secret-integration.test.ts b/test/integration/app-signing-secret-integration.test.ts
index e7d9158b69..8cdfc01d5c 100644
--- a/test/integration/app-signing-secret-integration.test.ts
+++ b/test/integration/app-signing-secret-integration.test.ts
@@ -1,6 +1,6 @@
import { expect, describe, test, beforeAll, afterAll } from 'vitest'
import { initPlainClient, getTestOrganization, timeoutToCalmRateLimiting } from '../helpers'
-import type { PlainClientAPI, Organization, AppDefinition } from '../../lib/contentful-management'
+import type { PlainClientAPI, Organization, AppDefinition } from '../../lib/index'
describe('AppSigningSecret api', { sequential: true }, () => {
let appDefinition: AppDefinition
diff --git a/test/integration/app-upload-integration.test.ts b/test/integration/app-upload-integration.test.ts
index ef27430c1b..7462bfaf86 100644
--- a/test/integration/app-upload-integration.test.ts
+++ b/test/integration/app-upload-integration.test.ts
@@ -1,7 +1,7 @@
import { expect, describe, test, beforeAll, afterAll } from 'vitest'
import { readFileSync } from 'fs'
import { getTestOrganization, timeoutToCalmRateLimiting } from '../helpers'
-import type { Organization } from '../../lib/contentful-management'
+import type { Organization } from '../../lib/index'
describe('AppUpload api', { sequential: true }, () => {
let organization: Organization
diff --git a/test/integration/bulk-action-integration.test.ts b/test/integration/bulk-action-integration.test.ts
index 76fafa76fe..ad980f9ac5 100644
--- a/test/integration/bulk-action-integration.test.ts
+++ b/test/integration/bulk-action-integration.test.ts
@@ -6,8 +6,8 @@ import type {
BulkActionUnpublishPayload,
BulkActionValidatePayload,
UnpublishBulkActionV2Payload,
-} from '../../lib/contentful-management'
-import type { Environment, Space } from '../../lib/contentful-management'
+} from '../../lib/index'
+import type { Environment, Space } from '../../lib/index'
import { TestDefaults } from '../defaults'
import {
getDefaultSpace,
diff --git a/test/integration/entry-references-integration.test.ts b/test/integration/entry-references-integration.test.ts
index c36883692d..9f7bb6609c 100644
--- a/test/integration/entry-references-integration.test.ts
+++ b/test/integration/entry-references-integration.test.ts
@@ -1,5 +1,5 @@
import { expect, describe, it, beforeAll, afterAll } from 'vitest'
-import type { PlainClientAPI } from '../../lib/contentful-management'
+import type { PlainClientAPI } from '../../lib/index'
import type { Environment } from '../../lib/entities/environment'
import type { Space } from '../../lib/entities/space'
import { TestDefaults } from '../defaults'
diff --git a/test/output-integration/browser/package.json b/test/output-integration/browser/package.json
index ffd2958e56..6f0528b49a 100644
--- a/test/output-integration/browser/package.json
+++ b/test/output-integration/browser/package.json
@@ -8,7 +8,7 @@
"test": "vitest --run",
"dev": "npx serve public",
"preinstall": "npm run preinstall:bundle && npm run preinstall:env",
- "preinstall:bundle": "cp ../../../dist/contentful-management.browser.min.js ./public/.",
+ "preinstall:bundle": "cp ../../../dist/browser/index.min.js ./public/contentful.min.js",
"preinstall:env": "node scripts/inject-env.js"
},
"author": "",
diff --git a/test/output-integration/browser/public/index.html b/test/output-integration/browser/public/index.html
index ecc69745d8..4c7cdf35fe 100644
--- a/test/output-integration/browser/public/index.html
+++ b/test/output-integration/browser/public/index.html
@@ -8,7 +8,7 @@
-
+
This text should be replaced by the response
This text should be replaced by the client version
diff --git a/test/output-integration/browser/public/index.js b/test/output-integration/browser/public/index.js
index af6702db6d..d438ac8470 100644
--- a/test/output-integration/browser/public/index.js
+++ b/test/output-integration/browser/public/index.js
@@ -1,9 +1,9 @@
async function run() {
- if (!createClient) {
+ if (!contentfulManagement) {
throw 'contentful-management.js could not be loaded. Please check the build output.'
}
- const client = createClient({
+ const client = contentfulManagement.createClient({
accessToken: process.env.CONTENTFUL_INTEGRATION_TEST_CMA_TOKEN,
})
diff --git a/test/unit/contentful-management.test.ts b/test/unit/contentful-management.test.ts
index 15e8d3b486..bd7fe707c4 100644
--- a/test/unit/contentful-management.test.ts
+++ b/test/unit/contentful-management.test.ts
@@ -1,6 +1,6 @@
import type { MockedFunction } from 'vitest'
import { describe, it, afterEach, expect, vi, beforeAll } from 'vitest'
-import { createClient } from '../../lib/contentful-management'
+import { createClient } from '../../lib/index'
import { version } from '../../package.json'
import { createAdapter } from '../../lib/create-adapter'
diff --git a/test/unit/plain/resource-provider.test.ts b/test/unit/plain/resource-provider.test.ts
index 9d4663fbed..b3afe3d7df 100644
--- a/test/unit/plain/resource-provider.test.ts
+++ b/test/unit/plain/resource-provider.test.ts
@@ -1,5 +1,5 @@
import { describe, test, expect } from 'vitest'
-import { createClient } from '../../../lib/contentful-management'
+import { createClient } from '../../../lib/index'
import setupRestAdapter from '../adapters/REST/helpers/setupRestAdapter'
import { resourceProviderMock } from '../mocks/entities'
diff --git a/test/unit/plain/resource-type.test.ts b/test/unit/plain/resource-type.test.ts
index 6f977125d8..3ac7a05a52 100644
--- a/test/unit/plain/resource-type.test.ts
+++ b/test/unit/plain/resource-type.test.ts
@@ -1,5 +1,5 @@
import { describe, test, expect } from 'vitest'
-import { createClient } from '../../../lib/contentful-management'
+import { createClient } from '../../../lib/index'
import setupRestAdapter from '../adapters/REST/helpers/setupRestAdapter'
import { resourceTypeMock } from '../mocks/entities'
diff --git a/test/unit/plain/resource.test.ts b/test/unit/plain/resource.test.ts
index 9881ef419c..3d257067c4 100644
--- a/test/unit/plain/resource.test.ts
+++ b/test/unit/plain/resource.test.ts
@@ -1,5 +1,5 @@
import { describe, test, expect } from 'vitest'
-import { createClient } from '../../../lib/contentful-management'
+import { createClient } from '../../../lib/index'
import setupRestAdapter from '../adapters/REST/helpers/setupRestAdapter'
import { resourceMock } from '../mocks/entities'
diff --git a/test/unit/plain/webhook.test.ts b/test/unit/plain/webhook.test.ts
index 5cf2b9ad32..44c668b153 100644
--- a/test/unit/plain/webhook.test.ts
+++ b/test/unit/plain/webhook.test.ts
@@ -1,5 +1,5 @@
import { describe, test, expect } from 'vitest'
-import { createClient } from '../../../lib/contentful-management'
+import { createClient } from '../../../lib/index'
import setupRestAdapter from '../adapters/REST/helpers/setupRestAdapter'
describe('Webhook', () => {
diff --git a/tsconfig.json b/tsconfig.json
index e21df64f4c..65b287f3a5 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -1,26 +1,17 @@
{
"compilerOptions": {
- "target": "esnext",
- "moduleResolution": "node",
- "allowJs": true,
- "noEmit": true,
- "outDir": "./dist/typings",
+ "rootDir": "./lib",
+ "lib": ["dom", "esnext"],
+ "target": "ES2021",
+ "module": "esnext",
+ "moduleResolution": "bundler",
"strict": true,
- "isolatedModules": true,
+ "importHelpers": true,
"esModuleInterop": true,
- "noImplicitThis": false,
- "typeRoots": ["node_modules/@types"],
- "skipLibCheck": true
+ "skipLibCheck": true,
+ "noEmit": true,
+ "sourceMap": true,
+ "noImplicitThis": false
},
- "include": ["lib", "global-types"],
- "typedocOptions": {
- "out": "./out",
- "entryPoints": ["./lib/contentful-management.ts"],
- "readme": "README.md",
- "name": "contentful-management.js",
- "exclude": ["./lib/adapters/REST/endpoints/*"],
- "includeVersion": true,
- "hideGenerator": true,
- "excludePrivate": true
- }
+ "include": ["lib"]
}
diff --git a/types.d.ts b/types.d.ts
deleted file mode 100644
index 9fa8a59d8c..0000000000
--- a/types.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from './dist/typings/export-types'
diff --git a/webpack.config.js b/webpack.config.js
deleted file mode 100644
index 2c12c3ba7e..0000000000
--- a/webpack.config.js
+++ /dev/null
@@ -1,108 +0,0 @@
-/* eslint-disable @typescript-eslint/no-require-imports */
-const path = require('path')
-const webpack = require('webpack')
-const clone = require('lodash/cloneDeep')
-const LodashModuleReplacementPlugin = require('lodash-webpack-plugin')
-
-const PROD = process.env.NODE_ENV === 'production'
-
-const presets = (targets) => [['@babel/preset-env', { targets }], '@babel/typescript']
-
-const plugins = [
- new webpack.EnvironmentPlugin({
- NODE_ENV: 'development',
- }),
- new LodashModuleReplacementPlugin({
- caching: true,
- cloning: true,
- }),
-]
-
-if (PROD) {
- plugins.push(
- new webpack.LoaderOptionsPlugin({
- minimize: true,
- debug: false,
- }),
- new webpack.optimize.ModuleConcatenationPlugin(),
- new (class {
- apply(compiler) {
- compiler.hooks.emit.tap('RemoveLicenseFilePlugin', (compilation) => {
- for (let name in compilation.assets) {
- if (name.endsWith('LICENSE.txt')) {
- delete compilation.assets[name]
- }
- }
- })
- }
- })(),
- )
-}
-
-const baseFileName = `contentful-management`
-
-const baseBundleConfig = {
- mode: PROD ? 'production' : 'development',
- context: path.join(__dirname, 'lib'),
- entry: ['./contentful-management.ts'],
- output: {
- path: path.join(__dirname, 'dist'),
- libraryTarget: 'umd',
- },
- module: {
- rules: [],
- },
- resolve: {
- extensions: ['.js', '.ts'],
- fallback: {
- os: false,
- },
- },
- devtool: PROD ? false : 'source-map',
- plugins,
- // Show minimal information, but all errors and warnings
- // Except for log generation which have to contain all information
- stats: process.env.WEBPACK_MODE === 'log' ? 'verbose' : 'normal',
-}
-
-const defaultBabelLoader = {
- test: /\.(ts|js)x?$/,
- include: [path.resolve(__dirname, 'lib'), path.resolve(__dirname, 'test')],
- loader: 'babel-loader',
- options: {
- presets: [],
- },
-}
-
-// Browsers
-const browserBundle = clone(baseBundleConfig)
-browserBundle.module.rules = [
- Object.assign({}, defaultBabelLoader, {
- options: Object.assign({}, defaultBabelLoader.options, {
- presets: presets({
- browsers: ['last 2 versions', 'not ie < 13', 'not android < 50'],
- }),
- envName: 'browser',
- }),
- }),
-]
-browserBundle.output.filename = `${baseFileName}.browser${PROD ? '.min' : ''}.js`
-
-// Node
-const nodeBundle = clone(baseBundleConfig)
-nodeBundle.module.rules = [
- Object.assign({}, defaultBabelLoader, {
- options: Object.assign({}, defaultBabelLoader.options, {
- envName: 'node',
- presets: presets({
- node: '14',
- }),
- }),
- }),
-]
-nodeBundle.target = 'node'
-nodeBundle.output.libraryTarget = 'commonjs2'
-nodeBundle.output.filename = `${baseFileName}.node${PROD ? '.min' : ''}.js`
-delete nodeBundle.node
-
-module.exports = [browserBundle, nodeBundle]