@longvansoftware/service-js-client 1.15.7 → 1.15.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.
Files changed (93) hide show
  1. package/README.md +93 -93
  2. package/dist/src/graphql/accounting_service/mutations.js +96 -96
  3. package/dist/src/graphql/accounting_service/queries.js +57 -57
  4. package/dist/src/graphql/auth/mutations.js +235 -235
  5. package/dist/src/graphql/auth/queries.js +68 -68
  6. package/dist/src/graphql/campaign/mutations.d.ts +1 -0
  7. package/dist/src/graphql/campaign/mutations.js +34 -0
  8. package/dist/src/graphql/campaign/queries.d.ts +9 -0
  9. package/dist/src/graphql/campaign/queries.js +412 -0
  10. package/dist/src/graphql/cashbook/queries.d.ts +2 -0
  11. package/dist/src/graphql/cashbook/queries.js +99 -0
  12. package/dist/src/graphql/cloud/mutations.d.ts +4 -0
  13. package/dist/src/graphql/cloud/mutations.js +287 -241
  14. package/dist/src/graphql/cloud/queries.js +341 -341
  15. package/dist/src/graphql/computing/mutations.js +303 -303
  16. package/dist/src/graphql/computing/queries.js +548 -548
  17. package/dist/src/graphql/crm/mutations.d.ts +1 -0
  18. package/dist/src/graphql/crm/mutations.js +392 -375
  19. package/dist/src/graphql/crm/queries.d.ts +1 -0
  20. package/dist/src/graphql/crm/queries.js +359 -332
  21. package/dist/src/graphql/crm_camping/mutations.js +32 -32
  22. package/dist/src/graphql/crm_camping/queries.js +198 -198
  23. package/dist/src/graphql/orderGraphQL/mutations.js +351 -351
  24. package/dist/src/graphql/orderGraphQL/queries.js +387 -387
  25. package/dist/src/graphql/payment/mutations.js +45 -45
  26. package/dist/src/graphql/payment/queries.js +60 -60
  27. package/dist/src/graphql/paymentLV/mutations.js +19 -19
  28. package/dist/src/graphql/paymentLV/queries.js +75 -75
  29. package/dist/src/graphql/paymentV2/mutations.d.ts +3 -0
  30. package/dist/src/graphql/paymentV2/mutations.js +54 -0
  31. package/dist/src/graphql/paymentV2/queries.d.ts +6 -0
  32. package/dist/src/graphql/paymentV2/queries.js +186 -0
  33. package/dist/src/graphql/product/queries.js +891 -891
  34. package/dist/src/graphql/quicklab_service/mutations.js +154 -154
  35. package/dist/src/graphql/quicklab_service/queries.js +108 -108
  36. package/dist/src/graphql/resource_permission/mutations.js +57 -57
  37. package/dist/src/graphql/resource_permission/queries.js +13 -13
  38. package/dist/src/graphql/service/mutations.js +228 -228
  39. package/dist/src/graphql/service/queries.js +128 -128
  40. package/dist/src/graphql/store/mutations.d.ts +1 -0
  41. package/dist/src/graphql/store/mutations.js +29 -0
  42. package/dist/src/graphql/store/queries.d.ts +1 -0
  43. package/dist/src/graphql/store/queries.js +29 -0
  44. package/dist/src/graphql/user/mutations.js +214 -214
  45. package/dist/src/graphql/user/queries.js +312 -312
  46. package/dist/src/lib/accounting/index.d.ts +5 -0
  47. package/dist/src/lib/accounting/index.js +32 -0
  48. package/dist/src/lib/campaign/index.d.ts +20 -0
  49. package/dist/src/lib/campaign/index.js +213 -0
  50. package/dist/src/lib/cashbook/index.d.ts +6 -0
  51. package/dist/src/lib/cashbook/index.js +56 -0
  52. package/dist/src/lib/cloud/index.d.ts +4 -0
  53. package/dist/src/lib/cloud/index.js +69 -0
  54. package/dist/src/lib/comhub/index.d.ts +6 -0
  55. package/dist/src/lib/comhub/index.js +50 -0
  56. package/dist/src/lib/crm/index.d.ts +2 -0
  57. package/dist/src/lib/crm/index.js +40 -0
  58. package/dist/src/lib/deepLinkVietQr/index.d.ts +6 -0
  59. package/dist/src/lib/deepLinkVietQr/index.js +45 -0
  60. package/dist/src/lib/getImage/index.d.ts +4 -0
  61. package/dist/src/lib/getImage/index.js +10 -0
  62. package/dist/src/lib/image/index.d.ts +7 -0
  63. package/dist/src/lib/image/index.js +49 -0
  64. package/dist/src/lib/omnigateway/index.d.ts +7 -0
  65. package/dist/src/lib/omnigateway/index.js +58 -0
  66. package/dist/src/lib/paymentV2/index.d.ts +13 -0
  67. package/dist/src/lib/paymentV2/index.js +163 -0
  68. package/dist/src/lib/portal/index.d.ts +21 -0
  69. package/dist/src/lib/portal/index.js +225 -0
  70. package/dist/src/lib/serviceSDK.js +12 -12
  71. package/dist/src/lib/store/index.d.ts +30 -0
  72. package/dist/src/lib/store/index.js +74 -0
  73. package/dist/src/lib/token/index.d.ts +5 -0
  74. package/dist/src/lib/token/index.js +32 -0
  75. package/dist/src/lib/upload/index.d.ts +5 -0
  76. package/dist/src/lib/upload/index.js +35 -0
  77. package/dist/src/lib/warehouseV2/index.d.ts +13 -0
  78. package/dist/src/lib/warehouseV2/index.js +54 -0
  79. package/dist/src/lib/zca/index.d.ts +12 -0
  80. package/dist/src/lib/zca/index.js +41 -0
  81. package/dist/src/types/campaign.d.ts +14 -0
  82. package/dist/src/types/campaign.js +2 -0
  83. package/dist/src/types/invoice.d.ts +13 -0
  84. package/dist/src/types/invoice.js +2 -0
  85. package/dist/src/types/store.d.ts +158 -0
  86. package/dist/src/types/store.js +3 -0
  87. package/dist/src/utils/validatePhoneNumber.d.ts +1 -0
  88. package/dist/src/utils/validatePhoneNumber.js +20 -0
  89. package/package.json +44 -43
  90. package/dist/src/lib/service.d.ts +0 -14
  91. package/dist/src/lib/service.js +0 -101
  92. package/dist/src/utils/build-field-string.d.ts +0 -1
  93. package/dist/src/utils/build-field-string.js +0 -16
