Huge News!Announcing our $40M Series B led by Abstract Ventures.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.12 to 0.3.13

2

content.d.ts
import { EnonicError } from "enonic-fp/errors";
import { IOEither } from "fp-ts/IOEither";
import { Content, CreateContentParams, DeleteContentParams, GetContentParams, ModifyContentParams } from "enonic-types/content";
import { Separated } from "fp-ts/Compactable";
import { Separated } from "fp-ts/Separated";
import { IO } from "fp-ts/IO";

@@ -6,0 +6,0 @@ import { Option } from "fp-ts/Option";

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

var IOEither_1 = require("fp-ts/IOEither");
var pipeable_1 = require("fp-ts/pipeable");
var function_1 = require("fp-ts/function");
var content_1 = require("enonic-fp/content");

@@ -23,3 +23,3 @@ var context_1 = require("./context");

var Apply_1 = require("fp-ts/Apply");
var function_1 = require("fp-ts/function");
var function_2 = require("fp-ts/function");
var Array_1 = require("fp-ts/Array");

@@ -32,10 +32,10 @@ var IO_1 = require("fp-ts/IO");

function getAsOption(paramsOrKey) {
return pipeable_1.pipe(paramsOrKey, utils_1.fromNullable(errors_1.notFoundError), IOEither_1.chain(function (params) { return content_1.get(params); }), utils_1.fromIOEither);
return function_1.pipe(paramsOrKey, utils_1.fromNullable(errors_1.notFoundError), IOEither_1.chain(function (params) { return content_1.get(params); }), utils_1.fromIOEither);
}
exports.getAsOption = getAsOption;
function getContentByIds(ids) {
return (ids.length > 0)
? pipeable_1.pipe(content_1.query({
return ids.length > 0
? function_1.pipe(content_1.query({
count: ids.length,
query: "_id IN (" + idsAsString(ids) + ")"
query: "_id IN (" + idsAsString(ids) + ")",
}), IOEither_1.map(function (result) { return sortResultByIdOrder(result.hits, ids); }))

@@ -49,3 +49,3 @@ : IOEither_1.right([]);

.map(function (id) { return "\"" + id + "\""; })
.join(',');
.join(",");
}

@@ -60,20 +60,18 @@ function sortResultByIdOrder(hits, ids) {

function notEmptyOrUndefined(str) {
return (str !== undefined)
&& (str !== null)
&& (str.length > 0);
return str !== undefined && str !== null && str.length > 0;
}
function createAll(paramsList) {
return Array_1.array.wilt(IO_1.io)(paramsList.map(content_1.create), function_1.identity);
return Array_1.array.wilt(IO_1.io)(paramsList.map(content_1.create), function_2.identity);
}
exports.createAll = createAll;
function createAndPublish(params) {
return pipeable_1.pipe(context_1.runInDraftContext(content_1.create(params)), IOEither_1.chainFirst(function (content) { return content_1.publish(content); }));
return function_1.pipe(context_1.runInDraftContext(content_1.create(params)), IOEither_1.chainFirst(function (content) { return content_1.publish(content); }));
}
exports.createAndPublish = createAndPublish;
function deleteAndPublish(params) {
return pipeable_1.pipe(context_1.runInDraftContext(content_1.remove(params)), IOEither_1.chainFirst(function () { return content_1.publish(params.key); }));
return function_1.pipe(context_1.runInDraftContext(content_1.remove(params)), IOEither_1.chainFirst(function () { return content_1.publish(params.key); }));
}
exports.deleteAndPublish = deleteAndPublish;
function modifyAndPublish(a, key) {
return pipeable_1.pipe(context_1.runInDraftContext(content_1.modify(applyChangesToData(key, a))), IOEither_1.chainFirst(function (content) { return content_1.publish(content); }));
return function_1.pipe(context_1.runInDraftContext(content_1.modify(applyChangesToData(key, a))), IOEither_1.chainFirst(function (content) { return content_1.publish(content); }));
}

@@ -85,3 +83,3 @@ exports.modifyAndPublish = modifyAndPublish;

editor: function (content) { return (__assign(__assign({}, content), { data: __assign(__assign({}, content.data), changes) })); },
requireValid: true
requireValid: true,
};

@@ -91,5 +89,5 @@ }

function createMediaFromAttachment(params) {
return pipeable_1.pipe(Apply_1.sequenceS(IOEither_1.ioEither)({
return function_1.pipe(Apply_1.sequenceS(IOEither_1.ioEither)({
data: portal_1.getMultipartStream(params.name, params.index),
item: portal_1.getMultipartItem(params.name, params.index)
item: portal_1.getMultipartItem(params.name, params.index),
}), IOEither_1.filterOrElse(hasDataAndItem, function () {

@@ -100,4 +98,4 @@ var _a;

key: params.name,
message: (_a = params.errorMessage) !== null && _a !== void 0 ? _a : "Missing parameter: \"" + params.name + "\""
}
message: (_a = params.errorMessage) !== null && _a !== void 0 ? _a : "Missing parameter: \"" + params.name + "\"",
},
] }));

@@ -111,3 +109,3 @@ }), IOEither_1.chain(function (_a) {

name: item.fileName,
mimeType: item === null || item === void 0 ? void 0 : item.contentType
mimeType: item === null || item === void 0 ? void 0 : item.contentType,
});

@@ -119,3 +117,4 @@ }));

