@telorun/kernel 0.42.0 → 0.44.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/dist/bundle/files-integrity.d.ts +25 -0
- package/dist/bundle/files-integrity.d.ts.map +1 -0
- package/dist/bundle/files-integrity.js +40 -0
- package/dist/bundle/files-integrity.js.map +1 -0
- package/dist/bundle/module-manifest.d.ts +22 -0
- package/dist/bundle/module-manifest.d.ts.map +1 -0
- package/dist/bundle/module-manifest.js +33 -0
- package/dist/bundle/module-manifest.js.map +1 -0
- package/dist/bundle/tar.d.ts +20 -0
- package/dist/bundle/tar.d.ts.map +1 -0
- package/dist/bundle/tar.js +63 -0
- package/dist/bundle/tar.js.map +1 -0
- package/dist/controllers/resource-definition/resource-definition-controller.d.ts +2 -0
- package/dist/controllers/resource-definition/resource-definition-controller.d.ts.map +1 -1
- package/dist/controllers/resource-definition/resource-definition-controller.js +46 -0
- package/dist/controllers/resource-definition/resource-definition-controller.js.map +1 -1
- package/dist/controllers/resource-definition/resource-inherited-controller.d.ts +21 -0
- package/dist/controllers/resource-definition/resource-inherited-controller.d.ts.map +1 -0
- package/dist/controllers/resource-definition/resource-inherited-controller.js +130 -0
- package/dist/controllers/resource-definition/resource-inherited-controller.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/kernel.d.ts +11 -1
- package/dist/kernel.d.ts.map +1 -1
- package/dist/kernel.js +21 -2
- package/dist/kernel.js.map +1 -1
- package/dist/manifest-sources/local-manifest-cache-source.d.ts +1 -1
- package/dist/manifest-sources/local-manifest-cache-source.d.ts.map +1 -1
- package/dist/manifest-sources/local-manifest-cache-source.js +14 -93
- package/dist/manifest-sources/local-manifest-cache-source.js.map +1 -1
- package/dist/resource-context.d.ts +8 -0
- package/dist/resource-context.d.ts.map +1 -1
- package/dist/resource-context.js +10 -0
- package/dist/resource-context.js.map +1 -1
- package/dist/transports/oci/docker-credentials.d.ts +10 -0
- package/dist/transports/oci/docker-credentials.d.ts.map +1 -0
- package/dist/transports/oci/docker-credentials.js +75 -0
- package/dist/transports/oci/docker-credentials.js.map +1 -0
- package/dist/transports/oci/oci-client.d.ts +51 -0
- package/dist/transports/oci/oci-client.d.ts.map +1 -0
- package/dist/transports/oci/oci-client.js +170 -0
- package/dist/transports/oci/oci-client.js.map +1 -0
- package/dist/transports/oci/oci-ref.d.ts +21 -0
- package/dist/transports/oci/oci-ref.d.ts.map +1 -0
- package/dist/transports/oci/oci-ref.js +36 -0
- package/dist/transports/oci/oci-ref.js.map +1 -0
- package/dist/transports/oci/oci-transport.d.ts +29 -0
- package/dist/transports/oci/oci-transport.d.ts.map +1 -0
- package/dist/transports/oci/oci-transport.js +142 -0
- package/dist/transports/oci/oci-transport.js.map +1 -0
- package/dist/transports/registry-transport.d.ts +23 -0
- package/dist/transports/registry-transport.d.ts.map +1 -0
- package/dist/transports/registry-transport.js +225 -0
- package/dist/transports/registry-transport.js.map +1 -0
- package/dist/transports/transport-registry.d.ts +40 -0
- package/dist/transports/transport-registry.d.ts.map +1 -0
- package/dist/transports/transport-registry.js +70 -0
- package/dist/transports/transport-registry.js.map +1 -0
- package/dist/transports/transport.d.ts +92 -0
- package/dist/transports/transport.d.ts.map +1 -0
- package/dist/transports/transport.js +2 -0
- package/dist/transports/transport.js.map +1 -0
- package/package.json +7 -4
- package/src/bundle/files-integrity.ts +46 -0
- package/src/bundle/module-manifest.ts +49 -0
- package/src/bundle/tar.ts +78 -0
- package/src/controllers/resource-definition/resource-definition-controller.ts +65 -0
- package/src/controllers/resource-definition/resource-inherited-controller.ts +167 -0
- package/src/index.ts +22 -0
- package/src/kernel.ts +24 -2
- package/src/manifest-sources/local-manifest-cache-source.ts +14 -99
- package/src/resource-context.ts +14 -0
- package/src/transports/oci/docker-credentials.ts +85 -0
- package/src/transports/oci/oci-client.ts +237 -0
- package/src/transports/oci/oci-ref.ts +53 -0
- package/src/transports/oci/oci-transport.ts +192 -0
- package/src/transports/registry-transport.ts +281 -0
- package/src/transports/transport-registry.ts +91 -0
- package/src/transports/transport.ts +112 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface PayloadFile {
|
|
2
|
+
/** POSIX-relative path inside the bundle. */
|
|
3
|
+
name: string;
|
|
4
|
+
content: Buffer | Uint8Array;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Canonical per-file content digest of a module's `files:` payload — the value
|
|
8
|
+
* of `filesIntegrity` in a bundle's `telo.yaml`. SHA-256 over the sorted
|
|
9
|
+
* `<path>\0<sha256(content)>` lines of every payload file, `telo.yaml`
|
|
10
|
+
* excluded (the importer's `#sha256-...` hash already covers the manifest, and
|
|
11
|
+
* excluding it breaks the self-reference — the manifest embeds this value).
|
|
12
|
+
*
|
|
13
|
+
* Hashing file *contents* rather than the tar/gzip bytes makes the digest
|
|
14
|
+
* independent of archive framing, so publisher and client compute the same
|
|
15
|
+
* value from the same file set, and it can be re-derived from the extracted
|
|
16
|
+
* files on disk. Returns `sha256-<base64url>`.
|
|
17
|
+
*/
|
|
18
|
+
export declare function computeFilesIntegrity(files: PayloadFile[]): Promise<string>;
|
|
19
|
+
/** Write `filesIntegrity` onto the manifest's owner doc so the published
|
|
20
|
+
* `telo.yaml` pins its payload — transitively covered by importers'
|
|
21
|
+
* `#sha256-...` hash. The digest excludes `telo.yaml`, so injecting it does
|
|
22
|
+
* not change the digest. Returns the manifest unchanged when it has no owner
|
|
23
|
+
* doc. */
|
|
24
|
+
export declare function injectFilesIntegrity(manifest: string, hash: string): string;
|
|
25
|
+
//# sourceMappingURL=files-integrity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files-integrity.d.ts","sourceRoot":"","sources":["../../src/bundle/files-integrity.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,WAAW;IAC1B,6CAA6C;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,GAAG,UAAU,CAAC;CAC9B;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,qBAAqB,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAUjF;AAED;;;;WAIW;AACX,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAM3E"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { DEFAULT_MANIFEST_FILENAME, sha256Base64Url } from "@telorun/analyzer";
|
|
2
|
+
import { findOwnerDoc, parseManifestDocs } from "./module-manifest.js";
|
|
3
|
+
/**
|
|
4
|
+
* Canonical per-file content digest of a module's `files:` payload — the value
|
|
5
|
+
* of `filesIntegrity` in a bundle's `telo.yaml`. SHA-256 over the sorted
|
|
6
|
+
* `<path>\0<sha256(content)>` lines of every payload file, `telo.yaml`
|
|
7
|
+
* excluded (the importer's `#sha256-...` hash already covers the manifest, and
|
|
8
|
+
* excluding it breaks the self-reference — the manifest embeds this value).
|
|
9
|
+
*
|
|
10
|
+
* Hashing file *contents* rather than the tar/gzip bytes makes the digest
|
|
11
|
+
* independent of archive framing, so publisher and client compute the same
|
|
12
|
+
* value from the same file set, and it can be re-derived from the extracted
|
|
13
|
+
* files on disk. Returns `sha256-<base64url>`.
|
|
14
|
+
*/
|
|
15
|
+
export async function computeFilesIntegrity(files) {
|
|
16
|
+
const lines = [];
|
|
17
|
+
for (const file of files) {
|
|
18
|
+
if (file.name === DEFAULT_MANIFEST_FILENAME)
|
|
19
|
+
continue;
|
|
20
|
+
const bytes = file.content instanceof Uint8Array ? file.content : new Uint8Array(file.content);
|
|
21
|
+
lines.push(`${file.name}\0${await sha256Base64Url(bytes)}`);
|
|
22
|
+
}
|
|
23
|
+
lines.sort();
|
|
24
|
+
const canonical = new TextEncoder().encode(lines.join("\n"));
|
|
25
|
+
return `sha256-${await sha256Base64Url(canonical)}`;
|
|
26
|
+
}
|
|
27
|
+
/** Write `filesIntegrity` onto the manifest's owner doc so the published
|
|
28
|
+
* `telo.yaml` pins its payload — transitively covered by importers'
|
|
29
|
+
* `#sha256-...` hash. The digest excludes `telo.yaml`, so injecting it does
|
|
30
|
+
* not change the digest. Returns the manifest unchanged when it has no owner
|
|
31
|
+
* doc. */
|
|
32
|
+
export function injectFilesIntegrity(manifest, hash) {
|
|
33
|
+
const docs = parseManifestDocs(manifest);
|
|
34
|
+
const owner = findOwnerDoc(docs);
|
|
35
|
+
if (!owner)
|
|
36
|
+
return manifest;
|
|
37
|
+
owner.set("filesIntegrity", hash);
|
|
38
|
+
return docs.map((d) => d.toString()).join("---\n");
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=files-integrity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files-integrity.js","sourceRoot":"","sources":["../../src/bundle/files-integrity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAE/E,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAQvE;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,KAAoB;IAC9D,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,IAAI,CAAC,IAAI,KAAK,yBAAyB;YAAE,SAAS;QACtD,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,YAAY,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC/F,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,KAAK,MAAM,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAC9D,CAAC;IACD,KAAK,CAAC,IAAI,EAAE,CAAC;IACb,MAAM,SAAS,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC7D,OAAO,UAAU,MAAM,eAAe,CAAC,SAAS,CAAC,EAAE,CAAC;AACtD,CAAC;AAED;;;;WAIW;AACX,MAAM,UAAU,oBAAoB,CAAC,QAAgB,EAAE,IAAY;IACjE,MAAM,IAAI,GAAG,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IACzC,MAAM,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IACjC,IAAI,CAAC,KAAK;QAAE,OAAO,QAAQ,CAAC;IAC5B,KAAK,CAAC,GAAG,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;IAClC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACrD,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type Document } from "yaml";
|
|
2
|
+
/** Parse a manifest's YAML documents, tolerating its `!cel` / `!ref` tags. */
|
|
3
|
+
export declare function parseManifestDocs(text: string): Document[];
|
|
4
|
+
/** The owner document of a manifest — the single `Telo.Application` /
|
|
5
|
+
* `Telo.Library` doc that carries its identity, `files:`, and `filesIntegrity`.
|
|
6
|
+
* The one place that selects it, shared by every reader/writer. */
|
|
7
|
+
export declare function findOwnerDoc(docs: Document[]): Document | undefined;
|
|
8
|
+
/** The owner-doc fields the transports read: identity for the publish location,
|
|
9
|
+
* and payload markers for artifact fetch. */
|
|
10
|
+
export interface OwnerManifest {
|
|
11
|
+
namespace?: string;
|
|
12
|
+
name?: string;
|
|
13
|
+
version?: string;
|
|
14
|
+
filesIntegrity?: string;
|
|
15
|
+
/** True when the owner doc declares a non-empty `files:` list. */
|
|
16
|
+
declaresFiles: boolean;
|
|
17
|
+
}
|
|
18
|
+
/** Read the owner doc's identity + payload fields from a manifest, parsing once
|
|
19
|
+
* (never regex-scraping). The single source both transports call for
|
|
20
|
+
* `<namespace>/<name>/<version>`, `filesIntegrity`, and payload detection. */
|
|
21
|
+
export declare function readOwnerManifest(text: string): OwnerManifest;
|
|
22
|
+
//# sourceMappingURL=module-manifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module-manifest.d.ts","sourceRoot":"","sources":["../../src/bundle/module-manifest.ts"],"names":[],"mappings":"AACA,OAAO,EAAqB,KAAK,QAAQ,EAAE,MAAM,MAAM,CAAC;AAIxD,8EAA8E;AAC9E,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,EAAE,CAE1D;AAED;;oEAEoE;AACpE,wBAAgB,YAAY,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,QAAQ,GAAG,SAAS,CAKnE;AAED;8CAC8C;AAC9C,MAAM,WAAW,aAAa;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,kEAAkE;IAClE,aAAa,EAAE,OAAO,CAAC;CACxB;AAED;;+EAE+E;AAC/E,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,CAc7D"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { defaultCustomTags } from "@telorun/templating";
|
|
2
|
+
import { parseAllDocuments } from "yaml";
|
|
3
|
+
const OWNER_KINDS = new Set(["Telo.Application", "Telo.Library"]);
|
|
4
|
+
/** Parse a manifest's YAML documents, tolerating its `!cel` / `!ref` tags. */
|
|
5
|
+
export function parseManifestDocs(text) {
|
|
6
|
+
return parseAllDocuments(text, { customTags: defaultCustomTags() });
|
|
7
|
+
}
|
|
8
|
+
/** The owner document of a manifest — the single `Telo.Application` /
|
|
9
|
+
* `Telo.Library` doc that carries its identity, `files:`, and `filesIntegrity`.
|
|
10
|
+
* The one place that selects it, shared by every reader/writer. */
|
|
11
|
+
export function findOwnerDoc(docs) {
|
|
12
|
+
return docs.find((d) => {
|
|
13
|
+
const kind = d.toJSON()?.kind;
|
|
14
|
+
return kind !== undefined && OWNER_KINDS.has(kind);
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
/** Read the owner doc's identity + payload fields from a manifest, parsing once
|
|
18
|
+
* (never regex-scraping). The single source both transports call for
|
|
19
|
+
* `<namespace>/<name>/<version>`, `filesIntegrity`, and payload detection. */
|
|
20
|
+
export function readOwnerManifest(text) {
|
|
21
|
+
const owner = findOwnerDoc(parseManifestDocs(text));
|
|
22
|
+
const parsed = owner?.toJSON();
|
|
23
|
+
const md = parsed?.metadata ?? {};
|
|
24
|
+
const str = (v) => (typeof v === "string" ? v : undefined);
|
|
25
|
+
return {
|
|
26
|
+
namespace: str(md.namespace),
|
|
27
|
+
name: str(md.name),
|
|
28
|
+
version: str(md.version),
|
|
29
|
+
filesIntegrity: str(parsed?.filesIntegrity),
|
|
30
|
+
declaresFiles: Array.isArray(parsed?.files) && parsed.files.length > 0,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=module-manifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module-manifest.js","sourceRoot":"","sources":["../../src/bundle/module-manifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAiB,MAAM,MAAM,CAAC;AAExD,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,CAAC,kBAAkB,EAAE,cAAc,CAAC,CAAC,CAAC;AAElE,8EAA8E;AAC9E,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC5C,OAAO,iBAAiB,CAAC,IAAI,EAAE,EAAE,UAAU,EAAE,iBAAiB,EAAE,EAAE,CAAC,CAAC;AACtE,CAAC;AAED;;oEAEoE;AACpE,MAAM,UAAU,YAAY,CAAC,IAAgB;IAC3C,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;QACrB,MAAM,IAAI,GAAI,CAAC,CAAC,MAAM,EAA+B,EAAE,IAAI,CAAC;QAC5D,OAAO,IAAI,KAAK,SAAS,IAAI,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;AACL,CAAC;AAaD;;+EAE+E;AAC/E,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC5C,MAAM,KAAK,GAAG,YAAY,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC;IACpD,MAAM,MAAM,GAAG,KAAK,EAAE,MAAM,EAEf,CAAC;IACd,MAAM,EAAE,GAAG,MAAM,EAAE,QAAQ,IAAI,EAAE,CAAC;IAClC,MAAM,GAAG,GAAG,CAAC,CAAU,EAAsB,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IACxF,OAAO;QACL,SAAS,EAAE,GAAG,CAAC,EAAE,CAAC,SAAS,CAAC;QAC5B,IAAI,EAAE,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC;QAClB,OAAO,EAAE,GAAG,CAAC,EAAE,CAAC,OAAO,CAAC;QACxB,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC;QAC3C,aAAa,EAAE,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC;KACvE,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { PayloadFile } from "./files-integrity.js";
|
|
2
|
+
export interface BundleEntry {
|
|
3
|
+
/** POSIX-relative path inside the archive (e.g. `telo.yaml`, `public/app.js`). */
|
|
4
|
+
name: string;
|
|
5
|
+
content: Buffer | string;
|
|
6
|
+
}
|
|
7
|
+
/** Normalize decoded tar entries to `PayloadFile`s (Buffer-backed content) —
|
|
8
|
+
* the fixed step both transports run after `readTarGz`. */
|
|
9
|
+
export declare function toPayloadFiles(entries: BundleEntry[]): PayloadFile[];
|
|
10
|
+
/**
|
|
11
|
+
* Pack `entries` into a gzipped tar (`module.tar.gz`) — the module-artifact
|
|
12
|
+
* writer shared by `telo publish` and the transports. Artifacts are small (a
|
|
13
|
+
* manifest plus a built frontend), so buffering the whole archive before gzip
|
|
14
|
+
* is fine. (Distinct from `apps/k8s-runner/src/tar.ts`, which is coupled to
|
|
15
|
+
* `@telorun/runner-core`'s `RunBundle`.)
|
|
16
|
+
*/
|
|
17
|
+
export declare function makeTarGz(entries: BundleEntry[]): Promise<Buffer>;
|
|
18
|
+
/** Decompress + untar a `module.tar.gz` buffer into its file entries. */
|
|
19
|
+
export declare function readTarGz(buf: Buffer): Promise<BundleEntry[]>;
|
|
20
|
+
//# sourceMappingURL=tar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tar.d.ts","sourceRoot":"","sources":["../../src/bundle/tar.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAExD,MAAM,WAAW,WAAW;IAC1B,kFAAkF;IAClF,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;CAC1B;AAED;4DAC4D;AAC5D,wBAAgB,cAAc,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,WAAW,EAAE,CAKpE;AAED;;;;;;GAMG;AACH,wBAAsB,SAAS,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAoBvE;AAED,yEAAyE;AACzE,wBAAsB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CA0BnE"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { extract as tarExtract, pack as tarPack } from "tar-stream";
|
|
2
|
+
import { gunzipSync, gzipSync } from "node:zlib";
|
|
3
|
+
import { Readable } from "node:stream";
|
|
4
|
+
/** Normalize decoded tar entries to `PayloadFile`s (Buffer-backed content) —
|
|
5
|
+
* the fixed step both transports run after `readTarGz`. */
|
|
6
|
+
export function toPayloadFiles(entries) {
|
|
7
|
+
return entries.map((e) => ({
|
|
8
|
+
name: e.name,
|
|
9
|
+
content: typeof e.content === "string" ? Buffer.from(e.content) : e.content,
|
|
10
|
+
}));
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Pack `entries` into a gzipped tar (`module.tar.gz`) — the module-artifact
|
|
14
|
+
* writer shared by `telo publish` and the transports. Artifacts are small (a
|
|
15
|
+
* manifest plus a built frontend), so buffering the whole archive before gzip
|
|
16
|
+
* is fine. (Distinct from `apps/k8s-runner/src/tar.ts`, which is coupled to
|
|
17
|
+
* `@telorun/runner-core`'s `RunBundle`.)
|
|
18
|
+
*/
|
|
19
|
+
export async function makeTarGz(entries) {
|
|
20
|
+
const pack = tarPack();
|
|
21
|
+
const chunks = [];
|
|
22
|
+
pack.on("data", (c) => chunks.push(c));
|
|
23
|
+
const done = new Promise((resolve, reject) => {
|
|
24
|
+
pack.on("end", resolve);
|
|
25
|
+
pack.on("error", reject);
|
|
26
|
+
});
|
|
27
|
+
for (const entry of entries) {
|
|
28
|
+
const buf = typeof entry.content === "string" ? Buffer.from(entry.content, "utf-8") : entry.content;
|
|
29
|
+
await new Promise((resolve, reject) => {
|
|
30
|
+
pack.entry({ name: entry.name }, buf, (err) => (err ? reject(err) : resolve()));
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
pack.finalize();
|
|
34
|
+
await done;
|
|
35
|
+
return gzipSync(Buffer.concat(chunks));
|
|
36
|
+
}
|
|
37
|
+
/** Decompress + untar a `module.tar.gz` buffer into its file entries. */
|
|
38
|
+
export async function readTarGz(buf) {
|
|
39
|
+
const tar = gunzipSync(buf);
|
|
40
|
+
const ex = tarExtract();
|
|
41
|
+
const entries = [];
|
|
42
|
+
await new Promise((resolve, reject) => {
|
|
43
|
+
ex.on("entry", (header, stream, next) => {
|
|
44
|
+
if (header.type !== "file") {
|
|
45
|
+
stream.on("end", next);
|
|
46
|
+
stream.resume();
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const chunks = [];
|
|
50
|
+
stream.on("data", (c) => chunks.push(c));
|
|
51
|
+
stream.on("end", () => {
|
|
52
|
+
entries.push({ name: header.name, content: Buffer.concat(chunks) });
|
|
53
|
+
next();
|
|
54
|
+
});
|
|
55
|
+
stream.on("error", reject);
|
|
56
|
+
});
|
|
57
|
+
ex.on("finish", resolve);
|
|
58
|
+
ex.on("error", reject);
|
|
59
|
+
Readable.from(tar).pipe(ex);
|
|
60
|
+
});
|
|
61
|
+
return entries;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=tar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tar.js","sourceRoot":"","sources":["../../src/bundle/tar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,IAAI,IAAI,OAAO,EAAE,MAAM,YAAY,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAUvC;4DAC4D;AAC5D,MAAM,UAAU,cAAc,CAAC,OAAsB;IACnD,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACzB,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,OAAO,EAAE,OAAO,CAAC,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,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B,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource-definition-controller.d.ts","sourceRoot":"","sources":["../../../src/controllers/resource-definition/resource-definition-controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,eAAe,
|
|
1
|
+
{"version":3,"file":"resource-definition-controller.d.ts","sourceRoot":"","sources":["../../../src/controllers/resource-definition/resource-definition-controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,eAAe,EAEf,gBAAgB,EAChB,eAAe,EAChB,MAAM,cAAc,CAAC;AAatB,KAAK,0BAA0B,GAAG,eAAe,GAAG;IAClD,IAAI,EAAE,iBAAiB,CAAC;IACxB,QAAQ,EAAE;QACR,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;QACnB,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,WAAW,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF;;;GAGG;AACH,cAAM,kBAAmB,YAAW,gBAAgB;IAGtC,QAAQ,CAAC,QAAQ,EAAE,0BAA0B;IAFzD,QAAQ,CAAC,IAAI,EAAE,oBAAoB,CAAwB;gBAEtC,QAAQ,EAAE,0BAA0B;IAEnD,IAAI,CAAC,GAAG,EAAE,eAAe;CAqHhC;AAeD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,iBAAiB,GAAG,IAAI,CAErD;AAED,wBAAsB,MAAM,CAAC,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAW7F;AAED,eAAO,MAAM,MAAM;;;CAGlB,CAAC"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import { RuntimeError } from "@telorun/sdk";
|
|
2
|
+
import { controllerBearingAncestor, hasOwnControllerOrTemplate, inheritedCapability, } from "@telorun/analyzer";
|
|
1
3
|
import { ControllerLoader } from "../../controller-loader.js";
|
|
2
4
|
import { formatAjvErrors, validateResourceDefinition } from "../../manifest-schemas.js";
|
|
3
5
|
import { createTemplateController } from "./resource-template-controller.js";
|
|
6
|
+
import { createInheritedController } from "./resource-inherited-controller.js";
|
|
4
7
|
/**
|
|
5
8
|
* ResourceDefinition resource - acts as metadata holder for resource type definitions
|
|
6
9
|
* Validates incoming definitions against schema and maintains definition metadata
|
|
@@ -11,6 +14,49 @@ class ResourceDefinition {
|
|
|
11
14
|
this.kind = "ResourceDefinition";
|
|
12
15
|
}
|
|
13
16
|
async init(ctx) {
|
|
17
|
+
const definingCtx = ctx.moduleContext;
|
|
18
|
+
// Resolve an `extends`/kind target (alias or canonical form) to its
|
|
19
|
+
// definition against the DEFINING library's scope — where the `extends`
|
|
20
|
+
// alias was declared.
|
|
21
|
+
const resolveDef = (kind) => {
|
|
22
|
+
let canonical = kind;
|
|
23
|
+
try {
|
|
24
|
+
canonical = definingCtx.resolveKind(kind);
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
// ungated / unqualified — fall back to the raw kind below
|
|
28
|
+
}
|
|
29
|
+
return definingCtx.getDefinition?.(canonical) ?? definingCtx.getDefinition?.(kind);
|
|
30
|
+
};
|
|
31
|
+
// Inherited-controller delegation: a definition that `extends` a concrete
|
|
32
|
+
// kind, declares no own `controllers:` / template body, inherits the parent
|
|
33
|
+
// controller by delegation and maps its config via `base:`.
|
|
34
|
+
if (this.resource.extends && !hasOwnControllerOrTemplate(this.resource)) {
|
|
35
|
+
const parentDef = resolveDef(this.resource.extends);
|
|
36
|
+
if (!parentDef) {
|
|
37
|
+
// The parent's Telo.Definition (and thus its controller) isn't loaded
|
|
38
|
+
// yet — defer; the multi-pass init loop retries once its import resolves.
|
|
39
|
+
throw new RuntimeError("ERR_LOCAL_REF_PENDING", `Telo.Definition '${this.resource.metadata.name}': 'extends' target '${this.resource.extends}' is not loaded yet.`);
|
|
40
|
+
}
|
|
41
|
+
if (controllerBearingAncestor(this.resource, resolveDef)) {
|
|
42
|
+
// Capability is inherited and immutable — stamp the resolved capability
|
|
43
|
+
// so every consumer that reads `definition.capability` (compile-CEL eval
|
|
44
|
+
// paths, `capabilityOf`, lifecycle role) sees the effective role without
|
|
45
|
+
// re-walking `extends`.
|
|
46
|
+
if (!this.resource.capability) {
|
|
47
|
+
const inherited = inheritedCapability(this.resource, resolveDef);
|
|
48
|
+
if (inherited)
|
|
49
|
+
this.resource.capability = inherited;
|
|
50
|
+
}
|
|
51
|
+
const controllerInstance = createInheritedController(this.resource, definingCtx, resolveDef);
|
|
52
|
+
ctx.registerDefinition(this.resource);
|
|
53
|
+
await ctx.registerController(this.resource.metadata.module, this.resource.metadata.name, controllerInstance);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
// Otherwise the chain reaches no controller-bearing concrete ancestor
|
|
57
|
+
// (e.g. it implements a pure abstract) — fall through to the normal
|
|
58
|
+
// template / controller handling below.
|
|
59
|
+
}
|
|
14
60
|
if (!this.resource.controllers?.length) {
|
|
15
61
|
if (this.resource.capability === "Telo.Provider" && this.resource.provide == null) {
|
|
16
62
|
throw new Error(`Telo.Definition '${this.resource.metadata.name}': 'capability: Telo.Provider' requires either 'controllers:' (TS-backed) or 'provide:' (template-backed).`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource-definition-controller.js","sourceRoot":"","sources":["../../../src/controllers/resource-definition/resource-definition-controller.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"resource-definition-controller.js","sourceRoot":"","sources":["../../../src/controllers/resource-definition/resource-definition-controller.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EACL,yBAAyB,EACzB,0BAA0B,EAC1B,mBAAmB,GAEpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AACxF,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAiB/E;;;GAGG;AACH,MAAM,kBAAkB;IAGtB,YAAqB,QAAoC;QAApC,aAAQ,GAAR,QAAQ,CAA4B;QAFhD,SAAI,GAAyB,oBAAoB,CAAC;IAEC,CAAC;IAE7D,KAAK,CAAC,IAAI,CAAC,GAAoB;QAC7B,MAAM,WAAW,GAAG,GAAG,CAAC,aAAa,CAAC;QACtC,oEAAoE;QACpE,wEAAwE;QACxE,sBAAsB;QACtB,MAAM,UAAU,GAAgB,CAAC,IAAI,EAAE,EAAE;YACvC,IAAI,SAAS,GAAG,IAAI,CAAC;YACrB,IAAI,CAAC;gBACH,SAAS,GAAG,WAAW,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;YAC5C,CAAC;YAAC,MAAM,CAAC;gBACP,0DAA0D;YAC5D,CAAC;YACD,OAAO,WAAW,CAAC,aAAa,EAAE,CAAC,SAAS,CAAC,IAAI,WAAW,CAAC,aAAa,EAAE,CAAC,IAAI,CAAC,CAAC;QACrF,CAAC,CAAC;QAEF,0EAA0E;QAC1E,4EAA4E;QAC5E,4DAA4D;QAC5D,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,IAAI,CAAC,0BAA0B,CAAC,IAAI,CAAC,QAAsC,CAAC,EAAE,CAAC;YACtG,MAAM,SAAS,GAAG,UA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E,CAChH,CAAC;IACJ,CAAC;IAED,oDAAoD;IACpD,MAAM,UAAU,GAAG,QAAiD,CAAC;IACrE,OAAO,IAAI,kBAAkB,CAAC,UAAU,CAAC,CAAC;AAC5C,CAAC;AAED,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,IAAI,EAAE,QAAQ;IACd,oBAAoB,EAAE,IAAI;CAC3B,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ControllerInstance, EvaluationContext, ResourceDefinition, ResourceInstance } from "@telorun/sdk";
|
|
2
|
+
import { type DefResolver } from "@telorun/analyzer";
|
|
3
|
+
/** Typed internal seam implemented by the concrete `ResourceContextImpl`: runs
|
|
4
|
+
* the kernel's create phase for the parent-kind manifest and returns the native
|
|
5
|
+
* parent instance (or null when the parent controller isn't registered yet — a
|
|
6
|
+
* retry, same as `_createInstance`). Off the public SDK surface, like
|
|
7
|
+
* `registerLazyController`. */
|
|
8
|
+
export interface InheritedInstanceHost {
|
|
9
|
+
createInheritedInstance(evalContext: EvaluationContext, resource: Record<string, unknown>): Promise<ResourceInstance | null>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Controller for a definition that inherits its controller by delegation — it
|
|
13
|
+
* `extends` a concrete kind, declares no own `controllers:` / template body, and
|
|
14
|
+
* maps the parent's config via `base:`. `create()` evaluates `base:` against the
|
|
15
|
+
* child instance's config (`self`, with reference slots resolved to live
|
|
16
|
+
* instances) and constructs the parent kind through {@link InheritedInstanceHost},
|
|
17
|
+
* returning that native parent instance verbatim so the child duck-types as its
|
|
18
|
+
* parent (e.g. inherits `.snapshot()`).
|
|
19
|
+
*/
|
|
20
|
+
export declare function createInheritedController(definition: ResourceDefinition, definingContext: EvaluationContext, resolveDef: DefResolver): ControllerInstance;
|
|
21
|
+
//# sourceMappingURL=resource-inherited-controller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-inherited-controller.d.ts","sourceRoot":"","sources":["../../../src/controllers/resource-definition/resource-inherited-controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,iBAAiB,EAEjB,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAIL,KAAK,WAAW,EACjB,MAAM,mBAAmB,CAAC;AAG3B;;;;gCAIgC;AAChC,MAAM,WAAW,qBAAqB;IACpC,uBAAuB,CACrB,WAAW,EAAE,iBAAiB,EAC9B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;CACrC;AAqED;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CACvC,UAAU,EAAE,kBAAkB,EAC9B,eAAe,EAAE,iBAAiB,EAClC,UAAU,EAAE,WAAW,GACtB,kBAAkB,CA0DpB"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { isCompiledValue } from "@telorun/sdk";
|
|
2
|
+
import { buildReferenceFieldMap, effectiveAuthorSchema, isRefEntry, } from "@telorun/analyzer";
|
|
3
|
+
import { isRefSentinel } from "@telorun/templating";
|
|
4
|
+
/** Matches a CEL source that is exactly a `self.<path>` member access — resolved
|
|
5
|
+
* by direct navigation so live resource instances (which CEL's output type
|
|
6
|
+
* checker rejects) can flow through `base:` untouched. */
|
|
7
|
+
const SELF_PATH = /^self((?:\.[A-Za-z_$][\w$]*)+)$/;
|
|
8
|
+
const hasSnapshot = (v) => !!v && typeof v.snapshot === "function";
|
|
9
|
+
/** Resolves a reference-slot value to its live instance, or undefined when the
|
|
10
|
+
* referenced resource isn't initialized yet. A value that is already a live
|
|
11
|
+
* instance (has `snapshot()`) passes through. Post Phase-2.5 a slot holds a
|
|
12
|
+
* `{kind, name, alias?}` object; a raw `!ref` sentinel (only reachable behind a
|
|
13
|
+
* hidden `$ref` slot) is normalized through the sanctioned `ctx.resolveChildren`
|
|
14
|
+
* so the reference grammar (alias/Self splitting) stays in one place. */
|
|
15
|
+
function resolveRefSlot(value, ctx) {
|
|
16
|
+
if (hasSnapshot(value))
|
|
17
|
+
return value;
|
|
18
|
+
let name;
|
|
19
|
+
let alias;
|
|
20
|
+
if (isRefSentinel(value)) {
|
|
21
|
+
const ref = ctx.resolveChildren(value);
|
|
22
|
+
name = ref.name;
|
|
23
|
+
alias = ref.alias;
|
|
24
|
+
}
|
|
25
|
+
else if (value && typeof value === "object") {
|
|
26
|
+
const ref = value;
|
|
27
|
+
if (typeof ref.name === "string") {
|
|
28
|
+
name = ref.name;
|
|
29
|
+
alias = typeof ref.alias === "string" ? ref.alias : undefined;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (!name)
|
|
33
|
+
return undefined;
|
|
34
|
+
const instance = alias && alias !== "Self"
|
|
35
|
+
? ctx.moduleContext.resolveImportedInstance(alias, name)
|
|
36
|
+
: ctx.moduleContext.resourceInstances.get(name)?.instance;
|
|
37
|
+
return instance ?? undefined;
|
|
38
|
+
}
|
|
39
|
+
/** Expand a `base:` node against `self`. Self-only CEL resolves to literals now;
|
|
40
|
+
* a pure `self.<path>` access is navigated directly so live instances pass
|
|
41
|
+
* through. */
|
|
42
|
+
function expandBaseNode(value, self, ctx) {
|
|
43
|
+
if (isCompiledValue(value)) {
|
|
44
|
+
const src = typeof value.source === "string" ? value.source.trim() : "";
|
|
45
|
+
const m = src.match(SELF_PATH);
|
|
46
|
+
if (m) {
|
|
47
|
+
let cur = self;
|
|
48
|
+
for (const key of m[1].split(".").slice(1)) {
|
|
49
|
+
cur = cur?.[key];
|
|
50
|
+
}
|
|
51
|
+
return cur;
|
|
52
|
+
}
|
|
53
|
+
return ctx.expandWith(value, { self });
|
|
54
|
+
}
|
|
55
|
+
if (Array.isArray(value))
|
|
56
|
+
return value.map((v) => expandBaseNode(v, self, ctx));
|
|
57
|
+
if (value !== null && typeof value === "object" && Object.getPrototypeOf(value) === Object.prototype) {
|
|
58
|
+
const out = {};
|
|
59
|
+
for (const [k, v] of Object.entries(value)) {
|
|
60
|
+
out[k] = expandBaseNode(v, self, ctx);
|
|
61
|
+
}
|
|
62
|
+
return out;
|
|
63
|
+
}
|
|
64
|
+
return value;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Controller for a definition that inherits its controller by delegation — it
|
|
68
|
+
* `extends` a concrete kind, declares no own `controllers:` / template body, and
|
|
69
|
+
* maps the parent's config via `base:`. `create()` evaluates `base:` against the
|
|
70
|
+
* child instance's config (`self`, with reference slots resolved to live
|
|
71
|
+
* instances) and constructs the parent kind through {@link InheritedInstanceHost},
|
|
72
|
+
* returning that native parent instance verbatim so the child duck-types as its
|
|
73
|
+
* parent (e.g. inherits `.snapshot()`).
|
|
74
|
+
*/
|
|
75
|
+
export function createInheritedController(definition, definingContext, resolveDef) {
|
|
76
|
+
const authorSchema = effectiveAuthorSchema(definition, resolveDef);
|
|
77
|
+
const parentKind = definition.extends;
|
|
78
|
+
if (!parentKind) {
|
|
79
|
+
throw new Error(`Telo.Definition '${definition.metadata.name}': inherited controller requires an 'extends' target.`);
|
|
80
|
+
}
|
|
81
|
+
const base = definition.base;
|
|
82
|
+
// Top-level reference fields on the author-facing schema — resolved to live
|
|
83
|
+
// instances before `base:` runs so a `!cel "self.<ref>"` passthrough forwards
|
|
84
|
+
// the live parent instance (e.g. a `client` into an inherited Http.Request).
|
|
85
|
+
const refFieldPaths = [];
|
|
86
|
+
for (const [path, entry] of buildReferenceFieldMap(authorSchema)) {
|
|
87
|
+
if (isRefEntry(entry) && !path.includes(".") && !path.includes("["))
|
|
88
|
+
refFieldPaths.push(path);
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
schema: authorSchema,
|
|
92
|
+
create: async (resource, ctx) => {
|
|
93
|
+
const self = { ...resource, name: resource.metadata.name };
|
|
94
|
+
for (const path of refFieldPaths) {
|
|
95
|
+
const raw = resource[path];
|
|
96
|
+
if (raw == null)
|
|
97
|
+
continue;
|
|
98
|
+
const live = resolveRefSlot(raw, ctx);
|
|
99
|
+
// A reference that is set but hasn't resolved yet means the dependency
|
|
100
|
+
// isn't initialized — defer via the retry signal, like _createInstance.
|
|
101
|
+
if (!live)
|
|
102
|
+
return null;
|
|
103
|
+
self[path] = live;
|
|
104
|
+
}
|
|
105
|
+
// With `base:`, it maps `self` onto the parent's (narrowed) config. Without
|
|
106
|
+
// it, the child is a pure additive extension: it carries the parent's config
|
|
107
|
+
// fields directly, so forward them (reference slots already resolved to live
|
|
108
|
+
// instances in `self`), minus the reserved keys.
|
|
109
|
+
let parentConfig;
|
|
110
|
+
if (base != null) {
|
|
111
|
+
parentConfig = expandBaseNode(base, self, definingContext);
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
const { kind: _kind, metadata: _metadata, name: _name, ...config } = self;
|
|
115
|
+
parentConfig = config;
|
|
116
|
+
}
|
|
117
|
+
const parentResource = {
|
|
118
|
+
kind: parentKind,
|
|
119
|
+
metadata: { ...resource.metadata },
|
|
120
|
+
...parentConfig,
|
|
121
|
+
};
|
|
122
|
+
const host = ctx;
|
|
123
|
+
if (typeof host.createInheritedInstance !== "function") {
|
|
124
|
+
throw new Error(`Telo.Definition '${definition.metadata.name}': inherited controller requires a ResourceContext host that implements createInheritedInstance().`);
|
|
125
|
+
}
|
|
126
|
+
return host.createInheritedInstance(definingContext, parentResource);
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=resource-inherited-controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-inherited-controller.js","sourceRoot":"","sources":["../../../src/controllers/resource-definition/resource-inherited-controller.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EACL,sBAAsB,EACtB,qBAAqB,EACrB,UAAU,GAEX,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAcpD;;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SAAS;gBAC1B,MAAM,IAAI,GAAG,cAAc,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;gBACtC,uEAAuE;gBACvE,wEAAwE;gBACxE,IAAI,CAAC,IAAI;oBAAE,OAAO,IAAI,CAAC;gBACvB,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;YACpB,CAAC;YAED,4EAA4E;YAC5E,6EAA6E;YAC7E,6EAA6E;YAC7E,iDAAiD;YACjD,IAAI,YAAqC,CAAC;YAC1C,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;gBACjB,YAAY,GAAG,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,eAAe,CAA4B,CAAC;YACxF,CAAC;iBAAM,CAAC;gBACN,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,EAAE,GAAG,IAAI,CAAC;gBAC1E,YAAY,GAAG,MAAM,CAAC;YACxB,CAAC;YACD,MAAM,cAAc,GAA4B;gBAC9C,IAAI,EAAE,UAAU;gBAChB,QAAQ,EAAE,EAAE,GAAG,QAAQ,CAAC,QAAQ,EAAE;gBAClC,GAAG,YAAY;aAChB,CAAC;YACF,MAAM,IAAI,GAAG,GAAuC,CAAC;YACrD,IAAI,OAAQ,IAA8C,CAAC,uBAAuB,KAAK,UAAU,EAAE,CAAC;gBAClG,MAAM,IAAI,KAAK,CACb,oBAAoB,UAAU,CAAC,QAAQ,CAAC,IAAI,oGAAoG,CACjJ,CAAC;YACJ,CAAC;YACD,OAAO,IAAI,CAAC,uBAAuB,CAAC,eAAe,EAAE,cAAc,CAAC,CAAC;QACvE,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,15 @@ export { EvaluationContext } from "./evaluation-context.js";
|
|
|
4
4
|
export { LocalFileSource } from "./manifest-sources/local-file-source.js";
|
|
5
5
|
export { LocalManifestCacheSource, cachePathForCanonical, resolveCacheRoot, resolveEntryDir, writeManifestCache, } from "./manifest-sources/local-manifest-cache-source.js";
|
|
6
6
|
export { MemorySource } from "./manifest-sources/memory-source.js";
|
|
7
|
+
export type { Transport } from "./transports/transport.js";
|
|
8
|
+
export { RegistryTransport } from "./transports/registry-transport.js";
|
|
9
|
+
export { OciTransport } from "./transports/oci/oci-transport.js";
|
|
10
|
+
export { OciClient } from "./transports/oci/oci-client.js";
|
|
11
|
+
export { isOciRef, parseOciRef, type ParsedOciRef } from "./transports/oci/oci-ref.js";
|
|
12
|
+
export { TransportRegistry, defaultTransports, defaultTransportRegistry, } from "./transports/transport-registry.js";
|
|
13
|
+
export { makeTarGz, readTarGz, type BundleEntry } from "./bundle/tar.js";
|
|
14
|
+
export { computeFilesIntegrity, injectFilesIntegrity, type PayloadFile, } from "./bundle/files-integrity.js";
|
|
15
|
+
export type { FetchedArtifact, PublishBundle, PublishResult, PublishOptions, } from "./transports/transport.js";
|
|
7
16
|
export { ExecutionContext } from "./execution-context.js";
|
|
8
17
|
export { Kernel, type KernelOptions } from "./kernel.js";
|
|
9
18
|
export { nodeCelHandlers } from "./cel-handlers.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAC1E,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACrB,gBAAgB,EAChB,eAAe,EACf,kBAAkB,GACnB,MAAM,mDAAmD,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,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MAAM,iBAAiB,CAAC;AACzE,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,KAAK,WAAW,GACjB,MAAM,6BAA6B,CAAC;AACrC,YAAY,EACV,eAAe,EACf,aAAa,EACb,aAAa,EACb,cAAc,GACf,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,gBAAgB,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,YAAY,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,13 @@ export { EvaluationContext } from "./evaluation-context.js";
|
|
|
4
4
|
export { LocalFileSource } from "./manifest-sources/local-file-source.js";
|
|
5
5
|
export { LocalManifestCacheSource, cachePathForCanonical, resolveCacheRoot, resolveEntryDir, writeManifestCache, } from "./manifest-sources/local-manifest-cache-source.js";
|
|
6
6
|
export { MemorySource } from "./manifest-sources/memory-source.js";
|
|
7
|
+
export { RegistryTransport } from "./transports/registry-transport.js";
|
|
8
|
+
export { OciTransport } from "./transports/oci/oci-transport.js";
|
|
9
|
+
export { OciClient } from "./transports/oci/oci-client.js";
|
|
10
|
+
export { isOciRef, parseOciRef } from "./transports/oci/oci-ref.js";
|
|
11
|
+
export { TransportRegistry, defaultTransports, defaultTransportRegistry, } from "./transports/transport-registry.js";
|
|
12
|
+
export { makeTarGz, readTarGz } from "./bundle/tar.js";
|
|
13
|
+
export { computeFilesIntegrity, injectFilesIntegrity, } from "./bundle/files-integrity.js";
|
|
7
14
|
export { ExecutionContext } from "./execution-context.js";
|
|
8
15
|
export { Kernel } from "./kernel.js";
|
|
9
16
|
export { nodeCelHandlers } from "./cel-handlers.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAC1E,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACrB,gBAAgB,EAChB,eAAe,EACf,kBAAkB,GACnB,MAAM,mDAAmD,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAC1E,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACrB,gBAAgB,EAChB,eAAe,EACf,kBAAkB,GACnB,MAAM,mDAAmD,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAEnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAqB,MAAM,6BAA6B,CAAC;AACvF,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,wBAAwB,GACzB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAoB,MAAM,iBAAiB,CAAC;AACzE,OAAO,EACL,qBAAqB,EACrB,oBAAoB,GAErB,MAAM,6BAA6B,CAAC;AAOrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAsB,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,gBAAgB,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/kernel.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AnalysisRegistry, type LoadedGraph, type ManifestSource } from "@telorun/analyzer";
|
|
2
|
-
import { Kernel as IKernel, ResourceDefinition, ResourceManifest, RuntimeEvent, type InvokeOptions, type LoadOptions } from "@telorun/sdk";
|
|
2
|
+
import { Kernel as IKernel, ResourceDefinition, ResourceInstance, ResourceManifest, RuntimeEvent, type EvaluationContext as IEvaluationContext, type InvokeOptions, type LoadOptions } from "@telorun/sdk";
|
|
3
3
|
export interface KernelOptions {
|
|
4
4
|
stdin?: NodeJS.ReadableStream;
|
|
5
5
|
stdout?: NodeJS.WritableStream;
|
|
@@ -239,6 +239,16 @@ export declare class Kernel implements IKernel {
|
|
|
239
239
|
* is not yet registered (retry signal).
|
|
240
240
|
*/
|
|
241
241
|
private _createInstance;
|
|
242
|
+
/**
|
|
243
|
+
* Create phase for an inherited (concrete-`extends`) definition's parent: runs
|
|
244
|
+
* the ordinary create pipeline (controller resolution + lazy load, schema
|
|
245
|
+
* validation, compile-CEL expansion, ctx creation) for the parent-kind
|
|
246
|
+
* manifest built from `base:`, and returns the native parent instance. The
|
|
247
|
+
* inherited child's controller returns this verbatim so the child duck-types
|
|
248
|
+
* as its parent. Null means the parent controller isn't registered yet — the
|
|
249
|
+
* caller propagates it as the create-phase retry signal.
|
|
250
|
+
*/
|
|
251
|
+
createInheritedInstance(evalContext: IEvaluationContext, resource: ResourceManifest): Promise<ResourceInstance | null>;
|
|
242
252
|
/**
|
|
243
253
|
* Phase 5 — Inject live instances into reference fields of a resource config.
|
|
244
254
|
*
|
package/dist/kernel.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kernel.d.ts","sourceRoot":"","sources":["../src/kernel.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,
|
|
1
|
+
{"version":3,"file":"kernel.d.ts","sourceRoot":"","sources":["../src/kernel.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAOhB,KAAK,WAAW,EAChB,KAAK,cAAc,EACpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAIL,MAAM,IAAI,OAAO,EAEjB,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAEhB,YAAY,EAGZ,KAAK,iBAAiB,IAAI,kBAAkB,EAC5C,KAAK,aAAa,EAElB,KAAK,WAAW,EAEjB,MAAM,cAAc,CAAC;AAsDtB,MAAM,WAAW,aAAa;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC;IAC/B,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IACzC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB;;;wEAGoE;IACpE,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B;;8EAE0E;IAC1E,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,qB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