@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.mjs CHANGED
@@ -56,6 +56,194 @@ var SAAS_ROUTE_PROVIDERS = {
56
56
  deps: ["RoutesService"]
57
57
  };
58
58
 
59
+ // src/proxy/host/edition.service.ts
60
+ var EditionService = class {
61
+ constructor(restService) {
62
+ this.restService = restService;
63
+ /**
64
+ * API name for multi-API configurations
65
+ * @since 3.2.0
66
+ */
67
+ this.apiName = "default";
68
+ }
69
+ /**
70
+ * Create a new edition
71
+ * @param input Edition creation DTO
72
+ * @returns Promise with created edition
73
+ */
74
+ async create(input) {
75
+ return this.restService.request({
76
+ method: "POST",
77
+ url: "/api/saas/editions",
78
+ body: input
79
+ });
80
+ }
81
+ /**
82
+ * Delete an edition by ID
83
+ * @param id Edition ID
84
+ * @returns Promise that resolves when deletion is complete
85
+ */
86
+ async delete(id) {
87
+ return this.restService.request({
88
+ method: "DELETE",
89
+ url: `/api/saas/editions/${id}`
90
+ });
91
+ }
92
+ /**
93
+ * Get an edition by ID
94
+ * @param id Edition ID
95
+ * @returns Promise with edition data
96
+ */
97
+ async get(id) {
98
+ return this.restService.request({
99
+ method: "GET",
100
+ url: `/api/saas/editions/${id}`
101
+ });
102
+ }
103
+ /**
104
+ * Get paginated list of editions
105
+ * @param input Query parameters for filtering and pagination
106
+ * @returns Promise with paginated editions response
107
+ */
108
+ async getList(input = {}) {
109
+ return this.restService.request({
110
+ method: "GET",
111
+ url: "/api/saas/editions",
112
+ params: input
113
+ });
114
+ }
115
+ /**
116
+ * Get usage statistics for editions
117
+ * @returns Promise with usage statistics data
118
+ */
119
+ async getUsageStatistics() {
120
+ return this.restService.request({
121
+ method: "GET",
122
+ url: "/api/saas/editions/statistics/usage-statistic"
123
+ });
124
+ }
125
+ /**
126
+ * Update an existing edition
127
+ * @param id Edition ID
128
+ * @param input Edition update DTO
129
+ * @returns Promise with updated edition
130
+ */
131
+ async update(id, input) {
132
+ return this.restService.request({
133
+ method: "PUT",
134
+ url: `/api/saas/editions/${id}`,
135
+ body: input
136
+ });
137
+ }
138
+ };
139
+
140
+ // src/proxy/host/tenant.service.ts
141
+ var TenantService = class {
142
+ constructor(restService) {
143
+ this.restService = restService;
144
+ /**
145
+ * API name for multi-API configurations
146
+ * @since 3.2.0
147
+ */
148
+ this.apiName = "default";
149
+ }
150
+ /**
151
+ * Create a new tenant
152
+ * @param input Tenant creation DTO
153
+ * @returns Promise with created tenant
154
+ */
155
+ async create(input) {
156
+ return this.restService.request({
157
+ method: "POST",
158
+ url: "/api/saas/tenants",
159
+ body: input
160
+ });
161
+ }
162
+ /**
163
+ * Delete a tenant by ID
164
+ * @param id Tenant ID
165
+ * @returns Promise that resolves when deletion is complete
166
+ */
167
+ async delete(id) {
168
+ return this.restService.request({
169
+ method: "DELETE",
170
+ url: `/api/saas/tenants/${id}`
171
+ });
172
+ }
173
+ /**
174
+ * Delete the default connection string for a tenant
175
+ * @param id Tenant ID
176
+ * @returns Promise that resolves when deletion is complete
177
+ */
178
+ async deleteDefaultConnectionString(id) {
179
+ return this.restService.request({
180
+ method: "DELETE",
181
+ url: `/api/saas/tenants/${id}/default-connection-string`
182
+ });
183
+ }
184
+ /**
185
+ * Get a tenant by ID
186
+ * @param id Tenant ID
187
+ * @returns Promise with tenant data
188
+ */
189
+ async get(id) {
190
+ return this.restService.request({
191
+ method: "GET",
192
+ url: `/api/saas/tenants/${id}`
193
+ });
194
+ }
195
+ /**
196
+ * Get the default connection string for a tenant
197
+ * @param id Tenant ID
198
+ * @returns Promise with connection string
199
+ */
200
+ async getDefaultConnectionString(id) {
201
+ return this.restService.request({
202
+ method: "GET",
203
+ url: `/api/saas/tenants/${id}/default-connection-string`,
204
+ responseType: "text"
205
+ });
206
+ }
207
+ /**
208
+ * Get paginated list of tenants
209
+ * @param input Query parameters for filtering and pagination
210
+ * @returns Promise with paginated tenants response
211
+ */
212
+ async getList(input = {}) {
213
+ return this.restService.request({
214
+ method: "GET",
215
+ url: "/api/saas/tenants",
216
+ params: input
217
+ });
218
+ }
219
+ /**
220
+ * Update an existing tenant
221
+ * @param id Tenant ID
222
+ * @param input Tenant update DTO
223
+ * @returns Promise with updated tenant
224
+ */
225
+ async update(id, input) {
226
+ return this.restService.request({
227
+ method: "PUT",
228
+ url: `/api/saas/tenants/${id}`,
229
+ body: input
230
+ });
231
+ }
232
+ /**
233
+ * Update the default connection string for a tenant
234
+ * @param id Tenant ID
235
+ * @param defaultConnectionString The connection string
236
+ * @returns Promise that resolves when update is complete
237
+ */
238
+ async updateDefaultConnectionString(id, defaultConnectionString) {
239
+ return this.restService.request({
240
+ method: "PUT",
241
+ url: `/api/saas/tenants/${id}/default-connection-string`,
242
+ params: { defaultConnectionString }
243
+ });
244
+ }
245
+ };
246
+
59
247
  // src/constants/routes.ts
