@aid-framework/generator-ts-vercel 0.0.0 → 0.1.48
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/LICENSE +201 -0
- package/README.md +123 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/emit/agents.d.ts +62 -0
- package/dist/emit/agents.d.ts.map +1 -0
- package/dist/emit/agents.js +256 -0
- package/dist/emit/agents.js.map +1 -0
- package/dist/emit/business.d.ts +23 -0
- package/dist/emit/business.d.ts.map +1 -0
- package/dist/emit/business.js +414 -0
- package/dist/emit/business.js.map +1 -0
- package/dist/emit/control.d.ts +40 -0
- package/dist/emit/control.d.ts.map +1 -0
- package/dist/emit/control.js +108 -0
- package/dist/emit/control.js.map +1 -0
- package/dist/emit/file.d.ts +64 -0
- package/dist/emit/file.d.ts.map +1 -0
- package/dist/emit/file.js +80 -0
- package/dist/emit/file.js.map +1 -0
- package/dist/emit/guardrails.d.ts +45 -0
- package/dist/emit/guardrails.d.ts.map +1 -0
- package/dist/emit/guardrails.js +192 -0
- package/dist/emit/guardrails.js.map +1 -0
- package/dist/emit/infrastructure.d.ts +15 -0
- package/dist/emit/infrastructure.d.ts.map +1 -0
- package/dist/emit/infrastructure.js +238 -0
- package/dist/emit/infrastructure.js.map +1 -0
- package/dist/emit/pipelines.d.ts +46 -0
- package/dist/emit/pipelines.d.ts.map +1 -0
- package/dist/emit/pipelines.js +1015 -0
- package/dist/emit/pipelines.js.map +1 -0
- package/dist/emit/prompts.d.ts +14 -0
- package/dist/emit/prompts.d.ts.map +1 -0
- package/dist/emit/prompts.js +61 -0
- package/dist/emit/prompts.js.map +1 -0
- package/dist/emit/retrieval.d.ts +19 -0
- package/dist/emit/retrieval.d.ts.map +1 -0
- package/dist/emit/retrieval.js +206 -0
- package/dist/emit/retrieval.js.map +1 -0
- package/dist/emit/schemas.d.ts +22 -0
- package/dist/emit/schemas.d.ts.map +1 -0
- package/dist/emit/schemas.js +145 -0
- package/dist/emit/schemas.js.map +1 -0
- package/dist/emit/text.d.ts +86 -0
- package/dist/emit/text.d.ts.map +1 -0
- package/dist/emit/text.js +242 -0
- package/dist/emit/text.js.map +1 -0
- package/dist/emit/tools.d.ts +15 -0
- package/dist/emit/tools.d.ts.map +1 -0
- package/dist/emit/tools.js +225 -0
- package/dist/emit/tools.js.map +1 -0
- package/dist/errors.d.ts +12 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +16 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +47 -0
- package/dist/index.js.map +1 -0
- package/dist/manifest.d.ts +48 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +88 -0
- package/dist/manifest.js.map +1 -0
- package/dist/names.d.ts +57 -0
- package/dist/names.d.ts.map +1 -0
- package/dist/names.js +294 -0
- package/dist/names.js.map +1 -0
- package/dist/placeholders.d.ts +48 -0
- package/dist/placeholders.d.ts.map +1 -0
- package/dist/placeholders.js +114 -0
- package/dist/placeholders.js.map +1 -0
- package/dist/plan.d.ts +18 -0
- package/dist/plan.d.ts.map +1 -0
- package/dist/plan.js +81 -0
- package/dist/plan.js.map +1 -0
- package/dist/validate.d.ts +88 -0
- package/dist/validate.d.ts.map +1 -0
- package/dist/validate.js +790 -0
- package/dist/validate.js.map +1 -0
- package/package.json +43 -14
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `generated/gateway/models.ts`, `generated/gateway/index.ts`, `generated/deps.ts` and
|
|
3
|
+
* `generated/observability.ts`.
|
|
4
|
+
*
|
|
5
|
+
* The gateway is the seam every generated app is testable through: `deps.ts` resolves a
|
|
6
|
+
* singleton that a test (or the example's fake gateway) replaces wholesale, and the
|
|
7
|
+
* model table is plain data so a cost or capability change is a one-line diff.
|
|
8
|
+
*/
|
|
9
|
+
import { literal, modelCapabilities, propertyKey, providerAdapter, stringLiteral, } from '../names.js';
|
|
10
|
+
import { hasAgents } from './agents.js';
|
|
11
|
+
import { generated, paths } from './file.js';
|
|
12
|
+
import { importStatement, lines, localExportStatement, moduleText, objectLiteral, tsValue, } from './text.js';
|
|
13
|
+
const RUNTIME = '@aid-framework/runtime';
|
|
14
|
+
function costExpression(model) {
|
|
15
|
+
const profile = model.costProfile;
|
|
16
|
+
const input = profile === undefined ? 0 : profile.inputPerMTok / 1000;
|
|
17
|
+
const output = profile === undefined ? 0 : profile.outputPerMTok / 1000;
|
|
18
|
+
return `new CostProfile({ inputPer1kUsd: ${literal(input)}, outputPer1kUsd: ${literal(output)} })`;
|
|
19
|
+
}
|
|
20
|
+
function modelExpression(model) {
|
|
21
|
+
const { advertised } = modelCapabilities(model.capabilities);
|
|
22
|
+
const capabilities = advertised.length === 0
|
|
23
|
+
? '[]'
|
|
24
|
+
: `[${advertised.map((capability) => stringLiteral(capability)).join(', ')}] as const`;
|
|
25
|
+
const fields = [
|
|
26
|
+
['name', stringLiteral(model.modelId)],
|
|
27
|
+
['provider', stringLiteral(model.provider)],
|
|
28
|
+
['cost', costExpression(model)],
|
|
29
|
+
['contextWindow', literal(model.limits.contextTokens)],
|
|
30
|
+
['maxOutputTokens', literal(model.limits.maxOutputTokens ?? model.params.maxTokens ?? 1024)],
|
|
31
|
+
['capabilities', capabilities],
|
|
32
|
+
];
|
|
33
|
+
return `new ModelSpec(${objectLiteral(fields, ' ')})`;
|
|
34
|
+
}
|
|
35
|
+
export function emitGatewayModels(ir) {
|
|
36
|
+
const aliases = ir.models
|
|
37
|
+
.map((model) => ` ${propertyKey(model.id)}: ${modelExpression(model)},`)
|
|
38
|
+
.join('\n');
|
|
39
|
+
const fallbacks = ir.models
|
|
40
|
+
.filter((model) => model.fallbacks.length > 0)
|
|
41
|
+
.map((model) => ` ${propertyKey(model.id)}: [${model.fallbacks.map(stringLiteral).join(', ')}],`)
|
|
42
|
+
.join('\n');
|
|
43
|
+
const providers = ir.models
|
|
44
|
+
.filter((model) => providerAdapter(model.provider) !== undefined)
|
|
45
|
+
.map((model) => {
|
|
46
|
+
const adapter = providerAdapter(model.provider);
|
|
47
|
+
if (adapter === 'FakeProvider')
|
|
48
|
+
return ` fake: new FakeProvider(),`;
|
|
49
|
+
const apiKey = model.apiKeyEnv;
|
|
50
|
+
if (apiKey === undefined) {
|
|
51
|
+
return ` ${propertyKey(model.provider)}: new OpenAICompatibleProvider({ name: ${stringLiteral(model.provider)} }),`;
|
|
52
|
+
}
|
|
53
|
+
return ` ${propertyKey(model.provider)}: keyedProvider(${stringLiteral(model.provider)}, ${stringLiteral(apiKey)}),`;
|
|
54
|
+
});
|
|
55
|
+
const header = importStatement(RUNTIME, [
|
|
56
|
+
{ name: 'CostProfile', type: false },
|
|
57
|
+
{ name: 'FakeProvider', type: false },
|
|
58
|
+
{ name: 'ModelSpec', type: false },
|
|
59
|
+
{ name: 'OpenAICompatibleProvider', type: false },
|
|
60
|
+
{ name: 'Provider', type: true },
|
|
61
|
+
]);
|
|
62
|
+
const needsKeyed = providers.some((line) => line.includes('keyedProvider('));
|
|
63
|
+
const body = [
|
|
64
|
+
...(needsKeyed
|
|
65
|
+
? [
|
|
66
|
+
'/**',
|
|
67
|
+
' * An adapter whose credential comes from the environment variable the spec named.',
|
|
68
|
+
' * The option is omitted rather than set to `undefined` when the variable is unset,',
|
|
69
|
+
' * so the provider fails at call time with its own message instead of at import time.',
|
|
70
|
+
' */',
|
|
71
|
+
'function keyedProvider(name: string, apiKeyEnv: string): OpenAICompatibleProvider {',
|
|
72
|
+
' const apiKey = process.env[apiKeyEnv];',
|
|
73
|
+
' return new OpenAICompatibleProvider(apiKey === undefined ? { name } : { name, apiKey });',
|
|
74
|
+
'}',
|
|
75
|
+
'',
|
|
76
|
+
]
|
|
77
|
+
: []),
|
|
78
|
+
'/** Every model alias the IR declares, resolved to a runtime model specification. */',
|
|
79
|
+
'export const ALIASES: Readonly<Record<string, ModelSpec>> = {',
|
|
80
|
+
aliases,
|
|
81
|
+
'};',
|
|
82
|
+
'',
|
|
83
|
+
'export const FALLBACKS: Readonly<Record<string, readonly string[]>> = {',
|
|
84
|
+
fallbacks.length === 0 ? '};' : `${fallbacks}\n};`,
|
|
85
|
+
'',
|
|
86
|
+
'/**',
|
|
87
|
+
' * The provider adapters a generated app talks to by default. Each one reads its',
|
|
88
|
+
' * credential from the environment variable the spec named, never from a literal.',
|
|
89
|
+
' */',
|
|
90
|
+
'export function defaultProviders(): Readonly<Record<string, Provider>> {',
|
|
91
|
+
' return {',
|
|
92
|
+
...dedupe(providers),
|
|
93
|
+
' };',
|
|
94
|
+
'}',
|
|
95
|
+
]
|
|
96
|
+
.filter((line) => line.length > 0)
|
|
97
|
+
.join('\n');
|
|
98
|
+
return generated(paths.gatewayModels, moduleText(header, body));
|
|
99
|
+
}
|
|
100
|
+
function dedupe(lines) {
|
|
101
|
+
const seen = new Set();
|
|
102
|
+
const result = [];
|
|
103
|
+
for (const line of lines) {
|
|
104
|
+
if (seen.has(line))
|
|
105
|
+
continue;
|
|
106
|
+
seen.add(line);
|
|
107
|
+
result.push(line);
|
|
108
|
+
}
|
|
109
|
+
return result;
|
|
110
|
+
}
|
|
111
|
+
export function emitGatewayIndex(ir) {
|
|
112
|
+
void ir;
|
|
113
|
+
const header = [
|
|
114
|
+
importStatement(RUNTIME, [
|
|
115
|
+
{ name: 'ModelGateway', type: false },
|
|
116
|
+
{ name: 'Provider', type: true },
|
|
117
|
+
]),
|
|
118
|
+
importStatement('./models.js', [
|
|
119
|
+
{ name: 'ALIASES', type: false },
|
|
120
|
+
{ name: 'FALLBACKS', type: false },
|
|
121
|
+
{ name: 'defaultProviders', type: false },
|
|
122
|
+
]),
|
|
123
|
+
].join('\n');
|
|
124
|
+
const body = [
|
|
125
|
+
localExportStatement(['ALIASES', 'FALLBACKS', 'defaultProviders']),
|
|
126
|
+
'',
|
|
127
|
+
'export interface BuildGatewayOptions {',
|
|
128
|
+
' readonly providers?: Readonly<Record<string, Provider>>;',
|
|
129
|
+
'}',
|
|
130
|
+
'',
|
|
131
|
+
'/** Build the gateway every generated call goes through. */',
|
|
132
|
+
'export function buildGateway(options: BuildGatewayOptions = {}): ModelGateway {',
|
|
133
|
+
' return new ModelGateway({',
|
|
134
|
+
' providers: options.providers ?? defaultProviders(),',
|
|
135
|
+
' aliases: ALIASES,',
|
|
136
|
+
' });',
|
|
137
|
+
'}',
|
|
138
|
+
].join('\n');
|
|
139
|
+
return generated(paths.gatewayIndex, moduleText(header, body));
|
|
140
|
+
}
|
|
141
|
+
export function emitDeps(ir) {
|
|
142
|
+
const hasRetrieval = ir.retrievers.length > 0;
|
|
143
|
+
const withAgents = hasAgents(ir);
|
|
144
|
+
const runtimeImports = [
|
|
145
|
+
{ name: 'ConfigurationError', type: false },
|
|
146
|
+
{ name: 'ModelGateway', type: true },
|
|
147
|
+
{ name: 'PromptRegistry', type: true },
|
|
148
|
+
{ name: 'Retriever', type: true },
|
|
149
|
+
// The agent loop takes `Tool` objects, not the executor, so when this app declares an
|
|
150
|
+
// agent the executor is built *from* the list rather than beside it: one adapter set
|
|
151
|
+
// with two views, so an agent and a `tool` step cannot execute different objects.
|
|
152
|
+
{ name: 'ToolExecutor', type: !withAgents },
|
|
153
|
+
];
|
|
154
|
+
if (withAgents)
|
|
155
|
+
runtimeImports.push({ name: 'Tool', type: true });
|
|
156
|
+
const header = [
|
|
157
|
+
importStatement(RUNTIME, runtimeImports),
|
|
158
|
+
importStatement('./gateway/index.js', [{ name: 'buildGateway', type: false }]),
|
|
159
|
+
importStatement('./prompts/index.js', [{ name: 'buildPrompts', type: false }]),
|
|
160
|
+
];
|
|
161
|
+
if (hasRetrieval) {
|
|
162
|
+
header.push(importStatement('./retrieval/index.js', [{ name: 'buildRetrievers', type: false }]));
|
|
163
|
+
}
|
|
164
|
+
header.push(importStatement('./tools/index.js', [
|
|
165
|
+
withAgents ? { name: 'buildTools', type: false } : { name: 'buildExecutor', type: false },
|
|
166
|
+
]));
|
|
167
|
+
const body = lines('export interface BuildDepsOptions {', ' readonly gateway?: ModelGateway;', ' readonly prompts?: PromptRegistry;', ' readonly tools?: ToolExecutor;', withAgents && ' /** The same adapters `tools` wraps; the agent loop needs them by value. */', withAgents && ' readonly toolList?: readonly Tool[];', hasRetrieval && ' readonly retrievers?: ReadonlyMap<string, Retriever>;', '}', '', '/**', ' * The wiring a generated pipeline needs. Everything a test wants to replace is a', ' * constructor argument, so no module-level singleton has to be monkey-patched.', ' */', 'export class Deps {', ' readonly gateway: ModelGateway;', ' readonly prompts: PromptRegistry;', ' readonly tools: ToolExecutor;', withAgents && ' readonly toolList: readonly Tool[];', hasRetrieval && ' private readonly _retrievers: ReadonlyMap<string, Retriever>;', '', ' constructor(init: Required<BuildDepsOptions>) {', ' this.gateway = init.gateway;', ' this.prompts = init.prompts;', ' this.tools = init.tools;', withAgents && ' this.toolList = init.toolList;', hasRetrieval && ' this._retrievers = init.retrievers;', ' }', hasRetrieval && [
|
|
168
|
+
'',
|
|
169
|
+
' /** One bound retriever, or a configuration error naming the missing id. */',
|
|
170
|
+
' retriever(id: string): Retriever {',
|
|
171
|
+
' const found = this._retrievers.get(id);',
|
|
172
|
+
' if (found === undefined) {',
|
|
173
|
+
// biome-ignore lint/suspicious/noTemplateCurlyInString: this is emitted source, not interpolation
|
|
174
|
+
' throw new ConfigurationError(`no retriever ${JSON.stringify(id)} is bound`);',
|
|
175
|
+
' }',
|
|
176
|
+
' return found;',
|
|
177
|
+
' }',
|
|
178
|
+
], '}', '', 'let singleton: Deps | undefined;', '', '/** Build a fresh `Deps`; every seam defaults to the generated wiring. */', 'export function buildDeps(options: BuildDepsOptions = {}): Deps {', withAgents && ' const toolList = options.toolList ?? buildTools();', ' return new Deps({', ' gateway: options.gateway ?? buildGateway(),', ' prompts: options.prompts ?? buildPrompts(),', withAgents
|
|
179
|
+
? ' tools: options.tools ?? new ToolExecutor(toolList),'
|
|
180
|
+
: ' tools: options.tools ?? buildExecutor(),', withAgents && ' toolList,', hasRetrieval && ' retrievers: options.retrievers ?? buildRetrievers(),', ' });', '}', '', '/** The process-wide wiring, built once. */', 'export function getDeps(): Deps {', ' singleton ??= buildDeps();', ' return singleton;', '}', '', '/**', ' * Replace the process-wide wiring, or clear it with `undefined` so the next', ' * `getDeps()` rebuilds from the environment. This is the seam a host or a test uses', ' * to run a generated pipeline against a fake provider; nothing in production calls it.', ' */', 'export function setDeps(deps: Deps | undefined): void {', ' singleton = deps;', '}')
|
|
181
|
+
.join('\n')
|
|
182
|
+
.replace(/\n{3,}/g, '\n\n');
|
|
183
|
+
return generated(paths.deps, moduleText(header.join('\n'), body));
|
|
184
|
+
}
|
|
185
|
+
export function emitObservability(ir) {
|
|
186
|
+
const declared = ir.models
|
|
187
|
+
.map((model) => model)
|
|
188
|
+
.flatMap((model) => model.capabilities)
|
|
189
|
+
.filter((capability, index, all) => all.indexOf(capability) === index);
|
|
190
|
+
const modelWired = {};
|
|
191
|
+
const unrepresentable = {};
|
|
192
|
+
for (const model of ir.models) {
|
|
193
|
+
const { advertised, dropped } = modelCapabilities(model.capabilities);
|
|
194
|
+
modelWired[model.id] = [...advertised];
|
|
195
|
+
if (dropped.length > 0)
|
|
196
|
+
unrepresentable[model.id] = dropped;
|
|
197
|
+
}
|
|
198
|
+
const payload = {
|
|
199
|
+
capabilities: {
|
|
200
|
+
declared: [...declared].sort(),
|
|
201
|
+
modelWired,
|
|
202
|
+
targetWired: [...TARGET_WIRED],
|
|
203
|
+
unwired: [...declared].filter((capability) => !wireable(capability)),
|
|
204
|
+
},
|
|
205
|
+
emitsAgainst: { structuredOutput: 'zod', tracing: 'otel-genai' },
|
|
206
|
+
generator: '@aid-framework/generator-ts-vercel',
|
|
207
|
+
irVersion: ir.irVersion,
|
|
208
|
+
models: { advertised: modelWired, unrepresentable },
|
|
209
|
+
observability: { redact: [...ir.observability.redact], trace: ir.observability.trace },
|
|
210
|
+
target: 'ts-vercel',
|
|
211
|
+
};
|
|
212
|
+
const body = [
|
|
213
|
+
'/**',
|
|
214
|
+
' * What this app was generated from and which capabilities it actually wires. A',
|
|
215
|
+
' * capability listed under `unwired` is one no emitter binds: it is reported rather',
|
|
216
|
+
' * than silently dropped.',
|
|
217
|
+
' */',
|
|
218
|
+
'export function generatedCapabilities(): Record<string, unknown> {',
|
|
219
|
+
` return ${tsValue(payload, ' ')};`,
|
|
220
|
+
'}',
|
|
221
|
+
].join('\n');
|
|
222
|
+
return generated(paths.observability, moduleText(body));
|
|
223
|
+
}
|
|
224
|
+
const TARGET_WIRED = [
|
|
225
|
+
'http-trigger',
|
|
226
|
+
'json-schema',
|
|
227
|
+
'tool-calling',
|
|
228
|
+
'otel',
|
|
229
|
+
'embeddings',
|
|
230
|
+
'rerank',
|
|
231
|
+
'guardrails',
|
|
232
|
+
'agents',
|
|
233
|
+
'cursor-memory',
|
|
234
|
+
];
|
|
235
|
+
function wireable(capability) {
|
|
236
|
+
return TARGET_WIRED.includes(capability);
|
|
237
|
+
}
|
|
238
|
+
//# sourceMappingURL=infrastructure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"infrastructure.js","sourceRoot":"","sources":["../../src/emit/infrastructure.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EACL,OAAO,EACP,iBAAiB,EACjB,WAAW,EACX,eAAe,EACf,aAAa,GACd,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAoB,SAAS,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAGL,eAAe,EACf,KAAK,EACL,oBAAoB,EACpB,UAAU,EACV,aAAa,EACb,OAAO,GACR,MAAM,WAAW,CAAC;AAEnB,MAAM,OAAO,GAAG,wBAAwB,CAAC;AAEzC,SAAS,cAAc,CAAC,KAAiB;IACvC,MAAM,OAAO,GAAG,KAAK,CAAC,WAAW,CAAC;IAClC,MAAM,KAAK,GAAG,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CA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ipeline is plain sequential async code, because that is what Phase 1 emits: no
|
|
5
|
+
* graph engine, no scheduler. Each step is a named `Step` that returns a new
|
|
6
|
+
* `PipelineContext`, so the step names survive into tracing and the values each step
|
|
7
|
+
* binds are readable in a diff.
|
|
8
|
+
*
|
|
9
|
+
* A route is deliberately *not* a Next.js module. It is a small
|
|
10
|
+
* `(request) => { status, body }` function, and the example's hand-written
|
|
11
|
+
* `app/api/<path>/route.ts` is the adapter that turns it into what Next serves. That
|
|
12
|
+
* split is forced by the ownership model: a path under `app/api` has no owner, so
|
|
13
|
+
* emitting it would break `validatePlan` and the next `aid gen`. See the README.
|
|
14
|
+
*/
|
|
15
|
+
import type { IR, PipelineShape, TypeField } from '@aid-framework/ir';
|
|
16
|
+
import { type EmittedFile } from './file.js';
|
|
17
|
+
/**
|
|
18
|
+
* Turn an IR interpolation template into a TypeScript template literal.
|
|
19
|
+
*
|
|
20
|
+
* `{{ event.subject }}` becomes `${event.subject}`. The two forms use different
|
|
21
|
+
* delimiters on purpose: the IR's spelling is language-neutral, and rewriting it at
|
|
22
|
+
* emit time is the whole job of the target.
|
|
23
|
+
*
|
|
24
|
+
* `resolve` decides what a reference becomes. A prompt's template names its *variables*,
|
|
25
|
+
* which `generateStepModule` binds as object-literal keys, so the default is a bare
|
|
26
|
+
* identifier. A guard step's, a rerank step's and an agent step's template name pipeline
|
|
27
|
+
* *bindings* instead, and those are read back through `context.require` -- see
|
|
28
|
+
* `contextTemplate`.
|
|
29
|
+
*/
|
|
30
|
+
export declare function templateToTs(template: string, resolve?: (path: readonly string[]) => string): string;
|
|
31
|
+
/**
|
|
32
|
+
* The same rendering for a template that names pipeline bindings.
|
|
33
|
+
*
|
|
34
|
+
* `{{ handbook }}` becomes `${context.require('handbook')}`, matching what
|
|
35
|
+
* `valueExpression` does for a `reference` StepInputValue. `event` stays a bare local
|
|
36
|
+
* because it is the one binding every emitted step receives as an argument.
|
|
37
|
+
*/
|
|
38
|
+
export declare function contextTemplate(template: string, types?: ReadonlyMap<string, string>): string;
|
|
39
|
+
/** The first binding a template names, which is how a `retrieval` guard finds its input. */
|
|
40
|
+
export declare function firstReference(template: string): string | undefined;
|
|
41
|
+
export declare function emitPipelineModule(ir: IR, pipeline: PipelineShape): EmittedFile;
|
|
42
|
+
export declare function emitPipelinesIndex(ir: IR): EmittedFile;
|
|
43
|
+
export declare function emitRouteModule(ir: IR, pipeline: PipelineShape): EmittedFile;
|
|
44
|
+
export declare function emitRoutesIndex(ir: IR): EmittedFile;
|
|
45
|
+
export type { TypeField };
|
|
46
|
+
//# sourceMappingURL=pipelines.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipelines.d.ts","sourceRoot":"","sources":["../../src/emit/pipelines.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAKV,EAAE,EAGF,aAAa,EAOb,SAAS,EACV,MAAM,mBAAmB,CAAC;AAI3B,OAAO,EAAE,KAAK,WAAW,EAA6C,MAAM,WAAW,CAAC;AAiDxF;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,KAAK,MAAkD,GACvF,MAAM,CAwBR;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAM7F;AAED,4FAA4F;AAC5F,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAUnE;AAqxBD,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,aAAa,GAAG,WAAW,CA2F/E;AA4CD,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,EAAE,GAAG,WAAW,CAOtD;AAkDD,wBAAgB,eAAe,CAAC,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,aAAa,GAAG,WAAW,CA8F5E;AAED,wBAAgB,eAAe,CAAC,EAAE,EAAE,EAAE,GAAG,WAAW,CAQnD;AAED,YAAY,EAAE,SAAS,EAAE,CAAC"}
|