@longvansoftware/service-js-client 2.5.4 → 2.5.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.
@@ -23,4 +23,3 @@ 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
25
  export declare const CREATE_COMPUTING_FOR_EC: DocumentNode;
26
- export declare const UPDATE_CLIENT_GROUP_ID_DYNAMIC: (fields?: string[]) => DocumentNode;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UPDATE_CLIENT_GROUP_ID_DYNAMIC = 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;
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!, $serviceId: String!) {
@@ -358,21 +358,3 @@ exports.CREATE_COMPUTING_FOR_EC = (0, graphql_tag_1.gql) `
358
358
  }
359
359
  }
360
360
  `;
361
- const UPDATE_CLIENT_GROUP_ID_DYNAMIC = (fields = []) => {
362
- const fieldStr = fields.join('\n ');
363
- const hasFields = fields.length > 0;
364
- return (0, graphql_tag_1.gql) `
365
- mutation UpdateClientGroupId(
366
- $computingIds: [String]
367
- $groupId: String
368
- $updateBy: String!
369
- ) {
370
- updateClientGroupId(
371
- computingIds: $computingIds
372
- groupId: $groupId
373
- updateBy: $updateBy
374
- )
375
- }
376
- `;
377
- };
378
- exports.UPDATE_CLIENT_GROUP_ID_DYNAMIC = UPDATE_CLIENT_GROUP_ID_DYNAMIC;
@@ -1,7 +1,6 @@
1
1
  import { DocumentNode } from "graphql";
2
2
  export declare const SEARCH_PRODUCT_QUANTITY_PROMOTION_ACTION: DocumentNode;
3
3
  export declare const GET_CAMPAIGN_ACTION_BY_ID: DocumentNode;
4
- export declare const GET_PRODUCT_DISCOUNT_BUY_WITH_DYNAMIC: (fields?: string[]) => DocumentNode;
5
4
  export declare const SUGGEST_VOUCHER: DocumentNode;
6
5
  export declare const GET_VOUCHERS: DocumentNode;
7
6
  export declare const GET_AVERAGE_RATING: DocumentNode;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GET_VOUCHERS_FOR_USER = exports.GET_CONDITION_BY_ORGID_CAMPAIGN_ACTIONIDS = exports.SEARCH_CAMPAIGN = exports.GET_VOUCHERS_V2 = exports.SEARCH_PRODUCT_GIFT_PROMOTION_RESPONSE = exports.GET_NUMBER_OF_TICKET_EVALUATION = exports.GET_URL_EVALUATION = exports.GET_AVERAGE_RATING = exports.GET_VOUCHERS = exports.SUGGEST_VOUCHER = exports.GET_PRODUCT_DISCOUNT_BUY_WITH_DYNAMIC = exports.GET_CAMPAIGN_ACTION_BY_ID = exports.SEARCH_PRODUCT_QUANTITY_PROMOTION_ACTION = void 0;
3
+ exports.GET_VOUCHERS_FOR_USER = exports.GET_CONDITION_BY_ORGID_CAMPAIGN_ACTIONIDS = exports.SEARCH_CAMPAIGN = exports.GET_VOUCHERS_V2 = exports.SEARCH_PRODUCT_GIFT_PROMOTION_RESPONSE = exports.GET_NUMBER_OF_TICKET_EVALUATION = exports.GET_URL_EVALUATION = exports.GET_AVERAGE_RATING = exports.GET_VOUCHERS = exports.SUGGEST_VOUCHER = exports.GET_CAMPAIGN_ACTION_BY_ID = exports.SEARCH_PRODUCT_QUANTITY_PROMOTION_ACTION = void 0;
4
4
  const graphql_tag_1 = require("graphql-tag");
5
5
  exports.SEARCH_PRODUCT_QUANTITY_PROMOTION_ACTION = (0, graphql_tag_1.gql) `
6
6
  query SearchProductQuantityPromotionAction(
@@ -41,26 +41,6 @@ exports.GET_CAMPAIGN_ACTION_BY_ID = (0, graphql_tag_1.gql) `
41
41
  }
