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.3.12 to 0.3.14

7

auth.d.ts

@@ -0,10 +1,7 @@

/// <reference types="enonic-types" />
import { IOEither } from "fp-ts/IOEither";
import { Option } from "fp-ts/Option";
import { AuthLibrary, ChangePasswordParams, CreateGroupParams, CreateRoleParams, CreateUserParams, FindPrincipalsParams, FindPrincipalsResult, FindUsersParams, GetProfileParams, Group, LoginParams, LoginResult, ModifyGroupParams, ModifyProfileParams, ModifyRoleParams, ModifyUserParams, Principal, Role, User, UserQueryResult, UserWithProfile } from "enonic-types/auth";
import type { ChangePasswordParams, CreateGroupParams, CreateRoleParams, CreateUserParams, FindPrincipalsParams, FindPrincipalsResult, FindUsersParams, GetProfileParams, Group, LoginParams, LoginResult, ModifyGroupParams, ModifyProfileParams, ModifyRoleParams, ModifyUserParams, Principal, Role, User, UserQueryResult, UserWithProfile } from "/lib/xp/auth";
import { EnonicError } from "./errors";
/**
* Replace the library with a mocked version
*/
export declare function setLibrary(library: AuthLibrary): void;
/**
* Login a user through the specified idProvider, with userName and password.

@@ -11,0 +8,0 @@ */

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getMemberships = exports.getMembers = exports.modifyGroup = exports.createGroup = exports.modifyRole = exports.hasRole = exports.createRole = exports.getPrincipal = exports.findPrincipals = exports.deletePrincipal = exports.removeMembers = exports.addMembers = exports.createUser = exports.modifyUser = exports.findUsers = exports.getIdProviderConfig = exports.modifyProfile = exports.getProfile = exports.getUser = exports.generatePassword = exports.changePassword = exports.logout = exports.login = exports.setLibrary = void 0;
exports.getMemberships = exports.getMembers = exports.modifyGroup = exports.createGroup = exports.modifyRole = exports.hasRole = exports.createRole = exports.getPrincipal = exports.findPrincipals = exports.deletePrincipal = exports.removeMembers = exports.addMembers = exports.createUser = exports.modifyUser = exports.findUsers = exports.getIdProviderConfig = exports.modifyProfile = exports.getProfile = exports.getUser = exports.generatePassword = exports.changePassword = exports.logout = exports.login = void 0;
var Option_1 = require("fp-ts/Option");
var errors_1 = require("./errors");
var authLib = __non_webpack_require__("/lib/xp/auth");
var authLib = require("/lib/xp/auth");
/**
* Replace the library with a mocked version
*/
function setLibrary(library) {
authLib = library;
}
exports.setLibrary = setLibrary;
/**
* Login a user through the specified idProvider, with userName and password.
*/
function login(params) {
return errors_1.catchEnonicError(function () { return authLib.login(params); });
return (0, errors_1.catchEnonicError)(function () { return authLib.login(params); });
}

@@ -25,3 +18,3 @@ exports.login = login;

function logout() {
return errors_1.catchEnonicError(function () { return authLib.logout(); });
return (0, errors_1.catchEnonicError)(function () { return authLib.logout(); });
}

@@ -33,3 +26,3 @@ exports.logout = logout;

function changePassword(params) {
return errors_1.catchEnonicError(function () { return authLib.changePassword(params); });
return (0, errors_1.catchEnonicError)(function () { return authLib.changePassword(params); });
}

@@ -48,3 +41,3 @@ exports.changePassword = changePassword;

function getUser() {
return Option_1.fromNullable(authLib.getUser());
return (0, Option_1.fromNullable)(authLib.getUser());
}

@@ -56,3 +49,3 @@ exports.getUser = getUser;

function getProfile(params) {
return errors_1.catchEnonicError(function () { return authLib.getProfile(params); });
return (0, errors_1.catchEnonicError)(function () { return authLib.getProfile(params); });
}

@@ -64,3 +57,3 @@ exports.getProfile = getProfile;

function modifyProfile(params) {
return errors_1.catchEnonicError(function () { return authLib.modifyProfile(params); });
return (0, errors_1.catchEnonicError)(function () { return authLib.modifyProfile(params); });
}

@@ -72,7 +65,7 @@ exports.modifyProfile = modifyProfile;

function getIdProviderConfig() {
return Option_1.fromNullable(authLib.getIdProviderConfig());
return (0, Option_1.fromNullable)(authLib.getIdProviderConfig());
}
exports.getIdProviderConfig = getIdProviderConfig;
function findUsers(params) {
return errors_1.catchEnonicError(function () { return (params.includeProfile ? authLib.findUsers(params) : authLib.findUsers(params)); });
return (0, errors_1.catchEnonicError)(function () { return (params.includeProfile ? authLib.findUsers(params) : authLib.findUsers(params)); });
}

@@ -84,3 +77,3 @@ exports.findUsers = findUsers;

function modifyUser(params) {
return errors_1.catchEnonicError(function () { return authLib.modifyUser(params); });
return (0, errors_1.catchEnonicError)(function () { return authLib.modifyUser(params); });
}

@@ -92,3 +85,3 @@ exports.modifyUser = modifyUser;

function createUser(params) {
return errors_1.catchEnonicError(function () { return authLib.createUser(params); });
return (0, errors_1.catchEnonicError)(function () { return authLib.createUser(params); });
}

@@ -100,3 +93,3 @@ exports.createUser = createUser;

function addMembers(principalKey, members) {
return errors_1.catchEnonicError(function () { return authLib.addMembers(principalKey, members); });
return (0, errors_1.catchEnonicError)(function () { return authLib.addMembers(principalKey, members); });
}

@@ -108,3 +101,3 @@ exports.addMembers = addMembers;

function removeMembers(principalKey, members) {
return errors_1.catchEnonicError(function () { return authLib.removeMembers(principalKey, members); });
return (0, errors_1.catchEnonicError)(function () { return authLib.removeMembers(principalKey, members); });
}

@@ -116,3 +109,3 @@ exports.removeMembers = removeMembers;

function deletePrincipal(principalKey) {
return errors_1.catchEnonicError(function () { return authLib.deletePrincipal(principalKey); });
return (0, errors_1.catchEnonicError)(function () { return authLib.deletePrincipal(principalKey); });
}

@@ -124,3 +117,3 @@ exports.deletePrincipal = deletePrincipal;

function findPrincipals(params) {
return errors_1.catchEnonicError(function () { return authLib.findPrincipals(params); });
return (0, errors_1.catchEnonicError)(function () { return authLib.findPrincipals(params); });
}

@@ -132,3 +125,3 @@ exports.findPrincipals = findPrincipals;

function getPrincipal(principalKey) {
return Option_1.fromNullable(authLib.getPrincipal(principalKey));
return (0, Option_1.fromNullable)(authLib.getPrincipal(principalKey));
}

@@ -140,3 +133,3 @@ exports.getPrincipal = getPrincipal;

function createRole(params) {
return errors_1.catchEnonicError(function () { return authLib.createRole(params); });
return (0, errors_1.catchEnonicError)(function () { return authLib.createRole(params); });
}

@@ -148,3 +141,3 @@ exports.createRole = createRole;

function hasRole(role) {
return errors_1.catchEnonicError(function () { return authLib.hasRole(role); });
return (0, errors_1.catchEnonicError)(function () { return authLib.hasRole(role); });
}

@@ -156,3 +149,3 @@ exports.hasRole = hasRole;

function modifyRole(params) {
return errors_1.catchEnonicError(function () { return authLib.modifyRole(params); });
return (0, errors_1.catchEnonicError)(function () { return authLib.modifyRole(params); });
}

@@ -164,3 +157,3 @@ exports.modifyRole = modifyRole;

function createGroup(params) {
return errors_1.catchEnonicError(function () { return authLib.createGroup(params); });
return (0, errors_1.catchEnonicError)(function () { return authLib.createGroup(params); });
}

@@ -172,3 +165,3 @@ exports.createGroup = createGroup;

function modifyGroup(params) {
return errors_1.catchEnonicError(function () { return authLib.modifyGroup(params); });
return (0, errors_1.catchEnonicError)(function () { return authLib.modifyGroup(params); });
}

@@ -180,3 +173,3 @@ exports.modifyGroup = modifyGroup;

function getMembers(principalKey) {
return errors_1.catchEnonicError(function () { return authLib.getMembers(principalKey); });
return (0, errors_1.catchEnonicError)(function () { return authLib.getMembers(principalKey); });
}

@@ -188,4 +181,4 @@ exports.getMembers = getMembers;

function getMemberships(principalKey, transitive) {
return errors_1.catchEnonicError(function () { return authLib.getMemberships(principalKey, transitive); });
return (0, errors_1.catchEnonicError)(function () { return authLib.getMemberships(principalKey, transitive); });
}
exports.getMemberships = getMemberships;

@@ -1,7 +0,2 @@

