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.5.0-next.0 to 0.5.0-next.1

4

array.d.ts

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

export declare function forceArray<A>(data?: A | Array<A>): Array<A>;
export declare function forceArray<A>(data?: A | ReadonlyArray<A>): ReadonlyArray<A>;
export declare function forceArray<A>(data?: A | Array<A> | null | undefined): Array<A>;
export declare function forceArray<A>(data?: A | ReadonlyArray<A> | null | undefined): ReadonlyArray<A>;

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

/// <reference types="enonic-types" />
import { IOEither } from "fp-ts/es6/IOEither";
import { Option } from "fp-ts/es6/Option";
import type { ChangePasswordParams, CreateGroupParams, CreateRoleParams, CreateUserParams, FindPrincipalsParams, FindPrincipalsResult, FindUsersParams, GetProfileParams, Group, LoginParams, LoginResult, ModifyGroupParams, ModifyProfileParams, ModifyRoleParams, ModifyUserParams, Principal, PrincipalKey, PrincipalKeyGroup, PrincipalKeyRole, PrincipalKeyUser, Role, User, UserQueryResult, UserWithProfile } from "/lib/xp/auth";
import type { ChangePasswordParams, CreateGroupParams, CreateRoleParams, CreateUserParams, FindPrincipalsParams, FindPrincipalsResult, FindUsersParams, GetProfileParams, Group, LoginParams, LoginResult, ModifyGroupParams, ModifyProfileParams, ModifyRoleParams, ModifyUserParams, Principal, PrincipalKey, GroupKey, RoleKey, UserKey, Role, User, UserWithProfile } from "/lib/xp/auth";
import { type EnonicError } from "./errors";

