@dereekb/firebase 9.19.0 → 9.19.2
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/CHANGELOG.md +8 -0
- package/package.json +5 -5
- package/src/lib/client/function/error.d.ts +8 -0
- package/src/lib/client/function/error.js +20 -0
- package/src/lib/client/function/error.js.map +1 -0
- package/src/lib/client/function/function.callable.d.ts +3 -1
- package/src/lib/client/function/function.callable.js +33 -9
- package/src/lib/client/function/function.callable.js.map +1 -1
- package/src/lib/client/function/index.d.ts +1 -0
- package/src/lib/client/function/index.js +1 -0
- package/src/lib/client/function/index.js.map +1 -1
- package/test/CHANGELOG.md +8 -0
- package/test/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [9.19.2](https://github.com/dereekb/dbx-components/compare/v9.19.1-dev...v9.19.2) (2022-12-13)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## [9.19.1](https://github.com/dereekb/dbx-components/compare/v9.19.0-dev...v9.19.1) (2022-12-12)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
5
13
|
# [9.19.0](https://github.com/dereekb/dbx-components/compare/v9.18.6-dev...v9.19.0) (2022-12-11)
|
|
6
14
|
|
|
7
15
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/firebase",
|
|
3
|
-
"version": "9.19.
|
|
3
|
+
"version": "9.19.2",
|
|
4
4
|
"devDependencies": {
|
|
5
5
|
"@firebase/rules-unit-testing": "^2.0.0"
|
|
6
6
|
},
|
|
@@ -24,17 +24,17 @@
|
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"rxjs": "^7.5.0",
|
|
26
26
|
"firebase": "^9.9.2",
|
|
27
|
-
"@dereekb/util": "9.19.
|
|
27
|
+
"@dereekb/util": "9.19.2",
|
|
28
28
|
"lodash.isequal": "^4.5.0",
|
|
29
29
|
"make-error": "^1.3.0",
|
|
30
30
|
"class-validator": "^0.13.2",
|
|
31
31
|
"ts-essentials": "^9.1.2",
|
|
32
32
|
"extra-set": "^2.2.11",
|
|
33
33
|
"class-transformer": "^0.5.1",
|
|
34
|
-
"@dereekb/rxjs": "9.19.
|
|
34
|
+
"@dereekb/rxjs": "9.19.2",
|
|
35
35
|
"ms": "^3.0.0-canary.1",
|
|
36
|
-
"@dereekb/model": "9.19.
|
|
37
|
-
"@dereekb/date": "9.19.
|
|
36
|
+
"@dereekb/model": "9.19.2",
|
|
37
|
+
"@dereekb/date": "9.19.2",
|
|
38
38
|
"date-fns": "^2.29.0",
|
|
39
39
|
"date-fns-tz": "^1.3.0",
|
|
40
40
|
"rrule": "git+https://git@github.com/dereekb/rrule#2b13b1ea881059ba2ecfec380e12ef244ef54570",
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ServerError, ServerErrorResponse, ServerErrorResponseData } from '@dereekb/util';
|
|
2
|
+
import { FirebaseError } from 'firebase/app';
|
|
3
|
+
export declare class FirebaseServerError<T extends ServerErrorResponseData = ServerErrorResponseData> extends ServerErrorResponse<T> {
|
|
4
|
+
readonly firebaseError: FirebaseError;
|
|
5
|
+
static fromFirebaseError(error: FirebaseError): FirebaseServerError;
|
|
6
|
+
constructor(firebaseError: FirebaseError, serverError: ServerError<T>);
|
|
7
|
+
get _error(): FirebaseError;
|
|
8
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FirebaseServerError = void 0;
|
|
4
|
+
const util_1 = require("@dereekb/util");
|
|
5
|
+
class FirebaseServerError extends util_1.ServerErrorResponse {
|
|
6
|
+
constructor(firebaseError, serverError) {
|
|
7
|
+
super(serverError);
|
|
8
|
+
this.firebaseError = firebaseError;
|
|
9
|
+
}
|
|
10
|
+
static fromFirebaseError(error) {
|
|
11
|
+
let details = error.details;
|
|
12
|
+
details = Object.assign({ status: 0, message: error.message || error.name, code: error.code }, details);
|
|
13
|
+
return new FirebaseServerError(error, details);
|
|
14
|
+
}
|
|
15
|
+
get _error() {
|
|
16
|
+
return this.firebaseError;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.FirebaseServerError = FirebaseServerError;
|
|
20
|
+
//# sourceMappingURL=error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../../../../../../packages/firebase/src/lib/client/function/error.ts"],"names":[],"mappings":";;;AAAA,wCAAiG;AAGjG,MAAa,mBAAiF,SAAQ,0BAAsB;IAc1H,YAAqB,aAA4B,EAAE,WAA2B;QAC5E,KAAK,CAAC,WAAW,CAAC,CAAC;QADA,kBAAa,GAAb,aAAa,CAAe;IAEjD,CAAC;IAfD,MAAM,CAAC,iBAAiB,CAAC,KAAoB;QAC3C,IAAI,OAAO,GAAiD,KAA2C,CAAC,OAAO,CAAC;QAEhH,OAAO,mBACL,MAAM,EAAE,CAAC,EACT,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,IAAI,EACpC,IAAI,EAAE,KAAK,CAAC,IAAI,IACb,OAAO,CACX,CAAC;QAEF,OAAO,IAAI,mBAAmB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACjD,CAAC;IAMD,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;CACF;AArBD,kDAqBC"}
|
|
@@ -5,7 +5,8 @@ export interface MapHttpsCallable<I, O, A, B> {
|
|
|
5
5
|
mapOutput?: FactoryWithInput<PromiseOrValue<O>, Maybe<B>>;
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
|
-
* Maps input and output values
|
|
8
|
+
* Maps input and output values when using HttpsCallable.
|
|
9
|
+
*
|
|
9
10
|
* @param callable
|
|
10
11
|
* @param wrap
|
|
11
12
|
* @returns
|
|
@@ -19,3 +20,4 @@ export declare function mapHttpsCallable<I, O, A, B = unknown>(callable: HttpsCa
|
|
|
19
20
|
*/
|
|
20
21
|
export declare type DirectDataHttpsCallable<C extends HttpsCallable<any, any>> = C extends HttpsCallable<infer I, infer O> ? (data?: I | null) => Promise<O> : never;
|
|
21
22
|
export declare function directDataHttpsCallable<I, O, C extends HttpsCallable<I, O> = HttpsCallable<I, O>>(callable: C): DirectDataHttpsCallable<C>;
|
|
23
|
+
export declare function convertHttpsCallableErrorToReadableError(error: unknown): unknown;
|
|
@@ -2,26 +2,50 @@
|
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
3
|
// The use of any here does not degrade the type-safety. The correct type is inferred in most cases.
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.directDataHttpsCallable = exports.mapHttpsCallable = void 0;
|
|
5
|
+
exports.convertHttpsCallableErrorToReadableError = exports.directDataHttpsCallable = exports.mapHttpsCallable = void 0;
|
|
6
6
|
const tslib_1 = require("tslib");
|
|
7
|
+
const util_1 = require("@dereekb/util");
|
|
8
|
+
const app_1 = require("firebase/app");
|
|
9
|
+
const error_1 = require("./error");
|
|
7
10
|
function mapHttpsCallable(callable, wrap, directData = false) {
|
|
8
11
|
const { mapInput = (x) => x, mapOutput = (x) => x } = wrap;
|
|
9
12
|
return ((inputData) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
10
13
|
const data = yield mapInput(inputData);
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
try {
|
|
15
|
+
const result = yield callable(data);
|
|
16
|
+
const resultData = result.data;
|
|
17
|
+
const mappedResultData = yield mapOutput(resultData);
|
|
18
|
+
if (directData) {
|
|
19
|
+
return mappedResultData;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
return Object.assign(Object.assign({}, result), { data: mappedResultData });
|
|
23
|
+
}
|
|
16
24
|
}
|
|
17
|
-
|
|
18
|
-
|
|
25
|
+
catch (e) {
|
|
26
|
+
throw convertHttpsCallableErrorToReadableError(e);
|
|
19
27
|
}
|
|
20
28
|
}));
|
|
21
29
|
}
|
|
22
30
|
exports.mapHttpsCallable = mapHttpsCallable;
|
|
23
31
|
function directDataHttpsCallable(callable) {
|
|
24
|
-
return ((data) => callable(data)
|
|
32
|
+
return ((data) => callable(data)
|
|
33
|
+
.then((x) => x.data)
|
|
34
|
+
.catch((e) => convertHttpsCallableErrorToReadableError(e)));
|
|
25
35
|
}
|
|
26
36
|
exports.directDataHttpsCallable = directDataHttpsCallable;
|
|
37
|
+
function convertHttpsCallableErrorToReadableError(error) {
|
|
38
|
+
let result;
|
|
39
|
+
if (error instanceof app_1.FirebaseError) {
|
|
40
|
+
result = error_1.FirebaseServerError.fromFirebaseError(error);
|
|
41
|
+
}
|
|
42
|
+
else if (typeof error === 'object') {
|
|
43
|
+
result = (0, util_1.toReadableError)(error);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
result = error;
|
|
47
|
+
}
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
exports.convertHttpsCallableErrorToReadableError = convertHttpsCallableErrorToReadableError;
|
|
27
51
|
//# sourceMappingURL=function.callable.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"function.callable.js","sourceRoot":"","sources":["../../../../../../../packages/firebase/src/lib/client/function/function.callable.ts"],"names":[],"mappings":";AAAA,uDAAuD;AACvD,oGAAoG;;;;
|
|
1
|
+
{"version":3,"file":"function.callable.js","sourceRoot":"","sources":["../../../../../../../packages/firebase/src/lib/client/function/function.callable.ts"],"names":[],"mappings":";AAAA,uDAAuD;AACvD,oGAAoG;;;;AAEpG,wCAAsG;AACtG,sCAA6C;AAE7C,mCAA8C;AAkB9C,SAAgB,gBAAgB,CAAuB,QAA6B,EAAE,IAAkC,EAAE,U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AM,GAAG,IAAA,sBAAe,EAAC,KAAK,CAAC,CAAC;KACjC;SAAM;QACL,MAAM,GAAG,KAAK,CAAC;KAChB;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAZD,4FAYC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./error"), exports);
|
|
4
5
|
tslib_1.__exportStar(require("./function"), exports);
|
|
5
6
|
tslib_1.__exportStar(require("./function.callable"), exports);
|
|
6
7
|
tslib_1.__exportStar(require("./function.factory"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/firebase/src/lib/client/function/index.ts"],"names":[],"mappings":";;;AAAA,qDAA2B;AAC3B,8DAAoC;AACpC,6DAAmC;AACnC,mEAAyC;AACzC,yEAA+C;AAC/C,iEAAuC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/firebase/src/lib/client/function/index.ts"],"names":[],"mappings":";;;AAAA,kDAAwB;AACxB,qDAA2B;AAC3B,8DAAoC;AACpC,6DAAmC;AACnC,mEAAyC;AACzC,yEAA+C;AAC/C,iEAAuC"}
|
package/test/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [9.19.2](https://github.com/dereekb/dbx-components/compare/v9.19.1-dev...v9.19.2) (2022-12-13)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## [9.19.1](https://github.com/dereekb/dbx-components/compare/v9.19.0-dev...v9.19.1) (2022-12-12)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
5
13
|
# [9.19.0](https://github.com/dereekb/dbx-components/compare/v9.18.6-dev...v9.19.0) (2022-12-11)
|
|
6
14
|
|
|
7
15
|
|
package/test/package.json
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/firebase/test",
|
|
3
|
-
"version": "9.19.
|
|
3
|
+
"version": "9.19.2",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"types": "./src/index.d.ts",
|
|
7
7
|
"dependencies": {},
|
|
8
8
|
"peerDependencies": {
|
|
9
|
-
"@dereekb/util/test": "9.19.
|
|
10
|
-
"@dereekb/util": "9.19.
|
|
9
|
+
"@dereekb/util/test": "9.19.2",
|
|
10
|
+
"@dereekb/util": "9.19.2",
|
|
11
11
|
"lodash.isequal": "^4.5.0",
|
|
12
12
|
"make-error": "^1.3.0",
|
|
13
13
|
"class-validator": "^0.13.2",
|
|
14
14
|
"ts-essentials": "^9.1.2",
|
|
15
15
|
"extra-set": "^2.2.11",
|
|
16
|
-
"@dereekb/firebase": "9.19.
|
|
16
|
+
"@dereekb/firebase": "9.19.2",
|
|
17
17
|
"rxjs": "^7.5.0",
|
|
18
18
|
"firebase": "^9.9.2",
|
|
19
19
|
"class-transformer": "^0.5.1",
|
|
20
|
-
"@dereekb/rxjs": "9.19.
|
|
20
|
+
"@dereekb/rxjs": "9.19.2",
|
|
21
21
|
"ms": "^3.0.0-canary.1",
|
|
22
|
-
"@dereekb/model": "9.19.
|
|
23
|
-
"@dereekb/date": "9.19.
|
|
22
|
+
"@dereekb/model": "9.19.2",
|
|
23
|
+
"@dereekb/date": "9.19.2",
|
|
24
24
|
"date-fns": "^2.29.0",
|
|
25
25
|
"date-fns-tz": "^1.3.0",
|
|
26
26
|
"rrule": "git+https://git@github.com/dereekb/rrule#2b13b1ea881059ba2ecfec380e12ef244ef54570",
|