@quillsql/admin 1.3.1 → 1.3.2

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 (192) hide show
  1. package/{lib → dist}/Admin.d.ts +12 -7
  2. package/dist/Admin.d.ts.map +1 -0
  3. package/dist/Admin.js +1384 -0
  4. package/{lib → dist}/AdminProvider.d.ts +41 -27
  5. package/dist/AdminProvider.d.ts.map +1 -0
  6. package/{lib → dist}/AdminProvider.js +105 -89
  7. package/dist/api/ConnectionClient.d.ts +27 -0
  8. package/dist/api/ConnectionClient.d.ts.map +1 -0
  9. package/dist/api/ConnectionClient.js +247 -0
  10. package/dist/components/Banner/index.d.ts +3 -0
  11. package/dist/components/Banner/index.d.ts.map +1 -0
  12. package/dist/components/Banner/index.js +27 -0
  13. package/dist/components/CardSection.d.ts +3 -0
  14. package/dist/components/CardSection.d.ts.map +1 -0
  15. package/dist/components/CardSection.js +9 -0
  16. package/dist/components/CardTitle.d.ts +3 -0
  17. package/dist/components/CardTitle.d.ts.map +1 -0
  18. package/dist/components/CardTitle.js +11 -0
  19. package/dist/components/DashboardSelectPopover.d.ts +11 -0
  20. package/dist/components/DashboardSelectPopover.d.ts.map +1 -0
  21. package/dist/components/DashboardSelectPopover.js +175 -0
  22. package/dist/components/DatabaseSelector.d.ts +11 -0
  23. package/dist/components/DatabaseSelector.d.ts.map +1 -0
  24. package/dist/components/DatabaseSelector.js +22 -0
  25. package/dist/components/DeleteButton.d.ts +3 -0
  26. package/dist/components/DeleteButton.d.ts.map +1 -0
  27. package/dist/components/DeleteButton.js +10 -0
  28. package/{lib → dist}/components/DropDownMenu.d.ts +1 -0
  29. package/dist/components/DropDownMenu.d.ts.map +1 -0
  30. package/dist/components/DropDownMenu.js +39 -0
  31. package/dist/components/DropDownMenuWithLabel.d.ts +12 -0
  32. package/dist/components/DropDownMenuWithLabel.d.ts.map +1 -0
  33. package/dist/components/DropDownMenuWithLabel.js +47 -0
  34. package/{lib → dist}/components/EnvSelectPopover.d.ts +1 -0
  35. package/dist/components/EnvSelectPopover.d.ts.map +1 -0
  36. package/dist/components/EnvSelectPopover.js +205 -0
  37. package/dist/components/InputLabel.d.ts +3 -0
  38. package/dist/components/InputLabel.d.ts.map +1 -0
  39. package/dist/components/InputLabel.js +10 -0
  40. package/{lib → dist}/components/OrgSelect.d.ts +1 -0
  41. package/dist/components/OrgSelect.d.ts.map +1 -0
  42. package/dist/components/OrgSelect.js +193 -0
  43. package/dist/components/SqlViewTile.d.ts +8 -0
  44. package/dist/components/SqlViewTile.d.ts.map +1 -0
  45. package/dist/components/SqlViewTile.js +40 -0
  46. package/dist/components/StepDisplay.d.ts +10 -0
  47. package/dist/components/StepDisplay.d.ts.map +1 -0
  48. package/dist/components/StepDisplay.js +15 -0
  49. package/dist/components/index.d.ts +6 -0
  50. package/dist/components/index.d.ts.map +1 -0
  51. package/dist/forms/client_onboard/ConnectDatabase.d.ts +11 -0
  52. package/dist/forms/client_onboard/ConnectDatabase.d.ts.map +1 -0
  53. package/dist/forms/client_onboard/ConnectDatabase.js +137 -0
  54. package/dist/forms/client_onboard/ConnectSchema.d.ts +13 -0
  55. package/dist/forms/client_onboard/ConnectSchema.d.ts.map +1 -0
  56. package/dist/forms/client_onboard/ConnectSchema.js +171 -0
  57. package/dist/forms/client_onboard/CreateSqlViews.d.ts +15 -0
  58. package/dist/forms/client_onboard/CreateSqlViews.d.ts.map +1 -0
  59. package/dist/forms/client_onboard/CreateSqlViews.js +202 -0
  60. package/dist/hooks/useItemBeingEdited.d.ts +4 -0
  61. package/dist/hooks/useItemBeingEdited.d.ts.map +1 -0
  62. package/dist/hooks/useItemBeingEdited.js +25 -0
  63. package/{lib → dist}/icons/ArrowDownHeadIcon.d.ts +1 -0
  64. package/dist/icons/ArrowDownHeadIcon.d.ts.map +1 -0
  65. package/dist/icons/ArrowDownHeadIcon.js +3 -0
  66. package/dist/icons/XMarkIcon.d.ts +3 -0
  67. package/dist/icons/XMarkIcon.d.ts.map +1 -0
  68. package/dist/icons/XMarkIcon.js +11 -0
  69. package/dist/icons/index.d.ts +2 -0
  70. package/dist/icons/index.d.ts.map +1 -0
  71. package/dist/index.d.ts +7 -0
  72. package/dist/index.d.ts.map +1 -0
  73. package/{lib/index.d.ts → dist/index.js} +1 -0
  74. package/{lib → dist}/modals/EditDashboardsModal.d.ts +1 -0
  75. package/dist/modals/EditDashboardsModal.d.ts.map +1 -0
  76. package/dist/modals/EditDashboardsModal.js +91 -0
  77. package/dist/modals/NewDashboardModal.d.ts +19 -0
  78. package/dist/modals/NewDashboardModal.d.ts.map +1 -0
  79. package/dist/modals/NewDashboardModal.js +276 -0
  80. package/{lib → dist}/modals/PromoteDashModal.d.ts +2 -1
  81. package/dist/modals/PromoteDashModal.d.ts.map +1 -0
  82. package/dist/modals/PromoteDashModal.js +123 -0
  83. package/{lib → dist}/modals/PromoteViewModal.d.ts +1 -0
  84. package/dist/modals/PromoteViewModal.d.ts.map +1 -0
  85. package/{lib → dist}/modals/PromoteViewModal.js +13 -16
  86. package/{lib → dist}/modals/ReorderDashboardModal.d.ts +4 -1
  87. package/dist/modals/ReorderDashboardModal.d.ts.map +1 -0
  88. package/{lib → dist}/modals/ReorderDashboardModal.js +53 -55
  89. package/dist/modals/index.d.ts +5 -0
  90. package/dist/modals/index.d.ts.map +1 -0
  91. package/{lib → dist}/primitives/ButtonPrimitive.d.ts +3 -0
  92. package/dist/primitives/ButtonPrimitive.d.ts.map +1 -0
  93. package/dist/primitives/ButtonPrimitive.js +47 -0
  94. package/{lib → dist}/primitives/HeaderPrimitive.d.ts +1 -0
  95. package/dist/primitives/HeaderPrimitive.d.ts.map +1 -0
  96. package/dist/primitives/HeaderPrimitive.js +9 -0
  97. package/{lib → dist}/primitives/ModalPrimitive.d.ts +3 -1
  98. package/dist/primitives/ModalPrimitive.d.ts.map +1 -0
  99. package/{lib → dist}/primitives/ModalPrimitive.js +9 -11
  100. package/{lib → dist}/primitives/SecondaryButtonPrimitive.d.ts +1 -0
  101. package/dist/primitives/SecondaryButtonPrimitive.d.ts.map +1 -0
  102. package/{lib → dist}/primitives/SecondaryButtonPrimitive.js +5 -8
  103. package/{lib → dist}/primitives/SelectPrimitive.d.ts +1 -0
  104. package/dist/primitives/SelectPrimitive.d.ts.map +1 -0
  105. package/{lib → dist}/primitives/SelectPrimitive.js +8 -11
  106. package/{lib → dist}/primitives/TextInputPrimitive.d.ts +2 -0
  107. package/dist/primitives/TextInputPrimitive.d.ts.map +1 -0
  108. package/dist/primitives/TextInputPrimitive.js +24 -0
  109. package/dist/primitives/TogglePrimitive.d.ts +6 -0
  110. package/dist/primitives/TogglePrimitive.d.ts.map +1 -0
  111. package/dist/primitives/TogglePrimitive.js +45 -0
  112. package/dist/primitives/index.d.ts +7 -0
  113. package/dist/primitives/index.d.ts.map +1 -0
  114. package/dist/public_components/CreateEnvironment.d.ts +6 -0
  115. package/dist/public_components/CreateEnvironment.d.ts.map +1 -0
  116. package/dist/public_components/CreateEnvironment.js +129 -0
  117. package/{lib → dist}/public_components/DashboardBuilder.d.ts +2 -1
  118. package/dist/public_components/DashboardBuilder.d.ts.map +1 -0
  119. package/dist/public_components/DashboardBuilder.js +192 -0
  120. package/{lib → dist}/public_components/DashboardManager.d.ts +2 -1
  121. package/dist/public_components/DashboardManager.d.ts.map +1 -0
  122. package/dist/public_components/DashboardManager.js +308 -0
  123. package/{lib → dist}/public_components/SQLViewManager.d.ts +2 -1
  124. package/dist/public_components/SQLViewManager.d.ts.map +1 -0
  125. package/dist/public_components/SQLViewManager.js +394 -0
  126. package/dist/utils/constants.d.ts +26 -0
  127. package/dist/utils/constants.d.ts.map +1 -0
  128. package/dist/utils/constants.js +13 -0
  129. package/dist/utils/databases.d.ts +34 -0
  130. package/dist/utils/databases.d.ts.map +1 -0
  131. package/dist/utils/databases.js +51 -0
  132. package/dist/utils/delay.d.ts +2 -0
  133. package/dist/utils/delay.d.ts.map +1 -0
  134. package/dist/utils/delay.js +3 -0
  135. package/dist/utils/schema.d.ts +22 -0
  136. package/dist/utils/schema.d.ts.map +1 -0
  137. package/dist/utils/schema.js +1 -0
  138. package/dist/utils/table.d.ts +9 -0
  139. package/dist/utils/table.d.ts.map +1 -0
  140. package/dist/utils/table.js +1 -0
  141. package/package.json +19 -26
  142. package/LICENSE +0 -21
  143. package/README.md +0 -10
  144. package/lib/Admin.js +0 -1573
  145. package/lib/Admin.js.map +0 -1
  146. package/lib/AdminProvider.js.map +0 -1
  147. package/lib/components/DashboardSelectPopover.d.ts +0 -9
  148. package/lib/components/DashboardSelectPopover.js +0 -187
  149. package/lib/components/DashboardSelectPopover.js.map +0 -1
  150. package/lib/components/DropDownMenu.js +0 -43
  151. package/lib/components/DropDownMenu.js.map +0 -1
  152. package/lib/components/EnvSelectPopover.js +0 -190
  153. package/lib/components/EnvSelectPopover.js.map +0 -1
  154. package/lib/components/OrgSelect.js +0 -188
  155. package/lib/components/OrgSelect.js.map +0 -1
  156. package/lib/components/index.js +0 -17
  157. package/lib/components/index.js.map +0 -1
  158. package/lib/icons/ArrowDownHeadIcon.js +0 -6
  159. package/lib/icons/ArrowDownHeadIcon.js.map +0 -1
  160. package/lib/icons/index.js +0 -9
  161. package/lib/icons/index.js.map +0 -1
  162. package/lib/index.js +0 -17
  163. package/lib/index.js.map +0 -1
  164. package/lib/modals/EditDashboardsModal.js +0 -94
  165. package/lib/modals/EditDashboardsModal.js.map +0 -1
  166. package/lib/modals/PromoteDashModal.js +0 -126
  167. package/lib/modals/PromoteDashModal.js.map +0 -1
  168. package/lib/modals/PromoteViewModal.js.map +0 -1
  169. package/lib/modals/ReorderDashboardModal.js.map +0 -1
  170. package/lib/modals/index.js +0 -15
  171. package/lib/modals/index.js.map +0 -1
  172. package/lib/primitives/ButtonPrimitive.js +0 -25
  173. package/lib/primitives/ButtonPrimitive.js.map +0 -1
  174. package/lib/primitives/HeaderPrimitive.js +0 -12
  175. package/lib/primitives/HeaderPrimitive.js.map +0 -1
  176. package/lib/primitives/ModalPrimitive.js.map +0 -1
  177. package/lib/primitives/SecondaryButtonPrimitive.js.map +0 -1
  178. package/lib/primitives/SelectPrimitive.js.map +0 -1
  179. package/lib/primitives/TextInputPrimitive.js +0 -26
  180. package/lib/primitives/TextInputPrimitive.js.map +0 -1
  181. package/lib/primitives/index.js +0 -19
  182. package/lib/primitives/index.js.map +0 -1
  183. package/lib/public_components/DashboardBuilder.js +0 -166
  184. package/lib/public_components/DashboardBuilder.js.map +0 -1
  185. package/lib/public_components/DashboardManager.js +0 -255
  186. package/lib/public_components/DashboardManager.js.map +0 -1
  187. package/lib/public_components/SQLViewManager.js +0 -400
  188. package/lib/public_components/SQLViewManager.js.map +0 -1
  189. /package/{lib/components/index.d.ts → dist/components/index.js} +0 -0
  190. /package/{lib/icons/index.d.ts → dist/icons/index.js} +0 -0
  191. /package/{lib/modals/index.d.ts → dist/modals/index.js} +0 -0
  192. /package/{lib/primitives/index.d.ts → dist/primitives/index.js} +0 -0
