@longvansoftware/storefront-js-client 3.1.2 → 3.1.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.
@@ -23,6 +23,7 @@ export declare const environmentEndpoints: {
23
23
  authorization: string;
24
24
  zca: string;
25
25
  cashbook: string;
26
+ store: string;
26
27
  };
27
28
  live: {
28
29
  product: string;
@@ -48,5 +49,6 @@ export declare const environmentEndpoints: {
48
49
  authorization: string;
49
50
  zca: string;
50
51
  cashbook: string;
52
+ store: string;
51
53
  };
52
54
  };
@@ -25,7 +25,8 @@ exports.environmentEndpoints = {
25
25
  omnigateway: "https://omni-gateway.dev.longvan.vn/omni-gateway/v1",
26
26
  authorization: "https://id.dev.longvan.vn/authorization/public",
27
27
  zca: "https://zca.dev.longvan.vn",
28
- cashbook: 'https://api-gateway.dev.longvan.vn/cashbook-service/graphql'
28
+ cashbook: 'https://api-gateway.dev.longvan.vn/cashbook-service/graphql',
29
+ store: "https://storefront.dev.longvan.vn/v2"
29
30
  },
30
31
  live: {
31
32
  product: "https://product-service.longvan.vn/product-service/graphql",
@@ -50,6 +51,7 @@ exports.environmentEndpoints = {
50
51
  omnigateway: "https://omni-gateway.longvan.vn/omni-gateway/v1",
51
52
  authorization: "https://id.longvan.vn/authorization/public",
52
53
  zca: "https://zca.longvan.vn",
53
- cashbook: 'https://api-gateway.dev.longvan.vn/cashbook-service/graphql'
54
+ cashbook: 'https://api-gateway.dev.longvan.vn/cashbook-service/graphql',
55
+ store: "https://storefront.longvan.vn/v2"
54
56
  },
55
57
  };
@@ -98,7 +98,7 @@ exports.UPDATE_PASSWORD_MUTATION = `
98
98
  }
99
99
  `;
