11import type { Command } from "commander" ;
22import { queryEntities } from "../queries/EntityQuery" ;
33import { queryFilings } from "../queries/FilingQuery" ;
4+ import { queryOfferings } from "../queries/OfferingQuery" ;
5+ import { queryCrowdfunding } from "../queries/CrowdfundingQuery" ;
6+ import { queryFacts } from "../queries/FactsQuery" ;
7+ import { queryPersons } from "../queries/PersonQuery" ;
48import { renderTable } from "../output/TableRenderer" ;
59
610export function addQueryCommands ( program : Command ) : void {
@@ -100,8 +104,35 @@ export function addQueryCommands(program: Command): void {
100104 . option ( "--limit <n>" , "Limit results" )
101105 . option ( "--offset <n>" , "Offset results" )
102106 . option ( "--format <format>" , "Output format (table, json, csv)" )
103- . action ( async ( ) => {
104- console . log ( "not yet implemented" ) ;
107+ . action ( async ( search : string | undefined , options : Record < string , string > ) => {
108+ const limit = parseInt ( options . limit ?? "25" ) ;
109+ const offset = parseInt ( options . offset ?? "0" ) ;
110+ const result = await queryOfferings ( {
111+ search,
112+ cik : options . cik ? parseInt ( options . cik ) : undefined ,
113+ industry : options . industry ,
114+ exemption : options . exemption ,
115+ after : options . after ,
116+ before : options . before ,
117+ limit,
118+ offset,
119+ } ) ;
120+
121+ const columns = [
122+ { key : "cik" , header : "CIK" , width : 10 } ,
123+ { key : "file_number" , header : "File #" , width : 12 } ,
124+ { key : "industry_group" , header : "Industry" , width : 20 } ,
125+ { key : "date_of_first_sale" , header : "First Sale" , width : 12 } ,
126+ ] ;
127+
128+ console . log (
129+ renderTable ( result . rows as Record < string , unknown > [ ] , columns , {
130+ format : options . format as "table" | "csv" | "json" ,
131+ total : result . total ,
132+ offset,
133+ limit,
134+ } )
135+ ) ;
105136 } ) ;
106137
107138 query
@@ -114,8 +145,34 @@ export function addQueryCommands(program: Command): void {
114145 . option ( "--limit <n>" , "Limit results" )
115146 . option ( "--offset <n>" , "Offset results" )
116147 . option ( "--format <format>" , "Output format (table, json, csv)" )
117- . action ( async ( ) => {
118- console . log ( "not yet implemented" ) ;
148+ . action ( async ( search : string | undefined , options : Record < string , string > ) => {
149+ const limit = parseInt ( options . limit ?? "25" ) ;
150+ const offset = parseInt ( options . offset ?? "0" ) ;
151+ const result = await queryCrowdfunding ( {
152+ search,
153+ cik : options . cik ? parseInt ( options . cik ) : undefined ,
154+ portal : options . portal ? parseInt ( options . portal ) : undefined ,
155+ after : options . after ,
156+ before : options . before ,
157+ limit,
158+ offset,
159+ } ) ;
160+
161+ const columns = [
162+ { key : "cik" , header : "CIK" , width : 10 } ,
163+ { key : "name" , header : "Name" , width : 25 } ,
164+ { key : "filing_date" , header : "Filed" , width : 12 } ,
165+ { key : "status" , header : "Status" , width : 10 } ,
166+ ] ;
167+
168+ console . log (
169+ renderTable ( result . rows as Record < string , unknown > [ ] , columns , {
170+ format : options . format as "table" | "csv" | "json" ,
171+ total : result . total ,
172+ offset,
173+ limit,
174+ } )
175+ ) ;
119176 } ) ;
120177
121178 query
@@ -127,8 +184,35 @@ export function addQueryCommands(program: Command): void {
127184 . option ( "--limit <n>" , "Limit results" )
128185 . option ( "--offset <n>" , "Offset results" )
129186 . option ( "--format <format>" , "Output format (table, json, csv)" )
130- . action ( async ( ) => {
131- console . log ( "not yet implemented" ) ;
187+ . action ( async ( cik : string , options : Record < string , string > ) => {
188+ const limit = parseInt ( options . limit ?? "25" ) ;
189+ const offset = parseInt ( options . offset ?? "0" ) ;
190+ const result = await queryFacts ( {
191+ cik : parseInt ( cik ) ,
192+ name : options . name ,
193+ taxonomy : options . taxonomy ,
194+ year : options . year ? parseInt ( options . year ) : undefined ,
195+ limit,
196+ offset,
197+ } ) ;
198+
199+ const columns = [
200+ { key : "name" , header : "Fact" , width : 25 } ,
201+ { key : "val" , header : "Value" , width : 15 } ,
202+ { key : "val_unit" , header : "Unit" , width : 10 } ,
203+ { key : "fy" , header : "FY" , width : 6 } ,
204+ { key : "fp" , header : "FP" , width : 4 } ,
205+ { key : "filed_date" , header : "Filed" , width : 12 } ,
206+ ] ;
207+
208+ console . log (
209+ renderTable ( result . rows as Record < string , unknown > [ ] , columns , {
210+ format : options . format as "table" | "csv" | "json" ,
211+ total : result . total ,
212+ offset,
213+ limit,
214+ } )
215+ ) ;
132216 } ) ;
133217
134218 query
@@ -139,7 +223,31 @@ export function addQueryCommands(program: Command): void {
139223 . option ( "--limit <n>" , "Limit results" )
140224 . option ( "--offset <n>" , "Offset results" )
141225 . option ( "--format <format>" , "Output format (table, json, csv)" )
142- . action ( async ( ) => {
143- console . log ( "not yet implemented" ) ;
226+ . action ( async ( search : string | undefined , options : Record < string , string > ) => {
227+ const limit = parseInt ( options . limit ?? "25" ) ;
228+ const offset = parseInt ( options . offset ?? "0" ) ;
229+ const result = await queryPersons ( {
230+ search,
231+ cik : options . cik ? parseInt ( options . cik ) : undefined ,
232+ role : options . role ,
233+ limit,
234+ offset,
235+ } ) ;
236+
237+ const columns = [
238+ { key : "first" , header : "First" , width : 15 } ,
239+ { key : "last" , header : "Last" , width : 20 } ,
240+ { key : "title" , header : "Title" , width : 20 } ,
241+ { key : "cik" , header : "CIK" , width : 10 } ,
242+ ] ;
243+
244+ console . log (
245+ renderTable ( result . rows as Record < string , unknown > [ ] , columns , {
246+ format : options . format as "table" | "csv" | "json" ,
247+ total : result . total ,
248+ offset,
249+ limit,
250+ } )
251+ ) ;
144252 } ) ;
145253}
0 commit comments