@longvansoftware/service-js-client 1.16.4 → 1.16.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.
Files changed (73) hide show
  1. package/dist/src/graphql/cloud/mutations.d.ts +23 -20
  2. package/dist/src/graphql/cloud/mutations.js +55 -1
  3. package/dist/src/graphql/crm/queries.d.ts +17 -14
  4. package/dist/src/graphql/crm/queries.js +37 -1
  5. package/dist/src/lib/cloud/index.d.ts +2 -0
  6. package/dist/src/lib/cloud/index.js +38 -0
  7. package/dist/src/lib/crm/index.d.ts +2 -0
  8. package/dist/src/lib/crm/index.js +34 -0
  9. package/package.json +1 -1
  10. package/dist/src/graphql/campaign/mutations.d.ts +0 -1
  11. package/dist/src/graphql/campaign/mutations.js +0 -34
  12. package/dist/src/graphql/campaign/queries.d.ts +0 -9
  13. package/dist/src/graphql/campaign/queries.js +0 -427
  14. package/dist/src/graphql/cashbook/queries.d.ts +0 -2
  15. package/dist/src/graphql/cashbook/queries.js +0 -99
  16. package/dist/src/graphql/fragments/product.d.ts +0 -38
  17. package/dist/src/graphql/fragments/product.js +0 -196
  18. package/dist/src/graphql/paymentV2/mutations.d.ts +0 -5
  19. package/dist/src/graphql/paymentV2/mutations.js +0 -120
  20. package/dist/src/graphql/paymentV2/queries.d.ts +0 -9
  21. package/dist/src/graphql/paymentV2/queries.js +0 -257
  22. package/dist/src/graphql/store/mutations.d.ts +0 -1
  23. package/dist/src/graphql/store/mutations.js +0 -29
  24. package/dist/src/graphql/store/queries.d.ts +0 -1
  25. package/dist/src/graphql/store/queries.js +0 -29
  26. package/dist/src/lib/accounting/index.d.ts +0 -5
  27. package/dist/src/lib/accounting/index.js +0 -32
  28. package/dist/src/lib/campaign/index.d.ts +0 -20
  29. package/dist/src/lib/campaign/index.js +0 -218
  30. package/dist/src/lib/cashbook/index.d.ts +0 -6
  31. package/dist/src/lib/cashbook/index.js +0 -56
  32. package/dist/src/lib/comhub/index.d.ts +0 -6
  33. package/dist/src/lib/comhub/index.js +0 -50
  34. package/dist/src/lib/deepLinkVietQr/index.d.ts +0 -7
  35. package/dist/src/lib/deepLinkVietQr/index.js +0 -58
  36. package/dist/src/lib/fileService/index.d.ts +0 -34
  37. package/dist/src/lib/fileService/index.js +0 -80
  38. package/dist/src/lib/getImage/index.d.ts +0 -4
  39. package/dist/src/lib/getImage/index.js +0 -10
  40. package/dist/src/lib/image/index.d.ts +0 -7
  41. package/dist/src/lib/image/index.js +0 -49
  42. package/dist/src/lib/omnigateway/index.d.ts +0 -7
  43. package/dist/src/lib/omnigateway/index.js +0 -58
  44. package/dist/src/lib/paymentV2/index.d.ts +0 -18
  45. package/dist/src/lib/paymentV2/index.js +0 -245
  46. package/dist/src/lib/portal/index.d.ts +0 -23
  47. package/dist/src/lib/portal/index.js +0 -255
  48. package/dist/src/lib/shareZalo/index.d.ts +0 -5
  49. package/dist/src/lib/shareZalo/index.js +0 -32
  50. package/dist/src/lib/store/index.d.ts +0 -30
  51. package/dist/src/lib/store/index.js +0 -74
  52. package/dist/src/lib/token/index.d.ts +0 -5
  53. package/dist/src/lib/token/index.js +0 -32
  54. package/dist/src/lib/upload/index.d.ts +0 -5
  55. package/dist/src/lib/upload/index.js +0 -35
  56. package/dist/src/lib/warehouseV2/index.d.ts +0 -13
  57. package/dist/src/lib/warehouseV2/index.js +0 -54
  58. package/dist/src/lib/zca/index.d.ts +0 -12
  59. package/dist/src/lib/zca/index.js +0 -41
  60. package/dist/src/types/campaign.d.ts +0 -14
  61. package/dist/src/types/campaign.js +0 -2
  62. package/dist/src/types/common.d.ts +0 -264
  63. package/dist/src/types/common.js +0 -35
  64. package/dist/src/types/invoice.d.ts +0 -13
  65. package/dist/src/types/invoice.js +0 -2
  66. package/dist/src/types/portal.d.ts +0 -7
  67. package/dist/src/types/portal.js +0 -2
  68. package/dist/src/types/store.d.ts +0 -158
  69. package/dist/src/types/store.js +0 -3
  70. package/dist/src/utils/errorHandler.d.ts +0 -64
  71. package/dist/src/utils/errorHandler.js +0 -197
  72. package/dist/src/utils/validatePhoneNumber.d.ts +0 -1
  73. package/dist/src/utils/validatePhoneNumber.js +0 -20
