@quillsql/admin 1.6.0 → 1.6.1

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 (151) hide show
  1. package/dist/cjs/Admin.d.ts.map +1 -1
  2. package/dist/cjs/Admin.js +24 -11
  3. package/dist/cjs/AdminProvider.d.ts +2 -1
  4. package/dist/cjs/AdminProvider.d.ts.map +1 -1
  5. package/dist/cjs/AdminProvider.js +13 -24
  6. package/dist/cjs/api/ConnectionClient.d.ts +8 -0
  7. package/dist/cjs/api/ConnectionClient.d.ts.map +1 -1
  8. package/dist/cjs/api/ConnectionClient.js +42 -8
  9. package/dist/cjs/components/DashboardSelectPopover.d.ts.map +1 -1
  10. package/dist/cjs/components/DashboardSelectPopover.js +20 -3
  11. package/dist/cjs/components/DropDownMenuWithLabel.d.ts.map +1 -1
  12. package/dist/cjs/components/DropDownMenuWithLabel.js +4 -35
  13. package/dist/cjs/components/EmptyDashboardComponent/index.d.ts.map +1 -1
  14. package/dist/cjs/components/EmptyDashboardComponent/index.js +11 -9
  15. package/dist/cjs/components/QuillSelect.d.ts.map +1 -1
  16. package/dist/cjs/components/QuillSelect.js +2 -2
  17. package/dist/cjs/components/SegmentedControl.d.ts +4 -2
  18. package/dist/cjs/components/SegmentedControl.d.ts.map +1 -1
  19. package/dist/cjs/components/SegmentedControl.js +22 -16
  20. package/dist/cjs/components/SqlTextEditor.d.ts +9 -1
  21. package/dist/cjs/components/SqlTextEditor.d.ts.map +1 -1
  22. package/dist/cjs/components/SqlTextEditor.js +60 -12
  23. package/dist/cjs/components/UiComponents.d.ts.map +1 -1
  24. package/dist/cjs/components/UiComponents.js +11 -2
  25. package/dist/cjs/constants/dataTypes.d.ts +2 -0
  26. package/dist/cjs/constants/dataTypes.d.ts.map +1 -0
  27. package/dist/cjs/constants/dataTypes.js +21 -0
  28. package/dist/cjs/forms/client_onboard/ConnectDatabase.d.ts.map +1 -1
  29. package/dist/cjs/forms/client_onboard/ConnectDatabase.js +9 -17
  30. package/dist/cjs/forms/client_onboard/CreateSqlViews.d.ts.map +1 -1
  31. package/dist/cjs/forms/client_onboard/CreateSqlViews.js +24 -11
  32. package/dist/cjs/forms/sql_views/CreateEditSqlView.d.ts +4 -1
  33. package/dist/cjs/forms/sql_views/CreateEditSqlView.d.ts.map +1 -1
  34. package/dist/cjs/forms/sql_views/CreateEditSqlView.js +87 -36
  35. package/dist/cjs/modals/EditFiltersModal.d.ts.map +1 -1
  36. package/dist/cjs/modals/EditFiltersModal.js +13 -3
  37. package/dist/cjs/modals/NewDashboardModal.js +2 -2
  38. package/dist/cjs/modals/PromoteDashModal.js +2 -2
  39. package/dist/cjs/modals/PromoteViewModal.d.ts +2 -1
  40. package/dist/cjs/modals/PromoteViewModal.d.ts.map +1 -1
  41. package/dist/cjs/modals/PromoteViewModal.js +46 -36
  42. package/dist/cjs/primitives/TextInputPrimitive.d.ts +1 -0
  43. package/dist/cjs/primitives/TextInputPrimitive.d.ts.map +1 -1
  44. package/dist/cjs/primitives/TextInputPrimitive.js +35 -20
  45. package/dist/cjs/public_components/CreateEnvironment.d.ts +2 -1
  46. package/dist/cjs/public_components/CreateEnvironment.d.ts.map +1 -1
  47. package/dist/cjs/public_components/CreateEnvironment.js +4 -1
  48. package/dist/cjs/public_components/DashboardBuilder.d.ts.map +1 -1
  49. package/dist/cjs/public_components/DashboardBuilder.js +67 -156
  50. package/dist/cjs/public_components/DashboardManager.d.ts.map +1 -1
  51. package/dist/cjs/public_components/DashboardManager.js +72 -73
  52. package/dist/cjs/public_components/SQLViewManager.d.ts +1 -0
  53. package/dist/cjs/public_components/SQLViewManager.d.ts.map +1 -1
  54. package/dist/cjs/public_components/SQLViewManager.js +216 -40
  55. package/dist/cjs/utils/astProcessing.d.ts +2 -0
  56. package/dist/cjs/utils/astProcessing.d.ts.map +1 -0
  57. package/dist/cjs/utils/astProcessing.js +41 -0
  58. package/dist/cjs/utils/astProcessing.uspec.d.ts +2 -0
  59. package/dist/cjs/utils/astProcessing.uspec.d.ts.map +1 -0
  60. package/dist/cjs/utils/astProcessing.uspec.js +26 -0
  61. package/dist/cjs/utils/columnProcessing.d.ts +3 -0
  62. package/dist/cjs/utils/columnProcessing.d.ts.map +1 -0
  63. package/dist/cjs/utils/columnProcessing.js +42 -0
  64. package/dist/cjs/utils/dataEditor.d.ts +2 -2
  65. package/dist/cjs/utils/dataEditor.d.ts.map +1 -1
  66. package/dist/cjs/utils/dataEditor.js +4 -2
  67. package/dist/cjs/utils/databases.d.ts +0 -1
  68. package/dist/cjs/utils/databases.d.ts.map +1 -1
  69. package/dist/cjs/utils/databases.js +5 -6
  70. package/dist/cjs/utils/monacoAutocomplete.d.ts +21 -0
  71. package/dist/cjs/utils/monacoAutocomplete.d.ts.map +1 -0
  72. package/dist/cjs/utils/monacoAutocomplete.js +250 -0
  73. package/dist/cjs/utils/schema.d.ts +5 -0
  74. package/dist/cjs/utils/schema.d.ts.map +1 -1
  75. package/dist/cjs/utils/schema.js +129 -0
  76. package/dist/esm/Admin.d.ts.map +1 -1
  77. package/dist/esm/Admin.js +24 -11
  78. package/dist/esm/AdminProvider.d.ts +2 -1
  79. package/dist/esm/AdminProvider.d.ts.map +1 -1
  80. package/dist/esm/AdminProvider.js +13 -24
  81. package/dist/esm/api/ConnectionClient.d.ts +8 -0
  82. package/dist/esm/api/ConnectionClient.d.ts.map +1 -1
  83. package/dist/esm/api/ConnectionClient.js +42 -8
  84. package/dist/esm/components/DashboardSelectPopover.d.ts.map +1 -1
  85. package/dist/esm/components/DashboardSelectPopover.js +20 -3
  86. package/dist/esm/components/DropDownMenuWithLabel.d.ts.map +1 -1
  87. package/dist/esm/components/DropDownMenuWithLabel.js +4 -35
  88. package/dist/esm/components/EmptyDashboardComponent/index.d.ts.map +1 -1
  89. package/dist/esm/components/EmptyDashboardComponent/index.js +11 -9
  90. package/dist/esm/components/QuillSelect.d.ts.map +1 -1
  91. package/dist/esm/components/QuillSelect.js +2 -2
  92. package/dist/esm/components/SegmentedControl.d.ts +4 -2
  93. package/dist/esm/components/SegmentedControl.d.ts.map +1 -1
  94. package/dist/esm/components/SegmentedControl.js +22 -16
  95. package/dist/esm/components/SqlTextEditor.d.ts +9 -1
  96. package/dist/esm/components/SqlTextEditor.d.ts.map +1 -1
  97. package/dist/esm/components/SqlTextEditor.js +59 -11
  98. package/dist/esm/components/UiComponents.d.ts.map +1 -1
  99. package/dist/esm/components/UiComponents.js +12 -3
  100. package/dist/esm/constants/dataTypes.d.ts +2 -0
  101. package/dist/esm/constants/dataTypes.d.ts.map +1 -0
  102. package/dist/esm/constants/dataTypes.js +18 -0
  103. package/dist/esm/forms/client_onboard/ConnectDatabase.d.ts.map +1 -1
  104. package/dist/esm/forms/client_onboard/ConnectDatabase.js +9 -17
  105. package/dist/esm/forms/client_onboard/CreateSqlViews.d.ts.map +1 -1
  106. package/dist/esm/forms/client_onboard/CreateSqlViews.js +25 -12
  107. package/dist/esm/forms/sql_views/CreateEditSqlView.d.ts +4 -1
  108. package/dist/esm/forms/sql_views/CreateEditSqlView.d.ts.map +1 -1
  109. package/dist/esm/forms/sql_views/CreateEditSqlView.js +87 -36
  110. package/dist/esm/modals/EditFiltersModal.d.ts.map +1 -1
  111. package/dist/esm/modals/EditFiltersModal.js +13 -3
  112. package/dist/esm/modals/NewDashboardModal.js +2 -2
  113. package/dist/esm/modals/PromoteDashModal.js +2 -2
  114. package/dist/esm/modals/PromoteViewModal.d.ts +2 -1
  115. package/dist/esm/modals/PromoteViewModal.d.ts.map +1 -1
  116. package/dist/esm/modals/PromoteViewModal.js +50 -40
  117. package/dist/esm/primitives/TextInputPrimitive.d.ts +1 -0
  118. package/dist/esm/primitives/TextInputPrimitive.d.ts.map +1 -1
  119. package/dist/esm/primitives/TextInputPrimitive.js +33 -21
  120. package/dist/esm/public_components/CreateEnvironment.d.ts +2 -1
  121. package/dist/esm/public_components/CreateEnvironment.d.ts.map +1 -1
  122. package/dist/esm/public_components/CreateEnvironment.js +4 -1
  123. package/dist/esm/public_components/DashboardBuilder.d.ts.map +1 -1
  124. package/dist/esm/public_components/DashboardBuilder.js +68 -157
  125. package/dist/esm/public_components/DashboardManager.d.ts.map +1 -1
  126. package/dist/esm/public_components/DashboardManager.js +73 -74
  127. package/dist/esm/public_components/SQLViewManager.d.ts +1 -0
  128. package/dist/esm/public_components/SQLViewManager.d.ts.map +1 -1
  129. package/dist/esm/public_components/SQLViewManager.js +216 -42
  130. package/dist/esm/utils/astProcessing.d.ts +2 -0
  131. package/dist/esm/utils/astProcessing.d.ts.map +1 -0
  132. package/dist/esm/utils/astProcessing.js +37 -0
  133. package/dist/esm/utils/astProcessing.uspec.d.ts +2 -0
  134. package/dist/esm/utils/astProcessing.uspec.d.ts.map +1 -0
  135. package/dist/esm/utils/astProcessing.uspec.js +24 -0
  136. package/dist/esm/utils/columnProcessing.d.ts +3 -0
  137. package/dist/esm/utils/columnProcessing.d.ts.map +1 -0
  138. package/dist/esm/utils/columnProcessing.js +37 -0
  139. package/dist/esm/utils/dataEditor.d.ts +2 -2
  140. package/dist/esm/utils/dataEditor.d.ts.map +1 -1
  141. package/dist/esm/utils/dataEditor.js +4 -2
  142. package/dist/esm/utils/databases.d.ts +0 -1
  143. package/dist/esm/utils/databases.d.ts.map +1 -1
  144. package/dist/esm/utils/databases.js +5 -6
  145. package/dist/esm/utils/monacoAutocomplete.d.ts +21 -0
  146. package/dist/esm/utils/monacoAutocomplete.d.ts.map +1 -0
  147. package/dist/esm/utils/monacoAutocomplete.js +245 -0
  148. package/dist/esm/utils/schema.d.ts +5 -0
  149. package/dist/esm/utils/schema.d.ts.map +1 -1
  150. package/dist/esm/utils/schema.js +126 -1
  151. package/package.json +3 -2
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getDuplicateColumns = void 0;
6
7
  const jsx_runtime_1 = require("react/jsx-runtime");
