@mxpicture/gcp-functions-common 0.2.1 → 0.2.2

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.
@@ -0,0 +1 @@
1
+ export * from "./path.common.js";
@@ -0,0 +1,2 @@
1
+ // This file is auto-generated. Do not edit manually.
2
+ export * from "./path.common.js";
@@ -0,0 +1,24 @@
1
+ export declare enum BasePathType {
2
+ packages = "packages",
3
+ root = "root"
4
+ }
5
+ export declare enum WsPathType {
6
+ backend = "backend",
7
+ code = "code",
8
+ common = "common",
9
+ frontend = "frontend",
10
+ fs = "fs",
11
+ generator = "generator"
12
+ }
13
+ export type BasePath = Record<BasePathType, string>;
14
+ export declare const basePaths: BasePath;
15
+ export type WsPath = Record<WsPathType, string>;
16
+ export declare const wsPaths: WsPath;
17
+ export interface CurrentPaths extends BasePath {
18
+ pkgDirName: string;
19
+ wsName: string;
20
+ packageJsonPath: string;
21
+ }
22
+ export declare const changelogPath: string;
23
+ export declare const packageJsonPath: (type: WsPathType) => string;
24
+ export declare const createCurrentWsPaths: (currentPath: string) => CurrentPaths;
@@ -0,0 +1,53 @@
1
+ import { dirname, isAbsolute, join, relative, resolve, sep } from "path";
2
+ import { fileURLToPath } from "url";
3
+ const __dirname = dirname(fileURLToPath(import.meta.url));
4
+ const packagesDir = resolve(__dirname, "../../..");
5
+ export var BasePathType;
6
+ (function (BasePathType) {
7
+ BasePathType["packages"] = "packages";
8
+ BasePathType["root"] = "root";
9
+ })(BasePathType || (BasePathType = {}));
10
+ export var WsPathType;
11
+ (function (WsPathType) {
12
+ WsPathType["backend"] = "backend";
13
+ WsPathType["code"] = "code";
14
+ WsPathType["common"] = "common";
15
+ WsPathType["frontend"] = "frontend";
16
+ WsPathType["fs"] = "fs";
17
+ WsPathType["generator"] = "generator";
18
+ })(WsPathType || (WsPathType = {}));
19
+ export const basePaths = {
20
+ [BasePathType.packages]: packagesDir,
21
+ [BasePathType.root]: resolve(packagesDir, ".."),
22
+ };
23
+ export const wsPaths = {
24
+ [WsPathType.backend]: join(packagesDir, WsPathType.backend),
25
+ [WsPathType.code]: join(packagesDir, WsPathType.code),
26
+ [WsPathType.common]: join(packagesDir, WsPathType.common),
27
+ [WsPathType.frontend]: join(packagesDir, WsPathType.frontend),
28
+ [WsPathType.fs]: join(packagesDir, WsPathType.fs),
29
+ [WsPathType.generator]: join(packagesDir, WsPathType.generator),
30
+ };
31
+ export const changelogPath = join(wsPaths.code, "changelog.json");
32
+ export const packageJsonPath = (type) => join(wsPaths[type], "package.json");
33
+ export const createCurrentWsPaths = (currentPath) => {
34
+ const res = isAbsolute(currentPath)
35
+ ? relative(basePaths.root, changelogPath)
36
+ : currentPath;
37
+ const parts = res.split(sep);
38
+ const pkgDirName = parts.shift();
39
+ if (pkgDirName !== "packages")
40
+ throw new Error(`Unsuppoted location. expected: packages/*, got: ${res}`);
41
+ const _wsName = parts.shift();
42
+ if (!_wsName)
43
+ throw new Error(`Unsuppoted workpace. expected: packages/*, got: ${res}`);
44
+ const wsName = _wsName;
45
+ if (!Object.values(WsPathType).includes(wsName))
46
+ throw new Error(`Unsuppoted workpace: ${res}`);
47
+ return {
48
+ ...basePaths,
49
+ pkgDirName,
50
+ wsName,
51
+ packageJsonPath: packageJsonPath(wsName),
52
+ };
53
+ };
@@ -12,7 +12,7 @@
12
12
  * tradeNames!: string[];
13
13
  * }
14
14
  */
15
- import { MetaPropertyType, MetaNumberFormat, MetaStringFormat, MetaHeadType, MetaTargetType } from "../meta/meta.enum.js";
15
+ import { MetaPropertyType, MetaHeadType, MetaTargetType } from "../meta/meta.enum.js";
16
16
  import { MetaHeadData } from "../meta/meta.main.js";
17
17
  export interface MetaRouteParams {
18
18
  requestType: string;
@@ -63,7 +63,6 @@ export interface MetaNumberOptions extends MetaPropertyBaseOptions {
63
63
  max?: number;
64
64
  maxInclusive?: boolean;
65
65
  multipleOf?: number;
66
- format?: MetaNumberFormat;
67
66
  }
68
67
  export interface MetaKeyOptions extends MetaPropertyBaseOptions {
69
68
  type: MetaPropertyType.key;
@@ -80,7 +79,6 @@ export interface MetaStringOptions extends MetaPropertyBaseOptions {
80
79
  maxLength?: number;
81
80
  exactLength?: number;
82
81
  regex?: string;
83
- format?: MetaStringFormat | string;
84
82
  }
85
83
  export interface MetaArrayOptions extends MetaPropertyBaseOptions {
86
84
  type: MetaPropertyType.array;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mxpicture/gcp-functions-common",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Utils for google cloud functions, publishing both CommonJS and ESM builds",
5
5
  "type": "module",
6
6
  "author": "MXPicture",
@@ -15,6 +15,7 @@
15
15
  "./zod": "./dist/zod/index.js",
16
16
  "./helper": "./dist/helper/index.js",
17
17
  "./meta": "./dist/meta/index.js",
18
+ "./path": "./dist/path/index.js",
18
19
  "./package.json": "./package.json"
19
20
  },
20
21
  "files": [