@longvansoftware/storefront-js-client 1.4.4 → 1.4.5

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.
@@ -8,6 +8,7 @@ export declare const environmentEndpoints: {
8
8
  payment: string;
9
9
  service: string;
10
10
  warehouse: string;
11
+ computing: string;
11
12
  };
12
13
  live: {
13
14
  product: string;
@@ -18,5 +19,6 @@ export declare const environmentEndpoints: {
18
19
  payment: string;
19
20
  service: string;
20
21
  warehouse: string;
22
+ computing: string;
21
23
  };
22
24
  };
@@ -11,6 +11,7 @@ exports.environmentEndpoints = {
11
11
  payment: "https://portal.dev.longvan.vn/invoice-gateway/graphql",
12
12
  service: "https://portal.dev.longvan.vn/service-api/graphql",
13
13
  warehouse: "https://facility-api-v2.dev.longvan.vn/facility-api/public-facility/1.0.0",
14
+ computing: "https://api-gateway.dev.longvan.vn/computing-service/graphql",
14
15
  },
15
16
  live: {
16
17
  product: "https://product-service.dev.longvan.vn/product-service/graphql",
@@ -21,5 +22,6 @@ exports.environmentEndpoints = {
21
22
  payment: "https://portal.dev.longvan.vn/invoice-gateway/graphql",
22
23
  service: "https://portal.dev.longvan.vn/service-api/graphql",
23
24
  warehouse: "https://facility-api-v2.dev.longvan.vn/facility-api/public-facility/1.0.0",
25
+ computing: "https://api-gateway.longvan.vn/computing-service/graphql",
24
26
  },
25
27
  };
@@ -0,0 +1,2 @@
1
+ export declare const COMPUTING_DETAIL: import("graphql").DocumentNode;
2
+ export declare const PORTNATS: import("graphql").DocumentNode;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PORTNATS = exports.COMPUTING_DETAIL = void 0;
4
+ const graphql_tag_1 = require("graphql-tag");
5
+ exports.COMPUTING_DETAIL = (0, graphql_tag_1.gql) `
6
+ query ComputingDetail($computingId: String!){
7
+ computingDetail(computingId: $computingId) {
8
+ id
9
+ name
10
+ username
11
+ password
12
+ state
13
+ os
14
+ ips
15
+ province
16
+ console
17
+ existPortNat
18
+ }
19
+ }
20
+ `;
21
+ exports.PORTNATS = (0, graphql_tag_1.gql) `
22
+ query PortNats($computingId: String!){
23
+ portNats(computingId: $computingId) {
24
+ id
25
+ action
26
+ protocol
27
+ originalAddress
28
+ originalPort
29
+ translatedAddress
30
+ translatedPort
31
+ description
32
+ status
33
+ }
34
+ }
35
+ `;
@@ -6,6 +6,7 @@ import { UserService } from "../lib/user/index";
6
6
  import { PaymentService } from "../lib/payment/index";
7
7
  import { CrmService } from "../lib/crm/index";
8
8
  import { WarehouseService } from "../lib/warehouse/index";
