@quillsql/node 0.9.16 → 0.9.18

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.
@@ -1,12 +1,11 @@
1
1
  import { Mappable, CacheCredentials } from "../models/Cache";
2
2
  import { DatabaseConnection, DatabaseConnectionConfig, DatabaseConnectionType } from "./DatabaseHelper";
3
3
  export declare class CachedConnection {
4
- private static sharedRedisClients;
5
4
  databaseType: DatabaseConnectionType;
6
5
  readonly pool: DatabaseConnection;
7
- tenantIds: (string | number)[] | null;
8
6
  ttl: number;
9
7
  cache: Mappable | null;
8
+ isCacheJobRunning: boolean;
10
9
  private _isClosed;
11
10
  get isClosed(): boolean;
12
11
  /** Private constructor; use CachedConnection.create(...) */
@@ -14,9 +13,6 @@ export declare class CachedConnection {
14
13
  /** Async factory initializer */
15
14
  static create(databaseType: DatabaseConnectionType, config: DatabaseConnectionConfig, cacheConfig?: Partial<CacheCredentials>): Promise<CachedConnection>;
16
15
  query(text: string, overwriteCache?: boolean): Promise<any>;
17
- getCachedValue(key: string): Promise<string | null>;
18
- setCachedValue(key: string, value: string): Promise<void>;
19
- deleteCachedValue(key: string): Promise<void>;
20
16
  /**
21
17
  * Configures and returns a cache instance or null if none could be created.
22
18
  */
@@ -22,7 +22,7 @@ class CachedConnection {
22
22
  /** Private constructor; use CachedConnection.create(...) */
23
23
  constructor(databaseType, config, cacheConfig = {}) {
24
24
  var _a;
25
- this.tenantIds = null;
25
+ this.isCacheJobRunning = false;
26
26
  this._isClosed = false;
27
27
  this.databaseType = databaseType;
28
28
  this.pool = (0, DatabaseHelper_1.connectToDatabase)(databaseType, config);
@@ -39,7 +39,6 @@ class CachedConnection {
39
39
  }
40
40
  query(text_1) {
41
41
  return __awaiter(this, arguments, void 0, function* (text, overwriteCache = false) {
42
- var _a;
43
42
  try {
44
43
  if (this.isClosed) {
45
44
  throw new Error("Connection is closed");
@@ -47,63 +46,27 @@ class CachedConnection {
47
46
  if (!this.cache) {
48
47
  return yield (0, DatabaseHelper_1.runQueryByDatabase)(this.databaseType, this.pool, text);
49
48
  }
50
- const keyBase = `${JSON.stringify((_a = this.tenantIds) !== null && _a !== void 0 ? _a : ["__NO_TENANT__"])}:${text}`;
51
- const fieldsKey = `${keyBase}:fields`;
52
- const rowsKey = `${keyBase}:rows`;
53
- const metaKey = `${keyBase}:meta`;
49
+ // `text` must be a tenant-scoped SQL query.
50
+ // Since runQueryByDatabase doesn't receive tenant information from any
51
+ // of its other parameters
52
+ const key = text;
54
53
  if (!overwriteCache) {
55
- const cachedMeta = yield this.cache.get(metaKey);
56
- if (cachedMeta !== null) {
57
- try {
58
- const parsedMeta = JSON.parse(cachedMeta);
59
- const [cachedFields, cachedRows] = yield Promise.all([
60
- this.cache.lRange(fieldsKey, 0, -1),
61
- this.cache.lRange(rowsKey, 0, -1),
62
- ]);
63
- if (parsedMeta.fieldsCount === cachedFields.length &&
64
- parsedMeta.rowsCount === cachedRows.length) {
65
- return {
66
- fields: cachedFields.map((item) => JSON.parse(item)),
67
- rows: cachedRows.map((item) => JSON.parse(item)),
68
- };
69
- }
70
- }
71
- catch (_b) {
72
- // Any parse/shape failure should invalidate this cache set.
73
- }
74
- yield this.cache.del(metaKey, fieldsKey, rowsKey);
75
- }
76
- }
77
- const newResult = yield (0, DatabaseHelper_1.runQueryByDatabase)(this.databaseType, this.pool, text);
78
- if (!newResult) {
79
- return newResult;
54
+ let cachedResult = yield this.cache.get(key);
55
+ if (cachedResult)
56
+ return JSON.parse(cachedResult);
80
57
  }
58
+ const result = yield (0, DatabaseHelper_1.runQueryByDatabase)(this.databaseType, this.pool, text);
81
59
  try {
82
- const fields = Array.isArray(newResult.fields) ? newResult.fields : [];
83
- const rows = Array.isArray(newResult.rows) ? newResult.rows : [];
84
- const fieldsPayload = fields.map((field) => JSON.stringify(field));
85
- const rowsPayload = rows.map((row) => JSON.stringify(row));
86
- const metaPayload = JSON.stringify({
87
- fieldsCount: fieldsPayload.length,
88
- rowsCount: rowsPayload.length,
89
- });
90
- const tx = this.cache.multi();
91
- tx.del(metaKey, fieldsKey, rowsKey);
92
- if (fieldsPayload.length) {
93
- tx.rPush(fieldsKey, fieldsPayload);
94
- tx.expire(fieldsKey, this.ttl);
95
- }
96
- if (rowsPayload.length) {
97
- tx.rPush(rowsKey, rowsPayload);
98
- tx.expire(rowsKey, this.ttl);
99
- }
100
- tx.set(metaKey, metaPayload, "EX", this.ttl);
101
- yield tx.exec();
60
+ yield this.cache.set(key, JSON.stringify(result), "EX", this.ttl);
102
61
  }
103
62
  catch (error) {
104
- console.warn("Redis Cache Set Failed: ", error);
63
+ const message = "Redis Cache Set Failed: " + String(error);
64
+ if (this.isCacheJobRunning) {
65
+ throw new Error(message);
66
+ }
67
+ console.warn(message); // This runs for general data fetching by customers
105
68
  }
106
- return newResult;
69
+ return result;
107
70
  }
108
71
  catch (err) {
109
72
  if ((0, Error_1.isSuperset)(err, Error_1.PgError)) {
@@ -115,56 +78,22 @@ class CachedConnection {
115
78
  }
116
79
  });
117
80
  }
118
- getCachedValue(key) {
119
- return __awaiter(this, void 0, void 0, function* () {
120
- if (!this.cache || this.isClosed)
121
- return null;
122
- return yield this.cache.get(key);
123
- });
124
- }
125
- setCachedValue(key, value) {
126
- return __awaiter(this, void 0, void 0, function* () {
127
- if (!this.cache || this.isClosed)
128
- return;
129
- yield this.cache.set(key, value, "EX", this.ttl);
130
- });
131
- }
132
- deleteCachedValue(key) {
133
- return __awaiter(this, void 0, void 0, function* () {
134
- if (!this.cache || this.isClosed)
135
- return;
136
- yield this.cache.del(key);
137
- });
138
- }
139
81
  /**
140
82
  * Configures and returns a cache instance or null if none could be created.
141
83
  */
142
84
  getCache(_a) {
143
85
  return __awaiter(this, arguments, void 0, function* ({ username, password, host, port, cacheType, }) {
144
86
  if (cacheType === "redis" || cacheType === "rediss") {
145
- const sharedKey = JSON.stringify({
146
- cacheType,
147
- username: username || "",
148
- password: password || "",
149
- host: host || "",
150
- port: port || "",
151
- });
152
- const existingClient = CachedConnection.sharedRedisClients.get(sharedKey);
153
- if (existingClient) {
154
- return existingClient;
155
- }
156
87
  const client = (0, redis_1.createClient)({
157
- username: username || "",
158
- password: password || "",
88
+ username: username || '',
89
+ password: password || '',
159
90
  socket: {
160
- host: host || "",
161
- port: port ? parseInt(port) : 0,
91
+ host: host || '',
92
+ port: port ? parseInt(port) : 0
162
93
  },
163
94
  });
164
95
  client.on("error", (err) => console.log("Redis Client Error", err));
165
96
  yield client.connect();
166
- // console.log("Redis connected to host:", host)
167
- CachedConnection.sharedRedisClients.set(sharedKey, client);
168
97
  return client;
169
98
  }
170
99
  return null;
@@ -181,5 +110,4 @@ class CachedConnection {
181
110
  }
182
111
  }
183
112
  exports.CachedConnection = CachedConnection;
184
- CachedConnection.sharedRedisClients = new Map();
185
113
  //# sourceMappingURL=CachedConnection.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CachedConnection.js","sourceRoot":"","sources":["../../../src/db/CachedConnection.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,iCAAqC;AACrC,0CAAqD;AACrD,qDAO0B;AAE1B,mDAAmD;AACnD,MAAM,iBAAiB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AAEvC,MAAa,gBAAgB;IAS3B,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED,4DAA4D;IAC5D,YACE,YAAoC,EACpC,MAAgC,EAChC,cAAyC,EAAE;;QAbtC,cAAS,GAA+B,IAAI,CAAC;QAI5C,cAAS,GAAY,KAAK,CAAC;QAWjC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,IAAI,GAAG,IAAA,kCAAiB,EAAC,YAAY,EAAE,MAAM,CAAC,CAAC;QACpD,IAAI,CAAC,GAAG,GAAG,MAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,GAAG,mCAAI,iBAAiB,CAAC;QACjD,IAAI,CAAC,KAAK,GAAG,IAAI,C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tHD,4CAsHC"}
@@ -19,6 +19,21 @@ export interface QuillQueryResult {
19
19
  fields: any[];
20
20
  };
21
21
  }
22
+ export type QuillCacheResult = {
23
+ status: "failed";
24
+ error: string;
25
+ } | {
26
+ status: "complete";
27
+ cachedDashboards: string[];
28
+ failedDashboards: string[];
29
+ };
30
+ export interface QuillCacheParams {
31
+ tenants: QuillQueryParams["tenants"];
32
+ dashboards?: string[];
33
+ signal?: AbortSignal;
34
+ parallelQueries?: number;
35
+ maxRowsPerReport?: number;
36
+ }
22
37
  export type QuillStreamEvent = {
23
38
  type: "start";
24
39
  } | {
@@ -74,6 +89,7 @@ export declare class Quill implements AsyncDisposable {
74
89
  private baseUrl;
75
90
  private config;
76
91
  private initPromise;
92
+ private lock;
77
93
  constructor(data: {
78
94
  privateKey: string;
79
95
  databaseType: "snowflake";
@@ -107,9 +123,7 @@ export declare class Quill implements AsyncDisposable {
107
123
  metadataServerURL?: string;
108
124
  });
109
125
  private ensureReady;
110
- private getTenantMappedFlagsCacheKey;
111
- private getTenantMappedFlagsFromCache;
112
- private setTenantMappedFlagsCache;
126
+ cache({ tenants, dashboards, signal, parallelQueries, maxRowsPerReport, }: QuillCacheParams): Promise<QuillCacheResult>;
113
127
  query({ tenants, flags, metadata, filters, adminEnabled, }: QuillQueryParams): Promise<QuillQueryResult>;
114
128
  stream({ tenants, flags, metadata, filters, adminEnabled, signal, }: QuillStreamOptions): Promise<AsyncIterable<QuillStreamEvent>>;
115
129
  private applyLimit;