@@ -500,18 +500,83 @@ export const createBlueprint = async (
500500 routes ,
501501 context ,
502502 )
503+ const events = await createEvents ( openapiSchemas , routes , context )
504+
505+ assertSeamPathsAreUndocumented ( {
506+ routes,
507+ namespaces,
508+ resources,
509+ events,
510+ actionAttempts,
511+ } )
503512
504513 return {
505514 title : openapi . info . title ,
506515 routes,
507516 namespaces,
508517 resources,
509518 pagination : createPagination ( pagination , openapiSchemas ) ,
510- events : await createEvents ( openapiSchemas , routes , context ) ,
519+ events,
511520 actionAttempts,
512521 }
513522}
514523
524+ const isSeamPath = ( path : string ) : boolean =>
525+ path === '/seam' || path . startsWith ( '/seam/' )
526+
527+ const assertSeamPathsAreUndocumented = ( {
528+ routes,
529+ namespaces,
530+ resources,
531+ events,
532+ actionAttempts,
533+ } : Pick <
534+ Blueprint ,
535+ 'routes' | 'namespaces' | 'resources' | 'events' | 'actionAttempts'
536+ > ) : void => {
537+ const offenders = [
538+ ...routes . flatMap ( ( route ) => {
539+ const routeOffenders =
540+ isSeamPath ( route . path ) && ! route . isUndocumented
541+ ? [ `route ${ route . path } ` ]
542+ : [ ]
543+ const endpointOffenders = route . endpoints . flatMap ( ( endpoint ) =>
544+ isSeamPath ( endpoint . path ) && ! endpoint . isUndocumented
545+ ? [ `endpoint ${ endpoint . path } ` ]
546+ : [ ] ,
547+ )
548+
549+ return [ ...routeOffenders , ...endpointOffenders ]
550+ } ) ,
551+ ...namespaces . flatMap ( ( namespace ) =>
552+ isSeamPath ( namespace . path ) && ! namespace . isUndocumented
553+ ? [ `namespace ${ namespace . path } ` ]
554+ : [ ] ,
555+ ) ,
556+ ...resources . flatMap ( ( resource ) =>
557+ isSeamPath ( resource . routePath ) && ! resource . isUndocumented
558+ ? [ `resource ${ resource . routePath } ` ]
559+ : [ ] ,
560+ ) ,
561+ ...events . flatMap ( ( event ) =>
562+ isSeamPath ( event . routePath ) && ! event . isUndocumented
563+ ? [ `event ${ event . routePath } ` ]
564+ : [ ] ,
565+ ) ,
566+ ...actionAttempts . flatMap ( ( actionAttempt ) =>
567+ isSeamPath ( actionAttempt . routePath ) && ! actionAttempt . isUndocumented
568+ ? [ `action_attempt ${ actionAttempt . routePath } ` ]
569+ : [ ] ,
570+ ) ,
571+ ]
572+
573+ if ( offenders . length > 0 ) {
574+ throw new Error (
575+ `All /seam entries must be marked undocumented. Found: ${ offenders . join ( ', ' ) } ` ,
576+ )
577+ }
578+ }
579+
515580const extractValidActionAttemptTypes = (
516581 schemas : Openapi [ 'components' ] [ 'schemas' ] ,
517582) : string [ ] => {
@@ -1946,9 +2011,9 @@ const createActionAttempts = async (
19462011 const allPropertyKeys = new Set < string > ( )
19472012 for ( const schema of actionAttemptSchemas ) {
19482013 if ( schema . properties != null ) {
1949- Object . keys ( schema . properties ) . forEach ( ( key ) =>
1950- allPropertyKeys . add ( key ) ,
1951- )
2014+ Object . keys ( schema . properties ) . forEach ( ( key ) => {
2015+ allPropertyKeys . add ( key )
2016+ } )
19522017 }
19532018 }
19542019
0 commit comments