@abpjs/saas 0.7.2

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/LICENSE ADDED
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version of
113
+ the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
package/README.md ADDED
@@ -0,0 +1,374 @@
1
+ # @abpjs/saas
2
+
3
+ > SaaS tenant and edition management UI components for ABP Framework in React
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@abpjs/saas.svg)](https://www.npmjs.com/package/@abpjs/saas)
6
+ [![License: LGPL-3.0](https://img.shields.io/badge/License-LGPL--3.0-blue.svg)](https://www.gnu.org/licenses/lgpl-3.0)
7
+
8
+ ## Overview
9
+
10
+ `@abpjs/saas` provides SaaS (Software as a Service) management components for ABP-based React applications. It includes tenant management, edition management, and subscription features for multi-tenant applications.
11
+
12
+ This package is a React translation of the original `@volo/abp.ng.saas` Angular package.
13
+
14
+ ## Features
15
+
16
+ - **Tenant Management** - Create, read, update, and delete tenants
17
+ - **Edition Management** - Create, read, update, and delete editions
18
+ - **Feature Management** - Configure features per tenant/edition
19
+ - **Connection Strings** - Manage tenant database connection strings
20
+ - **Tenant Activation** - Enable/disable tenants
21
+ - **Pagination** - Built-in pagination for all list views
22
+ - **Search & Filter** - Filter tenants and editions by name
23
+ - **Chakra UI** - Beautiful, accessible components
24
+ - **TypeScript** - Full type safety with comprehensive definitions
25
+
26
+ ## Installation
27
+
28
+ ```bash
29
+ # Using npm
30
+ npm install @abpjs/saas
31
+
32
+ # Using yarn
33
+ yarn add @abpjs/saas
34
+
35
+ # Using pnpm
36
+ pnpm add @abpjs/saas
37
+ ```
38
+
39
+ ### Required Dependencies
40
+
41
+ This package requires the following peer dependencies:
42
+
43
+ ```bash
44
+ npm install @abpjs/core @abpjs/theme-shared @abpjs/feature-management @chakra-ui/react @emotion/react react-router-dom
45
+ ```
46
+
47
+ ## Quick Start
48
+
49
+ ### Using Pre-built Components
50
+
51
+ ```tsx
52
+ import { TenantsComponent, EditionsComponent } from '@abpjs/saas';
53
+ import { Tabs, TabList, TabPanels, Tab, TabPanel } from '@chakra-ui/react';
54
+
55
+ function SaaSManagement() {
56
+ return (
57
+ <Tabs>
58
+ <TabList>
59
+ <Tab>Tenants</Tab>
60
+ <Tab>Editions</Tab>
61
+ </TabList>
62
+
63
+ <TabPanels>
64
+ <TabPanel>
65
+ <TenantsComponent
66
+ onTenantCreated={(tenant) => console.log('Tenant created:', tenant)}
67
+ onTenantDeleted={(id) => console.log('Tenant deleted:', id)}
68
+ />
69
+ </TabPanel>
70
+ <TabPanel>
71
+ <EditionsComponent
72
+ onEditionCreated={(edition) => console.log('Edition created:', edition)}
73
+ onEditionDeleted={(id) => console.log('Edition deleted:', id)}
74
+ />
75
+ </TabPanel>
76
+ </TabPanels>
77
+ </Tabs>
78
+ );
79
+ }
80
+ ```
81
+
82
+ ### Using Hooks for Custom UI
83
+
84
+ ```tsx
85
+ import { useTenants, useEditions } from '@abpjs/saas';
86
+ import { useEffect } from 'react';
87
+
88
+ function CustomSaaSView() {
89
+ const { tenants, fetchTenants } = useTenants();
90
+ const { editions, fetchEditions } = useEditions();
91
+
92
+ useEffect(() => {
93
+ fetchTenants();
94
+ fetchEditions();
95
+ }, [fetchTenants, fetchEditions]);
96
+
97
+ return (
98
+ <div>
99
+ <h2>Tenants: {tenants.length}</h2>
100
+ <h2>Editions: {editions.length}</h2>
101
+ </div>
102
+ );
103
+ }
104
+ ```
105
+
106
+ ## Components
107
+
108
+ ### TenantsComponent
109
+
110
+ Complete tenant management component with table, search, and modals.
111
+
112
+ ```tsx
113
+ import { TenantsComponent } from '@abpjs/saas';
114
+
115
+ <TenantsComponent
116
+ onTenantCreated={(tenant) => console.log('Created:', tenant)}
117
+ onTenantUpdated={(tenant) => console.log('Updated:', tenant)}
118
+ onTenantDeleted={(id) => console.log('Deleted:', id)}
119
+ />
120
+ ```
121
+
122
+ **Props:**
123
+
124
+ | Prop | Type | Required | Description |
125
+ |------|------|----------|-------------|
126
+ | `onTenantCreated` | `(tenant: Tenant) => void` | No | Callback when tenant is created |
127
+ | `onTenantUpdated` | `(tenant: Tenant) => void` | No | Callback when tenant is updated |
128
+ | `onTenantDeleted` | `(id: string) => void` | No | Callback when tenant is deleted |
129
+
130
+ **Features:**
131
+ - Tenant table with actions menu
132
+ - Search/filter by tenant name
133
+ - Pagination controls
134
+ - Create/Edit modal with tabs for tenant info and connection strings
135
+ - Edition assignment
136
+ - Tenant activation/deactivation
137
+ - Feature management integration
138
+ - Delete confirmation dialog
139
+
140
+ ### EditionsComponent
141
+
142
+ Complete edition management component.
143
+
144
+ ```tsx
145
+ import { EditionsComponent } from '@abpjs/saas';
146
+
147
+ <EditionsComponent
148
+ onEditionCreated={(edition) => console.log('Created:', edition)}
149
+ onEditionUpdated={(edition) => console.log('Updated:', edition)}
150
+ onEditionDeleted={(id) => console.log('Deleted:', id)}
151
+ />
152
+ ```
153
+
154
+ **Props:**
155
+
156
+ | Prop | Type | Required | Description |
157
+ |------|------|----------|-------------|
158
+ | `onEditionCreated` | `(edition: Edition) => void` | No | Callback when edition is created |
159
+ | `onEditionUpdated` | `(edition: Edition) => void` | No | Callback when edition is updated |
160
+ | `onEditionDeleted` | `(id: string) => void` | No | Callback when edition is deleted |
161
+
162
+ **Features:**
163
+ - Edition table with actions menu
164
+ - Search/filter by edition name
165
+ - Create/Edit modal
166
+ - Feature management integration
167
+ - Delete confirmation dialog
168
+
169
+ ## Hooks
170
+
171
+ ### useTenants
172
+
173
+ Hook for managing tenants with full CRUD and pagination support.
174
+
175
+ ```tsx
176
+ import { useTenants } from '@abpjs/saas';
177
+
178
+ const {
179
+ tenants, // Array of tenants
180
+ totalCount, // Total tenant count
181
+ selectedTenant, // Currently selected tenant
182
+ isLoading, // Loading state
183
+ error, // Error message
184
+ pageQuery, // Current pagination/filter params
185
+ fetchTenants, // Fetch tenants with optional params
186
+ getTenantById, // Get single tenant
187
+ createTenant, // Create new tenant
188
+ updateTenant, // Update existing tenant
189
+ deleteTenant, // Delete tenant
190
+ setSelectedTenant, // Set the selected tenant
191
+ setPageQuery, // Update pagination params
192
+ reset, // Reset all state
193
+ } = useTenants();
194
+ ```
195
+
196
+ ### useEditions
197
+
198
+ Hook for managing editions with full CRUD support.
199
+
200
+ ```tsx
201
+ import { useEditions } from '@abpjs/saas';
202
+
203
+ const {
204
+ editions, // Array of editions
205
+ totalCount, // Total edition count
206
+ selectedEdition, // Currently selected edition
207
+ isLoading, // Loading state
208
+ error, // Error message
209
+ fetchEditions, // Fetch all editions
210
+ getEditionById, // Get single edition
211
+ createEdition, // Create new edition
212
+ updateEdition, // Update existing edition
213
+ deleteEdition, // Delete edition
214
+ setSelectedEdition, // Set the selected edition
215
+ reset, // Reset all state
216
+ } = useEditions();
217
+ ```
218
+
219
+ ## Services
220
+
221
+ ### SaaSService
222
+
223
+ Service class for SaaS API operations.
224
+
225
+ ```tsx
226
+ import { SaaSService } from '@abpjs/saas';
227
+ import { useRestService } from '@abpjs/core';
228
+
229
+ function MyComponent() {
230
+ const restService = useRestService();
231
+ const service = new SaaSService(restService);
232
+
233
+ // Tenant operations
234
+ await service.getTenants({ maxResultCount: 10, skipCount: 0 });
235
+ await service.getTenantById(tenantId);
236
+ await service.createTenant(tenantData);
237
+ await service.updateTenant(tenantId, tenantData);
238
+ await service.deleteTenant(tenantId);
239
+ await service.getDefaultConnectionString(tenantId);
240
+ await service.updateDefaultConnectionString(tenantId, connectionString);
241
+
242
+ // Edition operations
243
+ await service.getEditions();
244
+ await service.getEditionById(editionId);
245
+ await service.createEdition(editionData);
246
+ await service.updateEdition(editionId, editionData);
247
+ await service.deleteEdition(editionId);
248
+ }
249
+ ```
250
+
251
+ ## Data Models
252
+
253
+ ### Tenant
254
+
255
+ ```typescript
256
+ interface Tenant {
257
+ id: string;
258
+ name: string;
259
+ editionId: string;
260
+ editionName: string;
261
+ concurrencyStamp: string;
262
+ isActive: boolean;
263
+ activationState: TenantActivationState;
264
+ activationEndDate: string;
265
+ }
266
+
267
+ enum TenantActivationState {
268
+ Active = 0,
269
+ ActiveWithLimitedTime = 1,
270
+ Passive = 2,
271
+ }
272
+ ```
273
+
274
+ ### Edition
275
+
276
+ ```typescript
277
+ interface Edition {
278
+ id: string;
279
+ displayName: string;
280
+ }
281
+
282
+ interface EditionCreateDto {
283
+ displayName: string;
284
+ }
285
+
286
+ interface EditionUpdateDto {
287
+ displayName: string;
288
+ }
289
+ ```
290
+
291
+ ### Tenant Connection String
292
+
293
+ ```typescript
294
+ interface TenantConnectionString {
295
+ name: string;
296
+ value: string;
297
+ }
298
+ ```
299
+
300
+ ## Constants
301
+
302
+ ### SAAS_ROUTES
303
+
304
+ Default route configuration for the SaaS module:
305
+
306
+ ```tsx
307
+ import { SAAS_ROUTES } from '@abpjs/saas';
308
+
309
+ // Use in your router configuration
310
+ const routes = [
311
+ ...SAAS_ROUTES.routes,
312
+ // your other routes
313
+ ];
314
+ ```
315
+
316
+ ## Router Setup Example
317
+
318
+ ```tsx
319
+ import { BrowserRouter, Routes, Route, Navigate } from 'react-router-dom';
320
+ import { TenantsComponent, EditionsComponent } from '@abpjs/saas';
321
+
322
+ function App() {
323
+ return (
324
+ <BrowserRouter>
325
+ <Routes>
326
+ <Route path="/saas">
327
+ <Route index element={<Navigate to="tenants" replace />} />
328
+ <Route path="tenants" element={<TenantsComponent />} />
329
+ <Route path="editions" element={<EditionsComponent />} />
330
+ </Route>
331
+ </Routes>
332
+ </BrowserRouter>
333
+ );
334
+ }
335
+ ```
336
+
337
+ ## ABP Permissions
338
+
339
+ This package respects ABP's SaaS permissions:
340
+
341
+ | Permission | Description |
342
+ |------------|-------------|
343
+ | `Saas.Tenants` | View tenants |
344
+ | `Saas.Tenants.Create` | Create tenants |
345
+ | `Saas.Tenants.Update` | Update tenants |
346
+ | `Saas.Tenants.Delete` | Delete tenants |
347
+ | `Saas.Tenants.ManageFeatures` | Manage tenant features |
348
+ | `Saas.Tenants.ManageConnectionStrings` | Manage connection strings |
349
+ | `Saas.Editions` | View editions |
350
+ | `Saas.Editions.Create` | Create editions |
351
+ | `Saas.Editions.Update` | Update editions |
352
+ | `Saas.Editions.Delete` | Delete editions |
353
+ | `Saas.Editions.ManageFeatures` | Manage edition features |
354
+
355
+ ## Related Packages
356
+
357
+ - [@abpjs/core](https://www.npmjs.com/package/@abpjs/core) - Core infrastructure (required)
358
+ - [@abpjs/theme-shared](https://www.npmjs.com/package/@abpjs/theme-shared) - Shared UI components (required)
359
+ - [@abpjs/feature-management](https://www.npmjs.com/package/@abpjs/feature-management) - Feature management (required)
360
+ - [@abpjs/tenant-management](https://www.npmjs.com/package/@abpjs/tenant-management) - Basic tenant management
361
+ - [@abpjs/identity-pro](https://www.npmjs.com/package/@abpjs/identity-pro) - Identity Pro features
362
+ - [@abpjs/audit-logging](https://www.npmjs.com/package/@abpjs/audit-logging) - Audit logging
363
+
364
+ ## Contributing
365
+
366
+ This package is part of the [ABP React](https://github.com/abpjs/abp-react) monorepo. Contributions are welcome!
367
+
368
+ ## License
369
+
370
+ LGPL-3.0 - See [LICENSE](https://github.com/abpjs/abp-react/blob/main/LICENSE) for details.
371
+
372
+ ---
373
+
374
+ **[View Full Documentation](https://docs.abpjs.io/docs/packages/saas/overview)** | **[Report Issues](https://github.com/abpjs/abp-react/issues)** | **[View Source](https://github.com/abpjs/abp-react/tree/main/packages/saas)**