@@ -0,0 +1,394 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useRef, useState } from 'react';
3
+ import { ButtonPrimitive, HeaderPrimitive, ModalPrimitive, SecondaryButtonPrimitive, TextInputPrimitive, } from '../primitives';
4
+ import { useAdmin } from '../AdminProvider';
5
+ import { EnvSelectPopover } from '../components';
6
+ import { TableCell, defineEditorTheme, setEditorTheme } from '../Admin';
7
+ import { PromoteViewModal } from '../modals';
8
+ import MonacoEditor from '@monaco-editor/react';
9
+ import { QUILL_SERVER } from '../utils/constants';
10
+ export default function SQLViewManager({ containerStyle, }) {
11
+ const [tables, setTables] = useState([]);
12
+ const [modalIsOpen, setIsOpen] = useState(false);
13
+ const [editModalIsOpen, setEditModalIsOpen] = useState(false);
14
+ const [name, setName] = useState('');
15
+ const [viewQuery, setViewQuery] = useState('');
16
+ const [editViewId, setEditViewId] = useState('');
17
+ const [editName, setEditName] = useState('');
18
+ const [editViewQuery, setEditViewQuery] = useState('');
19
+ const [tableToBeDeleted, setTableToBeDeleted] = useState('');
20
+ const [deleteName, setDeleteName] = useState('');
21
+ const [deleteModalIsOpen, setDeleteModalIsOpen] = useState(false);
22
+ const [isPromoteViewModalOpen, setIsPromoteViewModalOpen] = useState(false);
23
+ const parentRef = useRef(null);
24
+ const { state, dispatch } = useAdmin();
25
+ // const [organizations] = useContext(OrganizationsContext);
26
+ // const [organizationId, setOrganizationId] = useContext(OrganizationIdContext);
27
+ const closeDeleteModal = () => {
28
+ setDeleteModalIsOpen(false);
29
+ };
30
+ const openModal = () => {
31
+ setIsOpen(true);
32
+ setEditViewQuery('');
33
+ };
34
+ const closeModal = () => {
35
+ setIsOpen(false);
36
+ setName('');
37
+ setViewQuery('');
38
+ };
39
+ const closeEditModal = () => {
40
+ setEditModalIsOpen(false);
41
+ setEditName('');
42
+ setEditViewQuery('');
43
+ };
44
+ const clickTableCell = (table) => {
45
+ setEditModalIsOpen(true);
46
+ setEditName(table.name);
47
+ setEditViewQuery(table.viewQuery);
48
+ setEditViewId(table._id);
49
+ };
50
+ const handleDeleteTable = async () => {
51
+ if (deleteName !== tableToBeDeleted) {
52
+ alert('Table names must match');
53
+ return;
54
+ }
55
+ if (!editViewId) {
56
+ console.log('No view id found');
57
+ return;
58
+ }
59
+ let response;
60
+ if (state.queryEndpoint) {
61
+ response = await fetch(state.queryEndpoint, {
62
+ method: 'POST',
63
+ headers: {
64
+ 'Content-Type': 'application/json',
65
+ ...state.queryHeaders,
66
+ },
67
+ body: JSON.stringify({
68
+ metadata: {
69
+ task: 'view',
70
+ id: editViewId,
71
+ deleted: true,
72
+ clientId: state.client._id,
73
+ },
74
+ }),
75
+ credentials: state.withCredentials ? 'include' : 'omit', // If withCredentials is true, set to 'include'. Otherwise, set to 'omit'.
76
+ });
77
+ }
78
+ else {
79
+ response = await fetch(`${QUILL_SERVER}/table/${state.client._id}/`, {
80
+ method: 'POST',
81
+ headers: {
82
+ 'Content-Type': 'application/json',
83
+ Authorization: `Bearer `,
84
+ },
85
+ body: JSON.stringify({
86
+ id: editViewId,
87
+ deleted: true,
88
+ }),
89
+ });
90
+ }
91
+ const data = await response.json();
92
+ if (data) {
93
+ setDeleteName('');
94
+ setDeleteModalIsOpen(false);
95
+ setEditModalIsOpen(false);
96
+ setEditName('');
97
+ setEditViewQuery('');
98
+ getTables();
99
+ }
100
+ };
101
+ const getTables = async () => {
102
+ const response = await fetch(`${QUILL_SERVER}/schema2/${state.client._id}/`, {
103
+ method: 'GET',
104
+ headers: { Authorization: `Bearer ` },
105
+ });
106
+ const data = await response.json();
107
+ setTables(data.tables);
108
+ };
109
+ useEffect(() => {
110
+ let isSubscribed = true;
111
+ if (isSubscribed && state.client) {
112
+ getTables();
113
+ }
114
+ return () => {
115
+ isSubscribed = false;
116
+ };
117
+ }, []);
118
+ const handleClickFirstDelete = () => {
119
+ setTableToBeDeleted(editName);
120
+ setDeleteModalIsOpen(true);
121
+ };
122
+ const handleEditTable = async () => {
123
+ if (!editName.length) {
124
+ alert('Please enter a table name.');
125
+ return;
126
+ }
127
+ if (!editViewQuery.length) {
128
+ alert('Please enter a table query.');
129
+ return;
130
+ }
131
+ if (!editViewId) {
132
+ alert('Could not save.');
133
+ return;
134
+ }
135
+ let response;
136
+ if (state.queryEndpoint) {
137
+ response = await fetch(state.queryEndpoint, {
138
+ method: 'POST',
139
+ headers: {
140
+ 'Content-Type': 'application/json',
141
+ ...state.queryHeaders,
142
+ },
143
+ body: JSON.stringify({
144
+ metadata: {
145
+ preQueries: editViewQuery[editViewQuery.length - 1] === ';'
146
+ ? [editViewQuery.slice(0, -1)]
147
+ : [editViewQuery],
148
+ name: editName,
149
+ task: 'view',
150
+ id: editViewId,
151
+ clientId: state.client._id,
152
+ },
153
+ }),
154
+ credentials: state.withCredentials ? 'include' : 'omit', // If withCredentials is true, set to 'include'. Otherwise, set to 'omit'.
155
+ });
156
+ }
157
+ else {
158
+ response = await fetch(`${QUILL_SERVER}/table/${state.client._id}/`, {
159
+ method: 'POST',
160
+ headers: {
161
+ 'Content-Type': 'application/json',
162
+ Authorization: `Bearer `,
163
+ },
164
+ body: JSON.stringify({
165
+ viewQuery: editViewQuery[editViewQuery.length - 1] === ';'
166
+ ? editViewQuery.slice(0, -1)
167
+ : editViewQuery,
168
+ name: editName,
169
+ id: editViewId,
170
+ }),
171
+ });
172
+ }
173
+ const data = await response.json();
174
+ if (data) {
175
+ closeEditModal();
176
+ getTables();
177
+ }
178
+ };
179
+ const handleAddTable = async () => {
180
+ if (!name.length) {
181
+ alert('Please enter a table name.');
182
+ return;
183
+ }
184
+ if (!editViewQuery.length) {
185
+ alert('Please enter a table query.');
186
+ return;
187
+ }
188
+ let response;
189
+ if (state.queryEndpoint) {
190
+ response = await fetch(state.queryEndpoint, {
191
+ method: 'POST',
192
+ headers: {
193
+ 'Content-Type': 'application/json',
194
+ ...state.queryHeaders,
195
+ },
196
+ body: JSON.stringify({
197
+ metadata: {
198
+ preQueries: editViewQuery[editViewQuery.length - 1] === ';'
199
+ ? [editViewQuery.slice(0, -1)]
200
+ : [editViewQuery],
201
+ name: name,
202
+ task: 'view',
203
+ clientId: state.client._id,
204
+ },
205
+ }),
206
+ credentials: state.withCredentials ? 'include' : 'omit', // If withCredentials is true, set to 'include'. Otherwise, set to 'omit'.
207
+ });
208
+ }
209
+ else {
210
+ response = await fetch(`${QUILL_SERVER}/table/${state.client._id}/`, {
211
+ method: 'POST',
212
+ headers: {
213
+ 'Content-Type': 'application/json',
214
+ Authorization: `Bearer `,
215
+ },
216
+ body: JSON.stringify({
217
+ viewQuery: editViewQuery[editViewQuery.length - 1] === ';'
218
+ ? editViewQuery.slice(0, -1)
219
+ : editViewQuery,
220
+ name: name,
221
+ }),
222
+ });
223
+ }
224
+ const data = await response.json();
225
+ if (data) {
226
+ closeModal();
227
+ getTables();
228
+ }
229
+ };
230
+ useEffect(() => {
231
+ getTables();
232
+ }, [state.client]);
233
+ return (_jsx("div", { style: { ...containerStyle }, children: _jsxs("div", { style: {
234
+ display: 'flex',
235
+ flexDirection: 'column',
236
+ paddingTop: '0px',
237
+ position: 'relative',
238
+ }, ref: parentRef, children: [_jsx("div", { style: {
239
+ // width: 'calc(100vw - 30px)',
240
+ display: 'flex',
241
+ position: 'sticky',
242
+ // position: "fixed",
243
+ backgroundColor: 'white',
244
+ zIndex: 1,
245
+ left: 0,
246
+ right: 0,
247
+ top: 0,
248
+ flexDirection: 'row',
249
+ paddingTop: 12,
250
+ alignItems: 'center',
251
+ justifyContent: 'space-between',
252
+ paddingLeft: '30px',
253
+ paddingRight: '30px',
254
+ borderBottomWidth: 1,
255
+ borderTopWidth: 0,
256
+ borderLeftWidth: 0,
257
+ borderRightWidth: 0,
258
+ borderStyle: 'solid',
259
+ borderColor: state.theme.borderColor,
260
+ paddingBottom: 20,
261
+ // boxShadow: "0px 1px 4px 0px rgba(0, 0, 0, 0.07)",
262
+ // paddingRight: '50px',
263
+ // position: 'absolute'
264
+ // // zIndex: 10
265
+ }, children: _jsxs("div", { style: {
266
+ display: 'flex',
267
+ flexDirection: 'row',
268
+ alignItems: 'flex-end',
269
+ justifyContent: 'space-between',
270
+ width: '100%',
271
+ // marginLeft: '25px'
272
+ }, children: [_jsxs("div", { style: { display: 'flex', flexDirection: 'column' }, children: [_jsx("h1", { style: {
273
+ fontSize: '14px',
274
+ paddingTop: '0px',
275
+ marginTop: '0px',
276
+ marginBottom: '4px',
277
+ fontWeight: '600',
278
+ color: state.theme.secondaryTextColor,
279
+ fontFamily: state.theme.fontFamily,
280
+ userSelect: 'none',
281
+ }, children: "Environment" }), _jsx(EnvSelectPopover, { setEnvironment: (env) => dispatch({ type: 'SET_ENVIRONMENT', payload: env }), environment: state.environment, clients: state.clients, client: state.client, setClient: (client) => dispatch({ type: 'SET_CLIENT', payload: client }), theme: state.theme, showPromote: true, handlePromote: () => setIsPromoteViewModalOpen(true) })] }), _jsx(ButtonPrimitive, { onClick: openModal, label: "Add view +" })] }) }), _jsx("div", { style: {
282
+ display: 'flex',
283
+ flexWrap: 'wrap',
284
+ paddingLeft: 25,
285
+ paddingRight: 25,
286
+ paddingTop: 25,
287
+ }, children: tables.length
288
+ ? tables.map((table) => (_jsx(TableCell, { table: table, clickTableCell: clickTableCell })))
289
+ : null }), _jsx(PromoteViewModal, { clientId: state.client._id, client: state.client, clients: state.clients, isOpen: isPromoteViewModalOpen, setIsOpen: setIsPromoteViewModalOpen, ModalComponent: ModalPrimitive, views: tables }), _jsx(ModalPrimitive, { isOpen: modalIsOpen, close: closeModal, children: _jsxs("div", { className: "flex flex-col p-[6px]", children: [_jsx(HeaderPrimitive, { label: "Add view" }), _jsx("h3", { style: {
290
+ fontWeight: 600,
291
+ fontSize: 14,
292
+ marginBottom: 6,
293
+ marginTop: 8,
294
+ color: '#212121',
295
+ }, children: "name" }), _jsx(TextInputPrimitive, { placeholder: "Enter table display name...", onChange: (e) => setName(e.target.value), value: name }), _jsx("h3", { style: {
296
+ fontWeight: 600,
297
+ fontSize: 14,
298
+ marginBottom: 6,
299
+ color: '#212121',
300
+ marginTop: 8,
301
+ }, children: "query" }), _jsx("div", { style: {
302
+ background: state.theme.backgroundColor,
303
+ // maxHeight: 700,
304
+ width: '800px',
305
+ height: '500px',
306
+ // minWidth: 450,
307
+ // overflowY: "scroll",
308
+ // padding: "20px 30px 20px 20px",
309
+ // marginLeft: 20,
310
+ borderTopLeftRadius: 6,
311
+ borderBottomLeftRadius: 6,
312
+ borderTopRightRadius: 0,
313
+ borderBottomRightRadius: 0,
314
+ overflow: 'hidden',
315
+ }, children: _jsx(MonacoEditor, { height: "500px", width: "100%", defaultLanguage: "pgsql", defaultValue: "", value: editViewQuery, loading: _jsx("div", {}), options: {
316
+ wordWrap: 'on',
317
+ minimap: {
318
+ enabled: false,
319
+ },
320
+ padding: { top: 16 },
321
+ }, onChange: (query) => setEditViewQuery(query), beforeMount: (monaco) => defineEditorTheme(monaco, state.theme), onMount: setEditorTheme }) }), _jsx("div", { style: { height: 20 } }), _jsx(ButtonPrimitive, { label: "Add view +", onClick: handleAddTable })] }) }), _jsx(ModalPrimitive, { isOpen: editModalIsOpen, close: closeEditModal, children: _jsxs("div", { className: "flex flex-col p-[6px]", children: [_jsxs("div", { style: {
322
+ display: 'flex',
323
+ flexDirection: 'row',
324
+ alignItems: 'center',
325
+ justifyContent: 'space-between',
326
+ // width: '100%'
327
+ }, children: [_jsx("h1", { style: {
328
+ fontSize: '24px',
329
+ paddingTop: '0px',
330
+ marginTop: '0px',
331
+ marginBottom: '0px',
332
+ fontWeight: 'bold',
333
+ color: '#384151',
334
+ }, children: "Edit view" }), _jsx("button", { style: {
335
+ background: 'transparent',
336
+ border: 'none',
337
+ outline: 'none',
338
+ height: 24,
339
+ width: 24,
340
+ cursor: 'pointer',
341
+ }, onClick: closeEditModal, children: _jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", height: "24px", width: "24px", children: [_jsx("line", { x1: "18", x2: "6", y1: "6", y2: "18" }), _jsx("line", { x1: "6", x2: "18", y1: "6", y2: "18" })] }) })] }), _jsx("h3", { style: {
342
+ fontWeight: '600',
343
+ fontSize: '14px',
344
+ marginBottom: '6px',
345
+ color: '#212121',
346
+ }, children: "name" }), _jsx(TextInputPrimitive, { placeholder: "Enter table display name...", onChange: (e) => setEditName(e.target.value), value: editName }), _jsx("h3", { style: {
347
+ fontWeight: '600',
348
+ fontSize: '14px',
349
+ marginBottom: '6px',
350
+ color: '#212121',
351
+ }, children: "query" }), _jsx("div", { style: {
352
+ background: state.theme.backgroundColor,
353
+ // maxHeight: 700,
354
+ width: '520px',
355
+ height: '300px',
356
+ // minWidth: 450,
357
+ // overflowY: "scroll",
358
+ // padding: "20px 30px 20px 20px",
359
+ // marginLeft: 20,
360
+ borderTopLeftRadius: 6,
361
+ borderBottomLeftRadius: 6,
362
+ borderTopRightRadius: 0,
363
+ borderBottomRightRadius: 0,
364
+ overflow: 'hidden',
365
+ }, children: _jsx(MonacoEditor, { height: "300px", width: "520px", defaultLanguage: "pgsql", defaultValue: "", value: editViewQuery, loading: _jsx("div", {}), options: {
366
+ wordWrap: 'on',
367
+ minimap: {
368
+ enabled: false,
369
+ },
370
+ padding: { top: 16 },
371
+ }, onChange: (query) => setEditViewQuery(query), beforeMount: (monaco) => defineEditorTheme(monaco, state.theme), onMount: setEditorTheme }) }), _jsxs("div", { style: {
372
+ display: 'flex',
373
+ flexDirection: 'row',
374
+ alignItems: 'center',
375
+ marginTop: 20,
376
+ gap: 8,
377
+ }, children: [_jsx(ButtonPrimitive, { onClick: handleEditTable, label: "Save changes" }), _jsx(SecondaryButtonPrimitive, { onClick: handleClickFirstDelete, label: "Delete" })] })] }) }), _jsx(ModalPrimitive, { isOpen: deleteModalIsOpen, close: closeDeleteModal, children: _jsxs("div", { style: {
378
+ display: 'flex',
379
+ flexDirection: 'column',
380
+ padding: '6px',
381
+ }, children: [_jsxs("h1", { style: {
382
+ fontSize: '1.25rem',
383
+ paddingTop: '0px',
384
+ marginTop: '0px',
385
+ marginBottom: '12px',
386
+ fontWeight: 'bold',
387
+ color: '#212121',
388
+ }, children: ["Confirm delete \"", tableToBeDeleted, "\" view"] }), _jsx("h3", { style: {
389
+ fontWeight: '600',
390
+ fontSize: '0.875rem',
391
+ marginBottom: '6px',
392
+ color: '#212121',
393
+ }, children: "View name" }), _jsx(TextInputPrimitive, { placeholder: "Type view name to confirm delete...", onChange: (e) => setDeleteName(e.target.value), value: deleteName }), _jsx("div", { style: { height: 20 } }), _jsx(ButtonPrimitive, { onClick: handleDeleteTable, label: `Confirm delete ${tableToBeDeleted}` })] }) })] }) }));
394
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Initial date range default options.
3
+ */
4
+ export declare const InitialDateRangeOptions: readonly [{
5
+ readonly value: "LAST_90_DAYS";
6
+ readonly label: "Last 90 days";
7
+ }, {
8
+ readonly value: "LAST_30_DAYS";
9
+ readonly label: "Last 30 days";
10
+ }, {
11
+ readonly value: "CURRENT_MONTH";
12
+ readonly label: "Current Month";
13
+ }, {
14
+ readonly value: "CURRENT_WEEK";
15
+ readonly label: "Current Week";
16
+ }, {
17
+ readonly value: "ALL_TIME";
18
+ readonly label: "All time";
19
+ }];
20
+ export type DateRangeOption = (typeof InitialDateRangeOptions)[number];
21
+ export declare const defaultDateRange: {
22
+ readonly value: "LAST_90_DAYS";
23
+ readonly label: "Last 90 days";
24
+ };
25
+ export declare const QUILL_SERVER = "https://quill-344421.uc.r.appspot.com";
26
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/utils/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;EAM1B,CAAC;AACX,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,uBAAuB,CAAC,CAAC,MAAM,CAAC,CAAC;AACvE,eAAO,MAAM,gBAAgB;;;CAA6B,CAAC;AAG3D,eAAO,MAAM,YAAY,0CAA0C,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Initial date range default options.
3
+ */
4
+ export const InitialDateRangeOptions = [
5
+ { value: 'LAST_90_DAYS', label: 'Last 90 days' },
6
+ { value: 'LAST_30_DAYS', label: 'Last 30 days' },
7
+ { value: 'CURRENT_MONTH', label: 'Current Month' },
8
+ { value: 'CURRENT_WEEK', label: 'Current Week' },
9
+ { value: 'ALL_TIME', label: 'All time' },
10
+ ];
11
+ export const defaultDateRange = InitialDateRangeOptions[0];
12
+ // export const QUILL_SERVER = 'http://localhost:8080';
13
+ export const QUILL_SERVER = 'https://quill-344421.uc.r.appspot.com';
@@ -0,0 +1,34 @@
1
+ export interface DatabaseConnection {
2
+ type: string;
3
+ connectionString: string;
4
+ }
5
+ export interface ConnectionError {
6
+ message: string;
7
+ schemas: string[];
8
+ schemaName?: string;
9
+ }
10
+ interface PostgresConnection extends DatabaseConnection {
11
+ user: string;
12
+ password: string;
13
+ host: string;
14
+ databaseName: string;
15
+ port: string;
16
+ }
17
+ interface MySQLConnection extends DatabaseConnection {
18
+ user: string;
19
+ password: string;
20
+ host: string;
21
+ databaseName: string;
22
+ port: string;
23
+ }
24
+ export type ConnectionType = DatabaseConnection | PostgresConnection | MySQLConnection;
25
+ export interface DatabaseDefaultInfo {
26
+ label: string;
27
+ value: string;
28
+ imageUrl: string;
29
+ }
30
+ export declare const DATABASE_DEFAULT_INFO: DatabaseDefaultInfo[];
31
+ export declare function getDatabaseConnectionFormat(databaseName: string): ConnectionType | undefined;
32
+ export declare function formConnectionString(connection: DatabaseConnection | undefined): string;
33
+ export {};
34
+ //# sourceMappingURL=databases.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"databases.d.ts","sourceRoot":"","sources":["../../src/utils/databases.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,UAAU,kBAAmB,SAAQ,kBAAkB;IACrD,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,UAAU,eAAgB,SAAQ,kBAAkB;IAClD,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,MAAM,cAAc,GACtB,kBAAkB,GAClB,kBAAkB,GAClB,eAAe,CAAC;AAEpB,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,qBAAqB,EAAE,mBAAmB,EAatD,CAAC;AAEF,wBAAgB,2BAA2B,CACzC,YAAY,EAAE,MAAM,GACnB,cAAc,GAAG,SAAS,CAuB5B;AAED,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,kBAAkB,GAAG,SAAS,UAa3C"}
@@ -0,0 +1,51 @@
1
+ export const DATABASE_DEFAULT_INFO = [
2
+ {
3
+ label: 'PostgreSQL',
4
+ value: 'PostgreSQL',
5
+ imageUrl: 'https://upload.wikimedia.org/wikipedia/commons/thumb/2/29/Postgresql_elephant.svg/640px-Postgresql_elephant.svg.png',
6
+ },
7
+ // {
8
+ // label: 'MySQL',
9
+ // value: 'mysql',
10
+ // imageUrl:
11
+ // 'https://d1.awsstatic.com/asset-repository/products/amazon-rds/1024px-MySQL.ff87215b43fd7292af172e2a5d9b844217262571.png',
12
+ // },
13
+ ];
14
+ export function getDatabaseConnectionFormat(databaseName) {
15
+ if (databaseName === 'PostgreSQL') {
16
+ return {
17
+ user: '',
18
+ password: '',
19
+ host: '',
20
+ databaseName: '',
21
+ port: '',
22
+ type: 'PostgreSQL',
23
+ connectionString: '',
24
+ };
25
+ }
26
+ else if (databaseName === 'mysql') {
27
+ return {
28
+ user: '',
29
+ password: '',
30
+ host: '',
31
+ databaseName: '',
32
+ port: '',
33
+ type: 'mysql',
34
+ connectionString: '',
35
+ };
36
+ }
37
+ return undefined;
38
+ }
39
+ export function formConnectionString(connection) {
40
+ if (!connection) {
41
+ return 'There is no connection info';
42
+ }
43
+ if (connection.connectionString !== '') {
44
+ return connection.connectionString;
45
+ }
46
+ if (connection.type === 'PostgreSQL') {
47
+ const typedConnection = connection;
48
+ return `postgres://${typedConnection.user}:${typedConnection.password}@${typedConnection.host}:${typedConnection.port}/${typedConnection.databaseName}`;
49
+ }
50
+ return '';
51
+ }
@@ -0,0 +1,2 @@
1
+ export declare const delay: (ms: number) => Promise<unknown>;
2
+ //# sourceMappingURL=delay.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delay.d.ts","sourceRoot":"","sources":["../../src/utils/delay.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,KAAK,OAAQ,MAAM,qBAE/B,CAAC"}
@@ -0,0 +1,3 @@
1
+ export const delay = (ms) => {
2
+ return new Promise((resolve) => setTimeout(resolve, ms));
3
+ };
@@ -0,0 +1,22 @@
1
+ export interface SchemaDetails {
2
+ schemas: string[];
3
+ tables?: string[];
4
+ columns?: string[];
5
+ organizations?: {
6
+ id: any;
7
+ name: string;
8
+ }[];
9
+ foreignKeys?: string[];
10
+ selectedFields: {
11
+ schema: string;
12
+ table?: string;
13
+ organizationIdField?: string;
14
+ customerNameField?: string;
15
+ defaultOrg?: {
16
+ id: string;
17
+ name: string;
18
+ };
19
+ foreignKey?: string;
20
+ };
21
+ }
22
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/utils/schema.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,aAAa,CAAC,EAAE;QAAE,EAAE,EAAE,GAAG,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC5C,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,cAAc,EAAE;QACd,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,mBAAmB,CAAC,EAAE,MAAM,CAAC;QAC7B,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,UAAU,CAAC,EAAE;YAAE,EAAE,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC;QAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;CACH"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ export interface ColumnsByTable {
2
+ tableName: string;
3
+ columns: {
4
+ columnName: string;
5
+ fieldType: string;
6
+ dataTypeId: Number;
7
+ }[];
8
+ }
9
+ //# sourceMappingURL=table.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../src/utils/table.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE;QACP,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;KACpB,EAAE,CAAC;CACL"}
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@quillsql/admin",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "description": "Admin tools for Quill",
5
- "main": "lib/index.js",
5
+ "main": "dist/index.js",
6
+ "files": [
7
+ "dist"
8
+ ],
6
9
  "scripts": {
7
10
  "build": "tsc",
8
- "watch": "tsc -w",
9
- "test": "echo \"Error: no test specified\" && exit 1"
11
+ "dev": "tsc -w",
12
+ "lint": "eslint . --max-warnings 0"
10
13
  },
11
- "files": [
12
- "lib"
13
- ],
14
14
  "dependencies": {
15
15
  "@dnd-kit/core": "^6.0.8",
16
16
  "@dnd-kit/sortable": "^7.0.2",
@@ -19,24 +19,17 @@
19
19
  "prism-react-renderer": "^1.3.5",
20
20
  "prismjs": "^1.29.0"
21
21
  },
22
- "peerDependencies": {
23
- "@quillsql/react": "^2.6.9",
24
- "react-dom": "^18.0.0"
25
- },
26
- "author": "",
27
- "license": "ISC",
28
22
  "devDependencies": {
29
- "@types/react": "^18.0.33",
30
- "@types/react-dom": "^18.0.11",
31
- "@typescript-eslint/eslint-plugin": "^5.57.1",
32
- "@typescript-eslint/parser": "^5.57.1",
33
- "eslint": "^8.37.0",
34
- "eslint-config-prettier": "^8.8.0",
35
- "eslint-plugin-prettier": "^4.2.1",
36
- "eslint-plugin-react": "^7.32.2",
37
- "glob": "^10.2.2",
38
- "prettier": "^2.8.7",
39
- "react-dom": "^18.0.0",
40
- "typescript": "^5.2.2"
41
- }
23
+ "@repo/eslint-config": "*",
24
+ "@repo/typescript-config": "*",
25
+ "@types/eslint": "^8.56.1",
26
+ "@types/node": "^20.10.6",
27
+ "@types/react": "^18.2.46",
28
+ "@types/react-dom": "^18.2.18",
29
+ "eslint": "^8.56.0",
30
+ "react": "^18.2.0",
31
+ "react-dom": "^18.2.0",
32
+ "typescript": "^5.3.3"
33
+ },
34
+ "public": true
42
35
  }