@quillsql/node 0.4.0 → 0.4.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.
@@ -4,7 +4,7 @@ import express from "express";
4
4
  import cors from "cors";
5
5
 
6
6
  const app = express();
7
- const port = 3001;
7
+ const port = 3000;
8
8
 
9
9
  // postgresqlConfigExample {
10
10
  // connectionString: process.env.DB_URL,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quillsql/node",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Quill's client SDK for node backends.",
5
5
  "main": "dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -190,8 +190,15 @@ function inferType(elem: any) {
190
190
  // Check if the number is a float or an integer
191
191
  return Number.isInteger(elem) ? 23 : 700; // 23: integer, 700: real
192
192
  }
193
+ // BIG QUERY places data into objects as well
193
194
  if (typeof elem === "object") {
194
- if (/^\d{4}-\d{2}-\d{2}$/.test(elem.value)) return 1082; // date
195
+ if (/^\d{4}-\d{2}-\d{2}$/.test(elem.value)) return 1082; // YYYY-MM-DD format
196
+ if (/^\d{2}\/\d{2}\/\d{2,4}$/.test(elem.value)) return 1082; // MM\DD\YYYY or MM\DD\YY format
197
+ if (/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?$/.test(elem.value))
198
+ return 1114; // YYYY-MM-DDTHH:MM:SS[.fraction] format
199
+ if (/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?Z$/.test(elem.value))
200
+ return 1184; // YYYY-MM-DDTHH:MM:SS[.fraction]Z format
201
+ if (/^\d{2}:\d{2}:\d{2}$/.test(elem.value)) return 1083; // HH:MM:SS format
195
202
  }
196
203
  if (typeof elem === "string") {
197
204
  // Attempt to infer date, time, and timestamp formats
package/src/index.ts CHANGED
@@ -88,6 +88,9 @@ export default class QuillClass {
88
88
  orgId,
89
89
  viewQuery: metadata.preQueries ? metadata.preQueries[0] : undefined,
90
90
  });
91
+ if (response.error) {
92
+ return { status: "error", error: response.error };
93
+ }
91
94
  // if there is no metadata object in the response, create one
92
95
  if (!response.metadata) {
93
96
  response.metadata = {};
@@ -153,7 +156,7 @@ export default class QuillClass {
153
156
  return { ...results, queryResults: [], mappedArray };
154
157
  } else if (runQueryConfig?.getColumns) {
155
158
  const queryResult = await this.targetConnection.query(
156
- `${queries[0]} limit 1`
159
+ `${queries[0].replace(/;/, "")} limit 1`
157
160
  );
158
161
  const columns = queryResult.fields.map((field: any) => {
159
162
  return {
@@ -183,6 +186,10 @@ export default class QuillClass {
183
186
  queries = queries.map((query) => {
184
187
  return query.replace(/;/, "") + " limit 1000;";
185
188
  });
189
+ } else if (runQueryConfig?.limitBy) {
190
+ queries = queries.map((query) => {
191
+ return query.replace(/;/, "") + " limit " + runQueryConfig.limitBy;
192
+ });
186
193
  }
187
194
  const queryResults = await Promise.all(
188
195
  queries.map(async (query) => {
@@ -26,7 +26,7 @@ export interface QuillRequestMetadata {
26
26
  template?: boolean;
27
27
  clientId?: string;
28
28
  deleted?: boolean;
29
- databaseType?: string
29
+ databaseType?: string;
30
30
  }
31
31
 
32
32
  export interface QuillQueryParams {
@@ -55,18 +55,20 @@ export interface AdditionalProcessing {
55
55
  getSchema?: boolean;
56
56
  getColumns?: boolean;
57
57
  getTables?: boolean;
58
- schema?: string,
58
+ schema?: string;
59
59
  schemaNames?: string[];
60
- table?: string,
60
+ table?: string;
61
61
  removeFields?: string[];
62
62
  arrayToMap?: { arrayName: string; field: string };
63
63
  overridePost?: boolean;
64
- convertDatatypes?: boolean
64
+ convertDatatypes?: boolean;
65
65
  limitThousand?: boolean;
66
+ limitBy?: number;
66
67
  }
67
68
 
68
69
  export interface QuillClientResponse {
69
70
  queries: string[];
70
71
  metadata: any;
71
72
  runQueryConfig: AdditionalProcessing;
73
+ error?: string;
72
74
  }