ice-entity-designer-dsl 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("ice-entity-designer");function validateDsl(e){const t=[];if(!e||"object"!=typeof e||Array.isArray(e))return{valid:!1,errors:["DSL root must be an object"]};if(void 0!==e.schemaVersion&&1!==e.schemaVersion&&t.push("Unsupported schemaVersion: "+e.schemaVersion),Array.isArray(e.entities)){const i=new Set;e.entities.forEach((e,r)=>{const n=`entities[${r}]`;e&&"object"==typeof e?("string"==typeof e.id&&e.id.trim()?i.has(e.id)?t.push(`${n}.id is duplicated: ${e.id}`):i.add(e.id):t.push(n+".id must be a non-empty string"),Array.isArray(e.fields)?e.fields.forEach((e,i)=>{e&&"object"==typeof e&&"string"==typeof e.name&&e.name.trim()||t.push(`${n}.fields[${i}].name must be a non-empty string`)}):t.push(n+".fields must be an array")):t.push(n+" must be an object")})}else t.push("entities must be an array");return void 0===e.relations||Array.isArray(e.relations)?(e.relations||[]).forEach((e,i)=>{const r=`relations[${i}]`;e&&"object"==typeof e?("string"==typeof e.source&&e.source.trim()||t.push(r+".source must be a non-empty string"),"string"==typeof e.target&&e.target.trim()||t.push(r+".target must be a non-empty string")):t.push(r+" must be an object")}):t.push("relations must be an array"),{valid:0===t.length,errors:t}}function entityName(e){return e.entityName||e.name||e.id}function relationType(e){return e.relationType||e.type||"one-to-many"}function compileDsl(e){return{entities:e.entities.map(e=>({id:e.id,entityName:entityName(e),fields:e.fields||[],left:e.left,top:e.top,width:e.width,height:e.height,style:e.style,headerStyle:e.headerStyle,fieldStyle:e.fieldStyle,dividerStyle:e.dividerStyle,draggable:e.draggable,interactive:e.interactive})),relations:(e.relations||[]).map((e,t)=>({id:e.id||"relation-"+t,relationType:relationType(e),sourceId:e.source,targetId:e.target,sourceField:e.sourceField||"id",targetField:e.targetField||"id",nullable:e.nullable,onDelete:e.onDelete,onUpdate:e.onUpdate,joinTableName:e.joinTableName,fromKey:e.fromKey,toKey:e.toKey,sourceCardinality:e.sourceCardinality,targetCardinality:e.targetCardinality,label:e.label,style:e.style,arrow:e.arrow,linkShape:e.linkShape,routeType:e.routeType,routeOffset:e.routeOffset,curveType:e.curveType,lineDash:e.lineDash})),layout:e.layout,options:e.options}}exports.DSL_SCHEMA_VERSION=1,exports.compileDsl=compileDsl,exports.renderDsl=function renderDsl(t,i){const r=validateDsl(i);if(!r.valid)throw new Error(r.errors.join("\n"));const n=compileDsl(i),a=(new e.ICE).init(t),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("ice-entity-designer");function validateDsl(e){const t=[];if(!e||"object"!=typeof e||Array.isArray(e))return{valid:!1,errors:["DSL root must be an object"]};if(void 0!==e.schemaVersion&&1!==e.schemaVersion&&t.push("Unsupported schemaVersion: "+e.schemaVersion),Array.isArray(e.entities)){const i=new Set;e.entities.forEach((e,r)=>{const n=`entities[${r}]`;e&&"object"==typeof e?("string"==typeof e.id&&e.id.trim()?i.has(e.id)?t.push(`${n}.id is duplicated: ${e.id}`):i.add(e.id):t.push(n+".id must be a non-empty string"),Array.isArray(e.fields)?e.fields.forEach((e,i)=>{e&&"object"==typeof e&&"string"==typeof e.name&&e.name.trim()||t.push(`${n}.fields[${i}].name must be a non-empty string`)}):t.push(n+".fields must be an array")):t.push(n+" must be an object")})}else t.push("entities must be an array");return void 0===e.relations||Array.isArray(e.relations)?(e.relations||[]).forEach((e,i)=>{const r=`relations[${i}]`;e&&"object"==typeof e?("string"==typeof e.source&&e.source.trim()||t.push(r+".source must be a non-empty string"),"string"==typeof e.target&&e.target.trim()||t.push(r+".target must be a non-empty string")):t.push(r+" must be an object")}):t.push("relations must be an array"),{valid:0===t.length,errors:t}}function entityName(e){return e.entityName||e.name||e.id}function relationType(e){return e.relationType||e.type||"one-to-many"}function compileDsl(e){return{entities:e.entities.map(e=>({id:e.id,entityName:entityName(e),fields:e.fields||[],left:e.left,top:e.top,width:e.width,height:e.height,style:e.style,headerStyle:e.headerStyle,fieldStyle:e.fieldStyle,dividerStyle:e.dividerStyle,draggable:e.draggable,interactive:e.interactive})),relations:(e.relations||[]).map((e,t)=>({id:e.id||"relation-"+t,relationType:relationType(e),sourceId:e.source,targetId:e.target,sourceField:e.sourceField||"id",targetField:e.targetField||"id",nullable:e.nullable,onDelete:e.onDelete,onUpdate:e.onUpdate,joinTableName:e.joinTableName,fromKey:e.fromKey,toKey:e.toKey,sourceCardinality:e.sourceCardinality,targetCardinality:e.targetCardinality,label:e.label,style:e.style,arrow:e.arrow,linkShape:e.linkShape,routeType:e.routeType,routeOffset:e.routeOffset,curveType:e.curveType,lineDash:e.lineDash})),layout:e.layout,options:e.options}}exports.DSL_SCHEMA_VERSION=1,exports.compileDsl=compileDsl,exports.renderDsl=function renderDsl(t,i){const r=validateDsl(i);if(!r.valid)throw new Error(r.errors.join("\n"));const n=compileDsl(i),a=n.options||{},o=(new e.ICE).init(t),s=new e.EntityDesigner(o);return n.entities.forEach(e=>{s.createEntity(e)}),function positionLinks(e,t,i){const r=new Map;return e.entities.forEach(e=>{r.set(e.state.id,e.getMinBoundingBox(!0))}),t.relations.map(e=>{const t=r.get(e.sourceId),n=r.get(e.targetId);let a="R",o="L";if(t&&n){const e=n.center[0]-t.center[0],i=n.center[1]-t.center[1];Math.abs(e)>Math.abs(i)?(a=e>=0?"R":"L",o=e>=0?"L":"R"):(a=i>=0?"B":"T",o=i>=0?"T":"B")}return{...e,routeType:e.routeType||i||"orthogonal",linkShape:e.linkShape||"visio",links:{start:{id:e.sourceId,position:a},end:{id:e.targetId,position:o}}}})}(s,n,a.routeType).forEach(e=>{s.createRelation(e)}),"layered"!==n.layout&&"horizontal"!==n.layout||new e.ICELayeredLayout({gapX:a.gapX||120,gapY:a.gapY||50}).layoutContainer(o),a.viewport?o.setViewport(a.viewport.scale,a.viewport.tx,a.viewport.ty):a.fitViewport&&function fitViewport(e,t,i){const r=t.entities||[];let n=1/0,a=1/0,o=-1/0,s=-1/0;r.forEach(e=>{const t=e.getMinBoundingBox(!0).getMinAndMaxPoint();n=Math.min(n,t.minX),a=Math.min(a,t.minY),o=Math.max(o,t.maxX),s=Math.max(s,t.maxY)});const l=o-n,d=s-a,p=e.canvasWidth||0,u=e.canvasHeight||0;if(!p||!u||l<=0||d<=0)return;const c=Number.isFinite(i)&&i>=0?i:40,y=Math.max(1,p-2*c),m=Math.max(1,u-2*c),h=Math.min(y/l,m/d,1),f=(p-l*h)/2-n*h,g=(u-d*h)/2-a*h;e.setViewport(h,f,g)}(o,s,a.fitViewportPadding),{ice:o,designer:s}},exports.validateDsl=validateDsl;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ICE as e,EntityDesigner as t,ICELayeredLayout as i}from"ice-entity-designer";const r=1;function validateDsl(e){const t=[];if(!e||"object"!=typeof e||Array.isArray(e))return{valid:!1,errors:["DSL root must be an object"]};if(void 0!==e.schemaVersion&&1!==e.schemaVersion&&t.push("Unsupported schemaVersion: "+e.schemaVersion),Array.isArray(e.entities)){const i=new Set;e.entities.forEach((e,r)=>{const n=`entities[${r}]`;e&&"object"==typeof e?("string"==typeof e.id&&e.id.trim()?i.has(e.id)?t.push(`${n}.id is duplicated: ${e.id}`):i.add(e.id):t.push(n+".id must be a non-empty string"),Array.isArray(e.fields)?e.fields.forEach((e,i)=>{e&&"object"==typeof e&&"string"==typeof e.name&&e.name.trim()||t.push(`${n}.fields[${i}].name must be a non-empty string`)}):t.push(n+".fields must be an array")):t.push(n+" must be an object")})}else t.push("entities must be an array");return void 0===e.relations||Array.isArray(e.relations)?(e.relations||[]).forEach((e,i)=>{const r=`relations[${i}]`;e&&"object"==typeof e?("string"==typeof e.source&&e.source.trim()||t.push(r+".source must be a non-empty string"),"string"==typeof e.target&&e.target.trim()||t.push(r+".target must be a non-empty string")):t.push(r+" must be an object")}):t.push("relations must be an array"),{valid:0===t.length,errors:t}}function entityName(e){return e.entityName||e.name||e.id}function relationType(e){return e.relationType||e.type||"one-to-many"}function compileDsl(e){return{entities:e.entities.map(e=>({id:e.id,entityName:entityName(e),fields:e.fields||[],left:e.left,top:e.top,width:e.width,height:e.height,style:e.style,headerStyle:e.headerStyle,fieldStyle:e.fieldStyle,dividerStyle:e.dividerStyle,draggable:e.draggable,interactive:e.interactive})),relations:(e.relations||[]).map((e,t)=>({id:e.id||"relation-"+t,relationType:relationType(e),sourceId:e.source,targetId:e.target,sourceField:e.sourceField||"id",targetField:e.targetField||"id",nullable:e.nullable,onDelete:e.onDelete,onUpdate:e.onUpdate,joinTableName:e.joinTableName,fromKey:e.fromKey,toKey:e.toKey,sourceCardinality:e.sourceCardinality,targetCardinality:e.targetCardinality,label:e.label,style:e.style,arrow:e.arrow,linkShape:e.linkShape,routeType:e.routeType,routeOffset:e.routeOffset,curveType:e.curveType,lineDash:e.lineDash})),layout:e.layout,options:e.options}}function renderDsl(r,n){const a=validateDsl(n);if(!a.valid)throw new Error(a.errors.join("\n"));const o=compileDsl(n),s=(new e).init(r),
|
|
1
|
+
import{ICE as e,EntityDesigner as t,ICELayeredLayout as i}from"ice-entity-designer";const r=1;function validateDsl(e){const t=[];if(!e||"object"!=typeof e||Array.isArray(e))return{valid:!1,errors:["DSL root must be an object"]};if(void 0!==e.schemaVersion&&1!==e.schemaVersion&&t.push("Unsupported schemaVersion: "+e.schemaVersion),Array.isArray(e.entities)){const i=new Set;e.entities.forEach((e,r)=>{const n=`entities[${r}]`;e&&"object"==typeof e?("string"==typeof e.id&&e.id.trim()?i.has(e.id)?t.push(`${n}.id is duplicated: ${e.id}`):i.add(e.id):t.push(n+".id must be a non-empty string"),Array.isArray(e.fields)?e.fields.forEach((e,i)=>{e&&"object"==typeof e&&"string"==typeof e.name&&e.name.trim()||t.push(`${n}.fields[${i}].name must be a non-empty string`)}):t.push(n+".fields must be an array")):t.push(n+" must be an object")})}else t.push("entities must be an array");return void 0===e.relations||Array.isArray(e.relations)?(e.relations||[]).forEach((e,i)=>{const r=`relations[${i}]`;e&&"object"==typeof e?("string"==typeof e.source&&e.source.trim()||t.push(r+".source must be a non-empty string"),"string"==typeof e.target&&e.target.trim()||t.push(r+".target must be a non-empty string")):t.push(r+" must be an object")}):t.push("relations must be an array"),{valid:0===t.length,errors:t}}function entityName(e){return e.entityName||e.name||e.id}function relationType(e){return e.relationType||e.type||"one-to-many"}function compileDsl(e){return{entities:e.entities.map(e=>({id:e.id,entityName:entityName(e),fields:e.fields||[],left:e.left,top:e.top,width:e.width,height:e.height,style:e.style,headerStyle:e.headerStyle,fieldStyle:e.fieldStyle,dividerStyle:e.dividerStyle,draggable:e.draggable,interactive:e.interactive})),relations:(e.relations||[]).map((e,t)=>({id:e.id||"relation-"+t,relationType:relationType(e),sourceId:e.source,targetId:e.target,sourceField:e.sourceField||"id",targetField:e.targetField||"id",nullable:e.nullable,onDelete:e.onDelete,onUpdate:e.onUpdate,joinTableName:e.joinTableName,fromKey:e.fromKey,toKey:e.toKey,sourceCardinality:e.sourceCardinality,targetCardinality:e.targetCardinality,label:e.label,style:e.style,arrow:e.arrow,linkShape:e.linkShape,routeType:e.routeType,routeOffset:e.routeOffset,curveType:e.curveType,lineDash:e.lineDash})),layout:e.layout,options:e.options}}function renderDsl(r,n){const a=validateDsl(n);if(!a.valid)throw new Error(a.errors.join("\n"));const o=compileDsl(n),s=o.options||{},l=(new e).init(r),d=new t(l);return o.entities.forEach(e=>{d.createEntity(e)}),function positionLinks(e,t,i){const r=new Map;return e.entities.forEach(e=>{r.set(e.state.id,e.getMinBoundingBox(!0))}),t.relations.map(e=>{const t=r.get(e.sourceId),n=r.get(e.targetId);let a="R",o="L";if(t&&n){const e=n.center[0]-t.center[0],i=n.center[1]-t.center[1];Math.abs(e)>Math.abs(i)?(a=e>=0?"R":"L",o=e>=0?"L":"R"):(a=i>=0?"B":"T",o=i>=0?"T":"B")}return{...e,routeType:e.routeType||i||"orthogonal",linkShape:e.linkShape||"visio",links:{start:{id:e.sourceId,position:a},end:{id:e.targetId,position:o}}}})}(d,o,s.routeType).forEach(e=>{d.createRelation(e)}),"layered"!==o.layout&&"horizontal"!==o.layout||new i({gapX:s.gapX||120,gapY:s.gapY||50}).layoutContainer(l),s.viewport?l.setViewport(s.viewport.scale,s.viewport.tx,s.viewport.ty):s.fitViewport&&function fitViewport(e,t,i){const r=t.entities||[];let n=1/0,a=1/0,o=-1/0,s=-1/0;r.forEach(e=>{const t=e.getMinBoundingBox(!0).getMinAndMaxPoint();n=Math.min(n,t.minX),a=Math.min(a,t.minY),o=Math.max(o,t.maxX),s=Math.max(s,t.maxY)});const l=o-n,d=s-a,p=e.canvasWidth||0,c=e.canvasHeight||0;if(!p||!c||l<=0||d<=0)return;const u=Number.isFinite(i)&&i>=0?i:40,y=Math.max(1,p-2*u),m=Math.max(1,c-2*u),h=Math.min(y/l,m/d,1),f=(p-l*h)/2-n*h,g=(c-d*h)/2-a*h;e.setViewport(h,f,g)}(l,d,s.fitViewportPadding),{ice:l,designer:d}}export{r as DSL_SCHEMA_VERSION,compileDsl,renderDsl,validateDsl};
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("ice-entity-designer")):"function"==typeof define&&define.amd?define(["exports","ice-entity-designer"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ICEDSL={},e.IED)}(this,(function(e,t){"use strict";function validateDsl(e){const t=[];if(!e||"object"!=typeof e||Array.isArray(e))return{valid:!1,errors:["DSL root must be an object"]};if(void 0!==e.schemaVersion&&1!==e.schemaVersion&&t.push("Unsupported schemaVersion: "+e.schemaVersion),Array.isArray(e.entities)){const i=new Set;e.entities.forEach((e,
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("ice-entity-designer")):"function"==typeof define&&define.amd?define(["exports","ice-entity-designer"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ICEDSL={},e.IED)}(this,(function(e,t){"use strict";function validateDsl(e){const t=[];if(!e||"object"!=typeof e||Array.isArray(e))return{valid:!1,errors:["DSL root must be an object"]};if(void 0!==e.schemaVersion&&1!==e.schemaVersion&&t.push("Unsupported schemaVersion: "+e.schemaVersion),Array.isArray(e.entities)){const i=new Set;e.entities.forEach((e,n)=>{const r=`entities[${n}]`;e&&"object"==typeof e?("string"==typeof e.id&&e.id.trim()?i.has(e.id)?t.push(`${r}.id is duplicated: ${e.id}`):i.add(e.id):t.push(r+".id must be a non-empty string"),Array.isArray(e.fields)?e.fields.forEach((e,i)=>{e&&"object"==typeof e&&"string"==typeof e.name&&e.name.trim()||t.push(`${r}.fields[${i}].name must be a non-empty string`)}):t.push(r+".fields must be an array")):t.push(r+" must be an object")})}else t.push("entities must be an array");return void 0===e.relations||Array.isArray(e.relations)?(e.relations||[]).forEach((e,i)=>{const n=`relations[${i}]`;e&&"object"==typeof e?("string"==typeof e.source&&e.source.trim()||t.push(n+".source must be a non-empty string"),"string"==typeof e.target&&e.target.trim()||t.push(n+".target must be a non-empty string")):t.push(n+" must be an object")}):t.push("relations must be an array"),{valid:0===t.length,errors:t}}function entityName(e){return e.entityName||e.name||e.id}function relationType(e){return e.relationType||e.type||"one-to-many"}function compileDsl(e){return{entities:e.entities.map(e=>({id:e.id,entityName:entityName(e),fields:e.fields||[],left:e.left,top:e.top,width:e.width,height:e.height,style:e.style,headerStyle:e.headerStyle,fieldStyle:e.fieldStyle,dividerStyle:e.dividerStyle,draggable:e.draggable,interactive:e.interactive})),relations:(e.relations||[]).map((e,t)=>({id:e.id||"relation-"+t,relationType:relationType(e),sourceId:e.source,targetId:e.target,sourceField:e.sourceField||"id",targetField:e.targetField||"id",nullable:e.nullable,onDelete:e.onDelete,onUpdate:e.onUpdate,joinTableName:e.joinTableName,fromKey:e.fromKey,toKey:e.toKey,sourceCardinality:e.sourceCardinality,targetCardinality:e.targetCardinality,label:e.label,style:e.style,arrow:e.arrow,linkShape:e.linkShape,routeType:e.routeType,routeOffset:e.routeOffset,curveType:e.curveType,lineDash:e.lineDash})),layout:e.layout,options:e.options}}e.DSL_SCHEMA_VERSION=1,e.compileDsl=compileDsl,e.renderDsl=function renderDsl(e,i){const n=validateDsl(i);if(!n.valid)throw new Error(n.errors.join("\n"));const r=compileDsl(i),a=r.options||{},o=(new t.ICE).init(e),s=new t.EntityDesigner(o);return r.entities.forEach(e=>{s.createEntity(e)}),function positionLinks(e,t,i){const n=new Map;return e.entities.forEach(e=>{n.set(e.state.id,e.getMinBoundingBox(!0))}),t.relations.map(e=>{const t=n.get(e.sourceId),r=n.get(e.targetId);let a="R",o="L";if(t&&r){const e=r.center[0]-t.center[0],i=r.center[1]-t.center[1];Math.abs(e)>Math.abs(i)?(a=e>=0?"R":"L",o=e>=0?"L":"R"):(a=i>=0?"B":"T",o=i>=0?"T":"B")}return{...e,routeType:e.routeType||i||"orthogonal",linkShape:e.linkShape||"visio",links:{start:{id:e.sourceId,position:a},end:{id:e.targetId,position:o}}}})}(s,r,a.routeType).forEach(e=>{s.createRelation(e)}),"layered"!==r.layout&&"horizontal"!==r.layout||new t.ICELayeredLayout({gapX:a.gapX||120,gapY:a.gapY||50}).layoutContainer(o),a.viewport?o.setViewport(a.viewport.scale,a.viewport.tx,a.viewport.ty):a.fitViewport&&function fitViewport(e,t,i){const n=t.entities||[];let r=1/0,a=1/0,o=-1/0,s=-1/0;n.forEach(e=>{const t=e.getMinBoundingBox(!0).getMinAndMaxPoint();r=Math.min(r,t.minX),a=Math.min(a,t.minY),o=Math.max(o,t.maxX),s=Math.max(s,t.maxY)});const l=o-r,d=s-a,p=e.canvasWidth||0,u=e.canvasHeight||0;if(!p||!u||l<=0||d<=0)return;const c=Number.isFinite(i)&&i>=0?i:40,y=Math.max(1,p-2*c),f=Math.max(1,u-2*c),m=Math.min(y/l,f/d,1),h=(p-l*m)/2-r*m,g=(u-d*m)/2-a*m;e.setViewport(m,h,g)}(o,s,a.fitViewportPadding),{ice:o,designer:s}},e.validateDsl=validateDsl,Object.defineProperty(e,"__esModule",{value:!0})}));
|