@usestatemachines/sdk 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +86 -33
- package/agents/SKILL.md +71 -48
- package/agents/index.d.ts +2 -0
- package/agents/index.js +9 -7
- package/agents/llms.txt +23 -15
- package/agents/prompt.md +5 -25
- package/esm/extensions/client.d.ts +11 -7
- package/esm/extensions/client.js +32 -49
- package/esm/extensions/credentials.d.ts +25 -8
- package/esm/extensions/credentials.js +75 -40
- package/esm/extensions/environment.d.ts +1 -1
- package/esm/extensions/errors.js +1 -1
- package/esm/extensions/index.d.ts +2 -2
- package/esm/extensions/yaml.js +14 -12
- package/esm/funcs/environments-creators.d.ts +11 -0
- package/esm/funcs/environments-creators.js +90 -0
- package/esm/funcs/environments-list.js +2 -0
- package/esm/funcs/requests-list.js +5 -1
- package/esm/funcs/requests-stats.js +5 -1
- package/esm/lib/config.d.ts +2 -2
- package/esm/lib/config.js +2 -2
- package/esm/models/app-entry.d.ts +8 -0
- package/esm/models/app-entry.js +11 -0
- package/esm/models/create-environment-app.d.ts +25 -0
- package/esm/models/create-environment-app.js +14 -0
- package/esm/models/create-environment.d.ts +3 -26
- package/esm/models/create-environment.js +2 -19
- package/esm/models/credential.d.ts +50 -0
- package/esm/models/credential.js +60 -0
- package/esm/models/credentials.d.ts +26 -5
- package/esm/models/credentials.js +20 -3
- package/esm/models/environment-failure.d.ts +3 -2
- package/esm/models/environment-failure.js +3 -2
- package/esm/models/environment.d.ts +4 -1
- package/esm/models/environment.js +2 -1
- package/esm/models/error.d.ts +1 -0
- package/esm/models/error.js +1 -0
- package/esm/models/index.d.ts +6 -1
- package/esm/models/index.js +6 -1
- package/esm/models/mcp-server.d.ts +11 -0
- package/esm/models/mcp-server.js +16 -0
- package/esm/models/mcp-tool.d.ts +12 -0
- package/esm/models/mcp-tool.js +16 -0
- package/esm/models/me.d.ts +2 -0
- package/esm/models/me.js +2 -0
- package/esm/models/operations/create-credentials.d.ts +2 -0
- package/esm/models/operations/create-credentials.js +1 -0
- package/esm/models/operations/get-request-stats.d.ts +10 -2
- package/esm/models/operations/get-request-stats.js +5 -1
- package/esm/models/operations/index.d.ts +1 -0
- package/esm/models/operations/index.js +1 -0
- package/esm/models/operations/list-environment-creators.d.ts +23 -0
- package/esm/models/operations/list-environment-creators.js +20 -0
- package/esm/models/operations/list-environments.d.ts +5 -1
- package/esm/models/operations/list-environments.js +2 -0
- package/esm/models/operations/list-requests.d.ts +10 -2
- package/esm/models/operations/list-requests.js +5 -1
- package/esm/models/request-detail.d.ts +8 -1
- package/esm/models/request-detail.js +5 -1
- package/esm/models/request-stats.d.ts +8 -0
- package/esm/models/request-stats.js +9 -0
- package/esm/models/request.d.ts +8 -1
- package/esm/models/request.js +5 -1
- package/esm/models/service.d.ts +25 -0
- package/esm/models/service.js +28 -0
- package/esm/models/snapshot.d.ts +7 -0
- package/esm/models/snapshot.js +3 -0
- package/esm/models/version.d.ts +2 -2
- package/esm/models/version.js +2 -2
- package/esm/sdk/environments.d.ts +1 -0
- package/esm/sdk/environments.js +4 -0
- package/esm/types/discriminated-union.d.ts +24 -0
- package/esm/types/discriminated-union.js +60 -0
- package/esm/types/smart-union.js +2 -1
- package/openapi.json +596 -116
- package/package.json +6 -1
- package/esm/models/api.d.ts +0 -17
- package/esm/models/api.js +0 -21
|
@@ -1,13 +1,30 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import type { Credentials as CredentialsData, CredentialsService as CredentialsServiceData } from '../models/credentials.js';
|
|
2
|
+
/** What a client needs to reach one MCP server of a service: send `headers` with every request to `url`. */
|
|
3
|
+
export interface McpServerCredentials {
|
|
4
|
+
url: string;
|
|
5
|
+
headers: Record<string, string>;
|
|
6
|
+
}
|
|
7
|
+
/** One service from the credentials, plus `server` to hand one of its MCP servers to a client. */
|
|
8
|
+
export type ServiceCredentials = CredentialsServiceData & {
|
|
9
|
+
/**
|
|
10
|
+
* The URL of one MCP server the service serves, with the service's headers.
|
|
11
|
+
* Throws a `TypeError` naming the served MCP servers when it serves no MCP server
|
|
12
|
+
* named `name`.
|
|
13
|
+
*/
|
|
14
|
+
server(name: string): McpServerCredentials;
|
|
15
|
+
};
|
|
16
|
+
/** The API's `Credentials`, plus `fetch` to call the app and `service` to find one service. */
|
|
4
17
|
export type Credentials = CredentialsData & {
|
|
5
18
|
/**
|
|
6
|
-
* Sends one request to the
|
|
7
|
-
* `
|
|
8
|
-
*
|
|
9
|
-
*
|
|
19
|
+
* Sends one request to the `api` service: `path` is joined to its `url`.
|
|
20
|
+
* Its `headers` are defaults, so a header the caller sets, such as another
|
|
21
|
+
* session's `Authorization`, is sent instead. The environment token header
|
|
22
|
+
* is always the service's. Never retries, never follows redirects, never
|
|
23
|
+
* sends the State Machines API key. Throws a `TypeError` when the
|
|
24
|
+
* credentials list no `api` service.
|
|
10
25
|
*/
|
|
11
26
|
fetch(path: string, init?: RequestInit): Promise<Response>;
|
|
27
|
+
/** The service with this ID. Throws a `TypeError` naming the listed services when there is none. */
|
|
28
|
+
service(id: string): ServiceCredentials;
|
|
12
29
|
};
|
|
13
|
-
export declare function bindCredentials(data: CredentialsData,
|
|
30
|
+
export declare function bindCredentials(data: CredentialsData, fetcher: typeof fetch | undefined): Credentials;
|
|
@@ -1,56 +1,91 @@
|
|
|
1
|
-
|
|
1
|
+
/** The gateway admits a request by this header, so a caller cannot replace it. */
|
|
2
|
+
const ENVIRONMENT_TOKEN_HEADER = 'StateMachines-Environment-Token';
|
|
2
3
|
// Checked on the path part only. Covers protocol-relative starts, backslashes, control
|
|
3
4
|
// characters and encoded dots, slashes and backslashes, including double encoding.
|
|
4
5
|
const UNSAFE_PATH = /^\/\/|\\|%(?:25)*(?:2e|2f|5c)|\p{Cc}/iu;
|
|
5
|
-
const OUTSIDE = 'Credentials.fetch only reaches paths under the
|
|
6
|
-
export function bindCredentials(data,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
const OUTSIDE = 'Credentials.fetch only reaches paths under the api service url.';
|
|
7
|
+
export function bindCredentials(data, fetcher) {
|
|
8
|
+
return new BoundCredentials(data, fetcher);
|
|
9
|
+
}
|
|
10
|
+
// Methods live on the prototype, so neither JSON nor a spread copies them.
|
|
11
|
+
class BoundCredentials {
|
|
12
|
+
actorId;
|
|
13
|
+
appName;
|
|
14
|
+
environmentId;
|
|
15
|
+
expiresAt;
|
|
16
|
+
login;
|
|
17
|
+
services;
|
|
18
|
+
token;
|
|
19
|
+
#api;
|
|
20
|
+
#fetcher;
|
|
21
|
+
constructor(data, fetcher) {
|
|
22
|
+
this.actorId = data.actorId;
|
|
23
|
+
this.appName = data.appName;
|
|
24
|
+
this.environmentId = data.environmentId;
|
|
25
|
+
this.expiresAt = data.expiresAt;
|
|
26
|
+
this.login = data.login;
|
|
27
|
+
this.services = data.services;
|
|
28
|
+
this.token = data.token;
|
|
29
|
+
this.#fetcher = fetcher;
|
|
30
|
+
const api = data.services.find((candidate) => candidate.id === 'api');
|
|
31
|
+
this.#api = api
|
|
32
|
+
? { base: baseUrl(api.url), headers: { ...api.headers } }
|
|
33
|
+
: null;
|
|
13
34
|
}
|
|
14
|
-
|
|
35
|
+
async fetch(path, init = {}) {
|
|
36
|
+
const { base, headers: apiHeaders } = this.#api ?? this.#unlisted('api');
|
|
15
37
|
const url = resolve(base, path);
|
|
16
38
|
const headers = new Headers(init.headers);
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (actor) {
|
|
23
|
-
headers.set(actor.name, actor.value);
|
|
39
|
+
for (const [name, value] of Object.entries(apiHeaders)) {
|
|
40
|
+
if (!headers.has(name) ||
|
|
41
|
+
name.toLowerCase() === ENVIRONMENT_TOKEN_HEADER.toLowerCase()) {
|
|
42
|
+
headers.set(name, value);
|
|
43
|
+
}
|
|
24
44
|
}
|
|
25
45
|
const request = new Request(url, { ...init, headers, redirect: 'manual' });
|
|
26
46
|
// Called on `globalThis` at use time: a stored unbound `fetch` throws "Illegal invocation" in Workers.
|
|
27
|
-
return fetcher ? fetcher(request) : globalThis.fetch(request);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
47
|
+
return this.#fetcher ? this.#fetcher(request) : globalThis.fetch(request);
|
|
48
|
+
}
|
|
49
|
+
service(id) {
|
|
50
|
+
const entry = this.services.find((candidate) => candidate.id === id);
|
|
51
|
+
return entry ? new BoundService(entry) : this.#unlisted(id);
|
|
52
|
+
}
|
|
53
|
+
#unlisted(id) {
|
|
54
|
+
const listed = this.services.map((each) => each.id).join(', ') || 'none';
|
|
55
|
+
throw new TypeError(`These credentials list no service named ${JSON.stringify(id)}. They list ${listed}.`);
|
|
56
|
+
}
|
|
33
57
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
if (
|
|
44
|
-
|
|
45
|
-
|
|
58
|
+
class BoundService {
|
|
59
|
+
headers;
|
|
60
|
+
id;
|
|
61
|
+
url;
|
|
62
|
+
constructor(entry) {
|
|
63
|
+
this.headers = entry.headers;
|
|
64
|
+
this.id = entry.id;
|
|
65
|
+
this.url = entry.url;
|
|
66
|
+
// Set only when present, so a spread or JSON of a service without servers has no `servers` key.
|
|
67
|
+
if (entry.servers) {
|
|
68
|
+
this.servers = entry.servers;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
server(name) {
|
|
72
|
+
const found = this.servers?.find((candidate) => candidate.name === name);
|
|
73
|
+
if (!found) {
|
|
74
|
+
const served = this.servers?.map((each) => each.name).join(', ') || 'none';
|
|
75
|
+
throw new TypeError(`The ${this.id} service serves no MCP server named ${JSON.stringify(name)}. It serves ${served}.`);
|
|
46
76
|
}
|
|
77
|
+
return { url: found.url, headers: { ...this.headers } };
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function baseUrl(url) {
|
|
81
|
+
const base = URL.canParse(url) ? new URL(url) : null;
|
|
82
|
+
if (!base || !/^https?:$/.test(base.protocol) || base.search || base.hash) {
|
|
83
|
+
throw new TypeError('The api service url is not a plain http(s) URL.');
|
|
47
84
|
}
|
|
48
|
-
if (!
|
|
49
|
-
|
|
85
|
+
if (!base.pathname.endsWith('/')) {
|
|
86
|
+
base.pathname += '/';
|
|
50
87
|
}
|
|
51
|
-
return
|
|
52
|
-
? { name: 'Authorization', value: `Bearer ${token}` }
|
|
53
|
-
: { name: match.actorHeader, value: token };
|
|
88
|
+
return base;
|
|
54
89
|
}
|
|
55
90
|
function resolve(base, path) {
|
|
56
91
|
const pathPart = path.split(/[?#]/, 1)[0] ?? '';
|
|
@@ -9,7 +9,7 @@ import type { Credentials } from './credentials.js';
|
|
|
9
9
|
export type Environment = EnvironmentData & EnvironmentHelpers;
|
|
10
10
|
export interface EnvironmentHelpers {
|
|
11
11
|
/** Credentials for one app; `actorId` defaults to the app's default actor. */
|
|
12
|
-
connect(
|
|
12
|
+
connect(appName: string, options?: ConnectOptions): Promise<Credentials>;
|
|
13
13
|
delete(options?: SignalOptions): Promise<Environment>;
|
|
14
14
|
/** Reads the environment again. */
|
|
15
15
|
refresh(): Promise<Environment>;
|
package/esm/extensions/errors.js
CHANGED
|
@@ -48,7 +48,7 @@ export class EnvironmentFailedError extends StateMachinesError {
|
|
|
48
48
|
super({
|
|
49
49
|
...noResponse,
|
|
50
50
|
message: failure
|
|
51
|
-
? `Environment ${environment.id} failed: ${failure.message} (${failure.code}, app ${failure.
|
|
51
|
+
? `Environment ${environment.id} failed: ${failure.message} (${failure.code}, app ${failure.appName}).`
|
|
52
52
|
: `Environment ${environment.id} failed.`,
|
|
53
53
|
});
|
|
54
54
|
this.environment = environment;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export type { Actor,
|
|
1
|
+
export type { Actor, App, AppEntry, AuditEvent, BodyPreview, CreateEnvironment, CreateEnvironmentApp, EnvironmentApp, EnvironmentFailure, EnvironmentFailureCode, EnvironmentStatus, ErrorCode, Me, Permission, Principal, RequestDetail, RequestStats, RequestT as Request, Snapshot, SnapshotStatus, Version, Workspace, } from '../models/index.js';
|
|
2
2
|
export type { ConnectOptions, CreateEnvironmentOptions, CreateSnapshotOptions, ListAuditEventsQuery, ListEnvironmentsQuery, ListRequestsQuery, ListSnapshotsQuery, ListWorkspacesQuery, Page, PageQuery, RequestStatsQuery, SignalOptions, StateMachinesOptions, } from './client.js';
|
|
3
3
|
export { StateMachines } from './client.js';
|
|
4
|
-
export type { Credentials } from './credentials.js';
|
|
4
|
+
export type { Credentials, McpServerCredentials, ServiceCredentials, } from './credentials.js';
|
|
5
5
|
export type { Environment, EnvironmentHelpers } from './environment.js';
|
|
6
6
|
export { EnvironmentFailedError, SnapshotFailedError, StateMachinesError, UnexpectedStatusError, WaitTimeoutError, } from './errors.js';
|
|
7
7
|
export type { WaitOptions } from './wait.js';
|
package/esm/extensions/yaml.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isAlias, isScalar, parseDocument, visit } from 'yaml';
|
|
2
2
|
import { invalidInput } from './errors.js';
|
|
3
|
-
const APP_FIELDS = new Set(['
|
|
3
|
+
const APP_FIELDS = new Set(['appId', 'name', 'setup', 'services']);
|
|
4
4
|
/**
|
|
5
5
|
* Parses a YAML document with the fields of `CreateEnvironment`. The SDK checks the shape;
|
|
6
6
|
* the API checks the values. Anchors, aliases, tags and duplicate keys are refused.
|
|
@@ -97,8 +97,8 @@ export function parseEnvironmentYaml(text) {
|
|
|
97
97
|
add(key, 'Unknown field.');
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
|
-
if ('apps' in value
|
|
101
|
-
add('$', '
|
|
100
|
+
if (!('apps' in value) && !('snapshotId' in value)) {
|
|
101
|
+
add('$', 'Send apps, snapshotId or both.');
|
|
102
102
|
}
|
|
103
103
|
if (Object.keys(fields).length > 0) {
|
|
104
104
|
throw bad(fields);
|
|
@@ -110,22 +110,24 @@ function checkApp(app, path, add) {
|
|
|
110
110
|
return;
|
|
111
111
|
}
|
|
112
112
|
if (!isRecord(app)) {
|
|
113
|
-
add(path, 'Expected an app ID or a mapping with
|
|
113
|
+
add(path, 'Expected an app ID or a mapping with appId.');
|
|
114
114
|
return;
|
|
115
115
|
}
|
|
116
|
-
const {
|
|
117
|
-
if (typeof
|
|
118
|
-
add(`${path}.
|
|
116
|
+
const { appId, name } = app;
|
|
117
|
+
if (typeof appId !== 'string') {
|
|
118
|
+
add(`${path}.appId`, 'Expected a string.');
|
|
119
119
|
}
|
|
120
120
|
if ('name' in app && typeof name !== 'string') {
|
|
121
121
|
add(`${path}.name`, 'Expected a string.');
|
|
122
122
|
}
|
|
123
|
-
|
|
124
|
-
|
|
123
|
+
for (const field of ['setup', 'services']) {
|
|
124
|
+
if (field in app && !isRecord(app[field])) {
|
|
125
|
+
add(`${path}.${field}`, 'Expected a mapping.');
|
|
126
|
+
}
|
|
125
127
|
}
|
|
126
|
-
for (const
|
|
127
|
-
if (!APP_FIELDS.has(
|
|
128
|
-
add(`${path}.${
|
|
128
|
+
for (const field of Object.keys(app)) {
|
|
129
|
+
if (!APP_FIELDS.has(field)) {
|
|
130
|
+
add(`${path}.${field}`, 'Unknown field.');
|
|
129
131
|
}
|
|
130
132
|
}
|
|
131
133
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { StateMachinesCore } from "../core.js";
|
|
2
|
+
import { RequestOptions } from "../lib/sdks.js";
|
|
3
|
+
import { ConnectionError, InvalidRequestError, RequestAbortedError, RequestTimeoutError, UnexpectedClientError } from "../models/errors/http-client-errors.js";
|
|
4
|
+
import * as errors from "../models/errors/index.js";
|
|
5
|
+
import { ResponseValidationError } from "../models/errors/response-validation-error.js";
|
|
6
|
+
import { SDKValidationError } from "../models/errors/sdk-validation-error.js";
|
|
7
|
+
import { StateMachinesHTTPError } from "../models/errors/state-machines-http-error.js";
|
|
8
|
+
import * as operations from "../models/operations/index.js";
|
|
9
|
+
import { APIPromise } from "../types/async.js";
|
|
10
|
+
import { Result } from "../types/fp.js";
|
|
11
|
+
export declare function environmentsCreators(client: StateMachinesCore, request?: operations.ListEnvironmentCreatorsRequest | undefined, options?: RequestOptions): APIPromise<Result<operations.ListEnvironmentCreatorsResponse, errors.ErrorT | StateMachinesHTTPError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
import * as z from "zod/v4-mini";
|
|
5
|
+
import { encodeFormQuery } from "../lib/encodings.js";
|
|
6
|
+
import { matchStatusCode } from "../lib/http.js";
|
|
7
|
+
import * as M from "../lib/matchers.js";
|
|
8
|
+
import { compactMap } from "../lib/primitives.js";
|
|
9
|
+
import { safeParse } from "../lib/schemas.js";
|
|
10
|
+
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
11
|
+
import { pathToFunc } from "../lib/url.js";
|
|
12
|
+
import * as errors from "../models/errors/index.js";
|
|
13
|
+
import * as operations from "../models/operations/index.js";
|
|
14
|
+
import { APIPromise } from "../types/async.js";
|
|
15
|
+
export function environmentsCreators(client, request, options) {
|
|
16
|
+
return new APIPromise($do(client, request, options));
|
|
17
|
+
}
|
|
18
|
+
async function $do(client, request, options) {
|
|
19
|
+
const parsed = safeParse(request, (value) => z.parse(z.optional(operations.ListEnvironmentCreatorsRequest$outboundSchema), value), "Input validation failed");
|
|
20
|
+
if (!parsed.ok) {
|
|
21
|
+
return [parsed, { status: "invalid" }];
|
|
22
|
+
}
|
|
23
|
+
const payload = parsed.value;
|
|
24
|
+
const body = null;
|
|
25
|
+
const path = pathToFunc("/v1/environments/creators")();
|
|
26
|
+
const query = encodeFormQuery({
|
|
27
|
+
"workspaceId": payload?.workspaceId,
|
|
28
|
+
});
|
|
29
|
+
const headers = new Headers(compactMap({
|
|
30
|
+
Accept: "application/json",
|
|
31
|
+
}));
|
|
32
|
+
const secConfig = await extractSecurity(client._options.apiKey);
|
|
33
|
+
const securityInput = secConfig == null ? {} : { apiKey: secConfig };
|
|
34
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
35
|
+
const context = {
|
|
36
|
+
options: client._options,
|
|
37
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
38
|
+
operationID: "listEnvironmentCreators",
|
|
39
|
+
oAuth2Scopes: null,
|
|
40
|
+
resolvedSecurity: requestSecurity,
|
|
41
|
+
securitySource: client._options.apiKey,
|
|
42
|
+
retryConfig: options?.retries
|
|
43
|
+
|| client._options.retryConfig
|
|
44
|
+
|| {
|
|
45
|
+
strategy: "backoff",
|
|
46
|
+
backoff: {
|
|
47
|
+
initialInterval: 1000,
|
|
48
|
+
maxInterval: 5000,
|
|
49
|
+
exponent: 1.5,
|
|
50
|
+
maxElapsedTime: 600000,
|
|
51
|
+
},
|
|
52
|
+
retryConnectionErrors: true,
|
|
53
|
+
}
|
|
54
|
+
|| { strategy: "none" },
|
|
55
|
+
retryCodes: options?.retryCodes || ["502", "503", "504"],
|
|
56
|
+
};
|
|
57
|
+
const requestRes = client._createRequest(context, {
|
|
58
|
+
security: requestSecurity,
|
|
59
|
+
method: "GET",
|
|
60
|
+
baseURL: options?.serverURL,
|
|
61
|
+
path: path,
|
|
62
|
+
headers: headers,
|
|
63
|
+
query: query,
|
|
64
|
+
body: body,
|
|
65
|
+
userAgent: client._options.userAgent,
|
|
66
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
67
|
+
}, options);
|
|
68
|
+
if (!requestRes.ok) {
|
|
69
|
+
return [requestRes, { status: "invalid" }];
|
|
70
|
+
}
|
|
71
|
+
const req = requestRes.value;
|
|
72
|
+
const doResult = await client._do(req, {
|
|
73
|
+
context,
|
|
74
|
+
isErrorStatusCode: (statusCode) => matchStatusCode({ status: statusCode }, ["4XX", "5XX"]),
|
|
75
|
+
retryConfig: context.retryConfig,
|
|
76
|
+
retryCodes: context.retryCodes,
|
|
77
|
+
});
|
|
78
|
+
if (!doResult.ok) {
|
|
79
|
+
return [doResult, { status: "request-error", request: req }];
|
|
80
|
+
}
|
|
81
|
+
const response = doResult.value;
|
|
82
|
+
const responseFields = {
|
|
83
|
+
HttpMeta: { Response: response, Request: req },
|
|
84
|
+
};
|
|
85
|
+
const [result] = await M.match(M.json(200, operations.ListEnvironmentCreatorsResponse$inboundSchema), M.jsonErr([400, 401, 403, 404, 409, 413, 422, 429], errors.ErrorT$inboundSchema), M.jsonErr([500, 503], errors.ErrorT$inboundSchema), M.fail("4XX"), M.fail("5XX"))(response, req, { extraFields: responseFields });
|
|
86
|
+
if (!result.ok) {
|
|
87
|
+
return [result, { status: "complete", request: req, response }];
|
|
88
|
+
}
|
|
89
|
+
return [result, { status: "complete", request: req, response }];
|
|
90
|
+
}
|
|
@@ -24,6 +24,8 @@ async function $do(client, request, options) {
|
|
|
24
24
|
const body = null;
|
|
25
25
|
const path = pathToFunc("/v1/environments")();
|
|
26
26
|
const query = encodeFormQuery({
|
|
27
|
+
"appId": payload?.appId,
|
|
28
|
+
"createdBy": payload?.createdBy,
|
|
27
29
|
"cursor": payload?.cursor,
|
|
28
30
|
"label": payload?.label,
|
|
29
31
|
"limit": payload?.limit,
|
|
@@ -24,16 +24,20 @@ async function $do(client, request, options) {
|
|
|
24
24
|
const body = null;
|
|
25
25
|
const path = pathToFunc("/v1/requests")();
|
|
26
26
|
const query = encodeFormQuery({
|
|
27
|
-
"
|
|
27
|
+
"appName": payload.appName,
|
|
28
28
|
"cursor": payload.cursor,
|
|
29
29
|
"environmentId": payload.environmentId,
|
|
30
30
|
"from": payload.from,
|
|
31
31
|
"limit": payload.limit,
|
|
32
|
+
"mcpServer": payload.mcpServer,
|
|
32
33
|
"method": payload.method,
|
|
34
|
+
"operation": payload.operation,
|
|
33
35
|
"responseStatus": payload.responseStatus,
|
|
34
36
|
"search": payload.search,
|
|
37
|
+
"service": payload.service,
|
|
35
38
|
"statusClass": payload.statusClass,
|
|
36
39
|
"to": payload.to,
|
|
40
|
+
"tool": payload.tool,
|
|
37
41
|
"writesOnly": payload.writesOnly,
|
|
38
42
|
});
|
|
39
43
|
const headers = new Headers(compactMap({
|
|
@@ -25,14 +25,18 @@ async function $do(client, request, options) {
|
|
|
25
25
|
const body = null;
|
|
26
26
|
const path = pathToFunc("/v1/requests/stats")();
|
|
27
27
|
const query = encodeFormQuery({
|
|
28
|
-
"
|
|
28
|
+
"appName": payload.appName,
|
|
29
29
|
"environmentId": payload.environmentId,
|
|
30
30
|
"from": payload.from,
|
|
31
|
+
"mcpServer": payload.mcpServer,
|
|
31
32
|
"method": payload.method,
|
|
33
|
+
"operation": payload.operation,
|
|
32
34
|
"responseStatus": payload.responseStatus,
|
|
33
35
|
"search": payload.search,
|
|
36
|
+
"service": payload.service,
|
|
34
37
|
"statusClass": payload.statusClass,
|
|
35
38
|
"to": payload.to,
|
|
39
|
+
"tool": payload.tool,
|
|
36
40
|
"writesOnly": payload.writesOnly,
|
|
37
41
|
});
|
|
38
42
|
const headers = new Headers(compactMap({
|
package/esm/lib/config.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export declare function serverURLFromOptions(options: SDKOptions): URL | null;
|
|
|
31
31
|
export declare const SDK_METADATA: {
|
|
32
32
|
readonly language: "typescript";
|
|
33
33
|
readonly openapiDocVersion: "1.0.0";
|
|
34
|
-
readonly sdkVersion: "0.
|
|
34
|
+
readonly sdkVersion: "0.8.0";
|
|
35
35
|
readonly genVersion: "2.941.0";
|
|
36
|
-
readonly userAgent: "speakeasy-sdk/typescript 0.
|
|
36
|
+
readonly userAgent: "speakeasy-sdk/typescript 0.8.0 2.941.0 1.0.0 @usestatemachines/sdk";
|
|
37
37
|
};
|
package/esm/lib/config.js
CHANGED
|
@@ -24,7 +24,7 @@ export function serverURLFromOptions(options) {
|
|
|
24
24
|
export const SDK_METADATA = {
|
|
25
25
|
language: "typescript",
|
|
26
26
|
openapiDocVersion: "1.0.0",
|
|
27
|
-
sdkVersion: "0.
|
|
27
|
+
sdkVersion: "0.8.0",
|
|
28
28
|
genVersion: "2.941.0",
|
|
29
|
-
userAgent: "speakeasy-sdk/typescript 0.
|
|
29
|
+
userAgent: "speakeasy-sdk/typescript 0.8.0 2.941.0 1.0.0 @usestatemachines/sdk",
|
|
30
30
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as z from "zod/v4-mini";
|
|
2
|
+
import { CreateEnvironmentApp, CreateEnvironmentApp$Outbound } from "./create-environment-app.js";
|
|
3
|
+
export type AppEntry = CreateEnvironmentApp | string;
|
|
4
|
+
/** @internal */
|
|
5
|
+
export type AppEntry$Outbound = CreateEnvironmentApp$Outbound | string;
|
|
6
|
+
/** @internal */
|
|
7
|
+
export declare const AppEntry$outboundSchema: z.ZodMiniType<AppEntry$Outbound, AppEntry>;
|
|
8
|
+
export declare function appEntryToJSON(appEntry: AppEntry): string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
import * as z from "zod/v4-mini";
|
|
5
|
+
import { smartUnion } from "../types/smart-union.js";
|
|
6
|
+
import { CreateEnvironmentApp$outboundSchema, } from "./create-environment-app.js";
|
|
7
|
+
/** @internal */
|
|
8
|
+
export const AppEntry$outboundSchema = smartUnion([CreateEnvironmentApp$outboundSchema, z.string()]);
|
|
9
|
+
export function appEntryToJSON(appEntry) {
|
|
10
|
+
return JSON.stringify(AppEntry$outboundSchema.parse(appEntry));
|
|
11
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as z from "zod/v4-mini";
|
|
2
|
+
export type CreateEnvironmentApp = {
|
|
3
|
+
appId: string;
|
|
4
|
+
name?: string | undefined;
|
|
5
|
+
services?: {
|
|
6
|
+
[k: string]: any;
|
|
7
|
+
} | undefined;
|
|
8
|
+
setup?: {
|
|
9
|
+
[k: string]: any;
|
|
10
|
+
} | undefined;
|
|
11
|
+
};
|
|
12
|
+
/** @internal */
|
|
13
|
+
export type CreateEnvironmentApp$Outbound = {
|
|
14
|
+
appId: string;
|
|
15
|
+
name?: string | undefined;
|
|
16
|
+
services?: {
|
|
17
|
+
[k: string]: any;
|
|
18
|
+
} | undefined;
|
|
19
|
+
setup?: {
|
|
20
|
+
[k: string]: any;
|
|
21
|
+
} | undefined;
|
|
22
|
+
};
|
|
23
|
+
/** @internal */
|
|
24
|
+
export declare const CreateEnvironmentApp$outboundSchema: z.ZodMiniType<CreateEnvironmentApp$Outbound, CreateEnvironmentApp>;
|
|
25
|
+
export declare function createEnvironmentAppToJSON(createEnvironmentApp: CreateEnvironmentApp): string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
import * as z from "zod/v4-mini";
|
|
5
|
+
/** @internal */
|
|
6
|
+
export const CreateEnvironmentApp$outboundSchema = z.object({
|
|
7
|
+
appId: z.string(),
|
|
8
|
+
name: z.optional(z.string()),
|
|
9
|
+
services: z.optional(z.record(z.string(), z.any())),
|
|
10
|
+
setup: z.optional(z.record(z.string(), z.any())),
|
|
11
|
+
});
|
|
12
|
+
export function createEnvironmentAppToJSON(createEnvironmentApp) {
|
|
13
|
+
return JSON.stringify(CreateEnvironmentApp$outboundSchema.parse(createEnvironmentApp));
|
|
14
|
+
}
|
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
import * as z from "zod/v4-mini";
|
|
2
|
-
|
|
3
|
-
app: string;
|
|
4
|
-
name?: string | undefined;
|
|
5
|
-
settings?: {
|
|
6
|
-
[k: string]: any;
|
|
7
|
-
} | undefined;
|
|
8
|
-
};
|
|
9
|
-
export type AppUnion = CreateEnvironmentApp | string;
|
|
2
|
+
import { AppEntry, AppEntry$Outbound } from "./app-entry.js";
|
|
10
3
|
export type CreateEnvironment = {
|
|
11
|
-
apps?: Array<
|
|
4
|
+
apps?: Array<AppEntry> | undefined;
|
|
12
5
|
labels?: {
|
|
13
6
|
[k: string]: string;
|
|
14
7
|
} | undefined;
|
|
@@ -19,24 +12,8 @@ export type CreateEnvironment = {
|
|
|
19
12
|
workspaceId?: string | undefined;
|
|
20
13
|
};
|
|
21
14
|
/** @internal */
|
|
22
|
-
export type CreateEnvironmentApp$Outbound = {
|
|
23
|
-
app: string;
|
|
24
|
-
name?: string | undefined;
|
|
25
|
-
settings?: {
|
|
26
|
-
[k: string]: any;
|
|
27
|
-
} | undefined;
|
|
28
|
-
};
|
|
29
|
-
/** @internal */
|
|
30
|
-
export declare const CreateEnvironmentApp$outboundSchema: z.ZodMiniType<CreateEnvironmentApp$Outbound, CreateEnvironmentApp>;
|
|
31
|
-
export declare function createEnvironmentAppToJSON(createEnvironmentApp: CreateEnvironmentApp): string;
|
|
32
|
-
/** @internal */
|
|
33
|
-
export type AppUnion$Outbound = CreateEnvironmentApp$Outbound | string;
|
|
34
|
-
/** @internal */
|
|
35
|
-
export declare const AppUnion$outboundSchema: z.ZodMiniType<AppUnion$Outbound, AppUnion>;
|
|
36
|
-
export declare function appUnionToJSON(appUnion: AppUnion): string;
|
|
37
|
-
/** @internal */
|
|
38
15
|
export type CreateEnvironment$Outbound = {
|
|
39
|
-
apps?: Array<
|
|
16
|
+
apps?: Array<AppEntry$Outbound> | undefined;
|
|
40
17
|
labels?: {
|
|
41
18
|
[k: string]: string;
|
|
42
19
|
} | undefined;
|
|
@@ -2,27 +2,10 @@
|
|
|
2
2
|
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
3
|
*/
|
|
4
4
|
import * as z from "zod/v4-mini";
|
|
5
|
-
import {
|
|
6
|
-
/** @internal */
|
|
7
|
-
export const CreateEnvironmentApp$outboundSchema = z.object({
|
|
8
|
-
app: z.string(),
|
|
9
|
-
name: z.optional(z.string()),
|
|
10
|
-
settings: z.optional(z.record(z.string(), z.any())),
|
|
11
|
-
});
|
|
12
|
-
export function createEnvironmentAppToJSON(createEnvironmentApp) {
|
|
13
|
-
return JSON.stringify(CreateEnvironmentApp$outboundSchema.parse(createEnvironmentApp));
|
|
14
|
-
}
|
|
15
|
-
/** @internal */
|
|
16
|
-
export const AppUnion$outboundSchema = smartUnion([z.lazy(() => CreateEnvironmentApp$outboundSchema), z.string()]);
|
|
17
|
-
export function appUnionToJSON(appUnion) {
|
|
18
|
-
return JSON.stringify(AppUnion$outboundSchema.parse(appUnion));
|
|
19
|
-
}
|
|
5
|
+
import { AppEntry$outboundSchema, } from "./app-entry.js";
|
|
20
6
|
/** @internal */
|
|
21
7
|
export const CreateEnvironment$outboundSchema = z.object({
|
|
22
|
-
apps: z.optional(z.array(
|
|
23
|
-
z.lazy(() => CreateEnvironmentApp$outboundSchema),
|
|
24
|
-
z.string(),
|
|
25
|
-
]))),
|
|
8
|
+
apps: z.optional(z.array(AppEntry$outboundSchema)),
|
|
26
9
|
labels: z.optional(z.record(z.string(), z.string())),
|
|
27
10
|
name: z.optional(z.nullable(z.string())),
|
|
28
11
|
snapshotId: z.optional(z.string()),
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import * as z from "zod/v4-mini";
|
|
2
|
+
import * as discriminatedUnionTypes from "../types/discriminated-union.js";
|
|
3
|
+
import { OpenEnum } from "../types/enums.js";
|
|
4
|
+
import { Result as SafeParseResult } from "../types/fp.js";
|
|
5
|
+
import { SDKValidationError } from "./errors/sdk-validation-error.js";
|
|
6
|
+
export declare const ApiKeyKind: {
|
|
7
|
+
readonly Dashboard: "dashboard";
|
|
8
|
+
readonly CliRun: "cli_run";
|
|
9
|
+
readonly EnvPull: "env_pull";
|
|
10
|
+
};
|
|
11
|
+
export type ApiKeyKind = OpenEnum<typeof ApiKeyKind>;
|
|
12
|
+
export type CredentialAPIKey = {
|
|
13
|
+
apiKeyKind: ApiKeyKind;
|
|
14
|
+
expiresAt: Date | null;
|
|
15
|
+
id: string;
|
|
16
|
+
idleExpiresAt: any | null;
|
|
17
|
+
kind: "api_key";
|
|
18
|
+
name: string;
|
|
19
|
+
};
|
|
20
|
+
export type CredentialCliToken = {
|
|
21
|
+
apiKeyKind: any | null;
|
|
22
|
+
expiresAt: Date;
|
|
23
|
+
id: string;
|
|
24
|
+
idleExpiresAt: Date;
|
|
25
|
+
kind: "cli_token";
|
|
26
|
+
name: string;
|
|
27
|
+
};
|
|
28
|
+
export type CredentialSession = {
|
|
29
|
+
apiKeyKind: any | null;
|
|
30
|
+
expiresAt: Date;
|
|
31
|
+
id: string;
|
|
32
|
+
idleExpiresAt: any | null;
|
|
33
|
+
kind: "session";
|
|
34
|
+
name: any | null;
|
|
35
|
+
};
|
|
36
|
+
export type Credential = CredentialSession | CredentialCliToken | CredentialAPIKey | discriminatedUnionTypes.Unknown<"kind">;
|
|
37
|
+
/** @internal */
|
|
38
|
+
export declare const ApiKeyKind$inboundSchema: z.ZodMiniType<ApiKeyKind, unknown>;
|
|
39
|
+
/** @internal */
|
|
40
|
+
export declare const CredentialAPIKey$inboundSchema: z.ZodMiniType<CredentialAPIKey, unknown>;
|
|
41
|
+
export declare function credentialAPIKeyFromJSON(jsonString: string): SafeParseResult<CredentialAPIKey, SDKValidationError>;
|
|
42
|
+
/** @internal */
|
|
43
|
+
export declare const CredentialCliToken$inboundSchema: z.ZodMiniType<CredentialCliToken, unknown>;
|
|
44
|
+
export declare function credentialCliTokenFromJSON(jsonString: string): SafeParseResult<CredentialCliToken, SDKValidationError>;
|
|
45
|
+
/** @internal */
|
|
46
|
+
export declare const CredentialSession$inboundSchema: z.ZodMiniType<CredentialSession, unknown>;
|
|
47
|
+
export declare function credentialSessionFromJSON(jsonString: string): SafeParseResult<CredentialSession, SDKValidationError>;
|
|
48
|
+
/** @internal */
|
|
49
|
+
export declare const Credential$inboundSchema: z.ZodMiniType<Credential, unknown>;
|
|
50
|
+
export declare function credentialFromJSON(jsonString: string): SafeParseResult<Credential, SDKValidationError>;
|