@longvansoftware/service-js-client 2.2.1 → 2.2.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.
@@ -21,6 +21,7 @@ export declare const environmentEndpoints: {
21
21
  quicklab_service: string;
22
22
  remote_access_service: string;
23
23
  storage_s3: string;
24
+ content_api: string;
24
25
  };
25
26
  live: {
26
27
  product: string;
@@ -44,5 +45,6 @@ export declare const environmentEndpoints: {
44
45
  quicklab_service: string;
45
46
  remote_access_service: string;
46
47
  storage_s3: string;
48
+ content_api: string;
47
49
  };
48
50
  };
@@ -25,6 +25,7 @@ exports.environmentEndpoints = {
25
25
  remote_access_service: "https://api-gateway.dev.longvan.vn/remote-access-service/graphql",
26
26
  // storage_s3: "https://portal.dev.longvan.vn/storage-s3-api/graphql",
27
27
  storage_s3: "https://storage-s3-api.dev.longvan.vn/storage-s3-api/graphql",
28
+ content_api: "https://portal.dev.longvan.vn/content-api/graphql"
28
29
  },
29
30
  live: {
30
31
  product: "https://product-service.longvan.vn/product-service/graphql",
@@ -49,5 +50,6 @@ exports.environmentEndpoints = {
49
50
  remote_access_service: "https://api-gateway.longvan.vn/remote-access-service/graphql",
50
51
  // storage_s3: "https://portal.longvan.vn/storage-s3-api/graphql",
51
52
  storage_s3: "https://storage-s3-api.longvan.vn/storage-s3-api/graphql",
53
+ content_api: "https://portal.longvan.vn/content-api/graphql"
52
54
  },
53
55
  };
@@ -0,0 +1,2 @@
1
+ import { DocumentNode } from "graphql";
2
+ export declare const GET_ARTICLE_RELATED_TO_PRODUCT: (fields?: string[]) => DocumentNode;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GET_ARTICLE_RELATED_TO_PRODUCT = void 0;
4
+ const graphql_tag_1 = require("graphql-tag");
5
+ const GET_ARTICLE_RELATED_TO_PRODUCT = (fields = []) => {
6
+ const fieldStr = fields.join("\n ");
7
+ const hasFields = fields.length > 0;
8
+ return (0, graphql_tag_1.gql) `
9
+ query getArticleRelatedToProduct(
10
+ $partnerId: String!
11
+ $productId: String!
12
+ ) {
13
+ getArticleRelatedToProduct(
14
+ partnerId: $partnerId
15
+ productId: $productId
16
+ )
17
+ {
18
+ ${hasFields ? `${fieldStr}` : ""}
19
+ }
20
+ }
21
+ `;
22
+ };
23
+ exports.GET_ARTICLE_RELATED_TO_PRODUCT = GET_ARTICLE_RELATED_TO_PRODUCT;
@@ -26,3 +26,4 @@ export declare const GET_LIST_PRODUCTS_CONFIG_DYNAMIC: (fields?: string[]) => Do
26
26
  export declare const GET_CATEGORIES: DocumentNode;
27
27
  export declare const GET_PRICE_MENUS: DocumentNode;
28
28
  export declare const GET_SIMPLE_PRODUCTS_DYNAMIC: (fields?: string[]) => DocumentNode;