9
+ import { ComputingService } from "../lib/computing/index";
9
10
  export interface Endpoints {
10
11
  product: string;
11
12
  crm: string;
@@ -15,6 +16,7 @@ export interface Endpoints {
15
16
  payment: string;
16
17
  service: string;
17
18
  warehouse: string;
19
+ computing: string;
18
20
  }
19
21
  export declare class SDK {
20
22
  orgId: string;
@@ -28,6 +30,7 @@ export declare class SDK {
28
30
  crm: CrmService;
29
31
  service: ServiceManagementService;
30
32
  warehouse: WarehouseService;
33
+ computing: ComputingService;
31
34
  token: string | null;
32
35
  constructor(orgId: string, storeId: string, storefrontAccessToken: string);
33
36
  setToken(token: string): void;
@@ -12,6 +12,7 @@ const helpers_1 = require("../utils/helpers");
12
12
  const index_6 = require("../lib/payment/index");
13
13
  const index_7 = require("../lib/crm/index");
14
14
  const index_8 = require("../lib/warehouse/index");
15
+ const index_9 = require("../lib/computing/index");
15
16
  class SDK {
16
17
  constructor(orgId, storeId, storefrontAccessToken) {
17
18
  this.orgId = orgId;
@@ -20,6 +21,7 @@ class SDK {
20
21
  this.token = null;
21
22
  (0, helpers_1.validateStorefrontAccessToken)(storefrontAccessToken);
22
23
  const endpoints = config_1.environmentEndpoints.dev;
24
+ console.log("🚀 ~ SDK ~ endpoints:", endpoints.computing);
23
25
  this.product = new index_1.ProductService(endpoints.product, orgId, storeId);
24
26
  this.auth = new index_2.AuthService(endpoints.auth, orgId, storeId);
25
27
  this.order = new index_3.OrderService(endpoints.order, orgId, storeId);
@@ -28,6 +30,7 @@ class SDK {
28
30
  this.crm = new index_7.CrmService(endpoints.crm, orgId, storeId);
29
31
  this.service = new index_4.ServiceManagementService(endpoints.service, orgId, storeId);
30
32
  this.warehouse = new index_8.WarehouseService(endpoints.warehouse, orgId, storeId);
33
+ this.computing = new index_9.ComputingService(endpoints.computing, orgId, storeId);
31
34
  // Initialize other services here
32
35
  }
33
36
  setToken(token) {
@@ -41,6 +44,7 @@ class SDK {
41
44
  this.crm.setToken(token);
42
45
  this.service.setToken(token);
43
46
  this.warehouse.setToken(token);
47
+ this.computing.setToken(token);
44
48
  // Set token for other services here
45
49
  }
46
50
  // các module export từ serviceSDK.ts set storeId vào serviceSDK.ts
@@ -0,0 +1,13 @@
1
+ import { Service } from "../serviceSDK";
2
+ export declare class ComputingService extends Service {
3
+ /**
4
+ * Constructs a new OrderService instance.
5
+ * @param endpoint - The endpoint URL for the service.
6
+ * @param orgId - The organization ID.
7
+ * @param storeId - The store ID.
8
+ */
9
+ constructor(endpoint: string, orgId: string, storeId: string);
10
+ setToken(token: string): void;
11
+ computingDetail(computingId: string): Promise<any>;
12
+ portNats(computingId: string): Promise<any>;
13
+ }
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ComputingService = void 0;
13
+ const queries_1 = require("../../graphql/computing/queries");
14
+ const serviceSDK_1 = require("../serviceSDK");
15
+ class ComputingService extends serviceSDK_1.Service {
16
+ /**
17
+ * Constructs a new OrderService instance.
18
+ * @param endpoint - The endpoint URL for the service.
19
+ * @param orgId - The organization ID.
20
+ * @param storeId - The store ID.
21
+ */
22
+ constructor(endpoint, orgId, storeId) {
23
+ super(endpoint, orgId, storeId);
24
+ }
25
+ setToken(token) {
26
+ this.token = token;
27
+ }
28
+ computingDetail(computingId) {
29
+ return __awaiter(this, void 0, void 0, function* () {
30
+ const query = queries_1.COMPUTING_DETAIL;
31
+ const variables = {
32
+ computingId,
33
+ };
34
+ try {
35
+ const response = yield this.graphqlQuery(query, variables);
36
+ return response.computingDetail;
37
+ }
38
+ catch (error) {
39
+ console.log(`Error in computingDetail: ${error}`);
40
+ throw error;
41
+ }
42
+ });
43
+ }
44
+ portNats(computingId) {
45
+ return __awaiter(this, void 0, void 0, function* () {
46
+ const query = queries_1.PORTNATS;
47
+ const variables = {
48
+ computingId,
49
+ };
50
+ try {
51
+ const response = yield this.graphqlQuery(query, variables);
52
+ return response.portNats;
53
+ }
54
+ catch (error) {
55
+ console.log(`Error in portNats: ${error}`);
56
+ throw error;
57
+ }
58
+ });
59
+ }
60
+ }
61
+ exports.ComputingService = ComputingService;
@@ -2,6 +2,7 @@ import { AddOpportunityRequest, GetOpportunityRequest } from '../../types/crm';
2
2
  import { Service } from '../serviceSDK';
3
3
  export declare class CrmService extends Service {
4
4
  constructor(endpoint: string, orgId: string, storeId: string);
5
+ setToken(token: string): void;
5
6
  addOpportunity(addOpportunityRequest: AddOpportunityRequest, performerId: string): Promise<any>;
6
7
  getListOpportunity(performerId: string, getOpportunityRequest: GetOpportunityRequest): Promise<any>;
7
8
  getListTodo(workEffortId: string[]): Promise<any>;
@@ -17,6 +17,9 @@ class CrmService extends serviceSDK_1.Service {
17
17
  constructor(endpoint, orgId, storeId) {
18
18
  super(endpoint, orgId, storeId);
19
19
  }
20
+ setToken(token) {
21
+ this.token = token;
22
+ }
20
23
  addOpportunity(addOpportunityRequest, performerId) {
21
24
  return __awaiter(this, void 0, void 0, function* () {
22
25
  const mutation = mutations_1.ADD_OPPORTUNITY_MUTATION;
@@ -447,4 +447,6 @@ export declare class OrderService extends Service {
447
447
  * @throws If an error occurs while updating the customer and shipping address.
448
448
  */
449
449
  deleteNoteWithoutLogin(orderId: string, noteId: string, deletedBy: string): Promise<any>;
450
+ updateOrderDescription(orderId: string, description: string): Promise<any>;
451
+ getOrderDetail(orderId: string): Promise<any>;
450
452
  }
@@ -1179,5 +1179,26 @@ class OrderService extends serviceSDK_1.Service {
1179
1179
  }
1180
1180
  });
1181
1181
  }
1182
+ updateOrderDescription(orderId, description) {
1183
+ return __awaiter(this, void 0, void 0, function* () {
1184
+ const endpoint = `/orders/${this.orgId}/${this.storeId}/${orderId}/description`;
1185
+ const method = "PUT";
1186
+ try {
1187
+ const response = yield this.restApiCallWithToken(endpoint, method, description, {
1188
+ 'Content-Type': 'text/plain'
1189
+ });
1190
+ return response;
1191
+ }
1192
+ catch (error) {
1193
+ console.log(`Error in updateOrderDescription: ${error}`);
1194
+ throw error;
1195
+ }
1196
+ });
1197
+ }
1198
+ getOrderDetail(orderId) {
1199
+ return __awaiter(this, void 0, void 0, function* () {
1200
+ return this.restApiCallWithToken(`/orders/${this.orgId}/${this.storeId}/${orderId}/sale_order`, 'GET');
1201
+ });
1202
+ }
1182
1203
  }
1183
1204
  exports.OrderService = OrderService;
@@ -48,6 +48,13 @@ class Service {
48
48
  ${query}
49
49
  `,
50
50
  variables,
51
+ context: {
52
+ method: "POST",
53
+ headers: {
54
+ "Content-Type": "application/json",
55
+ partnerId: this.orgId,
56
+ },
57
+ },
51
58
  });
52
59
  if (errors) {
53
60
  throw new Error(`GraphQL error! errors: ${errors}`);
@@ -100,7 +107,6 @@ class Service {
100
107
  return __awaiter(this, void 0, void 0, function* () {
101
108
  try {
102
109
  const modifiedHeaders = Object.assign(Object.assign({}, headers), { Partnerid: this.orgId });
103
- console.log("🚀 ~ Service ~ modifiedHeaders:", modifiedHeaders);
104
110
  const response = yield (0, axios_1.default)({
105
111
  url: this.endpoint + path,
106
112
  method,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longvansoftware/storefront-js-client",
3
- "version": "1.4.4",
3
+ "version": "1.4.5",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "files": [