@rightbrain/brain-api-client 0.0.1-dev.6.784ee59

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/errors.js ADDED
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isBrainError = void 0;
4
+ var axios_1 = require("axios");
5
+ /**
6
+ * Determines if an error is a Brain API error.
7
+ *
8
+ * Example usage:
9
+ * ```ts
10
+ * orgAPI.organizationIamListMembers("123").catch(
11
+ * (error: unknown) => {
12
+ * if (isBrainError(error)) {
13
+ * switch (error.response.data.reason) {
14
+ * case "INVALID_MEMBER":
15
+ * console.log(error.response.data.invalidMemberError)
16
+ * break
17
+ * case "...":
18
+ * }
19
+ * }
20
+ * }
21
+ * )
22
+ * ```
23
+ *
24
+ * @param error An error caught by an Axios response.
25
+ * @returns bool
26
+ */
27
+ function isBrainError(error) {
28
+ if (!(0, axios_1.isAxiosError)(error) || !error.response || !("reason" in error.response.data)) {
29
+ return false;
30
+ }
31
+ return true;
32
+ }
33
+ exports.isBrainError = isBrainError;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * brain core api
3
+ */
4
+ export * from "./api";
5
+ export * from "./configuration";
6
+ export * from "./errors";
package/dist/index.js ADDED
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+ /**
5
+ * brain core api
6
+ */
7
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
+ if (k2 === undefined) k2 = k;
9
+ var desc = Object.getOwnPropertyDescriptor(m, k);
10
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
+ desc = { enumerable: true, get: function() { return m[k]; } };
12
+ }
13
+ Object.defineProperty(o, k2, desc);
14
+ }) : (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ o[k2] = m[k];
17
+ }));
18
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
19
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ __exportStar(require("./api"), exports);
23
+ __exportStar(require("./configuration"), exports);
24
+ __exportStar(require("./errors"), exports);
package/errors.ts ADDED
@@ -0,0 +1,46 @@
1
+ import * as api from "./api";
2
+ import { isAxiosError, AxiosError } from "axios";
3
+
4
+ export type InternalServerError = {
5
+ "reason": "INTERNAL_ERROR",
6
+ message: string,
7
+ }
8
+
9
+ export type BrainErrorResponse =
10
+ InternalServerError
11
+ | api.InvalidMemberErrorResponse
12
+ | api.InvalidRoleErrorResponse
13
+ | api.InvalidSubjectTypeErrorResponse
14
+ | api.MalformedResourceIdentifierErrorResponse
15
+ | api.MissingAuthenticationErrorResponse
16
+ | api.PermissionCheckFailedErrorResponse;
17
+
18
+ /**
19
+ * Determines if an error is a Brain API error.
20
+ *
21
+ * Example usage:
22
+ * ```ts
23
+ * orgAPI.organizationIamListMembers("123").catch(
24
+ * (error: unknown) => {
25
+ * if (isBrainError(error)) {
26
+ * switch (error.response.data.reason) {
27
+ * case "INVALID_MEMBER":
28
+ * console.log(error.response.data.invalidMemberError)
29
+ * break
30
+ * case "...":
31
+ * }
32
+ * }
33
+ * }
34
+ * )
35
+ * ```
36
+ *
37
+ * @param error An error caught by an Axios response.
38
+ * @returns bool
39
+ */
40
+ export function isBrainError(error: unknown): error is AxiosError<BrainErrorResponse> {
41
+ if (!isAxiosError(error) || !error.response || !("reason" in error.response.data)) {
42
+ return false;
43
+ }
44
+
45
+ return true;
46
+ }
package/index.ts ADDED
@@ -0,0 +1,10 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * brain core api
5
+ */
6
+
7
+
8
+ export * from "./api";
9
+ export * from "./configuration";
10
+ export * from "./errors"
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@rightbrain/brain-api-client",
3
+ "version": "0.0.1-dev.6.784ee59",
4
+ "description": "OpenAPI client for brain-api",
5
+ "keywords": [
6
+ "axios",
7
+ "typescript",
8
+ "openapi-client",
9
+ "openapi-generator",
10
+ "brain-api-client"
11
+ ],
12
+ "license": "Unlicense",
13
+ "main": "./dist/index.js",
14
+ "typings": "./dist/index.d.ts",
15
+ "scripts": {
16
+ "build": "tsc ",
17
+ "artifactregistry-login": "npx google-artifactregistry-auth"
18
+ },
19
+ "dependencies": {
20
+ "axios": "^1.12.0"
21
+ },
22
+ "devDependencies": {
23
+ "@types/node": "^18.11.5",
24
+ "google-artifactregistry-auth": "^3.1.2",
25
+ "typescript": "^4.0"
26
+ },
27
+ "publishConfig": {
28
+ "registry": "https://registry.npmjs.org/",
29
+ "access": "public"
30
+ }
31
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "compilerOptions": {
3
+ "declaration": true,
4
+ "target": "ES5",
5
+ "module": "CommonJS",
6
+ "noImplicitAny": false,
7
+ "moduleResolution": "Node",
8
+ "outDir": "dist",
9
+ "rootDir": ".",
10
+ "lib": [
11
+ "es6",
12
+ "dom"
13
+ ],
14
+ "typeRoots": [
15
+ "node_modules/@types"
16
+ ]
17
+ },
18
+ "exclude": [
19
+ "dist",
20
+ "node_modules"
21
+ ]
22
+ }