@smartcrab/management-client 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/dist/client.d.ts +176 -0
- package/dist/client.js +230 -0
- package/dist/client.test.d.ts +1 -0
- package/dist/client.test.js +1026 -0
- package/dist/errors.d.ts +44 -0
- package/dist/errors.js +6 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +7 -0
- package/dist/paginate.d.ts +40 -0
- package/dist/paginate.js +54 -0
- package/dist/paginate.test.d.ts +1 -0
- package/dist/paginate.test.js +113 -0
- package/dist/result.d.ts +28 -0
- package/dist/result.js +4 -0
- package/dist/transport.d.ts +81 -0
- package/dist/transport.js +144 -0
- package/package.json +41 -0
- package/src/client.test.ts +1114 -0
- package/src/client.ts +934 -0
- package/src/errors.ts +53 -0
- package/src/index.ts +59 -0
- package/src/paginate.test.ts +123 -0
- package/src/paginate.ts +75 -0
- package/src/result.ts +28 -0
- package/src/transport.ts +294 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import * as cm from "@smartcrab/contracts-management";
|
|
2
|
+
import type { ManagementClientError } from "./errors.js";
|
|
3
|
+
import type { Result, ResultAsync } from "./result.js";
|
|
4
|
+
import type { InputOf, ManagementResponse } from "./transport.js";
|
|
5
|
+
/**
|
|
6
|
+
* Typed client for the Management API (design.md §26).
|
|
7
|
+
*
|
|
8
|
+
* - one method per design.md §26.2 route
|
|
9
|
+
* - `Authorization: Bearer <key>` on every request (the key is never logged)
|
|
10
|
+
* - `Idempotency-Key` generated per write, caller-overridable (§26.3)
|
|
11
|
+
* - `If-Match` honored on conditional updates/deletes (§26.3)
|
|
12
|
+
* - response bodies validated with the `@smartcrab/contracts-management`
|
|
13
|
+
* zod schemas (`safeParse` — never trust the wire)
|
|
14
|
+
* - `x-request-id` (and `etag`) surfaced on every result for support correlation
|
|
15
|
+
*/
|
|
16
|
+
export interface ManagementClientOptions {
|
|
17
|
+
/** API root, e.g. `https://api.example-auth.com/v1` (design.md §26). */
|
|
18
|
+
readonly baseUrl: string;
|
|
19
|
+
/** `sk_live_...` / `sk_test_...` Management API key (design.md §26.1). */
|
|
20
|
+
readonly apiKey: string;
|
|
21
|
+
/** Injectable fetch implementation (defaults to the global `fetch`). */
|
|
22
|
+
readonly fetch?: typeof fetch;
|
|
23
|
+
}
|
|
24
|
+
export interface PaginationParams {
|
|
25
|
+
readonly cursor?: string;
|
|
26
|
+
/** Max 100 (design.md §26.3); the server default applies when omitted. */
|
|
27
|
+
readonly limit?: number;
|
|
28
|
+
}
|
|
29
|
+
export interface WriteOptions {
|
|
30
|
+
/** Caller override for the `Idempotency-Key` header; a UUID is generated when omitted. */
|
|
31
|
+
readonly idempotencyKey?: string;
|
|
32
|
+
/** Entity tag from a prior response (`ManagementResponse.etag`) sent as `If-Match`. */
|
|
33
|
+
readonly ifMatch?: string;
|
|
34
|
+
}
|
|
35
|
+
export interface WorkspaceListParams extends PaginationParams {
|
|
36
|
+
readonly status?: cm.WorkspaceStatus;
|
|
37
|
+
}
|
|
38
|
+
export type WorkspaceMemberListParams = PaginationParams;
|
|
39
|
+
export interface ProjectListParams extends PaginationParams {
|
|
40
|
+
readonly workspace_id: string;
|
|
41
|
+
}
|
|
42
|
+
export interface EnvironmentListParams extends PaginationParams {
|
|
43
|
+
readonly project_id: string;
|
|
44
|
+
readonly type?: cm.EnvironmentType;
|
|
45
|
+
}
|
|
46
|
+
export interface ClientListParams extends PaginationParams {
|
|
47
|
+
readonly environment_id: string;
|
|
48
|
+
readonly client_type?: cm.ClientType;
|
|
49
|
+
}
|
|
50
|
+
export interface ConnectionListParams extends PaginationParams {
|
|
51
|
+
readonly environment_id: string;
|
|
52
|
+
readonly provider?: cm.Connection["provider"];
|
|
53
|
+
}
|
|
54
|
+
export interface DomainListParams extends PaginationParams {
|
|
55
|
+
readonly environment_id: string;
|
|
56
|
+
readonly status?: cm.CustomDomainStatus;
|
|
57
|
+
}
|
|
58
|
+
export interface UserListParams extends PaginationParams {
|
|
59
|
+
readonly environment_id: string;
|
|
60
|
+
readonly status?: cm.UserStatus;
|
|
61
|
+
readonly search?: string;
|
|
62
|
+
}
|
|
63
|
+
export interface WebhookListParams extends PaginationParams {
|
|
64
|
+
readonly environment_id: string;
|
|
65
|
+
}
|
|
66
|
+
export interface WebhookDeliveryListParams extends PaginationParams {
|
|
67
|
+
readonly status?: cm.WebhookDeliveryStatus;
|
|
68
|
+
readonly occurred_after?: string;
|
|
69
|
+
readonly occurred_before?: string;
|
|
70
|
+
}
|
|
71
|
+
export interface AuditEventListParams extends PaginationParams {
|
|
72
|
+
readonly environment_id: string;
|
|
73
|
+
readonly actor_type?: cm.AuditActorType;
|
|
74
|
+
readonly action?: string;
|
|
75
|
+
readonly subject_type?: string;
|
|
76
|
+
readonly subject_id?: string;
|
|
77
|
+
readonly result?: cm.AuditResult;
|
|
78
|
+
readonly created_after?: string;
|
|
79
|
+
readonly created_before?: string;
|
|
80
|
+
}
|
|
81
|
+
export interface MauUsageParams {
|
|
82
|
+
readonly billing_month?: string;
|
|
83
|
+
readonly environment_id?: string;
|
|
84
|
+
}
|
|
85
|
+
export type WorkspaceCreateInput = InputOf<typeof cm.workspaceCreateRequestSchema>;
|
|
86
|
+
export type WorkspaceUpdateInput = InputOf<typeof cm.workspaceUpdateRequestSchema>;
|
|
87
|
+
export type ProjectCreateInput = InputOf<typeof cm.projectCreateRequestSchema>;
|
|
88
|
+
export type ProjectUpdateInput = InputOf<typeof cm.projectUpdateRequestSchema>;
|
|
89
|
+
export type EnvironmentCreateInput = InputOf<typeof cm.environmentCreateRequestSchema>;
|
|
90
|
+
export type EnvironmentUpdateInput = InputOf<typeof cm.environmentUpdateRequestSchema>;
|
|
91
|
+
export type RpMigrationDisableInput = InputOf<typeof cm.rpMigrationDisableLegacyRequestSchema>;
|
|
92
|
+
export type RpMigration = cm.RpMigrationResponse;
|
|
93
|
+
export type ClientCreateInput = InputOf<typeof cm.clientCreateRequestSchema>;
|
|
94
|
+
export type ClientUpdateInput = InputOf<typeof cm.clientUpdateRequestSchema>;
|
|
95
|
+
export type ConnectionCreateInput = InputOf<typeof cm.connectionCreateRequestSchema>;
|
|
96
|
+
export type ConnectionUpdateInput = InputOf<typeof cm.connectionUpdateRequestSchema>;
|
|
97
|
+
export type DomainCreateInput = InputOf<typeof cm.domainCreateRequestSchema>;
|
|
98
|
+
export type DomainUpdateInput = InputOf<typeof cm.domainUpdateRequestSchema>;
|
|
99
|
+
export type UserCreateInput = InputOf<typeof cm.userCreateRequestSchema>;
|
|
100
|
+
export type UserUpdateInput = InputOf<typeof cm.userUpdateRequestSchema>;
|
|
101
|
+
export type UserBlockInput = InputOf<typeof cm.userBlockRequestSchema>;
|
|
102
|
+
export type UserImportJobCreateInput = InputOf<typeof cm.userImportJobCreateRequestSchema>;
|
|
103
|
+
export type UserExportJobCreateInput = InputOf<typeof cm.userExportJobCreateRequestSchema>;
|
|
104
|
+
export type WebhookCreateInput = InputOf<typeof cm.webhookCreateRequestSchema>;
|
|
105
|
+
export type WebhookUpdateInput = InputOf<typeof cm.webhookUpdateRequestSchema>;
|
|
106
|
+
export type WebhookTestInput = InputOf<typeof cm.webhookTestRequestSchema>;
|
|
107
|
+
export type BillingCheckoutSessionCreateInput = InputOf<typeof cm.billingCheckoutSessionCreateRequestSchema>;
|
|
108
|
+
export type BillingPortalSessionCreateInput = InputOf<typeof cm.billingPortalSessionCreateRequestSchema>;
|
|
109
|
+
type Api<T> = ResultAsync<ManagementResponse<T>, ManagementClientError>;
|
|
110
|
+
export interface ManagementClient {
|
|
111
|
+
listWorkspaces(params?: WorkspaceListParams): Api<cm.WorkspaceListResponse>;
|
|
112
|
+
listWorkspaceMembers(workspaceId: string, params?: WorkspaceMemberListParams): Api<cm.WorkspaceMemberListResponse>;
|
|
113
|
+
createWorkspace(body: WorkspaceCreateInput, options?: WriteOptions): Api<cm.Workspace>;
|
|
114
|
+
getWorkspace(workspaceId: string): Api<cm.Workspace>;
|
|
115
|
+
updateWorkspace(workspaceId: string, body: WorkspaceUpdateInput, options?: WriteOptions): Api<cm.Workspace>;
|
|
116
|
+
listProjects(params: ProjectListParams): Api<cm.ProjectListResponse>;
|
|
117
|
+
createProject(body: ProjectCreateInput, options?: WriteOptions): Api<cm.Project>;
|
|
118
|
+
getProject(projectId: string): Api<cm.Project>;
|
|
119
|
+
updateProject(projectId: string, body: ProjectUpdateInput, options?: WriteOptions): Api<cm.Project>;
|
|
120
|
+
deleteProject(projectId: string, options?: WriteOptions): Api<cm.ProjectDeleteResponse>;
|
|
121
|
+
listEnvironments(params: EnvironmentListParams): Api<cm.EnvironmentListResponse>;
|
|
122
|
+
createEnvironment(body: EnvironmentCreateInput, options?: WriteOptions): Api<cm.Environment>;
|
|
123
|
+
getEnvironment(environmentId: string): Api<cm.Environment>;
|
|
124
|
+
updateEnvironment(environmentId: string, body: EnvironmentUpdateInput, options?: WriteOptions): Api<cm.Environment>;
|
|
125
|
+
deleteEnvironment(environmentId: string, options?: WriteOptions): Api<cm.EnvironmentDeleteResponse>;
|
|
126
|
+
getRpMigration(environmentId: string): Api<RpMigration>;
|
|
127
|
+
disableLegacyRp(environmentId: string, body: RpMigrationDisableInput, options?: WriteOptions): Api<RpMigration>;
|
|
128
|
+
listClients(params: ClientListParams): Api<cm.ClientListResponse>;
|
|
129
|
+
createClient(body: ClientCreateInput, options?: WriteOptions): Api<cm.ClientCreateResponse>;
|
|
130
|
+
getClient(clientId: string): Api<cm.Client>;
|
|
131
|
+
updateClient(clientId: string, body: ClientUpdateInput, options?: WriteOptions): Api<cm.Client>;
|
|
132
|
+
deleteClient(clientId: string, options?: WriteOptions): Api<cm.ClientDeleteResponse>;
|
|
133
|
+
rotateClientSecret(clientId: string, options?: WriteOptions): Api<cm.ClientRotateSecretResponse>;
|
|
134
|
+
listConnections(params: ConnectionListParams): Api<cm.ConnectionListResponse>;
|
|
135
|
+
createConnection(body: ConnectionCreateInput, options?: WriteOptions): Api<cm.Connection>;
|
|
136
|
+
updateConnection(connectionId: string, body: ConnectionUpdateInput, options?: WriteOptions): Api<cm.Connection>;
|
|
137
|
+
deleteConnection(connectionId: string, options?: WriteOptions): Api<cm.ConnectionDeleteResponse>;
|
|
138
|
+
listDomains(params: DomainListParams): Api<cm.DomainListResponse>;
|
|
139
|
+
createDomain(body: DomainCreateInput, options?: WriteOptions): Api<cm.Domain>;
|
|
140
|
+
getDomain(domainId: string): Api<cm.Domain>;
|
|
141
|
+
updateDomain(domainId: string, body: DomainUpdateInput, options?: WriteOptions): Api<cm.Domain>;
|
|
142
|
+
deleteDomain(domainId: string, options?: WriteOptions): Api<cm.DomainDeleteResponse>;
|
|
143
|
+
retryDomainValidation(domainId: string, options?: WriteOptions): Api<cm.Domain>;
|
|
144
|
+
listUsers(params: UserListParams): Api<cm.UserListResponse>;
|
|
145
|
+
createUser(body: UserCreateInput, options?: WriteOptions): Api<cm.User>;
|
|
146
|
+
getUser(environmentId: string, userId: string): Api<cm.User>;
|
|
147
|
+
updateUser(environmentId: string, userId: string, body: UserUpdateInput, options?: WriteOptions): Api<cm.User>;
|
|
148
|
+
deleteUser(environmentId: string, userId: string, options?: WriteOptions): Api<cm.UserDeleteResponse>;
|
|
149
|
+
blockUser(environmentId: string, userId: string, body?: UserBlockInput, options?: WriteOptions): Api<cm.UserBlockResponse>;
|
|
150
|
+
unblockUser(environmentId: string, userId: string, options?: WriteOptions): Api<cm.UserUnblockResponse>;
|
|
151
|
+
listUserIdentities(environmentId: string, userId: string, params?: PaginationParams): Api<cm.UserIdentityListResponse>;
|
|
152
|
+
deleteUserIdentity(environmentId: string, userId: string, identityId: string, options?: WriteOptions): Api<cm.UserIdentityDeleteResponse>;
|
|
153
|
+
listUserPasskeys(environmentId: string, userId: string, params?: PaginationParams): Api<cm.UserPasskeyListResponse>;
|
|
154
|
+
deleteUserPasskey(environmentId: string, userId: string, passkeyId: string, options?: WriteOptions): Api<cm.UserPasskeyDeleteResponse>;
|
|
155
|
+
listUserSessions(environmentId: string, userId: string, params?: PaginationParams): Api<cm.UserSessionListResponse>;
|
|
156
|
+
revokeUserSession(environmentId: string, userId: string, sessionId: string, options?: WriteOptions): Api<cm.UserSessionRevokeResponse>;
|
|
157
|
+
revokeAllUserSessions(environmentId: string, userId: string, options?: WriteOptions): Api<cm.UserSessionsRevokeAllResponse>;
|
|
158
|
+
createUserImportJob(body: UserImportJobCreateInput, options?: WriteOptions): Api<cm.UserImportJob>;
|
|
159
|
+
getUserImportJob(jobId: string): Api<cm.UserImportJob>;
|
|
160
|
+
createUserExportJob(body: UserExportJobCreateInput, options?: WriteOptions): Api<cm.UserExportJob>;
|
|
161
|
+
getUserExportJob(jobId: string): Api<cm.UserExportJob>;
|
|
162
|
+
listWebhooks(params: WebhookListParams): Api<cm.WebhookListResponse>;
|
|
163
|
+
listWebhookDeliveries(webhookId: string, params?: WebhookDeliveryListParams): Api<cm.WebhookDeliveryListResponse>;
|
|
164
|
+
createWebhook(body: WebhookCreateInput, options?: WriteOptions): Api<cm.WebhookCreateResponse>;
|
|
165
|
+
updateWebhook(webhookId: string, body: WebhookUpdateInput, options?: WriteOptions): Api<cm.Webhook>;
|
|
166
|
+
deleteWebhook(webhookId: string, options?: WriteOptions): Api<cm.WebhookDeleteResponse>;
|
|
167
|
+
rotateWebhookSecret(webhookId: string, options?: WriteOptions): Api<cm.WebhookRotateSecretResponse>;
|
|
168
|
+
testWebhook(webhookId: string, body?: WebhookTestInput, options?: WriteOptions): Api<cm.WebhookTestResponse>;
|
|
169
|
+
listAuditEvents(params: AuditEventListParams): Api<cm.AuditEventListResponse>;
|
|
170
|
+
getMauUsage(params?: MauUsageParams): Api<cm.MauUsageResponse>;
|
|
171
|
+
createBillingCheckoutSession(body: BillingCheckoutSessionCreateInput, options?: WriteOptions): Api<cm.BillingCheckoutSessionCreateResponse>;
|
|
172
|
+
createBillingPortalSession(body: BillingPortalSessionCreateInput, options?: WriteOptions): Api<cm.BillingPortalSessionCreateResponse>;
|
|
173
|
+
}
|
|
174
|
+
export declare const createManagementClient: (options: ManagementClientOptions) => ManagementClient;
|
|
175
|
+
export { isFailure, isSuccess } from "./result.js";
|
|
176
|
+
export type { Result };
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import * as cm from "@smartcrab/contracts-management";
|
|
2
|
+
import { fail } from "./result.js";
|
|
3
|
+
import { formatIssues, invalidRequest, send } from "./transport.js";
|
|
4
|
+
// ---------------------------------------------------------------------------
|
|
5
|
+
// Implementation
|
|
6
|
+
// ---------------------------------------------------------------------------
|
|
7
|
+
/** Normalizes and validates the API root. Throws `TypeError` on programmer misconfiguration. */
|
|
8
|
+
const normalizeBaseUrl = (raw) => {
|
|
9
|
+
const trimmed = raw.trim().replace(/\/+$/, "");
|
|
10
|
+
if (!URL.canParse(trimmed)) {
|
|
11
|
+
throw new TypeError(`management-client: invalid baseUrl ${JSON.stringify(raw)}`);
|
|
12
|
+
}
|
|
13
|
+
const protocol = new URL(trimmed).protocol;
|
|
14
|
+
if (protocol !== "https:" && protocol !== "http:") {
|
|
15
|
+
throw new TypeError(`management-client: baseUrl must be http(s), got protocol ${protocol}`);
|
|
16
|
+
}
|
|
17
|
+
return trimmed;
|
|
18
|
+
};
|
|
19
|
+
const newIdempotencyKey = () => crypto.randomUUID();
|
|
20
|
+
const segment = (id) => encodeURIComponent(id);
|
|
21
|
+
const getSpec = (path, query) => ({
|
|
22
|
+
method: "GET",
|
|
23
|
+
path,
|
|
24
|
+
...(query !== undefined ? { query } : {}),
|
|
25
|
+
});
|
|
26
|
+
export const createManagementClient = (options) => {
|
|
27
|
+
const baseUrl = normalizeBaseUrl(options.baseUrl);
|
|
28
|
+
if (options.apiKey.length === 0) {
|
|
29
|
+
throw new TypeError("management-client: apiKey must not be empty");
|
|
30
|
+
}
|
|
31
|
+
const config = { baseUrl, apiKey: options.apiKey, fetchFn: options.fetch ?? fetch };
|
|
32
|
+
const writeSpec = (method, path, body, writeOptions, query) => ({
|
|
33
|
+
method,
|
|
34
|
+
path,
|
|
35
|
+
...(query !== undefined ? { query } : {}),
|
|
36
|
+
...(body !== undefined ? { body } : {}),
|
|
37
|
+
idempotencyKey: writeOptions?.idempotencyKey ?? newIdempotencyKey(),
|
|
38
|
+
...(writeOptions?.ifMatch !== undefined ? { ifMatch: writeOptions.ifMatch } : {}),
|
|
39
|
+
});
|
|
40
|
+
/** Validates a request body against its contract schema before anything hits the wire. */
|
|
41
|
+
const withValidBody = (schema, body, then) => {
|
|
42
|
+
const parsed = schema.safeParse(body);
|
|
43
|
+
if (!parsed.success) {
|
|
44
|
+
return Promise.resolve(fail(invalidRequest(formatIssues(parsed.error))));
|
|
45
|
+
}
|
|
46
|
+
return then(parsed.data);
|
|
47
|
+
};
|
|
48
|
+
return {
|
|
49
|
+
// --------------------------------------------------------------
|
|
50
|
+
// Workspaces
|
|
51
|
+
// --------------------------------------------------------------
|
|
52
|
+
listWorkspaces: (params) => send(config, getSpec("/workspaces", {
|
|
53
|
+
cursor: params?.cursor,
|
|
54
|
+
limit: params?.limit,
|
|
55
|
+
status: params?.status,
|
|
56
|
+
}), cm.workspaceListResponseSchema),
|
|
57
|
+
listWorkspaceMembers: (workspaceId, params) => send(config, getSpec(`/workspaces/${segment(workspaceId)}/members`, {
|
|
58
|
+
cursor: params?.cursor,
|
|
59
|
+
limit: params?.limit,
|
|
60
|
+
}), cm.workspaceMemberListResponseSchema),
|
|
61
|
+
createWorkspace: (body, writeOptions) => withValidBody(cm.workspaceCreateRequestSchema, body, (valid) => send(config, writeSpec("POST", "/workspaces", valid, writeOptions), cm.workspaceCreateResponseSchema)),
|
|
62
|
+
getWorkspace: (workspaceId) => send(config, getSpec(`/workspaces/${segment(workspaceId)}`), cm.workspaceGetResponseSchema),
|
|
63
|
+
updateWorkspace: (workspaceId, body, writeOptions) => withValidBody(cm.workspaceUpdateRequestSchema, body, (valid) => send(config, writeSpec("PATCH", `/workspaces/${segment(workspaceId)}`, valid, writeOptions), cm.workspaceUpdateResponseSchema)),
|
|
64
|
+
// --------------------------------------------------------------
|
|
65
|
+
// Projects
|
|
66
|
+
// --------------------------------------------------------------
|
|
67
|
+
listProjects: (params) => send(config, getSpec("/projects", {
|
|
68
|
+
cursor: params.cursor,
|
|
69
|
+
limit: params.limit,
|
|
70
|
+
workspace_id: params.workspace_id,
|
|
71
|
+
}), cm.projectListResponseSchema),
|
|
72
|
+
createProject: (body, writeOptions) => withValidBody(cm.projectCreateRequestSchema, body, (valid) => send(config, writeSpec("POST", "/projects", valid, writeOptions), cm.projectCreateResponseSchema)),
|
|
73
|
+
getProject: (projectId) => send(config, getSpec(`/projects/${segment(projectId)}`), cm.projectGetResponseSchema),
|
|
74
|
+
updateProject: (projectId, body, writeOptions) => withValidBody(cm.projectUpdateRequestSchema, body, (valid) => send(config, writeSpec("PATCH", `/projects/${segment(projectId)}`, valid, writeOptions), cm.projectUpdateResponseSchema)),
|
|
75
|
+
deleteProject: (projectId, writeOptions) => send(config, writeSpec("DELETE", `/projects/${segment(projectId)}`, undefined, writeOptions), cm.projectDeleteResponseSchema),
|
|
76
|
+
// --------------------------------------------------------------
|
|
77
|
+
// Environments
|
|
78
|
+
// --------------------------------------------------------------
|
|
79
|
+
listEnvironments: (params) => send(config, getSpec("/environments", {
|
|
80
|
+
cursor: params.cursor,
|
|
81
|
+
limit: params.limit,
|
|
82
|
+
project_id: params.project_id,
|
|
83
|
+
type: params.type,
|
|
84
|
+
}), cm.environmentListResponseSchema),
|
|
85
|
+
createEnvironment: (body, writeOptions) => withValidBody(cm.environmentCreateRequestSchema, body, (valid) => send(config, writeSpec("POST", "/environments", valid, writeOptions), cm.environmentCreateResponseSchema)),
|
|
86
|
+
getEnvironment: (environmentId) => send(config, getSpec(`/environments/${segment(environmentId)}`), cm.environmentGetResponseSchema),
|
|
87
|
+
updateEnvironment: (environmentId, body, writeOptions) => withValidBody(cm.environmentUpdateRequestSchema, body, (valid) => send(config, writeSpec("PATCH", `/environments/${segment(environmentId)}`, valid, writeOptions), cm.environmentUpdateResponseSchema)),
|
|
88
|
+
deleteEnvironment: (environmentId, writeOptions) => send(config, writeSpec("DELETE", `/environments/${segment(environmentId)}`, undefined, writeOptions), cm.environmentDeleteResponseSchema),
|
|
89
|
+
getRpMigration: (environmentId) => send(config, getSpec(`/environments/${segment(environmentId)}/rp-migration`), cm.rpMigrationResponseSchema),
|
|
90
|
+
disableLegacyRp: (environmentId, body, writeOptions) => withValidBody(cm.rpMigrationDisableLegacyRequestSchema, body, (valid) => send(config, writeSpec("POST", `/environments/${segment(environmentId)}/rp-migration/disable-legacy`, valid, writeOptions), cm.rpMigrationResponseSchema)),
|
|
91
|
+
// --------------------------------------------------------------
|
|
92
|
+
// Clients
|
|
93
|
+
// --------------------------------------------------------------
|
|
94
|
+
listClients: (params) => send(config, getSpec("/clients", {
|
|
95
|
+
cursor: params.cursor,
|
|
96
|
+
limit: params.limit,
|
|
97
|
+
environment_id: params.environment_id,
|
|
98
|
+
client_type: params.client_type,
|
|
99
|
+
}), cm.clientListResponseSchema),
|
|
100
|
+
createClient: (body, writeOptions) => withValidBody(cm.clientCreateRequestSchema, body, (valid) => send(config, writeSpec("POST", "/clients", valid, writeOptions), cm.clientCreateResponseSchema)),
|
|
101
|
+
getClient: (clientId) => send(config, getSpec(`/clients/${segment(clientId)}`), cm.clientGetResponseSchema),
|
|
102
|
+
updateClient: (clientId, body, writeOptions) => withValidBody(cm.clientUpdateRequestSchema, body, (valid) => send(config, writeSpec("PATCH", `/clients/${segment(clientId)}`, valid, writeOptions), cm.clientUpdateResponseSchema)),
|
|
103
|
+
deleteClient: (clientId, writeOptions) => send(config, writeSpec("DELETE", `/clients/${segment(clientId)}`, undefined, writeOptions), cm.clientDeleteResponseSchema),
|
|
104
|
+
rotateClientSecret: (clientId, writeOptions) => send(config, writeSpec("POST", `/clients/${segment(clientId)}/rotate-secret`, {}, writeOptions), cm.clientRotateSecretResponseSchema),
|
|
105
|
+
// --------------------------------------------------------------
|
|
106
|
+
// Connections
|
|
107
|
+
// --------------------------------------------------------------
|
|
108
|
+
listConnections: (params) => send(config, getSpec("/connections", {
|
|
109
|
+
cursor: params.cursor,
|
|
110
|
+
limit: params.limit,
|
|
111
|
+
environment_id: params.environment_id,
|
|
112
|
+
provider: params.provider,
|
|
113
|
+
}), cm.connectionListResponseSchema),
|
|
114
|
+
createConnection: (body, writeOptions) => withValidBody(cm.connectionCreateRequestSchema, body, (valid) => send(config, writeSpec("POST", "/connections", valid, writeOptions), cm.connectionCreateResponseSchema)),
|
|
115
|
+
updateConnection: (connectionId, body, writeOptions) => withValidBody(cm.connectionUpdateRequestSchema, body, (valid) => send(config, writeSpec("PATCH", `/connections/${segment(connectionId)}`, valid, writeOptions), cm.connectionUpdateResponseSchema)),
|
|
116
|
+
deleteConnection: (connectionId, writeOptions) => send(config, writeSpec("DELETE", `/connections/${segment(connectionId)}`, undefined, writeOptions), cm.connectionDeleteResponseSchema),
|
|
117
|
+
// --------------------------------------------------------------
|
|
118
|
+
// Domains
|
|
119
|
+
// --------------------------------------------------------------
|
|
120
|
+
listDomains: (params) => send(config, getSpec("/domains", {
|
|
121
|
+
cursor: params.cursor,
|
|
122
|
+
limit: params.limit,
|
|
123
|
+
environment_id: params.environment_id,
|
|
124
|
+
status: params.status,
|
|
125
|
+
}), cm.domainListResponseSchema),
|
|
126
|
+
createDomain: (body, writeOptions) => withValidBody(cm.domainCreateRequestSchema, body, (valid) => send(config, writeSpec("POST", "/domains", valid, writeOptions), cm.domainCreateResponseSchema)),
|
|
127
|
+
getDomain: (domainId) => send(config, getSpec(`/domains/${segment(domainId)}`), cm.domainGetResponseSchema),
|
|
128
|
+
updateDomain: (domainId, body, writeOptions) => withValidBody(cm.domainUpdateRequestSchema, body, (valid) => send(config, writeSpec("PATCH", `/domains/${segment(domainId)}`, valid, writeOptions), cm.domainUpdateResponseSchema)),
|
|
129
|
+
deleteDomain: (domainId, writeOptions) => send(config, writeSpec("DELETE", `/domains/${segment(domainId)}`, undefined, writeOptions), cm.domainDeleteResponseSchema),
|
|
130
|
+
retryDomainValidation: (domainId, writeOptions) => send(config, writeSpec("POST", `/domains/${segment(domainId)}/retry-validation`, {}, writeOptions), cm.domainRetryValidationResponseSchema),
|
|
131
|
+
// --------------------------------------------------------------
|
|
132
|
+
// Users
|
|
133
|
+
// --------------------------------------------------------------
|
|
134
|
+
listUsers: (params) => send(config, getSpec("/users", {
|
|
135
|
+
cursor: params.cursor,
|
|
136
|
+
limit: params.limit,
|
|
137
|
+
environment_id: params.environment_id,
|
|
138
|
+
status: params.status,
|
|
139
|
+
search: params.search,
|
|
140
|
+
}), cm.userListResponseSchema),
|
|
141
|
+
createUser: (body, writeOptions) => withValidBody(cm.userCreateRequestSchema, body, (valid) => send(config, writeSpec("POST", "/users", valid, writeOptions), cm.userCreateResponseSchema)),
|
|
142
|
+
getUser: (environmentId, userId) => send(config, getSpec(`/users/${segment(userId)}`, { environment_id: environmentId }), cm.userGetResponseSchema),
|
|
143
|
+
updateUser: (environmentId, userId, body, writeOptions) => withValidBody(cm.userUpdateRequestSchema, body, (valid) => send(config, writeSpec("PATCH", `/users/${segment(userId)}`, valid, writeOptions, {
|
|
144
|
+
environment_id: environmentId,
|
|
145
|
+
}), cm.userUpdateResponseSchema)),
|
|
146
|
+
deleteUser: (environmentId, userId, writeOptions) => send(config, writeSpec("DELETE", `/users/${segment(userId)}`, undefined, writeOptions, {
|
|
147
|
+
environment_id: environmentId,
|
|
148
|
+
}), cm.userDeleteResponseSchema),
|
|
149
|
+
blockUser: (environmentId, userId, body, writeOptions) => withValidBody(cm.userBlockRequestSchema, body ?? {}, (valid) => send(config, writeSpec("POST", `/users/${segment(userId)}/block`, valid, writeOptions, {
|
|
150
|
+
environment_id: environmentId,
|
|
151
|
+
}), cm.userBlockResponseSchema)),
|
|
152
|
+
unblockUser: (environmentId, userId, writeOptions) => send(config, writeSpec("POST", `/users/${segment(userId)}/unblock`, {}, writeOptions, {
|
|
153
|
+
environment_id: environmentId,
|
|
154
|
+
}), cm.userUnblockResponseSchema),
|
|
155
|
+
// --------------------------------------------------------------
|
|
156
|
+
// User sub-resources
|
|
157
|
+
// --------------------------------------------------------------
|
|
158
|
+
listUserIdentities: (environmentId, userId, params) => send(config, getSpec(`/users/${segment(userId)}/identities`, {
|
|
159
|
+
environment_id: environmentId,
|
|
160
|
+
cursor: params?.cursor,
|
|
161
|
+
limit: params?.limit,
|
|
162
|
+
}), cm.userIdentityListResponseSchema),
|
|
163
|
+
deleteUserIdentity: (environmentId, userId, identityId, writeOptions) => send(config, writeSpec("DELETE", `/users/${segment(userId)}/identities/${segment(identityId)}`, undefined, writeOptions, { environment_id: environmentId }), cm.userIdentityDeleteResponseSchema),
|
|
164
|
+
listUserPasskeys: (environmentId, userId, params) => send(config, getSpec(`/users/${segment(userId)}/passkeys`, {
|
|
165
|
+
environment_id: environmentId,
|
|
166
|
+
cursor: params?.cursor,
|
|
167
|
+
limit: params?.limit,
|
|
168
|
+
}), cm.userPasskeyListResponseSchema),
|
|
169
|
+
deleteUserPasskey: (environmentId, userId, passkeyId, writeOptions) => send(config, writeSpec("DELETE", `/users/${segment(userId)}/passkeys/${segment(passkeyId)}`, undefined, writeOptions, { environment_id: environmentId }), cm.userPasskeyDeleteResponseSchema),
|
|
170
|
+
listUserSessions: (environmentId, userId, params) => send(config, getSpec(`/users/${segment(userId)}/sessions`, {
|
|
171
|
+
environment_id: environmentId,
|
|
172
|
+
cursor: params?.cursor,
|
|
173
|
+
limit: params?.limit,
|
|
174
|
+
}), cm.userSessionListResponseSchema),
|
|
175
|
+
revokeUserSession: (environmentId, userId, sessionId, writeOptions) => send(config, writeSpec("DELETE", `/users/${segment(userId)}/sessions/${segment(sessionId)}`, undefined, writeOptions, { environment_id: environmentId }), cm.userSessionRevokeResponseSchema),
|
|
176
|
+
revokeAllUserSessions: (environmentId, userId, writeOptions) => send(config, writeSpec("DELETE", `/users/${segment(userId)}/sessions`, undefined, writeOptions, {
|
|
177
|
+
environment_id: environmentId,
|
|
178
|
+
}), cm.userSessionsRevokeAllResponseSchema),
|
|
179
|
+
// --------------------------------------------------------------
|
|
180
|
+
// User import/export jobs
|
|
181
|
+
// --------------------------------------------------------------
|
|
182
|
+
createUserImportJob: (body, writeOptions) => withValidBody(cm.userImportJobCreateRequestSchema, body, (valid) => send(config, writeSpec("POST", "/user-import-jobs", valid, writeOptions), cm.userImportJobCreateResponseSchema)),
|
|
183
|
+
getUserImportJob: (jobId) => send(config, getSpec(`/user-import-jobs/${segment(jobId)}`), cm.userImportJobGetResponseSchema),
|
|
184
|
+
createUserExportJob: (body, writeOptions) => withValidBody(cm.userExportJobCreateRequestSchema, body, (valid) => send(config, writeSpec("POST", "/user-export-jobs", valid, writeOptions), cm.userExportJobCreateResponseSchema)),
|
|
185
|
+
getUserExportJob: (jobId) => send(config, getSpec(`/user-export-jobs/${segment(jobId)}`), cm.userExportJobGetResponseSchema),
|
|
186
|
+
// --------------------------------------------------------------
|
|
187
|
+
// Webhooks
|
|
188
|
+
// --------------------------------------------------------------
|
|
189
|
+
listWebhooks: (params) => send(config, getSpec("/webhooks", {
|
|
190
|
+
cursor: params.cursor,
|
|
191
|
+
limit: params.limit,
|
|
192
|
+
environment_id: params.environment_id,
|
|
193
|
+
}), cm.webhookListResponseSchema),
|
|
194
|
+
listWebhookDeliveries: (webhookId, params) => send(config, getSpec(`/webhooks/${segment(webhookId)}/deliveries`, {
|
|
195
|
+
cursor: params?.cursor,
|
|
196
|
+
limit: params?.limit,
|
|
197
|
+
status: params?.status,
|
|
198
|
+
occurred_after: params?.occurred_after,
|
|
199
|
+
occurred_before: params?.occurred_before,
|
|
200
|
+
}), cm.webhookDeliveryListResponseSchema),
|
|
201
|
+
createWebhook: (body, writeOptions) => withValidBody(cm.webhookCreateRequestSchema, body, (valid) => send(config, writeSpec("POST", "/webhooks", valid, writeOptions), cm.webhookCreateResponseSchema)),
|
|
202
|
+
updateWebhook: (webhookId, body, writeOptions) => withValidBody(cm.webhookUpdateRequestSchema, body, (valid) => send(config, writeSpec("PATCH", `/webhooks/${segment(webhookId)}`, valid, writeOptions), cm.webhookUpdateResponseSchema)),
|
|
203
|
+
deleteWebhook: (webhookId, writeOptions) => send(config, writeSpec("DELETE", `/webhooks/${segment(webhookId)}`, undefined, writeOptions), cm.webhookDeleteResponseSchema),
|
|
204
|
+
rotateWebhookSecret: (webhookId, writeOptions) => send(config, writeSpec("POST", `/webhooks/${segment(webhookId)}/rotate-secret`, {}, writeOptions), cm.webhookRotateSecretResponseSchema),
|
|
205
|
+
testWebhook: (webhookId, body, writeOptions) => withValidBody(cm.webhookTestRequestSchema, body ?? {}, (valid) => send(config, writeSpec("POST", `/webhooks/${segment(webhookId)}/test`, valid, writeOptions), cm.webhookTestResponseSchema)),
|
|
206
|
+
// --------------------------------------------------------------
|
|
207
|
+
// Audit events / usage / billing
|
|
208
|
+
// --------------------------------------------------------------
|
|
209
|
+
listAuditEvents: (params) => send(config, getSpec("/audit-events", {
|
|
210
|
+
cursor: params.cursor,
|
|
211
|
+
limit: params.limit,
|
|
212
|
+
environment_id: params.environment_id,
|
|
213
|
+
actor_type: params.actor_type,
|
|
214
|
+
action: params.action,
|
|
215
|
+
subject_type: params.subject_type,
|
|
216
|
+
subject_id: params.subject_id,
|
|
217
|
+
result: params.result,
|
|
218
|
+
created_after: params.created_after,
|
|
219
|
+
created_before: params.created_before,
|
|
220
|
+
}), cm.auditEventListResponseSchema),
|
|
221
|
+
getMauUsage: (params) => send(config, getSpec("/usage/mau", {
|
|
222
|
+
billing_month: params?.billing_month,
|
|
223
|
+
environment_id: params?.environment_id,
|
|
224
|
+
}), cm.mauUsageResponseSchema),
|
|
225
|
+
createBillingCheckoutSession: (body, writeOptions) => withValidBody(cm.billingCheckoutSessionCreateRequestSchema, body, (valid) => send(config, writeSpec("POST", "/billing/checkout-session", valid, writeOptions), cm.billingCheckoutSessionCreateResponseSchema)),
|
|
226
|
+
createBillingPortalSession: (body, writeOptions) => withValidBody(cm.billingPortalSessionCreateRequestSchema, body, (valid) => send(config, writeSpec("POST", "/billing/portal-session", valid, writeOptions), cm.billingPortalSessionCreateResponseSchema)),
|
|
227
|
+
};
|
|
228
|
+
};
|
|
229
|
+
// Re-exported for consumers that narrow on failures (e.g. the CLI).
|
|
230
|
+
export { isFailure, isSuccess } from "./result.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|