@dineug/erd-editor 4.0.0 → 4.1.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.
- package/README.md +93 -280
- package/dist/components/erd/canvas/DiffOutline.template.d.ts +14 -0
- package/dist/components/erd/canvas/sceneTokens.d.ts +2 -0
- package/dist/components/erd/diff-viewer/diff-tree/DiffTree.d.ts +19 -0
- package/dist/components/erd/diff-viewer/diff-tree/DiffTree.styles.d.ts +12 -0
- package/dist/components/erd/diff-viewer/diff-tree/diffTreeModel.d.ts +49 -0
- package/dist/components/erd/diff-viewer/diff.d.ts +21 -19
- package/dist/components/erd/draw-target/placePill.d.ts +1 -3
- package/dist/components/erd/floating-toolbar/FloatingToolbar.d.ts +7 -4
- package/dist/components/erd/goToErdTarget.d.ts +40 -16
- package/dist/components/erd/relationshipHighlight.d.ts +18 -0
- package/dist/components/erd/welcome-screen/welcome-hints/WelcomeHints.styles.d.ts +5 -0
- package/dist/components/erd/welcome-screen/welcomeLayout.d.ts +7 -3
- package/dist/components/erd-editor/ErdEditor.styles.d.ts +4 -0
- package/dist/components/erd-editor/viewportLayout.d.ts +52 -0
- package/dist/components/explorer/Explorer.d.ts +12 -0
- package/dist/components/explorer/explorer-controller/ExplorerController.d.ts +11 -0
- package/dist/components/explorer/explorer-panel/ExplorerPanel.d.ts +14 -0
- package/dist/components/explorer/explorer-panel/ExplorerPanel.styles.d.ts +13 -0
- package/dist/components/explorer/explorer-search/ExplorerSearch.d.ts +12 -0
- package/dist/components/explorer/explorer-search/ExplorerSearch.styles.d.ts +13 -0
- package/dist/components/explorer/explorerCommands.d.ts +28 -0
- package/dist/components/explorer/explorerNavigation.d.ts +14 -0
- package/dist/components/explorer/explorerSearch.d.ts +71 -0
- package/dist/components/explorer/explorerTree.d.ts +90 -0
- package/dist/components/explorer/explorerView.d.ts +54 -0
- package/dist/components/{find-replace → explorer}/matchTarget.d.ts +5 -7
- package/dist/components/primitives/icon/icons.d.ts +8 -4
- package/dist/components/primitives/sash/Sash.d.ts +1 -0
- package/dist/components/primitives/tree/Tree.d.ts +30 -0
- package/dist/components/primitives/tree/Tree.styles.d.ts +5 -0
- package/dist/components/primitives/tree/treeModel.d.ts +42 -0
- package/dist/components/quick-search/QuickSearch.styles.d.ts +1 -0
- package/dist/components/quick-search/actions.d.ts +0 -3
- package/dist/components/quick-search/paletteList.d.ts +7 -0
- package/dist/components/quick-search/scopedActions.d.ts +5 -11
- package/dist/components/theme-builder/ThemeBuilder.styles.d.ts +3 -3
- package/dist/components/toolbar/Toolbar.styles.d.ts +0 -1
- package/dist/constants/layout.d.ts +7 -1
- package/dist/constants/open.d.ts +0 -1
- package/dist/engine/index.js +7 -7
- package/dist/erd-editor.umd.js +1008 -786
- package/dist/i18n/messages/ar-SA.d.ts +41 -15
- package/dist/i18n/messages/de-DE.d.ts +41 -11
- package/dist/i18n/messages/en/code.d.ts +0 -1
- package/dist/i18n/messages/en/common.d.ts +0 -1
- package/dist/i18n/messages/en/explorer.d.ts +37 -0
- package/dist/i18n/messages/en/findReplace.d.ts +5 -1
- package/dist/i18n/messages/en/index.d.ts +42 -12
- package/dist/i18n/messages/en/palette.d.ts +1 -7
- package/dist/i18n/messages/en/shortcuts.d.ts +3 -1
- package/dist/i18n/messages/en/toolbar.d.ts +0 -1
- package/dist/i18n/messages/es-ES.d.ts +41 -12
- package/dist/i18n/messages/eu-ES.d.ts +41 -11
- package/dist/i18n/messages/fa-IR.d.ts +41 -11
- package/dist/i18n/messages/fr-FR.d.ts +41 -12
- package/dist/i18n/messages/he-IL.d.ts +41 -12
- package/dist/i18n/messages/id-ID.d.ts +41 -10
- package/dist/i18n/messages/it-IT.d.ts +41 -12
- package/dist/i18n/messages/ja-JP.d.ts +41 -10
- package/dist/i18n/messages/ko-KR.d.ts +41 -10
- package/dist/i18n/messages/nl-NL.d.ts +41 -11
- package/dist/i18n/messages/pl-PL.d.ts +41 -13
- package/dist/i18n/messages/pt-BR.d.ts +41 -12
- package/dist/i18n/messages/pt-PT.d.ts +41 -12
- package/dist/i18n/messages/ro-RO.d.ts +41 -12
- package/dist/i18n/messages/ru-RU.d.ts +41 -13
- package/dist/i18n/messages/sk-SK.d.ts +41 -13
- package/dist/i18n/messages/sl-SI.d.ts +41 -13
- package/dist/i18n/messages/sv-SE.d.ts +41 -11
- package/dist/i18n/messages/tr-TR.d.ts +41 -11
- package/dist/i18n/messages/uk-UA.d.ts +41 -13
- package/dist/i18n/messages/zh-CN.d.ts +41 -10
- package/dist/i18n/messages/zh-TW.d.ts +41 -10
- package/dist/index.js +21553 -18898
- package/dist/{loadValue-B3EFSe9k.js → loadValue-BKvXDYoC.js} +1651 -1651
- package/dist/peer/index.js +23 -23
- package/dist/shared-store-2IUOt99m.js +1341 -0
- package/dist/styles/scrollbar.styles.d.ts +1 -1
- package/dist/themes/tokens.d.ts +9 -4
- package/dist/utils/diff/compareEntities.d.ts +39 -0
- package/dist/utils/diff/diffDocuments.d.ts +12 -0
- package/dist/utils/diff/index.d.ts +5 -0
- package/dist/utils/diff/pairEntities.d.ts +41 -0
- package/dist/utils/diff/types.d.ts +77 -0
- package/dist/utils/emitter.d.ts +2 -8
- package/dist/utils/find-replace/findMatches.d.ts +25 -12
- package/dist/utils/find-replace/matcher.d.ts +2 -0
- package/dist/utils/find-replace/present.d.ts +3 -2
- package/dist/utils/find-replace/preserveCase.d.ts +10 -0
- package/dist/utils/keyboard-shortcut/index.d.ts +11 -3
- package/dist/utils/takeover.d.ts +6 -0
- package/dist/utils/virtualRange.d.ts +15 -0
- package/dist/workers/exportPng.shared-worker.js +29 -29
- package/package.json +4 -4
- package/dist/components/erd/diff-viewer/tree-viewer/TreeViewer.d.ts +0 -12
- package/dist/components/erd/diff-viewer/tree-viewer/TreeViewer.styles.d.ts +0 -6
- package/dist/components/find-replace/FindReplace.d.ts +0 -13
- package/dist/components/find-replace/FindReplace.styles.d.ts +0 -27
- package/dist/components/find-replace/panelLayout.d.ts +0 -20
- package/dist/shared-store-fUggY7sI.js +0 -1341
- /package/dist/components/{find-replace → explorer}/fieldIcon.d.ts +0 -0
|
@@ -1,1341 +0,0 @@
|
|
|
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 };
|