@longvansoftware/storefront-js-client 3.2.3 → 3.2.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.
@@ -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
  };
@@ -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
  };
@@ -405,7 +405,6 @@ exports.CREATE_WORK_EFFORT = (0, graphql_tag_1.gql) `
405
405
  $workEffortTypeId: String!
406
406
  $source: String!
407
407
  $attributes: JSON
408
- $addAttachmentRequest: [AddAttachmentRequest]
409
408
  $parentId: String
410
409
  ) {
411
410
  createWorkEffort(
@@ -416,7 +415,6 @@ exports.CREATE_WORK_EFFORT = (0, graphql_tag_1.gql) `
416
415
  workEffortTypeId: $workEffortTypeId
417
416
  source: $source
418
417
  attributes: $attributes
419
- addAttachmentRequest: $addAttachmentRequest
420
418
  parentId: $parentId
421
419
  ) {
422
420
  id
@@ -294,6 +294,8 @@ exports.GET_WORK_EFFORTS = (0, graphql_tag_1.gql) `
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
@@ -304,6 +306,8 @@ exports.GET_WORK_EFFORTS = (0, graphql_tag_1.gql) `
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 {
@@ -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;
@@ -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;
@@ -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, workEffortTypeId: string, source: string, attributes: object, addAttachmentRequest: AddAttachmentRequest, parentId?: string): Promise<any>;
21
+ createWorkEffort(createdBy: string, name: String, decription: string, workEffortTypeId: string, source: string, attributes: object, parentId?: string): Promise<any>;
22
22
  createWorkEffortV2(createdBy: string, name: string, decription: string, workEffortTypeId: string, source: string): Promise<any>;
23
- getWorkEfforts(performerId: string, workEffortTypeId: string, source: string, pageNumber: number, pageSize: number, sorts: BaseSort, attributes: object): Promise<any>;
23
+ getWorkEfforts(performerId: string, workEffortTypeId: string, source: 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>;
@@ -292,7 +292,7 @@ class CrmService extends serviceSDK_1.Service {
292
292
  }
293
293
  });
294
294
  }
295
- createWorkEffort(createdBy, name, decription, workEffortTypeId, source, attributes, addAttachmentRequest, parentId) {
295
+ createWorkEffort(createdBy, name, decription, workEffortTypeId, source, attributes, parentId) {
296
296
  return __awaiter(this, void 0, void 0, function* () {
297
297
  const query = mutations_1.CREATE_WORK_EFFORT;
298
298
  const variables = {
@@ -303,7 +303,6 @@ class CrmService extends serviceSDK_1.Service {
303
303
  workEffortTypeId,
304
304
  source,
305
305
  attributes,
306
- addAttachmentRequest,
307
306
  parentId,
308
307
  };
309
308
  try {
@@ -335,7 +334,7 @@ class CrmService extends serviceSDK_1.Service {
335
334
  }
336
335
  });
337
336
  }
338
- getWorkEfforts(performerId, workEffortTypeId, source, pageNumber, pageSize, sorts, attributes) {
337
+ getWorkEfforts(performerId, workEffortTypeId, source, pageNumber, pageSize, sorts, attributes, fromDate, toDate) {
339
338
  return __awaiter(this, void 0, void 0, function* () {
340
339
  const query = queries_1.GET_WORK_EFFORTS;
341
340
  const variables = {
@@ -347,6 +346,8 @@ class CrmService extends serviceSDK_1.Service {
347
346
  pageSize,
348
347
  sorts,
349
348
  attributes,
349
+ fromDate,
350
+ toDate,
350
351
  };
351
352
  try {
352
353
  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 = `/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 = `/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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longvansoftware/storefront-js-client",
3
- "version": "3.2.3",
3
+ "version": "3.2.5",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "files": [