typekro 0.20.3 → 0.21.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/.tsbuildinfo +1 -1
- package/dist/core/expressions/analysis/alias-inliner.d.ts +14 -0
- package/dist/core/expressions/analysis/alias-inliner.d.ts.map +1 -0
- package/dist/core/expressions/analysis/alias-inliner.js +307 -0
- package/dist/core/expressions/analysis/alias-inliner.js.map +1 -0
- package/dist/core/expressions/analysis/cel-emitter.d.ts +2 -1
- package/dist/core/expressions/analysis/cel-emitter.d.ts.map +1 -1
- package/dist/core/expressions/analysis/cel-emitter.js +37 -3
- package/dist/core/expressions/analysis/cel-emitter.js.map +1 -1
- package/dist/core/expressions/composition/imperative-analyzer.d.ts +0 -8
- package/dist/core/expressions/composition/imperative-analyzer.d.ts.map +1 -1
- package/dist/core/expressions/composition/imperative-analyzer.js +25 -102
- package/dist/core/expressions/composition/imperative-analyzer.js.map +1 -1
- package/dist/core/expressions/factory/status-builder-analyzer.d.ts.map +1 -1
- package/dist/core/expressions/factory/status-builder-analyzer.js +3 -1
- package/dist/core/expressions/factory/status-builder-analyzer.js.map +1 -1
- package/dist/core/expressions/factory/status-field-analysis.d.ts +2 -1
- package/dist/core/expressions/factory/status-field-analysis.d.ts.map +1 -1
- package/dist/core/expressions/factory/status-field-analysis.js +3 -2
- package/dist/core/expressions/factory/status-field-analysis.js.map +1 -1
- package/dist/core/references/computed.d.ts +56 -0
- package/dist/core/references/computed.d.ts.map +1 -0
- package/dist/core/references/computed.js +191 -0
- package/dist/core/references/computed.js.map +1 -0
- package/dist/core/references/index.d.ts +2 -1
- package/dist/core/references/index.d.ts.map +1 -1
- package/dist/core/references/index.js +2 -1
- package/dist/core/references/index.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import * as acorn from 'acorn';
|
|
2
|
+
import { CEL_EXPRESSION_BRAND } from '../constants/brands.js';
|
|
3
|
+
import { ensureError, TypeKroError } from '../errors.js';
|
|
4
|
+
import { JavaScriptToCelAnalyzer } from '../expressions/analysis/analyzer.js';
|
|
5
|
+
import { getNodeSource } from '../expressions/factory/status-ast-utils.js';
|
|
6
|
+
/**
|
|
7
|
+
* Define reusable status aliases for a single TypeKro resource.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* const web = alias(deployment, {
|
|
12
|
+
* ready: (d) => d.status.readyReplicas >= d.spec.replicas,
|
|
13
|
+
* available: (d) => d.status.availableReplicas,
|
|
14
|
+
* });
|
|
15
|
+
* return { ready: web.ready };
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export function alias(resource, aliasDefinitions) {
|
|
19
|
+
return Object.fromEntries(Object.entries(aliasDefinitions).map(([name, expression]) => [
|
|
20
|
+
name,
|
|
21
|
+
computedFromSource({ resource }, expression.toString(), 'resources.resource'),
|
|
22
|
+
]));
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Define reusable status aliases over multiple TypeKro resources.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* const app = aliases({ deployment, service }, {
|
|
30
|
+
* ready: ({ deployment, service }) =>
|
|
31
|
+
* deployment.status.readyReplicas >= deployment.spec.replicas &&
|
|
32
|
+
* service.status.loadBalancer.ingress.length > 0,
|
|
33
|
+
* });
|
|
34
|
+
* return { ready: app.ready };
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export function aliases(resources, aliasDefinitions) {
|
|
38
|
+
return Object.fromEntries(Object.entries(aliasDefinitions).map(([name, expression]) => [
|
|
39
|
+
name,
|
|
40
|
+
computed(resources, expression),
|
|
41
|
+
]));
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Define a reusable TypeKro status value from a native JavaScript expression.
|
|
45
|
+
*
|
|
46
|
+
* `computed(...)` is intended for framework and library authors that want to
|
|
47
|
+
* expose ergonomic aliases such as `web.ready`, while still letting TypeKro
|
|
48
|
+
* analyze the underlying JavaScript expression and serialize it to CEL.
|
|
49
|
+
*
|
|
50
|
+
* The callback is parsed, not executed. Use the provided resource map inside the
|
|
51
|
+
* callback, either via destructuring or a named parameter.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```ts
|
|
55
|
+
* const ready = computed({ web }, ({ web }) =>
|
|
56
|
+
* web.status.availableReplicas >= web.spec.replicas
|
|
57
|
+
* );
|
|
58
|
+
* return { ready };
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export function computed(resources, expression) {
|
|
62
|
+
return computedFromSource(resources, expression.toString(), 'resources');
|
|
63
|
+
}
|
|
64
|
+
function computedFromSource(resources, source, parameterPath) {
|
|
65
|
+
const { expressionSource, resourceParameterBindings } = extractComputedExpressionSource(source, parameterPath);
|
|
66
|
+
const normalizedExpression = normalizeComputedResourceParameter(expressionSource, resourceParameterBindings);
|
|
67
|
+
const analyzer = new JavaScriptToCelAnalyzer();
|
|
68
|
+
const result = analyzer.analyzeExpression(normalizedExpression, {
|
|
69
|
+
type: 'status',
|
|
70
|
+
availableReferences: resources,
|
|
71
|
+
factoryType: 'kro',
|
|
72
|
+
dependencies: [],
|
|
73
|
+
});
|
|
74
|
+
if (!result.valid || !result.celExpression) {
|
|
75
|
+
throw new TypeKroError(`computed() could not convert the supplied JavaScript expression to CEL: ${result.errors.map((error) => error.message).join('; ') || 'unknown conversion error'}`, 'COMPUTED_EXPRESSION_INVALID', { expression: normalizedExpression });
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
[CEL_EXPRESSION_BRAND]: true,
|
|
79
|
+
expression: normalizeCelResourceAliases(result.celExpression.expression, resources),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
function extractComputedExpressionSource(source, parameterPath) {
|
|
83
|
+
const wrappedSource = `(${source})`;
|
|
84
|
+
let ast;
|
|
85
|
+
try {
|
|
86
|
+
ast = acorn.parse(wrappedSource, {
|
|
87
|
+
ecmaVersion: 2022,
|
|
88
|
+
sourceType: 'script',
|
|
89
|
+
ranges: true,
|
|
90
|
+
locations: true,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
throw new TypeKroError(`computed() could not parse the supplied function: ${ensureError(error).message}`, 'COMPUTED_EXPRESSION_PARSE_FAILED', { source });
|
|
95
|
+
}
|
|
96
|
+
const functionNode = firstComputedFunctionNode(ast);
|
|
97
|
+
if (!functionNode) {
|
|
98
|
+
throw new TypeKroError('computed() requires an arrow function or function expression.', 'COMPUTED_EXPRESSION_INVALID_FUNCTION', { source });
|
|
99
|
+
}
|
|
100
|
+
const bodyExpression = computedFunctionBodyExpression(functionNode);
|
|
101
|
+
if (!bodyExpression) {
|
|
102
|
+
throw new TypeKroError('computed() requires an expression body or a block body with a direct top-level return expression.', 'COMPUTED_EXPRESSION_MISSING_RETURN', { source });
|
|
103
|
+
}
|
|
104
|
+
const resourceParameterBindings = computedResourceParameterBindings(functionNode, parameterPath);
|
|
105
|
+
return resourceParameterBindings
|
|
106
|
+
? {
|
|
107
|
+
expressionSource: getNodeSource(bodyExpression, wrappedSource),
|
|
108
|
+
resourceParameterBindings,
|
|
109
|
+
}
|
|
110
|
+
: { expressionSource: getNodeSource(bodyExpression, wrappedSource) };
|
|
111
|
+
}
|
|
112
|
+
function firstComputedFunctionNode(ast) {
|
|
113
|
+
const expression = ast.body[0]?.type === 'ExpressionStatement' ? ast.body[0].expression : undefined;
|
|
114
|
+
if (expression?.type === 'ArrowFunctionExpression' || expression?.type === 'FunctionExpression') {
|
|
115
|
+
return expression;
|
|
116
|
+
}
|
|
117
|
+
return undefined;
|
|
118
|
+
}
|
|
119
|
+
function computedFunctionBodyExpression(functionNode) {
|
|
120
|
+
if (functionNode.type === 'ArrowFunctionExpression' &&
|
|
121
|
+
functionNode.body.type !== 'BlockStatement') {
|
|
122
|
+
return functionNode.body;
|
|
123
|
+
}
|
|
124
|
+
if (functionNode.body.type !== 'BlockStatement') {
|
|
125
|
+
return undefined;
|
|
126
|
+
}
|
|
127
|
+
return topLevelReturnExpression(functionNode.body);
|
|
128
|
+
}
|
|
129
|
+
function topLevelReturnExpression(body) {
|
|
130
|
+
const statement = body.body.find((node) => node.type === 'ReturnStatement');
|
|
131
|
+
return statement?.type === 'ReturnStatement' ? (statement.argument ?? undefined) : undefined;
|
|
132
|
+
}
|
|
133
|
+
function computedResourceParameterBindings(functionNode, parameterPath) {
|
|
134
|
+
const [parameter] = functionNode.params;
|
|
135
|
+
if (!parameter) {
|
|
136
|
+
return undefined;
|
|
137
|
+
}
|
|
138
|
+
if (parameter.type === 'Identifier') {
|
|
139
|
+
return { [parameter.name]: parameterPath };
|
|
140
|
+
}
|
|
141
|
+
if (parameter.type !== 'ObjectPattern') {
|
|
142
|
+
return undefined;
|
|
143
|
+
}
|
|
144
|
+
const bindings = {};
|
|
145
|
+
for (const property of parameter.properties) {
|
|
146
|
+
if (property.type !== 'Property' || property.key.type !== 'Identifier') {
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
const resourceName = property.key.name;
|
|
150
|
+
if (property.value.type === 'Identifier') {
|
|
151
|
+
bindings[property.value.name] = `${parameterPath}.${resourceName}`;
|
|
152
|
+
}
|
|
153
|
+
else if (property.value.type === 'AssignmentPattern' &&
|
|
154
|
+
property.value.left.type === 'Identifier') {
|
|
155
|
+
bindings[property.value.left.name] = `${parameterPath}.${resourceName}`;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return Object.keys(bindings).length > 0 ? bindings : undefined;
|
|
159
|
+
}
|
|
160
|
+
function normalizeComputedResourceParameter(expressionSource, resourceParameterBindings) {
|
|
161
|
+
if (!resourceParameterBindings) {
|
|
162
|
+
return expressionSource;
|
|
163
|
+
}
|
|
164
|
+
let normalizedExpression = expressionSource;
|
|
165
|
+
for (const [localName, replacementPath] of Object.entries(resourceParameterBindings)) {
|
|
166
|
+
if (localName === replacementPath) {
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
normalizedExpression = normalizedExpression.replace(new RegExp(`\\b${escapeRegExp(localName)}\\.`, 'g'), `${replacementPath}.`);
|
|
170
|
+
}
|
|
171
|
+
return normalizedExpression;
|
|
172
|
+
}
|
|
173
|
+
function escapeRegExp(value) {
|
|
174
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
175
|
+
}
|
|
176
|
+
function normalizeCelResourceAliases(expression, resources) {
|
|
177
|
+
let normalizedExpression = expression.replace(/\bresources\./g, '');
|
|
178
|
+
for (const [localName, resource] of Object.entries(resources)) {
|
|
179
|
+
const resourceId = resourceIdOf(resource);
|
|
180
|
+
if (!resourceId || resourceId === localName) {
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
normalizedExpression = normalizedExpression.replace(new RegExp(`\\b${escapeRegExp(localName)}\\.`, 'g'), `${resourceId}.`);
|
|
184
|
+
}
|
|
185
|
+
return normalizedExpression;
|
|
186
|
+
}
|
|
187
|
+
function resourceIdOf(resource) {
|
|
188
|
+
const candidate = resource.id;
|
|
189
|
+
return typeof candidate === 'string' ? candidate : undefined;
|
|
190
|
+
}
|
|
191
|
+
//# sourceMappingURL=computed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"computed.js","sourceRoot":"","sources":["../../../src/core/references/computed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAQ/B,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,4CAA4C,CAAC;AAY3E;;;;;;;;;;;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C,SAAS,CAAC,EAAE,CAAC;QAC9D,MAAM,UAAU,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC;QAC1C,IAAI,CAAC,UAAU,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC5C,SAAS;QACX,CAAC;QACD,oBAAoB,GAAG,oBAAoB,CAAC,OAAO,CACjD,IAAI,MAAM,CAAC,MAAM,YAAY,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG,CAAC,EACnD,GAAG,UAAU,GAAG,CACjB,CAAC;IACJ,CAAC;IACD,OAAO,oBAAoB,CAAC;AAC9B,CAAC;AAED,SAAS,YAAY,CAAC,QAAoC;IACxD,MAAM,SAAS,GAAI,QAAsC,CAAC,EAAE,CAAC;IAC7D,OAAO,OAAO,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;AAC/D,CAAC"}
|
|
@@ -10,7 +10,8 @@ export type { CelEvaluationContext } from '../types/references.js';
|
|
|
10
10
|
export { CelEvaluationError } from '../types/references.js';
|
|
11
11
|
export * from './cel.js';
|
|
12
12
|
export { CelEvaluator } from './cel-evaluator.js';
|
|
13
|
-
export
|
|
13
|
+
export * from './computed.js';
|
|
14
|
+
export { createExternalRefWithoutRegistration, externalRef, observedResource, } from './external-refs.js';
|
|
14
15
|
export { DeploymentMode, ReferenceResolver } from './resolver.js';
|
|
15
16
|
export { createResourcesProxy, createSchemaProxy, isSchemaReference } from './schema-proxy.js';
|
|
16
17
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/references/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,YAAY,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,YAAY,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D,cAAc,UAAU,CAAC;AAEzB,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/references/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,YAAY,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,YAAY,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D,cAAc,UAAU,CAAC;AAEzB,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,cAAc,eAAe,CAAC;AAE9B,OAAO,EACL,oCAAoC,EACpC,WAAW,EACX,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElE,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -10,8 +10,9 @@ export { CelEvaluationError } from '../types/references.js';
|
|
|
10
10
|
export * from './cel.js';
|
|
11
11
|
// CEL evaluation
|
|
12
12
|
export { CelEvaluator } from './cel-evaluator.js';
|
|
13
|
+
export * from './computed.js';
|
|
13
14
|
// External references
|
|
14
|
-
export { createExternalRefWithoutRegistration, externalRef, observedResource } from './external-refs.js';
|
|
15
|
+
export { createExternalRefWithoutRegistration, externalRef, observedResource, } from './external-refs.js';
|
|
15
16
|
// Reference resolution (DeploymentMode is both a const object and a type via TS namespacing)
|
|
16
17
|
export { DeploymentMode, ReferenceResolver } from './resolver.js';
|
|
17
18
|
// Schema proxy
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/references/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,gBAAgB;AAChB,cAAc,UAAU,CAAC;AACzB,iBAAiB;AACjB,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,sBAAsB;AACtB,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/references/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,gBAAgB;AAChB,cAAc,UAAU,CAAC;AACzB,iBAAiB;AACjB,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,cAAc,eAAe,CAAC;AAC9B,sBAAsB;AACtB,OAAO,EACL,oCAAoC,EACpC,WAAW,EACX,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAC5B,6FAA6F;AAC7F,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClE,eAAe;AACf,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -87,12 +87,12 @@
|
|
|
87
87
|
*
|
|
88
88
|
* @packageDocumentation
|
|
89
89
|
*/
|
|
90
|
-
export { AspectApplicationError, AspectDefinitionError, allResources, append, aspect, hotReload, merge, metadata, override, replace, resources, slot, withAnnotations, withEnvFrom, withEnvVars, withHotReload, withImagePullPolicy, withLabels, withLocalWorkspace, withMetadata, withReplicas, withResourceDefaults, withServiceAccount, workloads, } from './core/aspects/index.js';
|
|
91
90
|
export type { AnnotationMap, EnvVarMap, HotReloadAspectOptions, HotReloadContainer, HotReloadVolume, LabelMap, LocalWorkspaceAspectOptions, } from './core/aspects/index.js';
|
|
92
|
-
export
|
|
91
|
+
export { AspectApplicationError, AspectDefinitionError, allResources, append, aspect, hotReload, merge, metadata, override, replace, resources, slot, withAnnotations, withEnvFrom, withEnvVars, withHotReload, withImagePullPolicy, withLabels, withLocalWorkspace, withMetadata, withReplicas, withResourceDefaults, withServiceAccount, workloads, } from './core/aspects/index.js';
|
|
92
|
+
export type { AppendOperation, ApplyAspectsOptions, AspectBuilder, AspectCardinality, AspectDefinition, AspectDiagnosticsPolicy, AspectFactoryTarget, AspectFactoryTargetBrand, AspectFactoryTargetFunction, AspectFieldPath, AspectMode, AspectOperation, AspectOperationKind, AspectOverridePatch, AspectOverrideSchemaForTarget, AspectPatchValue, AspectSafetyContext, AspectSelector, AspectSurface, AspectSurfaceForCommonKinds, AspectSurfaceForTarget, AspectSurfaceKind, AspectSurfaceKindForTarget, AspectTarget, AspectTargetGroup, AspectValidationPolicy, CommonAspectSchema, CommonAspectSchemaForTargets, CommonAspectSchemaKeys, CommonAspectSchemaValue, CommonAspectSurfaceForTargets, CommonAspectSurfaceKindForTargets, CompatibleAspectTargets, FactoryAspectTargetDescriptor, ImagePullPolicy, MergeByNameOperation, MergeOperation, MetadataAspectSurface, OverrideAspectSurface, PatchEachOperation, ReplaceOperation, ResourceAspectFactoryTarget, ResourceAspectMetadata, ResourceSpecOverrideSchema, ToYamlOptions, WorkloadAspectFactoryTarget, WorkloadPodTemplateAspectSchema, } from './core/aspects/types.js';
|
|
93
93
|
export { kubernetesComposition } from './core/composition/imperative.js';
|
|
94
94
|
export { createResource } from './core/proxy/create-resource.js';
|
|
95
|
-
export { Cel, cel, externalRef, observedResource } from './core/references/index.js';
|
|
95
|
+
export { alias, aliases, Cel, cel, computed, externalRef, observedResource, } from './core/references/index.js';
|
|
96
96
|
export type { ResourceBuilder, ResourceDependency, SchemaDefinition, SerializationContext, SerializationOptions, ValidationResult, } from './core/serialization/index.js';
|
|
97
97
|
export { generateKroSchema, generateKroSchemaFromArktype, serializeResourceGraphToYaml, toResourceGraph, validateResourceGraph, } from './core/serialization/index.js';
|
|
98
98
|
export { arktypeToKroSchema } from './core/serialization/schema.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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwFG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwFG;AAMH,YAAY,EACV,aAAa,EACb,SAAS,EACT,sBAAsB,EACtB,kBAAkB,EAClB,eAAe,EACf,QAAQ,EACR,2BAA2B,GAC5B,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,sBAAsB,EACtB,qBAAqB,EACrB,YAAY,EACZ,MAAM,EACN,MAAM,EACN,SAAS,EACT,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,SAAS,EACT,IAAI,EACJ,eAAe,EACf,WAAW,EACX,WAAW,EACX,aAAa,EACb,mBAAmB,EACnB,UAAU,EACV,kBAAkB,EAClB,YAAY,EACZ,YAAY,EACZ,oBAAoB,EACpB,kBAAkB,EAClB,SAAS,GACV,MAAM,yBAAyB,CAAC;AACjC,YAAY,EACV,eAAe,EACf,mBAAmB,EACnB,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,uBAAuB,EACvB,mBAAmB,EACnB,wBAAwB,EACxB,2BAA2B,EAC3B,eAAe,EACf,UAAU,EACV,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,6BAA6B,EAC7B,gBAAgB,EAChB,mBAAmB,EACnB,cAAc,EACd,aAAa,EACb,2BAA2B,EAC3B,sBAAsB,EACtB,iBAAiB,EACjB,0BAA0B,EAC1B,YAAY,EACZ,iBAAiB,EACjB,sBAAsB,EACtB,kBAAkB,EAClB,4BAA4B,EAC5B,sBAAs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,EAAE,4BAA4B,EAAE,MAAM,+BAA+B,CAAC;AAC7E,OAAO,EACL,yBAAyB,EACzB,2BAA2B,EAC3B,0BAA0B,EAC1B,uBAAuB,GACxB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,YAAY,EAAE,mBAAmB,EAAE,MAAM,gDAAgD,CAAC;AAC1F,OAAO,EAAE,gBAAgB,EAAE,MAAM,gDAAgD,CAAC;AAMlF,YAAY,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAC7F,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,wBAAwB,EACxB,6BAA6B,GAC9B,MAAM,4BAA4B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -87,9 +87,6 @@
|
|
|
87
87
|
*
|
|
88
88
|
* @packageDocumentation
|
|
89
89
|
*/
|
|
90
|
-
// =============================================================================
|
|
91
|
-
// 1. ESSENTIAL — Core APIs every user needs
|
|
92
|
-
// =============================================================================
|
|
93
90
|
// Aspect helpers for typed resource customization
|
|
94
91
|
export { AspectApplicationError, AspectDefinitionError, allResources, append, aspect, hotReload, merge, metadata, override, replace, resources, slot, withAnnotations, withEnvFrom, withEnvVars, withHotReload, withImagePullPolicy, withLabels, withLocalWorkspace, withMetadata, withReplicas, withResourceDefaults, withServiceAccount, workloads, } from './core/aspects/index.js';
|
|
95
92
|
// Imperative composition (define compositions with native TypeScript)
|
|
@@ -97,7 +94,7 @@ export { kubernetesComposition } from './core/composition/imperative.js';
|
|
|
97
94
|
// Resource factory (used inside resource builders)
|
|
98
95
|
export { createResource } from './core/proxy/create-resource.js';
|
|
99
96
|
// CEL expression helpers (used in status builders)
|
|
100
|
-
export { Cel, cel, externalRef, observedResource } from './core/references/index.js';
|
|
97
|
+
export { alias, aliases, Cel, cel, computed, externalRef, observedResource, } from './core/references/index.js';
|
|
101
98
|
// The primary API: define a typed resource graph
|
|
102
99
|
export { generateKroSchema, generateKroSchemaFromArktype, serializeResourceGraphToYaml, toResourceGraph, validateResourceGraph, } from './core/serialization/index.js';
|
|
103
100
|
// Schema conversion
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwFG;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwFG;AAeH,kDAAkD;AAClD,OAAO,EACL,sBAAsB,EACtB,qBAAqB,EACrB,YAAY,EACZ,MAAM,EACN,MAAM,EACN,SAAS,EACT,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,SAAS,EACT,IAAI,EACJ,eAAe,EACf,WAAW,EACX,WAAW,EACX,aAAa,EACb,mBAAmB,EACnB,UAAU,EACV,kBAAkB,EAClB,YAAY,EACZ,YAAY,EACZ,oBAAoB,EACpB,kBAAkB,EAClB,SAAS,GACV,MAAM,yBAAyB,CAAC;AAkDjC,sEAAsE;AACtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,mDAAmD;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,mDAAmD;AACnD,OAAO,EACL,KAAK,EACL,OAAO,EACP,GAAG,EACH,GAAG,EACH,QAAQ,EACR,WAAW,EACX,gBAAgB,GACjB,MAAM,4BAA4B,CAAC;AASpC,iDAAiD;AACjD,OAAO,EACL,iBAAiB,EACjB,4BAA4B,EAC5B,4BAA4B,EAC5B,eAAe,EACf,qBAAqB,GACtB,MAAM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