This repository was archived by the owner on Oct 7, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +63
-0
lines changed Expand file tree Collapse file tree 4 files changed +63
-0
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,31 @@ describe("$send.email", () => {
4040 } )
4141} )
4242
43+ describe ( "$send.emit" , ( ) => {
44+ const checker = $sendConfigRuntimeTypeChecker . emit
45+ let config
46+ beforeEach ( ( ) => {
47+ config = {
48+ raw_event : {
49+ key : randString ( ) ,
50+ } ,
51+ }
52+ } )
53+
54+ it ( "should fail with empty config" , ( ) => {
55+ expect ( ( ) => checker ( { } ) ) . toThrow ( )
56+ } )
57+
58+ it ( "should pass with full config" , ( ) => {
59+ expect ( ( ) => checker ( config ) ) . not . toThrow ( )
60+ } )
61+
62+ xit ( "should fail with .__extra" , ( ) => {
63+ config . __extra = randString ( )
64+ expect ( ( ) => checker ( config ) ) . toThrow ( )
65+ } )
66+ } )
67+
4368describe ( "$send.http" , ( ) => {
4469 const checker = $sendConfigRuntimeTypeChecker . http
4570 let config
Original file line number Diff line number Diff line change @@ -8,6 +8,18 @@ export declare const SendConfigEmail: t.PartialC<{
88 text : t . StringC ;
99} > ;
1010export declare type SendConfigEmail = t . TypeOf < typeof SendConfigEmail > ;
11+ export declare const SendConfigEmit_required : t . ExactC < t . TypeC < {
12+ raw_event : t . ObjectC ;
13+ } > > ;
14+ export declare const SendConfigEmit_optional : t . PartialC < {
15+ event : t . ObjectC ;
16+ } > ;
17+ export declare const SendConfigEmit : t . IntersectionC < [ t . ExactC < t . TypeC < {
18+ raw_event : t . ObjectC ;
19+ } > > , t . PartialC < {
20+ event : t . ObjectC ;
21+ } > ] > ;
22+ export declare type SendConfigEmit = t . TypeOf < typeof SendConfigEmit > ;
1123export declare const HTTP_METHODS : string [ ] ;
1224export declare const SendConfigHTTP : t . IntersectionC < [ t . ExactC < t . TypeC < {
1325 method : t . KeyofC < { } > ;
@@ -52,6 +64,7 @@ export declare const SendConfigSSE: t.ExactC<t.TypeC<{
5264export declare type SendConfigSSE = t . TypeOf < typeof SendConfigSSE > ;
5365interface SendFunctionsWrapper {
5466 email : ( config : SendConfigEmail ) => void ;
67+ emit : ( config : SendConfigEmit ) => void ;
5568 http : ( config : SendConfigHTTP ) => void ;
5669 s3 : ( config : SendConfigS3 ) => void ;
5770 sql : ( config : SendConfigSQL ) => void ;
@@ -64,6 +77,11 @@ export declare const sendTypeMap: {
6477 subject : t . StringC ;
6578 text : t . StringC ;
6679 } > ;
80+ emit : t . IntersectionC < [ t . ExactC < t . TypeC < {
81+ raw_event : t . ObjectC ;
82+ } > > , t . PartialC < {
83+ event : t . ObjectC ;
84+ } > ] > ;
6785 http : t . IntersectionC < [ t . ExactC < t . TypeC < {
6886 method : t . KeyofC < { } > ;
6987 url : t . StringC ;
Original file line number Diff line number Diff line change @@ -12,6 +12,13 @@ exports.SendConfigEmail = t.partial({
1212 subject : t . string ,
1313 text : t . string ,
1414} ) ;
15+ exports . SendConfigEmit_required = t . strict ( {
16+ raw_event : t . object ,
17+ } ) ;
18+ exports . SendConfigEmit_optional = t . partial ( {
19+ event : t . object ,
20+ } ) ;
21+ exports . SendConfigEmit = t . intersection ( [ exports . SendConfigEmit_required , exports . SendConfigEmit_optional ] ) ;
1522// interface SendConfigHTTPKv {
1623// [key: string]: string;
1724// }
@@ -75,6 +82,7 @@ exports.SendConfigSSE = t.strict({
7582// XXX would be cool to have this and SendFunctionsWrapper be more shared
7683exports . sendTypeMap = {
7784 email : exports . SendConfigEmail ,
85+ emit : exports . SendConfigEmit ,
7886 http : exports . SendConfigHTTP ,
7987 s3 : exports . SendConfigS3 ,
8088 sql : exports . SendConfigSQL ,
Original file line number Diff line number Diff line change @@ -15,6 +15,16 @@ export const SendConfigEmail = t.partial({
1515} ) ;
1616export type SendConfigEmail = t . TypeOf < typeof SendConfigEmail > ;
1717
18+ export const SendConfigEmit_required = t . strict ( {
19+ raw_event : t . object ,
20+ } ) ;
21+
22+ export const SendConfigEmit_optional = t . partial ( {
23+ event : t . object ,
24+ } ) ;
25+ export const SendConfigEmit = t . intersection ( [ SendConfigEmit_required , SendConfigEmit_optional ] ) ;
26+ export type SendConfigEmit = t . TypeOf < typeof SendConfigEmit > ;
27+
1828// interface SendConfigHTTPKv {
1929// [key: string]: string;
2030// }
@@ -92,6 +102,7 @@ export type SendConfigSSE = t.TypeOf<typeof SendConfigSSE>;
92102// optionals so we can use self-invoking function below
93103interface SendFunctionsWrapper {
94104 email : ( config : SendConfigEmail ) => void ;
105+ emit : ( config : SendConfigEmit ) => void ;
95106 http : ( config : SendConfigHTTP ) => void ;
96107 s3 : ( config : SendConfigS3 ) => void ;
97108 sql : ( config : SendConfigSQL ) => void ;
@@ -101,6 +112,7 @@ interface SendFunctionsWrapper {
101112// XXX would be cool to have this and SendFunctionsWrapper be more shared
102113export const sendTypeMap = {
103114 email : SendConfigEmail ,
115+ emit : SendConfigEmit ,
104116 http : SendConfigHTTP ,
105117 s3 : SendConfigS3 ,
106118 sql : SendConfigSQL ,
You can’t perform that action at this time.
0 commit comments