@sylphx/sdk 0.31.0 → 0.32.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +131 -4
- package/dist/access.d.ts +146 -17
- package/dist/access.js +114 -8
- package/dist/access.js.map +1 -1
- package/dist/agents.d.ts +1564 -0
- package/dist/agents.js +1096 -0
- package/dist/agents.js.map +1 -0
- package/dist/ai.d.ts +1 -2
- package/dist/ai.js +2 -3
- package/dist/ai.js.map +1 -1
- package/dist/artifacts.d.ts +1 -1
- package/dist/artifacts.js +2 -2
- package/dist/assets.d.ts +447 -0
- package/dist/assets.js +266 -0
- package/dist/assets.js.map +1 -0
- package/dist/auth/client.d.ts +239 -0
- package/dist/auth/client.js +337 -0
- package/dist/auth/client.js.map +1 -0
- package/dist/auth/end-user-keys-mock.d.ts +83 -0
- package/dist/auth/end-user-keys-mock.js +427 -0
- package/dist/auth/end-user-keys-mock.js.map +1 -0
- package/dist/auth/end-user-keys.d.ts +219 -0
- package/dist/auth/end-user-keys.js +240 -0
- package/dist/auth/end-user-keys.js.map +1 -0
- package/dist/auth/verify.d.ts +38 -3
- package/dist/auth/verify.js +58 -8
- package/dist/auth/verify.js.map +1 -1
- package/dist/auth.d.ts +656 -9
- package/dist/auth.js +563 -6
- package/dist/auth.js.map +1 -1
- package/dist/billing.d.ts +99 -21
- package/dist/billing.js +43 -5
- package/dist/billing.js.map +1 -1
- package/dist/broker.d.ts +5 -4
- package/dist/broker.js +3 -3
- package/dist/broker.js.map +1 -1
- package/dist/build.d.ts +362 -29
- package/dist/build.js +302 -10
- package/dist/build.js.map +1 -1
- package/dist/common.d.ts +1 -1
- package/dist/common.js +1 -1
- package/dist/config/flags.d.ts +140 -0
- package/dist/config/flags.js +462 -0
- package/dist/config/flags.js.map +1 -0
- package/dist/config.d.ts +380 -15
- package/dist/config.js +283 -5
- package/dist/config.js.map +1 -1
- package/dist/connections.d.ts +6 -6
- package/dist/connections.js +3 -3
- package/dist/data.d.ts +612 -7
- package/dist/data.js +566 -4
- package/dist/data.js.map +1 -1
- package/dist/entitlement.d.ts +10 -8
- package/dist/entitlement.js +3 -4
- package/dist/entitlement.js.map +1 -1
- package/dist/events/realtime.d.ts +69 -0
- package/dist/events/realtime.js +107 -0
- package/dist/events/realtime.js.map +1 -0
- package/dist/events/webhooks.d.ts +40 -0
- package/dist/events/webhooks.js +110 -0
- package/dist/events/webhooks.js.map +1 -0
- package/dist/events.d.ts +369 -22
- package/dist/events.js +311 -8
- package/dist/events.js.map +1 -1
- package/dist/flags.d.ts +18 -0
- package/dist/flags.js +44 -0
- package/dist/flags.js.map +1 -0
- package/dist/hosting.d.ts +13 -14
- package/dist/hosting.js +3 -4
- package/dist/hosting.js.map +1 -1
- package/dist/ids.d.ts +987 -0
- package/dist/ids.js +317 -0
- package/dist/ids.js.map +1 -0
- package/dist/index.d.ts +25 -1
- package/dist/index.js +34 -2
- package/dist/index.js.map +1 -1
- package/dist/keys.d.ts +2 -2
- package/dist/keys.js +3 -3
- package/dist/knowledge.d.ts +1192 -0
- package/dist/knowledge.js +1002 -0
- package/dist/knowledge.js.map +1 -0
- package/dist/localization.d.ts +663 -0
- package/dist/localization.js +491 -0
- package/dist/localization.js.map +1 -0
- package/dist/methods.js +3251 -133
- package/dist/methods.js.map +1 -1
- package/dist/money.d.ts +3086 -0
- package/dist/money.js +2358 -0
- package/dist/money.js.map +1 -0
- package/dist/network.d.ts +4 -5
- package/dist/network.js +3 -4
- package/dist/network.js.map +1 -1
- package/dist/notify.d.ts +667 -125
- package/dist/notify.js +471 -73
- package/dist/notify.js.map +1 -1
- package/dist/observability.d.ts +322 -7
- package/dist/observability.js +244 -8
- package/dist/observability.js.map +1 -1
- package/dist/realtime.d.ts +404 -0
- package/dist/realtime.js +312 -0
- package/dist/realtime.js.map +1 -0
- package/dist/release.d.ts +14 -15
- package/dist/release.js +3 -4
- package/dist/release.js.map +1 -1
- package/dist/runners.d.ts +2 -3
- package/dist/runners.js +3 -4
- package/dist/runners.js.map +1 -1
- package/dist/runtime.d.ts +5 -1
- package/dist/runtime.js +7 -3
- package/dist/runtime.js.map +1 -1
- package/dist/sandboxes.d.ts +64 -20
- package/dist/sandboxes.js +9 -4
- package/dist/sandboxes.js.map +1 -1
- package/dist/secrets.d.ts +342 -6
- package/dist/secrets.js +271 -4
- package/dist/secrets.js.map +1 -1
- package/dist/workflows.d.ts +969 -15
- package/dist/workflows.js +815 -6
- package/dist/workflows.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -32,9 +32,26 @@ for await (const project of sylphx.access.projects.listAll({ parent: me.org }))
|
|
|
32
32
|
`Retry-After`; each logical mutation sends one `Idempotency-Key`.
|
|
33
33
|
- `sylphx.invoke('data.databases.get', { name })` calls any method by id with
|
|
34
34
|
wire JSON.
|
|
35
|
+
- In a browser, use the environment's publishable key
|
|
36
|
+
(`SYLPHX_PUBLISHABLE_KEY`, delivered by the platform to every service and
|
|
37
|
+
safe to ship in a bundle). It calls only browser-safe methods, such as error
|
|
38
|
+
capture:
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
const sylphx = new Sylphx({ apiKey: PUBLISHABLE_KEY }) // e.g. from a public build-time variable
|
|
42
|
+
window.addEventListener('error', (e) =>
|
|
43
|
+
sylphx.observability.errorGroups.capture({
|
|
44
|
+
parent: 'orgs/-/projects/-/envs/-',
|
|
45
|
+
errorEvent: { exceptionType: e.error?.name ?? 'Error', message: e.message, stack: e.error?.stack, release: RELEASE },
|
|
46
|
+
}),
|
|
47
|
+
)
|
|
48
|
+
```
|
|
35
49
|
- Some services also have a data plane served at their own host, with the same
|
|
36
|
-
key: Sylphx Data's objects
|
|
37
|
-
|
|
50
|
+
key: Sylphx Data's objects, key-value entries, and search documents are
|
|
51
|
+
`sylphx.data.objects`, `sylphx.data.kv` (strings and counters, plus
|
|
52
|
+
`getMany`, hashes, lists, sorted sets, `scan`, and `expire`),
|
|
53
|
+
`sylphx.data.documents`, and `sylphx.data.search` (at
|
|
54
|
+
`https://api.data.sylphx.com`). Every such call
|
|
38
55
|
carries one `Sylphx-Effect-Id`, reused on its retries, so a retried write is
|
|
39
56
|
applied once.
|
|
40
57
|
- `SYLPHX_URL` and `SYLPHX_SECRET_URL` (per-project `<project>.api.sylphx.com`
|
|
@@ -43,13 +60,123 @@ for await (const project of sylphx.access.projects.listAll({ parent: me.org }))
|
|
|
43
60
|
- Per-service subpath imports tree-shake: `import { DataApi } from '@sylphx/sdk/data'`.
|
|
44
61
|
|
|
45
62
|
```ts
|
|
46
|
-
// Bytes travel base64 (`body`, `value`); the bucket
|
|
47
|
-
// Resources of the environment (`sylphx.data.buckets`,
|
|
63
|
+
// Bytes travel base64 (`body`, `value`, `documentJson`); the bucket, namespace,
|
|
64
|
+
// and index are Data Resources of the environment (`sylphx.data.buckets`,
|
|
65
|
+
// `sylphx.data.kvNamespaces`, `sylphx.data.searchIndexes`).
|
|
48
66
|
await sylphx.data.objects.put({ bucketId: 'uploads', key: `${orgId}/cv.pdf`, body: base64, contentType: 'application/pdf' })
|
|
49
67
|
const { body } = await sylphx.data.objects.get({ bucketId: 'uploads', key: `${orgId}/cv.pdf` })
|
|
50
68
|
const hits = await sylphx.data.kv.increment({ namespaceId: 'ratelimit', key: `ip:${ip}` })
|
|
69
|
+
await sylphx.data.kv.zsetAdd({ namespaceId: 'board', key: 'weekly', members: [{ member: userId, score: 120 }] })
|
|
70
|
+
const { score } = await sylphx.data.kv.zsetScore({ namespaceId: 'board', key: 'weekly', member: userId })
|
|
71
|
+
await sylphx.data.documents.put({ indexId: 'articles', documentId: slug, documentJson: btoa(JSON.stringify(article)) })
|
|
72
|
+
const { hits: found } = await sylphx.data.search.query({ indexId: 'articles', query: 'pricing', limit: 10 })
|
|
51
73
|
```
|
|
52
74
|
|
|
75
|
+
### Object upload transport and older SDKs
|
|
76
|
+
|
|
77
|
+
`data.objects.put` sends base64 bytes in an authenticated JSON request. Its
|
|
78
|
+
HTTP Content-Type is `application/json`; the object's MIME is the JSON
|
|
79
|
+
`contentType` field. It does not mint or PUT to presigned multipart URLs.
|
|
80
|
+
|
|
81
|
+
The older `@sylphx/sdk@0.27.0` exported `storage.uploads.create` and sent
|
|
82
|
+
Blob slices to presigned part URLs. That API is absent from this generated
|
|
83
|
+
SDK: upgrading such a caller requires migrating its upload and file-management
|
|
84
|
+
calls to Data's object API, not only changing its package pin. The old
|
|
85
|
+
`@sylphx/sdk/react`, `/server`, and `/nextjs` integrations are not equivalent
|
|
86
|
+
exports of this package either.
|
|
87
|
+
|
|
53
88
|
This package is generated from the Sylphx schema registry by `sylphx-gen`; do
|
|
54
89
|
not edit it by hand. Source: `clients/typescript` in the Sylphx monorepo,
|
|
55
90
|
published from its MIT mirror.
|
|
91
|
+
|
|
92
|
+
## Typed flags with offline defaults
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
const flags = sylphx.flags({
|
|
96
|
+
parent: 'orgs/my-org/projects/my-project/envs/production',
|
|
97
|
+
context: { userId: 'alice' },
|
|
98
|
+
})
|
|
99
|
+
const enabled = await flags.bool('new-checkout', false)
|
|
100
|
+
const layout = await flags.string('layout', 'classic')
|
|
101
|
+
const limit = await flags.number('limit', 10)
|
|
102
|
+
const settings = await flags.json('settings', { color: 'blue' })
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Keep the handle for that environment and subject. It uses the existing Config
|
|
106
|
+
flags evaluator (remote by default, with a five-minute cache). If the API is
|
|
107
|
+
unreachable, it returns the last evaluated values held in memory, then the
|
|
108
|
+
call-site default when none exist. Missing flags and scalar type mismatches
|
|
109
|
+
also return the default. A new handle has no offline cache; create a separate
|
|
110
|
+
handle when changing environment or subject. OpenFeature providers are unchanged.
|
|
111
|
+
|
|
112
|
+
## Browser sign-in: `createAuthClient`
|
|
113
|
+
|
|
114
|
+
A small client for Sylphx Auth's client API (`/v1/client/*`) in a browser app.
|
|
115
|
+
It holds only a publishable key (`sylphx_pk_...`, public by design); a secret
|
|
116
|
+
key given to it throws.
|
|
117
|
+
|
|
118
|
+
```ts
|
|
119
|
+
import { createAuthClient } from '@sylphx/sdk/auth/client' // also exported from '@sylphx/sdk'
|
|
120
|
+
|
|
121
|
+
const auth = createAuthClient({ publishableKey: 'sylphx_pk_live_...' })
|
|
122
|
+
const config = await auth.config() // methods, social providers, branding
|
|
123
|
+
const { session, user } = await auth.signInWithPassword({ email, password })
|
|
124
|
+
await auth.getSession()
|
|
125
|
+
await auth.signOut()
|
|
126
|
+
|
|
127
|
+
// Social sign-in is a navigation; the callback appends ?auth_ticket=...
|
|
128
|
+
// (config().ticketParam names it)
|
|
129
|
+
location.assign(auth.oauthStartUrl('google', { redirectUrl: location.href }))
|
|
130
|
+
await auth.redeemTicket(new URLSearchParams(location.search).get('auth_ticket')!)
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
- Every call carries `publishable_key` (or `instance`, the public slug) in the
|
|
134
|
+
query string, same-origin or not: a browser preflight has no `Authorization`,
|
|
135
|
+
and the query is where Auth learns the environment before it answers CORS.
|
|
136
|
+
An existing query is kept and the parameter is never duplicated. The key is
|
|
137
|
+
never sent as a Bearer.
|
|
138
|
+
- Options: `publishableKey` or `instance` (exactly one), `baseUrl`
|
|
139
|
+
(default `https://api.sylphx.com`), `fetch`, `credentials` (default `'omit'`;
|
|
140
|
+
`'include'` is opt-in), `sessionToken` (to restore a session).
|
|
141
|
+
- Add your app's origin to `allowed_origins` on the environment's Auth Config
|
|
142
|
+
to make browsers refuse every origin you did not name.
|
|
143
|
+
- Errors are `AuthClientError` subclasses keyed on the service's `code`
|
|
144
|
+
(`AuthUnauthorizedError`, `AuthMfaRequiredError`, `AuthRateLimitedError`
|
|
145
|
+
with `retryAfterSeconds`, `AuthNetworkError`, ...), not `SylphxError`.
|
|
146
|
+
|
|
147
|
+
### The session is a bearer token in JavaScript (XSS trade-off)
|
|
148
|
+
|
|
149
|
+
There is no cookie mode. The client asks for `session_mode: "browser"`, so the
|
|
150
|
+
session token is a bearer value that page script holds. A script injected into
|
|
151
|
+
your page (XSS) can read it. Keep the token out of URLs and logs, and keep a
|
|
152
|
+
strict Content-Security-Policy.
|
|
153
|
+
|
|
154
|
+
If your app has a backend and needs an HttpOnly cookie, use the server (BFF)
|
|
155
|
+
pattern instead: the page only ever holds a one-time ticket, and your server
|
|
156
|
+
redeems it with the secret key and sets the cookie on your own origin.
|
|
157
|
+
|
|
158
|
+
```ts
|
|
159
|
+
// Browser: sign in with the default server mode; hand the ticket to your backend.
|
|
160
|
+
const res = await fetch(`https://api.sylphx.com/v1/client/sign-in/password?publishable_key=${pk}`, {
|
|
161
|
+
method: 'POST',
|
|
162
|
+
headers: { 'content-type': 'application/json' },
|
|
163
|
+
body: JSON.stringify({ email, password }), // session_mode defaults to "server"
|
|
164
|
+
})
|
|
165
|
+
const { ticket } = await res.json()
|
|
166
|
+
await fetch('/auth/session', { method: 'POST', body: JSON.stringify({ ticket }) })
|
|
167
|
+
|
|
168
|
+
// Your server (secret key stays here; forward the browser's User-Agent):
|
|
169
|
+
const redeemed = await fetch('https://api.sylphx.com/v1/client/tickets:redeem', {
|
|
170
|
+
method: 'POST',
|
|
171
|
+
headers: {
|
|
172
|
+
authorization: `Bearer ${process.env.SYLPHX_AUTH_SECRET_KEY}`,
|
|
173
|
+
'content-type': 'application/json',
|
|
174
|
+
'user-agent': request.headers.get('user-agent') ?? '',
|
|
175
|
+
},
|
|
176
|
+
body: JSON.stringify({ ticket }),
|
|
177
|
+
})
|
|
178
|
+
const { session } = await redeemed.json()
|
|
179
|
+
// Set-Cookie: session=<session.token>; HttpOnly; Secure; SameSite=Lax
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
`@sylphx/nextjs` ships this pattern as a route handler.
|
package/dist/access.d.ts
CHANGED
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
import * as runtime from './runtime.js';
|
|
2
2
|
import './common.js';
|
|
3
3
|
import type * as common from './common.js';
|
|
4
|
+
/**
|
|
5
|
+
* AiSpendLimit caps Sylphx AI spend at the sell price, in USD cents. A day
|
|
6
|
+
* and a month are UTC calendar periods.
|
|
7
|
+
*/
|
|
8
|
+
export interface AiSpendLimit {
|
|
9
|
+
/** Most spend per calendar month, in USD cents. */
|
|
10
|
+
monthlyUsdMinor?: string;
|
|
11
|
+
/** Most spend per calendar day, in USD cents. */
|
|
12
|
+
dailyUsdMinor?: string;
|
|
13
|
+
}
|
|
4
14
|
/**
|
|
5
15
|
* An ApiKey is a credential of one environment, or an org-wide key of an
|
|
6
|
-
* org (it acts on every project of the org
|
|
7
|
-
*
|
|
8
|
-
*
|
|
16
|
+
* org (it acts on every project of the org), issued only by Access (the
|
|
17
|
+
* platform has one key system). The secret is returned once, by Create and
|
|
18
|
+
* Roll, and never again.
|
|
9
19
|
*/
|
|
10
20
|
export interface ApiKey {
|
|
11
21
|
/**
|
|
@@ -29,15 +39,17 @@ export interface ApiKeySpec {
|
|
|
29
39
|
* only).
|
|
30
40
|
*/
|
|
31
41
|
kind?: ApiKeyKind;
|
|
32
|
-
/**
|
|
33
|
-
* Scopes `<service>:<action>` (access-and-keys.md §5.1), a subset of the
|
|
34
|
-
* creator's effective scopes.
|
|
35
|
-
*/
|
|
42
|
+
/** Scopes `<service>:<action>`, a subset of the creator's effective scopes. */
|
|
36
43
|
scopes?: string[];
|
|
37
44
|
/** A free-form label, for example the talent id a key was minted for. */
|
|
38
45
|
label?: string;
|
|
39
46
|
/** When the key stops verifying; required in unclaimed projects. */
|
|
40
47
|
expireTime?: string;
|
|
48
|
+
/**
|
|
49
|
+
* Usage limits on this key, on top of its project's and the plan tier's;
|
|
50
|
+
* the tightest one applies. Unset means no key-level limit.
|
|
51
|
+
*/
|
|
52
|
+
limits?: UsageLimits;
|
|
41
53
|
}
|
|
42
54
|
/** ApiKeyStatus is the observed state of an ApiKey. */
|
|
43
55
|
export interface ApiKeyStatus {
|
|
@@ -200,6 +212,11 @@ export interface GetProjectRequest {
|
|
|
200
212
|
/** The name of the project to get. */
|
|
201
213
|
name: string;
|
|
202
214
|
}
|
|
215
|
+
/** The request of GetServiceEnablement. */
|
|
216
|
+
export interface GetServiceEnablementRequest {
|
|
217
|
+
/** The name of the service enablement to get. */
|
|
218
|
+
name: string;
|
|
219
|
+
}
|
|
203
220
|
/** The request of ListApiKeys. */
|
|
204
221
|
export interface ListApiKeysRequest {
|
|
205
222
|
/** The parent to list in. */
|
|
@@ -278,6 +295,26 @@ export interface ListProjectsResponse {
|
|
|
278
295
|
/** The token of the next page; empty on the last page. */
|
|
279
296
|
nextPageToken?: string;
|
|
280
297
|
}
|
|
298
|
+
/** The request of ListServiceEnablements. */
|
|
299
|
+
export interface ListServiceEnablementsRequest {
|
|
300
|
+
/** The parent to list in. */
|
|
301
|
+
parent: string;
|
|
302
|
+
/** At most this many; default 50, clamped to 1000. */
|
|
303
|
+
pageSize?: number;
|
|
304
|
+
/** `next_page_token` of the previous page. */
|
|
305
|
+
pageToken?: string;
|
|
306
|
+
/** AIP-160 filter over labels, filterable spec fields, and Ready. */
|
|
307
|
+
filter?: string;
|
|
308
|
+
/** AIP-132 ordering over filterable fields. */
|
|
309
|
+
orderBy?: string;
|
|
310
|
+
}
|
|
311
|
+
/** The response of ListServiceEnablements. */
|
|
312
|
+
export interface ListServiceEnablementsResponse {
|
|
313
|
+
/** The page. */
|
|
314
|
+
serviceEnablements?: ServiceEnablement[];
|
|
315
|
+
/** The token of the next page; empty on the last page. */
|
|
316
|
+
nextPageToken?: string;
|
|
317
|
+
}
|
|
281
318
|
/** An Org is the one Sylphx account: created once, billed once. */
|
|
282
319
|
export interface Org {
|
|
283
320
|
/** `orgs/{org}`. */
|
|
@@ -297,7 +334,7 @@ export interface OrgSpec {
|
|
|
297
334
|
slug?: string;
|
|
298
335
|
/**
|
|
299
336
|
* The API version (`YYYY-MM-DD`) requests are served at when neither the
|
|
300
|
-
* request nor the key pins one
|
|
337
|
+
* request nor the key pins one.
|
|
301
338
|
*/
|
|
302
339
|
apiVersion?: string;
|
|
303
340
|
}
|
|
@@ -313,7 +350,7 @@ export interface OrgStatus {
|
|
|
313
350
|
readonly state?: OrgState;
|
|
314
351
|
/** The partner org, set iff `kind` is PARTNER_SUB. */
|
|
315
352
|
readonly parentOrg?: string;
|
|
316
|
-
/** The org's home
|
|
353
|
+
/** The org's home cell code, for example `fs01`. */
|
|
317
354
|
readonly homeCell?: string;
|
|
318
355
|
}
|
|
319
356
|
/** A Project groups environments and the Resources in them. */
|
|
@@ -333,6 +370,11 @@ export interface Project {
|
|
|
333
370
|
export interface ProjectSpec {
|
|
334
371
|
/** Unique within the org. */
|
|
335
372
|
slug?: string;
|
|
373
|
+
/**
|
|
374
|
+
* Usage limits shared by every key of the project; a key's own limits
|
|
375
|
+
* only tighten them. Unset means no project-level limit.
|
|
376
|
+
*/
|
|
377
|
+
limits?: UsageLimits;
|
|
336
378
|
}
|
|
337
379
|
/** ProjectStatus is the observed state of a Project. */
|
|
338
380
|
export interface ProjectStatus {
|
|
@@ -363,6 +405,38 @@ export interface RollApiKeyRequest {
|
|
|
363
405
|
/** Validate without rolling. */
|
|
364
406
|
validateOnly?: boolean;
|
|
365
407
|
}
|
|
408
|
+
/**
|
|
409
|
+
* A ServiceEnablement says whether one service is enabled on a Project: the
|
|
410
|
+
* project's keys reach a service only while it is enabled (onboarding spec
|
|
411
|
+
* §3.2). It is project-scoped, applies to every environment of the project,
|
|
412
|
+
* and is named by the service id (`data`, `hosting`, ...): the rows are fixed
|
|
413
|
+
* by the platform's service list, so there is no create or delete, and an
|
|
414
|
+
* update writes `spec.enabled`.
|
|
415
|
+
*/
|
|
416
|
+
export interface ServiceEnablement {
|
|
417
|
+
/** `orgs/{org}/projects/{project}/service_enablements/{service}`. */
|
|
418
|
+
name?: string;
|
|
419
|
+
/** The service id; equals the name segment. */
|
|
420
|
+
readonly uid?: string;
|
|
421
|
+
/** Resource metadata. */
|
|
422
|
+
meta?: common.ResourceMeta;
|
|
423
|
+
/** Desired state. */
|
|
424
|
+
spec?: ServiceEnablementSpec;
|
|
425
|
+
/** Observed state. */
|
|
426
|
+
readonly status?: ServiceEnablementStatus;
|
|
427
|
+
}
|
|
428
|
+
/** ServiceEnablementSpec is the caller-writable state of a ServiceEnablement. */
|
|
429
|
+
export interface ServiceEnablementSpec {
|
|
430
|
+
/** Whether the project's keys may reach the service. */
|
|
431
|
+
enabled?: boolean;
|
|
432
|
+
}
|
|
433
|
+
/** ServiceEnablementStatus is the observed state of a ServiceEnablement. */
|
|
434
|
+
export interface ServiceEnablementStatus {
|
|
435
|
+
/** The generation this status was computed from. */
|
|
436
|
+
readonly observedGeneration?: string;
|
|
437
|
+
/** Ready, Reconciling, Stalled. */
|
|
438
|
+
readonly conditions?: common.Condition[];
|
|
439
|
+
}
|
|
366
440
|
/** The request of UpdateApiKey. */
|
|
367
441
|
export interface UpdateApiKeyRequest {
|
|
368
442
|
/** The API key to update; `name` identifies it. */
|
|
@@ -399,6 +473,29 @@ export interface UpdateProjectRequest {
|
|
|
399
473
|
/** Validate and return the result without writing anything. */
|
|
400
474
|
validateOnly?: boolean;
|
|
401
475
|
}
|
|
476
|
+
/** The request of UpdateServiceEnablement. */
|
|
477
|
+
export interface UpdateServiceEnablementRequest {
|
|
478
|
+
/** The service enablement to update; `name` identifies it. */
|
|
479
|
+
serviceEnablement: ServiceEnablement;
|
|
480
|
+
/** The fields to write; unset writes every populated field. */
|
|
481
|
+
updateMask?: string;
|
|
482
|
+
/** Validate and return the result without writing anything. */
|
|
483
|
+
validateOnly?: boolean;
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* UsageLimits are the limits a customer sets on a key or a project. Each is
|
|
487
|
+
* enforced before a call is served; a call over one is refused with
|
|
488
|
+
* RATE_LIMITED or SPEND_LIMIT_REACHED and is not billed. An unset field sets
|
|
489
|
+
* no limit at this level.
|
|
490
|
+
*/
|
|
491
|
+
export interface UsageLimits {
|
|
492
|
+
/** Sylphx AI spend. */
|
|
493
|
+
aiSpend?: AiSpendLimit;
|
|
494
|
+
/** Requests per minute. */
|
|
495
|
+
requestsPerMinute?: number;
|
|
496
|
+
/** Sylphx AI tokens per minute, input and output together. */
|
|
497
|
+
aiTokensPerMinute?: string;
|
|
498
|
+
}
|
|
402
499
|
/** The request of Whoami. */
|
|
403
500
|
export interface WhoamiRequest {
|
|
404
501
|
}
|
|
@@ -417,8 +514,8 @@ export interface WhoamiResponse {
|
|
|
417
514
|
/** The credential's scopes, `<service>:<action>`. */
|
|
418
515
|
readonly scopes?: string[];
|
|
419
516
|
/**
|
|
420
|
-
* The API version date applied to this request
|
|
421
|
-
*
|
|
517
|
+
* The API version date applied to this request; empty before the first
|
|
518
|
+
* version.
|
|
422
519
|
*/
|
|
423
520
|
readonly apiVersion?: string;
|
|
424
521
|
}
|
|
@@ -433,9 +530,8 @@ export type OrgState = 'active' | 'suspended' | 'deleting' | (string & {});
|
|
|
433
530
|
/** RevokeReason is why an ApiKey stopped verifying. */
|
|
434
531
|
export type RevokeReason = 'user' | 'rotation' | 'leaked' | 'claimed' | 'claim_expired' | 'org_deleted' | 'admin' | 'role_changed' | 'logout' | (string & {});
|
|
435
532
|
/**
|
|
436
|
-
* AccessService is Sylphx Access: orgs, projects, environments, and API keys
|
|
437
|
-
*
|
|
438
|
-
* only writer of these types.
|
|
533
|
+
* AccessService is Sylphx Access: orgs, projects, environments, and API keys.
|
|
534
|
+
* Access is the only writer of these types.
|
|
439
535
|
*
|
|
440
536
|
* Namespace of Sylphx Access on `Sylphx`.
|
|
441
537
|
*/
|
|
@@ -447,14 +543,15 @@ export declare class AccessApi {
|
|
|
447
543
|
readonly projects: ProjectsCollection;
|
|
448
544
|
/** The `envs` collection. */
|
|
449
545
|
readonly envs: EnvsCollection;
|
|
546
|
+
/** The `service_enablements` collection. */
|
|
547
|
+
readonly serviceEnablements: ServiceEnablementsCollection;
|
|
450
548
|
/** The `api_keys` collection. */
|
|
451
549
|
readonly apiKeys: ApiKeysCollection;
|
|
452
550
|
constructor(client: runtime.Client);
|
|
453
551
|
/**
|
|
454
552
|
* Returns the caller: the principal and the scope of the key or token that
|
|
455
553
|
* authenticated this request. Clients fill their org, project, and env
|
|
456
|
-
* defaults from it
|
|
457
|
-
* call it, whatever its scopes.
|
|
554
|
+
* defaults from it; every valid key may call it, whatever its scopes.
|
|
458
555
|
*
|
|
459
556
|
* `GET /v1/whoami` · permission `access:whoami` · effect `read`
|
|
460
557
|
*
|
|
@@ -604,6 +701,37 @@ export declare class EnvsCollection {
|
|
|
604
701
|
*/
|
|
605
702
|
delete(request: DeleteEnvironmentRequest): Promise<Record<string, never>>;
|
|
606
703
|
}
|
|
704
|
+
/** `service_enablements` of Sylphx Access: Resource type `access.sylphx.com/ServiceEnablement`. */
|
|
705
|
+
export declare class ServiceEnablementsCollection {
|
|
706
|
+
private readonly client;
|
|
707
|
+
constructor(client: runtime.Client);
|
|
708
|
+
/**
|
|
709
|
+
* Gets a service enablement.
|
|
710
|
+
*
|
|
711
|
+
* `GET /v1/{name=orgs/*\/projects/*\/service_enablements/*}` · permission `access:read` · effect `read`
|
|
712
|
+
*
|
|
713
|
+
* Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `RESOURCE_NOT_FOUND`.
|
|
714
|
+
*/
|
|
715
|
+
get(request: GetServiceEnablementRequest): Promise<ServiceEnablement>;
|
|
716
|
+
/**
|
|
717
|
+
* Lists the service enablements of a project, one per service.
|
|
718
|
+
*
|
|
719
|
+
* `GET /v1/{parent=orgs/*\/projects/*}/service_enablements` · permission `access:read` · effect `read`
|
|
720
|
+
*
|
|
721
|
+
* Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `INVALID_FIELD`, `PAGE_TOKEN_MISMATCH`.
|
|
722
|
+
*/
|
|
723
|
+
list(request: ListServiceEnablementsRequest): Promise<ListServiceEnablementsResponse>;
|
|
724
|
+
/** Every item of every page of `list`. */
|
|
725
|
+
listAll(request: ListServiceEnablementsRequest): AsyncGenerator<ServiceEnablement>;
|
|
726
|
+
/**
|
|
727
|
+
* Enables or disables a service on a project (`spec.enabled`).
|
|
728
|
+
*
|
|
729
|
+
* `PATCH /v1/{service_enablement.name=orgs/*\/projects/*\/service_enablements/*}` · permission `access:admin` · effect `write`
|
|
730
|
+
*
|
|
731
|
+
* Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `RESOURCE_NOT_FOUND`, `UNKNOWN_FIELD`, `INVALID_FIELD`, `ETAG_MISMATCH`, `IDEMPOTENCY_KEY_REUSED`, `IDEMPOTENCY_IN_PROGRESS`.
|
|
732
|
+
*/
|
|
733
|
+
update(request: UpdateServiceEnablementRequest): Promise<ServiceEnablement>;
|
|
734
|
+
}
|
|
607
735
|
/** `api_keys` of Sylphx Access: Resource type `access.sylphx.com/ApiKey`. */
|
|
608
736
|
export declare class ApiKeysCollection {
|
|
609
737
|
private readonly client;
|
|
@@ -651,7 +779,8 @@ export declare class ApiKeysCollection {
|
|
|
651
779
|
*/
|
|
652
780
|
delete(request: DeleteApiKeyRequest): Promise<Record<string, never>>;
|
|
653
781
|
/**
|
|
654
|
-
* Revokes an API key immediately; revocation
|
|
782
|
+
* Revokes an API key immediately; revocation propagates on its own fast
|
|
783
|
+
* path, ahead of the bulk key data.
|
|
655
784
|
*
|
|
656
785
|
* `POST /v1/{name=orgs/*\/projects/*\/envs/*\/api_keys/*}:revoke` · permission `access:keys:write` · effect `destructive`
|
|
657
786
|
*
|
package/dist/access.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
// @generated by sylphx-gen 0.1.0 from contracts@
|
|
1
|
+
// @generated by sylphx-gen 0.1.0 from contracts@c8a7361c53e572321b0ec9fb014fd1e8279b007b62562423038e0d0e5b9d767a. Do not edit.
|
|
2
2
|
// `sylphx.access.v1`.
|
|
3
3
|
import * as runtime from './runtime.js';
|
|
4
4
|
import './common.js';
|
|
5
5
|
runtime.registerSchemas({
|
|
6
|
+
'sylphx.access.v1.AiSpendLimit': [
|
|
7
|
+
['monthlyUsdMinor', 'monthly_usd_minor'],
|
|
8
|
+
['dailyUsdMinor', 'daily_usd_minor'],
|
|
9
|
+
],
|
|
6
10
|
'sylphx.access.v1.ApiKey': [
|
|
7
11
|
['meta', 'meta', 'sylphx.common.v1.ResourceMeta'],
|
|
8
12
|
['spec', 'spec', 'sylphx.access.v1.ApiKeySpec'],
|
|
@@ -10,6 +14,7 @@ runtime.registerSchemas({
|
|
|
10
14
|
],
|
|
11
15
|
'sylphx.access.v1.ApiKeySpec': [
|
|
12
16
|
['expireTime', 'expire_time'],
|
|
17
|
+
['limits', 'limits', 'sylphx.access.v1.UsageLimits'],
|
|
13
18
|
],
|
|
14
19
|
'sylphx.access.v1.ApiKeyStatus': [
|
|
15
20
|
['observedGeneration', 'observed_generation'],
|
|
@@ -62,6 +67,7 @@ runtime.registerSchemas({
|
|
|
62
67
|
'sylphx.access.v1.GetEnvironmentRequest': [],
|
|
63
68
|
'sylphx.access.v1.GetOrgRequest': [],
|
|
64
69
|
'sylphx.access.v1.GetProjectRequest': [],
|
|
70
|
+
'sylphx.access.v1.GetServiceEnablementRequest': [],
|
|
65
71
|
'sylphx.access.v1.ListApiKeysRequest': [
|
|
66
72
|
['pageSize', 'page_size'],
|
|
67
73
|
['pageToken', 'page_token'],
|
|
@@ -98,6 +104,15 @@ runtime.registerSchemas({
|
|
|
98
104
|
['projects', 'projects', 'sylphx.access.v1.Project'],
|
|
99
105
|
['nextPageToken', 'next_page_token'],
|
|
100
106
|
],
|
|
107
|
+
'sylphx.access.v1.ListServiceEnablementsRequest': [
|
|
108
|
+
['pageSize', 'page_size'],
|
|
109
|
+
['pageToken', 'page_token'],
|
|
110
|
+
['orderBy', 'order_by'],
|
|
111
|
+
],
|
|
112
|
+
'sylphx.access.v1.ListServiceEnablementsResponse': [
|
|
113
|
+
['serviceEnablements', 'service_enablements', 'sylphx.access.v1.ServiceEnablement'],
|
|
114
|
+
['nextPageToken', 'next_page_token'],
|
|
115
|
+
],
|
|
101
116
|
'sylphx.access.v1.Org': [
|
|
102
117
|
['meta', 'meta', 'sylphx.common.v1.ResourceMeta'],
|
|
103
118
|
['spec', 'spec', 'sylphx.access.v1.OrgSpec'],
|
|
@@ -117,7 +132,9 @@ runtime.registerSchemas({
|
|
|
117
132
|
['spec', 'spec', 'sylphx.access.v1.ProjectSpec'],
|
|
118
133
|
['status', 'status', 'sylphx.access.v1.ProjectStatus'],
|
|
119
134
|
],
|
|
120
|
-
'sylphx.access.v1.ProjectSpec': [
|
|
135
|
+
'sylphx.access.v1.ProjectSpec': [
|
|
136
|
+
['limits', 'limits', 'sylphx.access.v1.UsageLimits'],
|
|
137
|
+
],
|
|
121
138
|
'sylphx.access.v1.ProjectStatus': [
|
|
122
139
|
['observedGeneration', 'observed_generation'],
|
|
123
140
|
['conditions', 'conditions', 'sylphx.common.v1.Condition'],
|
|
@@ -130,6 +147,16 @@ runtime.registerSchemas({
|
|
|
130
147
|
['gracePeriod', 'grace_period'],
|
|
131
148
|
['validateOnly', 'validate_only'],
|
|
132
149
|
],
|
|
150
|
+
'sylphx.access.v1.ServiceEnablement': [
|
|
151
|
+
['meta', 'meta', 'sylphx.common.v1.ResourceMeta'],
|
|
152
|
+
['spec', 'spec', 'sylphx.access.v1.ServiceEnablementSpec'],
|
|
153
|
+
['status', 'status', 'sylphx.access.v1.ServiceEnablementStatus'],
|
|
154
|
+
],
|
|
155
|
+
'sylphx.access.v1.ServiceEnablementSpec': [],
|
|
156
|
+
'sylphx.access.v1.ServiceEnablementStatus': [
|
|
157
|
+
['observedGeneration', 'observed_generation'],
|
|
158
|
+
['conditions', 'conditions', 'sylphx.common.v1.Condition'],
|
|
159
|
+
],
|
|
133
160
|
'sylphx.access.v1.UpdateApiKeyRequest': [
|
|
134
161
|
['apiKey', 'api_key', 'sylphx.access.v1.ApiKey'],
|
|
135
162
|
['updateMask', 'update_mask'],
|
|
@@ -150,6 +177,16 @@ runtime.registerSchemas({
|
|
|
150
177
|
['updateMask', 'update_mask'],
|
|
151
178
|
['validateOnly', 'validate_only'],
|
|
152
179
|
],
|
|
180
|
+
'sylphx.access.v1.UpdateServiceEnablementRequest': [
|
|
181
|
+
['serviceEnablement', 'service_enablement', 'sylphx.access.v1.ServiceEnablement'],
|
|
182
|
+
['updateMask', 'update_mask'],
|
|
183
|
+
['validateOnly', 'validate_only'],
|
|
184
|
+
],
|
|
185
|
+
'sylphx.access.v1.UsageLimits': [
|
|
186
|
+
['aiSpend', 'ai_spend', 'sylphx.access.v1.AiSpendLimit'],
|
|
187
|
+
['requestsPerMinute', 'requests_per_minute'],
|
|
188
|
+
['aiTokensPerMinute', 'ai_tokens_per_minute'],
|
|
189
|
+
],
|
|
153
190
|
'sylphx.access.v1.WhoamiRequest': [],
|
|
154
191
|
'sylphx.access.v1.WhoamiResponse': [
|
|
155
192
|
['apiKey', 'api_key'],
|
|
@@ -157,9 +194,8 @@ runtime.registerSchemas({
|
|
|
157
194
|
],
|
|
158
195
|
});
|
|
159
196
|
/**
|
|
160
|
-
* AccessService is Sylphx Access: orgs, projects, environments, and API keys
|
|
161
|
-
*
|
|
162
|
-
* only writer of these types.
|
|
197
|
+
* AccessService is Sylphx Access: orgs, projects, environments, and API keys.
|
|
198
|
+
* Access is the only writer of these types.
|
|
163
199
|
*
|
|
164
200
|
* Namespace of Sylphx Access on `Sylphx`.
|
|
165
201
|
*/
|
|
@@ -171,6 +207,8 @@ export class AccessApi {
|
|
|
171
207
|
projects;
|
|
172
208
|
/** The `envs` collection. */
|
|
173
209
|
envs;
|
|
210
|
+
/** The `service_enablements` collection. */
|
|
211
|
+
serviceEnablements;
|
|
174
212
|
/** The `api_keys` collection. */
|
|
175
213
|
apiKeys;
|
|
176
214
|
constructor(client) {
|
|
@@ -178,13 +216,13 @@ export class AccessApi {
|
|
|
178
216
|
this.orgs = new OrgsCollection(client);
|
|
179
217
|
this.projects = new ProjectsCollection(client);
|
|
180
218
|
this.envs = new EnvsCollection(client);
|
|
219
|
+
this.serviceEnablements = new ServiceEnablementsCollection(client);
|
|
181
220
|
this.apiKeys = new ApiKeysCollection(client);
|
|
182
221
|
}
|
|
183
222
|
/**
|
|
184
223
|
* Returns the caller: the principal and the scope of the key or token that
|
|
185
224
|
* authenticated this request. Clients fill their org, project, and env
|
|
186
|
-
* defaults from it
|
|
187
|
-
* call it, whatever its scopes.
|
|
225
|
+
* defaults from it; every valid key may call it, whatever its scopes.
|
|
188
226
|
*
|
|
189
227
|
* `GET /v1/whoami` · permission `access:whoami` · effect `read`
|
|
190
228
|
*
|
|
@@ -502,6 +540,73 @@ export class EnvsCollection {
|
|
|
502
540
|
});
|
|
503
541
|
}
|
|
504
542
|
}
|
|
543
|
+
/** `service_enablements` of Sylphx Access: Resource type `access.sylphx.com/ServiceEnablement`. */
|
|
544
|
+
export class ServiceEnablementsCollection {
|
|
545
|
+
client;
|
|
546
|
+
constructor(client) {
|
|
547
|
+
this.client = client;
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* Gets a service enablement.
|
|
551
|
+
*
|
|
552
|
+
* `GET /v1/{name=orgs/*\/projects/*\/service_enablements/*}` · permission `access:read` · effect `read`
|
|
553
|
+
*
|
|
554
|
+
* Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `RESOURCE_NOT_FOUND`.
|
|
555
|
+
*/
|
|
556
|
+
async get(request) {
|
|
557
|
+
return this.client.call({
|
|
558
|
+
method: 'GET',
|
|
559
|
+
path: `/v1/${runtime.pathParam(request.name, 'orgs/*/projects/*/service_enablements/*', 'name')}`,
|
|
560
|
+
responseType: 'sylphx.access.v1.ServiceEnablement',
|
|
561
|
+
mutation: false,
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* Lists the service enablements of a project, one per service.
|
|
566
|
+
*
|
|
567
|
+
* `GET /v1/{parent=orgs/*\/projects/*}/service_enablements` · permission `access:read` · effect `read`
|
|
568
|
+
*
|
|
569
|
+
* Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `INVALID_FIELD`, `PAGE_TOKEN_MISMATCH`.
|
|
570
|
+
*/
|
|
571
|
+
async list(request) {
|
|
572
|
+
return this.client.call({
|
|
573
|
+
method: 'GET',
|
|
574
|
+
path: `/v1/${runtime.pathParam(request.parent, 'orgs/*/projects/*', 'parent')}/service_enablements`,
|
|
575
|
+
query: { page_size: request.pageSize, page_token: request.pageToken, filter: request.filter, order_by: request.orderBy },
|
|
576
|
+
responseType: 'sylphx.access.v1.ListServiceEnablementsResponse',
|
|
577
|
+
mutation: false,
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
/** Every item of every page of `list`. */
|
|
581
|
+
async *listAll(request) {
|
|
582
|
+
let next = request;
|
|
583
|
+
for (;;) {
|
|
584
|
+
const page = await this.list(next);
|
|
585
|
+
yield* page.serviceEnablements ?? [];
|
|
586
|
+
if (page.nextPageToken === undefined || page.nextPageToken === '')
|
|
587
|
+
return;
|
|
588
|
+
next = { ...request, pageToken: page.nextPageToken };
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
/**
|
|
592
|
+
* Enables or disables a service on a project (`spec.enabled`).
|
|
593
|
+
*
|
|
594
|
+
* `PATCH /v1/{service_enablement.name=orgs/*\/projects/*\/service_enablements/*}` · permission `access:admin` · effect `write`
|
|
595
|
+
*
|
|
596
|
+
* Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `RESOURCE_NOT_FOUND`, `UNKNOWN_FIELD`, `INVALID_FIELD`, `ETAG_MISMATCH`, `IDEMPOTENCY_KEY_REUSED`, `IDEMPOTENCY_IN_PROGRESS`.
|
|
597
|
+
*/
|
|
598
|
+
async update(request) {
|
|
599
|
+
return this.client.call({
|
|
600
|
+
method: 'PATCH',
|
|
601
|
+
path: `/v1/${runtime.pathParam(request.serviceEnablement?.name, 'orgs/*/projects/*/service_enablements/*', 'service_enablement.name')}`,
|
|
602
|
+
query: { update_mask: request.updateMask, validate_only: request.validateOnly },
|
|
603
|
+
body: request.serviceEnablement ?? {},
|
|
604
|
+
bodyType: 'sylphx.access.v1.ServiceEnablement',
|
|
605
|
+
responseType: 'sylphx.access.v1.ServiceEnablement',
|
|
606
|
+
mutation: true,
|
|
607
|
+
});
|
|
608
|
+
}
|
|
609
|
+
}
|
|
505
610
|
/** `api_keys` of Sylphx Access: Resource type `access.sylphx.com/ApiKey`. */
|
|
506
611
|
export class ApiKeysCollection {
|
|
507
612
|
client;
|
|
@@ -602,7 +707,8 @@ export class ApiKeysCollection {
|
|
|
602
707
|
});
|
|
603
708
|
}
|
|
604
709
|
/**
|
|
605
|
-
* Revokes an API key immediately; revocation
|
|
710
|
+
* Revokes an API key immediately; revocation propagates on its own fast
|
|
711
|
+
* path, ahead of the bulk key data.
|
|
606
712
|
*
|
|
607
713
|
* `POST /v1/{name=orgs/*\/projects/*\/envs/*\/api_keys/*}:revoke` · permission `access:keys:write` · effect `destructive`
|
|
608
714
|
*
|