import { CommonLibrary } from "enonic-types/common";
/**
* Replace the library with a mocked version
*/
export declare function setLibrary(library: CommonLibrary): void;
/**
* Transform a text string so that it can be safely used in cases where the range of accepted characters is restricted.

@@ -8,0 +3,0 @@ * Some usage examples are: as an XP content or node name, as a principal name, in a URL or in a filesystem path.

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.sanitize = exports.setLibrary = void 0;
var commonLib = __non_webpack_require__("/lib/xp/common");
exports.sanitize = void 0;
var commonLib = require("/lib/xp/common");
/**
* Replace the library with a mocked version
*/
function setLibrary(library) {
commonLib = library;
}
exports.setLibrary = setLibrary;
/**
* Transform a text string so that it can be safely used in cases where the range of accepted characters is restricted.

@@ -14,0 +7,0 @@ * Some usage examples are: as an XP content or node name, as a principal name, in a URL or in a filesystem path.

@@ -0,9 +1,6 @@

/// <reference types="enonic-types" />
import { IOEither } from "fp-ts/IOEither";
import { Semigroup } from "fp-ts/Semigroup";
import { AddAttachmentParams, Attachments, AttachmentStreamParams, ByteSource, Content, ContentLibrary, ContentType, CreateContentParams, CreateMediaParams, DeleteContentParams, ExistsParams, GetChildrenParams, GetContentParams, GetOutboundDependenciesParams, GetPermissionsParams, GetPermissionsResult, GetSiteConfigParams, GetSiteParams, ModifyContentParams, MoveParams, Page, PublishContentParams, PublishResponse, QueryContentParams, QueryContentParamsWithSort, QueryResponse, QueryResponseMetaDataScore, QueryResponseMetaDataSort, RemoveAttachmentParams, SetPermissionsParams, Site, UnpublishContentParams } from "enonic-types/content";
import type { AddAttachmentParams, Attachments, AttachmentStreamParams, ByteSource, Content, ContentType, CreateContentParams, CreateMediaParams, DeleteContentParams, ExistsParams, GetChildrenParams, GetContentParams, GetOutboundDependenciesParams, GetPermissionsParams, GetPermissionsResult, GetSiteConfigParams, GetSiteParams, ModifyContentParams, MoveParams, Page, PublishContentParams, PublishResponse, QueryContentParams, QueryContentParamsWithSort, QueryResponse, QueryResponseMetaDataScore, QueryResponseMetaDataSort, RemoveAttachmentParams, SetPermissionsParams, Site, UnpublishContentParams } from "/lib/xp/content";
import { EnonicError } from "./errors";
/**
* Replace the library with a mocked version
*/
export declare function setLibrary(library: ContentLibrary): void;
export declare function get<A extends object>(params: GetContentParams): IOEither<EnonicError, Content<A>>;

@@ -10,0 +7,0 @@ export declare function get<A extends object>(key: string): IOEither<EnonicError, Content<A>>;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isContent = 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 = exports.setLibrary = void 0;
exports.isContent = 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 function_1 = require("fp-ts/function");

@@ -9,24 +9,17 @@ var IOEither_1 = require("fp-ts/IOEither");

var errors_1 = require("./errors");
var contentLib = __non_webpack_require__("/lib/xp/content");
/**
* Replace the library with a mocked version
*/
function setLibrary(library) {
contentLib = library;
}
exports.setLibrary = setLibrary;
var contentLib = require("/lib/xp/content");
function get(paramsOrKey) {
return function_1.pipe(utils_1.stringToByKey(paramsOrKey), function (params) { return errors_1.catchEnonicError(function () { return contentLib.get(params); }); }, IOEither_1.chain(utils_1.fromNullable(errors_1.notFoundError)));
return (0, function_1.pipe)((0, utils_1.stringToByKey)(paramsOrKey), function (params) { return (0, errors_1.catchEnonicError)(function () { return contentLib.get(params); }); }, (0, IOEither_1.chain)((0, utils_1.fromNullable)(errors_1.notFoundError)));
}
exports.get = get;
function query(params) {
return errors_1.catchEnonicError(function () { return contentLib.query(params); });
return (0, errors_1.catchEnonicError)(function () { return contentLib.query(params); });
}
exports.query = query;
function create(params) {
return errors_1.catchEnonicError(function () { return contentLib.create(params); });
return (0, errors_1.catchEnonicError)(function () { return contentLib.create(params); });
}
exports.create = create;
function modify(params) {
return errors_1.catchEnonicError(function () { return contentLib.modify(params); });
return (0, errors_1.catchEnonicError)(function () { return contentLib.modify(params); });
}

@@ -40,3 +33,3 @@ exports.modify = modify;