7
8
  const react_1 = require("react");
8
9
  const primitives_1 = require("../primitives");
@@ -14,6 +15,28 @@ const dataEditor_1 = require("../utils/dataEditor");
14
15
  const ConnectionClient_1 = require("../api/ConnectionClient");
15
16
  const UiComponents_1 = require("../components/UiComponents");
16
17
  const DatabaseMismatchCard_1 = __importDefault(require("../components/DatabaseMismatchCard"));
18
+ const TogglePrimitive_1 = __importDefault(require("../primitives/TogglePrimitive"));
19
+ const SegmentedControl_1 = require("../components/SegmentedControl");
20
+ const SqlTextEditor_1 = __importDefault(require("../components/SqlTextEditor"));
21
+ const react_2 = require("@quillsql/react");
22
+ const schema_1 = require("../utils/schema");
23
+ const modals_1 = require("../modals");
24
+ const getDuplicateColumns = (columns) => {
25
+ if (!columns) {
26
+ return [];
27
+ }
28
+ const columnCount = columns?.reduce((acc, curr) => {
29
+ if (acc[curr.field]) {
30
+ acc[curr.field] += 1;
31
+ }
32
+ else {
33
+ acc[curr.field] = 1;
34
+ }
35
+ return acc;
36
+ }, {});
37
+ return Object.keys(columnCount).filter((column) => columnCount[column] > 1);
38
+ };
39
+ exports.getDuplicateColumns = getDuplicateColumns;
17
40
  function SQLViewManager({ containerStyle, }) {
18
41
  const [tables, setTables] = (0, react_1.useState)(undefined);
19
42
  const [modalIsOpen, setIsOpen] = (0, react_1.useState)(false);
@@ -31,13 +54,17 @@ function SQLViewManager({ containerStyle, }) {
31
54
  const [allTableData, setAllTableData] = (0, react_1.useState)([]);
32
55
  const [referencedTablesMap, setReferencedTablesMap] = (0, react_1.useState)({});
33
56
  const [schemaIsLoading, setSchemaIsLoading] = (0, react_1.useState)(false);
57
+ const [customFieldInfo, setCustomFieldInfo] = (0, react_1.useState)(undefined);
58
+ const [provider, setProvider] = (0, react_1.useState)(null);
34
59
  const [initialSqlView, setInitialSqlView] = (0, react_1.useState)(undefined);
60
+ const [submittingView, setSubmittingView] = (0, react_1.useState)(false);
35
61
  const parentRef = (0, react_1.useRef)(null);
36
62
  const { state, dispatch } = (0, AdminProvider_1.useAdmin)();
37
63
  const closeEditModal = () => {
38
64
  setEditModalIsOpen(false);
39
65
  setEditName('');
40
66
  setEditViewQuery('');
67
+ setCustomFieldInfo(undefined);
41
68
  };
42
69
  const clickTableCell = (table) => {
43
70
  setEditName(table.name);
@@ -48,29 +75,18 @@ function SQLViewManager({ containerStyle, }) {
48
75
  name: table.name,
49
76
  query: table.viewQuery,
50
77
  });
78
+ setCustomFieldInfo(table.customFieldInfo);
51
79
  setEditModalIsOpen(true);
52
80
  };
53
81
  const getTables = async () => {
54
- const response = await fetch(`${state.queryEndpoint}`, {
55
- method: 'POST',
56
- headers: {
57
- ...state.queryHeaders,
58
- 'Content-Type': 'application/json',
59
- },
60
- body: JSON.stringify({
61
- metadata: {
62
- clientId: state.client._id,
63
- publicKey: state.client._id,
64
- task: 'schema',
65
- databaseType: state.client.databaseType,
66
- },
67
- }),
68
- });
69
- if (!response.ok) {
70
- throw new Error('Failed to fetch tables data');
71
- }
72
- const data = await response.json();
73
- setTables(data.data.tables);
82
+ const schemaData = await (0, schema_1.getSchemaInfo)({
83
+ queryEndpoint: state.queryEndpoint,
84
+ queryHeaders: state.queryHeaders,
85
+ publicKey: state.client._id,
86
+ customerId: state.client.customerId,
87
+ gatherSchemaData: false,
88
+ }, 'svm');
89
+ setTables(schemaData);
74
90
  };
75
91
  const getSchemaTableDetails = async () => {
76
92
  setSchemaIsLoading(true);
@@ -111,7 +127,7 @@ function SQLViewManager({ containerStyle, }) {
111
127
  isSubscribed = false;
112
128
  };
113
129
  }, [state.client]);
