@scalekit-sdk/node 2.1.7 → 2.1.8
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/buf.gen.yaml +1 -0
- package/lib/auth.d.ts +41 -9
- package/lib/auth.js +44 -12
- package/lib/auth.js.map +1 -1
- package/lib/connection.d.ts +195 -21
- package/lib/connection.js +197 -23
- package/lib/connection.js.map +1 -1
- package/lib/core.d.ts +2 -2
- package/lib/core.js +13 -12
- package/lib/core.js.map +1 -1
- package/lib/directory.d.ts +293 -40
- package/lib/directory.js +308 -44
- package/lib/directory.js.map +1 -1
- package/lib/domain.d.ts +166 -18
- package/lib/domain.js +178 -29
- package/lib/domain.js.map +1 -1
- package/lib/organization.d.ts +404 -44
- package/lib/organization.js +419 -54
- package/lib/organization.js.map +1 -1
- package/lib/permission.d.ts +179 -35
- package/lib/permission.js +190 -38
- package/lib/permission.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/auth/auth_connect.d.ts +3 -3
- package/lib/pkg/grpc/scalekit/v1/auth/auth_connect.js +2 -2
- package/lib/pkg/grpc/scalekit/v1/auth/auth_connect.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/auth/auth_pb.d.ts +16 -16
- package/lib/pkg/grpc/scalekit/v1/auth/auth_pb.js +21 -21
- package/lib/pkg/grpc/scalekit/v1/auth/auth_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/auth/webauthn_connect.d.ts +82 -0
- package/lib/pkg/grpc/scalekit/v1/auth/webauthn_connect.js +90 -0
- package/lib/pkg/grpc/scalekit/v1/auth/webauthn_connect.js.map +1 -0
- package/lib/pkg/grpc/scalekit/v1/auth/webauthn_pb.d.ts +647 -0
- package/lib/pkg/grpc/scalekit/v1/auth/webauthn_pb.js +993 -0
- package/lib/pkg/grpc/scalekit/v1/auth/webauthn_pb.js.map +1 -0
- package/lib/pkg/grpc/scalekit/v1/commons/commons_pb.d.ts +142 -0
- package/lib/pkg/grpc/scalekit/v1/commons/commons_pb.js +165 -1
- package/lib/pkg/grpc/scalekit/v1/commons/commons_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/connections/connections_connect.d.ts +1 -10
- package/lib/pkg/grpc/scalekit/v1/connections/connections_connect.js +0 -9
- package/lib/pkg/grpc/scalekit/v1/connections/connections_connect.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/connections/connections_pb.d.ts +28 -63
- package/lib/pkg/grpc/scalekit/v1/connections/connections_pb.js +9 -90
- package/lib/pkg/grpc/scalekit/v1/connections/connections_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/users/users_pb.d.ts +2 -2
- package/lib/pkg/grpc/scalekit/v1/users/users_pb.js +1 -1
- package/lib/pkg/grpc/scalekit/v1/users/users_pb.js.map +1 -1
- package/lib/role.d.ts +252 -56
- package/lib/role.js +262 -62
- package/lib/role.js.map +1 -1
- package/lib/scalekit.d.ts +323 -54
- package/lib/scalekit.js +354 -76
- package/lib/scalekit.js.map +1 -1
- package/lib/session.d.ts +235 -22
- package/lib/session.js +237 -24
- package/lib/session.js.map +1 -1
- package/lib/user.d.ts +571 -53
- package/lib/user.js +598 -89
- package/lib/user.js.map +1 -1
- package/lib/webauthn.d.ts +33 -0
- package/lib/webauthn.js +80 -0
- package/lib/webauthn.js.map +1 -0
- package/package.json +2 -2
- package/src/auth.ts +53 -19
- package/src/connection.ts +237 -62
- package/src/core.ts +39 -33
- package/src/directory.ts +356 -98
- package/src/domain.ts +215 -68
- package/src/organization.ts +490 -112
- package/src/permission.ts +234 -88
- package/src/pkg/grpc/scalekit/v1/auth/auth_connect.ts +3 -3
- package/src/pkg/grpc/scalekit/v1/auth/auth_pb.ts +24 -24
- package/src/pkg/grpc/scalekit/v1/auth/webauthn_connect.ts +89 -0
- package/src/pkg/grpc/scalekit/v1/auth/webauthn_pb.ts +1263 -0
- package/src/pkg/grpc/scalekit/v1/commons/commons_pb.ts +217 -0
- package/src/pkg/grpc/scalekit/v1/connections/connections_connect.ts +1 -10
- package/src/pkg/grpc/scalekit/v1/connections/connections_pb.ts +42 -129
- package/src/pkg/grpc/scalekit/v1/users/users_pb.ts +3 -3
- package/src/role.ts +336 -136
- package/src/scalekit.ts +478 -149
- package/src/session.ts +266 -63
- package/src/user.ts +675 -168
- package/src/webauthn.ts +98 -0
package/lib/organization.js
CHANGED
|
@@ -10,6 +10,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
const organizations_connect_1 = require("./pkg/grpc/scalekit/v1/organizations/organizations_connect");
|
|
13
|
+
/**
|
|
14
|
+
* Client for managing organizations (tenants) in your Scalekit application.
|
|
15
|
+
*
|
|
16
|
+
* Organizations represent your B2B customers or tenants. Each organization can have
|
|
17
|
+
* its own SSO connection, users, and settings. Use this client to perform CRUD
|
|
18
|
+
* operations on organizations and manage organization-level configurations.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* const scalekitClient = new ScalekitClient(envUrl, clientId, clientSecret);
|
|
22
|
+
* const orgClient = scalekitClient.organization;
|
|
23
|
+
*
|
|
24
|
+
* @see {@link https://docs.scalekit.com/apis/#tag/organizations | Organization API Documentation}
|
|
25
|
+
*/
|
|
13
26
|
class OrganizationClient {
|
|
14
27
|
constructor(grpcConncet, coreClient) {
|
|
15
28
|
this.grpcConncet = grpcConncet;
|
|
@@ -17,27 +30,94 @@ class OrganizationClient {
|
|
|
17
30
|
this.client = this.grpcConncet.createClient(organizations_connect_1.OrganizationService);
|
|
18
31
|
}
|
|
19
32
|
/**
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
33
|
+
* Creates a new organization (tenant) in your Scalekit application.
|
|
34
|
+
*
|
|
35
|
+
* Organizations represent your B2B customers. Each organization can have its own
|
|
36
|
+
* SSO connections, users, and configuration. Use the external ID to map Scalekit
|
|
37
|
+
* organizations to your internal system's identifiers.
|
|
38
|
+
*
|
|
39
|
+
* @param {string} name - Display name for the organization (e.g., "Acme Corporation")
|
|
40
|
+
* @param {object} [options] - Optional configuration
|
|
41
|
+
* @param {string} [options.externalId] - Your system's unique identifier for this organization.
|
|
42
|
+
* Useful for mapping to your internal database.
|
|
43
|
+
*
|
|
44
|
+
* @returns {Promise<CreateOrganizationResponse>} The created organization with:
|
|
45
|
+
* - id: Scalekit's unique organization identifier
|
|
46
|
+
* - displayName: The organization's name
|
|
47
|
+
* - externalId: Unique Identifier of this organization as identified in your system. (if provided)
|
|
48
|
+
* - createTime: When the organization was created
|
|
49
|
+
* - updateTime: When the organization was last updated
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* // Create a basic organization
|
|
53
|
+
* const org = await scalekitClient.organization.createOrganization('Acme Corp');
|
|
54
|
+
* console.log('Organization ID:', org.organization.id);
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* // Create organization with external ID mapping
|
|
58
|
+
* const org = await scalekitClient.organization.createOrganization(
|
|
59
|
+
* 'Acme Corporation',
|
|
60
|
+
* { externalId: 'customer_12345' }
|
|
61
|
+
* );
|
|
62
|
+
* // Now you can look up this organization using either Scalekit ID or your external ID
|
|
63
|
+
*
|
|
64
|
+
* @see {@link https://docs.scalekit.com/apis/#tag/organizations | Create Organization API}
|
|
65
|
+
* @see {@link getOrganization} - Retrieve organization by Scalekit ID
|
|
66
|
+
* @see {@link getOrganizationByExternalId} - Retrieve organization by your external ID
|
|
67
|
+
*/
|
|
26
68
|
createOrganization(name, options) {
|
|
27
69
|
return __awaiter(this, void 0, void 0, function* () {
|
|
28
70
|
return this.coreClient.connectExec(this.client.createOrganization, {
|
|
29
71
|
organization: Object.assign({ displayName: name }, ((options === null || options === void 0 ? void 0 : options.externalId) && {
|
|
30
|
-
externalId: options.externalId
|
|
31
|
-
}))
|
|
72
|
+
externalId: options.externalId,
|
|
73
|
+
})),
|
|
32
74
|
});
|
|
33
75
|
});
|
|
34
76
|
}
|
|
35
77
|
/**
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
78
|
+
* Retrieves a paginated list of all organizations in your Scalekit environment.
|
|
79
|
+
*
|
|
80
|
+
* This method returns all organizations with support for pagination. Use this to
|
|
81
|
+
* display a list of your B2B customers, search for organizations, or perform bulk operations.
|
|
82
|
+
*
|
|
83
|
+
* @param {object} [options] - Optional pagination parameters
|
|
84
|
+
* @param {number} [options.pageSize] - Number of organizations to return per page (default: 10, max: 100)
|
|
85
|
+
* @param {string} [options.pageToken] - Token for retrieving the next page of results.
|
|
86
|
+
* Obtained from the previous response's nextPageToken.
|
|
87
|
+
*
|
|
88
|
+
* @returns {Promise<ListOrganizationsResponse>} Response containing:
|
|
89
|
+
* - organizations: Array of organization objects
|
|
90
|
+
* - nextPageToken: Token for fetching the next page (empty if no more pages)
|
|
91
|
+
* - totalSize: Total number of organizations
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* // List first page of organizations
|
|
95
|
+
* const response = await scalekitClient.organization.listOrganization({
|
|
96
|
+
* pageSize: 20
|
|
97
|
+
* });
|
|
98
|
+
*
|
|
99
|
+
* console.log('Organizations:', response.organizations);
|
|
100
|
+
* console.log('Total:', response.totalSize);
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* // Paginate through all organizations
|
|
104
|
+
* let pageToken = undefined;
|
|
105
|
+
* let allOrgs = [];
|
|
106
|
+
*
|
|
107
|
+
* do {
|
|
108
|
+
* const response = await scalekitClient.organization.listOrganization({
|
|
109
|
+
* pageSize: 50,
|
|
110
|
+
* pageToken
|
|
111
|
+
* });
|
|
112
|
+
*
|
|
113
|
+
* allOrgs.push(...response.organizations);
|
|
114
|
+
* pageToken = response.nextPageToken;
|
|
115
|
+
* } while (pageToken);
|
|
116
|
+
*
|
|
117
|
+
* console.log('Fetched all organizations:', allOrgs.length);
|
|
118
|
+
*
|
|
119
|
+
* @see {@link https://docs.scalekit.com/apis/#tag/organizations | List Organizations API}
|
|
120
|
+
* @see {@link getOrganization} - Get a specific organization by ID
|
|
41
121
|
*/
|
|
42
122
|
listOrganization(options) {
|
|
43
123
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -45,111 +125,396 @@ class OrganizationClient {
|
|
|
45
125
|
});
|
|
46
126
|
}
|
|
47
127
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
128
|
+
* Retrieves detailed information about a specific organization using its Scalekit ID.
|
|
129
|
+
*
|
|
130
|
+
* Use this method to fetch complete organization details including display name, region,
|
|
131
|
+
* metadata, settings, and configuration. This is useful for displaying organization info
|
|
132
|
+
* in your application or checking organization status.
|
|
133
|
+
*
|
|
134
|
+
* @param {string} id - The Scalekit-generated organization identifier (format: "org_...")
|
|
135
|
+
*
|
|
136
|
+
* @returns {Promise<GetOrganizationResponse>} Response containing:
|
|
137
|
+
* - organization: Complete organization object with:
|
|
138
|
+
* - id: Scalekit's unique identifier
|
|
139
|
+
* - displayName: Organization's display name
|
|
140
|
+
* - externalId: Your system's identifier (if set)
|
|
141
|
+
* - metadata: Custom metadata key-value pairs
|
|
142
|
+
* - createTime: When the organization was created
|
|
143
|
+
* - updateTime: When the organization was last updated
|
|
144
|
+
*
|
|
145
|
+
* @throws {Error} If the organization is not found or access is denied
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* // Get organization details
|
|
149
|
+
* const response = await scalekitClient.organization.getOrganization('org_12345');
|
|
150
|
+
* const org = response.organization;
|
|
151
|
+
*
|
|
152
|
+
* console.log('Organization:', org.displayName);
|
|
153
|
+
* console.log('External ID:', org.externalId);
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* // Check if organization exists before operations
|
|
157
|
+
* try {
|
|
158
|
+
* const response = await scalekitClient.organization.getOrganization(orgId);
|
|
159
|
+
* // Proceed with organization operations
|
|
160
|
+
* } catch (error) {
|
|
161
|
+
* console.error('Organization not found:', error);
|
|
162
|
+
* }
|
|
163
|
+
*
|
|
164
|
+
* @see {@link https://docs.scalekit.com/apis/#tag/organizations | Get Organization API}
|
|
165
|
+
* @see {@link getOrganizationByExternalId} - Retrieve organization using your external ID
|
|
166
|
+
* @see {@link listOrganization} - List all organizations
|
|
51
167
|
*/
|
|
52
168
|
getOrganization(id) {
|
|
53
169
|
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
-
return this.coreClient.connectExec(this.client.getOrganization, {
|
|
170
|
+
return this.coreClient.connectExec(this.client.getOrganization, {
|
|
171
|
+
identities: { case: "id", value: id },
|
|
172
|
+
});
|
|
55
173
|
});
|
|
56
174
|
}
|
|
57
175
|
/**
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
176
|
+
* Retrieves detailed information about an organization using your system's external identifier.
|
|
177
|
+
*
|
|
178
|
+
* This is particularly useful when you need to look up an organization using your own
|
|
179
|
+
* internal identifiers rather than Scalekit's ID. The external ID is typically set when
|
|
180
|
+
* creating or updating an organization to maintain a mapping between your system and Scalekit.
|
|
181
|
+
*
|
|
182
|
+
* @param {string} externalId - Your system's unique identifier for the organization
|
|
183
|
+
* (e.g., "customer_12345", "tenant_abc")
|
|
184
|
+
*
|
|
185
|
+
* @returns {Promise<GetOrganizationResponse>} Response containing:
|
|
186
|
+
* - organization: Complete organization object with all details
|
|
187
|
+
* (same structure as {@link getOrganization})
|
|
188
|
+
*
|
|
189
|
+
* @throws {Error} If no organization is found with the provided external ID
|
|
190
|
+
*
|
|
191
|
+
* @example
|
|
192
|
+
* // Retrieve organization using your internal customer ID
|
|
193
|
+
* const response = await scalekitClient.organization.getOrganizationByExternalId('customer_12345');
|
|
194
|
+
* const org = response.organization;
|
|
195
|
+
*
|
|
196
|
+
* console.log('Scalekit ID:', org.id);
|
|
197
|
+
* console.log('Organization:', org.displayName);
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* // Use in API endpoints where you have your customer ID
|
|
201
|
+
* app.get('/api/customers/:customerId/sso', async (req, res) => {
|
|
202
|
+
* const { customerId } = req.params;
|
|
203
|
+
*
|
|
204
|
+
* try {
|
|
205
|
+
* const response = await scalekitClient.organization.getOrganizationByExternalId(customerId);
|
|
206
|
+
* res.json({ organization: response.organization });
|
|
207
|
+
* } catch (error) {
|
|
208
|
+
* res.status(404).json({ error: 'Organization not found' });
|
|
209
|
+
* }
|
|
210
|
+
* });
|
|
211
|
+
*
|
|
212
|
+
* @see {@link https://docs.scalekit.com/apis/#tag/organizations | Get Organization API}
|
|
213
|
+
* @see {@link getOrganization} - Retrieve organization using Scalekit ID
|
|
214
|
+
* @see {@link createOrganization} - Create organization with external ID mapping
|
|
61
215
|
*/
|
|
62
216
|
getOrganizationByExternalId(externalId) {
|
|
63
217
|
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
-
return this.coreClient.connectExec(this.client.getOrganization, {
|
|
218
|
+
return this.coreClient.connectExec(this.client.getOrganization, {
|
|
219
|
+
identities: { case: "externalId", value: externalId },
|
|
220
|
+
});
|
|
65
221
|
});
|
|
66
222
|
}
|
|
67
223
|
/**
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
224
|
+
* Updates an organization's properties using its Scalekit ID.
|
|
225
|
+
*
|
|
226
|
+
* Use this method to modify an organization's display name, external ID, or custom metadata.
|
|
227
|
+
* Only the fields you specify in the update object will be changed; all other fields remain
|
|
228
|
+
* unchanged. Note that the region code cannot be modified once set.
|
|
229
|
+
*
|
|
230
|
+
* @param {string} id - The Scalekit organization identifier (format: "org_...")
|
|
231
|
+
* @param {PartialMessage<UpdateOrganization>} organization - Object containing fields to update:
|
|
232
|
+
* - displayName?: New display name for the organization
|
|
233
|
+
* - externalId?: New external ID to map to your system
|
|
234
|
+
* - metadata?: Custom key-value pairs for storing additional data
|
|
235
|
+
*
|
|
236
|
+
* @returns {Promise<UpdateOrganizationResponse>} Response containing:
|
|
237
|
+
* - organization: The updated organization object with all current values
|
|
238
|
+
*
|
|
239
|
+
* @throws {Error} If the organization is not found or update fails
|
|
240
|
+
*
|
|
241
|
+
* @example
|
|
242
|
+
* // Update organization display name
|
|
243
|
+
* const response = await scalekitClient.organization.updateOrganization('org_12345', {
|
|
244
|
+
* displayName: 'Acme Corporation (Updated)'
|
|
245
|
+
* });
|
|
246
|
+
*
|
|
247
|
+
* console.log('Updated:', response.organization.displayName);
|
|
248
|
+
*
|
|
249
|
+
* @example
|
|
250
|
+
* // Add external ID to existing organization
|
|
251
|
+
* await scalekitClient.organization.updateOrganization('org_12345', {
|
|
252
|
+
* externalId: 'customer_abc'
|
|
253
|
+
* });
|
|
254
|
+
*
|
|
255
|
+
* @example
|
|
256
|
+
* // Update multiple fields including metadata
|
|
257
|
+
* const response = await scalekitClient.organization.updateOrganization('org_12345', {
|
|
258
|
+
* displayName: 'Acme Corp',
|
|
259
|
+
* metadata: {
|
|
260
|
+
* industry: 'Technology',
|
|
261
|
+
* size: 'Enterprise',
|
|
262
|
+
* plan: 'Premium'
|
|
263
|
+
* }
|
|
264
|
+
* });
|
|
265
|
+
*
|
|
266
|
+
* @see {@link https://docs.scalekit.com/apis/#tag/organizations | Update Organization API}
|
|
267
|
+
* @see {@link updateOrganizationByExternalId} - Update using your external ID
|
|
268
|
+
* @see {@link getOrganization} - Retrieve current organization details
|
|
72
269
|
*/
|
|
73
270
|
updateOrganization(id, organization) {
|
|
74
271
|
return __awaiter(this, void 0, void 0, function* () {
|
|
75
272
|
return this.coreClient.connectExec(this.client.updateOrganization, {
|
|
76
273
|
identities: { case: "id", value: id },
|
|
77
|
-
organization
|
|
274
|
+
organization,
|
|
78
275
|
});
|
|
79
276
|
});
|
|
80
277
|
}
|
|
81
278
|
/**
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
* @
|
|
85
|
-
*
|
|
279
|
+
* Updates an organization's properties using your system's external identifier.
|
|
280
|
+
*
|
|
281
|
+
* This method provides the same functionality as {@link updateOrganization} but allows you
|
|
282
|
+
* to reference the organization using your own internal identifier instead of Scalekit's ID.
|
|
283
|
+
* Only specified fields will be updated; all other fields remain unchanged.
|
|
284
|
+
*
|
|
285
|
+
* @param {string} externalId - Your system's unique identifier for the organization
|
|
286
|
+
* @param {PartialMessage<UpdateOrganization>} organization - Object containing fields to update:
|
|
287
|
+
* - displayName?: New display name for the organization
|
|
288
|
+
* - externalId?: New external ID (useful for migrating identifiers)
|
|
289
|
+
* - metadata?: Custom key-value pairs for storing additional data
|
|
290
|
+
*
|
|
291
|
+
* @returns {Promise<UpdateOrganizationResponse>} Response containing:
|
|
292
|
+
* - organization: The updated organization object with all current values
|
|
293
|
+
*
|
|
294
|
+
* @throws {Error} If no organization is found with the provided external ID
|
|
295
|
+
*
|
|
296
|
+
* @example
|
|
297
|
+
* // Update organization using your customer ID
|
|
298
|
+
* const response = await scalekitClient.organization.updateOrganizationByExternalId(
|
|
299
|
+
* 'customer_12345',
|
|
300
|
+
* { displayName: 'New Company Name' }
|
|
301
|
+
* );
|
|
302
|
+
*
|
|
303
|
+
* @example
|
|
304
|
+
* // Update metadata for reporting and analytics
|
|
305
|
+
* await scalekitClient.organization.updateOrganizationByExternalId('customer_12345', {
|
|
306
|
+
* metadata: {
|
|
307
|
+
* accountManager: 'john@example.com',
|
|
308
|
+
* renewalDate: '2025-12-31',
|
|
309
|
+
* tier: 'enterprise'
|
|
310
|
+
* }
|
|
311
|
+
* });
|
|
312
|
+
*
|
|
313
|
+
* @example
|
|
314
|
+
* // Use in API endpoints with your customer identifiers
|
|
315
|
+
* app.patch('/api/customers/:customerId', async (req, res) => {
|
|
316
|
+
* const { customerId } = req.params;
|
|
317
|
+
* const { name } = req.body;
|
|
318
|
+
*
|
|
319
|
+
* const response = await scalekitClient.organization.updateOrganizationByExternalId(
|
|
320
|
+
* customerId,
|
|
321
|
+
* { displayName: name }
|
|
322
|
+
* );
|
|
323
|
+
*
|
|
324
|
+
* res.json({ organization: response.organization });
|
|
325
|
+
* });
|
|
326
|
+
*
|
|
327
|
+
* @see {@link https://docs.scalekit.com/apis/#tag/organizations | Update Organization API}
|
|
328
|
+
* @see {@link updateOrganization} - Update using Scalekit ID
|
|
329
|
+
* @see {@link getOrganizationByExternalId} - Retrieve organization by external ID
|
|
86
330
|
*/
|
|
87
331
|
updateOrganizationByExternalId(externalId, organization) {
|
|
88
332
|
return __awaiter(this, void 0, void 0, function* () {
|
|
89
333
|
return this.coreClient.connectExec(this.client.updateOrganization, {
|
|
90
|
-
identities: { case: "externalId", value: externalId
|
|
91
|
-
organization
|
|
334
|
+
identities: { case: "externalId", value: externalId },
|
|
335
|
+
organization,
|
|
92
336
|
});
|
|
93
337
|
});
|
|
94
338
|
}
|
|
95
339
|
/**
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
340
|
+
* Permanently deletes an organization from your Scalekit environment.
|
|
341
|
+
*
|
|
342
|
+
* This operation removes the organization and all associated data including SSO connections,
|
|
343
|
+
* users, and settings. This action cannot be undone, so use with caution.
|
|
344
|
+
*
|
|
345
|
+
* @param {string} organizationId - The Scalekit organization identifier to delete
|
|
346
|
+
*
|
|
347
|
+
* @returns {Promise<Empty>} Empty response on successful deletion
|
|
348
|
+
*
|
|
349
|
+
* @throws {Error} If the organization is not found or deletion fails
|
|
350
|
+
*
|
|
351
|
+
* @example
|
|
352
|
+
* // Delete an organization
|
|
353
|
+
* await scalekitClient.organization.deleteOrganization('org_12345');
|
|
354
|
+
* console.log('Organization deleted successfully');
|
|
355
|
+
*
|
|
356
|
+
* @example
|
|
357
|
+
* // Delete with confirmation flow
|
|
358
|
+
* const confirmDelete = await askUserConfirmation(
|
|
359
|
+
* 'Are you sure you want to delete this organization? This cannot be undone.'
|
|
360
|
+
* );
|
|
361
|
+
*
|
|
362
|
+
* if (confirmDelete) {
|
|
363
|
+
* try {
|
|
364
|
+
* await scalekitClient.organization.deleteOrganization(orgId);
|
|
365
|
+
* console.log('Organization deleted');
|
|
366
|
+
* } catch (error) {
|
|
367
|
+
* console.error('Failed to delete organization:', error);
|
|
368
|
+
* }
|
|
369
|
+
* }
|
|
370
|
+
*
|
|
371
|
+
* @see {@link https://docs.scalekit.com/apis/#tag/organizations | Delete Organization API}
|
|
372
|
+
* @see {@link getOrganization} - Check if organization exists before deletion
|
|
99
373
|
*/
|
|
100
374
|
deleteOrganization(organizationId) {
|
|
101
375
|
return __awaiter(this, void 0, void 0, function* () {
|
|
102
376
|
return this.coreClient.connectExec(this.client.deleteOrganization, {
|
|
103
|
-
identities: { case: "id", value: organizationId
|
|
377
|
+
identities: { case: "id", value: organizationId },
|
|
104
378
|
});
|
|
105
379
|
});
|
|
106
380
|
}
|
|
107
381
|
/**
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
382
|
+
* Creates a single use Admin Portal URL valid for 1 minute.
|
|
383
|
+
*
|
|
384
|
+
* Once the generated admin portal URL is accessed or rendered, a temporary session of 6 hours
|
|
385
|
+
* is created to allow the admin to update SSO/SCIM configuration.
|
|
386
|
+
*
|
|
387
|
+
*
|
|
388
|
+
* @param {string} organizationId - The Scalekit organization ID
|
|
389
|
+
*
|
|
390
|
+
* @returns {Promise<Link>} Link object containing:
|
|
391
|
+
* - location: The complete portal URL to redirect the admin to
|
|
392
|
+
* - expiresAt: Timestamp when the link expires (60 seconds from generation)
|
|
393
|
+
*
|
|
394
|
+
* @throws {Error} When the link generation fails
|
|
395
|
+
*
|
|
396
|
+
* @example
|
|
397
|
+
* // Generate admin portal link
|
|
398
|
+
* app.get('/admin/sso-settings', async (req, res) => {
|
|
399
|
+
* const organizationId = req.user.organizationId;
|
|
400
|
+
*
|
|
401
|
+
* try {
|
|
402
|
+
* const link = await scalekitClient.organization.generatePortalLink(organizationId);
|
|
403
|
+
*
|
|
404
|
+
* // Redirect the admin to the portal
|
|
405
|
+
* res.redirect(link.location);
|
|
406
|
+
* } catch (error) {
|
|
407
|
+
* console.error('Failed to generate portal link:', error);
|
|
408
|
+
* res.status(500).send('Unable to access admin portal');
|
|
409
|
+
* }
|
|
410
|
+
* });
|
|
411
|
+
*
|
|
412
|
+
*
|
|
413
|
+
* @see {@link https://docs.scalekit.com/apis/#tag/organizations | Generate Portal Link API}
|
|
414
|
+
* @see {@link https://docs.scalekit.com/authenticate/sso/admin-portal/ | Admin Portal Guide}
|
|
111
415
|
*/
|
|
112
416
|
generatePortalLink(organizationId) {
|
|
113
417
|
return __awaiter(this, void 0, void 0, function* () {
|
|
114
418
|
const response = yield this.coreClient.connectExec(this.client.generatePortalLink, {
|
|
115
|
-
id: organizationId
|
|
419
|
+
id: organizationId,
|
|
116
420
|
});
|
|
117
421
|
if (!response.link) {
|
|
118
|
-
throw new Error(
|
|
422
|
+
throw new Error("Error generating portal link");
|
|
119
423
|
}
|
|
120
424
|
return response.link;
|
|
121
425
|
});
|
|
122
426
|
}
|
|
123
427
|
/**
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
428
|
+
* Updates configuration settings and feature flags for an organization.
|
|
429
|
+
*
|
|
430
|
+
* Use this method to enable or disable organization-level features such as SSO configuration,
|
|
431
|
+
* directory synchronization, session management, and other organization-specific settings.
|
|
432
|
+
* This allows you to customize the capabilities available to each organization based on
|
|
433
|
+
* their subscription tier or requirements.
|
|
434
|
+
*
|
|
435
|
+
* @param {string} organizationId - The Scalekit organization identifier (format: "org_...")
|
|
436
|
+
* @param {OrganizationSettings} settings - Configuration settings object containing:
|
|
437
|
+
* - features: Array of feature objects, each with:
|
|
438
|
+
* - name: Feature identifier (e.g., "sso", "directory_sync")
|
|
439
|
+
* - enabled: Boolean flag to enable/disable the feature
|
|
440
|
+
*
|
|
441
|
+
* @returns {Promise<GetOrganizationResponse>} Response containing:
|
|
442
|
+
* - organization: Complete organization object with updated settings
|
|
443
|
+
*
|
|
444
|
+
* @throws {Error} If the organization is not found or settings update fails
|
|
445
|
+
*
|
|
446
|
+
* @example
|
|
447
|
+
* // Enable SSO and directory sync for an organization
|
|
448
|
+
* const response = await scalekitClient.organization.updateOrganizationSettings('org_12345', {
|
|
449
|
+
* features: [
|
|
450
|
+
* { name: 'sso', enabled: true },
|
|
451
|
+
* { name: 'directory_sync', enabled: true }
|
|
452
|
+
* ]
|
|
453
|
+
* });
|
|
454
|
+
*
|
|
455
|
+
* console.log('Settings updated:', response.organization.settings);
|
|
456
|
+
*
|
|
457
|
+
*
|
|
458
|
+
* @see {@link https://docs.scalekit.com/apis/#tag/organizations | Update Organization Settings API}
|
|
459
|
+
* @see {@link getOrganization} - Retrieve current organization settings
|
|
460
|
+
* @see {@link upsertUserManagementSettings} - Update user management settings
|
|
128
461
|
*/
|
|
129
462
|
updateOrganizationSettings(organizationId, settings) {
|
|
130
463
|
return __awaiter(this, void 0, void 0, function* () {
|
|
131
464
|
const request = {
|
|
132
465
|
id: organizationId,
|
|
133
466
|
settings: {
|
|
134
|
-
features: settings.features.map(feature => ({
|
|
467
|
+
features: settings.features.map((feature) => ({
|
|
135
468
|
name: feature.name,
|
|
136
|
-
enabled: feature.enabled
|
|
137
|
-
}))
|
|
138
|
-
}
|
|
469
|
+
enabled: feature.enabled,
|
|
470
|
+
})),
|
|
471
|
+
},
|
|
139
472
|
};
|
|
140
473
|
return this.coreClient.connectExec(this.client.updateOrganizationSettings, request);
|
|
141
474
|
});
|
|
142
475
|
}
|
|
143
476
|
/**
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
*
|
|
477
|
+
* Creates or updates user management settings for an organization.
|
|
478
|
+
*
|
|
479
|
+
* This method allows you to configure user-related constraints and policies at the
|
|
480
|
+
* organization level, such as setting a maximum number of allowed users. This is
|
|
481
|
+
* useful for enforcing subscription limits, preventing overuse, or managing capacity.
|
|
482
|
+
* If settings already exist, they will be updated; otherwise, new settings are created.
|
|
483
|
+
*
|
|
484
|
+
* @param {string} organizationId - The Scalekit organization identifier (format: "org_...")
|
|
485
|
+
* @param {OrganizationUserManagementSettingsInput} settings - User management configuration:
|
|
486
|
+
* - maxAllowedUsers?: Maximum number of users allowed in the organization.
|
|
487
|
+
* Set to null or undefined to remove the limit.
|
|
488
|
+
*
|
|
489
|
+
* @returns {Promise<OrganizationUserManagementSettingsMessage | undefined>} The updated settings object containing:
|
|
490
|
+
* - maxAllowedUsers: The configured user limit (if set)
|
|
491
|
+
*
|
|
492
|
+
* @throws {Error} If the organization is not found or settings update fails
|
|
493
|
+
*
|
|
494
|
+
* @example
|
|
495
|
+
* // Set maximum user limit for an organization
|
|
496
|
+
* const settings = await scalekitClient.organization.upsertUserManagementSettings(
|
|
497
|
+
* 'org_12345',
|
|
498
|
+
* { maxAllowedUsers: 100 }
|
|
499
|
+
* );
|
|
500
|
+
*
|
|
501
|
+
* console.log('Max users allowed:', settings?.maxAllowedUsers);
|
|
502
|
+
*
|
|
503
|
+
* @example
|
|
504
|
+
* // Remove user limit (set to unlimited)
|
|
505
|
+
* await scalekitClient.organization.upsertUserManagementSettings('org_12345', {
|
|
506
|
+
* maxAllowedUsers: null
|
|
507
|
+
* });
|
|
508
|
+
*
|
|
509
|
+
* @see {@link https://docs.scalekit.com/apis/#tag/organizations | User Management Settings API}
|
|
510
|
+
* @see {@link getOrganization} - Retrieve current organization settings
|
|
511
|
+
* @see {@link updateOrganizationSettings} - Update other organization settings
|
|
148
512
|
*/
|
|
149
513
|
upsertUserManagementSettings(organizationId, settings) {
|
|
150
514
|
return __awaiter(this, void 0, void 0, function* () {
|
|
151
515
|
const requestSettings = {};
|
|
152
|
-
if (settings.maxAllowedUsers !== undefined &&
|
|
516
|
+
if (settings.maxAllowedUsers !== undefined &&
|
|
517
|
+
settings.maxAllowedUsers !== null) {
|
|
153
518
|
requestSettings.maxAllowedUsers = settings.maxAllowedUsers;
|
|
154
519
|
}
|
|
155
520
|
const response = yield this.coreClient.connectExec(this.client.upsertUserManagementSettings, {
|
package/lib/organization.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"organization.js","sourceRoot":"","sources":["../src/organization.ts"],"names":[],"mappings":";;;;;;;;;;;AAIA,sGAAiG;
|
|
1
|
+
{"version":3,"file":"organization.js","sourceRoot":"","sources":["../src/organization.ts"],"names":[],"mappings":";;;;;;;;;;;AAIA,sGAAiG;AAejG;;;;;;;;;;;;GAYG;AACH,MAAqB,kBAAkB;IAErC,YACmB,WAAwB,EACxB,UAAsB;QADtB,gBAAW,GAAX,WAAW,CAAa;QACxB,eAAU,GAAV,UAAU,CAAY;QAEvC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,2CAAmB,CAAC,CAAC;IACnE,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmCG;IACG,kBAAkB,CACtB,IAAY,EACZ,OAAiC;;YAEjC,OAAO,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,kBAAkB,EAAE;gBACjE,YAAY,kBACV,WAAW,EAAE,IAAI,IACd,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,UAAU,KAAI;oBACzB,UAAU,EAAE,OAAO,CAAC,UAAU;iBAC/B,CAAC,CACH;aACF,CAAC,CAAC;QACL,CAAC;KAAA;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4CG;IACG,gBAAgB,CAAC,OAGtB;;YACC,OAAO,IAAI,CAAC,UAAU,CAAC,WAAW,CAChC,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAC5B,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CACvB,CAAC;QACJ,CAAC;KAAA;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwCG;IACG,eAAe,CAAC,EAAU;;YAC9B,OAAO,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,eAAe,EAAE;gBAC9D,UAAU,EAAE,EAAE,IAAI,EAAE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