var _a, _b, _c;
return (attachment.data !== undefined) && (((_c = (_b = (_a = attachment.item) === null || _a === void 0 ? void 0 : _a.fileName) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0) > 0);
return (attachment.data !== undefined &&
((_c = (_b = (_a = attachment.item) === null || _a === void 0 ? void 0 : _a.fileName) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0) > 0);
}

@@ -7,3 +7,5 @@ "use strict";

function chainRun(runContext) {
return function (f) { return IOEither_1.chain(function (a) { return context_1.run(runContext)(f(a)); }); };
return function (f) {
return IOEither_1.chain(function (a) { return context_1.run(runContext)(f(a)); });
};
}

@@ -14,7 +16,7 @@ exports.chainRun = chainRun;

login: "su",
idProvider: 'system'
}
idProvider: "system",
},
});
exports.runInDraftContext = context_1.run({
branch: 'draft'
branch: "draft",
});

@@ -24,7 +26,7 @@ exports.chainRunAsSuperUser = chainRun({

login: "su",
idProvider: 'system'
}
idProvider: "system",
},
});
exports.chainRunInDraftContext = chainRun({
branch: 'draft'
branch: "draft",
});

@@ -7,8 +7,8 @@ "use strict";

var menu_1 = require("enonic-fp/menu");
var pipeable_1 = require("fp-ts/pipeable");
var function_1 = require("fp-ts/function");
function getSubMenuByKey(levels, params, key) {
return (key !== undefined)
? pipeable_1.pipe(content_1.get({ key: key }), IOEither_1.chain(menu_1.getSubMenus(levels, params)))
return key !== undefined
? function_1.pipe(content_1.get({ key: key }), IOEither_1.chain(menu_1.getSubMenus(levels, params)))
: IOEither_1.right([]);
}
exports.getSubMenuByKey = getSubMenuByKey;
{
"name": "enonic-wizardry",
"sideEffects": false,
"version": "0.3.12",
"version": "0.3.13",
"description": "Functional utility library for Enonic XP",

@@ -29,14 +29,17 @@ "main": "lib/index.js",

"dependencies": {
"enonic-fp": "^0.3.9",
"enonic-types": "^0.1.27",
"fp-ts": "^2.9.5",
"enonic-fp": "^0.3.12",
"enonic-types": "^0.2.2",
"fp-ts": "^2.10.5",
"io-ts": "^2.2.16"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^4.17.0",
"@typescript-eslint/parser": "^4.17.0",
"eslint": "^7.22.0",
"@typescript-eslint/eslint-plugin": "^4.25.0",
"@typescript-eslint/parser": "^4.25.0",
"eslint": "^7.27.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.0",
"prettier": "^2.3.0",
"rimraf": "^3.0.2",
"typescript": "^4.2.3"
"typescript": "^4.3.2"
}
}

@@ -17,7 +17,9 @@ "use strict";

var i18n_1 = require("enonic-fp/i18n");
var pipeable_1 = require("fp-ts/pipeable");
var function_1 = require("fp-ts/function");
var Option_1 = require("fp-ts/Option");
function getErrorDetailReporter(localizeParams) {
return {
report: Either_1.fold(function (es) { return es.map(function (err) { return validationErrorToErrorDetail(err, localizeParams); }); }, function () { return []; })
report: Either_1.fold(function (es) {
return es.map(function (err) { return validationErrorToErrorDetail(err, localizeParams); });
}, function () { return []; }),
};

@@ -28,5 +30,5 @@ }

var key = getPathInInterface(err.context);
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 ({
return function_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,
message: message
message: message,
}); });

@@ -40,7 +42,7 @@ }

