@dineug/erd-editor 3.9.2 → 4.0.0

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.
Files changed (375) hide show
  1. package/README.md +321 -133
  2. package/dist/components/appContext.d.ts +4 -0
  3. package/dist/components/erd/Erd.d.ts +4 -0
  4. package/dist/components/erd/automatic-table-placement/AutomaticTablePlacement.d.ts +2 -1
  5. package/dist/components/erd/automatic-table-placement/createAutomaticTablePlacement.d.ts +38 -2
  6. package/dist/components/erd/automatic-table-placement/elkPlacement.d.ts +42 -0
  7. package/dist/components/erd/automatic-table-placement/flowPlacement.d.ts +21 -0
  8. package/dist/components/erd/automatic-table-placement/placementActions.d.ts +14 -0
  9. package/dist/components/erd/automatic-table-placement/runElkPlacement.d.ts +0 -11
  10. package/dist/components/erd/canvas/SceneIcon.template.d.ts +2 -2
  11. package/dist/components/erd/canvas/entityDrag.d.ts +17 -1
  12. package/dist/components/erd/canvas/middleButtonPan.d.ts +11 -0
  13. package/dist/components/erd/canvas/relationship-group/relationship/Relationship.d.ts +2 -0
  14. package/dist/components/erd/canvas/relationship-group/relationship/RelationshipActionLabel.d.ts +32 -0
  15. package/dist/components/erd/canvas/sceneTokens.d.ts +38 -0
  16. package/dist/components/erd/canvas/table/Table.d.ts +9 -1
  17. package/dist/components/erd/canvas/table/cellLayout.d.ts +11 -0
  18. package/dist/components/erd/canvas/table/column/Column.d.ts +7 -0
  19. package/dist/components/erd/canvas/table/doubleClick.d.ts +3 -4
  20. package/dist/components/erd/canvas/table/goToErd.d.ts +3 -10
  21. package/dist/components/erd/canvas/table-group/TableGroup.d.ts +17 -0
  22. package/dist/components/erd/canvas/table-group/TableGroupBody.d.ts +17 -0
  23. package/dist/components/erd/canvas/table-group/TableGroupDropTarget.d.ts +10 -0
  24. package/dist/components/erd/canvas/table-group/TableGroupSash.d.ts +35 -0
  25. package/dist/components/erd/canvas/table-group/TableGroups.d.ts +10 -0
  26. package/dist/components/erd/canvas/table-group/tableGroupBox.d.ts +40 -0
  27. package/dist/components/erd/canvas/table-group/titleLayout.d.ts +45 -0
  28. package/dist/components/erd/canvas/useMoveEntity.d.ts +2 -0
  29. package/dist/components/erd/draw-target/DrawTargetButtons.d.ts +16 -0
  30. package/dist/components/erd/draw-target/DrawTargetButtons.styles.d.ts +14 -0
  31. package/dist/components/erd/draw-target/drawTargetState.d.ts +26 -0
  32. package/dist/components/erd/draw-target/findDrawTarget.d.ts +29 -0
  33. package/dist/components/erd/draw-target/placePill.d.ts +49 -0
  34. package/dist/components/erd/erd-context-menu/ErdContextMenu.d.ts +6 -0
  35. package/dist/components/erd/erd-context-menu/menus/drawRelationshipMenus.d.ts +3 -0
  36. package/dist/components/erd/erd-context-menu/menus/exportMenus.d.ts +7 -2
  37. package/dist/components/erd/erd-context-menu/menus/importMenus.d.ts +5 -1
  38. package/dist/components/erd/erd-context-menu/menus/relationshipMenus.d.ts +16 -1
  39. package/dist/components/erd/erd-context-menu/menus/showMenus.d.ts +3 -1
  40. package/dist/components/erd/erd-context-menu/menus/tablePlacementMenus.d.ts +3 -0
  41. package/dist/components/erd/floating-toolbar/ToolbarCompass.template.d.ts +3 -1
  42. package/dist/components/erd/goToErdTarget.d.ts +85 -0
  43. package/dist/components/erd/hitTest.d.ts +16 -1
  44. package/dist/components/erd/minimap/MinimapScene.d.ts +1 -1
  45. package/dist/components/erd/minimap/table/Table.d.ts +3 -3
  46. package/dist/components/erd/minimap/table-group/TableGroup.d.ts +17 -0
  47. package/dist/components/erd/table-group/TableGroupDraft.d.ts +15 -0
  48. package/dist/components/erd/table-group/TableGroupDraft.styles.d.ts +6 -0
  49. package/dist/components/erd/table-group/tableGroupName.d.ts +21 -0
  50. package/dist/components/erd/table-group/useTableGroupDraw.d.ts +25 -0
  51. package/dist/components/erd/table-properties/TableProperties.d.ts +2 -0
  52. package/dist/components/erd/table-properties/TableProperties.styles.d.ts +24 -2
  53. package/dist/components/erd/table-properties/table-properties-indexes/TablePropertiesIndexes.d.ts +2 -0
  54. package/dist/components/erd/table-properties/table-properties-indexes/TablePropertiesIndexes.styles.d.ts +32 -0
  55. package/dist/components/erd/table-properties/table-properties-indexes/indexes-checkbox-column/IndexesCheckboxColumn.d.ts +7 -0
  56. package/dist/components/erd/table-properties/table-properties-indexes/indexes-checkbox-column/IndexesCheckboxColumn.styles.d.ts +5 -0
  57. package/dist/components/erd/table-properties/table-properties-indexes/indexes-column/IndexesColumn.d.ts +7 -0
  58. package/dist/components/erd/table-properties/table-properties-indexes/indexes-column/IndexesColumn.styles.d.ts +3 -0
  59. package/dist/components/erd/table-properties/table-properties-indexes/indexes-index/IndexesIndex.d.ts +7 -0
  60. package/dist/components/erd/table-properties/table-properties-indexes/indexes-index/IndexesIndex.styles.d.ts +6 -0
  61. package/dist/components/erd/table-properties/table-properties-indexes/indexes-key/IndexesKey.d.ts +21 -0
  62. package/dist/components/erd/table-properties/table-properties-indexes/indexes-key/IndexesKey.styles.d.ts +13 -0
  63. package/dist/components/erd/table-properties/table-properties-tabs/TablePropertiesTabs.d.ts +3 -0
  64. package/dist/components/erd/welcome-screen/WelcomeScreen.d.ts +17 -0
  65. package/dist/components/erd/welcome-screen/WelcomeScreen.styles.d.ts +17 -0
  66. package/dist/components/erd/welcome-screen/welcome-hints/WelcomeHints.d.ts +21 -0
  67. package/dist/components/erd/welcome-screen/welcome-hints/WelcomeHints.styles.d.ts +14 -0
  68. package/dist/components/erd/welcome-screen/welcome-hints/hintArrows.d.ts +10 -0
  69. package/dist/components/erd/welcome-screen/welcomeLayout.d.ts +87 -0
  70. package/dist/components/erd-editor/ErdEditor.d.ts +67 -7
  71. package/dist/components/erd-editor/useErdEditorAttachElement.d.ts +14 -1
  72. package/dist/components/export-image/ExportImage.d.ts +23 -0
  73. package/dist/components/export-image/ExportImage.styles.d.ts +34 -0
  74. package/dist/components/export-image/exportImageActions.d.ts +48 -0
  75. package/dist/components/find-replace/FindReplace.d.ts +13 -0
  76. package/dist/components/find-replace/FindReplace.styles.d.ts +27 -0
  77. package/dist/components/find-replace/fieldIcon.d.ts +5 -0
  78. package/dist/components/find-replace/matchTarget.d.ts +26 -0
  79. package/dist/components/find-replace/panelLayout.d.ts +20 -0
  80. package/dist/components/generator-code/GeneratorCode.d.ts +1 -0
  81. package/dist/components/generator-code/generator-code-context-menu/GeneratorCodeContextMenu.d.ts +3 -0
  82. package/dist/components/generator-code/generator-code-context-menu/menus/columnNameCaseMenus.d.ts +3 -0
  83. package/dist/components/generator-code/generator-code-context-menu/menus/languageMenus.d.ts +8 -0
  84. package/dist/components/generator-code/generator-code-context-menu/menus/tableNameCaseMenus.d.ts +3 -0
  85. package/dist/components/generator-code/generator-code-options/GeneratorCodeOptions.d.ts +17 -0
  86. package/dist/components/generator-code/generator-code-options/GeneratorCodeOptions.styles.d.ts +5 -0
  87. package/dist/components/generator-code/generatorCodeView.d.ts +12 -0
  88. package/dist/components/generator-code/languageSettings.d.ts +14 -0
  89. package/dist/components/locale-picker/LocalePicker.d.ts +13 -0
  90. package/dist/components/locale-picker/LocalePicker.styles.d.ts +19 -0
  91. package/dist/components/localeContext.d.ts +10 -0
  92. package/dist/components/localized/Localized.d.ts +18 -0
  93. package/dist/components/map-columns/MapColumnsBody.d.ts +24 -0
  94. package/dist/components/map-columns/MapColumnsDialog.d.ts +13 -0
  95. package/dist/components/map-columns/MapColumnsDialog.styles.d.ts +38 -0
  96. package/dist/components/map-columns/mapColumnsAction.d.ts +13 -0
  97. package/dist/components/map-columns/nameOf.d.ts +6 -0
  98. package/dist/components/map-columns/openMapColumns.d.ts +9 -0
  99. package/dist/components/primitives/code-block/CodeBlock.d.ts +6 -1
  100. package/dist/components/primitives/code-block/CodeBlock.styles.d.ts +2 -0
  101. package/dist/components/primitives/color-picker/ColorPicker.d.ts +10 -1
  102. package/dist/components/primitives/color-picker/ColorPicker.styles.d.ts +25 -0
  103. package/dist/components/primitives/color-picker/colorModel.d.ts +36 -0
  104. package/dist/components/primitives/color-picker/presetColors.d.ts +13 -0
  105. package/dist/components/primitives/color-picker/resolveColor.d.ts +7 -0
  106. package/dist/components/primitives/context-menu/ContextMenu.d.ts +2 -0
  107. package/dist/components/primitives/context-menu/context-menu-content/ContextMenuContent.d.ts +1 -0
  108. package/dist/components/primitives/context-menu/context-menu-content/fitMenu.d.ts +4 -4
  109. package/dist/components/primitives/context-menu/context-menu-separator/ContextMenuSeparator.d.ts +8 -0
  110. package/dist/components/primitives/context-menu/context-menu-separator/ContextMenuSeparator.styles.d.ts +2 -0
  111. package/dist/components/primitives/context-menu/menu/Menu.d.ts +2 -0
  112. package/dist/components/primitives/context-menu/submenu-chevron/SubmenuChevron.d.ts +5 -0
  113. package/dist/components/primitives/dialog/Dialog.d.ts +21 -0
  114. package/dist/components/primitives/dialog/Dialog.styles.d.ts +12 -0
  115. package/dist/components/primitives/highlighted-text/HighlightedText.d.ts +2 -5
  116. package/dist/components/primitives/icon/icons.d.ts +27 -1
  117. package/dist/components/primitives/select/Select.d.ts +18 -0
  118. package/dist/components/primitives/select/Select.styles.d.ts +13 -0
  119. package/dist/components/primitives/text-input/TextInput.d.ts +2 -0
  120. package/dist/components/primitives/toast/Toast.d.ts +5 -1
  121. package/dist/components/primitives/toast/Toast.styles.d.ts +2 -2
  122. package/dist/components/quick-search/QuickSearch.d.ts +2 -1
  123. package/dist/components/quick-search/QuickSearch.styles.d.ts +6 -0
  124. package/dist/components/quick-search/actions.d.ts +60 -2
  125. package/dist/components/quick-search/hangul.d.ts +79 -0
  126. package/dist/components/quick-search/paletteQuery.d.ts +38 -0
  127. package/dist/components/quick-search/scopedActions.d.ts +42 -0
  128. package/dist/components/schema-sql/SchemaSQL.d.ts +2 -0
  129. package/dist/components/schema-sql/SchemaSQL.styles.d.ts +7 -0
  130. package/dist/components/schema-sql/schema-sql-context-menu/SchemaSQLContextMenu.d.ts +3 -0
  131. package/dist/components/schema-sql/schema-sql-context-menu/menus/bracketMenus.d.ts +3 -0
  132. package/dist/components/schema-sql/schema-sql-context-menu/menus/headerMenus.d.ts +29 -0
  133. package/dist/components/schema-sql/schema-sql-context-menu/menus/statementsMenus.d.ts +27 -0
  134. package/dist/components/schema-sql/schema-sql-options/SchemaSQLOptions.d.ts +24 -0
  135. package/dist/components/schema-sql/schema-sql-options/SchemaSQLOptions.styles.d.ts +45 -0
  136. package/dist/components/schema-sql/schema-sql-options/ScriptEditor.d.ts +20 -0
  137. package/dist/components/schema-sql/schema-sql-options/ScriptEditor.styles.d.ts +13 -0
  138. package/dist/components/schema-sql/schema-sql-options/dropWarning.d.ts +8 -0
  139. package/dist/components/schema-sql/schemaSQLView.d.ts +71 -0
  140. package/dist/components/settings/Settings.styles.d.ts +7 -0
  141. package/dist/components/settings/columnTypeLabels.d.ts +8 -0
  142. package/dist/components/settings/lockSettingRows.d.ts +16 -0
  143. package/dist/components/settings/settings-lnb/SettingsLnb.d.ts +3 -0
  144. package/dist/components/settings/settingsPage.d.ts +10 -0
  145. package/dist/components/theme-builder/ThemeBuilder.d.ts +9 -1
  146. package/dist/components/theme-builder/ThemeBuilder.styles.d.ts +8 -5
  147. package/dist/components/toast-container/openStatusToast.d.ts +29 -0
  148. package/dist/components/toast-container/openToastWhileRunning.d.ts +1 -1
  149. package/dist/components/toolbar/Toolbar.d.ts +1 -0
  150. package/dist/components/visualization/graph-node/GraphNode.d.ts +2 -2
  151. package/dist/components/visualization/graphPan.d.ts +12 -0
  152. package/dist/components/visualization/table/column/Column.d.ts +4 -0
  153. package/dist/components/visualization/visualizationView.d.ts +2 -2
  154. package/dist/constants/language.d.ts +1 -1
  155. package/dist/constants/layout.d.ts +47 -0
  156. package/dist/constants/open.d.ts +4 -0
  157. package/dist/constants/schema.d.ts +38 -4
  158. package/dist/constants/sql/dataType/PostgreSQL.d.ts +2 -1
  159. package/dist/constants/sql/dataType/SQLite.d.ts +3 -1
  160. package/dist/engine/actions.d.ts +20 -2
  161. package/dist/engine/context.d.ts +6 -0
  162. package/dist/engine/index.d.ts +1 -1
  163. package/dist/engine/index.js +29 -18
  164. package/dist/engine/modules/editor/actions.d.ts +10 -2
  165. package/dist/engine/modules/editor/atom.actions.d.ts +49 -11
  166. package/dist/engine/modules/editor/generator.actions.d.ts +107 -8
  167. package/dist/engine/modules/editor/state.d.ts +16 -3
  168. package/dist/engine/modules/editor/utils/color.d.ts +21 -0
  169. package/dist/engine/modules/editor/utils/duplicate.d.ts +28 -1
  170. package/dist/engine/modules/editor/utils/focus.d.ts +16 -0
  171. package/dist/engine/modules/editor/utils/releaseHidden.d.ts +16 -0
  172. package/dist/engine/modules/editor/utils/selection.d.ts +12 -0
  173. package/dist/engine/modules/relationship/actions.d.ts +19 -0
  174. package/dist/engine/modules/relationship/atom.actions.d.ts +111 -1
  175. package/dist/engine/modules/relationship/endFlags.d.ts +14 -0
  176. package/dist/engine/modules/relationship/fkColumns.d.ts +40 -4
  177. package/dist/engine/modules/relationship/generator.actions.d.ts +5 -2
  178. package/dist/engine/modules/relationship/history.d.ts +3 -0
  179. package/dist/engine/modules/relationship/referenceType.d.ts +12 -0
  180. package/dist/engine/modules/settings/actions.d.ts +17 -4
  181. package/dist/engine/modules/settings/atom.actions.d.ts +63 -19
  182. package/dist/engine/modules/settings/generator.actions.d.ts +7 -0
  183. package/dist/engine/modules/settings/history.d.ts +1 -0
  184. package/dist/engine/modules/table/actions.d.ts +8 -0
  185. package/dist/engine/modules/table/atom.actions.d.ts +31 -0
  186. package/dist/engine/modules/table/generator.actions.d.ts +3 -3
  187. package/dist/engine/modules/table/history.d.ts +1 -0
  188. package/dist/engine/modules/table-column/generator.actions.d.ts +8 -0
  189. package/dist/engine/modules/table-column/keys.d.ts +14 -0
  190. package/dist/engine/modules/table-column/utils/dataType.d.ts +19 -1
  191. package/dist/engine/modules/table-group/actions.d.ts +63 -0
  192. package/dist/engine/modules/table-group/atom.actions.d.ts +238 -0
  193. package/dist/engine/modules/table-group/generator.actions.d.ts +111 -0
  194. package/dist/engine/modules/table-group/history.d.ts +13 -0
  195. package/dist/engine/peer-store.d.ts +9 -3
  196. package/dist/engine/replication-store.d.ts +18 -1
  197. package/dist/engine/rx-operators/groupByStreamActions.d.ts +5 -1
  198. package/dist/engine/rx-operators/lockIgnoreFilter.d.ts +8 -0
  199. package/dist/engine/rx-store.d.ts +2 -0
  200. package/dist/engine/settle.d.ts +9 -0
  201. package/dist/erd-editor.umd.js +2523 -4060
  202. package/dist/hooks/useNavigatorLanguages.d.ts +7 -0
  203. package/dist/i18n/locales.d.ts +126 -0
  204. package/dist/i18n/menuLabel.d.ts +12 -0
  205. package/dist/i18n/messages/ar-SA.d.ts +399 -0
  206. package/dist/i18n/messages/de-DE.d.ts +375 -0
  207. package/dist/i18n/messages/en/code.d.ts +17 -0
  208. package/dist/i18n/messages/en/colorPicker.d.ts +35 -0
  209. package/dist/i18n/messages/en/common.d.ts +65 -0
  210. package/dist/i18n/messages/en/contextMenu.d.ts +29 -0
  211. package/dist/i18n/messages/en/exportImage.d.ts +25 -0
  212. package/dist/i18n/messages/en/feedback.d.ts +11 -0
  213. package/dist/i18n/messages/en/findReplace.d.ts +36 -0
  214. package/dist/i18n/messages/en/floatingToolbar.d.ts +12 -0
  215. package/dist/i18n/messages/en/index.d.ts +378 -0
  216. package/dist/i18n/messages/en/mapColumns.d.ts +39 -0
  217. package/dist/i18n/messages/en/palette.d.ts +40 -0
  218. package/dist/i18n/messages/en/schemaSql.d.ts +28 -0
  219. package/dist/i18n/messages/en/settings.d.ts +22 -0
  220. package/dist/i18n/messages/en/shortcuts.d.ts +32 -0
  221. package/dist/i18n/messages/en/tableProperties.d.ts +34 -0
  222. package/dist/i18n/messages/en/themeBuilder.d.ts +7 -0
  223. package/dist/i18n/messages/en/toolbar.d.ts +9 -0
  224. package/dist/i18n/messages/en/visualization.d.ts +12 -0
  225. package/dist/i18n/messages/en/welcome.d.ts +13 -0
  226. package/dist/i18n/messages/es-ES.d.ts +381 -0
  227. package/dist/i18n/messages/eu-ES.d.ts +375 -0
  228. package/dist/i18n/messages/fa-IR.d.ts +375 -0
  229. package/dist/i18n/messages/fr-FR.d.ts +381 -0
  230. package/dist/i18n/messages/he-IL.d.ts +381 -0
  231. package/dist/i18n/messages/id-ID.d.ts +369 -0
  232. package/dist/i18n/messages/index.d.ts +11 -0
  233. package/dist/i18n/messages/it-IT.d.ts +381 -0
  234. package/dist/i18n/messages/ja-JP.d.ts +369 -0
  235. package/dist/i18n/messages/ko-KR.d.ts +369 -0
  236. package/dist/i18n/messages/nl-NL.d.ts +375 -0
  237. package/dist/i18n/messages/pl-PL.d.ts +387 -0
  238. package/dist/i18n/messages/pt-BR.d.ts +381 -0
  239. package/dist/i18n/messages/pt-PT.d.ts +381 -0
  240. package/dist/i18n/messages/ro-RO.d.ts +381 -0
  241. package/dist/i18n/messages/ru-RU.d.ts +387 -0
  242. package/dist/i18n/messages/sk-SK.d.ts +387 -0
  243. package/dist/i18n/messages/sl-SI.d.ts +387 -0
  244. package/dist/i18n/messages/sv-SE.d.ts +375 -0
  245. package/dist/i18n/messages/tr-TR.d.ts +375 -0
  246. package/dist/i18n/messages/uk-UA.d.ts +387 -0
  247. package/dist/i18n/messages/zh-CN.d.ts +369 -0
  248. package/dist/i18n/messages/zh-TW.d.ts +369 -0
  249. package/dist/i18n/resolveLocale.d.ts +11 -0
  250. package/dist/i18n/source.d.ts +7 -0
  251. package/dist/i18n/translate.d.ts +58 -0
  252. package/dist/index.d.ts +2 -0
  253. package/dist/index.js +28966 -11220
  254. package/dist/internal-types/index.d.ts +2 -4
  255. package/dist/konva/scene/contentBounds.d.ts +18 -12
  256. package/dist/konva/scene/metrics.d.ts +7 -0
  257. package/dist/konva/scene/renderScene.d.ts +10 -4
  258. package/dist/konva/scene/stacking.d.ts +21 -0
  259. package/dist/konva/scene/viewLayout.d.ts +2 -1
  260. package/dist/loadValue-B3EFSe9k.js +12925 -0
  261. package/dist/peer/index.d.ts +6 -3
  262. package/dist/peer/index.js +87 -83
  263. package/dist/services/elk-layout/elkGraph.d.ts +6 -4
  264. package/dist/services/elk-layout/elkLayoutOptions.d.ts +20 -0
  265. package/dist/services/elk-layout/elkLayoutService.d.ts +3 -3
  266. package/dist/services/export-png/ExportScene.d.ts +3 -3
  267. package/dist/services/export-png/documentScene.d.ts +14 -9
  268. package/dist/services/export-png/exportBox.d.ts +40 -5
  269. package/dist/services/export-png/exportPngService.d.ts +15 -0
  270. package/dist/services/export-png/exportTheme.d.ts +26 -0
  271. package/dist/services/export-png/index.d.ts +44 -11
  272. package/dist/services/export-png/renderPng.d.ts +18 -10
  273. package/dist/services/export-png/renderSvg.d.ts +22 -0
  274. package/dist/services/export-png/sceneSvg.d.ts +54 -0
  275. package/dist/services/shiki/graphqlGrammar.d.ts +8 -0
  276. package/dist/shared-store-fUggY7sI.js +1341 -0
  277. package/dist/themes/radix-ui-theme.d.ts +11 -3
  278. package/dist/themes/tokens.d.ts +9 -0
  279. package/dist/utils/calcTable.d.ts +18 -1
  280. package/dist/utils/clipboard.d.ts +9 -0
  281. package/dist/utils/collection/tableGroup.entity.d.ts +3 -0
  282. package/dist/utils/contrastText.d.ts +21 -0
  283. package/dist/utils/deepMerge.d.ts +8 -0
  284. package/dist/utils/device-detect/index.d.ts +2 -6
  285. package/dist/utils/domEvent.d.ts +18 -0
  286. package/dist/utils/dragSelect.d.ts +2 -0
  287. package/dist/utils/draw-relationship/bezier.d.ts +2 -0
  288. package/dist/utils/draw-relationship/corner.d.ts +9 -0
  289. package/dist/utils/draw-relationship/index.d.ts +18 -18
  290. package/dist/utils/draw-relationship/loop.d.ts +29 -0
  291. package/dist/utils/draw-relationship/pathFinding.d.ts +1 -1
  292. package/dist/utils/draw-relationship/sort.d.ts +8 -1
  293. package/dist/utils/draw-relationship/stub.d.ts +4 -3
  294. package/dist/utils/emitter.d.ts +64 -4
  295. package/dist/utils/file/exportFile.d.ts +15 -5
  296. package/dist/utils/file/importFile.d.ts +9 -5
  297. package/dist/utils/file/importSchema.d.ts +45 -0
  298. package/dist/utils/find-replace/findMatches.d.ts +90 -0
  299. package/dist/utils/find-replace/index.d.ts +5 -0
  300. package/dist/utils/find-replace/matcher.d.ts +53 -0
  301. package/dist/utils/find-replace/present.d.ts +24 -0
  302. package/dist/utils/find-replace/replaceActions.d.ts +20 -0
  303. package/dist/utils/generator-code/columnTypes.d.ts +99 -0
  304. package/dist/utils/generator-code/doctrine.d.ts +6 -0
  305. package/dist/utils/generator-code/doctrineReservedWords.d.ts +7 -0
  306. package/dist/utils/generator-code/graphql.d.ts +6 -0
  307. package/dist/utils/generator-code/heck.d.ts +5 -0
  308. package/dist/utils/generator-code/java.d.ts +28 -0
  309. package/dist/utils/generator-code/jsonSchema.d.ts +50 -0
  310. package/dist/utils/generator-code/jsonShape.d.ts +37 -0
  311. package/dist/utils/generator-code/kotlin.d.ts +1 -0
  312. package/dist/utils/generator-code/mermaid.d.ts +5 -0
  313. package/dist/utils/generator-code/php.d.ts +28 -0
  314. package/dist/utils/generator-code/rust.d.ts +13 -0
  315. package/dist/utils/generator-code/rustTypes.d.ts +44 -0
  316. package/dist/utils/generator-code/scala.d.ts +1 -0
  317. package/dist/utils/generator-code/seaorm.d.ts +22 -0
  318. package/dist/utils/generator-code/swift.d.ts +44 -0
  319. package/dist/utils/generator-code/utils.d.ts +31 -1
  320. package/dist/utils/generator-code/zod.d.ts +25 -0
  321. package/dist/utils/globalEventObservable.d.ts +10 -1
  322. package/dist/utils/highlightWords.d.ts +29 -0
  323. package/dist/utils/index.d.ts +1 -2
  324. package/dist/utils/keyboard-shortcut/bindKeys.d.ts +9 -0
  325. package/dist/utils/keyboard-shortcut/index.d.ts +15 -1
  326. package/dist/utils/keyboard-shortcut/utils.d.ts +21 -0
  327. package/dist/utils/loadValue.d.ts +7 -0
  328. package/dist/utils/map-columns/alignTypes.d.ts +37 -0
  329. package/dist/utils/map-columns/buildRows.d.ts +102 -0
  330. package/dist/utils/map-columns/candidateKeys.d.ts +24 -0
  331. package/dist/utils/map-columns/index.d.ts +8 -0
  332. package/dist/utils/map-columns/mapping.d.ts +67 -0
  333. package/dist/utils/map-columns/prefill.d.ts +26 -0
  334. package/dist/utils/map-columns/toMapColumnsActions.d.ts +10 -0
  335. package/dist/utils/map-columns/validate.d.ts +45 -0
  336. package/dist/utils/memo.d.ts +4 -0
  337. package/dist/utils/referentialAction.d.ts +21 -0
  338. package/dist/utils/schema-aml-parser/types.d.ts +8 -0
  339. package/dist/utils/schema-dbml-parser/tokenizer.d.ts +2 -0
  340. package/dist/utils/schema-dbml-parser/types.d.ts +14 -0
  341. package/dist/utils/schema-sql/Databricks.d.ts +13 -3
  342. package/dist/utils/schema-sql/MSSQL.d.ts +19 -2
  343. package/dist/utils/schema-sql/MariaDB.d.ts +10 -4
  344. package/dist/utils/schema-sql/MySQL.d.ts +18 -4
  345. package/dist/utils/schema-sql/Oracle.d.ts +23 -4
  346. package/dist/utils/schema-sql/PostgreSQL.d.ts +16 -4
  347. package/dist/utils/schema-sql/SQLite.d.ts +16 -4
  348. package/dist/utils/schema-sql/Snowflake.d.ts +8 -3
  349. package/dist/utils/schema-sql/index.d.ts +21 -1
  350. package/dist/utils/schema-sql/options.d.ts +57 -0
  351. package/dist/utils/schema-sql/utils.d.ts +120 -2
  352. package/dist/utils/schema-sql-parser/index.d.ts +5 -1
  353. package/dist/utils/stageCursor.d.ts +20 -0
  354. package/dist/utils/table-clipboard/payload.d.ts +3 -0
  355. package/dist/utils/table-clipboard/placement.d.ts +2 -0
  356. package/dist/utils/tableColor.d.ts +29 -0
  357. package/dist/utils/tableGroup.d.ts +142 -0
  358. package/dist/utils/tableKeys.d.ts +54 -0
  359. package/dist/workers/elkLayout.shared-worker.js +1 -1
  360. package/dist/workers/exportPng.shared-worker.js +30 -28
  361. package/dist/workers/shiki.shared-worker.js +1 -1
  362. package/dist/workers/spawn.d.ts +1 -2
  363. package/dist/workers/spawn.inline.d.ts +0 -1
  364. package/package.json +12 -18
  365. package/dist/components/generator-code/GeneratorCode.styles.d.ts +0 -2
  366. package/dist/schemaGCService-BagQ1wfF.js +0 -38
  367. package/dist/services/schema-gc/index.d.ts +0 -18
  368. package/dist/services/schema-gc/procGC.d.ts +0 -4
  369. package/dist/services/schema-gc/schemaGC.shared-worker.d.ts +0 -2
  370. package/dist/services/schema-gc/schemaGCService.d.ts +0 -5
  371. package/dist/shared-store-BqPSXAEf.js +0 -1072
  372. package/dist/store-hooks-DuzDVhPy.js +0 -10282
  373. package/dist/styles/colorPicker.style.d.ts +0 -7
  374. package/dist/utils/draw-relationship/chamfer.d.ts +0 -3
  375. package/dist/workers/schemaGC.shared-worker.js +0 -1
