@frontastic/common 2.32.0 → 2.33.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/composer.json +1 -1
- package/docs/php/CartApiBundle/Domain/Discount.md +2 -2
- package/docs/php/CartApiBundle/Domain/LineItem/Variant.md +1 -1
- package/docs/php/ShopwareBundle/Domain/CartApi/ShopwareCartApi.md +3 -1
- package/docs/php/WishlistApiBundle/Domain/LineItem/Variant.md +1 -1
- package/package.json +1 -1
- package/src/js/domain/cell.js +6 -0
- package/src/js/frontastic-common.js +1 -1
- package/src/js/notifier.js +5 -0
- package/src/js/types/account/index.ts +22 -0
- package/src/js/types/cart/index.ts +128 -6
- package/src/js/types/cart/lineitem/index.ts +1 -1
- package/src/js/types/content/contentapi/index.ts +9 -0
- package/src/js/types/core/index.ts +26 -0
- package/src/js/types/httpclient/index.ts +18 -0
- package/src/js/types/product/index.ts +64 -0
- package/src/js/types/product/productapi/index.ts +66 -0
- package/src/js/types/project/index.ts +8 -1
- package/src/js/types/replicator/index.ts +19 -1
- package/src/js/types/sapcommercecloud/locale/index.ts +6 -0
- package/src/js/types/shopware/projectconfigapi/index.ts +3 -0
- package/src/js/types/wishlist/index.ts +21 -0
- package/src/js/types/wishlist/lineitem/index.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# common Changelog
|
|
2
2
|
|
|
3
|
+
## `2.33.2` (2022-05-05)
|
|
4
|
+
|
|
5
|
+
* fix(FP-1934): Pagination previous/nextCursor set to null on count 0.
|
|
6
|
+
|
|
7
|
+
## `2.33.1` (2022-04-21)
|
|
8
|
+
|
|
9
|
+
* chore: re-run release process
|
|
10
|
+
|
|
11
|
+
## `2.33.0` (2022-04-21)
|
|
12
|
+
|
|
13
|
+
* fix: add a missing @required statements
|
|
14
|
+
* feat: enhance TypeScript map types
|
|
15
|
+
* fix: correct type hints for translatable text
|
|
16
|
+
|
|
17
|
+
## `2.33.0` (2022-04-21)
|
|
18
|
+
|
|
19
|
+
* fix: add a missing @required statements
|
|
20
|
+
* feat: enhance TypeScript map types
|
|
21
|
+
* fix: correct type hints for translatable text
|
|
22
|
+
|
|
3
23
|
## `2.32.0` (2022-04-13)
|
|
4
24
|
|
|
5
25
|
* fix: rehused cart on api test order
|
package/composer.json
CHANGED
|
@@ -9,8 +9,8 @@ Property|Type|Default|Required|Description
|
|
|
9
9
|
`discountId` | `string` | | *Yes* |
|
|
10
10
|
`code` | `string` | | *Yes* |
|
|
11
11
|
`state` | `string` | | *Yes* |
|
|
12
|
-
`name` |
|
|
13
|
-
`description` |
|
|
12
|
+
`name` | `array<string, string>` | | *Yes* |
|
|
13
|
+
`description` | `array<string, string>` | | - |
|
|
14
14
|
`discountedAmount` | `?int` | | - | Amount discounted.
|
|
15
15
|
`dangerousInnerDiscount` | `mixed` | | - | Access original object from backend
|
|
16
16
|
|
|
@@ -7,6 +7,6 @@
|
|
|
7
7
|
Property|Type|Default|Required|Description
|
|
8
8
|
--------|----|-------|--------|-----------
|
|
9
9
|
`variant` | [`Variant`](../../../ProductApiBundle/Domain/Variant.md) | | - |
|
|
10
|
-
`type` | `string` | `'variant'` |
|
|
10
|
+
`type` | `string` | `'variant'` | *Yes* |
|
|
11
11
|
|
|
12
12
|
Generated with [Frontastic API Docs](https://github.com/FrontasticGmbH/apidocs).
|
|
@@ -20,7 +20,8 @@ public function __construct(
|
|
|
20
20
|
DataMapperResolver $mapperResolver,
|
|
21
21
|
ShopwareProjectConfigApiFactory $projectConfigApiFactory,
|
|
22
22
|
AccountApi $accountApi,
|
|
23
|
-
?string $defaultLanguage
|
|
23
|
+
?string $defaultLanguage,
|
|
24
|
+
?CartCheckoutService $cartCheckoutService = null
|
|
24
25
|
): mixed
|
|
25
26
|
```
|
|
26
27
|
|
|
@@ -32,6 +33,7 @@ Argument|Type|Default|Description
|
|
|
32
33
|
`$projectConfigApiFactory`|[`ShopwareProjectConfigApiFactory`](../ProjectConfigApi/ShopwareProjectConfigApiFactory.md)||
|
|
33
34
|
`$accountApi`|[`AccountApi`](../../../AccountApiBundle/Domain/AccountApi.md)||
|
|
34
35
|
`$defaultLanguage`|`?string`||
|
|
36
|
+
`$cartCheckoutService`|?[`CartCheckoutService`](../../../CartApiBundle/Domain/CartCheckoutService.md)|`null`|
|
|
35
37
|
|
|
36
38
|
Return Value: `mixed`
|
|
37
39
|
|
|
@@ -7,6 +7,6 @@
|
|
|
7
7
|
Property|Type|Default|Required|Description
|
|
8
8
|
--------|----|-------|--------|-----------
|
|
9
9
|
`variant` | [`Variant`](../../../ProductApiBundle/Domain/Variant.md) | | - |
|
|
10
|
-
`type` | `string` | `'variant'` |
|
|
10
|
+
`type` | `string` | `'variant'` | *Yes* |
|
|
11
11
|
|
|
12
12
|
Generated with [Frontastic API Docs](https://github.com/FrontasticGmbH/apidocs).
|
package/package.json
CHANGED
package/src/js/domain/cell.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["frontastic-common"]=t():e["frontastic-common"]=t()}(global,(function(){return function(e){var t={};function n(i){if(t[i])return t[i].exports;var r=t[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(i,r,function(t){return e[t]}.bind(null,r));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=7)}([function(e){e.exports=JSON.parse('{"schema":[{"name":"Value Order","fields":[{"label":"Strip Label Prefix","field":"stripLabelPrefix","type":"boolean","default":false},{"label":"Sort Order","field":"sortOrder","type":"enum","values":[{"value":"sort-undefined","name":"Undefined"},{"value":"sort-ascending","name":"Ascending"},{"value":"sort-descending","name":"Descending"}],"default":"sort-undefined"}]}]}')},function(e){e.exports=JSON.parse('{"schema":[{"name":"Display properties","fields":[{"label":"Highlight menu item","field":"displayHighlightMenuItem","type":"boolean","default":false},{"label":"Highlight category tag","field":"displayHighlightCategoryTag","type":"boolean","default":false},{"label":"Description","field":"displayDescription","type":"string","translatable":true},{"label":"Custom CSS class","field":"displayClassname","type":"string","translatable":false},{"label":"Image","field":"displayMedia","type":"media","options":{"ratio":"4:1"}}]},{"name":"SEO","fields":[{"label":"Title","field":"seoTitle","type":"string","translatable":true},{"label":"Description","field":"seoDescription","type":"string","translatable":true},{"label":"Keywords","field":"seoKeywords","type":"string","translatable":true}]}]}')},function(e){e.exports=JSON.parse('{"schema":[]}')},function(e,t,n){var i=n(4),r=n(6);e.exports=function(e,t,n){var o=t&&n||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var s=(e=e||{}).random||(e.rng||i)();if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,t)for(var a=0;a<16;++a)t[o+a]=s[a];return t||r(s)}},function(e,t,n){var i=n(5);e.exports=function(){return i.randomBytes(16)}},function(e,t){e.exports=require("crypto")},function(e,t){for(var n=[],i=0;i<256;++i)n[i]=(i+256).toString(16).substr(1);e.exports=function(e,t){var i=t||0,r=n;return[r[e[i++]],r[e[i++]],r[e[i++]],r[e[i++]],"-",r[e[i++]],r[e[i++]],"-",r[e[i++]],r[e[i++]],"-",r[e[i++]],r[e[i++]],"-",r[e[i++]],r[e[i++]],r[e[i++]],r[e[i++]],r[e[i++]],r[e[i++]]].join("")}},function(e,t,n){"use strict";function i(e){return"stream"===e||"dataSource"===e}n.r(t);const r=["product","product-list","content","content-list"];function o(e,t,n){return void 0!==e?Boolean(e):"stream"===t&&r.includes(n)}function s(e){if(!Array.isArray(e.fields))return{};let t={};for(let n=0;n<e.fields.length;++n){const i=e.fields[n];if(!i.field)continue;const r=i.type||"text";t[i.field]={field:i.field,type:r,sectionName:e.name||"",values:i.values||[],default:u(r,i.default),validate:i.validate||{},fields:i.fields||null,min:void 0===i.min?1:i.min,max:i.max||16,required:o(i.required,r,i.streamType),disabled:!0===i.disabled,translatable:i.translatable}}return t}function a(e,t){let n=e.default;if(void 0!==t[e.field]&&null!==t[e.field]&&(n=t[e.field]),"group"===e.type){let t=(n||[]).slice(0,e.max);for(let n=t.length;n<e.min;++n)t[n]={};return i=t,r=e.fields,(i||[]).map(e=>{null!==e&&"object"==typeof e||(e={});for(let t of r)void 0!==e[t.field]&&null!==e[t.field]||(e[t.field]=t.default||null);return e})}var i,r;return n}function l(e,t,n,i){("object"!=typeof i||Array.isArray(i))&&(i={});let r={};for(let o of Object.values(e))r[o.field]=c(o,t,n,i);return r}function c(e,t,n,r){const o=r[e.field];if("group"===e.type){const i=s(e);return a(e,t).map((e,t)=>{const r=void 0!==o&&o.length>t?o[t]:{};return l(i,e,n,r)})}if(void 0!==o)return o;const c=a(e,t);return i(e.type)?n[c]||null:c}function u(e,t){if(void 0!==t)return t;switch(e){case"group":return[];case"decimal":case"integer":case"float":case"number":return 0;case"string":case"text":case"markdown":return"";case"json":return"{}";case"boolean":return!1;default:return null}}class d{constructor(e=[],t={}){this.schema=e,this.setConfiguration(t),this.fields={};for(let e=0;e<this.schema.length;++e)this.fields={...this.fields,...s(this.schema[e])}}setConfiguration(e){this.configuration=Array.isArray(e)?{}:e||{}}set(e,t){if(!this.fields[e])throw new Error("Unknown field "+e+" in this configuration schema.");return new d(this.schema,{...this.configuration,[e]:t})}get(e){const t=this.fields[e];return t?a(t,this.configuration):(console.warn("Unknown field "+e+" in this configuration schema."),this.configuration[e]||null)}getField(e){const t=this.fields[e];if(!t)throw new Error("Unknown field "+e+" in this configuration schema.");return t}has(e){return!!this.fields[e]}getSchema(){return this.schema}getConfiguration(){return this.configuration}isFieldRequired(e){return this.getField(e).required}isFieldDisabled(e){return this.getField(e).disabled}hasMissingRequiredValueInField(e,t=!1){const n=this.getField(e),r=this.get(e);return"group"===n.type?r.some(e=>new d([n],e).hasMissingRequiredFieldValues(t)):!!n.required&&((!i(n.type)||!t)&&("reference"===n.type?"object"!=typeof r||null===r||"string"!=typeof r.type||""===r.type||"string"!=typeof r.target||""===r.target:i(n.type)&&r||"media"===n.type&&r||"string"===n.type&&n.translatable&&r?Object.values(r).some(e=>!e):null==r||""===r))}hasMissingRequiredFieldValues(e=!1){return Object.keys(this.fields).some(t=>this.hasMissingRequiredValueInField(t,e))}hasMissingRequiredFieldValuesInSection(e,t=!1){return Object.entries(this.fields).some(([n,i])=>i.sectionName===e&&this.hasMissingRequiredValueInField(n,t))}getConfigurationWithResolvedStreams(e={},t={}){return l(this.fields,this.configuration,e,t)}}var f=d,h={NodeConfigurationSchema:n(1),CellConfigurationSchema:n(2)},g=n(3),m=n.n(g),p=function(){return m()()},y=function(e,t,n){if(!e||"object"!=typeof e)return{text:e,locale:t};if(e[t])return{text:e[t],locale:t};if(e[n])return{text:e[n],locale:n};if(!Object.keys(e).length)return{text:"",locale:null,translated:!1};let i=Object.keys(e)[0];return{text:e[i]||"",locale:i,translated:!1}};const b=e=>{switch(e){case"string":case"text":case"markdown":case"json":return!0;default:return!1}},w=e=>void 0!==e.translatable?e.translatable:b(e.type);let v=function(e){return e=(e+"").toString(),encodeURIComponent(e).replace(/!/g,"%21").replace(/'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/\*/g,"%2A").replace(/%20/g,"+")};var I=function(e,t,n){let i,r,o=[],s=function(e,t,n){let i,r=[];if(!0===t?t="1":!1===t&&(t="0"),null!=t){if("object"==typeof t){for(i in t)null!=t[i]&&r.push(s(e+"["+i+"]",t[i],n));return r.join(n)}if("function"!=typeof t)return v(e)+"="+v(t);throw new Error("There was an error processing for httpBuildQuery().")}return""};for(r in n||(n="&"),e){i=e[r],t&&!isNaN(r)&&(r=String(t)+r);let a=s(r,i,n);""!==a&&o.push(a)}return o.join(n)};let k=function(e){if("object"!=typeof e)return!1;let t=0;for(let n of Object.keys(e))if(+n!=t++)return!1;return!0},S=function(e){for(let[t,n]of Object.entries(e))n&&"object"==typeof n&&(e[t]=S(n)),k(n)&&(e[t]=Object.values(n));return e};var x=function(e){let t={};return function(e,t){var n,i,r,o,s,a,l,c,u,d,f,h,g,m=String(e).replace(/^&/,"").replace(/&$/,"").split("&"),p=m.length,y=function(e){return decodeURIComponent(e.replace(/\+/g,"%20"))};for(t||(t=this.window),n=0;n<p;n++){for(u=y((c=m[n].split("="))[0]),d=c.length<2?"":y(c[1]);" "===u.charAt(0);)u=u.slice(1);if(u.indexOf("\0")>-1&&(u=u.slice(0,u.indexOf("\0"))),u&&"["!==u.charAt(0)){for(h=[],f=0,i=0;i<u.length;i++)if("["!==u.charAt(i)||f){if("]"===u.charAt(i)&&f&&(h.length||h.push(u.slice(0,f-1)),h.push(u.substr(f,i-f)),f=0,"["!==u.charAt(i+1)))break}else f=i+1;for(h.length||(h=[u]),i=0;i<h[0].length&&(" "!==(l=h[0].charAt(i))&&"."!==l&&"["!==l||(h[0]=h[0].substr(0,i)+"_"+h[0].substr(i+1)),"["!==l);i++);for(a=t,i=0,g=h.length;i<g;i++)if(u=h[i].replace(/^['"]/,"").replace(/['"]$/,""),i!==h.length-1,s=a,""!==u&&" "!==u||0===i)void 0===a[u]&&(a[u]={}),a=a[u];else{for(o in r=-1,a)a.hasOwnProperty(o)&&+o>r&&o.match(/^\d+$/g)&&(r=+o);u=r+1}s[u]=d}}}(e,t),t=S(t),t};const C=Boolean("undefined"==typeof window||!window.location.hostname||"localhost"===window.location.hostname||"[::1]"===window.location.hostname||window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/));function T(){if("serviceWorker"in navigator){const e=process.env.PUBLIC_URL||"/";if(new URL(e,window.location).origin!==window.location.origin)return;window.addEventListener("load",()=>{const e="/service-worker.js";C?function(e){fetch(e).then(t=>{404===t.status||-1===t.headers.get("content-type").indexOf("javascript")?navigator.serviceWorker.ready.then(e=>{e.unregister().then(()=>{window.location.reload()})}):O(e)}).catch(()=>{console.log("No internet connection found. App is running in offline mode.")})}(e):O(e)})}}function O(e){navigator.serviceWorker.register(e).then(e=>{e.onupdatefound=()=>{const t=e.installing;t.onstatechange=()=>{"installed"===t.state&&(navigator.serviceWorker.controller?console.log("New content is available; please refresh."):console.log("Content is cached for offline use."))}}}).catch(e=>{console.error("Error during service worker registration:",e)})}var j=function(){let e,t,n={};if(this.registerCallBack=function(e,t){let i=null;do{i=Math.floor(65536*(1+Math.random())).toString(16).substring(1)}while(i in n);return n[i]={hidden:e,active:t},i},this.removeCallBack=function(e){delete n[e]},"undefined"==typeof document?(e=!1,t=!1):void 0!==document.hidden?(e="hidden",t="visibilitychange"):void 0!==document.mozHidden?(e="mozHidden",t="mozvisibilitychange"):void 0!==document.msHidden?(e="msHidden",t="msvisibilitychange"):void 0!==document.webkitHidden&&(e="webkitHidden",t="webkitvisibilitychange"),e&&t){let i=function(){for(let t of Object.values(n))document[e]?t.hidden():t.active()};void 0===document.addEventListener||void 0===document[e]?console.warn("This feature requires a browser, such as Google Chrome or Firefox, that supports the Page Visibility API."):document.addEventListener(t,i,!1)}},E=[{size:12,name:"1",icon:"looks_one"},{size:6,name:"1/2",icon:"looks_two"},{size:4,name:"1/3",icon:"looks_3"},{size:8,name:"2/3",icon:"looks_3"},{size:3,name:"1/4",icon:"looks_4"},{size:9,name:"3/4",icon:"looks_4"},{size:2,name:"1/6",icon:"looks_6"}];var D=class{constructor(e={}){this.tasticId=e.tasticId||p(),this.tasticType=e.tasticType,this.configuration=e.configuration||{};let t=[{name:"General settings",folded:!0,fields:[{label:"Name",field:"name",type:"string"},{label:"Show on mobile",field:"mobile",type:"boolean",default:!0},{label:"Show on tablet",field:"tablet",type:"boolean",default:!0},{label:"Show on desktop",field:"desktop",type:"boolean",default:!0},{label:"Anchor",field:"tasticId",type:"string",translatable:!1,disabled:!0,default:"#"+this.tasticId}]}];if(e.schema)for(let n=0;n<e.schema.length;++n)t.push(e.schema[n]);this.schema=new f(t,this.configuration)}export(){return{tasticId:this.tasticId,tasticType:this.tasticType,configuration:this.schema.getConfiguration()}}};var F=class{constructor(e={}){if(this.cellId=e.cellId||p(),this.configuration=e.configuration||{},this.customConfiguration=e.customConfiguration||{},this.schema=new f([{name:"General settings",folded:!0,fields:[{label:"Layout element width",field:"size",type:"enum",values:E&&E.map(e=>({name:e.name,value:e.size})),default:12},{label:"Show on mobile",field:"mobile",type:"boolean",default:!0},{label:"Show on tablet",field:"tablet",type:"boolean",default:!0},{label:"Show on desktop",field:"desktop",type:"boolean",default:!0}]}],this.configuration),this.tastics=[],e.tastics&&e.tastics.length)for(let t=0;t<e.tastics.length;++t)this.tastics.push(new D(e.tastics[t]))}addTastic(e,t={},n=[],i=0){const r=new D({tasticType:e,configuration:t,schema:n});return this.tastics.splice(i,0,r),r}getTastic(e){for(let t of this.tastics)if(t.tasticId===e)return t;throw new Error("Could not find component with ID "+e)}getTasticCount(){return this.tastics.length}export(){return{cellId:this.cellId,configuration:this.schema.getConfiguration(),customConfiguration:this.customConfiguration,tastics:this.tastics.map(e=>e.export())}}};var N=class{constructor(e){if(!e.kitDefinitionId)throw new Error("Missing kitDefinitionId in "+JSON.stringify(e));this.kitDefinitionId=e.kitDefinitionId,this.kitId=e.kitId||p(),this.configuration=e.configuration||{}}export(){return{kitId:this.kitId,kitDefinitionId:this.kitDefinitionId,configuration:this.configuration}}};var M=class{constructor(e={}){if(this.regionId=e.regionId||p(),this.configuration=e.configuration||{},this.schema=new f([{name:"Responsive",folded:!0,fields:[{label:"Show on mobile",field:"mobile",type:"boolean",default:!0},{label:"Show on tablet",field:"tablet",type:"boolean",default:!0},{label:"Show on desktop",field:"desktop",type:"boolean",default:!0}]},{name:"Layout",fields:[{label:"Cell direction",field:"flexDirection",type:"enum",default:"row",values:[{value:"row",name:"Row"},{value:"column",name:"Column"},{value:"row-reverse",name:"Row (reversed)"},{value:"column-reverse",name:"Column (reversed)"}]},{label:"Cell wrapping",field:"flexWrap",type:"enum",default:"wrap",values:[{value:"nowrap",name:"No wrapping"},{value:"wrap",name:"Wrap cells"}]},{label:"Justify cells",field:"justifyContent",type:"enum",default:"space-between",values:[{value:"flex-start",name:"Put at beginning"},{value:"flex-end",name:"Put at end"},{value:"center",name:"Center Cells"},{value:"space-between",name:"Space between cells"},{value:"space-around",name:"Space around cells"},{value:"space-even",name:"Evenly spaced cells"}]},{label:"Cell alignment",field:"alignItems",type:"enum",default:"stretch",values:[{value:"flex-start",name:"Align to start"},{value:"flex-end",name:"Align to end"},{value:"center",name:"Center cells"},{value:"stretch",name:"Stretch cells"},{value:"baseline",name:"Align to baseline"}]},{label:"Align multiple cell rows",field:"alignContent",type:"enum",default:"space-between",values:[{value:"flex-start",name:"Put at beginning"},{value:"flex-end",name:"Put at end"},{value:"center",name:"Center rows"},{value:"stretch",name:"Stretch rows"},{value:"space-between",name:"Space between rows"},{value:"space-around",name:"Space around rows"}]}]}],this.configuration),this.elements=[],e.elements&&e.elements.length)for(let t=0;t<e.elements.length;++t)this.addElement(e.elements[t])}addElement(e){if(e.cellId)return this.addCell(e);if(e.kitId)return this.addKit(e);throw new TypeError("Unknown element type: "+JSON.stringify(e))}addCell(e){return this.elements.push(new F(e)),this.elements[this.elements.length-1]}addKit(e){return this.elements.push(new N(e)),this.elements[this.elements.length-1]}getElement(e){const t=Object.keys(e)[0],n=Object.values(e)[0];for(let e of this.elements)if(e[t]===n)return e;throw new Error("Could not find element with ID "+JSON.stringify(n))}getCells(){return this.elements.filter(e=>e instanceof F)}getKits(){return this.elements.filter(e=>e instanceof N)}export(){return{regionId:this.regionId,configuration:this.schema.getConfiguration(),elements:this.elements.map(e=>e.export())}}};var R=class{constructor(e={},t=[],n=[]){this.pageId=e.pageId||null,this.nodes=e.nodes||[],this.layoutId=e.layoutId||"three_rows",this.name=e.name||"Unnamed Page",this.regions={},this.tasticSchemas=(n||[]).map(e=>e.configurationSchema);for(let n=0;n<t.length;++n){let i=t[n];e.regions&&e.regions[i]&&e.regions[i].elements&&e.regions[i].elements.length&&(e.regions[i].elements=this.mapTastics(e.regions[i].elements)),this.createRegion(i,e.regions&&e.regions[i]||{})}}mapTastics(e){for(let t=0;t<e.length;++t){let n=e[t];if(n.cellId&&(n.tastics&&n.tastics.length))for(let e=0;e<n.tastics.length;++e){let t=n.tastics[e];t.schema={schema:[]};for(let e of this.tasticSchemas)if(e.tasticType===t.tasticType){t.schema=e.schema;break}}}return e}createRegion(e,t){t.regionId=e,this.regions[e]=new M(t)}getRegion(e){if(!this.regions[e])throw new Error("Region with identifier "+e+" unknown.");return this.regions[e]}addCell(e,t={}){return this.getRegion(e).addCell({configuration:t})}duplicateCell(e,t){const n=this.addCell(e,t.configuration);return t.tastics.forEach((t,i)=>{this.addTastic(e,n.cellId,t.tasticType,i,t.configuration)}),n}addKit(e,t){return this.getRegion(e).addKit(t)}findElement(e){const t=Object.keys(e)[0],n=Object.values(e)[0];for(let e in this.regions)for(let[i,r]of Object.entries(this.regions[e].elements))if(r[t]===n)return[e,+i];throw new Error("Could not find element with "+JSON.stringify(e))}hasElement(e){try{return!!this.findElement(e)}catch(e){return!1}}getElement(e){let[t,n]=this.findElement(e);return this.regions[t].elements[n]}removeElement(e){let[t,n]=this.findElement(e);this.regions[t].elements.splice(n,1)}moveElement(e,t){if(!this.regions[t.region])throw new Error("Unknown target region "+t.region);let[n,i]=this.findElement(e),r=this.regions[n].elements.splice(i,1)[0];this.regions[t.region].elements.splice(void 0===t.element?this.regions[t.region].elements.length:t.element-(n===t.region&&t.element>i?1:0),0,r)}addTastic(e,t,n,i,r={}){let o=null;for(let e of this.tasticSchemas)if(e.tasticType===n){o=e;break}return this.getRegion(e).getElement({cellId:t}).addTastic(n,r,o,i)}getTastics(){let e=[];return Object.values(this.regions).forEach(t=>{t.getCells().forEach(t=>{e=e.concat(t.tastics)})}),e}findTastic(e){for(let t in this.regions)for(let n=0;n<this.regions[t].elements.length;++n)for(let i in this.regions[t].elements[n].tastics||[]){if(this.regions[t].elements[n].tastics[i].tasticId===e)return[t,+n,+i]}throw new Error("Could not find tastic with id "+e)}hasTastic(e){try{return!!this.findTastic(e)}catch(e){return!1}}getTastic(e){let[t,n,i]=this.findTastic(e);return this.regions[t].elements[n].tastics[i]}removeTastic(e){let[t,n,i]=this.findTastic(e);this.regions[t].elements[n].tastics.splice(i,1)}moveTastic(e,t){let[n,i,r]=this.findTastic(e),o=this.regions[n].elements[i].tastics.splice(r,1)[0],[s,a]=this.findElement({cellId:t.cell});this.regions[s].elements[a].tastics.splice(void 0===t.tasticDropPosition?this.regions[s].elements[a].tastics.length:t.tasticDropPosition-(n===s&&i===a&&t.tasticDropPosition>=r?1:0),0,o)}duplicateTastic(e,t){const[n,,i]=this.findTastic(e),r=this.getTastic(e);return this.addTastic(n,t,r.tasticType,i+1,r.configuration)}export(){let e={};for(let[t,n]of Object.entries(this.regions))e[t]=n.export();return{pageId:this.pageId,nodes:this.nodes,layoutId:this.layoutId,name:this.name,regions:e}}};const P=(e,t,n)=>{n={resourceType:"image",type:"upload",...n};let i=[];for(let[e,t]of Object.entries(n))switch(e){case"secure":case"resourceType":case"type":break;case"background":case"crop":case"fetch_format":case"gravity":case"height":case"quality":case"width":case"x":case"y":t&&i.push(e[0]+"_"+t);break;default:throw new Error("Unhandled image transformation "+e)}return i.sort(),`https://res.cloudinary.com/${t.cloudName}/${n.resourceType}/${n.type}/${i.join(",")}/${r=e,encodeURI(r).replace(/[?=]/g,(function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()}))}`;var r};var A=class{constructor(e){this.configuration={cloudName:e.cloudName}}getImageUrl(e,t,n,i={}){return P(e.mediaId,this.configuration,{fetch_format:e.format&&"svg"===e.format?void 0:"auto",width:t,height:n,secure:!0,...this.getQuality(i),...this.getFetchFormat(i),...this.getGravityOptions(i),...this.cropOptions(i)})}getFetchImageUrl(e,t,n,i={}){return e.startsWith("//")&&(e="https:"+e),P(e,this.configuration,{fetch_format:"auto",type:"fetch",width:t,height:n,secure:!0,...this.getQuality(i),...this.getFetchFormat(i),...this.getGravityOptions(i),...this.cropOptions(i)})}getImageUrlWithoutDefaults(e,t,n,i={}){return P(e.mediaId,this.configuration,{width:t,height:n,...i})}getGravityOptions(e){if(e.crop)return{};let t={gravity:"faces:auto"};return e.gravity&&(t.gravity="custom"===e.gravity.mode?"xy_center":e.gravity.mode,e.gravity.coordinates&&(t.x=e.gravity.coordinates.x,t.y=e.gravity.coordinates.y)),t}cropOptions(e){let t={crop:"fill"};return e.crop&&(t.crop=e.crop),e.background&&(t.background=e.background),t}getQuality(e){let t={quality:"auto"};return e.quality&&(t.quality=e.quality),t}getFetchFormat(e){let t={};return e.fetch_format&&(t.fetch_format=e.fetch_format),e.fetchFormat&&(t.fetch_format=e.fetchFormat),t}};var _=class{constructor(){this.imageSizes=[16,32,64,128,256,512,1024,2048]}getImageDimensions(e,t,n,i=null,r=1){let o=this.getFloatRatio(e,i),s=t&&Math.round(+t*r),a=n&&Math.round(+n*r);return s&&i&&(a=Math.round(s*o)),a&&!s&&i&&(s=Math.round(a/o)),[s,a]}getFloatRatio(e=null,t=null){if(!t&&e&&e.width&&e.height)return e.height/e.width;const n=String(t).match(/([0-9]+):([0-9]+)/);return n?n[2]/n[1]:t}getImageLink(e,t,n,i,r,o={},s=1){let a=this.getMediaApi(t),[l,c]=this.getImageDimensions(e,n,i,r,s),u=l/c;if(["fill","pad"].includes(o.crop)){for(let e=0;e<this.imageSizes.length;++e)if(this.imageSizes[e]>=l){l=this.imageSizes[e];break}c=o.autoHeight?null:Math.ceil(l/u)}return"string"==typeof e?a.getFetchImageUrl(e,l,c,o):a.getImageUrl(e,l,c,o)}getMediaApi(e){switch(e.media.engine){case"cloudinary":return new A(e.media);default:throw new Error("No valid media API found.")}}static getElementDimensions(e){let t=0;if(getComputedStyle){let n=getComputedStyle(e);t+=parseFloat(n.paddingLeft)+parseFloat(n.paddingRight)}return{width:e.clientWidth-t,height:e.clientHeight}}},U=n(0),q={enum:U,localizedEnum:U},z=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>!t.includes(e))),H=(e,t=null)=>{"undefined"!=typeof PRODUCTION&&PRODUCTION||"undefined"==typeof window||!window||!window.document||console.info("%c🗑 %cDeprecation Notice: %s %s","color: gray","color: orange",t?"["+(t.displayName||t.constructor.name)+"]":"",e)},W=(e,t,n=!1)=>{let i=!1;return function(){let r=this,o=arguments,s=function(){i=null,n||e.apply(r,o)},a=n&&!i;clearTimeout(i),i=setTimeout(s,t),a&&e.apply(r,o)}},L=(e,t)=>{let n=!1;return function(){n||(e.apply(this,arguments),n=!0,setTimeout((function(){n=!1}),t))}};var $=class{constructor(e,t={}){if(this.context={customer:"demo",idDebug:!1,endpoint:"preview",...e},this.messageHandlers=t,!this.context.previewId)throw new Error("context.previewId is required");this.webSocket=null,this.connected=!1,this.connectionFails=0,this.connect()}connect(){this.webSocket=new WebSocket((this.context.isDebug?"ws://":"wss://")+this.context.customer+".frontastic.io"+(this.context.isDebug?".local":"")+`:8080/ws?${this.context.endpoint}=${this.context.previewId}`),this.webSocket.onmessage=this.handleMessage.bind(this),this.webSocket.onopen=()=>{this.connectionFails=0,this.connected=!0},this.webSocket.onclose=()=>{this.webSocket=null,this.connected=!1,setTimeout(this.connect.bind(this),1e3*Math.min(++this.connectionFails,30))}}handleMessage(e){let t=JSON.parse(e.data);if("Ping"!==t.Name)return this.messageHandlers[t.Name]?this.messageHandlers[t.Name](t.Payload,t):void console.info("Unknown WebSocket message",t)}sendMessage(e,t=!1){if(e.Channel=this.context.previewId,e.Payload=e.Payload||[],this.connected)return this.webSocket.send(JSON.stringify(e));t&&setTimeout(()=>{this.sendMessage(e,!0)},100)}};n.d(t,"ConfigurationSchema",(function(){return f})),n.d(t,"DefaultSchemas",(function(){return h})),n.d(t,"generateId",(function(){return p})),n.d(t,"getTranslation",(function(){return y})),n.d(t,"httpBuildQuery",(function(){return I})),n.d(t,"httpParseQuery",(function(){return x})),n.d(t,"isTranslatableByDefault",(function(){return b})),n.d(t,"shouldFieldBeTranslated",(function(){return w})),n.d(t,"registerServiceWorker",(function(){return T})),n.d(t,"VisibilityChange",(function(){return j})),n.d(t,"cellDimensions",(function(){return E})),n.d(t,"Cell",(function(){return F})),n.d(t,"Page",(function(){return R})),n.d(t,"Region",(function(){return M})),n.d(t,"Tastic",(function(){return D})),n.d(t,"MediaApi",(function(){return _})),n.d(t,"FacetTypeSchemaMap",(function(){return q})),n.d(t,"omit",(function(){return z})),n.d(t,"deprecate",(function(){return H})),n.d(t,"debounce",(function(){return W})),n.d(t,"throttle",(function(){return L})),n.d(t,"Notifier",(function(){return $}))}])}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["frontastic-common"]=t():e["frontastic-common"]=t()}(global,(function(){return function(e){var t={};function n(i){if(t[i])return t[i].exports;var r=t[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(i,r,function(t){return e[t]}.bind(null,r));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=7)}([function(e){e.exports=JSON.parse('{"schema":[{"name":"Value Order","fields":[{"label":"Strip Label Prefix","field":"stripLabelPrefix","type":"boolean","default":false},{"label":"Sort Order","field":"sortOrder","type":"enum","values":[{"value":"sort-undefined","name":"Undefined"},{"value":"sort-ascending","name":"Ascending"},{"value":"sort-descending","name":"Descending"}],"default":"sort-undefined"}]}]}')},function(e){e.exports=JSON.parse('{"schema":[{"name":"Display properties","fields":[{"label":"Highlight menu item","field":"displayHighlightMenuItem","type":"boolean","default":false},{"label":"Highlight category tag","field":"displayHighlightCategoryTag","type":"boolean","default":false},{"label":"Description","field":"displayDescription","type":"string","translatable":true},{"label":"Custom CSS class","field":"displayClassname","type":"string","translatable":false},{"label":"Image","field":"displayMedia","type":"media","options":{"ratio":"4:1"}}]},{"name":"SEO","fields":[{"label":"Title","field":"seoTitle","type":"string","translatable":true},{"label":"Description","field":"seoDescription","type":"string","translatable":true},{"label":"Keywords","field":"seoKeywords","type":"string","translatable":true}]}]}')},function(e){e.exports=JSON.parse('{"schema":[]}')},function(e,t,n){var i=n(4),r=n(6);e.exports=function(e,t,n){var o=t&&n||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var s=(e=e||{}).random||(e.rng||i)();if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,t)for(var a=0;a<16;++a)t[o+a]=s[a];return t||r(s)}},function(e,t,n){var i=n(5);e.exports=function(){return i.randomBytes(16)}},function(e,t){e.exports=require("crypto")},function(e,t){for(var n=[],i=0;i<256;++i)n[i]=(i+256).toString(16).substr(1);e.exports=function(e,t){var i=t||0,r=n;return[r[e[i++]],r[e[i++]],r[e[i++]],r[e[i++]],"-",r[e[i++]],r[e[i++]],"-",r[e[i++]],r[e[i++]],"-",r[e[i++]],r[e[i++]],"-",r[e[i++]],r[e[i++]],r[e[i++]],r[e[i++]],r[e[i++]],r[e[i++]]].join("")}},function(e,t,n){"use strict";function i(e){return"stream"===e||"dataSource"===e}n.r(t);const r=["product","product-list","content","content-list"];function o(e,t,n){return void 0!==e?Boolean(e):"stream"===t&&r.includes(n)}function s(e){if(!Array.isArray(e.fields))return{};let t={};for(let n=0;n<e.fields.length;++n){const i=e.fields[n];if(!i.field)continue;const r=i.type||"text";t[i.field]={field:i.field,type:r,sectionName:e.name||"",values:i.values||[],default:u(r,i.default),validate:i.validate||{},fields:i.fields||null,min:void 0===i.min?1:i.min,max:i.max||16,required:o(i.required,r,i.streamType),disabled:!0===i.disabled,translatable:i.translatable}}return t}function a(e,t){let n=e.default;if(void 0!==t[e.field]&&null!==t[e.field]&&(n=t[e.field]),"group"===e.type){let t=(n||[]).slice(0,e.max);for(let n=t.length;n<e.min;++n)t[n]={};return i=t,r=e.fields,(i||[]).map(e=>{null!==e&&"object"==typeof e||(e={});for(let t of r)void 0!==e[t.field]&&null!==e[t.field]||(e[t.field]=t.default||null);return e})}var i,r;return n}function l(e,t,n,i){("object"!=typeof i||Array.isArray(i))&&(i={});let r={};for(let o of Object.values(e))r[o.field]=c(o,t,n,i);return r}function c(e,t,n,r){const o=r[e.field];if("group"===e.type){const i=s(e);return a(e,t).map((e,t)=>{const r=void 0!==o&&o.length>t?o[t]:{};return l(i,e,n,r)})}if(void 0!==o)return o;const c=a(e,t);return i(e.type)?n[c]||null:c}function u(e,t){if(void 0!==t)return t;switch(e){case"group":return[];case"decimal":case"integer":case"float":case"number":return 0;case"string":case"text":case"markdown":return"";case"json":return"{}";case"boolean":return!1;default:return null}}class d{constructor(e=[],t={}){this.schema=e,this.setConfiguration(t),this.fields={};for(let e=0;e<this.schema.length;++e)this.fields={...this.fields,...s(this.schema[e])}}setConfiguration(e){this.configuration=Array.isArray(e)?{}:e||{}}set(e,t){if(!this.fields[e])throw new Error("Unknown field "+e+" in this configuration schema.");return new d(this.schema,{...this.configuration,[e]:t})}get(e){const t=this.fields[e];return t?a(t,this.configuration):(console.warn("Unknown field "+e+" in this configuration schema."),this.configuration[e]||null)}getField(e){const t=this.fields[e];if(!t)throw new Error("Unknown field "+e+" in this configuration schema.");return t}has(e){return!!this.fields[e]}getSchema(){return this.schema}getConfiguration(){return this.configuration}isFieldRequired(e){return this.getField(e).required}isFieldDisabled(e){return this.getField(e).disabled}hasMissingRequiredValueInField(e,t=!1){const n=this.getField(e),r=this.get(e);return"group"===n.type?r.some(e=>new d([n],e).hasMissingRequiredFieldValues(t)):!!n.required&&((!i(n.type)||!t)&&("reference"===n.type?"object"!=typeof r||null===r||"string"!=typeof r.type||""===r.type||"string"!=typeof r.target||""===r.target:i(n.type)&&r||"media"===n.type&&r||"string"===n.type&&n.translatable&&r?Object.values(r).some(e=>!e):null==r||""===r))}hasMissingRequiredFieldValues(e=!1){return Object.keys(this.fields).some(t=>this.hasMissingRequiredValueInField(t,e))}hasMissingRequiredFieldValuesInSection(e,t=!1){return Object.entries(this.fields).some(([n,i])=>i.sectionName===e&&this.hasMissingRequiredValueInField(n,t))}getConfigurationWithResolvedStreams(e={},t={}){return l(this.fields,this.configuration,e,t)}}var f=d,h={NodeConfigurationSchema:n(1),CellConfigurationSchema:n(2)},g=n(3),m=n.n(g),p=function(){return m()()},y=function(e,t,n){if(!e||"object"!=typeof e)return{text:e,locale:t};if(e[t])return{text:e[t],locale:t};if(e[n])return{text:e[n],locale:n};if(!Object.keys(e).length)return{text:"",locale:null,translated:!1};let i=Object.keys(e)[0];return{text:e[i]||"",locale:i,translated:!1}};const b=e=>{switch(e){case"string":case"text":case"markdown":case"json":return!0;default:return!1}},w=e=>void 0!==e.translatable?e.translatable:b(e.type);let v=function(e){return e=(e+"").toString(),encodeURIComponent(e).replace(/!/g,"%21").replace(/'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/\*/g,"%2A").replace(/%20/g,"+")};var k=function(e,t,n){let i,r,o=[],s=function(e,t,n){let i,r=[];if(!0===t?t="1":!1===t&&(t="0"),null!=t){if("object"==typeof t){for(i in t)null!=t[i]&&r.push(s(e+"["+i+"]",t[i],n));return r.join(n)}if("function"!=typeof t)return v(e)+"="+v(t);throw new Error("There was an error processing for httpBuildQuery().")}return""};for(r in n||(n="&"),e){i=e[r],t&&!isNaN(r)&&(r=String(t)+r);let a=s(r,i,n);""!==a&&o.push(a)}return o.join(n)};let I=function(e){if("object"!=typeof e)return!1;let t=0;for(let n of Object.keys(e))if(+n!=t++)return!1;return!0},S=function(e){for(let[t,n]of Object.entries(e))n&&"object"==typeof n&&(e[t]=S(n)),I(n)&&(e[t]=Object.values(n));return e};var x=function(e){let t={};return function(e,t){var n,i,r,o,s,a,l,c,u,d,f,h,g,m=String(e).replace(/^&/,"").replace(/&$/,"").split("&"),p=m.length,y=function(e){return decodeURIComponent(e.replace(/\+/g,"%20"))};for(t||(t=this.window),n=0;n<p;n++){for(u=y((c=m[n].split("="))[0]),d=c.length<2?"":y(c[1]);" "===u.charAt(0);)u=u.slice(1);if(u.indexOf("\0")>-1&&(u=u.slice(0,u.indexOf("\0"))),u&&"["!==u.charAt(0)){for(h=[],f=0,i=0;i<u.length;i++)if("["!==u.charAt(i)||f){if("]"===u.charAt(i)&&f&&(h.length||h.push(u.slice(0,f-1)),h.push(u.substr(f,i-f)),f=0,"["!==u.charAt(i+1)))break}else f=i+1;for(h.length||(h=[u]),i=0;i<h[0].length&&(" "!==(l=h[0].charAt(i))&&"."!==l&&"["!==l||(h[0]=h[0].substr(0,i)+"_"+h[0].substr(i+1)),"["!==l);i++);for(a=t,i=0,g=h.length;i<g;i++)if(u=h[i].replace(/^['"]/,"").replace(/['"]$/,""),i!==h.length-1,s=a,""!==u&&" "!==u||0===i)void 0===a[u]&&(a[u]={}),a=a[u];else{for(o in r=-1,a)a.hasOwnProperty(o)&&+o>r&&o.match(/^\d+$/g)&&(r=+o);u=r+1}s[u]=d}}}(e,t),t=S(t),t};const C=Boolean("undefined"==typeof window||!window.location.hostname||"localhost"===window.location.hostname||"[::1]"===window.location.hostname||window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/));function T(){if("serviceWorker"in navigator){const e=process.env.PUBLIC_URL||"/";if(new URL(e,window.location).origin!==window.location.origin)return;window.addEventListener("load",()=>{const e="/service-worker.js";C?function(e){fetch(e).then(t=>{404===t.status||-1===t.headers.get("content-type").indexOf("javascript")?navigator.serviceWorker.ready.then(e=>{e.unregister().then(()=>{window.location.reload()})}):O(e)}).catch(()=>{console.log("No internet connection found. App is running in offline mode.")})}(e):O(e)})}}function O(e){navigator.serviceWorker.register(e).then(e=>{e.onupdatefound=()=>{const t=e.installing;t.onstatechange=()=>{"installed"===t.state&&(navigator.serviceWorker.controller?console.log("New content is available; please refresh."):console.log("Content is cached for offline use."))}}}).catch(e=>{console.error("Error during service worker registration:",e)})}var j=function(){let e,t,n={};if(this.registerCallBack=function(e,t){let i=null;do{i=Math.floor(65536*(1+Math.random())).toString(16).substring(1)}while(i in n);return n[i]={hidden:e,active:t},i},this.removeCallBack=function(e){delete n[e]},"undefined"==typeof document?(e=!1,t=!1):void 0!==document.hidden?(e="hidden",t="visibilitychange"):void 0!==document.mozHidden?(e="mozHidden",t="mozvisibilitychange"):void 0!==document.msHidden?(e="msHidden",t="msvisibilitychange"):void 0!==document.webkitHidden&&(e="webkitHidden",t="webkitvisibilitychange"),e&&t){let i=function(){for(let t of Object.values(n))document[e]?t.hidden():t.active()};void 0===document.addEventListener||void 0===document[e]?console.warn("This feature requires a browser, such as Google Chrome or Firefox, that supports the Page Visibility API."):document.addEventListener(t,i,!1)}},E=[{size:12,name:"1",icon:"looks_one"},{size:6,name:"1/2",icon:"looks_two"},{size:4,name:"1/3",icon:"looks_3"},{size:8,name:"2/3",icon:"looks_3"},{size:3,name:"1/4",icon:"looks_4"},{size:9,name:"3/4",icon:"looks_4"},{size:2,name:"1/6",icon:"looks_6"}];var D=class{constructor(e={}){this.tasticId=e.tasticId||p(),this.tasticType=e.tasticType,this.configuration=e.configuration||{};let t=[{name:"General settings",folded:!0,fields:[{label:"Name",field:"name",type:"string"},{label:"Show on mobile",field:"mobile",type:"boolean",default:!0},{label:"Show on tablet",field:"tablet",type:"boolean",default:!0},{label:"Show on desktop",field:"desktop",type:"boolean",default:!0},{label:"Anchor",field:"tasticId",type:"string",translatable:!1,disabled:!0,default:"#"+this.tasticId}]}];if(e.schema)for(let n=0;n<e.schema.length;++n)t.push(e.schema[n]);this.schema=new f(t,this.configuration)}export(){return{tasticId:this.tasticId,tasticType:this.tasticType,configuration:this.schema.getConfiguration()}}};var F=class{constructor(e={}){if(this.cellId=e.cellId||p(),this.configuration=e.configuration||{},this.customConfiguration=e.customConfiguration||{},this.schema=new f([{name:"General settings",folded:!0,fields:[{label:"Name",field:"name",type:"string",translatable:!0},{label:"Layout element width",field:"size",type:"enum",values:E&&E.map(e=>({name:e.name,value:e.size})),default:12},{label:"Show on mobile",field:"mobile",type:"boolean",default:!0},{label:"Show on tablet",field:"tablet",type:"boolean",default:!0},{label:"Show on desktop",field:"desktop",type:"boolean",default:!0}]}],this.configuration),this.tastics=[],e.tastics&&e.tastics.length)for(let t=0;t<e.tastics.length;++t)this.tastics.push(new D(e.tastics[t]))}addTastic(e,t={},n=[],i=0){const r=new D({tasticType:e,configuration:t,schema:n});return this.tastics.splice(i,0,r),r}getTastic(e){for(let t of this.tastics)if(t.tasticId===e)return t;throw new Error("Could not find component with ID "+e)}getTasticCount(){return this.tastics.length}export(){return{cellId:this.cellId,configuration:this.schema.getConfiguration(),customConfiguration:this.customConfiguration,tastics:this.tastics.map(e=>e.export())}}};var N=class{constructor(e){if(!e.kitDefinitionId)throw new Error("Missing kitDefinitionId in "+JSON.stringify(e));this.kitDefinitionId=e.kitDefinitionId,this.kitId=e.kitId||p(),this.configuration=e.configuration||{}}export(){return{kitId:this.kitId,kitDefinitionId:this.kitDefinitionId,configuration:this.configuration}}};var M=class{constructor(e={}){if(this.regionId=e.regionId||p(),this.configuration=e.configuration||{},this.schema=new f([{name:"Responsive",folded:!0,fields:[{label:"Show on mobile",field:"mobile",type:"boolean",default:!0},{label:"Show on tablet",field:"tablet",type:"boolean",default:!0},{label:"Show on desktop",field:"desktop",type:"boolean",default:!0}]},{name:"Layout",fields:[{label:"Cell direction",field:"flexDirection",type:"enum",default:"row",values:[{value:"row",name:"Row"},{value:"column",name:"Column"},{value:"row-reverse",name:"Row (reversed)"},{value:"column-reverse",name:"Column (reversed)"}]},{label:"Cell wrapping",field:"flexWrap",type:"enum",default:"wrap",values:[{value:"nowrap",name:"No wrapping"},{value:"wrap",name:"Wrap cells"}]},{label:"Justify cells",field:"justifyContent",type:"enum",default:"space-between",values:[{value:"flex-start",name:"Put at beginning"},{value:"flex-end",name:"Put at end"},{value:"center",name:"Center Cells"},{value:"space-between",name:"Space between cells"},{value:"space-around",name:"Space around cells"},{value:"space-even",name:"Evenly spaced cells"}]},{label:"Cell alignment",field:"alignItems",type:"enum",default:"stretch",values:[{value:"flex-start",name:"Align to start"},{value:"flex-end",name:"Align to end"},{value:"center",name:"Center cells"},{value:"stretch",name:"Stretch cells"},{value:"baseline",name:"Align to baseline"}]},{label:"Align multiple cell rows",field:"alignContent",type:"enum",default:"space-between",values:[{value:"flex-start",name:"Put at beginning"},{value:"flex-end",name:"Put at end"},{value:"center",name:"Center rows"},{value:"stretch",name:"Stretch rows"},{value:"space-between",name:"Space between rows"},{value:"space-around",name:"Space around rows"}]}]}],this.configuration),this.elements=[],e.elements&&e.elements.length)for(let t=0;t<e.elements.length;++t)this.addElement(e.elements[t])}addElement(e){if(e.cellId)return this.addCell(e);if(e.kitId)return this.addKit(e);throw new TypeError("Unknown element type: "+JSON.stringify(e))}addCell(e){return this.elements.push(new F(e)),this.elements[this.elements.length-1]}addKit(e){return this.elements.push(new N(e)),this.elements[this.elements.length-1]}getElement(e){const t=Object.keys(e)[0],n=Object.values(e)[0];for(let e of this.elements)if(e[t]===n)return e;throw new Error("Could not find element with ID "+JSON.stringify(n))}getCells(){return this.elements.filter(e=>e instanceof F)}getKits(){return this.elements.filter(e=>e instanceof N)}export(){return{regionId:this.regionId,configuration:this.schema.getConfiguration(),elements:this.elements.map(e=>e.export())}}};var R=class{constructor(e={},t=[],n=[]){this.pageId=e.pageId||null,this.nodes=e.nodes||[],this.layoutId=e.layoutId||"three_rows",this.name=e.name||"Unnamed Page",this.regions={},this.tasticSchemas=(n||[]).map(e=>e.configurationSchema);for(let n=0;n<t.length;++n){let i=t[n];e.regions&&e.regions[i]&&e.regions[i].elements&&e.regions[i].elements.length&&(e.regions[i].elements=this.mapTastics(e.regions[i].elements)),this.createRegion(i,e.regions&&e.regions[i]||{})}}mapTastics(e){for(let t=0;t<e.length;++t){let n=e[t];if(n.cellId&&(n.tastics&&n.tastics.length))for(let e=0;e<n.tastics.length;++e){let t=n.tastics[e];t.schema={schema:[]};for(let e of this.tasticSchemas)if(e.tasticType===t.tasticType){t.schema=e.schema;break}}}return e}createRegion(e,t){t.regionId=e,this.regions[e]=new M(t)}getRegion(e){if(!this.regions[e])throw new Error("Region with identifier "+e+" unknown.");return this.regions[e]}addCell(e,t={}){return this.getRegion(e).addCell({configuration:t})}duplicateCell(e,t){const n=this.addCell(e,t.configuration);return t.tastics.forEach((t,i)=>{this.addTastic(e,n.cellId,t.tasticType,i,t.configuration)}),n}addKit(e,t){return this.getRegion(e).addKit(t)}findElement(e){const t=Object.keys(e)[0],n=Object.values(e)[0];for(let e in this.regions)for(let[i,r]of Object.entries(this.regions[e].elements))if(r[t]===n)return[e,+i];throw new Error("Could not find element with "+JSON.stringify(e))}hasElement(e){try{return!!this.findElement(e)}catch(e){return!1}}getElement(e){let[t,n]=this.findElement(e);return this.regions[t].elements[n]}removeElement(e){let[t,n]=this.findElement(e);this.regions[t].elements.splice(n,1)}moveElement(e,t){if(!this.regions[t.region])throw new Error("Unknown target region "+t.region);let[n,i]=this.findElement(e),r=this.regions[n].elements.splice(i,1)[0];this.regions[t.region].elements.splice(void 0===t.element?this.regions[t.region].elements.length:t.element-(n===t.region&&t.element>i?1:0),0,r)}addTastic(e,t,n,i,r={}){let o=null;for(let e of this.tasticSchemas)if(e.tasticType===n){o=e;break}return this.getRegion(e).getElement({cellId:t}).addTastic(n,r,o,i)}getTastics(){let e=[];return Object.values(this.regions).forEach(t=>{t.getCells().forEach(t=>{e=e.concat(t.tastics)})}),e}findTastic(e){for(let t in this.regions)for(let n=0;n<this.regions[t].elements.length;++n)for(let i in this.regions[t].elements[n].tastics||[]){if(this.regions[t].elements[n].tastics[i].tasticId===e)return[t,+n,+i]}throw new Error("Could not find tastic with id "+e)}hasTastic(e){try{return!!this.findTastic(e)}catch(e){return!1}}getTastic(e){let[t,n,i]=this.findTastic(e);return this.regions[t].elements[n].tastics[i]}removeTastic(e){let[t,n,i]=this.findTastic(e);this.regions[t].elements[n].tastics.splice(i,1)}moveTastic(e,t){let[n,i,r]=this.findTastic(e),o=this.regions[n].elements[i].tastics.splice(r,1)[0],[s,a]=this.findElement({cellId:t.cell});this.regions[s].elements[a].tastics.splice(void 0===t.tasticDropPosition?this.regions[s].elements[a].tastics.length:t.tasticDropPosition-(n===s&&i===a&&t.tasticDropPosition>=r?1:0),0,o)}duplicateTastic(e,t){const[n,,i]=this.findTastic(e),r=this.getTastic(e);return this.addTastic(n,t,r.tasticType,i+1,r.configuration)}export(){let e={};for(let[t,n]of Object.entries(this.regions))e[t]=n.export();return{pageId:this.pageId,nodes:this.nodes,layoutId:this.layoutId,name:this.name,regions:e}}};const P=(e,t,n)=>{n={resourceType:"image",type:"upload",...n};let i=[];for(let[e,t]of Object.entries(n))switch(e){case"secure":case"resourceType":case"type":break;case"background":case"crop":case"fetch_format":case"gravity":case"height":case"quality":case"width":case"x":case"y":t&&i.push(e[0]+"_"+t);break;default:throw new Error("Unhandled image transformation "+e)}return i.sort(),`https://res.cloudinary.com/${t.cloudName}/${n.resourceType}/${n.type}/${i.join(",")}/${r=e,encodeURI(r).replace(/[?=]/g,(function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()}))}`;var r};var A=class{constructor(e){this.configuration={cloudName:e.cloudName}}getImageUrl(e,t,n,i={}){return P(e.mediaId,this.configuration,{fetch_format:e.format&&"svg"===e.format?void 0:"auto",width:t,height:n,secure:!0,...this.getQuality(i),...this.getFetchFormat(i),...this.getGravityOptions(i),...this.cropOptions(i)})}getFetchImageUrl(e,t,n,i={}){return e.startsWith("//")&&(e="https:"+e),P(e,this.configuration,{fetch_format:"auto",type:"fetch",width:t,height:n,secure:!0,...this.getQuality(i),...this.getFetchFormat(i),...this.getGravityOptions(i),...this.cropOptions(i)})}getImageUrlWithoutDefaults(e,t,n,i={}){return P(e.mediaId,this.configuration,{width:t,height:n,...i})}getGravityOptions(e){if(e.crop)return{};let t={gravity:"faces:auto"};return e.gravity&&(t.gravity="custom"===e.gravity.mode?"xy_center":e.gravity.mode,e.gravity.coordinates&&(t.x=e.gravity.coordinates.x,t.y=e.gravity.coordinates.y)),t}cropOptions(e){let t={crop:"fill"};return e.crop&&(t.crop=e.crop),e.background&&(t.background=e.background),t}getQuality(e){let t={quality:"auto"};return e.quality&&(t.quality=e.quality),t}getFetchFormat(e){let t={};return e.fetch_format&&(t.fetch_format=e.fetch_format),e.fetchFormat&&(t.fetch_format=e.fetchFormat),t}};var _=class{constructor(){this.imageSizes=[16,32,64,128,256,512,1024,2048]}getImageDimensions(e,t,n,i=null,r=1){let o=this.getFloatRatio(e,i),s=t&&Math.round(+t*r),a=n&&Math.round(+n*r);return s&&i&&(a=Math.round(s*o)),a&&!s&&i&&(s=Math.round(a/o)),[s,a]}getFloatRatio(e=null,t=null){if(!t&&e&&e.width&&e.height)return e.height/e.width;const n=String(t).match(/([0-9]+):([0-9]+)/);return n?n[2]/n[1]:t}getImageLink(e,t,n,i,r,o={},s=1){let a=this.getMediaApi(t),[l,c]=this.getImageDimensions(e,n,i,r,s),u=l/c;if(["fill","pad"].includes(o.crop)){for(let e=0;e<this.imageSizes.length;++e)if(this.imageSizes[e]>=l){l=this.imageSizes[e];break}c=o.autoHeight?null:Math.ceil(l/u)}return"string"==typeof e?a.getFetchImageUrl(e,l,c,o):a.getImageUrl(e,l,c,o)}getMediaApi(e){switch(e.media.engine){case"cloudinary":return new A(e.media);default:throw new Error("No valid media API found.")}}static getElementDimensions(e){let t=0;if(getComputedStyle){let n=getComputedStyle(e);t+=parseFloat(n.paddingLeft)+parseFloat(n.paddingRight)}return{width:e.clientWidth-t,height:e.clientHeight}}},U=n(0),q={enum:U,localizedEnum:U},z=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>!t.includes(e))),H=(e,t=null)=>{"undefined"!=typeof PRODUCTION&&PRODUCTION||"undefined"==typeof window||!window||!window.document||console.info("%c🗑 %cDeprecation Notice: %s %s","color: gray","color: orange",t?"["+(t.displayName||t.constructor.name)+"]":"",e)},W=(e,t,n=!1)=>{let i=!1;return function(){let r=this,o=arguments,s=function(){i=null,n||e.apply(r,o)},a=n&&!i;clearTimeout(i),i=setTimeout(s,t),a&&e.apply(r,o)}},L=(e,t)=>{let n=!1;return function(){n||(e.apply(this,arguments),n=!0,setTimeout((function(){n=!1}),t))}};var $=class{constructor(e,t={}){if(this.context={customer:"demo",idDebug:!1,endpoint:"preview",...e},this.messageHandlers=t,!this.context.previewId)throw new Error("context.previewId is required");this.webSocket=null,this.connected=!1,this.connectionFails=0,this.connect()}connect(){this.webSocket=new WebSocket((this.context.isDebug?"ws://":"wss://")+this.context.customer+".frontastic.io"+(this.context.isDebug?".local":"")+`:8080/ws?${this.context.endpoint}=${this.context.previewId}`),this.webSocket.onmessage=this.handleMessage.bind(this),this.webSocket.onopen=()=>{this.connectionFails=0,this.connected=!0},this.webSocket.onclose=()=>{this.webSocket=null,this.connected=!1,setTimeout(this.connect.bind(this),1e3*Math.min(++this.connectionFails,30))}}handleMessage(e){let t=JSON.parse(e.data);if("Ping"!==t.Name)return this.messageHandlers[t.Name]?this.messageHandlers[t.Name](t.Payload,t):void console.info("Unknown WebSocket message",t)}sendMessage(e,t=!1){if(e.Channel=this.context.previewId,e.Payload=e.Payload||[],this.connected)return this.webSocket.send(JSON.stringify(e));t&&setTimeout(()=>{this.sendMessage(e,!0)},100)}close(){this.webSocket.onclose=()=>{},this.webSocket.close()}};n.d(t,"ConfigurationSchema",(function(){return f})),n.d(t,"DefaultSchemas",(function(){return h})),n.d(t,"generateId",(function(){return p})),n.d(t,"getTranslation",(function(){return y})),n.d(t,"httpBuildQuery",(function(){return k})),n.d(t,"httpParseQuery",(function(){return x})),n.d(t,"isTranslatableByDefault",(function(){return b})),n.d(t,"shouldFieldBeTranslated",(function(){return w})),n.d(t,"registerServiceWorker",(function(){return T})),n.d(t,"VisibilityChange",(function(){return j})),n.d(t,"cellDimensions",(function(){return E})),n.d(t,"Cell",(function(){return F})),n.d(t,"Page",(function(){return R})),n.d(t,"Region",(function(){return M})),n.d(t,"Tastic",(function(){return D})),n.d(t,"MediaApi",(function(){return _})),n.d(t,"FacetTypeSchemaMap",(function(){return q})),n.d(t,"omit",(function(){return z})),n.d(t,"deprecate",(function(){return H})),n.d(t,"debounce",(function(){return W})),n.d(t,"throttle",(function(){return L})),n.d(t,"Notifier",(function(){return $}))}])}));
|
package/src/js/notifier.js
CHANGED
|
@@ -17,6 +17,16 @@ export interface Account extends CoreApiDataObject {
|
|
|
17
17
|
tokenValidUntil?: any /* \DateTime */;
|
|
18
18
|
addresses: Address[];
|
|
19
19
|
authToken?: string | null;
|
|
20
|
+
apiToken?: string | null;
|
|
21
|
+
/**
|
|
22
|
+
* Access original object from backend
|
|
23
|
+
*
|
|
24
|
+
* This should only be used if you need very specific features
|
|
25
|
+
* right NOW. Please notify Frontastic about your need so that
|
|
26
|
+
* we can integrate those twith the common API. Any usage off
|
|
27
|
+
* this property might make your code unstable against future
|
|
28
|
+
* changes.
|
|
29
|
+
*/
|
|
20
30
|
dangerousInnerAccount?: any;
|
|
21
31
|
}
|
|
22
32
|
|
|
@@ -31,11 +41,23 @@ export interface Address extends CoreApiDataObject {
|
|
|
31
41
|
additionalAddressInfo?: string;
|
|
32
42
|
postalCode?: string;
|
|
33
43
|
city?: string;
|
|
44
|
+
/**
|
|
45
|
+
* 2 letter ISO code (https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)
|
|
46
|
+
*/
|
|
34
47
|
country?: string;
|
|
35
48
|
state?: string;
|
|
36
49
|
phone?: string;
|
|
37
50
|
isDefaultBillingAddress?: boolean;
|
|
38
51
|
isDefaultShippingAddress?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Access original object from backend.
|
|
54
|
+
*
|
|
55
|
+
* This should only be used if you need very specific features
|
|
56
|
+
* right NOW. Please notify Frontastic about your need so that
|
|
57
|
+
* we can integrate those with the common API. Any usage off
|
|
58
|
+
* this property might make your code unstable against future
|
|
59
|
+
* changes.
|
|
60
|
+
*/
|
|
39
61
|
dangerousInnerAddress?: any;
|
|
40
62
|
}
|
|
41
63
|
|
|
@@ -8,10 +8,6 @@ import {
|
|
|
8
8
|
Address as AccountAddress,
|
|
9
9
|
} from '../account/'
|
|
10
10
|
|
|
11
|
-
import {
|
|
12
|
-
Translatable as Translatable,
|
|
13
|
-
} from '../'
|
|
14
|
-
|
|
15
11
|
export interface Cart extends CoreApiDataObject {
|
|
16
12
|
cartId: string;
|
|
17
13
|
cartVersion?: string;
|
|
@@ -27,6 +23,15 @@ export interface Cart extends CoreApiDataObject {
|
|
|
27
23
|
payments: Payment[];
|
|
28
24
|
discountCodes: Discount[];
|
|
29
25
|
taxed?: null | Tax;
|
|
26
|
+
/**
|
|
27
|
+
* Access original object from backend
|
|
28
|
+
*
|
|
29
|
+
* This should only be used if you need very specific features
|
|
30
|
+
* right NOW. Please notify Frontastic about your need so that
|
|
31
|
+
* we can integrate those twith the common API. Any usage off
|
|
32
|
+
* this property might make your code unstable against future
|
|
33
|
+
* changes.
|
|
34
|
+
*/
|
|
30
35
|
dangerousInnerCart?: any;
|
|
31
36
|
}
|
|
32
37
|
|
|
@@ -34,9 +39,24 @@ export interface Discount extends CoreApiDataObject {
|
|
|
34
39
|
discountId: string;
|
|
35
40
|
code: string;
|
|
36
41
|
state: string;
|
|
37
|
-
name:
|
|
38
|
-
description?:
|
|
42
|
+
name: Record<string, string> | [];
|
|
43
|
+
description?: Record<string, string> | [];
|
|
44
|
+
/**
|
|
45
|
+
* Amount discounted.
|
|
46
|
+
*
|
|
47
|
+
* On Cart, the amount discounted in the cart.
|
|
48
|
+
* On LineItem, the amount discounted per single line item.
|
|
49
|
+
*/
|
|
39
50
|
discountedAmount?: null | number;
|
|
51
|
+
/**
|
|
52
|
+
* Access original object from backend
|
|
53
|
+
*
|
|
54
|
+
* This should only be used if you need very specific features
|
|
55
|
+
* right NOW. Please notify Frontastic about your need so that
|
|
56
|
+
* we can integrate those twith the common API. Any usage off
|
|
57
|
+
* this property might make your code unstable against future
|
|
58
|
+
* changes.
|
|
59
|
+
*/
|
|
40
60
|
dangerousInnerDiscount?: any;
|
|
41
61
|
}
|
|
42
62
|
|
|
@@ -45,13 +65,34 @@ export interface LineItem extends CoreApiDataObject {
|
|
|
45
65
|
name?: string;
|
|
46
66
|
type: string;
|
|
47
67
|
count: number;
|
|
68
|
+
/**
|
|
69
|
+
* Price of a single item
|
|
70
|
+
*/
|
|
48
71
|
price: number;
|
|
72
|
+
/**
|
|
73
|
+
* Discounted price per item
|
|
74
|
+
*/
|
|
49
75
|
discountedPrice?: null | number;
|
|
76
|
+
/**
|
|
77
|
+
* Translatable discount texts, if any are applied
|
|
78
|
+
*/
|
|
50
79
|
discountTexts?: any;
|
|
51
80
|
discounts?: Discount[];
|
|
81
|
+
/**
|
|
82
|
+
* Total price, basically $price * $count, also discounted
|
|
83
|
+
*/
|
|
52
84
|
totalPrice: number;
|
|
53
85
|
currency: string;
|
|
54
86
|
isGift: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Access original object from backend
|
|
89
|
+
*
|
|
90
|
+
* This should only be used if you need very specific features
|
|
91
|
+
* right NOW. Please notify Frontastic about your need so that
|
|
92
|
+
* we can integrate those twith the common API. Any usage off
|
|
93
|
+
* this property might make your code unstable against future
|
|
94
|
+
* changes.
|
|
95
|
+
*/
|
|
55
96
|
dangerousInnerItem?: any;
|
|
56
97
|
}
|
|
57
98
|
|
|
@@ -60,40 +101,121 @@ export interface Order extends Cart {
|
|
|
60
101
|
orderVersion?: string;
|
|
61
102
|
orderState?: string;
|
|
62
103
|
createdAt?: any /* \DateTimeImmutable */;
|
|
104
|
+
/**
|
|
105
|
+
* Access original object from backend
|
|
106
|
+
*
|
|
107
|
+
* This should only be used if you need very specific features
|
|
108
|
+
* right NOW. Please notify Frontastic about your need so that
|
|
109
|
+
* we can integrate those twith the common API. Any usage off
|
|
110
|
+
* this property might make your code unstable against future
|
|
111
|
+
* changes.
|
|
112
|
+
*/
|
|
63
113
|
dangerousInnerOrder?: any;
|
|
64
114
|
}
|
|
65
115
|
|
|
66
116
|
export interface Payment extends CoreApiDataObject {
|
|
117
|
+
/**
|
|
118
|
+
* An internal ID to identify this payment
|
|
119
|
+
*/
|
|
67
120
|
id: string;
|
|
121
|
+
/**
|
|
122
|
+
* The name of the payment service provider
|
|
123
|
+
*/
|
|
68
124
|
paymentProvider: string;
|
|
125
|
+
/**
|
|
126
|
+
* The ID used by the payment service provider for this payment
|
|
127
|
+
*/
|
|
69
128
|
paymentId: string;
|
|
129
|
+
/**
|
|
130
|
+
* In cent
|
|
131
|
+
*/
|
|
70
132
|
amount: number;
|
|
71
133
|
currency: string;
|
|
134
|
+
/**
|
|
135
|
+
* A text describing the current status of the payment
|
|
136
|
+
*/
|
|
72
137
|
debug?: string;
|
|
138
|
+
/**
|
|
139
|
+
* One of the `PAYMENT_STATUS_*` constants
|
|
140
|
+
*/
|
|
73
141
|
paymentStatus: string;
|
|
74
142
|
version?: number;
|
|
143
|
+
/**
|
|
144
|
+
* The descriptor of the payment method used for this payment
|
|
145
|
+
*/
|
|
75
146
|
paymentMethod: string;
|
|
147
|
+
/**
|
|
148
|
+
* This data is stored as is by the `CartApi`. The payment integration can use this to store additional data which
|
|
149
|
+
* might be needed later in the payment process.
|
|
150
|
+
*/
|
|
76
151
|
paymentDetails?: any | null;
|
|
77
152
|
}
|
|
78
153
|
|
|
154
|
+
export interface ShippingInfo extends ShippingMethod {
|
|
155
|
+
price: number;
|
|
156
|
+
dangerousInnerShippingInfo?: null | any;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export interface ShippingLocation extends CoreApiDataObject {
|
|
160
|
+
/**
|
|
161
|
+
* 2 letter ISO code (https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)
|
|
162
|
+
*/
|
|
163
|
+
country?: string;
|
|
164
|
+
state?: null | string;
|
|
165
|
+
dangerousInnerShippingLocation?: null | any;
|
|
166
|
+
}
|
|
167
|
+
|
|
79
168
|
export interface ShippingMethod extends CoreApiDataObject {
|
|
80
169
|
shippingMethodId?: string;
|
|
81
170
|
name?: string;
|
|
82
171
|
price?: number;
|
|
172
|
+
/**
|
|
173
|
+
* Localized description of the shipping method.
|
|
174
|
+
*/
|
|
83
175
|
description?: string;
|
|
84
176
|
rates?: null | ShippingRate[];
|
|
85
177
|
dangerousInnerShippingMethod?: null | any;
|
|
86
178
|
}
|
|
87
179
|
|
|
180
|
+
export interface ShippingRate extends CoreApiDataObject {
|
|
181
|
+
/**
|
|
182
|
+
* Identifier of the shipping zone.
|
|
183
|
+
*/
|
|
184
|
+
zoneId?: string;
|
|
185
|
+
name?: string;
|
|
186
|
+
/**
|
|
187
|
+
* Shipping locations this rate applies to.
|
|
188
|
+
*/
|
|
189
|
+
locations?: null | ShippingLocation[];
|
|
190
|
+
/**
|
|
191
|
+
* 3-letter currency code.
|
|
192
|
+
*/
|
|
193
|
+
currency?: string;
|
|
194
|
+
/**
|
|
195
|
+
* Price in minor currency (e.g. Cent).
|
|
196
|
+
*/
|
|
197
|
+
price?: number;
|
|
198
|
+
dangerousInnerShippingRate?: null | any;
|
|
199
|
+
}
|
|
200
|
+
|
|
88
201
|
export interface Tax extends CoreApiDataObject {
|
|
202
|
+
/**
|
|
203
|
+
* Net amount in cent
|
|
204
|
+
*/
|
|
89
205
|
amount: number;
|
|
90
206
|
currency: string;
|
|
91
207
|
taxPortions?: TaxPortion[];
|
|
92
208
|
}
|
|
93
209
|
|
|
94
210
|
export interface TaxPortion extends CoreApiDataObject {
|
|
211
|
+
/**
|
|
212
|
+
* Amount in cent
|
|
213
|
+
*/
|
|
95
214
|
amount?: number;
|
|
96
215
|
currency?: string;
|
|
97
216
|
name?: string;
|
|
217
|
+
/**
|
|
218
|
+
* Rate number in the range [0..1]
|
|
219
|
+
*/
|
|
98
220
|
rate?: number;
|
|
99
221
|
}
|
|
@@ -16,5 +16,14 @@ export interface Content extends CoreApiDataObject {
|
|
|
16
16
|
name: string;
|
|
17
17
|
slug: string;
|
|
18
18
|
attributes: Attribute[];
|
|
19
|
+
/**
|
|
20
|
+
* Access original object from backend
|
|
21
|
+
*
|
|
22
|
+
* This should only be used if you need very specific features
|
|
23
|
+
* right NOW. Please notify Frontastic about your need so that
|
|
24
|
+
* we can integrate those twith the common API. Any usage off
|
|
25
|
+
* this property might make your code unstable against future
|
|
26
|
+
* changes.
|
|
27
|
+
*/
|
|
19
28
|
dangerousInnerContent?: any;
|
|
20
29
|
}
|
|
@@ -1,7 +1,33 @@
|
|
|
1
1
|
// This file is autogenerated – run `ant apidocs` to update it
|
|
2
2
|
|
|
3
3
|
export interface ApiDataObject {
|
|
4
|
+
/**
|
|
5
|
+
* Raw api data from client to backend.
|
|
6
|
+
*
|
|
7
|
+
* This property should not be filled by Frontastic itself, but if can be done only to allow backward compatibility.
|
|
8
|
+
* When present on write access to an API implementation MAY store information in appropriate way. It's up to the
|
|
9
|
+
* client to provide the right format.
|
|
10
|
+
*
|
|
11
|
+
* In a project it can be used to carry custom input from frontend to backend in the following use case:
|
|
12
|
+
*
|
|
13
|
+
* - Transfer raw api data to the backend: Use an API Lifecycle Decorator to map data from $projectSpecificData into
|
|
14
|
+
* $rawApiInput to make the API implementation carry it to the configured backend service, if the API supports it.
|
|
15
|
+
*
|
|
16
|
+
* This property should contain an object (\stdClass or data object) or an array (list).
|
|
17
|
+
*/
|
|
4
18
|
rawApiInput?: any | any;
|
|
19
|
+
/**
|
|
20
|
+
* Access backend data from and to frontend.
|
|
21
|
+
*
|
|
22
|
+
* This should only be used for customization on a project basis. Depending on the option of the access we can find
|
|
23
|
+
* the following use cases:
|
|
24
|
+
*
|
|
25
|
+
* - On write access: the data stored in $projectSpecificData can be used on an API Lifecycle Decorator to map
|
|
26
|
+
* data from $projectSpecificData into $rawApiInput.
|
|
27
|
+
*
|
|
28
|
+
* - On read access: the client can use a API Lifecycle Decorator to map to map data from $dangerousInner*
|
|
29
|
+
* into $projectSpecificData (since $dangerousInner* will be stripped before sending).
|
|
30
|
+
*/
|
|
5
31
|
projectSpecificData?: any;
|
|
6
32
|
}
|
|
7
33
|
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
export interface Configuration {
|
|
4
4
|
options?: Options;
|
|
5
|
+
/**
|
|
6
|
+
* List (not hashmap!) of headers
|
|
7
|
+
*/
|
|
5
8
|
defaultHeaders?: string[];
|
|
6
9
|
signatureSecret?: null | string;
|
|
7
10
|
collectStats?: boolean;
|
|
@@ -9,12 +12,27 @@ export interface Configuration {
|
|
|
9
12
|
}
|
|
10
13
|
|
|
11
14
|
export interface Options {
|
|
15
|
+
/**
|
|
16
|
+
* Timeout for the complete request in seconds
|
|
17
|
+
*/
|
|
12
18
|
timeout?: number | number;
|
|
13
19
|
}
|
|
14
20
|
|
|
15
21
|
export interface Response {
|
|
22
|
+
/**
|
|
23
|
+
* Response HTTP status code
|
|
24
|
+
*/
|
|
16
25
|
status: number;
|
|
26
|
+
/**
|
|
27
|
+
* The HTTP headers from the response as a plain array
|
|
28
|
+
*/
|
|
17
29
|
headers: string[];
|
|
30
|
+
/**
|
|
31
|
+
* Response body
|
|
32
|
+
*/
|
|
18
33
|
body?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Raw HTTP output response
|
|
36
|
+
*/
|
|
19
37
|
rawApiOutput?: any /* \Psr\Http\Message\ResponseInterface */;
|
|
20
38
|
}
|
|
@@ -8,13 +8,34 @@ export interface Category extends CoreApiDataObject {
|
|
|
8
8
|
categoryId: string;
|
|
9
9
|
name: string;
|
|
10
10
|
depth: number;
|
|
11
|
+
/**
|
|
12
|
+
* The materialized id path for this category.
|
|
13
|
+
*/
|
|
11
14
|
path: string;
|
|
12
15
|
slug: string;
|
|
16
|
+
/**
|
|
17
|
+
* Access original object from backend
|
|
18
|
+
*
|
|
19
|
+
* This should only be used if you need very specific features
|
|
20
|
+
* right NOW. Please notify Frontastic about your need so that
|
|
21
|
+
* we can integrate those twith the common API. Any usage off
|
|
22
|
+
* this property might make your code unstable against future
|
|
23
|
+
* changes.
|
|
24
|
+
*/
|
|
13
25
|
dangerousInnerCategory?: any;
|
|
14
26
|
}
|
|
15
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Class Product
|
|
30
|
+
*/
|
|
16
31
|
export interface Product extends CoreApiDataObject {
|
|
17
32
|
productId: string;
|
|
33
|
+
/**
|
|
34
|
+
* The date and time when this product was last changed or `null` if the
|
|
35
|
+
* date is unknown.
|
|
36
|
+
*
|
|
37
|
+
* // TODO: Do we want to start typing properties now that we're on 7.4?
|
|
38
|
+
*/
|
|
18
39
|
changed?: null | any /* \DateTimeImmutable */;
|
|
19
40
|
version?: null | string;
|
|
20
41
|
name: string;
|
|
@@ -22,12 +43,34 @@ export interface Product extends CoreApiDataObject {
|
|
|
22
43
|
description?: string;
|
|
23
44
|
categories?: string[];
|
|
24
45
|
variants: Variant[];
|
|
46
|
+
/**
|
|
47
|
+
* Access original object from backend
|
|
48
|
+
*
|
|
49
|
+
* This should only be used if you need very specific features
|
|
50
|
+
* right NOW. Please notify Frontastic about your need so that
|
|
51
|
+
* we can integrate those twith the common API. Any usage off
|
|
52
|
+
* this property might make your code unstable against future
|
|
53
|
+
* changes.
|
|
54
|
+
*
|
|
55
|
+
* Should only be accessed in lifecycle event listeners,
|
|
56
|
+
* and not in controllers, because ProductApiWithoutInner removes
|
|
57
|
+
* this value before the product is returned to a controller.
|
|
58
|
+
*/
|
|
25
59
|
dangerousInnerProduct?: any;
|
|
26
60
|
}
|
|
27
61
|
|
|
28
62
|
export interface ProductType extends CoreApiDataObject {
|
|
29
63
|
productTypeId: string;
|
|
30
64
|
name: string;
|
|
65
|
+
/**
|
|
66
|
+
* Access original object from backend
|
|
67
|
+
*
|
|
68
|
+
* This should only be used if you need very specific features
|
|
69
|
+
* right NOW. Please notify Frontastic about your need so that
|
|
70
|
+
* we can integrate those twith the common API. Any usage off
|
|
71
|
+
* this property might make your code unstable against future
|
|
72
|
+
* changes.
|
|
73
|
+
*/
|
|
31
74
|
dangerousInnerProductType?: any;
|
|
32
75
|
}
|
|
33
76
|
|
|
@@ -35,12 +78,33 @@ export interface Variant extends CoreApiDataObject {
|
|
|
35
78
|
id: string;
|
|
36
79
|
sku: string;
|
|
37
80
|
groupId?: string;
|
|
81
|
+
/**
|
|
82
|
+
* The product price in cent
|
|
83
|
+
*/
|
|
38
84
|
price: number;
|
|
85
|
+
/**
|
|
86
|
+
* If a discount is applied to the product, this contains the reduced value.
|
|
87
|
+
*/
|
|
39
88
|
discountedPrice?: null | number;
|
|
89
|
+
/**
|
|
90
|
+
* Array of discount descriptions
|
|
91
|
+
*/
|
|
40
92
|
discounts?: any;
|
|
93
|
+
/**
|
|
94
|
+
* A three letter currency code in upper case.
|
|
95
|
+
*/
|
|
41
96
|
currency?: string;
|
|
42
97
|
attributes?: any;
|
|
43
98
|
images?: any;
|
|
44
99
|
isOnStock?: boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Access original object from backend
|
|
102
|
+
*
|
|
103
|
+
* This should only be used if you need very specific features
|
|
104
|
+
* right NOW. Please notify Frontastic about your need so that
|
|
105
|
+
* we can integrate those twith the common API. Any usage off
|
|
106
|
+
* this property might make your code unstable against future
|
|
107
|
+
* changes.
|
|
108
|
+
*/
|
|
45
109
|
dangerousInnerVariant?: any;
|
|
46
110
|
}
|
|
@@ -9,25 +9,88 @@ export interface FacetDefinition extends CoreApiDataObject {
|
|
|
9
9
|
attributeId: string;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Simple utility class to handle locales:
|
|
14
|
+
*
|
|
15
|
+
* language[_territory[.codeset]][@modifier]
|
|
16
|
+
*
|
|
17
|
+
* - de_DE
|
|
18
|
+
* - en_GB@euro
|
|
19
|
+
*/
|
|
12
20
|
export interface Locale extends CoreApiDataObject {
|
|
21
|
+
/**
|
|
22
|
+
* A two or three letter identifier for the language, e.g. fr, de, en …
|
|
23
|
+
*/
|
|
13
24
|
language: string;
|
|
25
|
+
/**
|
|
26
|
+
* A two letter identifier for the territory, e.g. CH, DE, FR …
|
|
27
|
+
*/
|
|
14
28
|
territory: string;
|
|
29
|
+
/**
|
|
30
|
+
* A human readable country identifier.
|
|
31
|
+
*/
|
|
15
32
|
country: string;
|
|
33
|
+
/**
|
|
34
|
+
* A three letter identifier for used currency.
|
|
35
|
+
*/
|
|
16
36
|
currency: string;
|
|
17
37
|
original: string;
|
|
18
38
|
}
|
|
19
39
|
|
|
40
|
+
/**
|
|
41
|
+
* Class PaginatedQuery can be used for both, offset and cursor-based pagination.
|
|
42
|
+
*
|
|
43
|
+
* In general terms, REST APIs use offset pagination whereas GraphQL APIs use cursor-based pagination.
|
|
44
|
+
*
|
|
45
|
+
* Regardless the pagination implemented by your backend of choice, we highly recommend you to use in both cases
|
|
46
|
+
* the property $cursor to store the position where the pagination should start.
|
|
47
|
+
*
|
|
48
|
+
* NOTE: the property $offset will be deprecated in a further commit.
|
|
49
|
+
*/
|
|
20
50
|
export interface PaginatedQuery extends Query {
|
|
51
|
+
/**
|
|
52
|
+
* Optional limit, the default value is <b>24</b>, because it is divisible
|
|
53
|
+
* by 2, 3, 4 & 6 – which are common numbers or products per row in
|
|
54
|
+
* frontends.
|
|
55
|
+
*/
|
|
21
56
|
limit?: number;
|
|
57
|
+
/**
|
|
58
|
+
* Optional start offset, default is <b>0</b>.
|
|
59
|
+
*/
|
|
22
60
|
offset?: number;
|
|
61
|
+
/**
|
|
62
|
+
* Optional item reference where the pagination should start.
|
|
63
|
+
*/
|
|
23
64
|
cursor?: string;
|
|
24
65
|
}
|
|
25
66
|
|
|
26
67
|
export interface Query extends CoreApiDataObject {
|
|
27
68
|
locale?: string;
|
|
69
|
+
/**
|
|
70
|
+
* Access original object from backend
|
|
71
|
+
*
|
|
72
|
+
* This should only be used if you need very specific features
|
|
73
|
+
* right NOW. Please notify Frontastic about your need so that
|
|
74
|
+
* we can integrate those with the common API. Any usage off
|
|
75
|
+
* this property might make your code unstable against future
|
|
76
|
+
* changes.
|
|
77
|
+
*/
|
|
28
78
|
loadDangerousInnerData?: boolean;
|
|
29
79
|
}
|
|
30
80
|
|
|
81
|
+
/**
|
|
82
|
+
* Class Result can be used for both, offset and cursor-based pagination.
|
|
83
|
+
*
|
|
84
|
+
* In general terms, REST APIs use offset pagination whereas GraphQL APIs use cursor-based pagination.
|
|
85
|
+
*
|
|
86
|
+
* Regardless the pagination implemented by your backend of choice, we highly recommend you to use in both cases
|
|
87
|
+
* the property $nextCursor to store the position where the pagination should continue.
|
|
88
|
+
*
|
|
89
|
+
* Additionally, and only for GraphQL APIs, you can use $previousCursor to store the position
|
|
90
|
+
* of the first element to allow backward pagination.
|
|
91
|
+
*
|
|
92
|
+
* NOTE: the property $offset will be deprecated in a further commit.
|
|
93
|
+
*/
|
|
31
94
|
export interface Result extends CoreApiDataObject {
|
|
32
95
|
offset?: number;
|
|
33
96
|
total?: number;
|
|
@@ -36,5 +99,8 @@ export interface Result extends CoreApiDataObject {
|
|
|
36
99
|
count: number;
|
|
37
100
|
items: any;
|
|
38
101
|
facets?: any /* \Frontastic\Common\ProductApiBundle\Domain\ProductApi\Result\Facet */[];
|
|
102
|
+
/**
|
|
103
|
+
* The query used to generate this result (cloned)
|
|
104
|
+
*/
|
|
39
105
|
query: Query;
|
|
40
106
|
}
|
|
@@ -6,7 +6,14 @@ import {
|
|
|
6
6
|
|
|
7
7
|
export interface Attribute extends CoreApiDataObject {
|
|
8
8
|
attributeId: string;
|
|
9
|
+
/**
|
|
10
|
+
* TYPE_*
|
|
11
|
+
*/
|
|
9
12
|
type: string;
|
|
10
|
-
|
|
13
|
+
/**
|
|
14
|
+
* The labels with the locale as key and the actual label as value. `null`
|
|
15
|
+
* if the label is unknown
|
|
16
|
+
*/
|
|
17
|
+
label?: Record<string, string> | [] | null;
|
|
11
18
|
values?: null | any;
|
|
12
19
|
}
|
|
@@ -12,8 +12,18 @@ export interface Customer {
|
|
|
12
12
|
secret: string;
|
|
13
13
|
edition: string;
|
|
14
14
|
hasPaasModifications: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Number of available Frontastic Machines
|
|
17
|
+
*/
|
|
15
18
|
machineLimit: number;
|
|
19
|
+
/**
|
|
20
|
+
* Frontastic Machines Map to define providers use in each region
|
|
21
|
+
*/
|
|
22
|
+
machineRegionToProviderMap: any;
|
|
16
23
|
features: any;
|
|
24
|
+
/**
|
|
25
|
+
* Used to indicate this customer is only "half" configured or similar.
|
|
26
|
+
*/
|
|
17
27
|
isTransient: boolean;
|
|
18
28
|
configuration: any;
|
|
19
29
|
environments: any;
|
|
@@ -31,12 +41,20 @@ export interface Project {
|
|
|
31
41
|
projectId: string;
|
|
32
42
|
name: string;
|
|
33
43
|
customer: string;
|
|
44
|
+
/**
|
|
45
|
+
* In the config this is the `secret`.
|
|
46
|
+
*/
|
|
34
47
|
apiKey: string;
|
|
35
|
-
previewUrl
|
|
48
|
+
previewUrl?: string;
|
|
49
|
+
preview?: any;
|
|
36
50
|
publicUrl: string;
|
|
37
51
|
webpackPort: number;
|
|
38
52
|
ssrPort: number;
|
|
39
53
|
configuration: any;
|
|
54
|
+
/**
|
|
55
|
+
* Additional external project data from sources like tideways. Does not
|
|
56
|
+
* follow any defined schema.
|
|
57
|
+
*/
|
|
40
58
|
data: any;
|
|
41
59
|
languages: string[];
|
|
42
60
|
defaultLanguage: string;
|
|
@@ -10,9 +10,21 @@ export interface LineItem extends CoreApiDataObject {
|
|
|
10
10
|
type: string;
|
|
11
11
|
addedAt: any /* \DateTimeImmutable */;
|
|
12
12
|
count: number;
|
|
13
|
+
/**
|
|
14
|
+
* Access original object from backend
|
|
15
|
+
*
|
|
16
|
+
* This should only be used if you need very specific features
|
|
17
|
+
* right NOW. Please notify Frontastic about your need so that
|
|
18
|
+
* we can integrate those twith the common API. Any usage off
|
|
19
|
+
* this property might make your code unstable against future
|
|
20
|
+
* changes.
|
|
21
|
+
*/
|
|
13
22
|
dangerousInnerItem?: any;
|
|
14
23
|
}
|
|
15
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Class Wishlist
|
|
27
|
+
*/
|
|
16
28
|
export interface Wishlist extends CoreApiDataObject {
|
|
17
29
|
wishlistId: string;
|
|
18
30
|
wishlistVersion?: string;
|
|
@@ -20,5 +32,14 @@ export interface Wishlist extends CoreApiDataObject {
|
|
|
20
32
|
accountId?: string;
|
|
21
33
|
name: string[];
|
|
22
34
|
lineItems: LineItem[];
|
|
35
|
+
/**
|
|
36
|
+
* Access original object from backend
|
|
37
|
+
*
|
|
38
|
+
* This should only be used if you need very specific features
|
|
39
|
+
* right NOW. Please notify Frontastic about your need so that
|
|
40
|
+
* we can integrate those twith the common API. Any usage off
|
|
41
|
+
* this property might make your code unstable against future
|
|
42
|
+
* changes.
|
|
43
|
+
*/
|
|
23
44
|
dangerousInnerWishlist?: any;
|
|
24
45
|
}
|