@firebase/data-connect 0.4.0 → 0.5.0-canary.44ad4cc2e

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.
package/dist/index.esm.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { _isFirebaseServerApp, _removeServiceInstance, getApp, _getProvider, _registerComponent, registerVersion, SDK_VERSION as SDK_VERSION$1 } from '@firebase/app';
2
2
  import { Component } from '@firebase/component';
3
- import { FirebaseError, generateSHA256Hash, isCloudWorkstation, pingServer, updateEmulatorBanner } from '@firebase/util';
3
+ import { FirebaseError, generateSHA256Hash, isCloudWorkstation, pingServer } from '@firebase/util';
4
4
  import { Logger } from '@firebase/logger';
5
5
 
6
6
  const name = "@firebase/data-connect";
7
- const version = "0.4.0";
7
+ const version = "0.5.0-canary.44ad4cc2e";
8
8
 
9
9
  /**
10
10
  * @license
@@ -1711,7 +1711,6 @@ function connectDataConnectEmulator(dc, host, port, sslEnabled = false) {
1711
1711
  // Workaround to get cookies in Firebase Studio
1712
1712
  if (isCloudWorkstation(host)) {
1713
1713
  void pingServer(`https://${host}${port ? `:${port}` : ''}`);
1714
- updateEmulatorBanner('Data Connect', true);
1715
1714
  }
1716
1715
  dc.enableEmulator({ host, port, sslEnabled });
1717
1716
  }
@@ -1945,19 +1944,25 @@ function toQueryRef(serializedRef) {
1945
1944
  * limitations under the License.
1946
1945
  */
1947
1946
  /**
1948
- * The generated SDK will allow the user to pass in either the variable or the data connect instance with the variable,
1949
- * and this function validates the variables and returns back the DataConnect instance and variables based on the arguments passed in.
1947
+ * The generated SDK will allow the user to pass in either the variables or the data connect instance
1948
+ * with the variables. This function validates the variables and returns back the DataConnect instance
1949
+ * and variables based on the arguments passed in.
1950
+ *
1951
+ * Generated SDKs generated from versions 3.2.0 and lower of the Data Connect emulator binary are
1952
+ * NOT concerned with options, and will use this function to validate arguments.
1953
+ *
1950
1954
  * @param connectorConfig
1951
1955
  * @param dcOrVars
1952
1956
  * @param vars
1953
- * @param validateVars
1957
+ * @param variablesRequired
1954
1958
  * @returns {DataConnect} and {Variables} instance
1955
1959
  * @internal
1956
1960
  */
1957
- function validateArgs(connectorConfig, dcOrVars, vars, validateVars) {
1961
+ function validateArgs(connectorConfig, dcOrVars, vars, variablesRequired) {
1958
1962
  let dcInstance;
1959
1963
  let realVars;
1960
- if (dcOrVars && 'enableEmulator' in dcOrVars) {
1964
+ const dcFirstArg = dcOrVars && 'enableEmulator' in dcOrVars;
1965
+ if (dcFirstArg) {
1961
1966
  dcInstance = dcOrVars;
1962
1967
  realVars = vars;
1963
1968
  }
@@ -1965,11 +1970,59 @@ function validateArgs(connectorConfig, dcOrVars, vars, validateVars) {
1965
1970
  dcInstance = getDataConnect(connectorConfig);
1966
1971
  realVars = dcOrVars;
1967
1972
  }
1968
- if (!dcInstance || (!realVars && validateVars)) {
1973
+ if (!dcInstance || (!realVars && variablesRequired)) {
1969
1974
  throw new DataConnectError(Code.INVALID_ARGUMENT, 'Variables required.');
1970
1975
  }
1971
1976
  return { dc: dcInstance, vars: realVars };
1972
1977
  }
1978
+ /**
1979
+ * The generated SDK will allow the user to pass in either the variables or the data connect instance
1980
+ * with the variables, and/or options. This function validates the variables and returns back the
1981
+ * DataConnect instance and variables, and potentially options, based on the arguments passed in.
1982
+ *
1983
+ * Generated SDKs generated from versions 3.2.0 and higher of the Data Connect emulator binary are
1984
+ * in fact concerned with options, and will use this function to validate arguments.
1985
+ *
1986
+ * @param connectorConfig
1987
+ * @param dcOrVarsOrOptions
1988
+ * @param varsOrOptions
1989
+ * @param variablesRequired
1990
+ * @param options
1991
+ * @returns {DataConnect} and {Variables} instance, and optionally {ExecuteQueryOptions}
1992
+ * @internal
1993
+ */
1994
+ function validateArgsWithOptions(connectorConfig, dcOrVarsOrOptions, varsOrOptions, options, hasVars, variablesRequired) {
1995
+ let dcInstance;
1996
+ let realVars;
1997
+ let realOptions;
1998
+ const dcFirstArg = dcOrVarsOrOptions && 'enableEmulator' in dcOrVarsOrOptions;
1999
+ if (dcFirstArg) {
2000
+ dcInstance = dcOrVarsOrOptions;
2001
+ if (hasVars) {
2002
+ realVars = varsOrOptions;
2003
+ realOptions = options;
2004
+ }
2005
+ else {
2006
+ realVars = undefined;
2007
+ realOptions = varsOrOptions;
2008
+ }
2009
+ }
2010
+ else {
2011
+ dcInstance = getDataConnect(connectorConfig);
2012
+ if (hasVars) {
2013
+ realVars = dcOrVarsOrOptions;
2014
+ realOptions = varsOrOptions;
2015
+ }
2016
+ else {
2017
+ realVars = undefined;
2018
+ realOptions = dcOrVarsOrOptions;
2019
+ }
2020
+ }
2021
+ if (!dcInstance || (!realVars && variablesRequired)) {
2022
+ throw new DataConnectError(Code.INVALID_ARGUMENT, 'Variables required.');
2023
+ }
2024
+ return { dc: dcInstance, vars: realVars, options: realOptions };
2025
+ }
1973
2026
 
1974
2027
  /**
1975
2028
  * @license
@@ -2035,5 +2088,5 @@ function subscribe(queryRefOrSerializedResult, observerOrOnNext, onError, onComp
2035
2088
  */
2036
2089
  registerDataConnect();
2037
2090
 
2038
- 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 };
2091
+ 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 };
2039
2092
  //# sourceMappingURL=index.esm.js.map