@athenaintel/sdk 4.3.1117 → 4.3.1119
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/cjs/BaseClient.js +2 -2
- package/dist/cjs/Client.d.ts +3 -0
- package/dist/cjs/Client.js +9 -4
- package/dist/cjs/api/errors/BadGatewayError.d.ts +6 -0
- package/dist/cjs/api/errors/BadGatewayError.js +50 -0
- package/dist/cjs/api/errors/index.d.ts +1 -0
- package/dist/cjs/api/errors/index.js +1 -0
- package/dist/cjs/api/resources/index.d.ts +2 -0
- package/dist/cjs/api/resources/index.js +3 -1
- package/dist/cjs/api/resources/semanticModel/client/Client.d.ts +65 -0
- package/dist/cjs/api/resources/semanticModel/client/Client.js +301 -0
- package/dist/cjs/api/resources/semanticModel/client/index.d.ts +1 -0
- package/dist/cjs/api/resources/semanticModel/client/index.js +17 -0
- package/dist/cjs/api/resources/semanticModel/client/requests/SemanticModelQueryRequestIn.d.ts +18 -0
- package/dist/cjs/api/resources/semanticModel/client/requests/SemanticModelQueryRequestIn.js +3 -0
- package/dist/cjs/api/resources/semanticModel/client/requests/index.d.ts +1 -0
- package/dist/cjs/api/resources/semanticModel/client/requests/index.js +2 -0
- package/dist/cjs/api/resources/semanticModel/index.d.ts +1 -0
- package/dist/cjs/api/resources/semanticModel/index.js +17 -0
- package/dist/cjs/api/types/SemanticModelErrorResponse.d.ts +6 -0
- package/dist/cjs/api/types/SemanticModelErrorResponse.js +3 -0
- package/dist/cjs/api/types/SemanticModelMetaResponseOut.d.ts +7 -0
- package/dist/cjs/api/types/SemanticModelMetaResponseOut.js +3 -0
- package/dist/cjs/api/types/SemanticModelQueryResponseOut.d.ts +9 -0
- package/dist/cjs/api/types/SemanticModelQueryResponseOut.js +3 -0
- package/dist/cjs/api/types/SemanticModelTokenResponseOut.d.ts +11 -0
- package/dist/cjs/api/types/SemanticModelTokenResponseOut.js +3 -0
- package/dist/cjs/api/types/index.d.ts +4 -0
- package/dist/cjs/api/types/index.js +4 -0
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/BaseClient.mjs +2 -2
- package/dist/esm/Client.d.mts +3 -0
- package/dist/esm/Client.mjs +5 -0
- package/dist/esm/api/errors/BadGatewayError.d.mts +6 -0
- package/dist/esm/api/errors/BadGatewayError.mjs +13 -0
- package/dist/esm/api/errors/index.d.mts +1 -0
- package/dist/esm/api/errors/index.mjs +1 -0
- package/dist/esm/api/resources/index.d.mts +2 -0
- package/dist/esm/api/resources/index.mjs +2 -0
- package/dist/esm/api/resources/semanticModel/client/Client.d.mts +65 -0
- package/dist/esm/api/resources/semanticModel/client/Client.mjs +264 -0
- package/dist/esm/api/resources/semanticModel/client/index.d.mts +1 -0
- package/dist/esm/api/resources/semanticModel/client/index.mjs +1 -0
- package/dist/esm/api/resources/semanticModel/client/requests/SemanticModelQueryRequestIn.d.mts +18 -0
- package/dist/esm/api/resources/semanticModel/client/requests/SemanticModelQueryRequestIn.mjs +2 -0
- package/dist/esm/api/resources/semanticModel/client/requests/index.d.mts +1 -0
- package/dist/esm/api/resources/semanticModel/client/requests/index.mjs +1 -0
- package/dist/esm/api/resources/semanticModel/index.d.mts +1 -0
- package/dist/esm/api/resources/semanticModel/index.mjs +1 -0
- package/dist/esm/api/types/SemanticModelErrorResponse.d.mts +6 -0
- package/dist/esm/api/types/SemanticModelErrorResponse.mjs +2 -0
- package/dist/esm/api/types/SemanticModelMetaResponseOut.d.mts +7 -0
- package/dist/esm/api/types/SemanticModelMetaResponseOut.mjs +2 -0
- package/dist/esm/api/types/SemanticModelQueryResponseOut.d.mts +9 -0
- package/dist/esm/api/types/SemanticModelQueryResponseOut.mjs +2 -0
- package/dist/esm/api/types/SemanticModelTokenResponseOut.d.mts +11 -0
- package/dist/esm/api/types/SemanticModelTokenResponseOut.mjs +2 -0
- package/dist/esm/api/types/index.d.mts +4 -0
- package/dist/esm/api/types/index.mjs +4 -0
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +1 -1
- package/reference.md +200 -0
package/dist/cjs/BaseClient.js
CHANGED
|
@@ -43,8 +43,8 @@ function normalizeClientOptions(options) {
|
|
|
43
43
|
const headers = (0, headers_js_1.mergeHeaders)({
|
|
44
44
|
"X-Fern-Language": "JavaScript",
|
|
45
45
|
"X-Fern-SDK-Name": "@athenaintel/sdk",
|
|
46
|
-
"X-Fern-SDK-Version": "4.3.
|
|
47
|
-
"User-Agent": "@athenaintel/sdk/4.3.
|
|
46
|
+
"X-Fern-SDK-Version": "4.3.1119",
|
|
47
|
+
"User-Agent": "@athenaintel/sdk/4.3.1119",
|
|
48
48
|
"X-Fern-Runtime": core.RUNTIME.type,
|
|
49
49
|
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
50
50
|
}, options === null || options === void 0 ? void 0 : options.headers);
|
package/dist/cjs/Client.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { AopClient } from "./api/resources/aop/client/Client.js";
|
|
|
3
3
|
import { AssetsClient } from "./api/resources/assets/client/Client.js";
|
|
4
4
|
import { DatabasesClient } from "./api/resources/databases/client/Client.js";
|
|
5
5
|
import { QueryClient } from "./api/resources/query/client/Client.js";
|
|
6
|
+
import { SemanticModelClient } from "./api/resources/semanticModel/client/Client.js";
|
|
6
7
|
import { ThreadsClient } from "./api/resources/threads/client/Client.js";
|
|
7
8
|
import { ToolsClient } from "./api/resources/tools/client/Client.js";
|
|
8
9
|
import type { BaseClientOptions, BaseRequestOptions } from "./BaseClient.js";
|
|
@@ -20,6 +21,7 @@ export declare class AthenaIntelligenceClient {
|
|
|
20
21
|
protected _assets: AssetsClient | undefined;
|
|
21
22
|
protected _databases: DatabasesClient | undefined;
|
|
22
23
|
protected _query: QueryClient | undefined;
|
|
24
|
+
protected _semanticModel: SemanticModelClient | undefined;
|
|
23
25
|
protected _threads: ThreadsClient | undefined;
|
|
24
26
|
protected _tools: ToolsClient | undefined;
|
|
25
27
|
constructor(options: AthenaIntelligenceClient.Options);
|
|
@@ -28,6 +30,7 @@ export declare class AthenaIntelligenceClient {
|
|
|
28
30
|
get assets(): AssetsClient;
|
|
29
31
|
get databases(): DatabasesClient;
|
|
30
32
|
get query(): QueryClient;
|
|
33
|
+
get semanticModel(): SemanticModelClient;
|
|
31
34
|
get threads(): ThreadsClient;
|
|
32
35
|
get tools(): ToolsClient;
|
|
33
36
|
}
|
package/dist/cjs/Client.js
CHANGED
|
@@ -7,8 +7,9 @@ const Client_js_2 = require("./api/resources/aop/client/Client.js");
|
|
|
7
7
|
const Client_js_3 = require("./api/resources/assets/client/Client.js");
|
|
8
8
|
const Client_js_4 = require("./api/resources/databases/client/Client.js");
|
|
9
9
|
const Client_js_5 = require("./api/resources/query/client/Client.js");
|
|
10
|
-
const Client_js_6 = require("./api/resources/
|
|
11
|
-
const Client_js_7 = require("./api/resources/
|
|
10
|
+
const Client_js_6 = require("./api/resources/semanticModel/client/Client.js");
|
|
11
|
+
const Client_js_7 = require("./api/resources/threads/client/Client.js");
|
|
12
|
+
const Client_js_8 = require("./api/resources/tools/client/Client.js");
|
|
12
13
|
const BaseClient_js_1 = require("./BaseClient.js");
|
|
13
14
|
class AthenaIntelligenceClient {
|
|
14
15
|
constructor(options) {
|
|
@@ -34,13 +35,17 @@ class AthenaIntelligenceClient {
|
|
|
34
35
|
var _a;
|
|
35
36
|
return ((_a = this._query) !== null && _a !== void 0 ? _a : (this._query = new Client_js_5.QueryClient(this._options)));
|
|
36
37
|
}
|
|
38
|
+
get semanticModel() {
|
|
39
|
+
var _a;
|
|
40
|
+
return ((_a = this._semanticModel) !== null && _a !== void 0 ? _a : (this._semanticModel = new Client_js_6.SemanticModelClient(this._options)));
|
|
41
|
+
}
|
|
37
42
|
get threads() {
|
|
38
43
|
var _a;
|
|
39
|
-
return ((_a = this._threads) !== null && _a !== void 0 ? _a : (this._threads = new
|
|
44
|
+
return ((_a = this._threads) !== null && _a !== void 0 ? _a : (this._threads = new Client_js_7.ThreadsClient(this._options)));
|
|
40
45
|
}
|
|
41
46
|
get tools() {
|
|
42
47
|
var _a;
|
|
43
|
-
return ((_a = this._tools) !== null && _a !== void 0 ? _a : (this._tools = new
|
|
48
|
+
return ((_a = this._tools) !== null && _a !== void 0 ? _a : (this._tools = new Client_js_8.ToolsClient(this._options)));
|
|
44
49
|
}
|
|
45
50
|
}
|
|
46
51
|
exports.AthenaIntelligenceClient = AthenaIntelligenceClient;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type * as core from "../../core/index.js";
|
|
2
|
+
import * as errors from "../../errors/index.js";
|
|
3
|
+
import type * as AthenaIntelligence from "../index.js";
|
|
4
|
+
export declare class BadGatewayError extends errors.AthenaIntelligenceError {
|
|
5
|
+
constructor(body: AthenaIntelligence.SemanticModelErrorResponse, rawResponse?: core.RawResponse);
|
|
6
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.BadGatewayError = void 0;
|
|
38
|
+
const errors = __importStar(require("../../errors/index.js"));
|
|
39
|
+
class BadGatewayError extends errors.AthenaIntelligenceError {
|
|
40
|
+
constructor(body, rawResponse) {
|
|
41
|
+
super({
|
|
42
|
+
message: "BadGatewayError",
|
|
43
|
+
statusCode: 502,
|
|
44
|
+
body: body,
|
|
45
|
+
rawResponse: rawResponse,
|
|
46
|
+
});
|
|
47
|
+
Object.setPrototypeOf(this, BadGatewayError.prototype);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.BadGatewayError = BadGatewayError;
|
|
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./BadGatewayError.js"), exports);
|
|
17
18
|
__exportStar(require("./BadRequestError.js"), exports);
|
|
18
19
|
__exportStar(require("./ConflictError.js"), exports);
|
|
19
20
|
__exportStar(require("./ContentTooLargeError.js"), exports);
|
|
@@ -7,6 +7,8 @@ export * from "./databases/client/requests/index.js";
|
|
|
7
7
|
export * as databases from "./databases/index.js";
|
|
8
8
|
export * from "./query/client/requests/index.js";
|
|
9
9
|
export * as query from "./query/index.js";
|
|
10
|
+
export * from "./semanticModel/client/requests/index.js";
|
|
11
|
+
export * as semanticModel from "./semanticModel/index.js";
|
|
10
12
|
export * as threads from "./threads/index.js";
|
|
11
13
|
export * from "./tools/client/requests/index.js";
|
|
12
14
|
export * as tools from "./tools/index.js";
|
|
@@ -36,7 +36,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
36
36
|
};
|
|
37
37
|
})();
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.tools = exports.threads = exports.query = exports.databases = exports.assets = exports.aop = exports.agents = void 0;
|
|
39
|
+
exports.tools = exports.threads = exports.semanticModel = exports.query = exports.databases = exports.assets = exports.aop = exports.agents = void 0;
|
|
40
40
|
__exportStar(require("./agents/client/requests/index.js"), exports);
|
|
41
41
|
exports.agents = __importStar(require("./agents/index.js"));
|
|
42
42
|
exports.aop = __importStar(require("./aop/index.js"));
|
|
@@ -46,6 +46,8 @@ __exportStar(require("./databases/client/requests/index.js"), exports);
|
|
|
46
46
|
exports.databases = __importStar(require("./databases/index.js"));
|
|
47
47
|
__exportStar(require("./query/client/requests/index.js"), exports);
|
|
48
48
|
exports.query = __importStar(require("./query/index.js"));
|
|
49
|
+
__exportStar(require("./semanticModel/client/requests/index.js"), exports);
|
|
50
|
+
exports.semanticModel = __importStar(require("./semanticModel/index.js"));
|
|
49
51
|
exports.threads = __importStar(require("./threads/index.js"));
|
|
50
52
|
__exportStar(require("./tools/client/requests/index.js"), exports);
|
|
51
53
|
exports.tools = __importStar(require("./tools/index.js"));
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js";
|
|
2
|
+
import { type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js";
|
|
3
|
+
import * as core from "../../../../core/index.js";
|
|
4
|
+
import * as AthenaIntelligence from "../../../index.js";
|
|
5
|
+
export declare namespace SemanticModelClient {
|
|
6
|
+
interface Options extends BaseClientOptions {
|
|
7
|
+
}
|
|
8
|
+
interface RequestOptions extends BaseRequestOptions {
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export declare class SemanticModelClient {
|
|
12
|
+
protected readonly _options: NormalizedClientOptionsWithAuth<SemanticModelClient.Options>;
|
|
13
|
+
constructor(options: SemanticModelClient.Options);
|
|
14
|
+
/**
|
|
15
|
+
* Generate a short-lived JWT token for direct access to the semantic model's Cube REST API. Use this token to query /cubejs-api/v1/load and /cubejs-api/v1/meta directly. Token expires after 1 hour. The token carries only the model ID and schema hash — database credentials are NOT included and are resolved server-side by Cube via callback.
|
|
16
|
+
*
|
|
17
|
+
* @param {string} asset_id
|
|
18
|
+
* @param {SemanticModelClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
19
|
+
*
|
|
20
|
+
* @throws {@link AthenaIntelligence.BadRequestError}
|
|
21
|
+
* @throws {@link AthenaIntelligence.UnauthorizedError}
|
|
22
|
+
* @throws {@link AthenaIntelligence.NotFoundError}
|
|
23
|
+
* @throws {@link AthenaIntelligence.UnprocessableEntityError}
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* await client.semanticModel.generateToken("asset_id")
|
|
27
|
+
*/
|
|
28
|
+
generateToken(asset_id: string, requestOptions?: SemanticModelClient.RequestOptions): core.HttpResponsePromise<AthenaIntelligence.SemanticModelTokenResponseOut>;
|
|
29
|
+
private __generateToken;
|
|
30
|
+
/**
|
|
31
|
+
* Get metadata for a semantic model including all cubes, measures, dimensions, segments, and joins.
|
|
32
|
+
*
|
|
33
|
+
* @param {string} asset_id
|
|
34
|
+
* @param {SemanticModelClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
35
|
+
*
|
|
36
|
+
* @throws {@link AthenaIntelligence.UnauthorizedError}
|
|
37
|
+
* @throws {@link AthenaIntelligence.NotFoundError}
|
|
38
|
+
* @throws {@link AthenaIntelligence.UnprocessableEntityError}
|
|
39
|
+
* @throws {@link AthenaIntelligence.BadGatewayError}
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* await client.semanticModel.getMeta("asset_id")
|
|
43
|
+
*/
|
|
44
|
+
getMeta(asset_id: string, requestOptions?: SemanticModelClient.RequestOptions): core.HttpResponsePromise<AthenaIntelligence.SemanticModelMetaResponseOut>;
|
|
45
|
+
private __getMeta;
|
|
46
|
+
/**
|
|
47
|
+
* Execute a metric query against a semantic model. Specify measures, optional dimensions, filters, and time dimensions. Returns structured data rows.
|
|
48
|
+
*
|
|
49
|
+
* @param {string} asset_id
|
|
50
|
+
* @param {AthenaIntelligence.SemanticModelQueryRequestIn} request
|
|
51
|
+
* @param {SemanticModelClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
52
|
+
*
|
|
53
|
+
* @throws {@link AthenaIntelligence.UnauthorizedError}
|
|
54
|
+
* @throws {@link AthenaIntelligence.NotFoundError}
|
|
55
|
+
* @throws {@link AthenaIntelligence.UnprocessableEntityError}
|
|
56
|
+
* @throws {@link AthenaIntelligence.BadGatewayError}
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* await client.semanticModel.query("asset_id", {
|
|
60
|
+
* measures: ["orders.count", "orders.total_revenue"]
|
|
61
|
+
* })
|
|
62
|
+
*/
|
|
63
|
+
query(asset_id: string, request: AthenaIntelligence.SemanticModelQueryRequestIn, requestOptions?: SemanticModelClient.RequestOptions): core.HttpResponsePromise<AthenaIntelligence.SemanticModelQueryResponseOut>;
|
|
64
|
+
private __query;
|
|
65
|
+
}
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
37
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
38
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
39
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
40
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
41
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
42
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
+
exports.SemanticModelClient = void 0;
|
|
47
|
+
const BaseClient_js_1 = require("../../../../BaseClient.js");
|
|
48
|
+
const headers_js_1 = require("../../../../core/headers.js");
|
|
49
|
+
const core = __importStar(require("../../../../core/index.js"));
|
|
50
|
+
const environments = __importStar(require("../../../../environments.js"));
|
|
51
|
+
const errors = __importStar(require("../../../../errors/index.js"));
|
|
52
|
+
const AthenaIntelligence = __importStar(require("../../../index.js"));
|
|
53
|
+
class SemanticModelClient {
|
|
54
|
+
constructor(options) {
|
|
55
|
+
this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Generate a short-lived JWT token for direct access to the semantic model's Cube REST API. Use this token to query /cubejs-api/v1/load and /cubejs-api/v1/meta directly. Token expires after 1 hour. The token carries only the model ID and schema hash — database credentials are NOT included and are resolved server-side by Cube via callback.
|
|
59
|
+
*
|
|
60
|
+
* @param {string} asset_id
|
|
61
|
+
* @param {SemanticModelClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
62
|
+
*
|
|
63
|
+
* @throws {@link AthenaIntelligence.BadRequestError}
|
|
64
|
+
* @throws {@link AthenaIntelligence.UnauthorizedError}
|
|
65
|
+
* @throws {@link AthenaIntelligence.NotFoundError}
|
|
66
|
+
* @throws {@link AthenaIntelligence.UnprocessableEntityError}
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* await client.semanticModel.generateToken("asset_id")
|
|
70
|
+
*/
|
|
71
|
+
generateToken(asset_id, requestOptions) {
|
|
72
|
+
return core.HttpResponsePromise.fromPromise(this.__generateToken(asset_id, requestOptions));
|
|
73
|
+
}
|
|
74
|
+
__generateToken(asset_id, requestOptions) {
|
|
75
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
76
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
77
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
78
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
79
|
+
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
80
|
+
url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.AthenaIntelligenceEnvironment.Production, `api/v0/semantic-model/${core.url.encodePathParam(asset_id)}/generate-token`),
|
|
81
|
+
method: "POST",
|
|
82
|
+
headers: _headers,
|
|
83
|
+
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
|
|
84
|
+
timeoutMs: ((_g = (_e = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _e !== void 0 ? _e : (_f = this._options) === null || _f === void 0 ? void 0 : _f.timeoutInSeconds) !== null && _g !== void 0 ? _g : 60) * 1000,
|
|
85
|
+
maxRetries: (_h = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _h !== void 0 ? _h : (_j = this._options) === null || _j === void 0 ? void 0 : _j.maxRetries,
|
|
86
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
87
|
+
fetchFn: (_k = this._options) === null || _k === void 0 ? void 0 : _k.fetch,
|
|
88
|
+
logging: this._options.logging,
|
|
89
|
+
});
|
|
90
|
+
if (_response.ok) {
|
|
91
|
+
return {
|
|
92
|
+
data: _response.body,
|
|
93
|
+
rawResponse: _response.rawResponse,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
if (_response.error.reason === "status-code") {
|
|
97
|
+
switch (_response.error.statusCode) {
|
|
98
|
+
case 400:
|
|
99
|
+
throw new AthenaIntelligence.BadRequestError(_response.error.body, _response.rawResponse);
|
|
100
|
+
case 401:
|
|
101
|
+
throw new AthenaIntelligence.UnauthorizedError(_response.error.body, _response.rawResponse);
|
|
102
|
+
case 404:
|
|
103
|
+
throw new AthenaIntelligence.NotFoundError(_response.error.body, _response.rawResponse);
|
|
104
|
+
case 422:
|
|
105
|
+
throw new AthenaIntelligence.UnprocessableEntityError(_response.error.body, _response.rawResponse);
|
|
106
|
+
default:
|
|
107
|
+
throw new errors.AthenaIntelligenceError({
|
|
108
|
+
statusCode: _response.error.statusCode,
|
|
109
|
+
body: _response.error.body,
|
|
110
|
+
rawResponse: _response.rawResponse,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
switch (_response.error.reason) {
|
|
115
|
+
case "non-json":
|
|
116
|
+
throw new errors.AthenaIntelligenceError({
|
|
117
|
+
statusCode: _response.error.statusCode,
|
|
118
|
+
body: _response.error.rawBody,
|
|
119
|
+
rawResponse: _response.rawResponse,
|
|
120
|
+
});
|
|
121
|
+
case "body-is-null":
|
|
122
|
+
throw new errors.AthenaIntelligenceError({
|
|
123
|
+
statusCode: _response.error.statusCode,
|
|
124
|
+
rawResponse: _response.rawResponse,
|
|
125
|
+
});
|
|
126
|
+
case "timeout":
|
|
127
|
+
throw new errors.AthenaIntelligenceTimeoutError("Timeout exceeded when calling POST /api/v0/semantic-model/{asset_id}/generate-token.");
|
|
128
|
+
case "unknown":
|
|
129
|
+
throw new errors.AthenaIntelligenceError({
|
|
130
|
+
message: _response.error.errorMessage,
|
|
131
|
+
rawResponse: _response.rawResponse,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Get metadata for a semantic model including all cubes, measures, dimensions, segments, and joins.
|
|
138
|
+
*
|
|
139
|
+
* @param {string} asset_id
|
|
140
|
+
* @param {SemanticModelClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
141
|
+
*
|
|
142
|
+
* @throws {@link AthenaIntelligence.UnauthorizedError}
|
|
143
|
+
* @throws {@link AthenaIntelligence.NotFoundError}
|
|
144
|
+
* @throws {@link AthenaIntelligence.UnprocessableEntityError}
|
|
145
|
+
* @throws {@link AthenaIntelligence.BadGatewayError}
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* await client.semanticModel.getMeta("asset_id")
|
|
149
|
+
*/
|
|
150
|
+
getMeta(asset_id, requestOptions) {
|
|
151
|
+
return core.HttpResponsePromise.fromPromise(this.__getMeta(asset_id, requestOptions));
|
|
152
|
+
}
|
|
153
|
+
__getMeta(asset_id, requestOptions) {
|
|
154
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
155
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
156
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
157
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
158
|
+
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
159
|
+
url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.AthenaIntelligenceEnvironment.Production, `api/v0/semantic-model/${core.url.encodePathParam(asset_id)}/meta`),
|
|
160
|
+
method: "GET",
|
|
161
|
+
headers: _headers,
|
|
162
|
+
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
|
|
163
|
+
timeoutMs: ((_g = (_e = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _e !== void 0 ? _e : (_f = this._options) === null || _f === void 0 ? void 0 : _f.timeoutInSeconds) !== null && _g !== void 0 ? _g : 60) * 1000,
|
|
164
|
+
maxRetries: (_h = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _h !== void 0 ? _h : (_j = this._options) === null || _j === void 0 ? void 0 : _j.maxRetries,
|
|
165
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
166
|
+
fetchFn: (_k = this._options) === null || _k === void 0 ? void 0 : _k.fetch,
|
|
167
|
+
logging: this._options.logging,
|
|
168
|
+
});
|
|
169
|
+
if (_response.ok) {
|
|
170
|
+
return {
|
|
171
|
+
data: _response.body,
|
|
172
|
+
rawResponse: _response.rawResponse,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
if (_response.error.reason === "status-code") {
|
|
176
|
+
switch (_response.error.statusCode) {
|
|
177
|
+
case 401:
|
|
178
|
+
throw new AthenaIntelligence.UnauthorizedError(_response.error.body, _response.rawResponse);
|
|
179
|
+
case 404:
|
|
180
|
+
throw new AthenaIntelligence.NotFoundError(_response.error.body, _response.rawResponse);
|
|
181
|
+
case 422:
|
|
182
|
+
throw new AthenaIntelligence.UnprocessableEntityError(_response.error.body, _response.rawResponse);
|
|
183
|
+
case 502:
|
|
184
|
+
throw new AthenaIntelligence.BadGatewayError(_response.error.body, _response.rawResponse);
|
|
185
|
+
default:
|
|
186
|
+
throw new errors.AthenaIntelligenceError({
|
|
187
|
+
statusCode: _response.error.statusCode,
|
|
188
|
+
body: _response.error.body,
|
|
189
|
+
rawResponse: _response.rawResponse,
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
switch (_response.error.reason) {
|
|
194
|
+
case "non-json":
|
|
195
|
+
throw new errors.AthenaIntelligenceError({
|
|
196
|
+
statusCode: _response.error.statusCode,
|
|
197
|
+
body: _response.error.rawBody,
|
|
198
|
+
rawResponse: _response.rawResponse,
|
|
199
|
+
});
|
|
200
|
+
case "body-is-null":
|
|
201
|
+
throw new errors.AthenaIntelligenceError({
|
|
202
|
+
statusCode: _response.error.statusCode,
|
|
203
|
+
rawResponse: _response.rawResponse,
|
|
204
|
+
});
|
|
205
|
+
case "timeout":
|
|
206
|
+
throw new errors.AthenaIntelligenceTimeoutError("Timeout exceeded when calling GET /api/v0/semantic-model/{asset_id}/meta.");
|
|
207
|
+
case "unknown":
|
|
208
|
+
throw new errors.AthenaIntelligenceError({
|
|
209
|
+
message: _response.error.errorMessage,
|
|
210
|
+
rawResponse: _response.rawResponse,
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Execute a metric query against a semantic model. Specify measures, optional dimensions, filters, and time dimensions. Returns structured data rows.
|
|
217
|
+
*
|
|
218
|
+
* @param {string} asset_id
|
|
219
|
+
* @param {AthenaIntelligence.SemanticModelQueryRequestIn} request
|
|
220
|
+
* @param {SemanticModelClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
221
|
+
*
|
|
222
|
+
* @throws {@link AthenaIntelligence.UnauthorizedError}
|
|
223
|
+
* @throws {@link AthenaIntelligence.NotFoundError}
|
|
224
|
+
* @throws {@link AthenaIntelligence.UnprocessableEntityError}
|
|
225
|
+
* @throws {@link AthenaIntelligence.BadGatewayError}
|
|
226
|
+
*
|
|
227
|
+
* @example
|
|
228
|
+
* await client.semanticModel.query("asset_id", {
|
|
229
|
+
* measures: ["orders.count", "orders.total_revenue"]
|
|
230
|
+
* })
|
|
231
|
+
*/
|
|
232
|
+
query(asset_id, request, requestOptions) {
|
|
233
|
+
return core.HttpResponsePromise.fromPromise(this.__query(asset_id, request, requestOptions));
|
|
234
|
+
}
|
|
235
|
+
__query(asset_id, request, requestOptions) {
|
|
236
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
237
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
238
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
239
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
240
|
+
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
241
|
+
url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.AthenaIntelligenceEnvironment.Production, `api/v0/semantic-model/${core.url.encodePathParam(asset_id)}/query`),
|
|
242
|
+
method: "POST",
|
|
243
|
+
headers: _headers,
|
|
244
|
+
contentType: "application/json",
|
|
245
|
+
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
|
|
246
|
+
requestType: "json",
|
|
247
|
+
body: request,
|
|
248
|
+
timeoutMs: ((_g = (_e = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _e !== void 0 ? _e : (_f = this._options) === null || _f === void 0 ? void 0 : _f.timeoutInSeconds) !== null && _g !== void 0 ? _g : 60) * 1000,
|
|
249
|
+
maxRetries: (_h = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _h !== void 0 ? _h : (_j = this._options) === null || _j === void 0 ? void 0 : _j.maxRetries,
|
|
250
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
251
|
+
fetchFn: (_k = this._options) === null || _k === void 0 ? void 0 : _k.fetch,
|
|
252
|
+
logging: this._options.logging,
|
|
253
|
+
});
|
|
254
|
+
if (_response.ok) {
|
|
255
|
+
return {
|
|
256
|
+
data: _response.body,
|
|
257
|
+
rawResponse: _response.rawResponse,
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
if (_response.error.reason === "status-code") {
|
|
261
|
+
switch (_response.error.statusCode) {
|
|
262
|
+
case 401:
|
|
263
|
+
throw new AthenaIntelligence.UnauthorizedError(_response.error.body, _response.rawResponse);
|
|
264
|
+
case 404:
|
|
265
|
+
throw new AthenaIntelligence.NotFoundError(_response.error.body, _response.rawResponse);
|
|
266
|
+
case 422:
|
|
267
|
+
throw new AthenaIntelligence.UnprocessableEntityError(_response.error.body, _response.rawResponse);
|
|
268
|
+
case 502:
|
|
269
|
+
throw new AthenaIntelligence.BadGatewayError(_response.error.body, _response.rawResponse);
|
|
270
|
+
default:
|
|
271
|
+
throw new errors.AthenaIntelligenceError({
|
|
272
|
+
statusCode: _response.error.statusCode,
|
|
273
|
+
body: _response.error.body,
|
|
274
|
+
rawResponse: _response.rawResponse,
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
switch (_response.error.reason) {
|
|
279
|
+
case "non-json":
|
|
280
|
+
throw new errors.AthenaIntelligenceError({
|
|
281
|
+
statusCode: _response.error.statusCode,
|
|
282
|
+
body: _response.error.rawBody,
|
|
283
|
+
rawResponse: _response.rawResponse,
|
|
284
|
+
});
|
|
285
|
+
case "body-is-null":
|
|
286
|
+
throw new errors.AthenaIntelligenceError({
|
|
287
|
+
statusCode: _response.error.statusCode,
|
|
288
|
+
rawResponse: _response.rawResponse,
|
|
289
|
+
});
|
|
290
|
+
case "timeout":
|
|
291
|
+
throw new errors.AthenaIntelligenceTimeoutError("Timeout exceeded when calling POST /api/v0/semantic-model/{asset_id}/query.");
|
|
292
|
+
case "unknown":
|
|
293
|
+
throw new errors.AthenaIntelligenceError({
|
|
294
|
+
message: _response.error.errorMessage,
|
|
295
|
+
rawResponse: _response.rawResponse,
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
exports.SemanticModelClient = SemanticModelClient;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./requests/index.js";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./requests/index.js"), exports);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @example
|
|
3
|
+
* {
|
|
4
|
+
* measures: ["orders.count", "orders.total_revenue"]
|
|
5
|
+
* }
|
|
6
|
+
*/
|
|
7
|
+
export interface SemanticModelQueryRequestIn {
|
|
8
|
+
/** Optional dimension identifiers for grouping */
|
|
9
|
+
dimensions?: string[];
|
|
10
|
+
/** Optional filters */
|
|
11
|
+
filters?: Record<string, unknown>[];
|
|
12
|
+
/** Maximum rows to return */
|
|
13
|
+
limit?: number;
|
|
14
|
+
/** List of measure identifiers, e.g. ["orders.total_revenue"] */
|
|
15
|
+
measures: string[];
|
|
16
|
+
/** Optional time dimension configs */
|
|
17
|
+
time_dimensions?: Record<string, unknown>[];
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { SemanticModelQueryRequestIn } from "./SemanticModelQueryRequestIn.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./client/index.js";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./client/index.js"), exports);
|