@@ -29,20 +28,20 @@ /**

*/
export declare function getProfile<A>(params: GetProfileParams): IOEither<EnonicError, A>;
export declare function getProfile<A extends Record<string, unknown>>(params: GetProfileParams): IOEither<EnonicError, A>;
/**
* This function retrieves the profile of a user and updates it.
*/
export declare function modifyProfile<A>(params: ModifyProfileParams<A>): IOEither<EnonicError, A>;
export declare function modifyProfile<Profile extends Record<string, unknown>>(params: ModifyProfileParams<Profile>): IOEither<EnonicError, Profile>;
/**
* This function returns the ID provider configuration. It is meant to be called from an ID provider controller.
*/
export declare function getIdProviderConfig<A>(): Option<A>;
export declare function getIdProviderConfig<IdProviderConfig extends Record<string, unknown> = Record<string, unknown>>(): Option<IdProviderConfig>;
/**
* Search for users matching the specified query.
*/
export declare function findUsers<A>(params: FindUsersParams & {
export declare function findUsers<A extends Record<string, unknown> = Record<string, unknown>>(params: FindUsersParams & {
includeProfile: true;
}): IOEither<EnonicError, UserQueryResult<UserWithProfile<A>>>;
}): IOEither<EnonicError, FindPrincipalsResult<UserWithProfile<A>>>;
export declare function findUsers(params: FindUsersParams & {
includeProfile?: false;
}): IOEither<EnonicError, UserQueryResult<User>>;
}): IOEither<EnonicError, FindPrincipalsResult<User>>;
/**

@@ -59,7 +58,7 @@ * Retrieves the user specified and updates it with the changes applied through the editor.

*/
export declare function addMembers(principalKey: PrincipalKeyRole | PrincipalKeyGroup, members: Array<PrincipalKeyGroup | PrincipalKeyUser>): IOEither<EnonicError, void>;
export declare function addMembers(principalKey: RoleKey | GroupKey, members: Array<GroupKey | UserKey>): IOEither<EnonicError, void>;
/**
* Removes members from a principal (group or role).
*/
export declare function removeMembers(principalKey: PrincipalKeyRole | PrincipalKeyGroup, members: Array<PrincipalKeyGroup | PrincipalKeyUser>): IOEither<EnonicError, void>;
export declare function removeMembers(principalKey: RoleKey | GroupKey, members: Array<GroupKey | UserKey>): IOEither<EnonicError, void>;
/**

@@ -76,3 +75,3 @@ * Deletes the principal with the specifkey.

*/
export declare function getPrincipal(principalKey: PrincipalKey): Option<Principal>;
export declare function getPrincipal(principalKey: UserKey): Option<Principal>;
/**

@@ -101,6 +100,6 @@ * Creates a role.

*/
export declare function getMembers(principalKey: PrincipalKeyRole | PrincipalKeyGroup): IOEither<EnonicError, ReadonlyArray<User | Group>>;
export declare function getMembers(principalKey: RoleKey | GroupKey): IOEither<EnonicError, ReadonlyArray<User | Group>>;
/**
* Returns the list of principals which the specified principal is a member of.
*/
export declare function getMemberships(principalKey: PrincipalKeyUser | PrincipalKeyGroup, transitive?: boolean): IOEither<EnonicError, ReadonlyArray<Principal>>;
export declare function getMemberships(principalKey: UserKey | GroupKey, transitive?: boolean): IOEither<EnonicError, ReadonlyArray<Principal>>;
"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 = void 0;
var IOEither_1 = require("fp-ts/es6/IOEither");
var Option_1 = require("fp-ts/es6/Option");
var utils_1 = require("./utils");
var errors_1 = require("./errors");
var authLib = require("/lib/xp/auth");
var function_1 = require("fp-ts/es6/function");
/**

@@ -46,3 +49,3 @@ * Login a user through the specified idProvider, with userName and password.

function getProfile(params) {
return (0, errors_1.catchEnonicError)(function () { return authLib.getProfile(params); });
return (0, function_1.pipe)((0, errors_1.catchEnonicError)(function () { return authLib.getProfile(params); }), (0, IOEither_1.chain)((0, utils_1.fromNullable)(errors_1.notFoundError)));
}

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

function modifyProfile(params) {
return (0, errors_1.catchEnonicError)(function () { return authLib.modifyProfile(params); });
return (0, function_1.pipe)((0, errors_1.catchEnonicError)(function () { return authLib.modifyProfile(params); }), (0, IOEither_1.chain)((0, utils_1.fromNullable)(errors_1.notFoundError)));
}

@@ -73,3 +76,3 @@ exports.modifyProfile = modifyProfile;

function modifyUser(params) {
return (0, errors_1.catchEnonicError)(function () { return authLib.modifyUser(params); });
return (0, function_1.pipe)((0, errors_1.catchEnonicError)(function () { return authLib.modifyUser(params); }), (0, IOEither_1.chain)((0, utils_1.fromNullable)(errors_1.notFoundError)));
}

@@ -137,3 +140,3 @@ exports.modifyUser = modifyUser;

function modifyRole(params) {
return (0, errors_1.catchEnonicError)(function () { return authLib.modifyRole(params); });
return (0, function_1.pipe)((0, errors_1.catchEnonicError)(function () { return authLib.modifyRole(params); }), (0, IOEither_1.chain)((0, utils_1.fromNullable)(errors_1.notFoundError)));
}

@@ -152,3 +155,3 @@ exports.modifyRole = modifyRole;

function modifyGroup(params) {
return (0, errors_1.catchEnonicError)(function () { return authLib.modifyGroup(params); });
return (0, function_1.pipe)((0, errors_1.catchEnonicError)(function () { return authLib.modifyGroup(params); }), (0, IOEither_1.chain)((0, utils_1.fromNullable)(errors_1.notFoundError)));
}

@@ -155,0 +158,0 @@ exports.modifyGroup = modifyGroup;

@@ -1,20 +0,18 @@

/// <reference types="enonic-types" />
import { IOEither } from "fp-ts/es6/IOEither";
import { Semigroup } from "fp-ts/es6/Semigroup";
import type { AddAttachmentParams, Attachments, AttachmentStreamParams, ByteSource, Content, ContentType, CreateContentParams, CreateMediaParams, DeleteContentParams, ExistsParams, GetChildrenParams, GetContentParams, GetOutboundDependenciesParams, GetPermissionsParams, GetPermissionsResult, GetSiteConfigParams, GetSiteParams, ModifyContentParams, MoveParams, PublishContentParams, PublishResponse, QueryContentParams, QueryContentParamsWithSort, QueryResponse, RemoveAttachmentParams, SetPermissionsParams, Site, UnpublishContentParams } from "/lib/xp/content";
import type { ByteSource, Content, ContentType, CreateContentParams, CreateMediaParams, DeleteContentParams, GetContentParams, GetOutboundDependenciesParams, GetPermissionsParams, GetSiteConfigParams, GetSiteParams, ModifyContentParams, PublishContentParams, QueryContentParams, RemoveAttachmentParams, SetPermissionsParams, Site, UnpublishContentParams, AddAttachmentParam, ContentExistsParams, ContentsResult, GetAttachmentStreamParams, GetChildContentParams, MoveContentParams, Permissions, PublishContentResult } from "/lib/xp/content";
import { EnonicError } from "./errors";
import { ContentTypeByName, KeyOfContentType, LiteralContentTypeNames, QueryResponseSorted } from "*/lib/xp/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 get<A extends object>(paramsOrKey: GetContentParams | string): IOEither<EnonicError, Content<A>>;
export declare function query<Data, ContentTypeName extends LiteralContentTypeNames = KeyOfContentType<Data>>(params: QueryContentParams<ContentTypeName>): IOEither<EnonicError, QueryResponse<Data>>;
export declare function query<Data, ContentTypeName extends LiteralContentTypeNames = KeyOfContentType<Data>>(params: QueryContentParamsWithSort<ContentTypeName>): IOEither<EnonicError, QueryResponseSorted<Data>>;
export declare function create<Data, ContentTypeName extends LiteralContentTypeNames>(params: CreateContentParams<Data, ContentTypeName>): IOEither<EnonicError, Content<ContentTypeByName<ContentTypeName, Data>>>;
export declare function modify<Data>(params: ModifyContentParams<Data>): IOEither<EnonicError, Content<Data>>;
import { Aggregations, AggregationsResult, AggregationsToAggregationResults } from "@enonic-types/core";
export declare function get<Hit extends Content<unknown> = Content>(params: GetContentParams): IOEither<EnonicError, Hit>;
export declare function get<Hit extends Content<unknown> = Content>(key: string): IOEither<EnonicError, Hit>;
export declare function get<Hit extends Content<unknown> = Content>(paramsOrKey: GetContentParams | string): IOEither<EnonicError, Hit>;
export declare function query<Hit extends Content<unknown> = Content, AggregationInput extends Aggregations = never>(params: QueryContentParams<AggregationInput>): IOEither<EnonicError, ContentsResult<Hit, AggregationsToAggregationResults<AggregationInput>>>;
export declare function create<Data = Record<string, unknown>, Type extends string = string>(params: CreateContentParams<Data, Type>): IOEither<EnonicError, Content<Data, Type>>;
export declare function modify<Data = Record<string, unknown>, Type extends string = string>(params: ModifyContentParams<Data, Type>): IOEither<EnonicError, Content<Data, Type>>;
/**
* Require only Content._id and Content.data
*/
declare type PartialContent<Data> = Partial<Content<Data>> & Pick<Content<Data>, "_id" | "data">;
export interface ConcatContentParams<Data> {
readonly semigroup: Semigroup<PartialContent<Data>>;
type PartialContent<Data, Type extends string = string> = Partial<Content<Data, Type>> & Pick<Content<Data, Type>, "_id" | "data">;
export interface ConcatContentParams<Data, Type extends string = string> {
readonly semigroup: Semigroup<PartialContent<Data, Type>>;
readonly key?: string;

@@ -27,27 +25,27 @@ readonly requireValid?: boolean;

*/
export declare function modifyWithSemigroup<Data>(params: ConcatContentParams<Data>): (newContent: PartialContent<Data>) => IOEither<EnonicError, Content<Data>>;
export declare function getContentSemigroup<Data, Type extends string = KeyOfContentType<Data>>(dataSemigroup: Semigroup<Data>, xDataSemigroup?: Semigroup<XP.XData>): Semigroup<Content<Data, Type>>;
export declare function modifyWithSemigroup<Data, Type extends string>(params: ConcatContentParams<Data, Type>): (newContent: PartialContent<Data, Type>) => IOEither<EnonicError, Content<Data, Type>>;
export declare function getContentSemigroup<Data, Type extends string = string>(dataSemigroup: Semigroup<Data>, pageConfigSemigroup?: Semigroup<Content["page"] | undefined>, xDataSemigroup?: Semigroup<Content["x"] | undefined>): Semigroup<PartialContent<Data, Type>>;
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(params: ContentExistsParams): IOEither<EnonicError, boolean>;
export declare function exists(key: string): IOEither<EnonicError, boolean>;
export declare function publish(key: string): IOEither<EnonicError, PublishResponse>;
export declare function publish(content: Content): IOEither<EnonicError, PublishResponse>;
export declare function publish(params: PublishContentParams): IOEither<EnonicError, PublishResponse>;
export declare function publish(key: string): IOEither<EnonicError, PublishContentResult>;
export declare function publish(content: Content): IOEither<EnonicError, PublishContentResult>;
export declare function publish(params: PublishContentParams): IOEither<EnonicError, PublishContentResult>;
export declare function unpublish(key: string): IOEither<EnonicError, ReadonlyArray<string>>;
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<Hit extends Content<unknown> = Content, AggregationOutput extends Record<string, AggregationsResult> = never>(params: GetChildContentParams): IOEither<EnonicError, ContentsResult<Hit, AggregationOutput>>;
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(params: GetSiteParams): IOEither<EnonicError, Site>;
export declare function getSite(key: string): IOEither<EnonicError, Site>;
export declare function getSiteConfig(params: GetSiteConfigParams): IOEither<EnonicError, XP.SiteConfig>;
export declare function move<Data = Record<string, unknown>, Type extends string = string>(params: MoveContentParams): IOEither<EnonicError, Content<Data, Type>>;
export declare function getSite<Config = Record<string, unknown>>(params: GetSiteParams): IOEither<EnonicError, Site<Config>>;
export declare function getSite<Config = Record<string, unknown>>(key: string): IOEither<EnonicError, Site<Config>>;
export declare function getSiteConfig<Config = Record<string, unknown>>(params: GetSiteConfigParams): IOEither<EnonicError, Config>;
export declare function createMedia<A extends object>(params: CreateMediaParams): IOEither<EnonicError, Content<A>>;
export declare function addAttachment(params: AddAttachmentParams): IOEither<EnonicError, void>;
export declare function getAttachments(key: string): IOEither<EnonicError, Attachments>;
export declare function getAttachmentStream(params: AttachmentStreamParams): IOEither<EnonicError, ByteSource>;
export declare function addAttachment(params: AddAttachmentParam): IOEither<EnonicError, void>;
export declare function getAttachments(key: string): IOEither<EnonicError, Content["attachments"]>;
export declare function getAttachmentStream(params: GetAttachmentStreamParams): IOEither<EnonicError, ByteSource>;
export declare function removeAttachment(params: RemoveAttachmentParams): IOEither<EnonicError, void>;
export declare function getPermissions(params: GetPermissionsParams): IOEither<EnonicError, GetPermissionsResult>;
export declare function setPermissions(params: SetPermissionsParams): IOEither<EnonicError, GetPermissionsResult>;
export declare function getPermissions(params: GetPermissionsParams): IOEither<EnonicError, Permissions>;
export declare function setPermissions(params: SetPermissionsParams): IOEither<EnonicError, boolean>;
export declare function getType(name: string): IOEither<EnonicError, ContentType>;

@@ -54,0 +52,0 @@ export declare function getTypes(): IOEither<EnonicError, ReadonlyArray<ContentType>>;

@@ -6,6 +6,6 @@ "use strict";

var IOEither_1 = require("fp-ts/es6/IOEither");
var Semigroup_1 = require("fp-ts/es6/Semigroup");
var utils_1 = require("./utils");
var errors_1 = require("./errors");
var contentLib = require("/lib/xp/content");
var Semigroup_1 = require("fp-ts/Semigroup");
function get(paramsOrKey) {

@@ -24,3 +24,3 @@ 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)));

