@lowdefy/build
Version:
53 lines (49 loc) • 2.11 kB
JavaScript
/*
Copyright 2020-2026 Lowdefy, Inc
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/ import { evaluateOperators } from '@lowdefy/operators';
import operators from '@lowdefy/operators-js/operators/build';
import collectDynamicIdentifiers from '../collectDynamicIdentifiers.js';
import collectTypeNames from '../collectTypeNames.js';
import validateOperatorsDynamic from '../validateOperatorsDynamic.js';
import collectExceptions from '../../utils/collectExceptions.js';
validateOperatorsDynamic({
operators
});
const dynamicIdentifiers = collectDynamicIdentifiers({
operators
});
function evaluateStaticOperators({ context, input, refDef }) {
const typeNames = collectTypeNames({
typesMap: context.typesMap
});
const { output, errors } = evaluateOperators({
input,
operators,
operatorPrefix: '_',
env: process.env,
dynamicIdentifiers,
typeNames
});
if (errors.length > 0) {
errors.forEach((error)=>{
// Resolve source file path for error location.
// Only called from buildRefs top-level where refDef is root lowdefy.yaml,
// but ~r on each operator object identifies the real source file via refMap.
// Falls back to refDef.path if ~r is missing (shouldn't happen at this stage
// since all objects have ~r after recursiveBuild completes).
error.filePath = error.refId ? context.refMap[error.refId]?.path : refDef.path;
collectExceptions(context, error);
});
}
return output;
}
export default evaluateStaticOperators;