contentful-ui-extensions-sdk 4.13.0 → 4.14.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/dist/cf-extension-api.js +1 -1
- package/dist/channel.d.ts +1 -1
- package/dist/field-locale.d.ts +2 -1
- package/dist/index.d.ts +1 -1
- package/dist/signal.d.ts +10 -10
- package/dist/types/api.types.d.ts +16 -16
- package/dist/types/app.types.d.ts +2 -2
- package/dist/types/cmaClient.types.d.ts +31 -0
- package/dist/types/dialogs.types.d.ts +1 -1
- package/dist/types/entry.types.d.ts +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/navigator.types.d.ts +1 -1
- package/dist/types/space.types.d.ts +1 -1
- package/dist/types/utils.d.ts +8 -8
- package/dist/types/validation-error.d.ts +1 -1
- package/package.json +1 -1
package/dist/cf-extension-api.js
CHANGED
|
@@ -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])},t(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},r.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,l=function(){function e(e,t){var n=this;this._messageHandlers={},this._responseHandlers={},this._send=function(e,t){return function(n,r){var o=u.getMessageId();try{t.postMessage({source:e,id:o,method:n,params:r},"*")}catch(e){throw e instanceof DOMException&&"DataCloneError"===e.name&&"openDialog"===n&&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 o}}(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}(),u=(s=0,{getMessageId:function(){return s++}});var c=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}(),d=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 c(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 "'.concat(e,'" for field "').concat(this.id,'"'))},e}();function p(e,t){var n,r=e.document,o=e.MutationObserver,i=e.ResizeObserver,a=!1,s=!1,l=new Set,u=new o((function(e){!function(e){e.forEach((function(e){switch(e.type){case"attributes":if(e.target.nodeType===Node.ELEMENT_NODE){var t=e.target;p(e.type,t)?l.add(t):l.delete(t)}break;case"childList":e.addedNodes.forEach((function(t){if(t.nodeType===Node.ELEMENT_NODE){var n=t;p(e.type,n)&&l.add(n)}})),e.removedNodes.forEach((function(e){var t=e;l.delete(t)}))}}))}(e),a&&d.updateHeight()})),c=new i((function(){d.updateHeight()}));u.observe(r.body,{attributes:!0,childList:!0,subtree:!0,characterData:!0});var d={startAutoResizer:function(e){var t=(void 0===e?{}:e).absoluteElements;if(s=Boolean(t===void 0?false:t),d.updateHeight(),a)return;a=!0,c.observe(r.body)},stopAutoResizer:function(){if(!a)return;a=!1,c.disconnect()},updateHeight:function(e){void 0===e&&(e=null);if(null===e){var o=Math.ceil(r.documentElement.getBoundingClientRect().height);if(s&&l.size){var i=o;l.forEach((function(e){i=Math.max(e.getBoundingClientRect().bottom,i)})),e=i}else e=o}e!==n&&(t.send("setHeight",e),n=e)}};return d;function p(e,t){var n=getComputedStyle(t);return"absolute"===n.position&&("attributes"!==e||"none"!==n.display)}}var f=["getTask","getTasks","createTask","updateTask","deleteTask"];function h(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 f.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},publish:function(t){return e.call("callEntryMethod","publish",[t])},unpublish:function(){return e.call("callEntryMethod","unpublish")},save:function(){return e.call("callEntryMethod","save")},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 g=["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 v(e,t){var n={};return g.forEach((function(t){n[t]=function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return console.warn("You called ".concat(String(t)," on the Space API. Since version 4.0.0 the Space API and its methods are deprecated, and they will be removed from version 5.0.0 on. 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,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}([],t,!0)},n}var y=function(e){return"object"!=typeof(t=e)||null===t||Array.isArray(t)?{}:e;var t};function m(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,y(n))}function o(n){var o=y(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=y(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=y(r)).entityType=t,r.multiple=n,e.call("openDialog","entitySelector",r)}}function E(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 A="preInstall",C="postInstall",T=function(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)},b=function(e){return"function"==typeof e},w=function(e){return console.error(e),Promise.resolve(!1)},I=function(e,t,n){if(!b(e))return Promise.resolve(t);var r;try{r=void 0===n?e():e(n)}catch(e){return w(e)}var o,i=r;return T(o=i)&&b(o.then)||(i=Promise.resolve(i)),i.then((function(e){return e instanceof Error?Promise.reject(e):!1!==e&&(T(e)?e:t)}),w).catch(w)};function L(e){var t,n=((t={}).preInstall=null,t.postInstall=null,t),r=function(e,t){if(!b(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===A?I(n[r],{}).then((function(t){return e.send("appHookResult",{stage:r,installationRequestId:o,result:t})})):r===C?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(A,e)},onConfigurationCompleted:function(e){r(C,e)}}}var O,S={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",LOCATION_HOME:"home"},N=function(e){return function(t){return e.call("CMAAdapterCall",t)}};function D(e){return{makeRequest:N(e)}}var H=[R,k,function(e,t){var n=t.field;if(!n)throw new Error('FieldAPI called for location without "field" property defined.');return{field:new c(e,n)}},F,P],M=((O={})[S.LOCATION_ENTRY_FIELD]=H,O[S.LOCATION_ENTRY_FIELD_SIDEBAR]=H,O[S.LOCATION_ENTRY_SIDEBAR]=[R,k,F,P],O[S.LOCATION_ENTRY_EDITOR]=[R,k,F],O[S.LOCATION_DIALOG]=[R,function(e){return{close:function(t){return e.send("closeDialog",t)}}},P],O[S.LOCATION_PAGE]=[R],O[S.LOCATION_HOME]=[R],O[S.LOCATION_APP_CONFIG]=[R,function(e){return{app:L(e)}}],O);function R(e,t){var n=t.user,r=t.parameters,o=t.locales,i=t.ids,a=t.initialContentTypes,s=t.location||S.LOCATION_ENTRY_FIELD;return{cmaAdapter:D(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:v(e,a),dialogs:m(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})},warning:function(t){return e.send("notify",{type:"warning",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:p(n,e)}}function F(e,t){return{editor:E(e,t.editorInterface)}}function k(e,t){var n=t.locales,r=t.contentType,o=t.entry,i=t.fieldInfo;return{contentType:r,entry:h(e,o,i,(function(t){return new d(e,t,n.default)}))}}var x=function(e,t){if(void 0===e.window||void 0===e.document)return function(){};var n,r,o=((n={promise:null,resolve:null,isFulfilled:!1}).promise=new Promise((function(e){n.resolve=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];n.isFulfilled=!0,e.apply(void 0,t)}})),n);return o.promise.then((function(t){var n=t[0],r=e.document;r.addEventListener("focus",(function(){return n.send("setActive",!0)}),!0),r.addEventListener("blur",(function(){return n.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 l(n.id,e);t(o,n,r)}))}(e,(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return o.resolve(e)})),function(n,i){var a=void 0===i?{supressIframeWarning:!1}:i,s=a.makeCustomApi;a.supressIframeWarning||function(e){e.self===e.top&&console.error("Cannot use App SDK outside of Contenful:\n\nIn order for the App SDK to function correctly, your app needs to be run in an iframe in the Contentful Web App, Compose or Launch.\n\nLearn more about local development with the App SDK here:\nhttps://www.contentful.com/developers/docs/extensibility/ui-extensions/faq/#how-can-i-develop-with-the-ui-extension-sdk-locally")}(e),r||(r=o.promise.then((function(n){var r,o=n[0],i=n[1],a=n[2],l=t(o,i,e);return"function"==typeof s&&(r=s(o,i)),a.forEach((function(e){o._handleMessage(e)})),[l,r]})),o.isFulfilled||function(e){var t=u.getMessageId();e.parent.postMessage({id:t,method:"init",params:[]},"*")}(e)),r.then((function(e){var t=e[0],r=e[1];return n(t,r)}))}}(globalThis,(function(e,t,n){return(M[t.location]||H).reduce((function(o,i){return r(r({},o),i(e,t,n))}),{})}));e.init=x,e.locations=S,Object.defineProperty(e,"__esModule",{value:!0})})),globalThis.contentfulApp=globalThis.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])},t(e,n)};var n=function(){return n=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},n.apply(this,arguments)};var r=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}(),o=function(e){function n(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=e.call(this)||this;if(!t.length)throw new Error("Initial value to be memoized expected");return r._memoizedArgs=t,r}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)}(n,e),n.prototype.dispatch=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];this._memoizedArgs=t,e.prototype.dispatch.apply(this,t)},n.prototype.attach=function(t){var n=e.prototype.attach.call(this,t);return t.apply(void 0,this._memoizedArgs),n},n}(r);var i,a=function(){function e(e,t){var n=this;this._messageHandlers={},this._responseHandlers={},this._send=function(e,t){return function(n,r){var o=s.getMessageId();try{t.postMessage({source:e,id:o,method:n,params:r},"*")}catch(e){throw e instanceof DOMException&&"DataCloneError"===e.name&&"openDialog"===n&&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 o}}(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 r),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}(),s=(i=0,{getMessageId:function(){return i++}});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 o(this._value),this._isDisabledSignal=new o(void 0),this._schemaErrorsChangedSignal=new o(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,r){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=r,this._fieldLocales=t.locales.reduce((function(r,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 n(n({},r),((i={})[o]=a,i))}),{}),this.assertHasLocale(r)}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 "'.concat(e,'" for field "').concat(this.id,'"'))},e}();function c(e,t){var n,r=e.document,o=e.MutationObserver,i=e.ResizeObserver,a=!1,s=!1,l=new Set,u=new o((function(e){!function(e){e.forEach((function(e){switch(e.type){case"attributes":if(e.target.nodeType===Node.ELEMENT_NODE){var t=e.target;p(e.type,t)?l.add(t):l.delete(t)}break;case"childList":e.addedNodes.forEach((function(t){if(t.nodeType===Node.ELEMENT_NODE){var n=t;p(e.type,n)&&l.add(n)}})),e.removedNodes.forEach((function(e){var t=e;l.delete(t)}))}}))}(e),a&&d.updateHeight()})),c=new i((function(){d.updateHeight()}));u.observe(r.body,{attributes:!0,childList:!0,subtree:!0,characterData:!0});var d={startAutoResizer:function(e){var t=(void 0===e?{}:e).absoluteElements;if(s=Boolean(t===void 0?false:t),d.updateHeight(),a)return;a=!0,c.observe(r.body)},stopAutoResizer:function(){if(!a)return;a=!1,c.disconnect()},updateHeight:function(e){void 0===e&&(e=null);if(null===e){var o=Math.ceil(r.documentElement.getBoundingClientRect().height);if(s&&l.size){var i=o;l.forEach((function(e){i=Math.max(e.getBoundingClientRect().bottom,i)})),e=i}else e=o}e!==n&&(t.send("setHeight",e),n=e)}};return d;function p(e,t){var n=getComputedStyle(t);return"absolute"===n.position&&("attributes"!==e||"none"!==n.display)}}var d=["getTask","getTasks","createTask","updateTask","deleteTask"];function p(e,t,r,i){var a=t.sys,s=new o(a),l=t.metadata,u=new o(l);e.addHandler("sysChanged",(function(e){a=e,s.dispatch(a)})),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)}})),n(n(n({getSys:function(){return a},publish:function(t){return e.call("callEntryMethod","publish",[t])},unpublish:function(){return e.call("callEntryMethod","unpublish")},save:function(){return e.call("callEntryMethod","save")},onSysChanged:function(e){return s.attach(e)},fields:r.reduce((function(e,t){return e[t.id]=i(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 ".concat(String(t)," on the Space API. Since version 4.0.0 the Space API and its methods are deprecated, and they will be removed from version 5.0.0 on. 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,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}([],t,!0)},n}var g=function(e){return"object"!=typeof(t=e)||null===t||Array.isArray(t)?{}:e;var t};function v(e,t){return{openAlert:r.bind(null,"alert"),openConfirm:r.bind(null,"confirm"),openPrompt:r.bind(null,"prompt"),openExtension:o,openCurrentApp:i,openCurrent:function(e){return t.app?i(e):o(n(n({},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 r(t,n){return e.call("openDialog",t,g(n))}function o(r){var o=g(r);if((o=n(n({},o),{id:o.id||t.extension})).id)return e.call("openDialog","extension",o);throw new Error("Extension ID not provided.")}function i(r){if(r=g(r),t.app){var o=n(n({},r),{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 o([void 0]),r=new o([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 m(e,t){var o=new r;return e.addHandler("navigateSlideIn",(function(e){o.dispatch(e)})),{openEntry:function(t,r){return e.call("navigateToContentEntity",n(n({},r),{entityType:"Entry",id:t}))},openNewEntry:function(t,r){return e.call("navigateToContentEntity",n(n({},r),{entityType:"Entry",id:null,contentTypeId:t}))},openBulkEditor:function(t,r){return e.call("navigateToBulkEditor",n({entryId:t},r))},openAsset:function(t,r){return e.call("navigateToContentEntity",n(n({},r),{entityType:"Asset",id:t}))},openNewAsset:function(t){return e.call("navigateToContentEntity",n(n({},t),{entityType:"Asset",id:null}))},openPageExtension:function(r){return e.call("navigateToPage",n({type:"extension",id:t.extension},r))},openCurrentAppPage:function(r){return e.call("navigateToPage",n({type:"app",id:t.app},r))},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 o.attach(e)}}}var E="preInstall",_="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)},b=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?b(n[r],{}).then((function(t){return e.send("appHookResult",{stage:r,installationRequestId:o,result:t})})):r===_?b(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(_,e)}}}var I,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",LOCATION_HOME:"home"},O=function(e){return function(t){return e.call("CMAAdapterCall",t)}};function S(e){return{makeRequest:O(e)}}var N=[H,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)}},R,M],D=((I={})[L.LOCATION_ENTRY_FIELD]=N,I[L.LOCATION_ENTRY_FIELD_SIDEBAR]=N,I[L.LOCATION_ENTRY_SIDEBAR]=[H,P,R,M],I[L.LOCATION_ENTRY_EDITOR]=[H,P,R],I[L.LOCATION_DIALOG]=[H,function(e){return{close:function(t){return e.send("closeDialog",t)}}},M],I[L.LOCATION_PAGE]=[H],I[L.LOCATION_HOME]=[H],I[L.LOCATION_APP_CONFIG]=[H,function(e){return{app:w(e)}}],I);function H(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:m(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})},warning:function(t){return e.send("notify",{type:"warning",message:t})}},ids:i,access:{can:function(t,n,r){return e.call("checkAccess",t,n,r)},canEditAppConfig:function(){return e.call("checkAppConfigAccess")}}}}function M(e,t,n){return{window:c(n,e)}}function R(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 F=function(e,t){if(void 0===e.window||void 0===e.document)return function(){};var n,r,o=((n={promise:null,resolve:null,isFulfilled:!1}).promise=new Promise((function(e){n.resolve=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];n.isFulfilled=!0,e.apply(void 0,t)}})),n);return o.promise.then((function(t){var n=t[0],r=e.document;r.addEventListener("focus",(function(){return n.send("setActive",!0)}),!0),r.addEventListener("blur",(function(){return n.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 a(n.id,e);t(o,n,r)}))}(e,(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return o.resolve(e)})),function(n,i){var a=void 0===i?{supressIframeWarning:!1}:i,l=a.makeCustomApi;a.supressIframeWarning||function(e){e.self===e.top&&console.error("Cannot use App SDK outside of Contenful:\n\nIn order for the App SDK to function correctly, your app needs to be run in an iframe in the Contentful Web App, Compose or Launch.\n\nLearn more about local development with the App SDK here:\nhttps://www.contentful.com/developers/docs/extensibility/ui-extensions/faq/#how-can-i-develop-with-the-ui-extension-sdk-locally")}(e),r||(r=o.promise.then((function(n){var r,o=n[0],i=n[1],a=n[2],s=t(o,i,e);return"function"==typeof l&&(r=l(o,i)),a.forEach((function(e){o._handleMessage(e)})),[s,r]})),o.isFulfilled||function(e){var t=s.getMessageId();e.parent.postMessage({id:t,method:"init",params:[]},"*")}(e)),r.then((function(e){var t=e[0],r=e[1];return n(t,r)}))}}(globalThis,(function(e,t,r){return(D[t.location]||N).reduce((function(o,i){return n(n({},o),i(e,t,r))}),{})}));e.init=F,e.locations=L,Object.defineProperty(e,"__esModule",{value:!0})})),globalThis.contentfulApp=globalThis.contentfulExtension;
|
package/dist/channel.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare class Channel {
|
|
|
7
7
|
constructor(sourceId: string, currentGlobal: typeof globalThis);
|
|
8
8
|
call<T = unknown>(method: string, ...params: any[]): Promise<T>;
|
|
9
9
|
send(method: string, ...params: any[]): void;
|
|
10
|
-
addHandler(method: string, handler:
|
|
10
|
+
addHandler<T extends unknown[]>(method: string, handler: (...args: T) => void): () => boolean;
|
|
11
11
|
private _handleMessage;
|
|
12
12
|
}
|
|
13
13
|
export declare function sendInitMessage(currentGlobal: typeof globalThis): number;
|
package/dist/field-locale.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Channel } from './channel';
|
|
2
2
|
import { FieldAPI, FieldInfo, Items } from './types';
|
|
3
|
+
import { ValidationError } from './types/validation-error';
|
|
3
4
|
export default class FieldLocale implements FieldAPI {
|
|
4
5
|
id: string;
|
|
5
6
|
locale: string;
|
|
@@ -19,5 +20,5 @@ export default class FieldLocale implements FieldAPI {
|
|
|
19
20
|
setInvalid(isInvalid: boolean): any;
|
|
20
21
|
onValueChanged(handler: (value: any) => any): () => boolean;
|
|
21
22
|
onIsDisabledChanged(handler: (isDisabled: boolean) => any): () => boolean;
|
|
22
|
-
onSchemaErrorsChanged(handler:
|
|
23
|
+
onSchemaErrorsChanged(handler: (errors: ValidationError[]) => void): () => boolean;
|
|
23
24
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { KnownSDK } from './types';
|
|
2
2
|
export * from './types';
|
|
3
3
|
export { default as locations } from './locations';
|
|
4
|
-
|
|
4
|
+
type Init = <T extends KnownSDK = KnownSDK>(initCallback: (sdk: T) => any, options?: {
|
|
5
5
|
supressIframeWarning?: boolean;
|
|
6
6
|
}) => void;
|
|
7
7
|
export declare const init: Init;
|
package/dist/signal.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
type Listener<T extends unknown[]> = (...args: T) => void;
|
|
2
|
+
export declare class Signal<T extends unknown[]> {
|
|
2
3
|
private _id;
|
|
3
4
|
private _listeners;
|
|
4
|
-
dispatch(...args:
|
|
5
|
-
attach(listener:
|
|
5
|
+
dispatch(...args: T): void;
|
|
6
|
+
attach(listener: Listener<T>): () => boolean;
|
|
6
7
|
}
|
|
7
|
-
declare
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
attach(listener: Function): () => boolean;
|
|
8
|
+
export declare class MemoizedSignal<T extends unknown[]> extends Signal<T> {
|
|
9
|
+
private _memoizedArgs;
|
|
10
|
+
constructor(...memoizedArgs: T);
|
|
11
|
+
dispatch(...args: T): void;
|
|
12
|
+
attach(listener: Listener<T>): () => boolean;
|
|
13
13
|
}
|
|
14
|
-
export {
|
|
14
|
+
export {};
|
|
@@ -99,23 +99,23 @@ export interface EditorLocaleSettings {
|
|
|
99
99
|
export interface SharedEditorSDK {
|
|
100
100
|
editor: {
|
|
101
101
|
editorInterface: EditorInterface;
|
|
102
|
-
onLocaleSettingsChanged: (callback: (
|
|
103
|
-
onShowDisabledFieldsChanged: (callback: (
|
|
102
|
+
onLocaleSettingsChanged: (callback: (localeSettings: EditorLocaleSettings) => void) => () => void;
|
|
103
|
+
onShowDisabledFieldsChanged: (callback: (showDisabledFields: boolean) => any) => () => void;
|
|
104
104
|
};
|
|
105
105
|
/** Allows to read and update the value of any field of the current entry and to get the entry's metadata */
|
|
106
106
|
entry: EntryAPI;
|
|
107
107
|
/** Information about the content type of the entry. */
|
|
108
108
|
contentType: ContentTypeAPI;
|
|
109
109
|
}
|
|
110
|
-
export
|
|
111
|
-
export
|
|
112
|
-
export
|
|
113
|
-
export
|
|
110
|
+
export type CrudAction = 'create' | 'read' | 'update' | 'delete';
|
|
111
|
+
export type PublishableAction = 'publish' | 'unpublish';
|
|
112
|
+
export type ArchiveableAction = 'archive' | 'unarchive';
|
|
113
|
+
export type JSONPatchItem = {
|
|
114
114
|
op: 'remove' | 'replace' | 'add';
|
|
115
115
|
path: string;
|
|
116
116
|
value?: any;
|
|
117
117
|
};
|
|
118
|
-
|
|
118
|
+
type PatchEntity = Entry | Task | Asset | WorkflowDefinition;
|
|
119
119
|
export interface AccessAPI {
|
|
120
120
|
can(action: 'read' | 'update', entity: 'EditorInterface' | EditorInterface): Promise<boolean>;
|
|
121
121
|
can<T = Object>(action: CrudAction, entity: 'ContentType' | ContentType | 'Asset' | 'Entry' | T): Promise<boolean>;
|
|
@@ -125,7 +125,7 @@ export interface AccessAPI {
|
|
|
125
125
|
/** Whether the current user can edit app config */
|
|
126
126
|
canEditAppConfig: () => Promise<boolean>;
|
|
127
127
|
}
|
|
128
|
-
|
|
128
|
+
type EntryScopedIds = 'field' | 'entry' | 'contentType';
|
|
129
129
|
export interface BaseExtensionSDK {
|
|
130
130
|
/** @deprecated since version 4.0.0 consider using the CMA instead
|
|
131
131
|
* See https://www.contentful.com/developers/docs/extensibility/app-framework/sdk/#using-the-contentful-management-library for more details
|
|
@@ -152,17 +152,17 @@ export interface BaseExtensionSDK {
|
|
|
152
152
|
/** Adapter to be injected in contentful-management client */
|
|
153
153
|
cmaAdapter: Adapter;
|
|
154
154
|
}
|
|
155
|
-
export
|
|
155
|
+
export type EditorExtensionSDK = Omit<BaseExtensionSDK, 'ids'> & SharedEditorSDK & {
|
|
156
156
|
/** A set of IDs for the app */
|
|
157
157
|
ids: Omit<IdsAPI, 'field'>;
|
|
158
158
|
};
|
|
159
|
-
export
|
|
159
|
+
export type SidebarExtensionSDK = Omit<BaseExtensionSDK, 'ids'> & SharedEditorSDK & {
|
|
160
160
|
/** A set of IDs for the app */
|
|
161
161
|
ids: Omit<IdsAPI, 'field'>;
|
|
162
162
|
/** Methods to update the size of the iframe the app is contained within. */
|
|
163
163
|
window: WindowAPI;
|
|
164
164
|
};
|
|
165
|
-
export
|
|
165
|
+
export type FieldExtensionSDK = BaseExtensionSDK & SharedEditorSDK & {
|
|
166
166
|
/** A set of IDs for the app */
|
|
167
167
|
ids: IdsAPI;
|
|
168
168
|
/** Gives you access to the value and metadata of the field the app is attached to. */
|
|
@@ -170,7 +170,7 @@ export declare type FieldExtensionSDK = BaseExtensionSDK & SharedEditorSDK & {
|
|
|
170
170
|
/** Methods to update the size of the iframe the app is contained within. */
|
|
171
171
|
window: WindowAPI;
|
|
172
172
|
};
|
|
173
|
-
export
|
|
173
|
+
export type DialogExtensionSDK = Omit<BaseExtensionSDK, 'ids'> & {
|
|
174
174
|
/** A set of IDs for the app */
|
|
175
175
|
ids: Omit<IdsAPI, EntryScopedIds>;
|
|
176
176
|
/** Closes the dialog and resolves openCurrentApp promise with data */
|
|
@@ -178,21 +178,21 @@ export declare type DialogExtensionSDK = Omit<BaseExtensionSDK, 'ids'> & {
|
|
|
178
178
|
/** Methods to update the size of the iframe the app is contained within. */
|
|
179
179
|
window: WindowAPI;
|
|
180
180
|
};
|
|
181
|
-
export
|
|
181
|
+
export type PageExtensionSDK = Omit<BaseExtensionSDK, 'ids'> & {
|
|
182
182
|
/** A set of IDs actual for the app */
|
|
183
183
|
ids: Omit<IdsAPI, EntryScopedIds>;
|
|
184
184
|
};
|
|
185
|
-
export
|
|
185
|
+
export type HomeExtensionSDK = Omit<BaseExtensionSDK, 'ids'> & {
|
|
186
186
|
ids: Omit<IdsAPI, EntryScopedIds>;
|
|
187
187
|
};
|
|
188
|
-
export
|
|
188
|
+
export type AppExtensionSDK = Omit<BaseExtensionSDK, 'ids'> & {
|
|
189
189
|
/** A set of IDs actual for the app */
|
|
190
190
|
ids: Omit<IdsAPI, EntryScopedIds | 'extension' | 'app'> & {
|
|
191
191
|
app: string;
|
|
192
192
|
};
|
|
193
193
|
app: AppConfigAPI;
|
|
194
194
|
};
|
|
195
|
-
export
|
|
195
|
+
export type KnownSDK = FieldExtensionSDK | SidebarExtensionSDK | DialogExtensionSDK | EditorExtensionSDK | PageExtensionSDK | AppExtensionSDK | HomeExtensionSDK;
|
|
196
196
|
export interface Locations {
|
|
197
197
|
LOCATION_ENTRY_FIELD: 'entry-field';
|
|
198
198
|
LOCATION_ENTRY_FIELD_SIDEBAR: 'entry-field-sidebar';
|
|
@@ -20,11 +20,11 @@ interface AppStateEditorInterfaceItem {
|
|
|
20
20
|
export interface AppState {
|
|
21
21
|
EditorInterface: Record<ContentType['sys']['id'], AppStateEditorInterfaceItem>;
|
|
22
22
|
}
|
|
23
|
-
export
|
|
23
|
+
export type OnConfigureHandlerReturn = {
|
|
24
24
|
parameters?: KeyValueMap | null;
|
|
25
25
|
targetState?: AppState | null;
|
|
26
26
|
} | false;
|
|
27
|
-
export
|
|
27
|
+
export type OnConfigureHandler = () => OnConfigureHandlerReturn | Promise<OnConfigureHandlerReturn>;
|
|
28
28
|
export interface AppConfigAPI {
|
|
29
29
|
/** Tells the web app that the app is loaded */
|
|
30
30
|
setReady: () => Promise<void>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { PlainClientAPI } from 'contentful-management';
|
|
2
|
+
export type CMAClient = {
|
|
3
|
+
appAction: Pick<PlainClientAPI['appAction'], 'get' | 'getMany' | 'getManyForEnvironment'>;
|
|
4
|
+
appDefinition: Pick<PlainClientAPI['appDefinition'], 'get' | 'getInstallationsForOrg'>;
|
|
5
|
+
appInstallation: Pick<PlainClientAPI['appInstallation'], 'getForOrganization'>;
|
|
6
|
+
asset: PlainClientAPI['asset'];
|
|
7
|
+
assetKey: PlainClientAPI['assetKey'];
|
|
8
|
+
appSignedRequest: Pick<PlainClientAPI['appSignedRequest'], 'create'>;
|
|
9
|
+
bulkAction: PlainClientAPI['bulkAction'];
|
|
10
|
+
comment: PlainClientAPI['comment'];
|
|
11
|
+
contentType: PlainClientAPI['contentType'];
|
|
12
|
+
editorInterface: PlainClientAPI['editorInterface'];
|
|
13
|
+
environment: Pick<PlainClientAPI['environment'], 'get'>;
|
|
14
|
+
environmentAlias: Pick<PlainClientAPI['environmentAlias'], 'get'>;
|
|
15
|
+
entry: PlainClientAPI['entry'];
|
|
16
|
+
locale: PlainClientAPI['locale'];
|
|
17
|
+
release: PlainClientAPI['release'];
|
|
18
|
+
releaseAction: PlainClientAPI['releaseAction'];
|
|
19
|
+
role: Pick<PlainClientAPI['role'], 'get' | 'getMany'>;
|
|
20
|
+
scheduledActions: PlainClientAPI['scheduledActions'];
|
|
21
|
+
snapshot: PlainClientAPI['snapshot'];
|
|
22
|
+
space: Pick<PlainClientAPI['space'], 'get'>;
|
|
23
|
+
upload: PlainClientAPI['upload'];
|
|
24
|
+
user: Pick<PlainClientAPI['user'], 'getManyForSpace' | 'getForSpace'>;
|
|
25
|
+
usage: Pick<PlainClientAPI['usage'], 'getManyForSpace'>;
|
|
26
|
+
team: Pick<PlainClientAPI['team'], 'getManyForSpace'>;
|
|
27
|
+
task: PlainClientAPI['task'];
|
|
28
|
+
tag: PlainClientAPI['tag'];
|
|
29
|
+
uiConfig: PlainClientAPI['uiConfig'];
|
|
30
|
+
userUIConfig: PlainClientAPI['userUIConfig'];
|
|
31
|
+
};
|
|
@@ -6,7 +6,7 @@ export interface OpenAlertOptions {
|
|
|
6
6
|
shouldCloseOnEscapePress?: boolean;
|
|
7
7
|
shouldCloseOnOverlayClick?: boolean;
|
|
8
8
|
}
|
|
9
|
-
export
|
|
9
|
+
export type OpenConfirmOptions = OpenAlertOptions & {
|
|
10
10
|
cancelLabel?: string;
|
|
11
11
|
intent?: 'primary' | 'positive' | 'negative';
|
|
12
12
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Metadata, Task } from './entities';
|
|
2
2
|
import { EntryFieldAPI } from './field.types';
|
|
3
3
|
import { CollectionResponse, ContentEntitySys, SearchQuery } from './utils';
|
|
4
|
-
|
|
4
|
+
type TaskState = 'active' | 'resolved';
|
|
5
5
|
export interface TaskInputData {
|
|
6
6
|
assignedToId: string;
|
|
7
7
|
assignedToType?: 'User' | 'Team';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -10,3 +10,4 @@ export type { SpaceAPI } from './space.types';
|
|
|
10
10
|
export type { SearchQuery, CollectionResponse, ContentEntitySys, ContentEntityType, Items, Link, WithOptionalId, WithId, SerializedJSONValue, } from './utils';
|
|
11
11
|
export type { DateRangeValidationError, InValidationError, LinkContentTypeValidationError, LinkMimetypeGroupValidationError, NotResolvableValidationError, ProhibitRegexpValidationError, RangeValidationError, RegexpValidationError, RequiredValidationError, SizeValidationError, TypeValidationError, UniqueValidationError, UnknownValidationError, ValidationError, } from './validation-error';
|
|
12
12
|
export type { WindowAPI } from './window.types';
|
|
13
|
+
export type { CMAClient } from './cmaClient.types';
|
|
@@ -59,5 +59,5 @@ export interface NavigatorAPI {
|
|
|
59
59
|
openAppConfig: () => Promise<void>;
|
|
60
60
|
openEntriesList: () => Promise<void>;
|
|
61
61
|
openAssetsList: () => Promise<void>;
|
|
62
|
-
onSlideInNavigation: (fn: (slide: NavigatorSlideInfo) => void) =>
|
|
62
|
+
onSlideInNavigation: (fn: (slide: NavigatorSlideInfo) => void) => () => void;
|
|
63
63
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Asset, CanonicalRequest, ContentType, EditorInterface, ScheduledAction, Tag, Team, User, TagVisibility, KeyValueMap, Entry, QueryOptions, Upload } from './entities';
|
|
2
2
|
import { CollectionResponse, ContentEntityType, Link, WithOptionalId, SearchQuery } from './utils';
|
|
3
|
-
|
|
3
|
+
type Snapshot<T> = {
|
|
4
4
|
sys: {
|
|
5
5
|
space?: Link;
|
|
6
6
|
status?: Link;
|
package/dist/types/utils.d.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { ContentTypeFieldValidation } from './entities';
|
|
2
|
-
|
|
2
|
+
type Sys = {
|
|
3
3
|
id: string;
|
|
4
4
|
type: string;
|
|
5
5
|
[key: string]: any;
|
|
6
6
|
};
|
|
7
|
-
|
|
7
|
+
type Entity = {
|
|
8
8
|
sys: Sys;
|
|
9
9
|
[key: string]: any;
|
|
10
10
|
};
|
|
11
|
-
|
|
12
|
-
export
|
|
11
|
+
type Optional<Type, Keys extends keyof Type> = Partial<Type> & Omit<Type, Keys>;
|
|
12
|
+
export type WithSysWithAtLeastId = {
|
|
13
13
|
sys: {
|
|
14
14
|
id: string;
|
|
15
15
|
[key: string]: any;
|
|
16
16
|
};
|
|
17
17
|
};
|
|
18
|
-
export
|
|
19
|
-
export
|
|
18
|
+
export type WithId<Type extends Entity> = Omit<Type, 'sys'> & WithSysWithAtLeastId;
|
|
19
|
+
export type WithOptionalId<Type extends Entity> = Optional<Type, 'sys'> | WithId<Type>;
|
|
20
20
|
export interface Link<LinkType = string, Type = string> {
|
|
21
21
|
sys: {
|
|
22
22
|
id: string;
|
|
@@ -33,7 +33,7 @@ export interface CollectionResponse<T> {
|
|
|
33
33
|
type: string;
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
-
export
|
|
36
|
+
export type ContentEntityType = 'Entry' | 'Asset';
|
|
37
37
|
export interface ContentEntitySys {
|
|
38
38
|
space: Link;
|
|
39
39
|
id: string;
|
|
@@ -64,7 +64,7 @@ export interface SearchQuery {
|
|
|
64
64
|
limit?: number;
|
|
65
65
|
[key: string]: any;
|
|
66
66
|
}
|
|
67
|
-
export
|
|
67
|
+
export type SerializedJSONValue = null | string | number | boolean | Array<SerializedJSONValue> | {
|
|
68
68
|
[key: string]: SerializedJSONValue;
|
|
69
69
|
};
|
|
70
70
|
export {};
|
|
@@ -60,4 +60,4 @@ export interface TypeValidationError extends BaseValidationError {
|
|
|
60
60
|
name: 'type';
|
|
61
61
|
type: string;
|
|
62
62
|
}
|
|
63
|
-
export
|
|
63
|
+
export type ValidationError = SizeValidationError | RangeValidationError | InValidationError | RequiredValidationError | UniqueValidationError | RegexpValidationError | ProhibitRegexpValidationError | LinkMimetypeGroupValidationError | LinkContentTypeValidationError | DateRangeValidationError | NotResolvableValidationError | UnknownValidationError | TypeValidationError | BaseValidationError;
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"contentful-ui-extensions-sdk","description":"
|
|
1
|
+
{"name":"contentful-ui-extensions-sdk","description":"A JavaScript library to develop custom apps for Contentful","version":"4.14.1","author":"Contentful GmbH","license":"MIT","sideEffects":true,"repository":{"url":"https://github.com/contentful/ui-extensions-sdk.git","type":"git"},"homepage":"https://www.contentful.com/developers/docs/extensibility/app-framework/sdk/","main":"dist/cf-extension-api.js","types":"dist/index.d.ts","files":["dist/cf-extension-api.js","dist/cf-extension-api.js.map","dist/cf-extension.css","dist/**/*.d.ts"],"scripts":{"test":"ts-mocha -p tsconfig.test.json 'test/unit/*.[jt]s' --reporter mocha-multi-reporters --reporter-options configFile=mocha.unit-reporters.json","lint":"eslint '{lib,test}/**/*.{t,j}s'","lint:fix":"npm run lint -- --fix","build":"npm run check-types && rollup -c --compact","build:debug":"npm run build -- --sourcemap","prepublishOnly":"npm run build","size":"echo \"Gzipped, estimate: $(gzip -9 -c dist/cf-extension-api.js | wc -c) bytes\"","semantic-release":"semantic-release","publish-all":"node ./scripts/publish.js","verify":"node ./scripts/verify.js","check-types":"tsc --noEmit -m commonjs","prepare":"husky install","lint-staged":"lint-staged"},"devDependencies":{"@semantic-release/changelog":"6.0.2","@semantic-release/exec":"6.0.3","@semantic-release/git":"10.0.1","@testing-library/dom":"8.19.1","@types/chai-as-promised":"7.1.5","@types/cross-spawn":"6.0.2","@types/fs-extra":"9.0.13","@types/jsdom":"20.0.1","@types/mocha":"10.0.1","@types/nanoid":"3.0.0","@types/sinon":"^10.0.0","@types/sinon-chai":"^3.2.5","@typescript-eslint/eslint-plugin":"4.33.0","@typescript-eslint/parser":"4.33.0","babel-eslint":"10.1.0","chai":"4.3.7","chai-as-promised":"7.1.1","contentful-management":"10.26.0","cross-spawn":"7.0.3","eslint":"7.32.0","eslint-config-prettier":"8.5.0","eslint-config-standard":"16.0.3","eslint-plugin-import":"2.26.0","eslint-plugin-node":"11.1.0","eslint-plugin-prettier":"4.2.1","eslint-plugin-promise":"6.1.1","eslint-plugin-react":"7.31.11","eslint-plugin-standard":"5.0.0","fs-extra":"11.1.0","husky":"8.0.2","jsdom":"20.0.3","lint-staged":"13.1.0","mocha":"10.2.0","mocha-junit-reporter":"2.2.0","mocha-multi-reporters":"1.5.1","mochawesome":"7.1.3","mochawesome-merge":"4.2.2","mochawesome-report-generator":"6.2.0","prettier":"2.8.1","rollup":"2.79.1","rollup-plugin-terser":"7.0.2","rollup-plugin-typescript2":"0.34.1","semantic-release":"19.0.5","sinon":"15.0.1","sinon-chai":"3.7.0","ts-mocha":"10.0.0","tslib":"2.4.1","typescript":"4.9.4"},"lint-staged":{"*.ts":["prettier --write","eslint --fix","git add"],"*.md":["prettier --write","git add"]},"release":{"branches":["master",{"name":"canary","channel":"canary","prerelease":"alpha"}],"plugins":["@semantic-release/commit-analyzer","@semantic-release/release-notes-generator","@semantic-release/changelog",["@semantic-release/npm",{"npmPublish":false}],["@semantic-release/exec",{"verifyConditionsCmd":"node ./scripts/verify.js","publishCmd":"npm run publish-all"}],["@semantic-release/git",{"message":"chore: ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}","assets":["CHANGELOG.md","package.json","package-lock.json"]}],"@semantic-release/github"]},"peerDependencies":{"contentful-management":">=7.30.0"}}
|