@mxpicture/gcp-functions-frontend 0.1.23 → 0.1.25
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.
|
@@ -2,12 +2,12 @@ import type { MetaItem } from "@mxpicture/zod-meta";
|
|
|
2
2
|
import type { ApiKey, DocumentData, WithKey, FunctionPayload, FunctionResult } from "@mxpicture/gcp-functions-common/types";
|
|
3
3
|
import { IApi } from "@mxpicture/gcp-functions-common/api";
|
|
4
4
|
import { type HttpsCallable } from "firebase/functions";
|
|
5
|
-
export declare const functionCallable: <DTO extends DocumentData, KEYS extends ApiKey>(name: string) => Promise<HttpsCallable<FunctionPayload<DTO, KEYS>,
|
|
5
|
+
export declare const functionCallable: <DTO extends DocumentData, KEYS extends ApiKey>(name: string) => Promise<HttpsCallable<FunctionPayload<DTO, KEYS>, FunctionResult<WithKey<DTO>>, unknown>>;
|
|
6
6
|
export declare class FrontendApi<DTO extends DocumentData> extends IApi<DTO> {
|
|
7
7
|
readonly name: string;
|
|
8
|
-
protected _service?: HttpsCallable<FunctionPayload<DTO, ApiKey>,
|
|
8
|
+
protected _service?: HttpsCallable<FunctionPayload<DTO, ApiKey>, FunctionResult<WithKey<DTO>>, unknown>;
|
|
9
9
|
constructor(name: string);
|
|
10
|
-
protected service(): Promise<HttpsCallable<FunctionPayload<DTO, ApiKey>,
|
|
10
|
+
protected service(): Promise<HttpsCallable<FunctionPayload<DTO, ApiKey>, FunctionResult<WithKey<DTO>>, unknown>>;
|
|
11
11
|
delete(keys: ApiKey): Promise<void>;
|
|
12
12
|
get(keys: ApiKey): Promise<WithKey<DTO>>;
|
|
13
13
|
query(): Promise<WithKey<DTO>[]>;
|
package/dist/api/FrontendApi.js
CHANGED
|
@@ -20,20 +20,21 @@ export class FrontendApi extends IApi {
|
|
|
20
20
|
await (await this.service())({ route: "delete", keys });
|
|
21
21
|
}
|
|
22
22
|
async get(keys) {
|
|
23
|
-
return (await (await
|
|
23
|
+
return (await (await this.service())({ route: "get", keys })).data
|
|
24
24
|
.doc;
|
|
25
25
|
}
|
|
26
26
|
// todo add filter
|
|
27
27
|
async query() {
|
|
28
|
-
return (await (await
|
|
28
|
+
return (await (await this.service())({ route: "query" })).data
|
|
29
29
|
.doc;
|
|
30
30
|
}
|
|
31
31
|
async count() {
|
|
32
|
-
return (await (await
|
|
32
|
+
return (await (await this.service())({ route: "count" })).data
|
|
33
33
|
.doc;
|
|
34
34
|
}
|
|
35
35
|
async exists(keys) {
|
|
36
|
-
return (await (await
|
|
36
|
+
return (await (await this.service())({ route: "exists", keys })).data
|
|
37
|
+
.doc;
|
|
37
38
|
}
|
|
38
39
|
async meta() {
|
|
39
40
|
// return new Meta(this.shape).items();
|
|
@@ -41,13 +42,14 @@ export class FrontendApi extends IApi {
|
|
|
41
42
|
return [];
|
|
42
43
|
}
|
|
43
44
|
async create(data) {
|
|
44
|
-
return (await (await
|
|
45
|
+
return (await (await this.service())({ route: "create", content: data }))
|
|
46
|
+
.data.doc;
|
|
45
47
|
}
|
|
46
48
|
async update(keys, data) {
|
|
47
|
-
return (await (await
|
|
49
|
+
return (await (await this.service())({
|
|
48
50
|
route: "update",
|
|
49
51
|
keys,
|
|
50
52
|
content: data,
|
|
51
|
-
})).data
|
|
53
|
+
})).data.doc;
|
|
52
54
|
}
|
|
53
55
|
}
|