Socket
Socket
Sign inDemoInstall

@sitecore/byoc

Package Overview
Dependencies
Maintainers
4
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sitecore/byoc - npm Package Compare versions

Comparing version 0.2.13 to 0.2.14

3

build/components.js

@@ -21,3 +21,3 @@ var __rest = (this && this.__rest) || function (s, e) {

*/
const { thumbnail = 'https://feaasstatic.blob.core.windows.net/assets/thumbnails/byoc.svg', name, id = options.name, group = null, ui, isHidden = false, datasourceIds = [], links = {}, uiSchema: explicitUISchema, schema: explicitSchema } = options, schemaOptions = __rest(options, ["thumbnail", "name", "id", "group", "ui", "isHidden", "datasourceIds", "links", "uiSchema", "schema"]);
const { thumbnail = 'https://feaasstatic.blob.core.windows.net/assets/thumbnails/byoc.svg', name, id = options.name, group = null, ui, isHidden = false, datasourceIds = [], links = {}, meta = {}, uiSchema: explicitUISchema, schema: explicitSchema } = options, schemaOptions = __rest(options, ["thumbnail", "name", "id", "group", "ui", "isHidden", "datasourceIds", "links", "meta", "uiSchema", "schema"]);
const schemaBase = explicitSchema || schemaOptions || {};

@@ -38,2 +38,3 @@ const useSchemaBase = explicitUISchema || ui || {};

links,
meta,
title: (schema === null || schema === void 0 ? void 0 : schema.title) || (schemaOptions === null || schemaOptions === void 0 ? void 0 : schemaOptions.title) || name

@@ -40,0 +41,0 @@ };

@@ -1,2 +0,2 @@

