@longvansoftware/service-js-client 2.2.3 → 2.2.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.
@@ -16,3 +16,4 @@ export declare const GET_COLLEGES_BY_PROVINCE_ID: DocumentNode;
16
16
  export declare const GET_RELATED_RESOURCE_BY_RESOURCE_TYPE: DocumentNode;
17
17
  export declare const GET_RESUME_INFO_BY_CUSTOMER_ID: DocumentNode;
18
18
  export declare const GET_RESUME_INFO_BY_CUSTOMER_ID_DYNAMIC: (fields?: string[]) => DocumentNode;
19
+ export declare const GET_LIST_TICKET_BY_OWNER_DYNAMIC: (fields?: string[]) => DocumentNode;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GET_RESUME_INFO_BY_CUSTOMER_ID_DYNAMIC = exports.GET_RESUME_INFO_BY_CUSTOMER_ID = exports.GET_RELATED_RESOURCE_BY_RESOURCE_TYPE = exports.GET_COLLEGES_BY_PROVINCE_ID = exports.GET_RESUME_DOMAIN_BY_SERVICE_ID = exports.GET_REUSME_BY_CUSTOMER_ID = exports.GET_RESUME_CONTACT = exports.GET_RESUME_ID_BY_RESOURCE = exports.GET_LIST_COMMENT = exports.GET_ATTACHMENT_BY_WORK_EFFORT_ID = exports.GET_LIST_TICKET_BY_ID_DYNAMIC = exports.GET_TICKET_BY_ID = exports.GET_LIST_TICKET_DYNAMIC = exports.GET_LIST_TICKET = exports.GET_LIST_WORK_EFFORT_TYPE = exports.GET_LIST_TODO = exports.GET_LIST_OPPORTUNITY_QUERY = void 0;
3
+ exports.GET_LIST_TICKET_BY_OWNER_DYNAMIC = exports.GET_RESUME_INFO_BY_CUSTOMER_ID_DYNAMIC = exports.GET_RESUME_INFO_BY_CUSTOMER_ID = exports.GET_RELATED_RESOURCE_BY_RESOURCE_TYPE = exports.GET_COLLEGES_BY_PROVINCE_ID = exports.GET_RESUME_DOMAIN_BY_SERVICE_ID = exports.GET_REUSME_BY_CUSTOMER_ID = exports.GET_RESUME_CONTACT = exports.GET_RESUME_ID_BY_RESOURCE = exports.GET_LIST_COMMENT = exports.GET_ATTACHMENT_BY_WORK_EFFORT_ID = exports.GET_LIST_TICKET_BY_ID_DYNAMIC = exports.GET_TICKET_BY_ID = exports.GET_LIST_TICKET_DYNAMIC = exports.GET_LIST_TICKET = exports.GET_LIST_WORK_EFFORT_TYPE = exports.GET_LIST_TODO = exports.GET_LIST_OPPORTUNITY_QUERY = void 0;
4
4
  const graphql_tag_1 = require("graphql-tag");
5
5
  exports.GET_LIST_OPPORTUNITY_QUERY = (0, graphql_tag_1.gql) `
6
6
  query GetListOpportunity(
@@ -455,3 +455,27 @@ const GET_RESUME_INFO_BY_CUSTOMER_ID_DYNAMIC = (fields = []) => {
455
455
  `;
456
456
  };
457
457
  exports.GET_RESUME_INFO_BY_CUSTOMER_ID_DYNAMIC = GET_RESUME_INFO_BY_CUSTOMER_ID_DYNAMIC;
458
+ const GET_LIST_TICKET_BY_OWNER_DYNAMIC = (fields = []) => {
459
+ const fieldStr = fields.join("\n ");
460
+ const hasFields = fields.length > 0;
461
+ return (0, graphql_tag_1.gql) `
462
+ query getListTicketByOwner(
463
+ $partyId: String!
464
+ $ownerId: String!
465
+ $getTicketRequest: GetTicketRequest!
466
+ ) {
467
+ getListTicketByOwner(
468
+ partyId: $partyId
469
+ ownerId: $ownerId
470
+ getTicketRequest: $getTicketRequest
471
+ )
472
+ {
473
+ total
474
+ data {
475
+ ${hasFields ? `${fieldStr}` : ""}
476
+ }
477
+ }
478
+ }
479
+ `;
480
+ };
481
+ exports.GET_LIST_TICKET_BY_OWNER_DYNAMIC = GET_LIST_TICKET_BY_OWNER_DYNAMIC;
@@ -1,5 +1,6 @@
1
1
  import { DocumentNode } from 'graphql';
2
2
  export declare const GET_LIST_S3_USER_BY_SERVICE_ID: (fields?: string[]) => DocumentNode;
3
+ export declare const GET_LIST_S3_USER_ACTIVE_BY_SERVICE_ID: (fields?: string[]) => DocumentNode;
3
4
  export declare const GET_LIST_BUCKET_BY_S3_USER_ID: (fields?: string[]) => DocumentNode;