function modify(params) {
return (0, errors_1.catchEnonicError)(function () { return contentLib.modify(params); });
return (0, function_1.pipe)((0, errors_1.catchEnonicError)(function () { return contentLib.modify(params); }), (0, IOEither_1.chain)((0, utils_1.fromNullable)(errors_1.notFoundError)));
}

@@ -34,3 +34,3 @@ exports.modify = modify;

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

@@ -40,9 +40,12 @@ return contentLib.modify({

requireValid: params.requireValid,
editor: function (oldContent) { return params.semigroup.concat(oldContent, newContent); },
editor: function (oldContent) {
return params.semigroup.concat(oldContent, newContent);
},
});
});
}), (0, IOEither_1.chain)((0, utils_1.fromNullable)(errors_1.notFoundError)));
};
}
exports.modifyWithSemigroup = modifyWithSemigroup;
function getContentSemigroup(dataSemigroup, xDataSemigroup) {
function getContentSemigroup(dataSemigroup, pageConfigSemigroup, xDataSemigroup) {
if (pageConfigSemigroup === void 0) { pageConfigSemigroup = (0, Semigroup_1.last)(); }
if (xDataSemigroup === void 0) { xDataSemigroup = (0, Semigroup_1.last)(); }

@@ -68,7 +71,6 @@ return {

data: dataSemigroup.concat(x.data, y.data),
x: xDataSemigroup.concat(x.data, y.data),
page: x.page,
x: xDataSemigroup.concat(y.x, x.x),
page: pageConfigSemigroup.concat(y.page, x.page),
attachments: (_m = y.attachments) !== null && _m !== void 0 ? _m : x.attachments,
publish: (_o = y.publish) !== null && _o !== void 0 ? _o : x.publish,
workflow: x.workflow,
});

@@ -126,9 +128,7 @@ },

