@dbml/core 11.0.0-alpha.4 → 11.0.0-alpha.6

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/lib/index.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require("./_virtual/_rolldown/runtime.cjs");const e=require("./parse/error.cjs"),t=require("./parse/Parser.cjs"),n=require("./export/index.cjs"),r=require("./export/ModelExporter.cjs"),i=require("./import/index.cjs"),a=require("./transform/index.cjs"),o=require("./utils/version.cjs"),s=require("./transform/relations.cjs");let c=require("@dbml/parse");Object.defineProperty(exports,"CARDINALITY_MANY",{enumerable:!0,get:function(){return c.CARDINALITY_MANY}}),Object.defineProperty(exports,"CARDINALITY_MAYBE",{enumerable:!0,get:function(){return c.CARDINALITY_MAYBE}}),Object.defineProperty(exports,"CARDINALITY_ONE",{enumerable:!0,get:function(){return c.CARDINALITY_ONE}}),Object.defineProperty(exports,"CARDINALITY_SOME",{enumerable:!0,get:function(){return c.CARDINALITY_SOME}}),exports.CompilerError=e.CompilerError,Object.defineProperty(exports,"DEFAULT_ENTRY",{enumerable:!0,get:function(){return c.DEFAULT_ENTRY}}),Object.defineProperty(exports,"Filepath",{enumerable:!0,get:function(){return c.Filepath}}),Object.defineProperty(exports,"MetadataKind",{enumerable:!0,get:function(){return c.MetadataKind}}),exports.ModelExporter=r.default,exports.Parser=t.default,Object.defineProperty(exports,"SymbolKind",{enumerable:!0,get:function(){return c.SymbolKind}}),exports.VERSION=o.VERSION,Object.defineProperty(exports,"addDoubleQuoteIfNeeded",{enumerable:!0,get:function(){return c.addDoubleQuoteIfNeeded}}),Object.defineProperty(exports,"dbmlMonarchTokensProvider",{enumerable:!0,get:function(){return c.dbmlMonarchTokensProvider}}),exports.exporter=n.default,Object.defineProperty(exports,"findDiagramViewBlocks",{enumerable:!0,get:function(){return c.findDiagramViewBlocks}}),Object.defineProperty(exports,"formatRecordValue",{enumerable:!0,get:function(){return c.formatRecordValue}}),Object.defineProperty(exports,"getMultiplicities",{enumerable:!0,get:function(){return c.getMultiplicities}}),Object.defineProperty(exports,"getRelationshipOp",{enumerable:!0,get:function(){return c.getRelationshipOp}}),exports.importer=i.default,exports.inferMultiplicitiesFromColumns=s.inferMultiplicitiesFromColumns,Object.defineProperty(exports,"isBinaryType",{enumerable:!0,get:function(){return c.isBinaryType}}),Object.defineProperty(exports,"isBooleanType",{enumerable:!0,get:function(){return c.isBooleanType}}),Object.defineProperty(exports,"isDateTimeType",{enumerable:!0,get:function(){return c.isDateTimeType}}),Object.defineProperty(exports,"isEndpointManySide",{enumerable:!0,get:function(){return c.isEndpointManySide}}),Object.defineProperty(exports,"isEndpointOneSide",{enumerable:!0,get:function(){return c.isEndpointOneSide}}),Object.defineProperty(exports,"isEndpointOptional",{enumerable:!0,get:function(){return c.isEndpointOptional}}),Object.defineProperty(exports,"isEndpointRequired",{enumerable:!0,get:function(){return c.isEndpointRequired}}),Object.defineProperty(exports,"isFloatType",{enumerable:!0,get:function(){return c.isFloatType}}),Object.defineProperty(exports,"isIntegerType",{enumerable:!0,get:function(){return c.isIntegerType}}),Object.defineProperty(exports,"isNumericType",{enumerable:!0,get:function(){return c.isNumericType}}),Object.defineProperty(exports,"isSerialType",{enumerable:!0,get:function(){return c.isSerialType}}),Object.defineProperty(exports,"isStringType",{enumerable:!0,get:function(){return c.isStringType}}),Object.defineProperty(exports,"makeRelationshipRequired",{enumerable:!0,get:function(){return c.makeRelationshipRequired}}),exports.renameElement=a.renameElement,exports.renameTable=a.renameTable,exports.syncDep=a.syncDep,exports.syncDiagramView=a.syncDiagramView,Object.defineProperty(exports,"tryExtractBoolean",{enumerable:!0,get:function(){return c.tryExtractBoolean}}),Object.defineProperty(exports,"tryExtractDateTime",{enumerable:!0,get:function(){return c.tryExtractDateTime}}),Object.defineProperty(exports,"tryExtractEnum",{enumerable:!0,get:function(){return c.tryExtractEnum}}),Object.defineProperty(exports,"tryExtractInteger",{enumerable:!0,get:function(){return c.tryExtractInteger}}),Object.defineProperty(exports,"tryExtractNumeric",{enumerable:!0,get:function(){return c.tryExtractNumeric}}),Object.defineProperty(exports,"tryExtractString",{enumerable:!0,get:function(){return c.tryExtractString}}),exports.updateElementSetting=a.updateElementSetting,exports.updateElementSettingEdit=a.updateElementSettingEdit;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require("./_virtual/_rolldown/runtime.cjs");const e=require("./parse/error.cjs"),t=require("./parse/Parser.cjs"),n=require("./export/index.cjs"),r=require("./export/ModelExporter.cjs"),i=require("./import/index.cjs"),a=require("./transform/index.cjs"),o=require("./utils/version.cjs"),s=require("./transform/relations.cjs");let c=require("@dbml/parse");Object.defineProperty(exports,"BUILTIN_ROLES",{enumerable:!0,get:function(){return c.BUILTIN_ROLES}}),Object.defineProperty(exports,"CARDINALITY_MANY",{enumerable:!0,get:function(){return c.CARDINALITY_MANY}}),Object.defineProperty(exports,"CARDINALITY_MAYBE",{enumerable:!0,get:function(){return c.CARDINALITY_MAYBE}}),Object.defineProperty(exports,"CARDINALITY_ONE",{enumerable:!0,get:function(){return c.CARDINALITY_ONE}}),Object.defineProperty(exports,"CARDINALITY_SOME",{enumerable:!0,get:function(){return c.CARDINALITY_SOME}}),exports.CompilerError=e.CompilerError,Object.defineProperty(exports,"DEFAULT_ENTRY",{enumerable:!0,get:function(){return c.DEFAULT_ENTRY}}),Object.defineProperty(exports,"Filepath",{enumerable:!0,get:function(){return c.Filepath}}),Object.defineProperty(exports,"MetadataKind",{enumerable:!0,get:function(){return c.MetadataKind}}),exports.ModelExporter=r.default,exports.Parser=t.default,Object.defineProperty(exports,"SymbolKind",{enumerable:!0,get:function(){return c.SymbolKind}}),exports.VERSION=o.VERSION,Object.defineProperty(exports,"addDoubleQuoteIfNeeded",{enumerable:!0,get:function(){return c.addDoubleQuoteIfNeeded}}),Object.defineProperty(exports,"dbmlMonarchTokensProvider",{enumerable:!0,get:function(){return c.dbmlMonarchTokensProvider}}),exports.exporter=n.default,Object.defineProperty(exports,"findDiagramViewBlocks",{enumerable:!0,get:function(){return c.findDiagramViewBlocks}}),Object.defineProperty(exports,"formatRecordValue",{enumerable:!0,get:function(){return c.formatRecordValue}}),Object.defineProperty(exports,"getMultiplicities",{enumerable:!0,get:function(){return c.getMultiplicities}}),Object.defineProperty(exports,"getRelationshipOp",{enumerable:!0,get:function(){return c.getRelationshipOp}}),exports.importer=i.default,exports.inferMultiplicitiesFromColumns=s.inferMultiplicitiesFromColumns,Object.defineProperty(exports,"isBinaryType",{enumerable:!0,get:function(){return c.isBinaryType}}),Object.defineProperty(exports,"isBooleanType",{enumerable:!0,get:function(){return c.isBooleanType}}),Object.defineProperty(exports,"isDateTimeType",{enumerable:!0,get:function(){return c.isDateTimeType}}),Object.defineProperty(exports,"isEndpointManySide",{enumerable:!0,get:function(){return c.isEndpointManySide}}),Object.defineProperty(exports,"isEndpointOneSide",{enumerable:!0,get:function(){return c.isEndpointOneSide}}),Object.defineProperty(exports,"isEndpointOptional",{enumerable:!0,get:function(){return c.isEndpointOptional}}),Object.defineProperty(exports,"isEndpointRequired",{enumerable:!0,get:function(){return c.isEndpointRequired}}),Object.defineProperty(exports,"isFloatType",{enumerable:!0,get:function(){return c.isFloatType}}),Object.defineProperty(exports,"isIntegerType",{enumerable:!0,get:function(){return c.isIntegerType}}),Object.defineProperty(exports,"isNumericType",{enumerable:!0,get:function(){return c.isNumericType}}),Object.defineProperty(exports,"isSerialType",{enumerable:!0,get:function(){return c.isSerialType}}),Object.defineProperty(exports,"isStringType",{enumerable:!0,get:function(){return c.isStringType}}),Object.defineProperty(exports,"makeRelationshipRequired",{enumerable:!0,get:function(){return c.makeRelationshipRequired}}),exports.renameElement=a.renameElement,exports.renameTable=a.renameTable,exports.syncDep=a.syncDep,exports.syncDiagramView=a.syncDiagramView,Object.defineProperty(exports,"tryExtractBoolean",{enumerable:!0,get:function(){return c.tryExtractBoolean}}),Object.defineProperty(exports,"tryExtractDateTime",{enumerable:!0,get:function(){return c.tryExtractDateTime}}),Object.defineProperty(exports,"tryExtractEnum",{enumerable:!0,get:function(){return c.tryExtractEnum}}),Object.defineProperty(exports,"tryExtractInteger",{enumerable:!0,get:function(){return c.tryExtractInteger}}),Object.defineProperty(exports,"tryExtractNumeric",{enumerable:!0,get:function(){return c.tryExtractNumeric}}),Object.defineProperty(exports,"tryExtractString",{enumerable:!0,get:function(){return c.tryExtractString}}),exports.updateElementSetting=a.updateElementSetting,exports.updateElementSettingEdit=a.updateElementSettingEdit;
package/lib/index.mjs CHANGED
@@ -6,5 +6,5 @@ import i from "./import/index.mjs";
6
6
  import { findDiagramViewBlocks as a, renameElement as o, renameTable as s, syncDep as c, syncDiagramView as l, updateElementSetting as u, updateElementSettingEdit as d } from "./transform/index.mjs";
