@firebase/data-connect 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -342,6 +342,9 @@ export declare function executeMutation<Data, Variables>(mutationRef: MutationRe
342
342
  */
343
343
  export declare function executeQuery<Data, Variables>(queryRef: QueryRef<Data, Variables>, options?: ExecuteQueryOptions): QueryPromise<Data, Variables>;
344
344
 
345
+ /**
346
+ * Options for executing a query.
347
+ */
345
348
  export declare interface ExecuteQueryOptions {
346
349
  fetchPolicy: QueryFetchPolicy;
347
350
  }
@@ -512,6 +515,7 @@ export declare interface OpResult<Data> {
512
515
  declare interface ParsedArgs<Variables> {
513
516
  dc: DataConnect;
514
517
  vars: Variables;
518
+ options?: ExecuteQueryOptions;
515
519
  }
516
520
 
517
521
  /**
@@ -726,16 +730,39 @@ export declare interface TransportOptions {
726
730
  }
727
731
 
728
732
  /**
729
- * The generated SDK will allow the user to pass in either the variable or the data connect instance with the variable,
730
- * and this function validates the variables and returns back the DataConnect instance and variables based on the arguments passed in.
733
+ * The generated SDK will allow the user to pass in either the variables or the data connect instance
734
+ * with the variables. This function validates the variables and returns back the DataConnect instance
735
+ * and variables based on the arguments passed in.
736
+ *
737
+ * Generated SDKs generated from versions 3.2.0 and lower of the Data Connect emulator binary are
738
+ * NOT concerned with options, and will use this function to validate arguments.
739
+ *
731
740
  * @param connectorConfig
732
741
  * @param dcOrVars
733
742
  * @param vars
734
- * @param validateVars
743
+ * @param variablesRequired
735
744
  * @returns {DataConnect} and {Variables} instance
736
745
  * @internal
737
746
  */
738
- export declare function validateArgs<Variables extends object>(connectorConfig: ConnectorConfig, dcOrVars?: DataConnect | Variables, vars?: Variables, validateVars?: boolean): ParsedArgs<Variables>;
747
+ export declare function validateArgs<Variables extends object>(connectorConfig: ConnectorConfig, dcOrVars?: DataConnect | Variables, vars?: Variables, variablesRequired?: boolean): ParsedArgs<Variables>;
748
+
749
+ /**
750
+ * The generated SDK will allow the user to pass in either the variables or the data connect instance
751
+ * with the variables, and/or options. This function validates the variables and returns back the
752
+ * DataConnect instance and variables, and potentially options, based on the arguments passed in.
753
+ *
754
+ * Generated SDKs generated from versions 3.2.0 and higher of the Data Connect emulator binary are
755
+ * in fact concerned with options, and will use this function to validate arguments.
756
+ *
757
+ * @param connectorConfig
758
+ * @param dcOrVarsOrOptions
759
+ * @param varsOrOptions
760
+ * @param variablesRequired
761
+ * @param options
762
+ * @returns {DataConnect} and {Variables} instance, and optionally {ExecuteQueryOptions}
763
+ * @internal
764
+ */
765
+ export declare function validateArgsWithOptions<Variables extends object>(connectorConfig: ConnectorConfig, dcOrVarsOrOptions?: DataConnect | Variables | ExecuteQueryOptions, varsOrOptions?: Variables | ExecuteQueryOptions, options?: ExecuteQueryOptions, hasVars?: boolean, variablesRequired?: boolean): ParsedArgs<Variables>;
739
766
 
740
767
  /**
741
768
  *
@@ -1,4 +1,4 @@
1
- import { FirebaseError, isCloudWorkstation, generateSHA256Hash, pingServer, updateEmulatorBanner } from '@firebase/util';
1
+ import { FirebaseError, isCloudWorkstation, generateSHA256Hash, pingServer } from '@firebase/util';
2
2
  import { Logger } from '@firebase/logger';
3
3
  import { _isFirebaseServerApp, _removeServiceInstance, getApp, _getProvider, _registerComponent, registerVersion, SDK_VERSION as SDK_VERSION$1 } from '@firebase/app';
4
4
  import { Component } from '@firebase/component';
@@ -236,7 +236,7 @@ function getErrorMessage(obj) {
236
236
  }
237
237
 
238
238
  const name = "@firebase/data-connect";
239
- const version = "0.4.0";
239
+ const version = "0.5.0";
240
240
 
241
241
  /**
242
242
  * @license
@@ -1714,7 +1714,6 @@ function connectDataConnectEmulator(dc, host, port, sslEnabled = false) {
1714
1714
  // Workaround to get cookies in Firebase Studio
1715
1715
  if (isCloudWorkstation(host)) {
1716
1716
  void pingServer(`https://${host}${port ? `:${port}` : ''}`);
1717
- updateEmulatorBanner('Data Connect', true);
1718
1717
  }
1719
1718
  dc.enableEmulator({ host, port, sslEnabled });
1720
1719
  }
@@ -1948,19 +1947,25 @@ function toQueryRef(serializedRef) {
1948
1947
  * limitations under the License.
1949
1948
  */
1950
1949
  /**
1951
- * The generated SDK will allow the user to pass in either the variable or the data connect instance with the variable,
1952
- * and this function validates the variables and returns back the DataConnect instance and variables based on the arguments passed in.
1950
+ * The generated SDK will allow the user to pass in either the variables or the data connect instance
1951
+ * with the variables. This function validates the variables and returns back the DataConnect instance
1952
+ * and variables based on the arguments passed in.
1953
+ *
1954
+ * Generated SDKs generated from versions 3.2.0 and lower of the Data Connect emulator binary are
1955
+ * NOT concerned with options, and will use this function to validate arguments.
1956
+ *
1953
1957
  * @param connectorConfig
1954
1958
  * @param dcOrVars
1955
1959
  * @param vars
1956
- * @param validateVars
1960
+ * @param variablesRequired
1957
1961
  * @returns {DataConnect} and {Variables} instance
1958
1962
  * @internal
1959
1963
  */
1960
- function validateArgs(connectorConfig, dcOrVars, vars, validateVars) {
1964
+ function validateArgs(connectorConfig, dcOrVars, vars, variablesRequired) {
1961
1965
  let dcInstance;
1962
1966
  let realVars;
1963
- if (dcOrVars && 'enableEmulator' in dcOrVars) {
1967
+ const dcFirstArg = dcOrVars && 'enableEmulator' in dcOrVars;
1968
+ if (dcFirstArg) {
1964
1969
  dcInstance = dcOrVars;
1965
1970
  realVars = vars;
1966
1971
  }
@@ -1968,11 +1973,59 @@ function validateArgs(connectorConfig, dcOrVars, vars, validateVars) {
1968
1973
  dcInstance = getDataConnect(connectorConfig);
1969
1974
  realVars = dcOrVars;
1970
1975
  }
1971
- if (!dcInstance || (!realVars && validateVars)) {
1976
+ if (!dcInstance || (!realVars && variablesRequired)) {
1972
1977
  throw new DataConnectError(Code.INVALID_ARGUMENT, 'Variables required.');
1973
1978
  }
1974
1979
  return { dc: dcInstance, vars: realVars };
1975
1980
  }
1981
+ /**
1982
+ * The generated SDK will allow the user to pass in either the variables or the data connect instance
1983
+ * with the variables, and/or options. This function validates the variables and returns back the
1984
+ * DataConnect instance and variables, and potentially options, based on the arguments passed in.
1985
+ *
1986
+ * Generated SDKs generated from versions 3.2.0 and higher of the Data Connect emulator binary are
1987
+ * in fact concerned with options, and will use this function to validate arguments.
1988
+ *
1989
+ * @param connectorConfig
1990
+ * @param dcOrVarsOrOptions
1991
+ * @param varsOrOptions
1992
+ * @param variablesRequired
1993
+ * @param options
1994
+ * @returns {DataConnect} and {Variables} instance, and optionally {ExecuteQueryOptions}
1995
+ * @internal
1996
+ */
1997
+ function validateArgsWithOptions(connectorConfig, dcOrVarsOrOptions, varsOrOptions, options, hasVars, variablesRequired) {
1998
+ let dcInstance;
1999
+ let realVars;
2000
+ let realOptions;
2001
+ const dcFirstArg = dcOrVarsOrOptions && 'enableEmulator' in dcOrVarsOrOptions;
2002
+ if (dcFirstArg) {
2003
+ dcInstance = dcOrVarsOrOptions;
2004
+ if (hasVars) {
2005
+ realVars = varsOrOptions;
2006
+ realOptions = options;
2007
+ }
2008
+ else {
2009
+ realVars = undefined;
2010
+ realOptions = varsOrOptions;
2011
+ }
2012
+ }
2013
+ else {
2014
+ dcInstance = getDataConnect(connectorConfig);
2015
+ if (hasVars) {
2016
+ realVars = dcOrVarsOrOptions;
2017
+ realOptions = varsOrOptions;
2018
+ }
2019
+ else {
2020
+ realVars = undefined;
2021
+ realOptions = dcOrVarsOrOptions;
2022
+ }
2023
+ }
2024
+ if (!dcInstance || (!realVars && variablesRequired)) {
2025
+ throw new DataConnectError(Code.INVALID_ARGUMENT, 'Variables required.');
2026
+ }
2027
+ return { dc: dcInstance, vars: realVars, options: realOptions };
2028
+ }
1976
2029
 
1977
2030
  /**
1978
2031
  * @license
@@ -2050,5 +2103,5 @@ function subscribe(queryRefOrSerializedResult, observerOrOnNext, onError, onComp
2050
2103
  initializeFetch(fetch);
2051
2104
  registerDataConnect('node');
2052
2105
 
2053
- export { CallerSdkTypeEnum, Code, DataConnect, DataConnectError, DataConnectOperationError, MUTATION_STR, MutationManager, QUERY_STR, QueryFetchPolicy, SOURCE_CACHE, SOURCE_SERVER, StorageType, areTransportOptionsEqual, connectDataConnectEmulator, executeMutation, executeQuery, getDataConnect, makeMemoryCacheProvider, mutationRef, parseOptions, queryRef, setLogLevel, subscribe, terminate, toQueryRef, validateArgs, validateDCOptions };
2106
+ export { CallerSdkTypeEnum, Code, DataConnect, DataConnectError, DataConnectOperationError, MUTATION_STR, MutationManager, QUERY_STR, QueryFetchPolicy, SOURCE_CACHE, SOURCE_SERVER, StorageType, areTransportOptionsEqual, connectDataConnectEmulator, executeMutation, executeQuery, getDataConnect, makeMemoryCacheProvider, mutationRef, parseOptions, queryRef, setLogLevel, subscribe, terminate, toQueryRef, validateArgs, validateArgsWithOptions, validateDCOptions };
2054
2107
  //# sourceMappingURL=index.node.esm.js.map