@abpjs/saas 3.0.0 → 3.2.0

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.js CHANGED
@@ -35,6 +35,7 @@ __export(index_exports, {
35
35
  DEFAULT_TENANTS_ENTITY_ACTIONS: () => DEFAULT_TENANTS_ENTITY_ACTIONS,
36
36
  DEFAULT_TENANTS_ENTITY_PROPS: () => DEFAULT_TENANTS_ENTITY_PROPS,
37
37
  DEFAULT_TENANTS_TOOLBAR_ACTIONS: () => DEFAULT_TENANTS_TOOLBAR_ACTIONS,
38
+ EditionService: () => EditionService,
38
39
  EditionsComponent: () => EditionsComponent,
39
40
  SAAS_CREATE_FORM_PROP_CONTRIBUTORS: () => SAAS_CREATE_FORM_PROP_CONTRIBUTORS,
40
41
  SAAS_EDIT_FORM_PROP_CONTRIBUTORS: () => SAAS_EDIT_FORM_PROP_CONTRIBUTORS,
@@ -47,6 +48,7 @@ __export(index_exports, {
47
48
  SaasExtensionsGuard: () => SaasExtensionsGuard,
48
49
  SaasService: () => SaasService,
49
50
  SaasStateService: () => SaasStateService,
51
+ TenantService: () => TenantService,
50
52
  TenantsComponent: () => TenantsComponent,
51
53
  configureRoutes: () => configureRoutes,
52
54
  eSaasComponents: () => eSaasComponents,
@@ -118,6 +120,194 @@ var SAAS_ROUTE_PROVIDERS = {
118
120
  deps: ["RoutesService"]
119
121
  };
120
122
 
123
+ // src/proxy/host/edition.service.ts
124
+ var EditionService = class {
125
+ constructor(restService) {
126
+ this.restService = restService;
127
+ /**
128
+ * API name for multi-API configurations
129
+ * @since 3.2.0
130
+ */
131
+ this.apiName = "default";
132
+ }
133
+ /**
134
+ * Create a new edition
135
+ * @param input Edition creation DTO
136
+ * @returns Promise with created edition
137
+ */
138
+ async create(input) {
139
+ return this.restService.request({
140
+ method: "POST",
141
+ url: "/api/saas/editions",
142
+ body: input
143
+ });
144
+ }
145
+ /**
146
+ * Delete an edition by ID
147
+ * @param id Edition ID
148
+ * @returns Promise that resolves when deletion is complete
149
+ */
150
+ async delete(id) {
151
+ return this.restService.request({
152
+ method: "DELETE",
153
+ url: `/api/saas/editions/${id}`
154
+ });
155
+ }
156
+ /**
157
+ * Get an edition by ID
158
+ * @param id Edition ID
159
+ * @returns Promise with edition data
160
+ */
161
+ async get(id) {
162
+ return this.restService.request({
163
+ method: "GET",
164
+ url: `/api/saas/editions/${id}`
165
+ });
166
+ }
167
+ /**
168
+ * Get paginated list of editions
169
+ * @param input Query parameters for filtering and pagination
170
+ * @returns Promise with paginated editions response
171
+ */
172
+ async getList(input = {}) {
173
+ return this.restService.request({
174
+ method: "GET",
175
+ url: "/api/saas/editions",
176
+ params: input
177
+ });
178
+ }
179
+ /**
180
+ * Get usage statistics for editions
181
+ * @returns Promise with usage statistics data
182
+ */
183
+ async getUsageStatistics() {
184
+ return this.restService.request({
185
+ method: "GET",
186
+ url: "/api/saas/editions/statistics/usage-statistic"
187
+ });
188
+ }
189
+ /**
190
+ * Update an existing edition
191
+ * @param id Edition ID
192
+ * @param input Edition update DTO
193
+ * @returns Promise with updated edition
194
+ */
195
+ async update(id, input) {
196
+ return this.restService.request({
197
+ method: "PUT",
198
+ url: `/api/saas/editions/${id}`,
199
+ body: input
200
+ });
201
+ }
202
+ };
203
+
204
+ // src/proxy/host/tenant.service.ts
205
+ var TenantService = class {
206
+ constructor(restService) {
207
+ this.restService = restService;
208
+ /**
209
+ * API name for multi-API configurations
210
+ * @since 3.2.0
211
+ */
212
+ this.apiName = "default";
213
+ }
214
+ /**
215
+ * Create a new tenant
216
+ * @param input Tenant creation DTO
217
+ * @returns Promise with created tenant
218
+ */
219
+ async create(input) {
220
+ return this.restService.request({
221
+ method: "POST",
222
+ url: "/api/saas/tenants",
223
+ body: input
224
+ });
225
+ }
226
+ /**
227
+ * Delete a tenant by ID
228
+ * @param id Tenant ID
229
+ * @returns Promise that resolves when deletion is complete
230
+ */
231
+ async delete(id) {
232
+ return this.restService.request({
233
+ method: "DELETE",
234
+ url: `/api/saas/tenants/${id}`
235
+ });
236
+ }
237
+ /**
238
+ * Delete the default connection string for a tenant
239
+ * @param id Tenant ID
240
+ * @returns Promise that resolves when deletion is complete
241
+ */
242
+ async deleteDefaultConnectionString(id) {
243
+ return this.restService.request({
244
+ method: "DELETE",
245
+ url: `/api/saas/tenants/${id}/default-connection-string`
246
+ });
247
+ }
248
+ /**
249
+ * Get a tenant by ID
250
+ * @param id Tenant ID
251
+ * @returns Promise with tenant data
252
+ */
253
+ async get(id) {
254
+ return this.restService.request({
255
+ method: "GET",
256
+ url: `/api/saas/tenants/${id}`
257
+ });
258
+ }
259
+ /**
260
+ * Get the default connection string for a tenant
261
+ * @param id Tenant ID
262
+ * @returns Promise with connection string
263
+ */
264
+ async getDefaultConnectionString(id) {
265
+ return this.restService.request({
266
+ method: "GET",
267
+ url: `/api/saas/tenants/${id}/default-connection-string`,
268
+ responseType: "text"
269
+ });
270
+ }
271
+ /**
272
+ * Get paginated list of tenants
273
+ * @param input Query parameters for filtering and pagination
274
+ * @returns Promise with paginated tenants response
275
+ */
276
+ async getList(input = {}) {
277
+ return this.restService.request({
278
+ method: "GET",
279
+ url: "/api/saas/tenants",
280
+ params: input
281
+ });
282
+ }
283
+ /**
284
+ * Update an existing tenant
285
+ * @param id Tenant ID
286
+ * @param input Tenant update DTO
287
+ * @returns Promise with updated tenant
288
+ */
289
+ async update(id, input) {
290
+ return this.restService.request({
291
+ method: "PUT",
292
+ url: `/api/saas/tenants/${id}`,
293
+ body: input
294
+ });
295
+ }
296
+ /**
297
+ * Update the default connection string for a tenant
298
+ * @param id Tenant ID
299
+ * @param defaultConnectionString The connection string
300
+ * @returns Promise that resolves when update is complete
301
+ */
302
+ async updateDefaultConnectionString(id, defaultConnectionString) {
303
+ return this.restService.request({
304
+ method: "PUT",
305
+ url: `/api/saas/tenants/${id}/default-connection-string`,
306
+ params: { defaultConnectionString }
307
+ });
308
+ }
309
+ };
310
+
121
311
  // src/constants/routes.ts
122
312
  var SAAS_ROUTES = {
123
313
  routes: [
@@ -390,13 +580,15 @@ var SaasStateService = class {
390
580
  usageStatistics: {},
391
581
  latestTenants: []
392
582
  };
393
- this.service = new SaasService(rest);
583
+ this.tenantService = new TenantService(rest);
584
+ this.editionService = new EditionService(rest);
394
585
  }
395
586
  // ========================
396
587
  // Getter Methods
397
588
  // ========================
398
589
  /**
399
590
  * Get the current list of tenants from state
591
+ * @returns Array of tenants
400
592
  */
401
593
  getTenants() {
402
594
  return this.state.tenants?.items ?? [];
@@ -404,30 +596,35 @@ var SaasStateService = class {
404
596
  /**
405
597
  * Get the latest tenants from state (for dashboard widget)
406
598
  * @since 2.0.0
599
+ * @returns Array of latest tenants
407
600
  */
408
601
  getLatestTenants() {
409
602
  return this.state.latestTenants ?? [];
410
603
  }
411
604
  /**
412
605
  * Get the total count of tenants from state
606
+ * @returns Total count
413
607
  */
414
608
  getTenantsTotalCount() {
415
609
  return this.state.tenants?.totalCount ?? 0;
416
610
  }
417
611
  /**
418
612
  * Get the current list of editions from state
613
+ * @returns Array of editions
419
614
  */
420
615
  getEditions() {
421
616
  return this.state.editions?.items ?? [];
422
617
  }
423
618
  /**
424
619
  * Get the total count of editions from state
620
+ * @returns Total count
425
621
  */
426
622
  getEditionsTotalCount() {
427
623
  return this.state.editions?.totalCount ?? 0;
428
624
  }
429
625
  /**
430
626
  * Get the usage statistics from state
627
+ * @returns Usage statistics data
431
628
  */
432
629
  getUsageStatistics() {
433
630
  return this.state.usageStatistics ?? {};
@@ -441,7 +638,7 @@ var SaasStateService = class {
441
638
  * @returns Promise with the tenants response
442
639
  */
443
640
  async dispatchGetTenants(params = {}) {
444
- const response = await this.service.getTenants(params);
641
+ const response = await this.tenantService.getList(params);
445
642
  this.state = {
446
643
  ...this.state,
447
644
  tenants: response
@@ -454,7 +651,7 @@ var SaasStateService = class {
454
651
  * @returns Promise with the tenant
455
652
  */
456
653
  async dispatchGetTenantById(id) {
457
- const tenant = await this.service.getTenantById(id);
654
+ const tenant = await this.tenantService.get(id);
458
655
  return tenant;
459
656
  }
460
657
  /**
@@ -463,17 +660,18 @@ var SaasStateService = class {
463
660
  * @returns Promise with the created tenant
464
661
  */
465
662
  async dispatchCreateTenant(body) {
466
- const result = await this.service.createTenant(body);
663
+ const result = await this.tenantService.create(body);
467
664
  await this.dispatchGetTenants();
468
665
  return result;
469
666
  }
470
667
  /**
471
668
  * Dispatch action to update a tenant
472
- * @param body - The tenant update request
669
+ * @param payload - Object containing id and update data
473
670
  * @returns Promise with the updated tenant
474
671
  */
475
- async dispatchUpdateTenant(body) {
476
- const result = await this.service.updateTenant(body);
672
+ async dispatchUpdateTenant(payload) {
673
+ const { id, ...input } = payload;
674
+ const result = await this.tenantService.update(id, input);
477
675
  await this.dispatchGetTenants();
478
676
  return result;
479
677
  }
@@ -483,7 +681,7 @@ var SaasStateService = class {
483
681
  * @returns Promise resolving when complete
484
682
  */
485
683
  async dispatchDeleteTenant(id) {
486
- await this.service.deleteTenant(id);
684
+ await this.tenantService.delete(id);
487
685
  await this.dispatchGetTenants();
488
686
  }
489
687
  /**
@@ -492,12 +690,12 @@ var SaasStateService = class {
492
690
  * @since 2.0.0
493
691
  */
494
692
  async dispatchGetLatestTenants() {
495
- const latestTenants = await this.service.getLatestTenants();
693
+ const response = await this.tenantService.getList({ maxResultCount: 5, sorting: "creationTime desc" });
496
694
  this.state = {
497
695
  ...this.state,
498
- latestTenants
696
+ latestTenants: response.items ?? []
499
697
  };
500
- return latestTenants;
698
+ return response;
501
699
  }
502
700
  // ========================
503
701
  // Edition Dispatch Methods
@@ -508,7 +706,7 @@ var SaasStateService = class {
508
706
  * @returns Promise with the editions response
509
707
  */
510
708
  async dispatchGetEditions(params = {}) {
511
- const response = await this.service.getEditions(params);
709
+ const response = await this.editionService.getList(params);
512
710
  this.state = {
513
711
  ...this.state,
514
712
  editions: response
@@ -521,7 +719,7 @@ var SaasStateService = class {
521
719
  * @returns Promise with the edition
522
720
  */
523
721
  async dispatchGetEditionById(id) {
524
- const edition = await this.service.getEditionById(id);
722
+ const edition = await this.editionService.get(id);
525
723
  return edition;
526
724
  }
527
725
  /**
@@ -530,17 +728,18 @@ var SaasStateService = class {
530
728
  * @returns Promise with the created edition
531
729
  */
532
730
  async dispatchCreateEdition(body) {
533
- const result = await this.service.createEdition(body);
731
+ const result = await this.editionService.create(body);
534
732
  await this.dispatchGetEditions();
535
733
  return result;
536
734
  }
537
735
  /**
538
736
  * Dispatch action to update an edition
539
- * @param body - The edition update request
737
+ * @param payload - Object containing id and update data
540
738
  * @returns Promise with the updated edition
541
739
  */
542
- async dispatchUpdateEdition(body) {
543
- const result = await this.service.updateEdition(body);
740
+ async dispatchUpdateEdition(payload) {
741
+ const { id, ...input } = payload;
742
+ const result = await this.editionService.update(id, input);
544
743
  await this.dispatchGetEditions();
545
744
  return result;
546
745
  }
@@ -550,7 +749,7 @@ var SaasStateService = class {
550
749
  * @returns Promise resolving when complete
551
750
  */
552
751
  async dispatchDeleteEdition(id) {
553
- await this.service.deleteEdition(id);
752
+ await this.editionService.delete(id);
554
753
  await this.dispatchGetEditions();
555
754
  }
556
755
  // ========================
@@ -561,7 +760,7 @@ var SaasStateService = class {
561
760
  * @returns Promise with the usage statistics response
562
761
  */
563
762
  async dispatchGetUsageStatistics() {
564
- const response = await this.service.getUsageStatistics();
763
+ const response = await this.editionService.getUsageStatistics();
565
764
  this.state = {
566
765
  ...this.state,
567
766
  usageStatistics: response.data
@@ -1778,6 +1977,7 @@ function EditionsComponent({
1778
1977
  DEFAULT_TENANTS_ENTITY_ACTIONS,
1779
1978
  DEFAULT_TENANTS_ENTITY_PROPS,
1780
1979
  DEFAULT_TENANTS_TOOLBAR_ACTIONS,
1980
+ EditionService,
1781
1981
  EditionsComponent,
1782
1982
  SAAS_CREATE_FORM_PROP_CONTRIBUTORS,
1783
1983
  SAAS_EDIT_FORM_PROP_CONTRIBUTORS,
@@ -1790,6 +1990,7 @@ function EditionsComponent({
1790
1990
  SaasExtensionsGuard,
1791
1991
  SaasService,
1792
1992
  SaasStateService,
1993
+ TenantService,
1793
1994
  TenantsComponent,
1794
1995
  configureRoutes,
1795
1996
  eSaasComponents,