114
- const handleModalSubmit = async (submitRequest, query, name, id, columns) => {
130
+ const handleModalSubmit = async (submitRequest, query, name, id, columns, customFieldInfo) => {
115
131
  try {
116
132
  const prevTableName = tables?.find((table) => table._id === id)?.name;
117
133
  const isPlural = referencedTablesMap &&
@@ -119,21 +135,29 @@ function SQLViewManager({ containerStyle, }) {
119
135
  referencedTablesMap[prevTableName].length > 1
120
136
  ? 's'
121
137
  : '';
138
+ let trimmedName = name?.trim() || undefined;
139
+ let submitResponse;
122
140
  switch (submitRequest) {
123
141
  case 'add':
124
- if (!name) {
142
+ if (!trimmedName) {
125
143
  alert('No name found');
126
144
  return;
127
145
  }
128
- if (tables?.map((table) => table.name).includes(name)) {
146
+ if (tables?.map((table) => table.name).includes(trimmedName)) {
129
147
  alert('Name already exists');
130
148
  return;
131
149
  }
132
- if (!/^[a-z0-9_]+$/.test(name)) {
133
- alert('Name must be lowercase with no spaces');
150
+ // determine if there are duplicate names if there are then alert the user
151
+ let duplicateColumns = (0, exports.getDuplicateColumns)(columns);
152
+ if (duplicateColumns.length > 0) {
153
+ alert(`Ambiguous column names found. Either use aliases or remove the column to make every column name unique: \n\n${duplicateColumns.join('\n')}`);
134
154
  return;
135
155
  }
136
- await (0, dataEditor_1.addSqlView)(name, query, state);
156
+ if (!/^[a-z0-9_]+$/.test(trimmedName)) {
157
+ alert('Names can only include lowercase letters, numbers, and underscores');
158
+ return;
159
+ }
160
+ submitResponse = await (0, dataEditor_1.addSqlView)(trimmedName, query, customFieldInfo, state);
137
161
  break;
138
162
  case 'edit':
139
163
  if (!id) {
@@ -165,23 +189,29 @@ function SQLViewManager({ containerStyle, }) {
165
189
  return;
166
190
  }
167
191
  }
168
- if (!name) {
192
+ if (!trimmedName) {
169
193
  alert('No name found');
170
194
  return;
171
195
  }
172
- if (!/^[a-z0-9_]+$/.test(name)) {
196
+ if (!/^[a-z0-9_]+$/.test(trimmedName)) {
173
197
  alert('Names can only include lowercase letters, numbers, and underscores');
174
198
  return;
175
199
  }
200
+ // determine if there are duplicate names if there are then alert the user
201
+ const duplicateColumns2 = (0, exports.getDuplicateColumns)(columns);
202
+ if (duplicateColumns2.length > 0) {
203
+ alert(`Ambiguous column names found. Either use aliases or remove the column to make every column name unique: \n\n${duplicateColumns2.join('\n')}`);
204
+ return;
205
+ }
176
206
  // check if the tableName is present excluding the table with the same id
177
207
  if (tables
178
208
  ?.filter((table) => table._id !== id)
179
209
  .map((table) => table.name)
180
- .includes(name)) {
210
+ .includes(trimmedName)) {
181
211
  alert('Name already exists');
182
212
  return;
183
213
  }
184
- await (0, dataEditor_1.editSQLView)(name, query, id, state);
214
+ submitResponse = await (0, dataEditor_1.editSQLView)(trimmedName, query, id, customFieldInfo, state);
185
215
  break;
186
216
  case 'delete':
187
217
  if (!id) {
@@ -190,10 +220,13 @@ function SQLViewManager({ containerStyle, }) {
190
220
  }
191
221
  // Determine if the table is referenced in other charts
192
222
  if (referencedTablesMap && referencedTablesMap[prevTableName]) {
193
- alert(`This table is referenced in the following dashboard${isPlural}/chart${isPlural}.\n\n${referencedTablesMap[prevTableName]?.join('\n')} \n\nPlease delete those charts before deleting this table.`);
223
+ const referencedTableInfo = referencedTablesMap[prevTableName].map((info) => {
224
+ return `${info.dashboardName} - ${info.reportName}`;
225
+ });
226
+ alert(`This table is referenced in the following dashboard${isPlural}/chart${isPlural}.\n\n${referencedTableInfo.join('\n')} \n\nPlease delete those charts before deleting this table.`);
194
227
  return;
195
228
  }
196
- await (0, dataEditor_1.deleteSQLView)(id, state);
229
+ submitResponse = await (0, dataEditor_1.deleteSQLView)(id, state);
197
230
  break;
198
231
  default:
199
232
  setEditName('');
@@ -202,6 +235,10 @@ function SQLViewManager({ containerStyle, }) {
202
235
  setEditModalIsOpen(true);
203
236
  return;
204
237
  }
238
+ if (submitResponse.status !== 'success') {
239
+ alert(`There was an error processing your ${submitRequest} request.`);
240
+ return;
241
+ }
205
242
  await getTables();
206
243
  closeEditModal();
207
244
  setEditQueryView(false);
@@ -216,7 +253,7 @@ function SQLViewManager({ containerStyle, }) {
216
253
  await handleModalSubmit('edit', query, name, id, columns);
217
254
  break;
218
255
  default:
219
- await handleModalSubmit('final-edit', query);
256
+ await handleModalSubmit('final-edit', query, undefined, undefined, columns);
220
257
  break;
221
258
  }
222
259
  };
@@ -287,13 +324,30 @@ function SQLViewManager({ containerStyle, }) {
287
324
  ? tables.map((table) => ((0, jsx_runtime_1.jsx)(Admin_1.TableCell, { table: table, clickTableCell: clickTableCell }, table._id)))
288
325
  : null }, 'edit-view-query')) : ((0, jsx_runtime_1.jsx)(CreateEditSqlView_1.default, { containerStyle: {}, initialSqlView: initialSqlView, closeEditView: () => setEditQueryView(false), addEditView: (request, name, query, id, columns) => {
289
326
  handleEditAddView(request, name, query, id, columns);
290
- }, allTableData: allTableData, schemaIsLoading: schemaIsLoading })) }))] }), (0, jsx_runtime_1.jsx)(EditAddViewModal, { viewName: editName, viewQuery: editViewQuery, viewId: editViewId, editModalIsOpen: editModalIsOpen, closeEditModal: closeEditModal, submit: handleModalSubmit, state: state, onEditViewClick: () => setEditQueryView(true) })] }));
327
+ }, setProvider: (provider) => { setProvider(provider); }, provider: provider, allTableData: allTableData, schemaIsLoading: schemaIsLoading })) }))] }), (0, jsx_runtime_1.jsx)(modals_1.PromoteViewModal, { clientId: state.client._id, client: state.client, clients: state.clients, isOpen: isPromoteViewModalOpen, setIsOpen: setIsPromoteViewModalOpen, ModalComponent: UiComponents_1.MemoizedModal, views: tables || [], parentRef: parentRef }), (0, jsx_runtime_1.jsx)(EditAddViewModal, { viewName: editName, viewQuery: editViewQuery, viewId: editViewId, editModalIsOpen: editModalIsOpen, customFieldInfo: customFieldInfo, closeEditModal: closeEditModal, submit: async (submitRequest, query, name, id, columns, customFieldInfo) => {
328
+ if (submitRequest !== 'delete') {
329
+ setSubmittingView(true);
330
+ }
331
+ await handleModalSubmit(submitRequest, query, name, id, columns, customFieldInfo);
332
+ setSubmittingView(false);
333
+ }, state: state, onEditViewClick: () => setEditQueryView(true), isLoading: submittingView })] }));
291
334
  }
