contentful-ui-extensions-sdk
Advanced tools
Comparing version 4.10.0-alpha.4 to 4.10.0-alpha.5
@@ -1,3 +0,3 @@ | ||
import { KnownSDK, ConnectMessage } from './types'; | ||
import { ConnectMessage, KnownAppSDK } from './types'; | ||
import { Channel } from './channel'; | ||
export default function createAPI(channel: Channel, data: ConnectMessage, currentGlobal: typeof globalThis): KnownSDK; | ||
export default function createAPI(channel: Channel, data: ConnectMessage, currentGlobal: typeof globalThis): KnownAppSDK; |
import { Channel } from './channel'; | ||
import { AppConfigAPI } from './types'; | ||
export default function createApp(channel: Channel): AppConfigAPI; |
@@ -1,1 +0,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; | ||
!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)};function r(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{l(r.next(e))}catch(e){i(e)}}function s(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}l((r=r.apply(e,t||[])).next())}))}function o(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(l){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}}var i=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}(),a=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.prototype.getMemoizedArgs=function(){return this._memoizedArgs},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 i),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.name=t.name,this.locale=t.locale,this.type=t.type,this.required=t.required,this.validations=t.validations,"Array"===t.type&&(this.items=t.items),"Link"===t.type&&(this.linkType=t.linkType),this._value=t.value,this._valueSignal=new a(this._value),this._isDisabledSignal=new a(t.isDisabled),this._schemaErrorsChangedSignal=new a(t.schemaErrors),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 r(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return this._value=e,this._valueSignal.dispatch(e),[4,this._channel.call("setValue",this.id,this.locale,e)];case 1:return[2,t.sent()]}}))}))},e.prototype.removeValue=function(){return r(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return this._value=void 0,[4,this._channel.call("removeValue",this.id,this.locale)];case 1:return e.sent(),[2]}}))}))},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.getIsDisabled=function(){return this._isDisabledSignal.getMemoizedArgs()[0]},e.prototype.onIsDisabledChanged=function(e){return this._isDisabledSignal.attach(e)},e.prototype.getSchemaErrors=function(){return this._schemaErrorsChangedSignal.getMemoizedArgs()[0]},e.prototype.onSchemaErrorsChanged=function(e){return this._schemaErrorsChangedSignal.attach(e)},e}(),d=function(){function e(e,t,r){this.id=t.id,this.name=t.name,this.locales=t.locales,this.type=t.type,this.required=t.required,this.validations=t.validations,"Array"===t.type&&(this.items=t.items),"Link"===t.type&&(this.linkType=t.linkType),this._defaultLocale=r,this._fieldLocales=t.locales.reduce((function(r,o){var i,a=new c(e,{id:t.id,name:t.name,type:t.type,required:t.required,validations:t.validations,locale:o,items:"Array"===t.type?t.items:void 0,linkType:"Link"===t.type?t.linkType:void 0,value:t.values[o],isDisabled:t.isDisabled[o],schemaErrors:t.schemaErrors[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 r(this,void 0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return[4,this._getFieldLocale(t).setValue(e)];case 1:return[2,n.sent()]}}))}))},e.prototype.removeValue=function(e){return r(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return[4,this.setValue(void 0,e)];case 1:return t.sent(),[2]}}))}))},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,r,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)}})),n(n(n({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:r.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 y(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 v=function(e){return"object"!=typeof(t=e)||null===t||Array.isArray(t)?{}:e;var t};function m(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,v(n))}function o(r){var o=v(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=v(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=v(r)).entityType=t,r.multiple=n,e.call("openDialog","entitySelector",r)}}function E(e,t,n){var r=new a(n.localeSettings),o=new a(n.showHiddenFields);return e.addHandler("localeSettingsChanged",(function(e){r.dispatch(e)})),e.addHandler("showHiddenFieldsChanged",(function(e){o.dispatch(e)})),{editorInterface:t,getLocaleSettings:function(){return r.getMemoizedArgs()[0]},onLocaleSettingsChanged:function(e){return r.attach(e)},onShowDisabledFieldsChanged:function(e){return o.attach(e)},getShowHiddenFields:function(){return o.getMemoizedArgs()[0]},onShowHiddenFieldsChanged:function(e){return o.attach(e)}}}function A(e,t){var r=new i;return e.addHandler("navigateSlideIn",(function(e){r.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 r.attach(e)}}}var _="preInstall",b="postInstall",w=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 w(o=i)&&C(o.then)||(i=Promise.resolve(i)),i.then((function(e){return e instanceof Error?Promise.reject(e):!1!==e&&(w(e)?e:t)}),T).catch(T)};function L(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===_?I(n[r],{}).then((function(t){return e.send("appHookResult",{stage:r,installationRequestId:o,result:t})})):r===b?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)},onConfigurationCompleted:function(e){r(b,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"},D=function(e){return function(t){return e.call("CMAAdapterCall",t)}};function N(e){return{makeRequest:D(e)}}var M=[k,x,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)}},R,P],H=((O={})[S.LOCATION_ENTRY_FIELD]=M,O[S.LOCATION_ENTRY_FIELD_SIDEBAR]=M,O[S.LOCATION_ENTRY_SIDEBAR]=[k,x,R,P],O[S.LOCATION_ENTRY_EDITOR]=[k,x,R],O[S.LOCATION_DIALOG]=[k,function(e){return{close:function(t){return e.send("closeDialog",t)}}},P],O[S.LOCATION_PAGE]=[k],O[S.LOCATION_HOME]=[k],O[S.LOCATION_APP_CONFIG]=[k,function(e){return{app:L(e)}}],O);function k(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:N(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:y(e,a),dialogs:m(e,i),navigator:A(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 R(e,t){return{editor:E(e,t.editorInterface,t.editor)}}function x(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 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 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,r){return(H[t.location]||M).reduce((function(o,i){return n(n({},o),i(e,t,r))}),{})}));e.init=F,e.locations=S,Object.defineProperty(e,"__esModule",{value:!0})})),globalThis.contentfulApp=globalThis.contentfulExtension; |
@@ -10,5 +10,5 @@ import { ConnectMessage } from './types'; | ||
send(method: string, ...params: any[]): void; | ||
addHandler(method: string, handler: Function): () => boolean; | ||
addHandler<T extends unknown[]>(method: string, handler: (...args: T) => void): () => boolean; | ||
private _handleMessage; | ||
} | ||
export declare function sendInitMessage(currentGlobal: typeof globalThis): number; |
import { Channel } from './channel'; | ||
import { Adapter } from 'contentful-management/types'; | ||
export declare function createAdapter(channel: Channel): Adapter; |
import { Channel } from './channel'; | ||
import { DialogsAPI, IdsAPI } from './types'; | ||
export default function createDialogs(channel: Channel, ids: IdsAPI): DialogsAPI; |
import { EditorInterface, SharedEditorSDK } from './types'; | ||
import { Channel } from './channel'; | ||
export default function createEditor(channel: Channel, editorInterface: EditorInterface): SharedEditorSDK['editor']; | ||
import { ConnectMessage } from './types/api.types'; | ||
export default function createEditor(channel: Channel, editorInterface: EditorInterface, editorData: Exclude<ConnectMessage['editor'], undefined>): SharedEditorSDK['editor']; |
import { Channel } from './channel'; | ||
import { EntryAPI, EntryFieldInfo } from './types'; | ||
export default function createEntry(channel: Channel, entryData: any, fieldInfo: EntryFieldInfo[], createEntryField: Function): EntryAPI; | ||
import { ExhaustiveEntryFieldAPI } from './types/field.types'; | ||
export default function createEntry(channel: Channel, entryData: any, fieldInfo: EntryFieldInfo[], createEntryField: (info: EntryFieldInfo) => ExhaustiveEntryFieldAPI): EntryAPI; |
import { Channel } from './channel'; | ||
import { FieldAPI, FieldInfo, Items } from './types'; | ||
export default class FieldLocale implements FieldAPI { | ||
import { FieldInfo, FieldType, FieldLinkType, Items, SerializedJSONValue } from './types'; | ||
import { ExhaustiveFieldAPI } from './types/field-locale.types'; | ||
import { ValidationError } from './types/validation-error'; | ||
export default class FieldLocale implements ExhaustiveFieldAPI { | ||
id: string; | ||
name: string; | ||
locale: string; | ||
type: string; | ||
type: FieldType; | ||
required: boolean; | ||
validations: any[]; | ||
items?: Items; | ||
linkType?: FieldLinkType; | ||
private _value; | ||
@@ -17,8 +21,10 @@ private _valueSignal; | ||
getValue(): any; | ||
setValue(value: any): any; | ||
removeValue(): any; | ||
setInvalid(isInvalid: boolean): any; | ||
setValue(value: any): Promise<SerializedJSONValue | undefined>; | ||
removeValue(): Promise<void>; | ||
setInvalid(isInvalid: boolean): Promise<unknown>; | ||
onValueChanged(handler: (value: any) => any): () => boolean; | ||
getIsDisabled(): boolean; | ||
onIsDisabledChanged(handler: (isDisabled: boolean) => any): () => boolean; | ||
onSchemaErrorsChanged(handler: Function): () => boolean; | ||
getSchemaErrors(): ValidationError[]; | ||
onSchemaErrorsChanged(handler: (errors: ValidationError[]) => void): () => boolean; | ||
} |
import { Channel } from './channel'; | ||
import FieldLocale from './field-locale'; | ||
import { EntryFieldAPI, EntryFieldInfo, Items } from './types'; | ||
export default class Field implements EntryFieldAPI { | ||
import { EntryFieldInfo, FieldType, Items, FieldAPI, FieldLinkType } from './types'; | ||
import { ExhaustiveEntryFieldAPI } from './types/field.types'; | ||
export default class Field implements ExhaustiveEntryFieldAPI { | ||
private _defaultLocale; | ||
private _fieldLocales; | ||
id: string; | ||
name: string; | ||
locales: string[]; | ||
type: string; | ||
type: FieldType; | ||
required: boolean; | ||
validations: Object[]; | ||
items?: Items; | ||
linkType?: FieldLinkType; | ||
constructor(channel: Channel, info: EntryFieldInfo, defaultLocale: string); | ||
getValue(locale?: string): any; | ||
setValue(value: any, locale?: string): any; | ||
removeValue(locale?: string): any; | ||
onValueChanged(locale: string | ((value: any) => void), handler?: (value: any) => void): () => boolean; | ||
onIsDisabledChanged(locale: string | ((isDisabled: boolean) => void), handler?: (isDisabled: boolean) => void): () => boolean; | ||
setValue(value: any, locale?: string): Promise<import("./types").SerializedJSONValue | undefined>; | ||
removeValue(locale?: string): Promise<void>; | ||
onValueChanged(locale: string | ((value: any) => void), handler?: (value: any) => void): () => void; | ||
onIsDisabledChanged(locale: string | ((isDisabled: boolean) => void), handler?: (isDisabled: boolean) => void): () => void; | ||
private _getFieldLocale; | ||
getForLocale(locale: string): FieldLocale; | ||
getForLocale(locale: string): FieldAPI; | ||
assertHasLocale(locale: string): void; | ||
} |
@@ -1,7 +0,7 @@ | ||
import { KnownSDK } from './types'; | ||
import { KnownAppSDK } from './types'; | ||
export * from './types'; | ||
export { default as locations } from './locations'; | ||
declare type Init = <T extends KnownSDK = KnownSDK>(initCallback: (sdk: T) => any, options?: { | ||
type Init = <T extends KnownAppSDK = KnownAppSDK>(initCallback: (sdk: T) => any, options?: { | ||
supressIframeWarning?: boolean; | ||
}) => void; | ||
export declare const init: Init; |
@@ -1,6 +0,6 @@ | ||
import { ConnectMessage, KnownSDK } from './types'; | ||
import { ConnectMessage, KnownAppSDK } from './types'; | ||
import { Channel } from './channel'; | ||
export declare function createInitializer(currentGlobal: typeof globalThis, apiCreator: (channel: Channel, data: ConnectMessage, currentGlobal: typeof globalThis) => KnownSDK): (initCb: (sdk: KnownSDK, customSdk: any) => any, { makeCustomApi, supressIframeWarning, }?: { | ||
export declare function createInitializer(currentGlobal: typeof globalThis, apiCreator: (channel: Channel, data: ConnectMessage, currentGlobal: typeof globalThis) => KnownAppSDK): (initCb: (sdk: KnownAppSDK, customSdk: any) => any, { makeCustomApi, supressIframeWarning, }?: { | ||
makeCustomApi?: Function | undefined; | ||
supressIframeWarning?: boolean | undefined; | ||
}) => void; |
import { Locations } from './types'; | ||
declare const locations: Locations; | ||
export default locations; |
import { NavigatorAPI, IdsAPI } from './types'; | ||
import { Channel } from './channel'; | ||
export default function createNavigator(channel: Channel, ids: IdsAPI): NavigatorAPI; |
@@ -1,14 +0,15 @@ | ||
declare class Signal { | ||
type Listener<T extends unknown[]> = (...args: T) => void; | ||
export declare class Signal<T extends unknown[]> { | ||
private _id; | ||
private _listeners; | ||
dispatch(...args: any[]): void; | ||
attach(listener: Function): () => boolean; | ||
dispatch(...args: T): void; | ||
attach(listener: Listener<T>): () => boolean; | ||
} | ||
declare const memArgsSymbol = "__private__memoized__arguments__"; | ||
declare class MemoizedSignal extends Signal { | ||
private [memArgsSymbol]; | ||
constructor(...memoizedArgs: any[]); | ||
dispatch(...args: any[]): void; | ||
attach(listener: Function): () => boolean; | ||
export declare class MemoizedSignal<T extends unknown[]> extends Signal<T> { | ||
private _memoizedArgs; | ||
constructor(...memoizedArgs: T); | ||
dispatch(...args: T): void; | ||
attach(listener: Listener<T>): () => boolean; | ||
getMemoizedArgs(): T; | ||
} | ||
export { Signal, MemoizedSignal }; | ||
export {}; |
import { ContentType, SpaceAPI } from './types'; | ||
import { Channel } from './channel'; | ||
export default function createSpace(channel: Channel, initialContentTypes: ContentType[]): SpaceAPI; |
@@ -5,3 +5,3 @@ import { ContentType, EditorInterface, SpaceMembership, Role, ContentTypeField, Metadata, Entry, Task, Asset, WorkflowDefinition } from './entities'; | ||
import { WindowAPI } from './window.types'; | ||
import { ContentEntitySys, Link, SerializedJSONValue } from './utils'; | ||
import { EntrySys, Link, SerializedJSONValue } from './utils'; | ||
import { FieldAPI } from './field-locale.types'; | ||
@@ -62,6 +62,6 @@ import { DialogsAPI } from './dialogs.types'; | ||
} | ||
export interface ParametersAPI { | ||
installation: KeyValueMap; | ||
instance: KeyValueMap; | ||
invocation?: SerializedJSONValue; | ||
export interface ParametersAPI<InstallationParameters extends KeyValueMap, InstanceParameters extends KeyValueMap, InvocationParameters extends SerializedJSONValue> { | ||
installation: InstallationParameters; | ||
instance: InstanceParameters; | ||
invocation: InvocationParameters; | ||
} | ||
@@ -104,14 +104,50 @@ export interface IdsAPI { | ||
editorInterface: EditorInterface; | ||
onLocaleSettingsChanged: (callback: (value: EditorLocaleSettings) => any) => Function; | ||
onShowDisabledFieldsChanged: (callback: (value: boolean) => any) => Function; | ||
/** | ||
* Returns the current locale settings | ||
* | ||
* The locale setting can change. To always work with the latest settings, use `onLocaleSettingsChanged`. | ||
*/ | ||
getLocaleSettings(): EditorLocaleSettings; | ||
/** | ||
* Subscribes to changes of the editor's locale settings | ||
* | ||
* @param callback Function that is called every time the locale settings change. Called immidiately with the current setting. | ||
* @returns Function to unsubscribe. `callback` won't be called anymore. | ||
*/ | ||
onLocaleSettingsChanged: (callback: (localeSettings: EditorLocaleSettings) => void) => () => void; | ||
/** | ||
* Subscribes to changes of whether or not disabled fields are displayed | ||
* | ||
* @param callback Function that is called every time the setting whether or not disabled fields are displayed changes. Called immediately with the current state. | ||
* @returns Function to unsubscribe. `callback` won't be called anymore. | ||
* @deprecated Use {@link onShowHiddenFieldsChanged} instead | ||
*/ | ||
onShowDisabledFieldsChanged: (callback: (showDisabledFields: boolean) => void) => () => void; | ||
/** | ||
* Returns whether or not hidden fields are displayed | ||
* | ||
* This setting can change. To always work with the latest settings, use `onShowHiddenFieldsChanged`. | ||
*/ | ||
getShowHiddenFields(): boolean; | ||
/** | ||
* Subscribes to changes of whether or not hidden fields are displayed | ||
* | ||
* @param callback Function that is called every time the setting whether or not hidden fields are displayed changes. Called immediately with the current state. | ||
* @returns Function to unsubscribe. `callback` won't be called anymore. | ||
*/ | ||
onShowHiddenFieldsChanged: (callback: (showHiddenFields: boolean) => void) => () => void; | ||
}; | ||
/** Allows to read and update the value of any field of the current entry and to get the entry's metadata */ | ||
/** | ||
* Allows to read and update the value of any field of the current entry and to get the entry's metadata | ||
*/ | ||
entry: EntryAPI; | ||
/** Information about the content type of the entry. */ | ||
/** | ||
* Information about the content type of the entry. | ||
*/ | ||
contentType: ContentTypeAPI; | ||
} | ||
export declare type CrudAction = 'create' | 'read' | 'update' | 'delete'; | ||
export declare type PublishableAction = 'publish' | 'unpublish'; | ||
export declare type ArchiveableAction = 'archive' | 'unarchive'; | ||
export declare type JSONPatchItem = { | ||
export type CrudAction = 'create' | 'read' | 'update' | 'delete'; | ||
export type PublishableAction = 'publish' | 'unpublish'; | ||
export type ArchiveableAction = 'archive' | 'unarchive'; | ||
export type JSONPatchItem = { | ||
op: 'remove' | 'replace' | 'add'; | ||
@@ -121,3 +157,3 @@ path: string; | ||
}; | ||
declare type PatchEntity = Entry | Task | Asset | WorkflowDefinition; | ||
type PatchEntity = Entry | Task | Asset | WorkflowDefinition; | ||
export interface AccessAPI { | ||
@@ -132,4 +168,4 @@ can(action: 'read' | 'update', entity: 'EditorInterface' | EditorInterface): Promise<boolean>; | ||
} | ||
declare type EntryScopedIds = 'field' | 'entry' | 'contentType'; | ||
export interface BaseExtensionSDK { | ||
type EntryScopedIds = 'field' | 'entry' | 'contentType'; | ||
export interface BaseAppSDK<InstallationParameters extends KeyValueMap = KeyValueMap, InstanceParameters extends KeyValueMap = KeyValueMap, InvocationParameters extends SerializedJSONValue = SerializedJSONValue> { | ||
/** @deprecated since version 4.0.0 consider using the CMA instead | ||
@@ -150,3 +186,3 @@ * See https://www.contentful.com/developers/docs/extensibility/app-framework/sdk/#using-the-contentful-management-library for more details | ||
/** Exposes app configuration parameters */ | ||
parameters: ParametersAPI; | ||
parameters: ParametersAPI<InstallationParameters, InstanceParameters, InvocationParameters>; | ||
/** Exposes method to identify app's location */ | ||
@@ -161,7 +197,7 @@ location: LocationAPI; | ||
} | ||
export declare type EditorExtensionSDK = Omit<BaseExtensionSDK, 'ids'> & SharedEditorSDK & { | ||
export type EditorAppSDK<InstallationParameters extends KeyValueMap = KeyValueMap, InstanceParameters extends KeyValueMap = KeyValueMap> = Omit<BaseAppSDK<InstallationParameters, InstanceParameters, never>, 'ids'> & SharedEditorSDK & { | ||
/** A set of IDs for the app */ | ||
ids: Omit<IdsAPI, 'field'>; | ||
}; | ||
export declare type SidebarExtensionSDK = Omit<BaseExtensionSDK, 'ids'> & SharedEditorSDK & { | ||
export type SidebarAppSDK<InstallationParameters extends KeyValueMap = KeyValueMap, InstanceParameters extends KeyValueMap = KeyValueMap> = Omit<BaseAppSDK<InstallationParameters, InstanceParameters, never>, 'ids'> & SharedEditorSDK & { | ||
/** A set of IDs for the app */ | ||
@@ -172,3 +208,3 @@ ids: Omit<IdsAPI, 'field'>; | ||
}; | ||
export declare type FieldExtensionSDK = BaseExtensionSDK & SharedEditorSDK & { | ||
export type FieldAppSDK<InstallationParameters extends KeyValueMap = KeyValueMap, InstanceParameters extends KeyValueMap = KeyValueMap> = BaseAppSDK<InstallationParameters, InstanceParameters, never> & SharedEditorSDK & { | ||
/** A set of IDs for the app */ | ||
@@ -181,3 +217,3 @@ ids: IdsAPI; | ||
}; | ||
export declare type DialogExtensionSDK = Omit<BaseExtensionSDK, 'ids'> & { | ||
export type DialogAppSDK<InstallationParameters extends KeyValueMap = KeyValueMap, InvocationParameters extends SerializedJSONValue = SerializedJSONValue> = Omit<BaseAppSDK<InstallationParameters, never, InvocationParameters>, 'ids'> & { | ||
/** A set of IDs for the app */ | ||
@@ -190,10 +226,12 @@ ids: Omit<IdsAPI, EntryScopedIds>; | ||
}; | ||
export declare type PageExtensionSDK = Omit<BaseExtensionSDK, 'ids'> & { | ||
export type PageAppSDK<InstallationParameters extends KeyValueMap = KeyValueMap> = Omit<BaseAppSDK<InstallationParameters, never, { | ||
path: string; | ||
}>, 'ids'> & { | ||
/** A set of IDs actual for the app */ | ||
ids: Omit<IdsAPI, EntryScopedIds>; | ||
}; | ||
export declare type HomeExtensionSDK = Omit<BaseExtensionSDK, 'ids'> & { | ||
export type HomeAppSDK<InstallationParameters extends KeyValueMap = KeyValueMap> = Omit<BaseAppSDK<InstallationParameters, never, never>, 'ids'> & { | ||
ids: Omit<IdsAPI, EntryScopedIds>; | ||
}; | ||
export declare type AppExtensionSDK = Omit<BaseExtensionSDK, 'ids'> & { | ||
export type ConfigAppSDK<InstallationParameters extends KeyValueMap = KeyValueMap> = Omit<BaseAppSDK<InstallationParameters, never, never>, 'ids'> & { | ||
/** A set of IDs actual for the app */ | ||
@@ -205,3 +243,21 @@ ids: Omit<IdsAPI, EntryScopedIds | 'extension' | 'app'> & { | ||
}; | ||
export declare type KnownSDK = FieldExtensionSDK | SidebarExtensionSDK | DialogExtensionSDK | EditorExtensionSDK | PageExtensionSDK | AppExtensionSDK | HomeExtensionSDK; | ||
export type KnownAppSDK<InstallationParameters extends KeyValueMap = KeyValueMap, InstanceParameters extends KeyValueMap = KeyValueMap, InvocationParameters extends SerializedJSONValue = SerializedJSONValue> = FieldAppSDK<InstallationParameters, InstanceParameters> | SidebarAppSDK<InstallationParameters, InstanceParameters> | DialogAppSDK<InstallationParameters, InvocationParameters> | EditorAppSDK<InstallationParameters, InstanceParameters> | PageAppSDK<InstallationParameters> | ConfigAppSDK<InstallationParameters> | HomeAppSDK<InstallationParameters>; | ||
/** @deprecated consider using {@link BaseAppSDK} */ | ||
export type BaseExtensionSDK = BaseAppSDK; | ||
/** @deprecated consider using {@link EditorAppSDK} */ | ||
export type EditorExtensionSDK = EditorAppSDK; | ||
/** @deprecated consider using {@link SidebarAppSDK} */ | ||
export type SidebarExtensionSDK = SidebarAppSDK; | ||
/** @deprecated consider using {@link FieldAppSDK} */ | ||
export type FieldExtensionSDK = FieldAppSDK; | ||
/** @deprecated consider using {@link DialogAppSDK} */ | ||
export type DialogExtensionSDK = DialogAppSDK; | ||
/** @deprecated consider using {@link PageAppSDK} */ | ||
export type PageExtensionSDK = PageAppSDK; | ||
/** @deprecated consider using {@link HomeAppSDK} */ | ||
export type HomeExtensionSDK = HomeAppSDK; | ||
/** @deprecated consider using {@link ConfigAppSDK} */ | ||
export type AppExtensionSDK = ConfigAppSDK; | ||
/** @deprecated consider using {@link KnownAppSDK} */ | ||
export type KnownSDK = KnownAppSDK; | ||
export interface Locations { | ||
@@ -220,3 +276,3 @@ LOCATION_ENTRY_FIELD: 'entry-field'; | ||
location: Location[keyof Location]; | ||
parameters: ParametersAPI; | ||
parameters: ParametersAPI<KeyValueMap, KeyValueMap, never>; | ||
locales: LocalesAPI; | ||
@@ -228,4 +284,8 @@ user: UserAPI; | ||
editorInterface?: EditorInterface; | ||
editor?: { | ||
localeSettings: EditorLocaleSettings; | ||
showHiddenFields: boolean; | ||
}; | ||
entry: { | ||
sys: ContentEntitySys; | ||
sys: EntrySys; | ||
metadata?: Metadata; | ||
@@ -232,0 +292,0 @@ }; |
@@ -23,7 +23,7 @@ import { ContentType, KeyValueMap } from './entities'; | ||
} | ||
export declare type OnConfigureHandlerReturn = { | ||
export type OnConfigureHandlerReturn = { | ||
parameters?: KeyValueMap | null; | ||
targetState?: AppState | null; | ||
} | false; | ||
export declare type OnConfigureHandler = () => OnConfigureHandlerReturn | Promise<OnConfigureHandlerReturn>; | ||
export type OnConfigureHandler = () => OnConfigureHandlerReturn | Promise<OnConfigureHandlerReturn>; | ||
export interface AppConfigAPI { | ||
@@ -30,0 +30,0 @@ /** Tells the web app that the app is loaded */ |
@@ -9,3 +9,3 @@ import { SerializedJSONValue } from './utils'; | ||
} | ||
export declare type OpenConfirmOptions = OpenAlertOptions & { | ||
export type OpenConfirmOptions = OpenAlertOptions & { | ||
cancelLabel?: string; | ||
@@ -12,0 +12,0 @@ intent?: 'primary' | 'positive' | 'negative'; |
@@ -0,0 +0,0 @@ export type { AssetProps as Asset, ContentFields as ContentTypeField, ContentTypeFieldValidation, ContentTypeProps as ContentType, EditorInterfaceProps as EditorInterface, EntryProps as Entry, KeyValueMap, MetadataProps as Metadata, QueryOptions, RoleProps as Role, ScheduledActionProps as ScheduledAction, SpaceMembershipProps as SpaceMembership, TagProps as Tag, TagVisibility, TaskProps as Task, TeamProps as Team, UploadProps as Upload, UserProps as User, WorkflowDefinitionProps as WorkflowDefinition, } from 'contentful-management/types'; |
import { Metadata, Task } from './entities'; | ||
import { EntryFieldAPI } from './field.types'; | ||
import { CollectionResponse, ContentEntitySys, SearchQuery } from './utils'; | ||
declare type TaskState = 'active' | 'resolved'; | ||
import { CollectionResponse, EntrySys, SearchQuery } from './utils'; | ||
type TaskState = 'active' | 'resolved'; | ||
export interface TaskInputData { | ||
@@ -22,3 +22,3 @@ assignedToId: string; | ||
/** Returns sys for an entry. */ | ||
getSys: () => ContentEntitySys; | ||
getSys: () => EntrySys; | ||
/** Publish the entry */ | ||
@@ -33,3 +33,3 @@ publish: (options?: { | ||
/** Calls the callback with sys every time that sys changes. */ | ||
onSysChanged: (callback: (sys: ContentEntitySys) => void) => () => void; | ||
onSysChanged: (callback: (sys: EntrySys) => void) => () => void; | ||
/** Allows to control the values of all other fields in the current entry. */ | ||
@@ -36,0 +36,0 @@ fields: { |
import { ContentTypeFieldValidation } from './entities'; | ||
import type { Items, SerializedJSONValue } from './utils'; | ||
import type { SerializedJSONValue, FieldType, Items, FieldLinkType } from './utils'; | ||
import { ValidationError } from './validation-error'; | ||
export interface FieldAPI { | ||
interface FieldAPIBase { | ||
/** The ID of a field is defined in an entry's content type. */ | ||
id: string; | ||
/** The name of the field */ | ||
name: string; | ||
/** The current locale of a field the app is attached to. */ | ||
locale: string; | ||
/** Holds the type of the field the app is attached to. */ | ||
type: string; | ||
/** Indicates if a value for this field is required */ | ||
@@ -15,4 +15,2 @@ required: boolean; | ||
validations: ContentTypeFieldValidation[]; | ||
/** Defines the shape of array items */ | ||
items?: Items; | ||
/** Gets the current value of the field and locale. */ | ||
@@ -30,10 +28,51 @@ getValue: () => any; | ||
onValueChanged: (callback: (value: any) => void) => () => void; | ||
/** Calls the callback when the disabled status of the field changes. | ||
* the returned function can be called to remove the handler function | ||
**/ | ||
/** | ||
* Returns whether the current field is disabled | ||
* | ||
* The disabled state can change. To always work with the latest state, use `onIsDisabledChanged`. | ||
*/ | ||
getIsDisabled(): boolean; | ||
/** | ||
* Subscribes to changes to this field's disabled state | ||
* | ||
* @param callback Function that is called every time this field's disabled state changes. Called immidiately with the current state. | ||
* @returns Function to unsubscribe. `callback` won't be called anymore. | ||
*/ | ||
onIsDisabledChanged: (callback: (isDisabled: boolean) => void) => () => void; | ||
/** Calls the callback immediately with the current validation errors and whenever the field is re-validated. | ||
* the returned function can be called to remove the handler function | ||
**/ | ||
/** | ||
* Returns the field's validation errors | ||
* | ||
* The schema errors can change. To always work with the latest errors, use `onSchemaErrorsChanged`. | ||
*/ | ||
getSchemaErrors(): ValidationError[]; | ||
/** | ||
* Subscribes to schema errors | ||
* | ||
* @param callback Function that is called every time the schema errors change. Called immediately with the current errors. | ||
* @returns Function to unsubscribe. `callback` won't be called anymore. | ||
*/ | ||
onSchemaErrorsChanged: (callback: (errors: ValidationError[]) => void) => () => void; | ||
} | ||
interface BasicFieldAPI extends FieldAPIBase { | ||
/** Holds the type of the field. */ | ||
type: Exclude<FieldType, 'Array' | 'Link'>; | ||
} | ||
interface ArrayFieldAPI extends FieldAPIBase { | ||
/** Holds the type of the field. */ | ||
type: 'Array'; | ||
/** Defines the shape of array items */ | ||
items: Items; | ||
} | ||
interface LinkFieldAPI extends FieldAPIBase { | ||
/** Holds the type of the field. */ | ||
type: 'Link'; | ||
/** Type of linked resource */ | ||
linkType: FieldLinkType; | ||
} | ||
export interface ExhaustiveFieldAPI extends FieldAPIBase { | ||
type: FieldType; | ||
items?: Items; | ||
linkType?: FieldLinkType; | ||
} | ||
export type FieldAPI = BasicFieldAPI | ArrayFieldAPI | LinkFieldAPI; | ||
export {}; |
@@ -1,31 +0,62 @@ | ||
import { Items, SerializedJSONValue } from './utils'; | ||
import { SerializedJSONValue, FieldType, Items, FieldLinkType } from './utils'; | ||
import { FieldAPI } from './field-locale.types'; | ||
import { ContentTypeFieldValidation } from './entities'; | ||
export interface FieldInfo { | ||
import { ValidationError } from './validation-error'; | ||
interface FieldInfoBase { | ||
id: string; | ||
name: string; | ||
locale: string; | ||
type: string; | ||
required: boolean; | ||
validations: ContentTypeFieldValidation[]; | ||
items?: Items; | ||
value: any; | ||
isDisabled: boolean; | ||
schemaErrors: ValidationError[]; | ||
} | ||
export interface EntryFieldInfo { | ||
interface BasicFieldInfo extends FieldInfoBase { | ||
type: Exclude<FieldType, 'Array' | 'Link'>; | ||
} | ||
interface ArrayFieldInfo extends FieldInfoBase { | ||
type: 'Array'; | ||
items: Items; | ||
} | ||
interface LinkFieldInfo extends FieldInfoBase { | ||
type: 'Link'; | ||
linkType: FieldLinkType; | ||
} | ||
export type FieldInfo = BasicFieldInfo | ArrayFieldInfo | LinkFieldInfo; | ||
interface EntryFieldInfoBase { | ||
id: string; | ||
name: string; | ||
locales: string[]; | ||
type: string; | ||
required: boolean; | ||
validations: ContentTypeFieldValidation[]; | ||
items?: Items; | ||
values: { | ||
[locale: string]: any; | ||
}; | ||
isDisabled: { | ||
[locale: string]: boolean; | ||
}; | ||
schemaErrors: { | ||
[locale: string]: ValidationError[]; | ||
}; | ||
} | ||
export interface EntryFieldAPI { | ||
interface BasicEntryFieldInfo extends EntryFieldInfoBase { | ||
type: Exclude<FieldType, 'Array' | 'Link'>; | ||
} | ||
interface ArrayEntryFieldInfo extends EntryFieldInfoBase { | ||
type: 'Array'; | ||
items: Items; | ||
} | ||
interface LinkEntryFieldInfo extends EntryFieldInfoBase { | ||
type: 'Link'; | ||
linkType: FieldLinkType; | ||
} | ||
export type EntryFieldInfo = BasicEntryFieldInfo | ArrayEntryFieldInfo | LinkEntryFieldInfo; | ||
export interface EntryFieldAPIBase { | ||
/** The ID of a field is defined in an entry's content type. */ | ||
id: string; | ||
/** The name of the field */ | ||
name: string; | ||
/** The list of locales for the field. */ | ||
locales: string[]; | ||
/** Holds the type of the field. */ | ||
type: string; | ||
/** Indicates if a value for this field is required */ | ||
@@ -35,4 +66,2 @@ required: boolean; | ||
validations: ContentTypeFieldValidation[]; | ||
/** Defines the shape of array items */ | ||
items?: Items; | ||
/** Gets the current value of the field and locale. */ | ||
@@ -63,1 +92,24 @@ getValue: (locale?: string) => any; | ||
} | ||
interface BasicEntryFieldAPI extends EntryFieldAPIBase { | ||
/** Holds the type of the field. */ | ||
type: Exclude<FieldType, 'Array' | 'Link'>; | ||
} | ||
interface ArrayEntryFieldAPI extends EntryFieldAPIBase { | ||
/** Holds the type of the field. */ | ||
type: 'Array'; | ||
/** Defines the shape of array items */ | ||
items: Items; | ||
} | ||
interface LinkEntryFieldAPI extends EntryFieldAPIBase { | ||
/** Holds the type of the field. */ | ||
type: 'Link'; | ||
/** Type of linked resource */ | ||
linkType: FieldLinkType; | ||
} | ||
export interface ExhaustiveEntryFieldAPI extends EntryFieldAPIBase { | ||
type: FieldType; | ||
items?: Items; | ||
linkType?: FieldLinkType; | ||
} | ||
export type EntryFieldAPI = BasicEntryFieldAPI | ArrayEntryFieldAPI | LinkEntryFieldAPI; | ||
export {}; |
@@ -1,2 +0,2 @@ | ||
export type { AccessAPI, AppExtensionSDK, ArchiveableAction, BaseExtensionSDK, ConnectMessage, ContentTypeAPI, CrudAction, DialogExtensionSDK, EditorExtensionSDK, EditorLocaleSettings, FieldExtensionSDK, HomeExtensionSDK, IdsAPI, KnownSDK, LocalesAPI, LocationAPI, Locations, NotifierAPI, PageExtensionSDK, ParametersAPI, PublishableAction, SharedEditorSDK, SidebarExtensionSDK, UserAPI, JSONPatchItem, } from './api.types'; | ||
export type { AppExtensionSDK, BaseExtensionSDK, DialogExtensionSDK, EditorExtensionSDK, FieldExtensionSDK, HomeExtensionSDK, KnownSDK, PageExtensionSDK, SidebarExtensionSDK, ConfigAppSDK, BaseAppSDK, DialogAppSDK, EditorAppSDK, FieldAppSDK, HomeAppSDK, KnownAppSDK, PageAppSDK, SidebarAppSDK, AccessAPI, ArchiveableAction, ConnectMessage, ContentTypeAPI, CrudAction, EditorLocaleSettings, IdsAPI, LocalesAPI, LocationAPI, Locations, NotifierAPI, ParametersAPI, PublishableAction, SharedEditorSDK, UserAPI, JSONPatchItem, } from './api.types'; | ||
export type { AppConfigAPI, AppState, OnConfigureHandler, OnConfigureHandlerReturn, } from './app.types'; | ||
@@ -10,4 +10,5 @@ export type { DialogsAPI, EntityDialogOptions, OpenAlertOptions, OpenConfirmOptions, OpenCustomWidgetOptions, } from './dialogs.types'; | ||
export type { SpaceAPI } from './space.types'; | ||
export type { SearchQuery, CollectionResponse, ContentEntitySys, ContentEntityType, Items, Link, WithOptionalId, WithId, SerializedJSONValue, } from './utils'; | ||
export type { SearchQuery, CollectionResponse, EntrySys, ContentEntitySys, ContentEntityType, FieldType, FieldLinkType, Items, Link, WithOptionalId, WithId, SerializedJSONValue, } from './utils'; | ||
export type { DateRangeValidationError, InValidationError, LinkContentTypeValidationError, LinkMimetypeGroupValidationError, NotResolvableValidationError, ProhibitRegexpValidationError, RangeValidationError, RegexpValidationError, RequiredValidationError, SizeValidationError, TypeValidationError, UniqueValidationError, UnknownValidationError, ValidationError, } from './validation-error'; | ||
export type { WindowAPI } from './window.types'; | ||
export type { CMAClient } from './cmaClient.types'; |
@@ -62,3 +62,3 @@ import { Asset, Entry, KeyValueMap } from './entities'; | ||
openAssetsList: () => Promise<void>; | ||
onSlideInNavigation: (fn: (slide: NavigatorSlideInfo) => void) => Function; | ||
onSlideInNavigation: (fn: (slide: NavigatorSlideInfo) => void) => () => void; | ||
} |
import { Asset, CanonicalRequest, ContentType, EditorInterface, ScheduledAction, Tag, Team, User, TagVisibility, KeyValueMap, Entry, QueryOptions, Upload } from './entities'; | ||
import { CollectionResponse, ContentEntityType, Link, WithOptionalId, SearchQuery } from './utils'; | ||
declare type Snapshot<T> = { | ||
type Snapshot<T> = { | ||
sys: { | ||
@@ -5,0 +5,0 @@ space?: Link; |
import { ContentTypeFieldValidation } from './entities'; | ||
declare type Sys = { | ||
type Sys = { | ||
id: string; | ||
@@ -7,8 +7,8 @@ type: string; | ||
}; | ||
declare type Entity = { | ||
type Entity = { | ||
sys: Sys; | ||
[key: string]: any; | ||
}; | ||
declare type Optional<Type, Keys extends keyof Type> = Partial<Type> & Omit<Type, Keys>; | ||
export declare type WithSysWithAtLeastId = { | ||
type Optional<Type, Keys extends keyof Type> = Partial<Type> & Omit<Type, Keys>; | ||
export type WithSysWithAtLeastId = { | ||
sys: { | ||
@@ -19,4 +19,4 @@ id: string; | ||
}; | ||
export declare type WithId<Type extends Entity> = Omit<Type, 'sys'> & WithSysWithAtLeastId; | ||
export declare type WithOptionalId<Type extends Entity> = Optional<Type, 'sys'> | WithId<Type>; | ||
export type WithId<Type extends Entity> = Omit<Type, 'sys'> & WithSysWithAtLeastId; | ||
export type WithOptionalId<Type extends Entity> = Optional<Type, 'sys'> | WithId<Type>; | ||
export interface Link<LinkType = string, Type = string> { | ||
@@ -38,4 +38,4 @@ sys: { | ||
} | ||
export declare type ContentEntityType = 'Entry' | 'Asset' | string; | ||
export interface ContentEntitySys { | ||
export type ContentEntityType = 'Entry' | 'Asset'; | ||
export type ContentEntitySys = { | ||
space: Link; | ||
@@ -58,8 +58,20 @@ id: string; | ||
contentType: Link; | ||
}; | ||
export interface EntrySys extends ContentEntitySys { | ||
type: 'Entry'; | ||
automationTags: Link<'Tag'>[]; | ||
} | ||
export interface Items { | ||
type: string; | ||
linkType?: string; | ||
export type FieldType = 'Symbol' | 'Text' | 'RichText' | 'Number' | 'Integer' | 'Array' | 'Link' | 'Object' | 'Date' | 'Location' | 'Boolean'; | ||
export type FieldLinkType = 'Entry' | 'Asset'; | ||
interface ItemsBase { | ||
validations?: ContentTypeFieldValidation[]; | ||
} | ||
interface LinkItems extends ItemsBase { | ||
type: 'Link'; | ||
linkType: FieldLinkType; | ||
} | ||
interface SymbolItems extends ItemsBase { | ||
type: 'Symbol'; | ||
} | ||
export type Items = SymbolItems | LinkItems; | ||
export interface SearchQuery { | ||
@@ -71,5 +83,5 @@ order?: string; | ||
} | ||
export declare type SerializedJSONValue = null | string | number | boolean | Array<SerializedJSONValue> | { | ||
export type SerializedJSONValue = null | string | number | boolean | Array<SerializedJSONValue> | { | ||
[key: string]: SerializedJSONValue; | ||
}; | ||
export {}; |
@@ -63,2 +63,2 @@ import { Link } from './utils'; | ||
} | ||
export declare type ValidationError = SizeValidationError | RangeValidationError | InValidationError | RequiredValidationError | UniqueValidationError | RegexpValidationError | ProhibitRegexpValidationError | LinkMimetypeGroupValidationError | LinkContentTypeValidationError | DateRangeValidationError | NotResolvableValidationError | UnknownValidationError | TypeValidationError | BaseValidationError; | ||
export type ValidationError = SizeValidationError | RangeValidationError | InValidationError | RequiredValidationError | UniqueValidationError | RegexpValidationError | ProhibitRegexpValidationError | LinkMimetypeGroupValidationError | LinkContentTypeValidationError | DateRangeValidationError | NotResolvableValidationError | UnknownValidationError | TypeValidationError | BaseValidationError; |
@@ -0,0 +0,0 @@ export interface WindowAPI { |
@@ -0,0 +0,0 @@ export interface Deferred<T> { |
import { Channel } from './channel'; | ||
import { WindowAPI } from './types/window.types'; | ||
export default function createWindow(currentGlobal: typeof globalThis, channel: Channel): WindowAPI; |
@@ -1,1 +0,1 @@ | ||
{"name":"contentful-ui-extensions-sdk","description":"SDK to develop custom UI Extension for the Contentful Web App","version":"4.10.0-alpha.4","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.1","@semantic-release/exec":"6.0.3","@semantic-release/git":"10.0.1","@testing-library/dom":"8.17.1","@types/chai-as-promised":"7.1.5","@types/cross-spawn":"6.0.2","@types/fs-extra":"9.0.13","@types/jsdom":"20.0.0","@types/mocha":"9.1.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.6","chai-as-promised":"7.1.1","contentful-management":"10.12.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.0.0","eslint-plugin-react":"7.30.1","eslint-plugin-standard":"5.0.0","fs-extra":"10.1.0","husky":"8.0.1","jsdom":"20.0.0","lint-staged":"13.0.3","mocha":"10.0.0","mocha-junit-reporter":"2.0.2","mocha-multi-reporters":"1.5.1","mochawesome":"7.1.3","mochawesome-merge":"4.2.1","mochawesome-report-generator":"6.2.0","prettier":"2.7.1","rollup":"2.78.0","rollup-plugin-terser":"7.0.2","rollup-plugin-typescript2":"0.32.1","semantic-release":"19.0.3","sinon":"14.0.0","sinon-chai":"3.7.0","ts-mocha":"10.0.0","tslib":"2.4.0","typescript":"4.7.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"}} | ||
{"name":"contentful-ui-extensions-sdk","description":"A JavaScript library to develop custom apps for Contentful","version":"4.10.0-alpha.5","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.3","@semantic-release/exec":"6.0.3","@semantic-release/git":"10.0.1","@testing-library/dom":"9.3.1","@types/chai-as-promised":"7.1.5","@types/cross-spawn":"6.0.2","@types/fs-extra":"11.0.1","@types/jsdom":"21.1.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":"5.60.0","@typescript-eslint/parser":"5.60.0","babel-eslint":"10.1.0","chai":"4.3.7","chai-as-promised":"7.1.1","contentful-management":"10.38.2","cross-spawn":"7.0.3","eslint":"8.43.0","eslint-config-prettier":"8.8.0","eslint-config-standard":"17.1.0","eslint-plugin-import":"2.27.5","eslint-plugin-node":"11.1.0","eslint-plugin-prettier":"4.2.1","eslint-plugin-promise":"6.1.1","eslint-plugin-react":"7.32.2","eslint-plugin-standard":"5.0.0","fs-extra":"11.1.1","husky":"8.0.3","jsdom":"22.1.0","lint-staged":"13.2.2","mocha":"10.2.0","mocha-junit-reporter":"2.2.0","mocha-multi-reporters":"1.5.1","mochawesome":"7.1.3","mochawesome-merge":"4.3.0","mochawesome-report-generator":"6.2.0","prettier":"2.8.8","rollup":"2.79.1","rollup-plugin-terser":"7.0.2","rollup-plugin-typescript2":"0.35.0","semantic-release":"21.0.5","sinon":"15.2.0","sinon-chai":"3.7.0","ts-mocha":"10.0.0","tslib":"2.5.3","typescript":"5.1.3"},"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"}} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
105272
37
1919