@longvansoftware/service-js-client 1.18.8 → 1.18.9

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.
@@ -19,6 +19,7 @@ export declare const environmentEndpoints: {
19
19
  cloud_rest: string;
20
20
  accounting_service: string;
21
21
  quicklab_service: string;
22
+ remote_access_service: string;
22
23
  };
23
24
  live: {
24
25
  product: string;
@@ -40,5 +41,6 @@ export declare const environmentEndpoints: {
40
41
  cloud_rest: string;
41
42
  accounting_service: string;
42
43
  quicklab_service: string;
44
+ remote_access_service: string;
43
45
  };
44
46
  };
@@ -22,6 +22,7 @@ exports.environmentEndpoints = {
22
22
  cloud_rest: "https://api-gateway.dev.longvan.vn/cloud-service-api/v1",
23
23
  accounting_service: "https://api-gateway.dev.longvan.vn/accounting-service/graphql/",
24
24
  quicklab_service: "https://portal.dev.longvan.vn/quicklab-api/graphql",
25
+ remote_access_service: "https://api-gateway.dev.longvan.vn/remote-access-service/graphql"
25
26
  },
26
27
  live: {
27
28
  product: "https://product-service.longvan.vn/product-service/graphql",
@@ -43,5 +44,6 @@ exports.environmentEndpoints = {
43
44
  cloud_rest: "https://api-gateway.longvan.vn/cloud-service-api/v1",
44
45
  accounting_service: "https://api-gateway.longvan.vn/accounting-service/graphql/",
45
46
  quicklab_service: "https://portal.longvan.vn/quicklab-api/graphql",
47
+ remote_access_service: "https://api-gateway.longvan.vn/remote-access-service/graphql"
46
48
  },
47
49
  };
@@ -113,6 +113,8 @@ exports.GET_ORDER_DETAIL = (0, graphql_tag_1.gql) `
113
113
  currencyCode
114
114
  }
115
115
  orderLineItemParentId
116
+ giftConditionProductId
117
+ giftQuantity
116
118
  variant {
117
119
  id
118
120
  price {
@@ -135,18 +137,47 @@ exports.GET_ORDER_DETAIL = (0, graphql_tag_1.gql) `
135
137
  value
136
138
  title
137
139
  }
138
- resourceItems {
139
- name
140
- quantity
141
- unit
142
- productId
143
- }
144
140
  resourceConfigs {
145
- name
146
- quantity
147
- unit
148
- productId
149
- }
141
+ name
142
+ quantity
143
+ unit
144
+ productId
145
+ giftProductId
146
+ gift
147
+ giftQuantity
148
+ campaignId
149
+ campaignActionId
150
+ qualify
151
+ idParent
152
+ addQuantity
153
+ defaultQuantity
154
+ title
155
+ price
156
+ unitPrice
157
+ totalResource
158
+ }
159
+ resourceItems {
160
+ name
161
+ quantity
162
+ unit
163
+ productId
164
+ giftProductId
165
+ gift
166
+ giftQuantity
167
+ campaignId
168
+ campaignActionId
169
+ qualify
170
+ idParent
171
+ addQuantity
172
+ defaultQuantity
173
+ title
174
+ price
175
+ unitPrice
176
+ totalResource
177
+ unitGift
178
+ giftDuration
179
+ giftDurationUnit
180
+ }
150
181
  itemType
151
182
  }
152
183
  serviceId
@@ -181,6 +212,7 @@ exports.GET_QUANTITY_ORDER_LINEITEMS = (0, graphql_tag_1.gql) `
181
212
  }
182
213
  itemType
183
214
  orderLineItemParentId
215
+ giftConditionProductId
184
216
  }
185
217
  }
186
218
  }
@@ -240,6 +272,8 @@ exports.GET_ORDER_LINE_ITEM_BY_SERVICE_ID = (0, graphql_tag_1.gql) `
240
272
  updatedStamp
241
273
  completedAt
242
274
  orderLineItemParentId
275
+ giftConditionProductId
276
+ giftQuantity
243
277
  orderStatus
244
278
  totalVAT {
245
279
  amount
@@ -5,10 +5,16 @@ const graphql_tag_1 = require("graphql-tag");
5
5
  exports.CANCEL_PAYMENT = (0, graphql_tag_1.gql) `
6
6
  mutation CancelPayment(
7
7
  $paymentId: String!
8
+ $safeMode: Boolean!
8
9
  $reason: String!
9
10
  $createBy: String
10
11
  ) {
11
- cancelPayment(paymentId: $paymentId, reason: $reason, createBy: $createBy)
12
+ cancelPayment(
13
+ paymentId: $paymentId
14
+ safeMode: $safeMode
15
+ reason: $reason
16
+ createBy: $createBy
17
+ )
12
18
  }
13
19
  `;
14
20
  exports.CONFIRM_PAID_MANUAL = (0, graphql_tag_1.gql) `
@@ -2,3 +2,4 @@ export declare const PAYMENTS_BY_ORDERS: import("graphql").DocumentNode;
2
2
  export declare const GET_TRANSFER_INFO: import("graphql").DocumentNode;
3
3
  export declare const GET_PAYMENT_METHOD_TYPES: import("graphql").DocumentNode;
4
4
  export declare const PAYMENT_METHODS: import("graphql").DocumentNode;
5
+ export declare const PAYMENT_STATUS: import("graphql").DocumentNode;
@@ -1,12 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PAYMENT_METHODS = exports.GET_PAYMENT_METHOD_TYPES = exports.GET_TRANSFER_INFO = exports.PAYMENTS_BY_ORDERS = void 0;
3
+ exports.PAYMENT_STATUS = exports.PAYMENT_METHODS = exports.GET_PAYMENT_METHOD_TYPES = exports.GET_TRANSFER_INFO = exports.PAYMENTS_BY_ORDERS = void 0;
4
4
  const graphql_tag_1 = require("graphql-tag");
5
5
  exports.PAYMENTS_BY_ORDERS = (0, graphql_tag_1.gql) `
6
6
  query PaymentsByOrders($orderIds: [String!]!) {
7
7
  paymentsByOrders(orderIds: $orderIds) {
8
8
  methodCode
9
9
  methodTypeCode
10
+ gatewayConfigId
10
11
  partnerCode
11
12
  totalAmount
12
13
  fee
@@ -37,6 +38,12 @@ exports.PAYMENTS_BY_ORDERS = (0, graphql_tag_1.gql) `
37
38
  baseMethodCode
38
39
  confirmPaidBy
39
40
  confirmPaidDate
41
+ qrCode
42
+ payUrl
43
+ customerId
44
+ attributes
45
+ paymentNote
46
+ payExpireDate
40
47
  }
41
48
  }
42
49
  `;
@@ -81,3 +88,48 @@ exports.PAYMENT_METHODS = (0, graphql_tag_1.gql) `
81
88
  }
82
89
  }
83
90
  `;
91
+ exports.PAYMENT_STATUS = (0, graphql_tag_1.gql) `
92
+ query PaymentStatus($paymentId: String!) {
93
+ paymentStatus(paymentId: $paymentId) {
94
+ methodCode
95
+ methodTypeCode
96
+ gatewayConfigId
97
+ partnerCode
98
+ totalAmount
99
+ fee
100
+ discountAmount
101
+ payDate
102
+ payType
103
+ transactionDate
104
+ orderId
105
+ paymentId
106
+ invoiceId
107
+ orderInfo
108
+ orderType
109
+ locale
110
+ merchantIp
111
+ extraData
112
+ storeID
113
+ bankCode
114
+ appUser
115
+ phone
116
+ email
117
+ address
118
+ statusCode
119
+ statusDescription
120
+ transactionId
121
+ createBy
122
+ methodDescription
123
+ methodMapping
124
+ baseMethodCode
125
+ confirmPaidBy
126
+ confirmPaidDate
127
+ qrCode
128
+ payUrl
129
+ customerId
130
+ attributes
131
+ paymentNote
132
+ payExpireDate
133
+ }
134
+ }
135
+ `;
@@ -0,0 +1,6 @@
1
+ export declare const CREATE_REMOTE_ACCESS: import("graphql").DocumentNode;
2
+ export declare const UPDATE_REMOTE_ACCESS_NAME: import("graphql").DocumentNode;
3
+ export declare const UPDATE_REMOTE_ACCESS_DESCRIPTION: import("graphql").DocumentNode;
4
+ export declare const UPDATE_REMOTE_ACCESS_TYPE: import("graphql").DocumentNode;
5
+ export declare const UPDATE_REMOTE_ACCESS_INFO: import("graphql").DocumentNode;
6
+ export declare const DELETE_REMOTE_ACCESS: import("graphql").DocumentNode;
@@ -0,0 +1,76 @@
1
+ "use strict";
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;
4
+ const graphql_tag_1 = require("graphql-tag");
5
+ exports.CREATE_REMOTE_ACCESS = (0, graphql_tag_1.gql) `
6
+ mutation CreateRemoteAccess(
7
+ $remoteAccess: CreateRemoteAccessInput!
8
+ $remoteAccessInfo: RemoteAccessInfoInput!
9
+ $createdBy: String!
10
+ ) {
11
+ createRemoteAccess(
12
+ remoteAccess: $remoteAccess
13
+ remoteAccessInfo: $remoteAccessInfo
14
+ createdBy: $createdBy
15
+ ) {
16
+ id
17
+ }
18
+ }
19
+ `;
20
+ exports.UPDATE_REMOTE_ACCESS_NAME = (0, graphql_tag_1.gql) `
21
+ mutation UpdateRemoteAccessName(
22
+ $remoteAccessId: String!
23
+ $name: String!
24
+ $updatedBy: String!
25
+ ) {
26
+ updateRemoteAccessName(
27
+ remoteAccessId: $remoteAccessId
28
+ name: $name
29
+ updatedBy: $updatedBy
30
+ )
31
+ }
32
+ `;
33
+ exports.UPDATE_REMOTE_ACCESS_DESCRIPTION = (0, graphql_tag_1.gql) `
34
+ mutation UpdateRemoteAccessDescription(
35
+ $remoteAccessId: String!
36
+ $description: String!
37
+ $updatedBy: String!
38
+ ) {
39
+ updateRemoteAccessDescription(
40
+ remoteAccessId: $remoteAccessId
41
+ description: $description
42
+ updatedBy: $updatedBy
43
+ )
44
+ }
45
+ `;
46
+ exports.UPDATE_REMOTE_ACCESS_TYPE = (0, graphql_tag_1.gql) `
47
+ mutation UpdateRemoteAccessType(
48
+ $remoteAccessId: String!
49
+ $type: RemoteAccessType!
50
+ $updatedBy: String!
51
+ ) {
52
+ updateRemoteAccessType(
53
+ remoteAccessId: $remoteAccessId
54
+ type: $type
55
+ updatedBy: $updatedBy
56
+ )
57
+ }
58
+ `;
59
+ exports.UPDATE_REMOTE_ACCESS_INFO = (0, graphql_tag_1.gql) `
60
+ mutation UpdateRemoteAccessInfo(
61
+ $remoteAccessId: String!
62
+ $remoteAccessInfoInput: RemoteAccessInfoInput!
63
+ $updatedBy: String!
64
+ ) {
65
+ updateRemoteAccessInfo(
66
+ remoteAccessId: $remoteAccessId
67
+ remoteAccessInfoInput: $remoteAccessInfoInput
68
+ updatedBy: $updatedBy
69
+ )
70
+ }
71
+ `;
72
+ exports.DELETE_REMOTE_ACCESS = (0, graphql_tag_1.gql) `
73
+ mutation DeleteRemoteAccess($remoteAccessId: String!, $updatedBy: String!) {
74
+ deleteRemoteAccess(remoteAccessId: $remoteAccessId, updatedBy: $updatedBy)
75
+ }
76
+ `;
@@ -0,0 +1,2 @@
1
+ export declare const GET_REMOTE_ACCESS_BY_TARGETID_AND_TARGETTYPE: import("graphql").DocumentNode;
2
+ export declare const GET_CONNECTION_INFO_FROM_REMOTE_ACCESS_BY_ID: import("graphql").DocumentNode;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GET_CONNECTION_INFO_FROM_REMOTE_ACCESS_BY_ID = exports.GET_REMOTE_ACCESS_BY_TARGETID_AND_TARGETTYPE = void 0;
4
+ const graphql_tag_1 = require("graphql-tag");
5
+ exports.GET_REMOTE_ACCESS_BY_TARGETID_AND_TARGETTYPE = (0, graphql_tag_1.gql) `
6
+ query GetRemoteAccessByTargetIdAndTargetType(
7
+ $targetId: String!
8
+ $targetType: String!
9
+ ) {
10
+ getRemoteAccessByTargetIdAndTargetType(
11
+ targetId: $targetId
12
+ targetType: $targetType
13
+ ) {
14
+ id
15
+ name
16
+ description
17
+ targetId
18
+ targetType
19
+ type
20
+ status
21
+ }
22
+ }
23
+ `;
24
+ exports.GET_CONNECTION_INFO_FROM_REMOTE_ACCESS_BY_ID = (0, graphql_tag_1.gql) `
25
+ query GetConnectionInfoFromRemoteAccessById($remoteAccessId: String!) {
26
+ getConnectionInfoFromRemoteAccessById(remoteAccessId: $remoteAccessId) {
27
+ url
28
+ host
29
+ port
30
+ username
31
+ password
32
+ }
33
+ }
34
+ `;
@@ -17,6 +17,7 @@ import { CloudRestService } from "./cloud_rest";
17
17
  import { OrderCloudRestService } from "./order_cloud_rest";
18
18
  import { AccountingService } from "./accounting_service";
19
19
  import { QuicklabService } from "./quicklab_service";
20
+ import { RemoteAccessService } from "./remote_access_service";
20
21
  export interface Endpoints {
21
22
  product: string;
22
23
  crm: string;
@@ -37,6 +38,7 @@ export interface Endpoints {
37
38
  order_cloud_rest: string;
38
39
  accounting_service: string;
39
40
  quicklab_service: string;
41
+ remote_access_service: string;
40
42
  }
41
43
  export declare class SDK {
42
44
  orgId: string;
@@ -62,6 +64,7 @@ export declare class SDK {
62
64
  order_cloud_rest: OrderCloudRestService;
63
65
  accounting_service: AccountingService;
64
66
  quicklab_service: QuicklabService;
67
+ remote_access_service: RemoteAccessService;
65
68
  token: string | null;
66
69
  private endpoints;
67
70
  constructor(orgId: string, storeId: string, storefrontAccessToken: string, environment: string);
@@ -23,6 +23,7 @@ const cloud_rest_1 = require("./cloud_rest");
23
23
  const order_cloud_rest_1 = require("./order_cloud_rest");
24
24
  const accounting_service_1 = require("./accounting_service");
25
25
  const quicklab_service_1 = require("./quicklab_service");
26
+ const remote_access_service_1 = require("./remote_access_service");
26
27
  class SDK {
27
28
  constructor(orgId, storeId, storefrontAccessToken, environment) {
28
29
  this.orgId = orgId;
@@ -56,6 +57,7 @@ class SDK {
56
57
  this.order_cloud_rest = new order_cloud_rest_1.OrderCloudRestService(this.endpoints.order_cloud_rest, orgId, storeId);
57
58
  this.accounting_service = new accounting_service_1.AccountingService(this.endpoints.accounting_service, orgId, storeId);
58
59
  this.quicklab_service = new quicklab_service_1.QuicklabService(this.endpoints.quicklab_service, orgId, storeId);
60
+ this.remote_access_service = new remote_access_service_1.RemoteAccessService(this.endpoints.remote_access_service, orgId, storeId);
59
61
  // Initialize other services here
60
62
  }
61
63
  setToken(token) {
@@ -80,6 +82,7 @@ class SDK {
80
82
  this.order_cloud_rest.setToken(token);
81
83
  this.accounting_service.setToken(token);
82
84
  this.quicklab_service.setToken(token);
85
+ this.remote_access_service.setToken(token);
83
86
  // Set token for other services here
84
87
  }
85
88
  // các module export từ serviceSDK.ts set storeId vào serviceSDK.ts
@@ -106,6 +109,7 @@ class SDK {
106
109
  this.order_cloud_rest = new order_cloud_rest_1.OrderCloudRestService(this.endpoints.order_cloud_rest, this.orgId, storeId);
107
110
  this.accounting_service = new accounting_service_1.AccountingService(this.endpoints.accounting_service, this.orgId, storeId);
108
111
  this.quicklab_service = new quicklab_service_1.QuicklabService(this.endpoints.quicklab_service, this.orgId, storeId);
112
+ this.remote_access_service = new remote_access_service_1.RemoteAccessService(this.endpoints.remote_access_service, this.orgId, storeId);
109
113
  }
110
114
  }
111
115
  exports.SDK = SDK;
@@ -9,4 +9,5 @@ export declare class PaymentLVService extends Service {
9
9
  confirmPaidManual(paymentId: string, confirmBy: string): Promise<any>;
10
10
  getPaymentMethodTypes(store: string): Promise<any>;
11
11
  paymentMethods(): Promise<any>;
12
+ paymentStatus(paymentId: string): Promise<any>;
12
13
  }
@@ -65,6 +65,7 @@ class PaymentLVService extends serviceSDK_1.Service {
65
65
  const mutation = mutations_1.CANCEL_PAYMENT;
66
66
  const variables = {
67
67
  paymentId,
68
+ safeMode: true,
68
69
  reason,
69
70
  createBy,
70
71
  };
@@ -128,5 +129,21 @@ class PaymentLVService extends serviceSDK_1.Service {
128
129
  }
129
130
  });
130
131
  }
132
+ paymentStatus(paymentId) {
133
+ return __awaiter(this, void 0, void 0, function* () {
134
+ const query = queries_1.PAYMENT_STATUS;
135
+ const variables = {
136
+ paymentId,
137
+ };
138
+ try {
139
+ const response = yield this.graphqlQueryCustomHeader(query, variables);
140
+ return response.paymentStatus;
141
+ }
142
+ catch (error) {
143
+ console.log(`Error fetching get paymentStatus method: ${error}`);
144
+ throw error;
145
+ }
146
+ });
147
+ }
131
148
  }
132
149
  exports.PaymentLVService = PaymentLVService;
@@ -0,0 +1,14 @@
1
+ import { Service } from "../serviceSDK";
2
+ export declare class RemoteAccessService extends Service {
3
+ constructor(endpoint: string, orgId: string, storeId: string);
4
+ setToken(token: string): void;
5
+ setStoreId(storeId: string): void;
6
+ GetRemoteAccessByTargetIdAndTargetType(targetId: string, targetType: string): Promise<any>;
7
+ GetConnectionInfoFromRemoteAccessById(remoteAccessId: string): Promise<any>;
8
+ createRemoteAccess(data: any): Promise<any>;
9
+ updateRemoteAccessName(remoteAccessId: string, name: string, updatedBy: string): Promise<any>;
10
+ updateRemoteAccessDescription(remoteAccessId: string, description: string, updatedBy: string): Promise<any>;
11
+ updateRemoteAccessType(remoteAccessId: string, type: string, updatedBy: string): Promise<any>;
12
+ updateRemoteAccessInfo(remoteAccessId: string, remoteAccessInfoInput: any, updatedBy: string): Promise<any>;
13
+ deleteRemoteAccess(remoteAccessId: string, updatedBy: string): Promise<any>;
14
+ }
@@ -0,0 +1,163 @@
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.RemoteAccessService = void 0;
13
+ const mutations_1 = require("../../graphql/remote_access_service/mutations");
14
+ const queries_1 = require("../../graphql/remote_access_service/queries");
15
+ const serviceSDK_1 = require("../serviceSDK");
16
+ class RemoteAccessService extends serviceSDK_1.Service {
17
+ constructor(endpoint, orgId, storeId) {
18
+ super(endpoint, orgId, storeId);
19
+ }
20
+ setToken(token) {
21
+ this.token = token;
22
+ }
23
+ setStoreId(storeId) {
24
+ this.storeId = storeId;
25
+ }
26
+ GetRemoteAccessByTargetIdAndTargetType(targetId, targetType) {
27
+ return __awaiter(this, void 0, void 0, function* () {
28
+ const query = queries_1.GET_REMOTE_ACCESS_BY_TARGETID_AND_TARGETTYPE;
29
+ const variables = {
30
+ targetId,
31
+ targetType,
32
+ };
33
+ try {
34
+ const response = yield this.graphqlQuery(query, variables);
35
+ return response.getRemoteAccessByTargetIdAndTargetType;
36
+ }
37
+ catch (error) {
38
+ console.log(`Error in GetRemoteAccessByTargetIdAndTargetType : ${error}`);
39
+ throw error;
40
+ }
41
+ });
42
+ }
43
+ GetConnectionInfoFromRemoteAccessById(remoteAccessId) {
44
+ return __awaiter(this, void 0, void 0, function* () {
45
+ const query = queries_1.GET_CONNECTION_INFO_FROM_REMOTE_ACCESS_BY_ID;
46
+ const variables = {
47
+ remoteAccessId,
48
+ };
49
+ try {
50
+ const response = yield this.graphqlQueryV2(query, variables);
51
+ return response.getConnectionInfoFromRemoteAccessById;
52
+ }
53
+ catch (error) {
54
+ console.log(`Error in GetConnectionInfoFromRemoteAccessById : ${error}`);
55
+ throw error;
56
+ }
57
+ });
58
+ }
59
+ createRemoteAccess(data) {
60
+ return __awaiter(this, void 0, void 0, function* () {
61
+ const mutation = mutations_1.CREATE_REMOTE_ACCESS;
62
+ const variables = Object.assign({}, data);
63
+ try {
64
+ const response = yield this.graphqlMutation(mutation, variables);
65
+ return response.createRemoteAccess;
66
+ }
67
+ catch (error) {
68
+ console.log(`Error in createRemoteAccess : ${error}`);
69
+ throw error;
70
+ }
71
+ });
72
+ }
73
+ updateRemoteAccessName(remoteAccessId, name, updatedBy) {
74
+ return __awaiter(this, void 0, void 0, function* () {
75
+ const mutation = mutations_1.UPDATE_REMOTE_ACCESS_NAME;
76
+ const variables = {
77
+ remoteAccessId,
78
+ name,
79
+ updatedBy,
80
+ };
81
+ try {
82
+ const response = yield this.graphqlMutation(mutation, variables);
83
+ return response.updateRemoteAccessName;
84
+ }
85
+ catch (error) {
86
+ console.log(`Error in updateRemoteAccessName : ${error}`);
87
+ throw error;
88
+ }
89
+ });
90
+ }
91
+ updateRemoteAccessDescription(remoteAccessId, description, updatedBy) {
92
+ return __awaiter(this, void 0, void 0, function* () {
93
+ const mutation = mutations_1.UPDATE_REMOTE_ACCESS_DESCRIPTION;
94
+ const variables = {
95
+ remoteAccessId,
96
+ description,
97
+ updatedBy,
98
+ };
99
+ try {
100
+ const response = yield this.graphqlMutation(mutation, variables);
101
+ return response.updateRemoteAccessDescription;
102
+ }
103
+ catch (error) {
104
+ console.log(`Error in updateRemoteAccessDescription : ${error}`);
105
+ throw error;
106
+ }
107
+ });
108
+ }
109
+ updateRemoteAccessType(remoteAccessId, type, updatedBy) {
110
+ return __awaiter(this, void 0, void 0, function* () {
111
+ const mutation = mutations_1.UPDATE_REMOTE_ACCESS_TYPE;
112
+ const variables = {
113
+ remoteAccessId,
114
+ type,
115
+ updatedBy,
116
+ };
117
+ try {
118
+ const response = yield this.graphqlMutation(mutation, variables);
119
+ return response.updateRemoteAccessType;
120
+ }
121
+ catch (error) {
122
+ console.log(`Error in updateRemoteAccessType : ${error}`);
123
+ throw error;
124
+ }
125
+ });
126
+ }
127
+ updateRemoteAccessInfo(remoteAccessId, remoteAccessInfoInput, updatedBy) {
128
+ return __awaiter(this, void 0, void 0, function* () {
129
+ const mutation = mutations_1.UPDATE_REMOTE_ACCESS_INFO;
130
+ const variables = {
131
+ remoteAccessId,
132
+ remoteAccessInfoInput,
133
+ updatedBy,
134
+ };
135
+ try {
136
+ const response = yield this.graphqlMutation(mutation, variables);
137
+ return response.updateRemoteAccessInfo;
138
+ }
139
+ catch (error) {
140
+ console.log(`Error in updateRemoteAccessInfo : ${error}`);
141
+ throw error;
142
+ }
143
+ });
144
+ }
145
+ deleteRemoteAccess(remoteAccessId, updatedBy) {
146
+ return __awaiter(this, void 0, void 0, function* () {
147
+ const mutation = mutations_1.DELETE_REMOTE_ACCESS;
148
+ const variables = {
149
+ remoteAccessId,
150
+ updatedBy,
151
+ };
152
+ try {
153
+ const response = yield this.graphqlMutation(mutation, variables);
154
+ return response.deleteRemoteAccess;
155
+ }
156
+ catch (error) {
157
+ console.log(`Error in deleteRemoteAccess : ${error}`);
158
+ throw error;
159
+ }
160
+ });
161
+ }
162
+ }
163
+ exports.RemoteAccessService = RemoteAccessService;
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longvansoftware/service-js-client",
3
- "version": "1.18.8",
3
+ "version": "1.18.9",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "files": [