@kestra-io/kestra-sdk 2.0.0-dev.4bc905a7.0b725cca → 2.0.0-dev.4bc905a7.6706a2d2
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 +147 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -2
- package/package.json +3 -2
package/README.md
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# JavaScript SDK
|
|
2
|
+
|
|
3
|
+
## Steps to generate the SDK
|
|
4
|
+
|
|
5
|
+
1. Update the `kestra-ee.yml` if necessary with latest openspec api changes.
|
|
6
|
+
2. Generate the SDK using the script `generate-sdks.sh` that uses the openapi-generator-cli docker image.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install @kestra-io/kestra-sdk
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
The SDK is organized into domain-specific modules (e.g. `flows`, `executions`, `apps`, `plugins`). Import only the modules you need to keep your bundle lean and benefit from tree-shaking.
|
|
17
|
+
|
|
18
|
+
### Configure the client
|
|
19
|
+
|
|
20
|
+
Import and configure the shared HTTP client once, at the entry point of your application:
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import { client } from "@kestra-io/kestra-sdk/client";
|
|
24
|
+
|
|
25
|
+
client.setConfig({
|
|
26
|
+
baseURL: "https://<your-kestra-host>",
|
|
27
|
+
auth: () => "<username>:<password>",
|
|
28
|
+
});
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
For token-based authentication, pass the token directly:
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
client.setConfig({
|
|
35
|
+
baseURL: "https://<your-kestra-host>",
|
|
36
|
+
auth: () => "<your-api-token>",
|
|
37
|
+
});
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Import domain modules
|
|
41
|
+
|
|
42
|
+
Each domain is a separate entry point. Import them with a namespace alias to keep call sites readable:
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
import * as FlowsAPI from "@kestra-io/kestra-sdk/flows";
|
|
46
|
+
import * as ExecutionsAPI from "@kestra-io/kestra-sdk/executions";
|
|
47
|
+
import * as AppsAPI from "@kestra-io/kestra-sdk/apps";
|
|
48
|
+
import * as PluginsAPI from "@kestra-io/kestra-sdk/plugins";
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Other available domains:
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
import * as AiAPI from "@kestra-io/kestra-sdk/ai";
|
|
55
|
+
import * as AssetsAPI from "@kestra-io/kestra-sdk/assets";
|
|
56
|
+
import * as AuditLogsAPI from "@kestra-io/kestra-sdk/audit-logs";
|
|
57
|
+
import * as AuthsAPI from "@kestra-io/kestra-sdk/auths";
|
|
58
|
+
import * as BannersAPI from "@kestra-io/kestra-sdk/banners";
|
|
59
|
+
import * as BindingsAPI from "@kestra-io/kestra-sdk/bindings";
|
|
60
|
+
import * as BlueprintTagsAPI from "@kestra-io/kestra-sdk/blueprint-tags";
|
|
61
|
+
import * as BlueprintsAPI from "@kestra-io/kestra-sdk/blueprints";
|
|
62
|
+
import * as ClusterAPI from "@kestra-io/kestra-sdk/cluster";
|
|
63
|
+
import * as DashboardsAPI from "@kestra-io/kestra-sdk/dashboards";
|
|
64
|
+
import * as FilesAPI from "@kestra-io/kestra-sdk/files";
|
|
65
|
+
import * as GroupsAPI from "@kestra-io/kestra-sdk/groups";
|
|
66
|
+
import * as InvitationsAPI from "@kestra-io/kestra-sdk/invitations";
|
|
67
|
+
import * as KillSwitchesAPI from "@kestra-io/kestra-sdk/kill-switches";
|
|
68
|
+
import * as KvAPI from "@kestra-io/kestra-sdk/kv";
|
|
69
|
+
import * as LoginAPI from "@kestra-io/kestra-sdk/login";
|
|
70
|
+
import * as LogsAPI from "@kestra-io/kestra-sdk/logs";
|
|
71
|
+
import * as MetricsAPI from "@kestra-io/kestra-sdk/metrics";
|
|
72
|
+
import * as MiscAPI from "@kestra-io/kestra-sdk/misc";
|
|
73
|
+
import * as NamespacesAPI from "@kestra-io/kestra-sdk/namespaces";
|
|
74
|
+
import * as OutputsAPI from "@kestra-io/kestra-sdk/outputs";
|
|
75
|
+
import * as RolesAPI from "@kestra-io/kestra-sdk/roles";
|
|
76
|
+
import * as ScimConfigurationAPI from "@kestra-io/kestra-sdk/scim-configuration";
|
|
77
|
+
import * as ScimGroupsAPI from "@kestra-io/kestra-sdk/scim-groups";
|
|
78
|
+
import * as ScimUsersAPI from "@kestra-io/kestra-sdk/scim-users";
|
|
79
|
+
import * as SecretsAPI from "@kestra-io/kestra-sdk/secrets";
|
|
80
|
+
import * as SecurityIntegrationsAPI from "@kestra-io/kestra-sdk/security-integrations";
|
|
81
|
+
import * as ServiceAccountAPI from "@kestra-io/kestra-sdk/service-account";
|
|
82
|
+
import * as ServicesAPI from "@kestra-io/kestra-sdk/services";
|
|
83
|
+
import * as SharedAPI from "@kestra-io/kestra-sdk/shared";
|
|
84
|
+
import * as TenantAccessAPI from "@kestra-io/kestra-sdk/tenant-access";
|
|
85
|
+
import * as TenantsAPI from "@kestra-io/kestra-sdk/tenants";
|
|
86
|
+
import * as TestSuitesAPI from "@kestra-io/kestra-sdk/test-suites";
|
|
87
|
+
import * as TriggersAPI from "@kestra-io/kestra-sdk/triggers";
|
|
88
|
+
import * as UsersAPI from "@kestra-io/kestra-sdk/users";
|
|
89
|
+
import * as WorkerAuthAPI from "@kestra-io/kestra-sdk/worker-auth";
|
|
90
|
+
import * as WorkerGroupsAPI from "@kestra-io/kestra-sdk/worker-groups";
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Example: search and create a flow
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
import { client } from "@kestra-io/kestra-sdk/client";
|
|
97
|
+
import * as FlowsAPI from "@kestra-io/kestra-sdk/flows";
|
|
98
|
+
|
|
99
|
+
client.setConfig({
|
|
100
|
+
baseURL: "https://<your-kestra-host>",
|
|
101
|
+
auth: () => "root@root.com:Root!1234",
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
const tenantId = "main";
|
|
105
|
+
|
|
106
|
+
// Search flows
|
|
107
|
+
const searchRes = await FlowsAPI.searchFlows({
|
|
108
|
+
page: 1,
|
|
109
|
+
size: 10,
|
|
110
|
+
tenant: tenantId,
|
|
111
|
+
});
|
|
112
|
+
console.log(searchRes.data);
|
|
113
|
+
|
|
114
|
+
// Create a flow
|
|
115
|
+
const createRes = await FlowsAPI.createFlow({
|
|
116
|
+
tenant: tenantId,
|
|
117
|
+
body: `
|
|
118
|
+
id: hello-world
|
|
119
|
+
namespace: my.namespace
|
|
120
|
+
|
|
121
|
+
tasks:
|
|
122
|
+
- id: hello
|
|
123
|
+
type: io.kestra.plugin.core.log.Log
|
|
124
|
+
message: Hello World! 🚀
|
|
125
|
+
`,
|
|
126
|
+
});
|
|
127
|
+
console.log(createRes.data);
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Example: trigger an execution
|
|
131
|
+
|
|
132
|
+
```ts
|
|
133
|
+
import { client } from "@kestra-io/kestra-sdk/client";
|
|
134
|
+
import * as ExecutionsAPI from "@kestra-io/kestra-sdk/executions";
|
|
135
|
+
|
|
136
|
+
client.setConfig({
|
|
137
|
+
baseURL: "https://<your-kestra-host>",
|
|
138
|
+
auth: () => "root@root.com:Root!1234",
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
const execution = await ExecutionsAPI.createExecution({
|
|
142
|
+
tenant: "main",
|
|
143
|
+
namespace: "my.namespace",
|
|
144
|
+
id: "hello-world",
|
|
145
|
+
});
|
|
146
|
+
console.log(execution.data);
|
|
147
|
+
```
|
package/dist/index.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ declare const configureAxios: (clientConfig?: Config<ClientOptions$1>, options?:
|
|
|
23
23
|
name: string;
|
|
24
24
|
query?: Record<string, string>;
|
|
25
25
|
}) => void;
|
|
26
|
-
beforeEach: (callback: (to: any, from: any
|
|
26
|
+
beforeEach: (callback: (to: any, from: any) => void) => void;
|
|
27
27
|
afterEach: (callback: () => void) => void;
|
|
28
28
|
};
|
|
29
29
|
coreStore?: {
|
package/dist/index.js
CHANGED
|
@@ -197,11 +197,10 @@ const configureAxios = (clientConfig = {}, options = {}) => {
|
|
|
197
197
|
}
|
|
198
198
|
return Promise.reject(errorResponse);
|
|
199
199
|
});
|
|
200
|
-
router?.beforeEach((
|
|
200
|
+
router?.beforeEach(() => {
|
|
201
201
|
if (pendingRoute) requestsTotal--;
|
|
202
202
|
pendingRoute = true;
|
|
203
203
|
initProgress();
|
|
204
|
-
next();
|
|
205
204
|
});
|
|
206
205
|
router?.afterEach(() => {
|
|
207
206
|
if (pendingRoute) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kestra-io/kestra-sdk",
|
|
3
|
-
"version": "2.0.0-dev.4bc905a7.
|
|
3
|
+
"version": "2.0.0-dev.4bc905a7.6706a2d2",
|
|
4
4
|
"description": "All API operations, except for Superadmin-only endpoints, require a tenant identifier in the HTTP path.<br/> Endpoints designated as Superadmin-only are not tenant-scoped.",
|
|
5
5
|
"license": "Unlicense",
|
|
6
6
|
"type": "module",
|
|
@@ -59,7 +59,8 @@
|
|
|
59
59
|
"dev": "node scripts/dev.mjs",
|
|
60
60
|
"typecheck": "vue-tsc --noEmit",
|
|
61
61
|
"generate:openapi": "openapi-ts",
|
|
62
|
-
"prebuild": "openapi-ts"
|
|
62
|
+
"prebuild": "openapi-ts",
|
|
63
|
+
"prepack": "cp ../../README_JAVASCRIPT_SDK.md README.md"
|
|
63
64
|
},
|
|
64
65
|
"dependencies": {
|
|
65
66
|
"nprogress": "0.2.0",
|