@output.ai/core 0.5.2 → 0.5.4
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/package.json +1 -1
- package/src/consts.js +0 -5
- package/src/interface/workflow.js +1 -0
- package/src/tracing/tools/build_trace_tree.js +5 -1
- package/src/tracing/tools/build_trace_tree.spec.js +11 -0
- package/src/worker/catalog_workflow/workflow.js +9 -3
- package/src/worker/index.js +7 -39
- package/src/worker/index.spec.js +13 -31
- package/src/worker/interceptors/activity.js +6 -4
- package/src/worker/interceptors/workflow.js +1 -1
- package/src/worker/shutdown.js +26 -0
- package/src/worker/shutdown.spec.js +82 -0
- package/src/worker/sinks.js +5 -4
- package/src/worker/start_catalog.js +36 -0
- package/src/worker/start_catalog.spec.js +116 -0
- package/src/worker/webpack_loaders/tools.js +34 -4
- package/src/worker/webpack_loaders/tools.spec.js +4 -1
- package/src/worker/webpack_loaders/workflow_rewriter/collect_target_imports.js +107 -68
- package/src/worker/webpack_loaders/workflow_rewriter/collect_target_imports.spec.js +251 -1
- package/src/worker/webpack_loaders/workflow_rewriter/index.mjs +5 -4
- package/src/worker/webpack_loaders/workflow_rewriter/index.spec.js +48 -0
- package/src/worker/webpack_loaders/workflow_rewriter/rewrite_fn_bodies.js +2 -1
- package/src/worker/webpack_loaders/workflow_validator/index.mjs +3 -3
- package/src/worker/webpack_loaders/workflow_validator/index.spec.js +22 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import traverseModule from '@babel/traverse';
|
|
2
2
|
import { dirname } from 'node:path';
|
|
3
|
-
import { parse, toAbsolutePath, getFileKind, isAnyStepsPath,
|
|
3
|
+
import { parse, toAbsolutePath, getFileKind, isAnyStepsPath, isAnyEvaluatorsPath, isWorkflowPath } from '../tools.js';
|
|
4
4
|
import { ComponentFile } from '../consts.js';
|
|
5
5
|
import {
|
|
6
6
|
isCallExpression,
|
|
@@ -27,7 +27,7 @@ const getFileKindLabel = filename => {
|
|
|
27
27
|
if ( isAnyStepsPath( filename ) ) {
|
|
28
28
|
return 'steps.js';
|
|
29
29
|
}
|
|
30
|
-
if (
|
|
30
|
+
if ( isAnyEvaluatorsPath( filename ) ) {
|
|
31
31
|
return 'evaluators.js';
|
|
32
32
|
}
|
|
33
33
|
if ( /workflow\.js$/.test( filename ) ) {
|
|
@@ -48,7 +48,7 @@ const validateInstantiationLocation = ( calleeName, filename ) => {
|
|
|
48
48
|
if ( calleeName === 'step' && !isAnyStepsPath( filename ) ) {
|
|
49
49
|
throw new Error( `Invalid instantiation location: step() can only be called in files with 'steps' in the path. Found in: ${filename}` );
|
|
50
50
|
}
|
|
51
|
-
if ( calleeName === 'evaluator' && !
|
|
51
|
+
if ( calleeName === 'evaluator' && !isAnyEvaluatorsPath( filename ) ) {
|
|
52
52
|
throw new Error( `Invalid instantiation location: evaluator() can only be called in files with 'evaluators' in the path. Found in: ${filename}` );
|
|
53
53
|
}
|
|
54
54
|
if ( calleeName === 'workflow' && !isWorkflowPath( filename ) ) {
|
|
@@ -565,6 +565,28 @@ describe( 'workflow_validator loader', () => {
|
|
|
565
565
|
rmSync( dir, { recursive: true, force: true } );
|
|
566
566
|
} );
|
|
567
567
|
|
|
568
|
+
it( 'step() called in evaluators.js is blocked by validator', async () => {
|
|
569
|
+
const dir = mkdtempSync( join( tmpdir(), 'step-evals-fail-' ) );
|
|
570
|
+
const src = [
|
|
571
|
+
'import { step } from "@output.ai/core";',
|
|
572
|
+
'export const badStep = step({ name: "bad", fn: async () => ({}) });'
|
|
573
|
+
].join( '\n' );
|
|
574
|
+
await expect( runLoader( join( dir, 'evaluators.js' ), src ) )
|
|
575
|
+
.rejects.toThrow( /Invalid instantiation location.*step\(\).*steps/ );
|
|
576
|
+
rmSync( dir, { recursive: true, force: true } );
|
|
577
|
+
} );
|
|
578
|
+
|
|
579
|
+
it( 'evaluator() called in steps.js is blocked by validator', async () => {
|
|
580
|
+
const dir = mkdtempSync( join( tmpdir(), 'eval-steps-fail-' ) );
|
|
581
|
+
const src = [
|
|
582
|
+
'import { evaluator } from "@output.ai/core";',
|
|
583
|
+
'export const badEval = evaluator({ name: "bad", fn: async () => ({ value: 1 }) });'
|
|
584
|
+
].join( '\n' );
|
|
585
|
+
await expect( runLoader( join( dir, 'steps.js' ), src ) )
|
|
586
|
+
.rejects.toThrow( /Invalid instantiation location.*evaluator\(\).*evaluators/ );
|
|
587
|
+
rmSync( dir, { recursive: true, force: true } );
|
|
588
|
+
} );
|
|
589
|
+
|
|
568
590
|
it( 'workflow() called in shared/common.js is blocked by validator', async () => {
|
|
569
591
|
const dir = mkdtempSync( join( tmpdir(), 'wf-shared-fail-' ) );
|
|
570
592
|
mkdirSync( join( dir, 'shared' ) );
|