@longvansoftware/service-js-client 1.16.2 → 1.16.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.
Files changed (79) hide show
  1. package/dist/src/graphql/campaign/mutations.d.ts +1 -0
  2. package/dist/src/graphql/campaign/mutations.js +34 -0
  3. package/dist/src/graphql/campaign/queries.d.ts +9 -0
  4. package/dist/src/graphql/campaign/queries.js +427 -0
  5. package/dist/src/graphql/cashbook/queries.d.ts +2 -0
  6. package/dist/src/graphql/cashbook/queries.js +99 -0
  7. package/dist/src/graphql/crm/mutations.d.ts +2 -0
  8. package/dist/src/graphql/crm/mutations.js +37 -1
  9. package/dist/src/graphql/crm/queries.d.ts +1 -0
  10. package/dist/src/graphql/crm/queries.js +35 -1
  11. package/dist/src/graphql/fragments/product.d.ts +38 -0
  12. package/dist/src/graphql/fragments/product.js +196 -0
  13. package/dist/src/graphql/paymentV2/mutations.d.ts +5 -0
  14. package/dist/src/graphql/paymentV2/mutations.js +120 -0
  15. package/dist/src/graphql/paymentV2/queries.d.ts +9 -0
  16. package/dist/src/graphql/paymentV2/queries.js +257 -0
  17. package/dist/src/graphql/product/queries.d.ts +1 -0
  18. package/dist/src/graphql/product/queries.js +14 -1
  19. package/dist/src/graphql/store/mutations.d.ts +1 -0
  20. package/dist/src/graphql/store/mutations.js +29 -0
  21. package/dist/src/graphql/store/queries.d.ts +1 -0
  22. package/dist/src/graphql/store/queries.js +29 -0
  23. package/dist/src/lib/accounting/index.d.ts +5 -0
  24. package/dist/src/lib/accounting/index.js +32 -0
  25. package/dist/src/lib/campaign/index.d.ts +20 -0
  26. package/dist/src/lib/campaign/index.js +218 -0
  27. package/dist/src/lib/cashbook/index.d.ts +6 -0
  28. package/dist/src/lib/cashbook/index.js +56 -0
  29. package/dist/src/lib/comhub/index.d.ts +6 -0
  30. package/dist/src/lib/comhub/index.js +50 -0
  31. package/dist/src/lib/crm/index.d.ts +3 -0
  32. package/dist/src/lib/crm/index.js +51 -0
  33. package/dist/src/lib/deepLinkVietQr/index.d.ts +7 -0
  34. package/dist/src/lib/deepLinkVietQr/index.js +58 -0
  35. package/dist/src/lib/fileService/index.d.ts +34 -0
  36. package/dist/src/lib/fileService/index.js +80 -0
  37. package/dist/src/lib/getImage/index.d.ts +4 -0
  38. package/dist/src/lib/getImage/index.js +10 -0
  39. package/dist/src/lib/image/index.d.ts +7 -0
  40. package/dist/src/lib/image/index.js +49 -0
  41. package/dist/src/lib/omnigateway/index.d.ts +7 -0
  42. package/dist/src/lib/omnigateway/index.js +58 -0
  43. package/dist/src/lib/paymentV2/index.d.ts +18 -0
  44. package/dist/src/lib/paymentV2/index.js +245 -0
  45. package/dist/src/lib/portal/index.d.ts +23 -0
  46. package/dist/src/lib/portal/index.js +255 -0
  47. package/dist/src/lib/product/index.d.ts +1 -0
  48. package/dist/src/lib/product/index.js +16 -0
  49. package/dist/src/lib/shareZalo/index.d.ts +5 -0
  50. package/dist/src/lib/shareZalo/index.js +32 -0
  51. package/dist/src/lib/store/index.d.ts +30 -0
  52. package/dist/src/lib/store/index.js +74 -0
  53. package/dist/src/lib/token/index.d.ts +5 -0
  54. package/dist/src/lib/token/index.js +32 -0
  55. package/dist/src/lib/upload/index.d.ts +5 -0
  56. package/dist/src/lib/upload/index.js +35 -0
  57. package/dist/src/lib/warehouseV2/index.d.ts +13 -0
  58. package/dist/src/lib/warehouseV2/index.js +54 -0
  59. package/dist/src/lib/zca/index.d.ts +12 -0
  60. package/dist/src/lib/zca/index.js +41 -0
  61. package/dist/src/types/campaign.d.ts +14 -0
  62. package/dist/src/types/campaign.js +2 -0
  63. package/dist/src/types/common.d.ts +264 -0
  64. package/dist/src/types/common.js +35 -0
  65. package/dist/src/types/invoice.d.ts +13 -0
  66. package/dist/src/types/invoice.js +2 -0
  67. package/dist/src/types/portal.d.ts +7 -0
  68. package/dist/src/types/portal.js +2 -0
  69. package/dist/src/types/store.d.ts +158 -0
  70. package/dist/src/types/store.js +3 -0
  71. package/dist/src/utils/errorHandler.d.ts +64 -0
  72. package/dist/src/utils/errorHandler.js +197 -0
  73. package/dist/src/utils/validatePhoneNumber.d.ts +1 -0
  74. package/dist/src/utils/validatePhoneNumber.js +20 -0
  75. package/package.json +1 -1
  76. package/dist/src/lib/service.d.ts +0 -14
  77. package/dist/src/lib/service.js +0 -101
  78. package/dist/src/utils/build-field-string.d.ts +0 -1
  79. package/dist/src/utils/build-field-string.js +0 -16