100
100
  exports.CREATE_PASSWORD_MUTATION = (0, graphql_tag_1.gql) `
101
- mutation CreatePassword($orgId: String!, $accessToken: String!, $password: String!) {
101
+ mutation CreatePassword($orgId: String, $accessToken: String, $password: String) {
102
102
  updateInfo(orgId: $orgId, accessToken: $accessToken, password: $password) {
103
103
  partyId
104
104
  fullName
@@ -1,5 +1,4 @@
1
1
  import { Service } from "../serviceSDK";
2
- import type { StoreDTO } from "../../types/store";
3
2
  /**
4
3
  * Service class for managing store-related operations.
5
4
  */
@@ -11,20 +10,21 @@ export declare class StoreService extends Service {
11
10
  * @param storeId - The store ID.
12
11
  */
13
12
  constructor(endpoint: string, orgId: string, storeId: string);
13
+ setToken(token: string): void;
14
14
  /**
15
- * Creates a new store.
16
- * @param partnerId - The partner ID.
17
- * @param storeName - The name of the store to create.
18
- * @returns A promise that resolves to the created store data.
19
- * @throws Will throw an error if the GraphQL mutation fails.
15
+ * Creates a store channel.
16
+ *
17
+ * @param storeChannelData - The data for creating the store channel.
18
+ * @returns A promise that resolves to the created store channel response.
19
+ * @throws If an error occurs while creating the store channel.
20
20
  */
21
- createStore(partnerId: string, storeName: string): Promise<StoreDTO>;
21
+ createStoreChannel(storeChannelData: any): Promise<any>;
22
22
  /**
23
- * Gets store channels by employee ID.
24
- * If user has high permissions, will return all channels.
25
- * @param saleId - The employee/sale ID.
26
- * @returns A promise that resolves to an array of store data.
27
- * @throws Will throw an error if the GraphQL query fails.
23
+ * Gets available store channels for an employee.
24
+ *
25
+ * @param empId - The employee ID.
26
+ * @returns A promise that resolves to the available store channels.
27
+ * @throws If an error occurs while fetching the store channels.
28
28
  */
29
- getStoreChannelByEmpId(saleId: string): Promise<StoreDTO[]>;
29
+ getAvailableStoreChannels(empId: string): Promise<any>;
30
30
  }
@@ -25,146 +25,47 @@ class StoreService extends serviceSDK_1.Service {
25
25
  constructor(endpoint, orgId, storeId) {
26
26
  super(endpoint, orgId, storeId);
27
27
  }
28
+ setToken(token) {
29
+ this.token = token;
30
+ }
28
31
  /**
29
- * Creates a new store.
30
- * @param partnerId - The partner ID.
31
- * @param storeName - The name of the store to create.
32
- * @returns A promise that resolves to the created store data.
33
- * @throws Will throw an error if the GraphQL mutation fails.
32
+ * Creates a store channel.
33
+ *
34
+ * @param storeChannelData - The data for creating the store channel.
35
+ * @returns A promise that resolves to the created store channel response.
36
+ * @throws If an error occurs while creating the store channel.
34
37
  */
35
- createStore(partnerId, storeName) {
38
+ createStoreChannel(storeChannelData) {
36
39
  return __awaiter(this, void 0, void 0, function* () {
37
- // Mock data for now
38
- const mockStoreData = {
39
- id: `store-${Date.now()}`,
40
- createdStamp: new Date().toISOString(),
41
- name: storeName,
42
- type: "pos",
43
- enable: true,
44
- partyId: partnerId,
45
- warehouses: [
46
- "1699410559510051",
47
- "1701063268074130",
48
- "1710863353245977"
49
- ],
50
- warehouseIdDefault: "1701063268074130",
51
- enableOrderAbleFuture: false,
52
- enableOrderNegativeQuantity: false,
53
- storeEcommerceName: null,
54
- shippingCompanies: [
55
- "1680338339238",
56
- "20.10008",
57
- "20.10009",
58
- "20.10010"
59
- ],
60
- shippingCompanyIdPrimary: "1680338339238",
61
- customerIdPrimary: "20.52415",
62
- paymentMethodIdPrimary: "231123143230155ypCQ7vC4",
63
- enableCustomProductPrice: true,
64
- enablePaymentPartial: true,
65
- paymentPartialPercent: [10],
66
- productStoreLink: null,
67
- __typename: "ProductStore"
68
- };
40
+ const endpoint = `/store-channels/${this.orgId}`;
41
+ const method = "POST";
69
42
  try {
70
- // TODO: Replace with actual GraphQL mutation when ready
71
- // const variables = { partnerId, storeName };
72
- // const response = await this.graphqlMutation(CREATE_STORE_MUTATION, variables);
73
- // return response.createStore;
74
- // Return mock data for now
75
- console.log(`Creating store: ${storeName} for partner: ${partnerId}`);
76
- return mockStoreData;
43
+ const response = yield this.restApiCallWithToken(endpoint, method, Object.assign(Object.assign({}, storeChannelData), { partyId: this.orgId }));
44
+ return response;
77
45
  }
78
46
  catch (error) {
79
- console.log(`Error in createStore: ${error}`);
47
+ console.log(`Error in createStoreChannel: ${error}`);
80
48
  throw error;
81
49
  }
82
50
  });
83
51
  }
84
52
  /**
85
- * Gets store channels by employee ID.
86
- * If user has high permissions, will return all channels.
87
- * @param saleId - The employee/sale ID.
88
- * @returns A promise that resolves to an array of store data.
89
- * @throws Will throw an error if the GraphQL query fails.
53
+ * Gets available store channels for an employee.
54
+ *
55
+ * @param empId - The employee ID.
56
+ * @returns A promise that resolves to the available store channels.
57
+ * @throws If an error occurs while fetching the store channels.
90
58
  */
91
- getStoreChannelByEmpId(saleId) {
59
+ getAvailableStoreChannels(empId) {
92
60
  return __awaiter(this, void 0, void 0, function* () {
93
- // Mock data for now
94
- const mockStoreChannels = [
95
- {
96
- id: "pos-nowzone",
97
- createdStamp: null,
98
- name: "NowZone",
99
- type: "pos",
100
- enable: true,
101
- partyId: "FOX",
102
- warehouses: [
103
- "1699410559510051",
104
- "1701063268074130",
105
- "1710863353245977",
106
- "1708420902576454",
107
- "1708414435504879"
108
- ],
109
- warehouseIdDefault: "1701063268074130",
110
- enableOrderAbleFuture: false,
111
- enableOrderNegativeQuantity: false,
112
- storeEcommerceName: null,
113
- shippingCompanies: [
114
- "1680338339238",
115
- "20.10008",
116
- "20.10009",
117
- "20.10010"
118
- ],
119
- shippingCompanyIdPrimary: "1680338339238",
120
- customerIdPrimary: "20.52415",
121
- paymentMethodIdPrimary: "231123143230155ypCQ7vC4",
122
- enableCustomProductPrice: true,
123
- enablePaymentPartial: true,
124
- paymentPartialPercent: [10],
125
- productStoreLink: null,
126
- __typename: "ProductStore"
127
- },
128
- {
129
- id: "ecommerce-main",
130
- createdStamp: "2024-01-15T10:30:00Z",
131
- name: "Main E-commerce Store",
132
- type: "ecommerce",
133
- enable: true,
134
- partyId: "FOX",
135
- warehouses: [
136
- "1699410559510051",
137
- "1701063268074130"
138
- ],
139
- warehouseIdDefault: "1699410559510051",
140
- enableOrderAbleFuture: true,
141
- enableOrderNegativeQuantity: false,
142
- storeEcommerceName: "fox-ecommerce",
143
- shippingCompanies: [
144
- "1680338339238",
145
- "20.10008"
146
- ],
147
- shippingCompanyIdPrimary: "1680338339238",
148
- customerIdPrimary: "20.52415",
149
- paymentMethodIdPrimary: "231123143230155ypCQ7vC4",
150
- enableCustomProductPrice: false,
151
- enablePaymentPartial: true,
152
- paymentPartialPercent: [20, 50],
153
- productStoreLink: "https://fox-store.com",
154
- __typename: "ProductStore"
155
- }
156
- ];
61
+ const endpoint = `/store-channels/${this.orgId}/available/${empId}`;
62
+ const method = "GET";
157
63
  try {
158
- // TODO: Replace with actual GraphQL query when ready
159
- // const variables = { saleId };
160
- // const response = await this.graphqlQuery(GET_STORE_CHANNEL_BY_EMP_ID_QUERY, variables);
161
- // return response.getStoreChannelByEmpId;
162
- // Return mock data for now
163
- console.log(`Getting store channels for employee: ${saleId}`);
164
- return mockStoreChannels;
64
+ const response = yield this.restApiCallWithToken(endpoint, method);
65
+ return response;
165
66
  }
166
67
  catch (error) {
167
- console.log(`Error in getStoreChannelByEmpId: ${error}`);
68
+ console.log(`Error in getAvailableStoreChannels: ${error}`);
168
69
  throw error;
169
70
  }
170
71
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longvansoftware/storefront-js-client",
3
- "version": "3.1.2",
3
+ "version": "3.1.4",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "files": [