var E=(e={})=>Object.keys(e).reduce((t,n)=>Object.assign(t,{[b(n)]:e[n]}),{}),Y=(e={})=>Object.keys(e).reduce((t,n)=>Object.assign(t,{[O(n)]:e[n]}),{});function b(e){let t=/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g;return O(e).replace(t,function(n){return"-"+n.toLowerCase()})}function O(e){return e=e.replace(/[-_ ]+/g," "),e=e.charAt(0).toLowerCase()+e.slice(1),e.split(/\s+/).map((t,n)=>n===0?t:t.charAt(0).toUpperCase()+t.slice(1)).join("")}function h(e,t={}){let n=e.properties||{},r=e.required||[];return Object.assign(Object.assign({type:"object"},e),{required:r,properties:Object.keys(n).reduce((i,o)=>{let s=Object.assign(Object.assign({},n[o]),{default:t.hasOwnProperty(o)?t[o]:n[o].default,title:n[o].title||b(o).split("-").map(c=>c.charAt(0).toUpperCase()+c.slice(1).toLowerCase()).join(" ")});return s.default===void 0&&delete s.default,"required"in s&&typeof s.required=="boolean"&&(r.indexOf(o)==-1&&r.push(o),delete s.required),Object.assign(i,{[o]:s})},{})})}var _=(e,t)=>{let n=Object.assign({},e);return Object.keys(t).filter(i=>/(integer|number)/.test(t[i].type)).forEach(i=>{var o;!((o=n[i])===null||o===void 0)&&o["ui:widget"]||(n[i]=Object.assign(Object.assign({},n[i]),{"ui:widget":"updown"}))}),n};function v(e,t){switch(t){case"string":return e;case"object":try{return typeof e=="object"&&e!=null?e:JSON.parse(e)}catch(n){return null}case"array":try{return Array.isArray(e)?e:JSON.parse(e)}catch(n){return null}case"number":return parseFloat(e);case"integer":return parseInt(e);case"boolean":return e=="true"||e=="1";default:return e}}function I(e,t){return Object.keys(t).reduce((n,r)=>{let i=t[r],o=O(r),s=e==null?void 0:e.properties[o],c=s==null?void 0:s.type,l=v(i,c);return l!=null&&!r.startsWith("data-attribute")&&!["class","id","contenteditable"].includes(r)?Object.assign(Object.assign({},n),{[o]:l}):n},{})}function P(e,t){return Object.assign(Object.assign({},W(e)),I(e,t))}function W(e){return Object.keys(e.properties).reduce((t,n)=>{var r,i;return((r=e.properties[n])===null||r===void 0?void 0:r.default)!=null?Object.assign(Object.assign({},t),{[n]:(i=e.properties[n])===null||i===void 0?void 0:i.default}):t},{})}var j=typeof window!="undefined"?window.BYOCDatasources||(window.BYOCDatasources={}):{};function A(e,t){if(typeof e!="function")throw new Error("The first argument of registerDatasource must be a function returning DataSettings or Promise of data");if(!t.id)throw new Error("Missing 'id' property in input");if(!/^[a-zA-Z0-9-_]+$/.test(t.id))throw new Error("Invalid 'id' property in input. 'id' should only contain alphanumeric characters, hyphens, and underscores.");j[t.id]=Object.assign(Object.assign({},B(t)),{handler:e}),N()}function J(e){return j[e]}function B(e){let{id:t,name:n,title:r,properties:i,sample:o,schema:s,description:c=null,type:l="object"}=e;return{id:t,description:c,sample:o,name:n||r||t,handler:u=>u,schema:s||i?h(Object.assign(Object.assign({},s||{properties:i,type:l}),{title:(s==null?void 0:s.title)||r||n})):void 0}}var D;function N(){clearTimeout(D),D=setTimeout(()=>{var e;typeof window!="undefined"&&window.parent!==window&&((e=window.parent)===null||e===void 0||e.postMessage(JSON.stringify({action:"register-datasources",data:Object.values(j)}),"*"))},30)}N();function G(e,t){let n=j[e];return n!=null&&n.handler?n.handler(t):t}var K=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n};function U(e,t,n){let{thumbnail:r="https://feaasstatic.blob.core.windows.net/assets/thumbnails/byoc.svg",name:i,id:o=e.name,group:s=null,ui:c,isHidden:l=!1,datasourceIds:u=[],links:g={},uiSchema:p,schema:d}=e,a=K(e,["thumbnail","name","id","group","ui","isHidden","datasourceIds","links","uiSchema","schema"]),f=d||a||{},S=p||c||{},m=h(Object.assign(Object.assign({description:"External component"},f),{type:"object"}),n),H=_(S,m.properties||{});return{component:t||(()=>null),name:i,schema:m,uiSchema:H,thumbnail:r,group:s||"Default collection",isHidden:l,id:o,datasourceIds:u,links:g,title:(m==null?void 0:m.title)||(a==null?void 0:a.title)||i}}var T,k=typeof HTMLElement!="undefined"?HTMLElement:typeof windowJSDOM!="undefined"?windowJSDOM.HTMLElement:class{setAttribute(){}},y=typeof window!="undefined"?window.BYOCComponents||(window.BYOCComponents={}):{};function q(e,t,n={}){if(!(t!=null&&t.name))throw new Error("Could not register external component. Please make sure you provide a name in the options"+JSON.stringify(t));let r=U(t,e,n);y[r.id]=r,z(e)&&w.register("byoc-"+b(t.name),void 0,e),M()}function z(e){return e&&"prototype"in e&&"setAttribute"in e.prototype}function L(e,t={}){var n;let r=(n=C(e))===null||n===void 0?void 0:n.schema;return r?P(r,t):t}function ne(e){let t=C(e);return Object.keys((t==null?void 0:t.schema.properties)||{}).filter(n=>{var r,i;return((i=(r=t==null?void 0:t.uiSchema)===null||r===void 0?void 0:r[n])===null||i===void 0?void 0:i["ui:widget"])!="hidden"})}function C(e){if(typeof e!="string"){if(e&&"schema"in e)return e;throw new Error(`Component name should be a string, got ${typeof e}`)}let[t,n]=e.split("?");var r=y[t];if(n){let i=y[e];if(!i&&!r)return null;i&&(r=Object.assign(Object.assign(Object.assign({},r),i),{component:i.component||(r==null?void 0:r.component)})),n.split(/\&/g).forEach(o=>{var s,c,l;let[u,g]=o.split("="),p=((s=r.schema.properties)===null||s===void 0?void 0:s[u])||{type:"string"};r=Object.assign(Object.assign({},r),{schema:Object.assign(Object.assign({},r.schema),{properties:Object.assign(Object.assign({},r.schema.properties),{[u]:Object.assign(Object.assign({},p),{default:v(decodeURIComponent(g),p.type)})})}),uiSchema:Object.assign(Object.assign({},r.uiSchema),{[u]:Object.assign(Object.assign({},r.uiSchema[u]),{"ui:widget":(l=(c=r.uiSchema[u])===null||c===void 0?void 0:c["ui:widget"])!==null&&l!==void 0?l:"hidden"})})})})}return r}function re(e){let{componentName:t,className:n,fallbackWrapper:r,fallback:i,suppressHydrationWarning:o,_dynamic:s,datasources:c}=e,l=K(e,["componentName","className","fallbackWrapper","fallback","suppressHydrationWarning","_dynamic","datasources"]);try{var u=typeof c=="string"?JSON.parse(c):c}catch(a){}let g=Object.values(u||{}).find(a=>a&&!Array.isArray(a)&&Object.keys(a).length>0),p=Object.assign(Object.assign(Object.assign({},g),L(t,Object.assign(Object.assign({},g),l))),u?{datasources:u}:{}),d=Object.assign(Object.assign({"data-external-id":t},E(p)),{suppressHydrationWarning:!0,class:n});return R.forEach(a=>{Object.assign(d,{[b(a)]:x[a]})}),Object.keys(d).forEach(a=>{let f=d[a];if(f&&typeof f=="object"&&a!="class"&&a!="children")try{Object.assign(d,{[a]:JSON.stringify(f)})}catch(S){delete d[a]}(typeof f=="function"||f==null)&&delete d[a]}),{attributes:d,properties:p,merged:Object.assign(Object.assign({},x),p)}}function M(){clearTimeout(T),T=setTimeout(()=>{var e;typeof window!="undefined"&&window.parent!==window&&((e=window.parent)===null||e===void 0||e.postMessage(JSON.stringify({action:"register-components",data:Object.values(y)}),"*"))},30)}M();var w=class extends k{connectedCallback(){try{JSON.parse(String(this.getAttribute("components"))).forEach(t=>{C(t.id)||q(null,t)}),JSON.parse(String(this.getAttribute("datasources"))).forEach(t=>{J(t.id)||A(n=>n,t)})}catch(t){}}static register(t,n,r=this){n==null&&(n=typeof window!="undefined"?window:void 0),n&&!n.customElements.get(t)&&n.customElements.define(t,class extends r{})}},x={};function ie(e){x=e}var R=["sitecoreEdgeUrl","sitecoreEdgeContextId"];w.register("byoc-registration");export{w as BYOCRegistration,k as WebComponent,x as contextProperties,G as customizeDataSettings,C as getComponent,ne as getComponentConfigurablePropertyNames,L as getComponentProperties,J as getDatasource,re as getMergedComponentProperties,W as getSchemaDefaults,P as getSchemaProperties,z as isWebComponent,U as normalizeOptions,Y as objectKeysToCamelCase,E as objectKeysToKebabCase,I as parseSchemaProperties,v as parseValue,q as registerComponent,A as registerDatasource,y as registered,j as registeredDatasources,R as serializedContextProperties,ie as setContextProperties,M as setRegistrationCallback,O as toCamelCase,b as toKebabCase,h as transformSchema,_ as transformUiSchema};
var E=(e={})=>Object.keys(e).reduce((t,n)=>Object.assign(t,{[b(n)]:e[n]}),{}),V=(e={})=>Object.keys(e).reduce((t,n)=>Object.assign(t,{[O(n)]:e[n]}),{});function b(e){let t=/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g;return O(e).replace(t,function(n){return"-"+n.toLowerCase()})}function O(e){return e=e.replace(/[-_ ]+/g," "),e=e.charAt(0).toLowerCase()+e.slice(1),e.split(/\s+/).map((t,n)=>n===0?t:t.charAt(0).toUpperCase()+t.slice(1)).join("")}function h(e,t={}){let n=e.properties||{},r=e.required||[];return Object.assign(Object.assign({type:"object"},e),{required:r,properties:Object.keys(n).reduce((i,o)=>{let s=Object.assign(Object.assign({},n[o]),{default:t.hasOwnProperty(o)?t[o]:n[o].default,title:n[o].title||b(o).split("-").map(a=>a.charAt(0).toUpperCase()+a.slice(1).toLowerCase()).join(" ")});return s.default===void 0&&delete s.default,"required"in s&&typeof s.required=="boolean"&&(r.indexOf(o)==-1&&r.push(o),delete s.required),Object.assign(i,{[o]:s})},{})})}var _=(e,t)=>{let n=Object.assign({},e);return Object.keys(t).filter(i=>/(integer|number)/.test(t[i].type)).forEach(i=>{var o;!((o=n[i])===null||o===void 0)&&o["ui:widget"]||(n[i]=Object.assign(Object.assign({},n[i]),{"ui:widget":"updown"}))}),n};function v(e,t){switch(t){case"string":return e;case"object":try{return typeof e=="object"&&e!=null?e:JSON.parse(e)}catch(n){return null}case"array":try{return Array.isArray(e)?e:JSON.parse(e)}catch(n){return null}case"number":return parseFloat(e);case"integer":return parseInt(e);case"boolean":return e=="true"||e=="1";default:return e}}function W(e,t){return Object.keys(t).reduce((n,r)=>{let i=t[r],o=O(r),s=e==null?void 0:e.properties[o],a=s==null?void 0:s.type,l=v(i,a);return l!=null&&!r.startsWith("data-attribute")&&!["class","id","contenteditable"].includes(r)?Object.assign(Object.assign({},n),{[o]:l}):n},{})}function P(e,t){return Object.assign(Object.assign({},B(e)),W(e,t))}function B(e){return Object.keys(e.properties).reduce((t,n)=>{var r,i;return((r=e.properties[n])===null||r===void 0?void 0:r.default)!=null?Object.assign(Object.assign({},t),{[n]:(i=e.properties[n])===null||i===void 0?void 0:i.default}):t},{})}var j=typeof window!="undefined"?window.BYOCDatasources||(window.BYOCDatasources={}):{};function A(e,t){if(typeof e!="function")throw new Error("The first argument of registerDatasource must be a function returning DataSettings or Promise of data");if(!t.id)throw new Error("Missing 'id' property in input");if(!/^[a-zA-Z0-9-_]+$/.test(t.id))throw new Error("Invalid 'id' property in input. 'id' should only contain alphanumeric characters, hyphens, and underscores.");j[t.id]=Object.assign(Object.assign({},U(t)),{handler:e}),N()}function J(e){return j[e]}function U(e){let{id:t,name:n,title:r,properties:i,sample:o,schema:s,description:a=null,type:l="object"}=e;return{id:t,description:a,sample:o,name:n||r||t,handler:u=>u,schema:s||i?h(Object.assign(Object.assign({},s||{properties:i,type:l}),{title:(s==null?void 0:s.title)||r||n})):void 0}}var D;function N(){clearTimeout(D),D=setTimeout(()=>{var e;typeof window!="undefined"&&window.parent!==window&&((e=window.parent)===null||e===void 0||e.postMessage(JSON.stringify({action:"register-datasources",data:Object.values(j)}),"*"))},30)}N();function X(e,t){let n=j[e];return n!=null&&n.handler?n.handler(t):t}var K=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n};function k(e,t,n){let{thumbnail:r="https://feaasstatic.blob.core.windows.net/assets/thumbnails/byoc.svg",name:i,id:o=e.name,group:s=null,ui:a,isHidden:l=!1,datasourceIds:u=[],links:g={},meta:f={},uiSchema:p,schema:c}=e,d=K(e,["thumbnail","name","id","group","ui","isHidden","datasourceIds","links","meta","uiSchema","schema"]),S=c||d||{},H=p||a||{},m=h(Object.assign(Object.assign({description:"External component"},S),{type:"object"}),n),I=_(H,m.properties||{});return{component:t||(()=>null),name:i,schema:m,uiSchema:I,thumbnail:r,group:s||"Default collection",isHidden:l,id:o,datasourceIds:u,links:g,meta:f,title:(m==null?void 0:m.title)||(d==null?void 0:d.title)||i}}var T,q=typeof HTMLElement!="undefined"?HTMLElement:typeof windowJSDOM!="undefined"?windowJSDOM.HTMLElement:class{setAttribute(){}},y=typeof window!="undefined"?window.BYOCComponents||(window.BYOCComponents={}):{};function z(e,t,n={}){if(!(t!=null&&t.name))throw new Error("Could not register external component. Please make sure you provide a name in the options"+JSON.stringify(t));let r=k(t,e,n);y[r.id]=r,L(e)&&w.register("byoc-"+b(t.name),void 0,e),M()}function L(e){return e&&"prototype"in e&&"setAttribute"in e.prototype}function R(e,t={}){var n;let r=(n=C(e))===null||n===void 0?void 0:n.schema;return r?P(r,t):t}function re(e){let t=C(e);return Object.keys((t==null?void 0:t.schema.properties)||{}).filter(n=>{var r,i;return((i=(r=t==null?void 0:t.uiSchema)===null||r===void 0?void 0:r[n])===null||i===void 0?void 0:i["ui:widget"])!="hidden"})}function C(e){if(typeof e!="string"){if(e&&"schema"in e)return e;throw new Error(`Component name should be a string, got ${typeof e}`)}let[t,n]=e.split("?");var r=y[t];if(n){let i=y[e];if(!i&&!r)return null;i&&(r=Object.assign(Object.assign(Object.assign({},r),i),{component:i.component||(r==null?void 0:r.component)})),n.split(/\&/g).forEach(o=>{var s,a,l;let[u,g]=o.split("="),f=((s=r.schema.properties)===null||s===void 0?void 0:s[u])||{type:"string"};r=Object.assign(Object.assign({},r),{schema:Object.assign(Object.assign({},r.schema),{properties:Object.assign(Object.assign({},r.schema.properties),{[u]:Object.assign(Object.assign({},f),{default:v(decodeURIComponent(g),f.type)})})}),uiSchema:Object.assign(Object.assign({},r.uiSchema),{[u]:Object.assign(Object.assign({},r.uiSchema[u]),{"ui:widget":(l=(a=r.uiSchema[u])===null||a===void 0?void 0:a["ui:widget"])!==null&&l!==void 0?l:"hidden"})})})})}return r}function ie(e){let{componentName:t,className:n,fallbackWrapper:r,fallback:i,suppressHydrationWarning:o,_dynamic:s,datasources:a}=e,l=K(e,["componentName","className","fallbackWrapper","fallback","suppressHydrationWarning","_dynamic","datasources"]);try{var u=typeof a=="string"?JSON.parse(a):a}catch(c){}let g=Object.values(u||{}).find(c=>c&&!Array.isArray(c)&&Object.keys(c).length>0),f=Object.assign(Object.assign(Object.assign({},g),R(t,Object.assign(Object.assign({},g),l))),u?{datasources:u}:{}),p=Object.assign(Object.assign({"data-external-id":t},E(f)),{suppressHydrationWarning:!0,class:n});return Y.forEach(c=>{Object.assign(p,{[b(c)]:x[c]})}),Object.keys(p).forEach(c=>{let d=p[c];if(d&&typeof d=="object"&&c!="class"&&c!="children")try{Object.assign(p,{[c]:JSON.stringify(d)})}catch(S){delete p[c]}(typeof d=="function"||d==null)&&delete p[c]}),{attributes:p,properties:f,merged:Object.assign(Object.assign({},x),f)}}function M(){clearTimeout(T),T=setTimeout(()=>{var e;typeof window!="undefined"&&window.parent!==window&&((e=window.parent)===null||e===void 0||e.postMessage(JSON.stringify({action:"register-components",data:Object.values(y)}),"*"))},30)}M();var w=class extends q{connectedCallback(){try{JSON.parse(String(this.getAttribute("components"))).forEach(t=>{C(t.id)||z(null,t)}),JSON.parse(String(this.getAttribute("datasources"))).forEach(t=>{J(t.id)||A(n=>n,t)})}catch(t){}}static register(t,n,r=this){n==null&&(n=typeof window!="undefined"?window:void 0),n&&!n.customElements.get(t)&&n.customElements.define(t,class extends r{})}},x={};function oe(e){x=e}var Y=["sitecoreEdgeUrl","sitecoreEdgeContextId"];w.register("byoc-registration");export{w as BYOCRegistration,q as WebComponent,x as contextProperties,X as customizeDataSettings,C as getComponent,re as getComponentConfigurablePropertyNames,R as getComponentProperties,J as getDatasource,ie as getMergedComponentProperties,B as getSchemaDefaults,P as getSchemaProperties,L as isWebComponent,k as normalizeOptions,V as objectKeysToCamelCase,E as objectKeysToKebabCase,W as parseSchemaProperties,v as parseValue,z as registerComponent,A as registerDatasource,y as registered,j as registeredDatasources,Y as serializedContextProperties,oe as setContextProperties,M as setRegistrationCallback,O as toCamelCase,b as toKebabCase,h as transformSchema,_ as transformUiSchema};
//# sourceMappingURL=index.esm.js.map

