@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/esm/extensions/wait.js
CHANGED
|
@@ -1,15 +1,64 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EnvironmentFailedError, isTransient, SnapshotFailedError, toStateMachinesError, UnexpectedStatusError, WaitTimeoutError, } from './errors.js';
|
|
2
2
|
import { linkSignal } from './signal.js';
|
|
3
3
|
export const defaultTimeoutMs = 600000;
|
|
4
4
|
const readTimeoutMs = 30000;
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
/**
|
|
6
|
+
* The statuses each status reaches with no call from the customer: a boot ends, a restart
|
|
7
|
+
* fails, the time limit passes, a paused or failed environment expires after a day.
|
|
8
|
+
*/
|
|
9
|
+
const environmentReaches = {
|
|
10
|
+
starting: ['running', 'failed', 'deleted'],
|
|
11
|
+
running: ['failed', 'deleted'],
|
|
12
|
+
paused: ['deleted'],
|
|
13
|
+
failed: ['deleted'],
|
|
14
|
+
deleted: [],
|
|
15
|
+
};
|
|
16
|
+
const snapshotReaches = {
|
|
17
|
+
saving: ['ready', 'failed'],
|
|
18
|
+
ready: [],
|
|
19
|
+
failed: [],
|
|
20
|
+
deleted: [],
|
|
21
|
+
};
|
|
22
|
+
/** True at the target; false while the target is still reachable; throws otherwise. */
|
|
23
|
+
export function environmentAt(target) {
|
|
24
|
+
return (environment) => {
|
|
25
|
+
const { status } = environment;
|
|
26
|
+
if (status === target) {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
// An unknown status may be a step this SDK predates, so the wait goes on.
|
|
30
|
+
const reaches = environmentReaches[status] ?? null;
|
|
31
|
+
if (!reaches || reaches.includes(target)) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
if (status === 'failed' ||
|
|
35
|
+
(status === 'deleted' && environment.reason === 'failed')) {
|
|
36
|
+
throw new EnvironmentFailedError(environment);
|
|
37
|
+
}
|
|
38
|
+
throw new UnexpectedStatusError(environment, target);
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export function snapshotAt(target) {
|
|
42
|
+
return (snapshot) => {
|
|
43
|
+
const { status } = snapshot;
|
|
44
|
+
if (status === target) {
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
const reaches = snapshotReaches[status] ?? null;
|
|
48
|
+
if (!reaches || reaches.includes(target)) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
if (status === 'failed') {
|
|
52
|
+
throw new SnapshotFailedError(snapshot);
|
|
53
|
+
}
|
|
54
|
+
throw new UnexpectedStatusError(snapshot, target);
|
|
55
|
+
};
|
|
7
56
|
}
|
|
8
57
|
/**
|
|
9
|
-
* Reads until `done` returns true
|
|
58
|
+
* Reads until `done` returns true; `done` throws to end the wait with a failure.
|
|
10
59
|
* Transient read failures are retried with backoff until the deadline.
|
|
11
60
|
*/
|
|
12
|
-
export async function
|
|
61
|
+
export async function poll(id, read, done, options = {}) {
|
|
13
62
|
const { signal } = options;
|
|
14
63
|
const timeoutMs = options.timeoutMs ?? defaultTimeoutMs;
|
|
15
64
|
if (!(timeoutMs >= 0)) {
|
|
@@ -17,11 +66,12 @@ export async function pollUntil(read, done, options = {}, timeout) {
|
|
|
17
66
|
}
|
|
18
67
|
const deadline = Date.now() + timeoutMs;
|
|
19
68
|
let last = null;
|
|
69
|
+
const timeout = () => new WaitTimeoutError(last, timeoutMs, id);
|
|
20
70
|
for (let attempt = 0;; attempt += 1) {
|
|
21
71
|
signal?.throwIfAborted();
|
|
22
72
|
const remaining = deadline - Date.now();
|
|
23
73
|
if (remaining <= 0) {
|
|
24
|
-
throw timeout(
|
|
74
|
+
throw timeout();
|
|
25
75
|
}
|
|
26
76
|
let waitMs = backoff(attempt);
|
|
27
77
|
let value = null;
|
|
@@ -34,14 +84,14 @@ export async function pollUntil(read, done, options = {}, timeout) {
|
|
|
34
84
|
// Classify by signal state: a stalled body read surfaces as an arbitrary error.
|
|
35
85
|
signal?.throwIfAborted();
|
|
36
86
|
if (Date.now() >= deadline) {
|
|
37
|
-
throw timeout(
|
|
87
|
+
throw timeout();
|
|
38
88
|
}
|
|
39
89
|
if (!link.signal.aborted) {
|
|
40
90
|
const failure = toStateMachinesError(error);
|
|
41
|
-
if (!failure
|
|
91
|
+
if (!isTransient(failure)) {
|
|
42
92
|
throw failure;
|
|
43
93
|
}
|
|
44
|
-
waitMs = Math.max(waitMs, failure.
|
|
94
|
+
waitMs = Math.max(waitMs, failure.retryAfterMs ?? 0);
|
|
45
95
|
}
|
|
46
96
|
}
|
|
47
97
|
finally {
|
|
@@ -50,7 +100,7 @@ export async function pollUntil(read, done, options = {}, timeout) {
|
|
|
50
100
|
// A read can settle after an abort or past the deadline; neither may resolve the wait.
|
|
51
101
|
signal?.throwIfAborted();
|
|
52
102
|
if (Date.now() >= deadline) {
|
|
53
|
-
throw timeout(
|
|
103
|
+
throw timeout();
|
|
54
104
|
}
|
|
55
105
|
if (value !== null && done(value)) {
|
|
56
106
|
return value;
|
|
@@ -58,52 +108,6 @@ export async function pollUntil(read, done, options = {}, timeout) {
|
|
|
58
108
|
await sleep(Math.min(waitMs, deadline - Date.now()), signal);
|
|
59
109
|
}
|
|
60
110
|
}
|
|
61
|
-
/** Resolves on `running`. Never suspends or stops the environment. */
|
|
62
|
-
export function ready(environment) {
|
|
63
|
-
switch (environment.status) {
|
|
64
|
-
case 'running':
|
|
65
|
-
return true;
|
|
66
|
-
case 'failed':
|
|
67
|
-
case 'suspending':
|
|
68
|
-
case 'suspended':
|
|
69
|
-
case 'stopping':
|
|
70
|
-
case 'stopped':
|
|
71
|
-
throw new EnvironmentFailedError(environment);
|
|
72
|
-
default:
|
|
73
|
-
return false;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
/** Resolves on `suspended`, when the environment can resume. */
|
|
77
|
-
export function suspended(environment) {
|
|
78
|
-
switch (environment.status) {
|
|
79
|
-
case 'suspended':
|
|
80
|
-
return true;
|
|
81
|
-
case 'failed':
|
|
82
|
-
case 'stopping':
|
|
83
|
-
case 'stopped':
|
|
84
|
-
throw new EnvironmentFailedError(environment);
|
|
85
|
-
default:
|
|
86
|
-
return false;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
/** Resolves once the environment ended and every app's sandbox is confirmed disposed. */
|
|
90
|
-
export function disposed(environment) {
|
|
91
|
-
if (environment.status !== 'stopped' && environment.status !== 'failed') {
|
|
92
|
-
return false;
|
|
93
|
-
}
|
|
94
|
-
const unconfirmed = environment.apps.some(({ disposal }) => disposal === 'failed' || disposal === 'unknown');
|
|
95
|
-
if (unconfirmed) {
|
|
96
|
-
throw new DisposalIncompleteError(environment);
|
|
97
|
-
}
|
|
98
|
-
return environment.apps.every((app) => app.disposal === 'complete');
|
|
99
|
-
}
|
|
100
|
-
/** Resolves on `ready`. A failed or deleted snapshot ends the wait. */
|
|
101
|
-
export function snapshotReady(snapshot) {
|
|
102
|
-
if (snapshot.status === 'failed' || snapshot.deletedAt) {
|
|
103
|
-
throw new SnapshotFailedError(snapshot);
|
|
104
|
-
}
|
|
105
|
-
return snapshot.status === 'ready';
|
|
106
|
-
}
|
|
107
111
|
/** 1 s × 1.5ⁿ, capped at 5 s, with ±20% jitter. */
|
|
108
112
|
export function backoff(attempt) {
|
|
109
113
|
return Math.min(5000, 1000 * 1.5 ** attempt) * (0.8 + Math.random() * 0.4);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CreateEnvironment } from '../models/create-environment.js';
|
|
2
|
+
/**
|
|
3
|
+
* Parses a YAML document with the fields of `CreateEnvironment`. The SDK checks the shape;
|
|
4
|
+
* the API checks the values. Anchors, aliases, tags and duplicate keys are refused.
|
|
5
|
+
*/
|
|
6
|
+
export declare function parseEnvironmentYaml(text: string): CreateEnvironment;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { isAlias, isScalar, parseDocument, visit } from 'yaml';
|
|
2
|
+
import { invalidInput } from './errors.js';
|
|
3
|
+
const APP_FIELDS = new Set(['app', 'name', 'settings']);
|
|
4
|
+
/**
|
|
5
|
+
* Parses a YAML document with the fields of `CreateEnvironment`. The SDK checks the shape;
|
|
6
|
+
* the API checks the values. Anchors, aliases, tags and duplicate keys are refused.
|
|
7
|
+
*/
|
|
8
|
+
export function parseEnvironmentYaml(text) {
|
|
9
|
+
const document = parseDocument(text, {
|
|
10
|
+
version: '1.2',
|
|
11
|
+
strict: true,
|
|
12
|
+
uniqueKeys: true,
|
|
13
|
+
merge: false,
|
|
14
|
+
resolveKnownTags: false,
|
|
15
|
+
});
|
|
16
|
+
const issue = document.errors[0] ?? document.warnings[0];
|
|
17
|
+
if (issue) {
|
|
18
|
+
const position = issue.linePos?.[0];
|
|
19
|
+
throw bad({
|
|
20
|
+
$: [
|
|
21
|
+
`Invalid YAML${position ? ` at ${position.line}:${position.col}` : ''}: ${issue.code}.`,
|
|
22
|
+
],
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
let refused = null;
|
|
26
|
+
visit(document, {
|
|
27
|
+
Node(_key, node) {
|
|
28
|
+
if (isAlias(node) || ('anchor' in node && node.anchor) || node.tag) {
|
|
29
|
+
refused = 'Anchors, aliases and tags are not supported.';
|
|
30
|
+
return visit.BREAK;
|
|
31
|
+
}
|
|
32
|
+
return undefined;
|
|
33
|
+
},
|
|
34
|
+
Pair(_key, pair) {
|
|
35
|
+
if (!isScalar(pair.key) || typeof pair.key.value !== 'string') {
|
|
36
|
+
refused = 'Every key must be a string.';
|
|
37
|
+
return visit.BREAK;
|
|
38
|
+
}
|
|
39
|
+
return undefined;
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
if (refused) {
|
|
43
|
+
throw bad({ $: [refused] });
|
|
44
|
+
}
|
|
45
|
+
const value = document.toJS({ maxAliasCount: 0 });
|
|
46
|
+
const fields = {};
|
|
47
|
+
const add = (path, message) => {
|
|
48
|
+
fields[path] = [...(fields[path] ?? []), message];
|
|
49
|
+
};
|
|
50
|
+
if (!isRecord(value)) {
|
|
51
|
+
throw bad({ $: ['The document must be a mapping.'] });
|
|
52
|
+
}
|
|
53
|
+
for (const [key, field] of Object.entries(value)) {
|
|
54
|
+
switch (key) {
|
|
55
|
+
case 'workspaceId':
|
|
56
|
+
case 'snapshotId':
|
|
57
|
+
if (typeof field !== 'string') {
|
|
58
|
+
add(key, 'Expected a string.');
|
|
59
|
+
}
|
|
60
|
+
break;
|
|
61
|
+
case 'name':
|
|
62
|
+
if (field !== null && typeof field !== 'string') {
|
|
63
|
+
add(key, 'Expected a string or null.');
|
|
64
|
+
}
|
|
65
|
+
break;
|
|
66
|
+
case 'tokenInUrl':
|
|
67
|
+
if (typeof field !== 'boolean') {
|
|
68
|
+
add(key, 'Expected a boolean.');
|
|
69
|
+
}
|
|
70
|
+
break;
|
|
71
|
+
case 'timeLimitMinutes':
|
|
72
|
+
if (!Number.isInteger(field)) {
|
|
73
|
+
add(key, 'Expected an integer.');
|
|
74
|
+
}
|
|
75
|
+
break;
|
|
76
|
+
case 'labels':
|
|
77
|
+
if (!isRecord(field)) {
|
|
78
|
+
add(key, 'Expected a mapping.');
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
for (const [label, text] of Object.entries(field)) {
|
|
82
|
+
if (typeof text !== 'string') {
|
|
83
|
+
add(`labels.${label}`, 'Expected a string.');
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
break;
|
|
87
|
+
case 'apps':
|
|
88
|
+
if (!Array.isArray(field)) {
|
|
89
|
+
add(key, 'Expected a list.');
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
for (const [index, app] of field.entries()) {
|
|
93
|
+
checkApp(app, `apps.${index}`, add);
|
|
94
|
+
}
|
|
95
|
+
break;
|
|
96
|
+
default:
|
|
97
|
+
add(key, 'Unknown field.');
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if ('apps' in value === 'snapshotId' in value) {
|
|
101
|
+
add('$', 'Pass exactly one of apps and snapshotId.');
|
|
102
|
+
}
|
|
103
|
+
if (Object.keys(fields).length > 0) {
|
|
104
|
+
throw bad(fields);
|
|
105
|
+
}
|
|
106
|
+
return value;
|
|
107
|
+
}
|
|
108
|
+
function checkApp(app, path, add) {
|
|
109
|
+
if (typeof app === 'string') {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
if (!isRecord(app)) {
|
|
113
|
+
add(path, 'Expected an app ID or a mapping with app.');
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
const { app: id, name, settings } = app;
|
|
117
|
+
if (typeof id !== 'string') {
|
|
118
|
+
add(`${path}.app`, 'Expected a string.');
|
|
119
|
+
}
|
|
120
|
+
if ('name' in app && typeof name !== 'string') {
|
|
121
|
+
add(`${path}.name`, 'Expected a string.');
|
|
122
|
+
}
|
|
123
|
+
if ('settings' in app && !isRecord(settings)) {
|
|
124
|
+
add(`${path}.settings`, 'Expected a mapping.');
|
|
125
|
+
}
|
|
126
|
+
for (const key of Object.keys(app)) {
|
|
127
|
+
if (!APP_FIELDS.has(key)) {
|
|
128
|
+
add(`${path}.${key}`, 'Unknown field.');
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
function isRecord(value) {
|
|
133
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
134
|
+
}
|
|
135
|
+
function bad(fields) {
|
|
136
|
+
return invalidInput('The environment YAML is invalid.', fields);
|
|
137
|
+
}
|
|
@@ -8,4 +8,4 @@ import { StateMachinesHTTPError } from "../models/errors/state-machines-http-err
|
|
|
8
8
|
import * as operations from "../models/operations/index.js";
|
|
9
9
|
import { APIPromise } from "../types/async.js";
|
|
10
10
|
import { Result } from "../types/fp.js";
|
|
11
|
-
export declare function
|
|
11
|
+
export declare function appsList(client: StateMachinesCore, request?: operations.ListAppsRequest | undefined, options?: RequestOptions): APIPromise<Result<operations.ListAppsResponse, errors.ErrorT | StateMachinesHTTPError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
|
|
@@ -0,0 +1,91 @@
|
|
|
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 appsList(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.ListAppsRequest$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/apps")();
|
|
26
|
+
const query = encodeFormQuery({
|
|
27
|
+
"cursor": payload?.cursor,
|
|
28
|
+
"limit": payload?.limit,
|
|
29
|
+
});
|
|
30
|
+
const headers = new Headers(compactMap({
|
|
31
|
+
Accept: "application/json",
|
|
32
|
+
}));
|
|
33
|
+
const secConfig = await extractSecurity(client._options.apiKey);
|
|
34
|
+
const securityInput = secConfig == null ? {} : { apiKey: secConfig };
|
|
35
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
36
|
+
const context = {
|
|
37
|
+
options: client._options,
|
|
38
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
39
|
+
operationID: "listApps",
|
|
40
|
+
oAuth2Scopes: null,
|
|
41
|
+
resolvedSecurity: requestSecurity,
|
|
42
|
+
securitySource: client._options.apiKey,
|
|
43
|
+
retryConfig: options?.retries
|
|
44
|
+
|| client._options.retryConfig
|
|
45
|
+
|| {
|
|
46
|
+
strategy: "backoff",
|
|
47
|
+
backoff: {
|
|
48
|
+
initialInterval: 1000,
|
|
49
|
+
maxInterval: 5000,
|
|
50
|
+
exponent: 1.5,
|
|
51
|
+
maxElapsedTime: 600000,
|
|
52
|
+
},
|
|
53
|
+
retryConnectionErrors: true,
|
|
54
|
+
}
|
|
55
|
+
|| { strategy: "none" },
|
|
56
|
+
retryCodes: options?.retryCodes || ["502", "503", "504"],
|
|
57
|
+
};
|
|
58
|
+
const requestRes = client._createRequest(context, {
|
|
59
|
+
security: requestSecurity,
|
|
60
|
+
method: "GET",
|
|
61
|
+
baseURL: options?.serverURL,
|
|
62
|
+
path: path,
|
|
63
|
+
headers: headers,
|
|
64
|
+
query: query,
|
|
65
|
+
body: body,
|
|
66
|
+
userAgent: client._options.userAgent,
|
|
67
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
68
|
+
}, options);
|
|
69
|
+
if (!requestRes.ok) {
|
|
70
|
+
return [requestRes, { status: "invalid" }];
|
|
71
|
+
}
|
|
72
|
+
const req = requestRes.value;
|
|
73
|
+
const doResult = await client._do(req, {
|
|
74
|
+
context,
|
|
75
|
+
isErrorStatusCode: (statusCode) => matchStatusCode({ status: statusCode }, ["4XX", "5XX"]),
|
|
76
|
+
retryConfig: context.retryConfig,
|
|
77
|
+
retryCodes: context.retryCodes,
|
|
78
|
+
});
|
|
79
|
+
if (!doResult.ok) {
|
|
80
|
+
return [doResult, { status: "request-error", request: req }];
|
|
81
|
+
}
|
|
82
|
+
const response = doResult.value;
|
|
83
|
+
const responseFields = {
|
|
84
|
+
HttpMeta: { Response: response, Request: req },
|
|
85
|
+
};
|
|
86
|
+
const [result] = await M.match(M.json(200, operations.ListAppsResponse$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 });
|
|
87
|
+
if (!result.ok) {
|
|
88
|
+
return [result, { status: "complete", request: req, response }];
|
|
89
|
+
}
|
|
90
|
+
return [result, { status: "complete", request: req, response }];
|
|
91
|
+
}
|
|
@@ -8,4 +8,4 @@ import { StateMachinesHTTPError } from "../models/errors/state-machines-http-err
|
|
|
8
8
|
import * as operations from "../models/operations/index.js";
|
|
9
9
|
import { APIPromise } from "../types/async.js";
|
|
10
10
|
import { Result } from "../types/fp.js";
|
|
11
|
-
export declare function
|
|
11
|
+
export declare function appsVersions(client: StateMachinesCore, request: operations.ListVersionsRequest, options?: RequestOptions): APIPromise<Result<operations.ListVersionsResponse, errors.ErrorT | StateMachinesHTTPError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
|
|
@@ -10,26 +10,25 @@ import { safeParse } from "../lib/schemas.js";
|
|
|
10
10
|
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
11
11
|
import { pathToFunc } from "../lib/url.js";
|
|
12
12
|
import * as errors from "../models/errors/index.js";
|
|
13
|
-
import * as models from "../models/index.js";
|
|
14
13
|
import * as operations from "../models/operations/index.js";
|
|
15
14
|
import { APIPromise } from "../types/async.js";
|
|
16
|
-
export function
|
|
15
|
+
export function appsVersions(client, request, options) {
|
|
17
16
|
return new APIPromise($do(client, request, options));
|
|
18
17
|
}
|
|
19
18
|
async function $do(client, request, options) {
|
|
20
|
-
const parsed = safeParse(request, (value) => z.parse(operations.
|
|
19
|
+
const parsed = safeParse(request, (value) => z.parse(operations.ListVersionsRequest$outboundSchema, value), "Input validation failed");
|
|
21
20
|
if (!parsed.ok) {
|
|
22
21
|
return [parsed, { status: "invalid" }];
|
|
23
22
|
}
|
|
24
23
|
const payload = parsed.value;
|
|
25
24
|
const body = null;
|
|
26
25
|
const pathParams = {
|
|
27
|
-
|
|
26
|
+
appId: encodeSimple("appId", payload.appId, {
|
|
28
27
|
explode: false,
|
|
29
28
|
charEncoding: "percent",
|
|
30
29
|
}),
|
|
31
30
|
};
|
|
32
|
-
const path = pathToFunc("/v1/
|
|
31
|
+
const path = pathToFunc("/v1/apps/{appId}/versions")(pathParams);
|
|
33
32
|
const query = encodeFormQuery({
|
|
34
33
|
"cursor": payload.cursor,
|
|
35
34
|
"limit": payload.limit,
|
|
@@ -43,7 +42,7 @@ async function $do(client, request, options) {
|
|
|
43
42
|
const context = {
|
|
44
43
|
options: client._options,
|
|
45
44
|
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
46
|
-
operationID: "
|
|
45
|
+
operationID: "listVersions",
|
|
47
46
|
oAuth2Scopes: null,
|
|
48
47
|
resolvedSecurity: requestSecurity,
|
|
49
48
|
securitySource: client._options.apiKey,
|
|
@@ -90,7 +89,7 @@ async function $do(client, request, options) {
|
|
|
90
89
|
const responseFields = {
|
|
91
90
|
HttpMeta: { Response: response, Request: req },
|
|
92
91
|
};
|
|
93
|
-
const [result] = await M.match(M.json(200,
|
|
92
|
+
const [result] = await M.match(M.json(200, operations.ListVersionsResponse$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 });
|
|
94
93
|
if (!result.ok) {
|
|
95
94
|
return [result, { status: "complete", request: req, response }];
|
|
96
95
|
}
|
|
@@ -8,4 +8,4 @@ import { StateMachinesHTTPError } from "../models/errors/state-machines-http-err
|
|
|
8
8
|
import * as operations from "../models/operations/index.js";
|
|
9
9
|
import { APIPromise } from "../types/async.js";
|
|
10
10
|
import { Result } from "../types/fp.js";
|
|
11
|
-
export declare function
|
|
11
|
+
export declare function auditEventsList(client: StateMachinesCore, request?: operations.ListAuditEventsRequest | undefined, options?: RequestOptions): APIPromise<Result<operations.ListAuditEventsResponse, errors.ErrorT | StateMachinesHTTPError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
|
|
@@ -0,0 +1,93 @@
|
|
|
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 auditEventsList(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.ListAuditEventsRequest$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/audit-events")();
|
|
26
|
+
const query = encodeFormQuery({
|
|
27
|
+
"cursor": payload?.cursor,
|
|
28
|
+
"environmentId": payload?.environmentId,
|
|
29
|
+
"limit": payload?.limit,
|
|
30
|
+
"workspaceId": payload?.workspaceId,
|
|
31
|
+
});
|
|
32
|
+
const headers = new Headers(compactMap({
|
|
33
|
+
Accept: "application/json",
|
|
34
|
+
}));
|
|
35
|
+
const secConfig = await extractSecurity(client._options.apiKey);
|
|
36
|
+
const securityInput = secConfig == null ? {} : { apiKey: secConfig };
|
|
37
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
38
|
+
const context = {
|
|
39
|
+
options: client._options,
|
|
40
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
41
|
+
operationID: "listAuditEvents",
|
|
42
|
+
oAuth2Scopes: null,
|
|
43
|
+
resolvedSecurity: requestSecurity,
|
|
44
|
+
securitySource: client._options.apiKey,
|
|
45
|
+
retryConfig: options?.retries
|
|
46
|
+
|| client._options.retryConfig
|
|
47
|
+
|| {
|
|
48
|
+
strategy: "backoff",
|
|
49
|
+
backoff: {
|
|
50
|
+
initialInterval: 1000,
|
|
51
|
+
maxInterval: 5000,
|
|
52
|
+
exponent: 1.5,
|
|
53
|
+
maxElapsedTime: 600000,
|
|
54
|
+
},
|
|
55
|
+
retryConnectionErrors: true,
|
|
56
|
+
}
|
|
57
|
+
|| { strategy: "none" },
|
|
58
|
+
retryCodes: options?.retryCodes || ["502", "503", "504"],
|
|
59
|
+
};
|
|
60
|
+
const requestRes = client._createRequest(context, {
|
|
61
|
+
security: requestSecurity,
|
|
62
|
+
method: "GET",
|
|
63
|
+
baseURL: options?.serverURL,
|
|
64
|
+
path: path,
|
|
65
|
+
headers: headers,
|
|
66
|
+
query: query,
|
|
67
|
+
body: body,
|
|
68
|
+
userAgent: client._options.userAgent,
|
|
69
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
70
|
+
}, options);
|
|
71
|
+
if (!requestRes.ok) {
|
|
72
|
+
return [requestRes, { status: "invalid" }];
|
|
73
|
+
}
|
|
74
|
+
const req = requestRes.value;
|
|
75
|
+
const doResult = await client._do(req, {
|
|
76
|
+
context,
|
|
77
|
+
isErrorStatusCode: (statusCode) => matchStatusCode({ status: statusCode }, ["4XX", "5XX"]),
|
|
78
|
+
retryConfig: context.retryConfig,
|
|
79
|
+
retryCodes: context.retryCodes,
|
|
80
|
+
});
|
|
81
|
+
if (!doResult.ok) {
|
|
82
|
+
return [doResult, { status: "request-error", request: req }];
|
|
83
|
+
}
|
|
84
|
+
const response = doResult.value;
|
|
85
|
+
const responseFields = {
|
|
86
|
+
HttpMeta: { Response: response, Request: req },
|
|
87
|
+
};
|
|
88
|
+
const [result] = await M.match(M.json(200, operations.ListAuditEventsResponse$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 });
|
|
89
|
+
if (!result.ok) {
|
|
90
|
+
return [result, { status: "complete", request: req, response }];
|
|
91
|
+
}
|
|
92
|
+
return [result, { status: "complete", request: req, response }];
|
|
93
|
+
}
|
|
@@ -9,4 +9,4 @@ import * as models from "../models/index.js";
|
|
|
9
9
|
import * as operations from "../models/operations/index.js";
|
|
10
10
|
import { APIPromise } from "../types/async.js";
|
|
11
11
|
import { Result } from "../types/fp.js";
|
|
12
|
-
export declare function
|
|
12
|
+
export declare function environmentsConnect(client: StateMachinesCore, request: operations.CreateCredentialsRequest, options?: RequestOptions): APIPromise<Result<models.Credentials, errors.ErrorT | StateMachinesHTTPError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
|
|
@@ -10,20 +10,21 @@ import { safeParse } from "../lib/schemas.js";
|
|
|
10
10
|
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
11
11
|
import { pathToFunc } from "../lib/url.js";
|
|
12
12
|
import * as errors from "../models/errors/index.js";
|
|
13
|
+
import * as models from "../models/index.js";
|
|
13
14
|
import * as operations from "../models/operations/index.js";
|
|
14
15
|
import { APIPromise } from "../types/async.js";
|
|
15
|
-
export function
|
|
16
|
+
export function environmentsConnect(client, request, options) {
|
|
16
17
|
return new APIPromise($do(client, request, options));
|
|
17
18
|
}
|
|
18
19
|
async function $do(client, request, options) {
|
|
19
|
-
const parsed = safeParse(request, (value) => z.parse(operations.
|
|
20
|
+
const parsed = safeParse(request, (value) => z.parse(operations.CreateCredentialsRequest$outboundSchema, value), "Input validation failed");
|
|
20
21
|
if (!parsed.ok) {
|
|
21
22
|
return [parsed, { status: "invalid" }];
|
|
22
23
|
}
|
|
23
24
|
const payload = parsed.value;
|
|
24
25
|
const body = encodeJSON("body", payload.body, { explode: true });
|
|
25
26
|
const pathParams = {
|
|
26
|
-
|
|
27
|
+
appName: encodeSimple("appName", payload.appName, {
|
|
27
28
|
explode: false,
|
|
28
29
|
charEncoding: "percent",
|
|
29
30
|
}),
|
|
@@ -32,7 +33,7 @@ async function $do(client, request, options) {
|
|
|
32
33
|
charEncoding: "percent",
|
|
33
34
|
}),
|
|
34
35
|
};
|
|
35
|
-
const path = pathToFunc("/v1/environments/{environmentId}/apps/{
|
|
36
|
+
const path = pathToFunc("/v1/environments/{environmentId}/apps/{appName}/credentials")(pathParams);
|
|
36
37
|
const headers = new Headers(compactMap({
|
|
37
38
|
"Content-Type": "application/json",
|
|
38
39
|
Accept: "application/json",
|
|
@@ -43,7 +44,7 @@ async function $do(client, request, options) {
|
|
|
43
44
|
const context = {
|
|
44
45
|
options: client._options,
|
|
45
46
|
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
46
|
-
operationID: "
|
|
47
|
+
operationID: "createCredentials",
|
|
47
48
|
oAuth2Scopes: null,
|
|
48
49
|
resolvedSecurity: requestSecurity,
|
|
49
50
|
securitySource: client._options.apiKey,
|
|
@@ -89,7 +90,7 @@ async function $do(client, request, options) {
|
|
|
89
90
|
const responseFields = {
|
|
90
91
|
HttpMeta: { Response: response, Request: req },
|
|
91
92
|
};
|
|
92
|
-
const [result] = await M.match(M.json(200,
|
|
93
|
+
const [result] = await M.match(M.json(200, models.Credentials$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 });
|
|
93
94
|
if (!result.ok) {
|
|
94
95
|
return [result, { status: "complete", request: req, response }];
|
|
95
96
|
}
|
|
@@ -5,7 +5,8 @@ import * as errors from "../models/errors/index.js";
|
|
|
5
5
|
import { ResponseValidationError } from "../models/errors/response-validation-error.js";
|
|
6
6
|
import { SDKValidationError } from "../models/errors/sdk-validation-error.js";
|
|
7
7
|
import { StateMachinesHTTPError } from "../models/errors/state-machines-http-error.js";
|
|
8
|
+
import * as models from "../models/index.js";
|
|
8
9
|
import * as operations from "../models/operations/index.js";
|
|
9
10
|
import { APIPromise } from "../types/async.js";
|
|
10
11
|
import { Result } from "../types/fp.js";
|
|
11
|
-
export declare function environmentsCreate(client: StateMachinesCore, request: operations.
|
|
12
|
+
export declare function environmentsCreate(client: StateMachinesCore, request: operations.CreateEnvironmentRequest, options?: RequestOptions): APIPromise<Result<models.Environment, errors.ErrorT | StateMachinesHTTPError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
|