7
7
  import { VERSION as f } from "./utils/version.mjs";
8
8
  import { inferMultiplicitiesFromColumns as p } from "./transform/relations.mjs";
9
- import { CARDINALITY_MANY as m, CARDINALITY_MAYBE as h, CARDINALITY_ONE as g, CARDINALITY_SOME as _, DEFAULT_ENTRY as v, Filepath as y, MetadataKind as b, SymbolKind as x, addDoubleQuoteIfNeeded as S, dbmlMonarchTokensProvider as C, formatRecordValue as w, getMultiplicities as T, getRelationshipOp as E, isBinaryType as D, isBooleanType as O, isDateTimeType as k, isEndpointManySide as A, isEndpointOneSide as j, isEndpointOptional as M, isEndpointRequired as N, isFloatType as P, isIntegerType as F, isNumericType as I, isSerialType as L, isStringType as R, makeRelationshipRequired as z, tryExtractBoolean as B, tryExtractDateTime as V, tryExtractEnum as H, tryExtractInteger as U, tryExtractNumeric as W, tryExtractString as G } from "@dbml/parse";
10
- export { m as CARDINALITY_MANY, h as CARDINALITY_MAYBE, g as CARDINALITY_ONE, _ as CARDINALITY_SOME, e as CompilerError, v as DEFAULT_ENTRY, y as Filepath, b as MetadataKind, r as ModelExporter, t as Parser, x as SymbolKind, f as VERSION, S as addDoubleQuoteIfNeeded, C as dbmlMonarchTokensProvider, n as exporter, a as findDiagramViewBlocks, w as formatRecordValue, T as getMultiplicities, E as getRelationshipOp, i as importer, p as inferMultiplicitiesFromColumns, D as isBinaryType, O as isBooleanType, k as isDateTimeType, A as isEndpointManySide, j as isEndpointOneSide, M as isEndpointOptional, N as isEndpointRequired, P as isFloatType, F as isIntegerType, I as isNumericType, L as isSerialType, R as isStringType, z as makeRelationshipRequired, o as renameElement, s as renameTable, c as syncDep, l as syncDiagramView, B as tryExtractBoolean, V as tryExtractDateTime, H as tryExtractEnum, U as tryExtractInteger, W as tryExtractNumeric, G as tryExtractString, u as updateElementSetting, d as updateElementSettingEdit };
9
+ import { BUILTIN_ROLES as m, CARDINALITY_MANY as h, CARDINALITY_MAYBE as g, CARDINALITY_ONE as _, CARDINALITY_SOME as v, DEFAULT_ENTRY as y, Filepath as b, MetadataKind as x, SymbolKind as S, addDoubleQuoteIfNeeded as C, dbmlMonarchTokensProvider as w, formatRecordValue as T, getMultiplicities as E, getRelationshipOp as D, isBinaryType as O, isBooleanType as k, isDateTimeType as A, isEndpointManySide as j, isEndpointOneSide as M, isEndpointOptional as N, isEndpointRequired as P, isFloatType as F, isIntegerType as I, isNumericType as L, isSerialType as R, isStringType as z, makeRelationshipRequired as B, tryExtractBoolean as V, tryExtractDateTime as H, tryExtractEnum as U, tryExtractInteger as W, tryExtractNumeric as G, tryExtractString as K } from "@dbml/parse";
10
+ export { m as BUILTIN_ROLES, h as CARDINALITY_MANY, g as CARDINALITY_MAYBE, _ as CARDINALITY_ONE, v as CARDINALITY_SOME, e as CompilerError, y as DEFAULT_ENTRY, b as Filepath, x as MetadataKind, r as ModelExporter, t as Parser, S as SymbolKind, f as VERSION, C as addDoubleQuoteIfNeeded, w as dbmlMonarchTokensProvider, n as exporter, a as findDiagramViewBlocks, T as formatRecordValue, E as getMultiplicities, D as getRelationshipOp, i as importer, p as inferMultiplicitiesFromColumns, O as isBinaryType, k as isBooleanType, A as isDateTimeType, j as isEndpointManySide, M as isEndpointOneSide, N as isEndpointOptional, P as isEndpointRequired, F as isFloatType, I as isIntegerType, L as isNumericType, R as isSerialType, z as isStringType, B as makeRelationshipRequired, o as renameElement, s as renameTable, c as syncDep, l as syncDiagramView, V as tryExtractBoolean, H as tryExtractDateTime, U as tryExtractEnum, W as tryExtractInteger, G as tryExtractNumeric, K as tryExtractString, u as updateElementSetting, d as updateElementSettingEdit };
@@ -1 +1 @@
1
- require("../_virtual/_rolldown/runtime.cjs");const e=require("../node_modules/lodash-es/get.cjs"),t=require("../node_modules/lodash-es/capitalize.cjs"),n=require("../node_modules/lodash-es/lodash.cjs"),r=require("./config.cjs"),i=require("./dbState.cjs"),a=require("./element.cjs"),o=require("./dep.cjs"),s=require("./enum.cjs"),c=require("./ref.cjs"),l=require("./table.cjs"),u=require("./tableGroup.cjs"),d=require("./schema.cjs"),f=require("./stickyNote.cjs"),p=require("./tablePartial.cjs"),m=require("./node.cjs"),h=require("./group.cjs"),g=require("./link.cjs"),_=require("./kind.cjs");let v=require("@dbml/parse");n.init_lodash();var y=class extends a.default{constructor({schemas:t=[],tables:n=[],notes:a=[],enums:o=[],refs:s=[],deps:l=[],tableGroups:u=[],project:d={},aliases:f=[],records:p=[],tablePartials:m=[],diagramViews:h=[],nodes:g=[],groups:_=[],links:v=[],kinds:y=[],frontMatter:b,diagramType:x}={}){super(),this.dbState=new i.default,this.generateId(),this.hasDefaultSchema=!1,this.schemas=[],this.notes=[],this.note=d.note?e.default(d,`note.value`,typeof d.note==`string`?d.note:null):null,this.noteToken=d.note?e.default(d,`note.token`,d.noteToken):null,this.databaseType=d.database_type,this.name=d.name,this.token=d.token,this.aliases=f,this.records=[],this.tablePartials=[],this.diagramViews=h,this.injectedRawRefs=[],this.processNotes(a),this.processRecords(p),this.processTablePartials(m),this.processSchemas(t),this.processSchemaElements(o,r.ENUM),this.processSchemaElements(n,r.TABLE),this.linkRecordsToTables(),this.processSchemaElements(a,r.NOTE),this.processSchemaElements(s,`ref`),this.processSchemaElements(l,`dep`),this.processSchemaElements(u,r.TABLE_GROUP),this.injectedRawRefs.forEach(e=>{let t=this.findOrCreateSchema(r.DEFAULT_SCHEMA_NAME),n=new c.default({...e,schema:t});t.refs.some(e=>e.equals(n))||t.pushRef(n)}),this.nodes=[],this.groups=[],this.links=[],this.kinds=[],this.frontMatter=b??null,this.diagramType=x??null,this.processArch(y,g,_,v)}processArch(e,t,n,r){e.forEach(e=>this.kinds.push(new _.default({...e,database:this}))),t.forEach(e=>this.nodes.push(new m.default({...e,database:this}))),n.forEach(e=>this.groups.push(new h.default({...e,database:this})));let i=new Map,a=(e,t,n)=>{i.has(e)||i.set(e,{type:t,element:n})};this.nodes.forEach(e=>a(e.alias??e.name,`node`,e)),this.groups.forEach(e=>a(e.alias??e.name,`group`,e)),this.notes.forEach(e=>a(e.name,`note`,e)),this.groups.forEach(e=>{e.children.forEach(t=>{let n=i.get(t);n&&(e.childIds.push(n.element.id),e.childTypes.push(n.type),(n.element instanceof m.default||n.element instanceof h.default)&&(n.element.groupId=e.id))})}),r.forEach(({from:e,to:t,...n})=>{let r=i.get(e),a=i.get(t);!r||!a||this.links.push(new g.default({...n,fromId:r.element.id,fromType:r.type,toId:a.element.id,toType:a.type,database:this}))})}findKind(e){return this.kinds.find(t=>t.name===e)}generateId(){this.id=this.dbState.generateId(`dbId`)}processNotes(e){e.forEach(e=>{this.pushNote(new f.default({...e,database:this}))})}processRecords(e){e.forEach(({schemaName:e,tableName:t,columns:n,values:r,example:i,token:a})=>{this.records.push({id:this.dbState.generateId(`recordId`),schemaName:e,tableName:t,columns:n,values:r,example:i,token:a})})}processTablePartials(e){e.forEach(e=>{this.tablePartials.push(new p.default({...e,dbState:this.dbState}))})}pushNote(e){this.checkNote(e),this.notes.push(e)}checkNote(e){this.notes.some(t=>t.name===e.name)&&e.error(`Notes ${e.name} existed`)}processSchemas(e){e.forEach(e=>{this.pushSchema(new d.default({...e,database:this}))})}pushSchema(e){this.checkSchema(e),this.schemas.push(e)}checkSchema(e){this.schemas.some(t=>t.name===e.name)&&e.error(`Schemas ${e.name} existed`)}processSchemaElements(e,t){let n;e.forEach(e=>{switch(e.schemaName?(n=this.findOrCreateSchema(e.schemaName),e.schemaName):n=this.findOrCreateSchema(r.DEFAULT_SCHEMA_NAME),t){case r.TABLE:n.pushTable(new l.default({...e,schema:n}));break;case r.ENUM:n.pushEnum(new s.default({...e,schema:n}));break;case r.TABLE_GROUP:n.pushTableGroup(new u.default({...e,schema:n}));break;case`ref`:n.pushRef(new c.default({...e,schema:n}));break;case`dep`:n.pushDep(new o.default({...e,schema:n}));break;default:break}})}linkRecordsToTables(){let e={};this.schemas.forEach(t=>{e[t.name]={},t.tables.forEach(n=>{e[t.name][n.name]=n})}),this.records.forEach(t=>{let n=e[t.schemaName??`public`]?.[t.tableName];n&&(t.tableId=n.id,n.records.push(t))})}findOrCreateSchema(e){let n=this.schemas.find(t=>t.name===e||t.alias===e);return n||(n=new d.default({name:e,note:{value:e===`public`?`Default ${t.default(r.DEFAULT_SCHEMA_NAME)} Schema`:null},database:this}),this.pushSchema(n)),n}findTableAlias(e){let t=this.aliases.find(t=>t.name===e);if(!t||t.kind!==`table`)return null;let n=t.value.schemaName||`public`,r=this.schemas.find(e=>e.name===n);if(!r)return null;let{tableName:i}=t.value;return r.tables.find(e=>e.name===i)||null}findTable(e,t){let n=null;if(!e&&(n=this.findTableAlias(t),n))return n;let r=this.findOrCreateSchema(e||`public`);return r||this.error(`Schema ${e||`public`} don't exist`),r.findTable(t)}findEnum(e,t){let n=this.schemas.find(t=>t.name===e||t.alias===e);if(n)return n.enums.find(e=>e.name===t)}findTablePartial(e){return this.tablePartials.find(t=>t.name===e)}adjustCardinalitiesFromColumns(){this.schemas.forEach(e=>{e.refs.forEach(e=>{let t=e.endpoints.find(e=>(0,v.parseCardinality)(e.relation).max===`*`),n=e.endpoints.find(e=>(0,v.parseCardinality)(e.relation).max===1);if(!n)return;let r,i;t?(r=t,i=n):(r=e.endpoints[1],i=e.endpoints[0]),!(!r||!i)&&r.fields.every(e=>e.not_null||e.pk||e.increment)&&(i.relation=(0,v.makeCardinalityRequired)(i.relation))})})}export(){return{...this.exportChild()}}shallowExport(){return{hasDefaultSchema:this.hasDefaultSchema,note:this.note,databaseType:this.databaseType,name:this.name}}exportChild(){return{schemas:this.schemas.map(e=>e.export()),notes:this.notes.map(e=>e.export()),records:this.records.map(e=>({...e})),...this.archEntries(e=>e.map(e=>e.export()))}}exportChildIds(){return{schemaIds:this.schemas.map(e=>e.id),noteIds:this.notes.map(e=>e.id),...this.archIds(),...this.frontMatter?{frontMatter:this.frontMatter}:{},...this.diagramType?{diagramType:this.diagramType}:{}}}archEntries(e){let t={},n={nodes:this.nodes,groups:this.groups,links:this.links,kinds:this.kinds};return Object.entries(n).forEach(([n,r])=>{r.length&&(t[n]=e(r))}),t}archIds(){let e=this.archEntries(e=>e.map(e=>e.id));return{...e.nodes?{nodeIds:e.nodes}:{},...e.groups?{groupIds:e.groups}:{},...e.links?{linkIds:e.links}:{},...e.kinds?{kindIds:e.kinds}:{}}}normalize(){let e={database:{[this.id]:{id:this.id,...this.shallowExport(),...this.exportChildIds()}},schemas:{},notes:{},refs:{},deps:{},depEdges:{},enums:{},tableGroups:{},tables:{},endpoints:{},enumValues:{},indexes:{},indexColumns:{},checks:{},fields:{},records:{},tablePartials:{}};return this.schemas.forEach(t=>t.normalize(e)),this.notes.forEach(t=>t.normalize(e)),this.records.forEach(t=>{e.records[t.id]={...t}}),this.tablePartials.forEach(t=>t.normalize(e)),Object.entries(this.archEntries(e=>e)).forEach(([t,n])=>{e[t]={},n.forEach(t=>t.normalize(e))}),e}};exports.default=y;
1
+ require("../_virtual/_rolldown/runtime.cjs");const e=require("../node_modules/lodash-es/get.cjs"),t=require("../node_modules/lodash-es/capitalize.cjs"),n=require("../node_modules/lodash-es/lodash.cjs"),r=require("./config.cjs"),i=require("./dbState.cjs"),a=require("./element.cjs"),o=require("./dep.cjs"),s=require("./enum.cjs"),c=require("./ref.cjs"),l=require("./table.cjs"),u=require("./tableGroup.cjs"),d=require("./schema.cjs"),f=require("./stickyNote.cjs"),p=require("./tablePartial.cjs"),m=require("./node.cjs"),h=require("./group.cjs"),g=require("./link.cjs");let _=require("@dbml/parse");n.init_lodash();var v=class extends a.default{constructor({schemas:t=[],tables:n=[],notes:a=[],enums:o=[],refs:s=[],deps:l=[],tableGroups:u=[],project:d={},aliases:f=[],records:p=[],tablePartials:m=[],diagramViews:h=[],nodes:g=[],groups:_=[],links:v=[],frontMatter:y,diagramType:b}={}){super(),this.dbState=new i.default,this.generateId(),this.hasDefaultSchema=!1,this.schemas=[],this.notes=[],this.note=d.note?e.default(d,`note.value`,typeof d.note==`string`?d.note:null):null,this.noteToken=d.note?e.default(d,`note.token`,d.noteToken):null,this.databaseType=d.database_type,this.name=d.name,this.token=d.token,this.aliases=f,this.records=[],this.tablePartials=[],this.diagramViews=h,this.injectedRawRefs=[],this.processNotes(a),this.processRecords(p),this.processTablePartials(m),this.processSchemas(t),this.processSchemaElements(o,r.ENUM),this.processSchemaElements(n,r.TABLE),this.linkRecordsToTables(),this.processSchemaElements(a,r.NOTE),this.processSchemaElements(s,`ref`),this.processSchemaElements(l,`dep`),this.processSchemaElements(u,r.TABLE_GROUP),this.injectedRawRefs.forEach(e=>{let t=this.findOrCreateSchema(r.DEFAULT_SCHEMA_NAME),n=new c.default({...e,schema:t});t.refs.some(e=>e.equals(n))||t.pushRef(n)}),this.nodes=[],this.groups=[],this.links=[],this.frontMatter=y??null,this.diagramType=b??null,this.processArch(g,_,v)}processArch(e,t,n){e.forEach(e=>this.nodes.push(new m.default({...e,database:this}))),t.forEach(e=>this.groups.push(new h.default({...e,database:this})));let r=new Map,i=(e,t,n)=>{r.has(e)||r.set(e,{type:t,element:n})};this.nodes.forEach(e=>i(e.alias??e.name,`node`,e)),this.groups.forEach(e=>i(e.alias??e.name,`group`,e)),this.notes.forEach(e=>i(e.name,`note`,e)),this.groups.forEach(e=>{e.children.forEach(t=>{let n=r.get(t);n&&(e.childIds.push(n.element.id),e.childTypes.push(n.type),(n.element instanceof m.default||n.element instanceof h.default)&&(n.element.groupId=e.id))})}),n.forEach(({from:e,to:t,...n})=>{let i=r.get(e),a=r.get(t);!i||!a||this.links.push(new g.default({...n,fromId:i.element.id,fromType:i.type,toId:a.element.id,toType:a.type,database:this}))})}generateId(){this.id=this.dbState.generateId(`dbId`)}processNotes(e){e.forEach(e=>{this.pushNote(new f.default({...e,database:this}))})}processRecords(e){e.forEach(({schemaName:e,tableName:t,columns:n,values:r,example:i,token:a})=>{this.records.push({id:this.dbState.generateId(`recordId`),schemaName:e,tableName:t,columns:n,values:r,example:i,token:a})})}processTablePartials(e){e.forEach(e=>{this.tablePartials.push(new p.default({...e,dbState:this.dbState}))})}pushNote(e){this.checkNote(e),this.notes.push(e)}checkNote(e){this.notes.some(t=>t.name===e.name)&&e.error(`Notes ${e.name} existed`)}processSchemas(e){e.forEach(e=>{this.pushSchema(new d.default({...e,database:this}))})}pushSchema(e){this.checkSchema(e),this.schemas.push(e)}checkSchema(e){this.schemas.some(t=>t.name===e.name)&&e.error(`Schemas ${e.name} existed`)}processSchemaElements(e,t){let n;e.forEach(e=>{switch(e.schemaName?(n=this.findOrCreateSchema(e.schemaName),e.schemaName):n=this.findOrCreateSchema(r.DEFAULT_SCHEMA_NAME),t){case r.TABLE:n.pushTable(new l.default({...e,schema:n}));break;case r.ENUM:n.pushEnum(new s.default({...e,schema:n}));break;case r.TABLE_GROUP:n.pushTableGroup(new u.default({...e,schema:n}));break;case`ref`:n.pushRef(new c.default({...e,schema:n}));break;case`dep`:n.pushDep(new o.default({...e,schema:n}));break;default:break}})}linkRecordsToTables(){let e={};this.schemas.forEach(t=>{e[t.name]={},t.tables.forEach(n=>{e[t.name][n.name]=n})}),this.records.forEach(t=>{let n=e[t.schemaName??`public`]?.[t.tableName];n&&(t.tableId=n.id,n.records.push(t))})}findOrCreateSchema(e){let n=this.schemas.find(t=>t.name===e||t.alias===e);return n||(n=new d.default({name:e,note:{value:e===`public`?`Default ${t.default(r.DEFAULT_SCHEMA_NAME)} Schema`:null},database:this}),this.pushSchema(n)),n}findTableAlias(e){let t=this.aliases.find(t=>t.name===e);if(!t||t.kind!==`table`)return null;let n=t.value.schemaName||`public`,r=this.schemas.find(e=>e.name===n);if(!r)return null;let{tableName:i}=t.value;return r.tables.find(e=>e.name===i)||null}findTable(e,t){let n=null;if(!e&&(n=this.findTableAlias(t),n))return n;let r=this.findOrCreateSchema(e||`public`);return r||this.error(`Schema ${e||`public`} don't exist`),r.findTable(t)}findEnum(e,t){let n=this.schemas.find(t=>t.name===e||t.alias===e);if(n)return n.enums.find(e=>e.name===t)}findTablePartial(e){return this.tablePartials.find(t=>t.name===e)}adjustCardinalitiesFromColumns(){this.schemas.forEach(e=>{e.refs.forEach(e=>{let t=e.endpoints.find(e=>(0,_.parseCardinality)(e.relation).max===`*`),n=e.endpoints.find(e=>(0,_.parseCardinality)(e.relation).max===1);if(!n)return;let r,i;t?(r=t,i=n):(r=e.endpoints[1],i=e.endpoints[0]),!(!r||!i)&&r.fields.every(e=>e.not_null||e.pk||e.increment)&&(i.relation=(0,_.makeCardinalityRequired)(i.relation))})})}export(){return{...this.exportChild()}}shallowExport(){return{hasDefaultSchema:this.hasDefaultSchema,note:this.note,databaseType:this.databaseType,name:this.name}}exportChild(){return{schemas:this.schemas.map(e=>e.export()),notes:this.notes.map(e=>e.export()),records:this.records.map(e=>({...e})),...this.archEntries(e=>e.map(e=>e.export()))}}exportChildIds(){return{schemaIds:this.schemas.map(e=>e.id),noteIds:this.notes.map(e=>e.id),...this.archIds(),...this.frontMatter?{frontMatter:this.frontMatter}:{},...this.diagramType?{diagramType:this.diagramType}:{}}}archEntries(e){let t={},n={nodes:this.nodes,groups:this.groups,links:this.links};return Object.entries(n).forEach(([n,r])=>{r.length&&(t[n]=e(r))}),t}archIds(){let e=this.archEntries(e=>e.map(e=>e.id));return{...e.nodes?{nodeIds:e.nodes}:{},...e.groups?{groupIds:e.groups}:{},...e.links?{linkIds:e.links}:{}}}normalize(){let e={database:{[this.id]:{id:this.id,...this.shallowExport(),...this.exportChildIds()}},schemas:{},notes:{},refs:{},deps:{},depEdges:{},enums:{},tableGroups:{},tables:{},endpoints:{},enumValues:{},indexes:{},indexColumns:{},checks:{},fields:{},records:{},tablePartials:{}};return this.schemas.forEach(t=>t.normalize(e)),this.notes.forEach(t=>t.normalize(e)),this.records.forEach(t=>{e.records[t.id]={...t}}),this.tablePartials.forEach(t=>t.normalize(e)),Object.entries(this.archEntries(e=>e)).forEach(([t,n])=>{e[t]={},n.forEach(t=>t.normalize(e))}),e}};exports.default=v;
@@ -15,57 +15,50 @@ import _ from "./tablePartial.mjs";
15
15
  import v from "./node.mjs";