60
248
  var SAAS_ROUTES = {
61
249
  routes: [
@@ -328,13 +516,15 @@ var SaasStateService = class {
328
516
  usageStatistics: {},
329
517
  latestTenants: []
330
518
  };
331
- this.service = new SaasService(rest);
519
+ this.tenantService = new TenantService(rest);
520
+ this.editionService = new EditionService(rest);
332
521
  }
333
522
  // ========================
334
523
  // Getter Methods
335
524
  // ========================
336
525
  /**
337
526
  * Get the current list of tenants from state
527
+ * @returns Array of tenants
338
528
  */
339
529
  getTenants() {
340
530
  return this.state.tenants?.items ?? [];
@@ -342,30 +532,35 @@ var SaasStateService = class {
342
532
  /**
343
533
  * Get the latest tenants from state (for dashboard widget)
344
534
  * @since 2.0.0
535
+ * @returns Array of latest tenants
345
536
  */
346
537
  getLatestTenants() {
347
538
  return this.state.latestTenants ?? [];
348
539
  }
349
540
  /**
350
541
  * Get the total count of tenants from state
542
+ * @returns Total count
351
543
  */
352
544
  getTenantsTotalCount() {
353
545
  return this.state.tenants?.totalCount ?? 0;
354
546
  }
355
547
  /**
356
548
  * Get the current list of editions from state
549
+ * @returns Array of editions
357
550
  */
358
551
  getEditions() {
359
552
  return this.state.editions?.items ?? [];
360
553
  }
361
554
  /**
362
555
  * Get the total count of editions from state
556
+ * @returns Total count
363
557
  */
364
558
  getEditionsTotalCount() {
365
559
  return this.state.editions?.totalCount ?? 0;
366
560
  }
367
561
  /**
368
562
  * Get the usage statistics from state
563
+ * @returns Usage statistics data
369
564
  */
370
565
  getUsageStatistics() {
371
566
  return this.state.usageStatistics ?? {};
@@ -379,7 +574,7 @@ var SaasStateService = class {
379
574
  * @returns Promise with the tenants response
380
575
  */
381
576
  async dispatchGetTenants(params = {}) {
382
- const response = await this.service.getTenants(params);
577
+ const response = await this.tenantService.getList(params);
383
578
  this.state = {
384
579
  ...this.state,
385
580
  tenants: response
@@ -392,7 +587,7 @@ var SaasStateService = class {
392
587
  * @returns Promise with the tenant
393
588
  */
394
589
  async dispatchGetTenantById(id) {
395
- const tenant = await this.service.getTenantById(id);
590
+ const tenant = await this.tenantService.get(id);
396
591
  return tenant;
397
592
  }
398
593
  /**
@@ -401,17 +596,18 @@ var SaasStateService = class {
401
596
  * @returns Promise with the created tenant
402
597
  */
403
598
  async dispatchCreateTenant(body) {
404
- const result = await this.service.createTenant(body);
599
+ const result = await this.tenantService.create(body);
405
600
  await this.dispatchGetTenants();
406
601
  return result;
407
602
  }
408
603
  /**
409
604
  * Dispatch action to update a tenant
410
- * @param body - The tenant update request
605
+ * @param payload - Object containing id and update data
411
606
  * @returns Promise with the updated tenant
412
607
  */
413
- async dispatchUpdateTenant(body) {
414
- const result = await this.service.updateTenant(body);
608
+ async dispatchUpdateTenant(payload) {
609
+ const { id, ...input } = payload;
610
+ const result = await this.tenantService.update(id, input);
415
611
  await this.dispatchGetTenants();
416
612
  return result;
417
613
  }
@@ -421,7 +617,7 @@ var SaasStateService = class {
421
617
  * @returns Promise resolving when complete
422
618
  */
423
619
  async dispatchDeleteTenant(id) {
424
- await this.service.deleteTenant(id);
620
+ await this.tenantService.delete(id);
425
621
  await this.dispatchGetTenants();
426
622
  }
427
623
  /**
@@ -430,12 +626,12 @@ var SaasStateService = class {
430
626
  * @since 2.0.0
431
627
  */
432
628
  async dispatchGetLatestTenants() {
433
- const latestTenants = await this.service.getLatestTenants();
629
+ const response = await this.tenantService.getList({ maxResultCount: 5, sorting: "creationTime desc" });
434
630
  this.state = {
435
631
  ...this.state,
436
- latestTenants
632
+ latestTenants: response.items ?? []
437
633
  };
438
- return latestTenants;
634
+ return response;
439
635
  }
440
636
  // ========================
441
637
  // Edition Dispatch Methods
@@ -446,7 +642,7 @@ var SaasStateService = class {
446
642
  * @returns Promise with the editions response
447
643
  */
448
644
  async dispatchGetEditions(params = {}) {
449
- const response = await this.service.getEditions(params);
645
+ const response = await this.editionService.getList(params);
450
646
  this.state = {
451
647
  ...this.state,
452
648
  editions: response
@@ -459,7 +655,7 @@ var SaasStateService = class {
459
655
  * @returns Promise with the edition
460
656
  */
461
657
  async dispatchGetEditionById(id) {
462
- const edition = await this.service.getEditionById(id);
658
+ const edition = await this.editionService.get(id);
463
659
  return edition;
464
660
  }
465
661
  /**
@@ -468,17 +664,18 @@ var SaasStateService = class {
468
664
  * @returns Promise with the created edition
469
665
  */
470
666
  async dispatchCreateEdition(body) {
471
- const result = await this.service.createEdition(body);
667
+ const result = await this.editionService.create(body);
472
668
  await this.dispatchGetEditions();
473
669
  return result;
474
670
  }
475
671
  /**
476
672
  * Dispatch action to update an edition
477
- * @param body - The edition update request
673
+ * @param payload - Object containing id and update data
478
674
  * @returns Promise with the updated edition
479
675
  */
480
- async dispatchUpdateEdition(body) {
481
- const result = await this.service.updateEdition(body);
676
+ async dispatchUpdateEdition(payload) {
677
+ const { id, ...input } = payload;
678
+ const result = await this.editionService.update(id, input);
482
679
  await this.dispatchGetEditions();
483
680
  return result;
484
681
  }
@@ -488,7 +685,7 @@ var SaasStateService = class {
488
685
  * @returns Promise resolving when complete
489
686
  */
490
687
  async dispatchDeleteEdition(id) {
491
- await this.service.deleteEdition(id);
688
+ await this.editionService.delete(id);
492
689
  await this.dispatchGetEditions();
493
690
  }
494
691
  // ========================
@@ -499,7 +696,7 @@ var SaasStateService = class {
499
696
  * @returns Promise with the usage statistics response
500
697
  */
501
698
  async dispatchGetUsageStatistics() {
502
- const response = await this.service.getUsageStatistics();
699
+ const response = await this.editionService.getUsageStatistics();
503
700
  this.state = {
504
701
  ...this.state,
505
702
  usageStatistics: response.data
@@ -1732,6 +1929,7 @@ export {
1732
1929
  DEFAULT_TENANTS_ENTITY_ACTIONS,
1733
1930
  DEFAULT_TENANTS_ENTITY_PROPS,
1734
1931
  DEFAULT_TENANTS_TOOLBAR_ACTIONS,
1932
+ EditionService,
1735
1933
  EditionsComponent,
1736
1934
  SAAS_CREATE_FORM_PROP_CONTRIBUTORS,
1737
1935
  SAAS_EDIT_FORM_PROP_CONTRIBUTORS,
@@ -1744,6 +1942,7 @@ export {
1744
1942
  SaasExtensionsGuard,
1745
1943
  SaasService,
1746
1944
  SaasStateService,
1945
+ TenantService,
1747
1946
  TenantsComponent,
1748
1947
  configureRoutes,
1749
1948
  eSaasComponents,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abpjs/saas",
3
- "version": "3.0.0",
3
+ "version": "3.2.0",
4
4
  "description": "ABP Framework SaaS components for React - translated from @volo/abp.ng.saas",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -27,12 +27,12 @@
27
27
  "dependencies": {
28
28
  "@chakra-ui/react": "^3.2.0",
29
29
  "@emotion/react": "^11.11.0",
30
- "@abpjs/core": "3.0.0",
31
- "@abpjs/feature-management": "3.0.0",
32
- "@abpjs/theme-shared": "3.0.0"
30
+ "@abpjs/core": "3.2.0",
31
+ "@abpjs/theme-shared": "3.2.0",
32
+ "@abpjs/feature-management": "3.2.0"
33
33
  },
34
34
  "devDependencies": {
35
- "@volo/abp.ng.saas": "3.0.0",
35
+ "@volo/abp.ng.saas": "3.1.0",
36
36
  "@testing-library/jest-dom": "^6.9.1",
37
37
  "@testing-library/react": "^14.0.0",
38
38
  "@testing-library/user-event": "^14.6.1",