@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
@@ -0,0 +1,1341 @@
1
+ import { Aa as e, Ao as t, Bo as n, C as r, Ca as i, D as a, Da as o, E as s, Ea as c, Fa as l, Go as u, Ja as d, Kn as f, Ma as p, Oa as m, Pa as h, Sa as g, T as _, Ta as v, Xa as ee, Xo as y, Ya as te, _ as ne, _a as b, a as re, aa as x, ao as ie, b as ae, ba as S, c as C, ca as w, da as T, dr as E, es as D, fa as O, fs as k, g as oe, ga as A, h as se, hr as ce, hs as le, i as ue, ia as j, jo as de, ka as M, l as fe, la as N, m as pe, ma as me, mr as he, ms as P, n as ge, ni as F, o as _e, oa as ve, pa as I, pn as ye, r as be, s as xe, sa as L, ss as R, ua as z, va as B, w as Se, wa as V, x as Ce, xa as H, ya as U } from "./loadValue-B3EFSe9k.js";
2
+ import { Observable as W, Subject as G, debounceTime as we, filter as Te, map as K, merge as Ee, race as De, startWith as Oe, switchMap as q, take as ke, timer as Ae } from "rxjs";
3
+ import { isEmpty as je } from "es-toolkit/compat";
4
+ import { isFunction as Me, isNil as J } from "es-toolkit";
5
+ //#region src/engine/history.ts
6
+ function Y({ notify: e, dispatch: t, getNextVersion: n }, r) {
7
+ 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 = () => ({
8
+ hasRedo: l(),
9
+ hasUndo: c()
10
+ }), f = (e, r) => {
11
+ s = !1, e[r](t, n), s = !0;
12
+ };
13
+ return Object.freeze({
14
+ get cursor() {
15
+ return a;
16
+ },
17
+ get size() {
18
+ return i.length;
19
+ },
20
+ hasUndo: c,
21
+ hasRedo: l,
22
+ push: (t) => {
23
+ 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()));
24
+ },
25
+ undo: () => {
26
+ if (!c()) return;
27
+ let t = i[a];
28
+ f(t, "undo"), a--, e(d());
29
+ },
30
+ redo: () => {
31
+ if (!l()) return;
32
+ let t = i[a + 1];
33
+ f(t, "redo"), a++, e(d());
34
+ },
35
+ clear: () => {
36
+ let t = i.length;
37
+ i = [], a = -1, t > 0 && e(d());
38
+ },
39
+ setLimit: u,
40
+ clone: (e) => Y(e, {
41
+ commands: [...i],
42
+ cursor: a,
43
+ limit: o
44
+ })
45
+ });
46
+ }
47
+ //#endregion
48
+ //#region src/engine/rx-operators/flushOnNotifier.ts
49
+ var Ne = (e) => (t) => t.pipe(q((t) => e.pipe(ke(1), K(() => t)))), Pe = (e, t = 200) => (n) => n.pipe(q((n) => De(Ae(t), e.pipe(ke(1))).pipe(K(() => n)))), Fe = (e) => {
50
+ let n = (e) => (n) => {
51
+ let r = Reflect.get(oe, n.type);
52
+ return !r || !t(e, r);
53
+ };
54
+ return (t) => new W((r) => t.subscribe({
55
+ next: (t) => {
56
+ r.next(t.filter(n(e())));
57
+ },
58
+ error: (e) => r.error(e),
59
+ complete: () => r.complete()
60
+ })).pipe(fe);
61
+ }, X = (e, r = []) => {
62
+ let i = n(ne), a = (e) => !J(e.tags) && r.some((n) => t(e.tags, n)) || !i(e.type);
63
+ return (t) => new W((n) => t.subscribe({
64
+ next: (t) => {
65
+ n.next(e() ? t.filter(a) : t);
66
+ },
67
+ error: (e) => n.error(e),
68
+ complete: () => n.complete()
69
+ })).pipe(fe);
70
+ }, Ie = {
71
+ [F.scrollTo]: u.viewScrollTo,
72
+ [F.streamScrollTo]: u.viewStreamScrollTo,
73
+ [F.changeZoomLevel]: u.viewChangeZoomLevel,
74
+ [F.streamZoomLevel]: u.viewStreamZoomLevel
75
+ }, Le = ({ tags: e }) => !J(e) && (t(e, d.shared) || t(e, d.following)), Re = (e) => {
76
+ let t = Ie[e.type];
77
+ return t && !Le(e) ? {
78
+ ...e,
79
+ type: t
80
+ } : e;
81
+ }, ze = (e) => (t) => new W((n) => t.subscribe({
82
+ next: (t) => {
83
+ n.next(e() ? t.map(Re) : t);
84
+ },
85
+ error: (e) => n.error(e),
86
+ complete: () => n.complete()
87
+ })), Be = (e, r = []) => {
88
+ let i = n(a), o = (e) => !J(e.tags) && r.some((n) => t(e.tags, n)) || !i(e.type);
89
+ return (t) => new W((n) => t.subscribe({
90
+ next: (t) => {
91
+ n.next(e() ? t.filter(o) : t);
92
+ },
93
+ error: (e) => n.error(e),
94
+ complete: () => n.complete()
95
+ })).pipe(fe);
96
+ }, Ve = 2048;
97
+ function He(e, { getReadonly: t = () => !1, getHistory: n, manualStreamFlush: i = !1, observable: a = !0 } = {}) {
98
+ let o = /* @__PURE__ */ new Set(), c = be(e, a), l = ge(c), u = {
99
+ notify: (e) => c.dispatch(f(e)),
100
+ dispatch: c.dispatchSync,
101
+ getNextVersion: () => e.clock.getNextVersion()
102
+ }, p = n?.(u) ?? Y(u);
103
+ p.setLimit(Ve);
104
+ let m = () => ie(c.state), h = new G(), g = h.pipe(ze(m)), v = new G(), ee = new G(), y = new G(), te = ee.pipe(Oe(void 0), q(() => v.pipe(_e(r, [
105
+ [
106
+ "@@move",
107
+ _,
108
+ d.drag
109
+ ],
110
+ ["@@scroll", s],
111
+ ["@@color", Se]
112
+ ], i ? Ne(y) : void 0)))), ne = new W((e) => c.subscribe((t) => e.next(t))).pipe(C(pe), Fe(() => c.state.settings.lockSettings), X(t, [d.shared]), we(200)), b = (...t) => {
113
+ let n = e.clock.getNextVersion();
114
+ return le(c.state, c.context, t).map((e) => (J(e.version) && (e.version = n), e));
115
+ }, x = (...e) => {
116
+ let t = b(e);
117
+ h.next(t);
118
+ }, ae = (...e) => {
119
+ queueMicrotask(() => x(e));
120
+ }, S = () => {
121
+ Array.from(o).forEach((e) => Me(e) ? e() : e.unsubscribe()), o.clear(), c.destroy(), l.destroy(), p.clear(), h.complete(), y.complete();
122
+ }, w = () => {
123
+ ee.next(), p.clear();
124
+ }, T = () => {
125
+ t() || m() || p.undo();
126
+ }, E = () => {
127
+ t() || m() || p.redo();
128
+ }, D = () => {
129
+ i && y.next();
130
+ };
131
+ return o.add(te.subscribe(ye(c, p))).add(g.pipe(C(se), re([d.changeOnly, d.shared]), X(t), Be(m)).subscribe(v)).add(g.pipe(X(t, [d.shared]), Be(m, [d.shared])).subscribe(c.dispatchSync)).add(c.subscribe((t) => {
132
+ t.forEach((t) => e.clock.merge(t.version));
133
+ })), Object.freeze({
134
+ ...c,
135
+ dispatch: ae,
136
+ dispatchSync: x,
137
+ destroy: S,
138
+ undo: T,
139
+ redo: E,
140
+ history: p,
141
+ resetHistory: w,
142
+ change$: ne,
143
+ flushStreamBuffers: D,
144
+ getReadonly: t
145
+ });
146
+ }
147
+ //#endregion
148
+ //#region src/utils/focus.ts
149
+ function Ue(e, t, n, r = null) {
150
+ if (!e || n !== e.tableId) return !1;
151
+ switch (t) {
152
+ case "tableName":
153
+ case "tableComment": return t === e.focusType;
154
+ }
155
+ return r === e.columnId && t === e.focusType;
156
+ }
157
+ var We = (e, t, n) => e?.tableId === t && e.selectColumnIds.includes(n);
158
+ function Ge(e, t, n, r = null) {
159
+ if (e?.tableId !== n) return !1;
160
+ switch (t) {
161
+ case de.tableName:
162
+ case de.tableComment: return t === e.focusType && e.edit;
163
+ }
164
+ return r === e.columnId && t === e.focusType && e.edit;
165
+ }
166
+ function Ke(e) {
167
+ let t = e.value.length;
168
+ e.selectionStart = t, e.selectionEnd = t, e.focus();
169
+ }
170
+ var qe = (e) => e ? {
171
+ tableId: e.tableId,
172
+ columnId: e.columnId,
173
+ focusType: e.focusType
174
+ } : null, Je = (e) => e ? JSON.stringify([
175
+ e.tableId,
176
+ e.columnId,
177
+ e.focusType
178
+ ]) : "", Z = "`";
179
+ function Ye(e) {
180
+ return `'${e.replace(/[\\']/g, "\\$&")}'`;
181
+ }
182
+ var Xe = "NOT ENFORCED RELY", Ze = B(D.Databricks), Qe = /* @__PURE__ */ new Set(["BIGINT", "LONG"]);
183
+ function $e(e) {
184
+ return t(e.options, y.autoIncrement) && Qe.has(e.dataType.trim().toUpperCase());
185
+ }
186
+ function et(e, t, { statements: n, written: r } = {}) {
187
+ let i = [], a = [], o = [""], { tables: s, relationships: c, indexes: l } = v(e, t);
188
+ return s.forEach((t) => {
189
+ r?.tables.push(t), tt(e, {
190
+ table: t,
191
+ buffer: o,
192
+ statements: n
193
+ }), o.push(""), nt(e, {
194
+ table: t,
195
+ buffer: o
196
+ });
197
+ }), c.forEach((t) => {
198
+ it(e, {
199
+ relationship: t,
200
+ buffer: o,
201
+ fkNames: i,
202
+ statements: n
203
+ }) && o.push("");
204
+ }), l.forEach((t) => {
205
+ at(e, {
206
+ index: t,
207
+ buffer: o,
208
+ indexNames: a
209
+ }), o.push("");
210
+ }), o.join("\n");
211
+ }
212
+ function tt(e, { buffer: n, table: r, statements: i }) {
213
+ let { collections: a } = e, o = k(a).collection("tableColumnEntities").selectByIds(r.columnIds);
214
+ n.push(`CREATE TABLE${I(i)} ${Z}${r.name}${Z}`), n.push("(");
215
+ let s = A(o), c = z(o);
216
+ if (o.forEach((t, r) => {
217
+ rt(e, {
218
+ column: t,
219
+ isComma: s || o.length !== r + 1,
220
+ spaceSize: c,
221
+ buffer: n
222
+ });
223
+ }), s) {
224
+ let e = b(o);
225
+ n.push(` CONSTRAINT ${Z}PK_${r.name}${Z} PRIMARY KEY (${w(e, Z)}) ${Xe}`);
226
+ }
227
+ n.push(")"), r.comment.trim() === "" ? n.push("USING DELTA;") : (n.push("USING DELTA"), n.push(`COMMENT ${Ye(r.comment)};`));
228
+ let l = o.filter((e) => t(e.options, y.autoIncrement) && !$e(e));
229
+ l.length !== 0 && (n.push(""), l.forEach((e) => {
230
+ n.push(`-- Databricks takes IDENTITY only on BIGINT, so ${Z}${r.name}${Z}.${Z}${e.name}${Z} is written without it.`);
231
+ }));
232
+ }
233
+ function nt({ collections: e }, { buffer: t, table: n }) {
234
+ let r = k(e).collection("tableColumnEntities").selectByIds(n.columnIds);
235
+ m(r).forEach((e) => {
236
+ t.push(`-- Databricks does not support UNIQUE constraints: ${Z}${n.name}${Z}.${Z}${e.name}${Z}`), t.push("");
237
+ });
238
+ }
239
+ function rt(e, { buffer: n, column: r, isComma: i, spaceSize: a }) {
240
+ let o = [];
241
+ o.push(` ${Z}${r.name}${Z}` + T(a.name - r.name.length)), o.push(`${r.dataType}` + T(a.dataType - r.dataType.length));
242
+ let s = t(r.options, y.notNull) || t(r.options, y.primaryKey);
243
+ o.push(s ? "NOT NULL" : " "), $e(r) ? o.push("GENERATED ALWAYS AS IDENTITY") : !t(r.options, y.autoIncrement) && r.default.trim() !== "" && o.push(`DEFAULT ${r.default}`), r.comment.trim() !== "" && o.push(`COMMENT ${Ye(r.comment)}`), n.push(o.join(" ").trimEnd() + `${i ? "," : ""}`);
244
+ }
245
+ function it(e, { buffer: t, relationship: n, fkNames: r, statements: a }) {
246
+ let o = i(e, n);
247
+ if (!o) return !1;
248
+ let { startTable: s, endTable: c } = o, l = `FK_${s.name}_TO_${c.name}`;
249
+ l = j(r, "", l), r.push({
250
+ id: P(),
251
+ name: l
252
+ });
253
+ let u = `ALTER TABLE ${Z}${c.name}${Z}`;
254
+ return a === p.ifNotExists && t.push(`${u} DROP CONSTRAINT IF EXISTS ${Z}${l}${Z};`), t.push(u), t.push(` ADD CONSTRAINT ${Z}${l}${Z}`), t.push(` FOREIGN KEY (${w(o.end, Z)})`), t.push([
255
+ ` REFERENCES ${Z}${s.name}${Z} (${w(o.start, Z)})`,
256
+ ...N(n, Ze),
257
+ `${Xe};`
258
+ ].join(" ")), !0;
259
+ }
260
+ function at({ collections: e }, { buffer: t, index: n, indexNames: r }) {
261
+ let i = k(e).collection("tableEntities").selectById(n.tableId);
262
+ if (!i) return;
263
+ let a = U(e, i, n).map(({ indexColumn: e, column: t }) => ({ name: `${Z}${t.name}${Z} ${V(e.orderType)}` }));
264
+ if (a.length === 0) return;
265
+ let o = n.name;
266
+ n.name.trim() === "" && (o = `IDX_${i.name}`, o = j(r, "", o), r.push({
267
+ id: P(),
268
+ name: o
269
+ })), t.push(`-- Databricks has no secondary indexes. ${Z}${o}${Z} on ${Z}${i.name}${Z} (${w(a)})`), t.push(`-- ALTER TABLE ${Z}${i.name}${Z} CLUSTER BY (${w(U(e, i, n).map(({ column: e }) => e), Z)});`);
270
+ }
271
+ function ot(t, n, r) {
272
+ let i = `${Z}${r}${Z}`, a = `USE SCHEMA ${i};`;
273
+ return n === e.createAndUse ? `CREATE SCHEMA IF NOT EXISTS ${i};\n${a}` : a;
274
+ }
275
+ function st(e, { tables: t }) {
276
+ return t.map(({ name: e }) => `DROP TABLE IF EXISTS ${Z}${e}${Z};`).join("\n");
277
+ }
278
+ //#endregion
279
+ //#region src/utils/schema-sql/MySQL.ts
280
+ var ct = B(D.MySQL), lt = "SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;", ut = "SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;";
281
+ function dt(e, t, { statements: n, written: r } = {}) {
282
+ if (n === p.ifNotExists) return ft(e, t, r);
283
+ let i = [], a = [], o = [""], { tables: s, relationships: c, indexes: l } = v(e, t);
284
+ return s.forEach((t) => {
285
+ r?.tables.push(t), pt(e, {
286
+ table: t,
287
+ buffer: o
288
+ }), o.push(""), gt(e, {
289
+ table: t,
290
+ buffer: o
291
+ });
292
+ }), c.forEach((t) => {
293
+ yt(e, {
294
+ relationship: t,
295
+ buffer: o,
296
+ fkNames: i
297
+ }) && o.push("");
298
+ }), l.forEach((t) => {
299
+ xt(e, {
300
+ index: t,
301
+ buffer: o,
302
+ indexNames: a
303
+ }), o.push("");
304
+ }), o.join("\n");
305
+ }
306
+ function ft(e, t, n) {
307
+ let { settings: { bracketType: r }, collections: i } = e, { tables: a, relationships: o, indexes: s } = v(e, t);
308
+ if (a.length === 0) return "";
309
+ let c = [], l = /* @__PURE__ */ new Map();
310
+ o.forEach((t) => {
311
+ let n = vt(e, t, c);
312
+ if (!n) return;
313
+ let [r, ...i] = n.lines, a = l.get(n.table.id) ?? [];
314
+ a.push([` ${r}`, ...i]), l.set(n.table.id, a);
315
+ });
316
+ let u = [], d = /* @__PURE__ */ new Map();
317
+ s.forEach((t) => {
318
+ let n = bt(e, t, u);
319
+ if (!n) return;
320
+ let r = d.get(n.table.id) ?? [];
321
+ r.push([` ${t.unique ? "UNIQUE " : ""}INDEX ${n.name} (${n.columns})`]), d.set(n.table.id, r);
322
+ });
323
+ let f = [
324
+ "",
325
+ lt,
326
+ ""
327
+ ];
328
+ return a.forEach((t) => {
329
+ n?.tables.push(t);
330
+ let a = k(i).collection("tableColumnEntities").selectByIds(t.columnIds);
331
+ mt(e, f, t, p.ifNotExists, [
332
+ ...m(a).map((e) => [` ${ht(r, t, e)}`]),
333
+ ...d.get(t.id) ?? [],
334
+ ...l.get(t.id) ?? []
335
+ ]), f.push("");
336
+ }), f.push(ut, ""), f.join("\n");
337
+ }
338
+ function pt(e, { buffer: t, table: n, statements: r }) {
339
+ mt(e, t, n, r, []);
340
+ }
341
+ function mt(e, t, n, r, i) {
342
+ let { settings: { bracketType: a }, collections: o } = e, s = O(a), l = k(o).collection("tableColumnEntities").selectByIds(n.columnIds);
343
+ t.push(`CREATE TABLE${I(r)} ${s}${n.name}${s}`), t.push("(");
344
+ let u = A(l), d = z(l), f = i.length !== 0;
345
+ if (l.forEach((n, r) => {
346
+ _t(e, {
347
+ column: n,
348
+ isComma: u || f || l.length !== r + 1,
349
+ spaceSize: d,
350
+ buffer: t
351
+ });
352
+ }), u) {
353
+ let e = b(l);
354
+ t.push(` PRIMARY KEY (${w(e, s)})${f ? "," : ""}`);
355
+ }
356
+ i.forEach((e, n) => {
357
+ t.push(...e), n !== i.length - 1 && (t[t.length - 1] += ",");
358
+ }), n.comment.trim() === "" ? t.push(");") : t.push(`) COMMENT ${c(n.comment)};`);
359
+ }
360
+ function ht(e, t, n) {
361
+ let r = O(e);
362
+ return `CONSTRAINT ${r}UQ_${g(t.name, e)}_${n.name}${r} UNIQUE (${r}${n.name}${r})`;
363
+ }
364
+ function gt({ settings: { bracketType: e }, collections: t }, { buffer: n, table: r }) {
365
+ let i = O(e), a = k(t).collection("tableColumnEntities").selectByIds(r.columnIds);
366
+ o(a) && m(a).forEach((t) => {
367
+ n.push(`ALTER TABLE ${i}${r.name}${i}`), n.push(` ADD ${ht(e, r, t)};`), n.push("");
368
+ });
369
+ }
370
+ function _t({ settings: { bracketType: e } }, { buffer: n, column: r, isComma: i, spaceSize: a }) {
371
+ let o = O(e), s = [];
372
+ s.push(` ${o}${r.name}${o}` + T(a.name - r.name.length)), s.push(`${r.dataType}` + T(a.dataType - r.dataType.length)), s.push(`${t(r.options, y.notNull) ? "NOT NULL" : "NULL "}`), t(r.options, y.autoIncrement) ? s.push("AUTO_INCREMENT") : r.default.trim() !== "" && s.push(`DEFAULT ${L(r.default, D.MySQL, r.dataType)}`), r.comment.trim() !== "" && s.push(`COMMENT ${c(r.comment)}`), n.push(s.join(" ") + `${i ? "," : ""}`);
373
+ }
374
+ function vt(e, t, n) {
375
+ let { settings: { bracketType: r } } = e, a = i(e, t);
376
+ if (!a) return null;
377
+ let { startTable: o, endTable: s } = a, c = O(r), l = g(o.name, r), u = g(s.name, r), d = x(n, `FK_${l}_TO_${u}`);
378
+ return n.push({
379
+ id: P(),
380
+ name: d
381
+ }), {
382
+ table: s,
383
+ lines: [
384
+ `CONSTRAINT ${c}${d}${c}`,
385
+ ` FOREIGN KEY (${w(a.end, c)})`,
386
+ ` REFERENCES ${c}${o.name}${c} (${w(a.start, c)})`,
387
+ ...N(t, ct).map((e) => ` ${e}`)
388
+ ]
389
+ };
390
+ }
391
+ function yt(e, { buffer: t, relationship: n, fkNames: r }) {
392
+ let i = vt(e, n, r);
393
+ if (!i) return !1;
394
+ let a = O(e.settings.bracketType), [o, ...s] = i.lines;
395
+ return t.push(`ALTER TABLE ${a}${i.table.name}${a}`, ` ADD ${o}`, ...s), t[t.length - 1] += ";", !0;
396
+ }
397
+ function bt({ settings: { bracketType: e }, collections: t }, n, r) {
398
+ let i = O(e), a = k(t).collection("tableEntities").selectById(n.tableId);
399
+ if (!a) return null;
400
+ let o = U(t, a, n).map(({ indexColumn: e, column: t }) => ({ name: `${i}${t.name}${i} ${V(e.orderType)}` }));
401
+ if (o.length === 0) return null;
402
+ let s = n.name;
403
+ if (n.name.trim() === "") {
404
+ let t = g(a.name, e);
405
+ s = x(r, `IDX_${t}`), r.push({
406
+ id: P(),
407
+ name: s
408
+ });
409
+ }
410
+ return {
411
+ table: a,
412
+ name: `${i}${s}${i}`,
413
+ columns: w(o)
414
+ };
415
+ }
416
+ function xt(e, { buffer: t, index: n, indexNames: r }) {
417
+ let i = bt(e, n, r);
418
+ if (!i) return;
419
+ let a = O(e.settings.bracketType);
420
+ t.push(`CREATE ${n.unique ? "UNIQUE " : ""}INDEX ${i.name}`), t.push(` ON ${a}${i.table.name}${a} (${i.columns});`);
421
+ }
422
+ function St({ settings: { bracketType: t } }, n, r) {
423
+ let i = O(t), a = `${i}${r}${i}`, o = `USE ${a};`;
424
+ return n === e.createAndUse ? `CREATE DATABASE IF NOT EXISTS ${a};\n${o}` : o;
425
+ }
426
+ function Ct({ settings: { bracketType: e } }, { tables: t }) {
427
+ if (t.length === 0) return "";
428
+ let n = O(e);
429
+ return [
430
+ lt,
431
+ t.map((e) => `DROP TABLE IF EXISTS ${n}${e.name}${n};`).join("\n"),
432
+ ut
433
+ ].join("\n\n");
434
+ }
435
+ //#endregion
436
+ //#region src/utils/schema-sql/MariaDB.ts
437
+ var wt = B(D.MariaDB);
438
+ function Tt(e, t, { statements: n, written: r } = {}) {
439
+ let i = [], a = [], o = [""], { tables: s, relationships: c, indexes: l } = v(e, t);
440
+ return s.forEach((t) => {
441
+ r?.tables.push(t), Et(e, {
442
+ table: t,
443
+ buffer: o,
444
+ statements: n
445
+ }), o.push(""), Dt(e, {
446
+ table: t,
447
+ buffer: o,
448
+ statements: n
449
+ });
450
+ }), c.forEach((t) => {
451
+ kt(e, {
452
+ relationship: t,
453
+ buffer: o,
454
+ fkNames: i,
455
+ statements: n
456
+ }) && o.push("");
457
+ }), l.forEach((t) => {
458
+ At(e, {
459
+ index: t,
460
+ buffer: o,
461
+ indexNames: a,
462
+ statements: n
463
+ }), o.push("");
464
+ }), o.join("\n");
465
+ }
466
+ function Et(e, { buffer: t, table: n, statements: r }) {
467
+ let { settings: { bracketType: i }, collections: a } = e, o = O(i), s = k(a).collection("tableColumnEntities").selectByIds(n.columnIds);
468
+ t.push(`CREATE TABLE${I(r)} ${o}${n.name}${o}`), t.push("(");
469
+ let l = A(s), u = z(s);
470
+ if (s.forEach((n, r) => {
471
+ l ? Ot(e, {
472
+ column: n,
473
+ isComma: !0,
474
+ spaceSize: u,
475
+ buffer: t
476
+ }) : Ot(e, {
477
+ column: n,
478
+ isComma: s.length !== r + 1,
479
+ spaceSize: u,
480
+ buffer: t
481
+ });
482
+ }), l) {
483
+ let e = b(s);
484
+ t.push(` PRIMARY KEY (${w(e, o)})`);
485
+ }
486
+ n.comment.trim() === "" ? t.push(");") : t.push(`) COMMENT ${c(n.comment)};`);
487
+ }
488
+ function Dt({ settings: { bracketType: e }, collections: t }, { buffer: n, table: r, statements: i }) {
489
+ let a = O(e), s = k(t).collection("tableColumnEntities").selectByIds(r.columnIds);
490
+ o(s) && m(s).forEach((t) => {
491
+ n.push(`ALTER TABLE ${a}${r.name}${a}`), n.push(` ADD CONSTRAINT ${a}UQ_${g(r.name, e)}_${t.name}${a} UNIQUE${I(i)} (${a}${t.name}${a});`), n.push("");
492
+ });
493
+ }
494
+ function Ot({ settings: { bracketType: e } }, { buffer: n, column: r, isComma: i, spaceSize: a }) {
495
+ let o = O(e), s = [];
496
+ s.push(` ${o}${r.name}${o}` + T(a.name - r.name.length)), s.push(`${r.dataType}` + T(a.dataType - r.dataType.length)), s.push(`${t(r.options, y.notNull) ? "NOT NULL" : "NULL "}`), t(r.options, y.autoIncrement) ? s.push("AUTO_INCREMENT") : r.default.trim() !== "" && s.push(`DEFAULT ${L(r.default, D.MariaDB)}`), r.comment.trim() !== "" && s.push(`COMMENT ${c(r.comment)}`), n.push(s.join(" ") + `${i ? "," : ""}`);
497
+ }
498
+ function kt(e, { buffer: t, relationship: n, fkNames: r, statements: a }) {
499
+ let { settings: { bracketType: o } } = e, s = i(e, n);
500
+ if (!s) return !1;
501
+ let { startTable: c, endTable: l } = s, u = O(o);
502
+ t.push(`ALTER TABLE ${u}${l.name}${u}`);
503
+ let d = g(c.name, o), f = g(l.name, o), p = x(r, `FK_${d}_TO_${f}`);
504
+ return r.push({
505
+ id: P(),
506
+ name: p
507
+ }), t.push(` ADD CONSTRAINT ${u}${p}${u}`), t.push(` FOREIGN KEY${I(a)} (${w(s.end, u)})`), t.push(` REFERENCES ${u}${c.name}${u} (${w(s.start, u)})`, ...N(n, wt).map((e) => ` ${e}`)), t[t.length - 1] += ";", !0;
508
+ }
509
+ function At({ settings: { bracketType: e }, collections: t }, { buffer: n, index: r, indexNames: i, statements: a }) {
510
+ let o = O(e), s = k(t).collection("tableEntities").selectById(r.tableId);
511
+ if (!s) return;
512
+ let c = U(t, s, r).map(({ indexColumn: e, column: t }) => ({ name: `${o}${t.name}${o} ${V(e.orderType)}` }));
513
+ if (c.length !== 0) {
514
+ let t = r.name;
515
+ if (r.name.trim() === "") {
516
+ let n = g(s.name, e);
517
+ t = x(i, `IDX_${n}`), i.push({
518
+ id: P(),
519
+ name: t
520
+ });
521
+ }
522
+ n.push(`CREATE ${r.unique ? "UNIQUE " : ""}INDEX${I(a)} ${o}${t}${o}`), n.push(` ON ${o}${s.name}${o} (${w(c)});`);
523
+ }
524
+ }
525
+ //#endregion
526
+ //#region src/utils/schema-sql/MSSQL.ts
527
+ var jt = B(D.MSSQL), Mt = "dbo";
528
+ function Nt(e, t, { written: n } = {}) {
529
+ let r = [], i = [], a = [""], { tables: o, relationships: s, indexes: c } = v(e, t);
530
+ return o.forEach((t) => {
531
+ n?.tables.push(t), Pt(e, {
532
+ table: t,
533
+ buffer: a
534
+ }), a.push(""), Ft(e, {
535
+ table: t,
536
+ buffer: a
537
+ }), Vt(e, {
538
+ table: t,
539
+ buffer: a
540
+ });
541
+ }), s.forEach((t) => {
542
+ Ht(e, {
543
+ relationship: t,
544
+ buffer: a,
545
+ fkNames: r
546
+ }) && a.push("");
547
+ }), c.forEach((t) => {
548
+ Ut(e, {
549
+ index: t,
550
+ buffer: a,
551
+ indexNames: i
552
+ }), a.push("");
553
+ }), a.join("\n");
554
+ }
555
+ function Pt(e, { buffer: t, table: n }) {
556
+ let { settings: { bracketType: r }, collections: i } = e, a = O(r), o = k(i).collection("tableColumnEntities").selectByIds(n.columnIds);
557
+ t.push(`CREATE TABLE ${a}${n.name}${a}`), t.push("(");
558
+ let s = A(o), c = z(o);
559
+ if (o.forEach((n, r) => {
560
+ s ? It(e, {
561
+ column: n,
562
+ isComma: !0,
563
+ spaceSize: c,
564
+ buffer: t
565
+ }) : It(e, {
566
+ column: n,
567
+ isComma: o.length !== r + 1,
568
+ spaceSize: c,
569
+ buffer: t
570
+ });
571
+ }), s) {
572
+ let e = b(o), i = `PK_${g(n.name, r)}`;
573
+ t.push(` CONSTRAINT ${a}${i}${a} PRIMARY KEY (${w(e, a)})`);
574
+ }
575
+ t.push(")\nGO");
576
+ }
577
+ function Ft({ settings: { bracketType: e }, collections: t }, { buffer: n, table: r }) {
578
+ let i = O(e), a = k(t).collection("tableColumnEntities").selectByIds(r.columnIds);
579
+ o(a) && m(a).forEach((t) => {
580
+ n.push(`ALTER TABLE ${i}${r.name}${i}`), n.push(` ADD CONSTRAINT ${i}UQ_${g(r.name, e)}_${t.name}${i} UNIQUE (${i}${t.name}${i})\nGO`), n.push("");
581
+ });
582
+ }
583
+ function It({ settings: { bracketType: e } }, { buffer: n, column: r, isComma: i, spaceSize: a }) {
584
+ let o = O(e), s = [];
585
+ s.push(` ${o}${r.name}${o}` + T(a.name - r.name.length)), s.push(`${r.dataType}` + T(a.dataType - r.dataType.length)), t(r.options, y.notNull) && s.push("NOT NULL"), t(r.options, y.autoIncrement) ? s.push("IDENTITY(1,1)") : r.default.trim() !== "" && s.push(`DEFAULT ${r.default}`), n.push(s.join(" ") + `${i ? "," : ""}`);
586
+ }
587
+ var Lt = /^[\p{L}_@#][\p{L}\p{N}_@#$]*$/u;
588
+ function Rt(e) {
589
+ return me(e) || Lt.test(e);
590
+ }
591
+ function zt(e, t) {
592
+ if (t) return "";
593
+ let [, , n = ""] = S(e).reverse();
594
+ return Rt(n) ? `${n}.` : "";
595
+ }
596
+ function Bt(e, t) {
597
+ let [n, r = ""] = t ? [e] : S(e).reverse(), i = M(r) || Mt, a = t ? n : M(n);
598
+ return {
599
+ procedure: `${zt(e, t)}sys.sp_addextendedproperty`,
600
+ levels: `'schema', ${c(i)}, 'table', ${c(a)}`
601
+ };
602
+ }
603
+ function Vt({ settings: { bracketType: e }, collections: t }, { table: n, buffer: r }) {
604
+ let { procedure: i, levels: a } = Bt(n.name, O(e));
605
+ n.comment.trim() !== "" && (r.push(`EXECUTE ${i} 'MS_Description',`), r.push(` ${c(n.comment)}, ${a}\nGO`), r.push("")), k(t).collection("tableColumnEntities").selectByIds(n.columnIds).forEach((e) => {
606
+ e.comment.trim() !== "" && (r.push(`EXECUTE ${i} 'MS_Description',`), r.push(` ${c(e.comment)}, ${a}, 'column', ${c(e.name)}\nGO`), r.push(""));
607
+ });
608
+ }
609
+ function Ht(e, { buffer: t, relationship: n, fkNames: r }) {
610
+ let { settings: { bracketType: a } } = e, o = i(e, n);
611
+ if (!o) return !1;
612
+ let { startTable: s, endTable: c } = o, l = O(a);
613
+ t.push(`ALTER TABLE ${l}${c.name}${l}`);
614
+ let u = g(s.name, a), d = g(c.name, a), f = x(r, `FK_${u}_TO_${d}`);
615
+ return r.push({
616
+ id: P(),
617
+ name: f
618
+ }), t.push(` ADD CONSTRAINT ${l}${f}${l}`), t.push(` FOREIGN KEY (${w(o.end, l)})`), t.push(` REFERENCES ${l}${s.name}${l} (${w(o.start, l)})`, ...N(n, jt).map((e) => ` ${e}`)), t[t.length - 1] += "\nGO", !0;
619
+ }
620
+ function Ut({ settings: { bracketType: e }, collections: t }, { buffer: n, index: r, indexNames: i }) {
621
+ let a = O(e), o = k(t).collection("tableEntities").selectById(r.tableId);
622
+ if (!o) return;
623
+ let s = U(t, o, r).map(({ indexColumn: e, column: t }) => ({ name: `${a}${t.name}${a} ${V(e.orderType)}` }));
624
+ if (s.length !== 0) {
625
+ let t = r.name;
626
+ if (r.name.trim() === "") {
627
+ let n = g(o.name, e);
628
+ t = x(i, `IDX_${n}`), i.push({
629
+ id: P(),
630
+ name: t
631
+ });
632
+ }
633
+ r.unique ? n.push(`CREATE UNIQUE INDEX ${a}${t}${a}`) : n.push(`CREATE INDEX ${a}${t}${a}`), n.push(` ON ${a}${o.name}${a} (${w(s)})\nGO`);
634
+ }
635
+ }
636
+ function Wt({ settings: { bracketType: t } }, n, r) {
637
+ let i = O(t), a = `${i}${r}${i}`, o = `USE ${a}\nGO`;
638
+ return n === e.createAndUse ? `IF DB_ID(N${c(r)}) IS NULL\n CREATE DATABASE ${a}\nGO\n\n${o}` : o;
639
+ }
640
+ function Gt({ settings: { bracketType: e } }, { tables: t }) {
641
+ if (t.length === 0) return "";
642
+ let n = O(e), r = (e) => `${n}${e}${n}`;
643
+ return [
644
+ "BEGIN TRY",
645
+ " BEGIN TRANSACTION",
646
+ "",
647
+ " DECLARE @sql NVARCHAR(MAX) = N''",
648
+ ...t.flatMap(({ name: e }) => {
649
+ let t = zt(e, n), i = `OBJECT_ID(N${c(r(e))}, N'U')`, a = [
650
+ `SELECT @sql += N${c(`ALTER TABLE ${r(e)} DROP CONSTRAINT `)} + QUOTENAME(name) + N';'`,
651
+ ` FROM ${t}sys.foreign_keys`,
652
+ ` WHERE parent_object_id = ${i}`
653
+ ];
654
+ return t ? [` IF ${i} IS NOT NULL`, ...a.map((e) => ` ${e}`)] : a.map((e) => ` ${e}`);
655
+ }),
656
+ " EXECUTE sp_executesql @sql",
657
+ "",
658
+ ` DROP TABLE IF EXISTS ${t.map(({ name: e }) => r(e)).join(", ")}`,
659
+ "",
660
+ " COMMIT TRANSACTION",
661
+ "END TRY",
662
+ "BEGIN CATCH",
663
+ " IF @@TRANCOUNT > 0 ROLLBACK TRANSACTION;",
664
+ " THROW;",
665
+ "END CATCH",
666
+ "GO"
667
+ ].join("\n");
668
+ }
669
+ //#endregion
670
+ //#region src/utils/schema-sql/Oracle.ts
671
+ var Kt = B(D.Oracle);
672
+ function qt(e, n, { written: r } = {}) {
673
+ let { settings: { bracketType: i }, collections: a } = e, o = [], s = [], c = [], l = [], u = [""], { tables: d, relationships: f, indexes: p } = v(e, n);
674
+ return d.forEach((n) => {
675
+ r?.tables.push(n), Jt(e, {
676
+ table: n,
677
+ buffer: u,
678
+ written: r
679
+ }), u.push(""), Yt(e, {
680
+ table: n,
681
+ buffer: u,
682
+ written: r
683
+ });
684
+ let o = k(a).collection("tableColumnEntities").selectByIds(n.columnIds), [l] = H(n.name, i), d = g(n.name, i), f = l === "" ? "" : `${l}.`;
685
+ o.forEach((e) => {
686
+ if (t(e.options, y.autoIncrement)) {
687
+ let t = j(s, "", `SEQ_${d}`);
688
+ s.push({
689
+ id: P(),
690
+ name: t
691
+ });
692
+ let i = `${f}${t}`;
693
+ r?.sequences.push(i), r?.identifiers.push(t), u.push(`CREATE SEQUENCE ${i}`), u.push("START WITH 1"), u.push("INCREMENT BY 1;"), u.push("");
694
+ let a = j(s, "", `SEQ_TRG_${d}`);
695
+ c.push({
696
+ id: P(),
697
+ name: a
698
+ }), r?.identifiers.push(a), u.push(`CREATE OR REPLACE TRIGGER ${f}${a}`), u.push(`BEFORE INSERT ON ${n.name}`), u.push("REFERENCING NEW AS NEW FOR EACH ROW"), u.push("BEGIN"), u.push(` SELECT ${i}.NEXTVAL`), u.push(` INTO :NEW.${e.name}`), u.push(" FROM DUAL;"), u.push("END;"), u.push("/"), u.push("");
699
+ }
700
+ }), Zt(e, {
701
+ table: n,
702
+ buffer: u
703
+ });
704
+ }), f.forEach((t) => {
705
+ Qt(e, {
706
+ relationship: t,
707
+ buffer: u,
708
+ fkNames: o,
709
+ written: r
710
+ }) && u.push("");
711
+ }), p.forEach((t) => {
712
+ $t(e, {
713
+ index: t,
714
+ buffer: u,
715
+ indexNames: l,
716
+ written: r
717
+ }), u.push("");
718
+ }), u.join("\n");
719
+ }
720
+ function Jt(e, { buffer: t, table: n, written: r }) {
721
+ let { settings: { bracketType: i }, collections: a } = e, o = O(i), s = k(a).collection("tableColumnEntities").selectByIds(n.columnIds);
722
+ if (r) {
723
+ let [e, t] = H(n.name, i);
724
+ e !== "" && r.identifiers.push(M(e)), r.identifiers.push(M(t)), r.identifiers.push(...s.map((e) => e.name));
725
+ }
726
+ t.push(`CREATE TABLE ${o}${n.name}${o}`), t.push("(");
727
+ let c = A(s), l = z(s);
728
+ if (s.forEach((n, r) => {
729
+ c ? Xt(e, {
730
+ column: n,
731
+ isComma: !0,
732
+ spaceSize: l,
733
+ buffer: t
734
+ }) : Xt(e, {
735
+ column: n,
736
+ isComma: s.length !== r + 1,
737
+ spaceSize: l,
738
+ buffer: t
739
+ });
740
+ }), c) {
741
+ let e = b(s), a = `PK_${g(n.name, i)}`;
742
+ r?.identifiers.push(a), t.push(` CONSTRAINT ${o}${a}${o} PRIMARY KEY (${w(e, o)})`);
743
+ }
744
+ t.push(");");
745
+ }
746
+ function Yt({ settings: { bracketType: e }, collections: t }, { buffer: n, table: r, written: i }) {
747
+ let a = O(e), s = k(t).collection("tableColumnEntities").selectByIds(r.columnIds);
748
+ o(s) && m(s).forEach((t) => {
749
+ let o = `UQ_${g(r.name, e)}_${t.name}`;
750
+ i?.identifiers.push(o), n.push(`ALTER TABLE ${a}${r.name}${a}`), n.push(` ADD CONSTRAINT ${a}${o}${a} UNIQUE (${a}${t.name}${a});`), n.push("");
751
+ });
752
+ }
753
+ function Xt({ settings: { bracketType: e } }, { buffer: n, column: r, isComma: i, spaceSize: a }) {
754
+ let o = O(e), s = [];
755
+ s.push(` ${o}${r.name}${o}` + T(a.name - r.name.length)), s.push(`${r.dataType}` + T(a.dataType - r.dataType.length)), r.default.trim() !== "" && s.push(`DEFAULT ${r.default}`), t(r.options, y.notNull) && s.push("NOT NULL"), n.push(s.join(" ") + `${i ? "," : ""}`);
756
+ }
757
+ function Zt({ settings: { bracketType: e }, collections: t }, { table: n, buffer: r }) {
758
+ let i = O(e);
759
+ n.comment.trim() !== "" && (r.push(`COMMENT ON TABLE ${i}${n.name}${i} IS ${c(n.comment)};`), r.push("")), k(t).collection("tableColumnEntities").selectByIds(n.columnIds).forEach((e) => {
760
+ e.comment.trim() !== "" && (r.push(`COMMENT ON COLUMN ${i}${n.name}${i}.${i}${e.name}${i} IS ${c(e.comment)};`), r.push(""));
761
+ });
762
+ }
763
+ function Qt(e, { buffer: t, relationship: n, fkNames: r, written: a }) {
764
+ let { settings: { bracketType: o } } = e, s = i(e, n);
765
+ if (!s) return !1;
766
+ let { startTable: c, endTable: l } = s, u = O(o);
767
+ t.push(`ALTER TABLE ${u}${l.name}${u}`);
768
+ let d = g(c.name, o), f = g(l.name, o), p = x(r, `FK_${d}_TO_${f}`);
769
+ return r.push({
770
+ id: P(),
771
+ name: p
772
+ }), a?.identifiers.push(p), t.push(` ADD CONSTRAINT ${u}${p}${u}`), t.push(` FOREIGN KEY (${w(s.end, u)})`), t.push(` REFERENCES ${u}${c.name}${u} (${w(s.start, u)})`, ...N(n, Kt).map((e) => ` ${e}`)), t[t.length - 1] += ";", !0;
773
+ }
774
+ function $t({ settings: { bracketType: e }, collections: t }, { buffer: n, index: r, indexNames: i, written: a }) {
775
+ let o = O(e), s = k(t).collection("tableEntities").selectById(r.tableId);
776
+ if (!s) return;
777
+ let c = U(t, s, r).map(({ indexColumn: e, column: t }) => ({ name: `${o}${t.name}${o} ${V(e.orderType)}` }));
778
+ if (c.length !== 0) {
779
+ let [t] = H(s.name, e), l = r.name;
780
+ if (r.name.trim() === "") {
781
+ let t = g(s.name, e);
782
+ l = x(i, `IDX_${t}`), i.push({
783
+ id: P(),
784
+ name: l
785
+ });
786
+ }
787
+ let u = `${t === "" || l.includes(".") ? "" : `${t}.`}${o}${l}${o}`;
788
+ a?.identifiers.push(l.slice(l.lastIndexOf(".") + 1)), r.unique ? n.push(`CREATE UNIQUE INDEX ${u}`) : n.push(`CREATE INDEX ${u}`), n.push(` ON ${o}${s.name}${o} (${w(c)});`);
789
+ }
790
+ }
791
+ function en(e, t) {
792
+ let n = ve();
793
+ qt(e, t, { written: n });
794
+ let r = new TextEncoder();
795
+ return [...new Set(n.identifiers)].filter((e) => r.encode(e).length > 30);
796
+ }
797
+ function tn({ settings: { bracketType: t } }, n, r) {
798
+ if (n !== e.use) return "";
799
+ let i = O(t);
800
+ return `ALTER SESSION SET CURRENT_SCHEMA = ${i}${r}${i};`;
801
+ }
802
+ function nn(e, t) {
803
+ return [
804
+ "BEGIN",
805
+ ` EXECUTE IMMEDIATE ${c(e)};`,
806
+ "EXCEPTION WHEN OTHERS THEN",
807
+ ` IF SQLCODE != ${t} THEN RAISE; END IF;`,
808
+ "END;",
809
+ "/"
810
+ ].join("\n");
811
+ }
812
+ function rn({ settings: { bracketType: e } }, { tables: t, sequences: n }) {
813
+ if (t.length === 0) return "";
814
+ let r = O(e);
815
+ return [...t.map(({ name: e }) => nn(`DROP TABLE ${r}${e}${r} CASCADE CONSTRAINTS`, -942)), ...n.map((e) => nn(`DROP SEQUENCE ${e}`, -2289))].join("\n\n");
816
+ }
817
+ //#endregion
818
+ //#region src/utils/schema-sql/PostgreSQL.ts
819
+ var an = B(D.PostgreSQL), on = /* @__PURE__ */ new Set([
820
+ "INT",
821
+ "INTEGER",
822
+ "BIGINT",
823
+ "SMALLINT",
824
+ "INT2",
825
+ "INT4",
826
+ "INT8"
827
+ ]);
828
+ function sn(e) {
829
+ return t(e.options, y.autoIncrement) && on.has(e.dataType.trim().toUpperCase());
830
+ }
831
+ function cn(e, t, { statements: n, written: r } = {}) {
832
+ let i = [], a = [], o = [""], { tables: s, relationships: c, indexes: l } = v(e, t);
833
+ return s.forEach((t) => {
834
+ r?.tables.push(t), ln(e, {
835
+ table: t,
836
+ buffer: o,
837
+ statements: n
838
+ }), o.push(""), dn(e, {
839
+ table: t,
840
+ buffer: o
841
+ });
842
+ }), c.forEach((t) => {
843
+ fn(e, {
844
+ relationship: t,
845
+ buffer: o,
846
+ fkNames: i,
847
+ statements: n
848
+ }) && o.push("");
849
+ }), l.forEach((t) => {
850
+ pn(e, {
851
+ index: t,
852
+ buffer: o,
853
+ indexNames: a,
854
+ statements: n
855
+ }), o.push("");
856
+ }), o.join("\n");
857
+ }
858
+ function ln(e, { buffer: n, table: r, statements: i }) {
859
+ let { settings: { bracketType: a }, collections: o } = e, s = O(a), c = k(o).collection("tableColumnEntities").selectByIds(r.columnIds);
860
+ n.push(`CREATE TABLE${I(i)} ${s}${r.name}${s}`), n.push("(");
861
+ let l = A(c), u = z(c);
862
+ if (c.forEach((t, r) => {
863
+ l ? un(e, {
864
+ column: t,
865
+ isComma: !0,
866
+ spaceSize: u,
867
+ buffer: n
868
+ }) : un(e, {
869
+ column: t,
870
+ isComma: c.length !== r + 1,
871
+ spaceSize: u,
872
+ buffer: n
873
+ });
874
+ }), l) {
875
+ let e = b(c);
876
+ n.push(` PRIMARY KEY (${w(e, s)})`);
877
+ }
878
+ n.push(");");
879
+ let d = c.filter((e) => t(e.options, y.autoIncrement) && !sn(e));
880
+ d.length !== 0 && (n.push(""), d.forEach((e) => {
881
+ n.push(`-- PostgreSQL takes IDENTITY only on smallint, integer or bigint, so ${s}${r.name}${s}.${s}${e.name}${s} is written without it.`);
882
+ }));
883
+ }
884
+ function un({ settings: { bracketType: e } }, { buffer: n, column: r, isComma: i, spaceSize: a }) {
885
+ let o = O(e), s = [];
886
+ s.push(` ${o}${r.name}${o}` + T(a.name - r.name.length)), s.push(`${r.dataType}` + T(a.dataType - r.dataType.length)), t(r.options, y.notNull) && s.push("NOT NULL"), t(r.options, y.autoIncrement) ? sn(r) && s.push("GENERATED ALWAYS AS IDENTITY") : r.default.trim() !== "" && s.push(`DEFAULT ${L(r.default, D.PostgreSQL)}`), t(r.options, y.unique) && s.push("UNIQUE"), n.push(s.join(" ") + `${i ? "," : ""}`);
887
+ }
888
+ function dn({ settings: { bracketType: e }, collections: t }, { buffer: n, table: r }) {
889
+ let i = O(e);
890
+ r.comment.trim() !== "" && (n.push(`COMMENT ON TABLE ${i}${r.name}${i} IS ${c(r.comment)};`), n.push("")), k(t).collection("tableColumnEntities").selectByIds(r.columnIds).forEach((e) => {
891
+ e.comment.trim() !== "" && (n.push(`COMMENT ON COLUMN ${i}${r.name}${i}.${i}${e.name}${i} IS ${c(e.comment)};`), n.push(""));
892
+ });
893
+ }
894
+ function fn(e, { buffer: t, relationship: n, fkNames: r, statements: a }) {
895
+ let { settings: { bracketType: o } } = e, s = i(e, n);
896
+ if (!s) return !1;
897
+ let { startTable: c, endTable: l } = s, u = O(o), d = g(c.name, o), f = g(l.name, o), m = x(r, `FK_${d}_TO_${f}`);
898
+ r.push({
899
+ id: P(),
900
+ name: m
901
+ });
902
+ let h = `ALTER TABLE ${u}${l.name}${u}`;
903
+ return a === p.ifNotExists && t.push(`${h} DROP CONSTRAINT IF EXISTS ${u}${m}${u};`), t.push(h), t.push(` ADD CONSTRAINT ${u}${m}${u}`), t.push(` FOREIGN KEY (${w(s.end, u)})`), t.push(` REFERENCES ${u}${c.name}${u} (${w(s.start, u)})`, ...N(n, an).map((e) => ` ${e}`)), t[t.length - 1] += ";", !0;
904
+ }
905
+ function pn({ settings: { bracketType: e }, collections: t }, { buffer: n, index: r, indexNames: i, statements: a }) {
906
+ let o = O(e), s = k(t).collection("tableEntities").selectById(r.tableId);
907
+ if (!s) return;
908
+ let c = U(t, s, r).map(({ indexColumn: e, column: t }) => ({ name: `${o}${t.name}${o} ${V(e.orderType)}` }));
909
+ if (c.length !== 0) {
910
+ let t = r.name;
911
+ if (r.name.trim() === "") {
912
+ let n = g(s.name, e);
913
+ t = x(i, `IDX_${n}`), i.push({
914
+ id: P(),
915
+ name: t
916
+ });
917
+ }
918
+ n.push(`CREATE ${r.unique ? "UNIQUE " : ""}INDEX${I(a)} ${o}${t}${o}`), n.push(` ON ${o}${s.name}${o} (${w(c)});`);
919
+ }
920
+ }
921
+ function mn({ settings: { bracketType: t } }, n, r) {
922
+ if (n !== e.createAndUse) return "";
923
+ let i = O(t), a = `${i}${r}${i}`;
924
+ return `CREATE SCHEMA IF NOT EXISTS ${a};\nSET search_path TO ${a}, public;`;
925
+ }
926
+ function hn({ settings: { bracketType: t } }, { tables: n }, r, i) {
927
+ if (n.length === 0) return "";
928
+ let a = O(t), o = r === e.createAndUse ? `${a}${i}${a}.` : "";
929
+ return `DROP TABLE IF EXISTS ${n.map(({ name: e }) => {
930
+ let [n] = H(e, t);
931
+ return `${n === "" ? o : ""}${a}${e}${a}`;
932
+ }).join(", ")};`;
933
+ }
934
+ //#endregion
935
+ //#region src/utils/schema-sql/Snowflake.ts
936
+ var Q = B(D.Snowflake), $ = (e) => O(e) === "" ? "" : "\"";
937
+ function gn(e, t, { statements: n, written: r } = {}) {
938
+ let i = [], a = [], o = [""], { tables: s, relationships: c, indexes: l } = v(e, t);
939
+ return s.forEach((t) => {
940
+ r?.tables.push(t), _n(e, {
941
+ table: t,
942
+ buffer: o,
943
+ statements: n
944
+ }), o.push("");
945
+ }), c.forEach((t) => {
946
+ yn(e, {
947
+ relationship: t,
948
+ buffer: o,
949
+ fkNames: i
950
+ }) && o.push("");
951
+ }), l.forEach((t) => {
952
+ xn(e, {
953
+ index: t,
954
+ buffer: o,
955
+ indexNames: a
956
+ }), o.push("");
957
+ }), o.join("\n");
958
+ }
959
+ function _n(e, { buffer: t, table: n, statements: r }) {
960
+ let { collections: i, settings: { bracketType: a } } = e, o = $(a), s = k(i).collection("tableColumnEntities").selectByIds(n.columnIds), l = r === p.recreate ? "CREATE OR REPLACE TABLE" : "CREATE TABLE";
961
+ t.push(`${l} ${o}${n.name}${o}`), t.push("(");
962
+ let u = A(s), d = z(s);
963
+ if (s.forEach((n, r) => {
964
+ vn(e, {
965
+ column: n,
966
+ isComma: u || s.length !== r + 1,
967
+ spaceSize: d,
968
+ buffer: t
969
+ });
970
+ }), u) {
971
+ let e = b(s);
972
+ t.push(` CONSTRAINT ${o}PK_${n.name}${o} PRIMARY KEY (${w(e, o)})`);
973
+ }
974
+ n.comment.trim() === "" ? t.push(");") : (t.push(")"), t.push(`COMMENT = ${c(n.comment)};`));
975
+ }
976
+ function vn({ settings: { bracketType: e } }, { buffer: n, column: r, isComma: i, spaceSize: a }) {
977
+ let o = $(e), s = [];
978
+ s.push(` ${o}${r.name}${o}` + T(a.name - r.name.length)), s.push(`${r.dataType}` + T(a.dataType - r.dataType.length)), t(r.options, y.unique) && s.push("UNIQUE");
979
+ let l = t(r.options, y.notNull) || t(r.options, y.primaryKey);
980
+ s.push(l ? "NOT NULL" : " "), t(r.options, y.autoIncrement) ? s.push("AUTOINCREMENT") : r.default.trim() !== "" && s.push(`DEFAULT ${r.default}`), r.comment.trim() !== "" && s.push(`COMMENT ${c(r.comment)}`), n.push(s.join(" ").trimEnd() + `${i ? "," : ""}`);
981
+ }
982
+ function yn(e, { buffer: t, relationship: n, fkNames: r }) {
983
+ let { settings: { bracketType: a } } = e, o = i(e, n);
984
+ if (!o) return !1;
985
+ let { startTable: s, endTable: c } = o, l = $(a), u = bn(n);
986
+ u.length !== 0 && t.push(`-- Snowflake creates no foreign key with a referential action other than NO ACTION, so ${u.join(" and ")} ${u.length === 1 ? "is" : "are"} left out.`), t.push(`ALTER TABLE ${l}${c.name}${l}`);
987
+ let d = `FK_${s.name}_TO_${c.name}`;
988
+ return d = j(r, "", d), r.push({
989
+ id: P(),
990
+ name: d
991
+ }), t.push(` ADD CONSTRAINT ${l}${d}${l}`), t.push(` FOREIGN KEY (${w(o.end, l)})`), t.push(` REFERENCES ${l}${s.name}${l} (${w(o.start, l)})`, ...N(n, Q).map((e) => ` ${e}`)), t[t.length - 1] += ";", !0;
992
+ }
993
+ function bn({ onDelete: e, onUpdate: t }) {
994
+ let n = [];
995
+ return R[e] && !Q.onDelete.includes(e) && n.push(`ON DELETE ${R[e]}`), R[t] && !Q.onUpdate.includes(t) && n.push(`ON UPDATE ${R[t]}`), n;
996
+ }
997
+ function xn({ collections: e, settings: { bracketType: t } }, { buffer: n, index: r, indexNames: i }) {
998
+ let a = $(t), o = k(e).collection("tableEntities").selectById(r.tableId);
999
+ if (!o) return;
1000
+ let s = U(e, o, r), c = s.map(({ column: e }) => e);
1001
+ if (c.length === 0) return;
1002
+ let l = r.name;
1003
+ if (r.name.trim() === "" && (l = `IDX_${o.name}`, l = j(i, "", l), i.push({
1004
+ id: P(),
1005
+ name: l
1006
+ })), r.unique) {
1007
+ n.push(`ALTER TABLE ${a}${o.name}${a}`), n.push(` ADD CONSTRAINT ${a}${l}${a} UNIQUE (${w(c, a)});`);
1008
+ return;
1009
+ }
1010
+ let u = s.map(({ indexColumn: e, column: t }) => ({ name: `${a}${t.name}${a} ${V(e.orderType)}` }));
1011
+ n.push(`-- Snowflake has no secondary indexes. ${a}${l}${a} on ${a}${o.name}${a} (${w(u)})`), n.push(`-- ALTER TABLE ${a}${o.name}${a} CLUSTER BY (${w(c, a)});`);
1012
+ }
1013
+ function Sn({ settings: { bracketType: t } }, n, r) {
1014
+ let i = $(t), a = `${i}${r}${i}`, o = `USE SCHEMA ${a};`;
1015
+ return n === e.createAndUse ? `CREATE SCHEMA IF NOT EXISTS ${a};\n${o}` : o;
1016
+ }
1017
+ function Cn() {
1018
+ return "";
1019
+ }
1020
+ //#endregion
1021
+ //#region src/utils/schema-sql/SQLite.ts
1022
+ var wn = B(D.SQLite);
1023
+ function Tn(e, t, { statements: n, written: r } = {}) {
1024
+ let i = [], a = [""], { tables: o, indexes: s } = v(e, t);
1025
+ return o.forEach((t) => {
1026
+ r?.tables.push(t), Dn(e, {
1027
+ table: t,
1028
+ buffer: a,
1029
+ statements: n
1030
+ }), a.push("");
1031
+ }), s.forEach((t) => {
1032
+ kn(e, {
1033
+ index: t,
1034
+ buffer: a,
1035
+ indexNames: i,
1036
+ statements: n
1037
+ }), a.push("");
1038
+ }), a.join("\n");
1039
+ }
1040
+ function En(e) {
1041
+ return /^(?:(?:TINY|SMALL|MEDIUM|BIG)?INT(?:EGER)?|INT[248]|UNSIGNED\s+BIG\s+INT)(?:\s*\(\s*\d+\s*\))?$/i.test(e.trim());
1042
+ }
1043
+ function Dn(e, { buffer: n, table: r, statements: a }) {
1044
+ let { settings: { bracketType: o }, doc: { relationshipIds: s }, collections: c } = e, l = O(o), u = k(c).collection("tableColumnEntities").selectByIds(r.columnIds), d = b(u), f = d.length === 1 && t(d[0].options, y.autoIncrement) ? d[0] : null, p = f !== null && En(f.dataType), m = p ? u.map((e) => e === f ? {
1045
+ ...e,
1046
+ dataType: "INTEGER"
1047
+ } : e) : u, h = k(c).collection("relationshipEntities").selectByIds(s).filter(({ end: e }) => e.tableId === r.id).flatMap((t) => {
1048
+ let n = i(e, t);
1049
+ return n ? [{
1050
+ relationship: t,
1051
+ ...n
1052
+ }] : [];
1053
+ }), g = h.length !== 0;
1054
+ r.comment.trim() !== "" && n.push(`-- ${r.comment}`), n.push(`CREATE TABLE${I(a)} ${l}${r.name}${l}`), n.push("(");
1055
+ let _ = A(m), v = z(m);
1056
+ if (m.forEach((t, r) => {
1057
+ On(e, {
1058
+ column: t,
1059
+ isComma: _ || g || m.length !== r + 1,
1060
+ spaceSize: v,
1061
+ buffer: n
1062
+ });
1063
+ }), _) {
1064
+ let e = p ? " AUTOINCREMENT" : "";
1065
+ n.push(` PRIMARY KEY (${w(d, l)}${e})` + (g ? "," : ""));
1066
+ }
1067
+ h.forEach(({ relationship: e, startTable: t, start: r, end: i }, a) => {
1068
+ let s = N(e, wn).map((e) => ` ${e}`).join(""), [, c] = H(t.name, o);
1069
+ n.push(` FOREIGN KEY (${w(i, l)}) REFERENCES ${l}${c}${l} (${w(r, l)})${s}` + (h.length - 1 > a ? "," : ""));
1070
+ }), n.push(");"), f !== null && !p && (n.push(""), n.push(`-- SQLite takes AUTOINCREMENT only on an INTEGER column, so ${l}${r.name}${l}.${l}${f.name}${l} is written without it.`));
1071
+ }
1072
+ function On({ settings: { bracketType: e } }, { buffer: n, column: r, isComma: i, spaceSize: a }) {
1073
+ let o = O(e), s = [];
1074
+ r.comment.trim() !== "" && n.push(` -- ${r.comment}`), s.push(` ${o}${r.name}${o}` + T(a.name - r.name.length)), s.push(`${r.dataType}` + T(a.dataType - r.dataType.length)), s.push(`${t(r.options, y.notNull) ? "NOT NULL" : "NULL "}`), t(r.options, y.unique) && s.push("UNIQUE"), !t(r.options, y.autoIncrement) && r.default.trim() !== "" && s.push(`DEFAULT ${L(r.default, D.SQLite)}`), n.push(s.join(" ") + `${i ? "," : ""}`);
1075
+ }
1076
+ function kn({ settings: { bracketType: e }, collections: t }, { buffer: n, index: r, indexNames: i, statements: a }) {
1077
+ let o = O(e), s = k(t).collection("tableEntities").selectById(r.tableId);
1078
+ if (!s) return;
1079
+ let c = U(t, s, r).map(({ indexColumn: e, column: t }) => ({ name: `${o}${t.name}${o} ${V(e.orderType)}` }));
1080
+ if (c.length !== 0) {
1081
+ let [t, l] = H(s.name, e), u = r.name;
1082
+ if (r.name.trim() === "") {
1083
+ let t = g(s.name, e);
1084
+ u = x(i, `IDX_${t}`), i.push({
1085
+ id: P(),
1086
+ name: u
1087
+ });
1088
+ }
1089
+ let d = `${t === "" || u.includes(".") ? "" : `${t}.`}${o}${u}${o}`;
1090
+ n.push(`CREATE ${r.unique ? "UNIQUE " : ""}INDEX${I(a)} ${d}`), n.push(` ON ${o}${l}${o} (${w(c)});`);
1091
+ }
1092
+ }
1093
+ function An() {
1094
+ return "";
1095
+ }
1096
+ function jn({ settings: { bracketType: e } }, { tables: t }) {
1097
+ if (t.length === 0) return "";
1098
+ let n = O(e);
1099
+ return ["PRAGMA foreign_keys=OFF;", t.map(({ name: e }) => `DROP TABLE IF EXISTS ${n}${e}${n};`).join("\n")].join("\n\n");
1100
+ }
1101
+ //#endregion
1102
+ //#region src/utils/schema-sql/index.ts
1103
+ var Mn = {
1104
+ [D.Databricks]: {
1105
+ createSchema: et,
1106
+ formatHeader: ot,
1107
+ formatDropBlock: st
1108
+ },
1109
+ [D.MariaDB]: {
1110
+ createSchema: Tt,
1111
+ formatHeader: St,
1112
+ formatDropBlock: Ct
1113
+ },
1114
+ [D.MSSQL]: {
1115
+ createSchema: Nt,
1116
+ formatHeader: Wt,
1117
+ formatDropBlock: Gt
1118
+ },
1119
+ [D.MySQL]: {
1120
+ createSchema: dt,
1121
+ formatHeader: St,
1122
+ formatDropBlock: Ct
1123
+ },
1124
+ [D.Oracle]: {
1125
+ createSchema: qt,
1126
+ formatHeader: tn,
1127
+ formatDropBlock: rn
1128
+ },
1129
+ [D.PostgreSQL]: {
1130
+ createSchema: cn,
1131
+ formatHeader: mn,
1132
+ formatDropBlock: hn
1133
+ },
1134
+ [D.Snowflake]: {
1135
+ createSchema: gn,
1136
+ formatHeader: Sn,
1137
+ formatDropBlock: Cn
1138
+ },
1139
+ [D.SQLite]: {
1140
+ createSchema: Tn,
1141
+ formatHeader: An,
1142
+ formatDropBlock: jn
1143
+ }
1144
+ };
1145
+ function Nn(e) {
1146
+ return e === "" ? "" : e.slice(1, -1);
1147
+ }
1148
+ function Pn(t, n, r, i) {
1149
+ let a = n || t.settings.database, o = Mn[a];
1150
+ if (!o) return "";
1151
+ let { databaseName: s } = t.settings, c = l(a, i, s), u = ve(), d = Nn(o.createSchema(t, r, {
1152
+ statements: c.statements,
1153
+ written: u
1154
+ })), f = i?.scripts ?? r === void 0 ? t.settings.ddlScripts : void 0, m = h(f?.before ?? "", a), g = h(f?.after ?? "", a), _ = c.headerName === "valid" ? c.header : e.none, v = c.statements === p.recreate ? o.formatDropBlock(t, u, _, s) : "";
1155
+ return !m && !v && !d && !g ? "" : `\n${[
1156
+ _ === e.none ? "" : o.formatHeader(t, _, s),
1157
+ m,
1158
+ v,
1159
+ g ? d.replace(/\n+$/, "") : d,
1160
+ g
1161
+ ].filter(Boolean).join("\n\n")}\n`;
1162
+ }
1163
+ function Fn(e, t) {
1164
+ return v(e, t).tables.map((e) => e.name);
1165
+ }
1166
+ function In(e, t) {
1167
+ let { settings: n, doc: { indexIds: r }, collections: i } = e, a = [""], o = n.database, s = [], c = k(i).collection("indexEntities").selectByIds(r).filter((e) => e.tableId === t.id);
1168
+ switch (o) {
1169
+ case D.Databricks:
1170
+ tt(e, {
1171
+ buffer: a,
1172
+ table: t
1173
+ }), a.push(""), nt(e, {
1174
+ buffer: a,
1175
+ table: t
1176
+ }), c.forEach((t) => {
1177
+ at(e, {
1178
+ index: t,
1179
+ buffer: a,
1180
+ indexNames: s
1181
+ }), a.push("");
1182
+ });
1183
+ break;
1184
+ case D.MariaDB:
1185
+ Et(e, {
1186
+ buffer: a,
1187
+ table: t
1188
+ }), a.push(""), Dt(e, {
1189
+ buffer: a,
1190
+ table: t
1191
+ }), c.forEach((t) => {
1192
+ At(e, {
1193
+ index: t,
1194
+ buffer: a,
1195
+ indexNames: s
1196
+ }), a.push("");
1197
+ });
1198
+ break;
1199
+ case D.MSSQL:
1200
+ Pt(e, {
1201
+ buffer: a,
1202
+ table: t
1203
+ }), a.push(""), Ft(e, {
1204
+ buffer: a,
1205
+ table: t
1206
+ }), c.forEach((t) => {
1207
+ Ut(e, {
1208
+ index: t,
1209
+ buffer: a,
1210
+ indexNames: s
1211
+ }), a.push("");
1212
+ });
1213
+ break;
1214
+ case D.MySQL:
1215
+ pt(e, {
1216
+ buffer: a,
1217
+ table: t
1218
+ }), a.push(""), gt(e, {
1219
+ buffer: a,
1220
+ table: t
1221
+ }), c.forEach((t) => {
1222
+ xt(e, {
1223
+ index: t,
1224
+ buffer: a,
1225
+ indexNames: s
1226
+ }), a.push("");
1227
+ });
1228
+ break;
1229
+ case D.Oracle:
1230
+ Jt(e, {
1231
+ buffer: a,
1232
+ table: t
1233
+ }), a.push(""), Yt(e, {
1234
+ buffer: a,
1235
+ table: t
1236
+ }), c.forEach((t) => {
1237
+ $t(e, {
1238
+ index: t,
1239
+ buffer: a,
1240
+ indexNames: s
1241
+ }), a.push("");
1242
+ });
1243
+ break;
1244
+ case D.PostgreSQL:
1245
+ ln(e, {
1246
+ buffer: a,
1247
+ table: t
1248
+ }), a.push(""), c.forEach((t) => {
1249
+ pn(e, {
1250
+ index: t,
1251
+ buffer: a,
1252
+ indexNames: s
1253
+ }), a.push("");
1254
+ });
1255
+ break;
1256
+ case D.Snowflake:
1257
+ _n(e, {
1258
+ buffer: a,
1259
+ table: t
1260
+ }), a.push(""), c.forEach((t) => {
1261
+ xn(e, {
1262
+ index: t,
1263
+ buffer: a,
1264
+ indexNames: s
1265
+ }), a.push("");
1266
+ });
1267
+ break;
1268
+ case D.SQLite: Dn(e, {
1269
+ buffer: a,
1270
+ table: t
1271
+ }), a.push(""), c.forEach((t) => {
1272
+ kn(e, {
1273
+ index: t,
1274
+ buffer: a,
1275
+ indexNames: s
1276
+ }), a.push("");
1277
+ });
1278
+ }
1279
+ return a.join("\n");
1280
+ }
1281
+ //#endregion
1282
+ //#region src/engine/shared-store.ts
1283
+ var Ln = 2, Rn = n(Ce);
1284
+ function zn(e, t, n) {
1285
+ let r = n?.manualStreamFlush ?? !1, i = { editorId: e.state.editor.id }, a = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set(), s = new G(), c = new G(), l = new G(), u = new G(), f = new G(), p = ue(r ? Ne(f) : Pe(f)), m = !0, h = !0;
1286
+ a.add(Ee(new W((t) => e.subscribe((e) => t.next(e))), c).pipe(C(ae), re([d.shared]), p, xe(l, u), p, K((e) => ee(d.shared, e.map((e) => {
1287
+ let n = {
1288
+ ...e,
1289
+ meta: Object.assign({}, e.meta ?? {}, {
1290
+ ...i,
1291
+ nickname: t?.getNickname?.()
1292
+ })
1293
+ };
1294
+ return Rn(e.type) ? te(d.following, n) : n;
1295
+ })))).subscribe((e) => s.next(e)));
1296
+ let g = () => {
1297
+ c.next([{
1298
+ ...E(),
1299
+ version: e.context.clock.getVersion()
1300
+ }]);
1301
+ };
1302
+ a.add(new W((t) => e.subscribe((e) => t.next(e))).pipe(Te((e) => !h && e.some(({ type: e }) => e === he.type))).subscribe(g));
1303
+ let _ = () => {
1304
+ let e = 0 < o.size;
1305
+ m && e ? l.next() : u.next();
1306
+ }, v = (t) => {
1307
+ let n = (Array.isArray(t) ? t : [t]).some((e) => e.type === E.type), r = e.state.lww;
1308
+ n && !je(r) && c.next([{
1309
+ ...ce({ lww: r }),
1310
+ version: e.context.clock.getVersion()
1311
+ }]);
1312
+ };
1313
+ return Object.freeze({
1314
+ connection: () => {
1315
+ m = !0, _();
1316
+ },
1317
+ disconnect: () => {
1318
+ m = !1, _();
1319
+ },
1320
+ dispatch: (t) => {
1321
+ e.dispatch(t), v(t);
1322
+ },
1323
+ dispatchSync: (t) => {
1324
+ e.dispatchSync(t), v(t);
1325
+ },
1326
+ subscribe: (e) => {
1327
+ let t = s.subscribe((t) => e(t));
1328
+ return o.add(t), _(), h &&= (g(), !1), () => {
1329
+ t.unsubscribe(), o.delete(t), _();
1330
+ };
1331
+ },
1332
+ flushStreamBuffers: () => {
1333
+ for (let e = 0; e < Ln; e++) f.next();
1334
+ },
1335
+ destroy: () => {
1336
+ Array.from(a).forEach((e) => e.unsubscribe()), Array.from(o).forEach((e) => e.unsubscribe()), a.clear(), o.clear(), s.complete(), l.complete(), u.complete(), f.complete();
1337
+ }
1338
+ });
1339
+ }
1340
+ //#endregion
1341
+ export { En as a, Ue as c, qe as d, Je as f, Y as h, Fn as i, We as l, He as m, Pn as n, en as o, Ve as p, In as r, Ge as s, zn as t, Ke as u };