@contentful/app-sdk 4.0.0-alpha.7 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,63 +1,119 @@
1
- # [4.0.0-alpha.7](https://github.com/contentful/ui-extensions-sdk/compare/v4.0.0-alpha.6...v4.0.0-alpha.7) (2021-05-26)
1
+ ## [4.0.1](https://github.com/contentful/ui-extensions-sdk/compare/v4.0.0...v4.0.1) (2021-10-05)
2
2
 
3
3
 
4
- ### Features
4
+ ### Bug Fixes
5
5
 
6
- * better typings for user API ([#744](https://github.com/contentful/ui-extensions-sdk/issues/744)) ([29a6359](https://github.com/contentful/ui-extensions-sdk/commit/29a63594933f1063ac8734a9877fec6fa25928b9))
6
+ * measure old css file usage ([#1010](https://github.com/contentful/ui-extensions-sdk/issues/1010)) ([7dcd079](https://github.com/contentful/ui-extensions-sdk/commit/7dcd079c5f17f0a4e01e48e8184f0285dd0e9e1b))
7
7
 
8
- # [4.0.0-alpha.6](https://github.com/contentful/ui-extensions-sdk/compare/v4.0.0-alpha.5...v4.0.0-alpha.6) (2021-05-20)
8
+ # [4.0.0](https://github.com/contentful/ui-extensions-sdk/compare/v3.42.0...v4.0.0) (2021-10-05)
9
9
 
10
+ This major release of the Contentful App SDK provides two great features to make app development for Contentful even easier.
10
11
 
11
- ### Bug Fixes
12
+ ## Contentful Management API Adapter
13
+
14
+ You can now use the [`contentful-management` library](https://github.com/contentful/contentful-management.js) within apps. This gives you access to a huge load of APIs that were previously not available. Also, you can reuse existing code utilising the `contentful-management` library which makes it easier to convert your custom Contentful scripts to convenient apps.
15
+
16
+ After installing the library, a new client can be created using the `cmaAdapter` which is exposed by the App SDK. There is no need to deal with authentication and tokens.
17
+
18
+ ```javascript
19
+ import { createClient } from 'contentful-management'
20
+
21
+ const nestedClient = createClient({ apiAdapter: sdk.cmaAdapter })
22
+
23
+ const cma = createClient(
24
+ { apiAdapter: sdk.cmaAdapter },
25
+ {
26
+ type: 'plain',
27
+ defaults: {
28
+ environmentId: sdk.ids.environment,
29
+ spaceId: sdk.ids.space,
30
+ },
31
+ }
32
+ )
33
+ ```
34
+
35
+ Please note that not all methods are available. You can only use methods that access entities within the app’s space environment.
12
36
 
13
- * navigator api types ([#725](https://github.com/contentful/ui-extensions-sdk/issues/725)) ([7cac2eb](https://github.com/contentful/ui-extensions-sdk/commit/7cac2eb08200bba51d95d5461f00011a3add771b)), closes [#718](https://github.com/contentful/ui-extensions-sdk/issues/718) [#719](https://github.com/contentful/ui-extensions-sdk/issues/719) [#715](https://github.com/contentful/ui-extensions-sdk/issues/715) [#720](https://github.com/contentful/ui-extensions-sdk/issues/720) [#723](https://github.com/contentful/ui-extensions-sdk/issues/723) [#721](https://github.com/contentful/ui-extensions-sdk/issues/721)
37
+ ## Deprecation of Space API
14
38
 
15
- # [4.0.0-alpha.5](https://github.com/contentful/ui-extensions-sdk/compare/v4.0.0-alpha.4...v4.0.0-alpha.5) (2021-05-18)
39
+ The Space API (`sdk.space`) is deprecated and will be removed in a future major update of the App SDK. We recommend using the new CMA Adapters to replace existing Space API functionality.
16
40
 
41
+ ## Typings revamp
42
+
43
+ In the previous version of the App SDK app developers sometimes struggled with our provided types. For version 4 we took the opportunity to revamp and significantly improve the types of the whole library. These changes are likely to break existing TypeScript apps as we are more specific about each property and also changed the usage of generics on API methods.
44
+ The new types of the App SDK now align with the types of the `contentful-management` library.
45
+ To get the best development experience, you need to install `contentful-management` as a separate dependency.
46
+
47
+ ```bash
48
+ npm install contentful-management
49
+ ```
50
+
51
+ We do not include this dependency by default to keep your dependency tree clean and ensure small bundle sizes and short build times.
52
+
53
+ # [3.42.0](https://github.com/contentful/ui-extensions-sdk/compare/v3.41.0...v3.42.0) (2021-10-01)
17
54
 
18
55
  ### Features
19
56
 
20
- * expose WithId ([#722](https://github.com/contentful/ui-extensions-sdk/issues/722)) ([80189db](https://github.com/contentful/ui-extensions-sdk/commit/80189dbdf5b7592a73e1ed4ec4fef40b0c85a1c8))
57
+ - show better warning for DATA_CLONE_ERR [EXT-2761] ([#989](https://github.com/contentful/ui-extensions-sdk/issues/989)) ([fb82d86](https://github.com/contentful/ui-extensions-sdk/commit/fb82d866c4ffc97554673ea8e32bc8b81fa5f33c))
21
58
 
22
- # [4.0.0-alpha.4](https://github.com/contentful/ui-extensions-sdk/compare/v4.0.0-alpha.3...v4.0.0-alpha.4) (2021-05-18)
59
+ # [3.41.0](https://github.com/contentful/ui-extensions-sdk/compare/v3.40.1...v3.41.0) (2021-09-29)
23
60
 
61
+ ### Features
62
+
63
+ - Include patch in message ([#997](https://github.com/contentful/ui-extensions-sdk/issues/997)) ([0a97537](https://github.com/contentful/ui-extensions-sdk/commit/0a97537e3426dfb9a2c95365ae4c96eeb848d8b4))
64
+
65
+ ## [3.40.1](https://github.com/contentful/ui-extensions-sdk/compare/v3.40.0...v3.40.1) (2021-09-23)
24
66
 
25
67
  ### Bug Fixes
26
68
 
27
- * more explicit space api types ([#711](https://github.com/contentful/ui-extensions-sdk/issues/711)) ([42d63de](https://github.com/contentful/ui-extensions-sdk/commit/42d63dea5fd9a313918a9591311d716c3374ac60))
69
+ - **AccessSDK:** patch action isn't supported ([#987](https://github.com/contentful/ui-extensions-sdk/issues/987)) ([7aff0ae](https://github.com/contentful/ui-extensions-sdk/commit/7aff0aeb4d3680e33a2ab7173a78982c55fa3677))
28
70
 
71
+ # [3.40.0](https://github.com/contentful/ui-extensions-sdk/compare/v3.39.2...v3.40.0) (2021-09-17)
29
72
 
30
- ### Reverts
73
+ ### Features
31
74
 
32
- * "chore: test that SDK respects alias ([#710](https://github.com/contentful/ui-extensions-sdk/issues/710))" ([#717](https://github.com/contentful/ui-extensions-sdk/issues/717)) ([4ab6e48](https://github.com/contentful/ui-extensions-sdk/commit/4ab6e48237ef6d4cdd75c7721cd994539ced0ce2))
75
+ - **AccessAPI:** add support for JSON patches in access sdk [EXT-3041] ([#974](https://github.com/contentful/ui-extensions-sdk/issues/974)) ([a720fc2](https://github.com/contentful/ui-extensions-sdk/commit/a720fc223b19419f61fb5df917540834966dbd83))
33
76
 
34
- # [4.0.0-alpha.3](https://github.com/contentful/ui-extensions-sdk/compare/v4.0.0-alpha.2...v4.0.0-alpha.3) (2021-05-11)
77
+ ## [3.39.1](https://github.com/contentful/ui-extensions-sdk/compare/v3.39.0...v3.39.1) (2021-09-10)
35
78
 
36
79
  ### Bug Fixes
37
80
 
38
- - add missing types also in files ([#707](https://github.com/contentful/ui-extensions-sdk/issues/707)) ([957c858](https://github.com/contentful/ui-extensions-sdk/commit/957c85805a683832ca7f856fe525d17195a910d2))
81
+ - create upload types ([#961](https://github.com/contentful/ui-extensions-sdk/issues/961)) ([a65b320](https://github.com/contentful/ui-extensions-sdk/commit/a65b32046087763708f521b5b2dbb92ac22c6579))
39
82
 
40
- ## [3.34.3](https://github.com/contentful/ui-extensions-sdk/compare/v3.34.2...v3.34.3) (2021-05-18)
83
+ # [3.39.0](https://github.com/contentful/ui-extensions-sdk/compare/v3.38.0...v3.39.0) (2021-07-20)
41
84
 
42
- ### Reverts
85
+ ### Features
43
86
 
44
- - bump cypress from 7.2.0 to 7.3.0 ([#706](https://github.com/contentful/ui-extensions-sdk/issues/706)) ([ebcdf01](https://github.com/contentful/ui-extensions-sdk/commit/ebcdf01c26c59707e5733f34d8897a9de9bfa462))
87
+ - Add typings and expose metadata methods ([#865](https://github.com/contentful/ui-extensions-sdk/issues/865)) ([b0bbaad](https://github.com/contentful/ui-extensions-sdk/commit/b0bbaad477114f7929d974b8bce8c3c03f05f4bf))
45
88
 
46
- # [4.0.0-alpha.2](https://github.com/contentful/ui-extensions-sdk/compare/v4.0.0-alpha.1...v4.0.0-alpha.2) (2021-05-11)
89
+ # [3.38.0](https://github.com/contentful/ui-extensions-sdk/compare/v3.37.0...v3.38.0) (2021-06-30)
47
90
 
48
- ### Bug Fixes
91
+ ### Features
49
92
 
50
- - include typings in the release ([#699](https://github.com/contentful/ui-extensions-sdk/issues/699)) ([16b15e2](https://github.com/contentful/ui-extensions-sdk/commit/16b15e25ddcfd8a34a6f4c9732fc5e67929ac62b))
93
+ - add resolved info to tasks sys ([#822](https://github.com/contentful/ui-extensions-sdk/issues/822)) ([e0be824](https://github.com/contentful/ui-extensions-sdk/commit/e0be824956082aaa8fe00bd073f7354fb7dea51b))
51
94
 
52
- # [4.0.0-alpha.1](https://github.com/contentful/ui-extensions-sdk/compare/v3.34.1...v4.0.0-alpha.1) (2021-05-10)
95
+ # [3.37.0](https://github.com/contentful/ui-extensions-sdk/compare/v3.36.0...v3.37.0) (2021-06-23)
53
96
 
54
97
  ### Features
55
98
 
56
- - improve space API typings ([#684](https://github.com/contentful/ui-extensions-sdk/issues/684)) ([a57354c](https://github.com/contentful/ui-extensions-sdk/commit/a57354c32b78204d285aba897d213f201fec208c))
99
+ - add type parameter to create task input data ([#809](https://github.com/contentful/ui-extensions-sdk/issues/809)) ([e0fe688](https://github.com/contentful/ui-extensions-sdk/commit/e0fe688b3e07cf58abd20a0b1f9d82c7ea1e48e7))
100
+
101
+ # [3.36.0](https://github.com/contentful/ui-extensions-sdk/compare/v3.35.0...v3.36.0) (2021-06-17)
102
+
103
+ ### Features
57
104
 
58
- ### BREAKING CHANGES
105
+ - add interface for space.getTeams [HOMER-75] ([#789](https://github.com/contentful/ui-extensions-sdk/issues/789)) ([a5b8dac](https://github.com/contentful/ui-extensions-sdk/commit/a5b8dac92293d2e58ba7625ca4a310d182f3cabf))
106
+
107
+ # [3.35.0](https://github.com/contentful/ui-extensions-sdk/compare/v3.34.3...v3.35.0) (2021-06-11)
108
+
109
+ ### Features
110
+
111
+ - add due date as a task field type ([#776](https://github.com/contentful/ui-extensions-sdk/issues/776)) ([ed0bf60](https://github.com/contentful/ui-extensions-sdk/commit/ed0bf60ce877665a3558555346c6bf0c9274bb49))
112
+
113
+ ## [3.34.3](https://github.com/contentful/ui-extensions-sdk/compare/v3.34.2...v3.34.3) (2021-05-18)
114
+
115
+ ### Reverts
59
116
 
60
- - old typings were too loose.
61
117
  - "chore: test that SDK respects alias ([#710](https://github.com/contentful/ui-extensions-sdk/issues/710))" ([#717](https://github.com/contentful/ui-extensions-sdk/issues/717)) ([4ab6e48](https://github.com/contentful/ui-extensions-sdk/commit/4ab6e48237ef6d4cdd75c7721cd994539ced0ce2))
62
118
 
63
119
  ## [3.34.2](https://github.com/contentful/ui-extensions-sdk/compare/v3.34.1...v3.34.2) (2021-05-11)
package/dist/README.md CHANGED
@@ -6,6 +6,4 @@ Contentful UI Extension styles.
6
6
  It is here for backwards compatibility only: it will be packaged and published on npm
7
7
  so it's available under its legacy URL:
8
8
 
9
- https://unpkg.com/contentful-ui-extensions-sdk@3/dist/cf-extension.css
10
-
11
- We can remove it as soon as we reach 4.0.
9
+ https://unpkg.com/contentful-ui-extensions-sdk/dist/cf-extension.css
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).contentfulExtension={})}(this,(function(e){"use strict";var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,n)};var n,r=function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};var o=function(){function e(){this._id=0,this._listeners={}}return e.prototype.dispatch=function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];for(var r in this._listeners)(e=this._listeners)[r].apply(e,t)},e.prototype.attach=function(e){var t=this;if("function"!=typeof e)throw new Error("listener function expected");var n=this._id++;return this._listeners[n]=e,function(){return delete t._listeners[n]}},e}(),i="__private__memoized__arguments__",a=function(e){function r(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var o=e.call(this)||this;if(o[n]=[],!t.length)throw new Error("Initial value to be memoized expected");return o[i]=t,o}return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}(r,e),r.prototype.dispatch=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];this[i]=t,e.prototype.dispatch.apply(this,t)},r.prototype.attach=function(t){var n=e.prototype.attach.call(this,t);return t.apply(void 0,this[i]),n},r}(o);n=i;var s=function(){function e(e,t){var n=this;this._messageHandlers={},this._responseHandlers={},this._send=function(e,t){var n=0;return function(r,o){var i=n++;return t.postMessage({source:e,id:i,method:r,params:o},"*"),i}}(e,t.parent),t.addEventListener("message",(function(e){n._handleMessage(e.data)}))}return e.prototype.call=function(e){for(var t=this,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var o=this._send(e,n);return new Promise((function(e,n){t._responseHandlers[o]={resolve:e,reject:n}}))},e.prototype.send=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];this._send(e,t)},e.prototype.addHandler=function(e,t){return e in this._messageHandlers||(this._messageHandlers[e]=new o),this._messageHandlers[e].attach(t)},e.prototype._handleMessage=function(e){if(e.method){var t=e.method,n=e.params,r=this._messageHandlers[t];r&&r.dispatch.apply(r,n)}else{var o=e.id,i=this._responseHandlers[o];if(!i)return;"result"in e?i.resolve(e.result):"error"in e&&i.reject(e.error),delete this._responseHandlers[o]}},e}();var l=function(){function e(e,t){var n=this;this.id=t.id,this.locale=t.locale,this.type=t.type,this.required=t.required,this.validations=t.validations,this.items=t.items,this._value=t.value,this._valueSignal=new a(this._value),this._isDisabledSignal=new a(void 0),this._schemaErrorsChangedSignal=new a(void 0),this._channel=e,e.addHandler("valueChanged",(function(e,t,r){e!==n.id||t&&t!==n.locale||(n._value=r,n._valueSignal.dispatch(r))})),e.addHandler("isDisabledChangedForFieldLocale",(function(e,t,r){e===n.id&&t===n.locale&&n._isDisabledSignal.dispatch(r)})),e.addHandler("schemaErrorsChangedForFieldLocale",(function(e,t,r){e===n.id&&t===n.locale&&n._schemaErrorsChangedSignal.dispatch(r)}))}return e.prototype.getValue=function(){return this._value},e.prototype.setValue=function(e){return this._value=e,this._valueSignal.dispatch(e),this._channel.call("setValue",this.id,this.locale,e)},e.prototype.removeValue=function(){return this._value=void 0,this._channel.call("removeValue",this.id,this.locale)},e.prototype.setInvalid=function(e){return this._channel.call("setInvalid",e,this.locale)},e.prototype.onValueChanged=function(e){return this._valueSignal.attach(e)},e.prototype.onIsDisabledChanged=function(e){return this._isDisabledSignal.attach(e)},e.prototype.onSchemaErrorsChanged=function(e){return this._schemaErrorsChangedSignal.attach(e)},e}(),u=function(){function e(e,t,n){this.id=t.id,this.locales=t.locales,this.type=t.type,this.required=t.required,this.validations=t.validations,this.items=t.items,this._defaultLocale=n,this._fieldLocales=t.locales.reduce((function(n,o){var i,a=new l(e,{id:t.id,type:t.type,required:t.required,validations:t.validations,items:t.items,locale:o,value:t.values[o]});return r(r({},n),((i={})[o]=a,i))}),{}),this.assertHasLocale(n)}return e.prototype.getValue=function(e){return this._getFieldLocale(e).getValue()},e.prototype.setValue=function(e,t){return this._getFieldLocale(t).setValue(e)},e.prototype.removeValue=function(e){return this.setValue(void 0,e)},e.prototype.onValueChanged=function(e,t){var n=t||e;return t||(e=""),this._getFieldLocale(e).onValueChanged(n)},e.prototype.onIsDisabledChanged=function(e,t){var n=t||e;return t||(e=""),this._getFieldLocale(e).onIsDisabledChanged(n)},e.prototype._getFieldLocale=function(e){return e=e||this._defaultLocale,this.assertHasLocale(e),this._fieldLocales[e]},e.prototype.getForLocale=function(e){if(!e)throw new Error("getForLocale must be passed a locale");return this._getFieldLocale(e)},e.prototype.assertHasLocale=function(e){if(!this._fieldLocales[e])throw new Error('Unknown locale "'+e+'" for field "'+this.id+'"')},e}();function c(e,t){var n,r=e,o=r.document,i=r.MutationObserver,a=function(){u.updateHeight()},s=new i(a),l=!1,u={startAutoResizer:function(){if(u.updateHeight(),l)return;l=!0,s.observe(o.body,{attributes:!0,childList:!0,subtree:!0,characterData:!0}),e.addEventListener("resize",a)},stopAutoResizer:function(){if(!l)return;l=!1,s.disconnect(),e.removeEventListener("resize",a)},updateHeight:function(e){void 0===e&&(e=null);null===e&&(e=Math.ceil(o.documentElement.getBoundingClientRect().height));e!==n&&(t.send("setHeight",e),n=e)}};return u}var d=["getTask","getTasks","createTask","updateTask","deleteTask"];function p(e,t,n,o){var i=t.sys,s=new a(i),l=t.metadata;e.addHandler("sysChanged",(function(e){i=e,s.dispatch(i)}));var u={};return d.forEach((function(t){u[t]=function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return e.call("callEntryMethod",t,n)}})),r(r({getSys:function(){return i},onSysChanged:function(e){return s.attach(e)},fields:n.reduce((function(e,t){return e[t.id]=o(t),e}),{})},l?{metadata:l}:{}),u)}var f=["getContentType","getEntry","getEntrySnapshots","getAsset","getEditorInterface","getPublishedEntries","getPublishedAssets","getContentTypes","getEntries","getEditorInterfaces","getAssets","createContentType","createEntry","createAsset","updateContentType","updateEntry","updateAsset","deleteContentType","deleteEntry","deleteAsset","publishEntry","publishAsset","unpublishEntry","unpublishAsset","archiveEntry","archiveAsset","unarchiveEntry","unarchiveAsset","createUpload","processAsset","waitUntilAssetProcessed","getUsers","getAllScheduledActions","getEntityScheduledActions","signRequest","createTag","readTags","updateTag","deleteTag"];function h(e,t){var n={};return f.forEach((function(t){n[t]=function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return e.call("callSpaceMethod",t,n)}})),n.getCachedContentTypes=function(){return function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),o=0;for(t=0;t<n;t++)for(var i=arguments[t],a=0,s=i.length;a<s;a++,o++)r[o]=i[a];return r}(t)},n}var v=function(e){return"object"!=typeof(t=e)||null===t||Array.isArray(t)?{}:e;var t};function g(e,t){return{openAlert:n.bind(null,"alert"),openConfirm:n.bind(null,"confirm"),openPrompt:n.bind(null,"prompt"),openExtension:o,openCurrentApp:i,openCurrent:function(e){return t.app?i(e):o(r(r({},e),{id:t.extension}))},selectSingleEntry:a.bind(null,"Entry",!1),selectSingleAsset:a.bind(null,"Asset",!1),selectMultipleEntries:a.bind(null,"Entry",!0),selectMultipleAssets:a.bind(null,"Asset",!0)};function n(t,n){return e.call("openDialog",t,v(n))}function o(n){var o=v(n);if((o=r(r({},o),{id:o.id||t.extension})).id)return e.call("openDialog","extension",o);throw new Error("Extension ID not provided.")}function i(n){if(n=v(n),t.app){var o=r(r({},n),{id:t.app});return e.call("openDialog","app",o)}throw new Error("Not in the app context.")}function a(t,n,r){return(r=v(r)).entityType=t,r.multiple=n,e.call("openDialog","entitySelector",r)}}function y(e,t){var n=new a(void 0),r=new a(void 0);return e.addHandler("localeSettingsChanged",(function(e){n.dispatch(e)})),e.addHandler("showDisabledFieldsChanged",(function(e){r.dispatch(e)})),{editorInterface:t,onLocaleSettingsChanged:function(e){return n.attach(e)},onShowDisabledFieldsChanged:function(e){return r.attach(e)}}}function _(e,t){var n=new o;return e.addHandler("navigateSlideIn",(function(e){n.dispatch(e)})),{openEntry:function(t,n){return e.call("navigateToContentEntity",r(r({},n),{entityType:"Entry",id:t}))},openNewEntry:function(t,n){return e.call("navigateToContentEntity",r(r({},n),{entityType:"Entry",id:null,contentTypeId:t}))},openBulkEditor:function(t,n){return e.call("navigateToBulkEditor",r({entryId:t},n))},openAsset:function(t,n){return e.call("navigateToContentEntity",r(r({},n),{entityType:"Asset",id:t}))},openNewAsset:function(t){return e.call("navigateToContentEntity",r(r({},t),{entityType:"Asset",id:null}))},openPageExtension:function(n){return e.call("navigateToPage",r({type:"extension",id:t.extension},n))},openCurrentAppPage:function(n){return e.call("navigateToPage",r({type:"app",id:t.app},n))},openAppConfig:function(){return e.call("navigateToAppConfig")},openEntriesList:function(){return e.call("navigateToSpaceEnvRoute",{route:"entries"})},openAssetsList:function(){return e.call("navigateToSpaceEnvRoute",{route:"assets"})},onSlideInNavigation:function(e){return n.attach(e)}}}var E="preInstall",m="postInstall",A=function(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)},C=function(e){return"function"==typeof e},T=function(e){return console.error(e),Promise.resolve(!1)},I=function(e,t,n){if(!C(e))return Promise.resolve(t);var r;try{r=void 0===n?e():e(n)}catch(e){return T(e)}var o,i=r;return A(o=i)&&C(o.then)||(i=Promise.resolve(i)),i.then((function(e){return e instanceof Error?Promise.reject(e):!1!==e&&(A(e)?e:t)}),T).catch(T)};function w(e){var t,n=((t={}).preInstall=null,t.postInstall=null,t),r=function(e,t){if(!C(t))throw new Error("Handler must be a function.");n[e]=t};return e.addHandler("appHook",(function(t){var r=t.stage,o=t.installationRequestId,i=t.err;return r===E?I(n[r],{}).then((function(t){return e.send("appHookResult",{stage:r,installationRequestId:o,result:t})})):r===m?I(n[r],void 0,i||null).then((function(){return e.send("appHookResult",{stage:r,installationRequestId:o})})):Promise.resolve()})),{setReady:function(){return e.call("callAppMethod","setReady")},isInstalled:function(){return e.call("callAppMethod","isInstalled")},getParameters:function(){return e.call("callAppMethod","getParameters")},getCurrentState:function(){return e.call("callAppMethod","getCurrentState")},onConfigure:function(e){r(E,e)},onConfigurationCompleted:function(e){r(m,e)}}}var b,L={LOCATION_ENTRY_FIELD:"entry-field",LOCATION_ENTRY_FIELD_SIDEBAR:"entry-field-sidebar",LOCATION_ENTRY_SIDEBAR:"entry-sidebar",LOCATION_DIALOG:"dialog",LOCATION_ENTRY_EDITOR:"entry-editor",LOCATION_PAGE:"page",LOCATION_APP_CONFIG:"app-config"},O=[N,P,function(e,t){var n=t.field;if(!n)throw new Error('FieldAPI called for location without "field" property defined.');return{field:new l(e,n)}},H,D],S=((b={})[L.LOCATION_ENTRY_FIELD]=O,b[L.LOCATION_ENTRY_FIELD_SIDEBAR]=O,b[L.LOCATION_ENTRY_SIDEBAR]=[N,P,H,D],b[L.LOCATION_ENTRY_EDITOR]=[N,P,H],b[L.LOCATION_DIALOG]=[N,function(e){return{close:function(t){return e.send("closeDialog",t)}}},D],b[L.LOCATION_PAGE]=[N],b[L.LOCATION_APP_CONFIG]=[N,function(e){return{app:w(e)}}],b);function N(e,t){var n=t.user,r=t.parameters,o=t.locales,i=t.ids,a=t.initialContentTypes,s=t.location||L.LOCATION_ENTRY_FIELD;return{location:{is:function(e){return s===e}},user:n,parameters:r,locales:{available:o.available,default:o.default,names:o.names,fallbacks:o.fallbacks,optional:o.optional,direction:o.direction},space:h(e,a),dialogs:g(e,i),navigator:_(e,i),notifier:{success:function(t){return e.send("notify",{type:"success",message:t})},error:function(t){return e.send("notify",{type:"error",message:t})}},ids:i,access:{can:function(t,n){return e.call("checkAccess",t,n)},canEditAppConfig:function(){return e.call("checkAppConfigAccess")}}}}function D(e,t,n){return{window:c(n,e)}}function H(e,t){return{editor:y(e,t.editorInterface)}}function P(e,t){var n=t.locales,r=t.contentType,o=t.entry,i=t.fieldInfo;return{contentType:r,entry:p(e,o,i,(function(t){return new u(e,t,n.default)}))}}var R,x,F,k,M=(R=window,x=function(e,t,n){return(S[t.location]||O).reduce((function(o,i){return r(r({},o),i(e,t,n))}),{})},(F={promise:null,resolve:null}).promise=new Promise((function(e){F.resolve=e})),(k=F).promise.then((function(e){var t=e[0],n=R.document;n.addEventListener("focus",(function(){return t.send("setActive",!0)}),!0),n.addEventListener("blur",(function(){return t.send("setActive",!1)}),!0)})),function(e,t){!function(e,t){function n(r){var o=r.data;"connect"===o.method&&(e.removeEventListener("message",n),t.apply(void 0,o.params))}e.addEventListener("message",n)}(e,(function(n,r){var o=new s(n.id,e);t(o,n,r)}))}(R,(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return k.resolve(e)})),function(e,t){var n=void 0===t?{supressIframeWarning:!1}:t,r=n.makeCustomApi;n.supressIframeWarning||R.self!==R.top||console.error("Cannot use ui-extension-sdk outside of Contenful:\n\nIn order for the ui-extension-sdk to function correctly, your app needs to be run in an iframe in the Contentful Web App.\n\nLearn more about local development with the ui-extension-sdk here:\n https://www.contentful.com/developers/docs/extensibility/ui-extensions/faq/#how-can-i-use-the-ui-extension-sdk-locally"),k.promise.then((function(t){var n,o=t[0],i=t[1],a=t[2],s=x(o,i,R);"function"==typeof r&&(n=r(o,i)),a.forEach((function(e){o._handleMessage(e)})),e(s,n)}))});e.init=M,e.locations=L,Object.defineProperty(e,"__esModule",{value:!0})})),window.contentfulApp=window.contentfulExtension;
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).contentfulExtension={})}(this,(function(e){"use strict";var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,n)};var n,r=function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};var o=function(){function e(){this._id=0,this._listeners={}}return e.prototype.dispatch=function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];for(var r in this._listeners)(e=this._listeners)[r].apply(e,t)},e.prototype.attach=function(e){var t=this;if("function"!=typeof e)throw new Error("listener function expected");var n=this._id++;return this._listeners[n]=e,function(){return delete t._listeners[n]}},e}(),i="__private__memoized__arguments__",a=function(e){function r(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var o=e.call(this)||this;if(o[n]=[],!t.length)throw new Error("Initial value to be memoized expected");return o[i]=t,o}return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}(r,e),r.prototype.dispatch=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];this[i]=t,e.prototype.dispatch.apply(this,t)},r.prototype.attach=function(t){var n=e.prototype.attach.call(this,t);return t.apply(void 0,this[i]),n},r}(o);n=i;var s=function(){function e(e,t){var n=this;this._messageHandlers={},this._responseHandlers={},this._send=function(e,t){var n=0;return function(r,o){var i=n++;try{t.postMessage({source:e,id:i,method:r,params:o},"*")}catch(e){throw e instanceof DOMException&&"DataCloneError"===e.name&&"openDialog"===r&&console.error("Error: openCurrent[App] parameters could not be parsed. You likely tried to pass functions or DOM elements as a parameter. Tip: Use the App SDK directly within the dialog location.\n\nLearn more about the dialog location: https://ctfl.io/app-sdk-dialog"),e}return i}}(e,t.parent),t.addEventListener("message",(function(e){n._handleMessage(e.data)}))}return e.prototype.call=function(e){for(var t=this,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var o=this._send(e,n);return new Promise((function(e,n){t._responseHandlers[o]={resolve:e,reject:n}}))},e.prototype.send=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];this._send(e,t)},e.prototype.addHandler=function(e,t){return e in this._messageHandlers||(this._messageHandlers[e]=new o),this._messageHandlers[e].attach(t)},e.prototype._handleMessage=function(e){if(e.method){var t=e.method,n=e.params,r=this._messageHandlers[t];r&&r.dispatch.apply(r,n)}else{var o=e.id,i=this._responseHandlers[o];if(!i)return;"result"in e?i.resolve(e.result):"error"in e&&i.reject(e.error),delete this._responseHandlers[o]}},e}();var l=function(){function e(e,t){var n=this;this.id=t.id,this.locale=t.locale,this.type=t.type,this.required=t.required,this.validations=t.validations,this.items=t.items,this._value=t.value,this._valueSignal=new a(this._value),this._isDisabledSignal=new a(void 0),this._schemaErrorsChangedSignal=new a(void 0),this._channel=e,e.addHandler("valueChanged",(function(e,t,r){e!==n.id||t&&t!==n.locale||(n._value=r,n._valueSignal.dispatch(r))})),e.addHandler("isDisabledChangedForFieldLocale",(function(e,t,r){e===n.id&&t===n.locale&&n._isDisabledSignal.dispatch(r)})),e.addHandler("schemaErrorsChangedForFieldLocale",(function(e,t,r){e===n.id&&t===n.locale&&n._schemaErrorsChangedSignal.dispatch(r)}))}return e.prototype.getValue=function(){return this._value},e.prototype.setValue=function(e){return this._value=e,this._valueSignal.dispatch(e),this._channel.call("setValue",this.id,this.locale,e)},e.prototype.removeValue=function(){return this._value=void 0,this._channel.call("removeValue",this.id,this.locale)},e.prototype.setInvalid=function(e){return this._channel.call("setInvalid",e,this.locale)},e.prototype.onValueChanged=function(e){return this._valueSignal.attach(e)},e.prototype.onIsDisabledChanged=function(e){return this._isDisabledSignal.attach(e)},e.prototype.onSchemaErrorsChanged=function(e){return this._schemaErrorsChangedSignal.attach(e)},e}(),u=function(){function e(e,t,n){this.id=t.id,this.locales=t.locales,this.type=t.type,this.required=t.required,this.validations=t.validations,this.items=t.items,this._defaultLocale=n,this._fieldLocales=t.locales.reduce((function(n,o){var i,a=new l(e,{id:t.id,type:t.type,required:t.required,validations:t.validations,items:t.items,locale:o,value:t.values[o]});return r(r({},n),((i={})[o]=a,i))}),{}),this.assertHasLocale(n)}return e.prototype.getValue=function(e){return this._getFieldLocale(e).getValue()},e.prototype.setValue=function(e,t){return this._getFieldLocale(t).setValue(e)},e.prototype.removeValue=function(e){return this.setValue(void 0,e)},e.prototype.onValueChanged=function(e,t){var n=t||e;return t||(e=""),this._getFieldLocale(e).onValueChanged(n)},e.prototype.onIsDisabledChanged=function(e,t){var n=t||e;return t||(e=""),this._getFieldLocale(e).onIsDisabledChanged(n)},e.prototype._getFieldLocale=function(e){return e=e||this._defaultLocale,this.assertHasLocale(e),this._fieldLocales[e]},e.prototype.getForLocale=function(e){if(!e)throw new Error("getForLocale must be passed a locale");return this._getFieldLocale(e)},e.prototype.assertHasLocale=function(e){if(!this._fieldLocales[e])throw new Error('Unknown locale "'+e+'" for field "'+this.id+'"')},e}();function c(e,t){var n,r=e,o=r.document,i=r.MutationObserver,a=function(){u.updateHeight()},s=new i(a),l=!1,u={startAutoResizer:function(){if(u.updateHeight(),l)return;l=!0,s.observe(o.body,{attributes:!0,childList:!0,subtree:!0,characterData:!0}),e.addEventListener("resize",a)},stopAutoResizer:function(){if(!l)return;l=!1,s.disconnect(),e.removeEventListener("resize",a)},updateHeight:function(e){void 0===e&&(e=null);null===e&&(e=Math.ceil(o.documentElement.getBoundingClientRect().height));e!==n&&(t.send("setHeight",e),n=e)}};return u}var d=["getTask","getTasks","createTask","updateTask","deleteTask"];function p(e,t,n,o){var i=t.sys,s=new a(i),l=t.metadata,u=new a(l);e.addHandler("sysChanged",(function(e){i=e,s.dispatch(i)})),e.addHandler("metadataChanged",(function(e){l=e,u.dispatch(l)}));var c={};return d.forEach((function(t){c[t]=function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return e.call("callEntryMethod",t,n)}})),r(r(r({getSys:function(){return i},onSysChanged:function(e){return s.attach(e)},fields:n.reduce((function(e,t){return e[t.id]=o(t),e}),{})},l?{metadata:l}:{}),{getMetadata:function(){return l},onMetadataChanged:function(e){return u.attach(e)}}),c)}var f=["getContentType","getEntry","getEntrySnapshots","getAsset","getEditorInterface","getPublishedEntries","getPublishedAssets","getContentTypes","getEntries","getEditorInterfaces","getAssets","createContentType","createEntry","createAsset","updateContentType","updateEntry","updateAsset","deleteContentType","deleteEntry","deleteAsset","publishEntry","publishAsset","unpublishEntry","unpublishAsset","archiveEntry","archiveAsset","unarchiveEntry","unarchiveAsset","createUpload","processAsset","waitUntilAssetProcessed","getUsers","getAllScheduledActions","getEntityScheduledActions","signRequest","createTag","readTags","updateTag","deleteTag","getTeams"];function h(e,t){var n={};return f.forEach((function(t){n[t]=function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return console.warn("You called "+String(t)+" on the Space API. Since version 4.0.0 the Space API and its methods are deprecated. We recommend that you use the CMA client instead. See https://www.contentful.com/developers/docs/extensibility/app-framework/sdk/#using-the-contentful-management-library for more details."),e.call("callSpaceMethod",t,n)}})),n.getCachedContentTypes=function(){return function(e,t){for(var n=0,r=t.length,o=e.length;n<r;n++,o++)e[o]=t[n];return e}([],t)},n}var g=function(e){return"object"!=typeof(t=e)||null===t||Array.isArray(t)?{}:e;var t};function v(e,t){return{openAlert:n.bind(null,"alert"),openConfirm:n.bind(null,"confirm"),openPrompt:n.bind(null,"prompt"),openExtension:o,openCurrentApp:i,openCurrent:function(e){return t.app?i(e):o(r(r({},e),{id:t.extension}))},selectSingleEntry:a.bind(null,"Entry",!1),selectSingleAsset:a.bind(null,"Asset",!1),selectMultipleEntries:a.bind(null,"Entry",!0),selectMultipleAssets:a.bind(null,"Asset",!0)};function n(t,n){return e.call("openDialog",t,g(n))}function o(n){var o=g(n);if((o=r(r({},o),{id:o.id||t.extension})).id)return e.call("openDialog","extension",o);throw new Error("Extension ID not provided.")}function i(n){if(n=g(n),t.app){var o=r(r({},n),{id:t.app});return e.call("openDialog","app",o)}throw new Error("Not in the app context.")}function a(t,n,r){return(r=g(r)).entityType=t,r.multiple=n,e.call("openDialog","entitySelector",r)}}function y(e,t){var n=new a(void 0),r=new a(void 0);return e.addHandler("localeSettingsChanged",(function(e){n.dispatch(e)})),e.addHandler("showDisabledFieldsChanged",(function(e){r.dispatch(e)})),{editorInterface:t,onLocaleSettingsChanged:function(e){return n.attach(e)},onShowDisabledFieldsChanged:function(e){return r.attach(e)}}}function _(e,t){var n=new o;return e.addHandler("navigateSlideIn",(function(e){n.dispatch(e)})),{openEntry:function(t,n){return e.call("navigateToContentEntity",r(r({},n),{entityType:"Entry",id:t}))},openNewEntry:function(t,n){return e.call("navigateToContentEntity",r(r({},n),{entityType:"Entry",id:null,contentTypeId:t}))},openBulkEditor:function(t,n){return e.call("navigateToBulkEditor",r({entryId:t},n))},openAsset:function(t,n){return e.call("navigateToContentEntity",r(r({},n),{entityType:"Asset",id:t}))},openNewAsset:function(t){return e.call("navigateToContentEntity",r(r({},t),{entityType:"Asset",id:null}))},openPageExtension:function(n){return e.call("navigateToPage",r({type:"extension",id:t.extension},n))},openCurrentAppPage:function(n){return e.call("navigateToPage",r({type:"app",id:t.app},n))},openAppConfig:function(){return e.call("navigateToAppConfig")},openEntriesList:function(){return e.call("navigateToSpaceEnvRoute",{route:"entries"})},openAssetsList:function(){return e.call("navigateToSpaceEnvRoute",{route:"assets"})},onSlideInNavigation:function(e){return n.attach(e)}}}var m="preInstall",E="postInstall",A=function(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)},C=function(e){return"function"==typeof e},T=function(e){return console.error(e),Promise.resolve(!1)},w=function(e,t,n){if(!C(e))return Promise.resolve(t);var r;try{r=void 0===n?e():e(n)}catch(e){return T(e)}var o,i=r;return A(o=i)&&C(o.then)||(i=Promise.resolve(i)),i.then((function(e){return e instanceof Error?Promise.reject(e):!1!==e&&(A(e)?e:t)}),T).catch(T)};function I(e){var t,n=((t={}).preInstall=null,t.postInstall=null,t),r=function(e,t){if(!C(t))throw new Error("Handler must be a function.");n[e]=t};return e.addHandler("appHook",(function(t){var r=t.stage,o=t.installationRequestId,i=t.err;return r===m?w(n[r],{}).then((function(t){return e.send("appHookResult",{stage:r,installationRequestId:o,result:t})})):r===E?w(n[r],void 0,i||null).then((function(){return e.send("appHookResult",{stage:r,installationRequestId:o})})):Promise.resolve()})),{setReady:function(){return e.call("callAppMethod","setReady")},isInstalled:function(){return e.call("callAppMethod","isInstalled")},getParameters:function(){return e.call("callAppMethod","getParameters")},getCurrentState:function(){return e.call("callAppMethod","getCurrentState")},onConfigure:function(e){r(m,e)},onConfigurationCompleted:function(e){r(E,e)}}}var b,L={LOCATION_ENTRY_FIELD:"entry-field",LOCATION_ENTRY_FIELD_SIDEBAR:"entry-field-sidebar",LOCATION_ENTRY_SIDEBAR:"entry-sidebar",LOCATION_DIALOG:"dialog",LOCATION_ENTRY_EDITOR:"entry-editor",LOCATION_PAGE:"page",LOCATION_APP_CONFIG:"app-config"},O=function(e){return function(t){return e.call("CMAAdapterCall",t)}};function S(e){return{makeRequest:O(e)}}var D=[N,k,function(e,t){var n=t.field;if(!n)throw new Error('FieldAPI called for location without "field" property defined.');return{field:new l(e,n)}},R,P],H=((b={})[L.LOCATION_ENTRY_FIELD]=D,b[L.LOCATION_ENTRY_FIELD_SIDEBAR]=D,b[L.LOCATION_ENTRY_SIDEBAR]=[N,k,R,P],b[L.LOCATION_ENTRY_EDITOR]=[N,k,R],b[L.LOCATION_DIALOG]=[N,function(e){return{close:function(t){return e.send("closeDialog",t)}}},P],b[L.LOCATION_PAGE]=[N],b[L.LOCATION_APP_CONFIG]=[N,function(e){return{app:I(e)}}],b);function N(e,t){var n=t.user,r=t.parameters,o=t.locales,i=t.ids,a=t.initialContentTypes,s=t.location||L.LOCATION_ENTRY_FIELD;return{cmaAdapter:S(e),location:{is:function(e){return s===e}},user:n,parameters:r,locales:{available:o.available,default:o.default,names:o.names,fallbacks:o.fallbacks,optional:o.optional,direction:o.direction},space:h(e,a),dialogs:v(e,i),navigator:_(e,i),notifier:{success:function(t){return e.send("notify",{type:"success",message:t})},error:function(t){return e.send("notify",{type:"error",message:t})}},ids:i,access:{can:function(t,n,r){return e.call("checkAccess",t,n,r)},canEditAppConfig:function(){return e.call("checkAppConfigAccess")}}}}function P(e,t,n){return{window:c(n,e)}}function R(e,t){return{editor:y(e,t.editorInterface)}}function k(e,t){var n=t.locales,r=t.contentType,o=t.entry,i=t.fieldInfo;return{contentType:r,entry:p(e,o,i,(function(t){return new u(e,t,n.default)}))}}var x,F,M,V,j=(x=window,F=function(e,t,n){return(H[t.location]||D).reduce((function(o,i){return r(r({},o),i(e,t,n))}),{})},(M={promise:null,resolve:null}).promise=new Promise((function(e){M.resolve=e})),(V=M).promise.then((function(e){var t=e[0],n=x.document;n.addEventListener("focus",(function(){return t.send("setActive",!0)}),!0),n.addEventListener("blur",(function(){return t.send("setActive",!1)}),!0)})),function(e,t){!function(e,t){function n(r){var o=r.data;"connect"===o.method&&(e.removeEventListener("message",n),t.apply(void 0,o.params))}e.addEventListener("message",n)}(e,(function(n,r){var o=new s(n.id,e);t(o,n,r)}))}(x,(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return V.resolve(e)})),function(e,t){var n=void 0===t?{supressIframeWarning:!1}:t,r=n.makeCustomApi;n.supressIframeWarning||x.self!==x.top||console.error("Cannot use ui-extension-sdk outside of Contenful:\n\nIn order for the ui-extension-sdk to function correctly, your app needs to be run in an iframe in the Contentful Web App.\n\nLearn more about local development with the ui-extension-sdk here:\n https://www.contentful.com/developers/docs/extensibility/ui-extensions/faq/#how-can-i-use-the-ui-extension-sdk-locally"),V.promise.then((function(t){var n,o=t[0],i=t[1],a=t[2],s=F(o,i,x);"function"==typeof r&&(n=r(o,i)),a.forEach((function(e){o._handleMessage(e)})),e(s,n)}))});e.init=j,e.locations=L,Object.defineProperty(e,"__esModule",{value:!0})})),window.contentfulApp=window.contentfulExtension;
@@ -14,6 +14,8 @@ body {
14
14
  font-size: 14px;
15
15
  line-height: 18px;
16
16
  color: #2d2f31;
17
+
18
+ background-image: url("https://api.contentful.com/uie-tracking");
17
19
  }
18
20
  b,
19
21
  strong {
@@ -0,0 +1,3 @@
1
+ import { Channel } from './channel';
2
+ import { Adapter } from 'contentful-management/types';
3
+ export declare function createAdapter(channel: Channel): Adapter;
@@ -1,13 +1,14 @@
1
- import { ContentType, EditorInterface, SpaceMembership, Role } from './entities';
1
+ import { ContentType, EditorInterface, SpaceMembership, Role, ContentTypeField, Metadata, Entry, Task, Asset } from './entities';
2
2
  import { EntryAPI } from './entry.types';
3
3
  import { SpaceAPI } from './space.types';
4
4
  import { WindowAPI } from './window.types';
5
- import { ContentEntitySys, Metadata } from './utils';
5
+ import { ContentEntitySys, Link } from './utils';
6
6
  import { FieldAPI } from './field-locale.types';
7
7
  import { DialogsAPI } from './dialogs.types';
8
8
  import { AppConfigAPI } from './app.types';
9
9
  import { NavigatorAPI } from './navigator.types';
10
10
  import { EntryFieldInfo, FieldInfo } from './field.types';
11
+ import { Adapter } from 'contentful-management/types';
11
12
  export interface UserAPI {
12
13
  sys: {
13
14
  id: string;
@@ -52,7 +53,7 @@ export interface NotifierAPI {
52
53
  error: (message: string) => void;
53
54
  }
54
55
  export interface LocationAPI {
55
- /** Checks the location in which your extension is running */
56
+ /** Checks the location in which your app is running */
56
57
  is: (type: string) => boolean;
57
58
  }
58
59
  export interface ParametersAPI {
@@ -71,6 +72,22 @@ export interface IdsAPI {
71
72
  entry: string;
72
73
  contentType: string;
73
74
  }
75
+ /** Content API */
76
+ export interface ContentTypeAPI {
77
+ sys: {
78
+ id: string;
79
+ type: 'ContentType';
80
+ revision: number;
81
+ space: Link<'Space', 'Link'>;
82
+ environment: Link<'Environment', 'Link'>;
83
+ createdAt?: string;
84
+ updatedAt?: string;
85
+ };
86
+ fields: ContentTypeField[];
87
+ name: string;
88
+ displayField: string;
89
+ description: string;
90
+ }
74
91
  export interface EditorLocaleSettings {
75
92
  mode: 'multi' | 'single';
76
93
  focused?: string;
@@ -85,21 +102,31 @@ export interface SharedEditorSDK {
85
102
  /** Allows to read and update the value of any field of the current entry and to get the entry's metadata */
86
103
  entry: EntryAPI;
87
104
  /** Information about the content type of the entry. */
88
- contentType: ContentType;
105
+ contentType: ContentTypeAPI;
89
106
  }
90
107
  declare type CrudAction = 'create' | 'read' | 'update' | 'delete';
91
108
  declare type PublishableAction = 'publish' | 'unpublish';
92
109
  declare type ArchiveableAction = 'archive' | 'unarchive';
110
+ export declare type JSONPatchItem = {
111
+ op: 'remove' | 'replace' | 'add';
112
+ path: string;
113
+ value?: any;
114
+ };
115
+ declare type PatchEntity = Entry | Task | Asset;
93
116
  export interface AccessAPI {
94
117
  can(action: 'read' | 'update', entity: 'EditorInterface' | EditorInterface): Promise<boolean>;
95
118
  can<T = Object>(action: CrudAction, entity: 'ContentType' | ContentType | 'Asset' | 'Entry' | T): Promise<boolean>;
96
119
  can<T = Object>(action: PublishableAction, entity: 'ContentType' | ContentType | 'Asset' | 'Entry' | T): Promise<boolean>;
97
120
  can<T = Object>(action: ArchiveableAction, entity: 'Asset' | 'Entry' | T): Promise<boolean>;
121
+ can(action: 'update', entity: PatchEntity, patch: JSONPatchItem[]): Promise<boolean>;
98
122
  /** Whether the current user can edit app config */
99
123
  canEditAppConfig: () => Promise<boolean>;
100
124
  }
125
+ declare type EntryScopedIds = 'field' | 'entry' | 'contentType';
101
126
  export interface BaseExtensionSDK {
102
- /** Exposes methods that allow the extension to read and manipulate a wide range of objects in the space. */
127
+ /** @deprecated since version 4.0.0 consider using the CMA instead
128
+ * See https://www.contentful.com/developers/docs/extensibility/app-framework/sdk/#using-the-contentful-management-library for more details
129
+ */
103
130
  space: SpaceAPI;
104
131
  /** Information about the current user and roles */
105
132
  user: UserAPI;
@@ -111,46 +138,48 @@ export interface BaseExtensionSDK {
111
138
  navigator: NavigatorAPI;
112
139
  /** Methods for displaying notifications. */
113
140
  notifier: NotifierAPI;
114
- /** Exposes extension configuration parameters */
141
+ /** Exposes app configuration parameters */
115
142
  parameters: ParametersAPI;
116
- /** Exposes method to identify extension's location */
143
+ /** Exposes method to identify app's location */
117
144
  location: LocationAPI;
118
145
  /** Exposes methods for checking user's access level */
119
146
  access: AccessAPI;
120
147
  /** Exposes relevant ids, keys may be ommited based on location */
121
- ids: IdsAPI;
148
+ ids: Omit<IdsAPI, EntryScopedIds>;
149
+ /** Adapter to be injected in contentful-management client */
150
+ cmaAdapter: Adapter;
122
151
  }
123
152
  export declare type EditorExtensionSDK = Omit<BaseExtensionSDK, 'ids'> & SharedEditorSDK & {
124
- /** A set of IDs actual for the extension */
153
+ /** A set of IDs actual for the app */
125
154
  ids: Omit<IdsAPI, 'field'>;
126
155
  };
127
156
  export declare type SidebarExtensionSDK = Omit<BaseExtensionSDK, 'ids'> & SharedEditorSDK & {
128
- /** A set of IDs actual for the extension */
157
+ /** A set of IDs actual for the app */
129
158
  ids: Omit<IdsAPI, 'field'>;
130
- /** Methods to update the size of the iframe the extension is contained within. */
159
+ /** Methods to update the size of the iframe the app is contained within. */
131
160
  window: WindowAPI;
132
161
  };
133
162
  export declare type FieldExtensionSDK = BaseExtensionSDK & SharedEditorSDK & {
134
- /** Gives you access to the value and metadata of the field the extension is attached to. */
163
+ /** Gives you access to the value and metadata of the field the app is attached to. */
135
164
  field: FieldAPI;
136
- /** Methods to update the size of the iframe the extension is contained within. */
165
+ /** Methods to update the size of the iframe the app is contained within. */
137
166
  window: WindowAPI;
138
167
  };
139
168
  export declare type DialogExtensionSDK = Omit<BaseExtensionSDK, 'ids'> & {
140
- /** A set of IDs actual for the extension */
141
- ids: Omit<IdsAPI, 'field' | 'entry' | 'contentType'>;
142
- /** Closes the dialog and resolves openExtension promise with data */
169
+ /** A set of IDs actual for the app */
170
+ ids: Omit<IdsAPI, EntryScopedIds>;
171
+ /** Closes the dialog and resolves openCurrentApp promise with data */
143
172
  close: (data?: any) => void;
144
- /** Methods to update the size of the iframe the extension is contained within. */
173
+ /** Methods to update the size of the iframe the app is contained within. */
145
174
  window: WindowAPI;
146
175
  };
147
176
  export declare type PageExtensionSDK = Omit<BaseExtensionSDK, 'ids'> & {
148
- /** A set of IDs actual for the extension */
149
- ids: Omit<IdsAPI, 'field' | 'entry' | 'contentType'>;
177
+ /** A set of IDs actual for the app */
178
+ ids: Omit<IdsAPI, EntryScopedIds>;
150
179
  };
151
180
  export declare type AppExtensionSDK = Omit<BaseExtensionSDK, 'ids'> & {
152
181
  /** A set of IDs actual for the app */
153
- ids: Omit<IdsAPI, 'extension' | 'field' | 'entry' | 'contentType' | 'app'> & {
182
+ ids: Omit<IdsAPI, EntryScopedIds | 'extension' | 'app'> & {
154
183
  app: string;
155
184
  };
156
185
  app: AppConfigAPI;
@@ -173,7 +202,7 @@ export interface ConnectMessage {
173
202
  user: UserAPI;
174
203
  initialContentTypes: ContentType[];
175
204
  ids: IdsAPI;
176
- contentType: ContentType;
205
+ contentType: ContentTypeAPI;
177
206
  editorInterface?: EditorInterface;
178
207
  entry: {
179
208
  sys: ContentEntitySys;
@@ -1,4 +1,4 @@
1
- import { ContentType } from './entities';
1
+ import { ContentType, KeyValueMap } from './entities';
2
2
  interface AppStateEditorInterfaceItem {
3
3
  controls?: Array<{
4
4
  fieldId: string;
@@ -20,6 +20,11 @@ interface AppStateEditorInterfaceItem {
20
20
  export interface AppState {
21
21
  EditorInterface: Record<ContentType['sys']['id'], AppStateEditorInterfaceItem>;
22
22
  }
23
+ export declare type OnConfigureHandlerReturn = {
24
+ parameters?: KeyValueMap | null;
25
+ targetState?: AppState | null;
26
+ } | false;
27
+ export declare type OnConfigureHandler = () => OnConfigureHandlerReturn | Promise<OnConfigureHandlerReturn>;
23
28
  export interface AppConfigAPI {
24
29
  /** Tells the web app that the app is loaded */
25
30
  setReady: () => Promise<void>;
@@ -28,10 +33,12 @@ export interface AppConfigAPI {
28
33
  /** Returns current state of an App */
29
34
  getCurrentState: () => Promise<AppState | null>;
30
35
  /** Returns parameters of an App, null otherwise */
31
- getParameters: <T = Object>() => Promise<null | T>;
36
+ getParameters: <T extends KeyValueMap = KeyValueMap>() => Promise<null | T>;
32
37
  /** Registers a handler to be called to produce parameters for an App */
33
- onConfigure: (handler: Function) => void;
38
+ onConfigure: (handler: OnConfigureHandler) => void;
34
39
  /** Registers a handler to be called once configuration was finished */
35
- onConfigurationCompleted: (handler: Function) => void;
40
+ onConfigurationCompleted: (handler: (err: null | {
41
+ message: string;
42
+ }) => void) => void;
36
43
  }
37
44
  export {};
@@ -39,7 +39,7 @@ export interface DialogsAPI {
39
39
  openExtension: (options: OpenCustomWidgetOptions) => Promise<any>;
40
40
  /** Opens the current app in a dialog */
41
41
  openCurrentApp: (options?: Omit<OpenCustomWidgetOptions, 'id'>) => Promise<any>;
42
- /** Opens the current extension or app in a dialog */
42
+ /** Opens the current app or extension in a dialog */
43
43
  openCurrent: (options?: Omit<OpenCustomWidgetOptions, 'id'> | OpenCustomWidgetOptions) => Promise<any>;
44
44
  /** Opens a dialog for selecting a single entry. */
45
45
  selectSingleEntry: <T = Object>(options?: {
@@ -1,4 +1,4 @@
1
- export type { TagProps as Tag, TagVisibility, UserProps as User, AssetProps as Asset, TaskProps as Task, ScheduledActionProps as ScheduledAction, ContentTypeProps as ContentType, EditorInterfaceProps as EditorInterface, SpaceMembershipProps as SpaceMembership, ContentFields as ContentTypeField, EntryProps as Entry, RoleProps as Role, KeyValueMap, } from 'contentful-management/types';
1
+ export type { TagProps as Tag, TeamProps as Team, UserProps as User, AssetProps as Asset, TaskProps as Task, ScheduledActionProps as ScheduledAction, ContentTypeProps as ContentType, EditorInterfaceProps as EditorInterface, SpaceMembershipProps as SpaceMembership, ContentFields as ContentTypeField, ContentTypeFieldValidation, EntryProps as Entry, RoleProps as Role, KeyValueMap, QueryOptions, TagVisibility, MetadataProps as Metadata, UploadProps as Upload, } from 'contentful-management/types';
2
2
  export interface CanonicalRequest {
3
3
  method: 'GET' | 'PUT' | 'POST' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS';
4
4
  path: string;
@@ -1,11 +1,13 @@
1
- import { Task } from './entities';
1
+ import { Metadata, Task } from './entities';
2
2
  import { EntryFieldAPI } from './field.types';
3
- import { CollectionResponse, ContentEntitySys, Metadata } from './utils';
3
+ import { CollectionResponse, ContentEntitySys } from './utils';
4
4
  declare type TaskState = 'active' | 'resolved';
5
5
  export interface TaskInputData {
6
6
  assignedToId: string;
7
+ assignedToType?: 'User' | 'Team';
7
8
  body: string;
8
9
  status: TaskState;
10
+ dueDate?: string;
9
11
  }
10
12
  /** Allows accessing the Task API for the current entry. */
11
13
  export interface TaskAPI {
@@ -19,7 +21,7 @@ export interface EntryAPI extends TaskAPI {
19
21
  /** Returns sys for an entry. */
20
22
  getSys: () => ContentEntitySys;
21
23
  /** Calls the callback with sys every time that sys changes. */
22
- onSysChanged: (callback: (sys: ContentEntitySys) => void) => Function;
24
+ onSysChanged: (callback: (sys: ContentEntitySys) => void) => () => void;
23
25
  /** Allows to control the values of all other fields in the current entry. */
24
26
  fields: {
25
27
  [key: string]: EntryFieldAPI;
@@ -29,5 +31,7 @@ export interface EntryAPI extends TaskAPI {
29
31
  * @deprecated
30
32
  */
31
33
  metadata?: Metadata;
34
+ getMetadata: () => Metadata | undefined;
35
+ onMetadataChanged: (callback: (metadata?: Metadata) => void) => VoidFunction;
32
36
  }
33
37
  export {};
@@ -1,32 +1,37 @@
1
- import type { Items } from './utils';
1
+ import { ContentTypeFieldValidation } from './entities';
2
+ import type { Items, SerializedJSONValue } from './utils';
3
+ import { ValidationError } from './validation-error';
2
4
  export interface FieldAPI {
3
5
  /** The ID of a field is defined in an entry's content type. */
4
6
  id: string;
5
- /** The current locale of a field the extension is attached to. */
7
+ /** The current locale of a field the app is attached to. */
6
8
  locale: string;
7
- /** Holds the type of the field the extension is attached to. */
9
+ /** Holds the type of the field the app is attached to. */
8
10
  type: string;
9
11
  /** Indicates if a value for this field is required */
10
12
  required: boolean;
11
13
  /** A list of validations for this field that are defined in the content type. */
12
- validations: Object[];
14
+ validations: ContentTypeFieldValidation[];
13
15
  /** Defines the shape of array items */
14
16
  items?: Items;
15
17
  /** Gets the current value of the field and locale. */
16
18
  getValue: () => any;
17
19
  /** Sets the value for the field and locale. */
18
- setValue: (value: any) => Promise<any>;
20
+ setValue: <Value = any>(value: Value) => Promise<SerializedJSONValue | undefined>;
19
21
  /** Removes the value for the field and locale. */
20
22
  removeValue: () => Promise<void>;
21
23
  /** Communicates to the web application if the field is in a valid state or not. */
22
24
  setInvalid: (value: boolean) => void;
23
25
  /** Calls the callback every time the value of the field is changed by an external event or when setValue() is called.
24
- * the returned function can be called to remove the handler function */
26
+ * the returned function can be called to remove the handler function
27
+ **/
25
28
  onValueChanged: (callback: (value: any) => void) => () => void;
26
29
  /** Calls the callback when the disabled status of the field changes.
27
- * the returned function can be called to remove the handler function */
30
+ * the returned function can be called to remove the handler function
31
+ **/
28
32
  onIsDisabledChanged: (callback: (isDisabled: boolean) => void) => () => void;
29
33
  /** Calls the callback immediately with the current validation errors and whenever the field is re-validated.
30
- * the returned function can be called to remove the handler function */
31
- onSchemaErrorsChanged: (callback: (errors: Error[]) => void) => () => void;
34
+ * the returned function can be called to remove the handler function
35
+ **/
36
+ onSchemaErrorsChanged: (callback: (errors: ValidationError[]) => void) => () => void;
32
37
  }
@@ -1,11 +1,12 @@
1
- import { Items } from './utils';
1
+ import { Items, SerializedJSONValue } from './utils';
2
2
  import { FieldAPI } from './field-locale.types';
3
+ import { ContentTypeFieldValidation } from './entities';
3
4
  export interface FieldInfo {
4
5
  id: string;
5
6
  locale: string;
6
7
  type: string;
7
8
  required: boolean;
8
- validations: Object[];
9
+ validations: ContentTypeFieldValidation[];
9
10
  items?: Items;
10
11
  value: any;
11
12
  }
@@ -14,7 +15,7 @@ export interface EntryFieldInfo {
14
15
  locales: string[];
15
16
  type: string;
16
17
  required: boolean;
17
- validations: Object[];
18
+ validations: ContentTypeFieldValidation[];
18
19
  items?: Items;
19
20
  values: {
20
21
  [locale: string]: any;
@@ -30,29 +31,31 @@ export interface EntryFieldAPI {
30
31
  /** Indicates if a value for this field is required */
31
32
  required: boolean;
32
33
  /** A list of validations for this field that are defined in the content type. */
33
- validations: Object[];
34
+ validations: ContentTypeFieldValidation[];
34
35
  /** Defines the shape of array items */
35
36
  items?: Items;
36
37
  /** Gets the current value of the field and locale. */
37
38
  getValue: (locale?: string) => any;
38
39
  /** Sets the value for the field and locale. */
39
- setValue: (value: any, locale?: string) => Promise<any>;
40
+ setValue: <Value = any>(value: Value, locale?: string) => Promise<SerializedJSONValue | undefined>;
40
41
  /** Removes the value for the field and locale. */
41
42
  removeValue: (locale?: string) => Promise<void>;
42
43
  /** Calls the callback every time the value of the field is changed by an external event or when setValue() is called.
43
- * the returned function can be called to remove the handler function */
44
+ * the returned function can be called to remove the handler function
45
+ **/
44
46
  onValueChanged: {
45
47
  (callback: (value: any) => void): () => void;
46
48
  (locale: string, callback: (value: any) => void): () => void;
47
49
  };
48
50
  /** Calls the callback when the disabled status of the field changes.
49
- * the returned function can be called to remove the handler function */
51
+ * the returned function can be called to remove the handler function
52
+ **/
50
53
  onIsDisabledChanged: {
51
54
  (callback: (isDisabled: boolean) => void): () => void;
52
55
  (locale: string, callback: (isDisabled: boolean) => void): () => void;
53
- (...args: any[]): () => void;
54
56
  };
55
57
  /** Get an instance of FieldAPI for this field, specific to the locale that is
56
- * passed as an argument */
58
+ * passed as an argument
59
+ **/
57
60
  getForLocale: (locale: string) => FieldAPI;
58
61
  }
@@ -1,11 +1,11 @@
1
- export type { AccessAPI, AppExtensionSDK, BaseExtensionSDK, ConnectMessage, DialogExtensionSDK, EditorExtensionSDK, EditorLocaleSettings, FieldExtensionSDK, IdsAPI, KnownSDK, LocalesAPI, LocationAPI, Locations, NotifierAPI, PageExtensionSDK, ParametersAPI, SharedEditorSDK, SidebarExtensionSDK, UserAPI, } from './api.types';
2
- export type { AppConfigAPI, AppState } from './app.types';
1
+ export type { AccessAPI, AppExtensionSDK, BaseExtensionSDK, ConnectMessage, ContentTypeAPI, DialogExtensionSDK, EditorExtensionSDK, EditorLocaleSettings, FieldExtensionSDK, IdsAPI, KnownSDK, LocalesAPI, LocationAPI, Locations, NotifierAPI, PageExtensionSDK, ParametersAPI, SharedEditorSDK, SidebarExtensionSDK, UserAPI, JSONPatchItem, } from './api.types';
2
+ export type { AppConfigAPI, AppState, OnConfigureHandler, OnConfigureHandlerReturn, } from './app.types';
3
3
  export type { DialogsAPI, EntityDialogOptions, OpenAlertOptions, OpenConfirmOptions, OpenCustomWidgetOptions, } from './dialogs.types';
4
- export type { User, Asset, ContentType, CanonicalRequest, EditorInterface, ContentTypeField, ScheduledAction, SpaceMembership, Tag, TagVisibility, Task, Entry, Role, } from './entities';
4
+ export type { User, Asset, ContentType, CanonicalRequest, EditorInterface, ContentTypeField, ScheduledAction, SpaceMembership, Tag, TagVisibility, Task, Entry, Role, Metadata, } from './entities';
5
5
  export type { EntryAPI, TaskAPI, TaskInputData } from './entry.types';
6
6
  export type { FieldInfo, EntryFieldInfo, EntryFieldAPI } from './field.types';
7
7
  export type { FieldAPI } from './field-locale.types';
8
8
  export type { NavigatorAPI, AppPageLocationOptions, NavigatorAPIOptions, NavigatorOpenResponse, NavigatorPageResponse, NavigatorSlideInfo, PageExtensionOptions, } from './navigator.types';
9
9
  export type { SpaceAPI } from './space.types';
10
- export type { SearchQuery, Metadata, CollectionResponse, ContentEntitySys, ContentEntityType, Items, Link, WithOptionalId, WithId, } from './utils';
10
+ export type { SearchQuery, CollectionResponse, ContentEntitySys, ContentEntityType, Items, Link, WithOptionalId, WithId, SerializedJSONValue, } from './utils';
11
11
  export type { WindowAPI } from './window.types';
@@ -1,5 +1,5 @@
1
- import { Asset, CanonicalRequest, ContentType, EditorInterface, ScheduledAction, Tag, User, TagVisibility, KeyValueMap, Entry } from './entities';
2
- import { CollectionResponse, ContentEntityType, Link, WithOptionalId, SearchQuery, WithId } from './utils';
1
+ import { Asset, CanonicalRequest, ContentType, EditorInterface, ScheduledAction, Tag, Team, User, TagVisibility, KeyValueMap, Entry, QueryOptions, Upload } from './entities';
2
+ import { CollectionResponse, ContentEntityType, Link, WithOptionalId, SearchQuery } from './utils';
3
3
  declare type Snapshot<T> = {
4
4
  sys: {
5
5
  space?: Link;
@@ -17,48 +17,256 @@ declare type Snapshot<T> = {
17
17
  snapshot: T;
18
18
  };
19
19
  export interface SpaceAPI {
20
+ /**
21
+ * @deprecated since version 4.0.0
22
+ * Please using `cma.contentType.getMany` instead
23
+ * See https://www.contentful.com/developers/docs/extensibility/app-framework/sdk/#using-the-contentful-management-library for more details
24
+ */
20
25
  getCachedContentTypes: () => ContentType[];
26
+ /**
27
+ * @deprecated since version 4.0.0
28
+ * Consider using `cma.contentType.get` instead
29
+ * See https://www.contentful.com/developers/docs/extensibility/app-framework/sdk/#using-the-contentful-management-library for more details
30
+ */
21
31
  getContentType: (id: string) => Promise<ContentType>;
22
- getContentTypes: () => Promise<CollectionResponse<ContentType>>;
23
- createContentType: (data: WithId<ContentType>) => Promise<ContentType>;
32
+ /**
33
+ * @deprecated since version 4.0.0
34
+ * Consider using `cma.contentType.getMany` instead
35
+ * See https://www.contentful.com/developers/docs/extensibility/app-framework/sdk/#using-the-contentful-management-library for more details
36
+ */
37
+ getContentTypes: <Query extends SearchQuery = SearchQuery>(query?: Query) => Promise<CollectionResponse<ContentType>>;
38
+ /**
39
+ * @deprecated since version 4.0.0
40
+ * Consider using `cma.contentType.create` or `cma.contentType.createWithId` instead
41
+ * See https://www.contentful.com/developers/docs/extensibility/app-framework/sdk/#using-the-contentful-management-library for more details
42
+ */
43
+ createContentType: (data: WithOptionalId<ContentType>) => Promise<ContentType>;
44
+ /**
45
+ * @deprecated since version 4.0.0
46
+ * Consider using `cma.contentType.update` instead
47
+ * See https://www.contentful.com/developers/docs/extensibility/app-framework/sdk/#using-the-contentful-management-library for more details
48
+ */
24
49
  updateContentType: (data: ContentType) => Promise<ContentType>;
25
- deleteContentType: (data: ContentType) => Promise<void>;
50
+ /**
51
+ * @deprecated since version 4.0.0
52
+ * Consider using `cma.contentType.delete` instead
53
+ * See https://www.contentful.com/developers/docs/extensibility/app-framework/sdk/#using-the-contentful-management-library for more details
54
+ */
55
+ deleteContentType: (contentTypeId: string) => Promise<void>;
56
+ /**
57
+ * @deprecated since version 4.0.0
58
+ * Consider using `cma.entry.get` instead
59
+ * See https://www.contentful.com/developers/docs/extensibility/app-framework/sdk/#using-the-contentful-management-library for more details
60
+ */
26
61
  getEntry: <Fields extends KeyValueMap = KeyValueMap>(id: string) => Promise<Entry<Fields>>;
62
+ /**
63
+ * @deprecated since version 4.0.0
64
+ * Consider using `cma.snapshot.getForEntry` instead
65
+ * See https://www.contentful.com/developers/docs/extensibility/app-framework/sdk/#using-the-contentful-management-library for more details
66
+ */
27
67
  getEntrySnapshots: <Fields extends KeyValueMap = KeyValueMap>(id: string) => Promise<CollectionResponse<Snapshot<Entry<Fields>>>>;
68
+ /**
69
+ * @deprecated since version 4.0.0
70
+ * Consider using `cma.entry.getMany` instead
71
+ * See https://www.contentful.com/developers/docs/extensibility/app-framework/sdk/#using-the-contentful-management-library for more details
72
+ */
28
73
  getEntries: <Fields, Query extends SearchQuery = SearchQuery>(query?: Query) => Promise<CollectionResponse<Entry<Fields>>>;
74
+ /**
75
+ * @deprecated since version 4.0.0
76
+ * Consider using `cma.entry.create` or `cma.entry.createWithId` instead
77
+ * See https://www.contentful.com/developers/docs/extensibility/app-framework/sdk/#using-the-contentful-management-library for more details
78
+ */
29
79
  createEntry: <Fields>(contentTypeId: string, data: WithOptionalId<Entry<Fields>>) => Promise<Entry<Fields>>;
80
+ /**
81
+ * @deprecated since version 4.0.0
82
+ * Consider using `cma.entry.update` instead
83
+ * See https://www.contentful.com/developers/docs/extensibility/app-framework/sdk/#using-the-contentful-management-library for more details
84
+ */
30
85
  updateEntry: <Fields extends KeyValueMap = KeyValueMap>(data: Entry<Fields>) => Promise<Entry<Fields>>;
86
+ /**
87
+ * @deprecated since version 4.0.0
88
+ * Consider using `cma.entry.publish` instead
89
+ * See https://www.contentful.com/developers/docs/extensibility/app-framework/sdk/#using-the-contentful-management-library for more details
90
+ */
31
91
  publishEntry: <Fields extends KeyValueMap = KeyValueMap>(data: Entry<Fields>) => Promise<Entry<Fields>>;
92
+ /**
93
+ * @deprecated since version 4.0.0
94
+ * Consider using `cma.entry.unpublish` instead
95
+ * See https://www.contentful.com/developers/docs/extensibility/app-framework/sdk/#using-the-contentful-management-library for more details
96
+ */
32
97
  unpublishEntry: <Fields extends KeyValueMap = KeyValueMap>(data: Entry<Fields>) => Promise<Entry<Fields>>;
98
+ /**
99
+ * @deprecated since version 4.0.0
100
+ * Consider using `cma.entry.archive` instead
101
+ * See https://www.contentful.com/developers/docs/extensibility/app-framework/sdk/#using-the-contentful-management-library for more details
102
+ */
33
103
  archiveEntry: <Fields extends KeyValueMap = KeyValueMap>(data: Entry<Fields>) => Promise<Entry<Fields>>;
104
+ /**
105
+ * @deprecated since version 4.0.0
106
+ * Consider using `cma.entry.unarchive` instead
107
+ * See https://www.contentful.com/developers/docs/extensibility/app-framework/sdk/#using-the-contentful-management-library for more details
108
+ */
34
109
  unarchiveEntry: <Fields extends KeyValueMap = KeyValueMap>(data: Entry<Fields>) => Promise<Entry<Fields>>;
110
+ /**
111
+ * @deprecated since version 4.0.0
112
+ * Consider using `cma.entry.delete` instead
113
+ * See https://www.contentful.com/developers/docs/extensibility/app-framework/sdk/#using-the-contentful-management-library for more details
114
+ */
35
115
  deleteEntry: <Fields extends KeyValueMap = KeyValueMap>(data: Entry<Fields>) => Promise<void>;
116
+ /**
117
+ * @deprecated since version 4.0.0
118
+ * Consider using `cma.entry.getMany` instead
119
+ * See https://www.contentful.com/developers/docs/extensibility/app-framework/sdk/#using-the-contentful-management-library for more details
120
+ */
36
121
  getPublishedEntries: <Fields, Query extends SearchQuery = SearchQuery>(query?: Query) => Promise<CollectionResponse<Entry<Fields>>>;
122
+ /**
123
+ * @deprecated since version 4.0.0
124
+ * Consider using `cma.asset.get` instead
125
+ * See https://www.contentful.com/developers/docs/extensibility/app-framework/sdk/#using-the-contentful-management-library for more details
126
+ */
37
127
  getAsset: (id: string) => Promise<Asset>;
128
+ /**
129
+ * @deprecated since version 4.0.0
130
+ * Consider using `cma.asset.getMany` instead
131
+ * See https://www.contentful.com/developers/docs/extensibility/app-framework/sdk/#using-the-contentful-management-library for more details
132
+ */
38
133
  getAssets: <Query extends SearchQuery = SearchQuery>(query?: Query) => Promise<CollectionResponse<Asset>>;
134
+ /**
135
+ * @deprecated since version 4.0.0
136
+ * Consider using `cma.asset.create` instead
137
+ * See https://www.contentful.com/developers/docs/extensibility/app-framework/sdk/#using-the-contentful-management-library for more details
138
+ */
39
139
  createAsset: (data: WithOptionalId<Asset>) => Promise<Asset>;
140
+ /**
141
+ * @deprecated since version 4.0.0
142
+ * Consider using `cma.asset.update` instead
143
+ * See https://www.contentful.com/developers/docs/extensibility/app-framework/sdk/#using-the-contentful-management-library for more details
144
+ */
40
145
  updateAsset: (data: Asset) => Promise<Asset>;
146
+ /**
147
+ * @deprecated since version 4.0.0
148
+ * Consider using `cma.asset.delete` instead
149
+ * See https://www.contentful.com/developers/docs/extensibility/app-framework/sdk/#using-the-contentful-management-library for more details
150
+ */
41
151
  deleteAsset: (data: Asset) => Promise<void>;
152
+ /**
153
+ * @deprecated since version 4.0.0
154
+ * Consider using `cma.asset.publish` instead
155
+ * See https://www.contentful.com/developers/docs/extensibility/app-framework/sdk/#using-the-contentful-management-library for more details
156
+ */
42
157
  publishAsset: (data: Asset) => Promise<Asset>;
158
+ /**
159
+ * @deprecated since version 4.0.0
160
+ * Consider using `cma.asset.unpublish` instead
161
+ * See https://www.contentful.com/developers/docs/extensibility/app-framework/sdk/#using-the-contentful-management-library for more details
162
+ */
43
163
  unpublishAsset: (data: Asset) => Promise<Asset>;
164
+ /**
165
+ * @deprecated since version 4.0.0
166
+ * Consider using `cma.asset.archive` instead
167
+ * See https://www.contentful.com/developers/docs/extensibility/app-framework/sdk/#using-the-contentful-management-library for more details
168
+ */
44
169
  archiveAsset: (data: Asset) => Promise<Asset>;
170
+ /**
171
+ * @deprecated since version 4.0.0
172
+ * Consider using `cma.asset.processForLocale` instead
173
+ * See https://www.contentful.com/developers/docs/extensibility/app-framework/sdk/#using-the-contentful-management-library for more details
174
+ */
45
175
  processAsset: (data: Asset, locale: string) => Promise<Asset>;
176
+ /**
177
+ * @deprecated since version 4.0.0
178
+ * Consider using `cma.asset.unarchive` instead
179
+ * See https://www.contentful.com/developers/docs/extensibility/app-framework/sdk/#using-the-contentful-management-library for more details
180
+ */
46
181
  unarchiveAsset: (data: Asset) => Promise<Asset>;
182
+ /**
183
+ * @deprecated since version 4.0.0
184
+ * Consider using `cma.asset.getMany` instead
185
+ * See https://www.contentful.com/developers/docs/extensibility/app-framework/sdk/#using-the-contentful-management-library for more details
186
+ */
47
187
  getPublishedAssets: <Query extends SearchQuery = SearchQuery>(query?: Query) => Promise<CollectionResponse<Asset>>;
48
- createUpload: (base64data: string) => Promise<void>;
49
- waitUntilAssetProcessed: (assetId: string, locale: string) => Promise<void>;
50
- /** Returns all users who belong to the space. */
188
+ /**
189
+ * @deprecated since version 4.0.0
190
+ * Consider using `cma.upload.create` instead
191
+ * See https://www.contentful.com/developers/docs/extensibility/app-framework/sdk/#using-the-contentful-management-library for more details
192
+ */
193
+ createUpload: (base64data: string) => Promise<Upload>;
194
+ /**
195
+ * @deprecated since version 4.0.0
196
+ * Consider polling `cma.asset.get` instead
197
+ * See https://www.contentful.com/developers/docs/extensibility/app-framework/sdk/#using-the-contentful-management-library for more details
198
+ */
199
+ waitUntilAssetProcessed: (assetId: string, locale: string) => Promise<Asset>;
200
+ /**
201
+ * @deprecated since version 4.0.0
202
+ * Consider using `cma.user.getManyForSpace` instead
203
+ * See https://www.contentful.com/developers/docs/extensibility/app-framework/sdk/#using-the-contentful-management-library for more details
204
+ * Returns all users who belong to the space.
205
+ */
51
206
  getUsers: () => Promise<CollectionResponse<User>>;
52
- /** Returns editor interface for a given content type */
207
+ /**
208
+ * @deprecated since version 4.0.0
209
+ * Consider using `cma.editorInterface.get` instead
210
+ * See https://www.contentful.com/developers/docs/extensibility/app-framework/sdk/#using-the-contentful-management-library for more details
211
+ * Returns editor interface for a given content type
212
+ */
53
213
  getEditorInterface: (contentTypeId: string) => Promise<EditorInterface>;
54
- /** Returns editor interfaces for a given environment */
214
+ /**
215
+ * @deprecated since version 4.0.0
216
+ * Consider using `cma.editorInterface.getMany` instead
217
+ * See https://www.contentful.com/developers/docs/extensibility/app-framework/sdk/#using-the-contentful-management-library for more details
218
+ * Returns editor interfaces for a given environment
219
+ */
55
220
  getEditorInterfaces: () => Promise<CollectionResponse<EditorInterface>>;
221
+ /**
222
+ * @deprecated since version 4.0.0
223
+ * Consider using `cma.scheduledActions.getMany` instead
224
+ * See https://www.contentful.com/developers/docs/extensibility/app-framework/sdk/#using-the-contentful-management-library for more details
225
+ * Returns a list of scheduled actions for a given entity
226
+ */
56
227
  getEntityScheduledActions: (entityType: ContentEntityType, entityId: string) => Promise<ScheduledAction[]>;
228
+ /**
229
+ * @deprecated since version 4.0.0
230
+ * Consider using `cma.scheduledActions.getMany` instead
231
+ * See https://www.contentful.com/developers/docs/extensibility/app-framework/sdk/#using-the-contentful-management-library for more details
232
+ * Returns a list of scheduled actions for the currenst space & environment
233
+ */
57
234
  getAllScheduledActions: () => Promise<ScheduledAction[]>;
235
+ /**
236
+ * @deprecated since version 4.0.0
237
+ * Consider using `cma.appSignedRequest.create` instead
238
+ * See https://www.contentful.com/developers/docs/extensibility/app-framework/sdk/#using-the-contentful-management-library for more details
239
+ */
58
240
  signRequest: (request: CanonicalRequest) => Promise<Record<string, string>>;
241
+ /**
242
+ * @deprecated since version 4.0.0
243
+ * Consider using `cma.tag.create` instead
244
+ * See https://www.contentful.com/developers/docs/extensibility/app-framework/sdk/#using-the-contentful-management-library for more details
245
+ */
59
246
  createTag: (id: string, name: string, visibility?: TagVisibility) => Promise<Tag>;
247
+ /**
248
+ * @deprecated since version 4.0.0
249
+ * Consider using `cma.tag.getMany` instead
250
+ * See https://www.contentful.com/developers/docs/extensibility/app-framework/sdk/#using-the-contentful-management-library for more details
251
+ */
60
252
  readTags: (skip: number, limit: number) => Promise<CollectionResponse<Tag>>;
253
+ /**
254
+ * @deprecated since version 4.0.0
255
+ * Consider using `cma.tag.update` instead
256
+ * See https://www.contentful.com/developers/docs/extensibility/app-framework/sdk/#using-the-contentful-management-library for more details
257
+ */
61
258
  updateTag: (id: string, name: string, version: number) => Promise<Tag>;
259
+ /**
260
+ * @deprecated since version 4.0.0
261
+ * Consider using `cma.tag.delete` instead
262
+ * See https://www.contentful.com/developers/docs/extensibility/app-framework/sdk/#using-the-contentful-management-library for more details
263
+ */
62
264
  deleteTag: (id: string, version: number) => Promise<boolean>;
265
+ /**
266
+ * @deprecated since version 4.0.0
267
+ * Consider using `cma.team.get` instead
268
+ * See https://www.contentful.com/developers/docs/extensibility/app-framework/sdk/#using-the-contentful-management-library for more details
269
+ */
270
+ getTeams: (query: QueryOptions) => Promise<CollectionResponse<Team>>;
63
271
  }
64
272
  export {};
@@ -1,3 +1,4 @@
1
+ import { ContentTypeFieldValidation } from './entities';
1
2
  declare type Sys = {
2
3
  id: string;
3
4
  type: string;
@@ -52,13 +53,10 @@ export interface ContentEntitySys {
52
53
  publishedBy?: Link;
53
54
  contentType: Link;
54
55
  }
55
- export declare type Metadata = {
56
- tags: Link<'Tag', 'Link'>[];
57
- };
58
56
  export interface Items {
59
57
  type: string;
60
58
  linkType?: string;
61
- validations?: Object[];
59
+ validations?: ContentTypeFieldValidation[];
62
60
  }
63
61
  export interface SearchQuery {
64
62
  order?: string;
@@ -66,4 +64,7 @@ export interface SearchQuery {
66
64
  limit?: number;
67
65
  [key: string]: any;
68
66
  }
67
+ export declare type SerializedJSONValue = null | string | number | boolean | Array<SerializedJSONValue> | {
68
+ [key: string]: SerializedJSONValue;
69
+ };
69
70
  export {};
@@ -0,0 +1,62 @@
1
+ export interface BaseValidationError {
2
+ name: string;
3
+ message?: string;
4
+ details?: string;
5
+ value?: any;
6
+ customMessage?: string;
7
+ path: string[];
8
+ }
9
+ export interface SizeValidationError extends BaseValidationError {
10
+ name: 'size';
11
+ max: number;
12
+ min: number;
13
+ }
14
+ export interface RangeValidationError extends BaseValidationError {
15
+ name: 'range';
16
+ min?: number;
17
+ max?: number;
18
+ }
19
+ export interface InValidationError extends BaseValidationError {
20
+ name: 'in';
21
+ expected: string[];
22
+ }
23
+ export interface RequiredValidationError extends BaseValidationError {
24
+ name: 'required';
25
+ }
26
+ export interface UniqueValidationError extends BaseValidationError {
27
+ name: 'unique';
28
+ conflicting: string[];
29
+ }
30
+ export interface ProhibitRegexpValidationError extends BaseValidationError {
31
+ name: 'prohibitRegexp';
32
+ }
33
+ export interface RegexpValidationError extends BaseValidationError {
34
+ name: 'regexp';
35
+ }
36
+ export interface LinkMimetypeGroupValidationError extends BaseValidationError {
37
+ name: 'linkMimetypeGroup';
38
+ mimetypeGroupName: string[];
39
+ }
40
+ export interface LinkContentTypeValidationError extends BaseValidationError {
41
+ name: 'linkContentType';
42
+ contentTypeId: string;
43
+ }
44
+ export interface DateRangeValidationError extends BaseValidationError {
45
+ name: 'dateRange';
46
+ min: number;
47
+ max: number;
48
+ }
49
+ export interface NotResolvableValidationError extends BaseValidationError {
50
+ name: 'notResolvable';
51
+ link: {
52
+ linkType: string;
53
+ };
54
+ }
55
+ export interface UnknownValidationError extends BaseValidationError {
56
+ name: 'unknown';
57
+ }
58
+ export interface TypeValidationError extends BaseValidationError {
59
+ name: 'type';
60
+ type: string;
61
+ }
62
+ export declare type ValidationError = SizeValidationError | RangeValidationError | InValidationError | RequiredValidationError | UniqueValidationError | RegexpValidationError | ProhibitRegexpValidationError | LinkMimetypeGroupValidationError | LinkContentTypeValidationError | DateRangeValidationError | NotResolvableValidationError | UnknownValidationError | TypeValidationError | BaseValidationError;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@contentful/app-sdk",
3
3
  "description": "SDK to develop custom UI Extension for the Contentful Web App",
4
- "version": "4.0.0-alpha.7",
4
+ "version": "4.0.1",
5
5
  "author": "Contentful GmbH",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -21,7 +21,7 @@
21
21
  "test": "ts-mocha -p tsconfig.test.json 'test/unit/*.[jt]s' --reporter mocha-multi-reporters --reporter-options configFile=mocha.unit-reporters.json",
22
22
  "lint": "eslint '{lib,test}/**/*.{t,j}s'",
23
23
  "lint:fix": "npm run lint -- --fix",
24
- "build": "rollup -c --compact",
24
+ "build": "npm run check-types && rollup -c --compact",
25
25
  "build:debug": "npm run build -- --sourcemap",
26
26
  "prepublishOnly": "npm run build",
27
27
  "size": "echo \"Gzipped, estimate: $(gzip -9 -c dist/cf-extension-api.js | wc -c) bytes\"",
@@ -34,63 +34,67 @@
34
34
  "generate-report": "npx mochawesome-report-generator --reportDir test/cypress/reports test/cypress/reports/full_report.json",
35
35
  "semantic-release": "semantic-release",
36
36
  "publish-all": "node ./scripts/publish.js",
37
- "verify": "node ./scripts/verify.js"
37
+ "verify": "node ./scripts/verify.js",
38
+ "check-types": "tsc --noEmit -m commonjs"
38
39
  },
39
40
  "devDependencies": {
40
41
  "@semantic-release/changelog": "5.0.1",
41
42
  "@semantic-release/exec": "5.0.0",
42
- "@semantic-release/git": "9.0.0",
43
- "@testing-library/cypress": "7.0.6",
44
- "@testing-library/dom": "7.31.0",
45
- "@types/async-retry": "1.4.2",
43
+ "@semantic-release/git": "9.0.1",
44
+ "@testing-library/cypress": "8.0.1",
45
+ "@testing-library/dom": "8.7.2",
46
+ "@types/async-retry": "1.4.3",
46
47
  "@types/chai-as-promised": "7.1.4",
47
48
  "@types/cross-spawn": "6.0.2",
48
- "@types/fs-extra": "9.0.11",
49
- "@types/jsdom": "16.2.10",
50
- "@types/nanoid": "2.1.0",
49
+ "@types/fs-extra": "9.0.13",
50
+ "@types/jsdom": "16.2.13",
51
+ "@types/nanoid": "3.0.0",
51
52
  "@types/sinon": "^10.0.0",
52
53
  "@types/sinon-chai": "^3.2.5",
53
- "@typescript-eslint/eslint-plugin": "4.24.0",
54
- "@typescript-eslint/parser": "4.24.0",
55
- "async-retry": "1.3.1",
54
+ "@typescript-eslint/eslint-plugin": "4.32.0",
55
+ "@typescript-eslint/parser": "4.32.0",
56
+ "async-retry": "1.3.3",
56
57
  "babel-eslint": "10.1.0",
57
58
  "chai": "4.3.4",
58
59
  "chai-as-promised": "7.1.1",
60
+ "contentful-management": "7.41.1",
59
61
  "cross-spawn": "7.0.3",
60
- "cypress": "7.3.0",
62
+ "cypress": "8.5.0",
61
63
  "cypress-multi-reporters": "1.5.0",
62
- "dotenv": "9.0.2",
63
- "eslint": "7.26.0",
64
+ "cypress-terminal-report": "^3.3.2",
65
+ "dotenv": "10.0.0",
66
+ "eslint": "7.32.0",
64
67
  "eslint-config-prettier": "8.3.0",
65
- "eslint-config-standard": "16.0.2",
66
- "eslint-plugin-cypress": "2.11.3",
67
- "eslint-plugin-import": "2.23.2",
68
+ "eslint-config-standard": "16.0.3",
69
+ "eslint-plugin-cypress": "2.12.1",
70
+ "eslint-plugin-import": "2.24.2",
68
71
  "eslint-plugin-node": "11.1.0",
69
- "eslint-plugin-prettier": "3.4.0",
70
- "eslint-plugin-promise": "4.3.1",
71
- "eslint-plugin-react": "7.23.2",
72
+ "eslint-plugin-prettier": "4.0.0",
73
+ "eslint-plugin-promise": "5.1.0",
74
+ "eslint-plugin-react": "7.26.1",
72
75
  "eslint-plugin-standard": "5.0.0",
73
76
  "fs-extra": "10.0.0",
74
77
  "husky": "4.3.8",
75
- "jsdom": "16.5.3",
76
- "lint-staged": "11.0.0",
78
+ "jsdom": "17.0.0",
79
+ "lint-staged": "11.2.0",
77
80
  "mocha": "8.4.0",
78
81
  "mocha-junit-reporter": "2.0.0",
79
82
  "mocha-multi-reporters": "1.5.1",
80
- "mochawesome": "6.2.2",
83
+ "mochawesome": "6.3.0",
81
84
  "mochawesome-merge": "4.2.0",
82
85
  "mochawesome-report-generator": "5.2.0",
83
- "nanoid": "3.1.23",
84
- "prettier": "2.2.1",
85
- "rollup": "2.48.0",
86
+ "nanoid": "3.1.28",
87
+ "prettier": "2.4.1",
88
+ "rollup": "2.58.0",
86
89
  "rollup-plugin-terser": "7.0.2",
87
90
  "rollup-plugin-typescript2": "0.30.0",
88
91
  "semantic-release": "17.4.2",
89
- "sinon": "10.0.1",
90
- "sinon-chai": "3.6.0",
92
+ "sinon": "11.1.2",
93
+ "sinon-chai": "3.7.0",
91
94
  "ts-mocha": "8.0.0",
92
- "ts-node": "9.1.1",
93
- "typescript": "4.1.5"
95
+ "ts-node": "10.2.1",
96
+ "tslib": "2.3.1",
97
+ "typescript": "4.4.3"
94
98
  },
95
99
  "husky": {
96
100
  "hooks": {
@@ -148,7 +152,7 @@
148
152
  "@semantic-release/github"
149
153
  ]
150
154
  },
151
- "dependencies": {
152
- "contentful-management": "^7.22.0"
155
+ "peerDependencies": {
156
+ "contentful-management": "^7.30.0"
153
157
  }
154
158
  }