@bluemarble/bm-components 1.0.0 → 1.2.0

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/index.d.mts CHANGED
@@ -267,11 +267,13 @@ type MethodProps<T> = Partial<Record<PossibleMethods, HandlerProps<T>>>;
267
267
  type MiddlewaresProps<T> = ((handler: HandlerProps<T>) => HandlerProps<T>)[];
268
268
  type ConstructorProps<T> = {
269
269
  middlewares?: MiddlewaresProps<T>;
270
- onFinally: (req: NextApiRequest) => Promise<void>;
270
+ onFinally: (req: NextApiRequest, res: NextApiResponse) => Promise<void>;
271
+ onError?: (req: NextApiRequest, res: NextApiResponse) => Promise<void>;
271
272
  };
272
273
  declare class ApiHelper<T> {
273
274
  middlewares: MiddlewaresProps<T>;
274
275
  private onFinally;
276
+ private onError;
275
277
  constructor(props?: ConstructorProps<T>);
276
278
  setMiddlewares(middlewares: any[]): this;
277
279
  createMethods(methods: MethodProps<T>): (req: NextApiRequest, res: NextApiResponse) => Promise<void | NextApiResponse<any>>;
package/dist/index.d.ts CHANGED
@@ -267,11 +267,13 @@ type MethodProps<T> = Partial<Record<PossibleMethods, HandlerProps<T>>>;
267
267
  type MiddlewaresProps<T> = ((handler: HandlerProps<T>) => HandlerProps<T>)[];
268
268
  type ConstructorProps<T> = {
269
269
  middlewares?: MiddlewaresProps<T>;
270
- onFinally: (req: NextApiRequest) => Promise<void>;
270
+ onFinally: (req: NextApiRequest, res: NextApiResponse) => Promise<void>;
271
+ onError?: (req: NextApiRequest, res: NextApiResponse) => Promise<void>;
271
272
  };
272
273
  declare class ApiHelper<T> {
273
274
  middlewares: MiddlewaresProps<T>;
274
275
  private onFinally;
276
+ private onError;
275
277
  constructor(props?: ConstructorProps<T>);
276
278
  setMiddlewares(middlewares: any[]): this;
277
279
  createMethods(methods: MethodProps<T>): (req: NextApiRequest, res: NextApiResponse) => Promise<void | NextApiResponse<any>>;
package/dist/index.js CHANGED
@@ -255,7 +255,7 @@ var require_react_is_development = __commonJS({
255
255
  var ContextProvider = REACT_PROVIDER_TYPE;
256
256
  var Element = REACT_ELEMENT_TYPE;
257
257
  var ForwardRef = REACT_FORWARD_REF_TYPE;
258
- var Fragment = REACT_FRAGMENT_TYPE;
258
+ var Fragment2 = REACT_FRAGMENT_TYPE;
259
259
  var Lazy = REACT_LAZY_TYPE;
260
260
  var Memo = REACT_MEMO_TYPE;
261
261
  var Portal = REACT_PORTAL_TYPE;
@@ -314,7 +314,7 @@ var require_react_is_development = __commonJS({
314
314
  exports.ContextProvider = ContextProvider;
315
315
  exports.Element = Element;
316
316
  exports.ForwardRef = ForwardRef;
317
- exports.Fragment = Fragment;
317
+ exports.Fragment = Fragment2;
318
318
  exports.Lazy = Lazy;
319
319
  exports.Memo = Memo;
320
320
  exports.Portal = Portal;
@@ -3352,6 +3352,7 @@ function FormikSelect(_a) {
3352
3352
 
3353
3353
 
3354
3354
 
3355
+
3355
3356
  function Autocomplete2(_a) {
3356
3357
  var _b = _a, {
3357
3358
  withFormik = true,
@@ -3436,6 +3437,9 @@ function FormikAutocomplete(_a) {
3436
3437
  error: Boolean(meta == null ? void 0 : meta.error),
3437
3438
  helperText: meta == null ? void 0 : meta.error
3438
3439
  }, params), field), {
3440
+ InputProps: __spreadProps(__spreadValues({}, params.InputProps), {
3441
+ endAdornment: /* @__PURE__ */ React2.default.createElement(_react.Fragment, null, props.loading ? /* @__PURE__ */ React2.default.createElement(_material.CircularProgress, { color: "inherit", size: 20 }) : null, params.InputProps.endAdornment)
3442
+ }),
3439
3443
  label: props.label
3440
3444
  })
3441
3445
  ),
@@ -3969,7 +3973,11 @@ var HttpError = class extends Error {
3969
3973
 
3970
3974
  // src/helpers/apiHelper/index.ts
3971
3975
  var ApiHelper = class _ApiHelper {
3972
- onFinally(req) {
3976
+ onFinally(req, res) {
3977
+ return __async(this, null, function* () {
3978
+ });
3979
+ }
3980
+ onError(req, res) {
3973
3981
  return __async(this, null, function* () {
3974
3982
  });
3975
3983
  }
@@ -3977,6 +3985,8 @@ var ApiHelper = class _ApiHelper {
3977
3985
  this.middlewares = ((props == null ? void 0 : props.middlewares) || []).reverse();
3978
3986
  this.onFinally = props.onFinally || (() => __async(this, null, function* () {
3979
3987
  }));
3988
+ this.onError = props.onError || (() => __async(this, null, function* () {
3989
+ }));
3980
3990
  }
3981
3991
  setMiddlewares(middlewares) {
3982
3992
  this.middlewares = middlewares.reverse();
@@ -3998,15 +4008,18 @@ var ApiHelper = class _ApiHelper {
3998
4008
  } catch (error) {
3999
4009
  if (error instanceof HttpError)
4000
4010
  return res.status(error.status).json(error.message);
4001
- if (process.env.NODE_ENV === "production")
4002
- return res.status(500).json({
4011
+ if (process.env.NODE_ENV === "production") {
4012
+ res.status(500).json({
4003
4013
  code: "internal.error",
4004
4014
  error: "Erro interno do servidor",
4005
4015
  details: error
4006
4016
  });
4017
+ return this.onError(req, res);
4018
+ }
4019
+ this.onError(req, res);
4007
4020
  throw new Error(error);
4008
4021
  } finally {
4009
- yield this.onFinally(req);
4022
+ yield this.onFinally(req, res);
4010
4023
  }
4011
4024
  });
4012
4025
  }