1818import { getDataConnect } from './index' ;
1919import { DataConnect } from './data-connect' ;
2020import { ConnectorConfig , OperationOptions } from './data-connect-api' ;
21- import { DATA_CONNECT_ERROR_CODE_MAPPING , FirebaseDataConnectError } from './data-connect-api-client-internal' ;
22-
23-
24- interface ParsedAdminArgs < Variables > {
25- dc : DataConnect ;
26- vars : Variables ;
27- options : OperationOptions
28- }
21+ import {
22+ DATA_CONNECT_ERROR_CODE_MAPPING ,
23+ FirebaseDataConnectError ,
24+ } from './data-connect-api-client-internal' ;
2925
3026/**
31- * The generated Admin SDK will allow the user to pass in variables, a Data Connect
27+ * The generated Admin SDK will allow the user to pass in variables, a Data Connect
3228 * instance, or operation options. The only required argument is the variables,
33- * which are only required when the operation has at least one required variable.
29+ * which are only required when the operation has at least one required variable.
3430 * Otherwise, all arguments are optional. This function validates the variables
3531 * and returns back the DataConnect instance, variables, and options based on the
3632 * arguments passed in.
37- * @param connectorConfig DataConnect connector config
38- * @param dcOrVarsOrOptions the first argument provided to a generated admin function
39- * @param varsOrOptions the second argument provided to a generated admin function
40- * @param options the third argument provided to a generated admin function
41- * @param hasVars boolean parameter indicating whether the operation has variables
42- * @param validateVars boolean parameter indicating whether we should expect to find a value for realVars
33+ * @param connectorConfig - DataConnect connector config
34+ * @param dcOrVarsOrOptions - the first argument provided to a generated admin function
35+ * @param varsOrOptions - the second argument provided to a generated admin function
36+ * @param options - the third argument provided to a generated admin function
37+ * @param hasVars - boolean parameter indicating whether the operation has variables
38+ * @param validateVars - boolean parameter indicating whether we should expect to find a value for realVars
4339 * @returns parsed DataConnect, Variables, and Options for the operation
44- * @internal
4540 */
4641export function validateAdminArgs < Variables extends object > (
4742 connectorConfig : ConnectorConfig ,
4843 dcOrVarsOrOptions ?: DataConnect | Variables | OperationOptions ,
4944 varsOrOptions ?: Variables | OperationOptions ,
5045 options ?: OperationOptions ,
5146 hasVars ?: boolean ,
52- validateVars ?: boolean ,
53- ) : ParsedAdminArgs < Variables > {
47+ validateVars ?: boolean
48+ ) : { dc : DataConnect ; vars : Variables ; options : OperationOptions ; } {
5449 let dcInstance : DataConnect ;
5550 let realVars : Variables ;
5651 let realOptions : OperationOptions ;
@@ -76,7 +71,10 @@ export function validateAdminArgs<Variables extends object>(
7671 }
7772
7873 if ( ! dcInstance || ( ! realVars && validateVars ) ) {
79- throw new FirebaseDataConnectError ( DATA_CONNECT_ERROR_CODE_MAPPING . INVALID_ARGUMENT , 'Variables required.' ) ;
74+ throw new FirebaseDataConnectError (
75+ DATA_CONNECT_ERROR_CODE_MAPPING . INVALID_ARGUMENT ,
76+ 'Variables required.'
77+ ) ;
8078 }
8179 return { dc : dcInstance , vars : realVars , options : realOptions } ;
82- }
80+ }
0 commit comments