@@ -0,0 +1,32 @@
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.AuthorizationService = void 0;
13
+ const serviceSDK_1 = require("../serviceSDK");
14
+ class AuthorizationService extends serviceSDK_1.Service {
15
+ constructor(endpoint, orgId, storeId) {
16
+ super(endpoint, orgId, storeId);
17
+ }
18
+ checkToken(orgId, token) {
19
+ return __awaiter(this, void 0, void 0, function* () {
20
+ const endpoint = `/${orgId}/oauth2/api/v1/token/${token}`;
21
+ const method = "GET";
22
+ try {
23
+ const response = yield this.restApiCallWithNoHeader(endpoint, method);
24
+ return response;
25
+ }
26
+ catch (error) {
27
+ throw error;
28
+ }
29
+ });
30
+ }
31
+ }
32
+ exports.AuthorizationService = AuthorizationService;
@@ -0,0 +1,5 @@
1
+ import { Service } from "../serviceSDK";
2
+ export declare class UploadService extends Service {
3
+ constructor(endpoint: string, orgId: string, storeId: string);
4
+ uploadImage(imageCode: string): Promise<any>;
5
+ }
@@ -0,0 +1,35 @@
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.UploadService = void 0;
13
+ const serviceSDK_1 = require("../serviceSDK");
14
+ class UploadService extends serviceSDK_1.Service {
15
+ constructor(endpoint, orgId, storeId) {
16
+ super(endpoint, orgId, storeId);
17
+ }
18
+ uploadImage(imageCode) {
19
+ return __awaiter(this, void 0, void 0, function* () {
20
+ const endpoint = "";
21
+ const method = "POST";
22
+ try {
23
+ const formData = new FormData();
24
+ formData.append("uploadFile", imageCode);
25
+ formData.append("path", "public");
26
+ const response = yield this.restApiCallWithNoHeader(endpoint, method, formData);
27
+ return response;
28
+ }
29
+ catch (error) {
30
+ throw error;
31
+ }
32
+ });
33
+ }
34
+ }
35
+ exports.UploadService = UploadService;
@@ -0,0 +1,13 @@
1
+ import { Service } from "../serviceSDK";
2
+ export declare class WarehouseServiceV2 extends Service {
3
+ /**
4
+ * Constructs a new OrderService instance.
5
+ * @param endpoint - The endpoint URL for the service.
6
+ * @param orgId - The organization ID.
7
+ * @param storeId - The store ID.
8
+ */
9
+ constructor(endpoint: string, orgId: string, storeId: string);
10
+ setToken(token: string): void;
11
+ getInventory(warehouseId: string, data: any[]): Promise<any>;
12
+ getInfoWarehouse(warehouseId: string): Promise<any>;
13
+ }
@@ -0,0 +1,54 @@
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.WarehouseServiceV2 = void 0;
13
+ const serviceSDK_1 = require("../serviceSDK");
14
+ class WarehouseServiceV2 extends serviceSDK_1.Service {
15
+ /**
16
+ * Constructs a new OrderService instance.
17
+ * @param endpoint - The endpoint URL for the service.
18
+ * @param orgId - The organization ID.
19
+ * @param storeId - The store ID.
20
+ */
21
+ constructor(endpoint, orgId, storeId) {
22
+ super(endpoint, orgId, storeId);
23
+ }
24
+ setToken(token) {
25
+ this.token = token;
26
+ }
27
+ getInventory(warehouseId, data) {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ const endpoint = `/public-facility/1.0.0/product-inventory-v3/${warehouseId}`;
30
+ const method = "POST";
31
+ try {
32
+ const response = yield this.restApiCallWithNoToken(endpoint, method, data);
33
+ return response;
34
+ }
35
+ catch (error) {
36
+ throw error;
37
+ }
38
+ });
39
+ }
40
+ getInfoWarehouse(warehouseId) {
41
+ return __awaiter(this, void 0, void 0, function* () {
42
+ try {
43
+ const endpoint = `/facility/1.0.0/facility/${warehouseId}`;
44
+ const method = "GET";
45
+ const response = yield this.restApiCallWithNoToken(endpoint, method);
46
+ return response;
47
+ }
48
+ catch (error) {
49
+ throw error;
50
+ }
51
+ });
52
+ }
53
+ }
54
+ exports.WarehouseServiceV2 = WarehouseServiceV2;
@@ -0,0 +1,12 @@
1
+ import { Service } from "../serviceSDK";
2
+ export declare class ZcaService extends Service {
3
+ /**
4
+ * Constructs a new OrderService instance.
5
+ * @param endpoint - The endpoint URL for the service.
6
+ * @param orgId - The organization ID.
7
+ * @param storeId - The store ID.
8
+ */
9
+ constructor(endpoint: string, orgId: string, storeId: string);
10
+ setToken(token: string): void;
11
+ loginQR(sessionId: string, appId: string): Promise<any>;
12
+ }
@@ -0,0 +1,41 @@
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.ZcaService = void 0;
13
+ const serviceSDK_1 = require("../serviceSDK");
14
+ class ZcaService extends serviceSDK_1.Service {
15
+ /**
16
+ * Constructs a new OrderService instance.
17
+ * @param endpoint - The endpoint URL for the service.
18
+ * @param orgId - The organization ID.
19
+ * @param storeId - The store ID.
20
+ */
21
+ constructor(endpoint, orgId, storeId) {
22
+ super(endpoint, orgId, storeId);
23
+ }
24
+ setToken(token) {
25
+ this.token = token;
26
+ }
27
+ loginQR(sessionId, appId) {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ const endpoint = `/login?sessionId=${sessionId}&orgId=${this.orgId}&storeId=${this.storeId}&appId=${appId}`;
30
+ const method = "GET";
31
+ try {
32
+ const response = yield this.restApiCallWithNoHeader(endpoint, method);
33
+ return response;
34
+ }
35
+ catch (error) {
36
+ throw error;
37
+ }
38
+ });
39
+ }
40
+ }
41
+ exports.ZcaService = ZcaService;
@@ -0,0 +1,14 @@
1
+ export interface SearchVoucherRequest {
2
+ partyId: String;
3
+ voucherCodes: [String];
4
+ voucherCode: String;
5
+ voucherType: String;
6
+ campaignId: String;
7
+ campaignActionId: String;
8
+ customerId: String;
9
+ campaignActionType: String;
10
+ isBirthday: Boolean;
11
+ isPageAble: Boolean;
12
+ pageNumber: number;
13
+ pageSize: number;
14
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,13 @@
1
+ export interface VatInvoiceRequestDTO {
2
+ sourceId: String;
3
+ sourceType: String;
4
+ signType: String;
5
+ includeBuyerTaxCode: Boolean;
6
+ buyerName: String;
7
+ buyerTaxCode: String;
8
+ buyerCompany: String;
9
+ buyerAddress: String;
10
+ sendMail: Boolean;
11
+ receiverName: String;
12
+ receiverEmail: String;
13
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,158 @@
1
+ /**
2
+ * Store Data Transfer Object
3
+ * Represents a store/channel in the system
4
+ */
5
+ export interface StoreDTO {
6
+ /** Unique identifier for the store */
7
+ id: string;
8
+ /** Timestamp when the store was created */
9
+ createdStamp: string | null;
10
+ /** Display name of the store */
11
+ name: string;
12
+ /** Type of store (pos, ecommerce, etc.) */
13
+ type: 'pos' | 'ecommerce' | 'marketplace' | 'wholesale' | string;
14
+ /** Whether the store is enabled/active */
15
+ enable: boolean;
16
+ /** Party/Organization ID that owns this store */
17
+ partyId: string;
18
+ /** Array of warehouse IDs associated with this store */
19
+ warehouses: string[];
20
+ /** Default warehouse ID for this store */
21
+ warehouseIdDefault: string;
22
+ /** Whether future orders are allowed */
23
+ enableOrderAbleFuture: boolean;
24
+ /** Whether negative quantity orders are allowed */
25
+ enableOrderNegativeQuantity: boolean;
26
+ /** E-commerce specific store name */
27
+ storeEcommerceName: string | null;
28
+ /** Array of shipping company IDs */
29
+ shippingCompanies: string[];
30
+ /** Primary shipping company ID */
31
+ shippingCompanyIdPrimary: string;
32
+ /** Primary customer ID */
33
+ customerIdPrimary: string;
34
+ /** Primary payment method ID */
35
+ paymentMethodIdPrimary: string;
36
+ /** Whether custom product pricing is enabled */
37
+ enableCustomProductPrice: boolean;
38
+ /** Whether partial payments are enabled */
39
+ enablePaymentPartial: boolean;
40
+ /** Array of allowed partial payment percentages */
41
+ paymentPartialPercent: number[];
42
+ /** Link to the product store (for e-commerce) */
43
+ productStoreLink: string | null;
44
+ /** GraphQL typename */
45
+ __typename?: string;
46
+ }
47
+ /**
48
+ * Request interface for creating a new store
49
+ */
50
+ export interface CreateStoreRequest {
51
+ /** Partner/Organization ID */
52
+ partnerId: string;
53
+ /** Name for the new store */
54
+ storeName: string;
55
+ /** Optional store type */
56
+ type?: 'pos' | 'ecommerce' | 'marketplace' | 'wholesale';
57
+ /** Optional configuration */
58
+ config?: Partial<StoreConfiguration>;
59
+ }
60
+ /**
61
+ * Store configuration options
62
+ */
63
+ export interface StoreConfiguration {
64
+ /** Whether the store should be enabled by default */
65
+ enable: boolean;
66
+ /** Warehouse IDs to associate with the store */
67
+ warehouses: string[];
68
+ /** Default warehouse ID */
69
+ warehouseIdDefault: string;
70
+ /** Whether to enable future orders */
71
+ enableOrderAbleFuture: boolean;
72
+ /** Whether to enable negative quantity orders */
73
+ enableOrderNegativeQuantity: boolean;
74
+ /** E-commerce store name */
75
+ storeEcommerceName: string;
76
+ /** Shipping company IDs */
77
+ shippingCompanies: string[];
78
+ /** Primary shipping company ID */
79
+ shippingCompanyIdPrimary: string;
80
+ /** Primary customer ID */
81
+ customerIdPrimary: string;
82
+ /** Primary payment method ID */
83
+ paymentMethodIdPrimary: string;
84
+ /** Enable custom product pricing */
85
+ enableCustomProductPrice: boolean;
86
+ /** Enable partial payments */
87
+ enablePaymentPartial: boolean;
88
+ /** Partial payment percentages */
89
+ paymentPartialPercent: number[];
90
+ /** Product store link */
91
+ productStoreLink: string;
92
+ }
93
+ /**
94
+ * Request interface for getting store channels by employee ID
95
+ */
96
+ export interface GetStoreChannelRequest {
97
+ /** Employee/Sale ID */
98
+ saleId: string;
99
+ /** Optional filter by store type */
100
+ type?: 'pos' | 'ecommerce' | 'marketplace' | 'wholesale';
101
+ /** Optional filter by enabled status */
102
+ enabledOnly?: boolean;
103
+ }
104
+ /**
105
+ * Response interface for store channel queries
106
+ */
107
+ export interface StoreChannelResponse {
108
+ /** Array of accessible stores */
109
+ stores: StoreDTO[];
110
+ /** Total count of stores */
111
+ totalCount: number;
112
+ /** Whether user has admin permissions (can see all stores) */
113
+ hasAdminAccess: boolean;
114
+ }
115
+ /**
116
+ * Store filter options for querying stores
117
+ */
118
+ export interface StoreFilterOptions {
119
+ /** Filter by store type */
120
+ type?: 'pos' | 'ecommerce' | 'marketplace' | 'wholesale' | string;
121
+ /** Filter by enabled status */
122
+ enabled?: boolean;
123
+ /** Filter by party/organization ID */
124
+ partyId?: string;
125
+ /** Search by store name */
126
+ searchName?: string;
127
+ /** Pagination - current page */
128
+ currentPage?: number;
129
+ /** Pagination - max results per page */
130
+ maxResult?: number;
131
+ }
132
+ /**
133
+ * Store statistics interface
134
+ */
135
+ export interface StoreStats {
136
+ /** Total number of stores */
137
+ totalStores: number;
138
+ /** Number of active stores */
139
+ activeStores: number;
140
+ /** Number of inactive stores */
141
+ inactiveStores: number;
142
+ /** Breakdown by store type */
143
+ byType: {
144
+ pos: number;
145
+ ecommerce: number;
146
+ marketplace: number;
147
+ wholesale: number;
148
+ other: number;
149
+ };
150
+ }
151
+ /**
152
+ * Store service method return types
153
+ */
154
+ export interface StoreServiceMethods {
155
+ createStore: (partnerId: string, storeName: string) => Promise<StoreDTO>;
156
+ getStoreChannelByEmpId: (saleId: string) => Promise<StoreDTO[]>;
157
+ }
158
+ export type { StoreDTO as Store, };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // src/types/store.ts
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export declare function validatePhoneNumber(phoneNumber: string): boolean;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validatePhoneNumber = void 0;
4
+ function validatePhoneNumber(phoneNumber) {
5
+ var _a;
6
+ const urlParams = new URLSearchParams(window.location.search);
7
+ const country = ((_a = urlParams.get("country")) === null || _a === void 0 ? void 0 : _a.trim()) || "default";
8
+ const pattern = (() => {
9
+ switch (country) {
10
+ case "vietnam":
11
+ return /^(0?)(3[2-9]|5[6|8|9]|7[0|6-9]|8[0-6|8|9]|9[0-4|6-9])[0-9]{7}$/;
12
+ case "quocte":
13
+ return /^(\+|00)[1-9][0-9]{1,3}[0-9]{4,14}$/;
14
+ default:
15
+ return /^(0?)(3[2-9]|5[6|8|9]|7[0|6-9]|8[0-6|8|9]|9[0-4|6-9])[0-9]{7}$|^(\+|00)[1-9][0-9]{1,3}[0-9]{4,14}$/;
16
+ }
17
+ })();
18
+ return pattern.test(phoneNumber);
19
+ }
20
+ exports.validatePhoneNumber = validatePhoneNumber;
package/package.json CHANGED
@@ -1,43 +1,44 @@
1
- {
2
- "name": "@longvansoftware/service-js-client",
3
- "version": "1.15.7",
4
- "main": "dist/src/index.js",
5
- "types": "dist/src/index.d.ts",
6
- "files": [
7
- "dist/**/*.d.ts",
8
- "dist/**/*.js"
9
- ],
10
- "directories": {
11
- "test": "jest"
12
- },
13
- "scripts": {
14
- "test": "jest",
15
- "build": "tsc",
16
- "publish": "npm run build && npm publish"
17
- },
18
- "keywords": [],
19
- "author": "",
20
- "license": "ISC",
21
- "dependencies": {
22
- "@apollo/client": "3.9.11",
23
- "apollo-boost": "^0.4.9",
24
- "axios": "^1.6.8",
25
- "cross-fetch": "^4.0.0",
26
- "crypto-js": "^4.2.0",
27
- "graphql": "^15.8.0",
28
- "graphql-request": "^6.1.0",
29
- "graphql-tag": "^2.12.6",
30
- "react": "^18.2.0",
31
- "ts-node": "^10.9.2"
32
- },
33
- "devDependencies": {
34
- "@types/axios": "^0.14.0",
35
- "@types/crypto-js": "^4.2.2",
36
- "@types/jest": "^29.5.12",
37
- "@types/node": "^20.12.7",
38
- "jest": "^29.7.0",
39
- "ts-jest": "^29.1.2",
40
- "typescript": "^5.4.5"
41
- },
42
- "description": ""
43
- }
1
+ {
2
+ "name": "@longvansoftware/service-js-client",
3
+ "version": "1.15.9",
4
+ "main": "dist/src/index.js",
5
+ "types": "dist/src/index.d.ts",
6
+ "files": [
7
+ "dist/**/*.d.ts",
8
+ "dist/**/*.js"
9
+ ],
10
+ "directories": {
11
+ "test": "jest"
12
+ },
13
+ "scripts": {
14
+ "test": "jest",
15
+ "build": "tsc",
16
+ "publish": "npm run build && npm publish"
17
+ },
18
+ "keywords": [],
19
+ "author": "",
20
+ "license": "ISC",
21
+ "dependencies": {
22
+ "@apollo/client": "3.9.11",
23
+ "apollo-boost": "^0.4.9",
24
+ "axios": "^1.6.8",
25
+ "cross-fetch": "^4.0.0",
26
+ "crypto-js": "^4.2.0",
27
+ "graphql": "^15.8.0",
28
+ "graphql-request": "^6.1.0",
29
+ "graphql-tag": "^2.12.6",
30
+ "react": "^18.2.0",
31
+ "ts-node": "^10.9.2"
32
+ },
33
+ "devDependencies": {
34
+ "@types/axios": "^0.14.0",
35
+ "@types/crypto-js": "^4.2.2",
36
+ "@types/jest": "^29.5.12",
37
+ "@types/node": "^20.12.7",
38
+ "jest": "^29.7.0",
39
+ "ts-jest": "^29.1.2",
40
+ "typescript": "^5.4.5"
41
+ },
42
+ "description": "",
43
+ "packageManager": "yarn@4.7.0+sha512.5a0afa1d4c1d844b3447ee3319633797bcd6385d9a44be07993ae52ff4facabccafb4af5dcd1c2f9a94ac113e5e9ff56f6130431905884414229e284e37bb7c9"
44
+ }
@@ -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;