Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: contentful/contentful-management.js
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 28483c2cb8c36f874837a7de15724c9ab7d6315f
Choose a base ref
...
head repository: contentful/contentful-management.js
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 90c5f85068fe1085809d8708e9db0b2bf5bd117b
Choose a head ref
  • 20 commits
  • 24 files changed
  • 12 contributors

Commits on Jul 9, 2020

  1. feat(getTags): send query params object (#402)

    BREAKING CHANGE: The `getTags` method on the environment API now accepts a queryParams object instead of separate skip and limit parameters.
    phoebeschmidt authored Jul 9, 2020

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    8d0662e View commit details

Commits on Jul 16, 2020

  1. fix: optional asset description (#407)

    Creating assets is possible without providing a description.
    johanneswuerbach authored Jul 16, 2020
    Copy the full SHA
    aacb4d7 View commit details
  2. Copy the full SHA
    14e7eb1 View commit details

Commits on Jul 21, 2020

  1. Copy the full SHA
    3d12a46 View commit details

Commits on Aug 4, 2020

  1. fix: incorrect types for environment aliases (#414)

    Alexander Suevalov authored Aug 4, 2020
    Copy the full SHA
    0c2b807 View commit details
  2. Copy the full SHA
    9416c78 View commit details

Commits on Aug 7, 2020

  1. Feat/scheduled actions (#413)

    * Add support for scheduled actions
    Co-authored-by: Bruce Felt <bruce.felt@contentful.com>
    ronaldronson authored Aug 7, 2020
    Copy the full SHA
    a743fbd View commit details

Commits on Aug 10, 2020

  1. chore(deps-dev): bump typedoc from 0.17.8 to 0.18.0 (#420)

    Bumps [typedoc](https://github.com/TypeStrong/TypeDoc) from 0.17.8 to 0.18.0.
    - [Release notes](https://github.com/TypeStrong/TypeDoc/releases)
    - [Commits](TypeStrong/typedoc@0.17.8...v0.18.0)
    
    Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
    
    Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
    dependabot-preview[bot] authored Aug 10, 2020
    Copy the full SHA
    6a60d2e View commit details
  2. chore(deps): bump type-fest from 0.15.1 to 0.16.0 (#380)

    Bumps [type-fest](https://github.com/sindresorhus/type-fest) from 0.15.1 to 0.16.0.
    - [Release notes](https://github.com/sindresorhus/type-fest/releases)
    - [Commits](sindresorhus/type-fest@v0.15.1...v0.16.0)
    
    Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
    
    Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
    Co-authored-by: Alexander Suevalov <alex.suevalov@contentful.com>
    dependabot-preview[bot] and Alexander Suevalov authored Aug 10, 2020
    Copy the full SHA
    e037bc5 View commit details

Commits on Aug 18, 2020

  1. fix(tests): content-tags (#427)

    We accidentally only ran tests for tags. This PR removes the only, and ensures unique names for all tags created during tests to avoid name collision.
    marcolink authored Aug 18, 2020
    Copy the full SHA
    26ad7db View commit details
  2. Copy the full SHA
    caff6cb View commit details
  3. Copy the full SHA
    e809fb2 View commit details

Commits on Aug 24, 2020

  1. chore(lock-file): add (#425)

    Add package-lock.json
    marcolink authored Aug 24, 2020
    Copy the full SHA
    8483058 View commit details

Commits on Sep 10, 2020

  1. Copy the full SHA
    2fbb35e View commit details

Commits on Nov 5, 2020

  1. Copy the full SHA
    4f29cd7 View commit details

Commits on Nov 6, 2020

  1. Add support for query params for getRoles method (#530)

    * feat(roles): add tests
    
    feat(roles): adjust tests
    
    * feat(roles): add query options for getRoles
    ruderngespra authored Nov 6, 2020
    Copy the full SHA
    2ced68d View commit details
  2. Copy the full SHA
    3ca4e41 View commit details

Commits on Nov 11, 2020

  1. Copy the full SHA
    3362149 View commit details

Commits on Nov 12, 2020

  1. chore(deps): bump axios from 0.19.2 to 0.21.0 (#514)

    Bumps [axios](https://github.com/axios/axios) from 0.19.2 to 0.21.0.
    - [Release notes](https://github.com/axios/axios/releases)
    - [Changelog](https://github.com/axios/axios/blob/master/CHANGELOG.md)
    - [Commits](axios/axios@v0.19.2...v0.21.0)
    
    Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
    
    Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
    dependabot-preview[bot] authored Nov 12, 2020
    Copy the full SHA
    b2be22d View commit details

Commits on Nov 17, 2020

  1. fix: correct fallbackCode type for Locale (#553)

    Alexander Suevalov authored Nov 17, 2020
    Copy the full SHA
    90c5f85 View commit details
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -152,7 +152,6 @@ $RECYCLE.BIN/

# End of https://www.gitignore.io/api/node,windows,osx,linux,vim
yarn.lock
package-lock.json

# Editors
.vscode
28 changes: 25 additions & 3 deletions lib/common-types.ts
Original file line number Diff line number Diff line change
@@ -4,6 +4,20 @@ export interface DefaultElements<TPlainObject extends object = object> {
toPlainObject(): TPlainObject
}

/**
* Link is a reference object to another entity that can be resolved using tools such as contentful-resolve
*/
export interface Link<T extends string> {
sys: {
type: 'Link'
linkType: T
id: string
}
}

/** String will be in ISO8601 datetime format e.g. 2013-06-26T13:57:24Z */
export type ISO8601Timestamp = string

export interface MetaSysProps {
type: string
id: string
@@ -43,12 +57,20 @@ export interface Collection<T, TPlain>
DefaultElements<CollectionProp<TPlain>> {}

/* eslint-disable @typescript-eslint/no-explicit-any */
export interface QueryOptions {
export interface QueryOptions extends BasicQueryOptions {
content_type?: string
include?: number
}

export interface BasicQueryOptions {
skip?: number
limit?: number
order?: string
content_type?: string
include?: number

[key: string]: any
}

export interface BasicCursorPaginationOptions {
prev?: string
next?: string
}
6 changes: 3 additions & 3 deletions lib/create-environment-api.ts
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ import { AxiosInstance } from 'axios'
import { createRequestConfig } from 'contentful-sdk-core'
import cloneDeep from 'lodash/cloneDeep'
import { Stream } from 'stream'
import { QueryOptions } from './common-types'
import { BasicQueryOptions, QueryOptions } from './common-types'
import entities from './entities'
import { AppInstallationProps } from './entities/app-installation'
import { AssetFileProp, AssetProps } from './entities/asset'
@@ -1023,9 +1023,9 @@ export default function createEnvironmentApi({
})
.then((response) => wrapTag(http, response.data), errorHandler)
},
getTags(skip?: number, limit?: number) {
getTags(query: BasicQueryOptions = {}) {
return http
.get('tags', { params: { skip, limit } })
.get('tags', createRequestConfig({ query }))
.then((response) => wrapTagCollection(http, response.data), errorHandler)
},
getTag(id: string) {
63 changes: 57 additions & 6 deletions lib/create-space-api.ts
Original file line number Diff line number Diff line change
@@ -21,14 +21,16 @@ import { WebhookProps } from './entities/webhook'
import { QueryOptions } from './common-types'
import { UIExtensionProps } from './entities/ui-extension'
import { CreateApiKeyProps } from './entities/api-key'
import { ScheduledActionQueryOptions, ScheduledActionProps } from './entities/scheduled-action'
import { EnvironmentAliasProps } from './entities/environment-alias'

function raiseDeprecationWarning(method: string) {
console.warn(
[
`Deprecated: Space.${method}() will be removed in future major versions.`,
null,
`Please migrate your code to use Environment.${method}():`,
`https://contentful.github.io/contentful-management.js/contentful-management/latest/ContentfulEnvironmentAPI.html#.${method}`,
'https://contentful.github.io/contentful-management.js/contentful-management/latest/globals.html#createenvironmentapi',
null,
].join('\n')
)
@@ -72,12 +74,13 @@ export default function createSpaceApi({
wrapTeamSpaceMembershipCollection,
} = entities.teamSpaceMembership
const { wrapApiKey, wrapApiKeyCollection } = entities.apiKey
const { wrapEditorInterface } = entities.editorInterface
const { wrapEnvironmentAlias, wrapEnvironmentAliasCollection } = entities.environmentAlias
const { wrapPreviewApiKey, wrapPreviewApiKeyCollection } = entities.previewApiKey
const { wrapScheduledAction, wrapScheduledActionCollection } = entities.scheduledAction
const { wrapSnapshotCollection } = entities.snapshot
const { wrapEditorInterface } = entities.editorInterface
const { wrapUpload } = entities.upload
const { wrapUiExtension, wrapUiExtensionCollection } = entities.uiExtension
const { wrapEnvironmentAlias, wrapEnvironmentAliasCollection } = entities.environmentAlias
const { wrapUpload } = entities.upload

function createAsset(data: Omit<AssetProps, 'sys'>) {
return http
@@ -992,9 +995,10 @@ export default function createSpaceApi({
* .catch(console.error)
* ```
*/
getRoles() {
getRoles(query: QueryOptions = {}) {
normalizeSelect(query)
return http
.get('roles')
.get('roles', createRequestConfig({ query }))
.then((response) => wrapRoleCollection(http, response.data), errorHandler)
},

@@ -1101,6 +1105,26 @@ export default function createSpaceApi({
.put('roles/' + id, data)
.then((response) => wrapRole(http, response.data), errorHandler)
},
/**
* Query for scheduled actions in space.
* @param query - Object with search parameters. The enviroment id field is mandatory. Check the <a href="https://www.contentful.com/developers/docs/references/content-management-api/#/reference/scheduled-actions/scheduled-actions-collection">REST API reference</a> for more details.
* @return Promise for the scheduled actions query
*/
getScheduledActions(query: ScheduledActionQueryOptions) {
return http
.get('scheduled_actions', createRequestConfig({ query: query }))
.then((response) => wrapScheduledActionCollection(http, response.data), errorHandler)
},
/**
* Creates a scheduled action
* @param data - Object representation of the scheduled action to be created
* @return Promise for the newly created scheduled actions
*/
createScheduledAction(data: Omit<ScheduledActionProps, 'sys'>) {
return http
.post('scheduled_actions', data)
.then((response) => wrapScheduledAction(http, response.data), errorHandler)
},
/**
* Gets a User
* @param id - User ID
@@ -1687,6 +1711,33 @@ export default function createSpaceApi({
.get(`content_types/${contentTypeId}/snapshots`, createRequestConfig({ query: query }))
.then((response) => wrapSnapshotCollection(http, response.data), errorHandler)
},
/**
* Creates an EnvironmentAlias with a custom ID
* @param id - EnvironmentAlias ID
* @param data - Object representation of the EnvironmentAlias to be created
* @return Promise for the newly created EnvironmentAlias
* @example ```javascript
* const contentful = require('contentful-management')
*
* const client = contentful.createClient({
* accessToken: '<content_management_api_key>'
* })
*
* client.getSpace('<space_id>')
* .then((space) => space.createEnvironmentAliasWithId('<environment-alias-id>', {
* environment: {
* sys: { type: 'Link', linkType: 'Environment', id: 'targetEnvironment' }
* }
* }))
* .then((environmentAlias) => console.log(environmentAlias))
* .catch(console.error)
* ```
*/
createEnvironmentAliasWithId(id: string, data: Omit<EnvironmentAliasProps, 'sys'>) {
return http
.put('environment_aliases/' + id, data)
.then((response) => wrapEnvironmentAlias(http, response.data), errorHandler)
},
/**
* Gets an Environment Alias
* @param Environment Alias ID
10 changes: 6 additions & 4 deletions lib/entities/app-installation.ts
Original file line number Diff line number Diff line change
@@ -75,10 +75,12 @@ function createAppInstallationApi(http: AxiosInstance) {
.then((response) => wrapAppInstallation(http, response.data), errorHandler)
},

delete: createDeleteEntity({
http: http,
entityPath: 'app_installations',
}),
delete: function () {
const raw = this.toPlainObject() as AppInstallation
return http.delete(`app_installations/${raw.sys.appDefinition.sys.id}`).then(() => {
// do nothing
}, errorHandler)
},
}
}

2 changes: 1 addition & 1 deletion lib/entities/asset.ts
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ export type AssetProps = {
/** Title for this asset */
title: { [key: string]: string }
/** Description for this asset */
description: { [key: string]: string }
description?: { [key: string]: string }
/** File object for this asset */
file: {
[key: string]: {
22 changes: 22 additions & 0 deletions lib/entities/editor-interface.ts
Original file line number Diff line number Diff line change
@@ -15,6 +15,17 @@ export interface Control {
*/
widgetId: string
widgetNamespace: string
settings?: Record<string, any>
}

export interface Editor {
widgetId: string
widgetNamespace: string
/**
* Widget will be enabled if disabled property is missing
*/
disabled?: boolean
settings?: Record<string, any>
}

export type EditorInterfaceProps = {
@@ -27,6 +38,14 @@ export type EditorInterfaceProps = {
* Array of fields and it's associated widgetId
*/
controls: Control[]
/**
* Array of editors. Defaults will be used if property is missing.
*/
editors?: Editor[]
/**
* Array of sidebar widgerts. Defaults will be used if property is missing.
*/
sidebar?: Editor[]
}

export interface EditorInterface
@@ -68,6 +87,9 @@ export interface EditorInterface
* .then((contentType) => contentType.getEditorInterface())
* .then((editorInterface) => {
* editorInterface.controls[0] = { "fieldId": "title", "widgetId": "singleLine"}
* editorInterface.editors = [
* { "widgetId": "custom-widget", "widgetNamespace": "app" }
* ]
* return editorInterface.update()
* })
* .catch(console.error)
33 changes: 30 additions & 3 deletions lib/entities/environment-alias.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import cloneDeep from 'lodash/cloneDeep'
import { freezeSys, toPlainObject } from 'contentful-sdk-core'
import enhanceWithMethods from '../enhance-with-methods'
import { createUpdateEntity } from '../instance-actions'
import { createUpdateEntity, createDeleteEntity } from '../instance-actions'
import { wrapCollection } from '../common-utils'
import { DefaultElements, MetaLinkProps, MetaSysProps } from '../common-types'
import { AxiosInstance } from 'axios'
@@ -11,7 +11,7 @@ export type EnvironmentAliasProps = {
* System meta data
*/
sys: MetaSysProps
environment: MetaLinkProps
environment: { sys: MetaLinkProps }
}

export interface EnvironmentAlias
@@ -39,7 +39,30 @@ export interface EnvironmentAlias
* .catch(console.error)
* ```
*/
update(data: Omit<EnvironmentAliasProps, 'sys'>): Promise<EnvironmentAlias>
update(): Promise<EnvironmentAlias>

/**
* Deletes this object on the server.
* @memberof EnvironmentAlias
* @func delete
* @return {Promise<void>} Promise for the deletion. It contains no data, but the Promise error case should be handled.
* ```javascript
* const contentful = require('contentful-management')
*
* const client = contentful.createClient({
* accessToken: '<content_management_api_key>'
* })
*
* client.getSpace('<space_id>')
* .then((space) => space.getEnvironmentAlias('<environment_alias_id>'))
* .then((alias) => {
* return alias.delete()
* })
* .then(() => console.log(`Alias deleted.`))
* .catch(console.error)
* ```
*/
delete(): Promise<void>
}

function createEnvironmentAliasApi(http: AxiosInstance) {
@@ -49,6 +72,10 @@ function createEnvironmentAliasApi(http: AxiosInstance) {
entityPath: 'environment_aliases',
wrapperMethod: wrapEnvironmentAlias,
}),
delete: createDeleteEntity({
http: http,
entityPath: 'environment_aliases',
}),
}
}

Loading