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

enonic-fp

Package Overview
Dependencies
Maintainers
1
Versions
99
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

enonic-fp - npm Package Compare versions

Comparing version 0.2.36 to 0.2.37

1

lib/auth.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getMemberships = exports.createGroup = exports.createRole = exports.getPrincipal = exports.removeMembers = exports.addMembers = exports.createUser = exports.modifyUser = exports.findUsers = exports.getIdProviderConfig = exports.getUser = exports.logout = exports.login = void 0;
var Option_1 = require("fp-ts/lib/Option");

@@ -4,0 +5,0 @@ var utils_1 = require("./utils");

import { IOEither } from "fp-ts/lib/IOEither";
import { Semigroup } from "fp-ts/lib/Semigroup";
import { EnonicError } from "./errors";
import { AddAttachmentParams, Attachments, AttachmentStreamParams, ByteSource, Content, ContentType, CreateContentParams, CreateMediaParams, DeleteContentParams, ExistsParams, GetChildrenParams, GetContentParams, GetOutboundDependenciesParams, GetPermissionsParams, GetPermissionsResult, GetSiteConfigParams, GetSiteParams, ModifyContentParams, MoveParams, PublishContentParams, PublishResponse, QueryContentParams, QueryResponse, RemoveAttachmentParams, SetPermissionsParams, Site, UnpublishContentParams } from "enonic-types/lib/content";
export declare function get<A extends object>(params: GetContentParams): IOEither<EnonicError, Content<A>>;
export declare function get<A extends object>(key: string): IOEither<EnonicError, Content<A>>;
export declare function query<A extends object>(params: QueryContentParams): IOEither<EnonicError, QueryResponse<A>>;
export declare function create<A extends object>(params: CreateContentParams<A>): IOEither<EnonicError, Content<A>>;
export declare function modify<A extends object>(params: ModifyContentParams<A>): IOEither<EnonicError, Content<A>>;
declare type PartialContent<A extends object> = Partial<Content<A>> & Pick<Content<A>, '_id' | 'data'>;
export interface ConcatContentParams<A extends object> {
readonly semigroup: Semigroup<PartialContent<A>>;
readonly key?: string;
readonly requireValid?: boolean;
}
/**
* Instead of taking an "editor" function like the original `modify()` this `modify()` takes a Semigroup
* (or Monoid) to combine the old and new content.
*/
export declare function modifyWithSemigroup<A extends object>(params: ConcatContentParams<A>): (newContent: PartialContent<A>) => IOEither<EnonicError, Content<A>>;
export declare function getContentSemigroup<A extends object>(dataMonoid: Semigroup<A>): Semigroup<PartialContent<A>>;
export declare function remove(params: DeleteContentParams): IOEither<EnonicError, void>;
export declare function remove(key: string): IOEither<EnonicError, void>;
export declare function exists(params: ExistsParams): IOEither<EnonicError, boolean>;
export declare function exists(key: string): IOEither<EnonicError, boolean>;
export declare function publish(params: PublishContentParams): IOEither<EnonicError, PublishResponse>;
export declare function unpublish(params: UnpublishContentParams): IOEither<EnonicError, ReadonlyArray<string>>;
export declare function getChildren<A extends object>(params: GetChildrenParams): IOEither<EnonicError, QueryResponse<A>>;
export declare function getChildren<A extends object>(key: string): IOEither<EnonicError, QueryResponse<A>>;
export declare function getOutboundDependencies(params: GetOutboundDependenciesParams): IOEither<EnonicError, ReadonlyArray<string>>;
export declare function getOutboundDependencies(key: string): IOEither<EnonicError, ReadonlyArray<string>>;
export declare function move<A extends object>(params: MoveParams): IOEither<EnonicError, Content<A>>;
export declare function getSite<A extends object, PageConfig extends object = never>(params: GetSiteParams): IOEither<EnonicError, Site<A, PageConfig>>;
export declare function getSite<A extends object, PageConfig extends object = never>(key: string): IOEither<EnonicError, Site<A, PageConfig>>;
export declare function getSiteConfig<A extends object>(params: GetSiteConfigParams): IOEither<EnonicError, A>;

