@output.ai/core 0.1.0 → 0.1.2

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.
Files changed (53) hide show
  1. package/README.md +114 -30
  2. package/package.json +9 -6
  3. package/src/consts.js +3 -1
  4. package/src/index.d.ts +36 -4
  5. package/src/interface/evaluator.js +12 -8
  6. package/src/interface/step.js +4 -4
  7. package/src/interface/validations/static.js +16 -2
  8. package/src/interface/validations/static.spec.js +20 -0
  9. package/src/interface/workflow.js +28 -25
  10. package/src/interface/zod_integration.spec.js +6 -6
  11. package/src/internal_activities/index.js +1 -33
  12. package/src/tracing/index.d.ts +4 -4
  13. package/src/tracing/index.js +12 -121
  14. package/src/tracing/internal_interface.js +66 -0
  15. package/src/tracing/processors/local/index.js +50 -0
  16. package/src/tracing/processors/local/index.spec.js +67 -0
  17. package/src/tracing/processors/s3/index.js +51 -0
  18. package/src/tracing/processors/s3/index.spec.js +64 -0
  19. package/src/tracing/processors/s3/redis_client.js +19 -0
  20. package/src/tracing/processors/s3/redis_client.spec.js +50 -0
  21. package/src/tracing/processors/s3/s3_client.js +33 -0
  22. package/src/tracing/processors/s3/s3_client.spec.js +67 -0
  23. package/src/tracing/{tracer_tree.js → tools/build_trace_tree.js} +4 -11
  24. package/src/tracing/{tracer_tree.spec.js → tools/build_trace_tree.spec.js} +4 -20
  25. package/src/tracing/{utils.js → tools/utils.js} +7 -0
  26. package/src/tracing/trace_engine.js +63 -0
  27. package/src/tracing/trace_engine.spec.js +91 -0
  28. package/src/utils.js +37 -0
  29. package/src/utils.spec.js +60 -0
  30. package/src/worker/catalog_workflow/index.js +2 -1
  31. package/src/worker/catalog_workflow/index.spec.js +6 -10
  32. package/src/worker/configs.js +24 -0
  33. package/src/worker/index.js +7 -4
  34. package/src/worker/interceptors/activity.js +7 -14
  35. package/src/worker/interceptors/workflow.js +11 -3
  36. package/src/worker/loader.js +65 -29
  37. package/src/worker/loader.spec.js +32 -25
  38. package/src/worker/loader_tools.js +63 -0
  39. package/src/worker/loader_tools.spec.js +85 -0
  40. package/src/worker/sinks.js +8 -4
  41. package/src/worker/webpack_loaders/workflow_rewriter/collect_target_imports.js +38 -20
  42. package/src/worker/webpack_loaders/workflow_rewriter/index.mjs +5 -4
  43. package/src/worker/webpack_loaders/workflow_rewriter/index.spec.js +48 -0
  44. package/src/worker/webpack_loaders/workflow_rewriter/rewrite_fn_bodies.js +16 -20
  45. package/src/worker/webpack_loaders/workflow_rewriter/tools.js +23 -0
  46. package/src/configs.js +0 -31
  47. package/src/configs.spec.js +0 -331
  48. package/src/interface/metadata.js +0 -4
  49. package/src/tracing/index.private.spec.js +0 -84
  50. package/src/tracing/index.public.spec.js +0 -86
  51. package/src/worker/internal_utils.js +0 -60
  52. package/src/worker/internal_utils.spec.js +0 -134
  53. /package/src/tracing/{utils.spec.js → tools/utils.spec.js} +0 -0