42
42
  }
43
43
  `;
44
- const GET_PRODUCT_DISCOUNT_BUY_WITH_DYNAMIC = (fields = []) => {
45
- const fieldStr = fields.join('\n ');
46
- const hasFields = fields.length > 0;
47
- return (0, graphql_tag_1.gql) `
48
- query GetProductDiscountBuyWith(
49
- $partnerId: String!
50
- $storeId: String!
51
- $productId: String!
52
- ) {
53
- getProductDiscountBuyWith(
54
- partnerId: $partnerId
55
- storeId: $storeId
56
- productId: $productId
57
- ) {
58
- ${hasFields ? `${fieldStr}` : ''}
59
- }
60
- }
61
- `;
62
- };
63
- exports.GET_PRODUCT_DISCOUNT_BUY_WITH_DYNAMIC = GET_PRODUCT_DISCOUNT_BUY_WITH_DYNAMIC;
64
44
  // export const SUGGEST_VOUCHER = gql`
65
45
  // query SuggestVoucher (
66
46
  // searchVoucherRequest: { partyId: String, customerId: String }
@@ -1,4 +0,0 @@
1
- import { DocumentNode } from 'graphql';
2
- export declare const CREATE_CLIENT_GROUP_DYNAMIC: (fields?: string[]) => DocumentNode;
3
- export declare const UPDATE_CLIENT_GROUP_NAME_DYNAMIC: (fields?: string[]) => DocumentNode;
4
- export declare const DELETE_CLIENT_GROUP_DYNAMIC: (fields?: string[]) => DocumentNode;
@@ -1,60 +1 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DELETE_CLIENT_GROUP_DYNAMIC = exports.UPDATE_CLIENT_GROUP_NAME_DYNAMIC = exports.CREATE_CLIENT_GROUP_DYNAMIC = void 0;
4
- const graphql_tag_1 = require("graphql-tag");
5
- const CREATE_CLIENT_GROUP_DYNAMIC = (fields = []) => {
6
- const fieldStr = fields.join('\n ');
7
- const hasFields = fields.length > 0;
8
- return (0, graphql_tag_1.gql) `
9
- mutation CreateClientGroup(
10
- $name: String!
11
- $createdBy: String!
12
- $resourceId: String!
13
- $resourceType: String!
14
- $scope: String!
15
- ) {
16
- createClientGroup(
17
- name: $name
18
- createdBy: $createdBy
19
- resourceId: $resourceId
20
- resourceType: $resourceType
21
- scope: $scope
22
- ) {
23
- ${hasFields ? `${fieldStr}` : ''}
24
- }
25
- }
26
- `;
27
- };
28
- exports.CREATE_CLIENT_GROUP_DYNAMIC = CREATE_CLIENT_GROUP_DYNAMIC;
29
- const UPDATE_CLIENT_GROUP_NAME_DYNAMIC = (fields = []) => {
30
- const fieldStr = fields.join('\n ');
31
- const hasFields = fields.length > 0;
32
- return (0, graphql_tag_1.gql) `
33
- mutation UpdateClientGroupName(
34
- $groupId: String!
35
- $name: String!
36
- $updatedBy: String!
37
- ) {
38
- updateClientGroupName(
39
- groupId: $groupId
40
- name: $name
41
- updatedBy: $updatedBy
42
- )
43
- }
44
- `;
45
- };
46
- exports.UPDATE_CLIENT_GROUP_NAME_DYNAMIC = UPDATE_CLIENT_GROUP_NAME_DYNAMIC;
47
- const DELETE_CLIENT_GROUP_DYNAMIC = (fields = []) => {
48
- const fieldStr = fields.join('\n ');
49
- const hasFields = fields.length > 0;
50
- return (0, graphql_tag_1.gql) `
51
- mutation DeleteClientGroup(
52
- $groupId: String!
53
- ) {
54
- deleteClientGroup(
55
- groupId: $groupId
56
- )
57
- }
58
- `;
59
- };
60
- exports.DELETE_CLIENT_GROUP_DYNAMIC = DELETE_CLIENT_GROUP_DYNAMIC;
@@ -13,7 +13,6 @@ export declare const GET_BRAND_DETAIL_QUERY = "\n query GetBrandDetail($partner
13
13
  export declare const GET_PRODUCT_OPTION: DocumentNode;