@@ -1,2 +0,2 @@

var E=(e={})=>Object.keys(e).reduce((t,n)=>Object.assign(t,{[b(n)]:e[n]}),{}),Y=(e={})=>Object.keys(e).reduce((t,n)=>Object.assign(t,{[O(n)]:e[n]}),{});function b(e){let t=/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g;return O(e).replace(t,function(n){return"-"+n.toLowerCase()})}function O(e){return e=e.replace(/[-_ ]+/g," "),e=e.charAt(0).toLowerCase()+e.slice(1),e.split(/\s+/).map((t,n)=>n===0?t:t.charAt(0).toUpperCase()+t.slice(1)).join("")}function h(e,t={}){let n=e.properties||{},r=e.required||[];return Object.assign(Object.assign({type:"object"},e),{required:r,properties:Object.keys(n).reduce((i,o)=>{let s=Object.assign(Object.assign({},n[o]),{default:t.hasOwnProperty(o)?t[o]:n[o].default,title:n[o].title||b(o).split("-").map(c=>c.charAt(0).toUpperCase()+c.slice(1).toLowerCase()).join(" ")});return s.default===void 0&&delete s.default,"required"in s&&typeof s.required=="boolean"&&(r.indexOf(o)==-1&&r.push(o),delete s.required),Object.assign(i,{[o]:s})},{})})}var _=(e,t)=>{let n=Object.assign({},e);return Object.keys(t).filter(i=>/(integer|number)/.test(t[i].type)).forEach(i=>{var o;!((o=n[i])===null||o===void 0)&&o["ui:widget"]||(n[i]=Object.assign(Object.assign({},n[i]),{"ui:widget":"updown"}))}),n};function v(e,t){switch(t){case"string":return e;case"object":try{return typeof e=="object"&&e!=null?e:JSON.parse(e)}catch(n){return null}case"array":try{return Array.isArray(e)?e:JSON.parse(e)}catch(n){return null}case"number":return parseFloat(e);case"integer":return parseInt(e);case"boolean":return e=="true"||e=="1";default:return e}}function I(e,t){return Object.keys(t).reduce((n,r)=>{let i=t[r],o=O(r),s=e==null?void 0:e.properties[o],c=s==null?void 0:s.type,l=v(i,c);return l!=null&&!r.startsWith("data-attribute")&&!["class","id","contenteditable"].includes(r)?Object.assign(Object.assign({},n),{[o]:l}):n},{})}function P(e,t){return Object.assign(Object.assign({},W(e)),I(e,t))}function W(e){return Object.keys(e.properties).reduce((t,n)=>{var r,i;return((r=e.properties[n])===null||r===void 0?void 0:r.default)!=null?Object.assign(Object.assign({},t),{[n]:(i=e.properties[n])===null||i===void 0?void 0:i.default}):t},{})}var j=typeof window!="undefined"?window.BYOCDatasources||(window.BYOCDatasources={}):{};function A(e,t){if(typeof e!="function")throw new Error("The first argument of registerDatasource must be a function returning DataSettings or Promise of data");if(!t.id)throw new Error("Missing 'id' property in input");if(!/^[a-zA-Z0-9-_]+$/.test(t.id))throw new Error("Invalid 'id' property in input. 'id' should only contain alphanumeric characters, hyphens, and underscores.");j[t.id]=Object.assign(Object.assign({},B(t)),{handler:e}),N()}function J(e){return j[e]}function B(e){let{id:t,name:n,title:r,properties:i,sample:o,schema:s,description:c=null,type:l="object"}=e;return{id:t,description:c,sample:o,name:n||r||t,handler:u=>u,schema:s||i?h(Object.assign(Object.assign({},s||{properties:i,type:l}),{title:(s==null?void 0:s.title)||r||n})):void 0}}var D;function N(){clearTimeout(D),D=setTimeout(()=>{var e;typeof window!="undefined"&&window.parent!==window&&((e=window.parent)===null||e===void 0||e.postMessage(JSON.stringify({action:"register-datasources",data:Object.values(j)}),"*"))},30)}N();function G(e,t){let n=j[e];return n!=null&&n.handler?n.handler(t):t}var K=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n};function U(e,t,n){let{thumbnail:r="https://feaasstatic.blob.core.windows.net/assets/thumbnails/byoc.svg",name:i,id:o=e.name,group:s=null,ui:c,isHidden:l=!1,datasourceIds:u=[],links:g={},uiSchema:p,schema:d}=e,a=K(e,["thumbnail","name","id","group","ui","isHidden","datasourceIds","links","uiSchema","schema"]),f=d||a||{},S=p||c||{},m=h(Object.assign(Object.assign({description:"External component"},f),{type:"object"}),n),H=_(S,m.properties||{});return{component:t||(()=>null),name:i,schema:m,uiSchema:H,thumbnail:r,group:s||"Default collection",isHidden:l,id:o,datasourceIds:u,links:g,title:(m==null?void 0:m.title)||(a==null?void 0:a.title)||i}}var T,k=typeof HTMLElement!="undefined"?HTMLElement:typeof windowJSDOM!="undefined"?windowJSDOM.HTMLElement:class{setAttribute(){}},y=typeof window!="undefined"?window.BYOCComponents||(window.BYOCComponents={}):{};function q(e,t,n={}){if(!(t!=null&&t.name))throw new Error("Could not register external component. Please make sure you provide a name in the options"+JSON.stringify(t));let r=U(t,e,n);y[r.id]=r,z(e)&&w.register("byoc-"+b(t.name),void 0,e),M()}function z(e){return e&&"prototype"in e&&"setAttribute"in e.prototype}function L(e,t={}){var n;let r=(n=C(e))===null||n===void 0?void 0:n.schema;return r?P(r,t):t}function ne(e){let t=C(e);return Object.keys((t==null?void 0:t.schema.properties)||{}).filter(n=>{var r,i;return((i=(r=t==null?void 0:t.uiSchema)===null||r===void 0?void 0:r[n])===null||i===void 0?void 0:i["ui:widget"])!="hidden"})}function C(e){if(typeof e!="string"){if(e&&"schema"in e)return e;throw new Error(`Component name should be a string, got ${typeof e}`)}let[t,n]=e.split("?");var r=y[t];if(n){let i=y[e];if(!i&&!r)return null;i&&(r=Object.assign(Object.assign(Object.assign({},r),i),{component:i.component||(r==null?void 0:r.component)})),n.split(/\&/g).forEach(o=>{var s,c,l;let[u,g]=o.split("="),p=((s=r.schema.properties)===null||s===void 0?void 0:s[u])||{type:"string"};r=Object.assign(Object.assign({},r),{schema:Object.assign(Object.assign({},r.schema),{properties:Object.assign(Object.assign({},r.schema.properties),{[u]:Object.assign(Object.assign({},p),{default:v(decodeURIComponent(g),p.type)})})}),uiSchema:Object.assign(Object.assign({},r.uiSchema),{[u]:Object.assign(Object.assign({},r.uiSchema[u]),{"ui:widget":(l=(c=r.uiSchema[u])===null||c===void 0?void 0:c["ui:widget"])!==null&&l!==void 0?l:"hidden"})})})})}return r}function re(e){let{componentName:t,className:n,fallbackWrapper:r,fallback:i,suppressHydrationWarning:o,_dynamic:s,datasources:c}=e,l=K(e,["componentName","className","fallbackWrapper","fallback","suppressHydrationWarning","_dynamic","datasources"]);try{var u=typeof c=="string"?JSON.parse(c):c}catch(a){}let g=Object.values(u||{}).find(a=>a&&!Array.isArray(a)&&Object.keys(a).length>0),p=Object.assign(Object.assign(Object.assign({},g),L(t,Object.assign(Object.assign({},g),l))),u?{datasources:u}:{}),d=Object.assign(Object.assign({"data-external-id":t},E(p)),{suppressHydrationWarning:!0,class:n});return R.forEach(a=>{Object.assign(d,{[b(a)]:x[a]})}),Object.keys(d).forEach(a=>{let f=d[a];if(f&&typeof f=="object"&&a!="class"&&a!="children")try{Object.assign(d,{[a]:JSON.stringify(f)})}catch(S){delete d[a]}(typeof f=="function"||f==null)&&delete d[a]}),{attributes:d,properties:p,merged:Object.assign(Object.assign({},x),p)}}function M(){clearTimeout(T),T=setTimeout(()=>{var e;typeof window!="undefined"&&window.parent!==window&&((e=window.parent)===null||e===void 0||e.postMessage(JSON.stringify({action:"register-components",data:Object.values(y)}),"*"))},30)}M();var w=class extends k{connectedCallback(){try{JSON.parse(String(this.getAttribute("components"))).forEach(t=>{C(t.id)||q(null,t)}),JSON.parse(String(this.getAttribute("datasources"))).forEach(t=>{J(t.id)||A(n=>n,t)})}catch(t){}}static register(t,n,r=this){n==null&&(n=typeof window!="undefined"?window:void 0),n&&!n.customElements.get(t)&&n.customElements.define(t,class extends r{})}},x={};function ie(e){x=e}var R=["sitecoreEdgeUrl","sitecoreEdgeContextId"];w.register("byoc-registration");export{w as BYOCRegistration,k as WebComponent,x as contextProperties,G as customizeDataSettings,C as getComponent,ne as getComponentConfigurablePropertyNames,L as getComponentProperties,J as getDatasource,re as getMergedComponentProperties,W as getSchemaDefaults,P as getSchemaProperties,z as isWebComponent,U as normalizeOptions,Y as objectKeysToCamelCase,E as objectKeysToKebabCase,I as parseSchemaProperties,v as parseValue,q as registerComponent,A as registerDatasource,y as registered,j as registeredDatasources,R as serializedContextProperties,ie as setContextProperties,M as setRegistrationCallback,O as toCamelCase,b as toKebabCase,h as transformSchema,_ as transformUiSchema};
var E=(e={})=>Object.keys(e).reduce((t,n)=>Object.assign(t,{[b(n)]:e[n]}),{}),V=(e={})=>Object.keys(e).reduce((t,n)=>Object.assign(t,{[O(n)]:e[n]}),{});function b(e){let t=/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g;return O(e).replace(t,function(n){return"-"+n.toLowerCase()})}function O(e){return e=e.replace(/[-_ ]+/g," "),e=e.charAt(0).toLowerCase()+e.slice(1),e.split(/\s+/).map((t,n)=>n===0?t:t.charAt(0).toUpperCase()+t.slice(1)).join("")}function h(e,t={}){let n=e.properties||{},r=e.required||[];return Object.assign(Object.assign({type:"object"},e),{required:r,properties:Object.keys(n).reduce((i,o)=>{let s=Object.assign(Object.assign({},n[o]),{default:t.hasOwnProperty(o)?t[o]:n[o].default,title:n[o].title||b(o).split("-").map(a=>a.charAt(0).toUpperCase()+a.slice(1).toLowerCase()).join(" ")});return s.default===void 0&&delete s.default,"required"in s&&typeof s.required=="boolean"&&(r.indexOf(o)==-1&&r.push(o),delete s.required),Object.assign(i,{[o]:s})},{})})}var _=(e,t)=>{let n=Object.assign({},e);return Object.keys(t).filter(i=>/(integer|number)/.test(t[i].type)).forEach(i=>{var o;!((o=n[i])===null||o===void 0)&&o["ui:widget"]||(n[i]=Object.assign(Object.assign({},n[i]),{"ui:widget":"updown"}))}),n};function v(e,t){switch(t){case"string":return e;case"object":try{return typeof e=="object"&&e!=null?e:JSON.parse(e)}catch(n){return null}case"array":try{return Array.isArray(e)?e:JSON.parse(e)}catch(n){return null}case"number":return parseFloat(e);case"integer":return parseInt(e);case"boolean":return e=="true"||e=="1";default:return e}}function W(e,t){return Object.keys(t).reduce((n,r)=>{let i=t[r],o=O(r),s=e==null?void 0:e.properties[o],a=s==null?void 0:s.type,l=v(i,a);return l!=null&&!r.startsWith("data-attribute")&&!["class","id","contenteditable"].includes(r)?Object.assign(Object.assign({},n),{[o]:l}):n},{})}function P(e,t){return Object.assign(Object.assign({},B(e)),W(e,t))}function B(e){return Object.keys(e.properties).reduce((t,n)=>{var r,i;return((r=e.properties[n])===null||r===void 0?void 0:r.default)!=null?Object.assign(Object.assign({},t),{[n]:(i=e.properties[n])===null||i===void 0?void 0:i.default}):t},{})}var j=typeof window!="undefined"?window.BYOCDatasources||(window.BYOCDatasources={}):{};function A(e,t){if(typeof e!="function")throw new Error("The first argument of registerDatasource must be a function returning DataSettings or Promise of data");if(!t.id)throw new Error("Missing 'id' property in input");if(!/^[a-zA-Z0-9-_]+$/.test(t.id))throw new Error("Invalid 'id' property in input. 'id' should only contain alphanumeric characters, hyphens, and underscores.");j[t.id]=Object.assign(Object.assign({},U(t)),{handler:e}),N()}function J(e){return j[e]}function U(e){let{id:t,name:n,title:r,properties:i,sample:o,schema:s,description:a=null,type:l="object"}=e;return{id:t,description:a,sample:o,name:n||r||t,handler:u=>u,schema:s||i?h(Object.assign(Object.assign({},s||{properties:i,type:l}),{title:(s==null?void 0:s.title)||r||n})):void 0}}var D;function N(){clearTimeout(D),D=setTimeout(()=>{var e;typeof window!="undefined"&&window.parent!==window&&((e=window.parent)===null||e===void 0||e.postMessage(JSON.stringify({action:"register-datasources",data:Object.values(j)}),"*"))},30)}N();function X(e,t){let n=j[e];return n!=null&&n.handler?n.handler(t):t}var K=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n};function k(e,t,n){let{thumbnail:r="https://feaasstatic.blob.core.windows.net/assets/thumbnails/byoc.svg",name:i,id:o=e.name,group:s=null,ui:a,isHidden:l=!1,datasourceIds:u=[],links:g={},meta:f={},uiSchema:p,schema:c}=e,d=K(e,["thumbnail","name","id","group","ui","isHidden","datasourceIds","links","meta","uiSchema","schema"]),S=c||d||{},H=p||a||{},m=h(Object.assign(Object.assign({description:"External component"},S),{type:"object"}),n),I=_(H,m.properties||{});return{component:t||(()=>null),name:i,schema:m,uiSchema:I,thumbnail:r,group:s||"Default collection",isHidden:l,id:o,datasourceIds:u,links:g,meta:f,title:(m==null?void 0:m.title)||(d==null?void 0:d.title)||i}}var T,q=typeof HTMLElement!="undefined"?HTMLElement:typeof windowJSDOM!="undefined"?windowJSDOM.HTMLElement:class{setAttribute(){}},y=typeof window!="undefined"?window.BYOCComponents||(window.BYOCComponents={}):{};function z(e,t,n={}){if(!(t!=null&&t.name))throw new Error("Could not register external component. Please make sure you provide a name in the options"+JSON.stringify(t));let r=k(t,e,n);y[r.id]=r,L(e)&&w.register("byoc-"+b(t.name),void 0,e),M()}function L(e){return e&&"prototype"in e&&"setAttribute"in e.prototype}function R(e,t={}){var n;let r=(n=C(e))===null||n===void 0?void 0:n.schema;return r?P(r,t):t}function re(e){let t=C(e);return Object.keys((t==null?void 0:t.schema.properties)||{}).filter(n=>{var r,i;return((i=(r=t==null?void 0:t.uiSchema)===null||r===void 0?void 0:r[n])===null||i===void 0?void 0:i["ui:widget"])!="hidden"})}function C(e){if(typeof e!="string"){if(e&&"schema"in e)return e;throw new Error(`Component name should be a string, got ${typeof e}`)}let[t,n]=e.split("?");var r=y[t];if(n){let i=y[e];if(!i&&!r)return null;i&&(r=Object.assign(Object.assign(Object.assign({},r),i),{component:i.component||(r==null?void 0:r.component)})),n.split(/\&/g).forEach(o=>{var s,a,l;let[u,g]=o.split("="),f=((s=r.schema.properties)===null||s===void 0?void 0:s[u])||{type:"string"};r=Object.assign(Object.assign({},r),{schema:Object.assign(Object.assign({},r.schema),{properties:Object.assign(Object.assign({},r.schema.properties),{[u]:Object.assign(Object.assign({},f),{default:v(decodeURIComponent(g),f.type)})})}),uiSchema:Object.assign(Object.assign({},r.uiSchema),{[u]:Object.assign(Object.assign({},r.uiSchema[u]),{"ui:widget":(l=(a=r.uiSchema[u])===null||a===void 0?void 0:a["ui:widget"])!==null&&l!==void 0?l:"hidden"})})})})}return r}function ie(e){let{componentName:t,className:n,fallbackWrapper:r,fallback:i,suppressHydrationWarning:o,_dynamic:s,datasources:a}=e,l=K(e,["componentName","className","fallbackWrapper","fallback","suppressHydrationWarning","_dynamic","datasources"]);try{var u=typeof a=="string"?JSON.parse(a):a}catch(c){}let g=Object.values(u||{}).find(c=>c&&!Array.isArray(c)&&Object.keys(c).length>0),f=Object.assign(Object.assign(Object.assign({},g),R(t,Object.assign(Object.assign({},g),l))),u?{datasources:u}:{}),p=Object.assign(Object.assign({"data-external-id":t},E(f)),{suppressHydrationWarning:!0,class:n});return Y.forEach(c=>{Object.assign(p,{[b(c)]:x[c]})}),Object.keys(p).forEach(c=>{let d=p[c];if(d&&typeof d=="object"&&c!="class"&&c!="children")try{Object.assign(p,{[c]:JSON.stringify(d)})}catch(S){delete p[c]}(typeof d=="function"||d==null)&&delete p[c]}),{attributes:p,properties:f,merged:Object.assign(Object.assign({},x),f)}}function M(){clearTimeout(T),T=setTimeout(()=>{var e;typeof window!="undefined"&&window.parent!==window&&((e=window.parent)===null||e===void 0||e.postMessage(JSON.stringify({action:"register-components",data:Object.values(y)}),"*"))},30)}M();var w=class extends q{connectedCallback(){try{JSON.parse(String(this.getAttribute("components"))).forEach(t=>{C(t.id)||z(null,t)}),JSON.parse(String(this.getAttribute("datasources"))).forEach(t=>{J(t.id)||A(n=>n,t)})}catch(t){}}static register(t,n,r=this){n==null&&(n=typeof window!="undefined"?window:void 0),n&&!n.customElements.get(t)&&n.customElements.define(t,class extends r{})}},x={};function oe(e){x=e}var Y=["sitecoreEdgeUrl","sitecoreEdgeContextId"];w.register("byoc-registration");export{w as BYOCRegistration,q as WebComponent,x as contextProperties,X as customizeDataSettings,C as getComponent,re as getComponentConfigurablePropertyNames,R as getComponentProperties,J as getDatasource,ie as getMergedComponentProperties,B as getSchemaDefaults,P as getSchemaProperties,L as isWebComponent,k as normalizeOptions,V as objectKeysToCamelCase,E as objectKeysToKebabCase,W as parseSchemaProperties,v as parseValue,z as registerComponent,A as registerDatasource,y as registered,j as registeredDatasources,Y as serializedContextProperties,oe as setContextProperties,M as setRegistrationCallback,O as toCamelCase,b as toKebabCase,h as transformSchema,_ as transformUiSchema};
//# sourceMappingURL=index.esm.js.map

