@zyphr-dev/node-sdk 0.1.32 → 0.1.33

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.
Files changed (34) hide show
  1. package/dist/index.cjs +1624 -84
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +1780 -237
  4. package/dist/index.d.ts +1780 -237
  5. package/dist/index.js +1530 -84
  6. package/dist/index.js.map +1 -1
  7. package/package.json +1 -1
  8. package/src/.openapi-generator/FILES +20 -0
  9. package/src/client.ts +5 -0
  10. package/src/src/apis/AuthOrganizationsApi.ts +823 -0
  11. package/src/src/apis/AuthUserProfileApi.ts +62 -0
  12. package/src/src/apis/MuseApi.ts +531 -0
  13. package/src/src/apis/index.ts +2 -0
  14. package/src/src/models/AddOrganizationMemberRequest.ts +74 -0
  15. package/src/src/models/CreateOrganizationRequest.ts +82 -0
  16. package/src/src/models/LoginRequest.ts +12 -0
  17. package/src/src/models/Organization.ts +137 -0
  18. package/src/src/models/OrganizationListResponse.ts +90 -0
  19. package/src/src/models/OrganizationListResponseMeta.ts +73 -0
  20. package/src/src/models/OrganizationMembersListResponse.ts +90 -0
  21. package/src/src/models/OrganizationMembership.ts +119 -0
  22. package/src/src/models/OrganizationMembershipResponse.ts +90 -0
  23. package/src/src/models/OrganizationMembershipWithUser.ts +135 -0
  24. package/src/src/models/OrganizationResponse.ts +90 -0
  25. package/src/src/models/RegisterRequest.ts +23 -0
  26. package/src/src/models/SwitchOrganizationRequest.ts +75 -0
  27. package/src/src/models/SwitchOrganizationResponse.ts +90 -0
  28. package/src/src/models/SwitchOrganizationResponseData.ts +99 -0
  29. package/src/src/models/SwitchOrganizationResponseDataTokens.ts +103 -0
  30. package/src/src/models/SwitchOrganizationResponseDataUser.ts +73 -0
  31. package/src/src/models/UpdateOrganizationMemberRoleRequest.ts +66 -0
  32. package/src/src/models/UpdateOrganizationRequest.ts +81 -0
  33. package/src/src/models/V1MuseSubjectsSuggestPostRequest.ts +105 -0
  34. package/src/src/models/index.ts +18 -0
