Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

enonic-wizardry

Package Overview
Dependencies
Maintainers
1
Versions
85
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

enonic-wizardry - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

10

es6/content.d.ts
import { Error } from "enonic-fp/lib/common";
import { Either } from "fp-ts/lib/Either";
import { Content } from "enonic-fp/lib/content";
export declare function publishFromDraftToMaster(content: Content): Either<Error, Content>;
export declare function publishContentByKey<T>(key: string): (t: T) => Either<Error, T>;
import { Content, ModifyContentParams, CreateContentParams, DeleteContentParams } from "enonic-fp/lib/content";
export declare function publishFromDraftToMaster<A>(content: Content<A>): Either<Error, Content<A>>;
export declare function publishContentByKey<A>(key: string): (a: A) => Either<Error, A>;
export declare function applyChangesToData<A>(key: string, changes: any): ModifyContentParams<A>;
export declare function createAndPublish<A>(params: CreateContentParams<A>): Either<Error, Content<A>>;
export declare function deleteAndPublish(params: DeleteContentParams): Either<Error, boolean>;
export declare function modifyAndPublish<A>(key: string, changes: any): Either<Error, Content<A>>;

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

import { map } from "fp-ts/lib/Either";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
import { map, chain } from "fp-ts/lib/Either";
import { pipe } from "fp-ts/lib/pipeable";
import { publish } from "enonic-fp/lib/content";
import { publish, create, remove, modify } from "enonic-fp/lib/content";
import { runInDraftContext } from './context';
export function publishFromDraftToMaster(content) {

@@ -12,3 +24,3 @@ return pipe(publish({

export function publishContentByKey(key) {
return function (t) {
return function (a) {
return pipe(publish({

@@ -18,4 +30,23 @@ keys: [key],

targetBranch: 'master',
}), map(function () { return t; }));
}), map(function () { return a; }));
};
}
export function applyChangesToData(key, changes) {
return {
key: key,
editor: function (content) {
content.data = __assign({}, content.data, changes);
return content;
},
requireValid: true
};
}
export function createAndPublish(params) {
return pipe(runInDraftContext(create)(params), chain(publishFromDraftToMaster));
}
export function deleteAndPublish(params) {
return pipe(runInDraftContext(remove)(params), chain(publishContentByKey(params.key)));
}
export function modifyAndPublish(key, changes) {
return pipe(runInDraftContext(modify)(applyChangesToData(key, changes)), chain(publishFromDraftToMaster));
}

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

export declare function runAsSuperUser<T>(f: () => T): T;
export declare function runInDraftContext<T>(f: () => T): T;
export declare function runAsSuperUser<A, B>(f: (p: A) => B): (p: A) => B;
export declare function runInDraftContext<A, B>(f: (p: A) => B): (p: A) => B;
import * as context from "enonic-fp/lib/context";
export function runAsSuperUser(f) {
return context.run({
return function (params) { return context.run({
repository: 'com.enonic.cms.default',

@@ -11,8 +11,8 @@ branch: 'draft',

principals: ["role:system.admin"]
}, f);
}, function () { return f(params); }); };
}
export function runInDraftContext(f) {
return context.run({
return function (params) { return context.run({
branch: 'draft'
}, f);
}, function () { return f(params); }); };
}
import { Error } from "enonic-fp/lib/common";
import { Either } from "fp-ts/lib/Either";
import { Content } from "enonic-fp/lib/content";
export declare function publishFromDraftToMaster(content: Content): Either<Error, Content>;
export declare function publishContentByKey<T>(key: string): (t: T) => Either<Error, T>;
import { Content, ModifyContentParams, CreateContentParams, DeleteContentParams } from "enonic-fp/lib/content";
export declare function publishFromDraftToMaster<A>(content: Content<A>): Either<Error, Content<A>>;
export declare function publishContentByKey<A>(key: string): (a: A) => Either<Error, A>;
export declare function applyChangesToData<A>(key: string, changes: any): ModifyContentParams<A>;
export declare function createAndPublish<A>(params: CreateContentParams<A>): Either<Error, Content<A>>;
export declare function deleteAndPublish(params: DeleteContentParams): Either<Error, boolean>;
export declare function modifyAndPublish<A>(key: string, changes: any): Either<Error, Content<A>>;
"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -6,2 +17,3 @@ var Either_1 = require("fp-ts/lib/Either");

var content_1 = require("enonic-fp/lib/content");
var context_1 = require("./context");
function publishFromDraftToMaster(content) {

@@ -16,3 +28,3 @@ return pipeable_1.pipe(content_1.publish({

function publishContentByKey(key) {
return function (t) {
return function (a) {
return pipeable_1.pipe(content_1.publish({

@@ -22,5 +34,28 @@ keys: [key],

targetBranch: 'master',
}), Either_1.map(function () { return t; }));
}), Either_1.map(function () { return a; }));
};
}
exports.publishContentByKey = publishContentByKey;
function applyChangesToData(key, changes) {
return {
key: key,
editor: function (content) {
content.data = __assign({}, content.data, changes);
return content;
},
requireValid: true
};
}
exports.applyChangesToData = applyChangesToData;
function createAndPublish(params) {
return pipeable_1.pipe(context_1.runInDraftContext(content_1.create)(params), Either_1.chain(publishFromDraftToMaster));
}
exports.createAndPublish = createAndPublish;
function deleteAndPublish(params) {
return pipeable_1.pipe(context_1.runInDraftContext(content_1.remove)(params), Either_1.chain(publishContentByKey(params.key)));
}
exports.deleteAndPublish = deleteAndPublish;
function modifyAndPublish(key, changes) {
return pipeable_1.pipe(context_1.runInDraftContext(content_1.modify)(applyChangesToData(key, changes)), Either_1.chain(publishFromDraftToMaster));
}
exports.modifyAndPublish = modifyAndPublish;

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

export declare function runAsSuperUser<T>(f: () => T): T;
export declare function runInDraftContext<T>(f: () => T): T;
export declare function runAsSuperUser<A, B>(f: (p: A) => B): (p: A) => B;
export declare function runInDraftContext<A, B>(f: (p: A) => B): (p: A) => B;

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

function runAsSuperUser(f) {
return context.run({
return function (params) { return context.run({
repository: 'com.enonic.cms.default',

@@ -14,10 +14,10 @@ branch: 'draft',

principals: ["role:system.admin"]
}, f);
}, function () { return f(params); }); };
}
exports.runAsSuperUser = runAsSuperUser;
function runInDraftContext(f) {
return context.run({
return function (params) { return context.run({
branch: 'draft'
}, f);
}, function () { return f(params); }); };
}
exports.runInDraftContext = runInDraftContext;
{
"name": "enonic-wizardry",
"version": "0.0.2",
"version": "0.0.3",
"description": "Functional utility library for Enonic XP",

@@ -27,3 +27,3 @@ "main": "lib/index.js",

"dependencies": {
"enonic-fp": "^0.0.3",
"enonic-fp": "^0.0.8",
"fp-ts": "^2.0.5"

@@ -30,0 +30,0 @@ },

# Enonic Wizardry
[![npm version](https://badge.fury.io/js/enonic-wizardry.svg)](https://badge.fury.io/js/enonic-wizardry)
Functional utility library for Enonic XP
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