14
14
  export declare const GET_POLICY: DocumentNode;
15
15
  export declare const GET_PRODUCTS: DocumentNode;
16
- export declare const GET_CLIENT_GROUPS_DYNAMIC: (fields?: string[]) => DocumentNode;
17
16
  export declare const GET_PRODUCTS_DYNAMIC: (fields?: string[]) => DocumentNode;
18
17
  export declare const GET_HANDLE_BY_SERVICETYPE: DocumentNode;
19
18
  export declare const GET_RESOURCE_BY_PRODUCT: DocumentNode;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GET_PRODUCT_OPTION_DYNAMIC = exports.GET_PRODUCT_SIMPLE_BY_HANDLE_DYNAMIC = exports.GET_PRODUCTS_FEATURE_TYPE_DYNAMIC = exports.GET_PRODUCT_RELATED_TO_ARTICLE = exports.GET_SIMPLE_PRODUCTS_DYNAMIC = exports.GET_PRICE_MENUS = exports.GET_CATEGORIES = exports.GET_LIST_PRODUCTS_CONFIG_DYNAMIC = exports.GET_TAGS_BY_CATEGORY = exports.GET_TAGS = exports.GET_LIST_PRICE = exports.GET_DETAIL_STORES = exports.GET_RELATED_INFOR = exports.GET_PRODUCT_VARIANT_BY_ID_QUERY_DYNAMIC = exports.GET_PRODUCT_VARIANT_BY_ID = exports.GET_RESOURCE_BY_PRODUCT = exports.GET_HANDLE_BY_SERVICETYPE = exports.GET_PRODUCTS_DYNAMIC = exports.GET_CLIENT_GROUPS_DYNAMIC = exports.GET_PRODUCTS = exports.GET_POLICY = exports.GET_PRODUCT_OPTION = exports.GET_BRAND_DETAIL_QUERY = exports.GET_BRANDS_BY_CATEGORY_QUERY = exports.GET_BRANDS_QUERY = exports.GET_CATEGORY_BY_ID_QUERY = exports.GET_CATEGORY_BY_HANDLE_QUERY = exports.GET_CATEGORIES_QUERY = exports.GET_SIMPLE_PRODUCTS_QUERY = exports.GET_PRODUCT_BY_SLUG_QUERY = exports.GET_SIMPLE_PRODUCT_BY_ID_QUERY_DYNAMIC = exports.GET_PRODUCT_BY_ID_QUERY_DYNAMIC = exports.GET_PRODUCT_BY_ID_QUERY = void 0;
