@dereekb/firebase-server 10.1.28 → 10.1.30

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/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [10.1.30](https://github.com/dereekb/dbx-components/compare/v10.1.29-dev...v10.1.30) (2024-10-23)
6
+
7
+
8
+
9
+ ## [10.1.29](https://github.com/dereekb/dbx-components/compare/v10.1.28-dev...v10.1.29) (2024-10-20)
10
+
11
+
12
+
5
13
  ## [10.1.28](https://github.com/dereekb/dbx-components/compare/v10.1.27-dev...v10.1.28) (2024-10-12)
6
14
 
7
15
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dereekb/firebase-server/mailgun",
3
- "version": "10.1.28",
3
+ "version": "10.1.30",
4
4
  "type": "commonjs",
5
5
  "main": "./src/index.js"
6
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dereekb/firebase-server",
3
- "version": "10.1.28",
3
+ "version": "10.1.30",
4
4
  "exports": {
5
5
  ".": {
6
6
  "types": "./src/index.d.ts",
@@ -1,3 +1,4 @@
1
+ import { type ValidationError } from 'class-validator';
1
2
  import { type TransformAndValidateFunctionResultFactory, type TransformAndValidateObjectFactory } from '@dereekb/model';
2
3
  /**
3
4
  * Context used for building FirebaseServerActions. It contains references to reusable factories.
@@ -19,4 +20,26 @@ export interface FirebaseServerActionsTransformContext {
19
20
  readonly firebaseServerActionTransformFunctionFactory: TransformAndValidateFunctionResultFactory;
20
21
  }
21
22
  export declare function firebaseServerActionsTransformContext(logError?: FirebaseServerActionsTransformFactoryLogErrorFunctionInput): FirebaseServerActionsTransformContext;
23
+ export declare const FIREBASE_SERVER_VALIDATION_ERROR_CODE = "VALIDATION_ERROR";
24
+ /**
25
+ *
26
+ * @param validationError
27
+ * @returns
28
+ */
29
+ export declare function firebaseServerValidationServerError(validationError: ValidationError[]): {
30
+ message: string;
31
+ code: string;
32
+ data: string | object;
33
+ };
34
+ /**
35
+ * Creates a new badRequestError with the validation error details as the response data.
36
+ *
37
+ * @param validationError
38
+ * @returns
39
+ */
40
+ export declare function firebaseServerValidationError(validationError: ValidationError[]): import("firebase-functions/v1/auth").HttpsError;
22
41
  export declare function firebaseServerActionsTransformFactory(logError?: FirebaseServerActionsTransformFactoryLogErrorFunctionInput): TransformAndValidateObjectFactory;
42
+ /**
43
+ * @deprecated mispelling. Use FIREBASE_SERVER_VALIDATION_ERROR_CODE instead.
44
+ */
45
+ export declare const FIRESTBASE_SERVER_VALIDATION_ERROR_CODE = "VALIDATION_ERROR";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.firebaseServerActionsTransformFactory = exports.firebaseServerActionsTransformContext = exports.defaultFirebaseServerActionsTransformFactoryLogErrorFunction = exports.firebaseServerActionsContext = exports.AbstractFirebaseServerActionsContext = void 0;
3
+ exports.FIRESTBASE_SERVER_VALIDATION_ERROR_CODE = exports.firebaseServerActionsTransformFactory = exports.firebaseServerValidationError = exports.firebaseServerValidationServerError = exports.FIREBASE_SERVER_VALIDATION_ERROR_CODE = exports.firebaseServerActionsTransformContext = exports.defaultFirebaseServerActionsTransformFactoryLogErrorFunction = exports.firebaseServerActionsContext = exports.AbstractFirebaseServerActionsContext = void 0;
4
4
  const model_1 = require("@dereekb/model");
5
5
  const common_1 = require("@nestjs/common");
6
6
  const util_1 = require("@dereekb/util");
@@ -25,21 +25,49 @@ function firebaseServerActionsTransformContext(logError) {
25
25
  };
26
26
  }
27
27
  exports.firebaseServerActionsTransformContext = firebaseServerActionsTransformContext;
28
- function firebaseServerActionsTransformFactory(logError = false) {
28
+ exports.FIREBASE_SERVER_VALIDATION_ERROR_CODE = 'VALIDATION_ERROR';
29
+ /**
30
+ *
31
+ * @param validationError
32
+ * @returns
33
+ */
34
+ function firebaseServerValidationServerError(validationError) {
29
35
  const nestValidationExceptionFactory = new common_1.ValidationPipe().createExceptionFactory();
36
+ const nestError = nestValidationExceptionFactory(validationError);
37
+ const data = nestError.getResponse();
38
+ return {
39
+ message: 'One or more data/form validation errors occurred.',
40
+ code: exports.FIREBASE_SERVER_VALIDATION_ERROR_CODE,
41
+ data
42
+ };
43
+ }
44
+ exports.firebaseServerValidationServerError = firebaseServerValidationServerError;
45
+ /**
46
+ * Creates a new badRequestError with the validation error details as the response data.
47
+ *
48
+ * @param validationError
49
+ * @returns
50
+ */
51
+ function firebaseServerValidationError(validationError) {
52
+ const serverError = firebaseServerValidationServerError(validationError);
53
+ return (0, error_1.badRequestError)(serverError);
54
+ }
55
+ exports.firebaseServerValidationError = firebaseServerValidationError;
56
+ function firebaseServerActionsTransformFactory(logError = false) {
30
57
  const logErrorFunction = logError !== false ? (typeof logError === 'function' ? logError : exports.defaultFirebaseServerActionsTransformFactoryLogErrorFunction) : util_1.mapIdentityFunction;
31
58
  return (0, model_1.transformAndValidateObjectFactory)({
32
59
  handleValidationError: (validationError) => {
33
- const nestError = nestValidationExceptionFactory(validationError);
34
- const details = nestError.getResponse();
35
- logErrorFunction(details);
36
- throw (0, error_1.badRequestError)({
37
- code: 'VALIDATION_ERROR',
38
- message: 'One or more data/form validation errors occurred.',
39
- data: details
40
- });
60
+ const serverError = firebaseServerValidationServerError(validationError);
61
+ const { data } = serverError;
62
+ logErrorFunction(data);
63
+ throw (0, error_1.badRequestError)(serverError);
41
64
  }
42
65
  });
43
66
  }
44
67
  exports.firebaseServerActionsTransformFactory = firebaseServerActionsTransformFactory;
68
+ // MARK: Compat
69
+ /**
70
+ * @deprecated mispelling. Use FIREBASE_SERVER_VALIDATION_ERROR_CODE instead.
71
+ */
72
+ exports.FIRESTBASE_SERVER_VALIDATION_ERROR_CODE = exports.FIREBASE_SERVER_VALIDATION_ERROR_CODE;
45
73
  //# sourceMappingURL=context.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","sourceRoot":"","sources":["../../../../../../../packages/firebase-server/src/lib/nest/function/context.ts"],"names":[],"mappings":";;;AACA,0CAAwM;AACxM,2CAAoE;AACpE,wCAAoD;AACpD,gDAAuD;AAQvD,MAAsB,oCAAoC;CAGzD;AAHD,oFAGC;AAED,SAAgB,4BAA4B,CAAC,QAAqE;IAChH,yBACK,qCAAqC,CAAC,QAAQ,CAAC,EAClD;AACJ,CAAC;AAJD,oEAIC;AAMM,MAAM,4DAA4D,GAA0D,CAAC,OAAO,EAAE,EAAE;IAC7I,OAAO,CAAC,GAAG,CAAC,wEAAwE,EAAE,OAAO,CAAC,CAAC;AACjG,CAAC,CAAC;AAFW,QAAA,4DAA4D,gEAEvE;AAUF,SAAgB,qCAAqC,CAAC,QAAqE;IACzH,MAAM,oCAAoC,GAAG,qCAAqC,CAAC,QAAQ,CAAC,CAAC;IAC7F,MAAM,4CAA4C,GAAG,IAAA,mDAA2C,EAAC,oCAAoC,CAAC,CAAC;IAEvI,OAAO;QACL,oCAAoC;QACpC,4CAA4C;KAC7C,CAAC;AACJ,CAAC;AARD,sFAQC;AAED,SAAgB,qCAAqC,CAAC,WAAuE,KAAK;IAChI,MAAM,8BAA8B,GAAG,IAAI,uBAAc,EAAE,CAAC,sBAAsB,EAAE,CAAC;IACrF,MAAM,gBAAgB,GAAG,QAAQ,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,oEAA4D,CAAC,CAAC,CAAC,CAAC,0BAAmB,CAAC;IAE/K,OAAO,IAAA,yCAAiC,EAAC;QACvC,qBAAqB,EAAE,CAAC,eAAkC,EAAE,EAAE;YAC5D,MAAM,SAAS,GAAG,8BAA8B,CAAC,eAAe,CAAC,CAAC;YAClE,MAAM,OAAO,GAAI,SAA2B,CAAC,WAAW,EAAE,CAAC;YAC3D,gBAAgB,CAAC,OAAiB,CAAC,CAAC;YACpC,MAAM,IAAA,uBAAe,EAAC;gBACpB,IAAI,EAAE,kBAAkB;gBACxB,OAAO,EAAE,mDAAmD;gBAC5D,IAAI,EAAE,OAAO;aACd,CAAC,CAAC;QACL,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAhBD,sFAgBC"}
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../../../../../../packages/firebase-server/src/lib/nest/function/context.ts"],"names":[],"mappings":";;;AACA,0CAAwM;AACxM,2CAAoE;AACpE,wCAAoD;AACpD,gDAAuD;AAQvD,MAAsB,oCAAoC;CAGzD;AAHD,oFAGC;AAED,SAAgB,4BAA4B,CAAC,QAAqE;IAChH,yBACK,qCAAqC,CAAC,QAAQ,CAAC,EAClD;AACJ,CAAC;AAJD,oEAIC;AAMM,MAAM,4DAA4D,GAA0D,CAAC,OAAO,EAAE,EAAE;IAC7I,OAAO,CAAC,GAAG,CAAC,wEAAwE,EAAE,OAAO,CAAC,CAAC;AACjG,CAAC,CAAC;AAFW,QAAA,4DAA4D,gEAEvE;AAUF,SAAgB,qCAAqC,CAAC,QAAqE;IACzH,MAAM,oCAAoC,GAAG,qCAAqC,CAAC,QAAQ,CAAC,CAAC;IAC7F,MAAM,4CAA4C,GAAG,IAAA,mDAA2C,EAAC,oCAAoC,CAAC,CAAC;IAEvI,OAAO;QACL,oCAAoC;QACpC,4CAA4C;KAC7C,CAAC;AACJ,CAAC;AARD,sFAQC;AAEY,QAAA,qCAAqC,GAAG,kBAAkB,CAAC;AAExE;;;;GAIG;AACH,SAAgB,mCAAmC,CAAC,eAAkC;IACpF,MAAM,8BAA8B,GAAG,IAAI,uBAAc,EAAE,CAAC,sBAAsB,EAAE,CAAC;IACrF,MAAM,SAAS,GAAG,8BAA8B,CAAC,eAAe,CAAC,CAAC;IAClE,MAAM,IAAI,GAAI,SAA2B,CAAC,WAAW,EAAE,CAAC;IAExD,OAAO;QACL,OAAO,EAAE,mDAAmD;QAC5D,IAAI,EAAE,6CAAqC;QAC3C,IAAI;KACL,CAAC;AACJ,CAAC;AAVD,kFAUC;AAED;;;;;GAKG;AACH,SAAgB,6BAA6B,CAAC,eAAkC;IAC9E,MAAM,WAAW,GAAG,mCAAmC,CAAC,eAAe,CAAC,CAAC;IACzE,OAAO,IAAA,uBAAe,EAAC,WAAW,CAAC,CAAC;AACtC,CAAC;AAHD,sEAGC;AAED,SAAgB,qCAAqC,CAAC,WAAuE,KAAK;IAChI,MAAM,gBAAgB,GAAG,QAAQ,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,oEAA4D,CAAC,CAAC,CAAC,CAAC,0BAAmB,CAAC;IAE/K,OAAO,IAAA,yCAAiC,EAAC;QACvC,qBAAqB,EAAE,CAAC,eAAkC,EAAE,EAAE;YAC5D,MAAM,WAAW,GAAG,mCAAmC,CAAC,eAAe,CAAC,CAAC;YACzE,MAAM,EAAE,IAAI,EAAE,GAAG,WAAW,CAAC;YAC7B,gBAAgB,CAAC,IAAc,CAAC,CAAC;YACjC,MAAM,IAAA,uBAAe,EAAC,WAAW,CAAC,CAAC;QACrC,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAXD,sFAWC;AAED,eAAe;AACf;;GAEG;AACU,QAAA,uCAAuC,GAAG,6CAAqC,CAAC"}
package/test/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dereekb/firebase-server/test",
3
- "version": "10.1.28",
3
+ "version": "10.1.30",
4
4
  "type": "commonjs",
5
5
  "main": "./src/index.js"
6
6
  }