@mxpicture/gcp-functions-frontend 0.1.16 → 0.1.17
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/{cjs/base → api}/FrontendApi.d.ts +2 -3
- package/dist/{esm/base → api}/FrontendApi.js +10 -13
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.js +1 -0
- package/dist/{esm/config → config}/firebase.config.d.ts +1 -2
- package/dist/config/firebase.config.js +25 -0
- package/dist/config/index.d.ts +1 -0
- package/dist/config/index.js +1 -0
- package/dist/{cjs/loader → loader}/firebase.loader.d.ts +0 -1
- package/dist/loader/firebase.loader.js +18 -0
- package/dist/{cjs/services → services}/firebase/auth.service.d.ts +1 -2
- package/dist/{esm/services → services}/firebase/auth.service.js +15 -18
- package/dist/services/firebase/index.d.ts +1 -0
- package/dist/services/firebase/index.js +1 -0
- package/dist/{esm/types → types}/auth.types.d.ts +0 -1
- package/dist/types/auth.types.js +1 -0
- package/dist/{cjs/types → types}/firebase.types.d.ts +0 -1
- package/dist/types/firebase.types.js +1 -0
- package/dist/types/index.d.ts +2 -4
- package/dist/types/index.js +1 -0
- package/package.json +9 -17
- package/dist/cjs/base/FrontendApi.d.ts.map +0 -1
- package/dist/cjs/base/FrontendApi.js +0 -57
- package/dist/cjs/config/firebase.config.d.ts +0 -15
- package/dist/cjs/config/firebase.config.d.ts.map +0 -1
- package/dist/cjs/config/firebase.config.js +0 -30
- package/dist/cjs/index.d.ts +0 -4
- package/dist/cjs/index.d.ts.map +0 -1
- package/dist/cjs/index.js +0 -44
- package/dist/cjs/lib.d.ts +0 -7
- package/dist/cjs/lib.d.ts.map +0 -1
- package/dist/cjs/lib.js +0 -22
- package/dist/cjs/loader/firebase.loader.d.ts.map +0 -1
- package/dist/cjs/loader/firebase.loader.js +0 -57
- package/dist/cjs/package.d.ts +0 -2
- package/dist/cjs/package.d.ts.map +0 -1
- package/dist/cjs/package.js +0 -21
- package/dist/cjs/services/firebase/auth.service.d.ts.map +0 -1
- package/dist/cjs/services/firebase/auth.service.js +0 -85
- package/dist/cjs/types/auth.types.d.ts +0 -28
- package/dist/cjs/types/auth.types.d.ts.map +0 -1
- package/dist/cjs/types/auth.types.js +0 -2
- package/dist/cjs/types/firebase.types.d.ts.map +0 -1
- package/dist/cjs/types/firebase.types.js +0 -2
- package/dist/cjs/types/index.d.ts +0 -3
- package/dist/cjs/types/index.d.ts.map +0 -1
- package/dist/cjs/types/index.js +0 -2
- package/dist/esm/base/FrontendApi.d.ts +0 -26
- package/dist/esm/base/FrontendApi.d.ts.map +0 -1
- package/dist/esm/config/firebase.config.d.ts.map +0 -1
- package/dist/esm/config/firebase.config.js +0 -30
- package/dist/esm/index.d.ts +0 -4
- package/dist/esm/index.d.ts.map +0 -1
- package/dist/esm/index.js +0 -44
- package/dist/esm/lib.d.ts +0 -7
- package/dist/esm/lib.d.ts.map +0 -1
- package/dist/esm/lib.js +0 -22
- package/dist/esm/loader/firebase.loader.d.ts +0 -4
- package/dist/esm/loader/firebase.loader.d.ts.map +0 -1
- package/dist/esm/loader/firebase.loader.js +0 -24
- package/dist/esm/package.d.ts +0 -2
- package/dist/esm/package.d.ts.map +0 -1
- package/dist/esm/package.js +0 -21
- package/dist/esm/services/firebase/auth.service.d.ts +0 -14
- package/dist/esm/services/firebase/auth.service.d.ts.map +0 -1
- package/dist/esm/types/auth.types.d.ts.map +0 -1
- package/dist/esm/types/auth.types.js +0 -2
- package/dist/esm/types/firebase.types.d.ts +0 -14
- package/dist/esm/types/firebase.types.d.ts.map +0 -1
- package/dist/esm/types/firebase.types.js +0 -2
- package/dist/esm/types/index.d.ts +0 -3
- package/dist/esm/types/index.d.ts.map +0 -1
- package/dist/esm/types/index.js +0 -2
- package/dist/tsconfig.cjs.tsbuildinfo +0 -1
- package/dist/tsconfig.esm.tsbuildinfo +0 -1
- package/dist/tsconfig.types.tsbuildinfo +0 -1
- package/dist/types/base/FrontendApi.d.ts +0 -26
- package/dist/types/base/FrontendApi.d.ts.map +0 -1
- package/dist/types/config/firebase.config.d.ts +0 -15
- package/dist/types/config/firebase.config.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/lib.d.ts +0 -7
- package/dist/types/lib.d.ts.map +0 -1
- package/dist/types/loader/firebase.loader.d.ts +0 -4
- package/dist/types/loader/firebase.loader.d.ts.map +0 -1
- package/dist/types/package.d.ts +0 -2
- package/dist/types/package.d.ts.map +0 -1
- package/dist/types/services/firebase/auth.service.d.ts +0 -14
- package/dist/types/services/firebase/auth.service.d.ts.map +0 -1
- package/dist/types/types/auth.types.d.ts +0 -28
- package/dist/types/types/auth.types.d.ts.map +0 -1
- package/dist/types/types/firebase.types.d.ts +0 -14
- package/dist/types/types/firebase.types.d.ts.map +0 -1
- package/dist/types/types/index.d.ts +0 -3
- package/dist/types/types/index.d.ts.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { MetaItem } from "@mxpicture/zod-meta";
|
|
2
|
-
import type { ApiKey, DocumentData, WithKey, FunctionName, FunctionPayload, FunctionResult } from "@mxpicture/gcp-functions-common";
|
|
3
|
-
import { IApi } from "@mxpicture/gcp-functions-common";
|
|
2
|
+
import type { ApiKey, DocumentData, WithKey, FunctionName, FunctionPayload, FunctionResult } from "@mxpicture/gcp-functions-common/types";
|
|
3
|
+
import { IApi } from "@mxpicture/gcp-functions-common/api";
|
|
4
4
|
import type { HttpsCallable } from "firebase/functions";
|
|
5
5
|
export declare const functionCallable: <DTO extends DocumentData, KEYS extends ApiKey>(name: FunctionName) => Promise<HttpsCallable<FunctionPayload<DTO, KEYS>, Promise<FunctionResult<WithKey<DTO>>>, unknown>>;
|
|
6
6
|
export declare class FrontendApi<DTO extends DocumentData> extends IApi<DTO> {
|
|
@@ -23,4 +23,3 @@ export declare class FrontendApi<DTO extends DocumentData> extends IApi<DTO> {
|
|
|
23
23
|
id: string;
|
|
24
24
|
}, data: Partial<DTO>): Promise<WithKey<DTO>>;
|
|
25
25
|
}
|
|
26
|
-
//# sourceMappingURL=FrontendApi.d.ts.map
|
|
@@ -1,22 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const functionCallable = async (name) => {
|
|
8
|
-
const { httpsCallable } = await (0, firebase_loader_1.loadFirebaseFunctions)();
|
|
9
|
-
return httpsCallable((await (0, firebase_config_1.configFirebase)()).functions, name);
|
|
1
|
+
import { IApi } from "@mxpicture/gcp-functions-common/api";
|
|
2
|
+
import { configFirebase } from "../config/firebase.config.js";
|
|
3
|
+
import { loadFirebaseFunctions } from "../loader/firebase.loader.js";
|
|
4
|
+
export const functionCallable = async (name) => {
|
|
5
|
+
const { httpsCallable } = await loadFirebaseFunctions();
|
|
6
|
+
return httpsCallable((await configFirebase()).functions, name);
|
|
10
7
|
};
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
export class FrontendApi extends IApi {
|
|
9
|
+
name;
|
|
10
|
+
_service;
|
|
13
11
|
constructor(name) {
|
|
14
12
|
super();
|
|
15
13
|
this.name = name;
|
|
16
14
|
}
|
|
17
15
|
async service() {
|
|
18
16
|
if (!this._service)
|
|
19
|
-
this._service = await
|
|
17
|
+
this._service = await functionCallable(this.name);
|
|
20
18
|
return this._service;
|
|
21
19
|
}
|
|
22
20
|
async delete(keys) {
|
|
@@ -54,4 +52,3 @@ class FrontendApi extends gcp_functions_common_1.IApi {
|
|
|
54
52
|
})).data).doc;
|
|
55
53
|
}
|
|
56
54
|
}
|
|
57
|
-
exports.FrontendApi = FrontendApi;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { FrontendApi, functionCallable } from "./FrontendApi.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { FrontendApi, functionCallable } from "./FrontendApi.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Auth } from "firebase/auth";
|
|
2
2
|
import type { FirebaseApp } from "firebase/app";
|
|
3
3
|
import type { Functions } from "firebase/functions";
|
|
4
|
-
import type { FirebaseConfig } from "../types";
|
|
4
|
+
import type { FirebaseConfig } from "../types/firebase.types.js";
|
|
5
5
|
export declare const initializeFirebase: (config: FirebaseConfig) => Promise<{
|
|
6
6
|
app: FirebaseApp;
|
|
7
7
|
auth: Auth;
|
|
@@ -12,4 +12,3 @@ export declare const configFirebase: () => Promise<{
|
|
|
12
12
|
auth: Auth;
|
|
13
13
|
functions: Functions;
|
|
14
14
|
}>;
|
|
15
|
-
//# sourceMappingURL=firebase.config.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { loadFirebaseApp, loadFirebaseAuth, loadFirebaseFunctions, } from "../loader/firebase.loader.js";
|
|
2
|
+
let _inst = null;
|
|
3
|
+
let _config = null;
|
|
4
|
+
export const initializeFirebase = async (config) => {
|
|
5
|
+
if (_config)
|
|
6
|
+
throw new Error("Firebase config already present");
|
|
7
|
+
_config = { ...config };
|
|
8
|
+
return configFirebase();
|
|
9
|
+
};
|
|
10
|
+
export const configFirebase = async () => {
|
|
11
|
+
if (!_inst) {
|
|
12
|
+
if (!_config)
|
|
13
|
+
throw new Error("Firebase config not provided. Use initializeFirebase at first");
|
|
14
|
+
const { getAuth } = await loadFirebaseAuth();
|
|
15
|
+
const { getFunctions } = await loadFirebaseFunctions();
|
|
16
|
+
const { initializeApp } = await loadFirebaseApp();
|
|
17
|
+
// Initialize Firebase
|
|
18
|
+
const app = initializeApp(_config);
|
|
19
|
+
// Initialize Firebase services
|
|
20
|
+
const auth = getAuth(app);
|
|
21
|
+
const functions = getFunctions(app);
|
|
22
|
+
_inst = { app, auth, functions };
|
|
23
|
+
}
|
|
24
|
+
return _inst;
|
|
25
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { configFirebase, initializeFirebase } from "./firebase.config.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { configFirebase, initializeFirebase } from "./firebase.config.js";
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export declare const loadFirebaseAuth: () => Promise<typeof import("firebase/auth")>;
|
|
2
2
|
export declare const loadFirebaseApp: () => Promise<typeof import("firebase/app")>;
|
|
3
3
|
export declare const loadFirebaseFunctions: () => Promise<typeof import("firebase/functions")>;
|
|
4
|
-
//# sourceMappingURL=firebase.loader.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
let authPromise = null;
|
|
2
|
+
let appPromise = null;
|
|
3
|
+
let functionsPromise = null;
|
|
4
|
+
export const loadFirebaseAuth = () => {
|
|
5
|
+
if (!authPromise)
|
|
6
|
+
authPromise = import("firebase/auth");
|
|
7
|
+
return authPromise;
|
|
8
|
+
};
|
|
9
|
+
export const loadFirebaseApp = () => {
|
|
10
|
+
if (!appPromise)
|
|
11
|
+
appPromise = import("firebase/app");
|
|
12
|
+
return appPromise;
|
|
13
|
+
};
|
|
14
|
+
export const loadFirebaseFunctions = () => {
|
|
15
|
+
if (!functionsPromise)
|
|
16
|
+
functionsPromise = import("firebase/functions");
|
|
17
|
+
return functionsPromise;
|
|
18
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AuthUser, LoginCredentials, RegisterCredentials } from "../../types";
|
|
1
|
+
import type { AuthUser, LoginCredentials, RegisterCredentials } from "../../types/auth.types.js";
|
|
2
2
|
declare class AuthService {
|
|
3
3
|
login(credentials: LoginCredentials): Promise<AuthUser>;
|
|
4
4
|
register(credentials: RegisterCredentials): Promise<AuthUser>;
|
|
@@ -11,4 +11,3 @@ declare class AuthService {
|
|
|
11
11
|
}
|
|
12
12
|
export declare const authService: AuthService;
|
|
13
13
|
export default authService;
|
|
14
|
-
//# sourceMappingURL=auth.service.d.ts.map
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.authService = void 0;
|
|
4
|
-
const firebase_config_1 = require("../../config/firebase.config");
|
|
5
|
-
const firebase_loader_1 = require("../../loader/firebase.loader");
|
|
1
|
+
import { configFirebase } from "../../config/firebase.config.js";
|
|
2
|
+
import { loadFirebaseAuth } from "../../loader/firebase.loader.js";
|
|
6
3
|
class AuthService {
|
|
7
4
|
async login(credentials) {
|
|
8
5
|
try {
|
|
9
|
-
const { signInWithEmailAndPassword } = await
|
|
10
|
-
const { user } = await signInWithEmailAndPassword((await
|
|
6
|
+
const { signInWithEmailAndPassword } = await loadFirebaseAuth();
|
|
7
|
+
const { user } = await signInWithEmailAndPassword((await configFirebase()).auth, credentials.email, credentials.password);
|
|
11
8
|
return this.mapFirebaseUserToAuthUser(user);
|
|
12
9
|
}
|
|
13
10
|
catch (error) {
|
|
@@ -16,8 +13,8 @@ class AuthService {
|
|
|
16
13
|
}
|
|
17
14
|
async register(credentials) {
|
|
18
15
|
try {
|
|
19
|
-
const { createUserWithEmailAndPassword } = await
|
|
20
|
-
const { user } = await createUserWithEmailAndPassword((await
|
|
16
|
+
const { createUserWithEmailAndPassword } = await loadFirebaseAuth();
|
|
17
|
+
const { user } = await createUserWithEmailAndPassword((await configFirebase()).auth, credentials.email, credentials.password);
|
|
21
18
|
// Store additional user data in Firestore
|
|
22
19
|
// const userService = new UserService()
|
|
23
20
|
// await userService.createUserProfile(user.uid, credentials)
|
|
@@ -29,8 +26,8 @@ class AuthService {
|
|
|
29
26
|
}
|
|
30
27
|
async logout() {
|
|
31
28
|
try {
|
|
32
|
-
const { signOut } = await
|
|
33
|
-
await signOut((await
|
|
29
|
+
const { signOut } = await loadFirebaseAuth();
|
|
30
|
+
await signOut((await configFirebase()).auth);
|
|
34
31
|
}
|
|
35
32
|
catch (error) {
|
|
36
33
|
throw this.handleAuthError(error);
|
|
@@ -38,21 +35,21 @@ class AuthService {
|
|
|
38
35
|
}
|
|
39
36
|
async resetPassword(email) {
|
|
40
37
|
try {
|
|
41
|
-
const { sendPasswordResetEmail } = await
|
|
42
|
-
await sendPasswordResetEmail((await
|
|
38
|
+
const { sendPasswordResetEmail } = await loadFirebaseAuth();
|
|
39
|
+
await sendPasswordResetEmail((await configFirebase()).auth, email);
|
|
43
40
|
}
|
|
44
41
|
catch (error) {
|
|
45
42
|
throw this.handleAuthError(error);
|
|
46
43
|
}
|
|
47
44
|
}
|
|
48
45
|
async onAuthStateChanged(callback) {
|
|
49
|
-
const { onAuthStateChanged } = await
|
|
50
|
-
return onAuthStateChanged((await
|
|
46
|
+
const { onAuthStateChanged } = await loadFirebaseAuth();
|
|
47
|
+
return onAuthStateChanged((await configFirebase()).auth, (user) => {
|
|
51
48
|
callback(user ? this.mapFirebaseUserToAuthUser(user) : null);
|
|
52
49
|
});
|
|
53
50
|
}
|
|
54
51
|
async getCurrentUser() {
|
|
55
|
-
const user = (await
|
|
52
|
+
const user = (await configFirebase()).auth.currentUser;
|
|
56
53
|
return user ? this.mapFirebaseUserToAuthUser(user) : null;
|
|
57
54
|
}
|
|
58
55
|
mapFirebaseUserToAuthUser(user) {
|
|
@@ -81,5 +78,5 @@ class AuthService {
|
|
|
81
78
|
return new Error(message);
|
|
82
79
|
}
|
|
83
80
|
}
|
|
84
|
-
|
|
85
|
-
|
|
81
|
+
export const authService = new AuthService();
|
|
82
|
+
export default authService;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { authService } from "./auth.service.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { authService } from "./auth.service.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,40 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mxpicture/gcp-functions-frontend",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.17",
|
|
4
4
|
"description": "Utils for google cloud functions, publishing both CommonJS and ESM builds",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"author": "MXPicture",
|
|
6
7
|
"license": "MIT",
|
|
7
8
|
"repository": {
|
|
8
9
|
"type": "git",
|
|
9
10
|
"url": "git+https://github.com/MXPicture/npm-gcp-functions.git"
|
|
10
11
|
},
|
|
11
|
-
"main": "dist/cjs/index.js",
|
|
12
|
-
"module": "dist/esm/index.js",
|
|
13
|
-
"types": "dist/types/package.d.ts",
|
|
14
12
|
"exports": {
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
},
|
|
20
|
-
"./*": {
|
|
21
|
-
"types": "./dist/types/*",
|
|
22
|
-
"import": "./dist/esm/*",
|
|
23
|
-
"require": "./dist/cjs/*"
|
|
24
|
-
},
|
|
13
|
+
"./config": "./dist/config/index.js",
|
|
14
|
+
"./services/firebase": "./dist/services/firebase/index.js",
|
|
15
|
+
"./types": "./dist/types/index.js",
|
|
16
|
+
"./api": "./dist/api/index.js",
|
|
25
17
|
"./package.json": "./package.json"
|
|
26
18
|
},
|
|
27
19
|
"files": [
|
|
28
|
-
"dist
|
|
20
|
+
"dist"
|
|
29
21
|
],
|
|
30
22
|
"engines": {
|
|
31
23
|
"node": "24"
|
|
32
24
|
},
|
|
33
25
|
"scripts": {
|
|
34
|
-
"clean": "rm -rf dist .tsbuildinfo",
|
|
26
|
+
"clean": "rm -rf dist .tsbuildinfo node_modules",
|
|
35
27
|
"lint": "eslint \"src/**/*.{ts,tsx}\" --ext .ts,.tsx",
|
|
36
28
|
"update": "ncu -u && npm install",
|
|
37
|
-
"build": "tsc",
|
|
29
|
+
"build": "tsc -p tsconfig.json",
|
|
38
30
|
"update-own": "npm update --save @mxpicture/zod-meta"
|
|
39
31
|
},
|
|
40
32
|
"publishConfig": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FrontendApi.d.ts","sourceRoot":"","sources":["../../../src/base/FrontendApi.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EACV,MAAM,EACN,YAAY,EACZ,OAAO,EACP,YAAY,EACZ,eAAe,EACf,cAAc,EACf,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,iCAAiC,CAAC;AACvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAIxD,eAAO,MAAM,gBAAgB,GAC3B,GAAG,SAAS,YAAY,EACxB,IAAI,SAAS,MAAM,EAEnB,MAAM,YAAY,uGAOnB,CAAC;AAEF,qBAAa,WAAW,CAAC,GAAG,SAAS,YAAY,CAAE,SAAQ,IAAI,CAAC,GAAG,CAAC;aAO/B,IAAI,EAAE,YAAY;IANrD,SAAS,CAAC,QAAQ,CAAC,EAAE,aAAa,CAChC,eAAe,CAAC,GAAG,EAAE,MAAM,CAAC,EAC5B,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EACrC,OAAO,CACR,CAAC;gBAEiC,IAAI,EAAE,YAAY;cAIrC,OAAO;IAMD,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAMnC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAMxC,KAAK,IAAI,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;IAKhC,KAAK,IAAI,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAOnC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,OAAO,CAAA;KAAE,CAAC;IAYlD,IAAI,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;IAM3B,MAAM,CAAC,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAUxC,MAAM,CAAC,IAAI,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,EAAE,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC;CAatE"}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FrontendApi = exports.functionCallable = void 0;
|
|
4
|
-
const gcp_functions_common_1 = require("@mxpicture/gcp-functions-common");
|
|
5
|
-
const firebase_config_1 = require("../config/firebase.config");
|
|
6
|
-
const firebase_loader_1 = require("../loader/firebase.loader");
|
|
7
|
-
const functionCallable = async (name) => {
|
|
8
|
-
const { httpsCallable } = await (0, firebase_loader_1.loadFirebaseFunctions)();
|
|
9
|
-
return httpsCallable((await (0, firebase_config_1.configFirebase)()).functions, name);
|
|
10
|
-
};
|
|
11
|
-
exports.functionCallable = functionCallable;
|
|
12
|
-
class FrontendApi extends gcp_functions_common_1.IApi {
|
|
13
|
-
constructor(name) {
|
|
14
|
-
super();
|
|
15
|
-
this.name = name;
|
|
16
|
-
}
|
|
17
|
-
async service() {
|
|
18
|
-
if (!this._service)
|
|
19
|
-
this._service = await (0, exports.functionCallable)(this.name);
|
|
20
|
-
return this._service;
|
|
21
|
-
}
|
|
22
|
-
async delete(keys) {
|
|
23
|
-
await (await this.service())({ route: "delete", keys });
|
|
24
|
-
}
|
|
25
|
-
async get(keys) {
|
|
26
|
-
return (await (await (await this.service())({ route: "get", keys })).data)
|
|
27
|
-
.doc;
|
|
28
|
-
}
|
|
29
|
-
// todo add filter
|
|
30
|
-
async query() {
|
|
31
|
-
return (await (await (await this.service())({ route: "query" })).data)
|
|
32
|
-
.doc;
|
|
33
|
-
}
|
|
34
|
-
async count() {
|
|
35
|
-
return (await (await (await this.service())({ route: "count" })).data)
|
|
36
|
-
.doc;
|
|
37
|
-
}
|
|
38
|
-
async exists(keys) {
|
|
39
|
-
return (await (await (await this.service())({ route: "exists", keys })).data).doc;
|
|
40
|
-
}
|
|
41
|
-
async meta() {
|
|
42
|
-
// return new Meta(this.shape).items();
|
|
43
|
-
// todo
|
|
44
|
-
return [];
|
|
45
|
-
}
|
|
46
|
-
async create(data) {
|
|
47
|
-
return (await (await (await this.service())({ route: "create", content: data })).data).doc;
|
|
48
|
-
}
|
|
49
|
-
async update(keys, data) {
|
|
50
|
-
return (await (await (await this.service())({
|
|
51
|
-
route: "update",
|
|
52
|
-
keys,
|
|
53
|
-
content: data,
|
|
54
|
-
})).data).doc;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
exports.FrontendApi = FrontendApi;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { Auth } from "firebase/auth";
|
|
2
|
-
import type { FirebaseApp } from "firebase/app";
|
|
3
|
-
import type { Functions } from "firebase/functions";
|
|
4
|
-
import type { FirebaseConfig } from "../types";
|
|
5
|
-
export declare const initializeFirebase: (config: FirebaseConfig) => Promise<{
|
|
6
|
-
app: FirebaseApp;
|
|
7
|
-
auth: Auth;
|
|
8
|
-
functions: Functions;
|
|
9
|
-
}>;
|
|
10
|
-
export declare const configFirebase: () => Promise<{
|
|
11
|
-
app: FirebaseApp;
|
|
12
|
-
auth: Auth;
|
|
13
|
-
functions: Functions;
|
|
14
|
-
}>;
|
|
15
|
-
//# sourceMappingURL=firebase.config.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"firebase.config.d.ts","sourceRoot":"","sources":["../../../src/config/firebase.config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAe/C,eAAO,MAAM,kBAAkB,GAAU,QAAQ,cAAc;SAPxD,WAAW;UACV,IAAI;eACC,SAAS;EASrB,CAAC;AAEF,eAAO,MAAM,cAAc;SAbpB,WAAW;UACV,IAAI;eACC,SAAS;EAgCrB,CAAC"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.configFirebase = exports.initializeFirebase = void 0;
|
|
4
|
-
const firebase_loader_1 = require("../loader/firebase.loader");
|
|
5
|
-
let _inst = null;
|
|
6
|
-
let _config = null;
|
|
7
|
-
const initializeFirebase = async (config) => {
|
|
8
|
-
if (_config)
|
|
9
|
-
throw new Error("Firebase config already present");
|
|
10
|
-
_config = { ...config };
|
|
11
|
-
return (0, exports.configFirebase)();
|
|
12
|
-
};
|
|
13
|
-
exports.initializeFirebase = initializeFirebase;
|
|
14
|
-
const configFirebase = async () => {
|
|
15
|
-
if (!_inst) {
|
|
16
|
-
if (!_config)
|
|
17
|
-
throw new Error("Firebase config not provided. Use initializeFirebase at first");
|
|
18
|
-
const { getAuth } = await (0, firebase_loader_1.loadFirebaseAuth)();
|
|
19
|
-
const { getFunctions } = await (0, firebase_loader_1.loadFirebaseFunctions)();
|
|
20
|
-
const { initializeApp } = await (0, firebase_loader_1.loadFirebaseApp)();
|
|
21
|
-
// Initialize Firebase
|
|
22
|
-
const app = initializeApp(_config);
|
|
23
|
-
// Initialize Firebase services
|
|
24
|
-
const auth = getAuth(app);
|
|
25
|
-
const functions = getFunctions(app);
|
|
26
|
-
_inst = { app, auth, functions };
|
|
27
|
-
}
|
|
28
|
-
return _inst;
|
|
29
|
-
};
|
|
30
|
-
exports.configFirebase = configFirebase;
|
package/dist/cjs/index.d.ts
DELETED
package/dist/cjs/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,cAAc,OAAO,CAAC;AAItB,OAAO,KAAK,IAAI,MAAM,OAAO,CAAC;AAC9B,eAAe,IAAI,CAAC"}
|
package/dist/cjs/index.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
19
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
20
|
-
};
|
|
21
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
-
var ownKeys = function(o) {
|
|
23
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
-
var ar = [];
|
|
25
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
-
return ar;
|
|
27
|
-
};
|
|
28
|
-
return ownKeys(o);
|
|
29
|
-
};
|
|
30
|
-
return function (mod) {
|
|
31
|
-
if (mod && mod.__esModule) return mod;
|
|
32
|
-
var result = {};
|
|
33
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
-
__setModuleDefault(result, mod);
|
|
35
|
-
return result;
|
|
36
|
-
};
|
|
37
|
-
})();
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
// eslint-disable-next-line import/export
|
|
40
|
-
__exportStar(require("./lib"), exports);
|
|
41
|
-
// A default export can help some consumers using require()
|
|
42
|
-
// eslint-disable-next-line import/namespace
|
|
43
|
-
const _all = __importStar(require("./lib"));
|
|
44
|
-
exports.default = _all;
|
package/dist/cjs/lib.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export * from "./types/firebase.types.js";
|
|
2
|
-
export * from "./types/auth.types.js";
|
|
3
|
-
export * from "./types/index.js";
|
|
4
|
-
export * from "./config/firebase.config.js";
|
|
5
|
-
export * from "./base/FrontendApi.js";
|
|
6
|
-
export * from "./services/firebase/auth.service.js";
|
|
7
|
-
//# sourceMappingURL=lib.d.ts.map
|
package/dist/cjs/lib.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../../src/lib.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,qCAAqC,CAAC"}
|
package/dist/cjs/lib.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./types/firebase.types.js"), exports);
|
|
18
|
-
__exportStar(require("./types/auth.types.js"), exports);
|
|
19
|
-
__exportStar(require("./types/index.js"), exports);
|
|
20
|
-
__exportStar(require("./config/firebase.config.js"), exports);
|
|
21
|
-
__exportStar(require("./base/FrontendApi.js"), exports);
|
|
22
|
-
__exportStar(require("./services/firebase/auth.service.js"), exports);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"firebase.loader.d.ts","sourceRoot":"","sources":["../../../src/loader/firebase.loader.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,gBAAgB,+CAG5B,CAAC;AAEF,eAAO,MAAM,eAAe,8CAG3B,CAAC;AAEF,eAAO,MAAM,qBAAqB,oDAGjC,CAAC"}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.loadFirebaseFunctions = exports.loadFirebaseApp = exports.loadFirebaseAuth = void 0;
|
|
37
|
-
let authPromise = null;
|
|
38
|
-
let appPromise = null;
|
|
39
|
-
let functionsPromise = null;
|
|
40
|
-
const loadFirebaseAuth = () => {
|
|
41
|
-
if (!authPromise)
|
|
42
|
-
authPromise = Promise.resolve().then(() => __importStar(require("firebase/auth")));
|
|
43
|
-
return authPromise;
|
|
44
|
-
};
|
|
45
|
-
exports.loadFirebaseAuth = loadFirebaseAuth;
|
|
46
|
-
const loadFirebaseApp = () => {
|
|
47
|
-
if (!appPromise)
|
|
48
|
-
appPromise = Promise.resolve().then(() => __importStar(require("firebase/app")));
|
|
49
|
-
return appPromise;
|
|
50
|
-
};
|
|
51
|
-
exports.loadFirebaseApp = loadFirebaseApp;
|
|
52
|
-
const loadFirebaseFunctions = () => {
|
|
53
|
-
if (!functionsPromise)
|
|
54
|
-
functionsPromise = Promise.resolve().then(() => __importStar(require("firebase/functions")));
|
|
55
|
-
return functionsPromise;
|
|
56
|
-
};
|
|
57
|
-
exports.loadFirebaseFunctions = loadFirebaseFunctions;
|
package/dist/cjs/package.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"package.d.ts","sourceRoot":"","sources":["../../src/package.ts"],"names":[],"mappings":"AAKA,cAAc,OAAO,CAAC"}
|
package/dist/cjs/package.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// /// <reference path="./types/express.d.ts" />
|
|
3
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
-
if (k2 === undefined) k2 = k;
|
|
5
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
-
}
|
|
9
|
-
Object.defineProperty(o, k2, desc);
|
|
10
|
-
}) : (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
o[k2] = m[k];
|
|
13
|
-
}));
|
|
14
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
15
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
|
-
};
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
// Re-export your public types/exports so this file becomes the root .d.ts for the package.
|
|
19
|
-
// Adjust the relative path if your source layout differs.
|
|
20
|
-
// eslint-disable-next-line import/export
|
|
21
|
-
__exportStar(require("./lib"), exports);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth.service.d.ts","sourceRoot":"","sources":["../../../../src/services/firebase/auth.service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,QAAQ,EACR,gBAAgB,EAChB,mBAAmB,EACpB,MAAM,aAAa,CAAC;AAIrB,cAAM,WAAW;IACT,KAAK,CAAC,WAAW,EAAE,gBAAgB,GAAG,OAAO,CAAC,QAAQ,CAAC;IAgBvD,QAAQ,CAAC,WAAW,EAAE,mBAAmB,GAAG,OAAO,CAAC,QAAQ,CAAC;IAqB7D,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IASvB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAS3C,kBAAkB,CACtB,QAAQ,EAAE,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,KAAK,IAAI,GACxC,OAAO,CAAC,MAAM,IAAI,CAAC;IAOhB,cAAc,IAAI,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;IAKhD,OAAO,CAAC,yBAAyB;IAcjC,OAAO,CAAC,eAAe;CAcxB;AAED,eAAO,MAAM,WAAW,aAAoB,CAAC;AAC7C,eAAe,WAAW,CAAC"}
|