3
+ exports.GET_PRODUCT_OPTION_DYNAMIC = exports.GET_PRODUCT_SIMPLE_BY_HANDLE_DYNAMIC = exports.GET_PRODUCTS_FEATURE_TYPE_DYNAMIC = exports.GET_PRODUCT_RELATED_TO_ARTICLE = exports.GET_SIMPLE_PRODUCTS_DYNAMIC = exports.GET_PRICE_MENUS = exports.GET_CATEGORIES = exports.GET_LIST_PRODUCTS_CONFIG_DYNAMIC = exports.GET_TAGS_BY_CATEGORY = exports.GET_TAGS = exports.GET_LIST_PRICE = exports.GET_DETAIL_STORES = exports.GET_RELATED_INFOR = exports.GET_PRODUCT_VARIANT_BY_ID_QUERY_DYNAMIC = exports.GET_PRODUCT_VARIANT_BY_ID = exports.GET_RESOURCE_BY_PRODUCT = exports.GET_HANDLE_BY_SERVICETYPE = exports.GET_PRODUCTS_DYNAMIC = exports.GET_PRODUCTS = exports.GET_POLICY = exports.GET_PRODUCT_OPTION = exports.GET_BRAND_DETAIL_QUERY = exports.GET_BRANDS_BY_CATEGORY_QUERY = exports.GET_BRANDS_QUERY = exports.GET_CATEGORY_BY_ID_QUERY = exports.GET_CATEGORY_BY_HANDLE_QUERY = exports.GET_CATEGORIES_QUERY = exports.GET_SIMPLE_PRODUCTS_QUERY = exports.GET_PRODUCT_BY_SLUG_QUERY = exports.GET_SIMPLE_PRODUCT_BY_ID_QUERY_DYNAMIC = exports.GET_PRODUCT_BY_ID_QUERY_DYNAMIC = exports.GET_PRODUCT_BY_ID_QUERY = void 0;
4
4
  const graphql_tag_1 = require("graphql-tag");
5
5
  // export const GET_PRODUCT_BY_ID_QUERY = gql`
6
6
  // query GetProductById(
@@ -713,26 +713,6 @@ exports.GET_PRODUCTS = (0, graphql_tag_1.gql) `
713
713
  }
714
714
  }
715
715
  `;
716
- const GET_CLIENT_GROUPS_DYNAMIC = (fields = []) => {
717
- const fieldStr = fields.join("\n ");
718
- const hasFields = fields.length > 0;
719
- return (0, graphql_tag_1.gql) `
720
- query GetClientGroups(
721
- $resourceId: String!
722
- $resourceType: String!
723
- $scope: String!
724
- ) {
725
- getClientGroups(
726
- resourceId: $resourceId
727
- resourceType: $resourceType
728
- scope: $scope
729
- ) {
730
- ${hasFields ? `${fieldStr}` : ""}
731
- }
732
- }
733
- `;
734
- };
735
- exports.GET_CLIENT_GROUPS_DYNAMIC = GET_CLIENT_GROUPS_DYNAMIC;
736
716
  const GET_PRODUCTS_DYNAMIC = (fields = []) => {
737
717
  const fieldStr = fields.join("\n ");
738
718
  const hasFields = fields.length > 0;
@@ -61,7 +61,6 @@ export declare class ComputingService extends Service {
61
61
  updateCPU(computingId: string, socket: number, corePerSocket: number, updateBy: string, serviceId: string): Promise<any>;
62
62
  updateRAM(computingId: string, size: number, unit: string, updateBy: string, serviceId: string): Promise<any>;
63
63
  getComputingsDynamic(userId: string, fields: string[]): Promise<any>;
64
- updateClientGroupIdDynamic(computingIds: [string] | null, groupId: string, updateBy: string, fields: string[]): Promise<any>;
65
64
  createComputingForEC(createComputingInputForEC: any, createBy: string): Promise<any>;
66
65
  computingDetailDynamic(computingId: string, serviceId: string, fields: string[]): Promise<any>;
67
66
  }
@@ -923,24 +923,6 @@ class ComputingService extends serviceSDK_1.Service {
923
923
  }
924
924
  });
925
925
  }
