@rightbrain/brain-api-client 0.0.1-dev.29.b1d5e4e
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/.openapi-generator-ignore +28 -0
- package/README.md +45 -0
- package/api.ts +27331 -0
- package/base.ts +86 -0
- package/common.ts +190 -0
- package/configuration.ts +110 -0
- package/dist/api.d.ts +17749 -0
- package/dist/api.js +22699 -0
- package/dist/base.d.ts +66 -0
- package/dist/base.js +86 -0
- package/dist/common.d.ts +65 -0
- package/dist/common.js +305 -0
- package/dist/configuration.d.ts +91 -0
- package/dist/configuration.js +45 -0
- package/dist/errors.d.ts +30 -0
- package/dist/errors.js +33 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +24 -0
- package/errors.ts +46 -0
- package/index.ts +10 -0
- package/package.json +29 -0
- package/tsconfig.json +22 -0
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;
|
package/dist/index.d.ts
ADDED
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
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rightbrain/brain-api-client",
|
|
3
|
+
"version": "0.0.1-dev.29.b1d5e4e",
|
|
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
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"axios": "^1.12.0"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@types/node": "^18.11.5",
|
|
23
|
+
"typescript": "^4.0"
|
|
24
|
+
},
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"registry": "https://registry.npmjs.org/",
|
|
27
|
+
"access": "public"
|
|
28
|
+
}
|
|
29
|
+
}
|
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
|
+
}
|