@usestatemachines/sdk 0.5.0 → 0.6.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 +177 -521
- package/agents/SKILL.md +38 -47
- package/agents/index.js +7 -7
- package/agents/llms.txt +50 -46
- package/agents/prompt.md +11 -11
- package/esm/extensions/client.d.ts +104 -127
- package/esm/extensions/client.js +162 -322
- 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/{environments-get-connection.js → apps-list.js} +11 -16
- 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} +7 -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} +6 -5
- package/esm/funcs/environments-resume.d.ts +2 -1
- package/esm/funcs/environments-resume.js +2 -1
- package/esm/funcs/environments-update.d.ts +12 -0
- package/esm/funcs/{environments-events.js → environments-update.js} +9 -13
- 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-request-payload.js → requests-body.js} +5 -9
- package/esm/funcs/{environments-get-request-stats.d.ts → requests-get.d.ts} +2 -1
- 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/{environments-list-requests.js → requests-list.js} +9 -14
- package/esm/funcs/requests-stats.d.ts +12 -0
- package/esm/funcs/{environments-get-request-stats.js → requests-stats.js} +10 -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/{request-payload-preview.d.ts → body-preview.d.ts} +4 -4
- package/esm/models/{request-payload-preview.js → body-preview.js} +5 -4
- 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 -20
- package/esm/models/index.js +17 -20
- 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-environment-request-payload.js → get-request-body.js} +3 -4
- 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 -16
- package/esm/models/operations/index.js +13 -16
- 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 +0 -12
- package/esm/models/operations/resume-environment.js +0 -9
- 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/{environment-request-stats.d.ts → request-stats.d.ts} +3 -3
- package/esm/models/{environment-request-stats.js → request-stats.js} +3 -3
- package/esm/models/request.d.ts +30 -0
- package/esm/models/{environment-request.js → request.js} +11 -11
- 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 -13
- package/esm/sdk/environments.js +18 -38
- package/esm/sdk/requests.d.ts +9 -0
- package/esm/sdk/requests.js +23 -0
- package/esm/sdk/sdk.d.ts +11 -8
- package/esm/sdk/sdk.js +16 -11
- 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/openapi.json +1697 -2507
- 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-get-request-payload.d.ts +0 -11
- package/esm/funcs/environments-get-request.d.ts +0 -11
- package/esm/funcs/environments-get-request.js +0 -96
- package/esm/funcs/environments-list-requests.d.ts +0 -11
- package/esm/funcs/environments-reveal.d.ts +0 -11
- package/esm/funcs/environments-suspend.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 -45
- package/esm/models/environment-app.js +0 -47
- package/esm/models/environment-lifetime.d.ts +0 -10
- package/esm/models/environment-lifetime.js +0 -14
- package/esm/models/environment-request-detail.d.ts +0 -40
- package/esm/models/environment-request-detail.js +0 -39
- package/esm/models/environment-request.d.ts +0 -31
- 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 -57
- package/esm/models/error-response.js +0 -59
- package/esm/models/event-page.d.ts +0 -11
- package/esm/models/event-page.js +0 -16
- 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 -153
- package/esm/models/operations/create-environment-definition.js +0 -93
- 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-request-payload.d.ts +0 -23
- package/esm/models/operations/get-environment-request-stats.d.ts +0 -70
- package/esm/models/operations/get-environment-request-stats.js +0 -55
- package/esm/models/operations/get-environment-request.d.ts +0 -25
- package/esm/models/operations/get-environment-request.js +0 -21
- 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-requests.d.ts +0 -75
- package/esm/models/operations/list-environment-requests.js +0 -59
- 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 -25
- package/esm/models/operations/stop-environment.js +0 -26
- package/esm/models/operations/suspend-environment.d.ts +0 -25
- package/esm/models/operations/suspend-environment.js +0 -26
- 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/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usestatemachines/sdk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "TypeScript SDK for State environments",
|
|
3
|
+
"version": "0.6.1",
|
|
4
|
+
"description": "TypeScript SDK for State Machines environments",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://usestatemachines.com",
|
|
7
|
-
"author": "State",
|
|
7
|
+
"author": "State Machines",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"sideEffects": false,
|
|
10
10
|
"engines": {
|
|
@@ -29,7 +29,18 @@
|
|
|
29
29
|
"openapi.json",
|
|
30
30
|
"README.md"
|
|
31
31
|
],
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "node scripts/clean.mjs && tsgo",
|
|
34
|
+
"prepare": "pnpm build",
|
|
35
|
+
"typecheck": "tsgo -p tsconfig.check.json",
|
|
36
|
+
"lint": "biome ci . && pnpm agents:check && node scripts/source-stamp.mjs --check && node scripts/published-contract.mjs",
|
|
37
|
+
"generate": "speakeasy run -y --skip-versioning --skip-upload-spec --skip-compile && node scripts/source-stamp.mjs --write",
|
|
38
|
+
"test": "vitest run",
|
|
39
|
+
"agents:build": "node scripts/build-agents.mjs",
|
|
40
|
+
"agents:check": "node scripts/build-agents.mjs --check"
|
|
41
|
+
},
|
|
32
42
|
"dependencies": {
|
|
43
|
+
"yaml": "^2.9.1",
|
|
33
44
|
"zod": "^3.25.65 || ^4.0.0"
|
|
34
45
|
},
|
|
35
46
|
"devDependencies": {
|
|
@@ -37,14 +48,5 @@
|
|
|
37
48
|
"@types/node": "24.13.4",
|
|
38
49
|
"@typescript/native-preview": "7.0.0-dev.20260302.1",
|
|
39
50
|
"vitest": "5.0.1"
|
|
40
|
-
},
|
|
41
|
-
"scripts": {
|
|
42
|
-
"build": "node scripts/clean.mjs && tsgo",
|
|
43
|
-
"typecheck": "tsgo -p tsconfig.check.json",
|
|
44
|
-
"lint": "biome ci . && pnpm agents:check && node scripts/source-stamp.mjs --check",
|
|
45
|
-
"generate": "speakeasy run -y --skip-versioning --skip-upload-spec --skip-compile && node scripts/source-stamp.mjs --write",
|
|
46
|
-
"test": "vitest run",
|
|
47
|
-
"agents:build": "node scripts/build-agents.mjs",
|
|
48
|
-
"agents:check": "node scripts/build-agents.mjs --check"
|
|
49
51
|
}
|
|
50
|
-
}
|
|
52
|
+
}
|
package/esm/extensions/apps.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { CreateEnvironmentInput, CreateEnvironmentInputApp } from '../models/create-environment-input.js';
|
|
2
|
-
/** A string is shorthand for `{ key: <the string>, appId: <the string> }`. */
|
|
3
|
-
export type AppInput = string | CreateEnvironmentInputApp;
|
|
4
|
-
type Common = Omit<CreateEnvironmentInput, 'apps' | 'snapshotId' | 'snapshotAppInstanceKeys'>;
|
|
5
|
-
export interface EnvironmentInput extends Common {
|
|
6
|
-
/** 1 to 10 apps with unique keys. */
|
|
7
|
-
apps: AppInput[];
|
|
8
|
-
}
|
|
9
|
-
/** Starts from a snapshot: each app keeps the key it had when captured. */
|
|
10
|
-
export interface SnapshotEnvironmentInput extends Common {
|
|
11
|
-
snapshotId: string;
|
|
12
|
-
/** Keys of the snapshot's app instances to restore. Defaults to all. */
|
|
13
|
-
snapshotAppInstanceKeys?: string[];
|
|
14
|
-
}
|
|
15
|
-
export declare function expandApps(input: EnvironmentInput): CreateEnvironmentInput;
|
|
16
|
-
export type EnvironmentSource = EnvironmentInput | SnapshotEnvironmentInput | CreateEnvironmentInput;
|
|
17
|
-
export declare function expandSource(input: EnvironmentSource): CreateEnvironmentInput;
|
|
18
|
-
export {};
|
package/esm/extensions/apps.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
const APP_KEY = /^[a-z][a-z0-9-]{0,39}$/;
|
|
2
|
-
export function expandApps(input) {
|
|
3
|
-
if (input.apps.length === 0) {
|
|
4
|
-
throw new TypeError('Pass at least one app.');
|
|
5
|
-
}
|
|
6
|
-
const apps = input.apps.map((app) => {
|
|
7
|
-
if (typeof app !== 'string') {
|
|
8
|
-
return app;
|
|
9
|
-
}
|
|
10
|
-
if (!APP_KEY.test(app)) {
|
|
11
|
-
throw new TypeError(`"${app}" can't be used as an app key; pass { key, appId } instead.`);
|
|
12
|
-
}
|
|
13
|
-
return { key: app, appId: app };
|
|
14
|
-
});
|
|
15
|
-
const keys = new Set();
|
|
16
|
-
for (const { key } of apps) {
|
|
17
|
-
if (keys.has(key)) {
|
|
18
|
-
throw new TypeError(`App key "${key}" is used twice.`);
|
|
19
|
-
}
|
|
20
|
-
keys.add(key);
|
|
21
|
-
}
|
|
22
|
-
return { ...input, apps };
|
|
23
|
-
}
|
|
24
|
-
export function expandSource(input) {
|
|
25
|
-
const { apps, ...rest } = input;
|
|
26
|
-
if (rest.snapshotId === undefined) {
|
|
27
|
-
if (rest.snapshotAppInstanceKeys !== undefined) {
|
|
28
|
-
throw new TypeError('Pass snapshotAppInstanceKeys with snapshotId.');
|
|
29
|
-
}
|
|
30
|
-
if (apps === undefined) {
|
|
31
|
-
throw new TypeError('Pass apps or snapshotId.');
|
|
32
|
-
}
|
|
33
|
-
return expandApps({ ...rest, apps });
|
|
34
|
-
}
|
|
35
|
-
if (apps !== undefined) {
|
|
36
|
-
throw new TypeError('Pass apps or snapshotId, not both.');
|
|
37
|
-
}
|
|
38
|
-
return rest;
|
|
39
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import type { Fetcher } from '../lib/http.js';
|
|
2
|
-
import type { ApiProfile } from '../models/api-profile.js';
|
|
3
|
-
import type { ConnectionSecret } from '../models/connection-secret.js';
|
|
4
|
-
/**
|
|
5
|
-
* The HTTP header an app's API expects for its actor token, or `null` when the token goes in
|
|
6
|
-
* the request body instead: for `SOAP SessionHeader`, as the envelope's `SessionHeader/sessionId`.
|
|
7
|
-
*/
|
|
8
|
-
export declare function formatActorHeader(actorHeader: string, token: string): {
|
|
9
|
-
name: string;
|
|
10
|
-
value: string;
|
|
11
|
-
} | null;
|
|
12
|
-
/** A live app connection. `fetch` only reaches paths under `baseUrl`. */
|
|
13
|
-
export declare class Connection {
|
|
14
|
-
#private;
|
|
15
|
-
readonly baseUrl: string;
|
|
16
|
-
readonly environmentId: string;
|
|
17
|
-
readonly appKey: string;
|
|
18
|
-
readonly actorId: string;
|
|
19
|
-
readonly api: ApiProfile;
|
|
20
|
-
readonly expiresAt: Date;
|
|
21
|
-
constructor(baseUrl: string, api: ApiProfile, secret: ConnectionSecret, fetch?: Fetcher);
|
|
22
|
-
/**
|
|
23
|
-
* The headers the gateway and the app need, for clients that can't use `fetch`. For an API
|
|
24
|
-
* whose actor token goes in the request body, such as SOAP, only the environment token.
|
|
25
|
-
*/
|
|
26
|
-
headers(): Record<string, string>;
|
|
27
|
-
/**
|
|
28
|
-
* The live actor token, for APIs that take it in the request body: for a SOAP API, put it in
|
|
29
|
-
* the envelope's `SessionHeader/sessionId`. Treat it as a secret.
|
|
30
|
-
*/
|
|
31
|
-
actorToken(): string;
|
|
32
|
-
/** Sends one request to the app. Never retries, never follows redirects, never adds the API key. */
|
|
33
|
-
fetch(path: string, init?: RequestInit): Promise<Response>;
|
|
34
|
-
toJSON(): {
|
|
35
|
-
baseUrl: string;
|
|
36
|
-
environmentId: string;
|
|
37
|
-
appKey: string;
|
|
38
|
-
actorId: string;
|
|
39
|
-
api: ApiProfile;
|
|
40
|
-
expiresAt: Date;
|
|
41
|
-
};
|
|
42
|
-
}
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
const HTTP_TOKEN = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
|
|
2
|
-
// Salesforce's SOAP API takes the actor token in the envelope, not an HTTP header.
|
|
3
|
-
const SOAP_SESSION_HEADER = 'SOAP SessionHeader';
|
|
4
|
-
// Visible ASCII only: `Headers` would otherwise echo a bad value, token included, in its error.
|
|
5
|
-
const TOKEN_VALUE = /^[\x21-\x7e]+$/;
|
|
6
|
-
// Checked on the path part only (C7). Covers protocol-relative starts, backslashes, control
|
|
7
|
-
// characters and encoded dots, slashes and backslashes, including double encoding.
|
|
8
|
-
const UNSAFE_PATH = /^\/\/|\\|%(?:25)*(?:2e|2f|5c)|\p{Cc}/iu;
|
|
9
|
-
const OUTSIDE = 'Connection.fetch only reaches paths under the connection baseUrl.';
|
|
10
|
-
/**
|
|
11
|
-
* The HTTP header an app's API expects for its actor token, or `null` when the token goes in
|
|
12
|
-
* the request body instead: for `SOAP SessionHeader`, as the envelope's `SessionHeader/sessionId`.
|
|
13
|
-
*/
|
|
14
|
-
export function formatActorHeader(actorHeader, token) {
|
|
15
|
-
if (actorHeader === SOAP_SESSION_HEADER) {
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
if (!HTTP_TOKEN.test(actorHeader) ||
|
|
19
|
-
actorHeader.toLowerCase().startsWith('x-state-')) {
|
|
20
|
-
throw new TypeError('The API profile names an invalid actor header.');
|
|
21
|
-
}
|
|
22
|
-
return actorHeader.toLowerCase() === 'authorization'
|
|
23
|
-
? { name: 'Authorization', value: `Bearer ${token}` }
|
|
24
|
-
: { name: actorHeader, value: token };
|
|
25
|
-
}
|
|
26
|
-
/** A live app connection. `fetch` only reaches paths under `baseUrl`. */
|
|
27
|
-
export class Connection {
|
|
28
|
-
baseUrl;
|
|
29
|
-
environmentId;
|
|
30
|
-
appKey;
|
|
31
|
-
actorId;
|
|
32
|
-
api;
|
|
33
|
-
expiresAt;
|
|
34
|
-
#base;
|
|
35
|
-
#environmentToken;
|
|
36
|
-
#actorToken;
|
|
37
|
-
#actor;
|
|
38
|
-
#fetch;
|
|
39
|
-
constructor(baseUrl, api, secret, fetch) {
|
|
40
|
-
const base = URL.canParse(baseUrl) ? new URL(baseUrl) : null;
|
|
41
|
-
if (!base ||
|
|
42
|
-
!/^https?:$/.test(base.protocol) ||
|
|
43
|
-
base.username ||
|
|
44
|
-
base.password ||
|
|
45
|
-
base.search ||
|
|
46
|
-
base.hash) {
|
|
47
|
-
throw new TypeError('The connection baseUrl is not a plain http(s) URL.');
|
|
48
|
-
}
|
|
49
|
-
if (!TOKEN_VALUE.test(secret.environmentToken) ||
|
|
50
|
-
!TOKEN_VALUE.test(secret.actorToken)) {
|
|
51
|
-
throw new TypeError('The connection tokens are malformed.');
|
|
52
|
-
}
|
|
53
|
-
if (!base.pathname.endsWith('/')) {
|
|
54
|
-
base.pathname += '/';
|
|
55
|
-
}
|
|
56
|
-
this.#base = base;
|
|
57
|
-
this.#environmentToken = secret.environmentToken;
|
|
58
|
-
this.#actorToken = secret.actorToken;
|
|
59
|
-
this.#actor = formatActorHeader(api.actorHeader, secret.actorToken);
|
|
60
|
-
this.#fetch = fetch;
|
|
61
|
-
this.baseUrl = base.href;
|
|
62
|
-
this.environmentId = secret.environmentId;
|
|
63
|
-
this.appKey = secret.appKey;
|
|
64
|
-
this.actorId = secret.actorId;
|
|
65
|
-
this.api = api;
|
|
66
|
-
this.expiresAt = secret.expiresAt;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* The headers the gateway and the app need, for clients that can't use `fetch`. For an API
|
|
70
|
-
* whose actor token goes in the request body, such as SOAP, only the environment token.
|
|
71
|
-
*/
|
|
72
|
-
headers() {
|
|
73
|
-
return {
|
|
74
|
-
'X-State-Environment-Token': this.#environmentToken,
|
|
75
|
-
...(this.#actor ? { [this.#actor.name]: this.#actor.value } : {}),
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* The live actor token, for APIs that take it in the request body: for a SOAP API, put it in
|
|
80
|
-
* the envelope's `SessionHeader/sessionId`. Treat it as a secret.
|
|
81
|
-
*/
|
|
82
|
-
actorToken() {
|
|
83
|
-
return this.#actorToken;
|
|
84
|
-
}
|
|
85
|
-
/** Sends one request to the app. Never retries, never follows redirects, never adds the API key. */
|
|
86
|
-
async fetch(path, init = {}) {
|
|
87
|
-
const url = this.#resolve(path);
|
|
88
|
-
const headers = new Headers(init.headers);
|
|
89
|
-
for (const name of headers.keys()) {
|
|
90
|
-
if (name.startsWith('x-state-')) {
|
|
91
|
-
throw new TypeError(`Header ${name} is reserved for State.`);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
// Ours go last so a caller header of the same name can't replace them.
|
|
95
|
-
for (const [name, value] of Object.entries(this.headers())) {
|
|
96
|
-
headers.set(name, value);
|
|
97
|
-
}
|
|
98
|
-
const request = new Request(url, { ...init, headers, redirect: 'manual' });
|
|
99
|
-
// Called on `globalThis` at use time: a stored unbound `fetch` throws "Illegal invocation" in Workers.
|
|
100
|
-
return this.#fetch ? this.#fetch(request) : globalThis.fetch(request);
|
|
101
|
-
}
|
|
102
|
-
toJSON() {
|
|
103
|
-
return {
|
|
104
|
-
baseUrl: this.baseUrl,
|
|
105
|
-
environmentId: this.environmentId,
|
|
106
|
-
appKey: this.appKey,
|
|
107
|
-
actorId: this.actorId,
|
|
108
|
-
api: this.api,
|
|
109
|
-
expiresAt: this.expiresAt,
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
#resolve(path) {
|
|
113
|
-
const pathPart = path.split(/[?#]/, 1)[0] ?? '';
|
|
114
|
-
if (UNSAFE_PATH.test(pathPart)) {
|
|
115
|
-
throw new TypeError(OUTSIDE);
|
|
116
|
-
}
|
|
117
|
-
// A leading `/` means the root of the connection, not of the gateway.
|
|
118
|
-
const relative = path.startsWith('/') ? `.${path}` : path;
|
|
119
|
-
// `URL` errors carry the input, query included, so they are replaced rather than rethrown.
|
|
120
|
-
const url = URL.canParse(relative, this.#base)
|
|
121
|
-
? new URL(relative, this.#base)
|
|
122
|
-
: null;
|
|
123
|
-
if (!url ||
|
|
124
|
-
url.origin !== this.#base.origin ||
|
|
125
|
-
url.username ||
|
|
126
|
-
url.password ||
|
|
127
|
-
!url.pathname.startsWith(this.#base.pathname) ||
|
|
128
|
-
UNSAFE_PATH.test(url.pathname)) {
|
|
129
|
-
throw new TypeError(OUTSIDE);
|
|
130
|
-
}
|
|
131
|
-
return url;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import type { Environment } from '../models/environment.js';
|
|
2
|
-
import type { EnvironmentSnapshot } from '../models/environment-snapshot.js';
|
|
3
|
-
import type { ReleaseActor } from '../models/release-actor.js';
|
|
4
|
-
import type { CallOptions, CaptureInput, CaptureOptions, ConnectOptions, LifecycleOptions, StateMachines } from './client.js';
|
|
5
|
-
import type { Connection } from './connection.js';
|
|
6
|
-
import type { WaitOptions } from './wait.js';
|
|
7
|
-
/** A started environment. It remains the handle after `suspend()` and `stop()`. */
|
|
8
|
-
export declare class RunningEnvironment {
|
|
9
|
-
#private;
|
|
10
|
-
readonly id: string;
|
|
11
|
-
/** The record when `start()` resolved. Use `sm.environments.get(id)` for fresh state. */
|
|
12
|
-
readonly environment: Environment;
|
|
13
|
-
constructor(sm: StateMachines, environment: Environment);
|
|
14
|
-
/**
|
|
15
|
-
* actorId defaults to the actor of the environment's declared default connection, or
|
|
16
|
-
* else the app's first actor (for Salesforce, the administrator). Pick another from
|
|
17
|
-
* actors() to act with that user's permissions.
|
|
18
|
-
*/
|
|
19
|
-
connect(appKey: string, options?: ConnectOptions): Promise<Connection>;
|
|
20
|
-
/** The app's users, in the release's order. */
|
|
21
|
-
actors(appKey: string, options?: CallOptions): Promise<ReleaseActor[]>;
|
|
22
|
-
/** Captures a snapshot in the environment's own workspace and waits until it's `ready`. */
|
|
23
|
-
snapshot(input?: CaptureInput, options?: CaptureOptions): Promise<EnvironmentSnapshot>;
|
|
24
|
-
/**
|
|
25
|
-
* Ends the sandboxes and keeps the data for `resume()`. Doesn't wait: use
|
|
26
|
-
* `waitUntilSuspended()` before resuming.
|
|
27
|
-
*/
|
|
28
|
-
suspend(options?: LifecycleOptions): Promise<Environment>;
|
|
29
|
-
/** Resolves when the environment is suspended and can resume. */
|
|
30
|
-
waitUntilSuspended(options?: WaitOptions): Promise<Environment>;
|
|
31
|
-
/** Runs a suspended or failed environment again on its data. Use `waitUntilReady()` before connecting. */
|
|
32
|
-
resume(options?: LifecycleOptions): Promise<Environment>;
|
|
33
|
-
/** Resolves when the environment is running again. */
|
|
34
|
-
waitUntilReady(options?: WaitOptions): Promise<Environment>;
|
|
35
|
-
/**
|
|
36
|
-
* Ends the environment and discards its data. Safe to call twice. Doesn't wait for
|
|
37
|
-
* disposal: use `waitUntilStopped()`.
|
|
38
|
-
*/
|
|
39
|
-
stop(options?: LifecycleOptions): Promise<Environment>;
|
|
40
|
-
/** Resolves when the environment ended and every sandbox is confirmed disposed. */
|
|
41
|
-
waitUntilStopped(options?: WaitOptions): Promise<Environment>;
|
|
42
|
-
toJSON(): {
|
|
43
|
-
id: string;
|
|
44
|
-
environment: Environment;
|
|
45
|
-
};
|
|
46
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/** A started environment. It remains the handle after `suspend()` and `stop()`. */
|
|
2
|
-
export class RunningEnvironment {
|
|
3
|
-
id;
|
|
4
|
-
/** The record when `start()` resolved. Use `sm.environments.get(id)` for fresh state. */
|
|
5
|
-
environment;
|
|
6
|
-
#environments;
|
|
7
|
-
#snapshots;
|
|
8
|
-
constructor(sm, environment) {
|
|
9
|
-
this.id = environment.id;
|
|
10
|
-
this.environment = environment;
|
|
11
|
-
this.#environments = sm.environments;
|
|
12
|
-
this.#snapshots = sm.snapshots;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* actorId defaults to the actor of the environment's declared default connection, or
|
|
16
|
-
* else the app's first actor (for Salesforce, the administrator). Pick another from
|
|
17
|
-
* actors() to act with that user's permissions.
|
|
18
|
-
*/
|
|
19
|
-
connect(appKey, options) {
|
|
20
|
-
return this.#environments.connect(this.id, appKey, options);
|
|
21
|
-
}
|
|
22
|
-
/** The app's users, in the release's order. */
|
|
23
|
-
actors(appKey, options) {
|
|
24
|
-
return this.#environments.actors(this.id, appKey, options);
|
|
25
|
-
}
|
|
26
|
-
/** Captures a snapshot in the environment's own workspace and waits until it's `ready`. */
|
|
27
|
-
snapshot(input, options = {}) {
|
|
28
|
-
return this.#snapshots.capture(this.id, input, {
|
|
29
|
-
...options,
|
|
30
|
-
workspaceId: options.workspaceId ?? this.environment.workspaceId,
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Ends the sandboxes and keeps the data for `resume()`. Doesn't wait: use
|
|
35
|
-
* `waitUntilSuspended()` before resuming.
|
|
36
|
-
*/
|
|
37
|
-
suspend(options) {
|
|
38
|
-
return this.#environments.suspend(this.id, options);
|
|
39
|
-
}
|
|
40
|
-
/** Resolves when the environment is suspended and can resume. */
|
|
41
|
-
waitUntilSuspended(options) {
|
|
42
|
-
return this.#environments.waitUntilSuspended(this.id, options);
|
|
43
|
-
}
|
|
44
|
-
/** Runs a suspended or failed environment again on its data. Use `waitUntilReady()` before connecting. */
|
|
45
|
-
resume(options) {
|
|
46
|
-
return this.#environments.resume(this.id, options);
|
|
47
|
-
}
|
|
48
|
-
/** Resolves when the environment is running again. */
|
|
49
|
-
waitUntilReady(options) {
|
|
50
|
-
return this.#environments.waitUntilReady(this.id, options);
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Ends the environment and discards its data. Safe to call twice. Doesn't wait for
|
|
54
|
-
* disposal: use `waitUntilStopped()`.
|
|
55
|
-
*/
|
|
56
|
-
stop(options) {
|
|
57
|
-
return this.#environments.stop(this.id, options);
|
|
58
|
-
}
|
|
59
|
-
/** Resolves when the environment ended and every sandbox is confirmed disposed. */
|
|
60
|
-
waitUntilStopped(options) {
|
|
61
|
-
return this.#environments.waitUntilStopped(this.id, options);
|
|
62
|
-
}
|
|
63
|
-
toJSON() {
|
|
64
|
-
return { id: this.id, environment: this.environment };
|
|
65
|
-
}
|
|
66
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
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 createEnvironmentDefinition(client: StateMachinesCore, request: operations.CreateEnvironmentDefinitionRequest, options?: RequestOptions): APIPromise<Result<operations.CreateEnvironmentDefinitionResponse, errors.ErrorResponse | StateMachinesHTTPError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
-
*/
|
|
4
|
-
import * as z from "zod/v4-mini";
|
|
5
|
-
import { encodeJSON, encodeSimple } 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 createEnvironmentDefinition(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(operations.CreateEnvironmentDefinitionRequest$outboundSchema, value), "Input validation failed");
|
|
20
|
-
if (!parsed.ok) {
|
|
21
|
-
return [parsed, { status: "invalid" }];
|
|
22
|
-
}
|
|
23
|
-
const payload = parsed.value;
|
|
24
|
-
const body = encodeJSON("body", payload.body, { explode: true });
|
|
25
|
-
const pathParams = {
|
|
26
|
-
workspaceId: encodeSimple("workspaceId", payload.workspaceId, {
|
|
27
|
-
explode: false,
|
|
28
|
-
charEncoding: "percent",
|
|
29
|
-
}),
|
|
30
|
-
};
|
|
31
|
-
const path = pathToFunc("/v1/workspaces/{workspaceId}/environment-definitions")(pathParams);
|
|
32
|
-
const headers = new Headers(compactMap({
|
|
33
|
-
"Content-Type": "application/json",
|
|
34
|
-
Accept: "application/json",
|
|
35
|
-
"idempotency-key": encodeSimple("idempotency-key", payload["idempotency-key"], { explode: false, charEncoding: "none" }),
|
|
36
|
-
}));
|
|
37
|
-
const secConfig = await extractSecurity(client._options.apiKey);
|
|
38
|
-
const securityInput = secConfig == null ? {} : { apiKey: secConfig };
|
|
39
|
-
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
40
|
-
const context = {
|
|
41
|
-
options: client._options,
|
|
42
|
-
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
43
|
-
operationID: "createEnvironmentDefinition",
|
|
44
|
-
oAuth2Scopes: null,
|
|
45
|
-
resolvedSecurity: requestSecurity,
|
|
46
|
-
securitySource: client._options.apiKey,
|
|
47
|
-
retryConfig: options?.retries
|
|
48
|
-
|| client._options.retryConfig
|
|
49
|
-
|| {
|
|
50
|
-
strategy: "backoff",
|
|
51
|
-
backoff: {
|
|
52
|
-
initialInterval: 1000,
|
|
53
|
-
maxInterval: 5000,
|
|
54
|
-
exponent: 1.5,
|
|
55
|
-
maxElapsedTime: 600000,
|
|
56
|
-
},
|
|
57
|
-
retryConnectionErrors: true,
|
|
58
|
-
}
|
|
59
|
-
|| { strategy: "none" },
|
|
60
|
-
retryCodes: options?.retryCodes || ["502", "503", "504"],
|
|
61
|
-
};
|
|
62
|
-
const requestRes = client._createRequest(context, {
|
|
63
|
-
security: requestSecurity,
|
|
64
|
-
method: "POST",
|
|
65
|
-
baseURL: options?.serverURL,
|
|
66
|
-
path: path,
|
|
67
|
-
headers: headers,
|
|
68
|
-
body: body,
|
|
69
|
-
userAgent: client._options.userAgent,
|
|
70
|
-
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
71
|
-
}, options);
|
|
72
|
-
if (!requestRes.ok) {
|
|
73
|
-
return [requestRes, { status: "invalid" }];
|
|
74
|
-
}
|
|
75
|
-
const req = requestRes.value;
|
|
76
|
-
const doResult = await client._do(req, {
|
|
77
|
-
context,
|
|
78
|
-
isErrorStatusCode: (statusCode) => matchStatusCode({ status: statusCode }, ["4XX", "5XX"]),
|
|
79
|
-
retryConfig: context.retryConfig,
|
|
80
|
-
retryCodes: context.retryCodes,
|
|
81
|
-
});
|
|
82
|
-
if (!doResult.ok) {
|
|
83
|
-
return [doResult, { status: "request-error", request: req }];
|
|
84
|
-
}
|
|
85
|
-
const response = doResult.value;
|
|
86
|
-
const responseFields = {
|
|
87
|
-
HttpMeta: { Response: response, Request: req },
|
|
88
|
-
};
|
|
89
|
-
const [result] = await M.match(M.json(202, operations.CreateEnvironmentDefinitionResponse$inboundSchema), M.jsonErr([400, 401, 403, 404, 409, 413, 422, 429], errors.ErrorResponse$inboundSchema), M.jsonErr([500, 503], errors.ErrorResponse$inboundSchema), M.fail("4XX"), M.fail("5XX"))(response, req, { extraFields: responseFields });
|
|
90
|
-
if (!result.ok) {
|
|
91
|
-
return [result, { status: "complete", request: req, response }];
|
|
92
|
-
}
|
|
93
|
-
return [result, { status: "complete", request: req, response }];
|
|
94
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
-
*/
|
|
4
|
-
import { matchStatusCode } from "../lib/http.js";
|
|
5
|
-
import * as M from "../lib/matchers.js";
|
|
6
|
-
import { compactMap } from "../lib/primitives.js";
|
|
7
|
-
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
8
|
-
import { pathToFunc } from "../lib/url.js";
|
|
9
|
-
import * as errors from "../models/errors/index.js";
|
|
10
|
-
import * as operations from "../models/operations/index.js";
|
|
11
|
-
import { APIPromise } from "../types/async.js";
|
|
12
|
-
export function credentialGet(client, options) {
|
|
13
|
-
return new APIPromise($do(client, options));
|
|
14
|
-
}
|
|
15
|
-
async function $do(client, options) {
|
|
16
|
-
const path = pathToFunc("/v1/credential")();
|
|
17
|
-
const headers = new Headers(compactMap({
|
|
18
|
-
Accept: "application/json",
|
|
19
|
-
}));
|
|
20
|
-
const secConfig = await extractSecurity(client._options.apiKey);
|
|
21
|
-
const securityInput = secConfig == null ? {} : { apiKey: secConfig };
|
|
22
|
-
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
23
|
-
const context = {
|
|
24
|
-
options: client._options,
|
|
25
|
-
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
26
|
-
operationID: "getCredential",
|
|
27
|
-
oAuth2Scopes: null,
|
|
28
|
-
resolvedSecurity: requestSecurity,
|
|
29
|
-
securitySource: client._options.apiKey,
|
|
30
|
-
retryConfig: options?.retries
|
|
31
|
-
|| client._options.retryConfig
|
|
32
|
-
|| {
|
|
33
|
-
strategy: "backoff",
|
|
34
|
-
backoff: {
|
|
35
|
-
initialInterval: 1000,
|
|
36
|
-
maxInterval: 5000,
|
|
37
|
-
exponent: 1.5,
|
|
38
|
-
maxElapsedTime: 600000,
|
|
39
|
-
},
|
|
40
|
-
retryConnectionErrors: true,
|
|
41
|
-
}
|
|
42
|
-
|| { strategy: "none" },
|
|
43
|
-
retryCodes: options?.retryCodes || ["502", "503", "504"],
|
|
44
|
-
};
|
|
45
|
-
const requestRes = client._createRequest(context, {
|
|
46
|
-
security: requestSecurity,
|
|
47
|
-
method: "GET",
|
|
48
|
-
baseURL: options?.serverURL,
|
|
49
|
-
path: path,
|
|
50
|
-
headers: headers,
|
|
51
|
-
userAgent: client._options.userAgent,
|
|
52
|
-
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
53
|
-
}, options);
|
|
54
|
-
if (!requestRes.ok) {
|
|
55
|
-
return [requestRes, { status: "invalid" }];
|
|
56
|
-
}
|
|
57
|
-
const req = requestRes.value;
|
|
58
|
-
const doResult = await client._do(req, {
|
|
59
|
-
context,
|
|
60
|
-
isErrorStatusCode: (statusCode) => matchStatusCode({ status: statusCode }, ["4XX", "5XX"]),
|
|
61
|
-
retryConfig: context.retryConfig,
|
|
62
|
-
retryCodes: context.retryCodes,
|
|
63
|
-
});
|
|
64
|
-
if (!doResult.ok) {
|
|
65
|
-
return [doResult, { status: "request-error", request: req }];
|
|
66
|
-
}
|
|
67
|
-
const response = doResult.value;
|
|
68
|
-
const responseFields = {
|
|
69
|
-
HttpMeta: { Response: response, Request: req },
|
|
70
|
-
};
|
|
71
|
-
const [result] = await M.match(M.json(200, operations.GetCredentialResponse$inboundSchema), M.jsonErr([400, 401, 403, 404, 409, 413, 422, 429], errors.ErrorResponse$inboundSchema), M.jsonErr([500, 503], errors.ErrorResponse$inboundSchema), M.fail("4XX"), M.fail("5XX"))(response, req, { extraFields: responseFields });
|
|
72
|
-
if (!result.ok) {
|
|
73
|
-
return [result, { status: "complete", request: req, response }];
|
|
74
|
-
}
|
|
75
|
-
return [result, { status: "complete", request: req, response }];
|
|
76
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
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 environmentsGetRequestPayload(client: StateMachinesCore, request: operations.GetEnvironmentRequestPayloadRequest, options?: RequestOptions): APIPromise<Result<ReadableStream<Uint8Array>, errors.ErrorResponse | StateMachinesHTTPError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
|
|
@@ -1,11 +0,0 @@
|
|
|
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 environmentsGetRequest(client: StateMachinesCore, request: operations.GetEnvironmentRequestRequest, options?: RequestOptions): APIPromise<Result<operations.GetEnvironmentRequestResponse, errors.ErrorResponse | StateMachinesHTTPError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
|