926
- updateClientGroupIdDynamic(computingIds, groupId, updateBy, fields) {
927
- return __awaiter(this, void 0, void 0, function* () {
928
- const query = (0, mutations_1.UPDATE_CLIENT_GROUP_ID_DYNAMIC)(fields);
929
- const variables = {
930
- computingIds,
931
- groupId,
932
- updateBy,
933
- };
934
- try {
935
- const response = yield this.graphqlMutationV2(query, variables);
936
- return response.updateClientGroupId;
937
- }
938
- catch (error) {
939
- console.log(`Error in updateClientGroupIdDynamic: ${error}`);
940
- throw error;
941
- }
942
- });
943
- }
944
926
  createComputingForEC(createComputingInputForEC, createBy) {
945
927
  return __awaiter(this, void 0, void 0, function* () {
946
928
  const mutation = mutations_1.CREATE_COMPUTING_FOR_EC;
@@ -6,7 +6,6 @@ export declare class CrmCampingService extends Service {
6
6
  searchProductQuantityPromotionAction(productId: string): Promise<any>;
7
7
  addCustomerToVoucher(userId: string, voucherCode: string): Promise<any>;
8
8
  getCampaignActionById(campaignActionId: string): Promise<any>;
9
- getProductDiscountBuyWithDynamic(productId: string, fields: string[]): Promise<any>;
10
9
  suggestVoucher(customerId: string, scopeIgnore: string | null, scope: string | null, isNewCustomer: boolean, voucherCode: string | null): Promise<any>;
11
10
  searchVouchers(campaignId: String, campaignActionId: String, campaignActionType: String, customerId: String, pageNumber: number, pageSize: number): Promise<any>;
12
11
  getAverageRating(targetIds: [string], customerId: string, evaluationType: string): Promise<any>;
@@ -73,24 +73,22 @@ class CrmCampingService extends serviceSDK_1.Service {
73
73
  }
74
74
  });
75
75
  }
76
- getProductDiscountBuyWithDynamic(productId, fields) {
77
- return __awaiter(this, void 0, void 0, function* () {
78
- const query = (0, queries_1.GET_PRODUCT_DISCOUNT_BUY_WITH_DYNAMIC)(fields);
79
- const variables = {
80
- partnerId: this.orgId,
81
- storeId: this.storeId,
82
- productId,
83
- };
84
- try {
85
- const response = yield this.graphqlQueryV2(query, variables);
86
- return response.getProductDiscountBuyWith;
87
- }
88
- catch (error) {
89
- console.log(`Error in getProductDiscountBuyWithDynamic: ${error}`);
90
- throw error;
91
- }
92
- });
93
- }
76
+ // async suggestVoucher(customerId: String){
77
+ // const query = SUGGEST_VOUCHER;
78
+ // const variables = {
79
+ // partyId: this.orgId,
80
+ // customerId
81
+ // };
82
+ // console.log("🚀 Query:", SUGGEST_VOUCHER);
83
+ // console.log("🚀 Variables:", { partyId: this.orgId, customerId });
84
+ // try {
85
+ // const response = await this.graphqlQueryV2(query, variables);
86
+ // return response.suggestVoucher;
87
+ // } catch (error) {
88
+ // console.log(`Error in suggestVoucher: ${error}`);
89
+ // throw error;
90
+ // }
91
+ // }
94
92
  suggestVoucher(customerId, scopeIgnore, scope, isNewCustomer, voucherCode) {
95
93
  return __awaiter(this, void 0, void 0, function* () {
96
94
  const query = queries_1.SUGGEST_VOUCHER;
@@ -40,10 +40,6 @@ export declare class ProductService extends Service {
40
40
  getProductOption(productId: string, store: string): Promise<any>;
41
41
  getPolicy(groupId: string): Promise<any>;
42
42
  getProducts(param: getProduct, store: string): Promise<any>;
43
- getClientGroupsDynamic(resourceId: string, resourceType: string, scope: string, fields: string[]): Promise<any>;
44
- createClientGroupDynamic(name: string, createdBy: string, resourceId: string, resourceType: string, scope: string, fields: string[]): Promise<any>;
45
- updateClientGroupNameDynamic(groupId: string, name: string, updatedBy: string, fields: string[]): Promise<any>;
46
- deleteClientGroupDynamic(groupId: string, fields: string[]): Promise<any>;
47
43
  getProductsDynamic(param: getProduct, store: string, fields: string[]): Promise<any>;
48
44
  getHandleByServiceTypes(serviceTypes: [string]): Promise<any>;
49
45
  getResourceByProduct(productId: string): Promise<any>;
@@ -12,7 +12,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.ProductService = void 0;
13
13
  const serviceSDK_1 = require("../serviceSDK");
14
14
  const queries_1 = require("../../graphql/product/queries");
15
- const mutations_1 = require("../../graphql/product/mutations");
16
15
  /**
17
16
  * Service class for managing product-related operations.
18
17
  */
@@ -182,78 +181,6 @@ class ProductService extends serviceSDK_1.Service {
182
181
  }
183
182
  });
184
183
  }
185
- getClientGroupsDynamic(resourceId, resourceType, scope, fields) {
186
- return __awaiter(this, void 0, void 0, function* () {
187
- const query = (0, queries_1.GET_CLIENT_GROUPS_DYNAMIC)(fields);
188
- const variablesHandle = {
189
- resourceId,
190
- resourceType,
191
- scope,
192
- };
193
- try {
194
- const response = yield this.graphqlQueryV2(query, variablesHandle);
195
- return response.getClientGroups;
196
- }
197
- catch (error) {
198
- console.log(`Error fetching getClientGroups: ${error}`);
199
- throw error;
200
- }
201
- });
202
- }
203
- createClientGroupDynamic(name, createdBy, resourceId, resourceType, scope, fields) {
204
- return __awaiter(this, void 0, void 0, function* () {
205
- const mutation = (0, mutations_1.CREATE_CLIENT_GROUP_DYNAMIC)(fields);
206
- const variablesHandle = {
207
- name,
208
- createdBy,
209
- resourceId,
210
- resourceType,
211
- scope,
212
- };
213
- try {
214
- const response = yield this.graphqlMutationV2(mutation, variablesHandle);
215
- return response.createClientGroup;
216
- }
217
- catch (error) {
218
- console.log(`Error fetching createClientGroup: ${error}`);
219
- throw error;
220
- }
221
- });
222
- }
223
- updateClientGroupNameDynamic(groupId, name, updatedBy, fields) {
224
- return __awaiter(this, void 0, void 0, function* () {
225
- const mutation = (0, mutations_1.UPDATE_CLIENT_GROUP_NAME_DYNAMIC)(fields);
226
- const variablesHandle = {
227
- groupId,
228
- name,
229
- updatedBy
230
- };
231
- try {
232
- const response = yield this.graphqlMutationV2(mutation, variablesHandle);
233
- return response.updateClientGroupName;
234
- }
235
- catch (error) {
236
- console.log(`Error fetching updateClientGroupNameDynamic: ${error}`);
237
- throw error;
238
- }
239
- });
240
- }
241
- deleteClientGroupDynamic(groupId, fields) {
242
- return __awaiter(this, void 0, void 0, function* () {
243
- const mutation = (0, mutations_1.DELETE_CLIENT_GROUP_DYNAMIC)(fields);
244
- const variablesHandle = {
245
- groupId
246
- };
247
- try {
248
- const response = yield this.graphqlMutationV2(mutation, variablesHandle);
249
- return response.deleteClientGroup;
250
- }
251
- catch (error) {
252
- console.log(`Error fetching deleteClientGroupDynamic: ${error}`);
253
- throw error;
254
- }
255
- });
256
- }
257
184
  getProductsDynamic(param, store, fields) {
258
185
  return __awaiter(this, void 0, void 0, function* () {
259
186
  const query = (0, queries_1.GET_PRODUCTS_DYNAMIC)(fields);
@@ -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": "2.5.4",
3
+ "version": "2.5.5",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "files": [
@@ -39,5 +39,6 @@
39
39
  "ts-jest": "^29.1.2",
40
40
  "typescript": "^5.4.5"
41
41
  },
42
- "description": ""
42
+ "description": "",
43
+ "packageManager": "yarn@1.22.22+sha1.ac34549e6aa8e7ead463a7407e1c7390f61a6610"
43
44
  }