@@ -26,1 +45,2 @@ export declare function createMedia<A extends object>(params: CreateMediaParams): IOEither<EnonicError, Content<A>>;

export declare function getTypes(): IOEither<EnonicError, ReadonlyArray<ContentType>>;
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getTypes = exports.getType = exports.setPermissions = exports.getPermissions = exports.removeAttachment = exports.getAttachmentStream = exports.getAttachments = exports.addAttachment = exports.createMedia = exports.getSiteConfig = exports.getSite = exports.move = exports.getOutboundDependencies = exports.getChildren = exports.unpublish = exports.publish = exports.exists = exports.remove = exports.getContentSemigroup = exports.modifyWithSemigroup = exports.modify = exports.create = exports.query = exports.get = void 0;
var pipeable_1 = require("fp-ts/lib/pipeable");
var IOEither_1 = require("fp-ts/lib/IOEither");
var pipeable_1 = require("fp-ts/lib/pipeable");
var utils_1 = require("./utils");
var contentLib = __non_webpack_require__("/lib/xp/content");
function get(params) {
return pipeable_1.pipe(utils_1.catchEnonicError(function () { return contentLib.get(params); }), IOEither_1.chain(utils_1.fromNullable({ errorKey: "NotFoundError" })));
function get(paramsOrKey) {
return pipeable_1.pipe(utils_1.stringToByKey(paramsOrKey), function (params) { return utils_1.catchEnonicError(function () { return contentLib.get(params); }); }, IOEither_1.chain(utils_1.fromNullable({ errorKey: "NotFoundError" })));
}

@@ -23,4 +24,50 @@ exports.get = get;

exports.modify = modify;
function remove(params) {
return pipeable_1.pipe(utils_1.catchEnonicError(function () { return contentLib.delete(params); }), IOEither_1.chain(function (success) {
/**
* Instead of taking an "editor" function like the original `modify()` this `modify()` takes a Semigroup
* (or Monoid) to combine the old and new content.
*/
function modifyWithSemigroup(params) {
return function (newContent) {
return utils_1.catchEnonicError(function () {
var _a;
return contentLib.modify({
key: (_a = params.key) !== null && _a !== void 0 ? _a : newContent._id,
requireValid: params.requireValid,
editor: function (oldContent) { return params.semigroup.concat(oldContent, newContent); }
});
});
};
}
exports.modifyWithSemigroup = modifyWithSemigroup;
function getContentSemigroup(dataMonoid) {
return {
concat: function (x, y) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
return ({
_id: x._id,
_name: x._name,
_path: x._path,
creator: (_a = y.creator) !== null && _a !== void 0 ? _a : x.creator,
modifier: (_b = y.modifier) !== null && _b !== void 0 ? _b : x.modifier,
createdTime: (_c = y.createdTime) !== null && _c !== void 0 ? _c : x.createdTime,
modifiedTime: (_d = y.modifiedTime) !== null && _d !== void 0 ? _d : x.modifiedTime,
owner: (_e = y.owner) !== null && _e !== void 0 ? _e : x.owner,
type: (_f = y.type) !== null && _f !== void 0 ? _f : x.type,
displayName: (_g = y.displayName) !== null && _g !== void 0 ? _g : x.displayName,
hasChildren: (_h = y.hasChildren) !== null && _h !== void 0 ? _h : x.hasChildren,
language: (_j = y.language) !== null && _j !== void 0 ? _j : x.language,
valid: (_k = y.valid) !== null && _k !== void 0 ? _k : x.valid,
childOrder: (_l = y.childOrder) !== null && _l !== void 0 ? _l : x.childOrder,
data: dataMonoid.concat(x.data, y.data),
x: (_m = y.x) !== null && _m !== void 0 ? _m : x.x,
page: (_o = y.page) !== null && _o !== void 0 ? _o : x.page,
attachments: (_p = y.attachments) !== null && _p !== void 0 ? _p : x.attachments,
publish: (_q = y.publish) !== null && _q !== void 0 ? _q : x.publish,
});
}
};
}
exports.getContentSemigroup = getContentSemigroup;
function remove(paramsOrKey) {
return pipeable_1.pipe(utils_1.stringToByKey(paramsOrKey), function (params) { return utils_1.catchEnonicError(function () { return contentLib.delete(params); }); }, IOEither_1.chain(function (success) {
return success

@@ -34,4 +81,4 @@ ? IOEither_1.right(undefined)

exports.remove = remove;
function exists(params) {
return utils_1.catchEnonicError(function () { return contentLib.exists(params); }, "InternalServerError");
function exists(paramsOrKey) {
return pipeable_1.pipe(utils_1.stringToByKey(paramsOrKey), function (params) { return utils_1.catchEnonicError(function () { return contentLib.exists(params); }, "InternalServerError"); });
}

@@ -47,8 +94,8 @@ exports.exists = exists;

exports.unpublish = unpublish;
function getChildren(params) {
return utils_1.catchEnonicError(function () { return contentLib.getChildren(params); });
function getChildren(paramsOrKey) {
return pipeable_1.pipe(utils_1.stringToByKey(paramsOrKey), function (params) { return utils_1.catchEnonicError(function () { return contentLib.getChildren(params); }); });
}
exports.getChildren = getChildren;
function getOutboundDependencies(params) {
return utils_1.catchEnonicError(function () { return contentLib.getOutboundDependencies(params); });
function getOutboundDependencies(paramsOrKey) {
return pipeable_1.pipe(utils_1.stringToByKey(paramsOrKey), function (params) { return utils_1.catchEnonicError(function () { return contentLib.getOutboundDependencies(params); }); });
}

@@ -60,4 +107,4 @@ exports.getOutboundDependencies = getOutboundDependencies;

exports.move = move;
function getSite(params) {
return utils_1.catchEnonicError(function () { return contentLib.getSite(params); });
function getSite(paramsOrKey) {
return pipeable_1.pipe(utils_1.stringToByKey(paramsOrKey), function (params) { return utils_1.catchEnonicError(function () { return contentLib.getSite(params); }); });
}

@@ -64,0 +111,0 @@ exports.getSite = getSite;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.run = exports.runUnsafe = exports.get = void 0;
var utils_1 = require("./utils");

@@ -4,0 +5,0 @@ var contextLib = __non_webpack_require__("/lib/xp/context");

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isBadRequestError = void 0;
function isBadRequestError(err) {

@@ -4,0 +5,0 @@ return err.errorKey === "BadRequestError";

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.send = exports.listener = void 0;
var contentLib = __non_webpack_require__("/lib/xp/content");

@@ -4,0 +5,0 @@ function listener(params) {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.request = void 0;
var utils_1 = require("./utils");

@@ -4,0 +5,0 @@ var httpLib = __non_webpack_require__("/lib/http-client");

@@ -8,1 +8,2 @@ import { Option } from "fp-ts/lib/Option";

export declare function localize(params: LocalizeParams): Option<string>;
export declare function localize(key: string): Option<string>;

7

lib/i18n.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.localize = exports.getSupportedLocales = exports.getPhrases = void 0;
var Option_1 = require("fp-ts/lib/Option");
var pipeable_1 = require("fp-ts/lib/pipeable");
var utils_1 = require("./utils");
var i18nLib = __non_webpack_require__("/lib/xp/i18n");

@@ -15,4 +17,5 @@ var NOT_TRANSLATED_MESSAGE = "NOT_TRANSLATED";

exports.getSupportedLocales = getSupportedLocales;
function localize(params) {
return pipeable_1.pipe(Option_1.fromNullable(i18nLib.localize(params)), Option_1.map(function (result) {
function localize(paramsOrKey) {
var params = utils_1.stringToByKey(paramsOrKey);
return pipeable_1.pipe(params, i18nLib.localize, Option_1.fromNullable, Option_1.map(function (result) {
return result === NOT_TRANSLATED_MESSAGE ? params.key : result;

@@ -19,0 +22,0 @@ }));

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.error = exports.warn = exports.info = void 0;
function info() {

@@ -4,0 +5,0 @@ var args = [];

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.send = void 0;
var IOEither_1 = require("fp-ts/lib/IOEither");

@@ -4,0 +5,0 @@ var pipeable_1 = require("fp-ts/lib/pipeable");

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getSubMenus = exports.getMenuTree = exports.getBreadcrumbMenu = void 0;
var utils_1 = require("./utils");

@@ -4,0 +5,0 @@ var menuLib = __non_webpack_require__('/lib/menu');

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.query = exports.remove = exports.create = exports.get = exports.connect = void 0;
var IOEither_1 = require("fp-ts/lib/IOEither");

@@ -4,0 +5,0 @@ var pipeable_1 = require("fp-ts/lib/pipeable");

@@ -33,5 +33,9 @@ import { IOEither } from "fp-ts/lib/IOEither";

export declare function assetUrl(params: AssetUrlParams): string;
export declare function assetUrl(path: string): string;
export declare function attachmentUrl(params: AttachmentUrlParams): string;
export declare function attachmentUrl(id: string): string;
export declare function componentUrl(params: ComponentUrlParams): string;
export declare function componentUrl(id: string): string;
export declare function serviceUrl(params: ServiceUrlParams): string;
export declare function serviceUrl(serviceKey: string): string;
export declare function imageUrl(params: ImageUrlParams): string;

@@ -41,4 +45,6 @@ export declare function loginUrl(params: LoginUrlParams): string;

export declare function pageUrl(params: PageUrlParams): string;
export declare function pageUrl(id: string): string;
export declare function url(params: UrlParams): string;
export declare function processHtml(params: ProcessHtmlParams): string;
export declare function processHtml(value: string): string;
export declare function sanitizeHtml(html: string): string;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.sanitizeHtml = exports.processHtml = exports.url = exports.pageUrl = exports.logoutUrl = exports.loginUrl = exports.imageUrl = exports.serviceUrl = exports.componentUrl = exports.attachmentUrl = exports.assetUrl = exports.imagePlaceholder = exports.idProviderUrl = exports.getSiteConfig = exports.getSite = exports.getMultipartText = exports.getMultipartStream = exports.getMultipartItem = exports.getMultipartForm = exports.getIdProviderKey = exports.getComponent = exports.getContent = void 0;
var IOEither_1 = require("fp-ts/lib/IOEither");

@@ -73,16 +74,18 @@ var utils_1 = require("./utils");

exports.imagePlaceholder = imagePlaceholder;
function assetUrl(params) {
return portalLib.assetUrl(params);
function assetUrl(paramsOrPath) {
return pipeable_1.pipe(utils_1.stringToByPath(paramsOrPath), portalLib.assetUrl);
}
exports.assetUrl = assetUrl;
function attachmentUrl(params) {
return portalLib.attachmentUrl(params);
function attachmentUrl(paramsOrId) {
return pipeable_1.pipe(utils_1.stringToById(paramsOrId), portalLib.attachmentUrl);
}
exports.attachmentUrl = attachmentUrl;
function componentUrl(params) {
return portalLib.componentUrl(params);
function componentUrl(paramsOrId) {
return pipeable_1.pipe(utils_1.stringToById(paramsOrId), portalLib.componentUrl);
}
exports.componentUrl = componentUrl;
function serviceUrl(params) {
return portalLib.serviceUrl(params);
function serviceUrl(paramsOrServiceKey) {
return pipeable_1.pipe(utils_1.isString(paramsOrServiceKey)
? { service: paramsOrServiceKey }
: paramsOrServiceKey, portalLib.serviceUrl);
}

@@ -102,4 +105,4 @@ exports.serviceUrl = serviceUrl;

exports.logoutUrl = logoutUrl;
function pageUrl(params) {
return portalLib.pageUrl(params);
function pageUrl(paramsOrId) {
return pipeable_1.pipe(utils_1.stringToById(paramsOrId), portalLib.pageUrl);
}

@@ -111,4 +114,6 @@ exports.pageUrl = pageUrl;

exports.url = url;
function processHtml(params) {
return portalLib.processHtml(params);
function processHtml(paramsOrValue) {
return pipeable_1.pipe(utils_1.isString(paramsOrValue)
? { value: paramsOrValue }
: paramsOrValue, portalLib.processHtml);
}

@@ -115,0 +120,0 @@ exports.processHtml = processHtml;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isConfigured = exports.verify = exports.getSecretKey = exports.getSiteKey = void 0;
var pipeable_1 = require("fp-ts/lib/pipeable");

@@ -4,0 +5,0 @@ var utils_1 = require("./utils");

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.refresh = exports.deleteBranch = exports.remove = exports.list = exports.get = exports.createBranch = exports.create = void 0;
var IOEither_1 = require("fp-ts/lib/IOEither");

@@ -4,0 +5,0 @@ var pipeable_1 = require("fp-ts/lib/pipeable");

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getRenderer = exports.getUnsafeRenderer = exports.render = exports.renderUnsafe = void 0;
var utils_1 = require("./utils");

@@ -4,0 +5,0 @@ var thymeleafLib = __non_webpack_require__("/lib/thymeleaf");

import { IOEither } from "fp-ts/lib/IOEither";
import { EnonicError, GeneralEnonicErrorKey } from "./errors";
import { Lazy } from "fp-ts/lib/function";
import { ById, ByKey, ByPath } from "enonic-types/lib/portal";
export interface Throwable {

@@ -16,1 +17,5 @@ getMessage(): string;

export declare function catchEnonicError<A>(f: Lazy<A>, errorKey?: GeneralEnonicErrorKey): IOEither<EnonicError, A>;
export declare function isString<A>(a: A | string): a is string;
export declare function stringToByKey<A>(input: string | A): A | ByKey;
export declare function stringToById<A>(input: string | A): A | ById;
export declare function stringToByPath<A>(input: string | A): A | ByPath;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.stringToByPath = exports.stringToById = exports.stringToByKey = exports.isString = exports.catchEnonicError = exports.handleJavaThrowable = exports.getRootCause = exports.getStackTraceAsString = exports.getMessage = exports.isJavaThrowable = exports.fromNullable = void 0;
var EI = require("fp-ts/lib/Either");

@@ -58,1 +59,23 @@ var IOEither_1 = require("fp-ts/lib/IOEither");

exports.catchEnonicError = catchEnonicError;
function isString(a) {
return (typeof a === 'string');
}
exports.isString = isString;
function stringToByKey(input) {
return isString(input)
? { key: input }
: input;
}
exports.stringToByKey = stringToByKey;
function stringToById(input) {
return isString(input)
? { id: input }
: input;
}
exports.stringToById = stringToById;
function stringToByPath(input) {
return isString(input)
? { path: input }
: input;
}
exports.stringToByPath = stringToByPath;
{
"name": "enonic-fp",
"version": "0.2.36",
"version": "0.2.37",
"description": "Functional programming helpers for Enonic XP",

@@ -28,12 +28,12 @@ "main": "lib/index.js",

"dependencies": {
"enonic-types": "^0.0.45",
"fp-ts": "^2.5.3"
"enonic-types": "^0.0.52",
"fp-ts": "^2.6.0"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^2.28.0",
"@typescript-eslint/parser": "^2.28.0",
"eslint": "^6.8.0",
"@typescript-eslint/eslint-plugin": "^2.33.0",
"@typescript-eslint/parser": "^2.33.0",
"eslint": "^7.0.0",
"rimraf": "^3.0.2",
"typescript": "^3.8.3"
"typescript": "^3.9.2"
}
}
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