4
5
  export declare const GET_LIST_OBJECT: (fields?: string[]) => DocumentNode;
5
6
  export declare const GET_LIST_FILE_TRASH: (fields?: string[]) => DocumentNode;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
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;
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_ACTIVE_BY_SERVICE_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 ');
@@ -14,6 +14,18 @@ const GET_LIST_S3_USER_BY_SERVICE_ID = (fields = []) => {
14
14
  `;
15
15
  };
16
16
  exports.GET_LIST_S3_USER_BY_SERVICE_ID = GET_LIST_S3_USER_BY_SERVICE_ID;
17
+ const GET_LIST_S3_USER_ACTIVE_BY_SERVICE_ID = (fields = []) => {
18
+ const fieldStr = fields.join('\n ');
19
+ const hasFields = fields.length > 0;
20
+ return (0, graphql_tag_1.gql) `
21
+ query GetListS3UserActiveByServiceId($serviceId: String!) {
22
+ getListS3UserActiveByServiceId(serviceId: $serviceId) {
23
+ ${hasFields ? `${fieldStr}` : ''}
24
+ }
25
+ }
26
+ `;
27
+ };
28
+ exports.GET_LIST_S3_USER_ACTIVE_BY_SERVICE_ID = GET_LIST_S3_USER_ACTIVE_BY_SERVICE_ID;
17
29
  const GET_LIST_BUCKET_BY_S3_USER_ID = (fields = []) => {
18
30
  const fieldStr = fields.join('\n ');
19
31
  const hasFields = fields.length > 0;
@@ -37,4 +37,5 @@ export declare class CrmService extends Service {
37
37
  getResumeInfoByCustomerIdDynamic(customerId: string, fields: string[]): Promise<any>;
38
38
  createResumeInfo(data: any): Promise<any>;
39
39
  updateFieldResume(resumeId: string, fieldName: string, value: string, resourceType: string, updatedBy: string): Promise<any>;
40
+ getListTicketByOwnerDynamic(ownerId: string, getTicketRequest: getTicketRequest, fields: string[]): Promise<any>;
40
41
  }
@@ -616,5 +616,23 @@ class CrmService extends serviceSDK_1.Service {
616
616
  }
617
617
  });
618
618
  }
619
+ getListTicketByOwnerDynamic(ownerId, getTicketRequest, fields) {
620
+ return __awaiter(this, void 0, void 0, function* () {
621
+ const query = (0, queries_1.GET_LIST_TICKET_BY_OWNER_DYNAMIC)(fields);
622
+ const variables = {
623
+ partyId: this.orgId,
624
+ ownerId,
625
+ getTicketRequest,
626
+ };
627
+ try {
628
+ const response = yield this.graphqlQueryV2(query, variables);
629
+ return response.getListTicketByOwner;
630
+ }
631
+ catch (error) {
632
+ console.log(`Error fetching get getListTicketByOwnerDynamic method: ${error}`);
633
+ throw error;
634
+ }
635
+ });
636
+ }
619
637
  }
620
638
  exports.CrmService = CrmService;
@@ -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;
@@ -3,6 +3,7 @@ import { Service } from '../serviceSDK';
3
3
  export declare class StorageS3Service extends Service {
4
4
  constructor(endpoint: string, orgId: string, storeId: string);
5
5
  getListS3UserByServiceId(serviceId: string, fields: string[]): Promise<any>;
6
+ getListS3UserActiveByServiceId(serviceId: string, fields: string[]): Promise<any>;
6
7
  getListBucketByS3UserId(s3UserId: string, fields: string[]): Promise<any>;
7
8
  getListObject(s3UserId: string, bucketId: string, key: string, fields: string[]): Promise<any>;
8
9
  uploadFolder(userId: string, bucketId: string, fileInfo: [FileInfoInput], basePrefix: string, fields: string[]): Promise<any>;
@@ -33,6 +33,22 @@ class StorageS3Service extends serviceSDK_1.Service {
33
33
  }
34
34
  });
35
35
  }
36
+ getListS3UserActiveByServiceId(serviceId, fields) {
37
+ return __awaiter(this, void 0, void 0, function* () {
38
+ const query = (0, queries_1.GET_LIST_S3_USER_ACTIVE_BY_SERVICE_ID)(fields);
39
+ const variables = {
40
+ serviceId,
41
+ };
42
+ try {
43
+ const response = yield this.graphqlQueryV2(query, variables);
44
+ return response.getListS3UserActiveByServiceId;
45
+ }
46
+ catch (error) {
47
+ console.log(`Error in getListS3UserActiveByServiceId: ${error}`);
48
+ throw error;
49
+ }
50
+ });
51
+ }
36
52
  getListBucketByS3UserId(s3UserId, fields) {
37
53
  return __awaiter(this, void 0, void 0, function* () {
38
54
  const query = (0, queries_1.GET_LIST_BUCKET_BY_S3_USER_ID)(fields);
@@ -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.2.3",
3
+ "version": "2.2.5",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "files": [