@onkernel/sdk 0.1.0-alpha.1 → 0.1.0-alpha.11
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/CHANGELOG.md +84 -0
- package/README.md +34 -45
- package/client.d.mts +28 -6
- package/client.d.mts.map +1 -1
- package/client.d.ts +28 -6
- package/client.d.ts.map +1 -1
- package/client.js +28 -8
- package/client.js.map +1 -1
- package/client.mjs +28 -8
- package/client.mjs.map +1 -1
- package/core/app-framework.d.mts +49 -0
- package/core/app-framework.d.mts.map +1 -0
- package/core/app-framework.d.ts +49 -0
- package/core/app-framework.d.ts.map +1 -0
- package/core/app-framework.js +105 -0
- package/core/app-framework.js.map +1 -0
- package/core/app-framework.mjs +101 -0
- package/core/app-framework.mjs.map +1 -0
- package/index.d.mts +1 -0
- package/index.d.mts.map +1 -1
- package/index.d.ts +1 -0
- package/index.d.ts.map +1 -1
- package/index.js +3 -1
- package/index.js.map +1 -1
- package/index.mjs +1 -0
- package/index.mjs.map +1 -1
- package/internal/headers.js +1 -1
- package/internal/headers.js.map +1 -1
- package/internal/headers.mjs +1 -1
- package/internal/headers.mjs.map +1 -1
- package/internal/tslib.js +17 -17
- package/package.json +1 -4
- package/resources/apps/apps.d.mts +14 -0
- package/resources/apps/apps.d.mts.map +1 -0
- package/resources/apps/apps.d.ts +14 -0
- package/resources/apps/apps.d.ts.map +1 -0
- package/resources/apps/apps.js +21 -0
- package/resources/apps/apps.js.map +1 -0
- package/resources/apps/apps.mjs +16 -0
- package/resources/apps/apps.mjs.map +1 -0
- package/resources/apps/deployments.d.mts +82 -0
- package/resources/apps/deployments.d.mts.map +1 -0
- package/resources/apps/deployments.d.ts +82 -0
- package/resources/apps/deployments.d.ts.map +1 -0
- package/resources/apps/deployments.js +24 -0
- package/resources/apps/deployments.js.map +1 -0
- package/resources/apps/deployments.mjs +20 -0
- package/resources/apps/deployments.mjs.map +1 -0
- package/resources/apps/index.d.mts +4 -0
- package/resources/apps/index.d.mts.map +1 -0
- package/resources/apps/index.d.ts +4 -0
- package/resources/apps/index.d.ts.map +1 -0
- package/resources/apps/index.js +11 -0
- package/resources/apps/index.js.map +1 -0
- package/resources/apps/index.mjs +5 -0
- package/resources/apps/index.mjs.map +1 -0
- package/resources/apps/invocations.d.mts +110 -0
- package/resources/apps/invocations.d.mts.map +1 -0
- package/resources/apps/invocations.d.ts +110 -0
- package/resources/apps/invocations.d.ts.map +1 -0
- package/resources/apps/invocations.js +38 -0
- package/resources/apps/invocations.js.map +1 -0
- package/resources/apps/invocations.mjs +34 -0
- package/resources/apps/invocations.mjs.map +1 -0
- package/resources/apps.d.mts +1 -111
- package/resources/apps.d.mts.map +1 -1
- package/resources/apps.d.ts +1 -111
- package/resources/apps.d.ts.map +1 -1
- package/resources/apps.js +2 -50
- package/resources/apps.js.map +1 -1
- package/resources/apps.mjs +1 -48
- package/resources/apps.mjs.map +1 -1
- package/resources/browsers.d.mts +65 -0
- package/resources/browsers.d.mts.map +1 -0
- package/resources/browsers.d.ts +65 -0
- package/resources/browsers.d.ts.map +1 -0
- package/resources/browsers.js +36 -0
- package/resources/browsers.js.map +1 -0
- package/resources/browsers.mjs +32 -0
- package/resources/browsers.mjs.map +1 -0
- package/resources/index.d.mts +2 -2
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +2 -2
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +4 -4
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +2 -2
- package/resources/index.mjs.map +1 -1
- package/src/client.ts +53 -22
- package/src/core/app-framework.ts +137 -0
- package/src/index.ts +2 -0
- package/src/internal/headers.ts +1 -1
- package/src/resources/apps/apps.ts +35 -0
- package/src/resources/apps/deployments.ts +103 -0
- package/src/resources/apps/index.ts +10 -0
- package/src/resources/apps/invocations.ts +140 -0
- package/src/resources/apps.ts +1 -148
- package/src/resources/browsers.ts +85 -0
- package/src/resources/index.ts +6 -8
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.mts.map +1 -1
- package/version.d.ts +1 -1
- package/version.d.ts.map +1 -1
- package/version.js +1 -1
- package/version.js.map +1 -1
- package/version.mjs +1 -1
- package/version.mjs.map +1 -1
- package/resources/browser.d.mts +0 -27
- package/resources/browser.d.mts.map +0 -1
- package/resources/browser.d.ts +0 -27
- package/resources/browser.d.ts.map +0 -1
- package/resources/browser.js +0 -15
- package/resources/browser.js.map +0 -1
- package/resources/browser.mjs +0 -11
- package/resources/browser.mjs.map +0 -1
- package/src/resources/browser.ts +0 -35
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/resources/index.ts"],"names":[],"mappings":"OAEO,
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/resources/index.ts"],"names":[],"mappings":"OAEO,EAAE,IAAI,EAAE;OACR,EACL,QAAQ,EACR,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,GACzB"}
|
package/resources/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { Apps
|
|
2
|
-
export {
|
|
1
|
+
export { Apps } from "./apps/apps.js";
|
|
2
|
+
export { Browsers, type BrowserCreateResponse, type BrowserRetrieveResponse, type BrowserCreateParams, } from "./browsers.js";
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/resources/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/resources/index.ts"],"names":[],"mappings":"OAEO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/resources/index.ts"],"names":[],"mappings":"OAEO,EAAE,IAAI,EAAE;OACR,EACL,QAAQ,EACR,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,GACzB"}
|
package/resources/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.
|
|
5
|
-
var apps_1 = require("./apps.js");
|
|
4
|
+
exports.Browsers = exports.Apps = void 0;
|
|
5
|
+
var apps_1 = require("./apps/apps.js");
|
|
6
6
|
Object.defineProperty(exports, "Apps", { enumerable: true, get: function () { return apps_1.Apps; } });
|
|
7
|
-
var
|
|
8
|
-
Object.defineProperty(exports, "
|
|
7
|
+
var browsers_1 = require("./browsers.js");
|
|
8
|
+
Object.defineProperty(exports, "Browsers", { enumerable: true, get: function () { return browsers_1.Browsers; } });
|
|
9
9
|
//# sourceMappingURL=index.js.map
|
package/resources/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/resources/index.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/resources/index.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,uCAAmC;AAA1B,4FAAA,IAAI,OAAA;AACb,0CAKoB;AAJlB,oGAAA,QAAQ,OAAA"}
|
package/resources/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
-
export { Apps
|
|
3
|
-
export {
|
|
2
|
+
export { Apps } from "./apps/apps.mjs";
|
|
3
|
+
export { Browsers, } from "./browsers.mjs";
|
|
4
4
|
//# sourceMappingURL=index.mjs.map
|
package/resources/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/resources/index.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/resources/index.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,IAAI,EAAE;OACR,EACL,QAAQ,GAIT"}
|
package/src/client.ts
CHANGED
|
@@ -21,17 +21,22 @@ import { type Fetch } from './internal/builtin-types';
|
|
|
21
21
|
import { HeadersLike, NullableHeaders, buildHeaders } from './internal/headers';
|
|
22
22
|
import { FinalRequestOptions, RequestOptions } from './internal/request-options';
|
|
23
23
|
import {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
Apps,
|
|
30
|
-
} from './resources/apps';
|
|
31
|
-
import { Browser, BrowserCreateSessionResponse } from './resources/browser';
|
|
24
|
+
BrowserCreateParams,
|
|
25
|
+
BrowserCreateResponse,
|
|
26
|
+
BrowserRetrieveResponse,
|
|
27
|
+
Browsers,
|
|
28
|
+
} from './resources/browsers';
|
|
32
29
|
import { readEnv } from './internal/utils/env';
|
|
33
30
|
import { formatRequestDetails, loggerFor } from './internal/utils/log';
|
|
34
31
|
import { isEmptyObj } from './internal/utils/values';
|
|
32
|
+
import { KernelApp } from './core/app-framework';
|
|
33
|
+
import { Apps } from './resources/apps/apps';
|
|
34
|
+
|
|
35
|
+
const environments = {
|
|
36
|
+
production: 'https://api.onkernel.com/',
|
|
37
|
+
development: 'https://localhost:3001/',
|
|
38
|
+
};
|
|
39
|
+
type Environment = keyof typeof environments;
|
|
35
40
|
|
|
36
41
|
export interface ClientOptions {
|
|
37
42
|
/**
|
|
@@ -39,6 +44,15 @@ export interface ClientOptions {
|
|
|
39
44
|
*/
|
|
40
45
|
apiKey?: string | undefined;
|
|
41
46
|
|
|
47
|
+
/**
|
|
48
|
+
* Specifies the environment to use for the API.
|
|
49
|
+
*
|
|
50
|
+
* Each environment maps to a different base URL:
|
|
51
|
+
* - `production` corresponds to `https://api.onkernel.com/`
|
|
52
|
+
* - `development` corresponds to `https://localhost:3001/`
|
|
53
|
+
*/
|
|
54
|
+
environment?: Environment | undefined;
|
|
55
|
+
|
|
42
56
|
/**
|
|
43
57
|
* Override the default base URL for the API, e.g., "https://api.example.com/v2/"
|
|
44
58
|
*
|
|
@@ -128,7 +142,8 @@ export class Kernel {
|
|
|
128
142
|
* API Client for interfacing with the Kernel API.
|
|
129
143
|
*
|
|
130
144
|
* @param {string | undefined} [opts.apiKey=process.env['KERNEL_API_KEY'] ?? undefined]
|
|
131
|
-
* @param {
|
|
145
|
+
* @param {Environment} [opts.environment=production] - Specifies the environment URL to use for the API.
|
|
146
|
+
* @param {string} [opts.baseURL=process.env['KERNEL_BASE_URL'] ?? https://api.onkernel.com/] - Override the default base URL for the API.
|
|
132
147
|
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
|
|
133
148
|
* @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls.
|
|
134
149
|
* @param {Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
|
|
@@ -150,10 +165,17 @@ export class Kernel {
|
|
|
150
165
|
const options: ClientOptions = {
|
|
151
166
|
apiKey,
|
|
152
167
|
...opts,
|
|
153
|
-
baseURL
|
|
168
|
+
baseURL,
|
|
169
|
+
environment: opts.environment ?? 'production',
|
|
154
170
|
};
|
|
155
171
|
|
|
156
|
-
|
|
172
|
+
if (baseURL && opts.environment) {
|
|
173
|
+
throw new Errors.KernelError(
|
|
174
|
+
'Ambiguous URL; The `baseURL` option (or KERNEL_BASE_URL env var) and the `environment` option are given. If you want to use the environment you must pass baseURL: null',
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
this.baseURL = options.baseURL || environments[options.environment || 'production'];
|
|
157
179
|
this.timeout = options.timeout ?? Kernel.DEFAULT_TIMEOUT /* 1 minute */;
|
|
158
180
|
this.logger = options.logger ?? console;
|
|
159
181
|
const defaultLogLevel = 'warn';
|
|
@@ -179,7 +201,8 @@ export class Kernel {
|
|
|
179
201
|
withOptions(options: Partial<ClientOptions>): this {
|
|
180
202
|
return new (this.constructor as any as new (props: ClientOptions) => typeof this)({
|
|
181
203
|
...this._options,
|
|
182
|
-
|
|
204
|
+
environment: options.environment ? options.environment : undefined,
|
|
205
|
+
baseURL: options.environment ? undefined : this.baseURL,
|
|
183
206
|
maxRetries: this.maxRetries,
|
|
184
207
|
timeout: this.timeout,
|
|
185
208
|
logger: this.logger,
|
|
@@ -680,6 +703,16 @@ export class Kernel {
|
|
|
680
703
|
}
|
|
681
704
|
}
|
|
682
705
|
|
|
706
|
+
/**
|
|
707
|
+
* Create a new KernelApp instance.
|
|
708
|
+
*
|
|
709
|
+
* @param name - The name of the app to create.
|
|
710
|
+
* @returns A new KernelApp instance you can attach actions to.
|
|
711
|
+
*/
|
|
712
|
+
public app(name: string): KernelApp {
|
|
713
|
+
return new KernelApp(name);
|
|
714
|
+
}
|
|
715
|
+
|
|
683
716
|
static Kernel = this;
|
|
684
717
|
static DEFAULT_TIMEOUT = 60000; // 1 minute
|
|
685
718
|
|
|
@@ -700,21 +733,19 @@ export class Kernel {
|
|
|
700
733
|
static toFile = Uploads.toFile;
|
|
701
734
|
|
|
702
735
|
apps: API.Apps = new API.Apps(this);
|
|
703
|
-
|
|
736
|
+
browsers: API.Browsers = new API.Browsers(this);
|
|
704
737
|
}
|
|
705
738
|
Kernel.Apps = Apps;
|
|
706
|
-
Kernel.
|
|
739
|
+
Kernel.Browsers = Browsers;
|
|
707
740
|
export declare namespace Kernel {
|
|
708
741
|
export type RequestOptions = Opts.RequestOptions;
|
|
709
742
|
|
|
743
|
+
export { Apps as Apps };
|
|
744
|
+
|
|
710
745
|
export {
|
|
711
|
-
|
|
712
|
-
type
|
|
713
|
-
type
|
|
714
|
-
type
|
|
715
|
-
type AppDeployParams as AppDeployParams,
|
|
716
|
-
type AppInvokeParams as AppInvokeParams,
|
|
746
|
+
Browsers as Browsers,
|
|
747
|
+
type BrowserCreateResponse as BrowserCreateResponse,
|
|
748
|
+
type BrowserRetrieveResponse as BrowserRetrieveResponse,
|
|
749
|
+
type BrowserCreateParams as BrowserCreateParams,
|
|
717
750
|
};
|
|
718
|
-
|
|
719
|
-
export { Browser as Browser, type BrowserCreateSessionResponse as BrowserCreateSessionResponse };
|
|
720
751
|
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
export interface KernelContext {
|
|
2
|
+
invocationId: string;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export interface KernelAction {
|
|
6
|
+
name: string;
|
|
7
|
+
handler: (context: KernelContext, input: any) => Promise<any>;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface KernelJson {
|
|
11
|
+
apps: KernelAppJson[];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface KernelAppJson {
|
|
15
|
+
name: string;
|
|
16
|
+
actions: KernelActionJson[];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface KernelActionJson {
|
|
20
|
+
name: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export class KernelApp {
|
|
24
|
+
name: string;
|
|
25
|
+
actions: Map<string, KernelAction> = new Map();
|
|
26
|
+
|
|
27
|
+
constructor(name: string) {
|
|
28
|
+
this.name = name;
|
|
29
|
+
// Register this app in the global registry
|
|
30
|
+
appRegistry.registerApp(this);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Define an action
|
|
35
|
+
*/
|
|
36
|
+
action<T, R>(
|
|
37
|
+
nameOrHandler: string | ((input: T) => Promise<R>) | ((context: KernelContext, input: T) => Promise<R>),
|
|
38
|
+
handler?: ((input: T) => Promise<R>) | ((context: KernelContext, input: T) => Promise<R>),
|
|
39
|
+
) {
|
|
40
|
+
let actionName: string;
|
|
41
|
+
let actionHandler: (context: KernelContext, input: T) => Promise<R>;
|
|
42
|
+
|
|
43
|
+
if (typeof nameOrHandler === 'string' && handler) {
|
|
44
|
+
// Case: app.action("name", handler)
|
|
45
|
+
actionName = nameOrHandler;
|
|
46
|
+
|
|
47
|
+
// Create a handler that accepts context and input, adapting if needed
|
|
48
|
+
if (handler.length === 1) {
|
|
49
|
+
// Original handler only takes input, so we adapt it to the new signature
|
|
50
|
+
const singleArgHandler = handler as (input: T) => Promise<R>;
|
|
51
|
+
actionHandler = async (context: KernelContext, input: T) => singleArgHandler(input);
|
|
52
|
+
} else {
|
|
53
|
+
// Handler takes both context and input
|
|
54
|
+
actionHandler = handler as (context: KernelContext, input: T) => Promise<R>;
|
|
55
|
+
}
|
|
56
|
+
} else if (typeof nameOrHandler === 'function') {
|
|
57
|
+
// Case: app.action(handler)
|
|
58
|
+
actionName = nameOrHandler.name || 'default';
|
|
59
|
+
|
|
60
|
+
// Create a handler that accepts context and input, adapting if needed
|
|
61
|
+
if (nameOrHandler.length === 1) {
|
|
62
|
+
// Original handler only takes input, so we adapt it to the new signature
|
|
63
|
+
const singleArgHandler = nameOrHandler as (input: T) => Promise<R>;
|
|
64
|
+
actionHandler = async (context: KernelContext, input: T) => singleArgHandler(input);
|
|
65
|
+
} else {
|
|
66
|
+
// Handler takes both context and input
|
|
67
|
+
actionHandler = nameOrHandler as (context: KernelContext, input: T) => Promise<R>;
|
|
68
|
+
}
|
|
69
|
+
} else {
|
|
70
|
+
throw new Error('Invalid action definition');
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Register the action
|
|
74
|
+
this.actions.set(actionName, {
|
|
75
|
+
name: actionName,
|
|
76
|
+
handler: actionHandler,
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
return actionHandler;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Get all actions for this app
|
|
84
|
+
*/
|
|
85
|
+
getActions(): KernelAction[] {
|
|
86
|
+
return Array.from(this.actions.values());
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Get an action by name
|
|
91
|
+
*/
|
|
92
|
+
getAction(name: string): KernelAction | undefined {
|
|
93
|
+
return this.actions.get(name);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Export app information without handlers
|
|
98
|
+
*/
|
|
99
|
+
toJSON(): KernelAppJson {
|
|
100
|
+
return {
|
|
101
|
+
name: this.name,
|
|
102
|
+
actions: this.getActions().map((action) => ({
|
|
103
|
+
name: action.name,
|
|
104
|
+
})),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Registry for storing all Kernel apps
|
|
110
|
+
class KernelAppRegistry {
|
|
111
|
+
private apps: Map<string, KernelApp> = new Map();
|
|
112
|
+
|
|
113
|
+
registerApp(app: KernelApp): void {
|
|
114
|
+
this.apps.set(app.name, app);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
getApps(): KernelApp[] {
|
|
118
|
+
return Array.from(this.apps.values());
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
getAppByName(name: string): KernelApp | undefined {
|
|
122
|
+
return this.apps.get(name);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export(): KernelJson {
|
|
126
|
+
return {
|
|
127
|
+
apps: this.getApps().map((app) => app.toJSON()),
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
exportJSON(): string {
|
|
132
|
+
return JSON.stringify(this.export(), null, 2);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Create a singleton registry for apps
|
|
137
|
+
export const appRegistry = new KernelAppRegistry();
|
package/src/index.ts
CHANGED
package/src/internal/headers.ts
CHANGED
|
@@ -71,8 +71,8 @@ function* iterateHeaders(headers: HeadersLike): IterableIterator<readonly [strin
|
|
|
71
71
|
export const buildHeaders = (newHeaders: HeadersLike[]): NullableHeaders => {
|
|
72
72
|
const targetHeaders = new Headers();
|
|
73
73
|
const nullHeaders = new Set<string>();
|
|
74
|
-
const seenHeaders = new Set<string>();
|
|
75
74
|
for (const headers of newHeaders) {
|
|
75
|
+
const seenHeaders = new Set<string>();
|
|
76
76
|
for (const [name, value] of iterateHeaders(headers)) {
|
|
77
77
|
const lowerName = name.toLowerCase();
|
|
78
78
|
if (!seenHeaders.has(lowerName)) {
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { APIResource } from '../../core/resource';
|
|
4
|
+
import * as DeploymentsAPI from './deployments';
|
|
5
|
+
import { DeploymentCreateParams, DeploymentCreateResponse, Deployments } from './deployments';
|
|
6
|
+
import * as InvocationsAPI from './invocations';
|
|
7
|
+
import {
|
|
8
|
+
InvocationCreateParams,
|
|
9
|
+
InvocationCreateResponse,
|
|
10
|
+
InvocationRetrieveResponse,
|
|
11
|
+
Invocations,
|
|
12
|
+
} from './invocations';
|
|
13
|
+
|
|
14
|
+
export class Apps extends APIResource {
|
|
15
|
+
deployments: DeploymentsAPI.Deployments = new DeploymentsAPI.Deployments(this._client);
|
|
16
|
+
invocations: InvocationsAPI.Invocations = new InvocationsAPI.Invocations(this._client);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
Apps.Deployments = Deployments;
|
|
20
|
+
Apps.Invocations = Invocations;
|
|
21
|
+
|
|
22
|
+
export declare namespace Apps {
|
|
23
|
+
export {
|
|
24
|
+
Deployments as Deployments,
|
|
25
|
+
type DeploymentCreateResponse as DeploymentCreateResponse,
|
|
26
|
+
type DeploymentCreateParams as DeploymentCreateParams,
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export {
|
|
30
|
+
Invocations as Invocations,
|
|
31
|
+
type InvocationCreateResponse as InvocationCreateResponse,
|
|
32
|
+
type InvocationRetrieveResponse as InvocationRetrieveResponse,
|
|
33
|
+
type InvocationCreateParams as InvocationCreateParams,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { APIResource } from '../../core/resource';
|
|
4
|
+
import { APIPromise } from '../../core/api-promise';
|
|
5
|
+
import { type Uploadable } from '../../core/uploads';
|
|
6
|
+
import { RequestOptions } from '../../internal/request-options';
|
|
7
|
+
import { multipartFormRequestOptions } from '../../internal/uploads';
|
|
8
|
+
|
|
9
|
+
export class Deployments extends APIResource {
|
|
10
|
+
/**
|
|
11
|
+
* Deploy a new application
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* const deployment = await client.apps.deployments.create({
|
|
16
|
+
* entrypoint_rel_path: 'src/app.py',
|
|
17
|
+
* file: fs.createReadStream('path/to/file'),
|
|
18
|
+
* });
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
create(body: DeploymentCreateParams, options?: RequestOptions): APIPromise<DeploymentCreateResponse> {
|
|
22
|
+
return this._client.post('/deploy', multipartFormRequestOptions({ body, ...options }, this._client));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface DeploymentCreateResponse {
|
|
27
|
+
/**
|
|
28
|
+
* List of apps deployed
|
|
29
|
+
*/
|
|
30
|
+
apps: Array<DeploymentCreateResponse.App>;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Current status of the deployment
|
|
34
|
+
*/
|
|
35
|
+
status: 'queued' | 'deploying' | 'succeeded' | 'failed';
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Status reason
|
|
39
|
+
*/
|
|
40
|
+
status_reason?: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export namespace DeploymentCreateResponse {
|
|
44
|
+
export interface App {
|
|
45
|
+
/**
|
|
46
|
+
* ID for the app version deployed
|
|
47
|
+
*/
|
|
48
|
+
id: string;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* List of actions available on the app
|
|
52
|
+
*/
|
|
53
|
+
actions: Array<App.Action>;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Name of the app
|
|
57
|
+
*/
|
|
58
|
+
name: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export namespace App {
|
|
62
|
+
export interface Action {
|
|
63
|
+
/**
|
|
64
|
+
* Name of the action
|
|
65
|
+
*/
|
|
66
|
+
name: string;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface DeploymentCreateParams {
|
|
72
|
+
/**
|
|
73
|
+
* Relative path to the entrypoint of the application
|
|
74
|
+
*/
|
|
75
|
+
entrypoint_rel_path: string;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* ZIP file containing the application source directory
|
|
79
|
+
*/
|
|
80
|
+
file: Uploadable;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Allow overwriting an existing app version
|
|
84
|
+
*/
|
|
85
|
+
force?: boolean;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Region for deployment. Currently we only support "aws.us-east-1a"
|
|
89
|
+
*/
|
|
90
|
+
region?: 'aws.us-east-1a';
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Version of the application. Can be any string.
|
|
94
|
+
*/
|
|
95
|
+
version?: string;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export declare namespace Deployments {
|
|
99
|
+
export {
|
|
100
|
+
type DeploymentCreateResponse as DeploymentCreateResponse,
|
|
101
|
+
type DeploymentCreateParams as DeploymentCreateParams,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
export { Apps } from './apps';
|
|
4
|
+
export { Deployments, type DeploymentCreateResponse, type DeploymentCreateParams } from './deployments';
|
|
5
|
+
export {
|
|
6
|
+
Invocations,
|
|
7
|
+
type InvocationCreateResponse,
|
|
8
|
+
type InvocationRetrieveResponse,
|
|
9
|
+
type InvocationCreateParams,
|
|
10
|
+
} from './invocations';
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { APIResource } from '../../core/resource';
|
|
4
|
+
import { APIPromise } from '../../core/api-promise';
|
|
5
|
+
import { RequestOptions } from '../../internal/request-options';
|
|
6
|
+
import { path } from '../../internal/utils/path';
|
|
7
|
+
|
|
8
|
+
export class Invocations extends APIResource {
|
|
9
|
+
/**
|
|
10
|
+
* Invoke an application
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const invocation = await client.apps.invocations.create({
|
|
15
|
+
* action_name: 'analyze',
|
|
16
|
+
* app_name: 'my-app',
|
|
17
|
+
* version: '1.0.0',
|
|
18
|
+
* });
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
create(body: InvocationCreateParams, options?: RequestOptions): APIPromise<InvocationCreateResponse> {
|
|
22
|
+
return this._client.post('/invocations', { body, ...options });
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Get an app invocation by id
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* const invocation = await client.apps.invocations.retrieve(
|
|
31
|
+
* 'ckqwer3o20000jb9s7abcdef',
|
|
32
|
+
* );
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
retrieve(id: string, options?: RequestOptions): APIPromise<InvocationRetrieveResponse> {
|
|
36
|
+
return this._client.get(path`/invocations/${id}`, options);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface InvocationCreateResponse {
|
|
41
|
+
/**
|
|
42
|
+
* ID of the invocation
|
|
43
|
+
*/
|
|
44
|
+
id: string;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Status of the invocation
|
|
48
|
+
*/
|
|
49
|
+
status: 'queued' | 'running' | 'succeeded' | 'failed';
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* The return value of the action that was invoked, rendered as a JSON string. This
|
|
53
|
+
* could be: string, number, boolean, array, object, or null.
|
|
54
|
+
*/
|
|
55
|
+
output?: string;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Status reason
|
|
59
|
+
*/
|
|
60
|
+
status_reason?: string;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface InvocationRetrieveResponse {
|
|
64
|
+
/**
|
|
65
|
+
* ID of the invocation
|
|
66
|
+
*/
|
|
67
|
+
id: string;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Name of the action invoked
|
|
71
|
+
*/
|
|
72
|
+
action_name: string;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Name of the application
|
|
76
|
+
*/
|
|
77
|
+
app_name: string;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* RFC 3339 Nanoseconds timestamp when the invocation started
|
|
81
|
+
*/
|
|
82
|
+
started_at: string;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Status of the invocation
|
|
86
|
+
*/
|
|
87
|
+
status: 'queued' | 'running' | 'succeeded' | 'failed';
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* RFC 3339 Nanoseconds timestamp when the invocation finished (null if still
|
|
91
|
+
* running)
|
|
92
|
+
*/
|
|
93
|
+
finished_at?: string | null;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Output produced by the action, rendered as a JSON string. This could be: string,
|
|
97
|
+
* number, boolean, array, object, or null.
|
|
98
|
+
*/
|
|
99
|
+
output?: string;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Payload provided to the invocation. This is a string that can be parsed as JSON.
|
|
103
|
+
*/
|
|
104
|
+
payload?: string;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Status reason
|
|
108
|
+
*/
|
|
109
|
+
status_reason?: string;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface InvocationCreateParams {
|
|
113
|
+
/**
|
|
114
|
+
* Name of the action to invoke
|
|
115
|
+
*/
|
|
116
|
+
action_name: string;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Name of the application
|
|
120
|
+
*/
|
|
121
|
+
app_name: string;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Version of the application
|
|
125
|
+
*/
|
|
126
|
+
version: string;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Input data for the action, sent as a JSON string.
|
|
130
|
+
*/
|
|
131
|
+
payload?: string;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export declare namespace Invocations {
|
|
135
|
+
export {
|
|
136
|
+
type InvocationCreateResponse as InvocationCreateResponse,
|
|
137
|
+
type InvocationRetrieveResponse as InvocationRetrieveResponse,
|
|
138
|
+
type InvocationCreateParams as InvocationCreateParams,
|
|
139
|
+
};
|
|
140
|
+
}
|