@@ -0,0 +1,823 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * Zyphr API
5
+ * Zyphr is a multi-channel notification platform that enables developers to send emails, push notifications, SMS, and in-app messages through a unified API. ## Authentication All API requests require authentication using an API key. Include your API key in the `X-API-Key` header: ``` X-API-Key: zy_live_xxxxxxxxxxxx ``` API keys can be created in the Zyphr Dashboard. Use `zy_test_*` keys for testing and `zy_live_*` keys for production. ## Rate Limiting The API implements rate limiting to ensure fair usage. Rate limit information is included in response headers: - `X-RateLimit-Limit`: Maximum requests per window - `X-RateLimit-Remaining`: Remaining requests in current window - `X-RateLimit-Reset`: Unix timestamp when the window resets ## Errors All errors follow a consistent format: ```json { \"error\": { \"code\": \"error_code\", \"message\": \"Human readable message\", \"details\": {} }, \"meta\": { \"request_id\": \"req_xxxx\" } } ```
6
+ *
7
+ * The version of the OpenAPI document: 1.0.0
8
+ * Contact: support@zyphr.dev
9
+ *
10
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11
+ * https://openapi-generator.tech
12
+ * Do not edit the class manually.
13
+ */
14
+
15
+
16
+ import * as runtime from '../runtime';
17
+ import type {
18
+ AddOrganizationMemberRequest,
19
+ CreateOrganizationRequest,
20
+ OrganizationListResponse,
21
+ OrganizationMembersListResponse,
22
+ OrganizationMembershipResponse,
23
+ OrganizationResponse,
24
+ SwitchOrganizationRequest,
25
+ SwitchOrganizationResponse,
26
+ UpdateOrganizationMemberRoleRequest,
27
+ UpdateOrganizationRequest,
28
+ } from '../models/index';
29
+ import {
30
+ AddOrganizationMemberRequestFromJSON,
31
+ AddOrganizationMemberRequestToJSON,
32
+ CreateOrganizationRequestFromJSON,
33
+ CreateOrganizationRequestToJSON,
34
+ OrganizationListResponseFromJSON,
35
+ OrganizationListResponseToJSON,
36
+ OrganizationMembersListResponseFromJSON,
37
+ OrganizationMembersListResponseToJSON,
38
+ OrganizationMembershipResponseFromJSON,
39
+ OrganizationMembershipResponseToJSON,
40
+ OrganizationResponseFromJSON,
41
+ OrganizationResponseToJSON,
42
+ SwitchOrganizationRequestFromJSON,
43
+ SwitchOrganizationRequestToJSON,
44
+ SwitchOrganizationResponseFromJSON,
45
+ SwitchOrganizationResponseToJSON,
46
+ UpdateOrganizationMemberRoleRequestFromJSON,
47
+ UpdateOrganizationMemberRoleRequestToJSON,
48
+ UpdateOrganizationRequestFromJSON,
49
+ UpdateOrganizationRequestToJSON,
50
+ } from '../models/index';
51
+
52
+ export interface AuthOrganizationsApiAddOrganizationMemberOperationRequest {
53
+ id: string;
54
+ addOrganizationMemberRequest: AddOrganizationMemberRequest;
55
+ }
56
+
57
+ export interface AuthOrganizationsApiCreateOrganizationOperationRequest {
58
+ createOrganizationRequest: CreateOrganizationRequest;
59
+ }
60
+
61
+ export interface AuthOrganizationsApiDeleteOrganizationRequest {
62
+ id: string;
63
+ }
64
+
65
+ export interface AuthOrganizationsApiGetOrganizationRequest {
66
+ id: string;
67
+ }
68
+
69
+ export interface AuthOrganizationsApiListOrganizationMembersRequest {
70
+ id: string;
71
+ limit?: number;
72
+ cursor?: string;
73
+ }
74
+
75
+ export interface AuthOrganizationsApiListOrganizationsRequest {
76
+ limit?: number;
77
+ cursor?: string;
78
+ search?: string;
79
+ }
80
+
81
+ export interface AuthOrganizationsApiListOrganizationsForEndUserRequest {
82
+ userId: string;
83
+ }
84
+
85
+ export interface AuthOrganizationsApiRemoveOrganizationMemberRequest {
86
+ id: string;
87
+ userId: string;
88
+ }
89
+
90
+ export interface AuthOrganizationsApiSwitchOrganizationOperationRequest {
91
+ switchOrganizationRequest: SwitchOrganizationRequest;
92
+ }
93
+
94
+ export interface AuthOrganizationsApiUpdateOrganizationOperationRequest {
95
+ id: string;
96
+ updateOrganizationRequest: UpdateOrganizationRequest;
97
+ }
98
+
99
+ export interface AuthOrganizationsApiUpdateOrganizationMemberRoleOperationRequest {
100
+ id: string;
101
+ userId: string;
102
+ updateOrganizationMemberRoleRequest: UpdateOrganizationMemberRoleRequest;
103
+ }
104
+
105
+ /**
106
+ * AuthOrganizationsApi - interface
107
+ *
108
+ * @export
109
+ * @interface AuthOrganizationsApiInterface
110
+ */
111
+ export interface AuthOrganizationsApiInterface {
112
+ /**
113
+ *
114
+ * @summary Add a member to an organization
115
+ * @param {string} id
116
+ * @param {AddOrganizationMemberRequest} addOrganizationMemberRequest
117
+ * @param {*} [options] Override http request option.
118
+ * @throws {RequiredError}
119
+ * @memberof AuthOrganizationsApiInterface
120
+ */
121
+ addOrganizationMemberRaw(requestParameters: AuthOrganizationsApiAddOrganizationMemberOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<OrganizationMembershipResponse>>;
122
+
123
+ /**
124
+ * Add a member to an organization
125
+ */
126
+ addOrganizationMember(id: string, addOrganizationMemberRequest: AddOrganizationMemberRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<OrganizationMembershipResponse>;
127
+
128
+ /**
129
+ * Create a new organization inside the current application × environment. Membership is many-to-many — add end users via POST /auth/organizations/{id}/members. The Default organization for the environment is auto-created at migration time and cannot be created via API.
130
+ * @summary Create an organization
131
+ * @param {CreateOrganizationRequest} createOrganizationRequest
132
+ * @param {*} [options] Override http request option.
133
+ * @throws {RequiredError}
134
+ * @memberof AuthOrganizationsApiInterface
135
+ */
136
+ createOrganizationRaw(requestParameters: AuthOrganizationsApiCreateOrganizationOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<OrganizationResponse>>;
137
+
138
+ /**
139
+ * Create a new organization inside the current application × environment. Membership is many-to-many — add end users via POST /auth/organizations/{id}/members. The Default organization for the environment is auto-created at migration time and cannot be created via API.
140
+ * Create an organization
141
+ */
142
+ createOrganization(createOrganizationRequest: CreateOrganizationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<OrganizationResponse>;
143
+
144
+ /**
145
+ * Hard-deletes the org and cascades memberships. The Default organization cannot be deleted.
146
+ * @summary Delete an organization
147
+ * @param {string} id
148
+ * @param {*} [options] Override http request option.
149
+ * @throws {RequiredError}
150
+ * @memberof AuthOrganizationsApiInterface
151
+ */
152
+ deleteOrganizationRaw(requestParameters: AuthOrganizationsApiDeleteOrganizationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>>;
153
+
154
+ /**
155
+ * Hard-deletes the org and cascades memberships. The Default organization cannot be deleted.
156
+ * Delete an organization
157
+ */
158
+ deleteOrganization(id: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void>;
159
+
160
+ /**
161
+ *
162
+ * @summary Get organization by id
163
+ * @param {string} id
164
+ * @param {*} [options] Override http request option.
165
+ * @throws {RequiredError}
166
+ * @memberof AuthOrganizationsApiInterface
167
+ */
168
+ getOrganizationRaw(requestParameters: AuthOrganizationsApiGetOrganizationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<OrganizationResponse>>;
169
+
170
+ /**
171
+ * Get organization by id
172
+ */
173
+ getOrganization(id: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<OrganizationResponse>;
174
+
175
+ /**
176
+ *
177
+ * @summary List organization members
178
+ * @param {string} id
179
+ * @param {number} [limit]
180
+ * @param {string} [cursor]
181
+ * @param {*} [options] Override http request option.
182
+ * @throws {RequiredError}
183
+ * @memberof AuthOrganizationsApiInterface
184
+ */
185
+ listOrganizationMembersRaw(requestParameters: AuthOrganizationsApiListOrganizationMembersRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<OrganizationMembersListResponse>>;
186
+
187
+ /**
188
+ * List organization members
189
+ */
190
+ listOrganizationMembers(id: string, limit?: number, cursor?: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<OrganizationMembersListResponse>;
191
+
192
+ /**
193
+ * List organizations in the current environment. Cursor-paginated.
194
+ * @summary List organizations
195
+ * @param {number} [limit]
196
+ * @param {string} [cursor]
197
+ * @param {string} [search] ILIKE match on name OR slug
198
+ * @param {*} [options] Override http request option.
199
+ * @throws {RequiredError}
200
+ * @memberof AuthOrganizationsApiInterface
201
+ */
202
+ listOrganizationsRaw(requestParameters: AuthOrganizationsApiListOrganizationsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<OrganizationListResponse>>;
203
+
204
+ /**
205
+ * List organizations in the current environment. Cursor-paginated.
206
+ * List organizations
207
+ */
208
+ listOrganizations(limit?: number, cursor?: string, search?: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<OrganizationListResponse>;
209
+
210
+ /**
211
+ * Inverse of the membership list — returns all orgs the user is a member of within the current environment. Use this when the orgs[] JWT claim is omitted because the user belongs to more than 50.
212
+ * @summary List organizations an end user belongs to
213
+ * @param {string} userId
214
+ * @param {*} [options] Override http request option.
215
+ * @throws {RequiredError}
216
+ * @memberof AuthOrganizationsApiInterface
217
+ */
218
+ listOrganizationsForEndUserRaw(requestParameters: AuthOrganizationsApiListOrganizationsForEndUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<OrganizationListResponse>>;
219
+
220
+ /**
221
+ * Inverse of the membership list — returns all orgs the user is a member of within the current environment. Use this when the orgs[] JWT claim is omitted because the user belongs to more than 50.
222
+ * List organizations an end user belongs to
223
+ */
224
+ listOrganizationsForEndUser(userId: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<OrganizationListResponse>;
225
+
226
+ /**
227
+ *
228
+ * @summary Remove a member from an organization
229
+ * @param {string} id
230
+ * @param {string} userId
231
+ * @param {*} [options] Override http request option.
232
+ * @throws {RequiredError}
233
+ * @memberof AuthOrganizationsApiInterface
234
+ */
235
+ removeOrganizationMemberRaw(requestParameters: AuthOrganizationsApiRemoveOrganizationMemberRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>>;
236
+
237
+ /**
238
+ * Remove a member from an organization
239
+ */
240
+ removeOrganizationMember(id: string, userId: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void>;
241
+
242
+ /**
243
+ * Takes a valid refresh token + a target organization the user is a member of, verifies membership at mint time, revokes the old session, and mints a fresh access + refresh pair with `org_id` set to the target. The old refresh token is invalidated (jti rotated). Use this when the user\'s active workspace changes (the Slack/Linear workspace-switch pattern).
244
+ * @summary Switch the active organization on a session
245
+ * @param {SwitchOrganizationRequest} switchOrganizationRequest
246
+ * @param {*} [options] Override http request option.
247
+ * @throws {RequiredError}
248
+ * @memberof AuthOrganizationsApiInterface
249
+ */
250
+ switchOrganizationRaw(requestParameters: AuthOrganizationsApiSwitchOrganizationOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<SwitchOrganizationResponse>>;
251
+
252
+ /**
253
+ * Takes a valid refresh token + a target organization the user is a member of, verifies membership at mint time, revokes the old session, and mints a fresh access + refresh pair with `org_id` set to the target. The old refresh token is invalidated (jti rotated). Use this when the user\'s active workspace changes (the Slack/Linear workspace-switch pattern).
254
+ * Switch the active organization on a session
255
+ */
256
+ switchOrganization(switchOrganizationRequest: SwitchOrganizationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<SwitchOrganizationResponse>;
257
+
258
+ /**
259
+ * The Default organization cannot be renamed or have its slug/metadata changed.
260
+ * @summary Update an organization
261
+ * @param {string} id
262
+ * @param {UpdateOrganizationRequest} updateOrganizationRequest
263
+ * @param {*} [options] Override http request option.
264
+ * @throws {RequiredError}
265
+ * @memberof AuthOrganizationsApiInterface
266
+ */
267
+ updateOrganizationRaw(requestParameters: AuthOrganizationsApiUpdateOrganizationOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<OrganizationResponse>>;
268
+
269
+ /**
270
+ * The Default organization cannot be renamed or have its slug/metadata changed.
271
+ * Update an organization
272
+ */
273
+ updateOrganization(id: string, updateOrganizationRequest: UpdateOrganizationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<OrganizationResponse>;
274
+
275
+ /**
276
+ *
277
+ * @summary Update a member\'s role
278
+ * @param {string} id
279
+ * @param {string} userId
280
+ * @param {UpdateOrganizationMemberRoleRequest} updateOrganizationMemberRoleRequest
281
+ * @param {*} [options] Override http request option.
282
+ * @throws {RequiredError}
283
+ * @memberof AuthOrganizationsApiInterface
284
+ */
285
+ updateOrganizationMemberRoleRaw(requestParameters: AuthOrganizationsApiUpdateOrganizationMemberRoleOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<OrganizationMembershipResponse>>;
286
+
287
+ /**
288
+ * Update a member\'s role
289
+ */
290
+ updateOrganizationMemberRole(id: string, userId: string, updateOrganizationMemberRoleRequest: UpdateOrganizationMemberRoleRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<OrganizationMembershipResponse>;
291
+
292
+ }
293
+
294
+ /**
295
+ *
296
+ */
297
+ export class AuthOrganizationsApi extends runtime.BaseAPI implements AuthOrganizationsApiInterface {
298
+
299
+ /**
300
+ * Add a member to an organization
301
+ */
302
+ async addOrganizationMemberRaw(requestParameters: AuthOrganizationsApiAddOrganizationMemberOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<OrganizationMembershipResponse>> {
303
+ if (requestParameters['id'] == null) {
304
+ throw new runtime.RequiredError(
305
+ 'id',
306
+ 'Required parameter "id" was null or undefined when calling addOrganizationMember().'
307
+ );
308
+ }
309
+
310
+ if (requestParameters['addOrganizationMemberRequest'] == null) {
311
+ throw new runtime.RequiredError(
312
+ 'addOrganizationMemberRequest',
313
+ 'Required parameter "addOrganizationMemberRequest" was null or undefined when calling addOrganizationMember().'
314
+ );
315
+ }
316
+
317
+ const queryParameters: any = {};
318
+
319
+ const headerParameters: runtime.HTTPHeaders = {};
320
+
321
+ headerParameters['Content-Type'] = 'application/json';
322
+
323
+ if (this.configuration && this.configuration.apiKey) {
324
+ headerParameters["X-Application-Secret"] = await this.configuration.apiKey("X-Application-Secret"); // ApplicationSecret authentication
325
+ }
326
+
327
+ if (this.configuration && this.configuration.apiKey) {
328
+ headerParameters["X-Application-Key"] = await this.configuration.apiKey("X-Application-Key"); // ApplicationPublicKey authentication
329
+ }
330
+
331
+ const response = await this.request({
332
+ path: `/auth/organizations/{id}/members`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))),
333
+ method: 'POST',
334
+ headers: headerParameters,
335
+ query: queryParameters,
336
+ body: AddOrganizationMemberRequestToJSON(requestParameters['addOrganizationMemberRequest']),
337
+ }, initOverrides);
338
+
339
+ return new runtime.JSONApiResponse(response, (jsonValue) => OrganizationMembershipResponseFromJSON(jsonValue));
340
+ }
341
+
342
+ /**
343
+ * Add a member to an organization
344
+ */
345
+ async addOrganizationMember(id: string, addOrganizationMemberRequest: AddOrganizationMemberRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<OrganizationMembershipResponse> {
346
+ const response = await this.addOrganizationMemberRaw({ id: id, addOrganizationMemberRequest: addOrganizationMemberRequest }, initOverrides);
347
+ return await response.value();
348
+ }
349
+
350
+ /**
351
+ * Create a new organization inside the current application × environment. Membership is many-to-many — add end users via POST /auth/organizations/{id}/members. The Default organization for the environment is auto-created at migration time and cannot be created via API.
352
+ * Create an organization
353
+ */
354
+ async createOrganizationRaw(requestParameters: AuthOrganizationsApiCreateOrganizationOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<OrganizationResponse>> {
355
+ if (requestParameters['createOrganizationRequest'] == null) {
356
+ throw new runtime.RequiredError(
357
+ 'createOrganizationRequest',
358
+ 'Required parameter "createOrganizationRequest" was null or undefined when calling createOrganization().'
359
+ );
360
+ }
361
+
362
+ const queryParameters: any = {};
363
+
364
+ const headerParameters: runtime.HTTPHeaders = {};
365
+
366
+ headerParameters['Content-Type'] = 'application/json';
367
+
368
+ if (this.configuration && this.configuration.apiKey) {
369
+ headerParameters["X-Application-Secret"] = await this.configuration.apiKey("X-Application-Secret"); // ApplicationSecret authentication
370
+ }
371
+
372
+ if (this.configuration && this.configuration.apiKey) {
373
+ headerParameters["X-Application-Key"] = await this.configuration.apiKey("X-Application-Key"); // ApplicationPublicKey authentication
374
+ }
375
+
376
+ const response = await this.request({
377
+ path: `/auth/organizations`,
378
+ method: 'POST',
379
+ headers: headerParameters,
380
+ query: queryParameters,
381
+ body: CreateOrganizationRequestToJSON(requestParameters['createOrganizationRequest']),
382
+ }, initOverrides);
383
+
384
+ return new runtime.JSONApiResponse(response, (jsonValue) => OrganizationResponseFromJSON(jsonValue));
385
+ }
386
+
387
+ /**
388
+ * Create a new organization inside the current application × environment. Membership is many-to-many — add end users via POST /auth/organizations/{id}/members. The Default organization for the environment is auto-created at migration time and cannot be created via API.
389
+ * Create an organization
390
+ */
391
+ async createOrganization(createOrganizationRequest: CreateOrganizationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<OrganizationResponse> {
392
+ const response = await this.createOrganizationRaw({ createOrganizationRequest: createOrganizationRequest }, initOverrides);
393
+ return await response.value();
394
+ }
395
+
396
+ /**
397
+ * Hard-deletes the org and cascades memberships. The Default organization cannot be deleted.
398
+ * Delete an organization
399
+ */
400
+ async deleteOrganizationRaw(requestParameters: AuthOrganizationsApiDeleteOrganizationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
401
+ if (requestParameters['id'] == null) {
402
+ throw new runtime.RequiredError(
403
+ 'id',
404
+ 'Required parameter "id" was null or undefined when calling deleteOrganization().'
405
+ );
406
+ }
407
+
408
+ const queryParameters: any = {};
409
+
410
+ const headerParameters: runtime.HTTPHeaders = {};
411
+
412
+ if (this.configuration && this.configuration.apiKey) {
413
+ headerParameters["X-Application-Secret"] = await this.configuration.apiKey("X-Application-Secret"); // ApplicationSecret authentication
414
+ }
415
+
416
+ if (this.configuration && this.configuration.apiKey) {
417
+ headerParameters["X-Application-Key"] = await this.configuration.apiKey("X-Application-Key"); // ApplicationPublicKey authentication
418
+ }
419
+
420
+ const response = await this.request({
421
+ path: `/auth/organizations/{id}`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))),
422
+ method: 'DELETE',
423
+ headers: headerParameters,
424
+ query: queryParameters,
425
+ }, initOverrides);
426
+
427
+ return new runtime.VoidApiResponse(response);
428
+ }
429
+
430
+ /**
431
+ * Hard-deletes the org and cascades memberships. The Default organization cannot be deleted.
432
+ * Delete an organization
433
+ */
434
+ async deleteOrganization(id: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
435
+ await this.deleteOrganizationRaw({ id: id }, initOverrides);
436
+ }
437
+
438
+ /**
439
+ * Get organization by id
440
+ */
441
+ async getOrganizationRaw(requestParameters: AuthOrganizationsApiGetOrganizationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<OrganizationResponse>> {
442
+ if (requestParameters['id'] == null) {
443
+ throw new runtime.RequiredError(
444
+ 'id',
445
+ 'Required parameter "id" was null or undefined when calling getOrganization().'
446
+ );
447
+ }
448
+
449
+ const queryParameters: any = {};
450
+
451
+ const headerParameters: runtime.HTTPHeaders = {};
452
+
453
+ if (this.configuration && this.configuration.apiKey) {
454
+ headerParameters["X-Application-Secret"] = await this.configuration.apiKey("X-Application-Secret"); // ApplicationSecret authentication
455
+ }
456
+
457
+ if (this.configuration && this.configuration.apiKey) {
458
+ headerParameters["X-Application-Key"] = await this.configuration.apiKey("X-Application-Key"); // ApplicationPublicKey authentication
459
+ }
460
+
461
+ const response = await this.request({
462
+ path: `/auth/organizations/{id}`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))),
463
+ method: 'GET',
464
+ headers: headerParameters,
465
+ query: queryParameters,
466
+ }, initOverrides);
467
+
468
+ return new runtime.JSONApiResponse(response, (jsonValue) => OrganizationResponseFromJSON(jsonValue));
469
+ }
470
+
471
+ /**
472
+ * Get organization by id
473
+ */
474
+ async getOrganization(id: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<OrganizationResponse> {
475
+ const response = await this.getOrganizationRaw({ id: id }, initOverrides);
476
+ return await response.value();
477
+ }
478
+
479
+ /**
480
+ * List organization members
481
+ */
482
+ async listOrganizationMembersRaw(requestParameters: AuthOrganizationsApiListOrganizationMembersRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<OrganizationMembersListResponse>> {
483
+ if (requestParameters['id'] == null) {
484
+ throw new runtime.RequiredError(
485
+ 'id',
486
+ 'Required parameter "id" was null or undefined when calling listOrganizationMembers().'
487
+ );
488
+ }
489
+
490
+ const queryParameters: any = {};
491
+
492
+ if (requestParameters['limit'] != null) {
493
+ queryParameters['limit'] = requestParameters['limit'];
494
+ }
495
+
496
+ if (requestParameters['cursor'] != null) {
497
+ queryParameters['cursor'] = requestParameters['cursor'];
498
+ }
499
+
500
+ const headerParameters: runtime.HTTPHeaders = {};
501
+
502
+ if (this.configuration && this.configuration.apiKey) {
503
+ headerParameters["X-Application-Secret"] = await this.configuration.apiKey("X-Application-Secret"); // ApplicationSecret authentication
504
+ }
505
+
506
+ if (this.configuration && this.configuration.apiKey) {
507
+ headerParameters["X-Application-Key"] = await this.configuration.apiKey("X-Application-Key"); // ApplicationPublicKey authentication
508
+ }
509
+
510
+ const response = await this.request({
511
+ path: `/auth/organizations/{id}/members`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))),
512
+ method: 'GET',
513
+ headers: headerParameters,
514
+ query: queryParameters,
515
+ }, initOverrides);
516
+
517
+ return new runtime.JSONApiResponse(response, (jsonValue) => OrganizationMembersListResponseFromJSON(jsonValue));
518
+ }
519
+
520
+ /**
521
+ * List organization members
522
+ */
523
+ async listOrganizationMembers(id: string, limit?: number, cursor?: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<OrganizationMembersListResponse> {
524
+ const response = await this.listOrganizationMembersRaw({ id: id, limit: limit, cursor: cursor }, initOverrides);
525
+ return await response.value();
526
+ }
527
+
528
+ /**
529
+ * List organizations in the current environment. Cursor-paginated.
530
+ * List organizations
531
+ */
532
+ async listOrganizationsRaw(requestParameters: AuthOrganizationsApiListOrganizationsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<OrganizationListResponse>> {
533
+ const queryParameters: any = {};
534
+
535
+ if (requestParameters['limit'] != null) {
536
+ queryParameters['limit'] = requestParameters['limit'];
537
+ }
538
+
539
+ if (requestParameters['cursor'] != null) {
540
+ queryParameters['cursor'] = requestParameters['cursor'];
541
+ }
542
+
543
+ if (requestParameters['search'] != null) {
544
+ queryParameters['search'] = requestParameters['search'];
545
+ }
546
+
547
+ const headerParameters: runtime.HTTPHeaders = {};
548
+
549
+ if (this.configuration && this.configuration.apiKey) {
550
+ headerParameters["X-Application-Secret"] = await this.configuration.apiKey("X-Application-Secret"); // ApplicationSecret authentication
551
+ }
552
+
553
+ if (this.configuration && this.configuration.apiKey) {
554
+ headerParameters["X-Application-Key"] = await this.configuration.apiKey("X-Application-Key"); // ApplicationPublicKey authentication
555
+ }
556
+
557
+ const response = await this.request({
558
+ path: `/auth/organizations`,
559
+ method: 'GET',
560
+ headers: headerParameters,
561
+ query: queryParameters,
562
+ }, initOverrides);
563
+
564
+ return new runtime.JSONApiResponse(response, (jsonValue) => OrganizationListResponseFromJSON(jsonValue));
565
+ }
566
+
567
+ /**
568
+ * List organizations in the current environment. Cursor-paginated.
569
+ * List organizations
570
+ */
571
+ async listOrganizations(limit?: number, cursor?: string, search?: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<OrganizationListResponse> {
572
+ const response = await this.listOrganizationsRaw({ limit: limit, cursor: cursor, search: search }, initOverrides);
573
+ return await response.value();
574
+ }
575
+
576
+ /**
577
+ * Inverse of the membership list — returns all orgs the user is a member of within the current environment. Use this when the orgs[] JWT claim is omitted because the user belongs to more than 50.
578
+ * List organizations an end user belongs to
579
+ */
580
+ async listOrganizationsForEndUserRaw(requestParameters: AuthOrganizationsApiListOrganizationsForEndUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<OrganizationListResponse>> {
581
+ if (requestParameters['userId'] == null) {
582
+ throw new runtime.RequiredError(
583
+ 'userId',
584
+ 'Required parameter "userId" was null or undefined when calling listOrganizationsForEndUser().'
585
+ );
586
+ }
587
+
588
+ const queryParameters: any = {};
589
+
590
+ const headerParameters: runtime.HTTPHeaders = {};
591
+
592
+ if (this.configuration && this.configuration.apiKey) {
593
+ headerParameters["X-Application-Secret"] = await this.configuration.apiKey("X-Application-Secret"); // ApplicationSecret authentication
594
+ }
595
+
596
+ if (this.configuration && this.configuration.apiKey) {
597
+ headerParameters["X-Application-Key"] = await this.configuration.apiKey("X-Application-Key"); // ApplicationPublicKey authentication
598
+ }
599
+
600
+ const response = await this.request({
601
+ path: `/auth/end-users/{user_id}/organizations`.replace(`{${"user_id"}}`, encodeURIComponent(String(requestParameters['userId']))),
602
+ method: 'GET',
603
+ headers: headerParameters,
604
+ query: queryParameters,
605
+ }, initOverrides);
606
+
607
+ return new runtime.JSONApiResponse(response, (jsonValue) => OrganizationListResponseFromJSON(jsonValue));
608
+ }
609
+
610
+ /**
611
+ * Inverse of the membership list — returns all orgs the user is a member of within the current environment. Use this when the orgs[] JWT claim is omitted because the user belongs to more than 50.
612
+ * List organizations an end user belongs to
613
+ */
614
+ async listOrganizationsForEndUser(userId: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<OrganizationListResponse> {
615
+ const response = await this.listOrganizationsForEndUserRaw({ userId: userId }, initOverrides);
616
+ return await response.value();
617
+ }
618
+
619
+ /**
620
+ * Remove a member from an organization
621
+ */
622
+ async removeOrganizationMemberRaw(requestParameters: AuthOrganizationsApiRemoveOrganizationMemberRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
623
+ if (requestParameters['id'] == null) {
624
+ throw new runtime.RequiredError(
625
+ 'id',
626
+ 'Required parameter "id" was null or undefined when calling removeOrganizationMember().'
627
+ );
628
+ }
629
+
630
+ if (requestParameters['userId'] == null) {
631
+ throw new runtime.RequiredError(
632
+ 'userId',
633
+ 'Required parameter "userId" was null or undefined when calling removeOrganizationMember().'
634
+ );
635
+ }
636
+
637
+ const queryParameters: any = {};
638
+
639
+ const headerParameters: runtime.HTTPHeaders = {};
640
+
641
+ if (this.configuration && this.configuration.apiKey) {
642
+ headerParameters["X-Application-Secret"] = await this.configuration.apiKey("X-Application-Secret"); // ApplicationSecret authentication
643
+ }
644
+
645
+ if (this.configuration && this.configuration.apiKey) {
646
+ headerParameters["X-Application-Key"] = await this.configuration.apiKey("X-Application-Key"); // ApplicationPublicKey authentication
647
+ }
648
+
649
+ const response = await this.request({
650
+ path: `/auth/organizations/{id}/members/{user_id}`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))).replace(`{${"user_id"}}`, encodeURIComponent(String(requestParameters['userId']))),
651
+ method: 'DELETE',
652
+ headers: headerParameters,
653
+ query: queryParameters,
654
+ }, initOverrides);
655
+
656
+ return new runtime.VoidApiResponse(response);
657
+ }
658
+
659
+ /**
660
+ * Remove a member from an organization
661
+ */
662
+ async removeOrganizationMember(id: string, userId: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
663
+ await this.removeOrganizationMemberRaw({ id: id, userId: userId }, initOverrides);
664
+ }
665
+
666
+ /**
667
+ * Takes a valid refresh token + a target organization the user is a member of, verifies membership at mint time, revokes the old session, and mints a fresh access + refresh pair with `org_id` set to the target. The old refresh token is invalidated (jti rotated). Use this when the user\'s active workspace changes (the Slack/Linear workspace-switch pattern).
668
+ * Switch the active organization on a session
669
+ */
670
+ async switchOrganizationRaw(requestParameters: AuthOrganizationsApiSwitchOrganizationOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<SwitchOrganizationResponse>> {
671
+ if (requestParameters['switchOrganizationRequest'] == null) {
672
+ throw new runtime.RequiredError(
673
+ 'switchOrganizationRequest',
674
+ 'Required parameter "switchOrganizationRequest" was null or undefined when calling switchOrganization().'
675
+ );
676
+ }
677
+
678
+ const queryParameters: any = {};
679
+
680
+ const headerParameters: runtime.HTTPHeaders = {};
681
+
682
+ headerParameters['Content-Type'] = 'application/json';
683
+
684
+ if (this.configuration && this.configuration.apiKey) {
685
+ headerParameters["X-Application-Secret"] = await this.configuration.apiKey("X-Application-Secret"); // ApplicationSecret authentication
686
+ }
687
+
688
+ if (this.configuration && this.configuration.apiKey) {
689
+ headerParameters["X-Application-Key"] = await this.configuration.apiKey("X-Application-Key"); // ApplicationPublicKey authentication
690
+ }
691
+
692
+ const response = await this.request({
693
+ path: `/auth/sessions/switch-organization`,
694
+ method: 'POST',
695
+ headers: headerParameters,
696
+ query: queryParameters,
697
+ body: SwitchOrganizationRequestToJSON(requestParameters['switchOrganizationRequest']),
698
+ }, initOverrides);
699
+
700
+ return new runtime.JSONApiResponse(response, (jsonValue) => SwitchOrganizationResponseFromJSON(jsonValue));
701
+ }
702
+
703
+ /**
704
+ * Takes a valid refresh token + a target organization the user is a member of, verifies membership at mint time, revokes the old session, and mints a fresh access + refresh pair with `org_id` set to the target. The old refresh token is invalidated (jti rotated). Use this when the user\'s active workspace changes (the Slack/Linear workspace-switch pattern).
705
+ * Switch the active organization on a session
706
+ */
707
+ async switchOrganization(switchOrganizationRequest: SwitchOrganizationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<SwitchOrganizationResponse> {
708
+ const response = await this.switchOrganizationRaw({ switchOrganizationRequest: switchOrganizationRequest }, initOverrides);
709
+ return await response.value();
710
+ }
711
+
712
+ /**
713
+ * The Default organization cannot be renamed or have its slug/metadata changed.
714
+ * Update an organization
715
+ */
716
+ async updateOrganizationRaw(requestParameters: AuthOrganizationsApiUpdateOrganizationOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<OrganizationResponse>> {
717
+ if (requestParameters['id'] == null) {
718
+ throw new runtime.RequiredError(
719
+ 'id',
720
+ 'Required parameter "id" was null or undefined when calling updateOrganization().'
721
+ );
722
+ }
723
+
724
+ if (requestParameters['updateOrganizationRequest'] == null) {
725
+ throw new runtime.RequiredError(
726
+ 'updateOrganizationRequest',
727
+ 'Required parameter "updateOrganizationRequest" was null or undefined when calling updateOrganization().'
728
+ );
729
+ }
730
+
731
+ const queryParameters: any = {};
732
+
733
+ const headerParameters: runtime.HTTPHeaders = {};
734
+
735
+ headerParameters['Content-Type'] = 'application/json';
736
+
737
+ if (this.configuration && this.configuration.apiKey) {
738
+ headerParameters["X-Application-Secret"] = await this.configuration.apiKey("X-Application-Secret"); // ApplicationSecret authentication
739
+ }
740
+
741
+ if (this.configuration && this.configuration.apiKey) {
742
+ headerParameters["X-Application-Key"] = await this.configuration.apiKey("X-Application-Key"); // ApplicationPublicKey authentication
743
+ }
744
+
745
+ const response = await this.request({
746
+ path: `/auth/organizations/{id}`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))),
747
+ method: 'PATCH',
748
+ headers: headerParameters,
749
+ query: queryParameters,
750
+ body: UpdateOrganizationRequestToJSON(requestParameters['updateOrganizationRequest']),
751
+ }, initOverrides);
752
+
753
+ return new runtime.JSONApiResponse(response, (jsonValue) => OrganizationResponseFromJSON(jsonValue));
754
+ }
755
+
756
+ /**
757
+ * The Default organization cannot be renamed or have its slug/metadata changed.
758
+ * Update an organization
759
+ */
760
+ async updateOrganization(id: string, updateOrganizationRequest: UpdateOrganizationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<OrganizationResponse> {
761
+ const response = await this.updateOrganizationRaw({ id: id, updateOrganizationRequest: updateOrganizationRequest }, initOverrides);
762
+ return await response.value();
763
+ }
764
+
765
+ /**
766
+ * Update a member\'s role
767
+ */
768
+ async updateOrganizationMemberRoleRaw(requestParameters: AuthOrganizationsApiUpdateOrganizationMemberRoleOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<OrganizationMembershipResponse>> {
769
+ if (requestParameters['id'] == null) {
770
+ throw new runtime.RequiredError(
771
+ 'id',
772
+ 'Required parameter "id" was null or undefined when calling updateOrganizationMemberRole().'
773
+ );
774
+ }
775
+
776
+ if (requestParameters['userId'] == null) {
777
+ throw new runtime.RequiredError(
778
+ 'userId',
779
+ 'Required parameter "userId" was null or undefined when calling updateOrganizationMemberRole().'
780
+ );
781
+ }
782
+
783
+ if (requestParameters['updateOrganizationMemberRoleRequest'] == null) {
784
+ throw new runtime.RequiredError(
785
+ 'updateOrganizationMemberRoleRequest',
786
+ 'Required parameter "updateOrganizationMemberRoleRequest" was null or undefined when calling updateOrganizationMemberRole().'
787
+ );
788
+ }
789
+
790
+ const queryParameters: any = {};
791
+
792
+ const headerParameters: runtime.HTTPHeaders = {};
793
+
794
+ headerParameters['Content-Type'] = 'application/json';
795
+
796
+ if (this.configuration && this.configuration.apiKey) {
797
+ headerParameters["X-Application-Secret"] = await this.configuration.apiKey("X-Application-Secret"); // ApplicationSecret authentication
798
+ }
799
+
800
+ if (this.configuration && this.configuration.apiKey) {
801
+ headerParameters["X-Application-Key"] = await this.configuration.apiKey("X-Application-Key"); // ApplicationPublicKey authentication
802
+ }
803
+
804
+ const response = await this.request({
805
+ path: `/auth/organizations/{id}/members/{user_id}`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))).replace(`{${"user_id"}}`, encodeURIComponent(String(requestParameters['userId']))),
806
+ method: 'PATCH',
807
+ headers: headerParameters,
808
+ query: queryParameters,
809
+ body: UpdateOrganizationMemberRoleRequestToJSON(requestParameters['updateOrganizationMemberRoleRequest']),
810
+ }, initOverrides);
811
+
812
+ return new runtime.JSONApiResponse(response, (jsonValue) => OrganizationMembershipResponseFromJSON(jsonValue));
813
+ }
814
+
815
+ /**
816
+ * Update a member\'s role
817
+ */
818
+ async updateOrganizationMemberRole(id: string, userId: string, updateOrganizationMemberRoleRequest: UpdateOrganizationMemberRoleRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<OrganizationMembershipResponse> {
819
+ const response = await this.updateOrganizationMemberRoleRaw({ id: id, userId: userId, updateOrganizationMemberRoleRequest: updateOrganizationMemberRoleRequest }, initOverrides);
820
+ return await response.value();
821
+ }
822
+
823
+ }