@longvansoftware/storefront-js-client 3.7.5 â 3.7.8
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.
- package/dist/src/graphql/product/queries.d.ts +1 -0
- package/dist/src/graphql/product/queries.js +59 -1
- package/dist/src/lib/product/index.d.ts +1 -0
- package/dist/src/lib/product/index.js +17 -0
- package/package.json +2 -3
- package/dist/src/graphql/accounting_service/mutations.d.ts +0 -2
- package/dist/src/graphql/accounting_service/mutations.js +0 -102
- package/dist/src/graphql/accounting_service/queries.d.ts +0 -1
- package/dist/src/graphql/accounting_service/queries.js +0 -62
- package/dist/src/graphql/crm_camping/mutations.d.ts +0 -1
- package/dist/src/graphql/crm_camping/mutations.js +0 -37
- package/dist/src/graphql/crm_camping/queries.d.ts +0 -8
- package/dist/src/graphql/crm_camping/queries.js +0 -279
- package/dist/src/graphql/fragments/product.d.ts +0 -38
- package/dist/src/graphql/fragments/product.js +0 -196
- package/dist/src/graphql/orderGraphQL/mutations.d.ts +0 -4
- package/dist/src/graphql/orderGraphQL/mutations.js +0 -359
- package/dist/src/graphql/orderGraphQL/queries.d.ts +0 -7
- package/dist/src/graphql/orderGraphQL/queries.js +0 -402
- package/dist/src/graphql/paymentLV/mutations.d.ts +0 -2
- package/dist/src/graphql/paymentLV/mutations.js +0 -25
- package/dist/src/graphql/paymentLV/queries.d.ts +0 -4
- package/dist/src/graphql/paymentLV/queries.js +0 -83
- package/dist/src/graphql/quicklab_service/mutations.d.ts +0 -8
- package/dist/src/graphql/quicklab_service/mutations.js +0 -171
- package/dist/src/graphql/quicklab_service/queries.d.ts +0 -6
- package/dist/src/graphql/quicklab_service/queries.js +0 -121
- package/dist/src/graphql/resource_permission/mutations.d.ts +0 -2
- package/dist/src/graphql/resource_permission/mutations.js +0 -63
- package/dist/src/graphql/resource_permission/queries.d.ts +0 -1
- package/dist/src/graphql/resource_permission/queries.js +0 -18
- package/dist/src/lib/accounting_service/index.d.ts +0 -9
- package/dist/src/lib/accounting_service/index.js +0 -69
- package/dist/src/lib/cloud_rest/index.d.ts +0 -17
- package/dist/src/lib/cloud_rest/index.js +0 -101
- package/dist/src/lib/crm_camping/index.d.ts +0 -16
- package/dist/src/lib/crm_camping/index.js +0 -227
- package/dist/src/lib/dns/index.d.ts +0 -7
- package/dist/src/lib/dns/index.js +0 -40
- package/dist/src/lib/orderGraphQL/index.d.ts +0 -16
- package/dist/src/lib/orderGraphQL/index.js +0 -192
- package/dist/src/lib/order_cloud_rest/index.d.ts +0 -7
- package/dist/src/lib/order_cloud_rest/index.js +0 -39
- package/dist/src/lib/paymentLV/index.d.ts +0 -12
- package/dist/src/lib/paymentLV/index.js +0 -132
- package/dist/src/lib/quicklab_service/index.d.ts +0 -18
- package/dist/src/lib/quicklab_service/index.js +0 -197
- package/dist/src/lib/resource_permission/index.d.ts +0 -9
- package/dist/src/lib/resource_permission/index.js +0 -81
- package/dist/src/lib/shareZalo/index.d.ts +0 -5
- package/dist/src/lib/shareZalo/index.js +0 -32
- package/dist/src/types/common.d.ts +0 -264
- package/dist/src/types/common.js +0 -35
- package/dist/src/utils/errorHandler.d.ts +0 -64
- package/dist/src/utils/errorHandler.js +0 -197
|
@@ -1,81 +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.ResourcePermissionService = void 0;
|
|
13
|
-
const mutations_1 = require("../../graphql/resource_permission/mutations");
|
|
14
|
-
const queries_1 = require("../../graphql/resource_permission/queries");
|
|
15
|
-
const serviceSDK_1 = require("../serviceSDK");
|
|
16
|
-
class ResourcePermissionService extends serviceSDK_1.Service {
|
|
17
|
-
constructor(endpoint, orgId, storeId) {
|
|
18
|
-
super(endpoint, orgId, storeId);
|
|
19
|
-
}
|
|
20
|
-
setToken(token) {
|
|
21
|
-
this.token = token;
|
|
22
|
-
}
|
|
23
|
-
setStoreId(storeId) {
|
|
24
|
-
this.storeId = storeId;
|
|
25
|
-
}
|
|
26
|
-
shareResource(createModel, partnerId) {
|
|
27
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
const mutation = mutations_1.SHARE_RESOURCE;
|
|
29
|
-
const variables = {
|
|
30
|
-
partnerId: partnerId,
|
|
31
|
-
createModel,
|
|
32
|
-
};
|
|
33
|
-
try {
|
|
34
|
-
const response = yield this.graphqlMutationV2(mutation, variables);
|
|
35
|
-
return response.shareResource;
|
|
36
|
-
}
|
|
37
|
-
catch (error) {
|
|
38
|
-
console.log(`Error in shareResource: ${error}`);
|
|
39
|
-
throw error;
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
removeShareParty(resourceId, sharePartyId, resourceType, partnerId) {
|
|
44
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
-
const mutation = mutations_1.REMOVE_SHARE_PARTY;
|
|
46
|
-
const variables = {
|
|
47
|
-
partnerId: partnerId,
|
|
48
|
-
orgId: this.orgId,
|
|
49
|
-
resourceType,
|
|
50
|
-
resourceId,
|
|
51
|
-
sharePartyId,
|
|
52
|
-
};
|
|
53
|
-
try {
|
|
54
|
-
const response = yield this.graphqlMutationV2(mutation, variables);
|
|
55
|
-
return response.removeShareParty;
|
|
56
|
-
}
|
|
57
|
-
catch (error) {
|
|
58
|
-
console.log(`Error in removeShareParty: ${error}`);
|
|
59
|
-
throw error;
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
getSharedUserByService(resourceType, resourceId) {
|
|
64
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
-
const query = queries_1.GET_SHARED_USER_BY_SERVICE;
|
|
66
|
-
const variables = {
|
|
67
|
-
resourceType,
|
|
68
|
-
resourceId,
|
|
69
|
-
};
|
|
70
|
-
try {
|
|
71
|
-
const response = yield this.graphqlQueryV2(query, variables);
|
|
72
|
-
return response.getSharedUserByService;
|
|
73
|
-
}
|
|
74
|
-
catch (error) {
|
|
75
|
-
console.log(`Error in getSharedUserByService: ${error}`);
|
|
76
|
-
throw error;
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
exports.ResourcePermissionService = ResourcePermissionService;
|
|
@@ -1,32 +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.ShareZaloService = void 0;
|
|
13
|
-
const serviceSDK_1 = require("../serviceSDK");
|
|
14
|
-
class ShareZaloService extends serviceSDK_1.Service {
|
|
15
|
-
constructor(endpoint, orgId, storeId) {
|
|
16
|
-
super(endpoint, orgId, storeId);
|
|
17
|
-
}
|
|
18
|
-
shareOrder(dataRequet) {
|
|
19
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
const endpoint = ``;
|
|
21
|
-
const method = "POST";
|
|
22
|
-
try {
|
|
23
|
-
const response = yield this.restApiCallWithNoHeader(endpoint, method, dataRequet);
|
|
24
|
-
return response;
|
|
25
|
-
}
|
|
26
|
-
catch (error) {
|
|
27
|
-
throw error;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
exports.ShareZaloService = ShareZaloService;
|
|
@@ -1,264 +0,0 @@
|
|
|
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;
|
package/dist/src/types/common.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
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 = {}));
|
|
@@ -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;
|