@@ -0,0 +1,264 @@
1
+ /**
2
+ * Common types used across the SDK
3
+ */
4
+ /**
5
+ * Environment configuration
6
+ */
7
+ export type Environment = 'dev' | 'live';
8
+ /**
9
+ * HTTP methods supported by REST API calls
10
+ */
11
+ export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE';
12
+ /**
13
+ * Pagination parameters
14
+ */
15
+ export interface PaginationParams {
16
+ currentPage?: number;
17
+ maxResult?: number;
18
+ pageSize?: number;
19
+ }
20
+ /**
21
+ * Pagination response
22
+ */
23
+ export interface PaginationResponse<T> {
24
+ total: number;
25
+ currentPage: number;
26
+ maxResult: number;
27
+ totalPage: number;
28
+ data: T[];
29
+ }
30
+ /**
31
+ * Search parameters
32
+ */
33
+ export interface SearchParams extends PaginationParams {
34
+ keyword?: string;
35
+ sortBy?: string;
36
+ sortOrder?: 'ASC' | 'DESC';
37
+ }
38
+ /**
39
+ * API Response wrapper
40
+ */
41
+ export interface ApiResponse<T = any> {
42
+ success: boolean;
43
+ data?: T;
44
+ message?: string;
45
+ errors?: string[];
46
+ }
47
+ /**
48
+ * Service configuration
49
+ */
50
+ export interface ServiceConfig {
51
+ endpoint: string;
52
+ orgId: string;
53
+ storeId: string;
54
+ token?: string;
55
+ }
56
+ /**
57
+ * GraphQL variables base interface
58
+ */
59
+ export interface GraphQLVariables {
60
+ partnerId?: string;
61
+ storeChannel?: string;
62
+ [key: string]: any;
63
+ }
64
+ /**
65
+ * REST API headers
66
+ */
67
+ export interface RestApiHeaders {
68
+ 'Content-Type'?: string;
69
+ 'Authorization'?: string;
70
+ 'PartnerId'?: string;
71
+ 'Partner-Id'?: string;
72
+ 'X-Ecomos-Access-Token'?: string;
73
+ [key: string]: string | undefined;
74
+ }
75
+ /**
76
+ * File upload configuration
77
+ */
78
+ export interface FileUploadConfig {
79
+ maxSize?: number;
80
+ allowedTypes?: string[];
81
+ multiple?: boolean;
82
+ }
83
+ /**
84
+ * Cache configuration
85
+ */
86
+ export interface CacheConfig {
87
+ ttl?: number;
88
+ maxSize?: number;
89
+ enabled?: boolean;
90
+ }
91
+ /**
92
+ * Retry configuration
93
+ */
94
+ export interface RetryConfig {
95
+ maxRetries?: number;
96
+ baseDelay?: number;
97
+ maxDelay?: number;
98
+ exponentialBackoff?: boolean;
99
+ }
100
+ /**
101
+ * SDK Configuration
102
+ */
103
+ export interface SDKConfig {
104
+ orgId: string;
105
+ storeId: string;
106
+ environment: Environment;
107
+ cache?: CacheConfig;
108
+ retry?: RetryConfig;
109
+ timeout?: number;
110
+ }
111
+ /**
112
+ * Service method options
113
+ */
114
+ export interface ServiceMethodOptions {
115
+ timeout?: number;
116
+ retry?: RetryConfig;
117
+ cache?: boolean;
118
+ headers?: RestApiHeaders;
119
+ }
120
+ /**
121
+ * Base entity interface
122
+ */
123
+ export interface BaseEntity {
124
+ id: string;
125
+ createdAt?: string;
126
+ updatedAt?: string;
127
+ createdBy?: string;
128
+ updatedBy?: string;
129
+ }
130
+ /**
131
+ * Address interface
132
+ */
133
+ export interface Address {
134
+ street?: string;
135
+ city?: string;
136
+ state?: string;
137
+ country?: string;
138
+ postalCode?: string;
139
+ fullAddress?: string;
140
+ }
141
+ /**
142
+ * Contact information
143
+ */
144
+ export interface ContactInfo {
145
+ email?: string;
146
+ phone?: string;
147
+ website?: string;
148
+ }
149
+ /**
150
+ * Money/Price interface
151
+ */
152
+ export interface Money {
153
+ amount: number;
154
+ currency?: string;
155
+ formatted?: string;
156
+ }
157
+ /**
158
+ * Image interface
159
+ */
160
+ export interface Image {
161
+ id?: string;
162
+ url: string;
163
+ alt?: string;
164
+ width?: number;
165
+ height?: number;
166
+ size?: number;
167
+ }
168
+ /**
169
+ * Category interface
170
+ */
171
+ export interface Category extends BaseEntity {
172
+ title: string;
173
+ handle?: string;
174
+ description?: string;
175
+ image?: string;
176
+ icon?: string;
177
+ parentId?: string;
178
+ level?: number;
179
+ children?: Category[];
180
+ }
181
+ /**
182
+ * Tag interface
183
+ */
184
+ export interface Tag {
185
+ id: string;
186
+ name: string;
187
+ color?: string;
188
+ }
189
+ /**
190
+ * Attribute interface
191
+ */
192
+ export interface Attribute {
193
+ name: string;
194
+ value: string;
195
+ type?: string;
196
+ }
197
+ /**
198
+ * Unit interface
199
+ */
200
+ export interface Unit {
201
+ id: string;
202
+ name: string;
203
+ symbol?: string;
204
+ }
205
+ /**
206
+ * Status enum
207
+ */
208
+ export declare enum Status {
209
+ ACTIVE = "ACTIVE",
210
+ INACTIVE = "INACTIVE",
211
+ PENDING = "PENDING",
212
+ DRAFT = "DRAFT",
213
+ PUBLISHED = "PUBLISHED",
214
+ ARCHIVED = "ARCHIVED"
215
+ }
216
+ /**
217
+ * Gender enum
218
+ */
219
+ export declare enum Gender {
220
+ MALE = "MALE",
221
+ FEMALE = "FEMALE",
222
+ OTHER = "OTHER"
223
+ }
224
+ /**
225
+ * Sort order enum
226
+ */
227
+ export declare enum SortOrder {
228
+ ASC = "ASC",
229
+ DESC = "DESC"
230
+ }
231
+ /**
232
+ * Utility type for making all properties optional
233
+ */
234
+ export type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
235
+ /**
236
+ * Utility type for making all properties required
237
+ */
238
+ export type RequiredBy<T, K extends keyof T> = T & Required<Pick<T, K>>;
239
+ /**
240
+ * Utility type for nullable properties
241
+ */
242
+ export type Nullable<T> = T | null;
243
+ /**
244
+ * Utility type for optional properties
245
+ */
246
+ export type Optional<T> = T | undefined;
247
+ /**
248
+ * Deep partial type
249
+ */
250
+ export type DeepPartial<T> = {
251
+ [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
252
+ };
253
+ /**
254
+ * Promise result type
255
+ */
256
+ export type PromiseResult<T> = Promise<T>;
257
+ /**
258
+ * Callback function type
259
+ */
260
+ export type Callback<T = void> = (error?: Error, result?: T) => void;
261
+ /**
262
+ * Event handler type
263
+ */
264
+ export type EventHandler<T = any> = (event: T) => void;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ /**
3
+ * Common types used across the SDK
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.SortOrder = exports.Gender = exports.Status = void 0;
7
+ /**
8
+ * Status enum
9
+ */
10
+ var Status;
11
+ (function (Status) {
12
+ Status["ACTIVE"] = "ACTIVE";
13
+ Status["INACTIVE"] = "INACTIVE";
14
+ Status["PENDING"] = "PENDING";
15
+ Status["DRAFT"] = "DRAFT";
16
+ Status["PUBLISHED"] = "PUBLISHED";
17
+ Status["ARCHIVED"] = "ARCHIVED";
18
+ })(Status || (exports.Status = Status = {}));
19
+ /**
20
+ * Gender enum
21
+ */
22
+ var Gender;
23
+ (function (Gender) {
24
+ Gender["MALE"] = "MALE";
25
+ Gender["FEMALE"] = "FEMALE";
26
+ Gender["OTHER"] = "OTHER";
27
+ })(Gender || (exports.Gender = Gender = {}));
28
+ /**
29
+ * Sort order enum
30
+ */
31
+ var SortOrder;
32
+ (function (SortOrder) {
33
+ SortOrder["ASC"] = "ASC";
34
+ SortOrder["DESC"] = "DESC";
35
+ })(SortOrder || (exports.SortOrder = SortOrder = {}));
@@ -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,7 @@
1
+ export interface SaveTextEditor {
2
+ type: string;
3
+ relativeId: string;
4
+ content: string;
5
+ version: string;
6
+ createdBy: string;
7
+ }
@@ -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,64 @@
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
+ }