@usestatemachines/sdk 0.4.0 → 0.6.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 +177 -470
- package/agents/SKILL.md +38 -47
- package/agents/index.js +7 -7
- package/agents/llms.txt +49 -45
- package/agents/prompt.md +11 -11
- package/esm/extensions/client.d.ts +105 -116
- package/esm/extensions/client.js +162 -309
- package/esm/extensions/credentials.d.ts +13 -0
- package/esm/extensions/credentials.js +73 -0
- package/esm/extensions/environment.d.ts +25 -0
- package/esm/extensions/environment.js +1 -0
- package/esm/extensions/errors.d.ts +42 -75
- package/esm/extensions/errors.js +125 -110
- package/esm/extensions/index.d.ts +6 -11
- package/esm/extensions/index.js +2 -7
- package/esm/extensions/wait.d.ts +17 -18
- package/esm/extensions/wait.js +60 -56
- package/esm/extensions/yaml.d.ts +6 -0
- package/esm/extensions/yaml.js +137 -0
- package/esm/funcs/{catalog-release.d.ts → apps-list.d.ts} +1 -1
- package/esm/funcs/apps-list.js +91 -0
- package/esm/funcs/{credential-get.d.ts → apps-versions.d.ts} +1 -1
- package/esm/funcs/{workspaces-events.js → apps-versions.js} +6 -7
- package/esm/funcs/{environments-get-connection.d.ts → audit-events-list.d.ts} +1 -1
- package/esm/funcs/audit-events-list.js +93 -0
- package/esm/funcs/{workspaces-events.d.ts → environments-connect.d.ts} +1 -1
- package/esm/funcs/{environments-reveal.js → environments-connect.js} +7 -6
- package/esm/funcs/environments-create.d.ts +2 -1
- package/esm/funcs/environments-create.js +5 -10
- package/esm/funcs/{environments-events.d.ts → environments-delete.d.ts} +1 -1
- package/esm/funcs/{environments-stop.js → environments-delete.js} +8 -6
- package/esm/funcs/environments-get.d.ts +2 -1
- package/esm/funcs/environments-get.js +2 -1
- package/esm/funcs/environments-list.d.ts +1 -1
- package/esm/funcs/environments-list.js +11 -16
- package/esm/funcs/environments-pause.d.ts +12 -0
- package/esm/funcs/{environments-suspend.js → environments-pause.js} +7 -5
- package/esm/funcs/environments-resume.d.ts +2 -1
- package/esm/funcs/environments-resume.js +3 -1
- package/esm/funcs/environments-update.d.ts +12 -0
- package/esm/funcs/{get-environment-position.js → environments-update.js} +10 -8
- package/esm/funcs/me.d.ts +11 -0
- package/esm/funcs/{catalog-get.js → me.js} +5 -5
- package/esm/funcs/{catalog-get.d.ts → requests-body.d.ts} +1 -1
- package/esm/funcs/{environments-get-connection.js → requests-body.js} +8 -8
- package/esm/funcs/requests-get.d.ts +12 -0
- package/esm/funcs/{catalog-release.js → requests-get.js} +7 -6
- package/esm/funcs/{environments-stop.d.ts → requests-list.d.ts} +1 -1
- package/esm/funcs/{list-environment-history.js → requests-list.js} +15 -12
- package/esm/funcs/requests-stats.d.ts +12 -0
- package/esm/funcs/{environments-events.js → requests-stats.js} +15 -14
- package/esm/funcs/snapshots-create.d.ts +12 -0
- package/esm/funcs/{snapshots-capture.js → snapshots-create.js} +6 -11
- package/esm/funcs/snapshots-delete.d.ts +2 -1
- package/esm/funcs/snapshots-delete.js +2 -1
- package/esm/funcs/snapshots-get.d.ts +2 -1
- package/esm/funcs/snapshots-get.js +2 -1
- package/esm/funcs/snapshots-list.d.ts +1 -1
- package/esm/funcs/snapshots-list.js +9 -13
- package/esm/funcs/snapshots-update.d.ts +2 -1
- package/esm/funcs/snapshots-update.js +2 -1
- package/esm/funcs/workspaces-get.d.ts +2 -1
- package/esm/funcs/workspaces-get.js +2 -1
- package/esm/funcs/workspaces-list.d.ts +1 -1
- package/esm/funcs/workspaces-list.js +3 -1
- package/esm/lib/config.d.ts +3 -3
- package/esm/lib/config.js +3 -3
- package/esm/models/actor.d.ts +2 -3
- package/esm/models/actor.js +2 -3
- package/esm/models/{api-profile.d.ts → api.d.ts} +4 -4
- package/esm/models/{api-profile.js → api.js} +4 -5
- package/esm/models/app.d.ts +9 -1
- package/esm/models/app.js +7 -1
- package/esm/models/{event.d.ts → audit-event.d.ts} +6 -6
- package/esm/models/{event.js → audit-event.js} +7 -6
- package/esm/models/body-preview.d.ts +31 -0
- package/esm/models/body-preview.js +34 -0
- package/esm/models/create-environment.d.ts +51 -0
- package/esm/models/create-environment.js +35 -0
- package/esm/models/credentials.d.ts +31 -0
- package/esm/models/credentials.js +31 -0
- package/esm/models/environment-failure.d.ts +22 -0
- package/esm/models/environment-failure.js +25 -0
- package/esm/models/environment-status.d.ts +14 -0
- package/esm/models/environment-status.js +15 -0
- package/esm/models/environment.d.ts +27 -27
- package/esm/models/environment.js +28 -27
- package/esm/models/error.d.ts +38 -0
- package/esm/models/error.js +39 -0
- package/esm/models/errors/{error-response.d.ts → error.d.ts} +5 -5
- package/esm/models/errors/{error-response.js → error.js} +4 -4
- package/esm/models/errors/index.d.ts +1 -1
- package/esm/models/errors/index.js +1 -1
- package/esm/models/index.d.ts +17 -22
- package/esm/models/index.js +17 -22
- package/esm/models/me.d.ts +66 -0
- package/esm/models/me.js +75 -0
- package/esm/models/operations/create-credentials.d.ts +25 -0
- package/esm/models/operations/create-credentials.js +20 -0
- package/esm/models/operations/create-environment.d.ts +14 -0
- package/esm/models/operations/create-environment.js +18 -0
- package/esm/models/operations/create-snapshot.d.ts +25 -0
- package/esm/models/operations/create-snapshot.js +25 -0
- package/esm/models/operations/delete-environment.d.ts +13 -0
- package/esm/models/operations/delete-environment.js +17 -0
- package/esm/models/operations/delete-snapshot.d.ts +0 -12
- package/esm/models/operations/delete-snapshot.js +0 -9
- package/esm/models/operations/get-environment.d.ts +0 -12
- package/esm/models/operations/get-environment.js +0 -9
- package/esm/models/operations/get-request-body.d.ts +21 -0
- package/esm/models/operations/get-request-body.js +18 -0
- package/esm/models/operations/get-request-stats.d.ts +51 -0
- package/esm/models/operations/get-request-stats.js +40 -0
- package/esm/models/operations/get-request.d.ts +11 -0
- package/esm/models/operations/get-request.js +11 -0
- package/esm/models/operations/get-snapshot.d.ts +0 -12
- package/esm/models/operations/get-snapshot.js +0 -9
- package/esm/models/operations/get-workspace.d.ts +0 -12
- package/esm/models/operations/get-workspace.js +0 -9
- package/esm/models/operations/index.d.ts +13 -15
- package/esm/models/operations/index.js +13 -15
- package/esm/models/operations/list-apps.d.ts +26 -0
- package/esm/models/operations/list-apps.js +23 -0
- package/esm/models/operations/list-audit-events.d.ts +30 -0
- package/esm/models/operations/list-audit-events.js +25 -0
- package/esm/models/operations/list-environments.d.ts +6 -21
- package/esm/models/operations/list-environments.js +3 -16
- package/esm/models/operations/list-requests.d.ts +68 -0
- package/esm/models/operations/list-requests.js +53 -0
- package/esm/models/operations/list-snapshots.d.ts +8 -6
- package/esm/models/operations/list-snapshots.js +4 -3
- package/esm/models/operations/list-versions.d.ts +28 -0
- package/esm/models/operations/list-versions.js +24 -0
- package/esm/models/operations/list-workspaces.d.ts +8 -4
- package/esm/models/operations/list-workspaces.js +7 -4
- package/esm/models/operations/pause-environment.d.ts +13 -0
- package/esm/models/operations/pause-environment.js +17 -0
- package/esm/models/operations/resume-environment.d.ts +2 -12
- package/esm/models/operations/resume-environment.js +8 -11
- package/esm/models/operations/update-environment.d.ts +29 -0
- package/esm/models/operations/update-environment.js +20 -0
- package/esm/models/operations/update-snapshot.d.ts +0 -14
- package/esm/models/operations/update-snapshot.js +0 -10
- package/esm/models/permission.d.ts +17 -0
- package/esm/models/permission.js +18 -0
- package/esm/models/principal.d.ts +20 -0
- package/esm/models/principal.js +24 -0
- package/esm/models/request-detail.d.ts +39 -0
- package/esm/models/request-detail.js +38 -0
- package/esm/models/request-stats.d.ts +26 -0
- package/esm/models/request-stats.js +31 -0
- package/esm/models/request.d.ts +30 -0
- package/esm/models/request.js +34 -0
- package/esm/models/snapshot-status.d.ts +13 -0
- package/esm/models/snapshot-status.js +14 -0
- package/esm/models/snapshot.d.ts +47 -0
- package/esm/models/snapshot.js +54 -0
- package/esm/models/version.d.ts +27 -0
- package/esm/models/version.js +31 -0
- package/esm/models/workspace.d.ts +2 -4
- package/esm/models/workspace.js +2 -4
- package/esm/sdk/apps.d.ts +6 -0
- package/esm/sdk/apps.js +15 -0
- package/esm/sdk/audit-events.d.ts +5 -0
- package/esm/sdk/audit-events.js +11 -0
- package/esm/sdk/environments.d.ts +8 -9
- package/esm/sdk/environments.js +19 -23
- package/esm/sdk/requests.d.ts +9 -0
- package/esm/sdk/requests.js +23 -0
- package/esm/sdk/sdk.d.ts +11 -11
- package/esm/sdk/sdk.js +16 -23
- package/esm/sdk/snapshots.d.ts +6 -5
- package/esm/sdk/snapshots.js +7 -7
- package/esm/sdk/workspaces.d.ts +1 -2
- package/esm/sdk/workspaces.js +0 -4
- package/esm/types/smart-union.js +1 -2
- package/openapi.json +1630 -2380
- package/package.json +15 -13
- package/esm/extensions/apps.d.ts +0 -18
- package/esm/extensions/apps.js +0 -39
- package/esm/extensions/connection.d.ts +0 -42
- package/esm/extensions/connection.js +0 -133
- package/esm/extensions/running-environment.d.ts +0 -46
- package/esm/extensions/running-environment.js +0 -66
- package/esm/funcs/create-environment-definition.d.ts +0 -11
- package/esm/funcs/create-environment-definition.js +0 -94
- package/esm/funcs/credential-get.js +0 -76
- package/esm/funcs/environments-reveal.d.ts +0 -11
- package/esm/funcs/environments-suspend.d.ts +0 -11
- package/esm/funcs/get-environment-exchange.d.ts +0 -11
- package/esm/funcs/get-environment-exchange.js +0 -96
- package/esm/funcs/get-environment-position.d.ts +0 -11
- package/esm/funcs/list-environment-history.d.ts +0 -11
- package/esm/funcs/snapshots-capture.d.ts +0 -11
- package/esm/models/app-instance-snapshot.d.ts +0 -15
- package/esm/models/app-instance-snapshot.js +0 -19
- package/esm/models/catalog.d.ts +0 -12
- package/esm/models/catalog.js +0 -15
- package/esm/models/connection-secret.d.ts +0 -30
- package/esm/models/connection-secret.js +0 -31
- package/esm/models/connection.d.ts +0 -40
- package/esm/models/connection.js +0 -44
- package/esm/models/create-environment-input.d.ts +0 -39
- package/esm/models/create-environment-input.js +0 -25
- package/esm/models/credential-kind.d.ts +0 -9
- package/esm/models/credential-kind.js +0 -10
- package/esm/models/credential.d.ts +0 -48
- package/esm/models/credential.js +0 -44
- package/esm/models/environment-app.d.ts +0 -53
- package/esm/models/environment-app.js +0 -57
- package/esm/models/environment-exchange.d.ts +0 -116
- package/esm/models/environment-exchange.js +0 -126
- package/esm/models/environment-lifetime.d.ts +0 -10
- package/esm/models/environment-lifetime.js +0 -14
- package/esm/models/environment-position.d.ts +0 -25
- package/esm/models/environment-position.js +0 -32
- package/esm/models/environment-snapshot.d.ts +0 -40
- package/esm/models/environment-snapshot.js +0 -42
- package/esm/models/error-response.d.ts +0 -58
- package/esm/models/error-response.js +0 -60
- package/esm/models/event-page.d.ts +0 -11
- package/esm/models/event-page.js +0 -16
- package/esm/models/history-body.d.ts +0 -28
- package/esm/models/history-body.js +0 -33
- package/esm/models/history-cause.d.ts +0 -48
- package/esm/models/history-cause.js +0 -63
- package/esm/models/history-position.d.ts +0 -11
- package/esm/models/history-position.js +0 -15
- package/esm/models/history-transaction.d.ts +0 -16
- package/esm/models/history-transaction.js +0 -20
- package/esm/models/operations/capture-snapshot.d.ts +0 -41
- package/esm/models/operations/capture-snapshot.js +0 -36
- package/esm/models/operations/create-environment-definition.d.ts +0 -225
- package/esm/models/operations/create-environment-definition.js +0 -149
- package/esm/models/operations/create-environments.d.ts +0 -27
- package/esm/models/operations/create-environments.js +0 -27
- package/esm/models/operations/get-catalog.d.ts +0 -13
- package/esm/models/operations/get-catalog.js +0 -13
- package/esm/models/operations/get-connection.d.ts +0 -25
- package/esm/models/operations/get-connection.js +0 -21
- package/esm/models/operations/get-credential.d.ts +0 -13
- package/esm/models/operations/get-credential.js +0 -13
- package/esm/models/operations/get-environment-exchange.d.ts +0 -25
- package/esm/models/operations/get-environment-exchange.js +0 -21
- package/esm/models/operations/get-environment-position.d.ts +0 -23
- package/esm/models/operations/get-environment-position.js +0 -20
- package/esm/models/operations/get-release.d.ts +0 -23
- package/esm/models/operations/get-release.js +0 -20
- package/esm/models/operations/list-environment-events.d.ts +0 -15
- package/esm/models/operations/list-environment-events.js +0 -13
- package/esm/models/operations/list-environment-history.d.ts +0 -28
- package/esm/models/operations/list-environment-history.js +0 -24
- package/esm/models/operations/list-workspace-events.d.ts +0 -15
- package/esm/models/operations/list-workspace-events.js +0 -13
- package/esm/models/operations/reveal-connection.d.ts +0 -59
- package/esm/models/operations/reveal-connection.js +0 -55
- package/esm/models/operations/stop-environment.d.ts +0 -23
- package/esm/models/operations/stop-environment.js +0 -20
- package/esm/models/operations/suspend-environment.d.ts +0 -23
- package/esm/models/operations/suspend-environment.js +0 -20
- package/esm/models/release-actor.d.ts +0 -11
- package/esm/models/release-actor.js +0 -15
- package/esm/models/release.d.ts +0 -37
- package/esm/models/release.js +0 -39
- package/esm/sdk/catalog.d.ts +0 -6
- package/esm/sdk/catalog.js +0 -15
- package/esm/sdk/credential.d.ts +0 -5
- package/esm/sdk/credential.js +0 -11
- package/esm/types/discriminated-union.d.ts +0 -24
- package/esm/types/discriminated-union.js +0 -60
package/agents/prompt.md
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
Set up State Machines so this project can run code against a disposable replica of a SaaS app, such as Salesforce. Follow these steps in order.
|
|
2
2
|
|
|
3
|
-
1. Install the SDK: `npm install @usestatemachines/sdk`. It is ESM only and runs on Node.js
|
|
4
|
-
2. Check that `
|
|
5
|
-
3. Save this quickstart unchanged as `state-quickstart.mts` and run `npx tsx state-quickstart.mts` to confirm the setup. It prints `200` and the org's limits:
|
|
3
|
+
1. Install the SDK: `npm install @usestatemachines/sdk`. It is ESM only and runs on Node.js, at the versions in its `engines` field, and on Cloudflare Workers, not in browsers.
|
|
4
|
+
2. Check that `STATEMACHINES_API_KEY` is set without printing it: `test -n "$STATEMACHINES_API_KEY"`. If it is missing, stop and ask me to set it; the SDK doesn't read `.env` files. In Cloudflare Workers, pass the key as `new StateMachines({ apiKey })`.
|
|
5
|
+
3. Save this quickstart unchanged as `state-quickstart.mts` and run `npx tsx state-quickstart.mts` to confirm the setup. It prints `200` and the Salesforce org's limits:
|
|
6
6
|
|
|
7
7
|
```ts
|
|
8
8
|
import { StateMachines } from '@usestatemachines/sdk';
|
|
9
9
|
|
|
10
|
-
const sm = new StateMachines(); // reads
|
|
11
|
-
const env = await sm.environments.
|
|
10
|
+
const sm = new StateMachines(); // reads STATEMACHINES_API_KEY
|
|
11
|
+
const env = await sm.environments.create({ apps: ['salesforce'] });
|
|
12
12
|
|
|
13
13
|
try {
|
|
14
|
-
const salesforce = await env.connect('salesforce'
|
|
14
|
+
const salesforce = await env.connect('salesforce');
|
|
15
15
|
const res = await salesforce.fetch('/services/data/v67.0/limits');
|
|
16
16
|
console.log(res.status, await res.json());
|
|
17
17
|
} finally {
|
|
18
|
-
await env.
|
|
18
|
+
await env.delete();
|
|
19
19
|
}
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
4. Adapt it to my task. Log `await sm.
|
|
23
|
-
5. Always call `env.
|
|
24
|
-
6. Never print, log or commit keys or tokens, including `
|
|
22
|
+
4. Adapt it to my task. Log `await sm.apps.list()` to find each app's ID, and `await sm.apps.versions(appId)` for the actors and APIs of its versions; don't guess IDs. Create only the apps the task needs; a string such as `'salesforce'` names the app and also becomes its name in the environment. `connect()` acts as the app's default actor, the Salesforce administrator; to act as another user, pass an `actorId` from the version's `actors`. To reuse seeded data, create a snapshot once with `await env.snapshots.create()`, then `sm.environments.create({ snapshotId })`.
|
|
23
|
+
5. Always call `env.delete()` in a `finally`; it deletes the environment and its data. If the start fails, the server deletes the environment itself and `create` throws `EnvironmentFailedError`. Pass your own `idempotencyKey` to `create`; if it throws with no response, call it again with the same input and key.
|
|
24
|
+
6. Never print, log or commit keys or tokens, including `credentials.token` and `credentials.headers`.
|
|
25
25
|
|
|
26
|
-
Read more: `node_modules/@usestatemachines/sdk/README.md`, https://
|
|
26
|
+
Read more: `node_modules/@usestatemachines/sdk/README.md`, https://app.usestatemachines.com/llms.txt and https://www.npmjs.com/package/@usestatemachines/sdk
|
|
@@ -1,149 +1,138 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
7
|
-
import type { EnvironmentSnapshot } from '../models/environment-snapshot.js';
|
|
8
|
-
import type { EventPage } from '../models/event-page.js';
|
|
9
|
-
import type { CaptureSnapshotRequestBody } from '../models/operations/capture-snapshot.js';
|
|
1
|
+
import type { App } from '../models/app.js';
|
|
2
|
+
import type { AuditEvent } from '../models/audit-event.js';
|
|
3
|
+
import type { CreateEnvironment } from '../models/create-environment.js';
|
|
4
|
+
import type { Me } from '../models/me.js';
|
|
5
|
+
import type { GetRequestStatsRequest } from '../models/operations/get-request-stats.js';
|
|
6
|
+
import type { ListAuditEventsRequest } from '../models/operations/list-audit-events.js';
|
|
10
7
|
import type { ListEnvironmentsRequest } from '../models/operations/list-environments.js';
|
|
8
|
+
import type { ListRequestsRequest } from '../models/operations/list-requests.js';
|
|
11
9
|
import type { ListSnapshotsRequest } from '../models/operations/list-snapshots.js';
|
|
12
10
|
import type { ListWorkspacesRequest } from '../models/operations/list-workspaces.js';
|
|
13
|
-
import type {
|
|
14
|
-
import type {
|
|
15
|
-
import type {
|
|
11
|
+
import type { UpdateEnvironmentRequestBody } from '../models/operations/update-environment.js';
|
|
12
|
+
import type { RequestT as Request } from '../models/request.js';
|
|
13
|
+
import type { RequestDetail } from '../models/request-detail.js';
|
|
14
|
+
import type { RequestStats } from '../models/request-stats.js';
|
|
15
|
+
import type { Snapshot } from '../models/snapshot.js';
|
|
16
|
+
import type { Version } from '../models/version.js';
|
|
16
17
|
import type { Workspace } from '../models/workspace.js';
|
|
17
|
-
import { type
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import { type WaitOptions } from './wait.js';
|
|
18
|
+
import { type Credentials } from './credentials.js';
|
|
19
|
+
import type { Environment } from './environment.js';
|
|
20
|
+
import { type KnownEnvironmentStatus, type KnownSnapshotStatus, type WaitOptions } from './wait.js';
|
|
21
21
|
export interface StateMachinesOptions {
|
|
22
|
-
/**
|
|
22
|
+
/** An API key or a member's access token. Defaults to `STATEMACHINES_API_KEY` where a `process` exists. */
|
|
23
23
|
apiKey?: string;
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
/** Defaults to `https://api.usestatemachines.com`. */
|
|
25
|
+
baseUrl?: string;
|
|
26
|
+
/** The workspace for calls that name none. Member tokens need it; an API key has its own. */
|
|
26
27
|
workspaceId?: string;
|
|
27
|
-
fetch?:
|
|
28
|
-
/**
|
|
29
|
-
|
|
30
|
-
/** Timeout for each attempt of a request; retries get a fresh one. */
|
|
31
|
-
timeoutMs?: number;
|
|
28
|
+
fetch?: typeof fetch;
|
|
29
|
+
/** Timeout of each HTTP attempt; a retry gets a fresh one. Defaults to 60 seconds. */
|
|
30
|
+
attemptTimeoutMs?: number;
|
|
32
31
|
}
|
|
33
|
-
export interface
|
|
32
|
+
export interface SignalOptions {
|
|
34
33
|
signal?: AbortSignal;
|
|
35
34
|
}
|
|
36
|
-
export interface
|
|
35
|
+
export interface CreateEnvironmentOptions extends SignalOptions {
|
|
36
|
+
/** Wait until the environment is `running`. Defaults to true. */
|
|
37
|
+
wait?: boolean;
|
|
38
|
+
/** Deadline for the wait. Defaults to 10 minutes. */
|
|
39
|
+
timeoutMs?: number;
|
|
40
|
+
/** A replay with the same key and input returns the same environment. Defaults to a new UUID. */
|
|
37
41
|
idempotencyKey?: string;
|
|
38
|
-
workspaceId?: string;
|
|
39
42
|
}
|
|
40
|
-
export
|
|
41
|
-
|
|
42
|
-
|
|
43
|
+
export interface ResumeOptions extends SignalOptions {
|
|
44
|
+
/** Wait until the environment is `running`. Defaults to true. */
|
|
45
|
+
wait?: boolean;
|
|
46
|
+
/** Deadline for the wait. Defaults to 10 minutes. */
|
|
47
|
+
timeoutMs?: number;
|
|
48
|
+
}
|
|
49
|
+
export type CreateSnapshotOptions = CreateEnvironmentOptions;
|
|
50
|
+
export interface ConnectOptions {
|
|
51
|
+
/** Defaults to the app's default actor (for Salesforce, the administrator). */
|
|
52
|
+
actorId?: string;
|
|
53
|
+
}
|
|
43
54
|
export interface Page<T> {
|
|
44
55
|
data: T[];
|
|
45
56
|
nextCursor: string | null;
|
|
46
57
|
}
|
|
47
|
-
export
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
export type CaptureInput = Omit<CaptureSnapshotRequestBody, 'environmentId'>;
|
|
52
|
-
/** `readyTimeoutMs` bounds the wait for `ready`, as in `start()`. */
|
|
53
|
-
export type CaptureOptions = StartOptions;
|
|
54
|
-
export type ListSnapshotsQuery = Omit<ListSnapshotsRequest, 'workspaceId'> & {
|
|
55
|
-
workspaceId?: string;
|
|
58
|
+
export type PageQuery = {
|
|
59
|
+
limit?: number;
|
|
60
|
+
cursor?: string;
|
|
56
61
|
};
|
|
57
|
-
export
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
export type ListEnvironmentsQuery = ListEnvironmentsRequest;
|
|
63
|
+
export type ListSnapshotsQuery = ListSnapshotsRequest;
|
|
64
|
+
export type ListAuditEventsQuery = ListAuditEventsRequest;
|
|
65
|
+
export type ListWorkspacesQuery = ListWorkspacesRequest;
|
|
66
|
+
export type ListRequestsQuery = ListRequestsRequest;
|
|
67
|
+
export type RequestStatsQuery = GetRequestStatsRequest;
|
|
63
68
|
export declare class StateMachines {
|
|
64
69
|
#private;
|
|
65
70
|
constructor(options?: StateMachinesOptions);
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
/** The caller: its principal, organization, workspace, permissions and limits. */
|
|
72
|
+
me(): Promise<Me>;
|
|
73
|
+
readonly apps: {
|
|
74
|
+
list: (query?: PageQuery) => Promise<Page<App>>;
|
|
75
|
+
/** Published versions, including retired ones. */
|
|
76
|
+
versions: (appId: string, query?: PageQuery) => Promise<Page<Version>>;
|
|
72
77
|
};
|
|
73
78
|
readonly workspaces: {
|
|
74
|
-
list: (query?: ListWorkspacesRequest
|
|
75
|
-
get: (workspaceId: string
|
|
76
|
-
events: (workspaceId: string, query?: {
|
|
77
|
-
limit?: number;
|
|
78
|
-
cursor?: string;
|
|
79
|
-
}, options?: CallOptions | undefined) => Promise<EventPage>;
|
|
79
|
+
list: (query?: ListWorkspacesRequest) => Promise<Page<Workspace>>;
|
|
80
|
+
get: (workspaceId: string) => Promise<Workspace>;
|
|
80
81
|
};
|
|
81
82
|
readonly environments: {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
/** Ends the environment and discards its data. Safe to repeat. */
|
|
96
|
-
stop: (environmentId: string, options?: CallOptions | undefined) => Promise<Environment>;
|
|
83
|
+
/** Creates an environment and, unless `wait` is false, waits until it is `running`. */
|
|
84
|
+
create: (input: CreateEnvironment, options?: CreateEnvironmentOptions) => Promise<Environment>;
|
|
85
|
+
/** Newest first. Leaves deleted environments out unless `status` asks for them. */
|
|
86
|
+
list: (query?: ListEnvironmentsRequest) => Promise<Page<Environment>>;
|
|
87
|
+
get: (environmentId: string) => Promise<Environment>;
|
|
88
|
+
/** `labels` replaces the whole map. */
|
|
89
|
+
update: (environmentId: string, body: UpdateEnvironmentRequestBody) => Promise<Environment>;
|
|
90
|
+
/** Takes effect when the API answers: the gateway refuses calls from then on. */
|
|
91
|
+
pause: (environmentId: string, options?: SignalOptions) => Promise<Environment>;
|
|
92
|
+
/** Resumes a paused or failed environment and, unless `wait` is false, waits until it is `running`. */
|
|
93
|
+
resume: (environmentId: string, options?: ResumeOptions) => Promise<Environment>;
|
|
94
|
+
/** Deletes the environment and its data. Safe to repeat. */
|
|
95
|
+
delete: (environmentId: string, options?: SignalOptions) => Promise<Environment>;
|
|
97
96
|
/**
|
|
98
|
-
*
|
|
99
|
-
*
|
|
97
|
+
* Resolves when the environment has `status`. Throws once it cannot get there without
|
|
98
|
+
* another call: `EnvironmentFailedError` if it failed, else `UnexpectedStatusError`.
|
|
100
99
|
*/
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
|
|
104
|
-
events: (environmentId: string, query?: {
|
|
105
|
-
limit?: number;
|
|
106
|
-
cursor?: string;
|
|
107
|
-
}, options?: CallOptions | undefined) => Promise<EventPage>;
|
|
108
|
-
/** The app's users, in the release's order. */
|
|
109
|
-
actors: (environmentId: string, appKey: string, options?: CallOptions | undefined) => Promise<ReleaseActor[]>;
|
|
110
|
-
getConnection: (environmentId: string, appKey: string, options?: CallOptions | undefined) => Promise<ConnectionDetails>;
|
|
111
|
-
reveal: (environmentId: string, appKey: string, actorId: string, options?: CallOptions | undefined) => Promise<ConnectionSecret>;
|
|
112
|
-
/** Resolves when the environment is running. Never suspends or stops it. */
|
|
113
|
-
waitUntilReady: (environmentId: string, options?: WaitOptions | undefined) => Promise<Environment>;
|
|
114
|
-
/** Resolves when the environment is suspended and can resume. */
|
|
115
|
-
waitUntilSuspended: (environmentId: string, options?: WaitOptions | undefined) => Promise<Environment>;
|
|
116
|
-
/** Resolves when the environment ended and every sandbox is confirmed disposed. */
|
|
117
|
-
waitUntilStopped: (environmentId: string, options?: WaitOptions | undefined) => Promise<Environment>;
|
|
118
|
-
/**
|
|
119
|
-
* actorId defaults to the actor of the environment's declared default connection, or
|
|
120
|
-
* else the app's first actor (for Salesforce, the administrator). Pick another from
|
|
121
|
-
* actors() to act with that user's permissions.
|
|
122
|
-
*/
|
|
123
|
-
connect: (environmentId: string, appKey: string, options?: ConnectOptions) => Promise<Connection>;
|
|
100
|
+
wait: (environmentId: string, options: WaitOptions<KnownEnvironmentStatus>) => Promise<Environment>;
|
|
101
|
+
/** Credentials for one app of the environment. */
|
|
102
|
+
connect: (environmentId: string, app: string, options?: ConnectOptions) => Promise<Credentials>;
|
|
124
103
|
};
|
|
125
104
|
readonly snapshots: {
|
|
126
|
-
/**
|
|
127
|
-
create: (
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
|
|
105
|
+
/** Creates a snapshot of a running environment and, unless `wait` is false, waits until it is `ready`. */
|
|
106
|
+
create: (input: {
|
|
107
|
+
environmentId: string;
|
|
108
|
+
name?: string | null;
|
|
109
|
+
}, options?: CreateEnvironmentOptions) => Promise<Snapshot>;
|
|
110
|
+
/** Newest first. Leaves deleted snapshots out unless `status` asks for them. */
|
|
111
|
+
list: (query?: ListSnapshotsRequest) => Promise<Page<Snapshot>>;
|
|
112
|
+
get: (snapshotId: string) => Promise<Snapshot>;
|
|
113
|
+
/** `null` clears the name. */
|
|
114
|
+
update: (snapshotId: string, body: {
|
|
115
|
+
name: string | null;
|
|
116
|
+
}) => Promise<Snapshot>;
|
|
117
|
+
/** A `saving` snapshot cannot be deleted. Safe to repeat. */
|
|
118
|
+
delete: (snapshotId: string) => Promise<Snapshot>;
|
|
140
119
|
/**
|
|
141
|
-
*
|
|
142
|
-
*
|
|
120
|
+
* Resolves when the snapshot has `status`. Throws once it cannot get there without
|
|
121
|
+
* another call: `SnapshotFailedError` if it failed, else `UnexpectedStatusError`.
|
|
143
122
|
*/
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
123
|
+
wait: (snapshotId: string, options: WaitOptions<KnownSnapshotStatus>) => Promise<Snapshot>;
|
|
124
|
+
};
|
|
125
|
+
readonly requests: {
|
|
126
|
+
/** Calls the gateway recorded for one environment, newest first. Recording is best effort. */
|
|
127
|
+
list: (query: ListRequestsRequest) => Promise<Page<Request>>;
|
|
128
|
+
get: (requestId: string) => Promise<RequestDetail>;
|
|
129
|
+
stats: (query: GetRequestStatsRequest) => Promise<RequestStats>;
|
|
130
|
+
/** The recorded body, in full. */
|
|
131
|
+
body: (requestId: string, direction: "request" | "response") => Promise<Uint8Array<ArrayBufferLike>>;
|
|
132
|
+
};
|
|
133
|
+
readonly auditEvents: {
|
|
134
|
+
/** Newest first. An API key that names no filter gets its own workspace. */
|
|
135
|
+
list: (query?: ListAuditEventsRequest) => Promise<Page<AuditEvent>>;
|
|
147
136
|
};
|
|
148
137
|
}
|
|
149
138
|
/**
|