292
335
  exports.default = SQLViewManager;
293
- function EditAddViewModal({ viewName, viewQuery, viewId, editModalIsOpen, closeEditModal, submit, state, onEditViewClick = () => { }, }) {
336
+ function EditAddViewModal({ viewName, viewQuery, viewId, editModalIsOpen, customFieldInfo, closeEditModal, submit, state, onEditViewClick = () => { }, isLoading, }) {
294
337
  const [name, setName] = (0, react_1.useState)(viewName);
295
338
  const [query, setQuery] = (0, react_1.useState)(viewQuery);
296
339
  const [id, setId] = (0, react_1.useState)(viewId);
340
+ const [useCustomField, setUseCustomField] = (0, react_1.useState)(customFieldInfo ? true : false);
341
+ const [customFieldType, setCustomFieldType] = (0, react_1.useState)(customFieldInfo ? customFieldInfo.type : 'eav');
342
+ const [customFieldQuery, setCustomFieldQuery] = (0, react_1.useState)(customFieldInfo ? customFieldInfo.query : '');
343
+ const [runQueryButtonLoading, setRunQueryButtonLoading] = (0, react_1.useState)(false);
344
+ const [tableData, setTableData] = (0, react_1.useState)(undefined);
345
+ const [errorInfo, setErrorInfo] = (0, react_1.useState)({ show: false, message: '' });
346
+ (0, react_1.useEffect)(() => {
347
+ setCustomFieldQuery(customFieldInfo?.query || '');
348
+ setCustomFieldType(customFieldInfo?.type || 'eav');
349
+ setUseCustomField(customFieldInfo ? true : false);
350
+ }, [customFieldInfo]);
297
351
  (0, react_1.useEffect)(() => {
298
352
  setName(viewName);
299
353
  }, [viewName]);
@@ -303,7 +357,15 @@ function EditAddViewModal({ viewName, viewQuery, viewId, editModalIsOpen, closeE
303
357
  (0, react_1.useEffect)(() => {
304
358
  setId(viewId);
305
359
  }, [viewId]);
306
- return ((0, jsx_runtime_1.jsx)(primitives_1.ModalPrimitive, { isOpen: editModalIsOpen, close: closeEditModal, children: (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col p-[6px]", children: [(0, jsx_runtime_1.jsxs)("div", { style: {
360
+ return ((0, jsx_runtime_1.jsx)(primitives_1.ModalPrimitive, { isOpen: editModalIsOpen, close: () => {
361
+ setUseCustomField(false);
362
+ setCustomFieldType('eav');
363
+ setCustomFieldQuery('');
364
+ setTableData(undefined);
365
+ setErrorInfo({ show: false, message: '' });
366
+ setName('');
367
+ closeEditModal();
368
+ }, children: (0, jsx_runtime_1.jsxs)("div", { style: { height: '100%', overflow: 'scroll', width: '100%' }, children: [(0, jsx_runtime_1.jsxs)("div", { style: {
307
369
  display: 'flex',
308
370
  flexDirection: 'row',
309
371
  alignItems: 'center',
@@ -336,7 +398,6 @@ function EditAddViewModal({ viewName, viewQuery, viewId, editModalIsOpen, closeE
336
398
  fontWeight: 'medium',
337
399
  height: '120px',
338
400
  boxShadow: '0 1px 2px 0 rgba(0,0,0,.05)',
339
- width: '500px',
340
401
  background: 'linear-gradient(white 50%, transparent)',
341
402
  color: state.theme?.primaryTextColor,
342
403
  borderWidth: '1px',
@@ -370,7 +431,81 @@ function EditAddViewModal({ viewName, viewQuery, viewId, editModalIsOpen, closeE
370
431
  } }), viewName && ((0, jsx_runtime_1.jsx)("div", { style: { position: 'absolute', bottom: '10px', right: '10px' }, children: (0, jsx_runtime_1.jsx)(UiComponents_1.MemoizedSecondaryButton, { label: 'Edit Query ↗', onClick: () => {
371
432
  closeEditModal();
372
433
  onEditViewClick();
373
- } }) }))] }), (0, jsx_runtime_1.jsxs)("div", { style: {
434
+ } }) }))] }), (0, jsx_runtime_1.jsx)("br", {}), ['65d65b57cdd8ae70a5648d9c', '665610862cf7a3000be66453'].includes(state.client._id) &&
435
+ state.client.databaseType === 'PostgreSQL' && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("h3", { style: {
436
+ fontWeight: '600',
437
+ fontSize: '14px',
438
+ marginBottom: '6px',
439
+ color: '#212121',
440
+ }, children: "Custom fields" }), (0, jsx_runtime_1.jsx)(TogglePrimitive_1.default, { value: useCustomField, onClick: () => {
441
+ setUseCustomField((useCustomField) => !useCustomField);
442
+ } }), (0, jsx_runtime_1.jsx)("br", {}), useCustomField && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("h3", { style: {
443
+ fontWeight: '600',
444
+ fontSize: '14px',
445
+ marginBottom: '6px',
446
+ marginTop: '20px',
447
+ color: '#212121',
448
+ }, children: "Custom field type" }), (0, jsx_runtime_1.jsx)(SegmentedControl_1.SegmentedControl, { theme: state.theme, value: customFieldType, onChange: (e) => {
449
+ setCustomFieldType(e);
450
+ }, left: 'EAV', right: 'JSON' }), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)("h3", { style: {
451
+ fontWeight: '600',
452
+ fontSize: '14px',
453
+ marginBottom: '6px',
454
+ color: '#212121',
455
+ }, children: "Custom field query" }), (0, jsx_runtime_1.jsx)("h3", { style: {
456
+ fontWeight: '400',
457
+ fontSize: '14px',
458
+ marginBottom: '20px',
459
+ color: '#212121',
460
+ }, children: customFieldType === 'eav'
461
+ ? `A table of custom fields. It must have these columns: ref_table, ref_id, field, value, type, ${state.client.customerFieldName.replaceAll('"', '')}.`
462
+ : `A table of custom fields. It must have these columns: ref_table, ref_column, field, ${state.client.customerFieldName.replaceAll('"', '')}.` }), (0, jsx_runtime_1.jsx)(SqlTextEditor_1.default, { value: customFieldQuery, setValue: (e) => {
463
+ setCustomFieldQuery(e);
464
+ }, setEditorMounted: () => { }, containerStyle: {
465
+ width: 800,
466
+ }, previousProvider: null, height: '150px', schema: [] }), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)(UiComponents_1.MemoizedButton, { label: 'Run query', onClick: async () => {
467
+ if (/limit\s+\d+\s*;?\s*$/i.test(customFieldQuery)) {
468
+ setErrorInfo({
469
+ show: true,
470
+ message: 'Error: Please remove the limit at the end of your query.',
471
+ });
472
+ return;
473
+ }
474
+ setErrorInfo({ show: false, message: '' });
475
+ setRunQueryButtonLoading(true);
476
+ const getSqlResults = await (0, ConnectionClient_1.getSqlViewData)(state.client._id, customFieldQuery, state.client.databaseType, state.queryEndpoint);
477
+ if (!getSqlResults.success) {
478
+ setErrorInfo({
479
+ show: true,
480
+ message: getSqlResults.error,
481
+ });
482
+ }
483
+ else {
484
+ setErrorInfo({ show: false, message: '' });
485
+ setTableData(getSqlResults);
486
+ }
487
+ setRunQueryButtonLoading(false);
488
+ } }), (0, jsx_runtime_1.jsx)("br", {}), runQueryButtonLoading && ((0, jsx_runtime_1.jsx)("div", { style: {
489
+ height: '250px',
490
+ width: '100%',
491
+ display: 'flex',
492
+ justifyContent: 'center',
493
+ alignItems: 'center',
494
+ }, children: (0, jsx_runtime_1.jsx)(UiComponents_1.LoadingSpinner, {}) })), !errorInfo.show && tableData && !runQueryButtonLoading && ((0, jsx_runtime_1.jsx)(react_2.Table, { rows: tableData.rows, columns: tableData.fields, containerStyle: {
495
+ height: '250px',
496
+ maxWidth: '800px',
497
+ paddingTop: '20px',
498
+ }, hideCSVDownloadButton: true })), errorInfo.show && ((0, jsx_runtime_1.jsx)("div", { style: {
499
+ fontSize: 15,
500
+ fontWeight: '400',
501
+ paddingTop: '20px',
502
+ }, children: (0, jsx_runtime_1.jsx)("div", { style: {
503
+ padding: 30,
504
+ background: 'rgba(0,0,0,0.02)',
505
+ display: 'inline-block',
506
+ flex: 0,
507
+ borderRadius: 6,
508
+ }, children: errorInfo.message }) }))] }))] })), (0, jsx_runtime_1.jsxs)("div", { style: {
374
509
  display: 'flex',
375
510
  flexDirection: 'row',
376
511
  alignItems: 'center',
@@ -382,6 +517,47 @@ function EditAddViewModal({ viewName, viewQuery, viewId, editModalIsOpen, closeE
382
517
  alert('Please enter a name');
383
518
  return;
384
519
  }
385
- submit(viewName ? 'edit' : 'add', query, name, id);
386
- }, label: viewName ? 'Save changes' : 'Create view' })] })] }) }));
520
+ if (useCustomField) {
521
+ const fields = tableData?.fields.map((field) => field.field);
522
+ const missingFields = [];
523
+ if (!fields) {
524
+ alert('Custom field query is missing required columns');
525
+ return;
526
+ }
527
+ if (customFieldType === 'eav') {
528
+ // make sure the tableData has the required columns
529
+ [
530
+ 'ref_table',
531
+ 'ref_id',
532
+ 'field',
533
+ 'value',
534
+ 'type',
535
+ state.client.customerFieldName.replaceAll('"', ''),
536
+ ].forEach((requiredField) => {
537
+ if (!fields.includes(requiredField)) {
538
+ missingFields.push(requiredField);
539
+ }
540
+ });
541
+ }
542
+ else {
543
+ [
544
+ 'ref_table',
545
+ 'field',
546
+ 'ref_column',
547
+ state.client.customerFieldName.replaceAll('"', ''),
548
+ ].forEach((requiredField) => {
549
+ if (!fields.includes(requiredField)) {
550
+ missingFields.push(requiredField);
551
+ }
552
+ });
553
+ }
554
+ if (missingFields.length > 0) {
555
+ alert(`Custom field query is missing required columns: ${missingFields.join(', ')}`);
556
+ return;
557
+ }
558
+ }
559
+ submit(viewName ? 'edit' : 'add', query, name, id, undefined, useCustomField
560
+ ? { type: customFieldType, query: customFieldQuery }
561
+ : undefined);
562
+ }, label: viewName ? 'Save changes' : 'Create view', isLoading: isLoading })] })] }) }));
387
563
  }
