infrahub-sdk 0.0.2 → 0.0.4
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/.github/workflows/publish.yml +1 -0
- package/dist/branch.d.ts +20 -0
- package/dist/branch.js +105 -0
- package/dist/cjs/index.js +65 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/client.d.ts +6 -0
- package/dist/client.js +35 -0
- package/dist/constants.d.ts +0 -0
- package/dist/constants.js +1 -0
- package/dist/esm/index.js +32 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/graphql/branch.d.ts +23 -0
- package/dist/graphql/branch.js +35 -0
- package/dist/graphql/client.d.ts +71 -0
- package/dist/graphql/client.js +82 -0
- package/dist/graphql.d.ts +31 -0
- package/dist/graphql.js +174 -0
- package/dist/index.d.ts +52 -0
- package/dist/index.js +128 -0
- package/dist/index.test.d.ts +1 -0
- package/dist/index.test.js +62 -0
- package/dist/types/client.d.ts +7 -0
- package/dist/types/client.d.ts.map +1 -0
- package/dist/types/constants.d.ts +1 -0
- package/dist/types/constants.d.ts.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/utils/auth.d.ts +1 -0
- package/dist/types/utils/auth.d.ts.map +1 -0
- package/dist/types/utils/error-handling.d.ts +1 -0
- package/dist/types/utils/error-handling.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +1 -0
- package/dist/types/utils/index.d.ts.map +1 -0
- package/dist/types/utils/validation.d.ts +1 -0
- package/dist/types/utils/validation.d.ts.map +1 -0
- package/dist/types.d.ts +3144 -0
- package/dist/types.js +6 -0
- package/dist/utils/auth.d.ts +0 -0
- package/dist/utils/auth.js +1 -0
- package/dist/utils/error-handling.d.ts +0 -0
- package/dist/utils/error-handling.js +1 -0
- package/dist/utils/index.d.ts +0 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/validation.d.ts +0 -0
- package/dist/utils/validation.js +1 -0
- package/package.json +2 -1
- package/src/branch.ts +130 -0
- package/src/graphql/branch.ts +61 -0
- package/src/graphql/client.ts +158 -0
- package/src/graphql.ts +266 -0
- package/src/index.ts +36 -2
- package/test/main.js +11 -0
- package/test/package-lock.json +1044 -0
- package/test/package.json +14 -0
- package/tsconfig.json +1 -1
package/dist/branch.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { InfrahubClient } from './index';
|
|
2
|
+
import { BranchResponse, BranchCreateInput } from './graphql/branch';
|
|
3
|
+
export declare class BranchNotFoundError extends Error {
|
|
4
|
+
constructor(identifier: string);
|
|
5
|
+
}
|
|
6
|
+
export declare class InfrahubBranchManager {
|
|
7
|
+
private client;
|
|
8
|
+
constructor(client: InfrahubClient);
|
|
9
|
+
/**
|
|
10
|
+
* Fetches all branches using GraphQL and returns an object mapping branch names to branch data.
|
|
11
|
+
*/
|
|
12
|
+
all(): Promise<Record<string, BranchResponse>>;
|
|
13
|
+
/**
|
|
14
|
+
* Fetches a specific branch by name.
|
|
15
|
+
* @param branchName The name of the branch to fetch.
|
|
16
|
+
*/
|
|
17
|
+
get(branchName: string): Promise<BranchResponse | null>;
|
|
18
|
+
create(input: BranchCreateInput): Promise<BranchResponse>;
|
|
19
|
+
delete(branchName: string): Promise<boolean>;
|
|
20
|
+
}
|
package/dist/branch.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InfrahubBranchManager = exports.BranchNotFoundError = void 0;
|
|
4
|
+
const graphql_1 = require("./graphql");
|
|
5
|
+
const branch_1 = require("./graphql/branch");
|
|
6
|
+
class BranchNotFoundError extends Error {
|
|
7
|
+
constructor(identifier) {
|
|
8
|
+
super(`Branch not found: ${identifier}`);
|
|
9
|
+
this.name = 'BranchNotFoundError';
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.BranchNotFoundError = BranchNotFoundError;
|
|
13
|
+
const MUTATION_QUERY_TASK = { ok: null, task: { id: null } };
|
|
14
|
+
const MUTATION_QUERY_DATA = {
|
|
15
|
+
ok: null,
|
|
16
|
+
object: {
|
|
17
|
+
id: null,
|
|
18
|
+
name: null,
|
|
19
|
+
description: null,
|
|
20
|
+
origin_branch: null,
|
|
21
|
+
branched_from: null,
|
|
22
|
+
is_default: null,
|
|
23
|
+
sync_with_git: null,
|
|
24
|
+
has_schema_changes: null
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
// InfrahubBranchManager class to manage branches via GraphQL
|
|
28
|
+
class InfrahubBranchManager {
|
|
29
|
+
constructor(client) {
|
|
30
|
+
this.client = client;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Fetches all branches using GraphQL and returns an object mapping branch names to branch data.
|
|
34
|
+
*/
|
|
35
|
+
async all() {
|
|
36
|
+
const response = await this.client.executeGraphQL(branch_1.BranchAllQuery);
|
|
37
|
+
const branches = response.Branch || [];
|
|
38
|
+
const result = {};
|
|
39
|
+
branches.forEach((branch) => {
|
|
40
|
+
result[branch.name] = branch;
|
|
41
|
+
});
|
|
42
|
+
return result;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Fetches a specific branch by name.
|
|
46
|
+
* @param branchName The name of the branch to fetch.
|
|
47
|
+
*/
|
|
48
|
+
async get(branchName) {
|
|
49
|
+
const response = await this.client.executeGraphQL(branch_1.BranchGetQuery, {
|
|
50
|
+
name: branchName
|
|
51
|
+
});
|
|
52
|
+
const branchArr = response.Branch || [];
|
|
53
|
+
if (!branchArr.length) {
|
|
54
|
+
throw new BranchNotFoundError(branchName);
|
|
55
|
+
}
|
|
56
|
+
return branchArr[0];
|
|
57
|
+
}
|
|
58
|
+
async create(input) {
|
|
59
|
+
const inputData = {
|
|
60
|
+
background_execution: input.wait_until_completion,
|
|
61
|
+
data: {
|
|
62
|
+
name: input.name,
|
|
63
|
+
description: input.description,
|
|
64
|
+
sync_with_git: input.sync_with_git
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
// set mutation query to MUTATION_QUERY_TASK if brackground_execution is true
|
|
68
|
+
const mutationQuery = input.wait_until_completion
|
|
69
|
+
? MUTATION_QUERY_TASK
|
|
70
|
+
: MUTATION_QUERY_DATA;
|
|
71
|
+
const mutation = new graphql_1.Mutation({
|
|
72
|
+
mutation: 'BranchCreate',
|
|
73
|
+
inputData: inputData,
|
|
74
|
+
query: mutationQuery,
|
|
75
|
+
name: 'CreateBranch'
|
|
76
|
+
});
|
|
77
|
+
console.log(mutation.render());
|
|
78
|
+
const response = await this.client.executeGraphQL(mutation.render());
|
|
79
|
+
// Adjust the response path as needed based on your API
|
|
80
|
+
const branchData = response.BranchCreate?.object || response.BranchCreate?.task || null;
|
|
81
|
+
if (!branchData) {
|
|
82
|
+
throw new Error('Branch creation failed');
|
|
83
|
+
}
|
|
84
|
+
return branchData;
|
|
85
|
+
}
|
|
86
|
+
async delete(branchName) {
|
|
87
|
+
const inputData = {
|
|
88
|
+
data: {
|
|
89
|
+
name: branchName
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
const mutation = new graphql_1.Mutation({
|
|
93
|
+
mutation: 'BranchDelete',
|
|
94
|
+
inputData: inputData,
|
|
95
|
+
query: { ok: null },
|
|
96
|
+
name: 'DeleteBranch'
|
|
97
|
+
});
|
|
98
|
+
const response = await this.client.executeGraphQL(mutation.render(), {
|
|
99
|
+
input: inputData
|
|
100
|
+
});
|
|
101
|
+
console.log(response);
|
|
102
|
+
return !!(response.BranchDelete && response.BranchDelete.ok);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
exports.InfrahubBranchManager = InfrahubBranchManager;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
InfrahubClient: () => InfrahubClient
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(index_exports);
|
|
36
|
+
|
|
37
|
+
// src/client.ts
|
|
38
|
+
var import_axios = __toESM(require("axios"), 1);
|
|
39
|
+
var InfrahubClient = class {
|
|
40
|
+
constructor(baseURL, token) {
|
|
41
|
+
this.axiosInstance = import_axios.default.create({
|
|
42
|
+
baseURL,
|
|
43
|
+
headers: {
|
|
44
|
+
"Content-Type": "application/json"
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
if (token) {
|
|
48
|
+
this.setAuthToken(token);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
setAuthToken(token) {
|
|
52
|
+
this.axiosInstance.defaults.headers.common["X-INFRAHUB-KEY"] = token;
|
|
53
|
+
}
|
|
54
|
+
// get info from /api/info endpoint
|
|
55
|
+
async getInfo() {
|
|
56
|
+
try {
|
|
57
|
+
const response = await this.axiosInstance.get("/api/info");
|
|
58
|
+
return response.data;
|
|
59
|
+
} catch (error) {
|
|
60
|
+
console.error("Error fetching info:", error);
|
|
61
|
+
throw error;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/index.ts", "../../src/client.ts"],
|
|
4
|
+
"sourcesContent": ["export * from './client';", "import axios, { AxiosInstance } from 'axios';\n\nexport class InfrahubClient {\n private axiosInstance: AxiosInstance;\n\n constructor(baseURL: string, token?: string) {\n this.axiosInstance = axios.create({\n baseURL,\n headers: {\n 'Content-Type': 'application/json',\n }\n });\n if (token) {\n this.setAuthToken(token);\n }\n\n }\n\n public setAuthToken(token: string) {\n this.axiosInstance.defaults.headers.common[\"X-INFRAHUB-KEY\"] = token;\n }\n\n // get info from /api/info endpoint\n public async getInfo() {\n try {\n const response = await this.axiosInstance.get('/api/info');\n return response.data;\n } catch (error) {\n console.error('Error fetching info:', error);\n throw error;\n }\n }\n}"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAqC;AAE9B,IAAM,iBAAN,MAAqB;AAAA,EAGxB,YAAY,SAAiB,OAAgB;AACzC,SAAK,gBAAgB,aAAAA,QAAM,OAAO;AAAA,MAC9B;AAAA,MACA,SAAS;AAAA,QACL,gBAAgB;AAAA,MACpB;AAAA,IACJ,CAAC;AACD,QAAI,OAAO;AACP,WAAK,aAAa,KAAK;AAAA,IAC3B;AAAA,EAEJ;AAAA,EAEO,aAAa,OAAe;AAC/B,SAAK,cAAc,SAAS,QAAQ,OAAO,gBAAgB,IAAI;AAAA,EACnE;AAAA;AAAA,EAGA,MAAa,UAAU;AACnB,QAAI;AACA,YAAM,WAAW,MAAM,KAAK,cAAc,IAAI,WAAW;AACzD,aAAO,SAAS;AAAA,IACpB,SAAS,OAAO;AACZ,cAAQ,MAAM,wBAAwB,KAAK;AAC3C,YAAM;AAAA,IACV;AAAA,EACJ;AACJ;",
|
|
6
|
+
"names": ["axios"]
|
|
7
|
+
}
|
package/dist/client.d.ts
ADDED
package/dist/client.js
ADDED
|
@@ -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.InfrahubClient = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
class InfrahubClient {
|
|
9
|
+
constructor(baseURL, token) {
|
|
10
|
+
this.axiosInstance = axios_1.default.create({
|
|
11
|
+
baseURL,
|
|
12
|
+
headers: {
|
|
13
|
+
'Content-Type': 'application/json',
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
if (token) {
|
|
17
|
+
this.setAuthToken(token);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
setAuthToken(token) {
|
|
21
|
+
this.axiosInstance.defaults.headers.common["X-INFRAHUB-KEY"] = token;
|
|
22
|
+
}
|
|
23
|
+
// get info from /api/info endpoint
|
|
24
|
+
async getInfo() {
|
|
25
|
+
try {
|
|
26
|
+
const response = await this.axiosInstance.get('/api/info');
|
|
27
|
+
return response.data;
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
console.error('Error fetching info:', error);
|
|
31
|
+
throw error;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.InfrahubClient = InfrahubClient;
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// src/client.ts
|
|
2
|
+
import axios from "axios";
|
|
3
|
+
var InfrahubClient = class {
|
|
4
|
+
constructor(baseURL, token) {
|
|
5
|
+
this.axiosInstance = axios.create({
|
|
6
|
+
baseURL,
|
|
7
|
+
headers: {
|
|
8
|
+
"Content-Type": "application/json"
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
if (token) {
|
|
12
|
+
this.setAuthToken(token);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
setAuthToken(token) {
|
|
16
|
+
this.axiosInstance.defaults.headers.common["X-INFRAHUB-KEY"] = token;
|
|
17
|
+
}
|
|
18
|
+
// get info from /api/info endpoint
|
|
19
|
+
async getInfo() {
|
|
20
|
+
try {
|
|
21
|
+
const response = await this.axiosInstance.get("/api/info");
|
|
22
|
+
return response.data;
|
|
23
|
+
} catch (error) {
|
|
24
|
+
console.error("Error fetching info:", error);
|
|
25
|
+
throw error;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
export {
|
|
30
|
+
InfrahubClient
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/client.ts"],
|
|
4
|
+
"sourcesContent": ["import axios, { AxiosInstance } from 'axios';\n\nexport class InfrahubClient {\n private axiosInstance: AxiosInstance;\n\n constructor(baseURL: string, token?: string) {\n this.axiosInstance = axios.create({\n baseURL,\n headers: {\n 'Content-Type': 'application/json',\n }\n });\n if (token) {\n this.setAuthToken(token);\n }\n\n }\n\n public setAuthToken(token: string) {\n this.axiosInstance.defaults.headers.common[\"X-INFRAHUB-KEY\"] = token;\n }\n\n // get info from /api/info endpoint\n public async getInfo() {\n try {\n const response = await this.axiosInstance.get('/api/info');\n return response.data;\n } catch (error) {\n console.error('Error fetching info:', error);\n throw error;\n }\n }\n}"],
|
|
5
|
+
"mappings": ";AAAA,OAAO,WAA8B;AAE9B,IAAM,iBAAN,MAAqB;AAAA,EAGxB,YAAY,SAAiB,OAAgB;AACzC,SAAK,gBAAgB,MAAM,OAAO;AAAA,MAC9B;AAAA,MACA,SAAS;AAAA,QACL,gBAAgB;AAAA,MACpB;AAAA,IACJ,CAAC;AACD,QAAI,OAAO;AACP,WAAK,aAAa,KAAK;AAAA,IAC3B;AAAA,EAEJ;AAAA,EAEO,aAAa,OAAe;AAC/B,SAAK,cAAc,SAAS,QAAQ,OAAO,gBAAgB,IAAI;AAAA,EACnE;AAAA;AAAA,EAGA,MAAa,UAAU;AACnB,QAAI;AACA,YAAM,WAAW,MAAM,KAAK,cAAc,IAAI,WAAW;AACzD,aAAO,SAAS;AAAA,IACpB,SAAS,OAAO;AACZ,cAAQ,MAAM,wBAAwB,KAAK;AAC3C,YAAM;AAAA,IACV;AAAA,EACJ;AACJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { TypedDocumentNode } from '@graphql-typed-document-node/core';
|
|
2
|
+
export interface BranchCreateInput {
|
|
3
|
+
name: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
sync_with_git?: boolean;
|
|
6
|
+
wait_until_completion?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface BranchResponse {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
description: string;
|
|
12
|
+
origin_branch: string;
|
|
13
|
+
branched_from: string;
|
|
14
|
+
is_default: boolean;
|
|
15
|
+
sync_with_git: boolean;
|
|
16
|
+
has_schema_changes: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare const BranchAllQuery: TypedDocumentNode<{
|
|
19
|
+
Branch: BranchResponse[];
|
|
20
|
+
}, Record<any, never>>;
|
|
21
|
+
export declare const BranchGetQuery: TypedDocumentNode<{
|
|
22
|
+
Branch: BranchResponse[];
|
|
23
|
+
}, Record<any, any>>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BranchGetQuery = exports.BranchAllQuery = void 0;
|
|
4
|
+
const graphql_request_1 = require("graphql-request");
|
|
5
|
+
const graphql_1 = require("graphql");
|
|
6
|
+
const BranchAllQueryDocument = (0, graphql_1.parse)((0, graphql_request_1.gql) `
|
|
7
|
+
query BranchAllQuery {
|
|
8
|
+
Branch {
|
|
9
|
+
id
|
|
10
|
+
name
|
|
11
|
+
description
|
|
12
|
+
origin_branch
|
|
13
|
+
branched_from
|
|
14
|
+
is_default
|
|
15
|
+
sync_with_git
|
|
16
|
+
has_schema_changes
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
`);
|
|
20
|
+
const BranchGetQueryDocument = (0, graphql_1.parse)((0, graphql_request_1.gql) `
|
|
21
|
+
query BranchGetQuery($name: String!) {
|
|
22
|
+
Branch(name: $name) {
|
|
23
|
+
id
|
|
24
|
+
name
|
|
25
|
+
description
|
|
26
|
+
origin_branch
|
|
27
|
+
branched_from
|
|
28
|
+
is_default
|
|
29
|
+
sync_with_git
|
|
30
|
+
has_schema_changes
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
`);
|
|
34
|
+
exports.BranchAllQuery = BranchAllQueryDocument;
|
|
35
|
+
exports.BranchGetQuery = BranchGetQueryDocument;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { TypedDocumentNode } from '@graphql-typed-document-node/core';
|
|
2
|
+
export interface InfrahubInfoResponse {
|
|
3
|
+
InfrahubInfo: {
|
|
4
|
+
version: string;
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
export declare const InfrahubInfoQuery: TypedDocumentNode<InfrahubInfoResponse, Record<any, never>>;
|
|
8
|
+
export interface InfrahubUserResponse {
|
|
9
|
+
AccountProfile: {
|
|
10
|
+
id: string;
|
|
11
|
+
display_label: string;
|
|
12
|
+
account_type: {
|
|
13
|
+
value: string;
|
|
14
|
+
__typename: string;
|
|
15
|
+
updated_at: string;
|
|
16
|
+
};
|
|
17
|
+
status: {
|
|
18
|
+
label: string;
|
|
19
|
+
value: string;
|
|
20
|
+
updated_at: string;
|
|
21
|
+
__typename: string;
|
|
22
|
+
};
|
|
23
|
+
description: {
|
|
24
|
+
value: string;
|
|
25
|
+
updated_at: string;
|
|
26
|
+
__typename: string;
|
|
27
|
+
};
|
|
28
|
+
label: {
|
|
29
|
+
value: string;
|
|
30
|
+
updated_at: string;
|
|
31
|
+
__typename: string;
|
|
32
|
+
};
|
|
33
|
+
member_of_groups: {
|
|
34
|
+
count: number;
|
|
35
|
+
edges: Array<{
|
|
36
|
+
node: {
|
|
37
|
+
display_label: string;
|
|
38
|
+
group_type: {
|
|
39
|
+
value: string;
|
|
40
|
+
};
|
|
41
|
+
id?: string;
|
|
42
|
+
roles?: {
|
|
43
|
+
count: number;
|
|
44
|
+
edges: Array<{
|
|
45
|
+
node: {
|
|
46
|
+
permissions?: {
|
|
47
|
+
count: number;
|
|
48
|
+
edges: Array<{
|
|
49
|
+
node: {
|
|
50
|
+
display_label: string;
|
|
51
|
+
identifier?: {
|
|
52
|
+
value: string;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
}>;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
}>;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
}>;
|
|
62
|
+
__typename?: string;
|
|
63
|
+
};
|
|
64
|
+
name: {
|
|
65
|
+
value: string;
|
|
66
|
+
updated_at: string;
|
|
67
|
+
__typename?: string;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
export declare const InfrahubUserQuery: TypedDocumentNode<InfrahubUserResponse, Record<any, never>>;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InfrahubUserQuery = exports.InfrahubInfoQuery = void 0;
|
|
4
|
+
const graphql_1 = require("graphql");
|
|
5
|
+
const graphql_request_1 = require("graphql-request");
|
|
6
|
+
const InfrahubInfoDocument = (0, graphql_1.parse)((0, graphql_request_1.gql) `
|
|
7
|
+
query InfrahubInfo {
|
|
8
|
+
InfrahubInfo {
|
|
9
|
+
version
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
`);
|
|
13
|
+
exports.InfrahubInfoQuery = InfrahubInfoDocument;
|
|
14
|
+
const InfrahubUserDocument = (0, graphql_1.parse)((0, graphql_request_1.gql) `
|
|
15
|
+
query GET_PROFILE_DETAILS {
|
|
16
|
+
AccountProfile {
|
|
17
|
+
id
|
|
18
|
+
display_label
|
|
19
|
+
account_type {
|
|
20
|
+
value
|
|
21
|
+
__typename
|
|
22
|
+
updated_at
|
|
23
|
+
}
|
|
24
|
+
status {
|
|
25
|
+
label
|
|
26
|
+
value
|
|
27
|
+
updated_at
|
|
28
|
+
__typename
|
|
29
|
+
}
|
|
30
|
+
description {
|
|
31
|
+
value
|
|
32
|
+
updated_at
|
|
33
|
+
__typename
|
|
34
|
+
}
|
|
35
|
+
label {
|
|
36
|
+
value
|
|
37
|
+
updated_at
|
|
38
|
+
__typename
|
|
39
|
+
}
|
|
40
|
+
member_of_groups {
|
|
41
|
+
count
|
|
42
|
+
edges {
|
|
43
|
+
node {
|
|
44
|
+
display_label
|
|
45
|
+
group_type {
|
|
46
|
+
value
|
|
47
|
+
}
|
|
48
|
+
... on CoreAccountGroup {
|
|
49
|
+
id
|
|
50
|
+
roles {
|
|
51
|
+
count
|
|
52
|
+
edges {
|
|
53
|
+
node {
|
|
54
|
+
permissions {
|
|
55
|
+
count
|
|
56
|
+
edges {
|
|
57
|
+
node {
|
|
58
|
+
display_label
|
|
59
|
+
identifier {
|
|
60
|
+
value
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
display_label
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
__typename
|
|
74
|
+
name {
|
|
75
|
+
value
|
|
76
|
+
updated_at
|
|
77
|
+
__typename
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
`);
|
|
82
|
+
exports.InfrahubUserQuery = InfrahubUserDocument;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export type VariableType = string | number | boolean | null | undefined | VariableType[] | Record<string, any>;
|
|
2
|
+
export declare function convertToGraphqlAsString(value: VariableType, convertEnum?: boolean): string;
|
|
3
|
+
export declare function renderVariablesToString(data: Record<string, any>): string;
|
|
4
|
+
export declare function renderQueryBlock(data: Record<string, any>, offset?: number, indentation?: number, convertEnum?: boolean): string[];
|
|
5
|
+
export declare function renderInputBlock(data: Record<string, any>, offset?: number, indentation?: number, convertEnum?: boolean): string[];
|
|
6
|
+
export declare class BaseGraphQLQuery {
|
|
7
|
+
queryType: string;
|
|
8
|
+
indentation: number;
|
|
9
|
+
query: Record<string, any>;
|
|
10
|
+
variables?: Record<string, any>;
|
|
11
|
+
name: string;
|
|
12
|
+
constructor(query: Record<string, any>, variables?: Record<string, any>, name?: string);
|
|
13
|
+
renderFirstLine(): string;
|
|
14
|
+
}
|
|
15
|
+
export declare class Query extends BaseGraphQLQuery {
|
|
16
|
+
queryType: string;
|
|
17
|
+
render(convertEnum?: boolean): string;
|
|
18
|
+
}
|
|
19
|
+
export declare class Mutation extends BaseGraphQLQuery {
|
|
20
|
+
queryType: string;
|
|
21
|
+
inputData: Record<string, any>;
|
|
22
|
+
mutation: string;
|
|
23
|
+
constructor({ mutation, inputData, query, variables, name }: {
|
|
24
|
+
mutation: string;
|
|
25
|
+
inputData: Record<string, any>;
|
|
26
|
+
query: Record<string, any>;
|
|
27
|
+
variables?: Record<string, any>;
|
|
28
|
+
name?: string;
|
|
29
|
+
});
|
|
30
|
+
render(convertEnum?: boolean): string;
|
|
31
|
+
}
|