@mxpicture/gcp-functions-frontend 0.2.24 → 0.2.26

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,2 +1,3 @@
1
1
  export { authErrorText } from "./auth.helper.js";
2
+ export { guardValidationResult, guardValidationResultFields, } from "./validation.helper.js";
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helper/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helper/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EACL,qBAAqB,EACrB,2BAA2B,GAC5B,MAAM,wBAAwB,CAAC"}
@@ -1,3 +1,4 @@
1
1
  // This file is auto-generated. Do not edit manually.
2
2
  export { authErrorText } from "./auth.helper.js";
3
+ export { guardValidationResult, guardValidationResultFields, } from "./validation.helper.js";
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/helper/index.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/helper/index.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EACL,qBAAqB,EACrB,2BAA2B,GAC5B,MAAM,wBAAwB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { ValidationResult, ValidationResultFields } from "@mxpicture/gcp-functions-common/types";
2
+ export declare const guardValidationResult: (data: unknown) => ValidationResult | null;
3
+ export declare const guardValidationResultFields: (fields: unknown) => ValidationResultFields | null;
4
+ //# sourceMappingURL=validation.helper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.helper.d.ts","sourceRoot":"","sources":["../../src/helper/validation.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACvB,MAAM,uCAAuC,CAAC;AAG/C,eAAO,MAAM,qBAAqB,GAChC,MAAM,OAAO,KACZ,gBAAgB,GAAG,IAerB,CAAC;AAEF,eAAO,MAAM,2BAA2B,GACtC,QAAQ,OAAO,KACd,sBAAsB,GAAG,IAc3B,CAAC"}
@@ -0,0 +1,31 @@
1
+ import { FunctionsError } from "firebase/functions";
2
+ export const guardValidationResult = (data) => {
3
+ if (data instanceof FunctionsError)
4
+ return guardValidationResult(data.details);
5
+ if (!data || Array.isArray(data))
6
+ return null;
7
+ const partData = data;
8
+ if (!partData.errorFields)
9
+ return null;
10
+ const errorFields = guardValidationResultFields(partData.errorFields);
11
+ return errorFields
12
+ ? {
13
+ errorFields,
14
+ }
15
+ : null;
16
+ };
17
+ export const guardValidationResultFields = (fields) => {
18
+ if (!fields || typeof fields !== "object" || Array.isArray(fields))
19
+ return null;
20
+ const result = {};
21
+ for (const [fieldname, messages] of Object.entries(fields)) {
22
+ if (!messages || !Array.isArray(messages))
23
+ continue;
24
+ result[fieldname] = [];
25
+ for (const message of messages)
26
+ if (typeof message === "string")
27
+ result[fieldname].push(message);
28
+ }
29
+ return result;
30
+ };
31
+ //# sourceMappingURL=validation.helper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.helper.js","sourceRoot":"","sources":["../../src/helper/validation.helper.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,IAAa,EACY,EAAE;IAC3B,IAAI,IAAI,YAAY,cAAc;QAChC,OAAO,qBAAqB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAE7C,IAAI,CAAC,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IAE9C,MAAM,QAAQ,GAAG,IAAiC,CAAC;IACnD,IAAI,CAAC,QAAQ,CAAC,WAAW;QAAE,OAAO,IAAI,CAAC;IAEvC,MAAM,WAAW,GAAG,2BAA2B,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IACtE,OAAO,WAAW;QAChB,CAAC,CAAC;YACE,WAAW;SACZ;QACH,CAAC,CAAC,IAAI,CAAC;AACX,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,2BAA2B,GAAG,CACzC,MAAe,EACgB,EAAE;IACjC,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;QAChE,OAAO,IAAI,CAAC;IAEd,MAAM,MAAM,GAA2B,EAAE,CAAC;IAE1C,KAAK,MAAM,CAAC,SAAS,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAC3D,IAAI,CAAC,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC;YAAE,SAAS;QAEpD,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC;QACvB,KAAK,MAAM,OAAO,IAAI,QAAQ;YAC5B,IAAI,OAAO,OAAO,KAAK,QAAQ;gBAAE,MAAM,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACrE,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mxpicture/gcp-functions-frontend",
3
- "version": "0.2.24",
3
+ "version": "0.2.26",
4
4
  "description": "Utils for google cloud functions, publishing both CommonJS and ESM builds",
5
5
  "type": "module",
6
6
  "author": "MXPicture",
@@ -33,7 +33,7 @@
33
33
  "access": "public"
34
34
  },
35
35
  "dependencies": {
36
- "@mxpicture/gcp-functions-common": "^0.2.24",
36
+ "@mxpicture/gcp-functions-common": "^0.2.26",
37
37
  "firebase": "^12.9.0"
38
38
  },
39
39
  "devDependencies": {