@firebase/data-connect 0.2.0-canary.2f92a7402 → 0.2.0-canary.313faf66b
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.cjs.js +50 -9
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm2017.js +50 -10
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.node.cjs.js +50 -9
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/internal.d.ts +19 -1
- package/dist/node-esm/index.node.esm.js +50 -10
- package/dist/node-esm/index.node.esm.js.map +1 -1
- package/dist/node-esm/src/api/DataConnect.d.ts +3 -0
- package/dist/node-esm/src/network/fetch.d.ts +2 -1
- package/dist/node-esm/src/network/transport/index.d.ts +15 -1
- package/dist/node-esm/src/network/transport/rest.d.ts +4 -2
- package/dist/private.d.ts +17 -0
- package/dist/public.d.ts +13 -0
- package/dist/src/api/DataConnect.d.ts +3 -0
- package/dist/src/network/fetch.d.ts +2 -1
- package/dist/src/network/transport/index.d.ts +15 -1
- package/dist/src/network/transport/rest.d.ts +4 -2
- package/package.json +7 -7
package/dist/internal.d.ts
CHANGED
|
@@ -42,6 +42,21 @@ declare interface AuthTokenProvider {
|
|
|
42
42
|
addTokenChangeListener(listener: AuthTokenListener): void;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
/**
|
|
46
|
+
* enum representing different flavors of the SDK used by developers
|
|
47
|
+
* use the CallerSdkType for type-checking, and the CallerSdkTypeEnum for value-checking/assigning
|
|
48
|
+
*/
|
|
49
|
+
export declare type CallerSdkType = 'Base' | 'Generated' | 'TanstackReactCore' | 'GeneratedReact' | 'TanstackAngularCore' | 'GeneratedAngular';
|
|
50
|
+
|
|
51
|
+
export declare const CallerSdkTypeEnum: {
|
|
52
|
+
readonly Base: "Base";
|
|
53
|
+
readonly Generated: "Generated";
|
|
54
|
+
readonly TanstackReactCore: "TanstackReactCore";
|
|
55
|
+
readonly GeneratedReact: "GeneratedReact";
|
|
56
|
+
readonly TanstackAngularCore: "TanstackAngularCore";
|
|
57
|
+
readonly GeneratedAngular: "GeneratedAngular";
|
|
58
|
+
};
|
|
59
|
+
|
|
45
60
|
/**
|
|
46
61
|
* Connect to the DataConnect Emulator
|
|
47
62
|
* @param dc Data Connect instance
|
|
@@ -77,9 +92,11 @@ export declare class DataConnect {
|
|
|
77
92
|
private _transportOptions?;
|
|
78
93
|
private _authTokenProvider?;
|
|
79
94
|
_isUsingGeneratedSdk: boolean;
|
|
95
|
+
_callerSdkType: CallerSdkType;
|
|
80
96
|
private _appCheckTokenProvider?;
|
|
81
97
|
constructor(app: FirebaseApp, dataConnectOptions: DataConnectOptions, _authProvider: Provider<FirebaseAuthInternalName>, _appCheckProvider: Provider<AppCheckInternalComponentName>);
|
|
82
98
|
_useGeneratedSdk(): void;
|
|
99
|
+
_setCallerSdkType(callerSdkType: CallerSdkType): void;
|
|
83
100
|
_delete(): Promise<void>;
|
|
84
101
|
getSettings(): ConnectorConfig;
|
|
85
102
|
setInitialized(): void;
|
|
@@ -146,6 +163,7 @@ export declare interface DataConnectTransport {
|
|
|
146
163
|
}>;
|
|
147
164
|
useEmulator(host: string, port?: number, sslEnabled?: boolean): void;
|
|
148
165
|
onTokenChanged: (token: string | null) => void;
|
|
166
|
+
_setCallerSdkType(callerSdkType: CallerSdkType): void;
|
|
149
167
|
}
|
|
150
168
|
|
|
151
169
|
export declare type DataSource = typeof SOURCE_CACHE | typeof SOURCE_SERVER;
|
|
@@ -392,7 +410,7 @@ declare interface TrackedQuery<Data, Variables> {
|
|
|
392
410
|
/**
|
|
393
411
|
* @internal
|
|
394
412
|
*/
|
|
395
|
-
export declare type TransportClass = new (options: DataConnectOptions, apiKey?: string, appId?: string, authProvider?: AuthTokenProvider, appCheckProvider?: AppCheckTokenProvider, transportOptions?: TransportOptions, _isUsingGen?: boolean) => DataConnectTransport;
|
|
413
|
+
export declare type TransportClass = new (options: DataConnectOptions, apiKey?: string, appId?: string, authProvider?: AuthTokenProvider, appCheckProvider?: AppCheckTokenProvider, transportOptions?: TransportOptions, _isUsingGen?: boolean, _callerSdkType?: CallerSdkType) => DataConnectTransport;
|
|
396
414
|
|
|
397
415
|
/**
|
|
398
416
|
* Options to connect to emulator
|
|
@@ -103,6 +103,31 @@ function logError(msg) {
|
|
|
103
103
|
logger.error(`DataConnect (${SDK_VERSION}): ${msg}`);
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
+
/**
|
|
107
|
+
* @license
|
|
108
|
+
* Copyright 2024 Google LLC
|
|
109
|
+
*
|
|
110
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
111
|
+
* you may not use this file except in compliance with the License.
|
|
112
|
+
* You may obtain a copy of the License at
|
|
113
|
+
*
|
|
114
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
115
|
+
*
|
|
116
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
117
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
118
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
119
|
+
* See the License for the specific language governing permissions and
|
|
120
|
+
* limitations under the License.
|
|
121
|
+
*/
|
|
122
|
+
const CallerSdkTypeEnum = {
|
|
123
|
+
Base: 'Base', // Core JS SDK
|
|
124
|
+
Generated: 'Generated', // Generated JS SDK
|
|
125
|
+
TanstackReactCore: 'TanstackReactCore', // Tanstack non-generated React SDK
|
|
126
|
+
GeneratedReact: 'GeneratedReact', // Tanstack non-generated Angular SDK
|
|
127
|
+
TanstackAngularCore: 'TanstackAngularCore', // Tanstack non-generated Angular SDK
|
|
128
|
+
GeneratedAngular: 'GeneratedAngular' // Generated Angular SDK
|
|
129
|
+
};
|
|
130
|
+
|
|
106
131
|
/**
|
|
107
132
|
* @license
|
|
108
133
|
* Copyright 2024 Google LLC
|
|
@@ -123,20 +148,24 @@ let connectFetch = globalThis.fetch;
|
|
|
123
148
|
function initializeFetch(fetchImpl) {
|
|
124
149
|
connectFetch = fetchImpl;
|
|
125
150
|
}
|
|
126
|
-
function getGoogApiClientValue(_isUsingGen) {
|
|
151
|
+
function getGoogApiClientValue(_isUsingGen, _callerSdkType) {
|
|
127
152
|
let str = 'gl-js/ fire/' + SDK_VERSION;
|
|
128
|
-
if (
|
|
153
|
+
if (_callerSdkType !== CallerSdkTypeEnum.Base &&
|
|
154
|
+
_callerSdkType !== CallerSdkTypeEnum.Generated) {
|
|
155
|
+
str += ' js/' + _callerSdkType.toLowerCase();
|
|
156
|
+
}
|
|
157
|
+
else if (_isUsingGen || _callerSdkType === CallerSdkTypeEnum.Generated) {
|
|
129
158
|
str += ' js/gen';
|
|
130
159
|
}
|
|
131
160
|
return str;
|
|
132
161
|
}
|
|
133
|
-
function dcFetch(url, body, { signal }, appId, accessToken, appCheckToken, _isUsingGen) {
|
|
162
|
+
function dcFetch(url, body, { signal }, appId, accessToken, appCheckToken, _isUsingGen, _callerSdkType) {
|
|
134
163
|
if (!connectFetch) {
|
|
135
164
|
throw new DataConnectError(Code.OTHER, 'No Fetch Implementation detected!');
|
|
136
165
|
}
|
|
137
166
|
const headers = {
|
|
138
167
|
'Content-Type': 'application/json',
|
|
139
|
-
'X-Goog-Api-Client': getGoogApiClientValue(_isUsingGen)
|
|
168
|
+
'X-Goog-Api-Client': getGoogApiClientValue(_isUsingGen, _callerSdkType)
|
|
140
169
|
};
|
|
141
170
|
if (accessToken) {
|
|
142
171
|
headers['X-Firebase-Auth-Token'] = accessToken;
|
|
@@ -193,7 +222,7 @@ function getMessage(obj) {
|
|
|
193
222
|
}
|
|
194
223
|
|
|
195
224
|
const name = "@firebase/data-connect";
|
|
196
|
-
const version = "0.2.0-canary.
|
|
225
|
+
const version = "0.2.0-canary.313faf66b";
|
|
197
226
|
|
|
198
227
|
/**
|
|
199
228
|
* @license
|
|
@@ -585,13 +614,14 @@ function addToken(url, apiKey) {
|
|
|
585
614
|
* limitations under the License.
|
|
586
615
|
*/
|
|
587
616
|
class RESTTransport {
|
|
588
|
-
constructor(options, apiKey, appId, authProvider, appCheckProvider, transportOptions, _isUsingGen = false) {
|
|
617
|
+
constructor(options, apiKey, appId, authProvider, appCheckProvider, transportOptions, _isUsingGen = false, _callerSdkType = CallerSdkTypeEnum.Base) {
|
|
589
618
|
var _a, _b;
|
|
590
619
|
this.apiKey = apiKey;
|
|
591
620
|
this.appId = appId;
|
|
592
621
|
this.authProvider = authProvider;
|
|
593
622
|
this.appCheckProvider = appCheckProvider;
|
|
594
623
|
this._isUsingGen = _isUsingGen;
|
|
624
|
+
this._callerSdkType = _callerSdkType;
|
|
595
625
|
this._host = '';
|
|
596
626
|
this._location = 'l';
|
|
597
627
|
this._connectorName = '';
|
|
@@ -608,7 +638,7 @@ class RESTTransport {
|
|
|
608
638
|
name: `projects/${this._project}/locations/${this._location}/services/${this._serviceName}/connectors/${this._connectorName}`,
|
|
609
639
|
operationName: queryName,
|
|
610
640
|
variables: body
|
|
611
|
-
}, abortController, this.appId, this._accessToken, this._appCheckToken, this._isUsingGen));
|
|
641
|
+
}, abortController, this.appId, this._accessToken, this._appCheckToken, this._isUsingGen, this._callerSdkType));
|
|
612
642
|
return withAuth;
|
|
613
643
|
};
|
|
614
644
|
this.invokeMutation = (mutationName, body) => {
|
|
@@ -618,7 +648,7 @@ class RESTTransport {
|
|
|
618
648
|
name: `projects/${this._project}/locations/${this._location}/services/${this._serviceName}/connectors/${this._connectorName}`,
|
|
619
649
|
operationName: mutationName,
|
|
620
650
|
variables: body
|
|
621
|
-
}, abortController, this.appId, this._accessToken, this._appCheckToken, this._isUsingGen);
|
|
651
|
+
}, abortController, this.appId, this._accessToken, this._appCheckToken, this._isUsingGen, this._callerSdkType);
|
|
622
652
|
});
|
|
623
653
|
return taskResult;
|
|
624
654
|
};
|
|
@@ -719,6 +749,9 @@ class RESTTransport {
|
|
|
719
749
|
throw err;
|
|
720
750
|
});
|
|
721
751
|
}
|
|
752
|
+
_setCallerSdkType(callerSdkType) {
|
|
753
|
+
this._callerSdkType = callerSdkType;
|
|
754
|
+
}
|
|
722
755
|
}
|
|
723
756
|
|
|
724
757
|
/**
|
|
@@ -828,6 +861,7 @@ class DataConnect {
|
|
|
828
861
|
this.isEmulator = false;
|
|
829
862
|
this._initialized = false;
|
|
830
863
|
this._isUsingGeneratedSdk = false;
|
|
864
|
+
this._callerSdkType = CallerSdkTypeEnum.Base;
|
|
831
865
|
if (typeof process !== 'undefined' && process.env) {
|
|
832
866
|
const host = process.env[FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR];
|
|
833
867
|
if (host) {
|
|
@@ -843,6 +877,12 @@ class DataConnect {
|
|
|
843
877
|
this._isUsingGeneratedSdk = true;
|
|
844
878
|
}
|
|
845
879
|
}
|
|
880
|
+
_setCallerSdkType(callerSdkType) {
|
|
881
|
+
this._callerSdkType = callerSdkType;
|
|
882
|
+
if (this._initialized) {
|
|
883
|
+
this._transport._setCallerSdkType(callerSdkType);
|
|
884
|
+
}
|
|
885
|
+
}
|
|
846
886
|
_delete() {
|
|
847
887
|
_removeServiceInstance(this.app, 'data-connect', JSON.stringify(this.getSettings()));
|
|
848
888
|
return Promise.resolve();
|
|
@@ -869,7 +909,7 @@ class DataConnect {
|
|
|
869
909
|
this._appCheckTokenProvider = new AppCheckTokenProvider(this.app, this._appCheckProvider);
|
|
870
910
|
}
|
|
871
911
|
this._initialized = true;
|
|
872
|
-
this._transport = new this._transportClass(this.dataConnectOptions, this.app.options.apiKey, this.app.options.appId, this._authTokenProvider, this._appCheckTokenProvider, undefined, this._isUsingGeneratedSdk);
|
|
912
|
+
this._transport = new this._transportClass(this.dataConnectOptions, this.app.options.apiKey, this.app.options.appId, this._authTokenProvider, this._appCheckTokenProvider, undefined, this._isUsingGeneratedSdk, this._callerSdkType);
|
|
873
913
|
if (this._transportOptions) {
|
|
874
914
|
this._transport.useEmulator(this._transportOptions.host, this._transportOptions.port, this._transportOptions.sslEnabled);
|
|
875
915
|
}
|
|
@@ -1174,5 +1214,5 @@ function subscribe(queryRefOrSerializedResult, observerOrOnNext, onError, onComp
|
|
|
1174
1214
|
initializeFetch(fetch);
|
|
1175
1215
|
registerDataConnect('node');
|
|
1176
1216
|
|
|
1177
|
-
export { DataConnect, MUTATION_STR, MutationManager, QUERY_STR, SOURCE_CACHE, SOURCE_SERVER, areTransportOptionsEqual, connectDataConnectEmulator, executeMutation, executeQuery, getDataConnect, mutationRef, parseOptions, queryRef, setLogLevel, subscribe, terminate, toQueryRef, validateArgs, validateDCOptions };
|
|
1217
|
+
export { CallerSdkTypeEnum, DataConnect, MUTATION_STR, MutationManager, QUERY_STR, SOURCE_CACHE, SOURCE_SERVER, areTransportOptionsEqual, connectDataConnectEmulator, executeMutation, executeQuery, getDataConnect, mutationRef, parseOptions, queryRef, setLogLevel, subscribe, terminate, toQueryRef, validateArgs, validateDCOptions };
|
|
1178
1218
|
//# sourceMappingURL=index.node.esm.js.map
|