@@ -1,158 +0,0 @@
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, };
@@ -1,3 +0,0 @@
1
- "use strict";
2
- // src/types/store.ts
3
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,64 +0,0 @@
1
- import { SDKError } from '../lib/serviceSDK';
2
- /**
3
- * Error types for better categorization
4
- */
5
- export declare enum ErrorType {
6
- GRAPHQL_ERROR = "GRAPHQL_ERROR",
7
- NETWORK_ERROR = "NETWORK_ERROR",
8
- REST_API_ERROR = "REST_API_ERROR",
9
- VALIDATION_ERROR = "VALIDATION_ERROR",
10
- AUTHENTICATION_ERROR = "AUTHENTICATION_ERROR",
11
- AUTHORIZATION_ERROR = "AUTHORIZATION_ERROR",
12
- NOT_FOUND_ERROR = "NOT_FOUND_ERROR",
13
- UNKNOWN_ERROR = "UNKNOWN_ERROR"
14
- }
15
- /**
16
- * Error severity levels
17
- */
18
- export declare enum ErrorSeverity {
19
- LOW = "LOW",
20
- MEDIUM = "MEDIUM",
21
- HIGH = "HIGH",
22
- CRITICAL = "CRITICAL"
23
- }
24
- /**
25
- * Enhanced SDK Error with additional metadata
26
- */
27
- export declare class EnhancedSDKError extends SDKError {
28
- readonly severity: ErrorSeverity;
29
- readonly timestamp: Date;
30
- readonly context?: Record<string, any>;
31
- readonly retryable: boolean;
32
- constructor(message: string, type: ErrorType, originalError?: any, severity?: ErrorSeverity, context?: Record<string, any>, retryable?: boolean);
33
- }
34
- /**
35
- * Error handler utility class
36
- */
37
- export declare class ErrorHandler {
38
- /**
39
- * Create a standardized error from various error sources
40
- */
41
- static createError(error: any, context?: Record<string, any>): EnhancedSDKError;
42
- /**
43
- * Determine error severity based on error characteristics
44
- */
45
- private static determineSeverity;
46
- /**
47
- * Determine if an error is retryable
48
- */
49
- private static isRetryable;
50
- /**
51
- * Log error with appropriate level
52
- */
53
- static logError(error: EnhancedSDKError, operation?: string): void;
54
- /**
55
- * Check if error should trigger retry logic
56
- */
57
- static shouldRetry(error: EnhancedSDKError, attemptCount: number, maxRetries?: number): boolean;
58
- }
59
- /**
60
- * Retry utility with exponential backoff
61
- */
62
- export declare class RetryManager {
63
- static withExponentialBackoff<T>(operation: () => Promise<T>, maxRetries?: number, baseDelay?: number): Promise<T>;
64
- }
@@ -1,197 +0,0 @@
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.RetryManager = exports.ErrorHandler = exports.EnhancedSDKError = exports.ErrorSeverity = exports.ErrorType = void 0;
13
- const serviceSDK_1 = require("../lib/serviceSDK");
14
- /**
15
- * Error types for better categorization
16
- */
17
- var ErrorType;
18
- (function (ErrorType) {
19
- ErrorType["GRAPHQL_ERROR"] = "GRAPHQL_ERROR";
20
- ErrorType["NETWORK_ERROR"] = "NETWORK_ERROR";
21
- ErrorType["REST_API_ERROR"] = "REST_API_ERROR";
22
- ErrorType["VALIDATION_ERROR"] = "VALIDATION_ERROR";
23
- ErrorType["AUTHENTICATION_ERROR"] = "AUTHENTICATION_ERROR";
24
- ErrorType["AUTHORIZATION_ERROR"] = "AUTHORIZATION_ERROR";
25
- ErrorType["NOT_FOUND_ERROR"] = "NOT_FOUND_ERROR";
26
- ErrorType["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
27
- })(ErrorType || (exports.ErrorType = ErrorType = {}));
28
- /**
29
- * Error severity levels
30
- */
31
- var ErrorSeverity;
32
- (function (ErrorSeverity) {
33
- ErrorSeverity["LOW"] = "LOW";
34
- ErrorSeverity["MEDIUM"] = "MEDIUM";
35
- ErrorSeverity["HIGH"] = "HIGH";
36
- ErrorSeverity["CRITICAL"] = "CRITICAL";
37
- })(ErrorSeverity || (exports.ErrorSeverity = ErrorSeverity = {}));
38
- /**
39
- * Enhanced SDK Error with additional metadata
40
- */
41
- class EnhancedSDKError extends serviceSDK_1.SDKError {
42
- constructor(message, type, originalError, severity = ErrorSeverity.MEDIUM, context, retryable = false) {
43
- super(message, type, originalError);
44
- this.severity = severity;
45
- this.timestamp = new Date();
46
- this.context = context;
47
- this.retryable = retryable;
48
- }
49
- }
50
- exports.EnhancedSDKError = EnhancedSDKError;
51
- /**
52
- * Error handler utility class
53
- */
54
- class ErrorHandler {
55
- /**
56
- * Create a standardized error from various error sources
57
- */
58
- static createError(error, context) {
59
- var _a;
60
- // Handle GraphQL errors
61
- if (error.graphQLErrors && error.graphQLErrors.length > 0) {
62
- const message = error.graphQLErrors.map((err) => err.message).join(', ');
63
- return new EnhancedSDKError(message, ErrorType.GRAPHQL_ERROR, error, this.determineSeverity(error), context, this.isRetryable(error));
64
- }
65
- // Handle network errors
66
- if (error.networkError) {
67
- return new EnhancedSDKError(`Network Error: ${error.networkError.message}`, ErrorType.NETWORK_ERROR, error, ErrorSeverity.HIGH, context, true // Network errors are usually retryable
68
- );
69
- }
70
- // Handle Axios errors (REST API)
71
- if (error.response) {
72
- const status = error.response.status;
73
- let errorType = ErrorType.REST_API_ERROR;
74
- let severity = ErrorSeverity.MEDIUM;
75
- let retryable = false;
76
- // Categorize by HTTP status code
77
- if (status === 401) {
78
- errorType = ErrorType.AUTHENTICATION_ERROR;
79
- severity = ErrorSeverity.HIGH;
80
- }
81
- else if (status === 403) {
82
- errorType = ErrorType.AUTHORIZATION_ERROR;
83
- severity = ErrorSeverity.HIGH;
84
- }
85
- else if (status === 404) {
86
- errorType = ErrorType.NOT_FOUND_ERROR;
87
- severity = ErrorSeverity.LOW;
88
- }
89
- else if (status >= 500) {
90
- severity = ErrorSeverity.HIGH;
91
- retryable = true;
92
- }
93
- else if (status === 429) {
94
- retryable = true;
95
- }
96
- return new EnhancedSDKError(`API Error (${status}): ${((_a = error.response.data) === null || _a === void 0 ? void 0 : _a.message) || error.message}`, errorType, error, severity, Object.assign(Object.assign({}, context), { statusCode: status }), retryable);
97
- }
98
- // Handle validation errors
99
- if (error.name === 'ValidationError') {
100
- return new EnhancedSDKError(error.message, ErrorType.VALIDATION_ERROR, error, ErrorSeverity.LOW, context, false);
101
- }
102
- // Default unknown error
103
- return new EnhancedSDKError(error.message || 'An unknown error occurred', ErrorType.UNKNOWN_ERROR, error, ErrorSeverity.MEDIUM, context, false);
104
- }
105
- /**
106
- * Determine error severity based on error characteristics
107
- */
108
- static determineSeverity(error) {
109
- var _a;
110
- if (error.networkError)
111
- return ErrorSeverity.HIGH;
112
- if ((_a = error.graphQLErrors) === null || _a === void 0 ? void 0 : _a.some((e) => { var _a; return ((_a = e.extensions) === null || _a === void 0 ? void 0 : _a.code) === 'INTERNAL_ERROR'; })) {
113
- return ErrorSeverity.CRITICAL;
114
- }
115
- return ErrorSeverity.MEDIUM;
116
- }
117
- /**
118
- * Determine if an error is retryable
119
- */
120
- static isRetryable(error) {
121
- var _a;
122
- // Network errors are usually retryable
123
- if (error.networkError)
124
- return true;
125
- // Some GraphQL errors are retryable
126
- if ((_a = error.graphQLErrors) === null || _a === void 0 ? void 0 : _a.some((e) => {
127
- var _a, _b;
128
- return ((_a = e.extensions) === null || _a === void 0 ? void 0 : _a.code) === 'TIMEOUT' ||
129
- ((_b = e.extensions) === null || _b === void 0 ? void 0 : _b.code) === 'RATE_LIMITED';
130
- })) {
131
- return true;
132
- }
133
- return false;
134
- }
135
- /**
136
- * Log error with appropriate level
137
- */
138
- static logError(error, operation) {
139
- const logData = {
140
- operation,
141
- type: error.type,
142
- severity: error.severity,
143
- message: error.message,
144
- timestamp: error.timestamp,
145
- context: error.context,
146
- retryable: error.retryable
147
- };
148
- switch (error.severity) {
149
- case ErrorSeverity.CRITICAL:
150
- console.error('🚨 CRITICAL ERROR:', logData);
151
- break;
152
- case ErrorSeverity.HIGH:
153
- console.error('❌ HIGH SEVERITY ERROR:', logData);
154
- break;
155
- case ErrorSeverity.MEDIUM:
156
- console.warn('âš ī¸ MEDIUM SEVERITY ERROR:', logData);
157
- break;
158
- case ErrorSeverity.LOW:
159
- console.info('â„šī¸ LOW SEVERITY ERROR:', logData);
160
- break;
161
- }
162
- }
163
- /**
164
- * Check if error should trigger retry logic
165
- */
166
- static shouldRetry(error, attemptCount, maxRetries = 3) {
167
- return error.retryable && attemptCount < maxRetries;
168
- }
169
- }
170
- exports.ErrorHandler = ErrorHandler;
171
- /**
172
- * Retry utility with exponential backoff
173
- */
174
- class RetryManager {
175
- static withExponentialBackoff(operation_1) {
176
- return __awaiter(this, arguments, void 0, function* (operation, maxRetries = 3, baseDelay = 1000) {
177
- let lastError;
178
- for (let attempt = 0; attempt <= maxRetries; attempt++) {
179
- try {
180
- return yield operation();
181
- }
182
- catch (error) {
183
- lastError = error;
184
- const enhancedError = ErrorHandler.createError(error);
185
- if (attempt === maxRetries || !ErrorHandler.shouldRetry(enhancedError, attempt, maxRetries)) {
186
- throw enhancedError;
187
- }
188
- // Exponential backoff with jitter
189
- const delay = baseDelay * Math.pow(2, attempt) + Math.random() * 1000;
190
- yield new Promise(resolve => setTimeout(resolve, delay));
191
- }
192
- }
193
- throw ErrorHandler.createError(lastError);
194
- });
195
- }
196
- }
197
- exports.RetryManager = RetryManager;
@@ -1 +0,0 @@
1
- export declare function validatePhoneNumber(phoneNumber: string): boolean;
@@ -1,20 +0,0 @@
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;