@telorun/analyzer 0.4.0 → 0.6.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 +0 -4
- package/dist/analyzer.d.ts.map +1 -1
- package/dist/analyzer.js +62 -2
- package/dist/cel-environment.d.ts +11 -2
- package/dist/cel-environment.d.ts.map +1 -1
- package/dist/cel-environment.js +13 -2
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/manifest-loader.d.ts +5 -5
- package/dist/manifest-loader.d.ts.map +1 -1
- package/dist/manifest-loader.js +35 -35
- package/dist/normalize-inline-resources.js +22 -0
- package/dist/reference-field-map.d.ts +14 -3
- package/dist/reference-field-map.d.ts.map +1 -1
- package/dist/reference-field-map.js +39 -4
- package/dist/{adapters/http-adapter.d.ts → sources/http-source.d.ts} +3 -3
- package/dist/sources/http-source.d.ts.map +1 -0
- package/dist/{adapters/http-adapter.js → sources/http-source.js} +1 -1
- package/dist/{adapters/registry-adapter.d.ts → sources/registry-source.d.ts} +3 -3
- package/dist/sources/registry-source.d.ts.map +1 -0
- package/dist/{adapters/registry-adapter.js → sources/registry-source.js} +1 -1
- package/dist/types.d.ts +10 -10
- package/dist/types.d.ts.map +1 -1
- package/dist/validate-cel-context.d.ts +2 -1
- package/dist/validate-cel-context.d.ts.map +1 -1
- package/dist/validate-cel-context.js +30 -3
- package/package.json +2 -2
- package/src/analyzer.ts +81 -0
- package/src/cel-environment.ts +13 -3
- package/src/index.ts +7 -4
- package/src/manifest-loader.ts +34 -34
- package/src/normalize-inline-resources.ts +23 -0
- package/src/reference-field-map.ts +39 -4
- package/src/{adapters/http-adapter.ts → sources/http-source.ts} +2 -2
- package/src/{adapters/registry-adapter.ts → sources/registry-source.ts} +2 -2
- package/src/types.ts +10 -10
- package/src/validate-cel-context.ts +32 -3
- package/dist/adapters/http-adapter.d.ts.map +0 -1
- package/dist/adapters/registry-adapter.d.ts.map +0 -1
package/README.md
CHANGED
package/dist/analyzer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyzer.d.ts","sourceRoot":"","sources":["../src/analyzer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAsB,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAGL,KAAK,WAAW,EACjB,MAAM,sBAAsB,CAAC;AAa9B,OAAO,EAAsB,KAAK,kBAAkB,EAAE,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"analyzer.d.ts","sourceRoot":"","sources":["../src/analyzer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAsB,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAGL,KAAK,WAAW,EACjB,MAAM,sBAAsB,CAAC;AAa9B,OAAO,EAAsB,KAAK,kBAAkB,EAAE,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AAmT/F,MAAM,WAAW,qBAAqB;IACpC,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B;AAED,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAc;gBAEzB,OAAO,GAAE,qBAA0B;IAI/C,OAAO,CACL,SAAS,EAAE,gBAAgB,EAAE,EAC7B,OAAO,CAAC,EAAE,eAAe,EACzB,QAAQ,CAAC,EAAE,gBAAgB,GAC1B,kBAAkB,EAAE;IA2TvB,aAAa,CACX,SAAS,EAAE,gBAAgB,EAAE,EAC7B,OAAO,CAAC,EAAE,eAAe,EACzB,QAAQ,CAAC,EAAE,gBAAgB,GAC1B,kBAAkB,EAAE;IAMvB,SAAS,CAAC,SAAS,EAAE,gBAAgB,EAAE,EAAE,QAAQ,EAAE,gBAAgB,GAAG,gBAAgB,EAAE;IAKxF,OAAO,CACL,SAAS,EAAE,gBAAgB,EAAE,EAC7B,QAAQ,EAAE,gBAAgB,GACzB;QAAE,WAAW,EAAE,kBAAkB,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;QAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE;CAiB5F"}
|
package/dist/analyzer.js
CHANGED
|
@@ -13,6 +13,29 @@ import { validateExtends } from "./validate-extends.js";
|
|
|
13
13
|
import { validateReferences } from "./validate-references.js";
|
|
14
14
|
import { validateThrowsCoverage } from "./validate-throws-coverage.js";
|
|
15
15
|
const TEMPLATE_REGEX = /\$\{\{\s*([^}]+?)\s*\}\}/g;
|
|
16
|
+
const SELF_PREFIX = "Self.";
|
|
17
|
+
/** Resolve an alias-prefixed kind value (e.g. `Self.Encoder` or `Ai.Model`)
|
|
18
|
+
* to its canonical form. `Self.<Name>` resolves to `<ownModule>.<Name>` —
|
|
19
|
+
* the magic alias for "this library's own module" — and other prefixes
|
|
20
|
+
* resolve through the declaring file's Telo.Import aliases. */
|
|
21
|
+
function resolveSelfOrAlias(value, ownModule, scopeResolver) {
|
|
22
|
+
if (value.startsWith(SELF_PREFIX) && ownModule) {
|
|
23
|
+
return `${ownModule}.${value.slice(SELF_PREFIX.length)}`;
|
|
24
|
+
}
|
|
25
|
+
return scopeResolver.resolveKind(value);
|
|
26
|
+
}
|
|
27
|
+
/** Look up a top-level field (`outputType`, `inputType`) on a kind's
|
|
28
|
+
* `Telo.Definition`. Used as a fallback by `buildStepContextSchema` when the
|
|
29
|
+
* invoked resource manifest doesn't carry the field inline — most kinds
|
|
30
|
+
* declare result shape on the definition, not the resource. */
|
|
31
|
+
function lookupDefinitionTypeField(invokedKind, fieldName, defs, aliases, allManifests) {
|
|
32
|
+
const canonical = aliases.resolveKind(invokedKind) ?? invokedKind;
|
|
33
|
+
const def = defs.resolve(canonical);
|
|
34
|
+
if (!def)
|
|
35
|
+
return undefined;
|
|
36
|
+
const value = def[fieldName];
|
|
37
|
+
return resolveTypeFieldToSchema(value, allManifests);
|
|
38
|
+
}
|
|
16
39
|
function walkCelExpressions(value, path, cb) {
|
|
17
40
|
if (typeof value === "string") {
|
|
18
41
|
for (const m of value.matchAll(TEMPLATE_REGEX)) {
|
|
@@ -62,8 +85,20 @@ function extractContextsFromSchema(schema, path = "$") {
|
|
|
62
85
|
* Build a `steps` context schema from `x-telo-step-context` annotation.
|
|
63
86
|
* Walks each step in the manifest array, resolves the invoked resource's outputType,
|
|
64
87
|
* and builds `steps.<name>.result` context entries.
|
|
88
|
+
*
|
|
89
|
+
* outputType resolution falls through three layers:
|
|
90
|
+
* 1. The invoked resource manifest's own `outputType` field (rare — most
|
|
91
|
+
* resources don't declare outputType inline).
|
|
92
|
+
* 2. The kind's `Telo.Definition` outputType (the common case for kinds that
|
|
93
|
+
* declare a stable result shape, e.g. `Ai.TextStream` ↦ `{output: stream}`).
|
|
94
|
+
* 3. Permissive `{type: object, additionalProperties: true}` if neither
|
|
95
|
+
* yields a schema.
|
|
96
|
+
*
|
|
97
|
+
* Layer 2 is what makes `x-telo-stream` properties on definitions actually
|
|
98
|
+
* govern step-result chain validation — without it, the validator falls back
|
|
99
|
+
* to permissive and the stream-opacity rule never fires.
|
|
65
100
|
*/
|
|
66
|
-
function buildStepContextSchema(manifest, defSchema, allManifests) {
|
|
101
|
+
function buildStepContextSchema(manifest, defSchema, allManifests, defs, aliases) {
|
|
67
102
|
const props = defSchema.properties;
|
|
68
103
|
if (!props)
|
|
69
104
|
return undefined;
|
|
@@ -101,6 +136,11 @@ function buildStepContextSchema(manifest, defSchema, allManifests) {
|
|
|
101
136
|
else {
|
|
102
137
|
outputSchema = resolveTypeFieldToSchema(invoke[outputTypeField], allManifests);
|
|
103
138
|
}
|
|
139
|
+
// Fallback: pull outputType from the kind's Telo.Definition. The
|
|
140
|
+
// resource manifest typically doesn't carry outputType; the def does.
|
|
141
|
+
if (!outputSchema && invokedKind) {
|
|
142
|
+
outputSchema = lookupDefinitionTypeField(invokedKind, outputTypeField, defs, aliases, allManifests);
|
|
143
|
+
}
|
|
104
144
|
}
|
|
105
145
|
stepProperties[name] = {
|
|
106
146
|
type: "object",
|
|
@@ -235,6 +275,26 @@ export class StaticAnalyzer {
|
|
|
235
275
|
const moduleName = m.metadata.name;
|
|
236
276
|
if (moduleName)
|
|
237
277
|
defs.registerModuleIdentity(namespace, moduleName);
|
|
278
|
+
// Auto-register `Self` as an alias for this library's own module name.
|
|
279
|
+
// Lets same-library `extends:` work (e.g. `extends: Self.Encoder` for a
|
|
280
|
+
// concrete kind whose abstract lives in the same Telo.Library) without
|
|
281
|
+
// requiring a self-import (which would loop the loader). Resolves
|
|
282
|
+
// through the same alias machinery as user-declared Telo.Imports —
|
|
283
|
+
// honours the library's `exports.kinds` list, no special cases.
|
|
284
|
+
if (moduleName) {
|
|
285
|
+
const exportedKinds = m.exports?.kinds ?? [];
|
|
286
|
+
if (rootModules.has(moduleName)) {
|
|
287
|
+
aliases.registerImport("Self", moduleName, exportedKinds);
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
let libResolver = aliasesByModule.get(moduleName);
|
|
291
|
+
if (!libResolver) {
|
|
292
|
+
libResolver = new AliasResolver();
|
|
293
|
+
aliasesByModule.set(moduleName, libResolver);
|
|
294
|
+
}
|
|
295
|
+
libResolver.registerImport("Self", moduleName, exportedKinds);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
238
298
|
}
|
|
239
299
|
if (m.kind === "Telo.Import") {
|
|
240
300
|
const alias = m.metadata.name;
|
|
@@ -381,7 +441,7 @@ export class StaticAnalyzer {
|
|
|
381
441
|
const mDefinition = defs.resolve(m.kind) ?? (resolvedKind ? defs.resolve(resolvedKind) : undefined);
|
|
382
442
|
// Pre-compute step context for manifests with x-telo-step-context
|
|
383
443
|
const stepContextSchema = mDefinition?.schema
|
|
384
|
-
? buildStepContextSchema(m, mDefinition.schema, allManifests)
|
|
444
|
+
? buildStepContextSchema(m, mDefinition.schema, allManifests, defs, aliases)
|
|
385
445
|
: undefined;
|
|
386
446
|
walkCelExpressions(m, "", (expr, path) => {
|
|
387
447
|
let parsed;
|
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
import { Environment } from "@marcbachmann/cel-js";
|
|
2
|
-
import type
|
|
2
|
+
import { type ResourceManifest } from "@telorun/sdk";
|
|
3
3
|
export interface CelHandlers {
|
|
4
4
|
sha256: (s: string) => string;
|
|
5
5
|
}
|
|
6
6
|
/** Build a CEL `Environment` with Telo's stdlib of functions. Always registers the
|
|
7
7
|
* same function signatures (so `env.check()` succeeds for type-inference) — the
|
|
8
8
|
* handlers govern what the function does when called at runtime. Analyzer-only
|
|
9
|
-
* callers can omit handlers; runtime callers (kernel) must supply real ones.
|
|
9
|
+
* callers can omit handlers; runtime callers (kernel) must supply real ones.
|
|
10
|
+
*
|
|
11
|
+
* Also registers the `Stream` object type, backed by the `Stream` class from
|
|
12
|
+
* `@telorun/sdk`. CEL's type-checker rejects values whose constructor isn't
|
|
13
|
+
* Object/Map/Array/Set/registered; producers that need to expose an
|
|
14
|
+
* `AsyncIterable` through a stream-typed property must wrap the iterable in
|
|
15
|
+
* `new Stream(...)` so its constructor is the registered class. The type has
|
|
16
|
+
* no fields, so terminal access (passing the value through CEL) succeeds but
|
|
17
|
+
* member access raises a CEL error at runtime — matching the analyzer's
|
|
18
|
+
* static check on `x-telo-stream`-marked properties. */
|
|
10
19
|
export declare function buildCelEnvironment(handlers?: CelHandlers): Environment;
|
|
11
20
|
/** Clone `baseEnv` and register typed variable declarations so that
|
|
12
21
|
* `env.check(expr)` can infer return types for expressions referencing known variables.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cel-environment.d.ts","sourceRoot":"","sources":["../src/cel-environment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"cel-environment.d.ts","sourceRoot":"","sources":["../src/cel-environment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAU,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAG7D,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;CAC/B;AAaD;;;;;;;;;;;;yDAYyD;AACzD,wBAAgB,mBAAmB,CAAC,QAAQ,GAAE,WAA2B,GAAG,WAAW,CAetF;AAED;;;;;;;;;uEASuE;AACvE,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,WAAW,EACpB,QAAQ,EAAE,gBAAgB,EAC1B,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,GAC9C,WAAW,CAyCb"}
|
package/dist/cel-environment.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Environment } from "@marcbachmann/cel-js";
|
|
2
|
+
import { Stream } from "@telorun/sdk";
|
|
2
3
|
import { jsonSchemaToCelType } from "./schema-compat.js";
|
|
3
4
|
const stub = (name) => () => {
|
|
4
5
|
throw new Error(`${name}() is not available in this environment. ` +
|
|
@@ -10,7 +11,16 @@ const STUB_HANDLERS = {
|
|
|
10
11
|
/** Build a CEL `Environment` with Telo's stdlib of functions. Always registers the
|
|
11
12
|
* same function signatures (so `env.check()` succeeds for type-inference) — the
|
|
12
13
|
* handlers govern what the function does when called at runtime. Analyzer-only
|
|
13
|
-
* callers can omit handlers; runtime callers (kernel) must supply real ones.
|
|
14
|
+
* callers can omit handlers; runtime callers (kernel) must supply real ones.
|
|
15
|
+
*
|
|
16
|
+
* Also registers the `Stream` object type, backed by the `Stream` class from
|
|
17
|
+
* `@telorun/sdk`. CEL's type-checker rejects values whose constructor isn't
|
|
18
|
+
* Object/Map/Array/Set/registered; producers that need to expose an
|
|
19
|
+
* `AsyncIterable` through a stream-typed property must wrap the iterable in
|
|
20
|
+
* `new Stream(...)` so its constructor is the registered class. The type has
|
|
21
|
+
* no fields, so terminal access (passing the value through CEL) succeeds but
|
|
22
|
+
* member access raises a CEL error at runtime — matching the analyzer's
|
|
23
|
+
* static check on `x-telo-stream`-marked properties. */
|
|
14
24
|
export function buildCelEnvironment(handlers = STUB_HANDLERS) {
|
|
15
25
|
return new Environment({ unlistedVariablesAreDyn: true })
|
|
16
26
|
.registerFunction("join(list, string): string", (list, sep) => list.map(String).join(sep))
|
|
@@ -24,7 +34,8 @@ export function buildCelEnvironment(handlers = STUB_HANDLERS) {
|
|
|
24
34
|
return [...map.values()];
|
|
25
35
|
return Object.values(map);
|
|
26
36
|
})
|
|
27
|
-
.registerFunction("sha256(string): string", (s) => handlers.sha256(s))
|
|
37
|
+
.registerFunction("sha256(string): string", (s) => handlers.sha256(s))
|
|
38
|
+
.registerType("Stream", Stream);
|
|
28
39
|
}
|
|
29
40
|
/** Clone `baseEnv` and register typed variable declarations so that
|
|
30
41
|
* `env.check(expr)` can infer return types for expressions referencing known variables.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export { HttpAdapter } from "./adapters/http-adapter.js";
|
|
2
|
-
export { RegistryAdapter } from "./adapters/registry-adapter.js";
|
|
3
1
|
export { AnalysisRegistry } from "./analysis-registry.js";
|
|
4
2
|
export { StaticAnalyzer } from "./analyzer.js";
|
|
5
3
|
export { Loader } from "./manifest-loader.js";
|
|
6
|
-
export {
|
|
4
|
+
export { isModuleKind, MODULE_KINDS } from "./module-kinds.js";
|
|
7
5
|
export type { ModuleKind } from "./module-kinds.js";
|
|
6
|
+
export { HttpSource } from "./sources/http-source.js";
|
|
7
|
+
export { RegistrySource } from "./sources/registry-source.js";
|
|
8
8
|
export { DEFAULT_MANIFEST_FILENAME, DiagnosticSeverity } from "./types.js";
|
|
9
|
-
export type { AnalysisDiagnostic, AnalysisOptions, LoaderInitOptions, LoadOptions,
|
|
9
|
+
export type { AnalysisDiagnostic, AnalysisOptions, LoaderInitOptions, LoadOptions, ManifestSource, Position, PositionIndex, Range } from "./types.js";
|
|
10
10
|
//# sourceMappingURL=index.d.ts.map
|
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,
|
|
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,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC/D,YAAY,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAC3E,YAAY,EACR,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,WAAW,EACX,cAAc,EACd,QAAQ,EACR,aAAa,EACb,KAAK,EACR,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { HttpAdapter } from "./adapters/http-adapter.js";
|
|
2
|
-
export { RegistryAdapter } from "./adapters/registry-adapter.js";
|
|
3
1
|
export { AnalysisRegistry } from "./analysis-registry.js";
|
|
4
2
|
export { StaticAnalyzer } from "./analyzer.js";
|
|
5
3
|
export { Loader } from "./manifest-loader.js";
|
|
6
|
-
export {
|
|
4
|
+
export { isModuleKind, MODULE_KINDS } from "./module-kinds.js";
|
|
5
|
+
export { HttpSource } from "./sources/http-source.js";
|
|
6
|
+
export { RegistrySource } from "./sources/registry-source.js";
|
|
7
7
|
export { DEFAULT_MANIFEST_FILENAME, DiagnosticSeverity } from "./types.js";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { type ResourceManifest } from "@telorun/sdk";
|
|
2
|
-
import { type LoadOptions, type LoaderInitOptions, type
|
|
2
|
+
import { type LoadOptions, type LoaderInitOptions, type ManifestSource } from "./types.js";
|
|
3
3
|
export declare class Loader {
|
|
4
|
-
private
|
|
5
|
-
protected
|
|
4
|
+
private readonly moduleCache;
|
|
5
|
+
protected sources: ManifestSource[];
|
|
6
6
|
private readonly celEnv;
|
|
7
|
-
constructor(
|
|
8
|
-
register(
|
|
7
|
+
constructor(extraSourcesOrOptions?: ManifestSource[] | LoaderInitOptions);
|
|
8
|
+
register(source: ManifestSource): this;
|
|
9
9
|
private pick;
|
|
10
10
|
resolveEntryPoint(url: string): Promise<string>;
|
|
11
11
|
loadModule(url: string, options?: LoadOptions): Promise<ResourceManifest[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest-loader.d.ts","sourceRoot":"","sources":["../src/manifest-loader.ts"],"names":[],"mappings":"AACA,OAAO,EAAmB,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAOtE,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,
|
|
1
|
+
{"version":3,"file":"manifest-loader.d.ts","sourceRoot":"","sources":["../src/manifest-loader.ts"],"names":[],"mappings":"AACA,OAAO,EAAmB,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAOtE,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EAGpB,MAAM,YAAY,CAAC;AASpB,qBAAa,MAAM;IACjB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAGxB;IAEJ,SAAS,CAAC,OAAO,EAAE,cAAc,EAAE,CAAC;IACpC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAc;gBAEzB,qBAAqB,GAAE,cAAc,EAAE,GAAG,iBAAsB;IAmB5E,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI;IAKtC,OAAO,CAAC,IAAI;IAMN,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAK/C,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;YAqGnE,eAAe;YAoBf,eAAe;IAgEvB,iBAAiB,CACrB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC;QACT,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,gBAAgB,EAAE,CAAC;QAC9B,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,gBAAgB,EAAE,CAAC,CAAC;KAClD,GAAG,IAAI,CAAC;IAiCH,eAAe,CACnB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,KAAK,IAAI,GAC5C,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,gBAAgB,EAAE,CAAC,CAAC;IAsCrC,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;CA2GnE"}
|
package/dist/manifest-loader.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isCompiledValue } from "@telorun/sdk";
|
|
2
2
|
import { isMap, isPair, isScalar, isSeq, parseAllDocuments } from "yaml";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { HttpSource } from "./sources/http-source.js";
|
|
4
|
+
import { RegistrySource } from "./sources/registry-source.js";
|
|
5
5
|
import { buildCelEnvironment } from "./cel-environment.js";
|
|
6
6
|
import { isModuleKind } from "./module-kinds.js";
|
|
7
7
|
import { precompileDoc } from "./precompile.js";
|
|
@@ -13,34 +13,34 @@ const SYSTEM_KINDS = new Set([
|
|
|
13
13
|
"Telo.Definition",
|
|
14
14
|
]);
|
|
15
15
|
export class Loader {
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
moduleCache = new Map();
|
|
17
|
+
sources;
|
|
18
18
|
celEnv;
|
|
19
|
-
constructor(
|
|
20
|
-
const options = Array.isArray(
|
|
21
|
-
? {
|
|
22
|
-
:
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
this.
|
|
26
|
-
if (
|
|
27
|
-
this.
|
|
28
|
-
if (
|
|
29
|
-
this.
|
|
30
|
-
if (options.
|
|
31
|
-
this.
|
|
19
|
+
constructor(extraSourcesOrOptions = []) {
|
|
20
|
+
const options = Array.isArray(extraSourcesOrOptions)
|
|
21
|
+
? { extraSources: extraSourcesOrOptions }
|
|
22
|
+
: extraSourcesOrOptions;
|
|
23
|
+
const includeHttpSource = options.includeHttpSource ?? true;
|
|
24
|
+
const includeRegistrySource = options.includeRegistrySource ?? true;
|
|
25
|
+
this.sources = [];
|
|
26
|
+
if (includeHttpSource)
|
|
27
|
+
this.sources.push(new HttpSource());
|
|
28
|
+
if (includeRegistrySource)
|
|
29
|
+
this.sources.push(new RegistrySource(options.registryUrl));
|
|
30
|
+
if (options.extraSources?.length) {
|
|
31
|
+
this.sources.unshift(...options.extraSources);
|
|
32
32
|
}
|
|
33
33
|
this.celEnv = buildCelEnvironment(options.celHandlers);
|
|
34
34
|
}
|
|
35
|
-
register(
|
|
36
|
-
this.
|
|
35
|
+
register(source) {
|
|
36
|
+
this.sources.unshift(source);
|
|
37
37
|
return this;
|
|
38
38
|
}
|
|
39
39
|
pick(url) {
|
|
40
|
-
const
|
|
41
|
-
if (!
|
|
42
|
-
throw new Error(`No
|
|
43
|
-
return
|
|
40
|
+
const s = this.sources.find((s) => s.supports(url));
|
|
41
|
+
if (!s)
|
|
42
|
+
throw new Error(`No source found for: ${url}`);
|
|
43
|
+
return s;
|
|
44
44
|
}
|
|
45
45
|
async resolveEntryPoint(url) {
|
|
46
46
|
const { source } = await this.pick(url).read(url);
|
|
@@ -49,7 +49,7 @@ export class Loader {
|
|
|
49
49
|
async loadModule(url, options) {
|
|
50
50
|
const { text, source } = await this.pick(url).read(url);
|
|
51
51
|
const cacheKey = `${options?.compile ? "compiled" : "raw"}:${source}`;
|
|
52
|
-
const cached =
|
|
52
|
+
const cached = this.moduleCache.get(cacheKey);
|
|
53
53
|
if (cached && cached.text === text) {
|
|
54
54
|
return cloneManifestArray(cached.manifests);
|
|
55
55
|
}
|
|
@@ -126,8 +126,8 @@ export class Loader {
|
|
|
126
126
|
const includePatterns = moduleManifest.include;
|
|
127
127
|
if (includePatterns?.length) {
|
|
128
128
|
hasIncludes = true;
|
|
129
|
-
const
|
|
130
|
-
const includedFiles = await this.resolveIncludes(source, includePatterns,
|
|
129
|
+
const picked = this.pick(source);
|
|
130
|
+
const includedFiles = await this.resolveIncludes(source, includePatterns, picked);
|
|
131
131
|
for (const includedUrl of includedFiles) {
|
|
132
132
|
const partialManifests = await this.loadPartialFile(includedUrl, moduleName, options);
|
|
133
133
|
resolved.push(...partialManifests);
|
|
@@ -135,22 +135,22 @@ export class Loader {
|
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
if (!hasIncludes) {
|
|
138
|
-
|
|
138
|
+
this.moduleCache.set(cacheKey, { text, manifests: resolved });
|
|
139
139
|
}
|
|
140
140
|
return cloneManifestArray(resolved);
|
|
141
141
|
}
|
|
142
|
-
async resolveIncludes(ownerSource, patterns,
|
|
142
|
+
async resolveIncludes(ownerSource, patterns, source) {
|
|
143
143
|
const hasGlobs = patterns.some((p) => /[*?{}\[\]]/.test(p));
|
|
144
144
|
if (hasGlobs) {
|
|
145
|
-
if (!
|
|
146
|
-
throw new Error(`Include patterns in '${ownerSource}' contain globs but the
|
|
145
|
+
if (!source.expandGlob) {
|
|
146
|
+
throw new Error(`Include patterns in '${ownerSource}' contain globs but the source for this URL ` +
|
|
147
147
|
`does not support glob expansion. Use explicit file paths instead of patterns like: ` +
|
|
148
148
|
patterns.filter((p) => /[*?{}\[\]]/.test(p)).join(", "));
|
|
149
149
|
}
|
|
150
|
-
return
|
|
150
|
+
return source.expandGlob(ownerSource, patterns);
|
|
151
151
|
}
|
|
152
152
|
// Literal relative paths — deduplicate in case the same file appears under multiple patterns.
|
|
153
|
-
return [...new Set(patterns.map((p) =>
|
|
153
|
+
return [...new Set(patterns.map((p) => source.resolveRelative(ownerSource, p)))];
|
|
154
154
|
}
|
|
155
155
|
async loadPartialFile(url, ownerModuleName, options) {
|
|
156
156
|
const { text, source } = await this.pick(url).read(url);
|
|
@@ -228,10 +228,10 @@ export class Loader {
|
|
|
228
228
|
// Otherwise fall through to owner lookup — this is likely a partial file
|
|
229
229
|
}
|
|
230
230
|
// Find the owning telo.yaml via parent-directory traversal
|
|
231
|
-
const
|
|
232
|
-
if (!
|
|
231
|
+
const source = this.pick(fileUrl);
|
|
232
|
+
if (!source.resolveOwnerOf)
|
|
233
233
|
return null;
|
|
234
|
-
const ownerUrl = await
|
|
234
|
+
const ownerUrl = await source.resolveOwnerOf(fileUrl);
|
|
235
235
|
if (!ownerUrl)
|
|
236
236
|
return null;
|
|
237
237
|
// Load the owner module (which will load included files via include expansion)
|
|
@@ -78,6 +78,28 @@ function extractInlinesAtPath(resource, fieldPath, parentName, parentModule, inv
|
|
|
78
78
|
if (!obj || typeof obj !== "object" || partsLeft.length === 0)
|
|
79
79
|
return;
|
|
80
80
|
const [head, ...rest] = partsLeft;
|
|
81
|
+
// Map iteration: descend into every value of the current object (used for
|
|
82
|
+
// schema fields with `additionalProperties` like `content[mime]`).
|
|
83
|
+
if (head === "{}") {
|
|
84
|
+
const container = obj;
|
|
85
|
+
for (const mapKey of Object.keys(container)) {
|
|
86
|
+
const elem = container[mapKey];
|
|
87
|
+
if (!elem || typeof elem !== "object")
|
|
88
|
+
continue;
|
|
89
|
+
const sanitizedKey = sanitizeName(mapKey);
|
|
90
|
+
if (rest.length === 0) {
|
|
91
|
+
if (isInlineResource(elem)) {
|
|
92
|
+
const name = sanitizeName([parentName, ...nameParts, sanitizedKey].join("_"));
|
|
93
|
+
extracted.push(buildManifest(elem, name, parentModule, invocationContext));
|
|
94
|
+
container[mapKey] = { kind: elem.kind, name };
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
traverse(elem, rest, [...nameParts, sanitizedKey]);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
81
103
|
const isArr = head.endsWith("[]");
|
|
82
104
|
const key = isArr ? head.slice(0, -2) : head;
|
|
83
105
|
const container = obj;
|
|
@@ -33,11 +33,22 @@ export declare function isSchemaFromEntry(entry: FieldMapEntry): entry is Schema
|
|
|
33
33
|
/** Keys that a named reference object may have. Values beyond these indicate an inline resource. */
|
|
34
34
|
export declare const REFERENCE_KEYS: Set<string>;
|
|
35
35
|
/** True when `val` is an inline resource definition rather than a named reference.
|
|
36
|
-
*
|
|
37
|
-
*
|
|
36
|
+
* Three shapes flow through here:
|
|
37
|
+
* - `{kind, name}` (optionally with runtime call args) → named reference, NOT inline.
|
|
38
|
+
* - `{kind, ...config}` with no name → inline definition with config; extract.
|
|
39
|
+
* - `{kind}` alone (bare kind, no name) → inline singleton — extract a fresh
|
|
40
|
+
* stateless resource. Lets simple stateless kinds be used inline without
|
|
41
|
+
* boilerplate (e.g. `encoder: {kind: Ndjson.Encoder}`, `invoke: {kind: Run.Throw}`).
|
|
42
|
+
*
|
|
43
|
+
* A named reference (has string `name`) may carry extra keys (e.g. `inputs`)
|
|
44
|
+
* that are runtime call parameters — those are never inline resources. */
|
|
38
45
|
export declare function isInlineResource(val: Record<string, unknown>): boolean;
|
|
39
46
|
/** Resolves all values at a field map path in a resource config.
|
|
40
|
-
*
|
|
47
|
+
* Path-segment markers:
|
|
48
|
+
* - `[]` iterate array values at this key
|
|
49
|
+
* - `{}` iterate map values (every value in an `additionalProperties`-typed
|
|
50
|
+
* object — used for fields like `content[mime]` whose schema declares
|
|
51
|
+
* a key-as-MIME map). The path is `<key>.{}.<rest>`. */
|
|
41
52
|
export declare function resolveFieldValues(obj: unknown, path: string): unknown[];
|
|
42
53
|
/**
|
|
43
54
|
* Traverses a definition's JSON Schema once and returns a field map recording every
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reference-field-map.d.ts","sourceRoot":"","sources":["../src/reference-field-map.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,MAAM,WAAW,aAAa;IAC5B;sDACkD;IAClD,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,0FAA0F;IAC1F,OAAO,EAAE,OAAO,CAAC;IACjB;8DAC0D;IAC1D,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC/B;AAED,4EAA4E;AAC5E,MAAM,WAAW,eAAe;IAC9B;2CACuC;IACvC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC1B;AAED;8CAC8C;AAC9C,MAAM,WAAW,oBAAoB;IACnC;;qFAEiF;IACjF,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,aAAa,GAAG,aAAa,GAAG,eAAe,GAAG,oBAAoB,CAAC;AAEnF;0FAC0F;AAC1F,MAAM,MAAM,iBAAiB,GAAG,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;AAE3D,wBAAgB,UAAU,CAAC,KAAK,EAAE,aAAa,GAAG,KAAK,IAAI,aAAa,CAEvE;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,aAAa,GAAG,KAAK,IAAI,eAAe,CAE3E;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,aAAa,GAAG,KAAK,IAAI,oBAAoB,CAErF;AAED,oGAAoG;AACpG,eAAO,MAAM,cAAc,aAAwC,CAAC;AAEpE
|
|
1
|
+
{"version":3,"file":"reference-field-map.d.ts","sourceRoot":"","sources":["../src/reference-field-map.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,MAAM,WAAW,aAAa;IAC5B;sDACkD;IAClD,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,0FAA0F;IAC1F,OAAO,EAAE,OAAO,CAAC;IACjB;8DAC0D;IAC1D,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC/B;AAED,4EAA4E;AAC5E,MAAM,WAAW,eAAe;IAC9B;2CACuC;IACvC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC1B;AAED;8CAC8C;AAC9C,MAAM,WAAW,oBAAoB;IACnC;;qFAEiF;IACjF,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,aAAa,GAAG,aAAa,GAAG,eAAe,GAAG,oBAAoB,CAAC;AAEnF;0FAC0F;AAC1F,MAAM,MAAM,iBAAiB,GAAG,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;AAE3D,wBAAgB,UAAU,CAAC,KAAK,EAAE,aAAa,GAAG,KAAK,IAAI,aAAa,CAEvE;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,aAAa,GAAG,KAAK,IAAI,eAAe,CAE3E;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,aAAa,GAAG,KAAK,IAAI,oBAAoB,CAErF;AAED,oGAAoG;AACpG,eAAO,MAAM,cAAc,aAAwC,CAAC;AAEpE;;;;;;;;;2EAS2E;AAC3E,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAItE;AAED;;;;;kEAKkE;AAClE,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,EAAE,CA6BxE;AAED;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,iBAAiB,CAQrF"}
|
|
@@ -10,19 +10,46 @@ export function isSchemaFromEntry(entry) {
|
|
|
10
10
|
/** Keys that a named reference object may have. Values beyond these indicate an inline resource. */
|
|
11
11
|
export const REFERENCE_KEYS = new Set(["kind", "name", "metadata"]);
|
|
12
12
|
/** True when `val` is an inline resource definition rather than a named reference.
|
|
13
|
-
*
|
|
14
|
-
*
|
|
13
|
+
* Three shapes flow through here:
|
|
14
|
+
* - `{kind, name}` (optionally with runtime call args) → named reference, NOT inline.
|
|
15
|
+
* - `{kind, ...config}` with no name → inline definition with config; extract.
|
|
16
|
+
* - `{kind}` alone (bare kind, no name) → inline singleton — extract a fresh
|
|
17
|
+
* stateless resource. Lets simple stateless kinds be used inline without
|
|
18
|
+
* boilerplate (e.g. `encoder: {kind: Ndjson.Encoder}`, `invoke: {kind: Run.Throw}`).
|
|
19
|
+
*
|
|
20
|
+
* A named reference (has string `name`) may carry extra keys (e.g. `inputs`)
|
|
21
|
+
* that are runtime call parameters — those are never inline resources. */
|
|
15
22
|
export function isInlineResource(val) {
|
|
16
23
|
if (typeof val.name === "string")
|
|
17
24
|
return false;
|
|
18
|
-
|
|
25
|
+
if (typeof val.kind !== "string")
|
|
26
|
+
return false;
|
|
27
|
+
return true;
|
|
19
28
|
}
|
|
20
29
|
/** Resolves all values at a field map path in a resource config.
|
|
21
|
-
*
|
|
30
|
+
* Path-segment markers:
|
|
31
|
+
* - `[]` iterate array values at this key
|
|
32
|
+
* - `{}` iterate map values (every value in an `additionalProperties`-typed
|
|
33
|
+
* object — used for fields like `content[mime]` whose schema declares
|
|
34
|
+
* a key-as-MIME map). The path is `<key>.{}.<rest>`. */
|
|
22
35
|
export function resolveFieldValues(obj, path) {
|
|
23
36
|
const parts = path.split(".");
|
|
24
37
|
let current = [obj];
|
|
25
38
|
for (const part of parts) {
|
|
39
|
+
if (part === "{}") {
|
|
40
|
+
// Iterate the values of every map currently in `current`.
|
|
41
|
+
const next = [];
|
|
42
|
+
for (const item of current) {
|
|
43
|
+
if (!item || typeof item !== "object")
|
|
44
|
+
continue;
|
|
45
|
+
for (const v of Object.values(item)) {
|
|
46
|
+
if (v != null)
|
|
47
|
+
next.push(v);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
current = next;
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
26
53
|
const isArray = part.endsWith("[]");
|
|
27
54
|
const key = isArray ? part.slice(0, -2) : part;
|
|
28
55
|
const next = [];
|
|
@@ -104,4 +131,12 @@ function traverseNode(node, path, map) {
|
|
|
104
131
|
traverseNode(propSchema, `${path}.${key}`, map);
|
|
105
132
|
}
|
|
106
133
|
}
|
|
134
|
+
// Map — `additionalProperties: { ... }` describes every value in an
|
|
135
|
+
// open-keyed object. Encoder refs nested inside `content[mime]` map
|
|
136
|
+
// entries reach Phase 5 through this branch.
|
|
137
|
+
if (node.additionalProperties &&
|
|
138
|
+
typeof node.additionalProperties === "object" &&
|
|
139
|
+
!Array.isArray(node.additionalProperties)) {
|
|
140
|
+
traverseNode(node.additionalProperties, `${path}.{}`, map);
|
|
141
|
+
}
|
|
107
142
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
export declare class
|
|
1
|
+
import { type ManifestSource } from "../types.js";
|
|
2
|
+
export declare class HttpSource implements ManifestSource {
|
|
3
3
|
supports(url: string): boolean;
|
|
4
4
|
read(url: string): Promise<{
|
|
5
5
|
text: string;
|
|
@@ -7,4 +7,4 @@ export declare class HttpAdapter implements ManifestAdapter {
|
|
|
7
7
|
}>;
|
|
8
8
|
resolveRelative(base: string, relative: string): string;
|
|
9
9
|
}
|
|
10
|
-
//# sourceMappingURL=http-
|
|
10
|
+
//# sourceMappingURL=http-source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-source.d.ts","sourceRoot":"","sources":["../../src/sources/http-source.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7E,qBAAa,UAAW,YAAW,cAAc;IAC/C,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAIxB,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAWlE,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM;CAIxD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
export declare class
|
|
1
|
+
import { type ManifestSource } from "../types.js";
|
|
2
|
+
export declare class RegistrySource implements ManifestSource {
|
|
3
3
|
private registryUrl;
|
|
4
4
|
constructor(registryUrl?: string);
|
|
5
5
|
supports(url: string): boolean;
|
|
@@ -12,4 +12,4 @@ export declare class RegistryAdapter implements ManifestAdapter {
|
|
|
12
12
|
private toRegistryUrl;
|
|
13
13
|
private parseModuleRef;
|
|
14
14
|
}
|
|
15
|
-
//# sourceMappingURL=registry-
|
|
15
|
+
//# sourceMappingURL=registry-source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry-source.d.ts","sourceRoot":"","sources":["../../src/sources/registry-source.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAI7E,qBAAa,cAAe,YAAW,cAAc;IACvC,OAAO,CAAC,WAAW;gBAAX,WAAW,SAAuB;IAEtD,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAWxB,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAWxE,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM;IAMvD,OAAO,CAAC,oBAAoB;IAM5B,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,cAAc;CAmBvB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DEFAULT_MANIFEST_FILENAME } from "../types.js";
|
|
2
2
|
const DEFAULT_REGISTRY_URL = "https://registry.telo.run";
|
|
3
|
-
export class
|
|
3
|
+
export class RegistrySource {
|
|
4
4
|
registryUrl;
|
|
5
5
|
constructor(registryUrl = DEFAULT_REGISTRY_URL) {
|
|
6
6
|
this.registryUrl = registryUrl;
|
package/dist/types.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ export interface AnalysisDiagnostic {
|
|
|
35
35
|
/** Telo-specific extras such as { resource: { kind, name }, path } */
|
|
36
36
|
data?: unknown;
|
|
37
37
|
}
|
|
38
|
-
export interface
|
|
38
|
+
export interface ManifestSource {
|
|
39
39
|
supports(url: string): boolean;
|
|
40
40
|
read(url: string): Promise<{
|
|
41
41
|
text: string;
|
|
@@ -44,11 +44,11 @@ export interface ManifestAdapter {
|
|
|
44
44
|
resolveRelative(base: string, relative: string): string;
|
|
45
45
|
/** Expand glob patterns relative to a base source. Returns sources in the same
|
|
46
46
|
* format as read().source — suitable to pass back into read() / resolveRelative().
|
|
47
|
-
* Optional — only filesystem-capable
|
|
47
|
+
* Optional — only filesystem-capable sources implement this. */
|
|
48
48
|
expandGlob?(base: string, patterns: string[]): Promise<string[]>;
|
|
49
49
|
/** Walk parent directories from fileUrl looking for the nearest telo.yaml.
|
|
50
50
|
* Returns the source in the same format as read().source, or null if none found.
|
|
51
|
-
* Optional — only filesystem-capable
|
|
51
|
+
* Optional — only filesystem-capable sources implement this. */
|
|
52
52
|
resolveOwnerOf?(fileUrl: string): Promise<string | null>;
|
|
53
53
|
}
|
|
54
54
|
export interface LoadOptions {
|
|
@@ -59,13 +59,13 @@ export interface LoadOptions {
|
|
|
59
59
|
compile?: boolean;
|
|
60
60
|
}
|
|
61
61
|
export interface LoaderInitOptions {
|
|
62
|
-
/**
|
|
63
|
-
|
|
64
|
-
/** Include built-in
|
|
65
|
-
|
|
66
|
-
/** Include built-in
|
|
67
|
-
|
|
68
|
-
/** Base URL used by built-in
|
|
62
|
+
/** Sources inserted with highest priority before built-ins. */
|
|
63
|
+
extraSources?: ManifestSource[];
|
|
64
|
+
/** Include built-in HttpSource. Defaults to true. */
|
|
65
|
+
includeHttpSource?: boolean;
|
|
66
|
+
/** Include built-in RegistrySource. Defaults to true. */
|
|
67
|
+
includeRegistrySource?: boolean;
|
|
68
|
+
/** Base URL used by built-in RegistrySource when enabled. */
|
|
69
69
|
registryUrl?: string;
|
|
70
70
|
/** Handlers for CEL stdlib functions (e.g. `sha256`). Analyzer-only callers may
|
|
71
71
|
* omit this and get throwing stubs; runtime callers (kernel) must supply real impls. */
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;qHACqH;AACrH,eAAO,MAAM,kBAAkB;;;;;CAKrB,CAAC;AACX,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,OAAO,kBAAkB,CAAC,CAAC;AAE9F,gFAAgF;AAChF,eAAO,MAAM,yBAAyB,cAAc,CAAC;AAErD,MAAM,WAAW,QAAQ;IACvB,0BAA0B;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,+BAA+B;IAC/B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,KAAK;IACpB,KAAK,EAAE,QAAQ,CAAC;IAChB,GAAG,EAAE,QAAQ,CAAC;CACf;AAED;;oDAEoD;AACpD,MAAM,MAAM,aAAa,GAAG,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAE/C;6EAC6E;AAC7E,MAAM,WAAW,kBAAkB;IACjC,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAC9B,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,2BAA2B;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,sEAAsE;IACtE,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;qHACqH;AACrH,eAAO,MAAM,kBAAkB;;;;;CAKrB,CAAC;AACX,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,OAAO,kBAAkB,CAAC,CAAC;AAE9F,gFAAgF;AAChF,eAAO,MAAM,yBAAyB,cAAc,CAAC;AAErD,MAAM,WAAW,QAAQ;IACvB,0BAA0B;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,+BAA+B;IAC/B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,KAAK;IACpB,KAAK,EAAE,QAAQ,CAAC;IAChB,GAAG,EAAE,QAAQ,CAAC;CACf;AAED;;oDAEoD;AACpD,MAAM,MAAM,aAAa,GAAG,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAE/C;6EAC6E;AAC7E,MAAM,WAAW,kBAAkB;IACjC,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAC9B,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,2BAA2B;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,sEAAsE;IACtE,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAC/B,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC7D,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;IAExD;;qEAEiE;IACjE,UAAU,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAEjE;;qEAEiE;IACjE,cAAc,CAAC,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CAC1D;AAED,MAAM,WAAW,WAAW;IAC1B;;;+EAG2E;IAC3E,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,iBAAiB;IAChC,+DAA+D;IAC/D,YAAY,CAAC,EAAE,cAAc,EAAE,CAAC;IAChC,qDAAqD;IACrD,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,yDAAyD;IACzD,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,6DAA6D;IAC7D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;6FACyF;IACzF,WAAW,CAAC,EAAE,OAAO,sBAAsB,EAAE,WAAW,CAAC;CAC1D;AAED,MAAM,WAAW,eAAe;IAC9B,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED;;;;;gEAKgE;AAChE,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,EAAE,OAAO,qBAAqB,EAAE,aAAa,CAAC;IACtD,WAAW,CAAC,EAAE,OAAO,0BAA0B,EAAE,kBAAkB,CAAC;CACrE"}
|
|
@@ -16,7 +16,8 @@ export declare function extractAccessChains(node: ASTNode): string[][];
|
|
|
16
16
|
/**
|
|
17
17
|
* Check whether a member-access chain accesses only fields declared in a JSON Schema.
|
|
18
18
|
* Returns an error string if a field is unknown in a schema that declares explicit
|
|
19
|
-
* properties without `additionalProperties: true
|
|
19
|
+
* properties without `additionalProperties: true`, or if the chain attempts to
|
|
20
|
+
* reach inside an `x-telo-stream: true` property.
|
|
20
21
|
* Returns null when the chain is valid or the schema is too open to judge.
|
|
21
22
|
*/
|
|
22
23
|
export declare function validateChainAgainstSchema(chain: string[], schema: Record<string, any>): string | null;
|