@bshsolutions/sdk-beta 0.0.1-alpha

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 ADDED
@@ -0,0 +1,7 @@
1
+ # @bshsolutions/sdk
2
+
3
+ TypeScript SDK for integrating with BSH Engine - a backend tool that allows you to create APIs for your application with minimal work.
4
+
5
+ ## About BSH Engine
6
+
7
+ [BSH Engine](https://engine.bousalih.com) is a backend tool that allows you to create APIs for your application with minimal work. For more details, check out the [Documentation](https://docs.bousalih.com/docs/bsh-engine).
@@ -0,0 +1,697 @@
1
+ // src/services/entities/index.ts
2
+ var EntityService = class {
3
+ constructor(client, entity) {
4
+ this.client = client;
5
+ this.entity = entity;
6
+ this.baseEndpoint = "/api/entities";
7
+ }
8
+ // Get a single entity by ID
9
+ async findById(params) {
10
+ return this.client.get({
11
+ path: `${this.baseEndpoint}/${params.entity || this.entity}/${params.id}`,
12
+ options: {
13
+ responseType: "json",
14
+ requestFormat: "json",
15
+ headers: {
16
+ "Content-Type": "application/json"
17
+ }
18
+ },
19
+ bshOptions: { onSuccess: params.onSuccess, onError: params.onError },
20
+ api: `entities.${params.entity || this.entity}.findById`
21
+ });
22
+ }
23
+ // Create a new entity
24
+ async create(params) {
25
+ return this.client.post({
26
+ path: `${this.baseEndpoint}/${params.entity || this.entity}`,
27
+ options: {
28
+ responseType: "json",
29
+ requestFormat: "json",
30
+ body: params.payload,
31
+ headers: {
32
+ "Content-Type": "application/json"
33
+ }
34
+ },
35
+ bshOptions: { onSuccess: params.onSuccess, onError: params.onError },
36
+ api: `entities.${params.entity || this.entity}.create`
37
+ });
38
+ }
39
+ // Create multiple entities in batch
40
+ async createMany(params) {
41
+ return this.client.post({
42
+ path: `${this.baseEndpoint}/${params.entity || this.entity}/batch`,
43
+ options: {
44
+ responseType: "json",
45
+ requestFormat: "json",
46
+ body: params.payload,
47
+ headers: {
48
+ "Content-Type": "application/json"
49
+ }
50
+ },
51
+ bshOptions: { onSuccess: params.onSuccess, onError: params.onError },
52
+ api: `entities.${params.entity || this.entity}.createMany`
53
+ });
54
+ }
55
+ // Update an existing entity
56
+ async update(params) {
57
+ return this.client.put({
58
+ path: `${this.baseEndpoint}/${params.entity || this.entity}`,
59
+ options: {
60
+ responseType: "json",
61
+ requestFormat: "json",
62
+ body: params.payload,
63
+ headers: {
64
+ "Content-Type": "application/json"
65
+ }
66
+ },
67
+ bshOptions: { onSuccess: params.onSuccess, onError: params.onError },
68
+ api: `entities.${params.entity || this.entity}.update`
69
+ });
70
+ }
71
+ // Update multiple entities in batch
72
+ async updateMany(params) {
73
+ return this.client.put({
74
+ path: `${this.baseEndpoint}/${params.entity || this.entity}/batch`,
75
+ options: {
76
+ responseType: "json",
77
+ requestFormat: "json",
78
+ body: params.payload,
79
+ headers: {
80
+ "Content-Type": "application/json"
81
+ }
82
+ },
83
+ bshOptions: { onSuccess: params.onSuccess, onError: params.onError },
84
+ api: `entities.${params.entity || this.entity}.updateMany`
85
+ });
86
+ }
87
+ // Search for entities
88
+ async search(params) {
89
+ return this.client.post({
90
+ path: `${this.baseEndpoint}/${params.entity || this.entity}/search`,
91
+ options: {
92
+ responseType: "json",
93
+ requestFormat: "json",
94
+ body: params.payload,
95
+ headers: {
96
+ "Content-Type": "application/json"
97
+ }
98
+ },
99
+ bshOptions: { onSuccess: params.onSuccess, onError: params.onError },
100
+ api: `entities.${params.entity || this.entity}.delete`
101
+ });
102
+ }
103
+ // Delete entities by search criteria
104
+ async delete(params) {
105
+ return this.client.post({
106
+ path: `${this.baseEndpoint}/${params.entity || this.entity}/delete`,
107
+ options: {
108
+ responseType: "json",
109
+ requestFormat: "json",
110
+ body: params.payload,
111
+ headers: {
112
+ "Content-Type": "application/json"
113
+ }
114
+ },
115
+ bshOptions: { onSuccess: params.onSuccess, onError: params.onError },
116
+ api: `entities.${params.entity || this.entity}.delete`
117
+ });
118
+ }
119
+ // Delete a single entity by ID
120
+ async deleteById(params) {
121
+ return this.client.delete({
122
+ path: `${this.baseEndpoint}/${params.entity || this.entity}/${params.id}`,
123
+ options: {
124
+ responseType: "json",
125
+ requestFormat: "json",
126
+ headers: {
127
+ "Content-Type": "application/json"
128
+ }
129
+ },
130
+ bshOptions: { onSuccess: params.onSuccess, onError: params.onError },
131
+ api: `entities.${params.entity || this.entity}.deleteById`
132
+ });
133
+ }
134
+ // Get entity columns
135
+ async columns(params) {
136
+ return this.client.get({
137
+ path: `${this.baseEndpoint}/${params.entity || this.entity}/columns`,
138
+ options: {
139
+ responseType: "json",
140
+ requestFormat: "json",
141
+ headers: {
142
+ "Content-Type": "application/json"
143
+ }
144
+ },
145
+ bshOptions: { onSuccess: params.onSuccess, onError: params.onError },
146
+ api: `entities.${params.entity || this.entity}.columns`
147
+ });
148
+ }
149
+ // Export entities
150
+ async export(params) {
151
+ const defaultName = `${params.entity || this.entity}_export_${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}`;
152
+ const exportFilename = params.filename || `${defaultName}.${params.format == "excel" ? "xlsx" : params.format}`;
153
+ await this.client.download({
154
+ path: `${this.baseEndpoint}/${params.entity || this.entity}/export?format=${params.format}&filename=${exportFilename}`,
155
+ options: {
156
+ responseType: "blob",
157
+ requestFormat: "json",
158
+ body: params.payload,
159
+ headers: {
160
+ "Content-Type": "application/json"
161
+ }
162
+ },
163
+ bshOptions: { onDownload: params.onDownload, onError: params.onError },
164
+ api: `entities.${params.entity || this.entity}.export`
165
+ });
166
+ }
167
+ };
168
+
169
+ // src/services/auth/index.ts
170
+ var AuthService = class {
171
+ constructor(client) {
172
+ this.client = client;
173
+ this.baseEndpoint = "/api/auth";
174
+ }
175
+ async login(params) {
176
+ return this.client.post({
177
+ path: `${this.baseEndpoint}/login`,
178
+ options: {
179
+ responseType: "json",
180
+ requestFormat: "json",
181
+ body: params.payload,
182
+ headers: {
183
+ "Content-Type": "application/json"
184
+ }
185
+ },
186
+ bshOptions: { onSuccess: params.onSuccess, onError: params.onError },
187
+ api: "auth.login"
188
+ });
189
+ }
190
+ async register(params) {
191
+ return this.client.post({
192
+ path: `${this.baseEndpoint}/register`,
193
+ options: {
194
+ responseType: "json",
195
+ requestFormat: "json",
196
+ body: params.payload,
197
+ headers: {
198
+ "Content-Type": "application/json"
199
+ }
200
+ },
201
+ bshOptions: { onSuccess: params.onSuccess, onError: params.onError },
202
+ api: "auth.register"
203
+ });
204
+ }
205
+ async refreshToken(params) {
206
+ return this.client.post({
207
+ path: `${this.baseEndpoint}/refresh`,
208
+ options: {
209
+ responseType: "json",
210
+ requestFormat: "json",
211
+ body: params.payload,
212
+ headers: {
213
+ "Content-Type": "application/json"
214
+ }
215
+ },
216
+ bshOptions: { onSuccess: params.onSuccess, onError: params.onError },
217
+ api: "auth.refreshToken"
218
+ });
219
+ }
220
+ async forgetPassword(params) {
221
+ return this.client.post({
222
+ path: `${this.baseEndpoint}/forget-password`,
223
+ options: {
224
+ responseType: "json",
225
+ requestFormat: "json",
226
+ body: params.payload,
227
+ headers: {
228
+ "Content-Type": "application/json"
229
+ }
230
+ },
231
+ bshOptions: { onSuccess: params.onSuccess, onError: params.onError },
232
+ api: "auth.forgetPassword"
233
+ });
234
+ }
235
+ async resetPassword(params) {
236
+ return this.client.post({
237
+ path: `${this.baseEndpoint}/reset-password`,
238
+ options: {
239
+ responseType: "json",
240
+ requestFormat: "json",
241
+ body: params.payload,
242
+ headers: {
243
+ "Content-Type": "application/json"
244
+ }
245
+ },
246
+ bshOptions: { onSuccess: params.onSuccess, onError: params.onError },
247
+ api: "auth.resetPassword"
248
+ });
249
+ }
250
+ async activateAccount(params) {
251
+ return this.client.post({
252
+ path: `${this.baseEndpoint}/activate-account`,
253
+ options: {
254
+ responseType: "json",
255
+ requestFormat: "json",
256
+ body: params.payload,
257
+ headers: {
258
+ "Content-Type": "application/json"
259
+ }
260
+ },
261
+ bshOptions: { onSuccess: params.onSuccess, onError: params.onError },
262
+ api: "auth.activateAccount"
263
+ });
264
+ }
265
+ };
266
+
267
+ // src/services/user/index.ts
268
+ var UserService = class {
269
+ constructor(client) {
270
+ this.client = client;
271
+ this.baseEndpoint = "/api/users";
272
+ }
273
+ async me(params) {
274
+ return this.client.get({
275
+ path: `${this.baseEndpoint}/me`,
276
+ options: {
277
+ responseType: "json",
278
+ requestFormat: "json"
279
+ },
280
+ bshOptions: { onSuccess: params.onSuccess, onError: params.onError },
281
+ api: "user.me"
282
+ });
283
+ }
284
+ async init(params) {
285
+ return this.client.post({
286
+ path: `${this.baseEndpoint}/init`,
287
+ options: {
288
+ responseType: "json",
289
+ requestFormat: "json",
290
+ body: params.payload,
291
+ headers: {
292
+ "Content-Type": "application/json"
293
+ }
294
+ },
295
+ bshOptions: { onSuccess: params.onSuccess, onError: params.onError },
296
+ api: "user.init"
297
+ });
298
+ }
299
+ async updateProfile(params) {
300
+ return this.client.put({
301
+ path: `${this.baseEndpoint}/profile`,
302
+ options: {
303
+ responseType: "json",
304
+ requestFormat: "json",
305
+ body: params.payload,
306
+ headers: {
307
+ "Content-Type": "application/json"
308
+ }
309
+ },
310
+ bshOptions: { onSuccess: params.onSuccess, onError: params.onError },
311
+ api: "user.updateProfile"
312
+ });
313
+ }
314
+ async updatePicture(params) {
315
+ const formData = new FormData();
316
+ formData.set("picture", params.payload);
317
+ return this.client.post({
318
+ path: `${this.baseEndpoint}/picture`,
319
+ options: {
320
+ responseType: "json",
321
+ requestFormat: "json",
322
+ body: formData
323
+ },
324
+ bshOptions: { onSuccess: params.onSuccess, onError: params.onError },
325
+ api: "user.updatePicture"
326
+ });
327
+ }
328
+ async updatePassword(params) {
329
+ return this.client.put({
330
+ path: `${this.baseEndpoint}/password`,
331
+ options: {
332
+ responseType: "json",
333
+ requestFormat: "json",
334
+ body: params.payload,
335
+ headers: {
336
+ "Content-Type": "application/json"
337
+ }
338
+ },
339
+ bshOptions: { onSuccess: params.onSuccess, onError: params.onError },
340
+ api: "user.updatePassword"
341
+ });
342
+ }
343
+ // CRUD
344
+ async getById(params) {
345
+ return this.client.get({
346
+ path: `${this.baseEndpoint}/${params.id}`,
347
+ options: {
348
+ responseType: "json",
349
+ requestFormat: "json"
350
+ },
351
+ bshOptions: { onSuccess: params.onSuccess, onError: params.onError },
352
+ api: "user.getById"
353
+ });
354
+ }
355
+ async search(params) {
356
+ return this.client.post({
357
+ path: `${this.baseEndpoint}/search`,
358
+ options: {
359
+ responseType: "json",
360
+ requestFormat: "json",
361
+ body: params.payload,
362
+ headers: {
363
+ "Content-Type": "application/json"
364
+ }
365
+ },
366
+ bshOptions: { onSuccess: params.onSuccess, onError: params.onError },
367
+ api: "user.search"
368
+ });
369
+ }
370
+ async list(params) {
371
+ const urlSearchParams = new URLSearchParams();
372
+ if (params.queryParams?.page) urlSearchParams.append("page", params.queryParams.page);
373
+ if (params.queryParams?.size) urlSearchParams.append("size", params.queryParams.size);
374
+ if (params.queryParams?.sort) urlSearchParams.append("sort", params.queryParams.sort);
375
+ if (params.queryParams?.filter) urlSearchParams.append("filter", params.queryParams.filter);
376
+ const queryString = urlSearchParams.toString();
377
+ const endpoint = queryString ? `?${queryString}` : "";
378
+ return this.client.get({
379
+ path: `${this.baseEndpoint}${endpoint}`,
380
+ options: {
381
+ responseType: "json",
382
+ requestFormat: "json"
383
+ },
384
+ bshOptions: { onSuccess: params.onSuccess, onError: params.onError },
385
+ api: "user.list"
386
+ });
387
+ }
388
+ async update(params) {
389
+ return this.client.put({
390
+ path: `${this.baseEndpoint}`,
391
+ options: {
392
+ responseType: "json",
393
+ requestFormat: "json",
394
+ body: params.payload,
395
+ headers: {
396
+ "Content-Type": "application/json"
397
+ }
398
+ },
399
+ bshOptions: { onSuccess: params.onSuccess, onError: params.onError },
400
+ api: "user.update"
401
+ });
402
+ }
403
+ async deleteById(params) {
404
+ return this.client.delete({
405
+ path: `${this.baseEndpoint}/${params.id}`,
406
+ options: {
407
+ responseType: "json",
408
+ requestFormat: "json"
409
+ },
410
+ bshOptions: { onSuccess: params.onSuccess, onError: params.onError },
411
+ api: "user.deleteById"
412
+ });
413
+ }
414
+ };
415
+
416
+ // src/services/settings/index.ts
417
+ var SettingsService = class {
418
+ constructor(client) {
419
+ this.client = client;
420
+ this.baseEndpoint = "/api/settings";
421
+ }
422
+ async load(params) {
423
+ return this.client.get({
424
+ path: `${this.baseEndpoint}`,
425
+ options: {
426
+ responseType: "json",
427
+ requestFormat: "json"
428
+ },
429
+ bshOptions: { onSuccess: params.onSuccess, onError: params.onError },
430
+ api: "settings.load"
431
+ });
432
+ }
433
+ async update(params) {
434
+ return this.client.put({
435
+ path: `${this.baseEndpoint}`,
436
+ options: {
437
+ responseType: "json",
438
+ requestFormat: "json",
439
+ body: { ...params.payload, name: "BshEngine" },
440
+ headers: {
441
+ "Content-Type": "application/json"
442
+ }
443
+ },
444
+ bshOptions: { onSuccess: params.onSuccess, onError: params.onError },
445
+ api: "settings.update"
446
+ });
447
+ }
448
+ };
449
+
450
+ // src/services/image/index.ts
451
+ var ImageService = class {
452
+ constructor(client) {
453
+ this.client = client;
454
+ this.baseEndpoint = "/api/images";
455
+ }
456
+ async upload(params) {
457
+ const formData = new FormData();
458
+ formData.set("file", params.payload.file);
459
+ if (params.payload.namespace) formData.set("namespace", params.payload.namespace);
460
+ if (params.payload.assetId) formData.set("assetId", params.payload.assetId);
461
+ if (params.payload.options) formData.set("options", JSON.stringify(params.payload.options));
462
+ return this.client.post({
463
+ path: `${this.baseEndpoint}/upload`,
464
+ options: {
465
+ responseType: "json",
466
+ requestFormat: "form",
467
+ body: formData
468
+ },
469
+ bshOptions: { onSuccess: params.onSuccess, onError: params.onError },
470
+ api: "image.upload"
471
+ });
472
+ }
473
+ };
474
+
475
+ // src/services/mailing/index.ts
476
+ var MailingService = class {
477
+ constructor(client) {
478
+ this.client = client;
479
+ this.baseEndpoint = "/api/mailing";
480
+ }
481
+ async send(params) {
482
+ return this.client.post({
483
+ path: `${this.baseEndpoint}/send`,
484
+ options: {
485
+ responseType: "json",
486
+ requestFormat: "json",
487
+ body: params.payload,
488
+ headers: {
489
+ "Content-Type": "application/json"
490
+ }
491
+ },
492
+ bshOptions: { onSuccess: params.onSuccess, onError: params.onError },
493
+ api: "mailing.send"
494
+ });
495
+ }
496
+ };
497
+
498
+ // src/services/utils/index.ts
499
+ var BshUtilsService = class {
500
+ constructor(client) {
501
+ this.client = client;
502
+ this.baseEndpoint = "/api/utils";
503
+ }
504
+ async triggerPlugins(params) {
505
+ return this.client.get({
506
+ path: `${this.baseEndpoint}/triggers/plugins`,
507
+ options: {
508
+ responseType: "json",
509
+ requestFormat: "json"
510
+ },
511
+ bshOptions: { onSuccess: params.onSuccess, onError: params.onError },
512
+ api: "utils.triggerPlugins"
513
+ });
514
+ }
515
+ async triggerActions(params) {
516
+ return this.client.get({
517
+ path: `${this.baseEndpoint}/triggers/actions`,
518
+ options: {
519
+ responseType: "json",
520
+ requestFormat: "json"
521
+ },
522
+ bshOptions: { onSuccess: params.onSuccess, onError: params.onError },
523
+ api: "utils.triggerActions"
524
+ });
525
+ }
526
+ };
527
+
528
+ // src/services/caching/index.ts
529
+ var CachingService = class {
530
+ constructor(client) {
531
+ this.client = client;
532
+ this.baseEndpoint = "/api/caching";
533
+ }
534
+ async findById(params) {
535
+ return this.client.get({
536
+ path: `${this.baseEndpoint}/${params.id}`,
537
+ options: {
538
+ responseType: "json",
539
+ requestFormat: "json"
540
+ },
541
+ bshOptions: { onSuccess: params.onSuccess, onError: params.onError },
542
+ api: "caching.findById"
543
+ });
544
+ }
545
+ async search(params) {
546
+ return this.client.post({
547
+ path: `${this.baseEndpoint}/search`,
548
+ options: {
549
+ responseType: "json",
550
+ requestFormat: "json",
551
+ body: params.payload,
552
+ headers: {
553
+ "Content-Type": "application/json"
554
+ }
555
+ },
556
+ bshOptions: { onSuccess: params.onSuccess, onError: params.onError },
557
+ api: "caching.search"
558
+ });
559
+ }
560
+ async names(params) {
561
+ return this.client.get({
562
+ path: `${this.baseEndpoint}/names`,
563
+ options: {
564
+ responseType: "json",
565
+ requestFormat: "json"
566
+ },
567
+ bshOptions: { onSuccess: params.onSuccess, onError: params.onError },
568
+ api: "caching.names"
569
+ });
570
+ }
571
+ async clearById(params) {
572
+ return this.client.delete({
573
+ path: `${this.baseEndpoint}/${params.id}`,
574
+ options: {
575
+ responseType: "json",
576
+ requestFormat: "json"
577
+ },
578
+ bshOptions: { onSuccess: params.onSuccess, onError: params.onError },
579
+ api: "caching.clearById"
580
+ });
581
+ }
582
+ async clearAll(params) {
583
+ return this.client.delete({
584
+ path: `${this.baseEndpoint}/all`,
585
+ options: {
586
+ responseType: "json",
587
+ requestFormat: "json"
588
+ },
589
+ bshOptions: { onSuccess: params.onSuccess, onError: params.onError },
590
+ api: "caching.clearAll"
591
+ });
592
+ }
593
+ };
594
+
595
+ // src/services/api-key/index.ts
596
+ var ApiKeyService = class {
597
+ constructor(client) {
598
+ this.client = client;
599
+ this.baseEndpoint = "/api/api-keys";
600
+ }
601
+ async create(params) {
602
+ return this.client.post({
603
+ path: `${this.baseEndpoint}`,
604
+ options: {
605
+ responseType: "json",
606
+ requestFormat: "json",
607
+ body: params.payload,
608
+ headers: {
609
+ "Content-Type": "application/json"
610
+ }
611
+ },
612
+ bshOptions: { onSuccess: params.onSuccess, onError: params.onError },
613
+ api: "api-key.create"
614
+ });
615
+ }
616
+ async details(params) {
617
+ return this.client.get({
618
+ path: `${this.baseEndpoint}/${params.id}`,
619
+ options: {
620
+ responseType: "json",
621
+ requestFormat: "json"
622
+ },
623
+ bshOptions: { onSuccess: params.onSuccess, onError: params.onError }
624
+ });
625
+ }
626
+ async revoke(params) {
627
+ return this.client.delete({
628
+ path: `${this.baseEndpoint}/${params.id}/revoke`,
629
+ options: {
630
+ responseType: "json",
631
+ requestFormat: "json"
632
+ },
633
+ bshOptions: { onSuccess: params.onSuccess, onError: params.onError },
634
+ api: "api-key.revoke"
635
+ });
636
+ }
637
+ // CRUD
638
+ async getById(params) {
639
+ return this.client.get({
640
+ path: `${this.baseEndpoint}/${params.id}`,
641
+ options: {
642
+ responseType: "json",
643
+ requestFormat: "json"
644
+ },
645
+ bshOptions: { onSuccess: params.onSuccess, onError: params.onError },
646
+ api: "api-key.getById"
647
+ });
648
+ }
649
+ async search(params) {
650
+ return this.client.post({
651
+ path: `${this.baseEndpoint}/search`,
652
+ options: {
653
+ responseType: "json",
654
+ requestFormat: "json",
655
+ body: params.payload,
656
+ headers: {
657
+ "Content-Type": "application/json"
658
+ }
659
+ },
660
+ bshOptions: { onSuccess: params.onSuccess, onError: params.onError },
661
+ api: "api-key.search"
662
+ });
663
+ }
664
+ async list(params) {
665
+ const urlSearchParams = new URLSearchParams();
666
+ if (params.queryParams?.page) urlSearchParams.append("page", params.queryParams.page);
667
+ if (params.queryParams?.size) urlSearchParams.append("size", params.queryParams.size);
668
+ if (params.queryParams?.sort) urlSearchParams.append("sort", params.queryParams.sort);
669
+ if (params.queryParams?.filter) urlSearchParams.append("filter", params.queryParams.filter);
670
+ const queryString = urlSearchParams.toString();
671
+ const endpoint = queryString ? `?${queryString}` : "";
672
+ return this.client.get({
673
+ path: `${this.baseEndpoint}${endpoint}`,
674
+ options: {
675
+ responseType: "json",
676
+ requestFormat: "json"
677
+ },
678
+ bshOptions: { onSuccess: params.onSuccess, onError: params.onError },
679
+ api: "api-key.list"
680
+ });
681
+ }
682
+ async deleteById(params) {
683
+ return this.client.delete({
684
+ path: `${this.baseEndpoint}/${params.id}`,
685
+ options: {
686
+ responseType: "json",
687
+ requestFormat: "json"
688
+ },
689
+ bshOptions: { onSuccess: params.onSuccess, onError: params.onError },
690
+ api: "api-key.deleteById"
691
+ });
692
+ }
693
+ };
694
+
695
+ export { ApiKeyService, AuthService, BshUtilsService, CachingService, EntityService, ImageService, MailingService, SettingsService, UserService };
696
+ //# sourceMappingURL=chunk-HHI43U6W.js.map
697
+ //# sourceMappingURL=chunk-HHI43U6W.js.map