contentful-ui-extensions-sdk 4.34.0 → 4.35.0
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.bundled.js +1 -1
- package/dist/cf-extension-api.js +1 -1
- package/dist/entry.d.ts +2 -2
- package/dist/field-locale.d.ts +20 -6
- package/dist/field.d.ts +3 -23
- package/dist/navigator.d.ts +2 -1
- package/dist/types/field-locale.types.d.ts +3 -8
- package/dist/types/field.types.d.ts +9 -14
- package/dist/types/navigator.types.d.ts +2 -0
- 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,require("contentful-management")):"function"==typeof define&&define.amd?define(["exports","contentful-management"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).contentfulExtension={},e.contentfulManagement)}(this,(function(e,t){"use strict";var n=function(e,t){return n=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])},n(e,t)};var 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)};function o(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 i(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(l){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(i=0)),i;)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 i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=t.call(e,i)}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])}}}"function"==typeof SuppressedError&&SuppressedError;var a=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}(),s=function(e){function t(){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,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}(t,e),t.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)},t.prototype.attach=function(t){var n=e.prototype.attach.call(this,t);return t.apply(void 0,this._memoizedArgs),n},t.prototype.getMemoizedArgs=function(){return this._memoizedArgs},t}(a);var l,u=function(){function e(e,t){var n=this;this._messageHandlers={},this._responseHandlers={},this._send=function(e,t){return function(n,r){var o=c.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 a),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}(),c=(l=0,{getMessageId:function(){return l++}});var d=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 s(this._value),this._isDisabledSignal=new s(t.isDisabled),this._schemaErrorsChangedSignal=new s(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 o(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return this._value=e,[4,this._channel.call("setValue",this.id,this.locale,e)];case 1:return[2,t.sent()]}}))}))},e.prototype.removeValue=function(){return o(this,void 0,void 0,(function(){return i(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}(),p=function(){function e(e,t,n){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=n,this._fieldLocales=t.locales.reduce((function(n,o){var i,a=new d(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 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 o(this,void 0,void 0,(function(){return i(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 o(this,void 0,void 0,(function(){return i(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 f(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 h=["getTask","getTasks","createTask","updateTask","deleteTask"];function g(e,t,n,o){var i=t.sys,a=v(i),l=new s(i),u=t.metadata,c=new s(u);e.addHandler("sysChanged",(function(e){a=v(i=e),l.dispatch(i)})),e.addHandler("metadataChanged",(function(e){u=e,c.dispatch(u)}));var d={};return h.forEach((function(t){d[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){if(a)throw new Error('SDK method "publish" is not supported in release context');return e.call("callEntryMethod","publish",[t])},unpublish:function(){if(a)throw new Error('SDK method "unpublish" is not supported in release context');return e.call("callEntryMethod","unpublish")},save:function(){return e.call("callEntryMethod","save")},onSysChanged:function(e){return l.attach(e)},fields:n.reduce((function(e,t){return e[t.id]=o(t),e}),{})},u?{metadata:u}:{}),{getMetadata:function(){return u},onMetadataChanged:function(e){return c.attach(e)}}),d)}function v(e){var t,n;return!!(null===(n=null===(t=null==e?void 0:e.release)||void 0===t?void 0:t.sys)||void 0===n?void 0:n.id)}var y=["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 m(e,t){var n={};return y.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 E=function(e){return"object"!=typeof(t=e)||null===t||Array.isArray(t)?{}:e;var t};function A(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,E(n))}function o(n){var o=E(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=E(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=E(r)).entityType=t,r.multiple=n,e.call("openDialog","entitySelector",r)}}function _(e,t,n){var r=new s(n.localeSettings),o=new s(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 b(e,t){var n=new a;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 w="preInstall",C="postInstall",T=function(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)},I=function(e){return"function"==typeof e},L=function(e){return console.error(e),Promise.resolve(!1)},O=function(e,t,n){if(!I(e))return Promise.resolve(t);var r;try{r=void 0===n?e():e(n)}catch(e){return L(e)}var o,i=r;return T(o=i)&&I(o.then)||(i=Promise.resolve(i)),i.then((function(e){return e instanceof Error?Promise.reject(e):!1!==e&&(T(e)?e:t)}),L).catch(L)};function S(e){var t,n=((t={}).preInstall=null,t.postInstall=null,t),r=function(e,t){if(!I(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===w?O(n[r],{}).then((function(t){return e.send("appHookResult",{stage:r,installationRequestId:o,result:t})})):r===C?O(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(w,e)},onConfigurationCompleted:function(e){r(C,e)}}}var D,N={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"},M=function(e){return function(t){return e.call("CMAAdapterCall",t)}};function H(e){return{makeRequest:M(e)}}function k(e,n){var r;return t.createClient({apiAdapter:H(n)},{type:"plain",defaults:{environmentId:null!==(r=e.environmentAlias)&&void 0!==r?r:e.environment,spaceId:e.space,organizationId:e.organization}})}var P=[x,j,function(e,t){var n=t.field;if(!n)throw new Error('FieldAPI called for location without "field" property defined.');return{field:new d(e,n)}},z,F],R=((D={})[N.LOCATION_ENTRY_FIELD]=P,D[N.LOCATION_ENTRY_FIELD_SIDEBAR]=P,D[N.LOCATION_ENTRY_SIDEBAR]=[x,j,z,F],D[N.LOCATION_ENTRY_EDITOR]=[x,j,z],D[N.LOCATION_DIALOG]=[x,function(e){return{close:function(t){return e.send("closeDialog",t)}}},F],D[N.LOCATION_PAGE]=[x],D[N.LOCATION_HOME]=[x],D[N.LOCATION_APP_CONFIG]=[x,function(e){return{app:S(e)}}],D);function x(e,t){var n=t.user,r=t.parameters,o=t.locales,i=t.ids,a=t.initialContentTypes,s=t.hostnames,l=t.release,u=t.location||N.LOCATION_ENTRY_FIELD;return{cma:k(i,e),cmaAdapter:H(e),location:{is:function(e){return u===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:m(e,a),dialogs:A(e,i),navigator:b(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,hostnames:s,release:l,access:{can:function(t,n,r){return e.call("checkAccess",t,n,r)},canEditAppConfig:function(){return e.call("checkAppConfigAccess")}}}}function F(e,t,n){return{window:f(n,e)}}function z(e,t){return{editor:_(e,t.editorInterface,t.editor)}}function j(e,t){var n=t.locales,r=t.contentType,o=t.entry,i=t.fieldInfo;return{contentType:r,entry:g(e,o,i,(function(t){return new p(e,t,n.default)}))}}var V=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 u(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=c.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(R[t.location]||P).reduce((function(o,i){return r(r({},o),i(e,t,n))}),{})}));e.init=V,e.locations=N,Object.defineProperty(e,"__esModule",{value:!0})})),globalThis.contentfulApp=globalThis.contentfulExtension;
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("contentful-management")):"function"==typeof define&&define.amd?define(["exports","contentful-management"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).contentfulExtension={},e.contentfulManagement)}(this,(function(e,t){"use strict";var n=function(e,t){return n=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])},n(e,t)};function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var o=function(){return o=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},o.apply(this,arguments)};function i(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 a(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(l){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(i=0)),i;)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 i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=t.call(e,i)}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])}}}"function"==typeof SuppressedError&&SuppressedError;var s=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}(),l=function(e){function t(){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 r(t,e),t.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)},t.prototype.attach=function(t){var n=e.prototype.attach.call(this,t);return t.apply(void 0,this._memoizedArgs),n},t.prototype.getMemoizedArgs=function(){return this._memoizedArgs},t}(s);var u,c=function(){function e(e,t){var n=this;this._messageHandlers={},this._responseHandlers={},this._send=function(e,t){return function(n,r){var o=d.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 s),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}(),d=(u=0,{getMessageId:function(){return u++}});var p=function(){function e(e,t){var n=this;this.id=t.id,this.name=t.name,this.locale=t.locale,this.required=t.required,this.validations=t.validations,this._value=t.value,this._valueSignal=new l(this._value),this._isDisabledSignal=new l(t.isDisabled),this._schemaErrorsChangedSignal=new l(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 i(this,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return this._value=e,[4,this._channel.call("setValue",this.id,this.locale,e)];case 1:return[2,t.sent()]}}))}))},e.prototype.removeValue=function(){return i(this,void 0,void 0,(function(){return a(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}(),f=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.type=n.type,r}return r(t,e),t}(p),h=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.type=n.type,r.items=n.items,r}return r(t,e),t}(p),g=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.type=n.type,r.linkType=n.linkType,r}return r(t,e),t}(p);function y(e,t){switch(t.type){case"Link":return new g(e,t);case"Array":return new h(e,t);default:return new f(e,t)}}var v=function(){function e(e,t,n){var r=this;this.id=t.id,this.name=t.name,this.locales=t.locales,this.required=t.required,this.validations=t.validations,this._defaultLocale=n,this._fieldLocales=t.locales.reduce((function(n,i){var a,s=y(e,r.toFieldInfo(t,i));return o(o({},n),((a={})[i]=s,a))}),{}),this.assertHasLocale(n)}return e.prototype.getValue=function(e){return this._getFieldLocale(e).getValue()},e.prototype.setValue=function(e,t){return i(this,void 0,void 0,(function(){return a(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 i(this,void 0,void 0,(function(){return a(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.prototype.toFieldInfo=function(e,t){var n={id:e.id,name:e.name,required:e.required,validations:e.validations,locale:t,value:e.values[t],isDisabled:e.isDisabled[t],schemaErrors:e.schemaErrors[t]};switch(e.type){case"Array":return o(o({},n),{type:e.type,items:e.items});case"Link":return o(o({},n),{type:e.type,linkType:e.linkType});default:return o(o({},n),{type:e.type})}},e}(),m=function(e){function t(t,n,r){var o=e.call(this,t,n,r)||this;return o.type=n.type,o}return r(t,e),t}(v),E=function(e){function t(t,n,r){var o=e.call(this,t,n,r)||this;return o.type=n.type,o.items=n.items,o}return r(t,e),t}(v),A=function(e){function t(t,n,r){var o=e.call(this,t,n,r)||this;return o.type=n.type,o.linkType=n.linkType,o}return r(t,e),t}(v);function _(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 b=["getTask","getTasks","createTask","updateTask","deleteTask"];function w(e,t,n,r){var i=t.sys,a=C(i),s=new l(i),u=t.metadata,c=new l(u);e.addHandler("sysChanged",(function(e){a=C(i=e),s.dispatch(i)})),e.addHandler("metadataChanged",(function(e){u=e,c.dispatch(u)}));var d={};return b.forEach((function(t){d[t]=function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return e.call("callEntryMethod",t,n)}})),o(o(o({getSys:function(){return i},publish:function(t){if(a)throw new Error('SDK method "publish" is not supported in release context');return e.call("callEntryMethod","publish",[t])},unpublish:function(){if(a)throw new Error('SDK method "unpublish" is not supported in release context');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]=r(t),e}),{})},u?{metadata:u}:{}),{getMetadata:function(){return u},onMetadataChanged:function(e){return c.attach(e)}}),d)}function C(e){var t,n;return!!(null===(n=null===(t=null==e?void 0:e.release)||void 0===t?void 0:t.sys)||void 0===n?void 0:n.id)}var T=["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 I(e,t){var n={};return T.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 L=function(e){return"object"!=typeof(t=e)||null===t||Array.isArray(t)?{}:e;var t};function O(e,t){return{openAlert:n.bind(null,"alert"),openConfirm:n.bind(null,"confirm"),openPrompt:n.bind(null,"prompt"),openExtension:r,openCurrentApp:i,openCurrent:function(e){return t.app?i(e):r(o(o({},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,L(n))}function r(n){var r=L(n);if((r=o(o({},r),{id:r.id||t.extension})).id)return e.call("openDialog","extension",r);throw new Error("Extension ID not provided.")}function i(n){if(n=L(n),t.app){var r=o(o({},n),{id:t.app});return e.call("openDialog","app",r)}throw new Error("Not in the app context.")}function a(t,n,r){return(r=L(r)).entityType=t,r.multiple=n,e.call("openDialog","entitySelector",r)}}function S(e,t,n){var r=new l(n.localeSettings),o=new l(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 D(e,t,n){var r=new s;return e.addHandler("navigateSlideIn",(function(e){r.dispatch(e)})),{openEntry:function(t,r){var i=!1;return n&&(i=function(e,t){return t.entities.items.map((function(e){return e.sys.id})).includes(e)}(t,n)),e.call("navigateToContentEntity",o(o({},r),{entityType:"Entry",id:t,entryInRelease:i}))},openNewEntry:function(t,n){return e.call("navigateToContentEntity",o(o({},n),{entityType:"Entry",id:null,contentTypeId:t}))},openBulkEditor:function(t,n){return e.call("navigateToBulkEditor",o({entryId:t},n))},openAsset:function(t,n){return e.call("navigateToContentEntity",o(o({},n),{entityType:"Asset",id:t}))},openNewAsset:function(t){return e.call("navigateToContentEntity",o(o({},t),{entityType:"Asset",id:null}))},openPageExtension:function(n){return e.call("navigateToPage",o({type:"extension",id:t.extension},n))},openCurrentAppPage:function(n){return e.call("navigateToPage",o({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 r.attach(e)}}}var N="preInstall",M="postInstall",H=function(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)},k=function(e){return"function"==typeof e},R=function(e){return console.error(e),Promise.resolve(!1)},P=function(e,t,n){if(!k(e))return Promise.resolve(t);var r;try{r=void 0===n?e():e(n)}catch(e){return R(e)}var o,i=r;return H(o=i)&&k(o.then)||(i=Promise.resolve(i)),i.then((function(e){return e instanceof Error?Promise.reject(e):!1!==e&&(H(e)?e:t)}),R).catch(R)};function x(e){var t,n=((t={}).preInstall=null,t.postInstall=null,t),r=function(e,t){if(!k(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===N?P(n[r],{}).then((function(t){return e.send("appHookResult",{stage:r,installationRequestId:o,result:t})})):r===M?P(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(N,e)},onConfigurationCompleted:function(e){r(M,e)}}}var F,z={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"},j=function(e){return function(t){return e.call("CMAAdapterCall",t)}};function V(e){return{makeRequest:j(e)}}function q(e,n){var r;return t.createClient({apiAdapter:V(n)},{type:"plain",defaults:{environmentId:null!==(r=e.environmentAlias)&&void 0!==r?r:e.environment,spaceId:e.space,organizationId:e.organization}})}var Y=[G,W,function(e,t){var n=t.field;if(!n)throw new Error('FieldAPI called for location without "field" property defined.');return{field:y(e,n)}},U,K],B=((F={})[z.LOCATION_ENTRY_FIELD]=Y,F[z.LOCATION_ENTRY_FIELD_SIDEBAR]=Y,F[z.LOCATION_ENTRY_SIDEBAR]=[G,W,U,K],F[z.LOCATION_ENTRY_EDITOR]=[G,W,U],F[z.LOCATION_DIALOG]=[G,function(e){return{close:function(t){return e.send("closeDialog",t)}}},K],F[z.LOCATION_PAGE]=[G],F[z.LOCATION_HOME]=[G],F[z.LOCATION_APP_CONFIG]=[G,function(e){return{app:x(e)}}],F);function G(e,t){var n=t.user,r=t.parameters,o=t.locales,i=t.ids,a=t.initialContentTypes,s=t.hostnames,l=t.release,u=t.location||z.LOCATION_ENTRY_FIELD;return{cma:q(i,e),cmaAdapter:V(e),location:{is:function(e){return u===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:I(e,a),dialogs:O(e,i),navigator:D(e,i,l),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,hostnames:s,release:l,access:{can:function(t,n,r){return e.call("checkAccess",t,n,r)},canEditAppConfig:function(){return e.call("checkAppConfigAccess")}}}}function K(e,t,n){return{window:_(n,e)}}function U(e,t){return{editor:S(e,t.editorInterface,t.editor)}}function W(e,t){var n=t.locales,r=t.contentType,o=t.entry,i=t.fieldInfo;return{contentType:r,entry:w(e,o,i,(function(t){return function(e,t,n){switch(t.type){case"Array":return new E(e,t,n);case"Link":return new A(e,t,n);default:return new m(e,t,n)}}(e,t,n.default)}))}}var J=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 c(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=d.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(B[t.location]||Y).reduce((function(r,i){return o(o({},r),i(e,t,n))}),{})}));e.init=J,e.locations=z,Object.defineProperty(e,"__esModule",{value:!0})})),globalThis.contentfulApp=globalThis.contentfulExtension;
|
package/dist/entry.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Channel } from './channel';
|
|
2
2
|
import { ConnectMessage, EntryAPI, EntryFieldInfo } from './types';
|
|
3
|
-
import {
|
|
4
|
-
export default function createEntry(channel: Channel, entryData: ConnectMessage['entry'], fieldInfo: EntryFieldInfo[], createEntryField: (info: EntryFieldInfo) =>
|
|
3
|
+
import { EntryFieldAPI } from './types/field.types';
|
|
4
|
+
export default function createEntry(channel: Channel, entryData: ConnectMessage['entry'], fieldInfo: EntryFieldInfo[], createEntryField: (info: EntryFieldInfo) => EntryFieldAPI): EntryAPI;
|
package/dist/field-locale.d.ts
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import { Channel } from './channel';
|
|
2
|
-
import { FieldInfo,
|
|
3
|
-
import {
|
|
2
|
+
import { FieldInfo, FieldLinkType, Items, SerializedJSONValue } from './types';
|
|
3
|
+
import { ArrayFieldAPI, BasicFieldAPI, FieldAPI, LinkFieldAPI } from './types/field-locale.types';
|
|
4
|
+
import { ArrayFieldInfo, BasicFieldInfo, LinkFieldInfo } from './types/field.types';
|
|
4
5
|
import { ValidationError } from './types/validation-error';
|
|
5
|
-
|
|
6
|
+
declare class BaseFieldLocale {
|
|
6
7
|
id: string;
|
|
7
8
|
name: string;
|
|
8
9
|
locale: string;
|
|
9
|
-
type: FieldType;
|
|
10
10
|
required: boolean;
|
|
11
11
|
validations: any[];
|
|
12
|
-
items?: Items;
|
|
13
|
-
linkType?: FieldLinkType;
|
|
14
12
|
private _value;
|
|
15
13
|
private _valueSignal;
|
|
16
14
|
private _isDisabledSignal;
|
|
@@ -27,3 +25,19 @@ export default class FieldLocale implements ExhaustiveFieldAPI {
|
|
|
27
25
|
getSchemaErrors(): ValidationError[];
|
|
28
26
|
onSchemaErrorsChanged(handler: (errors: ValidationError[]) => void): () => boolean;
|
|
29
27
|
}
|
|
28
|
+
export declare class BasicFieldLocale extends BaseFieldLocale implements BasicFieldAPI {
|
|
29
|
+
type: BasicFieldAPI['type'];
|
|
30
|
+
constructor(channel: Channel, info: BasicFieldInfo);
|
|
31
|
+
}
|
|
32
|
+
export declare class ArrayFieldLocale extends BaseFieldLocale implements ArrayFieldAPI {
|
|
33
|
+
type: ArrayFieldAPI['type'];
|
|
34
|
+
items: Items;
|
|
35
|
+
constructor(channel: Channel, info: ArrayFieldInfo);
|
|
36
|
+
}
|
|
37
|
+
export declare class LinkFieldLocale extends BaseFieldLocale implements LinkFieldAPI {
|
|
38
|
+
type: LinkFieldAPI['type'];
|
|
39
|
+
linkType: FieldLinkType;
|
|
40
|
+
constructor(channel: Channel, info: LinkFieldInfo);
|
|
41
|
+
}
|
|
42
|
+
export declare function makeFieldLocale(channel: Channel, info: FieldInfo): FieldAPI;
|
|
43
|
+
export {};
|
package/dist/field.d.ts
CHANGED
|
@@ -1,24 +1,4 @@
|
|
|
1
1
|
import { Channel } from './channel';
|
|
2
|
-
import { EntryFieldInfo
|
|
3
|
-
import {
|
|
4
|
-
export
|
|
5
|
-
private _defaultLocale;
|
|
6
|
-
private _fieldLocales;
|
|
7
|
-
id: string;
|
|
8
|
-
name: string;
|
|
9
|
-
locales: string[];
|
|
10
|
-
type: FieldType;
|
|
11
|
-
required: boolean;
|
|
12
|
-
validations: Object[];
|
|
13
|
-
items?: Items;
|
|
14
|
-
linkType?: FieldLinkType;
|
|
15
|
-
constructor(channel: Channel, info: EntryFieldInfo, defaultLocale: string);
|
|
16
|
-
getValue(locale?: string): any;
|
|
17
|
-
setValue(value: any, locale?: string): Promise<import("./types").SerializedJSONValue | undefined>;
|
|
18
|
-
removeValue(locale?: string): Promise<void>;
|
|
19
|
-
onValueChanged(locale: string | ((value: any) => void), handler?: (value: any) => void): () => void;
|
|
20
|
-
onIsDisabledChanged(locale: string | ((isDisabled: boolean) => void), handler?: (isDisabled: boolean) => void): () => void;
|
|
21
|
-
private _getFieldLocale;
|
|
22
|
-
getForLocale(locale: string): FieldAPI;
|
|
23
|
-
assertHasLocale(locale: string): void;
|
|
24
|
-
}
|
|
2
|
+
import { EntryFieldInfo } from './types';
|
|
3
|
+
import { EntryFieldAPI } from './types/field.types';
|
|
4
|
+
export declare function makeField(channel: Channel, info: EntryFieldInfo, defaultLocale: string): EntryFieldAPI;
|
package/dist/navigator.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { NavigatorAPI, IdsAPI } from './types';
|
|
2
2
|
import { Channel } from './channel';
|
|
3
|
-
|
|
3
|
+
import { ReleaseProps } from 'contentful-management';
|
|
4
|
+
export default function createNavigator(channel: Channel, ids: IdsAPI, release?: ReleaseProps): NavigatorAPI;
|
|
@@ -51,26 +51,21 @@ interface FieldAPIBase {
|
|
|
51
51
|
*/
|
|
52
52
|
onSchemaErrorsChanged: (callback: (errors: ValidationError[]) => void) => () => void;
|
|
53
53
|
}
|
|
54
|
-
interface BasicFieldAPI extends FieldAPIBase {
|
|
54
|
+
export interface BasicFieldAPI extends FieldAPIBase {
|
|
55
55
|
/** Holds the type of the field. */
|
|
56
56
|
type: Exclude<FieldType, 'Array' | 'Link'>;
|
|
57
57
|
}
|
|
58
|
-
interface ArrayFieldAPI extends FieldAPIBase {
|
|
58
|
+
export interface ArrayFieldAPI extends FieldAPIBase {
|
|
59
59
|
/** Holds the type of the field. */
|
|
60
60
|
type: 'Array';
|
|
61
61
|
/** Defines the shape of array items */
|
|
62
62
|
items: Items;
|
|
63
63
|
}
|
|
64
|
-
interface LinkFieldAPI extends FieldAPIBase {
|
|
64
|
+
export interface LinkFieldAPI extends FieldAPIBase {
|
|
65
65
|
/** Holds the type of the field. */
|
|
66
66
|
type: 'Link';
|
|
67
67
|
/** Type of linked resource */
|
|
68
68
|
linkType: FieldLinkType;
|
|
69
69
|
}
|
|
70
|
-
export interface ExhaustiveFieldAPI extends FieldAPIBase {
|
|
71
|
-
type: FieldType;
|
|
72
|
-
items?: Items;
|
|
73
|
-
linkType?: FieldLinkType;
|
|
74
|
-
}
|
|
75
70
|
export type FieldAPI = BasicFieldAPI | ArrayFieldAPI | LinkFieldAPI;
|
|
76
71
|
export {};
|
|
@@ -12,14 +12,14 @@ interface FieldInfoBase {
|
|
|
12
12
|
isDisabled: boolean;
|
|
13
13
|
schemaErrors: ValidationError[];
|
|
14
14
|
}
|
|
15
|
-
interface BasicFieldInfo extends FieldInfoBase {
|
|
15
|
+
export interface BasicFieldInfo extends FieldInfoBase {
|
|
16
16
|
type: Exclude<FieldType, 'Array' | 'Link'>;
|
|
17
17
|
}
|
|
18
|
-
interface ArrayFieldInfo extends FieldInfoBase {
|
|
18
|
+
export interface ArrayFieldInfo extends FieldInfoBase {
|
|
19
19
|
type: 'Array';
|
|
20
20
|
items: Items;
|
|
21
21
|
}
|
|
22
|
-
interface LinkFieldInfo extends FieldInfoBase {
|
|
22
|
+
export interface LinkFieldInfo extends FieldInfoBase {
|
|
23
23
|
type: 'Link';
|
|
24
24
|
linkType: FieldLinkType;
|
|
25
25
|
}
|
|
@@ -40,14 +40,14 @@ interface EntryFieldInfoBase {
|
|
|
40
40
|
[locale: string]: ValidationError[];
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
|
-
interface BasicEntryFieldInfo extends EntryFieldInfoBase {
|
|
43
|
+
export interface BasicEntryFieldInfo extends EntryFieldInfoBase {
|
|
44
44
|
type: Exclude<FieldType, 'Array' | 'Link'>;
|
|
45
45
|
}
|
|
46
|
-
interface ArrayEntryFieldInfo extends EntryFieldInfoBase {
|
|
46
|
+
export interface ArrayEntryFieldInfo extends EntryFieldInfoBase {
|
|
47
47
|
type: 'Array';
|
|
48
48
|
items: Items;
|
|
49
49
|
}
|
|
50
|
-
interface LinkEntryFieldInfo extends EntryFieldInfoBase {
|
|
50
|
+
export interface LinkEntryFieldInfo extends EntryFieldInfoBase {
|
|
51
51
|
type: 'Link';
|
|
52
52
|
linkType: FieldLinkType;
|
|
53
53
|
}
|
|
@@ -88,26 +88,21 @@ export interface EntryFieldAPIBase {
|
|
|
88
88
|
**/
|
|
89
89
|
getForLocale: (locale: string) => FieldAPI;
|
|
90
90
|
}
|
|
91
|
-
interface BasicEntryFieldAPI extends EntryFieldAPIBase {
|
|
91
|
+
export interface BasicEntryFieldAPI extends EntryFieldAPIBase {
|
|
92
92
|
/** Holds the type of the field. */
|
|
93
93
|
type: Exclude<FieldType, 'Array' | 'Link'>;
|
|
94
94
|
}
|
|
95
|
-
interface ArrayEntryFieldAPI extends EntryFieldAPIBase {
|
|
95
|
+
export interface ArrayEntryFieldAPI extends EntryFieldAPIBase {
|
|
96
96
|
/** Holds the type of the field. */
|
|
97
97
|
type: 'Array';
|
|
98
98
|
/** Defines the shape of array items */
|
|
99
99
|
items: Items;
|
|
100
100
|
}
|
|
101
|
-
interface LinkEntryFieldAPI extends EntryFieldAPIBase {
|
|
101
|
+
export interface LinkEntryFieldAPI extends EntryFieldAPIBase {
|
|
102
102
|
/** Holds the type of the field. */
|
|
103
103
|
type: 'Link';
|
|
104
104
|
/** Type of linked resource */
|
|
105
105
|
linkType: FieldLinkType;
|
|
106
106
|
}
|
|
107
|
-
export interface ExhaustiveEntryFieldAPI extends EntryFieldAPIBase {
|
|
108
|
-
type: FieldType;
|
|
109
|
-
items?: Items;
|
|
110
|
-
linkType?: FieldLinkType;
|
|
111
|
-
}
|
|
112
107
|
export type EntryFieldAPI = BasicEntryFieldAPI | ArrayEntryFieldAPI | LinkEntryFieldAPI;
|
|
113
108
|
export {};
|
|
@@ -4,6 +4,8 @@ export interface NavigatorAPIOptions {
|
|
|
4
4
|
slideIn?: boolean | {
|
|
5
5
|
waitForClose: boolean;
|
|
6
6
|
};
|
|
7
|
+
/** If true, the entry will be opened in the release context. */
|
|
8
|
+
entryInRelease?: boolean;
|
|
7
9
|
}
|
|
8
10
|
export interface PageExtensionOptions {
|
|
9
11
|
/** If included, you can navigate to a different page extension. If omitted, you will navigate within the current extension. */
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"contentful-ui-extensions-sdk","description":"A JavaScript library to develop custom apps for Contentful","version":"4.
|
|
1
|
+
{"name":"contentful-ui-extensions-sdk","description":"A JavaScript library to develop custom apps for Contentful","version":"4.35.0","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","unpkg":"dist/cf-extension-api.bundled.js","jsdelivr":"dist/cf-extension-api.bundled.js","types":"dist/index.d.ts","files":["dist/cf-extension-api.js","dist/cf-extension-api.js.map","dist/cf-extension-api.bundled.js","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","lint-staged":"lint-staged"},"dependencies":{"contentful-management":"^11.52.1"},"devDependencies":{"@rollup/plugin-commonjs":"^28.0.0","@rollup/plugin-node-resolve":"^16.0.0","@semantic-release/changelog":"6.0.3","@semantic-release/exec":"7.1.0","@semantic-release/git":"10.0.1","@testing-library/dom":"10.4.0","@types/chai-as-promised":"7.1.8","@types/cross-spawn":"6.0.6","@types/fs-extra":"11.0.4","@types/jsdom":"21.1.7","@types/mocha":"10.0.10","@types/nanoid":"3.0.0","@types/sinon":"^17.0.0","@types/sinon-chai":"^3.2.5","@typescript-eslint/eslint-plugin":"7.18.0","@typescript-eslint/parser":"7.18.0","babel-eslint":"10.1.0","chai":"4.5.0","chai-as-promised":"7.1.2","cross-spawn":"7.0.6","eslint":"8.57.1","eslint-config-prettier":"10.1.8","eslint-config-standard":"17.1.0","eslint-plugin-import":"2.32.0","eslint-plugin-node":"11.1.0","eslint-plugin-prettier":"5.5.3","eslint-plugin-promise":"6.6.0","eslint-plugin-react":"7.37.5","eslint-plugin-standard":"5.0.0","fs-extra":"11.3.0","husky":"9.1.7","jsdom":"26.1.0","lint-staged":"16.1.2","mocha":"11.7.1","mocha-junit-reporter":"2.2.1","mocha-multi-reporters":"1.5.1","mochawesome":"7.1.3","mochawesome-merge":"5.0.0","mochawesome-report-generator":"6.2.0","prettier":"3.6.2","rollup":"2.79.2","rollup-plugin-terser":"7.0.2","rollup-plugin-typescript2":"0.36.0","semantic-release":"24.2.7","sinon":"21.0.0","sinon-chai":"3.7.0","ts-mocha":"11.1.0","tslib":"2.8.1","typescript":"5.8.3"},"lint-staged":{"*.ts":["prettier --write","eslint --fix"],"*.md":["prettier --write"]},"release":{"branches":["main",{"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"]}}
|