@@ -17,14 +17,16 @@ import {
1717 listSelectorResult ,
1818 requireListRequest ,
1919 type ServerSelectorAttachmentMap ,
20+ type ServerSelectorExecutionResult ,
2021} from '@/lib/selectors/server/types'
2122
2223type BigQuerySelectorKey = Extract < ServerSelectorKey , 'bigquery.datasets' | 'bigquery.tables' >
2324
2425const BIGQUERY_PAGE_SIZE = 200
2526const BIGQUERY_CURSOR_MAX_LENGTH = 4_096
2627const BIGQUERY_SCOPES = getScopesForService ( 'google-bigquery' )
27- const PROJECT_ID_PATTERN = / ^ [ a - z ] [ a - z 0 - 9 - ] { 4 , 28 } [ a - z 0 - 9 ] $ /
28+ /** Standard project IDs plus Google's legacy `domain.tld:project-id` form. */
29+ const PROJECT_ID_PATTERN = / ^ ( [ a - z ] [ a - z 0 - 9 . - ] { 0 , 61 } [ a - z 0 - 9 ] : ) ? [ a - z ] [ a - z 0 - 9 - ] { 4 , 28 } [ a - z 0 - 9 ] $ /
2830const DATASET_ID_PATTERN = / ^ [ A - Z a - z 0 - 9 _ ] { 1 , 1024 } $ /
2931const TABLE_ID_PATTERN = / ^ [ \p{ L} \p{ M} \p{ N} \p{ Pc} \p{ Pd} \p{ Zs} ] + $ / u
3032
@@ -67,7 +69,9 @@ const tablesPageSchema = z.object({
6769 nextPageToken : z . string ( ) . min ( 1 ) . max ( 4_096 ) . optional ( ) ,
6870} )
6971
70- function requireCredential ( args : ExecuteServerSelectorArgs ) {
72+ function requireCredential (
73+ args : ExecuteServerSelectorArgs
74+ ) : NonNullable < ExecuteServerSelectorArgs [ 'credential' ] > {
7175 if ( ! args . credential ) throw new SelectorConnectionUnavailableError ( )
7276 return args . credential
7377}
@@ -108,14 +112,16 @@ async function getAccessToken(args: ExecuteServerSelectorArgs): Promise<string>
108112 } )
109113}
110114
111- function requestHeaders ( accessToken : string ) {
115+ function requestHeaders ( accessToken : string ) : Record < string , string > {
112116 return {
113117 Authorization : `Bearer ${ accessToken } ` ,
114118 Accept : 'application/json' ,
115119 }
116120}
117121
118- async function listDatasets ( args : ExecuteServerSelectorArgs ) {
122+ async function listDatasets (
123+ args : ExecuteServerSelectorArgs
124+ ) : Promise < ServerSelectorExecutionResult > {
119125 const request = requireListRequest ( args . selectorKey , args . request )
120126 const projectId = requireProjectId ( args . context . projectId )
121127 const cursor = requireCursor ( request . cursor )
@@ -146,7 +152,7 @@ async function listDatasets(args: ExecuteServerSelectorArgs) {
146152 )
147153}
148154
149- async function listTables ( args : ExecuteServerSelectorArgs ) {
155+ async function listTables ( args : ExecuteServerSelectorArgs ) : Promise < ServerSelectorExecutionResult > {
150156 const request = requireListRequest ( args . selectorKey , args . request )
151157 const projectId = requireProjectId ( args . context . projectId )
152158 const datasetId = requireDatasetId ( args . context . datasetId )
@@ -183,7 +189,7 @@ async function listTables(args: ExecuteServerSelectorArgs) {
183189 )
184190}
185191
186- async function getDataset ( args : ExecuteServerSelectorArgs ) {
192+ async function getDataset ( args : ExecuteServerSelectorArgs ) : Promise < ServerSelectorExecutionResult > {
187193 if ( args . request . kind !== 'detail' ) throw new SelectorOptionsUnavailableError ( )
188194 const projectId = requireProjectId ( args . context . projectId )
189195 const datasetId = requireDatasetId ( args . request . id )
@@ -218,7 +224,7 @@ async function getDataset(args: ExecuteServerSelectorArgs) {
218224 } )
219225}
220226
221- async function getTable ( args : ExecuteServerSelectorArgs ) {
227+ async function getTable ( args : ExecuteServerSelectorArgs ) : Promise < ServerSelectorExecutionResult > {
222228 if ( args . request . kind !== 'detail' ) throw new SelectorOptionsUnavailableError ( )
223229 const projectId = requireProjectId ( args . context . projectId )
224230 const datasetId = requireDatasetId ( args . context . datasetId )
0 commit comments