@cubejs-backend/api-gateway 1.4.0 → 1.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.
- package/dist/src/{CubejsHandlerError.d.ts → cubejs-handler-error.d.ts} +1 -1
- package/dist/src/cubejs-handler-error.d.ts.map +1 -0
- package/dist/src/{CubejsHandlerError.js → cubejs-handler-error.js} +1 -1
- package/dist/src/cubejs-handler-error.js.map +1 -0
- package/dist/src/{dateParser.d.ts → date-parser.d.ts} +1 -1
- package/dist/src/date-parser.d.ts.map +1 -0
- package/dist/src/{dateParser.js → date-parser.js} +5 -5
- package/dist/src/date-parser.js.map +1 -0
- package/dist/src/gateway.d.ts +1 -1
- package/dist/src/gateway.d.ts.map +1 -1
- package/dist/src/gateway.js +55 -53
- package/dist/src/gateway.js.map +1 -1
- package/dist/src/helpers/{prepareAnnotation.d.ts → prepare-annotation.d.ts} +2 -2
- package/dist/src/helpers/prepare-annotation.d.ts.map +1 -0
- package/dist/src/helpers/{prepareAnnotation.js → prepare-annotation.js} +3 -3
- package/dist/src/helpers/prepare-annotation.js.map +1 -0
- package/dist/src/helpers/{toConfigMap.d.ts → to-config-map.d.ts} +1 -1
- package/dist/src/helpers/to-config-map.d.ts.map +1 -0
- package/dist/src/helpers/{toConfigMap.js → to-config-map.js} +1 -1
- package/dist/src/helpers/to-config-map.js.map +1 -0
- package/dist/src/helpers/{transformMetaExtended.d.ts → transform-meta-extended.d.ts} +1 -1
- package/dist/src/helpers/transform-meta-extended.d.ts.map +1 -0
- package/dist/src/helpers/{transformMetaExtended.js → transform-meta-extended.js} +1 -1
- package/dist/src/helpers/transform-meta-extended.js.map +1 -0
- package/dist/src/index.d.ts +4 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +4 -4
- package/dist/src/index.js.map +1 -1
- package/dist/src/interfaces.d.ts +1 -1
- package/dist/src/interfaces.d.ts.map +1 -1
- package/dist/src/query.js +14 -14
- package/dist/src/query.js.map +1 -1
- package/dist/src/{requestParser.d.ts → request-parser.d.ts} +1 -1
- package/dist/src/request-parser.d.ts.map +1 -0
- package/dist/src/{requestParser.js → request-parser.js} +1 -1
- package/dist/src/request-parser.js.map +1 -0
- package/dist/src/types/responses.d.ts +1 -1
- package/dist/src/types/responses.d.ts.map +1 -1
- package/dist/src/user-error.d.ts +5 -0
- package/dist/src/user-error.d.ts.map +1 -0
- package/dist/src/{UserError.js → user-error.js} +3 -3
- package/dist/src/user-error.js.map +1 -0
- package/dist/src/ws/index.d.ts +4 -0
- package/dist/src/ws/index.d.ts.map +1 -0
- package/dist/src/ws/index.js +20 -0
- package/dist/src/ws/index.js.map +1 -0
- package/dist/src/ws/local-subscription-store.d.ts +30 -0
- package/dist/src/ws/local-subscription-store.d.ts.map +1 -0
- package/dist/src/ws/local-subscription-store.js +64 -0
- package/dist/src/ws/local-subscription-store.js.map +1 -0
- package/dist/src/ws/message-schema.d.ts +53 -0
- package/dist/src/ws/message-schema.d.ts.map +1 -0
- package/dist/src/ws/message-schema.js +59 -0
- package/dist/src/ws/message-schema.js.map +1 -0
- package/dist/src/ws/subscription-server.d.ts +25 -0
- package/dist/src/ws/subscription-server.d.ts.map +1 -0
- package/dist/src/ws/subscription-server.js +187 -0
- package/dist/src/ws/subscription-server.js.map +1 -0
- package/package.json +8 -7
- package/dist/src/CubejsHandlerError.d.ts.map +0 -1
- package/dist/src/CubejsHandlerError.js.map +0 -1
- package/dist/src/LocalSubscriptionStore.d.ts +0 -19
- package/dist/src/LocalSubscriptionStore.d.ts.map +0 -1
- package/dist/src/LocalSubscriptionStore.js +0 -57
- package/dist/src/LocalSubscriptionStore.js.map +0 -1
- package/dist/src/SubscriptionServer.d.ts +0 -19
- package/dist/src/SubscriptionServer.d.ts.map +0 -1
- package/dist/src/SubscriptionServer.js +0 -133
- package/dist/src/SubscriptionServer.js.map +0 -1
- package/dist/src/UserError.d.ts +0 -5
- package/dist/src/UserError.d.ts.map +0 -1
- package/dist/src/UserError.js.map +0 -1
- package/dist/src/dateParser.d.ts.map +0 -1
- package/dist/src/dateParser.js.map +0 -1
- package/dist/src/helpers/prepareAnnotation.d.ts.map +0 -1
- package/dist/src/helpers/prepareAnnotation.js.map +0 -1
- package/dist/src/helpers/toConfigMap.d.ts.map +0 -1
- package/dist/src/helpers/toConfigMap.js.map +0 -1
- package/dist/src/helpers/transformMetaExtended.d.ts.map +0 -1
- package/dist/src/helpers/transformMetaExtended.js.map +0 -1
- package/dist/src/requestParser.d.ts.map +0 -1
- package/dist/src/requestParser.js.map +0 -1
|
@@ -4,4 +4,4 @@ export declare class CubejsHandlerError extends Error {
|
|
|
4
4
|
readonly originalError?: Error | undefined;
|
|
5
5
|
constructor(status: number, type: string, message: string, originalError?: Error | undefined);
|
|
6
6
|
}
|
|
7
|
-
//# sourceMappingURL=
|
|
7
|
+
//# sourceMappingURL=cubejs-handler-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cubejs-handler-error.d.ts","sourceRoot":"","sources":["../../src/cubejs-handler-error.ts"],"names":[],"mappings":"AAAA,qBAAa,kBAAmB,SAAQ,KAAK;aAEzB,MAAM,EAAE,MAAM;aACd,IAAI,EAAE,MAAM;aAEZ,aAAa,CAAC;gBAHd,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EAC5B,OAAO,EAAE,MAAM,EACC,aAAa,CAAC,mBAAO;CAIxC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cubejs-handler-error.js","sourceRoot":"","sources":["../../src/cubejs-handler-error.ts"],"names":[],"mappings":";;;AAAA,MAAa,kBAAmB,SAAQ,KAAK;IAEzB;IACA;IAEA;IAJlB,YACkB,MAAc,EACd,IAAY,EAC5B,OAAe,EACC,aAAqB;QAErC,KAAK,CAAC,OAAO,IAAI,IAAI,CAAC,CAAC;QALP,WAAM,GAAN,MAAM,CAAQ;QACd,SAAI,GAAJ,IAAI,CAAQ;QAEZ,kBAAa,GAAb,aAAa,CAAQ;IAGvC,CAAC;CACF;AATD,gDASC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export function dateParser(dateString: any, timezone: any, now?: Date): string[];
|
|
2
|
-
//# sourceMappingURL=
|
|
2
|
+
//# sourceMappingURL=date-parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date-parser.d.ts","sourceRoot":"","sources":["../../src/date-parser.js"],"names":[],"mappings":"AAmBA,iFA2FC"}
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.dateParser = void 0;
|
|
7
7
|
const moment_timezone_1 = __importDefault(require("moment-timezone"));
|
|
8
8
|
const chrono_node_1 = require("chrono-node");
|
|
9
|
-
const
|
|
9
|
+
const user_error_1 = require("./user-error");
|
|
10
10
|
const momentFromResult = (result, timezone) => {
|
|
11
11
|
const dateMoment = (0, moment_timezone_1.default)().tz(timezone);
|
|
12
12
|
dateMoment.set('year', result.get('year'));
|
|
@@ -74,10 +74,10 @@ function dateParser(dateString, timezone, now = new Date()) {
|
|
|
74
74
|
const fromResults = (0, chrono_node_1.parse)(from.trim(), new Date(current.format(moment_timezone_1.default.HTML5_FMT.DATETIME_LOCAL_MS)));
|
|
75
75
|
const toResults = (0, chrono_node_1.parse)(to.trim(), new Date(current.format(moment_timezone_1.default.HTML5_FMT.DATETIME_LOCAL_MS)));
|
|
76
76
|
if (!Array.isArray(fromResults) || !fromResults.length) {
|
|
77
|
-
throw new
|
|
77
|
+
throw new user_error_1.UserError(`Can't parse date: '${from}'`);
|
|
78
78
|
}
|
|
79
79
|
if (!Array.isArray(toResults) || !toResults.length) {
|
|
80
|
-
throw new
|
|
80
|
+
throw new user_error_1.UserError(`Can't parse date: '${to}'`);
|
|
81
81
|
}
|
|
82
82
|
const exactGranularity = ['second', 'minute', 'hour'].find(g => dateString.indexOf(g) !== -1) || 'day';
|
|
83
83
|
momentRange = [
|
|
@@ -90,7 +90,7 @@ function dateParser(dateString, timezone, now = new Date()) {
|
|
|
90
90
|
const current = (0, moment_timezone_1.default)(now).tz(timezone);
|
|
91
91
|
const results = (0, chrono_node_1.parse)(dateString, new Date(current.format(moment_timezone_1.default.HTML5_FMT.DATETIME_LOCAL_MS)));
|
|
92
92
|
if (!results?.length) {
|
|
93
|
-
throw new
|
|
93
|
+
throw new user_error_1.UserError(`Can't parse date: '${dateString}'`);
|
|
94
94
|
}
|
|
95
95
|
const exactGranularity = ['second', 'minute', 'hour'].find(g => dateString.indexOf(g) !== -1) || 'day';
|
|
96
96
|
momentRange = results[0].end ? [
|
|
@@ -105,4 +105,4 @@ function dateParser(dateString, timezone, now = new Date()) {
|
|
|
105
105
|
return momentRange.map(d => d.format(moment_timezone_1.default.HTML5_FMT.DATETIME_LOCAL_MS));
|
|
106
106
|
}
|
|
107
107
|
exports.dateParser = dateParser;
|
|
108
|
-
//# sourceMappingURL=
|
|
108
|
+
//# sourceMappingURL=date-parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date-parser.js","sourceRoot":"","sources":["../../src/date-parser.js"],"names":[],"mappings":";;;;;;AAAA,sEAAqC;AACrC,6CAAoC;AAEpC,6CAAyC;AAEzC,MAAM,gBAAgB,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE;IAC5C,MAAM,UAAU,GAAG,IAAA,yBAAM,GAAE,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;IAEzC,UAAU,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;IAC3C,UAAU,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;IACjD,UAAU,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;IAC1C,UAAU,CAAC,GAAG,CAAC,MAAM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CAAC,gBAAgB,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC;KAClG;IAED,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,yBAAM,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC,CAAC;AAC5E,CAAC;AA3FD,gCA2FC"}
|
package/dist/src/gateway.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { CheckAuthInternalOptions, JWTOptions, CheckAuthFn, ContextToApiScopesFn
|
|
|
8
8
|
import { Query, NormalizedQuery } from './types/query';
|
|
9
9
|
import { UserBackgroundContext, ApiGatewayOptions } from './types/gateway';
|
|
10
10
|
import { RequestLoggerMiddlewareFn, ContextRejectionMiddlewareFn, ContextAcceptorFn } from './interfaces';
|
|
11
|
-
import { SubscriptionServer, WebSocketSendMessageFn } from './
|
|
11
|
+
import { SubscriptionServer, WebSocketSendMessageFn } from './ws/subscription-server';
|
|
12
12
|
import { SQLServer, SQLServerConstructorOptions } from './sql-server';
|
|
13
13
|
type HandleErrorOptions = {
|
|
14
14
|
e: any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gateway.d.ts","sourceRoot":"","sources":["../../src/gateway.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAQjC,OAAO,EAKL,SAAS,EACV,MAAM,wBAAwB,CAAC;AAMhC,OAAO,KAAK,EACV,WAAW,IAAI,kBAAkB,EACjC,mBAAmB,EAEnB,cAAc,EAEd,QAAQ,IAAI,eAAe,EAC5B,MAAM,SAAS,CAAC;AAIjB,OAAO,EACL,SAAS,EACT,SAAS,EACV,MAAM,iBAAiB,CAAC;AAIzB,OAAO,EACL,WAAW,EACX,cAAc,EACd,sBAAsB,EACtB,OAAO,EACP,cAAc,EACd,0BAA0B,EAC1B,eAAe,EACf,gBAAgB,EAChB,YAAY,EAMZ,aAAa,EACb,oBAAoB,EACpB,YAAY,EACb,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,wBAAwB,EACxB,UAAU,EACV,WAAW,EACX,oBAAoB,EACrB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,KAAK,EACL,eAAe,EAGhB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EAClB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,yBAAyB,EACzB,4BAA4B,EAC5B,iBAAiB,EAClB,MAAM,cAAc,CAAC;AAItB,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"gateway.d.ts","sourceRoot":"","sources":["../../src/gateway.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAQjC,OAAO,EAKL,SAAS,EACV,MAAM,wBAAwB,CAAC;AAMhC,OAAO,KAAK,EACV,WAAW,IAAI,kBAAkB,EACjC,mBAAmB,EAEnB,cAAc,EAEd,QAAQ,IAAI,eAAe,EAC5B,MAAM,SAAS,CAAC;AAIjB,OAAO,EACL,SAAS,EACT,SAAS,EACV,MAAM,iBAAiB,CAAC;AAIzB,OAAO,EACL,WAAW,EACX,cAAc,EACd,sBAAsB,EACtB,OAAO,EACP,cAAc,EACd,0BAA0B,EAC1B,eAAe,EACf,gBAAgB,EAChB,YAAY,EAMZ,aAAa,EACb,oBAAoB,EACpB,YAAY,EACb,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,wBAAwB,EACxB,UAAU,EACV,WAAW,EACX,oBAAoB,EACrB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,KAAK,EACL,eAAe,EAGhB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EAClB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,yBAAyB,EACzB,4BAA4B,EAC5B,iBAAiB,EAClB,MAAM,cAAc,CAAC;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E,cAAc,CAQrC;IAEF,SAAS,CAAC,eAAe,EAAE,cAAc,CAkBvC;IAEF,SAAS,CAAC,2BAA2B,CAAC,KAAK,KAAA;IAoCpC,GAAG,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC;IAezF,SAAS,CAAC,cAAc,CAAC,GAAG,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,GAAG,MAAM;IAMxE,SAAS,CAAC,0BAA0B,aAAc,MAAM,KAAG,cAAc,CAUvE;IAEF,OAAO,CAAC,aAAa;IASrB,SAAS,CAAC,SAAS,EAAE,cAAc,CAkBjC;IAEF,SAAS,CAAC,QAAQ,EAAE,cAAc,CAahC;IAEK,OAAO;CAKf;AACD,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,UAAU,GACX,CAAC"}
|
package/dist/src/gateway.js
CHANGED
|
@@ -15,18 +15,18 @@ const shared_1 = require("@cubejs-backend/shared");
|
|
|
15
15
|
const native_1 = require("@cubejs-backend/native");
|
|
16
16
|
const http_proxy_middleware_1 = require("http-proxy-middleware");
|
|
17
17
|
const enums_1 = require("./types/enums");
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
18
|
+
const request_parser_1 = require("./request-parser");
|
|
19
|
+
const user_error_1 = require("./user-error");
|
|
20
|
+
const cubejs_handler_error_1 = require("./cubejs-handler-error");
|
|
21
|
+
const subscription_server_1 = require("./ws/subscription-server");
|
|
22
|
+
const local_subscription_store_1 = require("./ws/local-subscription-store");
|
|
23
23
|
const query_1 = require("./query");
|
|
24
24
|
const cached_handler_1 = require("./cached-handler");
|
|
25
25
|
const jwk_1 = require("./jwk");
|
|
26
26
|
const sql_server_1 = require("./sql-server");
|
|
27
27
|
const graphql_1 = require("./graphql");
|
|
28
|
-
const
|
|
29
|
-
const
|
|
28
|
+
const prepare_annotation_1 = require("./helpers/prepare-annotation");
|
|
29
|
+
const transform_meta_extended_1 = require("./helpers/transform-meta-extended");
|
|
30
30
|
function userAsyncHandler(handler) {
|
|
31
31
|
return (req, res, next) => {
|
|
32
32
|
handler(req, res).catch(next);
|
|
@@ -88,7 +88,7 @@ class ApiGateway {
|
|
|
88
88
|
this.basePath = options.basePath;
|
|
89
89
|
this.playgroundAuthSecret = options.playgroundAuthSecret;
|
|
90
90
|
this.queryRewrite = options.queryRewrite || (async (query) => query);
|
|
91
|
-
this.subscriptionStore = options.subscriptionStore || new
|
|
91
|
+
this.subscriptionStore = options.subscriptionStore || new local_subscription_store_1.LocalSubscriptionStore();
|
|
92
92
|
this.enforceSecurityChecks = options.enforceSecurityChecks || (process.env.NODE_ENV === 'production');
|
|
93
93
|
this.extendContext = options.extendContext;
|
|
94
94
|
this.checkAuthFn = this.createCheckAuthFn(options);
|
|
@@ -385,7 +385,7 @@ class ApiGateway {
|
|
|
385
385
|
app.use(`${this.basePath}/v2`, proxyMiddleware);
|
|
386
386
|
}
|
|
387
387
|
initSubscriptionServer(sendMessage) {
|
|
388
|
-
return new
|
|
388
|
+
return new subscription_server_1.SubscriptionServer(this, sendMessage, this.subscriptionStore, this.wsContextAcceptor);
|
|
389
389
|
}
|
|
390
390
|
duration(requestStarted) {
|
|
391
391
|
return requestStarted && (new Date().getTime() - requestStarted.getTime());
|
|
@@ -452,20 +452,20 @@ class ApiGateway {
|
|
|
452
452
|
const cubes = this.filterVisibleItemsInMeta(context, metaConfig)
|
|
453
453
|
.map((meta) => meta.config)
|
|
454
454
|
.map((cube) => ({
|
|
455
|
-
...(0,
|
|
455
|
+
...(0, transform_meta_extended_1.transformCube)(cube, cubeDefinitions),
|
|
456
456
|
measures: cube.measures?.map((measure) => ({
|
|
457
|
-
...(0,
|
|
457
|
+
...(0, transform_meta_extended_1.transformMeasure)(measure, cubeDefinitions),
|
|
458
458
|
})),
|
|
459
459
|
dimensions: cube.dimensions?.map((dimension) => ({
|
|
460
|
-
...(0,
|
|
460
|
+
...(0, transform_meta_extended_1.transformDimension)(dimension, cubeDefinitions),
|
|
461
461
|
})),
|
|
462
462
|
segments: cube.segments?.map((segment) => ({
|
|
463
|
-
...(0,
|
|
463
|
+
...(0, transform_meta_extended_1.transformSegment)(segment, cubeDefinitions),
|
|
464
464
|
})),
|
|
465
|
-
joins: (0,
|
|
466
|
-
preAggregations: (0,
|
|
465
|
+
joins: (0, transform_meta_extended_1.transformJoins)(cubeDefinitions[cube.name]?.joins),
|
|
466
|
+
preAggregations: (0, transform_meta_extended_1.transformPreAggregations)(cubeDefinitions[cube.name]?.preAggregations),
|
|
467
467
|
}));
|
|
468
|
-
res({ cubes });
|
|
468
|
+
await res({ cubes });
|
|
469
469
|
}
|
|
470
470
|
catch (e) {
|
|
471
471
|
this.handleError({
|
|
@@ -534,7 +534,7 @@ class ApiGateway {
|
|
|
534
534
|
} : {}),
|
|
535
535
|
})),
|
|
536
536
|
});
|
|
537
|
-
res({
|
|
537
|
+
await res({
|
|
538
538
|
preAggregationPartitions: preAggregationPartitions.map(mergePartitionsAndVersionEntries())
|
|
539
539
|
});
|
|
540
540
|
}
|
|
@@ -557,7 +557,7 @@ class ApiGateway {
|
|
|
557
557
|
});
|
|
558
558
|
const { partitions } = (preAggregationPartitions?.[0] || {});
|
|
559
559
|
const preAggregationPartition = partitions?.find(p => p?.tableName === versionEntry.table_name);
|
|
560
|
-
res({
|
|
560
|
+
await res({
|
|
561
561
|
preview: preAggregationPartition && await orchestratorApi.getPreAggregationPreview(context, preAggregationPartition)
|
|
562
562
|
});
|
|
563
563
|
}
|
|
@@ -573,7 +573,7 @@ class ApiGateway {
|
|
|
573
573
|
query = (0, query_1.normalizeQueryPreAggregations)(this.parseQueryParam(query));
|
|
574
574
|
const result = await this.refreshScheduler()
|
|
575
575
|
.buildPreAggregations(context, query);
|
|
576
|
-
res({ result });
|
|
576
|
+
await res({ result });
|
|
577
577
|
}
|
|
578
578
|
catch (e) {
|
|
579
579
|
this.handleError({
|
|
@@ -630,17 +630,17 @@ class ApiGateway {
|
|
|
630
630
|
try {
|
|
631
631
|
await this.assertApiScope('jobs', req?.context?.securityContext);
|
|
632
632
|
if (!query || Object.keys(query).length === 0) {
|
|
633
|
-
throw new
|
|
633
|
+
throw new user_error_1.UserError('No job description provided');
|
|
634
634
|
}
|
|
635
635
|
const { error } = query_1.preAggsJobsRequestSchema.validate(query);
|
|
636
636
|
if (error) {
|
|
637
|
-
throw new
|
|
637
|
+
throw new user_error_1.UserError(`Invalid Job query format: ${error.message || error.toString()}`);
|
|
638
638
|
}
|
|
639
639
|
switch (query.action) {
|
|
640
640
|
case 'post':
|
|
641
641
|
result = await this.preAggregationsJobsPOST(context, query.selector);
|
|
642
642
|
if (result.length === 0) {
|
|
643
|
-
throw new
|
|
643
|
+
throw new user_error_1.UserError('A user\'s selector doesn\'t match any of the ' +
|
|
644
644
|
'pre-aggregations defined in the data model.');
|
|
645
645
|
}
|
|
646
646
|
break;
|
|
@@ -672,7 +672,7 @@ class ApiGateway {
|
|
|
672
672
|
const start = (0, shared_1.parseUtcIntoLocalDate)([{ val: selector.dateRange[0] }], 'UTC');
|
|
673
673
|
const end = (0, shared_1.parseUtcIntoLocalDate)([{ val: selector.dateRange[1] }], 'UTC');
|
|
674
674
|
if (!start || !end) {
|
|
675
|
-
throw new
|
|
675
|
+
throw new user_error_1.UserError(`Cannot parse selector date range ${selector.dateRange}`);
|
|
676
676
|
}
|
|
677
677
|
selector.dateRange = [start, end];
|
|
678
678
|
}
|
|
@@ -842,7 +842,7 @@ class ApiGateway {
|
|
|
842
842
|
const requestStarted = new Date();
|
|
843
843
|
try {
|
|
844
844
|
const orchestratorApi = await this.getAdapterApi(context);
|
|
845
|
-
res({
|
|
845
|
+
await res({
|
|
846
846
|
result: await orchestratorApi.getPreAggregationQueueStates()
|
|
847
847
|
});
|
|
848
848
|
}
|
|
@@ -857,7 +857,7 @@ class ApiGateway {
|
|
|
857
857
|
try {
|
|
858
858
|
const { queryKeys, dataSource } = (0, query_1.normalizeQueryCancelPreAggregations)(this.parseQueryParam(query));
|
|
859
859
|
const orchestratorApi = await this.getAdapterApi(context);
|
|
860
|
-
res({
|
|
860
|
+
await res({
|
|
861
861
|
result: await orchestratorApi.cancelPreAggregationQueriesFromQueue(queryKeys, dataSource)
|
|
862
862
|
});
|
|
863
863
|
}
|
|
@@ -923,7 +923,7 @@ class ApiGateway {
|
|
|
923
923
|
rewrittenQuery = this.parseMemberExpressionsInQuery(rewrittenQuery);
|
|
924
924
|
rewrittenQuery = this.evalMemberExpressionsInQuery(rewrittenQuery);
|
|
925
925
|
}
|
|
926
|
-
return (0, query_1.normalizeQuery)(rewrittenQuery, persistent);
|
|
926
|
+
return (0, query_1.normalizeQuery)(rewrittenQuery, persistent, cacheMode);
|
|
927
927
|
}));
|
|
928
928
|
this.log({
|
|
929
929
|
type: 'Query Rewrite completed',
|
|
@@ -939,10 +939,10 @@ class ApiGateway {
|
|
|
939
939
|
if (queryType === enums_1.QueryType.BLENDING_QUERY) {
|
|
940
940
|
const queryGranularity = (0, query_1.getQueryGranularity)(normalizedQueries);
|
|
941
941
|
if (queryGranularity.length > 1) {
|
|
942
|
-
throw new
|
|
942
|
+
throw new user_error_1.UserError('Data blending query granularities must match');
|
|
943
943
|
}
|
|
944
944
|
if (queryGranularity.length === 0) {
|
|
945
|
-
throw new
|
|
945
|
+
throw new user_error_1.UserError('Data blending query without granularity is not supported');
|
|
946
946
|
}
|
|
947
947
|
}
|
|
948
948
|
return [queryType, normalizedQueries, queryNormalizationResult.map((it) => (0, query_1.remapToQueryAdapterFormat)(it.normalizedQuery))];
|
|
@@ -951,7 +951,7 @@ class ApiGateway {
|
|
|
951
951
|
try {
|
|
952
952
|
await this.assertApiScope('sql', context.securityContext);
|
|
953
953
|
const result = await this.sqlServer.sql4sql(query, disablePostProcessing, context.securityContext);
|
|
954
|
-
res({ sql: result });
|
|
954
|
+
await res({ sql: result });
|
|
955
955
|
}
|
|
956
956
|
catch (e) {
|
|
957
957
|
this.handleError({
|
|
@@ -975,7 +975,7 @@ class ApiGateway {
|
|
|
975
975
|
...sqlQuery,
|
|
976
976
|
order: ramda_1.default.fromPairs(sqlQuery.order.map(({ id: key, desc }) => [key, desc ? 'desc' : 'asc']))
|
|
977
977
|
});
|
|
978
|
-
res(queryType === enums_1.QueryType.REGULAR_QUERY ?
|
|
978
|
+
await res(queryType === enums_1.QueryType.REGULAR_QUERY ?
|
|
979
979
|
{ sql: toQuery(sqlQueries[0]) } :
|
|
980
980
|
sqlQueries.map((sqlQuery) => ({ sql: toQuery(sqlQuery) })));
|
|
981
981
|
}
|
|
@@ -1094,7 +1094,7 @@ class ApiGateway {
|
|
|
1094
1094
|
const memberToDataSource = await compilerApi.memberToDataSource(query);
|
|
1095
1095
|
const dataSources = new Set(Object.values(memberToDataSource));
|
|
1096
1096
|
const dataSourceToSqlGenerator = (await Promise.all([...dataSources].map(async (dataSource) => ({ [dataSource]: (await compilerApi.getSqlGenerator(query, dataSource)).sqlGenerator })))).reduce((a, b) => ({ ...a, ...b }), {});
|
|
1097
|
-
res({ memberToDataSource, dataSourceToSqlGenerator });
|
|
1097
|
+
await res({ memberToDataSource, dataSourceToSqlGenerator });
|
|
1098
1098
|
}
|
|
1099
1099
|
catch (e) {
|
|
1100
1100
|
this.handleError({
|
|
@@ -1156,7 +1156,7 @@ class ApiGateway {
|
|
|
1156
1156
|
const sqlQueries = await Promise.all(normalizedQueries.map(async (normalizedQuery) => (await this.getCompilerApi(context)).getSql(this.coerceForSqlQuery(normalizedQuery, context), {
|
|
1157
1157
|
includeDebugInfo: (0, shared_1.getEnv)('devMode') || context.signedWithPlaygroundAuthSecret
|
|
1158
1158
|
})));
|
|
1159
|
-
res({
|
|
1159
|
+
await res({
|
|
1160
1160
|
queryType,
|
|
1161
1161
|
normalizedQueries,
|
|
1162
1162
|
queryOrder: sqlQueries.map((sqlQuery) => ramda_1.default.fromPairs(sqlQuery.order.map(({ id: member, desc }) => [member, desc ? 'desc' : 'asc']))),
|
|
@@ -1349,7 +1349,7 @@ class ApiGateway {
|
|
|
1349
1349
|
const [queryType, normalizedQueries] = await this.getNormalizedQueries(query, context, false, false, cacheMode);
|
|
1350
1350
|
if (queryType !== enums_1.QueryType.REGULAR_QUERY &&
|
|
1351
1351
|
props.queryType == null) {
|
|
1352
|
-
throw new
|
|
1352
|
+
throw new user_error_1.UserError(`'${queryType}' query type is not supported by the client.` +
|
|
1353
1353
|
'Please update the client.');
|
|
1354
1354
|
}
|
|
1355
1355
|
let metaConfigResult = await (await this
|
|
@@ -1363,7 +1363,7 @@ class ApiGateway {
|
|
|
1363
1363
|
slowQuery = slowQuery ||
|
|
1364
1364
|
Boolean(sqlQueries[index].slowQuery);
|
|
1365
1365
|
const response = await this.getSqlResponseInternal(context, normalizedQuery, sqlQueries[index]);
|
|
1366
|
-
const annotation = (0,
|
|
1366
|
+
const annotation = (0, prepare_annotation_1.prepareAnnotation)(metaConfigResult, normalizedQuery);
|
|
1367
1367
|
return this.prepareResultTransformData(context, queryType, normalizedQuery, sqlQueries[index], annotation, response, resType);
|
|
1368
1368
|
}));
|
|
1369
1369
|
this.log({
|
|
@@ -1381,12 +1381,12 @@ class ApiGateway {
|
|
|
1381
1381
|
dbType: results.map(r => r.getRootResultObject()[0].dbType),
|
|
1382
1382
|
}, context);
|
|
1383
1383
|
if (props.queryType === 'multi') {
|
|
1384
|
-
// We prepare the final
|
|
1384
|
+
// We prepare the final JSON result on the native side
|
|
1385
1385
|
const resultMulti = new native_1.ResultMultiWrapper(results, { queryType, slowQuery });
|
|
1386
1386
|
await res(resultMulti);
|
|
1387
1387
|
}
|
|
1388
1388
|
else {
|
|
1389
|
-
// We prepare the full final
|
|
1389
|
+
// We prepare the full final JSON result on the native side
|
|
1390
1390
|
await res(results[0]);
|
|
1391
1391
|
}
|
|
1392
1392
|
}
|
|
@@ -1450,7 +1450,7 @@ class ApiGateway {
|
|
|
1450
1450
|
else {
|
|
1451
1451
|
const adapterApi = await this.getAdapterApi(context);
|
|
1452
1452
|
const response = await adapterApi.executeQuery(finalQuery);
|
|
1453
|
-
const annotation = (0,
|
|
1453
|
+
const annotation = (0, prepare_annotation_1.prepareAnnotation)(metaConfigResult, normalizedQueries[0]);
|
|
1454
1454
|
// TODO Can we just pass through data? Ensure hidden members can't be queried
|
|
1455
1455
|
results = [{
|
|
1456
1456
|
data: response.data,
|
|
@@ -1463,7 +1463,7 @@ class ApiGateway {
|
|
|
1463
1463
|
results = await Promise.all(normalizedQueries.map(async (normalizedQuery, index) => {
|
|
1464
1464
|
slowQuery = slowQuery ||
|
|
1465
1465
|
Boolean(sqlQueries[index].slowQuery);
|
|
1466
|
-
const annotation = (0,
|
|
1466
|
+
const annotation = (0, prepare_annotation_1.prepareAnnotation)(metaConfigResult, normalizedQuery);
|
|
1467
1467
|
if (request.streaming) {
|
|
1468
1468
|
return streamResponse(sqlQueries[index]);
|
|
1469
1469
|
}
|
|
@@ -1516,10 +1516,12 @@ class ApiGateway {
|
|
|
1516
1516
|
});
|
|
1517
1517
|
const state = await subscriptionState();
|
|
1518
1518
|
if (result && (!state || JSON.stringify(state.result) !== JSON.stringify(result))) {
|
|
1519
|
-
|
|
1519
|
+
// We prepare the full final JSON result on the native side
|
|
1520
|
+
await res(result.message, result.opts);
|
|
1520
1521
|
}
|
|
1521
1522
|
else if (error) {
|
|
1522
|
-
|
|
1523
|
+
// We prepare the full final JSON result on the native side
|
|
1524
|
+
await res(error.message, error.opts);
|
|
1523
1525
|
}
|
|
1524
1526
|
await subscribe({ error, result });
|
|
1525
1527
|
}
|
|
@@ -1545,14 +1547,14 @@ class ApiGateway {
|
|
|
1545
1547
|
}
|
|
1546
1548
|
parseQueryParam(query) {
|
|
1547
1549
|
if (!query || query === 'undefined') {
|
|
1548
|
-
throw new
|
|
1550
|
+
throw new user_error_1.UserError('Query param is required');
|
|
1549
1551
|
}
|
|
1550
1552
|
if (typeof query === 'string') {
|
|
1551
1553
|
try {
|
|
1552
1554
|
return JSON.parse(query);
|
|
1553
1555
|
}
|
|
1554
1556
|
catch (e) {
|
|
1555
|
-
throw new
|
|
1557
|
+
throw new user_error_1.UserError(`Unable to decode query param as JSON, error: ${e.message}`);
|
|
1556
1558
|
}
|
|
1557
1559
|
}
|
|
1558
1560
|
return query;
|
|
@@ -1587,7 +1589,7 @@ class ApiGateway {
|
|
|
1587
1589
|
const requestId = (0, shared_1.getEnv)('devMode') || context?.signedWithPlaygroundAuthSecret ? context?.requestId : undefined;
|
|
1588
1590
|
const stack = (0, shared_1.getEnv)('devMode') ? e.stack : undefined;
|
|
1589
1591
|
const plainError = e.plainMessages;
|
|
1590
|
-
if (e instanceof
|
|
1592
|
+
if (e instanceof cubejs_handler_error_1.CubejsHandlerError) {
|
|
1591
1593
|
this.log({
|
|
1592
1594
|
type: e.type,
|
|
1593
1595
|
query,
|
|
@@ -1701,14 +1703,14 @@ class ApiGateway {
|
|
|
1701
1703
|
checkAuthFn = async (auth) => {
|
|
1702
1704
|
const decoded = jsonwebtoken_1.default.decode(auth, { complete: true });
|
|
1703
1705
|
if (!decoded) {
|
|
1704
|
-
throw new
|
|
1706
|
+
throw new cubejs_handler_error_1.CubejsHandlerError(403, 'Forbidden', 'Unable to decode JWT key');
|
|
1705
1707
|
}
|
|
1706
1708
|
if (!decoded.header || !decoded.header.kid) {
|
|
1707
|
-
throw new
|
|
1709
|
+
throw new cubejs_handler_error_1.CubejsHandlerError(403, 'Forbidden', 'JWT without kid inside headers');
|
|
1708
1710
|
}
|
|
1709
1711
|
const jwk = await jwks.getJWKbyKid(typeof options.jwkUrl === 'function' ? await options.jwkUrl(decoded) : options.jwkUrl, decoded.header.kid);
|
|
1710
1712
|
if (!jwk) {
|
|
1711
|
-
throw new
|
|
1713
|
+
throw new cubejs_handler_error_1.CubejsHandlerError(403, 'Forbidden', `Unable to verify, JWK with kid: "${decoded.header.kid}" not found`);
|
|
1712
1714
|
}
|
|
1713
1715
|
return verifyToken(auth, jwk);
|
|
1714
1716
|
};
|
|
@@ -1722,13 +1724,13 @@ class ApiGateway {
|
|
|
1722
1724
|
}
|
|
1723
1725
|
catch (e) {
|
|
1724
1726
|
if (this.enforceSecurityChecks) {
|
|
1725
|
-
throw new
|
|
1727
|
+
throw new cubejs_handler_error_1.CubejsHandlerError(403, 'Forbidden', 'Invalid token', e);
|
|
1726
1728
|
}
|
|
1727
1729
|
}
|
|
1728
1730
|
}
|
|
1729
1731
|
else if (this.enforceSecurityChecks) {
|
|
1730
1732
|
// @todo Move it to 401 or 400
|
|
1731
|
-
throw new
|
|
1733
|
+
throw new cubejs_handler_error_1.CubejsHandlerError(403, 'Forbidden', 'Authorization header isn\'t set');
|
|
1732
1734
|
}
|
|
1733
1735
|
return {
|
|
1734
1736
|
securityContext: req.securityContext
|
|
@@ -1804,7 +1806,7 @@ class ApiGateway {
|
|
|
1804
1806
|
const scopes = await this.contextToApiScopesFn(securityContext || {}, (0, shared_1.getEnv)('defaultApiScope') || await this.contextToApiScopesDefFn());
|
|
1805
1807
|
const permited = scopes.indexOf(scope) >= 0;
|
|
1806
1808
|
if (!permited) {
|
|
1807
|
-
throw new
|
|
1809
|
+
throw new cubejs_handler_error_1.CubejsHandlerError(403, 'Forbidden', `API scope is missing: ${scope}`);
|
|
1808
1810
|
}
|
|
1809
1811
|
}
|
|
1810
1812
|
extractAuthorizationHeaderWithSchema(req) {
|
|
@@ -1827,7 +1829,7 @@ class ApiGateway {
|
|
|
1827
1829
|
}
|
|
1828
1830
|
}
|
|
1829
1831
|
catch (e) {
|
|
1830
|
-
if (e instanceof
|
|
1832
|
+
if (e instanceof cubejs_handler_error_1.CubejsHandlerError) {
|
|
1831
1833
|
const error = e.originalError || e;
|
|
1832
1834
|
const stack = (0, shared_1.getEnv)('devMode') ? error.stack : undefined;
|
|
1833
1835
|
this.log({
|
|
@@ -1860,7 +1862,7 @@ class ApiGateway {
|
|
|
1860
1862
|
};
|
|
1861
1863
|
requestContextMiddleware = async (req, res, next) => {
|
|
1862
1864
|
try {
|
|
1863
|
-
req.context = await this.contextByReq(req, req.securityContext, (0,
|
|
1865
|
+
req.context = await this.contextByReq(req, req.securityContext, (0, request_parser_1.getRequestIdFromRequest)(req));
|
|
1864
1866
|
req.requestStarted = new Date();
|
|
1865
1867
|
if (next) {
|
|
1866
1868
|
next();
|
|
@@ -1876,7 +1878,7 @@ class ApiGateway {
|
|
|
1876
1878
|
}
|
|
1877
1879
|
};
|
|
1878
1880
|
requestLogger = async (req, res, next) => {
|
|
1879
|
-
const details = (0,
|
|
1881
|
+
const details = (0, request_parser_1.requestParser)(req, res);
|
|
1880
1882
|
this.log({ type: 'REST API Request', ...details }, req.context);
|
|
1881
1883
|
if (next) {
|
|
1882
1884
|
next();
|
|
@@ -1907,7 +1909,7 @@ class ApiGateway {
|
|
|
1907
1909
|
(query.timeDimensions || []).forEach((td, index) => {
|
|
1908
1910
|
if (td.compareDateRange != null) {
|
|
1909
1911
|
if (queryCompareDateRange != null) {
|
|
1910
|
-
throw new
|
|
1912
|
+
throw new user_error_1.UserError('compareDateRange can only exist for one timeDimension');
|
|
1911
1913
|
}
|
|
1912
1914
|
queryCompareDateRange = td.compareDateRange;
|
|
1913
1915
|
compareDateRangeTDIndex = index;
|