@telorun/kernel 0.26.1 → 0.28.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.
Files changed (49) hide show
  1. package/dist/cel-handlers.d.ts +14 -0
  2. package/dist/cel-handlers.d.ts.map +1 -0
  3. package/dist/cel-handlers.js +22 -0
  4. package/dist/cel-handlers.js.map +1 -0
  5. package/dist/dependency-injection.d.ts +10 -0
  6. package/dist/dependency-injection.d.ts.map +1 -0
  7. package/dist/dependency-injection.js +95 -0
  8. package/dist/dependency-injection.js.map +1 -0
  9. package/dist/eval-paths.d.ts +10 -0
  10. package/dist/eval-paths.d.ts.map +1 -0
  11. package/dist/eval-paths.js +35 -0
  12. package/dist/eval-paths.js.map +1 -0
  13. package/dist/evaluation-context.d.ts.map +1 -1
  14. package/dist/evaluation-context.js +60 -0
  15. package/dist/evaluation-context.js.map +1 -1
  16. package/dist/index.d.ts +2 -2
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +2 -2
  19. package/dist/index.js.map +1 -1
  20. package/dist/invoke-dispatch.d.ts +11 -0
  21. package/dist/invoke-dispatch.d.ts.map +1 -0
  22. package/dist/invoke-dispatch.js +37 -0
  23. package/dist/invoke-dispatch.js.map +1 -0
  24. package/dist/kernel.d.ts +16 -31
  25. package/dist/kernel.d.ts.map +1 -1
  26. package/dist/kernel.js +28 -291
  27. package/dist/kernel.js.map +1 -1
  28. package/dist/resource-context.d.ts.map +1 -1
  29. package/dist/resource-context.js +2 -15
  30. package/dist/resource-context.js.map +1 -1
  31. package/dist/schema-compiled-values.d.ts +7 -0
  32. package/dist/schema-compiled-values.d.ts.map +1 -0
  33. package/dist/schema-compiled-values.js +72 -0
  34. package/dist/schema-compiled-values.js.map +1 -0
  35. package/package.json +2 -2
  36. package/src/cel-handlers.ts +24 -0
  37. package/src/dependency-injection.ts +96 -0
  38. package/src/eval-paths.ts +44 -0
  39. package/src/evaluation-context.ts +58 -0
  40. package/src/index.ts +2 -2
  41. package/src/invoke-dispatch.ts +43 -0
  42. package/src/kernel.ts +28 -323
  43. package/src/resource-context.ts +1 -13
  44. package/src/schema-compiled-values.ts +85 -0
  45. package/dist/event-stream.d.ts +0 -45
  46. package/dist/event-stream.d.ts.map +0 -1
  47. package/dist/event-stream.js +0 -98
  48. package/dist/event-stream.js.map +0 -1
  49. package/src/event-stream.ts +0 -121
@@ -1,121 +0,0 @@
1
- import * as fs from 'fs/promises';
2
- import * as path from 'path';
3
-
4
- /**
5
- * Streaming event log for debugging and testing
6
- * Records all events in JSONL format (one JSON object per line)
7
- * Useful for observing runtime execution, testing, and debugging
8
- */
9
- export class EventStream {
10
- private filePath: string;
11
- private isEnabled: boolean = false;
12
-
13
- constructor(filePath?: string) {
14
- this.filePath = filePath || '';
15
- this.isEnabled = !!filePath;
16
- }
17
-
18
- /**
19
- * Enable event streaming to a file
20
- */
21
- async enable(filePath: string): Promise<void> {
22
- this.filePath = filePath;
23
- this.isEnabled = true;
24
-
25
- // Ensure directory exists
26
- const dir = path.dirname(filePath);
27
- if (dir !== '.' && dir !== '') {
28
- await fs.mkdir(dir, { recursive: true });
29
- }
30
-
31
- // Initialize file (truncate if exists)
32
- await fs.writeFile(filePath, '', 'utf-8');
33
- }
34
-
35
- /**
36
- * Log an event to the stream
37
- */
38
- async log(
39
- event: string,
40
- payload?: any,
41
- metadata?: {
42
- namespace?: string;
43
- resource?: string;
44
- kind?: string;
45
- name?: string;
46
- },
47
- ): Promise<void> {
48
- if (!this.isEnabled) {
49
- return;
50
- }
51
-
52
- const logEntry = {
53
- timestamp: new Date().toISOString(),
54
- event,
55
- payload,
56
- ...metadata,
57
- };
58
-
59
- try {
60
- const line = JSON.stringify(logEntry) + '\n';
61
- await fs.appendFile(this.filePath, line, 'utf-8');
62
- } catch (error) {
63
- console.error('Failed to write event to stream:', error);
64
- }
65
- }
66
-
67
- /**
68
- * Read all events from the stream as an array
69
- * Useful for testing
70
- */
71
- async readAll(): Promise<Array<Record<string, any>>> {
72
- if (!this.isEnabled || !this.filePath) {
73
- return [];
74
- }
75
-
76
- try {
77
- const content = await fs.readFile(this.filePath, 'utf-8');
78
- if (!content.trim()) {
79
- return [];
80
- }
81
- return content
82
- .trim()
83
- .split('\n')
84
- .map((line) => JSON.parse(line));
85
- } catch (error) {
86
- console.error('Failed to read event stream:', error);
87
- return [];
88
- }
89
- }
90
-
91
- /**
92
- * Filter events by type
93
- */
94
- async getEventsByType(
95
- eventType: string,
96
- ): Promise<Array<Record<string, any>>> {
97
- const all = await this.readAll();
98
- return all.filter((e) => e.event === eventType);
99
- }
100
-
101
- /**
102
- * Get the file path for the event stream
103
- */
104
- getFilePath(): string {
105
- return this.filePath;
106
- }
107
-
108
- /**
109
- * Check if event streaming is enabled
110
- */
111
- isEnabledStream(): boolean {
112
- return this.isEnabled;
113
- }
114
-
115
- /**
116
- * Disable event streaming
117
- */
118
- disable(): void {
119
- this.isEnabled = false;
120
- }
121
- }