@telorun/kernel 0.2.5 → 0.2.6
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/dist/base-definition.d.ts +14 -0
- package/dist/base-definition.d.ts.map +1 -0
- package/dist/base-definition.js +17 -0
- package/dist/base-definition.js.map +1 -0
- package/dist/capabilities/component.d.ts +3 -0
- package/dist/capabilities/component.d.ts.map +1 -0
- package/dist/capabilities/component.js +4 -0
- package/dist/capabilities/component.js.map +1 -0
- package/dist/capabilities/executable.d.ts +3 -0
- package/dist/capabilities/executable.d.ts.map +1 -0
- package/dist/capabilities/executable.js +5 -0
- package/dist/capabilities/executable.js.map +1 -0
- package/dist/capabilities/handler.d.ts +3 -0
- package/dist/capabilities/handler.d.ts.map +1 -0
- package/dist/capabilities/handler.js +4 -0
- package/dist/capabilities/handler.js.map +1 -0
- package/dist/capabilities/invokable.d.ts +3 -0
- package/dist/capabilities/invokable.d.ts.map +1 -0
- package/dist/capabilities/invokable.js +5 -0
- package/dist/capabilities/invokable.js.map +1 -0
- package/dist/capabilities/listener.d.ts +3 -0
- package/dist/capabilities/listener.d.ts.map +1 -0
- package/dist/capabilities/listener.js +5 -0
- package/dist/capabilities/listener.js.map +1 -0
- package/dist/capabilities/mount.d.ts +3 -0
- package/dist/capabilities/mount.d.ts.map +1 -0
- package/dist/capabilities/mount.js +5 -0
- package/dist/capabilities/mount.js.map +1 -0
- package/dist/capabilities/provider.d.ts +3 -0
- package/dist/capabilities/provider.d.ts.map +1 -0
- package/dist/capabilities/provider.js +8 -0
- package/dist/capabilities/provider.js.map +1 -0
- package/dist/capabilities/runnable.d.ts +3 -0
- package/dist/capabilities/runnable.d.ts.map +1 -0
- package/dist/capabilities/runnable.js +5 -0
- package/dist/capabilities/runnable.js.map +1 -0
- package/dist/capabilities/service.d.ts +3 -0
- package/dist/capabilities/service.d.ts.map +1 -0
- package/dist/capabilities/service.js +5 -0
- package/dist/capabilities/service.js.map +1 -0
- package/dist/capabilities/template.d.ts +3 -0
- package/dist/capabilities/template.d.ts.map +1 -0
- package/dist/capabilities/template.js +5 -0
- package/dist/capabilities/template.js.map +1 -0
- package/dist/capabilities/type.d.ts +3 -0
- package/dist/capabilities/type.d.ts.map +1 -0
- package/dist/capabilities/type.js +5 -0
- package/dist/capabilities/type.js.map +1 -0
- package/dist/controller-loader.d.ts.map +1 -1
- package/dist/controller-loader.js +2 -1
- package/dist/controller-loader.js.map +1 -1
- package/dist/controller-registry.d.ts +0 -4
- package/dist/controller-registry.d.ts.map +1 -1
- package/dist/controller-registry.js +11 -22
- package/dist/controller-registry.js.map +1 -1
- package/dist/controllers/capability/capability-controller.d.ts +0 -5
- package/dist/controllers/capability/capability-controller.d.ts.map +1 -1
- package/dist/controllers/capability/capability-controller.js +1 -5
- package/dist/controllers/capability/capability-controller.js.map +1 -1
- package/dist/controllers/module/import-controller.d.ts +0 -3
- package/dist/controllers/module/import-controller.d.ts.map +1 -1
- package/dist/controllers/module/import-controller.js +21 -27
- package/dist/controllers/module/import-controller.js.map +1 -1
- package/dist/controllers/module/module-controller.d.ts +0 -59
- package/dist/controllers/module/module-controller.d.ts.map +1 -1
- package/dist/controllers/module/module-controller.js +0 -45
- package/dist/controllers/module/module-controller.js.map +1 -1
- package/dist/controllers/resource-definition/resource-definition-controller.d.ts +3 -4
- package/dist/controllers/resource-definition/resource-definition-controller.d.ts.map +1 -1
- package/dist/controllers/resource-definition/resource-definition-controller.js +6 -8
- package/dist/controllers/resource-definition/resource-definition-controller.js.map +1 -1
- package/dist/controllers/resource-definition/resource-template-controller.d.ts +12 -0
- package/dist/controllers/resource-definition/resource-template-controller.d.ts.map +1 -0
- package/dist/controllers/resource-definition/resource-template-controller.js +112 -0
- package/dist/controllers/resource-definition/resource-template-controller.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/kernel.d.ts +21 -24
- package/dist/kernel.d.ts.map +1 -1
- package/dist/kernel.js +254 -189
- package/dist/kernel.js.map +1 -1
- package/dist/loader.d.ts +9 -8
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js +50 -132
- package/dist/loader.js.map +1 -1
- package/dist/manifest-adapters/http-adapter.d.ts.map +1 -1
- package/dist/manifest-adapters/http-adapter.js +3 -1
- package/dist/manifest-adapters/http-adapter.js.map +1 -1
- package/dist/manifest-adapters/local-file-adapter.d.ts +7 -5
- package/dist/manifest-adapters/local-file-adapter.d.ts.map +1 -1
- package/dist/manifest-adapters/local-file-adapter.js +21 -26
- package/dist/manifest-adapters/local-file-adapter.js.map +1 -1
- package/dist/manifest-adapters/manifest-adapter.d.ts +2 -0
- package/dist/manifest-adapters/manifest-adapter.d.ts.map +1 -1
- package/dist/manifest-adapters/registry-adapter.d.ts.map +1 -1
- package/dist/manifest-adapters/registry-adapter.js +3 -1
- package/dist/manifest-adapters/registry-adapter.js.map +1 -1
- package/dist/manifest-schemas.d.ts +61 -25
- package/dist/manifest-schemas.d.ts.map +1 -1
- package/dist/manifest-schemas.js +56 -16
- package/dist/manifest-schemas.js.map +1 -1
- package/dist/resource-context.d.ts +2 -5
- package/dist/resource-context.d.ts.map +1 -1
- package/dist/resource-context.js +31 -21
- package/dist/resource-context.js.map +1 -1
- package/dist/schema-valiator.d.ts.map +1 -1
- package/dist/schema-valiator.js +13 -2
- package/dist/schema-valiator.js.map +1 -1
- package/package.json +6 -7
- package/src/controller-loader.ts +2 -1
- package/src/controller-registry.ts +11 -26
- package/src/controllers/module/import-controller.ts +30 -30
- package/src/controllers/module/module-controller.ts +0 -51
- package/src/controllers/resource-definition/resource-definition-controller.ts +14 -15
- package/src/controllers/resource-definition/resource-template-controller.ts +138 -0
- package/src/index.ts +1 -1
- package/src/kernel.ts +313 -224
- package/src/loader.ts +54 -165
- package/src/manifest-adapters/local-file-adapter.ts +24 -31
- package/src/manifest-adapters/manifest-adapter.ts +2 -0
- package/src/manifest-schemas.ts +60 -24
- package/src/resource-context.ts +31 -30
- package/src/schema-valiator.ts +14 -3
- package/src/capabilities/component.yaml +0 -4
- package/src/capabilities/executable.yaml +0 -8
- package/src/capabilities/handler.yaml +0 -4
- package/src/capabilities/listener.yaml +0 -4
- package/src/capabilities/provider.yaml +0 -4
- package/src/capabilities/template.yaml +0 -4
- package/src/capabilities/type.yaml +0 -4
- package/src/controllers/capability/capability-controller.ts +0 -41
- package/src/controllers/module/module.json +0 -48
- package/src/controllers/module/module.yaml +0 -32
- package/src/manifest-adapters/http-adapter.ts +0 -35
- package/src/manifest-adapters/registry-adapter.ts +0 -56
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import type { ResourceContext, ResourceInstance } from "@telorun/sdk";
|
|
2
|
-
|
|
3
|
-
type CapabilityResource = {
|
|
4
|
-
kind: string;
|
|
5
|
-
metadata: {
|
|
6
|
-
name: string;
|
|
7
|
-
[key: string]: any;
|
|
8
|
-
};
|
|
9
|
-
schema?: Record<string, any>;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
class Capability implements ResourceInstance {
|
|
13
|
-
constructor(private readonly resource: CapabilityResource) {}
|
|
14
|
-
|
|
15
|
-
async init(ctx: ResourceContext) {
|
|
16
|
-
ctx.registerCapability(this.resource.metadata.name, this.resource.schema);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export async function create(resource: any, _ctx: ResourceContext): Promise<Capability> {
|
|
21
|
-
return new Capability(resource as CapabilityResource);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const schema = {
|
|
25
|
-
type: "object",
|
|
26
|
-
properties: {
|
|
27
|
-
metadata: {
|
|
28
|
-
type: "object",
|
|
29
|
-
properties: {
|
|
30
|
-
name: { type: "string" },
|
|
31
|
-
},
|
|
32
|
-
required: ["name"],
|
|
33
|
-
},
|
|
34
|
-
schema: {
|
|
35
|
-
type: "object",
|
|
36
|
-
additionalProperties: true,
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
required: ["metadata"],
|
|
40
|
-
additionalProperties: true,
|
|
41
|
-
};
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"type": "object",
|
|
3
|
-
"properties": {
|
|
4
|
-
"metadata": {
|
|
5
|
-
"type": "object",
|
|
6
|
-
"properties": {
|
|
7
|
-
"name": {
|
|
8
|
-
"type": "string"
|
|
9
|
-
}
|
|
10
|
-
},
|
|
11
|
-
"required": ["name"]
|
|
12
|
-
},
|
|
13
|
-
"imports": {
|
|
14
|
-
"type": "array",
|
|
15
|
-
"items": {
|
|
16
|
-
"type": "string"
|
|
17
|
-
},
|
|
18
|
-
"description": "Paths to other modules to import"
|
|
19
|
-
},
|
|
20
|
-
"definitions": {
|
|
21
|
-
"type": "array",
|
|
22
|
-
"items": {
|
|
23
|
-
"type": "string"
|
|
24
|
-
},
|
|
25
|
-
"description": "Paths to ResourceDefinition files"
|
|
26
|
-
},
|
|
27
|
-
"resources": {
|
|
28
|
-
"type": "array",
|
|
29
|
-
"items": {
|
|
30
|
-
"oneOf": [
|
|
31
|
-
{
|
|
32
|
-
"type": "string"
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
"type": "object",
|
|
36
|
-
"properties": {
|
|
37
|
-
"path": {
|
|
38
|
-
"type": "string"
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
]
|
|
43
|
-
},
|
|
44
|
-
"description": "Paths to resource instance files to load"
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
"required": ["metadata"]
|
|
48
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
type: 'object'
|
|
2
|
-
properties:
|
|
3
|
-
metadata:
|
|
4
|
-
type: 'object'
|
|
5
|
-
properties:
|
|
6
|
-
name:
|
|
7
|
-
type: 'string'
|
|
8
|
-
required: ['name']
|
|
9
|
-
source:
|
|
10
|
-
type: 'string'
|
|
11
|
-
description: 'Path to module directory (relative to runtime root)'
|
|
12
|
-
imports:
|
|
13
|
-
type: 'array'
|
|
14
|
-
items:
|
|
15
|
-
type: 'string'
|
|
16
|
-
description: 'Paths to other modules to import'
|
|
17
|
-
definitions:
|
|
18
|
-
type: 'array'
|
|
19
|
-
items:
|
|
20
|
-
type: 'string'
|
|
21
|
-
description: 'Paths to ResourceDefinition files'
|
|
22
|
-
resources:
|
|
23
|
-
type: 'array'
|
|
24
|
-
items:
|
|
25
|
-
oneOf:
|
|
26
|
-
- type: 'string'
|
|
27
|
-
- type: 'object'
|
|
28
|
-
properties:
|
|
29
|
-
path:
|
|
30
|
-
type: 'string'
|
|
31
|
-
description: 'Paths to resource instance files to load'
|
|
32
|
-
required: ['metadata', 'source']
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import * as yaml from "js-yaml";
|
|
2
|
-
import type { ManifestAdapter, ManifestSourceData } from "./manifest-adapter.js";
|
|
3
|
-
|
|
4
|
-
export class HttpAdapter implements ManifestAdapter {
|
|
5
|
-
supports(pathOrUrl: string): boolean {
|
|
6
|
-
return pathOrUrl.startsWith("http://") || pathOrUrl.startsWith("https://");
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
async read(url: string): Promise<ManifestSourceData> {
|
|
10
|
-
return (await this.readAll(url))[0];
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
async readAll(url: string): Promise<ManifestSourceData[]> {
|
|
14
|
-
const fetchUrl = url.includes(".yaml") ? url : url + "/module.yaml";
|
|
15
|
-
const response = await fetch(fetchUrl);
|
|
16
|
-
if (!response.ok) {
|
|
17
|
-
throw new Error(
|
|
18
|
-
`Failed to fetch manifest from ${fetchUrl}: ${response.status} ${response.statusText}`,
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
return [
|
|
22
|
-
{
|
|
23
|
-
documents: yaml.loadAll(await response.text()),
|
|
24
|
-
source: fetchUrl,
|
|
25
|
-
baseDir: process.cwd(),
|
|
26
|
-
uriBase: url,
|
|
27
|
-
},
|
|
28
|
-
];
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
resolveRelative(base: string, relative: string): string {
|
|
32
|
-
const baseWithSlash = base.endsWith("/") ? base : `${base}/`;
|
|
33
|
-
return new URL(relative, baseWithSlash).href;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import * as yaml from "js-yaml";
|
|
2
|
-
import type { ManifestAdapter, ManifestSourceData } from "./manifest-adapter.js";
|
|
3
|
-
|
|
4
|
-
const REGISTRY_BASE = "https://registry.telo.run";
|
|
5
|
-
|
|
6
|
-
export class RegistryAdapter implements ManifestAdapter {
|
|
7
|
-
supports(pathOrUrl: string): boolean {
|
|
8
|
-
// Matches "owner/module@version" — has @ and /, but not an http/https URL or local path
|
|
9
|
-
return (
|
|
10
|
-
!pathOrUrl.startsWith("http://") &&
|
|
11
|
-
!pathOrUrl.startsWith("https://") &&
|
|
12
|
-
!pathOrUrl.startsWith("/") &&
|
|
13
|
-
!pathOrUrl.startsWith(".") &&
|
|
14
|
-
pathOrUrl.includes("@") &&
|
|
15
|
-
pathOrUrl.includes("/")
|
|
16
|
-
);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
async read(moduleRef: string): Promise<ManifestSourceData> {
|
|
20
|
-
return (await this.readAll(moduleRef))[0];
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
async readAll(moduleRef: string): Promise<ManifestSourceData[]> {
|
|
24
|
-
const url = this.toRegistryUrl(moduleRef);
|
|
25
|
-
const response = await fetch(url);
|
|
26
|
-
if (!response.ok) {
|
|
27
|
-
throw new Error(
|
|
28
|
-
`Failed to fetch manifest ${moduleRef}: ${response.status} ${response.statusText}`,
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
return [
|
|
32
|
-
{
|
|
33
|
-
documents: yaml.loadAll(await response.text()),
|
|
34
|
-
source: url,
|
|
35
|
-
baseDir: process.cwd(),
|
|
36
|
-
uriBase: url.replace("/module.yaml", ""),
|
|
37
|
-
},
|
|
38
|
-
];
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
resolveRelative(base: string, relative: string): string {
|
|
42
|
-
const baseUrl = this.supports(base)
|
|
43
|
-
? this.toRegistryUrl(base).replace("/module.yaml", "")
|
|
44
|
-
: base;
|
|
45
|
-
const baseWithSlash = baseUrl.endsWith("/") ? baseUrl : `${baseUrl}/`;
|
|
46
|
-
return new URL(relative, baseWithSlash).href;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
private toRegistryUrl(moduleRef: string): string {
|
|
50
|
-
const atIdx = moduleRef.lastIndexOf("@");
|
|
51
|
-
const path = moduleRef.slice(0, atIdx); // "example/module"
|
|
52
|
-
const version = moduleRef.slice(atIdx + 1); // "1.2.3" or "v1.2.3"
|
|
53
|
-
const versionSegment = version.startsWith("v") ? version.substring(1) : version;
|
|
54
|
-
return `${REGISTRY_BASE}/${path}/${versionSegment}/module.yaml`;
|
|
55
|
-
}
|
|
56
|
-
}
|