function getSite(paramsOrKey) {
return (0, function_1.pipe)((0, utils_1.stringToByKey)(paramsOrKey), function (params) {
return (0, 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); }); }, (0, IOEither_1.chain)((0, utils_1.fromNullable)(errors_1.notFoundError)));
}
exports.getSite = getSite;
function getSiteConfig(params) {
return (0, errors_1.catchEnonicError)(function () { return contentLib.getSiteConfig(params); });
return (0, function_1.pipe)((0, errors_1.catchEnonicError)(function () { return contentLib.getSiteConfig(params); }), (0, IOEither_1.chain)((0, utils_1.fromNullable)(errors_1.notFoundError)));
}

@@ -157,3 +157,3 @@ exports.getSiteConfig = getSiteConfig;

function getPermissions(params) {
return (0, errors_1.catchEnonicError)(function () { return contentLib.getPermissions(params); });
return (0, function_1.pipe)((0, errors_1.catchEnonicError)(function () { return contentLib.getPermissions(params); }), (0, IOEither_1.chain)((0, utils_1.fromNullable)(errors_1.notFoundError)));
}

@@ -160,0 +160,0 @@ exports.getPermissions = getPermissions;

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

/// <reference types="enonic-types" />
import { IO } from "fp-ts/es6/IO";
import { IOEither } from "fp-ts/es6/IOEither";
import type { Context, RunContext } from "/lib/xp/context";
import type { Context, ContextParams } from "/lib/xp/context";
import { type EnonicError } from "./errors";
import { ContextAttributes } from "*/lib/xp/context";
export declare function get<Attributes extends ContextAttributes>(): IOEither<EnonicError, Context<Attributes>>;
export declare function runUnsafe<A, Attributes extends ContextAttributes>(runContext: RunContext<Attributes>, f: () => A): A;
export declare function run<Attributes extends ContextAttributes>(runContext: RunContext<Attributes>): <A>(a: IO<A>) => IO<A>;
export declare function get(): IOEither<EnonicError, Context>;
export declare function runUnsafe<A>(runContext: ContextParams, f: () => A): A;
export declare function run(runContext: ContextParams): <A>(a: IO<A>) => IO<A>;

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

