@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.
@@ -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
  }
@@ -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 readonly routes: string[];
5
+ protected _routes?: string[];
6
6
  protected _func?: HttpsCallable<FunctionRequest<any>, Promise<FunctionResponse<any>>, unknown>;
7
- constructor(name: string, routes: 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
- routes;
5
+ _routes;
6
6
  _func;
7
- constructor(name, routes) {
7
+ constructor(name) {
8
8
  this.name = name;
9
- this.routes = routes;
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.routes.find((m) => m === request.route))
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
  }
@@ -11,4 +11,4 @@ declare class AuthService {
11
11
  private handleAuthError;
12
12
  }
13
13
  export declare const authService: AuthService;
14
- export default authService;
14
+ export {};
@@ -78,4 +78,3 @@ class AuthService {
78
78
  }
79
79
  }
80
80
  export const authService = new AuthService();
81
- export default authService;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mxpicture/gcp-functions-frontend",
3
- "version": "0.1.50",
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
  }