@longvansoftware/service-js-client 2.1.1 → 2.1.3
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/auth/mutations.d.ts +1 -1
- package/dist/src/graphql/auth/mutations.js +4 -4
- package/dist/src/graphql/remote_access_service/mutations.d.ts +1 -0
- package/dist/src/graphql/remote_access_service/mutations.js +14 -1
- package/dist/src/lib/auth/index.js +1 -1
- package/dist/src/lib/remote_access_service/index.d.ts +2 -0
- package/dist/src/lib/remote_access_service/index.js +18 -0
- package/dist/src/types/remote_access_service.d.ts +12 -0
- package/dist/src/types/remote_access_service.js +2 -0
- package/package.json +1 -1
- package/dist/src/lib/service.d.ts +0 -14
- package/dist/src/lib/service.js +0 -101
- package/dist/src/utils/build-field-string.d.ts +0 -1
- package/dist/src/utils/build-field-string.js +0 -16
|
@@ -16,4 +16,4 @@ export declare const SEND_OTP: DocumentNode;
|
|
|
16
16
|
export declare const VALIDATE_OTP: DocumentNode;
|
|
17
17
|
export declare const CREATE_USER_LOGIN: DocumentNode;
|
|
18
18
|
export declare const CREATE_USER_DETAIL_WITHOUT_USER_LOGIN: DocumentNode;
|
|
19
|
-
export declare const
|
|
19
|
+
export declare const CREATE_PARTY_DETAIL: (fields?: string[]) => DocumentNode;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.CREATE_PARTY_DETAIL = exports.CREATE_USER_DETAIL_WITHOUT_USER_LOGIN = exports.CREATE_USER_LOGIN = exports.VALIDATE_OTP = exports.SEND_OTP = exports.LINKING_USER_LOGIN_AND_USER_DETAIL = exports.CREATE_USER_DETAIL = exports.UPDATE_PROFILE = exports.CHECK_RESET_KEY = exports.CREATE_RESET_KEY = exports.LOGIN_v2 = exports.UPDATE_PASSWORD_MUTATION = exports.UPDATE_INFO_MUTATION = exports.RESET_PASSWORD_MUTATION = exports.VERIFY_CODE_MUTATION = exports.SEND_SMS_VERIFY_CODE_MUTATION = exports.REGISTER_MUTATION = exports.LOGIN_MUTATION = void 0;
|
|
4
4
|
const graphql_tag_1 = require("graphql-tag");
|
|
5
5
|
exports.LOGIN_MUTATION = (0, graphql_tag_1.gql) `
|
|
6
6
|
mutation Login($loginRequest: LoginRequest!) {
|
|
@@ -238,15 +238,15 @@ exports.CREATE_USER_DETAIL_WITHOUT_USER_LOGIN = (0, graphql_tag_1.gql) `
|
|
|
238
238
|
}
|
|
239
239
|
}
|
|
240
240
|
`;
|
|
241
|
-
const
|
|
241
|
+
const CREATE_PARTY_DETAIL = (fields = []) => {
|
|
242
242
|
const fieldStr = fields.join("\n ");
|
|
243
243
|
const hasFields = fields.length > 0;
|
|
244
244
|
return (0, graphql_tag_1.gql) `
|
|
245
|
-
|
|
245
|
+
mutation CreatePartyDetail($name: String!, $phone: String!, $orgId: String!, $createdBy: String!, $source: String) {
|
|
246
246
|
createPartyDetail(name: $name ,phone: $phone, orgId: $orgId, createdBy: $createdBy, source: $source) {
|
|
247
247
|
${hasFields ? `${fieldStr}` : ""}
|
|
248
248
|
}
|
|
249
249
|
}
|
|
250
250
|
`;
|
|
251
251
|
};
|
|
252
|
-
exports.
|
|
252
|
+
exports.CREATE_PARTY_DETAIL = CREATE_PARTY_DETAIL;
|
|
@@ -3,4 +3,5 @@ export declare const UPDATE_REMOTE_ACCESS_NAME: import("graphql").DocumentNode;
|
|
|
3
3
|
export declare const UPDATE_REMOTE_ACCESS_DESCRIPTION: import("graphql").DocumentNode;
|
|
4
4
|
export declare const UPDATE_REMOTE_ACCESS_TYPE: import("graphql").DocumentNode;
|
|
5
5
|
export declare const UPDATE_REMOTE_ACCESS_INFO: import("graphql").DocumentNode;
|
|
6
|
+
export declare const UPDATE_REMOTE_ACCESS: import("graphql").DocumentNode;
|
|
6
7
|
export declare const DELETE_REMOTE_ACCESS: import("graphql").DocumentNode;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DELETE_REMOTE_ACCESS = exports.UPDATE_REMOTE_ACCESS_INFO = exports.UPDATE_REMOTE_ACCESS_TYPE = exports.UPDATE_REMOTE_ACCESS_DESCRIPTION = exports.UPDATE_REMOTE_ACCESS_NAME = exports.CREATE_REMOTE_ACCESS = void 0;
|
|
3
|
+
exports.DELETE_REMOTE_ACCESS = exports.UPDATE_REMOTE_ACCESS = exports.UPDATE_REMOTE_ACCESS_INFO = exports.UPDATE_REMOTE_ACCESS_TYPE = exports.UPDATE_REMOTE_ACCESS_DESCRIPTION = exports.UPDATE_REMOTE_ACCESS_NAME = exports.CREATE_REMOTE_ACCESS = void 0;
|
|
4
4
|
const graphql_tag_1 = require("graphql-tag");
|
|
5
5
|
exports.CREATE_REMOTE_ACCESS = (0, graphql_tag_1.gql) `
|
|
6
6
|
mutation CreateRemoteAccess(
|
|
@@ -69,6 +69,19 @@ exports.UPDATE_REMOTE_ACCESS_INFO = (0, graphql_tag_1.gql) `
|
|
|
69
69
|
)
|
|
70
70
|
}
|
|
71
71
|
`;
|
|
72
|
+
exports.UPDATE_REMOTE_ACCESS = (0, graphql_tag_1.gql) `
|
|
73
|
+
mutation UpdateRemoteAccess(
|
|
74
|
+
$remoteAccessId: String!
|
|
75
|
+
$updateRemoteAccessDTO: UpdateRemoteAccessDTO!
|
|
76
|
+
$updatedBy: String!
|
|
77
|
+
) {
|
|
78
|
+
updateRemoteAccess(
|
|
79
|
+
remoteAccessId: $remoteAccessId
|
|
80
|
+
updateRemoteAccessDTO: $updateRemoteAccessDTO
|
|
81
|
+
updatedBy: $updatedBy
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
`;
|
|
72
85
|
exports.DELETE_REMOTE_ACCESS = (0, graphql_tag_1.gql) `
|
|
73
86
|
mutation DeleteRemoteAccess($remoteAccessId: String!, $updatedBy: String!) {
|
|
74
87
|
deleteRemoteAccess(remoteAccessId: $remoteAccessId, updatedBy: $updatedBy)
|
|
@@ -410,7 +410,7 @@ class AuthService extends serviceSDK_1.Service {
|
|
|
410
410
|
}
|
|
411
411
|
createPartyDetail(name, phone, createdBy, source, fields) {
|
|
412
412
|
return __awaiter(this, void 0, void 0, function* () {
|
|
413
|
-
const mutation = (0,
|
|
413
|
+
const mutation = (0, mutations_1.CREATE_PARTY_DETAIL)(fields);
|
|
414
414
|
const variables = {
|
|
415
415
|
name,
|
|
416
416
|
phone,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { UpdateRemoteAccessDTO } from "../../types/remote_access_service";
|
|
1
2
|
import { Service } from "../serviceSDK";
|
|
2
3
|
export declare class RemoteAccessService extends Service {
|
|
3
4
|
constructor(endpoint: string, orgId: string, storeId: string);
|
|
@@ -10,5 +11,6 @@ export declare class RemoteAccessService extends Service {
|
|
|
10
11
|
updateRemoteAccessDescription(remoteAccessId: string, description: string, updatedBy: string): Promise<any>;
|
|
11
12
|
updateRemoteAccessType(remoteAccessId: string, type: string, updatedBy: string): Promise<any>;
|
|
12
13
|
updateRemoteAccessInfo(remoteAccessId: string, remoteAccessInfoInput: any, updatedBy: string): Promise<any>;
|
|
14
|
+
updateRemoteAccess(remoteAccessId: string, updateRemoteAccessDTO: UpdateRemoteAccessDTO, updatedBy: string): Promise<any>;
|
|
13
15
|
deleteRemoteAccess(remoteAccessId: string, updatedBy: string): Promise<any>;
|
|
14
16
|
}
|
|
@@ -142,6 +142,24 @@ class RemoteAccessService extends serviceSDK_1.Service {
|
|
|
142
142
|
}
|
|
143
143
|
});
|
|
144
144
|
}
|
|
145
|
+
updateRemoteAccess(remoteAccessId, updateRemoteAccessDTO, updatedBy) {
|
|
146
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
147
|
+
const mutation = mutations_1.UPDATE_REMOTE_ACCESS;
|
|
148
|
+
const variables = {
|
|
149
|
+
remoteAccessId,
|
|
150
|
+
updateRemoteAccessDTO,
|
|
151
|
+
updatedBy,
|
|
152
|
+
};
|
|
153
|
+
try {
|
|
154
|
+
const response = yield this.graphqlMutation(mutation, variables);
|
|
155
|
+
return response.updateRemoteAccess;
|
|
156
|
+
}
|
|
157
|
+
catch (error) {
|
|
158
|
+
console.log(`Error in updateRemoteAccess : ${error}`);
|
|
159
|
+
throw error;
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
}
|
|
145
163
|
deleteRemoteAccess(remoteAccessId, updatedBy) {
|
|
146
164
|
return __awaiter(this, void 0, void 0, function* () {
|
|
147
165
|
const mutation = mutations_1.DELETE_REMOTE_ACCESS;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface UpdateRemoteAccessDTO {
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
type: 'SSH' | 'RDP' | 'VNC' | 'KVM' | 'IPMI' | 'URI';
|
|
5
|
+
remoteAccessInfoInput: {
|
|
6
|
+
host: string;
|
|
7
|
+
url: string;
|
|
8
|
+
port: string;
|
|
9
|
+
username: string;
|
|
10
|
+
password: string;
|
|
11
|
+
};
|
|
12
|
+
}
|
package/package.json
CHANGED
|
@@ -1,14 +0,0 @@
|
|
|
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
|
-
}
|
package/dist/src/lib/service.js
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
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;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function buildFieldString(fields: (string | Record<string, any>)[], indent?: number): string;
|
|
@@ -1,16 +0,0 @@
|
|
|
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;
|