16
16
  import y from "./group.mjs";
17
17
  import b from "./link.mjs";
18
- import x from "./kind.mjs";
19
- import { makeCardinalityRequired as S, parseCardinality as C } from "@dbml/parse";
18
+ import { makeCardinalityRequired as x, parseCardinality as S } from "@dbml/parse";
20
19
  //#region src/model_structure/database.ts
21
20
  n();
22
- var w = class extends l {
23
- constructor({ schemas: t = [], tables: n = [], notes: l = [], enums: u = [], refs: d = [], deps: p = [], tableGroups: m = [], project: h = {}, aliases: g = [], records: _ = [], tablePartials: v = [], diagramViews: y = [], nodes: b = [], groups: x = [], links: S = [], kinds: C = [], frontMatter: w, diagramType: T } = {}) {
21
+ var C = class extends l {
22
+ constructor({ schemas: t = [], tables: n = [], notes: l = [], enums: u = [], refs: d = [], deps: p = [], tableGroups: m = [], project: h = {}, aliases: g = [], records: _ = [], tablePartials: v = [], diagramViews: y = [], nodes: b = [], groups: x = [], links: S = [], frontMatter: C, diagramType: w } = {}) {
24
23
  super(), this.dbState = new c(), this.generateId(), this.hasDefaultSchema = !1, this.schemas = [], this.notes = [], this.note = h.note ? e(h, "note.value", typeof h.note == "string" ? h.note : null) : null, this.noteToken = h.note ? e(h, "note.token", h.noteToken) : null, this.databaseType = h.database_type, this.name = h.name, this.token = h.token, this.aliases = g, this.records = [], this.tablePartials = [], this.diagramViews = y, this.injectedRawRefs = [], this.processNotes(l), this.processRecords(_), this.processTablePartials(v), this.processSchemas(t), this.processSchemaElements(u, i), this.processSchemaElements(n, o), this.linkRecordsToTables(), this.processSchemaElements(l, a), this.processSchemaElements(d, "ref"), this.processSchemaElements(p, "dep"), this.processSchemaElements(m, s), this.injectedRawRefs.forEach((e) => {
25
24
  let t = this.findOrCreateSchema(r), n = new f({
26
25
  ...e,
27
26
  schema: t
28
27
  });
29
28
  t.refs.some((e) => e.equals(n)) || t.pushRef(n);
30
- }), this.nodes = [], this.groups = [], this.links = [], this.kinds = [], this.frontMatter = w ?? null, this.diagramType = T ?? null, this.processArch(C, b, x, S);
29
+ }), this.nodes = [], this.groups = [], this.links = [], this.frontMatter = C ?? null, this.diagramType = w ?? null, this.processArch(b, x, S);
31
30
  }
32
- processArch(e, t, n, r) {
33
- e.forEach((e) => this.kinds.push(new x({
31
+ processArch(e, t, n) {
32
+ e.forEach((e) => this.nodes.push(new v({
34
33
  ...e,
35
34
  database: this
36
- }))), t.forEach((e) => this.nodes.push(new v({
37
- ...e,
38
- database: this
39
- }))), n.forEach((e) => this.groups.push(new y({
35
+ }))), t.forEach((e) => this.groups.push(new y({
40
36
  ...e,
41
37
  database: this
42
38
  })));
43
- let i = /* @__PURE__ */ new Map(), a = (e, t, n) => {
44
- i.has(e) || i.set(e, {
39
+ let r = /* @__PURE__ */ new Map(), i = (e, t, n) => {
40
+ r.has(e) || r.set(e, {
45
41
  type: t,
46
42
  element: n
47
43
  });
48
44
  };
49
- this.nodes.forEach((e) => a(e.alias ?? e.name, "node", e)), this.groups.forEach((e) => a(e.alias ?? e.name, "group", e)), this.notes.forEach((e) => a(e.name, "note", e)), this.groups.forEach((e) => {
45
+ this.nodes.forEach((e) => i(e.alias ?? e.name, "node", e)), this.groups.forEach((e) => i(e.alias ?? e.name, "group", e)), this.notes.forEach((e) => i(e.name, "note", e)), this.groups.forEach((e) => {
50
46
  e.children.forEach((t) => {
51
- let n = i.get(t);
47
+ let n = r.get(t);
52
48
  n && (e.childIds.push(n.element.id), e.childTypes.push(n.type), (n.element instanceof v || n.element instanceof y) && (n.element.groupId = e.id));
53
49
  });
54
- }), r.forEach(({ from: e, to: t, ...n }) => {
55
- let r = i.get(e), a = i.get(t);
56
- !r || !a || this.links.push(new b({
50
+ }), n.forEach(({ from: e, to: t, ...n }) => {
51
+ let i = r.get(e), a = r.get(t);
52
+ !i || !a || this.links.push(new b({
57
53
  ...n,
58
- fromId: r.element.id,
59
- fromType: r.type,
54
+ fromId: i.element.id,
55
+ fromType: i.type,
60
56
  toId: a.element.id,
61
57
  toType: a.type,
62
58
  database: this
63
59
  }));
64
60
  });
65
61
  }
66
- findKind(e) {
67
- return this.kinds.find((t) => t.name === e);
68
- }
69
62
  generateId() {
70
63
  this.id = this.dbState.generateId("dbId");
71
64
  }
@@ -199,10 +192,10 @@ var w = class extends l {
199
192
  adjustCardinalitiesFromColumns() {
200
193
  this.schemas.forEach((e) => {
201
194
  e.refs.forEach((e) => {
202
- let t = e.endpoints.find((e) => C(e.relation).max === "*"), n = e.endpoints.find((e) => C(e.relation).max === 1);
195
+ let t = e.endpoints.find((e) => S(e.relation).max === "*"), n = e.endpoints.find((e) => S(e.relation).max === 1);
203
196
  if (!n) return;
204
197
  let r, i;
205
- t ? (r = t, i = n) : (r = e.endpoints[1], i = e.endpoints[0]), !(!r || !i) && r.fields.every((e) => e.not_null || e.pk || e.increment) && (i.relation = S(i.relation));
198
+ t ? (r = t, i = n) : (r = e.endpoints[1], i = e.endpoints[0]), !(!r || !i) && r.fields.every((e) => e.not_null || e.pk || e.increment) && (i.relation = x(i.relation));
206
199
  });
207
200
  });
208
201
  }
@@ -238,8 +231,7 @@ var w = class extends l {
238
231
  let t = {}, n = {
239
232
  nodes: this.nodes,
240
233
  groups: this.groups,
241
- links: this.links,
242
- kinds: this.kinds
234
+ links: this.links
243
235
  };
244
236
  return Object.entries(n).forEach(([n, r]) => {
245
237
  r.length && (t[n] = e(r));
@@ -250,8 +242,7 @@ var w = class extends l {
250
242
  return {
251
243
  ...e.nodes ? { nodeIds: e.nodes } : {},
252
244
  ...e.groups ? { groupIds: e.groups } : {},
253
- ...e.links ? { linkIds: e.links } : {},
254
- ...e.kinds ? { kindIds: e.kinds } : {}
245
+ ...e.links ? { linkIds: e.links } : {}
255
246
  };
256
247
  }
257
248
  normalize() {
@@ -286,4 +277,4 @@ var w = class extends l {
286
277
  }
287
278
  };
288
279
  //#endregion
289
- export { w as default };
280
+ export { C as default };
@@ -1 +1 @@
1
- require("../_virtual/_rolldown/runtime.cjs");var e=class{constructor(){this.dbId=1,this.schemaId=1,this.enumId=1,this.tableGroupId=1,this.refId=1,this.depId=1,this.depEdgeId=1,this.tableId=1,this.noteId=1,this.enumValueId=1,this.endpointId=1,this.indexId=1,this.checkId=1,this.fieldId=1,this.indexColumnId=1,this.recordId=1,this.tablePartialId=1,this.nodeId=1,this.groupId=1,this.linkId=1,this.kindId=1}generateId(e){let t=this[e];return this[e]+=1,t}};exports.default=e;
1
+ require("../_virtual/_rolldown/runtime.cjs");var e=class{constructor(){this.dbId=1,this.schemaId=1,this.enumId=1,this.tableGroupId=1,this.refId=1,this.depId=1,this.depEdgeId=1,this.tableId=1,this.noteId=1,this.enumValueId=1,this.endpointId=1,this.indexId=1,this.checkId=1,this.fieldId=1,this.indexColumnId=1,this.recordId=1,this.tablePartialId=1,this.nodeId=1,this.groupId=1,this.linkId=1}generateId(e){let t=this[e];return this[e]+=1,t}};exports.default=e;
@@ -1,7 +1,7 @@
1
1
  //#region src/model_structure/dbState.ts
2
2
  var e = class {
3
3
  constructor() {
4
- this.dbId = 1, this.schemaId = 1, this.enumId = 1, this.tableGroupId = 1, this.refId = 1, this.depId = 1, this.depEdgeId = 1, this.tableId = 1, this.noteId = 1, this.enumValueId = 1, this.endpointId = 1, this.indexId = 1, this.checkId = 1, this.fieldId = 1, this.indexColumnId = 1, this.recordId = 1, this.tablePartialId = 1, this.nodeId = 1, this.groupId = 1, this.linkId = 1, this.kindId = 1;
4
+ this.dbId = 1, this.schemaId = 1, this.enumId = 1, this.tableGroupId = 1, this.refId = 1, this.depId = 1, this.depEdgeId = 1, this.tableId = 1, this.noteId = 1, this.enumValueId = 1, this.endpointId = 1, this.indexId = 1, this.checkId = 1, this.fieldId = 1, this.indexColumnId = 1, this.recordId = 1, this.tablePartialId = 1, this.nodeId = 1, this.groupId = 1, this.linkId = 1;
5
5
  }
6
6
  generateId(e) {
7
7
  let t = this[e];
@@ -1 +1 @@
1
- require("../_virtual/_rolldown/runtime.cjs");const e=require("./element.cjs");var t=class extends e.default{constructor({name:e,alias:t,kind:n,type:r,image:i,settings:a,note:o,token:s,database:c}){super(s),this.name=e,this.alias=t,this.kindId=c.findKind(n)?.id??null,this.type=r,this.image=i,this.settings=a,this.note=o?.value??null,this.noteToken=o?.token??null,this.groupId=null,this.database=c,this.dbState=c.dbState,this.generateId()}generateId(){this.id=this.dbState.generateId(`nodeId`)}export(){return{name:this.name,alias:this.alias,type:this.type,image:this.image,settings:this.settings,note:this.note}}normalize(e){e.nodes[this.id]={id:this.id,...this.export(),kindId:this.kindId,groupId:this.groupId}}};exports.default=t;
1
+ require("../_virtual/_rolldown/runtime.cjs");const e=require("./element.cjs");var t=class extends e.default{constructor({name:e,alias:t,role:n,type:r,image:i,settings:a,note:o,token:s,database:c}){super(s),this.name=e,this.alias=t,this.role=n,this.type=r,this.image=i,this.settings=a,this.note=o?.value??null,this.noteToken=o?.token??null,this.groupId=null,this.database=c,this.dbState=c.dbState,this.generateId()}generateId(){this.id=this.dbState.generateId(`nodeId`)}export(){return{name:this.name,alias:this.alias,role:this.role,type:this.type,image:this.image,settings:this.settings,note:this.note}}normalize(e){e.nodes[this.id]={id:this.id,...this.export(),groupId:this.groupId}}};exports.default=t;
@@ -1,8 +1,8 @@
1
1
  import e from "./element.mjs";
2
2
  //#region src/model_structure/node.ts
3
3
  var t = class extends e {
4
- constructor({ name: e, alias: t, kind: n, type: r, image: i, settings: a, note: o, token: s, database: c }) {
5
- super(s), this.name = e, this.alias = t, this.kindId = c.findKind(n)?.id ?? null, this.type = r, this.image = i, this.settings = a, this.note = o?.value ?? null, this.noteToken = o?.token ?? null, this.groupId = null, this.database = c, this.dbState = c.dbState, this.generateId();
4
+ constructor({ name: e, alias: t, role: n, type: r, image: i, settings: a, note: o, token: s, database: c }) {
5
+ super(s), this.name = e, this.alias = t, this.role = n, this.type = r, this.image = i, this.settings = a, this.note = o?.value ?? null, this.noteToken = o?.token ?? null, this.groupId = null, this.database = c, this.dbState = c.dbState, this.generateId();
6
6
  }
7
7
  generateId() {
8
8
  this.id = this.dbState.generateId("nodeId");
@@ -11,6 +11,7 @@ var t = class extends e {
11
11
  return {
12
12
  name: this.name,
13
13
  alias: this.alias,
14
+ role: this.role,
14
15
  type: this.type,
15
16
  image: this.image,
16
17
  settings: this.settings,
@@ -21,7 +22,6 @@ var t = class extends e {
21
22
  e.nodes[this.id] = {
22
23
  id: this.id,
23
24
  ...this.export(),
24
- kindId: this.kindId,
25
25
  groupId: this.groupId
26
26
  };
27
27
  }
@@ -1 +1 @@
1
- require("../../_virtual/_rolldown/runtime.cjs");var e=`11.0.0-alpha.4`;exports.version=e;
1
+ require("../../_virtual/_rolldown/runtime.cjs");var e=`11.0.0-alpha.6`;exports.version=e;
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var e = "11.0.0-alpha.4";
2
+ var e = "11.0.0-alpha.6";
3
3
  //#endregion
4
4
  export { e as version };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "@dbml/core",
4
- "version": "11.0.0-alpha.4",
4
+ "version": "11.0.0-alpha.6",
5
5
  "description": "> TODO: description",
6
6
  "author": "Holistics <dev@holistics.io>",
7
7
  "license": "Apache-2.0",
@@ -48,7 +48,7 @@
48
48
  "lint:fix": "eslint --fix ."
49
49
  },
50
50
  "dependencies": {
51
- "@dbml/parse": "^11.0.0-alpha.4",
51
+ "@dbml/parse": "^11.0.0-alpha.6",
52
52
  "antlr4": "^4.13.1",
53
53
  "lodash": "^4.18.1",
54
54
  "lodash-es": "^4.18.1",
@@ -59,7 +59,7 @@
59
59
  "devDependencies": {
60
60
  "bluebird": "^3.5.5"
61
61
  },
62
- "gitHead": "40f71a2018dd2a5a9452cd4ba680ef08289fae3a",
62
+ "gitHead": "8d191d7fc27af2f5daab6d9074f7c3882f3541ab",
63
63
  "engines": {
64
64
  "node": ">=16"
65
65
  }
package/types/index.d.ts CHANGED
@@ -64,6 +64,7 @@ export {
64
64
  isEndpointOptional,
65
65
  isEndpointRequired,
66
66
  makeRelationshipRequired,
67
+ BUILTIN_ROLES,
67
68
  } from '@dbml/parse';
68
69
 
69
70
  export { inferMultiplicitiesFromColumns } from './transform/relations';
@@ -95,4 +96,5 @@ export type {
95
96
  RelationCardinality,
96
97
  RelationshipOp,
97
98
  DbmlProjectLayout,
99
+ RoleSpec,
98
100
  } from '@dbml/parse';
@@ -17,12 +17,11 @@ import { NormalizedCheckIdMap } from './check';
17
17
  import TablePartial, { NormalizedTablePartialIdMap } from './tablePartial';
18
18
  import { TokenPosition, DiagramView } from '@dbml/parse';
19
19
  import type {
20
- Group as RawGroup, Kind as RawKind, Link as RawLink, Node as RawNode,
20
+ Group as RawGroup, Link as RawLink, Node as RawNode,
21
21
  } from '@dbml/parse';
22
22
  import Node, { NormalizedNodeIdMap } from './node';
23
23
  import Group, { NormalizedGroupIdMap } from './group';
24
24
  import Link, { NormalizedLinkIdMap } from './link';
25
- import Kind, { NormalizedKindIdMap } from './kind';
26
25
  export interface Project {
27
26
  note: RawNote;
28
27
  database_type: string;
@@ -76,7 +75,6 @@ export interface RawDatabase {
76
75
  nodes?: RawNode[];
77
76
  groups?: RawGroup[];
78
77
  links?: RawLink[];
79
- kinds?: RawKind[];
80
78
  frontMatter?: Record<string, string>;
81
79
  diagramType?: 'arch';
82
80
  }
@@ -95,7 +93,6 @@ declare class Database extends Element {
95
93
  nodes: Node[];
96
94
  groups: Group[];
97
95
  links: Link[];
98
- kinds: Kind[];
99
96
  frontMatter: Record<string, string> | null;
100
97
  diagramType: 'arch' | null;
101
98
  id: number;
@@ -110,7 +107,6 @@ declare class Database extends Element {
110
107
  findTable(schemaName: string | null, tableName: string): Table;
111
108
  processTablePartials(rawTablePartials: any[]): TablePartial[];
112
109
  findTablePartial(partialName: string): TablePartial;
113
- findKind(name: string): Kind | undefined;
114
110
  export(): {
115
111
  schemas: {
116
112
  tables: {
@@ -331,7 +327,6 @@ export interface NormalizedDatabase {
331
327
  nodeIds?: number[];
332
328
  groupIds?: number[];
333
329
  linkIds?: number[];
334
- kindIds?: number[];
335
330
  frontMatter?: Record<string, string>;
336
331
  diagramType?: 'arch';
337
332
  }
@@ -362,6 +357,5 @@ export interface NormalizedModel {
362
357
  nodes?: NormalizedNodeIdMap;
363
358
  groups?: NormalizedGroupIdMap;
364
359
  links?: NormalizedLinkIdMap;
365
- kinds?: NormalizedKindIdMap;
366
360
  }
367
361
  export default Database;
@@ -19,6 +19,5 @@ export default class DbState {
19
19
  nodeId: number;
20
20
  groupId: number;
21
21
  linkId: number;
22
- kindId: number;
23
22
  generateId(el: Exclude<keyof DbState, 'generateId'>): number;
24
23
  }
@@ -8,7 +8,7 @@ declare class Node extends Element {
8
8
  id: number;
9
9
  name: string;
10
10
  alias: string | null;
11
- kindId: number | null;
11
+ role: string;
12
12
  type: string | null;
13
13
  image: string | null;
14
14
  settings: ArchSettings;
@@ -19,14 +19,14 @@ declare class Node extends Element {
19
19
  dbState: DbState;
20
20
  constructor(raw: RawNode & { database: Database });
21
21
  generateId(): void;
22
- export(): Omit<NormalizedNode, 'id' | 'kindId' | 'groupId'>;
22
+ export(): Omit<NormalizedNode, 'id' | 'groupId'>;
23
23
  normalize(model: NormalizedModel): void;
24
24
  }
25
25
  export interface NormalizedNode {
26
26
  id: number;
27
27
  name: string;
28
28
  alias: string | null;
29
- kindId: number | null;
29
+ role: string;
30
30
  type: string | null;
31
31
  image: string | null;
32
32
  settings: ArchSettings;
@@ -1 +0,0 @@
1
- require("../_virtual/_rolldown/runtime.cjs");const e=require("./element.cjs");var t=class extends e.default{constructor({name:e,icon:t,glyph:n,image:r,category:i,color:a,builtin:o,token:s,database:c}){super(s),this.name=e,this.icon=t,this.glyph=n,this.image=r,this.category=i,this.color=a,this.builtin=o,this.database=c,this.dbState=c.dbState,this.generateId()}generateId(){this.id=this.dbState.generateId(`kindId`)}export(){return{name:this.name,icon:this.icon,glyph:this.glyph,image:this.image,category:this.category,color:this.color,builtin:this.builtin}}normalize(e){e.kinds[this.id]={id:this.id,...this.export()}}};exports.default=t;
@@ -1,29 +0,0 @@
1
- import e from "./element.mjs";
2
- //#region src/model_structure/kind.ts
3
- var t = class extends e {
4
- constructor({ name: e, icon: t, glyph: n, image: r, category: i, color: a, builtin: o, token: s, database: c }) {
5
- super(s), this.name = e, this.icon = t, this.glyph = n, this.image = r, this.category = i, this.color = a, this.builtin = o, this.database = c, this.dbState = c.dbState, this.generateId();
6
- }
7
- generateId() {
8
- this.id = this.dbState.generateId("kindId");
9
- }
10
- export() {
11
- return {
12
- name: this.name,
13
- icon: this.icon,
14
- glyph: this.glyph,
15
- image: this.image,
16
- category: this.category,
17
- color: this.color,
18
- builtin: this.builtin
19
- };
20
- }
21
- normalize(e) {
22
- e.kinds[this.id] = {
23
- id: this.id,
24
- ...this.export()
25
- };
26
- }
27
- };
28
- //#endregion
29
- export { t as default };
@@ -1,36 +0,0 @@
1
- import type { KindCategory, Kind as RawKind } from '@dbml/parse';
2
- import Element from './element';
3
- import Database from './database';
4
- import DbState from './dbState';
5
- import type { NormalizedModel } from './database';
6
-
7
- declare class Kind extends Element {
8
- id: number;
9
- name: string;
10
- icon: string;
11
- glyph: string[] | null;
12
- image: string | null;
13
- category: KindCategory;
14
- color: string | null;
15
- builtin: boolean;
16
- database: Database;
17
- dbState: DbState;
18
- constructor(raw: RawKind & { database: Database });
19
- generateId(): void;
20
- export(): Omit<NormalizedKind, 'id'>;
21
- normalize(model: NormalizedModel): void;
22
- }
23
- export interface NormalizedKind {
24
- id: number;
25
- name: string;
26
- icon: string;
27
- glyph: string[] | null;
28
- image: string | null;
29
- category: KindCategory;
30
- color: string | null;
31
- builtin: boolean;
32
- }
33
- export interface NormalizedKindIdMap {
34
- [_id: number]: NormalizedKind;
35
- }
36
- export default Kind;