/// <reference types="enonic-types" />
/// <reference types="enonic-types" />
/// <reference types="enonic-types" />
/// <reference types="enonic-types" />
import { IO } from "fp-ts/es6/IO";
import type { ResourceKey } from "/lib/thymeleaf";
import { EnonicError } from "./errors";
import { type IO } from "fp-ts/es6/IO";
import type { ResourceKey } from "@enonic-types/core";
import { type EnonicError } from "./errors";
import type { 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>;
import type { Request, Response } from "@item-enonic-types/global/controller";
export type AsResponse = <ResponseType>(body: ResponseType, extras?: Partial<Response<ResponseType>>) => IO<Response<ResponseType>>;
export type AsErrorResponse = (err: EnonicError, extras?: Partial<Response<EnonicError>>) => IO<Response<EnonicError>>;
export declare const ok: AsResponse;
export declare const created: AsResponse;
export declare const noContent: AsResponse;
export declare const redirect: (redirect: string) => IO<XP.Response>;
export declare const redirect: (redirect: string) => IO<Response>;
export declare const badRequest: AsResponse;

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

*/
export declare function errorResponse(req?: XP.Request): AsErrorResponse;
export declare function errorResponse(req?: Request): AsErrorResponse;
export declare function errorResponse(params: ErrorResponseParams): AsErrorResponse;
export declare type LocalizeWithPrefixParams = Omit<LocalizeParams, "key"> & {
export type LocalizeWithPrefixParams = Omit<LocalizeParams, "key"> & {
readonly i18nPrefix?: string;
};
export interface ErrorResponseParams {
readonly req?: XP.Request;
readonly req?: Request;
readonly localizeParams?: LocalizeWithPrefixParams;

@@ -38,7 +35,7 @@ }

*/
export declare function unsafeRenderErrorPage(view: ResourceKey): AsErrorResponse;
export declare function unsafeRenderErrorPage(view: ResourceKey): (err: EnonicError, extras?: Partial<Response<string>>) => IO<Response<string>>;
/**
* Create a Response based on a http-status/ErrorMessage, body, and extra parameters
*/
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>;
export declare function status<ResponseType>(httpStatus: number, body?: ResponseType, extras?: Partial<Response<ResponseType>>): IO<Response<ResponseType>>;
export declare function status<ResponseType>(error: EnonicError, body?: ResponseType, extras?: Partial<Response<ResponseType>>): IO<Response<ResponseType>>;

@@ -114,3 +114,2 @@ "use strict";

return function (body, extras) {
if (extras === void 0) { extras = {}; }
return status(httpStatus, body, extras);

@@ -117,0 +116,0 @@ };

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

/// <reference types="enonic-types" />
import { ByteSource } from "/lib/xp/content";

@@ -3,0 +2,0 @@ import { IOEither } from "fp-ts/es6/IOEither";

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

/// <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;
import type { ListenerParams, SendParams } from "/lib/xp/event";
export declare function listener<EventData extends object>(params: ListenerParams<EventData>): void;
export declare function send<EventData extends object = object>(params: SendParams<EventData>): void;

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

/// <reference types="enonic-types" />
import { IOEither } from "fp-ts/es6/IOEither";

@@ -3,0 +2,0 @@ import type { HttpRequestParams, HttpResponse } from "/lib/http-client";

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

/// <reference types="enonic-types" />
import { Option } from "fp-ts/es6/Option";

@@ -7,3 +6,3 @@ import type { LocalizeParams } from "/lib/xp/i18n";

*/
export declare function getPhrases(locale: string | ReadonlyArray<string>, bundles: ReadonlyArray<string>): {
export declare function getPhrases(locale: string | string[], bundles: string[]): {
[key: string]: string;

@@ -14,3 +13,3 @@ };

*/
export declare function getSupportedLocales(bundles: ReadonlyArray<string>): ReadonlyArray<string>;
export declare function getSupportedLocales(bundles: string[]): ReadonlyArray<string>;
/**

@@ -17,0 +16,0 @@ * Localizes a phrase searching through the list of passed in locales in the given order, to find a translation for the

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

/// <reference types="enonic-types" />
import { IOEither } from "fp-ts/es6/IOEither";
import type { EmailParams } from "/lib/xp/mail";
import type { SendMessageParams } from "/lib/xp/mail";
import { EnonicError } from "./errors";
export declare function send(params: EmailParams): IOEither<EnonicError, void>;
export declare function send(params: SendMessageParams): IOEither<EnonicError, void>;

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

/// <reference types="enonic-types" />
/// <reference types="enonic-types" />
import type { BreadcrumbMenu, GetBreadcrumbMenuParams, GetMenuParams, GetMenuTreeParams, MenuItem, MenuTree } from "/lib/menu";

@@ -4,0 +2,0 @@ import type { Content } from "/lib/xp/content";

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

/// <reference types="enonic-types" />
import { IOEither } from "fp-ts/es6/IOEither";
import type { DiffParams, DiffResponse, FindVersionsParams, MultiRepoConnection, MultiRepoConnectParams, NodeCreateParams, NodeFindChildrenParams, NodeGetParams, NodeModifyParams, NodeQueryParams, NodeQueryResponse, NodeVersionQueryResult, RepoConnection, RepoNode, Source } from "/lib/xp/node";
import { type EnonicError } from "./errors";
import type { FindVersionsParams, MultiRepoConnection, MultiRepoConnectParams, RepoConnection, ConnectParams, CreateNodeParams, DiffBranchesParams, DiffBranchesResult, FindChildrenParams, FindNodesByParentResult, GetNodeParams, ModifyNodeParams, Node, NodeQueryResult, NodeVersionsQueryResult, QueryNodeParams } from "/lib/xp/node";
import { Aggregations, AggregationsToAggregationResults } from "@enonic-types/core";
/**
* Creates a connection to a repository with a given branch and authentication info.
*/
export declare function connect(params: Source): IOEither<EnonicError, RepoConnection>;
export declare function connect(params: ConnectParams): IOEither<EnonicError, RepoConnection>;
/**

@@ -17,35 +17,35 @@ * Creates a connection to several repositories with a given branch and authentication info.

*/
export declare function create<A>(repo: RepoConnection, params: A & NodeCreateParams): IOEither<EnonicError, A & RepoNode>;
export declare function create<NodeData = Record<string, unknown>>(repo: RepoConnection, params: CreateNodeParams<NodeData>): IOEither<EnonicError, Node<NodeData>>;
/**
* Deleting a node or nodes.
*/
export declare function remove(repo: RepoConnection, keys: string | Array<string>): IOEither<EnonicError, ReadonlyArray<string>>;
export declare function remove(repo: RepoConnection, keys: string | string[]): IOEither<EnonicError, string[]>;
/**
* Resolves the differences for a node between current and given branch.
*/
export declare function diff(repo: RepoConnection, params: DiffParams): IOEither<EnonicError, DiffResponse>;
export declare function diff(repo: RepoConnection, params: DiffBranchesParams): IOEither<EnonicError, DiffBranchesResult>;
/**
* Checking if a node or nodes exist for the current context.
*/
export declare function exists(repo: RepoConnection, keys: string | Array<string>): IOEither<EnonicError, ReadonlyArray<string>>;
export declare function exists(repo: RepoConnection, keys: string): IOEither<EnonicError, boolean>;
/**
* Fetch the versions of a node.
*/
export declare function findVersions(repo: RepoConnection, params: FindVersionsParams): IOEither<EnonicError, NodeVersionQueryResult>;
export declare function findVersions(repo: RepoConnection, params: FindVersionsParams): IOEither<EnonicError, NodeVersionsQueryResult>;
/**
* Fetches specific nodes by path or ID.
*/
export declare function get<A>(repo: RepoConnection, key: string | NodeGetParams): IOEither<EnonicError, A & RepoNode>;
export declare function get<A>(repo: RepoConnection, keys: Array<string | NodeGetParams>): IOEither<EnonicError, ReadonlyArray<A & RepoNode>>;
export declare function get<NodeData = Record<string, unknown>>(repo: RepoConnection, key: string | GetNodeParams): IOEither<EnonicError, Node<NodeData>>;
export declare function get<NodeData = Record<string, unknown>>(repo: RepoConnection, keys: (string | GetNodeParams)[]): IOEither<EnonicError, Node<NodeData>[]>;
/**
* This command queries nodes.
*/
export declare function query(repo: RepoConnection, params: NodeQueryParams): IOEither<EnonicError, NodeQueryResponse>;
export declare function query<AggregationInput extends Aggregations = never>(repo: RepoConnection, params: QueryNodeParams<AggregationInput>): IOEither<EnonicError, NodeQueryResult<AggregationsToAggregationResults<AggregationInput>>>;
/**
* This function modifies a node.
*/
export declare function modify<A>(repo: RepoConnection, params: NodeModifyParams<A>): IOEither<EnonicError, A & RepoNode>;
export declare function modify<NodeData = Record<string, unknown>>(repo: RepoConnection, params: ModifyNodeParams<NodeData>): IOEither<EnonicError, Node<NodeData>>;
/**
* Get children for given node.
*/
export declare function findChildren(repo: RepoConnection, params: NodeFindChildrenParams): IOEither<EnonicError, NodeQueryResponse>;
export declare function findChildren(repo: RepoConnection, params: FindChildrenParams): IOEither<EnonicError, FindNodesByParentResult>;
"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 = void 0;
var IOEither_1 = require("fp-ts/es6/IOEither");
var errors_1 = require("./errors");
var nodeLib = require("/lib/xp/node");
var array_1 = require("./array");
var function_1 = require("fp-ts/es6/function");
var utils_1 = require("./utils");
/**

@@ -57,3 +61,3 @@ * Creates a connection to a repository with a given branch and authentication info.

function get(repo, keys) {
return (0, errors_1.catchEnonicError)(function () { return repo.get(keys); });
return (0, function_1.pipe)((0, errors_1.catchEnonicError)(function () { return (Array.isArray(keys) ? (0, array_1.forceArray)(repo.get(keys)) : repo.get(keys)); }), (0, IOEither_1.chain)((0, utils_1.fromNullable)(errors_1.notFoundError)));
}

@@ -60,0 +64,0 @@ exports.get = get;

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

/// <reference types="enonic-types" />
import type { KeyPair, SendAsyncParams, SendParams } from "/lib/notifications";

@@ -3,0 +2,0 @@ import { type EnonicError } from "./errors";

{
"name": "enonic-fp",
"version": "0.5.0-next.0",
"version": "0.5.0-next.1",
"sideEffects": false,

@@ -10,3 +10,4 @@ "description": "Functional programming helpers for Enonic XP",

"lint": "eslint --fix 'src/**/*.ts'",
"prepublishOnly": "npm run lint && npm run build"
"prepublishOnly": "npm run lint && npm run build",
"postpublish": "rm ./*.d.ts && rm ./*.js"
},

@@ -28,15 +29,36 @@ "repository": {

"dependencies": {
"enonic-types": "^0.5.0-next.1",
"fp-ts": "^2.12.1"
"@enonic-types/core": "^7.12.2",
"@enonic-types/lib-auth": "^7.12.2",
"@enonic-types/lib-common": "^7.12.2",
"@enonic-types/lib-content": "^7.12.2",
"@enonic-types/lib-context": "^7.12.2",
"@enonic-types/lib-event": "^7.12.2",
"@enonic-types/lib-i18n": "^7.12.2",
"@enonic-types/lib-mail": "^7.12.2",
"@enonic-types/lib-node": "^7.12.2",
"@enonic-types/lib-project": "^7.12.2",
"@enonic-types/lib-portal": "^7.12.2",
"@enonic-types/lib-repo": "^7.12.2",
"@enonic-types/lib-task": "^7.12.2",
"@enonic-types/lib-websocket": "^7.12.2",
"@item-enonic-types/global": "^7.12.2",
"@item-enonic-types/lib-http-client": "^3.2.1",
"@item-enonic-types/lib-menu": "^4.2.0-patch1",
"@item-enonic-types/lib-notifications": "^2.0.0",
"@item-enonic-types/lib-recaptcha": "^3.0.0",
"@item-enonic-types/lib-text-encoding": "^2.1.0",
"@item-enonic-types/lib-thymeleaf": "^2.1.0",
"@item-enonic-types/lib-turbo-streams": "^1.0.4",
"fp-ts": "^2.14.0"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.30.0",
"@typescript-eslint/parser": "^5.30.0",
"eslint": "^8.18.0",
"eslint-config-prettier": "^8.5.0",
"@typescript-eslint/eslint-plugin": "^5.59.1",
"@typescript-eslint/parser": "^5.59.1",
"eslint": "^8.39.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-prettier": "^4.2.1",
"prettier": "^2.7.1",
"rimraf": "^3.0.2",
"typescript": "^4.7.4"
"prettier": "^2.8.8",
"rimraf": "^5.0.0",
"typescript": "^5.0.4"
}
}

@@ -1,8 +0,7 @@

/// <reference types="enonic-types" />
/// <reference types="enonic-types" />
import { IOEither } from "fp-ts/es6/IOEither";
import { type EnonicError } from "./errors";
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<Data>(): IOEither<EnonicError, Content<Data>>;
import type { AssetUrlParams, AttachmentUrlParams, Component, ComponentUrlParams, IdProviderUrlParams, ImageUrlParams, LoginUrlParams, LogoutUrlParams, MultipartItem, PageUrlParams, ProcessHtmlParams, ServiceUrlParams, UrlParams } from "/lib/xp/portal";
import { ImagePlaceholderParams } from "/lib/xp/portal";
export declare function getContent<Hit extends Content<unknown> = Content>(): IOEither<EnonicError, Hit>;
export declare function getComponent<Config extends object = never>(): IOEither<EnonicError, Component<Config>>;

@@ -19,3 +18,3 @@ export declare function getIdProviderKey(): IOEither<EnonicError, string>;

*/
export declare function getMultipartItem(name: string, index?: number): IOEither<EnonicError, MultipartItem | undefined>;
export declare function getMultipartItem(name: string, index?: number): IOEither<EnonicError, MultipartItem | null>;
/**

@@ -25,3 +24,3 @@ * This function returns a data-stream for a named multipart item.

*/
export declare function getMultipartStream(name: string, index?: number): IOEither<EnonicError, ByteSource | undefined>;
export declare function getMultipartStream(name: string, index?: number): IOEither<EnonicError, ByteSource | null>;
/**

@@ -31,7 +30,7 @@ * This function returns the multipart item data as text.

*/
export declare function getMultipartText(name: string, index?: number): IOEither<EnonicError, string | undefined>;
export declare function getSite(): IOEither<EnonicError, Site>;
export declare function getSiteConfig(): IOEither<EnonicError, XP.SiteConfig>;
export declare function getMultipartText(name: string, index?: number): IOEither<EnonicError, string | null>;
export declare function getSite<Config = Record<string, unknown>>(): IOEither<EnonicError, Site<Config>>;
export declare function getSiteConfig<Config = Record<string, unknown>>(): IOEither<EnonicError, Config>;
export declare function idProviderUrl(params: IdProviderUrlParams): string;
export declare function imagePlaceholder(params: ImagePlaceHolderParams): string;
export declare function imagePlaceholder(params: ImagePlaceholderParams): string;
export declare function assetUrl(params: AssetUrlParams): string;

@@ -38,0 +37,0 @@ export declare function assetUrl(path: string): string;

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

function getSite() {
return (0, errors_1.catchEnonicError)(function () { return portalLib.getSite(); });
return (0, function_1.pipe)((0, errors_1.catchEnonicError)(function () { return portalLib.getSite(); }), (0, IOEither_1.chain)((0, utils_1.fromNullable)(errors_1.notFoundError)));
}
exports.getSite = getSite;
function getSiteConfig() {
return (0, errors_1.catchEnonicError)(function () { return portalLib.getSiteConfig(); });
return (0, function_1.pipe)((0, errors_1.catchEnonicError)(function () { return portalLib.getSiteConfig(); }), (0, IOEither_1.chain)((0, utils_1.fromNullable)(errors_1.notFoundError)));
}

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

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

/// <reference types="enonic-types" />
import { IOEither } from "fp-ts/es6/IOEither";
import { type EnonicError } from "./errors";
import type { AddPermissionsParams, CreateProjectParams, DeleteProjectParams, GetProjectParams, ModifyProjectParams, ModifyReadAccessParams, ModifyReadAccessResult, Project, RemovePermissionsParams } from "/lib/xp/project";
export declare function addPermissions(params: AddPermissionsParams): IOEither<EnonicError, boolean>;
export declare function create(params: CreateProjectParams): IOEither<EnonicError, Project>;
import type { AddProjectPermissionsParams, CreateProjectParams, DeleteProjectParams, GetProjectParams, ModifyProjectParams, Project, ProjectPermissions, RemoveProjectPermissionsParams } from "/lib/xp/project";
import { ModifyProjectReadAccessParams, ProjectReadAccess } from "/lib/xp/project";
export declare function addPermissions(params: AddProjectPermissionsParams): IOEither<EnonicError, ProjectPermissions>;
export declare function create<Config extends Record<string, unknown> = Record<string, unknown>>(params: CreateProjectParams<Config>): IOEither<EnonicError, Project<Config>>;
declare function remove(params: DeleteProjectParams): IOEither<EnonicError, boolean>;

@@ -13,4 +13,4 @@ declare function remove(id: string): IOEither<EnonicError, boolean>;

export declare function list(): IOEither<EnonicError, ReadonlyArray<Project>>;
export declare function modify(params: ModifyProjectParams): IOEither<EnonicError, Project>;
export declare function modifyReadAccess(params: ModifyReadAccessParams): IOEither<EnonicError, ModifyReadAccessResult>;
export declare function removePermissions(params: RemovePermissionsParams): IOEither<EnonicError, boolean>;
export declare function modify<Config extends Record<string, unknown> = Record<string, unknown>>(params: ModifyProjectParams<Config>): IOEither<EnonicError, Project<Config>>;
export declare function modifyReadAccess(params: ModifyProjectReadAccessParams): IOEither<EnonicError, ProjectReadAccess>;
export declare function removePermissions(params: RemoveProjectPermissionsParams): IOEither<EnonicError, ProjectPermissions>;

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

function addPermissions(params) {
return (0, errors_1.catchEnonicError)(function () { return projectLib.addPermissions(params); });
return (0, function_1.pipe)((0, errors_1.catchEnonicError)(function () { return projectLib.addPermissions(params); }), (0, IOEither_1.chain)((0, utils_1.fromNullable)(errors_1.notFoundError)));
}

@@ -37,8 +37,8 @@ exports.addPermissions = addPermissions;

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

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

/// <reference types="enonic-types" />
import { IOEither } from "fp-ts/es6/IOEither";

@@ -3,0 +2,0 @@ import { Option } from "fp-ts/es6/Option";

@@ -1,11 +0,10 @@

/// <reference types="enonic-types" />
import { IOEither } from "fp-ts/es6/IOEither";
import { type EnonicError } from "./errors";
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, BranchConfig>;
export declare function get<Data>(id: string): IOEither<EnonicError, RepositoryConfig<Data> | null>;
export declare function list(): IOEither<EnonicError, ReadonlyArray<RepositoryConfig>>;
import type { CreateBranchParams, DeleteBranchParams, RefreshParams, BranchResult, CreateRepositoryParams, Repository } from "/lib/xp/repo";
export declare function create(params: CreateRepositoryParams): IOEither<EnonicError, Repository>;
export declare function createBranch(params: CreateBranchParams): IOEither<EnonicError, BranchResult>;
export declare function get(id: string): IOEither<EnonicError, Repository | null>;
export declare function list(): IOEither<EnonicError, ReadonlyArray<Repository>>;
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<unknown>>;
export declare function refresh(params: RefreshParams): IOEither<EnonicError, void>;

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

/// <reference types="enonic-types" />
import type { ListParams, ProgressParams, TaskInfo, ExecuteFunctionParams, SubmitTaskParams } from "/lib/xp/task";
import { TaskInfo, ExecuteFunctionParams, SubmitTaskParams, ListTasksParams, TaskProgressParams } from "/lib/xp/task";
import { type EnonicError } from "./errors";

@@ -16,3 +15,3 @@ import { IOEither } from "fp-ts/es6/IOEither";

*/
export declare function list(params?: ListParams): IOEither<EnonicError, ReadonlyArray<TaskInfo>>;
export declare function list(params: ListTasksParams): IOEither<EnonicError, ReadonlyArray<TaskInfo>>;
/**

@@ -23,3 +22,3 @@ * Reports progress information from an executing task.

*/
export declare function progress(params: Partial<ProgressParams>): IOEither<EnonicError, void>;
export declare function progress(params: TaskProgressParams): IOEither<EnonicError, void>;
/**

@@ -39,2 +38,2 @@ * Causes the current execution thread to sleep (temporarily cease execution)

*/
export declare function submitTask<Config extends object = never>(params: SubmitTaskParams<Config>): IOEither<EnonicError, string>;
export declare function submitTask<Config extends Record<string, unknown> = Record<string, unknown>>(params: SubmitTaskParams<Config>): IOEither<EnonicError, string>;

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

var errors_1 = require("./errors");
var IOEither_1 = require("fp-ts/es6/IOEither");
var taskLib = require("/lib/xp/task");
var function_1 = require("fp-ts/es6/function");
var utils_1 = require("./utils");
/**

@@ -11,3 +14,3 @@ * Returns the current state and progress details for the specified task.

function get(taskId) {
return (0, errors_1.catchEnonicError)(function () { return taskLib.get(taskId); });
return (0, function_1.pipe)((0, errors_1.catchEnonicError)(function () { return taskLib.get(taskId); }), (0, IOEither_1.chain)((0, utils_1.fromNullable)(errors_1.notFoundError)));
}

@@ -14,0 +17,0 @@ exports.get = get;

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

/// <reference types="enonic-types" />
import { IOEither } from "fp-ts/es6/IOEither";
import type { ResourceKey, ThymeleafRenderOptions } from "/lib/thymeleaf";
import type { ThymeleafRenderOptions } from "/lib/thymeleaf";
import type { ResourceKey } from "@enonic-types/core";
import { type EnonicError } from "./errors";

@@ -5,0 +5,0 @@ export declare function renderUnsafe<A extends object>(view: ResourceKey, model?: A, options?: ThymeleafRenderOptions): string;

@@ -1,11 +0,9 @@

/// <reference types="enonic-types" />
/// <reference types="enonic-types" />
import type { GetWebSocketUrlParams, TurboStreamAction, TurboStreamsLibrary, TurboStreamsParams, TurboStreamsRemoveParams } from "/lib/turbo-streams";
import { IOEither } from "fp-ts/es6/IOEither";
import type { TurboStreamAction, TurboStreamsParams, TurboStreamsRemoveParams } from "/lib/turbo-streams";
import { type EnonicError } from "./errors";
export declare function getLibrary(): TurboStreamsLibrary;
import type { IOEither } from "fp-ts/es6/IOEither";
import type { GetWebSocketUrlParams } from "/lib/turbo-streams/websockets";
import type { Request } from "@item-enonic-types/global/controller";
/**
* Replace the library with a mocked version
*/
export declare function setLibrary(library: TurboStreamsLibrary): void;
/**

@@ -48,3 +46,3 @@ * Append some markup to a target id in the dom

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

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

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getDefaultGroupId = exports.getTurboStreamsMimetype = exports.acceptTurboStreams = exports.serialize = exports.isTurboStreamAction = exports.getUsersPersonalGroupName = exports.getWebSocketUrl = exports.remove = exports.replace = exports.prepend = exports.append = exports.setLibrary = exports.getLibrary = void 0;
exports.getDefaultGroupId = exports.getTurboStreamsMimetype = exports.acceptTurboStreams = exports.serialize = exports.isTurboStreamAction = exports.getUsersPersonalGroupName = exports.getWebSocketUrl = exports.remove = exports.replace = exports.prepend = exports.append = void 0;
var turboStreamsLib = require("/lib/turbo-streams");
var errors_1 = require("./errors");
var lib;
function getLibrary() {
return lib !== null && lib !== void 0 ? lib : Promise.resolve().then(function () { return require("/lib/turbo-streams"); });
}
exports.getLibrary = getLibrary;
/**
* Replace the library with a mocked version
*/
function setLibrary(library) {
lib = library;
}
exports.setLibrary = setLibrary;
/**

@@ -21,3 +13,3 @@ * Append some markup to a target id in the dom

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

@@ -29,3 +21,3 @@ exports.append = append;

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

@@ -37,3 +29,3 @@ exports.prepend = prepend;

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

@@ -45,3 +37,3 @@ exports.replace = replace;

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

@@ -53,3 +45,3 @@ exports.remove = remove;

function getWebSocketUrl(params) {
return getLibrary().getWebSocketUrl(params);
return turboStreamsLib.getWebSocketUrl(params);
}

@@ -61,3 +53,3 @@ exports.getWebSocketUrl = getWebSocketUrl;

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

@@ -78,3 +70,3 @@ exports.getUsersPersonalGroupName = getUsersPersonalGroupName;

function serialize(actions) {
return getLibrary().serialize(actions);
return turboStreamsLib.serialize(actions);
}

@@ -86,3 +78,3 @@ exports.serialize = serialize;

function acceptTurboStreams(req) {
return getLibrary().acceptTurboStreams(req);
return turboStreamsLib.acceptTurboStreams(req);
}

@@ -94,3 +86,3 @@ exports.acceptTurboStreams = acceptTurboStreams;

function getTurboStreamsMimetype() {
return getLibrary().MIME_TYPE_TURBO_STREAMS;
return turboStreamsLib.MIME_TYPE_TURBO_STREAMS;
}

@@ -102,4 +94,4 @@ exports.getTurboStreamsMimetype = getTurboStreamsMimetype;

function getDefaultGroupId() {
return getLibrary().DEFAULT_GROUP_ID;
return turboStreamsLib.DEFAULT_GROUP_ID;
}
exports.getDefaultGroupId = getDefaultGroupId;

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

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

@@ -15,1 +13,10 @@ import * as O from "fp-ts/es6/Option";

export declare function stringToByPath<A>(input: string | A): A | ByPath;
export interface ByKey {
key: string;
}
export interface ById {
id: string;
}
export interface ByPath {
path: string;
}
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