@sovaria/sdk 0.0.0-stage → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +248 -2
- package/dist/analytics.d.ts +92 -0
- package/dist/analytics.js +236 -0
- package/dist/client.d.ts +146 -0
- package/dist/client.js +583 -0
- package/dist/collections.d.ts +255 -0
- package/dist/collections.js +569 -0
- package/dist/complete-api.d.ts +54 -0
- package/dist/complete-api.js +71 -0
- package/dist/crashes.d.ts +111 -0
- package/dist/crashes.js +244 -0
- package/dist/crypto.d.ts +37 -0
- package/dist/crypto.js +189 -0
- package/dist/errors.d.ts +40 -0
- package/dist/errors.js +258 -0
- package/dist/firestore.d.ts +239 -0
- package/dist/firestore.js +431 -0
- package/dist/generated.d.ts +2462 -0
- package/dist/generated.js +1962 -0
- package/dist/inapp.d.ts +52 -0
- package/dist/inapp.js +48 -0
- package/dist/index.d.ts +3562 -0
- package/dist/index.js +3018 -0
- package/dist/offline.d.ts +92 -0
- package/dist/offline.js +575 -0
- package/dist/passkeys.d.ts +17 -0
- package/dist/passkeys.js +76 -0
- package/dist/perf.d.ts +76 -0
- package/dist/perf.js +212 -0
- package/dist/remote-config.d.ts +87 -0
- package/dist/remote-config.js +182 -0
- package/dist/types.d.ts +102 -0
- package/dist/types.js +1 -0
- package/dist/webpush.d.ts +46 -0
- package/dist/webpush.js +99 -0
- package/package.json +74 -4
|
@@ -0,0 +1,1962 @@
|
|
|
1
|
+
function dropUndefined(obj) {
|
|
2
|
+
return Object.fromEntries(Object.entries(obj).filter(([, v]) => v !== undefined && v !== null));
|
|
3
|
+
}
|
|
4
|
+
function need(name, value) {
|
|
5
|
+
const text = String(value ?? '').trim();
|
|
6
|
+
if (!text)
|
|
7
|
+
throw new Error(`${name} is required`);
|
|
8
|
+
return text;
|
|
9
|
+
}
|
|
10
|
+
/** Every Sovaria API operation, grouped by module. */
|
|
11
|
+
export function createGeneratedApi(request, scope) {
|
|
12
|
+
return {
|
|
13
|
+
ai: {
|
|
14
|
+
/** Model-gateway routes, the models they may use, plan limits and cache size. `GET /api/v1/sovariq/gateway` */
|
|
15
|
+
gatewayOverview: () => request('GET', `/api/v1/sovariq/gateway`),
|
|
16
|
+
/** Create or change a route: models in order (fallbacks), retry_on, cache {enabled, ttl_s}, access, daily_requests_per_user. `PUT /api/v1/sovariq/gateway/routes/{name}` */
|
|
17
|
+
saveGatewayRoute: (args) => {
|
|
18
|
+
const name = need('name', args.name);
|
|
19
|
+
return request('PUT', `/api/v1/sovariq/gateway/routes/${encodeURIComponent(name)}`, { body: args.body });
|
|
20
|
+
},
|
|
21
|
+
/** Delete a route (refused while an agent uses it). `DELETE /api/v1/sovariq/gateway/routes/{name}` */
|
|
22
|
+
deleteGatewayRoute: (args) => {
|
|
23
|
+
const name = need('name', args.name);
|
|
24
|
+
return request('DELETE', `/api/v1/sovariq/gateway/routes/${encodeURIComponent(name)}`);
|
|
25
|
+
},
|
|
26
|
+
/** One completion on a route: the first model that answers (fallbacks), or the cache. `POST /api/v1/sovariq/gateway/{route}/complete` */
|
|
27
|
+
gatewayComplete: (args) => {
|
|
28
|
+
const route = need('route', args.route);
|
|
29
|
+
return request('POST', `/api/v1/sovariq/gateway/${encodeURIComponent(route)}/complete`, { body: dropUndefined({ "messages": args.messages, "system": args.system, "max_tokens": args.maxTokens, "cache": args.cache }) });
|
|
30
|
+
},
|
|
31
|
+
/** Requests, errors, fallbacks, cache hits, tokens and latency per model and route. `GET /api/v1/sovariq/gateway/usage` */
|
|
32
|
+
gatewayUsage: (args = {}) => request('GET', `/api/v1/sovariq/gateway/usage`, { query: dropUndefined({ "days": args.days }) }),
|
|
33
|
+
/** Drop every cached model response of the project. `POST /api/v1/sovariq/gateway/cache/clear` */
|
|
34
|
+
clearGatewayCache: () => request('POST', `/api/v1/sovariq/gateway/cache/clear`, { body: {} }),
|
|
35
|
+
/** An agent's published version and kept versions. `GET /api/v1/sovariq/agents/{agent_id}/versions` */
|
|
36
|
+
listAgentVersions: (args) => {
|
|
37
|
+
const agentId = need('agent_id', args.agentId);
|
|
38
|
+
return request('GET', `/api/v1/sovariq/agents/${encodeURIComponent(agentId)}/versions`);
|
|
39
|
+
},
|
|
40
|
+
/** Publish the agent's draft as its next version. `POST /api/v1/sovariq/agents/{agent_id}/versions` */
|
|
41
|
+
publishAgentVersion: (args) => {
|
|
42
|
+
const agentId = need('agent_id', args.agentId);
|
|
43
|
+
return request('POST', `/api/v1/sovariq/agents/${encodeURIComponent(agentId)}/versions`, { body: dropUndefined({ "note": args.note }) });
|
|
44
|
+
},
|
|
45
|
+
/** One version's definition (secrets hidden). `GET /api/v1/sovariq/agents/{agent_id}/versions/{version}` */
|
|
46
|
+
getAgentVersion: (args) => {
|
|
47
|
+
const agentId = need('agent_id', args.agentId);
|
|
48
|
+
const version = need('version', args.version);
|
|
49
|
+
return request('GET', `/api/v1/sovariq/agents/${encodeURIComponent(agentId)}/versions/${encodeURIComponent(version)}`);
|
|
50
|
+
},
|
|
51
|
+
/** What changed between two versions (or a version and the draft). `GET /api/v1/sovariq/agents/{agent_id}/versions/compare` */
|
|
52
|
+
compareAgentVersions: (args) => {
|
|
53
|
+
const agentId = need('agent_id', args.agentId);
|
|
54
|
+
return request('GET', `/api/v1/sovariq/agents/${encodeURIComponent(agentId)}/versions/compare`, { query: dropUndefined({ "a": args.a, "b": args.b }) });
|
|
55
|
+
},
|
|
56
|
+
/** Republish an older version as a new version and make it the draft. `POST /api/v1/sovariq/agents/{agent_id}/versions/{version}/rollback` */
|
|
57
|
+
rollbackAgentVersion: (args) => {
|
|
58
|
+
const agentId = need('agent_id', args.agentId);
|
|
59
|
+
const version = need('version', args.version);
|
|
60
|
+
return request('POST', `/api/v1/sovariq/agents/${encodeURIComponent(agentId)}/versions/${encodeURIComponent(version)}/rollback`, { body: dropUndefined({ "note": args.note }) });
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
analytics: {
|
|
64
|
+
/** DAU, WAU, MAU, events, new users, top events, platforms and countries over the last days (capped by analytics.retention_days). `GET /api/v1/analytics/overview` */
|
|
65
|
+
overview: (args = {}) => request('GET', `/api/v1/analytics/overview`, { query: dropUndefined({ "days": args.days }) }),
|
|
66
|
+
/** Event names with counts over the last days. `GET /api/v1/analytics/events` */
|
|
67
|
+
listEvents: (args = {}) => request('GET', `/api/v1/analytics/events`, { query: dropUndefined({ "days": args.days }) }),
|
|
68
|
+
/** Daily count and distinct users of one event, and its common properties. `GET /api/v1/analytics/events/{name}/trend` */
|
|
69
|
+
eventTrend: (args) => {
|
|
70
|
+
const name = need('name', args.name);
|
|
71
|
+
return request('GET', `/api/v1/analytics/events/${encodeURIComponent(name)}/trend`, { query: dropUndefined({ "days": args.days }) });
|
|
72
|
+
},
|
|
73
|
+
/** Ordered funnel: users who did each step after the previous one within window_hours of step 1 (steps: [{name, where?}]). `POST /api/v1/analytics/funnel` */
|
|
74
|
+
funnel: (args) => request('POST', `/api/v1/analytics/funnel`, { body: dropUndefined({ "steps": args.steps, "window_hours": args.windowHours, "days": args.days }) }),
|
|
75
|
+
/** Retention cohorts by first activity (or start_event), share active (or doing return_event) in each later week or day. `GET /api/v1/analytics/retention` */
|
|
76
|
+
retention: (args = {}) => request('GET', `/api/v1/analytics/retention`, { query: dropUndefined({ "start_event": args.startEvent, "return_event": args.returnEvent, "period": args.period, "periods": args.periods }) }),
|
|
77
|
+
/** Recently seen app users with their properties (q: prefix of user key or id). `GET /api/v1/analytics/users` */
|
|
78
|
+
listUsers: (args = {}) => request('GET', `/api/v1/analytics/users`, { query: dropUndefined({ "q": args.q, "limit": args.limit }) }),
|
|
79
|
+
/** One app user: profile, consent and their latest events. `GET /api/v1/analytics/users/{user_key}` */
|
|
80
|
+
getUser: (args) => {
|
|
81
|
+
const userKey = need('user_key', args.userKey);
|
|
82
|
+
return request('GET', `/api/v1/analytics/users/${encodeURIComponent(userKey)}`, { query: dropUndefined({ "limit": args.limit }) });
|
|
83
|
+
},
|
|
84
|
+
/** Erase one app user's analytics (events, properties, activity) and record that they opted out. `DELETE /api/v1/analytics/users/{user_key}` */
|
|
85
|
+
eraseUser: (args) => {
|
|
86
|
+
const userKey = need('user_key', args.userKey);
|
|
87
|
+
return request('DELETE', `/api/v1/analytics/users/${encodeURIComponent(userKey)}`);
|
|
88
|
+
},
|
|
89
|
+
/** Newest events received (debug view), optionally since an ISO time. `GET /api/v1/analytics/live` */
|
|
90
|
+
live: (args = {}) => request('GET', `/api/v1/analytics/live`, { query: dropUndefined({ "since": args.since, "limit": args.limit }) }),
|
|
91
|
+
/** Analytics events accepted and dropped this month, and the plan's limits. `GET /api/v1/analytics/usage` */
|
|
92
|
+
usage: () => request('GET', `/api/v1/analytics/usage`),
|
|
93
|
+
/** Project analytics settings (require consent) and whether staff turned analytics off. `GET /api/v1/analytics/settings` */
|
|
94
|
+
getSettings: () => request('GET', `/api/v1/analytics/settings`),
|
|
95
|
+
/** Require consent: only app users who said yes (PUT /analytics/v1/consent) are recorded. `PUT /api/v1/analytics/settings` */
|
|
96
|
+
putSettings: (args) => request('PUT', `/api/v1/analytics/settings`, { body: dropUndefined({ "require_consent": args.requireConsent }) }),
|
|
97
|
+
},
|
|
98
|
+
attestation: {
|
|
99
|
+
/** App attestation settings, credentials (metadata only), debug tokens and the last 7 days. `GET /api/v1/projects/{project_id}/attestation` */
|
|
100
|
+
getConfig: (args = {}) => {
|
|
101
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
102
|
+
return request('GET', `/api/v1/projects/${encodeURIComponent(projectId)}/attestation`);
|
|
103
|
+
},
|
|
104
|
+
/** Set mode (off | monitor | enforce), tokenTtlSeconds, providers, playIntegrity, appAttest. `PUT /api/v1/projects/{project_id}/attestation` */
|
|
105
|
+
updateConfig: (args) => {
|
|
106
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
107
|
+
return request('PUT', `/api/v1/projects/${encodeURIComponent(projectId)}/attestation`, { body: args.body });
|
|
108
|
+
},
|
|
109
|
+
/** Google service account for Play Integrity (encrypted, write-only). `PUT /api/v1/projects/{project_id}/attestation/credentials/google` */
|
|
110
|
+
setGoogleCredentials: (args) => {
|
|
111
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
112
|
+
return request('PUT', `/api/v1/projects/${encodeURIComponent(projectId)}/attestation/credentials/google`, { body: dropUndefined({ "service_account": args.serviceAccount }) });
|
|
113
|
+
},
|
|
114
|
+
/** Apple key with DeviceCheck enabled (encrypted, write-only). `PUT /api/v1/projects/{project_id}/attestation/credentials/apple` */
|
|
115
|
+
setAppleCredentials: (args) => {
|
|
116
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
117
|
+
return request('PUT', `/api/v1/projects/${encodeURIComponent(projectId)}/attestation/credentials/apple`, { body: dropUndefined({ "p8": args.p8, "key_id": args.keyId, "team_id": args.teamId }) });
|
|
118
|
+
},
|
|
119
|
+
/** Remove the google or apple attestation credentials. `DELETE /api/v1/projects/{project_id}/attestation/credentials/{which}` */
|
|
120
|
+
deleteCredentials: (args) => {
|
|
121
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
122
|
+
const which = need('which', args.which);
|
|
123
|
+
return request('DELETE', `/api/v1/projects/${encodeURIComponent(projectId)}/attestation/credentials/${encodeURIComponent(which)}`);
|
|
124
|
+
},
|
|
125
|
+
/** Create a debug token for simulators and CI (shown once). `POST /api/v1/projects/{project_id}/attestation/debug-tokens` */
|
|
126
|
+
createDebugToken: (args = {}) => {
|
|
127
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
128
|
+
return request('POST', `/api/v1/projects/${encodeURIComponent(projectId)}/attestation/debug-tokens`, { body: dropUndefined({ "name": args.name }) });
|
|
129
|
+
},
|
|
130
|
+
/** Delete a debug token. `DELETE /api/v1/projects/{project_id}/attestation/debug-tokens/{token_id}` */
|
|
131
|
+
deleteDebugToken: (args) => {
|
|
132
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
133
|
+
const tokenId = need('token_id', args.tokenId);
|
|
134
|
+
return request('DELETE', `/api/v1/projects/${encodeURIComponent(projectId)}/attestation/debug-tokens/${encodeURIComponent(tokenId)}`);
|
|
135
|
+
},
|
|
136
|
+
/** One-time challenge to bind attestation evidence to (anon key). `POST /api/v1/attest/challenge` */
|
|
137
|
+
challenge: () => request('POST', `/api/v1/attest/challenge`, { body: {} }),
|
|
138
|
+
/** Exchange Play Integrity / App Attest / DeviceCheck / debug evidence for an attestation token. `POST /api/v1/attest/exchange` */
|
|
139
|
+
exchange: (args) => request('POST', `/api/v1/attest/exchange`, { body: dropUndefined({ "provider": args.provider, "app_id": args.appId, "challenge": args.challenge, "token": args.token, "key_id": args.keyId, "attestation": args.attestation, "assertion": args.assertion, "development": args.development }) }),
|
|
140
|
+
},
|
|
141
|
+
auth: {
|
|
142
|
+
/** Confirm an email verification token. `POST /api/v1/auth/verify-email/confirm` */
|
|
143
|
+
confirmVerificationEmail: (args) => request('POST', `/api/v1/auth/verify-email/confirm`, { body: dropUndefined({ "token": args.token }), requiresAuth: false }),
|
|
144
|
+
/** `DELETE /api/v1/auth/mfa` */
|
|
145
|
+
disableMfa: (args) => request('DELETE', `/api/v1/auth/mfa`, { body: dropUndefined({ "totp_code": args.totpCode }) }),
|
|
146
|
+
/** `POST /api/v1/auth/mfa/enroll` */
|
|
147
|
+
enrollMfa: () => request('POST', `/api/v1/auth/mfa/enroll`, { body: {} }),
|
|
148
|
+
/** `GET /api/v1/auth/mfa/status` */
|
|
149
|
+
getMfaStatus: () => request('GET', `/api/v1/auth/mfa/status`),
|
|
150
|
+
/** `GET /api/v1/auth/providers/config` */
|
|
151
|
+
getProvidersConfig: () => request('GET', `/api/v1/auth/providers/config`),
|
|
152
|
+
/** `GET /api/v1/auth/sessions/config` */
|
|
153
|
+
getSessionsConfig: () => request('GET', `/api/v1/auth/sessions/config`),
|
|
154
|
+
/** `GET /api/v1/auth/product-users` */
|
|
155
|
+
listConsoleProductUsers: () => request('GET', `/api/v1/auth/product-users`),
|
|
156
|
+
/** `GET /api/v1/auth/sessions` */
|
|
157
|
+
listSessions: () => request('GET', `/api/v1/auth/sessions`),
|
|
158
|
+
/** `POST /api/v1/auth/sessions/revoke-others` */
|
|
159
|
+
revokeOtherSessions: () => request('POST', `/api/v1/auth/sessions/revoke-others`, { body: {} }),
|
|
160
|
+
/** `DELETE /api/v1/auth/sessions/{session_id}` */
|
|
161
|
+
revokeSession: (args) => {
|
|
162
|
+
const sessionId = need('session_id', args.sessionId);
|
|
163
|
+
return request('DELETE', `/api/v1/auth/sessions/${encodeURIComponent(sessionId)}`);
|
|
164
|
+
},
|
|
165
|
+
/** Trigger a verification email for the authenticated user. `POST /api/v1/auth/verify-email/send` */
|
|
166
|
+
sendVerificationEmail: () => request('POST', `/api/v1/auth/verify-email/send`, { body: {} }),
|
|
167
|
+
/** `PUT /api/v1/auth/providers/config` */
|
|
168
|
+
updateProvidersConfig: (args) => request('PUT', `/api/v1/auth/providers/config`, { body: args.body }),
|
|
169
|
+
/** `PUT /api/v1/auth/sessions/config` */
|
|
170
|
+
updateSessionsConfig: (args) => request('PUT', `/api/v1/auth/sessions/config`, { body: args.body }),
|
|
171
|
+
/** Devices the signed-in user is signed in on (current = this one). `GET /api/v1/auth/devices` */
|
|
172
|
+
listDevices: () => request('GET', `/api/v1/auth/devices`),
|
|
173
|
+
/** Sign one device out: its sessions end and push tokens are removed. `DELETE /api/v1/auth/devices/{device_id}` */
|
|
174
|
+
signOutDevice: (args) => {
|
|
175
|
+
const deviceId = need('device_id', args.deviceId);
|
|
176
|
+
return request('DELETE', `/api/v1/auth/devices/${encodeURIComponent(deviceId)}`);
|
|
177
|
+
},
|
|
178
|
+
/** Registration options for a new passkey for the signed-in user. `POST /api/v1/auth/passkeys/register/start` */
|
|
179
|
+
passkeyRegisterStart: (args = {}) => request('POST', `/api/v1/auth/passkeys/register/start`, { body: dropUndefined({ "name": args.name }) }),
|
|
180
|
+
/** Save a passkey from the authenticator's WebAuthn JSON. `POST /api/v1/auth/passkeys/register/finish` */
|
|
181
|
+
passkeyRegisterFinish: (args) => request('POST', `/api/v1/auth/passkeys/register/finish`, { body: dropUndefined({ "credential": args.credential, "name": args.name }) }),
|
|
182
|
+
/** Passkey sign-in options: challenge_id and options. `POST /api/v1/auth/passkeys/authenticate/start` */
|
|
183
|
+
passkeyAuthenticateStart: (args = {}) => request('POST', `/api/v1/auth/passkeys/authenticate/start`, { body: dropUndefined({ "user_id": args.userId }), requiresAuth: false }),
|
|
184
|
+
/** Verify a signed passkey challenge and return a session. `POST /api/v1/auth/passkeys/authenticate/finish` */
|
|
185
|
+
passkeyAuthenticateFinish: (args) => request('POST', `/api/v1/auth/passkeys/authenticate/finish`, { body: dropUndefined({ "challenge_id": args.challengeId, "credential": args.credential }), requiresAuth: false }),
|
|
186
|
+
/** The signed-in user's passkeys. `GET /api/v1/auth/passkeys` */
|
|
187
|
+
listPasskeys: () => request('GET', `/api/v1/auth/passkeys`),
|
|
188
|
+
/** Remove one of the signed-in user's passkeys. `DELETE /api/v1/auth/passkeys/{passkey_id}` */
|
|
189
|
+
deletePasskey: (args) => {
|
|
190
|
+
const passkeyId = need('passkey_id', args.passkeyId);
|
|
191
|
+
return request('DELETE', `/api/v1/auth/passkeys/${encodeURIComponent(passkeyId)}`);
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
billing: {
|
|
195
|
+
/** `POST /api/v1/invoices/{org_id}/build` */
|
|
196
|
+
buildInvoice: (args = {}) => {
|
|
197
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
198
|
+
return request('POST', `/api/v1/invoices/${encodeURIComponent(orgId)}/build`, { query: dropUndefined({ "period": args.period }) });
|
|
199
|
+
},
|
|
200
|
+
/** `POST /api/v1/accounts/{account_id}/cancel` */
|
|
201
|
+
cancelAccount: (args) => {
|
|
202
|
+
const accountId = need('account_id', args.accountId);
|
|
203
|
+
return request('POST', `/api/v1/accounts/${encodeURIComponent(accountId)}/cancel`);
|
|
204
|
+
},
|
|
205
|
+
/** `POST /api/v1/billing/checkout` */
|
|
206
|
+
checkout: (args) => request('POST', `/api/v1/billing/checkout`, { body: args.body }),
|
|
207
|
+
/** `GET /api/v1/accounts/{account_id}` */
|
|
208
|
+
getAccount: (args) => {
|
|
209
|
+
const accountId = need('account_id', args.accountId);
|
|
210
|
+
return request('GET', `/api/v1/accounts/${encodeURIComponent(accountId)}`);
|
|
211
|
+
},
|
|
212
|
+
/** `GET /api/v1/billing/accounts/{account_id}/overage` */
|
|
213
|
+
getAccountOverage: (args) => {
|
|
214
|
+
const accountId = need('account_id', args.accountId);
|
|
215
|
+
return request('GET', `/api/v1/billing/accounts/${encodeURIComponent(accountId)}/overage`);
|
|
216
|
+
},
|
|
217
|
+
/** `GET /api/v1/billing/accounts/{account_id}/overage-prefs` */
|
|
218
|
+
getAccountOveragePrefs: (args) => {
|
|
219
|
+
const accountId = need('account_id', args.accountId);
|
|
220
|
+
return request('GET', `/api/v1/billing/accounts/${encodeURIComponent(accountId)}/overage-prefs`);
|
|
221
|
+
},
|
|
222
|
+
/** The org's overage switches (one setting for the whole org) `GET /api/v1/billing/orgs/{org_id}/overage-prefs` */
|
|
223
|
+
getOrgOveragePrefs: (args = {}) => {
|
|
224
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
225
|
+
return request('GET', `/api/v1/billing/orgs/${encodeURIComponent(orgId)}/overage-prefs`);
|
|
226
|
+
},
|
|
227
|
+
/** `GET /api/v1/compute/{org_id}` */
|
|
228
|
+
getCompute: (args = {}) => {
|
|
229
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
230
|
+
return request('GET', `/api/v1/compute/${encodeURIComponent(orgId)}`, { query: dropUndefined({ "period": args.period }) });
|
|
231
|
+
},
|
|
232
|
+
/** `GET /api/v1/billing/fx` */
|
|
233
|
+
getFx: () => request('GET', `/api/v1/billing/fx`),
|
|
234
|
+
/** `GET /api/v1/billing/invoices/open` */
|
|
235
|
+
getOpenInvoice: () => request('GET', `/api/v1/billing/invoices/open`),
|
|
236
|
+
/** `GET /api/v1/billing/overage/{org_id}` */
|
|
237
|
+
getOverage: (args = {}) => {
|
|
238
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
239
|
+
return request('GET', `/api/v1/billing/overage/${encodeURIComponent(orgId)}`);
|
|
240
|
+
},
|
|
241
|
+
/** Fetch a billing plan by name. `GET /api/v1/plans/{name}` */
|
|
242
|
+
getPlan: (args) => {
|
|
243
|
+
const name = need('name', args.name);
|
|
244
|
+
return request('GET', `/api/v1/plans/${encodeURIComponent(name)}`, { requiresAuth: false });
|
|
245
|
+
},
|
|
246
|
+
/** `GET /api/v1/billing/provider` */
|
|
247
|
+
getProvider: () => request('GET', `/api/v1/billing/provider`),
|
|
248
|
+
/** Fetch the active subscription for an organisation. `GET /api/v1/subscriptions/{org_id}` */
|
|
249
|
+
getSubscription: (args = {}) => {
|
|
250
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
251
|
+
return request('GET', `/api/v1/subscriptions/${encodeURIComponent(orgId)}`);
|
|
252
|
+
},
|
|
253
|
+
/** Fetch usage counters for an organisation. `GET /api/v1/usage/{org_id}` */
|
|
254
|
+
getUsage: (args = {}) => {
|
|
255
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
256
|
+
return request('GET', `/api/v1/usage/${encodeURIComponent(orgId)}`, { query: dropUndefined({ "period": args.period }) });
|
|
257
|
+
},
|
|
258
|
+
/** Fetch historical usage for an organisation. `GET /api/v1/usage/{org_id}/history` */
|
|
259
|
+
getUsageHistory: (args = {}) => {
|
|
260
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
261
|
+
return request('GET', `/api/v1/usage/${encodeURIComponent(orgId)}/history`, { query: dropUndefined({ "months": args.months }) });
|
|
262
|
+
},
|
|
263
|
+
/** `GET /api/v1/invoices/{org_id}` */
|
|
264
|
+
listInvoices: (args = {}) => {
|
|
265
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
266
|
+
return request('GET', `/api/v1/invoices/${encodeURIComponent(orgId)}`);
|
|
267
|
+
},
|
|
268
|
+
/** List public billing plans. `GET /api/v1/plans` */
|
|
269
|
+
listPlans: () => request('GET', `/api/v1/plans`, { requiresAuth: false }),
|
|
270
|
+
/** List subscriptions visible to the authenticated caller. `GET /api/v1/subscriptions` */
|
|
271
|
+
listSubscriptions: () => request('GET', `/api/v1/subscriptions`),
|
|
272
|
+
/** `POST /api/v1/billing/invoices/{org_id}/{period}/pay` */
|
|
273
|
+
payInvoice: (args) => {
|
|
274
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
275
|
+
const period = need('period', args.period);
|
|
276
|
+
return request('POST', `/api/v1/billing/invoices/${encodeURIComponent(orgId)}/${encodeURIComponent(period)}/pay`);
|
|
277
|
+
},
|
|
278
|
+
/** `POST /api/v1/billing/razorpay/create-order` */
|
|
279
|
+
razorpayCreateOrder: (args) => request('POST', `/api/v1/billing/razorpay/create-order`, { body: args.body }),
|
|
280
|
+
/** `POST /api/v1/billing/razorpay/verify-payment` */
|
|
281
|
+
razorpayVerifyPayment: (args) => request('POST', `/api/v1/billing/razorpay/verify-payment`, { body: args.body }),
|
|
282
|
+
/** `POST /api/v1/accounts/{account_id}/resume` */
|
|
283
|
+
resumeAccount: (args) => {
|
|
284
|
+
const accountId = need('account_id', args.accountId);
|
|
285
|
+
return request('POST', `/api/v1/accounts/${encodeURIComponent(accountId)}/resume`);
|
|
286
|
+
},
|
|
287
|
+
/** `PUT /api/v1/billing/accounts/{account_id}/overage-prefs` */
|
|
288
|
+
setAccountOveragePrefs: (args) => {
|
|
289
|
+
const accountId = need('account_id', args.accountId);
|
|
290
|
+
return request('PUT', `/api/v1/billing/accounts/${encodeURIComponent(accountId)}/overage-prefs`, { body: dropUndefined({ "services": args.services }) });
|
|
291
|
+
},
|
|
292
|
+
/** Change the org's overage switches (org owners and admins) `PUT /api/v1/billing/orgs/{org_id}/overage-prefs` */
|
|
293
|
+
setOrgOveragePrefs: (args) => {
|
|
294
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
295
|
+
return request('PUT', `/api/v1/billing/orgs/${encodeURIComponent(orgId)}/overage-prefs`, { body: dropUndefined({ "services": args.services }) });
|
|
296
|
+
},
|
|
297
|
+
/** Add-ons on the billing account: price, paid units, what renews, paid-through date, and the autopay mandate `GET /api/v1/accounts/{account_id}/addons` */
|
|
298
|
+
listAccountAddons: (args) => {
|
|
299
|
+
const accountId = need('account_id', args.accountId);
|
|
300
|
+
return request('GET', `/api/v1/accounts/${encodeURIComponent(accountId)}/addons`);
|
|
301
|
+
},
|
|
302
|
+
/** Start paying for more add-on units (prorated to the period end); they count once the payment is verified `POST /api/v1/accounts/{account_id}/addons/{addon_id}/checkout` */
|
|
303
|
+
addonCheckout: (args) => {
|
|
304
|
+
const accountId = need('account_id', args.accountId);
|
|
305
|
+
const addonId = need('addon_id', args.addonId);
|
|
306
|
+
return request('POST', `/api/v1/accounts/${encodeURIComponent(accountId)}/addons/${encodeURIComponent(addonId)}/checkout`, { body: dropUndefined({ "quantity": args.quantity, "project_id": args.projectId }) });
|
|
307
|
+
},
|
|
308
|
+
/** How many units renew at the period end (0 cancels); paid units keep working until then `PUT /api/v1/accounts/{account_id}/addons/{addon_id}/renewal` */
|
|
309
|
+
setAddonRenewal: (args) => {
|
|
310
|
+
const accountId = need('account_id', args.accountId);
|
|
311
|
+
const addonId = need('addon_id', args.addonId);
|
|
312
|
+
return request('PUT', `/api/v1/accounts/${encodeURIComponent(accountId)}/addons/${encodeURIComponent(addonId)}/renewal`, { body: dropUndefined({ "renew_quantity": args.renewQuantity }) });
|
|
313
|
+
},
|
|
314
|
+
/** Older switch: lowering schedules at the period end; more units than are paid for answer 402 (use addonCheckout) `POST /api/v1/accounts/{account_id}/addons/{addon_id}` */
|
|
315
|
+
setAccountAddon: (args) => {
|
|
316
|
+
const accountId = need('account_id', args.accountId);
|
|
317
|
+
const addonId = need('addon_id', args.addonId);
|
|
318
|
+
return request('POST', `/api/v1/accounts/${encodeURIComponent(accountId)}/addons/${encodeURIComponent(addonId)}`, { query: dropUndefined({ "enabled": args.enabled, "quantity": args.quantity }) });
|
|
319
|
+
},
|
|
320
|
+
/** Renew automatically (true) or end the plan with the paid period (false) `POST /api/v1/accounts/{account_id}/autopay` */
|
|
321
|
+
setAccountAutopay: (args) => {
|
|
322
|
+
const accountId = need('account_id', args.accountId);
|
|
323
|
+
return request('POST', `/api/v1/accounts/${encodeURIComponent(accountId)}/autopay`, { query: dropUndefined({ "enabled": args.enabled }) });
|
|
324
|
+
},
|
|
325
|
+
/** Start a ₹1 (refunded) authorisation that saves a card or UPI mandate for automatic renewals `POST /api/v1/accounts/{account_id}/autopay/setup` */
|
|
326
|
+
autopaySetup: (args) => {
|
|
327
|
+
const accountId = need('account_id', args.accountId);
|
|
328
|
+
return request('POST', `/api/v1/accounts/${encodeURIComponent(accountId)}/autopay/setup`, { body: dropUndefined({ "customer_email": args.customerEmail, "name": args.name }) });
|
|
329
|
+
},
|
|
330
|
+
/** Remove the saved mandate; renewals become invoices to pay by hand `DELETE /api/v1/accounts/{account_id}/autopay/mandate` */
|
|
331
|
+
removeAutopayMandate: (args) => {
|
|
332
|
+
const accountId = need('account_id', args.accountId);
|
|
333
|
+
return request('DELETE', `/api/v1/accounts/${encodeURIComponent(accountId)}/autopay/mandate`);
|
|
334
|
+
},
|
|
335
|
+
/** Add-on prices (USD per month per unit) and the plans each is sold on, as staff set them. `GET /api/v1/plans/addons` */
|
|
336
|
+
billingListAddonPrices: () => request('GET', `/api/v1/plans/addons`, { requiresAuth: false }),
|
|
337
|
+
},
|
|
338
|
+
builds: {
|
|
339
|
+
/** Check an app build Sovariq wrote (title, description, migration {name, up_sql, down_sql}, policies [{id, spl}], functions [{name, runtime, files}], tests [rules test cases]) against the project — nothing changes: the migration is dry-run up, down and up again, rules are simulated, rules tests run with the build's rules. Returns the build id and the report. `POST /api/v1/fn/builds/check` */
|
|
340
|
+
check: (args) => request('POST', `/api/v1/fn/builds/check`, { body: dropUndefined({ "build": args.build }) }),
|
|
341
|
+
/** Recent app builds of the project: title, status (checked, failed, pr_opened), each check's result and the pull request. `GET /api/v1/fn/builds` */
|
|
342
|
+
list: (args = {}) => request('GET', `/api/v1/fn/builds`, { query: dropUndefined({ "limit": args.limit }) }),
|
|
343
|
+
/** One app build: its files (the bundle), the check report and the pull request. `GET /api/v1/fn/builds/{build_id}` */
|
|
344
|
+
get: (args) => {
|
|
345
|
+
const buildId = need('build_id', args.buildId);
|
|
346
|
+
return request('GET', `/api/v1/fn/builds/${encodeURIComponent(buildId)}`);
|
|
347
|
+
},
|
|
348
|
+
/** Check the build again and open it as a pull request on the project's linked GitHub repository (one commit on a new branch; dev.app_build_prs_month). GitHub needs repository access: connect it with repository access or pass a token with repo scope. `POST /api/v1/fn/builds/{build_id}/pull-request` */
|
|
349
|
+
pullRequest: (args) => {
|
|
350
|
+
const buildId = need('build_id', args.buildId);
|
|
351
|
+
return request('POST', `/api/v1/fn/builds/${encodeURIComponent(buildId)}/pull-request`, { body: dropUndefined({ "token": args.token }) });
|
|
352
|
+
},
|
|
353
|
+
/** Forget an app build (its pull request, if opened, stays on GitHub). `DELETE /api/v1/fn/builds/{build_id}` */
|
|
354
|
+
delete: (args) => {
|
|
355
|
+
const buildId = need('build_id', args.buildId);
|
|
356
|
+
return request('DELETE', `/api/v1/fn/builds/${encodeURIComponent(buildId)}`);
|
|
357
|
+
},
|
|
358
|
+
},
|
|
359
|
+
byok: {
|
|
360
|
+
/** Your organization's own encryption key (Enterprise): whether it's on, the key, its data key version, whether it is usable now, what it covers, and setup (Sovaria's AWS principal and the key policy statement). `GET /api/v1/byok` */
|
|
361
|
+
get: () => request('GET', `/api/v1/byok`),
|
|
362
|
+
/** Use your AWS KMS key (its ARN) for the organization's storage files and backups. Checked end to end first (wrap, unwrap, a file written and read with it). Organization owners. `PUT /api/v1/byok` */
|
|
363
|
+
set: (args) => request('PUT', `/api/v1/byok`, { body: dropUndefined({ "provider": args.provider, "key_ref": args.keyRef }) }),
|
|
364
|
+
/** A new data key version under the same KMS key; older versions stay to decrypt what they encrypted. Organization owners. `POST /api/v1/byok/rotate` */
|
|
365
|
+
rotate: () => request('POST', `/api/v1/byok/rotate`),
|
|
366
|
+
/** Ask your KMS now whether Sovaria can still use the key. `POST /api/v1/byok/check` */
|
|
367
|
+
check: () => request('POST', `/api/v1/byok/check`),
|
|
368
|
+
/** Rewrite the organization's existing storage files under its key (in the background; progress in byok.get). Organization owners. `POST /api/v1/byok/reencrypt-storage` */
|
|
369
|
+
reencryptStorage: () => request('POST', `/api/v1/byok/reencrypt-storage`),
|
|
370
|
+
},
|
|
371
|
+
compliance: {
|
|
372
|
+
/** Compliance overview for an organization (owners and admins): audit-log check, encryption, backups, access, regions. `GET /api/v1/org/{org_id}/compliance` */
|
|
373
|
+
overview: (args = {}) => {
|
|
374
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
375
|
+
return request('GET', `/api/v1/org/${encodeURIComponent(orgId)}/compliance`, { query: dropUndefined({ "project_id": args.projectId }) });
|
|
376
|
+
},
|
|
377
|
+
},
|
|
378
|
+
crashes: {
|
|
379
|
+
/** App crash issues of the project (grouped reports from sov.crashes), newest first, filtered by status, release, app environment, platform or text, with a 24-hour trend and the plan's limits. `GET /api/v1/crashes/issues` */
|
|
380
|
+
listIssues: (args = {}) => request('GET', `/api/v1/crashes/issues`, { query: dropUndefined({ "status": args.status, "limit": args.limit, "release": args.release, "environment": args.environment, "platform": args.platform, "q": args.q, "sort": args.sort, "handled": args.handled }) }),
|
|
381
|
+
/** One crash issue: sample report (stack, breadcrumbs, device, release) and its last 50 reports. `GET /api/v1/crashes/issues/{fingerprint}` */
|
|
382
|
+
getIssue: (args) => {
|
|
383
|
+
const fingerprint = need('fingerprint', args.fingerprint);
|
|
384
|
+
return request('GET', `/api/v1/crashes/issues/${encodeURIComponent(fingerprint)}`);
|
|
385
|
+
},
|
|
386
|
+
/** Mark a crash issue open, resolved (reopens if it happens again) or ignored. `POST /api/v1/crashes/issues/{fingerprint}/status` */
|
|
387
|
+
setIssueStatus: (args) => {
|
|
388
|
+
const fingerprint = need('fingerprint', args.fingerprint);
|
|
389
|
+
return request('POST', `/api/v1/crashes/issues/${encodeURIComponent(fingerprint)}/status`, { body: dropUndefined({ "status": args.status }) });
|
|
390
|
+
},
|
|
391
|
+
/** Crash reports, release-health sessions and debug-file storage used this month, and the plan's limits. `GET /api/v1/crashes/usage` */
|
|
392
|
+
usage: () => request('GET', `/api/v1/crashes/usage`),
|
|
393
|
+
/** Crash events over time (hourly up to 2 days, else daily) and the releases, app environments and platforms seen. `GET /api/v1/crashes/trends` */
|
|
394
|
+
trends: (args = {}) => request('GET', `/api/v1/crashes/trends`, { query: dropUndefined({ "days": args.days, "release": args.release, "environment": args.environment, "platform": args.platform }) }),
|
|
395
|
+
/** Release health: sessions, crash-free sessions and users, and adoption per release. `GET /api/v1/crashes/releases` */
|
|
396
|
+
releases: (args = {}) => request('GET', `/api/v1/crashes/releases`, { query: dropUndefined({ "days": args.days, "environment": args.environment, "platform": args.platform, "limit": args.limit }) }),
|
|
397
|
+
/** Uploaded source maps, ProGuard/R8 mappings and Apple symbols, and the storage used. `GET /api/v1/crashes/debug-files` */
|
|
398
|
+
listDebugFiles: (args = {}) => request('GET', `/api/v1/crashes/debug-files`, { query: dropUndefined({ "kind": args.kind, "release": args.release }) }),
|
|
399
|
+
/** Delete one debug file (frames of that release stay as they were stored). `DELETE /api/v1/crashes/debug-files/{file_id}` */
|
|
400
|
+
deleteDebugFile: (args) => {
|
|
401
|
+
const fileId = need('file_id', args.fileId);
|
|
402
|
+
return request('DELETE', `/api/v1/crashes/debug-files/${encodeURIComponent(fileId)}`);
|
|
403
|
+
},
|
|
404
|
+
},
|
|
405
|
+
data: {
|
|
406
|
+
/** Add a column to an existing table. `POST /api/v1/data/rel/column/add` */
|
|
407
|
+
addColumn: (args) => request('POST', `/api/v1/data/rel/column/add`, { body: dropUndefined({ "table_name": args.tableName, "column_name": args.columnName, "data_type": args.dataType, "is_nullable": args.isNullable, "is_unique": args.isUnique, "default_value": args.defaultValue }) }),
|
|
408
|
+
/** Add a foreign-key relation. `POST /api/v1/data/rel/foreign-key/add` */
|
|
409
|
+
addForeignKey: (args) => request('POST', `/api/v1/data/rel/foreign-key/add`, { body: dropUndefined({ "table_name": args.tableName, "column_name": args.columnName, "referenced_table": args.referencedTable, "referenced_column": args.referencedColumn }) }),
|
|
410
|
+
/** Start a table transaction and receive tx/snapshot IDs. `POST /api/v1/data/rel/transaction/begin` */
|
|
411
|
+
beginTransaction: () => request('POST', `/api/v1/data/rel/transaction/begin`),
|
|
412
|
+
/** Commit a previously opened table transaction. `POST /api/v1/data/rel/transaction/commit` */
|
|
413
|
+
commitTransaction: (args) => request('POST', `/api/v1/data/rel/transaction/commit`, { body: dropUndefined({ "txid": args.txid }) }),
|
|
414
|
+
/** Drop a column from a table. `POST /api/v1/data/rel/column/drop` */
|
|
415
|
+
dropColumn: (args) => request('POST', `/api/v1/data/rel/column/drop`, { body: dropUndefined({ "table_name": args.tableName, "column_name": args.columnName }) }),
|
|
416
|
+
/** Drop a foreign-key relation. `POST /api/v1/data/rel/foreign-key/drop` */
|
|
417
|
+
dropForeignKey: (args) => request('POST', `/api/v1/data/rel/foreign-key/drop`, { body: dropUndefined({ "table_name": args.tableName, "column_name": args.columnName, "referenced_table": args.referencedTable, "referenced_column": args.referencedColumn }) }),
|
|
418
|
+
/** Drop a relational table. `POST /api/v1/data/rel/drop` */
|
|
419
|
+
dropTable: (args) => request('POST', `/api/v1/data/rel/drop`, { body: dropUndefined({ "table_name": args.tableName }) }),
|
|
420
|
+
/** `POST /api/v1/data/rel/transaction/rollback` */
|
|
421
|
+
rollbackTransaction: (args) => request('POST', `/api/v1/data/rel/transaction/rollback`, { body: dropUndefined({ "txid": args.txid }) }),
|
|
422
|
+
/** Tables that keep history (versions, oldest, retention) and the plan's db.history_* limits. `GET /api/v1/data/rel/history` */
|
|
423
|
+
tableHistory: () => request('GET', `/api/v1/data/rel/history`),
|
|
424
|
+
/** Turn a table's history on (every row version kept; read with sov_as_of(NULL::table, time)) or off (versions dropped). `POST /api/v1/data/rel/history` */
|
|
425
|
+
setTableHistory: (args) => request('POST', `/api/v1/data/rel/history`, { body: dropUndefined({ "table_name": args.tableName, "enabled": args.enabled, "keep_days": args.keepDays }) }),
|
|
426
|
+
/** The schema as one short line per table: columns with types, keys, →references, allowed values, indexes and owner-only rows. tables (comma-separated) expands only those in a big schema; since=<version> answers unchanged when nothing changed. `GET /api/v1/data/rel/schema/digest` */
|
|
427
|
+
schemaDigest: (args = {}) => request('GET', `/api/v1/data/rel/schema/digest`, { query: dropUndefined({ "tables": args.tables, "max_chars": args.maxChars, "since": args.since }) }),
|
|
428
|
+
/** Create or extend tables from one declarative plan ([{name, columns, patterns, unique, indexes}]; columns as objects or short form like "status text!='draft' in(draft|live)" or "customer_id →customers cascade"). Checked first (422 lists every problem, nothing changes), then applied as one reversible migration and verified. dry_run returns the SQL without applying. `POST /api/v1/data/rel/schema/plan` */
|
|
429
|
+
applySchemaPlan: (args) => request('POST', `/api/v1/data/rel/schema/plan`, { body: dropUndefined({ "tables": args.tables, "dry_run": args.dryRun, "name": args.name }) }),
|
|
430
|
+
/** Apply a migration and record it in the project's history, in one transaction (all or nothing). down_sql makes it reversible; the same version with the same SQL again does nothing, with different SQL it is refused (409). `POST /api/v1/data/rel/migrations/apply` */
|
|
431
|
+
applyMigration: (args) => request('POST', `/api/v1/data/rel/migrations/apply`, { body: dropUndefined({ "name": args.name, "up_sql": args.upSql, "down_sql": args.downSql, "version": args.version }) }),
|
|
432
|
+
/** Run a migration inside a transaction and roll it back: whether it would apply. Nothing is kept. `POST /api/v1/data/rel/migrations/dry-run` */
|
|
433
|
+
dryRunMigration: (args) => request('POST', `/api/v1/data/rel/migrations/dry-run`, { body: dropUndefined({ "name": args.name, "up_sql": args.upSql, "down_sql": args.downSql }) }),
|
|
434
|
+
/** Check several migrations ([{name, up_sql}], up to 500 and 5 MB of SQL) in order inside one transaction that is rolled back, so later ones see what earlier ones create. Returns status dry_run_ok, or failed with failed.index, name and error for the first that fails. `POST /api/v1/data/rel/migrations/dry-run-sequence` */
|
|
435
|
+
dryRunMigrations: (args) => request('POST', `/api/v1/data/rel/migrations/dry-run-sequence`, { body: dropUndefined({ "migrations": args.migrations }) }),
|
|
436
|
+
/** Undo the most recent migration with its down SQL (or version, with force when it isn't the latest). `POST /api/v1/data/rel/migrations/rollback` */
|
|
437
|
+
rollbackMigration: (args = {}) => request('POST', `/api/v1/data/rel/migrations/rollback`, { query: dropUndefined({ "version": args.version, "force": args.force }) }),
|
|
438
|
+
/** Drop every user table and forget the migration history, in one transaction (what `sov db reset` runs). dry_run lists what would be dropped. `POST /api/v1/data/rel/migrations/reset` */
|
|
439
|
+
resetMigrations: (args = {}) => request('POST', `/api/v1/data/rel/migrations/reset`, { body: dropUndefined({ "dry_run": args.dryRun }) }),
|
|
440
|
+
/** Run a document pipeline: where, aggregate, distinct, sort, offset, limit, select, remove_fields, sample. `POST /api/v1/data/doc/_pipeline/{collection}` */
|
|
441
|
+
docPipeline: (args) => {
|
|
442
|
+
const collection = need('collection', args.collection);
|
|
443
|
+
return request('POST', `/api/v1/data/doc/_pipeline/${encodeURIComponent(collection)}`, { body: dropUndefined({ "stages": args.stages, "collection_group": args.collectionGroup }) });
|
|
444
|
+
},
|
|
445
|
+
/** How two environments' databases differ (to_env '' = production): migrations to deploy and only in the target, and the tables, columns, indexes, constraints and row policies that would be added, changed or dropped. Read-only. `GET /api/v1/data/rel/schema/diff` */
|
|
446
|
+
schemaDiff: (args) => request('GET', `/api/v1/data/rel/schema/diff`, { query: dropUndefined({ "from_env": args.fromEnv, "to_env": args.toEnv }) }),
|
|
447
|
+
/** Deploy a branch (or staging environment) into production, or into a staging environment with to_env_id: its migrations, functions, policies and project settings, all checked first with nothing written (dry_run=true returns only the check). from_name/to_name label the commit. accept_violations deploys even when production's access simulation finds new write access (deploys into staging aren't simulated). `POST /api/v1/data/rel/migrations/promote` */
|
|
448
|
+
promoteEnvironment: (args) => request('POST', `/api/v1/data/rel/migrations/promote`, { body: dropUndefined({ "from_env_id": args.fromEnvId, "to_env_id": args.toEnvId, "from_name": args.fromName, "to_name": args.toName, "dry_run": args.dryRun, "accept_violations": args.acceptViolations }) }),
|
|
449
|
+
},
|
|
450
|
+
deadLetters: {
|
|
451
|
+
/** Background runs that ran out of tries (trigger events, async calls, schedules), kept for the plan's fn.dead_letter_days. `GET /api/v1/fn/dead-letters` */
|
|
452
|
+
list: (args = {}) => request('GET', `/api/v1/fn/dead-letters`, { query: dropUndefined({ "function": args.functionName, "trigger_id": args.triggerId, "limit": args.limit, "offset": args.offset }) }),
|
|
453
|
+
/** Run a dead-lettered event again (on the function's live version). `POST /api/v1/fn/dead-letters/{invocation_id}/replay` */
|
|
454
|
+
replay: (args) => {
|
|
455
|
+
const invocationId = need('invocation_id', args.invocationId);
|
|
456
|
+
return request('POST', `/api/v1/fn/dead-letters/${encodeURIComponent(invocationId)}/replay`);
|
|
457
|
+
},
|
|
458
|
+
/** Replay up to 100 dead letters at once; returns replayed and failed ids. `POST /api/v1/fn/dead-letters/replay` */
|
|
459
|
+
replayMany: (args) => request('POST', `/api/v1/fn/dead-letters/replay`, { body: dropUndefined({ "ids": args.ids }) }),
|
|
460
|
+
/** Discard a dead letter for good. `DELETE /api/v1/fn/dead-letters/{invocation_id}` */
|
|
461
|
+
discard: (args) => {
|
|
462
|
+
const invocationId = need('invocation_id', args.invocationId);
|
|
463
|
+
return request('DELETE', `/api/v1/fn/dead-letters/${encodeURIComponent(invocationId)}`);
|
|
464
|
+
},
|
|
465
|
+
},
|
|
466
|
+
distribution: {
|
|
467
|
+
/** Tester builds, groups, testers, usage and the plan's limits. `GET /api/v1/projects/{project_id}/distribution` */
|
|
468
|
+
overview: (args = {}) => {
|
|
469
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
470
|
+
return request('GET', `/api/v1/projects/${encodeURIComponent(projectId)}/distribution`);
|
|
471
|
+
},
|
|
472
|
+
/** Start a tester build upload: returns the release and a signed upload URL (PUT the .apk/.aab/.ipa there, then finalize). `POST /api/v1/projects/{project_id}/distribution/releases` */
|
|
473
|
+
createRelease: (args) => {
|
|
474
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
475
|
+
return request('POST', `/api/v1/projects/${encodeURIComponent(projectId)}/distribution/releases`, { body: dropUndefined({ "filename": args.filename, "size_bytes": args.sizeBytes, "notes": args.notes, "groups": args.groups, "env": args.env, "git_ref": args.gitRef, "app_id": args.appId, "notify": args.notify }) });
|
|
476
|
+
},
|
|
477
|
+
/** Read the uploaded build (package/bundle id, version, build, minimum OS), share it with its groups and email their testers. `POST /api/v1/projects/{project_id}/distribution/releases/{release_id}/finalize` */
|
|
478
|
+
finalizeRelease: (args) => {
|
|
479
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
480
|
+
const releaseId = need('release_id', args.releaseId);
|
|
481
|
+
return request('POST', `/api/v1/projects/${encodeURIComponent(projectId)}/distribution/releases/${encodeURIComponent(releaseId)}/finalize`);
|
|
482
|
+
},
|
|
483
|
+
/** Change a build's notes or groups. `PATCH /api/v1/projects/{project_id}/distribution/releases/{release_id}` */
|
|
484
|
+
updateRelease: (args) => {
|
|
485
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
486
|
+
const releaseId = need('release_id', args.releaseId);
|
|
487
|
+
return request('PATCH', `/api/v1/projects/${encodeURIComponent(projectId)}/distribution/releases/${encodeURIComponent(releaseId)}`, { body: dropUndefined({ "notes": args.notes, "groups": args.groups }) });
|
|
488
|
+
},
|
|
489
|
+
/** Delete a tester build and its file. `DELETE /api/v1/projects/{project_id}/distribution/releases/{release_id}` */
|
|
490
|
+
deleteRelease: (args) => {
|
|
491
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
492
|
+
const releaseId = need('release_id', args.releaseId);
|
|
493
|
+
return request('DELETE', `/api/v1/projects/${encodeURIComponent(projectId)}/distribution/releases/${encodeURIComponent(releaseId)}`);
|
|
494
|
+
},
|
|
495
|
+
/** Add testers by email to groups and send them install links. `POST /api/v1/projects/{project_id}/distribution/testers` */
|
|
496
|
+
addTesters: (args) => {
|
|
497
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
498
|
+
return request('POST', `/api/v1/projects/${encodeURIComponent(projectId)}/distribution/testers`, { body: dropUndefined({ "emails": args.emails, "groups": args.groups, "send_invite": args.sendInvite }) });
|
|
499
|
+
},
|
|
500
|
+
/** Remove a tester; their install links stop working at once. `DELETE /api/v1/projects/{project_id}/distribution/testers/{tester_id}` */
|
|
501
|
+
removeTester: (args) => {
|
|
502
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
503
|
+
const testerId = need('tester_id', args.testerId);
|
|
504
|
+
return request('DELETE', `/api/v1/projects/${encodeURIComponent(projectId)}/distribution/testers/${encodeURIComponent(testerId)}`);
|
|
505
|
+
},
|
|
506
|
+
/** Send a tester a new install link (older links stop working). `POST /api/v1/projects/{project_id}/distribution/testers/{tester_id}/invite` */
|
|
507
|
+
resendInvite: (args) => {
|
|
508
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
509
|
+
const testerId = need('tester_id', args.testerId);
|
|
510
|
+
return request('POST', `/api/v1/projects/${encodeURIComponent(projectId)}/distribution/testers/${encodeURIComponent(testerId)}/invite`);
|
|
511
|
+
},
|
|
512
|
+
/** Delete a tester group. `DELETE /api/v1/projects/{project_id}/distribution/groups/{name}` */
|
|
513
|
+
deleteGroup: (args) => {
|
|
514
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
515
|
+
const name = need('name', args.name);
|
|
516
|
+
return request('DELETE', `/api/v1/projects/${encodeURIComponent(projectId)}/distribution/groups/${encodeURIComponent(name)}`);
|
|
517
|
+
},
|
|
518
|
+
},
|
|
519
|
+
e2ee: {
|
|
520
|
+
/** Create (or fetch) the active e2ee channel key. `POST /api/v1/rt/e2ee/keys/bootstrap` */
|
|
521
|
+
bootstrapKey: (args) => request('POST', `/api/v1/rt/e2ee/keys/bootstrap`, { body: dropUndefined({ "channel": args.channel, "ttl_seconds": args.ttlSeconds, "force_new": args.forceNew }) }),
|
|
522
|
+
/** Get the active e2ee key for a channel, wrapped for ``client_public_key``. `GET /api/v1/rt/e2ee/keys/active/{channel}` */
|
|
523
|
+
getActiveKey: (args) => {
|
|
524
|
+
const channel = need('channel', args.channel);
|
|
525
|
+
return request('GET', `/api/v1/rt/e2ee/keys/active/${encodeURIComponent(channel)}`, { query: dropUndefined({ "client_public_key_pem": args.clientPublicKey }) });
|
|
526
|
+
},
|
|
527
|
+
/** Get key material by channel/key_id, wrapped for ``client_public_key``. `GET /api/v1/rt/e2ee/keys/{channel}/{key_id}` */
|
|
528
|
+
getKey: (args) => {
|
|
529
|
+
const channel = need('channel', args.channel);
|
|
530
|
+
const keyId = need('key_id', args.keyId);
|
|
531
|
+
return request('GET', `/api/v1/rt/e2ee/keys/${encodeURIComponent(channel)}/${encodeURIComponent(keyId)}`, { query: dropUndefined({ "client_public_key_pem": args.clientPublicKey }) });
|
|
532
|
+
},
|
|
533
|
+
/** List key metadata for a channel. `GET /api/v1/rt/e2ee/keys/{channel}` */
|
|
534
|
+
listKeys: (args) => {
|
|
535
|
+
const channel = need('channel', args.channel);
|
|
536
|
+
return request('GET', `/api/v1/rt/e2ee/keys/${encodeURIComponent(channel)}`);
|
|
537
|
+
},
|
|
538
|
+
/** Revoke an active or historical channel key. `POST /api/v1/rt/e2ee/keys/revoke` */
|
|
539
|
+
revokeKey: (args) => request('POST', `/api/v1/rt/e2ee/keys/revoke`, { body: dropUndefined({ "channel": args.channel, "key_id": args.keyId, "reason": args.reason }) }),
|
|
540
|
+
/** Rotate e2ee key material for a channel. `POST /api/v1/rt/e2ee/keys/rotate` */
|
|
541
|
+
rotateKey: (args) => request('POST', `/api/v1/rt/e2ee/keys/rotate`, { body: dropUndefined({ "channel": args.channel, "ttl_seconds": args.ttlSeconds }) }),
|
|
542
|
+
},
|
|
543
|
+
embeddings: {
|
|
544
|
+
/** The project's embedding model, who pays (managed | own_key), dimensions and list price. `GET /api/v1/embeddings/settings` */
|
|
545
|
+
getSettings: () => request('GET', `/api/v1/embeddings/settings`),
|
|
546
|
+
/** Use the project's own provider key: provider (openai | gemini | openai_compatible), model, dimensions, base_url, api_key. Tested before it is saved. `PUT /api/v1/embeddings/settings` */
|
|
547
|
+
setSettings: (args) => request('PUT', `/api/v1/embeddings/settings`, { body: args.body }),
|
|
548
|
+
/** Go back to Sovaria's managed embedding model. `DELETE /api/v1/embeddings/settings` */
|
|
549
|
+
clearSettings: () => request('DELETE', `/api/v1/embeddings/settings`),
|
|
550
|
+
/** Texts, tokens and estimated cost per month, model and who paid. `GET /api/v1/embeddings/usage` */
|
|
551
|
+
usage: (args = {}) => request('GET', `/api/v1/embeddings/usage`, { query: dropUndefined({ "months": args.months }) }),
|
|
552
|
+
},
|
|
553
|
+
experiments: {
|
|
554
|
+
/** A/B experiments of an environment and the plan's limits. `GET /api/v1/projects/{project_id}/experiments` */
|
|
555
|
+
listExperiments: (args = {}) => {
|
|
556
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
557
|
+
return request('GET', `/api/v1/projects/${encodeURIComponent(projectId)}/experiments`, { query: dropUndefined({ "env": args.env }) });
|
|
558
|
+
},
|
|
559
|
+
/** Create an experiment on a parameter: variants [{name, value, weight}], control, condition?, exposure_pct?, goal {type, event|sql, value_prop?}, min_sample?. `POST /api/v1/projects/{project_id}/experiments` */
|
|
560
|
+
createExperiment: (args) => {
|
|
561
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
562
|
+
return request('POST', `/api/v1/projects/${encodeURIComponent(projectId)}/experiments`, { body: dropUndefined({ "name": args.name, "param": args.param, "variants": args.variants, "control": args.control, "condition": args.condition, "exposure_pct": args.exposurePct, "goal": args.goal, "min_sample": args.minSample, "description": args.description }), query: dropUndefined({ "env": args.env }) });
|
|
563
|
+
},
|
|
564
|
+
/** One experiment (by id or name). `GET /api/v1/projects/{project_id}/experiments/{ref}` */
|
|
565
|
+
getExperiment: (args) => {
|
|
566
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
567
|
+
const ref = need('ref', args.ref);
|
|
568
|
+
return request('GET', `/api/v1/projects/${encodeURIComponent(projectId)}/experiments/${encodeURIComponent(ref)}`, { query: dropUndefined({ "env": args.env }) });
|
|
569
|
+
},
|
|
570
|
+
/** Change an experiment: weights and exposure while running (assigned units keep their variant); anything while draft. `PATCH /api/v1/projects/{project_id}/experiments/{ref}` */
|
|
571
|
+
updateExperiment: (args) => {
|
|
572
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
573
|
+
const ref = need('ref', args.ref);
|
|
574
|
+
return request('PATCH', `/api/v1/projects/${encodeURIComponent(projectId)}/experiments/${encodeURIComponent(ref)}`, { body: dropUndefined({ "variants": args.variants, "control": args.control, "exposure_pct": args.exposurePct, "goal": args.goal, "min_sample": args.minSample, "description": args.description }), query: dropUndefined({ "env": args.env }) });
|
|
575
|
+
},
|
|
576
|
+
/** Delete a draft or stopped experiment. `DELETE /api/v1/projects/{project_id}/experiments/{ref}` */
|
|
577
|
+
deleteExperiment: (args) => {
|
|
578
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
579
|
+
const ref = need('ref', args.ref);
|
|
580
|
+
return request('DELETE', `/api/v1/projects/${encodeURIComponent(projectId)}/experiments/${encodeURIComponent(ref)}`, { query: dropUndefined({ "env": args.env }) });
|
|
581
|
+
},
|
|
582
|
+
/** Start an experiment (publishes a config version with it). `POST /api/v1/projects/{project_id}/experiments/{ref}/start` */
|
|
583
|
+
startExperiment: (args) => {
|
|
584
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
585
|
+
const ref = need('ref', args.ref);
|
|
586
|
+
return request('POST', `/api/v1/projects/${encodeURIComponent(projectId)}/experiments/${encodeURIComponent(ref)}/start`, { query: dropUndefined({ "env": args.env }) });
|
|
587
|
+
},
|
|
588
|
+
/** Stop an experiment (optionally naming the winner). `POST /api/v1/projects/{project_id}/experiments/{ref}/stop` */
|
|
589
|
+
stopExperiment: (args) => {
|
|
590
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
591
|
+
const ref = need('ref', args.ref);
|
|
592
|
+
return request('POST', `/api/v1/projects/${encodeURIComponent(projectId)}/experiments/${encodeURIComponent(ref)}/stop`, { body: dropUndefined({ "winner": args.winner }), query: dropUndefined({ "env": args.env }) });
|
|
593
|
+
},
|
|
594
|
+
/** Per-variant results: z-test or Welch with 95% intervals, sample-ratio check, winner once every variant has min_sample units. `GET /api/v1/projects/{project_id}/experiments/{ref}/results` */
|
|
595
|
+
results: (args) => {
|
|
596
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
597
|
+
const ref = need('ref', args.ref);
|
|
598
|
+
return request('GET', `/api/v1/projects/${encodeURIComponent(projectId)}/experiments/${encodeURIComponent(ref)}/results`, { query: dropUndefined({ "env": args.env }) });
|
|
599
|
+
},
|
|
600
|
+
/** Make a variant (the winner by default) the parameter's default, end the experiment and publish. `POST /api/v1/projects/{project_id}/experiments/{ref}/rollout` */
|
|
601
|
+
rollout: (args) => {
|
|
602
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
603
|
+
const ref = need('ref', args.ref);
|
|
604
|
+
return request('POST', `/api/v1/projects/${encodeURIComponent(projectId)}/experiments/${encodeURIComponent(ref)}/rollout`, { body: dropUndefined({ "variant": args.variant }), query: dropUndefined({ "env": args.env }) });
|
|
605
|
+
},
|
|
606
|
+
},
|
|
607
|
+
functions: {
|
|
608
|
+
/** `DELETE /api/v1/fn/functions/{function_name}` */
|
|
609
|
+
delete: (args) => {
|
|
610
|
+
const functionName = need('function_name', args.functionName);
|
|
611
|
+
return request('DELETE', `/api/v1/fn/functions/${encodeURIComponent(functionName)}`);
|
|
612
|
+
},
|
|
613
|
+
/** `GET /api/v1/fn/functions/{function_name}` */
|
|
614
|
+
get: (args) => {
|
|
615
|
+
const functionName = need('function_name', args.functionName);
|
|
616
|
+
return request('GET', `/api/v1/fn/functions/${encodeURIComponent(functionName)}`, { query: dropUndefined({ "project_id": args.projectId }) });
|
|
617
|
+
},
|
|
618
|
+
/** `GET /api/v1/fn/functions/{function_name}/bindings` */
|
|
619
|
+
getBindings: (args) => {
|
|
620
|
+
const functionName = need('function_name', args.functionName);
|
|
621
|
+
return request('GET', `/api/v1/fn/functions/${encodeURIComponent(functionName)}/bindings`);
|
|
622
|
+
},
|
|
623
|
+
/** `GET /api/v1/fn/functions/{function_name}/policy` */
|
|
624
|
+
getPolicy: (args) => {
|
|
625
|
+
const functionName = need('function_name', args.functionName);
|
|
626
|
+
return request('GET', `/api/v1/fn/functions/${encodeURIComponent(functionName)}/policy`);
|
|
627
|
+
},
|
|
628
|
+
/** `GET /api/v1/fn/functions/{function_name}/source` */
|
|
629
|
+
getSource: (args) => {
|
|
630
|
+
const functionName = need('function_name', args.functionName);
|
|
631
|
+
return request('GET', `/api/v1/fn/functions/${encodeURIComponent(functionName)}/source`, { query: dropUndefined({ "project_id": args.projectId }) });
|
|
632
|
+
},
|
|
633
|
+
/** `POST /api/v1/fn/github/commit` */
|
|
634
|
+
githubCommit: (args) => request('POST', `/api/v1/fn/github/commit`, { body: args.body }),
|
|
635
|
+
/** `POST /api/v1/fn/github/import` */
|
|
636
|
+
githubImport: (args) => request('POST', `/api/v1/fn/github/import`, { body: args.body }),
|
|
637
|
+
/** Get status for an async Forge invocation id. `GET /api/v1/fn/invocations/{invocation_id}` */
|
|
638
|
+
invocationStatus: (args) => {
|
|
639
|
+
const invocationId = need('invocation_id', args.invocationId);
|
|
640
|
+
return request('GET', `/api/v1/fn/invocations/${encodeURIComponent(invocationId)}`, { query: dropUndefined({ "project_id": args.projectId }) });
|
|
641
|
+
},
|
|
642
|
+
/** List Forge functions with active version and queue summary. `GET /api/v1/fn/functions` */
|
|
643
|
+
list: (args = {}) => request('GET', `/api/v1/fn/functions`, { query: dropUndefined({ "project_id": args.projectId, "limit": args.limit, "offset": args.offset }) }),
|
|
644
|
+
/** Diff two simulation invocation outputs. `GET /api/v1/fn/{function_name}/history/simulation-diff` */
|
|
645
|
+
simulationDiff: (args) => {
|
|
646
|
+
const functionName = need('function_name', args.functionName);
|
|
647
|
+
return request('GET', `/api/v1/fn/${encodeURIComponent(functionName)}/history/simulation-diff`, { query: dropUndefined({ "project_id": args.projectId, "left_invocation_id": args.leftInvocationId, "right_invocation_id": args.rightInvocationId }) });
|
|
648
|
+
},
|
|
649
|
+
/** Get forge deployment status by deploy id. `GET /api/v1/fn/{deploy_id}/status` */
|
|
650
|
+
status: (args) => {
|
|
651
|
+
const deployId = need('deploy_id', args.deployId);
|
|
652
|
+
return request('GET', `/api/v1/fn/${encodeURIComponent(deployId)}/status`, { query: dropUndefined({ "project_id": args.projectId }) });
|
|
653
|
+
},
|
|
654
|
+
/** `PATCH /api/v1/fn/functions/{function_name}` */
|
|
655
|
+
update: (args) => {
|
|
656
|
+
const functionName = need('function_name', args.functionName);
|
|
657
|
+
return request('PATCH', `/api/v1/fn/functions/${encodeURIComponent(functionName)}`, { body: args.body, query: dropUndefined({ "project_id": args.projectId }) });
|
|
658
|
+
},
|
|
659
|
+
/** `PUT /api/v1/fn/functions/{function_name}/bindings` */
|
|
660
|
+
updateBindings: (args) => {
|
|
661
|
+
const functionName = need('function_name', args.functionName);
|
|
662
|
+
return request('PUT', `/api/v1/fn/functions/${encodeURIComponent(functionName)}/bindings`, { body: dropUndefined({ "bindings": args.bindings }) });
|
|
663
|
+
},
|
|
664
|
+
/** `PUT /api/v1/fn/functions/{function_name}/policy` */
|
|
665
|
+
updatePolicy: (args) => {
|
|
666
|
+
const functionName = need('function_name', args.functionName);
|
|
667
|
+
return request('PUT', `/api/v1/fn/functions/${encodeURIComponent(functionName)}/policy`, { body: args.policy });
|
|
668
|
+
},
|
|
669
|
+
/** List deployment versions for a Forge function. `GET /api/v1/fn/{function_name}/versions` */
|
|
670
|
+
versions: (args) => {
|
|
671
|
+
const functionName = need('function_name', args.functionName);
|
|
672
|
+
return request('GET', `/api/v1/fn/${encodeURIComponent(functionName)}/versions`, { query: dropUndefined({ "project_id": args.projectId, "limit": args.limit, "offset": args.offset }) });
|
|
673
|
+
},
|
|
674
|
+
/** Preview environments of the linked GitHub repository's open pull requests: PR number and title, status (creating, deploying, ready, partial, error), API URL, functions and migrations applied. `GET /api/v1/fn/github/previews` */
|
|
675
|
+
listGithubPreviews: () => request('GET', `/api/v1/fn/github/previews`),
|
|
676
|
+
/** A function's own memory, timeout and minimum-instances settings, what it runs with (effective) and the plan's maximums. `GET /api/v1/fn/functions/{function_name}/limits` */
|
|
677
|
+
getFunctionLimits: (args) => {
|
|
678
|
+
const functionName = need('function_name', args.functionName);
|
|
679
|
+
return request('GET', `/api/v1/fn/functions/${encodeURIComponent(functionName)}/limits`);
|
|
680
|
+
},
|
|
681
|
+
/** Lower a function's timeout or memory (never above the plan; null = plan maximum) and set its minimum instances: pre-started sandboxes kept for it so its calls start warm (plan fn.min_instances; left out = unchanged). `PUT /api/v1/fn/functions/{function_name}/limits` */
|
|
682
|
+
setFunctionLimits: (args) => {
|
|
683
|
+
const functionName = need('function_name', args.functionName);
|
|
684
|
+
return request('PUT', `/api/v1/fn/functions/${encodeURIComponent(functionName)}/limits`, { body: dropUndefined({ "timeout_sec": args.timeoutSec, "memory_mb": args.memoryMb, "min_instances": args.minInstances }) });
|
|
685
|
+
},
|
|
686
|
+
},
|
|
687
|
+
governance: {
|
|
688
|
+
/** `GET /api/v1/governance/admin/databases` */
|
|
689
|
+
adminDatabases: () => request('GET', `/api/v1/governance/admin/databases`),
|
|
690
|
+
/** `GET /api/v1/governance/tenants/{org_id}` */
|
|
691
|
+
getTenant: (args = {}) => {
|
|
692
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
693
|
+
return request('GET', `/api/v1/governance/tenants/${encodeURIComponent(orgId)}`);
|
|
694
|
+
},
|
|
695
|
+
/** `GET /api/v1/governance/tenants/{org_id}/databases/{project_id}/connection` */
|
|
696
|
+
getTenantDatabaseConnection: (args = {}) => {
|
|
697
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
698
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
699
|
+
return request('GET', `/api/v1/governance/tenants/${encodeURIComponent(orgId)}/databases/${encodeURIComponent(projectId)}/connection`);
|
|
700
|
+
},
|
|
701
|
+
/** `GET /api/v1/governance/hosts` */
|
|
702
|
+
listHosts: (args = {}) => request('GET', `/api/v1/governance/hosts`, { query: dropUndefined({ "region_id": args.regionId }) }),
|
|
703
|
+
/** `GET /api/v1/governance/regions` */
|
|
704
|
+
listRegions: () => request('GET', `/api/v1/governance/regions`),
|
|
705
|
+
/** `GET /api/v1/governance/tenants/{org_id}/databases/{project_id}/backups` */
|
|
706
|
+
listTenantDatabaseBackups: (args = {}) => {
|
|
707
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
708
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
709
|
+
return request('GET', `/api/v1/governance/tenants/${encodeURIComponent(orgId)}/databases/${encodeURIComponent(projectId)}/backups`, { query: dropUndefined({ "limit": args.limit }) });
|
|
710
|
+
},
|
|
711
|
+
/** `GET /api/v1/governance/tenants/{org_id}/databases` */
|
|
712
|
+
listTenantDatabases: (args = {}) => {
|
|
713
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
714
|
+
return request('GET', `/api/v1/governance/tenants/${encodeURIComponent(orgId)}/databases`);
|
|
715
|
+
},
|
|
716
|
+
/** `GET /api/v1/governance/tenants` */
|
|
717
|
+
listTenants: () => request('GET', `/api/v1/governance/tenants`),
|
|
718
|
+
/** `GET /api/v1/governance/metrics/overview` */
|
|
719
|
+
metricsOverview: () => request('GET', `/api/v1/governance/metrics/overview`),
|
|
720
|
+
/** `PATCH /api/v1/governance/hosts/{host_id}` */
|
|
721
|
+
patchHost: (args) => {
|
|
722
|
+
const hostId = need('host_id', args.hostId);
|
|
723
|
+
return request('PATCH', `/api/v1/governance/hosts/${encodeURIComponent(hostId)}`, { body: args.body });
|
|
724
|
+
},
|
|
725
|
+
/** `PATCH /api/v1/governance/regions/{region_id}` */
|
|
726
|
+
patchRegion: (args) => {
|
|
727
|
+
const regionId = need('region_id', args.regionId);
|
|
728
|
+
return request('PATCH', `/api/v1/governance/regions/${encodeURIComponent(regionId)}`, { body: args.body });
|
|
729
|
+
},
|
|
730
|
+
/** `POST /api/v1/governance/tenants/{org_id}/databases/{project_id}/pause` */
|
|
731
|
+
pauseTenantDatabase: (args = {}) => {
|
|
732
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
733
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
734
|
+
return request('POST', `/api/v1/governance/tenants/${encodeURIComponent(orgId)}/databases/${encodeURIComponent(projectId)}/pause`);
|
|
735
|
+
},
|
|
736
|
+
/** `POST /api/v1/governance/tenants/{org_id}/databases/{project_id}/resize` */
|
|
737
|
+
resizeTenantDatabase: (args) => {
|
|
738
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
739
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
740
|
+
return request('POST', `/api/v1/governance/tenants/${encodeURIComponent(orgId)}/databases/${encodeURIComponent(projectId)}/resize`, { body: dropUndefined({ "compute_size": args.computeSize }) });
|
|
741
|
+
},
|
|
742
|
+
/** `POST /api/v1/governance/tenants/{org_id}/databases/{project_id}/resume` */
|
|
743
|
+
resumeTenantDatabase: (args = {}) => {
|
|
744
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
745
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
746
|
+
return request('POST', `/api/v1/governance/tenants/${encodeURIComponent(orgId)}/databases/${encodeURIComponent(projectId)}/resume`);
|
|
747
|
+
},
|
|
748
|
+
/** Reveal a database connection string (staff, with an active access grant). `POST /api/v1/governance/tenants/{org_id}/databases/{project_id}/connection/reveal` */
|
|
749
|
+
revealTenantDatabaseConnection: (args) => {
|
|
750
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
751
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
752
|
+
return request('POST', `/api/v1/governance/tenants/${encodeURIComponent(orgId)}/databases/${encodeURIComponent(projectId)}/connection/reveal`, { body: dropUndefined({ "grant_id": args.grantId }) });
|
|
753
|
+
},
|
|
754
|
+
/** `POST /api/v1/governance/tenants/{org_id}/status` */
|
|
755
|
+
setTenantStatus: (args) => {
|
|
756
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
757
|
+
return request('POST', `/api/v1/governance/tenants/${encodeURIComponent(orgId)}/status`, { body: dropUndefined({ "status": args.status }) });
|
|
758
|
+
},
|
|
759
|
+
/** `POST /api/v1/governance/tenants/{org_id}/databases/{project_id}/backups` */
|
|
760
|
+
triggerTenantDatabaseBackup: (args = {}) => {
|
|
761
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
762
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
763
|
+
return request('POST', `/api/v1/governance/tenants/${encodeURIComponent(orgId)}/databases/${encodeURIComponent(projectId)}/backups`);
|
|
764
|
+
},
|
|
765
|
+
/** Read replicas of the project's dedicated database: status, connection string, lag behind the primary, plan limit. `GET /api/v1/governance/tenants/{org_id}/databases/{project_id}/replicas` */
|
|
766
|
+
listDatabaseReplicas: (args = {}) => {
|
|
767
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
768
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
769
|
+
return request('GET', `/api/v1/governance/tenants/${encodeURIComponent(orgId)}/databases/${encodeURIComponent(projectId)}/replicas`);
|
|
770
|
+
},
|
|
771
|
+
/** Start a streaming read replica (status provisioning until its base backup is done, then ready). `POST /api/v1/governance/tenants/{org_id}/databases/{project_id}/replicas` */
|
|
772
|
+
createDatabaseReplica: (args = {}) => {
|
|
773
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
774
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
775
|
+
return request('POST', `/api/v1/governance/tenants/${encodeURIComponent(orgId)}/databases/${encodeURIComponent(projectId)}/replicas`, { body: {} });
|
|
776
|
+
},
|
|
777
|
+
/** Remove a read replica and its copy of the data. `DELETE /api/v1/governance/tenants/{org_id}/databases/{project_id}/replicas/{replica_id}` */
|
|
778
|
+
deleteDatabaseReplica: (args) => {
|
|
779
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
780
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
781
|
+
const replicaId = need('replica_id', args.replicaId);
|
|
782
|
+
return request('DELETE', `/api/v1/governance/tenants/${encodeURIComponent(orgId)}/databases/${encodeURIComponent(projectId)}/replicas/${encodeURIComponent(replicaId)}`);
|
|
783
|
+
},
|
|
784
|
+
/** What changed between two moments of the database — a backup id or "now" on each side: schema objects added, removed or changed (with a diff) and rows per table. `POST /api/v1/governance/tenants/{org_id}/databases/{project_id}/compare` */
|
|
785
|
+
compareDatabaseMoments: (args) => {
|
|
786
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
787
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
788
|
+
return request('POST', `/api/v1/governance/tenants/${encodeURIComponent(orgId)}/databases/${encodeURIComponent(projectId)}/compare`, { body: dropUndefined({ "from": args.fromMoment, "to": args.toMoment, "include_platform": args.includePlatform }) });
|
|
789
|
+
},
|
|
790
|
+
/** Replace the project's database with a backup (dedicated databases): a safety backup is taken first, the backup loads beside production in one transaction and is swapped in; undo within 7 days. Org owners and admins. `POST /api/v1/governance/tenants/{org_id}/databases/{project_id}/backups/{backup_id}/restore` */
|
|
791
|
+
restoreDatabaseBackup: (args) => {
|
|
792
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
793
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
794
|
+
const backupId = need('backup_id', args.backupId);
|
|
795
|
+
return request('POST', `/api/v1/governance/tenants/${encodeURIComponent(orgId)}/databases/${encodeURIComponent(projectId)}/backups/${encodeURIComponent(backupId)}/restore`, { body: dropUndefined({ "confirm": args.confirm }) });
|
|
796
|
+
},
|
|
797
|
+
/** Database restores of the project: status, the backup used, the safety backup and until when it can be undone. `GET /api/v1/governance/tenants/{org_id}/databases/{project_id}/restores` */
|
|
798
|
+
listDatabaseRestores: (args = {}) => {
|
|
799
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
800
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
801
|
+
return request('GET', `/api/v1/governance/tenants/${encodeURIComponent(orgId)}/databases/${encodeURIComponent(projectId)}/restores`);
|
|
802
|
+
},
|
|
803
|
+
/** Put back the database exactly as it was right before a restore (within the undo window). `POST /api/v1/governance/tenants/{org_id}/databases/{project_id}/restores/{restore_id}/undo` */
|
|
804
|
+
undoDatabaseRestore: (args) => {
|
|
805
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
806
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
807
|
+
const restoreId = need('restore_id', args.restoreId);
|
|
808
|
+
return request('POST', `/api/v1/governance/tenants/${encodeURIComponent(orgId)}/databases/${encodeURIComponent(projectId)}/restores/${encodeURIComponent(restoreId)}/undo`, { body: {} });
|
|
809
|
+
},
|
|
810
|
+
/** Point-in-time recovery of the project's database: whether it is on, the earliest and latest moment that can be restored, base backups and archived WAL. `GET /api/v1/governance/tenants/{org_id}/databases/{project_id}/backups/pitr` */
|
|
811
|
+
getPitrStatus: (args = {}) => {
|
|
812
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
813
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
814
|
+
return request('GET', `/api/v1/governance/tenants/${encodeURIComponent(orgId)}/databases/${encodeURIComponent(projectId)}/backups/pitr`);
|
|
815
|
+
},
|
|
816
|
+
/** Turn on point-in-time recovery (WAL archiving; Pro and higher). If the database needs one restart for it (a few seconds), it restarts only with restart=true; otherwise the answer says state=restart_required. `POST /api/v1/governance/tenants/{org_id}/databases/{project_id}/pitr/enable` */
|
|
817
|
+
enablePitr: (args = {}) => {
|
|
818
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
819
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
820
|
+
return request('POST', `/api/v1/governance/tenants/${encodeURIComponent(orgId)}/databases/${encodeURIComponent(projectId)}/pitr/enable`, { body: dropUndefined({ "restart": args.restart }) });
|
|
821
|
+
},
|
|
822
|
+
/** Stop point-in-time recovery archiving (no restart). What was archived stays restorable until it leaves the plan's window. `POST /api/v1/governance/tenants/{org_id}/databases/{project_id}/pitr/disable` */
|
|
823
|
+
disablePitr: (args = {}) => {
|
|
824
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
825
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
826
|
+
return request('POST', `/api/v1/governance/tenants/${encodeURIComponent(orgId)}/databases/${encodeURIComponent(projectId)}/pitr/disable`, { body: {} });
|
|
827
|
+
},
|
|
828
|
+
/** Restore the project's database to a moment (ISO-8601 target_time). It is recovered in a new container beside production and checked; with confirm=true it is then swapped in (safety backup first, undo for 7 days). verify_only=true only checks the moment restores. Returns a job; poll get_restore_job. `POST /api/v1/governance/tenants/{org_id}/databases/{project_id}/restore` */
|
|
829
|
+
restoreDatabaseToTime: (args) => {
|
|
830
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
831
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
832
|
+
return request('POST', `/api/v1/governance/tenants/${encodeURIComponent(orgId)}/databases/${encodeURIComponent(projectId)}/restore`, { body: dropUndefined({ "target_time": args.targetTime, "confirm": args.confirm, "verify_only": args.verifyOnly }) });
|
|
833
|
+
},
|
|
834
|
+
/** A database restore job (point-in-time or from a backup): status (running, done, verified, failed, undone), the step it is on, the moment, and until when it can be undone. `GET /api/v1/governance/tenants/{org_id}/databases/{project_id}/backups/pitr/jobs/{job_id}` */
|
|
835
|
+
getRestoreJob: (args) => {
|
|
836
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
837
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
838
|
+
const jobId = need('job_id', args.jobId);
|
|
839
|
+
return request('GET', `/api/v1/governance/tenants/${encodeURIComponent(orgId)}/databases/${encodeURIComponent(projectId)}/backups/pitr/jobs/${encodeURIComponent(jobId)}`);
|
|
840
|
+
},
|
|
841
|
+
/** Production plus the project's environments (staging ones and API versions): database status, what each database started with (database, copy_state) and its own API URL; limit is how many the plan allows. `GET /api/v1/governance/tenants/{org_id}/projects/{project_id}/environments` */
|
|
842
|
+
listEnvironments: (args = {}) => {
|
|
843
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
844
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
845
|
+
return request('GET', `/api/v1/governance/tenants/${encodeURIComponent(orgId)}/projects/${encodeURIComponent(projectId)}/environments`);
|
|
846
|
+
},
|
|
847
|
+
/** Create a branch (kind=branch: a copy of the system to change, then deploy; plan env.branches) or an environment (kind=staging | version; plan env.staging_environments), each with its own database in the project's container. database: empty | schema (default: production's structure, no rows) | sample (plus up to sample_rows newest rows per table and every row they reference; plan env.branch_data, Pro and higher) | all (every row, up to env.branch_data_max_gb; Ultra and higher). Personal columns are masked unless mask=false (owners/admins, audited). Rows are copied as a job: poll get_environment_copy. protected (plan env.protection) and expires_in_days (deleted automatically) are optional. `POST /api/v1/governance/tenants/{org_id}/projects/{project_id}/environments` */
|
|
848
|
+
createEnvironment: (args) => {
|
|
849
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
850
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
851
|
+
return request('POST', `/api/v1/governance/tenants/${encodeURIComponent(orgId)}/projects/${encodeURIComponent(projectId)}/environments`, { body: dropUndefined({ "env_id": args.envId, "name": args.name, "kind": args.kind, "label": args.label, "from_env_id": args.fromEnvId, "database": args.database, "sample_rows": args.sampleRows, "include_tables": args.includeTables, "exclude_tables": args.excludeTables, "mask": args.mask, "mask_add": args.maskAdd, "mask_skip": args.maskSkip, "protected": args.protected, "expires_in_days": args.expiresInDays }) });
|
|
852
|
+
},
|
|
853
|
+
/** What an environment's database started with and how its row copy is going: state copying | done | failed, tables and rows copied, masked columns, size, or why it failed. `GET /api/v1/governance/tenants/{org_id}/projects/{project_id}/environments/{env_id}/copy` */
|
|
854
|
+
getEnvironmentCopy: (args) => {
|
|
855
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
856
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
857
|
+
const envId = need('env_id', args.envId);
|
|
858
|
+
return request('GET', `/api/v1/governance/tenants/${encodeURIComponent(orgId)}/projects/${encodeURIComponent(projectId)}/environments/${encodeURIComponent(envId)}/copy`);
|
|
859
|
+
},
|
|
860
|
+
/** Delete an environment, its database (a backup is kept first), URL and Version history branch. Owners and admins; a protected environment is refused (ENVIRONMENT_PROTECTED). `DELETE /api/v1/governance/tenants/{org_id}/projects/{project_id}/environments/{env_id}` */
|
|
861
|
+
deleteEnvironment: (args) => {
|
|
862
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
863
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
864
|
+
const envId = need('env_id', args.envId);
|
|
865
|
+
return request('DELETE', `/api/v1/governance/tenants/${encodeURIComponent(orgId)}/projects/${encodeURIComponent(projectId)}/environments/${encodeURIComponent(envId)}`);
|
|
866
|
+
},
|
|
867
|
+
/** The project's SQL statements (pg_stat_statements) by total time, average, calls, worst run or rows. `GET /api/v1/governance/tenants/{org_id}/databases/{project_id}/query-insights` */
|
|
868
|
+
queryInsights: (args = {}) => {
|
|
869
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
870
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
871
|
+
return request('GET', `/api/v1/governance/tenants/${encodeURIComponent(orgId)}/databases/${encodeURIComponent(projectId)}/query-insights`, { query: dropUndefined({ "sort": args.sort, "limit": args.limit }) });
|
|
872
|
+
},
|
|
873
|
+
/** Clear this database's query statistics. `POST /api/v1/governance/tenants/{org_id}/databases/{project_id}/query-insights/reset` */
|
|
874
|
+
resetQueryInsights: (args = {}) => {
|
|
875
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
876
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
877
|
+
return request('POST', `/api/v1/governance/tenants/${encodeURIComponent(orgId)}/databases/${encodeURIComponent(projectId)}/query-insights/reset`, { body: {} });
|
|
878
|
+
},
|
|
879
|
+
/** Indexes that would speed up the slowest statements, tested as hypothetical indexes (hypopg). `GET /api/v1/governance/tenants/{org_id}/databases/{project_id}/index-advisor` */
|
|
880
|
+
indexAdvisor: (args = {}) => {
|
|
881
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
882
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
883
|
+
return request('GET', `/api/v1/governance/tenants/${encodeURIComponent(orgId)}/databases/${encodeURIComponent(projectId)}/index-advisor`, { query: dropUndefined({ "queryid": args.queryid }) });
|
|
884
|
+
},
|
|
885
|
+
/** Index recommendations for one statement (only EXPLAINed, never run). `POST /api/v1/governance/tenants/{org_id}/databases/{project_id}/index-advisor/query` */
|
|
886
|
+
indexAdvisorForQuery: (args) => {
|
|
887
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
888
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
889
|
+
return request('POST', `/api/v1/governance/tenants/${encodeURIComponent(orgId)}/databases/${encodeURIComponent(projectId)}/index-advisor/query`, { body: dropUndefined({ "query": args.query }) });
|
|
890
|
+
},
|
|
891
|
+
/** Build a recommended index with CREATE INDEX CONCURRENTLY (background; poll index_status). `POST /api/v1/governance/tenants/{org_id}/databases/{project_id}/index-advisor/apply` */
|
|
892
|
+
applyIndex: (args) => {
|
|
893
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
894
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
895
|
+
return request('POST', `/api/v1/governance/tenants/${encodeURIComponent(orgId)}/databases/${encodeURIComponent(projectId)}/index-advisor/apply`, { body: dropUndefined({ "schema": args.schema, "table": args.table, "columns": args.columns }) });
|
|
896
|
+
},
|
|
897
|
+
/** Whether an index the advisor started is building, ready, failed or invalid. `GET /api/v1/governance/tenants/{org_id}/databases/{project_id}/index-advisor/indexes/{index_name}` */
|
|
898
|
+
indexStatus: (args) => {
|
|
899
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
900
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
901
|
+
const indexName = need('index_name', args.indexName);
|
|
902
|
+
return request('GET', `/api/v1/governance/tenants/${encodeURIComponent(orgId)}/databases/${encodeURIComponent(projectId)}/index-advisor/indexes/${encodeURIComponent(indexName)}`);
|
|
903
|
+
},
|
|
904
|
+
/** Change an environment (owners and admins): kind staging | version (with label, e.g. v2), protected (plan env.protection: no delete, reset or restore until turned off), expires_in_days (deleted automatically after that many days; 0 clears it). `PATCH /api/v1/governance/tenants/{org_id}/projects/{project_id}/environments/{env_id}` */
|
|
905
|
+
updateEnvironment: (args) => {
|
|
906
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
907
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
908
|
+
const envId = need('env_id', args.envId);
|
|
909
|
+
return request('PATCH', `/api/v1/governance/tenants/${encodeURIComponent(orgId)}/projects/${encodeURIComponent(projectId)}/environments/${encodeURIComponent(envId)}`, { body: dropUndefined({ "kind": args.kind, "label": args.label, "protected": args.protected, "expires_in_days": args.expiresInDays }) });
|
|
910
|
+
},
|
|
911
|
+
/** Make an environment's database again from the one it started from (its parent environment, else production) with the same data option; sample/all rows are copied again with the same masking. A backup is taken first; functions and policies are kept. `POST /api/v1/governance/tenants/{org_id}/projects/{project_id}/environments/{env_id}/reset` */
|
|
912
|
+
resetEnvironment: (args) => {
|
|
913
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
914
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
915
|
+
const envId = need('env_id', args.envId);
|
|
916
|
+
return request('POST', `/api/v1/governance/tenants/${encodeURIComponent(orgId)}/projects/${encodeURIComponent(projectId)}/environments/${encodeURIComponent(envId)}/reset`, { body: dropUndefined({ "confirm": args.confirm }) });
|
|
917
|
+
},
|
|
918
|
+
/** Put an environment's database back as it was at `at` (point-in-time, within db.pitr_retention_days; production is not touched). Runs as a job: poll get_environment_restore. `POST /api/v1/governance/tenants/{org_id}/projects/{project_id}/environments/{env_id}/restore` */
|
|
919
|
+
restoreEnvironment: (args) => {
|
|
920
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
921
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
922
|
+
const envId = need('env_id', args.envId);
|
|
923
|
+
return request('POST', `/api/v1/governance/tenants/${encodeURIComponent(orgId)}/projects/${encodeURIComponent(projectId)}/environments/${encodeURIComponent(envId)}/restore`, { body: dropUndefined({ "at": args.at, "confirm": args.confirm }) });
|
|
924
|
+
},
|
|
925
|
+
/** How an environment restore is going: status running | done | failed, phase, recovered_to, error. `GET /api/v1/governance/tenants/{org_id}/projects/{project_id}/environments/{env_id}/restore/{restore_id}` */
|
|
926
|
+
getEnvironmentRestore: (args) => {
|
|
927
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
928
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
929
|
+
const envId = need('env_id', args.envId);
|
|
930
|
+
const restoreId = need('restore_id', args.restoreId);
|
|
931
|
+
return request('GET', `/api/v1/governance/tenants/${encodeURIComponent(orgId)}/projects/${encodeURIComponent(projectId)}/environments/${encodeURIComponent(envId)}/restore/${encodeURIComponent(restoreId)}`);
|
|
932
|
+
},
|
|
933
|
+
/** Backup health: last good backup, failures since, recovery point (RPO) of daily backups and PITR, retention and on-demand limits with what was used. `GET /api/v1/governance/tenants/{org_id}/databases/{project_id}/backups/health` */
|
|
934
|
+
getBackupHealth: (args = {}) => {
|
|
935
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
936
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
937
|
+
return request('GET', `/api/v1/governance/tenants/${encodeURIComponent(orgId)}/databases/${encodeURIComponent(projectId)}/backups/health`);
|
|
938
|
+
},
|
|
939
|
+
/** Portable export bundles of the project (Postgres dump + migration metadata). `GET /api/v1/governance/tenants/{org_id}/databases/{project_id}/exports` */
|
|
940
|
+
listProjectExports: (args = {}) => {
|
|
941
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
942
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
943
|
+
return request('GET', `/api/v1/governance/tenants/${encodeURIComponent(orgId)}/databases/${encodeURIComponent(projectId)}/exports`, { query: dropUndefined({ "limit": args.limit }) });
|
|
944
|
+
},
|
|
945
|
+
/** Create a portable export bundle (download it with download_project_export). `POST /api/v1/governance/tenants/{org_id}/databases/{project_id}/exports` */
|
|
946
|
+
triggerProjectExport: (args = {}) => {
|
|
947
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
948
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
949
|
+
return request('POST', `/api/v1/governance/tenants/${encodeURIComponent(orgId)}/databases/${encodeURIComponent(projectId)}/exports`, { body: {} });
|
|
950
|
+
},
|
|
951
|
+
/** A compare job: running, failed (with error) or the full answer with status done. `GET /api/v1/governance/tenants/{org_id}/databases/{project_id}/compare/{compare_id}` */
|
|
952
|
+
getCompare: (args) => {
|
|
953
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
954
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
955
|
+
const compareId = need('compare_id', args.compareId);
|
|
956
|
+
return request('GET', `/api/v1/governance/tenants/${encodeURIComponent(orgId)}/databases/${encodeURIComponent(projectId)}/compare/${encodeURIComponent(compareId)}`);
|
|
957
|
+
},
|
|
958
|
+
/** Restore this project's backup (backup_id) or a moment (target_time) into an environment of the project (env_id) or another project (project_id) instead of replacing production. Owners/admins; confirm: true; counts as a rollback. `POST /api/v1/governance/tenants/{org_id}/databases/{project_id}/restore-into` */
|
|
959
|
+
restoreDatabaseInto: (args = {}) => {
|
|
960
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
961
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
962
|
+
return request('POST', `/api/v1/governance/tenants/${encodeURIComponent(orgId)}/databases/${encodeURIComponent(projectId)}/restore-into`, { body: dropUndefined({ "env_id": args.envId, "project_id": args.targetProjectId, "backup_id": args.backupId, "target_time": args.targetTime, "confirm": args.confirm, "reason": args.reason }) });
|
|
963
|
+
},
|
|
964
|
+
/** Copy single tables from a backup or a moment into production as restored_<table>_<stamp> beside the live ones (nothing live changes). Owners/admins; counts as a rollback. `POST /api/v1/governance/tenants/{org_id}/databases/{project_id}/restore-tables` */
|
|
965
|
+
restoreDatabaseTables: (args) => {
|
|
966
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
967
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
968
|
+
return request('POST', `/api/v1/governance/tenants/${encodeURIComponent(orgId)}/databases/${encodeURIComponent(projectId)}/restore-tables`, { body: dropUndefined({ "tables": args.tables, "backup_id": args.backupId, "target_time": args.targetTime, "reason": args.reason }) });
|
|
969
|
+
},
|
|
970
|
+
},
|
|
971
|
+
history: {
|
|
972
|
+
/** Create a Chrono commit. `POST /api/v1/chrono/commit` */
|
|
973
|
+
commit: (args) => request('POST', `/api/v1/chrono/commit`, { body: dropUndefined({ "timeline": args.timeline, "message": args.message, "author": args.author, "event_type": args.eventType }) }),
|
|
974
|
+
/** Converge source timeline into target timeline. Branches that record an environment are refused (409 USE_DEPLOY): deploy them with promote_environment. `POST /api/v1/chrono/timelines/converge` */
|
|
975
|
+
converge: (args) => request('POST', `/api/v1/chrono/timelines/converge`, { body: dropUndefined({ "target": args.target, "source": args.source, "author": args.author, "message": args.message }) }),
|
|
976
|
+
/** Name a point on a branch to go back to (timeline: main = production, or a branch's name; env_id: the environment checked out, '' = production). include_database also keeps a checkpoint of that branch's database (a backup taken now), so restoring brings the data back exactly. `POST /api/v1/chrono/snapshots/create` */
|
|
977
|
+
createSnapshot: (args = {}) => request('POST', `/api/v1/chrono/snapshots/create`, { body: dropUndefined({ "message": args.message, "timeline": args.timeline, "env_id": args.envId, "include_database": args.includeDatabase }) }),
|
|
978
|
+
/** Delete a timeline. `DELETE /api/v1/chrono/timelines/{name}` */
|
|
979
|
+
deleteTimeline: (args) => {
|
|
980
|
+
const name = need('name', args.name);
|
|
981
|
+
return request('DELETE', `/api/v1/chrono/timelines/${encodeURIComponent(name)}`);
|
|
982
|
+
},
|
|
983
|
+
/** Move a history-only branch to a commit. main and branches that record an environment only move forward (409 USE_RESTORE): use restore. `POST /api/v1/chrono/timelines/{name}/jump` */
|
|
984
|
+
jumpTimeline: (args) => {
|
|
985
|
+
const name = need('name', args.name);
|
|
986
|
+
return request('POST', `/api/v1/chrono/timelines/${encodeURIComponent(name)}/jump`, { body: dropUndefined({ "target_hex": args.targetHex }) });
|
|
987
|
+
},
|
|
988
|
+
/** Snapshots with their branch (timeline, env_id) and database checkpoint (database: kind, backup_id, at) when one was kept. timeline lists one branch's. `GET /api/v1/chrono/snapshots` */
|
|
989
|
+
listSnapshots: (args = {}) => request('GET', `/api/v1/chrono/snapshots`, { query: dropUndefined({ "timeline": args.timeline }) }),
|
|
990
|
+
/** Branches: name, head_hex, kind (production | environment | history) and env_id for an environment's branch. `GET /api/v1/chrono/timelines` */
|
|
991
|
+
listTimelines: () => request('GET', `/api/v1/chrono/timelines`),
|
|
992
|
+
/** Go back to a snapshot on its branch (confirm=true; review restore_snapshot_plan first): policies, settings, functions and buckets are put back with your own permissions; include_schema rolls back migrations since then and include_database puts the database back from the snapshot's checkpoint (or the closest backup before it). `POST /api/v1/chrono/snapshots/{snapshot_id}/restore` */
|
|
993
|
+
restoreSnapshot: (args) => {
|
|
994
|
+
const snapshotId = need('snapshot_id', args.snapshotId);
|
|
995
|
+
return request('POST', `/api/v1/chrono/snapshots/${encodeURIComponent(snapshotId)}/restore`, { body: dropUndefined({ "confirm": args.confirm, "include_database": args.includeDatabase, "include_schema": args.includeSchema, "env_id": args.envId }) });
|
|
996
|
+
},
|
|
997
|
+
/** What restoring a snapshot puts back on its branch, change by change, with who would gain or lose access (writes nothing). `POST /api/v1/chrono/snapshots/{snapshot_id}/restore-plan` */
|
|
998
|
+
restoreSnapshotPlan: (args) => {
|
|
999
|
+
const snapshotId = need('snapshot_id', args.snapshotId);
|
|
1000
|
+
return request('POST', `/api/v1/chrono/snapshots/${encodeURIComponent(snapshotId)}/restore-plan`, { body: dropUndefined({ "env_id": args.envId }) });
|
|
1001
|
+
},
|
|
1002
|
+
/** Forget a snapshot (its commit stays in the history; its database checkpoint expires like a manual backup). `DELETE /api/v1/chrono/snapshots/{snapshot_id}` */
|
|
1003
|
+
deleteSnapshot: (args) => {
|
|
1004
|
+
const snapshotId = need('snapshot_id', args.snapshotId);
|
|
1005
|
+
return request('DELETE', `/api/v1/chrono/snapshots/${encodeURIComponent(snapshotId)}`);
|
|
1006
|
+
},
|
|
1007
|
+
/** Spawn a new timeline from a source chronon. `POST /api/v1/chrono/timelines/spawn` */
|
|
1008
|
+
spawnTimeline: (args) => request('POST', `/api/v1/chrono/timelines/spawn`, { body: dropUndefined({ "name": args.name, "source_hex_id": args.sourceHexId }) }),
|
|
1009
|
+
/** Fetch timeline history chronons. `GET /api/v1/chrono/timelines/{name}/history` */
|
|
1010
|
+
timelineHistory: (args) => {
|
|
1011
|
+
const name = need('name', args.name);
|
|
1012
|
+
return request('GET', `/api/v1/chrono/timelines/${encodeURIComponent(name)}/history`, { query: dropUndefined({ "limit": args.limit, "offset": args.offset }) });
|
|
1013
|
+
},
|
|
1014
|
+
/** Return timeline graph topology. `GET /api/v1/chrono/timelines/topology` */
|
|
1015
|
+
topology: (args = {}) => request('GET', `/api/v1/chrono/timelines/topology`, { query: dropUndefined({ "timeline": args.timeline, "limit": args.limit }) }),
|
|
1016
|
+
/** Calculate variance between two chronons. `POST /api/v1/chrono/variance` */
|
|
1017
|
+
variance: (args) => request('POST', `/api/v1/chrono/variance`, { body: dropUndefined({ "old_chronon_hex": args.oldChrononHex, "new_chronon_hex": args.newChrononHex, "domain_filter": args.domainFilter }) }),
|
|
1018
|
+
/** What going back to `at` (a commit id or ISO time) on a branch means, change by change, for that branch's own environment (main = production): automated actions, manual ones, changes from other branches (left alone), the opt-in schema rollback and database restore, and the access preview. env_id is the environment you have checked out ('' = production); a mismatch is refused (ENV_MISMATCH). Writes nothing. `POST /api/v1/chrono/restore-plan` */
|
|
1019
|
+
restorePlan: (args) => request('POST', `/api/v1/chrono/restore-plan`, { body: dropUndefined({ "at": args.at, "timeline": args.timeline, "env_id": args.envId, "only": args.only, "include_database": args.includeDatabase, "include_schema": args.includeSchema }) }),
|
|
1020
|
+
/** Apply the restore plan with your own permissions, in the branch's own environment: configuration first, then the schema rollback (include_schema), then the database (include_database). Waits briefly for the new commits: new_head, or recording=true while they are still arriving (poll the branch until its head moves past head_before). `POST /api/v1/chrono/restore` */
|
|
1021
|
+
restore: (args) => request('POST', `/api/v1/chrono/restore`, { body: dropUndefined({ "at": args.at, "timeline": args.timeline, "env_id": args.envId, "only": args.only, "include_database": args.includeDatabase, "include_schema": args.includeSchema, "confirm": args.confirm }) }),
|
|
1022
|
+
/** What one commit changed (or how it differs from compare_to), item by item: policy, table, function, settings, bucket, with a summary in words and each item's previous version. `GET /api/v1/chrono/commits/{hex_id}/changes` */
|
|
1023
|
+
commitChanges: (args) => {
|
|
1024
|
+
const hexId = need('hex_id', args.hexId);
|
|
1025
|
+
return request('GET', `/api/v1/chrono/commits/${encodeURIComponent(hexId)}/changes`, { query: dropUndefined({ "compare_to": args.compareTo }) });
|
|
1026
|
+
},
|
|
1027
|
+
/** What undoing exactly one commit puts back on the branch's environment (writes nothing), with the schema rollback dry run when the commit applied a migration. `POST /api/v1/chrono/commits/{hex_id}/undo-plan` */
|
|
1028
|
+
undoPlan: (args) => {
|
|
1029
|
+
const hexId = need('hex_id', args.hexId);
|
|
1030
|
+
return request('POST', `/api/v1/chrono/commits/${encodeURIComponent(hexId)}/undo-plan`, { body: dropUndefined({ "timeline": args.timeline, "env_id": args.envId }) });
|
|
1031
|
+
},
|
|
1032
|
+
/** Undo one commit with your own permissions on the branch's environment; its migration's down SQL only with include_schema. `POST /api/v1/chrono/commits/{hex_id}/undo` */
|
|
1033
|
+
undo: (args) => {
|
|
1034
|
+
const hexId = need('hex_id', args.hexId);
|
|
1035
|
+
return request('POST', `/api/v1/chrono/commits/${encodeURIComponent(hexId)}/undo`, { body: dropUndefined({ "confirm": args.confirm, "timeline": args.timeline, "env_id": args.envId, "include_schema": args.includeSchema }) });
|
|
1036
|
+
},
|
|
1037
|
+
/** Which Version history branch records which environment ({env_id, branch}). main is production's. `GET /api/v1/chrono/environments` */
|
|
1038
|
+
listEnvironmentBranches: () => request('GET', `/api/v1/chrono/environments`),
|
|
1039
|
+
/** Give an environment its own Version history branch (spawned from main's head), for environments made before branches recorded them; returns the branch it has. `PUT /api/v1/chrono/environments/{env_id}` */
|
|
1040
|
+
bindEnvironment: (args) => {
|
|
1041
|
+
const envId = need('env_id', args.envId);
|
|
1042
|
+
return request('PUT', `/api/v1/chrono/environments/${encodeURIComponent(envId)}`, { body: dropUndefined({ "name": args.name }) });
|
|
1043
|
+
},
|
|
1044
|
+
},
|
|
1045
|
+
knowledge: {
|
|
1046
|
+
/** Knowledge bases (RAG) with documents, chunks, tokens, the embedding model and estimated cost. `GET /api/v1/data/rel/vector/knowledge` */
|
|
1047
|
+
list: () => request('GET', `/api/v1/data/rel/vector/knowledge`),
|
|
1048
|
+
/** Create a knowledge base: name, description, access (team | app_users), user_uploads, chunk_tokens. `POST /api/v1/data/rel/vector/knowledge` */
|
|
1049
|
+
create: (args) => request('POST', `/api/v1/data/rel/vector/knowledge`, { body: args.body }),
|
|
1050
|
+
/** Change a knowledge base's description, access or user_uploads. `PATCH /api/v1/data/rel/vector/knowledge/{name}` */
|
|
1051
|
+
update: (args) => {
|
|
1052
|
+
const name = need('name', args.name);
|
|
1053
|
+
return request('PATCH', `/api/v1/data/rel/vector/knowledge/${encodeURIComponent(name)}`, { body: args.body });
|
|
1054
|
+
},
|
|
1055
|
+
/** Delete a knowledge base with all its documents. `DELETE /api/v1/data/rel/vector/knowledge/{name}` */
|
|
1056
|
+
delete: (args) => {
|
|
1057
|
+
const name = need('name', args.name);
|
|
1058
|
+
return request('DELETE', `/api/v1/data/rel/vector/knowledge/${encodeURIComponent(name)}`);
|
|
1059
|
+
},
|
|
1060
|
+
/** Documents the caller may read: title, source, chunks, tokens, status. `GET /api/v1/data/rel/vector/knowledge/{name}/documents` */
|
|
1061
|
+
listDocuments: (args) => {
|
|
1062
|
+
const name = need('name', args.name);
|
|
1063
|
+
return request('GET', `/api/v1/data/rel/vector/knowledge/${encodeURIComponent(name)}/documents`, { query: dropUndefined({ "limit": args.limit, "offset": args.offset }) });
|
|
1064
|
+
},
|
|
1065
|
+
/** Add or replace a document: text (+format), content_base64 + filename (PDF, DOCX, HTML, Markdown, TXT, CSV, JSON) or url; optional document_id, title, metadata. refresh_hours (url, team) fetches the page again on a schedule. `POST /api/v1/data/rel/vector/knowledge/{name}/documents` */
|
|
1066
|
+
addDocument: (args) => {
|
|
1067
|
+
const name = need('name', args.name);
|
|
1068
|
+
return request('POST', `/api/v1/data/rel/vector/knowledge/${encodeURIComponent(name)}/documents`, { body: args.body });
|
|
1069
|
+
},
|
|
1070
|
+
/** Remove a document (its owner or the team). `DELETE /api/v1/data/rel/vector/knowledge/{name}/documents/{document_id}` */
|
|
1071
|
+
deleteDocument: (args) => {
|
|
1072
|
+
const name = need('name', args.name);
|
|
1073
|
+
const documentId = need('document_id', args.documentId);
|
|
1074
|
+
return request('DELETE', `/api/v1/data/rel/vector/knowledge/${encodeURIComponent(name)}/documents/${encodeURIComponent(documentId)}`);
|
|
1075
|
+
},
|
|
1076
|
+
/** Passages for a question with numbered citations: query, k, mode (vector | keyword | hybrid), metadata_filter, document_ids (up to 50), rerank. Only passages the caller may read. `POST /api/v1/data/rel/vector/knowledge/{name}/search` */
|
|
1077
|
+
search: (args) => {
|
|
1078
|
+
const name = need('name', args.name);
|
|
1079
|
+
return request('POST', `/api/v1/data/rel/vector/knowledge/${encodeURIComponent(name)}/search`, { body: args.body });
|
|
1080
|
+
},
|
|
1081
|
+
/** URL documents fetched again on a schedule (refresh_hours): next fetch, last error. `GET /api/v1/data/rel/vector/knowledge/{name}/sources` */
|
|
1082
|
+
listSources: (args) => {
|
|
1083
|
+
const name = need('name', args.name);
|
|
1084
|
+
return request('GET', `/api/v1/data/rel/vector/knowledge/${encodeURIComponent(name)}/sources`);
|
|
1085
|
+
},
|
|
1086
|
+
},
|
|
1087
|
+
mcp: {
|
|
1088
|
+
/** AI assistants you connected over Sovaria's MCP server: the app, its organization and project, read-only or not, when it was connected and last used. `GET /api/v1/auth/mcp/connections` */
|
|
1089
|
+
listConnections: () => request('GET', `/api/v1/auth/mcp/connections`),
|
|
1090
|
+
/** Disconnect one of your AI assistants: its tokens stop working at once. `DELETE /api/v1/auth/mcp/connections/{grant_id}` */
|
|
1091
|
+
disconnect: (args) => {
|
|
1092
|
+
const grantId = need('grant_id', args.grantId);
|
|
1093
|
+
return request('DELETE', `/api/v1/auth/mcp/connections/${encodeURIComponent(grantId)}`);
|
|
1094
|
+
},
|
|
1095
|
+
/** Whether members may connect AI assistants to this organization, the MCP server URL, and (owners and admins) every member's connection. `GET /api/v1/org/{org_id}/mcp` */
|
|
1096
|
+
orgSettings: (args = {}) => {
|
|
1097
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
1098
|
+
return request('GET', `/api/v1/org/${encodeURIComponent(orgId)}/mcp`);
|
|
1099
|
+
},
|
|
1100
|
+
/** Allow or stop AI assistants for the organization (owners and admins). Turning it off ends every member's connection. `PUT /api/v1/org/{org_id}/mcp` */
|
|
1101
|
+
setOrgAllowed: (args) => {
|
|
1102
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
1103
|
+
return request('PUT', `/api/v1/org/${encodeURIComponent(orgId)}/mcp`, { body: dropUndefined({ "allowed": args.allowed }) });
|
|
1104
|
+
},
|
|
1105
|
+
/** Disconnect a member's AI assistant from the organization (owners and admins). `DELETE /api/v1/org/{org_id}/mcp/connections/{grant_id}` */
|
|
1106
|
+
orgDisconnect: (args) => {
|
|
1107
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
1108
|
+
const grantId = need('grant_id', args.grantId);
|
|
1109
|
+
return request('DELETE', `/api/v1/org/${encodeURIComponent(orgId)}/mcp/connections/${encodeURIComponent(grantId)}`);
|
|
1110
|
+
},
|
|
1111
|
+
},
|
|
1112
|
+
messaging: {
|
|
1113
|
+
/** Message templates of the project (push and/or email content with {{ variables }}). `GET /api/v1/projects/{project_id}/messaging/templates` */
|
|
1114
|
+
listTemplates: (args = {}) => {
|
|
1115
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
1116
|
+
return request('GET', `/api/v1/projects/${encodeURIComponent(projectId)}/messaging/templates`);
|
|
1117
|
+
},
|
|
1118
|
+
/** One message template. `GET /api/v1/projects/{project_id}/messaging/templates/{name}` */
|
|
1119
|
+
getTemplate: (args) => {
|
|
1120
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
1121
|
+
const name = need('name', args.name);
|
|
1122
|
+
return request('GET', `/api/v1/projects/${encodeURIComponent(projectId)}/messaging/templates/${encodeURIComponent(name)}`);
|
|
1123
|
+
},
|
|
1124
|
+
/** Create or replace a template: push {title, body, image?, data?}, email {subject, html?, text?}; category transactional or marketing (marketing skips opted-out users and adds an unsubscribe link). `PUT /api/v1/projects/{project_id}/messaging/templates/{name}` */
|
|
1125
|
+
putTemplate: (args) => {
|
|
1126
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
1127
|
+
const name = need('name', args.name);
|
|
1128
|
+
return request('PUT', `/api/v1/projects/${encodeURIComponent(projectId)}/messaging/templates/${encodeURIComponent(name)}`, { body: dropUndefined({ "description": args.description, "category": args.category, "push": args.push, "email": args.email }) });
|
|
1129
|
+
},
|
|
1130
|
+
/** Delete a message template. `DELETE /api/v1/projects/{project_id}/messaging/templates/{name}` */
|
|
1131
|
+
deleteTemplate: (args) => {
|
|
1132
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
1133
|
+
const name = need('name', args.name);
|
|
1134
|
+
return request('DELETE', `/api/v1/projects/${encodeURIComponent(projectId)}/messaging/templates/${encodeURIComponent(name)}`);
|
|
1135
|
+
},
|
|
1136
|
+
/** Saved audiences: read-only SQL queries returning user_id (other columns become per-user variables). `GET /api/v1/projects/{project_id}/messaging/audiences` */
|
|
1137
|
+
listAudiences: (args = {}) => {
|
|
1138
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
1139
|
+
return request('GET', `/api/v1/projects/${encodeURIComponent(projectId)}/messaging/audiences`);
|
|
1140
|
+
},
|
|
1141
|
+
/** One audience and its last count. `GET /api/v1/projects/{project_id}/messaging/audiences/{name}` */
|
|
1142
|
+
getAudience: (args) => {
|
|
1143
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
1144
|
+
const name = need('name', args.name);
|
|
1145
|
+
return request('GET', `/api/v1/projects/${encodeURIComponent(projectId)}/messaging/audiences/${encodeURIComponent(name)}`);
|
|
1146
|
+
},
|
|
1147
|
+
/** Create or replace an audience: a SELECT on the project database returning user_id (e.g. select user_id, first_name from profiles where plan = 'pro'). `PUT /api/v1/projects/{project_id}/messaging/audiences/{name}` */
|
|
1148
|
+
putAudience: (args) => {
|
|
1149
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
1150
|
+
const name = need('name', args.name);
|
|
1151
|
+
return request('PUT', `/api/v1/projects/${encodeURIComponent(projectId)}/messaging/audiences/${encodeURIComponent(name)}`, { body: dropUndefined({ "sql": args.sql, "description": args.description }) });
|
|
1152
|
+
},
|
|
1153
|
+
/** Delete an audience. `DELETE /api/v1/projects/{project_id}/messaging/audiences/{name}` */
|
|
1154
|
+
deleteAudience: (args) => {
|
|
1155
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
1156
|
+
const name = need('name', args.name);
|
|
1157
|
+
return request('DELETE', `/api/v1/projects/${encodeURIComponent(projectId)}/messaging/audiences/${encodeURIComponent(name)}`);
|
|
1158
|
+
},
|
|
1159
|
+
/** Run a saved audience: how many app users it reaches, columns and a sample of 10. `POST /api/v1/projects/{project_id}/messaging/audiences/{name}/preview` */
|
|
1160
|
+
previewAudience: (args) => {
|
|
1161
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
1162
|
+
const name = need('name', args.name);
|
|
1163
|
+
return request('POST', `/api/v1/projects/${encodeURIComponent(projectId)}/messaging/audiences/${encodeURIComponent(name)}/preview`, { body: {} });
|
|
1164
|
+
},
|
|
1165
|
+
/** Try an audience query before saving it: app users reached, columns and a sample. `POST /api/v1/projects/{project_id}/messaging/audiences/preview` */
|
|
1166
|
+
previewSql: (args) => {
|
|
1167
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
1168
|
+
return request('POST', `/api/v1/projects/${encodeURIComponent(projectId)}/messaging/audiences/preview`, { body: dropUndefined({ "sql": args.sql }) });
|
|
1169
|
+
},
|
|
1170
|
+
/** Send a template (or content {push, email}) to {user_ids | audience | sql | topic | all_users} on push and/or email, with variables; dry_run reports who would get it and renders a preview. send_at schedules it (timezone 'user' = that local time for each recipient). A durable job sends it; poll getSend. `POST /api/v1/projects/{project_id}/messaging/send` */
|
|
1171
|
+
send: (args) => {
|
|
1172
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
1173
|
+
return request('POST', `/api/v1/projects/${encodeURIComponent(projectId)}/messaging/send`, { body: dropUndefined({ "template": args.template, "content": args.content, "to": args.to, "channels": args.channels, "variables": args.variables, "category": args.category, "dry_run": args.dryRun, "send_at": args.sendAt, "timezone": args.timezone, "timezone_fallback": args.timezoneFallback, "track": args.track }) });
|
|
1174
|
+
},
|
|
1175
|
+
/** Recent sends with status and per-channel counts. `GET /api/v1/projects/{project_id}/messaging/sends` */
|
|
1176
|
+
listSends: (args = {}) => {
|
|
1177
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
1178
|
+
return request('GET', `/api/v1/projects/${encodeURIComponent(projectId)}/messaging/sends`, { query: dropUndefined({ "limit": args.limit }) });
|
|
1179
|
+
},
|
|
1180
|
+
/** One send: status (sending, done, failed) and counts per channel and outcome. `GET /api/v1/projects/{project_id}/messaging/sends/{send_id}` */
|
|
1181
|
+
getSend: (args) => {
|
|
1182
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
1183
|
+
const sendId = need('send_id', args.sendId);
|
|
1184
|
+
return request('GET', `/api/v1/projects/${encodeURIComponent(projectId)}/messaging/sends/${encodeURIComponent(sendId)}`);
|
|
1185
|
+
},
|
|
1186
|
+
/** Delivery log: per recipient and channel, sent / failed / no_device / no_email / opted_out with an error code (never content). `GET /api/v1/projects/{project_id}/messaging/deliveries` */
|
|
1187
|
+
listDeliveries: (args = {}) => {
|
|
1188
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
1189
|
+
return request('GET', `/api/v1/projects/${encodeURIComponent(projectId)}/messaging/deliveries`, { query: dropUndefined({ "send_id": args.sendId, "user_id": args.userId, "status": args.status, "limit": args.limit, "offset": args.offset }) });
|
|
1190
|
+
},
|
|
1191
|
+
/** Messages sent this month per channel and the plan's messaging limits. `GET /api/v1/projects/{project_id}/messaging/usage` */
|
|
1192
|
+
usage: (args = {}) => {
|
|
1193
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
1194
|
+
return request('GET', `/api/v1/projects/${encodeURIComponent(projectId)}/messaging/usage`);
|
|
1195
|
+
},
|
|
1196
|
+
/** Record an app user's marketing choice (channel push, email or all) from your own UI. `PUT /api/v1/projects/{project_id}/messaging/users/{user_id}/optouts` */
|
|
1197
|
+
setUserOptout: (args) => {
|
|
1198
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
1199
|
+
const userId = need('user_id', args.userId);
|
|
1200
|
+
return request('PUT', `/api/v1/projects/${encodeURIComponent(projectId)}/messaging/users/${encodeURIComponent(userId)}/optouts`, { body: dropUndefined({ "channel": args.channel, "opted_out": args.optedOut }) });
|
|
1201
|
+
},
|
|
1202
|
+
/** The signed-in app user's marketing preferences per channel. `GET /api/v1/messaging/preferences` */
|
|
1203
|
+
getPreferences: () => request('GET', `/api/v1/messaging/preferences`),
|
|
1204
|
+
/** The signed-in app user turns marketing push/email on or off: { marketing: { email: false } }. `PUT /api/v1/messaging/preferences` */
|
|
1205
|
+
setPreferences: (args) => request('PUT', `/api/v1/messaging/preferences`, { body: dropUndefined({ "marketing": args.marketing }) }),
|
|
1206
|
+
/** Cancel a scheduled or running send (recipients not reached yet get nothing). `POST /api/v1/projects/{project_id}/messaging/sends/{send_id}/cancel` */
|
|
1207
|
+
cancelSend: (args) => {
|
|
1208
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
1209
|
+
const sendId = need('send_id', args.sendId);
|
|
1210
|
+
return request('POST', `/api/v1/projects/${encodeURIComponent(projectId)}/messaging/sends/${encodeURIComponent(sendId)}/cancel`, { body: {} });
|
|
1211
|
+
},
|
|
1212
|
+
/** In-app messages of the project with impressions, clicks and dismissals. `GET /api/v1/projects/{project_id}/messaging/in-app` */
|
|
1213
|
+
listInApp: (args = {}) => {
|
|
1214
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
1215
|
+
return request('GET', `/api/v1/projects/${encodeURIComponent(projectId)}/messaging/in-app`);
|
|
1216
|
+
},
|
|
1217
|
+
/** Create or replace an in-app message: content {title, body, image, layout, buttons}, trigger (app_open, screen:x, event:x), audience, window, max impressions per user. `PUT /api/v1/projects/{project_id}/messaging/in-app/{name}` */
|
|
1218
|
+
putInApp: (args) => {
|
|
1219
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
1220
|
+
const name = need('name', args.name);
|
|
1221
|
+
return request('PUT', `/api/v1/projects/${encodeURIComponent(projectId)}/messaging/in-app/${encodeURIComponent(name)}`, { body: dropUndefined({ "content": args.content, "trigger": args.trigger, "audience": args.audience, "status": args.status, "starts_at": args.startsAt, "ends_at": args.endsAt, "max_impressions": args.maxImpressions, "priority": args.priority }) });
|
|
1222
|
+
},
|
|
1223
|
+
/** Delete an in-app message. `DELETE /api/v1/projects/{project_id}/messaging/in-app/{name}` */
|
|
1224
|
+
deleteInApp: (args) => {
|
|
1225
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
1226
|
+
const name = need('name', args.name);
|
|
1227
|
+
return request('DELETE', `/api/v1/projects/${encodeURIComponent(projectId)}/messaging/in-app/${encodeURIComponent(name)}`);
|
|
1228
|
+
},
|
|
1229
|
+
/** The signed-in app user opened (or clicked) a message they were sent (push data sov_send). `POST /api/v1/messaging/events` */
|
|
1230
|
+
trackEvent: (args) => request('POST', `/api/v1/messaging/events`, { body: dropUndefined({ "send_id": args.sendId, "channel": args.channel, "kind": args.kind }) }),
|
|
1231
|
+
/** In-app messages the signed-in app user should see now for a trigger. `GET /api/v1/messaging/in-app` */
|
|
1232
|
+
myInApp: (args = {}) => request('GET', `/api/v1/messaging/in-app`, { query: dropUndefined({ "trigger": args.trigger, "limit": args.limit }) }),
|
|
1233
|
+
/** Report an in-app message impression, click or dismissal. `POST /api/v1/messaging/in-app/{message_id}/events` */
|
|
1234
|
+
inAppEvent: (args) => {
|
|
1235
|
+
const messageId = need('message_id', args.messageId);
|
|
1236
|
+
return request('POST', `/api/v1/messaging/in-app/${encodeURIComponent(messageId)}/events`, { body: dropUndefined({ "kind": args.kind }) });
|
|
1237
|
+
},
|
|
1238
|
+
},
|
|
1239
|
+
mobile: {
|
|
1240
|
+
/** Registered iOS/Android apps (bundle/package ids, redirect URIs). `GET /api/v1/projects/{project_id}/mobile/apps` */
|
|
1241
|
+
listApps: (args = {}) => {
|
|
1242
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
1243
|
+
return request('GET', `/api/v1/projects/${encodeURIComponent(projectId)}/mobile/apps`);
|
|
1244
|
+
},
|
|
1245
|
+
/** Register an app: platform, bundle_id+team_id (iOS) or package_name+sha256_cert_fingerprints (Android), redirect_uris. `POST /api/v1/projects/{project_id}/mobile/apps` */
|
|
1246
|
+
createApp: (args) => {
|
|
1247
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
1248
|
+
return request('POST', `/api/v1/projects/${encodeURIComponent(projectId)}/mobile/apps`, { body: args.body });
|
|
1249
|
+
},
|
|
1250
|
+
/** Change a registered app (name, ids, fingerprints, redirect URIs). `PATCH /api/v1/projects/{project_id}/mobile/apps/{app_id}` */
|
|
1251
|
+
updateApp: (args) => {
|
|
1252
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
1253
|
+
const appId = need('app_id', args.appId);
|
|
1254
|
+
return request('PATCH', `/api/v1/projects/${encodeURIComponent(projectId)}/mobile/apps/${encodeURIComponent(appId)}`, { body: args.body });
|
|
1255
|
+
},
|
|
1256
|
+
/** Remove a registered app. `DELETE /api/v1/projects/{project_id}/mobile/apps/{app_id}` */
|
|
1257
|
+
deleteApp: (args) => {
|
|
1258
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
1259
|
+
const appId = need('app_id', args.appId);
|
|
1260
|
+
return request('DELETE', `/api/v1/projects/${encodeURIComponent(projectId)}/mobile/apps/${encodeURIComponent(appId)}`);
|
|
1261
|
+
},
|
|
1262
|
+
/** An app user's signed-in devices and push tokens. `GET /api/v1/projects/{project_id}/users/{user_id}/devices` */
|
|
1263
|
+
listUserDevices: (args) => {
|
|
1264
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
1265
|
+
const userId = need('user_id', args.userId);
|
|
1266
|
+
return request('GET', `/api/v1/projects/${encodeURIComponent(projectId)}/users/${encodeURIComponent(userId)}/devices`);
|
|
1267
|
+
},
|
|
1268
|
+
/** Sign one of an app user's devices out (sessions and push tokens). `DELETE /api/v1/projects/{project_id}/users/{user_id}/devices/{device_id}` */
|
|
1269
|
+
revokeUserDevice: (args) => {
|
|
1270
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
1271
|
+
const userId = need('user_id', args.userId);
|
|
1272
|
+
const deviceId = need('device_id', args.deviceId);
|
|
1273
|
+
return request('DELETE', `/api/v1/projects/${encodeURIComponent(projectId)}/users/${encodeURIComponent(userId)}/devices/${encodeURIComponent(deviceId)}`);
|
|
1274
|
+
},
|
|
1275
|
+
},
|
|
1276
|
+
observability: {
|
|
1277
|
+
/** Requests, 4xx/5xx errors, latency (avg, p50, p95, p99) and bytes over time for the project, per gateway service. History by plan (obs.retention_days). `GET /api/v1/observability/metrics` */
|
|
1278
|
+
metrics: (args = {}) => request('GET', `/api/v1/observability/metrics`, { query: dropUndefined({ "hours": args.hours, "service": args.service, "points": args.points, "by_service": args.byService }) }),
|
|
1279
|
+
/** Recent requests, newest first (method, path, status, duration, service, trace_id, env_id). after = live tail, before = older page. `GET /api/v1/observability/logs` */
|
|
1280
|
+
logs: (args = {}) => request('GET', `/api/v1/observability/logs`, { query: dropUndefined({ "limit": args.limit, "service": args.service, "status": args.status, "q": args.q, "after": args.after, "before": args.before, "source": args.source, "env": args.env }) }),
|
|
1281
|
+
/** Latency (p50, p95, p99) and 4xx/5xx per route (method + path with ids collapsed), busiest first; env = comma-separated environment ids (main = none named), default all; route adds that route's series. `GET /api/v1/observability/routes` */
|
|
1282
|
+
routes: (args = {}) => request('GET', `/api/v1/observability/routes`, { query: dropUndefined({ "hours": args.hours, "env": args.env, "route": args.route, "limit": args.limit }) }),
|
|
1283
|
+
/** SLO alert rules with their state (ok, firing, no_data, paused), the plan limit (obs.alert_rules), the metric catalog and recent events. `GET /api/v1/observability/alerts` */
|
|
1284
|
+
alertsList: () => request('GET', `/api/v1/observability/alerts`),
|
|
1285
|
+
/** Create an alert rule: metric latency_p95_ms, latency_p99_ms, error_rate (5xx %), function_failures or db_connections; threshold; window 5-60 min; optional route/function target; team email and/or a signed HTTPS webhook (signing_secret returned once). Owners and admins. `POST /api/v1/observability/alerts` */
|
|
1286
|
+
alertsCreate: (args) => request('POST', `/api/v1/observability/alerts`, { body: dropUndefined({ "metric": args.metric, "threshold": args.threshold, "window_minutes": args.windowMinutes, "name": args.name, "target": args.target, "env": args.env, "min_requests": args.minRequests, "email": args.email, "webhook_url": args.webhookUrl }) }),
|
|
1287
|
+
/** Change an alert rule (any create field) or pause/resume it ({enabled: false}). `PATCH /api/v1/observability/alerts/{rule_id}` */
|
|
1288
|
+
alertsUpdate: (args) => {
|
|
1289
|
+
const ruleId = need('rule_id', args.ruleId);
|
|
1290
|
+
return request('PATCH', `/api/v1/observability/alerts/${encodeURIComponent(ruleId)}`, { body: args.body });
|
|
1291
|
+
},
|
|
1292
|
+
/** Delete an alert rule. `DELETE /api/v1/observability/alerts/{rule_id}` */
|
|
1293
|
+
alertsDelete: (args) => {
|
|
1294
|
+
const ruleId = need('rule_id', args.ruleId);
|
|
1295
|
+
return request('DELETE', `/api/v1/observability/alerts/${encodeURIComponent(ruleId)}`);
|
|
1296
|
+
},
|
|
1297
|
+
/** Measure the rule now (value, would_fire) and send an alert.test to its webhook. `POST /api/v1/observability/alerts/{rule_id}/test` */
|
|
1298
|
+
alertsTest: (args) => {
|
|
1299
|
+
const ruleId = need('rule_id', args.ruleId);
|
|
1300
|
+
return request('POST', `/api/v1/observability/alerts/${encodeURIComponent(ruleId)}/test`);
|
|
1301
|
+
},
|
|
1302
|
+
/** Fired and resolved alerts, newest first. `GET /api/v1/observability/alerts/events` */
|
|
1303
|
+
alertsEvents: (args = {}) => request('GET', `/api/v1/observability/alerts/events`, { query: dropUndefined({ "limit": args.limit }) }),
|
|
1304
|
+
},
|
|
1305
|
+
org: {
|
|
1306
|
+
/** `POST /api/v1/org/invites/accept` */
|
|
1307
|
+
acceptOrgInvite: (args) => request('POST', `/api/v1/org/invites/accept`, { body: dropUndefined({ "token": args.token }) }),
|
|
1308
|
+
/** Add a user as a member of an org/project node. `POST /api/v1/org/{org_id}/member` */
|
|
1309
|
+
addMember: (args) => {
|
|
1310
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
1311
|
+
return request('POST', `/api/v1/org/${encodeURIComponent(orgId)}/member`, { body: dropUndefined({ "user_id": args.userId, "role": args.role }) });
|
|
1312
|
+
},
|
|
1313
|
+
/** Connect two DAPG nodes with a typed relationship. `POST /api/v1/edge` */
|
|
1314
|
+
createEdge: (args) => request('POST', `/api/v1/edge`, { body: dropUndefined({ "source_id": args.sourceNodeId, "target_id": args.targetNodeId, "relation_type": args.relationType, "role": args.role }) }),
|
|
1315
|
+
/** `POST /api/v1/org/{org_id}/invites` */
|
|
1316
|
+
createOrgInvite: (args) => {
|
|
1317
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
1318
|
+
return request('POST', `/api/v1/org/${encodeURIComponent(orgId)}/invites`, { body: dropUndefined({ "email": args.email, "role": args.role }) });
|
|
1319
|
+
},
|
|
1320
|
+
/** `DELETE /api/v1/org/{org_id}` */
|
|
1321
|
+
deleteOrg: (args = {}) => {
|
|
1322
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
1323
|
+
return request('DELETE', `/api/v1/org/${encodeURIComponent(orgId)}`);
|
|
1324
|
+
},
|
|
1325
|
+
/** `POST /api/v1/apikeys/ensure-defaults` */
|
|
1326
|
+
ensureDefaultApiKeys: () => request('POST', `/api/v1/apikeys/ensure-defaults`, { body: {} }),
|
|
1327
|
+
/** List child nodes attached by a relation (e.g. OWNS, HAS_ENV). `GET /api/v1/org/{parent_id}/children` */
|
|
1328
|
+
getChildren: (args) => {
|
|
1329
|
+
const parentId = need('parent_id', args.parentId);
|
|
1330
|
+
return request('GET', `/api/v1/org/${encodeURIComponent(parentId)}/children`, { query: dropUndefined({ "relation": args.relation }) });
|
|
1331
|
+
},
|
|
1332
|
+
/** Resolve a user's roles on a resource by walking the DAPG. `GET /api/v1/context/{user_id}/{resource_id}` */
|
|
1333
|
+
getContext: (args) => {
|
|
1334
|
+
const userId = need('user_id', args.userId);
|
|
1335
|
+
const resourceId = need('resource_id', args.resourceId);
|
|
1336
|
+
return request('GET', `/api/v1/context/${encodeURIComponent(userId)}/${encodeURIComponent(resourceId)}`);
|
|
1337
|
+
},
|
|
1338
|
+
/** Fetch a single graph node by ID. `GET /api/v1/org/{node_id}` */
|
|
1339
|
+
getNode: (args) => {
|
|
1340
|
+
const nodeId = need('node_id', args.nodeId);
|
|
1341
|
+
return request('GET', `/api/v1/org/${encodeURIComponent(nodeId)}`);
|
|
1342
|
+
},
|
|
1343
|
+
/** `GET /api/v1/org/{project_id}/ref` */
|
|
1344
|
+
getProjectRef: (args = {}) => {
|
|
1345
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
1346
|
+
return request('GET', `/api/v1/org/${encodeURIComponent(projectId)}/ref`);
|
|
1347
|
+
},
|
|
1348
|
+
/** `GET /api/v1/project-settings` */
|
|
1349
|
+
getProjectSettings: () => request('GET', `/api/v1/project-settings`),
|
|
1350
|
+
/** `GET /api/v1/roles/catalog` */
|
|
1351
|
+
getRoleCatalog: () => request('GET', `/api/v1/roles/catalog`),
|
|
1352
|
+
/** `GET /api/v1/roles/matrix` */
|
|
1353
|
+
getRoleMatrix: () => request('GET', `/api/v1/roles/matrix`),
|
|
1354
|
+
/** Whether the saved role matrix is enforced, and the plan's role allowance `GET /api/v1/roles/matrix/status` */
|
|
1355
|
+
getRoleMatrixStatus: () => request('GET', `/api/v1/roles/matrix/status`),
|
|
1356
|
+
/** `GET /api/v1/apikeys` */
|
|
1357
|
+
listApiKeys: () => request('GET', `/api/v1/apikeys`),
|
|
1358
|
+
/** List graph nodes; when provided, ``node_type`` filters by type. `GET /api/v1/org` */
|
|
1359
|
+
listNodes: (args = {}) => request('GET', `/api/v1/org`, { query: dropUndefined({ "type": args.nodeType }) }),
|
|
1360
|
+
/** `GET /api/v1/org/{org_id}/members` */
|
|
1361
|
+
listOrgMembers: (args = {}) => {
|
|
1362
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
1363
|
+
return request('GET', `/api/v1/org/${encodeURIComponent(orgId)}/members`);
|
|
1364
|
+
},
|
|
1365
|
+
/** `DELETE /api/v1/org/{org_id}/member/{user_id}` */
|
|
1366
|
+
removeOrgMember: (args) => {
|
|
1367
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
1368
|
+
const userId = need('user_id', args.userId);
|
|
1369
|
+
return request('DELETE', `/api/v1/org/${encodeURIComponent(orgId)}/member/${encodeURIComponent(userId)}`);
|
|
1370
|
+
},
|
|
1371
|
+
/** `DELETE /api/v1/apikeys/{key_id}` */
|
|
1372
|
+
revokeApiKey: (args) => {
|
|
1373
|
+
const keyId = need('key_id', args.keyId);
|
|
1374
|
+
return request('DELETE', `/api/v1/apikeys/${encodeURIComponent(keyId)}`);
|
|
1375
|
+
},
|
|
1376
|
+
/** `PUT /api/v1/org/{org_id}/plan` */
|
|
1377
|
+
setOrgPlan: (args) => {
|
|
1378
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
1379
|
+
return request('PUT', `/api/v1/org/${encodeURIComponent(orgId)}/plan`, { body: dropUndefined({ "plan": args.plan }) });
|
|
1380
|
+
},
|
|
1381
|
+
/** `PUT /api/v1/org/{org_id}/member/{user_id}` */
|
|
1382
|
+
updateMemberRole: (args) => {
|
|
1383
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
1384
|
+
const userId = need('user_id', args.userId);
|
|
1385
|
+
return request('PUT', `/api/v1/org/${encodeURIComponent(orgId)}/member/${encodeURIComponent(userId)}`, { body: dropUndefined({ "role": args.role }) });
|
|
1386
|
+
},
|
|
1387
|
+
/** `PUT /api/v1/org/{org_id}` */
|
|
1388
|
+
updateOrg: (args) => {
|
|
1389
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
1390
|
+
return request('PUT', `/api/v1/org/${encodeURIComponent(orgId)}`, { body: args.body });
|
|
1391
|
+
},
|
|
1392
|
+
/** `PUT /api/v1/project-settings` */
|
|
1393
|
+
updateProjectSettings: (args) => request('PUT', `/api/v1/project-settings`, { body: dropUndefined({ "settings": args.settings }) }),
|
|
1394
|
+
/** `PUT /api/v1/roles/matrix` */
|
|
1395
|
+
updateRoleMatrix: (args) => request('PUT', `/api/v1/roles/matrix`, { body: dropUndefined({ "matrix": args.matrix }) }),
|
|
1396
|
+
/** Hand the organization and its billing to another admin (owner only). 409 ONE_OWNED_ORG when they already own one. `POST /api/v1/org/{org_id}/transfer-ownership` */
|
|
1397
|
+
transferOrgOwnership: (args) => {
|
|
1398
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
1399
|
+
return request('POST', `/api/v1/org/${encodeURIComponent(orgId)}/transfer-ownership`, { body: dropUndefined({ "new_owner_id": args.newOwnerId, "reason": args.reason }) });
|
|
1400
|
+
},
|
|
1401
|
+
},
|
|
1402
|
+
perf: {
|
|
1403
|
+
/** Client performance: p50/p75/p95, count and web-vitals ratings per metric (or per page/screen with by=route). `GET /api/v1/perf/summary` */
|
|
1404
|
+
summary: (args = {}) => request('GET', `/api/v1/perf/summary`, { query: dropUndefined({ "days": args.days, "kind": args.kind, "release": args.release, "platform": args.platform, "by": args.by, "limit": args.limit }) }),
|
|
1405
|
+
/** One client metric's percentile over time. `GET /api/v1/perf/series` */
|
|
1406
|
+
series: (args) => request('GET', `/api/v1/perf/series`, { query: dropUndefined({ "kind": args.kind, "name": args.name, "days": args.days, "route": args.route, "release": args.release, "platform": args.platform, "q": args.q }) }),
|
|
1407
|
+
/** Raw client measurements (newest or slowest first), each with its trace id. `GET /api/v1/perf/samples` */
|
|
1408
|
+
samples: (args = {}) => request('GET', `/api/v1/perf/samples`, { query: dropUndefined({ "kind": args.kind, "name": args.name, "route": args.route, "trace_id": args.traceId, "slowest": args.slowest, "days": args.days, "limit": args.limit }) }),
|
|
1409
|
+
/** Client network time per route next to the gateway's server time for the same route. `GET /api/v1/perf/network` */
|
|
1410
|
+
network: (args = {}) => request('GET', `/api/v1/perf/network`, { query: dropUndefined({ "days": args.days, "env": args.env, "limit": args.limit }) }),
|
|
1411
|
+
/** Client spans and the server trace for one trace id. `GET /api/v1/perf/traces/{trace_id}` */
|
|
1412
|
+
trace: (args) => {
|
|
1413
|
+
const traceId = need('trace_id', args.traceId);
|
|
1414
|
+
return request('GET', `/api/v1/perf/traces/${encodeURIComponent(traceId)}`);
|
|
1415
|
+
},
|
|
1416
|
+
/** Performance measurements accepted and dropped this month, and the plan's limits. `GET /api/v1/perf/usage` */
|
|
1417
|
+
usage: () => request('GET', `/api/v1/perf/usage`),
|
|
1418
|
+
},
|
|
1419
|
+
platform: {
|
|
1420
|
+
/** `POST /api/v1/auth/event-hooks` */
|
|
1421
|
+
createEventHook: (args) => request('POST', `/api/v1/auth/event-hooks`, { body: args.body }),
|
|
1422
|
+
/** `DELETE /api/v1/auth/event-hooks/{hook_id}` */
|
|
1423
|
+
deleteEventHook: (args) => {
|
|
1424
|
+
const hookId = need('hook_id', args.hookId);
|
|
1425
|
+
return request('DELETE', `/api/v1/auth/event-hooks/${encodeURIComponent(hookId)}`);
|
|
1426
|
+
},
|
|
1427
|
+
/** `DELETE /api/v1/auth/github/connection-state` */
|
|
1428
|
+
disconnectGithub: (args = {}) => request('DELETE', `/api/v1/auth/github/connection-state`, { query: dropUndefined({ "project_id": args.projectId }) }),
|
|
1429
|
+
/** `GET /healthz` */
|
|
1430
|
+
gatewayHealth: () => request('GET', `/healthz`, { requiresAuth: false }),
|
|
1431
|
+
/** Return aggregate gateway health for downstream engines. `GET /api/v1/system/engines/health` */
|
|
1432
|
+
getEnginesHealth: () => request('GET', `/api/v1/system/engines/health`, { requiresAuth: false }),
|
|
1433
|
+
/** `GET /api/v1/error-traces/{trace_id}` */
|
|
1434
|
+
getErrorTrace: (args) => {
|
|
1435
|
+
const traceId = need('trace_id', args.traceId);
|
|
1436
|
+
return request('GET', `/api/v1/error-traces/${encodeURIComponent(traceId)}`);
|
|
1437
|
+
},
|
|
1438
|
+
/** `GET /api/v1/auth/github/connection-state` */
|
|
1439
|
+
getGithubConnectionState: (args = {}) => request('GET', `/api/v1/auth/github/connection-state`, { query: dropUndefined({ "project_id": args.projectId }) }),
|
|
1440
|
+
/** `GET /api/v1/auth/event-hooks` */
|
|
1441
|
+
listEventHooks: () => request('GET', `/api/v1/auth/event-hooks`),
|
|
1442
|
+
/** `PATCH /api/v1/error-traces/{trace_id}/resolved` */
|
|
1443
|
+
resolveErrorTrace: (args) => {
|
|
1444
|
+
const traceId = need('trace_id', args.traceId);
|
|
1445
|
+
return request('PATCH', `/api/v1/error-traces/${encodeURIComponent(traceId)}/resolved`, { body: dropUndefined({ "resolved": args.resolved }) });
|
|
1446
|
+
},
|
|
1447
|
+
},
|
|
1448
|
+
policy: {
|
|
1449
|
+
/** Return current audit-entry count. `GET /api/v1/audit/count` */
|
|
1450
|
+
auditCount: () => request('GET', `/api/v1/audit/count`),
|
|
1451
|
+
/** Verify audit hash-chain integrity. `GET /api/v1/audit/verify` */
|
|
1452
|
+
auditVerify: () => request('GET', `/api/v1/audit/verify`),
|
|
1453
|
+
/** Create and compile a policy. `POST /api/v1/policies/` */
|
|
1454
|
+
policyCreate: (args) => request('POST', `/api/v1/policies/`, { body: dropUndefined({ "policy_id": args.policyId, "name": args.name, "spl_source": args.splSource, "org_id": args.orgId }) }),
|
|
1455
|
+
/** Delete (deactivate) a policy. `DELETE /api/v1/policies/{policy_id}` */
|
|
1456
|
+
policyDelete: (args) => {
|
|
1457
|
+
const policyId = need('policy_id', args.policyId);
|
|
1458
|
+
return request('DELETE', `/api/v1/policies/${encodeURIComponent(policyId)}`);
|
|
1459
|
+
},
|
|
1460
|
+
/** Evaluate a policy against an explicit debug context. `POST /api/v1/policies/{policy_id}/evaluate` */
|
|
1461
|
+
policyEvaluate: (args) => {
|
|
1462
|
+
const policyId = need('policy_id', args.policyId);
|
|
1463
|
+
return request('POST', `/api/v1/policies/${encodeURIComponent(policyId)}/evaluate`, { body: dropUndefined({ "context": args.context }) });
|
|
1464
|
+
},
|
|
1465
|
+
/** Get a single policy by ID. `GET /api/v1/policies/{policy_id}` */
|
|
1466
|
+
policyGet: (args) => {
|
|
1467
|
+
const policyId = need('policy_id', args.policyId);
|
|
1468
|
+
return request('GET', `/api/v1/policies/${encodeURIComponent(policyId)}`);
|
|
1469
|
+
},
|
|
1470
|
+
/** Return version history for a policy. `GET /api/v1/policies/{policy_id}/history` */
|
|
1471
|
+
policyHistory: (args) => {
|
|
1472
|
+
const policyId = need('policy_id', args.policyId);
|
|
1473
|
+
return request('GET', `/api/v1/policies/${encodeURIComponent(policyId)}/history`);
|
|
1474
|
+
},
|
|
1475
|
+
/** List active policies visible in current tenant scope. `GET /api/v1/policies/` */
|
|
1476
|
+
policyList: () => request('GET', `/api/v1/policies/`),
|
|
1477
|
+
/** Rollback a policy to a historical version. `POST /api/v1/policies/{policy_id}/rollback` */
|
|
1478
|
+
policyRollback: (args) => {
|
|
1479
|
+
const policyId = need('policy_id', args.policyId);
|
|
1480
|
+
return request('POST', `/api/v1/policies/${encodeURIComponent(policyId)}/rollback`, { body: dropUndefined({ "version": args.version }) });
|
|
1481
|
+
},
|
|
1482
|
+
/** List server-authoritative SPL templates. `GET /api/v1/policies/templates` */
|
|
1483
|
+
policyTemplates: () => request('GET', `/api/v1/policies/templates`),
|
|
1484
|
+
},
|
|
1485
|
+
push: {
|
|
1486
|
+
/** Which push providers are set up (never the keys). `GET /api/v1/projects/{project_id}/push/credentials` */
|
|
1487
|
+
getCredentials: (args = {}) => {
|
|
1488
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
1489
|
+
return request('GET', `/api/v1/projects/${encodeURIComponent(projectId)}/push/credentials`);
|
|
1490
|
+
},
|
|
1491
|
+
/** Upload the Firebase service account JSON (encrypted, write-only). `PUT /api/v1/projects/{project_id}/push/credentials/fcm` */
|
|
1492
|
+
setFcmCredentials: (args) => {
|
|
1493
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
1494
|
+
return request('PUT', `/api/v1/projects/${encodeURIComponent(projectId)}/push/credentials/fcm`, { body: dropUndefined({ "service_account": args.serviceAccount }) });
|
|
1495
|
+
},
|
|
1496
|
+
/** Upload the APNs .p8 key (encrypted, write-only). `PUT /api/v1/projects/{project_id}/push/credentials/apns` */
|
|
1497
|
+
setApnsCredentials: (args) => {
|
|
1498
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
1499
|
+
return request('PUT', `/api/v1/projects/${encodeURIComponent(projectId)}/push/credentials/apns`, { body: dropUndefined({ "p8": args.p8, "key_id": args.keyId, "team_id": args.teamId, "bundle_id": args.bundleId, "environment": args.environment }) });
|
|
1500
|
+
},
|
|
1501
|
+
/** Remove FCM or APNs credentials. `DELETE /api/v1/projects/{project_id}/push/credentials/{provider}` */
|
|
1502
|
+
deleteCredentials: (args) => {
|
|
1503
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
1504
|
+
const provider = need('provider', args.provider);
|
|
1505
|
+
return request('DELETE', `/api/v1/projects/${encodeURIComponent(projectId)}/push/credentials/${encodeURIComponent(provider)}`);
|
|
1506
|
+
},
|
|
1507
|
+
/** Push devices registered in the project (tokens are never returned). `GET /api/v1/projects/{project_id}/push/devices` */
|
|
1508
|
+
listDevices: (args = {}) => {
|
|
1509
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
1510
|
+
return request('GET', `/api/v1/projects/${encodeURIComponent(projectId)}/push/devices`, { query: dropUndefined({ "user_id": args.userId, "limit": args.limit, "before": args.before }) });
|
|
1511
|
+
},
|
|
1512
|
+
/** Send a push: to {user_ids|device_ids|topic}, notification {title, body, image}, data, badge, priority, ttl_seconds, dry_run. `POST /api/v1/projects/{project_id}/push/send` */
|
|
1513
|
+
send: (args) => {
|
|
1514
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
1515
|
+
return request('POST', `/api/v1/projects/${encodeURIComponent(projectId)}/push/send`, { body: args.message });
|
|
1516
|
+
},
|
|
1517
|
+
/** Recent sends (counts and error codes) and this month's total. `GET /api/v1/projects/{project_id}/push/sends` */
|
|
1518
|
+
listSends: (args = {}) => {
|
|
1519
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
1520
|
+
return request('GET', `/api/v1/projects/${encodeURIComponent(projectId)}/push/sends`, { query: dropUndefined({ "limit": args.limit }) });
|
|
1521
|
+
},
|
|
1522
|
+
/** Register the signed-in app user's push token (FCM or APNs). `POST /api/v1/push/devices` */
|
|
1523
|
+
registerDevice: (args) => request('POST', `/api/v1/push/devices`, { body: dropUndefined({ "token": args.token, "platform": args.platform, "provider": args.provider, "device_id": args.deviceId, "app_id": args.appId, "topics": args.topics, "locale": args.locale }) }),
|
|
1524
|
+
/** The signed-in app user's push tokens. `GET /api/v1/push/devices` */
|
|
1525
|
+
myDevices: () => request('GET', `/api/v1/push/devices`),
|
|
1526
|
+
/** Subscribe a device to topics or unsubscribe it. `PATCH /api/v1/push/devices/{device_row_id}/topics` */
|
|
1527
|
+
updateTopics: (args) => {
|
|
1528
|
+
const deviceRowId = need('device_row_id', args.deviceRowId);
|
|
1529
|
+
return request('PATCH', `/api/v1/push/devices/${encodeURIComponent(deviceRowId)}/topics`, { body: dropUndefined({ "subscribe": args.subscribe, "unsubscribe": args.unsubscribe, "replace": args.replace }) });
|
|
1530
|
+
},
|
|
1531
|
+
/** Remove one of the signed-in user's push devices. `DELETE /api/v1/push/devices/{device_row_id}` */
|
|
1532
|
+
deleteDevice: (args) => {
|
|
1533
|
+
const deviceRowId = need('device_row_id', args.deviceRowId);
|
|
1534
|
+
return request('DELETE', `/api/v1/push/devices/${encodeURIComponent(deviceRowId)}`);
|
|
1535
|
+
},
|
|
1536
|
+
/** Drop a push token (sign-out, notifications turned off). `POST /api/v1/push/devices/unregister` */
|
|
1537
|
+
unregisterToken: (args) => request('POST', `/api/v1/push/devices/unregister`, { body: dropUndefined({ "token": args.token }) }),
|
|
1538
|
+
/** Create (or rotate) the project's web push VAPID keys; returns the public key. `POST /api/v1/projects/{project_id}/push/credentials/webpush` */
|
|
1539
|
+
setWebpushCredentials: (args = {}) => {
|
|
1540
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
1541
|
+
return request('POST', `/api/v1/projects/${encodeURIComponent(projectId)}/push/credentials/webpush`, { body: dropUndefined({ "subject": args.subject, "rotate": args.rotate }) });
|
|
1542
|
+
},
|
|
1543
|
+
/** The project's VAPID public key for browsers (pushManager.subscribe applicationServerKey). `GET /api/v1/push/webpush-key` */
|
|
1544
|
+
webpushKey: () => request('GET', `/api/v1/push/webpush-key`),
|
|
1545
|
+
/** Cancel a queued or running large push send. `POST /api/v1/projects/{project_id}/push/sends/{send_id}/cancel` */
|
|
1546
|
+
cancelSend: (args) => {
|
|
1547
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
1548
|
+
const sendId = need('send_id', args.sendId);
|
|
1549
|
+
return request('POST', `/api/v1/projects/${encodeURIComponent(projectId)}/push/sends/${encodeURIComponent(sendId)}/cancel`, { body: {} });
|
|
1550
|
+
},
|
|
1551
|
+
},
|
|
1552
|
+
queues: {
|
|
1553
|
+
/** Message queues of the project's environment with length and oldest message age, plus the plan's queue limits and usage. `GET /api/v1/queues` */
|
|
1554
|
+
list: () => request('GET', `/api/v1/queues`),
|
|
1555
|
+
/** Create a queue: visibility_timeout_sec, max_reads + dead_letter_queue, retention_days, app_send (app users may send) and an optional consumer {function_name, enabled, batch_size, concurrency, visibility_timeout_sec, ack}. `POST /api/v1/queues` */
|
|
1556
|
+
create: (args) => request('POST', `/api/v1/queues`, { body: dropUndefined({ "name": args.name, "description": args.description, "visibility_timeout_sec": args.visibilityTimeoutSec, "max_reads": args.maxReads, "dead_letter_queue": args.deadLetterQueue, "retention_days": args.retentionDays, "app_send": args.appSend, "consumer": args.consumer }) }),
|
|
1557
|
+
/** One queue with its settings, consumer binding and metrics. `GET /api/v1/queues/{queue_name}` */
|
|
1558
|
+
get: (args) => {
|
|
1559
|
+
const queueName = need('queue_name', args.queueName);
|
|
1560
|
+
return request('GET', `/api/v1/queues/${encodeURIComponent(queueName)}`);
|
|
1561
|
+
},
|
|
1562
|
+
/** Change a queue's settings or consumer binding (only the fields sent change). `PATCH /api/v1/queues/{queue_name}` */
|
|
1563
|
+
update: (args) => {
|
|
1564
|
+
const queueName = need('queue_name', args.queueName);
|
|
1565
|
+
return request('PATCH', `/api/v1/queues/${encodeURIComponent(queueName)}`, { body: args.settings });
|
|
1566
|
+
},
|
|
1567
|
+
/** Delete a queue and all its messages. `DELETE /api/v1/queues/{queue_name}` */
|
|
1568
|
+
delete: (args) => {
|
|
1569
|
+
const queueName = need('queue_name', args.queueName);
|
|
1570
|
+
return request('DELETE', `/api/v1/queues/${encodeURIComponent(queueName)}`);
|
|
1571
|
+
},
|
|
1572
|
+
/** Send one JSON message (delay: seconds before it can be read); returns msg_id. `POST /api/v1/queues/{queue_name}/send` */
|
|
1573
|
+
send: (args) => {
|
|
1574
|
+
const queueName = need('queue_name', args.queueName);
|
|
1575
|
+
return request('POST', `/api/v1/queues/${encodeURIComponent(queueName)}/send`, { body: dropUndefined({ "message": args.message, "delay": args.delay, "headers": args.headers }) });
|
|
1576
|
+
},
|
|
1577
|
+
/** Send up to 100 messages at once; returns msg_ids in order. `POST /api/v1/queues/{queue_name}/send_batch` */
|
|
1578
|
+
sendBatch: (args) => {
|
|
1579
|
+
const queueName = need('queue_name', args.queueName);
|
|
1580
|
+
return request('POST', `/api/v1/queues/${encodeURIComponent(queueName)}/send_batch`, { body: dropUndefined({ "messages": args.messages, "delay": args.delay, "headers": args.headers }) });
|
|
1581
|
+
},
|
|
1582
|
+
/** Read up to qty visible messages and hide them for vt seconds (default: the queue's); archive or delete each when done, or it reappears. `POST /api/v1/queues/{queue_name}/read` */
|
|
1583
|
+
read: (args) => {
|
|
1584
|
+
const queueName = need('queue_name', args.queueName);
|
|
1585
|
+
return request('POST', `/api/v1/queues/${encodeURIComponent(queueName)}/read`, { body: dropUndefined({ "qty": args.qty, "vt": args.vt }) });
|
|
1586
|
+
},
|
|
1587
|
+
/** Read and delete up to qty messages at once (at-most-once). `POST /api/v1/queues/{queue_name}/pop` */
|
|
1588
|
+
pop: (args) => {
|
|
1589
|
+
const queueName = need('queue_name', args.queueName);
|
|
1590
|
+
return request('POST', `/api/v1/queues/${encodeURIComponent(queueName)}/pop`, { body: dropUndefined({ "qty": args.qty }) });
|
|
1591
|
+
},
|
|
1592
|
+
/** Archive messages (kept for the retention period); returns the ids archived. `POST /api/v1/queues/{queue_name}/archive` */
|
|
1593
|
+
archive: (args) => {
|
|
1594
|
+
const queueName = need('queue_name', args.queueName);
|
|
1595
|
+
return request('POST', `/api/v1/queues/${encodeURIComponent(queueName)}/archive`, { body: dropUndefined({ "msg_ids": args.msgIds }) });
|
|
1596
|
+
},
|
|
1597
|
+
/** Delete messages; returns the ids deleted. `POST /api/v1/queues/{queue_name}/delete` */
|
|
1598
|
+
deleteMessages: (args) => {
|
|
1599
|
+
const queueName = need('queue_name', args.queueName);
|
|
1600
|
+
return request('POST', `/api/v1/queues/${encodeURIComponent(queueName)}/delete`, { body: dropUndefined({ "msg_ids": args.msgIds }) });
|
|
1601
|
+
},
|
|
1602
|
+
/** Hide a message for vt more seconds from now (0 = visible now). `POST /api/v1/queues/{queue_name}/set_vt` */
|
|
1603
|
+
setVt: (args) => {
|
|
1604
|
+
const queueName = need('queue_name', args.queueName);
|
|
1605
|
+
return request('POST', `/api/v1/queues/${encodeURIComponent(queueName)}/set_vt`, { body: dropUndefined({ "msg_id": args.msgId, "vt": args.vt }) });
|
|
1606
|
+
},
|
|
1607
|
+
/** Delete every waiting message (and the archive with include_archived); returns how many. `POST /api/v1/queues/{queue_name}/purge` */
|
|
1608
|
+
purge: (args) => {
|
|
1609
|
+
const queueName = need('queue_name', args.queueName);
|
|
1610
|
+
return request('POST', `/api/v1/queues/${encodeURIComponent(queueName)}/purge`, { body: dropUndefined({ "include_archived": args.includeArchived }) });
|
|
1611
|
+
},
|
|
1612
|
+
/** Queue length, visible / in flight / delayed, oldest and newest message age, totals, archived and dead-lettered. `GET /api/v1/queues/{queue_name}/metrics` */
|
|
1613
|
+
metrics: (args) => {
|
|
1614
|
+
const queueName = need('queue_name', args.queueName);
|
|
1615
|
+
return request('GET', `/api/v1/queues/${encodeURIComponent(queueName)}/metrics`);
|
|
1616
|
+
},
|
|
1617
|
+
/** Look at messages without reading them: state waiting, archived or dead. `GET /api/v1/queues/{queue_name}/messages` */
|
|
1618
|
+
messages: (args) => {
|
|
1619
|
+
const queueName = need('queue_name', args.queueName);
|
|
1620
|
+
return request('GET', `/api/v1/queues/${encodeURIComponent(queueName)}/messages`, { query: dropUndefined({ "state": args.state, "limit": args.limit, "before": args.before }) });
|
|
1621
|
+
},
|
|
1622
|
+
},
|
|
1623
|
+
realtime: {
|
|
1624
|
+
/** List active realtime channels. `GET /api/v1/rt/stream/channels` */
|
|
1625
|
+
channels: () => request('GET', `/api/v1/rt/stream/channels`),
|
|
1626
|
+
/** Fetch presence for a realtime channel. `GET /api/v1/rt/stream/presence/{channel}` */
|
|
1627
|
+
presence: (args) => {
|
|
1628
|
+
const channel = need('channel', args.channel);
|
|
1629
|
+
return request('GET', `/api/v1/rt/stream/presence/${encodeURIComponent(channel)}`);
|
|
1630
|
+
},
|
|
1631
|
+
/** Replay events for a realtime channel. `GET /api/v1/rt/stream/replay/{channel}` */
|
|
1632
|
+
replay: (args) => {
|
|
1633
|
+
const channel = need('channel', args.channel);
|
|
1634
|
+
return request('GET', `/api/v1/rt/stream/replay/${encodeURIComponent(channel)}`, { query: dropUndefined({ "after": args.after, "limit": args.limit }) });
|
|
1635
|
+
},
|
|
1636
|
+
/** Subscribe a client ID to a realtime channel. `POST /api/v1/rt/stream/subscribe` */
|
|
1637
|
+
subscribe: (args) => request('POST', `/api/v1/rt/stream/subscribe`, { body: dropUndefined({ "channel": args.channel, "client_id": args.clientId }) }),
|
|
1638
|
+
/** Unsubscribe a client ID from a realtime channel. `POST /api/v1/rt/stream/unsubscribe` */
|
|
1639
|
+
unsubscribe: (args) => request('POST', `/api/v1/rt/stream/unsubscribe`, { body: dropUndefined({ "channel": args.channel, "client_id": args.clientId }) }),
|
|
1640
|
+
},
|
|
1641
|
+
remoteConfig: {
|
|
1642
|
+
/** Remote config draft of an environment: parameters, conditions, the published version and pending changes. `GET /api/v1/projects/{project_id}/config` */
|
|
1643
|
+
getDraft: (args = {}) => {
|
|
1644
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
1645
|
+
return request('GET', `/api/v1/projects/${encodeURIComponent(projectId)}/config`, { query: dropUndefined({ "env": args.env }) });
|
|
1646
|
+
},
|
|
1647
|
+
/** Create or change a parameter: type (bool|string|number|json), default, description, conditional [{condition, value}]. `PUT /api/v1/projects/{project_id}/config/params/{key}` */
|
|
1648
|
+
putParam: (args) => {
|
|
1649
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
1650
|
+
const key = need('key', args.key);
|
|
1651
|
+
return request('PUT', `/api/v1/projects/${encodeURIComponent(projectId)}/config/params/${encodeURIComponent(key)}`, { body: dropUndefined({ "type": args.type, "default": args.defaultValue, "description": args.description, "conditional": args.conditional }), query: dropUndefined({ "env": args.env }) });
|
|
1652
|
+
},
|
|
1653
|
+
/** Delete a parameter from the draft. `DELETE /api/v1/projects/{project_id}/config/params/{key}` */
|
|
1654
|
+
deleteParam: (args) => {
|
|
1655
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
1656
|
+
const key = need('key', args.key);
|
|
1657
|
+
return request('DELETE', `/api/v1/projects/${encodeURIComponent(projectId)}/config/params/${encodeURIComponent(key)}`, { query: dropUndefined({ "env": args.env }) });
|
|
1658
|
+
},
|
|
1659
|
+
/** Create or change a targeting condition: rules (attrs, semver, percent, users, audience), priority (lower wins first). `PUT /api/v1/projects/{project_id}/config/conditions/{name}` */
|
|
1660
|
+
putCondition: (args) => {
|
|
1661
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
1662
|
+
const name = need('name', args.name);
|
|
1663
|
+
return request('PUT', `/api/v1/projects/${encodeURIComponent(projectId)}/config/conditions/${encodeURIComponent(name)}`, { body: dropUndefined({ "rules": args.rules, "priority": args.priority, "description": args.description }), query: dropUndefined({ "env": args.env }) });
|
|
1664
|
+
},
|
|
1665
|
+
/** Delete a condition from the draft. `DELETE /api/v1/projects/{project_id}/config/conditions/{name}` */
|
|
1666
|
+
deleteCondition: (args) => {
|
|
1667
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
1668
|
+
const name = need('name', args.name);
|
|
1669
|
+
return request('DELETE', `/api/v1/projects/${encodeURIComponent(projectId)}/config/conditions/${encodeURIComponent(name)}`, { query: dropUndefined({ "env": args.env }) });
|
|
1670
|
+
},
|
|
1671
|
+
/** The draft (or the published version) as a git-friendly template file. `GET /api/v1/projects/{project_id}/config/template` */
|
|
1672
|
+
getTemplate: (args = {}) => {
|
|
1673
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
1674
|
+
return request('GET', `/api/v1/projects/${encodeURIComponent(projectId)}/config/template`, { query: dropUndefined({ "env": args.env, "source": args.source }) });
|
|
1675
|
+
},
|
|
1676
|
+
/** Replace the draft from a template file {conditions, parameters}; prune removes what the file doesn't have. Nothing is published. `PUT /api/v1/projects/{project_id}/config/template` */
|
|
1677
|
+
putTemplate: (args = {}) => {
|
|
1678
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
1679
|
+
return request('PUT', `/api/v1/projects/${encodeURIComponent(projectId)}/config/template`, { body: dropUndefined({ "conditions": args.conditions, "parameters": args.parameters }), query: dropUndefined({ "env": args.env, "prune": args.prune }) });
|
|
1680
|
+
},
|
|
1681
|
+
/** What publishing the draft (or a given template) would change against the published version. `POST /api/v1/projects/{project_id}/config/diff` */
|
|
1682
|
+
diff: (args = {}) => {
|
|
1683
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
1684
|
+
return request('POST', `/api/v1/projects/${encodeURIComponent(projectId)}/config/diff`, { body: dropUndefined({ "template": args.template }), query: dropUndefined({ "env": args.env }) });
|
|
1685
|
+
},
|
|
1686
|
+
/** How many recently seen users would get different values if the draft (or template) were published. `POST /api/v1/projects/{project_id}/config/preview` */
|
|
1687
|
+
preview: (args = {}) => {
|
|
1688
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
1689
|
+
return request('POST', `/api/v1/projects/${encodeURIComponent(projectId)}/config/preview`, { body: dropUndefined({ "template": args.template }), query: dropUndefined({ "env": args.env, "sample": args.sample }) });
|
|
1690
|
+
},
|
|
1691
|
+
/** Publish the draft as the next immutable version (base_version: the version you reviewed; scheduled_at: publish later). `POST /api/v1/projects/{project_id}/config/publish` */
|
|
1692
|
+
publish: (args = {}) => {
|
|
1693
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
1694
|
+
return request('POST', `/api/v1/projects/${encodeURIComponent(projectId)}/config/publish`, { body: dropUndefined({ "message": args.message, "base_version": args.baseVersion, "scheduled_at": args.scheduledAt }), query: dropUndefined({ "env": args.env }) });
|
|
1695
|
+
},
|
|
1696
|
+
/** Published (and scheduled) versions, newest first. `GET /api/v1/projects/{project_id}/config/versions` */
|
|
1697
|
+
listVersions: (args = {}) => {
|
|
1698
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
1699
|
+
return request('GET', `/api/v1/projects/${encodeURIComponent(projectId)}/config/versions`, { query: dropUndefined({ "env": args.env, "limit": args.limit }) });
|
|
1700
|
+
},
|
|
1701
|
+
/** One published version with its snapshot and template file. `GET /api/v1/projects/{project_id}/config/versions/{version}` */
|
|
1702
|
+
getVersion: (args) => {
|
|
1703
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
1704
|
+
const version = need('version', args.version);
|
|
1705
|
+
return request('GET', `/api/v1/projects/${encodeURIComponent(projectId)}/config/versions/${encodeURIComponent(version)}`, { query: dropUndefined({ "env": args.env }) });
|
|
1706
|
+
},
|
|
1707
|
+
/** Publish an older version again as a new version. `POST /api/v1/projects/{project_id}/config/rollback/{version}` */
|
|
1708
|
+
rollback: (args) => {
|
|
1709
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
1710
|
+
const version = need('version', args.version);
|
|
1711
|
+
return request('POST', `/api/v1/projects/${encodeURIComponent(projectId)}/config/rollback/${encodeURIComponent(version)}`, { body: dropUndefined({ "message": args.message }), query: dropUndefined({ "env": args.env }) });
|
|
1712
|
+
},
|
|
1713
|
+
/** Cancel a scheduled publish. `DELETE /api/v1/projects/{project_id}/config/schedules/{schedule_id}` */
|
|
1714
|
+
cancelSchedule: (args) => {
|
|
1715
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
1716
|
+
const scheduleId = need('schedule_id', args.scheduleId);
|
|
1717
|
+
return request('DELETE', `/api/v1/projects/${encodeURIComponent(projectId)}/config/schedules/${encodeURIComponent(scheduleId)}`, { query: dropUndefined({ "env": args.env }) });
|
|
1718
|
+
},
|
|
1719
|
+
/** The values one user or device would get (context: user_id, anon_id, platform, app_version, country, language, attrs). `POST /api/v1/projects/{project_id}/config/evaluate` */
|
|
1720
|
+
evaluate: (args = {}) => {
|
|
1721
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
1722
|
+
return request('POST', `/api/v1/projects/${encodeURIComponent(projectId)}/config/evaluate`, { body: dropUndefined({ "context": args.context, "source": args.source }), query: dropUndefined({ "env": args.env }) });
|
|
1723
|
+
},
|
|
1724
|
+
},
|
|
1725
|
+
schedules: {
|
|
1726
|
+
/** Cron schedules of the project's environment, newest first (optionally of one function). `GET /api/v1/fn/schedules` */
|
|
1727
|
+
list: (args = {}) => request('GET', `/api/v1/fn/schedules`, { query: dropUndefined({ "function": args.functionName }) }),
|
|
1728
|
+
/** Create a cron schedule: target_type function (function_name, payload), http (target: url, method, headers, body) or sql (target: sql, params); cron_expression in timezone (IANA), overlap allow|skip, max_attempts, timeout_sec. Payload/target values may be {"$secret": NAME}. `POST /api/v1/fn/schedules` */
|
|
1729
|
+
create: (args) => request('POST', `/api/v1/fn/schedules`, { body: dropUndefined({ "cron_expression": args.cronExpression, "function_name": args.functionName, "payload": args.payload, "enabled": args.enabled, "name": args.name, "description": args.description, "timezone": args.timezone, "overlap": args.overlap, "max_attempts": args.maxAttempts, "timeout_sec": args.timeoutSec, "target_type": args.targetType, "target": args.target }) }),
|
|
1730
|
+
/** One schedule: expression, timezone, readable summary, next and last run. `GET /api/v1/fn/schedules/{schedule_id}` */
|
|
1731
|
+
get: (args) => {
|
|
1732
|
+
const scheduleId = need('schedule_id', args.scheduleId);
|
|
1733
|
+
return request('GET', `/api/v1/fn/schedules/${encodeURIComponent(scheduleId)}`);
|
|
1734
|
+
},
|
|
1735
|
+
/** Change a schedule; only the fields sent change (payload null clears it; "[redacted]" values keep what is stored). `PATCH /api/v1/fn/schedules/{schedule_id}` */
|
|
1736
|
+
update: (args) => {
|
|
1737
|
+
const scheduleId = need('schedule_id', args.scheduleId);
|
|
1738
|
+
return request('PATCH', `/api/v1/fn/schedules/${encodeURIComponent(scheduleId)}`, { body: args.changes });
|
|
1739
|
+
},
|
|
1740
|
+
/** Delete a schedule (its run history stays in the logs). `DELETE /api/v1/fn/schedules/{schedule_id}` */
|
|
1741
|
+
delete: (args) => {
|
|
1742
|
+
const scheduleId = need('schedule_id', args.scheduleId);
|
|
1743
|
+
return request('DELETE', `/api/v1/fn/schedules/${encodeURIComponent(scheduleId)}`);
|
|
1744
|
+
},
|
|
1745
|
+
/** Run history, newest first: status (incl. SKIPPED and MISSED slots), duration, error, attempts and the response preview of HTTP/SQL targets. `GET /api/v1/fn/schedules/{schedule_id}/runs` */
|
|
1746
|
+
runs: (args) => {
|
|
1747
|
+
const scheduleId = need('schedule_id', args.scheduleId);
|
|
1748
|
+
return request('GET', `/api/v1/fn/schedules/${encodeURIComponent(scheduleId)}/runs`, { query: dropUndefined({ "limit": args.limit, "before": args.before }) });
|
|
1749
|
+
},
|
|
1750
|
+
/** Run a schedule now (its regular times don't change); returns the queued invocation id. `POST /api/v1/fn/schedules/{schedule_id}/run` */
|
|
1751
|
+
run: (args) => {
|
|
1752
|
+
const scheduleId = need('schedule_id', args.scheduleId);
|
|
1753
|
+
return request('POST', `/api/v1/fn/schedules/${encodeURIComponent(scheduleId)}/run`);
|
|
1754
|
+
},
|
|
1755
|
+
/** The next run times of a cron expression in a time zone, with a readable summary; nothing is saved. `POST /api/v1/fn/schedules/preview` */
|
|
1756
|
+
preview: (args) => request('POST', `/api/v1/fn/schedules/preview`, { body: dropUndefined({ "cron_expression": args.cronExpression, "timezone": args.timezone, "count": args.count }) }),
|
|
1757
|
+
},
|
|
1758
|
+
simulation: {
|
|
1759
|
+
/** Compare two simulation runs of the project: regressions, improvements and new failures. `GET /api/v1/sim/runs/{target_run_id}/compare/{baseline_run_id}` */
|
|
1760
|
+
compareRuns: (args) => {
|
|
1761
|
+
const targetRunId = need('target_run_id', args.targetRunId);
|
|
1762
|
+
const baselineRunId = need('baseline_run_id', args.baselineRunId);
|
|
1763
|
+
return request('GET', `/api/v1/sim/runs/${encodeURIComponent(targetRunId)}/compare/${encodeURIComponent(baselineRunId)}`);
|
|
1764
|
+
},
|
|
1765
|
+
/** What a simulation would test (user types, resources, rules), redacted by what you may read; pass its manifest_id to a run. `POST /api/v1/sim/discover` */
|
|
1766
|
+
discover: () => request('POST', `/api/v1/sim/discover`, { body: {} }),
|
|
1767
|
+
/** One simulation run with every case's result (history keeps no rule source or user ids). `GET /api/v1/sim/runs/{run_id}` */
|
|
1768
|
+
getRun: (args) => {
|
|
1769
|
+
const runId = need('run_id', args.runId);
|
|
1770
|
+
return request('GET', `/api/v1/sim/runs/${encodeURIComponent(runId)}`);
|
|
1771
|
+
},
|
|
1772
|
+
/** The project's simulation runs, newest first; limit 1-100 (default 50) and offset page through them. `GET /api/v1/sim/runs` */
|
|
1773
|
+
listRuns: (args = {}) => request('GET', `/api/v1/sim/runs`, { query: dropUndefined({ "limit": args.limit, "offset": args.offset }) }),
|
|
1774
|
+
/** Real simulation runs used and allowed today (UTC) and this month; reading it uses nothing. `GET /api/v1/sim/quota` */
|
|
1775
|
+
quota: () => request('GET', `/api/v1/sim/quota`),
|
|
1776
|
+
/** Outcomes the team marked as intended for this project (shown green on every run, left out of findings). `GET /api/v1/sim/intended` */
|
|
1777
|
+
listIntended: () => request('GET', `/api/v1/sim/intended`),
|
|
1778
|
+
/** Mark an outcome as intended (role, action, resource, outcome ALLOW or DENY, optional note); needs policies.write. Marking the same role/action/resource again replaces it. `POST /api/v1/sim/intended` */
|
|
1779
|
+
markIntended: (args) => request('POST', `/api/v1/sim/intended`, { body: dropUndefined({ "role": args.role, "action": args.action, "resource": args.resource, "outcome": args.outcome, "note": args.note }) }),
|
|
1780
|
+
/** Remove an intended-outcome mark; matching cases show as measured again. Needs policies.write. `DELETE /api/v1/sim/intended/{mark_id}` */
|
|
1781
|
+
unmarkIntended: (args) => {
|
|
1782
|
+
const markId = need('mark_id', args.markId);
|
|
1783
|
+
return request('DELETE', `/api/v1/sim/intended/${encodeURIComponent(markId)}`);
|
|
1784
|
+
},
|
|
1785
|
+
/** Callers, gateway checks, sign-in, resources and connectors of the project (platform defences as one 'Platform protection' node). `GET /api/v1/sim/topology` */
|
|
1786
|
+
topology: () => request('GET', `/api/v1/sim/topology`),
|
|
1787
|
+
/** Everything the project has, read from every engine: tables in every schema it created, collections, buckets, secrets (names only), functions with their schedules, queues, workflows and triggers, sign-in providers, hooks, webhooks, channels, edge limits, backups, environments, domains, policies and plan headroom. Cached a minute; redacted by the caller's permissions. `GET /api/v1/sim/inventory` */
|
|
1788
|
+
inventory: (args = {}) => request('GET', `/api/v1/sim/inventory`, { query: dropUndefined({ "include": args.include, "fresh": args.fresh }) }),
|
|
1789
|
+
/** The checks catalogue: what is wrong or at risk (database, functions, storage, sign-in, edge, plan headroom, settings above the plan, realtime, backups, integrations, design), worst first, each with a fix. severity keeps that level and worse. `GET /api/v1/sim/checks` */
|
|
1790
|
+
checks: (args = {}) => request('GET', `/api/v1/sim/checks`, { query: dropUndefined({ "severity": args.severity, "area": args.area, "fresh": args.fresh }) }),
|
|
1791
|
+
/** The architecture map: nodes by layer (clients, edge, identity, policies, services and data, async, external, resilience) with their status from the checks and the latest run, and the edges between them. `GET /api/v1/sim/graph` */
|
|
1792
|
+
graph: (args = {}) => request('GET', `/api/v1/sim/graph`, { query: dropUndefined({ "fresh": args.fresh }) }),
|
|
1793
|
+
/** Every limit the project lives under, with its value and how it is counted. `GET /api/v1/sim/limits` */
|
|
1794
|
+
limits: () => request('GET', `/api/v1/sim/limits`),
|
|
1795
|
+
/** Run one integration flow under a programmed outcome: modelled (free, nothing sent) or sealed (real code path, recorded, one single-request check). `POST /api/v1/sim/integrations/run` */
|
|
1796
|
+
integrationRun: (args) => request('POST', `/api/v1/sim/integrations/run`, { body: dropUndefined({ "connector_id": args.connectorId, "flow_id": args.flowId, "outcome": args.outcome, "mode": args.mode }) }),
|
|
1797
|
+
/** Judge the 14 security drills from the project's configuration (optionally with a what-if draft that is never saved). `POST /api/v1/sim/drills/run` */
|
|
1798
|
+
drillsRun: (args = {}) => request('POST', `/api/v1/sim/drills/run`, { body: dropUndefined({ "drill_ids": args.drillIds, "overrides": args.overrides }) }),
|
|
1799
|
+
/** What a run's sealed send points would have sent (secrets masked; message bodies need settings.manage). `GET /api/v1/sim/runs/{run_id}/artifacts` */
|
|
1800
|
+
runArtifacts: (args) => {
|
|
1801
|
+
const runId = need('run_id', args.runId);
|
|
1802
|
+
return request('GET', `/api/v1/sim/runs/${encodeURIComponent(runId)}/artifacts`);
|
|
1803
|
+
},
|
|
1804
|
+
/** A project snapshot for offline simulation (sov simulate offline): tables, row policies, functions, every case with the rules' verdict. `POST /api/v1/sim/snapshot` */
|
|
1805
|
+
snapshot: (args = {}) => request('POST', `/api/v1/sim/snapshot`, { body: dropUndefined({ "include_rows": args.includeRows }) }),
|
|
1806
|
+
},
|
|
1807
|
+
storage: {
|
|
1808
|
+
/** `POST /api/v1/store/buckets` */
|
|
1809
|
+
createBucket: (args) => request('POST', `/api/v1/store/buckets`, { body: args.body }),
|
|
1810
|
+
/** `DELETE /api/v1/store/buckets/{name}` */
|
|
1811
|
+
deleteBucket: (args) => {
|
|
1812
|
+
const name = need('name', args.name);
|
|
1813
|
+
return request('DELETE', `/api/v1/store/buckets/${encodeURIComponent(name)}`);
|
|
1814
|
+
},
|
|
1815
|
+
/** `GET /api/v1/store/buckets/{name}` */
|
|
1816
|
+
getBucket: (args) => {
|
|
1817
|
+
const name = need('name', args.name);
|
|
1818
|
+
return request('GET', `/api/v1/store/buckets/${encodeURIComponent(name)}`);
|
|
1819
|
+
},
|
|
1820
|
+
/** `GET /api/v1/store/buckets` */
|
|
1821
|
+
listBuckets: () => request('GET', `/api/v1/store/buckets`),
|
|
1822
|
+
/** `POST /api/v1/store/objects/move` */
|
|
1823
|
+
moveObject: (args) => request('POST', `/api/v1/store/objects/move`, { body: dropUndefined({ "from_path": args.fromPath, "to_path": args.toPath }) }),
|
|
1824
|
+
/** `PATCH /api/v1/store/buckets/{name}` */
|
|
1825
|
+
updateBucket: (args) => {
|
|
1826
|
+
const name = need('name', args.name);
|
|
1827
|
+
return request('PATCH', `/api/v1/store/buckets/${encodeURIComponent(name)}`, { body: args.body });
|
|
1828
|
+
},
|
|
1829
|
+
},
|
|
1830
|
+
templates: {
|
|
1831
|
+
/** App templates (SaaS, marketplace, chat): what each creates, the tables it adds and its steps. Project team only. `GET /api/v1/templates` */
|
|
1832
|
+
list: () => request('GET', `/api/v1/templates`),
|
|
1833
|
+
/** One app template, including the SQL its migration runs. `GET /api/v1/templates/{name}` */
|
|
1834
|
+
get: (args) => {
|
|
1835
|
+
const name = need('name', args.name);
|
|
1836
|
+
return request('GET', `/api/v1/templates/${encodeURIComponent(name)}`);
|
|
1837
|
+
},
|
|
1838
|
+
/** Apply a template to the project: its migration (tables + row-level security), buckets and their rules, realtime — each step with your own permissions, stopping at the first refusal. dry_run checks for tables that already exist and changes nothing. Needs database.admin. `POST /api/v1/governance/tenants/{org_id}/projects/{project_id}/templates/{name}/apply` */
|
|
1839
|
+
apply: (args) => {
|
|
1840
|
+
const orgId = need('org_id', args.orgId ?? scope()?.orgId);
|
|
1841
|
+
const projectId = need('project_id', args.projectId ?? scope()?.projectId);
|
|
1842
|
+
const name = need('name', args.name);
|
|
1843
|
+
return request('POST', `/api/v1/governance/tenants/${encodeURIComponent(orgId)}/projects/${encodeURIComponent(projectId)}/templates/${encodeURIComponent(name)}/apply`, { body: dropUndefined({ "dry_run": args.dryRun }) });
|
|
1844
|
+
},
|
|
1845
|
+
},
|
|
1846
|
+
traces: {
|
|
1847
|
+
/** The project's recent refused (4xx) and failed (5xx) requests, each with who refused it, why and what to do (kind: denied, failed or all). Project team only. `GET /api/v1/request-traces` */
|
|
1848
|
+
list: (args = {}) => request('GET', `/api/v1/request-traces`, { query: dropUndefined({ "kind": args.kind, "before": args.before, "limit": args.limit }) }),
|
|
1849
|
+
/** One request by its trace id (SovariaError.traceId, the X-Request-ID header): every hop — gateway checks, engine, SQL — and the explanation. `GET /api/v1/request-traces/{trace_id}` */
|
|
1850
|
+
get: (args) => {
|
|
1851
|
+
const traceId = need('trace_id', args.traceId);
|
|
1852
|
+
return request('GET', `/api/v1/request-traces/${encodeURIComponent(traceId)}`);
|
|
1853
|
+
},
|
|
1854
|
+
},
|
|
1855
|
+
triggers: {
|
|
1856
|
+
/** Event triggers of the project's environment with the plan's trigger limits and the event sources. `GET /api/v1/fn/triggers` */
|
|
1857
|
+
list: (args = {}) => request('GET', `/api/v1/fn/triggers`, { query: dropUndefined({ "function": args.functionName }) }),
|
|
1858
|
+
/** Run a function when something happens: source db.document | db.row | auth.user | storage.object | realtime.message, event_types, resource (glob), subject_prefix, max_attempts. `POST /api/v1/fn/triggers` */
|
|
1859
|
+
create: (args) => request('POST', `/api/v1/fn/triggers`, { body: dropUndefined({ "function_name": args.functionName, "source": args.source, "event_types": args.eventTypes, "resource": args.resource, "subject_prefix": args.subjectPrefix, "name": args.name, "enabled": args.enabled, "max_attempts": args.maxAttempts }) }),
|
|
1860
|
+
/** One event trigger. `GET /api/v1/fn/triggers/{trigger_id}` */
|
|
1861
|
+
get: (args) => {
|
|
1862
|
+
const triggerId = need('trigger_id', args.triggerId);
|
|
1863
|
+
return request('GET', `/api/v1/fn/triggers/${encodeURIComponent(triggerId)}`);
|
|
1864
|
+
},
|
|
1865
|
+
/** Change an event trigger (only the fields sent change). `PATCH /api/v1/fn/triggers/{trigger_id}` */
|
|
1866
|
+
update: (args) => {
|
|
1867
|
+
const triggerId = need('trigger_id', args.triggerId);
|
|
1868
|
+
return request('PATCH', `/api/v1/fn/triggers/${encodeURIComponent(triggerId)}`, { body: args.changes });
|
|
1869
|
+
},
|
|
1870
|
+
/** Delete an event trigger. `DELETE /api/v1/fn/triggers/{trigger_id}` */
|
|
1871
|
+
delete: (args) => {
|
|
1872
|
+
const triggerId = need('trigger_id', args.triggerId);
|
|
1873
|
+
return request('DELETE', `/api/v1/fn/triggers/${encodeURIComponent(triggerId)}`);
|
|
1874
|
+
},
|
|
1875
|
+
/** Queue one run with a sample event (counts as an invocation). `POST /api/v1/fn/triggers/{trigger_id}/test` */
|
|
1876
|
+
test: (args) => {
|
|
1877
|
+
const triggerId = need('trigger_id', args.triggerId);
|
|
1878
|
+
return request('POST', `/api/v1/fn/triggers/${encodeURIComponent(triggerId)}/test`);
|
|
1879
|
+
},
|
|
1880
|
+
},
|
|
1881
|
+
vector: {
|
|
1882
|
+
/** Delete an entire vector collection. `DELETE /api/v1/collections/{collection}` */
|
|
1883
|
+
deleteCollection: (args) => {
|
|
1884
|
+
const collection = need('collection', args.collection);
|
|
1885
|
+
return request('DELETE', `/api/v1/collections/${encodeURIComponent(collection)}`);
|
|
1886
|
+
},
|
|
1887
|
+
/** Delete a record from a vector collection. `DELETE /api/v1/collections/{collection}/records/{record_id}` */
|
|
1888
|
+
deleteRecord: (args) => {
|
|
1889
|
+
const collection = need('collection', args.collection);
|
|
1890
|
+
const recordId = need('record_id', args.recordId);
|
|
1891
|
+
return request('DELETE', `/api/v1/collections/${encodeURIComponent(collection)}/records/${encodeURIComponent(recordId)}`);
|
|
1892
|
+
},
|
|
1893
|
+
/** Generate embeddings for one or more texts. `POST /api/v1/embed` */
|
|
1894
|
+
embed: (args) => request('POST', `/api/v1/embed`, { body: dropUndefined({ "texts": args.texts }) }),
|
|
1895
|
+
/** List vector collections in the current project scope. `GET /api/v1/collections` */
|
|
1896
|
+
listCollections: () => request('GET', `/api/v1/collections`),
|
|
1897
|
+
/** Embed and upsert documents into a vector collection. `POST /api/v1/vectors/upsert` */
|
|
1898
|
+
upsert: (args) => request('POST', `/api/v1/vectors/upsert`, { body: dropUndefined({ "collection": args.collection, "docs": args.docs }) }),
|
|
1899
|
+
/** Collection settings. app_search: true lets the project's apps (anon key, signed-in users) search it; they can never write or list it. `PATCH /api/v1/collections/{collection}` */
|
|
1900
|
+
setCollection: (args) => {
|
|
1901
|
+
const collection = need('collection', args.collection);
|
|
1902
|
+
return request('PATCH', `/api/v1/collections/${encodeURIComponent(collection)}`, { body: dropUndefined({ "app_search": args.appSearch }) });
|
|
1903
|
+
},
|
|
1904
|
+
/** Embed every stored text again with the project's current model (large collections need this after a model change). `POST /api/v1/collections/{collection}/reembed` */
|
|
1905
|
+
reembedCollection: (args) => {
|
|
1906
|
+
const collection = need('collection', args.collection);
|
|
1907
|
+
return request('POST', `/api/v1/collections/${encodeURIComponent(collection)}/reembed`, { query: dropUndefined({ "force": args.force }) });
|
|
1908
|
+
},
|
|
1909
|
+
/** Search a SQL table: mode vector (nearest embeddings), keyword (full text) or hybrid (both, reciprocal rank fusion). text is embedded with the project's model when no vector is given. ef_search / probes tune recall, rerank reorders with the managed reranker, filter_in matches any of several values. Only rows the caller may read. `POST /api/v1/data/rel/vector/search` */
|
|
1910
|
+
sqlSearch: (args) => request('POST', `/api/v1/data/rel/vector/search`, { body: dropUndefined({ "table_name": args.tableName, "column_name": args.columnName, "vector": args.vector, "text": args.text, "mode": args.mode, "text_columns": args.textColumns, "language": args.language, "k": args.k, "metric": args.metric, "select": args.select, "filter": args.filter, "max_distance": args.maxDistance, "metadata_filter": args.metadataFilter, "metadata_column": args.metadataColumn, "filter_in": args.filterIn, "ef_search": args.efSearch, "probes": args.probes, "rerank": args.rerank, "rerank_candidates": args.rerankCandidates }) }),
|
|
1911
|
+
/** Tables whose vector column Sovaria keeps embedded, rows embedded and waiting, last error, and the project's model. `GET /api/v1/data/rel/vector/auto` */
|
|
1912
|
+
sqlAutoStatus: () => request('GET', `/api/v1/data/rel/vector/auto`),
|
|
1913
|
+
/** Keep a vector column (created if missing) filled with embeddings of the source columns; edited rows are embedded again automatically. rebuild re-embeds the whole table. language sets the keyword index's text search configuration (e.g. english). `POST /api/v1/data/rel/vector/auto` */
|
|
1914
|
+
sqlAutoEnable: (args) => request('POST', `/api/v1/data/rel/vector/auto`, { body: dropUndefined({ "table_name": args.tableName, "column_name": args.columnName, "source_columns": args.sourceColumns, "rebuild": args.rebuild, "language": args.language }) }),
|
|
1915
|
+
/** Stop keeping a table's vectors up to date (the column and its vectors stay). `DELETE /api/v1/data/rel/vector/auto/{table_name}` */
|
|
1916
|
+
sqlAutoDisable: (args) => {
|
|
1917
|
+
const tableName = need('table_name', args.tableName);
|
|
1918
|
+
return request('DELETE', `/api/v1/data/rel/vector/auto/${encodeURIComponent(tableName)}`);
|
|
1919
|
+
},
|
|
1920
|
+
/** Embed waiting rows now instead of on the next background pass (up to limit per table). `POST /api/v1/data/rel/vector/auto/sync` */
|
|
1921
|
+
sqlAutoSync: (args = {}) => request('POST', `/api/v1/data/rel/vector/auto/sync`, { body: dropUndefined({ "table_name": args.tableName, "limit": args.limit }) }),
|
|
1922
|
+
/** pgvector on the project database: available/enabled, vector columns, their indexes (method, metric, quantization, options, building/ready) and row estimates. Team only. `GET /api/v1/data/rel/vector/status` */
|
|
1923
|
+
sqlStatus: () => request('GET', `/api/v1/data/rel/vector/status`),
|
|
1924
|
+
/** Turn pgvector on (or off with enabled: false) for the project database. `POST /api/v1/data/rel/vector/enable` */
|
|
1925
|
+
sqlEnable: (args = {}) => request('POST', `/api/v1/data/rel/vector/enable`, { body: dropUndefined({ "enabled": args.enabled }) }),
|
|
1926
|
+
/** Create a documents table (id, content, metadata, embedding vector(n), optional owner_id with owner-only row policies) with an HNSW index. `POST /api/v1/data/rel/vector/tables` */
|
|
1927
|
+
sqlCreateTable: (args) => request('POST', `/api/v1/data/rel/vector/tables`, { body: dropUndefined({ "table_name": args.tableName, "dimensions": args.dimensions, "owner_rows": args.ownerRows }) }),
|
|
1928
|
+
/** Add a vector(n) column to an existing table. `POST /api/v1/data/rel/vector/columns` */
|
|
1929
|
+
sqlAddColumn: (args) => request('POST', `/api/v1/data/rel/vector/columns`, { body: dropUndefined({ "table_name": args.tableName, "column_name": args.columnName, "dimensions": args.dimensions }) }),
|
|
1930
|
+
/** HNSW (m, ef_construction) or IVFFlat (lists) index, cosine / l2 / inner_product; built CONCURRENTLY in the background by default; halfvec above 2,000 dimensions. `POST /api/v1/data/rel/vector/indexes` */
|
|
1931
|
+
sqlCreateIndex: (args) => request('POST', `/api/v1/data/rel/vector/indexes`, { body: dropUndefined({ "table_name": args.tableName, "column_name": args.columnName, "metric": args.metric, "method": args.method, "m": args.m, "ef_construction": args.efConstruction, "lists": args.lists, "concurrently": args.concurrently }) }),
|
|
1932
|
+
/** Insert rows whose vector column is a number array; embed: true embeds rows without a vector in the request (automatic-embeddings tables, small batches). `POST /api/v1/data/rel/vector/rows` */
|
|
1933
|
+
sqlInsertRows: (args) => request('POST', `/api/v1/data/rel/vector/rows`, { body: dropUndefined({ "table_name": args.tableName, "column_name": args.columnName, "rows": args.rows, "embed": args.embed }) }),
|
|
1934
|
+
},
|
|
1935
|
+
workflows: {
|
|
1936
|
+
/** Start a durable workflow run of a function that uses context.step; key makes the start idempotent; max_attempts sets the tries per step (plan fn.trigger_max_attempts). `POST /api/v1/fn/workflows` */
|
|
1937
|
+
start: (args) => request('POST', `/api/v1/fn/workflows`, { body: dropUndefined({ "function_name": args.functionName, "input": args.input, "key": args.key, "max_attempts": args.maxAttempts }) }),
|
|
1938
|
+
/** Workflow runs, newest first, with the plan's workflow limits. `GET /api/v1/fn/workflows` */
|
|
1939
|
+
list: (args = {}) => request('GET', `/api/v1/fn/workflows`, { query: dropUndefined({ "function": args.functionName, "status": args.status, "before": args.before, "limit": args.limit }) }),
|
|
1940
|
+
/** One run: status, input, output or error, and every finished step with its result. `GET /api/v1/fn/workflows/{run_id}` */
|
|
1941
|
+
get: (args) => {
|
|
1942
|
+
const runId = need('run_id', args.runId);
|
|
1943
|
+
return request('GET', `/api/v1/fn/workflows/${encodeURIComponent(runId)}`);
|
|
1944
|
+
},
|
|
1945
|
+
/** Wake step.waitForSignal(name) with data (kept until the run waits for it). `POST /api/v1/fn/workflows/{run_id}/signal` */
|
|
1946
|
+
signal: (args) => {
|
|
1947
|
+
const runId = need('run_id', args.runId);
|
|
1948
|
+
return request('POST', `/api/v1/fn/workflows/${encodeURIComponent(runId)}/signal`, { body: dropUndefined({ "name": args.name, "data": args.data }) });
|
|
1949
|
+
},
|
|
1950
|
+
/** Stop an unfinished run for good. `POST /api/v1/fn/workflows/{run_id}/cancel` */
|
|
1951
|
+
cancel: (args) => {
|
|
1952
|
+
const runId = need('run_id', args.runId);
|
|
1953
|
+
return request('POST', `/api/v1/fn/workflows/${encodeURIComponent(runId)}/cancel`);
|
|
1954
|
+
},
|
|
1955
|
+
/** Resume a failed run from its failed step; latest moves it to the live function version. `POST /api/v1/fn/workflows/{run_id}/retry` */
|
|
1956
|
+
retry: (args) => {
|
|
1957
|
+
const runId = need('run_id', args.runId);
|
|
1958
|
+
return request('POST', `/api/v1/fn/workflows/${encodeURIComponent(runId)}/retry`, { body: dropUndefined({ "latest": args.latest }) });
|
|
1959
|
+
},
|
|
1960
|
+
},
|
|
1961
|
+
};
|
|
1962
|
+
}
|