@frontastic/common 2.42.0 → 2.42.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/build.xml +0 -2
- package/composer.json +1 -1
- package/docs/README.md +3 -0
- package/docs/php/SpecificationBundle/Domain/DataSourceSchemaSpecParser.md +19 -0
- package/docs/php/SpecificationBundle/Domain/DynamicFiltersResponseSpecParser.md +19 -0
- package/docs/php/SpecificationBundle/Domain/JsonSchemaValidator.md +2 -2
- package/docs/php/SpecificationBundle/Domain/SchemaError.md +13 -0
- package/package.json +4 -3
- package/src/ant/javascript.xml +9 -6
- package/src/js/configuration/schema.js +2 -0
- package/src/js/frontastic-common.js +1 -1
- package/src/js/generateId.js +1 -1
- package/src/json/dataSourceResultSchema.json +27 -0
- package/src/json/dynamicFiltersResponseSchema.json +72 -0
- package/src/json/library/common.json +12 -4
- package/src/json/library/implications.json +26 -1
- package/src/json/tasticSchema.json +8 -4
package/CHANGELOG.md
CHANGED
package/build.xml
CHANGED
|
@@ -25,8 +25,6 @@
|
|
|
25
25
|
<import file="${frontastic_basedir}/paas/integration/build-commons/modules/composer.xml" />
|
|
26
26
|
<import file="${frontastic_basedir}/paas/integration/build-commons/modules/phpunit.xml" />
|
|
27
27
|
<import file="${frontastic_basedir}/paas/integration/build-commons/modules/checkstyle.xml" />
|
|
28
|
-
<import file="${frontastic_basedir}/paas/integration/build-commons/modules/pdepend.xml" />
|
|
29
|
-
<import file="${frontastic_basedir}/paas/integration/build-commons/modules/phpmd.xml" />
|
|
30
28
|
<import file="${frontastic_basedir}/paas/integration/build-commons/modules/phpstan.xml" />
|
|
31
29
|
<import file="${frontastic_basedir}/paas/integration/build-commons/modules/apidocs.xml" />
|
|
32
30
|
<import file="${basedir}/src/ant/javascript.xml" />
|
package/composer.json
CHANGED
package/docs/README.md
CHANGED
|
@@ -372,7 +372,9 @@ Here you find the API documentation for the relevant classes:
|
|
|
372
372
|
* [CustomAppSpecParser](php/SpecificationBundle/Domain/CustomAppSpecParser.md)
|
|
373
373
|
* [CustomDataSourceSpecParser](php/SpecificationBundle/Domain/CustomDataSourceSpecParser.md)
|
|
374
374
|
* [CustomStreamSpecParser](php/SpecificationBundle/Domain/CustomStreamSpecParser.md)
|
|
375
|
+
* [DataSourceSchemaSpecParser](php/SpecificationBundle/Domain/DataSourceSchemaSpecParser.md)
|
|
375
376
|
* [DefaultSchemaLoader](php/SpecificationBundle/Domain/DefaultSchemaLoader.md)
|
|
377
|
+
* [DynamicFiltersResponseSpecParser](php/SpecificationBundle/Domain/DynamicFiltersResponseSpecParser.md)
|
|
376
378
|
* [InvalidCustomDataSourceTypeException](php/SpecificationBundle/Domain/InvalidCustomDataSourceTypeException.md)
|
|
377
379
|
* [InvalidSchemaException](php/SpecificationBundle/Domain/InvalidSchemaException.md)
|
|
378
380
|
* [JsonSchemaValidator](php/SpecificationBundle/Domain/JsonSchemaValidator.md)
|
|
@@ -384,6 +386,7 @@ Here you find the API documentation for the relevant classes:
|
|
|
384
386
|
* [FieldVisitor](php/SpecificationBundle/Domain/Schema/FieldVisitor.md)
|
|
385
387
|
* [GroupFieldConfiguration](php/SpecificationBundle/Domain/Schema/GroupFieldConfiguration.md)
|
|
386
388
|
* [StreamFieldConfiguration](php/SpecificationBundle/Domain/Schema/StreamFieldConfiguration.md)
|
|
389
|
+
* [SchemaError](php/SpecificationBundle/Domain/SchemaError.md)
|
|
387
390
|
* [SpecParser](php/SpecificationBundle/Domain/SpecParser.md)
|
|
388
391
|
* [TasticSpecParser](php/SpecificationBundle/Domain/TasticSpecParser.md)
|
|
389
392
|
* [ValidatingSpecParser](php/SpecificationBundle/Domain/ValidatingSpecParser.md)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# DataSourceSchemaSpecParser
|
|
2
|
+
|
|
3
|
+
**Fully Qualified**: [`\Frontastic\Common\SpecificationBundle\Domain\DataSourceSchemaSpecParser`](../../../../src/php/SpecificationBundle/Domain/DataSourceSchemaSpecParser.php)
|
|
4
|
+
|
|
5
|
+
**Extends**: [`ValidatingSpecParser`](ValidatingSpecParser.md)
|
|
6
|
+
|
|
7
|
+
## Methods
|
|
8
|
+
|
|
9
|
+
* [__construct()](#__construct)
|
|
10
|
+
|
|
11
|
+
### __construct()
|
|
12
|
+
|
|
13
|
+
```php
|
|
14
|
+
public function __construct(): mixed
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Return Value: `mixed`
|
|
18
|
+
|
|
19
|
+
Generated with [Frontastic API Docs](https://github.com/FrontasticGmbH/apidocs).
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# DynamicFiltersResponseSpecParser
|
|
2
|
+
|
|
3
|
+
**Fully Qualified**: [`\Frontastic\Common\SpecificationBundle\Domain\DynamicFiltersResponseSpecParser`](../../../../src/php/SpecificationBundle/Domain/DynamicFiltersResponseSpecParser.php)
|
|
4
|
+
|
|
5
|
+
**Extends**: [`ValidatingSpecParser`](ValidatingSpecParser.md)
|
|
6
|
+
|
|
7
|
+
## Methods
|
|
8
|
+
|
|
9
|
+
* [__construct()](#__construct)
|
|
10
|
+
|
|
11
|
+
### __construct()
|
|
12
|
+
|
|
13
|
+
```php
|
|
14
|
+
public function __construct(): mixed
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Return Value: `mixed`
|
|
18
|
+
|
|
19
|
+
Generated with [Frontastic API Docs](https://github.com/FrontasticGmbH/apidocs).
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
```php
|
|
13
13
|
public function validate(
|
|
14
|
-
|
|
14
|
+
mixed $toValidate,
|
|
15
15
|
string $schemaFile,
|
|
16
16
|
array $schemaLibraryFiles = []
|
|
17
17
|
): array
|
|
@@ -19,7 +19,7 @@ public function validate(
|
|
|
19
19
|
|
|
20
20
|
Argument|Type|Default|Description
|
|
21
21
|
--------|----|-------|-----------
|
|
22
|
-
`$toValidate`|`
|
|
22
|
+
`$toValidate`|`mixed`||
|
|
23
23
|
`$schemaFile`|`string`||
|
|
24
24
|
`$schemaLibraryFiles`|`array`|`[]`|
|
|
25
25
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# SchemaError
|
|
2
|
+
|
|
3
|
+
**Fully Qualified**: [`\Frontastic\Common\SpecificationBundle\Domain\SchemaError`](../../../../src/php/SpecificationBundle/Domain/SchemaError.php)
|
|
4
|
+
|
|
5
|
+
**Extends**: [`\Kore\DataObject\DataObject`](https://github.com/kore/DataObject)
|
|
6
|
+
|
|
7
|
+
Property|Type|Default|Required|Description
|
|
8
|
+
--------|----|-------|--------|-----------
|
|
9
|
+
`propertyName` | `?string` | `null` | - |
|
|
10
|
+
`errorIndex` | `?string` | `null` | - |
|
|
11
|
+
`errorFlag` | `?string` | `null` | - |
|
|
12
|
+
|
|
13
|
+
Generated with [Frontastic API Docs](https://github.com/FrontasticGmbH/apidocs).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontastic/common",
|
|
3
|
-
"version": "2.42.
|
|
3
|
+
"version": "2.42.1",
|
|
4
4
|
"devDependencies": {
|
|
5
5
|
"@babel/core": "7.21.0",
|
|
6
6
|
"@babel/plugin-proposal-class-properties": "^7.5.0",
|
|
@@ -28,12 +28,13 @@
|
|
|
28
28
|
"eslint-plugin-standard": "^4.0.0",
|
|
29
29
|
"jest": "26.6.3",
|
|
30
30
|
"mime": "^1.4.1",
|
|
31
|
-
"uuid": "^3.3.2",
|
|
32
31
|
"webpack": "4.46.0",
|
|
33
32
|
"webpack-cli": "^4.10.0",
|
|
34
33
|
"whatwg-fetch": "3.0.0"
|
|
35
34
|
},
|
|
36
|
-
"dependencies": {
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"uuid": "^3.3.2 || ^9.0.0"
|
|
37
|
+
},
|
|
37
38
|
"main": "src/js/frontastic-common.js",
|
|
38
39
|
"module": "src/js/index.js",
|
|
39
40
|
"scripts": {
|
package/src/ant/javascript.xml
CHANGED
|
@@ -32,11 +32,14 @@
|
|
|
32
32
|
<arg value="build" />
|
|
33
33
|
</exec>
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
<!-- git directly fails if it can't acquire it's lock, but it might be that some other component does a git operation at the same time. In this case it's better to wait for the lock than directly fail. -->
|
|
36
|
+
<exec executable="flock" failonerror="true" dir="${basedir}">
|
|
37
|
+
<arg value="--timeout" />
|
|
38
|
+
<arg value="5" />
|
|
39
|
+
<arg value="${frontastic_basedir}/git-flock.lock" />
|
|
40
|
+
<arg value="git" />
|
|
41
|
+
<arg value="add" />
|
|
42
|
+
<arg value="${basedir}/src/js/frontastic-common.js" />
|
|
43
|
+
</exec>
|
|
41
44
|
</target>
|
|
42
45
|
</project>
|
|
@@ -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),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 C})),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 $}));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||!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;case"instant":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?null!==r?Object.values(r).some(e=>!e)||0===Object.values(r).length:"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?Object.values(r).some(e=>!e):("string"===n.type||"markdown"===n.type)&&n.translatable&&r?Object.values(r).some(e=>!e)||0===Object.values(r).length: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 T=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 C(){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";T?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,i)=>{i={resourceType:t,type:"upload",...i};let r=[];for(let[e,t]of Object.entries(i))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&&r.push(e[0]+"_"+t);break;default:throw new Error("Unhandled image transformation "+e)}return r.sort(),`https://res.cloudinary.com/${n.cloudName}/${i.resourceType}/${i.type}/${r.join(",")}/${o=e,encodeURI(o).replace(/[?=]/g,(function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()}))}`;var o};var A=class{constructor(e){this.configuration={cloudName:e.cloudName}}getImageUrl(e,t,n,i={}){return P(e.mediaId,"string"==typeof e.resourceType&&""!==e.resourceType?e.resourceType:"image",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,"image",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,"string"==typeof e.resourceType&&""!==e.resourceType?e.resourceType:"image",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()}}}])}));
|
|
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=4)}([function(e,t){e.exports=require("crypto")},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){"use strict";function i(e){return"stream"===e||"dataSource"===e}n.r(t),n.d(t,"ConfigurationSchema",(function(){return f})),n.d(t,"DefaultSchemas",(function(){return h})),n.d(t,"generateId",(function(){return S})),n.d(t,"getTranslation",(function(){return T})),n.d(t,"httpBuildQuery",(function(){return j})),n.d(t,"httpParseQuery",(function(){return F})),n.d(t,"isTranslatableByDefault",(function(){return C})),n.d(t,"shouldFieldBeTranslated",(function(){return x})),n.d(t,"registerServiceWorker",(function(){return N})),n.d(t,"VisibilityChange",(function(){return R})),n.d(t,"cellDimensions",(function(){return P})),n.d(t,"Cell",(function(){return _})),n.d(t,"Page",(function(){return H})),n.d(t,"Region",(function(){return z})),n.d(t,"Tastic",(function(){return A})),n.d(t,"MediaApi",(function(){return $})),n.d(t,"FacetTypeSchemaMap",(function(){return B})),n.d(t,"omit",(function(){return V})),n.d(t,"deprecate",(function(){return K})),n.d(t,"debounce",(function(){return G})),n.d(t,"throttle",(function(){return Q})),n.d(t,"Notifier",(function(){return X}));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||!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;case"instant":case"encrypted":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?null!==r?Object.values(r).some(e=>!e)||0===Object.values(r).length:"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?Object.values(r).some(e=>!e):("string"===n.type||"markdown"===n.type)&&n.translatable&&r?Object.values(r).some(e=>!e)||0===Object.values(r).length: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(2),CellConfigurationSchema:n(3)},g=n(0),m=n.n(g),p={randomUUID:m.a.randomUUID};const y=new Uint8Array(256);let b=y.length;function w(){return b>y.length-16&&(m.a.randomFillSync(y),b=0),y.slice(b,b+=16)}const v=[];for(let e=0;e<256;++e)v.push((e+256).toString(16).slice(1));function I(e,t=0){return(v[e[t+0]]+v[e[t+1]]+v[e[t+2]]+v[e[t+3]]+"-"+v[e[t+4]]+v[e[t+5]]+"-"+v[e[t+6]]+v[e[t+7]]+"-"+v[e[t+8]]+v[e[t+9]]+"-"+v[e[t+10]]+v[e[t+11]]+v[e[t+12]]+v[e[t+13]]+v[e[t+14]]+v[e[t+15]]).toLowerCase()}var k=function(e,t,n){if(p.randomUUID&&!t&&!e)return p.randomUUID();const i=(e=e||{}).random||(e.rng||w)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,t){n=n||0;for(let e=0;e<16;++e)t[n+e]=i[e];return t}return I(i)},S=function(){return k()},T=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 C=e=>{switch(e){case"string":case"text":case"markdown":case"json":return!0;default:return!1}},x=e=>void 0!==e.translatable?e.translatable:C(e.type);let O=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 j=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 O(e)+"="+O(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 E=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},D=function(e){for(let[t,n]of Object.entries(e))n&&"object"==typeof n&&(e[t]=D(n)),E(n)&&(e[t]=Object.values(n));return e};var F=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=D(t),t};const U=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 N(){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";U?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()})}):M(e)}).catch(()=>{console.log("No internet connection found. App is running in offline mode.")})}(e):M(e)})}}function M(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 R=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)}},P=[{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 A=class{constructor(e={}){this.tasticId=e.tasticId||S(),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 _=class{constructor(e={}){if(this.cellId=e.cellId||S(),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:P&&P.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 A(e.tastics[t]))}addTastic(e,t={},n=[],i=0){const r=new A({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 q=class{constructor(e){if(!e.kitDefinitionId)throw new Error("Missing kitDefinitionId in "+JSON.stringify(e));this.kitDefinitionId=e.kitDefinitionId,this.kitId=e.kitId||S(),this.configuration=e.configuration||{}}export(){return{kitId:this.kitId,kitDefinitionId:this.kitDefinitionId,configuration:this.configuration}}};var z=class{constructor(e={}){if(this.regionId=e.regionId||S(),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 _(e)),this.elements[this.elements.length-1]}addKit(e){return this.elements.push(new q(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 _)}getKits(){return this.elements.filter(e=>e instanceof q)}export(){return{regionId:this.regionId,configuration:this.schema.getConfiguration(),elements:this.elements.map(e=>e.export())}}};var H=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 z(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 L=(e,t,n,i)=>{i={resourceType:t,type:"upload",...i};let r=[];for(let[e,t]of Object.entries(i))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&&r.push(e[0]+"_"+t);break;default:throw new Error("Unhandled image transformation "+e)}return r.sort(),`https://res.cloudinary.com/${n.cloudName}/${i.resourceType}/${i.type}/${r.join(",")}/${o=e,encodeURI(o).replace(/[?=]/g,(function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()}))}`;var o};var W=class{constructor(e){this.configuration={cloudName:e.cloudName}}getImageUrl(e,t,n,i={}){return L(e.mediaId,"string"==typeof e.resourceType&&""!==e.resourceType?e.resourceType:"image",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),L(e,"image",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 L(e.mediaId,"string"==typeof e.resourceType&&""!==e.resourceType?e.resourceType:"image",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 W(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}}},J=n(1),B={enum:J,localizedEnum:J},V=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>!t.includes(e))),K=(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)},G=(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)}},Q=(e,t)=>{let n=!1;return function(){n||(e.apply(this,arguments),n=!0,setTimeout((function(){n=!1}),t))}};var X=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()}}}])}));
|
package/src/js/generateId.js
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-04/schema#",
|
|
3
|
+
"id": "https://frontastic.cloud/json/dataSourceResponseSchema",
|
|
4
|
+
"title": "Data Source Preview Schema",
|
|
5
|
+
"description": "A Frontastic data source Preview definition",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"dataSourcePayload": {
|
|
9
|
+
"type": "object"
|
|
10
|
+
},
|
|
11
|
+
"previewPayload": {
|
|
12
|
+
"type": "array",
|
|
13
|
+
"items": {
|
|
14
|
+
"type": "object",
|
|
15
|
+
"properties": {
|
|
16
|
+
"title": {
|
|
17
|
+
"type":"string"
|
|
18
|
+
},
|
|
19
|
+
"image": {
|
|
20
|
+
"type": "string"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"required": ["dataSourcePayload", "previewPayload"]
|
|
27
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-04/schema#",
|
|
3
|
+
"id": "https://frontastic.cloud/json/dynamicFiltersResponseSchema",
|
|
4
|
+
"title": "Dynamic Filters Response Schema",
|
|
5
|
+
"description": "A Frontastic dynamic Filters Response definition",
|
|
6
|
+
"type": "array",
|
|
7
|
+
"items": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"properties": {
|
|
10
|
+
"field": {
|
|
11
|
+
"type": "string",
|
|
12
|
+
"not": {
|
|
13
|
+
"enum": [
|
|
14
|
+
"id",
|
|
15
|
+
"sequence",
|
|
16
|
+
"locale",
|
|
17
|
+
"is_deleted"
|
|
18
|
+
]
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"type": {
|
|
22
|
+
"type": "string"
|
|
23
|
+
},
|
|
24
|
+
"label": {
|
|
25
|
+
"type": "string"
|
|
26
|
+
},
|
|
27
|
+
"values": {
|
|
28
|
+
"type": "array",
|
|
29
|
+
"items": {
|
|
30
|
+
"type": "object",
|
|
31
|
+
"properties": {
|
|
32
|
+
"value": {
|
|
33
|
+
"type": "string"
|
|
34
|
+
},
|
|
35
|
+
"name": {
|
|
36
|
+
"type": "string"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"$ref": "#/definitions/enum-field-types-imply-values-attributes-is-required"
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
"definitions": {
|
|
46
|
+
"enum-field-types-imply-values-attributes-is-required": {
|
|
47
|
+
"allOf":[
|
|
48
|
+
{
|
|
49
|
+
"anyOf":[
|
|
50
|
+
{
|
|
51
|
+
"not": {
|
|
52
|
+
"properties": {
|
|
53
|
+
"type": {
|
|
54
|
+
"enum": ["enum"]
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"required": ["type"]
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"required": ["values"],
|
|
62
|
+
"$comment": "Field of type 'enum' requires 'values' property"
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"required": ["type", "field", "label"]
|
|
68
|
+
}
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -53,7 +53,8 @@
|
|
|
53
53
|
"group",
|
|
54
54
|
"image",
|
|
55
55
|
"description",
|
|
56
|
-
"tastic"
|
|
56
|
+
"tastic",
|
|
57
|
+
"encrypted"
|
|
57
58
|
]
|
|
58
59
|
}
|
|
59
60
|
}
|
|
@@ -78,7 +79,14 @@
|
|
|
78
79
|
"field": {
|
|
79
80
|
"type": "string",
|
|
80
81
|
"not": {
|
|
81
|
-
"enum": [
|
|
82
|
+
"enum": [
|
|
83
|
+
"id",
|
|
84
|
+
"sequence",
|
|
85
|
+
"locale",
|
|
86
|
+
"is_deleted",
|
|
87
|
+
"password",
|
|
88
|
+
"token"
|
|
89
|
+
]
|
|
82
90
|
}
|
|
83
91
|
},
|
|
84
92
|
"streamType": {
|
|
@@ -90,8 +98,8 @@
|
|
|
90
98
|
"type": "string"
|
|
91
99
|
},
|
|
92
100
|
"dynamicFilterEndpoint": {
|
|
93
|
-
"
|
|
94
|
-
"
|
|
101
|
+
"type": "string",
|
|
102
|
+
"pattern": "^/"
|
|
95
103
|
},
|
|
96
104
|
"customAppType": {
|
|
97
105
|
"$comment": "TODO: Define dependency to type?",
|
|
@@ -174,7 +174,7 @@
|
|
|
174
174
|
},
|
|
175
175
|
{
|
|
176
176
|
"required": ["dynamicFilterEndpoint"],
|
|
177
|
-
"$comment": "Field of type 'dynamic-filter' requires '
|
|
177
|
+
"$comment": "Field of type 'dynamic-filter' requires 'dynamicFilterEndpoint' property"
|
|
178
178
|
}
|
|
179
179
|
]
|
|
180
180
|
},
|
|
@@ -216,6 +216,31 @@
|
|
|
216
216
|
}
|
|
217
217
|
]
|
|
218
218
|
},
|
|
219
|
+
{
|
|
220
|
+
"anyOf":[
|
|
221
|
+
{
|
|
222
|
+
"not": {
|
|
223
|
+
"properties": {
|
|
224
|
+
"type": {
|
|
225
|
+
"enum": ["encrypted"]
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
"required": ["type"]
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
"patternProperties": {
|
|
233
|
+
"^(translatable)$": {
|
|
234
|
+
"enum": [false]
|
|
235
|
+
},
|
|
236
|
+
"^(default)$": {
|
|
237
|
+
"enum": [null]
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
"$comment": "Encrypted fields are neither translatable nor having a default value."
|
|
241
|
+
}
|
|
242
|
+
]
|
|
243
|
+
},
|
|
219
244
|
{
|
|
220
245
|
"anyOf":[
|
|
221
246
|
{
|
|
@@ -7,16 +7,20 @@
|
|
|
7
7
|
"properties": {
|
|
8
8
|
"tasticType": {
|
|
9
9
|
"type": "string",
|
|
10
|
-
"pattern": "[^ ]"
|
|
10
|
+
"pattern": "[^ ]",
|
|
11
|
+
"maxLength": 255
|
|
11
12
|
},
|
|
12
13
|
"name": {
|
|
13
|
-
"type": "string"
|
|
14
|
+
"type": "string",
|
|
15
|
+
"maxLength": 255
|
|
14
16
|
},
|
|
15
17
|
"description": {
|
|
16
|
-
"type": "string"
|
|
18
|
+
"type": "string",
|
|
19
|
+
"maxLength": 255
|
|
17
20
|
},
|
|
18
21
|
"category": {
|
|
19
|
-
"type": "string"
|
|
22
|
+
"type": "string",
|
|
23
|
+
"maxLength": 255
|
|
20
24
|
},
|
|
21
25
|
"schema": {
|
|
22
26
|
"$ref": "https://frontastic.cloud/json/library/common#/definitions/schema"
|