@alwaysmeticulous/client 2.40.0
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/LICENSE +15 -0
- package/README.md +3 -0
- package/dist/api/project.api.d.ts +3 -0
- package/dist/api/project.api.js +22 -0
- package/dist/api/replay.api.d.ts +8 -0
- package/dist/api/replay.api.js +35 -0
- package/dist/api/session.api.d.ts +6 -0
- package/dist/api/session.api.js +45 -0
- package/dist/api/test-run.api.d.ts +8 -0
- package/dist/api/test-run.api.js +23 -0
- package/dist/api-token.utils.d.ts +1 -0
- package/dist/api-token.utils.js +31 -0
- package/dist/client.d.ts +5 -0
- package/dist/client.js +32 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +18 -0
- package/package.json +42 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022, Meticulous Contributors
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
10
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
11
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
12
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
13
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
14
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
15
|
+
PERFORMANCE OF THIS SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getProject = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const getProject = async (client) => {
|
|
9
|
+
const { data } = await client
|
|
10
|
+
.get("projects/token-info")
|
|
11
|
+
.catch((error) => {
|
|
12
|
+
var _a;
|
|
13
|
+
if (axios_1.default.isAxiosError(error)) {
|
|
14
|
+
if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 404) {
|
|
15
|
+
return { data: null };
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
throw error;
|
|
19
|
+
});
|
|
20
|
+
return data;
|
|
21
|
+
};
|
|
22
|
+
exports.getProject = getProject;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Replay } from "@alwaysmeticulous/common";
|
|
2
|
+
import { AxiosInstance } from "axios";
|
|
3
|
+
export declare const getReplay: (client: AxiosInstance, replayId: string) => Promise<Replay>;
|
|
4
|
+
export interface ReplayDownloadUrlOutput {
|
|
5
|
+
replayId: string;
|
|
6
|
+
dowloadUrl: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const getReplayDownloadUrl: (client: AxiosInstance, replayId: string) => Promise<ReplayDownloadUrlOutput | null>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getReplayDownloadUrl = exports.getReplay = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const getReplay = async (client, replayId) => {
|
|
9
|
+
const { data } = await client.get(`replays/${replayId}`).catch((error) => {
|
|
10
|
+
var _a;
|
|
11
|
+
if (axios_1.default.isAxiosError(error)) {
|
|
12
|
+
if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 404) {
|
|
13
|
+
return { data: null };
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
throw error;
|
|
17
|
+
});
|
|
18
|
+
return data;
|
|
19
|
+
};
|
|
20
|
+
exports.getReplay = getReplay;
|
|
21
|
+
const getReplayDownloadUrl = async (client, replayId) => {
|
|
22
|
+
const { data } = await client
|
|
23
|
+
.get(`replays/${replayId}/archive-url`)
|
|
24
|
+
.catch((error) => {
|
|
25
|
+
var _a;
|
|
26
|
+
if (axios_1.default.isAxiosError(error)) {
|
|
27
|
+
if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 404) {
|
|
28
|
+
return { data: null };
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
throw error;
|
|
32
|
+
});
|
|
33
|
+
return data;
|
|
34
|
+
};
|
|
35
|
+
exports.getReplayDownloadUrl = getReplayDownloadUrl;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SessionData } from "@alwaysmeticulous/api";
|
|
2
|
+
import { AxiosInstance } from "axios";
|
|
3
|
+
export declare const getRecordedSession: (client: AxiosInstance, sessionId: string) => Promise<any>;
|
|
4
|
+
export declare const getRecordedSessionData: (client: AxiosInstance, sessionId: string) => Promise<SessionData>;
|
|
5
|
+
export declare const getRecordingCommandId: (client: AxiosInstance) => Promise<string>;
|
|
6
|
+
export declare const postSessionIdNotification: (client: AxiosInstance, sessionId: string, recordingCommandId: string) => Promise<void>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.postSessionIdNotification = exports.getRecordingCommandId = exports.getRecordedSessionData = exports.getRecordedSession = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const getRecordedSession = async (client, sessionId) => {
|
|
9
|
+
const { data } = await client.get(`sessions/${sessionId}`).catch((error) => {
|
|
10
|
+
var _a;
|
|
11
|
+
if (axios_1.default.isAxiosError(error)) {
|
|
12
|
+
if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 404) {
|
|
13
|
+
return { data: null };
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
throw error;
|
|
17
|
+
});
|
|
18
|
+
return data;
|
|
19
|
+
};
|
|
20
|
+
exports.getRecordedSession = getRecordedSession;
|
|
21
|
+
const getRecordedSessionData = async (client, sessionId) => {
|
|
22
|
+
const { data } = await client
|
|
23
|
+
.get(`sessions/${sessionId}/data`)
|
|
24
|
+
.catch((error) => {
|
|
25
|
+
var _a;
|
|
26
|
+
if (axios_1.default.isAxiosError(error)) {
|
|
27
|
+
if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 404) {
|
|
28
|
+
return { data: null };
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
throw error;
|
|
32
|
+
});
|
|
33
|
+
return data;
|
|
34
|
+
};
|
|
35
|
+
exports.getRecordedSessionData = getRecordedSessionData;
|
|
36
|
+
const getRecordingCommandId = async (client) => {
|
|
37
|
+
const { data } = await client.post("sessions/start");
|
|
38
|
+
const { recordingCommandId } = data;
|
|
39
|
+
return recordingCommandId;
|
|
40
|
+
};
|
|
41
|
+
exports.getRecordingCommandId = getRecordingCommandId;
|
|
42
|
+
const postSessionIdNotification = async (client, sessionId, recordingCommandId) => {
|
|
43
|
+
await client.post(`sessions/${sessionId}/notify`, { recordingCommandId });
|
|
44
|
+
};
|
|
45
|
+
exports.postSessionIdNotification = postSessionIdNotification;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TestRun } from "@alwaysmeticulous/api";
|
|
2
|
+
import { AxiosInstance } from "axios";
|
|
3
|
+
export interface GetLatestTestRunOptions {
|
|
4
|
+
client: AxiosInstance;
|
|
5
|
+
commitSha: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const getLatestTestRunResults: ({ client, commitSha, }: GetLatestTestRunOptions) => Promise<TestRun | null>;
|
|
8
|
+
export declare const getLatestTestRunId: (opts: GetLatestTestRunOptions) => Promise<string | null>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getLatestTestRunId = exports.getLatestTestRunResults = void 0;
|
|
4
|
+
const axios_1 = require("axios");
|
|
5
|
+
const getLatestTestRunResults = async ({ client, commitSha, }) => {
|
|
6
|
+
var _a;
|
|
7
|
+
const { data } = await client
|
|
8
|
+
.get(`test-runs/cache?commitSha=${encodeURIComponent(commitSha)}`)
|
|
9
|
+
.catch((error) => {
|
|
10
|
+
var _a;
|
|
11
|
+
if (error instanceof axios_1.AxiosError && ((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 404) {
|
|
12
|
+
return { data: null };
|
|
13
|
+
}
|
|
14
|
+
throw error;
|
|
15
|
+
});
|
|
16
|
+
return (_a = data) !== null && _a !== void 0 ? _a : null;
|
|
17
|
+
};
|
|
18
|
+
exports.getLatestTestRunResults = getLatestTestRunResults;
|
|
19
|
+
const getLatestTestRunId = async (opts) => {
|
|
20
|
+
var _a, _b;
|
|
21
|
+
return (_b = (_a = (await (0, exports.getLatestTestRunResults)(opts))) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : null;
|
|
22
|
+
};
|
|
23
|
+
exports.getLatestTestRunId = getLatestTestRunId;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getApiToken: (apiToken: string | null | undefined) => string | null;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getApiToken = void 0;
|
|
7
|
+
const fs_1 = require("fs");
|
|
8
|
+
const os_1 = require("os");
|
|
9
|
+
const path_1 = require("path");
|
|
10
|
+
const common_1 = require("@alwaysmeticulous/common");
|
|
11
|
+
const loglevel_1 = __importDefault(require("loglevel"));
|
|
12
|
+
const PERSONAL_CONFIG_FILE_PATH = ".meticulous/config.json";
|
|
13
|
+
const getApiToken = (apiToken) => {
|
|
14
|
+
const logger = loglevel_1.default.getLogger(common_1.METICULOUS_LOGGER_NAME);
|
|
15
|
+
if (apiToken) {
|
|
16
|
+
return apiToken;
|
|
17
|
+
}
|
|
18
|
+
if (process.env["METICULOUS_API_TOKEN"]) {
|
|
19
|
+
return process.env["METICULOUS_API_TOKEN"];
|
|
20
|
+
}
|
|
21
|
+
const personalConfigFileAbsolutePath = (0, path_1.join)((0, os_1.homedir)(), PERSONAL_CONFIG_FILE_PATH);
|
|
22
|
+
if ((0, fs_1.existsSync)(personalConfigFileAbsolutePath)) {
|
|
23
|
+
const config = JSON.parse((0, fs_1.readFileSync)(personalConfigFileAbsolutePath).toString("utf-8"));
|
|
24
|
+
if (config.apiToken) {
|
|
25
|
+
logger.info(`Using apiToken from ${personalConfigFileAbsolutePath}`);
|
|
26
|
+
return config.apiToken;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return null;
|
|
30
|
+
};
|
|
31
|
+
exports.getApiToken = getApiToken;
|
package/dist/client.d.ts
ADDED
package/dist/client.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createClient = void 0;
|
|
7
|
+
const common_1 = require("@alwaysmeticulous/common");
|
|
8
|
+
const axios_1 = __importDefault(require("axios"));
|
|
9
|
+
const loglevel_1 = __importDefault(require("loglevel"));
|
|
10
|
+
const api_token_utils_1 = require("./api-token.utils");
|
|
11
|
+
const BASE_API_URL = "https://app.meticulous.ai/api/";
|
|
12
|
+
const createClient = ({ apiToken: apiToken_, }) => {
|
|
13
|
+
const apiToken = (0, api_token_utils_1.getApiToken)(apiToken_);
|
|
14
|
+
if (!apiToken) {
|
|
15
|
+
const logger = loglevel_1.default.getLogger(common_1.METICULOUS_LOGGER_NAME);
|
|
16
|
+
logger.error("You must provide an API token by using the --apiToken parameter");
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
19
|
+
return axios_1.default.create({
|
|
20
|
+
baseURL: getApiUrl(),
|
|
21
|
+
headers: {
|
|
22
|
+
authorization: apiToken,
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
exports.createClient = createClient;
|
|
27
|
+
const getApiUrl = () => {
|
|
28
|
+
if (process.env["METICULOUS_API_URL"]) {
|
|
29
|
+
return process.env["METICULOUS_API_URL"];
|
|
30
|
+
}
|
|
31
|
+
return BASE_API_URL;
|
|
32
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { getProject } from "./api/project.api";
|
|
2
|
+
export { getRecordedSession, getRecordedSessionData, getRecordingCommandId, postSessionIdNotification, } from "./api/session.api";
|
|
3
|
+
export { getLatestTestRunId, getLatestTestRunResults, GetLatestTestRunOptions, } from "./api/test-run.api";
|
|
4
|
+
export { getReplay, getReplayDownloadUrl } from "./api/replay.api";
|
|
5
|
+
export { createClient, ClientOptions } from "./client";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createClient = exports.getReplayDownloadUrl = exports.getReplay = exports.getLatestTestRunResults = exports.getLatestTestRunId = exports.postSessionIdNotification = exports.getRecordingCommandId = exports.getRecordedSessionData = exports.getRecordedSession = exports.getProject = void 0;
|
|
4
|
+
var project_api_1 = require("./api/project.api");
|
|
5
|
+
Object.defineProperty(exports, "getProject", { enumerable: true, get: function () { return project_api_1.getProject; } });
|
|
6
|
+
var session_api_1 = require("./api/session.api");
|
|
7
|
+
Object.defineProperty(exports, "getRecordedSession", { enumerable: true, get: function () { return session_api_1.getRecordedSession; } });
|
|
8
|
+
Object.defineProperty(exports, "getRecordedSessionData", { enumerable: true, get: function () { return session_api_1.getRecordedSessionData; } });
|
|
9
|
+
Object.defineProperty(exports, "getRecordingCommandId", { enumerable: true, get: function () { return session_api_1.getRecordingCommandId; } });
|
|
10
|
+
Object.defineProperty(exports, "postSessionIdNotification", { enumerable: true, get: function () { return session_api_1.postSessionIdNotification; } });
|
|
11
|
+
var test_run_api_1 = require("./api/test-run.api");
|
|
12
|
+
Object.defineProperty(exports, "getLatestTestRunId", { enumerable: true, get: function () { return test_run_api_1.getLatestTestRunId; } });
|
|
13
|
+
Object.defineProperty(exports, "getLatestTestRunResults", { enumerable: true, get: function () { return test_run_api_1.getLatestTestRunResults; } });
|
|
14
|
+
var replay_api_1 = require("./api/replay.api");
|
|
15
|
+
Object.defineProperty(exports, "getReplay", { enumerable: true, get: function () { return replay_api_1.getReplay; } });
|
|
16
|
+
Object.defineProperty(exports, "getReplayDownloadUrl", { enumerable: true, get: function () { return replay_api_1.getReplayDownloadUrl; } });
|
|
17
|
+
var client_1 = require("./client");
|
|
18
|
+
Object.defineProperty(exports, "createClient", { enumerable: true, get: function () { return client_1.createClient; } });
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@alwaysmeticulous/client",
|
|
3
|
+
"version": "2.40.0",
|
|
4
|
+
"description": "Helper methods for using the Meticulous backend API",
|
|
5
|
+
"license": "ISC",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"clean": "rimraf dist tsconfig.tsbuildinfo",
|
|
13
|
+
"build": "tsc --build tsconfig.json",
|
|
14
|
+
"dev": "tsc --build tsconfig.json --watch",
|
|
15
|
+
"format": "prettier --write src",
|
|
16
|
+
"lint": "eslint src --ext=ts,tsx,js --cache",
|
|
17
|
+
"lint:commit": "eslint --cache $(git diff --relative --name-only --diff-filter=ACMRTUXB master | grep -E \"(.js$|.ts$|.tsx$)\")",
|
|
18
|
+
"lint:fix": "eslint src --ext=ts,tsx,js --cache --fix"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@alwaysmeticulous/common": "^2.40.0",
|
|
22
|
+
"axios": "^1.2.6"
|
|
23
|
+
},
|
|
24
|
+
"author": {
|
|
25
|
+
"name": "The Meticulous Team",
|
|
26
|
+
"email": "eng@meticulous.ai",
|
|
27
|
+
"url": "https://meticulous.ai"
|
|
28
|
+
},
|
|
29
|
+
"engines": {
|
|
30
|
+
"node": ">= 12"
|
|
31
|
+
},
|
|
32
|
+
"homepage": "https://github.com/alwaysmeticulous/meticulous-sdk",
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "https://github.com/alwaysmeticulous/meticulous-sdk.git",
|
|
36
|
+
"directory": "packages/cli"
|
|
37
|
+
},
|
|
38
|
+
"bugs": {
|
|
39
|
+
"url": "https://github.com/alwaysmeticulous/meticulous-sdk/issues"
|
|
40
|
+
},
|
|
41
|
+
"gitHead": "d62af712d37801e6df9c5d4d091a97b084baa51c"
|
|
42
|
+
}
|