@longvansoftware/storefront-js-client 1.3.6 → 1.3.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/README.md +93 -93
- package/dist/config/config.d.ts +4 -0
- package/dist/config/config.js +4 -0
- package/dist/src/graphql/auth/mutations.js +88 -88
- package/dist/src/graphql/auth/queries.js +20 -20
- package/dist/src/graphql/crm/mutations.js +253 -248
- package/dist/src/graphql/crm/queries.js +148 -148
- package/dist/src/graphql/payment/mutations.js +30 -30
- package/dist/src/graphql/payment/queries.js +17 -17
- package/dist/src/graphql/product/queries.js +322 -322
- package/dist/src/graphql/service/mutations.d.ts +8 -0
- package/dist/src/graphql/service/mutations.js +203 -0
- package/dist/src/graphql/service/queries.d.ts +4 -0
- package/dist/src/graphql/service/queries.js +154 -0
- package/dist/src/graphql/user/mutations.js +110 -110
- package/dist/src/graphql/user/queries.js +60 -60
- package/dist/src/lib/SDK.d.ts +6 -0
- package/dist/src/lib/SDK.js +6 -0
- package/dist/src/lib/auth/index.d.ts +1 -1
- package/dist/src/lib/auth/index.js +2 -2
- package/dist/src/lib/crm/index.d.ts +1 -1
- package/dist/src/lib/crm/index.js +2 -2
- package/dist/src/lib/order/index.d.ts +1 -1
- package/dist/src/lib/order/index.js +19 -2
- package/dist/src/lib/payment/index.d.ts +1 -1
- package/dist/src/lib/payment/index.js +2 -2
- package/dist/src/lib/product/index.d.ts +1 -1
- package/dist/src/lib/product/index.js +2 -2
- package/dist/src/lib/service/index.d.ts +91 -0
- package/dist/src/lib/service/index.js +298 -0
- package/dist/src/lib/service.js +4 -4
- package/dist/src/lib/serviceSDK.d.ts +15 -0
- package/dist/src/lib/serviceSDK.js +117 -0
- package/dist/src/lib/user/index.d.ts +1 -1
- package/dist/src/lib/user/index.js +2 -2
- package/dist/src/lib/warehouse/index.d.ts +20 -0
- package/dist/src/lib/warehouse/index.js +48 -0
- package/dist/src/types/order.d.ts +2 -2
- package/dist/src/types/service.d.ts +28 -0
- package/dist/src/types/service.js +2 -0
- package/dist/src/types/warehouse.d.ts +5 -0
- package/dist/src/types/warehouse.js +2 -0
- package/package.json +42 -42
|
@@ -0,0 +1,298 @@
|
|
|
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.ServiceManagementService = void 0;
|
|
13
|
+
const serviceSDK_1 = require("../serviceSDK");
|
|
14
|
+
const queries_1 = require("../../graphql/service/queries");
|
|
15
|
+
const mutations_1 = require("../../graphql/service/mutations");
|
|
16
|
+
class ServiceManagementService extends serviceSDK_1.Service {
|
|
17
|
+
/**
|
|
18
|
+
* Constructs a new ProductService instance.
|
|
19
|
+
* @param endpoint - The endpoint URL for the service.
|
|
20
|
+
* @param orgId - The organization ID.
|
|
21
|
+
* @param storeId - The store ID.
|
|
22
|
+
*/
|
|
23
|
+
constructor(endpoint, orgId, storeId) {
|
|
24
|
+
super(endpoint, orgId, storeId);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* get service by id .
|
|
28
|
+
* @param serviceId - The id of the service
|
|
29
|
+
*/
|
|
30
|
+
getServiceById(serviceId) {
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
const query = queries_1.GET_SERVICE_BY_ID;
|
|
33
|
+
const variables = {
|
|
34
|
+
partnerId: this.orgId,
|
|
35
|
+
serviceId,
|
|
36
|
+
};
|
|
37
|
+
try {
|
|
38
|
+
const response = yield this.graphqlQuery(query, variables);
|
|
39
|
+
return response.getServiceById;
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
console.log(`Error in getServiceById: ${error}`);
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* get service by type
|
|
49
|
+
* @param type - The endpoint URL for the service.
|
|
50
|
+
*/
|
|
51
|
+
getServiceByType(type) {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
const query = queries_1.GET_SERVICE_BY_TYPE;
|
|
54
|
+
const variables = {
|
|
55
|
+
partnerId: this.orgId,
|
|
56
|
+
type,
|
|
57
|
+
};
|
|
58
|
+
try {
|
|
59
|
+
const response = yield this.graphqlQuery(query, variables);
|
|
60
|
+
return response.getServiceByType;
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
console.log(`Error in getServiceByType :${error}`);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* get service by owner id
|
|
69
|
+
* @param ownerId - The endpoint URL for the service.
|
|
70
|
+
*/
|
|
71
|
+
getServiceByOwnerId(ownerId) {
|
|
72
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
73
|
+
const query = queries_1.GET_SERVICE_BY_OWNER_ID;
|
|
74
|
+
const variables = {
|
|
75
|
+
partnerId: this.orgId,
|
|
76
|
+
ownerId,
|
|
77
|
+
};
|
|
78
|
+
try {
|
|
79
|
+
const response = yield this.graphqlQuery(query, variables);
|
|
80
|
+
return response.getServiceByOwnerId;
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
console.log(`Error in getServiceByOwnerId :${error}`);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* get service actions
|
|
89
|
+
* @param serviceId -
|
|
90
|
+
* @param actionType
|
|
91
|
+
* @param updatedBy
|
|
92
|
+
*/
|
|
93
|
+
getServiceActions(serviceId) {
|
|
94
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
+
const query = queries_1.GET_SERVICE_ACTION;
|
|
96
|
+
const variables = {
|
|
97
|
+
serviceId: serviceId,
|
|
98
|
+
};
|
|
99
|
+
try {
|
|
100
|
+
const response = yield this.graphqlQuery(query, variables);
|
|
101
|
+
return response.getServiceActions;
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
throw error;
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* create service
|
|
110
|
+
* @param data
|
|
111
|
+
*/
|
|
112
|
+
createService(data) {
|
|
113
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
114
|
+
const mutation = mutations_1.CREATE_SERVICE;
|
|
115
|
+
const variables = {
|
|
116
|
+
partnerId: this.orgId,
|
|
117
|
+
createModel: data,
|
|
118
|
+
};
|
|
119
|
+
try {
|
|
120
|
+
const response = yield this.graphqlMutation(mutation, variables);
|
|
121
|
+
return response.createService;
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
throw error;
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* create service
|
|
130
|
+
* @param data
|
|
131
|
+
* @param serviceId
|
|
132
|
+
* @param updatedBy
|
|
133
|
+
*/
|
|
134
|
+
updateService(data, serviceId, updatedBy) {
|
|
135
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
136
|
+
const mutation = mutations_1.UPDATE_SERVICE;
|
|
137
|
+
const variables = {
|
|
138
|
+
partnerId: this.orgId,
|
|
139
|
+
serviceId: serviceId,
|
|
140
|
+
updateModel: data,
|
|
141
|
+
updatedBy: updatedBy,
|
|
142
|
+
};
|
|
143
|
+
try {
|
|
144
|
+
const response = yield this.graphqlMutation(mutation, variables);
|
|
145
|
+
return response.updateService;
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
throw error;
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* delete service
|
|
154
|
+
* @param serviceId
|
|
155
|
+
* @param deletedBy
|
|
156
|
+
*/
|
|
157
|
+
deleteService(serviceId, deletedBy) {
|
|
158
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
159
|
+
const mutation = mutations_1.DELETE_SERVICE;
|
|
160
|
+
const variables = {
|
|
161
|
+
partnerId: this.orgId,
|
|
162
|
+
serviceId: serviceId,
|
|
163
|
+
deletedBy: deletedBy,
|
|
164
|
+
};
|
|
165
|
+
try {
|
|
166
|
+
const response = yield this.graphqlMutation(mutation, variables);
|
|
167
|
+
return response.deleteService;
|
|
168
|
+
}
|
|
169
|
+
catch (error) {
|
|
170
|
+
throw error;
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* update attr value
|
|
176
|
+
* @param serviceId
|
|
177
|
+
* @param attrName
|
|
178
|
+
* @param attrValue
|
|
179
|
+
* @param updatedBy
|
|
180
|
+
*/
|
|
181
|
+
updateAttrValue(serviceId, attrName, attrValue, updatedBy) {
|
|
182
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
183
|
+
const mutation = mutations_1.UPDATE_ATTR_VALUE;
|
|
184
|
+
const variables = {
|
|
185
|
+
partnerId: this.orgId,
|
|
186
|
+
serviceId: serviceId,
|
|
187
|
+
attrName: attrName,
|
|
188
|
+
attrValue: attrValue,
|
|
189
|
+
updatedBy: updatedBy,
|
|
190
|
+
};
|
|
191
|
+
try {
|
|
192
|
+
const response = yield this.graphqlMutation(mutation, variables);
|
|
193
|
+
return response.updateAttrValue;
|
|
194
|
+
}
|
|
195
|
+
catch (error) {
|
|
196
|
+
throw error;
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* delete attr value
|
|
202
|
+
* @param serviceId
|
|
203
|
+
* @param attrName
|
|
204
|
+
* @param updatedBy
|
|
205
|
+
*/
|
|
206
|
+
deleteAttrValue(serviceId, attrName, updatedBy) {
|
|
207
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
208
|
+
const mutation = mutations_1.DELETE_ATTR_VALUE;
|
|
209
|
+
const variables = {
|
|
210
|
+
partnerId: this.orgId,
|
|
211
|
+
serviceId: serviceId,
|
|
212
|
+
attrName: attrName,
|
|
213
|
+
updatedBy: updatedBy,
|
|
214
|
+
};
|
|
215
|
+
try {
|
|
216
|
+
const response = yield this.graphqlMutation(mutation, variables);
|
|
217
|
+
return response.deleteAttrValue;
|
|
218
|
+
}
|
|
219
|
+
catch (error) {
|
|
220
|
+
throw error;
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* update success action process status
|
|
226
|
+
* @param serviceId
|
|
227
|
+
* @param actionResult
|
|
228
|
+
* @param updatedBy
|
|
229
|
+
*/
|
|
230
|
+
updateSuccessActionProcessStatus(serviceActionId, updatedBy) {
|
|
231
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
232
|
+
const mutation = mutations_1.UPDATE_SUCCESS_ACTION_PROCESS_STATUS;
|
|
233
|
+
const variables = {
|
|
234
|
+
serviceActionId: serviceActionId,
|
|
235
|
+
updatedBy: updatedBy,
|
|
236
|
+
};
|
|
237
|
+
try {
|
|
238
|
+
const response = yield this.graphqlMutation(mutation, variables);
|
|
239
|
+
return response;
|
|
240
|
+
}
|
|
241
|
+
catch (error) {
|
|
242
|
+
throw error;
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* update fail action process status
|
|
248
|
+
* @param serviceId
|
|
249
|
+
* @param actionResult
|
|
250
|
+
* @param updatedBy
|
|
251
|
+
*/
|
|
252
|
+
updateFailActionProcessStatus(serviceActionId, description, updatedBy) {
|
|
253
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
254
|
+
const mutation = mutations_1.UPDATE_FAIL_ACTION_PROCESS_STATUS;
|
|
255
|
+
const variables = {
|
|
256
|
+
serviceActionId: serviceActionId,
|
|
257
|
+
description: description,
|
|
258
|
+
updatedBy: updatedBy,
|
|
259
|
+
};
|
|
260
|
+
try {
|
|
261
|
+
const response = yield this.graphqlMutation(mutation, variables);
|
|
262
|
+
return response;
|
|
263
|
+
}
|
|
264
|
+
catch (error) {
|
|
265
|
+
throw error;
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Creates a service ticket.
|
|
271
|
+
*
|
|
272
|
+
* @param {string} serviceId - The ID of the service.
|
|
273
|
+
* @param {string} name - The name of the service ticket.
|
|
274
|
+
* @param {string} createdBy - The user who created the service ticket.
|
|
275
|
+
* @param {string} description - The description of the service ticket.
|
|
276
|
+
* @returns {Promise<any>} - A promise that resolves to the created service ticket.
|
|
277
|
+
* @throws {Error} - If an error occurs during the creation of the service ticket.
|
|
278
|
+
*/
|
|
279
|
+
createServiceTicket(serviceId, name, createdBy, description) {
|
|
280
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
281
|
+
const mutation = mutations_1.CREATE_SERVICE_TICKET;
|
|
282
|
+
const variables = {
|
|
283
|
+
serviceId,
|
|
284
|
+
name,
|
|
285
|
+
createdBy,
|
|
286
|
+
description,
|
|
287
|
+
};
|
|
288
|
+
try {
|
|
289
|
+
const response = yield this.graphqlMutation(mutation, variables);
|
|
290
|
+
return response.createServiceTicket;
|
|
291
|
+
}
|
|
292
|
+
catch (error) {
|
|
293
|
+
throw error;
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
exports.ServiceManagementService = ServiceManagementService;
|
package/dist/src/lib/service.js
CHANGED
|
@@ -42,8 +42,8 @@ class Service {
|
|
|
42
42
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43
43
|
try {
|
|
44
44
|
const { data, errors } = yield this.client.query({
|
|
45
|
-
query: (0, client_1.gql) `
|
|
46
|
-
${query}
|
|
45
|
+
query: (0, client_1.gql) `
|
|
46
|
+
${query}
|
|
47
47
|
`,
|
|
48
48
|
variables,
|
|
49
49
|
});
|
|
@@ -62,8 +62,8 @@ class Service {
|
|
|
62
62
|
return __awaiter(this, void 0, void 0, function* () {
|
|
63
63
|
try {
|
|
64
64
|
const { data, errors } = yield this.client.mutate({
|
|
65
|
-
mutation: (0, client_1.gql) `
|
|
66
|
-
${mutation}
|
|
65
|
+
mutation: (0, client_1.gql) `
|
|
66
|
+
${mutation}
|
|
67
67
|
`,
|
|
68
68
|
variables,
|
|
69
69
|
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ApolloClient, NormalizedCacheObject } from "@apollo/client";
|
|
2
|
+
import { DocumentNode } from "graphql";
|
|
3
|
+
export declare class Service {
|
|
4
|
+
protected token: string | null;
|
|
5
|
+
protected client: ApolloClient<NormalizedCacheObject>;
|
|
6
|
+
protected orgId: string;
|
|
7
|
+
protected storeId: string;
|
|
8
|
+
protected endpoint: string;
|
|
9
|
+
constructor(endpoint: string, orgId: string, storeId: string);
|
|
10
|
+
setToken(token: string): void;
|
|
11
|
+
protected graphqlQuery(query: DocumentNode, variables: any): Promise<any>;
|
|
12
|
+
protected graphqlMutation(mutation: DocumentNode, variables: any): Promise<any>;
|
|
13
|
+
protected restApiCallWithToken(path: string, method: "GET" | "POST" | "PUT" | "DELETE", data?: any, headers?: any): Promise<any>;
|
|
14
|
+
protected restApiCallWithNoToken(path: string, method: "GET" | "POST" | "PUT" | "DELETE", data?: any, headers?: any): Promise<any>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// src/service.ts
|
|
3
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
|
+
};
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.Service = void 0;
|
|
17
|
+
const client_1 = require("@apollo/client");
|
|
18
|
+
const axios_1 = __importDefault(require("axios"));
|
|
19
|
+
class Service {
|
|
20
|
+
constructor(endpoint, orgId, storeId) {
|
|
21
|
+
this.token = null;
|
|
22
|
+
this.client = new client_1.ApolloClient({
|
|
23
|
+
uri: endpoint,
|
|
24
|
+
cache: new client_1.InMemoryCache(),
|
|
25
|
+
defaultOptions: {
|
|
26
|
+
query: {
|
|
27
|
+
fetchPolicy: "network-only",
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
this.orgId = orgId;
|
|
32
|
+
this.storeId = storeId;
|
|
33
|
+
this.endpoint = endpoint;
|
|
34
|
+
}
|
|
35
|
+
setToken(token) {
|
|
36
|
+
this.token = token;
|
|
37
|
+
}
|
|
38
|
+
graphqlQuery(query, variables) {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
try {
|
|
41
|
+
const { data, errors } = yield this.client.query({
|
|
42
|
+
query: (0, client_1.gql) `
|
|
43
|
+
${query}
|
|
44
|
+
`,
|
|
45
|
+
variables,
|
|
46
|
+
});
|
|
47
|
+
if (errors) {
|
|
48
|
+
throw new Error(`GraphQL error! errors: ${errors}`);
|
|
49
|
+
}
|
|
50
|
+
return data;
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
console.log(`Error in graphqlQuery: ${error}`);
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
graphqlMutation(mutation, variables) {
|
|
59
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
+
try {
|
|
61
|
+
const { data, errors } = yield this.client.mutate({
|
|
62
|
+
mutation: (0, client_1.gql) `
|
|
63
|
+
${mutation}
|
|
64
|
+
`,
|
|
65
|
+
variables,
|
|
66
|
+
});
|
|
67
|
+
if (errors) {
|
|
68
|
+
throw new Error(`GraphQL error! errors: ${errors}`);
|
|
69
|
+
}
|
|
70
|
+
return data;
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
console.log(`Error in graphqlMutation: ${error}`);
|
|
74
|
+
throw error;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
restApiCallWithToken(path, method, data, headers) {
|
|
79
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
+
try {
|
|
81
|
+
const modifiedHeaders = Object.assign(Object.assign({}, headers), { "Partner-Id": this.orgId, "X-Ecomos-Access-Token": this.token });
|
|
82
|
+
console.log("🚀 ~ Service ~ modifiedHeaders:", modifiedHeaders);
|
|
83
|
+
const response = yield (0, axios_1.default)({
|
|
84
|
+
url: this.endpoint + path,
|
|
85
|
+
method,
|
|
86
|
+
data,
|
|
87
|
+
headers: modifiedHeaders,
|
|
88
|
+
});
|
|
89
|
+
return response.data;
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
console.log(`Error in restApiCallWithToken: ${error}`);
|
|
93
|
+
throw error;
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
restApiCallWithNoToken(path, method, data, headers) {
|
|
98
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
99
|
+
try {
|
|
100
|
+
const modifiedHeaders = Object.assign(Object.assign({}, headers), { PartnerId: this.orgId });
|
|
101
|
+
console.log("🚀 ~ Service ~ modifiedHeaders:", modifiedHeaders);
|
|
102
|
+
const response = yield (0, axios_1.default)({
|
|
103
|
+
url: this.endpoint + path,
|
|
104
|
+
method,
|
|
105
|
+
data,
|
|
106
|
+
headers: modifiedHeaders,
|
|
107
|
+
});
|
|
108
|
+
return response.data;
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
console.log(`Error in restApiCallWithNoToken: ${error}`);
|
|
112
|
+
throw error;
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
exports.Service = Service;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Service } from "../
|
|
1
|
+
import { Service } from "../serviceSDK";
|
|
2
2
|
import { createCompanyRequest, createCustomerRequest, dataCustomerRequest, updateCustomerRequest } from "../../types/user";
|
|
3
3
|
export declare class UserService extends Service {
|
|
4
4
|
constructor(endpoint: string, orgId: string, storeId: string);
|
|
@@ -10,10 +10,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.UserService = void 0;
|
|
13
|
-
const
|
|
13
|
+
const serviceSDK_1 = require("../serviceSDK");
|
|
14
14
|
const queries_1 = require("../../graphql/user/queries");
|
|
15
15
|
const mutations_1 = require("../../graphql/user/mutations");
|
|
16
|
-
class UserService extends
|
|
16
|
+
class UserService extends serviceSDK_1.Service {
|
|
17
17
|
constructor(endpoint, orgId, storeId) {
|
|
18
18
|
super(endpoint, orgId, storeId);
|
|
19
19
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ListProduct } from "../../types/warehouse";
|
|
2
|
+
import { Service } from "../serviceSDK";
|
|
3
|
+
export declare class WarehouseService extends Service {
|
|
4
|
+
/**
|
|
5
|
+
* Constructs a new OrderService instance.
|
|
6
|
+
* @param endpoint - The endpoint URL for the service.
|
|
7
|
+
* @param orgId - The organization ID.
|
|
8
|
+
* @param storeId - The store ID.
|
|
9
|
+
*/
|
|
10
|
+
constructor(endpoint: string, orgId: string, storeId: string);
|
|
11
|
+
setToken(token: string): void;
|
|
12
|
+
/**
|
|
13
|
+
* get product inventory
|
|
14
|
+
* @param warehouseId - the id of the warehouse
|
|
15
|
+
* @param listProduct - list product
|
|
16
|
+
* @returns A promise that resolves with the created order.
|
|
17
|
+
* @throws If an error occurs while creating the order.
|
|
18
|
+
*/
|
|
19
|
+
getInventory(warehouseId: string, listProduct: ListProduct[]): Promise<any>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
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.WarehouseService = void 0;
|
|
13
|
+
const serviceSDK_1 = require("../serviceSDK");
|
|
14
|
+
class WarehouseService extends serviceSDK_1.Service {
|
|
15
|
+
/**
|
|
16
|
+
* Constructs a new OrderService instance.
|
|
17
|
+
* @param endpoint - The endpoint URL for the service.
|
|
18
|
+
* @param orgId - The organization ID.
|
|
19
|
+
* @param storeId - The store ID.
|
|
20
|
+
*/
|
|
21
|
+
constructor(endpoint, orgId, storeId) {
|
|
22
|
+
super(endpoint, orgId, storeId);
|
|
23
|
+
}
|
|
24
|
+
setToken(token) {
|
|
25
|
+
this.token = token;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* get product inventory
|
|
29
|
+
* @param warehouseId - the id of the warehouse
|
|
30
|
+
* @param listProduct - list product
|
|
31
|
+
* @returns A promise that resolves with the created order.
|
|
32
|
+
* @throws If an error occurs while creating the order.
|
|
33
|
+
*/
|
|
34
|
+
getInventory(warehouseId, listProduct) {
|
|
35
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
const endpoint = `/product-inventory/${warehouseId}`;
|
|
37
|
+
const method = "POST";
|
|
38
|
+
try {
|
|
39
|
+
const response = yield this.restApiCallWithNoToken(endpoint, method, listProduct);
|
|
40
|
+
return response;
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.WarehouseService = WarehouseService;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface ServiceRequest {
|
|
2
|
+
partnerId: String;
|
|
3
|
+
serviceName: String;
|
|
4
|
+
serviceId: String;
|
|
5
|
+
type: String;
|
|
6
|
+
typeName: String;
|
|
7
|
+
orderId: String;
|
|
8
|
+
orderLineItemId: String;
|
|
9
|
+
orderItemTermId: String;
|
|
10
|
+
status: String;
|
|
11
|
+
ownerId: String;
|
|
12
|
+
ownerName: String;
|
|
13
|
+
ownerEmail: String;
|
|
14
|
+
ownerPhone: String;
|
|
15
|
+
saleName: String;
|
|
16
|
+
salePartyId: String;
|
|
17
|
+
startDate: Date;
|
|
18
|
+
endDate: Date;
|
|
19
|
+
version: String;
|
|
20
|
+
location: String;
|
|
21
|
+
description: String;
|
|
22
|
+
username: String;
|
|
23
|
+
password: String;
|
|
24
|
+
urlPrivate: String;
|
|
25
|
+
urlPublic: String;
|
|
26
|
+
serviceType: Number;
|
|
27
|
+
actionResult: String;
|
|
28
|
+
}
|
package/package.json
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@longvansoftware/storefront-js-client",
|
|
3
|
-
"version": "1.3.
|
|
4
|
-
"main": "dist/src/index.js",
|
|
5
|
-
"types": "dist/src/index.d.ts",
|
|
6
|
-
"files": [
|
|
7
|
-
"dist/**/*.d.ts",
|
|
8
|
-
"dist/**/*.js"
|
|
9
|
-
],
|
|
10
|
-
"directories": {
|
|
11
|
-
"test": "jest"
|
|
12
|
-
},
|
|
13
|
-
"scripts": {
|
|
14
|
-
"test": "jest",
|
|
15
|
-
"build": "tsc",
|
|
16
|
-
"publish": "npm run build && npm publish"
|
|
17
|
-
},
|
|
18
|
-
"keywords": [],
|
|
19
|
-
"author": "",
|
|
20
|
-
"license": "ISC",
|
|
21
|
-
"dependencies": {
|
|
22
|
-
"@apollo/client": "3.9.11",
|
|
23
|
-
"apollo-boost": "^0.4.9",
|
|
24
|
-
"axios": "^1.6.8",
|
|
25
|
-
"crypto-js": "^4.2.0",
|
|
26
|
-
"graphql": "^15.8.0",
|
|
27
|
-
"graphql-request": "^6.1.0",
|
|
28
|
-
"graphql-tag": "^2.12.6",
|
|
29
|
-
"react": "^18.2.0",
|
|
30
|
-
"ts-node": "^10.9.2"
|
|
31
|
-
},
|
|
32
|
-
"devDependencies": {
|
|
33
|
-
"@types/axios": "^0.14.0",
|
|
34
|
-
"@types/crypto-js": "^4.2.2",
|
|
35
|
-
"@types/jest": "^29.5.12",
|
|
36
|
-
"@types/node": "^20.12.7",
|
|
37
|
-
"jest": "^29.7.0",
|
|
38
|
-
"ts-jest": "^29.1.2",
|
|
39
|
-
"typescript": "^5.4.5"
|
|
40
|
-
},
|
|
41
|
-
"description": ""
|
|
42
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@longvansoftware/storefront-js-client",
|
|
3
|
+
"version": "1.3.8",
|
|
4
|
+
"main": "dist/src/index.js",
|
|
5
|
+
"types": "dist/src/index.d.ts",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist/**/*.d.ts",
|
|
8
|
+
"dist/**/*.js"
|
|
9
|
+
],
|
|
10
|
+
"directories": {
|
|
11
|
+
"test": "jest"
|
|
12
|
+
},
|
|
13
|
+
"scripts": {
|
|
14
|
+
"test": "jest",
|
|
15
|
+
"build": "tsc",
|
|
16
|
+
"publish": "npm run build && npm publish"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [],
|
|
19
|
+
"author": "",
|
|
20
|
+
"license": "ISC",
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@apollo/client": "3.9.11",
|
|
23
|
+
"apollo-boost": "^0.4.9",
|
|
24
|
+
"axios": "^1.6.8",
|
|
25
|
+
"crypto-js": "^4.2.0",
|
|
26
|
+
"graphql": "^15.8.0",
|
|
27
|
+
"graphql-request": "^6.1.0",
|
|
28
|
+
"graphql-tag": "^2.12.6",
|
|
29
|
+
"react": "^18.2.0",
|
|
30
|
+
"ts-node": "^10.9.2"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/axios": "^0.14.0",
|
|
34
|
+
"@types/crypto-js": "^4.2.2",
|
|
35
|
+
"@types/jest": "^29.5.12",
|
|
36
|
+
"@types/node": "^20.12.7",
|
|
37
|
+
"jest": "^29.7.0",
|
|
38
|
+
"ts-jest": "^29.1.2",
|
|
39
|
+
"typescript": "^5.4.5"
|
|
40
|
+
},
|
|
41
|
+
"description": ""
|
|
42
|
+
}
|