@mxpicture/gcp-functions 0.1.3 → 0.1.7

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/cjs/lib.js CHANGED
@@ -14,13 +14,16 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./types/types.common.js"), exports);
17
+ __exportStar(require("./types/types.httpHandler.js"), exports);
18
+ __exportStar(require("./types/types.document.js"), exports);
18
19
  __exportStar(require("./types/types.function.js"), exports);
20
+ __exportStar(require("./types/express.d.js"), exports);
19
21
  __exportStar(require("./types/types.apiRoutes.js"), exports);
20
22
  __exportStar(require("./common/firebase.js"), exports);
21
- __exportStar(require("./lib.js"), exports);
22
- __exportStar(require("./index.js"), exports);
23
+ __exportStar(require("./FunctionCollection.js"), exports);
24
+ __exportStar(require("./base/BaseHttp.js"), exports);
25
+ __exportStar(require("./base/BaseFunction.js"), exports);
26
+ __exportStar(require("./base/BaseApi.js"), exports);
23
27
  __exportStar(require("./validation/Validation.js"), exports);
24
- __exportStar(require("./package.js"), exports);
25
28
  __exportStar(require("./store/types.store.js"), exports);
26
29
  __exportStar(require("./store/Store.js"), exports);
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.documentKeySchema = exports.documentKeyShape = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.documentKeyShape = {
6
+ id: zod_1.z.string().optional(),
7
+ createTime: zod_1.z.date().optional(),
8
+ updateTime: zod_1.z.date().optional(),
9
+ };
10
+ exports.documentKeySchema = zod_1.z.object(exports.documentKeyShape);
package/dist/esm/lib.js CHANGED
@@ -14,13 +14,16 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./types/types.common.js"), exports);
17
+ __exportStar(require("./types/types.httpHandler.js"), exports);
18
+ __exportStar(require("./types/types.document.js"), exports);
18
19
  __exportStar(require("./types/types.function.js"), exports);
20
+ __exportStar(require("./types/express.d.js"), exports);
19
21
  __exportStar(require("./types/types.apiRoutes.js"), exports);
20
22
  __exportStar(require("./common/firebase.js"), exports);
21
- __exportStar(require("./lib.js"), exports);
22
- __exportStar(require("./index.js"), exports);
23
+ __exportStar(require("./FunctionCollection.js"), exports);
24
+ __exportStar(require("./base/BaseHttp.js"), exports);
25
+ __exportStar(require("./base/BaseFunction.js"), exports);
26
+ __exportStar(require("./base/BaseApi.js"), exports);
23
27
  __exportStar(require("./validation/Validation.js"), exports);
24
- __exportStar(require("./package.js"), exports);
25
28
  __exportStar(require("./store/types.store.js"), exports);
26
29
  __exportStar(require("./store/Store.js"), exports);
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.documentKeySchema = exports.documentKeyShape = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.documentKeyShape = {
6
+ id: zod_1.z.string().optional(),
7
+ createTime: zod_1.z.date().optional(),
8
+ updateTime: zod_1.z.date().optional(),
9
+ };
10
+ exports.documentKeySchema = zod_1.z.object(exports.documentKeyShape);
@@ -1,5 +1,5 @@
1
1
  import { BaseFunction } from "./base/BaseFunction";