return function (newContent) {
return errors_1.catchEnonicError(function () {
return (0, errors_1.catchEnonicError)(function () {
var _a;

@@ -55,4 +48,4 @@ return contentLib.modify({

function getContentSemigroup(dataSemigroup, pageConfigSemigroup, xDataSemigroup) {
if (pageConfigSemigroup === void 0) { pageConfigSemigroup = Semigroup_1.last(); }
if (xDataSemigroup === void 0) { xDataSemigroup = Semigroup_1.last(); }
if (pageConfigSemigroup === void 0) { pageConfigSemigroup = (0, Semigroup_1.last)(); }
if (xDataSemigroup === void 0) { xDataSemigroup = (0, Semigroup_1.last)(); }
return {

@@ -87,8 +80,8 @@ concat: function (x, y) {

function remove(paramsOrKey) {
return function_1.pipe(utils_1.stringToByKey(paramsOrKey), function (params) { return errors_1.catchEnonicError(function () { return contentLib.delete(params); }); }, IOEither_1.chain(function (success) { return (success ? IOEither_1.right(undefined) : IOEither_1.left(errors_1.notFoundError)); }));
return (0, function_1.pipe)((0, utils_1.stringToByKey)(paramsOrKey), function (params) { return (0, errors_1.catchEnonicError)(function () { return contentLib.delete(params); }); }, (0, IOEither_1.chain)(function (success) { return (success ? (0, IOEither_1.right)(undefined) : (0, IOEither_1.left)(errors_1.notFoundError)); }));
}
exports.remove = remove;
function exists(paramsOrKey) {
return function_1.pipe(utils_1.stringToByKey(paramsOrKey), function (params) {
return errors_1.catchEnonicError(function () { return contentLib.exists(params); }, errors_1.internalServerError);
return (0, function_1.pipe)((0, utils_1.stringToByKey)(paramsOrKey), function (params) {
return (0, errors_1.catchEnonicError)(function () { return contentLib.exists(params); }, errors_1.internalServerError);
});

@@ -98,3 +91,3 @@ }

function publish(paramsOrKey) {
var params = utils_1.isString(paramsOrKey)
var params = (0, utils_1.isString)(paramsOrKey)
? {

@@ -112,17 +105,17 @@ keys: [paramsOrKey],

: paramsOrKey;
return errors_1.catchEnonicError(function () { return contentLib.publish(params); }, errors_1.publishError);
return (0, errors_1.catchEnonicError)(function () { return contentLib.publish(params); }, errors_1.publishError);
}
exports.publish = publish;
function unpublish(paramsOrKey) {
var params = utils_1.isString(paramsOrKey) ? { keys: [paramsOrKey] } : paramsOrKey;
return errors_1.catchEnonicError(function () { return contentLib.unpublish(params); }, errors_1.unPublishError);
var params = (0, utils_1.isString)(paramsOrKey) ? { keys: [paramsOrKey] } : paramsOrKey;
return (0, errors_1.catchEnonicError)(function () { return contentLib.unpublish(params); }, errors_1.unPublishError);
}
exports.unpublish = unpublish;
function getChildren(params) {
return errors_1.catchEnonicError(function () { return contentLib.getChildren(params); });
return (0, errors_1.catchEnonicError)(function () { return contentLib.getChildren(params); });
}
exports.getChildren = getChildren;
function getOutboundDependencies(paramsOrKey) {
return function_1.pipe(utils_1.stringToByKey(paramsOrKey), function (params) {
return errors_1.catchEnonicError(function () { return contentLib.getOutboundDependencies(params); });
return (0, function_1.pipe)((0, utils_1.stringToByKey)(paramsOrKey), function (params) {
return (0, errors_1.catchEnonicError)(function () { return contentLib.getOutboundDependencies(params); });
});

@@ -132,8 +125,8 @@ }

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

@@ -143,39 +136,39 @@ }

function getSiteConfig(params) {
return errors_1.catchEnonicError(function () { return contentLib.getSiteConfig(params); });
return (0, errors_1.catchEnonicError)(function () { return contentLib.getSiteConfig(params); });
}
exports.getSiteConfig = getSiteConfig;
function createMedia(params) {
return errors_1.catchEnonicError(function () { return contentLib.createMedia(params); });
return (0, errors_1.catchEnonicError)(function () { return contentLib.createMedia(params); });
}
exports.createMedia = createMedia;
function addAttachment(params) {
return errors_1.catchEnonicError(function () { return contentLib.addAttachment(params); });
return (0, errors_1.catchEnonicError)(function () { return contentLib.addAttachment(params); });
}
exports.addAttachment = addAttachment;
function getAttachments(key) {
return function_1.pipe(errors_1.catchEnonicError(function () { return contentLib.getAttachments(key); }), IOEither_1.chain(utils_1.fromNullable(errors_1.notFoundError)));
return (0, function_1.pipe)((0, errors_1.catchEnonicError)(function () { return contentLib.getAttachments(key); }), (0, IOEither_1.chain)((0, utils_1.fromNullable)(errors_1.notFoundError)));
}
exports.getAttachments = getAttachments;
function getAttachmentStream(params) {
return function_1.pipe(errors_1.catchEnonicError(function () { return contentLib.getAttachmentStream(params); }), IOEither_1.chain(utils_1.fromNullable(errors_1.notFoundError)));
return (0, function_1.pipe)((0, errors_1.catchEnonicError)(function () { return contentLib.getAttachmentStream(params); }), (0, IOEither_1.chain)((0, utils_1.fromNullable)(errors_1.notFoundError)));
}
exports.getAttachmentStream = getAttachmentStream;
function removeAttachment(params) {
return errors_1.catchEnonicError(function () { return contentLib.removeAttachment(params); });
return (0, errors_1.catchEnonicError)(function () { return contentLib.removeAttachment(params); });
}
exports.removeAttachment = removeAttachment;
function getPermissions(params) {
return errors_1.catchEnonicError(function () { return contentLib.getPermissions(params); });
return (0, errors_1.catchEnonicError)(function () { return contentLib.getPermissions(params); });
}
exports.getPermissions = getPermissions;
function setPermissions(params) {
return errors_1.catchEnonicError(function () { return contentLib.setPermissions(params); });
return (0, errors_1.catchEnonicError)(function () { return contentLib.setPermissions(params); });
}
exports.setPermissions = setPermissions;
function getType(name) {
return function_1.pipe(errors_1.catchEnonicError(function () { return contentLib.getType(name); }), IOEither_1.chain(utils_1.fromNullable(errors_1.notFoundError)));
return (0, function_1.pipe)((0, errors_1.catchEnonicError)(function () { return contentLib.getType(name); }), (0, IOEither_1.chain)((0, utils_1.fromNullable)(errors_1.notFoundError)));
}
exports.getType = getType;
function getTypes() {
return errors_1.catchEnonicError(function () { return contentLib.getTypes(); });
return (0, errors_1.catchEnonicError)(function () { return contentLib.getTypes(); });
}

@@ -182,0 +175,0 @@ exports.getTypes = getTypes;

@@ -0,11 +1,8 @@

/// <reference types="enonic-types" />
import { IO } from "fp-ts/IO";
import { IOEither } from "fp-ts/IOEither";
import { Context, ContextLibrary, RunContext } from "enonic-types/context";
import type { Context, RunContext } from "/lib/xp/context";
import { EnonicError } from "./errors";
/**
* Replace the library with a mocked version
*/
export declare function setLibrary(library: ContextLibrary): void;
export declare function get(): IOEither<EnonicError, Context>;
export declare function runUnsafe<A>(runContext: RunContext, f: () => A): A;
export declare function run(runContext: RunContext): <A>(a: IO<A>) => IO<A>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.run = exports.runUnsafe = exports.get = exports.setLibrary = void 0;
exports.run = exports.runUnsafe = exports.get = void 0;
var errors_1 = require("./errors");
var contextLib = __non_webpack_require__("/lib/xp/context");
/**
* Replace the library with a mocked version
*/
function setLibrary(library) {
contextLib = library;
}
exports.setLibrary = setLibrary;
var contextLib = require("/lib/xp/context");
function get() {
return errors_1.catchEnonicError(function () { return contextLib.get(); });
return (0, errors_1.catchEnonicError)(function () { return contextLib.get(); });
}

@@ -16,0 +9,0 @@ exports.get = get;

@@ -1,12 +0,12 @@

import { Request, Response, ResponseType } from "enonic-types/controller";
/// <reference types="enonic-types" />
import { IO } from "fp-ts/IO";
import { ResourceKey } from "enonic-types/thymeleaf";
import { ResourceKey } from "/lib/thymeleaf";
import { EnonicError } from "./errors";
import { LocalizeParams } from "enonic-types/i18n";
export declare type AsResponse = (body: ResponseType, extras?: Partial<Response>) => IO<Response>;
export declare type AsErrorResponse = (err: EnonicError, extras?: Partial<Response>) => IO<Response>;
import { LocalizeParams } from "/lib/xp/i18n";
export declare type AsResponse = (body: XP.ResponseType, extras?: Partial<XP.Response>) => IO<XP.Response>;
export declare type AsErrorResponse = (err: EnonicError, extras?: Partial<XP.Response>) => IO<XP.Response>;
export declare const ok: AsResponse;
export declare const created: AsResponse;
export declare const noContent: AsResponse;
export declare const redirect: (redirect: string) => IO<Response>;
export declare const redirect: (redirect: string) => IO<XP.Response>;
export declare const badRequest: AsResponse;

@@ -22,3 +22,3 @@ export declare const unauthorized: AsResponse;

*/
export declare function errorResponse(req?: Request): AsErrorResponse;
export declare function errorResponse(req?: XP.Request): AsErrorResponse;
export declare function errorResponse(params: ErrorResponseParams): AsErrorResponse;

@@ -29,3 +29,3 @@ export declare type LocalizeWithPrefixParams = Omit<LocalizeParams, "key"> & {

export interface ErrorResponseParams {
readonly req?: Request;
readonly req?: XP.Request;
readonly localizeParams?: LocalizeWithPrefixParams;

@@ -40,3 +40,3 @@ }

*/
export declare function status(httpStatus: number, body?: ResponseType, extras?: Partial<Response>): IO<Response>;
export declare function status(error: EnonicError, body?: ResponseType, extras?: Partial<Response>): IO<Response>;
export declare function status(httpStatus: number, body?: XP.ResponseType, extras?: Partial<XP.Response>): IO<XP.Response>;
export declare function status(error: EnonicError, body?: XP.ResponseType, extras?: Partial<XP.Response>): IO<XP.Response>;

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

if (extras === void 0) { extras = {}; }
return IO_1.of(__assign(__assign({}, extras), { status: 204, body: "" }));
return (0, IO_1.of)(__assign(__assign({}, extras), { status: 204, body: "" }));
};
exports.noContent = noContent;
var redirect = function (redirect) {
return IO_1.of({
return (0, IO_1.of)({
applyFilters: false,

@@ -72,3 +72,3 @@ postProcess: false,

var _a, _b;
var typeString = utils_1.substringAfter(err.type, "/");
var typeString = (0, utils_1.substringAfter)(err.type, "/");
var i18nPrefix = (_b = (_a = params === null || params === void 0 ? void 0 : params.localizeParams) === null || _a === void 0 ? void 0 : _a.i18nPrefix) !== null && _b !== void 0 ? _b : "errors";

@@ -86,3 +86,3 @@ // keys to try to look up in order

];
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]; }));
return (0, function_1.pipe)(titleKeys.map(function (key) { return (__assign(__assign({}, params === null || params === void 0 ? void 0 : params.localizeParams), { key: key })); }), i18n_1.localizeFirst, (0, Option_1.getOrElse)(function () { return err[fieldName]; }));
}

@@ -95,3 +95,3 @@ /**

if (extras === void 0) { extras = {}; }
return status(err, thymeleaf_1.getUnsafeRenderer(view)(err), extras);
return status(err, (0, thymeleaf_1.getUnsafeRenderer)(view)(err), extras);
};

@@ -104,3 +104,3 @@ }

function contentType(body) {
return typeof body === "string" ? "text/html" : errors_1.isEnonicError(body) ? "application/problem+json" : "application/json";
return typeof body === "string" ? "text/html" : (0, errors_1.isEnonicError)(body) ? "application/problem+json" : "application/json";
}

@@ -113,4 +113,4 @@ function status(httpStatusOrError, body, extras) {

return isTurboStream(body)
? IO_1.of(__assign(__assign({ contentType: turbo_1.getTurboStreamsMimetype() }, extras), { status: httpStatus, body: turbo_1.serialize(body) }))
: IO_1.of(__assign(__assign({ contentType: contentType(body) }, extras), { status: httpStatus, body: body }));
? (0, IO_1.of)(__assign(__assign({ contentType: (0, turbo_1.getTurboStreamsMimetype)() }, extras), { status: httpStatus, body: (0, turbo_1.serialize)(body) }))
: (0, IO_1.of)(__assign(__assign({ contentType: contentType(body) }, extras), { status: httpStatus, body: body }));
}

@@ -125,3 +125,3 @@ exports.status = status;

function isTurboStream(v) {
return turbo_1.isTurboStreamAction(v instanceof Array ? v[0] : v);
return (0, turbo_1.isTurboStreamAction)(v instanceof Array ? v[0] : v);
}

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

import { ByteSource } from "enonic-types/content";
/// <reference types="enonic-types" />
import { ByteSource } from "/lib/xp/content";
import { IOEither } from "fp-ts/IOEither";
import { EnonicError } from "./errors";
import { EncodingLibrary } from "enonic-types/encoding";
/**
* Replace the library with a mocked version
*/
export declare function setLibrary(library: EncodingLibrary): void;
export declare function base64Encode(stream: ByteSource | string): string;

@@ -10,0 +6,0 @@ export declare function base64Decode(text: string): IOEither<EnonicError, ByteSource>;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.hmacSha512AsStream = exports.hmacSha512AsHex = exports.hmacSha256AsStream = exports.hmacSha256AsHex = exports.hmacSha1AsStream = exports.hmacSha1AsHex = exports.sha512 = exports.sha256 = exports.sha1 = exports.md5 = exports.htmlUnescape = exports.htmlEscape = exports.urlUnescape = exports.urlEscape = exports.xmlUnescape = exports.xmlEscape = exports.charsetEncode = exports.charsetDecode = exports.hexDecode = exports.hexEncode = exports.base32Decode = exports.base32Encode = exports.base64UrlDecode = exports.base64UrlEncode = exports.base64Decode = exports.base64Encode = exports.setLibrary = void 0;
exports.hmacSha512AsStream = exports.hmacSha512AsHex = exports.hmacSha256AsStream = exports.hmacSha256AsHex = exports.hmacSha1AsStream = exports.hmacSha1AsHex = exports.sha512 = exports.sha256 = exports.sha1 = exports.md5 = exports.htmlUnescape = exports.htmlEscape = exports.urlUnescape = exports.urlEscape = exports.xmlUnescape = exports.xmlEscape = exports.charsetEncode = exports.charsetDecode = exports.hexDecode = exports.hexEncode = exports.base32Decode = exports.base32Encode = exports.base64UrlDecode = exports.base64UrlEncode = exports.base64Decode = exports.base64Encode = void 0;
var IOEither_1 = require("fp-ts/IOEither");

@@ -8,10 +8,3 @@ var utils_1 = require("./utils");

var errors_1 = require("./errors");
var encodingLib = __non_webpack_require__("/lib/text-encoding");
/**
* Replace the library with a mocked version
*/
function setLibrary(library) {
encodingLib = library;
}
exports.setLibrary = setLibrary;
var encodingLib = require("/lib/text-encoding");
function base64Encode(stream) {

@@ -22,3 +15,3 @@ return encodingLib.base64Encode(stream);

function base64Decode(text) {
return function_1.pipe(errors_1.catchEnonicError(function () { return encodingLib.base64Decode(text); }), IOEither_1.chain(utils_1.fromNullable(errors_1.notFoundError)));
return (0, function_1.pipe)((0, errors_1.catchEnonicError)(function () { return encodingLib.base64Decode(text); }), (0, IOEither_1.chain)((0, utils_1.fromNullable)(errors_1.notFoundError)));
}

@@ -31,3 +24,3 @@ exports.base64Decode = base64Decode;

function base64UrlDecode(text) {
return function_1.pipe(errors_1.catchEnonicError(function () { return encodingLib.base64UrlDecode(text); }), IOEither_1.chain(utils_1.fromNullable(errors_1.notFoundError)));
return (0, function_1.pipe)((0, errors_1.catchEnonicError)(function () { return encodingLib.base64UrlDecode(text); }), (0, IOEither_1.chain)((0, utils_1.fromNullable)(errors_1.notFoundError)));
}

@@ -40,3 +33,3 @@ exports.base64UrlDecode = base64UrlDecode;

function base32Decode(text) {
return function_1.pipe(errors_1.catchEnonicError(function () { return encodingLib.base32Decode(text); }), IOEither_1.chain(utils_1.fromNullable(errors_1.notFoundError)));
return (0, function_1.pipe)((0, errors_1.catchEnonicError)(function () { return encodingLib.base32Decode(text); }), (0, IOEither_1.chain)((0, utils_1.fromNullable)(errors_1.notFoundError)));
}

@@ -49,3 +42,3 @@ exports.base32Decode = base32Decode;

function hexDecode(text) {
return function_1.pipe(errors_1.catchEnonicError(function () { return encodingLib.hexDecode(text); }), IOEither_1.chain(utils_1.fromNullable(errors_1.notFoundError)));
return (0, function_1.pipe)((0, errors_1.catchEnonicError)(function () { return encodingLib.hexDecode(text); }), (0, IOEither_1.chain)((0, utils_1.fromNullable)(errors_1.notFoundError)));
}

@@ -52,0 +45,0 @@ exports.hexDecode = hexDecode;

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

if (defaultError === void 0) { defaultError = exports.internalServerError; }
return IOEither_1.tryCatch(f, function (t) {
return (0, IOEither_1.tryCatch)(f, function (t) {
return isJavaThrowable(t) ? throwableToEnonicError(t, defaultError) : defaultError;

@@ -80,0 +80,0 @@ });

@@ -1,7 +0,4 @@

import { EnonicEventData, EventLibrary, ListenerParams, SendParams } from "enonic-types/event";
/**
* Replace the library with a mocked version
*/
export declare function setLibrary(library: EventLibrary): void;
/// <reference types="enonic-types" />
import type { EnonicEventData, ListenerParams, SendParams } from "/lib/xp/event";
export declare function listener<A extends object = EnonicEventData>(params: ListenerParams<A>): null;
export declare function send(params: SendParams): null;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.send = exports.listener = exports.setLibrary = void 0;
var eventLib = __non_webpack_require__("/lib/xp/event");
/**
* Replace the library with a mocked version
*/
function setLibrary(library) {
eventLib = library;
}
exports.setLibrary = setLibrary;
exports.send = exports.listener = void 0;
var eventLib = require("/lib/xp/event");
function listener(params) {

@@ -13,0 +6,0 @@ return eventLib.listener(params);

@@ -0,10 +1,7 @@

/// <reference types="enonic-types" />
import { IOEither } from "fp-ts/IOEither";
import { HttpLibrary, HttpRequestParams, HttpResponse } from "enonic-types/http";
import type { HttpRequestParams, HttpResponse } from "/lib/http-client";
import { EnonicError } from "./errors";
import { Json } from "fp-ts/Json";
import type { Json } from "fp-ts/Json";
/**
* Replace the library with a mocked version
*/
export declare function setLibrary(library: HttpLibrary): void;
/**
* Sends an HTTP request and returns the response received from the remote server.

@@ -11,0 +8,0 @@ * The request is sent synchronously, the execution blocks until the response is received.

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

@@ -8,17 +8,10 @@ var errors_1 = require("./errors");

var function_1 = require("fp-ts/function");
var httpLib = __non_webpack_require__("/lib/http-client");
/**
* Replace the library with a mocked version
*/
function setLibrary(library) {
httpLib = library;
}
exports.setLibrary = setLibrary;
var httpLib = require("/lib/http-client");
function request(paramsOrUrl) {
return errors_1.catchEnonicError(function () { return httpLib.request(utils_1.isString(paramsOrUrl) ? { url: paramsOrUrl } : paramsOrUrl); }, errors_1.badGatewayError);
return (0, errors_1.catchEnonicError)(function () { return httpLib.request((0, utils_1.isString)(paramsOrUrl) ? { url: paramsOrUrl } : paramsOrUrl); }, errors_1.badGatewayError);
}
exports.request = request;
function bodyAsJson(res) {
return function_1.pipe(res.body, utils_1.fromNullable(errors_1.badGatewayError), IOEither_1.chain(function (str) {
return utils_1.parseJSON(str, function (reason) { return ({
return (0, function_1.pipe)(res.body, (0, utils_1.fromNullable)(errors_1.badGatewayError), (0, IOEither_1.chain)(function (str) {
return (0, utils_1.parseJSON)(str, function (reason) { return ({
type: "https://itemconsulting.github.io/problems/bad-gateway",

@@ -25,0 +18,0 @@ title: "Bad Gateway Error",

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

/// <reference types="enonic-types" />
import { Option } from "fp-ts/Option";
import { I18nLibrary, LocalizeParams } from "enonic-types/i18n";
import type { LocalizeParams } from "/lib/xp/i18n";
/**
* Replace the library with a mocked version
*/
export declare function setLibrary(library: I18nLibrary): void;
/**
* Returns an object of key/value-pairs for all phrases with the given locales in the specified bundles.

@@ -9,0 +6,0 @@ */

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.localizeFirst = exports.localize = exports.localizeUnsafe = exports.getSupportedLocales = exports.getPhrases = exports.setLibrary = void 0;
exports.localizeFirst = exports.localize = exports.localizeUnsafe = exports.getSupportedLocales = exports.getPhrases = void 0;
var Option_1 = require("fp-ts/Option");

@@ -8,12 +8,5 @@ var function_1 = require("fp-ts/function");

var Array_1 = require("fp-ts/Array");
var i18nLib = __non_webpack_require__("/lib/xp/i18n");
var i18nLib = require("/lib/xp/i18n");
var NOT_TRANSLATED_MESSAGE = "NOT_TRANSLATED";
/**
* Replace the library with a mocked version
*/
function setLibrary(library) {
i18nLib = library;
}
exports.setLibrary = setLibrary;
/**
* Returns an object of key/value-pairs for all phrases with the given locales in the specified bundles.

@@ -33,3 +26,3 @@ */

function localizeUnsafe(paramsOrKey) {
var params = utils_1.stringToByKey(paramsOrKey);
var params = (0, utils_1.stringToByKey)(paramsOrKey);
return i18nLib.localize(params);

@@ -39,3 +32,3 @@ }

function localize(paramsOrKey) {
return function_1.pipe(localizeUnsafe(paramsOrKey), Option_1.fromPredicate(function (result) { return result !== NOT_TRANSLATED_MESSAGE; }));
return (0, function_1.pipe)(localizeUnsafe(paramsOrKey), (0, Option_1.fromPredicate)(function (result) { return result !== NOT_TRANSLATED_MESSAGE; }));
}

@@ -47,4 +40,4 @@ exports.localize = localize;

function localizeFirst(keys) {
return Array_1.findFirstMap(localize)(keys);
return (0, Array_1.findFirstMap)(localize)(keys);
}
exports.localizeFirst = localizeFirst;

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

/// <reference types="enonic-types" />
import { IOEither } from "fp-ts/IOEither";
import { EmailParams, MailLibrary } from "enonic-types/mail";
import type { EmailParams } from "/lib/xp/mail";
import { EnonicError } from "./errors";
/**
* Replace the library with a mocked version
*/
export declare function setLibrary(library: MailLibrary): void;
export declare function send(params: EmailParams): IOEither<EnonicError, void>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.send = exports.setLibrary = void 0;
exports.send = void 0;
var IOEither_1 = require("fp-ts/IOEither");
var function_1 = require("fp-ts/function");
var errors_1 = require("./errors");
var mailLib = __non_webpack_require__("/lib/xp/mail");
/**
* Replace the library with a mocked version
*/
function setLibrary(library) {
mailLib = library;
}
exports.setLibrary = setLibrary;
var mailLib = require("/lib/xp/mail");
function send(params) {
return function_1.pipe(errors_1.catchEnonicError(function () { return mailLib.send(params); }), IOEither_1.chain(function (success) { return (success ? IOEither_1.right(undefined) : IOEither_1.left(errors_1.internalServerError)); }));
return (0, function_1.pipe)((0, errors_1.catchEnonicError)(function () { return mailLib.send(params); }), (0, IOEither_1.chain)(function (success) { return (success ? (0, IOEither_1.right)(undefined) : (0, IOEither_1.left)(errors_1.internalServerError)); }));
}
exports.send = send;

@@ -1,11 +0,8 @@

import { BreadcrumbMenu, GetBreadcrumbMenuParams, GetMenuParams, GetMenuTreeParams, MenuItem, MenuLibrary, MenuTree } from "enonic-types/menu";
import { Content } from "enonic-types/content";
/// <reference types="enonic-types" />
import type { BreadcrumbMenu, GetBreadcrumbMenuParams, GetMenuParams, GetMenuTreeParams, MenuItem, MenuTree } from "/lib/menu";
import type { Content } from "/lib/xp/content";
import { IOEither } from "fp-ts/IOEither";
import { EnonicError } from "./errors";
/**
* Replace the library with a mocked version
*/
export declare function setLibrary(library: MenuLibrary): void;
export declare function getBreadcrumbMenu(params: GetBreadcrumbMenuParams): IOEither<EnonicError, BreadcrumbMenu>;
export declare function getMenuTree(levels: number, params?: GetMenuTreeParams): IOEither<EnonicError, MenuTree>;
export declare function getSubMenus(levels?: number, params?: GetMenuParams): (parentContent: Content) => IOEither<EnonicError, ReadonlyArray<MenuItem>>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getSubMenus = exports.getMenuTree = exports.getBreadcrumbMenu = exports.setLibrary = void 0;
exports.getSubMenus = exports.getMenuTree = exports.getBreadcrumbMenu = void 0;
var errors_1 = require("./errors");
var menuLib = __non_webpack_require__("/lib/menu");
/**
* Replace the library with a mocked version
*/
function setLibrary(library) {
menuLib = library;
}
exports.setLibrary = setLibrary;
var menuLib = require("/lib/menu");
function getBreadcrumbMenu(params) {
return errors_1.catchEnonicError(function () { return menuLib.getBreadcrumbMenu(params); });
return (0, errors_1.catchEnonicError)(function () { return menuLib.getBreadcrumbMenu(params); });
}
exports.getBreadcrumbMenu = getBreadcrumbMenu;
function getMenuTree(levels, params) {
return errors_1.catchEnonicError(function () { return menuLib.getMenuTree(levels, params); });
return (0, errors_1.catchEnonicError)(function () { return menuLib.getMenuTree(levels, params); });
}

@@ -23,5 +16,5 @@ exports.getMenuTree = getMenuTree;

return function (parentContent) {
return errors_1.catchEnonicError(function () { return menuLib.getSubMenus(parentContent, levels, params); });
return (0, errors_1.catchEnonicError)(function () { return menuLib.getSubMenus(parentContent, levels, params); });
};
}
exports.getSubMenus = getSubMenus;

@@ -0,9 +1,6 @@

/// <reference types="enonic-types" />
import { IOEither } from "fp-ts/IOEither";
import { DiffParams, DiffResponse, FindVersionsParams, MultiRepoConnection, MultiRepoConnectParams, NodeCreateParams, NodeFindChildrenParams, NodeGetParams, NodeLibrary, NodeModifyParams, NodeQueryParams, NodeQueryResponse, NodeVersionQueryResult, RepoConnection, RepoNode, Source } from "enonic-types/node";
import type { DiffParams, DiffResponse, FindVersionsParams, MultiRepoConnection, MultiRepoConnectParams, NodeCreateParams, NodeFindChildrenParams, NodeGetParams, NodeModifyParams, NodeQueryParams, NodeQueryResponse, NodeVersionQueryResult, RepoConnection, RepoNode, Source } from "/lib/xp/node";
import { EnonicError } from "./errors";
/**
* Replace the library with a mocked version
*/
export declare function setLibrary(library: NodeLibrary): void;
/**
* Creates a connection to a repository with a given branch and authentication info.

@@ -10,0 +7,0 @@ */

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.findChildren = exports.modify = exports.query = exports.get = exports.findVersions = exports.exists = exports.diff = exports.remove = exports.create = exports.multiRepoConnect = exports.connect = exports.setLibrary = void 0;
exports.findChildren = exports.modify = exports.query = exports.get = exports.findVersions = exports.exists = exports.diff = exports.remove = exports.create = exports.multiRepoConnect = exports.connect = void 0;
var errors_1 = require("./errors");
var nodeLib = __non_webpack_require__("/lib/xp/node");
var nodeLib = require("/lib/xp/node");
/**
* Replace the library with a mocked version
*/
function setLibrary(library) {
nodeLib = library;
}
exports.setLibrary = setLibrary;
/**
* Creates a connection to a repository with a given branch and authentication info.
*/
function connect(params) {
return errors_1.catchEnonicError(function () { return nodeLib.connect(params); });
return (0, errors_1.catchEnonicError)(function () { return nodeLib.connect(params); });
}

@@ -24,3 +17,3 @@ exports.connect = connect;

function multiRepoConnect(params) {
return errors_1.catchEnonicError(function () { return nodeLib.multiRepoConnect(params); });
return (0, errors_1.catchEnonicError)(function () { return nodeLib.multiRepoConnect(params); });
}

@@ -33,3 +26,3 @@ exports.multiRepoConnect = multiRepoConnect;

function create(repo, params) {
return errors_1.catchEnonicError(function () { return repo.create(params); });
return (0, errors_1.catchEnonicError)(function () { return repo.create(params); });
}

@@ -41,3 +34,3 @@ exports.create = create;

function remove(repo, keys) {
return errors_1.catchEnonicError(function () { return repo.delete(keys); });
return (0, errors_1.catchEnonicError)(function () { return repo.delete(keys); });
}

@@ -49,3 +42,3 @@ exports.remove = remove;

function diff(repo, params) {
return errors_1.catchEnonicError(function () { return repo.diff(params); });
return (0, errors_1.catchEnonicError)(function () { return repo.diff(params); });
}

@@ -57,3 +50,3 @@ exports.diff = diff;

function exists(repo, keys) {
return errors_1.catchEnonicError(function () { return repo.exists(keys); });
return (0, errors_1.catchEnonicError)(function () { return repo.exists(keys); });
}

@@ -65,7 +58,7 @@ exports.exists = exists;

function findVersions(repo, params) {
return errors_1.catchEnonicError(function () { return repo.findVersions(params); });
return (0, errors_1.catchEnonicError)(function () { return repo.findVersions(params); });
}
exports.findVersions = findVersions;
function get(repo, keys) {
return errors_1.catchEnonicError(function () { return repo.get(keys); });
return (0, errors_1.catchEnonicError)(function () { return repo.get(keys); });
}

@@ -77,3 +70,3 @@ exports.get = get;

function query(repo, params) {
return errors_1.catchEnonicError(function () { return repo.query(params); });
return (0, errors_1.catchEnonicError)(function () { return repo.query(params); });
}

@@ -85,3 +78,3 @@ exports.query = query;

function modify(repo, params) {
return errors_1.catchEnonicError(function () { return repo.modify(params); });
return (0, errors_1.catchEnonicError)(function () { return repo.modify(params); });
}

@@ -93,4 +86,4 @@ exports.modify = modify;

function findChildren(repo, params) {
return errors_1.catchEnonicError(function () { return repo.findChildren(params); });
return (0, errors_1.catchEnonicError)(function () { return repo.findChildren(params); });
}
exports.findChildren = findChildren;

@@ -1,9 +0,6 @@

import { KeyPair, NotificationsLibrary, SendAsyncParams, SendParams } from "enonic-types/notifications";
/// <reference types="enonic-types" />
import type { KeyPair, SendAsyncParams, SendParams } from "/lib/notifications";
import { EnonicError } from "./errors";
import { IOEither } from "fp-ts/IOEither";
import type { IOEither } from "fp-ts/IOEither";
/**
* Replace the library with a mocked version
*/
export declare function setLibrary(library: NotificationsLibrary): void;
/**
* Generate a VAPID public/private key pair.

@@ -10,0 +7,0 @@ */

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.sendAsync = exports.send = exports.generateKeyPair = exports.setLibrary = void 0;
exports.sendAsync = exports.send = exports.generateKeyPair = void 0;
var errors_1 = require("./errors");
var notificationsLib = __non_webpack_require__("/lib/notifications");
var notificationsLib = require("/lib/notifications");
/**
* Replace the library with a mocked version
*/
function setLibrary(library) {
notificationsLib = library;
}
exports.setLibrary = setLibrary;
/**
* Generate a VAPID public/private key pair.
*/
function generateKeyPair() {
return errors_1.catchEnonicError(function () { return notificationsLib.generateKeyPair(); });
return (0, errors_1.catchEnonicError)(function () { return notificationsLib.generateKeyPair(); });
}

@@ -24,3 +17,3 @@ exports.generateKeyPair = generateKeyPair;

function send(params) {
return errors_1.catchEnonicError(function () { return notificationsLib.send(params); });
return (0, errors_1.catchEnonicError)(function () { return notificationsLib.send(params); });
}

@@ -32,4 +25,4 @@ exports.send = send;

function sendAsync(params) {
return errors_1.catchEnonicError(function () { return notificationsLib.sendAsync(params); });
return (0, errors_1.catchEnonicError)(function () { return notificationsLib.sendAsync(params); });
}
exports.sendAsync = sendAsync;
{
"name": "enonic-fp",
"version": "0.3.12",
"version": "0.3.14",
"sideEffects": false,

@@ -27,15 +27,15 @@ "description": "Functional programming helpers for Enonic XP",

"dependencies": {
"enonic-types": "^0.2.2",
"fp-ts": "^2.10.5"
"enonic-types": "^0.3.0",
"fp-ts": "^2.11.4"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^4.22.0",
"@typescript-eslint/parser": "^4.22.0",
"eslint": "^7.24.0",
"@typescript-eslint/eslint-plugin": "^4.32.0",
"@typescript-eslint/parser": "^4.32.0",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.0",
"prettier": "^2.3.0",
"eslint-plugin-prettier": "^4.0.0",
"prettier": "^2.4.1",
"rimraf": "^3.0.2",
"typescript": "^4.2.4"
"typescript": "^4.4.3"
}
}

@@ -0,9 +1,6 @@

/// <reference types="enonic-types" />
import { IOEither } from "fp-ts/IOEither";
import { EnonicError } from "./errors";
import { ByteSource, Content, Site } from "enonic-types/content";
import { AssetUrlParams, AttachmentUrlParams, Component, ComponentUrlParams, IdProviderUrlParams, ImagePlaceHolderParams, ImageUrlParams, LoginUrlParams, LogoutUrlParams, MultipartItem, PageUrlParams, PortalLibrary, ProcessHtmlParams, ServiceUrlParams, UrlParams } from "enonic-types/portal";
/**
* Replace the library with a mocked version
*/
export declare function setLibrary(library: PortalLibrary): void;
import type { ByteSource, Content, Site } from "/lib/xp/content";
import type { AssetUrlParams, AttachmentUrlParams, Component, ComponentUrlParams, IdProviderUrlParams, ImagePlaceHolderParams, ImageUrlParams, LoginUrlParams, LogoutUrlParams, MultipartItem, PageUrlParams, ProcessHtmlParams, ServiceUrlParams, UrlParams } from "/lib/xp/portal";
export declare function getContent<A extends object, PageConfig extends object = never>(): IOEither<EnonicError, Content<A, PageConfig>>;

@@ -16,3 +13,3 @@ export declare function getComponent<Config extends object = never>(): IOEither<EnonicError, Component<Config>>;

*/
export declare function getMultipartForm(): IOEither<EnonicError, ReadonlyArray<MultipartItem | ReadonlyArray<MultipartItem>>>;
export declare function getMultipartForm(): IOEither<EnonicError, Record<string, MultipartItem | ReadonlyArray<MultipartItem>>>;
/**

@@ -19,0 +16,0 @@ * This function returns a JSON containing a named multipart item.

"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 = exports.setLibrary = void 0;
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/IOEither");

@@ -8,20 +8,13 @@ var errors_1 = require("./errors");

var function_1 = require("fp-ts/function");
var portalLib = __non_webpack_require__("/lib/xp/portal");
/**
* Replace the library with a mocked version
*/
function setLibrary(library) {
portalLib = library;
}
exports.setLibrary = setLibrary;
var portalLib = require("/lib/xp/portal");
function getContent() {
return function_1.pipe(errors_1.catchEnonicError(function () { return portalLib.getContent(); }), IOEither_1.chain(utils_1.fromNullable(errors_1.notFoundError)));
return (0, function_1.pipe)((0, errors_1.catchEnonicError)(function () { return portalLib.getContent(); }), (0, IOEither_1.chain)((0, utils_1.fromNullable)(errors_1.notFoundError)));
}
exports.getContent = getContent;
function getComponent() {
return function_1.pipe(errors_1.catchEnonicError(function () { return portalLib.getComponent(); }), IOEither_1.chain(utils_1.fromNullable(errors_1.notFoundError)));
return (0, function_1.pipe)((0, errors_1.catchEnonicError)(function () { return portalLib.getComponent(); }), (0, IOEither_1.chain)((0, utils_1.fromNullable)(errors_1.notFoundError)));
}
exports.getComponent = getComponent;
function getIdProviderKey() {
return utils_1.fromNullable(errors_1.missingIdProviderError)(portalLib.getIdProviderKey());
return (0, utils_1.fromNullable)(errors_1.missingIdProviderError)(portalLib.getIdProviderKey());
}

@@ -34,3 +27,3 @@ exports.getIdProviderKey = getIdProviderKey;

function getMultipartForm() {
return errors_1.catchEnonicError(function () { return portalLib.getMultipartForm(); });
return (0, errors_1.catchEnonicError)(function () { return portalLib.getMultipartForm(); });
}

@@ -44,3 +37,3 @@ exports.getMultipartForm = getMultipartForm;

if (index === void 0) { index = 0; }
return errors_1.catchEnonicError(function () { return portalLib.getMultipartItem(name, index); });
return (0, errors_1.catchEnonicError)(function () { return portalLib.getMultipartItem(name, index); });
}

@@ -54,3 +47,3 @@ exports.getMultipartItem = getMultipartItem;

if (index === void 0) { index = 0; }
return errors_1.catchEnonicError(function () { return portalLib.getMultipartStream(name, index); });
return (0, errors_1.catchEnonicError)(function () { return portalLib.getMultipartStream(name, index); });
}

@@ -64,11 +57,11 @@ exports.getMultipartStream = getMultipartStream;

if (index === void 0) { index = 0; }
return errors_1.catchEnonicError(function () { return portalLib.getMultipartText(name, index); });
return (0, errors_1.catchEnonicError)(function () { return portalLib.getMultipartText(name, index); });
}
exports.getMultipartText = getMultipartText;
function getSite() {
return errors_1.catchEnonicError(function () { return portalLib.getSite(); });
return (0, errors_1.catchEnonicError)(function () { return portalLib.getSite(); });
}
exports.getSite = getSite;
function getSiteConfig() {
return errors_1.catchEnonicError(function () { return portalLib.getSiteConfig(); });
return (0, errors_1.catchEnonicError)(function () { return portalLib.getSiteConfig(); });
}

@@ -85,15 +78,15 @@ exports.getSiteConfig = getSiteConfig;

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

@@ -114,3 +107,3 @@ exports.serviceUrl = serviceUrl;

function pageUrl(paramsOrId) {
return function_1.pipe(utils_1.stringToById(paramsOrId), portalLib.pageUrl);
return (0, function_1.pipe)((0, utils_1.stringToById)(paramsOrId), portalLib.pageUrl);
}

@@ -123,3 +116,3 @@ exports.pageUrl = pageUrl;

function processHtml(paramsOrValue) {
return function_1.pipe(utils_1.isString(paramsOrValue) ? { value: paramsOrValue } : paramsOrValue, portalLib.processHtml);
return (0, function_1.pipe)((0, utils_1.isString)(paramsOrValue) ? { value: paramsOrValue } : paramsOrValue, portalLib.processHtml);
}

@@ -126,0 +119,0 @@ exports.processHtml = processHtml;

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

/// <reference types="enonic-types" />
import { IOEither } from "fp-ts/IOEither";
import { EnonicError } from "./errors";
import { AddPermissionsParams, CreateProjectParams, DeleteProjectParams, GetProjectParams, ModifyProjectParams, ModifyReadAccessParams, ModifyReadAccessResult, Project, ProjectLibrary, RemovePermissionsParams } from "enonic-types/project";
/**
* Replace the library with a mocked version
*/
export declare function setLibrary(library: ProjectLibrary): void;
import type { AddPermissionsParams, CreateProjectParams, DeleteProjectParams, GetProjectParams, ModifyProjectParams, ModifyReadAccessParams, ModifyReadAccessResult, Project, RemovePermissionsParams } from "/lib/xp/project";
export declare function addPermissions(params: AddPermissionsParams): IOEither<EnonicError, boolean>;

@@ -9,0 +6,0 @@ export declare function create(params: CreateProjectParams): IOEither<EnonicError, Project>;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.removePermissions = exports.modifyReadAccess = exports.modify = exports.list = exports.get = exports.delete = exports.create = exports.addPermissions = exports.setLibrary = void 0;
exports.removePermissions = exports.modifyReadAccess = exports.modify = exports.list = exports.get = exports.delete = exports.create = exports.addPermissions = void 0;
var IOEither_1 = require("fp-ts/IOEither");

@@ -8,21 +8,14 @@ var errors_1 = require("./errors");

var utils_1 = require("./utils");
var projectLib = __non_webpack_require__("/lib/xp/project");
/**
* Replace the library with a mocked version
*/
function setLibrary(library) {
projectLib = library;
}
exports.setLibrary = setLibrary;
var projectLib = require("/lib/xp/project");
function addPermissions(params) {
return errors_1.catchEnonicError(function () { return projectLib.addPermissions(params); });
return (0, errors_1.catchEnonicError)(function () { return projectLib.addPermissions(params); });
}
exports.addPermissions = addPermissions;
function create(params) {
return errors_1.catchEnonicError(function () { return projectLib.create(params); });
return (0, errors_1.catchEnonicError)(function () { return projectLib.create(params); });
}
exports.create = create;
function remove(paramsOrId) {
return function_1.pipe(utils_1.stringToById(paramsOrId), function (params) {
return errors_1.catchEnonicError(function () { return projectLib.delete(params); });
return (0, function_1.pipe)((0, utils_1.stringToById)(paramsOrId), function (params) {
return (0, errors_1.catchEnonicError)(function () { return projectLib.delete(params); });
});

@@ -32,20 +25,20 @@ }

function get(paramsOrId) {
return function_1.pipe(utils_1.stringToById(paramsOrId), function (params) { return errors_1.catchEnonicError(function () { return projectLib.get(params); }); }, IOEither_1.chain(utils_1.fromNullable(errors_1.notFoundError)));
return (0, function_1.pipe)((0, utils_1.stringToById)(paramsOrId), function (params) { return (0, errors_1.catchEnonicError)(function () { return projectLib.get(params); }); }, (0, IOEither_1.chain)((0, utils_1.fromNullable)(errors_1.notFoundError)));
}
exports.get = get;
function list() {
return errors_1.catchEnonicError(function () { return projectLib.list(); });
return (0, errors_1.catchEnonicError)(function () { return projectLib.list(); });
}
exports.list = list;
function modify(params) {
return errors_1.catchEnonicError(function () { return projectLib.modify(params); });
return (0, errors_1.catchEnonicError)(function () { return projectLib.modify(params); });
}
exports.modify = modify;
function modifyReadAccess(params) {
return errors_1.catchEnonicError(function () { return projectLib.modifyReadAccess(params); });
return (0, errors_1.catchEnonicError)(function () { return projectLib.modifyReadAccess(params); });
}
exports.modifyReadAccess = modifyReadAccess;
function removePermissions(params) {
return errors_1.catchEnonicError(function () { return projectLib.removePermissions(params); });
return (0, errors_1.catchEnonicError)(function () { return projectLib.removePermissions(params); });
}
exports.removePermissions = removePermissions;

@@ -44,3 +44,2 @@ # Enonic FP

import {pipe} from "fp-ts/pipeable";
import {Request, Response} from "enonic-types/controller";
import {get as getContent} from "enonic-fp/content";

@@ -50,3 +49,3 @@ import {Article} from "../../site/content-types/article/article"; // 1

export function get(req: Request): Response { // 2
export function get(req: XP.Request): XP.Response { // 2
const program = pipe( // 3

@@ -90,3 +89,2 @@ getContent<Article>(req.params.key!), // 4

import {pipe} from "fp-ts/pipeable";
import {Request, Response} from "enonic-types/controller";
import {publish, remove} from "enonic-fp/content";

@@ -96,3 +94,3 @@ import {run} from "enonic-fp/context";

function del(req: Request): Response {
function del(req: XP.Request): XP.Response {
const program = pipe(

@@ -149,4 +147,3 @@ runOnBranchDraft(

import {pipe} from "fp-ts/pipeable";
import {Request, Response} from "enonic-types/controller";
import {Content, QueryResponse} from "enonic-types/content";
import {Content, QueryResponse} from "/lib/xp/content";
import {getRenderer} from "enonic-fp/thymeleaf";

@@ -165,3 +162,3 @@ import {EnonicError} from "enonic-fp/errors";

export function get(req: Request): Response {
export function get(req: XP.Request): XP.Response {
const articleId = req.params.key!;

@@ -168,0 +165,0 @@

@@ -0,9 +1,6 @@

/// <reference types="enonic-types" />
import { IOEither } from "fp-ts/IOEither";
import { Option } from "fp-ts/Option";
import { EnonicError } from "./errors";
import { RecaptchaLibrary, VerifyResponse } from "enonic-types/recaptcha";
/**
* Replace the library with a mocked version
*/
export declare function setLibrary(library: RecaptchaLibrary): void;
import type { VerifyResponse } from "/lib/recaptcha";
export declare function getSiteKey(): Option<string>;

@@ -10,0 +7,0 @@ export declare function getSecretKey(): Option<string>;

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

@@ -8,10 +8,3 @@ var IOEither_1 = require("fp-ts/IOEither");

var errors_1 = require("./errors");
var recaptchaLib = __non_webpack_require__("/lib/recaptcha");
/**
* Replace the library with a mocked version
*/
function setLibrary(library) {
recaptchaLib = library;
}
exports.setLibrary = setLibrary;
var recaptchaLib = require("/lib/recaptcha");
function notEmptyString(str) {

@@ -21,11 +14,11 @@ return str.length > 0;

function getSiteKey() {
return function_1.pipe(Option_1.some(recaptchaLib.getSiteKey()), Option_1.filter(notEmptyString));
return (0, function_1.pipe)((0, Option_1.some)(recaptchaLib.getSiteKey()), (0, Option_1.filter)(notEmptyString));
}
exports.getSiteKey = getSiteKey;
function getSecretKey() {
return function_1.pipe(Option_1.some(recaptchaLib.getSecretKey()), Option_1.filter(notEmptyString));
return (0, function_1.pipe)((0, Option_1.some)(recaptchaLib.getSecretKey()), (0, Option_1.filter)(notEmptyString));
}
exports.getSecretKey = getSecretKey;
function verify(res) {
return function_1.pipe(errors_1.catchEnonicError(function () { return recaptchaLib.verify(res); }), IOEither_1.filterOrElse(function (res) { return res.success; }, // fails on false
return (0, function_1.pipe)((0, errors_1.catchEnonicError)(function () { return recaptchaLib.verify(res); }), (0, IOEither_1.filterOrElse)(function (res) { return res.success; }, // fails on false
function () { return errors_1.badRequestError; }));

@@ -32,0 +25,0 @@ }

@@ -0,14 +1,11 @@

/// <reference types="enonic-types" />
import { IOEither } from "fp-ts/IOEither";
import { EnonicError } from "./errors";
import { CreateBranchParams, CreateRepoParams, DeleteBranchParams, RefreshParams, RepoLibrary, RepositoryConfig } from "enonic-types/repo";
/**
* Replace the library with a mocked version
*/
export declare function setLibrary(library: RepoLibrary): void;
import type { BranchConfig, CreateBranchParams, CreateRepoParams, DeleteBranchParams, RefreshParams, RepositoryConfig } from "/lib/xp/repo";
export declare function create(params: CreateRepoParams): IOEither<EnonicError, RepositoryConfig>;
export declare function createBranch(params: CreateBranchParams): IOEither<EnonicError, RepositoryConfig>;
export declare function get(id: string): IOEither<EnonicError, RepositoryConfig>;
export declare function createBranch(params: CreateBranchParams): IOEither<EnonicError, BranchConfig>;
export declare function get<Data>(id: string): IOEither<EnonicError, RepositoryConfig<Data> | null>;
export declare function list(): IOEither<EnonicError, ReadonlyArray<RepositoryConfig>>;
export declare function remove(id: string): IOEither<EnonicError, boolean>;
export declare function deleteBranch(params: DeleteBranchParams): IOEither<EnonicError, any>;
export declare function refresh(params: RefreshParams): IOEither<EnonicError, ReadonlyArray<RepositoryConfig>>;
export declare function refresh(params: RefreshParams): IOEither<EnonicError, ReadonlyArray<unknown>>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.refresh = exports.deleteBranch = exports.remove = exports.list = exports.get = exports.createBranch = exports.create = exports.setLibrary = void 0;
exports.refresh = exports.deleteBranch = exports.remove = exports.list = exports.get = exports.createBranch = exports.create = void 0;
var IOEither_1 = require("fp-ts/IOEither");

@@ -8,37 +8,30 @@ var function_1 = require("fp-ts/function");

var utils_1 = require("./utils");
var repoLib = __non_webpack_require__("/lib/xp/repo");
/**
* Replace the library with a mocked version
*/
function setLibrary(library) {
repoLib = library;
}
exports.setLibrary = setLibrary;
var repoLib = require("/lib/xp/repo");
function create(params) {
return errors_1.catchEnonicError(function () { return repoLib.create(params); });
return (0, errors_1.catchEnonicError)(function () { return repoLib.create(params); });
}
exports.create = create;
function createBranch(params) {
return errors_1.catchEnonicError(function () { return repoLib.createBranch(params); });
return (0, errors_1.catchEnonicError)(function () { return repoLib.createBranch(params); });
}
exports.createBranch = createBranch;
function get(id) {
return function_1.pipe(errors_1.catchEnonicError(function () { return repoLib.get(id); }), IOEither_1.chain(utils_1.fromNullable(errors_1.notFoundError)));
return (0, function_1.pipe)((0, errors_1.catchEnonicError)(function () { return repoLib.get(id); }), (0, IOEither_1.chain)((0, utils_1.fromNullable)(errors_1.notFoundError)));
}
exports.get = get;
function list() {
return errors_1.catchEnonicError(function () { return repoLib.list(); });
return (0, errors_1.catchEnonicError)(function () { return repoLib.list(); });
}
exports.list = list;
function remove(id) {
return errors_1.catchEnonicError(function () { return repoLib.delete(id); });
return (0, errors_1.catchEnonicError)(function () { return repoLib.delete(id); });
}
exports.remove = remove;
function deleteBranch(params) {
return errors_1.catchEnonicError(function () { return repoLib.deleteBranch(params); });
return (0, errors_1.catchEnonicError)(function () { return repoLib.deleteBranch(params); });
}
exports.deleteBranch = deleteBranch;
function refresh(params) {
return errors_1.catchEnonicError(function () { return repoLib.refresh(params); });
return (0, errors_1.catchEnonicError)(function () { return repoLib.refresh(params); });
}
exports.refresh = refresh;

@@ -1,9 +0,6 @@

import { ListParams, ProgressParams, SubmitNamedParams, SubmitParams, TaskInfo, TaskLibrary } from "enonic-types/task";
/// <reference types="enonic-types" />
import type { ListParams, ProgressParams, TaskInfo, ExecuteFunctionParams, SubmitTaskParams } from "/lib/xp/task";
import { EnonicError } from "./errors";
import { IOEither } from "fp-ts/IOEither";
/**
* Replace the library with a mocked version
*/
export declare function setLibrary(library: TaskLibrary): void;
/**
* Returns the current state and progress details for the specified task.

@@ -35,3 +32,3 @@ */

*/
export declare function submit(params: SubmitParams): IOEither<EnonicError, string>;
export declare function executeFunction(params: ExecuteFunctionParams): IOEither<EnonicError, string>;
/**

@@ -41,2 +38,2 @@ * Submits a named task to be executed in the background and returns an id representing the task.

*/
export declare function submitNamed<A extends object = never>(params: SubmitNamedParams<A>): IOEither<EnonicError, string>;
export declare function submitTask<Config extends object = never>(params: SubmitTaskParams<Config>): IOEither<EnonicError, string>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.submitNamed = exports.submit = exports.sleep = exports.progress = exports.list = exports.isRunning = exports.get = exports.setLibrary = void 0;
exports.submitTask = exports.executeFunction = exports.sleep = exports.progress = exports.list = exports.isRunning = exports.get = void 0;
var errors_1 = require("./errors");
var taskLib = __non_webpack_require__("/lib/xp/task");
var taskLib = require("/lib/xp/task");
/**
* Replace the library with a mocked version
*/
function setLibrary(library) {
taskLib = library;
}
exports.setLibrary = setLibrary;
/**
* Returns the current state and progress details for the specified task.
*/
function get(taskId) {
return errors_1.catchEnonicError(function () { return taskLib.get(taskId); });
return (0, errors_1.catchEnonicError)(function () { return taskLib.get(taskId); });
}

@@ -24,3 +17,3 @@ exports.get = get;

function isRunning(task) {
return errors_1.catchEnonicError(function () { return taskLib.isRunning(task); });
return (0, errors_1.catchEnonicError)(function () { return taskLib.isRunning(task); });
}

@@ -32,3 +25,3 @@ exports.isRunning = isRunning;

function list(params) {
return errors_1.catchEnonicError(function () { return taskLib.list(params); });
return (0, errors_1.catchEnonicError)(function () { return taskLib.list(params); });
}

@@ -42,3 +35,3 @@ exports.list = list;

function progress(params) {
return errors_1.catchEnonicError(function () { return taskLib.progress(params); });
return (0, errors_1.catchEnonicError)(function () { return taskLib.progress(params); });
}

@@ -51,3 +44,3 @@ exports.progress = progress;

function sleep(timeMillis) {
return errors_1.catchEnonicError(function () { return taskLib.sleep(timeMillis); });
return (0, errors_1.catchEnonicError)(function () { return taskLib.sleep(timeMillis); });
}

@@ -59,6 +52,6 @@ exports.sleep = sleep;

*/
function submit(params) {
return errors_1.catchEnonicError(function () { return taskLib.submit(params); });
function executeFunction(params) {
return (0, errors_1.catchEnonicError)(function () { return taskLib.executeFunction(params); });
}
exports.submit = submit;
exports.executeFunction = executeFunction;
/**

@@ -68,5 +61,5 @@ * Submits a named task to be executed in the background and returns an id representing the task.

*/
function submitNamed(params) {
return errors_1.catchEnonicError(function () { return taskLib.submitNamed(params); });
function submitTask(params) {
return (0, errors_1.catchEnonicError)(function () { return taskLib.submitTask(params); });
}
exports.submitNamed = submitNamed;
exports.submitTask = submitTask;

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

/// <reference types="enonic-types" />
import { IOEither } from "fp-ts/IOEither";
import { ResourceKey, ThymeleafLibrary, ThymeleafRenderOptions } from "enonic-types/thymeleaf";
import type { ResourceKey, ThymeleafRenderOptions } from "/lib/thymeleaf";
import { EnonicError } from "./errors";
/**
* Replace the library with a mocked version
*/
export declare function setLibrary(library: ThymeleafLibrary): void;
export declare function renderUnsafe<A extends object>(view: ResourceKey, model?: A, options?: ThymeleafRenderOptions): string;

@@ -9,0 +6,0 @@ export declare function render<A extends object>(view: ResourceKey, model?: A, options?: ThymeleafRenderOptions): IOEither<EnonicError, string>;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getRenderer = exports.getUnsafeRenderer = exports.render = exports.renderUnsafe = exports.setLibrary = void 0;
exports.getRenderer = exports.getUnsafeRenderer = exports.render = exports.renderUnsafe = void 0;
var errors_1 = require("./errors");
var thymeleafLib = __non_webpack_require__("/lib/thymeleaf");
/**
* Replace the library with a mocked version
*/
function setLibrary(library) {
thymeleafLib = library;
}
exports.setLibrary = setLibrary;
var thymeleafLib = require("/lib/thymeleaf");
function renderUnsafe(view, model, options) {

@@ -18,3 +11,3 @@ return thymeleafLib.render(view, model, options);

function render(view, model, options) {
return errors_1.catchEnonicError(function () { return renderUnsafe(view, model, options); });
return (0, errors_1.catchEnonicError)(function () { return renderUnsafe(view, model, options); });
}

@@ -21,0 +14,0 @@ exports.render = render;

@@ -1,3 +0,3 @@

import { Request } from "enonic-types/controller";
import { GetWebSocketUrlParams, TurboStreamAction, TurboStreamsLibrary, TurboStreamsParams, TurboStreamsRemoveParams } from "enonic-types/turbo";
/// <reference types="enonic-types" />
import { GetWebSocketUrlParams, TurboStreamAction, TurboStreamsLibrary, TurboStreamsParams, TurboStreamsRemoveParams } from "/lib/turbo-streams";
import { IOEither } from "fp-ts/IOEither";

@@ -47,3 +47,3 @@ import { EnonicError } from "./errors";

*/
export declare function acceptTurboStreams(req: Request): boolean;
export declare function acceptTurboStreams(req: XP.Request): boolean;
/**

@@ -50,0 +50,0 @@ * Get mime type to use when returning Turbo Streams over HTTP

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

function getLibrary() {
return lib !== null && lib !== void 0 ? lib : __non_webpack_require__("/lib/turbo-streams");
return lib !== null && lib !== void 0 ? lib : Promise.resolve().then(function () { return require("/lib/turbo-streams"); });
}

@@ -22,3 +22,3 @@ exports.getLibrary = getLibrary;

function append(params) {
return errors_1.catchEnonicError(function () { return getLibrary().append(params); });
return (0, errors_1.catchEnonicError)(function () { return getLibrary().append(params); });
}

@@ -30,3 +30,3 @@ exports.append = append;

function prepend(params) {
return errors_1.catchEnonicError(function () { return getLibrary().prepend(params); });
return (0, errors_1.catchEnonicError)(function () { return getLibrary().prepend(params); });
}

@@ -38,3 +38,3 @@ exports.prepend = prepend;

function replace(params) {
return errors_1.catchEnonicError(function () { return getLibrary().replace(params); });
return (0, errors_1.catchEnonicError)(function () { return getLibrary().replace(params); });
}

@@ -46,3 +46,3 @@ exports.replace = replace;

function remove(params) {
return errors_1.catchEnonicError(function () { return getLibrary().remove(params); });
return (0, errors_1.catchEnonicError)(function () { return getLibrary().remove(params); });
}

@@ -61,3 +61,3 @@ exports.remove = remove;

function getUsersPersonalGroupName() {
return errors_1.catchEnonicError(function () { return getLibrary().getUsersPersonalGroupName(); });
return (0, errors_1.catchEnonicError)(function () { return getLibrary().getUsersPersonalGroupName(); });
}

@@ -64,0 +64,0 @@ exports.getUsersPersonalGroupName = getUsersPersonalGroupName;

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

/// <reference types="enonic-types" />
import * as JSON from "fp-ts/Json";
import { IOEither } from "fp-ts/IOEither";
import { ById, ByKey, ByPath } from "enonic-types/portal";
import { ById, ByKey, ByPath } from "/lib/xp/portal";
import { EnonicError } from "./errors";

@@ -5,0 +6,0 @@ import * as O from "fp-ts/Option";

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

function fromNullable(e) {
return function (a) { return IOEither_1.fromEither(EI.fromNullable(e)(a)); };
return function (a) { return (0, IOEither_1.fromEither)(EI.fromNullable(e)(a)); };
}

@@ -19,3 +19,3 @@ exports.fromNullable = fromNullable;

function parseJSON(s, onError) {
return function_1.pipe(JSON.parse(s), EI.mapLeft(onError), IOEither_1.fromEither);
return (0, function_1.pipe)(JSON.parse(s), EI.mapLeft(onError), IOEither_1.fromEither);
}

@@ -22,0 +22,0 @@ exports.parseJSON = parseJSON;

import { EnonicError } from "./errors";
import { IOEither } from "fp-ts/IOEither";
import { WebsocketLibrary } from "enonic-types/websocket";
/**
* Replace the library with a mocked version
*/
export declare function setLibrary(library: WebsocketLibrary): void;
/**
* Add an id to a socket group.

@@ -10,0 +5,0 @@ */

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.sendToGroup = exports.send = exports.removeFromGroup = exports.addToGroup = exports.setLibrary = void 0;
exports.sendToGroup = exports.send = exports.removeFromGroup = exports.addToGroup = void 0;
var errors_1 = require("./errors");
var websocketLib = __non_webpack_require__("/lib/xp/websocket");
var websocketLib = require("/lib/xp/websocket");
/**
* Replace the library with a mocked version
*/
function setLibrary(library) {
websocketLib = library;
}
exports.setLibrary = setLibrary;
/**
* Add an id to a socket group.
*/
function addToGroup(group, id) {
return errors_1.catchEnonicError(function () { return websocketLib.addToGroup(group, id); });
return (0, errors_1.catchEnonicError)(function () { return websocketLib.addToGroup(group, id); });
}

@@ -24,3 +17,3 @@ exports.addToGroup = addToGroup;

function removeFromGroup(group, id) {
return errors_1.catchEnonicError(function () { return websocketLib.removeFromGroup(group, id); });
return (0, errors_1.catchEnonicError)(function () { return websocketLib.removeFromGroup(group, id); });
}

@@ -32,3 +25,3 @@ exports.removeFromGroup = removeFromGroup;

function send(id, message) {
return errors_1.catchEnonicError(function () { return websocketLib.send(id, message); });
return (0, errors_1.catchEnonicError)(function () { return websocketLib.send(id, message); });
}

@@ -40,4 +33,4 @@ exports.send = send;

function sendToGroup(group, message) {
return errors_1.catchEnonicError(function () { return websocketLib.sendToGroup(group, message); });
return (0, errors_1.catchEnonicError)(function () { return websocketLib.sendToGroup(group, message); });
}
exports.sendToGroup = sendToGroup;
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