@longvansoftware/storefront-js-client 3.2.4 → 3.2.6
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/config/config.d.ts +2 -0
- package/dist/config/config.js +4 -2
- package/dist/src/graphql/crm/mutations.js +8 -171
- package/dist/src/graphql/crm/queries.js +8 -5
- package/dist/src/lib/SDK.d.ts +3 -0
- package/dist/src/lib/SDK.js +5 -0
- package/dist/src/lib/crm/index.d.ts +3 -3
- package/dist/src/lib/crm/index.js +10 -10
- package/dist/src/lib/fileService/index.d.ts +34 -0
- package/dist/src/lib/fileService/index.js +80 -0
- package/package.json +1 -1
package/dist/config/config.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ export declare const environmentEndpoints: {
|
|
|
24
24
|
zca: string;
|
|
25
25
|
cashbook: string;
|
|
26
26
|
store: string;
|
|
27
|
+
fileService: string;
|
|
27
28
|
};
|
|
28
29
|
live: {
|
|
29
30
|
product: string;
|
|
@@ -50,5 +51,6 @@ export declare const environmentEndpoints: {
|
|
|
50
51
|
zca: string;
|
|
51
52
|
cashbook: string;
|
|
52
53
|
store: string;
|
|
54
|
+
fileService: string;
|
|
53
55
|
};
|
|
54
56
|
};
|
package/dist/config/config.js
CHANGED
|
@@ -26,7 +26,8 @@ exports.environmentEndpoints = {
|
|
|
26
26
|
authorization: "https://id.dev.longvan.vn/authorization/public",
|
|
27
27
|
zca: "https://zca.dev.longvan.vn",
|
|
28
28
|
cashbook: 'https://api-gateway.dev.longvan.vn/cashbook-service/graphql',
|
|
29
|
-
store: "https://storefront.dev.longvan.vn/v2"
|
|
29
|
+
store: "https://storefront.dev.longvan.vn/v2",
|
|
30
|
+
fileService: "https://fileservice.dev.longvan.vn"
|
|
30
31
|
},
|
|
31
32
|
live: {
|
|
32
33
|
product: "https://product-service.longvan.vn/product-service/graphql",
|
|
@@ -52,6 +53,7 @@ exports.environmentEndpoints = {
|
|
|
52
53
|
authorization: "https://id.longvan.vn/authorization/public",
|
|
53
54
|
zca: "https://zca.longvan.vn",
|
|
54
55
|
cashbook: 'https://api-gateway.dev.longvan.vn/cashbook-service/graphql',
|
|
55
|
-
store: "https://storefront.longvan.vn/v2"
|
|
56
|
+
store: "https://storefront.longvan.vn/v2",
|
|
57
|
+
fileService: "https://fileservice.longvan.vn"
|
|
56
58
|
},
|
|
57
59
|
};
|
|
@@ -256,14 +256,14 @@ exports.UPDATE_WORK_EFFORT_STATUS = (0, graphql_tag_1.gql) `
|
|
|
256
256
|
$partyId: String!
|
|
257
257
|
$performerId: String!
|
|
258
258
|
$workEffortId: String!
|
|
259
|
-
$
|
|
260
|
-
$status:
|
|
259
|
+
$group: String
|
|
260
|
+
$status: WorkEffortStatus!
|
|
261
261
|
) {
|
|
262
262
|
updateWorkEffortStatus(
|
|
263
263
|
partyId: $partyId
|
|
264
264
|
performerId: $performerId
|
|
265
265
|
workEffortId: $workEffortId
|
|
266
|
-
|
|
266
|
+
group: $group
|
|
267
267
|
status: $status
|
|
268
268
|
) {
|
|
269
269
|
id
|
|
@@ -287,28 +287,14 @@ exports.UPDATE_WORK_EFFORT_STATUS = (0, graphql_tag_1.gql) `
|
|
|
287
287
|
startDateActual
|
|
288
288
|
startDateExpect
|
|
289
289
|
source
|
|
290
|
-
owner {
|
|
291
|
-
id
|
|
292
|
-
fullName
|
|
293
|
-
name
|
|
294
|
-
type
|
|
295
|
-
phone
|
|
296
|
-
email
|
|
297
|
-
}
|
|
298
290
|
priorityName
|
|
299
291
|
priorityValue
|
|
300
|
-
extSource
|
|
301
|
-
extSourceTopicId
|
|
302
|
-
extSourceSocialAppId
|
|
303
|
-
extSourceSupportChannelType
|
|
304
|
-
extSourceSocialChannelType
|
|
305
|
-
extSourceSocialAppName
|
|
306
|
-
extSourceTopicUrl
|
|
307
292
|
connectorId
|
|
308
293
|
mode
|
|
309
294
|
partyGroupIds
|
|
310
295
|
tagIds
|
|
311
296
|
processResult
|
|
297
|
+
processStatus
|
|
312
298
|
}
|
|
313
299
|
}
|
|
314
300
|
`;
|
|
@@ -402,22 +388,18 @@ exports.CREATE_WORK_EFFORT = (0, graphql_tag_1.gql) `
|
|
|
402
388
|
$createdBy: String!
|
|
403
389
|
$name: String
|
|
404
390
|
$description: String
|
|
405
|
-
$
|
|
406
|
-
$
|
|
391
|
+
$workflowId: String
|
|
392
|
+
$group: String
|
|
407
393
|
$attributes: JSON
|
|
408
|
-
$addAttachmentRequest: [AddAttachmentRequest]
|
|
409
|
-
$parentId: String
|
|
410
394
|
) {
|
|
411
395
|
createWorkEffort(
|
|
412
396
|
partnerId: $partnerId
|
|
413
397
|
createdBy: $createdBy
|
|
414
398
|
name: $name
|
|
415
399
|
description: $description
|
|
416
|
-
|
|
417
|
-
|
|
400
|
+
workflowId: $workflowId
|
|
401
|
+
group: $group
|
|
418
402
|
attributes: $attributes
|
|
419
|
-
addAttachmentRequest: $addAttachmentRequest
|
|
420
|
-
parentId: $parentId
|
|
421
403
|
) {
|
|
422
404
|
id
|
|
423
405
|
createdStamp
|
|
@@ -440,14 +422,6 @@ exports.CREATE_WORK_EFFORT = (0, graphql_tag_1.gql) `
|
|
|
440
422
|
startDateActual
|
|
441
423
|
startDateExpect
|
|
442
424
|
source
|
|
443
|
-
owner {
|
|
444
|
-
id
|
|
445
|
-
fullName
|
|
446
|
-
name
|
|
447
|
-
type
|
|
448
|
-
phone
|
|
449
|
-
email
|
|
450
|
-
}
|
|
451
425
|
priorityName
|
|
452
426
|
priorityValue
|
|
453
427
|
connectorId
|
|
@@ -456,143 +430,6 @@ exports.CREATE_WORK_EFFORT = (0, graphql_tag_1.gql) `
|
|
|
456
430
|
tagIds
|
|
457
431
|
processResult
|
|
458
432
|
processStatus
|
|
459
|
-
subTasks {
|
|
460
|
-
id
|
|
461
|
-
createdStamp
|
|
462
|
-
updatedStamp
|
|
463
|
-
createdBy
|
|
464
|
-
updatedBy
|
|
465
|
-
name
|
|
466
|
-
partyId
|
|
467
|
-
targetId
|
|
468
|
-
targetType
|
|
469
|
-
targetUrl
|
|
470
|
-
description
|
|
471
|
-
status
|
|
472
|
-
parentId
|
|
473
|
-
workEffortTypeId
|
|
474
|
-
stmId
|
|
475
|
-
workflowId
|
|
476
|
-
endDateExpect
|
|
477
|
-
endDateActual
|
|
478
|
-
startDateActual
|
|
479
|
-
startDateExpect
|
|
480
|
-
source
|
|
481
|
-
owner {
|
|
482
|
-
id
|
|
483
|
-
fullName
|
|
484
|
-
name
|
|
485
|
-
type
|
|
486
|
-
phone
|
|
487
|
-
email
|
|
488
|
-
}
|
|
489
|
-
priorityName
|
|
490
|
-
priorityValue
|
|
491
|
-
connectorId
|
|
492
|
-
mode
|
|
493
|
-
partyGroupIds
|
|
494
|
-
tagIds
|
|
495
|
-
processResult
|
|
496
|
-
processStatus
|
|
497
|
-
processPipeline {
|
|
498
|
-
id
|
|
499
|
-
name
|
|
500
|
-
}
|
|
501
|
-
attachments {
|
|
502
|
-
id
|
|
503
|
-
createdStamp
|
|
504
|
-
updatedStamp
|
|
505
|
-
updatedBy
|
|
506
|
-
createdBy
|
|
507
|
-
partyId
|
|
508
|
-
path
|
|
509
|
-
srcId
|
|
510
|
-
srcName
|
|
511
|
-
srcPath
|
|
512
|
-
srcConfigPathId
|
|
513
|
-
name
|
|
514
|
-
fileType
|
|
515
|
-
type
|
|
516
|
-
status
|
|
517
|
-
referId
|
|
518
|
-
}
|
|
519
|
-
subTasks {
|
|
520
|
-
id
|
|
521
|
-
createdStamp
|
|
522
|
-
updatedStamp
|
|
523
|
-
createdBy
|
|
524
|
-
updatedBy
|
|
525
|
-
name
|
|
526
|
-
partyId
|
|
527
|
-
targetId
|
|
528
|
-
targetType
|
|
529
|
-
targetUrl
|
|
530
|
-
description
|
|
531
|
-
status
|
|
532
|
-
parentId
|
|
533
|
-
workEffortTypeId
|
|
534
|
-
stmId
|
|
535
|
-
workflowId
|
|
536
|
-
endDateExpect
|
|
537
|
-
endDateActual
|
|
538
|
-
startDateActual
|
|
539
|
-
startDateExpect
|
|
540
|
-
source
|
|
541
|
-
owner {
|
|
542
|
-
id
|
|
543
|
-
fullName
|
|
544
|
-
name
|
|
545
|
-
type
|
|
546
|
-
phone
|
|
547
|
-
email
|
|
548
|
-
}
|
|
549
|
-
priorityName
|
|
550
|
-
priorityValue
|
|
551
|
-
connectorId
|
|
552
|
-
mode
|
|
553
|
-
partyGroupIds
|
|
554
|
-
tagIds
|
|
555
|
-
processResult
|
|
556
|
-
processStatus
|
|
557
|
-
}
|
|
558
|
-
actionLink {
|
|
559
|
-
name
|
|
560
|
-
uri
|
|
561
|
-
type
|
|
562
|
-
partyId
|
|
563
|
-
fromCollection
|
|
564
|
-
toCollection
|
|
565
|
-
group
|
|
566
|
-
params
|
|
567
|
-
id
|
|
568
|
-
createdStamp
|
|
569
|
-
updatedStamp
|
|
570
|
-
updatedBy
|
|
571
|
-
createdBy
|
|
572
|
-
}
|
|
573
|
-
}
|
|
574
|
-
attachments {
|
|
575
|
-
id
|
|
576
|
-
createdStamp
|
|
577
|
-
updatedStamp
|
|
578
|
-
updatedBy
|
|
579
|
-
createdBy
|
|
580
|
-
partyId
|
|
581
|
-
path
|
|
582
|
-
srcId
|
|
583
|
-
srcName
|
|
584
|
-
srcPath
|
|
585
|
-
srcConfigPathId
|
|
586
|
-
name
|
|
587
|
-
fileType
|
|
588
|
-
type
|
|
589
|
-
status
|
|
590
|
-
referId
|
|
591
|
-
}
|
|
592
|
-
processPipeline {
|
|
593
|
-
id
|
|
594
|
-
name
|
|
595
|
-
}
|
|
596
433
|
}
|
|
597
434
|
}
|
|
598
435
|
`;
|
|
@@ -288,22 +288,26 @@ exports.GET_WORK_EFFORTS = (0, graphql_tag_1.gql) `
|
|
|
288
288
|
query GetWorkEfforts(
|
|
289
289
|
$partnerId: String!
|
|
290
290
|
$performerId: String!
|
|
291
|
-
$
|
|
292
|
-
$
|
|
291
|
+
$workflowId: String
|
|
292
|
+
$group: String!
|
|
293
293
|
$pageNumber: Int!
|
|
294
294
|
$pageSize: Int!
|
|
295
295
|
$sorts: [BaseSort]
|
|
296
296
|
$attributes: JSON
|
|
297
|
+
$fromDate: DateCustom
|
|
298
|
+
$toDate: DateCustom
|
|
297
299
|
) {
|
|
298
300
|
getWorkEfforts(
|
|
299
301
|
partnerId: $partnerId
|
|
300
302
|
performerId: $performerId
|
|
301
|
-
|
|
302
|
-
|
|
303
|
+
workflowId: $workflowId
|
|
304
|
+
group: $group
|
|
303
305
|
pageNumber: $pageNumber
|
|
304
306
|
pageSize: $pageSize
|
|
305
307
|
sorts: $sorts
|
|
306
308
|
attributes: $attributes
|
|
309
|
+
fromDate: $fromDate
|
|
310
|
+
toDate: $toDate
|
|
307
311
|
) {
|
|
308
312
|
total
|
|
309
313
|
data {
|
|
@@ -320,7 +324,6 @@ exports.GET_WORK_EFFORTS = (0, graphql_tag_1.gql) `
|
|
|
320
324
|
description
|
|
321
325
|
status
|
|
322
326
|
parentId
|
|
323
|
-
workEffortTypeId
|
|
324
327
|
stmId
|
|
325
328
|
workflowId
|
|
326
329
|
endDateExpect
|
package/dist/src/lib/SDK.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ import { AuthorizationService } from "./token";
|
|
|
22
22
|
import { ZcaService } from "./zca";
|
|
23
23
|
import { CashbookService } from "./cashbook";
|
|
24
24
|
import { StoreService } from "./store";
|
|
25
|
+
import { FileServiceSerVice } from "./fileService";
|
|
25
26
|
export interface Endpoints {
|
|
26
27
|
product: string;
|
|
27
28
|
crm: string;
|
|
@@ -47,6 +48,7 @@ export interface Endpoints {
|
|
|
47
48
|
zca: string;
|
|
48
49
|
cashbook: string;
|
|
49
50
|
store: string;
|
|
51
|
+
fileService: string;
|
|
50
52
|
}
|
|
51
53
|
export declare class SDK {
|
|
52
54
|
orgId: string;
|
|
@@ -76,6 +78,7 @@ export declare class SDK {
|
|
|
76
78
|
zca: ZcaService;
|
|
77
79
|
cashbook: CashbookService;
|
|
78
80
|
store: StoreService;
|
|
81
|
+
fileService: FileServiceSerVice;
|
|
79
82
|
token: string | null;
|
|
80
83
|
constructor(orgId: string, storeId: string, environment: "dev" | "live");
|
|
81
84
|
setToken(token: string): void;
|
package/dist/src/lib/SDK.js
CHANGED
|
@@ -27,6 +27,7 @@ const token_1 = require("./token");
|
|
|
27
27
|
const zca_1 = require("./zca");
|
|
28
28
|
const cashbook_1 = require("./cashbook");
|
|
29
29
|
const store_1 = require("./store");
|
|
30
|
+
const fileService_1 = require("./fileService");
|
|
30
31
|
class SDK {
|
|
31
32
|
constructor(orgId, storeId, environment) {
|
|
32
33
|
this.orgId = orgId;
|
|
@@ -58,6 +59,7 @@ class SDK {
|
|
|
58
59
|
this.zca = new zca_1.ZcaService(endpoints.zca, orgId, storeId);
|
|
59
60
|
this.cashbook = new cashbook_1.CashbookService(endpoints.cashbook, orgId, storeId);
|
|
60
61
|
this.store = new store_1.StoreService(endpoints.store, orgId, storeId); // Using product endpoint for now
|
|
62
|
+
this.fileService = new fileService_1.FileServiceSerVice(endpoints.fileService, orgId, storeId);
|
|
61
63
|
// Initialize other services here
|
|
62
64
|
}
|
|
63
65
|
setToken(token) {
|
|
@@ -88,6 +90,7 @@ class SDK {
|
|
|
88
90
|
this.zca.setToken(token);
|
|
89
91
|
this.cashbook.setToken(token);
|
|
90
92
|
this.store.setToken(token);
|
|
93
|
+
this.fileService.setToken(token);
|
|
91
94
|
}
|
|
92
95
|
// các module export từ serviceSDK.ts set storeId vào serviceSDK.ts
|
|
93
96
|
// src/service.ts
|
|
@@ -115,6 +118,7 @@ class SDK {
|
|
|
115
118
|
this.zca.setStoreId(storeId);
|
|
116
119
|
this.cashbook.setStoreId(storeId);
|
|
117
120
|
this.store.setStoreId(storeId);
|
|
121
|
+
this.fileService.setStoreId(storeId);
|
|
118
122
|
// Set storeId for other services here
|
|
119
123
|
}
|
|
120
124
|
setOrgId(orgId) {
|
|
@@ -141,6 +145,7 @@ class SDK {
|
|
|
141
145
|
this.zca.setOrgId(orgId);
|
|
142
146
|
this.cashbook.setOrgId(orgId);
|
|
143
147
|
this.store.setOrgId(orgId);
|
|
148
|
+
this.fileService.setOrgId(orgId);
|
|
144
149
|
}
|
|
145
150
|
}
|
|
146
151
|
exports.SDK = SDK;
|
|
@@ -10,7 +10,7 @@ export declare class CrmService extends Service {
|
|
|
10
10
|
updateStatusAttachmentById(performerId: string, attachmentId: string, status: string): Promise<any>;
|
|
11
11
|
updateWorkEffortDescription(performerId: string, workEffortId: string, description: string): Promise<any>;
|
|
12
12
|
updateWorkEffortName(performerId: string, workEffortId: string, name: string): Promise<any>;
|
|
13
|
-
updateWorkEffortStatus(performerId: string, workEffortId: string,
|
|
13
|
+
updateWorkEffortStatus(performerId: string, workEffortId: string, group: string, status: string): Promise<any>;
|
|
14
14
|
addAttachmentForWorkEffort(performerId: string, workEffortId: string, addAttachmentRequest: AddAttachmentRequest): Promise<any>;
|
|
15
15
|
getListTicket(performerId: string, getTicketRequest: getTicketRequest): Promise<any>;
|
|
16
16
|
addTicket(performerId: string, addTicketRequest: AddTicketRequest, addAttachmentRequest: [AddAttachmentRequest]): Promise<any>;
|
|
@@ -18,9 +18,9 @@ export declare class CrmService extends Service {
|
|
|
18
18
|
getAttachmentByWorkEffortId(workEffortIds: [string]): Promise<any>;
|
|
19
19
|
getListComment(getCommentRequest: GetCommentRequest): Promise<any>;
|
|
20
20
|
addComment(params: any): Promise<any>;
|
|
21
|
-
createWorkEffort(createdBy: string, name: String, decription: string,
|
|
21
|
+
createWorkEffort(createdBy: string, name: String, decription: string, workflowId: string, group: string, attributes: object): Promise<any>;
|
|
22
22
|
createWorkEffortV2(createdBy: string, name: string, decription: string, workEffortTypeId: string, source: string): Promise<any>;
|
|
23
|
-
getWorkEfforts(performerId: string,
|
|
23
|
+
getWorkEfforts(performerId: string, workflowId: string, group: string, pageNumber: number, pageSize: number, sorts: BaseSort, attributes: object, fromDate: any, toDate: any): Promise<any>;
|
|
24
24
|
getWorkEffortsV2(performerId: string, workEffortTypeId: string, source: string, fromDate: string, toDate: string): Promise<any>;
|
|
25
25
|
getWorkEffortById(id: string): Promise<any>;
|
|
26
26
|
updateWorkEffortProcessStatus(workEffortId: string, processStatus: string, performerId: string): Promise<any>;
|
|
@@ -145,14 +145,14 @@ class CrmService extends serviceSDK_1.Service {
|
|
|
145
145
|
}
|
|
146
146
|
});
|
|
147
147
|
}
|
|
148
|
-
updateWorkEffortStatus(performerId, workEffortId,
|
|
148
|
+
updateWorkEffortStatus(performerId, workEffortId, group, status) {
|
|
149
149
|
return __awaiter(this, void 0, void 0, function* () {
|
|
150
150
|
const mutation = mutations_1.UPDATE_WORK_EFFORT_STATUS;
|
|
151
151
|
const variables = {
|
|
152
152
|
partyId: this.orgId,
|
|
153
153
|
performerId,
|
|
154
154
|
workEffortId,
|
|
155
|
-
|
|
155
|
+
group,
|
|
156
156
|
status,
|
|
157
157
|
};
|
|
158
158
|
try {
|
|
@@ -292,7 +292,7 @@ class CrmService extends serviceSDK_1.Service {
|
|
|
292
292
|
}
|
|
293
293
|
});
|
|
294
294
|
}
|
|
295
|
-
createWorkEffort(createdBy, name, decription,
|
|
295
|
+
createWorkEffort(createdBy, name, decription, workflowId, group, attributes) {
|
|
296
296
|
return __awaiter(this, void 0, void 0, function* () {
|
|
297
297
|
const query = mutations_1.CREATE_WORK_EFFORT;
|
|
298
298
|
const variables = {
|
|
@@ -300,11 +300,9 @@ class CrmService extends serviceSDK_1.Service {
|
|
|
300
300
|
createdBy,
|
|
301
301
|
name,
|
|
302
302
|
decription,
|
|
303
|
-
|
|
304
|
-
|
|
303
|
+
workflowId,
|
|
304
|
+
group,
|
|
305
305
|
attributes,
|
|
306
|
-
addAttachmentRequest,
|
|
307
|
-
parentId,
|
|
308
306
|
};
|
|
309
307
|
try {
|
|
310
308
|
const response = yield this.graphqlMutationV2(query, variables);
|
|
@@ -335,18 +333,20 @@ class CrmService extends serviceSDK_1.Service {
|
|
|
335
333
|
}
|
|
336
334
|
});
|
|
337
335
|
}
|
|
338
|
-
getWorkEfforts(performerId,
|
|
336
|
+
getWorkEfforts(performerId, workflowId, group, pageNumber, pageSize, sorts, attributes, fromDate, toDate) {
|
|
339
337
|
return __awaiter(this, void 0, void 0, function* () {
|
|
340
338
|
const query = queries_1.GET_WORK_EFFORTS;
|
|
341
339
|
const variables = {
|
|
342
340
|
partnerId: this.orgId,
|
|
343
341
|
performerId,
|
|
344
|
-
|
|
345
|
-
|
|
342
|
+
workflowId,
|
|
343
|
+
group,
|
|
346
344
|
pageNumber,
|
|
347
345
|
pageSize,
|
|
348
346
|
sorts,
|
|
349
347
|
attributes,
|
|
348
|
+
fromDate,
|
|
349
|
+
toDate,
|
|
350
350
|
};
|
|
351
351
|
try {
|
|
352
352
|
const response = yield this.graphqlQueryV2(query, variables);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Service } from "../serviceSDK";
|
|
2
|
+
export interface UploadFileRequest {
|
|
3
|
+
uploadFile: File;
|
|
4
|
+
path: string;
|
|
5
|
+
parentId?: string;
|
|
6
|
+
parentType?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface UploadFileResponse {
|
|
9
|
+
fileName: string;
|
|
10
|
+
filePath: string;
|
|
11
|
+
fileSize: number;
|
|
12
|
+
}
|
|
13
|
+
export declare class FileServiceSerVice extends Service {
|
|
14
|
+
constructor(endpoint: string, orgId: string, storeId: string);
|
|
15
|
+
/**
|
|
16
|
+
* Upload file to the file service
|
|
17
|
+
* @param uploadFile - File object to upload
|
|
18
|
+
* @param path - Directory path to save the file
|
|
19
|
+
* @param parentId - Reference ID of parent object (optional)
|
|
20
|
+
* @param parentType - Type of parent object reference (optional)
|
|
21
|
+
* @returns Promise<UploadFileResponse>
|
|
22
|
+
*/
|
|
23
|
+
uploadFile(uploadFile: File, path: string, parentId?: string, parentType?: string): Promise<UploadFileResponse>;
|
|
24
|
+
/**
|
|
25
|
+
* Upload image file (convenience method)
|
|
26
|
+
* @param imageFile - Image file to upload
|
|
27
|
+
* @param path - Directory path to save the image (default: "public")
|
|
28
|
+
* @param parentId - Reference ID of parent object (optional)
|
|
29
|
+
* @param parentType - Type of parent object reference (optional)
|
|
30
|
+
* @returns Promise<UploadFileResponse>
|
|
31
|
+
*/
|
|
32
|
+
uploadImage(imageFile: File, path?: string, parentId?: string, parentType?: string): Promise<UploadFileResponse>;
|
|
33
|
+
getImage(parentId: string, parenttype: string): Promise<any>;
|
|
34
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
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.FileServiceSerVice = void 0;
|
|
13
|
+
const serviceSDK_1 = require("../serviceSDK");
|
|
14
|
+
class FileServiceSerVice extends serviceSDK_1.Service {
|
|
15
|
+
constructor(endpoint, orgId, storeId) {
|
|
16
|
+
super(endpoint, orgId, storeId);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Upload file to the file service
|
|
20
|
+
* @param uploadFile - File object to upload
|
|
21
|
+
* @param path - Directory path to save the file
|
|
22
|
+
* @param parentId - Reference ID of parent object (optional)
|
|
23
|
+
* @param parentType - Type of parent object reference (optional)
|
|
24
|
+
* @returns Promise<UploadFileResponse>
|
|
25
|
+
*/
|
|
26
|
+
uploadFile(uploadFile, path, parentId, parentType) {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
const endpoint = `/omnichannel/files/upload`;
|
|
29
|
+
const method = "POST";
|
|
30
|
+
try {
|
|
31
|
+
const formData = new FormData();
|
|
32
|
+
formData.append("uploadFile", uploadFile);
|
|
33
|
+
formData.append("path", path);
|
|
34
|
+
if (parentId) {
|
|
35
|
+
formData.append("parentId", parentId);
|
|
36
|
+
}
|
|
37
|
+
if (parentType) {
|
|
38
|
+
formData.append("parentType", parentType);
|
|
39
|
+
}
|
|
40
|
+
const response = yield this.restApiCallWithNoHeader(endpoint, method, formData);
|
|
41
|
+
return response;
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
console.error("Error uploading file:", error);
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Upload image file (convenience method)
|
|
51
|
+
* @param imageFile - Image file to upload
|
|
52
|
+
* @param path - Directory path to save the image (default: "public")
|
|
53
|
+
* @param parentId - Reference ID of parent object (optional)
|
|
54
|
+
* @param parentType - Type of parent object reference (optional)
|
|
55
|
+
* @returns Promise<UploadFileResponse>
|
|
56
|
+
*/
|
|
57
|
+
uploadImage(imageFile_1) {
|
|
58
|
+
return __awaiter(this, arguments, void 0, function* (imageFile, path = "public", parentId, parentType) {
|
|
59
|
+
// Validate that the file is an image
|
|
60
|
+
if (!imageFile.type.startsWith("image/")) {
|
|
61
|
+
throw new Error("File must be an image");
|
|
62
|
+
}
|
|
63
|
+
return this.uploadFile(imageFile, path, parentId, parentType);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
getImage(parentId, parenttype) {
|
|
67
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
const endpoint = `/omnichannel/files/gets/${parentId}/${parenttype}`;
|
|
69
|
+
const method = "GET";
|
|
70
|
+
try {
|
|
71
|
+
const response = yield this.restApiCallWithNoHeader(endpoint, method);
|
|
72
|
+
return response;
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
throw error;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.FileServiceSerVice = FileServiceSerVice;
|