2
- import { DocumentData } from "./types/types.common";
2
+ import { DocumentData } from "./types/types.document";
3
3
  export declare class FunctionCollection {
4
4
  protected funcs: {
5
5
  [key: string]: BaseFunction<any>;
@@ -1,7 +1,7 @@
1
1
  import { MetaItem } from "@mxpicture/zod-meta";
2
2
  import { ApiRoutes, ApiFromRoutes, ApiKey } from "../types/types.apiRoutes";
3
3
  import { Store } from "../store/Store";
4
- import { DocumentData, WithKey } from "../types/types.common";
4
+ import { DocumentData, WithKey } from "../types/types.document";
5
5
  import { Validation } from "../validation/Validation";
6
6
  import { ZodRawShape } from "zod";
7
7
  export declare class BaseApi<DTO extends DocumentData> implements ApiFromRoutes<ApiRoutes<DTO>> {
@@ -1,6 +1,6 @@
1
1
  import { HttpsFunction } from "firebase-functions/https";
2
2
  import { HttpHandlers } from "../types/types.httpHandler";
3
- import { DocumentData } from "../types/types.common";
3
+ import { DocumentData } from "../types/types.document";
4
4
  import { ApiRoutes } from "../types/types.apiRoutes";
5
5
  export declare class BaseFunction<DTO extends DocumentData> {
6
6
  protected http: HttpHandlers<ApiRoutes<DTO>>;
@@ -2,13 +2,13 @@ import { ApiKey, ApiRoutes } from "../types/types.apiRoutes";
2
2
  import { FunctionPayload } from "../types/types.function";
3
3
  import { HttpHandlers } from "../types/types.httpHandler";
4
4
  import { BaseApi } from "./BaseApi";
5
- import { DocumentData } from "../types/types.common";
5
+ import { DocumentData } from "../types/types.document";
6
6
  export declare class BaseHttp<DTO extends DocumentData> implements HttpHandlers<ApiRoutes<DTO>> {
7
7
  protected api: BaseApi<DTO>;
8
8
  constructor(api: BaseApi<DTO>);
9
9
  delete(req: FunctionPayload<never, ApiKey>): Promise<void>;
10
- get(req: FunctionPayload<never, ApiKey>): Promise<import("../types/types.common").WithKey<DTO>>;
11
- query(): Promise<import("../types/types.common").WithKey<DTO>[]>;
10
+ get(req: FunctionPayload<never, ApiKey>): Promise<import("../types/types.document").WithKey<DTO>>;
11
+ query(): Promise<import("../types/types.document").WithKey<DTO>[]>;
12
12
  count(): Promise<{
13
13
  count: number;
14
14
  }>;
@@ -16,6 +16,6 @@ export declare class BaseHttp<DTO extends DocumentData> implements HttpHandlers<
16
16
  exists: boolean;
17
17
  }>;
18
18
  meta(): Promise<import("@mxpicture/zod-meta").MetaItem[]>;
19
- create(req: FunctionPayload<DTO>): Promise<import("../types/types.common").WithKey<DTO>>;
20
- update(req: FunctionPayload<Partial<DTO>, ApiKey>): Promise<import("../types/types.common").WithKey<DTO>>;
19
+ create(req: FunctionPayload<DTO>): Promise<import("../types/types.document").WithKey<DTO>>;
20
+ update(req: FunctionPayload<Partial<DTO>, ApiKey>): Promise<import("../types/types.document").WithKey<DTO>>;
21
21
  }
@@ -1,11 +1,14 @@
1
- export * from "./types/types.common.js";
1
+ export * from "./types/types.httpHandler.js";
2
+ export * from "./types/types.document.js";
2
3
  export * from "./types/types.function.js";
4
+ export * from "./types/express.d.js";
3
5
  export * from "./types/types.apiRoutes.js";
4
6
  export * from "./common/firebase.js";
5
- export * from "./lib.js";
6
- export * from "./index.js";
7
+ export * from "./FunctionCollection.js";
8
+ export * from "./base/BaseHttp.js";
9
+ export * from "./base/BaseFunction.js";
10
+ export * from "./base/BaseApi.js";
7
11
  export * from "./validation/Validation.js";
8
- export * from "./package.js";
9
12
  export * from "./store/types.store.js";
10
13
  export * from "./store/Store.js";
11
14
  export { ZodRawShape, ZodSafeParseResult } from "zod";
@@ -1,5 +1,5 @@
1
1
  import { CollectionReference, DocumentReference, FirestoreDataConverter } from "firebase-admin/firestore";
2
- import { DocumentData, WithKey } from "../types/types.common.js";
2
+ import { DocumentData, WithKey } from "../types/types.document.js";
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
1
  import { MetaItem } from "@mxpicture/zod-meta";
2
- import { DocumentData, WithKey } from "./types.common.js";
2
+ import { DocumentData, WithKey } from "./types.document.js";
3
3
  export type ApiRouteDef<KEYS, PAYLOAD, RESULT> = {
4
4
  keys: KEYS;
5
5
  payload: PAYLOAD;
@@ -0,0 +1,17 @@
1
+ import { z } from "zod";
2
+ export type DocumentFieldValue = any;
3
+ export type DocumentData = {
4
+ [field: string]: DocumentFieldValue;
5
+ };
6
+ export declare const documentKeyShape: {
7
+ id: z.ZodOptional<z.ZodString>;
8
+ createTime: z.ZodOptional<z.ZodDate>;
9
+ updateTime: z.ZodOptional<z.ZodDate>;
10
+ };
11
+ export declare const documentKeySchema: z.ZodObject<{
12
+ id: z.ZodOptional<z.ZodString>;
13
+ createTime: z.ZodOptional<z.ZodDate>;
14
+ updateTime: z.ZodOptional<z.ZodDate>;
15
+ }, z.core.$strip>;
16
+ export type DocumentKey = z.infer<typeof documentKeySchema>;
17
+ export type WithKey<DTO extends DocumentData> = DocumentKey & DTO;
@@ -1,6 +1,6 @@
1
1
  import { Store } from "../store/Store";
2
2
  import { ZodError, ZodObject, ZodRawShape } from "zod";
3
- import { DocumentData, WithKey } from "../types/types.common";
3
+ import { DocumentData, WithKey } from "../types/types.document";
4
4
  export type ValidationFieldErrors = Record<string, string[]>;
5
5
  export declare class Validation<DTO extends DocumentData> {
6
6
  readonly store: Store<DTO>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mxpicture/gcp-functions",
3
- "version": "0.1.3",
3
+ "version": "0.1.7",
4
4
  "description": "Utils for google cloud functions, publishing both CommonJS and ESM builds",
5
5
  "author": "MXPicture",
6
6
  "license": "MIT",
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,10 +0,0 @@
1
- export type DocumentFieldValue = any;
2
- export type DocumentData = {
3
- [field: string]: DocumentFieldValue;
4
- };
5
- export interface DocumentKey {
6
- id?: string;
7
- createTime?: Date;
8
- updateTime?: Date;
9
- }
10
- export type WithKey<DTO extends DocumentData> = DocumentKey & DTO;