@onkernel/sdk 0.1.0-alpha.13 → 0.1.0-alpha.15
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 +16 -0
- package/core/app-framework.d.mts +2 -2
- package/core/app-framework.d.mts.map +1 -1
- package/core/app-framework.d.ts +2 -2
- package/core/app-framework.d.ts.map +1 -1
- package/core/app-framework.js +14 -31
- package/core/app-framework.js.map +1 -1
- package/core/app-framework.mjs +14 -31
- package/core/app-framework.mjs.map +1 -1
- package/package.json +1 -1
- package/src/core/app-framework.ts +18 -35
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.0-alpha.15 (2025-05-20)
|
|
4
|
+
|
|
5
|
+
Full Changelog: [v0.1.0-alpha.14...v0.1.0-alpha.15](https://github.com/onkernel/kernel-node-sdk/compare/v0.1.0-alpha.14...v0.1.0-alpha.15)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
* **api:** update via SDK Studio ([5a8e147](https://github.com/onkernel/kernel-node-sdk/commit/5a8e1474d3a630ae770ebd541375aec4bf183086))
|
|
10
|
+
|
|
11
|
+
## 0.1.0-alpha.14 (2025-05-20)
|
|
12
|
+
|
|
13
|
+
Full Changelog: [v0.1.0-alpha.13...v0.1.0-alpha.14](https://github.com/onkernel/kernel-node-sdk/compare/v0.1.0-alpha.13...v0.1.0-alpha.14)
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* **api:** update via SDK Studio ([1a48ef2](https://github.com/onkernel/kernel-node-sdk/commit/1a48ef24166848971e3f2f6403cad99c1771f0e9))
|
|
18
|
+
|
|
3
19
|
## 0.1.0-alpha.13 (2025-05-19)
|
|
4
20
|
|
|
5
21
|
Full Changelog: [v0.1.0-alpha.12...v0.1.0-alpha.13](https://github.com/onkernel/kernel-node-sdk/compare/v0.1.0-alpha.12...v0.1.0-alpha.13)
|
package/core/app-framework.d.mts
CHANGED
|
@@ -3,7 +3,7 @@ export interface KernelContext {
|
|
|
3
3
|
}
|
|
4
4
|
export interface KernelAction {
|
|
5
5
|
name: string;
|
|
6
|
-
handler: (context: KernelContext,
|
|
6
|
+
handler: (context: KernelContext, payload?: any) => Promise<any>;
|
|
7
7
|
}
|
|
8
8
|
export interface KernelJson {
|
|
9
9
|
apps: KernelAppJson[];
|
|
@@ -22,7 +22,7 @@ export declare class KernelApp {
|
|
|
22
22
|
/**
|
|
23
23
|
* Define an action
|
|
24
24
|
*/
|
|
25
|
-
action<T, R>(
|
|
25
|
+
action<T, R>(name: string, handler: ((context: KernelContext) => Promise<R>) | ((context: KernelContext, payload?: T) => Promise<R>)): (context: KernelContext, payload?: T) => Promise<R>;
|
|
26
26
|
/**
|
|
27
27
|
* Get all actions for this app
|
|
28
28
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-framework.d.mts","sourceRoot":"","sources":["../src/core/app-framework.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,CAAC,OAAO,EAAE,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"app-framework.d.mts","sourceRoot":"","sources":["../src/core/app-framework.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;CAClE;AAED,M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
name: string;
|
|
6
|
-
handler: (context: KernelContext,
|
|
6
|
+
handler: (context: KernelContext, payload?: any) => Promise<any>;
|
|
7
7
|
}
|
|
8
8
|
export interface KernelJson {
|
|
9
9
|
apps: KernelAppJson[];
|
|
@@ -22,7 +22,7 @@ export declare class KernelApp {
|
|
|
22
22
|
/**
|
|
23
23
|
* Define an action
|
|
24
24
|
*/
|
|
25
|
-
action<T, R>(
|
|
25
|
+
action<T, R>(name: string, handler: ((context: KernelContext) => Promise<R>) | ((context: KernelContext, payload?: T) => Promise<R>)): (context: KernelContext, payload?: T) => Promise<R>;
|
|
26
26
|
/**
|
|
27
27
|
* Get all actions for this app
|
|
28
28
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-framework.d.ts","sourceRoot":"","sources":["../src/core/app-framework.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,CAAC,OAAO,EAAE,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"app-framework.d.ts","sourceRoot":"","sources":["../src/core/app-framework.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;CAClE;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,aAAa,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,gBAAgB,EAAE,CAAC;CAC7B;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,qBAAa,SAAS;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAa;gBAEnC,IAAI,EAAE,MAAM;IAMxB;;OAEG;IACH,MAAM,CAAC,CAAC,EAAE,CAAC,EACT,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,aAAa,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,aAE5E,aAAa,YAAY,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC;IAyBxE;;OAEG;IACH,UAAU,IAAI,YAAY,EAAE;IAI5B;;OAEG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IAIjD;;OAEG;IACH,MAAM,IAAI,aAAa;CAQxB;AAGD,cAAM,iBAAiB;IACrB,OAAO,CAAC,IAAI,CAAqC;IAEjD,WAAW,CAAC,GAAG,EAAE,SAAS,GAAG,IAAI;IAIjC,OAAO,IAAI,SAAS,EAAE;IAItB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS;IAIjD,MAAM,IAAI,UAAU;IAMpB,UAAU,IAAI,MAAM;CAGrB;AAGD,eAAO,MAAM,WAAW,mBAA0B,CAAC"}
|
package/core/app-framework.js
CHANGED
|
@@ -11,43 +11,26 @@ class KernelApp {
|
|
|
11
11
|
/**
|
|
12
12
|
* Define an action
|
|
13
13
|
*/
|
|
14
|
-
action(
|
|
15
|
-
let actionName;
|
|
14
|
+
action(name, handler) {
|
|
16
15
|
let actionHandler;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (handler.length === 1) {
|
|
22
|
-
// Original handler only takes input, so we adapt it to the new signature
|
|
23
|
-
const singleArgHandler = handler;
|
|
24
|
-
actionHandler = async (context, input) => singleArgHandler(input);
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
// Handler takes both context and input
|
|
28
|
-
actionHandler = handler;
|
|
29
|
-
}
|
|
16
|
+
// Create a handler that accepts context and payload, adapting if needed
|
|
17
|
+
if (handler.length === 0) {
|
|
18
|
+
// Handlers with no arguments are not supported
|
|
19
|
+
throw new Error('Action handlers must accept at least the context parameter');
|
|
30
20
|
}
|
|
31
|
-
else if (
|
|
32
|
-
//
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (nameOrHandler.length === 1) {
|
|
36
|
-
// Original handler only takes input, so we adapt it to the new signature
|
|
37
|
-
const singleArgHandler = nameOrHandler;
|
|
38
|
-
actionHandler = async (context, input) => singleArgHandler(input);
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
// Handler takes both context and input
|
|
42
|
-
actionHandler = nameOrHandler;
|
|
43
|
-
}
|
|
21
|
+
else if (handler.length === 1) {
|
|
22
|
+
// Handler takes context only
|
|
23
|
+
const contextOnlyHandler = handler;
|
|
24
|
+
actionHandler = async (context, _payload) => contextOnlyHandler(context);
|
|
44
25
|
}
|
|
45
26
|
else {
|
|
46
|
-
|
|
27
|
+
// Handler takes both context and payload
|
|
28
|
+
const twoArgHandler = handler;
|
|
29
|
+
actionHandler = twoArgHandler;
|
|
47
30
|
}
|
|
48
31
|
// Register the action
|
|
49
|
-
this.actions.set(
|
|
50
|
-
name
|
|
32
|
+
this.actions.set(name, {
|
|
33
|
+
name,
|
|
51
34
|
handler: actionHandler,
|
|
52
35
|
});
|
|
53
36
|
return actionHandler;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-framework.js","sourceRoot":"","sources":["../src/core/app-framework.ts"],"names":[],"mappings":";;;AAsBA,MAAa,SAAS;IAIpB,YAAY,IAAY;QAFxB,YAAO,GAA8B,IAAI,GAAG,EAAE,CAAC;QAG7C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB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Define an action
|
|
10
10
|
*/
|
|
11
|
-
action(
|
|
12
|
-
let actionName;
|
|
11
|
+
action(name, handler) {
|
|
13
12
|
let actionHandler;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (handler.length === 1) {
|
|
19
|
-
// Original handler only takes input, so we adapt it to the new signature
|
|
20
|
-
const singleArgHandler = handler;
|
|
21
|
-
actionHandler = async (context, input) => singleArgHandler(input);
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
// Handler takes both context and input
|
|
25
|
-
actionHandler = handler;
|
|
26
|
-
}
|
|
13
|
+
// Create a handler that accepts context and payload, adapting if needed
|
|
14
|
+
if (handler.length === 0) {
|
|
15
|
+
// Handlers with no arguments are not supported
|
|
16
|
+
throw new Error('Action handlers must accept at least the context parameter');
|
|
27
17
|
}
|
|
28
|
-
else if (
|
|
29
|
-
//
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if (nameOrHandler.length === 1) {
|
|
33
|
-
// Original handler only takes input, so we adapt it to the new signature
|
|
34
|
-
const singleArgHandler = nameOrHandler;
|
|
35
|
-
actionHandler = async (context, input) => singleArgHandler(input);
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
// Handler takes both context and input
|
|
39
|
-
actionHandler = nameOrHandler;
|
|
40
|
-
}
|
|
18
|
+
else if (handler.length === 1) {
|
|
19
|
+
// Handler takes context only
|
|
20
|
+
const contextOnlyHandler = handler;
|
|
21
|
+
actionHandler = async (context, _payload) => contextOnlyHandler(context);
|
|
41
22
|
}
|
|
42
23
|
else {
|
|
43
|
-
|
|
24
|
+
// Handler takes both context and payload
|
|
25
|
+
const twoArgHandler = handler;
|
|
26
|
+
actionHandler = twoArgHandler;
|
|
44
27
|
}
|
|
45
28
|
// Register the action
|
|
46
|
-
this.actions.set(
|
|
47
|
-
name
|
|
29
|
+
this.actions.set(name, {
|
|
30
|
+
name,
|
|
48
31
|
handler: actionHandler,
|
|
49
32
|
});
|
|
50
33
|
return actionHandler;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-framework.mjs","sourceRoot":"","sources":["../src/core/app-framework.ts"],"names":[],"mappings":"AAsBA,MAAM,OAAO,SAAS;IAIpB,YAAY,IAAY;QAFxB,YAAO,GAA8B,IAAI,GAAG,EAAE,CAAC;QAG7C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,2CAA2C;QAC3C,WAAW,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;IAED;;OAEG;IACH,MAAM,CACJ,
|
|
1
|
+
{"version":3,"file":"app-framework.mjs","sourceRoot":"","sources":["../src/core/app-framework.ts"],"names":[],"mappings":"AAsBA,MAAM,OAAO,SAAS;IAIpB,YAAY,IAAY;QAFxB,YAAO,GAA8B,IAAI,GAAG,EAAE,CAAC;QAG7C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,2CAA2C;QAC3C,WAAW,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;IAED;;OAEG;IACH,MAAM,CACJ,IAAY,EACZ,OAAyG;QAEzG,IAAI,aAAkE,CAAC;QAEvE,wEAAwE;QACxE,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACzB,+CAA+C;YAC/C,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;QAChF,CAAC;aAAM,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAChC,6BAA6B;YAC7B,MAAM,kBAAkB,GAAG,OAAiD,CAAC;YAC7E,aAAa,GAAG,KAAK,EAAE,OAAsB,EAAE,QAAY,EAAE,EAAE,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;QAC9F,CAAC;aAAM,CAAC;YACN,yCAAyC;YACzC,MAAM,aAAa,GAAG,OAA8D,CAAC;YACrF,aAAa,GAAG,aAAa,CAAC;QAChC,CAAC;QAED,sBAAsB;QACtB,IAAI,CAAC,OA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,SAAS,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAChD,CAAC;CACF;AAED,uCAAuC;AACvC,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,iBAAiB,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@ export interface KernelContext {
|
|
|
4
4
|
|
|
5
5
|
export interface KernelAction {
|
|
6
6
|
name: string;
|
|
7
|
-
handler: (context: KernelContext,
|
|
7
|
+
handler: (context: KernelContext, payload?: any) => Promise<any>;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export interface KernelJson {
|
|
@@ -34,45 +34,28 @@ export class KernelApp {
|
|
|
34
34
|
* Define an action
|
|
35
35
|
*/
|
|
36
36
|
action<T, R>(
|
|
37
|
-
|
|
38
|
-
handler
|
|
37
|
+
name: string,
|
|
38
|
+
handler: ((context: KernelContext) => Promise<R>) | ((context: KernelContext, payload?: T) => Promise<R>),
|
|
39
39
|
) {
|
|
40
|
-
let
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
if (
|
|
44
|
-
//
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
//
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
}
|
|
40
|
+
let actionHandler: (context: KernelContext, payload?: T) => Promise<R>;
|
|
41
|
+
|
|
42
|
+
// Create a handler that accepts context and payload, adapting if needed
|
|
43
|
+
if (handler.length === 0) {
|
|
44
|
+
// Handlers with no arguments are not supported
|
|
45
|
+
throw new Error('Action handlers must accept at least the context parameter');
|
|
46
|
+
} else if (handler.length === 1) {
|
|
47
|
+
// Handler takes context only
|
|
48
|
+
const contextOnlyHandler = handler as (context: KernelContext) => Promise<R>;
|
|
49
|
+
actionHandler = async (context: KernelContext, _payload?: T) => contextOnlyHandler(context);
|
|
69
50
|
} else {
|
|
70
|
-
|
|
51
|
+
// Handler takes both context and payload
|
|
52
|
+
const twoArgHandler = handler as (context: KernelContext, payload?: T) => Promise<R>;
|
|
53
|
+
actionHandler = twoArgHandler;
|
|
71
54
|
}
|
|
72
55
|
|
|
73
56
|
// Register the action
|
|
74
|
-
this.actions.set(
|
|
75
|
-
name
|
|
57
|
+
this.actions.set(name, {
|
|
58
|
+
name,
|
|
76
59
|
handler: actionHandler,
|
|
77
60
|
});
|
|
78
61
|
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '0.1.0-alpha.
|
|
1
|
+
export const VERSION = '0.1.0-alpha.15'; // x-release-please-version
|
package/version.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.1.0-alpha.
|
|
1
|
+
export declare const VERSION = "0.1.0-alpha.15";
|
|
2
2
|
//# sourceMappingURL=version.d.mts.map
|
package/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.1.0-alpha.
|
|
1
|
+
export declare const VERSION = "0.1.0-alpha.15";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/version.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.VERSION = void 0;
|
|
4
|
-
exports.VERSION = '0.1.0-alpha.
|
|
4
|
+
exports.VERSION = '0.1.0-alpha.15'; // x-release-please-version
|
|
5
5
|
//# sourceMappingURL=version.js.map
|
package/version.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '0.1.0-alpha.
|
|
1
|
+
export const VERSION = '0.1.0-alpha.15'; // x-release-please-version
|
|
2
2
|
//# sourceMappingURL=version.mjs.map
|