@longvansoftware/service-js-client 2.3.2 → 2.3.4

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,5 +8,6 @@ export declare const GET_PHONE_BY_PARTYID: DocumentNode;
8
8
  export declare const GET_EMAIL_BY_PARTYID: DocumentNode;
9
9
  export declare const GET_ACCESS_TOKEN_BY_OTP: DocumentNode;
10
10
  export declare const GET_PARTY_DETAIL_BY_PHONE: (fields?: string[]) => DocumentNode;
11
+ export declare const GET_PARTY_DETAIL_BY_CONTACT_INFO: (fields?: string[]) => DocumentNode;
11
12
  export declare const GET_ORGANIZATIONS_BY_PARTYID: (fields?: string[]) => DocumentNode;
12
13
  export declare const CHECK_ENABLED_2FA: (fields?: string[]) => DocumentNode;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CHECK_ENABLED_2FA = exports.GET_ORGANIZATIONS_BY_PARTYID = exports.GET_PARTY_DETAIL_BY_PHONE = exports.GET_ACCESS_TOKEN_BY_OTP = exports.GET_EMAIL_BY_PARTYID = exports.GET_PHONE_BY_PARTYID = exports.GET_USER_LOGIN_BY_PARTY_ID = exports.CHECK_USERNAME_EXISTED = exports.GET_USER_LOGIN_BY_USER_LOGIN_ID = exports.GET_USER_LOGIN_BY_TOKEN = exports.GET_USER_DETAIL = void 0;
3
+ exports.CHECK_ENABLED_2FA = exports.GET_ORGANIZATIONS_BY_PARTYID = exports.GET_PARTY_DETAIL_BY_CONTACT_INFO = exports.GET_PARTY_DETAIL_BY_PHONE = exports.GET_ACCESS_TOKEN_BY_OTP = exports.GET_EMAIL_BY_PARTYID = exports.GET_PHONE_BY_PARTYID = exports.GET_USER_LOGIN_BY_PARTY_ID = exports.CHECK_USERNAME_EXISTED = exports.GET_USER_LOGIN_BY_USER_LOGIN_ID = exports.GET_USER_LOGIN_BY_TOKEN = exports.GET_USER_DETAIL = void 0;
4
4
  const graphql_tag_1 = require("graphql-tag");
5
5
  exports.GET_USER_DETAIL = (0, graphql_tag_1.gql) `
6
6
  query GetUserDetail($orgId: String!, $accessToken: String!) {
@@ -98,6 +98,18 @@ const GET_PARTY_DETAIL_BY_PHONE = (fields = []) => {
98
98
  `;
99
99
  };
100
100
  exports.GET_PARTY_DETAIL_BY_PHONE = GET_PARTY_DETAIL_BY_PHONE;
