@telorun/kernel 0.2.8 → 0.3.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 +7 -7
- package/dist/controllers/module/import-controller.d.ts.map +1 -1
- package/dist/controllers/module/import-controller.js +22 -23
- package/dist/controllers/module/import-controller.js.map +1 -1
- package/dist/controllers/resource-definition/resource-definition-controller.d.ts +1 -1
- package/dist/controllers/resource-definition/resource-definition-controller.d.ts.map +1 -1
- package/dist/evaluation-context.d.ts +21 -4
- package/dist/evaluation-context.d.ts.map +1 -1
- package/dist/evaluation-context.js +85 -13
- package/dist/evaluation-context.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/kernel.d.ts +11 -8
- package/dist/kernel.d.ts.map +1 -1
- package/dist/kernel.js +38 -16
- package/dist/kernel.js.map +1 -1
- package/dist/manifest-adapters/local-file-adapter.d.ts +2 -0
- package/dist/manifest-adapters/local-file-adapter.d.ts.map +1 -1
- package/dist/manifest-adapters/local-file-adapter.js +52 -13
- package/dist/manifest-adapters/local-file-adapter.js.map +1 -1
- package/dist/manifest-schemas.d.ts +44 -1
- package/dist/manifest-schemas.d.ts.map +1 -1
- package/dist/manifest-schemas.js +59 -15
- package/dist/manifest-schemas.js.map +1 -1
- package/dist/module-context.d.ts +1 -1
- package/dist/module-context.js +1 -1
- package/dist/resource-context.d.ts +6 -2
- package/dist/resource-context.d.ts.map +1 -1
- package/dist/resource-context.js +24 -4
- package/dist/resource-context.js.map +1 -1
- package/package.json +5 -4
- package/src/controllers/module/import-controller.ts +28 -28
- package/src/controllers/resource-definition/resource-definition-controller.ts +1 -1
- package/src/evaluation-context.ts +107 -18
- package/src/index.ts +1 -0
- package/src/kernel.ts +52 -18
- package/src/manifest-adapters/local-file-adapter.ts +54 -13
- package/src/manifest-schemas.ts +61 -15
- package/src/module-context.ts +1 -1
- package/src/resource-context.ts +38 -3
- package/dist/base-definition.d.ts +0 -14
- package/dist/base-definition.d.ts.map +0 -1
- package/dist/base-definition.js +0 -17
- package/dist/base-definition.js.map +0 -1
- package/dist/capabilities/capabilities/component.yaml +0 -4
- package/dist/capabilities/capabilities/executable.yaml +0 -8
- package/dist/capabilities/capabilities/handler.yaml +0 -4
- package/dist/capabilities/capabilities/listener.yaml +0 -4
- package/dist/capabilities/capabilities/provider.yaml +0 -4
- package/dist/capabilities/capabilities/template.yaml +0 -4
- package/dist/capabilities/capabilities/type.yaml +0 -4
- package/dist/capabilities/component.d.ts +0 -3
- package/dist/capabilities/component.d.ts.map +0 -1
- package/dist/capabilities/component.js +0 -4
- package/dist/capabilities/component.js.map +0 -1
- package/dist/capabilities/component.yaml +0 -3
- package/dist/capabilities/executable.d.ts +0 -3
- package/dist/capabilities/executable.d.ts.map +0 -1
- package/dist/capabilities/executable.js +0 -5
- package/dist/capabilities/executable.js.map +0 -1
- package/dist/capabilities/executable.yaml +0 -7
- package/dist/capabilities/handler.d.ts +0 -3
- package/dist/capabilities/handler.d.ts.map +0 -1
- package/dist/capabilities/handler.js +0 -4
- package/dist/capabilities/handler.js.map +0 -1
- package/dist/capabilities/handler.yaml +0 -3
- package/dist/capabilities/invokable.d.ts +0 -3
- package/dist/capabilities/invokable.d.ts.map +0 -1
- package/dist/capabilities/invokable.js +0 -5
- package/dist/capabilities/invokable.js.map +0 -1
- package/dist/capabilities/listener.d.ts +0 -3
- package/dist/capabilities/listener.d.ts.map +0 -1
- package/dist/capabilities/listener.js +0 -5
- package/dist/capabilities/listener.js.map +0 -1
- package/dist/capabilities/listener.yaml +0 -3
- package/dist/capabilities/mount.d.ts +0 -3
- package/dist/capabilities/mount.d.ts.map +0 -1
- package/dist/capabilities/mount.js +0 -5
- package/dist/capabilities/mount.js.map +0 -1
- package/dist/capabilities/provider.d.ts +0 -3
- package/dist/capabilities/provider.d.ts.map +0 -1
- package/dist/capabilities/provider.js +0 -8
- package/dist/capabilities/provider.js.map +0 -1
- package/dist/capabilities/provider.yaml +0 -3
- package/dist/capabilities/runnable.d.ts +0 -3
- package/dist/capabilities/runnable.d.ts.map +0 -1
- package/dist/capabilities/runnable.js +0 -5
- package/dist/capabilities/runnable.js.map +0 -1
- package/dist/capabilities/service.d.ts +0 -3
- package/dist/capabilities/service.d.ts.map +0 -1
- package/dist/capabilities/service.js +0 -5
- package/dist/capabilities/service.js.map +0 -1
- package/dist/capabilities/template.d.ts +0 -3
- package/dist/capabilities/template.d.ts.map +0 -1
- package/dist/capabilities/template.js +0 -5
- package/dist/capabilities/template.js.map +0 -1
- package/dist/capabilities/template.yaml +0 -3
- package/dist/capabilities/type.d.ts +0 -3
- package/dist/capabilities/type.d.ts.map +0 -1
- package/dist/capabilities/type.js +0 -5
- package/dist/capabilities/type.js.map +0 -1
- package/dist/capabilities/type.yaml +0 -3
- package/dist/controllers/capability/capability-controller.d.ts +0 -32
- package/dist/controllers/capability/capability-controller.d.ts.map +0 -1
- package/dist/controllers/capability/capability-controller.js +0 -26
- package/dist/controllers/capability/capability-controller.js.map +0 -1
- package/dist/controllers/module/module.json +0 -48
- package/dist/loader.d.ts +0 -18
- package/dist/loader.d.ts.map +0 -1
- package/dist/loader.js +0 -127
- package/dist/loader.js.map +0 -1
- package/dist/manifest-adapters/http-adapter.d.ts +0 -8
- package/dist/manifest-adapters/http-adapter.d.ts.map +0 -1
- package/dist/manifest-adapters/http-adapter.js +0 -31
- package/dist/manifest-adapters/http-adapter.js.map +0 -1
- package/dist/manifest-adapters/registry-adapter.d.ts +0 -9
- package/dist/manifest-adapters/registry-adapter.d.ts.map +0 -1
- package/dist/manifest-adapters/registry-adapter.js +0 -48
- package/dist/manifest-adapters/registry-adapter.js.map +0 -1
- package/dist/module-context-registry.d.ts +0 -48
- package/dist/module-context-registry.d.ts.map +0 -1
- package/dist/module-context-registry.js +0 -91
- package/dist/module-context-registry.js.map +0 -1
- package/dist/schema-valiator.d.ts +0 -15
- package/dist/schema-valiator.d.ts.map +0 -1
- package/dist/schema-valiator.js +0 -127
- package/dist/schema-valiator.js.map +0 -1
- package/dist/snapshot-serializer.d.ts +0 -62
- package/dist/snapshot-serializer.d.ts.map +0 -1
- package/dist/snapshot-serializer.js +0 -164
- package/dist/snapshot-serializer.js.map +0 -1
- package/dist/types.d.ts +0 -65
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -8
- package/dist/types.js.map +0 -1
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { DEFAULT_MANIFEST_FILENAME, type ManifestAdapter } from "@telorun/analyzer";
|
|
2
2
|
import * as fs from "fs/promises";
|
|
3
3
|
import * as path from "path";
|
|
4
|
+
import { fileURLToPath, pathToFileURL } from "url";
|
|
5
|
+
import { minimatch } from "minimatch";
|
|
6
|
+
|
|
7
|
+
function toFilePath(pathOrUrl: string): string {
|
|
8
|
+
return pathOrUrl.startsWith("file://") ? fileURLToPath(pathOrUrl) : pathOrUrl;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function toFileUrl(filePath: string): string {
|
|
12
|
+
return pathToFileURL(filePath).href;
|
|
13
|
+
}
|
|
4
14
|
|
|
5
15
|
export class LocalFileAdapter implements ManifestAdapter {
|
|
6
16
|
supports(pathOrUrl: string): boolean {
|
|
@@ -14,32 +24,63 @@ export class LocalFileAdapter implements ManifestAdapter {
|
|
|
14
24
|
}
|
|
15
25
|
|
|
16
26
|
async read(pathOrUrl: string): Promise<{ text: string; source: string }> {
|
|
17
|
-
const
|
|
18
|
-
? new URL(pathOrUrl).pathname
|
|
19
|
-
: pathOrUrl;
|
|
20
|
-
const resolvedPath = path.resolve(normalizedPath);
|
|
27
|
+
const resolvedPath = path.resolve(toFilePath(pathOrUrl));
|
|
21
28
|
const stat = await fs.stat(resolvedPath);
|
|
22
29
|
const filePath = stat.isDirectory() ? path.join(resolvedPath, DEFAULT_MANIFEST_FILENAME) : resolvedPath;
|
|
23
30
|
const text = await fs.readFile(filePath, "utf-8");
|
|
24
|
-
return { text, source:
|
|
31
|
+
return { text, source: toFileUrl(filePath) };
|
|
25
32
|
}
|
|
26
33
|
|
|
27
34
|
async readAll(pathOrUrl: string): Promise<string[]> {
|
|
28
|
-
const
|
|
29
|
-
? new URL(pathOrUrl).pathname
|
|
30
|
-
: pathOrUrl;
|
|
31
|
-
const resolvedPath = path.resolve(normalizedPath);
|
|
35
|
+
const resolvedPath = path.resolve(toFilePath(pathOrUrl));
|
|
32
36
|
const stat = await fs.stat(resolvedPath);
|
|
33
37
|
if (stat.isDirectory()) {
|
|
34
38
|
return this.collectYamlSources(resolvedPath);
|
|
35
39
|
}
|
|
36
|
-
return [
|
|
40
|
+
return [toFileUrl(resolvedPath)];
|
|
37
41
|
}
|
|
38
42
|
|
|
39
43
|
resolveRelative(base: string, relative: string): string {
|
|
40
|
-
const basePath =
|
|
44
|
+
const basePath = toFilePath(base);
|
|
41
45
|
const baseDir = basePath.endsWith("/") ? basePath : path.dirname(basePath);
|
|
42
|
-
return
|
|
46
|
+
return toFileUrl(path.resolve(baseDir, relative));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async expandGlob(base: string, patterns: string[]): Promise<string[]> {
|
|
50
|
+
const baseDir = path.dirname(path.resolve(toFilePath(base)));
|
|
51
|
+
const entries = await fs.readdir(baseDir, { recursive: true, withFileTypes: true });
|
|
52
|
+
const normalizedPatterns = patterns.map((p) => p.replace(/\\/g, "/").replace(/^\.\//, ""));
|
|
53
|
+
const matched: string[] = [];
|
|
54
|
+
for (const entry of entries) {
|
|
55
|
+
if (!entry.isFile()) continue;
|
|
56
|
+
const relative = path.relative(baseDir, path.join(entry.parentPath, entry.name));
|
|
57
|
+
const normalized = relative.replace(/\\/g, "/");
|
|
58
|
+
if (normalizedPatterns.some((p) => minimatch(normalized, p))) {
|
|
59
|
+
matched.push(toFileUrl(path.resolve(baseDir, relative)));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return matched.sort();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async resolveOwnerOf(fileUrl: string): Promise<string | null> {
|
|
66
|
+
const resolved = path.resolve(toFilePath(fileUrl));
|
|
67
|
+
let dir = path.dirname(resolved);
|
|
68
|
+
|
|
69
|
+
while (true) {
|
|
70
|
+
const candidate = path.join(dir, DEFAULT_MANIFEST_FILENAME);
|
|
71
|
+
if (candidate !== resolved) {
|
|
72
|
+
try {
|
|
73
|
+
await fs.access(candidate);
|
|
74
|
+
return toFileUrl(candidate);
|
|
75
|
+
} catch {
|
|
76
|
+
// telo.yaml not found at this level
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const parent = path.dirname(dir);
|
|
80
|
+
if (parent === dir) break;
|
|
81
|
+
dir = parent;
|
|
82
|
+
}
|
|
83
|
+
return null;
|
|
43
84
|
}
|
|
44
85
|
|
|
45
86
|
private async collectYamlSources(dirPath: string): Promise<string[]> {
|
|
@@ -50,7 +91,7 @@ export class LocalFileAdapter implements ManifestAdapter {
|
|
|
50
91
|
if (entry.isDirectory()) {
|
|
51
92
|
sources.push(...(await this.collectYamlSources(fullPath)));
|
|
52
93
|
} else if (entry.isFile() && this.isYamlFile(entry.name)) {
|
|
53
|
-
sources.push(
|
|
94
|
+
sources.push(toFileUrl(fullPath));
|
|
54
95
|
}
|
|
55
96
|
}
|
|
56
97
|
return sources;
|
package/src/manifest-schemas.ts
CHANGED
|
@@ -21,41 +21,87 @@ const metadataSchema = {
|
|
|
21
21
|
additionalProperties: true,
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
+
const throwsSchema = {
|
|
25
|
+
type: "object",
|
|
26
|
+
additionalProperties: false,
|
|
27
|
+
properties: {
|
|
28
|
+
codes: {
|
|
29
|
+
type: "object",
|
|
30
|
+
propertyNames: { pattern: "^[A-Z][A-Z0-9_]*$" },
|
|
31
|
+
additionalProperties: {
|
|
32
|
+
type: "object",
|
|
33
|
+
required: ["description"],
|
|
34
|
+
additionalProperties: false,
|
|
35
|
+
properties: {
|
|
36
|
+
description: { type: "string" },
|
|
37
|
+
data: { type: "object", additionalProperties: true },
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
// "my throw union includes every code thrown by every invocable I call
|
|
42
|
+
// (minus codes caught in an enclosing try/catch)". Analyzer enforces
|
|
43
|
+
// that this is only legal on definitions whose schema declares at least
|
|
44
|
+
// one `x-telo-step-context` array.
|
|
45
|
+
inherit: { type: "boolean" },
|
|
46
|
+
// "my throw union is whatever `inputs.code` resolves to statically." Used
|
|
47
|
+
// by passthrough-style adapters. Analyzer resolves per call site.
|
|
48
|
+
passthrough: { type: "boolean" },
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
|
|
24
52
|
const baseDefinition = {
|
|
25
53
|
type: "object",
|
|
26
54
|
required: ["kind", "metadata"],
|
|
27
55
|
properties: {
|
|
28
|
-
kind: { const: "
|
|
56
|
+
kind: { const: "Telo.Definition" },
|
|
29
57
|
metadata: metadataSchema,
|
|
30
58
|
capability: { type: "string" },
|
|
31
59
|
schema: { type: "object", additionalProperties: true },
|
|
32
60
|
controllers: { type: "array", items: { type: "string" } },
|
|
61
|
+
throws: throwsSchema,
|
|
33
62
|
},
|
|
34
63
|
unevaluatedProperties: false,
|
|
35
64
|
};
|
|
36
65
|
|
|
37
66
|
const KNOWN_CAPABILITIES = [
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
67
|
+
"Telo.Service",
|
|
68
|
+
"Telo.Runnable",
|
|
69
|
+
"Telo.Invocable",
|
|
70
|
+
"Telo.Provider",
|
|
71
|
+
"Telo.Type",
|
|
72
|
+
"Telo.Mount",
|
|
44
73
|
] as const;
|
|
45
74
|
|
|
75
|
+
/** Rule 8: `throws:` is only meaningful on Telo.Invocable or Telo.Runnable.
|
|
76
|
+
* On Service/Mount/Provider/Type/etc. a thrown error is a boot-time failure,
|
|
77
|
+
* not a structured runtime error for a downstream caller, so declaring one
|
|
78
|
+
* is a schema error. */
|
|
79
|
+
const forbidThrows = { not: { required: ["throws"] } };
|
|
80
|
+
|
|
46
81
|
export const ResourceDefinitionSchema = {
|
|
47
82
|
...baseDefinition,
|
|
48
83
|
oneOf: [
|
|
49
|
-
{ required: ["capability"], properties: { capability: { const: "Kernel.Service" } } },
|
|
50
|
-
{ required: ["capability"], properties: { capability: { const: "Kernel.Runnable" } } },
|
|
51
|
-
{ required: ["capability"], properties: { capability: { const: "Kernel.Invocable" } } },
|
|
52
|
-
{ required: ["capability"], properties: { capability: { const: "Kernel.Provider" } } },
|
|
53
|
-
{ required: ["capability"], properties: { capability: { const: "Kernel.Type" } } },
|
|
54
84
|
{
|
|
55
85
|
required: ["capability"],
|
|
56
|
-
properties: {
|
|
57
|
-
|
|
58
|
-
|
|
86
|
+
properties: { capability: { const: "Telo.Service" } },
|
|
87
|
+
...forbidThrows,
|
|
88
|
+
},
|
|
89
|
+
{ required: ["capability"], properties: { capability: { const: "Telo.Runnable" } } },
|
|
90
|
+
{ required: ["capability"], properties: { capability: { const: "Telo.Invocable" } } },
|
|
91
|
+
{
|
|
92
|
+
required: ["capability"],
|
|
93
|
+
properties: { capability: { const: "Telo.Provider" } },
|
|
94
|
+
...forbidThrows,
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
required: ["capability"],
|
|
98
|
+
properties: { capability: { const: "Telo.Type" } },
|
|
99
|
+
...forbidThrows,
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
required: ["capability"],
|
|
103
|
+
properties: { capability: { const: "Telo.Mount" } },
|
|
104
|
+
...forbidThrows,
|
|
59
105
|
},
|
|
60
106
|
// Unknown/absent capability: open schema for third-party extensibility
|
|
61
107
|
{
|
package/src/module-context.ts
CHANGED
|
@@ -109,7 +109,7 @@ export class ModuleContext extends EvaluationContext implements IModuleContext {
|
|
|
109
109
|
|
|
110
110
|
/**
|
|
111
111
|
* Register an imported module under the given alias, with the list of kind names
|
|
112
|
-
* it exports. An empty kinds array means no restriction (used for built-ins like
|
|
112
|
+
* it exports. An empty kinds array means no restriction (used for built-ins like Telo).
|
|
113
113
|
*/
|
|
114
114
|
registerImport(alias: string, targetModule: string, kinds: string[]): void {
|
|
115
115
|
this.importAliases.set(alias, targetModule);
|
package/src/resource-context.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
NoopValidator,
|
|
3
3
|
ResourceContext,
|
|
4
|
+
ResourceInstance,
|
|
5
|
+
ResourceManifest,
|
|
4
6
|
RuntimeError,
|
|
5
7
|
RuntimeResource,
|
|
6
8
|
isCompiledValue,
|
|
7
9
|
type EvaluationContext as IEvaluationContext,
|
|
10
|
+
type LoadOptions,
|
|
8
11
|
type ModuleContext,
|
|
9
12
|
type ParsedArgs,
|
|
10
13
|
type TypeRule,
|
|
@@ -19,6 +22,7 @@ import { SchemaValidator } from "./schema-validator.js";
|
|
|
19
22
|
const Ajv = AjvModule.default ?? AjvModule;
|
|
20
23
|
|
|
21
24
|
export class ResourceContextImpl implements ResourceContext {
|
|
25
|
+
readonly env: Record<string, string | undefined>;
|
|
22
26
|
readonly stdin: NodeJS.ReadableStream;
|
|
23
27
|
readonly stdout: NodeJS.WritableStream;
|
|
24
28
|
readonly stderr: NodeJS.WritableStream;
|
|
@@ -29,11 +33,13 @@ export class ResourceContextImpl implements ResourceContext {
|
|
|
29
33
|
readonly moduleContext: ModuleContext,
|
|
30
34
|
private readonly metadata: Record<string, any>,
|
|
31
35
|
private readonly validator: SchemaValidator = new SchemaValidator(),
|
|
36
|
+
env?: Record<string, string | undefined>,
|
|
32
37
|
stdin?: NodeJS.ReadableStream,
|
|
33
38
|
stdout?: NodeJS.WritableStream,
|
|
34
39
|
stderr?: NodeJS.WritableStream,
|
|
35
40
|
args?: ParsedArgs,
|
|
36
41
|
) {
|
|
42
|
+
this.env = env ?? process.env;
|
|
37
43
|
this.stdin = stdin ?? process.stdin;
|
|
38
44
|
this.stdout = stdout ?? process.stdout;
|
|
39
45
|
this.stderr = stderr ?? process.stderr;
|
|
@@ -128,6 +134,15 @@ export class ResourceContextImpl implements ResourceContext {
|
|
|
128
134
|
return this.moduleContext.invoke(kind, name, inputs);
|
|
129
135
|
}
|
|
130
136
|
|
|
137
|
+
invokeResolved<TInputs>(
|
|
138
|
+
kind: string,
|
|
139
|
+
name: string,
|
|
140
|
+
instance: ResourceInstance,
|
|
141
|
+
inputs: TInputs,
|
|
142
|
+
): Promise<any> {
|
|
143
|
+
return this.moduleContext.invokeResolved(kind, name, instance, inputs);
|
|
144
|
+
}
|
|
145
|
+
|
|
131
146
|
async run(name: string) {
|
|
132
147
|
await this.moduleContext.run(name);
|
|
133
148
|
}
|
|
@@ -136,6 +151,14 @@ export class ResourceContextImpl implements ResourceContext {
|
|
|
136
151
|
this.moduleContext.registerManifest(resource);
|
|
137
152
|
}
|
|
138
153
|
|
|
154
|
+
loadModule(url: string, options?: LoadOptions): Promise<ResourceManifest[]> {
|
|
155
|
+
return this.kernel.loadModule(url, options);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
loadManifests(url: string): Promise<ResourceManifest[]> {
|
|
159
|
+
return this.kernel.loadManifests(url);
|
|
160
|
+
}
|
|
161
|
+
|
|
139
162
|
/**
|
|
140
163
|
* Resolves a resource into a normalized {kind, name} reference.
|
|
141
164
|
* If the resource contains a definition (kind + properties), registers it as a manifest.
|
|
@@ -168,12 +191,24 @@ export class ResourceContextImpl implements ResourceContext {
|
|
|
168
191
|
resourceName ??
|
|
169
192
|
`Unnamed${Math.random().toString(16).slice(2, 8)}`;
|
|
170
193
|
|
|
171
|
-
//
|
|
172
|
-
|
|
194
|
+
// Register an inline manifest when:
|
|
195
|
+
// - the ref carries definition properties (clearly an inline definition), or
|
|
196
|
+
// - the ref is bare `{kind}` with no explicit name and the caller supplied
|
|
197
|
+
// a `resourceName` (the slot is known-inline — e.g. a Run.Sequence step
|
|
198
|
+
// with `invoke: {kind: SomeInvocable}` — and wants a fresh stateless
|
|
199
|
+
// instance registered under the generated name).
|
|
200
|
+
// Pure references (`{kind, name}` pointing at an existing resource) carry
|
|
201
|
+
// an explicit name and skip registration.
|
|
202
|
+
const hasInlineProperties = Object.keys(resource).some(
|
|
173
203
|
(k) => k !== "kind" && k !== "name" && k !== "metadata",
|
|
174
204
|
);
|
|
205
|
+
const hasExplicitName =
|
|
206
|
+
resource.name !== undefined || resource.metadata?.name !== undefined;
|
|
207
|
+
const shouldRegister =
|
|
208
|
+
(hasInlineProperties || (!hasExplicitName && resourceName !== undefined)) &&
|
|
209
|
+
!this.moduleContext.hasManifest(name);
|
|
175
210
|
|
|
176
|
-
if (
|
|
211
|
+
if (shouldRegister) {
|
|
177
212
|
this.registerManifest({
|
|
178
213
|
...resource,
|
|
179
214
|
metadata: {
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { ModuleContext, ResourceContext, ResourceDefinition, ResourceInstance, ResourceManifest } from "@telorun/sdk";
|
|
2
|
-
export interface BaseDefinition {
|
|
3
|
-
name: string;
|
|
4
|
-
expand?: {
|
|
5
|
-
compile?: string[];
|
|
6
|
-
runtime?: string[];
|
|
7
|
-
};
|
|
8
|
-
onDefinition?(definition: ResourceDefinition, ctx: ResourceContext): void | Promise<void>;
|
|
9
|
-
onManifest?(manifest: ResourceManifest, ctx: ModuleContext): ResourceManifest | Promise<ResourceManifest>;
|
|
10
|
-
onInit?(instance: ResourceInstance, ctx: ResourceContext): Promise<void>;
|
|
11
|
-
onInvoke?(instance: ResourceInstance, inputs: any, ctx: ResourceContext): Promise<any>;
|
|
12
|
-
}
|
|
13
|
-
export declare function createBaseDefinition(def: BaseDefinition): BaseDefinition;
|
|
14
|
-
//# sourceMappingURL=base-definition.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base-definition.d.ts","sourceRoot":"","sources":["../src/base-definition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,cAAc,CAAC;AAEtB,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE;QACP,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;QACnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;KACpB,CAAC;IACF,YAAY,CAAC,CAAC,UAAU,EAAE,kBAAkB,EAAE,GAAG,EAAE,eAAe,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1F,UAAU,CAAC,CACT,QAAQ,EAAE,gBAAgB,EAC1B,GAAG,EAAE,aAAa,GACjB,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAChD,MAAM,CAAC,CAAC,QAAQ,EAAE,gBAAgB,EAAE,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACzE,QAAQ,CAAC,CAAC,QAAQ,EAAE,gBAAgB,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;CACxF;AAED,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,cAAc,GAAG,cAAc,CAoBxE"}
|
package/dist/base-definition.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export function createBaseDefinition(def) {
|
|
2
|
-
const compile = def.expand?.compile ?? [];
|
|
3
|
-
const runtime = def.expand?.runtime ?? [];
|
|
4
|
-
return {
|
|
5
|
-
...def,
|
|
6
|
-
onManifest: compile.length
|
|
7
|
-
? (manifest, ctx) => ctx.expandPaths(manifest, compile, runtime)
|
|
8
|
-
: def.onManifest,
|
|
9
|
-
onInvoke: runtime.length
|
|
10
|
-
? async (instance, inputs, _ctx) => {
|
|
11
|
-
const expanded = _ctx.moduleContext.expandPaths(inputs, runtime);
|
|
12
|
-
return instance.invoke(expanded);
|
|
13
|
-
}
|
|
14
|
-
: def.onInvoke,
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=base-definition.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base-definition.js","sourceRoot":"","sources":["../src/base-definition.ts"],"names":[],"mappings":"AAuBA,MAAM,UAAU,oBAAoB,CAAC,GAAmB;IACtD,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,EAAE,OAAO,IAAI,EAAE,CAAC;IAC1C,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,EAAE,OAAO,IAAI,EAAE,CAAC;IAE1C,OAAO;QACL,GAAG,GAAG;QACN,UAAU,EAAE,OAAO,CAAC,MAAM;YACxB,CAAC,CAAC,CAAC,QAAQ,EAAE,GAAG,EAAE,EAAE,CAChB,GAAG,CAAC,WAAW,CAAC,QAAmC,EAAE,OAAO,EAAE,OAAO,CAAqB;YAC9F,CAAC,CAAC,GAAG,CAAC,UAAU;QAClB,QAAQ,EAAE,OAAO,CAAC,MAAM;YACtB,CAAC,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE;gBAC/B,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,WAAW,CAC7C,MAAiC,EACjC,OAAO,CACR,CAAC;gBACF,OAAO,QAAQ,CAAC,MAAO,CAAC,QAAQ,CAAC,CAAC;YACpC,CAAC;YACH,CAAC,CAAC,GAAG,CAAC,QAAQ;KACjB,CAAC;AACJ,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../src/capabilities/component.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,eAAO,MAAM,SAAS,EAAE,cAEvB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sourceRoot":"","sources":["../../src/capabilities/component.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,SAAS,GAAmB;IACvC,IAAI,EAAE,WAAW;CAClB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"executable.d.ts","sourceRoot":"","sources":["../../src/capabilities/executable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEvD,eAAO,MAAM,QAAQ,EAAE,kBAGtB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"executable.js","sourceRoot":"","sources":["../../src/capabilities/executable.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,QAAQ,GAAuB;IAC1C,IAAI,EAAE,iBAAiB;IACvB,QAAQ,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE;CACjD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/capabilities/handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,eAAO,MAAM,OAAO,EAAE,cAErB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../src/capabilities/handler.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,OAAO,GAAmB;IACrC,IAAI,EAAE,SAAS;CAChB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"invokable.d.ts","sourceRoot":"","sources":["../../src/capabilities/invokable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEvD,eAAO,MAAM,SAAS,EAAE,kBAGvB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"invokable.js","sourceRoot":"","sources":["../../src/capabilities/invokable.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,SAAS,GAAuB;IAC3C,IAAI,EAAE,iBAAiB;IACvB,QAAQ,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE;CAClD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"listener.d.ts","sourceRoot":"","sources":["../../src/capabilities/listener.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEvD,eAAO,MAAM,OAAO,EAAE,kBAGrB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"listener.js","sourceRoot":"","sources":["../../src/capabilities/listener.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,OAAO,GAAuB;IACzC,IAAI,EAAE,iBAAiB;IACvB,QAAQ,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE;CAChD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mount.d.ts","sourceRoot":"","sources":["../../src/capabilities/mount.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEvD,eAAO,MAAM,KAAK,EAAE,kBAGnB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mount.js","sourceRoot":"","sources":["../../src/capabilities/mount.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,KAAK,GAAuB;IACvC,IAAI,EAAE,iBAAiB;IACvB,QAAQ,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE;CAC9C,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/capabilities/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEvD,eAAO,MAAM,QAAQ,EAAE,kBAMtB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../src/capabilities/provider.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,QAAQ,GAAuB;IAC1C,IAAI,EAAE,iBAAiB;IACvB,QAAQ,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE;IAChD,MAAM,EAAE;QACN,OAAO,EAAE,CAAC,IAAI,CAAC;KAChB;CACF,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runnable.d.ts","sourceRoot":"","sources":["../../src/capabilities/runnable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEvD,eAAO,MAAM,QAAQ,EAAE,kBAGtB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runnable.js","sourceRoot":"","sources":["../../src/capabilities/runnable.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,QAAQ,GAAuB;IAC1C,IAAI,EAAE,iBAAiB;IACvB,QAAQ,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE;CACjD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/capabilities/service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEvD,eAAO,MAAM,OAAO,EAAE,kBAGrB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/capabilities/service.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,OAAO,GAAuB;IACzC,IAAI,EAAE,iBAAiB;IACvB,QAAQ,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE;CAChD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../../src/capabilities/template.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEvD,eAAO,MAAM,QAAQ,EAAE,kBAGtB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../src/capabilities/template.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,QAAQ,GAAuB;IAC1C,IAAI,EAAE,iBAAiB;IACvB,QAAQ,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE;CACjD,CAAC"}
|