@mxpicture/gcp-functions-backend 0.1.34 → 0.1.43

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,32 +1,23 @@
1
1
  import type { MetaItem } from "@mxpicture/zod-meta";
2
- import type { ApiKey, ApiFilter, DocumentData, WithKey, CallbackAble } from "@mxpicture/gcp-functions-common/types";
3
- import { IApi } from "@mxpicture/gcp-functions-common/api";
2
+ import type { DocumentData, WithKey, CallbackAble, ApiFromRoutes, CrudRoutes, WithoutKey, DocumentKey, ApiFilter } from "@mxpicture/gcp-functions-common/types";
4
3
  import { Store } from "../store/Store.js";
5
4
  import type { Validation } from "../validation/Validation.js";
6
5
  import type { ZodRawShape } from "zod";
7
- export declare class BackendApi<DTO extends DocumentData, STORE extends Store<DTO> = Store<DTO>, VAL extends Validation<DTO> = Validation<DTO>> extends IApi<DTO> {
8
- protected readonly storeC: CallbackAble<STORE>;
9
- protected readonly validationC: CallbackAble<VAL>;
10
- protected readonly shapeC: CallbackAble<ZodRawShape>;
11
- protected _store?: STORE;
12
- protected _validation?: VAL;
13
- protected _shape?: ZodRawShape;
6
+ import { IBackendApi } from "./IBackendApi.js";
7
+ export declare class BackendApi<DTO extends DocumentData, STORE extends Store<DTO> = Store<DTO>, VAL extends Validation<DTO> = Validation<DTO>> extends IBackendApi<DTO, STORE, VAL> implements ApiFromRoutes<CrudRoutes<DTO>> {
14
8
  constructor(storeC: CallbackAble<STORE>, validationC: CallbackAble<VAL>, shapeC: CallbackAble<ZodRawShape>);
15
- protected store(): Promise<STORE>;
16
- protected validation(): Promise<VAL>;
17
- protected shape(): Promise<ZodRawShape>;
18
- delete(p: ApiKey): Promise<void>;
19
- get(p: ApiKey): Promise<WithKey<DTO>>;
20
- query(payload?: ApiFilter): Promise<WithKey<DTO>[]>;
21
- count(payload?: ApiFilter): Promise<{
9
+ delete(request: DocumentKey): Promise<{
10
+ deleted: true;
11
+ }>;
12
+ get(request: DocumentKey): Promise<WithKey<DTO>>;
13
+ query(request?: ApiFilter | null): Promise<WithKey<DTO>[]>;
14
+ count(request?: ApiFilter | null): Promise<{
22
15
  count: number;
23
16
  }>;
24
- exists(p: ApiKey): Promise<{
17
+ exists(request: DocumentKey): Promise<{
25
18
  exists: boolean;
26
19
  }>;
27
20
  meta(): Promise<MetaItem[]>;
28
- create(data: DTO): Promise<WithKey<DTO>>;
29
- update(p: {
30
- id: string;
31
- }, data: Partial<DTO>): Promise<WithKey<DTO>>;
21
+ create(request: WithoutKey<DTO>): Promise<WithKey<DTO>>;
22
+ update(request: WithKey<Partial<DTO>>): Promise<WithKey<DTO>>;
32
23
  }
@@ -1,58 +1,34 @@
1
1
  import { Meta } from "@mxpicture/zod-meta";
2
- import { IApi } from "@mxpicture/gcp-functions-common/api";
3
- import { callableUnwrap } from "@mxpicture/gcp-functions-common/helper";
4
- export class BackendApi extends IApi {
5
- storeC;
6
- validationC;
7
- shapeC;
8
- _store;
9
- _validation;
10
- _shape;
2
+ import { IBackendApi } from "./IBackendApi.js";
3
+ export class BackendApi extends IBackendApi {
11
4
  constructor(storeC, validationC, shapeC) {
12
- super();
13
- this.storeC = storeC;
14
- this.validationC = validationC;
15
- this.shapeC = shapeC;
5
+ super(storeC, validationC, shapeC);
16
6
  }
17
- async store() {
18
- if (!this._store)
19
- this._store = await callableUnwrap(this.storeC);
20
- return this._store;
7
+ async delete(request) {
8
+ await (await this.store()).delete(request.id);
9
+ return { deleted: true };
21
10
  }
22
- async validation() {
23
- if (!this._validation)
24
- this._validation = await callableUnwrap(this.validationC);
25
- return this._validation;
11
+ async get(request) {
12
+ return (await this.store()).get(request.id);
26
13
  }
27
- async shape() {
28
- if (!this._shape)
29
- this._shape = await callableUnwrap(this.shapeC);
30
- return this._shape;
14
+ async query(request) {
15
+ return (await this.store()).query(request?.filters);
31
16
  }
32
- async delete(p) {
33
- return (await this.store()).delete(p.id);
17
+ async count(request) {
18
+ return { count: await (await this.store()).count(request?.filters) };
34
19
  }
35
- async get(p) {
36
- return (await this.store()).get(p.id);
37
- }
38
- async query(payload) {
39
- return (await this.store()).query(payload?.filters);
40
- }
41
- async count(payload) {
42
- return { count: await (await this.store()).count(payload?.filters) };
43
- }
44
- async exists(p) {
45
- return { exists: await (await this.store()).exists(p.id) };
20
+ async exists(request) {
21
+ return { exists: await (await this.store()).exists(request.id) };
46
22
  }
47
23
  async meta() {
48
24
  return new Meta(await this.shape()).items();
49
25
  }
50
- async create(data) {
51
- const result = await (await this.validation()).validate(data);
26
+ async create(request) {
27
+ const result = await (await this.validation()).validate(request);
52
28
  return (await this.store()).create(result);
53
29
  }
54
- async update(p, data) {
55
- const result = await (await this.validation()).validatePartial(data);
56
- return (await this.store()).update(p.id, result);
30
+ async update(request) {
31
+ const result = await (await this.validation()).validatePartial(request);
32
+ return (await this.store()).update(request.id, result);
57
33
  }
58
34
  }
@@ -0,0 +1,16 @@
1
+ import type { DocumentData, CallbackAble } from "@mxpicture/gcp-functions-common/types";
2
+ import { Store } from "../store/Store.js";
3
+ import type { Validation } from "../validation/Validation.js";
4
+ import type { ZodRawShape } from "zod";
5
+ export declare class IBackendApi<DTO extends DocumentData, STORE extends Store<DTO> = Store<DTO>, VAL extends Validation<DTO> = Validation<DTO>> {
6
+ protected readonly storeC: CallbackAble<STORE>;
7
+ protected readonly validationC: CallbackAble<VAL>;
8
+ protected readonly shapeC: CallbackAble<ZodRawShape>;
9
+ protected _store?: STORE;
10
+ protected _validation?: VAL;
11
+ protected _shape?: ZodRawShape;
12
+ protected constructor(storeC: CallbackAble<STORE>, validationC: CallbackAble<VAL>, shapeC: CallbackAble<ZodRawShape>);
13
+ protected store(): Promise<STORE>;
14
+ protected validation(): Promise<VAL>;
15
+ protected shape(): Promise<ZodRawShape>;
16
+ }
@@ -0,0 +1,29 @@
1
+ import { callableUnwrap } from "@mxpicture/gcp-functions-common/helper";
2
+ export class IBackendApi {
3
+ storeC;
4
+ validationC;
5
+ shapeC;
6
+ _store;
7
+ _validation;
8
+ _shape;
9
+ constructor(storeC, validationC, shapeC) {
10
+ this.storeC = storeC;
11
+ this.validationC = validationC;
12
+ this.shapeC = shapeC;
13
+ }
14
+ async store() {
15
+ if (!this._store)
16
+ this._store = await callableUnwrap(this.storeC);
17
+ return this._store;
18
+ }
19
+ async validation() {
20
+ if (!this._validation)
21
+ this._validation = await callableUnwrap(this.validationC);
22
+ return this._validation;
23
+ }
24
+ async shape() {
25
+ if (!this._shape)
26
+ this._shape = await callableUnwrap(this.shapeC);
27
+ return this._shape;
28
+ }
29
+ }
@@ -1 +1,2 @@
1
1
  export { BackendApi } from "./BackendApi.js";
2
+ export { IBackendApi } from "./IBackendApi.js";
package/dist/api/index.js CHANGED
@@ -1 +1,2 @@
1
1
  export { BackendApi } from "./BackendApi.js";
2
+ export { IBackendApi } from "./IBackendApi.js";
@@ -1,11 +1,22 @@
1
- import { CallableFunction } from "firebase-functions/https";
2
- import type { HttpHandlers, DocumentData, WithKey, ApiRoutes, FunctionPayload, FunctionResult, CallbackAble } from "@mxpicture/gcp-functions-common/types";
3
- export declare class BackendFunction<DTO extends DocumentData, HANDLER extends HttpHandlers<ApiRoutes<DTO>> = HttpHandlers<ApiRoutes<DTO>>> {
4
- readonly name: string;
5
- protected httpC: CallbackAble<HANDLER>;
6
- protected readonly httpMethods: string[];
7
- protected _http?: HANDLER;
8
- constructor(name: string, httpC: CallbackAble<HANDLER>);
9
- protected http(): Promise<HANDLER>;
10
- createFunction(): CallableFunction<FunctionPayload<DTO>, Promise<FunctionResult<WithKey<DTO>>>>;
1
+ import type { DocumentData, CallbackAble, CrudRoutes, ApiFilter, DocumentKey, WithKey, WithoutKey } from "@mxpicture/gcp-functions-common/types";
2
+ import { BackendApi } from "../api/BackendApi.js";
3
+ import { FunctionFromRoutes, FunctionResponse } from "../../../common/src/types/types.function.js";
4
+ import { MetaItem } from "@mxpicture/zod-meta";
5
+ import { IBackendFunction } from "./IBackendFunction.js";
6
+ export declare class BackendFunction<DTO extends DocumentData, API extends BackendApi<DTO>> extends IBackendFunction<DTO, API> implements FunctionFromRoutes<CrudRoutes<DTO>> {
7
+ constructor(name: string, apiC: CallbackAble<API>);
8
+ create(request: WithoutKey<DTO>): Promise<FunctionResponse<WithKey<DTO>>>;
9
+ update(request: WithKey<Partial<DTO>>): Promise<FunctionResponse<WithKey<DTO>>>;
10
+ delete(request: DocumentKey): Promise<FunctionResponse<{
11
+ deleted: true;
12
+ }>>;
13
+ get(request: DocumentKey): Promise<FunctionResponse<WithKey<DTO>>>;
14
+ query(request: ApiFilter | null | undefined): Promise<FunctionResponse<WithKey<DTO>[]>>;
15
+ count(request: ApiFilter | null | undefined): Promise<FunctionResponse<{
16
+ count: number;
17
+ }>>;
18
+ exists(request: DocumentKey): Promise<FunctionResponse<{
19
+ exists: boolean;
20
+ }>>;
21
+ meta(): Promise<FunctionResponse<MetaItem[]>>;
11
22
  }
@@ -1,29 +1,31 @@
1
- import { HttpsError, onCall } from "firebase-functions/https";
2
- import { API_ROUTES_METHODS } from "@mxpicture/gcp-functions-common/config";
3
- import { callableUnwrap } from "@mxpicture/gcp-functions-common/helper";
4
- export class BackendFunction {
5
- name;
6
- httpC;
7
- httpMethods;
8
- _http;
9
- constructor(name, httpC) {
10
- this.name = name;
11
- this.httpC = httpC;
12
- this.httpMethods = API_ROUTES_METHODS;
13
- }
14
- async http() {
15
- if (!this._http)
16
- this._http = await callableUnwrap(this.httpC);
17
- return this._http;
18
- }
19
- createFunction() {
20
- return onCall(async (req) => {
21
- if (!this.httpMethods.find((m) => m === req.data.route))
22
- throw new HttpsError("invalid-argument", `Route ${req.data.route} not available`);
23
- return {
24
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
25
- doc: await (await this.http())[req.data.route](req.data),
26
- };
27
- });
1
+ import { IBackendFunction } from "./IBackendFunction.js";
2
+ import { CRUD_ROUTES } from "@mxpicture/gcp-functions-common/config";
3
+ export class BackendFunction extends IBackendFunction {
4
+ constructor(name, apiC) {
5
+ super(name, apiC, CRUD_ROUTES);
6
+ }
7
+ async create(request) {
8
+ return this.ingress({ data: request, route: "create" });
9
+ }
10
+ async update(request) {
11
+ return this.ingress({ data: request, route: "update" });
12
+ }
13
+ async delete(request) {
14
+ return this.ingress({ data: request, route: "delete" });
15
+ }
16
+ async get(request) {
17
+ return this.ingress({ data: request, route: "get" });
18
+ }
19
+ async query(request) {
20
+ return this.ingress({ data: request, route: "query" });
21
+ }
22
+ async count(request) {
23
+ return this.ingress({ data: request, route: "count" });
24
+ }
25
+ async exists(request) {
26
+ return this.ingress({ data: request, route: "exists" });
27
+ }
28
+ async meta() {
29
+ return this.ingress({ route: "meta", data: null });
28
30
  }
29
31
  }
@@ -0,0 +1,14 @@
1
+ import type { DocumentData, CallbackAble } from "@mxpicture/gcp-functions-common/types";
2
+ import { BackendApi } from "../api/BackendApi.js";
3
+ import { CallableFunction } from "firebase-functions/v2/https";
4
+ import { FunctionRequest, FunctionResponse } from "../../../common/src/types/types.function.js";
5
+ export declare class IBackendFunction<DTO extends DocumentData, API extends BackendApi<DTO>> {
6
+ readonly name: string;
7
+ protected apiC: CallbackAble<API>;
8
+ protected readonly routes: string[];
9
+ protected _api?: API;
10
+ protected constructor(name: string, apiC: CallbackAble<API>, routes: string[]);
11
+ protected api(): Promise<API>;
12
+ ingress<REQ, RES extends DocumentData>(request: FunctionRequest<REQ>): Promise<FunctionResponse<RES>>;
13
+ buildFunction(): CallableFunction<FunctionRequest<any>, Promise<FunctionResponse<any>>>;
14
+ }
@@ -0,0 +1,38 @@
1
+ import { onCall, HttpsError, } from "firebase-functions/v2/https";
2
+ import { callableUnwrap } from "@mxpicture/gcp-functions-common/helper";
3
+ export class IBackendFunction {
4
+ name;
5
+ apiC;
6
+ routes;
7
+ _api;
8
+ constructor(name, apiC, routes) {
9
+ this.name = name;
10
+ this.apiC = apiC;
11
+ this.routes = routes;
12
+ }
13
+ async api() {
14
+ if (!this._api)
15
+ this._api = await callableUnwrap(this.apiC);
16
+ return this._api;
17
+ }
18
+ async ingress(request) {
19
+ if (!this.routes.find((m) => m === request.route))
20
+ throw new HttpsError("invalid-argument", `Route ${request.route} not available`);
21
+ try {
22
+ return {
23
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
24
+ data: await (await this.api())[request.route](request.data),
25
+ };
26
+ }
27
+ catch (error) {
28
+ if (error instanceof HttpsError)
29
+ throw error;
30
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
31
+ throw new HttpsError("internal", error?.message ?? "unknown");
32
+ // }
33
+ }
34
+ }
35
+ buildFunction() {
36
+ return onCall(async (req) => this.ingress(req.data));
37
+ }
38
+ }
@@ -1,2 +1,2 @@
1
1
  export { BackendFunction } from "./BackendFunction.js";
2
- export { FunctionCollection } from "./FunctionCollection.js";
2
+ export { IBackendFunction } from "./IBackendFunction.js";
@@ -1,2 +1,2 @@
1
1
  export { BackendFunction } from "./BackendFunction.js";
2
- export { FunctionCollection } from "./FunctionCollection.js";
2
+ export { IBackendFunction } from "./IBackendFunction.js";
@@ -1,5 +1,5 @@
1
1
  import type { CollectionReference, DocumentReference, FirestoreDataConverter, Query, QuerySnapshot } from "firebase-admin/firestore";
2
- import type { DocumentData, WithKey, ApiFilterItems } from "@mxpicture/gcp-functions-common/types";
2
+ import type { ApiFilterItems, DocumentData, WithKey } from "@mxpicture/gcp-functions-common/types";
3
3
  export declare class Store<DTO extends DocumentData> {
4
4
  readonly collectionName: string;
5
5
  protected readonly converter?: FirestoreDataConverter<DTO> | undefined;
@@ -1,5 +1,5 @@
1
- import type { ZodError, ZodObject, ZodRawShape } from "zod";
2
- import type { CallbackAble, DocumentData, WithKey } from "@mxpicture/gcp-functions-common/types";
1
+ import { type ZodError, type ZodObject, type ZodRawShape } from "zod";
2
+ import type { CallbackAble, DocumentData, WithKey, WithoutKey } from "@mxpicture/gcp-functions-common/types";
3
3
  import { ValidationFieldErrors } from "../types/types.validation.js";
4
4
  export declare class Validation<DTO extends DocumentData> {
5
5
  protected shapeC: CallbackAble<ZodRawShape>;
@@ -10,7 +10,7 @@ export declare class Validation<DTO extends DocumentData> {
10
10
  protected shape(): Promise<ZodRawShape>;
11
11
  protected createSchema(): Promise<ZodObject>;
12
12
  protected updateSchema(): Promise<ZodObject>;
13
- validate(doc: Partial<WithKey<DTO>>): Promise<WithKey<DTO>>;
13
+ validate(doc: Partial<WithoutKey<DTO>>): Promise<WithKey<DTO>>;
14
14
  validatePartial(doc: Partial<WithKey<DTO>>): Promise<Partial<WithKey<DTO>>>;
15
15
  protected issuesToFieldErrors(issues: ZodError["issues"]): ValidationFieldErrors;
16
16
  }
@@ -1,5 +1,5 @@
1
+ import { z } from "zod";
1
2
  import { HttpsError } from "firebase-functions/https";
2
- import { loadZod } from "../loader/zod.loader.js";
3
3
  import { callableUnwrap } from "@mxpicture/gcp-functions-common/helper";
4
4
  export class Validation {
5
5
  shapeC;
@@ -16,7 +16,7 @@ export class Validation {
16
16
  }
17
17
  async createSchema() {
18
18
  if (!this._createSchema)
19
- this._createSchema = (await loadZod()).object(await this.shape());
19
+ this._createSchema = z.object(await this.shape());
20
20
  return this._createSchema;
21
21
  }
22
22
  async updateSchema() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mxpicture/gcp-functions-backend",
3
- "version": "0.1.34",
3
+ "version": "0.1.43",
4
4
  "description": "Utils for google cloud functions, publishing both CommonJS and ESM builds",
5
5
  "type": "module",
6
6
  "author": "MXPicture",
@@ -14,7 +14,6 @@
14
14
  "./firebase": "./dist/firebase/index.js",
15
15
  "./validation": "./dist/validation/index.js",
16
16
  "./api": "./dist/api/index.js",
17
- "./http": "./dist/http/index.js",
18
17
  "./function": "./dist/function/index.js",
19
18
  "./types": "./dist/types/index.js",
20
19
  "./package.json": "./package.json"
@@ -1,11 +0,0 @@
1
- import { HttpsFunction } from "firebase-functions/https";
2
- import { BackendFunction } from "./BackendFunction.js";
3
- import type { DocumentData } from "@mxpicture/gcp-functions-common/types";
4
- export declare class FunctionCollection {
5
- protected funcs: {
6
- [key: string]: BackendFunction<any>;
7
- };
8
- constructor();
9
- add<DTO extends DocumentData>(func: BackendFunction<DTO>, name?: string): FunctionCollection;
10
- build(): Record<string, HttpsFunction>;
11
- }
@@ -1,15 +0,0 @@
1
- export class FunctionCollection {
2
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
3
- funcs = {};
4
- constructor() { }
5
- add(func, name) {
6
- this.funcs[name ?? func.name] = func;
7
- return this;
8
- }
9
- build() {
10
- const r = {};
11
- for (const [key, func] of Object.entries(this.funcs))
12
- r[key] = func.createFunction();
13
- return r;
14
- }
15
- }
@@ -1,20 +0,0 @@
1
- import type { HttpHandlers, FunctionPayload, ApiFilter, ApiKey, ApiRoutes, DocumentData, CallbackAble } from "@mxpicture/gcp-functions-common/types";
2
- import { BackendApi } from "../api/BackendApi.js";
3
- export declare class BackendHttp<DTO extends DocumentData, API extends BackendApi<DTO> = BackendApi<DTO>> implements HttpHandlers<ApiRoutes<DTO>> {
4
- protected apiC: CallbackAble<API>;
5
- protected _api?: API;
6
- constructor(apiC: CallbackAble<API>);
7
- protected api(): Promise<API>;
8
- delete(req: FunctionPayload<never, ApiKey>): Promise<void>;
9
- get(req: FunctionPayload<never, ApiKey>): Promise<import("@mxpicture/gcp-functions-common/types").WithKey<DTO>>;
10
- query(req: FunctionPayload<ApiFilter>): Promise<import("@mxpicture/gcp-functions-common/types").WithKey<DTO>[]>;
11
- count(req: FunctionPayload<ApiFilter>): Promise<{
12
- count: number;
13
- }>;
14
- exists(req: FunctionPayload<never, ApiKey>): Promise<{
15
- exists: boolean;
16
- }>;
17
- meta(): Promise<import("@mxpicture/zod-meta").MetaItem[]>;
18
- create(req: FunctionPayload<DTO>): Promise<import("@mxpicture/gcp-functions-common/types").WithKey<DTO>>;
19
- update(req: FunctionPayload<Partial<DTO>, ApiKey>): Promise<import("@mxpicture/gcp-functions-common/types").WithKey<DTO>>;
20
- }
@@ -1,110 +0,0 @@
1
- import { HttpsError } from "firebase-functions/https";
2
- import { callableUnwrap } from "@mxpicture/gcp-functions-common/helper";
3
- export class BackendHttp {
4
- apiC;
5
- _api;
6
- constructor(apiC) {
7
- this.apiC = apiC;
8
- }
9
- async api() {
10
- if (!this._api)
11
- this._api = await callableUnwrap(this.apiC);
12
- return this._api;
13
- }
14
- async delete(req) {
15
- try {
16
- const id = req.keys?.id;
17
- if (!id)
18
- throw new HttpsError("invalid-argument", "Id invalid");
19
- await (await this.api()).delete({ id });
20
- }
21
- catch (error) {
22
- if (error instanceof HttpsError)
23
- throw error;
24
- throw new HttpsError("not-found", `Id ${req.keys?.id} not found`);
25
- }
26
- }
27
- async get(req) {
28
- try {
29
- const id = req.keys?.id;
30
- if (!id)
31
- throw new HttpsError("invalid-argument", "Id invalid");
32
- return (await this.api()).get({ id });
33
- }
34
- catch (error) {
35
- if (error instanceof HttpsError)
36
- throw error;
37
- throw new HttpsError("not-found", `Id ${req.keys?.id} not found`);
38
- }
39
- }
40
- async query(req) {
41
- try {
42
- return (await this.api()).query(req.content);
43
- }
44
- catch (error) {
45
- if (error instanceof HttpsError)
46
- throw error;
47
- throw new HttpsError("unknown", "Unknown error");
48
- }
49
- }
50
- async count(req) {
51
- try {
52
- return (await this.api()).count(req.content);
53
- }
54
- catch (error) {
55
- if (error instanceof HttpsError)
56
- throw error;
57
- throw new HttpsError("unknown", "Unknown error");
58
- }
59
- }
60
- async exists(req) {
61
- try {
62
- const id = req.keys?.id;
63
- if (!id)
64
- throw new HttpsError("invalid-argument", "Id invalid");
65
- return await (await this.api()).exists({ id });
66
- }
67
- catch (error) {
68
- if (error instanceof HttpsError)
69
- throw error;
70
- throw new HttpsError("unknown", "Unknown error");
71
- }
72
- }
73
- async meta() {
74
- try {
75
- return (await this.api()).meta();
76
- }
77
- catch (error) {
78
- if (error instanceof HttpsError)
79
- throw error;
80
- throw new HttpsError("unknown", "Unknown error");
81
- }
82
- }
83
- async create(req) {
84
- try {
85
- if (!req.content)
86
- throw new HttpsError("invalid-argument", "Content is invalid");
87
- return (await this.api()).create(req.content);
88
- }
89
- catch (error) {
90
- if (error instanceof HttpsError)
91
- throw error;
92
- throw new HttpsError("unknown", "Unknown error");
93
- }
94
- }
95
- async update(req) {
96
- try {
97
- const id = req.keys?.id;
98
- if (!id)
99
- throw new HttpsError("invalid-argument", "Id invalid");
100
- if (!req.content)
101
- throw new HttpsError("invalid-argument", "Content is invalid");
102
- return (await this.api()).update({ id }, req.content);
103
- }
104
- catch (error) {
105
- if (error instanceof HttpsError)
106
- throw error;
107
- throw new HttpsError("unknown", "Unknown error");
108
- }
109
- }
110
- }
@@ -1 +0,0 @@
1
- export { BackendHttp } from "./BackendHttp.js";
@@ -1 +0,0 @@
1
- export { BackendHttp } from "./BackendHttp.js";
@@ -1 +0,0 @@
1
- export declare const loadZod: () => Promise<typeof import("zod")>;
@@ -1,6 +0,0 @@
1
- let zodPromise = null;
2
- export const loadZod = () => {
3
- if (!zodPromise)
4
- zodPromise = import("zod");
5
- return zodPromise;
6
- };