29
+ export declare const GET_PRODUCT_RELATED_TO_ARTICLE: (fields?: string[]) => DocumentNode;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- 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_PRODUCT_BY_ID_QUERY_DYNAMIC = exports.GET_PRODUCT_BY_ID_QUERY = void 0;
3
+ 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_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(
@@ -1177,3 +1177,23 @@ const GET_SIMPLE_PRODUCTS_DYNAMIC = (fields = []) => {
1177
1177
  `;
1178
1178
  };
1179
1179
  exports.GET_SIMPLE_PRODUCTS_DYNAMIC = GET_SIMPLE_PRODUCTS_DYNAMIC;
1180
+ const GET_PRODUCT_RELATED_TO_ARTICLE = (fields = []) => {
1181
+ const fieldStr = fields.join("\n ");
1182
+ const hasFields = fields.length > 0;
1183
+ return (0, graphql_tag_1.gql) `
1184
+ query getProductRelatedToArticle(
1185
+ $partnerId: String!
1186
+ $storeId: String!
1187
+ $articleId: String!
1188
+ ) {
1189
+ getProductRelatedToArticle(
1190
+ partnerId: $partnerId
1191
+ storeId: $storeId
1192
+ articleId: $articleId
1193
+ ) {
1194
+ ${hasFields ? `${fieldStr}` : ""}
1195
+ }
1196
+ }
1197
+ `;
1198
+ };
1199
+ exports.GET_PRODUCT_RELATED_TO_ARTICLE = GET_PRODUCT_RELATED_TO_ARTICLE;
@@ -8,3 +8,4 @@ export declare const GET_LIST_CORS_BY_S3_USER_ID: (fields?: string[]) => Documen
8
8
  export declare const GET_LIST_FILE_OTHER_VERSION: (fields?: string[]) => DocumentNode;
9
9
  export declare const CHART_IN_YEAR: (fields?: string[]) => DocumentNode;
10
10
  export declare const GET_IP_CONSUL: DocumentNode;
11
+ export declare const FILTER_LIST_OBJECT: (fields?: string[]) => DocumentNode;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GET_IP_CONSUL = exports.CHART_IN_YEAR = exports.GET_LIST_FILE_OTHER_VERSION = exports.GET_LIST_CORS_BY_S3_USER_ID = exports.GET_LIST_S3_DOMAIN_BY_S3_USER_ID = exports.GET_LIST_FILE_TRASH = exports.GET_LIST_OBJECT = exports.GET_LIST_BUCKET_BY_S3_USER_ID = exports.GET_LIST_S3_USER_BY_SERVICE_ID = void 0;
3
+ exports.FILTER_LIST_OBJECT = exports.GET_IP_CONSUL = exports.CHART_IN_YEAR = exports.GET_LIST_FILE_OTHER_VERSION = exports.GET_LIST_CORS_BY_S3_USER_ID = exports.GET_LIST_S3_DOMAIN_BY_S3_USER_ID = exports.GET_LIST_FILE_TRASH = exports.GET_LIST_OBJECT = exports.GET_LIST_BUCKET_BY_S3_USER_ID = exports.GET_LIST_S3_USER_BY_SERVICE_ID = void 0;
4
4
  const graphql_tag_1 = require("graphql-tag");
5
5
  const GET_LIST_S3_USER_BY_SERVICE_ID = (fields = []) => {
6
6
  const fieldStr = fields.join('\n ');
@@ -103,3 +103,15 @@ exports.GET_IP_CONSUL = (0, graphql_tag_1.gql) `
103
103
  getIPConsul(userId: $userId)
104
104
  }
105
105
  `;
106
+ const FILTER_LIST_OBJECT = (fields = []) => {
107
+ const fieldStr = fields.join('\n ');
108
+ const hasFields = fields.length > 0;
109
+ return (0, graphql_tag_1.gql) `
110
+ query FilterListObject($s3UserId: String!, $bucketId: String!, $maxKeys: Int!, $key: String, $prefixSearch: String, $continuationToken: String) {
111
+ filterListObject(s3UserId: $s3UserId, bucketId: $bucketId, maxKeys: $maxKeys, key: $key, prefixSearch: $prefixSearch, continuationToken: $continuationToken){
112
+ ${hasFields ? `${fieldStr}` : ''}
113
+ }
114
+ }
115
+ `;
116
+ };
117
+ exports.FILTER_LIST_OBJECT = FILTER_LIST_OBJECT;
@@ -19,6 +19,7 @@ import { AccountingService } from "./accounting_service";
19
19
  import { QuicklabService } from "./quicklab_service";
20
20
  import { RemoteAccessService } from "./remote_access_service";
21
21
  import { StorageS3Service } from "./storage_s3";
22
+ import { ContentApiService } from "./content_api";
22
23
  export interface Endpoints {
23
24
  product: string;
24
25
  crm: string;
@@ -41,6 +42,7 @@ export interface Endpoints {
41
42
  quicklab_service: string;
42
43
  remote_access_service: string;
43
44
  storage_s3: string;
45
+ content_api: string;
44
46
  }
45
47
  export declare class SDK {
46
48
  orgId: string;
@@ -68,6 +70,7 @@ export declare class SDK {
68
70
  quicklab_service: QuicklabService;
69
71
  remote_access_service: RemoteAccessService;
70
72
  storage_s3: StorageS3Service;
73
+ content_api: ContentApiService;
71
74
  token: string | null;
72
75
  private endpoints;
73
76
  constructor(orgId: string, storeId: string, storefrontAccessToken: string, environment: string);
@@ -25,6 +25,7 @@ const accounting_service_1 = require("./accounting_service");
25
25
  const quicklab_service_1 = require("./quicklab_service");
26
26
  const remote_access_service_1 = require("./remote_access_service");
27
27
  const storage_s3_1 = require("./storage_s3");
28
+ const content_api_1 = require("./content_api");
28
29
  class SDK {
29
30
  constructor(orgId, storeId, storefrontAccessToken, environment) {
30
31
  this.orgId = orgId;
@@ -60,6 +61,7 @@ class SDK {
60
61
  this.quicklab_service = new quicklab_service_1.QuicklabService(this.endpoints.quicklab_service, orgId, storeId);
61
62
  this.remote_access_service = new remote_access_service_1.RemoteAccessService(this.endpoints.remote_access_service, orgId, storeId);
62
63
  this.storage_s3 = new storage_s3_1.StorageS3Service(this.endpoints.storage_s3, orgId, storeId);
64
+ this.content_api = new content_api_1.ContentApiService(this.endpoints.content_api, orgId, storeId);
63
65
  // Initialize other services here
64
66
  }
65
67
  setToken(token) {
@@ -86,6 +88,7 @@ class SDK {
86
88
  this.quicklab_service.setToken(token);
87
89
  this.remote_access_service.setToken(token);
88
90
  this.storage_s3.setToken(token);
91
+ this.content_api.setToken(token);
89
92
  // Set token for other services here
90
93
  }
91
94
  // các module export từ serviceSDK.ts set storeId vào serviceSDK.ts
@@ -114,6 +117,7 @@ class SDK {
114
117
  this.quicklab_service = new quicklab_service_1.QuicklabService(this.endpoints.quicklab_service, this.orgId, storeId);
115
118
  this.remote_access_service = new remote_access_service_1.RemoteAccessService(this.endpoints.remote_access_service, this.orgId, storeId);
116
119
  this.storage_s3 = new storage_s3_1.StorageS3Service(this.endpoints.storage_s3, this.orgId, storeId);
120
+ this.content_api = new content_api_1.ContentApiService(this.endpoints.content_api, this.orgId, storeId);
117
121
  }
118
122
  }
119
123
  exports.SDK = SDK;
@@ -0,0 +1,7 @@
1
+ import { Service } from "../serviceSDK";
2
+ export declare class ContentApiService extends Service {
3
+ constructor(endpoint: string, orgId: string, storeId: string);
4
+ setToken(token: string): void;
5
+ setStoreId(storeId: string): void;
6
+ getArticleRelatedToProduct(productId: string, fields: string[]): Promise<any>;
7
+ }
@@ -0,0 +1,43 @@
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.ContentApiService = void 0;
13
+ const queries_1 = require("../../graphql/content_api/queries");
14
+ const serviceSDK_1 = require("../serviceSDK");
15
+ class ContentApiService extends serviceSDK_1.Service {
16
+ constructor(endpoint, orgId, storeId) {
17
+ super(endpoint, orgId, storeId);
18
+ }
19
+ setToken(token) {
20
+ this.token = token;
21
+ }
22
+ setStoreId(storeId) {
23
+ this.storeId = storeId;
24
+ }
25
+ getArticleRelatedToProduct(productId, fields) {
26
+ return __awaiter(this, void 0, void 0, function* () {
27
+ const query = (0, queries_1.GET_ARTICLE_RELATED_TO_PRODUCT)(fields);
28
+ const variables = {
29
+ partnerId: this.orgId,
30
+ productId,
31
+ };
32
+ try {
33
+ const response = yield this.graphqlQuery(query, variables);
34
+ return response.getArticleRelatedToProduct;
35
+ }
36
+ catch (error) {
37
+ console.log(`Error fetching get getArticleRelatedToProduct method: ${error}`);
38
+ throw error;
39
+ }
40
+ });
41
+ }
42
+ }
43
+ exports.ContentApiService = ContentApiService;
@@ -53,4 +53,5 @@ export declare class ProductService extends Service {
53
53
  getCategories(): Promise<any>;
54
54
  getPriceMenus(categoryId: string, store: string): Promise<any>;
55
55
  getSimpleProductsDynamic(variables: any, storeId: string, fields: string[]): Promise<any>;
56
+ getProductRelatedToArticle(articleId: string, storeId: string, fields: string[]): Promise<any>;
56
57
  }
@@ -401,5 +401,23 @@ class ProductService extends serviceSDK_1.Service {
401
401
  }
402
402
  });
403
403
  }
404
+ getProductRelatedToArticle(articleId, storeId, fields) {
405
+ return __awaiter(this, void 0, void 0, function* () {
406
+ const query = (0, queries_1.GET_PRODUCT_RELATED_TO_ARTICLE)(fields);
407
+ const variablesHandle = {
408
+ partnerId: this.orgId,
409
+ storeId: storeId ? storeId : this.storeId,
410
+ articleId,
411
+ };
412
+ try {
413
+ const response = yield this.graphqlQuery(query, variablesHandle);
414
+ return response.getProductRelatedToArticle;
415
+ }
416
+ catch (error) {
417
+ console.log(`Error fetching getProductRelatedToArticle: ${error}`);
418
+ throw error;
419
+ }
420
+ });
421
+ }
404
422
  }
405
423
  exports.ProductService = ProductService;
@@ -37,4 +37,5 @@ export declare class StorageS3Service extends Service {
37
37
  actionSyncUserFromS3(s3UserId: string, updateBy: string, fields: string[]): Promise<any>;
38
38
  chartInYear(s3UserId: string, year: number, month: number, fields: string[]): Promise<any>;
39
39
  getIPConsul(userId: string): Promise<any>;
40
+ filterListObject(s3UserId: string, bucketId: string, maxKeys: number, key: string, prefixSearch: string, continuationToken: string, fields: string[]): Promise<any>;
40
41
  }
@@ -422,14 +422,14 @@ class StorageS3Service extends serviceSDK_1.Service {
422
422
  }
423
423
  addS3Domain(s3UserId, domain, byUser, fields) {
424
424
  return __awaiter(this, void 0, void 0, function* () {
425
- const query = (0, mutations_1.ADD_S3_DOMAIN)(fields);
425
+ const mutation = (0, mutations_1.ADD_S3_DOMAIN)(fields);
426
426
  const variables = {
427
427
  s3UserId,
428
428
  domain,
429
429
  byUser,
430
430
  };
431
431
  try {
432
- const response = yield this.graphqlQueryV2(query, variables);
432
+ const response = yield this.graphqlMutationV2(mutation, variables);
433
433
  return response.addS3Domain;
434
434
  }
435
435
  catch (error) {
@@ -440,14 +440,14 @@ class StorageS3Service extends serviceSDK_1.Service {
440
440
  }
441
441
  removeS3Domain(s3UserId, domainId, byUser, fields) {
442
442
  return __awaiter(this, void 0, void 0, function* () {
443
- const query = (0, mutations_1.REMOVE_S3_DOMAIN)(fields);
443
+ const mutation = (0, mutations_1.REMOVE_S3_DOMAIN)(fields);
444
444
  const variables = {
445
445
  s3UserId,
446
446
  domainId,
447
447
  byUser,
448
448
  };
449
449
  try {
450
- const response = yield this.graphqlQueryV2(query, variables);
450
+ const response = yield this.graphqlMutationV2(mutation, variables);
451
451
  return response.removeS3Domain;
452
452
  }
453
453
  catch (error) {
@@ -662,5 +662,26 @@ class StorageS3Service extends serviceSDK_1.Service {
662
662
  }
663
663
  });
664
664
  }
665
+ filterListObject(s3UserId, bucketId, maxKeys, key, prefixSearch, continuationToken, fields) {
666
+ return __awaiter(this, void 0, void 0, function* () {
667
+ const query = (0, queries_1.FILTER_LIST_OBJECT)(fields);
668
+ const variables = {
669
+ s3UserId,
670
+ bucketId,
671
+ maxKeys,
672
+ key,
673
+ prefixSearch,
674
+ continuationToken
675
+ };
676
+ try {
677
+ const response = yield this.graphqlQueryV2(query, variables);
678
+ return response.filterListObject;
679
+ }
680
+ catch (error) {
681
+ console.log(`Error in filterListObject: ${error}`);
682
+ throw error;
683
+ }
684
+ });
685
+ }
665
686
  }
666
687
  exports.StorageS3Service = StorageS3Service;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longvansoftware/service-js-client",
3
- "version": "2.2.1",
3
+ "version": "2.2.3",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "files": [