@@ -0,0 +1,2 @@
1
+ export declare function processJoinASTWithDuplicateColumns(duplicateColumnsNames: string[], tableNames: string[], schema: any, ast: any): any;
2
+ //# sourceMappingURL=astProcessing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"astProcessing.d.ts","sourceRoot":"","sources":["../../../src/utils/astProcessing.ts"],"names":[],"mappings":"AAAA,wBAAgB,kCAAkC,CAChD,qBAAqB,EAAE,MAAM,EAAE,EAC/B,UAAU,EAAE,MAAM,EAAE,EACpB,MAAM,EAAE,GAAG,EACX,GAAG,EAAE,GAAG,OAsCT"}
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.processJoinASTWithDuplicateColumns = void 0;
4
+ function processJoinASTWithDuplicateColumns(duplicateColumnsNames, tableNames, schema, ast) {
5
+ const columns = [];
6
+ schema.forEach((table) => {
7
+ if (tableNames.includes(table.tableName)) {
8
+ table.columns.forEach((column) => {
9
+ let tableName = table.tableName;
10
+ if (table.tableName.includes('.')) {
11
+ tableName = table.tableName.split('.')[1] || table.tableName;
12
+ }
13
+ if (duplicateColumnsNames.includes(column.columnName)) {
14
+ columns.push({
15
+ type: 'expr',
16
+ as: `${tableName}_${column.columnName}`,
17
+ expr: {
18
+ type: 'column_ref',
19
+ table: tableName,
20
+ column: column.columnName,
21
+ },
22
+ });
23
+ }
24
+ else {
25
+ columns.push({
26
+ type: 'expr',
27
+ as: null,
28
+ expr: {
29
+ type: 'column_ref',
30
+ table: tableName,
31
+ column: column.columnName,
32
+ },
33
+ });
34
+ }
35
+ });
36
+ }
37
+ });
38
+ ast.columns = columns;
39
+ return ast;
40
+ }
41
+ exports.processJoinASTWithDuplicateColumns = processJoinASTWithDuplicateColumns;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=astProcessing.uspec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"astProcessing.uspec.d.ts","sourceRoot":"","sources":["../../../src/utils/astProcessing.uspec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const astProcessing_1 = require("./astProcessing");
4
+ describe('astProcessing', () => {
5
+ describe('processJoinASTWithDuplicateColumns', () => {
6
+ it('should return a new ast object with unambiguous columns', () => {
7
+ const dummyAst = { where: 'dummy where' };
8
+ const tableNames = ['table1', 'table2'];
9
+ const duplicateColumns = ['amount'];
10
+ const schema = [
11
+ {
12
+ tableName: 'table1',
13
+ columns: [{ columnName: 'amount' }, { columnName: 'name' }],
14
+ },
15
+ {
16
+ tableName: 'table2',
17
+ columns: [{ columnName: 'amount' }, { columnName: 'other_name' }],
18
+ },
19
+ ];
20
+ const resultAst = (0, astProcessing_1.processJoinASTWithDuplicateColumns)(duplicateColumns, tableNames, schema, dummyAst);
21
+ expect(resultAst.columns.length).toEqual(4);
22
+ expect(resultAst.columns[0].as).toEqual('table1_amount');
23
+ expect(resultAst.columns[1].as).toEqual(null);
24
+ });
25
+ });
26
+ });
@@ -0,0 +1,3 @@
1
+ export declare function convertFieldTypeToJSType(fieldType: string): string;
2
+ export declare function processColumnReference(column: string, databaseType: string): string;
3
+ //# sourceMappingURL=columnProcessing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"columnProcessing.d.ts","sourceRoot":"","sources":["../../../src/utils/columnProcessing.ts"],"names":[],"mappings":"AAAA,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAsBlE;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,UAa1E"}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.processColumnReference = exports.convertFieldTypeToJSType = void 0;
4
+ function convertFieldTypeToJSType(fieldType) {
5
+ switch (fieldType) {
6
+ case 'bool':
7
+ return 'bool';
8
+ case 'int8':
9
+ case 'int2':
10
+ case 'int4':
11
+ case 'float4':
12
+ case 'float8':
13
+ case 'numeric':
14
+ return 'number';
15
+ case 'date':
16
+ case 'time':
17
+ case 'timestamptz':
18
+ case 'timestamp':
19
+ return 'date';
20
+ case 'interval':
21
+ case 'varchar':
22
+ case 'text':
23
+ default:
24
+ return 'string';
25
+ }
26
+ }
27
+ exports.convertFieldTypeToJSType = convertFieldTypeToJSType;
28
+ function processColumnReference(column, databaseType) {
29
+ if (['postgresql', 'snowflake'].includes(databaseType.toLowerCase())) {
30
+ const columnParts = column.split('.');
31
+ if (columnParts.length > 1) {
32
+ return `"${columnParts[0]}"."${columnParts[1]}"`;
33
+ }
34
+ return `"${column}"`;
35
+ }
36
+ const columnParts = column.split('.');
37
+ if (columnParts.length > 1) {
38
+ return `\`${columnParts[0]}\`.\`${columnParts[1]}\``;
39
+ }
40
+ return `\`${column}\``;
41
+ }
42
+ exports.processColumnReference = processColumnReference;
@@ -1,4 +1,4 @@
1
- export declare const editSQLView: (editName: string, editViewQuery: string, editViewId: string, state: any) => Promise<any>;
2
- export declare const addSqlView: (name: string, editViewQuery: string, state: any) => Promise<any>;
1
+ export declare const editSQLView: (editName: string, editViewQuery: string, editViewId: string, customFieldInfo: any, state: any) => Promise<any>;
2
+ export declare const addSqlView: (name: string, editViewQuery: string, customFieldInfo: any, state: any) => Promise<any>;
3
3
  export declare const deleteSQLView: (id: string, state: any) => Promise<any>;
4
4
  //# sourceMappingURL=dataEditor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dataEditor.d.ts","sourceRoot":"","sources":["../../../src/utils/dataEditor.tsx"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW,aACZ,MAAM,iBACD,MAAM,cACT,MAAM,SACX,GAAG,iBAsDX,CAAC;AAEF,eAAO,MAAM,UAAU,SACf,MAAM,iBACG,MAAM,SACd,GAAG,iBA+CX,CAAC;AAEF,eAAO,MAAM,aAAa,OAAc,MAAM,SAAS,GAAG,iBAmCzD,CAAC"}
1
+ {"version":3,"file":"dataEditor.d.ts","sourceRoot":"","sources":["../../../src/utils/dataEditor.tsx"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW,aACZ,MAAM,iBACD,MAAM,cACT,MAAM,mBACD,GAAG,SACb,GAAG,iBAuDX,CAAC;AAEF,eAAO,MAAM,UAAU,SACf,MAAM,iBACG,MAAM,mBACJ,GAAG,SACb,GAAG,iBAgDX,CAAC;AAEF,eAAO,MAAM,aAAa,OAAc,MAAM,SAAS,GAAG,iBAmCzD,CAAC"}
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.deleteSQLView = exports.addSqlView = exports.editSQLView = void 0;
4
4
  const constants_1 = require("./constants");
5
- const editSQLView = async (editName, editViewQuery, editViewId, state) => {
5
+ const editSQLView = async (editName, editViewQuery, editViewId, customFieldInfo, state) => {
6
6
  if (!editName.length) {
7
7
  alert('Please enter a table name.');
8
8
  return;
@@ -27,6 +27,7 @@ const editSQLView = async (editName, editViewQuery, editViewId, state) => {
27
27
  metadata: {
28
28
  preQueries: [editViewQuery.replace(/;/, '')],
29
29
  name: editName,
30
+ customFieldInfo: customFieldInfo,
30
31
  task: 'view',
31
32
  id: editViewId,
32
33
  clientId: state.client._id,
@@ -56,7 +57,7 @@ const editSQLView = async (editName, editViewQuery, editViewId, state) => {
56
57
  return await response.json();
57
58
  };
58
59
  exports.editSQLView = editSQLView;
59
- const addSqlView = async (name, editViewQuery, state) => {
60
+ const addSqlView = async (name, editViewQuery, customFieldInfo, state) => {
60
61
  if (!name.length) {
61
62
  alert('Please enter a table name.');
62
63
  return;
@@ -76,6 +77,7 @@ const addSqlView = async (name, editViewQuery, state) => {
76
77
  body: JSON.stringify({
77
78
  metadata: {
78
79
  preQueries: [editViewQuery.replace(/;/, '')],
80
+ customFieldInfo: customFieldInfo,
79
81
  name: name,
80
82
  task: 'view',
81
83
  clientId: state.client._id,
@@ -29,7 +29,6 @@ interface SnowflakeConnection extends DatabaseConnection {
29
29
  port: string;
30
30
  }
31
31
  interface BigQueryConnection extends DatabaseConnection {
32
- companyTag: string;
33
32
  jsonString: string;
34
33
  }
35
34
  export type ConnectionType = DatabaseConnection | PostgresConnection | MySQLConnection | SnowflakeConnection | BigQueryConnection;
@@ -1 +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,UAAU,mBAAoB,SAAQ,kBAAkB;IACtD,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,kBAAmB,SAAQ,kBAAkB;IACrD,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,cAAc,GACtB,kBAAkB,GAClB,kBAAkB,GAClB,eAAe,GACf,mBAAmB,GACnB,kBAAkB,CAAC;AAEvB,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,EAyBtD,CAAC;AAEF,wBAAgB,2BAA2B,CACzC,YAAY,EAAE,MAAM,GACnB,cAAc,GAAG,SAAS,CAwC5B;AAED,wBAAgB,oBAAoB,CAClC,UAAU,CAAC,EAAE,kBAAkB,EAC/B,QAAQ,CAAC,EAAE,IAAI,UAyBhB"}
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,UAAU,mBAAoB,SAAQ,kBAAkB;IACtD,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,kBAAmB,SAAQ,kBAAkB;IACrD,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,cAAc,GACtB,kBAAkB,GAClB,kBAAkB,GAClB,eAAe,GACf,mBAAmB,GACnB,kBAAkB,CAAC;AAEvB,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,EAyBtD,CAAC;AAEF,wBAAgB,2BAA2B,CACzC,YAAY,EAAE,MAAM,GACnB,cAAc,GAAG,SAAS,CAuC5B;AAED,wBAAgB,oBAAoB,CAClC,UAAU,CAAC,EAAE,kBAAkB,EAC/B,QAAQ,CAAC,EAAE,IAAI,UAkChB"}
@@ -61,7 +61,6 @@ function getDatabaseConnectionFormat(databaseName) {
61
61
  return {
62
62
  type: 'BigQuery',
63
63
  connectionString: '',
64
- companyTag: '',
65
64
  jsonString: '',
66
65
  };
67
66
  }
@@ -73,26 +72,26 @@ function formConnectionString(connection, jsonFile) {
73
72
  return 'There is no connection info';
74
73
  }
75
74
  if (connection.connectionString !== '') {
76
- return connection.connectionString;
75
+ return connection.connectionString.replaceAll(' ', '');
77
76
  }
78
77
  if (connection.type === 'PostgreSQL') {
79
78
  const typedConnection = connection;
80
- return `postgres://${typedConnection.user}:${typedConnection.password}@${typedConnection.host}:${typedConnection.port}/${typedConnection.databaseName}`;
79
+ return `postgres://${typedConnection.user}:${typedConnection.password}@${typedConnection.host}:${typedConnection.port}/${typedConnection.databaseName}`.replaceAll(' ', '');
81
80
  }
82
81
  else if (connection.type === 'mysql') {
83
82
  const typedConnection = connection;
84
- return `mysql://${typedConnection.user}:${typedConnection.password}@${typedConnection.host}:${typedConnection.port}`;
83
+ return `mysql://${typedConnection.user}:${typedConnection.password}@${typedConnection.host}:${typedConnection.port}`.replaceAll(' ', '');
85
84
  }
86
85
  else if (connection.type === 'snowflake') {
87
86
  const typedConnection = connection;
88
- return `mysql://${typedConnection.user}:${typedConnection.password}@${typedConnection.host}:${typedConnection.port}`;
87
+ return `mysql://${typedConnection.user}:${typedConnection.password}@${typedConnection.host}:${typedConnection.port}`.replaceAll(' ', '');
89
88
  }
90
89
  else if (connection.type === 'BigQuery') {
91
90
  const typedConnection = connection;
92
91
  const cleanedJsonString = typedConnection.jsonString
93
92
  .replace(/\\(?![n"])/g, '')
94
93
  .replace(/\n/g, '');
95
- return `${typedConnection.companyTag}${cleanedJsonString}`;
94
+ return cleanedJsonString;
96
95
  }
97
96
  return '';
98
97
  }