@@ -1,134 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { mkdtempSync, mkdirSync, writeFileSync, rmSync, readFileSync, existsSync } from 'node:fs';
3
- import { join, resolve } from 'node:path';
4
- import { tmpdir } from 'node:os';
5
- import { pathToFileURL } from 'node:url';
6
- import { recursiveNavigateWhileCollecting, iteratorOverImportedComponents, writeFileOnLocationSync } from './internal_utils.js';
7
-
8
- function makeTmpRoot( prefix ) {
9
- return mkdtempSync( join( tmpdir(), prefix ) );
10
- }
11
-
12
- describe( '.recursiveNavigateWhileCollecting', () => {
13
- it( 'collects matching files recursively (happy path)', () => {
14
- const root = makeTmpRoot( 'nsu-happy-' );
15
- const target = 'target.txt';
16
-
17
- // layout:
18
- // root/target.txt
19
- // root/a/target.txt
20
- // root/b/c/target.txt
21
- mkdirSync( join( root, 'a' ), { recursive: true } );
22
- mkdirSync( join( root, 'b', 'c' ), { recursive: true } );
23
- writeFileSync( join( root, target ), 'root' );
24
- writeFileSync( join( root, 'a', target ), 'a' );
25
- writeFileSync( join( root, 'b', 'c', target ), 'bc' );
26
-
27
- const results = recursiveNavigateWhileCollecting( root, [ target ] );
28
-
29
- expect( results.length ).toBe( 3 );
30
- for ( const { pathname, path, url } of results ) {
31
- expect( url ).toBe( pathToFileURL( pathname ).href );
32
- expect( resolve( path, target ) ).toBe( pathname );
33
- }
34
-
35
- rmSync( root, { recursive: true, force: true } );
36
- } );
37
-
38
- it( 'skips files inside ignored directories (ignoreDirNames)', () => {
39
- const root = makeTmpRoot( 'nsu-ignore-' );
40
- const target = 'target.txt';
41
-
42
- // layout:
43
- // root/node_modules/target.txt (ignored)
44
- // root/vendor/target.txt (ignored)
45
- // root/ok/target.txt (collected)
46
- mkdirSync( join( root, 'node_modules' ), { recursive: true } );
47
- mkdirSync( join( root, 'vendor' ), { recursive: true } );
48
- mkdirSync( join( root, 'ok' ), { recursive: true } );
49
- writeFileSync( join( root, 'node_modules', target ), 'nm' );
50
- writeFileSync( join( root, 'vendor', target ), 'v' );
51
- writeFileSync( join( root, 'ok', target ), 'ok' );
52
-
53
- const results = recursiveNavigateWhileCollecting( root, [ target ] );
54
-
55
- expect( results.length ).toBe( 1 );
56
- expect( results[0].pathname ).toBe( join( root, 'ok', target ) );
57
- expect( results[0].path ).toBe( join( root, 'ok' ) );
58
- expect( results[0].url ).toBe( pathToFileURL( results[0].pathname ).href );
59
-
60
- rmSync( root, { recursive: true, force: true } );
61
- } );
62
- } );
63
-
64
- describe( '.iteratorOverImportedComponents', () => {
65
- it( 'imports modules and yields metadata from exports tagged with METADATA_ACCESS_SYMBOL', async () => {
66
- const root = join( process.cwd(), 'sdk/core/temp_test_modules', `meta-${Date.now()}` );
67
- mkdirSync( root, { recursive: true } );
68
- const file = join( root, 'meta.module.js' );
69
- writeFileSync( file, [
70
- 'import { METADATA_ACCESS_SYMBOL } from \"#consts\";',
71
- 'export const StepA = () => {};',
72
- 'StepA[METADATA_ACCESS_SYMBOL] = { kind: \"step\", name: \"a\" };',
73
- 'export const FlowB = () => {};',
74
- 'FlowB[METADATA_ACCESS_SYMBOL] = { kind: \"workflow\", name: \"b\" };'
75
- ].join( '\n' ) );
76
-
77
- const paths = recursiveNavigateWhileCollecting( root, [ 'meta.module.js' ] );
78
- const collected = [];
79
- for await ( const m of iteratorOverImportedComponents( paths ) ) {
80
- collected.push( m );
81
- }
82
-
83
- expect( collected.length ).toBe( 2 );
84
- expect( collected.map( m => m.metadata.name ).sort() ).toEqual( [ 'a', 'b' ] );
85
- expect( collected.map( m => m.metadata.kind ).sort() ).toEqual( [ 'step', 'workflow' ] );
86
- for ( const m of collected ) {
87
- expect( m.pathname ).toBe( file );
88
- expect( m.path ).toBe( root );
89
- expect( typeof m.component ).toBe( 'function' );
90
- }
91
-
92
- rmSync( root, { recursive: true, force: true } );
93
- } );
94
-
95
- it( 'ignores exports without metadata symbol', async () => {
96
- const root = join( process.cwd(), 'sdk/core/temp_test_modules', `meta-${Date.now()}-nometa` );
97
- mkdirSync( root, { recursive: true } );
98
- const file = join( root, 'meta.module.js' );
99
- writeFileSync( file, [
100
- 'export const Plain = () => {};',
101
- 'export const AlsoPlain = {}'
102
- ].join( '\n' ) );
103
-
104
- const paths = recursiveNavigateWhileCollecting( root, [ 'meta.module.js' ] );
105
- const collected = [];
106
- for await ( const m of iteratorOverImportedComponents( paths ) ) {
107
- collected.push( m );
108
- }
109
-
110
- expect( collected.length ).toBe( 0 );
111
- rmSync( root, { recursive: true, force: true } );
112
- } );
113
- } );
114
-
115
- describe( '.writeFileOnLocationSync', () => {
116
- it( 'creates missing directories and writes file', () => {
117
- const root = makeTmpRoot( 'nsu-write-' );
118
- const nested = join( root, 'a', 'b', 'c.txt' );
119
- writeFileOnLocationSync( nested, 'hello' );
120
- expect( existsSync( join( root, 'a', 'b' ) ) ).toBe( true );
121
- expect( readFileSync( nested, 'utf-8' ) ).toBe( 'hello' );
122
- rmSync( root, { recursive: true, force: true } );
123
- } );
124
-
125
- it( 'overwrites existing content', () => {
126
- const root = makeTmpRoot( 'nsu-write2-' );
127
- const file = join( root, 'x', 'y.txt' );
128
- mkdirSync( join( root, 'x' ), { recursive: true } );
129
- writeFileSync( file, 'old' );
130
- writeFileOnLocationSync( file, 'new' );
131
- expect( readFileSync( file, 'utf-8' ) ).toBe( 'new' );
132
- rmSync( root, { recursive: true, force: true } );
133
- } );
134
- } );