i18nPrefix + ".400." + key,
i18nPrefix + "." + key
i18nPrefix + "." + key,
];
var emptyMessageKeys = [
"errors.bad-request-error.defaultEmpty",
"errors.400.defaultEmpty"
"errors.400.defaultEmpty",
];

@@ -51,3 +53,3 @@ var defaultMessageKeys = [

"errors.bad-request-error.default",
"errors.400.default"
"errors.400.default",
];

@@ -66,5 +68,5 @@ return keyedMessageKeys

var last = entries[entries.length - 1];
return (last.actual === undefined)
|| (last.actual === null)
|| isString(last.actual)
return last.actual === undefined ||
last.actual === null ||
isString(last.actual)
? ((_a = last.actual) === null || _a === void 0 ? void 0 : _a.length) === 0

@@ -80,3 +82,3 @@ : false;

.map(function (c) { return c.key; })
.join('.');
.join(".");
}

@@ -1,5 +0,5 @@

import { Errors, Type } from 'io-ts';
import * as t from 'io-ts';
import { Either } from 'fp-ts/Either';
import { EnonicError } from 'enonic-fp/errors';
import { Errors, Type } from "io-ts";
import * as t from "io-ts";
import { Either } from "fp-ts/Either";
import { EnonicError } from "enonic-fp/errors";
import { IOEither } from "fp-ts/IOEither";

@@ -6,0 +6,0 @@ import { LocalizeWithPrefixParams } from "enonic-fp/controller";

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

var IOEither_1 = require("fp-ts/IOEither");
var pipeable_1 = require("fp-ts/pipeable");
var function_1 = require("fp-ts/function");
function validate(a, localizeParams) {
return function (i) { return normalizeDecoded(a.decode(i), 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) })); }));
return function_1.pipe(decoded, IOEither_1.fromEither, IOEither_1.mapLeft(function () { return (__assign(__assign({}, errors_1.badRequestError), { errors: ErrorDetailReporter_1.getErrorDetailReporter(localizeParams).report(decoded) })); }));
}

@@ -31,4 +33,8 @@ exports.normalizeDecoded = normalizeDecoded;

var regexp = _a.regexp, _b = _a.isNullable, isNullable = _b === void 0 ? false : _b;
return new t.Type('RegexpValidatedString', function (u) { return (typeof u === "string" && regexp.test(u)) || (isNullable && u === undefined); }, function (u, c) {
return (typeof u === "string" && regexp.test(u)) || (isNullable && u === undefined)
return new t.Type("RegexpValidatedString", function (u) {
return (typeof u === "string" && regexp.test(u)) ||
(isNullable && u === undefined);
}, function (u, c) {
return (typeof u === "string" && regexp.test(u)) ||
(isNullable && u === undefined)
? t.success(u)

@@ -41,4 +47,8 @@ : t.failure(u, c);

var maxLength = _a.maxLength, _b = _a.isNullable, isNullable = _b === void 0 ? false : _b;
return new t.Type('MaxLengthValidatedString', function (u) { return (typeof u === "string" && u.length <= maxLength) || (isNullable && u === undefined); }, function (u, c) {
return (typeof u === "string" && u.length <= maxLength) || (isNullable && u === undefined)
return new t.Type("MaxLengthValidatedString", function (u) {
return (typeof u === "string" && u.length <= maxLength) ||
(isNullable && u === undefined);
}, function (u, c) {
return (typeof u === "string" && u.length <= maxLength) ||
(isNullable && u === undefined)
? t.success(u)

@@ -51,4 +61,8 @@ : t.failure(u, c);

var _b = _a.min, min = _b === void 0 ? Number.NEGATIVE_INFINITY : _b, _c = _a.max, max = _c === void 0 ? Number.POSITIVE_INFINITY : _c, _d = _a.isNullable, isNullable = _d === void 0 ? false : _d;
return new t.Type('MinMaxValidatedNumber', function (u) { return (t.number.is(u) && (min <= u) && (u <= max)) || (isNullable && u === undefined); }, function (u, c) {
return (t.number.is(u) && (min <= u) && (u <= max)) || (isNullable && u === undefined)
return new t.Type("MinMaxValidatedNumber", function (u) {
return (t.number.is(u) && min <= u && u <= max) ||
(isNullable && u === undefined);
}, function (u, c) {
return (t.number.is(u) && min <= u && u <= max) ||
(isNullable && u === undefined)
? t.success(u)

@@ -55,0 +69,0 @@ : t.failure(u, c);

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