@@ -8,6 +8,8 @@ import type {
88 SdkCommentUpdateInput ,
99 SdkCycleInput ,
1010 SdkCycleUpdateInput ,
11+ SdkDocumentInput ,
12+ SdkDocumentUpdateInput ,
1113 SdkInitiativeInput ,
1214 SdkInitiativeUpdateInput ,
1315 SdkIssueInput ,
@@ -107,6 +109,14 @@ function isProjectUpdateInput(value: unknown): value is SdkProjectUpdateInput {
107109 return isRecord ( value ) && Object . keys ( value ) . length > 0 ;
108110}
109111
112+ function isDocumentCreateInput ( value : unknown ) : value is SdkDocumentInput {
113+ return isRecord ( value ) && hasString ( value , "title" ) ;
114+ }
115+
116+ function isDocumentUpdateInput ( value : unknown ) : value is SdkDocumentUpdateInput {
117+ return isRecord ( value ) && Object . keys ( value ) . length > 0 ;
118+ }
119+
110120function isCycleCreateInput ( value : unknown ) : value is SdkCycleInput {
111121 return isRecord ( value ) && hasString ( value , "teamId" ) ;
112122}
@@ -561,6 +571,37 @@ export function createProgram(authManager = new AuthManager()): Command {
561571 authManager ,
562572 ) ;
563573
574+ registerResourceCommand (
575+ program ,
576+ "documents" ,
577+ "Document commands" ,
578+ {
579+ list : async ( _manager , cmd ) => {
580+ const globals = getGlobalOptions ( cmd ) ;
581+ return ( await sessionGateway ( cmd ) ) . listDocuments ( {
582+ limit : globals . limit ,
583+ cursor : globals . cursor ,
584+ } ) ;
585+ } ,
586+ get : async ( _manager , id , cmd ) => ( await sessionGateway ( cmd ) ) . getDocument ( id ) ,
587+ create : async ( _manager , payload , cmd ) =>
588+ ( await sessionGateway ( cmd ) ) . createDocument (
589+ ensurePayload ( payload , isDocumentCreateInput , "Document create payload requires title." ) ,
590+ ) ,
591+ update : async ( _manager , id , payload , cmd ) =>
592+ ( await sessionGateway ( cmd ) ) . updateDocument (
593+ id ,
594+ ensurePayload (
595+ payload ,
596+ isDocumentUpdateInput ,
597+ "Document update payload must be a non-empty object." ,
598+ ) ,
599+ ) ,
600+ delete : async ( _manager , id , cmd ) => ( await sessionGateway ( cmd ) ) . deleteDocument ( id ) ,
601+ } ,
602+ authManager ,
603+ ) ;
604+
564605 registerResourceCommand (
565606 program ,
566607 "cycles" ,
@@ -809,9 +850,7 @@ export function createProgram(authManager = new AuthManager()): Command {
809850 try {
810851 const session = await authManager . openSession ( { profile : globals . profile } ) ;
811852 const defaultScreen =
812- opts . screen === "projects" ||
813- opts . screen === "initiatives" ||
814- opts . screen === "cycles"
853+ opts . screen === "projects" || opts . screen === "initiatives" || opts . screen === "cycles"
815854 ? opts . screen
816855 : "issues" ;
817856 await runLinearTui ( {
0 commit comments