forked from BeOnAuto/auto-engineer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema-test.ts
More file actions
67 lines (56 loc) · 2.76 KB
/
schema-test.ts
File metadata and controls
67 lines (56 loc) · 2.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import { DataSinkSchema, DataSourceSchema, MessageTargetSchema } from './schema';
import { sink, source } from './data-flow-builders';
// Test that the builders produce output compatible with the schema
const testSink = sink().event('TestEvent').fields({ id: true }).toStream('test-${id}');
const testSource = source().state('TestState').fromProjection('TestProjection', 'id');
// Test new additionalInstructions functionality
const sinkWithInstructions = sink()
.event('TestEvent')
.additionalInstructions('Custom processing instructions')
.toStream('test-${id}');
const sourceWithInstructions = source()
.state('TestState')
.additionalInstructions('Custom query instructions')
.fromProjection('TestProjection', 'eventId');
// Test withState functionality for commands
const commandSinkWithState = sink()
.command('TestCommand')
.withState(testSource)
.additionalInstructions('Process with state context')
.toIntegration('TestIntegration', 'DoSomething', 'command');
console.log('Testing sink schema compatibility...');
const sinkResult = DataSinkSchema.safeParse(testSink);
console.log('Sink valid:', sinkResult.success);
if (!sinkResult.success) {
console.log('Sink errors:', sinkResult.error);
}
console.log('Testing source schema compatibility...');
const sourceResult = DataSourceSchema.safeParse(testSource);
console.log('Source valid:', sourceResult.success);
if (!sourceResult.success) {
console.log('Source errors:', sourceResult.error);
}
console.log('Testing message target schema compatibility...');
const targetResult = MessageTargetSchema.safeParse(testSink.target);
console.log('Target valid:', targetResult.success);
if (!targetResult.success) {
console.log('Target errors:', targetResult.error);
}
console.log('\nTesting sink with additional instructions...');
const sinkWithInstructionsResult = DataSinkSchema.safeParse(sinkWithInstructions);
console.log('Sink with instructions valid:', sinkWithInstructionsResult.success);
if (!sinkWithInstructionsResult.success) {
console.log('Sink with instructions errors:', sinkWithInstructionsResult.error);
}
console.log('\nTesting source with additional instructions...');
const sourceWithInstructionsResult = DataSourceSchema.safeParse(sourceWithInstructions);
console.log('Source with instructions valid:', sourceWithInstructionsResult.success);
if (!sourceWithInstructionsResult.success) {
console.log('Source with instructions errors:', sourceWithInstructionsResult.error);
}
console.log('\nTesting command sink with state...');
const commandSinkWithStateResult = DataSinkSchema.safeParse(commandSinkWithState);
console.log('Command sink with state valid:', commandSinkWithStateResult.success);
if (!commandSinkWithStateResult.success) {
console.log('Command sink with state errors:', commandSinkWithStateResult.error);
}