101
+ const GET_PARTY_DETAIL_BY_CONTACT_INFO = (fields = []) => {
102
+ const fieldStr = fields.join("\n ");
103
+ const hasFields = fields.length > 0;
104
+ return (0, graphql_tag_1.gql) `
105
+ query GetPartyDetailByContactInfo($contactInfo: String!, $orgId: String!) {
106
+ getPartyDetailByContactInfo(contactInfo: $contactInfo, orgId: $orgId) {
107
+ ${hasFields ? `${fieldStr}` : ""}
108
+ }
109
+ }
110
+ `;
111
+ };
112
+ exports.GET_PARTY_DETAIL_BY_CONTACT_INFO = GET_PARTY_DETAIL_BY_CONTACT_INFO;
101
113
  const GET_ORGANIZATIONS_BY_PARTYID = (fields = []) => {
102
114
  const fieldStr = fields.join("\n ");
103
115
  const hasFields = fields.length > 0;
@@ -512,7 +512,6 @@ const UPDATE_CORS_BUCKET = (fields = []) => {
512
512
  const hasFields = fields.length > 0;
513
513
  return (0, graphql_tag_1.gql) `
514
514
  mutation UpdateCorsBucket(
515
- $s3UserId: String!,
516
515
  $bucketId: String!,
517
516
  $allowedMethods: [String],
518
517
  $allowedOrigins: [String],
@@ -524,7 +523,6 @@ const UPDATE_CORS_BUCKET = (fields = []) => {
524
523
  $serviceId: String!
525
524
  ) {
526
525
  updateCorsBucket(
527
- s3UserId: $s3UserId,
528
526
  bucketId: $bucketId,
529
527
  allowedMethods: $allowedMethods,
530
528
  allowedOrigins: $allowedOrigins,
@@ -45,6 +45,7 @@ export declare class AuthService extends Service {
45
45
  getPhoneByPartyId(partyId: string): Promise<any>;
46
46
  getEmailByPartyId(partyId: string): Promise<any>;
47
47
  getPartyDetailByPhone(phone: string, fields: string[]): Promise<any>;
48
+ getPartyDetailByContactInfo(contactInfo: string, fields: string[]): Promise<any>;
48
49
  createPartyDetail(name: string, phone: string, createdBy: string, source: string, fields: string[]): Promise<any>;
49
50
  getOrganizationsByPartyIdDynamic(partyId: string, fields: string[]): Promise<any>;
50
51
  checkEnabled2FA(partyId: string, fields: string[]): Promise<any>;
@@ -408,6 +408,23 @@ class AuthService extends serviceSDK_1.Service {
408
408
  }
409
409
  });
410
410
  }
411
+ getPartyDetailByContactInfo(contactInfo, fields) {
412
+ return __awaiter(this, void 0, void 0, function* () {
413
+ const query = (0, queries_1.GET_PARTY_DETAIL_BY_CONTACT_INFO)(fields);
414
+ const variables = {
415
+ contactInfo,
416
+ orgId: this.orgId,
417
+ };
418
+ try {
419
+ const response = yield this.graphqlQuery(query, variables);
420
+ return response.getPartyDetailByContactInfo;
421
+ }
422
+ catch (error) {
423
+ console.log(`Error in getPartyDetailByContactInfo: ${error}`);
424
+ throw error;
425
+ }
426
+ });
427
+ }
411
428
  createPartyDetail(name, phone, createdBy, source, fields) {
412
429
  return __awaiter(this, void 0, void 0, function* () {
413
430
  const mutation = (0, mutations_1.CREATE_PARTY_DETAIL)(fields);
@@ -29,7 +29,7 @@ export declare class StorageS3Service extends Service {
29
29
  removeS3Domain(s3UserId: string, domainId: string, byUser: string, serviceId: string, fields: string[]): Promise<any>;
30
30
  getListCorsByS3UserId(s3UserId: string, bucketId: string, serviceId: string, fields: string[]): Promise<any>;
31
31
  addCorsBucket(s3UserId: string, bucketId: string, allowedMethods: string[], allowedOrigins: string[], allowedHeaders: string[], exposeHeaders: string[], maxAgeSeconds: number, updateBy: string, serviceId: string, fields: string[]): Promise<any>;
32
- updateCorsBucket(s3UserId: string, bucketId: string, corsId: string, allowedMethods: string[], allowedOrigins: string[], allowedHeaders: string[], exposeHeaders: string[], maxAgeSeconds: number, updateBy: string, serviceId: string, fields: string[]): Promise<any>;
32
+ updateCorsBucket(bucketId: string, corsId: string, allowedMethods: string[], allowedOrigins: string[], allowedHeaders: string[], exposeHeaders: string[], maxAgeSeconds: number, updateBy: string, serviceId: string, fields: string[]): Promise<any>;
33
33
  removeCorsBucket(bucketId: string, corsId: string, updateBy: string, serviceId: string, fields: string[]): Promise<any>;
34
34
  getListFileOtherVersion(s3UserId: string, bucketId: string, key: string, serviceId: string, fields: string[]): Promise<any>;
35
35
  restoreFileOtherVersion(s3UserId: string, bucketId: string, key: string, versionId: string, serviceId: string, fields: string[]): Promise<any>;
@@ -536,11 +536,10 @@ class StorageS3Service extends serviceSDK_1.Service {
536
536
  }
537
537
  });
538
538
  }
539
- updateCorsBucket(s3UserId, bucketId, corsId, allowedMethods, allowedOrigins, allowedHeaders, exposeHeaders, maxAgeSeconds, updateBy, serviceId, fields) {
539
+ updateCorsBucket(bucketId, corsId, allowedMethods, allowedOrigins, allowedHeaders, exposeHeaders, maxAgeSeconds, updateBy, serviceId, fields) {
540
540
  return __awaiter(this, void 0, void 0, function* () {
541
541
  const mutation = (0, mutations_1.UPDATE_CORS_BUCKET)(fields);
542
542
  const variables = {
543
- s3UserId,
544
543
  bucketId,
545
544
  corsId,
546
545
  allowedMethods,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longvansoftware/service-js-client",
3
- "version": "2.3.2",
3
+ "version": "2.3.4",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "files": [
@@ -1,14 +0,0 @@
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
- }
@@ -1,101 +0,0 @@
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;
@@ -1 +0,0 @@
1
- export declare function buildFieldString(fields: (string | Record<string, any>)[], indent?: number): string;
@@ -1,16 +0,0 @@
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;