@longvansoftware/service-js-client 1.15.6 → 1.15.7
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/src/graphql/cloud/queries.d.ts +1 -0
- package/dist/src/graphql/cloud/queries.js +26 -1
- package/dist/src/graphql/computing/mutations.d.ts +1 -0
- package/dist/src/graphql/computing/mutations.js +15 -1
- package/dist/src/lib/cloud/index.d.ts +1 -0
- package/dist/src/lib/cloud/index.js +16 -0
- package/dist/src/lib/computing/index.d.ts +1 -0
- package/dist/src/lib/computing/index.js +17 -0
- package/dist/src/lib/service.d.ts +14 -0
- package/dist/src/lib/service.js +101 -0
- package/dist/src/utils/build-field-string.d.ts +1 -0
- package/dist/src/utils/build-field-string.js +16 -0
- package/package.json +1 -1
@@ -16,3 +16,4 @@ export declare const GET_CONTACTS_BY_OWNER_ID: import("graphql").DocumentNode;
|
|
16
16
|
export declare const GET_DOMAIN_SUPPLIER: import("graphql").DocumentNode;
|
17
17
|
export declare const CHECK_DOMAIN_EXIST: import("graphql").DocumentNode;
|
18
18
|
export declare const SEARCH_ACTIONS: import("graphql").DocumentNode;
|
19
|
+
export declare const GET_ELASTIC_CLOUD_RESOURCE: import("graphql").DocumentNode;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.SEARCH_ACTIONS = exports.CHECK_DOMAIN_EXIST = exports.GET_DOMAIN_SUPPLIER = exports.GET_CONTACTS_BY_OWNER_ID = exports.GET_OWNERS_BY_CUSTOMER_ID = exports.GET_DOMAIN_CONTACTS = exports.GET_SERVICE_TYPE_LIST = exports.GET_SERVICES_BY_ORDER_ID = exports.GET_IPS_OF_SERVICE = exports.GET_PRODUCTS_OF_SERVICE = exports.SEARCH_SERVICE = exports.SERVICE_TYPE = exports.GET_USER_MAIL_HOSTING = exports.GET_MAIL_RESOURCE = exports.SERVICE_DETAIL = exports.GET_WHOIS_DOMAIN_INFO = exports.CHECK_DOMAIN_NAME_AVAILAVLE_VNNIC = exports.CHECK_DOMAIN_NAME_AVAILABLE = void 0;
|
3
|
+
exports.GET_ELASTIC_CLOUD_RESOURCE = exports.SEARCH_ACTIONS = exports.CHECK_DOMAIN_EXIST = exports.GET_DOMAIN_SUPPLIER = exports.GET_CONTACTS_BY_OWNER_ID = exports.GET_OWNERS_BY_CUSTOMER_ID = exports.GET_DOMAIN_CONTACTS = exports.GET_SERVICE_TYPE_LIST = exports.GET_SERVICES_BY_ORDER_ID = exports.GET_IPS_OF_SERVICE = exports.GET_PRODUCTS_OF_SERVICE = exports.SEARCH_SERVICE = exports.SERVICE_TYPE = exports.GET_USER_MAIL_HOSTING = exports.GET_MAIL_RESOURCE = exports.SERVICE_DETAIL = exports.GET_WHOIS_DOMAIN_INFO = exports.CHECK_DOMAIN_NAME_AVAILAVLE_VNNIC = exports.CHECK_DOMAIN_NAME_AVAILABLE = void 0;
|
4
4
|
const graphql_tag_1 = require("graphql-tag");
|
5
5
|
exports.CHECK_DOMAIN_NAME_AVAILABLE = (0, graphql_tag_1.gql) `
|
6
6
|
query CheckDomainNameAvailable($domainName: String!) {
|
@@ -337,3 +337,28 @@ exports.SEARCH_ACTIONS = (0, graphql_tag_1.gql) `
|
|
337
337
|
}
|
338
338
|
}
|
339
339
|
`;
|
340
|
+
exports.GET_ELASTIC_CLOUD_RESOURCE = (0, graphql_tag_1.gql) `
|
341
|
+
query GetElasticCloudResource($serviceId: String!) {
|
342
|
+
getElasticCloudResource(serviceId: $serviceId) {
|
343
|
+
ram {
|
344
|
+
size
|
345
|
+
used
|
346
|
+
unit
|
347
|
+
}
|
348
|
+
cpu {
|
349
|
+
size
|
350
|
+
used
|
351
|
+
unit
|
352
|
+
}
|
353
|
+
disk {
|
354
|
+
size
|
355
|
+
used
|
356
|
+
unit
|
357
|
+
}
|
358
|
+
ip {
|
359
|
+
size
|
360
|
+
used
|
361
|
+
}
|
362
|
+
}
|
363
|
+
}
|
364
|
+
`;
|
@@ -22,3 +22,4 @@ export declare const RESTORE_COMPUTING_WAITING_REVOKE: (fields?: string[]) => Do
|
|
22
22
|
export declare const DELETE_COMPUTING: (fields?: string[]) => DocumentNode;
|
23
23
|
export declare const UPDATE_CPU: DocumentNode;
|
24
24
|
export declare const UPDATE_RAM: DocumentNode;
|
25
|
+
export declare const CREATE_COMPUTING_FOR_EC: DocumentNode;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.UPDATE_RAM = exports.UPDATE_CPU = exports.DELETE_COMPUTING = exports.RESTORE_COMPUTING_WAITING_REVOKE = exports.COMPUTING_WAITING_REVOKE = exports.UPDATE_NAME_COMPUTING = exports.CREATE_COMPUTING_FOR_DC = exports.UPDATE_DESCRIPTION_COMPUTING = exports.ADD_PORT_NAT = exports.STOP_USE_COMPUTING = exports.REMOVE_COMPUTING_IN_CLUSTER = exports.ADD_COMPUTING_IN_CLUSTER = exports.CREATE_CLUSTER = exports.DELETE_SNAPSHOT = exports.ROLLBACK_SNAPSHOT = exports.CREATE_SNAP_SHOT = exports.POWER_OFF = exports.POWER_ON = exports.REMOVE_PORT_NAT = exports.UPDATE_PORT_NAT = exports.CREATE_PORT_NAT = exports.UPDATE_DESCRIPTION_PORTNAT = exports.RESTARTVM = void 0;
|
3
|
+
exports.CREATE_COMPUTING_FOR_EC = exports.UPDATE_RAM = exports.UPDATE_CPU = exports.DELETE_COMPUTING = exports.RESTORE_COMPUTING_WAITING_REVOKE = exports.COMPUTING_WAITING_REVOKE = exports.UPDATE_NAME_COMPUTING = exports.CREATE_COMPUTING_FOR_DC = exports.UPDATE_DESCRIPTION_COMPUTING = exports.ADD_PORT_NAT = exports.STOP_USE_COMPUTING = exports.REMOVE_COMPUTING_IN_CLUSTER = exports.ADD_COMPUTING_IN_CLUSTER = exports.CREATE_CLUSTER = exports.DELETE_SNAPSHOT = exports.ROLLBACK_SNAPSHOT = exports.CREATE_SNAP_SHOT = exports.POWER_OFF = exports.POWER_ON = exports.REMOVE_PORT_NAT = exports.UPDATE_PORT_NAT = exports.CREATE_PORT_NAT = exports.UPDATE_DESCRIPTION_PORTNAT = exports.RESTARTVM = void 0;
|
4
4
|
const graphql_tag_1 = require("graphql-tag");
|
5
5
|
exports.RESTARTVM = (0, graphql_tag_1.gql) `
|
6
6
|
mutation Restart($computingId: String!, $actor: String!) {
|
@@ -330,3 +330,17 @@ exports.UPDATE_RAM = (0, graphql_tag_1.gql) `
|
|
330
330
|
)
|
331
331
|
}
|
332
332
|
`;
|
333
|
+
exports.CREATE_COMPUTING_FOR_EC = (0, graphql_tag_1.gql) `
|
334
|
+
mutation CreateComputingForEC(
|
335
|
+
$createComputingInputForEC: CreateComputingInputForEC!
|
336
|
+
$createBy: String!
|
337
|
+
) {
|
338
|
+
createComputingForEC(
|
339
|
+
createComputingInputForEC: $createComputingInputForEC
|
340
|
+
createBy: $createBy
|
341
|
+
) {
|
342
|
+
computingId
|
343
|
+
message
|
344
|
+
}
|
345
|
+
}
|
346
|
+
`;
|
@@ -44,4 +44,5 @@ export declare class CloudService extends Service {
|
|
44
44
|
createActionChangeIpOfService(action: any, byUser: string): Promise<any>;
|
45
45
|
updateActionStatus(actionId: string, status: string, byUser: string): Promise<any>;
|
46
46
|
updateActionCustomAttribute(actionId: string, attrName: string, attrValue: string, byUser: string): Promise<any>;
|
47
|
+
getElasticCloudResource(serviceId: string): Promise<any>;
|
47
48
|
}
|
@@ -611,5 +611,21 @@ class CloudService extends serviceSDK_1.Service {
|
|
611
611
|
}
|
612
612
|
});
|
613
613
|
}
|
614
|
+
getElasticCloudResource(serviceId) {
|
615
|
+
return __awaiter(this, void 0, void 0, function* () {
|
616
|
+
const query = queries_1.GET_ELASTIC_CLOUD_RESOURCE;
|
617
|
+
const variables = {
|
618
|
+
serviceId,
|
619
|
+
};
|
620
|
+
try {
|
621
|
+
const response = yield this.graphqlQueryV2(query, variables);
|
622
|
+
return response.getElasticCloudResource;
|
623
|
+
}
|
624
|
+
catch (error) {
|
625
|
+
console.log(`Error in getElasticCloudResource: ${error}`);
|
626
|
+
throw error;
|
627
|
+
}
|
628
|
+
});
|
629
|
+
}
|
614
630
|
}
|
615
631
|
exports.CloudService = CloudService;
|
@@ -61,4 +61,5 @@ export declare class ComputingService extends Service {
|
|
61
61
|
updateCPU(computingId: string, socket: number, corePerSocket: number, updateBy: string): Promise<any>;
|
62
62
|
updateRAM(computingId: string, size: number, unit: string, updateBy: string): Promise<any>;
|
63
63
|
getComputingsDynamic(userId: string, fields: string[]): Promise<any>;
|
64
|
+
createComputingForEC(createComputingInputForEC: any, createBy: string): Promise<any>;
|
64
65
|
}
|
@@ -906,5 +906,22 @@ class ComputingService extends serviceSDK_1.Service {
|
|
906
906
|
}
|
907
907
|
});
|
908
908
|
}
|
909
|
+
createComputingForEC(createComputingInputForEC, createBy) {
|
910
|
+
return __awaiter(this, void 0, void 0, function* () {
|
911
|
+
const mutation = mutations_1.CREATE_COMPUTING_FOR_EC;
|
912
|
+
const variables = {
|
913
|
+
createComputingInputForEC,
|
914
|
+
createBy,
|
915
|
+
};
|
916
|
+
try {
|
917
|
+
const response = yield this.graphqlMutationV2(mutation, variables);
|
918
|
+
return response.createComputingForEC;
|
919
|
+
}
|
920
|
+
catch (error) {
|
921
|
+
console.log(`Error fetching get createComputingForEC method: ${error}`);
|
922
|
+
throw error;
|
923
|
+
}
|
924
|
+
});
|
925
|
+
}
|
909
926
|
}
|
910
927
|
exports.ComputingService = ComputingService;
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { ApolloClient, NormalizedCacheObject } from "@apollo/client";
|
2
|
+
import { DocumentNode } from "graphql";
|
3
|
+
export declare class Service {
|
4
|
+
protected token: string | null;
|
5
|
+
protected client: ApolloClient<NormalizedCacheObject>;
|
6
|
+
protected orgId: string;
|
7
|
+
protected storeId: string;
|
8
|
+
protected endpoint: string;
|
9
|
+
constructor(endpoint: string, orgId: string, storeId: string);
|
10
|
+
setToken(token: string): void;
|
11
|
+
protected graphqlQuery(query: DocumentNode, variables: any): Promise<any>;
|
12
|
+
protected graphqlMutation(mutation: DocumentNode, variables: any): Promise<any>;
|
13
|
+
protected restApiCallWithToken(path: string, method: "GET" | "POST" | "PUT" | "DELETE", data?: any, headers?: any): Promise<any>;
|
14
|
+
}
|
@@ -0,0 +1,101 @@
|
|
1
|
+
"use strict";
|
2
|
+
// src/service.ts
|
3
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
4
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
5
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
6
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
7
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
8
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
9
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
10
|
+
});
|
11
|
+
};
|
12
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
13
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
14
|
+
};
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
16
|
+
exports.Service = void 0;
|
17
|
+
const client_1 = require("@apollo/client");
|
18
|
+
const axios_1 = __importDefault(require("axios"));
|
19
|
+
class Service {
|
20
|
+
constructor(endpoint, orgId, storeId) {
|
21
|
+
this.token = null;
|
22
|
+
this.client = new client_1.ApolloClient({
|
23
|
+
uri: endpoint,
|
24
|
+
cache: new client_1.InMemoryCache(),
|
25
|
+
defaultOptions: {
|
26
|
+
query: {
|
27
|
+
fetchPolicy: "network-only",
|
28
|
+
},
|
29
|
+
},
|
30
|
+
});
|
31
|
+
this.orgId = orgId;
|
32
|
+
this.storeId = storeId;
|
33
|
+
this.endpoint = endpoint;
|
34
|
+
}
|
35
|
+
setToken(token) {
|
36
|
+
this.token = token;
|
37
|
+
}
|
38
|
+
// setOrgId(orgId: string) {
|
39
|
+
// this.orgId = orgId;
|
40
|
+
// }
|
41
|
+
graphqlQuery(query, variables) {
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
43
|
+
try {
|
44
|
+
const { data, errors } = yield this.client.query({
|
45
|
+
query: (0, client_1.gql) `
|
46
|
+
${query}
|
47
|
+
`,
|
48
|
+
variables,
|
49
|
+
});
|
50
|
+
if (errors) {
|
51
|
+
throw new Error(`GraphQL error! errors: ${errors}`);
|
52
|
+
}
|
53
|
+
return data;
|
54
|
+
}
|
55
|
+
catch (error) {
|
56
|
+
console.log(`Error in graphqlQuery: ${error}`);
|
57
|
+
throw error;
|
58
|
+
}
|
59
|
+
});
|
60
|
+
}
|
61
|
+
graphqlMutation(mutation, variables) {
|
62
|
+
return __awaiter(this, void 0, void 0, function* () {
|
63
|
+
try {
|
64
|
+
const { data, errors } = yield this.client.mutate({
|
65
|
+
mutation: (0, client_1.gql) `
|
66
|
+
${mutation}
|
67
|
+
`,
|
68
|
+
variables,
|
69
|
+
});
|
70
|
+
if (errors) {
|
71
|
+
throw new Error(`GraphQL error! errors: ${errors}`);
|
72
|
+
}
|
73
|
+
return data;
|
74
|
+
}
|
75
|
+
catch (error) {
|
76
|
+
console.log(`Error in graphqlMutation: ${error}`);
|
77
|
+
throw error;
|
78
|
+
}
|
79
|
+
});
|
80
|
+
}
|
81
|
+
restApiCallWithToken(path, method, data, headers) {
|
82
|
+
return __awaiter(this, void 0, void 0, function* () {
|
83
|
+
try {
|
84
|
+
const modifiedHeaders = Object.assign(Object.assign({}, headers), { "Partner-Id": this.orgId, "X-Ecomos-Access-Token": this.token });
|
85
|
+
console.log("🚀 ~ Service ~ modifiedHeaders:", modifiedHeaders);
|
86
|
+
const response = yield (0, axios_1.default)({
|
87
|
+
url: this.endpoint + path,
|
88
|
+
method,
|
89
|
+
data,
|
90
|
+
headers: modifiedHeaders,
|
91
|
+
});
|
92
|
+
return response.data;
|
93
|
+
}
|
94
|
+
catch (error) {
|
95
|
+
console.log(`Error in restApiCallWithToken: ${error}`);
|
96
|
+
throw error;
|
97
|
+
}
|
98
|
+
});
|
99
|
+
}
|
100
|
+
}
|
101
|
+
exports.Service = Service;
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare function buildFieldString(fields: (string | Record<string, any>)[], indent?: number): string;
|
@@ -0,0 +1,16 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.buildFieldString = void 0;
|
4
|
+
function buildFieldString(fields, indent = 6) {
|
5
|
+
const space = " ".repeat(indent);
|
6
|
+
return fields
|
7
|
+
.map((field) => {
|
8
|
+
if (typeof field === "string")
|
9
|
+
return `${space}${field}`;
|
10
|
+
const [key, value] = Object.entries(field)[0];
|
11
|
+
const nested = buildFieldString(value, indent + 2);
|
12
|
+
return `${space}${key} {\n${nested}\n${space}}`;
|
13
|
+
})
|
14
|
+
.join("\n");
|
15
|
+
}
|
16
|
+
exports.buildFieldString = buildFieldString;
|