@connect-plus-online/ogabai-integrations 0.1.6 → 0.1.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/index.cjs.js +1757 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.mts +1192 -0
- package/dist/index.d.ts +199 -8
- package/dist/{index.js → index.esm.js} +499 -303
- package/dist/index.esm.js.map +1 -0
- package/package.json +12 -3
- package/dist/index.mjs +0 -1369
|
@@ -0,0 +1,1757 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/auth.ts
|
|
4
|
+
var toAsyncTokenProvider = (p) => {
|
|
5
|
+
if (!p) return async () => null;
|
|
6
|
+
return async () => {
|
|
7
|
+
try {
|
|
8
|
+
const res = p();
|
|
9
|
+
return res instanceof Promise ? await res : res;
|
|
10
|
+
} catch (e) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
var toAsyncHeadersFactory = (f) => {
|
|
16
|
+
if (!f) return async () => ({});
|
|
17
|
+
return async () => {
|
|
18
|
+
var _a;
|
|
19
|
+
try {
|
|
20
|
+
const res = f();
|
|
21
|
+
return (_a = res instanceof Promise ? await res : res) != null ? _a : {};
|
|
22
|
+
} catch (e) {
|
|
23
|
+
return {};
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// src/errors.ts
|
|
29
|
+
var SdkError = class extends Error {
|
|
30
|
+
constructor(message, code, info) {
|
|
31
|
+
super(message);
|
|
32
|
+
this.name = "SdkError";
|
|
33
|
+
this.code = code;
|
|
34
|
+
this.info = info;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var NetworkError = class extends SdkError {
|
|
38
|
+
constructor(message = "Network error", info) {
|
|
39
|
+
super(message, "NETWORK_ERROR", info);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
var AuthenticationError = class extends SdkError {
|
|
43
|
+
constructor(message = "Authentication failed", info) {
|
|
44
|
+
super(message, "AUTH_ERROR", info);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// src/middleware.ts
|
|
49
|
+
var compose = (middlewares) => async (ctx, resCtx) => {
|
|
50
|
+
let idx = -1;
|
|
51
|
+
const dispatch = async (i) => {
|
|
52
|
+
if (i <= idx) throw new Error("next() called multiple times");
|
|
53
|
+
idx = i;
|
|
54
|
+
const fn = middlewares[i];
|
|
55
|
+
if (!fn) return;
|
|
56
|
+
await fn(ctx, resCtx, () => dispatch(i + 1));
|
|
57
|
+
};
|
|
58
|
+
await dispatch(0);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
// src/transport.ts
|
|
62
|
+
var createTransport = (opts) => {
|
|
63
|
+
var _a;
|
|
64
|
+
const fetchImpl = (_a = opts == null ? void 0 : opts.fetchImpl) != null ? _a : typeof fetch !== "undefined" ? fetch.bind(globalThis) : void 0;
|
|
65
|
+
if (!fetchImpl) {
|
|
66
|
+
throw new Error(
|
|
67
|
+
"No fetch implementation available. Provide fetchImpl in TransportOptions or polyfill fetch."
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
return async (ctx, resCtx, next) => {
|
|
71
|
+
const body = JSON.stringify({ query: ctx.request.query, variables: ctx.request.variables });
|
|
72
|
+
try {
|
|
73
|
+
const controller = typeof AbortController !== "undefined" ? new AbortController() : null;
|
|
74
|
+
const signal = controller == null ? void 0 : controller.signal;
|
|
75
|
+
let timer;
|
|
76
|
+
if (controller && (opts == null ? void 0 : opts.timeoutMs)) timer = setTimeout(() => controller.abort(), opts.timeoutMs);
|
|
77
|
+
const r = await fetchImpl(ctx.url, {
|
|
78
|
+
method: "POST",
|
|
79
|
+
headers: ctx.headers,
|
|
80
|
+
body,
|
|
81
|
+
signal
|
|
82
|
+
});
|
|
83
|
+
if (timer) clearTimeout(timer);
|
|
84
|
+
const text = await r.text();
|
|
85
|
+
let parsed;
|
|
86
|
+
try {
|
|
87
|
+
parsed = JSON.parse(text);
|
|
88
|
+
} catch (e) {
|
|
89
|
+
resCtx.error = new Error("Invalid JSON response");
|
|
90
|
+
resCtx.status = r.status;
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
resCtx.response = parsed;
|
|
94
|
+
resCtx.status = r.status;
|
|
95
|
+
} catch (err) {
|
|
96
|
+
if (err.name === "AbortError") resCtx.error = new Error("Request timed out");
|
|
97
|
+
else resCtx.error = err;
|
|
98
|
+
}
|
|
99
|
+
await next();
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
// src/client.ts
|
|
104
|
+
var GraphQLClient = class {
|
|
105
|
+
constructor(opts) {
|
|
106
|
+
this.url = opts.url;
|
|
107
|
+
this.tokenProvider = toAsyncTokenProvider(opts.tokenProvider);
|
|
108
|
+
this.headersFactory = toAsyncHeadersFactory(opts.headersFactory);
|
|
109
|
+
const base = [this.authMiddleware.bind(this)];
|
|
110
|
+
if (opts.middlewares) base.push(...opts.middlewares);
|
|
111
|
+
base.push(createTransport({ fetchImpl: opts.fetchImpl, timeoutMs: opts.timeoutMs }));
|
|
112
|
+
this.middlewares = base;
|
|
113
|
+
}
|
|
114
|
+
async authMiddleware(ctx, resCtx, next) {
|
|
115
|
+
var _a;
|
|
116
|
+
const token = await this.tokenProvider();
|
|
117
|
+
const dynamicHeaders = await this.headersFactory();
|
|
118
|
+
ctx.headers = {
|
|
119
|
+
"Content-Type": "application/json",
|
|
120
|
+
Accept: "application/json",
|
|
121
|
+
...dynamicHeaders,
|
|
122
|
+
...token ? { Authorization: `Bearer ${token}` } : {},
|
|
123
|
+
...(_a = ctx.headers) != null ? _a : {}
|
|
124
|
+
};
|
|
125
|
+
await next();
|
|
126
|
+
}
|
|
127
|
+
// core request
|
|
128
|
+
async request(query, variables, options) {
|
|
129
|
+
var _a;
|
|
130
|
+
const ctx = {
|
|
131
|
+
request: { query, variables },
|
|
132
|
+
url: this.url,
|
|
133
|
+
headers: (_a = options == null ? void 0 : options.headers) != null ? _a : {},
|
|
134
|
+
cacheOptions: options == null ? void 0 : options.cacheOptions
|
|
135
|
+
};
|
|
136
|
+
const resCtx = {};
|
|
137
|
+
const runner = compose(this.middlewares);
|
|
138
|
+
await runner(ctx, resCtx);
|
|
139
|
+
console.log({ data: JSON.stringify(resCtx.response) });
|
|
140
|
+
if (resCtx.error) throw resCtx.error;
|
|
141
|
+
if (!resCtx.response) throw new Error("No response from GraphQL transport");
|
|
142
|
+
if (resCtx.response.errors) {
|
|
143
|
+
console.log({ errors: resCtx.response.errors });
|
|
144
|
+
console.log("Detailed error - log: ", JSON.stringify(resCtx.response.errors));
|
|
145
|
+
}
|
|
146
|
+
return resCtx.response;
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
// src/helpers/query.ts
|
|
151
|
+
function gqlQueryStringBuilder(query, nestedValues) {
|
|
152
|
+
let queryString = "";
|
|
153
|
+
if (query)
|
|
154
|
+
for (let i = 0; i < query.length; i++) {
|
|
155
|
+
const element = query == null ? void 0 : query[i];
|
|
156
|
+
if (nestedValues == null ? void 0 : nestedValues[element]) {
|
|
157
|
+
queryString += `${String(element)} {
|
|
158
|
+
${gqlQueryStringBuilder(nestedValues[element], nestedValues)}
|
|
159
|
+
}`;
|
|
160
|
+
} else queryString += `${String(element)} `;
|
|
161
|
+
}
|
|
162
|
+
return queryString;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// src/services/user/schemas/user.schema.ts
|
|
166
|
+
var userSchema = {
|
|
167
|
+
me: (query) => `
|
|
168
|
+
query me {
|
|
169
|
+
me {
|
|
170
|
+
${query}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
`,
|
|
174
|
+
getUser: (query) => `
|
|
175
|
+
query getUser($user: UserInput!) {
|
|
176
|
+
user(user: $user) {
|
|
177
|
+
${query}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
`,
|
|
181
|
+
getUsers: (query) => `
|
|
182
|
+
query getUsers($user: UserInput, $userIds: [String], $limit: Int!, $skip: Int!) {
|
|
183
|
+
users(user: $user, userIds: $userIds, limit: $limit, skip: $skip) {
|
|
184
|
+
${query}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
`,
|
|
188
|
+
updateUser: (mutation) => `
|
|
189
|
+
mutation updateUser($userId: String!, $userUpdate: UpdateUserFieldInput, $imageType: String) {
|
|
190
|
+
updateUser(userId: $userId, userUpdate: $userUpdate, imageType: $imageType) {
|
|
191
|
+
${mutation}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
`
|
|
195
|
+
};
|
|
196
|
+
var user_schema_default = userSchema;
|
|
197
|
+
|
|
198
|
+
// src/services/user/user.entity.ts
|
|
199
|
+
var accountQuery = [
|
|
200
|
+
"_id",
|
|
201
|
+
"accountStatus",
|
|
202
|
+
"bvn",
|
|
203
|
+
"createdAt",
|
|
204
|
+
"nin",
|
|
205
|
+
"totalBalance",
|
|
206
|
+
"userId",
|
|
207
|
+
"wallets"
|
|
208
|
+
];
|
|
209
|
+
var walletQuery = [
|
|
210
|
+
"_id",
|
|
211
|
+
"accountId",
|
|
212
|
+
"balance",
|
|
213
|
+
"createdAt",
|
|
214
|
+
"currency",
|
|
215
|
+
"status",
|
|
216
|
+
"storeId"
|
|
217
|
+
];
|
|
218
|
+
var userQuery = [
|
|
219
|
+
"_id",
|
|
220
|
+
"country",
|
|
221
|
+
"createdAt",
|
|
222
|
+
"dob",
|
|
223
|
+
"email",
|
|
224
|
+
"firstName",
|
|
225
|
+
"isAdmin",
|
|
226
|
+
"lastName",
|
|
227
|
+
"phone",
|
|
228
|
+
"phoneVerified",
|
|
229
|
+
"phoneVerifiedAt",
|
|
230
|
+
"profileImageUrl",
|
|
231
|
+
"updatedAt"
|
|
232
|
+
];
|
|
233
|
+
var userSettingQuery = [
|
|
234
|
+
"_id",
|
|
235
|
+
"defaultStoreId",
|
|
236
|
+
"hasFa2",
|
|
237
|
+
"hasTransactionPin",
|
|
238
|
+
"subBillType",
|
|
239
|
+
"subscriptionPlanID",
|
|
240
|
+
"userId"
|
|
241
|
+
];
|
|
242
|
+
|
|
243
|
+
// src/services/inventory/entities.ts
|
|
244
|
+
var attributeQuery = [
|
|
245
|
+
"name",
|
|
246
|
+
"value"
|
|
247
|
+
];
|
|
248
|
+
var priceQuery = [
|
|
249
|
+
"_id",
|
|
250
|
+
"packageId",
|
|
251
|
+
"sellingPrice",
|
|
252
|
+
"costPrice",
|
|
253
|
+
"newSellingPrice",
|
|
254
|
+
"newCostPrice",
|
|
255
|
+
"deduction",
|
|
256
|
+
"storeId",
|
|
257
|
+
"timestamp",
|
|
258
|
+
"createdAt"
|
|
259
|
+
];
|
|
260
|
+
var stockQuery = [
|
|
261
|
+
"_id",
|
|
262
|
+
"packageId",
|
|
263
|
+
"stockQty",
|
|
264
|
+
"costPerPackage",
|
|
265
|
+
"sellPerPackage",
|
|
266
|
+
"deduction",
|
|
267
|
+
"timestamp",
|
|
268
|
+
"storeId",
|
|
269
|
+
"createdAt"
|
|
270
|
+
];
|
|
271
|
+
var storeQuery = [
|
|
272
|
+
"_id",
|
|
273
|
+
"name",
|
|
274
|
+
"address",
|
|
275
|
+
"shopType",
|
|
276
|
+
"ownerId",
|
|
277
|
+
"createdAt",
|
|
278
|
+
"storeLocation"
|
|
279
|
+
];
|
|
280
|
+
var addressQuery = [
|
|
281
|
+
"city",
|
|
282
|
+
"country",
|
|
283
|
+
"state",
|
|
284
|
+
"zipcode"
|
|
285
|
+
];
|
|
286
|
+
var categoryQuery = [
|
|
287
|
+
"_id",
|
|
288
|
+
"name",
|
|
289
|
+
"description",
|
|
290
|
+
"categoryStatus",
|
|
291
|
+
"storeId",
|
|
292
|
+
"createdAt",
|
|
293
|
+
"status",
|
|
294
|
+
"isTemplate"
|
|
295
|
+
];
|
|
296
|
+
var productQuery = [
|
|
297
|
+
"_id",
|
|
298
|
+
"barcode",
|
|
299
|
+
"category",
|
|
300
|
+
"categoryId",
|
|
301
|
+
"createdAt",
|
|
302
|
+
"description",
|
|
303
|
+
"images",
|
|
304
|
+
"metricPackage",
|
|
305
|
+
"metricPackageId",
|
|
306
|
+
"name",
|
|
307
|
+
"productAttributes",
|
|
308
|
+
"productPackages",
|
|
309
|
+
"storeId",
|
|
310
|
+
"tag",
|
|
311
|
+
"totalStockInMetricPackage"
|
|
312
|
+
];
|
|
313
|
+
var productNameQuery = [
|
|
314
|
+
"_id",
|
|
315
|
+
"name"
|
|
316
|
+
];
|
|
317
|
+
var packageQuery = [
|
|
318
|
+
"_id",
|
|
319
|
+
"name",
|
|
320
|
+
"description",
|
|
321
|
+
"trackIndex",
|
|
322
|
+
"productId",
|
|
323
|
+
"unit",
|
|
324
|
+
"unitQuantity",
|
|
325
|
+
"totalStock",
|
|
326
|
+
"barcode",
|
|
327
|
+
"priorityPrice",
|
|
328
|
+
"stockLimit",
|
|
329
|
+
"storeId",
|
|
330
|
+
"createdAt",
|
|
331
|
+
"price",
|
|
332
|
+
"deduction",
|
|
333
|
+
"stocks"
|
|
334
|
+
];
|
|
335
|
+
|
|
336
|
+
// src/services/user/types/account.type.ts
|
|
337
|
+
var getAccountResponseNestedFields = {
|
|
338
|
+
account: accountQuery,
|
|
339
|
+
wallets: walletQuery
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
// src/services/user/types/user.type.ts
|
|
343
|
+
var getUserResponse = [
|
|
344
|
+
"user"
|
|
345
|
+
];
|
|
346
|
+
var _getUserResponseNestedFields = {
|
|
347
|
+
address: addressQuery
|
|
348
|
+
};
|
|
349
|
+
var getUserResponseNestedFields = {
|
|
350
|
+
user: userQuery,
|
|
351
|
+
..._getUserResponseNestedFields
|
|
352
|
+
};
|
|
353
|
+
var getUsersResponse = [
|
|
354
|
+
"users"
|
|
355
|
+
];
|
|
356
|
+
var getUsersResponseNestedFields = {
|
|
357
|
+
users: userQuery,
|
|
358
|
+
..._getUserResponseNestedFields
|
|
359
|
+
};
|
|
360
|
+
({
|
|
361
|
+
...getUserResponse});
|
|
362
|
+
({
|
|
363
|
+
...getUserResponseNestedFields});
|
|
364
|
+
var meResponse = [
|
|
365
|
+
"user",
|
|
366
|
+
"account",
|
|
367
|
+
"stores",
|
|
368
|
+
"userSetting"
|
|
369
|
+
];
|
|
370
|
+
var meResponseNestedFields = {
|
|
371
|
+
stores: storeQuery,
|
|
372
|
+
userSetting: userSettingQuery,
|
|
373
|
+
...getUserResponseNestedFields,
|
|
374
|
+
...getAccountResponseNestedFields
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
// src/services/user/user.service.ts
|
|
378
|
+
var createUserService = (client) => ({
|
|
379
|
+
async me(fetchFields, option) {
|
|
380
|
+
var _a, _b;
|
|
381
|
+
return client.request(
|
|
382
|
+
user_schema_default.me(
|
|
383
|
+
gqlQueryStringBuilder(
|
|
384
|
+
(_a = fetchFields == null ? void 0 : fetchFields.root) != null ? _a : meResponse,
|
|
385
|
+
(_b = fetchFields == null ? void 0 : fetchFields.nestedFields) != null ? _b : meResponseNestedFields
|
|
386
|
+
)
|
|
387
|
+
),
|
|
388
|
+
{},
|
|
389
|
+
option
|
|
390
|
+
);
|
|
391
|
+
},
|
|
392
|
+
async getUser(input, fetchFields, option) {
|
|
393
|
+
var _a, _b;
|
|
394
|
+
return client.request(
|
|
395
|
+
user_schema_default.getUser(
|
|
396
|
+
gqlQueryStringBuilder(
|
|
397
|
+
(_a = fetchFields == null ? void 0 : fetchFields.root) != null ? _a : getUserResponse,
|
|
398
|
+
(_b = fetchFields == null ? void 0 : fetchFields.nestedFields) != null ? _b : getUserResponseNestedFields
|
|
399
|
+
)
|
|
400
|
+
),
|
|
401
|
+
input,
|
|
402
|
+
option
|
|
403
|
+
);
|
|
404
|
+
},
|
|
405
|
+
async getUsers(input, fetchFields, option) {
|
|
406
|
+
var _a, _b;
|
|
407
|
+
return client.request(
|
|
408
|
+
user_schema_default.getUsers(
|
|
409
|
+
gqlQueryStringBuilder(
|
|
410
|
+
(_a = fetchFields == null ? void 0 : fetchFields.root) != null ? _a : getUsersResponse,
|
|
411
|
+
(_b = fetchFields == null ? void 0 : fetchFields.nestedFields) != null ? _b : getUsersResponseNestedFields
|
|
412
|
+
)
|
|
413
|
+
),
|
|
414
|
+
input,
|
|
415
|
+
option
|
|
416
|
+
);
|
|
417
|
+
}
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
// src/services/user/schemas/auth.schema.ts
|
|
421
|
+
var authSchema = {
|
|
422
|
+
checkRegistration: (query) => `
|
|
423
|
+
query checkRegistration($phone: String!) {
|
|
424
|
+
checkRegistration(phone: $phone) {
|
|
425
|
+
${query}
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
`,
|
|
429
|
+
login: (query) => `
|
|
430
|
+
mutation login($phone: String!, $pin: String!, $userType: UserTypeInputEnum) {
|
|
431
|
+
login(phone: $phone, pin: $pin, userType: $userType) {
|
|
432
|
+
${query}
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
`,
|
|
436
|
+
signUp: (query) => `
|
|
437
|
+
mutation signUp($firstName: String!, $lastName: String!, $phone: String!, $pin: String!, $storeName: String!, $storeLocation: String, $email: String, $userType: UserTypeInputEnum) {
|
|
438
|
+
signUp( firstName: $firstName, lastName: $lastName, phone: $phone, pin: $pin, storeName: $storeName, storeLocation: $storeLocation, email: $email, userType: $userType) {
|
|
439
|
+
${query}
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
`,
|
|
443
|
+
resetPin: (query) => `
|
|
444
|
+
mutation resetPin($phone: String!, $pin: String!) {
|
|
445
|
+
resetPin(phone: $phone, pin: $pin) {
|
|
446
|
+
${query}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
`,
|
|
450
|
+
sendOTP: (query) => `
|
|
451
|
+
mutation sendOTP($phone: String!) {
|
|
452
|
+
sendOTP(phone: $phone) {
|
|
453
|
+
${query}
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
`,
|
|
457
|
+
verifyOTP: (query) => `
|
|
458
|
+
mutation verifyOTP($phone: String!, $otp: String!) {
|
|
459
|
+
verifyOTP(phone: $phone, otp: $otp) {
|
|
460
|
+
${query}
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
`,
|
|
464
|
+
updateTxPin: (mutation) => `
|
|
465
|
+
mutation updateTxPin($userId: String!, $pin: String!, $oldPin: String!) {
|
|
466
|
+
updateTxPin(userId: $userId, pin: $pin, oldPin: $oldPin) {
|
|
467
|
+
${mutation}
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
`
|
|
471
|
+
};
|
|
472
|
+
|
|
473
|
+
// src/services/user/types/auth.type.ts
|
|
474
|
+
var updateTxPinResponse = [
|
|
475
|
+
"success"
|
|
476
|
+
];
|
|
477
|
+
var resetPinResponse = [
|
|
478
|
+
"success"
|
|
479
|
+
];
|
|
480
|
+
var sendOTPResponse = [
|
|
481
|
+
"successful",
|
|
482
|
+
"otp"
|
|
483
|
+
];
|
|
484
|
+
var verifyOTPResponse = [
|
|
485
|
+
"otpVerifiedAccessToken"
|
|
486
|
+
];
|
|
487
|
+
var loginResponse = [
|
|
488
|
+
"accessToken",
|
|
489
|
+
"userId"
|
|
490
|
+
];
|
|
491
|
+
var signUpResponse = [
|
|
492
|
+
"accessToken",
|
|
493
|
+
"userId"
|
|
494
|
+
];
|
|
495
|
+
|
|
496
|
+
// src/services/user/auth.service.ts
|
|
497
|
+
var createAuthService = (client) => ({
|
|
498
|
+
async updateTxPin(input, fetchFields, option) {
|
|
499
|
+
var _a;
|
|
500
|
+
return client.request(
|
|
501
|
+
authSchema.updateTxPin(
|
|
502
|
+
gqlQueryStringBuilder(
|
|
503
|
+
(_a = fetchFields == null ? void 0 : fetchFields.root) != null ? _a : updateTxPinResponse
|
|
504
|
+
)
|
|
505
|
+
),
|
|
506
|
+
input,
|
|
507
|
+
option
|
|
508
|
+
);
|
|
509
|
+
},
|
|
510
|
+
async verifyOTP(input, fetchFields, option) {
|
|
511
|
+
var _a;
|
|
512
|
+
return client.request(
|
|
513
|
+
authSchema.verifyOTP(
|
|
514
|
+
gqlQueryStringBuilder(
|
|
515
|
+
(_a = fetchFields == null ? void 0 : fetchFields.root) != null ? _a : verifyOTPResponse
|
|
516
|
+
)
|
|
517
|
+
),
|
|
518
|
+
input,
|
|
519
|
+
option
|
|
520
|
+
);
|
|
521
|
+
},
|
|
522
|
+
async sendOTP(input, fetchFields, option) {
|
|
523
|
+
var _a;
|
|
524
|
+
return client.request(
|
|
525
|
+
authSchema.sendOTP(
|
|
526
|
+
gqlQueryStringBuilder(
|
|
527
|
+
(_a = fetchFields == null ? void 0 : fetchFields.root) != null ? _a : sendOTPResponse
|
|
528
|
+
)
|
|
529
|
+
),
|
|
530
|
+
input,
|
|
531
|
+
option
|
|
532
|
+
);
|
|
533
|
+
},
|
|
534
|
+
async resetPin(input, fetchFields, option) {
|
|
535
|
+
var _a;
|
|
536
|
+
return client.request(
|
|
537
|
+
authSchema.resetPin(
|
|
538
|
+
gqlQueryStringBuilder(
|
|
539
|
+
(_a = fetchFields == null ? void 0 : fetchFields.root) != null ? _a : resetPinResponse
|
|
540
|
+
)
|
|
541
|
+
),
|
|
542
|
+
input,
|
|
543
|
+
option
|
|
544
|
+
);
|
|
545
|
+
},
|
|
546
|
+
async signUp(input, fetchFields, option) {
|
|
547
|
+
var _a;
|
|
548
|
+
return client.request(
|
|
549
|
+
authSchema.signUp(
|
|
550
|
+
gqlQueryStringBuilder(
|
|
551
|
+
(_a = fetchFields == null ? void 0 : fetchFields.root) != null ? _a : signUpResponse
|
|
552
|
+
)
|
|
553
|
+
),
|
|
554
|
+
input,
|
|
555
|
+
option
|
|
556
|
+
);
|
|
557
|
+
},
|
|
558
|
+
async login(input, fetchFields, option) {
|
|
559
|
+
var _a;
|
|
560
|
+
return client.request(
|
|
561
|
+
authSchema.login(
|
|
562
|
+
gqlQueryStringBuilder(
|
|
563
|
+
(_a = fetchFields == null ? void 0 : fetchFields.root) != null ? _a : loginResponse
|
|
564
|
+
)
|
|
565
|
+
),
|
|
566
|
+
input,
|
|
567
|
+
option
|
|
568
|
+
);
|
|
569
|
+
}
|
|
570
|
+
});
|
|
571
|
+
|
|
572
|
+
// src/services/inventory/types/package.type.ts
|
|
573
|
+
var getPackageResponseFields = [
|
|
574
|
+
"productPackage"
|
|
575
|
+
];
|
|
576
|
+
var _getPackageResponseNestedFields = {
|
|
577
|
+
price: priceQuery,
|
|
578
|
+
stocks: stockQuery
|
|
579
|
+
};
|
|
580
|
+
var getPackageResponseNestedFields = {
|
|
581
|
+
productPackage: packageQuery,
|
|
582
|
+
..._getPackageResponseNestedFields
|
|
583
|
+
};
|
|
584
|
+
var removePackageResponseFields = [
|
|
585
|
+
"packageId"
|
|
586
|
+
];
|
|
587
|
+
var updatePackageResponseFields = getPackageResponseFields;
|
|
588
|
+
var updatePackageResponseNestedFields = getPackageResponseNestedFields;
|
|
589
|
+
var addPackagesResponseFields = [
|
|
590
|
+
"productPackages"
|
|
591
|
+
];
|
|
592
|
+
var addPackagesResponseNestedFields = {
|
|
593
|
+
productPackages: packageQuery,
|
|
594
|
+
..._getPackageResponseNestedFields
|
|
595
|
+
};
|
|
596
|
+
var addPackageResponseFields = getPackageResponseFields;
|
|
597
|
+
var addPackageResponseNestedFields = getPackageResponseNestedFields;
|
|
598
|
+
var getPackagesResponseFields = [
|
|
599
|
+
"productPackages",
|
|
600
|
+
"uniqueProducts"
|
|
601
|
+
];
|
|
602
|
+
var getPackagesResponseNestedFields = {
|
|
603
|
+
productPackages: packageQuery,
|
|
604
|
+
uniqueProducts: productQuery,
|
|
605
|
+
...getPackageResponseNestedFields
|
|
606
|
+
};
|
|
607
|
+
|
|
608
|
+
// src/services/inventory/types/price.type.ts
|
|
609
|
+
var getPriceResponseFields = ["price"];
|
|
610
|
+
var _getPriceResponseNestedFields = {};
|
|
611
|
+
var getPriceResponseNestedFields = {
|
|
612
|
+
price: priceQuery,
|
|
613
|
+
..._getPriceResponseNestedFields
|
|
614
|
+
};
|
|
615
|
+
var getPricesResponseFields = ["prices"];
|
|
616
|
+
var getPricesResponseNestedFields = {
|
|
617
|
+
..._getPriceResponseNestedFields,
|
|
618
|
+
prices: priceQuery
|
|
619
|
+
};
|
|
620
|
+
var addPriceResponseFields = getPriceResponseFields;
|
|
621
|
+
var addPriceResponseNestedFields = getPriceResponseNestedFields;
|
|
622
|
+
var updatePriceResponseFields = getPriceResponseFields;
|
|
623
|
+
var updatePriceResponseNestedFields = getPriceResponseNestedFields;
|
|
624
|
+
var removePriceResponseFields = [
|
|
625
|
+
"priceId"
|
|
626
|
+
];
|
|
627
|
+
|
|
628
|
+
// src/services/inventory/types/product.type.ts
|
|
629
|
+
var getProductResponseFields = [
|
|
630
|
+
"product"
|
|
631
|
+
];
|
|
632
|
+
var _getProductResponseNestedFields = {
|
|
633
|
+
productPackages: packageQuery,
|
|
634
|
+
metricPackage: packageQuery,
|
|
635
|
+
category: categoryQuery,
|
|
636
|
+
price: priceQuery,
|
|
637
|
+
stocks: stockQuery,
|
|
638
|
+
productAttributes: attributeQuery
|
|
639
|
+
};
|
|
640
|
+
var getProductResponseNestedFields = {
|
|
641
|
+
product: productQuery,
|
|
642
|
+
..._getProductResponseNestedFields
|
|
643
|
+
};
|
|
644
|
+
var getProductsResponseFields = [
|
|
645
|
+
"products"
|
|
646
|
+
];
|
|
647
|
+
var getProductsResponseNestedFields = {
|
|
648
|
+
products: productQuery,
|
|
649
|
+
..._getProductResponseNestedFields
|
|
650
|
+
};
|
|
651
|
+
var getProductByBarcodeResponse = [
|
|
652
|
+
"Product"
|
|
653
|
+
];
|
|
654
|
+
var getProductByBarcodeResponseNestedFields = {
|
|
655
|
+
Product: productQuery,
|
|
656
|
+
..._getProductResponseNestedFields
|
|
657
|
+
};
|
|
658
|
+
var searchProductNamesResponse = [
|
|
659
|
+
"productNames"
|
|
660
|
+
];
|
|
661
|
+
var searchProductNamesResponseNestedFields = {
|
|
662
|
+
productNames: productNameQuery
|
|
663
|
+
};
|
|
664
|
+
var addProductResponseFields = [
|
|
665
|
+
"product"
|
|
666
|
+
];
|
|
667
|
+
var addProductResponseNestedFields = {
|
|
668
|
+
product: productQuery,
|
|
669
|
+
uploadImageResponse: ["fileUrl", "url"],
|
|
670
|
+
..._getProductResponseNestedFields
|
|
671
|
+
};
|
|
672
|
+
var updateProductResponseFields = getProductResponseFields;
|
|
673
|
+
var updateProductResponseNestedFields = getProductResponseNestedFields;
|
|
674
|
+
var removeProductResponseFields = [
|
|
675
|
+
"productId"
|
|
676
|
+
];
|
|
677
|
+
var searchCategoriesAndTemplateResponse = [
|
|
678
|
+
"productCategories"
|
|
679
|
+
];
|
|
680
|
+
var searchCategoriesAndTemplateResponseNestedFields = {
|
|
681
|
+
productCategories: categoryQuery
|
|
682
|
+
};
|
|
683
|
+
|
|
684
|
+
// src/services/inventory/types/stock.type.ts
|
|
685
|
+
var getStockResponse = [
|
|
686
|
+
"stock"
|
|
687
|
+
];
|
|
688
|
+
var getStockResponseNestedFields = {
|
|
689
|
+
stock: stockQuery
|
|
690
|
+
};
|
|
691
|
+
var getStocksResponse = [
|
|
692
|
+
"stocks"
|
|
693
|
+
];
|
|
694
|
+
var getStocksResponseNestedFields = {
|
|
695
|
+
stocks: stockQuery
|
|
696
|
+
};
|
|
697
|
+
var addStockResponse = getStockResponse;
|
|
698
|
+
var addStockResponseNestedFields = getStockResponseNestedFields;
|
|
699
|
+
var updateStockResponse = getStockResponse;
|
|
700
|
+
var updateStockResponseNestedFields = getStockResponseNestedFields;
|
|
701
|
+
var removeStockResponse = [
|
|
702
|
+
"stockId"
|
|
703
|
+
];
|
|
704
|
+
|
|
705
|
+
// src/services/inventory/types/store.type.ts
|
|
706
|
+
var getStoreResponse = [
|
|
707
|
+
"store"
|
|
708
|
+
];
|
|
709
|
+
var _getStoreResponseNestedFields = {
|
|
710
|
+
address: addressQuery
|
|
711
|
+
};
|
|
712
|
+
var getStoreResponseNestedFields = {
|
|
713
|
+
store: storeQuery,
|
|
714
|
+
..._getStoreResponseNestedFields
|
|
715
|
+
};
|
|
716
|
+
var getStoresResponse = [
|
|
717
|
+
"stores"
|
|
718
|
+
];
|
|
719
|
+
var getStoresResponseNestedFields = {
|
|
720
|
+
stores: storeQuery,
|
|
721
|
+
address: addressQuery
|
|
722
|
+
};
|
|
723
|
+
var addStoreResponse = getStoreResponse;
|
|
724
|
+
var addStoreResponseNestedFields = getStoreResponseNestedFields;
|
|
725
|
+
var updateStoreResponse = getStoreResponse;
|
|
726
|
+
var updateStoreResponseNestedFields = getStoreResponseNestedFields;
|
|
727
|
+
var removeStoreResponse = [
|
|
728
|
+
"storeId"
|
|
729
|
+
];
|
|
730
|
+
|
|
731
|
+
// src/services/inventory/schema/package.schema.ts
|
|
732
|
+
var packageSchema = {
|
|
733
|
+
getPackage: (query) => `
|
|
734
|
+
query getPackage($productPackage: ProductPackageInput!, $template: Boolean) {
|
|
735
|
+
getPackage(productPackage: $productPackage, template: $template) {
|
|
736
|
+
${query}
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
`,
|
|
740
|
+
getPackages: (query) => `
|
|
741
|
+
query getPackages($productPackage: ProductPackageInput, $packageIds: [String], $search: String, $template: Boolean, $shouldGetFromAllStores: Boolean, $limit: Int, $skip: Int) {
|
|
742
|
+
packages(productPackage: $productPackage, packageIds: $packageIds, search: $search, template: $template, shouldGetFromAllStores: $shouldGetFromAllStores, limit: $limit, skip: $skip) {
|
|
743
|
+
${query}
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
`,
|
|
747
|
+
addPackage: (query) => `
|
|
748
|
+
mutation addPackage($productPackage: ProductPackageInput!, $packageStocks: [StockInput], $template: Boolean) {
|
|
749
|
+
addPackage(productPackage: $productPackage, packageStocks: $packageStocks, template: $template) {
|
|
750
|
+
${query}
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
`,
|
|
754
|
+
addPackages: (query) => `
|
|
755
|
+
mutation addPackages($productPackages: [ProductPackagesInput]!, $template: Boolean) {
|
|
756
|
+
addPackages(productPackages: $productPackages, template: $template) {
|
|
757
|
+
${query}
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
`,
|
|
761
|
+
updatePackage: (query) => `
|
|
762
|
+
mutation updatePackage($packageId: String!, $productPackage: ProductPackageInput!, $template: Boolean) {
|
|
763
|
+
updatePackage(packageId: $packageId, productPackage: $productPackage, template: $template) {
|
|
764
|
+
${query}
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
`,
|
|
768
|
+
updatePackages: (query) => `
|
|
769
|
+
mutation updatePackages($packages: [PackagesInput]) {
|
|
770
|
+
updatePackages(packages: $packages) {
|
|
771
|
+
${query}
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
`,
|
|
775
|
+
removePackage: (query) => `
|
|
776
|
+
mutation removePackage($packageId: String!, $template: Boolean) {
|
|
777
|
+
removePackage(packageId: $packageId, template: $template) {
|
|
778
|
+
${query}
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
`
|
|
782
|
+
};
|
|
783
|
+
|
|
784
|
+
// src/services/inventory/package.service.ts
|
|
785
|
+
var createPackageService = (client) => ({
|
|
786
|
+
async updatePackage(input, fetchFields, option) {
|
|
787
|
+
var _a, _b, _c, _d;
|
|
788
|
+
const res = await client.request(
|
|
789
|
+
packageSchema.updatePackage(
|
|
790
|
+
gqlQueryStringBuilder(
|
|
791
|
+
(_a = fetchFields == null ? void 0 : fetchFields.root) != null ? _a : updatePackageResponseFields,
|
|
792
|
+
(_b = fetchFields == null ? void 0 : fetchFields.nestedFields) != null ? _b : updatePackageResponseNestedFields
|
|
793
|
+
)
|
|
794
|
+
),
|
|
795
|
+
input,
|
|
796
|
+
option
|
|
797
|
+
);
|
|
798
|
+
return (_d = (_c = res.data) == null ? void 0 : _c.updatePackage) != null ? _d : null;
|
|
799
|
+
},
|
|
800
|
+
async removePackage(input, fetchFields, option) {
|
|
801
|
+
var _a, _b, _c;
|
|
802
|
+
const res = await client.request(
|
|
803
|
+
packageSchema.removePackage(
|
|
804
|
+
gqlQueryStringBuilder(
|
|
805
|
+
(_a = fetchFields == null ? void 0 : fetchFields.root) != null ? _a : removePackageResponseFields
|
|
806
|
+
)
|
|
807
|
+
),
|
|
808
|
+
input,
|
|
809
|
+
option
|
|
810
|
+
);
|
|
811
|
+
return (_c = (_b = res.data) == null ? void 0 : _b.removePackage) != null ? _c : null;
|
|
812
|
+
},
|
|
813
|
+
async addPackages(input, fetchFields, option) {
|
|
814
|
+
var _a, _b, _c, _d;
|
|
815
|
+
const res = await client.request(
|
|
816
|
+
packageSchema.addPackages(
|
|
817
|
+
gqlQueryStringBuilder(
|
|
818
|
+
(_a = fetchFields == null ? void 0 : fetchFields.root) != null ? _a : addPackagesResponseFields,
|
|
819
|
+
(_b = fetchFields == null ? void 0 : fetchFields.nestedFields) != null ? _b : addPackagesResponseNestedFields
|
|
820
|
+
)
|
|
821
|
+
),
|
|
822
|
+
input,
|
|
823
|
+
option
|
|
824
|
+
);
|
|
825
|
+
return (_d = (_c = res.data) == null ? void 0 : _c.addPackages) != null ? _d : null;
|
|
826
|
+
},
|
|
827
|
+
async addPackage(input, fetchFields, option) {
|
|
828
|
+
var _a, _b, _c, _d;
|
|
829
|
+
const res = await client.request(
|
|
830
|
+
packageSchema.addPackage(
|
|
831
|
+
gqlQueryStringBuilder(
|
|
832
|
+
(_a = fetchFields == null ? void 0 : fetchFields.root) != null ? _a : addPackageResponseFields,
|
|
833
|
+
(_b = fetchFields == null ? void 0 : fetchFields.nestedFields) != null ? _b : addPackageResponseNestedFields
|
|
834
|
+
)
|
|
835
|
+
),
|
|
836
|
+
input,
|
|
837
|
+
option
|
|
838
|
+
);
|
|
839
|
+
return (_d = (_c = res.data) == null ? void 0 : _c.addPackage) != null ? _d : null;
|
|
840
|
+
},
|
|
841
|
+
async getPackage(input, fetchFields, option) {
|
|
842
|
+
var _a, _b, _c, _d;
|
|
843
|
+
const res = await client.request(
|
|
844
|
+
packageSchema.getPackage(
|
|
845
|
+
gqlQueryStringBuilder(
|
|
846
|
+
(_a = fetchFields == null ? void 0 : fetchFields.root) != null ? _a : getPackageResponseFields,
|
|
847
|
+
(_b = fetchFields == null ? void 0 : fetchFields.nestedFields) != null ? _b : getPackageResponseNestedFields
|
|
848
|
+
)
|
|
849
|
+
),
|
|
850
|
+
input,
|
|
851
|
+
option
|
|
852
|
+
);
|
|
853
|
+
return (_d = (_c = res.data) == null ? void 0 : _c.getPackage) != null ? _d : null;
|
|
854
|
+
},
|
|
855
|
+
async getPackages(input, fetchFields, option) {
|
|
856
|
+
var _a, _b, _c, _d;
|
|
857
|
+
const res = await client.request(
|
|
858
|
+
packageSchema.getPackages(
|
|
859
|
+
gqlQueryStringBuilder(
|
|
860
|
+
(_a = fetchFields == null ? void 0 : fetchFields.root) != null ? _a : getPackagesResponseFields,
|
|
861
|
+
(_b = fetchFields == null ? void 0 : fetchFields.nestedFields) != null ? _b : getPackagesResponseNestedFields
|
|
862
|
+
)
|
|
863
|
+
),
|
|
864
|
+
input,
|
|
865
|
+
option
|
|
866
|
+
);
|
|
867
|
+
return (_d = (_c = res.data) == null ? void 0 : _c.getPackages) != null ? _d : null;
|
|
868
|
+
}
|
|
869
|
+
});
|
|
870
|
+
|
|
871
|
+
// src/services/inventory/schema/price.schema.ts
|
|
872
|
+
var priceSchema = {
|
|
873
|
+
getPrice: (query) => `
|
|
874
|
+
query getPrice($price: PriceInput!) {
|
|
875
|
+
price(price: $price) {
|
|
876
|
+
${query}
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
`,
|
|
880
|
+
getPrices: (query) => `
|
|
881
|
+
query getPrices($price: PriceInput, $priceIds: [String], $limit: Int!, $skip: Int!) {
|
|
882
|
+
prices(price: $price, priceIds: $priceIds, limit: $limit, skip: $skip) {
|
|
883
|
+
${query}
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
`,
|
|
887
|
+
addPrice: (mutation) => `
|
|
888
|
+
mutation addPrice($price: PriceInput) {
|
|
889
|
+
addPrice(price: $price) {
|
|
890
|
+
${mutation}
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
`,
|
|
894
|
+
updatePrice: (mutation) => `
|
|
895
|
+
mutation updatePrice($priceId: String, $price: PriceInput) {
|
|
896
|
+
updatePrice(priceId: $priceId, price: $price) {
|
|
897
|
+
${mutation}
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
`,
|
|
901
|
+
removePrice: (mutation) => `
|
|
902
|
+
mutation removePrice($priceId: String!) {
|
|
903
|
+
removePrice(priceId: $priceId) {
|
|
904
|
+
${mutation}
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
`
|
|
908
|
+
};
|
|
909
|
+
|
|
910
|
+
// src/services/inventory/price.service.ts
|
|
911
|
+
var createPriceService = (client) => ({
|
|
912
|
+
async updatePrice(input, fetchFields, option) {
|
|
913
|
+
var _a, _b, _c, _d;
|
|
914
|
+
const res = await client.request(
|
|
915
|
+
priceSchema.updatePrice(
|
|
916
|
+
gqlQueryStringBuilder(
|
|
917
|
+
(_a = fetchFields == null ? void 0 : fetchFields.root) != null ? _a : updatePriceResponseFields,
|
|
918
|
+
(_b = fetchFields == null ? void 0 : fetchFields.nestedFields) != null ? _b : updatePriceResponseNestedFields
|
|
919
|
+
)
|
|
920
|
+
),
|
|
921
|
+
input,
|
|
922
|
+
option
|
|
923
|
+
);
|
|
924
|
+
return (_d = (_c = res.data) == null ? void 0 : _c.updatePrice) != null ? _d : null;
|
|
925
|
+
},
|
|
926
|
+
async removePrice(input, fetchFields, option) {
|
|
927
|
+
var _a, _b, _c;
|
|
928
|
+
const res = await client.request(
|
|
929
|
+
priceSchema.removePrice(
|
|
930
|
+
gqlQueryStringBuilder(
|
|
931
|
+
(_a = fetchFields == null ? void 0 : fetchFields.root) != null ? _a : removePriceResponseFields
|
|
932
|
+
)
|
|
933
|
+
),
|
|
934
|
+
input,
|
|
935
|
+
option
|
|
936
|
+
);
|
|
937
|
+
return (_c = (_b = res.data) == null ? void 0 : _b.removePrice) != null ? _c : null;
|
|
938
|
+
},
|
|
939
|
+
async addPrice(input, fetchFields, option) {
|
|
940
|
+
var _a, _b, _c, _d;
|
|
941
|
+
const res = await client.request(
|
|
942
|
+
priceSchema.addPrice(
|
|
943
|
+
gqlQueryStringBuilder(
|
|
944
|
+
(_a = fetchFields == null ? void 0 : fetchFields.root) != null ? _a : addPriceResponseFields,
|
|
945
|
+
(_b = fetchFields == null ? void 0 : fetchFields.nestedFields) != null ? _b : addPriceResponseNestedFields
|
|
946
|
+
)
|
|
947
|
+
),
|
|
948
|
+
input,
|
|
949
|
+
option
|
|
950
|
+
);
|
|
951
|
+
return (_d = (_c = res.data) == null ? void 0 : _c.addPrice) != null ? _d : null;
|
|
952
|
+
},
|
|
953
|
+
async getPrice(input, fetchFields, option) {
|
|
954
|
+
var _a, _b, _c, _d;
|
|
955
|
+
const res = await client.request(
|
|
956
|
+
priceSchema.getPrice(
|
|
957
|
+
gqlQueryStringBuilder(
|
|
958
|
+
(_a = fetchFields == null ? void 0 : fetchFields.root) != null ? _a : getPriceResponseFields,
|
|
959
|
+
(_b = fetchFields == null ? void 0 : fetchFields.nestedFields) != null ? _b : getPriceResponseNestedFields
|
|
960
|
+
)
|
|
961
|
+
),
|
|
962
|
+
input,
|
|
963
|
+
option
|
|
964
|
+
);
|
|
965
|
+
return (_d = (_c = res.data) == null ? void 0 : _c.getPrice) != null ? _d : null;
|
|
966
|
+
},
|
|
967
|
+
async getPrices(input, fetchFields, option) {
|
|
968
|
+
var _a, _b, _c, _d;
|
|
969
|
+
const res = await client.request(
|
|
970
|
+
priceSchema.getPrices(
|
|
971
|
+
gqlQueryStringBuilder(
|
|
972
|
+
(_a = fetchFields == null ? void 0 : fetchFields.root) != null ? _a : getPricesResponseFields,
|
|
973
|
+
(_b = fetchFields == null ? void 0 : fetchFields.nestedFields) != null ? _b : getPricesResponseNestedFields
|
|
974
|
+
)
|
|
975
|
+
),
|
|
976
|
+
input,
|
|
977
|
+
option
|
|
978
|
+
);
|
|
979
|
+
return (_d = (_c = res.data) == null ? void 0 : _c.getPrices) != null ? _d : null;
|
|
980
|
+
}
|
|
981
|
+
});
|
|
982
|
+
|
|
983
|
+
// src/services/inventory/schema/product.schema.ts
|
|
984
|
+
var productSchema = {
|
|
985
|
+
searchCategoriesAndTemplate: (query) => `
|
|
986
|
+
query searchCategoriesAndTemplate($search: String, $shouldGetFromAllStores: Boolean){
|
|
987
|
+
searchCategoriesAndTemplate(search: $search, shouldGetFromAllStores: $shouldGetFromAllStores) {
|
|
988
|
+
${query}
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
`,
|
|
992
|
+
getProduct: (query) => `
|
|
993
|
+
query getProduct($product: ProductInput!, $template: Boolean) {
|
|
994
|
+
getProduct(product: $product, template: $template) {
|
|
995
|
+
${query}
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
`,
|
|
999
|
+
getProducts: (query) => `
|
|
1000
|
+
query getProducts($product: ProductInput, $productIds: [String], $search: String, $limit: Int!, $skip: Int!, $template: Boolean, $shouldGetFromAllStores: Boolean) {
|
|
1001
|
+
getProducts(product: $product, productIds: $productIds, search: $search, limit: $limit, skip: $skip, template: $template, shouldGetFromAllStores: $shouldGetFromAllStores) {
|
|
1002
|
+
${query}
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
`,
|
|
1006
|
+
getProductByBarcode: (query) => `
|
|
1007
|
+
query getProductByBarcode($barcode: String!, $fetchFromGS1IfNotFound: Boolean, $template: Boolean) {
|
|
1008
|
+
getProductByBarcode(barcode: $barcode, fetchFromGS1IfNotFound: $fetchFromGS1IfNotFound, template: $template) {
|
|
1009
|
+
${query}
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
`,
|
|
1013
|
+
searchProductNames: (query) => `
|
|
1014
|
+
query searchProductNames($search: String!, $limit: Int, $skip: Int, $template: Boolean) {
|
|
1015
|
+
searchProductNames(search: $search, limit: $limit, skip: $skip, template: $template) {
|
|
1016
|
+
${query}
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
`,
|
|
1020
|
+
addProduct: (mutation) => `
|
|
1021
|
+
mutation addProduct($product: ProductInput!, $imageTypes: [String], $template: Boolean) {
|
|
1022
|
+
addProduct(product: $product, imageTypes: $imageTypes, template: $template) {
|
|
1023
|
+
${mutation}
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
`,
|
|
1027
|
+
updateProduct: (mutation) => `
|
|
1028
|
+
mutation updateProduct($productId: String!, $product: ProductInput!, $template: Boolean) {
|
|
1029
|
+
updateProduct(productId: $productId, product: $product, template: $template) {
|
|
1030
|
+
${mutation}
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
`,
|
|
1034
|
+
removeProduct: (mutation) => `
|
|
1035
|
+
mutation removeProduct($productId: String!, $template: Boolean) {
|
|
1036
|
+
removeProduct(productId: $productId, template: $template) {
|
|
1037
|
+
${mutation}
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
`
|
|
1041
|
+
};
|
|
1042
|
+
|
|
1043
|
+
// src/services/inventory/product.service.ts
|
|
1044
|
+
var createProductService = (client) => ({
|
|
1045
|
+
async searchCategoriesAndTemplate(input, fetchFields, option) {
|
|
1046
|
+
var _a, _b, _c, _d;
|
|
1047
|
+
const res = await client.request(
|
|
1048
|
+
productSchema.searchCategoriesAndTemplate(
|
|
1049
|
+
gqlQueryStringBuilder(
|
|
1050
|
+
(_a = fetchFields == null ? void 0 : fetchFields.root) != null ? _a : searchCategoriesAndTemplateResponse,
|
|
1051
|
+
(_b = fetchFields == null ? void 0 : fetchFields.nestedFields) != null ? _b : searchCategoriesAndTemplateResponseNestedFields
|
|
1052
|
+
)
|
|
1053
|
+
),
|
|
1054
|
+
input,
|
|
1055
|
+
option
|
|
1056
|
+
);
|
|
1057
|
+
return (_d = (_c = res.data) == null ? void 0 : _c.searchCategoriesAndTemplate) != null ? _d : null;
|
|
1058
|
+
},
|
|
1059
|
+
async searchProductNames(input, fetchFields, option) {
|
|
1060
|
+
var _a, _b, _c, _d;
|
|
1061
|
+
const res = await client.request(
|
|
1062
|
+
productSchema.searchProductNames(
|
|
1063
|
+
gqlQueryStringBuilder(
|
|
1064
|
+
(_a = fetchFields == null ? void 0 : fetchFields.root) != null ? _a : searchProductNamesResponse,
|
|
1065
|
+
(_b = fetchFields == null ? void 0 : fetchFields.nestedFields) != null ? _b : searchProductNamesResponseNestedFields
|
|
1066
|
+
)
|
|
1067
|
+
),
|
|
1068
|
+
input,
|
|
1069
|
+
option
|
|
1070
|
+
);
|
|
1071
|
+
return (_d = (_c = res.data) == null ? void 0 : _c.searchProductNames) != null ? _d : null;
|
|
1072
|
+
},
|
|
1073
|
+
async updateProduct(input, fetchFields, option) {
|
|
1074
|
+
var _a, _b, _c, _d;
|
|
1075
|
+
const res = await client.request(
|
|
1076
|
+
productSchema.updateProduct(
|
|
1077
|
+
gqlQueryStringBuilder(
|
|
1078
|
+
(_a = fetchFields == null ? void 0 : fetchFields.root) != null ? _a : updateProductResponseFields,
|
|
1079
|
+
(_b = fetchFields == null ? void 0 : fetchFields.nestedFields) != null ? _b : updateProductResponseNestedFields
|
|
1080
|
+
)
|
|
1081
|
+
),
|
|
1082
|
+
input,
|
|
1083
|
+
option
|
|
1084
|
+
);
|
|
1085
|
+
return (_d = (_c = res.data) == null ? void 0 : _c.updateProduct) != null ? _d : null;
|
|
1086
|
+
},
|
|
1087
|
+
async removeProduct(input, fetchFields, option) {
|
|
1088
|
+
var _a, _b, _c;
|
|
1089
|
+
const res = await client.request(
|
|
1090
|
+
productSchema.removeProduct(
|
|
1091
|
+
gqlQueryStringBuilder(
|
|
1092
|
+
(_a = fetchFields == null ? void 0 : fetchFields.root) != null ? _a : removeProductResponseFields
|
|
1093
|
+
)
|
|
1094
|
+
),
|
|
1095
|
+
input,
|
|
1096
|
+
option
|
|
1097
|
+
);
|
|
1098
|
+
return (_c = (_b = res.data) == null ? void 0 : _b.removeProduct) != null ? _c : null;
|
|
1099
|
+
},
|
|
1100
|
+
async addProduct(input, fetchFields, option) {
|
|
1101
|
+
var _a, _b, _c, _d;
|
|
1102
|
+
const res = await client.request(
|
|
1103
|
+
productSchema.addProduct(
|
|
1104
|
+
gqlQueryStringBuilder(
|
|
1105
|
+
(_a = fetchFields == null ? void 0 : fetchFields.root) != null ? _a : addProductResponseFields,
|
|
1106
|
+
(_b = fetchFields == null ? void 0 : fetchFields.nestedFields) != null ? _b : addProductResponseNestedFields
|
|
1107
|
+
)
|
|
1108
|
+
),
|
|
1109
|
+
input,
|
|
1110
|
+
option
|
|
1111
|
+
);
|
|
1112
|
+
return (_d = (_c = res.data) == null ? void 0 : _c.addProduct) != null ? _d : null;
|
|
1113
|
+
},
|
|
1114
|
+
async getProduct(input, fetchFields, option) {
|
|
1115
|
+
var _a, _b, _c, _d;
|
|
1116
|
+
const res = await client.request(
|
|
1117
|
+
productSchema.getProduct(
|
|
1118
|
+
gqlQueryStringBuilder(
|
|
1119
|
+
(_a = fetchFields == null ? void 0 : fetchFields.root) != null ? _a : getProductResponseFields,
|
|
1120
|
+
(_b = fetchFields == null ? void 0 : fetchFields.nestedFields) != null ? _b : getProductResponseNestedFields
|
|
1121
|
+
)
|
|
1122
|
+
),
|
|
1123
|
+
input,
|
|
1124
|
+
option
|
|
1125
|
+
);
|
|
1126
|
+
return (_d = (_c = res.data) == null ? void 0 : _c.getProduct) != null ? _d : null;
|
|
1127
|
+
},
|
|
1128
|
+
async getProducts(input, fetchFields, option) {
|
|
1129
|
+
var _a, _b, _c, _d;
|
|
1130
|
+
const res = await client.request(
|
|
1131
|
+
productSchema.getProducts(
|
|
1132
|
+
gqlQueryStringBuilder(
|
|
1133
|
+
(_a = fetchFields == null ? void 0 : fetchFields.root) != null ? _a : getProductsResponseFields,
|
|
1134
|
+
(_b = fetchFields == null ? void 0 : fetchFields.nestedFields) != null ? _b : getProductsResponseNestedFields
|
|
1135
|
+
)
|
|
1136
|
+
),
|
|
1137
|
+
input,
|
|
1138
|
+
option
|
|
1139
|
+
);
|
|
1140
|
+
return (_d = (_c = res.data) == null ? void 0 : _c.getProducts) != null ? _d : null;
|
|
1141
|
+
}
|
|
1142
|
+
});
|
|
1143
|
+
|
|
1144
|
+
// src/services/inventory/schema/stock.schema.ts
|
|
1145
|
+
var stockSchema = {
|
|
1146
|
+
getStock: (query) => `
|
|
1147
|
+
query getStock($stock: StockInput!) {
|
|
1148
|
+
stock(stock: $stock) {
|
|
1149
|
+
${query}
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
`,
|
|
1153
|
+
getStocks: (query) => `
|
|
1154
|
+
query getStocks($stock: StockInput, $stockIds: [String], $limit: Int!, $skip: Int!) {
|
|
1155
|
+
stocks(stock: $stock, stockIds: $stockIds, limit: $limit, skip: $skip) {
|
|
1156
|
+
${query}
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
`,
|
|
1160
|
+
addStock: (mutation) => `
|
|
1161
|
+
mutation addStock($stock: StockInput!) {
|
|
1162
|
+
addStock(stock: $stock) {
|
|
1163
|
+
${mutation}
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
`,
|
|
1167
|
+
updateStock: (mutation) => `
|
|
1168
|
+
mutation updateStock($stockId: String!, $stock: StockInput!) {
|
|
1169
|
+
updateStock(stockId: $stockId, stock: $stock) {
|
|
1170
|
+
${mutation}
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
`,
|
|
1174
|
+
removeStock: (mutation) => `
|
|
1175
|
+
mutation removeStock($stockId: String!) {
|
|
1176
|
+
removeStock(stockId: $stockId) {
|
|
1177
|
+
${mutation}
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
`
|
|
1181
|
+
};
|
|
1182
|
+
|
|
1183
|
+
// src/services/inventory/stock.service.ts
|
|
1184
|
+
var createStockService = (client) => ({
|
|
1185
|
+
async updateStock(input, fetchFields, option) {
|
|
1186
|
+
var _a, _b, _c, _d;
|
|
1187
|
+
const res = await client.request(
|
|
1188
|
+
stockSchema.updateStock(
|
|
1189
|
+
gqlQueryStringBuilder(
|
|
1190
|
+
(_a = fetchFields == null ? void 0 : fetchFields.root) != null ? _a : updateStockResponse,
|
|
1191
|
+
(_b = fetchFields == null ? void 0 : fetchFields.nestedFields) != null ? _b : updateStockResponseNestedFields
|
|
1192
|
+
)
|
|
1193
|
+
),
|
|
1194
|
+
input,
|
|
1195
|
+
option
|
|
1196
|
+
);
|
|
1197
|
+
return (_d = (_c = res.data) == null ? void 0 : _c.updateStock) != null ? _d : null;
|
|
1198
|
+
},
|
|
1199
|
+
async removeStock(input, fetchFields, option) {
|
|
1200
|
+
var _a, _b, _c;
|
|
1201
|
+
const res = await client.request(
|
|
1202
|
+
stockSchema.removeStock(
|
|
1203
|
+
gqlQueryStringBuilder(
|
|
1204
|
+
(_a = fetchFields == null ? void 0 : fetchFields.root) != null ? _a : removeStockResponse
|
|
1205
|
+
)
|
|
1206
|
+
),
|
|
1207
|
+
input,
|
|
1208
|
+
option
|
|
1209
|
+
);
|
|
1210
|
+
return (_c = (_b = res.data) == null ? void 0 : _b.removeStock) != null ? _c : null;
|
|
1211
|
+
},
|
|
1212
|
+
async addStock(input, fetchFields, option) {
|
|
1213
|
+
var _a, _b, _c, _d;
|
|
1214
|
+
const res = await client.request(
|
|
1215
|
+
stockSchema.addStock(
|
|
1216
|
+
gqlQueryStringBuilder(
|
|
1217
|
+
(_a = fetchFields == null ? void 0 : fetchFields.root) != null ? _a : addStockResponse,
|
|
1218
|
+
(_b = fetchFields == null ? void 0 : fetchFields.nestedFields) != null ? _b : addStockResponseNestedFields
|
|
1219
|
+
)
|
|
1220
|
+
),
|
|
1221
|
+
input,
|
|
1222
|
+
option
|
|
1223
|
+
);
|
|
1224
|
+
return (_d = (_c = res.data) == null ? void 0 : _c.addStock) != null ? _d : null;
|
|
1225
|
+
},
|
|
1226
|
+
async getStock(input, fetchFields, option) {
|
|
1227
|
+
var _a, _b, _c, _d;
|
|
1228
|
+
const res = await client.request(
|
|
1229
|
+
stockSchema.getStock(
|
|
1230
|
+
gqlQueryStringBuilder(
|
|
1231
|
+
(_a = fetchFields == null ? void 0 : fetchFields.root) != null ? _a : getStockResponse,
|
|
1232
|
+
(_b = fetchFields == null ? void 0 : fetchFields.nestedFields) != null ? _b : getStockResponseNestedFields
|
|
1233
|
+
)
|
|
1234
|
+
),
|
|
1235
|
+
input,
|
|
1236
|
+
option
|
|
1237
|
+
);
|
|
1238
|
+
return (_d = (_c = res.data) == null ? void 0 : _c.getStock) != null ? _d : null;
|
|
1239
|
+
},
|
|
1240
|
+
async getStocks(input, fetchFields, option) {
|
|
1241
|
+
var _a, _b, _c, _d;
|
|
1242
|
+
const res = await client.request(
|
|
1243
|
+
stockSchema.getStocks(
|
|
1244
|
+
gqlQueryStringBuilder(
|
|
1245
|
+
(_a = fetchFields == null ? void 0 : fetchFields.root) != null ? _a : getStocksResponse,
|
|
1246
|
+
(_b = fetchFields == null ? void 0 : fetchFields.nestedFields) != null ? _b : getStocksResponseNestedFields
|
|
1247
|
+
)
|
|
1248
|
+
),
|
|
1249
|
+
input,
|
|
1250
|
+
option
|
|
1251
|
+
);
|
|
1252
|
+
return (_d = (_c = res.data) == null ? void 0 : _c.getStocks) != null ? _d : null;
|
|
1253
|
+
}
|
|
1254
|
+
});
|
|
1255
|
+
|
|
1256
|
+
// src/services/inventory/schema/store.schema.ts
|
|
1257
|
+
var storeSchema = {
|
|
1258
|
+
getStore: (query) => `
|
|
1259
|
+
query getStore($store: StoreInput!) {
|
|
1260
|
+
store(store: $store) {
|
|
1261
|
+
${query}
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
`,
|
|
1265
|
+
getStores: (query) => `
|
|
1266
|
+
query getStores($search: String, $store: StoreInput, $storeIds: [String], $limit: Int, $skip: Int) {
|
|
1267
|
+
stores(search: $search, store: $store, storeIds: $storeIds, limit: $limit, skip: $skip) {
|
|
1268
|
+
${query}
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
`,
|
|
1272
|
+
createStore: (mutation) => `
|
|
1273
|
+
mutation createStore($store: StoreInput) {
|
|
1274
|
+
createStore(store: $store) {
|
|
1275
|
+
${mutation}
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
`,
|
|
1279
|
+
updateStore: (mutation) => `
|
|
1280
|
+
mutation updateStore($storeId: String, $store: StoreInput) {
|
|
1281
|
+
updateStore(storeId: $storeId, store: $store) {
|
|
1282
|
+
${mutation}
|
|
1283
|
+
}
|
|
1284
|
+
}
|
|
1285
|
+
`,
|
|
1286
|
+
deleteStore: (mutation) => `
|
|
1287
|
+
mutation deleteStore($storeId: String) {
|
|
1288
|
+
deleteStore(storeId: $storeId) {
|
|
1289
|
+
${mutation}
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
`
|
|
1293
|
+
};
|
|
1294
|
+
|
|
1295
|
+
// src/services/inventory/store.service.ts
|
|
1296
|
+
var createStoreService = (client) => ({
|
|
1297
|
+
async updateStore(input, fetchFields, option) {
|
|
1298
|
+
var _a, _b, _c, _d;
|
|
1299
|
+
const res = await client.request(
|
|
1300
|
+
storeSchema.updateStore(
|
|
1301
|
+
gqlQueryStringBuilder(
|
|
1302
|
+
(_a = fetchFields == null ? void 0 : fetchFields.root) != null ? _a : updateStoreResponse,
|
|
1303
|
+
(_b = fetchFields == null ? void 0 : fetchFields.nestedFields) != null ? _b : updateStoreResponseNestedFields
|
|
1304
|
+
)
|
|
1305
|
+
),
|
|
1306
|
+
input,
|
|
1307
|
+
option
|
|
1308
|
+
);
|
|
1309
|
+
return (_d = (_c = res.data) == null ? void 0 : _c.updateStore) != null ? _d : null;
|
|
1310
|
+
},
|
|
1311
|
+
async removeStore(input, fetchFields, option) {
|
|
1312
|
+
var _a, _b, _c;
|
|
1313
|
+
const res = await client.request(
|
|
1314
|
+
storeSchema.deleteStore(
|
|
1315
|
+
gqlQueryStringBuilder(
|
|
1316
|
+
(_a = fetchFields == null ? void 0 : fetchFields.root) != null ? _a : removeStoreResponse
|
|
1317
|
+
)
|
|
1318
|
+
),
|
|
1319
|
+
input,
|
|
1320
|
+
option
|
|
1321
|
+
);
|
|
1322
|
+
return (_c = (_b = res.data) == null ? void 0 : _b.removeStore) != null ? _c : null;
|
|
1323
|
+
},
|
|
1324
|
+
async addStore(input, fetchFields, option) {
|
|
1325
|
+
var _a, _b, _c, _d;
|
|
1326
|
+
const res = await client.request(
|
|
1327
|
+
storeSchema.createStore(
|
|
1328
|
+
gqlQueryStringBuilder(
|
|
1329
|
+
(_a = fetchFields == null ? void 0 : fetchFields.root) != null ? _a : addStoreResponse,
|
|
1330
|
+
(_b = fetchFields == null ? void 0 : fetchFields.nestedFields) != null ? _b : addStoreResponseNestedFields
|
|
1331
|
+
)
|
|
1332
|
+
),
|
|
1333
|
+
input,
|
|
1334
|
+
option
|
|
1335
|
+
);
|
|
1336
|
+
return (_d = (_c = res.data) == null ? void 0 : _c.addStore) != null ? _d : null;
|
|
1337
|
+
},
|
|
1338
|
+
async getStore(input, fetchFields, option) {
|
|
1339
|
+
var _a, _b, _c, _d;
|
|
1340
|
+
const res = await client.request(
|
|
1341
|
+
storeSchema.getStore(
|
|
1342
|
+
gqlQueryStringBuilder(
|
|
1343
|
+
(_a = fetchFields == null ? void 0 : fetchFields.root) != null ? _a : getStoreResponse,
|
|
1344
|
+
(_b = fetchFields == null ? void 0 : fetchFields.nestedFields) != null ? _b : getStoreResponseNestedFields
|
|
1345
|
+
)
|
|
1346
|
+
),
|
|
1347
|
+
input,
|
|
1348
|
+
option
|
|
1349
|
+
);
|
|
1350
|
+
return (_d = (_c = res.data) == null ? void 0 : _c.getStore) != null ? _d : null;
|
|
1351
|
+
},
|
|
1352
|
+
async getStores(input, fetchFields, option) {
|
|
1353
|
+
var _a, _b, _c, _d;
|
|
1354
|
+
const res = await client.request(
|
|
1355
|
+
storeSchema.getStores(
|
|
1356
|
+
gqlQueryStringBuilder(
|
|
1357
|
+
(_a = fetchFields == null ? void 0 : fetchFields.root) != null ? _a : getStoresResponse,
|
|
1358
|
+
(_b = fetchFields == null ? void 0 : fetchFields.nestedFields) != null ? _b : getStoresResponseNestedFields
|
|
1359
|
+
)
|
|
1360
|
+
),
|
|
1361
|
+
input,
|
|
1362
|
+
option
|
|
1363
|
+
);
|
|
1364
|
+
return (_d = (_c = res.data) == null ? void 0 : _c.getStores) != null ? _d : null;
|
|
1365
|
+
}
|
|
1366
|
+
});
|
|
1367
|
+
|
|
1368
|
+
// src/services/sales/schemas/order.schema.ts
|
|
1369
|
+
var orderSchema = {
|
|
1370
|
+
getOrder: (query) => `
|
|
1371
|
+
query getOrder($order: OrderInput) {
|
|
1372
|
+
getOrder(order: $order){
|
|
1373
|
+
${query}
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
`,
|
|
1377
|
+
getOrders: (query) => `
|
|
1378
|
+
query getOrders($orderIds: [String], $order: OrderInput, $limit: Int, $skip: Int){
|
|
1379
|
+
getOrders(orderIds: $orderIds, order: $order, limit: $limit, skip: $skip){
|
|
1380
|
+
${query}
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
`
|
|
1384
|
+
};
|
|
1385
|
+
|
|
1386
|
+
// src/services/sales/sale.entity.ts
|
|
1387
|
+
var transactionQuery = [
|
|
1388
|
+
"_id",
|
|
1389
|
+
"amountPaid",
|
|
1390
|
+
"amountTotal",
|
|
1391
|
+
"createdAt",
|
|
1392
|
+
"from",
|
|
1393
|
+
"fromWallet",
|
|
1394
|
+
"isCredit",
|
|
1395
|
+
"paymentDate",
|
|
1396
|
+
"paymentType",
|
|
1397
|
+
"platform",
|
|
1398
|
+
"saleIds",
|
|
1399
|
+
"saleStatus",
|
|
1400
|
+
"sales",
|
|
1401
|
+
"storeId",
|
|
1402
|
+
"to",
|
|
1403
|
+
"toWallet",
|
|
1404
|
+
"txStatus"
|
|
1405
|
+
];
|
|
1406
|
+
var orderQuery = [
|
|
1407
|
+
"_id",
|
|
1408
|
+
"createdAt",
|
|
1409
|
+
"orderStatus",
|
|
1410
|
+
"transactionId",
|
|
1411
|
+
"userId"
|
|
1412
|
+
];
|
|
1413
|
+
var saleQuery = [
|
|
1414
|
+
"_id",
|
|
1415
|
+
"amountTotal",
|
|
1416
|
+
"createdAt",
|
|
1417
|
+
"packageId",
|
|
1418
|
+
"productId",
|
|
1419
|
+
"quantity",
|
|
1420
|
+
"quantityInMetricUnit",
|
|
1421
|
+
"storeId"
|
|
1422
|
+
];
|
|
1423
|
+
|
|
1424
|
+
// src/services/sales/types/order.type.ts
|
|
1425
|
+
var getOrderResponse = ["order"];
|
|
1426
|
+
var getOrderResponseNestedFields = {
|
|
1427
|
+
order: orderQuery
|
|
1428
|
+
};
|
|
1429
|
+
var getOrdersResponse = ["orders"];
|
|
1430
|
+
var getOrdersResponseNestedFields = {
|
|
1431
|
+
orders: orderQuery
|
|
1432
|
+
};
|
|
1433
|
+
|
|
1434
|
+
// src/services/sales/order.service.ts
|
|
1435
|
+
var createOrderService = (client) => ({
|
|
1436
|
+
async getOrder(input, fetchFields, option) {
|
|
1437
|
+
var _a, _b, _c, _d;
|
|
1438
|
+
const res = await client.request(
|
|
1439
|
+
orderSchema.getOrder(
|
|
1440
|
+
gqlQueryStringBuilder(
|
|
1441
|
+
(_a = fetchFields == null ? void 0 : fetchFields.root) != null ? _a : getOrderResponse,
|
|
1442
|
+
(_b = fetchFields == null ? void 0 : fetchFields.nestedFields) != null ? _b : getOrderResponseNestedFields
|
|
1443
|
+
)
|
|
1444
|
+
),
|
|
1445
|
+
input,
|
|
1446
|
+
option
|
|
1447
|
+
);
|
|
1448
|
+
return (_d = (_c = res.data) == null ? void 0 : _c.getOrder) != null ? _d : null;
|
|
1449
|
+
},
|
|
1450
|
+
async getOrders(input, fetchFields, option) {
|
|
1451
|
+
var _a, _b, _c, _d;
|
|
1452
|
+
const res = await client.request(
|
|
1453
|
+
orderSchema.getOrders(
|
|
1454
|
+
gqlQueryStringBuilder(
|
|
1455
|
+
(_a = fetchFields == null ? void 0 : fetchFields.root) != null ? _a : getOrdersResponse,
|
|
1456
|
+
(_b = fetchFields == null ? void 0 : fetchFields.nestedFields) != null ? _b : getOrdersResponseNestedFields
|
|
1457
|
+
)
|
|
1458
|
+
),
|
|
1459
|
+
input,
|
|
1460
|
+
option
|
|
1461
|
+
);
|
|
1462
|
+
return (_d = (_c = res.data) == null ? void 0 : _c.getOrders) != null ? _d : null;
|
|
1463
|
+
}
|
|
1464
|
+
});
|
|
1465
|
+
|
|
1466
|
+
// src/services/sales/schemas/sale.schema.ts
|
|
1467
|
+
var saleSchema = {
|
|
1468
|
+
getSales: (query) => `
|
|
1469
|
+
query getSales($saleIds: [String], $saleFilter: SaleFilterInput, $ShouldGetFromAllStores: Boolean, $dateFilter: DateFilterInput, $limit: Int, $skip: Int) {
|
|
1470
|
+
getSales(saleIds: $saleIds, saleFilter: $saleFilter, ShouldGetFromAllStores: $ShouldGetFromAllStores, dateFilter: $dateFilter, limit: $limit, skip: $skip) {
|
|
1471
|
+
${query}
|
|
1472
|
+
}
|
|
1473
|
+
}
|
|
1474
|
+
`,
|
|
1475
|
+
updateSale: (query) => `
|
|
1476
|
+
mutation updateSale($saleId: String!, $sale: SaleInput!) {
|
|
1477
|
+
updateSale(saleId: $saleId, sale: $sale) {
|
|
1478
|
+
${query}
|
|
1479
|
+
}
|
|
1480
|
+
}
|
|
1481
|
+
`
|
|
1482
|
+
};
|
|
1483
|
+
|
|
1484
|
+
// src/services/sales/types/sale.type.ts
|
|
1485
|
+
var getSaleResponse = ["sale"];
|
|
1486
|
+
var _getSaleResponseNestedFields = {
|
|
1487
|
+
..._getProductResponseNestedFields
|
|
1488
|
+
};
|
|
1489
|
+
var getSaleResponseNestedFields = {
|
|
1490
|
+
sale: saleQuery,
|
|
1491
|
+
..._getSaleResponseNestedFields
|
|
1492
|
+
};
|
|
1493
|
+
var getSalesResponse = [
|
|
1494
|
+
"sales",
|
|
1495
|
+
"uniqueProducts"
|
|
1496
|
+
];
|
|
1497
|
+
var getSalesResponseNestedFields = {
|
|
1498
|
+
sales: saleQuery,
|
|
1499
|
+
uniqueProducts: productQuery,
|
|
1500
|
+
..._getSaleResponseNestedFields
|
|
1501
|
+
};
|
|
1502
|
+
var UpdateSaleResponse = ["sale"];
|
|
1503
|
+
var updateSaleResponseNestedFields = getSaleResponseNestedFields;
|
|
1504
|
+
|
|
1505
|
+
// src/services/sales/sale.service.ts
|
|
1506
|
+
var createSaleService = (client) => ({
|
|
1507
|
+
async updateSale(input, fetchFields, option) {
|
|
1508
|
+
var _a, _b, _c, _d;
|
|
1509
|
+
const res = await client.request(
|
|
1510
|
+
saleSchema.updateSale(
|
|
1511
|
+
gqlQueryStringBuilder(
|
|
1512
|
+
(_a = fetchFields == null ? void 0 : fetchFields.root) != null ? _a : UpdateSaleResponse,
|
|
1513
|
+
(_b = fetchFields == null ? void 0 : fetchFields.nestedFields) != null ? _b : updateSaleResponseNestedFields
|
|
1514
|
+
)
|
|
1515
|
+
),
|
|
1516
|
+
input,
|
|
1517
|
+
option
|
|
1518
|
+
);
|
|
1519
|
+
return (_d = (_c = res.data) == null ? void 0 : _c.updateSale) != null ? _d : null;
|
|
1520
|
+
},
|
|
1521
|
+
async getSales(input, fetchFields, option) {
|
|
1522
|
+
var _a, _b, _c, _d;
|
|
1523
|
+
const res = await client.request(
|
|
1524
|
+
saleSchema.getSales(
|
|
1525
|
+
gqlQueryStringBuilder(
|
|
1526
|
+
(_a = fetchFields == null ? void 0 : fetchFields.root) != null ? _a : getSalesResponse,
|
|
1527
|
+
(_b = fetchFields == null ? void 0 : fetchFields.nestedFields) != null ? _b : getSalesResponseNestedFields
|
|
1528
|
+
)
|
|
1529
|
+
),
|
|
1530
|
+
input,
|
|
1531
|
+
option
|
|
1532
|
+
);
|
|
1533
|
+
return (_d = (_c = res.data) == null ? void 0 : _c.getSales) != null ? _d : null;
|
|
1534
|
+
}
|
|
1535
|
+
});
|
|
1536
|
+
|
|
1537
|
+
// src/services/sales/schemas/transaction.schema.ts
|
|
1538
|
+
var transactionSchema = {
|
|
1539
|
+
getTransaction: (query) => `
|
|
1540
|
+
query getTransaction($transaction: TransactionInput!){
|
|
1541
|
+
getTransaction(transaction: $transaction){
|
|
1542
|
+
${query}
|
|
1543
|
+
}
|
|
1544
|
+
}
|
|
1545
|
+
`,
|
|
1546
|
+
getTransactions: (query) => `
|
|
1547
|
+
query getTransactions($dateFilter: DateFilterInput, $transactionIds: [String], $transaction: TransactionInput, $limit: Int, $skip: Int, $shouldGetFromAllStores: Boolean){
|
|
1548
|
+
getTransactions(dateFilter: $dateFilter, transactionIds: $transactionIds, transaction: $transaction, limit: $limit, skip: $skip, shouldGetFromAllStores: $shouldGetFromAllStores){
|
|
1549
|
+
${query}
|
|
1550
|
+
}
|
|
1551
|
+
}
|
|
1552
|
+
`,
|
|
1553
|
+
addTransaction: (query) => `
|
|
1554
|
+
mutation addTransaction($sales: [SaleInput]!, $transaction: TransactionInput!){
|
|
1555
|
+
addTransaction(sales: $sales, transaction: $transaction){
|
|
1556
|
+
${query}
|
|
1557
|
+
}
|
|
1558
|
+
}
|
|
1559
|
+
`,
|
|
1560
|
+
updateTransaction: (query) => `
|
|
1561
|
+
mutation updateTransaction($transactionId: String!, $transaction: TransactionInput!){
|
|
1562
|
+
updateTransaction(transactionId: $transactionId, transaction: $transaction){
|
|
1563
|
+
${query}
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1566
|
+
`
|
|
1567
|
+
};
|
|
1568
|
+
|
|
1569
|
+
// src/services/sales/types/transaction.type.ts
|
|
1570
|
+
var getTransactionResponse = [
|
|
1571
|
+
"transaction"
|
|
1572
|
+
];
|
|
1573
|
+
var _getTransactionResponseNestedFields = {
|
|
1574
|
+
sales: saleQuery
|
|
1575
|
+
};
|
|
1576
|
+
var getTransactionResponseNestedFields = {
|
|
1577
|
+
transaction: transactionQuery,
|
|
1578
|
+
..._getTransactionResponseNestedFields
|
|
1579
|
+
};
|
|
1580
|
+
var getTransactionsResponse = [
|
|
1581
|
+
"transactions",
|
|
1582
|
+
"uniqueProducts"
|
|
1583
|
+
];
|
|
1584
|
+
var _getTransactionsResponseNestedFields = {
|
|
1585
|
+
sales: saleQuery,
|
|
1586
|
+
uniqueProducts: productNameQuery,
|
|
1587
|
+
..._getProductResponseNestedFields
|
|
1588
|
+
};
|
|
1589
|
+
var getTransactionsResponseNestedFields = {
|
|
1590
|
+
transactions: transactionQuery,
|
|
1591
|
+
..._getTransactionsResponseNestedFields
|
|
1592
|
+
};
|
|
1593
|
+
var addTransactionResponse = getTransactionResponse;
|
|
1594
|
+
var addTransactionResponseNestedFields = getTransactionResponseNestedFields;
|
|
1595
|
+
var updateTransactionResponse = getTransactionResponse;
|
|
1596
|
+
var updateTransactionResponseNestedFields = getTransactionResponseNestedFields;
|
|
1597
|
+
|
|
1598
|
+
// src/services/sales/transaction.service.ts
|
|
1599
|
+
var createTransactionService = (client) => ({
|
|
1600
|
+
async updateTransaction(input, fetchFields, option) {
|
|
1601
|
+
var _a, _b, _c, _d;
|
|
1602
|
+
const res = await client.request(
|
|
1603
|
+
transactionSchema.updateTransaction(
|
|
1604
|
+
gqlQueryStringBuilder(
|
|
1605
|
+
(_a = fetchFields == null ? void 0 : fetchFields.root) != null ? _a : updateTransactionResponse,
|
|
1606
|
+
(_b = fetchFields == null ? void 0 : fetchFields.nestedFields) != null ? _b : updateTransactionResponseNestedFields
|
|
1607
|
+
)
|
|
1608
|
+
),
|
|
1609
|
+
input,
|
|
1610
|
+
option
|
|
1611
|
+
);
|
|
1612
|
+
return (_d = (_c = res.data) == null ? void 0 : _c.updateTransaction) != null ? _d : null;
|
|
1613
|
+
},
|
|
1614
|
+
async addTransaction(input, fetchFields, option) {
|
|
1615
|
+
var _a, _b, _c, _d;
|
|
1616
|
+
const res = await client.request(
|
|
1617
|
+
transactionSchema.addTransaction(
|
|
1618
|
+
gqlQueryStringBuilder(
|
|
1619
|
+
(_a = fetchFields == null ? void 0 : fetchFields.root) != null ? _a : addTransactionResponse,
|
|
1620
|
+
(_b = fetchFields == null ? void 0 : fetchFields.nestedFields) != null ? _b : addTransactionResponseNestedFields
|
|
1621
|
+
)
|
|
1622
|
+
),
|
|
1623
|
+
input,
|
|
1624
|
+
option
|
|
1625
|
+
);
|
|
1626
|
+
return (_d = (_c = res.data) == null ? void 0 : _c.addTransaction) != null ? _d : null;
|
|
1627
|
+
},
|
|
1628
|
+
async getTransaction(input, fetchFields, option) {
|
|
1629
|
+
var _a, _b, _c, _d;
|
|
1630
|
+
const res = await client.request(
|
|
1631
|
+
transactionSchema.getTransaction(
|
|
1632
|
+
gqlQueryStringBuilder(
|
|
1633
|
+
(_a = fetchFields == null ? void 0 : fetchFields.root) != null ? _a : getTransactionResponse,
|
|
1634
|
+
(_b = fetchFields == null ? void 0 : fetchFields.nestedFields) != null ? _b : getTransactionResponseNestedFields
|
|
1635
|
+
)
|
|
1636
|
+
),
|
|
1637
|
+
input,
|
|
1638
|
+
option
|
|
1639
|
+
);
|
|
1640
|
+
return (_d = (_c = res.data) == null ? void 0 : _c.getTransaction) != null ? _d : null;
|
|
1641
|
+
},
|
|
1642
|
+
async getTransactions(input, fetchFields, option) {
|
|
1643
|
+
var _a, _b, _c, _d;
|
|
1644
|
+
const res = await client.request(
|
|
1645
|
+
transactionSchema.getTransactions(
|
|
1646
|
+
gqlQueryStringBuilder(
|
|
1647
|
+
(_a = fetchFields == null ? void 0 : fetchFields.root) != null ? _a : getTransactionsResponse,
|
|
1648
|
+
(_b = fetchFields == null ? void 0 : fetchFields.nestedFields) != null ? _b : getTransactionsResponseNestedFields
|
|
1649
|
+
)
|
|
1650
|
+
),
|
|
1651
|
+
input,
|
|
1652
|
+
option
|
|
1653
|
+
);
|
|
1654
|
+
return (_d = (_c = res.data) == null ? void 0 : _c.getTransactions) != null ? _d : null;
|
|
1655
|
+
}
|
|
1656
|
+
});
|
|
1657
|
+
|
|
1658
|
+
exports.AuthenticationError = AuthenticationError;
|
|
1659
|
+
exports.GraphQLClient = GraphQLClient;
|
|
1660
|
+
exports.NetworkError = NetworkError;
|
|
1661
|
+
exports.SdkError = SdkError;
|
|
1662
|
+
exports.UpdateSaleResponse = UpdateSaleResponse;
|
|
1663
|
+
exports._getPackageResponseNestedFields = _getPackageResponseNestedFields;
|
|
1664
|
+
exports._getProductResponseNestedFields = _getProductResponseNestedFields;
|
|
1665
|
+
exports._getSaleResponseNestedFields = _getSaleResponseNestedFields;
|
|
1666
|
+
exports._getStoreResponseNestedFields = _getStoreResponseNestedFields;
|
|
1667
|
+
exports._getTransactionResponseNestedFields = _getTransactionResponseNestedFields;
|
|
1668
|
+
exports._getTransactionsResponseNestedFields = _getTransactionsResponseNestedFields;
|
|
1669
|
+
exports.addPackageResponseFields = addPackageResponseFields;
|
|
1670
|
+
exports.addPackageResponseNestedFields = addPackageResponseNestedFields;
|
|
1671
|
+
exports.addPackagesResponseFields = addPackagesResponseFields;
|
|
1672
|
+
exports.addPackagesResponseNestedFields = addPackagesResponseNestedFields;
|
|
1673
|
+
exports.addPriceResponseFields = addPriceResponseFields;
|
|
1674
|
+
exports.addPriceResponseNestedFields = addPriceResponseNestedFields;
|
|
1675
|
+
exports.addProductResponseFields = addProductResponseFields;
|
|
1676
|
+
exports.addProductResponseNestedFields = addProductResponseNestedFields;
|
|
1677
|
+
exports.addStockResponse = addStockResponse;
|
|
1678
|
+
exports.addStockResponseNestedFields = addStockResponseNestedFields;
|
|
1679
|
+
exports.addStoreResponse = addStoreResponse;
|
|
1680
|
+
exports.addStoreResponseNestedFields = addStoreResponseNestedFields;
|
|
1681
|
+
exports.addTransactionResponse = addTransactionResponse;
|
|
1682
|
+
exports.addTransactionResponseNestedFields = addTransactionResponseNestedFields;
|
|
1683
|
+
exports.compose = compose;
|
|
1684
|
+
exports.createAuthService = createAuthService;
|
|
1685
|
+
exports.createOrderService = createOrderService;
|
|
1686
|
+
exports.createPackageService = createPackageService;
|
|
1687
|
+
exports.createPriceService = createPriceService;
|
|
1688
|
+
exports.createProductService = createProductService;
|
|
1689
|
+
exports.createSaleService = createSaleService;
|
|
1690
|
+
exports.createStockService = createStockService;
|
|
1691
|
+
exports.createStoreService = createStoreService;
|
|
1692
|
+
exports.createTransactionService = createTransactionService;
|
|
1693
|
+
exports.createTransport = createTransport;
|
|
1694
|
+
exports.createUserService = createUserService;
|
|
1695
|
+
exports.getOrderResponse = getOrderResponse;
|
|
1696
|
+
exports.getOrderResponseNestedFields = getOrderResponseNestedFields;
|
|
1697
|
+
exports.getOrdersResponse = getOrdersResponse;
|
|
1698
|
+
exports.getOrdersResponseNestedFields = getOrdersResponseNestedFields;
|
|
1699
|
+
exports.getPackageResponseFields = getPackageResponseFields;
|
|
1700
|
+
exports.getPackageResponseNestedFields = getPackageResponseNestedFields;
|
|
1701
|
+
exports.getPackagesResponseFields = getPackagesResponseFields;
|
|
1702
|
+
exports.getPackagesResponseNestedFields = getPackagesResponseNestedFields;
|
|
1703
|
+
exports.getPriceResponseFields = getPriceResponseFields;
|
|
1704
|
+
exports.getPriceResponseNestedFields = getPriceResponseNestedFields;
|
|
1705
|
+
exports.getPricesResponseFields = getPricesResponseFields;
|
|
1706
|
+
exports.getPricesResponseNestedFields = getPricesResponseNestedFields;
|
|
1707
|
+
exports.getProductByBarcodeResponse = getProductByBarcodeResponse;
|
|
1708
|
+
exports.getProductByBarcodeResponseNestedFields = getProductByBarcodeResponseNestedFields;
|
|
1709
|
+
exports.getProductResponseFields = getProductResponseFields;
|
|
1710
|
+
exports.getProductResponseNestedFields = getProductResponseNestedFields;
|
|
1711
|
+
exports.getProductsResponseFields = getProductsResponseFields;
|
|
1712
|
+
exports.getProductsResponseNestedFields = getProductsResponseNestedFields;
|
|
1713
|
+
exports.getSaleResponse = getSaleResponse;
|
|
1714
|
+
exports.getSaleResponseNestedFields = getSaleResponseNestedFields;
|
|
1715
|
+
exports.getSalesResponse = getSalesResponse;
|
|
1716
|
+
exports.getSalesResponseNestedFields = getSalesResponseNestedFields;
|
|
1717
|
+
exports.getStockResponse = getStockResponse;
|
|
1718
|
+
exports.getStockResponseNestedFields = getStockResponseNestedFields;
|
|
1719
|
+
exports.getStocksResponse = getStocksResponse;
|
|
1720
|
+
exports.getStocksResponseNestedFields = getStocksResponseNestedFields;
|
|
1721
|
+
exports.getStoreResponse = getStoreResponse;
|
|
1722
|
+
exports.getStoreResponseNestedFields = getStoreResponseNestedFields;
|
|
1723
|
+
exports.getStoresResponse = getStoresResponse;
|
|
1724
|
+
exports.getStoresResponseNestedFields = getStoresResponseNestedFields;
|
|
1725
|
+
exports.getTransactionResponse = getTransactionResponse;
|
|
1726
|
+
exports.getTransactionResponseNestedFields = getTransactionResponseNestedFields;
|
|
1727
|
+
exports.getTransactionsResponse = getTransactionsResponse;
|
|
1728
|
+
exports.getTransactionsResponseNestedFields = getTransactionsResponseNestedFields;
|
|
1729
|
+
exports.orderQuery = orderQuery;
|
|
1730
|
+
exports.removePackageResponseFields = removePackageResponseFields;
|
|
1731
|
+
exports.removePriceResponseFields = removePriceResponseFields;
|
|
1732
|
+
exports.removeProductResponseFields = removeProductResponseFields;
|
|
1733
|
+
exports.removeStockResponse = removeStockResponse;
|
|
1734
|
+
exports.removeStoreResponse = removeStoreResponse;
|
|
1735
|
+
exports.saleQuery = saleQuery;
|
|
1736
|
+
exports.searchCategoriesAndTemplateResponse = searchCategoriesAndTemplateResponse;
|
|
1737
|
+
exports.searchCategoriesAndTemplateResponseNestedFields = searchCategoriesAndTemplateResponseNestedFields;
|
|
1738
|
+
exports.searchProductNamesResponse = searchProductNamesResponse;
|
|
1739
|
+
exports.searchProductNamesResponseNestedFields = searchProductNamesResponseNestedFields;
|
|
1740
|
+
exports.toAsyncHeadersFactory = toAsyncHeadersFactory;
|
|
1741
|
+
exports.toAsyncTokenProvider = toAsyncTokenProvider;
|
|
1742
|
+
exports.transactionQuery = transactionQuery;
|
|
1743
|
+
exports.updatePackageResponseFields = updatePackageResponseFields;
|
|
1744
|
+
exports.updatePackageResponseNestedFields = updatePackageResponseNestedFields;
|
|
1745
|
+
exports.updatePriceResponseFields = updatePriceResponseFields;
|
|
1746
|
+
exports.updatePriceResponseNestedFields = updatePriceResponseNestedFields;
|
|
1747
|
+
exports.updateProductResponseFields = updateProductResponseFields;
|
|
1748
|
+
exports.updateProductResponseNestedFields = updateProductResponseNestedFields;
|
|
1749
|
+
exports.updateSaleResponseNestedFields = updateSaleResponseNestedFields;
|
|
1750
|
+
exports.updateStockResponse = updateStockResponse;
|
|
1751
|
+
exports.updateStockResponseNestedFields = updateStockResponseNestedFields;
|
|
1752
|
+
exports.updateStoreResponse = updateStoreResponse;
|
|
1753
|
+
exports.updateStoreResponseNestedFields = updateStoreResponseNestedFields;
|
|
1754
|
+
exports.updateTransactionResponse = updateTransactionResponse;
|
|
1755
|
+
exports.updateTransactionResponseNestedFields = updateTransactionResponseNestedFields;
|
|
1756
|
+
//# sourceMappingURL=index.cjs.js.map
|
|
1757
|
+
//# sourceMappingURL=index.cjs.js.map
|