@entropic-bond/firebase 1.6.4 → 1.7.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.
- package/lib/cloud-functions/firebase-cloud-functions.d.ts +6 -0
- package/lib/cloud-functions/firebase-cloud-functions.js +23 -0
- package/lib/cloud-functions/firebase-cloud-functions.js.map +1 -0
- package/lib/cloud-functions/firebase-cloud-functions.spec.d.ts +1 -0
- package/lib/cloud-functions/firebase-cloud-functions.spec.js +29 -0
- package/lib/cloud-functions/firebase-cloud-functions.spec.js.map +1 -0
- package/lib/firebase-helper.d.ts +4 -0
- package/lib/firebase-helper.js +8 -0
- package/lib/firebase-helper.js.map +1 -1
- package/package.json +9 -7
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CloudFunction, CloudFunctionsService } from 'entropic-bond';
|
|
2
|
+
import { EmulatorConfig } from '../firebase-helper';
|
|
3
|
+
export declare class FirebaseCloudFunctions implements CloudFunctionsService {
|
|
4
|
+
constructor(emulator?: EmulatorConfig, region?: string);
|
|
5
|
+
getFunction<P, R>(cloudFunction: string): CloudFunction<P, R>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FirebaseCloudFunctions = void 0;
|
|
4
|
+
const functions_1 = require("firebase/functions");
|
|
5
|
+
const firebase_helper_1 = require("../firebase-helper");
|
|
6
|
+
class FirebaseCloudFunctions {
|
|
7
|
+
constructor(emulator, region) {
|
|
8
|
+
var _a;
|
|
9
|
+
if (region)
|
|
10
|
+
firebase_helper_1.FirebaseHelper.setRegion(region);
|
|
11
|
+
if (emulator)
|
|
12
|
+
firebase_helper_1.FirebaseHelper.useEmulator(emulator);
|
|
13
|
+
if ((_a = firebase_helper_1.FirebaseHelper.emulator) === null || _a === void 0 ? void 0 : _a.emulate) {
|
|
14
|
+
const { host, functionsPort } = firebase_helper_1.FirebaseHelper.emulator;
|
|
15
|
+
(0, functions_1.connectFunctionsEmulator)(firebase_helper_1.FirebaseHelper.instance.functions(), host, functionsPort);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
getFunction(cloudFunction) {
|
|
19
|
+
return (0, functions_1.httpsCallable)(firebase_helper_1.FirebaseHelper.instance.functions(), cloudFunction);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.FirebaseCloudFunctions = FirebaseCloudFunctions;
|
|
23
|
+
//# sourceMappingURL=firebase-cloud-functions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"firebase-cloud-functions.js","sourceRoot":"","sources":["../../src/cloud-functions/firebase-cloud-functions.ts"],"names":[],"mappings":";;;AACA,kDAA4E;AAC5E,wDAAmE;AAEnE,MAAa,sBAAsB;IAClC,YAAa,QAAyB,EAAE,MAAe;;QACtD,IAAK,MAAM;YAAG,gCAAc,CAAC,SAAS,CAAE,MAAM,CAAE,CAAA;QAChD,IAAK,QAAQ;YAAG,gCAAc,CAAC,WAAW,CAAE,QAAQ,CAAE,CAAA;QAEtD,IAAK,MAAA,gCAAc,CAAC,QAAQ,0CAAE,OAAO,EAAG;YACvC,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,GAAG,gCAAc,CAAC,QAAQ,CAAA;YACvD,IAAA,oCAAwB,EAAE,gCAAc,CAAC,QAAQ,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,aAAa,CAAE,CAAA;SACpF;IAEF,CAAC;IAED,WAAW,CAAQ,aAAqB;QACvC,OAAO,IAAA,yBAAa,EAAO,gCAAc,CAAC,QAAQ,CAAC,SAAS,EAAE,EAAE,aAAa,CAAoC,CAAA;IAClH,CAAC;CACD;AAfD,wDAeC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const entropic_bond_1 = require("entropic-bond");
|
|
13
|
+
const firebase_helper_1 = require("../firebase-helper");
|
|
14
|
+
const firebase_cloud_functions_1 = require("./firebase-cloud-functions");
|
|
15
|
+
describe('Cloud functions', () => {
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
firebase_helper_1.FirebaseHelper.setFirebaseConfig({
|
|
18
|
+
projectId: 'demo-test',
|
|
19
|
+
storageBucket: 'default-bucket'
|
|
20
|
+
});
|
|
21
|
+
firebase_helper_1.FirebaseHelper.useEmulator();
|
|
22
|
+
entropic_bond_1.CloudFunctions.useCloudFunctionsService(new firebase_cloud_functions_1.FirebaseCloudFunctions({ emulate: true }, 'europe-west1'));
|
|
23
|
+
});
|
|
24
|
+
it('should call cloud function', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
25
|
+
const testCallable = entropic_bond_1.CloudFunctions.instance.getFunction('testCallable');
|
|
26
|
+
expect(yield testCallable({ test: 'test', age: 3 })).toEqual({ data: { test: 'test', age: 3 } });
|
|
27
|
+
}));
|
|
28
|
+
});
|
|
29
|
+
//# sourceMappingURL=firebase-cloud-functions.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"firebase-cloud-functions.spec.js","sourceRoot":"","sources":["../../src/cloud-functions/firebase-cloud-functions.spec.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,iDAA8C;AAC9C,wDAAmD;AACnD,yEAAmE;AAEnE,QAAQ,CAAE,iBAAiB,EAAE,GAAE,EAAE;IAEhC,UAAU,CAAC,GAAE,EAAE;QACd,gCAAc,CAAC,iBAAiB,CAAC;YAChC,SAAS,EAAE,WAAW;YACtB,aAAa,EAAE,gBAAgB;SAC/B,CAAC,CAAA;QAEF,gCAAc,CAAC,WAAW,EAAE,CAAA;QAC5B,8BAAc,CAAC,wBAAwB,CACtC,IAAI,iDAAsB,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,cAAc,CAAE,CAC9D,CAAA;IACF,CAAC,CAAC,CAAA;IAEF,EAAE,CAAE,4BAA4B,EAAE,GAAQ,EAAE;QAC3C,MAAM,YAAY,GAAG,8BAAc,CAAC,QAAQ,CAAC,WAAW,CAAE,cAAc,CAAE,CAAA;QAC1E,MAAM,CAAE,MAAM,YAAY,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,CAAE,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,EAAC,CAAC,CAAA;IAClG,CAAC,CAAA,CAAC,CAAA;AACH,CAAC,CAAC,CAAA"}
|
package/lib/firebase-helper.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export interface EmulatorConfig {
|
|
|
15
15
|
firestorePort?: number;
|
|
16
16
|
storagePort?: number;
|
|
17
17
|
authPort?: number;
|
|
18
|
+
functionsPort?: number;
|
|
18
19
|
emulate?: boolean;
|
|
19
20
|
}
|
|
20
21
|
export declare class FirebaseHelper {
|
|
@@ -26,8 +27,11 @@ export declare class FirebaseHelper {
|
|
|
26
27
|
firestore(): import("@firebase/firestore").Firestore;
|
|
27
28
|
storage(): import("@firebase/storage").FirebaseStorage;
|
|
28
29
|
auth(): import("@firebase/auth").Auth;
|
|
30
|
+
functions(): import("@firebase/functions").Functions;
|
|
31
|
+
static setRegion(region: string): void;
|
|
29
32
|
private static _instance;
|
|
30
33
|
private static _firebaseConfig;
|
|
31
34
|
private static _emulatorConfig;
|
|
35
|
+
private static _region;
|
|
32
36
|
private _firebaseApp;
|
|
33
37
|
}
|
package/lib/firebase-helper.js
CHANGED
|
@@ -5,6 +5,7 @@ const app_1 = require("firebase/app");
|
|
|
5
5
|
const firestore_1 = require("firebase/firestore");
|
|
6
6
|
const auth_1 = require("firebase/auth");
|
|
7
7
|
const storage_1 = require("firebase/storage");
|
|
8
|
+
const functions_1 = require("firebase/functions");
|
|
8
9
|
class FirebaseHelper {
|
|
9
10
|
constructor() {
|
|
10
11
|
if (!FirebaseHelper._firebaseConfig)
|
|
@@ -20,6 +21,7 @@ class FirebaseHelper {
|
|
|
20
21
|
firestorePort: 8080,
|
|
21
22
|
storagePort: 9199,
|
|
22
23
|
authPort: 9099,
|
|
24
|
+
functionsPort: 5001,
|
|
23
25
|
emulate: true
|
|
24
26
|
};
|
|
25
27
|
this._emulatorConfig = Object.assign(Object.assign({}, defaultConfig), emulatorConfig);
|
|
@@ -39,6 +41,12 @@ class FirebaseHelper {
|
|
|
39
41
|
auth() {
|
|
40
42
|
return (0, auth_1.getAuth)(this._firebaseApp);
|
|
41
43
|
}
|
|
44
|
+
functions() {
|
|
45
|
+
return (0, functions_1.getFunctions)(this._firebaseApp, FirebaseHelper._region);
|
|
46
|
+
}
|
|
47
|
+
static setRegion(region) {
|
|
48
|
+
this._region = region;
|
|
49
|
+
}
|
|
42
50
|
}
|
|
43
51
|
exports.FirebaseHelper = FirebaseHelper;
|
|
44
52
|
//# sourceMappingURL=firebase-helper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"firebase-helper.js","sourceRoot":"","sources":["../src/firebase-helper.ts"],"names":[],"mappings":";;;AAAA,sCAAyD;AACzD,kDAA2F;AAC3F,wCAAuC;AACvC,8CAA6C;
|
|
1
|
+
{"version":3,"file":"firebase-helper.js","sourceRo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AC,OAAO,CAAE,CAAA;IACjE,CAAC;IAED,MAAM,CAAC,SAAS,CAAE,MAAc;QAC/B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAA;IACtB,CAAC;CAOD;AA5DD,wCA4DC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@entropic-bond/firebase",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"branches": [
|
|
@@ -25,10 +25,12 @@
|
|
|
25
25
|
"scripts": {
|
|
26
26
|
"test": "firebase emulators:exec --project demo-test 'jest --forceExit'",
|
|
27
27
|
"build": "npm run build-cjs",
|
|
28
|
+
"build-functions": "cd functions && npm run build",
|
|
28
29
|
"prepare": "npm run build",
|
|
29
30
|
"build-ts": "cp -r ./src/ ./lib",
|
|
30
31
|
"build-cjs": "tsc -p tsconfig-cjs.json",
|
|
31
|
-
"emulators": "firebase emulators:start --project demo-test"
|
|
32
|
+
"emulators": "firebase emulators:start --project demo-test",
|
|
33
|
+
"postinstall": "cd functions && npm ci"
|
|
32
34
|
},
|
|
33
35
|
"repository": {
|
|
34
36
|
"type": "git",
|
|
@@ -47,20 +49,20 @@
|
|
|
47
49
|
"devDependencies": {
|
|
48
50
|
"@semantic-release/changelog": "^6.0.1",
|
|
49
51
|
"@semantic-release/git": "^10.0.1",
|
|
50
|
-
"@types/jest": "^28.1.
|
|
52
|
+
"@types/jest": "^28.1.7",
|
|
51
53
|
"@types/node-fetch": "^3.0.3",
|
|
52
54
|
"git-branch-is": "^4.0.0",
|
|
53
55
|
"husky": "^8.0.1",
|
|
54
|
-
"jest": "^28.1.
|
|
56
|
+
"jest": "^28.1.3",
|
|
55
57
|
"node-fetch": "^2.6.1",
|
|
56
58
|
"semantic-release": "^19.0.3",
|
|
57
|
-
"ts-jest": "^28.0.
|
|
59
|
+
"ts-jest": "^28.0.8",
|
|
58
60
|
"typescript": "^4.7.4",
|
|
59
61
|
"xhr2": "^0.2.1"
|
|
60
62
|
},
|
|
61
63
|
"dependencies": {
|
|
62
|
-
"entropic-bond": "^1.
|
|
63
|
-
"firebase": "^9.
|
|
64
|
+
"entropic-bond": "^1.29.1",
|
|
65
|
+
"firebase": "^9.9.2"
|
|
64
66
|
},
|
|
65
67
|
"husky": {
|
|
66
68
|
"hooks": {
|