@mxpicture/gcp-functions-frontend 0.1.48 → 0.1.50
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.
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type { MetaItem } from "@mxpicture/
|
|
2
|
-
import type { DocumentData, WithKey,
|
|
1
|
+
import type { MetaItem } from "@mxpicture/gcp-functions-common/meta";
|
|
2
|
+
import type { DocumentData, WithKey, ApiFromRoutes, CrudRoutes, WithoutKey, DocumentKey, ApiFilter } from "@mxpicture/gcp-functions-common/types";
|
|
3
3
|
import { IFrontendApi } from "./IFrontendApi.js";
|
|
4
4
|
import { IFrontendFunction } from "../function/IFrontendFunction.js";
|
|
5
5
|
export declare abstract class FrontendApi<DTO extends DocumentData, FUNC extends IFrontendFunction> extends IFrontendApi<FUNC> implements ApiFromRoutes<CrudRoutes<DTO>> {
|
|
6
|
-
constructor(funcC: CallbackAble<FUNC>);
|
|
7
6
|
delete(request: DocumentKey): Promise<{
|
|
8
7
|
deleted: true;
|
|
9
8
|
}>;
|
package/dist/api/FrontendApi.js
CHANGED
|
@@ -1,32 +1,35 @@
|
|
|
1
1
|
import { IFrontendApi } from "./IFrontendApi.js";
|
|
2
2
|
export class FrontendApi extends IFrontendApi {
|
|
3
|
-
constructor(funcC) {
|
|
4
|
-
super(funcC);
|
|
5
|
-
}
|
|
6
3
|
async delete(request) {
|
|
7
|
-
return (await
|
|
4
|
+
return (await this.func().outgress({ route: "delete", data: request }))
|
|
5
|
+
.data;
|
|
8
6
|
}
|
|
9
7
|
async get(request) {
|
|
10
|
-
return (await
|
|
8
|
+
return (await this.func().outgress({ route: "get", data: request }))
|
|
11
9
|
.data;
|
|
12
10
|
}
|
|
13
11
|
async query(request) {
|
|
14
|
-
return (await
|
|
12
|
+
return (await this.func().outgress({ route: "query", data: request }))
|
|
13
|
+
.data;
|
|
15
14
|
}
|
|
16
15
|
async count(request) {
|
|
17
|
-
return (await
|
|
16
|
+
return (await this.func().outgress({ route: "count", data: request }))
|
|
17
|
+
.data;
|
|
18
18
|
}
|
|
19
19
|
async exists(request) {
|
|
20
|
-
return (await
|
|
20
|
+
return (await this.func().outgress({ route: "exists", data: request }))
|
|
21
|
+
.data;
|
|
21
22
|
}
|
|
22
23
|
async meta() {
|
|
23
|
-
return (await
|
|
24
|
+
return (await this.func().outgress({ route: "meta", data: null }))
|
|
24
25
|
.data;
|
|
25
26
|
}
|
|
26
27
|
async create(request) {
|
|
27
|
-
return (await
|
|
28
|
+
return (await this.func().outgress({ route: "create", data: request }))
|
|
29
|
+
.data;
|
|
28
30
|
}
|
|
29
31
|
async update(request) {
|
|
30
|
-
return (await
|
|
32
|
+
return (await this.func().outgress({ route: "update", data: request }))
|
|
33
|
+
.data;
|
|
31
34
|
}
|
|
32
35
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type { CallbackAble } from "@mxpicture/gcp-functions-common/types";
|
|
2
1
|
import { IFrontendFunction } from "../function/IFrontendFunction.js";
|
|
3
|
-
export declare class IFrontendApi<FUNC extends IFrontendFunction> {
|
|
4
|
-
|
|
2
|
+
export declare abstract class IFrontendApi<FUNC extends IFrontendFunction> {
|
|
3
|
+
readonly name: string;
|
|
5
4
|
protected _func?: FUNC;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
constructor(name: string);
|
|
6
|
+
useFunc(func: FUNC): void;
|
|
7
|
+
protected func(): FUNC;
|
|
9
8
|
}
|
package/dist/api/IFrontendApi.js
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import { callableUnwrap } from "@mxpicture/gcp-functions-common/helper";
|
|
2
1
|
export class IFrontendApi {
|
|
3
|
-
|
|
2
|
+
name;
|
|
4
3
|
_func;
|
|
5
|
-
constructor(
|
|
6
|
-
this.
|
|
4
|
+
constructor(name) {
|
|
5
|
+
this.name = name;
|
|
7
6
|
}
|
|
8
|
-
|
|
7
|
+
useFunc(func) {
|
|
8
|
+
this._func = func;
|
|
9
|
+
}
|
|
10
|
+
func() {
|
|
9
11
|
if (!this._func)
|
|
10
|
-
this.
|
|
12
|
+
throw new Error(`${this.name}: func not provided. Use "useFunc" method`);
|
|
11
13
|
return this._func;
|
|
12
14
|
}
|
|
13
|
-
async name() {
|
|
14
|
-
return (await this.func()).name;
|
|
15
|
-
}
|
|
16
15
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { DocumentData, FunctionRequest, FunctionResponse } from "@mxpicture/gcp-functions-common/types";
|
|
2
2
|
import { HttpsCallable } from "firebase/functions";
|
|
3
|
-
export declare class IFrontendFunction {
|
|
3
|
+
export declare abstract class IFrontendFunction {
|
|
4
4
|
readonly name: string;
|
|
5
5
|
protected readonly routes: string[];
|
|
6
6
|
protected _func?: HttpsCallable<FunctionRequest<any>, Promise<FunctionResponse<any>>, unknown>;
|
|
7
|
-
|
|
7
|
+
constructor(name: string, routes: string[]);
|
|
8
8
|
outgress<REQ, RES extends DocumentData>(request: FunctionRequest<REQ>): Promise<FunctionResponse<RES>>;
|
|
9
9
|
protected func(): HttpsCallable<FunctionRequest<any>, Promise<FunctionResponse<any>>, unknown>;
|
|
10
10
|
}
|
|
@@ -4,7 +4,7 @@ import { authErrorText } from "../../helper/auth.helper.js";
|
|
|
4
4
|
class AuthService {
|
|
5
5
|
async login(credentials) {
|
|
6
6
|
try {
|
|
7
|
-
const { user } = await signInWithEmailAndPassword(
|
|
7
|
+
const { user } = await signInWithEmailAndPassword(configFirebase().auth, credentials.email, credentials.password);
|
|
8
8
|
return this.mapFirebaseUserToAuthUser(user);
|
|
9
9
|
}
|
|
10
10
|
catch (error) {
|
|
@@ -13,7 +13,7 @@ class AuthService {
|
|
|
13
13
|
}
|
|
14
14
|
async loginWithGoogle() {
|
|
15
15
|
try {
|
|
16
|
-
const config =
|
|
16
|
+
const config = configFirebase();
|
|
17
17
|
const { user } = await signInWithPopup(config.auth, config.googleProvider);
|
|
18
18
|
return this.mapFirebaseUserToAuthUser(user);
|
|
19
19
|
}
|
|
@@ -23,7 +23,7 @@ class AuthService {
|
|
|
23
23
|
}
|
|
24
24
|
async register(credentials) {
|
|
25
25
|
try {
|
|
26
|
-
const { user } = await createUserWithEmailAndPassword(
|
|
26
|
+
const { user } = await createUserWithEmailAndPassword(configFirebase().auth, credentials.email, credentials.password);
|
|
27
27
|
// Store additional user data in Firestore
|
|
28
28
|
// const userService = new UserService()
|
|
29
29
|
// await userService.createUserProfile(user.uid, credentials)
|
|
@@ -35,7 +35,7 @@ class AuthService {
|
|
|
35
35
|
}
|
|
36
36
|
async logout() {
|
|
37
37
|
try {
|
|
38
|
-
await signOut(
|
|
38
|
+
await signOut(configFirebase().auth);
|
|
39
39
|
}
|
|
40
40
|
catch (error) {
|
|
41
41
|
throw this.handleAuthError(error);
|
|
@@ -43,19 +43,19 @@ class AuthService {
|
|
|
43
43
|
}
|
|
44
44
|
async resetPassword(email) {
|
|
45
45
|
try {
|
|
46
|
-
await sendPasswordResetEmail(
|
|
46
|
+
await sendPasswordResetEmail(configFirebase().auth, email);
|
|
47
47
|
}
|
|
48
48
|
catch (error) {
|
|
49
49
|
throw this.handleAuthError(error);
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
async onAuthStateChanged(callback) {
|
|
53
|
-
return onAuthStateChanged(
|
|
53
|
+
return onAuthStateChanged(configFirebase().auth, (user) => {
|
|
54
54
|
callback(user ? this.mapFirebaseUserToAuthUser(user) : null);
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
57
|
async getCurrentUser() {
|
|
58
|
-
const user =
|
|
58
|
+
const user = configFirebase().auth.currentUser;
|
|
59
59
|
return user ? this.mapFirebaseUserToAuthUser(user) : null;
|
|
60
60
|
}
|
|
61
61
|
mapFirebaseUserToAuthUser(user) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mxpicture/gcp-functions-frontend",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.50",
|
|
4
4
|
"description": "Utils for google cloud functions, publishing both CommonJS and ESM builds",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "MXPicture",
|
|
@@ -28,19 +28,19 @@
|
|
|
28
28
|
"clean": "rm -rf dist .tsbuildinfo tsconfig.tsbuildinfo node_modules",
|
|
29
29
|
"lint": "eslint \"src/**/*.{ts,tsx}\" --ext .ts,.tsx",
|
|
30
30
|
"update": "ncu -u && npm install",
|
|
31
|
-
"build": "tsc -b ."
|
|
32
|
-
"update-own": "npm update --save @mxpicture/zod-meta"
|
|
31
|
+
"build": "tsc -b ."
|
|
33
32
|
},
|
|
34
33
|
"publishConfig": {
|
|
35
34
|
"access": "public"
|
|
36
35
|
},
|
|
37
36
|
"dependencies": {
|
|
38
37
|
"@mxpicture/gcp-functions-common": "*",
|
|
39
|
-
"@mxpicture/zod-meta": "^0.1.12",
|
|
40
38
|
"firebase": "^12.8.0"
|
|
41
39
|
},
|
|
42
40
|
"devDependencies": {
|
|
43
41
|
"@types/node": "^25.2.0",
|
|
42
|
+
"@typescript-eslint/eslint-plugin": "^8.55.0",
|
|
43
|
+
"@typescript-eslint/parser": "^8.55.0",
|
|
44
44
|
"typescript": "^5.9.3"
|
|
45
45
|
}
|
|
46
46
|
}
|