@productcraft/platform-auth 0.1.3 → 1.0.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/README.md +118 -212
- package/api.md +1716 -0
- package/dist/index.cjs +1809 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4082 -260
- package/dist/index.d.ts +4082 -260
- package/dist/index.js +1744 -8
- package/dist/index.js.map +1 -1
- package/dist/testing.cjs +691 -0
- package/dist/testing.cjs.map +1 -0
- package/dist/testing.d.cts +32 -0
- package/dist/testing.d.ts +32 -0
- package/dist/testing.js +689 -0
- package/dist/testing.js.map +1 -0
- package/manifest.json +1115 -0
- package/package.json +15 -5
package/dist/index.js
CHANGED
|
@@ -1,14 +1,1750 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { APIClient, PC_BASE_URL, createOpenAPIClient } from '@productcraft/core';
|
|
2
|
+
export { APIConnectionError, APIError, APITimeoutError, APIUserAbortError, AuthenticationError, BadRequestError, ConfigurationError, ConflictError, IdempotencyKeyReuseError, InternalServerError, NotFoundError, PermissionDeniedError, ProductCraftError, RateLimitError, UnprocessableEntityError, WebhookVerificationError } from '@productcraft/core';
|
|
2
3
|
|
|
3
|
-
// src/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
// src/_generated/client.ts
|
|
5
|
+
|
|
6
|
+
// src/_generated/resources.ts
|
|
7
|
+
function fillActor(params, bound) {
|
|
8
|
+
if (bound.actor_id === void 0) return params;
|
|
9
|
+
const p = params ?? {};
|
|
10
|
+
return p.actor_id === void 0 ? { ...p, actor_id: bound.actor_id } : p;
|
|
11
|
+
}
|
|
12
|
+
function formData(fields) {
|
|
13
|
+
const form = new FormData();
|
|
14
|
+
for (const [k, v] of Object.entries(fields ?? {})) {
|
|
15
|
+
if (v === void 0 || v === null) continue;
|
|
16
|
+
if (v instanceof Blob) form.append(k, v);
|
|
17
|
+
else form.append(k, typeof v === "object" ? JSON.stringify(v) : String(v));
|
|
18
|
+
}
|
|
19
|
+
return form;
|
|
20
|
+
}
|
|
21
|
+
var APIResource = class {
|
|
22
|
+
_client;
|
|
23
|
+
/** Path parameters (and `actor_id`) bound by the enclosing scope. */
|
|
24
|
+
_b;
|
|
25
|
+
constructor(client, bound = {}) {
|
|
26
|
+
this._client = client;
|
|
27
|
+
this._b = bound;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
var AccountResource = class extends APIResource {
|
|
31
|
+
/**
|
|
32
|
+
* Delete the calling account. Auto-promotes the oldest admin (or oldest non-self member) to owner in any workspace where the departing account is the sole owner. Linked provider grants that require server-side revocation (Sign in with Apple) are revoked with the provider.
|
|
33
|
+
*
|
|
34
|
+
* @param options - Per-request options.
|
|
35
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, invalid or expired bearer token.
|
|
36
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN: The session lacks the required action for self-account deletion (defence-in-depth — the route is guarded but the cookie may be present without action access).
|
|
37
|
+
* @throws {NotFoundError} 404 NOT_FOUND: No account row exists for the session principal. Should never fire for a valid session — surfaced for SDKs.
|
|
38
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
39
|
+
* @see DELETE /v1/account
|
|
40
|
+
* @see https://productcraft.co/docs/platform/api-reference#delete-v1-account
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* await platform.account.erase();
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
erase(options) {
|
|
47
|
+
return this._client.request({ method: "DELETE", path: "/v1/account" }, options);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
var ApiKeysResource = class extends APIResource {
|
|
51
|
+
/**
|
|
52
|
+
* Describe the workspace key making this request: its name, workspace, expiry and what it may do in plain sentences. Call it with `Authorization: Bearer pcft_live_…` to test a key right after minting it.
|
|
53
|
+
*
|
|
54
|
+
* @param options - Per-request options.
|
|
55
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: No bearer, or the key is unknown, revoked or expired.
|
|
56
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN, WORKSPACE_KEY_REQUIRED: Signed in with a session or another token instead of a workspace key (`WORKSPACE_KEY_REQUIRED`). Send the `pcft_live_…` key as the bearer.
|
|
57
|
+
* @throws {NotFoundError} 404 NOT_FOUND, PAK_NOT_FOUND: The key was deleted while the request was in flight (`PAK_NOT_FOUND`).
|
|
58
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
59
|
+
* @see GET /v1/api-keys/self
|
|
60
|
+
* @see https://productcraft.co/docs/platform/api-reference#get-v1-api-keys-self
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* const apiKeySelf = await platform.apiKeys.self();
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
self(options) {
|
|
67
|
+
return this._client.request({ method: "GET", path: "/v1/api-keys/self" }, options);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
var AuthPasswordResource = class extends APIResource {
|
|
71
|
+
/**
|
|
72
|
+
* Request a password reset email. Neither the response nor its timing reveals whether the email matched an account.
|
|
73
|
+
*
|
|
74
|
+
* @param params - `PlatformAuth.AuthPasswordRequestResetParams`.
|
|
75
|
+
* @param options - Per-request options.
|
|
76
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Body failed validation (`email` missing or not an email address). Depends only on the request shape, never on whether an account exists.
|
|
77
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: more than 10 requests/min from this IP (strict `auth` bucket). `Retry-After` header set. Per-IP limit: rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
78
|
+
* @see POST /v1/auth/password/request-reset
|
|
79
|
+
* @see https://productcraft.co/docs/platform/api-reference#post-v1-auth-password-request-reset
|
|
80
|
+
* @example
|
|
81
|
+
* ```ts
|
|
82
|
+
* await platform.auth.password.requestReset({ email: "user@example.com" });
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
requestReset(params, options) {
|
|
86
|
+
return this._client.request({ method: "POST", path: "/v1/auth/password/request-reset", body: params, public: true }, options);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Reset password using the email-delivered reset token.
|
|
90
|
+
*
|
|
91
|
+
* @param params - `PlatformAuth.AuthPasswordResetParams`.
|
|
92
|
+
* @param options - Per-request options.
|
|
93
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR, PASSWORD_RESET_INVALID: Body failed validation, the new password fails the password policy, or the reset token is invalid or expired (`PASSWORD_RESET_INVALID`).
|
|
94
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: more than 10 requests/min from this IP (strict `auth` bucket). `Retry-After` header set. Per-IP limit: rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
95
|
+
* @see POST /v1/auth/password/reset
|
|
96
|
+
* @see https://productcraft.co/docs/platform/api-reference#post-v1-auth-password-reset
|
|
97
|
+
* @example
|
|
98
|
+
* ```ts
|
|
99
|
+
* await platform.auth.password.reset({ new_password: "MyNewPassword123", token: "123456" });
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
reset(params, options) {
|
|
103
|
+
return this._client.request({ method: "POST", path: "/v1/auth/password/reset", body: params, public: true }, options);
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
var AuthResource = class extends APIResource {
|
|
107
|
+
#password;
|
|
108
|
+
get password() {
|
|
109
|
+
return this.#password ??= new AuthPasswordResource(this._client, this._b);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Logout by revoking refresh token
|
|
113
|
+
*
|
|
114
|
+
* @param params - `PlatformAuth.AuthLogoutParams`.
|
|
115
|
+
* @param options - Per-request options.
|
|
116
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Validation failed or invalid token
|
|
117
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
118
|
+
* @see POST /v1/auth/logout
|
|
119
|
+
* @see https://productcraft.co/docs/platform/api-reference#post-v1-auth-logout
|
|
120
|
+
* @example
|
|
121
|
+
* ```ts
|
|
122
|
+
* await platform.auth.logout({ refresh_token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." });
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
logout(params, options) {
|
|
126
|
+
return this._client.request({ method: "POST", path: "/v1/auth/logout", body: params, public: true }, options);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Revoke the server-side session tied to the caller’s current access token
|
|
130
|
+
*
|
|
131
|
+
* @param options - Per-request options.
|
|
132
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Missing or invalid access token
|
|
133
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
134
|
+
* @see POST /v1/auth/logout-current
|
|
135
|
+
* @see https://productcraft.co/docs/platform/api-reference#post-v1-auth-logout-current
|
|
136
|
+
* @example
|
|
137
|
+
* ```ts
|
|
138
|
+
* await platform.auth.logoutCurrent();
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
logoutCurrent(options) {
|
|
142
|
+
return this._client.request({ method: "POST", path: "/v1/auth/logout-current" }, options);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Refresh access token using refresh token
|
|
146
|
+
*
|
|
147
|
+
* @param params - `PlatformAuth.AuthRefreshParams`.
|
|
148
|
+
* @param options - Per-request options.
|
|
149
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Validation failed or invalid token
|
|
150
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
151
|
+
* @see POST /v1/auth/refresh
|
|
152
|
+
* @see https://productcraft.co/docs/platform/api-reference#post-v1-auth-refresh
|
|
153
|
+
* @example
|
|
154
|
+
* ```ts
|
|
155
|
+
* const token = await platform.auth.refresh({ refresh_token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." });
|
|
156
|
+
* ```
|
|
157
|
+
*/
|
|
158
|
+
refresh(params, options) {
|
|
159
|
+
return this._client.request({ method: "POST", path: "/v1/auth/refresh", body: params, public: true }, options);
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Sign in with email/username and password
|
|
163
|
+
*
|
|
164
|
+
* Every failed attempt answers `401 INVALID_CREDENTIALS`, whatever went wrong: unknown identifier, wrong password, an account with no password credential, an account locked out through a different identifier, an account an operator has blocked, and a wrong password against a suspended or deactivated account. The responses are deliberately identical in body, timing, DB round trips and Redis ops, so signin is not an account-existence oracle. See core/block/CLAUDE.md.
|
|
165
|
+
*
|
|
166
|
+
* @param params - `PlatformAuth.AuthSigninParams`.
|
|
167
|
+
* @param options - Per-request options.
|
|
168
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Validation failed
|
|
169
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED, INVALID_CREDENTIALS: Invalid credentials (`INVALID_CREDENTIALS`). Returned for every failed attempt, including a correct password offered while the account is locked out or blocked, and a wrong password against a suspended or deactivated account. The body never says which.
|
|
170
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN, ACCOUNT_SUSPENDED, ACCOUNT_DEACTIVATED: The account is suspended (`ACCOUNT_SUSPENDED`) or deactivated (`ACCOUNT_DEACTIVATED`). Only reachable once the caller has proven the password — a wrong password against such an account is a 401.
|
|
171
|
+
* @throws {RateLimitError} 429 RATE_LIMITED, TOO_MANY_ATTEMPTS: Too many attempts for this identifier (`TOO_MANY_ATTEMPTS`). Two counters produce it, both keyed purely by the submitted identifier: a burst limit of 5 attempts per minute, and a 15-minute lock after 4 failed attempts. Both fire on the same attempt for a registered and an unregistered identifier. Per-IP limit: rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
172
|
+
* @see POST /v1/auth/signin
|
|
173
|
+
* @see https://productcraft.co/docs/platform/api-reference#post-v1-auth-signin
|
|
174
|
+
* @example
|
|
175
|
+
* ```ts
|
|
176
|
+
* const token = await platform.auth.signin({ identifier: "user@example.com", password: "MySecurePassword123" });
|
|
177
|
+
* ```
|
|
178
|
+
*/
|
|
179
|
+
signin(params, options) {
|
|
180
|
+
return this._client.request({ method: "POST", path: "/v1/auth/signin", body: params, public: true }, options);
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Create a new account and sign in
|
|
184
|
+
*
|
|
185
|
+
* @param params - `PlatformAuth.AuthSignupParams`.
|
|
186
|
+
* @param options - Per-request options.
|
|
187
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Validation failed
|
|
188
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
189
|
+
* @see POST /v1/auth/signup
|
|
190
|
+
* @see https://productcraft.co/docs/platform/api-reference#post-v1-auth-signup
|
|
191
|
+
* @example
|
|
192
|
+
* ```ts
|
|
193
|
+
* const token = await platform.auth.signup({ email: "user@example.com", password: "MySecurePassword123", username: "john_doe" });
|
|
194
|
+
* ```
|
|
195
|
+
*/
|
|
196
|
+
signup(params, options) {
|
|
197
|
+
return this._client.request({ method: "POST", path: "/v1/auth/signup", body: params, public: true }, options);
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
var IntrospectWorkspacesResource = class extends APIResource {
|
|
201
|
+
/**
|
|
202
|
+
* Introspect caller's membership + effective policy + enabled services in a workspace
|
|
203
|
+
*
|
|
204
|
+
* @param workspaceId - Id of the workspace.
|
|
205
|
+
* @param options - Per-request options.
|
|
206
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED, SESSION_REVOKED: Missing or invalid session. Also a session that has been signed out (`SESSION_REVOKED`).
|
|
207
|
+
* @throws {NotFoundError} 404 NOT_FOUND: Workspace not found (unknown slug or id). Known workspaces the caller is not a member of answer 200 with `is_member: false`.
|
|
208
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
209
|
+
* @see GET /v1/introspect/workspaces/{workspace_id}
|
|
210
|
+
* @see https://productcraft.co/docs/platform/api-reference#get-v1-introspect-workspaces-workspace-id
|
|
211
|
+
* @example
|
|
212
|
+
* ```ts
|
|
213
|
+
* const introspectWorkspace = await platform.introspect.workspaces.retrieve("workspace");
|
|
214
|
+
* ```
|
|
215
|
+
*/
|
|
216
|
+
retrieve(workspaceId, options) {
|
|
217
|
+
return this._client.request({ method: "GET", path: "/v1/introspect/workspaces/{workspace_id}", pathParams: { workspace_id: workspaceId } }, options);
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
var IntrospectResource = class extends APIResource {
|
|
221
|
+
#workspaces;
|
|
222
|
+
get workspaces() {
|
|
223
|
+
return this.#workspaces ??= new IntrospectWorkspacesResource(this._client, this._b);
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Resolve a Platform API Key (PAK) to its workspace + IAM-style policy. Downstream services use this with a 60s LRU cache and evaluate the policy via @repo/authz-nestjs evaluatePolicy().
|
|
227
|
+
*
|
|
228
|
+
* @param options - Per-request options.
|
|
229
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Missing or malformed `Authorization: Bearer` header, or the PAK is unknown, revoked or expired.
|
|
230
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
231
|
+
* @see POST /v1/introspect/api-key
|
|
232
|
+
* @see https://productcraft.co/docs/platform/api-reference#post-v1-introspect-api-key
|
|
233
|
+
* @example
|
|
234
|
+
* ```ts
|
|
235
|
+
* const introspectApiKey = await platform.introspect.apiKey();
|
|
236
|
+
* ```
|
|
237
|
+
*/
|
|
238
|
+
apiKey(options) {
|
|
239
|
+
return this._client.request({ method: "POST", path: "/v1/introspect/api-key" }, options);
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Introspect current user with workspace list
|
|
243
|
+
*
|
|
244
|
+
* @param options - Per-request options.
|
|
245
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: more than 60 requests/min from this IP (default bucket). Anonymous callers, and callers whose session has been signed out, otherwise get 200 with `is_authenticated: false`, never 401. Per-IP limit: rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
246
|
+
* @see GET /v1/introspect
|
|
247
|
+
* @see https://productcraft.co/docs/platform/api-reference#get-v1-introspect
|
|
248
|
+
* @example
|
|
249
|
+
* ```ts
|
|
250
|
+
* const introspect = await platform.introspect.retrieve();
|
|
251
|
+
* ```
|
|
252
|
+
*/
|
|
253
|
+
retrieve(options) {
|
|
254
|
+
return this._client.request({ method: "GET", path: "/v1/introspect" }, options);
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
var MeAvatarResource = class extends APIResource {
|
|
258
|
+
/**
|
|
259
|
+
* Clear the caller's avatar and delete the stored object.
|
|
260
|
+
*
|
|
261
|
+
* @param options - Per-request options.
|
|
262
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: No session.
|
|
263
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
264
|
+
* @see DELETE /v1/me/avatar
|
|
265
|
+
* @see https://productcraft.co/docs/platform/api-reference#delete-v1-me-avatar
|
|
266
|
+
* @example
|
|
267
|
+
* ```ts
|
|
268
|
+
* await platform.me.avatar.clear();
|
|
269
|
+
* ```
|
|
270
|
+
*/
|
|
271
|
+
clear(options) {
|
|
272
|
+
return this._client.request({ method: "DELETE", path: "/v1/me/avatar" }, options);
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Upload (or replace) the caller's avatar. PNG/JPEG/WEBP only — SVG is rejected because user-uploaded SVG from a productcraft.co origin is a stored-XSS vector. ≤2 MB. Magic bytes are sniffed; a mislabeled file is rejected.
|
|
276
|
+
*
|
|
277
|
+
* @param params - `PlatformAuth.MeAvatarUploadParams`.
|
|
278
|
+
* @param options - Per-request options.
|
|
279
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Invalid file: wrong mimetype, oversized, or content does not match the declared type.
|
|
280
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: No session.
|
|
281
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
282
|
+
* @see POST /v1/me/avatar
|
|
283
|
+
* @see https://productcraft.co/docs/platform/api-reference#post-v1-me-avatar
|
|
284
|
+
* @example
|
|
285
|
+
* ```ts
|
|
286
|
+
* const avatarUrl = await platform.me.avatar.upload({ file: new File(["…"], "image.png", { type: "image/png" }) });
|
|
287
|
+
* ```
|
|
288
|
+
*/
|
|
289
|
+
upload(params, options) {
|
|
290
|
+
return this._client.request({ method: "POST", path: "/v1/me/avatar", body: formData(params) }, options);
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
var MeHiddenGuidesResource = class extends APIResource {
|
|
294
|
+
/**
|
|
295
|
+
* Hide a getting-started guide for the caller.
|
|
296
|
+
*
|
|
297
|
+
* Idempotent: hiding a guide that is already hidden returns it unchanged, with its first `hidden_at`. At most 200 are kept; hiding one more drops the oldest.
|
|
298
|
+
*
|
|
299
|
+
* @param key - The guide: a surface name, optionally followed by `:` and a resource id, e.g. `dashboard:<workspace id>` or `all`.
|
|
300
|
+
* @param options - Per-request options.
|
|
301
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: The key is not a valid guide key.
|
|
302
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: No session.
|
|
303
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN: The caller authenticated with a non-human principal (e.g. a workspace API key). Hidden guides are a person's console preference.
|
|
304
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
305
|
+
* @see PUT /v1/me/hidden-guides/{key}
|
|
306
|
+
* @see https://productcraft.co/docs/platform/api-reference#put-v1-me-hidden-guides-key
|
|
307
|
+
* @example
|
|
308
|
+
* ```ts
|
|
309
|
+
* const hiddenGuide = await platform.me.hiddenGuides.hide("key");
|
|
310
|
+
* ```
|
|
311
|
+
*/
|
|
312
|
+
hide(key, options) {
|
|
313
|
+
return this._client.request({ method: "PUT", path: "/v1/me/hidden-guides/{key}", pathParams: { key } }, options);
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* List the getting-started guides the caller has hidden.
|
|
317
|
+
*
|
|
318
|
+
* Every guide the caller has hidden in the console, newest first. Hiding is presentation only: the setup status behind a guide is unchanged.
|
|
319
|
+
*
|
|
320
|
+
* @param options - Per-request options.
|
|
321
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: No session.
|
|
322
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN: The caller authenticated with a non-human principal (e.g. a workspace API key). Hidden guides are a person's console preference.
|
|
323
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
324
|
+
* @see GET /v1/me/hidden-guides
|
|
325
|
+
* @see https://productcraft.co/docs/platform/api-reference#get-v1-me-hidden-guides
|
|
326
|
+
* @example
|
|
327
|
+
* ```ts
|
|
328
|
+
* const hiddenGuides = await platform.me.hiddenGuides.list();
|
|
329
|
+
* ```
|
|
330
|
+
*/
|
|
331
|
+
list(options) {
|
|
332
|
+
return this._client.request({ method: "GET", path: "/v1/me/hidden-guides" }, options);
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Show every getting-started guide again.
|
|
336
|
+
*
|
|
337
|
+
* Removes every hidden guide for the caller, `all` included. Idempotent.
|
|
338
|
+
*
|
|
339
|
+
* @param options - Per-request options.
|
|
340
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: No session.
|
|
341
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN: The caller authenticated with a non-human principal (e.g. a workspace API key). Hidden guides are a person's console preference.
|
|
342
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
343
|
+
* @see DELETE /v1/me/hidden-guides
|
|
344
|
+
* @see https://productcraft.co/docs/platform/api-reference#delete-v1-me-hidden-guides
|
|
345
|
+
* @example
|
|
346
|
+
* ```ts
|
|
347
|
+
* await platform.me.hiddenGuides.reset();
|
|
348
|
+
* ```
|
|
349
|
+
*/
|
|
350
|
+
reset(options) {
|
|
351
|
+
return this._client.request({ method: "DELETE", path: "/v1/me/hidden-guides" }, options);
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Show a hidden getting-started guide again.
|
|
355
|
+
*
|
|
356
|
+
* Idempotent: showing a guide that is not hidden is a no-op.
|
|
357
|
+
*
|
|
358
|
+
* @param key - The guide: a surface name, optionally followed by `:` and a resource id, e.g. `dashboard:<workspace id>` or `all`.
|
|
359
|
+
* @param options - Per-request options.
|
|
360
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: The key is not a valid guide key.
|
|
361
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: No session.
|
|
362
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN: The caller authenticated with a non-human principal (e.g. a workspace API key). Hidden guides are a person's console preference.
|
|
363
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
364
|
+
* @see DELETE /v1/me/hidden-guides/{key}
|
|
365
|
+
* @see https://productcraft.co/docs/platform/api-reference#delete-v1-me-hidden-guides-key
|
|
366
|
+
* @example
|
|
367
|
+
* ```ts
|
|
368
|
+
* await platform.me.hiddenGuides.unhide("key");
|
|
369
|
+
* ```
|
|
370
|
+
*/
|
|
371
|
+
unhide(key, options) {
|
|
372
|
+
return this._client.request({ method: "DELETE", path: "/v1/me/hidden-guides/{key}", pathParams: { key } }, options);
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
var MeProfileResource = class extends APIResource {
|
|
376
|
+
/**
|
|
377
|
+
* Update the caller's profile. Currently only `displayName` is editable. An empty body is a no-op that returns the current profile. Cookie/JWT only — this is a human-self-service surface, not a PAK-mutation surface.
|
|
378
|
+
*
|
|
379
|
+
* @param params - `PlatformAuth.MeProfileUpdateParams`.
|
|
380
|
+
* @param options - Per-request options.
|
|
381
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Validation failed (e.g. displayName outside 1-128 chars).
|
|
382
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: No session.
|
|
383
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN: The caller authenticated with a non-human principal (e.g. PAK). Profile is per-human; only the human owner can mutate their own row.
|
|
384
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
385
|
+
* @see PATCH /v1/me/profile
|
|
386
|
+
* @see https://productcraft.co/docs/platform/api-reference#patch-v1-me-profile
|
|
387
|
+
* @example
|
|
388
|
+
* ```ts
|
|
389
|
+
* const meProfile = await platform.me.profile.update({ display_name: "string" });
|
|
390
|
+
* ```
|
|
391
|
+
*/
|
|
392
|
+
update(params, options) {
|
|
393
|
+
return this._client.request({ method: "PATCH", path: "/v1/me/profile", body: params }, options);
|
|
394
|
+
}
|
|
395
|
+
};
|
|
396
|
+
var MeResource = class extends APIResource {
|
|
397
|
+
#avatar;
|
|
398
|
+
#hiddenGuides;
|
|
399
|
+
#profile;
|
|
400
|
+
get avatar() {
|
|
401
|
+
return this.#avatar ??= new MeAvatarResource(this._client, this._b);
|
|
402
|
+
}
|
|
403
|
+
get hiddenGuides() {
|
|
404
|
+
return this.#hiddenGuides ??= new MeHiddenGuidesResource(this._client, this._b);
|
|
405
|
+
}
|
|
406
|
+
get profile() {
|
|
407
|
+
return this.#profile ??= new MeProfileResource(this._client, this._b);
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Read the caller's account profile.
|
|
411
|
+
*
|
|
412
|
+
* @param options - Per-request options.
|
|
413
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: No session.
|
|
414
|
+
* @throws {NotFoundError} 404 NOT_FOUND: No account row for the session principal. Should never fire for a valid session — surfaced for SDKs.
|
|
415
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
416
|
+
* @see GET /v1/me
|
|
417
|
+
* @see https://productcraft.co/docs/platform/api-reference#get-v1-me
|
|
418
|
+
* @example
|
|
419
|
+
* ```ts
|
|
420
|
+
* const meProfile = await platform.me.retrieve();
|
|
421
|
+
* ```
|
|
422
|
+
*/
|
|
423
|
+
retrieve(options) {
|
|
424
|
+
return this._client.request({ method: "GET", path: "/v1/me" }, options);
|
|
425
|
+
}
|
|
426
|
+
};
|
|
427
|
+
var OauthConnectionsResource = class extends APIResource {
|
|
428
|
+
/**
|
|
429
|
+
* Disconnect a client
|
|
430
|
+
*
|
|
431
|
+
* Revokes the whole grant family — the grant, its authorization codes, its refresh tokens and every live access token — in one transaction.
|
|
432
|
+
*
|
|
433
|
+
* @param grantId - Id of the grant.
|
|
434
|
+
* @param options - Per-request options.
|
|
435
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, invalid or expired bearer token.
|
|
436
|
+
* @throws {NotFoundError} 404 NOT_FOUND: No such connection for this human.
|
|
437
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
438
|
+
* @see DELETE /v1/oauth/connections/{grant_id}
|
|
439
|
+
* @see https://productcraft.co/docs/platform/api-reference#delete-v1-oauth-connections-grant-id
|
|
440
|
+
* @example
|
|
441
|
+
* ```ts
|
|
442
|
+
* await platform.oauth.connections.delete("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b");
|
|
443
|
+
* ```
|
|
444
|
+
*/
|
|
445
|
+
delete(grantId, options) {
|
|
446
|
+
return this._client.request({ method: "DELETE", path: "/v1/oauth/connections/{grant_id}", pathParams: { grant_id: grantId } }, options);
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* List clients this human has connected
|
|
450
|
+
*
|
|
451
|
+
* The user-facing half of revocation: which third-party clients hold a grant, in which workspace, carrying which policy.
|
|
452
|
+
*
|
|
453
|
+
* @param params - `PlatformAuth.OauthConnectionListParams`.
|
|
454
|
+
* @param options - Per-request options.
|
|
455
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Malformed `cursor`.
|
|
456
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, invalid or expired bearer token.
|
|
457
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
458
|
+
* @see GET /v1/oauth/connections
|
|
459
|
+
* @see https://productcraft.co/docs/platform/api-reference#get-v1-oauth-connections
|
|
460
|
+
* @example
|
|
461
|
+
* ```ts
|
|
462
|
+
* for await (const connection of platform.oauth.connections.list()) {
|
|
463
|
+
* console.log(connection);
|
|
464
|
+
* }
|
|
465
|
+
* const page = await platform.oauth.connections.list({}, { timeout: 5_000 });
|
|
466
|
+
* ```
|
|
467
|
+
*/
|
|
468
|
+
list(params, options) {
|
|
469
|
+
return this._client.list({ method: "GET", path: "/v1/oauth/connections", query: params }, options);
|
|
470
|
+
}
|
|
471
|
+
};
|
|
472
|
+
var OauthWorkspacesConnectionsResource = class extends APIResource {
|
|
473
|
+
/**
|
|
474
|
+
* Disconnect a client on behalf of the workspace
|
|
475
|
+
*
|
|
476
|
+
* Revokes the whole grant family for a grant made by any member of this workspace — the lever a workspace owner needs when an employee leaves and their MCP client is still running. Requires `workspace.connection.revoke`.
|
|
477
|
+
*
|
|
478
|
+
* @param workspaceId - Id of the workspace.
|
|
479
|
+
* @param grantId - Id of the grant.
|
|
480
|
+
* @param options - Per-request options.
|
|
481
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, invalid or expired bearer token.
|
|
482
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN: Not a member, or lacks `workspace.connection.revoke`.
|
|
483
|
+
* @throws {NotFoundError} 404 NOT_FOUND: No such connection in this workspace.
|
|
484
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
485
|
+
* @see DELETE /v1/oauth/workspaces/{workspace_id}/connections/{grant_id}
|
|
486
|
+
* @see https://productcraft.co/docs/platform/api-reference#delete-v1-oauth-workspaces-workspace-id-connections-grant-id
|
|
487
|
+
* @example
|
|
488
|
+
* ```ts
|
|
489
|
+
* await platform.oauth.workspaces.connections.delete("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b", "5d1e2f3a-4b5c-4d6e-8f70-8192a3b4c5d6");
|
|
490
|
+
* ```
|
|
491
|
+
*/
|
|
492
|
+
delete(workspaceId, grantId, options) {
|
|
493
|
+
return this._client.request({ method: "DELETE", path: "/v1/oauth/workspaces/{workspace_id}/connections/{grant_id}", pathParams: { workspace_id: workspaceId, grant_id: grantId } }, options);
|
|
494
|
+
}
|
|
495
|
+
/**
|
|
496
|
+
* List every client connected to a workspace
|
|
497
|
+
*
|
|
498
|
+
* The workspace-side half of revocation, for owners and admins: every grant made against this workspace, by any member, including grants made by people who have since left. Requires `workspace.connection.read`.
|
|
499
|
+
*
|
|
500
|
+
* @param workspaceId - Id of the workspace.
|
|
501
|
+
* @param params - `PlatformAuth.OauthWorkspaceConnectionListParams`.
|
|
502
|
+
* @param options - Per-request options.
|
|
503
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Malformed `cursor`.
|
|
504
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, invalid or expired bearer token.
|
|
505
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN: Not a member, or lacks `workspace.connection.read`.
|
|
506
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
507
|
+
* @see GET /v1/oauth/workspaces/{workspace_id}/connections
|
|
508
|
+
* @see https://productcraft.co/docs/platform/api-reference#get-v1-oauth-workspaces-workspace-id-connections
|
|
509
|
+
* @example
|
|
510
|
+
* ```ts
|
|
511
|
+
* for await (const connection of platform.oauth.workspaces.connections.list("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b")) {
|
|
512
|
+
* console.log(connection);
|
|
513
|
+
* }
|
|
514
|
+
* const page = await platform.oauth.workspaces.connections.list("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b", {}, { timeout: 5_000 });
|
|
515
|
+
* ```
|
|
516
|
+
*/
|
|
517
|
+
list(workspaceId, params, options) {
|
|
518
|
+
return this._client.list({ method: "GET", path: "/v1/oauth/workspaces/{workspace_id}/connections", pathParams: { workspace_id: workspaceId }, query: params }, options);
|
|
519
|
+
}
|
|
520
|
+
/**
|
|
521
|
+
* Lift a workspace revocation so the member may reconnect
|
|
522
|
+
*
|
|
523
|
+
* A workspace revocation is durable: the member re-running the connect flow does not undo it, so an administrator has to. This clears the block only — every token minted under the old grant stays revoked and the member still has to approve a fresh consent screen. Requires `workspace.connection.revoke`.
|
|
524
|
+
*
|
|
525
|
+
* @param workspaceId - Id of the workspace.
|
|
526
|
+
* @param grantId - Id of the grant.
|
|
527
|
+
* @param options - Per-request options.
|
|
528
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED, SESSION_REVOKED: Missing or invalid session, or a session that has been signed out (`SESSION_REVOKED`).
|
|
529
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN: Not a member, or lacks `workspace.connection.revoke`.
|
|
530
|
+
* @throws {NotFoundError} 404 NOT_FOUND: No such connection in this workspace.
|
|
531
|
+
* @throws {ConflictError} 409 CONFLICT: The connection was not revoked by an administrator — there is nothing to lift.
|
|
532
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
533
|
+
* @see POST /v1/oauth/workspaces/{workspace_id}/connections/{grant_id}/restore
|
|
534
|
+
* @see https://productcraft.co/docs/platform/api-reference#post-v1-oauth-workspaces-workspace-id-connections-grant-id-restore
|
|
535
|
+
* @example
|
|
536
|
+
* ```ts
|
|
537
|
+
* await platform.oauth.workspaces.connections.restore("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b", "5d1e2f3a-4b5c-4d6e-8f70-8192a3b4c5d6");
|
|
538
|
+
* ```
|
|
539
|
+
*/
|
|
540
|
+
restore(workspaceId, grantId, options) {
|
|
541
|
+
return this._client.request({ method: "POST", path: "/v1/oauth/workspaces/{workspace_id}/connections/{grant_id}/restore", pathParams: { workspace_id: workspaceId, grant_id: grantId } }, options);
|
|
542
|
+
}
|
|
543
|
+
};
|
|
544
|
+
var OauthWorkspacesResource = class extends APIResource {
|
|
545
|
+
#connections;
|
|
546
|
+
get connections() {
|
|
547
|
+
return this.#connections ??= new OauthWorkspacesConnectionsResource(this._client, this._b);
|
|
548
|
+
}
|
|
549
|
+
};
|
|
550
|
+
var OauthResource = class extends APIResource {
|
|
551
|
+
#connections;
|
|
552
|
+
#workspaces;
|
|
553
|
+
get connections() {
|
|
554
|
+
return this.#connections ??= new OauthConnectionsResource(this._client, this._b);
|
|
555
|
+
}
|
|
556
|
+
get workspaces() {
|
|
557
|
+
return this.#workspaces ??= new OauthWorkspacesResource(this._client, this._b);
|
|
558
|
+
}
|
|
559
|
+
};
|
|
560
|
+
var SessionsResource = class extends APIResource {
|
|
561
|
+
/**
|
|
562
|
+
* Revoke one of the caller's own sessions. Takes effect immediately — the refresh token stops working straight away, not at the end of its window.
|
|
563
|
+
*
|
|
564
|
+
* @param id - Id of the session.
|
|
565
|
+
* @param options - Per-request options.
|
|
566
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `id` is not a UUID.
|
|
567
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Unauthorized
|
|
568
|
+
* @throws {NotFoundError} 404 NOT_FOUND: No such session, or it belongs to somebody else — deliberately the same response, so this cannot be used to probe which session ids exist.
|
|
569
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
570
|
+
* @see DELETE /v1/session/{id}
|
|
571
|
+
* @see https://productcraft.co/docs/platform/api-reference#delete-v1-session-id
|
|
572
|
+
* @example
|
|
573
|
+
* ```ts
|
|
574
|
+
* const revokeSession = await platform.sessions.delete("3f0c1a2b-4c5d-4e6f-8a9b-0c1d2e3f4a5b");
|
|
575
|
+
* ```
|
|
576
|
+
*/
|
|
577
|
+
delete(id, options) {
|
|
578
|
+
return this._client.request({ method: "DELETE", path: "/v1/session/{id}", pathParams: { id } }, options);
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* List active sessions
|
|
582
|
+
*
|
|
583
|
+
* @param options - Per-request options.
|
|
584
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Unauthorized
|
|
585
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
586
|
+
* @see GET /v1/session
|
|
587
|
+
* @see https://productcraft.co/docs/platform/api-reference#get-v1-session
|
|
588
|
+
* @example
|
|
589
|
+
* ```ts
|
|
590
|
+
* const result = await platform.sessions.list();
|
|
591
|
+
* ```
|
|
592
|
+
*/
|
|
593
|
+
list(options) {
|
|
594
|
+
return this._client.request({ method: "GET", path: "/v1/session" }, options);
|
|
595
|
+
}
|
|
596
|
+
/**
|
|
597
|
+
* Sign out every other session of the caller, keeping the one this request was made with. Takes effect immediately for the revoked sessions. Idempotent: a repeat call revokes 0.
|
|
598
|
+
*
|
|
599
|
+
* @param options - Per-request options.
|
|
600
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Unauthorized
|
|
601
|
+
* @throws {ConflictError} 409 CONFLICT: The access token maps to no session (minted before sessions tracked token ids), so the current session cannot be kept. Sign in again.
|
|
602
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
603
|
+
* @see POST /v1/session/revoke-others
|
|
604
|
+
* @see https://productcraft.co/docs/platform/api-reference#post-v1-session-revoke-others
|
|
605
|
+
* @example
|
|
606
|
+
* ```ts
|
|
607
|
+
* const revokeOtherSessions = await platform.sessions.revokeOthers();
|
|
608
|
+
* ```
|
|
609
|
+
*/
|
|
610
|
+
revokeOthers(options) {
|
|
611
|
+
return this._client.request({ method: "POST", path: "/v1/session/revoke-others" }, options);
|
|
612
|
+
}
|
|
613
|
+
};
|
|
614
|
+
var StatsResource = class extends APIResource {
|
|
615
|
+
/**
|
|
616
|
+
* Workspace stats
|
|
617
|
+
*
|
|
618
|
+
* Member count, active platform API keys, admin changes in the window with a daily series, the last admin change and the last API-key use, for the console dashboard.
|
|
619
|
+
*
|
|
620
|
+
* Admin changes are workspace audit events that record a mutation. Reads (any action ending `.read`), sign-ins (`auth.signin.succeeded`) and MCP tool-call rows (`workspace.mcp_tool.*`) are not counted, so opening the console does not move the numbers. Days are UTC. Counts and timestamps only: no actor identifiers. Cached for up to 60 seconds (`generated_at`).
|
|
621
|
+
*
|
|
622
|
+
* @param params - `PlatformAuth.StatsRetrieveParams`.
|
|
623
|
+
* @param options - Per-request options.
|
|
624
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `window` is not one of 1d, 7d, 30d, or `workspaceId` is the slug of a workspace the caller can read rather than its UUID.
|
|
625
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, invalid or expired bearer token.
|
|
626
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN, NOT_A_MEMBER: Caller is not a member of the workspace (`NOT_A_MEMBER`) or lacks `workspace.audit.read` on it.
|
|
627
|
+
* @throws {NotFoundError} 404 NOT_FOUND: Workspace not found: no workspace has this id (or slug). Same answer as the service's other workspace routes.
|
|
628
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
629
|
+
* @see GET /v1/workspaces/{workspace_id}/stats
|
|
630
|
+
* @see https://productcraft.co/docs/platform/api-reference#get-v1-workspaces-workspace-id-stats
|
|
631
|
+
* @example
|
|
632
|
+
* ```ts
|
|
633
|
+
* const workspaceStats = await platform.stats.retrieve();
|
|
634
|
+
* ```
|
|
635
|
+
*/
|
|
636
|
+
retrieve(params, options) {
|
|
637
|
+
return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/stats", query: params }, options);
|
|
638
|
+
}
|
|
639
|
+
};
|
|
640
|
+
var VerificationResource = class extends APIResource {
|
|
641
|
+
/**
|
|
642
|
+
* Resend verification email
|
|
643
|
+
*
|
|
644
|
+
* @param options - Per-request options.
|
|
645
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Unauthorized
|
|
646
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
647
|
+
* @see POST /v1/verification/resend
|
|
648
|
+
* @see https://productcraft.co/docs/platform/api-reference#post-v1-verification-resend
|
|
649
|
+
* @example
|
|
650
|
+
* ```ts
|
|
651
|
+
* const feedback = await platform.verification.resend();
|
|
652
|
+
* ```
|
|
653
|
+
*/
|
|
654
|
+
resend(options) {
|
|
655
|
+
return this._client.request({ method: "POST", path: "/v1/verification/resend" }, options);
|
|
656
|
+
}
|
|
657
|
+
/**
|
|
658
|
+
* Verify an email code
|
|
659
|
+
*
|
|
660
|
+
* @param params - `PlatformAuth.VerificationVerifyParams`.
|
|
661
|
+
* @param options - Per-request options.
|
|
662
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Invalid or expired verification code
|
|
663
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
664
|
+
* @see POST /v1/verification/verify
|
|
665
|
+
* @see https://productcraft.co/docs/platform/api-reference#post-v1-verification-verify
|
|
666
|
+
* @example
|
|
667
|
+
* ```ts
|
|
668
|
+
* const feedback = await platform.verification.verify({ code: "a1b2c3d4…" });
|
|
669
|
+
* ```
|
|
670
|
+
*/
|
|
671
|
+
verify(params, options) {
|
|
672
|
+
return this._client.request({ method: "POST", path: "/v1/verification/verify", body: params, public: true }, options);
|
|
673
|
+
}
|
|
674
|
+
};
|
|
675
|
+
var WellKnownResource = class extends APIResource {
|
|
676
|
+
/**
|
|
677
|
+
* Public JWKS for verifying platform-issued JWTs (issuer `https://api.auth.productcraft.co`).
|
|
678
|
+
*
|
|
679
|
+
* @param options - Per-request options.
|
|
680
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
681
|
+
* @see GET /.well-known/jwks.json
|
|
682
|
+
* @see https://productcraft.co/docs/platform/api-reference#get-well-known-jwks-json
|
|
683
|
+
* @example
|
|
684
|
+
* ```ts
|
|
685
|
+
* const jwks = await platform.wellKnown.jwks();
|
|
686
|
+
* ```
|
|
687
|
+
*/
|
|
688
|
+
jwks(options) {
|
|
689
|
+
return this._client.request({ method: "GET", path: "/.well-known/jwks.json", public: true }, options);
|
|
690
|
+
}
|
|
691
|
+
/**
|
|
692
|
+
* OAuth 2.1 authorization server metadata (RFC 8414)
|
|
693
|
+
*
|
|
694
|
+
* Discovery document for third-party clients (Claude Desktop, Cursor, the ProductCraft MCP server). PKCE with `S256` is mandatory; no other code-challenge method is advertised or accepted. `scopes_supported` lists **presets**, not scopes: authority is the policy document on the grant (`authority_model`).
|
|
695
|
+
*
|
|
696
|
+
* @param options - Per-request options.
|
|
697
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
698
|
+
* @see GET /.well-known/oauth-authorization-server
|
|
699
|
+
* @see https://productcraft.co/docs/platform/api-reference#get-well-known-oauth-authorization-server
|
|
700
|
+
* @example
|
|
701
|
+
* ```ts
|
|
702
|
+
* const authorizationServerMetadata = await platform.wellKnown.oauthAuthorizationServer();
|
|
703
|
+
* ```
|
|
704
|
+
*/
|
|
705
|
+
oauthAuthorizationServer(options) {
|
|
706
|
+
return this._client.request({ method: "GET", path: "/.well-known/oauth-authorization-server", public: true }, options);
|
|
707
|
+
}
|
|
708
|
+
};
|
|
709
|
+
var WorkspacesApiKeysPresetsResource = class extends APIResource {
|
|
710
|
+
/**
|
|
711
|
+
* List the ready-made permission sets a workspace key can be minted with (`preset` on create), each with a label, a description and what it allows in this workspace, in plain sentences. A preset a key has already used reads its stored policy, so edits show.
|
|
712
|
+
*
|
|
713
|
+
* @param workspaceSlug - Slug of the workspace. Platform routes name the workspace by slug, positionally in the SDK (`platform.workspaces.retrieve("acme")`); the product APIs bind `workspace_id` instead.
|
|
714
|
+
* @param options - Per-request options.
|
|
715
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, malformed or invalid session.
|
|
716
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN, NOT_A_MEMBER: Caller is not a member of this workspace (`NOT_A_MEMBER`), or lacks `workspace.apikey.read`.
|
|
717
|
+
* @throws {NotFoundError} 404 NOT_FOUND: Workspace not found.
|
|
718
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
719
|
+
* @see GET /v1/workspaces/{workspace_slug}/api-keys/presets
|
|
720
|
+
* @see https://productcraft.co/docs/platform/api-reference#get-v1-workspaces-workspace-slug-api-keys-presets
|
|
721
|
+
* @example
|
|
722
|
+
* ```ts
|
|
723
|
+
* for await (const preset of platform.workspaces.apiKeys.presets.list("workspace")) {
|
|
724
|
+
* console.log(preset);
|
|
725
|
+
* }
|
|
726
|
+
* ```
|
|
727
|
+
*/
|
|
728
|
+
list(workspaceSlug, options) {
|
|
729
|
+
return this._client.list({ method: "GET", path: "/v1/workspaces/{workspace_slug}/api-keys/presets", pathParams: { workspace_slug: workspaceSlug } }, options);
|
|
730
|
+
}
|
|
731
|
+
};
|
|
732
|
+
var WorkspacesApiKeysResource = class extends APIResource {
|
|
733
|
+
#presets;
|
|
734
|
+
get presets() {
|
|
735
|
+
return this.#presets ??= new WorkspacesApiKeysPresetsResource(this._client, this._b);
|
|
736
|
+
}
|
|
737
|
+
/**
|
|
738
|
+
* Mint a new PAK. Choose what it can do with `preset` (a ready-made set such as `mail-send`) or `policy_ids` (managed policies you wrote), never both. The plaintext `token` is returned ONCE — store it now, then call `GET /v1/api-keys/self` with it to check what it can do. The minter can grant at most their own effective permissions. Cookie/JWT only — PAKs cannot mint other PAKs. Send an `Idempotency-Key` to make a retry safe: a retry of a mint that succeeded mints nothing and answers `409 PAK_ALREADY_MINTED` with that key's `id` (the token itself is never cached).
|
|
739
|
+
*
|
|
740
|
+
* @param workspaceSlug - Slug of the workspace. Platform routes name the workspace by slug, positionally in the SDK (`platform.workspaces.retrieve("acme")`); the product APIs bind `workspace_id` instead.
|
|
741
|
+
* @param params - `PlatformAuth.WorkspaceApiKeyCreateParams`.
|
|
742
|
+
* @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
|
|
743
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR, PAK_NAME_REQUIRED, PAK_NAME_TOO_LONG: Body failed validation (`VALIDATION_ERROR`): neither or both of `policy_ids` and `preset`, an unknown `preset`, an empty `policy_ids`, more than 25 policies, or a blank/overlong `name` (`PAK_NAME_REQUIRED` / `PAK_NAME_TOO_LONG`).
|
|
744
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED, SESSION_REVOKED: Missing, malformed or invalid session. Also a session that has been signed out (`SESSION_REVOKED`).
|
|
745
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN, NOT_A_MEMBER: Caller is a PAK (`pcft_live_*`) — mint requires a human-issued session; or is not a member (`NOT_A_MEMBER`), lacks `workspace.apikey.create`, or cannot grant one or more actions in the chosen preset or policies.
|
|
746
|
+
* @throws {NotFoundError} 404 NOT_FOUND, POLICY_NOT_FOUND: Workspace not found, or one of `policy_ids` does not exist in this workspace (`POLICY_NOT_FOUND`).
|
|
747
|
+
* @throws {ConflictError} 409 CONFLICT, PAK_ALREADY_MINTED, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: `PAK_ALREADY_MINTED`: this `Idempotency-Key` already minted a key (its `id` is in `details`); the token was shown once, so rotate that key for a new one. Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
|
|
748
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
749
|
+
* @see POST /v1/workspaces/{workspace_slug}/api-keys
|
|
750
|
+
* @see https://productcraft.co/docs/platform/api-reference#post-v1-workspaces-workspace-slug-api-keys
|
|
751
|
+
* @example
|
|
752
|
+
* ```ts
|
|
753
|
+
* const mintPak = await platform.workspaces.apiKeys.create("workspace", { name: "Production social client" });
|
|
754
|
+
* ```
|
|
755
|
+
*/
|
|
756
|
+
create(workspaceSlug, params, options) {
|
|
757
|
+
return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_slug}/api-keys", pathParams: { workspace_slug: workspaceSlug }, body: params, idempotent: true }, options);
|
|
758
|
+
}
|
|
759
|
+
/**
|
|
760
|
+
* Revoke a PAK. Default behaviour: introspect returns null on the next upstream call; downstream services fail-closed within the 60s cache TTL window. Pass `?force=true` to additionally publish a Redis fan-out that evicts the matching cache entry across every PAK-consuming service immediately — use it when rotating a leaked PAK and the 60s window matters.
|
|
761
|
+
*
|
|
762
|
+
* @param workspaceSlug - Slug of the workspace. Platform routes name the workspace by slug, positionally in the SDK (`platform.workspaces.retrieve("acme")`); the product APIs bind `workspace_id` instead.
|
|
763
|
+
* @param id - Id of the api key.
|
|
764
|
+
* @param params - `PlatformAuth.WorkspaceApiKeyDeleteParams`.
|
|
765
|
+
* @param options - Per-request options.
|
|
766
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `id` is not a UUID.
|
|
767
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED, SESSION_REVOKED: Missing, malformed or invalid session, or a PAK bearer (this route accepts cookie/JWT sessions only). Also a session that has been signed out (`SESSION_REVOKED`).
|
|
768
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN, NOT_A_MEMBER: Caller is not a member of this workspace (`NOT_A_MEMBER`), or lacks `workspace.apikey.delete`.
|
|
769
|
+
* @throws {NotFoundError} 404 NOT_FOUND, PAK_NOT_FOUND: Workspace not found, or PAK not found in this workspace (`PAK_NOT_FOUND`). Revoking an already-revoked PAK is a 204 no-op.
|
|
770
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
771
|
+
* @see DELETE /v1/workspaces/{workspace_slug}/api-keys/{id}
|
|
772
|
+
* @see https://productcraft.co/docs/platform/api-reference#delete-v1-workspaces-workspace-slug-api-keys-id
|
|
773
|
+
* @example
|
|
774
|
+
* ```ts
|
|
775
|
+
* await platform.workspaces.apiKeys.delete("workspace", "5d1e2f3a-4b5c-4d6e-8f70-8192a3b4c5d6");
|
|
776
|
+
* ```
|
|
777
|
+
*/
|
|
778
|
+
delete(workspaceSlug, id, params, options) {
|
|
779
|
+
return this._client.request({ method: "DELETE", path: "/v1/workspaces/{workspace_slug}/api-keys/{id}", pathParams: { workspace_slug: workspaceSlug, id }, query: params }, options);
|
|
780
|
+
}
|
|
781
|
+
/**
|
|
782
|
+
* List the API keys in this workspace
|
|
783
|
+
*
|
|
784
|
+
* Newest first, as the standard cursor-paginated `{data, pagination}` envelope (20 per page, at most 100). Plaintext tokens are never returned, only prefixes and metadata.
|
|
785
|
+
*
|
|
786
|
+
* **Deprecated legacy shape:** a request that sends neither `limit` nor `cursor` gets a bare JSON array of every key (capped at 1000), unless its `User-Agent` is a ProductCraft SDK (`productcraft-…`), which always gets the envelope. The array is kept only for `@productcraft/platform-auth` 0.0.x clients and is removed in the platform API's next major version; send `limit` (or use an SDK).
|
|
787
|
+
*
|
|
788
|
+
* @param workspaceSlug - Slug of the workspace. Platform routes name the workspace by slug, positionally in the SDK (`platform.workspaces.retrieve("acme")`); the product APIs bind `workspace_id` instead.
|
|
789
|
+
* @param params - `PlatformAuth.WorkspaceApiKeyListParams`.
|
|
790
|
+
* @param options - Per-request options.
|
|
791
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Malformed `cursor`, or `include_revoked` is not `true` or `false` (`VALIDATION_ERROR`).
|
|
792
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, invalid or expired bearer token.
|
|
793
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
794
|
+
* @see GET /v1/workspaces/{workspace_slug}/api-keys
|
|
795
|
+
* @see https://productcraft.co/docs/platform/api-reference#get-v1-workspaces-workspace-slug-api-keys
|
|
796
|
+
* @example
|
|
797
|
+
* ```ts
|
|
798
|
+
* for await (const apiKey of platform.workspaces.apiKeys.list("workspace")) {
|
|
799
|
+
* console.log(apiKey);
|
|
800
|
+
* }
|
|
801
|
+
* const page = await platform.workspaces.apiKeys.list("workspace", {}, { timeout: 5_000 });
|
|
802
|
+
* ```
|
|
803
|
+
*/
|
|
804
|
+
list(workspaceSlug, params, options) {
|
|
805
|
+
return this._client.list({ method: "GET", path: "/v1/workspaces/{workspace_slug}/api-keys", pathParams: { workspace_slug: workspaceSlug }, query: params }, options);
|
|
806
|
+
}
|
|
807
|
+
/**
|
|
808
|
+
* Describe the key a mint with this `preset` or these `policy_ids` would create, without creating anything: what it could do in plain sentences, and whether you may mint it. Read-only, so it takes no `Idempotency-Key`. Powers the review step of the console key wizard.
|
|
809
|
+
*
|
|
810
|
+
* @param workspaceSlug - Slug of the workspace. Platform routes name the workspace by slug, positionally in the SDK (`platform.workspaces.retrieve("acme")`); the product APIs bind `workspace_id` instead.
|
|
811
|
+
* @param params - `PlatformAuth.WorkspaceApiKeyPreviewParams`.
|
|
812
|
+
* @param options - Per-request options.
|
|
813
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Body failed validation (`VALIDATION_ERROR`): neither or both of `policy_ids` and `preset`, an unknown `preset`, or an empty or oversized `policy_ids`.
|
|
814
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED, SESSION_REVOKED: Missing, malformed or invalid session. Also a session that has been signed out (`SESSION_REVOKED`).
|
|
815
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN, NOT_A_MEMBER: Caller is a PAK, is not a member (`NOT_A_MEMBER`), or lacks `workspace.apikey.create`. A key you could not mint is NOT a 403 here: it comes back with `grantable: false`.
|
|
816
|
+
* @throws {NotFoundError} 404 NOT_FOUND, POLICY_NOT_FOUND: Workspace not found, or one of `policy_ids` does not exist in this workspace (`POLICY_NOT_FOUND`).
|
|
817
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
818
|
+
* @see POST /v1/workspaces/{workspace_slug}/api-keys/preview
|
|
819
|
+
* @see https://productcraft.co/docs/platform/api-reference#post-v1-workspaces-workspace-slug-api-keys-preview
|
|
820
|
+
* @example
|
|
821
|
+
* ```ts
|
|
822
|
+
* const pakGrantPreview = await platform.workspaces.apiKeys.preview("workspace", { policy_ids: ["11111111-1111-1111-1111-111111111111"] });
|
|
823
|
+
* ```
|
|
824
|
+
*/
|
|
825
|
+
preview(workspaceSlug, params, options) {
|
|
826
|
+
return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_slug}/api-keys/preview", pathParams: { workspace_slug: workspaceSlug }, body: params }, options);
|
|
827
|
+
}
|
|
828
|
+
/**
|
|
829
|
+
* Get a single PAK by id.
|
|
830
|
+
*
|
|
831
|
+
* @param workspaceSlug - Slug of the workspace. Platform routes name the workspace by slug, positionally in the SDK (`platform.workspaces.retrieve("acme")`); the product APIs bind `workspace_id` instead.
|
|
832
|
+
* @param id - Id of the api key.
|
|
833
|
+
* @param options - Per-request options.
|
|
834
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `id` is not a UUID.
|
|
835
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, malformed or invalid session, or a PAK bearer (this route accepts cookie/JWT sessions only).
|
|
836
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN, NOT_A_MEMBER: Caller is not a member of this workspace (`NOT_A_MEMBER`), or lacks `workspace.apikey.read`.
|
|
837
|
+
* @throws {NotFoundError} 404 NOT_FOUND, PAK_NOT_FOUND: Workspace not found, or PAK not found in this workspace (`PAK_NOT_FOUND`).
|
|
838
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
839
|
+
* @see GET /v1/workspaces/{workspace_slug}/api-keys/{id}
|
|
840
|
+
* @see https://productcraft.co/docs/platform/api-reference#get-v1-workspaces-workspace-slug-api-keys-id
|
|
841
|
+
* @example
|
|
842
|
+
* ```ts
|
|
843
|
+
* const publicApiKey = await platform.workspaces.apiKeys.retrieve("workspace", "5d1e2f3a-4b5c-4d6e-8f70-8192a3b4c5d6");
|
|
844
|
+
* ```
|
|
845
|
+
*/
|
|
846
|
+
retrieve(workspaceSlug, id, options) {
|
|
847
|
+
return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_slug}/api-keys/{id}", pathParams: { workspace_slug: workspaceSlug, id } }, options);
|
|
848
|
+
}
|
|
849
|
+
/**
|
|
850
|
+
* Mint a replacement for an existing PAK, carrying its name, description and policy bindings over. The outgoing key keeps working for `grace_hours` (24 by default) so a fleet can roll over without downtime. The plaintext `token` is returned ONCE. Cookie/JWT only — a PAK cannot rotate a PAK, for the same reason it cannot mint one.
|
|
851
|
+
*
|
|
852
|
+
* @param workspaceSlug - Slug of the workspace. Platform routes name the workspace by slug, positionally in the SDK (`platform.workspaces.retrieve("acme")`); the product APIs bind `workspace_id` instead.
|
|
853
|
+
* @param id - Id of the api key.
|
|
854
|
+
* @param params - `PlatformAuth.WorkspaceApiKeyRotateParams`.
|
|
855
|
+
* @param options - Per-request options.
|
|
856
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED, SESSION_REVOKED: Missing or invalid session, or a session that has been signed out (`SESSION_REVOKED`).
|
|
857
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN: Caller is a PAK (`pcft_live_*`), or cannot grant one or more actions in the bindings being carried across.
|
|
858
|
+
* @throws {NotFoundError} 404 NOT_FOUND: PAK not found in this workspace.
|
|
859
|
+
* @throws {ConflictError} 409 CONFLICT, PAK_REVOKED, PAK_EXPIRED: The key is revoked (`PAK_REVOKED`), already expired (`PAK_EXPIRED`), or has no policy bindings to carry across.
|
|
860
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
861
|
+
* @see POST /v1/workspaces/{workspace_slug}/api-keys/{id}/rotate
|
|
862
|
+
* @see https://productcraft.co/docs/platform/api-reference#post-v1-workspaces-workspace-slug-api-keys-id-rotate
|
|
863
|
+
* @example
|
|
864
|
+
* ```ts
|
|
865
|
+
* const rotatePak = await platform.workspaces.apiKeys.rotate("workspace", "5d1e2f3a-4b5c-4d6e-8f70-8192a3b4c5d6", { grace_hours: 24 });
|
|
866
|
+
* ```
|
|
867
|
+
*/
|
|
868
|
+
rotate(workspaceSlug, id, params, options) {
|
|
869
|
+
return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_slug}/api-keys/{id}/rotate", pathParams: { workspace_slug: workspaceSlug, id }, body: params }, options);
|
|
870
|
+
}
|
|
871
|
+
/**
|
|
872
|
+
* Update a PAK’s name or description (does not touch bindings).
|
|
873
|
+
*
|
|
874
|
+
* @param workspaceSlug - Slug of the workspace. Platform routes name the workspace by slug, positionally in the SDK (`platform.workspaces.retrieve("acme")`); the product APIs bind `workspace_id` instead.
|
|
875
|
+
* @param id - Id of the api key.
|
|
876
|
+
* @param params - `PlatformAuth.WorkspaceApiKeyUpdateParams`.
|
|
877
|
+
* @param options - Per-request options.
|
|
878
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR, PAK_NAME_REQUIRED: `id` is not a UUID, body failed validation, or `name` is blank (`PAK_NAME_REQUIRED`).
|
|
879
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED, SESSION_REVOKED: Missing, malformed or invalid session, or a PAK bearer (this route accepts cookie/JWT sessions only). Also a session that has been signed out (`SESSION_REVOKED`).
|
|
880
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN, NOT_A_MEMBER: Caller is not a member of this workspace (`NOT_A_MEMBER`), or lacks `workspace.apikey.update`.
|
|
881
|
+
* @throws {NotFoundError} 404 NOT_FOUND, PAK_NOT_FOUND: Workspace not found, or PAK not found in this workspace (`PAK_NOT_FOUND`).
|
|
882
|
+
* @throws {ConflictError} 409 CONFLICT, PAK_REVOKED: PAK is revoked (`PAK_REVOKED`).
|
|
883
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
884
|
+
* @see PATCH /v1/workspaces/{workspace_slug}/api-keys/{id}
|
|
885
|
+
* @see https://productcraft.co/docs/platform/api-reference#patch-v1-workspaces-workspace-slug-api-keys-id
|
|
886
|
+
* @example
|
|
887
|
+
* ```ts
|
|
888
|
+
* const publicApiKey = await platform.workspaces.apiKeys.update("workspace", "5d1e2f3a-4b5c-4d6e-8f70-8192a3b4c5d6", { description: "string" });
|
|
889
|
+
* ```
|
|
890
|
+
*/
|
|
891
|
+
update(workspaceSlug, id, params, options) {
|
|
892
|
+
return this._client.request({ method: "PATCH", path: "/v1/workspaces/{workspace_slug}/api-keys/{id}", pathParams: { workspace_slug: workspaceSlug, id }, body: params }, options);
|
|
893
|
+
}
|
|
894
|
+
/**
|
|
895
|
+
* Replace the managed-policy bindings on a PAK. Re-runs caller-narrowing on the merged union of statements.
|
|
896
|
+
*
|
|
897
|
+
* @param workspaceSlug - Slug of the workspace. Platform routes name the workspace by slug, positionally in the SDK (`platform.workspaces.retrieve("acme")`); the product APIs bind `workspace_id` instead.
|
|
898
|
+
* @param id - Id of the api key.
|
|
899
|
+
* @param params - `PlatformAuth.WorkspaceApiKeyUpdateBindingsParams`.
|
|
900
|
+
* @param options - Per-request options.
|
|
901
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: One of: bound > 25 policies; merged > 200 statements; one of the policy ids does not exist or lives in a different workspace.
|
|
902
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED, SESSION_REVOKED: Missing or invalid session, or a session that has been signed out (`SESSION_REVOKED`).
|
|
903
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN: Caller cannot grant one or more actions in the merged statement set.
|
|
904
|
+
* @throws {NotFoundError} 404 NOT_FOUND: PAK not found in this workspace.
|
|
905
|
+
* @throws {ConflictError} 409 CONFLICT: Empty bindings — revoke the PAK instead of leaving it unbound.
|
|
906
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
907
|
+
* @see PATCH /v1/workspaces/{workspace_slug}/api-keys/{id}/bindings
|
|
908
|
+
* @see https://productcraft.co/docs/platform/api-reference#patch-v1-workspaces-workspace-slug-api-keys-id-bindings
|
|
909
|
+
* @example
|
|
910
|
+
* ```ts
|
|
911
|
+
* const publicApiKey = await platform.workspaces.apiKeys.updateBindings("workspace", "5d1e2f3a-4b5c-4d6e-8f70-8192a3b4c5d6", { policy_ids: ["string"] });
|
|
912
|
+
* ```
|
|
913
|
+
*/
|
|
914
|
+
updateBindings(workspaceSlug, id, params, options) {
|
|
915
|
+
return this._client.request({ method: "PATCH", path: "/v1/workspaces/{workspace_slug}/api-keys/{id}/bindings", pathParams: { workspace_slug: workspaceSlug, id }, body: params }, options);
|
|
916
|
+
}
|
|
917
|
+
};
|
|
918
|
+
var WorkspacesAuditFeedResource = class extends APIResource {
|
|
919
|
+
/**
|
|
920
|
+
* Unified workspace audit feed (cursor-paginated)
|
|
921
|
+
*
|
|
922
|
+
* Audit timeline for workspace-scoped events — workspace, member, role, invite, service-activation, PAK and OAuth-consent mutations, plus successful sign-ins and completed password resets. Per-app Auth rows are NOT merged in: they live in another database with no cursor that spans both, and they are served by `GET /v1/apps/:appId/audit-logs` (paginated), `.../audit-logs/export` (streamed) and the per-app audit sink. The `sources` field reports that explicitly rather than implying a pending follow-up.
|
|
923
|
+
*
|
|
924
|
+
* @param workspaceSlug - Slug of the workspace. Platform routes name the workspace by slug, positionally in the SDK (`platform.workspaces.retrieve("acme")`); the product APIs bind `workspace_id` instead.
|
|
925
|
+
* @param params - `PlatformAuth.WorkspaceAuditFeedListParams`.
|
|
926
|
+
* @param options - Per-request options.
|
|
927
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Invalid query params — `actor_id` is not a well-formed UUID, or `cursor` is not a cursor this endpoint minted. `since`/`until` that do not parse as ISO-8601 are ignored rather than rejected, and `sources` silently drops unknown names; an empty result set after those filters still returns 200.
|
|
928
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, invalid or expired bearer token.
|
|
929
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN: The caller is signed in but lacks `workspace.audit.read` for this workspace.
|
|
930
|
+
* @throws {NotFoundError} 404 NOT_FOUND: The `:workspaceSlug` path param does not resolve to a workspace the caller can see.
|
|
931
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
932
|
+
* @see GET /v1/workspaces/{workspace_slug}/audit-feed
|
|
933
|
+
* @see https://productcraft.co/docs/platform/api-reference#get-v1-workspaces-workspace-slug-audit-feed
|
|
934
|
+
* @example
|
|
935
|
+
* ```ts
|
|
936
|
+
* for await (const auditFeed of platform.workspaces.auditFeed.list("workspace")) {
|
|
937
|
+
* console.log(auditFeed);
|
|
938
|
+
* }
|
|
939
|
+
* const page = await platform.workspaces.auditFeed.list("workspace", {}, { timeout: 5_000 });
|
|
940
|
+
* ```
|
|
941
|
+
*/
|
|
942
|
+
list(workspaceSlug, params, options) {
|
|
943
|
+
return this._client.list({ method: "GET", path: "/v1/workspaces/{workspace_slug}/audit-feed", pathParams: { workspace_slug: workspaceSlug }, query: fillActor(params, this._b) }, options);
|
|
944
|
+
}
|
|
945
|
+
};
|
|
946
|
+
var WorkspacesAuditLogsResource = class extends APIResource {
|
|
947
|
+
/**
|
|
948
|
+
* Stream the workspace audit log as NDJSON or CSV, applying the same `?action=` / `?actor_id=` / `?since=` / `?until=` filters as the list. Newest first. Reading the export is itself audited.
|
|
949
|
+
*
|
|
950
|
+
* The response is streamed: rows are walked in keyset batches and written as they are read, so neither the service nor the client holds the whole log. This is the SOC 2 / GDPR export the platform docs promise. Hard cap of 1,000,000 rows per call; a wider request is refused with 413 before any body is written, so a truncated file can never masquerade as a complete one.
|
|
951
|
+
*
|
|
952
|
+
* @param workspaceSlug - Slug of the workspace. Platform routes name the workspace by slug, positionally in the SDK (`platform.workspaces.retrieve("acme")`); the product APIs bind `workspace_id` instead.
|
|
953
|
+
* @param params - `PlatformAuth.WorkspaceAuditLogExportParams`.
|
|
954
|
+
* @param options - Per-request options.
|
|
955
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Unknown `format`, or malformed `since` / `until`.
|
|
956
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, invalid or expired bearer token.
|
|
957
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN: Caller lacks `workspace.audit.read`.
|
|
958
|
+
* @throws {NotFoundError} 404 NOT_FOUND: Workspace not found.
|
|
959
|
+
* @throws {APIError} 413 PAYLOAD_TOO_LARGE: More than 1,000,000 rows match. Narrow the window with `since` / `until` and retry.
|
|
960
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
961
|
+
* @see GET /v1/workspaces/{workspace_slug}/audit-logs/export
|
|
962
|
+
* @see https://productcraft.co/docs/platform/api-reference#get-v1-workspaces-workspace-slug-audit-logs-export
|
|
963
|
+
* @example
|
|
964
|
+
* ```ts
|
|
965
|
+
* const response = await platform.workspaces.auditLogs.export("workspace");
|
|
966
|
+
* const text = await response.text();
|
|
967
|
+
* ```
|
|
968
|
+
*/
|
|
969
|
+
export(workspaceSlug, params, options) {
|
|
970
|
+
return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_slug}/audit-logs/export", pathParams: { workspace_slug: workspaceSlug }, query: fillActor(params, this._b), raw: true }, options);
|
|
971
|
+
}
|
|
972
|
+
/**
|
|
973
|
+
* List workspace audit log entries, newest first. Filter by `?action=`, `?actor_id=`, and/or the `?since=` / `?until=` date range. 20/page (max 100), cursor-paginated.
|
|
974
|
+
*
|
|
975
|
+
* @param workspaceSlug - Slug of the workspace. Platform routes name the workspace by slug, positionally in the SDK (`platform.workspaces.retrieve("acme")`); the product APIs bind `workspace_id` instead.
|
|
976
|
+
* @param params - `PlatformAuth.WorkspaceAuditLogListParams`.
|
|
977
|
+
* @param options - Per-request options.
|
|
978
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Malformed `cursor`, `since`, or `until`.
|
|
979
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, invalid or expired bearer token.
|
|
980
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
981
|
+
* @see GET /v1/workspaces/{workspace_slug}/audit-logs
|
|
982
|
+
* @see https://productcraft.co/docs/platform/api-reference#get-v1-workspaces-workspace-slug-audit-logs
|
|
983
|
+
* @example
|
|
984
|
+
* ```ts
|
|
985
|
+
* for await (const auditLog of platform.workspaces.auditLogs.list("workspace")) {
|
|
986
|
+
* console.log(auditLog);
|
|
987
|
+
* }
|
|
988
|
+
* const page = await platform.workspaces.auditLogs.list("workspace", {}, { timeout: 5_000 });
|
|
989
|
+
* ```
|
|
990
|
+
*/
|
|
991
|
+
list(workspaceSlug, params, options) {
|
|
992
|
+
return this._client.list({ method: "GET", path: "/v1/workspaces/{workspace_slug}/audit-logs", pathParams: { workspace_slug: workspaceSlug }, query: fillActor(params, this._b) }, options);
|
|
993
|
+
}
|
|
994
|
+
};
|
|
995
|
+
var WorkspacesAvatarResource = class extends APIResource {
|
|
996
|
+
/**
|
|
997
|
+
* Clear the workspace avatar and delete the stored object. Gated by `workspace.settings.update`.
|
|
998
|
+
*
|
|
999
|
+
* @param workspaceSlug - Slug of the workspace. Platform routes name the workspace by slug, positionally in the SDK (`platform.workspaces.retrieve("acme")`); the product APIs bind `workspace_id` instead.
|
|
1000
|
+
* @param options - Per-request options.
|
|
1001
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Missing or invalid session.
|
|
1002
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN, NOT_A_MEMBER: Caller is not a member of this workspace (`NOT_A_MEMBER`), or lacks `workspace.settings.update`.
|
|
1003
|
+
* @throws {NotFoundError} 404 NOT_FOUND: Workspace not found (unknown slug or id).
|
|
1004
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
1005
|
+
* @see DELETE /v1/workspaces/{workspace_slug}/avatar
|
|
1006
|
+
* @see https://productcraft.co/docs/platform/api-reference#delete-v1-workspaces-workspace-slug-avatar
|
|
1007
|
+
* @example
|
|
1008
|
+
* ```ts
|
|
1009
|
+
* await platform.workspaces.avatar.clear("workspace");
|
|
1010
|
+
* ```
|
|
1011
|
+
*/
|
|
1012
|
+
clear(workspaceSlug, options) {
|
|
1013
|
+
return this._client.request({ method: "DELETE", path: "/v1/workspaces/{workspace_slug}/avatar", pathParams: { workspace_slug: workspaceSlug } }, options);
|
|
1014
|
+
}
|
|
1015
|
+
/**
|
|
1016
|
+
* Upload (or replace) the workspace identity avatar. Gated by `workspace.settings.update` (owner + admin). PNG/JPEG/WEBP only, ≤2 MB, magic-byte sniffed. SVG is rejected (stored-XSS).
|
|
1017
|
+
*
|
|
1018
|
+
* @param workspaceSlug - Slug of the workspace. Platform routes name the workspace by slug, positionally in the SDK (`platform.workspaces.retrieve("acme")`); the product APIs bind `workspace_id` instead.
|
|
1019
|
+
* @param params - `PlatformAuth.WorkspaceAvatarUploadParams`.
|
|
1020
|
+
* @param options - Per-request options.
|
|
1021
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, invalid or expired bearer token.
|
|
1022
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN: Caller is not a member of this workspace, or lacks workspace.settings.update.
|
|
1023
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
1024
|
+
* @see POST /v1/workspaces/{workspace_slug}/avatar
|
|
1025
|
+
* @see https://productcraft.co/docs/platform/api-reference#post-v1-workspaces-workspace-slug-avatar
|
|
1026
|
+
* @example
|
|
1027
|
+
* ```ts
|
|
1028
|
+
* const workspaceAvatarUrl = await platform.workspaces.avatar.upload("workspace", { file: new File(["…"], "image.png", { type: "image/png" }) });
|
|
1029
|
+
* ```
|
|
1030
|
+
*/
|
|
1031
|
+
upload(workspaceSlug, params, options) {
|
|
1032
|
+
return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_slug}/avatar", pathParams: { workspace_slug: workspaceSlug }, body: formData(params) }, options);
|
|
1033
|
+
}
|
|
1034
|
+
};
|
|
1035
|
+
var WorkspacesInvitesResource = class extends APIResource {
|
|
1036
|
+
/**
|
|
1037
|
+
* Accept a workspace invite by code. Cookie/JWT only — invite acceptance binds a human identity to a workspace.
|
|
1038
|
+
*
|
|
1039
|
+
* @param params - `PlatformAuth.WorkspaceInviteAcceptParams`.
|
|
1040
|
+
* @param options - Per-request options.
|
|
1041
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Body failed validation (`code` missing or empty).
|
|
1042
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED, SESSION_REVOKED: Missing or invalid session. Also a session that has been signed out (`SESSION_REVOKED`).
|
|
1043
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN, EMAIL_NOT_VERIFIED, INVITE_EMAIL_MISMATCH: Caller is a PAK (`pcft_live_*`), email not verified (`EMAIL_NOT_VERIFIED`), or the invite is restricted to a different email (`INVITE_EMAIL_MISMATCH`).
|
|
1044
|
+
* @throws {NotFoundError} 404 NOT_FOUND, INVITE_INVALID: Invite code not found (`INVITE_INVALID`).
|
|
1045
|
+
* @throws {ConflictError} 409 CONFLICT, ALREADY_A_MEMBER: Caller is already a member of this workspace (`ALREADY_A_MEMBER`).
|
|
1046
|
+
* @throws {APIError} 410 GONE, INVITE_REVOKED, INVITE_EXPIRED, INVITE_EXHAUSTED: Invite revoked (`INVITE_REVOKED`), expired (`INVITE_EXPIRED`) or out of uses (`INVITE_EXHAUSTED`).
|
|
1047
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: more than 10 requests/min from this IP (strict `auth` bucket). `Retry-After` header set. Per-IP limit: rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
1048
|
+
* @see POST /v1/workspaces/invites/accept
|
|
1049
|
+
* @see https://productcraft.co/docs/platform/api-reference#post-v1-workspaces-invites-accept
|
|
1050
|
+
* @example
|
|
1051
|
+
* ```ts
|
|
1052
|
+
* const workspace = await platform.workspaces.invites.accept({ code: "inv_…" });
|
|
1053
|
+
* ```
|
|
1054
|
+
*/
|
|
1055
|
+
accept(params, options) {
|
|
1056
|
+
return this._client.request({ method: "POST", path: "/v1/workspaces/invites/accept", body: params }, options);
|
|
1057
|
+
}
|
|
1058
|
+
/**
|
|
1059
|
+
* Create a workspace invite link. Cookie/JWT only — invites bring new humans into the workspace.
|
|
1060
|
+
*
|
|
1061
|
+
* @param workspaceSlug - Slug of the workspace. Platform routes name the workspace by slug, positionally in the SDK (`platform.workspaces.retrieve("acme")`); the product APIs bind `workspace_id` instead.
|
|
1062
|
+
* @param params - `PlatformAuth.WorkspaceInviteCreateParams`.
|
|
1063
|
+
* @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
|
|
1064
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Body failed validation.
|
|
1065
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED, SESSION_REVOKED: Missing or invalid session. Also a session that has been signed out (`SESSION_REVOKED`).
|
|
1066
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN, EMAIL_NOT_VERIFIED, NOT_A_MEMBER, OWNER_ROLE_REQUIRED, MEMBER_RANK_EXCEEDED: Caller is a PAK (`pcft_live_*`), email not verified (`EMAIL_NOT_VERIFIED`), not a member (`NOT_A_MEMBER`), lacks `workspace.member.invite`, a non-owner tried to invite an owner (`OWNER_ROLE_REQUIRED`), or the role holds permissions the caller does not (`MEMBER_RANK_EXCEEDED`).
|
|
1067
|
+
* @throws {NotFoundError} 404 NOT_FOUND, ROLE_NOT_FOUND: Workspace not found, or role not found in this workspace (`ROLE_NOT_FOUND`).
|
|
1068
|
+
* @throws {ConflictError} 409 CONFLICT, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
|
|
1069
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
1070
|
+
* @see POST /v1/workspaces/{workspace_slug}/invites
|
|
1071
|
+
* @see https://productcraft.co/docs/platform/api-reference#post-v1-workspaces-workspace-slug-invites
|
|
1072
|
+
* @example
|
|
1073
|
+
* ```ts
|
|
1074
|
+
* const workspaceInvite = await platform.workspaces.invites.create("workspace", { email: "alice@example.com" });
|
|
1075
|
+
* ```
|
|
1076
|
+
*/
|
|
1077
|
+
create(workspaceSlug, params, options) {
|
|
1078
|
+
return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_slug}/invites", pathParams: { workspace_slug: workspaceSlug }, body: params, idempotent: true }, options);
|
|
1079
|
+
}
|
|
1080
|
+
/**
|
|
1081
|
+
* Revoke a workspace invite. Cookie/JWT only.
|
|
1082
|
+
*
|
|
1083
|
+
* @param workspaceSlug - Slug of the workspace. Platform routes name the workspace by slug, positionally in the SDK (`platform.workspaces.retrieve("acme")`); the product APIs bind `workspace_id` instead.
|
|
1084
|
+
* @param inviteId - Id of the invite.
|
|
1085
|
+
* @param options - Per-request options.
|
|
1086
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED, SESSION_REVOKED: Missing or invalid session. Also a session that has been signed out (`SESSION_REVOKED`).
|
|
1087
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN, NOT_A_MEMBER: Caller is a PAK (`pcft_live_*`), not a member of the invite’s workspace (`NOT_A_MEMBER`), or lacks `workspace.member.invite`.
|
|
1088
|
+
* @throws {NotFoundError} 404 NOT_FOUND, INVITE_NOT_FOUND: Workspace not found, or invite not found (`INVITE_NOT_FOUND`).
|
|
1089
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
1090
|
+
* @see DELETE /v1/workspaces/{workspace_slug}/invites/{invite_id}
|
|
1091
|
+
* @see https://productcraft.co/docs/platform/api-reference#delete-v1-workspaces-workspace-slug-invites-invite-id
|
|
1092
|
+
* @example
|
|
1093
|
+
* ```ts
|
|
1094
|
+
* await platform.workspaces.invites.delete("workspace", "invite");
|
|
1095
|
+
* ```
|
|
1096
|
+
*/
|
|
1097
|
+
delete(workspaceSlug, inviteId, options) {
|
|
1098
|
+
return this._client.request({ method: "DELETE", path: "/v1/workspaces/{workspace_slug}/invites/{invite_id}", pathParams: { workspace_slug: workspaceSlug, invite_id: inviteId } }, options);
|
|
1099
|
+
}
|
|
1100
|
+
/**
|
|
1101
|
+
* List workspace invites, newest first. Cursor-paginated.
|
|
1102
|
+
*
|
|
1103
|
+
* @param workspaceSlug - Slug of the workspace. Platform routes name the workspace by slug, positionally in the SDK (`platform.workspaces.retrieve("acme")`); the product APIs bind `workspace_id` instead.
|
|
1104
|
+
* @param params - `PlatformAuth.WorkspaceInviteListParams`.
|
|
1105
|
+
* @param options - Per-request options.
|
|
1106
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Malformed `cursor`.
|
|
1107
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Missing or invalid session.
|
|
1108
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN, NOT_A_MEMBER: Caller is not a member of this workspace (`NOT_A_MEMBER`), or lacks `workspace.member.invite`.
|
|
1109
|
+
* @throws {NotFoundError} 404 NOT_FOUND: Workspace not found (unknown slug or id).
|
|
1110
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
1111
|
+
* @see GET /v1/workspaces/{workspace_slug}/invites
|
|
1112
|
+
* @see https://productcraft.co/docs/platform/api-reference#get-v1-workspaces-workspace-slug-invites
|
|
1113
|
+
* @example
|
|
1114
|
+
* ```ts
|
|
1115
|
+
* for await (const invite of platform.workspaces.invites.list("workspace")) {
|
|
1116
|
+
* console.log(invite);
|
|
1117
|
+
* }
|
|
1118
|
+
* const page = await platform.workspaces.invites.list("workspace", {}, { timeout: 5_000 });
|
|
1119
|
+
* ```
|
|
1120
|
+
*/
|
|
1121
|
+
list(workspaceSlug, params, options) {
|
|
1122
|
+
return this._client.list({ method: "GET", path: "/v1/workspaces/{workspace_slug}/invites", pathParams: { workspace_slug: workspaceSlug }, query: params }, options);
|
|
1123
|
+
}
|
|
1124
|
+
};
|
|
1125
|
+
var WorkspacesMembersResource = class extends APIResource {
|
|
1126
|
+
/**
|
|
1127
|
+
* Remove a member from a workspace (or self-leave)
|
|
1128
|
+
*
|
|
1129
|
+
* @param workspaceSlug - Slug of the workspace. Platform routes name the workspace by slug, positionally in the SDK (`platform.workspaces.retrieve("acme")`); the product APIs bind `workspace_id` instead.
|
|
1130
|
+
* @param accountId - Id of the account.
|
|
1131
|
+
* @param options - Per-request options.
|
|
1132
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED, SESSION_REVOKED: Missing or invalid session. Also a session that has been signed out (`SESSION_REVOKED`).
|
|
1133
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN, NOT_A_MEMBER, MEMBER_RANK_EXCEEDED: Caller is not a member of this workspace (`NOT_A_MEMBER`), lacks `workspace.member.remove` (not required for self-leave), or the target outranks the caller (`MEMBER_RANK_EXCEEDED`: only an owner can remove an owner, and the target role's permissions must all be held by the caller).
|
|
1134
|
+
* @throws {NotFoundError} 404 NOT_FOUND, NOT_A_MEMBER: Workspace not found, or target account is not a member (`NOT_A_MEMBER`).
|
|
1135
|
+
* @throws {ConflictError} 409 CONFLICT, LAST_MEMBER, SOLE_OWNER: Target is the last member (`LAST_MEMBER`) or the sole owner (`SOLE_OWNER`).
|
|
1136
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
1137
|
+
* @see DELETE /v1/workspaces/{workspace_slug}/members/{account_id}
|
|
1138
|
+
* @see https://productcraft.co/docs/platform/api-reference#delete-v1-workspaces-workspace-slug-members-account-id
|
|
1139
|
+
* @example
|
|
1140
|
+
* ```ts
|
|
1141
|
+
* await platform.workspaces.members.delete("workspace", "account");
|
|
1142
|
+
* ```
|
|
1143
|
+
*/
|
|
1144
|
+
delete(workspaceSlug, accountId, options) {
|
|
1145
|
+
return this._client.request({ method: "DELETE", path: "/v1/workspaces/{workspace_slug}/members/{account_id}", pathParams: { workspace_slug: workspaceSlug, account_id: accountId } }, options);
|
|
1146
|
+
}
|
|
1147
|
+
/**
|
|
1148
|
+
* List workspace members, oldest join first. Narrow with `?q=` (name / username / email substring) and/or `?role=`. Cursor-paginated.
|
|
1149
|
+
*
|
|
1150
|
+
* @param workspaceSlug - Slug of the workspace. Platform routes name the workspace by slug, positionally in the SDK (`platform.workspaces.retrieve("acme")`); the product APIs bind `workspace_id` instead.
|
|
1151
|
+
* @param params - `PlatformAuth.WorkspaceMemberListParams`.
|
|
1152
|
+
* @param options - Per-request options.
|
|
1153
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Malformed `cursor`.
|
|
1154
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Missing or invalid session.
|
|
1155
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN, NOT_A_MEMBER: Caller is not a member of this workspace (`NOT_A_MEMBER`), or lacks `workspace.member.read`.
|
|
1156
|
+
* @throws {NotFoundError} 404 NOT_FOUND: Workspace not found (unknown slug or id).
|
|
1157
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
1158
|
+
* @see GET /v1/workspaces/{workspace_slug}/members
|
|
1159
|
+
* @see https://productcraft.co/docs/platform/api-reference#get-v1-workspaces-workspace-slug-members
|
|
1160
|
+
* @example
|
|
1161
|
+
* ```ts
|
|
1162
|
+
* for await (const member of platform.workspaces.members.list("workspace")) {
|
|
1163
|
+
* console.log(member);
|
|
1164
|
+
* }
|
|
1165
|
+
* const page = await platform.workspaces.members.list("workspace", {}, { timeout: 5_000 });
|
|
1166
|
+
* ```
|
|
1167
|
+
*/
|
|
1168
|
+
list(workspaceSlug, params, options) {
|
|
1169
|
+
return this._client.list({ method: "GET", path: "/v1/workspaces/{workspace_slug}/members", pathParams: { workspace_slug: workspaceSlug }, query: params }, options);
|
|
1170
|
+
}
|
|
1171
|
+
/**
|
|
1172
|
+
* Update a member's role. Body: { roleId } or { role: "owner"|"admin"|"member" }.
|
|
1173
|
+
*
|
|
1174
|
+
* @param workspaceSlug - Slug of the workspace. Platform routes name the workspace by slug, positionally in the SDK (`platform.workspaces.retrieve("acme")`); the product APIs bind `workspace_id` instead.
|
|
1175
|
+
* @param accountId - Id of the account.
|
|
1176
|
+
* @param params - `PlatformAuth.WorkspaceMemberUpdateRoleParams`.
|
|
1177
|
+
* @param options - Per-request options.
|
|
1178
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Body failed validation.
|
|
1179
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED, SESSION_REVOKED: Missing or invalid session. Also a session that has been signed out (`SESSION_REVOKED`).
|
|
1180
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN, NOT_A_MEMBER, OWNER_ROLE_REQUIRED, MEMBER_RANK_EXCEEDED: Caller is not a member of this workspace (`NOT_A_MEMBER`), lacks `workspace.member.update-role`, a non-owner tried to assign the owner role or change an owner (`OWNER_ROLE_REQUIRED`), or a non-owner tried to change a role to or from one holding permissions the caller lacks (`MEMBER_RANK_EXCEEDED`). Admins may make admins, never owners.
|
|
1181
|
+
* @throws {NotFoundError} 404 NOT_FOUND, NOT_A_MEMBER, ROLE_NOT_FOUND: Workspace not found, target account is not a member (`NOT_A_MEMBER`), or role not found in this workspace (`ROLE_NOT_FOUND`).
|
|
1182
|
+
* @throws {ConflictError} 409 CONFLICT, SOLE_OWNER: Would demote the only owner (`SOLE_OWNER`). Assign another owner first.
|
|
1183
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
1184
|
+
* @see PATCH /v1/workspaces/{workspace_slug}/members/{account_id}/role
|
|
1185
|
+
* @see https://productcraft.co/docs/platform/api-reference#patch-v1-workspaces-workspace-slug-members-account-id-role
|
|
1186
|
+
* @example
|
|
1187
|
+
* ```ts
|
|
1188
|
+
* const updateMemberRole = await platform.workspaces.members.updateRole("workspace", "account", { role: "owner" });
|
|
1189
|
+
* ```
|
|
1190
|
+
*/
|
|
1191
|
+
updateRole(workspaceSlug, accountId, params, options) {
|
|
1192
|
+
return this._client.request({ method: "PATCH", path: "/v1/workspaces/{workspace_slug}/members/{account_id}/role", pathParams: { workspace_slug: workspaceSlug, account_id: accountId }, body: params }, options);
|
|
1193
|
+
}
|
|
1194
|
+
};
|
|
1195
|
+
var WorkspacesPoliciesActionsResource = class extends APIResource {
|
|
1196
|
+
/**
|
|
1197
|
+
* List every known workspace action (catalog of statement actions).
|
|
1198
|
+
*
|
|
1199
|
+
* @param workspaceSlug - Slug of the workspace. Platform routes name the workspace by slug, positionally in the SDK (`platform.workspaces.retrieve("acme")`); the product APIs bind `workspace_id` instead.
|
|
1200
|
+
* @param options - Per-request options.
|
|
1201
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, malformed or invalid session, or a PAK bearer (this route accepts cookie/JWT sessions only).
|
|
1202
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN, NOT_A_MEMBER: Caller is not a member of this workspace (`NOT_A_MEMBER`), or lacks `workspace.policy.read`.
|
|
1203
|
+
* @throws {NotFoundError} 404 NOT_FOUND: Workspace not found (unknown slug or id).
|
|
1204
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
1205
|
+
* @see GET /v1/workspaces/{workspace_slug}/policies/actions/catalog
|
|
1206
|
+
* @see https://productcraft.co/docs/platform/api-reference#get-v1-workspaces-workspace-slug-policies-actions-catalog
|
|
1207
|
+
* @example
|
|
1208
|
+
* ```ts
|
|
1209
|
+
* const workspaceActionCatalog = await platform.workspaces.policies.actions.catalog("workspace");
|
|
1210
|
+
* ```
|
|
1211
|
+
*/
|
|
1212
|
+
catalog(workspaceSlug, options) {
|
|
1213
|
+
return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_slug}/policies/actions/catalog", pathParams: { workspace_slug: workspaceSlug } }, options);
|
|
1214
|
+
}
|
|
1215
|
+
};
|
|
1216
|
+
var WorkspacesPoliciesResource = class extends APIResource {
|
|
1217
|
+
#actions;
|
|
1218
|
+
get actions() {
|
|
1219
|
+
return this.#actions ??= new WorkspacesPoliciesActionsResource(this._client, this._b);
|
|
1220
|
+
}
|
|
1221
|
+
/**
|
|
1222
|
+
* Create a managed policy. Cookie/JWT only — policy authoring is a human-admin surface.
|
|
1223
|
+
*
|
|
1224
|
+
* @param workspaceSlug - Slug of the workspace. Platform routes name the workspace by slug, positionally in the SDK (`platform.workspaces.retrieve("acme")`); the product APIs bind `workspace_id` instead.
|
|
1225
|
+
* @param params - `PlatformAuth.WorkspacePolicyCreateParams`.
|
|
1226
|
+
* @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
|
|
1227
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Invalid policy shape, name, or condition block.
|
|
1228
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED, SESSION_REVOKED: Missing or invalid session, or a session that has been signed out (`SESSION_REVOKED`).
|
|
1229
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN, NOT_A_MEMBER: Caller is not a member (`NOT_A_MEMBER`), lacks `workspace.policy.create` (owner and admin hold it by default), or the policy grants an action the caller does not hold.
|
|
1230
|
+
* @throws {ConflictError} 409 CONFLICT, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: Name already in use, or the workspace already has 100 policies. Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
|
|
1231
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
1232
|
+
* @see POST /v1/workspaces/{workspace_slug}/policies
|
|
1233
|
+
* @see https://productcraft.co/docs/platform/api-reference#post-v1-workspaces-workspace-slug-policies
|
|
1234
|
+
* @example
|
|
1235
|
+
* ```ts
|
|
1236
|
+
* const managedPolicy = await platform.workspaces.policies.create("workspace", {
|
|
1237
|
+
* name: "mail-readonly",
|
|
1238
|
+
* policy: [{ actions: ["mail.read", "mail.list"], effect: "allow", resources: ["*"] }],
|
|
1239
|
+
* });
|
|
1240
|
+
* ```
|
|
1241
|
+
*/
|
|
1242
|
+
create(workspaceSlug, params, options) {
|
|
1243
|
+
return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_slug}/policies", pathParams: { workspace_slug: workspaceSlug }, body: params, idempotent: true }, options);
|
|
1244
|
+
}
|
|
1245
|
+
/**
|
|
1246
|
+
* Delete a managed policy. Cascades: API keys lose the binding (deny-all if no other bindings remain); roles fall back to their inline policy column. Owners and admins; a policy bound to a role, or a preset policy, only an owner can delete. Cookie/JWT only.
|
|
1247
|
+
*
|
|
1248
|
+
* @param workspaceSlug - Slug of the workspace. Platform routes name the workspace by slug, positionally in the SDK (`platform.workspaces.retrieve("acme")`); the product APIs bind `workspace_id` instead.
|
|
1249
|
+
* @param policyId - Id of the policy.
|
|
1250
|
+
* @param options - Per-request options.
|
|
1251
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED, SESSION_REVOKED: Missing or invalid session, or a session that has been signed out (`SESSION_REVOKED`).
|
|
1252
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN, OWNER_ROLE_REQUIRED: Caller lacks `workspace.policy.delete`, or is not an owner and the policy is bound to a role or is a preset policy (`OWNER_ROLE_REQUIRED`).
|
|
1253
|
+
* @throws {NotFoundError} 404 NOT_FOUND, POLICY_NOT_FOUND: Policy not found in this workspace (`POLICY_NOT_FOUND`).
|
|
1254
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
1255
|
+
* @see DELETE /v1/workspaces/{workspace_slug}/policies/{policy_id}
|
|
1256
|
+
* @see https://productcraft.co/docs/platform/api-reference#delete-v1-workspaces-workspace-slug-policies-policy-id
|
|
1257
|
+
* @example
|
|
1258
|
+
* ```ts
|
|
1259
|
+
* const managedPolicyDeleted = await platform.workspaces.policies.delete("workspace", "5d1e2f3a-4b5c-4d6e-8f70-8192a3b4c5d6");
|
|
1260
|
+
* ```
|
|
1261
|
+
*/
|
|
1262
|
+
delete(workspaceSlug, policyId, options) {
|
|
1263
|
+
return this._client.request({ method: "DELETE", path: "/v1/workspaces/{workspace_slug}/policies/{policy_id}", pathParams: { workspace_slug: workspaceSlug, policy_id: policyId } }, options);
|
|
1264
|
+
}
|
|
1265
|
+
/**
|
|
1266
|
+
* List managed policies in a workspace, alphabetically. 20/page (max 100), cursor-paginated.
|
|
1267
|
+
*
|
|
1268
|
+
* @param workspaceSlug - Slug of the workspace. Platform routes name the workspace by slug, positionally in the SDK (`platform.workspaces.retrieve("acme")`); the product APIs bind `workspace_id` instead.
|
|
1269
|
+
* @param params - `PlatformAuth.WorkspacePolicyListParams`.
|
|
1270
|
+
* @param options - Per-request options.
|
|
1271
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Malformed `cursor`.
|
|
1272
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, invalid or expired bearer token.
|
|
1273
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
1274
|
+
* @see GET /v1/workspaces/{workspace_slug}/policies
|
|
1275
|
+
* @see https://productcraft.co/docs/platform/api-reference#get-v1-workspaces-workspace-slug-policies
|
|
1276
|
+
* @example
|
|
1277
|
+
* ```ts
|
|
1278
|
+
* for await (const policy of platform.workspaces.policies.list("workspace")) {
|
|
1279
|
+
* console.log(policy);
|
|
1280
|
+
* }
|
|
1281
|
+
* const page = await platform.workspaces.policies.list("workspace", {}, { timeout: 5_000 });
|
|
1282
|
+
* ```
|
|
1283
|
+
*/
|
|
1284
|
+
list(workspaceSlug, params, options) {
|
|
1285
|
+
return this._client.list({ method: "GET", path: "/v1/workspaces/{workspace_slug}/policies", pathParams: { workspace_slug: workspaceSlug }, query: params }, options);
|
|
1286
|
+
}
|
|
1287
|
+
/**
|
|
1288
|
+
* Get a managed policy by id
|
|
1289
|
+
*
|
|
1290
|
+
* @param workspaceSlug - Slug of the workspace. Platform routes name the workspace by slug, positionally in the SDK (`platform.workspaces.retrieve("acme")`); the product APIs bind `workspace_id` instead.
|
|
1291
|
+
* @param policyId - Id of the policy.
|
|
1292
|
+
* @param options - Per-request options.
|
|
1293
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, invalid or expired bearer token.
|
|
1294
|
+
* @throws {NotFoundError} 404 NOT_FOUND: Policy not found in this workspace.
|
|
1295
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
1296
|
+
* @see GET /v1/workspaces/{workspace_slug}/policies/{policy_id}
|
|
1297
|
+
* @see https://productcraft.co/docs/platform/api-reference#get-v1-workspaces-workspace-slug-policies-policy-id
|
|
1298
|
+
* @example
|
|
1299
|
+
* ```ts
|
|
1300
|
+
* const managedPolicyDetail = await platform.workspaces.policies.retrieve("workspace", "5d1e2f3a-4b5c-4d6e-8f70-8192a3b4c5d6");
|
|
1301
|
+
* ```
|
|
1302
|
+
*/
|
|
1303
|
+
retrieve(workspaceSlug, policyId, options) {
|
|
1304
|
+
return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_slug}/policies/{policy_id}", pathParams: { workspace_slug: workspaceSlug, policy_id: policyId } }, options);
|
|
1305
|
+
}
|
|
1306
|
+
/**
|
|
1307
|
+
* Update a managed policy. Owners and admins; a policy bound to a role, or a preset policy, only an owner can edit. Cookie/JWT only — policy authoring is a human-admin surface.
|
|
1308
|
+
*
|
|
1309
|
+
* @param workspaceSlug - Slug of the workspace. Platform routes name the workspace by slug, positionally in the SDK (`platform.workspaces.retrieve("acme")`); the product APIs bind `workspace_id` instead.
|
|
1310
|
+
* @param policyId - Id of the policy.
|
|
1311
|
+
* @param params - `PlatformAuth.WorkspacePolicyUpdateParams`.
|
|
1312
|
+
* @param options - Per-request options.
|
|
1313
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Invalid policy shape, name, or condition block.
|
|
1314
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED, SESSION_REVOKED: Missing or invalid session, or a session that has been signed out (`SESSION_REVOKED`).
|
|
1315
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN, OWNER_ROLE_REQUIRED: Caller lacks `workspace.policy.update`, cannot grant one or more requested actions, or is not an owner and the policy is bound to a role or is a preset policy (`OWNER_ROLE_REQUIRED`).
|
|
1316
|
+
* @throws {NotFoundError} 404 NOT_FOUND, POLICY_NOT_FOUND: Policy not found in this workspace (`POLICY_NOT_FOUND`).
|
|
1317
|
+
* @throws {ConflictError} 409 CONFLICT, POLICY_NAME_TAKEN: Name already in use (`POLICY_NAME_TAKEN`).
|
|
1318
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
1319
|
+
* @see PATCH /v1/workspaces/{workspace_slug}/policies/{policy_id}
|
|
1320
|
+
* @see https://productcraft.co/docs/platform/api-reference#patch-v1-workspaces-workspace-slug-policies-policy-id
|
|
1321
|
+
* @example
|
|
1322
|
+
* ```ts
|
|
1323
|
+
* const managedPolicyDetail = await platform.workspaces.policies.update("workspace", "5d1e2f3a-4b5c-4d6e-8f70-8192a3b4c5d6", { description: "Read-only access to all Mail resources" });
|
|
1324
|
+
* ```
|
|
1325
|
+
*/
|
|
1326
|
+
update(workspaceSlug, policyId, params, options) {
|
|
1327
|
+
return this._client.request({ method: "PATCH", path: "/v1/workspaces/{workspace_slug}/policies/{policy_id}", pathParams: { workspace_slug: workspaceSlug, policy_id: policyId }, body: params }, options);
|
|
1328
|
+
}
|
|
1329
|
+
};
|
|
1330
|
+
var WorkspacesRolesResource = class extends APIResource {
|
|
1331
|
+
/**
|
|
1332
|
+
* Create a new custom role. Cookie/JWT only — role authoring is a human-admin surface.
|
|
1333
|
+
*
|
|
1334
|
+
* @param workspaceSlug - Slug of the workspace. Platform routes name the workspace by slug, positionally in the SDK (`platform.workspaces.retrieve("acme")`); the product APIs bind `workspace_id` instead.
|
|
1335
|
+
* @param params - `PlatformAuth.WorkspaceRoleCreateParams`.
|
|
1336
|
+
* @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
|
|
1337
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR, POLICY_INVALID: Body failed validation, invalid role name, malformed policy, both `policy_id` and `policy` sent, or an action pattern matches no known permission (`POLICY_INVALID`).
|
|
1338
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED, SESSION_REVOKED: Missing, malformed or invalid session, or a PAK bearer (this route accepts cookie/JWT sessions only). Also a session that has been signed out (`SESSION_REVOKED`).
|
|
1339
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN, NOT_A_MEMBER, ACTIONS_NOT_GRANTABLE: Caller is not a member of this workspace (`NOT_A_MEMBER`), lacks `workspace.role.create`, or the policy grants actions the caller does not hold (`ACTIONS_NOT_GRANTABLE`).
|
|
1340
|
+
* @throws {NotFoundError} 404 NOT_FOUND, POLICY_NOT_FOUND: Workspace not found, or `policy_id` not found in this workspace (`POLICY_NOT_FOUND`).
|
|
1341
|
+
* @throws {ConflictError} 409 CONFLICT, ROLE_NAME_TAKEN, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: Role name already in use or reserved for a system role (`ROLE_NAME_TAKEN`). Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
|
|
1342
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
1343
|
+
* @see POST /v1/workspaces/{workspace_slug}/roles
|
|
1344
|
+
* @see https://productcraft.co/docs/platform/api-reference#post-v1-workspaces-workspace-slug-roles
|
|
1345
|
+
* @example
|
|
1346
|
+
* ```ts
|
|
1347
|
+
* const workspaceRole = await platform.workspaces.roles.create("workspace", { name: "BillingAdmin" });
|
|
1348
|
+
* ```
|
|
1349
|
+
*/
|
|
1350
|
+
create(workspaceSlug, params, options) {
|
|
1351
|
+
return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_slug}/roles", pathParams: { workspace_slug: workspaceSlug }, body: params, idempotent: true }, options);
|
|
1352
|
+
}
|
|
1353
|
+
/**
|
|
1354
|
+
* Delete a custom role (fails if it has members). Cookie/JWT only — role authoring is a human-admin surface.
|
|
1355
|
+
*
|
|
1356
|
+
* @param workspaceSlug - Slug of the workspace. Platform routes name the workspace by slug, positionally in the SDK (`platform.workspaces.retrieve("acme")`); the product APIs bind `workspace_id` instead.
|
|
1357
|
+
* @param roleId - Id of the role.
|
|
1358
|
+
* @param options - Per-request options.
|
|
1359
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `roleId` is not a UUID.
|
|
1360
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED, SESSION_REVOKED: Missing, malformed or invalid session, or a PAK bearer (this route accepts cookie/JWT sessions only). Also a session that has been signed out (`SESSION_REVOKED`).
|
|
1361
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN, NOT_A_MEMBER: Caller is not a member of this workspace (`NOT_A_MEMBER`), or lacks `workspace.role.delete`.
|
|
1362
|
+
* @throws {NotFoundError} 404 NOT_FOUND, ROLE_NOT_FOUND: Workspace not found, or role not found in this workspace (`ROLE_NOT_FOUND`).
|
|
1363
|
+
* @throws {ConflictError} 409 CONFLICT, ROLE_SYSTEM_IMMUTABLE, ROLE_HAS_MEMBERS: Role is a system role (`ROLE_SYSTEM_IMMUTABLE`) or still has members (`ROLE_HAS_MEMBERS`).
|
|
1364
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
1365
|
+
* @see DELETE /v1/workspaces/{workspace_slug}/roles/{role_id}
|
|
1366
|
+
* @see https://productcraft.co/docs/platform/api-reference#delete-v1-workspaces-workspace-slug-roles-role-id
|
|
1367
|
+
* @example
|
|
1368
|
+
* ```ts
|
|
1369
|
+
* await platform.workspaces.roles.delete("workspace", "5d1e2f3a-4b5c-4d6e-8f70-8192a3b4c5d6");
|
|
1370
|
+
* ```
|
|
1371
|
+
*/
|
|
1372
|
+
delete(workspaceSlug, roleId, options) {
|
|
1373
|
+
return this._client.request({ method: "DELETE", path: "/v1/workspaces/{workspace_slug}/roles/{role_id}", pathParams: { workspace_slug: workspaceSlug, role_id: roleId } }, options);
|
|
1374
|
+
}
|
|
1375
|
+
/**
|
|
1376
|
+
* List roles in a workspace. System roles first, then alphabetical. 20/page (max 100), cursor-paginated.
|
|
1377
|
+
*
|
|
1378
|
+
* @param workspaceSlug - Slug of the workspace. Platform routes name the workspace by slug, positionally in the SDK (`platform.workspaces.retrieve("acme")`); the product APIs bind `workspace_id` instead.
|
|
1379
|
+
* @param params - `PlatformAuth.WorkspaceRoleListParams`.
|
|
1380
|
+
* @param options - Per-request options.
|
|
1381
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Malformed `cursor`.
|
|
1382
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, invalid or expired bearer token.
|
|
1383
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
1384
|
+
* @see GET /v1/workspaces/{workspace_slug}/roles
|
|
1385
|
+
* @see https://productcraft.co/docs/platform/api-reference#get-v1-workspaces-workspace-slug-roles
|
|
1386
|
+
* @example
|
|
1387
|
+
* ```ts
|
|
1388
|
+
* for await (const role of platform.workspaces.roles.list("workspace")) {
|
|
1389
|
+
* console.log(role);
|
|
1390
|
+
* }
|
|
1391
|
+
* const page = await platform.workspaces.roles.list("workspace", {}, { timeout: 5_000 });
|
|
1392
|
+
* ```
|
|
1393
|
+
*/
|
|
1394
|
+
list(workspaceSlug, params, options) {
|
|
1395
|
+
return this._client.list({ method: "GET", path: "/v1/workspaces/{workspace_slug}/roles", pathParams: { workspace_slug: workspaceSlug }, query: params }, options);
|
|
1396
|
+
}
|
|
1397
|
+
/**
|
|
1398
|
+
* Get a role + its permissions
|
|
1399
|
+
*
|
|
1400
|
+
* @param workspaceSlug - Slug of the workspace. Platform routes name the workspace by slug, positionally in the SDK (`platform.workspaces.retrieve("acme")`); the product APIs bind `workspace_id` instead.
|
|
1401
|
+
* @param roleId - Id of the role.
|
|
1402
|
+
* @param options - Per-request options.
|
|
1403
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `roleId` is not a UUID.
|
|
1404
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, malformed or invalid session, or a PAK bearer (this route accepts cookie/JWT sessions only).
|
|
1405
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN, NOT_A_MEMBER: Caller is not a member of this workspace (`NOT_A_MEMBER`), or lacks `workspace.role.read`.
|
|
1406
|
+
* @throws {NotFoundError} 404 NOT_FOUND, ROLE_NOT_FOUND: Workspace not found, or role not found in this workspace (`ROLE_NOT_FOUND`).
|
|
1407
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
1408
|
+
* @see GET /v1/workspaces/{workspace_slug}/roles/{role_id}
|
|
1409
|
+
* @see https://productcraft.co/docs/platform/api-reference#get-v1-workspaces-workspace-slug-roles-role-id
|
|
1410
|
+
* @example
|
|
1411
|
+
* ```ts
|
|
1412
|
+
* const workspaceRole = await platform.workspaces.roles.retrieve("workspace", "5d1e2f3a-4b5c-4d6e-8f70-8192a3b4c5d6");
|
|
1413
|
+
* ```
|
|
1414
|
+
*/
|
|
1415
|
+
retrieve(workspaceSlug, roleId, options) {
|
|
1416
|
+
return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_slug}/roles/{role_id}", pathParams: { workspace_slug: workspaceSlug, role_id: roleId } }, options);
|
|
1417
|
+
}
|
|
1418
|
+
/**
|
|
1419
|
+
* Update a role or replace its permission set. Cookie/JWT only — role authoring is a human-admin surface.
|
|
1420
|
+
*
|
|
1421
|
+
* @param workspaceSlug - Slug of the workspace. Platform routes name the workspace by slug, positionally in the SDK (`platform.workspaces.retrieve("acme")`); the product APIs bind `workspace_id` instead.
|
|
1422
|
+
* @param roleId - Id of the role.
|
|
1423
|
+
* @param params - `PlatformAuth.WorkspaceRoleUpdateParams`.
|
|
1424
|
+
* @param options - Per-request options.
|
|
1425
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `roleId` is not a UUID, body failed validation, malformed policy, both `policy_id` and `policy` sent, or an action pattern matches no known permission.
|
|
1426
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED, SESSION_REVOKED: Missing, malformed or invalid session, or a PAK bearer (this route accepts cookie/JWT sessions only). Also a session that has been signed out (`SESSION_REVOKED`).
|
|
1427
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN, NOT_A_MEMBER, ACTIONS_NOT_GRANTABLE: Caller is not a member of this workspace (`NOT_A_MEMBER`), lacks `workspace.role.update`, or the policy grants actions the caller does not hold (`ACTIONS_NOT_GRANTABLE`).
|
|
1428
|
+
* @throws {NotFoundError} 404 NOT_FOUND, ROLE_NOT_FOUND, POLICY_NOT_FOUND: Workspace, role (`ROLE_NOT_FOUND`) or bound policy (`POLICY_NOT_FOUND`) not found in this workspace.
|
|
1429
|
+
* @throws {ConflictError} 409 CONFLICT, ROLE_SYSTEM_IMMUTABLE, ROLE_NAME_TAKEN: System roles cannot be renamed, edited or bound (`ROLE_SYSTEM_IMMUTABLE`), or the new name is taken (`ROLE_NAME_TAKEN`).
|
|
1430
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
1431
|
+
* @see PATCH /v1/workspaces/{workspace_slug}/roles/{role_id}
|
|
1432
|
+
* @see https://productcraft.co/docs/platform/api-reference#patch-v1-workspaces-workspace-slug-roles-role-id
|
|
1433
|
+
* @example
|
|
1434
|
+
* ```ts
|
|
1435
|
+
* const workspaceRole = await platform.workspaces.roles.update("workspace", "5d1e2f3a-4b5c-4d6e-8f70-8192a3b4c5d6", { description: "string" });
|
|
1436
|
+
* ```
|
|
1437
|
+
*/
|
|
1438
|
+
update(workspaceSlug, roleId, params, options) {
|
|
1439
|
+
return this._client.request({ method: "PATCH", path: "/v1/workspaces/{workspace_slug}/roles/{role_id}", pathParams: { workspace_slug: workspaceSlug, role_id: roleId }, body: params }, options);
|
|
1440
|
+
}
|
|
1441
|
+
};
|
|
1442
|
+
var WorkspacesServicesResource = class extends APIResource {
|
|
1443
|
+
/**
|
|
1444
|
+
* Disable a service (settings are retained)
|
|
1445
|
+
*
|
|
1446
|
+
* @param workspaceSlug - Slug of the workspace. Platform routes name the workspace by slug, positionally in the SDK (`platform.workspaces.retrieve("acme")`); the product APIs bind `workspace_id` instead.
|
|
1447
|
+
* @param service - The product: `auth`, `mail`, `waitlist`, `social` or `trawl`.
|
|
1448
|
+
* @param options - Per-request options.
|
|
1449
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR, SERVICE_UNKNOWN: Unknown service name (`SERVICE_UNKNOWN`).
|
|
1450
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, malformed or invalid session, or a PAK bearer (this route accepts cookie/JWT sessions only).
|
|
1451
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN, NOT_A_MEMBER: Caller is not a member of this workspace (`NOT_A_MEMBER`), or lacks `workspace.service.disable`.
|
|
1452
|
+
* @throws {NotFoundError} 404 NOT_FOUND: Workspace not found (unknown slug or id).
|
|
1453
|
+
* @throws {ConflictError} 409 CONFLICT, SERVICE_NOT_ENABLED: Service is not currently enabled (`SERVICE_NOT_ENABLED`).
|
|
1454
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
1455
|
+
* @see DELETE /v1/workspaces/{workspace_slug}/services/{service}
|
|
1456
|
+
* @see https://productcraft.co/docs/platform/api-reference#delete-v1-workspaces-workspace-slug-services-service
|
|
1457
|
+
* @example
|
|
1458
|
+
* ```ts
|
|
1459
|
+
* await platform.workspaces.services.disable("workspace", "service");
|
|
1460
|
+
* ```
|
|
1461
|
+
*/
|
|
1462
|
+
disable(workspaceSlug, service, options) {
|
|
1463
|
+
return this._client.request({ method: "DELETE", path: "/v1/workspaces/{workspace_slug}/services/{service}", pathParams: { workspace_slug: workspaceSlug, service } }, options);
|
|
1464
|
+
}
|
|
1465
|
+
/**
|
|
1466
|
+
* Enable (or re-enable) a service for this workspace
|
|
1467
|
+
*
|
|
1468
|
+
* @param workspaceSlug - Slug of the workspace. Platform routes name the workspace by slug, positionally in the SDK (`platform.workspaces.retrieve("acme")`); the product APIs bind `workspace_id` instead.
|
|
1469
|
+
* @param service - The product: `auth`, `mail`, `waitlist`, `social` or `trawl`.
|
|
1470
|
+
* @param params - `PlatformAuth.WorkspaceServiceEnableParams`.
|
|
1471
|
+
* @param options - Per-request options.
|
|
1472
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR, SERVICE_UNKNOWN: Unknown service name (`SERVICE_UNKNOWN`) or body failed validation.
|
|
1473
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, malformed or invalid session, or a PAK bearer (this route accepts cookie/JWT sessions only).
|
|
1474
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN, NOT_A_MEMBER: Caller is not a member of this workspace (`NOT_A_MEMBER`), or lacks `workspace.service.enable`.
|
|
1475
|
+
* @throws {NotFoundError} 404 NOT_FOUND: Workspace not found (unknown slug or id).
|
|
1476
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
1477
|
+
* @see POST /v1/workspaces/{workspace_slug}/services/{service}
|
|
1478
|
+
* @see https://productcraft.co/docs/platform/api-reference#post-v1-workspaces-workspace-slug-services-service
|
|
1479
|
+
* @example
|
|
1480
|
+
* ```ts
|
|
1481
|
+
* const workspaceServiceState = await platform.workspaces.services.enable("workspace", "service", { settings: {} });
|
|
1482
|
+
* ```
|
|
1483
|
+
*/
|
|
1484
|
+
enable(workspaceSlug, service, params, options) {
|
|
1485
|
+
return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_slug}/services/{service}", pathParams: { workspace_slug: workspaceSlug, service }, body: params }, options);
|
|
1486
|
+
}
|
|
1487
|
+
/**
|
|
1488
|
+
* List services activated on this workspace. Complete — one row per product, not paginated.
|
|
1489
|
+
*
|
|
1490
|
+
* @param workspaceSlug - Slug of the workspace. Platform routes name the workspace by slug, positionally in the SDK (`platform.workspaces.retrieve("acme")`); the product APIs bind `workspace_id` instead.
|
|
1491
|
+
* @param options - Per-request options.
|
|
1492
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, malformed or invalid session, or a PAK bearer (this route accepts cookie/JWT sessions only).
|
|
1493
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN, NOT_A_MEMBER: Caller is not a member of this workspace (`NOT_A_MEMBER`), or lacks `workspace.service.read`.
|
|
1494
|
+
* @throws {NotFoundError} 404 NOT_FOUND: Workspace not found (unknown slug or id).
|
|
1495
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
1496
|
+
* @see GET /v1/workspaces/{workspace_slug}/services
|
|
1497
|
+
* @see https://productcraft.co/docs/platform/api-reference#get-v1-workspaces-workspace-slug-services
|
|
1498
|
+
* @example
|
|
1499
|
+
* ```ts
|
|
1500
|
+
* const listWorkspaceServices = await platform.workspaces.services.list("workspace");
|
|
1501
|
+
* ```
|
|
1502
|
+
*/
|
|
1503
|
+
list(workspaceSlug, options) {
|
|
1504
|
+
return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_slug}/services", pathParams: { workspace_slug: workspaceSlug } }, options);
|
|
1505
|
+
}
|
|
1506
|
+
/**
|
|
1507
|
+
* Replace the settings jsonb for an active service
|
|
1508
|
+
*
|
|
1509
|
+
* @param workspaceSlug - Slug of the workspace. Platform routes name the workspace by slug, positionally in the SDK (`platform.workspaces.retrieve("acme")`); the product APIs bind `workspace_id` instead.
|
|
1510
|
+
* @param service - The product: `auth`, `mail`, `waitlist`, `social` or `trawl`.
|
|
1511
|
+
* @param params - `PlatformAuth.WorkspaceServiceUpdateSettingsParams`.
|
|
1512
|
+
* @param options - Per-request options.
|
|
1513
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR, SERVICE_UNKNOWN: Unknown service name (`SERVICE_UNKNOWN`).
|
|
1514
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, malformed or invalid session, or a PAK bearer (this route accepts cookie/JWT sessions only).
|
|
1515
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN, NOT_A_MEMBER: Caller is not a member of this workspace (`NOT_A_MEMBER`), or lacks `workspace.service.enable`.
|
|
1516
|
+
* @throws {NotFoundError} 404 NOT_FOUND, SERVICE_NOT_ACTIVATED: Workspace not found, or the service was never activated on it (`SERVICE_NOT_ACTIVATED`).
|
|
1517
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
1518
|
+
* @see PATCH /v1/workspaces/{workspace_slug}/services/{service}/settings
|
|
1519
|
+
* @see https://productcraft.co/docs/platform/api-reference#patch-v1-workspaces-workspace-slug-services-service-settings
|
|
1520
|
+
* @example
|
|
1521
|
+
* ```ts
|
|
1522
|
+
* const workspaceServiceState = await platform.workspaces.services.updateSettings("workspace", "service", { default_sender: "noreply@acme.com" });
|
|
1523
|
+
* ```
|
|
1524
|
+
*/
|
|
1525
|
+
updateSettings(workspaceSlug, service, params, options) {
|
|
1526
|
+
return this._client.request({ method: "PATCH", path: "/v1/workspaces/{workspace_slug}/services/{service}/settings", pathParams: { workspace_slug: workspaceSlug, service }, body: params }, options);
|
|
1527
|
+
}
|
|
1528
|
+
};
|
|
1529
|
+
var WorkspacesResource = class extends APIResource {
|
|
1530
|
+
#apiKeys;
|
|
1531
|
+
#auditFeed;
|
|
1532
|
+
#auditLogs;
|
|
1533
|
+
#avatar;
|
|
1534
|
+
#invites;
|
|
1535
|
+
#members;
|
|
1536
|
+
#policies;
|
|
1537
|
+
#roles;
|
|
1538
|
+
#services;
|
|
1539
|
+
get apiKeys() {
|
|
1540
|
+
return this.#apiKeys ??= new WorkspacesApiKeysResource(this._client, this._b);
|
|
1541
|
+
}
|
|
1542
|
+
get auditFeed() {
|
|
1543
|
+
return this.#auditFeed ??= new WorkspacesAuditFeedResource(this._client, this._b);
|
|
1544
|
+
}
|
|
1545
|
+
get auditLogs() {
|
|
1546
|
+
return this.#auditLogs ??= new WorkspacesAuditLogsResource(this._client, this._b);
|
|
1547
|
+
}
|
|
1548
|
+
get avatar() {
|
|
1549
|
+
return this.#avatar ??= new WorkspacesAvatarResource(this._client, this._b);
|
|
1550
|
+
}
|
|
1551
|
+
get invites() {
|
|
1552
|
+
return this.#invites ??= new WorkspacesInvitesResource(this._client, this._b);
|
|
1553
|
+
}
|
|
1554
|
+
get members() {
|
|
1555
|
+
return this.#members ??= new WorkspacesMembersResource(this._client, this._b);
|
|
1556
|
+
}
|
|
1557
|
+
get policies() {
|
|
1558
|
+
return this.#policies ??= new WorkspacesPoliciesResource(this._client, this._b);
|
|
1559
|
+
}
|
|
1560
|
+
get roles() {
|
|
1561
|
+
return this.#roles ??= new WorkspacesRolesResource(this._client, this._b);
|
|
1562
|
+
}
|
|
1563
|
+
get services() {
|
|
1564
|
+
return this.#services ??= new WorkspacesServicesResource(this._client, this._b);
|
|
1565
|
+
}
|
|
1566
|
+
/**
|
|
1567
|
+
* Create a new workspace. Cookie/JWT only — PAKs are workspace-scoped credentials and cannot create new workspaces.
|
|
1568
|
+
*
|
|
1569
|
+
* @param params - `PlatformAuth.WorkspaceCreateParams`.
|
|
1570
|
+
* @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
|
|
1571
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, invalid or expired bearer token.
|
|
1572
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN: Caller is a PAK (`pcft_live_*`). Workspace creation requires a human-issued session.
|
|
1573
|
+
* @throws {ConflictError} 409 CONFLICT, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
|
|
1574
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
1575
|
+
* @see POST /v1/workspaces
|
|
1576
|
+
* @see https://productcraft.co/docs/platform/api-reference#post-v1-workspaces
|
|
1577
|
+
* @example
|
|
1578
|
+
* ```ts
|
|
1579
|
+
* const workspace = await platform.workspaces.create({ display_name: "Acme Corp", slug: "acme-corp" });
|
|
1580
|
+
* ```
|
|
1581
|
+
*/
|
|
1582
|
+
create(params, options) {
|
|
1583
|
+
return this._client.request({ method: "POST", path: "/v1/workspaces", body: params, idempotent: true }, options);
|
|
1584
|
+
}
|
|
1585
|
+
/**
|
|
1586
|
+
* Delete a workspace (requires workspace.delete). Cookie/JWT only — irreversible workspace destruction needs a human-attributed audit row.
|
|
1587
|
+
*
|
|
1588
|
+
* @param workspaceSlug - Slug of the workspace. Platform routes name the workspace by slug, positionally in the SDK (`platform.workspaces.retrieve("acme")`); the product APIs bind `workspace_id` instead.
|
|
1589
|
+
* @param options - Per-request options.
|
|
1590
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED, SESSION_REVOKED: Missing or invalid session, or a session that has been signed out (`SESSION_REVOKED`).
|
|
1591
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN: Caller is a PAK (`pcft_live_*`). Workspace deletion requires a human-issued session.
|
|
1592
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
1593
|
+
* @see DELETE /v1/workspaces/{workspace_slug}
|
|
1594
|
+
* @see https://productcraft.co/docs/platform/api-reference#delete-v1-workspaces-workspace-slug
|
|
1595
|
+
* @example
|
|
1596
|
+
* ```ts
|
|
1597
|
+
* await platform.workspaces.delete("workspace");
|
|
1598
|
+
* ```
|
|
1599
|
+
*/
|
|
1600
|
+
delete(workspaceSlug, options) {
|
|
1601
|
+
return this._client.request({ method: "DELETE", path: "/v1/workspaces/{workspace_slug}", pathParams: { workspace_slug: workspaceSlug } }, options);
|
|
1602
|
+
}
|
|
1603
|
+
/**
|
|
1604
|
+
* List workspaces the current user belongs to
|
|
1605
|
+
*
|
|
1606
|
+
* @param params - `PlatformAuth.WorkspaceListParams`.
|
|
1607
|
+
* @param options - Per-request options.
|
|
1608
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Malformed `cursor`.
|
|
1609
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Missing or invalid session.
|
|
1610
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
1611
|
+
* @see GET /v1/workspaces
|
|
1612
|
+
* @see https://productcraft.co/docs/platform/api-reference#get-v1-workspaces
|
|
1613
|
+
* @example
|
|
1614
|
+
* ```ts
|
|
1615
|
+
* for await (const workspace of platform.workspaces.list()) {
|
|
1616
|
+
* console.log(workspace);
|
|
1617
|
+
* }
|
|
1618
|
+
* const page = await platform.workspaces.list({}, { timeout: 5_000 });
|
|
1619
|
+
* ```
|
|
1620
|
+
*/
|
|
1621
|
+
list(params, options) {
|
|
1622
|
+
return this._client.list({ method: "GET", path: "/v1/workspaces", query: params }, options);
|
|
1623
|
+
}
|
|
1624
|
+
/**
|
|
1625
|
+
* Get workspace details
|
|
1626
|
+
*
|
|
1627
|
+
* @param workspaceSlug - Slug of the workspace. Platform routes name the workspace by slug, positionally in the SDK (`platform.workspaces.retrieve("acme")`); the product APIs bind `workspace_id` instead.
|
|
1628
|
+
* @param options - Per-request options.
|
|
1629
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Missing or invalid session.
|
|
1630
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN, NOT_A_MEMBER: Caller is not a member of this workspace (`NOT_A_MEMBER`).
|
|
1631
|
+
* @throws {NotFoundError} 404 NOT_FOUND: Workspace not found (unknown slug or id).
|
|
1632
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
1633
|
+
* @see GET /v1/workspaces/{workspace_slug}
|
|
1634
|
+
* @see https://productcraft.co/docs/platform/api-reference#get-v1-workspaces-workspace-slug
|
|
1635
|
+
* @example
|
|
1636
|
+
* ```ts
|
|
1637
|
+
* const workspace = await platform.workspaces.retrieve("workspace");
|
|
1638
|
+
* ```
|
|
1639
|
+
*/
|
|
1640
|
+
retrieve(workspaceSlug, options) {
|
|
1641
|
+
return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_slug}", pathParams: { workspace_slug: workspaceSlug } }, options);
|
|
1642
|
+
}
|
|
1643
|
+
/**
|
|
1644
|
+
* Update workspace display name, slug, or settings. Slug renames broadcast a `workspace.renamed` event so denormalised consumers (waitlist-api) sync.
|
|
1645
|
+
*
|
|
1646
|
+
* @param workspaceSlug - Slug of the workspace. Platform routes name the workspace by slug, positionally in the SDK (`platform.workspaces.retrieve("acme")`); the product APIs bind `workspace_id` instead.
|
|
1647
|
+
* @param params - `PlatformAuth.WorkspaceUpdateParams`.
|
|
1648
|
+
* @param options - Per-request options.
|
|
1649
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: Invalid slug or display name.
|
|
1650
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, invalid or expired bearer token.
|
|
1651
|
+
* @throws {NotFoundError} 404 NOT_FOUND: Workspace not found.
|
|
1652
|
+
* @throws {ConflictError} 409 CONFLICT: Slug already taken by another workspace.
|
|
1653
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: Rate limited: too many requests from this client IP in the last 60 seconds (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
1654
|
+
* @see PATCH /v1/workspaces/{workspace_slug}
|
|
1655
|
+
* @see https://productcraft.co/docs/platform/api-reference#patch-v1-workspaces-workspace-slug
|
|
1656
|
+
* @example
|
|
1657
|
+
* ```ts
|
|
1658
|
+
* const workspace = await platform.workspaces.update("workspace", { display_name: "string" });
|
|
1659
|
+
* ```
|
|
1660
|
+
*/
|
|
1661
|
+
update(workspaceSlug, params, options) {
|
|
1662
|
+
return this._client.request({ method: "PATCH", path: "/v1/workspaces/{workspace_slug}", pathParams: { workspace_slug: workspaceSlug }, body: params }, options);
|
|
1663
|
+
}
|
|
1664
|
+
};
|
|
1665
|
+
var PlatformAuthResources = class extends APIResource {
|
|
1666
|
+
#account;
|
|
1667
|
+
#apiKeys;
|
|
1668
|
+
#auth;
|
|
1669
|
+
#introspect;
|
|
1670
|
+
#me;
|
|
1671
|
+
#oauth;
|
|
1672
|
+
#sessions;
|
|
1673
|
+
#stats;
|
|
1674
|
+
#verification;
|
|
1675
|
+
#wellKnown;
|
|
1676
|
+
#workspaces;
|
|
1677
|
+
get account() {
|
|
1678
|
+
return this.#account ??= new AccountResource(this._client, this._b);
|
|
1679
|
+
}
|
|
1680
|
+
get apiKeys() {
|
|
1681
|
+
return this.#apiKeys ??= new ApiKeysResource(this._client, this._b);
|
|
1682
|
+
}
|
|
1683
|
+
get auth() {
|
|
1684
|
+
return this.#auth ??= new AuthResource(this._client, this._b);
|
|
1685
|
+
}
|
|
1686
|
+
get introspect() {
|
|
1687
|
+
return this.#introspect ??= new IntrospectResource(this._client, this._b);
|
|
1688
|
+
}
|
|
1689
|
+
get me() {
|
|
1690
|
+
return this.#me ??= new MeResource(this._client, this._b);
|
|
1691
|
+
}
|
|
1692
|
+
get oauth() {
|
|
1693
|
+
return this.#oauth ??= new OauthResource(this._client, this._b);
|
|
1694
|
+
}
|
|
1695
|
+
get sessions() {
|
|
1696
|
+
return this.#sessions ??= new SessionsResource(this._client, this._b);
|
|
1697
|
+
}
|
|
1698
|
+
get stats() {
|
|
1699
|
+
return this.#stats ??= new StatsResource(this._client, this._b);
|
|
1700
|
+
}
|
|
1701
|
+
get verification() {
|
|
1702
|
+
return this.#verification ??= new VerificationResource(this._client, this._b);
|
|
1703
|
+
}
|
|
1704
|
+
get wellKnown() {
|
|
1705
|
+
return this.#wellKnown ??= new WellKnownResource(this._client, this._b);
|
|
1706
|
+
}
|
|
1707
|
+
get workspaces() {
|
|
1708
|
+
return this.#workspaces ??= new WorkspacesResource(this._client, this._b);
|
|
1709
|
+
}
|
|
1710
|
+
};
|
|
1711
|
+
|
|
1712
|
+
// src/_generated/types.ts
|
|
1713
|
+
var ApiKeyPresetKey = { values: ["mail-send", "waitlist-write", "trawl-jobs", "readonly", "full"] };
|
|
1714
|
+
var ApiKeyStatus = { values: ["active", "expired", "revoked"] };
|
|
1715
|
+
var AuditActorType = { values: ["platform_user", "system", "pat"] };
|
|
1716
|
+
var AuditFeedSource = { values: ["workspace_audit", "heimdall_audit", "agora_moderation"] };
|
|
1717
|
+
var McpProduct = { values: ["auth", "mail", "waitlist", "social", "trawl"] };
|
|
1718
|
+
var PolicyEffect = { values: ["allow", "deny"] };
|
|
1719
|
+
var StatsGranularity = { values: ["day"] };
|
|
1720
|
+
var StatsMetric = { values: ["audit_events"] };
|
|
1721
|
+
var StatsWindow = { values: ["1d", "7d", "30d"] };
|
|
1722
|
+
|
|
1723
|
+
// src/_generated/client.ts
|
|
1724
|
+
var VERSION = "1.0.0" ;
|
|
1725
|
+
var PlatformAuth = class extends PlatformAuthResources {
|
|
1726
|
+
#openapi;
|
|
1727
|
+
constructor(options = {}) {
|
|
1728
|
+
super(new APIClient(options, PC_BASE_URL.platformAuth, { name: "platform-auth", version: VERSION }));
|
|
1729
|
+
}
|
|
1730
|
+
/** The typed `openapi-fetch` escape hatch over the same credential and base URL. It does not retry. */
|
|
1731
|
+
get client() {
|
|
1732
|
+
return this.#openapi ??= createOpenAPIClient(this._client);
|
|
9
1733
|
}
|
|
10
1734
|
};
|
|
1735
|
+
((PlatformAuth2) => {
|
|
1736
|
+
PlatformAuth2.ApiKeyPresetKey = ApiKeyPresetKey;
|
|
1737
|
+
PlatformAuth2.ApiKeyStatus = ApiKeyStatus;
|
|
1738
|
+
PlatformAuth2.AuditActorType = AuditActorType;
|
|
1739
|
+
PlatformAuth2.AuditFeedSource = AuditFeedSource;
|
|
1740
|
+
PlatformAuth2.McpProduct = McpProduct;
|
|
1741
|
+
PlatformAuth2.PolicyEffect = PolicyEffect;
|
|
1742
|
+
PlatformAuth2.StatsGranularity = StatsGranularity;
|
|
1743
|
+
PlatformAuth2.StatsMetric = StatsMetric;
|
|
1744
|
+
PlatformAuth2.StatsWindow = StatsWindow;
|
|
1745
|
+
})(PlatformAuth || (PlatformAuth = {}));
|
|
1746
|
+
var PlatformAuthErrorCode = { values: ["BAD_REQUEST", "VALIDATION_ERROR", "UNAUTHORIZED", "PAYMENT_REQUIRED", "FORBIDDEN", "NOT_FOUND", "METHOD_NOT_ALLOWED", "NOT_ACCEPTABLE", "REQUEST_TIMEOUT", "CONFLICT", "GONE", "PRECONDITION_FAILED", "PAYLOAD_TOO_LARGE", "UNSUPPORTED_MEDIA_TYPE", "UNPROCESSABLE_ENTITY", "PRECONDITION_REQUIRED", "RATE_LIMITED", "INTERNAL_SERVER_ERROR", "NOT_IMPLEMENTED", "BAD_GATEWAY", "SERVICE_UNAVAILABLE", "GATEWAY_TIMEOUT", "SERVICE_NOT_ENABLED", "INVALID_CREDENTIALS", "SESSION_REVOKED", "MCP_NOT_PERMITTED", "MCP_WORKSPACE_MISMATCH", "PAK_NOT_PERMITTED", "ACTIONS_NOT_GRANTABLE", "IDEMPOTENCY_KEY_REUSE", "IDEMPOTENCY_KEY_REQUIRED", "IDEMPOTENCY_IN_PROGRESS", "WEBHOOK_ENDPOINT_LIMIT", "WEBHOOK_ENDPOINT_NOT_FOUND", "WEBHOOK_ENDPOINT_NOT_SUBSCRIBED", "WEBHOOK_EVENT_NOT_FOUND", "WEBHOOK_EVENT_TYPE_UNKNOWN", "ACCOUNT_DEACTIVATED", "ACCOUNT_SUSPENDED", "ALREADY_A_MEMBER", "CROSS_ORIGIN_REJECTED", "EMAIL_NOT_VERIFIED", "INVITE_EMAIL_MISMATCH", "INVITE_EXHAUSTED", "INVITE_EXPIRED", "INVITE_INVALID", "INVITE_NOT_FOUND", "INVITE_REVOKED", "LAST_MEMBER", "MEMBER_RANK_EXCEEDED", "NOT_A_MEMBER", "OAUTH_GRANT_ADMIN_REVOKED", "OWNER_ROLE_REQUIRED", "PAK_ALREADY_MINTED", "PAK_EXPIRED", "PAK_NAME_REQUIRED", "PAK_NAME_TOO_LONG", "PAK_NOT_FOUND", "PAK_REVOKED", "PASSWORD_RESET_INVALID", "POLICY_INVALID", "POLICY_NAME_TAKEN", "POLICY_NOT_FOUND", "ROLE_HAS_MEMBERS", "ROLE_NAME_TAKEN", "ROLE_NOT_FOUND", "ROLE_SYSTEM_IMMUTABLE", "SERVICE_NOT_ACTIVATED", "SERVICE_UNKNOWN", "SOLE_OWNER", "TOO_MANY_ATTEMPTS", "WORKSPACE_KEY_REQUIRED"] };
|
|
11
1747
|
|
|
12
|
-
export { PlatformAuth };
|
|
1748
|
+
export { PlatformAuth, PlatformAuthErrorCode, PlatformAuth as default };
|
|
13
1749
|
//# sourceMappingURL=index.js.map
|
|
14
1750
|
//# sourceMappingURL=index.js.map
|