@@ -1,1072 +0,0 @@
1
- import { C as e, Ct as t, D as n, Dt as r, E as i, Et as a, Hn as o, O as s, Ot as c, S as l, Sn as u, St as d, T as f, Tt as p, Xi as m, _a as h, b as g, bi as _, bt as v, c as ee, ca as y, ci as b, d as te, di as x, f as S, ia as C, k as w, kt as T, l as E, li as D, m as O, p as k, t as ne, tn as re, u as ie, ui as A, wt as j, x as M, xa as ae, xi as N, xt as P, y as oe, ya as F, yr as I, yt as L, zn as se } from "./store-hooks-DuzDVhPy.js";
2
- import { isEmpty as ce } from "es-toolkit/compat";
3
- import { isFunction as le, isNil as R } from "es-toolkit";
4
- import { nanoid as z } from "nanoid";
5
- import { Observable as B, Subject as V, debounceTime as ue, map as H, merge as de, race as fe, startWith as pe, switchMap as U, take as W, timer as me } from "rxjs";
6
- //#region src/engine/history.ts
7
- function G({ notify: e, dispatch: t, getNextVersion: n }, r) {
8
- let i = r?.commands ?? [], a = r?.cursor ?? -1, o = r?.limit ?? 0, s = !0, c = () => a !== -1, l = () => a < i.length - 1, u = (e) => o = e, d = () => ({
9
- hasRedo: l(),
10
- hasUndo: c()
11
- }), f = (e, r) => {
12
- s = !1, e[r](t, n), s = !0;
13
- };
14
- return Object.freeze({
15
- get cursor() {
16
- return a;
17
- },
18
- get size() {
19
- return i.length;
20
- },
21
- hasUndo: c,
22
- hasRedo: l,
23
- push: (t) => {
24
- s && (i.splice(a + 1, i.length - a), i.push(t), o !== 0 && i.length > o && (i = i.slice(i.length - o, i.length)), a = i.length - 1, e(d()));
25
- },
26
- undo: () => {
27
- if (!c()) return;
28
- let t = i[a];
29
- f(t, "undo"), a--, e(d());
30
- },
31
- redo: () => {
32
- if (!l()) return;
33
- let t = i[a + 1];
34
- f(t, "redo"), a++, e(d());
35
- },
36
- clear: () => {
37
- let t = i.length;
38
- i = [], a = -1, t > 0 && e(d());
39
- },
40
- setLimit: u,
41
- clone: (e) => G(e, {
42
- commands: [...i],
43
- cursor: a,
44
- limit: o
45
- })
46
- });
47
- }
48
- //#endregion
49
- //#region src/engine/rx-operators/flushOnNotifier.ts
50
- var K = (e) => (t) => t.pipe(U((t) => e.pipe(W(1), H(() => t)))), he = (e, t = 200) => (n) => n.pipe(U((n) => fe(me(t), e.pipe(W(1))).pipe(H(() => n)))), q = (e, t = []) => {
51
- let n = m(M), r = (e) => !R(e.tags) && t.some((t) => b(e.tags, t)) || !n(e.type);
52
- return (t) => new B((n) => t.subscribe({
53
- next: (t) => {
54
- n.next(e() ? t.filter(r) : t);
55
- },
56
- error: (e) => n.error(e),
57
- complete: () => n.complete()
58
- })).pipe(O);
59
- }, ge = {
60
- [I.scrollTo]: h.viewScrollTo,
61
- [I.streamScrollTo]: h.viewStreamScrollTo,
62
- [I.changeZoomLevel]: h.viewChangeZoomLevel,
63
- [I.streamZoomLevel]: h.viewStreamZoomLevel
64
- }, _e = ({ tags: e }) => !R(e) && (b(e, D.shared) || b(e, D.following)), ve = (e) => {
65
- let t = ge[e.type];
66
- return t && !_e(e) ? {
67
- ...e,
68
- type: t
69
- } : e;
70
- }, ye = (e) => (t) => new B((n) => t.subscribe({
71
- next: (t) => {
72
- n.next(e() ? t.map(ve) : t);
73
- },
74
- error: (e) => n.error(e),
75
- complete: () => n.complete()
76
- })), J = (e, t = []) => {
77
- let n = m(w), r = (e) => !R(e.tags) && t.some((t) => b(e.tags, t)) || !n(e.type);
78
- return (t) => new B((n) => t.subscribe({
79
- next: (t) => {
80
- n.next(e() ? t.filter(r) : t);
81
- },
82
- error: (e) => n.error(e),
83
- complete: () => n.complete()
84
- })).pipe(O);
85
- }, Y = 2048;
86
- function be(e, { getReadonly: t = () => !1, getHistory: r, manualStreamFlush: a = !1, observable: o = !0 } = {}) {
87
- let c = /* @__PURE__ */ new Set(), l = ee(e, o), d = ne(l), p = {
88
- notify: (e) => l.dispatch(u(e)),
89
- dispatch: l.dispatchSync,
90
- getNextVersion: () => e.clock.getNextVersion()
91
- }, m = r?.(p) ?? G(p);
92
- m.setLimit(Y);
93
- let h = () => _(l.state), v = new V(), y = v.pipe(ye(h)), b = new V(), x = new V(), S = new V(), C = x.pipe(pe(void 0), U(() => b.pipe(te(f, [
94
- ["@@move", n],
95
- ["@@scroll", s],
96
- ["@@color", i]
97
- ], a ? K(S) : void 0)))), w = new B((e) => l.subscribe((t) => e.next(t))).pipe(k(oe), q(t, [D.shared]), ue(200)), T = (...t) => {
98
- let n = e.clock.getNextVersion();
99
- return ae(l.state, l.context, t).map((e) => (R(e.version) && (e.version = n), e));
100
- }, E = (...e) => {
101
- let t = T(e);
102
- v.next(t);
103
- }, O = (...e) => {
104
- queueMicrotask(() => E(e));
105
- }, A = () => {
106
- Array.from(c).forEach((e) => le(e) ? e() : e.unsubscribe()), c.clear(), l.destroy(), d.destroy(), m.clear(), v.complete(), S.complete();
107
- }, j = () => {
108
- x.next(), m.clear();
109
- }, M = () => {
110
- t() || h() || m.undo();
111
- }, N = () => {
112
- t() || h() || m.redo();
113
- }, P = () => {
114
- a && S.next();
115
- };
116
- return c.add(C.subscribe(re(l, m))).add(y.pipe(k(g), ie([D.changeOnly, D.shared]), q(t), J(h)).subscribe(b)).add(y.pipe(q(t, [D.shared]), J(h, [D.shared])).subscribe(l.dispatchSync)).add(l.subscribe((t) => {
117
- t.forEach((t) => e.clock.merge(t.version));
118
- })), Object.freeze({
119
- ...l,
120
- dispatch: O,
121
- dispatchSync: E,
122
- destroy: A,
123
- undo: M,
124
- redo: N,
125
- history: m,
126
- resetHistory: j,
127
- change$: w,
128
- flushStreamBuffers: P
129
- });
130
- }
131
- //#endregion
132
- //#region src/utils/focus.ts
133
- function xe(e, t, n, r = null) {
134
- if (!e || n !== e.tableId) return !1;
135
- switch (t) {
136
- case "tableName":
137
- case "tableComment": return t === e.focusType;
138
- }
139
- return r === e.columnId && t === e.focusType;
140
- }
141
- var Se = (e, t, n) => e?.tableId === t && e.selectColumnIds.includes(n);
142
- function Ce(e, t, n, r = null) {
143
- if (e?.tableId !== n) return !1;
144
- switch (t) {
145
- case N.tableName:
146
- case N.tableComment: return t === e.focusType && e.edit;
147
- }
148
- return r === e.columnId && t === e.focusType && e.edit;
149
- }
150
- function we(e) {
151
- let t = e.value.length;
152
- e.selectionStart = t, e.selectionEnd = t, e.focus();
153
- }
154
- var Te = (e) => e ? {
155
- tableId: e.tableId,
156
- columnId: e.columnId,
157
- focusType: e.focusType
158
- } : null, Ee = (e) => e ? JSON.stringify([
159
- e.tableId,
160
- e.columnId,
161
- e.focusType
162
- ]) : "", X = "`", De = "NOT ENFORCED RELY";
163
- function Oe(e) {
164
- let { doc: { tableIds: t, relationshipIds: n, indexIds: r }, collections: i } = e, a = [], o = [], s = [""], l = F(i).collection("tableEntities").selectByIds(t).sort(j), u = F(i).collection("relationshipEntities").selectByIds(n), d = F(i).collection("indexEntities").selectByIds(r);
165
- return l.forEach((t) => {
166
- ke(e, {
167
- table: t,
168
- buffer: s
169
- }), s.push("");
170
- let n = F(i).collection("tableColumnEntities").selectByIds(t.columnIds);
171
- c(n) && T(n).forEach((e) => {
172
- s.push(`-- Databricks does not support UNIQUE constraints: ${X}${t.name}${X}.${X}${e.name}${X}`), s.push("");
173
- });
174
- }), u.forEach((t) => {
175
- je(e, {
176
- relationship: t,
177
- buffer: s,
178
- fkNames: a
179
- }), s.push("");
180
- }), d.forEach((t) => {
181
- Me(e, {
182
- index: t,
183
- buffer: s,
184
- indexNames: o
185
- }), s.push("");
186
- }), s.join("\n");
187
- }
188
- function ke(e, { buffer: t, table: n }) {
189
- let { collections: r } = e, i = F(r).collection("tableColumnEntities").selectByIds(n.columnIds);
190
- t.push(`CREATE TABLE ${X}${n.name}${X}`), t.push("(");
191
- let o = p(i), s = P(i);
192
- if (i.forEach((n, r) => {
193
- Ae(e, {
194
- column: n,
195
- isComma: o || i.length !== r + 1,
196
- spaceSize: s,
197
- buffer: t
198
- });
199
- }), o) {
200
- let e = a(i);
201
- t.push(` CONSTRAINT ${X}PK_${n.name}${X} PRIMARY KEY (${v(e, X)}) ${De}`);
202
- }
203
- t.push(")"), n.comment.trim() === "" ? t.push("USING DELTA;") : (t.push("USING DELTA"), t.push(`COMMENT '${n.comment}';`));
204
- }
205
- function Ae(e, { buffer: t, column: n, isComma: r, spaceSize: i }) {
206
- let a = [];
207
- a.push(` ${X}${n.name}${X}` + d(i.name - n.name.length)), a.push(`${n.dataType}` + d(i.dataType - n.dataType.length));
208
- let o = b(n.options, C.notNull) || b(n.options, C.primaryKey);
209
- a.push(o ? "NOT NULL" : " "), b(n.options, C.autoIncrement) ? a.push("GENERATED ALWAYS AS IDENTITY") : n.default.trim() !== "" && a.push(`DEFAULT ${n.default}`), n.comment.trim() !== "" && a.push(`COMMENT '${n.comment}'`), t.push(a.join(" ").trimEnd() + `${r ? "," : ""}`);
210
- }
211
- function je({ collections: e }, { buffer: t, relationship: n, fkNames: r }) {
212
- let i = F(e).collection("tableEntities"), a = F(e).collection("tableColumnEntities"), o = i.selectById(n.start.tableId), s = i.selectById(n.end.tableId);
213
- if (o && s) {
214
- t.push(`ALTER TABLE ${X}${s.name}${X}`);
215
- let e = `FK_${o.name}_TO_${s.name}`;
216
- e = L(r, "", e), r.push({
217
- id: z(),
218
- name: e
219
- }), t.push(` ADD CONSTRAINT ${X}${e}${X}`);
220
- let i = {
221
- start: [],
222
- end: []
223
- };
224
- n.end.columnIds.forEach((e) => {
225
- let t = a.selectById(e);
226
- t && i.end.push(t);
227
- }), n.start.columnIds.forEach((e) => {
228
- let t = a.selectById(e);
229
- t && i.start.push(t);
230
- }), t.push(` FOREIGN KEY (${v(i.end, X)})`), t.push(` REFERENCES ${X}${o.name}${X} (${v(i.start, X)}) ${De};`);
231
- }
232
- }
233
- function Me({ collections: e }, { buffer: t, index: n, indexNames: i }) {
234
- let a = F(e).collection("tableEntities").selectById(n.tableId);
235
- if (!a) return;
236
- let o = F(e).collection("indexColumnEntities").selectByIds(n.indexColumnIds).map((t) => {
237
- let n = F(e).collection("tableColumnEntities").selectById(t.columnId);
238
- return n ? { name: `${X}${n.name}${X} ${r(t.orderType)}` } : null;
239
- }).filter((e) => e !== null);
240
- if (o.length === 0) return;
241
- let s = n.name;
242
- n.name.trim() === "" && (s = `IDX_${a.name}`, s = L(i, "", s), i.push({
243
- id: z(),
244
- name: s
245
- })), t.push(`-- Databricks has no secondary indexes. ${X}${s}${X} on ${X}${a.name}${X} (${v(o)})`), t.push(`-- ALTER TABLE ${X}${a.name}${X} CLUSTER BY (${v(F(e).collection("indexColumnEntities").selectByIds(n.indexColumnIds).map((t) => F(e).collection("tableColumnEntities").selectById(t.columnId)).filter((e) => e !== void 0), X)});`);
246
- }
247
- //#endregion
248
- //#region src/utils/schema-sql/MariaDB.ts
249
- function Ne(e) {
250
- let { settings: { bracketType: n }, doc: { tableIds: r, relationshipIds: i, indexIds: a }, collections: o } = e, s = [], l = [], u = [""], d = t(n), f = F(o).collection("tableEntities").selectByIds(r).sort(j), p = F(o).collection("relationshipEntities").selectByIds(i), m = F(o).collection("indexEntities").selectByIds(a);
251
- return f.forEach((t) => {
252
- Pe(e, {
253
- table: t,
254
- buffer: u
255
- }), u.push("");
256
- let n = F(o).collection("tableColumnEntities").selectByIds(t.columnIds);
257
- c(n) && T(n).forEach((e) => {
258
- u.push(`ALTER TABLE ${d}${t.name}${d}`), u.push(` ADD CONSTRAINT ${d}UQ_${t.name}_${e.name}${d} UNIQUE (${d}${e.name}${d});`), u.push("");
259
- });
260
- }), p.forEach((t) => {
261
- Ie(e, {
262
- relationship: t,
263
- buffer: u,
264
- fkNames: s
265
- }), u.push("");
266
- }), m.forEach((t) => {
267
- Le(e, {
268
- index: t,
269
- buffer: u,
270
- indexNames: l
271
- }), u.push("");
272
- }), u.join("\n");
273
- }
274
- function Pe(e, { buffer: n, table: r }) {
275
- let { settings: { bracketType: i }, collections: o } = e, s = t(i), c = F(o).collection("tableColumnEntities").selectByIds(r.columnIds);
276
- n.push(`CREATE TABLE ${s}${r.name}${s}`), n.push("(");
277
- let l = p(c), u = P(c);
278
- if (c.forEach((t, r) => {
279
- l ? Fe(e, {
280
- column: t,
281
- isComma: !0,
282
- spaceSize: u,
283
- buffer: n
284
- }) : Fe(e, {
285
- column: t,
286
- isComma: c.length !== r + 1,
287
- spaceSize: u,
288
- buffer: n
289
- });
290
- }), l) {
291
- let e = a(c);
292
- n.push(` PRIMARY KEY (${v(e, s)})`);
293
- }
294
- r.comment.trim() === "" ? n.push(");") : n.push(`) COMMENT '${r.comment}';`);
295
- }
296
- function Fe({ settings: { bracketType: e } }, { buffer: n, column: r, isComma: i, spaceSize: a }) {
297
- let o = t(e), s = [];
298
- s.push(` ${o}${r.name}${o}` + d(a.name - r.name.length)), s.push(`${r.dataType}` + d(a.dataType - r.dataType.length)), s.push(`${b(r.options, C.notNull) ? "NOT NULL" : "NULL "}`), b(r.options, C.autoIncrement) ? s.push("AUTO_INCREMENT") : r.default.trim() !== "" && s.push(`DEFAULT ${r.default}`), r.comment.trim() !== "" && s.push(`COMMENT '${r.comment}'`), n.push(s.join(" ") + `${i ? "," : ""}`);
299
- }
300
- function Ie({ settings: { bracketType: e }, collections: n }, { buffer: r, relationship: i, fkNames: a }) {
301
- let o = t(e), s = F(n).collection("tableEntities"), c = F(n).collection("tableColumnEntities"), l = s.selectById(i.start.tableId), u = s.selectById(i.end.tableId);
302
- if (l && u) {
303
- r.push(`ALTER TABLE ${o}${u.name}${o}`);
304
- let e = `FK_${l.name}_TO_${u.name}`;
305
- e = L(a, "", e), a.push({
306
- id: z(),
307
- name: e
308
- }), r.push(` ADD CONSTRAINT ${o}${e}${o}`);
309
- let t = {
310
- start: [],
311
- end: []
312
- };
313
- i.end.columnIds.forEach((e) => {
314
- let n = c.selectById(e);
315
- n && t.end.push(n);
316
- }), i.start.columnIds.forEach((e) => {
317
- let n = c.selectById(e);
318
- n && t.start.push(n);
319
- }), r.push(` FOREIGN KEY (${v(t.end, o)})`), r.push(` REFERENCES ${o}${l.name}${o} (${v(t.start, o)});`);
320
- }
321
- }
322
- function Le({ settings: { bracketType: e }, collections: n }, { buffer: i, index: a, indexNames: o }) {
323
- let s = t(e), c = F(n).collection("tableEntities").selectById(a.tableId);
324
- if (!c) return;
325
- let l = F(n).collection("indexColumnEntities").selectByIds(a.indexColumnIds).map((e) => {
326
- let t = F(n).collection("tableColumnEntities").selectById(e.columnId);
327
- return t ? { name: `${s}${t.name}${s} ${r(e.orderType)}` } : null;
328
- }).filter((e) => e !== null);
329
- if (l.length !== 0) {
330
- let e = a.name;
331
- a.name.trim() === "" && (e = `IDX_${c.name}`, e = L(o, "", e), o.push({
332
- id: z(),
333
- name: e
334
- })), a.unique ? i.push(`CREATE UNIQUE INDEX ${s}${e}${s}`) : i.push(`CREATE INDEX ${s}${e}${s}`), i.push(` ON ${s}${c.name}${s} (${v(l)});`);
335
- }
336
- }
337
- //#endregion
338
- //#region src/utils/schema-sql/MSSQL.ts
339
- function Re(e) {
340
- let { settings: { bracketType: n }, doc: { tableIds: r, relationshipIds: i, indexIds: a }, collections: o } = e, s = [], l = [], u = [""], d = t(n), f = F(o).collection("tableEntities").selectByIds(r).sort(j), p = F(o).collection("relationshipEntities").selectByIds(i), m = F(o).collection("indexEntities").selectByIds(a);
341
- return f.forEach((t) => {
342
- ze(e, {
343
- table: t,
344
- buffer: u
345
- }), u.push("");
346
- let n = F(o).collection("tableColumnEntities").selectByIds(t.columnIds);
347
- c(n) && T(n).forEach((e) => {
348
- u.push(`ALTER TABLE ${d}${t.name}${d}`), u.push(` ADD CONSTRAINT ${d}UQ_${t.name}_${e.name}${d} UNIQUE (${d}${e.name}${d})\nGO`), u.push("");
349
- }), Ve(e, {
350
- table: t,
351
- buffer: u
352
- });
353
- }), p.forEach((t) => {
354
- He(e, {
355
- relationship: t,
356
- buffer: u,
357
- fkNames: s
358
- }), u.push("");
359
- }), m.forEach((t) => {
360
- Ue(e, {
361
- index: t,
362
- buffer: u,
363
- indexNames: l
364
- }), u.push("");
365
- }), u.join("\n");
366
- }
367
- function ze(e, { buffer: n, table: r }) {
368
- let { settings: { bracketType: i }, collections: o } = e, s = t(i), c = F(o).collection("tableColumnEntities").selectByIds(r.columnIds);
369
- n.push(`CREATE TABLE ${s}${r.name}${s}`), n.push("(");
370
- let l = p(c), u = P(c);
371
- if (c.forEach((t, r) => {
372
- l ? Be(e, {
373
- column: t,
374
- isComma: !0,
375
- spaceSize: u,
376
- buffer: n
377
- }) : Be(e, {
378
- column: t,
379
- isComma: c.length !== r + 1,
380
- spaceSize: u,
381
- buffer: n
382
- });
383
- }), l) {
384
- let e = a(c);
385
- n.push(` CONSTRAINT ${s}PK_${r.name}${s} PRIMARY KEY (${v(e, s)})`);
386
- }
387
- n.push(")\nGO");
388
- }
389
- function Be({ settings: { bracketType: e } }, { buffer: n, column: r, isComma: i, spaceSize: a }) {
390
- let o = t(e), s = [];
391
- s.push(` ${o}${r.name}${o}` + d(a.name - r.name.length)), s.push(`${r.dataType}` + d(a.dataType - r.dataType.length)), b(r.options, C.notNull) && s.push("NOT NULL"), b(r.options, C.autoIncrement) ? s.push("IDENTITY(1,1)") : r.default.trim() !== "" && s.push(`DEFAULT ${r.default}`), n.push(s.join(" ") + `${i ? "," : ""}`);
392
- }
393
- function Ve({ collections: e }, { table: t, buffer: n }) {
394
- t.comment.trim() !== "" && (n.push("EXECUTE sys.sp_addextendedproperty 'MS_Description',"), n.push(` '${t.comment}', 'user', dbo, 'table', '${t.name}'\nGO`), n.push("")), F(e).collection("tableColumnEntities").selectByIds(t.columnIds).forEach((e) => {
395
- e.comment.trim() !== "" && (n.push("EXECUTE sys.sp_addextendedproperty 'MS_Description',"), n.push(` '${e.comment}', 'user', dbo, 'table', '${t.name}', 'column', '${e.name}'\nGO`), n.push(""));
396
- });
397
- }
398
- function He({ settings: { bracketType: e }, collections: n }, { buffer: r, relationship: i, fkNames: a }) {
399
- let o = t(e), s = F(n).collection("tableEntities"), c = F(n).collection("tableColumnEntities"), l = s.selectById(i.start.tableId), u = s.selectById(i.end.tableId);
400
- if (l && u) {
401
- r.push(`ALTER TABLE ${o}${u.name}${o}`);
402
- let e = `FK_${l.name}_TO_${u.name}`;
403
- e = L(a, "", e), a.push({
404
- id: z(),
405
- name: e
406
- }), r.push(` ADD CONSTRAINT ${o}${e}${o}`);
407
- let t = {
408
- start: [],
409
- end: []
410
- };
411
- i.end.columnIds.forEach((e) => {
412
- let n = c.selectById(e);
413
- n && t.end.push(n);
414
- }), i.start.columnIds.forEach((e) => {
415
- let n = c.selectById(e);
416
- n && t.start.push(n);
417
- }), r.push(` FOREIGN KEY (${v(t.end, o)})`), r.push(` REFERENCES ${o}${l.name}${o} (${v(t.start, o)})\nGO`);
418
- }
419
- }
420
- function Ue({ settings: { bracketType: e }, collections: n }, { buffer: i, index: a, indexNames: o }) {
421
- let s = t(e), c = F(n).collection("tableEntities").selectById(a.tableId);
422
- if (!c) return;
423
- let l = F(n).collection("indexColumnEntities").selectByIds(a.indexColumnIds).map((e) => {
424
- let t = F(n).collection("tableColumnEntities").selectById(e.columnId);
425
- return t ? { name: `${s}${t.name}${s} ${r(e.orderType)}` } : null;
426
- }).filter((e) => e !== null);
427
- if (l.length !== 0) {
428
- let e = a.name;
429
- a.name.trim() === "" && (e = `IDX_${c.name}`, e = L(o, "", e), o.push({
430
- id: z(),
431
- name: e
432
- })), a.unique ? i.push(`CREATE UNIQUE INDEX ${s}${e}${s}`) : i.push(`CREATE INDEX ${s}${e}${s}`), i.push(` ON ${s}${c.name}${s} (${v(l)})\nGO`);
433
- }
434
- }
435
- //#endregion
436
- //#region src/utils/schema-sql/MySQL.ts
437
- function We(e) {
438
- let { settings: { bracketType: n }, doc: { tableIds: r, relationshipIds: i, indexIds: a }, collections: o } = e, s = [], l = [], u = [""], d = t(n), f = F(o).collection("tableEntities").selectByIds(r).sort(j), p = F(o).collection("relationshipEntities").selectByIds(i), m = F(o).collection("indexEntities").selectByIds(a);
439
- return f.forEach((t) => {
440
- Ge(e, {
441
- table: t,
442
- buffer: u
443
- }), u.push("");
444
- let n = F(o).collection("tableColumnEntities").selectByIds(t.columnIds);
445
- c(n) && T(n).forEach((e) => {
446
- u.push(`ALTER TABLE ${d}${t.name}${d}`), u.push(` ADD CONSTRAINT ${d}UQ_${t.name}_${e.name}${d} UNIQUE (${d}${e.name}${d});`), u.push("");
447
- });
448
- }), p.forEach((t) => {
449
- qe(e, {
450
- relationship: t,
451
- buffer: u,
452
- fkNames: s
453
- }), u.push("");
454
- }), m.forEach((t) => {
455
- Je(e, {
456
- index: t,
457
- buffer: u,
458
- indexNames: l
459
- }), u.push("");
460
- }), u.join("\n");
461
- }
462
- function Ge(e, { buffer: n, table: r }) {
463
- let { settings: { bracketType: i }, collections: o } = e, s = t(i), c = F(o).collection("tableColumnEntities").selectByIds(r.columnIds);
464
- n.push(`CREATE TABLE ${s}${r.name}${s}`), n.push("(");
465
- let l = p(c), u = P(c);
466
- if (c.forEach((t, r) => {
467
- l ? Ke(e, {
468
- column: t,
469
- isComma: !0,
470
- spaceSize: u,
471
- buffer: n
472
- }) : Ke(e, {
473
- column: t,
474
- isComma: c.length !== r + 1,
475
- spaceSize: u,
476
- buffer: n
477
- });
478
- }), l) {
479
- let e = a(c);
480
- n.push(` PRIMARY KEY (${v(e, s)})`);
481
- }
482
- r.comment.trim() === "" ? n.push(");") : n.push(`) COMMENT '${r.comment}';`);
483
- }
484
- function Ke({ settings: { bracketType: e } }, { buffer: n, column: r, isComma: i, spaceSize: a }) {
485
- let o = t(e), s = [];
486
- s.push(` ${o}${r.name}${o}` + d(a.name - r.name.length)), s.push(`${r.dataType}` + d(a.dataType - r.dataType.length)), s.push(`${b(r.options, C.notNull) ? "NOT NULL" : "NULL "}`), b(r.options, C.autoIncrement) ? s.push("AUTO_INCREMENT") : r.default.trim() !== "" && s.push(`DEFAULT ${r.default}`), r.comment.trim() !== "" && s.push(`COMMENT '${r.comment}'`), n.push(s.join(" ") + `${i ? "," : ""}`);
487
- }
488
- function qe({ settings: { bracketType: e }, collections: n }, { buffer: r, relationship: i, fkNames: a }) {
489
- let o = t(e), s = F(n).collection("tableEntities"), c = F(n).collection("tableColumnEntities"), l = s.selectById(i.start.tableId), u = s.selectById(i.end.tableId);
490
- if (l && u) {
491
- r.push(`ALTER TABLE ${o}${u.name}${o}`);
492
- let e = `FK_${l.name}_TO_${u.name}`;
493
- e = L(a, "", e), a.push({
494
- id: z(),
495
- name: e
496
- }), r.push(` ADD CONSTRAINT ${o}${e}${o}`);
497
- let t = {
498
- start: [],
499
- end: []
500
- };
501
- i.end.columnIds.forEach((e) => {
502
- let n = c.selectById(e);
503
- n && t.end.push(n);
504
- }), i.start.columnIds.forEach((e) => {
505
- let n = c.selectById(e);
506
- n && t.start.push(n);
507
- }), r.push(` FOREIGN KEY (${v(t.end, o)})`), r.push(` REFERENCES ${o}${l.name}${o} (${v(t.start, o)});`);
508
- }
509
- }
510
- function Je({ settings: { bracketType: e }, collections: n }, { buffer: i, index: a, indexNames: o }) {
511
- let s = t(e), c = F(n).collection("tableEntities").selectById(a.tableId);
512
- if (!c) return;
513
- let l = F(n).collection("indexColumnEntities").selectByIds(a.indexColumnIds).map((e) => {
514
- let t = F(n).collection("tableColumnEntities").selectById(e.columnId);
515
- return t ? { name: `${s}${t.name}${s} ${r(e.orderType)}` } : null;
516
- }).filter((e) => e !== null);
517
- if (l.length !== 0) {
518
- let e = a.name;
519
- a.name.trim() === "" && (e = `IDX_${c.name}`, e = L(o, "", e), o.push({
520
- id: z(),
521
- name: e
522
- })), a.unique ? i.push(`CREATE UNIQUE INDEX ${s}${e}${s}`) : i.push(`CREATE INDEX ${s}${e}${s}`), i.push(` ON ${s}${c.name}${s} (${v(l)});`);
523
- }
524
- }
525
- //#endregion
526
- //#region src/utils/schema-sql/Oracle.ts
527
- function Ye(e) {
528
- let { settings: { bracketType: n }, doc: { tableIds: r, relationshipIds: i, indexIds: a }, collections: o } = e, s = [], l = [], u = [], d = [], f = [""], p = t(n), m = F(o).collection("tableEntities").selectByIds(r).sort(j), h = F(o).collection("relationshipEntities").selectByIds(i), g = F(o).collection("indexEntities").selectByIds(a);
529
- return m.forEach((t) => {
530
- Xe(e, {
531
- table: t,
532
- buffer: f
533
- }), f.push("");
534
- let n = F(o).collection("tableColumnEntities").selectByIds(t.columnIds);
535
- c(n) && T(n).forEach((e) => {
536
- f.push(`ALTER TABLE ${p}${t.name}${p}`), f.push(` ADD CONSTRAINT ${p}UQ_${t.name}_${e.name}${p} UNIQUE (${p}${e.name}${p});`), f.push("");
537
- }), n.forEach((e) => {
538
- if (b(e.options, C.autoIncrement)) {
539
- let n = `SEQ_${t.name}`;
540
- n = L(l, "", n), l.push({
541
- id: z(),
542
- name: n
543
- }), f.push(`CREATE SEQUENCE ${n}`), f.push("START WITH 1"), f.push("INCREMENT BY 1;"), f.push("");
544
- let r = `SEQ_TRG_${t.name}`;
545
- r = L(l, "", r), u.push({
546
- id: z(),
547
- name: r
548
- }), f.push(`CREATE OR REPLACE TRIGGER ${r}`), f.push(`BEFORE INSERT ON ${t.name}`), f.push("REFERENCING NEW AS NEW FOR EACH ROW"), f.push("BEGIN"), f.push(` SELECT ${n}.NEXTVAL`), f.push(` INTO: NEW.${e.name}`), f.push(" FROM DUAL;"), f.push("END;"), f.push("");
549
- }
550
- }), Qe(e, {
551
- table: t,
552
- buffer: f
553
- });
554
- }), h.forEach((t) => {
555
- $e(e, {
556
- relationship: t,
557
- buffer: f,
558
- fkNames: s
559
- }), f.push("");
560
- }), g.forEach((t) => {
561
- Z(e, {
562
- index: t,
563
- buffer: f,
564
- indexNames: d
565
- }), f.push("");
566
- }), f.join("\n");
567
- }
568
- function Xe(e, { buffer: n, table: r }) {
569
- let { settings: { bracketType: i }, collections: o } = e, s = t(i), c = F(o).collection("tableColumnEntities").selectByIds(r.columnIds);
570
- n.push(`CREATE TABLE ${s}${r.name}${s}`), n.push("(");
571
- let l = p(c), u = P(c);
572
- if (c.forEach((t, r) => {
573
- l ? Ze(e, {
574
- column: t,
575
- isComma: !0,
576
- spaceSize: u,
577
- buffer: n
578
- }) : Ze(e, {
579
- column: t,
580
- isComma: c.length !== r + 1,
581
- spaceSize: u,
582
- buffer: n
583
- });
584
- }), l) {
585
- let e = a(c);
586
- n.push(` CONSTRAINT ${s}PK_${r.name}${s} PRIMARY KEY (${v(e, s)})`);
587
- }
588
- n.push(");");
589
- }
590
- function Ze({ settings: { bracketType: e } }, { buffer: n, column: r, isComma: i, spaceSize: a }) {
591
- let o = t(e), s = [];
592
- s.push(` ${o}${r.name}${o}` + d(a.name - r.name.length)), s.push(`${r.dataType}` + d(a.dataType - r.dataType.length)), r.default.trim() !== "" && s.push(`DEFAULT ${r.default}`), b(r.options, C.notNull) && s.push("NOT NULL"), n.push(s.join(" ") + `${i ? "," : ""}`);
593
- }
594
- function Qe({ settings: { bracketType: e }, collections: n }, { table: r, buffer: i }) {
595
- let a = t(e);
596
- r.comment.trim() !== "" && (i.push(`COMMENT ON TABLE ${a}${r.name}${a} IS '${r.comment}';`), i.push("")), F(n).collection("tableColumnEntities").selectByIds(r.columnIds).forEach((e) => {
597
- e.comment.trim() !== "" && (i.push(`COMMENT ON COLUMN ${a}${r.name}${a}.${a}${e.name}${a} IS '${e.comment}';`), i.push(""));
598
- });
599
- }
600
- function $e({ settings: { bracketType: e }, collections: n }, { buffer: r, relationship: i, fkNames: a }) {
601
- let o = t(e), s = F(n).collection("tableEntities"), c = F(n).collection("tableColumnEntities"), l = s.selectById(i.start.tableId), u = s.selectById(i.end.tableId);
602
- if (l && u) {
603
- r.push(`ALTER TABLE ${o}${u.name}${o}`);
604
- let e = `FK_${l.name}_TO_${u.name}`;
605
- e = L(a, "", e), a.push({
606
- id: z(),
607
- name: e
608
- }), r.push(` ADD CONSTRAINT ${o}${e}${o}`);
609
- let t = {
610
- start: [],
611
- end: []
612
- };
613
- i.end.columnIds.forEach((e) => {
614
- let n = c.selectById(e);
615
- n && t.end.push(n);
616
- }), i.start.columnIds.forEach((e) => {
617
- let n = c.selectById(e);
618
- n && t.start.push(n);
619
- }), r.push(` FOREIGN KEY (${v(t.end, o)})`), r.push(` REFERENCES ${o}${l.name}${o} (${v(t.start, o)});`);
620
- }
621
- }
622
- function Z({ settings: { bracketType: e }, collections: n }, { buffer: i, index: a, indexNames: o }) {
623
- let s = t(e), c = F(n).collection("tableEntities").selectById(a.tableId);
624
- if (!c) return;
625
- let l = F(n).collection("indexColumnEntities").selectByIds(a.indexColumnIds).map((e) => {
626
- let t = F(n).collection("tableColumnEntities").selectById(e.columnId);
627
- return t ? { name: `${s}${t.name}${s} ${r(e.orderType)}` } : null;
628
- }).filter((e) => e !== null);
629
- if (l.length !== 0) {
630
- let e = a.name;
631
- a.name.trim() === "" && (e = `IDX_${c.name}`, e = L(o, "", e), o.push({
632
- id: z(),
633
- name: e
634
- })), a.unique ? i.push(`CREATE UNIQUE INDEX ${s}${e}${s}`) : i.push(`CREATE INDEX ${s}${e}${s}`), i.push(` ON ${s}${c.name}${s} (${v(l)});`);
635
- }
636
- }
637
- //#endregion
638
- //#region src/utils/schema-sql/PostgreSQL.ts
639
- function et(e) {
640
- let { doc: { tableIds: t, relationshipIds: n, indexIds: r }, collections: i } = e, a = [], o = [], s = [""], c = F(i).collection("tableEntities").selectByIds(t).sort(j), l = F(i).collection("relationshipEntities").selectByIds(n), u = F(i).collection("indexEntities").selectByIds(r);
641
- return c.forEach((t) => {
642
- tt(e, {
643
- table: t,
644
- buffer: s
645
- }), s.push(""), rt(e, {
646
- table: t,
647
- buffer: s
648
- });
649
- }), l.forEach((t) => {
650
- it(e, {
651
- relationship: t,
652
- buffer: s,
653
- fkNames: a
654
- }), s.push("");
655
- }), u.forEach((t) => {
656
- at(e, {
657
- index: t,
658
- buffer: s,
659
- indexNames: o
660
- }), s.push("");
661
- }), s.join("\n");
662
- }
663
- function tt(e, { buffer: n, table: r }) {
664
- let { settings: { bracketType: i }, collections: o } = e, s = t(i), c = F(o).collection("tableColumnEntities").selectByIds(r.columnIds);
665
- n.push(`CREATE TABLE ${s}${r.name}${s}`), n.push("(");
666
- let l = p(c), u = P(c);
667
- if (c.forEach((t, r) => {
668
- l ? nt(e, {
669
- column: t,
670
- isComma: !0,
671
- spaceSize: u,
672
- buffer: n
673
- }) : nt(e, {
674
- column: t,
675
- isComma: c.length !== r + 1,
676
- spaceSize: u,
677
- buffer: n
678
- });
679
- }), l) {
680
- let e = a(c);
681
- n.push(` PRIMARY KEY (${v(e, s)})`);
682
- }
683
- n.push(");");
684
- }
685
- function nt({ settings: { bracketType: e } }, { buffer: n, column: r, isComma: i, spaceSize: a }) {
686
- let o = t(e), s = [];
687
- s.push(` ${o}${r.name}${o}` + d(a.name - r.name.length)), s.push(`${r.dataType}` + d(a.dataType - r.dataType.length)), b(r.options, C.notNull) && s.push("NOT NULL"), b(r.options, C.autoIncrement) ? s.push("GENERATED ALWAYS AS IDENTITY") : r.default.trim() !== "" && s.push(`DEFAULT ${r.default}`), b(r.options, C.unique) && s.push("UNIQUE"), n.push(s.join(" ") + `${i ? "," : ""}`);
688
- }
689
- function rt({ settings: { bracketType: e }, collections: n }, { buffer: r, table: i }) {
690
- let a = t(e);
691
- i.comment.trim() !== "" && (r.push(`COMMENT ON TABLE ${a}${i.name}${a} IS '${i.comment}';`), r.push("")), F(n).collection("tableColumnEntities").selectByIds(i.columnIds).forEach((e) => {
692
- e.comment.trim() !== "" && (r.push(`COMMENT ON COLUMN ${a}${i.name}${a}.${a}${e.name}${a} IS '${e.comment}';`), r.push(""));
693
- });
694
- }
695
- function it({ settings: { bracketType: e }, collections: n }, { buffer: r, relationship: i, fkNames: a }) {
696
- let o = t(e), s = F(n).collection("tableEntities"), c = F(n).collection("tableColumnEntities"), l = s.selectById(i.start.tableId), u = s.selectById(i.end.tableId);
697
- if (l && u) {
698
- r.push(`ALTER TABLE ${o}${u.name}${o}`);
699
- let e = `FK_${l.name}_TO_${u.name}`;
700
- e = L(a, "", e), a.push({
701
- id: z(),
702
- name: e
703
- }), r.push(` ADD CONSTRAINT ${o}${e}${o}`);
704
- let t = {
705
- start: [],
706
- end: []
707
- };
708
- i.end.columnIds.forEach((e) => {
709
- let n = c.selectById(e);
710
- n && t.end.push(n);
711
- }), i.start.columnIds.forEach((e) => {
712
- let n = c.selectById(e);
713
- n && t.start.push(n);
714
- }), r.push(` FOREIGN KEY (${v(t.end, o)})`), r.push(` REFERENCES ${o}${l.name}${o} (${v(t.start, o)});`);
715
- }
716
- }
717
- function at({ settings: { bracketType: e }, collections: n }, { buffer: i, index: a, indexNames: o }) {
718
- let s = t(e), c = F(n).collection("tableEntities").selectById(a.tableId);
719
- if (!c) return;
720
- let l = F(n).collection("indexColumnEntities").selectByIds(a.indexColumnIds).map((e) => {
721
- let t = F(n).collection("tableColumnEntities").selectById(e.columnId);
722
- return t ? { name: `${s}${t.name}${s} ${r(e.orderType)}` } : null;
723
- }).filter((e) => e !== null);
724
- if (l.length !== 0) {
725
- let e = a.name;
726
- a.name.trim() === "" && (e = `IDX_${c.name}`, e = L(o, "", e), o.push({
727
- id: z(),
728
- name: e
729
- })), a.unique ? i.push(`CREATE UNIQUE INDEX ${s}${e}${s}`) : i.push(`CREATE INDEX ${s}${e}${s}`), i.push(` ON ${s}${c.name}${s} (${v(l)});`);
730
- }
731
- }
732
- //#endregion
733
- //#region src/utils/schema-sql/Snowflake.ts
734
- var Q = (e) => t(e) === "" ? "" : "\"";
735
- function ot(e) {
736
- let { doc: { tableIds: t, relationshipIds: n, indexIds: r }, collections: i } = e, a = [], o = [], s = [""], c = F(i).collection("tableEntities").selectByIds(t).sort(j), l = F(i).collection("relationshipEntities").selectByIds(n), u = F(i).collection("indexEntities").selectByIds(r);
737
- return c.forEach((t) => {
738
- st(e, {
739
- table: t,
740
- buffer: s
741
- }), s.push("");
742
- }), l.forEach((t) => {
743
- lt(e, {
744
- relationship: t,
745
- buffer: s,
746
- fkNames: a
747
- }), s.push("");
748
- }), u.forEach((t) => {
749
- ut(e, {
750
- index: t,
751
- buffer: s,
752
- indexNames: o
753
- }), s.push("");
754
- }), s.join("\n");
755
- }
756
- function st(e, { buffer: t, table: n }) {
757
- let { collections: r, settings: { bracketType: i } } = e, o = Q(i), s = F(r).collection("tableColumnEntities").selectByIds(n.columnIds);
758
- t.push(`CREATE TABLE ${o}${n.name}${o}`), t.push("(");
759
- let c = p(s), l = P(s);
760
- if (s.forEach((n, r) => {
761
- ct(e, {
762
- column: n,
763
- isComma: c || s.length !== r + 1,
764
- spaceSize: l,
765
- buffer: t
766
- });
767
- }), c) {
768
- let e = a(s);
769
- t.push(` CONSTRAINT ${o}PK_${n.name}${o} PRIMARY KEY (${v(e, o)})`);
770
- }
771
- n.comment.trim() === "" ? t.push(");") : (t.push(")"), t.push(`COMMENT = '${n.comment}';`));
772
- }
773
- function ct({ settings: { bracketType: e } }, { buffer: t, column: n, isComma: r, spaceSize: i }) {
774
- let a = Q(e), o = [];
775
- o.push(` ${a}${n.name}${a}` + d(i.name - n.name.length)), o.push(`${n.dataType}` + d(i.dataType - n.dataType.length)), b(n.options, C.unique) && o.push("UNIQUE");
776
- let s = b(n.options, C.notNull) || b(n.options, C.primaryKey);
777
- o.push(s ? "NOT NULL" : " "), b(n.options, C.autoIncrement) ? o.push("AUTOINCREMENT") : n.default.trim() !== "" && o.push(`DEFAULT ${n.default}`), n.comment.trim() !== "" && o.push(`COMMENT '${n.comment}'`), t.push(o.join(" ").trimEnd() + `${r ? "," : ""}`);
778
- }
779
- function lt({ collections: e, settings: { bracketType: t } }, { buffer: n, relationship: r, fkNames: i }) {
780
- let a = Q(t), o = F(e).collection("tableEntities"), s = F(e).collection("tableColumnEntities"), c = o.selectById(r.start.tableId), l = o.selectById(r.end.tableId);
781
- if (c && l) {
782
- n.push(`ALTER TABLE ${a}${l.name}${a}`);
783
- let e = `FK_${c.name}_TO_${l.name}`;
784
- e = L(i, "", e), i.push({
785
- id: z(),
786
- name: e
787
- }), n.push(` ADD CONSTRAINT ${a}${e}${a}`);
788
- let t = {
789
- start: [],
790
- end: []
791
- };
792
- r.end.columnIds.forEach((e) => {
793
- let n = s.selectById(e);
794
- n && t.end.push(n);
795
- }), r.start.columnIds.forEach((e) => {
796
- let n = s.selectById(e);
797
- n && t.start.push(n);
798
- }), n.push(` FOREIGN KEY (${v(t.end, a)})`), n.push(` REFERENCES ${a}${c.name}${a} (${v(t.start, a)});`);
799
- }
800
- }
801
- function ut({ collections: e, settings: { bracketType: t } }, { buffer: n, index: i, indexNames: a }) {
802
- let o = Q(t), s = F(e).collection("tableEntities").selectById(i.tableId);
803
- if (!s) return;
804
- let c = F(e).collection("indexColumnEntities").selectByIds(i.indexColumnIds), l = c.map((t) => F(e).collection("tableColumnEntities").selectById(t.columnId)).filter((e) => e !== void 0);
805
- if (l.length === 0) return;
806
- let u = i.name;
807
- if (i.name.trim() === "" && (u = `IDX_${s.name}`, u = L(a, "", u), a.push({
808
- id: z(),
809
- name: u
810
- })), i.unique) {
811
- n.push(`ALTER TABLE ${o}${s.name}${o}`), n.push(` ADD CONSTRAINT ${o}${u}${o} UNIQUE (${v(l, o)});`);
812
- return;
813
- }
814
- let d = c.map((t) => {
815
- let n = F(e).collection("tableColumnEntities").selectById(t.columnId);
816
- return n ? { name: `${o}${n.name}${o} ${r(t.orderType)}` } : null;
817
- }).filter((e) => e !== null);
818
- n.push(`-- Snowflake has no secondary indexes. ${o}${u}${o} on ${o}${s.name}${o} (${v(d)})`), n.push(`-- ALTER TABLE ${o}${s.name}${o} CLUSTER BY (${v(l, o)});`);
819
- }
820
- //#endregion
821
- //#region src/utils/schema-sql/SQLite.ts
822
- function dt(e) {
823
- let { doc: { tableIds: t, indexIds: n }, collections: r } = e, i = [], a = [""], o = F(r).collection("tableEntities").selectByIds(t).sort(j), s = F(r).collection("indexEntities").selectByIds(n);
824
- return o.forEach((t) => {
825
- ft(e, {
826
- table: t,
827
- buffer: a
828
- }), a.push("");
829
- }), s.forEach((t) => {
830
- $(e, {
831
- index: t,
832
- buffer: a,
833
- indexNames: i
834
- }), a.push("");
835
- }), a.join("\n");
836
- }
837
- function ft(e, { buffer: n, table: r }) {
838
- let { settings: { bracketType: i }, doc: { relationshipIds: o }, collections: s } = e, c = t(i), l = F(s).collection("tableEntities"), u = F(s).collection("tableColumnEntities"), d = u.selectByIds(r.columnIds), f = F(s).collection("relationshipEntities").selectByIds(o).filter(({ end: e }) => e.tableId === r.id);
839
- r.comment.trim() !== "" && n.push(`-- ${r.comment}`), n.push(`CREATE TABLE ${c}${r.name}${c}`), n.push("(");
840
- let m = p(d), h = P(d);
841
- if (d.forEach((t, r) => {
842
- m ? pt(e, {
843
- column: t,
844
- isComma: !0,
845
- spaceSize: h,
846
- buffer: n
847
- }) : pt(e, {
848
- column: t,
849
- isComma: d.length !== r + 1,
850
- spaceSize: h,
851
- buffer: n
852
- });
853
- }), m) {
854
- let e = a(d);
855
- if (f.length !== 0) {
856
- if (e.length === 1) {
857
- let t = b(e[0].options, C.autoIncrement) ? " AUTOINCREMENT" : "";
858
- n.push(` PRIMARY KEY (${v(e, c)}${t}),`);
859
- } else n.push(` PRIMARY KEY (${v(e, c)}),`);
860
- } else if (e.length === 1) {
861
- let t = b(e[0].options, C.autoIncrement) ? " AUTOINCREMENT" : "";
862
- n.push(` PRIMARY KEY (${v(e, c)}${t})`);
863
- } else n.push(` PRIMARY KEY (${v(e, c)})`);
864
- }
865
- f.forEach((e, t) => {
866
- let r = l.selectById(e.start.tableId), i = l.selectById(e.end.tableId);
867
- if (r && i) {
868
- let i = {
869
- start: [],
870
- end: []
871
- };
872
- e.end.columnIds.forEach((e) => {
873
- let t = u.selectById(e);
874
- t && i.end.push(t);
875
- }), e.start.columnIds.forEach((e) => {
876
- let t = u.selectById(e);
877
- t && i.start.push(t);
878
- }), f.length - 1 > t ? n.push(` FOREIGN KEY (${v(i.end, c)}) REFERENCES ${c}${r.name}${c} (${v(i.start, c)}),`) : n.push(` FOREIGN KEY (${v(i.end, c)}) REFERENCES ${c}${r.name}${c} (${v(i.start, c)})`);
879
- }
880
- }), n.push(");");
881
- }
882
- function pt({ settings: { bracketType: e } }, { buffer: n, column: r, isComma: i, spaceSize: a }) {
883
- let o = t(e), s = [];
884
- r.comment.trim() !== "" && n.push(` -- ${r.comment}`), s.push(` ${o}${r.name}${o}` + d(a.name - r.name.length)), s.push(`${r.dataType}` + d(a.dataType - r.dataType.length)), s.push(`${b(r.options, C.notNull) ? "NOT NULL" : "NULL "}`), b(r.options, C.unique) && s.push("UNIQUE"), !b(r.options, C.autoIncrement) && r.default.trim() !== "" && s.push(`DEFAULT ${r.default}`), n.push(s.join(" ") + `${i ? "," : ""}`);
885
- }
886
- function $({ settings: { bracketType: e }, collections: n }, { buffer: i, index: a, indexNames: o }) {
887
- let s = t(e), c = F(n).collection("tableEntities").selectById(a.tableId);
888
- if (!c) return;
889
- let l = F(n).collection("indexColumnEntities").selectByIds(a.indexColumnIds).map((e) => {
890
- let t = F(n).collection("tableColumnEntities").selectById(e.columnId);
891
- return t ? { name: `${s}${t.name}${s} ${r(e.orderType)}` } : null;
892
- }).filter((e) => e !== null);
893
- if (l.length !== 0) {
894
- let e = a.name;
895
- a.name.trim() === "" && (e = `IDX_${c.name}`, e = L(o, "", e), o.push({
896
- id: z(),
897
- name: e
898
- })), a.unique ? i.push(`CREATE UNIQUE INDEX ${s}${e}${s}`) : i.push(`CREATE INDEX ${s}${e}${s}`), i.push(` ON ${s}${c.name}${s} (${v(l)});`);
899
- }
900
- }
901
- //#endregion
902
- //#region src/utils/schema-sql/index.ts
903
- function mt(e, t) {
904
- switch (t || e.settings.database) {
905
- case y.Databricks: return Oe(e);
906
- case y.MariaDB: return Ne(e);
907
- case y.MSSQL: return Re(e);
908
- case y.MySQL: return We(e);
909
- case y.Oracle: return Ye(e);
910
- case y.PostgreSQL: return et(e);
911
- case y.Snowflake: return ot(e);
912
- case y.SQLite: return dt(e);
913
- }
914
- return "";
915
- }
916
- function ht(e, t) {
917
- let { settings: n, doc: { indexIds: r }, collections: i } = e, a = [""], o = n.database, s = [], c = F(i).collection("indexEntities").selectByIds(r).filter((e) => e.tableId === t.id);
918
- switch (o) {
919
- case y.Databricks:
920
- ke(e, {
921
- buffer: a,
922
- table: t
923
- }), a.push(""), c.forEach((t) => {
924
- Me(e, {
925
- index: t,
926
- buffer: a,
927
- indexNames: s
928
- }), a.push("");
929
- });
930
- break;
931
- case y.MariaDB:
932
- Pe(e, {
933
- buffer: a,
934
- table: t
935
- }), a.push(""), c.forEach((t) => {
936
- Le(e, {
937
- index: t,
938
- buffer: a,
939
- indexNames: s
940
- }), a.push("");
941
- });
942
- break;
943
- case y.MSSQL:
944
- ze(e, {
945
- buffer: a,
946
- table: t
947
- }), a.push(""), c.forEach((t) => {
948
- Ue(e, {
949
- index: t,
950
- buffer: a,
951
- indexNames: s
952
- }), a.push("");
953
- });
954
- break;
955
- case y.MySQL:
956
- Ge(e, {
957
- buffer: a,
958
- table: t
959
- }), a.push(""), c.forEach((t) => {
960
- Je(e, {
961
- index: t,
962
- buffer: a,
963
- indexNames: s
964
- }), a.push("");
965
- });
966
- break;
967
- case y.Oracle:
968
- Xe(e, {
969
- buffer: a,
970
- table: t
971
- }), a.push(""), c.forEach((t) => {
972
- Z(e, {
973
- index: t,
974
- buffer: a,
975
- indexNames: s
976
- }), a.push("");
977
- });
978
- break;
979
- case y.PostgreSQL:
980
- tt(e, {
981
- buffer: a,
982
- table: t
983
- }), a.push(""), c.forEach((t) => {
984
- at(e, {
985
- index: t,
986
- buffer: a,
987
- indexNames: s
988
- }), a.push("");
989
- });
990
- break;
991
- case y.Snowflake:
992
- st(e, {
993
- buffer: a,
994
- table: t
995
- }), a.push(""), c.forEach((t) => {
996
- ut(e, {
997
- index: t,
998
- buffer: a,
999
- indexNames: s
1000
- }), a.push("");
1001
- });
1002
- break;
1003
- case y.SQLite: ft(e, {
1004
- buffer: a,
1005
- table: t
1006
- }), a.push(""), c.forEach((t) => {
1007
- $(e, {
1008
- index: t,
1009
- buffer: a,
1010
- indexNames: s
1011
- }), a.push("");
1012
- });
1013
- }
1014
- return a.join("\n");
1015
- }
1016
- //#endregion
1017
- //#region src/engine/shared-store.ts
1018
- var gt = 2, _t = m(e);
1019
- function vt(e, t, n) {
1020
- let r = n?.manualStreamFlush ?? !1, i = { editorId: e.state.editor.id }, a = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), c = new V(), u = new V(), d = new V(), f = new V(), p = new V(), m = E(r ? K(p) : he(p)), h = !0, g = !0;
1021
- a.add(de(new B((t) => e.subscribe((e) => t.next(e))), u).pipe(k(l), ie([D.shared]), m, S(d, f), m, H((e) => x(D.shared, e.map((e) => {
1022
- let n = {
1023
- ...e,
1024
- meta: Object.assign({}, e.meta ?? {}, {
1025
- ...i,
1026
- nickname: t?.getNickname?.()
1027
- })
1028
- };
1029
- return _t(e.type) ? A(D.following, n) : n;
1030
- })))).subscribe((e) => c.next(e)));
1031
- let _ = () => {
1032
- let e = 0 < s.size;
1033
- h && e ? d.next() : f.next();
1034
- }, v = (t) => {
1035
- let n = (Array.isArray(t) ? t : [t]).some((e) => e.type === se.type), r = e.state.lww;
1036
- n && !ce(r) && u.next([{
1037
- ...o({ lww: r }),
1038
- version: e.context.clock.getVersion()
1039
- }]);
1040
- };
1041
- return Object.freeze({
1042
- connection: () => {
1043
- h = !0, _();
1044
- },
1045
- disconnect: () => {
1046
- h = !1, _();
1047
- },
1048
- dispatch: (t) => {
1049
- e.dispatch(t), v(t);
1050
- },
1051
- dispatchSync: (t) => {
1052
- e.dispatchSync(t), v(t);
1053
- },
1054
- subscribe: (t) => {
1055
- let n = c.subscribe((e) => t(e));
1056
- return s.add(n), _(), g &&= (u.next([{
1057
- ...se(),
1058
- version: e.context.clock.getVersion()
1059
- }]), !1), () => {
1060
- n.unsubscribe(), s.delete(n), _();
1061
- };
1062
- },
1063
- flushStreamBuffers: () => {
1064
- for (let e = 0; e < gt; e++) p.next();
1065
- },
1066
- destroy: () => {
1067
- Array.from(a).forEach((e) => e.unsubscribe()), Array.from(s).forEach((e) => e.unsubscribe()), a.clear(), s.clear(), c.complete(), d.complete(), f.complete(), p.complete();
1068
- }
1069
- });
1070
- }
1071
- //#endregion
1072
- export { xe as a, Te as c, be as d, G as f, Ce as i, Ee as l, mt as n, Se as o, ht as r, we as s, vt as t, Y as u };