@firebase/data-connect 0.3.2 → 0.3.3-auth-redirect-credentials.82faa0828
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 +41 -25
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm2017.js +40 -27
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.node.cjs.js +41 -25
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/internal.d.ts +38 -21
- package/dist/node-esm/index.node.esm.js +40 -27
- package/dist/node-esm/index.node.esm.js.map +1 -1
- package/dist/node-esm/src/api/index.d.ts +1 -0
- package/dist/node-esm/src/core/error.d.ts +21 -19
- package/dist/node-esm/src/network/fetch.d.ts +1 -1
- package/dist/node-esm/src/network/transport/rest.d.ts +1 -0
- package/dist/private.d.ts +35 -21
- package/dist/public.d.ts +33 -2
- package/dist/src/api/index.d.ts +1 -0
- package/dist/src/core/error.d.ts +21 -19
- package/dist/src/network/fetch.d.ts +1 -1
- package/dist/src/network/transport/rest.d.ts +1 -0
- package/package.json +7 -7
package/dist/internal.d.ts
CHANGED
|
@@ -57,6 +57,18 @@ export declare const CallerSdkTypeEnum: {
|
|
|
57
57
|
readonly GeneratedAngular: "GeneratedAngular";
|
|
58
58
|
};
|
|
59
59
|
|
|
60
|
+
export declare type Code = DataConnectErrorCode;
|
|
61
|
+
|
|
62
|
+
export declare const Code: {
|
|
63
|
+
OTHER: DataConnectErrorCode;
|
|
64
|
+
ALREADY_INITIALIZED: DataConnectErrorCode;
|
|
65
|
+
NOT_INITIALIZED: DataConnectErrorCode;
|
|
66
|
+
NOT_SUPPORTED: DataConnectErrorCode;
|
|
67
|
+
INVALID_ARGUMENT: DataConnectErrorCode;
|
|
68
|
+
PARTIAL_ERROR: DataConnectErrorCode;
|
|
69
|
+
UNAUTHORIZED: DataConnectErrorCode;
|
|
70
|
+
};
|
|
71
|
+
|
|
60
72
|
/**
|
|
61
73
|
* Connect to the DataConnect Emulator
|
|
62
74
|
* @param dc Data Connect instance
|
|
@@ -104,30 +116,35 @@ export declare class DataConnect {
|
|
|
104
116
|
}
|
|
105
117
|
|
|
106
118
|
/** An error returned by a DataConnect operation. */
|
|
107
|
-
declare class DataConnectError extends FirebaseError {
|
|
108
|
-
/**
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
119
|
+
export declare class DataConnectError extends FirebaseError {
|
|
120
|
+
/** @internal */
|
|
121
|
+
readonly name: string;
|
|
122
|
+
constructor(code: Code, message: string);
|
|
123
|
+
/** @internal */
|
|
124
|
+
toString(): string;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export declare type DataConnectErrorCode = 'other' | 'already-initialized' | 'not-initialized' | 'not-supported' | 'invalid-argument' | 'partial-error' | 'unauthorized';
|
|
128
|
+
|
|
129
|
+
/** An error returned by a DataConnect operation. */
|
|
130
|
+
export declare class DataConnectOperationError extends DataConnectError {
|
|
131
|
+
/** @internal */
|
|
132
|
+
readonly name: string;
|
|
133
|
+
/** The response received from the backend. */
|
|
134
|
+
readonly response: DataConnectOperationFailureResponse;
|
|
118
135
|
/** @hideconstructor */
|
|
119
|
-
constructor(
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
* A custom error description.
|
|
126
|
-
*/
|
|
127
|
-
message: string);
|
|
136
|
+
constructor(message: string, response: DataConnectOperationFailureResponse);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export declare interface DataConnectOperationFailureResponse {
|
|
140
|
+
readonly data?: Record<string, unknown> | null;
|
|
141
|
+
readonly errors: DataConnectOperationFailureResponseErrorInfo[];
|
|
128
142
|
}
|
|
129
143
|
|
|
130
|
-
declare
|
|
144
|
+
export declare interface DataConnectOperationFailureResponseErrorInfo {
|
|
145
|
+
readonly message: string;
|
|
146
|
+
readonly path: Array<string | number>;
|
|
147
|
+
}
|
|
131
148
|
|
|
132
149
|
/**
|
|
133
150
|
* DataConnectOptions including project id
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FirebaseError } from '@firebase/util';
|
|
1
|
+
import { FirebaseError, isCloudWorkstation } 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';
|
|
@@ -30,23 +30,28 @@ const Code = {
|
|
|
30
30
|
};
|
|
31
31
|
/** An error returned by a DataConnect operation. */
|
|
32
32
|
class DataConnectError extends FirebaseError {
|
|
33
|
-
|
|
34
|
-
constructor(
|
|
35
|
-
/**
|
|
36
|
-
* The backend error code associated with this error.
|
|
37
|
-
*/
|
|
38
|
-
code,
|
|
39
|
-
/**
|
|
40
|
-
* A custom error description.
|
|
41
|
-
*/
|
|
42
|
-
message) {
|
|
33
|
+
constructor(code, message) {
|
|
43
34
|
super(code, message);
|
|
44
|
-
|
|
45
|
-
this.
|
|
46
|
-
//
|
|
47
|
-
//
|
|
48
|
-
//
|
|
49
|
-
|
|
35
|
+
/** @internal */
|
|
36
|
+
this.name = 'DataConnectError';
|
|
37
|
+
// Ensure the instanceof operator works as expected on subclasses of Error.
|
|
38
|
+
// See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error#custom_error_types
|
|
39
|
+
// and https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-2.html#support-for-newtarget
|
|
40
|
+
Object.setPrototypeOf(this, DataConnectError.prototype);
|
|
41
|
+
}
|
|
42
|
+
/** @internal */
|
|
43
|
+
toString() {
|
|
44
|
+
return `${this.name}[code=${this.code}]: ${this.message}`;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/** An error returned by a DataConnect operation. */
|
|
48
|
+
class DataConnectOperationError extends DataConnectError {
|
|
49
|
+
/** @hideconstructor */
|
|
50
|
+
constructor(message, response) {
|
|
51
|
+
super(Code.PARTIAL_ERROR, message);
|
|
52
|
+
/** @internal */
|
|
53
|
+
this.name = 'DataConnectOperationError';
|
|
54
|
+
this.response = response;
|
|
50
55
|
}
|
|
51
56
|
}
|
|
52
57
|
|
|
@@ -159,7 +164,7 @@ function getGoogApiClientValue(_isUsingGen, _callerSdkType) {
|
|
|
159
164
|
}
|
|
160
165
|
return str;
|
|
161
166
|
}
|
|
162
|
-
function dcFetch(url, body, { signal }, appId, accessToken, appCheckToken, _isUsingGen, _callerSdkType) {
|
|
167
|
+
function dcFetch(url, body, { signal }, appId, accessToken, appCheckToken, _isUsingGen, _callerSdkType, _isUsingEmulator) {
|
|
163
168
|
if (!connectFetch) {
|
|
164
169
|
throw new DataConnectError(Code.OTHER, 'No Fetch Implementation detected!');
|
|
165
170
|
}
|
|
@@ -177,13 +182,16 @@ function dcFetch(url, body, { signal }, appId, accessToken, appCheckToken, _isUs
|
|
|
177
182
|
headers['X-Firebase-AppCheck'] = appCheckToken;
|
|
178
183
|
}
|
|
179
184
|
const bodyStr = JSON.stringify(body);
|
|
180
|
-
|
|
181
|
-
return connectFetch(url, {
|
|
185
|
+
const fetchOptions = {
|
|
182
186
|
body: bodyStr,
|
|
183
187
|
method: 'POST',
|
|
184
188
|
headers,
|
|
185
189
|
signal
|
|
186
|
-
}
|
|
190
|
+
};
|
|
191
|
+
if (isCloudWorkstation(url) && _isUsingEmulator) {
|
|
192
|
+
fetchOptions.credentials = 'include';
|
|
193
|
+
}
|
|
194
|
+
return connectFetch(url, fetchOptions)
|
|
187
195
|
.catch(err => {
|
|
188
196
|
throw new DataConnectError(Code.OTHER, 'Failed to fetch: ' + JSON.stringify(err));
|
|
189
197
|
})
|
|
@@ -208,8 +216,11 @@ function dcFetch(url, body, { signal }, appId, accessToken, appCheckToken, _isUs
|
|
|
208
216
|
.then(res => {
|
|
209
217
|
if (res.errors && res.errors.length) {
|
|
210
218
|
const stringified = JSON.stringify(res.errors);
|
|
211
|
-
|
|
212
|
-
|
|
219
|
+
const response = {
|
|
220
|
+
errors: res.errors,
|
|
221
|
+
data: res.data
|
|
222
|
+
};
|
|
223
|
+
throw new DataConnectOperationError('DataConnect error while performing request: ' + stringified, response);
|
|
213
224
|
}
|
|
214
225
|
return res;
|
|
215
226
|
});
|
|
@@ -222,7 +233,7 @@ function getMessage(obj) {
|
|
|
222
233
|
}
|
|
223
234
|
|
|
224
235
|
const name = "@firebase/data-connect";
|
|
225
|
-
const version = "0.3.
|
|
236
|
+
const version = "0.3.3-auth-redirect-credentials.82faa0828";
|
|
226
237
|
|
|
227
238
|
/**
|
|
228
239
|
* @license
|
|
@@ -630,6 +641,7 @@ class RESTTransport {
|
|
|
630
641
|
this._accessToken = null;
|
|
631
642
|
this._appCheckToken = null;
|
|
632
643
|
this._lastToken = null;
|
|
644
|
+
this._isUsingEmulator = false;
|
|
633
645
|
// TODO(mtewani): Update U to include shape of body defined in line 13.
|
|
634
646
|
this.invokeQuery = (queryName, body) => {
|
|
635
647
|
const abortController = new AbortController();
|
|
@@ -638,7 +650,7 @@ class RESTTransport {
|
|
|
638
650
|
name: `projects/${this._project}/locations/${this._location}/services/${this._serviceName}/connectors/${this._connectorName}`,
|
|
639
651
|
operationName: queryName,
|
|
640
652
|
variables: body
|
|
641
|
-
}, abortController, this.appId, this._accessToken, this._appCheckToken, this._isUsingGen, this._callerSdkType));
|
|
653
|
+
}, abortController, this.appId, this._accessToken, this._appCheckToken, this._isUsingGen, this._callerSdkType, this._isUsingEmulator));
|
|
642
654
|
return withAuth;
|
|
643
655
|
};
|
|
644
656
|
this.invokeMutation = (mutationName, body) => {
|
|
@@ -648,7 +660,7 @@ class RESTTransport {
|
|
|
648
660
|
name: `projects/${this._project}/locations/${this._location}/services/${this._serviceName}/connectors/${this._connectorName}`,
|
|
649
661
|
operationName: mutationName,
|
|
650
662
|
variables: body
|
|
651
|
-
}, abortController, this.appId, this._accessToken, this._appCheckToken, this._isUsingGen, this._callerSdkType);
|
|
663
|
+
}, abortController, this.appId, this._accessToken, this._appCheckToken, this._isUsingGen, this._callerSdkType, this._isUsingEmulator);
|
|
652
664
|
});
|
|
653
665
|
return taskResult;
|
|
654
666
|
};
|
|
@@ -693,6 +705,7 @@ class RESTTransport {
|
|
|
693
705
|
}
|
|
694
706
|
useEmulator(host, port, isSecure) {
|
|
695
707
|
this._host = host;
|
|
708
|
+
this._isUsingEmulator = true;
|
|
696
709
|
if (typeof port === 'number') {
|
|
697
710
|
this._port = port;
|
|
698
711
|
}
|
|
@@ -1214,5 +1227,5 @@ function subscribe(queryRefOrSerializedResult, observerOrOnNext, onError, onComp
|
|
|
1214
1227
|
initializeFetch(fetch);
|
|
1215
1228
|
registerDataConnect('node');
|
|
1216
1229
|
|
|
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 };
|
|
1230
|
+
export { CallerSdkTypeEnum, Code, DataConnect, DataConnectError, DataConnectOperationError, MUTATION_STR, MutationManager, QUERY_STR, SOURCE_CACHE, SOURCE_SERVER, areTransportOptionsEqual, connectDataConnectEmulator, executeMutation, executeQuery, getDataConnect, mutationRef, parseOptions, queryRef, setLogLevel, subscribe, terminate, toQueryRef, validateArgs, validateDCOptions };
|
|
1218
1231
|
//# sourceMappingURL=index.node.esm.js.map
|