@@ -6,10 +6,13 @@ import {
6
6
FailureOrigin ,
7
7
FailureReason ,
8
8
FailureType ,
9
+ FieldTransformTransformType ,
9
10
Geography ,
10
11
JobConfigType ,
11
12
NamespaceDefinitionType ,
12
13
NonBreakingChangesPreference ,
14
+ StreamAttributeTransformTransformType ,
15
+ StreamTransformTransformType ,
13
16
} from "core/api/types/AirbyteClient" ;
14
17
15
18
/**
@@ -38,6 +41,9 @@ const connectionAutoDisabledReasons = [
38
41
] ;
39
42
40
43
// property-specific schemas
44
+ /**
45
+ * @typedef {import("core/api/types/AirbyteClient").StreamDescriptor }
46
+ */
41
47
const streamDescriptorSchema = yup . object ( {
42
48
name : yup . string ( ) . required ( ) ,
43
49
namespace : yup . string ( ) . optional ( ) ,
@@ -49,6 +55,80 @@ const jobRunningStreamSchema = yup.object({
49
55
configType : yup . mixed < JobConfigType > ( ) . oneOf ( [ "sync" , "refresh" , "clear" , "reset_connection" ] ) . required ( ) ,
50
56
} ) ;
51
57
58
+ /**
59
+ * @typedef {import("core/api/types/AirbyteClient").FieldSchema }
60
+ */
61
+ const fieldSchema = yup . object ( {
62
+ schema : yup . object ( ) . optional ( ) ,
63
+ } ) ;
64
+
65
+ /**
66
+ * @typedef {import("core/api/types/AirbyteClient").FieldSchemaUpdate }
67
+ */
68
+ const fieldSchemaUpdateSchema = yup . object ( {
69
+ newSchema : fieldSchema . required ( ) ,
70
+ oldSchema : fieldSchema . required ( ) ,
71
+ } ) ;
72
+
73
+ /**
74
+ * @typedef {import("core/api/types/AirbyteClient").FieldTransform }
75
+ */
76
+ const fieldTransformSchema = yup . object ( {
77
+ addField : fieldSchema . optional ( ) ,
78
+ breaking : yup . boolean ( ) . required ( ) ,
79
+ fieldName : yup . array ( ) . of ( yup . string ( ) ) . required ( ) ,
80
+ removeField : fieldSchema . optional ( ) ,
81
+ transformType : yup
82
+ . mixed < FieldTransformTransformType > ( )
83
+ . oneOf ( [ "add_field" , "remove_field" , "update_field_schema" ] )
84
+ . required ( ) ,
85
+ updateFieldSchema : fieldSchemaUpdateSchema . optional ( ) ,
86
+ } ) ;
87
+
88
+ /**
89
+ * @typedef {import("core/api/types/AirbyteClient").StreamAttributePrimaryKeyUpdate }
90
+ */
91
+ const streamAttributePrimaryKeyUpdateSchema = yup . object ( {
92
+ newPrimaryKey : yup . array ( ) . of ( yup . array ( ) . of ( yup . string ( ) ) ) . optional ( ) ,
93
+ oldPrimaryKey : yup . array ( ) . of ( yup . array ( ) . of ( yup . string ( ) ) ) . optional ( ) ,
94
+ } ) ;
95
+
96
+ /**
97
+ * @typedef {import("core/api/types/AirbyteClient").StreamAttributeTransform }
98
+ */
99
+ const streamAttributeTransformSchema = yup . object ( {
100
+ breaking : yup . boolean ( ) . required ( ) ,
101
+ transformType : yup . mixed < StreamAttributeTransformTransformType > ( ) . oneOf ( [ "update_primary_key" ] ) . required ( ) ,
102
+ updatePrimaryKey : streamAttributePrimaryKeyUpdateSchema . optional ( ) ,
103
+ } ) ;
104
+
105
+ /**
106
+ * @typedef {import("core/api/types/AirbyteClient").StreamTransformUpdateStream }
107
+ */
108
+ const streamTransformUpdateStreamSchema = yup . object ( {
109
+ fieldTransforms : yup . array ( ) . of ( fieldTransformSchema ) . optional ( ) ,
110
+ streamAttributeTransforms : yup . array ( ) . of ( streamAttributeTransformSchema ) . optional ( ) ,
111
+ } ) ;
112
+
113
+ /**
114
+ * @typedef {import("core/api/types/AirbyteClient").StreamTransform }
115
+ */
116
+ const streamTransformsSchema = yup . object ( {
117
+ streamDescriptor : streamDescriptorSchema . required ( ) ,
118
+ transformType : yup
119
+ . mixed < StreamTransformTransformType > ( )
120
+ . oneOf ( [ "add_stream" , "remove_stream" , "update_stream" ] )
121
+ . required ( ) ,
122
+ updateStream : streamTransformUpdateStreamSchema . optional ( ) ,
123
+ } ) ;
124
+
125
+ /**
126
+ * @typedef {import("core/api/types/AirbyteClient").CatalogDiff }
127
+ */
128
+ const catalogDiffSchema = yup . object ( {
129
+ transforms : yup . array ( ) . of ( streamTransformsSchema ) . required ( ) ,
130
+ } ) ;
131
+
52
132
export type TimelineFailureReason = Omit < FailureReason , "timestamp" > ;
53
133
54
134
export const jobFailureReasonSchema = yup . object ( {
@@ -61,6 +141,9 @@ export const jobFailureReasonSchema = yup.object({
61
141
stacktrace : yup . string ( ) . optional ( ) ,
62
142
} ) ;
63
143
144
+ /**
145
+ * @typedef {import("core/api/types/AirbyteClient").UserReadInConnectionEvent }
146
+ */
64
147
export const userInEventSchema = yup . object ( {
65
148
email : yup . string ( ) . optional ( ) ,
66
149
id : yup . string ( ) . optional ( ) ,
@@ -161,6 +244,14 @@ export const connectionSettingsUpdateEventSummarySchema = yup.object({
161
244
. required ( ) ,
162
245
} ) ;
163
246
247
+ export const schemaUpdateSummarySchema = yup . object ( {
248
+ catalogDiff : catalogDiffSchema . required ( ) ,
249
+ updateReason : yup . mixed ( ) . oneOf ( [ "SCHEMA_CHANGE_AUTO_PROPAGATE" ] ) . optional ( ) ,
250
+ } ) ;
251
+
252
+ /**
253
+ * @typedef {import("core/api/types/AirbyteClient").ConnectionEvent }
254
+ */
164
255
export const generalEventSchema = yup . object ( {
165
256
id : yup . string ( ) . required ( ) ,
166
257
connectionId : yup . string ( ) . required ( ) ,
@@ -241,3 +332,8 @@ export const connectionSettingsUpdateEventSchema = generalEventSchema.shape({
241
332
eventType : yup . mixed < ConnectionEventType > ( ) . oneOf ( [ ConnectionEventType . CONNECTION_SETTINGS_UPDATE ] ) . required ( ) ,
242
333
summary : connectionSettingsUpdateEventSummarySchema . required ( ) ,
243
334
} ) ;
335
+
336
+ export const schemaUpdateEventSchema = generalEventSchema . shape ( {
337
+ eventType : yup . mixed < ConnectionEventType > ( ) . oneOf ( [ ConnectionEventType . SCHEMA_UPDATE ] ) . required ( ) ,
338
+ summary : schemaUpdateSummarySchema . required ( ) ,
339
+ } ) ;
0 commit comments