@@ -5,3 +5,3 @@ {

"description": "Bring-Your-Own-Components runtime to register and retrieve react components",
"version": "0.2.13",
"version": "0.2.14",
"repository": {

@@ -8,0 +8,0 @@ "type": "git",

@@ -176,3 +176,3 @@ # Sitecore BYOC components

First, import the `registerDatasource` function from the `@sitecore/byoc/data` package:
First, import the `registerDatasource` function from the `@sitecore/byoc` package:

@@ -223,4 +223,4 @@ ```javascript

When datasource is registered with ID of a datasource that exist in the library, it can adjust the data settings of the
original request.
When `registerDatasource` is given an ID of a datasource that exist in the library (i.e. created via UI), the handler
can adjust the data settings of the original request.

@@ -245,3 +245,3 @@ ```typescript

// ID of a datasource as created in UI (can be visible in the address bar URL) to be extended
// No other options are specified in this case.
// No other options need to be specified for this case of intercepting datasource.
id: 'aBcDaaa23a'

@@ -254,5 +254,5 @@ }

When handler returns promise (e.g. if it's async function), it is expected that promise will return data directly in
place of original HTTP request. This allows returning data through alternative means, like reading from a file,
database, etc.
When handler returns promise (e.g. if it's async function), the promised data is passed to component directly bypassing
the original HTTP request. This allows returning data through alternative means, like reading from a file, database,
etc.

@@ -259,0 +259,0 @@ ```typescript

@@ -12,2 +12,3 @@ import { getDatasource, registerDatasource } from './datasources.js'

import { toKebabCase, objectKeysToKebabCase } from './utils.js'
import { Datasource } from './lib/types.js'

@@ -102,2 +103,4 @@ /** Normalized BYOC component */

links?: Record<string, string>
/** Key/value list of links to be displayed in BYOC Marketplace */
meta?: Record<string, string>
/**

@@ -138,2 +141,3 @@ * UI Schema providing customization of form UI.

links = {},
meta ={},
uiSchema: explicitUISchema,

@@ -161,2 +165,3 @@ schema: explicitSchema,

links,
meta,
title: schema?.title || schemaOptions?.title || name

@@ -163,0 +168,0 @@ }

/**
* The DataSettings function definition is part of the @sitecore-feaas/clientside package.
* This is the return type of the DataSettings function copied from the package to avoid a circular dependency.
* @located in https://github.com/Sitecore-PD/sitecore.components.monorepo/blob/main/clientside/src/utils/settings.ts
*
* @located in https://github.com/Sitecore-PD/sitecore.components.monorepo/blob/main/clientside/src/utils/settings.ts
*/

@@ -16,4 +17,5 @@ export type DataSettings = {

/**
* This is the DataSource type copied from the @sitecore-feaas/sdk package for reference
* @located in https://github.com/Sitecore-PD/sitecore.components.monorepo/blob/main/sdk/src/models/datasources.ts
* This is the DataSource type copied from the @sitecore-feaas/sdk package for reference.
*
* @located in https://github.com/Sitecore-PD/sitecore.components.monorepo/blob/main/sdk/src/models/datasources.ts
*/

@@ -81,3 +83,3 @@

*/
type?: 'internal' | 'xmTemplate' | 'contentHubOne'
type?: 'internal' | 'external' | 'xmTemplate' | 'contentHubOne'

@@ -84,0 +86,0 @@ /**

@@ -87,2 +87,4 @@ /// <reference types="@types/react" />

links?: Record<string, string>;
/** Key/value list of links to be displayed in BYOC Marketplace */
meta?: Record<string, string>;
/**

@@ -111,2 +113,3 @@ * UI Schema providing customization of form UI.

links: Record<string, string>;
meta: Record<string, string>;
title: string;

@@ -216,2 +219,3 @@ };

links: Record<string, string>;
meta: Record<string, string>;
title: string;

@@ -218,0 +222,0 @@ } | null;

/**
* The DataSettings function definition is part of the @sitecore-feaas/clientside package.
* This is the return type of the DataSettings function copied from the package to avoid a circular dependency.
* @located in https://github.com/Sitecore-PD/sitecore.components.monorepo/blob/main/clientside/src/utils/settings.ts
*
* @located in https://github.com/Sitecore-PD/sitecore.components.monorepo/blob/main/clientside/src/utils/settings.ts
*/

@@ -15,4 +16,5 @@ export type DataSettings = {

/**
* This is the DataSource type copied from the @sitecore-feaas/sdk package for reference
* @located in https://github.com/Sitecore-PD/sitecore.components.monorepo/blob/main/sdk/src/models/datasources.ts
* This is the DataSource type copied from the @sitecore-feaas/sdk package for reference.
*
* @located in https://github.com/Sitecore-PD/sitecore.components.monorepo/blob/main/sdk/src/models/datasources.ts
*/

@@ -69,3 +71,3 @@ /** Defines the schema for Datasource. */

*/
type?: 'internal' | 'xmTemplate' | 'contentHubOne';
type?: 'internal' | 'external' | 'xmTemplate' | 'contentHubOne';
/**

@@ -72,0 +74,0 @@ * Id of external source. Eg: Tenant name for XM Cloud datasources, Project Id for internal datasources etc.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc