@applite/js-sdk 0.0.1

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.mjs ADDED
@@ -0,0 +1,616 @@
1
+ // src/http.ts
2
+ var HttpClient = class {
3
+ constructor(config = {}) {
4
+ this.baseUrl = config.baseUrl?.replace(/\/$/, "") ?? "";
5
+ this.headers = config.headers ?? {};
6
+ this.fetchImpl = config.fetchFn ?? fetch;
7
+ }
8
+ async post(path, body) {
9
+ const url = `${this.baseUrl}${path}`;
10
+ const response = await this.fetchImpl(url, {
11
+ method: "POST",
12
+ headers: {
13
+ "Content-Type": "application/json",
14
+ ...this.headers
15
+ },
16
+ body: JSON.stringify(body)
17
+ });
18
+ const contentType = response.headers.get("content-type") ?? "";
19
+ const isJson = contentType.includes("application/json");
20
+ const payload = isJson ? await response.json() : null;
21
+ if (!response.ok) {
22
+ const message = payload?.error ?? response.statusText;
23
+ throw new Error(`Request failed with status ${response.status}: ${message}`);
24
+ }
25
+ if (!payload || payload.success !== true) {
26
+ throw new Error(`Request failed: ${payload?.error ?? "Unknown error"}`);
27
+ }
28
+ return payload;
29
+ }
30
+ };
31
+
32
+ // src/modules/app/customer.ts
33
+ var plateformTypes = [
34
+ "STORE",
35
+ "TRANSPORT",
36
+ "RESTAURATION",
37
+ "MULTI_SERVICE",
38
+ "E_LEARNING",
39
+ "DUTICOTAC"
40
+ ];
41
+ var sexes = ["M", "F"];
42
+ var AppCustomerModule = class {
43
+ constructor(http) {
44
+ this.http = http;
45
+ }
46
+ async list(params) {
47
+ const { appId, apiKey, plateformType = [] } = params;
48
+ return this.http.post(
49
+ `/app/${appId}/customer/list`,
50
+ {
51
+ apiKey,
52
+ plateformType
53
+ }
54
+ );
55
+ }
56
+ async auth(params) {
57
+ const { appId, apiKey, fullname, email = null, telephone, plateform = null } = params;
58
+ return this.http.post(`/app/${appId}/customer/auth`, {
59
+ apiKey,
60
+ fullname,
61
+ email,
62
+ telephone,
63
+ plateform
64
+ });
65
+ }
66
+ async check(params) {
67
+ const { appId, apiKey, telephone, plateform = null } = params;
68
+ return this.http.post(`/app/${appId}/customer/check`, {
69
+ apiKey,
70
+ telephone,
71
+ plateform
72
+ });
73
+ }
74
+ async listFew(params) {
75
+ const { appId, apiKey, plateformType = [] } = params;
76
+ return this.http.post(
77
+ `/app/${appId}/customer/list/few`,
78
+ {
79
+ apiKey,
80
+ plateformType
81
+ }
82
+ );
83
+ }
84
+ async get(params) {
85
+ const { appId, apiKey, id } = params;
86
+ return this.http.post(
87
+ `/app/${appId}/customer/${id}`,
88
+ {
89
+ apiKey
90
+ }
91
+ );
92
+ }
93
+ async update(params) {
94
+ const { appId, apiKey, id, ...rest } = params;
95
+ return this.http.post(
96
+ `/app/${appId}/customer/${id}/update`,
97
+ {
98
+ apiKey,
99
+ ...rest
100
+ }
101
+ );
102
+ }
103
+ };
104
+
105
+ // src/modules/app/finance.ts
106
+ var AppFinanceModule = class {
107
+ constructor(http) {
108
+ this.http = http;
109
+ }
110
+ balance(params) {
111
+ const { appId, ...body } = params;
112
+ return this.http.post(`/app/${appId}/balance`, body);
113
+ }
114
+ listTransactions(params) {
115
+ const { appId, ...body } = params;
116
+ return this.http.post(`/app/${appId}/transaction/list`, body);
117
+ }
118
+ getTransaction(params) {
119
+ const { appId, id, ...body } = params;
120
+ return this.http.post(`/app/${appId}/transaction/${id}`, body);
121
+ }
122
+ withdraw(params) {
123
+ const { appId, ...body } = params;
124
+ return this.http.post(`/app/${appId}/withdraw`, body);
125
+ }
126
+ };
127
+
128
+ // src/modules/app/info.ts
129
+ var AppInfoModule = class {
130
+ constructor(http) {
131
+ this.http = http;
132
+ }
133
+ list(params) {
134
+ return this.http.post("/app/app/list", params);
135
+ }
136
+ create(params) {
137
+ return this.http.post("/app/app/create", params);
138
+ }
139
+ getBySlug(params) {
140
+ const { slug, ...body } = params;
141
+ return this.http.post(`/app/app/get/${slug}`, body);
142
+ }
143
+ getById(params) {
144
+ const { appId, ...body } = params;
145
+ return this.http.post(`/app/app/${appId}`, body);
146
+ }
147
+ };
148
+
149
+ // src/modules/app/stats.ts
150
+ var AppStatsModule = class {
151
+ constructor(http) {
152
+ this.http = http;
153
+ }
154
+ create(params) {
155
+ const { appId, ...body } = params;
156
+ return this.http.post(`/app/${appId}/stats/create`, body);
157
+ }
158
+ get(params) {
159
+ const { appId, ...body } = params;
160
+ return this.http.post(`/app/${appId}/stats/get`, body);
161
+ }
162
+ set(params) {
163
+ const { appId, ...body } = params;
164
+ return this.http.post(`/app/${appId}/stats/set`, body);
165
+ }
166
+ update(params) {
167
+ const { appId, id, ...body } = params;
168
+ return this.http.post(`/app/${appId}/stats/${id}/update`, body);
169
+ }
170
+ };
171
+
172
+ // src/modules/app/store.ts
173
+ var StoreBadgeModule = class {
174
+ constructor(http) {
175
+ this.http = http;
176
+ }
177
+ list(params) {
178
+ const { appId, ...body } = params;
179
+ return this.http.post(`/app/${appId}/store/badge/list`, body);
180
+ }
181
+ create(params) {
182
+ const { appId, ...body } = params;
183
+ return this.http.post(`/app/${appId}/store/badge/create`, body);
184
+ }
185
+ get(params) {
186
+ const { appId, id, ...body } = params;
187
+ return this.http.post(`/app/${appId}/store/badge/${id}`, body);
188
+ }
189
+ update(params) {
190
+ const { appId, id, ...body } = params;
191
+ return this.http.post(`/app/${appId}/store/badge/${id}/edit`, body);
192
+ }
193
+ delete(params) {
194
+ const { appId, id, ...body } = params;
195
+ return this.http.post(`/app/${appId}/store/badge/${id}/delete`, body);
196
+ }
197
+ };
198
+ var StoreCategoryModule = class {
199
+ constructor(http) {
200
+ this.http = http;
201
+ }
202
+ list(params) {
203
+ const { appId, ...body } = params;
204
+ return this.http.post(`/app/${appId}/store/category/list`, body);
205
+ }
206
+ create(params) {
207
+ const { appId, ...body } = params;
208
+ return this.http.post(`/app/${appId}/store/category/create`, body);
209
+ }
210
+ get(params) {
211
+ const { appId, id, ...body } = params;
212
+ return this.http.post(`/app/${appId}/store/category/${id}`, body);
213
+ }
214
+ update(params) {
215
+ const { appId, id, ...body } = params;
216
+ return this.http.post(`/app/${appId}/store/category/${id}/edit`, body);
217
+ }
218
+ delete(params) {
219
+ const { appId, id, ...body } = params;
220
+ return this.http.post(`/app/${appId}/store/category/${id}/delete`, body);
221
+ }
222
+ };
223
+ var StoreCollectionModule = class {
224
+ constructor(http) {
225
+ this.http = http;
226
+ }
227
+ list(params) {
228
+ const { appId, ...body } = params;
229
+ return this.http.post(`/app/${appId}/store/collection/list`, body);
230
+ }
231
+ create(params) {
232
+ const { appId, ...body } = params;
233
+ return this.http.post(`/app/${appId}/store/collection/create`, body);
234
+ }
235
+ get(params) {
236
+ const { appId, id, ...body } = params;
237
+ return this.http.post(`/app/${appId}/store/collection/${id}`, body);
238
+ }
239
+ update(params) {
240
+ const { appId, id, ...body } = params;
241
+ return this.http.post(`/app/${appId}/store/collection/${id}/edit`, body);
242
+ }
243
+ delete(params) {
244
+ const { appId, id, ...body } = params;
245
+ return this.http.post(`/app/${appId}/store/collection/${id}/delete`, body);
246
+ }
247
+ };
248
+ var StoreDiscountModule = class {
249
+ constructor(http) {
250
+ this.http = http;
251
+ }
252
+ list(params) {
253
+ const { appId, ...body } = params;
254
+ return this.http.post(`/app/${appId}/store/discount/list`, body);
255
+ }
256
+ create(params) {
257
+ const { appId, ...body } = params;
258
+ return this.http.post(`/app/${appId}/store/discount/create`, body);
259
+ }
260
+ get(params) {
261
+ const { appId, id, ...body } = params;
262
+ return this.http.post(`/app/${appId}/store/discount/${id}`, body);
263
+ }
264
+ update(params) {
265
+ const { appId, id, ...body } = params;
266
+ return this.http.post(`/app/${appId}/store/discount/${id}/edit`, body);
267
+ }
268
+ delete(params) {
269
+ const { appId, id, ...body } = params;
270
+ return this.http.post(`/app/${appId}/store/discount/${id}/delete`, body);
271
+ }
272
+ };
273
+ var StoreOptionModule = class {
274
+ constructor(http) {
275
+ this.http = http;
276
+ }
277
+ list(params) {
278
+ const { appId, ...body } = params;
279
+ return this.http.post(`/app/${appId}/store/option/list`, body);
280
+ }
281
+ create(params) {
282
+ const { appId, ...body } = params;
283
+ return this.http.post(`/app/${appId}/store/option/create`, body);
284
+ }
285
+ get(params) {
286
+ const { appId, id, ...body } = params;
287
+ return this.http.post(`/app/${appId}/store/option/${id}`, body);
288
+ }
289
+ update(params) {
290
+ const { appId, id, ...body } = params;
291
+ return this.http.post(`/app/${appId}/store/option/${id}/edit`, body);
292
+ }
293
+ delete(params) {
294
+ const { appId, id, ...body } = params;
295
+ return this.http.post(`/app/${appId}/store/option/${id}/delete`, body);
296
+ }
297
+ };
298
+ var StoreOrderModule = class {
299
+ constructor(http) {
300
+ this.http = http;
301
+ }
302
+ list(params) {
303
+ const { appId, ...body } = params;
304
+ return this.http.post(`/app/${appId}/store/order/list`, body);
305
+ }
306
+ create(params) {
307
+ const { appId, ...body } = params;
308
+ return this.http.post(`/app/${appId}/store/order/create`, body);
309
+ }
310
+ get(params) {
311
+ const { appId, id, ...body } = params;
312
+ return this.http.post(`/app/${appId}/store/order/${id}`, body);
313
+ }
314
+ update(params) {
315
+ const { appId, id, ...body } = params;
316
+ return this.http.post(`/app/${appId}/store/order/${id}/edit`, body);
317
+ }
318
+ delete(params) {
319
+ const { appId, id, ...body } = params;
320
+ return this.http.post(`/app/${appId}/store/order/${id}/delete`, body);
321
+ }
322
+ };
323
+ var StoreProductModule = class {
324
+ constructor(http) {
325
+ this.http = http;
326
+ }
327
+ list(params) {
328
+ const { appId, ...body } = params;
329
+ return this.http.post(`/app/${appId}/store/product/list`, body);
330
+ }
331
+ create(params) {
332
+ const { appId, ...body } = params;
333
+ return this.http.post(`/app/${appId}/store/product/create`, body);
334
+ }
335
+ get(params) {
336
+ const { appId, id, ...body } = params;
337
+ return this.http.post(`/app/${appId}/store/product/${id}`, body);
338
+ }
339
+ update(params) {
340
+ const { appId, id, ...body } = params;
341
+ return this.http.post(`/app/${appId}/store/product/${id}/edit`, body);
342
+ }
343
+ delete(params) {
344
+ const { appId, id, ...body } = params;
345
+ return this.http.post(`/app/${appId}/store/product/${id}/delete`, body);
346
+ }
347
+ };
348
+ var StoreSellerModule = class {
349
+ constructor(http) {
350
+ this.http = http;
351
+ }
352
+ list(params) {
353
+ const { appId, ...body } = params;
354
+ return this.http.post(`/app/${appId}/store/seller/list`, body);
355
+ }
356
+ create(params) {
357
+ const { appId, ...body } = params;
358
+ return this.http.post(`/app/${appId}/store/seller/create`, body);
359
+ }
360
+ get(params) {
361
+ const { appId, id, ...body } = params;
362
+ return this.http.post(`/app/${appId}/store/seller/${id}`, body);
363
+ }
364
+ update(params) {
365
+ const { appId, id, ...body } = params;
366
+ return this.http.post(`/app/${appId}/store/seller/${id}/edit`, body);
367
+ }
368
+ delete(params) {
369
+ const { appId, id, ...body } = params;
370
+ return this.http.post(`/app/${appId}/store/seller/${id}/delete`, body);
371
+ }
372
+ };
373
+ var StoreShippingModule = class {
374
+ constructor(http) {
375
+ this.http = http;
376
+ }
377
+ list(params) {
378
+ const { appId, ...body } = params;
379
+ return this.http.post(`/app/${appId}/store/shipping/list`, body);
380
+ }
381
+ create(params) {
382
+ const { appId, ...body } = params;
383
+ return this.http.post(`/app/${appId}/store/shipping/create`, body);
384
+ }
385
+ delete(params) {
386
+ const { appId, id, ...body } = params;
387
+ return this.http.post(`/app/${appId}/store/shipping/${id}/delete`, body);
388
+ }
389
+ };
390
+ var StoreTagModule = class {
391
+ constructor(http) {
392
+ this.http = http;
393
+ }
394
+ list(params) {
395
+ const { appId, ...body } = params;
396
+ return this.http.post(`/app/${appId}/store/tag/list`, body);
397
+ }
398
+ create(params) {
399
+ const { appId, ...body } = params;
400
+ return this.http.post(`/app/${appId}/store/tag/create`, body);
401
+ }
402
+ get(params) {
403
+ const { appId, id, ...body } = params;
404
+ return this.http.post(`/app/${appId}/store/tag/${id}`, body);
405
+ }
406
+ update(params) {
407
+ const { appId, id, ...body } = params;
408
+ return this.http.post(`/app/${appId}/store/tag/${id}/edit`, body);
409
+ }
410
+ delete(params) {
411
+ const { appId, id, ...body } = params;
412
+ return this.http.post(`/app/${appId}/store/tag/${id}/delete`, body);
413
+ }
414
+ };
415
+ var StoreTaxModule = class {
416
+ constructor(http) {
417
+ this.http = http;
418
+ }
419
+ list(params) {
420
+ const { appId, ...body } = params;
421
+ return this.http.post(`/app/${appId}/store/tax/list`, body);
422
+ }
423
+ create(params) {
424
+ const { appId, ...body } = params;
425
+ return this.http.post(`/app/${appId}/store/tax/create`, body);
426
+ }
427
+ get(params) {
428
+ const { appId, id, ...body } = params;
429
+ return this.http.post(`/app/${appId}/store/tax/${id}`, body);
430
+ }
431
+ update(params) {
432
+ const { appId, id, ...body } = params;
433
+ return this.http.post(`/app/${appId}/store/tax/${id}/edit`, body);
434
+ }
435
+ delete(params) {
436
+ const { appId, id, ...body } = params;
437
+ return this.http.post(`/app/${appId}/store/tax/${id}/delete`, body);
438
+ }
439
+ };
440
+ var StoreModule = class {
441
+ constructor(http) {
442
+ this.http = http;
443
+ this.badge = new StoreBadgeModule(http);
444
+ this.category = new StoreCategoryModule(http);
445
+ this.collection = new StoreCollectionModule(http);
446
+ this.discount = new StoreDiscountModule(http);
447
+ this.option = new StoreOptionModule(http);
448
+ this.order = new StoreOrderModule(http);
449
+ this.product = new StoreProductModule(http);
450
+ this.seller = new StoreSellerModule(http);
451
+ this.shipping = new StoreShippingModule(http);
452
+ this.tag = new StoreTagModule(http);
453
+ this.tax = new StoreTaxModule(http);
454
+ }
455
+ };
456
+
457
+ // src/modules/app/welcome-item.ts
458
+ var AppWelcomeItemModule = class {
459
+ constructor(http) {
460
+ this.http = http;
461
+ }
462
+ list(params) {
463
+ const { appId, ...body } = params;
464
+ return this.http.post(`/app/${appId}/welcome-item/list`, body);
465
+ }
466
+ create(params) {
467
+ const { appId, ...body } = params;
468
+ return this.http.post(`/app/${appId}/welcome-item/create`, body);
469
+ }
470
+ get(params) {
471
+ const { appId, id, ...body } = params;
472
+ return this.http.post(`/app/${appId}/welcome-item/${id}`, body);
473
+ }
474
+ update(params) {
475
+ const { appId, id, ...body } = params;
476
+ return this.http.post(`/app/${appId}/welcome-item/${id}/edit`, body);
477
+ }
478
+ delete(params) {
479
+ const { appId, id, ...body } = params;
480
+ return this.http.post(`/app/${appId}/welcome-item/${id}/delete`, body);
481
+ }
482
+ };
483
+
484
+ // src/modules/app/multi-service/index.ts
485
+ var MultiServiceModule = class {
486
+ constructor(http) {
487
+ this.http = http;
488
+ }
489
+ listCompanies(params) {
490
+ const { appId, ...body } = params;
491
+ return this.http.post(`/app/${appId}/multi-service/companies/list`, body);
492
+ }
493
+ createCompany(params) {
494
+ const { appId, ...body } = params;
495
+ return this.http.post(`/app/${appId}/multi-service/companies/create`, body);
496
+ }
497
+ getCompany(params) {
498
+ const { appId, id, ...body } = params;
499
+ return this.http.post(`/app/${appId}/multi-service/companies/${id}`, body);
500
+ }
501
+ updateCompany(params) {
502
+ const { appId, id, ...body } = params;
503
+ return this.http.post(`/app/${appId}/multi-service/companies/${id}/edit`, body);
504
+ }
505
+ deleteCompany(params) {
506
+ const { appId, id, ...body } = params;
507
+ return this.http.post(`/app/${appId}/multi-service/companies/${id}/delete`, body);
508
+ }
509
+ listServices(params) {
510
+ const { appId, ...body } = params;
511
+ return this.http.post(`/app/${appId}/multi-service/services/list`, body);
512
+ }
513
+ createService(params) {
514
+ const { appId, ...body } = params;
515
+ return this.http.post(`/app/${appId}/multi-service/services/create`, body);
516
+ }
517
+ getService(params) {
518
+ const { appId, id, ...body } = params;
519
+ return this.http.post(`/app/${appId}/multi-service/services/${id}`, body);
520
+ }
521
+ updateService(params) {
522
+ const { appId, id, ...body } = params;
523
+ return this.http.post(`/app/${appId}/multi-service/services/${id}/edit`, body);
524
+ }
525
+ deleteService(params) {
526
+ const { appId, id, ...body } = params;
527
+ return this.http.post(`/app/${appId}/multi-service/services/${id}/delete`, body);
528
+ }
529
+ createAppointment(params) {
530
+ const { appId, ...body } = params;
531
+ return this.http.post(`/app/${appId}/multi-service/appointments/create`, body);
532
+ }
533
+ listAppointments(params) {
534
+ const { appId, ...body } = params;
535
+ return this.http.post(`/app/${appId}/multi-service/appointments/list`, body);
536
+ }
537
+ updateAppointmentStatus(params) {
538
+ const { appId, id, ...body } = params;
539
+ return this.http.post(
540
+ `/app/${appId}/multi-service/appointments/${id}/status`,
541
+ body
542
+ );
543
+ }
544
+ listAgents(params) {
545
+ const { appId, ...body } = params;
546
+ return this.http.post(`/app/${appId}/multi-service/agents/list`, body);
547
+ }
548
+ createAgent(params) {
549
+ const { appId, ...body } = params;
550
+ return this.http.post(`/app/${appId}/multi-service/agents/create`, body);
551
+ }
552
+ getAgent(params) {
553
+ const { appId, id, ...body } = params;
554
+ return this.http.post(`/app/${appId}/multi-service/agents/${id}`, body);
555
+ }
556
+ updateAgent(params) {
557
+ const { appId, id, ...body } = params;
558
+ return this.http.post(`/app/${appId}/multi-service/agents/${id}/edit`, body);
559
+ }
560
+ deleteAgent(params) {
561
+ const { appId, id, ...body } = params;
562
+ return this.http.post(`/app/${appId}/multi-service/agents/${id}/delete`, body);
563
+ }
564
+ };
565
+
566
+ // src/modules/app/index.ts
567
+ var AppModule = class {
568
+ constructor(http) {
569
+ this.http = http;
570
+ this.customer = new AppCustomerModule(http);
571
+ this.stats = new AppStatsModule(http);
572
+ this.finance = new AppFinanceModule(http);
573
+ this.welcomeItem = new AppWelcomeItemModule(http);
574
+ this.info = new AppInfoModule(http);
575
+ this.store = new StoreModule(http);
576
+ this.multiService = new MultiServiceModule(http);
577
+ }
578
+ };
579
+
580
+ // src/index.ts
581
+ var AppliteUI = class {
582
+ constructor(config = {}) {
583
+ this.http = new HttpClient({
584
+ baseUrl: config.baseUrl,
585
+ headers: config.headers,
586
+ fetchFn: config.fetchFn
587
+ });
588
+ this.app = new AppModule(this.http);
589
+ }
590
+ };
591
+ export {
592
+ AppCustomerModule,
593
+ AppFinanceModule,
594
+ AppInfoModule,
595
+ AppModule,
596
+ AppStatsModule,
597
+ AppWelcomeItemModule,
598
+ AppliteUI,
599
+ HttpClient,
600
+ MultiServiceModule,
601
+ StoreBadgeModule,
602
+ StoreCategoryModule,
603
+ StoreCollectionModule,
604
+ StoreDiscountModule,
605
+ StoreModule,
606
+ StoreOptionModule,
607
+ StoreOrderModule,
608
+ StoreProductModule,
609
+ StoreSellerModule,
610
+ StoreShippingModule,
611
+ StoreTagModule,
612
+ StoreTaxModule,
613
+ plateformTypes,
614
+ sexes
615
+ };
616
+ //# sourceMappingURL=index.mjs.map