@mxpicture/gcp-functions-frontend 0.1.50 → 0.1.52
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/api/FrontendApi.d.ts +0 -2
- package/dist/api/FrontendApi.js +0 -4
- package/dist/function/IFrontendFunction.d.ts +5 -2
- package/dist/function/IFrontendFunction.js +14 -4
- package/dist/services/firebase/auth.service.d.ts +1 -1
- package/dist/services/firebase/auth.service.js +0 -1
- package/package.json +1 -4
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { MetaItem } from "@mxpicture/gcp-functions-common/meta";
|
|
2
1
|
import type { DocumentData, WithKey, ApiFromRoutes, CrudRoutes, WithoutKey, DocumentKey, ApiFilter } from "@mxpicture/gcp-functions-common/types";
|
|
3
2
|
import { IFrontendApi } from "./IFrontendApi.js";
|
|
4
3
|
import { IFrontendFunction } from "../function/IFrontendFunction.js";
|
|
@@ -14,7 +13,6 @@ export declare abstract class FrontendApi<DTO extends DocumentData, FUNC extends
|
|
|
14
13
|
exists(request: DocumentKey): Promise<{
|
|
15
14
|
exists: boolean;
|
|
16
15
|
}>;
|
|
17
|
-
meta(): Promise<MetaItem[]>;
|
|
18
16
|
create(request: WithoutKey<DTO>): Promise<WithKey<DTO>>;
|
|
19
17
|
update(request: WithKey<Partial<DTO>>): Promise<WithKey<DTO>>;
|
|
20
18
|
}
|
package/dist/api/FrontendApi.js
CHANGED
|
@@ -20,10 +20,6 @@ export class FrontendApi extends IFrontendApi {
|
|
|
20
20
|
return (await this.func().outgress({ route: "exists", data: request }))
|
|
21
21
|
.data;
|
|
22
22
|
}
|
|
23
|
-
async meta() {
|
|
24
|
-
return (await this.func().outgress({ route: "meta", data: null }))
|
|
25
|
-
.data;
|
|
26
|
-
}
|
|
27
23
|
async create(request) {
|
|
28
24
|
return (await this.func().outgress({ route: "create", data: request }))
|
|
29
25
|
.data;
|
|
@@ -2,9 +2,12 @@ import type { DocumentData, FunctionRequest, FunctionResponse } from "@mxpicture
|
|
|
2
2
|
import { HttpsCallable } from "firebase/functions";
|
|
3
3
|
export declare abstract class IFrontendFunction {
|
|
4
4
|
readonly name: string;
|
|
5
|
-
protected
|
|
5
|
+
protected _routes?: string[];
|
|
6
6
|
protected _func?: HttpsCallable<FunctionRequest<any>, Promise<FunctionResponse<any>>, unknown>;
|
|
7
|
-
constructor(name: string
|
|
7
|
+
constructor(name: string);
|
|
8
|
+
useRoutes(routes: string[]): void;
|
|
9
|
+
protected routes(): string[];
|
|
10
|
+
protected hasRoute(name: string): boolean;
|
|
8
11
|
outgress<REQ, RES extends DocumentData>(request: FunctionRequest<REQ>): Promise<FunctionResponse<RES>>;
|
|
9
12
|
protected func(): HttpsCallable<FunctionRequest<any>, Promise<FunctionResponse<any>>, unknown>;
|
|
10
13
|
}
|
|
@@ -2,14 +2,24 @@ import { httpsCallable } from "firebase/functions";
|
|
|
2
2
|
import { configFirebase } from "../config/firebase.config.js";
|
|
3
3
|
export class IFrontendFunction {
|
|
4
4
|
name;
|
|
5
|
-
|
|
5
|
+
_routes;
|
|
6
6
|
_func;
|
|
7
|
-
constructor(name
|
|
7
|
+
constructor(name) {
|
|
8
8
|
this.name = name;
|
|
9
|
-
|
|
9
|
+
}
|
|
10
|
+
useRoutes(routes) {
|
|
11
|
+
this._routes = routes;
|
|
12
|
+
}
|
|
13
|
+
routes() {
|
|
14
|
+
if (!this._routes)
|
|
15
|
+
throw new Error(`${this.name}: routes not provided. Use "useRoutes" method`);
|
|
16
|
+
return this._routes;
|
|
17
|
+
}
|
|
18
|
+
hasRoute(name) {
|
|
19
|
+
return !!this.routes().find((m) => m === name);
|
|
10
20
|
}
|
|
11
21
|
async outgress(request) {
|
|
12
|
-
if (!this.
|
|
22
|
+
if (!this.hasRoute(request.route))
|
|
13
23
|
throw new Error(`Route ${request.route} not available`);
|
|
14
24
|
return (await this.func()(request)).data;
|
|
15
25
|
}
|
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.52",
|
|
4
4
|
"description": "Utils for google cloud functions, publishing both CommonJS and ESM builds",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "MXPicture",
|
|
@@ -27,7 +27,6 @@
|
|
|
27
27
|
"scripts": {
|
|
28
28
|
"clean": "rm -rf dist .tsbuildinfo tsconfig.tsbuildinfo node_modules",
|
|
29
29
|
"lint": "eslint \"src/**/*.{ts,tsx}\" --ext .ts,.tsx",
|
|
30
|
-
"update": "ncu -u && npm install",
|
|
31
30
|
"build": "tsc -b ."
|
|
32
31
|
},
|
|
33
32
|
"publishConfig": {
|
|
@@ -39,8 +38,6 @@
|
|
|
39
38
|
},
|
|
40
39
|
"devDependencies": {
|
|
41
40
|
"@types/node": "^25.2.0",
|
|
42
|
-
"@typescript-eslint/eslint-plugin": "^8.55.0",
|
|
43
|
-
"@typescript-eslint/parser": "^8.55.0",
|
|
44
41
|
"typescript": "^5.9.3"
|
|
45
42
|
}
|
|
46
43
|
}
|