@quillsql/node 0.2.1 → 0.2.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 (3) hide show
  1. package/index.js +19 -8
  2. package/index.ts +24 -10
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -13,7 +13,7 @@ const axios = require("axios");
13
13
  var PgError = require("pg-error");
14
14
  Connection.prototype.parseE = PgError.parse;
15
15
  Connection.prototype.parseN = PgError.parse;
16
- module.exports = ({ publicKey, privateKey, databaseConnectionString, stagingDatabaseConnectionString, }) => {
16
+ module.exports = ({ privateKey, databaseConnectionString, stagingDatabaseConnectionString, }) => {
17
17
  const pool = new Pool({
18
18
  connectionString: databaseConnectionString,
19
19
  });
@@ -27,16 +27,23 @@ module.exports = ({ publicKey, privateKey, databaseConnectionString, stagingData
27
27
  if (task === "query") {
28
28
  const response = yield axios.post("https://quill-344421.uc.r.appspot.com/validate", { query: query }, {
29
29
  params: {
30
- publicKey,
31
30
  orgId,
32
31
  },
33
32
  headers: {
34
33
  Authorization: `Bearer ${privateKey}`,
35
34
  },
36
35
  });
36
+ const { fieldToRemove } = response.data;
37
37
  try {
38
38
  const queryResult = yield targetPool.query(response.data.query);
39
- return queryResult;
39
+ return Object.assign(Object.assign({}, queryResult), { fields: queryResult.fields.filter(
40
+ // @ts-ignore
41
+ (field) => field.name !== fieldToRemove),
42
+ // @ts-ignore
43
+ rows: queryResult.rows.map((row) => {
44
+ delete row[fieldToRemove];
45
+ return row;
46
+ }) });
40
47
  }
41
48
  catch (err) {
42
49
  return Object.assign(Object.assign({}, err), {
@@ -47,7 +54,6 @@ module.exports = ({ publicKey, privateKey, databaseConnectionString, stagingData
47
54
  if (task === "config") {
48
55
  const response = yield axios.get("https://quill-344421.uc.r.appspot.com/config", {
49
56
  params: {
50
- publicKey,
51
57
  orgId,
52
58
  // @ts-ignore
53
59
  name: metadata === null || metadata === void 0 ? void 0 : metadata.name,
@@ -71,7 +77,6 @@ module.exports = ({ publicKey, privateKey, databaseConnectionString, stagingData
71
77
  if (task === "create") {
72
78
  const response = yield axios.post("https://quill-344421.uc.r.appspot.com/item", Object.assign({}, metadata), {
73
79
  params: {
74
- publicKey,
75
80
  orgId,
76
81
  },
77
82
  headers: {
@@ -86,7 +91,6 @@ module.exports = ({ publicKey, privateKey, databaseConnectionString, stagingData
86
91
  params: {
87
92
  id,
88
93
  orgId,
89
- publicKey,
90
94
  },
91
95
  headers: {
92
96
  Authorization: `Bearer ${privateKey}`,
@@ -94,15 +98,22 @@ module.exports = ({ publicKey, privateKey, databaseConnectionString, stagingData
94
98
  });
95
99
  const response = yield axios.post("https://quill-344421.uc.r.appspot.com/validate", { query: resp.data.queryString }, {
96
100
  params: {
97
- publicKey,
98
101
  orgId,
99
102
  },
100
103
  headers: {
101
104
  Authorization: `Bearer ${privateKey}`,
102
105
  },
103
106
  });
107
+ const { fieldToRemove } = response.data;
104
108
  const queryResult = yield targetPool.query(response.data.query);
105
- return Object.assign(Object.assign({}, resp.data), { rows: queryResult.rows, fields: queryResult.fields });
109
+ return Object.assign(Object.assign({}, resp.data), { fields: queryResult.fields.filter(
110
+ // @ts-ignore
111
+ (field) => field.name !== fieldToRemove),
112
+ // @ts-ignore
113
+ rows: queryResult.rows.map((row) => {
114
+ delete row[fieldToRemove];
115
+ return row;
116
+ }) });
106
117
  }
107
118
  catch (err) {
108
119
  return Object.assign(Object.assign({}, err), {
package/index.ts CHANGED
@@ -5,7 +5,6 @@ Connection.prototype.parseE = PgError.parse;
5
5
  Connection.prototype.parseN = PgError.parse;
6
6
 
7
7
  interface QuillConfig {
8
- publicKey: string;
9
8
  privateKey: string;
10
9
  databaseConnectionString: string;
11
10
  stagingDatabaseConnectionString?: string;
@@ -49,6 +48,7 @@ interface QuillRequestMetadata {
49
48
  dashboardName?: string;
50
49
  columns?: FormattedColumn[];
51
50
  dateField?: { table: string; field: string };
51
+ template?: boolean;
52
52
  }
53
53
 
54
54
  interface QuillQueryParams {
@@ -58,7 +58,6 @@ interface QuillQueryParams {
58
58
  }
59
59
 
60
60
  module.exports = ({
61
- publicKey,
62
61
  privateKey,
63
62
  databaseConnectionString,
64
63
  stagingDatabaseConnectionString,
@@ -81,7 +80,6 @@ module.exports = ({
81
80
  { query: query },
82
81
  {
83
82
  params: {
84
- publicKey,
85
83
  orgId,
86
84
  },
87
85
  headers: {
@@ -89,9 +87,21 @@ module.exports = ({
89
87
  },
90
88
  }
91
89
  );
90
+ const { fieldToRemove } = response.data;
92
91
  try {
93
92
  const queryResult = await targetPool.query(response.data.query);
94
- return queryResult;
93
+ return {
94
+ ...queryResult,
95
+ fields: queryResult.fields.filter(
96
+ // @ts-ignore
97
+ (field) => field.name !== fieldToRemove
98
+ ),
99
+ // @ts-ignore
100
+ rows: queryResult.rows.map((row) => {
101
+ delete row[fieldToRemove];
102
+ return row;
103
+ }),
104
+ };
95
105
  } catch (err) {
96
106
  return {
97
107
  // @ts-ignore
@@ -107,7 +117,6 @@ module.exports = ({
107
117
  "https://quill-344421.uc.r.appspot.com/config",
108
118
  {
109
119
  params: {
110
- publicKey,
111
120
  orgId,
112
121
  // @ts-ignore
113
122
  name: metadata?.name,
@@ -138,7 +147,6 @@ module.exports = ({
138
147
  { ...metadata },
139
148
  {
140
149
  params: {
141
- publicKey,
142
150
  orgId,
143
151
  },
144
152
  headers: {
@@ -157,7 +165,6 @@ module.exports = ({
157
165
  params: {
158
166
  id,
159
167
  orgId,
160
- publicKey,
161
168
  },
162
169
  headers: {
163
170
  Authorization: `Bearer ${privateKey}`,
@@ -169,7 +176,6 @@ module.exports = ({
169
176
  { query: resp.data.queryString },
170
177
  {
171
178
  params: {
172
- publicKey,
173
179
  orgId,
174
180
  },
175
181
  headers: {
@@ -177,11 +183,19 @@ module.exports = ({
177
183
  },
178
184
  }
179
185
  );
186
+ const { fieldToRemove } = response.data;
180
187
  const queryResult = await targetPool.query(response.data.query);
181
188
  return {
182
189
  ...resp.data,
183
- rows: queryResult.rows,
184
- fields: queryResult.fields,
190
+ fields: queryResult.fields.filter(
191
+ // @ts-ignore
192
+ (field) => field.name !== fieldToRemove
193
+ ),
194
+ // @ts-ignore
195
+ rows: queryResult.rows.map((row) => {
196
+ delete row[fieldToRemove];
197
+ return row;
198
+ }),
185
199
  };
186
200
  } catch (err) {
187
201
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quillsql/node",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Quill SDK for Node.js",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {