New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

enonic-wizardry

Package Overview
Dependencies
Maintainers
2
Versions
85
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

enonic-wizardry - npm Package Compare versions

Comparing version 0.3.7 to 0.3.8

6

package.json
{
"name": "enonic-wizardry",
"sideEffects": false,
"version": "0.3.7",
"version": "0.3.8",
"description": "Functional utility library for Enonic XP",

@@ -35,4 +35,4 @@ "main": "lib/index.js",

"devDependencies": {
"@typescript-eslint/eslint-plugin": "^4.8.0",
"@typescript-eslint/parser": "^4.8.0",
"@typescript-eslint/eslint-plugin": "^4.8.1",
"@typescript-eslint/parser": "^4.8.1",
"eslint": "^7.13.0",

@@ -39,0 +39,0 @@ "rimraf": "^3.0.2",

import { Reporter } from "io-ts/lib/Reporter";
import { ErrorDetail } from "enonic-fp/errors";
import { LocalizeWithPrefixParams } from "enonic-fp/controller";
export interface GetErrorDetailReporterParams {
readonly localizeParams?: LocalizeWithPrefixParams;
}
export declare function getErrorDetailReporter(params?: GetErrorDetailReporterParams): Reporter<Array<ErrorDetail>>;
export declare function getErrorDetailReporter(localizeParams?: LocalizeWithPrefixParams): Reporter<Array<ErrorDetail>>;

@@ -19,12 +19,11 @@ "use strict";

var Option_1 = require("fp-ts/Option");
function getErrorDetailReporter(params) {
if (params === void 0) { params = {}; }
function getErrorDetailReporter(localizeParams) {
return {
report: Either_1.fold(function (es) { return es.map(function (err) { return validationErrorToErrorDetail(err, params); }); }, function () { return []; })
report: Either_1.fold(function (es) { return es.map(function (err) { return validationErrorToErrorDetail(err, localizeParams); }); }, function () { return []; })
};
}
exports.getErrorDetailReporter = getErrorDetailReporter;
function validationErrorToErrorDetail(err, params) {
function validationErrorToErrorDetail(err, localizeParams) {
var key = getPathInInterface(err.context);
return pipeable_1.pipe(getMessageKeys(key, isLastEmpty(err.context), params), i18n_1.localizeFirst, Option_1.getOrElse(function () { var _a; return (_a = err.message) !== null && _a !== void 0 ? _a : 'Invalid value'; }), function (message) { return ({
return pipeable_1.pipe(getMessageKeys(key, isLastEmpty(err.context), localizeParams), i18n_1.localizeFirst, Option_1.getOrElse(function () { var _a; return (_a = err.message) !== null && _a !== void 0 ? _a : 'Invalid value'; }), function (message) { return ({
key: key,

@@ -34,5 +33,5 @@ message: message

}
function getMessageKeys(key, fieldIsEmpty, params) {
var _a, _b;
var i18nPrefix = (_b = (_a = params.localizeParams) === null || _a === void 0 ? void 0 : _a.i18nPrefix) !== null && _b !== void 0 ? _b : "errors";
function getMessageKeys(key, fieldIsEmpty, localizeParams) {
var _a;
var i18nPrefix = (_a = localizeParams === null || localizeParams === void 0 ? void 0 : localizeParams.i18nPrefix) !== null && _a !== void 0 ? _a : "errors";
var keyedMessageKeys = [

@@ -56,3 +55,3 @@ i18nPrefix + ".bad-request-error." + key,

.concat(defaultMessageKeys)
.map(function (key) { return (__assign(__assign({}, params.localizeParams), { key: key })); });
.map(function (key) { return (__assign(__assign({}, localizeParams), { key: key })); });
}

@@ -59,0 +58,0 @@ /**

@@ -1,7 +0,9 @@

import { Type } from 'io-ts';
import { Errors, Type } from 'io-ts';
import * as t from 'io-ts';
import { GetErrorDetailReporterParams } from "./reporters/ErrorDetailReporter";
import { Either } from 'fp-ts/Either';
import { EnonicError } from 'enonic-fp/errors';
import { IOEither } from "fp-ts/IOEither";
export declare function validate<A, O = A, I = unknown>(a: Type<A, O, I>, params?: GetErrorDetailReporterParams): (i: I) => IOEither<EnonicError, A>;
import { LocalizeWithPrefixParams } from "enonic-fp/controller";
export declare function validate<A, O = A, I = unknown>(a: Type<A, O, I>, localizeParams?: LocalizeWithPrefixParams): (i: I) => IOEither<EnonicError, A>;
export declare function normalizeDecoded<A>(decoded: Either<Errors, A>, localizeParams?: LocalizeWithPrefixParams): IOEither<EnonicError, A>;
export interface RegexpValidatedStringProps<A extends boolean = false> {

@@ -8,0 +10,0 @@ readonly regexp: RegExp;

@@ -14,3 +14,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.MinMaxValidatedNumber = exports.MaxLengthValidatedString = exports.RegexpValidatedString = exports.validate = void 0;
exports.MinMaxValidatedNumber = exports.MaxLengthValidatedString = exports.RegexpValidatedString = exports.normalizeDecoded = exports.validate = void 0;
var t = require("io-ts");

@@ -21,9 +21,10 @@ var ErrorDetailReporter_1 = require("./reporters/ErrorDetailReporter");

var pipeable_1 = require("fp-ts/pipeable");
function validate(a, params) {
return function (i) {
var decoded = a.decode(i);
return pipeable_1.pipe(decoded, IOEither_1.fromEither, IOEither_1.mapLeft(function () { return (__assign(__assign({}, errors_1.badRequestError), { errors: ErrorDetailReporter_1.getErrorDetailReporter(params).report(decoded) })); }));
};
function validate(a, localizeParams) {
return function (i) { return normalizeDecoded(a.decode(i), localizeParams); };
}
exports.validate = validate;
function normalizeDecoded(decoded, localizeParams) {
return pipeable_1.pipe(decoded, IOEither_1.fromEither, IOEither_1.mapLeft(function () { return (__assign(__assign({}, errors_1.badRequestError), { errors: ErrorDetailReporter_1.getErrorDetailReporter(localizeParams).report(decoded) })); }));
}
exports.normalizeDecoded = normalizeDecoded;
function RegexpValidatedString(_a) {

@@ -30,0 +31,0 @@ var regexp = _a.regexp, _b = _a.isNullable, isNullable = _b === void 0 ? false : _b;

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc