Comparing version 0.3.2 to 0.3.3
@@ -5,2 +5,3 @@ import { Request, Response, ResponseType } from "enonic-types/controller"; | ||
import { EnonicError } from "./errors"; | ||
import { LocalizeParams } from "enonic-types/i18n"; | ||
export declare type AsResponse = (body: ResponseType, extras?: Partial<Response>) => IO<Response>; | ||
@@ -27,2 +28,3 @@ export declare type AsErrorResponse = (err: EnonicError, extras?: Partial<Response>) => IO<Response>; | ||
readonly i18nPrefix?: string; | ||
readonly localizeParams?: Partial<LocalizeParams>; | ||
} | ||
@@ -29,0 +31,0 @@ /** |
@@ -51,6 +51,6 @@ "use strict"; | ||
type: err.type, | ||
title: translateField("title", err, params === null || params === void 0 ? void 0 : params.i18nPrefix), | ||
title: translateField("title", err, params), | ||
instance: (_a = params === null || params === void 0 ? void 0 : params.req) === null || _a === void 0 ? void 0 : _a.path, | ||
status: err.status, | ||
detail: translateField("detail", err, params === null || params === void 0 ? void 0 : params.i18nPrefix), | ||
detail: translateField("detail", err, params), | ||
// don't expose server internals on live site | ||
@@ -69,5 +69,6 @@ errors: (err.status >= 500 && ((_b = params === null || params === void 0 ? void 0 : params.req) === null || _b === void 0 ? void 0 : _b.mode) !== 'live') | ||
} | ||
function translateField(fieldName, err, i18nPrefix) { | ||
if (i18nPrefix === void 0) { i18nPrefix = "errors"; } | ||
function translateField(fieldName, err, params) { | ||
var _a; | ||
var typeString = utils_1.substringAfter(err.type, "/"); | ||
var i18nPrefix = (_a = params === null || params === void 0 ? void 0 : params.i18nPrefix) !== null && _a !== void 0 ? _a : "errors"; | ||
// keys to try to look up in order | ||
@@ -84,3 +85,3 @@ var titleKeys = [ | ||
]; | ||
return function_1.pipe(titleKeys, i18n_1.localizeFirst, Option_1.getOrElse(function () { return err[fieldName]; })); | ||
return function_1.pipe(titleKeys.map(function (key) { return (__assign(__assign({}, params === null || params === void 0 ? void 0 : params.localizeParams), { key: key })); }), i18n_1.localizeFirst, Option_1.getOrElse(function () { return err[fieldName]; })); | ||
} | ||
@@ -87,0 +88,0 @@ /** |
{ | ||
"name": "enonic-fp", | ||
"version": "0.3.2", | ||
"version": "0.3.3", | ||
"sideEffects": false, | ||
@@ -28,8 +28,8 @@ "description": "Functional programming helpers for Enonic XP", | ||
"enonic-types": "^0.1.4", | ||
"fp-ts": "^2.8.5" | ||
"fp-ts": "^2.8.6" | ||
}, | ||
"devDependencies": { | ||
"@typescript-eslint/eslint-plugin": "^4.6.0", | ||
"@typescript-eslint/parser": "^4.6.0", | ||
"eslint": "^7.12.1", | ||
"@typescript-eslint/eslint-plugin": "^4.8.0", | ||
"@typescript-eslint/parser": "^4.8.0", | ||
"eslint": "^7.13.0", | ||
"rimraf": "^3.0.2", | ||
@@ -36,0 +36,0 @@ "typescript": "^4.0.5" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
100507
1930
Updatedfp-ts@^2.8.6